summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--EdkCompatibilityPkg/EDK_Snapshot.txt10
-rw-r--r--EdkCompatibilityPkg/EdkCompatibilityPkg.dec2
-rw-r--r--EdkCompatibilityPkg/Foundation/Cpu/Pentium/CpuIA32Lib/IA32/CpuIA32.S4
-rw-r--r--EdkCompatibilityPkg/Foundation/Cpu/Pentium/CpuIA32Lib/IA32/CpuIA32.asm4
-rw-r--r--EdkCompatibilityPkg/Foundation/Cpu/Pentium/CpuIA32Lib/IA32/CpuIA32.c4
-rw-r--r--EdkCompatibilityPkg/Foundation/Cpu/Pentium/CpuIA32Lib/X64/Cpu.S4
-rw-r--r--EdkCompatibilityPkg/Foundation/Cpu/Pentium/CpuIA32Lib/X64/Cpu.asm4
-rw-r--r--EdkCompatibilityPkg/Foundation/Efi/Include/EfiDevicePath.h25
-rw-r--r--EdkCompatibilityPkg/Foundation/Efi/Include/EfiError.h5
-rw-r--r--EdkCompatibilityPkg/Foundation/Efi/Include/EfiHii.h48
-rw-r--r--EdkCompatibilityPkg/Foundation/Efi/Include/EfiImage.h44
-rw-r--r--EdkCompatibilityPkg/Foundation/Efi/Include/EfiTypes.h6
-rw-r--r--EdkCompatibilityPkg/Foundation/Efi/Protocol/BlockIo/BlockIo.h11
-rw-r--r--EdkCompatibilityPkg/Foundation/Efi/Protocol/ComponentName2/ComponentName2.h29
-rw-r--r--EdkCompatibilityPkg/Foundation/Efi/Protocol/EfiProtocolLib.inf4
-rw-r--r--EdkCompatibilityPkg/Foundation/Efi/Protocol/HiiDatabase/HiiDatabase.h16
-rw-r--r--EdkCompatibilityPkg/Foundation/Efi/Protocol/HiiFont/HiiFont.h76
-rw-r--r--EdkCompatibilityPkg/Foundation/Efi/Protocol/HiiImage/HiiImage.h20
-rw-r--r--EdkCompatibilityPkg/Foundation/Efi/Protocol/HiiPackageList/HiiPackageList.c27
-rw-r--r--EdkCompatibilityPkg/Foundation/Efi/Protocol/HiiPackageList/HiiPackageList.h36
-rw-r--r--EdkCompatibilityPkg/Foundation/Efi/Protocol/HiiString/HiiString.h29
-rw-r--r--EdkCompatibilityPkg/Foundation/Efi/Protocol/Ip4/Ip4.h6
-rw-r--r--EdkCompatibilityPkg/Foundation/Efi/Protocol/SimpleFileSystem/SimpleFileSystem.h8
-rw-r--r--EdkCompatibilityPkg/Foundation/Framework/Guid/DataHubRecords/DataHubSubClassMemory.h28
-rw-r--r--EdkCompatibilityPkg/Foundation/Framework/Guid/DataHubRecords/DataHubSubClassMisc.h90
-rw-r--r--EdkCompatibilityPkg/Foundation/Framework/Guid/DataHubRecords/DataHubSubClassProcessor.h55
-rw-r--r--EdkCompatibilityPkg/Foundation/Framework/Include/EfiCapsule.h8
-rw-r--r--EdkCompatibilityPkg/Foundation/Framework/Include/EfiPciCfg.h11
-rw-r--r--EdkCompatibilityPkg/Foundation/Framework/Include/PeiApi.h10
-rw-r--r--EdkCompatibilityPkg/Foundation/Framework/Include/TianoSpecDevicePath.h25
-rw-r--r--EdkCompatibilityPkg/Foundation/Framework/Ppi/EdkFrameworkPpiLib.inf7
-rw-r--r--EdkCompatibilityPkg/Foundation/Framework/Ppi/FirmwareVolume/FirmwareVolume.h4
-rw-r--r--EdkCompatibilityPkg/Foundation/Framework/Ppi/LoadedImage/LoadedImage.c30
-rw-r--r--EdkCompatibilityPkg/Foundation/Framework/Ppi/LoadedImage/LoadedImage.h56
-rw-r--r--EdkCompatibilityPkg/Foundation/Framework/Ppi/TemporaryRamSupport/TemporaryRamSupport.c30
-rw-r--r--EdkCompatibilityPkg/Foundation/Framework/Ppi/TemporaryRamSupport/TemporaryRamSupport.h66
-rw-r--r--EdkCompatibilityPkg/Foundation/Framework/Protocol/FirmwareVolumeBlock/FirmwareVolumeBlock.c4
-rw-r--r--EdkCompatibilityPkg/Foundation/Framework/Protocol/FirmwareVolumeBlock/FirmwareVolumeBlock.h4
-rw-r--r--EdkCompatibilityPkg/Foundation/Framework/Protocol/IdeControllerInit/IdeControllerInit.h13
-rw-r--r--EdkCompatibilityPkg/Foundation/Guid/AcpiDescription/AcpiDescription.h4
-rw-r--r--EdkCompatibilityPkg/Foundation/Guid/PciOptionRomTable/PciOptionRomTable.h3
-rw-r--r--EdkCompatibilityPkg/Foundation/Guid/PeiPeCoffLoader/PeiPeCoffLoader.h5
-rw-r--r--EdkCompatibilityPkg/Foundation/Include/EfiSpec.h14
-rw-r--r--EdkCompatibilityPkg/Foundation/Include/EfiTpm.h7
-rw-r--r--EdkCompatibilityPkg/Foundation/Include/IndustryStandard/Smbios.h28
-rw-r--r--EdkCompatibilityPkg/Foundation/Include/IndustryStandard/Tpm12.h158
-rw-r--r--EdkCompatibilityPkg/Foundation/Include/IndustryStandard/pci23.h12
-rw-r--r--EdkCompatibilityPkg/Foundation/Include/IndustryStandard/scsi.h24
-rw-r--r--EdkCompatibilityPkg/Foundation/Include/Tiano.h12
-rw-r--r--EdkCompatibilityPkg/Foundation/Include/TianoHii.h7
-rw-r--r--EdkCompatibilityPkg/Foundation/Library/CompilerStub/CompilerStubLib.inf6
-rw-r--r--EdkCompatibilityPkg/Foundation/Library/CompilerStub/CompilerStubLib_Edk2.inf4
-rw-r--r--EdkCompatibilityPkg/Foundation/Library/Dxe/EfiDriverLib/DevicePath.c29
-rw-r--r--EdkCompatibilityPkg/Foundation/Library/Dxe/EfiDriverLib/EfiDriverLib.c179
-rw-r--r--EdkCompatibilityPkg/Foundation/Library/Dxe/EfiDriverLib/ReportStatusCode.c101
-rw-r--r--EdkCompatibilityPkg/Foundation/Library/Dxe/EfiIfrSupportLib/EfiIfrSupportLib.inf3
-rw-r--r--EdkCompatibilityPkg/Foundation/Library/Dxe/EfiScriptLib/EfiScriptLib.inf1
-rw-r--r--EdkCompatibilityPkg/Foundation/Library/Dxe/EfiUiLib/EfiUiLib.c5
-rw-r--r--EdkCompatibilityPkg/Foundation/Library/Dxe/Include/EfiDriverLib.h18
-rw-r--r--EdkCompatibilityPkg/Foundation/Library/Dxe/Include/EfiUiLib.h31
-rw-r--r--EdkCompatibilityPkg/Foundation/Library/Dxe/UefiEfiIfrSupportLib/UefiEfiIfrSupportLib.inf3
-rw-r--r--EdkCompatibilityPkg/Foundation/Library/Dxe/UefiEfiIfrSupportLib/UefiIfrCommon.c154
-rw-r--r--EdkCompatibilityPkg/Foundation/Library/Dxe/UefiEfiIfrSupportLib/UefiIfrForm.c805
-rw-r--r--EdkCompatibilityPkg/Foundation/Library/Dxe/UefiEfiIfrSupportLib/UefiIfrLibrary.h222
-rw-r--r--EdkCompatibilityPkg/Foundation/Library/Dxe/UefiEfiIfrSupportLib/UefiIfrOpCodeCreation.c6
-rw-r--r--EdkCompatibilityPkg/Foundation/Library/Dxe/UefiEfiIfrSupportLib/UefiIfrString.c35
-rw-r--r--EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/EntryPoints/EdkIIGlueDxeDriverEntryPoint.c160
-rw-r--r--EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/EntryPoints/EdkIIGlueSmmDriverEntryPoint.c95
-rw-r--r--EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Include/Common/EdkIIGlueDependencies.h18
-rw-r--r--EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Include/EdkIIGlueConfig.h13
-rw-r--r--EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Include/EdkIIGlueUefi.h4
-rw-r--r--EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Include/Library/EdkIIGlueUefiDriverModelLib.h19
-rw-r--r--EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Include/Library/EdkIIGlueUefiLib.h18
-rw-r--r--EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/BaseMemoryLib/CompareMemWrapper.c4
-rw-r--r--EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/EdkDxeRuntimeDriverLib/Common/RuntimeLib.c15
-rw-r--r--EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/EdkDxeRuntimeDriverLib/Common/RuntimeService.c32
-rw-r--r--EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/EdkDxeRuntimeDriverLib/Ipf/RuntimeLib.c8
-rw-r--r--EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/EdkDxeRuntimeDriverLib/Ipf/RuntimeService.c6
-rw-r--r--EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/EdkDxeRuntimeDriverLib/RuntimeLibInternal.h4
-rw-r--r--EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/UefiDriverModelLib/UefiDriverModelLib.c257
-rw-r--r--EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/UefiLib/UefiLib.c166
-rw-r--r--EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/UefiLib/UefiNotTiano.c100
-rw-r--r--EdkCompatibilityPkg/Foundation/Library/EfiCommonLib/EfiCommonLib.inf4
-rw-r--r--EdkCompatibilityPkg/Foundation/Library/EfiCommonLib/EfiCommonLib_Edk2.inf6
-rw-r--r--EdkCompatibilityPkg/Foundation/Library/EfiCommonLib/Ia32/EfiCopyMem.S6
-rw-r--r--EdkCompatibilityPkg/Foundation/Library/EfiCommonLib/Ia32/EfiCopyMem.asm6
-rw-r--r--EdkCompatibilityPkg/Foundation/Library/EfiCommonLib/Ia32/EfiCopyMem.c9
-rw-r--r--EdkCompatibilityPkg/Foundation/Library/EfiCommonLib/Ia32/EfiCopyMemSSE2.c10
-rw-r--r--EdkCompatibilityPkg/Foundation/Library/EfiCommonLib/Ia32/Power10U64.S2
-rw-r--r--EdkCompatibilityPkg/Foundation/Library/EfiCommonLib/Ia32/Power10U64.asm2
-rw-r--r--EdkCompatibilityPkg/Foundation/Library/EfiCommonLib/Ia32/Power10U64.c4
-rw-r--r--EdkCompatibilityPkg/Foundation/Library/EfiCommonLib/Math.c17
-rw-r--r--EdkCompatibilityPkg/Foundation/Library/EfiCommonLib/Misc.c14
-rw-r--r--EdkCompatibilityPkg/Foundation/Library/Pei/Include/PeiLib.h12
-rw-r--r--EdkCompatibilityPkg/Foundation/Library/Pei/PeiLib/PeCoffLoader.c82
-rw-r--r--EdkCompatibilityPkg/Foundation/Library/Pei/PeiLib/PeiLib.c16
-rw-r--r--EdkCompatibilityPkg/Foundation/Library/Pei/PeiLib/X64/EfiJump.h4
-rw-r--r--EdkCompatibilityPkg/Foundation/Library/Pei/PeiLib/X64/Processor.c5
-rw-r--r--EdkCompatibilityPkg/Foundation/Library/Pei/PeiLib/X64/ProcessorAsms.Asm30
-rw-r--r--EdkCompatibilityPkg/Foundation/Library/Pei/PeiLib/X64/ProcessorAsms.S30
-rw-r--r--EdkCompatibilityPkg/Foundation/Library/RuntimeDxe/EfiRuntimeLib/Ia32/RuntimeLib.c176
-rw-r--r--EdkCompatibilityPkg/Foundation/Library/RuntimeDxe/EfiRuntimeLib/RtDevicePath.c30
-rw-r--r--EdkCompatibilityPkg/Foundation/Library/RuntimeDxe/EfiRuntimeLib/X64/RuntimeLib.c176
-rw-r--r--EdkCompatibilityPkg/Foundation/Library/Thunk16/Ia32/Fx.S24
-rw-r--r--EdkCompatibilityPkg/Foundation/Library/Thunk16/Ia32/Fx.asm26
-rw-r--r--EdkCompatibilityPkg/Foundation/Library/Thunk16/Ia32/Thunk16.S18
-rw-r--r--EdkCompatibilityPkg/Foundation/Library/Thunk16/Ia32/Thunk16.asm21
-rw-r--r--EdkCompatibilityPkg/Foundation/Library/Thunk16/Thunk16Lib.h9
-rw-r--r--EdkCompatibilityPkg/Foundation/Library/Thunk16/X64/Fx.S26
-rw-r--r--EdkCompatibilityPkg/Foundation/Library/Thunk16/X64/Fx.asm26
-rw-r--r--EdkCompatibilityPkg/Foundation/Library/Thunk16/X64/Thunk16.S20
-rw-r--r--EdkCompatibilityPkg/Foundation/Library/Thunk16/X64/Thunk16.asm24
-rw-r--r--EdkCompatibilityPkg/Foundation/Library/Thunk16/X86Thunk.c96
-rw-r--r--EdkCompatibilityPkg/Foundation/Protocol/ConsoleControl/ConsoleControl.h4
-rw-r--r--EdkCompatibilityPkg/Foundation/Protocol/NicIp4Config/NicIp4Config.h4
-rw-r--r--EdkCompatibilityPkg/Foundation/Protocol/TcgService/TcgService.h17
-rw-r--r--EdkCompatibilityPkg/Sample/CommonTools.env23
-rw-r--r--EdkCompatibilityPkg/Sample/Platform/Common.dsc173
-rw-r--r--EdkCompatibilityPkg/Sample/Platform/EdkIIGlueLibAll.dsc3
-rw-r--r--EdkCompatibilityPkg/Sample/Platform/Generic/Pei/Capsule/Capsule.h15
-rw-r--r--EdkCompatibilityPkg/Sample/Tools/Source/Common/FvLib.c11
-rw-r--r--EdkCompatibilityPkg/Sample/Tools/Source/Common/ParseInf.c148
-rw-r--r--EdkCompatibilityPkg/Sample/Tools/Source/Common/ParseInf.h38
-rw-r--r--EdkCompatibilityPkg/Sample/Tools/Source/EfiCompress/EfiCompressMain.c51
-rw-r--r--EdkCompatibilityPkg/Sample/Tools/Source/EfiRom/EfiRom.c66
-rw-r--r--EdkCompatibilityPkg/Sample/Tools/Source/FwImage/fwimage.c36
-rw-r--r--EdkCompatibilityPkg/Sample/Tools/Source/GenAprioriFile/GenAprioriFile.c35
-rw-r--r--EdkCompatibilityPkg/Sample/Tools/Source/GenCRC32Section/GenCRC32Section.c32
-rw-r--r--EdkCompatibilityPkg/Sample/Tools/Source/GenDepex/GenDepex.c59
-rw-r--r--EdkCompatibilityPkg/Sample/Tools/Source/GenDepex/GenDepex.h12
-rw-r--r--EdkCompatibilityPkg/Sample/Tools/Source/GenFfsFile/GenFfsFile.c219
-rw-r--r--EdkCompatibilityPkg/Sample/Tools/Source/GenFvImage/GenFvImageExe.c37
-rw-r--r--EdkCompatibilityPkg/Sample/Tools/Source/GenFvImage/GenFvImageExe.h5
-rw-r--r--EdkCompatibilityPkg/Sample/Tools/Source/GenFvImage/GenFvImageLib.c475
-rw-r--r--EdkCompatibilityPkg/Sample/Tools/Source/GenFvImage/GenFvImageLibInternal.h8
-rw-r--r--EdkCompatibilityPkg/Sample/Tools/Source/GenSection/GenSection.c48
-rw-r--r--EdkCompatibilityPkg/Sample/Tools/Source/GenTEImage/GenTEImage.c37
-rw-r--r--EdkCompatibilityPkg/Sample/Tools/Source/GuidChk/GuidChk.c48
-rw-r--r--EdkCompatibilityPkg/Sample/Tools/Source/HiiPack/FindFiles.c208
-rw-r--r--EdkCompatibilityPkg/Sample/Tools/Source/HiiPack/HiiPack.c2561
-rw-r--r--EdkCompatibilityPkg/Sample/Tools/Source/HiiPack/HiiPack.h63
-rw-r--r--EdkCompatibilityPkg/Sample/Tools/Source/HiiPack/IfrParse.c2533
-rw-r--r--EdkCompatibilityPkg/Sample/Tools/Source/HiiPack/IfrParse.h267
-rw-r--r--EdkCompatibilityPkg/Sample/Tools/Source/HiiPack/Makefile103
-rw-r--r--EdkCompatibilityPkg/Sample/Tools/Source/HiiPack/StringParse.c244
-rw-r--r--EdkCompatibilityPkg/Sample/Tools/Source/HiiPack/StringParse.h125
-rw-r--r--EdkCompatibilityPkg/Sample/Tools/Source/MakeDeps/MakeDeps.c53
-rw-r--r--EdkCompatibilityPkg/Sample/Tools/Source/Makefile4
-rw-r--r--EdkCompatibilityPkg/Sample/Tools/Source/ModifyInf/ModifyInf.c21
-rw-r--r--EdkCompatibilityPkg/Sample/Tools/Source/ProcessDsc/FWVolume.c80
-rw-r--r--EdkCompatibilityPkg/Sample/Tools/Source/ProcessDsc/Makefile27
-rw-r--r--EdkCompatibilityPkg/Sample/Tools/Source/ProcessDsc/MultiThread.c905
-rw-r--r--EdkCompatibilityPkg/Sample/Tools/Source/ProcessDsc/MultiThread.h116
-rw-r--r--EdkCompatibilityPkg/Sample/Tools/Source/ProcessDsc/ProcessDsc.c326
-rw-r--r--EdkCompatibilityPkg/Sample/Tools/Source/SetStamp/SetStamp.c28
-rw-r--r--EdkCompatibilityPkg/Sample/Tools/Source/SplitFile/splitfile.c28
-rw-r--r--EdkCompatibilityPkg/Sample/Tools/Source/StrGather/StrGather.c164
-rw-r--r--EdkCompatibilityPkg/Sample/Tools/Source/StrGather/StrGather.h4
-rw-r--r--EdkCompatibilityPkg/Sample/Tools/Source/StrGather/StringDB.c27
-rw-r--r--EdkCompatibilityPkg/Sample/Tools/Source/StrGather/StringDB.h49
-rw-r--r--EdkCompatibilityPkg/Sample/Tools/Source/Strip/strip.c48
-rw-r--r--EdkCompatibilityPkg/Sample/Tools/Source/UefiHiiPack/HiiPack.c740
-rw-r--r--EdkCompatibilityPkg/Sample/Tools/Source/UefiHiiPack/Makefile71
-rw-r--r--EdkCompatibilityPkg/Sample/Tools/Source/UefiStrGather/StrGather.c564
-rw-r--r--EdkCompatibilityPkg/Sample/Tools/Source/UefiStrGather/StrGather.h4
-rw-r--r--EdkCompatibilityPkg/Sample/Tools/Source/UefiStrGather/StringDB.c94
-rw-r--r--EdkCompatibilityPkg/Sample/Tools/Source/UefiStrGather/StringDB.h60
-rw-r--r--EdkCompatibilityPkg/Sample/Tools/Source/UefiVfrCompile/EfiVfr.h4
-rw-r--r--EdkCompatibilityPkg/Sample/Tools/Source/UefiVfrCompile/VfrCompiler.cpp133
-rw-r--r--EdkCompatibilityPkg/Sample/Tools/Source/UefiVfrCompile/VfrCompiler.h11
-rw-r--r--EdkCompatibilityPkg/Sample/Tools/Source/UefiVfrCompile/VfrError.cpp80
-rw-r--r--EdkCompatibilityPkg/Sample/Tools/Source/UefiVfrCompile/VfrError.h8
-rw-r--r--EdkCompatibilityPkg/Sample/Tools/Source/UefiVfrCompile/VfrFormPkg.cpp107
-rw-r--r--EdkCompatibilityPkg/Sample/Tools/Source/UefiVfrCompile/VfrFormPkg.h198
-rw-r--r--EdkCompatibilityPkg/Sample/Tools/Source/UefiVfrCompile/VfrSyntax.g1001
-rw-r--r--EdkCompatibilityPkg/Sample/Tools/Source/UefiVfrCompile/VfrUtilityLib.cpp424
-rw-r--r--EdkCompatibilityPkg/Sample/Tools/Source/UefiVfrCompile/VfrUtilityLib.h68
-rw-r--r--EdkCompatibilityPkg/Sample/Tools/Source/UefiVfrCompile/makefile5
-rw-r--r--EdkCompatibilityPkg/Sample/Tools/Source/VfrCompile/EfiVfr.h6
-rw-r--r--EdkCompatibilityPkg/Sample/Tools/Source/VfrCompile/VfrCompile.g83
-rw-r--r--EdkCompatibilityPkg/Sample/Tools/Source/VfrCompile/VfrServices.cpp16
-rw-r--r--EdkCompatibilityPkg/Sample/Tools/Source/VfrCompile/makefile4
-rw-r--r--EdkCompatibilityPkg/Sample/Version.env4
183 files changed, 15238 insertions, 2624 deletions
diff --git a/EdkCompatibilityPkg/EDK_Snapshot.txt b/EdkCompatibilityPkg/EDK_Snapshot.txt
deleted file mode 100644
index efc15da456..0000000000
--- a/EdkCompatibilityPkg/EDK_Snapshot.txt
+++ /dev/null
@@ -1,10 +0,0 @@
-Notes:
- This EDK Compatibility Package is based on the EDK 1.03 release found at http://edk.tianocore.org.
- It is compatibile with EDK 1.01 with the following exception:
-
-
-13:49 2008-1-24
-
- This Edk Compatibility Package is updated to the EDK 1.04 release found at http://edk.tianocore.org.
-
- \ No newline at end of file
diff --git a/EdkCompatibilityPkg/EdkCompatibilityPkg.dec b/EdkCompatibilityPkg/EdkCompatibilityPkg.dec
index bda1bcd7b7..6240bfde57 100644
--- a/EdkCompatibilityPkg/EdkCompatibilityPkg.dec
+++ b/EdkCompatibilityPkg/EdkCompatibilityPkg.dec
@@ -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.
# EdkCompatibilityPkg is based on the EDK 1.01 release, found at http://edk.tianocore.org. This package only
# 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.
-# This package also incorporates bug fixes released in EDK 1.04.
+# This package also incorporates bug fixes released in EDK 1.06.
#
# Copyright (c) 2008 - 2010, Intel Corporation. All rights reserved.<BR>
#
diff --git a/EdkCompatibilityPkg/Foundation/Cpu/Pentium/CpuIA32Lib/IA32/CpuIA32.S b/EdkCompatibilityPkg/Foundation/Cpu/Pentium/CpuIA32Lib/IA32/CpuIA32.S
index 35cb4957c4..acc2b2e9c9 100644
--- a/EdkCompatibilityPkg/Foundation/Cpu/Pentium/CpuIA32Lib/IA32/CpuIA32.S
+++ b/EdkCompatibilityPkg/Foundation/Cpu/Pentium/CpuIA32Lib/IA32/CpuIA32.S
@@ -1,6 +1,6 @@
#/*++
#
-#Copyright (c) 2006, Intel Corporation. All rights reserved.<BR>
+#Copyright (c) 2006 - 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
@@ -157,7 +157,7 @@ L2:
# VOID
# )
ASM_PFX(EfiEnableCache):
- invd
+ wbinvd
movl %cr0, %eax
andl $0x9fffffff, %eax
movl %eax, %cr0
diff --git a/EdkCompatibilityPkg/Foundation/Cpu/Pentium/CpuIA32Lib/IA32/CpuIA32.asm b/EdkCompatibilityPkg/Foundation/Cpu/Pentium/CpuIA32Lib/IA32/CpuIA32.asm
index 38d3c49744..878be4d80a 100644
--- a/EdkCompatibilityPkg/Foundation/Cpu/Pentium/CpuIA32Lib/IA32/CpuIA32.asm
+++ b/EdkCompatibilityPkg/Foundation/Cpu/Pentium/CpuIA32Lib/IA32/CpuIA32.asm
@@ -1,6 +1,6 @@
;/*++
;
-;Copyright (c) 2006, Intel Corporation. All rights reserved.<BR>
+;Copyright (c) 2006 - 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
@@ -140,7 +140,7 @@ EfiDisableCache ENDP
; VOID
; )
EfiEnableCache PROC C PUBLIC
- invd
+ wbinvd
mov eax, cr0
and eax, 09fffffffh
mov cr0, eax
diff --git a/EdkCompatibilityPkg/Foundation/Cpu/Pentium/CpuIA32Lib/IA32/CpuIA32.c b/EdkCompatibilityPkg/Foundation/Cpu/Pentium/CpuIA32Lib/IA32/CpuIA32.c
index 6572bbd8f5..b4dc7e0b22 100644
--- a/EdkCompatibilityPkg/Foundation/Cpu/Pentium/CpuIA32Lib/IA32/CpuIA32.c
+++ b/EdkCompatibilityPkg/Foundation/Cpu/Pentium/CpuIA32Lib/IA32/CpuIA32.c
@@ -1,6 +1,6 @@
/*++
-Copyright (c) 2006, Intel Corporation. All rights reserved.<BR>
+Copyright (c) 2006 - 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
@@ -118,7 +118,7 @@ VOID
EfiEnableCache (VOID)
{
__asm {
- invd
+ wbinvd
mov eax, cr0
and eax, 09fffffffh
mov cr0, eax
diff --git a/EdkCompatibilityPkg/Foundation/Cpu/Pentium/CpuIA32Lib/X64/Cpu.S b/EdkCompatibilityPkg/Foundation/Cpu/Pentium/CpuIA32Lib/X64/Cpu.S
index 380ff936a1..38c663e131 100644
--- a/EdkCompatibilityPkg/Foundation/Cpu/Pentium/CpuIA32Lib/X64/Cpu.S
+++ b/EdkCompatibilityPkg/Foundation/Cpu/Pentium/CpuIA32Lib/X64/Cpu.S
@@ -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
@@ -151,7 +151,7 @@ ASM_PFX(EfiDisableCache):
# );
#------------------------------------------------------------------------------
ASM_PFX(EfiEnableCache):
- invd
+ wbinvd
mov %cr0,%rax
and $0xffffffff9fffffff,%rax
mov %rax,%cr0
diff --git a/EdkCompatibilityPkg/Foundation/Cpu/Pentium/CpuIA32Lib/X64/Cpu.asm b/EdkCompatibilityPkg/Foundation/Cpu/Pentium/CpuIA32Lib/X64/Cpu.asm
index ab4daedfdc..adb0fa73f3 100644
--- a/EdkCompatibilityPkg/Foundation/Cpu/Pentium/CpuIA32Lib/X64/Cpu.asm
+++ b/EdkCompatibilityPkg/Foundation/Cpu/Pentium/CpuIA32Lib/X64/Cpu.asm
@@ -2,7 +2,7 @@ TITLE Cpu.asm: Assembly code for the x64 resources
;------------------------------------------------------------------------------
;*
-;* Copyright (c) 2005 - 2007, Intel Corporation. All rights reserved.<BR>
+;* Copyright (c) 2005 - 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
@@ -150,7 +150,7 @@ EfiDisableCache ENDP
; );
;------------------------------------------------------------------------------
EfiEnableCache PROC PUBLIC
- invd
+ wbinvd
mov rax, cr0
and rax, 09fffffffh
mov cr0, rax
diff --git a/EdkCompatibilityPkg/Foundation/Efi/Include/EfiDevicePath.h b/EdkCompatibilityPkg/Foundation/Efi/Include/EfiDevicePath.h
index ea54c4bc0f..4bde7d2610 100644
--- a/EdkCompatibilityPkg/Foundation/Efi/Include/EfiDevicePath.h
+++ b/EdkCompatibilityPkg/Foundation/Efi/Include/EfiDevicePath.h
@@ -1,6 +1,6 @@
/*++
-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
@@ -214,7 +214,6 @@ typedef struct {
UINT8 DeviceProtocol;
} USB_CLASS_DEVICE_PATH;
-#if (EFI_SPECIFICATION_VERSION >= 0x00020000)
#define MSG_USB_WWID_DP 0x10
typedef struct {
EFI_DEVICE_PATH_PROTOCOL Header;
@@ -231,7 +230,6 @@ typedef struct {
EFI_DEVICE_PATH_PROTOCOL Header;
UINT8 Lun;
} DEVICE_LOGICAL_UNIT_DEVICE_PATH;
-#endif
#define MSG_SATA_DP 0x12
typedef struct {
@@ -330,8 +328,6 @@ typedef struct {
UINT32 FlowControlMap;
} UART_FLOW_CONTROL_DEVICE_PATH;
-#if (EFI_SPECIFICATION_VERSION >= 0x00020000)
-
#define DEVICE_PATH_MESSAGING_SAS \
{ 0xd487ddb4, 0x008b, 0x11d9, {0xaf, 0xdc, 0x00, 0x10, 0x83, 0xff, 0xca, 0x4d} }
@@ -345,8 +341,6 @@ typedef struct {
UINT16 RelativeTargetPort;
} SAS_DEVICE_PATH;
-#endif
-
#define MSG_ISCSI_DP 0x13
typedef struct {
EFI_DEVICE_PATH_PROTOCOL Header;
@@ -428,8 +422,6 @@ typedef struct {
EFI_GUID Protocol;
} MEDIA_PROTOCOL_DEVICE_PATH;
-#if (EFI_SPECIFICATION_VERSION >= 0x0002000A)
-
#define MEDIA_FV_DP 0x07
typedef struct {
EFI_DEVICE_PATH_PROTOCOL Header;
@@ -449,7 +441,6 @@ typedef struct {
UINT64 StartingOffset;
UINT64 EndingOffset;
} MEDIA_RELATIVE_OFFSET_RANGE_DEVICE_PATH;
-#endif
//
// BBS Device Path
@@ -509,10 +500,8 @@ typedef union {
F1394_DEVICE_PATH F1394;
USB_DEVICE_PATH Usb;
USB_CLASS_DEVICE_PATH UsbClass;
- #if (EFI_SPECIFICATION_VERSION >= 0x00020000)
USB_WWID_DEVICE_PATH UsbWwid;
DEVICE_LOGICAL_UNIT_DEVICE_PATH LogicUnit;
- #endif
I2O_DEVICE_PATH I2O;
MAC_ADDR_DEVICE_PATH MacAddr;
IPv4_DEVICE_PATH Ipv4;
@@ -520,9 +509,7 @@ typedef union {
INFINIBAND_DEVICE_PATH InfiniBand;
UART_DEVICE_PATH Uart;
UART_FLOW_CONTROL_DEVICE_PATH UartFlowControl;
- #if (EFI_SPECIFICATION_VERSION >= 0x00020000)
SAS_DEVICE_PATH Sas;
- #endif
ISCSI_DEVICE_PATH Iscsi;
HARDDRIVE_DEVICE_PATH HardDrive;
CDROM_DEVICE_PATH CD;
@@ -530,12 +517,10 @@ typedef union {
FILEPATH_DEVICE_PATH FilePath;
MEDIA_PROTOCOL_DEVICE_PATH MediaProtocol;
- #if (EFI_SPECIFICATION_VERSION >= 0x0002000A)
MEDIA_FW_VOL_DEVICE_PATH PiwgFirmwareVolume;
MEDIA_FW_VOL_FILEPATH_DEVICE_PATH PiwgFirmwareFile;
MEDIA_RELATIVE_OFFSET_RANGE_DEVICE_PATH
Offset;
- #endif
BBS_BBS_DEVICE_PATH Bbs;
} EFI_DEV_PATH;
@@ -563,10 +548,8 @@ typedef union {
F1394_DEVICE_PATH *F1394;
USB_DEVICE_PATH *Usb;
USB_CLASS_DEVICE_PATH *UsbClass;
- #if (EFI_SPECIFICATION_VERSION >= 0x00020000)
USB_WWID_DEVICE_PATH *UsbWwid;
DEVICE_LOGICAL_UNIT_DEVICE_PATH *LogicUnit;
- #endif
I2O_DEVICE_PATH *I2O;
MAC_ADDR_DEVICE_PATH *MacAddr;
IPv4_DEVICE_PATH *Ipv4;
@@ -575,9 +558,7 @@ typedef union {
UART_DEVICE_PATH *Uart;
UART_FLOW_CONTROL_DEVICE_PATH *UartFlowControl;
- #if (EFI_SPECIFICATION_VERSION >= 0x00020000)
SAS_DEVICE_PATH *Sas;
- #endif
ISCSI_DEVICE_PATH *Iscsi;
HARDDRIVE_DEVICE_PATH *HardDrive;
@@ -586,10 +567,10 @@ typedef union {
FILEPATH_DEVICE_PATH *FilePath;
MEDIA_PROTOCOL_DEVICE_PATH *MediaProtocol;
- #if (EFI_SPECIFICATION_VERSION >= 0x0002000A)
MEDIA_FW_VOL_DEVICE_PATH *PiwgFirmwareVolume;
MEDIA_FW_VOL_FILEPATH_DEVICE_PATH *PiwgFirmwareFile;
- #endif
+ MEDIA_RELATIVE_OFFSET_RANGE_DEVICE_PATH
+ *Offset;
BBS_BBS_DEVICE_PATH *Bbs;
UINT8 *Raw;
diff --git a/EdkCompatibilityPkg/Foundation/Efi/Include/EfiError.h b/EdkCompatibilityPkg/Foundation/Efi/Include/EfiError.h
index 9ddd1b3568..1db119b298 100644
--- a/EdkCompatibilityPkg/Foundation/Efi/Include/EfiError.h
+++ b/EdkCompatibilityPkg/Foundation/Efi/Include/EfiError.h
@@ -1,6 +1,6 @@
/*++
-Copyright (c) 2004, 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
@@ -58,6 +58,9 @@ Abstract:
#define EFI_INCOMPATIBLE_VERSION EFIERR (25)
#define EFI_SECURITY_VIOLATION EFIERR (26)
#define EFI_CRC_ERROR EFIERR (27)
+#define EFI_END_OF_MEDIA EFIERR (28)
+#define EFI_END_OF_FILE EFIERR (31)
+#define EFI_INVALID_LANGUAGE EFIERR (32)
#define EFI_WARN_UNKNOWN_GLYPH EFIWARN (1)
#define EFI_WARN_DELETE_FAILURE EFIWARN (2)
diff --git a/EdkCompatibilityPkg/Foundation/Efi/Include/EfiHii.h b/EdkCompatibilityPkg/Foundation/Efi/Include/EfiHii.h
index 30e001963c..fd15d4f179 100644
--- a/EdkCompatibilityPkg/Foundation/Efi/Include/EfiHii.h
+++ b/EdkCompatibilityPkg/Foundation/Efi/Include/EfiHii.h
@@ -1,6 +1,6 @@
/*++
-Copyright (c) 2007, Intel Corporation. All rights reserved.<BR>
+Copyright (c) 2007 - 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
@@ -59,13 +59,13 @@ typedef struct {
#define EFI_HII_PACKAGE_TYPE_ALL 0x00
#define EFI_HII_PACKAGE_TYPE_GUID 0x01
-#define EFI_HII_PACKAGE_FORM 0x02
-#define EFI_HII_PACKAGE_KEYBOARD_LAYOUT 0x03
+#define EFI_HII_PACKAGE_FORMS 0x02
#define EFI_HII_PACKAGE_STRINGS 0x04
#define EFI_HII_PACKAGE_FONTS 0x05
#define EFI_HII_PACKAGE_IMAGES 0x06
#define EFI_HII_PACKAGE_SIMPLE_FONTS 0x07
#define EFI_HII_PACKAGE_DEVICE_PATH 0x08
+#define EFI_HII_PACKAGE_KEYBOARD_LAYOUT 0x09
#define EFI_HII_PACKAGE_END 0xDF
#define EFI_HII_PACKAGE_TYPE_SYSTEM_BEGIN 0xE0
#define EFI_HII_PACKAGE_TYPE_SYSTEM_END 0xFF
@@ -108,6 +108,7 @@ typedef struct _EFI_HII_SIMPLE_FONT_PACKAGE_HDR {
// Font Package
//
+#define EFI_HII_FONT_STYLE_NORMAL 0x00000000
#define EFI_HII_FONT_STYLE_BOLD 0x00000001
#define EFI_HII_FONT_STYLE_ITALIC 0x00000002
#define EFI_HII_FONT_STYLE_EMBOSS 0x00010000
@@ -237,8 +238,8 @@ typedef struct _EFI_HII_GUID_PACKAGE_HDR {
// String Package
//
-#define UEFI_CONFIG_LANG L"x-UEFI"
-#define UEFI_CONFIG_LANG2 L"x-i-UEFI" // BUGBUG, spec need to be updated.
+#define UEFI_CONFIG_LANG "x-UEFI"
+#define UEFI_CONFIG_LANG_2 "x-i-UEFI"
typedef struct _EFI_HII_STRING_PACKAGE_HDR {
EFI_HII_PACKAGE_HEADER Header;
@@ -697,14 +698,14 @@ typedef struct _EFI_IFR_VARSTORE {
typedef struct _EFI_IFR_VARSTORE_EFI {
EFI_IFR_OP_HEADER Header;
- UINT16 VarStoreId;
+ EFI_VARSTORE_ID VarStoreId;
EFI_GUID Guid;
UINT32 Attributes;
} EFI_IFR_VARSTORE_EFI;
typedef struct _EFI_IFR_VARSTORE_NAME_VALUE {
EFI_IFR_OP_HEADER Header;
- UINT16 VarStoreId;
+ EFI_VARSTORE_ID VarStoreId;
EFI_GUID Guid;
} EFI_IFR_VARSTORE_NAME_VALUE;
@@ -713,8 +714,13 @@ typedef struct _EFI_IFR_FORM_SET {
EFI_GUID Guid;
EFI_STRING_ID FormSetTitle;
EFI_STRING_ID Help;
+ UINT8 Flags;
+ EFI_GUID ClassGuid[1];
} EFI_IFR_FORM_SET;
+#define EFI_HII_PLATFORM_SETUP_FORMSET_GUID \
+ { 0x93039971, 0x8545, 0x4b04, { 0xb4, 0x5e, 0x32, 0xeb, 0x83, 0x26, 0x4, 0xe } }
+
typedef struct _EFI_IFR_END {
EFI_IFR_OP_HEADER Header;
} EFI_IFR_END;
@@ -805,7 +811,7 @@ typedef struct _EFI_IFR_REF4 {
typedef struct _EFI_IFR_RESET_BUTTON {
EFI_IFR_OP_HEADER Header;
- EFI_IFR_QUESTION_HEADER Question;
+ EFI_IFR_STATEMENT_HEADER Statement;
EFI_DEFAULT_ID DefaultId;
} EFI_IFR_RESET_BUTTON;
@@ -1273,7 +1279,7 @@ typedef enum {
EfiKeyB8,
EfiKeyB9,
EfiKeyB10,
- EfiKeyRshift,
+ EfiKeyRShift,
EfiKeyUpArrow,
EfiKeyOne,
EfiKeyTwo,
@@ -1396,16 +1402,16 @@ typedef struct {
// EFI_HII_KEYBOARD_LAYOUT Layout[];
} EFI_HII_KEYBOARD_PACKAGE_HDR;
-typedef struct {
- CHAR16 Language[3];
- CHAR16 Space;
- CHAR16 DescriptionString[1];
-} EFI_DESCRIPTION_STRING;
+//typedef struct {
+// CHAR16 Language[]; // RFC4646 Language Code
+// CHAR16 Space;
+// CHAR16 DescriptionString[];
+//} EFI_DESCRIPTION_STRING;
-typedef struct {
- UINT16 DescriptionCount;
- EFI_DESCRIPTION_STRING DescriptionString[1];
-} EFI_DESCRIPTION_STRING_BUNDLE;
+//typedef struct {
+// UINT16 DescriptionCount;
+// EFI_DESCRIPTION_STRING DescriptionString[];
+//} EFI_DESCRIPTION_STRING_BUNDLE;
//
// Modifier values
@@ -1425,7 +1431,7 @@ typedef struct {
#define EFI_LEFT_SHIFT_MODIFIER 0x000C
#define EFI_RIGHT_SHIFT_MODIFIER 0x000D
#define EFI_CAPS_LOCK_MODIFIER 0x000E
-#define EFI_NUM_LOCK _MODIFIER 0x000F
+#define EFI_NUM_LOCK_MODIFIER 0x000F
#define EFI_LEFT_ARROW_MODIFIER 0x0010
#define EFI_RIGHT_ARROW_MODIFIER 0x0011
#define EFI_DOWN_ARROW_MODIFIER 0x0012
@@ -1458,6 +1464,10 @@ typedef struct {
#define EFI_PAUSE_MODIFIER 0x0025
#define EFI_BREAK_MODIFIER 0x0026
+#define EFI_LEFT_LOGO_MODIFIER 0x0027
+#define EFI_RIGHT_LOGO_MODIFIER 0x0028
+#define EFI_MENU_MODIFIER 0x0029
+
#pragma pack()
#endif
diff --git a/EdkCompatibilityPkg/Foundation/Efi/Include/EfiImage.h b/EdkCompatibilityPkg/Foundation/Efi/Include/EfiImage.h
index fa6dc424c3..90f7b75b47 100644
--- a/EdkCompatibilityPkg/Foundation/Efi/Include/EfiImage.h
+++ b/EdkCompatibilityPkg/Foundation/Efi/Include/EfiImage.h
@@ -1,6 +1,6 @@
/*++
-Copyright (c) 2004 - 2006, 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
@@ -623,6 +623,48 @@ typedef struct {
} EFI_IMAGE_DEBUG_CODEVIEW_RSDS_ENTRY;
//
+// Resource Format
+//
+typedef struct {
+ UINT32 Characteristics;
+ UINT32 TimeDateStamp;
+ UINT16 MajorVersion;
+ UINT16 MinorVersion;
+ UINT16 NumberOfNamedEntries;
+ UINT16 NumberOfIdEntries;
+// EFI_IMAGE_RESOURCE_DIRECTORY_ENTRY DirectoryEntries[];
+} EFI_IMAGE_RESOURCE_DIRECTORY;
+
+typedef struct {
+ union {
+ struct {
+ UINT32 NameOffset:31;
+ UINT32 NameIsString:1;
+ } s;
+ UINT32 Id;
+ } u1;
+ union {
+ UINT32 OffsetToData;
+ struct {
+ UINT32 OffsetToDirectory:31;
+ UINT32 DataIsDirectory:1;
+ } s;
+ } u2;
+} EFI_IMAGE_RESOURCE_DIRECTORY_ENTRY;
+
+typedef struct {
+ UINT16 Length;
+ CHAR16 String[1];
+} EFI_IMAGE_RESOURCE_DIRECTORY_STRING;
+
+typedef struct {
+ UINT32 OffsetToData;
+ UINT32 Size;
+ UINT32 CodePage;
+ UINT32 Reserved;
+} EFI_IMAGE_RESOURCE_DATA_ENTRY;
+
+//
// Header format for TE images
//
typedef struct {
diff --git a/EdkCompatibilityPkg/Foundation/Efi/Include/EfiTypes.h b/EdkCompatibilityPkg/Foundation/Efi/Include/EfiTypes.h
index 3fba60ff5d..5de817e091 100644
--- a/EdkCompatibilityPkg/Foundation/Efi/Include/EfiTypes.h
+++ b/EdkCompatibilityPkg/Foundation/Efi/Include/EfiTypes.h
@@ -1,6 +1,6 @@
/*++
-Copyright (c) 2004, 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
@@ -90,11 +90,11 @@ typedef UINT64 EFI_LBA;
// EFI Constants. They may exist in other build structures, so #ifndef them.
//
#ifndef TRUE
-#define TRUE ((BOOLEAN) 1 == 1)
+#define TRUE ((BOOLEAN) (1 == 1))
#endif
#ifndef FALSE
-#define FALSE ((BOOLEAN) 0 == 1)
+#define FALSE ((BOOLEAN) (0 == 1))
#endif
#ifndef NULL
diff --git a/EdkCompatibilityPkg/Foundation/Efi/Protocol/BlockIo/BlockIo.h b/EdkCompatibilityPkg/Foundation/Efi/Protocol/BlockIo/BlockIo.h
index ac914f7508..0767b8a4a1 100644
--- a/EdkCompatibilityPkg/Foundation/Efi/Protocol/BlockIo/BlockIo.h
+++ b/EdkCompatibilityPkg/Foundation/Efi/Protocol/BlockIo/BlockIo.h
@@ -1,6 +1,6 @@
/*++
-Copyright (c) 2004, 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
@@ -185,9 +185,16 @@ typedef struct {
UINT32 IoAlign;
EFI_LBA LastBlock;
+
+ EFI_LBA LowestAlignedLba;
+ UINT32 LogicalBlocksPerPhysicalBlock;
} EFI_BLOCK_IO_MEDIA;
-#define EFI_BLOCK_IO_PROTOCOL_REVISION 0x00010000
+#define EFI_BLOCK_IO_PROTOCOL_REVISION 0x00010000
+#define EFI_BLOCK_IO_PROTOCOL_REVISION2 0x00020001
+
+#define SIZE_OF_EFI_BLOCK_IO_MEDIA_REV1 ((UINTN)&((EFI_BLOCK_IO_MEDIA *)0)->LastBlock + sizeof(EFI_LBA))
+#define SIZE_OF_EFI_BLOCK_IO_MEDIA_REV2 sizeof(EFI_BLOCK_IO_MEDIA)
struct _EFI_BLOCK_IO_PROTOCOL {
UINT64 Revision;
diff --git a/EdkCompatibilityPkg/Foundation/Efi/Protocol/ComponentName2/ComponentName2.h b/EdkCompatibilityPkg/Foundation/Efi/Protocol/ComponentName2/ComponentName2.h
index 6a3a42bd9d..19c6d5a09d 100644
--- a/EdkCompatibilityPkg/Foundation/Efi/Protocol/ComponentName2/ComponentName2.h
+++ b/EdkCompatibilityPkg/Foundation/Efi/Protocol/ComponentName2/ComponentName2.h
@@ -1,6 +1,6 @@
/*++
-Copyright (c) 2004, 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
@@ -50,12 +50,13 @@ EFI_STATUS
Retrieves a Unicode string that is the user readable name of the EFI Driver.
Arguments:
- This - A pointer to the EFI_COMPONENT_NAME_PROTOCOL instance.
- Language - A pointer to a three character ISO 639-2 language identifier.
- This is the language of the driver name that that the caller
- is requesting, and it must match one of the languages specified
- in SupportedLanguages. The number of languages supported by a
- driver is up to the driver writer.
+ This - A pointer to the EFI_COMPONENT_NAME2_PROTOCOL instance.
+ Language - A pointer to a Null-terminated ASCII string array indicating the
+ language. This is the language of the driver name that the caller
+ is requesting, and it must match one of the languages specified in
+ SupportedLanguages. The number of languages supported by a
+ driver is up to the driver writer. Language is specified in RFC
+ 4646 language code format.
DriverName - A pointer to the Unicode string to return. This Unicode string
is the name of the driver specified by This in the language
specified by Language.
@@ -86,7 +87,7 @@ EFI_STATUS
that is being managed by an EFI Driver.
Arguments:
- This - A pointer to the EFI_COMPONENT_NAME_PROTOCOL instance.
+ This - A pointer to the EFI_COMPONENT_NAME2_PROTOCOL instance.
ControllerHandle - The handle of a controller that the driver specified by
This is managing. This handle specifies the controller
whose name is to be returned.
@@ -96,12 +97,12 @@ EFI_STATUS
for a bus drivers that wish to retrieve the name of the
bus controller. It will not be NULL for a bus driver
that wishes to retrieve the name of a child controller.
- Language - A pointer to a three character ISO 639-2 language
- identifier. This is the language of the controller name
- that that the caller is requesting, and it must match one
- of the languages specified in SupportedLanguages. The
- number of languages supported by a driver is up to the
- driver writer.
+ Language - A pointer to a Null-terminated ASCII string array indicating the
+ language. This is the language of the driver name that the caller
+ is requesting, and it must match one of the languages specified in
+ SupportedLanguages. The number of languages supported by a
+ driver is up to the driver writer. Language is specified in RFC
+ 4646 language code format.
ControllerName - A pointer to the Unicode string to return. This Unicode
string is the name of the controller specified by
ControllerHandle and ChildHandle in the language specified
diff --git a/EdkCompatibilityPkg/Foundation/Efi/Protocol/EfiProtocolLib.inf b/EdkCompatibilityPkg/Foundation/Efi/Protocol/EfiProtocolLib.inf
index 854efb354e..e99e26de27 100644
--- a/EdkCompatibilityPkg/Foundation/Efi/Protocol/EfiProtocolLib.inf
+++ b/EdkCompatibilityPkg/Foundation/Efi/Protocol/EfiProtocolLib.inf
@@ -1,6 +1,6 @@
#/*++
#
-# Copyright (c) 2004 - 2007, 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
@@ -117,6 +117,8 @@ COMPONENT_TYPE= LIBRARY
HiiFont/HiiFont.c
HiiImage/HiiImage.h
HiiImage/HiiImage.c
+ HiiPackageList/HiiPackageList.h
+ HiiPackageList/HiiPackageList.c
HiiString/HiiString.h
HiiString/HiiString.c
Ip4/Ip4.h
diff --git a/EdkCompatibilityPkg/Foundation/Efi/Protocol/HiiDatabase/HiiDatabase.h b/EdkCompatibilityPkg/Foundation/Efi/Protocol/HiiDatabase/HiiDatabase.h
index 8cb526613e..b319aae973 100644
--- a/EdkCompatibilityPkg/Foundation/Efi/Protocol/HiiDatabase/HiiDatabase.h
+++ b/EdkCompatibilityPkg/Foundation/Efi/Protocol/HiiDatabase/HiiDatabase.h
@@ -1,6 +1,6 @@
/*++
-Copyright (c) 2007, Intel Corporation. All rights reserved.<BR>
+Copyright (c) 2007 - 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
@@ -138,8 +138,7 @@ EFI_STATUS
Returns:
EFI_SUCCESS - The data associated with the Handle was removed from
the HII database.
- EFI_NOT_FOUND - The specified PackageList could not be found in database.
- EFI_INVALID_PARAMETER - The Handle was not valid.
+ EFI_NOT_FOUND - The specified Handle is not in database.
--*/
;
@@ -166,8 +165,8 @@ EFI_STATUS
Returns:
EFI_SUCCESS - The HII database was successfully updated.
EFI_OUT_OF_RESOURCES - Unable to allocate enough memory for the updated database.
- EFI_INVALID_PARAMETER - Handle or PackageList was NULL.
- EFI_NOT_FOUND - The Handle was not valid or could not be found in database.
+ EFI_INVALID_PARAMETER - PackageList was NULL.
+ EFI_NOT_FOUND - The specified Handle is not in database.
--*/
;
@@ -203,12 +202,16 @@ EFI_STATUS
Returns:
EFI_SUCCESS - The matching handles are outputed successfully.
+ HandleBufferLength is updated with the actual length.
EFI_BUFFER_TO_SMALL - The HandleBufferLength parameter indicates that
Handle is too small to support the number of handles.
HandleBufferLength is updated with a value that will
enable the data to fit.
EFI_NOT_FOUND - No matching handle could not be found in database.
EFI_INVALID_PARAMETER - Handle or HandleBufferLength was NULL.
+ EFI_INVALID_PARAMETER - PackageType is not a EFI_HII_PACKAGE_TYPE_GUID but
+ PackageGuid is not NULL, PackageType is a EFI_HII_
+ PACKAGE_TYPE_GUID but PackageGuid is NULL.
--*/
;
@@ -312,7 +315,8 @@ EFI_STATUS
Returns:
EFI_SUCCESS - Notification is unregistered successfully.
- EFI_INVALID_PARAMETER - The Handle is invalid.
+ EFI_NOT_FOUND - The incoming notification handle does not exist
+ in current hii database.
--*/
;
diff --git a/EdkCompatibilityPkg/Foundation/Efi/Protocol/HiiFont/HiiFont.h b/EdkCompatibilityPkg/Foundation/Efi/Protocol/HiiFont/HiiFont.h
index 36f5a872eb..46c922cf12 100644
--- a/EdkCompatibilityPkg/Foundation/Efi/Protocol/HiiFont/HiiFont.h
+++ b/EdkCompatibilityPkg/Foundation/Efi/Protocol/HiiFont/HiiFont.h
@@ -1,6 +1,6 @@
/*++
-Copyright (c) 2007, Intel Corporation. All rights reserved.<BR>
+Copyright (c) 2007 - 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
@@ -53,9 +53,9 @@ typedef struct _EFI_HII_ROW_INFO {
} EFI_HII_ROW_INFO;
typedef struct {
- UINT32 FontStyle;
- UINT16 FontSize; // character cell size in pixels
- CHAR16 FontName[1];
+ EFI_HII_FONT_STYLE FontStyle;
+ UINT16 FontSize; // character cell height in pixels
+ CHAR16 FontName[1];
} EFI_FONT_INFO;
typedef struct _EFI_FONT_DISPLAY_INFO {
@@ -65,25 +65,25 @@ typedef struct _EFI_FONT_DISPLAY_INFO {
EFI_FONT_INFO FontInfo;
} EFI_FONT_DISPLAY_INFO;
-#define EFI_HII_OUT_FLAG_CLIP 0x00000001
-#define EFI_HII_OUT_FLAG_WRAP 0x00000002
-#define EFI_HII_OUT_FLAG_CLEAN_Y 0x00000004
-#define EFI_HII_OUT_FLAG_CLEAN_X 0x00000008
-#define EFI_HII_OUT_FLAG_TRANSPARENT 0x00000010
-#define EFI_HII_IGNORE_IF_NO_GLYPH 0x00000020
-#define EFI_HII_IGNORE_LINE_BREAK 0x00000040
-#define EFI_HII_DIRECT_TO_SCREEN 0x00000080
-
-#define EFI_FONT_INFO_SYS_FONT 0x00000001
-#define EFI_FONT_INFO_SYS_SIZE 0x00000002
-#define EFI_FONT_INFO_SYS_STYLE 0x00000004
-#define EFI_FONT_INFO_SYS_FORE_COLOR 0x00000010
-#define EFI_FONT_INFO_SYS_BACK_COLOR 0x00000020
-#define EFI_FONT_INFO_RESIZE 0x00001000
-#define EFI_FONT_INFO_RESTYLE 0x00002000
-#define EFI_FONT_INFO_ANY_FONT 0x00010000
-#define EFI_FONT_INFO_ANY_SIZE 0x00020000
-#define EFI_FONT_INFO_ANY_STYLE 0x00040000
+#define EFI_HII_OUT_FLAG_CLIP 0x00000001
+#define EFI_HII_OUT_FLAG_WRAP 0x00000002
+#define EFI_HII_OUT_FLAG_CLIP_CLEAN_Y 0x00000004
+#define EFI_HII_OUT_FLAG_CLIP_CLEAN_X 0x00000008
+#define EFI_HII_OUT_FLAG_TRANSPARENT 0x00000010
+#define EFI_HII_IGNORE_IF_NO_GLYPH 0x00000020
+#define EFI_HII_IGNORE_LINE_BREAK 0x00000040
+#define EFI_HII_DIRECT_TO_SCREEN 0x00000080
+
+#define EFI_FONT_INFO_SYS_FONT 0x00000001
+#define EFI_FONT_INFO_SYS_SIZE 0x00000002
+#define EFI_FONT_INFO_SYS_STYLE 0x00000004
+#define EFI_FONT_INFO_SYS_FORE_COLOR 0x00000010
+#define EFI_FONT_INFO_SYS_BACK_COLOR 0x00000020
+#define EFI_FONT_INFO_RESIZE 0x00001000
+#define EFI_FONT_INFO_RESTYLE 0x00002000
+#define EFI_FONT_INFO_ANY_FONT 0x00010000
+#define EFI_FONT_INFO_ANY_SIZE 0x00020000
+#define EFI_FONT_INFO_ANY_STYLE 0x00040000
typedef
EFI_STATUS
@@ -109,7 +109,7 @@ EFI_STATUS
Flags - Describes how the string is to be drawn.
String - Points to the null-terminated string to be displayed.
StringInfo - Points to the string output information, including the color and font.
- If NULL, then the string will be output in the default system font and color.
+ If NULL, then the string will be output in the default system font and color.
Blt - If this points to a non-NULL on entry, this points to the image, which is Width pixels
wide and Height pixels high. The string will be drawn onto this image and
EFI_HII_OUT_FLAG_CLIP is implied. If this points to a NULL on entry, then a
@@ -132,7 +132,8 @@ EFI_STATUS
Returns:
EFI_SUCCESS - The string was successfully rendered.
EFI_OUT_OF_RESOURCES - Unable to allocate an output buffer for RowInfoArray or Blt.
- EFI_INVALID_PARAMETER - The String was NULL.
+ EFI_INVALID_PARAMETER - The String or Blt was NULL.
+ EFI_INVALID_PARAMETER - Flags were invalid combination.
--*/
;
@@ -166,7 +167,7 @@ EFI_STATUS
Language - Points to the language for the retrieved string. If NULL, then the current system
language is used.
StringInfo - Points to the string output information, including the color and font.
- If NULL, then the string will be output in the default system font and color.
+ If NULL, then the string will be output in the default system font and color.
Blt - If this points to a non-NULL on entry, this points to the image, which is Width pixels
wide and Height pixels high. The string will be drawn onto this image and
EFI_HII_OUT_FLAG_CLIP is implied. If this points to a NULL on entry, then a
@@ -187,9 +188,12 @@ EFI_STATUS
is possible when character display is normalized that some character cells overlap.
Returns:
- EFI_SUCCESS - The string was successfully rendered.
+ EFI_SUCCESS - The string was successfully rendered.
EFI_OUT_OF_RESOURCES - Unable to allocate an output buffer for RowInfoArray or Blt.
- EFI_INVALID_PARAMETER - The String was NULL.
+ EFI_INVALID_PARAMETER - The Blt or PackageList was NULL.
+ EFI_INVALID_PARAMETER - Flags were invalid combination.
+ EFI_NOT_FOUND - The specified PackageList is not in the Database or the stringid is not
+ in the specified PackageList.
--*/
;
@@ -233,7 +237,7 @@ EFI_STATUS
(EFIAPI *EFI_HII_GET_FONT_INFO) (
IN CONST EFI_HII_FONT_PROTOCOL *This,
IN OUT EFI_FONT_HANDLE *FontHandle,
- IN CONST EFI_FONT_DISPLAY_INFO *StringInfoIn,
+ IN CONST EFI_FONT_DISPLAY_INFO *StringInfoIn, OPTIONAL
OUT EFI_FONT_DISPLAY_INFO **StringInfoOut,
IN CONST EFI_STRING String OPTIONAL
)
@@ -246,11 +250,13 @@ EFI_STATUS
Arguments:
This - A pointer to the EFI_HII_FONT_PROTOCOL instance.
- FontHandle - On entry, points to the font handle returned by a
- previous call to GetFontInfo() or NULL to start with the
+ FontHandle - On entry, points to the font handle returned by a previous
+ call to GetFontInfo() or points to NULL to start with the
first font. On return, points to the returned font handle or
- points to NULL if there are no more matching fonts.
- StringInfoIn - Upon entry, points to the font to return information about.
+ points to NULL if there are no more matching fonts.
+ StringInfoIn - Upon entry, points to the font to return information about.
+ If NULL, then the information about the system default
+ font will be returned.
StringInfoOut - Upon return, contains the matching font's information.
If NULL, then no information is returned.
It's caller's responsibility to free this buffer.
@@ -261,10 +267,10 @@ EFI_STATUS
Returns:
EFI_SUCCESS - Matching font returned successfully.
EFI_NOT_FOUND - No matching font was found.
- EFI_INVALID_PARAMETER - StringInfoIn is NULL.
+ EFI_INVALID_PARAMETER - StringInfoIn->FontInfoMask is an invalid combination.
EFI_OUT_OF_RESOURCES - There were insufficient resources to complete the request.
---*/
+--*/
;
diff --git a/EdkCompatibilityPkg/Foundation/Efi/Protocol/HiiImage/HiiImage.h b/EdkCompatibilityPkg/Foundation/Efi/Protocol/HiiImage/HiiImage.h
index 1eb4e6fab0..0a27599e8a 100644
--- a/EdkCompatibilityPkg/Foundation/Efi/Protocol/HiiImage/HiiImage.h
+++ b/EdkCompatibilityPkg/Foundation/Efi/Protocol/HiiImage/HiiImage.h
@@ -1,6 +1,6 @@
/*++
-Copyright (c) 2007, Intel Corporation. All rights reserved.<BR>
+Copyright (c) 2007 - 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
@@ -45,7 +45,7 @@ typedef struct _EFI_IMAGE_INPUT {
UINT32 Flags;
UINT16 Width;
UINT16 Height;
- EFI_GRAPHICS_OUTPUT_BLT_PIXEL Bitmap[1];
+ EFI_GRAPHICS_OUTPUT_BLT_PIXEL *Bitmap;
} EFI_IMAGE_INPUT;
#define EFI_IMAGE_TRANSPARENT 0x00000001
@@ -101,8 +101,7 @@ EFI_STATUS
IN CONST EFI_HII_IMAGE_PROTOCOL *This,
IN EFI_HII_HANDLE PackageList,
IN EFI_IMAGE_ID ImageId,
- OUT EFI_IMAGE_INPUT *Image,
- OUT UINTN *ImageSize
+ OUT EFI_IMAGE_INPUT *Image
)
/*++
@@ -115,14 +114,14 @@ EFI_STATUS
PackageList - Handle of the package list where this image will be searched.
ImageId - The image's id,, which is unique within PackageList.
Image - Points to the image.
- ImageSize - On entry, points to the size of the buffer pointed to by Image, in bytes. On return,
- points to the length of the image, in bytes.
Returns:
EFI_SUCCESS - The new image was returned successfully.
EFI_NOT_FOUND - The image specified by ImageId is not available.
- EFI_BUFFER_TOO_SMALL - The buffer specified by ImageSize is too small to hold the image.
+ The specified PackageList is not in the database.
EFI_INVALID_PARAMETER - The Image or ImageSize was NULL.
+ EFI_OUT_OF_RESOURCES - The bitmap could not be retrieved because there was not
+ enough memory.
--*/
;
@@ -149,7 +148,8 @@ EFI_STATUS
Returns:
EFI_SUCCESS - The new image was updated successfully.
- EFI_NOT_FOUND - The image specified by ImageId is not in the database.
+ EFI_NOT_FOUND - The image specified by ImageId is not in the database.
+ The specified PackageList is not in the database.
EFI_INVALID_PARAMETER - The Image was NULL.
--*/
@@ -233,7 +233,9 @@ EFI_STATUS
Returns:
EFI_SUCCESS - The image was successfully drawn.
EFI_OUT_OF_RESOURCES - Unable to allocate an output buffer for Blt.
- EFI_INVALID_PARAMETER - The Image was NULL.
+ EFI_NOT_FOUND - The image specified by ImageId is not in the database.
+ The specified PackageList is not in the database.
+ EFI_INVALID_PARAMETER - The Blt was NULL.
--*/
;
diff --git a/EdkCompatibilityPkg/Foundation/Efi/Protocol/HiiPackageList/HiiPackageList.c b/EdkCompatibilityPkg/Foundation/Efi/Protocol/HiiPackageList/HiiPackageList.c
new file mode 100644
index 0000000000..aa424ab700
--- /dev/null
+++ b/EdkCompatibilityPkg/Foundation/Efi/Protocol/HiiPackageList/HiiPackageList.c
@@ -0,0 +1,27 @@
+/*++
+
+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
+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:
+
+ HiiPackageList.c
+
+Abstract:
+
+ EFI_HII_PACKAGE_LIST_PROTOCOL as defined in UEFI 2.1 spec.
+
+--*/
+
+#include "EfiSpec.h"
+#include EFI_PROTOCOL_DEFINITION (HiiPackageList)
+
+EFI_GUID gEfiHiiPackageListProtocolGuid = EFI_HII_PACKAGE_LIST_PROTOCOL_GUID;
+
+EFI_GUID_STRING(&gEfiHiiPackageListProtocolGuid, "HII Package List Protocol", "HII Package List 2.1 protocol");
diff --git a/EdkCompatibilityPkg/Foundation/Efi/Protocol/HiiPackageList/HiiPackageList.h b/EdkCompatibilityPkg/Foundation/Efi/Protocol/HiiPackageList/HiiPackageList.h
new file mode 100644
index 0000000000..a3d057a018
--- /dev/null
+++ b/EdkCompatibilityPkg/Foundation/Efi/Protocol/HiiPackageList/HiiPackageList.h
@@ -0,0 +1,36 @@
+/*++
+
+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
+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:
+
+ HiiPackageList.h
+
+Abstract:
+
+ EFI_HII_PACKAGE_LIST_PROTOCOL as defined in UEFI 2.1 spec.
+
+--*/
+
+#ifndef _HII_PACKAGE_LIST_H_
+#define _HII_PACKAGE_LIST_H_
+
+#include "EfiHii.h"
+
+#define EFI_HII_PACKAGE_LIST_PROTOCOL_GUID \
+ { \
+ 0x6a1ee763, 0xd47a, 0x43b4, {0xaa, 0xbe, 0xef, 0x1d, 0xe2, 0xab, 0x56, 0xfc} \
+ }
+
+typedef EFI_HII_PACKAGE_LIST_HEADER * EFI_HII_PACKAGE_LIST_PROTOCOL;
+
+extern EFI_GUID gEfiHiiPackageListProtocolGuid;
+
+#endif
diff --git a/EdkCompatibilityPkg/Foundation/Efi/Protocol/HiiString/HiiString.h b/EdkCompatibilityPkg/Foundation/Efi/Protocol/HiiString/HiiString.h
index c243d9e680..0c27218b38 100644
--- a/EdkCompatibilityPkg/Foundation/Efi/Protocol/HiiString/HiiString.h
+++ b/EdkCompatibilityPkg/Foundation/Efi/Protocol/HiiString/HiiString.h
@@ -1,6 +1,6 @@
/*++
-Copyright (c) 2007, Intel Corporation. All rights reserved.<BR>
+Copyright (c) 2007 - 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
@@ -54,6 +54,8 @@ EFI_STATUS
Routine Description:
This function adds the string String to the group of strings owned by PackageList, with the
specified font information StringFontInfo and returns a new string id.
+ The new string identifier is guaranteed to be unique within the package list.
+ That new string identifier is reserved for all languages in the package list.
Arguments:
This - A pointer to the EFI_HII_STRING_PROTOCOL instance.
@@ -104,13 +106,19 @@ EFI_STATUS
String - Points to the new null-terminated string.
StringSize - On entry, points to the size of the buffer pointed to by
String, in bytes. On return,
- points to the length of the string, in bytes.
- StringFontInfo - If not NULL, points to the string's font information.
- It's caller's responsibility to free this buffer.
+ points to the length of the string, in bytes.
+ StringFontInfo - Points to a buffer that will be callee allocated and will
+ have the string's font information into this buffer.
+ The caller is responsible for freeing this buffer.
+ If the parameter is NULL a buffer will not be allocated
+ and the string font information will not be returned.
Returns:
EFI_SUCCESS - The string was returned successfully.
EFI_NOT_FOUND - The string specified by StringId is not available.
+ The specified PackageList is not in the database.
+ EFI_INVALID_LANGUAGE - The string specified by StringId is available but
+ not in the specified language.
EFI_BUFFER_TOO_SMALL - The buffer specified by StringSize is too small to
hold the string.
EFI_INVALID_PARAMETER - The String or Language or StringSize was NULL.
@@ -147,7 +155,8 @@ EFI_STATUS
Returns:
EFI_SUCCESS - The string was updated successfully.
- EFI_NOT_FOUND - The string specified by StringId is not in the database.
+ EFI_NOT_FOUND - The string specified by StringId is not in the database.
+ The specified PackageList is not in the database.
EFI_INVALID_PARAMETER - The String or Language was NULL.
EFI_OUT_OF_RESOURCES - The system is out of resources to accomplish the task.
@@ -182,6 +191,7 @@ EFI_STATUS
EFI_BUFFER_TOO_SMALL - The LanguagesSize is too small to hold the list of
supported languages. LanguageSize is updated to
contain the required size.
+ EFI_NOT_FOUND - The specified PackageList is not in the database.
--*/
;
@@ -220,9 +230,12 @@ EFI_STATUS
EFI_BUFFER_TOO_SMALL - The buffer specified by SecondLanguagesSize is
too small to hold the returned information.
SecondLanguageSize is updated to hold the size of
- the buffer required.
-
---*/
+ the buffer required.
+ EFI_INVALID_LANGUAGE - The language specified by FirstLanguage is not
+ present in the specified package list.
+ EFI_NOT_FOUND - The specified PackageList is not in the Database.
+
+--*/
;
//
// Interface structure for the EFI_HII_STRING_PROTOCOL
diff --git a/EdkCompatibilityPkg/Foundation/Efi/Protocol/Ip4/Ip4.h b/EdkCompatibilityPkg/Foundation/Efi/Protocol/Ip4/Ip4.h
index 0263bf04f4..3e315c0bb2 100644
--- a/EdkCompatibilityPkg/Foundation/Efi/Protocol/Ip4/Ip4.h
+++ b/EdkCompatibilityPkg/Foundation/Efi/Protocol/Ip4/Ip4.h
@@ -1,6 +1,6 @@
/*++
-Copyright (c) 2005 - 2009, Intel Corporation. All rights reserved.<BR>
+Copyright (c) 2005 - 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
@@ -15,7 +15,7 @@ Module Name:
Abstract:
- UEFI IPv4 protocol.
+ EFI_IP4_PROTOCOL definition in UEFI 2.2 specification.
--*/
@@ -80,7 +80,7 @@ typedef struct _EFI_IP4_ICMP_TYPE {
typedef struct {
BOOLEAN IsStarted;
UINT32 MaxPacketSize;
-
+
EFI_IP4_CONFIG_DATA ConfigData;
BOOLEAN IsConfigured;
diff --git a/EdkCompatibilityPkg/Foundation/Efi/Protocol/SimpleFileSystem/SimpleFileSystem.h b/EdkCompatibilityPkg/Foundation/Efi/Protocol/SimpleFileSystem/SimpleFileSystem.h
index d9f0032559..6abd11d5bf 100644
--- a/EdkCompatibilityPkg/Foundation/Efi/Protocol/SimpleFileSystem/SimpleFileSystem.h
+++ b/EdkCompatibilityPkg/Foundation/Efi/Protocol/SimpleFileSystem/SimpleFileSystem.h
@@ -1,6 +1,6 @@
/*++
-Copyright (c) 2004, 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
@@ -35,6 +35,8 @@ Abstract:
EFI_FORWARD_DECLARATION (EFI_SIMPLE_FILE_SYSTEM_PROTOCOL);
EFI_FORWARD_DECLARATION (EFI_FILE);
+typedef struct _EFI_FILE *EFI_FILE_HANDLE;
+typedef struct _EFI_FILE EFI_FILE_PROTOCOL;
typedef
EFI_STATUS
@@ -356,7 +358,7 @@ EFI_STATUS
;
#define EFI_FILE_HANDLE_REVISION 0x00010000
-typedef struct _EFI_FILE {
+struct _EFI_FILE {
UINT64 Revision;
EFI_FILE_OPEN Open;
EFI_FILE_CLOSE Close;
@@ -368,7 +370,7 @@ typedef struct _EFI_FILE {
EFI_FILE_GET_INFO GetInfo;
EFI_FILE_SET_INFO SetInfo;
EFI_FILE_FLUSH Flush;
-} *EFI_FILE_HANDLE;
+};
extern EFI_GUID gEfiSimpleFileSystemProtocolGuid;
diff --git a/EdkCompatibilityPkg/Foundation/Framework/Guid/DataHubRecords/DataHubSubClassMemory.h b/EdkCompatibilityPkg/Foundation/Framework/Guid/DataHubRecords/DataHubSubClassMemory.h
index a4b83c33d9..482e69e114 100644
--- a/EdkCompatibilityPkg/Foundation/Framework/Guid/DataHubRecords/DataHubSubClassMemory.h
+++ b/EdkCompatibilityPkg/Foundation/Framework/Guid/DataHubRecords/DataHubSubClassMemory.h
@@ -1,6 +1,6 @@
/*++
-Copyright (c) 2004 - 2007, 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
@@ -140,7 +140,9 @@ typedef enum _EFI_MEMORY_ARRAY_TYPE {
EfiMemoryTypeRdram = 0x11,
EfiMemoryTypeDdr = 0x12,
EfiMemoryTypeDdr2 = 0x13,
- EfiMemoryTypeDdr2FbDimm = 0x14
+ EfiMemoryTypeDdr2FbDimm = 0x14,
+ EfiMemoryTypeDdr3 = 0x18,
+ EfiMemoryTypeFbd2 = 0x19
} EFI_MEMORY_ARRAY_TYPE;
typedef struct {
@@ -189,6 +191,8 @@ typedef struct {
UINT16 MemorySpeed;
EFI_MEMORY_STATE MemoryState;
UINT8 MemoryAttributes;
+ UINT8 MemoryBankConnections;
+ UINT8 MemoryErrorStatus;
} EFI_MEMORY_ARRAY_LINK;
@@ -304,11 +308,15 @@ typedef struct {
typedef struct {
UINT8 Five :1;
- UINT8 There :1;
+ UINT8 Three :1;
UINT8 Two :1;
UINT8 Reserved :5;
} EFI_MEMORY_MODULE_VOLTAGE_TYPE;
+//
+// EFI_MEMORY_CONTROLLER_INFORMATION is obsolete
+// Use EFI_MEMORY_CONTROLLER_INFORMATION_DATA instead
+//
typedef struct {
EFI_MEMORY_ERROR_DETECT_METHOD_TYPE ErrorDetectingMethod;
EFI_MEMORY_ERROR_CORRECT_CAPABILITY ErrorCorrectingCapability;
@@ -323,6 +331,20 @@ typedef struct {
UINT16 *MemoryModuleConfigHandles;
} EFI_MEMORY_CONTROLLER_INFORMATION;
+typedef struct {
+ EFI_MEMORY_ERROR_DETECT_METHOD_TYPE ErrorDetectingMethod;
+ EFI_MEMORY_ERROR_CORRECT_CAPABILITY ErrorCorrectingCapability;
+ EFI_MEMORY_SUPPORT_INTERLEAVE_TYPE MemorySupportedInterleave;
+ EFI_MEMORY_SUPPORT_INTERLEAVE_TYPE MemoryCurrentInterleave;
+ UINT8 MaxMemoryModuleSize;
+ EFI_MEMORY_SPEED_TYPE MemorySpeedType;
+ EFI_MEMORY_SUPPORTED_TYPE MemorySupportedType;
+ EFI_MEMORY_MODULE_VOLTAGE_TYPE MemoryModuleVoltage;
+ UINT8 NumberofMemorySlot;
+ EFI_MEMORY_ERROR_CORRECT_CAPABILITY EnabledCorrectingCapability;
+ EFI_INTER_LINK_DATA MemoryModuleConfig[1];
+} EFI_MEMORY_CONTROLLER_INFORMATION_DATA;
+
//
// Memory. Error Information - SMBIOS Type 18
//
diff --git a/EdkCompatibilityPkg/Foundation/Framework/Guid/DataHubRecords/DataHubSubClassMisc.h b/EdkCompatibilityPkg/Foundation/Framework/Guid/DataHubRecords/DataHubSubClassMisc.h
index 56124059a6..d7545afc8b 100644
--- a/EdkCompatibilityPkg/Foundation/Framework/Guid/DataHubRecords/DataHubSubClassMisc.h
+++ b/EdkCompatibilityPkg/Foundation/Framework/Guid/DataHubRecords/DataHubSubClassMisc.h
@@ -1,6 +1,6 @@
/*++
-Copyright (c) 2004 - 2007, 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
@@ -261,6 +261,7 @@ typedef enum {
typedef struct {
UINT32 RecordType :1;
+ UINT32 Type :7;
UINT32 Reserved :24;
} EFI_MISC_ELEMENT_TYPE;
@@ -417,7 +418,7 @@ typedef enum {
EfiSlotTypeApg2X = 0x10,
EfiSlotTypeAgp4X = 0x11,
EfiSlotTypePciX = 0x12,
- EfiSlotTypeAgp4x = 0x13,
+ EfiSlotTypeAgp8X = 0x13,
EfiSlotTypePC98C20 = 0xA0,
EfiSlotTypePC98C24 = 0xA1,
EfiSlotTypePC98E = 0xA2,
@@ -428,7 +429,13 @@ typedef enum {
EfiSlotTypePciExpressX2 = 0xA7,
EfiSlotTypePciExpressX4 = 0xA8,
EfiSlotTypePciExpressX8 = 0xA9,
- EfiSlotTypePciExpressX16 = 0xAA
+ EfiSlotTypePciExpressX16 = 0xAA,
+ EfiSlotTypePciExpressGen2 = 0xAB,
+ EfiSlotTypePciExpressGen2X1 = 0xAC,
+ EfiSlotTypePciExpressGen2X2 = 0xAD,
+ EfiSlotTypePciExpressGen2X4 = 0xAE,
+ EfiSlotTypePciExpressGen2X8 = 0xAF,
+ EfiSlotTypePciExpressGen2X16 = 0xB0
} EFI_MISC_SLOT_TYPE;
typedef enum {
@@ -595,6 +602,7 @@ typedef struct {
EFI_INTER_LINK_DATA GroupLink;
UINT16 GroupId;
UINT16 GroupElementId;
+ UINT8 ItemType;
} EFI_MISC_GROUP_ITEM_SET_DATA;
//
@@ -711,7 +719,12 @@ typedef struct {
//
// Misc. Hardware Security - SMBIOS Type 24
//
-#define EFI_MISC_HARDWARE_SECURITY_SETTINGS_DATA_RECORD_NUMBER 0x00000012
+#define EFI_MISC_HARDWARE_SECURITY_RECORD_NUMBER 0x00000012
+
+//
+// Backward Compatibility
+//
+#define EFI_MISC_HARDWARE_SECURITY_SETTINGS_DATA_RECORD_NUMBER EFI_MISC_HARDWARE_SECURITY_RECORD_NUMBER
typedef enum {
EfiHardwareSecurityStatusDisabled = 0,
@@ -966,6 +979,7 @@ typedef struct {
EFI_INTER_LINK_DATA ManagementDeviceLink;
EFI_INTER_LINK_DATA ManagementDeviceComponentLink;
EFI_INTER_LINK_DATA ManagementDeviceThresholdLink;
+ UINT8 ComponentType;
} EFI_MISC_MANAGEMENT_DEVICE_COMPONENT_DESCRIPTION;
//
@@ -1013,7 +1027,7 @@ typedef struct {
} POWER_SUPPLY_CHARACTERISTICS;
typedef struct {
- UINT8 PowerUnitGroup;
+ UINT16 PowerUnitGroup;
STRING_REF PowerSupplyLocation;
STRING_REF PowerSupplyDeviceName;
STRING_REF PowerSupplyManufacturer;
@@ -1098,18 +1112,62 @@ typedef struct {
// Misc. System Event Log - SMBIOS Type 15
//
#define EFI_MISC_SYSTEM_EVENT_LOG_RECORD_NUMBER 0x00000020
+
+typedef enum {
+ EfiEventLogTypeReserved1 = 0,
+ EfiEventLogTypeSingleBitEccMemoryError = 1,
+ EfiEventLogTypeMultiBitEccMemoryError = 2,
+ EfiEventLogTypeParityMemoryError = 3,
+ EfiEventLogTypeBusTimeOut = 4,
+ EfiEventLogTypeIoChannelCheck = 5,
+ EfiEventLogTypeSoftwareNmi = 6,
+ EfiEventLogTypePostMemoryResize = 7,
+ EfiEventLogTypePostError = 8,
+ EfiEventLogTypePciParityError = 9,
+ EfiEventLogTypePciSystemError = 0xA,
+ EfiEventLogTypeCpuFailure = 0xB,
+ EfiEventLogTypeEisaFailSafeTimerTimeOut = 0xC,
+ EfiEventLogTypeCorrectableMemoryLogDisabled = 0xD,
+ EfiEventLogTypeLoggingDisabled = 0xE,
+ EfiEventLogTypeReserved2 = 0xF,
+ EfiEventLogTypeSystemLimitExceeded = 0x10,
+ EfiEventLogTypeAsynchronousHardwareTimerExpired = 0x11,
+ EfiEventLogTypeSystemConfigurationInformation = 0x12,
+ EfiEventLogTypeHardDiskInformation = 0x13,
+ EfiEventLogTypeSystemReconfigured = 0x14,
+ EfiEventLogTypeUncorrectableCpuComplexError = 0x15,
+ EfiEventLogTypeLogAreaResetCleared = 0x16,
+ EfiEventLogTypeSystemBoot = 0x17,
+ EfiEventLogTypeEndOfLog = 0xFF
+} EFI_MISC_LOG_TYPE;
+
+typedef enum {
+ EfiEventLogDataFormatTypeNone = 0,
+ EfiEventLogDataFormatTypeHandle = 1,
+ EfiEventLogDataFormatTypeMultipleEvent = 2,
+ EfiEventLogDataFormatTypeMultipleEventHandle = 3,
+ EfiEventLogDataFormatTypePostResultsBitmap = 4,
+ EfiEventLogDataFormatTypeSystemManagement = 5,
+ EfiEventLogDataFormatTypeMultipleEventSystemManagement = 6
+} EFI_MISC_VARIABLE_DATA_FORMAT_TYPE;
+
+typedef struct {
+ UINT8 LogType;
+ UINT8 DataFormatType;
+} EFI_MISC_EVENT_LOG_TYPE;
+
typedef struct {
- //SMBIOS_STRUCTURE_HDR Header;
- UINT16 LogAreaLength;
- UINT16 LogHeaderStartOffset;
- UINT16 LogDataStartOffset;
- UINT8 AccessMethod;
- UINT8 LogStatus;
- UINT32 LogChangeToken;
- UINT32 AccessMethodAddress;
- UINT8 LogHeaderFormat;
- UINT8 NumberOfSupportedLogType;
- UINT8 LengthOfLogDescriptor;
+ UINT16 LogAreaLength;
+ UINT16 LogHeaderStartOffset;
+ UINT16 LogDataStartOffset;
+ UINT8 AccessMethod;
+ UINT8 LogStatus;
+ UINT32 LogChangeToken;
+ UINT32 AccessMethodAddress;
+ UINT8 LogHeaderFormat;
+ UINT8 NumberOfSupportedLogType;
+ UINT8 LengthOfLogDescriptor;
+ EFI_PHYSICAL_ADDRESS EventLogTypeDescriptors; // Pointer to EFI_MISC_EVENT_LOG_TYPE
} EFI_MISC_SYSTEM_EVENT_LOG;
//
diff --git a/EdkCompatibilityPkg/Foundation/Framework/Guid/DataHubRecords/DataHubSubClassProcessor.h b/EdkCompatibilityPkg/Foundation/Framework/Guid/DataHubRecords/DataHubSubClassProcessor.h
index fc094b7b9c..f55bd30830 100644
--- a/EdkCompatibilityPkg/Foundation/Framework/Guid/DataHubRecords/DataHubSubClassProcessor.h
+++ b/EdkCompatibilityPkg/Foundation/Framework/Guid/DataHubRecords/DataHubSubClassProcessor.h
@@ -1,6 +1,6 @@
/*++
-Copyright (c) 2004 - 2007, 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
@@ -49,6 +49,7 @@ typedef STRING_REF EFI_PROCESSOR_MANUFACTURER_DATA;
typedef STRING_REF EFI_PROCESSOR_SERIAL_NUMBER_DATA;
typedef STRING_REF EFI_PROCESSOR_ASSET_TAG_DATA;
+
typedef STRING_REF EFI_PROCESSOR_PART_NUMBER_DATA;
typedef struct {
@@ -159,6 +160,10 @@ typedef enum {
EfiProcessorFamilyPowerPC620 = 0x25,
EfiProcessorFamilyPowerPC704 = 0x26,
EfiProcessorFamilyPowerPC750 = 0x27,
+ EfiProcessorFamilyIntelCoreDuo = 0x28,
+ EfiProcessorFamilyIntelCoreDuoMobile = 0x29,
+ EfiProcessorFamilyIntelCoreSoloMobile = 0x2A,
+ EfiProcessorFamilyIntelAtom = 0x2B,
EfiProcessorFamilyAlpha2 = 0x30,
EfiProcessorFamilyAlpha21064 = 0x31,
EfiProcessorFamilyAlpha21066 = 0x32,
@@ -201,6 +206,12 @@ typedef enum {
EfiProcessorFamilyDualCoreAmdOpteron = 0x87,
EfiProcessorFamilyAmdAthlon64X2DualCore = 0x88,
EfiProcessorFamilyAmdTurion64X2Mobile = 0x89,
+ EfiProcessorFamilyQuadCoreAmdOpteron = 0x8A,
+ EfiProcessorFamilyThirdGenerationAmdOpteron = 0x8B,
+ EfiProcessorFamilyAmdPhenomFxQuadCore = 0x8C,
+ EfiProcessorFamilyAmdPhenomX4QuadCore = 0x8D,
+ EfiProcessorFamilyAmdPhenomX2DualCore = 0x8E,
+ EfiProcessorFamilyAmdAthlonX2DualCore = 0x8F,
EfiProcessorFamilyPARISC = 0x90,
EfiProcessorFamilyPaRisc8500 = 0x91,
EfiProcessorFamilyPaRisc8000 = 0x92,
@@ -209,6 +220,21 @@ typedef enum {
EfiProcessorFamilyPaRisc7100LC = 0x95,
EfiProcessorFamilyPaRisc7100 = 0x96,
EfiProcessorFamilyV30 = 0xA0,
+ EfiProcessorFamilyQuadCoreIntelXeon3200Series = 0xA1,
+ EfiProcessorFamilyDualCoreIntelXeon3000Series = 0xA2,
+ EfiProcessorFamilyQuadCoreIntelXeon5300Series = 0xA3,
+ EfiProcessorFamilyDualCoreIntelXeon5100Series = 0xA4,
+ EfiProcessorFamilyDualCoreIntelXeon5000Series = 0xA5,
+ EfiProcessorFamilyDualCoreIntelXeonLV = 0xA6,
+ EfiProcessorFamilyDualCoreIntelXeonULV = 0xA7,
+ EfiProcessorFamilyDualCoreIntelXeon7100Series = 0xA8,
+ EfiProcessorFamilyQuadCoreIntelXeon5400Series = 0xA9,
+ EfiProcessorFamilyQuadCoreIntelXeon = 0xAA,
+ EfiProcessorFamilyDualCoreIntelXeon5200Series = 0xAB,
+ EfiProcessorFamilyDualCoreIntelXeon7200Series = 0xAC,
+ EfiProcessorFamilyQuadCoreIntelXeon7300Series = 0xAD,
+ EfiProcessorFamilyQuadCoreIntelXeon7400Series = 0xAE,
+ EfiProcessorFamilyMultiCoreIntelXeon7400Series = 0xAF,
EfiProcessorFamilyPentiumIIIXeon = 0xB0,
EfiProcessorFamilyPentiumIIISpeedStep = 0xB1,
EfiProcessorFamilyPentium4 = 0xB2,
@@ -222,9 +248,17 @@ typedef enum {
EfiProcessorFamilyIntelCeleronD = 0xBA,
EfiProcessorFamilyIntelPentiumD = 0xBB,
EfiProcessorFamilyIntelPentiumEx = 0xBC,
- EfiProcessorFamilyIntelCoreBrand = 0xBD,
+ EfiProcessorFamilyIntelCoreSolo = 0xBD, // SMBIOS spec 2.6 correct this value
EfiProcessorFamilyReserved = 0xBE,
EfiProcessorFamilyIntelCore2 = 0xBF,
+ EfiProcessorFamilyIntelCore2Solo = 0xC0,
+ EfiProcessorFamilyIntelCore2Extreme = 0xC1,
+ EfiProcessorFamilyIntelCore2Quad = 0xC2,
+ EfiProcessorFamilyIntelCore2ExtremeMobile = 0xC3,
+ EfiProcessorFamilyIntelCore2DuoMobile = 0xC4,
+ EfiProcessorFamilyIntelCore2SoloMobile = 0xC5,
+ EfiProcessorFamilyIntelCoreI7 = 0xC6,
+ EfiProcessorFamilyDualCoreIntelCeleron = 0xC7,
EfiProcessorFamilyIBM390 = 0xC8,
EfiProcessorFamilyG4 = 0xC9,
EfiProcessorFamilyG5 = 0xCA,
@@ -234,6 +268,20 @@ typedef enum {
EfiProcessorFamilyViaC7D = 0xD3,
EfiProcessorFamilyViaC7 = 0xD4,
EfiProcessorFamilyViaEden = 0xD5,
+ EfiProcessorFamilyMultiCoreIntelXeon = 0xD6,
+ EfiProcessorFamilyDualCoreIntelXeon3Series = 0xD7,
+ EfiProcessorFamilyQuadCoreIntelXeon3Series = 0xD8,
+ EfiProcessorFamilyDualCoreIntelXeon5Series = 0xDA,
+ EfiProcessorFamilyQuadCoreIntelXeon5Series = 0xDB,
+ EfiProcessorFamilyDualCoreIntelXeon7Series = 0xDD,
+ EfiProcessorFamilyQuadCoreIntelXeon7Series = 0xDE,
+ EfiProcessorFamilyMultiCoreIntelXeon7Series = 0xDF,
+ EfiProcessorFamilyEmbeddedAmdOpteronQuadCore = 0xE6,
+ EfiProcessorFamilyAmdPhenomTripleCore = 0xE7,
+ EfiProcessorFamilyAmdTurionUltraDualCoreMobile = 0xE8,
+ EfiProcessorFamilyAmdTurionDualCoreMobile = 0xE9,
+ EfiProcessorFamilyAmdAthlonDualCore = 0xEA,
+ EfiProcessorFamilyAmdSempronSI = 0xEB,
EfiProcessorFamilyi860 = 0xFA,
EfiProcessorFamilyi960 = 0xFB,
EfiProcessorFamilyIndicatorFamily2 = 0xFE
@@ -314,7 +362,8 @@ typedef enum {
EfiProcessorSocketLGA775 = 0x15,
EfiProcessorSocketS1 = 0x16,
EfiProcessorSocketAm2 = 0x17,
- EfiProcessorSocketF = 0x18
+ EfiProcessorSocketF = 0x18,
+ EfiProcessorSocketLGA1366 = 0x19
} EFI_PROCESSOR_SOCKET_TYPE_DATA;
typedef STRING_REF EFI_PROCESSOR_SOCKET_NAME_DATA;
diff --git a/EdkCompatibilityPkg/Foundation/Framework/Include/EfiCapsule.h b/EdkCompatibilityPkg/Foundation/Framework/Include/EfiCapsule.h
index f2e996a794..cae8aec161 100644
--- a/EdkCompatibilityPkg/Foundation/Framework/Include/EfiCapsule.h
+++ b/EdkCompatibilityPkg/Foundation/Framework/Include/EfiCapsule.h
@@ -1,6 +1,6 @@
/*++
-Copyright (c) 2004 - 2007, 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
@@ -59,6 +59,11 @@ typedef struct {
VOID* CapsulePtr[1];
} EFI_CAPSULE_TABLE;
+//
+// This struct is deprecated because VendorTable entries physical address will not be fixed up when
+// transitioning from preboot to runtime phase. So we don't need CapsuleInfoTable to record capsule
+// GUIDs any more for runtime convert.
+//
typedef struct {
UINT32 CapsuleGuidNumber;
EFI_GUID CapsuleGuidPtr[1];
@@ -66,6 +71,7 @@ typedef struct {
//
// This GUID is used for collecting all capsules' Guids who install in ConfigTable.
+// This GUID is deprecated as well.
//
#define EFI_CAPSULE_INFO_GUID \
{ \
diff --git a/EdkCompatibilityPkg/Foundation/Framework/Include/EfiPciCfg.h b/EdkCompatibilityPkg/Foundation/Framework/Include/EfiPciCfg.h
index c5c180d337..1db788670f 100644
--- a/EdkCompatibilityPkg/Foundation/Framework/Include/EfiPciCfg.h
+++ b/EdkCompatibilityPkg/Foundation/Framework/Include/EfiPciCfg.h
@@ -1,6 +1,6 @@
/*++
-Copyright (c) 2007, Intel Corporation. All rights reserved.<BR>
+Copyright (c) 2007 - 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
@@ -50,11 +50,10 @@ typedef enum {
} EFI_PEI_PCI_CFG_PPI_WIDTH;
#define EFI_PEI_PCI_CFG_ADDRESS(bus, dev, func, reg) \
- ( ((bus) << 24) | \
- ((dev) << 16) | \
- ((func) << 8) | \
- ((reg) < 256 ? (reg): ((UINT64)(reg) << 32)))
-
+ (UINT64) ((((UINTN) (bus)) << 24) | \
+ (((UINTN) (dev)) << 16) | \
+ (((UINTN) (func)) << 8) | \
+ ((reg) < 256 ? ((UINTN) (reg)): ((UINT64) (reg) << 32)))
#if (PI_SPECIFICATION_VERSION < 0x00010000)
diff --git a/EdkCompatibilityPkg/Foundation/Framework/Include/PeiApi.h b/EdkCompatibilityPkg/Foundation/Framework/Include/PeiApi.h
index 5d1ce1f63f..e37baeb10c 100644
--- a/EdkCompatibilityPkg/Foundation/Framework/Include/PeiApi.h
+++ b/EdkCompatibilityPkg/Foundation/Framework/Include/PeiApi.h
@@ -1,6 +1,6 @@
/*++
-Copyright (c) 2004 - 2007, 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
@@ -361,8 +361,8 @@ EFI_STATUS
(EFIAPI *EFI_PEI_FFS_FIND_NEXT_FILE2) (
IN CONST EFI_PEI_SERVICES **PeiServices,
IN EFI_FV_FILETYPE SearchType,
- IN CONST EFI_PEI_FV_HANDLE *FwVolHeader,
- IN OUT EFI_PEI_FILE_HANDLE **FileHandle
+ IN CONST EFI_PEI_FV_HANDLE FvHandle,
+ IN OUT EFI_PEI_FILE_HANDLE *FileHandle
);
typedef
@@ -370,7 +370,7 @@ EFI_STATUS
(EFIAPI *EFI_PEI_FFS_FIND_SECTION_DATA2) (
IN CONST EFI_PEI_SERVICES **PeiServices,
IN EFI_SECTION_TYPE SectionType,
- IN EFI_PEI_FILE_HANDLE *FileHandle,
+ IN EFI_PEI_FILE_HANDLE FileHandle,
OUT VOID **SectionData
);
@@ -443,7 +443,7 @@ EFI_STATUS
typedef
EFI_STATUS
(EFIAPI *EFI_PEI_FFS_GET_VOLUME_INFO) (
- IN EFI_PEI_FV_HANDLE *VolumeHandle,
+ IN EFI_PEI_FV_HANDLE VolumeHandle,
OUT EFI_FV_INFO *VolumeInfo
);
diff --git a/EdkCompatibilityPkg/Foundation/Framework/Include/TianoSpecDevicePath.h b/EdkCompatibilityPkg/Foundation/Framework/Include/TianoSpecDevicePath.h
index c8eec3d946..4f6cb395d6 100644
--- a/EdkCompatibilityPkg/Foundation/Framework/Include/TianoSpecDevicePath.h
+++ b/EdkCompatibilityPkg/Foundation/Framework/Include/TianoSpecDevicePath.h
@@ -1,6 +1,6 @@
/*++
-Copyright (c) 2004 - 2007, 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
@@ -22,28 +22,11 @@ Abstract:
#ifndef _TIANO_SPEC_DEVICE_PATH_H
#define _TIANO_SPEC_DEVICE_PATH_H
-#pragma pack(1)
+#include "EfiDevicePath.h"
-#if (EFI_SPECIFICATION_VERSION <= 0x00020000)
//
-// EFI Specification extension on Media Device Path. MEDIA_FW_VOL_FILEPATH_DEVICE_PATH is adopted by UEFI later and added in UEFI2.10.
-// In EdkCompatibility Package, we only support MEDIA_FW_VOL_FILEPATH_DEVICE_PATH that complies with
-// EFI 1.10 and UEFI 2.10.
+// MEDIA_FW_VOL_FILEPATH_DEVICE_PATH and MEDIA_FW_VOL_DEVICE_PATH are defined in
+// EfiDevicePath.h
//
-#define MEDIA_FV_FILEPATH_DP 0x06
-typedef struct {
- EFI_DEVICE_PATH_PROTOCOL Header;
- EFI_GUID NameGuid;
-} MEDIA_FW_VOL_FILEPATH_DEVICE_PATH;
-#endif
-
-
-#if (EFI_SPECIFICATION_VERSION > 0x00020000)
-//
-// EFI Specification extension on Media Device Path was added to UEFI 2.1 specification,
-// so the definition is moved to EfiDevicePath.h
-//
-#endif
-#pragma pack()
#endif
diff --git a/EdkCompatibilityPkg/Foundation/Framework/Ppi/EdkFrameworkPpiLib.inf b/EdkCompatibilityPkg/Foundation/Framework/Ppi/EdkFrameworkPpiLib.inf
index b391215839..cba842faa1 100644
--- a/EdkCompatibilityPkg/Foundation/Framework/Ppi/EdkFrameworkPpiLib.inf
+++ b/EdkCompatibilityPkg/Foundation/Framework/Ppi/EdkFrameworkPpiLib.inf
@@ -1,6 +1,6 @@
#/*++
#
-# Copyright (c) 2004 - 2007, 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
@@ -102,4 +102,7 @@ COMPONENT_TYPE= LIBRARY
GuidedSectionExtraction/GuidedSectionExtraction.c
EcpPciCfg/EcpPciCfg.h
EcpPciCfg/EcpPciCfg.c
-
+ TemporaryRamSupport/TemporaryRamSupport.h
+ TemporaryRamSupport/TemporaryRamSupport.c
+ LoadedImage/LoadedImage.h
+ LoadedImage/LoadedImage.c
diff --git a/EdkCompatibilityPkg/Foundation/Framework/Ppi/FirmwareVolume/FirmwareVolume.h b/EdkCompatibilityPkg/Foundation/Framework/Ppi/FirmwareVolume/FirmwareVolume.h
index 006a4fb23a..e3740169ae 100644
--- a/EdkCompatibilityPkg/Foundation/Framework/Ppi/FirmwareVolume/FirmwareVolume.h
+++ b/EdkCompatibilityPkg/Foundation/Framework/Ppi/FirmwareVolume/FirmwareVolume.h
@@ -1,6 +1,6 @@
/*++
-Copyright (c) 2007, Intel Corporation. All rights reserved.<BR>
+Copyright (c) 2007 - 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
@@ -77,7 +77,7 @@ EFI_STATUS
(EFIAPI *EFI_PEI_FV_FIND_FILE_NAME) (
IN CONST EFI_PEI_FIRMWARE_VOLUME_PPI *This,
IN CONST EFI_GUID *FileName,
- IN EFI_PEI_FV_HANDLE FvHandle,
+ IN OUT EFI_PEI_FV_HANDLE *FvHandle,
OUT EFI_PEI_FILE_HANDLE *FileHandle
);
diff --git a/EdkCompatibilityPkg/Foundation/Framework/Ppi/LoadedImage/LoadedImage.c b/EdkCompatibilityPkg/Foundation/Framework/Ppi/LoadedImage/LoadedImage.c
new file mode 100644
index 0000000000..09d4a8ba0f
--- /dev/null
+++ b/EdkCompatibilityPkg/Foundation/Framework/Ppi/LoadedImage/LoadedImage.c
@@ -0,0 +1,30 @@
+/*++
+
+Copyright (c) 2009 - 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:
+
+ LoadedImage.c
+
+Abstract:
+
+ The file describes the PPI which notifies other drivers
+ of the PEIM being initialized by the PEI Dispatcher.
+
+--*/
+
+#include "Tiano.h"
+#include "PeiBind.h"
+#include "PeiApi.h"
+#include EFI_PPI_DEFINITION (LoadedImage)
+
+EFI_GUID gEfiPeiLoadedImagePpiGuid = EFI_PEI_LOADED_IMAGE_PPI_GUID;
+
+EFI_GUID_STRING(&gEfiPeiLoadedImagePpiGuid, "LoadedImagePpi", "LoadedImage PPI");
diff --git a/EdkCompatibilityPkg/Foundation/Framework/Ppi/LoadedImage/LoadedImage.h b/EdkCompatibilityPkg/Foundation/Framework/Ppi/LoadedImage/LoadedImage.h
new file mode 100644
index 0000000000..909b1091d4
--- /dev/null
+++ b/EdkCompatibilityPkg/Foundation/Framework/Ppi/LoadedImage/LoadedImage.h
@@ -0,0 +1,56 @@
+/*++
+
+Copyright (c) 2009 - 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:
+
+ LoadedImage.h
+
+Abstract:
+
+ The file describes the PPI which notifies other drivers
+ of the PEIM being initialized by the PEI Dispatcher.
+
+--*/
+
+#ifndef __LOADED_IMAGE_PPI_H__
+#define __LOADED_IMAGE_PPI_H__
+
+#include "Tiano.h"
+
+#define EFI_PEI_LOADED_IMAGE_PPI_GUID \
+ { 0xc1fcd448, 0x6300, 0x4458, {0xb8, 0x64, 0x28, 0xdf, 0x01, 0x53, 0x64, 0xbc} }
+
+typedef struct _EFI_PEI_LOADED_IMAGE_PPI EFI_PEI_LOADED_IMAGE_PPI;
+
+///
+/// This interface is installed by the PEI Dispatcher after the image has been
+/// loaded and after all security checks have been performed,
+/// to notify other PEIMs of the files which are being loaded.
+///
+struct _EFI_PEI_LOADED_IMAGE_PPI {
+ ///
+ /// Address of the image at the address where it will be executed.
+ ///
+ EFI_PHYSICAL_ADDRESS ImageAddress;
+ ///
+ /// Size of the image as it will be executed.
+ ///
+ UINT64 ImageSize;
+ ///
+ /// File handle from which the image was loaded.
+ /// Can be NULL, indicating the image was not loaded from a handle.
+ ///
+ EFI_PEI_FILE_HANDLE FileHandle;
+};
+
+extern EFI_GUID gEfiPeiLoadedImagePpiGuid;
+
+#endif
diff --git a/EdkCompatibilityPkg/Foundation/Framework/Ppi/TemporaryRamSupport/TemporaryRamSupport.c b/EdkCompatibilityPkg/Foundation/Framework/Ppi/TemporaryRamSupport/TemporaryRamSupport.c
new file mode 100644
index 0000000000..b4a2b86645
--- /dev/null
+++ b/EdkCompatibilityPkg/Foundation/Framework/Ppi/TemporaryRamSupport/TemporaryRamSupport.c
@@ -0,0 +1,30 @@
+/*++
+
+Copyright (c) 2009 - 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:
+
+ TemporaryRamSupport.c
+
+Abstract:
+
+ This file declares Temporary RAM Support PPI.
+ This Ppi provides the service that migrates temporary RAM into permanent memory.
+
+--*/
+
+#include "Tiano.h"
+#include "PeiBind.h"
+#include "PeiApi.h"
+#include EFI_PPI_DEFINITION (TemporaryRamSupport)
+
+EFI_GUID gEfiTemporaryRamSupportPpiGuid = TEMPORARY_RAM_SUPPORT_PPI_GUID;
+
+EFI_GUID_STRING(&gEfiTemporaryRamSupportPpiGuid, "TemporaryRamSupportPpi", "TemporaryRamSupport PPI");
diff --git a/EdkCompatibilityPkg/Foundation/Framework/Ppi/TemporaryRamSupport/TemporaryRamSupport.h b/EdkCompatibilityPkg/Foundation/Framework/Ppi/TemporaryRamSupport/TemporaryRamSupport.h
new file mode 100644
index 0000000000..635c3f8f25
--- /dev/null
+++ b/EdkCompatibilityPkg/Foundation/Framework/Ppi/TemporaryRamSupport/TemporaryRamSupport.h
@@ -0,0 +1,66 @@
+/*++
+
+Copyright (c) 2009 - 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:
+
+ TemporaryRamSupport.h
+
+Abstract:
+
+ This file declares Temporary RAM Support PPI.
+ This Ppi provides the service that migrates temporary RAM into permanent memory.
+
+--*/
+
+#ifndef __TEMPORARY_RAM_SUPPORT_H__
+#define __TEMPORARY_RAM_SUPPORT_H__
+
+#include "Tiano.h"
+
+#define TEMPORARY_RAM_SUPPORT_PPI_GUID \
+ { \
+ 0xdbe23aa9, 0xa345, 0x4b97, {0x85, 0xb6, 0xb2, 0x26, 0xf1, 0x61, 0x73, 0x89} \
+ }
+
+/**
+ This service of the TEMPORARY_RAM_SUPPORT_PPI that migrates temporary RAM into
+ permanent memory.
+
+ @param PeiServices Pointer to the PEI Services Table.
+ @param TemporaryMemoryBase Source Address in temporary memory from which the SEC or PEIM will copy the
+ Temporary RAM contents.
+ @param PermanentMemoryBase Destination Address in permanent memory into which the SEC or PEIM will copy the
+ Temporary RAM contents.
+ @param CopySize Amount of memory to migrate from temporary to permanent memory.
+
+ @retval EFI_SUCCESS The data was successfully returned.
+ @retval EFI_INVALID_PARAMETER PermanentMemoryBase + CopySize > TemporaryMemoryBase when TemporaryMemoryBase > PermanentMemoryBase.
+
+ **/
+typedef
+EFI_STATUS
+(EFIAPI * TEMPORARY_RAM_MIGRATION)(
+ IN CONST EFI_PEI_SERVICES **PeiServices,
+ IN EFI_PHYSICAL_ADDRESS TemporaryMemoryBase,
+ IN EFI_PHYSICAL_ADDRESS PermanentMemoryBase,
+ IN UINTN CopySize
+);
+
+///
+/// This service abstracts the ability to migrate contents of the platform early memory store.
+///
+typedef struct {
+ TEMPORARY_RAM_MIGRATION TemporaryRamMigration;
+} TEMPORARY_RAM_SUPPORT_PPI;
+
+extern EFI_GUID gEfiTemporaryRamSupportPpiGuid;
+
+#endif
diff --git a/EdkCompatibilityPkg/Foundation/Framework/Protocol/FirmwareVolumeBlock/FirmwareVolumeBlock.c b/EdkCompatibilityPkg/Foundation/Framework/Protocol/FirmwareVolumeBlock/FirmwareVolumeBlock.c
index ffa2f5b362..30cff849db 100644
--- a/EdkCompatibilityPkg/Foundation/Framework/Protocol/FirmwareVolumeBlock/FirmwareVolumeBlock.c
+++ b/EdkCompatibilityPkg/Foundation/Framework/Protocol/FirmwareVolumeBlock/FirmwareVolumeBlock.c
@@ -1,6 +1,6 @@
/*++
-Copyright (c) 2004, 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
@@ -27,5 +27,7 @@ Abstract:
#include EFI_PROTOCOL_DEFINITION (FirmwareVolumeBlock)
EFI_GUID gEfiFirmwareVolumeBlockProtocolGuid = EFI_FIRMWARE_VOLUME_BLOCK_PROTOCOL_GUID;
+EFI_GUID gEfiFirmwareVolumeBlock2ProtocolGuid = EFI_FIRMWARE_VOLUME_BLOCK_PROTOCOL_GUID;
EFI_GUID_STRING(&gEfiFirmwareVolumeBlockProtocolGuid, "FirmwareVolumeBlock Protocol", "Firmware Volume Block protocol");
+EFI_GUID_STRING(&gEfiFirmwareVolumeBlock2ProtocolGuid, "FirmwareVolumeBlock2 Protocol", "Firmware Volume Block2 protocol");
diff --git a/EdkCompatibilityPkg/Foundation/Framework/Protocol/FirmwareVolumeBlock/FirmwareVolumeBlock.h b/EdkCompatibilityPkg/Foundation/Framework/Protocol/FirmwareVolumeBlock/FirmwareVolumeBlock.h
index d431aedc5d..a2fd4e9d7a 100644
--- a/EdkCompatibilityPkg/Foundation/Framework/Protocol/FirmwareVolumeBlock/FirmwareVolumeBlock.h
+++ b/EdkCompatibilityPkg/Foundation/Framework/Protocol/FirmwareVolumeBlock/FirmwareVolumeBlock.h
@@ -1,6 +1,6 @@
/*++
-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
@@ -40,6 +40,8 @@ Abstract:
EFI_FORWARD_DECLARATION (EFI_FIRMWARE_VOLUME_BLOCK_PROTOCOL);
+typedef EFI_FIRMWARE_VOLUME_BLOCK_PROTOCOL EFI_FIRMWARE_VOLUME_BLOCK2_PROTOCOL;
+
typedef
EFI_STATUS
(EFIAPI *EFI_FVB_GET_ATTRIBUTES) (
diff --git a/EdkCompatibilityPkg/Foundation/Framework/Protocol/IdeControllerInit/IdeControllerInit.h b/EdkCompatibilityPkg/Foundation/Framework/Protocol/IdeControllerInit/IdeControllerInit.h
index c28852c64b..6e3691cb3b 100644
--- a/EdkCompatibilityPkg/Foundation/Framework/Protocol/IdeControllerInit/IdeControllerInit.h
+++ b/EdkCompatibilityPkg/Foundation/Framework/Protocol/IdeControllerInit/IdeControllerInit.h
@@ -1,6 +1,6 @@
/*++
-Copyright (c) 2004, 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
@@ -174,10 +174,17 @@ typedef struct {
UINT16 command_set_feature_enb_86; // word 86
UINT16 command_set_feature_default; // word 87
UINT16 ultra_dma_mode; // word 88
- UINT16 reserved_89_127[39];
+ UINT16 reserved_89_105[17];
+ UINT16 phy_logic_sector_support; // word 106
+ UINT16 reserved_107_116[10];
+ UINT16 logic_sector_size_lo; // word 117
+ UINT16 logic_sector_size_hi; // word 118
+ UINT16 reserved_119_127[9];
UINT16 security_status;
UINT16 vendor_data_129_159[31];
- UINT16 reserved_160_255[96];
+ UINT16 reserved_160_208[49];
+ UINT16 alignment_logic_in_phy_blocks; // word 209
+ UINT16 reserved_210_255[46];
} EFI_ATA_IDENTIFY_DATA;
#pragma pack()
diff --git a/EdkCompatibilityPkg/Foundation/Guid/AcpiDescription/AcpiDescription.h b/EdkCompatibilityPkg/Foundation/Guid/AcpiDescription/AcpiDescription.h
index 4c1462712c..a2e6fd4f5b 100644
--- a/EdkCompatibilityPkg/Foundation/Guid/AcpiDescription/AcpiDescription.h
+++ b/EdkCompatibilityPkg/Foundation/Guid/AcpiDescription/AcpiDescription.h
@@ -1,6 +1,6 @@
/*++
-Copyright (c) 2006 - 2007, Intel Corporation. All rights reserved.<BR>
+Copyright (c) 2006 - 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
@@ -28,6 +28,7 @@ Abstract:
0x3c699197, 0x93c, 0x4c69, {0xb0, 0x6b, 0x12, 0x8a, 0xe3, 0x48, 0x1d, 0xc9} \
}
+#pragma pack(1)
typedef struct {
UINT8 AddressSpaceId;
UINT8 RegisterBitWidth;
@@ -52,7 +53,6 @@ typedef struct {
// Following structure defines ACPI Description information.
// This information is platform specific, may be consumed by DXE generic driver.
//
-#pragma pack(1)
typedef struct _EFI_ACPI_DESCRIPTION {
//
// For Timer
diff --git a/EdkCompatibilityPkg/Foundation/Guid/PciOptionRomTable/PciOptionRomTable.h b/EdkCompatibilityPkg/Foundation/Guid/PciOptionRomTable/PciOptionRomTable.h
index 8e5025161f..396d89cbd4 100644
--- a/EdkCompatibilityPkg/Foundation/Guid/PciOptionRomTable/PciOptionRomTable.h
+++ b/EdkCompatibilityPkg/Foundation/Guid/PciOptionRomTable/PciOptionRomTable.h
@@ -1,6 +1,6 @@
/*++
-Copyright (c) 2004, 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
@@ -20,6 +20,7 @@ Abstract:
--*/
#ifndef _PCI_OPTION_ROM_TABLE_GUID_H_
+#define _PCI_OPTION_ROM_TABLE_GUID_H_
#define EFI_PCI_OPTION_ROM_TABLE_GUID \
{ 0x7462660f, 0x1cbd, 0x48da, {0xad, 0x11, 0x91, 0x71, 0x79, 0x13, 0x83, 0x1c} }
diff --git a/EdkCompatibilityPkg/Foundation/Guid/PeiPeCoffLoader/PeiPeCoffLoader.h b/EdkCompatibilityPkg/Foundation/Guid/PeiPeCoffLoader/PeiPeCoffLoader.h
index 7fc640de96..57f91b7ff3 100644
--- a/EdkCompatibilityPkg/Foundation/Guid/PeiPeCoffLoader/PeiPeCoffLoader.h
+++ b/EdkCompatibilityPkg/Foundation/Guid/PeiPeCoffLoader/PeiPeCoffLoader.h
@@ -1,6 +1,6 @@
/*++
-Copyright (c) 2005 - 2006, Intel Corporation. All rights reserved.<BR>
+Copyright (c) 2005 - 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
@@ -75,6 +75,9 @@ typedef struct {
#ifdef EFI_NT_EMULATOR
VOID **ModHandle;
#endif
+#if (EFI_SPECIFICATION_VERSION >= 0x0002000A)
+ EFI_PHYSICAL_ADDRESS HiiResourceData;
+#endif
} EFI_PEI_PE_COFF_LOADER_IMAGE_CONTEXT;
typedef
diff --git a/EdkCompatibilityPkg/Foundation/Include/EfiSpec.h b/EdkCompatibilityPkg/Foundation/Include/EfiSpec.h
index d64c2b2b56..31b50deb8b 100644
--- a/EdkCompatibilityPkg/Foundation/Include/EfiSpec.h
+++ b/EdkCompatibilityPkg/Foundation/Include/EfiSpec.h
@@ -33,19 +33,5 @@ Abstract:
#include "EfiApi.h"
#include "EfiDevicePath.h"
-//
-// Check to make sure EFI_SPECIFICATION_VERSION and TIANO_RELEASE_VERSION are defined.
-//
-#if !defined(EFI_SPECIFICATION_VERSION)
- #error EFI_SPECIFICATION_VERSION not defined
-#elif !defined(TIANO_RELEASE_VERSION)
- #error TIANO_RELEASE_VERSION not defined
-#elif (TIANO_RELEASE_VERSION == 0)
-//
-// UEFI mode with no Tiano extensions is legal
-//
-#elif ((TIANO_RELEASE_VERSION < 0x00080005) && (EFI_SPECIFICATION_VERSION >= 0x00020000))
- #error Illegal combination of EFI_SPECIFICATION_VERSION and TIANO_RELEASE_VERSION versions
-#endif
#endif
diff --git a/EdkCompatibilityPkg/Foundation/Include/EfiTpm.h b/EdkCompatibilityPkg/Foundation/Include/EfiTpm.h
index 6d03ec4896..07a7fec735 100644
--- a/EdkCompatibilityPkg/Foundation/Include/EfiTpm.h
+++ b/EdkCompatibilityPkg/Foundation/Include/EfiTpm.h
@@ -25,7 +25,12 @@ Abstract:
#define _EFI_TPM_H_
#include "Tiano.h"
-#include "IndustryStandard/Tpm12.h"
+
+//
+// The start of TPM return codes
+//
+#define TPM_BASE (EFI_MAX_BIT + (EFI_MAX_BIT >> 1))
+#include "Tpm12.h"
//
// Standard event types
diff --git a/EdkCompatibilityPkg/Foundation/Include/IndustryStandard/Smbios.h b/EdkCompatibilityPkg/Foundation/Include/IndustryStandard/Smbios.h
index 89b3015713..901bd52ea7 100644
--- a/EdkCompatibilityPkg/Foundation/Include/IndustryStandard/Smbios.h
+++ b/EdkCompatibilityPkg/Foundation/Include/IndustryStandard/Smbios.h
@@ -1,6 +1,6 @@
/*++
-Copyright (c) 2007, Intel Corporation. All rights reserved.<BR>
+Copyright (c) 2007 - 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
@@ -22,6 +22,32 @@ Abstract:
#include "Tiano.h"
+//
+// Reference SMBIOS 2.6, chapter 3.1.2.
+// For v2.1 and later, handle values in the range 0FF00h to 0FFFFh are reserved for
+// use by this specification.
+//
+#define SMBIOS_HANDLE_RESERVED_BEGIN 0xFF00
+
+//
+// Reference SMBIOS 2.6, chapter 3.1.3
+// Each text string is limited to 64 significant characters due to system MIF limitations
+//
+#define SMBIOS_STRING_MAX_LENGTH 64
+
+//
+// Inactive type is added from SMBIOS 2.2. Reference SMBIOS 2.6, chapter 3.3.43.
+// Upper-level software that interprets the SMBIOS structure-table should bypass an
+// Inactive structure just like a structure type that the software does not recognize.
+//
+#define SMBIOS_TYPE_INACTIVE 0x007E
+
+//
+// End-of-table type is added from SMBIOS 2.2. Reference SMBIOS 2.6, chapter 3.3.44.
+// The end-of-table indicator is used in the last physical structure in a table
+//
+#define SMBIOS_TYPE_END_OF_TABLE 0x007F
+
#pragma pack(1)
typedef UINT8 SMBIOS_TABLE_STRING;
diff --git a/EdkCompatibilityPkg/Foundation/Include/IndustryStandard/Tpm12.h b/EdkCompatibilityPkg/Foundation/Include/IndustryStandard/Tpm12.h
index 0ba14cecfb..aa54b384ee 100644
--- a/EdkCompatibilityPkg/Foundation/Include/IndustryStandard/Tpm12.h
+++ b/EdkCompatibilityPkg/Foundation/Include/IndustryStandard/Tpm12.h
@@ -15,7 +15,7 @@ Module Name:
Abstract:
- TPM Specification data structures (TCG TPM Specification Version 1.2 Revision 94)
+ TPM Specification data structures (TCG TPM Specification Version 1.2 Revision 103)
See http://trustedcomputinggroup.org for latest specification updates
@@ -39,6 +39,7 @@ Abstract:
typedef UINT8 TPM_AUTH_DATA_USAGE;
typedef UINT8 TPM_PAYLOAD_TYPE;
typedef UINT8 TPM_VERSION_BYTE;
+typedef UINT8 TPM_DA_STATE;
typedef UINT16 TPM_TAG;
typedef UINT16 TPM_PROTOCOL_ID;
typedef UINT16 TPM_STARTUP_TYPE;
@@ -144,6 +145,9 @@ typedef UINT32 TPM_FAMILY_OPERATION;
#define TPM_TAG_CMK_SIGTICKET ((TPM_STRUCTURE_TAG) 0x0034)
#define TPM_TAG_CMK_MA_APPROVAL ((TPM_STRUCTURE_TAG) 0x0035)
#define TPM_TAG_QUOTE_INFO2 ((TPM_STRUCTURE_TAG) 0x0036)
+#define TPM_TAG_DA_INFO ((TPM_STRUCTURE_TAG) 0x0037)
+#define TPM_TAG_DA_LIMITED ((TPM_STRUCTURE_TAG) 0x0038)
+#define TPM_TAG_DA_ACTION_TYPE ((TPM_STRUCTURE_TAG) 0x0039)
//
// Part 2, section 4: TPM Types
@@ -190,6 +194,7 @@ typedef UINT32 TPM_FAMILY_OPERATION;
#define TPM_ET_DEL_KEY_BLOB ((UINT16) 0x0009) // The entity is a delegate key blob
#define TPM_ET_COUNTER ((UINT16) 0x000A) // The entity is a counter
#define TPM_ET_NV ((UINT16) 0x000B) // The entity is a NV index
+#define TPM_ET_OPERATOR ((UINT16) 0x000C) // The entity is the operator
#define TPM_ET_RESERVED_HANDLE ((UINT16) 0x0040) // Reserved. This value avoids collisions with the handle MSB setting.
//
// TPM_ENTITY_TYPE MSB Values: The MSB is used to indicate the ADIP encryption sheme when applicable
@@ -323,8 +328,6 @@ typedef TPM_DIGEST TPM_DIRVALUE; // This SHALL be the value of
typedef TPM_DIGEST TPM_HMAC;
typedef TPM_DIGEST TPM_PCRVALUE; // The value inside of the PCR
typedef TPM_DIGEST TPM_AUDITDIGEST; // This SHALL be the value of the current internal audit state
-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
-typedef TPM_DIGEST TPM_DAA_CONTEXT_SEED; // This SHALL be a random value
//
// Part 2, section 5.5: TPM_NONCE
@@ -333,6 +336,9 @@ typedef struct tdTPM_NONCE{
UINT8 nonce[20];
} TPM_NONCE;
+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
+typedef TPM_NONCE TPM_DAA_CONTEXT_SEED; // This SHALL be a random value
+
//
// Part 2, section 5.6: TPM_AUTHDATA
//
@@ -393,7 +399,8 @@ typedef struct tdTPM_KEY_HANDLE_LIST {
#define TPM_ES_NONE ((TPM_ENC_SCHEME) 0x0001)
#define TPM_ES_RSAESPKCSv15 ((TPM_ENC_SCHEME) 0x0002)
#define TPM_ES_RSAESOAEP_SHA1_MGF1 ((TPM_ENC_SCHEME) 0x0003)
-#define TPM_ES_SYM_CNT ((TPM_ENC_SCHEME) 0x0004)
+#define TPM_ES_SYM_CNT ((TPM_ENC_SCHEME) 0x0004) // rev94 defined
+#define TPM_ES_SYM_CTR ((TPM_ENC_SCHEME) 0x0004)
#define TPM_ES_SYM_OFB ((TPM_ENC_SCHEME) 0x0005)
#define TPM_SS_NONE ((TPM_SIG_SCHEME) 0x0001)
@@ -584,6 +591,7 @@ typedef struct tdTPM_PERMANENT_FLAGS{
BOOLEAN readSRKPub;
BOOLEAN tpmEstablished;
BOOLEAN maintenanceDone;
+ BOOLEAN disableFullDALogicInfo;
} TPM_PERMANENT_FLAGS;
//
@@ -608,6 +616,7 @@ typedef struct tdTPM_PERMANENT_FLAGS{
#define TPM_PF_READSRKPUB ((TPM_CAPABILITY_AREA) 17)
#define TPM_PF_TPMESTABLISHED ((TPM_CAPABILITY_AREA) 18)
#define TPM_PF_MAINTENANCEDONE ((TPM_CAPABILITY_AREA) 19)
+#define TPM_PF_DISABLEFULLDALOGICINFO ((TPM_CAPABILITY_AREA) 20)
//
// Part 2, section 7.2: TPM_STCLEAR_FLAGS
@@ -655,10 +664,11 @@ typedef struct tdTPM_STANY_FLAGS{
//
// Part 2, section 7.4: TPM_PERMANENT_DATA
//
-//#define TPM_MIN_COUNTERS 4 // the minimum number of counters is 4
-//#define TPM_DELEGATE_KEY TPM_KEY
-//#define TPM_NUM_PCR 16
-//#define TPM_MAX_NV_WRITE_NOOWNER 64
+#define TPM_MIN_COUNTERS 4 // the minimum number of counters is 4
+#define TPM_DELEGATE_KEY TPM_KEY
+#define TPM_NUM_PCR 16
+#define TPM_MAX_NV_WRITE_NOOWNER 64
+
//typedef struct tdTPM_PERMANENT_DATA
//{
// TPM_STRUCTURE_TAG tag;
@@ -686,20 +696,62 @@ typedef struct tdTPM_STANY_FLAGS{
// UINT32 noOwnerNVWrite;
// TPM_CMK_DELEGATE restrictDelegate;
// TPM_DAA_TPM_SEED tpmDAASeed;
+// TPM_NONCE daaProff;
+// TPM_KEY daaBlobKey;
//} TPM_PERMANENT_DATA;
//
+// Part 2, section 7.4.1: PERMANENT_DATA Subcap for SetCapability
+//
+#define TPM_PD_REVMAJOR ((TPM_CAPABILITY_AREA) 1)
+#define TPM_PD_REVMINOR ((TPM_CAPABILITY_AREA) 2)
+#define TPM_PD_TPMPROOF ((TPM_CAPABILITY_AREA) 3)
+#define TPM_PD_OWNERAUTH ((TPM_CAPABILITY_AREA) 4)
+#define TPM_PD_OPERATORAUTH ((TPM_CAPABILITY_AREA) 5)
+#define TPM_PD_MANUMAINTPUB ((TPM_CAPABILITY_AREA) 6)
+#define TPM_PD_ENDORSEMENTKEY ((TPM_CAPABILITY_AREA) 7)
+#define TPM_PD_SRK ((TPM_CAPABILITY_AREA) 8)
+#define TPM_PD_DELEGATEKEY ((TPM_CAPABILITY_AREA) 9)
+#define TPM_PD_CONTEXTKEY ((TPM_CAPABILITY_AREA) 10)
+#define TPM_PD_AUDITMONOTONICCOUNTER ((TPM_CAPABILITY_AREA) 11)
+#define TPM_PD_MONOTONICCOUNTER ((TPM_CAPABILITY_AREA) 12)
+#define TPM_PD_PCRATTRIB ((TPM_CAPABILITY_AREA) 13)
+#define TPM_PD_ORDINALAUDITSTATUS ((TPM_CAPABILITY_AREA) 14)
+#define TPM_PD_AUTHDIR ((TPM_CAPABILITY_AREA) 15)
+#define TPM_PD_RNGSTATE ((TPM_CAPABILITY_AREA) 16)
+#define TPM_PD_FAMILYTABLE ((TPM_CAPABILITY_AREA) 17)
+#define TPM_DELEGATETABLE ((TPM_CAPABILITY_AREA) 18)
+#define TPM_PD_EKRESET ((TPM_CAPABILITY_AREA) 19)
+#define TPM_PD_MAXNVBUFSIZE ((TPM_CAPABILITY_AREA) 20)
+#define TPM_PD_LASTFAMILYID ((TPM_CAPABILITY_AREA) 21)
+#define TPM_PD_NOOWNERNVWRITE ((TPM_CAPABILITY_AREA) 22)
+#define TPM_PD_RESTRICTDELEGATE ((TPM_CAPABILITY_AREA) 23)
+#define TPM_PD_TPMDAASEED ((TPM_CAPABILITY_AREA) 24)
+#define TPM_PD_DAAPROOF ((TPM_CAPABILITY_AREA) 25)
+
+//
// Part 2, section 7.5: TPM_STCLEAR_DATA
// available inside TPM only
//
-//typedef struct tdTPM_STCLEAR_DATA
-//{
-// TPM_STRUCTURE_TAG tag;
-// TPM_NONCE contextNonceKey;
-// TPM_COUNT_ID countID;
-// UINT32 ownerReference;
-// BOOLEAN disableResetLock;
-//} TPM_STCLEAR_DATA;
+ typedef struct tdTPM_STCLEAR_DATA{
+ TPM_STRUCTURE_TAG tag;
+ TPM_NONCE contextNonceKey;
+ TPM_COUNT_ID countID;
+ UINT32 ownerReference;
+ BOOLEAN disableResetLock;
+ TPM_PCRVALUE PCR[TPM_NUM_PCR];
+ UINT32 deferredPhysicalPresence;
+ }TPM_STCLEAR_DATA;
+
+//
+// Part 2, section 7.5.1: STCLEAR_DATA Subcap for SetCapability
+//
+#define TPM_SD_CONTEXTNONCEKEY ((TPM_CAPABILITY_AREA)0x00000001)
+#define TPM_SD_COUNTID ((TPM_CAPABILITY_AREA)0x00000002)
+#define TPM_SD_OWNERREFERENCE ((TPM_CAPABILITY_AREA)0x00000003)
+#define TPM_SD_DISABLERESETLOCK ((TPM_CAPABILITY_AREA)0x00000004)
+#define TPM_SD_PCR ((TPM_CAPABILITY_AREA)0x00000005)
+#define TPM_SD_DEFERREDPHYSICALPRESENCE ((TPM_CAPABILITY_AREA)0x00000006)
//
// Part 2, section 7.6: TPM_STANY_DATA
@@ -717,6 +769,16 @@ typedef struct tdTPM_STANY_FLAGS{
//} TPM_STANY_DATA;
//
+// Part 2, section 7.6.1: STANY_DATA Subcap for SetCapability
+//
+#define TPM_AD_CONTEXTNONCESESSION ((TPM_CAPABILITY_AREA) 1)
+#define TPM_AD_AUDITDIGEST ((TPM_CAPABILITY_AREA) 2)
+#define TPM_AD_CURRENTTICKS ((TPM_CAPABILITY_AREA) 3)
+#define TPM_AD_CONTEXTCOUNT ((TPM_CAPABILITY_AREA) 4)
+#define TPM_AD_CONTEXTLIST ((TPM_CAPABILITY_AREA) 5)
+#define TPM_AD_SESSIONS ((TPM_CAPABILITY_AREA) 6)
+
+//
// Part 2, section 8: PCR Structures
//
@@ -1137,7 +1199,9 @@ typedef struct tdTPM_AUDIT_EVENT_OUT
//
// Part 2, section 16: Return Codes
//
-#define TPM_BASE 0
+#ifndef TPM_BASE
+#error "TPM Error Codes require definition of TPM_BASE"
+#endif
#define TPM_VENDOR_ERROR TPM_Vendor_Specific32
#define TPM_NON_FATAL 0x00000800
@@ -1498,12 +1562,14 @@ typedef struct tdTPM_NV_DATA_PUBLIC
//
//
-// Part 2, section 20.3: Owner Permissions Settings for per1 bits
+// Part 2, section 20.2.1: Owner Permissions Settings for per1 bits
//
#define TPM_DELEGATE_SetOrdinalAuditStatus (((UINT32)1)<<30)
#define TPM_DELEGATE_DirWriteAuth (((UINT32)1)<<29)
#define TPM_DELEGATE_CMK_ApproveMA (((UINT32)1)<<28)
+#define TPM_DELEGATE_NV_WriteValue (((UINT32)1)<<27)
#define TPM_DELEGATE_CMK_CreateTicket (((UINT32)1)<<26)
+#define TPM_DELEGATE_NV_ReadValue (((UINT32)1)<<25)
#define TPM_DELEGATE_Delegate_LoadOwnerDelegation (((UINT32)1)<<24)
#define TPM_DELEGATE_DAA_Join (((UINT32)1)<<23)
#define TPM_DELEGATE_AuthorizeMigrationKey (((UINT32)1)<<22)
@@ -1514,6 +1580,7 @@ typedef struct tdTPM_NV_DATA_PUBLIC
#define TPM_DELEGATE_ResetLockValue (((UINT32)1)<<17)
#define TPM_DELEGATE_OwnerClear (((UINT32)1)<<16)
#define TPM_DELEGATE_DisableOwnerClear (((UINT32)1)<<15)
+#define TPM_DELEGATE_NV_DefineSpace (((UINT32)1)<<14)
#define TPM_DELEGATE_OwnerSetDisable (((UINT32)1)<<13)
#define TPM_DELEGATE_SetCapability (((UINT32)1)<<12)
#define TPM_DELEGATE_MakeIdentity (((UINT32)1)<<11)
@@ -1530,7 +1597,7 @@ typedef struct tdTPM_NV_DATA_PUBLIC
#define TPM_DELEGATE_DAA_Sign (((UINT32)1)<<0)
//
-// Part 2, section 20.3: Key Permissions Settings for per1 bits
+// Part 2, section 20.2.3: Key Permissions Settings for per1 bits
//
#define TPM_KEY_DELEGATE_CMK_ConvertMigration (((UINT32)1)<<28)
#define TPM_KEY_DELEGATE_TickStampBlob (((UINT32)1)<<27)
@@ -1723,6 +1790,15 @@ typedef struct tdTPM_DELEGATE_KEY_BLOB
#define TPM_CAP_PROP_INPUT_BUFFER ((TPM_CAPABILITY_AREA) 0x00000124)
//
+// Part 2, section 21.4: TPM_CAPABILITY_AREA for SetCapability
+//
+#define TPM_SET_PERM_FLAGS ((TPM_CAPABILITY_AREA) 0x00000001)
+#define TPM_SET_PERM_DATA ((TPM_CAPABILITY_AREA) 0x00000002)
+#define TPM_SET_STCLEAR_FLAGS ((TPM_CAPABILITY_AREA) 0x00000003)
+#define TPM_SET_STCLEAR_DATA ((TPM_CAPABILITY_AREA) 0x00000004)
+#define TPM_SET_STANY_FLAGS ((TPM_CAPABILITY_AREA) 0x00000005)
+#define TPM_SET_STANY_DATA ((TPM_CAPABILITY_AREA) 0x00000006)
+
// Part 2, section 21.6: TPM_CAP_VERSION_INFO
// [size_is(vendorSpecificSize)] BYTE* vendorSpecific;
//
@@ -1737,6 +1813,50 @@ typedef struct tdTPM_CAP_VERSION_INFO {
} TPM_CAP_VERSION_INFO;
//
+// Part 2, section 21.10: TPM_DA_ACTION_TYPE
+//
+typedef struct tdTPM_DA_ACTION_TYPE {
+ TPM_STRUCTURE_TAG tag;
+ UINT32 actions;
+} TPM_DA_ACTION_TYPE;
+
+#define TPM_DA_ACTION_FAILURE_MODE (((UINT32)1)<<3)
+#define TPM_DA_ACTION_DEACTIVATE (((UINT32)1)<<2)
+#define TPM_DA_ACTION_DISABLE (((UINT32)1)<<1)
+#define TPM_DA_ACTION_TIMEOUT (((UINT32)1)<<0)
+
+//
+// Part 2, section 21.7: TPM_DA_INFO
+//
+typedef struct tdTPM_DA_INFO {
+ TPM_STRUCTURE_TAG tag;
+ TPM_DA_STATE state;
+ UINT16 currentCount;
+ UINT16 thresholdCount;
+ TPM_DA_ACTION_TYPE actionAtThreshold;
+ UINT32 actionDependValue;
+ UINT32 vendorDataSize;
+ UINT8 *vendorData;
+} TPM_DA_INFO;
+
+//
+// Part 2, section 21.8: TPM_DA_INFO_LIMITED
+//
+typedef struct tdTPM_DA_INFO_LIMITED {
+ TPM_STRUCTURE_TAG tag;
+ TPM_DA_STATE state;
+ TPM_DA_ACTION_TYPE actionAtThreshold;
+ UINT32 vendorDataSize;
+ UINT8 *vendorData;
+} TPM_DA_INFO_LIMITED;
+
+//
+// Part 2, section 21.9: CAP_PROPERTY Subcap values for GetCapability
+//
+#define TPM_DA_STATE_INACTIVE ((UINT8)0x00)
+#define TPM_DA_STATE_ACTIVE ((UINT8)0x01)
+
+//
// Part 2, section 22: DAA Structures
//
diff --git a/EdkCompatibilityPkg/Foundation/Include/IndustryStandard/pci23.h b/EdkCompatibilityPkg/Foundation/Include/IndustryStandard/pci23.h
index 0957c86d25..e1be8f5a87 100644
--- a/EdkCompatibilityPkg/Foundation/Include/IndustryStandard/pci23.h
+++ b/EdkCompatibilityPkg/Foundation/Include/IndustryStandard/pci23.h
@@ -1,6 +1,6 @@
/*++
-Copyright (c) 2006 - 2007, Intel Corporation. All rights reserved.<BR>
+Copyright (c) 2006 - 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
@@ -25,6 +25,16 @@ Revision History
#include "pci22.h"
+//
+// PCI_CLASS_MASS_STORAGE
+//
+#define PCI_CLASS_MASS_STORAGE_ATA 0x05
+
+//
+// PCI_CLASS_SERIAL
+//
+#define PCI_CLASS_SERIAL_IB 0x06
+
#define PCI_EXP_MAX_CONFIG_OFFSET 0x1000
#define EFI_PCI_CAPABILITY_ID_PCIEXP 0x10
diff --git a/EdkCompatibilityPkg/Foundation/Include/IndustryStandard/scsi.h b/EdkCompatibilityPkg/Foundation/Include/IndustryStandard/scsi.h
index 2c2025583b..0ae3bfd336 100644
--- a/EdkCompatibilityPkg/Foundation/Include/IndustryStandard/scsi.h
+++ b/EdkCompatibilityPkg/Foundation/Include/IndustryStandard/scsi.h
@@ -1,6 +1,6 @@
/*++
-Copyright (c) 2004 - 2006, 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
@@ -56,6 +56,7 @@ Revision History
#define EFI_SCSI_OP_READ6 0x08
#define EFI_SCSI_OP_READ10 0x28
#define EFI_SCSI_OP_READ_CAPACITY 0x25
+#define EFI_SCSI_OP_READ_CAPACITY16 0x9e
#define EFI_SCSI_OP_READ_DEFECT 0x37
#define EFI_SCSI_OP_READ_LONG 0x3e
#define EFI_SCSI_OP_REASSIGN_BLK 0x07
@@ -238,6 +239,27 @@ typedef struct {
UINT8 BlockSize0;
} EFI_SCSI_DISK_CAPACITY_DATA;
+typedef struct {
+ UINT8 LastLba7;
+ UINT8 LastLba6;
+ UINT8 LastLba5;
+ UINT8 LastLba4;
+ UINT8 LastLba3;
+ UINT8 LastLba2;
+ UINT8 LastLba1;
+ UINT8 LastLba0;
+ UINT8 BlockSize3;
+ UINT8 BlockSize2;
+ UINT8 BlockSize1;
+ UINT8 BlockSize0;
+ UINT8 Protection;
+ UINT8 LogicPerPhysical;
+ UINT8 LowestAlignLogic2;
+ UINT8 LowestAlignLogic1;
+ UINT8 Reserved[16];
+} EFI_SCSI_DISK_CAPACITY_DATA16;
+
+
#pragma pack()
//
// Sense Key
diff --git a/EdkCompatibilityPkg/Foundation/Include/Tiano.h b/EdkCompatibilityPkg/Foundation/Include/Tiano.h
index f26515251c..159936fa75 100644
--- a/EdkCompatibilityPkg/Foundation/Include/Tiano.h
+++ b/EdkCompatibilityPkg/Foundation/Include/Tiano.h
@@ -27,18 +27,6 @@ Abstract:
#ifndef _TIANO_H_
#define _TIANO_H_
-//
-// Check to make sure EFI_SPECIFICATION_VERSION and TIANO_RELEASE_VERSION are defined.
-//
-#if !defined(EFI_SPECIFICATION_VERSION)
- #error EFI_SPECIFICATION_VERSION not defined
-#elif !defined(TIANO_RELEASE_VERSION)
- #error TIANO_RELEASE_VERSION not defined
-#elif (TIANO_RELEASE_VERSION == 0)
- #error TIANO_RELEASE_VERSION can not be zero
-#elif (EFI_SPECIFICATION_VERSION <= 0x00020000)
- #define TIANO_EXTENSION_FLAG
-#endif
#include "TianoCommon.h"
#include "TianoApi.h"
diff --git a/EdkCompatibilityPkg/Foundation/Include/TianoHii.h b/EdkCompatibilityPkg/Foundation/Include/TianoHii.h
index fd97e4215a..ba17702d15 100644
--- a/EdkCompatibilityPkg/Foundation/Include/TianoHii.h
+++ b/EdkCompatibilityPkg/Foundation/Include/TianoHii.h
@@ -1,6 +1,6 @@
/*++
-Copyright (c) 2007, Intel Corporation. All rights reserved.<BR>
+Copyright (c) 2007 - 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
@@ -50,6 +50,11 @@ Revision History
//
#define EFI_IFR_TIANO_GUID \
{ 0xf0b1735, 0x87a0, 0x4193, {0xb2, 0x66, 0x53, 0x8c, 0x38, 0xaf, 0x48, 0xce} }
+//
+// ClassGuid for Front Page
+//
+#define EFI_HII_FRONT_PAGE_CLASS_GUID \
+ { 0x94d411b7, 0x7669, 0x45c3, {0xba, 0x3b, 0xf3, 0xa5, 0x8a, 0x71, 0x56, 0x81} }
#pragma pack(1)
diff --git a/EdkCompatibilityPkg/Foundation/Library/CompilerStub/CompilerStubLib.inf b/EdkCompatibilityPkg/Foundation/Library/CompilerStub/CompilerStubLib.inf
index d0aef2f1b6..72f19fbca7 100644
--- a/EdkCompatibilityPkg/Foundation/Library/CompilerStub/CompilerStubLib.inf
+++ b/EdkCompatibilityPkg/Foundation/Library/CompilerStub/CompilerStubLib.inf
@@ -1,6 +1,6 @@
#/*++
#
-# Copyright (c) 2006 - 2007, Intel Corporation. All rights reserved.<BR>
+# Copyright (c) 2006 - 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
@@ -34,8 +34,8 @@ COMPONENT_TYPE = LIBRARY
memset.c | GCC
[sources.x64]
- x64/memcpyRep1.asm | MSFT
- x64/memcpyRep1.asm | INTEL
+ x64/memcpyRep4.asm | MSFT
+ x64/memcpyRep4.asm | INTEL
x64/memsetRep4.asm | MSFT
x64/memsetRep4.asm | INTEL
memcpy.c | GCC
diff --git a/EdkCompatibilityPkg/Foundation/Library/CompilerStub/CompilerStubLib_Edk2.inf b/EdkCompatibilityPkg/Foundation/Library/CompilerStub/CompilerStubLib_Edk2.inf
index 909ee60936..bbe3f33d5d 100644
--- a/EdkCompatibilityPkg/Foundation/Library/CompilerStub/CompilerStubLib_Edk2.inf
+++ b/EdkCompatibilityPkg/Foundation/Library/CompilerStub/CompilerStubLib_Edk2.inf
@@ -1,6 +1,6 @@
#/*++
#
-# Copyright (c) 2006 - 2007, Intel Corporation. All rights reserved.<BR>
+# Copyright (c) 2006 - 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
@@ -34,7 +34,7 @@ COMPONENT_TYPE = LIBRARY
[sources.x64]
memcpy.c | GCC
- x64/memcpyRep1.asm
+ x64/memcpyRep4.asm
x64/memsetRep4.asm
# x64/memcpy.asm
# x64/memset.asm
diff --git a/EdkCompatibilityPkg/Foundation/Library/Dxe/EfiDriverLib/DevicePath.c b/EdkCompatibilityPkg/Foundation/Library/Dxe/EfiDriverLib/DevicePath.c
index 568ac12613..daa01a29a7 100644
--- a/EdkCompatibilityPkg/Foundation/Library/Dxe/EfiDriverLib/DevicePath.c
+++ b/EdkCompatibilityPkg/Foundation/Library/Dxe/EfiDriverLib/DevicePath.c
@@ -1,6 +1,6 @@
/*++
-Copyright (c) 2004 - 2007, 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
@@ -502,13 +502,6 @@ Routine Description:
Initialize a Firmware Volume (FV) Media Device Path node.
- Tiano extended the EFI 1.10 device path nodes. Tiano does not own this enum
- so as we move to UEFI 2.0 support we must use a mechanism that conforms with
- the UEFI 2.0 specification to define the FV device path. An UEFI GUIDed
- device path is defined for PIWG extensions of device path. If the code
- is compiled to conform with the UEFI 2.0 specification use the new device path
- else use the old form for backwards compatability.
-
Arguments:
FvDevicePathNode - Pointer to a FV device path node to initialize
@@ -520,12 +513,6 @@ Returns:
--*/
{
- //
- // EFI Specification extension on Media Device Path. MEDIA_FW_VOL_FILEPATH_DEVICE_PATH is adopted by UEFI later and added in UEFI2.10.
- // In EdkCompatibility Package, we only support MEDIA_FW_VOL_FILEPATH_DEVICE_PATH that complies with
- // EFI 1.10 and UEFI 2.10.
- //
-
FvDevicePathNode->Header.Type = MEDIA_DEVICE_PATH;
FvDevicePathNode->Header.SubType = MEDIA_FV_FILEPATH_DP;
SetDevicePathNodeLength (&FvDevicePathNode->Header, sizeof (MEDIA_FW_VOL_FILEPATH_DEVICE_PATH));
@@ -544,15 +531,6 @@ Routine Description:
Check to see if the Firmware Volume (FV) Media Device Path is valid.
- Tiano extended the EFI 1.10 device path nodes. Tiano does not own this enum
- so as we move to UEFI 2.0 support we must use a mechanism that conforms with
- the UEFI 2.0 specification to define the FV device path. An UEFI GUIDed
- device path is defined for PIWG extensions of device path. If the code
- is compiled to conform with the UEFI 2.0 specification use the new device path
- else use the old form for backwards compatability. The return value to this
- function points to a location in FvDevicePathNode and it does not allocate
- new memory for the GUID pointer that is returned.
-
Arguments:
FvDevicePathNode - Pointer to FV device path to check
@@ -564,11 +542,6 @@ Returns:
--*/
{
- //
- // EFI Specification extension on Media Device Path. MEDIA_FW_VOL_FILEPATH_DEVICE_PATH is adopted by UEFI later and added in UEFI2.10.
- // In EdkCompatibility Package, we only support MEDIA_FW_VOL_FILEPATH_DEVICE_PATH that complies with
- // EFI 1.10 and UEFI 2.10.
- //
if (DevicePathType (&FvDevicePathNode->Header) == MEDIA_DEVICE_PATH &&
DevicePathSubType (&FvDevicePathNode->Header) == MEDIA_FV_FILEPATH_DP) {
return &FvDevicePathNode->NameGuid;
diff --git a/EdkCompatibilityPkg/Foundation/Library/Dxe/EfiDriverLib/EfiDriverLib.c b/EdkCompatibilityPkg/Foundation/Library/Dxe/EfiDriverLib/EfiDriverLib.c
index 3de6c59dc2..ef10d41702 100644
--- a/EdkCompatibilityPkg/Foundation/Library/Dxe/EfiDriverLib/EfiDriverLib.c
+++ b/EdkCompatibilityPkg/Foundation/Library/Dxe/EfiDriverLib/EfiDriverLib.c
@@ -1,6 +1,6 @@
/*++
-Copyright (c) 2004 - 2007, 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
@@ -21,6 +21,18 @@ Abstract:
#include "Tiano.h"
#include "EfiDriverLib.h"
+#include EFI_ARCH_PROTOCOL_DEFINITION (StatusCode)
+
+#if (EFI_SPECIFICATION_VERSION >= 0x00020000)
+
+VOID
+EFIAPI
+OnStatusCodeInstall (
+ IN EFI_EVENT Event,
+ IN VOID *Context
+ );
+
+#endif
//
// Global Interface for Debug Mask Protocol
@@ -50,6 +62,10 @@ Returns:
--*/
{
+#if (EFI_SPECIFICATION_VERSION >= 0x00020000)
+ VOID *Registration;
+#endif
+
gST = SystemTable;
ASSERT (gST != NULL);
@@ -70,6 +86,21 @@ Returns:
(VOID *) &gDebugMaskInterface
);
#endif
+
+#if (EFI_SPECIFICATION_VERSION >= 0x00020000)
+ //
+ // Register EFI_STATUS_CODE_PROTOCOL notify function
+ //
+ EfiLibCreateProtocolNotifyEvent (
+ &gEfiStatusCodeRuntimeProtocolGuid,
+ EFI_TPL_CALLBACK,
+ OnStatusCodeInstall,
+ NULL,
+ &Registration
+ );
+
+#endif
+
//
// Should be at EFI_D_INFO, but lets us know things are running
//
@@ -78,55 +109,107 @@ Returns:
return EFI_SUCCESS;
}
+STATIC
+BOOLEAN
+IsIso639LanguageCode (
+ IN CHAR8 *Languages
+ )
+/*++
+
+Routine Description:
+
+ Tests whether a language code has format of ISO639-2.
+
+Arguments:
+
+ Languages - The language code to be tested.
+
+Returns:
+
+ TRUE - Language code format is ISO 639-2.
+ FALSE - Language code format is not ISO 639-2.
+
+--*/
+{
+ UINTN Index;
+
+ //
+ // Find out format of Languages
+ //
+ for (Index = 0; Languages[Index] != 0 && Languages[Index] != ';' && Languages[Index] != '-'; Index++);
+ if (Languages[Index] != 0) {
+ //
+ // RFC4646 language code
+ //
+ return FALSE;
+ }
+
+ //
+ // No ';' and '-', it's either ISO639-2 code (list) or single RFC4646 code
+ //
+ if (Index == 2) {
+ //
+ // Single RFC4646 language code without country code, e.g. "en"
+ //
+ return FALSE;
+ }
+
+ //
+ // Languages in format of ISO639-2
+ //
+ return TRUE;
+}
+
BOOLEAN
EfiLibCompareLanguage (
- IN CHAR8 *Language1,
- IN CHAR8 *Language2
+ IN CHAR8 *Language1,
+ IN CHAR8 *Language2
)
/*++
Routine Description:
- Compare whether two names of languages are identical.
+ Compare the first language instance of two language codes, either could be a
+ single language code or a language code list. This function assume Language1
+ and Language2 has the same language code format, i.e. either ISO639-2 or RFC4646.
Arguments:
- Language1 - Name of language 1
- Language2 - Name of language 2
+ Language1 - The first language code to be tested.
+ Language2 - The second language code to be tested.
Returns:
- TRUE - same
- FALSE - not same
+ TRUE - Language code match.
+ FALSE - Language code mismatch.
--*/
{
UINTN Index;
-#if (EFI_SPECIFICATION_VERSION >= 0x00020000)
- for (Index = 0; (Language1[Index] != 0) && (Language2[Index] != 0); Index++) {
- if (Language1[Index] != Language2[Index]) {
- return FALSE;
- }
+ //
+ // Compare first two bytes of language tag
+ //
+ if ((Language1[0] != Language2[0]) || (Language1[1] != Language2[1])) {
+ return FALSE;
}
- if (((Language1[Index] == 0) && (Language2[Index] == 0)) ||
- ((Language1[Index] == 0) && (Language2[Index] != ';')) ||
- ((Language1[Index] == ';') && (Language2[Index] != 0)) ||
- ((Language1[Index] == ';') && (Language2[Index] != ';'))) {
- return TRUE;
+ if (IsIso639LanguageCode (Language1)) {
+ //
+ // ISO639-2 language code, compare the third byte of language tag
+ //
+ return (BOOLEAN) ((Language1[2] == Language2[2]) ? TRUE : FALSE);
}
- return FALSE;
-#else
- for (Index = 0; Index < 3; Index++) {
- if (Language1[Index] != Language2[Index]) {
- return FALSE;
- }
+ //
+ // RFC4646 language code
+ //
+ for (Index = 0; Language1[Index] != 0 && Language1[Index] != ';'; Index++);
+ if ((EfiAsciiStrnCmp (Language1, Language2, Index) == 0) && (Language2[Index] == 0 || Language2[Index] == ';')) {
+ return TRUE;
}
- return TRUE;
-#endif
+ return FALSE;
}
STATIC
@@ -134,19 +217,39 @@ CHAR8 *
NextSupportedLanguage (
IN CHAR8 *Languages
)
+/*++
+
+Routine Description:
+
+ Step to next language code of a language code list.
+
+Arguments:
+
+ Languages - The language code list to traverse.
+
+Returns:
+
+ Pointer to next language code or NULL terminator if it's the last one.
+
+--*/
{
-#ifdef LANGUAGE_RFC_3066 // LANGUAGE_RFC_3066
- for (; (*Languages != 0) && (*Languages != ';'); Languages++)
- ;
+ UINTN Index;
- if (*Languages == ';') {
- Languages++;
+ if (IsIso639LanguageCode (Languages)) {
+ //
+ // ISO639-2 language code
+ //
+ return (Languages + 3);
}
- return Languages;
-#else // LANGUAGE_ISO_639_2
- return (Languages + 3);
-#endif
+ //
+ // Search in RFC4646 language code list
+ //
+ for (Index = 0; Languages[Index] != 0 && Languages[Index] != ';'; Index++);
+ if (Languages[Index] == ';') {
+ Index++;
+ }
+ return (Languages + Index);
}
EFI_STATUS
@@ -217,7 +320,7 @@ Returns:
return EFI_UNSUPPORTED;
}
- SupportedLanguages = NextSupportedLanguage(SupportedLanguages);
+ SupportedLanguages = NextSupportedLanguage (SupportedLanguages);
}
return EFI_UNSUPPORTED;
@@ -326,7 +429,7 @@ Returns:
//
// Allocate space for a copy of the Language specifier
//
- NewUnicodeStringTable[NumberOfEntries].Language = EfiLibAllocateCopyPool (EfiAsciiStrLen(Language) + 1, Language);
+ NewUnicodeStringTable[NumberOfEntries].Language = EfiLibAllocateCopyPool (EfiAsciiStrSize (Language), Language);
if (NewUnicodeStringTable[NumberOfEntries].Language == NULL) {
gBS->FreePool (NewUnicodeStringTable);
return EFI_OUT_OF_RESOURCES;
@@ -372,7 +475,7 @@ Returns:
return EFI_SUCCESS;
}
- SupportedLanguages = NextSupportedLanguage(SupportedLanguages);
+ SupportedLanguages = NextSupportedLanguage (SupportedLanguages);
}
return EFI_UNSUPPORTED;
diff --git a/EdkCompatibilityPkg/Foundation/Library/Dxe/EfiDriverLib/ReportStatusCode.c b/EdkCompatibilityPkg/Foundation/Library/Dxe/EfiDriverLib/ReportStatusCode.c
index 547c203a83..e5b84d205a 100644
--- a/EdkCompatibilityPkg/Foundation/Library/Dxe/EfiDriverLib/ReportStatusCode.c
+++ b/EdkCompatibilityPkg/Foundation/Library/Dxe/EfiDriverLib/ReportStatusCode.c
@@ -1,6 +1,6 @@
/*++
-Copyright (c) 2004 - 2006, 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
@@ -19,12 +19,85 @@ Abstract:
#include "Tiano.h"
#include "EfiDriverLib.h"
+#include "PeiHob.h"
#include EFI_PROTOCOL_DEFINITION (DevicePath)
+#include EFI_GUID_DEFINITION (Hob)
#include EFI_GUID_DEFINITION (StatusCodeDataTypeId)
#include EFI_ARCH_PROTOCOL_DEFINITION (StatusCode)
#if (EFI_SPECIFICATION_VERSION >= 0x00020000)
-STATIC EFI_STATUS_CODE_PROTOCOL *gStatusCode = NULL;
+
+EFI_REPORT_STATUS_CODE gReportStatusCode = NULL;
+
+VOID
+EFIAPI
+OnStatusCodeInstall (
+ IN EFI_EVENT Event,
+ IN VOID *Context
+ )
+{
+ EFI_STATUS Status;
+ EFI_STATUS_CODE_PROTOCOL *StatusCode;
+
+ Status = gBS->LocateProtocol (&gEfiStatusCodeRuntimeProtocolGuid, NULL, (VOID **) &StatusCode);
+ if (!EFI_ERROR (Status)) {
+ gReportStatusCode = StatusCode->ReportStatusCode;
+ }
+}
+
+EFI_STATUS
+GetPeiProtocol (
+ IN EFI_GUID *ProtocolGuid,
+ IN VOID **Interface
+ )
+/*++
+
+Routine Description:
+
+ Searches for a Protocol Interface passed from PEI through a HOB
+
+Arguments:
+
+ ProtocolGuid - The Protocol GUID to search for in the HOB List
+ Interface - A pointer to the interface for the Protocol GUID
+
+Returns:
+
+ EFI_SUCCESS - The Protocol GUID was found and its interface is returned in Interface
+ EFI_NOT_FOUND - The Protocol GUID was not found in the HOB List
+
+--*/
+{
+ EFI_STATUS Status;
+ EFI_PEI_HOB_POINTERS GuidHob;
+
+ //
+ // Get Hob list
+ //
+ Status = EfiLibGetSystemConfigurationTable (&gEfiHobListGuid, (VOID **) &GuidHob.Raw);
+ if (EFI_ERROR (Status)) {
+ return Status;
+ }
+
+ for (Status = EFI_NOT_FOUND; EFI_ERROR (Status);) {
+ if (END_OF_HOB_LIST (GuidHob)) {
+ Status = EFI_NOT_FOUND;
+ break;
+ }
+
+ if (GET_HOB_TYPE (GuidHob) == EFI_HOB_TYPE_GUID_EXTENSION) {
+ if (EfiCompareGuid (ProtocolGuid, &GuidHob.Guid->Name)) {
+ Status = EFI_SUCCESS;
+ *Interface = (VOID *) *(UINTN *) ((UINT8 *) (&GuidHob.Guid->Name) + sizeof (EFI_GUID));
+ }
+ }
+
+ GuidHob.Raw = GET_NEXT_HOB (GuidHob);
+ }
+
+ return Status;
+}
+
#endif
EFI_STATUS
@@ -59,18 +132,28 @@ Returns:
{
EFI_STATUS Status;
-#if (EFI_SPECIFICATION_VERSION >= 0x00020000)
- if (gStatusCode == NULL) {
+#if (EFI_SPECIFICATION_VERSION >= 0x00020000)
+ if (gReportStatusCode == NULL) {
+ //
+ // Because we've installed the protocol notification on EfiStatusCodeRuntimeProtocol,
+ // running here indicates that the StatusCode driver has not started yet.
+ //
if (gBS == NULL) {
+ //
+ // Running here only when StatusCode driver never starts.
+ //
return EFI_UNSUPPORTED;
}
- Status = gBS->LocateProtocol (&gEfiStatusCodeRuntimeProtocolGuid, NULL, (VOID **)&gStatusCode);
- if (EFI_ERROR (Status) || gStatusCode == NULL) {
+
+ //
+ // Try to get the PEI version of ReportStatusCode.
+ //
+ Status = GetPeiProtocol (&gEfiStatusCodeRuntimeProtocolGuid, (VOID **) &gReportStatusCode);
+ if (EFI_ERROR (Status)) {
return EFI_UNSUPPORTED;
}
}
- Status = gStatusCode->ReportStatusCode (Type, Value, Instance, CallerId, Data);
- return Status;
+ Status = gReportStatusCode (Type, Value, Instance, CallerId, Data);
#else
if (gRT == NULL) {
return EFI_UNSUPPORTED;
@@ -84,8 +167,8 @@ Returns:
gRT->ReportStatusCode != NULL) {
Status = gRT->ReportStatusCode (Type, Value, Instance, CallerId, Data);
}
- return Status;
#endif
+ return Status;
}
EFI_STATUS
diff --git a/EdkCompatibilityPkg/Foundation/Library/Dxe/EfiIfrSupportLib/EfiIfrSupportLib.inf b/EdkCompatibilityPkg/Foundation/Library/Dxe/EfiIfrSupportLib/EfiIfrSupportLib.inf
index 63e09d0087..5cbbe02104 100644
--- a/EdkCompatibilityPkg/Foundation/Library/Dxe/EfiIfrSupportLib/EfiIfrSupportLib.inf
+++ b/EdkCompatibilityPkg/Foundation/Library/Dxe/EfiIfrSupportLib/EfiIfrSupportLib.inf
@@ -1,6 +1,6 @@
#/*++
#
-# Copyright (c) 2004, 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
@@ -41,7 +41,6 @@ COMPONENT_TYPE = LIBRARY
$(EDK_SOURCE)/Foundation/Include/IndustryStandard
$(EDK_SOURCE)/Foundation/Core/Dxe
$(EDK_SOURCE)/Foundation/Library/Dxe/Include
- $(EDK_SOURCE)/Foundation/Library/Dxe/EfiDriverLib
[libraries.common]
EfiGuidLib
diff --git a/EdkCompatibilityPkg/Foundation/Library/Dxe/EfiScriptLib/EfiScriptLib.inf b/EdkCompatibilityPkg/Foundation/Library/Dxe/EfiScriptLib/EfiScriptLib.inf
index 47b084e09b..a6b7f06a50 100644
--- a/EdkCompatibilityPkg/Foundation/Library/Dxe/EfiScriptLib/EfiScriptLib.inf
+++ b/EdkCompatibilityPkg/Foundation/Library/Dxe/EfiScriptLib/EfiScriptLib.inf
@@ -30,7 +30,6 @@ COMPONENT_TYPE = LIBRARY
[includes.common]
$(EDK_SOURCE)/Foundation/Framework
$(EDK_SOURCE)/Foundation/Efi
-# $(EFI_SOURCE)/Framework
.
$(EDK_SOURCE)/Foundation/Include
$(EDK_SOURCE)/Foundation/Efi/Include
diff --git a/EdkCompatibilityPkg/Foundation/Library/Dxe/EfiUiLib/EfiUiLib.c b/EdkCompatibilityPkg/Foundation/Library/Dxe/EfiUiLib/EfiUiLib.c
index b913d3fac2..9d4260768c 100644
--- a/EdkCompatibilityPkg/Foundation/Library/Dxe/EfiUiLib/EfiUiLib.c
+++ b/EdkCompatibilityPkg/Foundation/Library/Dxe/EfiUiLib/EfiUiLib.c
@@ -1,6 +1,6 @@
/*++
-Copyright (c) 2007, Intel Corporation. All rights reserved.<BR>
+Copyright (c) 2007 - 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
@@ -23,7 +23,6 @@ Revision History:
#define IS_DIGIT(Ch) (((Ch) >= L'0') && ((Ch) <= L'9'))
-STATIC
EFI_STATUS
EfiStringToValue (
OUT UINT64 *Val,
@@ -37,8 +36,6 @@ Routine Description:
The returned value is 64-bit.
The string is expected in decimal format,
the string is parsed and format verified.
- This function is missing from the libs. One day it maybe
- replaced with a lib function when it'll become available.
Arguments:
Val - pointer to the variable to store the value to
diff --git a/EdkCompatibilityPkg/Foundation/Library/Dxe/Include/EfiDriverLib.h b/EdkCompatibilityPkg/Foundation/Library/Dxe/Include/EfiDriverLib.h
index bd8de3a1cf..c417242552 100644
--- a/EdkCompatibilityPkg/Foundation/Library/Dxe/Include/EfiDriverLib.h
+++ b/EdkCompatibilityPkg/Foundation/Library/Dxe/Include/EfiDriverLib.h
@@ -106,10 +106,8 @@ typedef struct {
CHAR16 *UnicodeString;
} EFI_UNICODE_STRING_TABLE;
#if (EFI_SPECIFICATION_VERSION >= 0x00020000)
-#define LANGUAGE_RFC_3066
#define LANGUAGE_CODE_ENGLISH "en-US"
#else
-#define LANGUAGE_ISO_639_2
#define LANGUAGE_CODE_ENGLISH "eng"
#endif
@@ -1179,13 +1177,6 @@ EfiInitializeFwVolDevicepathNode (
Routine Description:
Initialize a Firmware Volume (FV) Media Device Path node.
- Tiano extended the EFI 1.10 device path nodes. Tiano does not own this enum
- so as we move to UEFI 2.0 support we must use a mechanism that conforms with
- the UEFI 2.0 specification to define the FV device path. An UEFI GUIDed
- device path is defined for PIWG extensions of device path. If the code
- is compiled to conform with the UEFI 2.0 specification use the new device path
- else use the old form for backwards compatability.
-
Arguments:
FvDevicePathNode - Pointer to a FV device path node to initialize
NameGuid - FV file name to use in FvDevicePathNode
@@ -1202,15 +1193,6 @@ EfiGetNameGuidFromFwVolDevicePathNode (
Routine Description:
Check to see if the Firmware Volume (FV) Media Device Path is valid.
- Tiano extended the EFI 1.10 device path nodes. Tiano does not own this enum
- so as we move to UEFI 2.0 support we must use a mechanism that conforms with
- the UEFI 2.0 specification to define the FV device path. An UEFI GUIDed
- device path is defined for PIWG extensions of device path. If the code
- is compiled to conform with the UEFI 2.0 specification use the new device path
- else use the old form for backwards compatability. The return value to this
- function points to a location in FvDevicePathNode and it does not allocate
- new memory for the GUID pointer that is returned.
-
Arguments:
FvDevicePathNode - Pointer to FV device path to check
diff --git a/EdkCompatibilityPkg/Foundation/Library/Dxe/Include/EfiUiLib.h b/EdkCompatibilityPkg/Foundation/Library/Dxe/Include/EfiUiLib.h
index 7cfeffe5fb..946742cb17 100644
--- a/EdkCompatibilityPkg/Foundation/Library/Dxe/Include/EfiUiLib.h
+++ b/EdkCompatibilityPkg/Foundation/Library/Dxe/Include/EfiUiLib.h
@@ -1,6 +1,6 @@
/*++
-Copyright (c) 2004, 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
@@ -202,4 +202,33 @@ Returns:
--*/
;
+EFI_STATUS
+EfiStringToValue (
+ OUT UINT64 *Val,
+ IN CHAR16 *String,
+ OUT UINT8 *EndIdx OPTIONAL
+ )
+/*++
+
+Routine Description:
+ Parses and converts Unicode string to decimal value.
+ The returned value is 64-bit.
+ The string is expected in decimal format,
+ the string is parsed and format verified.
+
+Arguments:
+ Val - pointer to the variable to store the value to
+ String - string that contains the value to parse and convert
+ EndIdx - index on which the parsing stopped. It points to the
+ first character that was not part of the returned Val.
+ It's valid only if the function returns success.
+ It's optional and it could be NULL.
+
+Returns:
+ EFI_SUCCESS - if successful
+ EFI_INVALID_PARAMETER - if String is in unexpected format
+
+--*/
+;
+
#endif
diff --git a/EdkCompatibilityPkg/Foundation/Library/Dxe/UefiEfiIfrSupportLib/UefiEfiIfrSupportLib.inf b/EdkCompatibilityPkg/Foundation/Library/Dxe/UefiEfiIfrSupportLib/UefiEfiIfrSupportLib.inf
index c70fb87e79..ae771b13a5 100644
--- a/EdkCompatibilityPkg/Foundation/Library/Dxe/UefiEfiIfrSupportLib/UefiEfiIfrSupportLib.inf
+++ b/EdkCompatibilityPkg/Foundation/Library/Dxe/UefiEfiIfrSupportLib/UefiEfiIfrSupportLib.inf
@@ -1,6 +1,6 @@
#/*++
#
-# Copyright (c) 2007, Intel Corporation. All rights reserved.<BR>
+# Copyright (c) 2007 - 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
@@ -41,7 +41,6 @@ COMPONENT_TYPE = LIBRARY
$(EDK_SOURCE)/Foundation/Include/IndustryStandard
$(EDK_SOURCE)/Foundation/Core/Dxe
$(EDK_SOURCE)/Foundation/Library/Dxe/Include
- $(EDK_SOURCE)/Foundation/Library/Dxe/EfiDriverLib
[libraries.common]
EfiGuidLib
diff --git a/EdkCompatibilityPkg/Foundation/Library/Dxe/UefiEfiIfrSupportLib/UefiIfrCommon.c b/EdkCompatibilityPkg/Foundation/Library/Dxe/UefiEfiIfrSupportLib/UefiIfrCommon.c
index 90afafe837..c41a85c38d 100644
--- a/EdkCompatibilityPkg/Foundation/Library/Dxe/UefiEfiIfrSupportLib/UefiIfrCommon.c
+++ b/EdkCompatibilityPkg/Foundation/Library/Dxe/UefiEfiIfrSupportLib/UefiIfrCommon.c
@@ -37,6 +37,7 @@ HII_VENDOR_DEVICE_PATH mHiiVendorDevicePathTemplate = {
},
EFI_IFR_TIANO_GUID,
},
+ 0,
0
},
{
@@ -181,22 +182,23 @@ Returns:
{
EFI_STATUS Status;
HII_VENDOR_DEVICE_PATH_NODE *VendorDevicePath;
- UINT64 MonotonicCount;
VendorDevicePath = EfiLibAllocateCopyPool (sizeof (HII_VENDOR_DEVICE_PATH), &mHiiVendorDevicePathTemplate);
if (VendorDevicePath == NULL) {
return EFI_OUT_OF_RESOURCES;
}
- gBS->GetNextMonotonicCount (&MonotonicCount);
- VendorDevicePath->MonotonicCount = (UINT32) MonotonicCount;
+ //
+ // Use memory address as unique ID to distinguish from different device paths
+ //
+ VendorDevicePath->UniqueId = (UINT64) ((UINTN) VendorDevicePath);
*DriverHandle = NULL;
- Status = gBS->InstallProtocolInterface (
+ Status = gBS->InstallMultipleProtocolInterfaces (
DriverHandle,
&gEfiDevicePathProtocolGuid,
- EFI_NATIVE_INTERFACE,
- VendorDevicePath
+ VendorDevicePath,
+ NULL
);
if (EFI_ERROR (Status)) {
return Status;
@@ -240,7 +242,7 @@ Returns:
&gEfiDevicePathProtocolGuid,
DevicePath
);
-
+ gBS->FreePool (DevicePath);
return Status;
}
@@ -511,6 +513,7 @@ Arguments:
Returns:
EFI_SUCCESS - Successfully extract Class for specified Hii handle.
+ EFI_NOT_FOUND - Class not found.
--*/
{
@@ -525,10 +528,12 @@ Returns:
UINT32 Offset2;
UINT32 PackageListLength;
EFI_HII_PACKAGE_HEADER PackageHeader;
+ BOOLEAN ClassFound;
*Class = EFI_NON_DEVICE_CLASS;
*FormSetTitle = 0;
*FormSetHelp = 0;
+ ClassFound = FALSE;
//
// Locate HII Database protocol
@@ -574,7 +579,7 @@ Returns:
Package = ((UINT8 *) HiiPackageList) + Offset;
EfiCopyMem (&PackageHeader, Package, sizeof (EFI_HII_PACKAGE_HEADER));
- if (PackageHeader.Type == EFI_HII_PACKAGE_FORM) {
+ if (PackageHeader.Type == EFI_HII_PACKAGE_FORMS) {
//
// Search Class Opcode in this Form Package
//
@@ -602,6 +607,139 @@ Returns:
//
// Till now, we ought to have found the formset Opcode
//
+ ClassFound = TRUE;
+ break;
+ }
+
+ Offset2 += ((EFI_IFR_OP_HEADER *) OpCodeData)->Length;
+ }
+
+ if (Offset2 < PackageHeader.Length) {
+ //
+ // Target formset found
+ //
+ break;
+ }
+ }
+
+ Offset += PackageHeader.Length;
+ }
+
+ gBS->FreePool (HiiPackageList);
+
+ return ClassFound ? EFI_SUCCESS : EFI_NOT_FOUND;
+}
+
+EFI_STATUS
+ExtractClassGuidFromHiiHandle (
+ IN EFI_HII_HANDLE Handle,
+ OUT UINT8 *NumberOfClassGuid,
+ OUT EFI_GUID **ClassGuid,
+ OUT EFI_STRING_ID *FormSetTitle,
+ OUT EFI_STRING_ID *FormSetHelp
+ )
+/*++
+
+Routine Description:
+ Extract formset ClassGuid for given HII handle.
+
+Arguments:
+ HiiHandle - Hii handle
+ NumberOfClassGuid - Number of ClassGuid
+ ClassGuid - Pointer to callee allocated buffer, an array of ClassGuid
+ FormSetTitle - Formset title string
+ FormSetHelp - Formset help string
+
+Returns:
+ EFI_SUCCESS - Successfully extract Class for specified Hii handle.
+
+--*/
+{
+ EFI_STATUS Status;
+ UINTN BufferSize;
+ EFI_HII_DATABASE_PROTOCOL *HiiDatabase;
+ EFI_HII_PACKAGE_LIST_HEADER *HiiPackageList;
+ UINT8 *Package;
+ UINT8 *FormSet;
+ UINT8 *OpCodeData;
+ UINT32 Offset;
+ UINT32 Offset2;
+ UINT32 PackageListLength;
+ EFI_HII_PACKAGE_HEADER PackageHeader;
+
+ if (NumberOfClassGuid == NULL || ClassGuid == NULL || FormSetTitle == NULL || FormSetHelp == NULL) {
+ return EFI_INVALID_PARAMETER;
+ }
+
+ *NumberOfClassGuid = 0;
+ *ClassGuid = NULL;
+ *FormSetTitle = 0;
+ *FormSetHelp = 0;
+
+ //
+ // Locate HII Database protocol
+ //
+ Status = gBS->LocateProtocol (
+ &gEfiHiiDatabaseProtocolGuid,
+ NULL,
+ (VOID **) &HiiDatabase
+ );
+ if (EFI_ERROR (Status)) {
+ return Status;
+ }
+
+ //
+ // Get HII PackageList
+ //
+ BufferSize = 0;
+ HiiPackageList = NULL;
+ Status = HiiDatabase->ExportPackageLists (HiiDatabase, Handle, &BufferSize, HiiPackageList);
+ if (Status == EFI_BUFFER_TOO_SMALL) {
+ HiiPackageList = EfiLibAllocatePool (BufferSize);
+ ASSERT (HiiPackageList != NULL);
+
+ Status = HiiDatabase->ExportPackageLists (HiiDatabase, Handle, &BufferSize, HiiPackageList);
+ }
+ if (EFI_ERROR (Status)) {
+ return Status;
+ }
+
+ //
+ // Get Form package from this HII package List
+ //
+ Offset = sizeof (EFI_HII_PACKAGE_LIST_HEADER);
+ Offset2 = 0;
+ FormSet = NULL;
+ EfiCopyMem (&PackageListLength, &HiiPackageList->PackageLength, sizeof (UINT32));
+
+ while (Offset < PackageListLength) {
+ Package = ((UINT8 *) HiiPackageList) + Offset;
+ EfiCopyMem (&PackageHeader, Package, sizeof (EFI_HII_PACKAGE_HEADER));
+
+ if (PackageHeader.Type == EFI_HII_PACKAGE_FORMS) {
+ //
+ // Search Class Opcode in this Form Package
+ //
+ Offset2 = sizeof (EFI_HII_PACKAGE_HEADER);
+ while (Offset2 < PackageHeader.Length) {
+ OpCodeData = Package + Offset2;
+
+ if (((EFI_IFR_OP_HEADER *) OpCodeData)->OpCode == EFI_IFR_FORM_SET_OP) {
+ //
+ // Find FormSet OpCode
+ //
+ EfiCopyMem (FormSetTitle, &((EFI_IFR_FORM_SET *) OpCodeData)->FormSetTitle, sizeof (EFI_STRING_ID));
+ EfiCopyMem (FormSetHelp, &((EFI_IFR_FORM_SET *) OpCodeData)->Help, sizeof (EFI_STRING_ID));
+ if (((EFI_IFR_OP_HEADER *) OpCodeData)->Length > ((UINTN) &((EFI_IFR_FORM_SET *) 0)->Flags)) {
+ //
+ // New version of formset OpCode
+ //
+ *NumberOfClassGuid = (UINT8) (((EFI_IFR_FORM_SET *) OpCodeData)->Flags & 0x3);
+ *ClassGuid = EfiLibAllocateCopyPool (
+ *NumberOfClassGuid * sizeof (EFI_GUID),
+ ((EFI_IFR_FORM_SET *) OpCodeData)->ClassGuid
+ );
+ }
break;
}
diff --git a/EdkCompatibilityPkg/Foundation/Library/Dxe/UefiEfiIfrSupportLib/UefiIfrForm.c b/EdkCompatibilityPkg/Foundation/Library/Dxe/UefiEfiIfrSupportLib/UefiIfrForm.c
index fbb46075c4..355935322c 100644
--- a/EdkCompatibilityPkg/Foundation/Library/Dxe/UefiEfiIfrSupportLib/UefiIfrForm.c
+++ b/EdkCompatibilityPkg/Foundation/Library/Dxe/UefiEfiIfrSupportLib/UefiIfrForm.c
@@ -1,6 +1,6 @@
/*++
-Copyright (c) 2007, Intel Corporation. All rights reserved.<BR>
+Copyright (c) 2007 - 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
@@ -26,7 +26,6 @@ Abstract:
//
UINT16 mFakeConfigHdr[] = L"GUID=00000000000000000000000000000000&NAME=0000&PATH=0";
-STATIC
EFI_STATUS
GetPackageDataFromPackageList (
IN EFI_HII_PACKAGE_LIST_HEADER *HiiPackageList,
@@ -72,7 +71,6 @@ GetPackageDataFromPackageList (
return EFI_SUCCESS;
}
-STATIC
EFI_STATUS
UpdateFormPackageData (
IN EFI_GUID *FormSetGuid,
@@ -86,17 +84,15 @@ UpdateFormPackageData (
OUT UINT32 *TempBufferSize
)
{
- UINTN AddSize;
UINT8 *BufferPos;
EFI_HII_PACKAGE_HEADER PackageHeader;
- UINTN Offset;
+ UINT32 Offset;
EFI_IFR_OP_HEADER *IfrOpHdr;
BOOLEAN GetFormSet;
BOOLEAN GetForm;
UINT8 ExtendOpCode;
UINT16 LabelNumber;
BOOLEAN Updated;
- EFI_IFR_OP_HEADER *AddOpCode;
if ((TempBuffer == NULL) || (TempBufferSize == NULL)) {
return EFI_INVALID_PARAMETER;
@@ -122,7 +118,7 @@ UpdateFormPackageData (
GetForm = FALSE;
Updated = FALSE;
- while (Offset < PackageHeader.Length) {
+ while (!Updated && Offset < PackageHeader.Length) {
EfiCopyMem (BufferPos, IfrOpHdr, IfrOpHdr->Length);
BufferPos += IfrOpHdr->Length;
*TempBufferSize += IfrOpHdr->Length;
@@ -132,6 +128,8 @@ UpdateFormPackageData (
if (FormSetGuid != NULL) {
if (EfiCompareMem (&((EFI_IFR_FORM_SET *) IfrOpHdr)->Guid, FormSetGuid, sizeof (EFI_GUID)) == 0) {
GetFormSet = TRUE;
+ } else {
+ GetFormSet = FALSE;
}
}
break;
@@ -139,17 +137,24 @@ UpdateFormPackageData (
case EFI_IFR_FORM_OP:
if (EfiCompareMem (&((EFI_IFR_FORM *) IfrOpHdr)->FormId, &FormId, sizeof (EFI_FORM_ID)) == 0) {
GetForm = TRUE;
+ } else {
+ GetForm = FALSE;
}
break;
case EFI_IFR_GUID_OP :
- if (!GetFormSet || !GetForm || Updated) {
+ if (!GetFormSet || !GetForm) {
//
// Go to the next Op-Code
//
- Offset += IfrOpHdr->Length;
- IfrOpHdr = (EFI_IFR_OP_HEADER *) ((CHAR8 *) (IfrOpHdr) + IfrOpHdr->Length);
- continue;
+ break;
+ }
+
+ if (!EfiCompareGuid (&((EFI_IFR_GUID *) IfrOpHdr)->Guid, &mIfrVendorGuid)) {
+ //
+ // GUID mismatch, skip this op-code
+ //
+ break;
}
ExtendOpCode = ((EFI_IFR_GUID_LABEL *) IfrOpHdr)->ExtendOpCode;
@@ -158,29 +163,18 @@ UpdateFormPackageData (
//
// Go to the next Op-Code
//
- Offset += IfrOpHdr->Length;
- IfrOpHdr = (EFI_IFR_OP_HEADER *) ((CHAR8 *) (IfrOpHdr) + IfrOpHdr->Length);
- continue;
+ break;
}
- if (Insert && (Data != NULL)) {
+ if (Insert) {
//
- // insert the DataCount amount of opcodes to TempBuffer if Data is NULL remove
- // DataCount amount of opcodes unless runing into a label.
+ // Insert data after current Label, skip myself
//
- AddOpCode = (EFI_IFR_OP_HEADER *)Data->Data;
- AddSize = 0;
- while (AddSize < Data->Offset) {
- EfiCopyMem (BufferPos, AddOpCode, AddOpCode->Length);
- BufferPos += AddOpCode->Length;
- *TempBufferSize += AddOpCode->Length;
-
- AddSize += AddOpCode->Length;
- AddOpCode = (EFI_IFR_OP_HEADER *) ((CHAR8 *) (AddOpCode) + AddOpCode->Length);
- }
+ Offset += IfrOpHdr->Length;
+ IfrOpHdr = (EFI_IFR_OP_HEADER *) ((CHAR8 *) (IfrOpHdr) + IfrOpHdr->Length);
} else {
//
- // Search the next Label.
+ // Replace data between two paired Label, try to find the next Label.
//
while (TRUE) {
Offset += IfrOpHdr->Length;
@@ -193,33 +187,28 @@ UpdateFormPackageData (
IfrOpHdr = (EFI_IFR_OP_HEADER *) ((CHAR8 *) (IfrOpHdr) + IfrOpHdr->Length);
if (IfrOpHdr->OpCode == EFI_IFR_GUID_OP) {
ExtendOpCode = ((EFI_IFR_GUID_LABEL *) IfrOpHdr)->ExtendOpCode;
- if (ExtendOpCode == EFI_IFR_EXTEND_OP_LABEL) {
+ if (EfiCompareGuid (&((EFI_IFR_GUID *) IfrOpHdr)->Guid, &mIfrVendorGuid) && ExtendOpCode == EFI_IFR_EXTEND_OP_LABEL) {
break;
}
}
}
+ }
- if (Data != NULL) {
- AddOpCode = (EFI_IFR_OP_HEADER *)Data->Data;
- AddSize = 0;
- while (AddSize < Data->Offset) {
- EfiCopyMem (BufferPos, AddOpCode, AddOpCode->Length);
- BufferPos += AddOpCode->Length;
- *TempBufferSize += AddOpCode->Length;
-
- AddSize += AddOpCode->Length;
- AddOpCode = (EFI_IFR_OP_HEADER *) ((CHAR8 *) (AddOpCode) + AddOpCode->Length);
- }
- }
-
- //
- // copy the next label
- //
- EfiCopyMem (BufferPos, IfrOpHdr, IfrOpHdr->Length);
- BufferPos += IfrOpHdr->Length;
- *TempBufferSize += IfrOpHdr->Length;
+ //
+ // Fill in the update data
+ //
+ if (Data != NULL) {
+ EfiCopyMem (BufferPos, Data->Data, Data->Offset);
+ BufferPos += Data->Offset;
+ *TempBufferSize += Data->Offset;
}
+ //
+ // Copy the reset data
+ //
+ EfiCopyMem (BufferPos, IfrOpHdr, PackageHeader.Length - Offset);
+ *TempBufferSize += PackageHeader.Length - Offset;
+
Updated = TRUE;
break;
default :
@@ -250,6 +239,68 @@ Fail:
}
EFI_STATUS
+IfrLibInitUpdateData (
+ IN OUT EFI_HII_UPDATE_DATA *UpdateData,
+ IN UINT32 BufferSize
+ )
+/*++
+
+Routine Description:
+ This function initialize the data structure for dynamic opcode.
+
+Arguments:
+ UpdateData - The adding data;
+ BufferSize - Length of the buffer to fill dynamic opcodes.
+
+Returns:
+ EFI_SUCCESS - Update data is initialized.
+ EFI_INVALID_PARAMETER - UpdateData is NULL.
+ EFI_OUT_OF_RESOURCES - No enough memory to allocate.
+
+--*/
+{
+ if (UpdateData == NULL) {
+ return EFI_INVALID_PARAMETER;
+ }
+
+ UpdateData->BufferSize = BufferSize;
+ UpdateData->Offset = 0;
+ UpdateData->Data = EfiLibAllocatePool (BufferSize);
+
+ return (UpdateData->Data != NULL) ? EFI_SUCCESS : EFI_OUT_OF_RESOURCES;
+}
+
+EFI_STATUS
+IfrLibFreeUpdateData (
+ IN EFI_HII_UPDATE_DATA *UpdateData
+ )
+/*++
+
+Routine Description:
+ This function free the resource of update data.
+
+Arguments:
+ UpdateData - The adding data;
+
+Returns:
+ EFI_SUCCESS - Resource in UpdateData is released.
+ EFI_INVALID_PARAMETER - UpdateData is NULL.
+
+--*/
+{
+ EFI_STATUS Status;
+
+ if (UpdateData == NULL) {
+ return EFI_INVALID_PARAMETER;
+ }
+
+ Status = gBS->FreePool (UpdateData->Data);
+ UpdateData->Data = NULL;
+
+ return Status;
+}
+
+EFI_STATUS
IfrLibUpdateForm (
IN EFI_HII_HANDLE Handle,
IN EFI_GUID *FormSetGuid, OPTIONAL
@@ -339,7 +390,7 @@ Returns:
Status = GetPackageDataFromPackageList (HiiPackageList, Index, &PackageLength, &Package);
if (Status == EFI_SUCCESS) {
EfiCopyMem (&PackageHeader, Package, sizeof (EFI_HII_PACKAGE_HEADER));
- if ((PackageHeader.Type == EFI_HII_PACKAGE_FORM) && !Updated) {
+ if ((PackageHeader.Type == EFI_HII_PACKAGE_FORMS) && !Updated) {
Status = UpdateFormPackageData (FormSetGuid, FormId, Package, PackageLength, Label, Insert, Data, (UINT8 **)&TempBuffer, &TempBufferSize);
if (!EFI_ERROR(Status)) {
if (FormSetGuid == NULL) {
@@ -644,7 +695,376 @@ ExtractDefault(
return EFI_SUCCESS;
}
-STATIC
+EFI_STATUS
+ExtractBlockName (
+ IN UINT8 *Buffer,
+ OUT CHAR16 **BlockName
+ )
+/*++
+
+ Routine Description:
+
+ Extract block name from the array generated by VFR compiler. The name of
+ this array is "Vfr + <StorageName> + BlockName", e.g. "VfrMyIfrNVDataBlockName".
+ Format of this array is:
+ Array length | 4-bytes
+ Offset | 2-bytes
+ Width | 2-bytes
+ Offset | 2-bytes
+ Width | 2-bytes
+ ... ...
+
+ Arguments:
+ Buffer - Array generated by VFR compiler.
+ BlockName - The returned <BlockName>
+
+ Returns:
+ EFI_OUT_OF_RESOURCES - Run out of memory resource.
+ EFI_INVALID_PARAMETER - Buffer is NULL or BlockName is NULL.
+ EFI_SUCCESS - Operation successful.
+
+--*/
+{
+ UINTN Index;
+ UINT32 Length;
+ UINT32 BlockNameNumber;
+ UINTN HexStringBufferLen;
+ CHAR16 *StringPtr;
+
+ if ((Buffer == NULL) || (BlockName == NULL)) {
+ return EFI_INVALID_PARAMETER;
+ }
+
+ //
+ // Calculate number of Offset/Width pair
+ //
+ EfiCopyMem (&Length, Buffer, sizeof (UINT32));
+ BlockNameNumber = (Length - sizeof (UINT32)) / (sizeof (UINT16) * 2);
+
+ //
+ // <BlockName> ::= &OFFSET=1234&WIDTH=1234
+ // | 8 | 4 | 7 | 4 |
+ //
+ StringPtr = EfiLibAllocateZeroPool ((BlockNameNumber * (8 + 4 + 7 + 4) + 1) * sizeof (CHAR16));
+ *BlockName = StringPtr;
+ if (StringPtr == NULL) {
+ return EFI_OUT_OF_RESOURCES;
+ }
+
+ Buffer += sizeof (UINT32);
+ for (Index = 0; Index < BlockNameNumber; Index++) {
+ EfiStrCpy (StringPtr, L"&OFFSET=");
+ StringPtr += 8;
+
+ HexStringBufferLen = 5;
+ BufToHexString (StringPtr, &HexStringBufferLen, Buffer, sizeof (UINT16));
+ Buffer += sizeof (UINT16);
+ StringPtr += 4;
+
+ EfiStrCpy (StringPtr, L"&WIDTH=");
+ StringPtr += 7;
+
+ HexStringBufferLen = 5;
+ BufToHexString (StringPtr, &HexStringBufferLen, Buffer, sizeof (UINT16));
+ Buffer += sizeof (UINT16);
+ StringPtr += 4;
+ }
+
+ return EFI_SUCCESS;
+}
+
+EFI_STATUS
+ExtractBlockConfig (
+ IN UINT8 *Buffer,
+ OUT CHAR16 **BlockConfig
+ )
+/*++
+
+ Routine Description:
+
+ Extract block config from the array generated by VFR compiler. The name of
+ this array is "Vfr + <StorageName> + Default<HexCh>4", e.g. "VfrMyIfrNVDataDefault0000".
+
+ Arguments:
+ Buffer - Array generated by VFR compiler.
+ BlockConfig - The returned <BlockConfig>
+
+ Returns:
+ EFI_OUT_OF_RESOURCES - Run out of memory resource.
+ EFI_INVALID_PARAMETER - Buffer is NULL or BlockConfig is NULL.
+ EFI_SUCCESS - Operation successful.
+
+--*/
+{
+ UINT32 Length;
+ UINT16 Width;
+ UINTN HexStringBufferLen;
+ CHAR16 *StringPtr;
+ UINT8 *BufferEnd;
+ CHAR16 *StringEnd;
+ EFI_STATUS Status;
+
+ if ((Buffer == NULL) || (BlockConfig == NULL)) {
+ return EFI_INVALID_PARAMETER;
+ }
+
+ //
+ // Calculate length of AltResp string
+ // Format of Default value array is:
+ // Array length | 4-bytes
+ // Offset | 2-bytes
+ // Width | 2-bytes
+ // Value | Variable length
+ // Offset | 2-bytes
+ // Width | 2-bytes
+ // Value | Variable length
+ // ... ...
+ // When value is 1 byte in length, overhead of AltResp string will be maximum,
+ // BlockConfig ::= <&OFFSET=1234&WIDTH=1234&VALUE=12>+
+ // | 8 | 4 | 7 | 4 | 7 |2|
+ // so the maximum length of BlockConfig could be calculated as:
+ // (ArrayLength / 5) * (8 + 4 + 7 + 4 + 7 + 2) = ArrayLength * 6.4 < ArrayLength * 7
+ //
+ EfiCopyMem (&Length, Buffer, sizeof (UINT32));
+ BufferEnd = Buffer + Length;
+ StringPtr = EfiLibAllocatePool (Length * 7 * sizeof (CHAR16));
+ *BlockConfig = StringPtr;
+ if (StringPtr == NULL) {
+ return EFI_OUT_OF_RESOURCES;
+ }
+ StringEnd = StringPtr + (Length * 7);
+
+ Buffer += sizeof (UINT32);
+ while (Buffer < BufferEnd) {
+ EfiStrCpy (StringPtr, L"&OFFSET=");
+ StringPtr += 8;
+
+ HexStringBufferLen = 5;
+ BufToHexString (StringPtr, &HexStringBufferLen, Buffer, sizeof (UINT16));
+ Buffer += sizeof (UINT16);
+ StringPtr += 4;
+
+ EfiStrCpy (StringPtr, L"&WIDTH=");
+ StringPtr += 7;
+
+ HexStringBufferLen = 5;
+ BufToHexString (StringPtr, &HexStringBufferLen, Buffer, sizeof (UINT16));
+ EfiCopyMem (&Width, Buffer, sizeof (UINT16));
+ Buffer += sizeof (UINT16);
+ StringPtr += 4;
+
+ EfiStrCpy (StringPtr, L"&VALUE=");
+ StringPtr += 7;
+
+ HexStringBufferLen = StringEnd - StringPtr;
+ Status = BufToHexString (StringPtr, &HexStringBufferLen, Buffer, Width);
+ if (EFI_ERROR (Status)) {
+ return Status;
+ }
+ Buffer += Width;
+ StringPtr += (Width * 2);
+ }
+
+ return EFI_SUCCESS;
+}
+
+EFI_STATUS
+ConstructConfigAltResp (
+ IN EFI_STRING ConfigRequest, OPTIONAL
+ OUT EFI_STRING *Progress,
+ OUT EFI_STRING *ConfigAltResp,
+ IN EFI_GUID *Guid,
+ IN CHAR16 *Name,
+ IN EFI_HANDLE *DriverHandle,
+ IN VOID *BufferStorage,
+ IN UINTN BufferStorageSize,
+ IN VOID *BlockNameArray, OPTIONAL
+ IN UINTN NumberAltCfg,
+ ...
+//IN UINT16 AltCfgId,
+//IN VOID *DefaultValueArray,
+ )
+/*++
+
+ Routine Description:
+
+ Construct <ConfigAltResp> for a buffer storage.
+
+ Arguments:
+ ConfigRequest - The Config request string. If set to NULL, all the
+ configurable elements will be extracted from BlockNameArray.
+ ConfigAltResp - The returned <ConfigAltResp>.
+ Progress - On return, points to a character in the Request.
+ Guid - GUID of the buffer storage.
+ Name - Name of the buffer storage.
+ DriverHandle - The DriverHandle which is used to invoke HiiDatabase
+ protocol interface NewPackageList().
+ BufferStorage - Content of the buffer storage.
+ BufferStorageSize - Length in bytes of the buffer storage.
+ BlockNameArray - Array generated by VFR compiler.
+ NumberAltCfg - Number of Default value array generated by VFR compiler.
+ The sequential input parameters will be number of
+ AltCfgId and DefaultValueArray pairs. When set to 0,
+ there will be no <AltResp>.
+
+ Returns:
+ EFI_OUT_OF_RESOURCES - Run out of memory resource.
+ EFI_INVALID_PARAMETER - ConfigAltResp is NULL.
+ EFI_SUCCESS - Operation successful.
+
+--*/
+{
+ EFI_STATUS Status;
+ CHAR16 *ConfigHdr;
+ CHAR16 *BlockName;
+ CHAR16 *DescHdr;
+ CHAR16 *StringPtr;
+ CHAR16 **AltCfg;
+ UINT16 AltCfgId;
+ VOID *DefaultValueArray;
+ UINTN StrBufferLen;
+ EFI_STRING ConfigResp;
+ EFI_STRING TempStr;
+ VA_LIST Args;
+ UINTN AltRespLen;
+ UINTN Index;
+ BOOLEAN NeedFreeConfigRequest;
+ EFI_HII_CONFIG_ROUTING_PROTOCOL *HiiConfigRouting;
+
+ if (ConfigAltResp == NULL) {
+ return EFI_INVALID_PARAMETER;
+ }
+
+ //
+ // Construct <ConfigHdr> : "GUID=...&NAME=...&PATH=..."
+ //
+ ConfigHdr = NULL;
+ StrBufferLen = 0;
+ Status = ConstructConfigHdr (
+ ConfigHdr,
+ &StrBufferLen,
+ Guid,
+ Name,
+ DriverHandle
+ );
+ if (Status == EFI_BUFFER_TOO_SMALL) {
+ ConfigHdr = EfiLibAllocateZeroPool (StrBufferLen);
+ Status = ConstructConfigHdr (
+ ConfigHdr,
+ &StrBufferLen,
+ Guid,
+ Name,
+ DriverHandle
+ );
+ }
+
+ if (EFI_ERROR (Status)) {
+ return Status;
+ }
+
+ //
+ // Construct <ConfigResp>
+ //
+ NeedFreeConfigRequest = FALSE;
+ if (ConfigRequest == NULL) {
+ //
+ // If ConfigRequest is set to NULL, export all configurable elements in BlockNameArray
+ //
+ Status = ExtractBlockName (BlockNameArray, &BlockName);
+ if (EFI_ERROR (Status)) {
+ return Status;
+ }
+
+ StrBufferLen = EfiStrSize (ConfigHdr);
+ StrBufferLen = StrBufferLen + EfiStrSize (BlockName) - sizeof (CHAR16);
+ ConfigRequest = EfiLibAllocateZeroPool (StrBufferLen);
+ EfiStrCpy (ConfigRequest, ConfigHdr);
+ EfiStrCat (ConfigRequest, BlockName);
+ NeedFreeConfigRequest = TRUE;
+ }
+
+ Status = gBS->LocateProtocol (&gEfiHiiConfigRoutingProtocolGuid, NULL, (VOID **) &HiiConfigRouting);
+ if (EFI_ERROR (Status)) {
+ return Status;
+ }
+
+ Status = HiiConfigRouting->BlockToConfig (
+ HiiConfigRouting,
+ ConfigRequest,
+ BufferStorage,
+ BufferStorageSize,
+ &ConfigResp,
+ (Progress == NULL) ? &TempStr : Progress
+ );
+ if (EFI_ERROR (Status)) {
+ return Status;
+ }
+
+ //
+ // Construct <AltResp>
+ //
+ DescHdr = EfiLibAllocateZeroPool (NumberAltCfg * 16 * sizeof (CHAR16));
+ StringPtr = DescHdr;
+ AltCfg = EfiLibAllocateZeroPool (NumberAltCfg * sizeof (CHAR16 *));
+ AltRespLen = 0;
+ VA_START (Args, NumberAltCfg);
+ for (Index = 0; Index < NumberAltCfg; Index++) {
+ AltCfgId = (UINT16) VA_ARG (Args, UINT16);
+ DefaultValueArray = (UINT8 *) VA_ARG (Args, VOID *);
+
+ //
+ // '&' <ConfigHdr>
+ //
+ AltRespLen += (EfiStrLen (ConfigHdr) + 1);
+
+ StringPtr = DescHdr + Index * 16;
+ EfiStrCpy (StringPtr, L"&ALTCFG=");
+ AltRespLen += (8 + sizeof (UINT16) * 2);
+
+ StrBufferLen = 5;
+ BufToHexString (StringPtr + 8, &StrBufferLen, (UINT8 *) &AltCfgId, sizeof (UINT16));
+ Status = ExtractBlockConfig (DefaultValueArray, &AltCfg[Index]);
+ if (EFI_ERROR (Status)) {
+ return Status;
+ }
+ AltRespLen += EfiStrLen (AltCfg[Index]);
+ }
+ VA_END (Args);
+
+ //
+ // Generate the final <ConfigAltResp>
+ //
+ StrBufferLen = (EfiStrLen ((CHAR16 *) ConfigResp) + AltRespLen + 1) * sizeof (CHAR16);
+ TempStr = EfiLibAllocateZeroPool (StrBufferLen);
+ *ConfigAltResp = TempStr;
+ if (TempStr == NULL) {
+ return EFI_OUT_OF_RESOURCES;
+ }
+
+ //
+ // <ConfigAltResp> ::= <ConfigResp> ['&' <AltResp>]*
+ //
+ EfiStrCpy (TempStr, ConfigResp);
+ for (Index = 0; Index < NumberAltCfg; Index++) {
+ EfiStrCat (TempStr, L"&");
+ EfiStrCat (TempStr, ConfigHdr);
+ EfiStrCat (TempStr, DescHdr + Index * 16);
+ EfiStrCat (TempStr, AltCfg[Index]);
+
+ gBS->FreePool (AltCfg[Index]);
+ }
+
+ if (NeedFreeConfigRequest) {
+ gBS->FreePool (ConfigRequest);
+ }
+ gBS->FreePool (ConfigHdr);
+ gBS->FreePool (ConfigResp);
+ gBS->FreePool (DescHdr);
+ gBS->FreePool (AltCfg);
+
+ return EFI_SUCCESS;
+}
+
VOID
SwapBuffer (
IN OUT UINT8 *Buffer,
@@ -668,7 +1088,7 @@ Returns:
UINT8 Temp;
UINTN SwapCount;
- SwapCount = (BufferSize - 1) / 2;
+ SwapCount = BufferSize / 2;
for (Index = 0; Index < SwapCount; Index++) {
Temp = Buffer[Index];
Buffer[Index] = Buffer[BufferSize - 1 - Index];
@@ -676,6 +1096,31 @@ Returns:
}
}
+VOID
+ToLower (
+ IN OUT CHAR16 *Str
+ )
+/*++
+
+Routine Description:
+ Converts the unicode character of the string from uppercase to lowercase.
+
+Arguments:
+ Str - String to be converted
+
+Returns:
+
+--*/
+{
+ CHAR16 *Ptr;
+
+ for (Ptr = Str; *Ptr != L'\0'; Ptr++) {
+ if (*Ptr >= L'A' && *Ptr <= L'Z') {
+ *Ptr = (CHAR16) (*Ptr - L'A' + L'a');
+ }
+ }
+}
+
EFI_STATUS
BufferToHexString (
IN OUT CHAR16 *Str,
@@ -704,10 +1149,14 @@ Returns:
NewBuffer = EfiLibAllocateCopyPool (BufferSize, Buffer);
SwapBuffer (NewBuffer, BufferSize);
- StrBufferLen = (BufferSize + 1) * sizeof (CHAR16);
+ StrBufferLen = BufferSize * 2 + 1;
Status = BufToHexString (Str, &StrBufferLen, NewBuffer, BufferSize);
gBS->FreePool (NewBuffer);
+ //
+ // Convert the uppercase to lowercase since <HexAf> is defined in lowercase format.
+ //
+ ToLower (Str);
return Status;
}
@@ -741,13 +1190,139 @@ Returns:
ConvertedStrLen = 0;
Status = HexStringToBuf (Buffer, BufferSize, Str, &ConvertedStrLen);
if (!EFI_ERROR (Status)) {
- SwapBuffer (Buffer, ConvertedStrLen);
+ SwapBuffer (Buffer, (ConvertedStrLen + 1) / 2);
}
return Status;
}
EFI_STATUS
+ConfigStringToUnicode (
+ IN OUT CHAR16 *UnicodeString,
+ IN OUT UINTN *StrBufferLen,
+ IN CHAR16 *ConfigString
+ )
+/*++
+
+Routine Description:
+ Convert binary representation Config string (e.g. "0041004200430044") to the
+ original string (e.g. "ABCD"). Config string appears in <ConfigHdr> (i.e.
+ "&NAME=<string>"), or Name/Value pair in <ConfigBody> (i.e. "label=<string>").
+
+Arguments:
+ UnicodeString - Original Unicode string.
+ StrBufferLen - On input: Length in bytes of buffer to hold the Unicode string.
+ Includes tailing '\0' character.
+ On output:
+ If return EFI_SUCCESS, containing length of Unicode string buffer.
+ If return EFI_BUFFER_TOO_SMALL, containg length of string buffer desired.
+ ConfigString - Binary representation of Unicode String, <string> := (<HexCh>4)+
+
+Returns:
+ EFI_SUCCESS - Routine success.
+ EFI_BUFFER_TOO_SMALL - The string buffer is too small.
+
+--*/
+{
+ UINTN Index;
+ UINTN Len;
+ UINTN BufferSize;
+ CHAR16 BackupChar;
+
+ Len = EfiStrLen (ConfigString) / 4;
+ BufferSize = (Len + 1) * sizeof (CHAR16);
+
+ if (*StrBufferLen < BufferSize) {
+ *StrBufferLen = BufferSize;
+ return EFI_BUFFER_TOO_SMALL;
+ }
+
+ *StrBufferLen = BufferSize;
+
+ for (Index = 0; Index < Len; Index++) {
+ BackupChar = ConfigString[4];
+ ConfigString[4] = L'\0';
+
+ HexStringToBuf ((UINT8 *) UnicodeString, &BufferSize, ConfigString, NULL);
+
+ ConfigString[4] = BackupChar;
+
+ ConfigString += 4;
+ UnicodeString += 1;
+ }
+
+ //
+ // Add tailing '\0' character
+ //
+ *UnicodeString = L'\0';
+
+ return EFI_SUCCESS;
+}
+
+EFI_STATUS
+UnicodeToConfigString (
+ IN OUT CHAR16 *ConfigString,
+ IN OUT UINTN *StrBufferLen,
+ IN CHAR16 *UnicodeString
+ )
+/*++
+
+Routine Description:
+ Convert Unicode string to binary representation Config string, e.g.
+ "ABCD" => "0041004200430044". Config string appears in <ConfigHdr> (i.e.
+ "&NAME=<string>"), or Name/Value pair in <ConfigBody> (i.e. "label=<string>").
+
+Arguments:
+ ConfigString - Binary representation of Unicode String, <string> := (<HexCh>4)+
+ StrBufferLen - On input: Length in bytes of buffer to hold the Unicode string.
+ Includes tailing '\0' character.
+ On output:
+ If return EFI_SUCCESS, containing length of Unicode string buffer.
+ If return EFI_BUFFER_TOO_SMALL, containg length of string buffer desired.
+ UnicodeString - Original Unicode string.
+
+Returns:
+ EFI_SUCCESS - Routine success.
+ EFI_BUFFER_TOO_SMALL - The string buffer is too small.
+
+--*/
+{
+ UINTN Index;
+ UINTN Len;
+ UINTN BufferSize;
+ CHAR16 *String;
+
+ Len = EfiStrLen (UnicodeString);
+ BufferSize = (Len * 4 + 1) * sizeof (CHAR16);
+
+ if (*StrBufferLen < BufferSize) {
+ *StrBufferLen = BufferSize;
+ return EFI_BUFFER_TOO_SMALL;
+ }
+
+ *StrBufferLen = BufferSize;
+ String = ConfigString;
+
+ for (Index = 0; Index < Len; Index++) {
+ BufToHexString (ConfigString, &BufferSize, (UINT8 *) UnicodeString, 2);
+
+ ConfigString += 4;
+ UnicodeString += 1;
+ }
+
+ //
+ // Add tailing '\0' character
+ //
+ *ConfigString = L'\0';
+
+ //
+ // Convert the uppercase to lowercase since <HexAf> is defined in lowercase format.
+ //
+ ToLower (String);
+ return EFI_SUCCESS;
+}
+
+EFI_STATUS
ConstructConfigHdr (
IN OUT CHAR16 *ConfigHdr,
IN OUT UINTN *StrBufferLen,
@@ -811,10 +1386,10 @@ Returns:
DevicePathSize = EfiDevicePathSize (DevicePath);
//
- // GUID=<HexCh>32&NAME=<Alpha>NameStrLen&PATH=<HexChar>DevicePathStrLen <NULL>
- // | 5 | 32 | 6 | NameStrLen | 6 | DevicePathStrLen |
+ // GUID=<HexCh>32&NAME=<Char>NameStrLen&PATH=<HexChar>DevicePathStrLen <NULL>
+ // | 5 | 32 | 6 | NameStrLen*4 | 6 | DevicePathStrLen | 1 |
//
- BufferSize = (5 + 32 + 6 + NameStrLen + 6 + DevicePathSize * 2 + 1) * sizeof (CHAR16);
+ BufferSize = (5 + 32 + 6 + NameStrLen * 4 + 6 + DevicePathSize * 2 + 1) * sizeof (CHAR16);
if (*StrBufferLen < BufferSize) {
*StrBufferLen = BufferSize;
return EFI_BUFFER_TOO_SMALL;
@@ -829,11 +1404,15 @@ Returns:
BufferToHexString (StrPtr, (UINT8 *) Guid, sizeof (EFI_GUID));
StrPtr += 32;
+ //
+ // Convert name string, e.g. name "ABCD" => "&NAME=0041004200430044"
+ //
EfiStrCpy (StrPtr, L"&NAME=");
StrPtr += 6;
if (Name != NULL) {
- EfiStrCpy (StrPtr, Name);
- StrPtr += NameStrLen;
+ BufferSize = (NameStrLen * 4 + 1) * sizeof (CHAR16);
+ UnicodeToConfigString (StrPtr, &BufferSize, Name);
+ StrPtr += (NameStrLen * 4);
}
EfiStrCpy (StrPtr, L"&PATH=");
@@ -844,6 +1423,105 @@ Returns:
}
BOOLEAN
+IsConfigHdrMatch (
+ IN EFI_STRING ConfigString,
+ IN EFI_GUID *StorageGuid, OPTIONAL
+ IN CHAR16 *StorageName OPTIONAL
+ )
+/*++
+
+Routine Description:
+ Determines if the Routing data (Guid and Name) is correct in <ConfigHdr>.
+
+Arguments:
+ ConfigString - Either <ConfigRequest> or <ConfigResp>.
+ StorageGuid - GUID of the storage.
+ StorageName - Name of the stoarge.
+
+Returns:
+ TRUE - Routing information is correct in ConfigString.
+ FALSE - Routing information is incorrect in ConfigString.
+
+--*/
+{
+ EFI_STATUS Status;
+ BOOLEAN Match;
+ EFI_GUID Guid;
+ CHAR16 *Name;
+ CHAR16 *StrPtr;
+ UINTN BufferSize;
+
+ //
+ // <ConfigHdr> ::=
+ // GUID=<HexCh>32&NAME=<Char>NameStrLen&PATH=<HexChar>DevicePathStrLen <NULL>
+ // | 5 | 32 | 6 | NameStrLen*4 | 6 | DevicePathStrLen | 1 |
+ //
+ if (EfiStrLen (ConfigString) <= (5 + 32 + 6)) {
+ return FALSE;
+ }
+
+ //
+ // Compare GUID
+ //
+ if (StorageGuid != NULL) {
+
+ StrPtr = ConfigString + 5 + 32;
+ if (*StrPtr != L'&') {
+ return FALSE;
+ }
+ *StrPtr = L'\0';
+
+ BufferSize = sizeof (EFI_GUID);
+ Status = HexStringToBuffer (
+ (UINT8 *) &Guid,
+ &BufferSize,
+ ConfigString + 5
+ );
+ *StrPtr = L'&';
+
+ if (EFI_ERROR (Status)) {
+ return FALSE;
+ }
+
+ if (!EfiCompareGuid (&Guid, StorageGuid)) {
+ return FALSE;
+ }
+ }
+
+ //
+ // Compare Name
+ //
+ Match = TRUE;
+ if (StorageName != NULL) {
+ StrPtr = ConfigString + 5 + 32 + 6;
+ while (*StrPtr != L'\0' && *StrPtr != L'&') {
+ StrPtr++;
+ }
+ if (*StrPtr != L'&') {
+ return FALSE;
+ }
+
+ *StrPtr = L'\0';
+ BufferSize = (EfiStrLen (ConfigString + 5 + 32 + 6) + 1) * sizeof (CHAR16);
+ Name = EfiLibAllocatePool (BufferSize);
+ ASSERT (Name != NULL);
+ Status = ConfigStringToUnicode (
+ Name,
+ &BufferSize,
+ ConfigString + 5 + 32 + 6
+ );
+ *StrPtr = L'&';
+
+ if (EFI_ERROR (Status) || (EfiStrCmp (Name, StorageName) != 0)) {
+ Match = FALSE;
+ }
+ gBS->FreePool (Name);
+ }
+
+ return Match;
+}
+
+BOOLEAN
FindBlockName (
IN OUT CHAR16 *String,
UINTN Offset,
@@ -965,7 +1643,7 @@ Returns:
HeaderLen = EfiStrLen (ConfigHdr);
BufferLen = 0x4000;
- ConfigResp = EfiLibAllocateZeroPool (BufferLen + HeaderLen);
+ ConfigResp = EfiLibAllocateZeroPool (BufferLen + (HeaderLen + 1) * sizeof (CHAR16));
StringPtr = ConfigResp + HeaderLen;
*StringPtr = L'&';
@@ -981,7 +1659,7 @@ Returns:
);
if (Status == EFI_BUFFER_TOO_SMALL) {
gBS->FreePool (ConfigResp);
- ConfigResp = EfiLibAllocateZeroPool (BufferLen + HeaderLen);
+ ConfigResp = EfiLibAllocateZeroPool (BufferLen + (HeaderLen + 1) * sizeof (CHAR16));
StringPtr = ConfigResp + HeaderLen;
*StringPtr = L'&';
@@ -1116,7 +1794,7 @@ Returns:
&Progress
);
if (EFI_ERROR (Status)) {
- gBS->FreePool (ConfigResp);
+ gBS->FreePool (ConfigRequest);
return Status;
}
@@ -1133,9 +1811,10 @@ Returns:
&BufferSize,
StringPtr,
FALSE,
- NULL,
- NULL
+ VariableGuid,
+ VariableName
);
gBS->FreePool (ConfigResp);
+ gBS->FreePool (ConfigRequest);
return Status;
}
diff --git a/EdkCompatibilityPkg/Foundation/Library/Dxe/UefiEfiIfrSupportLib/UefiIfrLibrary.h b/EdkCompatibilityPkg/Foundation/Library/Dxe/UefiEfiIfrSupportLib/UefiIfrLibrary.h
index bd85764d4a..3de0efb651 100644
--- a/EdkCompatibilityPkg/Foundation/Library/Dxe/UefiEfiIfrSupportLib/UefiIfrLibrary.h
+++ b/EdkCompatibilityPkg/Foundation/Library/Dxe/UefiEfiIfrSupportLib/UefiIfrLibrary.h
@@ -1,6 +1,6 @@
/*++
-Copyright (c) 2007, Intel Corporation. All rights reserved.<BR>
+Copyright (c) 2007 - 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
@@ -78,10 +78,13 @@ typedef struct {
} IFR_OPTION;
#pragma pack()
+#pragma pack(1)
typedef struct {
VENDOR_DEVICE_PATH VendorDevicePath;
- UINT32 MonotonicCount;
+ UINT32 Reserved;
+ UINT64 UniqueId;
} HII_VENDOR_DEVICE_PATH_NODE;
+#pragma pack()
typedef struct {
HII_VENDOR_DEVICE_PATH_NODE Node;
@@ -280,7 +283,8 @@ CreateOneOfOptionOpCode (
IN IFR_OPTION *OptionsList,
IN UINT8 Type,
IN OUT EFI_HII_UPDATE_DATA *Data
- );
+ )
+;
EFI_STATUS
CreateOneOfOpCode (
@@ -600,6 +604,53 @@ ExtractDefault(
;
EFI_STATUS
+ConstructConfigAltResp (
+ IN EFI_STRING ConfigRequest, OPTIONAL
+ OUT EFI_STRING *Progress,
+ OUT EFI_STRING *ConfigAltResp,
+ IN EFI_GUID *Guid,
+ IN CHAR16 *Name,
+ IN EFI_HANDLE *DriverHandle,
+ IN VOID *BufferStorage,
+ IN UINTN BufferStorageSize,
+ IN VOID *BlockNameArray, OPTIONAL
+ IN UINTN NumberAltCfg,
+ ...
+//IN UINT16 AltCfgId,
+//IN VOID *DefaultValueArray,
+ )
+/*++
+
+ Routine Description:
+
+ Construct <ConfigAltResp> for a buffer storage.
+
+ Arguments:
+ ConfigRequest - The Config request string. If set to NULL, all the
+ configurable elements will be extracted from BlockNameArray.
+ ConfigAltResp - The returned <ConfigAltResp>.
+ Progress - On return, points to a character in the Request.
+ Guid - GUID of the buffer storage.
+ Name - Name of the buffer storage.
+ DriverHandle - The DriverHandle which is used to invoke HiiDatabase
+ protocol interface NewPackageList().
+ BufferStorage - Content of the buffer storage.
+ BufferStorageSize - Length in bytes of the buffer storage.
+ BlockNameArray - Array generated by VFR compiler.
+ NumberAltCfg - Number of Default value array generated by VFR compiler.
+ The sequential input parameters will be number of
+ AltCfgId and DefaultValueArray pairs. When set to 0,
+ there will be no <AltResp>.
+
+ Returns:
+ EFI_OUT_OF_RESOURCES - Run out of memory resource.
+ EFI_INVALID_PARAMETER - ConfigAltResp is NULL.
+ EFI_SUCCESS - Operation successful.
+
+--*/
+;
+
+EFI_STATUS
ExtractGuidFromHiiHandle (
IN EFI_HII_HANDLE Handle,
OUT EFI_GUID *Guid
@@ -644,6 +695,49 @@ Returns:
;
EFI_STATUS
+ExtractClassGuidFromHiiHandle (
+ IN EFI_HII_HANDLE Handle,
+ OUT UINT8 *NumberOfClassGuid,
+ OUT EFI_GUID **ClassGuid,
+ OUT EFI_STRING_ID *FormSetTitle,
+ OUT EFI_STRING_ID *FormSetHelp
+ )
+/*++
+
+Routine Description:
+ Extract formset ClassGuid for given HII handle.
+
+Arguments:
+ HiiHandle - Hii handle
+ NumberOfClassGuid - Number of ClassGuid
+ ClassGuid - Pointer to callee allocated buffer, an array of ClassGuid
+ FormSetTitle - Formset title string
+ FormSetHelp - Formset help string
+
+Returns:
+ EFI_SUCCESS - Successfully extract Class for specified Hii handle.
+
+--*/
+;
+
+VOID
+ToLower (
+ IN OUT CHAR16 *Str
+ )
+/*++
+
+Routine Description:
+ Converts the unicode character from uppercase to lowercase.
+
+Arguments:
+ Str - String to be converted
+
+Returns:
+
+--*/
+;
+
+EFI_STATUS
BufferToHexString (
IN OUT CHAR16 *Str,
IN UINT8 *Buffer,
@@ -690,6 +784,64 @@ Returns:
;
EFI_STATUS
+ConfigStringToUnicode (
+ IN OUT CHAR16 *UnicodeString,
+ IN OUT UINTN *StrBufferLen,
+ IN CHAR16 *ConfigString
+ )
+/*++
+
+Routine Description:
+ Convert binary representation Config string (e.g. "0041004200430044") to the
+ original string (e.g. "ABCD"). Config string appears in <ConfigHdr> (i.e.
+ "&NAME=<string>"), or Name/Value pair in <ConfigBody> (i.e. "label=<string>").
+
+Arguments:
+ UnicodeString - Original Unicode string.
+ StrBufferLen - On input: Length in bytes of buffer to hold the Unicode string.
+ Includes tailing '\0' character.
+ On output:
+ If return EFI_SUCCESS, containing length of Unicode string buffer.
+ If return EFI_BUFFER_TOO_SMALL, containg length of string buffer desired.
+ ConfigString - Binary representation of Unicode String, <string> := (<HexCh>4)+
+
+Returns:
+ EFI_SUCCESS - Routine success.
+ EFI_BUFFER_TOO_SMALL - The string buffer is too small.
+
+--*/
+;
+
+EFI_STATUS
+UnicodeToConfigString (
+ IN OUT CHAR16 *ConfigString,
+ IN OUT UINTN *StrBufferLen,
+ IN CHAR16 *UnicodeString
+ )
+/*++
+
+Routine Description:
+ Convert Unicode string to binary representation Config string, e.g.
+ "ABCD" => "0041004200430044". Config string appears in <ConfigHdr> (i.e.
+ "&NAME=<string>"), or Name/Value pair in <ConfigBody> (i.e. "label=<string>").
+
+Arguments:
+ ConfigString - Binary representation of Unicode String, <string> := (<HexCh>4)+
+ StrBufferLen - On input: Length in bytes of buffer to hold the Unicode string.
+ Includes tailing '\0' character.
+ On output:
+ If return EFI_SUCCESS, containing length of Unicode string buffer.
+ If return EFI_BUFFER_TOO_SMALL, containg length of string buffer desired.
+ UnicodeString - Original Unicode string.
+
+Returns:
+ EFI_SUCCESS - Routine success.
+ EFI_BUFFER_TOO_SMALL - The string buffer is too small.
+
+--*/
+;
+
+EFI_STATUS
ConstructConfigHdr (
IN OUT CHAR16 *ConfigHdr,
IN OUT UINTN *StrBufferLen,
@@ -720,6 +872,29 @@ Returns:
;
BOOLEAN
+IsConfigHdrMatch (
+ IN EFI_STRING ConfigString,
+ IN EFI_GUID *StorageGuid, OPTIONAL
+ IN CHAR16 *StorageName OPTIONAL
+ )
+/*++
+
+Routine Description:
+ Determines if the Routing data (Guid and Name) is correct in <ConfigHdr>.
+
+Arguments:
+ ConfigString - Either <ConfigRequest> or <ConfigResp>.
+ StorageGuid - GUID of the storage.
+ StorageName - Name of the stoarge.
+
+Returns:
+ TRUE - Routing information is correct in ConfigString.
+ FALSE - Routing information is incorrect in ConfigString.
+
+--*/
+;
+
+BOOLEAN
FindBlockName (
IN OUT CHAR16 *String,
UINTN Offset,
@@ -1094,6 +1269,47 @@ Returns:
;
EFI_STATUS
+IfrLibInitUpdateData (
+ IN OUT EFI_HII_UPDATE_DATA *UpdateData,
+ IN UINT32 BufferSize
+ )
+/*++
+
+Routine Description:
+ This function initialize the data structure for dynamic opcode.
+
+Arguments:
+ UpdateData - The adding data;
+ BufferSize - Length of the buffer to fill dynamic opcodes.
+
+Returns:
+ EFI_SUCCESS - Update data is initialized.
+ EFI_INVALID_PARAMETER - UpdateData is NULL.
+ EFI_OUT_OF_RESOURCES - No enough memory to allocate.
+
+--*/
+;
+
+EFI_STATUS
+IfrLibFreeUpdateData (
+ IN EFI_HII_UPDATE_DATA *UpdateData
+ )
+/*++
+
+Routine Description:
+ This function free the resource of update data.
+
+Arguments:
+ UpdateData - The adding data;
+
+Returns:
+ EFI_SUCCESS - Resource in UpdateData is released.
+ EFI_INVALID_PARAMETER - UpdateData is NULL.
+
+--*/
+;
+
+EFI_STATUS
IfrLibUpdateForm (
IN EFI_HII_HANDLE Handle,
IN EFI_GUID *FormSetGuid, OPTIONAL
diff --git a/EdkCompatibilityPkg/Foundation/Library/Dxe/UefiEfiIfrSupportLib/UefiIfrOpCodeCreation.c b/EdkCompatibilityPkg/Foundation/Library/Dxe/UefiEfiIfrSupportLib/UefiIfrOpCodeCreation.c
index c46bc7d73e..2c454de951 100644
--- a/EdkCompatibilityPkg/Foundation/Library/Dxe/UefiEfiIfrSupportLib/UefiIfrOpCodeCreation.c
+++ b/EdkCompatibilityPkg/Foundation/Library/Dxe/UefiEfiIfrSupportLib/UefiIfrOpCodeCreation.c
@@ -1,6 +1,6 @@
/*++
-Copyright (c) 2007, Intel Corporation. All rights reserved.<BR>
+Copyright (c) 2007 - 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
@@ -394,9 +394,7 @@ CreateOrderedListOpCode (
return EFI_INVALID_PARAMETER;
}
- if ((OrderedListFlags != 0) &&
- (OrderedListFlags != EFI_IFR_UNIQUE_SET) &&
- (OrderedListFlags != EFI_IFR_NO_EMPTY_SET)) {
+ if ((OrderedListFlags & (~(EFI_IFR_UNIQUE_SET | EFI_IFR_NO_EMPTY_SET))) != 0) {
return EFI_INVALID_PARAMETER;
}
diff --git a/EdkCompatibilityPkg/Foundation/Library/Dxe/UefiEfiIfrSupportLib/UefiIfrString.c b/EdkCompatibilityPkg/Foundation/Library/Dxe/UefiEfiIfrSupportLib/UefiIfrString.c
index 0a5739965a..ece78bfb44 100644
--- a/EdkCompatibilityPkg/Foundation/Library/Dxe/UefiEfiIfrSupportLib/UefiIfrString.c
+++ b/EdkCompatibilityPkg/Foundation/Library/Dxe/UefiEfiIfrSupportLib/UefiIfrString.c
@@ -555,20 +555,37 @@ IfrLibNewString (
if (Languages == NULL) {
return EFI_NOT_FOUND;
}
+
+ if (StringId == NULL) {
+ return EFI_INVALID_PARAMETER;
+ }
+ *StringId = 0;
LangStrings = Languages;
while (*LangStrings != 0) {
GetNextLanguage (&LangStrings, Lang);
- Status = gIfrLibHiiString->NewString (
- gIfrLibHiiString,
- PackageList,
- StringId,
- Lang,
- NULL,
- String,
- NULL
- );
+ if (*StringId == 0) {
+ Status = gIfrLibHiiString->NewString (
+ gIfrLibHiiString,
+ PackageList,
+ StringId,
+ Lang,
+ NULL,
+ String,
+ NULL
+ );
+ } else {
+ Status = gIfrLibHiiString->SetString (
+ gIfrLibHiiString,
+ PackageList,
+ *StringId,
+ Lang,
+ String,
+ NULL
+ );
+ }
+
if (EFI_ERROR (Status)) {
break;
}
diff --git a/EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/EntryPoints/EdkIIGlueDxeDriverEntryPoint.c b/EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/EntryPoints/EdkIIGlueDxeDriverEntryPoint.c
index 7968995794..be5bf00f7c 100644
--- a/EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/EntryPoints/EdkIIGlueDxeDriverEntryPoint.c
+++ b/EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/EntryPoints/EdkIIGlueDxeDriverEntryPoint.c
@@ -23,6 +23,81 @@ Abstract:
#include "EdkIIGlueDxe.h"
#include "Common/EdkIIGlueDependencies.h"
+//
+// Check definitions in .inf file to determine __EDKII_GLUE_DRIVER_MODEL_PROTOCOL_SELECTION__
+//
+// __EDKII_GLUE_DRIVER_MODEL_PROTOCOL_SELECTION__
+// 1: only install ComponentName, DriverConfiguration and DriverDiagnostics
+// 2: only install ComponentName2, DriverConfiguration2 and DriverDiagnostics2
+// 3: install all including ComponentName, DriverConfiguration, DriverDiagnostics AND
+// ComponentName2, DriverConfiguration2 and DriverDiagnostics2
+// 4: install automatically according to EFI_SPECIFICATION_VERSION:
+// if EFI_SPECIFICATION_VERSION < 0x00020000: only install ComponentName, DriverConfiguration and DriverDiagnostics
+// if EFI_SPECIFICATION_VERSION >= 0x00020000: only install ComponentName2, DriverConfiguration2 and DriverDiagnostics2
+//
+#ifdef __EDKII_GLUE_DRIVER_MODEL_VERSION_1_DEFINED__
+#undef __EDKII_GLUE_DRIVER_MODEL_VERSION_1_DEFINED__
+#endif
+
+#ifdef __EDKII_GLUE_DRIVER_MODEL_VERSION_2_DEFINED__
+#undef __EDKII_GLUE_DRIVER_MODEL_VERSION_2_DEFINED__
+#endif
+
+#ifdef __EDKII_GLUE_DRIVER_MODEL_PROTOCOL_SELECTION__
+#undef __EDKII_GLUE_DRIVER_MODEL_PROTOCOL_SELECTION__
+#endif
+
+#if defined(__EDKII_GLUE_COMPONENT_NAME_PROTOCOL_INSTANCE__) || defined(__EDKII_GLUE_DRIVER_CONFIGURATION_PROTOCOL_INSTANCE__) || defined(__EDKII_GLUE_DRIVER_DIAGNOSTICS_PROTOCOL_INSTANCE__)
+#define __EDKII_GLUE_DRIVER_MODEL_VERSION_1_DEFINED__
+#endif
+
+#if defined(__EDKII_GLUE_COMPONENT_NAME2_PROTOCOL_INSTANCE__) || defined(__EDKII_GLUE_DRIVER_CONFIGURATION2_PROTOCOL_INSTANCE__) || defined(__EDKII_GLUE_DRIVER_DIAGNOSTICS2_PROTOCOL_INSTANCE__)
+#define __EDKII_GLUE_DRIVER_MODEL_VERSION_2_DEFINED__
+#endif
+
+#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__)
+#define __EDKII_GLUE_DRIVER_MODEL_PROTOCOL_SELECTION__ 1
+#endif
+
+#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__)
+#define __EDKII_GLUE_DRIVER_MODEL_PROTOCOL_SELECTION__ 2
+#endif
+
+#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__)
+#define __EDKII_GLUE_DRIVER_MODEL_PROTOCOL_SELECTION__ 3
+#endif
+
+//
+// To use Auto-Select, it must be:
+// 1. both Protocol and Protocol2 are defined
+// 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__
+//
+#if defined(__EDKII_GLUE_DRIVER_MODEL_AUTO_SELECT_PROTOCOLS_BY_EFI_VERSION__)
+#if !(defined(__EDKII_GLUE_DRIVER_MODEL_VERSION_1_DEFINED__) && defined(__EDKII_GLUE_DRIVER_MODEL_VERSION_2_DEFINED__))
+#error "To use Auto-Select please define both Protocol and Protocol2 instances"
+#endif
+#define __EDKII_GLUE_DRIVER_MODEL_PROTOCOL_SELECTION__ 4
+#endif
+
+#if (__EDKII_GLUE_DRIVER_MODEL_PROTOCOL_SELECTION__ == 4)
+#undef __EDKII_GLUE_DRIVER_MODEL_PROTOCOL_SELECTION__
+#if (EFI_SPECIFICATION_VERSION >= 0x00020000)
+#define __EDKII_GLUE_DRIVER_MODEL_PROTOCOL_SELECTION__ 2
+#else
+#define __EDKII_GLUE_DRIVER_MODEL_PROTOCOL_SELECTION__ 1
+#endif
+#endif
+
+#if (__EDKII_GLUE_DRIVER_MODEL_PROTOCOL_SELECTION__ == 1)
+UINT8 _gEdkIIGlueDriverModelProtocolSelection = 1;
+#elif (__EDKII_GLUE_DRIVER_MODEL_PROTOCOL_SELECTION__ == 2)
+UINT8 _gEdkIIGlueDriverModelProtocolSelection = 2;
+#elif (__EDKII_GLUE_DRIVER_MODEL_PROTOCOL_SELECTION__ == 3)
+UINT8 _gEdkIIGlueDriverModelProtocolSelection = 3;
+#else
+UINT8 _gEdkIIGlueDriverModelProtocolSelection = 0;
+#endif
+
STATIC EFI_EVENT _mDriverExitBootServicesNotifyEvent;
//
@@ -31,27 +106,38 @@ STATIC EFI_EVENT _mDriverExitBootServicesNotifyEvent;
// In case where multiple Driver Model protocols need to be installed in a single driver,
// manually edit this file and compile/link the modified file with the driver.
//
-
-#ifdef __EDKII_GLUE_DRIVER_BINDING_PROTOCOL_INSTANCE__
+#if defined(__EDKII_GLUE_DRIVER_BINDING_PROTOCOL_INSTANCE__)
extern EFI_DRIVER_BINDING_PROTOCOL __EDKII_GLUE_DRIVER_BINDING_PROTOCOL_INSTANCE__;
#endif
-#ifdef __EDKII_GLUE_COMPONENT_NAME_PROTOCOL_INSTANCE__
-#if (EFI_SPECIFICATION_VERSION >= 0x00020000)
-extern EFI_COMPONENT_NAME2_PROTOCOL __EDKII_GLUE_COMPONENT_NAME_PROTOCOL_INSTANCE__;
-#else
+#if (__EDKII_GLUE_DRIVER_MODEL_PROTOCOL_SELECTION__ == 1) || (__EDKII_GLUE_DRIVER_MODEL_PROTOCOL_SELECTION__ == 3)
+#if defined(__EDKII_GLUE_COMPONENT_NAME_PROTOCOL_INSTANCE__)
extern EFI_COMPONENT_NAME_PROTOCOL __EDKII_GLUE_COMPONENT_NAME_PROTOCOL_INSTANCE__;
#endif
-#endif
-#ifdef __EDKII_GLUE_DRIVER_CONFIGURATION_PROTOCOL_INSTANCE__
+#if defined(__EDKII_GLUE_DRIVER_CONFIGURATION_PROTOCOL_INSTANCE__)
extern EFI_DRIVER_CONFIGURATION_PROTOCOL __EDKII_GLUE_DRIVER_CONFIGURATION_PROTOCOL_INSTANCE__;
#endif
+#endif
-#ifdef __EDKII_GLUE_DRIVER_DIAGNOSTICS_PROTOCOL_INSTANCE__
+#if defined(__EDKII_GLUE_DRIVER_DIAGNOSTICS_PROTOCOL_INSTANCE__)
extern EFI_DRIVER_DIAGNOSTICS_PROTOCOL __EDKII_GLUE_DRIVER_DIAGNOSTICS_PROTOCOL_INSTANCE__;
#endif
+#if (__EDKII_GLUE_DRIVER_MODEL_PROTOCOL_SELECTION__ == 2) || (__EDKII_GLUE_DRIVER_MODEL_PROTOCOL_SELECTION__ == 3)
+#if defined(__EDKII_GLUE_COMPONENT_NAME2_PROTOCOL_INSTANCE__)
+extern EFI_COMPONENT_NAME2_PROTOCOL __EDKII_GLUE_COMPONENT_NAME2_PROTOCOL_INSTANCE__;
+#endif
+
+#if defined(__EDKII_GLUE_DRIVER_CONFIGURATION2_PROTOCOL_INSTANCE__)
+extern EFI_DRIVER_CONFIGURATION2_PROTOCOL __EDKII_GLUE_DRIVER_CONFIGURATION2_PROTOCOL_INSTANCE__;
+#endif
+
+#if defined(__EDKII_GLUE_DRIVER_DIAGNOSTICS2_PROTOCOL_INSTANCE__)
+extern EFI_DRIVER_DIAGNOSTICS2_PROTOCOL __EDKII_GLUE_DRIVER_DIAGNOSTICS2_PROTOCOL_INSTANCE__;
+#endif
+#endif
+
GLOBAL_REMOVE_IF_UNREFERENCED const EFI_DRIVER_MODEL_PROTOCOL_LIST _gDriverModelProtocolList[] = {
{
#ifdef __EDKII_GLUE_DRIVER_BINDING_PROTOCOL_INSTANCE__
@@ -60,23 +146,41 @@ GLOBAL_REMOVE_IF_UNREFERENCED const EFI_DRIVER_MODEL_PROTOCOL_LIST _gDriverMode
NULL,
#endif
-#ifdef __EDKII_GLUE_COMPONENT_NAME_PROTOCOL_INSTANCE__
+#if defined(__EDKII_GLUE_COMPONENT_NAME_PROTOCOL_INSTANCE__) && !(__EDKII_GLUE_DRIVER_MODEL_PROTOCOL_SELECTION__ == 2)
&__EDKII_GLUE_COMPONENT_NAME_PROTOCOL_INSTANCE__,
#else
NULL,
#endif
-#ifdef __EDKII_GLUE_DRIVER_CONFIGURATION_PROTOCOL_INSTANCE__
+#if defined(__EDKII_GLUE_DRIVER_CONFIGURATION_PROTOCOL_INSTANCE__) && !(__EDKII_GLUE_DRIVER_MODEL_PROTOCOL_SELECTION__ == 2)
&__EDKII_GLUE_DRIVER_CONFIGURATION_PROTOCOL_INSTANCE__,
#else
NULL,
#endif
-#ifdef __EDKII_GLUE_DRIVER_DIAGNOSTICS_PROTOCOL_INSTANCE__
+#if defined(__EDKII_GLUE_DRIVER_DIAGNOSTICS_PROTOCOL_INSTANCE__) && !(__EDKII_GLUE_DRIVER_MODEL_PROTOCOL_SELECTION__ == 2)
&__EDKII_GLUE_DRIVER_DIAGNOSTICS_PROTOCOL_INSTANCE__,
#else
NULL,
#endif
+
+#if defined(__EDKII_GLUE_COMPONENT_NAME2_PROTOCOL_INSTANCE__) && !(__EDKII_GLUE_DRIVER_MODEL_PROTOCOL_SELECTION__ == 1)
+ &__EDKII_GLUE_COMPONENT_NAME2_PROTOCOL_INSTANCE__,
+#else
+ NULL,
+#endif
+
+#if defined(__EDKII_GLUE_DRIVER_CONFIGURATION2_PROTOCOL_INSTANCE__) && !(__EDKII_GLUE_DRIVER_MODEL_PROTOCOL_SELECTION__ == 1)
+ &__EDKII_GLUE_DRIVER_CONFIGURATION2_PROTOCOL_INSTANCE__,
+#else
+ NULL,
+#endif
+
+#if defined(__EDKII_GLUE_DRIVER_DIAGNOSTICS2_PROTOCOL_INSTANCE__) && !(__EDKII_GLUE_DRIVER_MODEL_PROTOCOL_SELECTION__ == 1)
+ &__EDKII_GLUE_DRIVER_DIAGNOSTICS2_PROTOCOL_INSTANCE__,
+#else
+ NULL,
+#endif
}
};
@@ -249,15 +353,15 @@ ProcessLibraryConstructorList (
// NOTE: the constructors must be called according to dependency order
//
// UefiBootServicesTableLib UefiBootServicesTableLibConstructor()
+// UefiRuntimeServicesTableLib UefiRuntimeServicesTableLibConstructor()
+// DxeServicesTableLib DxeServicesTableLibConstructor()
// DxeIoLibCpuIo IoLibConstructor()
// DxeSalLib DxeSalLibConstructor(), IPF only
// EdkDxeRuntimeDriverLib RuntimeDriverLibConstruct()
-// DxeHobLib HobLibConstructor()
+// SmmRuntimeDxeReportStatusCodeLib ReportStatusCodeLibConstruct()
// UefiDriverModelLib UefiDriverModelLibConstructor()
+// DxeHobLib HobLibConstructor()
// DxeSmbusLib SmbusLibConstructor()
-// DxeServicesTableLib DxeServicesTableLibConstructor()
-// UefiRuntimeServicesTableLib UefiRuntimeServicesTableLibConstructor()
-// SmmRuntimeDxeReportStatusCodeLib ReportStatusCodeLibConstruct()
//
#ifdef __EDKII_GLUE_UEFI_BOOT_SERVICES_TABLE_LIB__
@@ -265,6 +369,16 @@ ProcessLibraryConstructorList (
ASSERT_EFI_ERROR (Status);
#endif
+#ifdef __EDKII_GLUE_UEFI_RUNTIME_SERVICES_TABLE_LIB__
+ Status = UefiRuntimeServicesTableLibConstructor (ImageHandle, SystemTable);
+ ASSERT_EFI_ERROR (Status);
+#endif
+
+#ifdef __EDKII_GLUE_DXE_SERVICES_TABLE_LIB__
+ Status = DxeServicesTableLibConstructor (ImageHandle, SystemTable);
+ ASSERT_EFI_ERROR (Status);
+#endif
+
#ifdef __EDKII_GLUE_DXE_IO_LIB_CPU_IO__
Status = IoLibConstructor (ImageHandle, SystemTable);
ASSERT_EFI_ERROR (Status);
@@ -280,8 +394,8 @@ ProcessLibraryConstructorList (
ASSERT_EFI_ERROR (Status);
#endif
-#ifdef __EDKII_GLUE_UEFI_RUNTIME_SERVICES_TABLE_LIB__
- Status = UefiRuntimeServicesTableLibConstructor (ImageHandle, SystemTable);
+#ifdef __EDKII_GLUE_SMM_RUNTIME_DXE_REPORT_STATUS_CODE_LIB__
+ Status = ReportStatusCodeLibConstruct (ImageHandle, SystemTable);
ASSERT_EFI_ERROR (Status);
#endif
@@ -290,16 +404,6 @@ ProcessLibraryConstructorList (
ASSERT_EFI_ERROR (Status);
#endif
-#ifdef __EDKII_GLUE_DXE_SERVICES_TABLE_LIB__
- Status = DxeServicesTableLibConstructor (ImageHandle, SystemTable);
- ASSERT_EFI_ERROR (Status);
-#endif
-
-#ifdef __EDKII_GLUE_SMM_RUNTIME_DXE_REPORT_STATUS_CODE_LIB__
- Status = ReportStatusCodeLibConstruct (ImageHandle, SystemTable);
- ASSERT_EFI_ERROR (Status);
-#endif
-
#ifdef __EDKII_GLUE_DXE_HOB_LIB__
Status = HobLibConstructor (ImageHandle, SystemTable);
ASSERT_EFI_ERROR (Status);
diff --git a/EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/EntryPoints/EdkIIGlueSmmDriverEntryPoint.c b/EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/EntryPoints/EdkIIGlueSmmDriverEntryPoint.c
index c83b28efbb..13cddfbe1d 100644
--- a/EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/EntryPoints/EdkIIGlueSmmDriverEntryPoint.c
+++ b/EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/EntryPoints/EdkIIGlueSmmDriverEntryPoint.c
@@ -83,23 +83,18 @@ ProcessLibraryConstructorList (
// here
//
// UefiBootServicesTableLib UefiBootServicesTableLibConstructor()
+// UefiRuntimeServicesTableLib UefiRuntimeServicesTableLibConstructor()
+// DxeServicesTableLib DxeServicesTableLibConstructor()
// DxeIoLibCpuIo IoLibConstructor
+// SmmRuntimeDxeReportStatusCodeLib ReportStatusCodeLibConstruct()
// DxeHobLib HobLibConstructor()
// DxeSmbusLib SmbusLibConstructor()
-// DxeServicesTableLib DxeServicesTableLibConstructor()
-// UefiRuntimeServicesTableLib UefiRuntimeServicesTableLibConstructor()
-// SmmRuntimeDxeReportStatusCodeLib ReportStatusCodeLibConstruct()
-// check here: check lib usage
+
#ifdef __EDKII_GLUE_UEFI_BOOT_SERVICES_TABLE_LIB__
Status = UefiBootServicesTableLibConstructor (ImageHandle, SystemTable);
ASSERT_EFI_ERROR (Status);
#endif
-#ifdef __EDKII_GLUE_DXE_IO_LIB_CPU_IO__
- Status = IoLibConstructor (ImageHandle, SystemTable);
- ASSERT_EFI_ERROR (Status);
-#endif
-
#ifdef __EDKII_GLUE_UEFI_RUNTIME_SERVICES_TABLE_LIB__
Status = UefiRuntimeServicesTableLibConstructor (ImageHandle, SystemTable);
ASSERT_EFI_ERROR (Status);
@@ -110,6 +105,11 @@ ProcessLibraryConstructorList (
ASSERT_EFI_ERROR (Status);
#endif
+#ifdef __EDKII_GLUE_DXE_IO_LIB_CPU_IO__
+ Status = IoLibConstructor (ImageHandle, SystemTable);
+ ASSERT_EFI_ERROR (Status);
+#endif
+
#ifdef __EDKII_GLUE_SMM_RUNTIME_DXE_REPORT_STATUS_CODE_LIB__
Status = ReportStatusCodeLibConstruct (ImageHandle, SystemTable);
ASSERT_EFI_ERROR (Status);
@@ -321,14 +321,26 @@ _ModuleEntryPoint (
EFI_HANDLE Handle;
//
- // Call constructor for all libraries
+ // Cache a pointer to the Boot Services Table
//
- ProcessLibraryConstructorList (ImageHandle, SystemTable);
+ mBS = SystemTable->BootServices;
//
- // Cache a pointer to the Boot Services Table
+ // Initialize gBS as ASSERT needs it
+ // Both DxeReportStatusCodeLib and SmmRuntimeDxeReportStatusCodeLib implementations
+ // Can handle this cleanly before lib constructors are called.
//
- mBS = SystemTable->BootServices;
+ gBS = mBS;
+
+ //
+ // Retrieve the Loaded Image Protocol
+ //
+ Status = mBS->HandleProtocol (
+ ImageHandle,
+ &gEfiLoadedImageProtocolGuid,
+ (VOID*)&LoadedImage
+ );
+ ASSERT_EFI_ERROR (Status);
//
// Retrieve SMM Base Protocol
@@ -350,27 +362,6 @@ _ModuleEntryPoint (
//
if (!InSmm) {
//
- // Retrieve the Loaded Image Protocol
- //
- Status = mBS->HandleProtocol (
- ImageHandle,
- &gEfiLoadedImageProtocolGuid,
- (VOID*)&LoadedImage
- );
- ASSERT_EFI_ERROR (Status);
-
- //
- // Install the unload handler
- //
- Status = mBS->HandleProtocol (
- ImageHandle,
- &gEfiLoadedImageProtocolGuid,
- (VOID **)&LoadedImage
- );
- ASSERT_EFI_ERROR (Status);
- LoadedImage->Unload = _DriverUnloadHandler;
-
- //
// Retrieve the Device Path Protocol from the DeviceHandle tha this driver was loaded from
//
Status = mBS->HandleProtocol (
@@ -391,18 +382,34 @@ _ModuleEntryPoint (
//
Status = SmmBase->Register (SmmBase, CompleteFilePath, NULL, 0, &Handle, FALSE);
ASSERT_EFI_ERROR (Status);
- } else {
-
- //
- // Call the list of driver entry points
- //
- #ifdef __EDKII_GLUE_MODULE_ENTRY_POINT__
- Status = (__EDKII_GLUE_MODULE_ENTRY_POINT__ (ImageHandle, SystemTable));
- #else
- Status = EFI_SUCCESS;
- #endif
+ return Status;
}
+ //
+ // Call constructor for all libraries
+ //
+ ProcessLibraryConstructorList (ImageHandle, SystemTable);
+
+ //
+ // Install the unload handler
+ //
+ Status = mBS->HandleProtocol (
+ ImageHandle,
+ &gEfiLoadedImageProtocolGuid,
+ (VOID **)&LoadedImage
+ );
+ ASSERT_EFI_ERROR (Status);
+ LoadedImage->Unload = _DriverUnloadHandler;
+
+ //
+ // Call the list of driver entry points
+ //
+ #ifdef __EDKII_GLUE_MODULE_ENTRY_POINT__
+ Status = (__EDKII_GLUE_MODULE_ENTRY_POINT__ (ImageHandle, SystemTable));
+ #else
+ Status = EFI_SUCCESS;
+ #endif
+
if (EFI_ERROR (Status)) {
ProcessLibraryDestructorList (ImageHandle, SystemTable);
}
diff --git a/EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Include/Common/EdkIIGlueDependencies.h b/EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Include/Common/EdkIIGlueDependencies.h
index b3b1f0ef73..321e5fb0ec 100644
--- a/EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Include/Common/EdkIIGlueDependencies.h
+++ b/EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Include/Common/EdkIIGlueDependencies.h
@@ -333,6 +333,15 @@ Abstract:
#endif
//
+// DxeServicesTableLib
+//
+#ifdef __EDKII_GLUE_DXE_SERVICES_TABLE_LIB__
+ #ifndef __EDKII_GLUE_UEFI_LIB__
+ #define __EDKII_GLUE_UEFI_LIB__
+ #endif
+#endif
+
+//
// UefiLib
//
#ifdef __EDKII_GLUE_UEFI_LIB__
@@ -490,15 +499,6 @@ Abstract:
#endif
//
-// DxeServicesTableLib
-//
-#ifdef __EDKII_GLUE_DXE_SERVICES_TABLE_LIB__
- #ifndef __EDKII_GLUE_UEFI_LIB__
- #define __EDKII_GLUE_UEFI_LIB__
- #endif
-#endif
-
-//
// BasePrintLib
//
#ifdef __EDKII_GLUE_BASE_PRINT_LIB__
diff --git a/EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Include/EdkIIGlueConfig.h b/EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Include/EdkIIGlueConfig.h
index 2650379ba9..3513f87d69 100644
--- a/EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Include/EdkIIGlueConfig.h
+++ b/EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Include/EdkIIGlueConfig.h
@@ -1,6 +1,6 @@
/*++
-Copyright (c) 2004 - 2006, 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
@@ -33,10 +33,15 @@ Abstract:
// 0x6000 - support EBC. Feb, 2007
// 0x7000 - size reduction, Jun, 2007
// 0x7100 - backward compatibility supported, Jun, 2007
+// 0x8000 - Driver model protocols2 supported, May, 2008
+// 0x9000 - add SmmRuntimeDxeReportStatusCodeLib and OemHookStatusCodeLibNull, Feb, 2009
+// 0x9100 - change to use unique member RT variable names in various library instances, June, 2009
+// 0x9200 - Update LEGACY_BOOT and READY_TO_BOOT event handling in UefiLib, July, 2009
+// 0x9300 - Remove OemHookStatusCodeLibNull. SmmRuntimeDxeReportStatusCodeLib uses SMM StatusCode Protocol, Oct, 2009
//
// For reference only, don't change the value
//
-#define EDKII_GLUE_LIBRARY_VERSION 0x7100
+#define EDKII_GLUE_LIBRARY_VERSION 0x9300
//
@@ -120,7 +125,9 @@ Abstract:
// This value is FSB Clock frequency. Its unit is Hz and its
// default value is 200000000, that means FSB frequency is 200Mhz.
//
+#ifndef EDKII_GLUE_FSBClock
#define EDKII_GLUE_FSBClock 200000000
+#endif
//
// post code property mask
@@ -142,7 +149,9 @@ Abstract:
// The base address of IPF IO Block
//
#ifdef MDE_CPU_IPF
+#ifndef EDKII_GLUE_IoBlockBaseAddressForIpf
#define EDKII_GLUE_IoBlockBaseAddressForIpf 0x0ffffc000000
#endif
+#endif
#endif
diff --git a/EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Include/EdkIIGlueUefi.h b/EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Include/EdkIIGlueUefi.h
index 5482785b77..8c4e2ae946 100644
--- a/EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Include/EdkIIGlueUefi.h
+++ b/EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Include/EdkIIGlueUefi.h
@@ -1,6 +1,6 @@
/*++
-Copyright (c) 2004 - 2007, 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
@@ -173,4 +173,6 @@ Abstract:
#include "Library/EdkIIGlueUefiLib.h"
#include "Library/EdkIIGlueUefiRuntimeServicesTableLib.h"
+extern UINT8 _gEdkIIGlueDriverModelProtocolSelection;
+
#endif
diff --git a/EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Include/Library/EdkIIGlueUefiDriverModelLib.h b/EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Include/Library/EdkIIGlueUefiDriverModelLib.h
index 9bb057f5ab..ef947fa7eb 100644
--- a/EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Include/Library/EdkIIGlueUefiDriverModelLib.h
+++ b/EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Include/Library/EdkIIGlueUefiDriverModelLib.h
@@ -1,6 +1,6 @@
/*++
-Copyright (c) 2004 - 2007, 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
@@ -34,15 +34,14 @@ Abstract:
// Data structure that declares pointers to the Driver Model
// Protocols.
//
-typedef struct {
- const EFI_DRIVER_BINDING_PROTOCOL *DriverBinding;
-#if (EFI_SPECIFICATION_VERSION >= 0x00020000)
- const EFI_COMPONENT_NAME2_PROTOCOL *ComponentName;
-#else
- const EFI_COMPONENT_NAME_PROTOCOL *ComponentName;
-#endif
- const EFI_DRIVER_CONFIGURATION_PROTOCOL *DriverConfiguration;
- const EFI_DRIVER_DIAGNOSTICS_PROTOCOL *DriverDiagnostics;
+typedef struct {
+ const EFI_DRIVER_BINDING_PROTOCOL *DriverBinding;
+ const EFI_COMPONENT_NAME_PROTOCOL *ComponentName;
+ const EFI_DRIVER_CONFIGURATION_PROTOCOL *DriverConfiguration;
+ const EFI_DRIVER_DIAGNOSTICS_PROTOCOL *DriverDiagnostics;
+ const EFI_COMPONENT_NAME2_PROTOCOL *ComponentName2;
+ const EFI_DRIVER_CONFIGURATION2_PROTOCOL *DriverConfiguration2;
+ const EFI_DRIVER_DIAGNOSTICS2_PROTOCOL *DriverDiagnostics2;
} EFI_DRIVER_MODEL_PROTOCOL_LIST;
//
diff --git a/EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Include/Library/EdkIIGlueUefiLib.h b/EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Include/Library/EdkIIGlueUefiLib.h
index 15d5f2e730..48c8f5e8be 100644
--- a/EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Include/Library/EdkIIGlueUefiLib.h
+++ b/EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Include/Library/EdkIIGlueUefiLib.h
@@ -1,6 +1,6 @@
/*++
-Copyright (c) 2004 - 2006, 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
@@ -585,13 +585,6 @@ EfiCreateEventReadyToBootEx (
/**
Initialize a Firmware Volume (FV) Media Device Path node.
- Tiano extended the EFI 1.10 device path nodes. Tiano does not own this enum
- so as we move to UEFI 2.0 support we must use a mechanism that conforms with
- the UEFI 2.0 specification to define the FV device path. An UEFI GUIDed
- device path is defined for Tiano extensions of device path. If the code
- is compiled to conform with the UEFI 2.0 specification use the new device path
- else use the old form for backwards compatability.
-
@param FvDevicePathNode Pointer to a FV device path node to initialize
@param NameGuid FV file name to use in FvDevicePathNode
@@ -606,15 +599,6 @@ GlueEfiInitializeFwVolDevicepathNode (
/**
Check to see if the Firmware Volume (FV) Media Device Path is valid
- Tiano extended the EFI 1.10 device path nodes. Tiano does not own this enum
- so as we move to UEFI 2.0 support we must use a mechanism that conforms with
- the UEFI 2.0 specification to define the FV device path. An UEFI GUIDed
- device path is defined for Tiano extensions of device path. If the code
- is compiled to conform with the UEFI 2.0 specification use the new device path
- else use the old form for backwards compatability. The return value to this
- function points to a location in FvDevicePathNode and it does not allocate
- new memory for the GUID pointer that is returned.
-
@param FvDevicePathNode Pointer to FV device path to check.
@retval NULL FvDevicePathNode is not valid.
diff --git a/EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/BaseMemoryLib/CompareMemWrapper.c b/EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/BaseMemoryLib/CompareMemWrapper.c
index 4caec5f371..9562460e0f 100644
--- a/EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/BaseMemoryLib/CompareMemWrapper.c
+++ b/EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/BaseMemoryLib/CompareMemWrapper.c
@@ -1,6 +1,6 @@
/*++
-Copyright (c) 2004 - 2006, 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
@@ -51,7 +51,7 @@ GlueCompareMem (
IN UINTN Length
)
{
- if (Length == 0) {
+ if (Length == 0 || DestinationBuffer == SourceBuffer) {
return 0;
}
ASSERT (DestinationBuffer != NULL);
diff --git a/EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/EdkDxeRuntimeDriverLib/Common/RuntimeLib.c b/EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/EdkDxeRuntimeDriverLib/Common/RuntimeLib.c
index 6cc2da31b0..387a6835a6 100644
--- a/EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/EdkDxeRuntimeDriverLib/Common/RuntimeLib.c
+++ b/EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/EdkDxeRuntimeDriverLib/Common/RuntimeLib.c
@@ -1,6 +1,6 @@
/*++
-Copyright (c) 2004 - 2006, 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
@@ -29,7 +29,7 @@ Abstract:
STATIC EFI_EVENT mEfiVirtualNotifyEvent;
STATIC BOOLEAN mEfiGoneVirtual = FALSE;
STATIC BOOLEAN mEfiAtRuntime = FALSE;
-EFI_RUNTIME_SERVICES *mRT;
+EFI_RUNTIME_SERVICES *mRTEdkDxeRuntimeDriverLib;
/**
Set AtRuntime flag as TRUE after ExitBootServices
@@ -44,6 +44,11 @@ RuntimeDriverExitBootServices (
IN VOID *Context
)
{
+ //
+ // Clear out BootService globals
+ //
+ gBS = NULL;
+
mEfiAtRuntime = TRUE;
}
@@ -76,7 +81,7 @@ RuntimeLibVirtualNotifyEvent (
//
// Update global for Runtime Services Table and IO
//
- EfiConvertPointer (0, (VOID **) &mRT);
+ EfiConvertPointer (0, (VOID **) &mRTEdkDxeRuntimeDriverLib);
mEfiGoneVirtual = TRUE;
}
@@ -99,8 +104,8 @@ RuntimeDriverLibConstruct (
EFI_STATUS Status;
ASSERT (SystemTable != NULL);
- mRT = SystemTable->RuntimeServices;
- ASSERT (mRT != NULL);
+ mRTEdkDxeRuntimeDriverLib = SystemTable->RuntimeServices;
+ ASSERT (mRTEdkDxeRuntimeDriverLib != NULL);
//
// Register SetVirtualAddressMap () notify function
diff --git a/EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/EdkDxeRuntimeDriverLib/Common/RuntimeService.c b/EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/EdkDxeRuntimeDriverLib/Common/RuntimeService.c
index 1fcfddb585..c57588c770 100644
--- a/EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/EdkDxeRuntimeDriverLib/Common/RuntimeService.c
+++ b/EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/EdkDxeRuntimeDriverLib/Common/RuntimeService.c
@@ -1,6 +1,6 @@
/*++
-Copyright (c) 2004 - 2006, 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
@@ -50,11 +50,11 @@ Returns:
--*/
{
- mRT->ResetSystem (ResetType, ResetStatus, DataSize, ResetData);
+ mRTEdkDxeRuntimeDriverLib->ResetSystem (ResetType, ResetStatus, DataSize, ResetData);
}
//
-// The following functions hide the mRT local global from the call to
+// The following functions hide the mRTEdkDxeRuntimeDriverLib local global from the call to
// runtime service in the EFI system table.
//
EFI_STATUS
@@ -82,7 +82,7 @@ Returns:
--*/
{
- return mRT->GetTime (Time, Capabilities);
+ return mRTEdkDxeRuntimeDriverLib->GetTime (Time, Capabilities);
}
EFI_STATUS
@@ -106,7 +106,7 @@ Returns:
--*/
{
- return mRT->SetTime (Time);
+ return mRTEdkDxeRuntimeDriverLib->SetTime (Time);
}
EFI_STATUS
@@ -134,7 +134,7 @@ Returns:
--*/
{
- return mRT->GetWakeupTime (Enabled, Pending, Time);
+ return mRTEdkDxeRuntimeDriverLib->GetWakeupTime (Enabled, Pending, Time);
}
EFI_STATUS
@@ -161,7 +161,7 @@ Returns:
--*/
{
- return mRT->SetWakeupTime (Enable, Time);
+ return mRTEdkDxeRuntimeDriverLib->SetWakeupTime (Enable, Time);
}
@@ -199,7 +199,7 @@ Returns:
--*/
{
- return mRT->GetVariable (VariableName, VendorGuid, Attributes, DataSize, Data);
+ return mRTEdkDxeRuntimeDriverLib->GetVariable (VariableName, VendorGuid, Attributes, DataSize, Data);
}
EFI_STATUS
@@ -232,7 +232,7 @@ Returns:
--*/
{
- return mRT->GetNextVariableName (VariableNameSize, VariableName, VendorGuid);
+ return mRTEdkDxeRuntimeDriverLib->GetNextVariableName (VariableNameSize, VariableName, VendorGuid);
}
EFI_STATUS
@@ -265,7 +265,7 @@ Returns:
--*/
{
- return mRT->SetVariable (VariableName, VendorGuid, Attributes, DataSize, Data);
+ return mRTEdkDxeRuntimeDriverLib->SetVariable (VariableName, VendorGuid, Attributes, DataSize, Data);
}
EFI_STATUS
@@ -289,7 +289,7 @@ Returns:
--*/
{
- return mRT->GetNextHighMonotonicCount (HighCount);
+ return mRTEdkDxeRuntimeDriverLib->GetNextHighMonotonicCount (HighCount);
}
EFI_STATUS
@@ -316,7 +316,7 @@ Returns:
--*/
{
- return mRT->ConvertPointer (DebugDisposition, Address);
+ return mRTEdkDxeRuntimeDriverLib->ConvertPointer (DebugDisposition, Address);
}
EFI_STATUS
@@ -399,7 +399,7 @@ EfiSetVirtualAddressMap (
IN CONST EFI_MEMORY_DESCRIPTOR *VirtualMap
)
{
- return mRT->SetVirtualAddressMap (
+ return mRTEdkDxeRuntimeDriverLib->SetVirtualAddressMap (
MemoryMapSize,
DescriptorSize,
DescriptorVersion,
@@ -417,7 +417,7 @@ EfiUpdateCapsule (
)
{
#if (EFI_SPECIFICATION_VERSION >= 0x00020000)
- return mRT->UpdateCapsule (
+ return mRTEdkDxeRuntimeDriverLib->UpdateCapsule (
CapsuleHeaderArray,
CapsuleCount,
ScatterGatherList
@@ -437,7 +437,7 @@ EfiQueryCapsuleCapabilities (
)
{
#if (EFI_SPECIFICATION_VERSION >= 0x00020000)
- return mRT->QueryCapsuleCapabilities (
+ return mRTEdkDxeRuntimeDriverLib->QueryCapsuleCapabilities (
CapsuleHeaderArray,
CapsuleCount,
MaximumCapsuleSize,
@@ -459,7 +459,7 @@ EfiQueryVariableInfo (
)
{
#if (EFI_SPECIFICATION_VERSION >= 0x00020000)
- return mRT->QueryVariableInfo (
+ return mRTEdkDxeRuntimeDriverLib->QueryVariableInfo (
Attributes,
MaximumVariableStorageSize,
RemainingVariableStorageSize,
diff --git a/EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/EdkDxeRuntimeDriverLib/Ipf/RuntimeLib.c b/EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/EdkDxeRuntimeDriverLib/Ipf/RuntimeLib.c
index 8f154a888c..e0f4deb6ce 100644
--- a/EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/EdkDxeRuntimeDriverLib/Ipf/RuntimeLib.c
+++ b/EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/EdkDxeRuntimeDriverLib/Ipf/RuntimeLib.c
@@ -1,6 +1,6 @@
/*++
-Copyright (c) 2004 - 2006, 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
@@ -26,7 +26,7 @@ Abstract:
// Driver Lib Module Globals
//
static EFI_EVENT mEfiVirtualNotifyEvent;
-EFI_RUNTIME_SERVICES *mRT;
+EFI_RUNTIME_SERVICES *mRTEdkDxeRuntimeDriverLib;
VOID
EFIAPI
@@ -95,7 +95,7 @@ Returns:
//
// Update global for Runtime Services Table
//
- EfiConvertPointer (0, (VOID **) &mRT);
+ EfiConvertPointer (0, (VOID **) &mRTEdkDxeRuntimeDriverLib);
}
EFI_STATUS
@@ -126,7 +126,7 @@ Returns:
{
EFI_STATUS Status;
- mRT = SystemTable->RuntimeServices;
+ mRTEdkDxeRuntimeDriverLib = SystemTable->RuntimeServices;
//
// Register SetVirtualAddressMap () notify function
diff --git a/EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/EdkDxeRuntimeDriverLib/Ipf/RuntimeService.c b/EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/EdkDxeRuntimeDriverLib/Ipf/RuntimeService.c
index bcaa7448bd..a270fc5508 100644
--- a/EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/EdkDxeRuntimeDriverLib/Ipf/RuntimeService.c
+++ b/EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/EdkDxeRuntimeDriverLib/Ipf/RuntimeService.c
@@ -1,6 +1,6 @@
/*++
-Copyright (c) 2004 - 2006, 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
@@ -70,7 +70,7 @@ Returns:
//
-// The following functions hide the mRT local global from the call to
+// The following functions hide the mRTEdkDxeRuntimeDriverLib local global from the call to
// runtime service in the EFI system table.
//
EFI_STATUS
@@ -415,7 +415,7 @@ Returns:
--*/
{
- return mRT->ConvertPointer (DebugDisposition, Address);
+ return mRTEdkDxeRuntimeDriverLib->ConvertPointer (DebugDisposition, Address);
}
EFI_STATUS
diff --git a/EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/EdkDxeRuntimeDriverLib/RuntimeLibInternal.h b/EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/EdkDxeRuntimeDriverLib/RuntimeLibInternal.h
index 2d8e4e7760..287f525cb9 100644
--- a/EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/EdkDxeRuntimeDriverLib/RuntimeLibInternal.h
+++ b/EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/EdkDxeRuntimeDriverLib/RuntimeLibInternal.h
@@ -1,6 +1,6 @@
/*++
-Copyright (c) 2004 - 2006, 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
@@ -25,6 +25,6 @@ Abstract:
#include "EdkIIGlueDxe.h"
-extern EFI_RUNTIME_SERVICES *mRT;
+extern EFI_RUNTIME_SERVICES *mRTEdkDxeRuntimeDriverLib;
#endif //__RUNTIMELIBINTERNAL_H__
diff --git a/EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/UefiDriverModelLib/UefiDriverModelLib.c b/EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/UefiDriverModelLib/UefiDriverModelLib.c
index cd8da602b8..c82736c74b 100644
--- a/EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/UefiDriverModelLib/UefiDriverModelLib.c
+++ b/EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/UefiDriverModelLib/UefiDriverModelLib.c
@@ -1,6 +1,6 @@
/*++
-Copyright (c) 2004 - 2006, 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
@@ -22,13 +22,6 @@ Abstract:
#include "EdkIIGlueUefi.h"
-#if (EFI_SPECIFICATION_VERSION >= 0x00020000)
- #define EDKII_GLUE_SELECTED_COMPONENT_NAME_PROTOCOL_GUID gEfiComponentName2ProtocolGuid
- #define EDKII_GLUE_SELECTED_COMPONENT_NAME_PROTOCOL EFI_COMPONENT_NAME2_PROTOCOL
-#else
- #define EDKII_GLUE_SELECTED_COMPONENT_NAME_PROTOCOL_GUID gEfiComponentNameProtocolGuid
- #define EDKII_GLUE_SELECTED_COMPONENT_NAME_PROTOCOL EFI_COMPONENT_NAME_PROTOCOL
-#endif
/**
The constructor function installs the standard EFI Driver Model Protocols.
@@ -46,7 +39,7 @@ UefiDriverModelLibConstructor (
IN EFI_SYSTEM_TABLE *SystemTable
)
{
- EFI_STATUS Status;
+ EFI_STATUS Status = EFI_UNSUPPORTED;
EFI_HANDLE DriverBindingHandle;
EFI_DRIVER_BINDING_PROTOCOL *DriverBinding;
@@ -60,16 +53,17 @@ UefiDriverModelLibConstructor (
// EdkIIGlueLib: _gDriverModelProtocolListEntries is always 1
//
- //
- // The Driver Binding Protocol must never be NULL
- //
- ASSERT(_gDriverModelProtocolList[0].DriverBinding != NULL);
+ //
+ // The Driver Binding Protocol must never be NULL
+ //
+ ASSERT(_gDriverModelProtocolList[0].DriverBinding != NULL);
- //
- // Check for all 8 possible combinations of the ComponentName, DriverConfiguration, and DriverDiagnostics Protocol
- // These are all checks against const pointers, so the optimizing compiler will only select one of the
- // calls to InstallMultipleProtocolInterfaces()
- //
+ //
+ // Check for all 8 possible combinations of the ComponentName, DriverConfiguration, and DriverDiagnostics Protocol
+ // These are all checks against const pointers, so the optimizing compiler will only select one of the
+ // calls to InstallMultipleProtocolInterfaces()
+ //
+ if ((_gEdkIIGlueDriverModelProtocolSelection == 1) || (_gEdkIIGlueDriverModelProtocolSelection == 3)) {
if (_gDriverModelProtocolList[0].DriverDiagnostics == NULL) {
if (_gDriverModelProtocolList[0].DriverConfiguration == NULL) {
if (_gDriverModelProtocolList[0].ComponentName == NULL) {
@@ -82,7 +76,7 @@ UefiDriverModelLibConstructor (
Status = gBS->InstallMultipleProtocolInterfaces (
&DriverBindingHandle,
&gEfiDriverBindingProtocolGuid, (EFI_DRIVER_BINDING_PROTOCOL *)_gDriverModelProtocolList[0].DriverBinding,
- &EDKII_GLUE_SELECTED_COMPONENT_NAME_PROTOCOL_GUID, (EDKII_GLUE_SELECTED_COMPONENT_NAME_PROTOCOL *)_gDriverModelProtocolList[0].ComponentName,
+ &gEfiComponentNameProtocolGuid, (EFI_COMPONENT_NAME_PROTOCOL *)_gDriverModelProtocolList[0].ComponentName,
NULL
);
}
@@ -98,7 +92,7 @@ UefiDriverModelLibConstructor (
Status = gBS->InstallMultipleProtocolInterfaces (
&DriverBindingHandle,
&gEfiDriverBindingProtocolGuid, (EFI_DRIVER_BINDING_PROTOCOL *)_gDriverModelProtocolList[0].DriverBinding,
- &EDKII_GLUE_SELECTED_COMPONENT_NAME_PROTOCOL_GUID, (EDKII_GLUE_SELECTED_COMPONENT_NAME_PROTOCOL *)_gDriverModelProtocolList[0].ComponentName,
+ &gEfiComponentNameProtocolGuid, (EFI_COMPONENT_NAME_PROTOCOL *)_gDriverModelProtocolList[0].ComponentName,
&gEfiDriverConfigurationProtocolGuid, (EFI_DRIVER_CONFIGURATION_PROTOCOL *)_gDriverModelProtocolList[0].DriverConfiguration,
NULL
);
@@ -117,7 +111,7 @@ UefiDriverModelLibConstructor (
Status = gBS->InstallMultipleProtocolInterfaces (
&DriverBindingHandle,
&gEfiDriverBindingProtocolGuid, (EFI_DRIVER_BINDING_PROTOCOL *)_gDriverModelProtocolList[0].DriverBinding,
- &EDKII_GLUE_SELECTED_COMPONENT_NAME_PROTOCOL_GUID, (EDKII_GLUE_SELECTED_COMPONENT_NAME_PROTOCOL *)_gDriverModelProtocolList[0].ComponentName,
+ &gEfiComponentNameProtocolGuid, (EFI_COMPONENT_NAME_PROTOCOL *)_gDriverModelProtocolList[0].ComponentName,
&gEfiDriverDiagnosticsProtocolGuid, (EFI_DRIVER_DIAGNOSTICS_PROTOCOL *)_gDriverModelProtocolList[0].DriverDiagnostics,
NULL
);
@@ -135,7 +129,7 @@ UefiDriverModelLibConstructor (
Status = gBS->InstallMultipleProtocolInterfaces (
&DriverBindingHandle,
&gEfiDriverBindingProtocolGuid, (EFI_DRIVER_BINDING_PROTOCOL *)_gDriverModelProtocolList[0].DriverBinding,
- &EDKII_GLUE_SELECTED_COMPONENT_NAME_PROTOCOL_GUID, (EDKII_GLUE_SELECTED_COMPONENT_NAME_PROTOCOL *)_gDriverModelProtocolList[0].ComponentName,
+ &gEfiComponentNameProtocolGuid, (EFI_COMPONENT_NAME_PROTOCOL *)_gDriverModelProtocolList[0].ComponentName,
&gEfiDriverConfigurationProtocolGuid, (EFI_DRIVER_CONFIGURATION_PROTOCOL *)_gDriverModelProtocolList[0].DriverConfiguration,
&gEfiDriverDiagnosticsProtocolGuid, (EFI_DRIVER_DIAGNOSTICS_PROTOCOL *)_gDriverModelProtocolList[0].DriverDiagnostics,
NULL
@@ -143,18 +137,95 @@ UefiDriverModelLibConstructor (
}
}
}
+ } // selection == 1 or 3
- //
- // ASSERT if the call to InstallMultipleProtocolInterfaces() failed
- //
- ASSERT_EFI_ERROR (Status);
+ if ((_gEdkIIGlueDriverModelProtocolSelection == 2) || (_gEdkIIGlueDriverModelProtocolSelection == 3)) {
+ if (_gDriverModelProtocolList[0].DriverDiagnostics2== NULL) {
+ if (_gDriverModelProtocolList[0].DriverConfiguration2== NULL) {
+ if (_gDriverModelProtocolList[0].ComponentName2== NULL) {
+ Status = gBS->InstallMultipleProtocolInterfaces (
+ &DriverBindingHandle,
+ &gEfiDriverBindingProtocolGuid, (EFI_DRIVER_BINDING_PROTOCOL *)_gDriverModelProtocolList[0].DriverBinding,
+ NULL
+ );
+ } else {
+ Status = gBS->InstallMultipleProtocolInterfaces (
+ &DriverBindingHandle,
+ &gEfiDriverBindingProtocolGuid, (EFI_DRIVER_BINDING_PROTOCOL *)_gDriverModelProtocolList[0].DriverBinding,
+ &gEfiComponentName2ProtocolGuid, (EFI_COMPONENT_NAME2_PROTOCOL *)_gDriverModelProtocolList[0].ComponentName2,
+ NULL
+ );
+ }
+ } else {
+ if (_gDriverModelProtocolList[0].ComponentName2 == NULL) {
+ Status = gBS->InstallMultipleProtocolInterfaces (
+ &DriverBindingHandle,
+ &gEfiDriverBindingProtocolGuid, (EFI_DRIVER_BINDING_PROTOCOL *)_gDriverModelProtocolList[0].DriverBinding,
+ &gEfiDriverConfiguration2ProtocolGuid, (EFI_DRIVER_CONFIGURATION2_PROTOCOL *)_gDriverModelProtocolList[0].DriverConfiguration2,
+ NULL
+ );
+ } else {
+ Status = gBS->InstallMultipleProtocolInterfaces (
+ &DriverBindingHandle,
+ &gEfiDriverBindingProtocolGuid, (EFI_DRIVER_BINDING_PROTOCOL *)_gDriverModelProtocolList[0].DriverBinding,
+ &gEfiComponentName2ProtocolGuid, (EFI_COMPONENT_NAME2_PROTOCOL *)_gDriverModelProtocolList[0].ComponentName2,
+ &gEfiDriverConfiguration2ProtocolGuid, (EFI_DRIVER_CONFIGURATION2_PROTOCOL *)_gDriverModelProtocolList[0].DriverConfiguration2,
+ NULL
+ );
+ }
+ }
+ } else {
+ if (_gDriverModelProtocolList[0].DriverConfiguration2 == NULL) {
+ if (_gDriverModelProtocolList[0].ComponentName2 == NULL) {
+ Status = gBS->InstallMultipleProtocolInterfaces (
+ &DriverBindingHandle,
+ &gEfiDriverBindingProtocolGuid, (EFI_DRIVER_BINDING_PROTOCOL *)_gDriverModelProtocolList[0].DriverBinding,
+ &gEfiDriverDiagnostics2ProtocolGuid, (EFI_DRIVER_DIAGNOSTICS2_PROTOCOL *)_gDriverModelProtocolList[0].DriverDiagnostics2,
+ NULL
+ );
+ } else {
+ Status = gBS->InstallMultipleProtocolInterfaces (
+ &DriverBindingHandle,
+ &gEfiDriverBindingProtocolGuid, (EFI_DRIVER_BINDING_PROTOCOL *)_gDriverModelProtocolList[0].DriverBinding,
+ &gEfiComponentName2ProtocolGuid, (EFI_COMPONENT_NAME2_PROTOCOL *)_gDriverModelProtocolList[0].ComponentName2,
+ &gEfiDriverDiagnostics2ProtocolGuid, (EFI_DRIVER_DIAGNOSTICS2_PROTOCOL *)_gDriverModelProtocolList[0].DriverDiagnostics2,
+ NULL
+ );
+ }
+ } else {
+ if (_gDriverModelProtocolList[0].ComponentName2 == NULL) {
+ Status = gBS->InstallMultipleProtocolInterfaces (
+ &DriverBindingHandle,
+ &gEfiDriverBindingProtocolGuid, (EFI_DRIVER_BINDING_PROTOCOL *)_gDriverModelProtocolList[0].DriverBinding,
+ &gEfiDriverConfiguration2ProtocolGuid, (EFI_DRIVER_CONFIGURATION2_PROTOCOL *)_gDriverModelProtocolList[0].DriverConfiguration2,
+ &gEfiDriverDiagnostics2ProtocolGuid, (EFI_DRIVER_DIAGNOSTICS2_PROTOCOL *)_gDriverModelProtocolList[0].DriverDiagnostics2,
+ NULL
+ );
+ } else {
+ Status = gBS->InstallMultipleProtocolInterfaces (
+ &DriverBindingHandle,
+ &gEfiDriverBindingProtocolGuid, (EFI_DRIVER_BINDING_PROTOCOL *)_gDriverModelProtocolList[0].DriverBinding,
+ &gEfiComponentName2ProtocolGuid, (EFI_COMPONENT_NAME2_PROTOCOL *)_gDriverModelProtocolList[0].ComponentName2,
+ &gEfiDriverConfiguration2ProtocolGuid, (EFI_DRIVER_CONFIGURATION2_PROTOCOL *)_gDriverModelProtocolList[0].DriverConfiguration2,
+ &gEfiDriverDiagnostics2ProtocolGuid, (EFI_DRIVER_DIAGNOSTICS2_PROTOCOL *)_gDriverModelProtocolList[0].DriverDiagnostics2,
+ NULL
+ );
+ }
+ }
+ }
+ } // selection == 2 or 3
- //
- // Update the ImageHandle and DriverBindingHandle fields of the Driver Binding Protocol
- //
- DriverBinding = (EFI_DRIVER_BINDING_PROTOCOL *)_gDriverModelProtocolList[0].DriverBinding;
- DriverBinding->ImageHandle = ImageHandle;
- DriverBinding->DriverBindingHandle = DriverBindingHandle;
+ //
+ // ASSERT if the call to InstallMultipleProtocolInterfaces() failed
+ //
+ ASSERT_EFI_ERROR (Status);
+
+ //
+ // Update the ImageHandle and DriverBindingHandle fields of the Driver Binding Protocol
+ //
+ DriverBinding = (EFI_DRIVER_BINDING_PROTOCOL *)_gDriverModelProtocolList[0].DriverBinding;
+ DriverBinding->ImageHandle = ImageHandle;
+ DriverBinding->DriverBindingHandle = DriverBindingHandle;
return EFI_SUCCESS;
@@ -176,7 +247,7 @@ UefiDriverModelLibDestructor (
IN EFI_SYSTEM_TABLE *SystemTable
)
{
- EFI_STATUS Status;
+ EFI_STATUS Status = EFI_UNSUPPORTED;
EFI_HANDLE DriverBindingHandle;
//
@@ -184,21 +255,22 @@ UefiDriverModelLibDestructor (
// EdkIIGlueLib: _gDriverModelProtocolListEntries is always 1
//
- //
- // The Driver Binding Protocol must never be NULL
- //
- ASSERT(_gDriverModelProtocolList[0].DriverBinding != NULL);
+ //
+ // The Driver Binding Protocol must never be NULL
+ //
+ ASSERT(_gDriverModelProtocolList[0].DriverBinding != NULL);
- //
- // Retrieve the DriverBindingHandle from the Driver Binding Protocol
- //
- DriverBindingHandle = _gDriverModelProtocolList[0].DriverBinding->DriverBindingHandle;
+ //
+ // Retrieve the DriverBindingHandle from the Driver Binding Protocol
+ //
+ DriverBindingHandle = _gDriverModelProtocolList[0].DriverBinding->DriverBindingHandle;
- //
- // Check for all 8 possible combinations of the ComponentName, DriverConfiguration, and DriverDiagnostics Protocol
- // These are all checks against const pointers, so the optimizing compiler will only select one of the
- // calls to InstallMultipleProtocolInterfaces()
- //
+ //
+ // Check for all 8 possible combinations of the ComponentName, DriverConfiguration, and DriverDiagnostics Protocol
+ // These are all checks against const pointers, so the optimizing compiler will only select one of the
+ // calls to InstallMultipleProtocolInterfaces()
+ //
+ if ((_gEdkIIGlueDriverModelProtocolSelection == 1) || (_gEdkIIGlueDriverModelProtocolSelection == 3)) {
if (_gDriverModelProtocolList[0].DriverDiagnostics == NULL) {
if (_gDriverModelProtocolList[0].DriverConfiguration == NULL) {
if (_gDriverModelProtocolList[0].ComponentName == NULL) {
@@ -211,7 +283,7 @@ UefiDriverModelLibDestructor (
Status = gBS->UninstallMultipleProtocolInterfaces (
&DriverBindingHandle,
&gEfiDriverBindingProtocolGuid, (EFI_DRIVER_BINDING_PROTOCOL *)_gDriverModelProtocolList[0].DriverBinding,
- &EDKII_GLUE_SELECTED_COMPONENT_NAME_PROTOCOL_GUID, (EDKII_GLUE_SELECTED_COMPONENT_NAME_PROTOCOL *)_gDriverModelProtocolList[0].ComponentName,
+ &gEfiComponentNameProtocolGuid, (EFI_COMPONENT_NAME_PROTOCOL *)_gDriverModelProtocolList[0].ComponentName,
NULL
);
}
@@ -227,7 +299,7 @@ UefiDriverModelLibDestructor (
Status = gBS->UninstallMultipleProtocolInterfaces (
&DriverBindingHandle,
&gEfiDriverBindingProtocolGuid, (EFI_DRIVER_BINDING_PROTOCOL *)_gDriverModelProtocolList[0].DriverBinding,
- &EDKII_GLUE_SELECTED_COMPONENT_NAME_PROTOCOL_GUID, (EDKII_GLUE_SELECTED_COMPONENT_NAME_PROTOCOL *)_gDriverModelProtocolList[0].ComponentName,
+ &gEfiComponentNameProtocolGuid, (EFI_COMPONENT_NAME_PROTOCOL *)_gDriverModelProtocolList[0].ComponentName,
&gEfiDriverConfigurationProtocolGuid, (EFI_DRIVER_CONFIGURATION_PROTOCOL *)_gDriverModelProtocolList[0].DriverConfiguration,
NULL
);
@@ -246,7 +318,7 @@ UefiDriverModelLibDestructor (
Status = gBS->UninstallMultipleProtocolInterfaces (
&DriverBindingHandle,
&gEfiDriverBindingProtocolGuid, (EFI_DRIVER_BINDING_PROTOCOL *)_gDriverModelProtocolList[0].DriverBinding,
- &EDKII_GLUE_SELECTED_COMPONENT_NAME_PROTOCOL_GUID, (EDKII_GLUE_SELECTED_COMPONENT_NAME_PROTOCOL *)_gDriverModelProtocolList[0].ComponentName,
+ &gEfiComponentNameProtocolGuid, (EFI_COMPONENT_NAME_PROTOCOL *)_gDriverModelProtocolList[0].ComponentName,
&gEfiDriverDiagnosticsProtocolGuid, (EFI_DRIVER_DIAGNOSTICS_PROTOCOL *)_gDriverModelProtocolList[0].DriverDiagnostics,
NULL
);
@@ -264,7 +336,7 @@ UefiDriverModelLibDestructor (
Status = gBS->UninstallMultipleProtocolInterfaces (
&DriverBindingHandle,
&gEfiDriverBindingProtocolGuid, (EFI_DRIVER_BINDING_PROTOCOL *)_gDriverModelProtocolList[0].DriverBinding,
- &EDKII_GLUE_SELECTED_COMPONENT_NAME_PROTOCOL_GUID, (EDKII_GLUE_SELECTED_COMPONENT_NAME_PROTOCOL *)_gDriverModelProtocolList[0].ComponentName,
+ &gEfiComponentNameProtocolGuid, (EFI_COMPONENT_NAME_PROTOCOL *)_gDriverModelProtocolList[0].ComponentName,
&gEfiDriverConfigurationProtocolGuid, (EFI_DRIVER_CONFIGURATION_PROTOCOL *)_gDriverModelProtocolList[0].DriverConfiguration,
&gEfiDriverDiagnosticsProtocolGuid, (EFI_DRIVER_DIAGNOSTICS_PROTOCOL *)_gDriverModelProtocolList[0].DriverDiagnostics,
NULL
@@ -272,11 +344,88 @@ UefiDriverModelLibDestructor (
}
}
}
+ } // selection == 1 or 3
+
+ if ((_gEdkIIGlueDriverModelProtocolSelection == 2) || (_gEdkIIGlueDriverModelProtocolSelection == 3)) {
+ if (_gDriverModelProtocolList[0].DriverDiagnostics2 == NULL) {
+ if (_gDriverModelProtocolList[0].DriverConfiguration2 == NULL) {
+ if (_gDriverModelProtocolList[0].ComponentName2 == NULL) {
+ Status = gBS->UninstallMultipleProtocolInterfaces (
+ DriverBindingHandle,
+ &gEfiDriverBindingProtocolGuid, (EFI_DRIVER_BINDING_PROTOCOL *)_gDriverModelProtocolList[0].DriverBinding,
+ NULL
+ );
+ } else {
+ Status = gBS->UninstallMultipleProtocolInterfaces (
+ &DriverBindingHandle,
+ &gEfiDriverBindingProtocolGuid, (EFI_DRIVER_BINDING_PROTOCOL *)_gDriverModelProtocolList[0].DriverBinding,
+ &gEfiComponentName2ProtocolGuid, (EFI_COMPONENT_NAME2_PROTOCOL *)_gDriverModelProtocolList[0].ComponentName2,
+ NULL
+ );
+ }
+ } else {
+ if (_gDriverModelProtocolList[0].ComponentName2 == NULL) {
+ Status = gBS->UninstallMultipleProtocolInterfaces (
+ &DriverBindingHandle,
+ &gEfiDriverBindingProtocolGuid, (EFI_DRIVER_BINDING_PROTOCOL *)_gDriverModelProtocolList[0].DriverBinding,
+ &gEfiDriverConfiguration2ProtocolGuid, (EFI_DRIVER_CONFIGURATION2_PROTOCOL *)_gDriverModelProtocolList[0].DriverConfiguration2,
+ NULL
+ );
+ } else {
+ Status = gBS->UninstallMultipleProtocolInterfaces (
+ &DriverBindingHandle,
+ &gEfiDriverBindingProtocolGuid, (EFI_DRIVER_BINDING_PROTOCOL *)_gDriverModelProtocolList[0].DriverBinding,
+ &gEfiComponentName2ProtocolGuid, (EFI_COMPONENT_NAME2_PROTOCOL *)_gDriverModelProtocolList[0].ComponentName2,
+ &gEfiDriverConfiguration2ProtocolGuid, (EFI_DRIVER_CONFIGURATION2_PROTOCOL *)_gDriverModelProtocolList[0].DriverConfiguration2,
+ NULL
+ );
+ }
+ }
+ } else {
+ if (_gDriverModelProtocolList[0].DriverConfiguration2 == NULL) {
+ if (_gDriverModelProtocolList[0].ComponentName2 == NULL) {
+ Status = gBS->UninstallMultipleProtocolInterfaces (
+ &DriverBindingHandle,
+ &gEfiDriverBindingProtocolGuid, (EFI_DRIVER_BINDING_PROTOCOL *)_gDriverModelProtocolList[0].DriverBinding,
+ &gEfiDriverDiagnostics2ProtocolGuid, (EFI_DRIVER_DIAGNOSTICS2_PROTOCOL *)_gDriverModelProtocolList[0].DriverDiagnostics2,
+ NULL
+ );
+ } else {
+ Status = gBS->UninstallMultipleProtocolInterfaces (
+ &DriverBindingHandle,
+ &gEfiDriverBindingProtocolGuid, (EFI_DRIVER_BINDING_PROTOCOL *)_gDriverModelProtocolList[0].DriverBinding,
+ &gEfiComponentName2ProtocolGuid, (EFI_COMPONENT_NAME2_PROTOCOL *)_gDriverModelProtocolList[0].ComponentName2,
+ &gEfiDriverDiagnostics2ProtocolGuid, (EFI_DRIVER_DIAGNOSTICS2_PROTOCOL *)_gDriverModelProtocolList[0].DriverDiagnostics2,
+ NULL
+ );
+ }
+ } else {
+ if (_gDriverModelProtocolList[0].ComponentName2 == NULL) {
+ Status = gBS->UninstallMultipleProtocolInterfaces (
+ &DriverBindingHandle,
+ &gEfiDriverBindingProtocolGuid, (EFI_DRIVER_BINDING_PROTOCOL *)_gDriverModelProtocolList[0].DriverBinding,
+ &gEfiDriverConfiguration2ProtocolGuid, (EFI_DRIVER_CONFIGURATION2_PROTOCOL *)_gDriverModelProtocolList[0].DriverConfiguration2,
+ &gEfiDriverDiagnostics2ProtocolGuid, (EFI_DRIVER_DIAGNOSTICS2_PROTOCOL *)_gDriverModelProtocolList[0].DriverDiagnostics2,
+ NULL
+ );
+ } else {
+ Status = gBS->UninstallMultipleProtocolInterfaces (
+ &DriverBindingHandle,
+ &gEfiDriverBindingProtocolGuid, (EFI_DRIVER_BINDING_PROTOCOL *)_gDriverModelProtocolList[0].DriverBinding,
+ &gEfiComponentName2ProtocolGuid, (EFI_COMPONENT_NAME2_PROTOCOL *)_gDriverModelProtocolList[0].ComponentName2,
+ &gEfiDriverConfiguration2ProtocolGuid, (EFI_DRIVER_CONFIGURATION2_PROTOCOL *)_gDriverModelProtocolList[0].DriverConfiguration2,
+ &gEfiDriverDiagnostics2ProtocolGuid, (EFI_DRIVER_DIAGNOSTICS2_PROTOCOL *)_gDriverModelProtocolList[0].DriverDiagnostics2,
+ NULL
+ );
+ }
+ }
+ }
+ } // selection == 2 or 3
- //
- // ASSERT if the call to UninstallMultipleProtocolInterfaces() failed
- //
- ASSERT_EFI_ERROR (Status);
+ //
+ // ASSERT if the call to UninstallMultipleProtocolInterfaces() failed
+ //
+ ASSERT_EFI_ERROR (Status);
return EFI_SUCCESS;
}
diff --git a/EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/UefiLib/UefiLib.c b/EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/UefiLib/UefiLib.c
index b8852e43f3..cdfea2daf3 100644
--- a/EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/UefiLib/UefiLib.c
+++ b/EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/UefiLib/UefiLib.c
@@ -1,6 +1,6 @@
/*++
-Copyright (c) 2004 - 2006, 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
@@ -17,32 +17,6 @@ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
/**
- Compare whether two names of languages are identical.
-
- @param Language1 Name of language 1.
- @param Language2 Name of language 2.
-
- @retval TRUE Language 1 and language 2 are the same.
- @retval FALSE Language 1 and language 2 are not the same.
-
-**/
-STATIC
-BOOLEAN
-CompareIso639LanguageCode (
- IN CONST CHAR8 *Language1,
- IN CONST CHAR8 *Language2
- )
-{
- UINT32 Name1;
- UINT32 Name2;
-
- Name1 = ReadUnaligned24 ((CONST UINT32 *) Language1);
- Name2 = ReadUnaligned24 ((CONST UINT32 *) Language2);
-
- return (BOOLEAN) (Name1 == Name2);
-}
-
-/**
This function searches the list of configuration tables stored in the EFI System
Table for a table with a GUID that matches TableGuid. If a match is found,
then a pointer to the configuration table is returned in Table, and EFI_SUCCESS
@@ -510,6 +484,130 @@ EfiTestChildHandle (
}
/**
+ Tests whether a language code has format of ISO639-2.
+
+ @param Languages The language code to be tested.
+
+ @retval TRUE Language code format is ISO 639-2.
+ @retval FALSE Language code format is not ISO639-2.
+
+**/
+STATIC
+BOOLEAN
+IsIso639LanguageCode (
+ IN CONST CHAR8 *Languages
+ )
+{
+ UINTN Index;
+
+ //
+ // Find out format of Languages
+ //
+ for (Index = 0; Languages[Index] != 0 && Languages[Index] != ';' && Languages[Index] != '-'; Index++);
+ if (Languages[Index] != 0) {
+ //
+ // RFC4646 language code
+ //
+ return FALSE;
+ }
+
+ //
+ // No ';' and '-', it's either ISO639-2 code (list) or single RFC4646 code
+ //
+ if (Index == 2) {
+ //
+ // Single RFC4646 language code without country code, e.g. "en"
+ //
+ return FALSE;
+ }
+
+ //
+ // Languages in format of ISO639-2
+ //
+ return TRUE;
+}
+
+/**
+ Compare the first language instance of two language codes, either could be a
+ single language code or a language code list. This function assume Language1
+ and Language2 has the same language code format, i.e. either ISO639-2 or RFC4646.
+
+ @param Language1 The first language code to be tested.
+ @param Language2 The second language code to be tested.
+
+ @retval TRUE Language code match.
+ @retval FALSE Language code mismatch.
+
+**/
+STATIC
+BOOLEAN
+CompareLanguageCode (
+ IN CONST CHAR8 *Language1,
+ IN CONST CHAR8 *Language2
+ )
+{
+ UINTN Index;
+
+ //
+ // Compare first two bytes of language tag
+ //
+ if ((Language1[0] != Language2[0]) || (Language1[1] != Language2[1])) {
+ return FALSE;
+ }
+
+ if (IsIso639LanguageCode (Language1)) {
+ //
+ // ISO639-2 language code, compare the third byte of language tag
+ //
+ return (BOOLEAN) ((Language1[2] == Language2[2]) ? TRUE : FALSE);
+ }
+
+ //
+ // RFC4646 language code
+ //
+ for (Index = 0; Language1[Index] != 0 && Language1[Index] != ';'; Index++);
+ if ((AsciiStrnCmp (Language1, Language2, Index) == 0) && (Language2[Index] == 0 || Language2[Index] == ';')) {
+ return TRUE;
+ }
+
+ return FALSE;
+}
+
+/**
+ Step to next language code of a language code list.
+
+ @param Languages The language code list to traverse.
+
+ @return Pointer to next language code or NULL terminator if it's the last one.
+
+**/
+STATIC
+CONST
+CHAR8 *
+NextSupportedLanguage (
+ IN CONST CHAR8 *Languages
+ )
+{
+ UINTN Index;
+
+ if (IsIso639LanguageCode (Languages)) {
+ //
+ // ISO639-2 language code
+ //
+ return (Languages + 3);
+ }
+
+ //
+ // Search in RFC4646 language code list
+ //
+ for (Index = 0; Languages[Index] != 0 && Languages[Index] != ';'; Index++);
+ if (Languages[Index] == ';') {
+ Index++;
+ }
+ return (Languages + Index);
+}
+
+/**
This function looks up a Unicode string in UnicodeStringTable. If Language is
a member of SupportedLanguages and a Unicode string is found in UnicodeStringTable
that matches the language code specified by Language, then it is returned in
@@ -566,13 +664,13 @@ LookupUnicodeString (
// Make sure Language is in the set of Supported Languages
//
while (*SupportedLanguages != 0) {
- if (CompareIso639LanguageCode (Language, SupportedLanguages)) {
+ if (CompareLanguageCode (Language, SupportedLanguages)) {
//
// Search the Unicode String Table for the matching Language specifier
//
while (UnicodeStringTable->Language != NULL) {
- if (CompareIso639LanguageCode (Language, UnicodeStringTable->Language)) {
+ if (CompareLanguageCode (Language, UnicodeStringTable->Language)) {
//
// A matching string was found, so return it
@@ -587,7 +685,7 @@ LookupUnicodeString (
return EFI_UNSUPPORTED;
}
- SupportedLanguages += 3;
+ SupportedLanguages = NextSupportedLanguage (SupportedLanguages);
}
return EFI_UNSUPPORTED;
@@ -664,7 +762,7 @@ AddUnicodeString (
// Make sure Language is a member of SupportedLanguages
//
while (*SupportedLanguages != 0) {
- if (CompareIso639LanguageCode (Language, SupportedLanguages)) {
+ if (CompareLanguageCode (Language, SupportedLanguages)) {
//
// Determine the size of the Unicode String Table by looking for a NULL Language entry
@@ -673,7 +771,7 @@ AddUnicodeString (
if (*UnicodeStringTable != NULL) {
OldUnicodeStringTable = *UnicodeStringTable;
while (OldUnicodeStringTable->Language != NULL) {
- if (CompareIso639LanguageCode (Language, OldUnicodeStringTable->Language)) {
+ if (CompareLanguageCode (Language, OldUnicodeStringTable->Language)) {
return EFI_ALREADY_STARTED;
}
@@ -707,7 +805,7 @@ AddUnicodeString (
//
// Allocate space for a copy of the Language specifier
//
- NewUnicodeStringTable[NumberOfEntries].Language = AllocateCopyPool (3, Language);
+ NewUnicodeStringTable[NumberOfEntries].Language = AllocateCopyPool (AsciiStrSize (Language), Language);
if (NewUnicodeStringTable[NumberOfEntries].Language == NULL) {
(gBS->FreePool) (NewUnicodeStringTable);
return EFI_OUT_OF_RESOURCES;
@@ -753,7 +851,7 @@ AddUnicodeString (
return EFI_SUCCESS;
}
- SupportedLanguages += 3;
+ SupportedLanguages = NextSupportedLanguage (SupportedLanguages);
}
return EFI_UNSUPPORTED;
diff --git a/EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/UefiLib/UefiNotTiano.c b/EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/UefiLib/UefiNotTiano.c
index c995b92bc9..bccb35a44b 100644
--- a/EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/UefiLib/UefiNotTiano.c
+++ b/EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/UefiLib/UefiNotTiano.c
@@ -1,6 +1,6 @@
/*++
-Copyright (c) 2004 - 2007, 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
@@ -67,7 +67,7 @@ GlueEfiCreateEventLegacyBoot (
{
return EfiCreateEventLegacyBootEx (
EFI_TPL_CALLBACK,
- InternalEmptyFuntion,
+ NULL,
NULL,
LegacyBootEvent
);
@@ -101,29 +101,50 @@ EfiCreateEventLegacyBootEx (
OUT EFI_EVENT *LegacyBootEvent
)
{
- EFI_STATUS Status;
+ EFI_STATUS Status;
+ UINT32 EventType;
+ EFI_EVENT_NOTIFY WorkerNotifyFunction;
ASSERT (LegacyBootEvent != NULL);
#if (EFI_SPECIFICATION_VERSION < 0x00020000)
+
+ if (NotifyFunction == NULL) {
+ EventType = EFI_EVENT_SIGNAL_LEGACY_BOOT | EFI_EVENT_NOTIFY_SIGNAL_ALL;
+ } else {
+ EventType = EFI_EVENT_SIGNAL_LEGACY_BOOT;
+ }
+ WorkerNotifyFunction = NotifyFunction;
+
//
// prior to UEFI 2.0 use Tiano extension to EFI
//
Status = gBS->CreateEvent (
- EFI_EVENT_SIGNAL_LEGACY_BOOT | EFI_EVENT_NOTIFY_SIGNAL_ALL,
+ EventType,
NotifyTpl,
- NotifyFunction,
+ WorkerNotifyFunction,
NotifyContext,
LegacyBootEvent
);
#else
+
+ EventType = EVENT_NOTIFY_SIGNAL;
+ if (NotifyFunction == NULL) {
+ //
+ // CreatEventEx will check NotifyFunction is NULL or not
+ //
+ WorkerNotifyFunction = InternalEmptyFuntion;
+ } else {
+ WorkerNotifyFunction = NotifyFunction;
+ }
+
//
// For UEFI 2.0 and the future use an Event Group
//
Status = gBS->CreateEventEx (
- EVENT_NOTIFY_SIGNAL,
+ EventType,
NotifyTpl,
- NotifyFunction,
+ WorkerNotifyFunction,
NotifyContext,
&gEfiEventLegacyBootGuid,
LegacyBootEvent
@@ -157,7 +178,7 @@ GlueEfiCreateEventReadyToBoot (
{
return EfiCreateEventReadyToBootEx (
EFI_TPL_CALLBACK,
- InternalEmptyFuntion,
+ NULL,
NULL,
ReadyToBootEvent
);
@@ -191,29 +212,51 @@ EfiCreateEventReadyToBootEx (
OUT EFI_EVENT *ReadyToBootEvent
)
{
- EFI_STATUS Status;
+ EFI_STATUS Status;
+ UINT32 EventType;
+ EFI_EVENT_NOTIFY WorkerNotifyFunction;
ASSERT (ReadyToBootEvent != NULL);
-#if (EFI_SPECIFICATION_VERSION < 0x00020000)
+#if (EFI_SPECIFICATION_VERSION < 0x00020000)
+
+ if (NotifyFunction == NULL) {
+ EventType = EFI_EVENT_SIGNAL_READY_TO_BOOT | EFI_EVENT_NOTIFY_SIGNAL_ALL;
+ } else {
+ EventType = EFI_EVENT_SIGNAL_READY_TO_BOOT;
+ }
+ WorkerNotifyFunction = NotifyFunction;
+
//
// prior to UEFI 2.0 use Tiano extension to EFI
//
Status = gBS->CreateEvent (
- EFI_EVENT_SIGNAL_READY_TO_BOOT | EFI_EVENT_NOTIFY_SIGNAL_ALL,
+ EventType,
NotifyTpl,
- NotifyFunction,
+ WorkerNotifyFunction,
NotifyContext,
ReadyToBootEvent
);
#else
+
+ EventType = EVENT_NOTIFY_SIGNAL;
+
+ if (NotifyFunction == NULL) {
+ //
+ // CreatEventEx will check NotifyFunction is NULL or not
+ //
+ WorkerNotifyFunction = InternalEmptyFuntion;
+ } else {
+ WorkerNotifyFunction = NotifyFunction;
+ }
+
//
// For UEFI 2.0 and the future use an Event Group
//
Status = gBS->CreateEventEx (
- EVENT_NOTIFY_SIGNAL,
+ EventType,
NotifyTpl,
- NotifyFunction,
+ WorkerNotifyFunction,
NotifyContext,
&gEfiEventReadyToBootGuid,
ReadyToBootEvent
@@ -274,15 +317,6 @@ EfiSignalEventLegacyBoot (
/**
Check to see if the Firmware Volume (FV) Media Device Path is valid
- Tiano extended the EFI 1.10 device path nodes. Tiano does not own this enum
- so as we move to UEFI 2.0 support we must use a mechanism that conforms with
- the UEFI 2.0 specification to define the FV device path. An UEFI GUIDed
- device path is defined for PIWG extensions of device path. If the code
- is compiled to conform with the UEFI 2.0 specification use the new device path
- else use the old form for backwards compatability. The return value to this
- function points to a location in FvDevicePathNode and it does not allocate
- new memory for the GUID pointer that is returned.
-
@param FvDevicePathNode Pointer to FV device path to check.
@retval NULL FvDevicePathNode is not valid.
@@ -297,11 +331,6 @@ GlueEfiGetNameGuidFromFwVolDevicePathNode (
{
ASSERT (FvDevicePathNode != NULL);
- //
- // EFI Specification extension on Media Device Path. MEDIA_FW_VOL_FILEPATH_DEVICE_PATH is adopted by UEFI later and added in UEFI2.10.
- // In EdkCompatibility Package, we only support MEDIA_FW_VOL_FILEPATH_DEVICE_PATH that complies with
- // EFI 1.10 and UEFI 2.10.
- //
if (DevicePathType (&FvDevicePathNode->Header) == MEDIA_DEVICE_PATH &&
DevicePathSubType (&FvDevicePathNode->Header) == MEDIA_FV_FILEPATH_DP) {
return (EFI_GUID *) &FvDevicePathNode->NameGuid;
@@ -314,13 +343,6 @@ GlueEfiGetNameGuidFromFwVolDevicePathNode (
/**
Initialize a Firmware Volume (FV) Media Device Path node.
- Tiano extended the EFI 1.10 device path nodes. Tiano does not own this enum
- so as we move to UEFI 2.0 support we must use a mechanism that conforms with
- the UEFI 2.0 specification to define the FV device path. An UEFI GUIDed
- device path is defined for PIWG extensions of device path. If the code
- is compiled to conform with the UEFI 2.0 specification use the new device path
- else use the old form for backwards compatability.
-
@param FvDevicePathNode Pointer to a FV device path node to initialize
@param NameGuid FV file name to use in FvDevicePathNode
@@ -335,16 +357,10 @@ GlueEfiInitializeFwVolDevicepathNode (
ASSERT (FvDevicePathNode != NULL);
ASSERT (NameGuid != NULL);
- //
- // EFI Specification extension on Media Device Path. MEDIA_FW_VOL_FILEPATH_DEVICE_PATH is adopted by UEFI later and added in UEFI2.10.
- // In EdkCompatibility Package, we only support MEDIA_FW_VOL_FILEPATH_DEVICE_PATH that complies with
- // EFI 1.10 and UEFI 2.10.
- //
FvDevicePathNode->Header.Type = MEDIA_DEVICE_PATH;
FvDevicePathNode->Header.SubType = MEDIA_FV_FILEPATH_DP;
SetDevicePathNodeLength (&FvDevicePathNode->Header, sizeof (MEDIA_FW_VOL_FILEPATH_DEVICE_PATH));
-
- CopyGuid (&FvDevicePathNode->NameGuid, NameGuid);
+ CopyGuid (&FvDevicePathNode->NameGuid, NameGuid);
}
diff --git a/EdkCompatibilityPkg/Foundation/Library/EfiCommonLib/EfiCommonLib.inf b/EdkCompatibilityPkg/Foundation/Library/EfiCommonLib/EfiCommonLib.inf
index 8aff8813ad..722c9a9664 100644
--- a/EdkCompatibilityPkg/Foundation/Library/EfiCommonLib/EfiCommonLib.inf
+++ b/EdkCompatibilityPkg/Foundation/Library/EfiCommonLib/EfiCommonLib.inf
@@ -1,6 +1,6 @@
#/*++
#
-# Copyright (c) 2004 - 2007, 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
@@ -60,7 +60,7 @@ COMPONENT_TYPE = LIBRARY
Math.c
[sources.x64]
- X64/EfiCopyMemRep1.asm
+ X64/EfiCopyMemRep4.asm
X64/EfiSetMemRep4.asm
X64/EfiZeroMemRep4.asm
# X64/EfiCopyMem.asm
diff --git a/EdkCompatibilityPkg/Foundation/Library/EfiCommonLib/EfiCommonLib_Edk2.inf b/EdkCompatibilityPkg/Foundation/Library/EfiCommonLib/EfiCommonLib_Edk2.inf
index a6f930dacf..fd183c1d6a 100644
--- a/EdkCompatibilityPkg/Foundation/Library/EfiCommonLib/EfiCommonLib_Edk2.inf
+++ b/EdkCompatibilityPkg/Foundation/Library/EfiCommonLib/EfiCommonLib_Edk2.inf
@@ -1,6 +1,6 @@
#/*++
#
-# Copyright (c) 2004 - 2008, 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
@@ -85,14 +85,14 @@ COMPONENT_TYPE = LIBRARY
Math.c
[sources.x64]
- X64/EfiCopyMemRep1.asm | MSFT
+ X64/EfiCopyMemRep4.asm | MSFT
X64/EfiSetMemRep4.asm | MSFT
X64/EfiZeroMemRep4.asm | MSFT
# X64/EfiCopyMem.asm | MSFT
# X64/EfiSetMem.asm | MSFT
# X64/EfiZeroMem.asm | MSFT
- X64/EfiCopyMemRep1.asm | INTEL
+ X64/EfiCopyMemRep4.asm | INTEL
X64/EfiSetMemRep4.asm | INTEL
X64/EfiZeroMemRep4.asm | INTEL
# X64/EfiCopyMem.asm | INTEL
diff --git a/EdkCompatibilityPkg/Foundation/Library/EfiCommonLib/Ia32/EfiCopyMem.S b/EdkCompatibilityPkg/Foundation/Library/EfiCommonLib/Ia32/EfiCopyMem.S
index ed41ff994d..580c3fe94b 100644
--- a/EdkCompatibilityPkg/Foundation/Library/EfiCommonLib/Ia32/EfiCopyMem.S
+++ b/EdkCompatibilityPkg/Foundation/Library/EfiCommonLib/Ia32/EfiCopyMem.S
@@ -75,16 +75,16 @@ ASM_PFX(EfiCommonLibCopyMem):
movl %esi, %eax
addl %ecx, %eax # Source + Count
cmpl %edi, %eax
- jle _StartByteCopy
+ jbe _StartByteCopy
movl %edi, %eax
addl %ecx, %eax # Dest + Count
cmpl %esi, %eax
- jle _StartByteCopy
+ jbe _StartByteCopy
cmpl %edi, %esi
je _CopyMemDone
- jl _CopyOverlapped # too bad -- overlaps
+ jb _CopyOverlapped # too bad -- overlaps
# Pick up misaligned start bytes to get destination pointer 4-byte aligned
_StartByteCopy:
diff --git a/EdkCompatibilityPkg/Foundation/Library/EfiCommonLib/Ia32/EfiCopyMem.asm b/EdkCompatibilityPkg/Foundation/Library/EfiCommonLib/Ia32/EfiCopyMem.asm
index 7cf8b7f630..275e29b0c5 100644
--- a/EdkCompatibilityPkg/Foundation/Library/EfiCommonLib/Ia32/EfiCopyMem.asm
+++ b/EdkCompatibilityPkg/Foundation/Library/EfiCommonLib/Ia32/EfiCopyMem.asm
@@ -73,16 +73,16 @@ EfiCommonLibCopyMem PROC
mov eax, esi
add eax, ecx ; Source + Count
cmp eax, edi
- jle _StartByteCopy
+ jbe _StartByteCopy
mov eax, edi
add eax, ecx ; Dest + Count
cmp eax, esi
- jle _StartByteCopy
+ jbe _StartByteCopy
cmp esi, edi
je _CopyMemDone
- jl _CopyOverlapped ; too bad -- overlaps
+ jb _CopyOverlapped ; too bad -- overlaps
; Pick up misaligned start bytes to get destination pointer 4-byte aligned
_StartByteCopy:
diff --git a/EdkCompatibilityPkg/Foundation/Library/EfiCommonLib/Ia32/EfiCopyMem.c b/EdkCompatibilityPkg/Foundation/Library/EfiCommonLib/Ia32/EfiCopyMem.c
index 0acfdc9e5c..cb6b8ffe89 100644
--- a/EdkCompatibilityPkg/Foundation/Library/EfiCommonLib/Ia32/EfiCopyMem.c
+++ b/EdkCompatibilityPkg/Foundation/Library/EfiCommonLib/Ia32/EfiCopyMem.c
@@ -1,6 +1,6 @@
/*++
-Copyright (c) 2006, Intel Corporation. All rights reserved.<BR>
+Copyright (c) 2006 - 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
@@ -58,20 +58,21 @@ Returns:
; if (Source == Destination) => do nothing
; if (Source + Count <= Destination) => regular copy
; if (Destination + Count <= Source) => regular copy
+ ; if (Source >= Destination) => regular copy
; otherwise, do a reverse copy
mov eax, esi
add eax, ecx ; Source + Count
cmp eax, edi
- jle _StartByteCopy
+ jbe _StartByteCopy
mov eax, edi
add eax, ecx ; Dest + Count
cmp eax, esi
- jle _StartByteCopy
+ jbe _StartByteCopy
cmp esi, edi
je _CopyMemDone
- jl _CopyOverlapped ; too bad -- overlaps
+ jb _CopyOverlapped ; too bad -- overlaps
; Pick up misaligned start bytes to get destination pointer 4-byte aligned
_StartByteCopy:
diff --git a/EdkCompatibilityPkg/Foundation/Library/EfiCommonLib/Ia32/EfiCopyMemSSE2.c b/EdkCompatibilityPkg/Foundation/Library/EfiCommonLib/Ia32/EfiCopyMemSSE2.c
index 9a15288f5c..595c008a04 100644
--- a/EdkCompatibilityPkg/Foundation/Library/EfiCommonLib/Ia32/EfiCopyMemSSE2.c
+++ b/EdkCompatibilityPkg/Foundation/Library/EfiCommonLib/Ia32/EfiCopyMemSSE2.c
@@ -1,6 +1,6 @@
/*++
-Copyright (c) 2006, Intel Corporation. All rights reserved.<BR>
+Copyright (c) 2006 - 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
@@ -104,13 +104,13 @@ _CopyBlocks:
copyxmm:
movdqu xmm0, OWORD PTR ds:[esi]
- movdqu QWORD PTR ds:[edi], xmm0
+ movdqu OWORD PTR ds:[edi], xmm0
movdqu xmm1, OWORD PTR ds:[esi+16]
- movdqu QWORD PTR ds:[edi+16], xmm1
+ movdqu OWORD PTR ds:[edi+16], xmm1
movdqu xmm2, OWORD PTR ds:[esi+32]
- movdqu QWORD PTR ds:[edi+32], xmm2
+ movdqu OWORD PTR ds:[edi+32], xmm2
movdqu xmm3, OWORD PTR ds:[esi+48]
- movdqu QWORD PTR ds:[edi+48], xmm3
+ movdqu OWORD PTR ds:[edi+48], xmm3
add edi, 64
add esi, 64
diff --git a/EdkCompatibilityPkg/Foundation/Library/EfiCommonLib/Ia32/Power10U64.S b/EdkCompatibilityPkg/Foundation/Library/EfiCommonLib/Ia32/Power10U64.S
index b22609afb3..a40c56bcb1 100644
--- a/EdkCompatibilityPkg/Foundation/Library/EfiCommonLib/Ia32/Power10U64.S
+++ b/EdkCompatibilityPkg/Foundation/Library/EfiCommonLib/Ia32/Power10U64.S
@@ -65,11 +65,13 @@ ASM_PFX(Power10U64):
jcxz _Power10U64_Done
_Power10U64_Wend:
+ pushl %ecx
pushl $10
push 0xC(%ebp)
push 0x8(%ebp)
call ASM_PFX(MultU64x32)
addl $0xc, %esp
+ popl %ecx
movl %eax, 8(%ebp) # dword ptr Operand[0]
movl %edx, 0xC(%ebp) # dword ptr Operand[4]
loopl _Power10U64_Wend
diff --git a/EdkCompatibilityPkg/Foundation/Library/EfiCommonLib/Ia32/Power10U64.asm b/EdkCompatibilityPkg/Foundation/Library/EfiCommonLib/Ia32/Power10U64.asm
index b7d3373fd3..b6e25320d4 100644
--- a/EdkCompatibilityPkg/Foundation/Library/EfiCommonLib/Ia32/Power10U64.asm
+++ b/EdkCompatibilityPkg/Foundation/Library/EfiCommonLib/Ia32/Power10U64.asm
@@ -64,11 +64,13 @@ Power10U64 PROC
jcxz _Power10U64_Done
_Power10U64_Wend:
+ push ecx
push 10
push [ebp + 0Ch]; dword ptr Operand[4]
push [ebp + 8]; dword ptr Operand[0]
call MultU64x32
add esp, 0cH
+ pop ecx
mov [ebp + 8] , eax; dword ptr Operand[0]
mov [ebp + 0Ch] , edx; dword ptr Operand[4]
loop _Power10U64_Wend
diff --git a/EdkCompatibilityPkg/Foundation/Library/EfiCommonLib/Ia32/Power10U64.c b/EdkCompatibilityPkg/Foundation/Library/EfiCommonLib/Ia32/Power10U64.c
index c74e7933dd..2a31fe133e 100644
--- a/EdkCompatibilityPkg/Foundation/Library/EfiCommonLib/Ia32/Power10U64.c
+++ b/EdkCompatibilityPkg/Foundation/Library/EfiCommonLib/Ia32/Power10U64.c
@@ -1,6 +1,6 @@
/*++
-Copyright (c) 2006, Intel Corporation. All rights reserved.<BR>
+Copyright (c) 2006 - 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
@@ -56,11 +56,13 @@ Returns:
jcxz _Power10U64_Done
_Power10U64_Wend:
+ push ecx
push 10
push dword ptr Operand[4]
push dword ptr Operand[0]
call MultU64x32
add esp, 0Ch
+ pop ecx
mov dword ptr Operand[0], eax
mov dword ptr Operand[4], edx
loop _Power10U64_Wend
diff --git a/EdkCompatibilityPkg/Foundation/Library/EfiCommonLib/Math.c b/EdkCompatibilityPkg/Foundation/Library/EfiCommonLib/Math.c
index a931b533ea..c558869149 100644
--- a/EdkCompatibilityPkg/Foundation/Library/EfiCommonLib/Math.c
+++ b/EdkCompatibilityPkg/Foundation/Library/EfiCommonLib/Math.c
@@ -1,6 +1,6 @@
/*++
-Copyright (c) 2004, 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
@@ -76,6 +76,21 @@ Returns:
}
UINT64
+Power10U64 (
+ IN UINT64 Operand,
+ IN UINTN Power
+ )
+{
+ UINT64 Result;
+
+ Result = Operand;
+ while (Power-- > 0) {
+ Result *= 10;
+ }
+ return Result;
+}
+
+UINT64
RShiftU64 (
IN UINT64 Operand,
IN UINTN Count
diff --git a/EdkCompatibilityPkg/Foundation/Library/EfiCommonLib/Misc.c b/EdkCompatibilityPkg/Foundation/Library/EfiCommonLib/Misc.c
index 5356e235e8..ef68647569 100644
--- a/EdkCompatibilityPkg/Foundation/Library/EfiCommonLib/Misc.c
+++ b/EdkCompatibilityPkg/Foundation/Library/EfiCommonLib/Misc.c
@@ -1,6 +1,6 @@
/*++
-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
@@ -20,8 +20,8 @@ Abstract:
#include "Tiano.h"
#include "pei.h"
#include "cpuio.h"
-#include "pcicfg.h"
-#include "pcicfg2.h"
+#include EFI_PPI_CONSUMER (PciCfg)
+#include EFI_PPI_CONSUMER (PciCfg2)
#include EFI_PROTOCOL_CONSUMER (PciRootBridgeIo)
//
@@ -68,8 +68,6 @@ Returns:
--*/
{
- EFI_STATUS Status;
-
mPeiServices = NULL;
CpuIoPpi = NULL;
PciCfgPpi = NULL;
@@ -136,7 +134,7 @@ Returns:
EFI_STATUS Status;
EFI_PCI_ROOT_BRIDGE_IO_PROTOCOL *RootBridgeIo;
- if (mPeiServices == NULL) {
+ if (mPeiServices != NULL) {
//
// The function is called in PEI phase, use PEI interfaces
//
@@ -197,7 +195,7 @@ Returns:
EFI_STATUS Status;
EFI_PCI_ROOT_BRIDGE_IO_PROTOCOL *RootBridgeIo;
- if (mPeiServices == NULL) {
+ if (mPeiServices != NULL) {
//
// The function is called in PEI phase, use PEI interfaces
//
@@ -260,7 +258,7 @@ Returns:
UINT8 *Buffer8;
EFI_PCI_ROOT_BRIDGE_IO_PROTOCOL *RootBridgeIo;
- if (mPeiServices == NULL) {
+ if (mPeiServices != NULL) {
//
// The function is called in PEI phase, use PEI interfaces
//
diff --git a/EdkCompatibilityPkg/Foundation/Library/Pei/Include/PeiLib.h b/EdkCompatibilityPkg/Foundation/Library/Pei/Include/PeiLib.h
index b2fde2721d..8fd3f93247 100644
--- a/EdkCompatibilityPkg/Foundation/Library/Pei/Include/PeiLib.h
+++ b/EdkCompatibilityPkg/Foundation/Library/Pei/Include/PeiLib.h
@@ -1,6 +1,6 @@
/*++
-Copyright (c) 2004 - 2007, 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
@@ -195,8 +195,8 @@ EFI_STATUS
EFIAPI
PeiLibFfsFindNextFile (
IN EFI_FV_FILETYPE SearchType,
- IN EFI_PEI_FV_HANDLE FwVolHeader,
- IN OUT EFI_PEI_FILE_HANDLE *FileHeader
+ IN EFI_PEI_FV_HANDLE FvHandle,
+ IN OUT EFI_PEI_FILE_HANDLE *FileHandle
)
/*++
@@ -207,7 +207,7 @@ Routine Description:
Arguments:
SearchType - Filter to find only file of this type.
- FwVolHeader - Pointer to the current FV to search.
+ FvHandle - Pointer to the current FV to search.
FileHandle - Pointer to the file matching SearchType in FwVolHeader.
- NULL if file not found
@@ -271,7 +271,7 @@ Returns:
EFI_STATUS
EFIAPI
PeiLibFfsGetVolumeInfo (
- IN EFI_PEI_FV_HANDLE *VolumeHandle,
+ IN EFI_PEI_FV_HANDLE VolumeHandle,
OUT EFI_FV_INFO *VolumeInfo
)
/*++
@@ -464,7 +464,7 @@ MigrateIdtTable (
Routine Description:
- Migrate IDT from temporary memory to real memory where preceded with 4 bytes for
+ Migrate IDT from CAR to real memory where preceded with 4 bytes for
storing PeiService pointer.
Arguments:
diff --git a/EdkCompatibilityPkg/Foundation/Library/Pei/PeiLib/PeCoffLoader.c b/EdkCompatibilityPkg/Foundation/Library/Pei/PeiLib/PeCoffLoader.c
index bc4ca8ee66..1904902c78 100644
--- a/EdkCompatibilityPkg/Foundation/Library/Pei/PeiLib/PeCoffLoader.c
+++ b/EdkCompatibilityPkg/Foundation/Library/Pei/PeiLib/PeCoffLoader.c
@@ -70,7 +70,7 @@ PeCoffLoaderLoadImage (
EFI_STATUS
EFIAPI
PeCoffLoaderUnloadImage (
- IN OUT EFI_PEI_PE_COFF_LOADER_IMAGE_CONTEXT *ImageContext
+ IN EFI_PEI_PE_COFF_LOADER_IMAGE_CONTEXT *ImageContext
);
#if defined (EFI_DEBUG_ITP_BREAK) && !defined (_CONSOLE)
@@ -565,7 +565,10 @@ Returns:
// Pe image and in Te image header there is not a field to describe the imagesize,
// we use the largest VirtualAddress plus Size in each directory entry to describe the imagesize
//
- ImageContext->ImageSize = (UINT64) (Hdr.Te->DataDirectory[0].VirtualAddress + Hdr.Te->DataDirectory[0].Size);
+ ImageContext->ImageSize = (UINT64) (Hdr.Te->DataDirectory[0].VirtualAddress + Hdr.Te->DataDirectory[0].Size);
+ if(Hdr.Te->DataDirectory[1].VirtualAddress > Hdr.Te->DataDirectory[0].VirtualAddress) {
+ ImageContext->ImageSize = (UINT64) (Hdr.Te->DataDirectory[1].VirtualAddress + Hdr.Te->DataDirectory[1].Size);
+ }
ImageContext->SectionAlignment = 4096;
ImageContext->SizeOfHeaders = sizeof (EFI_TE_IMAGE_HEADER) + (UINTN) Hdr.Te->BaseOfCode - (UINTN) Hdr.Te->StrippedSize;
@@ -1013,6 +1016,12 @@ Returns:
UINT32 TempDebugEntryRva;
UINT32 NumberOfRvaAndSizes;
UINT16 Magic;
+#if (EFI_SPECIFICATION_VERSION >= 0x0002000A)
+ EFI_IMAGE_RESOURCE_DIRECTORY *ResourceDirectory;
+ EFI_IMAGE_RESOURCE_DIRECTORY_ENTRY *ResourceDirectoryEntry;
+ EFI_IMAGE_RESOURCE_DIRECTORY_STRING *ResourceDirectoryString;
+ EFI_IMAGE_RESOURCE_DATA_ENTRY *ResourceDataEntry;
+#endif
if (NULL == ImageContext) {
return EFI_INVALID_PARAMETER;
@@ -1368,6 +1377,73 @@ Returns:
}
}
+#if (EFI_SPECIFICATION_VERSION >= 0x0002000A)
+ //
+ // Get Image's HII resource section
+ //
+ if (!(ImageContext->IsTeImage)) {
+ if (Magic == EFI_IMAGE_NT_OPTIONAL_HDR32_MAGIC) {
+ //
+ // Use PE32 offset
+ //
+ DirectoryEntry = (EFI_IMAGE_DATA_DIRECTORY *)&Hdr.Pe32->OptionalHeader.DataDirectory[EFI_IMAGE_DIRECTORY_ENTRY_RESOURCE];
+ } else {
+ //
+ // Use PE32+ offset
+ //
+ DirectoryEntry = (EFI_IMAGE_DATA_DIRECTORY *)&Hdr.Pe32Plus->OptionalHeader.DataDirectory[EFI_IMAGE_DIRECTORY_ENTRY_RESOURCE];
+ }
+
+ if (DirectoryEntry->Size != 0) {
+ Base = PeCoffLoaderImageAddress (ImageContext, DirectoryEntry->VirtualAddress);
+
+ ResourceDirectory = (EFI_IMAGE_RESOURCE_DIRECTORY *) Base;
+ ResourceDirectoryEntry = (EFI_IMAGE_RESOURCE_DIRECTORY_ENTRY *) (ResourceDirectory + 1);
+
+ for (Index = 0; Index < ResourceDirectory->NumberOfNamedEntries; Index++) {
+ if (ResourceDirectoryEntry->u1.s.NameIsString) {
+ ResourceDirectoryString = (EFI_IMAGE_RESOURCE_DIRECTORY_STRING *) (Base + ResourceDirectoryEntry->u1.s.NameOffset);
+
+ if (ResourceDirectoryString->Length == 3 &&
+ ResourceDirectoryString->String[0] == L'H' &&
+ ResourceDirectoryString->String[1] == L'I' &&
+ ResourceDirectoryString->String[2] == L'I') {
+ //
+ // Resource Type "HII" found
+ //
+ if (ResourceDirectoryEntry->u2.s.DataIsDirectory) {
+ //
+ // Move to next level - resource Name
+ //
+ ResourceDirectory = (EFI_IMAGE_RESOURCE_DIRECTORY *) (Base + ResourceDirectoryEntry->u2.s.OffsetToDirectory);
+ ResourceDirectoryEntry = (EFI_IMAGE_RESOURCE_DIRECTORY_ENTRY *) (ResourceDirectory + 1);
+
+ if (ResourceDirectoryEntry->u2.s.DataIsDirectory) {
+ //
+ // Move to next level - resource Language
+ //
+ ResourceDirectory = (EFI_IMAGE_RESOURCE_DIRECTORY *) (Base + ResourceDirectoryEntry->u2.s.OffsetToDirectory);
+ ResourceDirectoryEntry = (EFI_IMAGE_RESOURCE_DIRECTORY_ENTRY *) (ResourceDirectory + 1);
+ }
+ }
+
+ //
+ // Now it ought to be resource Data
+ //
+ if (!ResourceDirectoryEntry->u2.s.DataIsDirectory) {
+ ResourceDataEntry = (EFI_IMAGE_RESOURCE_DATA_ENTRY *) (Base + ResourceDirectoryEntry->u2.OffsetToData);
+ ImageContext->HiiResourceData = (EFI_PHYSICAL_ADDRESS) (UINTN) PeCoffLoaderImageAddress (ImageContext, ResourceDataEntry->OffsetToData);
+ break;
+ }
+ }
+ }
+
+ ResourceDirectoryEntry++;
+ }
+ }
+ }
+#endif
+
#if defined (EFI_DEBUG_ITP_BREAK) && !defined (_CONSOLE)
AsmEfiSetBreakSupport ((UINTN)(ImageContext->ImageAddress));
#endif
@@ -1378,7 +1454,7 @@ Returns:
EFI_STATUS
EFIAPI
PeCoffLoaderUnloadImage (
- IN OUT EFI_PEI_PE_COFF_LOADER_IMAGE_CONTEXT *ImageContext
+ IN EFI_PEI_PE_COFF_LOADER_IMAGE_CONTEXT *ImageContext
)
/*++
diff --git a/EdkCompatibilityPkg/Foundation/Library/Pei/PeiLib/PeiLib.c b/EdkCompatibilityPkg/Foundation/Library/Pei/PeiLib/PeiLib.c
index 824ab4b8ce..11ae5a17f0 100644
--- a/EdkCompatibilityPkg/Foundation/Library/Pei/PeiLib/PeiLib.c
+++ b/EdkCompatibilityPkg/Foundation/Library/Pei/PeiLib/PeiLib.c
@@ -1,6 +1,6 @@
/*++
-Copyright (c) 2004 - 2008, 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
@@ -383,8 +383,8 @@ EFI_STATUS
EFIAPI
PeiLibFfsFindNextFile (
IN EFI_FV_FILETYPE SearchType,
- IN EFI_PEI_FV_HANDLE FwVolHeader,
- IN OUT EFI_PEI_FILE_HANDLE *FileHeader
+ IN EFI_PEI_FV_HANDLE FvHandle,
+ IN OUT EFI_PEI_FILE_HANDLE *FileHandle
)
/*++
@@ -395,9 +395,9 @@ Routine Description:
Arguments:
SearchType - Filter to find only file of this type.
- FwVolHeader - Pointer to the current FV to search.
+ FvHandle - Pointer to the current FV to search.
FileHandle - Pointer to the file matching SearchType in FwVolHeader.
- - NULL if file not found
+ - NULL if file not found
Returns:
EFI_STATUS
@@ -407,7 +407,7 @@ Returns:
EFI_PEI_SERVICES **PeiServices;
PeiServices = GetPeiServicesTablePointer();
- return (*PeiServices)->FfsFindNextFile (PeiServices, SearchType, &FwVolHeader, &FileHeader);
+ return (*PeiServices)->FfsFindNextFile (PeiServices, SearchType, FvHandle, FileHandle);
}
@@ -471,13 +471,13 @@ Returns:
EFI_PEI_SERVICES **PeiServices;
PeiServices = GetPeiServicesTablePointer();
- return (*PeiServices)->FfsFindSectionData (PeiServices, SectionType, &FfsFileHeader, SectionData);
+ return (*PeiServices)->FfsFindSectionData (PeiServices, SectionType, (EFI_PEI_FILE_HANDLE)FfsFileHeader, SectionData);
}
EFI_STATUS
EFIAPI
PeiLibFfsGetVolumeInfo (
- IN EFI_PEI_FV_HANDLE *VolumeHandle,
+ IN EFI_PEI_FV_HANDLE VolumeHandle,
OUT EFI_FV_INFO *VolumeInfo
)
/*++
diff --git a/EdkCompatibilityPkg/Foundation/Library/Pei/PeiLib/X64/EfiJump.h b/EdkCompatibilityPkg/Foundation/Library/Pei/PeiLib/X64/EfiJump.h
index 9e01b2cd9e..884ec1cc27 100644
--- a/EdkCompatibilityPkg/Foundation/Library/Pei/PeiLib/X64/EfiJump.h
+++ b/EdkCompatibilityPkg/Foundation/Library/Pei/PeiLib/X64/EfiJump.h
@@ -1,6 +1,6 @@
/*++
-Copyright (c) 2005, Intel Corporation. All rights reserved.<BR>
+Copyright (c) 2005 - 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
@@ -35,6 +35,8 @@ typedef struct {
UINT64 R14;
UINT64 R15;
UINT64 Rip;
+ UINT32 MxCsr;
+ UINT8 XmmBuffer[160]; // XMM6-XMM15
} EFI_JUMP_BUFFER;
#endif
diff --git a/EdkCompatibilityPkg/Foundation/Library/Pei/PeiLib/X64/Processor.c b/EdkCompatibilityPkg/Foundation/Library/Pei/PeiLib/X64/Processor.c
index aa366c2a1f..c930486183 100644
--- a/EdkCompatibilityPkg/Foundation/Library/Pei/PeiLib/X64/Processor.c
+++ b/EdkCompatibilityPkg/Foundation/Library/Pei/PeiLib/X64/Processor.c
@@ -1,6 +1,6 @@
/*++
-Copyright (c) 2005 - 2008, Intel Corporation. All rights reserved.<BR>
+Copyright (c) 2005 - 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
@@ -84,8 +84,6 @@ Returns:
--*/
{
*This = &mTransferControl;
- mTransferControl.SetJump = TransferControlSetJump;
- mTransferControl.LongJump = TransferControlLongJump;
return EFI_SUCCESS;
}
@@ -112,7 +110,6 @@ Returns:
--*/
{
*This = &mFlushInstructionCache;
- mFlushInstructionCache.Flush = FlushInstructionCacheFlush;
return EFI_SUCCESS;
}
diff --git a/EdkCompatibilityPkg/Foundation/Library/Pei/PeiLib/X64/ProcessorAsms.Asm b/EdkCompatibilityPkg/Foundation/Library/Pei/PeiLib/X64/ProcessorAsms.Asm
index b6be0b2f60..418400c15a 100644
--- a/EdkCompatibilityPkg/Foundation/Library/Pei/PeiLib/X64/ProcessorAsms.Asm
+++ b/EdkCompatibilityPkg/Foundation/Library/Pei/PeiLib/X64/ProcessorAsms.Asm
@@ -1,6 +1,6 @@
;------------------------------------------------------------------------------
;
-; Copyright (c) 2005 - 2007, Intel Corporation. All rights reserved.<BR>
+; Copyright (c) 2005 - 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
@@ -73,6 +73,8 @@ _r13 QWORD ?
_r14 QWORD ?
_r15 QWORD ?
_rip QWORD ?
+_MxCsr DWORD ?
+_XmmBuffer DB 160 DUP (?)
_EFI_JUMP_BUFFER ENDS
EFI_JUMP_BUFFER TYPEDEF _EFI_JUMP_BUFFER
@@ -116,6 +118,19 @@ TransferControlSetJump PROC
mov (EFI_JUMP_BUFFER PTR [rdx])._r13, r13
mov (EFI_JUMP_BUFFER PTR [rdx])._r14, r14
mov (EFI_JUMP_BUFFER PTR [rdx])._r15, r15
+ ; save non-volatile fp registers
+ stmxcsr (EFI_JUMP_BUFFER PTR [rdx])._MxCsr
+ lea rax, (EFI_JUMP_BUFFER PTR [rdx])._XmmBuffer
+ movdqu [rax], xmm6
+ movdqu [rax + 10h], xmm7
+ movdqu [rax + 20h], xmm8
+ movdqu [rax + 30h], xmm9
+ movdqu [rax + 40h], xmm10
+ movdqu [rax + 50h], xmm11
+ movdqu [rax + 60h], xmm12
+ movdqu [rax + 70h], xmm13
+ movdqu [rax + 80h], xmm14
+ movdqu [rax + 90h], xmm15
mov rax, QWORD PTR [rsp+0]
mov (EFI_JUMP_BUFFER PTR [rdx])._rip, rax
mov rax, EFI_SUCCESS
@@ -134,6 +149,19 @@ TransferControlSetJump ENDP
;
PUBLIC TransferControlLongJump
TransferControlLongJump PROC
+ ; load non-volatile fp registers
+ ldmxcsr (EFI_JUMP_BUFFER PTR [rdx])._MxCsr
+ lea rax, (EFI_JUMP_BUFFER PTR [rdx])._XmmBuffer
+ movdqu xmm6, [rax]
+ movdqu xmm7, [rax + 10h]
+ movdqu xmm8, [rax + 20h]
+ movdqu xmm9, [rax + 30h]
+ movdqu xmm10, [rax + 40h]
+ movdqu xmm11, [rax + 50h]
+ movdqu xmm12, [rax + 60h]
+ movdqu xmm13, [rax + 70h]
+ movdqu xmm14, [rax + 80h]
+ movdqu xmm15, [rax + 90h]
; set return from SetJump to EFI_WARN_RETURN_FROM_LONG_JUMP
mov rax, EFI_WARN_RETURN_FROM_LONG_JUMP
mov rbx, (EFI_JUMP_BUFFER PTR [rdx])._rbx
diff --git a/EdkCompatibilityPkg/Foundation/Library/Pei/PeiLib/X64/ProcessorAsms.S b/EdkCompatibilityPkg/Foundation/Library/Pei/PeiLib/X64/ProcessorAsms.S
index 5253c0e2d1..2d464488cc 100644
--- a/EdkCompatibilityPkg/Foundation/Library/Pei/PeiLib/X64/ProcessorAsms.S
+++ b/EdkCompatibilityPkg/Foundation/Library/Pei/PeiLib/X64/ProcessorAsms.S
@@ -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
+ stmxcsr 0x60(%rdx)
+ lea 0x68(%rdx), %rax
+ movdqu %xmm6, (%rax)
+ movdqu %xmm7, 0x10(%rax)
+ movdqu %xmm8, 0x20(%rax)
+ movdqu %xmm9, 0x30(%rax)
+ movdqu %xmm10, 0x40(%rax)
+ movdqu %xmm11, 0x50(%rax)
+ movdqu %xmm12, 0x60(%rax)
+ movdqu %xmm13, 0x70(%rax)
+ movdqu %xmm14, 0x80(%rax)
+ movdqu %xmm15, 0x90(%rax)
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
+ ldmxcsr 0x60(%rdx)
+ lea 0x68(%rdx), %rax
+ movdqu (%rax), %xmm6
+ movdqu 0x10(%rax), %xmm7
+ movdqu 0x20(%rax), %xmm8
+ movdqu 0x30(%rax), %xmm9
+ movdqu 0x40(%rax), %xmm10
+ movdqu 0x50(%rax), %xmm11
+ movdqu 0x60(%rax), %xmm12
+ movdqu 0x70(%rax), %xmm13
+ movdqu 0x80(%rax), %xmm14
+ movdqu 0x90(%rax), %xmm15
mov $0x5,%rax
mov (%rdx),%rbx
mov 0x8(%rdx),%rsp
diff --git a/EdkCompatibilityPkg/Foundation/Library/RuntimeDxe/EfiRuntimeLib/Ia32/RuntimeLib.c b/EdkCompatibilityPkg/Foundation/Library/RuntimeDxe/EfiRuntimeLib/Ia32/RuntimeLib.c
index 9807b45035..29cdeb967a 100644
--- a/EdkCompatibilityPkg/Foundation/Library/RuntimeDxe/EfiRuntimeLib/Ia32/RuntimeLib.c
+++ b/EdkCompatibilityPkg/Foundation/Library/RuntimeDxe/EfiRuntimeLib/Ia32/RuntimeLib.c
@@ -1,6 +1,6 @@
/*++
-Copyright (c) 2004 - 2008, 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
@@ -21,9 +21,11 @@ Abstract:
#include "Tiano.h"
#include "EfiRuntimeLib.h"
+#include "PeiHob.h"
#include EFI_PROTOCOL_DEFINITION (CpuIo)
#include EFI_PROTOCOL_DEFINITION (FirmwareVolumeBlock)
#include EFI_GUID_DEFINITION (StatusCodeCallerId)
+#include EFI_GUID_DEFINITION (Hob)
#include EFI_ARCH_PROTOCOL_DEFINITION (StatusCode)
//
@@ -43,7 +45,81 @@ BOOLEAN mEfiAtRuntime = FALSE;
FVB_ENTRY *mFvbEntry;
#if (EFI_SPECIFICATION_VERSION >= 0x00020000)
-static EFI_STATUS_CODE_PROTOCOL *gStatusCode = NULL;
+
+EFI_REPORT_STATUS_CODE gReportStatusCode = NULL;
+EFI_EVENT gEfiStatusCodeNotifyEvent = NULL;
+
+VOID
+EFIAPI
+OnStatusCodeInstall (
+ IN EFI_EVENT Event,
+ IN VOID *Context
+ )
+{
+ EFI_STATUS Status;
+ EFI_STATUS_CODE_PROTOCOL *StatusCode;
+
+ Status = gBS->LocateProtocol (&gEfiStatusCodeRuntimeProtocolGuid, NULL, (VOID **) &StatusCode);
+ if (!EFI_ERROR (Status)) {
+ gReportStatusCode = StatusCode->ReportStatusCode;
+ }
+}
+
+EFI_STATUS
+GetPeiProtocol (
+ IN EFI_GUID *ProtocolGuid,
+ IN VOID **Interface
+ )
+/*++
+
+Routine Description:
+
+ Searches for a Protocol Interface passed from PEI through a HOB
+
+Arguments:
+
+ ProtocolGuid - The Protocol GUID to search for in the HOB List
+
+ Interface - A pointer to the interface for the Protocol GUID
+
+Returns:
+
+ EFI_SUCCESS - The Protocol GUID was found and its interface is returned in Interface
+
+ EFI_NOT_FOUND - The Protocol GUID was not found in the HOB List
+
+--*/
+{
+ EFI_STATUS Status;
+ EFI_PEI_HOB_POINTERS GuidHob;
+
+ //
+ // Get Hob list
+ //
+ Status = EfiLibGetSystemConfigurationTable (&gEfiHobListGuid, (VOID **) &GuidHob.Raw);
+ if (EFI_ERROR (Status)) {
+ return Status;
+ }
+
+ for (Status = EFI_NOT_FOUND; EFI_ERROR (Status);) {
+ if (END_OF_HOB_LIST (GuidHob)) {
+ Status = EFI_NOT_FOUND;
+ break;
+ }
+
+ if (GET_HOB_TYPE (GuidHob) == EFI_HOB_TYPE_GUID_EXTENSION) {
+ if (EfiCompareGuid (ProtocolGuid, &GuidHob.Guid->Name)) {
+ Status = EFI_SUCCESS;
+ *Interface = (VOID *) *(UINTN *) ((UINT8 *) (&GuidHob.Guid->Name) + sizeof (EFI_GUID));
+ }
+ }
+
+ GuidHob.Raw = GET_NEXT_HOB (GuidHob);
+ }
+
+ return Status;
+}
+
#endif
EFI_STATUS
@@ -214,9 +290,8 @@ Returns:
//
EfiConvertInternalPointer ((VOID **) &gCpuIo);
#if (EFI_SPECIFICATION_VERSION >= 0x00020000)
- if (gStatusCode != NULL) {
- EfiConvertInternalPointer ((VOID **) &gStatusCode->ReportStatusCode);
- EfiConvertInternalPointer ((VOID **) &gStatusCode);
+ if (gReportStatusCode != NULL) {
+ EfiConvertInternalPointer ((VOID **) &gReportStatusCode);
}
#endif
EfiConvertInternalPointer ((VOID **) &mRT);
@@ -256,6 +331,9 @@ Returns:
--*/
{
EFI_STATUS Status;
+#if (EFI_SPECIFICATION_VERSION >= 0x00020000)
+ VOID *Registration;
+#endif
if (mRuntimeLibInitialized) {
return EFI_ALREADY_STARTED;
@@ -275,10 +353,26 @@ Returns:
ASSERT_EFI_ERROR (Status);
#if (EFI_SPECIFICATION_VERSION >= 0x00020000)
- Status = gBS->LocateProtocol (&gEfiStatusCodeRuntimeProtocolGuid, NULL, (VOID **)&gStatusCode);
- if (EFI_ERROR (Status)) {
- gStatusCode = NULL;
- }
+ //
+ // Register EFI_STATUS_CODE_PROTOCOL notify function
+ //
+ Status = gBS->CreateEvent (
+ EFI_EVENT_NOTIFY_SIGNAL,
+ EFI_TPL_CALLBACK,
+ OnStatusCodeInstall,
+ NULL,
+ &gEfiStatusCodeNotifyEvent
+ );
+ ASSERT_EFI_ERROR (Status);
+
+ Status = gBS->RegisterProtocolNotify (
+ &gEfiStatusCodeRuntimeProtocolGuid,
+ gEfiStatusCodeNotifyEvent,
+ &Registration
+ );
+ ASSERT_EFI_ERROR (Status);
+
+ gBS->SignalEvent (gEfiStatusCodeNotifyEvent);
#endif
Status = gBS->LocateProtocol (&gEfiCpuIoProtocolGuid, NULL, (VOID **) &gCpuIo);
@@ -363,6 +457,16 @@ Returns:
ASSERT_EFI_ERROR (Status);
}
+#if (EFI_SPECIFICATION_VERSION >= 0x00020000)
+ //
+ // Close EfiStatusCodeRuntimeProtocol notify function
+ //
+ if (gEfiStatusCodeNotifyEvent != NULL) {
+ Status = gBS->CloseEvent (gEfiStatusCodeNotifyEvent);
+ ASSERT_EFI_ERROR (Status);
+ }
+#endif
+
return EFI_SUCCESS;
}
@@ -390,6 +494,9 @@ Returns:
--*/
{
EFI_STATUS Status;
+#if (EFI_SPECIFICATION_VERSION >= 0x00020000)
+ VOID *Registration;
+#endif
if (mRuntimeLibInitialized) {
return EFI_ALREADY_STARTED;
@@ -406,10 +513,26 @@ Returns:
ASSERT (mRT != NULL);
#if (EFI_SPECIFICATION_VERSION >= 0x00020000)
- Status = gBS->LocateProtocol (&gEfiStatusCodeRuntimeProtocolGuid, NULL, (VOID **)&gStatusCode);
- if (EFI_ERROR (Status)) {
- gStatusCode = NULL;
- }
+ //
+ // Register EFI_STATUS_CODE_PROTOCOL notify function
+ //
+ Status = gBS->CreateEvent (
+ EFI_EVENT_NOTIFY_SIGNAL,
+ EFI_TPL_CALLBACK,
+ OnStatusCodeInstall,
+ NULL,
+ &gEfiStatusCodeNotifyEvent
+ );
+ ASSERT_EFI_ERROR (Status);
+
+ Status = gBS->RegisterProtocolNotify (
+ &gEfiStatusCodeRuntimeProtocolGuid,
+ gEfiStatusCodeNotifyEvent,
+ &Registration
+ );
+ ASSERT_EFI_ERROR (Status);
+
+ gBS->SignalEvent (gEfiStatusCodeNotifyEvent);
#endif
Status = gBS->LocateProtocol (&gEfiCpuIoProtocolGuid, NULL, (VOID **) &gCpuIo);
@@ -761,8 +884,8 @@ EfiReportStatusCode (
IN EFI_STATUS_CODE_TYPE CodeType,
IN EFI_STATUS_CODE_VALUE Value,
IN UINT32 Instance,
- IN EFI_GUID * CallerId,
- IN EFI_STATUS_CODE_DATA * Data OPTIONAL
+ IN EFI_GUID *CallerId OPTIONAL,
+ IN EFI_STATUS_CODE_DATA *Data OPTIONAL
)
/*++
@@ -788,19 +911,30 @@ Returns:
--*/
{
- EFI_STATUS Status;
+ EFI_STATUS Status;
-#if (EFI_SPECIFICATION_VERSION >= 0x00020000)
- if (gStatusCode == NULL) {
+#if (EFI_SPECIFICATION_VERSION >= 0x00020000)
+ if (gReportStatusCode == NULL) {
+ //
+ // Because we've installed the protocol notification on EfiStatusCodeRuntimeProtocol,
+ // running here indicates that the StatusCode driver has not started yet.
+ //
if (EfiAtRuntime ()) {
+ //
+ // Running here only when StatusCode driver never starts.
+ //
return EFI_UNSUPPORTED;
}
- Status = gBS->LocateProtocol (&gEfiStatusCodeRuntimeProtocolGuid, NULL, (VOID **)&gStatusCode);
- if (EFI_ERROR (Status) || gStatusCode == NULL) {
+
+ //
+ // Try to get the PEI version of ReportStatusCode.
+ //
+ Status = GetPeiProtocol (&gEfiStatusCodeRuntimeProtocolGuid, (VOID **) &gReportStatusCode);
+ if (EFI_ERROR (Status)) {
return EFI_UNSUPPORTED;
}
}
- Status = gStatusCode->ReportStatusCode (CodeType, Value, Instance, CallerId, Data);
+ Status = gReportStatusCode (CodeType, Value, Instance, CallerId, Data);
#else
if (mRT == NULL) {
return EFI_UNSUPPORTED;
diff --git a/EdkCompatibilityPkg/Foundation/Library/RuntimeDxe/EfiRuntimeLib/RtDevicePath.c b/EdkCompatibilityPkg/Foundation/Library/RuntimeDxe/EfiRuntimeLib/RtDevicePath.c
index c94ee431ef..ac169a1166 100644
--- a/EdkCompatibilityPkg/Foundation/Library/RuntimeDxe/EfiRuntimeLib/RtDevicePath.c
+++ b/EdkCompatibilityPkg/Foundation/Library/RuntimeDxe/EfiRuntimeLib/RtDevicePath.c
@@ -1,6 +1,6 @@
/*++
-Copyright (c) 2006 - 2007, Intel Corporation. All rights reserved.<BR>
+Copyright (c) 2006 - 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
@@ -599,13 +599,6 @@ Routine Description:
Initialize a Firmware Volume (FV) Media Device Path node.
- Tiano extended the EFI 1.10 device path nodes. Tiano does not own this enum
- so as we move to UEFI 2.0 support we must use a mechanism that conforms with
- the UEFI 2.0 specification to define the FV device path. An UEFI GUIDed
- device path is defined for PIWG extensions of device path. If the code
- is compiled to conform with the UEFI 2.0 specification use the new device path
- else use the old form for backwards compatability.
-
Arguments:
FvDevicePathNode - Pointer to a FV device path node to initialize
@@ -617,11 +610,6 @@ Returns:
--*/
{
- //
- // EFI Specification extension on Media Device Path. MEDIA_FW_VOL_FILEPATH_DEVICE_PATH is adopted by UEFI later and added in UEFI2.10.
- // In EdkCompatibility Package, we only support MEDIA_FW_VOL_FILEPATH_DEVICE_PATH that complies with
- // EFI 1.10 and UEFI 2.10.
- //
FvDevicePathNode->Header.Type = MEDIA_DEVICE_PATH;
FvDevicePathNode->Header.SubType = MEDIA_FV_FILEPATH_DP;
SetDevicePathNodeLength (&FvDevicePathNode->Header, sizeof (MEDIA_FW_VOL_FILEPATH_DEVICE_PATH));
@@ -640,15 +628,6 @@ Routine Description:
Check to see if the Firmware Volume (FV) Media Device Path is valid.
- Tiano extended the EFI 1.10 device path nodes. Tiano does not own this enum
- so as we move to UEFI 2.0 support we must use a mechanism that conforms with
- the UEFI 2.0 specification to define the FV device path. An UEFI GUIDed
- device path is defined for PIWG extensions of device path. If the code
- is compiled to conform with the UEFI 2.0 specification use the new device path
- else use the old form for backwards compatability. The return value to this
- function points to a location in FvDevicePathNode and it does not allocate
- new memory for the GUID pointer that is returned.
-
Arguments:
FvDevicePathNode - Pointer to FV device path to check
@@ -660,16 +639,11 @@ Returns:
--*/
{
- //
- // EFI Specification extension on Media Device Path. MEDIA_FW_VOL_FILEPATH_DEVICE_PATH is adopted by UEFI later and added in UEFI2.10.
- // In EdkCompatibility Package, we only support MEDIA_FW_VOL_FILEPATH_DEVICE_PATH that complies with
- // EFI 1.10 and UEFI 2.10.
- //
if (DevicePathType (&FvDevicePathNode->Header) == MEDIA_DEVICE_PATH &&
DevicePathSubType (&FvDevicePathNode->Header) == MEDIA_FV_FILEPATH_DP) {
return &FvDevicePathNode->NameGuid;
}
- return NULL;
+ return NULL;
}
diff --git a/EdkCompatibilityPkg/Foundation/Library/RuntimeDxe/EfiRuntimeLib/X64/RuntimeLib.c b/EdkCompatibilityPkg/Foundation/Library/RuntimeDxe/EfiRuntimeLib/X64/RuntimeLib.c
index 8771e2bcd3..11b36e056d 100644
--- a/EdkCompatibilityPkg/Foundation/Library/RuntimeDxe/EfiRuntimeLib/X64/RuntimeLib.c
+++ b/EdkCompatibilityPkg/Foundation/Library/RuntimeDxe/EfiRuntimeLib/X64/RuntimeLib.c
@@ -1,6 +1,6 @@
/*++
-Copyright (c) 2005 - 2008, Intel Corporation. All rights reserved.<BR>
+Copyright (c) 2005 - 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
@@ -21,9 +21,11 @@ Abstract:
#include "Tiano.h"
#include "EfiRuntimeLib.h"
+#include "PeiHob.h"
#include EFI_PROTOCOL_DEFINITION (CpuIo)
#include EFI_PROTOCOL_DEFINITION (FirmwareVolumeBlock)
#include EFI_GUID_DEFINITION (StatusCodeCallerId)
+#include EFI_GUID_DEFINITION (Hob)
#include EFI_ARCH_PROTOCOL_DEFINITION (StatusCode)
//
@@ -43,7 +45,81 @@ BOOLEAN mEfiAtRuntime = FALSE;
FVB_ENTRY *mFvbEntry;
#if (EFI_SPECIFICATION_VERSION >= 0x00020000)
-static EFI_STATUS_CODE_PROTOCOL *gStatusCode = NULL;
+
+EFI_REPORT_STATUS_CODE gReportStatusCode = NULL;
+EFI_EVENT gEfiStatusCodeNotifyEvent = NULL;
+
+VOID
+EFIAPI
+OnStatusCodeInstall (
+ IN EFI_EVENT Event,
+ IN VOID *Context
+ )
+{
+ EFI_STATUS Status;
+ EFI_STATUS_CODE_PROTOCOL *StatusCode;
+
+ Status = gBS->LocateProtocol (&gEfiStatusCodeRuntimeProtocolGuid, NULL, (VOID **) &StatusCode);
+ if (!EFI_ERROR (Status)) {
+ gReportStatusCode = StatusCode->ReportStatusCode;
+ }
+}
+
+EFI_STATUS
+GetPeiProtocol (
+ IN EFI_GUID *ProtocolGuid,
+ IN VOID **Interface
+ )
+/*++
+
+Routine Description:
+
+ Searches for a Protocol Interface passed from PEI through a HOB
+
+Arguments:
+
+ ProtocolGuid - The Protocol GUID to search for in the HOB List
+
+ Interface - A pointer to the interface for the Protocol GUID
+
+Returns:
+
+ EFI_SUCCESS - The Protocol GUID was found and its interface is returned in Interface
+
+ EFI_NOT_FOUND - The Protocol GUID was not found in the HOB List
+
+--*/
+{
+ EFI_STATUS Status;
+ EFI_PEI_HOB_POINTERS GuidHob;
+
+ //
+ // Get Hob list
+ //
+ Status = EfiLibGetSystemConfigurationTable (&gEfiHobListGuid, (VOID **) &GuidHob.Raw);
+ if (EFI_ERROR (Status)) {
+ return Status;
+ }
+
+ for (Status = EFI_NOT_FOUND; EFI_ERROR (Status);) {
+ if (END_OF_HOB_LIST (GuidHob)) {
+ Status = EFI_NOT_FOUND;
+ break;
+ }
+
+ if (GET_HOB_TYPE (GuidHob) == EFI_HOB_TYPE_GUID_EXTENSION) {
+ if (EfiCompareGuid (ProtocolGuid, &GuidHob.Guid->Name)) {
+ Status = EFI_SUCCESS;
+ *Interface = (VOID *) *(UINTN *) ((UINT8 *) (&GuidHob.Guid->Name) + sizeof (EFI_GUID));
+ }
+ }
+
+ GuidHob.Raw = GET_NEXT_HOB (GuidHob);
+ }
+
+ return Status;
+}
+
#endif
EFI_STATUS
@@ -214,9 +290,8 @@ Returns:
//
EfiConvertInternalPointer ((VOID **) &gCpuIo);
#if (EFI_SPECIFICATION_VERSION >= 0x00020000)
- if (gStatusCode != NULL) {
- EfiConvertInternalPointer ((VOID **) &gStatusCode->ReportStatusCode);
- EfiConvertInternalPointer ((VOID **) &gStatusCode);
+ if (gReportStatusCode != NULL) {
+ EfiConvertInternalPointer ((VOID **) &gReportStatusCode);
}
#endif
EfiConvertInternalPointer ((VOID **) &mRT);
@@ -256,6 +331,9 @@ Returns:
--*/
{
EFI_STATUS Status;
+#if (EFI_SPECIFICATION_VERSION >= 0x00020000)
+ VOID *Registration;
+#endif
if (mRuntimeLibInitialized) {
return EFI_ALREADY_STARTED;
@@ -275,10 +353,26 @@ Returns:
ASSERT_EFI_ERROR (Status);
#if (EFI_SPECIFICATION_VERSION >= 0x00020000)
- Status = gBS->LocateProtocol (&gEfiStatusCodeRuntimeProtocolGuid, NULL, (VOID **)&gStatusCode);
- if (EFI_ERROR (Status)) {
- gStatusCode = NULL;
- }
+ //
+ // Register EFI_STATUS_CODE_PROTOCOL notify function
+ //
+ Status = gBS->CreateEvent (
+ EFI_EVENT_NOTIFY_SIGNAL,
+ EFI_TPL_CALLBACK,
+ OnStatusCodeInstall,
+ NULL,
+ &gEfiStatusCodeNotifyEvent
+ );
+ ASSERT_EFI_ERROR (Status);
+
+ Status = gBS->RegisterProtocolNotify (
+ &gEfiStatusCodeRuntimeProtocolGuid,
+ gEfiStatusCodeNotifyEvent,
+ &Registration
+ );
+ ASSERT_EFI_ERROR (Status);
+
+ gBS->SignalEvent (gEfiStatusCodeNotifyEvent);
#endif
Status = gBS->LocateProtocol (&gEfiCpuIoProtocolGuid, NULL, (VOID **) &gCpuIo);
@@ -363,6 +457,16 @@ Returns:
ASSERT_EFI_ERROR (Status);
}
+#if (EFI_SPECIFICATION_VERSION >= 0x00020000)
+ //
+ // Close EfiStatusCodeRuntimeProtocol notify function
+ //
+ if (gEfiStatusCodeNotifyEvent != NULL) {
+ Status = gBS->CloseEvent (gEfiStatusCodeNotifyEvent);
+ ASSERT_EFI_ERROR (Status);
+ }
+#endif
+
return EFI_SUCCESS;
}
@@ -390,6 +494,9 @@ Returns:
--*/
{
EFI_STATUS Status;
+#if (EFI_SPECIFICATION_VERSION >= 0x00020000)
+ VOID *Registration;
+#endif
if (mRuntimeLibInitialized) {
return EFI_ALREADY_STARTED;
@@ -406,10 +513,26 @@ Returns:
ASSERT (mRT != NULL);
#if (EFI_SPECIFICATION_VERSION >= 0x00020000)
- Status = gBS->LocateProtocol (&gEfiStatusCodeRuntimeProtocolGuid, NULL, (VOID **)&gStatusCode);
- if (EFI_ERROR (Status)) {
- gStatusCode = NULL;
- }
+ //
+ // Register EFI_STATUS_CODE_PROTOCOL notify function
+ //
+ Status = gBS->CreateEvent (
+ EFI_EVENT_NOTIFY_SIGNAL,
+ EFI_TPL_CALLBACK,
+ OnStatusCodeInstall,
+ NULL,
+ &gEfiStatusCodeNotifyEvent
+ );
+ ASSERT_EFI_ERROR (Status);
+
+ Status = gBS->RegisterProtocolNotify (
+ &gEfiStatusCodeRuntimeProtocolGuid,
+ gEfiStatusCodeNotifyEvent,
+ &Registration
+ );
+ ASSERT_EFI_ERROR (Status);
+
+ gBS->SignalEvent (gEfiStatusCodeNotifyEvent);
#endif
Status = gBS->LocateProtocol (&gEfiCpuIoProtocolGuid, NULL, (VOID **) &gCpuIo);
@@ -761,8 +884,8 @@ EfiReportStatusCode (
IN EFI_STATUS_CODE_TYPE CodeType,
IN EFI_STATUS_CODE_VALUE Value,
IN UINT32 Instance,
- IN EFI_GUID * CallerId,
- IN EFI_STATUS_CODE_DATA * Data OPTIONAL
+ IN EFI_GUID *CallerId OPTIONAL,
+ IN EFI_STATUS_CODE_DATA *Data OPTIONAL
)
/*++
@@ -788,19 +911,30 @@ Returns:
--*/
{
- EFI_STATUS Status;
+ EFI_STATUS Status;
-#if (EFI_SPECIFICATION_VERSION >= 0x00020000)
- if (gStatusCode == NULL) {
+#if (EFI_SPECIFICATION_VERSION >= 0x00020000)
+ if (gReportStatusCode == NULL) {
+ //
+ // Because we've installed the protocol notification on EfiStatusCodeRuntimeProtocol,
+ // running here indicates that the StatusCode driver has not started yet.
+ //
if (EfiAtRuntime ()) {
+ //
+ // Running here only when StatusCode driver never starts.
+ //
return EFI_UNSUPPORTED;
}
- Status = gBS->LocateProtocol (&gEfiStatusCodeRuntimeProtocolGuid, NULL, (VOID **)&gStatusCode);
- if (EFI_ERROR (Status) || gStatusCode == NULL) {
+
+ //
+ // Try to get the PEI version of ReportStatusCode.
+ //
+ Status = GetPeiProtocol (&gEfiStatusCodeRuntimeProtocolGuid, (VOID **) &gReportStatusCode);
+ if (EFI_ERROR (Status)) {
return EFI_UNSUPPORTED;
}
}
- Status = gStatusCode->ReportStatusCode (CodeType, Value, Instance, CallerId, Data);
+ Status = gReportStatusCode (CodeType, Value, Instance, CallerId, Data);
#else
if (mRT == NULL) {
return EFI_UNSUPPORTED;
diff --git a/EdkCompatibilityPkg/Foundation/Library/Thunk16/Ia32/Fx.S b/EdkCompatibilityPkg/Foundation/Library/Thunk16/Ia32/Fx.S
index fcf7ff44d4..dd1cb289fc 100644
--- a/EdkCompatibilityPkg/Foundation/Library/Thunk16/Ia32/Fx.S
+++ b/EdkCompatibilityPkg/Foundation/Library/Thunk16/Ia32/Fx.S
@@ -1,6 +1,6 @@
#*****************************************************************************
#*
-#* Copyright (c) 2006, Intel Corporation. All rights reserved.<BR>
+#* Copyright (c) 2006 - 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
@@ -51,4 +51,26 @@ ASM_PFX(AsmFxRestore):
ret
#AsmFxRestore ENDP
+#------------------------------------------------------------------------------
+# UINTN
+# AsmGetEflags (
+# VOID
+# );
+#------------------------------------------------------------------------------
+ASM_PFX(AsmGetEflags):
+ pushfl
+ pop %eax
+ ret
+#AsmGetEflags ENDP
+#------------------------------------------------------------------------------
+# VOID
+# AsmSetEflags (
+# IN UINTN Eflags
+# );
+#------------------------------------------------------------------------------
+ASM_PFX(AsmSetEflags):
+ push 4(%esp)
+ popfl
+ ret
+#AsmSetEflags ENDP
diff --git a/EdkCompatibilityPkg/Foundation/Library/Thunk16/Ia32/Fx.asm b/EdkCompatibilityPkg/Foundation/Library/Thunk16/Ia32/Fx.asm
index e07b52a46c..7f3f275b37 100644
--- a/EdkCompatibilityPkg/Foundation/Library/Thunk16/Ia32/Fx.asm
+++ b/EdkCompatibilityPkg/Foundation/Library/Thunk16/Ia32/Fx.asm
@@ -1,6 +1,6 @@
;*****************************************************************************
;*
-;* Copyright (c) 2006, Intel Corporation. All rights reserved.<BR>
+;* Copyright (c) 2006 - 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
@@ -48,4 +48,28 @@ AsmFxRestore PROC
ret
AsmFxRestore ENDP
+;------------------------------------------------------------------------------
+; UINTN
+; AsmGetEflags (
+; VOID
+; );
+;------------------------------------------------------------------------------
+AsmGetEflags PROC
+ pushfd
+ pop eax
+ ret
+AsmGetEflags ENDP
+
+;------------------------------------------------------------------------------
+; VOID
+; AsmSetEflags (
+; IN UINTN Eflags
+; );
+;------------------------------------------------------------------------------
+AsmSetEflags PROC
+ push [esp + 4]
+ popfd
+ ret
+AsmSetEflags ENDP
+
END
diff --git a/EdkCompatibilityPkg/Foundation/Library/Thunk16/Ia32/Thunk16.S b/EdkCompatibilityPkg/Foundation/Library/Thunk16/Ia32/Thunk16.S
index d1feb9972e..55415d8703 100644
--- a/EdkCompatibilityPkg/Foundation/Library/Thunk16/Ia32/Thunk16.S
+++ b/EdkCompatibilityPkg/Foundation/Library/Thunk16/Ia32/Thunk16.S
@@ -1,6 +1,6 @@
#*****************************************************************************
#*
-#* Copyright (c) 2006 - 2009, Intel Corporation. All rights reserved.<BR>
+#* Copyright (c) 2006 - 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
@@ -72,6 +72,9 @@ ASM_PFX(Thunk16):
push $0xd
pop %ecx
rep movsl %ds:(%esi),%es:(%edi) #; copy context to 16-bit stack
+ #; copy eflags to stack frame
+ mov -12(%esi), %eax
+ mov %eax, -72(%edi)
pop %ebx #; ebx <- 16-bit stack offset
mov $L_Lable1,%eax
stos %eax,%es:(%edi)
@@ -140,20 +143,23 @@ ASM_PFX(RealMode):
popw %es
popw %fs
popw %gs
- addw $4, %sp # skip EFlags
- testw $1, 14(%esp) #(_STK16 ptr [esp + 8]).ThunkFlags, 1
+ sub 60, %esp
+ popfw
+ testw $1, 74(%esp) #(_STK16 ptr [esp + STACK_PARAM_SIZE + sizeof(IA32_REGS)]).ThunkFlags, 1
+
jz 1f
- pushf
+ pushf # push Flags when it's INT#
1:
pushw %cs
# push @FarCallRet - _Code16Addr
.byte 0x68 # push /iw
.word FarCallRet - _Code16Addr
jz 2f
- ljmp *6(%esp) #bugbug
+ ljmp *66(%esp) #[esp + 6 + STACK_PARAM_SIZE + sizeof(IA32_REGS) - 8]
2:
- ljmp *4(%esp) #bugbug
+ ljmp *64(%esp) #[esp + 4 + STACK_PARAM_SIZE + sizeof(IA32_REGS) - 8]
FarCallRet:
+ add 60, %esp
pushfl
pushw %gs
pushw %fs
diff --git a/EdkCompatibilityPkg/Foundation/Library/Thunk16/Ia32/Thunk16.asm b/EdkCompatibilityPkg/Foundation/Library/Thunk16/Ia32/Thunk16.asm
index 410347764a..76c1317469 100644
--- a/EdkCompatibilityPkg/Foundation/Library/Thunk16/Ia32/Thunk16.asm
+++ b/EdkCompatibilityPkg/Foundation/Library/Thunk16/Ia32/Thunk16.asm
@@ -1,6 +1,6 @@
;*****************************************************************************
;*
-;* Copyright (c) 2006 - 2007, Intel Corporation. All rights reserved.<BR>
+;* Copyright (c) 2006 - 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
@@ -55,6 +55,8 @@ _DATA ENDS
_TEXT SEGMENT FLAT "CODE" PARA
+STACK_PARAM_SIZE EQU 16
+
IA32_REGS STRUC 4t
_EDI DD ?
_ESI DD ?
@@ -99,6 +101,11 @@ __Thunk16 PROC USES ebp ebx esi edi ds es fs gs
push sizeof (IA32_REGS) / 4
pop ecx
rep movsd ; copy context to 16-bit stack
+
+ ; copy eflags to stack frame
+ mov eax, [esi - sizeof(IA32_REGS)]._EFLAGS
+ mov [edi - sizeof(IA32_REGS) - STACK_PARAM_SIZE - 4], eax
+
pop ebx ; ebx <- 16-bit stack offset
mov eax, offset @F ; return offset
stosd
@@ -158,20 +165,22 @@ RealMode PROC
pop es
pop fs
pop gs
- add sp, 4 ; skip EFlags
- test (_STK16 ptr [esp + 8]).ThunkFlags, 1
+ sub esp, (sizeof(IA32_REGS) - 12) + STACK_PARAM_SIZE + 4
+ popfd
+ test (_STK16 ptr [esp + STACK_PARAM_SIZE + sizeof(IA32_REGS)]).ThunkFlags, 1
jz @F
- pushf
+ pushf ; push Flags when it's INT#
@@:
push cs
; push @FarCallRet - _Code16Addr
DB 68h ; push /iw
DW @FarCallRet - _Code16Addr
jz @F
- jmp fword ptr [esp + 6]
+ jmp fword ptr [esp + 6 + STACK_PARAM_SIZE + sizeof(IA32_REGS) - 8]
@@:
- jmp fword ptr [esp + 4]
+ jmp fword ptr [esp + 4 + STACK_PARAM_SIZE + sizeof(IA32_REGS) - 8]
@FarCallRet:
+ add esp, (sizeof(IA32_REGS) - 12) + STACK_PARAM_SIZE + 4
pushfd
push gs
push fs
diff --git a/EdkCompatibilityPkg/Foundation/Library/Thunk16/Thunk16Lib.h b/EdkCompatibilityPkg/Foundation/Library/Thunk16/Thunk16Lib.h
index 8a865616c1..6c16e25e4b 100644
--- a/EdkCompatibilityPkg/Foundation/Library/Thunk16/Thunk16Lib.h
+++ b/EdkCompatibilityPkg/Foundation/Library/Thunk16/Thunk16Lib.h
@@ -1,6 +1,6 @@
/*++
-Copyright (c) 2006, Intel Corporation. All rights reserved.<BR>
+Copyright (c) 2006 - 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
@@ -237,6 +237,13 @@ Returns:
--*/
;
+BOOLEAN
+AsmThunk16SetUserStack (
+ IN THUNK_CONTEXT *ThunkContext,
+ IN VOID *Stack,
+ IN UINTN StackSize
+ );
+
VOID
EFIAPI
AsmThunk16Destroy (
diff --git a/EdkCompatibilityPkg/Foundation/Library/Thunk16/X64/Fx.S b/EdkCompatibilityPkg/Foundation/Library/Thunk16/X64/Fx.S
index 30c76974e2..c0807bc523 100644
--- a/EdkCompatibilityPkg/Foundation/Library/Thunk16/X64/Fx.S
+++ b/EdkCompatibilityPkg/Foundation/Library/Thunk16/X64/Fx.S
@@ -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
+
+#------------------------------------------------------------------------------
+# UINTN
+# AsmGetEflags (
+# VOID
+# );
+#------------------------------------------------------------------------------
+ASM_PFX(AsmGetEflags):
+ pushfq
+ popq %rax
+ ret
+#AsmGetEflags ENDP
+
+#------------------------------------------------------------------------------
+# VOID
+# AsmSetEflags (
+# IN UINTN Eflags
+# );
+#------------------------------------------------------------------------------
+ASM_PFX(AsmSetEflags):
+ pushq %rcx
+ popfq
+ ret
+#AsmSetEflags ENDP
diff --git a/EdkCompatibilityPkg/Foundation/Library/Thunk16/X64/Fx.asm b/EdkCompatibilityPkg/Foundation/Library/Thunk16/X64/Fx.asm
index f9c2e4d57b..ab4a97f23a 100644
--- a/EdkCompatibilityPkg/Foundation/Library/Thunk16/X64/Fx.asm
+++ b/EdkCompatibilityPkg/Foundation/Library/Thunk16/X64/Fx.asm
@@ -1,6 +1,6 @@
;*****************************************************************************
;*
-;* Copyright (c) 2006, Intel Corporation. All rights reserved.<BR>
+;* Copyright (c) 2006 - 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
@@ -43,4 +43,28 @@ AsmFxRestore PROC
ret
AsmFxRestore ENDP
+;------------------------------------------------------------------------------
+; UINTN
+; AsmGetEflags (
+; VOID
+; );
+;------------------------------------------------------------------------------
+AsmGetEflags PROC
+ pushfq
+ pop rax
+ ret
+AsmGetEflags ENDP
+
+;------------------------------------------------------------------------------
+; VOID
+; AsmSetEflags (
+; IN UINTN Eflags
+; );
+;------------------------------------------------------------------------------
+AsmSetEflags PROC
+ push rcx
+ popfq
+ ret
+AsmSetEflags ENDP
+
END
diff --git a/EdkCompatibilityPkg/Foundation/Library/Thunk16/X64/Thunk16.S b/EdkCompatibilityPkg/Foundation/Library/Thunk16/X64/Thunk16.S
index 888801b1ab..10f3a34c19 100644
--- a/EdkCompatibilityPkg/Foundation/Library/Thunk16/X64/Thunk16.S
+++ b/EdkCompatibilityPkg/Foundation/Library/Thunk16/X64/Thunk16.S
@@ -1,6 +1,6 @@
#*****************************************************************************
#*
-#* Copyright (c) 2008 - 2009, 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
@@ -106,6 +106,9 @@ ASM_PFX(Thunk16):
pushq $0xe #push sizeof (IA32_REGS) / 4
pop %rcx
rep movsl %ds:(%rsi),%es:(%rdi)
+ #; copy eflags to stack frame
+ mov -16(%rsi), %rax
+ mov %rax, -80(%rsi)
pop %rbx #rbx <- 16-bit stack offset
lea Label,%eax #42 <_Thunk16+0x42>
stos %eax,%es:(%rdi)
@@ -183,27 +186,30 @@ ASM_PFX(RealMode):
.byte 0x07 #pop es
popq %fs
popq %gs
- add $0x8,%esp #skip RFLAGS
- .byte 0x67 #test [esp + 0eh], 1
+ sub 64, %esp
+ .byte 0x66, 0x9d #popfd
+ add $0x4,%esp #skip high part of RFLAGS
+ .byte 0x67 #; test (_STK16 ptr [esp + STACK_PARAM_SIZE + sizeof(IA32_REGS)]).ThunkFlags, 1
.byte 0xf7
.byte 0x44
.byte 0x24
- .byte 0x0e
+ .byte 0x4e
.byte 0x01
.byte 0x00
jz 1f
- pushfq #pushf, actually
+ pushfq #pushf, actually, when it's INT#
1:
.byte 0x0e #push cs
.byte 0x68 #push /iw
.word FarCallRet - _Code16Addr
jz 2f
.byte 0x66
- ljmp *6(%esp)
+ ljmp *70(%esp)
2:
.byte 0x66
- ljmp *4(%esp)
+ ljmp *68(%esp)
FarCallRet:
+ add 64, %esp
.byte 0x66
push $0x00 #push a dword of zero
.byte 0x66
diff --git a/EdkCompatibilityPkg/Foundation/Library/Thunk16/X64/Thunk16.asm b/EdkCompatibilityPkg/Foundation/Library/Thunk16/X64/Thunk16.asm
index b6a8f86879..0638d5faa8 100644
--- a/EdkCompatibilityPkg/Foundation/Library/Thunk16/X64/Thunk16.asm
+++ b/EdkCompatibilityPkg/Foundation/Library/Thunk16/X64/Thunk16.asm
@@ -1,6 +1,6 @@
;*****************************************************************************
;*
-;* Copyright (c) 2006, Intel Corporation. All rights reserved.<BR>
+;* Copyright (c) 2006 - 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
@@ -49,6 +49,8 @@ _16Gdtr LABEL FWORD
.code
+STACK_PARAM_SIZE EQU 16
+
IA32_REGS STRUC 4t
_EDI DD ?
_ESI DD ?
@@ -98,6 +100,11 @@ _Thunk16 PROC USES rbp rbx rsi rdi r12 r13 r14 r15
push sizeof (IA32_REGS) / 4
pop rcx
rep movsd
+
+ ; copy eflags to stack frame
+ mov rax, (IA32_REGS ptr [rsi - sizeof(IA32_REGS)])._RFLAGS
+ mov [rdi - sizeof(IA32_REGS) - STACK_PARAM_SIZE - 8], rax
+
pop rbx ; rbx <- 16-bit stack offset
lea eax, @F ; return offset
stosd
@@ -165,22 +172,27 @@ RealMode PROC
DB 7 ; pop es
pop fs
pop gs
+ sub esp, (sizeof(IA32_REGS) - 16) + STACK_PARAM_SIZE + 8
- add esp, 8 ; skip RFLAGS
- DB 67h, 0f7h, 44h, 24h, 0eh, 1, 0 ; test [esp + 0eh], 1
+ DB 66h, 9Dh ; popfd
+ add esp, 4 ; skip high part of RFLAGS
+ DB 67h, 0f7h, 44h, 24h ; test (_STK16 ptr [esp + STACK_PARAM_SIZE + sizeof(IA32_REGS)]).ThunkFlags, 1
+ DB (STACK_PARAM_SIZE + sizeof(IA32_REGS) + 6)
+ DB 1, 0
jz @F
- pushfq ; pushf, actually
+ pushfq ; pushf, actually, when it's INT#
@@:
DB 0eh ; push cs
DB 68h ; push /iw
DW @FarCallRet - _Code16Addr
jz @F
DB 66h
- jmp fword ptr [esp + 6]
+ jmp fword ptr [esp + 6 + STACK_PARAM_SIZE + sizeof(IA32_REGS) - 8]
@@:
DB 66h
- jmp fword ptr [esp + 4]
+ jmp fword ptr [esp + 4 + STACK_PARAM_SIZE + sizeof(IA32_REGS) - 8]
@FarCallRet:
+ add esp, (sizeof(IA32_REGS) - 16) + STACK_PARAM_SIZE + 8
DB 66h
push 0 ; push a dword of zero
pushf ; pushfd, actually
diff --git a/EdkCompatibilityPkg/Foundation/Library/Thunk16/X86Thunk.c b/EdkCompatibilityPkg/Foundation/Library/Thunk16/X86Thunk.c
index c9aafd36aa..ed24663b48 100644
--- a/EdkCompatibilityPkg/Foundation/Library/Thunk16/X86Thunk.c
+++ b/EdkCompatibilityPkg/Foundation/Library/Thunk16/X86Thunk.c
@@ -1,6 +1,6 @@
/*++
-Copyright (c) 2006, Intel Corporation. All rights reserved.<BR>
+Copyright (c) 2006 - 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
@@ -53,6 +53,18 @@ AsmFxSave (
OUT IA32_FX_BUFFER *Buffer
);
+UINTN
+EFIAPI
+AsmGetEflags (
+ VOID
+ );
+
+VOID
+EFIAPI
+AsmSetEflags (
+ IN UINTN Eflags
+ );
+
//
// Implementation
//
@@ -98,6 +110,7 @@ Returns:
{
IA32_FX_BUFFER *FpSavedState;
UINT8 FpBuffer[sizeof (*FpSavedState) + 0x10];
+ UINTN Eflags;
FpSavedState = (IA32_FX_BUFFER*)(((UINTN)FpBuffer + 0xf) & ~0xf);
@@ -110,6 +123,8 @@ Returns:
AsmFxSave (FpSavedState);
}
+ Eflags = AsmGetEflags ();
+
EfiCommonLibCopyMem (
RegisterSet,
_Thunk16 (
@@ -120,6 +135,8 @@ Returns:
sizeof (*RegisterSet)
);
+ AsmSetEflags (Eflags);
+
if (ThunkFlags & THUNK_SAVE_FP_STATE) {
AsmFxRestore (FpSavedState);
}
@@ -200,6 +217,67 @@ Returns:
return ThunkContext;
}
+#pragma pack (1)
+
+typedef struct {
+ UINT32 EDI;
+ UINT32 ESI;
+ UINT32 EBP;
+ UINT32 ESP;
+ UINT32 EBX;
+ UINT32 EDX;
+ UINT32 ECX;
+ UINT32 EAX;
+ UINT16 DS;
+ UINT16 ES;
+ UINT16 FS;
+ UINT16 GS;
+ UINTN EFLAGS;
+ UINT32 EIP;
+ UINT16 CS;
+ UINT16 SS;
+} IA32_REGS;
+
+typedef struct {
+ UINT16 Limit;
+ UINT32 Base;
+} IA32_DESC;
+
+typedef struct {
+ UINT32 RetEip;
+ UINT16 RetCs;
+ UINT16 ThunkFlags;
+#ifdef EFI32
+ UINT32 SavedEsp;
+ UINT16 SavedSs;
+#endif
+ IA32_DESC SavedGdtr;
+#ifdef EFIX64
+ UINT16 Resvd1;
+#endif
+ UINT32 SavedCr0;
+ UINT32 SavedCr4;
+} _STK16;
+#pragma pack ()
+
+#define STACK_PARAM_SIZE 16
+
+BOOLEAN
+AsmThunk16SetUserStack (
+ IN THUNK_CONTEXT *ThunkContext,
+ IN VOID *Stack,
+ IN UINTN StackSize
+ )
+{
+ if (StackSize > STACK_PARAM_SIZE) {
+ return FALSE;
+ }
+
+ EfiCommonLibCopyMem ((VOID *)(UINTN)(ThunkContext->DefaultStack - sizeof(_STK16) - sizeof(IA32_REGS) - STACK_PARAM_SIZE), Stack, StackSize);
+
+ return TRUE;
+}
+
VOID
EFIAPI
AsmThunk16Destroy (
@@ -253,12 +331,8 @@ Arguments:
set on input, otherwise ignored.
EFlages is ignored on input.
On output, values of CS, EIP, SS and ESP should be ignored.
- ThunkFlags - 2 flags have currently been defined, THUNK_SAVE_FP_STATE and
- THUNK_USER_STACK.
- THUNK_SAVE_FP_STATE - FPU state would be saved/restored
- before/after calling real mode code.
- THUNK_USER_STACK - The stack specified by SS:ESP would be
- used instead of the default stack.
+ ThunkFlags - THUNK_USER_STACK: The stack specified by SS:ESP would be
+ used instead of the default stack.
Returns:
@@ -298,12 +372,8 @@ Arguments:
set on input, otherwise ignored.
EFlages is ignored on input.
On output, values of CS, EIP, SS and ESP should be ignored.
- ThunkFlags - 2 flags have currently been defined, THUNK_SAVE_FP_STATE and
- THUNK_USER_STACK.
- THUNK_SAVE_FP_STATE - FPU state would be saved/restored
- before/after calling real mode code.
- THUNK_USER_STACK - The stack specified by SS:ESP would be
- used instead of the default stack.
+ ThunkFlags - THUNK_USER_STACK: The stack specified by SS:ESP would be
+ used instead of the default stack.
Returns:
diff --git a/EdkCompatibilityPkg/Foundation/Protocol/ConsoleControl/ConsoleControl.h b/EdkCompatibilityPkg/Foundation/Protocol/ConsoleControl/ConsoleControl.h
index f6f2c44fb7..c52ef47f73 100644
--- a/EdkCompatibilityPkg/Foundation/Protocol/ConsoleControl/ConsoleControl.h
+++ b/EdkCompatibilityPkg/Foundation/Protocol/ConsoleControl/ConsoleControl.h
@@ -1,6 +1,6 @@
/*++
-Copyright (c) 2004 - 2006, 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
@@ -68,7 +68,7 @@ typedef
EFI_STATUS
(EFIAPI *EFI_CONSOLE_CONTROL_PROTOCOL_SET_MODE) (
IN EFI_CONSOLE_CONTROL_PROTOCOL *This,
- OUT EFI_CONSOLE_CONTROL_SCREEN_MODE Mode
+ IN EFI_CONSOLE_CONTROL_SCREEN_MODE Mode
)
/*++
diff --git a/EdkCompatibilityPkg/Foundation/Protocol/NicIp4Config/NicIp4Config.h b/EdkCompatibilityPkg/Foundation/Protocol/NicIp4Config/NicIp4Config.h
index c9c96f762c..56e03e2266 100644
--- a/EdkCompatibilityPkg/Foundation/Protocol/NicIp4Config/NicIp4Config.h
+++ b/EdkCompatibilityPkg/Foundation/Protocol/NicIp4Config/NicIp4Config.h
@@ -1,6 +1,6 @@
/*++
-Copyright (c) 2006, Intel Corporation. All rights reserved.<BR>
+Copyright (c) 2006 - 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
@@ -42,7 +42,7 @@ enum {
IP4_CONFIG_SOURCE_MAX,
IP4_NIC_NAME_LENGTH = 64,
- MAX_IP4_CONFIG_IN_VARIABLE = 16
+ MAX_IP4_CONFIG_IN_VARIABLE = 128
};
//
diff --git a/EdkCompatibilityPkg/Foundation/Protocol/TcgService/TcgService.h b/EdkCompatibilityPkg/Foundation/Protocol/TcgService/TcgService.h
index 84d244555e..e0290c0b0a 100644
--- a/EdkCompatibilityPkg/Foundation/Protocol/TcgService/TcgService.h
+++ b/EdkCompatibilityPkg/Foundation/Protocol/TcgService/TcgService.h
@@ -1,6 +1,6 @@
/*++
-Copyright (c) 2006, Intel Corporation. All rights reserved.<BR>
+Copyright (c) 2006 - 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
@@ -111,8 +111,8 @@ typedef
EFI_STATUS
(EFIAPI *EFI_TCG_PASS_THROUGH_TO_TPM) (
IN EFI_TCG_PROTOCOL *This,
- IN UINT32 TpmInputParamterBlockSize,
- IN UINT8 *TpmInputParamterBlock,
+ IN UINT32 TpmInputParameterBlockSize,
+ IN UINT8 *TpmInputParameterBlock,
IN UINT32 TpmOutputParameterBlockSize,
IN UINT8 *TpmOutputParameterBlock
);
@@ -121,7 +121,7 @@ typedef
EFI_STATUS
(EFIAPI *EFI_TCG_HASH_LOG_EXTEND_EVENT) (
IN EFI_TCG_PROTOCOL *This,
- IN UINT8 *HashData,
+ IN EFI_PHYSICAL_ADDRESS HashData,
IN UINT64 HashDataLen,
IN TCG_ALGORITHM_ID AlgorithmId,
IN OUT TCG_PCR_EVENT *TCGLogData,
@@ -160,9 +160,16 @@ EFI_STATUS
IN CHAR8 *ActionString
);
-typedef struct tdEFI_TCG_PLATFORM_PROTOCOL {
+typedef
+EFI_STATUS
+(EFIAPI *EFI_TCG_MEASURE_GPT_TABLE) (
+ IN EFI_DEVICE_PATH_PROTOCOL *DevicePath
+ );
+
+typedef struct _EFI_TCG_PLATFORM_PROTOCOL {
EFI_TCG_MEASURE_PE_IMAGE MeasurePeImage;
EFI_TCG_MEASURE_ACTION MeasureAction;
+ EFI_TCG_MEASURE_GPT_TABLE MeasureGptTable;
} EFI_TCG_PLATFORM_PROTOCOL;
extern EFI_GUID gEfiTcgPlatformProtocolGuid;
diff --git a/EdkCompatibilityPkg/Sample/CommonTools.env b/EdkCompatibilityPkg/Sample/CommonTools.env
index cd7d4c2ea7..567e746c83 100644
--- a/EdkCompatibilityPkg/Sample/CommonTools.env
+++ b/EdkCompatibilityPkg/Sample/CommonTools.env
@@ -1,6 +1,6 @@
#/*++
#
-# Copyright (c) 2004 - 2007, 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
@@ -83,6 +83,7 @@ GENFVIMAGE = $(EDK_TOOLS_OUTPUT)\GenFvImage
GENSECTION = $(EDK_TOOLS_OUTPUT)\GenSection
GENTEIMAGE = $(EDK_TOOLS_OUTPUT)\GenTEImage
GUIDCHK = $(EDK_TOOLS_OUTPUT)\GuidChk
+HIIPACK = $(EDK_TOOLS_OUTPUT)\HiiPack
MAKEDEPS = $(EDK_TOOLS_OUTPUT)\MakeDeps
PROCESSDSC = $(EDK_TOOLS_OUTPUT)\ProcessDsc
STRGATHER = $(EDK_TOOLS_OUTPUT)\StrGather
@@ -188,6 +189,7 @@ ASMLINK = $(EDK_TOOLS_BIN)\Ia32\$(EFI_ASSEMBLER_NAME)\binr\link
!ENDIF
BSCMAKE = bscmake
+RC = rc
!IF "$(EFI_SYMBOLIC_DEBUG)" == "YES"
ASM_ARCH_FLAGS = $(ASM_ARCH_FLAGS) /Zi /DDEBUG
@@ -274,6 +276,7 @@ ASMLINK = $(EDK_TOOLS_BIN)\Ia32\$(EFI_ASSEMBLER_NAME)\binr\link
!ENDIF
BSCMAKE = bscmake
+RC = rc
!IF "$(EFI_SYMBOLIC_DEBUG)" == "YES"
ASM_ARCH_FLAGS = $(ASM_ARCH_FLAGS) /Zi /DDEBUG
@@ -381,6 +384,7 @@ ASMLINK = $(EDK_TOOLS_BIN)\Ipf\$(EFI_ASSEMBLER_NAME)\link
!ENDIF
BSCMAKE = bscmake
+RC = rc
!IF "$(EFI_SYMBOLIC_DEBUG)" == "YES"
C_STD_FLAGS = $(C_STD_FLAGS) /Zi /Gm /Fd$(DEST_DIR)\$(BASE_NAME)Obj
@@ -531,8 +535,10 @@ EBC_CC = $(EBC_TOOLS_PATH)\Bin\Iec
EBC_LINK = $(EBC_TOOLS_PATH)\Bin\Link
EBC_LIB = $(EBC_TOOLS_PATH)\Bin\Link /lib
+RC = rc
+
!IF "$(EFI_SYMBOLIC_DEBUG)" == "YES"
-EBC_C_STD_FLAGS = $(EBC_C_STD_FLAGS) /Zd /Zi
+EBC_C_STD_FLAGS = $(EBC_C_STD_FLAGS) /Zi
EBC_LINK_STD_FLAGS = $(EBC_LINK_STD_FLAGS) /DEBUG
!ENDIF
@@ -579,6 +585,15 @@ VFRCOMPILE_FLAGS = $(VFRCOMPILE_FLAGS) -ppflag "$(VERSION_FLAGS)"
ASM_STD_FLAGS = $(ASM_STD_FLAGS) $(VERSION_FLAGS)
!ENDIF
+!IF "$(TOOLCHAIN)" != "TOOLCHAIN_MSVC"
+BUILD_STRING_FLAGS = /D EFI_BUILD_VERSION="L\"$(EDK_BUILD_VERSION)\"" /D EFI_FIRMWARE_VENDOR="L\"TianoCore.org\""
+!ELSE
+BUILD_STRING_FLAGS = /D UTILITY_BUILD="\"$(EDK_BUILD_VERSION)\"" /D UTILITY_VENDOR="\"TianoCore.org\""
+!ENDIF
+
+C_STD_FLAGS = $(C_STD_FLAGS) $(BUILD_STRING_FLAGS)
+EBC_C_STD_FLAGS = $(EBC_C_STD_FLAGS) $(BUILD_STRING_FLAGS)
+
!IF "$(EFI_DEBUG)" == "YES"
FEATURE_FLAGS = $(FEATURE_FLAGS) /D EFI_DEBUG
!ENDIF
@@ -611,6 +626,10 @@ FEATURE_FLAGS = $(FEATURE_FLAGS) /D EFI_DXE_PERFORMANCE
FEATURE_FLAGS = $(FEATURE_FLAGS) /D EFI_S3_RESUME
!ENDIF
+!IF "$(EFI_NO_CSM_SUPPORT)" == "YES"
+FEATURE_FLAGS = $(FEATURE_FLAGS) /D EFI_NO_CSM_SUPPORT
+!ENDIF
+
!IF "$(EFI_SIZE_REDUCTION_APPLIED)" == "YES"
FEATURE_FLAGS = $(FEATURE_FLAGS) /D EFI_SIZE_REDUCTION_APPLIED
!ENDIF
diff --git a/EdkCompatibilityPkg/Sample/Platform/Common.dsc b/EdkCompatibilityPkg/Sample/Platform/Common.dsc
index c077e81c9e..be582eec68 100644
--- a/EdkCompatibilityPkg/Sample/Platform/Common.dsc
+++ b/EdkCompatibilityPkg/Sample/Platform/Common.dsc
@@ -1,6 +1,6 @@
#/*++
#
-# Copyright (c) 2004 - 2007, 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
@@ -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
# "APRIORI=" on the component lines in components section in the DSC file.
#
-$(DEST_DIR)\$(BASE_NAME).bin : $(SOURCE_FILE_NAME)
+$(DEST_DIR)\$(BASE_NAME).bin : $(SOURCE_FILE_NAME) $(INF_FILENAME)
$(GENAPRIORI) -v -f $(SOURCE_FILE_NAME) -o $(DEST_DIR)\$(BASE_NAME).bin
$(DEST_DIR)\$(BASE_NAME).sec : $(DEST_DIR)\$(BASE_NAME).bin
@@ -299,34 +299,29 @@ clean :
[Build.Ia32.Makefile,Build.Ipf.Makefile,Build.Ebc.Makefile,Build.x64.Makefile]
#
-# Copy the makefile directly from the source directory, then make it
-# writable so we can copy over it later if we try to.
+# Set some required macros
#
-$(DEST_DIR)\makefile.new : $(SOURCE_DIR)\makefile.new
- copy $(SOURCE_DIR)\makefile.new $(DEST_DIR)\makefile.new
- attrib -r $(DEST_DIR)\makefile.new
+MAKEFILE_MACROS = SOURCE_DIR=$(SOURCE_DIR) \
+ BUILD_DIR=$(BUILD_DIR) \
+ FILE_GUID=$(FILE_GUID) \
+ DEST_DIR=$(DEST_DIR) \
+ PROCESSOR=$(PROCESSOR) \
+ TOOLCHAIN=TOOLCHAIN_$(PROCESSOR) \
+ BASE_NAME=$(BASE_NAME) \
+ PACKAGE_FILENAME=$(PACKAGE_FILENAME)
#
-# Make the all target, set some required macros.
+# Just call the makefile from the source directory, passing in some
+# useful info.
#
-call_makefile :
- $(MAKE) -f $(DEST_DIR)\makefile.new all \
- SOURCE_DIR=$(SOURCE_DIR) \
- BUILD_DIR=$(BUILD_DIR) \
- FILE_GUID=$(FILE_GUID) \
- DEST_DIR=$(DEST_DIR) \
- PROCESSOR=$(PROCESSOR) \
- TOOLCHAIN=TOOLCHAIN_$(PROCESSOR) \
- BASE_NAME=$(BASE_NAME) \
- PACKAGE_FILENAME=$(PACKAGE_FILENAME)
-
-all : $(DEST_DIR)\makefile.new call_makefile
+all :
+ $(MAKE) -f $(SOURCE_DIR)\makefile.new all $(MAKEFILE_MACROS)
#
# Remove the generated temp and final files for this modules.
#
clean :
- @- $(MAKE) -f $(DEST_DIR)\makefile.new clean > NUL 2>&1
+ @- $(MAKE) -f $(SOURCE_DIR)\makefile.new clean $(MAKEFILE_MACROS) > NUL 2>&1
!IF ("$(FILE_GUID)" != "")
@if exist $(BIN_DIR)\$(FILE_GUID)-$(BASE_NAME).* del $(BIN_DIR)\$(FILE_GUID)-$(BASE_NAME).*
!ENDIF
@@ -345,27 +340,31 @@ clean :
[Build.Ia32.Custom_Makefile,Build.Ipf.Custom_Makefile,Build.Ebc.Custom_Makefile,Build.x64.Custom_Makefile]
#
+# Set some required macros
+#
+MAKEFILE_MACROS = SOURCE_DIR=$(SOURCE_DIR) \
+ BUILD_DIR=$(BUILD_DIR) \
+ DEST_DIR=$(DEST_DIR) \
+ FILE_GUID=$(FILE_GUID) \
+ PROCESSOR=$(PROCESSOR) \
+ TOOLCHAIN=TOOLCHAIN_$(PROCESSOR) \
+ BASE_NAME=$(BASE_NAME) \
+ PLATFORM=$(PLATFORM) \
+ SOURCE_FV=$(SOURCE_FV) \
+ PACKAGE_FILENAME=$(PACKAGE_FILENAME)
+
+#
# Just call the makefile from the source directory, passing in some
# useful info.
#
all :
- $(MAKE) -f $(SOURCE_DIR)\makefile all \
- SOURCE_DIR=$(SOURCE_DIR) \
- BUILD_DIR=$(BUILD_DIR) \
- DEST_DIR=$(DEST_DIR) \
- FILE_GUID=$(FILE_GUID) \
- PROCESSOR=$(PROCESSOR) \
- TOOLCHAIN=TOOLCHAIN_$(PROCESSOR) \
- BASE_NAME=$(BASE_NAME) \
- PLATFORM=$(PLATFORM) \
- SOURCE_FV=$(SOURCE_FV) \
- PACKAGE_FILENAME=$(PACKAGE_FILENAME)
+ $(MAKE) -f $(SOURCE_DIR)\makefile all $(MAKEFILE_MACROS)
#
# Remove the generated temp and final files for this modules.
#
clean :
- @- $(MAKE) -f $(SOURCE_DIR)\makefile clean > NUL 2>&1
+ @- $(MAKE) -f $(SOURCE_DIR)\makefile clean $(MAKEFILE_MACROS) > NUL 2>&1
!IF ("$(FILE_GUID)" != "")
@if exist $(BIN_DIR)\$(FILE_GUID)-$(BASE_NAME).* del $(BIN_DIR)\$(FILE_GUID)-$(BASE_NAME).*
!ENDIF
@@ -496,9 +495,29 @@ clean :
!IF "$(LOCALIZE)" == "YES"
-!IF "$(EFI_GENERATE_HII_EXPORT)" == "YES"
-STRGATHER_FLAGS = $(STRGATHER_FLAGS) -hpk $(DEST_DIR)\$(BASE_NAME)Strings.hpk
+!IF (("$(EFI_GENERATE_HII_RESOURCE)" == "YES") && ("$(EFI_SPECIFICATION_VERSION)" >= "0x0002000A"))
+#
+# This will generate HII resource section in PE/COFF image.
+#
+# Note: when HII package list is built into resource section, Driver no longer
+# refer to C array generated by VfrCompiler ($(FILE_NAME)Bin) and StrGather
+# ($(BASE_NAME)Strings); while in current build rule, those C array objects
+# will still be linked with the Driver, so please turn on link flag "/OPT:REF"
+# to minimize the code size.
+#
+HII_PACK_FILES = $(HII_PACK_FILES) $(DEST_DIR)\$(BASE_NAME)Strings.hpk
+LOCALIZE_TARGETS = $(LOCALIZE_TARGETS) $(DEST_DIR)\$(BASE_NAME).res
+LINK_FLAGS_DLL = $(LINK_FLAGS_DLL) $(DEST_DIR)\$(BASE_NAME).res
+
+$(DEST_DIR)\$(BASE_NAME).rc : $(HII_PACK_FILES)
+ $(HIIPACK) -g $(FILE_GUID) $(HII_PACK_FILES) -rc $(DEST_DIR)\$(BASE_NAME).rc -hii $(DEST_DIR)\$(BASE_NAME).hii
+
+$(DEST_DIR)\$(BASE_NAME).res : $(DEST_DIR)\$(BASE_NAME).rc
+ $(RC) /fo $(DEST_DIR)\$(BASE_NAME).res $(DEST_DIR)\$(BASE_NAME).rc
+!ENDIF
+
+!IF (("$(EFI_GENERATE_HII_EXPORT)" == "YES") && ("$(EFI_SPECIFICATION_VERSION)" < "0x0002000A"))
#
# There will be one HII pack containing all the strings. Add that file
# to the list of HII pack files we'll use to create our final HII export file.
@@ -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
!ENDIF
+!IF ("$(EFI_SPECIFICATION_VERSION)" >= "0x0002000A")
+#
+# Note: currently -ppflag option is only available for UefiStrGather
+# Note: /GS- will cause warning for preprocess, so filter it out from STRGATHER_PPFLAG
+#
+STRGATHER_PPFLAG = $(C_FLAGS: /GS-=)
+STRGATHER_FLAGS = $(STRGATHER_FLAGS) -ppflag "$(STRGATHER_PPFLAG)" -oh $(DEST_DIR)\$(BASE_NAME)StrDefs.h
+!ENDIF
+
$(DEST_DIR)\$(BASE_NAME).sdb : $(SDB_FILES) $(SOURCE_FILES)
$(STRGATHER) -scan -vdbr $(STRGATHER_FLAGS) -od $(DEST_DIR)\$(BASE_NAME).sdb \
-skipext .uni -skipext .h $(SOURCE_FILES)
@@ -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)
$(CC) $(C_FLAGS) $(DEST_DIR)\$(BASE_NAME)Strings.c
-LOCALIZE_TARGETS = $(LOCALIZE_TARGETS) $(DEST_DIR)\$(BASE_NAME)StrDefs.h
+LOCALIZE_TARGETS = $(DEST_DIR)\$(BASE_NAME)StrDefs.h $(LOCALIZE_TARGETS)
!ENDIF
@@ -677,7 +705,7 @@ $(TARGET_VER) : $(INF_FILENAME)
$(GENSECTION) -O $(TARGET_VER) -S EFI_SECTION_VERSION -V $(BUILD_NUMBER)
!ENDIF
!ELSE
-$(TARGET_VER) :
+$(TARGET_VER) : $(INF_FILENAME)
echo.>$(TARGET_VER)
type $(TARGET_VER)>$(TARGET_VER)
!ENDIF
@@ -741,7 +769,7 @@ $(TARGET_DPX) : $(DPX_SOURCE_FILE) $(INF_FILENAME)
!ERROR Dependency expression source file "$(DPX_SOURCE_FILE)" does not exist.
!ENDIF
!ELSE
-$(TARGET_DPX) :
+$(TARGET_DPX) : $(INF_FILENAME)
echo. > $(TARGET_DPX)
type $(TARGET_DPX) > $(TARGET_DPX)
!ENDIF
@@ -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.
!ENDIF
!ELSE
-$(TARGET_DXE_DPX) :
+$(TARGET_DXE_DPX) : $(INF_FILENAME)
echo. > $(TARGET_DXE_DPX)
type $(TARGET_DXE_DPX) > $(TARGET_DXE_DPX)
!ENDIF
@@ -963,7 +991,7 @@ $(TARGET_VER) : $(INF_FILENAME)
$(GENSECTION) -O $(TARGET_VER) -S EFI_SECTION_VERSION -V $(BUILD_NUMBER)
!ENDIF
!ELSE
-$(TARGET_VER) :
+$(TARGET_VER) : $(INF_FILENAME)
echo.>$(TARGET_VER)
type $(TARGET_VER)>$(TARGET_VER)
!ENDIF
@@ -1027,7 +1055,7 @@ $(TARGET_DPX) : $(DPX_SOURCE_FILE) $(INF_FILENAME)
!ERROR Dependency expression source file "$(DPX_SOURCE_FILE)" does not exist.
!ENDIF
!ELSE
-$(TARGET_DPX) :
+$(TARGET_DPX) : $(INF_FILENAME)
echo. > $(TARGET_DPX)
type $(TARGET_DPX) > $(TARGET_DPX)
!ENDIF
@@ -1069,9 +1097,29 @@ LIBS = $(LIBS) $(EBC_TOOLS_PATH)\lib\EbcLib.lib
!IF "$(LOCALIZE)" == "YES"
-!IF "$(EFI_GENERATE_HII_EXPORT)" == "YES"
-STRGATHER_FLAGS = $(STRGATHER_FLAGS) -hpk $(DEST_DIR)\$(BASE_NAME)Strings.hpk
+!IF (("$(EFI_GENERATE_HII_RESOURCE)" == "YES") && ("$(EFI_SPECIFICATION_VERSION)" >= "0x0002000A"))
+#
+# This will generate HII resource section in PE/COFF image.
+#
+# Note: when HII package list is built into resource section, Driver no longer
+# refer to C array generated by VfrCompiler ($(FILE_NAME)Bin) and StrGather
+# ($(BASE_NAME)Strings); while in current build rule, those C array objects
+# will still be linked with the Driver, so please turn on link flag "/OPT:REF"
+# to minimize the code size.
+#
+HII_PACK_FILES = $(HII_PACK_FILES) $(DEST_DIR)\$(BASE_NAME)Strings.hpk
+LOCALIZE_TARGETS = $(LOCALIZE_TARGETS) $(DEST_DIR)\$(BASE_NAME).res
+OBJECTS = $(OBJECTS) $(DEST_DIR)\$(BASE_NAME).res
+
+$(DEST_DIR)\$(BASE_NAME).rc : $(HII_PACK_FILES)
+ $(HIIPACK) -g $(FILE_GUID) $(HII_PACK_FILES) -rc $(DEST_DIR)\$(BASE_NAME).rc -hii $(DEST_DIR)\$(BASE_NAME).hii
+$(DEST_DIR)\$(BASE_NAME).res : $(DEST_DIR)\$(BASE_NAME).rc
+ $(RC) /fo $(DEST_DIR)\$(BASE_NAME).res $(DEST_DIR)\$(BASE_NAME).rc
+
+!ENDIF
+
+!IF (("$(EFI_GENERATE_HII_EXPORT)" == "YES") && ("$(EFI_SPECIFICATION_VERSION)" < "0x0002000A"))
#
# There will be one HII pack containing all the strings. Add that file
# to the list of HII pack files we'll use to create our final HII export file.
@@ -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
!ENDIF
+!IF ("$(EFI_SPECIFICATION_VERSION)" >= "0x0002000A")
+#
+# Note: currently -ppflag option is only available for UefiStrGather
+# Note: /GS- will cause warning for preprocess, so filter it out from STRGATHER_PPFLAG
+#
+STRGATHER_PPFLAG = $(EBC_C_FLAGS: /GS-=)
+STRGATHER_FLAGS = $(STRGATHER_FLAGS) -ppflag "$(STRGATHER_PPFLAG)" -oh $(DEST_DIR)\$(BASE_NAME)StrDefs.h
+!ENDIF
+
$(DEST_DIR)\$(BASE_NAME).sdb : $(SDB_FILES) $(SOURCE_FILES)
$(STRGATHER) -scan -vdbr $(STRGATHER_FLAGS) -od $(DEST_DIR)\$(BASE_NAME).sdb \
-skipext .uni -skipext .h $(SOURCE_FILES)
@@ -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)
$(EBC_CC) $(EBC_C_FLAGS) $(DEST_DIR)\$(BASE_NAME)Strings.c
-LOCALIZE_TARGETS = $(LOCALIZE_TARGETS) $(DEST_DIR)\$(BASE_NAME)StrDefs.h
+LOCALIZE_TARGETS = $(DEST_DIR)\$(BASE_NAME)StrDefs.h $(LOCALIZE_TARGETS)
!ENDIF
@@ -1170,7 +1227,7 @@ $(TARGET_VER) : $(INF_FILENAME)
$(GENSECTION) -O $(TARGET_VER) -S EFI_SECTION_VERSION -V $(BUILD_NUMBER)
!ENDIF
!ELSE
-$(TARGET_VER) :
+$(TARGET_VER) : $(INF_FILENAME)
echo. > $(TARGET_VER)
type $(TARGET_VER) > $(TARGET_VER)
!ENDIF
@@ -1234,7 +1291,7 @@ $(TARGET_DPX) : $(DPX_SOURCE_FILE) $(INF_FILENAME)
!ERROR Dependency expression source file "$(DPX_SOURCE_FILE)" does not exist.
!ENDIF
!ELSE
-$(TARGET_DPX) :
+$(TARGET_DPX) : $(INF_FILENAME)
echo. > $(TARGET_DPX)
type $(TARGET_DPX) > $(TARGET_DPX)
!ENDIF
@@ -1293,7 +1350,7 @@ clean :
# This section, as it now exists, only supports boot service drivers.
#
[=============================================================================]
-[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]
+[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]
#
# Defines for standard intermediate files and build targets. For the source
# .efi file, take the one in the source directory if it exists. If there's not
@@ -1320,6 +1377,8 @@ TARGET_DLL = $(BIN_DIR)\$(BASE_NAME).dll
#
!IF "$(COMPONENT_TYPE)" == "APPLICATION"
TARGET_FFS_FILE = $(BIN_DIR)\$(FILE_GUID)-$(BASE_NAME).app
+!ELSE IF "$(COMPONENT_TYPE)" == "PE32_PEIM"
+TARGET_FFS_FILE = $(BIN_DIR)\$(FILE_GUID)-$(BASE_NAME).pei
!ELSE
TARGET_FFS_FILE = $(BIN_DIR)\$(FILE_GUID)-$(BASE_NAME).dxe
!ENDIF
@@ -1348,7 +1407,7 @@ $(TARGET_VER) : $(INF_FILENAME)
$(GENSECTION) -O $(TARGET_VER) -S EFI_SECTION_VERSION -V $(BUILD_NUMBER)
!ENDIF
!ELSE
-$(TARGET_VER) :
+$(TARGET_VER) : $(INF_FILENAME)
echo. > $(TARGET_VER)
type $(TARGET_VER) > $(TARGET_VER)
!ENDIF
@@ -1412,7 +1471,7 @@ $(TARGET_DPX) : $(DPX_SOURCE_FILE) $(INF_FILENAME)
!ERROR Dependency expression source file "$(DPX_SOURCE_FILE)" does not exist.
!ENDIF
!ELSE
-$(TARGET_DPX) :
+$(TARGET_DPX) : $(INF_FILENAME)
echo. > $(TARGET_DPX)
type $(TARGET_DPX) > $(TARGET_DPX)
!ENDIF
@@ -1438,18 +1497,17 @@ clean :
[=============================================================================]
[Compile.Ia32.Bin|Bmp,Compile.x64.Bin|Bmp,Compile.Ipf.Bin|Bmp]
#
-# We simply copy the binary file from the source directory to the destination directory
+# We simply define the binary source file name
#
-$(DEST_DIR)\$(BASE_NAME).bin : $(SOURCE_FILE_NAME)
- copy $** $@
+BINARY_SOURCE_FILE = $(SOURCE_FILE_NAME)
[=============================================================================]
[Build.Ia32.BINARY|Legacy16|Logo,Build.Ipf.BINARY|Legacy16|Logo,Build.x64.BINARY|Legacy16|Logo]
#
# Use GenFfsFile to convert it to an FFS file
#
-$(BIN_DIR)\$(FILE_GUID)-$(BASE_NAME).ffs : $(DEST_DIR)\$(BASE_NAME).bin $(PACKAGE_FILENAME)
- $(GENSECTION) -I $(DEST_DIR)\$(BASE_NAME).bin -O $(DEST_DIR)\$(BASE_NAME).sec -S EFI_SECTION_RAW
+$(BIN_DIR)\$(FILE_GUID)-$(BASE_NAME).ffs : $(BINARY_SOURCE_FILE) $(PACKAGE_FILENAME) $(INF_FILENAME)
+ $(GENSECTION) -I $(BINARY_SOURCE_FILE) -O $(DEST_DIR)\$(BASE_NAME).sec -S EFI_SECTION_RAW
$(GENFFSFILE) -B $(DEST_DIR) -P1 $(PACKAGE_FILENAME) -V
all : $(BIN_DIR)\$(FILE_GUID)-$(BASE_NAME).ffs
@@ -1469,7 +1527,8 @@ clean :
#
# Use GenFfsFile to convert it to an raw FFS file
#
-$(BIN_DIR)\$(FILE_GUID)-$(BASE_NAME).raw : $(DEST_DIR)\$(BASE_NAME).bin $(PACKAGE_FILENAME)
+$(BIN_DIR)\$(FILE_GUID)-$(BASE_NAME).raw : $(BINARY_SOURCE_FILE) $(PACKAGE_FILENAME) $(INF_FILENAME)
+ copy $(BINARY_SOURCE_FILE) $(DEST_DIR)\$(BASE_NAME).bin /Y
$(GENFFSFILE) -B $(DEST_DIR) -P1 $(PACKAGE_FILENAME) -V
all : $(BIN_DIR)\$(FILE_GUID)-$(BASE_NAME).raw
@@ -1516,6 +1575,8 @@ STRGATHER_FLAGS = $(STRGATHER_FLAGS) -db $(DEST_DIR)\$(FILE).sdb
LOCALIZE = YES
[=============================================================================]
+[Compile.Ia32.hfr,Compile.Ipf.hfr,Compile.Ebc.hfr,Compile.x64.hfr]
+[=============================================================================]
[Compile.Ia32.Vfr,Compile.Ipf.Vfr,Compile.x64.Vfr]
#
@@ -1695,7 +1756,7 @@ HII_IFR_PACK_FILES = $(HII_IFR_PACK_FILES) $(DEST_DIR)\$(FILE).hpk
#
# Run GenSection on the firmware volume image.
#
-$(DEST_DIR)\$(SOURCE_FV)Fv.sec : $(SOURCE_FILE_NAME)
+$(DEST_DIR)\$(SOURCE_FV)Fv.sec : $(SOURCE_FILE_NAME) $(INF_FILENAME)
$(GENSECTION) -I $(SOURCE_FILE_NAME) -O $(DEST_DIR)\$(SOURCE_FV)Fv.sec -S EFI_SECTION_FIRMWARE_VOLUME_IMAGE
[=============================================================================]
diff --git a/EdkCompatibilityPkg/Sample/Platform/EdkIIGlueLibAll.dsc b/EdkCompatibilityPkg/Sample/Platform/EdkIIGlueLibAll.dsc
index 533695cd47..0eba5f9e3a 100644
--- a/EdkCompatibilityPkg/Sample/Platform/EdkIIGlueLibAll.dsc
+++ b/EdkCompatibilityPkg/Sample/Platform/EdkIIGlueLibAll.dsc
@@ -1,5 +1,5 @@
#/*++
-# Copyright (c) 2006, Intel Corporation. All rights reserved.<BR>
+# Copyright (c) 2006 - 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
@@ -54,3 +54,4 @@ $(EDK_PREFIX)Foundation\Library\EdkIIGlueLib\Library\DxeSmbusLib\DxeSmbusLib.inf
$(EDK_PREFIX)Foundation\Library\EdkIIGlueLib\Library\PeiSmbusLib\PeiSmbusLib.inf
$(EDK_PREFIX)Foundation\Library\EdkIIGlueLib\Library\DxePerformanceLib\DxePerformanceLib.inf
$(EDK_PREFIX)Foundation\Library\EdkIIGlueLib\Library\PeiPerformanceLib\PeiPerformanceLib.inf
+$(EDK_PREFIX)Foundation\Library\EdkIIGlueLib\Library\SmmRuntimeDxeReportStatusCodeLib\SmmRuntimeDxeReportStatusCodeLib.inf
diff --git a/EdkCompatibilityPkg/Sample/Platform/Generic/Pei/Capsule/Capsule.h b/EdkCompatibilityPkg/Sample/Platform/Generic/Pei/Capsule/Capsule.h
index 6f2839fa4a..099ce167d3 100644
--- a/EdkCompatibilityPkg/Sample/Platform/Generic/Pei/Capsule/Capsule.h
+++ b/EdkCompatibilityPkg/Sample/Platform/Generic/Pei/Capsule/Capsule.h
@@ -1,6 +1,6 @@
/*++
-Copyright (c) 2004 - 2006, 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
@@ -20,8 +20,21 @@ Abstract:
#ifndef _CAPSULE_PEIM_H
#define _CAPSULE_PEIM_H
+#include "Tiano.h"
+
//
// If capsule data is passed via a variable, then this name should be used.
//
#define EFI_CAPSULE_VARIABLE_NAME L"CapsuleUpdateData"
+
+//
+// The variable describes the long mode buffer used by IA32 Capsule PEIM
+// to call X64 CapsuleCoalesce code to handle >4GB capsule blocks.
+//
+#define EFI_CAPSULE_LONG_MODE_BUFFER_NAME L"CapsuleLongModeBuffer"
+typedef struct {
+ UINT64 Base;
+ UINT64 Length;
+} EFI_CAPSULE_LONG_MODE_BUFFER;
+
#endif
diff --git a/EdkCompatibilityPkg/Sample/Tools/Source/Common/FvLib.c b/EdkCompatibilityPkg/Sample/Tools/Source/Common/FvLib.c
index 341204852c..f133d358d5 100644
--- a/EdkCompatibilityPkg/Sample/Tools/Source/Common/FvLib.c
+++ b/EdkCompatibilityPkg/Sample/Tools/Source/Common/FvLib.c
@@ -1,6 +1,6 @@
/*++
-Copyright (c) 2004 - 2007, 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
@@ -707,8 +707,13 @@ Returns:
//
FileLength = GetLength (FfsHeader->Size);
OccupiedFileLength = (FileLength + 0x07) & (-1 << 3);
+#if (PI_SPECIFICATION_VERSION < 0x00010000)
Checksum = CalculateSum8 ((UINT8 *) FfsHeader, FileLength - TailSize);
Checksum = (UINT8) (Checksum - FfsHeader->State);
+#else
+ Checksum = CalculateSum8 ((UINT8 *) ((UINTN)FfsHeader + sizeof (EFI_FFS_FILE_HEADER)), FileLength - TailSize - sizeof (EFI_FFS_FILE_HEADER));
+ Checksum = Checksum + (UINT8)FfsHeader->IntegrityCheck.Checksum.File;
+#endif
if (Checksum != 0) {
Error (NULL, 0, 0, FileGuidString, "invalid FFS file checksum");
return EFI_ABORTED;
@@ -716,10 +721,10 @@ Returns:
} else {
//
// File does not have a checksum
- // Verify contents are 0x5A as spec'd
+ // Verify contents are 0x5A(Framework) and 0xAA(PI 1.0) as spec'd
//
if (FfsHeader->IntegrityCheck.Checksum.File != FFS_FIXED_CHECKSUM) {
- Error (NULL, 0, 0, FileGuidString, "invalid fixed FFS file header checksum");
+ Error (NULL, 0, 0, FileGuidString, "invalid fixed file checksum");
return EFI_ABORTED;
}
}
diff --git a/EdkCompatibilityPkg/Sample/Tools/Source/Common/ParseInf.c b/EdkCompatibilityPkg/Sample/Tools/Source/Common/ParseInf.c
index 3d9fe11ab9..5abea63106 100644
--- a/EdkCompatibilityPkg/Sample/Tools/Source/Common/ParseInf.c
+++ b/EdkCompatibilityPkg/Sample/Tools/Source/Common/ParseInf.c
@@ -1,6 +1,6 @@
/*++
-Copyright (c) 2004, 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
@@ -344,6 +344,152 @@ Returns:
}
EFI_STATUS
+FindTokenInstanceInSection (
+ IN MEMORY_FILE *InputFile,
+ IN CHAR8 *Section,
+ IN UINTN Instance,
+ OUT CHAR8 *Token,
+ OUT CHAR8 *Value
+ )
+/*++
+
+Routine Description:
+
+ Finds the Instance-th token in a section.
+
+Arguments:
+
+ InputFile Memory file image.
+ Section The section to search for, a string within [].
+ Instance Specify the Instance-th token to search for, starting from zero
+ Token The token name to return. Caller should allocate the buffer.
+ Must be _MAX_PATH in size.
+ Value The token value to return. Caller should allocate the buffer.
+ Must be _MAX_PATH in size.
+
+Returns:
+
+ EFI_SUCCESS Token and Value found.
+ EFI_ABORTED Format error detected in INF file.
+ EFI_INVALID_PARAMETER Input argument was null.
+ EFI_LOAD_ERROR Error reading from the file.
+ EFI_NOT_FOUND Section/Token/Value not found.
+
+--*/
+{
+ CHAR8 InputBuffer[_MAX_PATH];
+ CHAR8 *CurrentToken;
+ CHAR8 *CurrentValue;
+ BOOLEAN ParseError;
+ BOOLEAN ReadError;
+ UINTN InstanceIndex;
+
+ //
+ // Check input parameters
+ //
+ if (InputFile->FileImage == NULL ||
+ InputFile->Eof == NULL ||
+ InputFile->CurrentFilePointer == NULL ||
+ Section == NULL ||
+ strlen (Section) == 0 ||
+ Value == NULL
+ ) {
+ return EFI_INVALID_PARAMETER;
+ }
+ //
+ // Initialize error codes
+ //
+ ParseError = FALSE;
+ ReadError = FALSE;
+
+ //
+ // Initialize our instance counter for the search token
+ //
+ InstanceIndex = 0;
+
+ if (FindSection (InputFile, Section)) {
+ //
+ // Found the desired section, find and read the desired token
+ //
+ do {
+ //
+ // Read a line from the file
+ //
+ if (ReadLine (InputFile, InputBuffer, _MAX_PATH) == NULL) {
+ //
+ // Error reading from input file
+ //
+ ReadError = TRUE;
+ break;
+ }
+ //
+ // Get the first non-whitespace string
+ //
+ CurrentToken = strtok (InputBuffer, " \t\n");
+ if (CurrentToken == NULL) {
+ //
+ // Whitespace line found (or comment) so continue
+ //
+ CurrentToken = InputBuffer;
+ continue;
+ }
+ //
+ // Make sure we have not reached the end of the current section
+ //
+ if (CurrentToken[0] == '[') {
+ break;
+ }
+ //
+ // Check if it is the correct instance
+ //
+ if (Instance == InstanceIndex) {
+ //
+ // Copy the contents following the =
+ //
+ CurrentValue = strtok (NULL, "= \t\n");
+ if (CurrentValue == NULL) {
+ //
+ // Nothing found, parsing error
+ //
+ ParseError = TRUE;
+ } else {
+ //
+ // Copy the current token to the output value
+ //
+ strcpy (Token, CurrentToken);
+ strcpy (Value, CurrentValue);
+ return EFI_SUCCESS;
+ }
+ } else {
+ //
+ // Increment the occurrance found
+ //
+ InstanceIndex++;
+ }
+ } while (
+ !ParseError &&
+ !ReadError &&
+ InputFile->CurrentFilePointer < InputFile->Eof &&
+ CurrentToken[0] != '[' &&
+ InstanceIndex <= Instance
+ );
+ }
+ //
+ // Distinguish between read errors and INF file format errors.
+ //
+ if (ReadError) {
+ return EFI_LOAD_ERROR;
+ }
+
+ if (ParseError) {
+ return EFI_ABORTED;
+ }
+
+ return EFI_NOT_FOUND;
+}
+
+
+EFI_STATUS
StringToGuid (
IN CHAR8 *AsciiGuidBuffer,
OUT EFI_GUID *GuidBuffer
diff --git a/EdkCompatibilityPkg/Sample/Tools/Source/Common/ParseInf.h b/EdkCompatibilityPkg/Sample/Tools/Source/Common/ParseInf.h
index 7dba8f8fdc..3d5eb5c34f 100644
--- a/EdkCompatibilityPkg/Sample/Tools/Source/Common/ParseInf.h
+++ b/EdkCompatibilityPkg/Sample/Tools/Source/Common/ParseInf.h
@@ -1,6 +1,6 @@
/*++
-Copyright (c) 2004, 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
@@ -124,6 +124,42 @@ Returns:
EFI_NOT_FOUND Section/Token/Value not found.
--*/
+
+EFI_STATUS
+FindTokenInstanceInSection (
+ IN MEMORY_FILE *InputFile,
+ IN CHAR8 *Section,
+ IN UINTN Instance,
+ OUT CHAR8 *Token,
+ OUT CHAR8 *Value
+ )
+;
+/*++
+
+Routine Description:
+
+ Finds the Instance-th token in a section.
+
+Arguments:
+
+ InputFile Memory file image.
+ Section The section to search for, a string within [].
+ Instance Specify the Instance-th token to search for, starting from zero
+ Token The token name to return. Caller should allocate the buffer.
+ Must be _MAX_PATH in size.
+ Value The token value to return. Caller should allocate the buffer.
+ Must be _MAX_PATH in size.
+
+Returns:
+
+ EFI_SUCCESS Token and Value found.
+ EFI_ABORTED Format error detected in INF file.
+ EFI_INVALID_PARAMETER Input argument was null.
+ EFI_LOAD_ERROR Error reading from the file.
+ EFI_NOT_FOUND Section/Token/Value not found.
+
+--*/
+
EFI_STATUS
StringToGuid (
IN CHAR8 *AsciiGuidBuffer,
diff --git a/EdkCompatibilityPkg/Sample/Tools/Source/EfiCompress/EfiCompressMain.c b/EdkCompatibilityPkg/Sample/Tools/Source/EfiCompress/EfiCompressMain.c
index d30d6272cf..8fbcd10a4e 100644
--- a/EdkCompatibilityPkg/Sample/Tools/Source/EfiCompress/EfiCompressMain.c
+++ b/EdkCompatibilityPkg/Sample/Tools/Source/EfiCompress/EfiCompressMain.c
@@ -1,6 +1,6 @@
/*++
-Copyright (c) 2006 - 2007, Intel Corporation. All rights reserved.<BR>
+Copyright (c) 2006 - 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
@@ -25,6 +25,9 @@ Abstract:
#include "TianoCommon.h"
#include "Compress.h"
+#define UTILITY_VERSION "v1.0"
+#define UTILITY_NAME "EfiCompress"
+
typedef enum {
EFI_COMPRESS = 1,
TIANO_COMPRESS = 2
@@ -365,22 +368,32 @@ Usage (
CHAR8 *ExeName
)
{
- fprintf (
- stdout,
- "\n"
- "Usage: %s [-tCompressType] InFileName OutFileName\n"
- " %*c [[-tCompressType] InFileName OutFileName ...]\n"
- "\n"
- "where:\n"
- " CompressType - optional compress algorithm (EFI | Tiano), case insensitive.\n"
- " If ommitted, compress type specified ahead is used, \n"
- " default is EFI\n"
- " e.g.: EfiCompress a.in a.out -tTiano b.in b.out \\ \n"
- " c.in c.out -tEFI d.in d.out\n"
- " a.in and d.in are compressed using EFI compress algorithm\n"
- " b.in and c.in are compressed using Tiano compress algorithm\n"
- " InFileName - input file path\n"
- " OutFileName - output file path\n",
- ExeName, strlen(ExeName), ' '
- );
+ int Index;
+ const char *Str[] = {
+ UTILITY_NAME" "UTILITY_VERSION" - Intel EFI Compress Utility",
+ " Copyright (C), 2006 - 2008 Intel Corporation",
+
+#if ( defined(UTILITY_BUILD) && defined(UTILITY_VENDOR) )
+ " Built from "UTILITY_BUILD", project of "UTILITY_VENDOR,
+#endif
+ "",
+ "Usage:",
+ " "UTILITY_NAME" [OPTION] SOURCE DEST ...",
+ "Description:",
+ " Compress a list of SOURCE(s) to accordingly DEST(s) using the specified",
+ " compress algorithm.",
+ "Options:",
+ " -tCompressAlgo Optional compress algorithm (EFI | Tiano), case insensitive.",
+ " If ommitted, compress type specified ahead is used,",
+ " default is EFI\n"
+ " e.g.: EfiCompress a.in a.out -tTiano b.in b.out \\",
+ " c.in c.out -tEFI d.in d.out",
+ " a.in and d.in are compressed using EFI compress algorithm",
+ " b.in and c.in are compressed using Tiano compress algorithm",
+ NULL
+ };
+ for (Index = 0; Str[Index] != NULL; Index++) {
+ fprintf (stdout, "%s\n", Str[Index]);
+ }
+
}
diff --git a/EdkCompatibilityPkg/Sample/Tools/Source/EfiRom/EfiRom.c b/EdkCompatibilityPkg/Sample/Tools/Source/EfiRom/EfiRom.c
index 11ae84f8ff..cf8efc86e1 100644
--- a/EdkCompatibilityPkg/Sample/Tools/Source/EfiRom/EfiRom.c
+++ b/EdkCompatibilityPkg/Sample/Tools/Source/EfiRom/EfiRom.c
@@ -1,6 +1,6 @@
/*++
-Copyright (c) 2007, Intel Corporation. All rights reserved.<BR>
+Copyright (c) 2007 - 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
@@ -45,7 +45,8 @@ Abstract:
//
// Version of this utility
//
-#define UTILITY_VERSION "v2.6"
+#define UTILITY_NAME "EfiRom"
+#define UTILITY_VERSION "v2.7"
//
// Define some status return values
@@ -1311,39 +1312,42 @@ Returns:
--*/
{
- int Index;
- static const char *Msg[] = {
- "EfiRom "UTILITY_VERSION" - Intel EFI Make Option ROM utility",
- " Copyright (C), 1999 - 2002 Intel Coproration\n",
- " Create an option ROM image from a list of input files",
- " Usage: efirom {-p} [-v VendorId] [-d DeviceId] {-o OutFileName} ",
- " [-e|-b] [FileName(s)]",
- " where:",
- " VendorId - required hex PCI Vendor ID for the device",
- " DeviceId - required hex PCI Device ID for the device",
- " OutFileName - optional output file name. Default is the first input",
- " file name with a "DEFAULT_OUTPUT_EXTENSION" file extension",
- " FileNames - input PE32 or binary file name(s)",
- " BinFileName - input binary file name(s)",
- " -p - for verbose output",
- " -l - to not automatically set the LAST bit on the last file",
- " -b - following FileNames are binary files",
- " -e - following FileNames are EFI PE32 image files",
- " -ec - following FileNames are EFI PE32 image files, and should",
- " be compressed by this utility",
- " -cc ClassCode - to use hex ClassCode in the PCI data structure header for",
- " the following FileName",
- " -rev Revision - to use hex Revision in the PCI data structure header for",
- " the following FileName",
- " -dump - to dump the headers of an existing option ROM image",
- "",
- "Example usage: EfiRom -v 0xABCD -d 0x1234 -b File1.bin File2.bin -e File1.efi File2.efi",
+ int Index;
+ const char *Str[] = {
+ UTILITY_NAME" "UTILITY_VERSION" - Intel EFI Make Option ROM Utility",
+ " Copyright (C), 1999 - 2008 Intel Coproration",
+
+#if ( defined(UTILITY_BUILD) && defined(UTILITY_VENDOR) )
+ " Built from "UTILITY_BUILD", project of "UTILITY_VENDOR,
+#endif
+
"",
+ "Usage:",
+ " "UTILITY_NAME" [OPTION]... SOURCE ...",
+ "Description:",
+ " Create an option ROM image from a list of input files",
+ "Options:",
+ " -v VendorId - required hex PCI Vendor ID for the device",
+ " -d DeviceId - required hex PCI Device ID for the device",
+ " -o OutFileName - optional output file name. Default is the first input",
+ " file name with a "DEFAULT_OUTPUT_EXTENSION" file extension",
+ " -e SOURCE ... - input are EFI PE32 image file(s)",
+ " -b SOURCE ... - input are Legacy binary file(s)",
+ " -ec SOURCE ... - input are EFI PE32 image file(s) and should be compressed",
+ " -p - for verbose output",
+ " -l - to not automatically set the LAST bit on the last file",
+ " -cc ClassCode - to use hex ClassCode in the PCI data structure header for",
+ " the following SOURCE(s)",
+ " -rev Revision - to use hex Revision in the PCI data structure header for",
+ " the following one SOURCE",
+ " -dump - to dump the headers of an existing option ROM image",
+ "Example Usage:",
+ " EfiRom -v 0xABCD -d 0x1234 -b File1.bin File2.bin -e File1.efi File2.efi",
NULL
};
- for (Index = 0; Msg[Index] != NULL; Index++) {
- fprintf (stdout, "%s\n", Msg[Index]);
+ for (Index = 0; Str[Index] != NULL; Index++) {
+ fprintf (stdout, "%s\n", Str[Index]);
}
}
diff --git a/EdkCompatibilityPkg/Sample/Tools/Source/FwImage/fwimage.c b/EdkCompatibilityPkg/Sample/Tools/Source/FwImage/fwimage.c
index eb23dc7637..d5f2ecee0a 100644
--- a/EdkCompatibilityPkg/Sample/Tools/Source/FwImage/fwimage.c
+++ b/EdkCompatibilityPkg/Sample/Tools/Source/FwImage/fwimage.c
@@ -1,6 +1,6 @@
/*++
-Copyright (c) 2004 - 2006, 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
@@ -29,7 +29,8 @@ Abstract:
#include "EfiImage.h"
#include "EfiUtilityMsgs.c"
-#define UTILITY_NAME "FwImage"
+#define UTILITY_NAME "FwImage"
+#define UTILITY_VERSION "v1.0"
typedef union {
IMAGE_NT_HEADERS32 PeHeader32;
@@ -41,10 +42,33 @@ Usage (
VOID
)
{
- 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");
- printf (" -t: Add Time Stamp for output image\n");
- printf (" -e: Not clear ExceptionTable for output image\n");
- printf (" -r: Not strip zero pending of .reloc for output image\n");
+ int Index;
+ const char *Str[] = {
+ UTILITY_NAME" "UTILITY_VERSION" - Intel Firmware Image Utility",
+ " Copyright (C), 2004 - 2008 Intel Corporation",
+
+#if ( defined(UTILITY_BUILD) && defined(UTILITY_VENDOR) )
+ " Built from "UTILITY_BUILD", project of "UTILITY_VENDOR,
+#endif
+
+ "",
+ "Usage:",
+ " "UTILITY_NAME" [OPTION]... FWTYPE SOURCE [DEST]",
+ "Description:",
+ " Converts a pe32/pe32+ SOURCE to DEST with FWTYPE image type.",
+ "Options:",
+ " FWTYPE Can be one of APPLICATION, BS_DRIVER, RT_DRIVER, SAL_RT_DRIVER,",
+ " COMBINED_PEIM_DRIVER, SECURITY_CORE, PEI_CORE, PE32_PEIM and",
+ " RELOCATABLE_PEIM",
+ " -t time-date Add Time Stamp for output image",
+ " -e Not clear ExceptionTable for output image",
+ " -r Not strip zero pending of .reloc for output image",
+ NULL
+ };
+
+ for (Index = 0; Str[Index] != NULL; Index++) {
+ fprintf (stdout, "%s\n", Str[Index]);
+ }
}
static
diff --git a/EdkCompatibilityPkg/Sample/Tools/Source/GenAprioriFile/GenAprioriFile.c b/EdkCompatibilityPkg/Sample/Tools/Source/GenAprioriFile/GenAprioriFile.c
index e346a1e4c8..81ffcb78df 100644
--- a/EdkCompatibilityPkg/Sample/Tools/Source/GenAprioriFile/GenAprioriFile.c
+++ b/EdkCompatibilityPkg/Sample/Tools/Source/GenAprioriFile/GenAprioriFile.c
@@ -1,6 +1,6 @@
/*++
- Copyright (c) 2006, Intel Corporation. All rights reserved.<BR>
+ Copyright (c) 2006 - 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
@@ -39,7 +39,8 @@ Abstract:
// #define STATUS_WARNING 1
// #define STATUS_ERROR 2
//
-#define UTILITY_NAME "GenAprioriFile"
+#define UTILITY_NAME "GenAprioriFile"
+#define UTILITY_VERSION "v1.0"
//
// Here's all our globals.
//
@@ -447,18 +448,26 @@ Returns:
--*/
{
- int Index;
- static const char *Str[] = {
- UTILITY_NAME " -- create an Apriori file consumable by the DXE dispatcher",
- " Usage: "UTILITY_NAME " [Options]",
- " Options include:",
- " -h or -? for this help information",
- " -f AprioriFile parse the GUID'ed files in AprioriFile (required)",
- " -o OutputFile write output to OutputFile (required)",
- " -i for intelligent re-creation of OutputFile",
- " -null to terminate the output file with a NULL GUID",
- " -v verbose option",
+ int Index;
+ const char *Str[] = {
+ UTILITY_NAME" "UTILITY_VERSION" - Intel Generate Apriori File Utility",
+ " Copyright (C), 2006 - 2008 Intel Corporation",
+
+#if ( defined(UTILITY_BUILD) && defined(UTILITY_VENDOR) )
+ " Built from "UTILITY_BUILD", project of "UTILITY_VENDOR,
+#endif
"",
+ "Usage:",
+ " "UTILITY_NAME" [OPTION]...",
+ "Description:",
+ " Generate an Apriori file consumable by the DXE or PEI dispatcher.",
+ "Options:",
+ " -h or -? for this help information",
+ " -f AprioriFile parse the GUID'ed files in AprioriFile (required)",
+ " -o OutputFile write output to OutputFile (required)",
+ " -i for intelligent re-creation of OutputFile",
+ " -null to terminate the output file with a NULL GUID",
+ " -v verbose option",
NULL
};
for (Index = 0; Str[Index] != NULL; Index++) {
diff --git a/EdkCompatibilityPkg/Sample/Tools/Source/GenCRC32Section/GenCRC32Section.c b/EdkCompatibilityPkg/Sample/Tools/Source/GenCRC32Section/GenCRC32Section.c
index b1f3f1eec4..5bbbd14c7e 100644
--- a/EdkCompatibilityPkg/Sample/Tools/Source/GenCRC32Section/GenCRC32Section.c
+++ b/EdkCompatibilityPkg/Sample/Tools/Source/GenCRC32Section/GenCRC32Section.c
@@ -1,6 +1,6 @@
/*++
-Copyright (c) 2004 - 2006, 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
@@ -35,9 +35,9 @@ Abstract:
#include EFI_PROTOCOL_DEFINITION (GuidedSectionExtraction)
-#define TOOLVERSION "0.2"
+#define UTILITY_VERSION "v1.0"
-#define UTILITY_NAME "GenCrc32Section"
+#define UTILITY_NAME "GenCrc32Section"
EFI_GUID gEfiCrc32SectionGuid = EFI_CRC32_GUIDED_SECTION_EXTRACTION_PROTOCOL_GUID;
@@ -134,12 +134,26 @@ PrintUsage (
VOID
)
{
- printf ("Usage:\n");
- printf (UTILITY_NAME " -i \"inputfile1\" \"inputfile2\" -o \"outputfile\" \n");
- printf (" -i \"inputfile\":\n ");
- printf (" specifies the input files that would be signed to CRC32 Guided section.\n");
- printf (" -o \"outputfile\":\n");
- printf (" specifies the output file that is a CRC32 Guided section.\n");
+ int Index;
+ const char *Str[] = {
+ UTILITY_NAME" "UTILITY_VERSION" - Intel Generate CRC32 Section Utility",
+ " Copyright (C), 2004 - 2008 Intel Corporation",
+
+#if ( defined(UTILITY_BUILD) && defined(UTILITY_VENDOR) )
+ " Built from "UTILITY_BUILD", project of "UTILITY_VENDOR,
+#endif
+ "",
+ "Usage:",
+ " "UTILITY_NAME" [OPTION]",
+ "Options:",
+ " -i Input1 ... specifies the input file(s) that would be signed to CRC32",
+ " Guided section.",
+ " -o Output specifies the output file that is a CRC32 Guided section",
+ NULL
+ };
+ for (Index = 0; Str[Index] != NULL; Index++) {
+ fprintf (stdout, "%s\n", Str[Index]);
+ }
}
INT32
diff --git a/EdkCompatibilityPkg/Sample/Tools/Source/GenDepex/GenDepex.c b/EdkCompatibilityPkg/Sample/Tools/Source/GenDepex/GenDepex.c
index 37c1039c0f..2cfc3079ab 100644
--- a/EdkCompatibilityPkg/Sample/Tools/Source/GenDepex/GenDepex.c
+++ b/EdkCompatibilityPkg/Sample/Tools/Source/GenDepex/GenDepex.c
@@ -1,6 +1,6 @@
/*++
-Copyright (c) 2004 - 2006, 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
@@ -77,7 +77,15 @@ Abstract:
#include "GenDepex.h"
-#define TOOL_NAME "GenDepex"
+//
+// Utility Name
+//
+#define UTILITY_NAME "GenDepex"
+
+//
+// Utility version information
+//
+#define UTILITY_VERSION "v1.0"
extern
BOOLEAN
@@ -106,13 +114,19 @@ Returns:
--*/
{
- printf (
- "%s, Tiano Dependency Expression Generation Utility. Version %d.%d.\n",
- UTILITY_NAME,
- UTILITY_MAJOR_VERSION,
- UTILITY_MINOR_VERSION
- );
- printf ("Copyright (C) 1996-2002 Intel Corporation. All rights reserved.\n\n");
+ int Index;
+ const char *Str[] = {
+ UTILITY_NAME" "UTILITY_VERSION" - Intel Generate Dependency Expression Utility",
+ " Copyright (C), 1996 - 2008 Intel Corporation",
+
+#if ( defined(UTILITY_BUILD) && defined(UTILITY_VENDOR) )
+ " Built from "UTILITY_BUILD", project of "UTILITY_VENDOR,
+#endif
+ NULL
+ };
+ for (Index = 0; Str[Index] != NULL; Index++) {
+ fprintf (stdout, "%s\n", Str[Index]);
+ }
}
VOID
@@ -135,15 +149,22 @@ Returns:
--*/
{
- printf (
- "Usage: %s -I <INFILE> -O <OUTFILE> [-P <Optional Boundary for padding up>] \n",
- UTILITY_NAME
- );
- printf (" Where:\n");
- printf (" <INFILE> is the input pre-processed dependency text files name.\n");
- printf (" <OUTFILE> is the output binary dependency files name.\n");
- printf (" <Optional Boundary for padding up> is the padding integer value.\n");
- printf (" This is the boundary to align the output file size to.\n");
+ int Index;
+ const char *Str[] = {
+ "",
+ "Usage:",
+ " "UTILITY_NAME" [OPTION]...",
+ "Options:",
+ " -I INFILE The input pre-processed dependency text files name",
+ " -O OUTFILE The output binary dependency files name",
+ " -P BOUNDARY The padding integer value to align the output file size",
+ NULL
+ };
+
+ PrintGenDepexUtilityInfo ();
+ for (Index = 0; Str[Index] != NULL; Index++) {
+ fprintf (stdout, "%s\n", Str[Index]);
+ }
}
DEPENDENCY_OPCODE
@@ -742,7 +763,7 @@ Returns:
// print an error message.
//
*(Ptrx + 20) = 0;
- printf (TOOL_NAME " ERROR: Unrecognized input at: \"%s\"...\n", Ptrx);
+ printf (UTILITY_NAME" ERROR: Unrecognized input at: \"%s\"...\n", Ptrx);
return EFI_INVALID_PARAMETER;
}
}
diff --git a/EdkCompatibilityPkg/Sample/Tools/Source/GenDepex/GenDepex.h b/EdkCompatibilityPkg/Sample/Tools/Source/GenDepex/GenDepex.h
index a1d6ec30d3..0321a4c840 100644
--- a/EdkCompatibilityPkg/Sample/Tools/Source/GenDepex/GenDepex.h
+++ b/EdkCompatibilityPkg/Sample/Tools/Source/GenDepex/GenDepex.h
@@ -1,5 +1,5 @@
/*++
-Copyright (c) 2004, 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
@@ -53,15 +53,5 @@ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
#define EVAL_STACK_SIZE 0x1024
#define BUFFER_SIZE 0x100
-//
-// Utility Name
-//
-#define UTILITY_NAME "GenDepex"
-
-//
-// Utility version information
-//
-#define UTILITY_MAJOR_VERSION 0
-#define UTILITY_MINOR_VERSION 4
#endif
diff --git a/EdkCompatibilityPkg/Sample/Tools/Source/GenFfsFile/GenFfsFile.c b/EdkCompatibilityPkg/Sample/Tools/Source/GenFfsFile/GenFfsFile.c
index d4053671f5..269a5b81cb 100644
--- a/EdkCompatibilityPkg/Sample/Tools/Source/GenFfsFile/GenFfsFile.c
+++ b/EdkCompatibilityPkg/Sample/Tools/Source/GenFfsFile/GenFfsFile.c
@@ -1,6 +1,6 @@
/*++
-Copyright (c) 2004 - 2007, 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
@@ -43,7 +43,7 @@ Abstract:
#include "SimpleFileParsing.h"
#define UTILITY_NAME "GenFfsFile"
-#define TOOLVERSION "0.32"
+#define UTILITY_VERSION "v1.1"
#define MAX_ARRAY_SIZE 100
static
@@ -123,6 +123,7 @@ static struct {
UINT8 BuildDirectory[_MAX_PATH];
UINT8 PrimaryPackagePath[_MAX_PATH];
UINT8 OverridePackagePath[_MAX_PATH];
+ UINT8 OutputFilePath[_MAX_PATH];
BOOLEAN Verbose;
MACRO *MacroList;
} mGlobals;
@@ -187,22 +188,33 @@ Returns:
--*/
{
- printf ("Usage:\n");
- printf (UTILITY_NAME " -b \"build directory\" -p1 \"package1.inf\" -p2 \"package2.inf\"\n");
- printf (" -d \"name=value\" -v\n");
- printf (" -b \"build directory\":\n");
- printf (" specifies the full path to the component build directory.\n");
- printf (" -p1 \"P1_path\":\n");
- printf (" specifies fully qualified file name to the primary package file.\n");
- printf (" This file will normally exist in the same directory as the makefile\n");
- printf (" for the component. Required.\n");
- printf (" -p2 \"P2_path\":\n");
- printf (" specifies fully qualified file name to the override package file.\n");
- printf (" This file will normally exist in the build tip. Optional.\n");
- printf (" -d \"name=value\":\n");
- printf (" add a macro definition for package file. Optional.\n");
- printf (" -v :\n");
- printf (" verbose. Optional.\n");
+ int Index;
+ const char *Str[] = {
+ UTILITY_NAME" "UTILITY_VERSION" - Intel Generate FFS File Utility",
+ " Copyright (C), 2004 - 2009 Intel Corporation",
+
+#if ( defined(UTILITY_BUILD) && defined(UTILITY_VENDOR) )
+ " Built from "UTILITY_BUILD", project of "UTILITY_VENDOR,
+#endif
+ "",
+ "Usage:",
+ " "UTILITY_NAME" [OPTION]...",
+ "Options:",
+ " -b BuildDirectory Specifies the full path to the component build directory",
+ " -p1 P1Path Specifies fully qualified file name to the primary package",
+ " file. This file will normally exist in the same directory",
+ " as the makefile for the component. Required.",
+ " -p2 P2Path Specifies fully qualified file name to the override",
+ " package. This file will normally exist in the build tip.",
+ " Optional.",
+ " -d Name=Value Add a macro definition for the package file. Optional.",
+ " -o OutputFile Specifies the file name of output file. Optional.",
+ " -v Verbose. Optional.",
+ NULL
+ };
+ for (Index = 0; Str[Index] != NULL; Index++) {
+ fprintf (stdout, "%s\n", Str[Index]);
+ }
}
static
@@ -2160,54 +2172,64 @@ here:
StripQuotes (BaseName);
}
- if (BaseName[0] != 0) {
- sprintf (InputString, "%s-%s", GuidString, BaseName);
+ if (mGlobals.OutputFilePath[0]) {
+ //
+ // Use user specified output file name
+ //
+ strcpy (InputString, mGlobals.OutputFilePath);
} else {
- strcpy (InputString, GuidString);
- }
+ //
+ // Construct the output file name according to FileType
+ //
+ if (BaseName[0] != 0) {
+ sprintf (InputString, "%s-%s", GuidString, BaseName);
+ } else {
+ strcpy (InputString, GuidString);
+ }
- switch (StringToType (FileType)) {
+ switch (StringToType (FileType)) {
- case EFI_FV_FILETYPE_SECURITY_CORE:
- strcat (InputString, ".SEC");
- break;
+ case EFI_FV_FILETYPE_SECURITY_CORE:
+ strcat (InputString, ".SEC");
+ break;
- case EFI_FV_FILETYPE_PEIM:
- case EFI_FV_FILETYPE_PEI_CORE:
- case EFI_FV_FILETYPE_COMBINED_PEIM_DRIVER:
- strcat (InputString, ".PEI");
- break;
+ case EFI_FV_FILETYPE_PEIM:
+ case EFI_FV_FILETYPE_PEI_CORE:
+ case EFI_FV_FILETYPE_COMBINED_PEIM_DRIVER:
+ strcat (InputString, ".PEI");
+ break;
- case EFI_FV_FILETYPE_DRIVER:
- case EFI_FV_FILETYPE_DXE_CORE:
- strcat (InputString, ".DXE");
- break;
+ case EFI_FV_FILETYPE_DRIVER:
+ case EFI_FV_FILETYPE_DXE_CORE:
+ strcat (InputString, ".DXE");
+ break;
- case EFI_FV_FILETYPE_APPLICATION:
- strcat (InputString, ".APP");
- break;
+ case EFI_FV_FILETYPE_APPLICATION:
+ strcat (InputString, ".APP");
+ break;
- case EFI_FV_FILETYPE_FIRMWARE_VOLUME_IMAGE:
- strcat (InputString, ".FVI");
- break;
+ case EFI_FV_FILETYPE_FIRMWARE_VOLUME_IMAGE:
+ strcat (InputString, ".FVI");
+ break;
- case EFI_FV_FILETYPE_RAW:
- strcat (InputString, ".RAW");
- break;
+ case EFI_FV_FILETYPE_RAW:
+ strcat (InputString, ".RAW");
+ break;
- case EFI_FV_FILETYPE_ALL:
- Error (mGlobals.OverridePackagePath, 1, 0, "invalid FFS file type for this utility", NULL);
- goto Done;
+ case EFI_FV_FILETYPE_ALL:
+ Error (mGlobals.OverridePackagePath, 1, 0, "invalid FFS file type for this utility", NULL);
+ goto Done;
- default:
- strcat (InputString, ".FFS");
- break;
+ default:
+ strcat (InputString, ".FFS");
+ break;
+ }
}
if (ForceUncompress) {
strcat (InputString, ".ORG");
}
-
+
Out = fopen (InputString, "wb");
if (Out == NULL) {
Error (NULL, 0, 0, InputString, "could not open output file for writing");
@@ -2242,7 +2264,11 @@ here:
sizeof (EFI_FFS_FILE_HEADER)
);
if (FileHeader.Attributes & FFS_ATTRIB_CHECKSUM) {
+#if (PI_SPECIFICATION_VERSION < 0x00010000)
FileHeader.IntegrityCheck.Checksum.File = CalculateChecksum8 ((UINT8 *) &FileHeader, FileSize);
+#else
+ FileHeader.IntegrityCheck.Checksum.File = CalculateChecksum8 ((UINT8 *) ((UINTN)&FileHeader + sizeof (EFI_FFS_FILE_HEADER)), FileSize - sizeof (EFI_FFS_FILE_HEADER));
+#endif
} else {
FileHeader.IntegrityCheck.Checksum.File = FFS_FIXED_CHECKSUM;
}
@@ -2307,48 +2333,58 @@ here:
StripQuotes (BaseName);
}
- if (BaseName[0] != 0) {
- sprintf (InputString, "%s-%s", GuidString, BaseName);
+ if (mGlobals.OutputFilePath[0]) {
+ //
+ // Use user specified output file name
+ //
+ strcpy (InputString, mGlobals.OutputFilePath);
} else {
- strcpy (InputString, GuidString);
- }
+ //
+ // Construct the output file name according to FileType
+ //
+ if (BaseName[0] != 0) {
+ sprintf (InputString, "%s-%s", GuidString, BaseName);
+ } else {
+ strcpy (InputString, GuidString);
+ }
- switch (StringToType (FileType)) {
+ switch (StringToType (FileType)) {
- case EFI_FV_FILETYPE_SECURITY_CORE:
- strcat (InputString, ".SEC");
- break;
+ case EFI_FV_FILETYPE_SECURITY_CORE:
+ strcat (InputString, ".SEC");
+ break;
- case EFI_FV_FILETYPE_PEIM:
- case EFI_FV_FILETYPE_PEI_CORE:
- case EFI_FV_FILETYPE_COMBINED_PEIM_DRIVER:
- strcat (InputString, ".PEI");
- break;
+ case EFI_FV_FILETYPE_PEIM:
+ case EFI_FV_FILETYPE_PEI_CORE:
+ case EFI_FV_FILETYPE_COMBINED_PEIM_DRIVER:
+ strcat (InputString, ".PEI");
+ break;
- case EFI_FV_FILETYPE_DRIVER:
- case EFI_FV_FILETYPE_DXE_CORE:
- strcat (InputString, ".DXE");
- break;
+ case EFI_FV_FILETYPE_DRIVER:
+ case EFI_FV_FILETYPE_DXE_CORE:
+ strcat (InputString, ".DXE");
+ break;
- case EFI_FV_FILETYPE_APPLICATION:
- strcat (InputString, ".APP");
- break;
+ case EFI_FV_FILETYPE_APPLICATION:
+ strcat (InputString, ".APP");
+ break;
- case EFI_FV_FILETYPE_FIRMWARE_VOLUME_IMAGE:
- strcat (InputString, ".FVI");
- break;
+ case EFI_FV_FILETYPE_FIRMWARE_VOLUME_IMAGE:
+ strcat (InputString, ".FVI");
+ break;
- case EFI_FV_FILETYPE_RAW:
- strcat (InputString, ".RAW");
- break;
+ case EFI_FV_FILETYPE_RAW:
+ strcat (InputString, ".RAW");
+ break;
- case EFI_FV_FILETYPE_ALL:
- Error (mGlobals.PrimaryPackagePath, 1, 0, "invalid FFS file type for this utility", NULL);
- goto Done;
+ case EFI_FV_FILETYPE_ALL:
+ Error (mGlobals.PrimaryPackagePath, 1, 0, "invalid FFS file type for this utility", NULL);
+ goto Done;
- default:
- strcat (InputString, ".FFS");
- break;
+ default:
+ strcat (InputString, ".FFS");
+ break;
+ }
}
if (ForceUncompress) {
@@ -2624,6 +2660,23 @@ Returns:
OriginalOverridePackagePath = Argv[1];
Argc--;
Argv++;
+ } else if (_strcmpi (Argv[0], "-o") == 0) {
+ //
+ // OPTION: -o OutputFilePath
+ // Make sure there is another argument, then save it to out globals.
+ //
+ if (Argc < 2) {
+ Error (NULL, 0, 0, Argv[0], "option requires the output file name");
+ return STATUS_ERROR;
+ }
+ if (mGlobals.OutputFilePath[0]) {
+ Error (NULL, 0, 0, Argv[0], "option can only be specified once");
+ return STATUS_ERROR;
+ }
+
+ strcpy (mGlobals.OutputFilePath, Argv[1]);
+ Argc--;
+ Argv++;
} else if (_strcmpi (Argv[0], "-v") == 0) {
//
// OPTION: -v verbose
diff --git a/EdkCompatibilityPkg/Sample/Tools/Source/GenFvImage/GenFvImageExe.c b/EdkCompatibilityPkg/Sample/Tools/Source/GenFvImage/GenFvImageExe.c
index 8d9a7768ec..6e45c8695d 100644
--- a/EdkCompatibilityPkg/Sample/Tools/Source/GenFvImage/GenFvImageExe.c
+++ b/EdkCompatibilityPkg/Sample/Tools/Source/GenFvImage/GenFvImageExe.c
@@ -1,6 +1,6 @@
/*++
-Copyright (c) 2004, 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
@@ -49,12 +49,19 @@ Returns:
--*/
{
- printf (
- "%s - Tiano Firmware Volume Generation Utility."" Version %i.%i\n\n",
- UTILITY_NAME,
- UTILITY_MAJOR_VERSION,
- UTILITY_MINOR_VERSION
- );
+ int Index;
+ const char *Str[] = {
+ UTILITY_NAME" "UTILITY_VERSION" - Intel Generate Firmware Volume Utility",
+ " Copyright (C), 2004 - 2009 Intel Corporation",
+
+#if ( defined(UTILITY_BUILD) && defined(UTILITY_VENDOR) )
+ " Built from "UTILITY_BUILD", project of "UTILITY_VENDOR,
+#endif
+ NULL
+ };
+ for (Index = 0; Str[Index] != NULL; Index++) {
+ fprintf (stdout, "%s\n", Str[Index]);
+ }
}
VOID
@@ -77,9 +84,19 @@ Returns:
--*/
{
- printf ("Usage: %s -I FvInfFileName\n", UTILITY_NAME);
- printf (" Where:\n");
- printf ("\tFvInfFileName is the name of the image description file.\n\n");
+ int Index;
+ const char *Str[] = {
+ "",
+ "Usage:",
+ " "UTILITY_NAME" [OPTION]",
+ "Options:",
+ " -I FvInfFileName The name of the image description file.",
+ NULL
+ };
+
+ for (Index = 0; Str[Index] != NULL; Index++) {
+ fprintf (stdout, "%s\n", Str[Index]);
+ }
}
EFI_STATUS
diff --git a/EdkCompatibilityPkg/Sample/Tools/Source/GenFvImage/GenFvImageExe.h b/EdkCompatibilityPkg/Sample/Tools/Source/GenFvImage/GenFvImageExe.h
index d0dd1bbe02..08a62af3e6 100644
--- a/EdkCompatibilityPkg/Sample/Tools/Source/GenFvImage/GenFvImageExe.h
+++ b/EdkCompatibilityPkg/Sample/Tools/Source/GenFvImage/GenFvImageExe.h
@@ -1,6 +1,6 @@
/*++
-Copyright (c) 2004, 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
@@ -38,8 +38,7 @@ Abstract:
//
// Utility version information
//
-#define UTILITY_MAJOR_VERSION 0
-#define UTILITY_MINOR_VERSION 1
+#define UTILITY_VERSION "v1.1"
#define UTILITY_DATE __DATE__
//
diff --git a/EdkCompatibilityPkg/Sample/Tools/Source/GenFvImage/GenFvImageLib.c b/EdkCompatibilityPkg/Sample/Tools/Source/GenFvImage/GenFvImageLib.c
index cb193ce2ce..b5ed87a131 100644
--- a/EdkCompatibilityPkg/Sample/Tools/Source/GenFvImage/GenFvImageLib.c
+++ b/EdkCompatibilityPkg/Sample/Tools/Source/GenFvImage/GenFvImageLib.c
@@ -1,6 +1,6 @@
/*++
-Copyright (c) 2004 - 2007, 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
@@ -968,13 +968,17 @@ Returns:
Status = FindToken (InfFile, OPTIONS_SECTION_STRING, EFI_NUM_BLOCKS_STRING, Index, Value);
if (Status == EFI_SUCCESS) {
- //
- // Update the number of blocks
- //
- Status = AsciiStringToUint64 (Value, FALSE, &Value64);
- if (EFI_ERROR (Status)) {
- Error (NULL, 0, 0, Value, "invalid value for %s", EFI_NUM_BLOCKS_STRING);
- return EFI_ABORTED;
+ if (strcmp (Value, AUTO_STRING) == 0) {
+ Value64 = (UINT64) -1;
+ } else {
+ //
+ // Update the number of blocks
+ //
+ Status = AsciiStringToUint64 (Value, FALSE, &Value64);
+ if (EFI_ERROR (Status)) {
+ Error (NULL, 0, 0, Value, "invalid value for %s", EFI_NUM_BLOCKS_STRING);
+ return EFI_ABORTED;
+ }
}
FvInfo->FvBlocks[Index].NumBlocks = (UINT32) Value64;
@@ -1040,99 +1044,59 @@ Returns:
if (FindSection (InfFile, COMPONENT_SECTION_STRING)) {
Index = 0;
- //
- // Read component FV_VARIABLE
- //
- Status = FindToken (InfFile, COMPONENT_SECTION_STRING, EFI_NV_VARIABLE_STRING, 0, Value);
-
- if (Status == EFI_SUCCESS) {
- //
- // Add the component
- //
- strcpy (FvInfo->FvComponents[Index].ComponentName, EFI_NV_VARIABLE_STRING);
- Status = AsciiStringToUint64 (Value, FALSE, &Value64);
+ while (TRUE) {
+ Status = FindTokenInstanceInSection (
+ InfFile,
+ COMPONENT_SECTION_STRING,
+ Index,
+ FvInfo->FvComponents[Index].ComponentName,
+ Value
+ );
if (EFI_ERROR (Status)) {
- printf ("ERROR: %s is not a valid integer.\n", EFI_NV_VARIABLE_STRING);
- return EFI_ABORTED;
+ break;
}
-
- FvInfo->FvComponents[Index].Size = (UINTN) Value64;
- } else {
- printf ("WARNING: Could not read %s.\n", EFI_NV_VARIABLE_STRING);
- }
-
- Index++;
- //
- // Read component FV_EVENT_LOG
- //
- Status = FindToken (InfFile, COMPONENT_SECTION_STRING, EFI_NV_EVENT_LOG_STRING, 0, Value);
-
- if (Status == EFI_SUCCESS) {
- //
- // Add the component
- //
- strcpy (FvInfo->FvComponents[Index].ComponentName, EFI_NV_EVENT_LOG_STRING);
Status = AsciiStringToUint64 (Value, FALSE, &Value64);
if (EFI_ERROR (Status)) {
- printf ("ERROR: %s is not a valid integer.\n", EFI_NV_EVENT_LOG_STRING);
+ Error (NULL, 0, 0, Value, "not a valid integer");
return EFI_ABORTED;
}
FvInfo->FvComponents[Index].Size = (UINTN) Value64;
- } else {
- printf ("WARNING: Could not read %s.\n", EFI_NV_EVENT_LOG_STRING);
+ Index++;
}
-
- Index++;
- //
- // Read component FV_FTW_WORKING
- //
- Status = FindToken (InfFile, COMPONENT_SECTION_STRING, EFI_NV_FTW_WORKING_STRING, 0, Value);
-
- if (Status == EFI_SUCCESS) {
+ }
+ //
+ // Compute size for easy access later
+ //
+ FvInfo->Size = 0;
+ for (Index = 0; FvInfo->FvBlocks[Index].NumBlocks; Index++) {
+ if ((FvInfo->Size == (UINTN) -1 && Index > 0) ||
+ (FvInfo->FvBlocks[Index].NumBlocks == (UINT32) -1 && Index > 0)
+ ) {
//
- // Add the component
+ // Error 1. more pairs after AUTO
+ // Error 2. AUTO appear in non-first position
//
- strcpy (FvInfo->FvComponents[Index].ComponentName, EFI_NV_FTW_WORKING_STRING);
- Status = AsciiStringToUint64 (Value, FALSE, &Value64);
- if (EFI_ERROR (Status)) {
- printf ("ERROR: %s is not a valid integer.\n", EFI_NV_FTW_WORKING_STRING);
- return EFI_ABORTED;
- }
+ Error (NULL, 0, 0, NULL, "cannot have more than one pair of %s and %s if %s is set to %s",
+ EFI_NUM_BLOCKS_STRING, EFI_BLOCK_SIZE_STRING,
+ EFI_NUM_BLOCKS_STRING, AUTO_STRING
+ );
+ return EFI_ABORTED;
+ }
- FvInfo->FvComponents[Index].Size = (UINTN) Value64;
+ if (FvInfo->FvBlocks[Index].NumBlocks == (UINT32) -1) {
+ FvInfo->Size = (UINTN) -1;
} else {
- printf ("WARNING: Could not read %s.\n", EFI_NV_FTW_WORKING_STRING);
+ FvInfo->Size += FvInfo->FvBlocks[Index].NumBlocks * FvInfo->FvBlocks[Index].BlockLength;
}
+ }
- Index++;
+ if (FvInfo->Size == (UINTN) -1 && FvInfo->FvFiles[0][0] == 0) {
//
- // Read component FV_FTW_SPARE
+ // Non FFS FV cannot set block number to AUTO
//
- Status = FindToken (InfFile, COMPONENT_SECTION_STRING, EFI_NV_FTW_SPARE_STRING, 0, Value);
-
- if (Status == EFI_SUCCESS) {
- //
- // Add the component
- //
- strcpy (FvInfo->FvComponents[Index].ComponentName, EFI_NV_FTW_SPARE_STRING);
- Status = AsciiStringToUint64 (Value, FALSE, &Value64);
- if (EFI_ERROR (Status)) {
- printf ("ERROR: %s is not a valid integer.\n", EFI_NV_FTW_SPARE_STRING);
- return EFI_ABORTED;
- }
-
- FvInfo->FvComponents[Index].Size = (UINTN) Value64;
- } else {
- printf ("WARNING: Could not read %s.\n", EFI_NV_FTW_SPARE_STRING);
- }
- }
- //
- // Compute size for easy access later
- //
- FvInfo->Size = 0;
- for (Index = 0; FvInfo->FvBlocks[Index].NumBlocks; Index++) {
- FvInfo->Size += FvInfo->FvBlocks[Index].NumBlocks * FvInfo->FvBlocks[Index].BlockLength;
+ Error (NULL, 0, 0, "non-FFS FV", "cannot set %s to %s", EFI_NUM_BLOCKS_STRING, AUTO_STRING);
+ return EFI_ABORTED;
}
return EFI_SUCCESS;
@@ -1372,7 +1336,11 @@ Returns:
PadFile->State = 0;
PadFile->IntegrityCheck.Checksum.Header = CalculateChecksum8 ((UINT8 *) PadFile, sizeof (EFI_FFS_FILE_HEADER));
if (PadFile->Attributes & FFS_ATTRIB_CHECKSUM) {
+#if (PI_SPECIFICATION_VERSION < 0x00010000)
PadFile->IntegrityCheck.Checksum.File = CalculateChecksum8 ((UINT8 *) PadFile, PadFileSize);
+#else
+ PadFile->IntegrityCheck.Checksum.File = CalculateChecksum8 ((UINT8 *) ((UINTN)PadFile + sizeof (EFI_FFS_FILE_HEADER)), PadFileSize - sizeof (EFI_FFS_FILE_HEADER));
+#endif
} else {
PadFile->IntegrityCheck.Checksum.File = FFS_FIXED_CHECKSUM;
}
@@ -1876,12 +1844,139 @@ Returns:
}
EFI_STATUS
+ReallocateFvImage (
+ IN OUT MEMORY_FILE *FvImage,
+ IN OUT FV_INFO *FvInfo,
+ IN OUT EFI_FFS_FILE_HEADER **VtfFileImage,
+ IN OUT UINTN *FvImageCapacity
+ )
+/*++
+Routine Description:
+ Increase the size of FV image by 1 block. The routine may reallocate memory
+ depending on the capacity of the FV image.
+
+Arguments:
+ FvImage The memory image of the FV to add it to. The current offset
+ must be valid.
+ FvInfo Pointer to information about the FV.
+ VtfFileImage A pointer to the VTF file within the FvImage. If this is equal
+ to the end of the FvImage then no VTF previously found.
+ FvImageCapacity Capacity of image buffer for FV.
+
+Returns:
+ EFI_SUCCESS The function completed successfully.
+ EFI_OUT_OF_RESOURCES Insufficient resources exist to complete the reallocation.
+
+--*/
+{
+ CHAR8 *FileImage;
+ UINTN OldSize;
+ UINTN IncreaseSize;
+ EFI_FIRMWARE_VOLUME_HEADER *FvHeader;
+ BOOLEAN AllocateNewMemory;
+ EFI_FFS_FILE_HEADER *NewVtfFileImage;
+ UINT32 VtfFileLength;
+ UINT8 TempByte;
+
+ OldSize = (UINTN) FvImage->Eof - (UINTN) FvImage->FileImage;
+ IncreaseSize = FvInfo->FvBlocks[0].BlockLength;
+ assert (OldSize == FvInfo->FvBlocks[0].NumBlocks * FvInfo->FvBlocks[0].BlockLength);
+
+ //
+ // Assume we have enough capacity
+ //
+ AllocateNewMemory = FALSE;
+
+
+ if (OldSize + IncreaseSize > *FvImageCapacity) {
+ AllocateNewMemory = TRUE;
+ //
+ // Increase capacity by one unit
+ //
+ *FvImageCapacity = OldSize + FV_CAPACITY_INCREASE_UNIT;
+ FileImage = malloc (*FvImageCapacity);
+
+ if (FileImage == NULL) {
+ Error (NULL, 0, 0, "memory allocation failure", NULL);
+ return EFI_OUT_OF_RESOURCES;
+ }
+
+ //
+ // Initialize the content per FV polarity
+ //
+ if (FvInfo->FvAttributes & EFI_FVB_ERASE_POLARITY) {
+ memset (FileImage, -1, *FvImageCapacity);
+ } else {
+ memset (FileImage, 0, *FvImageCapacity);
+ }
+
+ //
+ // Copy the FV content before VTF
+ //
+ memcpy (FileImage, FvImage->FileImage, (UINTN) *VtfFileImage - (UINTN) FvImage->FileImage);
+ } else {
+ FileImage = FvImage->FileImage;
+ }
+
+ //
+ // Move VTF if it exists
+ //
+ NewVtfFileImage = (EFI_FFS_FILE_HEADER *) (FileImage + ((UINTN) *VtfFileImage - (UINTN) FvImage->FileImage) + IncreaseSize);
+ if ((UINTN) *VtfFileImage != (UINTN) FvImage->Eof) {
+ //
+ // Exchange the VTF buffer from end to start for two purpose:
+ // 1. Exchange: Preserve the default value per FV polarity
+ // 2. End->Start: Avoid destroying the VTF data during exchanging
+ //
+ VtfFileLength = GetLength ((*VtfFileImage)->Size);
+ while (VtfFileLength-- != 0) {
+ TempByte = ((UINT8 *) VtfFileImage)[VtfFileLength];
+ ((UINT8 *) VtfFileImage)[VtfFileLength] = ((UINT8 *) NewVtfFileImage)[VtfFileLength];
+ ((UINT8 *) NewVtfFileImage)[VtfFileLength] = TempByte;
+ }
+ }
+
+ //
+ // Update VTF Pointer
+ //
+ *VtfFileImage = NewVtfFileImage;
+
+ //
+ // Update FvInfo
+ //
+ FvInfo->FvBlocks[0].NumBlocks ++;
+
+ //
+ // Update FV Header
+ //
+ FvHeader = (EFI_FIRMWARE_VOLUME_HEADER *) FileImage;
+ FvHeader->FvBlockMap[0].NumBlocks = FvInfo->FvBlocks[0].NumBlocks;
+ FvHeader->FvLength = OldSize + IncreaseSize;
+ FvHeader->Checksum = 0;
+ FvHeader->Checksum = CalculateChecksum16 ((UINT16 *) FvHeader, FvHeader->HeaderLength / sizeof (UINT16));
+
+ //
+ // Update FvImage
+ //
+ if (AllocateNewMemory) {
+ free (FvImage->FileImage);
+ FvImage->CurrentFilePointer = FileImage + (FvImage->CurrentFilePointer - FvImage->FileImage);
+ FvImage->FileImage = FileImage;
+ }
+ FvImage->Eof = FvImage->FileImage + OldSize + IncreaseSize;
+
+ InitializeFvLib (FvImage->FileImage, OldSize + IncreaseSize);
+ return EFI_SUCCESS;
+}
+
+EFI_STATUS
AddFile (
IN OUT MEMORY_FILE *FvImage,
IN FV_INFO *FvInfo,
IN UINTN Index,
IN OUT EFI_FFS_FILE_HEADER **VtfFileImage,
- IN OUT MEMORY_FILE *SymImage
+ IN OUT MEMORY_FILE *SymImage,
+ IN OUT UINTN *FvImageCapacity
)
/*++
@@ -1892,14 +1987,15 @@ Routine Description:
Arguments:
- FvImage The memory image of the FV to add it to. The current offset
- must be valid.
- FvInfo Pointer to information about the FV.
- Index The file in the FvInfo file list to add.
- VtfFileImage A pointer to the VTF file within the FvImage. If this is equal
- to the end of the FvImage then no VTF previously found.
- SymImage The memory image of the Sym file to update if symbols are present.
- The current offset must be valid.
+ FvImage The memory image of the FV to add it to. The current offset
+ must be valid.
+ FvInfo Pointer to information about the FV.
+ Index The file in the FvInfo file list to add.
+ VtfFileImage A pointer to the VTF file within the FvImage. If this is equal
+ to the end of the FvImage then no VTF previously found.
+ SymImage The memory image of the Sym file to update if symbols are present.
+ The current offset must be valid.
+ FvImageCapacity Capacity of image buffer for FV.
Returns:
@@ -1964,16 +2060,28 @@ Returns:
// Verify read successful
//
if (NumBytesRead != sizeof (UINT8) * FileSize) {
- free (FileBuffer);
Error (NULL, 0, 0, FvInfo->FvFiles[Index], "failed to read input file contents");
- return EFI_ABORTED;
+ Status = EFI_ABORTED;
+ goto Exit;
}
//
// Verify space exists to add the file
//
- if (FileSize > (UINTN) ((UINTN) *VtfFileImage - (UINTN) FvImage->CurrentFilePointer)) {
- Error (NULL, 0, 0, FvInfo->FvFiles[Index], "insufficient space remains to add the file");
- return EFI_OUT_OF_RESOURCES;
+ while (FileSize > (UINTN) ((UINTN) *VtfFileImage - (UINTN) FvImage->CurrentFilePointer)) {
+ if (FvInfo->Size != (UINTN) -1) {
+ Error (NULL, 0, 0, FvInfo->FvFiles[Index], "insufficient space remains to add the file");
+ Status = EFI_OUT_OF_RESOURCES;
+ goto Exit;
+ } else {
+ //
+ // FV Size is AUTO, increase by one block
+ //
+ Status = ReallocateFvImage (FvImage, FvInfo, VtfFileImage, FvImageCapacity);
+ if (EFI_ERROR (Status)) {
+ Error (NULL, 0, 0, FvInfo->FvFiles[Index], "insufficient resources to add the file");
+ goto Exit;
+ }
+ }
}
//
// Update the file state based on polarity of the FV.
@@ -2033,7 +2141,11 @@ Returns:
}
if ((*VtfFileImage)->Attributes & FFS_ATTRIB_CHECKSUM) {
+ #if (PI_SPECIFICATION_VERSION < 0x00010000)
VtfFileChecksum = CalculateChecksum8 ((UINT8 *) *VtfFileImage, FileSize - TailSize);
+ #else
+ VtfFileChecksum = CalculateChecksum8 ((UINT8 *) ((UINTN)*VtfFileImage + sizeof (EFI_FFS_FILE_HEADER)), FileSize - TailSize - sizeof(EFI_FFS_FILE_HEADER));
+ #endif
(*VtfFileImage)->IntegrityCheck.Checksum.File = VtfFileChecksum;
} else {
(*VtfFileImage)->IntegrityCheck.Checksum.File = FFS_FIXED_CHECKSUM;
@@ -2048,15 +2160,15 @@ Returns:
}
#endif
(*VtfFileImage)->State = FileState;
- free (FileBuffer);
- return EFI_SUCCESS;
+ Status = EFI_SUCCESS;
+ goto Exit;
} else {
//
// Already found a VTF file.
//
Error (NULL, 0, 0, "multiple VTF files are illegal in a single FV", NULL);
- free (FileBuffer);
- return EFI_ABORTED;
+ Status = EFI_ABORTED;
+ goto Exit;
}
}
//
@@ -2065,68 +2177,93 @@ Returns:
Status = ReadFfsAlignment ((EFI_FFS_FILE_HEADER *) FileBuffer, &CurrentFileAlignment);
if (EFI_ERROR (Status)) {
printf ("ERROR: Could not determine alignment of file %s.\n", FvInfo->FvFiles[Index]);
- free (FileBuffer);
- return EFI_ABORTED;
+ Status = EFI_ABORTED;
+ goto Exit;
}
//
// Add pad file if necessary
//
- Status = AddPadFile (FvImage, CurrentFileAlignment);
- if (EFI_ERROR (Status)) {
- printf ("ERROR: Could not align the file data properly.\n");
- free (FileBuffer);
- return EFI_ABORTED;
+ while (EFI_ERROR (AddPadFile (FvImage, CurrentFileAlignment))) {
+ if (FvInfo->Size != (UINTN) -1) {
+ printf ("ERROR: Could not align the file data properly.\n");
+ Status = EFI_ABORTED;
+ goto Exit;
+ } else {
+ //
+ // FV Size is AUTO, increase by one block
+ //
+ Status = ReallocateFvImage (FvImage, FvInfo, VtfFileImage, FvImageCapacity);
+ if (EFI_ERROR (Status)) {
+ Error (NULL, 0, 0, FvInfo->FvFiles[Index], "insufficient resources to add the file");
+ goto Exit;
+ }
+ }
}
+
//
// Add file
//
- if ((FvImage->CurrentFilePointer + FileSize) < FvImage->Eof) {
- //
- // Copy the file
- //
- memcpy (FvImage->CurrentFilePointer, FileBuffer, FileSize);
+ while (FileSize > (UINTN) ((UINTN) *VtfFileImage - (UINTN) FvImage->CurrentFilePointer)) {
+ if (FvInfo->Size != (UINTN) -1) {
+ printf ("ERROR: The firmware volume is out of space, could not add file %s.\n", FvInfo->FvFiles[Index]);
+ Status = EFI_ABORTED;
+ goto Exit;
+ } else {
+ //
+ // FV Size is AUTO, increase by one one block
+ //
+ Status = ReallocateFvImage (FvImage, FvInfo, VtfFileImage, FvImageCapacity);
+ if (EFI_ERROR (Status)) {
+ Error (NULL, 0, 0, FvInfo->FvFiles[Index], "insufficient resources to add the file");
+ goto Exit;
+ }
+ }
+ }
- //
- // If the file is XIP, rebase
- //
- CurrentFileBaseAddress = FvInfo->BaseAddress + ((UINTN) FvImage->CurrentFilePointer - (UINTN) FvImage->FileImage);
- //
- // Status = RebaseFfsFile ((EFI_FFS_FILE_HEADER*) FvImage->CurrentFilePointer, CurrentFileBaseAddress);
- // if (EFI_ERROR(Status)) {
- // printf ("ERROR: Could not rebase the file %s.\n", FvInfo->FvFiles[Index]);
- // return EFI_ABORTED;
- // }
- //
- // Update Symbol file
- //
- Status = AddSymFile (
- CurrentFileBaseAddress,
- (EFI_FFS_FILE_HEADER *) FvImage->CurrentFilePointer,
- SymImage,
- FvInfo->FvFiles[Index]
- );
- assert (!EFI_ERROR (Status));
+ //
+ // Copy the file
+ //
+ memcpy (FvImage->CurrentFilePointer, FileBuffer, FileSize);
+
+ //
+ // If the file is XIP, rebase
+ //
+ CurrentFileBaseAddress = FvInfo->BaseAddress + ((UINTN) FvImage->CurrentFilePointer - (UINTN) FvImage->FileImage);
+ //
+ // Status = RebaseFfsFile ((EFI_FFS_FILE_HEADER*) FvImage->CurrentFilePointer, CurrentFileBaseAddress);
+ // if (EFI_ERROR(Status)) {
+ // printf ("ERROR: Could not rebase the file %s.\n", FvInfo->FvFiles[Index]);
+ // return EFI_ABORTED;
+ // }
+ //
+ // Update Symbol file
+ //
+ Status = AddSymFile (
+ CurrentFileBaseAddress,
+ (EFI_FFS_FILE_HEADER *) FvImage->CurrentFilePointer,
+ SymImage,
+ FvInfo->FvFiles[Index]
+ );
+ assert (!EFI_ERROR (Status));
+
+ //
+ // Update the current pointer in the FV image
+ //
+ FvImage->CurrentFilePointer += FileSize;
- //
- // Update the current pointer in the FV image
- //
- FvImage->CurrentFilePointer += FileSize;
- } else {
- printf ("ERROR: The firmware volume is out of space, could not add file %s.\n", FvInfo->FvFiles[Index]);
- return EFI_ABORTED;
- }
//
// Make next file start at QWord Boundry
//
while (((UINTN) FvImage->CurrentFilePointer & 0x07) != 0) {
FvImage->CurrentFilePointer++;
}
+
+Exit:
//
// Free allocated memory.
//
free (FileBuffer);
-
- return EFI_SUCCESS;
+ return Status;
}
EFI_STATUS
@@ -2250,8 +2387,7 @@ Returns:
} else if (_stricmp (FvInfo->FvComponents[Index].ComponentName, EFI_NV_FTW_SPARE_STRING) == 0) {
AddFTWSpareBlock (FvImage, FvInfo->FvComponents[Index].Size, FvInfo);
} else {
- printf ("Error. Unknown Non-FFS block %s \n", FvInfo->FvComponents[Index].ComponentName);
- return EFI_ABORTED;
+ printf ("Warning: Unknown Non-FFS block %s \n", FvInfo->FvComponents[Index].ComponentName);
}
FvImage = FvImage + FvInfo->FvComponents[Index].Size;
@@ -2332,7 +2468,11 @@ Returns:
PadFile->State = 0;
PadFile->IntegrityCheck.Checksum.Header = CalculateChecksum8 ((UINT8 *) PadFile, sizeof (EFI_FFS_FILE_HEADER));
if (PadFile->Attributes & FFS_ATTRIB_CHECKSUM) {
+#if (PI_SPECIFICATION_VERSION < 0x00010000)
PadFile->IntegrityCheck.Checksum.File = CalculateChecksum8 ((UINT8 *) PadFile, FileSize);
+#else
+ PadFile->IntegrityCheck.Checksum.File = CalculateChecksum8 ((UINT8 *) ((UINTN) PadFile + sizeof (EFI_FFS_FILE_HEADER)), FileSize - sizeof (EFI_FFS_FILE_HEADER));
+#endif
} else {
PadFile->IntegrityCheck.Checksum.File = FFS_FIXED_CHECKSUM;
}
@@ -2611,10 +2751,18 @@ Returns:
VtfFile->IntegrityCheck.Checksum.File = 0;
VtfFile->State = 0;
if (VtfFile->Attributes & FFS_ATTRIB_CHECKSUM) {
+#if (PI_SPECIFICATION_VERSION < 0x00010000)
VtfFile->IntegrityCheck.Checksum.File = CalculateChecksum8 (
(UINT8 *) VtfFile,
GetLength (VtfFile->Size) - TailSize
);
+
+#else
+ VtfFile->IntegrityCheck.Checksum.File = CalculateChecksum8 (
+ (UINT8 *) ((UINTN)VtfFile + sizeof (EFI_FFS_FILE_HEADER)),
+ GetLength (VtfFile->Size) - TailSize - sizeof (EFI_FFS_FILE_HEADER)
+ );
+#endif
} else {
VtfFile->IntegrityCheck.Checksum.File = FFS_FIXED_CHECKSUM;
}
@@ -2780,6 +2928,7 @@ Returns:
UINTN Index;
EFI_FIRMWARE_VOLUME_HEADER *FvHeader;
EFI_FFS_FILE_HEADER *VtfFileImage;
+ UINTN FvImageCapacity;
//
// Check for invalid parameter
@@ -2811,12 +2960,22 @@ Returns:
//
// Calculate the FV size
//
- *FvImageSize = FvInfo.Size;
+ if (FvInfo.Size != (UINTN) -1) {
+ *FvImageSize = FvInfo.Size;
+ FvImageCapacity = FvInfo.Size;
+ } else {
+ //
+ // For auto size, set default as one block
+ //
+ FvInfo.FvBlocks[0].NumBlocks = 1;
+ *FvImageSize = FvInfo.FvBlocks[0].BlockLength;
+ FvImageCapacity = FV_CAPACITY_INCREASE_UNIT;
+ }
//
// Allocate the FV
//
- *FvImage = malloc (*FvImageSize);
+ *FvImage = malloc (FvImageCapacity);
if (*FvImage == NULL) {
return EFI_OUT_OF_RESOURCES;
}
@@ -2831,9 +2990,9 @@ Returns:
// Initialize the FV to the erase polarity
//
if (FvInfo.FvAttributes & EFI_FVB_ERASE_POLARITY) {
- memset (*FvImage, -1, *FvImageSize);
+ memset (*FvImage, -1, FvImageCapacity);
} else {
- memset (*FvImage, 0, *FvImageSize);
+ memset (*FvImage, 0, FvImageCapacity);
}
//
// Initialize FV header
@@ -2913,7 +3072,7 @@ Returns:
//
// Initialize the FV library.
//
- InitializeFvLib (FvImageMemoryFile.FileImage, FvInfo.Size);
+ InitializeFvLib (FvImageMemoryFile.FileImage, *FvImageSize);
//
// Files start on 8 byte alignments, so move to the next 8 byte aligned
@@ -2935,7 +3094,15 @@ Returns:
//
// Add the file
//
- Status = AddFile (&FvImageMemoryFile, &FvInfo, Index, &VtfFileImage, &SymImageMemoryFile);
+ Status = AddFile (&FvImageMemoryFile, &FvInfo, Index, &VtfFileImage, &SymImageMemoryFile, &FvImageCapacity);
+
+ //
+ // Update FvImageSize and FvImage as they may be changed in AddFile routine
+ //
+ if (FvInfo.Size == (UINTN) -1) {
+ *FvImageSize = FvInfo.FvBlocks[0].NumBlocks * FvInfo.FvBlocks[0].BlockLength;
+ *FvImage = FvImageMemoryFile.FileImage;
+ }
//
// Exit if error detected while adding the file
@@ -2966,7 +3133,7 @@ Returns:
// reset vector. If the PEI Core is found, the VTF file will probably get
// corrupted by updating the entry point.
//
- if ((FvInfo.BaseAddress + FvInfo.Size) == FV_IMAGES_TOP_ADDRESS) {
+ if ((FvInfo.BaseAddress + *FvImageSize) == FV_IMAGES_TOP_ADDRESS) {
Status = UpdateResetVector (&FvImageMemoryFile, &FvInfo, VtfFileImage);
if (EFI_ERROR(Status)) {
printf ("ERROR: Could not update the reset vector.\n");
@@ -2974,7 +3141,7 @@ Returns:
return EFI_ABORTED;
}
}
- }
+ }
//
// Determine final Sym file size
//
diff --git a/EdkCompatibilityPkg/Sample/Tools/Source/GenFvImage/GenFvImageLibInternal.h b/EdkCompatibilityPkg/Sample/Tools/Source/GenFvImage/GenFvImageLibInternal.h
index c8e63e83d1..7b8ab11413 100644
--- a/EdkCompatibilityPkg/Sample/Tools/Source/GenFvImage/GenFvImageLibInternal.h
+++ b/EdkCompatibilityPkg/Sample/Tools/Source/GenFvImage/GenFvImageLibInternal.h
@@ -1,6 +1,6 @@
/*++
-Copyright (c) 2004 - 2007, 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
@@ -44,6 +44,8 @@ Abstract:
#define MAX_NUMBER_OF_FILES_IN_FV 1000
#define MAX_NUMBER_OF_COMPONENTS_IN_FV 10
+#define FV_CAPACITY_INCREASE_UNIT 0x100000
+
//
// INF file strings
//
@@ -150,6 +152,7 @@ Abstract:
#define TRUE_STRING "TRUE"
#define FALSE_STRING "FALSE"
#define NULL_STRING "NULL"
+#define AUTO_STRING "AUTO"
//
// Defines to calculate the offset for PEI CORE entry points
@@ -206,6 +209,7 @@ EFI_STATUS
ParseFvInf (
IN MEMORY_FILE *InfFile,
IN FV_INFO *FvInfo
- );
+ )
+;
#endif
diff --git a/EdkCompatibilityPkg/Sample/Tools/Source/GenSection/GenSection.c b/EdkCompatibilityPkg/Sample/Tools/Source/GenSection/GenSection.c
index 1d1c307e87..fd367c3d62 100644
--- a/EdkCompatibilityPkg/Sample/Tools/Source/GenSection/GenSection.c
+++ b/EdkCompatibilityPkg/Sample/Tools/Source/GenSection/GenSection.c
@@ -1,6 +1,6 @@
/*++
-Copyright (c) 2004 - 2007, 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
@@ -35,6 +35,7 @@ Abstract:
#include EFI_PROTOCOL_DEFINITION (GuidedSectionExtraction)
#define UTILITY_NAME "GenSection"
+#define UTILITY_VERSION "v1.0"
#define PARAMETER_NOT_SPECIFIED "Parameter not specified"
#define MAXIMUM_INPUT_FILE_NUM 10
@@ -81,37 +82,52 @@ PrintUsageMessage (
VOID
)
{
- UINTN SectionType;
- UINTN DisplayCount;
-
- printf ("Usage: "UTILITY_NAME " -i InputFile -o OutputFile -s SectionType [SectionType params]\n\n");
- printf (" Where SectionType is one of the following section types:\n\n");
+ UINTN SectionType;
+ int Index;
+ const char *Str[] = {
+ UTILITY_NAME" "UTILITY_VERSION" - Intel Generate Section Utility",
+ " Copyright (C), 2004 - 2008 Intel Corporation",
+
+#if ( defined(UTILITY_BUILD) && defined(UTILITY_VENDOR) )
+ " Built from "UTILITY_BUILD", project of "UTILITY_VENDOR,
+#endif
+ "",
+ "Usage:",
+ " "UTILITY_NAME" [OPTION]",
+ "Common Options:",
+ " -i InputFile Specifies the input file",
+ " -o OutputFile Specifies the output file",
+ " -s SectionType Specifies the type of the section, which can be one of",
+ NULL
+ };
+
+ for (Index = 0; Str[Index] != NULL; Index++) {
+ fprintf (stdout, "%s\n", Str[Index]);
+ }
- DisplayCount = 0;
for (SectionType = 0; SectionType <= EFI_SECTION_LAST_SECTION_TYPE; SectionType++) {
if (SectionTypeName[SectionType] != NULL) {
- printf (" %s\n", SectionTypeName[SectionType]);
+ fprintf (stdout, " %s\n", SectionTypeName[SectionType]);
}
}
-
- printf ("\n and SectionType dependent parameters are as follows:\n\n");
- printf (
- " %s: -t < %s | %s >\n",
+ fprintf (stdout, "Section dependent options:\n");
+ fprintf (stdout,
+ " %s: -t < %s | %s >\n",
SectionTypeName[EFI_SECTION_COMPRESSION],
CompressionTypeName[EFI_NOT_COMPRESSED],
CompressionTypeName[EFI_STANDARD_COMPRESSION]
);
- printf (
- " %s: -t < %s >\n"" // Currently only CRC32 is supported\n\n",
+ fprintf (stdout,
+ " %s: -t < %s > // Only CRC32 is supported\n",
SectionTypeName[EFI_SECTION_GUID_DEFINED],
GUIDedSectionTypeName[EFI_SECTION_CRC32_GUID_DEFINED]
);
printf (
- " %s: -v VersionNumber\n"" [-a \"Version string\"]\n\n",
+ " %s: -v VersionNumber [-a \"Version string\"]\n",
SectionTypeName[EFI_SECTION_VERSION]
);
printf (
- " %s: -a \"Human readable name\"\n\n",
+ " %s: -a \"Human readable name\"\n",
SectionTypeName[EFI_SECTION_USER_INTERFACE]
);
}
diff --git a/EdkCompatibilityPkg/Sample/Tools/Source/GenTEImage/GenTEImage.c b/EdkCompatibilityPkg/Sample/Tools/Source/GenTEImage/GenTEImage.c
index f9988257f1..178e9322aa 100644
--- a/EdkCompatibilityPkg/Sample/Tools/Source/GenTEImage/GenTEImage.c
+++ b/EdkCompatibilityPkg/Sample/Tools/Source/GenTEImage/GenTEImage.c
@@ -1,6 +1,6 @@
/*++
-Copyright (c) 1999 - 2007, Intel Corporation. All rights reserved.<BR>
+Copyright (c) 1999 - 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
@@ -33,7 +33,7 @@ Abstract:
// Version of this utility
//
#define UTILITY_NAME "GenTEImage"
-#define UTILITY_VERSION "v0.11"
+#define UTILITY_VERSION "v1.0"
//
// Define the max length of a filename
@@ -767,23 +767,28 @@ Returns:
--*/
{
- int Index;
- static const char *Msg[] = {
- UTILITY_NAME " version "UTILITY_VERSION " - TE image utility",
- " Generate a TE image from an EFI PE32 image",
- " Usage: "UTILITY_NAME " {-v} {-dump} {-h|-?} {-o OutFileName} InFileName",
- " [-e|-b] [FileName(s)]",
- " where:",
- " -v - for verbose output",
- " -dump - to dump the input file to a text file",
- " -h -? - for this help information",
- " -o OutFileName - to write output to OutFileName rather than InFileName"DEFAULT_OUTPUT_EXTENSION,
- " InFileName - name of the input PE32 file",
+ int Index;
+ const char *Str[] = {
+ UTILITY_NAME" "UTILITY_VERSION" - Intel Generate TE Image Utility",
+ " Copyright (C), 1999 - 2008 Intel Corporation",
+
+#if ( defined(UTILITY_BUILD) && defined(UTILITY_VENDOR) )
+ " Built from "UTILITY_BUILD", project of "UTILITY_VENDOR,
+#endif
"",
+ "Usage:",
+ " "UTILITY_NAME" [OPTION]... PE32IMAGE",
+ "Description:",
+ " Generate a TE image from an EFI PE32 image.",
+ "Options:",
+ " -v - for verbose output",
+ " -dump - to dump the input file to a text file",
+ " -h -? - for this help information",
+ " -o OutFileName - to write output to OutFileName rather than PE32IMAGE"DEFAULT_OUTPUT_EXTENSION,
NULL
};
- for (Index = 0; Msg[Index] != NULL; Index++) {
- fprintf (stdout, "%s\n", Msg[Index]);
+ for (Index = 0; Str[Index] != NULL; Index++) {
+ fprintf (stdout, "%s\n", Str[Index]);
}
}
diff --git a/EdkCompatibilityPkg/Sample/Tools/Source/GuidChk/GuidChk.c b/EdkCompatibilityPkg/Sample/Tools/Source/GuidChk/GuidChk.c
index 7b9aa041c5..f1084a3cd9 100644
--- a/EdkCompatibilityPkg/Sample/Tools/Source/GuidChk/GuidChk.c
+++ b/EdkCompatibilityPkg/Sample/Tools/Source/GuidChk/GuidChk.c
@@ -1,6 +1,6 @@
/*++
-Copyright (c) 2004 - 2007, 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
@@ -38,6 +38,9 @@ Abstract:
#define MAX_PATH 1024
#endif
+#define UTILITY_NAME "GuidChk"
+#define UTILITY_VERSION "v1.0"
+
typedef struct {
INT8 *Extension;
INT8 ExtensionCode;
@@ -593,25 +596,32 @@ Usage (
VOID
)
{
- int Index;
- char *Str[] = {
- "GuidChk - scan files for duplicate GUID or signature definitions",
- "",
- "Usage: GuidChk {options}\n",
- " Options: ",
- " -d dirname exclude searching of a directory",
- " -f filename exclude searching of a file",
- " -e extension exclude searching of files by extension",
- " -p print all GUIDS found",
- " -g check for duplicate guids",
- " -s check for duplicate signatures",
- " -x print guid+defined symbol name",
- " -b outfile write internal GUID+basename list to outfile",
- " -u dirname exclude searching all subdirectories of a directory",
- " -h -? print this help text",
- " ",
- " Example: GuidChk -g -u build -d fv -f make.inf -e .pkg",
+ int Index;
+ const char *Str[] = {
+ UTILITY_NAME" "UTILITY_VERSION" - Intel GUID Check Utility",
+ " Copyright (C), 2004 - 2008 Intel Corporation",
+
+#if ( defined(UTILITY_BUILD) && defined(UTILITY_VENDOR) )
+ " Built from "UTILITY_BUILD", project of "UTILITY_VENDOR,
+#endif
"",
+ "Usage:",
+ " "UTILITY_NAME" [OPTION]...",
+ "Description:",
+ " Scan files for duplicate GUID or signature definitions.",
+ "Options:",
+ " -d dirname exclude searching of a directory",
+ " -f filename exclude searching of a file",
+ " -e extension exclude searching of files by extension",
+ " -p print all GUIDS found",
+ " -g check for duplicate guids",
+ " -s check for duplicate signatures",
+ " -x print guid+defined symbol name",
+ " -b outfile write internal GUID+basename list to outfile",
+ " -u dirname exclude searching all subdirectories of a directory",
+ " -h -? print this help text",
+ "Example Usage:",
+ " GuidChk -g -u build -d fv -f make.inf -e .pkg",
NULL
};
for (Index = 0; Str[Index] != NULL; Index++) {
diff --git a/EdkCompatibilityPkg/Sample/Tools/Source/HiiPack/FindFiles.c b/EdkCompatibilityPkg/Sample/Tools/Source/HiiPack/FindFiles.c
new file mode 100644
index 0000000000..b63a1f8347
--- /dev/null
+++ b/EdkCompatibilityPkg/Sample/Tools/Source/HiiPack/FindFiles.c
@@ -0,0 +1,208 @@
+/*++
+
+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:
+
+ FindFiles.c
+
+Abstract:
+
+ OS-specific functions to assist in finding files in
+ subdirectories.
+
+--*/
+
+#include <windows.h>
+#include <direct.h>
+//
+// #include <io.h> // for _chmod()
+//
+#include <sys/stat.h>
+//
+// #include <errno.h> // for errno
+//
+#include <stdio.h>
+#include <string.h>
+#include <stdlib.h>
+#include <ctype.h>
+
+#include "HiiPack.h"
+
+extern
+void
+Error (
+ char *Name,
+ UINT32 LineNumber,
+ UINT32 MessageCode,
+ char *Text,
+ char *MsgFmt,
+ ...
+ );
+
+static
+int
+ProcessDirectory (
+ char *RootDirectory,
+ char *FileMask,
+ FIND_FILE_CALLBACK Callback
+ );
+
+/*****************************************************************************/
+int
+FindFiles (
+ char *RootDirectory,
+ char *FileMask,
+ FIND_FILE_CALLBACK Callback
+ )
+/*++
+
+Routine Description:
+ Find files of a given name under a root directory
+
+Arguments:
+ RootDirectory - base directory -- look in this directory and
+ all its subdirectories for files matching FileMask.
+ FileMask - file mask of files to find
+ Callback - function to call for each file found
+
+Returns:
+
+--*/
+{
+ char FullPath[MAX_PATH];
+ //
+ // If RootDirectory is relative, then append to cwd.
+ //
+ if (isalpha (RootDirectory[0]) && (RootDirectory[1] == ':')) {
+ strcpy (FullPath, RootDirectory);
+ } else {
+ //
+ // Get current working directory
+ //
+ if (_getcwd (FullPath, sizeof (FullPath)) == NULL) {
+ Error (NULL, 0, 0, "failed to get current working directory", NULL);
+ return 1;
+ }
+ //
+ // Append the relative path they passed in
+ //
+ if (FullPath[strlen (FullPath) - 1] != '\\') {
+ strcat (FullPath, "\\");
+ }
+
+ strcat (FullPath, RootDirectory);
+ }
+
+ if (FullPath[strlen (FullPath) - 1] == '\\') {
+ FullPath[strlen (FullPath) - 1] = 0;
+ }
+ //
+ // Process the directory
+ //
+ return ProcessDirectory (FullPath, FileMask, Callback);
+}
+
+static
+int
+ProcessDirectory (
+ char *RootDirectory,
+ char *FileMask,
+ FIND_FILE_CALLBACK Callback
+ )
+/*++
+
+Routine Description:
+ Process a directory to find all files matching a given file mask
+
+Arguments:
+ RootDirectory - base directory -- look in this directory and
+ all its subdirectories for files matching FileMask.
+ FileMask - file mask of files to find
+ Callback - function to call for each file found
+
+Returns:
+
+--*/
+{
+ HANDLE Handle;
+ WIN32_FIND_DATA FindData;
+ char TempName[MAX_PATH];
+
+ Handle = INVALID_HANDLE_VALUE;
+ //
+ // Concatenate the filemask to the directory to create the full
+ // path\mask path name.
+ //
+ strcpy (TempName, RootDirectory);
+ strcat (TempName, "\\");
+ strcat (TempName, FileMask);
+ memset (&FindData, 0, sizeof (FindData));
+ Handle = FindFirstFile (TempName, &FindData);
+ if (Handle != INVALID_HANDLE_VALUE) {
+ do {
+ if ((FindData.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY) == 0) {
+ strcpy (TempName, RootDirectory);
+ strcat (TempName, "\\");
+ strcat (TempName, FindData.cFileName);
+ if (Callback (TempName) != 0) {
+ goto Done;
+ }
+ }
+ } while (FindNextFile (Handle, &FindData));
+ }
+
+ if (Handle != INVALID_HANDLE_VALUE) {
+ FindClose (Handle);
+ Handle = INVALID_HANDLE_VALUE;
+ }
+ //
+ // Now create a *.* file mask to get all subdirectories and recursive call this
+ // function to handle each one found.
+ //
+ strcpy (TempName, RootDirectory);
+ strcat (TempName, "\\*.*");
+ memset (&FindData, 0, sizeof (FindData));
+ Handle = FindFirstFile (TempName, &FindData);
+ //
+ // Loop until no more files/directories
+ //
+ if (Handle != INVALID_HANDLE_VALUE) {
+ do {
+ if (FindData.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY) {
+ //
+ // Make sure it's not "." or ".."
+ //
+ if ((strcmp (FindData.cFileName, ".") != 0) && (strcmp (FindData.cFileName, "..") != 0)) {
+ //
+ // Found a valid directory. Put it all together and make a recursive call
+ // to process it.
+ //
+ strcpy (TempName, RootDirectory);
+ strcat (TempName, "\\");
+ strcat (TempName, FindData.cFileName);
+ if (ProcessDirectory (TempName, FileMask, Callback) != 0) {
+ goto Done;
+ }
+ }
+ }
+ } while (FindNextFile (Handle, &FindData));
+ }
+
+Done:
+ //
+ // Free the handle
+ //
+ if (Handle != INVALID_HANDLE_VALUE) {
+ FindClose (Handle);
+ }
+
+ return 0;
+}
diff --git a/EdkCompatibilityPkg/Sample/Tools/Source/HiiPack/HiiPack.c b/EdkCompatibilityPkg/Sample/Tools/Source/HiiPack/HiiPack.c
new file mode 100644
index 0000000000..70b88279d2
--- /dev/null
+++ b/EdkCompatibilityPkg/Sample/Tools/Source/HiiPack/HiiPack.c
@@ -0,0 +1,2561 @@
+/*++
+
+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:
+
+ HiiPack.c
+
+Abstract:
+
+ Process HII export and pack files and create HII export files,
+ dumps, or variable defaults packs.
+
+--*/
+
+#include <stdio.h>
+#include <string.h>
+#include <stdlib.h>
+#include <ctype.h>
+
+#include "Tiano.h"
+#include "EfiUtilityMsgs.h"
+#include "ParseInf.h"
+#include "EfiInternalFormRepresentation.h"
+#include "HiiPack.h"
+#include "Hii.h"
+#include "IfrParse.h"
+#include "StringParse.h"
+
+#define UTILITY_VERSION "v1.0"
+#define UTILITY_NAME "HiiPack"
+#define MAX_PATH 260
+
+//
+// We may have to create an empty IFR formset to provide a GUID for an HII
+// export pack. Create a structure definition to make it easier.
+//
+#pragma pack(1)
+
+typedef struct {
+ EFI_HII_IFR_PACK PackHeader;
+ EFI_IFR_FORM_SET Formset;
+ EFI_IFR_END_FORM_SET EndFormset;
+} EMPTY_FORMSET_PACK;
+
+#pragma pack()
+//
+// We'll store lists of file names from the command line in
+// a linked list of these
+//
+typedef struct _FILE_NAME_LIST {
+ struct _FILE_NAME_LIST *Next;
+ UINT8 FileName[MAX_PATH];
+ int Tag; // used for whatever
+} FILE_NAME_LIST;
+
+//
+// When merging HII export packs, we save HII data table headers in a linked
+// list of these.
+//
+typedef struct _DATA_TABLE_HEADER_LIST {
+ struct _DATA_TABLE_HEADER_LIST *Next;
+ EFI_HII_DATA_TABLE DataTableHeader;
+} DATA_TABLE_HEADER_LIST;
+//
+// Create some defines for the different operation modes supported by this utility
+//
+#define MODE_CREATE_HII_EXPORT 1
+#define MODE_MERGE_HII_EXPORTS 2
+#define MODE_EMIT_DEFAULTS 3
+#define MODE_DUMP_HII_EXPORT 4
+//
+// Here's all our globals.
+//
+static struct {
+ FILE_NAME_LIST *PackFileNames; // Input HII pack file names
+ FILE_NAME_LIST *HiiExportFileNames; // Input files when merging
+ CHAR8 OutputFileName[MAX_PATH]; // Output dump file
+ BOOLEAN MfgFlag; // From -mfg command line arg
+ BOOLEAN NoEmptyVarPacks; // From -noemptyvarpacks command line arg
+ BOOLEAN NoVarPacks; // From -novarpacks command line arg
+ EFI_GUID Guid; // Guid specified on command line
+ BOOLEAN GuidSpecified;
+ BOOLEAN DumpStrings; // In dump mode, dump string data
+ int Verbose;
+ int Mode; // Mode this utility is operating in
+} mGlobals;
+
+static
+void
+Usage (
+ VOID
+ );
+
+static
+STATUS
+ProcessArgs (
+ int Argc,
+ char *Argv[]
+ );
+
+static
+STATUS
+DumpHiiExportFile (
+ char *HiiExportFileName,
+ char *OutputFileName
+ );
+
+static
+void
+DumpString (
+ FILE *OutFptr,
+ int StringIndex,
+ CHAR16 *Str,
+ int Indent
+ );
+
+static
+void
+DumpStringPack (
+ FILE *OutFptr,
+ EFI_HII_STRING_PACK *Pack,
+ int BaseOffset,
+ int Indent
+ );
+
+static
+void
+DumpVariablePacks (
+ FILE *OutFptr,
+ EFI_HII_VARIABLE_PACK *Pack,
+ int NumPacks,
+ int BaseOffset,
+ int Indent
+ );
+
+static
+void
+TestDumpHiiPack (
+ FILE *OutFptr,
+ char *BufferStart,
+ int BufferSize
+ );
+
+static
+void
+DumpRawBytes (
+ FILE *OutFptr,
+ char *Buffer,
+ int Count,
+ int BaseOffset,
+ int Indent
+ );
+
+static
+void
+DumpIfrPack (
+ FILE *OutFptr,
+ EFI_HII_IFR_PACK *Pack,
+ int BaseOffset,
+ int Indent
+ );
+
+static
+void
+FreeGlobals (
+ VOID
+ );
+
+static
+STATUS
+AddStringPack (
+ EFI_HII_STRING_PACK *PackHeader
+ );
+
+static
+STATUS
+ProcessHiiExportFile (
+ char *FileName,
+ int MfgDefaults
+ );
+
+static
+STATUS
+ProcessIfrFiles (
+ FILE_NAME_LIST *FileName
+ );
+
+static
+STATUS
+EmitDefaults (
+ FILE_NAME_LIST *HiiExportFiles,
+ int MfgDefaults,
+ int NoEmptyVarPacks
+ );
+
+static
+STATUS
+MergeHiiExports (
+ FILE_NAME_LIST *HiiExportFiles,
+ char *OutputFileName,
+ int MfgDefaults,
+ int NoEmptyVarPacks
+ );
+
+void
+GuidToString (
+ EFI_GUID *Guid,
+ char *Str
+ );
+
+static
+CHAR16 *
+AsciiToWchar (
+ CHAR8 *Str
+ );
+
+static
+STATUS
+CreateHiiExport (
+ char *OutputFileName,
+ EFI_GUID *DummyFormsetGuid,
+ FILE_NAME_LIST *PackFiles,
+ int MfgDefaults
+ );
+
+int
+main (
+ int Argc,
+ char *Argv[]
+ )
+/*++
+
+Routine Description:
+
+ Call the routine to parse the command-line options, then process the file.
+
+Arguments:
+
+ Standard C main() argc and argv.
+
+Returns:
+
+ 0 if successful
+ nonzero otherwise
+
+--*/
+// GC_TODO: Argc - add argument and description to function comment
+// GC_TODO: ] - add argument and description to function comment
+{
+ STATUS Status;
+ //
+ // Set the utility name for error reporting purposes
+ //
+ SetUtilityName (UTILITY_NAME);
+ //
+ // Process the command-line arguments
+ //
+ Status = ProcessArgs (Argc, Argv);
+ if (Status != STATUS_SUCCESS) {
+ return Status;
+ }
+ //
+ // Switch based on whether we're dumping, merging, etc.
+ //
+ if (mGlobals.Mode == MODE_DUMP_HII_EXPORT) {
+ if (mGlobals.Verbose) {
+ fprintf (stdout, "Dumping HII export file %s => %s\n", mGlobals.HiiExportFileNames, mGlobals.OutputFileName);
+ }
+
+ DumpHiiExportFile (mGlobals.HiiExportFileNames->FileName, mGlobals.OutputFileName);
+ } else if (mGlobals.Mode == MODE_CREATE_HII_EXPORT) {
+ CreateHiiExport (mGlobals.OutputFileName, &mGlobals.Guid, mGlobals.PackFileNames, mGlobals.MfgFlag);
+ } else if (mGlobals.Mode == MODE_MERGE_HII_EXPORTS) {
+ MergeHiiExports (mGlobals.HiiExportFileNames, mGlobals.OutputFileName, mGlobals.MfgFlag, mGlobals.NoEmptyVarPacks);
+ } else if (mGlobals.Mode == MODE_EMIT_DEFAULTS) {
+ EmitDefaults (mGlobals.HiiExportFileNames, mGlobals.MfgFlag, mGlobals.NoEmptyVarPacks);
+ }
+ //
+ //
+ FreeGlobals ();
+ IfrParseEnd ();
+ StringEnd ();
+ return GetUtilityStatus ();
+}
+
+/******************************************************************************/
+static
+STATUS
+MergeHiiExports (
+ FILE_NAME_LIST *HiiExportFiles,
+ char *OutputFileName,
+ int MfgDefaults,
+ int NoEmptyVarPacks
+ )
+/*++
+
+Routine Description:
+
+ Given a linked list of input HII export pack files, read in the contents
+ of each and create a single HII export pack that contains the contents
+ of all the input files.
+
+Arguments:
+
+ HiiExportFiles - pointer to linked list of input HII export pack file names
+ OutputFileName - name of output (merged) HII export file
+ MfgDefaults - non-zero to emit manufacturing defaults in output file
+ NoEmptyVarPacks - non-zero to not emit 0-length variable packs to the output file
+
+Returns:
+
+ STATUS_SUCCESS - if successful
+ STATUS_ERROR - otherwise
+
+--*/
+{
+ EFI_HII_HANDLE HiiHandle;
+ FILE *OutFptr;
+ FILE *InFptr;
+ STATUS Status;
+ CHAR8 *Buffer;
+ int FileSize;
+ int DataTableIndex;
+ int Count;
+ int NumDataTables;
+ EFI_HII_EXPORT_TABLE *HiiExportTableHeader;
+ EFI_HII_EXPORT_TABLE TempHiiExportTableHeader;
+ EFI_HII_DATA_TABLE *DataTableHeader;
+ EFI_HII_STRING_PACK *StringPack;
+ EFI_HII_VARIABLE_PACK *VarPack;
+ EFI_HII_IFR_PACK *IfrPack;
+ EFI_GUID HiiExportRevisionGuid = EFI_HII_PROTOCOL_GUID;
+ EFI_GUID PackageGuid;
+ EFI_GUID FormsetGuid;
+ long DataTableHeaderOffset;
+ DATA_TABLE_HEADER_LIST *DataTableList;
+ DATA_TABLE_HEADER_LIST *LastDataTable;
+ DATA_TABLE_HEADER_LIST *TempDataTable;
+ //
+ // Init locals
+ //
+ HiiHandle = FIRST_HII_PACK_HANDLE;
+ Buffer = NULL;
+ InFptr = NULL;
+ OutFptr = NULL;
+ Status = STATUS_ERROR;
+ DataTableList = NULL;
+ LastDataTable = NULL;
+ //
+ // Initialize our IFR parser and string routines
+ //
+ IfrParseInit ();
+ StringInit ();
+ //
+ // Process each input HII export file
+ //
+ NumDataTables = 0;
+ while (HiiExportFiles != NULL) {
+ if (mGlobals.Verbose) {
+ fprintf (stdout, "Processing file %s\n", HiiExportFiles->FileName);
+ }
+ //
+ // Read in the entire file contents
+ //
+ if ((InFptr = fopen (HiiExportFiles->FileName, "rb")) == NULL) {
+ Error (NULL, 0, 0, HiiExportFiles->FileName, "failed to open HII export file for reading");
+ goto Done;
+ }
+
+ fseek (InFptr, 0, SEEK_END);
+ FileSize = (int) ftell (InFptr);
+ fseek (InFptr, 0, SEEK_SET);
+ Buffer = (CHAR8 *) malloc (FileSize);
+ if (Buffer == NULL) {
+ Error (NULL, 0, 0, "memory allocation failure", NULL);
+ goto Done;
+ }
+
+ if (fread (Buffer, FileSize, 1, InFptr) != 1) {
+ Error (NULL, 0, 0, HiiExportFiles->FileName, "failed to read file contents");
+ goto Done;
+ }
+
+ fclose (InFptr);
+ InFptr = NULL;
+ HiiExportTableHeader = (EFI_HII_EXPORT_TABLE *) Buffer;
+ //
+ // Walk all the data tables
+ //
+ DataTableHeader = (EFI_HII_DATA_TABLE *) (HiiExportTableHeader + 1);
+ for (DataTableIndex = 0; DataTableIndex < (int) HiiExportTableHeader->NumberOfHiiDataTables; DataTableIndex++) {
+ NumDataTables++;
+ //
+ // Make sure we're still pointing into our buffer
+ //
+ if (((char *) DataTableHeader < Buffer) || ((char *) DataTableHeader > Buffer + FileSize)) {
+ Error (NULL, 0, 0, "bad data table size in input file", NULL);
+ goto Done;
+ }
+ //
+ // Save a copy of the data table header
+ //
+ TempDataTable = (DATA_TABLE_HEADER_LIST *) malloc (sizeof (DATA_TABLE_HEADER_LIST));
+ if (TempDataTable == NULL) {
+ Error (NULL, 0, 0, "memory allocation failure", NULL);
+ goto Done;
+ }
+
+ memset ((void *) TempDataTable, 0, sizeof (DATA_TABLE_HEADER_LIST));
+ memcpy (&TempDataTable->DataTableHeader, DataTableHeader, sizeof (EFI_HII_DATA_TABLE));
+ if (DataTableList == NULL) {
+ DataTableList = TempDataTable;
+ } else {
+ LastDataTable->Next = TempDataTable;
+ }
+
+ LastDataTable = TempDataTable;
+ //
+ // If there is an IFR pack, parse it
+ //
+ if (DataTableHeader->IfrDataOffset != 0) {
+ if (IfrParsePack (
+ HiiHandle,
+ (EFI_HII_IFR_PACK *) ((char *) DataTableHeader + DataTableHeader->IfrDataOffset),
+ &DataTableHeader->PackageGuid
+ ) != STATUS_SUCCESS
+ ) {
+ goto Done;
+ }
+ }
+ //
+ // If there is string data, save it
+ //
+ if (DataTableHeader->StringDataOffset != 0) {
+ Status = StringParsePack (
+ HiiHandle,
+ (EFI_HII_STRING_PACK *) ((char *) DataTableHeader + DataTableHeader->StringDataOffset),
+ NULL,
+ &DataTableHeader->PackageGuid
+ );
+ if (Status != STATUS_SUCCESS) {
+ goto Done;
+ }
+ }
+ //
+ // If there is device path data, process it
+ //
+ if (DataTableHeader->DevicePathOffset != 0) {
+ Error (NULL, 0, 0, "application error", "%s contains unsupported device path data", HiiExportFiles->FileName);
+ goto Done;
+ }
+ //
+ // Next data pack
+ //
+ DataTableHeader = (EFI_HII_DATA_TABLE *) ((char *) DataTableHeader + DataTableHeader->DataTableSize);
+ HiiHandle++;
+ }
+
+ free (Buffer);
+ Buffer = NULL;
+ //
+ // Next input file
+ //
+ HiiExportFiles = HiiExportFiles->Next;
+ }
+ //
+ // Now create defaults
+ //
+ if (IfrSetDefaults (MfgDefaults) != STATUS_SUCCESS) {
+ goto Done;
+ }
+ //
+ // Create and write the output HII export header
+ //
+ if ((OutFptr = fopen (OutputFileName, "wb")) == NULL) {
+ Error (NULL, 0, 0, OutputFileName, "failed to open output file for writing");
+ goto Done;
+ }
+
+ memset ((void *) &TempHiiExportTableHeader, 0, sizeof (EFI_HII_EXPORT_TABLE));
+ TempHiiExportTableHeader.NumberOfHiiDataTables = HiiHandle - FIRST_HII_PACK_HANDLE;
+ memcpy (&TempHiiExportTableHeader.Revision, &HiiExportRevisionGuid, sizeof (EFI_GUID));
+ if (fwrite ((void *) &TempHiiExportTableHeader, sizeof (EFI_HII_EXPORT_TABLE), 1, OutFptr) != 1) {
+ Error (NULL, 0, 0, OutputFileName, "failed to write HII export table header to output file");
+ goto Done;
+ }
+ //
+ // Now go back through all the handles and create new data packs for each, writing out
+ // the contents as we go.
+ //
+ HiiHandle = FIRST_HII_PACK_HANDLE;
+ for (TempDataTable = DataTableList; TempDataTable != NULL; TempDataTable = TempDataTable->Next) {
+ //
+ // Write a data table header to the output file. We'll rewind the file and
+ // write an updated one when we're done with this data set
+ //
+ DataTableHeaderOffset = ftell (OutFptr);
+ TempDataTable->DataTableHeader.HiiHandle = HiiHandle;
+ TempDataTable->DataTableHeader.DataTableSize = sizeof (EFI_HII_DATA_TABLE);
+ //
+ // We may change the number of variable data when merging export files, so init to 0
+ //
+ TempDataTable->DataTableHeader.NumberOfVariableData = 0;
+ if (fwrite ((void *) &TempDataTable->DataTableHeader, sizeof (EFI_HII_DATA_TABLE), 1, OutFptr) != 1) {
+ Error (NULL, 0, 0, OutputFileName, "failed to write HII data table header to output file");
+ goto Done;
+ }
+ //
+ // Get the string pack if any
+ //
+ Status = StringGetPack (HiiHandle, &StringPack, &FileSize, &Count, &FormsetGuid, &PackageGuid);
+ if (Status == STATUS_SUCCESS) {
+ TempDataTable->DataTableHeader.StringDataOffset = TempDataTable->DataTableHeader.DataTableSize;
+ TempDataTable->DataTableHeader.DataTableSize += FileSize;
+ //
+ // TempDataTable->DataTableHeader.NumberOfLanguages should be unchanged
+ //
+ if (fwrite ((void *) StringPack, FileSize, 1, OutFptr) != 1) {
+ Error (NULL, 0, 0, "failed to write string pack to output file", NULL);
+ goto Done;
+ }
+ }
+ //
+ // Get the IFR pack
+ //
+ Status = IfrGetIfrPack (HiiHandle, &IfrPack, &FormsetGuid);
+ if (Status == STATUS_SUCCESS) {
+ //
+ // Write the IFR pack, followed by the variable packs
+ //
+ TempDataTable->DataTableHeader.IfrDataOffset = TempDataTable->DataTableHeader.DataTableSize;
+ TempDataTable->DataTableHeader.DataTableSize += IfrPack->Header.Length;
+ if (fwrite ((void *) IfrPack, IfrPack->Header.Length, 1, OutFptr) != 1) {
+ Error (NULL, 0, 0, "failed to write IFR pack to output file", NULL);
+ goto Done;
+ }
+ //
+ // If this is just a formset stub, then don't write the variable packs
+ //
+ if (IfrPack->Header.Length != sizeof (EMPTY_FORMSET_PACK)) {
+ //
+ // Go through all the variable packs and see if they're referenced by this IFR
+ //
+ Count = 0;
+ do {
+ Status = IfrGetVarPack (Count, &VarPack);
+ if (Status == STATUS_SUCCESS) {
+ //
+ // Check for variable data length of 0
+ //
+ if ((NoEmptyVarPacks == 0) ||
+ ((VarPack->Header.Length - sizeof (EFI_HII_VARIABLE_PACK) - VarPack->VariableNameLength) != 0)
+ ) {
+ //
+ // See if it's referenced by this IFR
+ //
+ if (IfrReferencesVarPack (HiiHandle, VarPack) == STATUS_SUCCESS) {
+ if (TempDataTable->DataTableHeader.VariableDataOffset == 0) {
+ TempDataTable->DataTableHeader.VariableDataOffset = TempDataTable->DataTableHeader.DataTableSize;
+ }
+
+ TempDataTable->DataTableHeader.DataTableSize += VarPack->Header.Length;
+ TempDataTable->DataTableHeader.NumberOfVariableData++;
+ if (fwrite ((void *) VarPack, VarPack->Header.Length, 1, OutFptr) != 1) {
+ Error (NULL, 0, 0, "failed to write variable pack to output file", NULL);
+ goto Done;
+ }
+
+ }
+ }
+ }
+
+ Count++;
+ } while (Status == STATUS_SUCCESS);
+ }
+
+ Status = STATUS_SUCCESS;
+ }
+ //
+ // Get the device path pack
+ //
+ //
+ // Rewind the file and write the updated data table header.
+ //
+ fseek (OutFptr, DataTableHeaderOffset, SEEK_SET);
+ if (fwrite ((void *) &TempDataTable->DataTableHeader, sizeof (EFI_HII_DATA_TABLE), 1, OutFptr) != 1) {
+ Error (NULL, 0, 0, OutputFileName, "failed to write HII data table header to output file");
+ goto Done;
+ }
+
+ fseek (OutFptr, 0, SEEK_END);
+ HiiHandle++;
+ }
+
+ Status = STATUS_SUCCESS;
+Done:
+ IfrParseEnd ();
+ StringEnd ();
+ if (Buffer != NULL) {
+ free (Buffer);
+ }
+
+ if (InFptr != NULL) {
+ fclose (InFptr);
+ }
+
+ if (OutFptr != NULL) {
+ fclose (OutFptr);
+ }
+
+ while (DataTableList != NULL) {
+ TempDataTable = DataTableList->Next;
+ free (DataTableList);
+ DataTableList = TempDataTable;
+ }
+
+ return Status;
+}
+
+/******************************************************************************/
+static
+STATUS
+CreateHiiExport (
+ char *OutputFileName,
+ EFI_GUID *DummyFormsetGuid,
+ FILE_NAME_LIST *PackFiles,
+ int MfgDefaults
+ )
+/*++
+
+Routine Description:
+
+ Given a linked list of HII pack file names, walk the list to
+ process them and create a single HII export file.
+
+Arguments:
+
+ OutputFileName - name of output HII export file to create
+ DummyFormsetGuid - IFR formsets contain a GUID which is used in many
+ places while processing data tables. If we were not
+ given an IFR pack, then we'll create a stub IFR
+ pack using this GUID as the formset GUID.
+ PackFiles - linked list of HII pack files to process
+ MfgDefaults - when creating variable packs (via IFR pack processing),
+ use manufacturing defaults rather than standard defaults
+
+Returns:
+
+ STATUS_SUCCESS - if successful
+ STATUS_ERROR - otherwise
+
+--*/
+{
+ STATUS Status;
+ EMPTY_FORMSET_PACK EmptyFormset;
+ EFI_HII_DATA_TABLE DataTableHeader;
+ EFI_HII_EXPORT_TABLE ExportTableHeader;
+ long DataTableHeaderOffset;
+ long FileSize;
+ FILE *OutFptr;
+ FILE *InFptr;
+ FILE_NAME_LIST *TempFile;
+ EFI_GUID HiiExportRevisionGuid = EFI_HII_PROTOCOL_GUID;
+ EFI_GUID TempGuid;
+ EFI_GUID PackageGuid;
+ char *Buffer;
+ EFI_HII_VARIABLE_PACK *VarPack;
+ EFI_HII_IFR_PACK *IfrPack;
+ EFI_HII_STRING_PACK_HEADER *StringPack;
+ EFI_HII_STRING_PACK_HEADER TerminatorStringPack;
+ int NumIfr;
+ int NumStrings;
+ int Index;
+ int VarPackIndex;
+ //
+ // If no input HII pack files, then why are we here? Should have been caught when
+ // args were processed though.
+ //
+ if (PackFiles == NULL) {
+ Error (NULL, 0, 0, "no input pack files specified", NULL);
+ return STATUS_ERROR;
+ }
+
+ InFptr = NULL;
+ Status = STATUS_ERROR;
+ Buffer = NULL;
+ //
+ // Open the output file for writing
+ //
+ if ((OutFptr = fopen (OutputFileName, "wb")) == NULL) {
+ Error (NULL, 0, 0, OutputFileName, "failed to open output file for writing");
+ goto Done;
+ }
+ //
+ // Figure out how many data tables we are going to need. We'll create one
+ // data table if no more than one IFR, or we'll create one data table per IFR,
+ // and then one for strings if multiple IFR
+ //
+ NumIfr = 0;
+ NumStrings = 0;
+ for (TempFile = PackFiles; TempFile != NULL; TempFile = TempFile->Next) {
+ if (TempFile->Tag == EFI_HII_IFR) {
+ NumIfr++;
+ } else if (TempFile->Tag == EFI_HII_STRING) {
+ NumStrings++;
+ }
+ }
+ //
+ // Three possibilities:
+ // 1) No IFR, so create one data table that contains only strings and an empty formset
+ // 2) Only 1 IFR, so create an export table with one data table that contains the IFR
+ // and all the strings
+ // 3) Multiple IFR, so create a data table for each IFR and another data table with
+ // all the strings.
+ //
+ // Initialize the export table header and write it out
+ //
+ memset ((void *) &ExportTableHeader, 0, sizeof (EFI_HII_EXPORT_TABLE));
+ if (NumIfr < 2) {
+ ExportTableHeader.NumberOfHiiDataTables = 1;
+ } else {
+ //
+ // One data table per IFR, plus one for strings (if any).
+ //
+ ExportTableHeader.NumberOfHiiDataTables = (UINT16) NumIfr;
+ if (NumStrings != 0) {
+ ExportTableHeader.NumberOfHiiDataTables++;
+ }
+ }
+ //
+ // Init the GUID in the HII export table header
+ //
+ memcpy (&ExportTableHeader.Revision, &HiiExportRevisionGuid, sizeof (EFI_GUID));
+ if (fwrite ((void *) &ExportTableHeader, sizeof (EFI_HII_EXPORT_TABLE), 1, OutFptr) != 1) {
+ Error (NULL, 0, 0, OutputFileName, "failed to write HII export table header to output file");
+ goto Done;
+ }
+ //
+ // *****************************************************************************************
+ //
+ // CASE 1 - No IFR => one data table that contains only strings and an empty formset.
+ // No variable data.
+ //
+ // CASE 2 - Only 1 IFR => create an export table with one data table that contains the IFR
+ // and all the strings plus variable data
+ //
+ // CASE 3 - Multiple IFR => create a data table for each IFR and another data table with
+ // all the strings. Each IFR data table has variable data if applicable.
+ //
+ // *****************************************************************************************
+ //
+ // If the user did not give us an IFR file, then we'll have to create an empty formset
+ // and emit it to the output file. In this case, we need a formset GUID on the command
+ // line.
+ //
+ if ((NumIfr == 0) && (mGlobals.GuidSpecified == 0)) {
+ //
+ // Warning (NULL, 0, 0, "using NULL GUID for empty formset", "specify -g GUID on the command line if desired");
+ //
+ memset ((void *) &PackageGuid, 0, sizeof (EFI_GUID));
+ } else if (mGlobals.GuidSpecified) {
+ //
+ // Use it for the package GUID
+ //
+ memcpy (&PackageGuid, &mGlobals.Guid, sizeof (EFI_GUID));
+ }
+ //
+ // Init the data table header.
+ // Write out the blank data table header. Save the offset so we can
+ // write an updated version at the end of processing.
+ //
+ memset ((void *) &DataTableHeader, 0, sizeof (EFI_HII_DATA_TABLE));
+ DataTableHeaderOffset = ftell (OutFptr);
+ DataTableHeader.HiiHandle = FIRST_HII_PACK_HANDLE;
+ if (mGlobals.Verbose) {
+ fprintf (stdout, "writing data table (first time) to offset 0x%X\n", ftell (OutFptr));
+ }
+
+ if (fwrite ((void *) &DataTableHeader, sizeof (EFI_HII_DATA_TABLE), 1, OutFptr) != 1) {
+ Error (NULL, 0, 0, "failed to write Data Table Header to output file", NULL);
+ goto Done;
+ }
+ //
+ // Set the data table size, then write out all the string packs
+ //
+ DataTableHeader.DataTableSize = sizeof (EFI_HII_DATA_TABLE);
+ //
+ // Write out the string files to a single data record
+ //
+ for (TempFile = PackFiles; TempFile != NULL; TempFile = TempFile->Next) {
+ //
+ // Continue to next file if it's not a string pack file
+ //
+ if (TempFile->Tag != EFI_HII_STRING) {
+ continue;
+ }
+ //
+ // Set the offset in the header if this is the first string pack
+ //
+ if (DataTableHeader.StringDataOffset == 0) {
+ DataTableHeader.StringDataOffset = DataTableHeader.DataTableSize;
+ }
+
+ if ((InFptr = fopen (TempFile->FileName, "rb")) == NULL) {
+ Error (NULL, 0, 0, TempFile->FileName, "failed to open input string pack file for reading");
+ goto Done;
+ }
+ //
+ // Get the file size, then read it into a buffer
+ //
+ fseek (InFptr, 0, SEEK_END);
+ FileSize = ftell (InFptr);
+ fseek (InFptr, 0, SEEK_SET);
+ Buffer = (char *) malloc (FileSize);
+ if (Buffer == NULL) {
+ Error (NULL, 0, 0, TempFile->FileName, "memory allocation failure reading in file contents");
+ goto Done;
+ }
+
+ if (fread (Buffer, FileSize, 1, InFptr) != 1) {
+ Error (NULL, 0, 0, TempFile->FileName, "failed to read file contents");
+ goto Done;
+ }
+
+ fclose (InFptr);
+ InFptr = NULL;
+ //
+ // Verify that it's actually a string pack
+ //
+ StringPack = (EFI_HII_STRING_PACK_HEADER *) Buffer;
+ while ((char *) StringPack < Buffer + FileSize) {
+ if (StringPack->Header.Type != EFI_HII_STRING) {
+ Error (NULL, 0, 0, TempFile->FileName, "file does not consist entirely of string packs");
+ goto Done;
+ }
+
+ if (StringPack->Header.Length == 0) {
+ break;
+ }
+
+ DataTableHeader.NumberOfLanguages++;
+ DataTableHeader.DataTableSize += StringPack->Header.Length;
+ //
+ // Write the string pack to the output file
+ //
+ if (mGlobals.Verbose) {
+ fprintf (stdout, "writing string pack to offset 0x%X\n", ftell (OutFptr));
+ }
+
+ if (fwrite (StringPack, StringPack->Header.Length, 1, OutFptr) != 1) {
+ Error (NULL, 0, 0, TempFile->FileName, "failed to write string pack to output file");
+ goto Done;
+ }
+ //
+ // Sanity check that adding the length advances us (no wrap)
+ //
+ if ((char *) StringPack + StringPack->Header.Length <= (char *) StringPack) {
+ Error (NULL, 0, 0, TempFile->FileName, "invalid pack size in file");
+ goto Done;
+ }
+
+ StringPack = (EFI_HII_STRING_PACK_HEADER *) ((char *) StringPack + StringPack->Header.Length);
+ }
+ //
+ // Free up buffer, go to next input string pack file
+ //
+ free (Buffer);
+ Buffer = NULL;
+ }
+ //
+ // Write a null-terminator string pack if we had any string packs at all
+ //
+ if (DataTableHeader.StringDataOffset != 0) {
+ memset (&TerminatorStringPack, 0, sizeof (EFI_HII_STRING_PACK_HEADER));
+ TerminatorStringPack.Header.Length = 0;
+ TerminatorStringPack.Header.Type = EFI_HII_STRING;
+ if (mGlobals.Verbose) {
+ fprintf (stdout, "writing terminator string pack to offset 0x%X\n", ftell (OutFptr));
+ }
+
+ if (fwrite (&TerminatorStringPack, sizeof (EFI_HII_STRING_PACK_HEADER), 1, OutFptr) != 1) {
+ Error (NULL, 0, 0, "failed to write string pack terminator to output file", NULL);
+ goto Done;
+ }
+
+ DataTableHeader.DataTableSize += sizeof (EFI_HII_STRING_PACK_HEADER);
+ }
+ //
+ // Parse all the IFR packs, then get the GUID from the first
+ // one so we can use it for the package GUID if necessary.
+ //
+ memcpy (&PackageGuid, &mGlobals.Guid, sizeof (EFI_GUID));
+ if (NumIfr != 0) {
+ IfrParseInit ();
+ if (ProcessIfrFiles (PackFiles) != STATUS_SUCCESS) {
+ goto Done;
+ }
+ //
+ // Set variable defaults in all variable packs
+ //
+ IfrSetDefaults (MfgDefaults);
+ //
+ // Get the GUID from the first IFR pack if the user did not specify a GUID on
+ // the command line.
+ //
+ if (mGlobals.GuidSpecified == 0) {
+ if (IfrGetIfrPack (FIRST_HII_PACK_HANDLE, &IfrPack, &PackageGuid) != STATUS_SUCCESS) {
+ Error (NULL, 0, 0, "internal application error", "failed to retrieve IFR pack after parsing");
+ goto Done;
+ }
+ }
+ }
+ //
+ // Set the package GUID in the data table header.
+ //
+ memcpy (&DataTableHeader.PackageGuid, &PackageGuid, sizeof (EFI_GUID));
+ //
+ // If no IFR, then create and write the empty formset. Otherwise
+ // parse the IFR and emit it and the variable data for it.
+ //
+ if (NumIfr == 0) {
+ memset ((void *) &EmptyFormset, 0, sizeof (EMPTY_FORMSET_PACK));
+ EmptyFormset.PackHeader.Header.Type = EFI_HII_IFR;
+ EmptyFormset.PackHeader.Header.Length = sizeof (EMPTY_FORMSET_PACK);
+ //
+ // Formset Opcode
+ //
+ EmptyFormset.Formset.Header.OpCode = EFI_IFR_FORM_SET_OP;
+ EmptyFormset.Formset.Header.Length = (UINT8) sizeof (EFI_IFR_FORM_SET);
+ memcpy (&EmptyFormset.Formset.Guid, &PackageGuid, sizeof (EFI_GUID));
+ //
+ // EndFormset Opcode
+ //
+ EmptyFormset.EndFormset.Header.OpCode = EFI_IFR_END_FORM_SET_OP;
+ EmptyFormset.EndFormset.Header.Length = (UINT8) sizeof (EFI_IFR_END_FORM_SET);
+ DataTableHeader.IfrDataOffset = DataTableHeader.DataTableSize;
+ if (mGlobals.Verbose) {
+ fprintf (stdout, "writing stub IFR formset to to offset 0x%X\n", ftell (OutFptr));
+ }
+
+ if (fwrite (&EmptyFormset, sizeof (EMPTY_FORMSET_PACK), 1, OutFptr) != 1) {
+ Error (NULL, 0, 0, OutputFileName, "failed to write formset stub to output file");
+ goto Done;
+ }
+
+ DataTableHeader.DataTableSize += sizeof (EMPTY_FORMSET_PACK);
+ //
+ // Go back and re-write the data table header, reposition to the end, then return.
+ //
+ fseek (OutFptr, DataTableHeaderOffset, SEEK_SET);
+ if (mGlobals.Verbose) {
+ fprintf (stdout, "writing data table (second time) to offset 0x%X\n", ftell (OutFptr));
+ }
+
+ if (fwrite ((void *) &DataTableHeader, sizeof (EFI_HII_DATA_TABLE), 1, OutFptr) != 1) {
+ Error (NULL, 0, 0, "failed to write Data Table Header to output file", NULL);
+ goto Done;
+ }
+
+ fseek (OutFptr, 0, SEEK_END);
+ if (mGlobals.Verbose) {
+ fprintf (
+ stdout,
+ "final file offset=0x%X DataTableHeader.DataTableSize=0x%X\n",
+ ftell (OutFptr),
+ DataTableHeader.DataTableSize
+ );
+ }
+ } else if (NumIfr == 1) {
+ //
+ // They gave us one input IFR file. We parsed it above, so get each one
+ // and emit the IFR and each variable pack it references.
+ // Update the data pack header for the IFR pack, then write the IFR pack data
+ //
+ DataTableHeader.IfrDataOffset = DataTableHeader.DataTableSize;
+ if (IfrGetIfrPack (FIRST_HII_PACK_HANDLE, &IfrPack, &TempGuid) != STATUS_SUCCESS) {
+ Error (NULL, 0, 0, "internal application error", "failed to retrieve IFR pack after parsing");
+ goto Done;
+ }
+
+ if (mGlobals.Verbose) {
+ fprintf (stdout, "writing IFR pack to 0x%X\n", ftell (OutFptr));
+ }
+
+ if (fwrite (IfrPack, IfrPack->Header.Length, 1, OutFptr) != 1) {
+ Error (NULL, 0, 0, OutputFileName, "failed to write IFR pack to output file");
+ goto Done;
+ }
+
+ DataTableHeader.DataTableSize += IfrPack->Header.Length;
+ //
+ // Now go through all the variable packs discovered during IFR processing
+ // and write them to the output file
+ //
+ if (mGlobals.NoVarPacks == 0) {
+ Index = 0;
+ do {
+ Status = IfrGetVarPack (Index, &VarPack);
+ if (Status == STATUS_SUCCESS) {
+ //
+ // If this is the first variable pack, then update the "offset
+ // to variable data" in the data table header
+ //
+ if (Index == 0) {
+ DataTableHeader.VariableDataOffset = DataTableHeader.DataTableSize;
+ }
+
+ DataTableHeader.DataTableSize += VarPack->Header.Length;
+ DataTableHeader.NumberOfVariableData++;
+ if (fwrite ((void *) VarPack, VarPack->Header.Length, 1, OutFptr) != 1) {
+ Error (NULL, 0, 0, OutputFileName, "failed to write variable pack to output file");
+ goto Done;
+ }
+
+ Index++;
+ }
+ } while (Status == STATUS_SUCCESS);
+ }
+ //
+ // Reposition in the output file and write the updated data table header
+ //
+ fseek (OutFptr, DataTableHeaderOffset, SEEK_SET);
+ if (fwrite ((void *) &DataTableHeader, sizeof (EFI_HII_DATA_TABLE), 1, OutFptr) != 1) {
+ Error (NULL, 0, 0, "failed to write Data Table Header to output file", NULL);
+ goto Done;
+ }
+
+ fseek (OutFptr, 0, SEEK_END);
+ } else {
+ //
+ // Multiple IFR input files. Close out the current data table (strings)
+ // if applicable. Then retrieve each parsed IFR pack and create a data pack
+ // that contains the IFR (one per data set) and the variable packs that
+ // the given IFR form references.
+ //
+ if (NumStrings != 0) {
+ fseek (OutFptr, DataTableHeaderOffset, SEEK_SET);
+ if (fwrite ((void *) &DataTableHeader, sizeof (EFI_HII_DATA_TABLE), 1, OutFptr) != 1) {
+ Error (NULL, 0, 0, "failed to write Data Table Header to output file", NULL);
+ goto Done;
+ }
+
+ fseek (OutFptr, 0, SEEK_END);
+ } else {
+ //
+ // No strings, so back up over the data table header we wrote because we assumed
+ // at least one string pack.
+ //
+ fseek (OutFptr, DataTableHeaderOffset, SEEK_SET);
+ }
+ //
+ // Now go through all the IFR packs and write them out, along with variable
+ // data referenced by each. Note that multiple IFR forms can refer to the
+ // same variables, so the same variable data could be duplicated in multiple
+ // data packs.
+ //
+ Index = FIRST_HII_PACK_HANDLE;
+ while (IfrGetIfrPack (Index, &IfrPack, &TempGuid) == STATUS_SUCCESS) {
+ //
+ // Initialize the data table header
+ //
+ memset (&DataTableHeader, 0, sizeof (EFI_HII_DATA_TABLE));
+ memcpy (&DataTableHeader.PackageGuid, &PackageGuid, sizeof (EFI_GUID));
+ //
+ // If we didn't have strings, then the HiiHandle should be just Index,
+ // rather than Index+1. But since the HiiHandle is not required to start
+ // with 1, we'll let it be Index+1.
+ //
+ DataTableHeader.HiiHandle = (EFI_HII_HANDLE) (Index + 1);
+ DataTableHeader.DataTableSize = sizeof (EFI_HII_DATA_TABLE);
+ //
+ // Save the file offset of the data table header so we can write an updated
+ // version later.
+ //
+ DataTableHeaderOffset = ftell (OutFptr);
+ if (mGlobals.Verbose) {
+ fprintf (stdout, "writing data table header to 0x%X\n", ftell (OutFptr));
+ }
+
+ if (fwrite ((void *) &DataTableHeader, sizeof (EFI_HII_DATA_TABLE), 1, OutFptr) != 1) {
+ Error (NULL, 0, 0, "failed to write Data Table Header to output file", NULL);
+ goto Done;
+ }
+
+ DataTableHeader.IfrDataOffset = DataTableHeader.DataTableSize;
+ if (fwrite (IfrPack, IfrPack->Header.Length, 1, OutFptr) != 1) {
+ Error (NULL, 0, 0, OutputFileName, "failed to write IFR pack to output file");
+ goto Done;
+ }
+
+ DataTableHeader.DataTableSize += IfrPack->Header.Length;
+ //
+ // Go through all the variable packs and see if this IFR references each. If the
+ // IFR does reference it, then add the variable pack to the output.
+ //
+ if (mGlobals.NoVarPacks == 0) {
+ VarPackIndex = 0;
+ while (IfrGetVarPack (VarPackIndex, &VarPack) == STATUS_SUCCESS) {
+ //
+ // See if the IFR references this variable pack
+ //
+ if (IfrReferencesVarPack (Index, VarPack) == STATUS_SUCCESS) {
+ //
+ // If this is the first variable pack, then set the offset in
+ // the data table header.
+ //
+ if (DataTableHeader.VariableDataOffset == 0) {
+ DataTableHeader.VariableDataOffset = DataTableHeader.DataTableSize;
+ }
+ //
+ // Write the variable pack
+ //
+ if (fwrite (VarPack, VarPack->Header.Length, 1, OutFptr) != 1) {
+ Error (NULL, 0, 0, OutputFileName, "failed to write variable pack to output file");
+ goto Done;
+ }
+
+ DataTableHeader.NumberOfVariableData++;
+ DataTableHeader.DataTableSize += VarPack->Header.Length;
+ }
+
+ VarPackIndex++;
+ }
+ }
+ //
+ // Write the updated data table header
+ //
+ fseek (OutFptr, DataTableHeaderOffset, SEEK_SET);
+ if (fwrite ((void *) &DataTableHeader, sizeof (EFI_HII_DATA_TABLE), 1, OutFptr) != 1) {
+ Error (NULL, 0, 0, "failed to write Data Table Header to output file", NULL);
+ goto Done;
+ }
+
+ fseek (OutFptr, 0, SEEK_END);
+ //
+ // Next IFR pack
+ //
+ Index++;
+ }
+ }
+
+ Status = STATUS_SUCCESS;
+Done:
+ IfrParseEnd ();
+ StringEnd ();
+ if (Buffer != NULL) {
+ free (Buffer);
+ }
+
+ if (InFptr != NULL) {
+ fclose (InFptr);
+ }
+
+ if (OutFptr != NULL) {
+ fclose (OutFptr);
+ }
+
+ return Status;
+}
+
+/******************************************************************************/
+static
+STATUS
+ProcessIfrFiles (
+ FILE_NAME_LIST *FileName
+ )
+/*++
+
+Routine Description:
+
+ Given a linked list of pack file names, read in each IFR pack file
+ and process the contents.
+
+Arguments:
+
+ FileName - pointer to linked list of input pack file names
+
+Returns:
+
+ STATUS_SUCCESS - if successful
+ STATUS_ERROR - otherwise
+
+--*/
+{
+ FILE *InFptr;
+ char *Buffer;
+ long BufferSize;
+ STATUS Status;
+ STATUS IfrStatus;
+ int Handle;
+ EFI_GUID FormsetGuid;
+ EFI_HII_PACK_HEADER *PackHeader;
+ //
+ // Process each input IFR file
+ //
+ Status = STATUS_ERROR;
+ Handle = 1;
+ InFptr = NULL;
+ Buffer = NULL;
+ while (FileName != NULL) {
+ //
+ // Only process IFR pack files
+ //
+ if (FileName->Tag != EFI_HII_IFR) {
+ FileName = FileName->Next;
+ continue;
+ }
+ //
+ // Open the input file, then read the contents
+ //
+ if ((InFptr = fopen (FileName->FileName, "rb")) == NULL) {
+ Error (NULL, 0, 0, FileName->FileName, "failed to open input IFR file");
+ goto Done;
+ }
+
+ fseek (InFptr, 0, SEEK_END);
+ BufferSize = ftell (InFptr);
+ fseek (InFptr, 0, SEEK_SET);
+ Buffer = (char *) malloc (BufferSize);
+ if (Buffer == NULL) {
+ Error (NULL, 0, 0, "memory allocation failure", NULL);
+ goto Done;
+ }
+
+ if (fread (Buffer, BufferSize, 1, InFptr) != 1) {
+ Error (NULL, 0, 0, FileName->FileName, "failed to read file contents");
+ goto Done;
+ }
+
+ fclose (InFptr);
+ InFptr = NULL;
+ //
+ // Check the buffer contents -- better be an IFR pack
+ //
+ if (BufferSize < sizeof (EFI_HII_PACK_HEADER)) {
+ Error (NULL, 0, 0, FileName->FileName, "file is not large enough to contain an IFR pack");
+ goto Done;
+ }
+
+ PackHeader = (EFI_HII_PACK_HEADER *) Buffer;
+ if (PackHeader->Type != EFI_HII_IFR) {
+ Error (NULL, 0, 0, FileName->FileName, "file does not appear to be an IFR pack");
+ goto Done;
+ }
+ //
+ // Process the contents
+ //
+ memset ((void *) &FormsetGuid, 0, sizeof (EFI_GUID));
+ IfrStatus = IfrParsePack (Handle, (EFI_HII_IFR_PACK *) PackHeader, &FormsetGuid);
+ if (IfrStatus != STATUS_SUCCESS) {
+ goto Done;
+ }
+
+ Handle++;
+ free (Buffer);
+ Buffer = NULL;
+ FileName = FileName->Next;
+ }
+
+ Status = STATUS_SUCCESS;
+Done:
+ if (InFptr != NULL) {
+ fclose (InFptr);
+ }
+
+ if (Buffer != NULL) {
+ free (Buffer);
+ }
+
+ return Status;
+}
+
+static
+STATUS
+EmitDefaults (
+ FILE_NAME_LIST *HiiExportFiles,
+ int MfgDefaults,
+ int NoEmptyVarPacks
+ )
+/*++
+
+Routine Description:
+
+ Given a linked list of HII export files, read in each file,
+ process the contents, and then emit variable packs.
+
+Arguments:
+
+ HiiExportFiles - linked list of HII export files to process
+ MfgDefaults - emit manufacturing defaults
+ NoEmptyVarPacks - don't emit variable packs if they are 0-length
+
+Returns:
+
+ STATUS_SUCCESS - if successful
+ STATUS_ERROR - otherwise
+
+--*/
+{
+ int HiiHandle;
+ FILE *OutFptr;
+ FILE *InFptr;
+ EFI_HII_VARIABLE_PACK *VarPack;
+ CHAR8 OutFileName[MAX_PATH];
+ CHAR8 GuidString[100];
+ STATUS Status;
+ CHAR8 *Buffer;
+ int FileSize;
+ int DataTableIndex;
+ EFI_HII_EXPORT_TABLE *HiiExportTableHeader;
+ EFI_HII_DATA_TABLE *DataTableHeader;
+ //
+ // Init locals
+ //
+ HiiHandle = FIRST_HII_PACK_HANDLE;
+ Buffer = NULL;
+ InFptr = NULL;
+ OutFptr = NULL;
+ Status = STATUS_ERROR;
+ //
+ // Initialize our IFR parser
+ //
+ IfrParseInit ();
+ //
+ // Process each input HII export file
+ //
+ while (HiiExportFiles != NULL) {
+ if (mGlobals.Verbose) {
+ fprintf (stdout, "Processing file %s\n", HiiExportFiles->FileName);
+ }
+ //
+ // Read in the entire file contents
+ //
+ if ((InFptr = fopen (HiiExportFiles->FileName, "rb")) == NULL) {
+ Error (NULL, 0, 0, HiiExportFiles->FileName, "failed to open HII export file for reading");
+ goto Done;
+ }
+
+ fseek (InFptr, 0, SEEK_END);
+ FileSize = (int) ftell (InFptr);
+ fseek (InFptr, 0, SEEK_SET);
+ Buffer = (CHAR8 *) malloc (FileSize);
+ if (Buffer == NULL) {
+ Error (NULL, 0, 0, "memory allocation failure", NULL);
+ goto Done;
+ }
+
+ if (fread (Buffer, FileSize, 1, InFptr) != 1) {
+ Error (NULL, 0, 0, HiiExportFiles->FileName, "failed to read file contents");
+ goto Done;
+ }
+
+ fclose (InFptr);
+ InFptr = NULL;
+ HiiExportTableHeader = (EFI_HII_EXPORT_TABLE *) Buffer;
+ //
+ // Walk all the data tables
+ //
+ DataTableHeader = (EFI_HII_DATA_TABLE *) (HiiExportTableHeader + 1);
+ for (DataTableIndex = 0; DataTableIndex < (int) HiiExportTableHeader->NumberOfHiiDataTables; DataTableIndex++) {
+ //
+ // Make sure we're still pointing into our buffer
+ //
+ if (((char *) DataTableHeader < Buffer) || ((char *) DataTableHeader > Buffer + FileSize)) {
+ Error (NULL, 0, 0, "bad data table size in input file", NULL);
+ goto Done;
+ }
+ //
+ // If there is an IFR pack, parse it
+ //
+ HiiHandle++;
+ if (DataTableHeader->IfrDataOffset != 0) {
+ if (IfrParsePack (
+ HiiHandle,
+ (EFI_HII_IFR_PACK *) ((char *) DataTableHeader + DataTableHeader->IfrDataOffset),
+ &DataTableHeader->PackageGuid
+ ) != STATUS_SUCCESS
+ ) {
+ goto Done;
+ }
+ }
+ //
+ // Next data pack
+ //
+ DataTableHeader = (EFI_HII_DATA_TABLE *) ((char *) DataTableHeader + DataTableHeader->DataTableSize);
+ }
+
+ free (Buffer);
+ Buffer = NULL;
+ //
+ // Next input file
+ //
+ HiiExportFiles = HiiExportFiles->Next;
+ }
+ //
+ // Now create defaults
+ //
+ if (IfrSetDefaults (MfgDefaults) != STATUS_SUCCESS) {
+ goto Done;
+ }
+ //
+ // Now retrieve each variable pack and write it out to a GUID-VarName.hpk file
+ //
+ HiiHandle = 0;
+ do {
+ Status = IfrGetVarPack (HiiHandle, &VarPack);
+ if (Status == STATUS_SUCCESS) {
+ //
+ // Check for variable data length of 0
+ //
+ if ((NoEmptyVarPacks == 0) ||
+ ((VarPack->Header.Length - sizeof (EFI_HII_VARIABLE_PACK) - VarPack->VariableNameLength) != 0)
+ ) {
+ //
+ // Open the output file and write the variable pack
+ //
+ GuidToString (&VarPack->VariableGuid, GuidString);
+ if (MfgDefaults) {
+ sprintf (
+ OutFileName,
+ "%s-%S-MfgDefaults%s",
+ GuidString,
+ (CHAR16 *) (VarPack + 1),
+ DEFAULT_HII_PACK_FILENAME_EXTENSION
+ );
+ } else {
+ sprintf (
+ OutFileName,
+ "%s-%S-Defaults%s",
+ GuidString,
+ (CHAR16 *) (VarPack + 1),
+ DEFAULT_HII_PACK_FILENAME_EXTENSION
+ );
+ }
+
+ if (mGlobals.Verbose) {
+ fprintf (
+ stdout,
+ "Creating %svariable defaults pack file %s\n",
+ MfgDefaults ? "manufacturing " : "",
+ OutFileName
+ );
+ }
+
+ if ((OutFptr = fopen (OutFileName, "wb")) == NULL) {
+ Error (NULL, 0, 0, OutFileName, "failed to open output file for writing", NULL);
+ goto Done;
+ }
+
+ if (fwrite ((void *) VarPack, VarPack->Header.Length, 1, OutFptr) != 1) {
+ Error (NULL, 0, 0, OutFileName, "failed to write defaults to output file");
+ goto Done;
+ }
+
+ fclose (OutFptr);
+ OutFptr = NULL;
+ } else {
+ //
+ // Print a message that we skipped one if in verbose mode
+ //
+ if (mGlobals.Verbose) {
+ GuidToString (&VarPack->VariableGuid, GuidString);
+ if (MfgDefaults) {
+ sprintf (
+ OutFileName,
+ "%s-%S-MfgDefaults%s",
+ GuidString,
+ (CHAR16 *) (VarPack + 1),
+ DEFAULT_HII_PACK_FILENAME_EXTENSION
+ );
+ } else {
+ sprintf (
+ OutFileName,
+ "%s-%S-Defaults%s",
+ GuidString,
+ (CHAR16 *) (VarPack + 1),
+ DEFAULT_HII_PACK_FILENAME_EXTENSION
+ );
+ }
+
+ fprintf (
+ stdout,
+ "Skipping 0-length %svariable defaults pack file %s\n",
+ MfgDefaults ? "manufacturing " : "",
+ OutFileName
+ );
+ }
+ }
+ }
+
+ HiiHandle++;
+ } while (Status == STATUS_SUCCESS);
+ Status = STATUS_SUCCESS;
+Done:
+ IfrParseEnd ();
+ if (Buffer != NULL) {
+ free (Buffer);
+ }
+
+ if (InFptr != NULL) {
+ fclose (InFptr);
+ }
+
+ if (OutFptr != NULL) {
+ fclose (OutFptr);
+ }
+
+ return Status;
+}
+
+static
+void
+FreeGlobals (
+ VOID
+ )
+/*++
+
+Routine Description:
+
+ Free up an memory we allocated so we can exit cleanly
+
+Arguments:
+
+Returns: NA
+
+--*/
+{
+ FILE_NAME_LIST *Next;
+ //
+ // Free up input pack file names
+ //
+ while (mGlobals.PackFileNames != NULL) {
+ Next = mGlobals.PackFileNames->Next;
+ free (mGlobals.PackFileNames);
+ mGlobals.PackFileNames = Next;
+ }
+ //
+ // Free up input HII export file names
+ //
+ while (mGlobals.HiiExportFileNames != NULL) {
+ Next = mGlobals.HiiExportFileNames->Next;
+ free (mGlobals.HiiExportFileNames);
+ mGlobals.HiiExportFileNames = Next;
+ }
+}
+
+static
+STATUS
+DumpHiiExportFile (
+ char *HiiExportFileName,
+ char *OutputFileName
+ )
+/*++
+
+Routine Description:
+
+ Dump the contents of an HII export file for debug purposes
+
+Arguments:
+
+ HiiExportFileName - name of input HII export file
+ OutputFileName - name of output file to dump contents
+
+Returns:
+ STATUS_SUCCESS - no problems
+ STATUS_ERROR - problems encountered processing the file
+
+--*/
+{
+ FILE *InFptr;
+
+ FILE *OutFptr;
+ char *Buffer;
+ char *BufferStart;
+ char *BufferEnd;
+ int BufferSize;
+ STATUS Status;
+ char GuidString[100];
+ int Counter;
+ int NumberOfTables;
+ EFI_HII_DATA_TABLE *DataTableHeader;
+ EFI_GUID HiiExportRevisionGuid = EFI_HII_PROTOCOL_GUID;
+ //
+ // Init locals
+ //
+ InFptr = NULL;
+ OutFptr = NULL;
+ BufferStart = NULL;
+ Status = STATUS_ERROR;
+ //
+ // Open the input file
+ //
+ if ((InFptr = fopen (HiiExportFileName, "rb")) == NULL) {
+ Error (NULL, 0, 0, HiiExportFileName, "failed to open input HII export file for reading");
+ goto Done;
+ }
+ //
+ // Open the output file
+ //
+ if ((OutFptr = fopen (OutputFileName, "w")) == NULL) {
+ Error (NULL, 0, 0, OutputFileName, "failed to open output file for writing");
+ goto Done;
+ }
+ //
+ // Get the file size, then allocate a buffer and read in the file contents.
+ //
+ fseek (InFptr, 0, SEEK_END);
+ BufferSize = (int) ftell (InFptr);
+ fseek (InFptr, 0, SEEK_SET);
+ BufferStart = (char *) malloc (BufferSize);
+ if (BufferStart == NULL) {
+ Error (NULL, 0, 0, "memory allocation failure", NULL);
+ goto Done;
+ }
+
+ if (fread (BufferStart, BufferSize, 1, InFptr) != 1) {
+ Error (NULL, 0, 0, HiiExportFileName, "error reading file contents");
+ goto Done;
+ }
+
+ fclose (InFptr);
+ InFptr = NULL;
+ //
+ // Crude check of the input data -- check the size and GUID
+ //
+ if (BufferSize < sizeof (EFI_HII_EXPORT_TABLE)) {
+ Error (NULL, 0, 0, HiiExportFileName, "files not large enough to contain an HII export table header");
+ goto Done;
+ }
+
+ if (memcmp (&((EFI_HII_EXPORT_TABLE *) BufferStart)->Revision, &HiiExportRevisionGuid, sizeof (EFI_GUID)) != 0) {
+ Error (NULL, 0, 0, HiiExportFileName, "invalid HII export revision GUID -- is this an HII export file?");
+ //
+ // See if it's a HII pack file
+ //
+ TestDumpHiiPack (OutFptr, BufferStart, BufferSize);
+ goto Done;
+ }
+ //
+ // Now walk the export data
+ //
+ Buffer = BufferStart;
+ BufferEnd = BufferStart + BufferSize;
+ //
+ // Dump the header
+ //
+ fprintf (OutFptr, "HII dump of file %s\n\n", HiiExportFileName);
+ NumberOfTables = ((EFI_HII_EXPORT_TABLE *) Buffer)->NumberOfHiiDataTables;
+ fprintf (OutFptr, "Number of data tables: %d\n", NumberOfTables);
+ GuidToString (&((EFI_HII_EXPORT_TABLE *) Buffer)->Revision, GuidString);
+ fprintf (OutFptr, "HII export revision: %s\n", GuidString);
+ //
+ // Now walk the data tables
+ //
+ Buffer += sizeof (EFI_HII_EXPORT_TABLE);
+ for (Counter = 0; Counter < NumberOfTables; Counter++) {
+ DataTableHeader = (EFI_HII_DATA_TABLE *) Buffer;
+ fprintf (OutFptr, "----------------------------------------------------------\n");
+ fprintf (OutFptr, " DataTable at offset 0x%08X\n", (int) Buffer - (int) BufferStart);
+ fprintf (OutFptr, " HII Handle: 0x%08X\n", DataTableHeader->HiiHandle);
+ GuidToString (&DataTableHeader->PackageGuid, GuidString);
+ fprintf (OutFptr, " Package GUID: %s\n", GuidString);
+ fprintf (OutFptr, " Data table size: 0x%08X\n", DataTableHeader->DataTableSize);
+ fprintf (OutFptr, " IFR data offset: 0x%08X\n", DataTableHeader->IfrDataOffset);
+ fprintf (OutFptr, " String data offset: 0x%08X\n", DataTableHeader->StringDataOffset);
+ fprintf (OutFptr, " Variable data offset: 0x%08X\n", DataTableHeader->VariableDataOffset);
+ fprintf (OutFptr, " Device path offset: 0x%08X\n", DataTableHeader->DevicePathOffset);
+ fprintf (OutFptr, " Number of variable data: 0x%08X\n", DataTableHeader->NumberOfVariableData);
+ fprintf (OutFptr, " Number of languages: 0x%08X\n", DataTableHeader->NumberOfLanguages);
+ //
+ // Dump strings
+ //
+ if (DataTableHeader->StringDataOffset != 0) {
+ DumpStringPack (
+ OutFptr,
+ (EFI_HII_STRING_PACK *) ((char *) DataTableHeader + DataTableHeader->StringDataOffset),
+ DataTableHeader->StringDataOffset,
+ 6
+ );
+ }
+ //
+ // Dump IFR
+ //
+ if (DataTableHeader->IfrDataOffset != 0) {
+ DumpIfrPack (
+ OutFptr,
+ (EFI_HII_IFR_PACK *) ((char *) DataTableHeader + DataTableHeader->IfrDataOffset),
+ DataTableHeader->IfrDataOffset,
+ 6
+ );
+ }
+ //
+ // Dump variables
+ //
+ if (DataTableHeader->VariableDataOffset != 0) {
+ DumpVariablePacks (
+ OutFptr,
+ (EFI_HII_VARIABLE_PACK *) ((char *) DataTableHeader + DataTableHeader->VariableDataOffset),
+ DataTableHeader->NumberOfVariableData,
+ DataTableHeader->VariableDataOffset,
+ 6
+ );
+ }
+ //
+ // Dump device path
+ //
+ //
+ // Check position before advancing
+ //
+ if ((Buffer + DataTableHeader->DataTableSize < Buffer) || (Buffer + DataTableHeader->DataTableSize > BufferEnd)) {
+ Error (NULL, 0, 0, HiiExportFileName, "bad data table size at offset 0x%X", (int) Buffer - (int) BufferStart);
+ goto Done;
+ }
+
+ Buffer += DataTableHeader->DataTableSize;
+ }
+
+ Status = STATUS_SUCCESS;
+Done:
+ if (OutFptr != NULL) {
+ fclose (OutFptr);
+ }
+
+ if (InFptr != NULL) {
+ fclose (InFptr);
+ }
+
+ if (BufferStart != NULL) {
+ free (BufferStart);
+ }
+
+ return Status;
+}
+
+static
+void
+DumpIfrPack (
+ FILE *OutFptr,
+ EFI_HII_IFR_PACK *Pack,
+ int BaseOffset,
+ int Indent
+ )
+/*++
+
+Routine Description:
+
+ Dump the contents of an IFR pack for debug purposes
+
+Arguments:
+
+ OutFptr - file pointer to which to dump the output
+ Pack - pointer to IFR pack to dump
+ BaseOffset - offset from which Pack starts in its parent data table
+ Indent - indent this many spaces when printing text to OutFptr
+
+Returns:
+ NA
+
+--*/
+{
+ EFI_IFR_FORM_SET *IfrFormSet;
+ char GuidString[100];
+ if (Pack->Header.Type != EFI_HII_IFR) {
+ Error (NULL, 0, 0, "found non-IFR pack type at IFR data offset", NULL);
+ return ;
+ }
+
+ fprintf (OutFptr, "%*cIFR pack at offset 0x%08X\n", Indent, ' ', BaseOffset);
+ fprintf (OutFptr, "%*c Length 0x%08X\n", Indent, ' ', Pack->Header.Length);
+ //
+ // Get the GUID from the formset
+ //
+ IfrFormSet = (EFI_IFR_FORM_SET *) (Pack + 1);
+ GuidToString (&IfrFormSet->Guid, GuidString);
+ fprintf (OutFptr, "%*c Variable GUID %s\n", Indent, ' ', GuidString);
+ //
+ // Print the IFR formset size, with a note indicating if it's a min (likely stub)
+ // formset
+ //
+ if (Pack->Header.Length == sizeof (EMPTY_FORMSET_PACK)) {
+ fprintf (
+ OutFptr,
+ "%*c IFR formset size 0x%08X (empty formset)\n",
+ Indent,
+ ' ',
+ Pack->Header.Length - sizeof (EFI_HII_IFR_PACK)
+ );
+ } else {
+ fprintf (
+ OutFptr,
+ "%*c IFR formset size 0x%08X\n",
+ Indent,
+ ' ',
+ Pack->Header.Length - sizeof (EFI_HII_IFR_PACK)
+ );
+ }
+ //
+ // Dump raw bytes -- not much use
+ //
+}
+
+static
+void
+DumpVariablePacks (
+ FILE *OutFptr,
+ EFI_HII_VARIABLE_PACK *Pack,
+ int NumPacks,
+ int BaseOffset,
+ int Indent
+ )
+/*++
+
+Routine Description:
+
+ Dump the contents of an IFR pack for debug purposes
+
+Arguments:
+
+ OutFptr - file pointer to which to dump the output
+ Pack - pointer to variable pack to dump
+ NumPacks - number of packs in Pack[] array
+ BaseOffset - offset from which Pack starts in its parent data table
+ Indent - indent this many spaces when printing text to OutFptr
+
+Returns:
+ NA
+
+--*/
+{
+ int Count;
+
+ int Len;
+ char GuidString[100];
+
+ for (Count = 0; Count < NumPacks; Count++) {
+ if (Pack->Header.Type != EFI_HII_VARIABLE) {
+ Error (NULL, 0, 0, "found non-variable pack type in variable pack array", NULL);
+ return ;
+ }
+
+ fprintf (OutFptr, "%*cVariable pack at offset 0x%08X\n", Indent, ' ', BaseOffset);
+ fprintf (OutFptr, "%*c Length 0x%08X\n", Indent, ' ', Pack->Header.Length);
+ GuidToString (&Pack->VariableGuid, GuidString);
+ fprintf (OutFptr, "%*c Variable GUID %s\n", Indent, ' ', GuidString);
+ fprintf (OutFptr, "%*c Variable Name %S\n", Indent, ' ', (CHAR16 *) (Pack + 1));
+ Len = sizeof (EFI_HII_VARIABLE_PACK) + Pack->VariableNameLength;
+ fprintf (OutFptr, "%*c Variable Size 0x%08X\n", Indent, ' ', Pack->Header.Length - Len);
+ //
+ // Dump raw bytes
+ //
+ DumpRawBytes (OutFptr, (char *) Pack + Len, Pack->Header.Length - Len, Len, Indent + 2);
+ BaseOffset += Pack->Header.Length;
+ Pack = (EFI_HII_VARIABLE_PACK *) ((char *) Pack + Pack->Header.Length);
+ }
+}
+
+static
+void
+DumpStringPack (
+ FILE *OutFptr,
+ EFI_HII_STRING_PACK *Pack,
+ int BaseOffset,
+ int Indent
+ )
+/*++
+
+Routine Description:
+
+ Dump the contents of a string pack array for debug purposes
+
+Arguments:
+
+ OutFptr - file pointer to which to dump the output
+ Pack - pointer to string pack array to dump
+ BaseOffset - offset from which Pack starts in its parent data table
+ Indent - indent this many spaces when printing text to OutFptr
+
+Returns:
+ NA
+
+--*/
+{
+ int Count;
+ int *IndexPtr;
+ CHAR16 *WCPtr;
+ //
+ // String pack array is terminated with a zero-length string pack
+ //
+ while (Pack->Header.Length > 0) {
+ if (Pack->Header.Type != EFI_HII_STRING) {
+ Error (NULL, 0, 0, "found non-string pack type in string pack array", NULL);
+ return ;
+ }
+
+ fprintf (OutFptr, "%*cString pack at offset 0x%08X\n", Indent, ' ', BaseOffset);
+ fprintf (OutFptr, "%*c Length 0x%08X\n", Indent, ' ', Pack->Header.Length);
+ fprintf (
+ OutFptr,
+ "%*c Language %S\n",
+ Indent,
+ ' ',
+ (CHAR16 *) ((char *) Pack + Pack->LanguageNameString)
+ );
+ fprintf (
+ OutFptr,
+ "%*c Printable Language %S\n",
+ Indent,
+ ' ',
+ (CHAR16 *) ((char *) Pack + Pack->PrintableLanguageName)
+ );
+ fprintf (OutFptr, "%*c Number of strings 0x%08X\n", Indent, ' ', Pack->NumStringPointers);
+ fprintf (OutFptr, "%*c Attributes 0x%08X\n", Indent, ' ', Pack->Attributes);
+ IndexPtr = (int *) (Pack + 1);
+ //
+ // Dump string data
+ //
+ if (mGlobals.DumpStrings) {
+ for (Count = 0; Count < (int) Pack->NumStringPointers; Count++) {
+ fprintf (OutFptr, "%*c String 0x%04X: ", Indent, ' ', Count);
+ //
+ // Print raw hex bytes
+ //
+ for (WCPtr = (CHAR16 *) ((char *) Pack +*IndexPtr); *WCPtr != 0; WCPtr++) {
+ fprintf (OutFptr, "%02X ", (unsigned int) *WCPtr);
+ }
+
+ fprintf (OutFptr, "00\n");
+ IndexPtr++;
+ }
+ }
+
+ BaseOffset += Pack->Header.Length;
+ Pack = (EFI_HII_STRING_PACK *) ((char *) Pack + Pack->Header.Length);
+ }
+}
+
+static
+void
+TestDumpHiiPack (
+ FILE *OutFptr,
+ char *Buffer,
+ int BufferSize
+ )
+/*++
+
+Routine Description:
+
+ GC_TODO: Add function description
+
+Arguments:
+
+ OutFptr - GC_TODO: add argument description
+ Buffer - GC_TODO: add argument description
+ BufferSize - GC_TODO: add argument description
+
+Returns:
+
+ GC_TODO: add return values
+
+--*/
+{
+ EFI_HII_PACK_HEADER *PackHeader;
+
+ PackHeader = (EFI_HII_PACK_HEADER *) Buffer;
+ //
+ // Check size match
+ //
+ if (PackHeader->Length != (unsigned int) BufferSize) {
+ return ;
+ }
+ //
+ // Check type
+ //
+ switch (PackHeader->Type) {
+ case EFI_HII_STRING:
+ fprintf (stdout, "Dumping as string pack\n");
+ DumpStringPack (OutFptr, (EFI_HII_STRING_PACK *) Buffer, 0, 2);
+ break;
+
+ case EFI_HII_IFR:
+ fprintf (stdout, "Dumping as IFR pack\n");
+ DumpIfrPack (OutFptr, (EFI_HII_IFR_PACK *) Buffer, 0, 2);
+ break;
+
+ case EFI_HII_VARIABLE:
+ fprintf (stdout, "Dumping as IFR pack\n");
+ DumpVariablePacks (OutFptr, (EFI_HII_VARIABLE_PACK *) Buffer, 1, 0, 2);
+ break;
+ }
+}
+
+static
+void
+DumpRawBytes (
+ FILE *OutFptr,
+ char *Buffer,
+ int Count,
+ int BaseOffset,
+ int Indent
+ )
+/*++
+
+Routine Description:
+
+ GC_TODO: Add function description
+
+Arguments:
+
+ OutFptr - GC_TODO: add argument description
+ Buffer - GC_TODO: add argument description
+ Count - GC_TODO: add argument description
+ BaseOffset - GC_TODO: add argument description
+ Indent - GC_TODO: add argument description
+
+Returns:
+
+ GC_TODO: add return values
+
+--*/
+{
+ int Counter;
+
+ for (Counter = 0; Counter < Count; Counter++) {
+ if ((Counter & 0xF) == 0) {
+ if (Counter != 0) {
+ fprintf (OutFptr, "\n%*c%08X ", Indent, ' ', Counter);
+ } else {
+ fprintf (OutFptr, "\n%*c%08X ", Indent, ' ', Counter);
+ }
+ }
+
+ fprintf (OutFptr, "%02X ", (unsigned int) (unsigned char) *Buffer);
+ Buffer++;
+ }
+
+ fprintf (OutFptr, "\n");
+}
+
+void
+GuidToString (
+ EFI_GUID *Guid,
+ char *Str
+ )
+/*++
+
+Routine Description:
+
+ Given a pointer to a GUID, sprint the value into a string
+
+Arguments:
+
+ Guid - pointer to input GUID
+ Str - pointer to outgoing printed GUID value
+
+Returns:
+ NA
+
+--*/
+{
+ sprintf (
+ Str,
+ "%08X-%04X-%04X-%02X%02X-%02X%02X%02X%02X%02X%02X",
+ Guid->Data1,
+ Guid->Data2,
+ Guid->Data3,
+ Guid->Data4[0],
+ Guid->Data4[1],
+ Guid->Data4[2],
+ Guid->Data4[3],
+ Guid->Data4[4],
+ Guid->Data4[5],
+ Guid->Data4[6],
+ Guid->Data4[7]
+ );
+}
+
+int
+FindFilesCallback (
+ char *FoundFileName
+ )
+/*++
+
+Routine Description:
+
+ Callback function used to get files matching a file mask. This
+ function is called when the command-line arguments to this utility
+ are parsed and the user specified "-s Path FileMask" to process
+ all HII export files in Path and its subdirectories that match
+ FileMask.
+
+Arguments:
+
+ FoundFileName - name of file found.
+
+Returns:
+ non-zero - caller should halt processing
+ zero - no problems while processing FoundFileName
+
+--*/
+{
+ FILE_NAME_LIST *FileName;
+
+ FILE_NAME_LIST *TempFileName;
+
+ FileName = (FILE_NAME_LIST *) malloc (sizeof (FILE_NAME_LIST));
+ if (FileName == NULL) {
+ Error (NULL, 0, 0, "memory allocation failure", NULL);
+ return STATUS_ERROR;
+ }
+
+ memset ((void *) FileName, 0, sizeof (FILE_NAME_LIST));
+ strcpy (FileName->FileName, FoundFileName);
+ if (mGlobals.HiiExportFileNames == NULL) {
+ mGlobals.HiiExportFileNames = FileName;
+ } else {
+ //
+ // Add to the end of the list
+ //
+ for (TempFileName = mGlobals.HiiExportFileNames; TempFileName->Next != NULL; TempFileName = TempFileName->Next)
+ ;
+ TempFileName->Next = FileName;
+ }
+
+ return 0;
+}
+
+static
+STATUS
+ProcessArgs (
+ int Argc,
+ char *Argv[]
+ )
+/*++
+
+Routine Description:
+
+ Process the command line arguments
+
+Arguments:
+
+ As per standard C main()
+
+Returns:
+
+ STATUS_SUCCESS - if successful
+ STATUS_ERROR - otherwise
+
+--*/
+// GC_TODO: Argc - add argument and description to function comment
+// GC_TODO: ] - add argument and description to function comment
+{
+ FILE_NAME_LIST *FileName;
+
+ FILE_NAME_LIST *TempFileName;
+ FILE *InFptr;
+ EFI_HII_PACK_HEADER PackHeader;
+
+ memset ((void *) &mGlobals, 0, sizeof (mGlobals));
+ //
+ // Skip program name
+ //
+ Argc--;
+ Argv++;
+
+ if (Argc == 0) {
+ Usage ();
+ return STATUS_ERROR;
+ }
+ //
+ // First arg must be one of create, merge, defaults, or dump
+ //
+ if (_stricmp (Argv[0], "create") == 0) {
+ mGlobals.Mode = MODE_CREATE_HII_EXPORT;
+ } else if (_stricmp (Argv[0], "merge") == 0) {
+ mGlobals.Mode = MODE_MERGE_HII_EXPORTS;
+ } else if (_stricmp (Argv[0], "defaults") == 0) {
+ mGlobals.Mode = MODE_EMIT_DEFAULTS;
+ } else if (_stricmp (Argv[0], "dump") == 0) {
+ mGlobals.Mode = MODE_DUMP_HII_EXPORT;
+ } else if (strcmp (Argv[0], "-?") == 0) {
+ Usage ();
+ return STATUS_ERROR;
+ } else {
+ Error (NULL, 0, 0, Argv[0], "unrecognized mode");
+ return STATUS_ERROR;
+ }
+
+ Argv++;
+ Argc--;
+ //
+ // Process until no more args.
+ //
+ while (Argc > 0) {
+ if (_stricmp (Argv[0], "-o") == 0) {
+ //
+ // -o option to specify the output file
+ //
+ if ((Argc <= 1) || (Argv[1][0] == '-')) {
+ Error (UTILITY_NAME, 0, 0, Argv[0], "missing output file name");
+ return STATUS_ERROR;
+ }
+
+ if (mGlobals.OutputFileName[0] == 0) {
+ mGlobals.OutputFileName[MAX_PATH - 1] = 0;
+ strncpy (mGlobals.OutputFileName, Argv[1], MAX_PATH - 1);
+ } else {
+ Error (UTILITY_NAME, 0, 0, Argv[1], "-o option already specified with '%s'", mGlobals.OutputFileName);
+ return STATUS_ERROR;
+ }
+
+ Argv++;
+ Argc--;
+ } else if (_stricmp (Argv[0], "-mfg") == 0) {
+ mGlobals.MfgFlag = 1;
+ } else if (_stricmp (Argv[0], "-g") == 0) {
+ //
+ // -g option to specify the guid
+ //
+ if ((Argc <= 1) || (Argv[1][0] == '-')) {
+ Error (UTILITY_NAME, 0, 0, Argv[0], "missing GUID");
+ return STATUS_ERROR;
+ }
+
+ StringToGuid (Argv[1], &mGlobals.Guid);
+ mGlobals.GuidSpecified = 1;
+ Argv++;
+ Argc--;
+ } else if (_stricmp (Argv[0], "-v") == 0) {
+ mGlobals.Verbose = 1;
+ } else if (_stricmp (Argv[0], "-p") == 0) {
+ //
+ // -p option to specify an input pack file. Only valid for 'create' mode
+ //
+ if (mGlobals.Mode != MODE_CREATE_HII_EXPORT) {
+ Error (NULL, 0, 0, Argv[0], "option only valid in 'create' mode");
+ return STATUS_ERROR;
+ }
+
+ if ((Argc <= 1) || (Argv[1][0] == '-')) {
+ Error (UTILITY_NAME, 0, 0, Argv[0], "missing pack file name");
+ return STATUS_ERROR;
+ }
+ //
+ // Consume arguments until next -arg or end
+ //
+ do {
+ Argv++;
+ Argc--;
+ //
+ // Open the file, read the pack header, and figure out what type of
+ // HII pack it is.
+ //
+ if ((InFptr = fopen (Argv[0], "rb")) == NULL) {
+ Error (NULL, 0, 0, Argv[0], "failed to open input HII pack file for reading");
+ return STATUS_ERROR;
+ }
+
+ if (fread (&PackHeader, sizeof (EFI_HII_PACK_HEADER), 1, InFptr) != 1) {
+ Error (NULL, 0, 0, Argv[0], "failed to read pack header from input HII pack file");
+ fclose (InFptr);
+ return STATUS_ERROR;
+ }
+
+ fclose (InFptr);
+ if ((PackHeader.Type != EFI_HII_STRING) &&
+ (PackHeader.Type != EFI_HII_IFR) &&
+ (PackHeader.Type != EFI_HII_VARIABLE)
+ ) {
+ Error (NULL, 0, 0, Argv[0], "unsupported HII pack type 0x%X", (unsigned int) PackHeader.Type);
+ return STATUS_ERROR;
+ }
+ //
+ // Add this file name to our list of pack files
+ //
+ FileName = (FILE_NAME_LIST *) malloc (sizeof (FILE_NAME_LIST));
+ if (FileName == NULL) {
+ Error (NULL, 0, 0, "memory allocation failure", NULL);
+ return STATUS_ERROR;
+ }
+
+ memset ((void *) FileName, 0, sizeof (FILE_NAME_LIST));
+ FileName->Tag = (int) PackHeader.Type;
+ strcpy (FileName->FileName, Argv[0]);
+ if (mGlobals.PackFileNames == NULL) {
+ mGlobals.PackFileNames = FileName;
+ } else {
+ //
+ // Add to the end of the list
+ //
+ for (TempFileName = mGlobals.PackFileNames; TempFileName->Next != NULL; TempFileName = TempFileName->Next)
+ ;
+ TempFileName->Next = FileName;
+ }
+ } while ((Argc > 1) && (Argv[1][0] != '-'));
+ } else if (_stricmp (Argv[0], "-noemptyvarpacks") == 0) {
+ mGlobals.NoEmptyVarPacks = 1;
+ } else if (_stricmp (Argv[0], "-novarpacks") == 0) {
+ mGlobals.NoVarPacks = 1;
+ } else if (_stricmp (Argv[0], "-x") == 0) {
+ //
+ // -x option to specify an input HII export file name. Not valid for 'create' mode
+ //
+ if (mGlobals.Mode == MODE_CREATE_HII_EXPORT) {
+ Error (NULL, 0, 0, Argv[0], "option is not valid in 'create' mode");
+ return STATUS_ERROR;
+ }
+
+ if ((Argc <= 1) || (Argv[1][0] == '-')) {
+ Error (UTILITY_NAME, 0, 0, Argv[0], "missing HII export input file name");
+ return STATUS_ERROR;
+ }
+ //
+ // Consume arguments until next -arg or end
+ //
+ do {
+ Argv++;
+ Argc--;
+ //
+ // Add this file name to our list of export files
+ //
+ FileName = (FILE_NAME_LIST *) malloc (sizeof (FILE_NAME_LIST));
+ if (FileName == NULL) {
+ Error (NULL, 0, 0, "memory allocation failure", NULL);
+ return STATUS_ERROR;
+ }
+
+ memset ((void *) FileName, 0, sizeof (FILE_NAME_LIST));
+ strcpy (FileName->FileName, Argv[0]);
+ if (mGlobals.HiiExportFileNames == NULL) {
+ mGlobals.HiiExportFileNames = FileName;
+ } else {
+ //
+ // Add to the end of the list
+ //
+ for (TempFileName = mGlobals.HiiExportFileNames;
+ TempFileName->Next != NULL;
+ TempFileName = TempFileName->Next
+ )
+ ;
+ TempFileName->Next = FileName;
+ }
+ } while ((Argc > 1) && (Argv[1][0] != '-'));
+ } else if (_stricmp (Argv[0], "-dumpstrings") == 0) {
+ mGlobals.DumpStrings = 1;
+ } else if (_stricmp (Argv[0], "-s") == 0) {
+ //
+ // -s option to specify input HII export files using a path and file mask.
+ // Only valid in merge mode
+ //
+ if (mGlobals.Mode != MODE_MERGE_HII_EXPORTS) {
+ Error (NULL, 0, 0, Argv[0], "option only valid in 'merge' mode");
+ return STATUS_ERROR;
+ }
+
+ if ((Argc <= 1) || (Argv[1][0] == '-')) {
+ Error (UTILITY_NAME, 0, 0, Argv[0], "missing root directory name");
+ return STATUS_ERROR;
+ }
+
+ if ((Argc <= 2) || (Argv[2][0] == '-')) {
+ Error (UTILITY_NAME, 0, 0, Argv[0], "missing file mask");
+ return STATUS_ERROR;
+ }
+ //
+ // Call our function to process the directory and file mask. If
+ // the directory does not start with c:\, then prepend cwd to it.
+ //
+ if (FindFiles (Argv[1], Argv[2], FindFilesCallback)) {
+ Error (NULL, 0, 0, "failed to process matching files", "%s\\%s", Argv[1], Argv[2]);
+ return STATUS_ERROR;
+ }
+
+ Argv += 2;
+ Argc -= 2;
+ } else if (_stricmp (Argv[0], "-p") == 0) {
+ //
+ // -p option to specify an input pack file. Only valid for 'create' mode
+ //
+ if (mGlobals.Mode != MODE_CREATE_HII_EXPORT) {
+ Error (NULL, 0, 0, Argv[0], "option only valid in 'create' mode");
+ return STATUS_ERROR;
+ }
+
+ if ((Argc <= 1) || (Argv[1][0] == '-')) {
+ Error (UTILITY_NAME, 0, 0, Argv[0], "missing pack file name");
+ return STATUS_ERROR;
+ }
+ //
+ // Consume arguments until next -arg or end
+ //
+ do {
+ Argv++;
+ Argc--;
+ //
+ // Open the file, read the pack header, and figure out what type of
+ // HII pack it is.
+ //
+ if ((InFptr = fopen (Argv[0], "rb")) == NULL) {
+ Error (NULL, 0, 0, Argv[0], "failed to open input HII pack file for reading");
+ return STATUS_ERROR;
+ }
+
+ if (fread (&PackHeader, sizeof (EFI_HII_PACK_HEADER), 1, InFptr) != 1) {
+ Error (NULL, 0, 0, Argv[0], "failed to read pack header from input HII pack file");
+ fclose (InFptr);
+ return STATUS_ERROR;
+ }
+
+ fclose (InFptr);
+ if ((PackHeader.Type != EFI_HII_STRING) &&
+ (PackHeader.Type != EFI_HII_IFR) &&
+ (PackHeader.Type != EFI_HII_VARIABLE)
+ ) {
+ Error (NULL, 0, 0, Argv[0], "unsupported HII pack type 0x%X", (unsigned int) PackHeader.Type);
+ return STATUS_ERROR;
+ }
+ //
+ // Add this file name to our list of pack files
+ //
+ FileName = (FILE_NAME_LIST *) malloc (sizeof (FILE_NAME_LIST));
+ if (FileName == NULL) {
+ Error (NULL, 0, 0, "memory allocation failure", NULL);
+ return STATUS_ERROR;
+ }
+
+ memset ((void *) FileName, 0, sizeof (FILE_NAME_LIST));
+ FileName->Tag = (int) PackHeader.Type;
+ strcpy (FileName->FileName, Argv[0]);
+ if (mGlobals.PackFileNames == NULL) {
+ mGlobals.PackFileNames = FileName;
+ } else {
+ //
+ // Add to the end of the list
+ //
+ for (TempFileName = mGlobals.PackFileNames; TempFileName->Next != NULL; TempFileName = TempFileName->Next)
+ ;
+ TempFileName->Next = FileName;
+ }
+ } while ((Argc > 1) && (Argv[1][0] != '-'));
+ } else {
+ Error (NULL, 0, 0, Argv[0], "unrecognized option");
+ return STATUS_ERROR;
+ }
+
+ Argv++;
+ Argc--;
+ }
+ //
+ // All modes except 'defaults' requires an output file name
+ //
+ if (mGlobals.Mode != MODE_EMIT_DEFAULTS) {
+ if (mGlobals.OutputFileName[0] == 0) {
+ Error (NULL, 0, 0, "must specify '-o OutputFileName'", NULL);
+ return STATUS_ERROR;
+ }
+ //
+ // If merging, then you have to specify at least one HII export files.
+ // We support specifying only one file in case you want to take an export file
+ // and emit a copy with different (for example, manufacturing) defaults.
+ //
+ if (mGlobals.Mode == MODE_MERGE_HII_EXPORTS) {
+ if (mGlobals.HiiExportFileNames == NULL) {
+ Error (NULL, 0, 0, "must specify at least one HII export file in 'merge' mode", NULL);
+ return STATUS_ERROR;
+ }
+ } else if (mGlobals.Mode == MODE_CREATE_HII_EXPORT) {
+ //
+ // Must have specified at least one HII pack file
+ //
+ if (mGlobals.PackFileNames == NULL) {
+ Error (NULL, 0, 0, "must specify at least one input HII pack file in 'create' mode", NULL);
+ return STATUS_ERROR;
+ }
+ }
+ } else {
+ //
+ // Must have specified an input HII export file name
+ //
+ if (mGlobals.HiiExportFileNames == NULL) {
+ Error (NULL, 0, 0, "must specify at least one '-x HiiExportFileName'", NULL);
+ return STATUS_ERROR;
+ }
+ }
+
+ return STATUS_SUCCESS;
+}
+
+static
+void
+Usage (
+ VOID
+ )
+/*++
+
+Routine Description:
+
+ Print usage information for this utility.
+
+Arguments:
+
+ None.
+
+Returns:
+
+ Nothing.
+
+--*/
+{
+ int Index;
+ const char *Str[] = {
+ UTILITY_NAME" "UTILITY_VERSION" - Create/Dump HII Database Files Utility",
+ " Copyright (C), 2004 - 2008 Intel Corporation",
+#if ( defined(UTILITY_BUILD) && defined(UTILITY_VENDOR) )
+ " Built from "UTILITY_BUILD", project of "UTILITY_VENDOR,
+#endif
+ "",
+ "Usage:",
+ " "UTILITY_NAME " [MODE] [OPTION]",
+ "Modes:",
+ " create create an HII export file from one or more HII pack files",
+ " merge merge two or more HII export files into one HII export file",
+ " defaults emit variable defaults from an input HII export file",
+ " dump ASCII dump the contents of an HII export file",
+ "Options for all modes:",
+ " -o FileName write output to FileName",
+ " -mfg use manufacturing defaults from IFR rather than standard defaults",
+ " -g GUID use GUID for a package GUID in the data tables where applicable",
+ " -v verbose operation",
+ "Options for 'create' mode:",
+ " -p PackFileName(s) include contents of HII pack file PackFileName",
+ " in the output file",
+ " -novarpacks don't emit variable packs to the output file",
+ "Options for 'merge' mode:",
+ " -x HiiExportFileName(s) include contents of HII export file",
+ " HiiExportFileName in the output file",
+ " -s Path FileMask include all matching HII export files in Path",
+ " and its subdirectories in the output file.",
+ " If Path does not begin with the form C:\\, then",
+ " it is assumed to be relative to the current working",
+ " directory. FileMask may contain wildcard characters.",
+ "Options for 'defaults' mode:",
+ " -x HiiExportFileName emit defaults from all variables referenced",
+ " in input file HiiExportFileName",
+ " -noemptyvarpacks don't emit variable packs for 0-length variables",
+ "Options for 'dump' mode:",
+ " -x HiiExportFileName dump contents of input file HiiExportFileName",
+ " -dumpstrings dump string data",
+ NULL
+ };
+ for (Index = 0; Str[Index] != NULL; Index++) {
+ fprintf (stdout, "%s\n", Str[Index]);
+ }
+}
diff --git a/EdkCompatibilityPkg/Sample/Tools/Source/HiiPack/HiiPack.h b/EdkCompatibilityPkg/Sample/Tools/Source/HiiPack/HiiPack.h
new file mode 100644
index 0000000000..e9fa66b759
--- /dev/null
+++ b/EdkCompatibilityPkg/Sample/Tools/Source/HiiPack/HiiPack.h
@@ -0,0 +1,63 @@
+/*++
+
+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:
+
+ HiiPack.h
+
+Abstract:
+
+ Common defines and prototypes for the HII pack tool.
+
+--*/
+
+#ifndef _HII_PACK_H_
+#define _HII_PACK_H_
+
+#define DEFAULT_VARIABLE_NAME_L L"Setup"
+#define DEFAULT_VARIABLE_NAME "Setup"
+
+#define MAX_VARIABLE_NAME 256
+#define FIRST_HII_PACK_HANDLE 1
+
+typedef
+int
+(*FIND_FILE_CALLBACK) (
+ char *FileName
+ );
+
+extern
+int
+FindFiles (
+ char *RootDirectory,
+ char *FileMask,
+ FIND_FILE_CALLBACK Callback
+ )
+/*++
+
+Routine Description:
+
+ GC_TODO: Add function description
+
+Arguments:
+
+ RootDirectory - GC_TODO: add argument description
+ FileMask - GC_TODO: add argument description
+ Callback - GC_TODO: add argument description
+
+Returns:
+
+ GC_TODO: add return values
+
+--*/
+;
+
+#endif // #ifndef _HII_PACK_H_
diff --git a/EdkCompatibilityPkg/Sample/Tools/Source/HiiPack/IfrParse.c b/EdkCompatibilityPkg/Sample/Tools/Source/HiiPack/IfrParse.c
new file mode 100644
index 0000000000..e69af5c259
--- /dev/null
+++ b/EdkCompatibilityPkg/Sample/Tools/Source/HiiPack/IfrParse.c
@@ -0,0 +1,2533 @@
+/*++
+
+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:
+
+ IfrParse.c
+
+Abstract:
+
+ Routines for parsing and managing HII IFR packs.
+
+--*/
+
+#include <stdio.h>
+#include <string.h>
+#include <stdlib.h>
+
+#include "Tiano.h"
+#include "EfiUtilityMsgs.h"
+#include "EfiInternalFormRepresentation.h"
+#include "Hii.h"
+#include "IfrParse.h"
+#include "HiiPack.h"
+
+typedef struct _VARIABLE_STORE_ENTRY {
+ struct _VARIABLE_STORE_ENTRY *Next;
+ CHAR8 VarName[MAX_VARIABLE_NAME];
+ char *VarBuffer;
+ int VarBufferSize;
+ EFI_HII_VARIABLE_PACK *VarPack;
+ int VarPackSize;
+} VARIABLE_STORE_ENTRY;
+
+typedef STATUS (*IFR_PARSE_FUNCTION) (IFR_PARSE_CONTEXT * Context);
+
+typedef struct {
+ INT8 *Name;
+ INT32 Size;
+ IFR_PARSE_FUNCTION Parse;
+} IFR_PARSE_TABLE_ENTRY;
+
+static
+STATUS
+IfrParse01 (
+ IFR_PARSE_CONTEXT *Context
+ );
+static
+STATUS
+IfrParse02 (
+ IFR_PARSE_CONTEXT *Context
+ );
+static
+STATUS
+IfrParse03 (
+ IFR_PARSE_CONTEXT *Context
+ );
+static
+STATUS
+IfrParse05 (
+ IFR_PARSE_CONTEXT *Context
+ );
+static
+STATUS
+IfrParse06 (
+ IFR_PARSE_CONTEXT *Context
+ );
+static
+STATUS
+IfrParse07 (
+ IFR_PARSE_CONTEXT *Context
+ );
+static
+STATUS
+IfrParse08 (
+ IFR_PARSE_CONTEXT *Context
+ );
+static
+STATUS
+IfrParse09 (
+ IFR_PARSE_CONTEXT *Context
+ );
+static
+STATUS
+IfrParse0A (
+ IFR_PARSE_CONTEXT *Context
+ );
+static
+STATUS
+IfrParse0B (
+ IFR_PARSE_CONTEXT *Context
+ );
+static
+STATUS
+IfrParse0C (
+ IFR_PARSE_CONTEXT *Context
+ );
+static
+STATUS
+IfrParse0D (
+ IFR_PARSE_CONTEXT *Context
+ );
+static
+STATUS
+IfrParse0E (
+ IFR_PARSE_CONTEXT *Context
+ );
+static
+STATUS
+IfrParse0F (
+ IFR_PARSE_CONTEXT *Context
+ );
+static
+STATUS
+IfrParse10 (
+ IFR_PARSE_CONTEXT *Context
+ );
+static
+STATUS
+IfrParse11 (
+ IFR_PARSE_CONTEXT *Context
+ );
+static
+STATUS
+IfrParse12 (
+ IFR_PARSE_CONTEXT *Context
+ );
+static
+STATUS
+IfrParse13 (
+ IFR_PARSE_CONTEXT *Context
+ );
+static
+STATUS
+IfrParse14 (
+ IFR_PARSE_CONTEXT *Context
+ );
+static
+STATUS
+IfrParse15 (
+ IFR_PARSE_CONTEXT *Context
+ );
+static
+STATUS
+IfrParse16 (
+ IFR_PARSE_CONTEXT *Context
+ );
+static
+STATUS
+IfrParse17 (
+ IFR_PARSE_CONTEXT *Context
+ );
+static
+STATUS
+IfrParse18 (
+ IFR_PARSE_CONTEXT *Context
+ );
+static
+STATUS
+IfrParse19 (
+ IFR_PARSE_CONTEXT *Context
+ );
+static
+STATUS
+IfrParse1A (
+ IFR_PARSE_CONTEXT *Context
+ );
+static
+STATUS
+IfrParse1B (
+ IFR_PARSE_CONTEXT *Context
+ );
+static
+STATUS
+IfrParse1C (
+ IFR_PARSE_CONTEXT *Context
+ );
+static
+STATUS
+IfrParse1D (
+ IFR_PARSE_CONTEXT *Context
+ );
+static
+STATUS
+IfrParse1E (
+ IFR_PARSE_CONTEXT *Context
+ );
+static
+STATUS
+IfrParse1F (
+ IFR_PARSE_CONTEXT *Context
+ );
+static
+STATUS
+IfrParse20 (
+ IFR_PARSE_CONTEXT *Context
+ );
+static
+STATUS
+IfrParse21 (
+ IFR_PARSE_CONTEXT *Context
+ );
+static
+STATUS
+IfrParse22 (
+ IFR_PARSE_CONTEXT *Context
+ );
+static
+STATUS
+IfrParse23 (
+ IFR_PARSE_CONTEXT *Context
+ );
+static
+STATUS
+IfrParse24 (
+ IFR_PARSE_CONTEXT *Context
+ );
+static
+STATUS
+IfrParse25 (
+ IFR_PARSE_CONTEXT *Context
+ );
+static
+STATUS
+IfrParse26 (
+ IFR_PARSE_CONTEXT *Context
+ );
+static
+STATUS
+IfrParse27 (
+ IFR_PARSE_CONTEXT *Context
+ );
+static
+STATUS
+IfrParse28 (
+ IFR_PARSE_CONTEXT *Context
+ );
+static
+STATUS
+IfrParse29 (
+ IFR_PARSE_CONTEXT *Context
+ );
+static
+STATUS
+IfrParse2A (
+ IFR_PARSE_CONTEXT *Context
+ );
+
+static const IFR_PARSE_TABLE_ENTRY mIfrParseTable[] = {
+ {
+ 0,
+ 0,
+ NULL
+ }, // invalid
+ {
+ "EFI_IFR_FORM",
+ sizeof (EFI_IFR_FORM),
+ IfrParse01
+ },
+ {
+ "EFI_IFR_SUBTITLE",
+ sizeof (EFI_IFR_SUBTITLE),
+ IfrParse02
+ },
+ {
+ "EFI_IFR_TEXT",
+ -6,
+ IfrParse03
+ }, // sizeof (EFI_IFR_TEXT) },
+ {
+ "unused 0x04 opcode",
+ 0,
+ NULL
+ }, // EFI_IFR_GRAPHIC_OP
+ {
+ "EFI_IFR_ONE_OF",
+ sizeof (EFI_IFR_ONE_OF),
+ IfrParse05
+ },
+ {
+ "EFI_IFR_CHECK_BOX",
+ sizeof (EFI_IFR_CHECK_BOX),
+ IfrParse06
+ },
+ {
+ "EFI_IFR_NUMERIC",
+ sizeof (EFI_IFR_NUMERIC),
+ IfrParse07
+ },
+ {
+ "EFI_IFR_PASSWORD",
+ sizeof (EFI_IFR_PASSWORD),
+ IfrParse08
+ },
+ {
+ "EFI_IFR_ONE_OF_OPTION",
+ sizeof (EFI_IFR_ONE_OF_OPTION),
+ IfrParse09
+ },
+ {
+ "EFI_IFR_SUPPRESS",
+ sizeof (EFI_IFR_SUPPRESS),
+ IfrParse0A
+ },
+ {
+ "EFI_IFR_END_FORM",
+ sizeof (EFI_IFR_END_FORM),
+ IfrParse0B
+ },
+ {
+ "EFI_IFR_HIDDEN",
+ sizeof (EFI_IFR_HIDDEN),
+ IfrParse0C
+ },
+ {
+ "EFI_IFR_END_FORM_SET",
+ sizeof (EFI_IFR_END_FORM_SET),
+ IfrParse0D
+ },
+ {
+ "EFI_IFR_FORM_SET",
+ sizeof (EFI_IFR_FORM_SET),
+ IfrParse0E
+ },
+ {
+ "EFI_IFR_REF",
+ sizeof (EFI_IFR_REF),
+ IfrParse0F
+ },
+ {
+ "EFI_IFR_END_ONE_OF",
+ sizeof (EFI_IFR_END_ONE_OF),
+ IfrParse10
+ },
+ {
+ "EFI_IFR_INCONSISTENT",
+ sizeof (EFI_IFR_INCONSISTENT),
+ IfrParse11
+ },
+ {
+ "EFI_IFR_EQ_ID_VAL",
+ sizeof (EFI_IFR_EQ_ID_VAL),
+ IfrParse12
+ },
+ {
+ "EFI_IFR_EQ_ID_ID",
+ sizeof (EFI_IFR_EQ_ID_ID),
+ IfrParse13
+ },
+ {
+ "EFI_IFR_EQ_ID_LIST",
+ -(int) (sizeof (EFI_IFR_EQ_ID_LIST)),
+ IfrParse14
+ },
+ {
+ "EFI_IFR_AND",
+ sizeof (EFI_IFR_AND),
+ IfrParse15
+ },
+ {
+ "EFI_IFR_OR",
+ sizeof (EFI_IFR_OR),
+ IfrParse16
+ },
+ {
+ "EFI_IFR_NOT",
+ sizeof (EFI_IFR_NOT),
+ IfrParse17
+ },
+ {
+ "EFI_IFR_END_IF",
+ sizeof (EFI_IFR_END_IF),
+ IfrParse18
+ },
+ {
+ "EFI_IFR_GRAYOUT",
+ sizeof (EFI_IFR_GRAYOUT),
+ IfrParse19
+ },
+ {
+ "EFI_IFR_DATE",
+ sizeof (EFI_IFR_DATE) / 3,
+ IfrParse1A
+ },
+ {
+ "EFI_IFR_TIME",
+ sizeof (EFI_IFR_TIME) / 3,
+ IfrParse1B
+ },
+ {
+ "EFI_IFR_STRING",
+ sizeof (EFI_IFR_STRING),
+ IfrParse1C
+ },
+ {
+ "EFI_IFR_LABEL",
+ sizeof (EFI_IFR_LABEL),
+ IfrParse1D
+ },
+ {
+ "EFI_IFR_SAVE_DEFAULTS",
+ sizeof (EFI_IFR_SAVE_DEFAULTS),
+ IfrParse1E
+ },
+ {
+ "EFI_IFR_RESTORE_DEFAULTS",
+ sizeof (EFI_IFR_RESTORE_DEFAULTS),
+ IfrParse1F
+ },
+ {
+ "EFI_IFR_BANNER",
+ sizeof (EFI_IFR_BANNER),
+ IfrParse20
+ },
+ {
+ "EFI_IFR_INVENTORY",
+ sizeof (EFI_IFR_INVENTORY),
+ IfrParse21
+ },
+ {
+ "EFI_IFR_EQ_VAR_VAL_OP",
+ sizeof (EFI_IFR_EQ_VAR_VAL),
+ IfrParse22
+ },
+ {
+ "EFI_IFR_ORDERED_LIST_OP",
+ sizeof (EFI_IFR_ORDERED_LIST),
+ IfrParse23
+ },
+ {
+ "EFI_IFR_VARSTORE_OP",
+ -(int) (sizeof (EFI_IFR_VARSTORE)),
+ IfrParse24
+ },
+ {
+ "EFI_IFR_VARSTORE_SELECT_OP",
+ sizeof (EFI_IFR_VARSTORE_SELECT),
+ IfrParse25
+ },
+ {
+ "EFI_IFR_VARSTORE_SELECT_PAIR_OP",
+ sizeof (EFI_IFR_VARSTORE_SELECT_PAIR),
+ IfrParse26
+ },
+ {
+ "EFI_IFR_TRUE",
+ sizeof (EFI_IFR_TRUE),
+ IfrParse27
+ },
+ {
+ "EFI_IFR_FALSE",
+ sizeof (EFI_IFR_FALSE),
+ IfrParse28
+ },
+ {
+ "EFI_IFR_GT",
+ sizeof (EFI_IFR_GT),
+ IfrParse29
+ },
+ {
+ "EFI_IFR_GE",
+ sizeof (EFI_IFR_GE),
+ IfrParse2A
+ },
+};
+#define PARSE_TABLE_ENTRIES (sizeof (mIfrParseTable) / sizeof (mIfrParseTable[0]))
+
+static
+STATUS
+GetVarStoreInfo (
+ IFR_PARSE_CONTEXT *Context,
+ UINT16 VarId,
+ EFI_GUID **VarStoreGuid,
+ char **VarStoreName
+ );
+
+static
+void
+FreeVarStores (
+ VOID
+ );
+
+static
+STATUS
+CreateVarStore (
+ EFI_GUID *VarGuid,
+ CHAR8 *VarName,
+ int VarStoreSize
+ );
+
+static
+STATUS
+SetDefaults (
+ IFR_PARSE_CONTEXT *Context,
+ UINT32 MfgDefaults
+ );
+
+//
+// Globals
+//
+static IFR_PARSE_CONTEXT *mParseContext = NULL;
+static VARIABLE_STORE_ENTRY *mVariableStores = NULL;
+static int BreakOnOpcodeTag = 0;
+static int OpcodeTag = 1;
+
+/*****************************************************************************/
+STATUS
+IfrParseCheck (
+ char *Buffer,
+ long BufferSize
+ )
+/*++
+
+Routine Description:
+
+ Check a buffer to ensure that is is parseable IFR
+
+Arguments:
+
+ Buffer - pointer to raw IFR bytes
+ BufferSize - size of IFR pointed to by Buffer
+
+Returns:
+
+ STATUS_SUCCESS if successful
+ STATUS_ERROR otherwise
+
+--*/
+{
+ char *Start;
+
+ char *End;
+
+ char *Pos;
+ EFI_IFR_OP_HEADER *OpHeader;
+ char *FileName;
+ FileName = "";
+ //
+ // Walk the list of IFR statements in the IFR pack
+ //
+ Start = Buffer;
+ Pos = Buffer;
+ End = Start + BufferSize;
+ while ((Pos >= Start) && (Pos < End)) {
+ OpHeader = (EFI_IFR_OP_HEADER *) Pos;
+ //
+ // Check range on size
+ //
+ if (Pos + OpHeader->Length > End) {
+ Error (NULL, 0, 0, FileName, "invalid IFR opcode size at offset 0x%X", (int) Pos - (int) Start);
+ return STATUS_ERROR;
+ }
+
+ if (OpHeader->Length == 0) {
+ Error (NULL, 0, 0, FileName, "IFR opcode size=0 at offset 0x%X", (int) Pos - (int) Start);
+ return STATUS_ERROR;
+ }
+ //
+ // See if it's the END_FORMSET opcode
+ //
+ if (OpHeader->OpCode == EFI_IFR_END_FORM_SET_OP) {
+ break;
+ }
+ //
+ // Advance to next IFR statement/opcode
+ //
+ Pos += OpHeader->Length;
+ }
+
+ return STATUS_SUCCESS;
+}
+
+STATUS
+IfrParseInit (
+ VOID
+ )
+/*++
+
+Routine Description:
+
+ Initialize this module for IFR pack parsing
+
+Arguments:
+
+Returns:
+
+ STATUS_SUCCESS always
+
+--*/
+{
+ return STATUS_SUCCESS;
+}
+
+STATUS
+IfrParseEnd (
+ VOID
+ )
+/*++
+
+Routine Description:
+
+ Free up memory allocated during IFR pack parsing done by this module
+
+Arguments:
+ None
+
+Returns:
+
+ STATUS_SUCCESS always
+
+--*/
+{
+ IFR_PARSE_CONTEXT *NextContext;
+ IFR_PARSE_ENTRY *NextEntry;
+ //
+ // Free up the memory from our parse contexts
+ //
+ while (mParseContext != NULL) {
+ while (mParseContext->Ifr != NULL) {
+ NextEntry = mParseContext->Ifr->Next;
+ //
+ // We pointed directly into the user buffer, rather than make
+ // a copy, so don't free up the bytes.
+ //
+ free (mParseContext->Ifr);
+ mParseContext->Ifr = NextEntry;
+ }
+
+ NextContext = mParseContext->Next;
+ free (mParseContext->PackHeader);
+ free (mParseContext);
+ mParseContext = NextContext;
+ }
+
+ return STATUS_SUCCESS;
+}
+
+static
+void
+FreeVarStores (
+ VOID
+ )
+/*++
+
+Routine Description:
+
+ GC_TODO: Add function description
+
+Arguments:
+
+ None
+
+Returns:
+
+ GC_TODO: add return values
+
+--*/
+{
+ VARIABLE_STORE_ENTRY *NextVarStore;
+ //
+ // Free up memory from our variable stores
+ //
+ while (mVariableStores != NULL) {
+ if (mVariableStores->VarPack != NULL) {
+ free (mVariableStores->VarPack);
+ }
+
+ NextVarStore = mVariableStores->Next;
+ free (mVariableStores);
+ mVariableStores = NextVarStore;
+ }
+}
+
+/******************************************************************************
+ FUNCTION: IfrParsePack()
+
+ DESCRIPTION: Given a pointer to an IFR pack, parse it to create a linked
+ list of opcodes and relevant data required for later dumping.
+
+
+*******************************************************************************/
+STATUS
+IfrParsePack (
+ int Handle,
+ EFI_HII_IFR_PACK *PackHeader,
+ EFI_GUID *PackageGuid
+ )
+/*++
+
+Routine Description:
+
+ Given a pointer to an IFR pack, parse it to create a linked
+ list of opcodes and relevant data required for later dumping.
+
+Arguments:
+
+ Handle - the handle number associated with this IFR pack. It
+ can be used later to retrieve more info on the particular
+ pack
+ PackHeader - pointer to IFR pack to parse
+ PackageGuid - on input, it comes from the HII data table entry for this pack.
+ On output, we'll return the IFR formset GUID.
+
+Returns:
+
+ STATUS_SUCCESS always
+
+--*/
+{
+ EFI_IFR_OP_HEADER *OpHeader;
+ IFR_PARSE_CONTEXT *Context;
+ IFR_PARSE_CONTEXT *TempContext;
+ IFR_PARSE_ENTRY *IfrEntry;
+ //
+ // Initialize our context
+ //
+ Context = (IFR_PARSE_CONTEXT *) malloc (sizeof (IFR_PARSE_CONTEXT));
+ if (Context == NULL) {
+ Error (NULL, 0, 0, "memory allocation failure", NULL);
+ return STATUS_ERROR;
+ }
+
+ memset ((void *) Context, 0, sizeof (IFR_PARSE_CONTEXT));
+ //
+ // Cache a copy of the input pack so the caller can free their copy
+ //
+ Context->PackHeader = (EFI_HII_IFR_PACK *) malloc (PackHeader->Header.Length);
+ if (Context->PackHeader == NULL) {
+ Error (NULL, 0, 0, "memory allocation failure", NULL);
+ free (Context);
+ return STATUS_ERROR;
+ }
+
+ memcpy (Context->PackHeader, PackHeader, PackHeader->Header.Length);
+ Context->IfrBufferStart = (char *) (Context->PackHeader + 1);
+ Context->CurrentPos = Context->IfrBufferStart;
+ Context->IfrBufferLen = PackHeader->Header.Length - sizeof (EFI_HII_IFR_PACK);
+ Context->Handle = Handle;
+ Context->FormsetGuid = &Context->NullGuid;
+ Context->PackageGuid = *PackageGuid;
+ //
+ // Add it to the end of our list
+ //
+ if (mParseContext == NULL) {
+ mParseContext = Context;
+ } else {
+ TempContext = mParseContext;
+ while (TempContext->Next != NULL) {
+ TempContext = TempContext->Next;
+ }
+
+ TempContext->Next = Context;
+ }
+ //
+ // Walk the opcodes in the pack
+ //
+ while
+ (
+ (Context->CurrentPos >= Context->IfrBufferStart) &&
+ (Context->CurrentPos < Context->IfrBufferStart + Context->IfrBufferLen)
+ ) {
+ OpHeader = (EFI_IFR_OP_HEADER *) Context->CurrentPos;
+ //
+ // Allocate a new IFR entry to put in our linked list, then
+ // point directly to the caller's raw data.
+ //
+ IfrEntry = (IFR_PARSE_ENTRY *) malloc (sizeof (IFR_PARSE_ENTRY));
+ if (IfrEntry == NULL) {
+ Error (NULL, 0, 0, "memory allocation failure", NULL);
+ free (Context->PackHeader);
+ free (Context);
+ return STATUS_ERROR;
+ }
+
+ memset ((void *) IfrEntry, 0, sizeof (IFR_PARSE_ENTRY));
+ IfrEntry->Tag = ++OpcodeTag;
+ if (OpcodeTag == BreakOnOpcodeTag) {
+ EFI_BREAKPOINT ();
+ }
+
+ IfrEntry->RawIfrHeader = (EFI_IFR_OP_HEADER *) (Context->CurrentPos);
+ //
+ // Add this entry to our linked list. If it's not the first, then
+ // forward the variable store settings from the previous entry.
+ //
+ if (Context->LastIfr != NULL) {
+ IfrEntry->VarStoreGuid1 = Context->LastIfr->VarStoreGuid1;
+ IfrEntry->VarStoreName1 = Context->LastIfr->VarStoreName1;
+ IfrEntry->VarStoreGuid2 = Context->LastIfr->VarStoreGuid2;
+ IfrEntry->VarStoreName2 = Context->LastIfr->VarStoreName2;
+ Context->LastIfr->Next = IfrEntry;
+ } else {
+ Context->Ifr = IfrEntry;
+ }
+
+ Context->LastIfr = IfrEntry;
+ //
+ // Switch on the opcode to parse it
+ //
+ if (OpHeader->OpCode < PARSE_TABLE_ENTRIES) {
+ if (mIfrParseTable[OpHeader->OpCode].Parse != NULL) {
+ mIfrParseTable[OpHeader->OpCode].Parse (Context);
+ }
+ } else {
+ Error (
+ NULL,
+ 0,
+ 0,
+ "invalid opcode found in IFR",
+ "offset=0x%X opcode=0x%02X",
+ (int) OpHeader - (int) Context->PackHeader,
+ (int) OpHeader->OpCode
+ );
+ free (IfrEntry);
+ free (Context->PackHeader);
+ free (Context);
+ return STATUS_ERROR;
+ }
+ //
+ // If it's the END_FORMSET opcode, then we're done
+ //
+ if (OpHeader->OpCode == EFI_IFR_END_FORM_SET_OP) {
+ break;
+ }
+ //
+ // Advance to next IFR statement/opcode
+ //
+ if (OpHeader->Length == 0) {
+ Error (NULL, 0, 0, "0-length IFR opcode encountered", NULL);
+ free (IfrEntry);
+ free (Context->PackHeader);
+ free (Context);
+ return STATUS_ERROR;
+ }
+
+ Context->CurrentPos += OpHeader->Length;
+ }
+ //
+ // Return the form GUID.
+ //
+ *PackageGuid = *Context->FormsetGuid;
+ return STATUS_SUCCESS;
+}
+
+/******************************************************************************
+ FUNCTION: GetVarStoreInfo()
+
+ DESCRIPTION: IFR contains VARSTORE opcodes to specify where variable data
+ for following opcodes is supposed to be stored. One VARSTORE statement
+ allows you to specify the variable store GUID and a key, and another
+ VARSTORE (select) allows you to specify the key of a VARSTORE statement.
+ Given the key from a VARSTORE_SELECT statement, go find the corresponding
+ VARSTORE statement with a matching key and return the varstore GUID and
+ name. If key == 0, then the variable store is FormsetGuid."Setup"
+*******************************************************************************/
+static
+STATUS
+GetVarStoreInfo (
+ IFR_PARSE_CONTEXT *Context,
+ UINT16 VarId,
+ EFI_GUID **VarStoreGuid,
+ char **VarStoreName
+ )
+/*++
+
+Routine Description:
+
+ Get variable store information from an IFR pack for a given variable store ID.
+
+Arguments:
+
+ Context - pointer to IFR parse context
+ VarId - variable store ID referenced by IFR being parsed
+ VarStoreGuid - outgoing GUID of the variable store corresponding to VarId
+ VarStoreName - outgoing variable name of variable store corresponding to VarId
+
+Returns:
+
+ STATUS_SUCCESS - variable store with matching VarId found, and outoing GUID/Name are valid
+ STATUS_ERROR - otherwise
+
+--*/
+{
+ IFR_PARSE_ENTRY *Ptr;
+ EFI_IFR_VARSTORE *VarStore;
+ if (Context == NULL) {
+ return STATUS_ERROR;
+ }
+
+ //
+ // Walk the entire IFR form and find a variable store opcode that
+ // has a matching variable store ID.
+ //
+ for (Ptr = Context->Ifr; Ptr != NULL; Ptr = Ptr->Next) {
+ if (Ptr->RawIfrHeader->OpCode == EFI_IFR_FORM_SET_OP) {
+ if (VarId == 0) {
+ *VarStoreGuid = &((EFI_IFR_FORM_SET *) (Ptr->RawIfrHeader))->Guid;
+ *VarStoreName = DEFAULT_VARIABLE_NAME;
+ return STATUS_SUCCESS;
+ }
+ } else if (Ptr->RawIfrHeader->OpCode == EFI_IFR_VARSTORE_OP) {
+ //
+ // See if it's a variable ID match
+ //
+ VarStore = (EFI_IFR_VARSTORE *) Ptr->RawIfrHeader;
+ if (VarStore->VarId == VarId) {
+ *VarStoreGuid = &VarStore->Guid;
+ *VarStoreName = (char *) (VarStore + 1);
+ return STATUS_SUCCESS;
+ }
+ }
+ }
+
+ return STATUS_ERROR;
+}
+
+STATUS
+IfrSetDefaults (
+ int MfgDefaults
+ )
+/*++
+
+Routine Description:
+
+ Go through all the IFR forms we've parsed so far and create and set variable
+ defaults.
+
+Arguments:
+
+ MfgDefaults - non-zero if manufacturing defaults are desired
+
+Returns:
+
+ STATUS_SUCCESS - always
+
+--*/
+{
+ IFR_PARSE_CONTEXT *Context;
+ //
+ // First free up any variable stores we've created so far.
+ //
+ FreeVarStores ();
+ for (Context = mParseContext; Context != NULL; Context = Context->Next) {
+ //
+ // Call our internal function to handle it
+ //
+ SetDefaults (Context, MfgDefaults);
+ }
+
+ return STATUS_SUCCESS;
+
+}
+
+/******************************************************************************/
+STATUS
+IfrGetIfrPack (
+ int Handle,
+ EFI_HII_IFR_PACK **PackHeader,
+ EFI_GUID *FormsetGuid
+ )
+/*++
+
+Routine Description:
+
+ GC_TODO: Add function description
+
+Arguments:
+
+ Handle - GC_TODO: add argument description
+ PackHeader - GC_TODO: add argument description
+ FormsetGuid - GC_TODO: add argument description
+
+Returns:
+
+ GC_TODO: add return values
+
+--*/
+{
+ IFR_PARSE_CONTEXT *Context;
+
+ for (Context = mParseContext; Context != NULL; Context = Context->Next) {
+ if (Context->Handle == Handle) {
+ *PackHeader = Context->PackHeader;
+ memcpy (FormsetGuid, Context->FormsetGuid, sizeof (EFI_GUID));
+ return STATUS_SUCCESS;
+ }
+ }
+
+ return STATUS_ERROR;
+}
+
+STATUS
+IfrReferencesVarPack (
+ int IfrHandle,
+ EFI_HII_VARIABLE_PACK *VarPack
+ )
+/*++
+
+Routine Description:
+
+ Given an HII handle number (which corrresponds to a handle number passed
+ in to IfrParsePack()), see if the IFR references the specified variable
+ pack.
+
+Arguments:
+
+ IfrHandle - handle number for the IFR pack to check (passed to IfrParsePack())
+ VarPack - variable pack to check to see if the IFR references
+
+Returns:
+
+ STATUS_SUCCESS if the IFR on the given handle references the variable pack
+ STATUS_WARNING the IFR does not reference the variable pack
+ STATUS_ERROR invalid IFR handle
+
+--*/
+{
+ IFR_PARSE_CONTEXT *Context;
+ char VarName[MAX_VARIABLE_NAME];
+ IFR_PARSE_ENTRY *ParseEntry;
+
+ for (Context = mParseContext; Context != NULL; Context = Context->Next) {
+ if (Context->Handle == IfrHandle) {
+ //
+ // Create an ASCII version of the variable name, since that's what is
+ // referenced in IFR.
+ //
+ sprintf (VarName, "%S", (CHAR16 *) (VarPack + 1));
+ //
+ // Walk all the opcodes and see if the IFR references this variable pack
+ //
+ for (ParseEntry = Context->Ifr; ParseEntry != NULL; ParseEntry = ParseEntry->Next) {
+ //
+ // Check for Name.Guid match for primary IFR variable store
+ //
+ if ((strcmp (VarName, ParseEntry->VarStoreName1) == 0) &&
+ (memcmp (&VarPack->VariableGuid, ParseEntry->VarStoreGuid1, sizeof (EFI_GUID)) == 0)
+ ) {
+ return STATUS_SUCCESS;
+ }
+ //
+ // Check for Name.Guid match for secondary IFR variable store
+ //
+ if ((ParseEntry->VarStoreName2 != NULL) &&
+ (strcmp (VarName, ParseEntry->VarStoreName2) == 0) &&
+ (memcmp (&VarPack->VariableGuid, ParseEntry->VarStoreGuid2, sizeof (EFI_GUID)) == 0)
+ ) {
+ return STATUS_SUCCESS;
+ }
+ }
+
+ return STATUS_WARNING;
+ }
+ }
+
+ return STATUS_ERROR;
+}
+
+STATUS
+IfrGetVarPack (
+ int VarIndex,
+ EFI_HII_VARIABLE_PACK **VarPack
+ )
+/*++
+
+Routine Description:
+
+ Get the variable defaults. It is expected that the caller
+ called IfrSetDefaults() previously to walk all the IFR forms we know about
+ and create and initialize default values.
+
+Arguments:
+
+ VarIndex - a 0-based index into all the variable stores we know about
+ VarPack - outgoing pointer to a variable pack
+
+Returns:
+
+ STATUS_ERROR - VarIndex exceeds the number of variable packs we know of
+ STATUS_SUCCESS - otherwise
+
+--*/
+{
+ VARIABLE_STORE_ENTRY *Entry;
+ //
+ // Initialize outgoing parameters
+ //
+ *VarPack = NULL;
+ for (Entry = mVariableStores; Entry != NULL; Entry = Entry->Next) {
+ if (VarIndex == 0) {
+ *VarPack = Entry->VarPack;
+ return STATUS_SUCCESS;
+ }
+
+ VarIndex--;
+ }
+
+ return STATUS_ERROR;
+}
+
+static
+STATUS
+SetVariableValue (
+ EFI_GUID *VarGuid,
+ char *VarName,
+ int VarOffset,
+ int VarSize,
+ void *VarValue
+ )
+/*++
+
+Routine Description:
+
+ Given a variable GUID.Name, offset, size, and value, set the bytes in
+ the variable to the provided value.
+
+Arguments:
+ VarGuid - GUID of variable to set
+ VarName - name of variable to set
+ VarOffset - byte offset into the variable store
+ VarSize - size of the value in the variable store (in bytes)
+ VarValue - pointer to buffer containing the value to set
+
+Returns:
+
+
+--*/
+{
+ VARIABLE_STORE_ENTRY *Entry;
+ char *Src;
+ char *Dest;
+ //
+ // Go through our list of variable stores to find the match
+ //
+ for (Entry = mVariableStores; Entry != NULL; Entry = Entry->Next) {
+ if (memcmp (VarGuid, &Entry->VarPack->VariableGuid, sizeof (EFI_GUID)) == 0) {
+ if (strcmp (VarName, Entry->VarName) == 0) {
+ //
+ // Found match -- check offset. If it's beyond the size of the variable store
+ // buffer, then return a warning. Note that date-time can be beyond the
+ // end of the varstore, which is ok.
+ //
+ if (VarOffset + VarSize <= Entry->VarBufferSize) {
+ //
+ // Stuff the data
+ //
+ Dest = Entry->VarBuffer + VarOffset;
+ Src = (char *) VarValue;
+ while (VarSize > 0) {
+ *Dest = *Src;
+ Src++;
+ Dest++;
+ VarSize--;
+ }
+
+ return STATUS_SUCCESS;
+ }
+
+ return STATUS_WARNING;
+ }
+ }
+ }
+
+ return STATUS_ERROR;
+}
+
+static
+STATUS
+SetDefaults (
+ IFR_PARSE_CONTEXT *Context,
+ UINT32 MfgDefaults
+ )
+/*++
+
+Routine Description:
+
+ Set variable defaults by walking a single IFR form.
+
+Arguments:
+
+ Context - Pointer to the IFR context.
+ MfgDefaults - Number of Mfg defaults
+
+Returns:
+
+ EFI_INVALID_PARAMETER - arguments to function are invalid
+ STATUS_SUCCESS - function executed successfully
+
+--*/
+{
+ int Size;
+ int CachedVarOffset;
+ int CachedVarSize;
+ int OrderedList;
+ IFR_PARSE_ENTRY *SavedParseEntry;
+ EFI_IFR_CHECK_BOX *IfrCheckBox;
+ EFI_IFR_ONE_OF_OPTION *IfrOneOfOption;
+ EFI_IFR_NUMERIC *IfrNumeric;
+ STATUS Status;
+ char ZeroByte;
+
+ //
+ // Walk the opcodes to set default values and stuff them into the variable stores
+ //
+
+ if (Context == NULL) {
+ return EFI_INVALID_PARAMETER;
+ }
+ Status = STATUS_SUCCESS;
+ Context->CurrentIfr = Context->Ifr;
+ SavedParseEntry = NULL;
+ OrderedList = 0;
+ CachedVarOffset = 0;
+ CachedVarSize = 0;
+ ZeroByte = 0;
+
+ while (Context->CurrentIfr != NULL) {
+ if (Context->CurrentIfr->RawIfrHeader->OpCode == EFI_IFR_FORM_SET_OP) {
+ //
+ // Formset opcode -- create a variable pack
+ //
+ Status = CreateVarStore (
+ &((EFI_IFR_FORM_SET *) (Context->CurrentIfr->RawIfrHeader))->Guid,
+ DEFAULT_VARIABLE_NAME,
+ ((EFI_IFR_FORM_SET *) (Context->CurrentIfr->RawIfrHeader))->NvDataSize
+ );
+ } else if (Context->CurrentIfr->RawIfrHeader->OpCode == EFI_IFR_VARSTORE_OP) {
+ //
+ // Variable store opcode -- create a variable pack
+ //
+ Status = CreateVarStore (
+ &((EFI_IFR_VARSTORE *) (Context->CurrentIfr->RawIfrHeader))->Guid,
+ (char *) Context->CurrentIfr->RawIfrHeader + sizeof (EFI_IFR_VARSTORE),
+ ((EFI_IFR_VARSTORE *) (Context->CurrentIfr->RawIfrHeader))->Size
+ );
+ } else if (Context->CurrentIfr->RawIfrHeader->OpCode == EFI_IFR_ONE_OF_OP) {
+ //
+ // Need this parse context later when we find the default ONE_OF_OPTION.
+ // Clear out the variable store first, so that we're covered if someone
+ // has two one-of opcode that operate on the same data.
+ // So "last one wins" is the behavior.
+ //
+ OrderedList = 0;
+ SavedParseEntry = Context->CurrentIfr;
+ CachedVarOffset = ((EFI_IFR_ONE_OF *) Context->CurrentIfr->RawIfrHeader)->QuestionId;
+ CachedVarSize = ((EFI_IFR_ONE_OF *) Context->CurrentIfr->RawIfrHeader)->Width;
+ } else if (Context->CurrentIfr->RawIfrHeader->OpCode == EFI_IFR_ORDERED_LIST_OP) {
+ //
+ // Need this parse context later as we parse the ONE_OF_OP's in the ordered list
+ //
+ OrderedList = 1;
+ SavedParseEntry = Context->CurrentIfr;
+ CachedVarOffset = ((EFI_IFR_ORDERED_LIST *) Context->CurrentIfr->RawIfrHeader)->QuestionId;
+ CachedVarSize = ((EFI_IFR_ORDERED_LIST *) Context->CurrentIfr->RawIfrHeader)->MaxEntries;
+
+ while (CachedVarSize > 0) {
+ Status = SetVariableValue (
+ SavedParseEntry->VarStoreGuid1, // GUID of variable store to write
+ SavedParseEntry->VarStoreName1, // name of variable store to write
+ CachedVarOffset, // offset into variable store
+ 1, // variable data size
+ (void *) &ZeroByte
+ );
+ //
+ // variable value
+ //
+ CachedVarSize--;
+ CachedVarOffset++;
+ }
+
+ CachedVarOffset = ((EFI_IFR_ORDERED_LIST *) Context->CurrentIfr->RawIfrHeader)->QuestionId;
+ CachedVarSize = 1;
+ //
+ // ((EFI_IFR_ORDERED_LIST *)Context->CurrentIfr->RawIfrHeader)->Width;
+ //
+ } else if (Context->CurrentIfr->RawIfrHeader->OpCode == EFI_IFR_ONE_OF_OPTION_OP) {
+ IfrOneOfOption = (EFI_IFR_ONE_OF_OPTION *) Context->CurrentIfr->RawIfrHeader;
+ //
+ // If we're in an ordered list, then copy the value to the data store
+ //
+ if (OrderedList) {
+ Status = SetVariableValue (
+ SavedParseEntry->VarStoreGuid1, // GUID of variable store to write
+ SavedParseEntry->VarStoreName1, // name of variable store to write
+ CachedVarOffset, // offset into variable store
+ 1, // variable data size
+ (void *) &IfrOneOfOption->Value
+ );
+ //
+ // variable value
+ //
+ // Advance the offset for the next ordered list item
+ //
+ CachedVarOffset += CachedVarSize;
+ } else {
+ //
+ // ONE-OF list. See if the default flag is set (provided we're not doing mfg defaults)
+ //
+ if (!MfgDefaults) {
+ if (IfrOneOfOption->Flags & EFI_IFR_FLAG_DEFAULT) {
+ Status = SetVariableValue (
+ SavedParseEntry->VarStoreGuid1, // GUID of variable store to write
+ SavedParseEntry->VarStoreName1, // name of variable store to write
+ CachedVarOffset, // offset into variable store
+ CachedVarSize, // variable data size
+ &IfrOneOfOption->Value
+ );
+ //
+ // variable value
+ //
+ }
+ } else {
+ if (IfrOneOfOption->Flags & EFI_IFR_FLAG_MANUFACTURING) {
+ Status = SetVariableValue (
+ SavedParseEntry->VarStoreGuid1, // GUID of variable store to write
+ SavedParseEntry->VarStoreName1, // name of variable store to write
+ CachedVarOffset, // offset into variable store
+ CachedVarSize, // variable data size
+ &IfrOneOfOption->Value
+ );
+ //
+ // variable value
+ //
+ }
+ }
+ }
+ } else if (Context->CurrentIfr->RawIfrHeader->OpCode == EFI_IFR_CHECKBOX_OP) {
+ //
+ // If we're saving defaults, and the default flag is set, or we're saving
+ // manufacturing defaults and the manufacturing flag is set, then save a 1.
+ // By default the varstore buffer is cleared, so we don't need to save a 0 ever.
+ //
+ IfrCheckBox = (EFI_IFR_CHECK_BOX *) Context->CurrentIfr->RawIfrHeader;
+ if (((MfgDefaults == 0) && (IfrCheckBox->Flags & EFI_IFR_FLAG_DEFAULT)) ||
+ ((MfgDefaults != 0) && (IfrCheckBox->Flags & EFI_IFR_FLAG_MANUFACTURING))
+ ) {
+ Size = 1;
+ Status = SetVariableValue (
+ Context->CurrentIfr->VarStoreGuid1, // GUID of variable store to write
+ Context->CurrentIfr->VarStoreName1, // name of variable store to write
+ IfrCheckBox->QuestionId, // offset into variable store
+ IfrCheckBox->Width, // variable data size
+ (void *) &Size
+ );
+ //
+ // variable value
+ //
+ }
+ } else if (Context->CurrentIfr->RawIfrHeader->OpCode == EFI_IFR_NUMERIC_OP) {
+ IfrNumeric = (EFI_IFR_NUMERIC *) Context->CurrentIfr->RawIfrHeader;
+ Status = SetVariableValue (
+ Context->CurrentIfr->VarStoreGuid1, // GUID of variable store to write
+ Context->CurrentIfr->VarStoreName1, // name of variable store to write
+ IfrNumeric->QuestionId, // offset into variable store
+ IfrNumeric->Width, // variable data size
+ (void *) &IfrNumeric->Default
+ );
+ //
+ // variable value
+ //
+ }
+
+ Context->CurrentIfr = Context->CurrentIfr->Next;
+ }
+
+ return STATUS_SUCCESS;
+}
+
+static
+STATUS
+CreateVarStore (
+ EFI_GUID *VarGuid,
+ CHAR8 *VarName,
+ int VarStoreSize
+ )
+/*++
+
+Routine Description:
+
+ Given a variable GUID.Name and the size of the variable store, allocate
+ storage for maintaining the variable value.
+
+Arguments:
+
+ VarGuid - GUID for a variable
+ VarName - Name of the variable
+ VarStoreSize - size of the variable store
+
+Returns:
+
+ STATUS_ERROR - problem with storage allocation
+ STATUS_SUCCESS - function executed successfully
+
+--*/
+{
+ VARIABLE_STORE_ENTRY *Entry;
+
+ VARIABLE_STORE_ENTRY *TempEntry;
+ int PackSize;
+ int VarNameLen;
+ //
+ // If the variable store size is zero, then do nothing. This could be valid
+ // if variable steering is used in the IFR such that FormsetGUID."Setup" variable
+ // store is never used.
+ //
+ // OPEN: What about a form that only has a time/date question? Then if some other
+ // function called SetDefaults(), attempting to set time/date would result in an
+ // error in the SetVarValue() function.
+ //
+ if (VarStoreSize == 0) {
+ return STATUS_SUCCESS;
+ }
+ //
+ // Go through our list of variable stores and see if we've already created one
+ // for this Guid.Name. If so, check the size and return. Otherwise create
+ // one and add it to the list.
+ //
+ for (Entry = mVariableStores; Entry != NULL; Entry = Entry->Next) {
+ if (memcmp (VarGuid, &Entry->VarPack->VariableGuid, sizeof (EFI_GUID)) == 0) {
+ if (strcmp (VarName, Entry->VarName) == 0) {
+ //
+ // Already have one. Check size.
+ //
+ if (Entry->VarBufferSize != VarStoreSize) {
+ Error (NULL, 0, 0, "mismatched variable store size between two formsets", VarName);
+ return STATUS_ERROR;
+ }
+
+ return STATUS_SUCCESS;
+ }
+ }
+ }
+ //
+ // Create a new one.
+ //
+ Entry = (VARIABLE_STORE_ENTRY *) malloc (sizeof (VARIABLE_STORE_ENTRY));
+ if (Entry == NULL) {
+ Error (NULL, 0, 0, "memory allocation failure", NULL);
+ return STATUS_ERROR;
+ }
+
+ memset ((void *) Entry, 0, sizeof (VARIABLE_STORE_ENTRY));
+ //
+ // Compute size of the varpack
+ //
+ VarNameLen = strlen (VarName) + 1;
+ PackSize = sizeof (EFI_HII_VARIABLE_PACK) + VarNameLen * sizeof (CHAR16) + VarStoreSize;
+ Entry->VarPack = (EFI_HII_VARIABLE_PACK *) malloc (PackSize);
+ if (Entry->VarPack == NULL) {
+ Error (NULL, 0, 0, "memory allocation failure", NULL);
+ free (Entry);
+ return STATUS_ERROR;
+ }
+
+ Entry->VarPack->Header.Length = PackSize;
+ Entry->VarPack->Header.Type = EFI_HII_VARIABLE;
+ Entry->VarPack->VariableNameLength = VarNameLen * sizeof (CHAR16);
+ Entry->VarName[MAX_VARIABLE_NAME - 1] = 0;
+ strncpy (Entry->VarName, VarName, MAX_VARIABLE_NAME - 1);
+#ifdef USE_VC8
+ swprintf ((CHAR16 *) (Entry->VarPack + 1), (strlen (VarName) + 1) * sizeof (CHAR16), L"%S", VarName);
+#else
+ swprintf ((CHAR16 *) (Entry->VarPack + 1), L"%S", VarName);
+#endif
+ memcpy (&Entry->VarPack->VariableGuid, VarGuid, sizeof (EFI_GUID));
+ //
+ // Point VarBuffer into the allocated buffer (for convenience)
+ //
+ Entry->VarBuffer = (char *) Entry->VarPack + sizeof (EFI_HII_VARIABLE_PACK) + VarNameLen * sizeof (CHAR16);
+ memset ((void *) Entry->VarBuffer, 0, VarStoreSize);
+ Entry->VarBufferSize = VarStoreSize;
+ //
+ // Add this new varstore to our list
+ //
+ if (mVariableStores == NULL) {
+ mVariableStores = Entry;
+ } else {
+ for (TempEntry = mVariableStores; TempEntry->Next != NULL; TempEntry = TempEntry->Next)
+ ;
+ TempEntry->Next = Entry;
+ }
+ return STATUS_SUCCESS;
+}
+
+/******************************************************************************/
+
+/*++
+
+Routine Description:
+
+ The following IfrParseXX() functions are used to parse an IFR opcode numbered
+ XX via a dispatch table.
+
+Arguments:
+
+ Context - IFR parsing context into which pertinent data for the
+ current opcode can be saved. Context->LastIfr->RawIfrHeader points to
+ the raw IFR bytes currently being parsed.
+
+Returns:
+
+ STATUS_SUCCESS - always
+
+--*/
+
+/*******************************************************************************/
+static
+STATUS
+IfrParse01 (
+ IFR_PARSE_CONTEXT *Context
+ )
+/*++
+
+Routine Description:
+
+ GC_TODO: Add function description
+
+Arguments:
+
+ Context - GC_TODO: add argument description
+
+Returns:
+
+ GC_TODO: add return values
+
+--*/
+{
+ return STATUS_SUCCESS;
+}
+
+static
+STATUS
+IfrParse02 (
+ IFR_PARSE_CONTEXT *Context
+ )
+/*++
+
+Routine Description:
+
+ GC_TODO: Add function description
+
+Arguments:
+
+ Context - GC_TODO: add argument description
+
+Returns:
+
+ GC_TODO: add return values
+
+--*/
+{
+ return STATUS_SUCCESS;
+}
+
+static
+STATUS
+IfrParse03 (
+ IFR_PARSE_CONTEXT *Context
+ )
+/*++
+
+Routine Description:
+
+ GC_TODO: Add function description
+
+Arguments:
+
+ Context - GC_TODO: add argument description
+
+Returns:
+
+ GC_TODO: add return values
+
+--*/
+{
+ return STATUS_SUCCESS;
+}
+//
+// Parse the IFR EFI_IFR_ONE_OF opcode.
+//
+static
+STATUS
+IfrParse05 (
+ IFR_PARSE_CONTEXT *Context
+ )
+/*++
+
+Routine Description:
+
+ GC_TODO: Add function description
+
+Arguments:
+
+ Context - GC_TODO: add argument description
+
+Returns:
+
+ GC_TODO: add return values
+
+--*/
+{
+ return STATUS_SUCCESS;
+}
+
+static
+STATUS
+IfrParse06 (
+ IFR_PARSE_CONTEXT *Context
+ )
+/*++
+
+Routine Description:
+
+ GC_TODO: Add function description
+
+Arguments:
+
+ Context - GC_TODO: add argument description
+
+Returns:
+
+ GC_TODO: add return values
+
+--*/
+{
+ return STATUS_SUCCESS;
+}
+
+static
+STATUS
+IfrParse07 (
+ IFR_PARSE_CONTEXT *Context
+ )
+/*++
+
+Routine Description:
+
+ GC_TODO: Add function description
+
+Arguments:
+
+ Context - GC_TODO: add argument description
+
+Returns:
+
+ GC_TODO: add return values
+
+--*/
+{
+ return STATUS_SUCCESS;
+}
+
+static
+STATUS
+IfrParse08 (
+ IFR_PARSE_CONTEXT *Context
+ )
+/*++
+
+Routine Description:
+
+ GC_TODO: Add function description
+
+Arguments:
+
+ Context - GC_TODO: add argument description
+
+Returns:
+
+ GC_TODO: add return values
+
+--*/
+{
+ return STATUS_SUCCESS;
+}
+
+static
+STATUS
+IfrParse09 (
+ IFR_PARSE_CONTEXT *Context
+ )
+/*++
+
+Routine Description:
+
+ GC_TODO: Add function description
+
+Arguments:
+
+ Context - GC_TODO: add argument description
+
+Returns:
+
+ GC_TODO: add return values
+
+--*/
+{
+ return STATUS_SUCCESS;
+}
+
+static
+STATUS
+IfrParse0A (
+ IFR_PARSE_CONTEXT *Context
+ )
+/*++
+
+Routine Description:
+
+ GC_TODO: Add function description
+
+Arguments:
+
+ Context - GC_TODO: add argument description
+
+Returns:
+
+ GC_TODO: add return values
+
+--*/
+{
+ return STATUS_SUCCESS;
+}
+
+static
+STATUS
+IfrParse0B (
+ IFR_PARSE_CONTEXT *Context
+ )
+/*++
+
+Routine Description:
+
+ GC_TODO: Add function description
+
+Arguments:
+
+ Context - GC_TODO: add argument description
+
+Returns:
+
+ GC_TODO: add return values
+
+--*/
+{
+ return STATUS_SUCCESS;
+}
+
+static
+STATUS
+IfrParse0C (
+ IFR_PARSE_CONTEXT *Context
+ )
+/*++
+
+Routine Description:
+
+ GC_TODO: Add function description
+
+Arguments:
+
+ Context - GC_TODO: add argument description
+
+Returns:
+
+ GC_TODO: add return values
+
+--*/
+{
+ return STATUS_SUCCESS;
+}
+
+static
+STATUS
+IfrParse0D (
+ IFR_PARSE_CONTEXT *Context
+ )
+/*++
+
+Routine Description:
+
+ GC_TODO: Add function description
+
+Arguments:
+
+ Context - GC_TODO: add argument description
+
+Returns:
+
+ GC_TODO: add return values
+
+--*/
+{
+ return STATUS_SUCCESS;
+}
+
+static
+STATUS
+IfrParse0E (
+ IFR_PARSE_CONTEXT *Context
+ )
+/*++
+
+Routine Description:
+
+ GC_TODO: Add function description
+
+Arguments:
+
+ Context - GC_TODO: add argument description
+
+Returns:
+
+ GC_TODO: add return values
+
+--*/
+{
+ EFI_IFR_FORM_SET *Op;
+ Op = (EFI_IFR_FORM_SET *) Context->LastIfr->RawIfrHeader;
+ Context->LastIfr->VarStoreGuid1 = &Op->Guid;
+ Context->LastIfr->VarStoreName1 = "Setup";
+ Context->FormsetGuid = &Op->Guid;
+ return STATUS_SUCCESS;
+}
+
+static
+STATUS
+IfrParse0F (
+ IFR_PARSE_CONTEXT *Context
+ )
+/*++
+
+Routine Description:
+
+ GC_TODO: Add function description
+
+Arguments:
+
+ Context - GC_TODO: add argument description
+
+Returns:
+
+ GC_TODO: add return values
+
+--*/
+{
+ return STATUS_SUCCESS;
+}
+
+static
+STATUS
+IfrParse10 (
+ IFR_PARSE_CONTEXT *Context
+ )
+/*++
+
+Routine Description:
+
+ GC_TODO: Add function description
+
+Arguments:
+
+ Context - GC_TODO: add argument description
+
+Returns:
+
+ GC_TODO: add return values
+
+--*/
+{
+ return STATUS_SUCCESS;
+}
+
+static
+STATUS
+IfrParse11 (
+ IFR_PARSE_CONTEXT *Context
+ )
+/*++
+
+Routine Description:
+
+ GC_TODO: Add function description
+
+Arguments:
+
+ Context - GC_TODO: add argument description
+
+Returns:
+
+ GC_TODO: add return values
+
+--*/
+{
+ return STATUS_SUCCESS;
+}
+
+static
+STATUS
+IfrParse12 (
+ IFR_PARSE_CONTEXT *Context
+ )
+/*++
+
+Routine Description:
+
+ GC_TODO: Add function description
+
+Arguments:
+
+ Context - GC_TODO: add argument description
+
+Returns:
+
+ GC_TODO: add return values
+
+--*/
+{
+ return STATUS_SUCCESS;
+}
+
+static
+STATUS
+IfrParse13 (
+ IFR_PARSE_CONTEXT *Context
+ )
+/*++
+
+Routine Description:
+
+ GC_TODO: Add function description
+
+Arguments:
+
+ Context - GC_TODO: add argument description
+
+Returns:
+
+ GC_TODO: add return values
+
+--*/
+{
+ return STATUS_SUCCESS;
+}
+
+static
+STATUS
+IfrParse14 (
+ IFR_PARSE_CONTEXT *Context
+ )
+/*++
+
+Routine Description:
+
+ GC_TODO: Add function description
+
+Arguments:
+
+ Context - GC_TODO: add argument description
+
+Returns:
+
+ GC_TODO: add return values
+
+--*/
+{
+ return STATUS_SUCCESS;
+}
+
+static
+STATUS
+IfrParse15 (
+ IFR_PARSE_CONTEXT *Context
+ )
+/*++
+
+Routine Description:
+
+ GC_TODO: Add function description
+
+Arguments:
+
+ Context - GC_TODO: add argument description
+
+Returns:
+
+ GC_TODO: add return values
+
+--*/
+{
+ return STATUS_SUCCESS;
+}
+
+static
+STATUS
+IfrParse16 (
+ IFR_PARSE_CONTEXT *Context
+ )
+/*++
+
+Routine Description:
+
+ GC_TODO: Add function description
+
+Arguments:
+
+ Context - GC_TODO: add argument description
+
+Returns:
+
+ GC_TODO: add return values
+
+--*/
+{
+ return STATUS_SUCCESS;
+}
+
+static
+STATUS
+IfrParse17 (
+ IFR_PARSE_CONTEXT *Context
+ )
+/*++
+
+Routine Description:
+
+ GC_TODO: Add function description
+
+Arguments:
+
+ Context - GC_TODO: add argument description
+
+Returns:
+
+ GC_TODO: add return values
+
+--*/
+{
+ return STATUS_SUCCESS;
+}
+
+static
+STATUS
+IfrParse18 (
+ IFR_PARSE_CONTEXT *Context
+ )
+/*++
+
+Routine Description:
+
+ GC_TODO: Add function description
+
+Arguments:
+
+ Context - GC_TODO: add argument description
+
+Returns:
+
+ GC_TODO: add return values
+
+--*/
+{
+ return STATUS_SUCCESS;
+}
+
+static
+STATUS
+IfrParse19 (
+ IFR_PARSE_CONTEXT *Context
+ )
+/*++
+
+Routine Description:
+
+ GC_TODO: Add function description
+
+Arguments:
+
+ Context - GC_TODO: add argument description
+
+Returns:
+
+ GC_TODO: add return values
+
+--*/
+{
+ return STATUS_SUCCESS;
+}
+
+static
+STATUS
+IfrParse1A (
+ IFR_PARSE_CONTEXT *Context
+ )
+/*++
+
+Routine Description:
+
+ GC_TODO: Add function description
+
+Arguments:
+
+ Context - GC_TODO: add argument description
+
+Returns:
+
+ GC_TODO: add return values
+
+--*/
+{
+ return STATUS_SUCCESS;
+}
+
+static
+STATUS
+IfrParse1B (
+ IFR_PARSE_CONTEXT *Context
+ )
+/*++
+
+Routine Description:
+
+ GC_TODO: Add function description
+
+Arguments:
+
+ Context - GC_TODO: add argument description
+
+Returns:
+
+ GC_TODO: add return values
+
+--*/
+{
+ return STATUS_SUCCESS;
+}
+
+static
+STATUS
+IfrParse1C (
+ IFR_PARSE_CONTEXT *Context
+ )
+/*++
+
+Routine Description:
+
+ GC_TODO: Add function description
+
+Arguments:
+
+ Context - GC_TODO: add argument description
+
+Returns:
+
+ GC_TODO: add return values
+
+--*/
+{
+ return STATUS_SUCCESS;
+}
+
+static
+STATUS
+IfrParse1D (
+ IFR_PARSE_CONTEXT *Context
+ )
+/*++
+
+Routine Description:
+
+ GC_TODO: Add function description
+
+Arguments:
+
+ Context - GC_TODO: add argument description
+
+Returns:
+
+ GC_TODO: add return values
+
+--*/
+{
+ return STATUS_SUCCESS;
+}
+
+static
+STATUS
+IfrParse1E (
+ IFR_PARSE_CONTEXT *Context
+ )
+/*++
+
+Routine Description:
+
+ GC_TODO: Add function description
+
+Arguments:
+
+ Context - GC_TODO: add argument description
+
+Returns:
+
+ GC_TODO: add return values
+
+--*/
+{
+ return STATUS_SUCCESS;
+}
+
+static
+STATUS
+IfrParse1F (
+ IFR_PARSE_CONTEXT *Context
+ )
+/*++
+
+Routine Description:
+
+ GC_TODO: Add function description
+
+Arguments:
+
+ Context - GC_TODO: add argument description
+
+Returns:
+
+ GC_TODO: add return values
+
+--*/
+{
+ return STATUS_SUCCESS;
+}
+
+static
+STATUS
+IfrParse20 (
+ IFR_PARSE_CONTEXT *Context
+ )
+/*++
+
+Routine Description:
+
+ GC_TODO: Add function description
+
+Arguments:
+
+ Context - GC_TODO: add argument description
+
+Returns:
+
+ GC_TODO: add return values
+
+--*/
+{
+ return STATUS_SUCCESS;
+}
+
+static
+STATUS
+IfrParse21 (
+ IFR_PARSE_CONTEXT *Context
+ )
+/*++
+
+Routine Description:
+
+ GC_TODO: Add function description
+
+Arguments:
+
+ Context - GC_TODO: add argument description
+
+Returns:
+
+ GC_TODO: add return values
+
+--*/
+{
+ return STATUS_SUCCESS;
+}
+
+static
+STATUS
+IfrParse22 (
+ IFR_PARSE_CONTEXT *Context
+ )
+/*++
+
+Routine Description:
+
+ GC_TODO: Add function description
+
+Arguments:
+
+ Context - GC_TODO: add argument description
+
+Returns:
+
+ GC_TODO: add return values
+
+--*/
+{
+ return STATUS_SUCCESS;
+}
+
+static
+STATUS
+IfrParse23 (
+ IFR_PARSE_CONTEXT *Context
+ )
+/*++
+
+Routine Description:
+
+ GC_TODO: Add function description
+
+Arguments:
+
+ Context - GC_TODO: add argument description
+
+Returns:
+
+ GC_TODO: add return values
+
+--*/
+{
+ return STATUS_SUCCESS;
+}
+//
+// EFI_IFR_VARSTORE
+//
+static
+STATUS
+IfrParse24 (
+ IFR_PARSE_CONTEXT *Context
+ )
+/*++
+
+Routine Description:
+
+ GC_TODO: Add function description
+
+Arguments:
+
+ Context - GC_TODO: add argument description
+
+Returns:
+
+ GC_TODO: add return values
+
+--*/
+{
+ EFI_IFR_VARSTORE *Op;
+ Op = (EFI_IFR_VARSTORE *) Context->LastIfr->RawIfrHeader;
+ return STATUS_SUCCESS;
+}
+//
+// VARSTORE_SELECT
+//
+static
+STATUS
+IfrParse25 (
+ IFR_PARSE_CONTEXT *Context
+ )
+/*++
+
+Routine Description:
+
+ GC_TODO: Add function description
+
+Arguments:
+
+ Context - GC_TODO: add argument description
+
+Returns:
+
+ GC_TODO: add return values
+
+--*/
+{
+ STATUS Status;
+ EFI_IFR_VARSTORE_SELECT *Op;
+ Op = (EFI_IFR_VARSTORE_SELECT *) Context->LastIfr->RawIfrHeader;
+ Status = GetVarStoreInfo (Context, Op->VarId, &Context->LastIfr->VarStoreGuid1, &Context->LastIfr->VarStoreName1);
+ //
+ // VARSTORE_SELECT sets both
+ //
+ Context->LastIfr->VarStoreGuid2 = Context->LastIfr->VarStoreGuid1;
+ Context->LastIfr->VarStoreName2 = Context->LastIfr->VarStoreName1;
+ return Status;
+}
+//
+// VARSTORE_SELECT_PAIR
+//
+static
+STATUS
+IfrParse26 (
+ IFR_PARSE_CONTEXT *Context
+ )
+/*++
+
+Routine Description:
+
+ GC_TODO: Add function description
+
+Arguments:
+
+ Context - GC_TODO: add argument description
+
+Returns:
+
+ GC_TODO: add return values
+
+--*/
+{
+ STATUS Status;
+ EFI_IFR_VARSTORE_SELECT_PAIR *Op;
+
+ Op = (EFI_IFR_VARSTORE_SELECT_PAIR *) Context->LastIfr->RawIfrHeader;
+ Status = GetVarStoreInfo (Context, Op->VarId, &Context->LastIfr->VarStoreGuid1, &Context->LastIfr->VarStoreName1);
+ Status = GetVarStoreInfo (
+ Context,
+ Op->SecondaryVarId,
+ &Context->LastIfr->VarStoreGuid2,
+ &Context->LastIfr->VarStoreName2
+ );
+ return Status;
+}
+//
+// TRUE
+//
+static
+STATUS
+IfrParse27 (
+ IFR_PARSE_CONTEXT *Context
+ )
+/*++
+
+Routine Description:
+
+ GC_TODO: Add function description
+
+Arguments:
+
+ Context - GC_TODO: add argument description
+
+Returns:
+
+ GC_TODO: add return values
+
+--*/
+{
+ return STATUS_SUCCESS;
+}
+//
+// FALSe
+//
+static
+STATUS
+IfrParse28 (
+ IFR_PARSE_CONTEXT *Context
+ )
+/*++
+
+Routine Description:
+
+ GC_TODO: Add function description
+
+Arguments:
+
+ Context - GC_TODO: add argument description
+
+Returns:
+
+ GC_TODO: add return values
+
+--*/
+{
+ return STATUS_SUCCESS;
+}
+static
+STATUS
+IfrParse29 (
+ IFR_PARSE_CONTEXT *Context
+ )
+/*++
+
+Routine Description:
+
+ GC_TODO: Add function description
+
+Arguments:
+
+ Context - GC_TODO: add argument description
+
+Returns:
+
+ GC_TODO: add return values
+
+--*/
+{
+ return STATUS_SUCCESS;
+}
+static
+STATUS
+IfrParse2A (
+ IFR_PARSE_CONTEXT *Context
+ )
+/*++
+
+Routine Description:
+
+ GC_TODO: Add function description
+
+Arguments:
+
+ Context - GC_TODO: add argument description
+
+Returns:
+
+ GC_TODO: add return values
+
+--*/
+{
+ return STATUS_SUCCESS;
+}
diff --git a/EdkCompatibilityPkg/Sample/Tools/Source/HiiPack/IfrParse.h b/EdkCompatibilityPkg/Sample/Tools/Source/HiiPack/IfrParse.h
new file mode 100644
index 0000000000..6a2a597b33
--- /dev/null
+++ b/EdkCompatibilityPkg/Sample/Tools/Source/HiiPack/IfrParse.h
@@ -0,0 +1,267 @@
+/*++
+
+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:
+
+ IfrParse.h
+
+Abstract:
+
+ Prototypes and defines for the IFR parsing services.
+
+--*/
+
+#ifndef _IFR_PARSE_H_
+#define _IFR_PARSE_H_
+
+#define DEFAULT_HII_PACK_FILENAME_EXTENSION ".hpk"
+//
+// When we parse IFR, we'll keep the IFR in a linked list of
+// these.
+//
+typedef struct _IFR_PARSE_ENTRY {
+ struct _IFR_PARSE_ENTRY *Next;
+ int Tag; // for debugging
+ EFI_IFR_OP_HEADER *RawIfrHeader;
+ //
+ // GUIDs for variable storage
+ //
+ EFI_GUID *VarStoreGuid1;
+ char *VarStoreName1;
+ EFI_GUID *VarStoreGuid2;
+ char *VarStoreName2;
+} IFR_PARSE_ENTRY;
+
+typedef struct _IFR_PARSE_CONTEXT {
+ struct _IFR_PARSE_CONTEXT *Next;
+ EFI_HII_IFR_PACK *PackHeader;
+ char *IfrBufferStart;
+ char *CurrentPos;
+ long IfrBufferLen;
+ int Handle;
+ IFR_PARSE_ENTRY *Ifr;
+ IFR_PARSE_ENTRY *LastIfr;
+ IFR_PARSE_ENTRY *CurrentIfr;
+ FILE *OutFptr;
+ CHAR16 *Language;
+ EFI_GUID *FormsetGuid;
+ EFI_GUID NullGuid; // for use until we set the Guid field correctly
+ EFI_GUID PackageGuid; // from the PackageGuid in the HII data table
+} IFR_PARSE_CONTEXT;
+
+STATUS
+IfrGetVarPack (
+ int VarIndex,
+ EFI_HII_VARIABLE_PACK **VarPack
+ )
+/*++
+
+Routine Description:
+
+ GC_TODO: Add function description
+
+Arguments:
+
+ VarIndex - GC_TODO: add argument description
+ VarPack - GC_TODO: add argument description
+
+Returns:
+
+ GC_TODO: add return values
+
+--*/
+;
+
+STATUS
+IfrParsePack (
+ int Handle,
+ EFI_HII_IFR_PACK *PackHeader,
+ EFI_GUID *PackageGuid
+ )
+/*++
+
+Routine Description:
+
+ GC_TODO: Add function description
+
+Arguments:
+
+ Handle - GC_TODO: add argument description
+ PackHeader - GC_TODO: add argument description
+ PackageGuid - GC_TODO: add argument description
+
+Returns:
+
+ GC_TODO: add return values
+
+--*/
+;
+
+STATUS
+IfrParseCheck (
+ char *Buffer,
+ long BufferSize
+ )
+/*++
+
+Routine Description:
+
+ GC_TODO: Add function description
+
+Arguments:
+
+ Buffer - GC_TODO: add argument description
+ BufferSize - GC_TODO: add argument description
+
+Returns:
+
+ GC_TODO: add return values
+
+--*/
+;
+
+STATUS
+IfrParseInit (
+ VOID
+ )
+/*++
+
+Routine Description:
+
+ GC_TODO: Add function description
+
+Arguments:
+
+ None
+
+Returns:
+
+ GC_TODO: add return values
+
+--*/
+;
+
+STATUS
+IfrParseEnd (
+ VOID
+ )
+/*++
+
+Routine Description:
+
+ GC_TODO: Add function description
+
+Arguments:
+
+ None
+
+Returns:
+
+ GC_TODO: add return values
+
+--*/
+;
+
+STATUS
+IfrParseDump (
+ int Handle,
+ CHAR16 *Language,
+ FILE *OutFptr
+ )
+/*++
+
+Routine Description:
+
+ GC_TODO: Add function description
+
+Arguments:
+
+ Handle - GC_TODO: add argument description
+ Language - GC_TODO: add argument description
+ OutFptr - GC_TODO: add argument description
+
+Returns:
+
+ GC_TODO: add return values
+
+--*/
+;
+
+STATUS
+IfrSetDefaults (
+ int MfgDefaults
+ )
+/*++
+
+Routine Description:
+
+ GC_TODO: Add function description
+
+Arguments:
+
+ MfgDefaults - GC_TODO: add argument description
+
+Returns:
+
+ GC_TODO: add return values
+
+--*/
+;
+
+STATUS
+IfrGetIfrPack (
+ int Handle,
+ EFI_HII_IFR_PACK **PackHeader,
+ EFI_GUID *FormsetGuid
+ )
+/*++
+
+Routine Description:
+
+ GC_TODO: Add function description
+
+Arguments:
+
+ Handle - GC_TODO: add argument description
+ PackHeader - GC_TODO: add argument description
+ FormsetGuid - GC_TODO: add argument description
+
+Returns:
+
+ GC_TODO: add return values
+
+--*/
+;
+
+STATUS
+IfrReferencesVarPack (
+ int IfrHandle,
+ EFI_HII_VARIABLE_PACK *VarPack
+ )
+/*++
+
+Routine Description:
+
+ GC_TODO: Add function description
+
+Arguments:
+
+ IfrHandle - GC_TODO: add argument description
+ VarPack - GC_TODO: add argument description
+
+Returns:
+
+ GC_TODO: add return values
+
+--*/
+;
+
+#endif // #ifndef _IFR_PARSE_H_
diff --git a/EdkCompatibilityPkg/Sample/Tools/Source/HiiPack/Makefile b/EdkCompatibilityPkg/Sample/Tools/Source/HiiPack/Makefile
new file mode 100644
index 0000000000..83f6ba7ff8
--- /dev/null
+++ b/EdkCompatibilityPkg/Sample/Tools/Source/HiiPack/Makefile
@@ -0,0 +1,103 @@
+#/*++
+#
+# 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:
+#
+# Makefile
+#
+# Abstract:
+#
+# This file is used to build the HiiPack utility
+#
+#--*/
+
+#
+# Make sure environmental variable EDK_SOURCE is set
+#
+!IFNDEF EDK_SOURCE
+!ERROR EDK_SOURCE environmental variable not set
+!ENDIF
+
+#
+# Do this if you want to compile from this directory
+#
+!IFNDEF TOOLCHAIN
+TOOLCHAIN = TOOLCHAIN_MSVC
+!ENDIF
+
+!INCLUDE $(BUILD_DIR)\PlatformTools.env
+
+#
+# Target specific information
+#
+
+TARGET_NAME = HiiPack
+TARGET_SRC_DIR = $(EDK_TOOLS_SOURCE)\$(TARGET_NAME)
+TARGET_EXE = $(EDK_TOOLS_OUTPUT)\HiiPack.exe
+
+#
+# Build targets
+#
+
+all: $(TARGET_EXE)
+
+INC = $(INC) -I "$(EDK_SOURCE)\Foundation\Framework\Protocol\Hii"
+
+INC_DEPS = "$(TARGET_SRC_DIR)\HiiPack.h" "$(TARGET_SRC_DIR)\IfrParse.h" "$(TARGET_SRC_DIR)\StringParse.h"
+
+LIBS = "$(EDK_TOOLS_OUTPUT)\Common.lib"
+
+OBJECTS = $(EDK_TOOLS_OUTPUT)\FindFiles.obj \
+ $(EDK_TOOLS_OUTPUT)\HiiPack.obj \
+ $(EDK_TOOLS_OUTPUT)\IfrParse.obj \
+ $(EDK_TOOLS_OUTPUT)\StringParse.obj
+
+#
+# Build EXE
+#
+
+$(EDK_TOOLS_OUTPUT)\FindFiles.obj : $(TARGET_SRC_DIR)\FindFiles.c $(INC_DEPS)
+ $(CC) $(C_FLAGS) $(INC) $(TARGET_SRC_DIR)\FindFiles.c /Fo$@
+
+$(EDK_TOOLS_OUTPUT)\HiiPack.obj : $(TARGET_SRC_DIR)\HiiPack.c $(INC_DEPS)
+ $(CC) $(C_FLAGS) $(INC) $(TARGET_SRC_DIR)\HiiPack.c /Fo$@
+
+$(EDK_TOOLS_OUTPUT)\IfrParse.obj : $(TARGET_SRC_DIR)\IfrParse.c $(INC_DEPS)
+ $(CC) $(C_FLAGS) $(INC) $(TARGET_SRC_DIR)\IfrParse.c /Fo$@
+
+$(EDK_TOOLS_OUTPUT)\StringParse.obj : $(TARGET_SRC_DIR)\StringParse.c $(INC_DEPS)
+ $(CC) $(C_FLAGS) $(INC) $(TARGET_SRC_DIR)\StringParse.c /Fo$@
+
+#
+# Add Binary Build description for this tool.
+#
+
+!IF (("$(EFI_BINARY_TOOLS)" == "YES") && EXIST($(EFI_PLATFORM_BIN)\Tools\$(TARGET_NAME).exe))
+$(TARGET_EXE): $(EFI_PLATFORM_BIN)\Tools\$(TARGET_NAME).exe
+ copy $(EFI_PLATFORM_BIN)\Tools\$(TARGET_NAME).exe $(TARGET_EXE) /Y
+ if exist $(EFI_PLATFORM_BIN)\Tools\$(TARGET_NAME).pdb \
+ copy $(EFI_PLATFORM_BIN)\Tools\$(TARGET_NAME).pdb $(EDK_TOOLS_OUTPUT)\$(TARGET_NAME).pdb /Y
+!ELSE
+$(TARGET_EXE) : $(OBJECTS) $(LIBS)
+ $(LINK) $(MSVS_LINK_LIBPATHS) $(L_FLAGS) $(LIBS) /out:$(TARGET_EXE) $(OBJECTS)
+!IF ("$(EFI_BINARY_BUILD)" == "YES")
+ if not exist $(EFI_PLATFORM_BIN)\Tools mkdir $(EFI_PLATFORM_BIN)\Tools
+ if exist $(TARGET_EXE) copy $(TARGET_EXE) $(EFI_PLATFORM_BIN)\tools\$(TARGET_NAME).exe /Y
+ if exist $(EDK_TOOLS_OUTPUT)\$(TARGET_NAME).pdb \
+ copy $(EDK_TOOLS_OUTPUT)\$(TARGET_NAME).pdb $(EFI_PLATFORM_BIN)\Tools\$(TARGET_NAME).pdb /Y
+!ENDIF
+!ENDIF
+
+clean:
+ @if exist $(EDK_TOOLS_OUTPUT)\$(TARGET_NAME).* del $(EDK_TOOLS_OUTPUT)\$(TARGET_NAME).* > NUL
+ @if exist $(EDK_TOOLS_OUTPUT)\FindFiles.* del $(EDK_TOOLS_OUTPUT)\FindFiles.* > NUL
+ @if exist $(EDK_TOOLS_OUTPUT)\IfrParse* del $(EDK_TOOLS_OUTPUT)\IfrParse.* > NUL
+ @if exist $(EDK_TOOLS_OUTPUT)\StringParse.* del $(EDK_TOOLS_OUTPUT)\StringParse.* > NUL
diff --git a/EdkCompatibilityPkg/Sample/Tools/Source/HiiPack/StringParse.c b/EdkCompatibilityPkg/Sample/Tools/Source/HiiPack/StringParse.c
new file mode 100644
index 0000000000..8dd26e1529
--- /dev/null
+++ b/EdkCompatibilityPkg/Sample/Tools/Source/HiiPack/StringParse.c
@@ -0,0 +1,244 @@
+/*++
+
+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:
+
+ StringParse.c
+
+Abstract:
+
+ Routines for parsing HII string packs
+
+--*/
+
+#include <stdio.h>
+#include <string.h>
+#include <stdlib.h>
+
+#include "Tiano.h"
+#include "EfiUtilityMsgs.h"
+#include "EfiInternalFormRepresentation.h"
+#include "Hii.h"
+#include "StringParse.h"
+#include "HiiPack.h"
+
+typedef struct _STRING_PACK_RECORD {
+ struct _STRING_PACK_RECORD *Next;
+ int Handle;
+ EFI_GUID PackageGuid;
+ EFI_GUID FormsetGuid;
+ EFI_HII_STRING_PACK *StringPack;
+ int StringPackSize;
+ int NumStringPacks;
+} STRING_PACK_RECORD;
+
+static STRING_PACK_RECORD *mStringPacks = NULL;
+
+STATUS
+StringGetPack (
+ int Handle, // matches handle passed in with StringParsePack()
+ EFI_HII_STRING_PACK **StringPack, // returned pointer to string pack
+ int *StringPackSize, // sizeof buffer pointed to by StringPack
+ int *NumStringPacks, // in the array pointed to by StringPack
+ EFI_GUID *FormsetGuid,
+ EFI_GUID *PackageGuid
+ )
+/*++
+
+Routine Description:
+
+ Get a string pack given to us previously
+
+Arguments:
+ Handle - handle of string pack to get
+ StringPack - outgoing pointer to string pack on the given handle
+ StringPackSize - outgoing size of string pack pointed to by StringPack
+ NumStringPacks - outgoing number of string packs in StringPack[] array
+ FormsetGuid - outgoing GUID passed in with the string pack when it was parsed
+ PackageGuid - outgoing GUID passed in with the string pack when it was parsed
+
+Returns:
+
+ STATUS_SUCCESS - string pack with matching handle was found
+ STATUS_ERROR - otherwise
+
+--*/
+{
+ STRING_PACK_RECORD *Rec;
+
+ for (Rec = mStringPacks; Rec != NULL; Rec = Rec->Next) {
+ if (Rec->Handle == Handle) {
+ *StringPack = Rec->StringPack;
+ *StringPackSize = Rec->StringPackSize;
+ *NumStringPacks = Rec->NumStringPacks;
+ return STATUS_SUCCESS;
+ }
+ }
+
+ return STATUS_ERROR;
+}
+
+STATUS
+StringParsePack (
+ int Handle,
+ EFI_HII_STRING_PACK *StringPack,
+ EFI_GUID *FormsetGuid,
+ EFI_GUID *PackageGuid
+ )
+/*++
+
+Routine Description:
+
+ Parse a string pack, saving the information for later retrieval by the caller
+
+Arguments:
+ Handle - handle of string pack
+ StringPack - pointer to string pack array to parse
+ FormsetGuid - GUID of the string pack
+ PackageGuid - package GUID from the HII data table from which this string pack orginated
+
+Returns:
+
+ STATUS_SUCCESS - Stringpack processed successfully
+ STATUS_ERROR - otherwise
+
+--*/
+{
+ STRING_PACK_RECORD *Rec;
+
+ STRING_PACK_RECORD *TempRec;
+ int PackSize;
+ EFI_HII_STRING_PACK *TempPack;
+ //
+ // Allocate a new string pack record
+ //
+ Rec = (STRING_PACK_RECORD *) malloc (sizeof (STRING_PACK_RECORD));
+ if (Rec == NULL) {
+ Error (NULL, 0, 0, "memory allocation failure", NULL);
+ return STATUS_ERROR;
+ }
+
+ memset (Rec, 0, sizeof (STRING_PACK_RECORD));
+ Rec->Handle = Handle;
+ if (PackageGuid != NULL) {
+ memcpy (&Rec->PackageGuid, PackageGuid, sizeof (EFI_GUID));
+ }
+
+ if (FormsetGuid != NULL) {
+ memcpy (&Rec->FormsetGuid, FormsetGuid, sizeof (EFI_GUID));
+ }
+ //
+ // Walk the string packs to find the terminator
+ //
+ TempPack = StringPack;
+ PackSize = 0;
+ while (TempPack->Header.Length > 0) {
+ if (TempPack->Header.Type != EFI_HII_STRING) {
+ Error (NULL, 0, 0, "found a non-string pack in the string pack array", NULL);
+ free (Rec);
+ return STATUS_ERROR;
+ }
+
+ PackSize += TempPack->Header.Length;
+ Rec->NumStringPacks++;
+ TempPack = (EFI_HII_STRING_PACK *) ((char *) TempPack + TempPack->Header.Length);
+ }
+ //
+ // Add space for the terminator
+ //
+ PackSize += sizeof (EFI_HII_STRING_PACK);
+ Rec->StringPackSize = PackSize;
+ //
+ // Make a copy of the incoming string pack
+ //
+ Rec->StringPack = (EFI_HII_STRING_PACK *) malloc (PackSize);
+ if (Rec->StringPack == NULL) {
+ Error (NULL, 0, 0, "memory allocation failure", NULL);
+ free (Rec);
+ return STATUS_ERROR;
+ }
+
+ memcpy ((void *) Rec->StringPack, StringPack, PackSize);
+ //
+ // Add this record to our list
+ //
+ if (mStringPacks == NULL) {
+ mStringPacks = Rec;
+ } else {
+ for (TempRec = mStringPacks; TempRec->Next != NULL; TempRec = TempRec->Next)
+ ;
+ TempRec->Next = Rec;
+ }
+ free (Rec->StringPack);
+ free (Rec);
+ return STATUS_SUCCESS;
+}
+
+STATUS
+StringInit (
+ VOID
+ )
+/*++
+
+Routine Description:
+
+ GC_TODO: Add function description
+
+Arguments:
+
+ None
+
+Returns:
+
+ GC_TODO: add return values
+
+--*/
+{
+ StringEnd ();
+ return STATUS_SUCCESS;
+}
+
+STATUS
+StringEnd (
+ VOID
+ )
+/*++
+
+Routine Description:
+
+ GC_TODO: Add function description
+
+Arguments:
+
+ None
+
+Returns:
+
+ GC_TODO: add return values
+
+--*/
+{
+ STRING_PACK_RECORD *Next;
+ //
+ // Free up all the memory we've allocated
+ //
+ while (mStringPacks != NULL) {
+ if (mStringPacks->StringPack != NULL) {
+ free (mStringPacks->StringPack);
+ }
+
+ Next = mStringPacks->Next;
+ free (mStringPacks);
+ mStringPacks = Next;
+ }
+
+ return STATUS_SUCCESS;
+}
diff --git a/EdkCompatibilityPkg/Sample/Tools/Source/HiiPack/StringParse.h b/EdkCompatibilityPkg/Sample/Tools/Source/HiiPack/StringParse.h
new file mode 100644
index 0000000000..a5df7d0ccb
--- /dev/null
+++ b/EdkCompatibilityPkg/Sample/Tools/Source/HiiPack/StringParse.h
@@ -0,0 +1,125 @@
+/*++
+
+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:
+
+ StringParse.h
+
+Abstract:
+
+ Prototypes and defines for the string pack parsing services.
+
+--*/
+
+#ifndef _STRING_PARSE_H_
+#define _STRING_PARSE_H_
+
+STATUS
+StringGetPack (
+ int Handle, // matches handle passed in with StringParsePack()
+ EFI_HII_STRING_PACK **StringPack, // returned pointer to string pack
+ int *StringPackSize, // sizeof buffer pointed to by StringPack
+ int *NumStringPacks, // in the array pointed to by StringPack
+ EFI_GUID *FormsetGuid,
+ EFI_GUID *PackageGuid
+ )
+/*++
+
+Routine Description:
+
+ GC_TODO: Add function description
+
+Arguments:
+
+ Handle - GC_TODO: add argument description
+ StringPack - GC_TODO: add argument description
+ StringPackSize - GC_TODO: add argument description
+ NumStringPacks - GC_TODO: add argument description
+ FormsetGuid - GC_TODO: add argument description
+ PackageGuid - GC_TODO: add argument description
+
+Returns:
+
+ GC_TODO: add return values
+
+--*/
+;
+
+STATUS
+StringParsePack (
+ int Handle,
+ EFI_HII_STRING_PACK *StringPack,
+ EFI_GUID *FormsetGuid,
+ EFI_GUID *PackageGuid
+ )
+/*++
+
+Routine Description:
+
+ GC_TODO: Add function description
+
+Arguments:
+
+ Handle - GC_TODO: add argument description
+ StringPack - GC_TODO: add argument description
+ FormsetGuid - GC_TODO: add argument description
+ PackageGuid - GC_TODO: add argument description
+
+Returns:
+
+ GC_TODO: add return values
+
+--*/
+;
+
+STATUS
+StringInit (
+ VOID
+ )
+/*++
+
+Routine Description:
+
+ GC_TODO: Add function description
+
+Arguments:
+
+ None
+
+Returns:
+
+ GC_TODO: add return values
+
+--*/
+;
+
+STATUS
+StringEnd (
+ VOID
+ )
+/*++
+
+Routine Description:
+
+ GC_TODO: Add function description
+
+Arguments:
+
+ None
+
+Returns:
+
+ GC_TODO: add return values
+
+--*/
+;
+
+#endif // #ifndef _STRING_PARSE_H_
diff --git a/EdkCompatibilityPkg/Sample/Tools/Source/MakeDeps/MakeDeps.c b/EdkCompatibilityPkg/Sample/Tools/Source/MakeDeps/MakeDeps.c
index 3b780de4ab..13fdd22aa5 100644
--- a/EdkCompatibilityPkg/Sample/Tools/Source/MakeDeps/MakeDeps.c
+++ b/EdkCompatibilityPkg/Sample/Tools/Source/MakeDeps/MakeDeps.c
@@ -1,6 +1,6 @@
/*++
-Copyright (c) 2004 - 2007, 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
@@ -37,6 +37,7 @@ typedef struct _STRING_LIST {
} STRING_LIST;
#define UTILITY_NAME "MakeDeps"
+#define UTILITY_VERSION "v1.0"
#define MAX_LINE_LEN 2048
#define MAX_PATH 2048
@@ -1488,30 +1489,36 @@ Returns:
--*/
{
- int Index;
- static const char *Str[] = {
- UTILITY_NAME " -- make dependencies",
- " Usage: MakeDeps [options]",
- " Options include:",
- " -h or -? for this help information",
- " -f SourceFile add SourceFile to list of files to scan",
- " -i IncludePath add IncludePath to list of search paths",
- " -o OutputFile write output dependencies to OutputFile",
- " -s SubDir for each IncludePath, also search IncludePath\\SubDir",
- " -v for verbose output",
- " -ignorenotfound don't warn for files not found",
- " -target Target for single SourceFile, target is Target, not SourceFile.obj",
- " -q quiet mode to not report files not found if ignored",
- " -sub sym str replace all occurrances of 'str' with 'sym' in the output",
- " -nosystem not process system <include> files",
- " -neverfail always return a success return code",
+ int Index;
+ const char *Str[] = {
+ UTILITY_NAME" "UTILITY_VERSION" - Intel Make Dependencies Utility",
+ " Copyright (C), 2004 - 2008 Intel Corporation",
+
+#if ( defined(UTILITY_BUILD) && defined(UTILITY_VENDOR) )
+ " Built from "UTILITY_BUILD", project of "UTILITY_VENDOR,
+#endif
+ "",
+ "Usage:",
+ " "UTILITY_NAME" [OPTION]...",
+ "Options:",
+ " -h or -? for this help information",
+ " -f SourceFile add SourceFile to list of files to scan",
+ " -i IncludePath add IncludePath to list of search paths",
+ " -o OutputFile write output dependencies to OutputFile",
+ " -s SubDir for each IncludePath, also search IncludePath\\SubDir",
+ " -v for verbose output",
+ " -ignorenotfound don't warn for files not found",
+ " -target Target for single SourceFile, target is Target, not SourceFile.obj",
+ " -q quiet mode to not report files not found if ignored",
+ " -sub sym str replace all occurrances of 'str' with 'sym' in the output",
+ " -nosystem not process system <include> files",
+ " -neverfail always return a success return code",
//
- // " -nodupes keep track of include files, don't rescan duplicates",
+ // " -nodupes keep track of include files, don't rescan duplicates",
//
- " -usesumdeps path use summary dependency files in 'path' directory.",
- " -asm The SourceFiles are assembler files",
- " -cl The SourceFiles are the output of cl with /showIncludes",
- "",
+ " -usesumdeps path use summary dependency files in 'path' directory.",
+ " -asm The SourceFiles are assembler files",
+ " -cl The SourceFiles are the output of cl with /showIncludes",
NULL
};
for (Index = 0; Str[Index] != NULL; Index++) {
diff --git a/EdkCompatibilityPkg/Sample/Tools/Source/Makefile b/EdkCompatibilityPkg/Sample/Tools/Source/Makefile
index 772417e1f7..c8e85e51f6 100644
--- a/EdkCompatibilityPkg/Sample/Tools/Source/Makefile
+++ b/EdkCompatibilityPkg/Sample/Tools/Source/Makefile
@@ -1,6 +1,6 @@
#/*++
#
-# Copyright (c) 2004 - 2007, 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
@@ -44,9 +44,11 @@ MAKEFILES = $(EDK_TOOLS_SOURCE)\Common\Makefile \
!IF "$(EFI_SPECIFICATION_VERSION)" >= "0x0002000A"
$(EDK_TOOLS_SOURCE)\UefiVfrCompile\makefile \
$(EDK_TOOLS_SOURCE)\UefiStrGather\makefile \
+ $(EDK_TOOLS_SOURCE)\UefiHiiPack\Makefile \
!ELSE
$(EDK_TOOLS_SOURCE)\VfrCompile\makefile \
$(EDK_TOOLS_SOURCE)\StrGather\makefile \
+ $(EDK_TOOLS_SOURCE)\HiiPack\Makefile \
!ENDIF
$(EDK_TOOLS_SOURCE)\SplitFile\Makefile \
$(EDK_TOOLS_SOURCE)\Strip\Makefile \
diff --git a/EdkCompatibilityPkg/Sample/Tools/Source/ModifyInf/ModifyInf.c b/EdkCompatibilityPkg/Sample/Tools/Source/ModifyInf/ModifyInf.c
index 3d7a97ca7d..2f6ac471e6 100644
--- a/EdkCompatibilityPkg/Sample/Tools/Source/ModifyInf/ModifyInf.c
+++ b/EdkCompatibilityPkg/Sample/Tools/Source/ModifyInf/ModifyInf.c
@@ -1,6 +1,6 @@
/*++
-Copyright (c) 1999 - 2002, Intel Corporation. All rights reserved.<BR>
+Copyright (c) 1999 - 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
@@ -23,6 +23,8 @@ Abstract:
#include "stdio.h"
#include "string.h"
+#define UTILITY_NAME "ModifyInf"
+#define UTILITY_VERSION "v1.0"
//
// Read a line into buffer including '\r\n'
//
@@ -263,7 +265,22 @@ Returns:
--*/
{
- printf ("ModifyInf InputFVInfFileName OutputFVInfFileName [Pattern strings]\r\n");
+ int Index;
+ const char *Str[] = {
+ UTILITY_NAME" "UTILITY_VERSION" - Intel Modify INF File Utility",
+ " Copyright (C), 1999 - 2008 Intel Corporation",
+
+#if ( defined(UTILITY_BUILD) && defined(UTILITY_VENDOR) )
+ " Built from "UTILITY_BUILD", project of "UTILITY_VENDOR,
+#endif
+ "",
+ "Usage:",
+ " "UTILITY_NAME" SOURCE DEST [PATTERN]",
+ NULL
+ };
+ for (Index = 0; Str[Index] != NULL; Index++) {
+ fprintf (stdout, "%s\n", Str[Index]);
+ }
}
int
diff --git a/EdkCompatibilityPkg/Sample/Tools/Source/ProcessDsc/FWVolume.c b/EdkCompatibilityPkg/Sample/Tools/Source/ProcessDsc/FWVolume.c
index 3e60b0344b..5181373a54 100644
--- a/EdkCompatibilityPkg/Sample/Tools/Source/ProcessDsc/FWVolume.c
+++ b/EdkCompatibilityPkg/Sample/Tools/Source/ProcessDsc/FWVolume.c
@@ -1,6 +1,6 @@
/*++
-Copyright (c) 2004 - 2007, 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
@@ -35,18 +35,7 @@ Abstract:
#define EFI_BASE_ADDRESS "EFI_BASE_ADDRESS"
#define DEFAULT_FV_INF_DIR "FV" // default dir for where we create the FV INF file
#define DEFAULT_FV_DIR "$(BUILD_DIR)" // where the FV file comes from
-#define MALLOC(size) malloc (size)
-#define FREE(ptr) free (ptr)
-//
-// Disable warning for unused function arguments
-//
-#pragma warning(disable : 4100)
-//
-// Disable warning for while(1) code
-//
-// #pragma warning (disable : 4127)
-//
typedef struct {
char *ComponentType;
char *Extension;
@@ -196,8 +185,7 @@ static
void
AddFirmwareVolumes (
char *FVs,
- int ComponentsInstance,
- FILE_LIST *FileListPtr
+ int ComponentsInstance
);
static
@@ -503,7 +491,7 @@ Returns:
// Add these firmware volumes to the list of known firmware
// volume names.
//
- AddFirmwareVolumes (FVs, ComponentsInstance, Ptr);
+ AddFirmwareVolumes (FVs, ComponentsInstance);
return STATUS_SUCCESS;
}
@@ -528,7 +516,7 @@ CFVDestructor (
//
while (mFVList != NULL) {
mFVListLast = mFVList->Next;
- FREE (mFVList);
+ free (mFVList);
mFVList = mFVListLast;
}
}
@@ -957,10 +945,10 @@ Returns:
//
// Now go through the list of all NonFFS FVs they specified and search for
// a [build.fv.$(FV)] or [build.fv] command and emit the commands to the
- // output makefile. Add them to the "fvs" target as well.
+ // output makefile. Add them to the "fvs_0" target as well.
//
if (mNonFfsFVList != NULL) {
- fprintf (MakeFptr, "fvs ::");
+ fprintf (MakeFptr, "fvs_0 ::");
FVPtr = mNonFfsFVList;
while (FVPtr != NULL) {
fprintf (MakeFptr, " %s%s.fv", FVDir, FVPtr->FVFileName);
@@ -1022,43 +1010,40 @@ Returns:
DSCFileRestorePosition (DSC);
}
}
+
//
- // Go through our list of firmware volumes and create an "fvs" target that
- // builds everything. It has to be a mix of components and FV's in order.
- // For example: fvs : components_0 fv\fv001.fv fv\fv002.fv components_1 fv\fv003.fv
+ // Get the components count
//
- ComponentsInstance = 0;
- ComponentCount = 0;
- fprintf (MakeFptr, "fvs ::");
- for (;;) {
- //
- // First see if we have any components for this section. If we don't,
- // then we're done
- //
- for (FileListPtr = mFileList; FileListPtr != NULL; FileListPtr = FileListPtr->Next) {
- if (FileListPtr->ComponentsInstance == ComponentsInstance) {
- break;
- }
- }
-
- if (FileListPtr == NULL) {
- break;
+ ComponentCount = -1;
+ for (FileListPtr = mFileList; FileListPtr != NULL; FileListPtr = FileListPtr->Next) {
+ if (FileListPtr->ComponentsInstance > ComponentCount) {
+ ComponentCount = FileListPtr->ComponentsInstance;
}
+ }
+ ComponentCount++;
- fprintf (MakeFptr, " components_%d", ComponentsInstance);
- ComponentCount++;
- //
- // Now print any firmware volumes that match this components instance
- //
+ //
+ // Now print firmware volumes build targets fvs_0, fvs_1 etc.
+ //
+ for (ComponentsInstance = 0; ComponentsInstance < ComponentCount; ComponentsInstance++) {
+ fprintf (MakeFptr, "fvs_%d ::", ComponentsInstance);
for (FVPtr = mFVList; FVPtr != NULL; FVPtr = FVPtr->Next) {
if (FVPtr->ComponentsInstance == ComponentsInstance) {
fprintf (MakeFptr, " %s%s.fv", FVDir, FVPtr->FVFileName);
}
}
-
- ComponentsInstance++;
+ fprintf (MakeFptr, "\n\n");
+ }
+
+ //
+ // Create an "fvs" target that builds everything. It has to be a mix of
+ // components and FV's in order. For example:
+ // fvs :: components_0 fvs_0 components_1 fvs_1
+ //
+ fprintf (MakeFptr, "fvs ::");
+ for (ComponentsInstance = 0; ComponentsInstance < ComponentCount; ComponentsInstance++) {
+ fprintf (MakeFptr, " components_%d fvs_%d", ComponentsInstance, ComponentsInstance);
}
-
fprintf (MakeFptr, "\n\n");
//
@@ -1351,8 +1336,7 @@ static
void
AddFirmwareVolumes (
char *FVs,
- int ComponentsInstance,
- FILE_LIST *FileListPtr
+ int ComponentsInstance
)
{
FV_LIST *FvPtr;
@@ -1386,7 +1370,7 @@ AddFirmwareVolumes (
// If we didn't find a match, then create a new one
//
if (FvPtr == NULL) {
- FvPtr = MALLOC (sizeof (FV_LIST));
+ FvPtr = malloc (sizeof (FV_LIST));
if (FvPtr == NULL) {
Error (__FILE__, __LINE__, 0, "application error", "memory allocation failed");
return ;
diff --git a/EdkCompatibilityPkg/Sample/Tools/Source/ProcessDsc/Makefile b/EdkCompatibilityPkg/Sample/Tools/Source/ProcessDsc/Makefile
index 417951cf59..e2a4b5f06b 100644
--- a/EdkCompatibilityPkg/Sample/Tools/Source/ProcessDsc/Makefile
+++ b/EdkCompatibilityPkg/Sample/Tools/Source/ProcessDsc/Makefile
@@ -1,6 +1,6 @@
#/*++
#
-# Copyright (c) 2004 - 2007, 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
@@ -49,25 +49,31 @@ TARGET_EXE = $(EDK_TOOLS_OUTPUT)\ProcessDsc.exe
all: $(TARGET_EXE)
-INC_DEPS = $(TARGET_SRC_DIR)\DSCFile.h $(INC_DEPS)
-INC_DEPS = $(TARGET_SRC_DIR)\FWVolume.h $(INC_DEPS)
-INC_DEPS = $(TARGET_SRC_DIR)\Exceptions.h $(INC_DEPS)
-INC_DEPS = $(TARGET_SRC_DIR)\Common.h $(INC_DEPS)
+INC_DEPS = $(TARGET_SRC_DIR)\DSCFile.h $(INC_DEPS)
+INC_DEPS = $(TARGET_SRC_DIR)\MultiThread.h $(INC_DEPS)
+INC_DEPS = $(TARGET_SRC_DIR)\FWVolume.h $(INC_DEPS)
+INC_DEPS = $(TARGET_SRC_DIR)\Exceptions.h $(INC_DEPS)
+INC_DEPS = $(TARGET_SRC_DIR)\Common.h $(INC_DEPS)
LIBS = $(LIBS) "$(EDK_TOOLS_OUTPUT)\Common.lib"
-OBJECTS = $(EDK_TOOLS_OUTPUT)\DSCFile.obj \
- $(EDK_TOOLS_OUTPUT)\FWVolume.obj \
- $(EDK_TOOLS_OUTPUT)\ProcessDsc.obj \
+OBJECTS = $(EDK_TOOLS_OUTPUT)\DSCFile.obj \
+ $(EDK_TOOLS_OUTPUT)\MultiThread.obj \
+ $(EDK_TOOLS_OUTPUT)\FWVolume.obj \
+ $(EDK_TOOLS_OUTPUT)\ProcessDsc.obj \
$(EDK_TOOLS_OUTPUT)\Exceptions.obj
#
# Compile each source file
#
+C_FLAGS = $(C_FLAGS) /MT /wd4201
$(EDK_TOOLS_OUTPUT)\DSCFile.obj : $(TARGET_SRC_DIR)\DSCFile.c $(INC_DEPS)
$(CC) $(C_FLAGS) $(TARGET_SRC_DIR)\DSCFile.c /Fo$@
+$(EDK_TOOLS_OUTPUT)\MultiThread.obj : $(TARGET_SRC_DIR)\MultiThread.c $(INC_DEPS)
+ $(CC) $(C_FLAGS) $(TARGET_SRC_DIR)\MultiThread.c /Fo$@
+
$(EDK_TOOLS_OUTPUT)\FWVolume.obj : $(TARGET_SRC_DIR)\FWVolume.c $(INC_DEPS)
$(CC) $(C_FLAGS) $(TARGET_SRC_DIR)\FWVolume.c /Fo$@
@@ -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
!ELSE
$(TARGET_EXE) : $(OBJECTS) $(LIBS)
- $(LINK) $(MSVS_LINK_LIBPATHS) $(L_FLAGS) $(LIBS) /out:$(TARGET_EXE) $(OBJECTS)
+ $(LINK) $(MSVS_LINK_LIBPATHS) $(L_FLAGS) $(LIBS) /out:$(TARGET_EXE) $(OBJECTS) shlwapi.lib \
+ /NODEFAULTLIB:libc.lib /NODEFAULTLIB:msvcrt.lib /NODEFAULTLIB:libcd.lib \
+ /NODEFAULTLIB:libcmtd.lib /NODEFAULTLIB:msvcrtd.lib
!IF ("$(EFI_BINARY_BUILD)" == "YES")
if not exist $(EFI_PLATFORM_BIN)\Tools mkdir $(EFI_PLATFORM_BIN)\Tools
if exist $(TARGET_EXE) copy $(TARGET_EXE) $(EFI_PLATFORM_BIN)\tools\$(TARGET_NAME).exe /Y
@@ -100,5 +108,6 @@ $(TARGET_EXE) : $(OBJECTS) $(LIBS)
clean:
@if exist $(EDK_TOOLS_OUTPUT)\$(TARGET_NAME).* del $(EDK_TOOLS_OUTPUT)\$(TARGET_NAME).* > NUL
@if exist $(EDK_TOOLS_OUTPUT)\DscFile.* del $(EDK_TOOLS_OUTPUT)\DscFile.* > NUL
+ @if exist $(EDK_TOOLS_OUTPUT)\MultiThread.* del $(EDK_TOOLS_OUTPUT)\MultiThread.* > NUL
@if exist $(EDK_TOOLS_OUTPUT)\Exceptions* del $(EDK_TOOLS_OUTPUT)\Exceptions.* > NUL
@if exist $(EDK_TOOLS_OUTPUT)\FwVolume.* del $(EDK_TOOLS_OUTPUT)\FwVolume.* > NUL
diff --git a/EdkCompatibilityPkg/Sample/Tools/Source/ProcessDsc/MultiThread.c b/EdkCompatibilityPkg/Sample/Tools/Source/ProcessDsc/MultiThread.c
new file mode 100644
index 0000000000..b6a72eca78
--- /dev/null
+++ b/EdkCompatibilityPkg/Sample/Tools/Source/ProcessDsc/MultiThread.c
@@ -0,0 +1,905 @@
+/*++
+
+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
+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:
+
+ MultiThread.c
+
+Abstract:
+
+ This module is used to add multi-thread build support to ProcessDsc utility
+ to improve the build performance.
+
+--*/
+
+#include <windows.h>
+#include <stdio.h>
+#include <string.h>
+#include <stdlib.h>
+#include <direct.h>
+#include "Common.h"
+#include "MultiThread.h"
+
+BUILD_ITEM *
+AddBuildItem (
+ BUILD_ITEM **BuildList,
+ INT8 *BaseName,
+ INT8 *Processor,
+ INT8 *Makefile
+ )
+/*++
+
+Routine Description:
+
+ Add a build item to a specified build list
+
+Arguments:
+
+ BuildList - build list where the new build item will be added
+ BaseName - base name of the new module
+ Processor - processor type of the new module
+ Makefile - makefile name of the new module
+
+Returns:
+
+ Pointer to the newly added build item
+
+--*/
+{
+ BUILD_ITEM *NewBuildItem;
+
+ //
+ // Create a new build item
+ //
+ NewBuildItem = malloc (sizeof (BUILD_ITEM));
+ if (NewBuildItem == NULL) {
+ return NULL;
+ }
+ memset (NewBuildItem, 0, sizeof (BUILD_ITEM));
+ NewBuildItem->BaseName = _strdup (BaseName);
+ NewBuildItem->Processor = _strdup (Processor);
+ NewBuildItem->Makefile = _strdup (Makefile);
+
+ //
+ // Add the build item to the head of the build list
+ //
+ NewBuildItem->Next = *BuildList;
+ *BuildList = NewBuildItem;
+
+ return NewBuildItem;
+}
+
+SOURCE_FILE_ITEM *
+AddSourceFile (
+ BUILD_ITEM *BuildItem,
+ INT8 *FileName
+ )
+/*++
+
+Routine Description:
+
+ Add a source file for a build item
+
+Arguments:
+
+ BuildItem - build item to add the source file
+ FileName - source file name to be added
+
+Returns:
+
+ Pointer to the newly added source file item
+
+--*/
+{
+ SOURCE_FILE_ITEM *NewSourceFile;
+
+ //
+ // Create a new source file item
+ //
+ NewSourceFile = malloc (sizeof (SOURCE_FILE_ITEM));
+ if (NewSourceFile == NULL) {
+ return NULL;
+ }
+ memset (NewSourceFile, 0, sizeof (SOURCE_FILE_ITEM));
+ NewSourceFile->FileName = _strdup (FileName);
+
+ //
+ // Add the source file item to the head of the source file list
+ //
+ NewSourceFile->Next = BuildItem->SourceFileList;
+ BuildItem->SourceFileList = NewSourceFile;
+
+ return NewSourceFile;
+}
+
+DEPENDENCY_ITEM *
+AddDependency (
+ BUILD_ITEM *BuildList,
+ BUILD_ITEM *BuildItem,
+ INT8 *BaseName,
+ INT8 AdjustIndex
+ )
+/*++
+
+Routine Description:
+
+ Add a build dependency for a build item in the specified build list
+
+Arguments:
+
+ BuildList - build list where to search the dependency
+ BuildItem - build item to add the dependency
+ BaseName - dependency module base name
+ AdjustIndex - Adjust BuildItem->Index when non-zero
+
+Returns:
+
+ Pointer to the newly added build dependency
+
+--*/
+{
+ BUILD_ITEM *TempBuildItem;
+ DEPENDENCY_ITEM *NewDependency;
+
+ //
+ // Search the dependency in the build list
+ //
+ TempBuildItem = BuildList;
+ while (TempBuildItem != NULL) {
+ if ((_stricmp (TempBuildItem->BaseName, BaseName) == 0) &&
+ (_stricmp (TempBuildItem->Processor, BuildItem->Processor) == 0) &&
+ (TempBuildItem != BuildItem)) {
+ break;
+ }
+ TempBuildItem = TempBuildItem->Next;
+ }
+ if (TempBuildItem == NULL) {
+ return NULL;
+ }
+
+ //
+ // This index is used to isolate two modules with same base name and processor.
+ // (ProcessDsc allows duplicate base name libraries.)
+ //
+ if (AdjustIndex) {
+ BuildItem->Index = TempBuildItem->Index + 1;
+ }
+
+ //
+ // Create a new build dependency item
+ //
+ NewDependency = malloc (sizeof (DEPENDENCY_ITEM));
+ if (NewDependency == NULL) {
+ return NULL;
+ }
+ memset (NewDependency, 0, sizeof (DEPENDENCY_ITEM));
+ NewDependency->Dependency = TempBuildItem;
+
+ //
+ // Add the build dependency item to the head of the dependency list
+ //
+ NewDependency->Next = BuildItem->DependencyList;
+ BuildItem->DependencyList = NewDependency;
+
+ return NewDependency;
+}
+
+void
+FreeBuildList (
+ BUILD_ITEM *BuildList
+ )
+/*++
+
+Routine Description:
+
+ Free a build list
+
+Arguments:
+
+ BuildList - build list to be freed
+
+Returns:
+
+--*/
+{
+ BUILD_ITEM *TempBuildItem;
+ BUILD_ITEM *FreeBuildItem;
+ SOURCE_FILE_ITEM *TempSourceFile;
+ SOURCE_FILE_ITEM *FreeSourceFile;
+ DEPENDENCY_ITEM *TempDependency;
+ DEPENDENCY_ITEM *FreeDependency;
+
+ TempBuildItem = BuildList;
+ while (TempBuildItem != NULL) {
+ free (TempBuildItem->BaseName);
+ free (TempBuildItem->Processor);
+ free (TempBuildItem->Makefile);
+
+ //
+ // Free source file list
+ //
+ TempSourceFile = TempBuildItem->SourceFileList;
+ while (TempSourceFile != NULL) {
+ FreeSourceFile = TempSourceFile;
+ TempSourceFile = TempSourceFile->Next;
+ free (FreeSourceFile);
+ }
+
+ //
+ // Free dependency list
+ //
+ TempDependency = TempBuildItem->DependencyList;
+ while (TempDependency != NULL) {
+ FreeDependency = TempDependency;
+ TempDependency = TempDependency->Next;
+ free (FreeDependency);
+ }
+
+ FreeBuildItem = TempBuildItem;
+ TempBuildItem = TempBuildItem->Next;
+ free (FreeBuildItem);
+ }
+}
+
+COMPONENTS_ITEM *
+AddComponentsItem (
+ COMPONENTS_ITEM **ComponentsList
+ )
+/*++
+
+Routine Description:
+
+ Add a new components item to a specified components list
+
+Arguments:
+
+ ComponentsList - components list where the new components item will be added
+
+Returns:
+
+ Pointer to the newly added components item
+
+--*/
+{
+ COMPONENTS_ITEM *NewComponents;
+ COMPONENTS_ITEM *TempComponents;
+
+ //
+ // Create a new components item
+ //
+ NewComponents = malloc (sizeof (COMPONENTS_ITEM));
+ if (NewComponents == NULL) {
+ return NULL;
+ }
+ memset (NewComponents, 0, sizeof (COMPONENTS_ITEM));
+
+ //
+ // Add the components item to the tail of the components list
+ //
+ TempComponents = *ComponentsList;
+ if (TempComponents == NULL) {
+ *ComponentsList = NewComponents;
+ } else {
+ while (TempComponents->Next != NULL) {
+ TempComponents = TempComponents->Next;
+ }
+ TempComponents->Next = NewComponents;
+ }
+
+ return NewComponents;
+}
+
+void
+FreeComponentsList (
+ COMPONENTS_ITEM *ComponentsList
+ )
+/*++
+
+Routine Description:
+
+ Free a components list
+
+Arguments:
+
+ ComponentsList - components list to be freed
+
+Returns:
+
+--*/
+{
+ COMPONENTS_ITEM *TempComponents;
+ COMPONENTS_ITEM *FreeComponents;
+
+ TempComponents = ComponentsList;
+ while (TempComponents != NULL) {
+ FreeBuildList (TempComponents->BuildList);
+ FreeComponents = TempComponents;
+ TempComponents = TempComponents->Next;
+ free (FreeComponents);
+ }
+}
+
+//
+// Module globals for multi-thread build
+//
+static INT8 mError; // non-zero means error occurred
+static INT8 mDone; // non-zero means no more build items available for build
+static UINT32 mThreadNumber; // thread number
+static INT8 *mBuildDir; // build directory
+static INT8 mLogDir[MAX_PATH]; // build item log dir
+static CRITICAL_SECTION mCriticalSection; // critical section object
+static HANDLE mSemaphoreHandle; // semaphore for "ready for build" items in mWaitingList
+static HANDLE mEventHandle; // event signaled when one build item is finished
+static BUILD_ITEM *mPendingList; // build list for build items which are not ready for build
+static BUILD_ITEM *mWaitingList; // build list for build items which are ready for build
+static BUILD_ITEM *mBuildingList; // build list for build items which are buiding
+static BUILD_ITEM *mDoneList; // build list for build items which already finish the build
+
+//
+// Restore the BuildList (not care about the sequence of the build items)
+//
+static void
+RestoreBuildList (
+ BUILD_ITEM **BuildList
+ )
+{
+ BUILD_ITEM *TempBuildItem;
+
+ if (mPendingList != NULL) {
+ //
+ // Add the mPendingList to the header of *BuildList
+ //
+ TempBuildItem = mPendingList;
+ while (TempBuildItem->Next != NULL) {
+ TempBuildItem = TempBuildItem->Next;
+ }
+ TempBuildItem->Next = *BuildList;
+ *BuildList = mPendingList;
+ }
+
+ if (mWaitingList != NULL) {
+ //
+ // Add the mWaitingList to the header of *BuildList
+ //
+ TempBuildItem = mWaitingList;
+ while (TempBuildItem->Next != NULL) {
+ TempBuildItem = TempBuildItem->Next;
+ }
+ TempBuildItem->Next = *BuildList;
+ *BuildList = mWaitingList;
+ }
+
+ if (mBuildingList != NULL) {
+ //
+ // Add the mBuildingList to the header of *BuildList
+ //
+ TempBuildItem = mBuildingList;
+ while (TempBuildItem->Next != NULL) {
+ TempBuildItem = TempBuildItem->Next;
+ }
+ TempBuildItem->Next = *BuildList;
+ *BuildList = mBuildingList;
+ }
+
+ if (mDoneList != NULL) {
+ //
+ // Add the mDoneList to the header of *BuildList
+ //
+ TempBuildItem = mDoneList;
+ while (TempBuildItem->Next != NULL) {
+ TempBuildItem = TempBuildItem->Next;
+ }
+ TempBuildItem->Next = *BuildList;
+ *BuildList = mDoneList;
+ }
+}
+
+//
+// Return non-zero when no source file build conflict
+//
+static INT8
+CheckSourceFile (
+ SOURCE_FILE_ITEM *SourceFileList
+ )
+{
+ BUILD_ITEM *TempBuildItem;
+ SOURCE_FILE_ITEM *TempSourceFile;
+
+ while (SourceFileList != NULL) {
+ TempBuildItem = mBuildingList;
+ while (TempBuildItem != NULL) {
+ TempSourceFile = TempBuildItem->SourceFileList;
+ while (TempSourceFile != NULL) {
+ if (_stricmp (SourceFileList->FileName, TempSourceFile->FileName) == 0) {
+ return 0;
+ }
+ TempSourceFile = TempSourceFile->Next;
+ }
+ TempBuildItem = TempBuildItem->Next;
+ }
+ SourceFileList = SourceFileList->Next;
+ }
+
+ return 1;
+}
+
+//
+// Return non-zero when all the dependency build items has been built
+//
+static INT8
+CheckDependency (
+ DEPENDENCY_ITEM *DependencyList
+ )
+{
+ while (DependencyList != NULL) {
+ if (!(DependencyList->Dependency->CompleteFlag)) {
+ return 0;
+ }
+ DependencyList = DependencyList->Next;
+ }
+
+ return 1;
+}
+
+//
+// Run the build task. The system() function call will cause stdout conflict
+// in multi-thread envroment, so implement this through CreateProcess().
+//
+static INT8
+RunBuildTask (
+ INT8 *WorkingDir,
+ INT8 *LogFile,
+ INT8 *BuildCmd
+ )
+{
+ HANDLE FileHandle;
+ SECURITY_ATTRIBUTES SecAttr;
+ PROCESS_INFORMATION ProcInfo;
+ STARTUPINFO StartInfo;
+ BOOL FuncRetn;
+ DWORD ExitCode;
+
+ //
+ // Init SecAttr
+ //
+ SecAttr.nLength = sizeof (SECURITY_ATTRIBUTES);
+ SecAttr.bInheritHandle = TRUE;
+ SecAttr.lpSecurityDescriptor = NULL;
+
+ //
+ // Create the log file
+ //
+ FileHandle = CreateFile (
+ LogFile, // file to create
+ GENERIC_WRITE, // open for writing
+ 0, // do not share
+ &SecAttr, // can be inherited by child processes
+ CREATE_ALWAYS, // overwrite existing
+ FILE_ATTRIBUTE_NORMAL, // normal file
+ NULL // no attr. template
+ );
+
+ if (FileHandle == INVALID_HANDLE_VALUE) {
+ EnterCriticalSection (&mCriticalSection);
+ Error (NULL, 0, 0, NULL, "could not open file %s", LogFile);
+ LeaveCriticalSection (&mCriticalSection);
+ return 1;
+ }
+
+ //
+ // Init ProcInfo and StartInfo
+ //
+ ZeroMemory (&ProcInfo, sizeof (PROCESS_INFORMATION));
+ ZeroMemory (&StartInfo, sizeof (STARTUPINFO));
+ StartInfo.cb = sizeof (STARTUPINFO);
+ StartInfo.hStdError = FileHandle;
+ StartInfo.hStdOutput = FileHandle;
+ StartInfo.hStdInput = GetStdHandle (STD_INPUT_HANDLE);
+ StartInfo.dwFlags = STARTF_USESTDHANDLES;
+
+ //
+ // Create the child process
+ //
+ FuncRetn = CreateProcess (
+ NULL, // no application name
+ BuildCmd, // command line
+ NULL, // process security attributes
+ NULL, // primary thread security attributes
+ TRUE, // handles are inherited
+ 0, // creation flags
+ NULL, // use parent's environment
+ WorkingDir, // set current directory
+ &StartInfo, // STARTUPINFO pointer
+ &ProcInfo // receives PROCESS_INFORMATION
+ );
+
+ if (FuncRetn == FALSE) {
+ EnterCriticalSection (&mCriticalSection);
+ Error (NULL, 0, 0, NULL, "could not create child process");
+ LeaveCriticalSection (&mCriticalSection);
+ CloseHandle (FileHandle);
+ return 1;
+ }
+
+ //
+ // Wait until child process exits
+ //
+ WaitForSingleObject (ProcInfo.hProcess, INFINITE);
+ GetExitCodeProcess (ProcInfo.hProcess, &ExitCode);
+ CloseHandle (ProcInfo.hProcess);
+ CloseHandle (ProcInfo.hThread);
+ CloseHandle (FileHandle);
+
+ if (ExitCode != 0) {
+ return 1;
+ } else {
+ return 0;
+ }
+}
+
+//
+// Thread function
+//
+static DWORD WINAPI
+ThreadProc (
+ LPVOID lpParam
+ )
+{
+ UINT32 ThreadId;
+ BUILD_ITEM *PreviousBuildItem;
+ BUILD_ITEM *CurrentBuildItem;
+ BUILD_ITEM *NextBuildItem;
+ INT8 WorkingDir[MAX_PATH];
+ INT8 LogFile[MAX_PATH];
+ INT8 BuildCmd[MAX_PATH];
+
+ ThreadId = (UINT32)lpParam;
+ //
+ // Loop until error occurred or no more build items available for build
+ //
+ for (;;) {
+ WaitForSingleObject (mSemaphoreHandle, INFINITE);
+ if (mError || mDone) {
+ return 0;
+ }
+
+ //
+ // When code runs here, there must have one build item available for this
+ // thread. Loop until error occurred or get one build item for build.
+ //
+ for (;;) {
+ EnterCriticalSection (&mCriticalSection);
+ PreviousBuildItem = NULL;
+ CurrentBuildItem = mWaitingList;
+ while (CurrentBuildItem != NULL) {
+ NextBuildItem = CurrentBuildItem->Next;
+ //
+ // CheckSourceFile() is to avoid concurrently build the same source file
+ // which may cause the muti-thread build failure
+ //
+ if (CheckSourceFile (CurrentBuildItem->SourceFileList)) {
+ //
+ // Move the current build item from mWaitingList
+ //
+ if (PreviousBuildItem != NULL) {
+ PreviousBuildItem->Next = NextBuildItem;
+ } else {
+ mWaitingList = NextBuildItem;
+ }
+ //
+ // Add the current build item to the head of mBuildingList
+ //
+ CurrentBuildItem->Next = mBuildingList;
+ mBuildingList = CurrentBuildItem;
+ //
+ // If no more build items is pending or waiting for build,
+ // wake up every child thread for exit.
+ //
+ if ((mPendingList == NULL) && (mWaitingList == NULL)) {
+ mDone = 1;
+ //
+ // Make sure to wake up every child thread for exit
+ //
+ ReleaseSemaphore (mSemaphoreHandle, mThreadNumber, NULL);
+ }
+ break;
+ }
+ PreviousBuildItem = CurrentBuildItem;
+ CurrentBuildItem = NextBuildItem;
+ }
+ if (CurrentBuildItem != NULL) {
+ //
+ // Display build item info
+ //
+ printf ("\t[Thread_%d] nmake -nologo -f %s all\n", ThreadId, CurrentBuildItem->Makefile);
+ //
+ // Prepare build task
+ //
+ sprintf (WorkingDir, "%s\\%s", mBuildDir, CurrentBuildItem->Processor);
+ sprintf (LogFile, "%s\\%s_%s_%d.txt", mLogDir, CurrentBuildItem->BaseName,
+ CurrentBuildItem->Processor, CurrentBuildItem->Index);
+ sprintf (BuildCmd, "nmake -nologo -f %s all", CurrentBuildItem->Makefile);
+ LeaveCriticalSection (&mCriticalSection);
+ break;
+ } else {
+ LeaveCriticalSection (&mCriticalSection);
+ //
+ // All the build items in mWaitingList have source file conflict with
+ // mBuildingList. This rarely hapeens. Need wait for the build items in
+ // mBuildingList to be finished by other child threads.
+ //
+ Sleep (1000);
+ if (mError) {
+ return 0;
+ }
+ }
+ }
+
+ //
+ // Start to build the CurrentBuildItem
+ //
+ if (RunBuildTask (WorkingDir, LogFile, BuildCmd)) {
+ //
+ // Build failure
+ //
+ mError = 1;
+ //
+ // Make sure to wake up every child thread for exit
+ //
+ ReleaseSemaphore (mSemaphoreHandle, mThreadNumber, NULL);
+ SetEvent(mEventHandle);
+
+ return mError;
+ } else {
+ //
+ // Build success
+ //
+ CurrentBuildItem->CompleteFlag = 1;
+
+ EnterCriticalSection (&mCriticalSection);
+ //
+ // Move this build item from mBuildingList
+ //
+ if (mBuildingList == CurrentBuildItem) {
+ mBuildingList = mBuildingList->Next;
+ } else {
+ NextBuildItem = mBuildingList;
+ while (NextBuildItem->Next != CurrentBuildItem) {
+ NextBuildItem = NextBuildItem->Next;
+ }
+ NextBuildItem->Next = CurrentBuildItem->Next;
+ }
+ //
+ // Add this build item to mDoneList
+ //
+ CurrentBuildItem->Next = mDoneList;
+ mDoneList = CurrentBuildItem;
+ LeaveCriticalSection (&mCriticalSection);
+
+ SetEvent(mEventHandle);
+ }
+ }
+}
+
+INT8
+StartMultiThreadBuild (
+ BUILD_ITEM **BuildList,
+ UINT32 ThreadNumber,
+ INT8 *BuildDir
+ )
+/*++
+
+Routine Description:
+
+ Start multi-thread build for a specified build list
+
+Arguments:
+
+ BuildList - build list for multi-thread build
+ ThreadNumber - thread number for multi-thread build
+ BuildDir - build dir
+
+Returns:
+
+ 0 - Successfully finished the multi-thread build
+ other value - Build failure
+
+--*/
+{
+ UINT32 Index;
+ UINT32 Count;
+ BUILD_ITEM *PreviousBuildItem;
+ BUILD_ITEM *CurrentBuildItem;
+ BUILD_ITEM *NextBuildItem;
+ HANDLE *ThreadHandle;
+ INT8 Cmd[MAX_PATH];
+
+ mError = 0;
+ mDone = 0;
+ mThreadNumber = ThreadNumber;
+ mBuildDir = BuildDir;
+ mPendingList = *BuildList;
+ *BuildList = NULL;
+ mWaitingList = NULL;
+ mBuildingList = NULL;
+ mDoneList = NULL;
+
+ //
+ // Do nothing when mPendingList is empty
+ //
+ if (mPendingList == NULL) {
+ return 0;
+ }
+
+ //
+ // Get build item count of mPendingList
+ //
+ Count = 0;
+ CurrentBuildItem = mPendingList;
+ while (CurrentBuildItem != NULL) {
+ Count++;
+ CurrentBuildItem = CurrentBuildItem->Next;
+ }
+
+ //
+ // The semaphore is also used to wake up child threads for exit,
+ // so need to make sure "maximum count" >= "thread number".
+ //
+ if (Count < ThreadNumber) {
+ Count = ThreadNumber;
+ }
+
+ //
+ // Init mSemaphoreHandle
+ //
+ mSemaphoreHandle = CreateSemaphore (
+ NULL, // default security attributes
+ 0, // initial count
+ Count, // maximum count
+ NULL // unnamed semaphore
+ );
+ if (mSemaphoreHandle == NULL) {
+ Error (NULL, 0, 0, NULL, "failed to create semaphore");
+ RestoreBuildList (BuildList);
+ return 1;
+ }
+
+ //
+ // Init mEventHandle
+ //
+ mEventHandle = CreateEvent(
+ NULL, // default security attributes
+ FALSE, // auto-reset event
+ TRUE, // initial state is signaled
+ NULL // object not named
+ );
+ if (mEventHandle == NULL) {
+ Error (NULL, 0, 0, NULL, "failed to create event");
+ CloseHandle (mSemaphoreHandle);
+ RestoreBuildList (BuildList);
+ return 1;
+ }
+
+ //
+ // Init mCriticalSection
+ //
+ InitializeCriticalSection (&mCriticalSection);
+
+ //
+ // Create build item log dir
+ //
+ sprintf (mLogDir, "%s\\Log", mBuildDir);
+ _mkdir (mLogDir);
+
+ //
+ // Create child threads for muti-thread build
+ //
+ ThreadHandle = malloc (ThreadNumber * sizeof (HANDLE));
+ if (ThreadHandle == NULL) {
+ Error (NULL, 0, 0, NULL, "failed to allocate memory");
+ CloseHandle (mSemaphoreHandle);
+ CloseHandle (mEventHandle);
+ RestoreBuildList (BuildList);
+ return 1;
+ }
+ for (Index = 0; Index < ThreadNumber; Index++) {
+ ThreadHandle[Index] = CreateThread (
+ NULL, // default security attributes
+ 0, // use default stack size
+ ThreadProc, // thread function
+ (LPVOID)Index, // argument to thread function: use Index as thread id
+ 0, // use default creation flags
+ NULL // thread identifier not needed
+ );
+ if (ThreadHandle[Index] == NULL) {
+ Error (NULL, 0, 0, NULL, "failed to create Thread_%d", Index);
+ mError = 1;
+ ThreadNumber = Index;
+ //
+ // Make sure to wake up every child thread for exit
+ //
+ ReleaseSemaphore (mSemaphoreHandle, ThreadNumber, NULL);
+ break;
+ }
+ }
+
+ //
+ // Loop until error occurred or no more build items pending for build
+ //
+ for (;;) {
+ WaitForSingleObject (mEventHandle, INFINITE);
+ if (mError) {
+ break;
+ }
+ Count = 0;
+
+ EnterCriticalSection (&mCriticalSection);
+ PreviousBuildItem = NULL;
+ CurrentBuildItem = mPendingList;
+ while (CurrentBuildItem != NULL) {
+ NextBuildItem = CurrentBuildItem->Next;
+ if (CheckDependency (CurrentBuildItem->DependencyList)) {
+ //
+ // Move the current build item from mPendingList
+ //
+ if (PreviousBuildItem != NULL) {
+ PreviousBuildItem->Next = NextBuildItem;
+ } else {
+ mPendingList = NextBuildItem;
+ }
+ //
+ // Add the current build item to the head of mWaitingList
+ //
+ CurrentBuildItem->Next = mWaitingList;
+ mWaitingList = CurrentBuildItem;
+ Count++;
+ } else {
+ PreviousBuildItem = CurrentBuildItem;
+ }
+ CurrentBuildItem = NextBuildItem;
+ }
+ LeaveCriticalSection (&mCriticalSection);
+
+ ReleaseSemaphore (mSemaphoreHandle, Count, NULL);
+ if (mPendingList == NULL) {
+ break;
+ }
+ }
+
+ //
+ // Wait until all threads have terminated
+ //
+ WaitForMultipleObjects (ThreadNumber, ThreadHandle, TRUE, INFINITE);
+
+ if (mError && (mBuildingList != NULL)) {
+ //
+ // Dump build failure log of the first build item which doesn't finish the build
+ //
+ printf ("\tnmake -nologo -f %s all\n", mBuildingList->Makefile);
+ sprintf (Cmd, "type %s\\%s_%s_%d.txt 2>NUL", mLogDir, mBuildingList->BaseName,
+ mBuildingList->Processor, mBuildingList->Index);
+ _flushall ();
+ if (system (Cmd)) {
+ Error (NULL, 0, 0, NULL, "failed to run \"%s\"", Cmd);
+ }
+ }
+
+ DeleteCriticalSection (&mCriticalSection);
+ for (Index = 0; Index < ThreadNumber; Index++) {
+ CloseHandle (ThreadHandle[Index]);
+ }
+ free (ThreadHandle);
+ CloseHandle (mSemaphoreHandle);
+ CloseHandle (mEventHandle);
+ RestoreBuildList (BuildList);
+
+ return mError;
+}
diff --git a/EdkCompatibilityPkg/Sample/Tools/Source/ProcessDsc/MultiThread.h b/EdkCompatibilityPkg/Sample/Tools/Source/ProcessDsc/MultiThread.h
new file mode 100644
index 0000000000..7a5566a913
--- /dev/null
+++ b/EdkCompatibilityPkg/Sample/Tools/Source/ProcessDsc/MultiThread.h
@@ -0,0 +1,116 @@
+/*++
+
+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
+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:
+
+ MultiThread.h
+
+Abstract:
+
+ Defines and function prototypes for the ProcessDsc utility.
+
+--*/
+
+#ifndef _MULTI_THREAD_H_
+#define _MULTI_THREAD_H_
+
+typedef struct _COMPONENTS_ITEM COMPONENTS_ITEM;
+typedef struct _BUILD_ITEM BUILD_ITEM;
+typedef struct _SOURCE_FILE_ITEM SOURCE_FILE_ITEM;
+typedef struct _DEPENDENCY_ITEM DEPENDENCY_ITEM;
+
+//
+// Use this structure to keep track of module build items
+//
+typedef struct _BUILD_ITEM {
+ BUILD_ITEM *Next;
+ INT8 *BaseName;
+ INT8 *Processor;
+ INT8 *Makefile;
+ UINT32 Index;
+ UINT32 CompleteFlag;
+ SOURCE_FILE_ITEM *SourceFileList;
+ DEPENDENCY_ITEM *DependencyList;
+} BUILD_ITEM;
+
+//
+// Use this structure to keep track of module source files
+//
+typedef struct _SOURCE_FILE_ITEM {
+ SOURCE_FILE_ITEM *Next;
+ INT8 *FileName;
+} SOURCE_FILE_ITEM;
+
+//
+// Use this structure to keep track of module build dependencies
+//
+typedef struct _DEPENDENCY_ITEM {
+ DEPENDENCY_ITEM *Next;
+ BUILD_ITEM *Dependency;
+} DEPENDENCY_ITEM;
+
+//
+// Use this structure to keep track of [components] and [components.n] sections
+//
+typedef struct _COMPONENTS_ITEM {
+ COMPONENTS_ITEM *Next;
+ BUILD_ITEM *BuildList;
+} COMPONENTS_ITEM;
+
+//
+// Function prototypes
+//
+BUILD_ITEM *
+AddBuildItem (
+ BUILD_ITEM **BuildList,
+ INT8 *BaseName,
+ INT8 *Processor,
+ INT8 *Makefile
+ );
+
+
+SOURCE_FILE_ITEM *
+AddSourceFile (
+ BUILD_ITEM *BuildItem,
+ INT8 *FileName
+ );
+
+DEPENDENCY_ITEM *
+AddDependency (
+ BUILD_ITEM *BuildList,
+ BUILD_ITEM *BuildItem,
+ INT8 *BaseName,
+ INT8 AdjustIndex
+ );
+
+void
+FreeBuildList (
+ BUILD_ITEM *BuildList
+ );
+
+COMPONENTS_ITEM *
+AddComponentsItem (
+ COMPONENTS_ITEM **ComponentsList
+ );
+
+void
+FreeComponentsList (
+ COMPONENTS_ITEM *ComponentsList
+ );
+
+INT8
+StartMultiThreadBuild (
+ BUILD_ITEM **BuildList,
+ UINT32 ThreadNumber,
+ INT8 *BuildDir
+ );
+
+#endif // ifndef _MULTI_THREAD_H_
diff --git a/EdkCompatibilityPkg/Sample/Tools/Source/ProcessDsc/ProcessDsc.c b/EdkCompatibilityPkg/Sample/Tools/Source/ProcessDsc/ProcessDsc.c
index 20faf6f69f..5f64bf5685 100644
--- a/EdkCompatibilityPkg/Sample/Tools/Source/ProcessDsc/ProcessDsc.c
+++ b/EdkCompatibilityPkg/Sample/Tools/Source/ProcessDsc/ProcessDsc.c
@@ -1,6 +1,6 @@
/*++
-Copyright (c) 2004 - 2007, 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
@@ -27,25 +27,18 @@ Abstract:
#include <direct.h> // for _mkdir()
#include <errno.h>
#include <stdlib.h> // for getenv()
+#include <shlwapi.h> // for PathCanonicalize()
#include "DSCFile.h"
+#include "MultiThread.h"
#include "FWVolume.h"
#include "Exceptions.h"
#include "Common.h"
#include "EfiUtilityMsgs.h"
#include "TianoBind.h"
-//
-// Disable warning for while(1) code
-//
-#pragma warning(disable : 4127)
-//
-// Disable warning for unreferenced function parameters
-//
-#pragma warning(disable : 4100)
-
-extern int errno;
-#define PROGRAM_NAME "ProcessDsc"
+#define UTILITY_NAME "ProcessDsc"
+#define UTILITY_VERSION "v1.0"
//
// Common symbol name definitions. For example, the user can reference
@@ -220,25 +213,39 @@ typedef struct _SYMBOL {
} SYMBOL;
//
-// Define new SYMBOL list to record all module name used in the platform.dsc file.
+// Module globals for multi-thread build
//
-SYMBOL *gModuleList = NULL;
+static BUILD_ITEM **mCurrentBuildList; // build list currently handling
+static BUILD_ITEM *mCurrentBuildItem; // build item currently handling
+
+//
+// Define masks for the build targets
+//
+#define BUILD_TARGET_COMPONENTS 0x01
+#define BUILD_TARGET_LIBRARIES 0x02
+#define BUILD_TARGET_FVS 0x04
+#define BUILD_TARGET_ALL 0xff
+
//
// This structure is used to save globals
//
struct {
- INT8 *DscFilename;
- SYMBOL *Symbol;
- INT8 MakefileName[MAX_PATH]; // output makefile name
- INT8 XRefFileName[MAX_PATH];
- INT8 GuidDatabaseFileName[MAX_PATH];
- INT8 ModuleMakefileName[MAX_PATH];
- FILE *MakefileFptr;
- FILE *ModuleMakefileFptr;
- SYMBOL *ModuleList;
- SYMBOL *OutdirList;
- UINT32 Verbose;
+ INT8 *DscFilename;
+ SYMBOL *Symbol;
+ INT8 MakefileName[MAX_PATH]; // output makefile name
+ INT8 XRefFileName[MAX_PATH];
+ INT8 GuidDatabaseFileName[MAX_PATH];
+ INT8 ModuleMakefileName[MAX_PATH];
+ FILE *MakefileFptr;
+ FILE *ModuleMakefileFptr;
+ SYMBOL *ModuleList;
+ SYMBOL *OutdirList;
+ UINT32 Verbose;
+ UINT32 ThreadNumber;
+ UINT32 BuildTarget;
+ BUILD_ITEM *LibraryList;
+ COMPONENTS_ITEM *ComponentsList;
} gGlobals;
//
@@ -584,16 +591,18 @@ Returns:
--*/
{
- int i;
- DSC_FILE DSCFile;
- SECTION *Sect;
- INT8 Line[MAX_LINE_LEN];
- INT8 ExpLine[MAX_LINE_LEN];
- INT8 *EMsg;
- FILE *FpModule;
- SYMBOL *TempSymbol;
-
- SetUtilityName (PROGRAM_NAME);
+ int i;
+ DSC_FILE DSCFile;
+ SECTION *Sect;
+ INT8 Line[MAX_LINE_LEN];
+ INT8 ExpLine[MAX_LINE_LEN];
+ INT8 *BuildDir;
+ INT8 *EMsg;
+ FILE *FpModule;
+ SYMBOL *TempSymbol;
+ COMPONENTS_ITEM *TempComponents;
+
+ SetUtilityName (UTILITY_NAME);
InitExceptions ();
@@ -710,6 +719,7 @@ Returns:
//
Sect = DSCFileFindSection (&DSCFile, LIBRARIES_SECTION_NAME);
if (Sect != NULL) {
+ mCurrentBuildList = &gGlobals.LibraryList;
ProcessSectionComponents (&DSCFile, DSC_SECTION_TYPE_LIBRARIES, 0);
}
@@ -721,6 +731,7 @@ Returns:
//
Sect = DSCFileFindSection (&DSCFile, LIBRARIES_PLATFORM_SECTION_NAME);
if (Sect != NULL) {
+ mCurrentBuildList = &gGlobals.LibraryList;
ProcessSectionComponents (&DSCFile, DSC_SECTION_TYPE_PLATFORM_LIBRARIES, 0);
}
@@ -735,6 +746,8 @@ Returns:
Sect = DSCFileFindSection (&DSCFile, COMPONENTS_SECTION_NAME);
if (Sect != NULL) {
fprintf (gGlobals.MakefileFptr, "components_0 : \n");
+ TempComponents = AddComponentsItem (&gGlobals.ComponentsList);
+ mCurrentBuildList = &TempComponents->BuildList;
ProcessSectionComponents (&DSCFile, DSC_SECTION_TYPE_COMPONENTS, 0);
fprintf (gGlobals.MakefileFptr, "\n");
}
@@ -754,6 +767,8 @@ Returns:
Sect = DSCFileFindSection (&DSCFile, Line);
if (Sect != NULL) {
fprintf (gGlobals.MakefileFptr, "components_%d : \n", i);
+ TempComponents = AddComponentsItem (&gGlobals.ComponentsList);
+ mCurrentBuildList = &TempComponents->BuildList;
ProcessSectionComponents (&DSCFile, DSC_SECTION_TYPE_COMPONENTS, i);
fprintf (gGlobals.MakefileFptr, "\n");
} else {
@@ -807,12 +822,52 @@ ProcessingError:
fclose (gGlobals.ModuleMakefileFptr);
gGlobals.ModuleMakefileFptr = NULL;
}
-
+
+ //
+ // Start multi-thread build if ThreadNumber is specified and no error status
+ //
+ if ((gGlobals.ThreadNumber != 0) && (GetUtilityStatus () < STATUS_ERROR)) {
+ BuildDir = GetSymbolValue (BUILD_DIR);
+ if (gGlobals.BuildTarget & BUILD_TARGET_LIBRARIES) {
+ if (StartMultiThreadBuild (&gGlobals.LibraryList, gGlobals.ThreadNumber, BuildDir) != 0) {
+ Error (NULL, 0, 0, NULL, "Multi-thread build libraries failure");
+ goto Cleanup;
+ }
+ }
+ i = 0;
+ TempComponents = gGlobals.ComponentsList;
+ while (TempComponents != NULL) {
+ if (gGlobals.BuildTarget & BUILD_TARGET_COMPONENTS) {
+ if (StartMultiThreadBuild (&TempComponents->BuildList, gGlobals.ThreadNumber, BuildDir) != 0) {
+ Error (NULL, 0, 0, NULL, "Multi-thread build components %d failure", i);
+ goto Cleanup;
+ }
+ }
+ if (gGlobals.BuildTarget & BUILD_TARGET_FVS) {
+ sprintf (ExpLine, "nmake -nologo -f %s fvs_%d", gGlobals.MakefileName, i);
+ _flushall ();
+ if (system (ExpLine)) {
+ Error (NULL, 0, 0, NULL, "Build FVs for components %d failure", i);
+ goto Cleanup;
+ }
+ }
+ i++;
+ TempComponents = TempComponents->Next;
+ }
+ }
+
+Cleanup:
//
// Clean up
//
+ FreeBuildList (gGlobals.LibraryList);
+ gGlobals.LibraryList = NULL;
+ FreeComponentsList (gGlobals.ComponentsList);
+ gGlobals.ComponentsList = NULL;
FreeSymbols (gGlobals.ModuleList);
+ gGlobals.ModuleList = NULL;
FreeSymbols (gGlobals.OutdirList);
+ gGlobals.OutdirList = NULL;
FreeSymbols (gGlobals.Symbol);
gGlobals.Symbol = NULL;
CFVDestructor ();
@@ -1312,6 +1367,16 @@ Returns:
}
//
+ // Add a new build item to mCurrentBuildList
+ //
+ mCurrentBuildItem = AddBuildItem (mCurrentBuildList, GetSymbolValue (BASE_NAME), Processor, FileName);
+ //
+ // ProcessDsc allows duplicate base name libraries. Make sure the duplicate
+ // base name libraries will be built in the same order as listed in DSC file.
+ //
+ AddDependency (*mCurrentBuildList, mCurrentBuildItem, mCurrentBuildItem->BaseName, 1);
+
+ //
// Add Module name to the global module list
//
AddModuleName (&gGlobals.ModuleList, GetSymbolValue (BASE_NAME), GetSymbolValue (INF_FILENAME));
@@ -1336,6 +1401,7 @@ Returns:
// files in this component. This macro can then be used elsewhere to
// process all the files making up the component. Required for scanning
// files for string localization.
+ // Also add source files to mCurrentBuildItem.
//
ProcessSourceFiles (DSCFile, &ComponentFile, MakeFptr, SOURCE_MODE_SOURCE_FILES);
//
@@ -1370,7 +1436,8 @@ Returns:
// Process all the libraries to define "LIBS = x.lib y.lib..."
// Be generous and append ".lib" if they forgot.
// Make a macro definition: LIBS = $(LIBS) xlib.lib ylib.lib...
- // Also add libs dependency for single module build: basenamebuild :: xlibbuild ylibbuild ...
+ // Add libs dependency for single module build: basenamebuild :: xlibbuild ylibbuild ...
+ // Also add libs dependency to mCurrentBuildItem.
//
ProcessLibs (&ComponentFile, MakeFptr);
@@ -1829,8 +1896,14 @@ Returns:
OverridePath = GetSymbolValue (SOURCE_OVERRIDE_PATH);
if (OverridePath != NULL) {
ReplaceSlash (OverridePath);
+ fprintf (MakeFptr, "!IF EXIST(%s)\n", OverridePath);
fprintf (MakeFptr, "INC = $(INC) -I %s\n", OverridePath);
- fprintf (MakeFptr, "INC = $(INC) -I %s\\%s \n", OverridePath, Processor);
+ fprintf (MakeFptr, "!IF EXIST(%s\\%s)\n", OverridePath, Processor);
+ fprintf (MakeFptr, "INC = $(INC) -I %s\\%s\n", OverridePath, Processor);
+ fprintf (MakeFptr, "!ENDIF\n");
+ fprintf (MakeFptr, "!ELSE\n");
+ fprintf (MakeFptr, "!MESSAGE Warning: include dir %s does not exist\n", OverridePath);
+ fprintf (MakeFptr, "!ENDIF\n");
}
//
// Try for an [includes.$(PROCESSOR).$(PLATFORM)]
@@ -1909,43 +1982,45 @@ ProcessIncludesSectionSingle (
//
if (Cptr[1] == 0) {
fprintf (MakeFptr, "INC = $(INC) -I $(SOURCE_DIR)\n");
- fprintf (
- MakeFptr,
- "INC = $(INC) -I $(SOURCE_DIR)\\%s \n",
- Processor
- );
+ fprintf (MakeFptr, "!IF EXIST($(SOURCE_DIR)\\%s)\n", Processor);
+ fprintf (MakeFptr, "INC = $(INC) -I $(SOURCE_DIR)\\%s\n", Processor);
+ fprintf (MakeFptr, "!ENDIF\n");
} else {
//
// Handle case of ".\path\path\path" or "..\path\path\path"
//
- fprintf (
- MakeFptr,
- "INC = $(INC) -I $(SOURCE_DIR)\\%s \n",
- Cptr
- );
- fprintf (
- MakeFptr,
- "INC = $(INC) -I $(SOURCE_DIR)\\%s\\%s \n",
- Cptr,
- Processor
- );
+ fprintf (MakeFptr, "!IF EXIST($(SOURCE_DIR)\\%s)\n", Cptr);
+ fprintf (MakeFptr, "INC = $(INC) -I $(SOURCE_DIR)\\%s\n", Cptr);
+ fprintf (MakeFptr, "!IF EXIST($(SOURCE_DIR)\\%s\\%s)\n", Cptr, Processor);
+ fprintf (MakeFptr, "INC = $(INC) -I $(SOURCE_DIR)\\%s\\%s\n", Cptr, Processor);
+ fprintf (MakeFptr, "!ENDIF\n");
+ fprintf (MakeFptr, "!ELSE\n");
+ fprintf (MakeFptr, "!MESSAGE Warning: include dir $(SOURCE_DIR)\\%s does not exist\n", Cptr);
+ fprintf (MakeFptr, "!ENDIF\n");
}
} else if ((Cptr[1] != ':') && isalpha (*Cptr)) {
- fprintf (MakeFptr, "INC = $(INC) -I $(EFI_SOURCE)\\%s \n", Cptr);
- fprintf (
- MakeFptr,
- "INC = $(INC) -I $(EFI_SOURCE)\\%s\\%s \n",
- Cptr,
- Processor
- );
+ fprintf (MakeFptr, "!IF EXIST($(EFI_SOURCE)\\%s)\n", Cptr);
+ fprintf (MakeFptr, "INC = $(INC) -I $(EFI_SOURCE)\\%s\n", Cptr);
+ fprintf (MakeFptr, "!IF EXIST($(EFI_SOURCE)\\%s\\%s)\n", Cptr, Processor);
+ fprintf (MakeFptr, "INC = $(INC) -I $(EFI_SOURCE)\\%s\\%s\n", Cptr, Processor);
+ fprintf (MakeFptr, "!ENDIF\n");
+ fprintf (MakeFptr, "!ELSE\n");
+ fprintf (MakeFptr, "!MESSAGE Warning: include dir $(EFI_SOURCE)\\%s does not exist\n", Cptr);
+ fprintf (MakeFptr, "!ENDIF\n");
} else {
//
// The line is something like: $(EFI_SOURCE)\dxe\include. Add it to
// the existing $(INC) definition. Add user includes before any
// other existing paths.
//
- fprintf (MakeFptr, "INC = $(INC) -I %s \n", Cptr);
- fprintf (MakeFptr, "INC = $(INC) -I %s\\%s \n", Cptr, Processor);
+ fprintf (MakeFptr, "!IF EXIST(%s)\n", Cptr);
+ fprintf (MakeFptr, "INC = $(INC) -I %s\n", Cptr);
+ fprintf (MakeFptr, "!IF EXIST(%s\\%s)\n", Cptr, Processor);
+ fprintf (MakeFptr, "INC = $(INC) -I %s\\%s\n", Cptr, Processor);
+ fprintf (MakeFptr, "!ENDIF\n");
+ fprintf (MakeFptr, "!ELSE\n");
+ fprintf (MakeFptr, "!MESSAGE Warning: include dir %s does not exist\n", Cptr);
+ fprintf (MakeFptr, "!ENDIF\n");
}
}
}
@@ -2260,16 +2335,35 @@ ProcessSourceFilesSection (
// SOURCE_FILES = $(SOURCE_FILES) c:\Path\ThisFile.c
//
fprintf (MakeFptr, "SOURCE_FILES = $(SOURCE_FILES) %s\n", TempFileName);
+ //
+ // Save the source absolute path
+ //
+ if (PathCanonicalize (FilePath, TempFileName)) {
+ AddSourceFile (mCurrentBuildItem, FilePath);
+ }
} else if (IsAbsolutePath (FileName)) {
//
// For Absolute path, don't print $(SOURCE_FILE) directory.
//
fprintf (MakeFptr, "SOURCE_FILES = $(SOURCE_FILES) %s\n", FileName);
+ //
+ // Save the source absolute path
+ //
+ if (PathCanonicalize (FilePath, FileName)) {
+ AddSourceFile (mCurrentBuildItem, FilePath);
+ }
} else {
//
// SOURCE_FILES = $(SOURCE_FILES) $(SOURCE_DIR)\ThisFile.c
//
fprintf (MakeFptr, "SOURCE_FILES = $(SOURCE_FILES) $(SOURCE_DIR)\\%s\n", FileName);
+ //
+ // Save the source absolute path
+ //
+ sprintf (Str, "%s\\%s", GetSymbolValue (SOURCE_DIR), FileName);
+ if (PathCanonicalize (FilePath, Str)) {
+ AddSourceFile (mCurrentBuildItem, FilePath);
+ }
}
} else if (Mode & SOURCE_MODE_BUILD_COMMANDS) {
//
@@ -2612,6 +2706,10 @@ ProcessLibsSingle (
Cptr[strlen (Cptr) - 4] = 0;
fprintf (gGlobals.ModuleMakefileFptr, " %sbuild", Cptr);
}
+ //
+ // Add libs dependency for mCurrentBuildItem
+ //
+ AddDependency (*mCurrentBuildList, mCurrentBuildItem, Cptr, 0);
}
}
}
@@ -2767,8 +2865,9 @@ ProcessIncludeFilesSingle (
if (Cptr >= TempFileName) {
*Cptr = 0;
}
-
+ fprintf (MakeFptr, "!IF EXIST(%s)\n", TempFileName);
fprintf (MakeFptr, "INC = -I %s $(INC)\n", TempFileName);
+ fprintf (MakeFptr, "!ENDIF\n");
}
}
//
@@ -4173,6 +4272,63 @@ Returns:
}
break;
+ //
+ // Enable multi-thread build and specify the thread number
+ //
+ case 'n':
+ case 'N':
+ //
+ // Skip to next arg
+ //
+ Argc--;
+ Argv++;
+ if (Argc == 0) {
+ Argv--;
+ Error (NULL, 0, 0, Argv[0], "missing input thread number with option");
+ Usage ();
+ return STATUS_ERROR;
+ } else {
+ gGlobals.ThreadNumber = atoi (Argv[0]);
+ if (gGlobals.ThreadNumber == 0) {
+ Argv--;
+ Error (NULL, 0, 0, Argv[0], "input thread number should not be %s", Argv[1]);
+ return STATUS_ERROR;
+ } else if (gGlobals.ThreadNumber > MAXIMUM_WAIT_OBJECTS) {
+ Argv--;
+ Error (NULL, 0, 0, Argv[0], "input thread number should not greater than %d", MAXIMUM_WAIT_OBJECTS);
+ return STATUS_ERROR;
+ }
+ }
+ break;
+
+ //
+ // Specify the multi-thread build target
+ //
+ case 't':
+ case 'T':
+ //
+ // Skip to next arg
+ //
+ Argc--;
+ Argv++;
+ if (Argc == 0) {
+ Argv--;
+ Error (NULL, 0, 0, Argv[0], "missing input build target with option");
+ Usage ();
+ return STATUS_ERROR;
+ } else if (_stricmp (Argv[0], "all") == 0) {
+ gGlobals.BuildTarget |= BUILD_TARGET_ALL;
+ } else if (_stricmp (Argv[0], "libraries") == 0) {
+ gGlobals.BuildTarget |= BUILD_TARGET_LIBRARIES;
+ } else if (_stricmp (Argv[0], "components") == 0) {
+ gGlobals.BuildTarget |= BUILD_TARGET_COMPONENTS;
+ } else {
+ Argv--;
+ Error (NULL, 0, 0, Argv[0], "input build target not supported");
+ Usage ();
+ }
+ break;
+
case 'v':
case 'V':
gGlobals.Verbose = 1;
@@ -4228,7 +4384,14 @@ Returns:
if (FreeCwd) {
free (Cptr);
}
-
+
+ //
+ // Default build target is all
+ //
+ if (gGlobals.BuildTarget == 0) {
+ gGlobals.BuildTarget = BUILD_TARGET_ALL;
+ }
+
return 0;
}
@@ -4426,18 +4589,29 @@ Usage (
VOID
)
{
- int i;
- static const INT8 *Help[] = {
- "Usage: ProcessDsc {options} [Dsc Filename]",
- " Options:",
- " -d var=value to define symbol 'var' to 'value'",
- " -v for verbose mode",
- " -g filename to preparse GUID listing file",
- " -x filename to create a cross-reference file",
+ int Index;
+ const char *Str[] = {
+ UTILITY_NAME" "UTILITY_VERSION" - Intel Process DSC File Utility",
+ " Copyright (C), 2004 - 2008 Intel Corporation",
+
+#if ( defined(UTILITY_BUILD) && defined(UTILITY_VENDOR) )
+ " Built from "UTILITY_BUILD", project of "UTILITY_VENDOR,
+#endif
+ "",
+ "Usage:",
+ " "UTILITY_NAME" [OPTION]... DSCFILE",
+ "Options:",
+ " -d var=value to define symbol 'var' to 'value'",
+ " -v for verbose mode",
+ " -g filename to preparse GUID listing file",
+ " -x filename to create a cross-reference file",
+ " -n threadnumber to build with multi-thread",
+ " -t target to build the specified target:",
+ " all, libraries or components",
NULL
};
- for (i = 0; Help[i] != NULL; i++) {
- fprintf (stdout, "%s\n", Help[i]);
+ for (Index = 0; Str[Index] != NULL; Index++) {
+ fprintf (stdout, "%s\n", Str[Index]);
}
}
@@ -4562,7 +4736,7 @@ SmartOpen (
if (SmartFile->FileContent != NULL) {
memset (SmartFile->FileContent, 0, FileSize + 1);
//
- // Usually FileLength < FileSize, because in text mode, carriage return-linefeed
+ // Usually FileLength < FileSize, because in text mode, carriage return¨Clinefeed
// combinations are translated into single linefeeds on input
//
SmartFile->FileLength = fread (SmartFile->FileContent, sizeof(char), FileSize, Fptr);
diff --git a/EdkCompatibilityPkg/Sample/Tools/Source/SetStamp/SetStamp.c b/EdkCompatibilityPkg/Sample/Tools/Source/SetStamp/SetStamp.c
index 866c6a4523..6777973810 100644
--- a/EdkCompatibilityPkg/Sample/Tools/Source/SetStamp/SetStamp.c
+++ b/EdkCompatibilityPkg/Sample/Tools/Source/SetStamp/SetStamp.c
@@ -1,6 +1,6 @@
/*++
-Copyright (c) 2004, 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
@@ -22,7 +22,8 @@ Abstract:
#include <time.h>
#define LINE_MAXLEN 80
-
+#define UTILITY_NAME "SetStamp"
+#define UTILITY_VERSION "v1.0"
void
PrintUsage (
void
@@ -38,10 +39,25 @@ Returns:
None
--*/
{
- //
- // print usage of command
- //
- printf ("Usage: SetStamp <PE-File> <TIME-File>\n");
+ int Index;
+ const char *Str[] = {
+ UTILITY_NAME" "UTILITY_VERSION" - Intel Set Time Stamp Utility",
+ " Copyright (C), 2004 - 2008 Intel Corporation",
+
+#if ( defined(UTILITY_BUILD) && defined(UTILITY_VENDOR) )
+ " Built from "UTILITY_BUILD", project of "UTILITY_VENDOR,
+#endif
+ "",
+ "Usage:",
+ " "UTILITY_NAME" PEFILE TIMEFILE",
+ "Description:",
+ " Set Date/Time Stamp of Portable Executable (PE) format file",
+ NULL
+ };
+ for (Index = 0; Str[Index] != NULL; Index++) {
+ fprintf (stdout, "%s\n", Str[Index]);
+ }
+
}
int
diff --git a/EdkCompatibilityPkg/Sample/Tools/Source/SplitFile/splitfile.c b/EdkCompatibilityPkg/Sample/Tools/Source/SplitFile/splitfile.c
index 74ac5a143c..c0df181f63 100644
--- a/EdkCompatibilityPkg/Sample/Tools/Source/SplitFile/splitfile.c
+++ b/EdkCompatibilityPkg/Sample/Tools/Source/SplitFile/splitfile.c
@@ -1,6 +1,6 @@
/*++
-Copyright (c) 2006, Intel Corporation. All rights reserved.<BR>
+Copyright (c) 2006 - 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
@@ -21,6 +21,9 @@ Abstract:
#include "string.h"
#include "stdlib.h"
+#define UTILITY_NAME "SplitFile"
+#define UTILITY_VERSION "v1.0"
+
void
helpmsg (
void
@@ -40,11 +43,24 @@ Returns:
--*/
{
- printf (
- "SplitFile Filename Offset\n"" Filename = Input file to split\n"" Offset = offset at which to split file\n"
- "\n\n""SplitFile will break a file in two pieces at the requested offset\n"
- " outputting Filename1 and Filename2\n"
- );
+ int Index;
+ const char *Str[] = {
+ UTILITY_NAME" "UTILITY_VERSION" - Intel Split File Utility",
+ " Copyright (C), 2006 - 2008 Intel Corporation",
+
+#if ( defined(UTILITY_BUILD) && defined(UTILITY_VENDOR) )
+ " Built from "UTILITY_BUILD", project of "UTILITY_VENDOR,
+#endif
+ "",
+ "Usage:",
+ " "UTILITY_NAME" FILE OFFSET",
+ "Description:",
+ " Break the FILE in two pieces FILE1 and FILE2 at the requested OFFSET.",
+ NULL
+ };
+ for (Index = 0; Str[Index] != NULL; Index++) {
+ fprintf (stdout, "%s\n", Str[Index]);
+ }
}
int
diff --git a/EdkCompatibilityPkg/Sample/Tools/Source/StrGather/StrGather.c b/EdkCompatibilityPkg/Sample/Tools/Source/StrGather/StrGather.c
index f830400b24..2d6d35bb88 100644
--- a/EdkCompatibilityPkg/Sample/Tools/Source/StrGather/StrGather.c
+++ b/EdkCompatibilityPkg/Sample/Tools/Source/StrGather/StrGather.c
@@ -1,6 +1,6 @@
/*++
-Copyright (c) 2004 - 2007, 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
@@ -29,7 +29,8 @@ Abstract:
#include "StrGather.h"
#include "StringDB.h"
-#define TOOL_VERSION "0.31"
+#define UTILITY_NAME "StrGather"
+#define UTILITY_VERSION "v1.0"
typedef UINT16 WCHAR;
@@ -281,11 +282,6 @@ ParseIndirectionFiles (
TEXT_STRING_LIST *Files
);
-STATUS
-StringDBCreateHiiExportPack (
- INT8 *OutputFileName
- );
-
int
main (
int Argc,
@@ -311,7 +307,7 @@ Returns:
{
STATUS Status;
- SetUtilityName (PROGRAM_NAME);
+ SetUtilityName (UTILITY_NAME);
//
// Process the command-line arguments
//
@@ -405,7 +401,7 @@ Returns:
// Dump the string data as HII binary string pack if requested
//
if ((mGlobals.HiiExportPackFileName[0] != 0) && (GetUtilityStatus () < STATUS_ERROR)) {
- StringDBCreateHiiExportPack (mGlobals.HiiExportPackFileName);
+ StringDBCreateHiiExportPack (mGlobals.HiiExportPackFileName, mGlobals.Language);
}
//
// Always update the database if no errors and not in dump mode. If they specified -od
@@ -1481,7 +1477,7 @@ FindFile (
// Put the path and filename together
//
if (strlen (List->Str) + strlen (FileName) + 1 > FoundFileNameLen) {
- Error (PROGRAM_NAME, 0, 0, NULL, "internal error - cannot concatenate path+filename");
+ Error (UTILITY_NAME, 0, 0, NULL, "internal error - cannot concatenate path+filename");
return NULL;
}
//
@@ -1581,7 +1577,7 @@ ProcessArgs (
// check for one more arg
//
if ((Argc <= 1) || (Argv[1][0] == '-')) {
- Error (PROGRAM_NAME, 0, 0, Argv[0], "missing include path");
+ Error (UTILITY_NAME, 0, 0, Argv[0], "missing include path");
return STATUS_ERROR;
}
//
@@ -1591,7 +1587,7 @@ ProcessArgs (
//
NewList = malloc (sizeof (TEXT_STRING_LIST));
if (NewList == NULL) {
- Error (PROGRAM_NAME, 0, 0, NULL, "memory allocation failure");
+ Error (UTILITY_NAME, 0, 0, NULL, "memory allocation failure");
return STATUS_ERROR;
}
@@ -1599,7 +1595,7 @@ ProcessArgs (
NewList->Str = malloc (strlen (Argv[1]) + 2);
if (NewList->Str == NULL) {
free (NewList);
- Error (PROGRAM_NAME, 0, 0, NULL, "memory allocation failure");
+ Error (UTILITY_NAME, 0, 0, NULL, "memory allocation failure");
return STATUS_ERROR;
}
@@ -1624,7 +1620,7 @@ ProcessArgs (
// Indirection file -- check for one more arg
//
if ((Argc <= 1) || (Argv[1][0] == '-')) {
- Error (PROGRAM_NAME, 0, 0, Argv[0], "missing indirection file name");
+ Error (UTILITY_NAME, 0, 0, Argv[0], "missing indirection file name");
return STATUS_ERROR;
}
//
@@ -1634,7 +1630,7 @@ ProcessArgs (
//
NewList = malloc (sizeof (TEXT_STRING_LIST));
if (NewList == NULL) {
- Error (PROGRAM_NAME, 0, 0, NULL, "memory allocation failure");
+ Error (UTILITY_NAME, 0, 0, NULL, "memory allocation failure");
return STATUS_ERROR;
}
@@ -1642,7 +1638,7 @@ ProcessArgs (
NewList->Str = malloc (strlen (Argv[1]) + 1);
if (NewList->Str == NULL) {
free (NewList);
- Error (PROGRAM_NAME, 0, 0, NULL, "memory allocation failure");
+ Error (UTILITY_NAME, 0, 0, NULL, "memory allocation failure");
return STATUS_ERROR;
}
@@ -1665,13 +1661,13 @@ ProcessArgs (
// Check for one more arg (the database file name)
//
if ((Argc <= 1) || (Argv[1][0] == '-')) {
- Error (PROGRAM_NAME, 0, 0, Argv[0], "missing database file name");
+ Error (UTILITY_NAME, 0, 0, Argv[0], "missing database file name");
return STATUS_ERROR;
}
NewList = malloc (sizeof (TEXT_STRING_LIST));
if (NewList == NULL) {
- Error (PROGRAM_NAME, 0, 0, NULL, "memory allocation failure");
+ Error (UTILITY_NAME, 0, 0, NULL, "memory allocation failure");
return STATUS_ERROR;
}
@@ -1679,7 +1675,7 @@ ProcessArgs (
NewList->Str = malloc (strlen (Argv[1]) + 1);
if (NewList->Str == NULL) {
free (NewList);
- Error (PROGRAM_NAME, 0, 0, NULL, "memory allocation failure");
+ Error (UTILITY_NAME, 0, 0, NULL, "memory allocation failure");
return STATUS_ERROR;
}
@@ -1702,14 +1698,14 @@ ProcessArgs (
// which we can dump our database.
//
if ((Argc <= 1) || (Argv[1][0] == '-')) {
- Error (PROGRAM_NAME, 0, 0, Argv[0], "missing database dump output file name");
+ Error (UTILITY_NAME, 0, 0, Argv[0], "missing database dump output file name");
return STATUS_ERROR;
}
if (mGlobals.DumpUFileName[0] == 0) {
strcpy (mGlobals.DumpUFileName, Argv[1]);
} else {
- Error (PROGRAM_NAME, 0, 0, Argv[1], "-ou option already specified with '%s'", mGlobals.DumpUFileName);
+ Error (UTILITY_NAME, 0, 0, Argv[1], "-ou option already specified with '%s'", mGlobals.DumpUFileName);
return STATUS_ERROR;
}
@@ -1720,14 +1716,14 @@ ProcessArgs (
// -hpk option to create an HII export pack of the input database file
//
if ((Argc <= 1) || (Argv[1][0] == '-')) {
- Error (PROGRAM_NAME, 0, 0, Argv[0], "missing raw string data dump output file name");
+ Error (UTILITY_NAME, 0, 0, Argv[0], "missing raw string data dump output file name");
return STATUS_ERROR;
}
if (mGlobals.HiiExportPackFileName[0] == 0) {
strcpy (mGlobals.HiiExportPackFileName, Argv[1]);
} else {
- Error (PROGRAM_NAME, 0, 0, Argv[1], "-or option already specified with '%s'", mGlobals.HiiExportPackFileName);
+ Error (UTILITY_NAME, 0, 0, Argv[1], "-or option already specified with '%s'", mGlobals.HiiExportPackFileName);
return STATUS_ERROR;
}
@@ -1751,7 +1747,7 @@ ProcessArgs (
// check for one more arg
//
if ((Argc <= 1) || (Argv[1][0] == '-')) {
- Error (PROGRAM_NAME, 0, 0, Argv[0], "missing output C filename");
+ Error (UTILITY_NAME, 0, 0, Argv[0], "missing output C filename");
return STATUS_ERROR;
}
@@ -1763,7 +1759,7 @@ ProcessArgs (
// check for one more arg
//
if ((Argc <= 1) || (Argv[1][0] == '-')) {
- Error (PROGRAM_NAME, 0, 0, Argv[0], "missing base name");
+ Error (UTILITY_NAME, 0, 0, Argv[0], "missing base name");
Usage ();
return STATUS_ERROR;
}
@@ -1776,7 +1772,7 @@ ProcessArgs (
// -oh to specify output .h defines file name
//
if ((Argc <= 1) || (Argv[1][0] == '-')) {
- Error (PROGRAM_NAME, 0, 0, Argv[0], "missing output .h filename");
+ Error (UTILITY_NAME, 0, 0, Argv[0], "missing output .h filename");
return STATUS_ERROR;
}
@@ -1788,7 +1784,7 @@ ProcessArgs (
// -dep to specify output dependency file name
//
if ((Argc <= 1) || (Argv[1][0] == '-')) {
- Error (PROGRAM_NAME, 0, 0, Argv[0], "missing output dependency filename");
+ Error (UTILITY_NAME, 0, 0, Argv[0], "missing output dependency filename");
return STATUS_ERROR;
}
@@ -1800,7 +1796,7 @@ ProcessArgs (
// -skipext to skip scanning of files with certain filename extensions
//
if ((Argc <= 1) || (Argv[1][0] == '-')) {
- Error (PROGRAM_NAME, 0, 0, Argv[0], "missing filename extension");
+ Error (UTILITY_NAME, 0, 0, Argv[0], "missing filename extension");
return STATUS_ERROR;
}
//
@@ -1810,7 +1806,7 @@ ProcessArgs (
//
NewList = malloc (sizeof (TEXT_STRING_LIST));
if (NewList == NULL) {
- Error (PROGRAM_NAME, 0, 0, NULL, "memory allocation failure");
+ Error (UTILITY_NAME, 0, 0, NULL, "memory allocation failure");
return STATUS_ERROR;
}
@@ -1818,7 +1814,7 @@ ProcessArgs (
NewList->Str = malloc (strlen (Argv[1]) + 2);
if (NewList->Str == NULL) {
free (NewList);
- Error (PROGRAM_NAME, 0, 0, NULL, "memory allocation failure");
+ Error (UTILITY_NAME, 0, 0, NULL, "memory allocation failure");
return STATUS_ERROR;
}
@@ -1845,7 +1841,7 @@ ProcessArgs (
// "-lang eng" or "-lang spa+cat" to only output certain languages
//
if ((Argc <= 1) || (Argv[1][0] == '-')) {
- Error (PROGRAM_NAME, 0, 0, Argv[0], "missing language name");
+ Error (UTILITY_NAME, 0, 0, Argv[0], "missing language name");
Usage ();
return STATUS_ERROR;
}
@@ -1861,7 +1857,7 @@ ProcessArgs (
// Output database file name -- check for another arg
//
if ((Argc <= 1) || (Argv[1][0] == '-')) {
- Error (PROGRAM_NAME, 0, 0, Argv[0], "missing output database file name");
+ Error (UTILITY_NAME, 0, 0, Argv[0], "missing output database file name");
return STATUS_ERROR;
}
@@ -1872,7 +1868,7 @@ ProcessArgs (
//
// Unrecognized arg
//
- Error (PROGRAM_NAME, 0, 0, Argv[0], "unrecognized option");
+ Error (UTILITY_NAME, 0, 0, Argv[0], "unrecognized option");
Usage ();
return STATUS_ERROR;
}
@@ -1919,7 +1915,7 @@ ProcessArgs (
//
if (mGlobals.Mode == MODE_SCAN) {
if (Argc < 1) {
- Error (PROGRAM_NAME, 0, 0, NULL, "must specify at least one source file to scan with -scan");
+ Error (UTILITY_NAME, 0, 0, NULL, "must specify at least one source file to scan with -scan");
Usage ();
return STATUS_ERROR;
}
@@ -1929,14 +1925,14 @@ ProcessArgs (
while (Argc > 0) {
NewList = malloc (sizeof (TEXT_STRING_LIST));
if (NewList == NULL) {
- Error (PROGRAM_NAME, 0, 0, "memory allocation failure", NULL);
+ Error (UTILITY_NAME, 0, 0, "memory allocation failure", NULL);
return STATUS_ERROR;
}
memset (NewList, 0, sizeof (TEXT_STRING_LIST));
NewList->Str = (UINT8 *) malloc (strlen (Argv[0]) + 1);
if (NewList->Str == NULL) {
- Error (PROGRAM_NAME, 0, 0, "memory allocation failure", NULL);
+ Error (UTILITY_NAME, 0, 0, "memory allocation failure", NULL);
return STATUS_ERROR;
}
@@ -1956,7 +1952,7 @@ ProcessArgs (
// Parse mode -- must specify an input unicode file name
//
if (Argc < 1) {
- Error (PROGRAM_NAME, 0, 0, NULL, "must specify input unicode string file name with -parse");
+ Error (UTILITY_NAME, 0, 0, NULL, "must specify input unicode string file name with -parse");
Usage ();
return STATUS_ERROR;
}
@@ -1989,7 +1985,7 @@ AddCommandLineLanguage (
//
WNewList = MALLOC (sizeof (WCHAR_STRING_LIST));
if (WNewList == NULL) {
- Error (PROGRAM_NAME, 0, 0, NULL, "memory allocation failure");
+ Error (UTILITY_NAME, 0, 0, NULL, "memory allocation failure");
return STATUS_ERROR;
}
@@ -1997,7 +1993,7 @@ AddCommandLineLanguage (
WNewList->Str = malloc ((strlen (Language) + 1) * sizeof (WCHAR));
if (WNewList->Str == NULL) {
free (WNewList);
- Error (PROGRAM_NAME, 0, 0, NULL, "memory allocation failure");
+ Error (UTILITY_NAME, 0, 0, NULL, "memory allocation failure");
return STATUS_ERROR;
}
//
@@ -2024,7 +2020,7 @@ AddCommandLineLanguage (
(From[LANGUAGE_IDENTIFIER_NAME_LEN] != L',')
)
) {
- Error (PROGRAM_NAME, 0, 0, Language, "invalid format for language name on command line");
+ Error (UTILITY_NAME, 0, 0, Language, "invalid format for language name on command line");
FREE (WNewList->Str);
FREE (WNewList);
return STATUS_ERROR;
@@ -2523,48 +2519,56 @@ Returns:
--*/
{
- int Index;
- static const char *Str[] = {
+ int Index;
+ const char *Str[] = {
+ UTILITY_NAME" "UTILITY_VERSION" - Intel String Gather Utility",
+ " Copyright (C), 2004 - 2008 Intel Corporation",
+
+#if ( defined(UTILITY_BUILD) && defined(UTILITY_VENDOR) )
+ " Built from "UTILITY_BUILD", project of "UTILITY_VENDOR,
+#endif
"",
- PROGRAM_NAME " version "TOOL_VERSION " -- process unicode strings file",
- " Usage: "PROGRAM_NAME " -parse {parse options} [FileNames]",
- " "PROGRAM_NAME " -scan {scan options} [FileName]",
- " "PROGRAM_NAME " -dump {dump options}",
- " Common options include:",
- " -h or -? for this help information",
- " -db Database required name of output/input database file",
- " -bn BaseName for use in the .h and .c output files",
- " Default = "DEFAULT_BASE_NAME,
- " -v for verbose output",
- " -vdbw for verbose output when writing database",
- " -vdbr for verbose output when reading database",
- " -od FileName to specify an output database file name",
- " Parse options include:",
- " -i IncludePath add IncludePath to list of search paths",
- " -dep FileName to specify an output dependency file name",
- " -newdb to not read in existing database file",
- " -uqs to indicate that unquoted strings are used",
- " FileNames name of one or more unicode files to parse",
- " Scan options include:",
- " -scan scan text file(s) for STRING_TOKEN() usage",
- " -skipext .ext to skip scan of files with .ext filename extension",
- " -ignorenotfound ignore if a given STRING_TOKEN(STR) is not ",
- " found in the database",
- " FileNames one or more files to scan",
- " Dump options include:",
- " -oc FileName write string data to FileName",
- " -oh FileName write string defines to FileName",
- " -ou FileName dump database to unicode file FileName",
- " -lang Lang only dump for the language 'Lang'",
- " -if FileName to specify an indirection file",
- " -hpk FileName to create an HII export pack of the strings",
+ "Usage:",
+ " "UTILITY_NAME" -parse [OPTION] FILE",
+ " "UTILITY_NAME" -scan [OPTION] FILE",
+ " "UTILITY_NAME" -dump [OPTION]",
+ "Description:",
+ " Process unicode strings file.",
+ "Common options include:",
+ " -h or -? for this help information",
+ " -db Database required name of output/input database file",
+ " -bn BaseName for use in the .h and .c output files",
+ " Default = "DEFAULT_BASE_NAME,
+ " -v for verbose output",
+ " -vdbw for verbose output when writing database",
+ " -vdbr for verbose output when reading database",
+ " -od FileName to specify an output database file name",
+ "Parse options include:",
+ " -i IncludePath add IncludePath to list of search paths",
+ " -dep FileName to specify an output dependency file name",
+ " -newdb to not read in existing database file",
+ " -uqs to indicate that unquoted strings are used",
+ " FileNames name of one or more unicode files to parse",
+ "Scan options include:",
+ " -scan scan text file(s) for STRING_TOKEN() usage",
+ " -skipext .ext to skip scan of files with .ext filename extension",
+ " -ignorenotfound ignore if a given STRING_TOKEN(STR) is not ",
+ " found in the database",
+ " FileNames one or more files to scan",
+ "Dump options include:",
+ " -oc FileName write string data to FileName",
+ " -oh FileName write string defines to FileName",
+ " -ou FileName dump database to unicode file FileName",
+ " -lang Lang only dump for the language 'Lang'",
+ " -if FileName to specify an indirection file",
+ " -hpk FileName to create an HII export pack of the strings",
"",
- " The expected process is to parse a unicode string file to create an initial",
- " database of string identifier names and string definitions. Then text files",
- " should be scanned for STRING_TOKEN() usages, and the referenced",
- " strings will be tagged as used in the database. After all files have been",
- " scanned, then the database should be dumped to create the necessary output",
- " files.",
+ "The expected process is to parse a unicode string file to create an initial",
+ "database of string identifier names and string definitions. Then text files",
+ "should be scanned for STRING_TOKEN() usages, and the referenced",
+ "strings will be tagged as used in the database. After all files have been",
+ "scanned, then the database should be dumped to create the necessary output",
+ "files.",
"",
NULL
};
diff --git a/EdkCompatibilityPkg/Sample/Tools/Source/StrGather/StrGather.h b/EdkCompatibilityPkg/Sample/Tools/Source/StrGather/StrGather.h
index d4da8e8690..e0dc783a8d 100644
--- a/EdkCompatibilityPkg/Sample/Tools/Source/StrGather/StrGather.h
+++ b/EdkCompatibilityPkg/Sample/Tools/Source/StrGather/StrGather.h
@@ -1,6 +1,6 @@
/*++
-Copyright (c) 2004, 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
@@ -25,8 +25,6 @@ Abstract:
#define MALLOC(size) malloc (size)
#define FREE(ptr) free (ptr)
-#define PROGRAM_NAME "StrGather"
-
typedef CHAR16 WCHAR;
#define UNICODE_TO_ASCII(w) (INT8) ((w) & 0xFF)
diff --git a/EdkCompatibilityPkg/Sample/Tools/Source/StrGather/StringDB.c b/EdkCompatibilityPkg/Sample/Tools/Source/StrGather/StringDB.c
index 6b17f48c6d..08afd83fb3 100644
--- a/EdkCompatibilityPkg/Sample/Tools/Source/StrGather/StringDB.c
+++ b/EdkCompatibilityPkg/Sample/Tools/Source/StrGather/StringDB.c
@@ -1,6 +1,6 @@
/*++
-Copyright (c) 2004 - 2007, 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
@@ -2508,7 +2508,8 @@ Returns:
--*/
STATUS
StringDBCreateHiiExportPack (
- INT8 *FileName
+ INT8 *FileName,
+ WCHAR_STRING_LIST *LanguagesOfInterest
)
{
FILE *Fptr;
@@ -2524,6 +2525,9 @@ StringDBCreateHiiExportPack (
WCHAR *TempStringPtr;
WCHAR *LangName;
STRING_IDENTIFIER *StringIdentifier;
+ WCHAR_STRING_LIST *LOIPtr;
+ BOOLEAN LanguageOk;
+
if ((Fptr = fopen (FileName, "wb")) == NULL) {
Error (NULL, 0, 0, FileName, "failed to open output HII export file");
@@ -2545,6 +2549,25 @@ StringDBCreateHiiExportPack (
ZeroString[0] = 0;
for (Lang = mDBData.LanguageList; Lang != NULL; Lang = Lang->Next) {
//
+ // If we have a language list, then make sure this language is in that
+ // list.
+ //
+ LanguageOk = TRUE;
+ if (LanguagesOfInterest != NULL) {
+ LanguageOk = FALSE;
+ for (LOIPtr = LanguagesOfInterest; LOIPtr != NULL; LOIPtr = LOIPtr->Next) {
+ if (wcsncmp (LOIPtr->Str, Lang->LanguageName, LANGUAGE_IDENTIFIER_NAME_LEN) == 0) {
+ LanguageOk = TRUE;
+ break;
+ }
+ }
+ }
+
+ if (!LanguageOk) {
+ continue;
+ }
+
+ //
// Process each string for this language. We have to make 3 passes on the strings:
// Pass1: computes sizes and fill in the string pack header
// Pass2: write the array of offsets
diff --git a/EdkCompatibilityPkg/Sample/Tools/Source/StrGather/StringDB.h b/EdkCompatibilityPkg/Sample/Tools/Source/StrGather/StringDB.h
index 92801f70f8..a4c2837ae0 100644
--- a/EdkCompatibilityPkg/Sample/Tools/Source/StrGather/StringDB.h
+++ b/EdkCompatibilityPkg/Sample/Tools/Source/StrGather/StringDB.h
@@ -1,6 +1,6 @@
/*++
-Copyright (c) 2004, 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
@@ -28,11 +28,13 @@ Abstract:
void
StringDBConstructor (
void
- );
+ )
+;
void
StringDBDestructor (
void
- );
+ )
+;
STATUS
StringDBAddString (
@@ -42,12 +44,14 @@ StringDBAddString (
WCHAR *String,
BOOLEAN Format,
UINT16 Flags
- );
+ )
+;
STATUS
StringDBSetScope (
WCHAR *Scope
- );
+ )
+;
#define STRING_FLAGS_REFERENCED 0x0001 // if referenced somewhere
#define STRING_FLAGS_UNDEFINED 0x0002 // if we added it for padding purposes
@@ -61,33 +65,38 @@ StringDBAddStringIdentifier (
WCHAR *StringIdentifier,
UINT16 *NewId,
UINT16 Flags
- );
+ )
+;
STATUS
StringDBReadDatabase (
INT8 *DBFileName,
BOOLEAN IgnoreIfNotExist,
BOOLEAN Verbose
- );
+ )
+;
STATUS
StringDBWriteDatabase (
INT8 *DBFileName,
BOOLEAN Verbose
- );
+ )
+;
STATUS
StringDBDumpDatabase (
INT8 *DBFileName,
INT8 *OutputFileName,
BOOLEAN Verbose
- );
+ )
+;
STATUS
StringDBAddLanguage (
WCHAR *LanguageName,
WCHAR *PrintableLanguageName
- );
+ )
+;
STATUS
StringDBDumpCStrings (
@@ -95,28 +104,40 @@ StringDBDumpCStrings (
INT8 *BaseName,
WCHAR_STRING_LIST *LanguagesOfInterest,
WCHAR_MATCHING_STRING_LIST *IndirectionList
- );
+ )
+;
STATUS
StringDBDumpStringDefines (
INT8 *FileName,
INT8 *BaseName
- );
+ )
+;
STATUS
StringDBSetCurrentLanguage (
WCHAR *LanguageName
- );
+ )
+;
STATUS
StringDBSetStringReferenced (
INT8 *StringIdentifierName,
BOOLEAN IgnoreNotFound
- );
+ )
+;
void
StringDBFormatString (
WCHAR *String
+ )
+;
+
+STATUS
+StringDBCreateHiiExportPack (
+ INT8 *OutputFileName,
+ WCHAR_STRING_LIST *LanguagesOfInterest
);
+
#endif // #ifndef _STRING_DB_H_
diff --git a/EdkCompatibilityPkg/Sample/Tools/Source/Strip/strip.c b/EdkCompatibilityPkg/Sample/Tools/Source/Strip/strip.c
index 03e1831ca7..03d3c3e5dd 100644
--- a/EdkCompatibilityPkg/Sample/Tools/Source/Strip/strip.c
+++ b/EdkCompatibilityPkg/Sample/Tools/Source/Strip/strip.c
@@ -1,6 +1,6 @@
/*++
-Copyright (c) 2006, Intel Corporation. All rights reserved.<BR>
+Copyright (c) 2006 - 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
@@ -24,6 +24,50 @@ Abstract:
#include <string.h>
#include <malloc.h>
+#define UTILITY_NAME "Strip"
+#define UTILITY_VERSION "v1.0"
+
+static
+void
+Usage (
+ )
+/*++
+
+Routine Description:
+
+ Print usage information for this utility.
+
+Arguments:
+
+ None.
+
+Returns:
+
+ Nothing.
+
+--*/
+{
+ int Index;
+ const char *Str[] = {
+ UTILITY_NAME" "UTILITY_VERSION" - Intel Strip Utility",
+ " Copyright (C), 2006 - 2008 Intel Corporation",
+
+#if ( defined(UTILITY_BUILD) && defined(UTILITY_VENDOR) )
+ " Built from "UTILITY_BUILD", project of "UTILITY_VENDOR,
+#endif
+ "",
+ "Usage:",
+ " "UTILITY_NAME" SOURCE DEST",
+ "Description:",
+ " Convert executable files to binary files.",
+ NULL
+ };
+
+ for (Index = 0; Str[Index] != NULL; Index++) {
+ fprintf (stdout, "%s\n", Str[Index]);
+ }
+}
+
int
main (
int argc,
@@ -55,7 +99,7 @@ Returns:
char *Ptrx;
if (argc < 3) {
- printf ("Need more args, such as file name to convert and output name\n");
+ Usage ();
return -1;
}
diff --git a/EdkCompatibilityPkg/Sample/Tools/Source/UefiHiiPack/HiiPack.c b/EdkCompatibilityPkg/Sample/Tools/Source/UefiHiiPack/HiiPack.c
new file mode 100644
index 0000000000..c1a4c3358c
--- /dev/null
+++ b/EdkCompatibilityPkg/Sample/Tools/Source/UefiHiiPack/HiiPack.c
@@ -0,0 +1,740 @@
+/*++
+
+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
+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:
+
+ HiiPack.c
+
+Abstract:
+
+ Process HII package files to generate HII package list binary file or PE/COFF
+ resource script file (i.e. .rc file).
+
+--*/
+
+#include <stdio.h>
+#include <string.h>
+
+#include "Tiano.h"
+#include "EfiHii.h"
+
+#include "EfiUtilityMsgs.h"
+#include "ParseInf.h"
+
+#define UTILITY_VERSION "v1.0"
+#define UTILITY_NAME "HiiPack"
+#define MAX_PATH 260
+
+//
+// Define HII resource section type and name
+//
+#define HII_RESOURCE_TYPE "HII"
+#define HII_RESOURCE_NAME 1
+
+//
+// We'll store lists of file names from the command line in
+// a linked list of these
+//
+typedef struct _FILE_NAME_LIST {
+ struct _FILE_NAME_LIST *Next;
+ UINT8 FileName[MAX_PATH];
+ UINT32 PackageType;
+ UINT32 Length;
+ UINT8 *Data;
+} FILE_NAME_LIST;
+
+//
+// Create some defines for the different operation modes supported by this utility
+//
+#define MODE_CREATE_HII_RESOURCE_FILE 0x0001
+#define MODE_CREATE_HII_PACKAGE_LIST 0x0002
+
+//
+// Here's all our globals.
+//
+static struct {
+ FILE_NAME_LIST *PackageFile; // all include paths to search
+ FILE_NAME_LIST *LastPackageFile;
+ UINT8 PackageListFileName[MAX_PATH]; // Output package list file name
+ UINT8 ResourceFileName[MAX_PATH]; // Output HII resource file name
+ EFI_GUID Guid; // Guid specified on command line
+ BOOLEAN GuidSpecified;
+ BOOLEAN Verbose;
+ UINT32 Mode; // Mode this utility is operating in
+} mGlobals;
+
+static
+void
+Usage (
+ VOID
+ );
+
+static
+STATUS
+ProcessArgs (
+ int Argc,
+ char *Argv[]
+ );
+
+static
+void
+FreeGlobals (
+ VOID
+ );
+
+static
+void
+DumpRawBytes (
+ FILE *OutFptr,
+ UINT8 *Buffer,
+ int Count,
+ int Indent
+ );
+
+static
+STATUS
+CreateResourceScript (
+ char *OutputFileName,
+ EFI_GUID *PackageListGuid,
+ FILE_NAME_LIST *PackageFiles
+ );
+
+static
+STATUS
+CreatePackageList (
+ char *OutputFileName,
+ EFI_GUID *PackageListGuid,
+ FILE_NAME_LIST *PackageFiles
+ );
+
+int
+main (
+ int Argc,
+ char *Argv[]
+ )
+/*++
+
+Routine Description:
+
+ Call the routine to parse the command-line options, then process the file.
+
+Arguments:
+
+ Standard C main() argc and argv.
+
+Returns:
+
+ 0 if successful
+ nonzero otherwise
+
+--*/
+{
+ STATUS Status;
+
+ //
+ // Set the utility name for error reporting purposes
+ //
+ SetUtilityName (UTILITY_NAME);
+
+ //
+ // Process the command-line arguments
+ //
+ Status = ProcessArgs (Argc, Argv);
+ if (Status != STATUS_SUCCESS) {
+ return Status;
+ }
+
+ //
+ // Switch based on args
+ //
+ if (mGlobals.Mode & MODE_CREATE_HII_RESOURCE_FILE) {
+ CreateResourceScript (mGlobals.ResourceFileName, &mGlobals.Guid, mGlobals.PackageFile);
+ }
+
+ if (mGlobals.Mode & MODE_CREATE_HII_PACKAGE_LIST) {
+ CreatePackageList (mGlobals.PackageListFileName, &mGlobals.Guid, mGlobals.PackageFile);
+ }
+
+ FreeGlobals ();
+
+ return GetUtilityStatus ();
+}
+
+/******************************************************************************/
+static const char *gRcFileHeader[] = {
+ "//",
+ "// DO NOT EDIT -- auto-generated file",
+ "//",
+ "// This file is generated by the hiipack utility",
+ "//",
+ NULL
+};
+
+static
+STATUS
+CreateResourceScript (
+ char *OutputFileName,
+ EFI_GUID *PackageListGuid,
+ FILE_NAME_LIST *PackageFiles
+ )
+/*++
+
+Routine Description:
+
+ Given a linked list of HII package files, walk the list to
+ process them and create a single HII resource script file.
+
+Arguments:
+
+ OutputFileName - name of output HII resource script file to create
+ PackageListGuid - the specified package list GUID
+ PackageFiles - linked list of HII package files to process
+
+Returns:
+
+ STATUS_SUCCESS - if successful
+ STATUS_ERROR - otherwise
+
+--*/
+{
+ STATUS Status;
+ UINT8 *PackageList;
+ UINT8 *Buffer;
+ UINT32 PackageListLen;
+ FILE *OutFptr;
+ UINTN Index;
+ FILE_NAME_LIST *Package;
+
+ //
+ // If no input HII pack files, then why are we here? Should have been caught when
+ // args were processed though.
+ //
+ if (PackageFiles == NULL) {
+ Error (NULL, 0, 0, "no input package file(s) specified", NULL);
+ return STATUS_ERROR;
+ }
+
+ OutFptr = NULL;
+ Status = STATUS_ERROR;
+
+ //
+ // Open the output file for writing
+ //
+ if ((OutFptr = fopen (OutputFileName, "w")) == NULL) {
+ Error (NULL, 0, 0, OutputFileName, "failed to open output file for writing");
+ goto Done;
+ }
+
+ //
+ // Write file header
+ //
+ for (Index = 0; gRcFileHeader[Index] != NULL; Index++) {
+ fprintf (OutFptr, "%s\n", gRcFileHeader[Index]);
+ }
+
+ //
+ // Write nameID and typeID
+ //
+ fprintf (OutFptr, "\n");
+ fprintf (OutFptr, "%d %s\n", HII_RESOURCE_NAME, HII_RESOURCE_TYPE);
+ fprintf (OutFptr, "{\n");
+
+ //
+ // Prepare package list
+ //
+ PackageListLen = sizeof (EFI_HII_PACKAGE_LIST_HEADER);
+ Package = PackageFiles;
+ while (Package != NULL) {
+ PackageListLen += Package->Length;
+ Package = Package->Next;
+ }
+ //
+ // Inlucde the length of EFI_HII_PACKAGE_END
+ //
+ PackageListLen += sizeof (EFI_HII_PACKAGE_HEADER);
+
+ Buffer = (UINT8 *) malloc (PackageListLen);
+ if (Buffer == NULL) {
+ Error (NULL, 0, 0, "memory allocation failure", NULL);
+ goto Done;
+ }
+ PackageList = Buffer;
+
+ memcpy (Buffer, PackageListGuid, sizeof (EFI_GUID));
+ Buffer += sizeof (EFI_GUID);
+ memcpy (Buffer, &PackageListLen, sizeof (UINT32));
+ Buffer += sizeof (UINT32);
+
+ Package = PackageFiles;
+ while (Package != NULL) {
+ memcpy (Buffer, Package->Data, Package->Length);
+ Buffer += Package->Length;
+ Package = Package->Next;
+ }
+ //
+ // Append EFI_HII_PACKAGE_END
+ //
+ ((EFI_HII_PACKAGE_HEADER *) Buffer)->Type = EFI_HII_PACKAGE_END;
+ ((EFI_HII_PACKAGE_HEADER *) Buffer)->Length = sizeof (EFI_HII_PACKAGE_HEADER);
+
+ //
+ // Dump package list
+ //
+ DumpRawBytes (OutFptr, PackageList, PackageListLen, 2);
+
+ //
+ // Write file tail
+ //
+ fprintf (OutFptr, "}\n");
+
+ Status = STATUS_SUCCESS;
+
+Done:
+ if (OutFptr != NULL) {
+ fclose (OutFptr);
+ }
+
+ return Status;
+}
+
+static
+STATUS
+CreatePackageList (
+ char *OutputFileName,
+ EFI_GUID *PackageListGuid,
+ FILE_NAME_LIST *PackageFiles
+ )
+/*++
+
+Routine Description:
+
+ Given a linked list of HII package files, walk the list to
+ process them and create a binary HII package list file.
+
+Arguments:
+
+ OutputFileName - name of output HII package list file to create
+ PackageListGuid - the specified package list GUID
+ PackageFiles - linked list of HII package files to process
+
+Returns:
+
+ STATUS_SUCCESS - if successful
+ STATUS_ERROR - otherwise
+
+--*/
+{
+ FILE *OutFptr;
+ UINT32 PackageListLen;
+ FILE_NAME_LIST *Package;
+
+ if (OutputFileName == NULL || PackageListGuid == NULL || PackageFiles == NULL) {
+ return STATUS_ERROR;
+ }
+
+ //
+ // Open the output file for writing
+ //
+ if ((OutFptr = fopen (OutputFileName, "wb")) == NULL) {
+ Error (NULL, 0, 0, OutputFileName, "failed to open output file for writing");
+ goto Done;
+ }
+
+ //
+ // Write package list header
+ //
+ PackageListLen = sizeof (EFI_HII_PACKAGE_LIST_HEADER);
+ Package = PackageFiles;
+ while (Package != NULL) {
+ PackageListLen += Package->Length;
+ Package = Package->Next;
+ }
+ fwrite (PackageListGuid, sizeof (UINT8), sizeof (EFI_GUID), OutFptr);
+ fwrite (&PackageListLen, sizeof (UINT8), sizeof (UINT32), OutFptr);
+
+ //
+ // Write packages
+ //
+ Package = PackageFiles;
+ while (Package != NULL) {
+ fwrite (Package->Data, sizeof (UINT8), Package->Length, OutFptr);
+ Package = Package->Next;
+ }
+
+Done:
+ if (OutFptr != NULL) {
+ fclose (OutFptr);
+ }
+
+ return STATUS_SUCCESS;
+}
+
+static
+void
+FreeGlobals (
+ VOID
+ )
+/*++
+
+Routine Description:
+
+ Free up an memory we allocated so we can exit cleanly
+
+Arguments:
+
+Returns: NA
+
+--*/
+{
+ FILE_NAME_LIST *Next;
+
+ //
+ // Free up input package file names
+ //
+ while (mGlobals.PackageFile != NULL) {
+ Next = mGlobals.PackageFile->Next;
+ if (mGlobals.PackageFile->Data != NULL) {
+ free (mGlobals.PackageFile->Data);
+ }
+ free (mGlobals.PackageFile);
+ mGlobals.PackageFile = Next;
+ }
+}
+
+static
+void
+DumpRawBytes (
+ FILE *OutFptr,
+ UINT8 *Buffer,
+ int Count,
+ int Indent
+ )
+/*++
+
+Routine Description:
+
+ Dump buffer data into output file.
+
+Arguments:
+
+ OutFptr - FILE pointer to output file.
+ Buffer - the buffer to dump
+ Count - number of bytes to dump
+ Indent - indent at each line start
+
+Returns:
+
+ Nothing.
+
+--*/
+{
+ int Counter;
+ int Count2;
+ UINT16 *Ptr16;
+
+ Ptr16 = (UINT16 *) Buffer;
+ Count2 = Count - (Count & 0x1);
+
+ for (Counter = 0; Counter < Count2; Counter += 2) {
+ if ((Counter & 0xF) == 0) {
+ if (Counter == 0) {
+ fprintf (OutFptr, "%*c", Indent, ' ');
+ } else {
+ fprintf (OutFptr, "\n%*c", Indent, ' ');
+ }
+ }
+
+ fprintf (OutFptr, "0x%04X, ", (unsigned int) *Ptr16);
+ Ptr16++;
+ }
+
+ //
+ // Handle the last byte
+ //
+ if ((Count & 0x1) != 0) {
+ if ((Counter & 0xF) == 0) {
+ if (Counter == 0) {
+ fprintf (OutFptr, "%*c", Indent, ' ');
+ } else {
+ fprintf (OutFptr, "\n%*c", Indent, ' ');
+ }
+ }
+
+ fprintf (OutFptr, "0x%04X, ", (unsigned int) (*Ptr16 & 0xff));
+ }
+
+ fprintf (OutFptr, "\n");
+}
+
+static
+STATUS
+LoadPackage (
+ FILE_NAME_LIST *NameList
+ )
+/*++
+
+Routine Description:
+
+ Process the command line arguments
+
+Arguments:
+
+ NameList - the FILE_NAME_LIST linked list node
+
+Returns:
+
+ STATUS_SUCCESS - if successful
+ STATUS_ERROR - otherwise
+
+--*/
+{
+ STATUS Status;
+ FILE *InFptr;
+ UINT32 BufferSize;
+ UINT8 *Buffer;
+ EFI_HII_PACKAGE_HEADER *PackageHeader;
+ EFI_IFR_FORM_SET *FormSet;
+
+ Status = STATUS_SUCCESS;
+ if (NameList == NULL) {
+ return STATUS_ERROR;
+ }
+
+ //
+ // Try to open the package file
+ //
+ if ((InFptr = fopen (NameList->FileName, "rb")) == NULL) {
+ Error (NULL, 0, 0, NameList->FileName, "failed to open input file for read");
+ return STATUS_ERROR;
+ }
+
+ //
+ // Get the file size, then allocate a buffer and read in the file contents.
+ //
+ fseek (InFptr, 0, SEEK_END);
+ BufferSize = (UINT32) ftell (InFptr);
+ fseek (InFptr, 0, SEEK_SET);
+ Buffer = (UINT8 *) malloc (BufferSize);
+ if (Buffer == NULL) {
+ Error (NULL, 0, 0, "memory allocation failure", NULL);
+ goto Done;
+ }
+
+ if (fread (Buffer, sizeof (UINT8), BufferSize, InFptr) != BufferSize) {
+ Error (NULL, 0, 0, NameList->FileName, "error reading file contents");
+ Status = STATUS_ERROR;
+ goto Done;
+ }
+
+ NameList->Length = BufferSize;
+ NameList->Data = Buffer;
+
+ PackageHeader = (EFI_HII_PACKAGE_HEADER *) Buffer;
+ NameList->PackageType = PackageHeader->Type;
+
+ if (!mGlobals.GuidSpecified && NameList->PackageType == EFI_HII_PACKAGE_FORMS) {
+ FormSet = (EFI_IFR_FORM_SET *) (Buffer + sizeof (EFI_HII_PACKAGE_HEADER));
+ memcpy (&mGlobals.Guid, &FormSet->Guid, sizeof (EFI_GUID));
+ mGlobals.GuidSpecified = TRUE;
+ }
+
+Done:
+ fclose (InFptr);
+
+ return Status;
+}
+
+
+static
+STATUS
+ProcessArgs (
+ int Argc,
+ char *Argv[]
+ )
+/*++
+
+Routine Description:
+
+ Process the command line arguments
+
+Arguments:
+
+ As per standard C main()
+
+Returns:
+
+ STATUS_SUCCESS - if successful
+ STATUS_ERROR - otherwise
+
+--*/
+{
+ FILE_NAME_LIST *NewList;
+ STATUS Status;
+
+ Status = STATUS_SUCCESS;
+ memset ((void *) &mGlobals, 0, sizeof (mGlobals));
+
+ //
+ // Skip program name
+ //
+ Argc--;
+ Argv++;
+
+ if (Argc == 0) {
+ Usage ();
+ return STATUS_ERROR;
+ }
+
+ if (_stricmp (Argv[0], "-h") == 0 || _stricmp (Argv[0], "-?") == 0) {
+ Usage ();
+ return STATUS_ERROR;
+ }
+
+ //
+ // Process until no more args.
+ //
+ while (Argc > 0) {
+ if (_stricmp (Argv[0], "-rc") == 0) {
+ Argc--;
+ Argv++;
+
+ if (Argc == 0) {
+ Error (UTILITY_NAME, 0, 0, "mising HII resource file name", NULL);
+ Status = STATUS_ERROR;
+ goto Done;
+ }
+
+ strcpy (mGlobals.ResourceFileName, Argv[0]);
+ mGlobals.Mode |= MODE_CREATE_HII_RESOURCE_FILE;
+
+ } else if (_stricmp (Argv[0], "-hii") == 0) {
+ Argc--;
+ Argv++;
+
+ if (Argc == 0) {
+ Error (UTILITY_NAME, 0, 0, "mising HII package list file name", NULL);
+ Status = STATUS_ERROR;
+ goto Done;
+ }
+
+ strcpy (mGlobals.PackageListFileName, Argv[0]);
+ mGlobals.Mode |= MODE_CREATE_HII_PACKAGE_LIST;
+
+ } else if (_stricmp (Argv[0], "-g") == 0) {
+ Argc--;
+ Argv++;
+
+ if (Argc == 0) {
+ Error (UTILITY_NAME, 0, 0, "mising package list GUID", NULL);
+ Status = STATUS_ERROR;
+ goto Done;
+ }
+
+ Status = StringToGuid (Argv[0], &mGlobals.Guid);
+ if (Status != STATUS_SUCCESS) {
+ goto Done;
+ }
+ mGlobals.GuidSpecified = TRUE;
+
+ } else {
+ //
+ // This is a package file
+ //
+ NewList = malloc (sizeof (FILE_NAME_LIST));
+ if (NewList == NULL) {
+ Error (UTILITY_NAME, 0, 0, "memory allocation failure", NULL);
+ Status = STATUS_ERROR;
+ goto Done;
+ }
+
+ memset (NewList, 0, sizeof (FILE_NAME_LIST));
+ strcpy (NewList->FileName, Argv[0]);
+
+ if (mGlobals.PackageFile == NULL) {
+ mGlobals.PackageFile = NewList;
+ } else {
+ mGlobals.LastPackageFile->Next = NewList;
+ }
+ mGlobals.LastPackageFile = NewList;
+
+ Status = LoadPackage (NewList);
+ if (Status != STATUS_SUCCESS) {
+ goto Done;
+ }
+ }
+
+ Argc--;
+ Argv++;
+ }
+
+ if (!mGlobals.GuidSpecified) {
+ Error (UTILITY_NAME, 0, 0, "please specify HII pakcage list GUID", NULL);
+ Status = STATUS_ERROR;
+ }
+
+Done:
+ if (Status != STATUS_SUCCESS) {
+ FreeGlobals ();
+ }
+
+ return Status;
+}
+
+static
+void
+Usage (
+ VOID
+ )
+/*++
+
+Routine Description:
+
+ Print usage information for this utility.
+
+Arguments:
+
+ None.
+
+Returns:
+
+ Nothing.
+
+--*/
+{
+ int i;
+ const char *Str[] = {
+ UTILITY_NAME" "UTILITY_VERSION" - UEFI HII Package List Utility",
+ " Copyright (C), 2008 Intel Corporation",
+
+#if ( defined(UTILITY_BUILD) && defined(UTILITY_VENDOR) )
+ " Built from "UTILITY_BUILD", project of "UTILITY_VENDOR,
+#endif
+ "",
+ "Usage:",
+ " "UTILITY_NAME" [OPTION] PACKAGE [PACKAGE [...]]",
+ "Description:",
+ " Merge HII package files into a single HII Package List.",
+ "Options:",
+ " -rc FileName write output to PE/COFF Resource Script file",
+ " -hii FileName write output to binary Package List file",
+ " -g GUID use GUID for the HII Package List Guid",
+ "",
+ "PACKAGE is the raw binary HII package file generated by StrGather or",
+ "VfrCompiler which named as *.hpk. For example, merge a Form package and",
+ "a String package into one HII package list:",
+ " \""UTILITY_NAME" -rc Sample.rc -hii Sample.hii \\",
+ " -g 12345678-1234-1234-1234-123456789abc Vfr.hpk Strings.hpk\"",
+ NULL
+ };
+ for (i = 0; Str[i] != NULL; i++) {
+ fprintf (stdout, "%s\n", Str[i]);
+ }
+}
diff --git a/EdkCompatibilityPkg/Sample/Tools/Source/UefiHiiPack/Makefile b/EdkCompatibilityPkg/Sample/Tools/Source/UefiHiiPack/Makefile
new file mode 100644
index 0000000000..ac12d760e8
--- /dev/null
+++ b/EdkCompatibilityPkg/Sample/Tools/Source/UefiHiiPack/Makefile
@@ -0,0 +1,71 @@
+#/*++
+#
+# 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
+# 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:
+#
+# Makefile
+#
+# Abstract:
+#
+# Makefile for building the UEFI HiiPack utility
+#
+#--*/
+
+#
+# Make sure environmental variable EDK_SOURCE is set
+#
+!IFNDEF EDK_SOURCE
+!ERROR EDK_SOURCE environmental variable not set
+!ENDIF
+
+!INCLUDE $(BUILD_DIR)\PlatformTools.env
+
+#
+# Target specific information
+#
+TARGET_NAME = HiiPack
+TARGET_SOURCE_DIR = $(EDK_TOOLS_SOURCE)\Uefi$(TARGET_NAME)
+TARGET_EXE = $(EDK_TOOLS_OUTPUT)\$(TARGET_NAME).exe
+
+OBJECTS = $(EDK_TOOLS_OUTPUT)\HiiPack.obj
+LIBS = $(LIBS) $(EDK_TOOLS_OUTPUT)\Common.lib
+
+#
+# Build targets
+#
+
+all: $(TARGET_EXE)
+
+#
+# Compile each tool source file
+#
+$(EDK_TOOLS_OUTPUT)\HiiPack.obj : $(TARGET_SOURCE_DIR)\HiiPack.c
+ $(CC) $(C_FLAGS) $(TARGET_SOURCE_DIR)\HiiPack.c /Fo$@
+
+#
+# Add Binary Build description for this tool.
+#
+
+!IF (("$(EFI_BINARY_TOOLS)" == "YES") && EXIST($(EFI_PLATFORM_BIN)\Tools\$(TARGET_NAME).exe))
+$(TARGET_EXE): $(EFI_PLATFORM_BIN)\Tools\$(TARGET_NAME).exe
+ copy $(EFI_PLATFORM_BIN)\Tools\$(TARGET_NAME).exe $(TARGET_EXE) /Y
+ if exist $(EFI_PLATFORM_BIN)\Tools\$(TARGET_NAME).pdb \
+ copy $(EFI_PLATFORM_BIN)\Tools\$(TARGET_NAME).pdb $(EDK_TOOLS_OUTPUT)\$(TARGET_NAME).pdb /Y
+!ELSE
+$(TARGET_EXE) : $(OBJECTS) $(LIBS)
+ $(LINK) $(MSVS_LINK_LIBPATHS) $(L_FLAGS) $(LIBS) /out:$(TARGET_EXE) $(OBJECTS)
+!IF ("$(EFI_BINARY_BUILD)" == "YES")
+ if not exist $(EFI_PLATFORM_BIN)\Tools mkdir $(EFI_PLATFORM_BIN)\Tools
+ if exist $(TARGET_EXE) copy $(TARGET_EXE) $(EFI_PLATFORM_BIN)\tools\$(TARGET_NAME).exe /Y
+ if exist $(EDK_TOOLS_OUTPUT)\$(TARGET_NAME).pdb \
+ copy $(EDK_TOOLS_OUTPUT)\$(TARGET_NAME).pdb $(EFI_PLATFORM_BIN)\Tools\$(TARGET_NAME).pdb /Y
+!ENDIF
+!ENDIF
diff --git a/EdkCompatibilityPkg/Sample/Tools/Source/UefiStrGather/StrGather.c b/EdkCompatibilityPkg/Sample/Tools/Source/UefiStrGather/StrGather.c
index dd5bdb45ed..535a265046 100644
--- a/EdkCompatibilityPkg/Sample/Tools/Source/UefiStrGather/StrGather.c
+++ b/EdkCompatibilityPkg/Sample/Tools/Source/UefiStrGather/StrGather.c
@@ -1,6 +1,6 @@
/*++
-Copyright (c) 2004 - 2007, 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
@@ -11,7 +11,7 @@ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
Module Name:
- StrGather.c
+ StrGather.c
Abstract:
@@ -29,7 +29,8 @@ Abstract:
#include "StrGather.h"
#include "StringDB.h"
-#define TOOL_VERSION "0.31"
+#define UTILITY_NAME "StrGather"
+#define UTILITY_VERSION "v1.2"
typedef UINT16 WCHAR;
@@ -48,6 +49,15 @@ typedef UINT16 WCHAR;
#define MODE_DUMP 3
//
+// This is how we invoke the C preprocessor on the source file
+// to resolve #if, #else, etc.
+//
+#define PREPROCESSOR_COMMAND "cl"
+#define PREPROCESSOR_OPTIONS "/nologo /EP /TC /DSTRGATHER"
+#define PREPROCESS_TEMP_FILE_EXTENSION ".ii"
+#define PREPROCESS_OUTPUT_FILE_EXTENSION ".iii"
+
+//
// We keep a linked list of these for the source files we process
//
typedef struct _SOURCE_FILE {
@@ -83,6 +93,8 @@ static struct {
TEXT_STRING_LIST *LastIndirectionFileName;
TEXT_STRING_LIST *DatabaseFileName;
TEXT_STRING_LIST *LastDatabaseFileName;
+ TEXT_STRING_LIST *PreprocessFlags;
+ TEXT_STRING_LIST *LastPreprocessFlags;
WCHAR_STRING_LIST *Language;
WCHAR_STRING_LIST *LastLanguage;
WCHAR_MATCHING_STRING_LIST *IndirectionList; // from indirection file(s)
@@ -94,6 +106,8 @@ static struct {
BOOLEAN IgnoreNotFound; // when scanning
BOOLEAN VerboseScan;
BOOLEAN UnquotedStrings; // -uqs option
+ BOOLEAN Preprocess; // -ppflag option
+ INT8 PreprocessFileName[MAX_PATH];
INT8 OutputDatabaseFileName[MAX_PATH];
INT8 StringHFileName[MAX_PATH];
INT8 StringCFileName[MAX_PATH]; // output .C filename
@@ -294,11 +308,6 @@ ParseIndirectionFiles (
TEXT_STRING_LIST *Files
);
-STATUS
-StringDBCreateHiiExportPack (
- INT8 *OutputFileName
- );
-
int
main (
int Argc,
@@ -309,7 +318,7 @@ main (
Routine Description:
Call the routine to parse the command-line options, then process the file.
-
+
Arguments:
Argc - Standard C main() argc and argv.
@@ -319,12 +328,12 @@ Returns:
0 if successful
nonzero otherwise
-
+
--*/
{
STATUS Status;
- SetUtilityName (PROGRAM_NAME);
+ SetUtilityName (UTILITY_NAME);
//
// Process the command-line arguments
//
@@ -374,12 +383,12 @@ Returns:
if ((mGlobals.OutputDependencyFptr = fopen (mGlobals.OutputDependencyFileName, "w")) == NULL) {
Error (NULL, 0, 0, mGlobals.OutputDependencyFileName, "failed to open output dependency file");
goto Finish;
- }
+ }
}
Status = ProcessIncludeFile (&mGlobals.SourceFiles, NULL);
if (mGlobals.OutputDependencyFptr != NULL) {
fclose (mGlobals.OutputDependencyFptr);
- }
+ }
if (Status != STATUS_SUCCESS) {
goto Finish;
}
@@ -401,7 +410,8 @@ Returns:
if ((mGlobals.StringCFileName[0] != 0) && (GetUtilityStatus () < STATUS_ERROR)) {
Status = StringDBDumpCStrings (
mGlobals.BaseName,
- mGlobals.StringCFileName
+ mGlobals.StringCFileName,
+ mGlobals.Language
);
if (Status != EFI_SUCCESS) {
goto Finish;
@@ -418,7 +428,7 @@ Returns:
// Dump the string data as HII binary string pack if requested
//
if ((mGlobals.HiiExportPackFileName[0] != 0) && (GetUtilityStatus () < STATUS_ERROR)) {
- StringDBCreateHiiExportPack (mGlobals.HiiExportPackFileName);
+ StringDBCreateHiiExportPack (mGlobals.HiiExportPackFileName, mGlobals.Language);
}
//
// Always update the database if no errors and not in dump mode. If they specified -od
@@ -457,7 +467,7 @@ ProcessIncludeFile (
Routine Description:
Given a source file, open the file and parse it
-
+
Arguments:
SourceFile - name of file to parse
@@ -466,7 +476,7 @@ Arguments:
Returns:
Standard status.
-
+
--*/
{
static UINT32 NestDepth = 0;
@@ -513,18 +523,18 @@ Returns:
goto Finish;
}
}
-
+
//
- // Output the dependency
+ // Output the dependency
//
if (mGlobals.OutputDependencyFptr != NULL) {
- fprintf (mGlobals.OutputDependencyFptr, "%s : %s\n", mGlobals.DatabaseFileName->Str, FoundFileName);
+ fprintf (mGlobals.OutputDependencyFptr, "%s : %s\n", mGlobals.DatabaseFileName->Str, FoundFileName);
//
// Add pseudo target to avoid incremental build failure when the file is deleted
//
- fprintf (mGlobals.OutputDependencyFptr, "%s : \n", FoundFileName);
+ fprintf (mGlobals.OutputDependencyFptr, "%s : \n", FoundFileName);
}
-
+
//
// Process the file found
//
@@ -695,13 +705,13 @@ PreprocessFile (
Routine Description:
Preprocess a file to replace all carriage returns with NULLs so
we can print lines from the file to the screen.
-
+
Arguments:
SourceFile - structure that we use to keep track of an input file.
Returns:
Nothing.
-
+
--*/
{
BOOLEAN InComment;
@@ -1736,7 +1746,7 @@ FindFile (
// Put the path and filename together
//
if (strlen (List->Str) + strlen (FileName) + 1 > FoundFileNameLen) {
- Error (PROGRAM_NAME, 0, 0, NULL, "internal error - cannot concatenate path+filename");
+ Error (UTILITY_NAME, 0, 0, NULL, "internal error - cannot concatenate path+filename");
return NULL;
}
//
@@ -1770,6 +1780,9 @@ ProcessArgs (
)
{
TEXT_STRING_LIST *NewList;
+ char *Cptr;
+ char *Cptr2;
+
//
// Clear our globals
//
@@ -1836,7 +1849,7 @@ ProcessArgs (
// check for one more arg
//
if ((Argc <= 1) || (Argv[1][0] == '-')) {
- Error (PROGRAM_NAME, 0, 0, Argv[0], "missing include path");
+ Error (UTILITY_NAME, 0, 0, Argv[0], "missing include path");
return STATUS_ERROR;
}
//
@@ -1846,7 +1859,7 @@ ProcessArgs (
//
NewList = malloc (sizeof (TEXT_STRING_LIST));
if (NewList == NULL) {
- Error (PROGRAM_NAME, 0, 0, NULL, "memory allocation failure");
+ Error (UTILITY_NAME, 0, 0, NULL, "memory allocation failure");
return STATUS_ERROR;
}
@@ -1854,7 +1867,7 @@ ProcessArgs (
NewList->Str = malloc (strlen (Argv[1]) + 2);
if (NewList->Str == NULL) {
free (NewList);
- Error (PROGRAM_NAME, 0, 0, NULL, "memory allocation failure");
+ Error (UTILITY_NAME, 0, 0, NULL, "memory allocation failure");
return STATUS_ERROR;
}
@@ -1879,7 +1892,7 @@ ProcessArgs (
// Indirection file -- check for one more arg
//
if ((Argc <= 1) || (Argv[1][0] == '-')) {
- Error (PROGRAM_NAME, 0, 0, Argv[0], "missing indirection file name");
+ Error (UTILITY_NAME, 0, 0, Argv[0], "missing indirection file name");
return STATUS_ERROR;
}
//
@@ -1889,7 +1902,7 @@ ProcessArgs (
//
NewList = malloc (sizeof (TEXT_STRING_LIST));
if (NewList == NULL) {
- Error (PROGRAM_NAME, 0, 0, NULL, "memory allocation failure");
+ Error (UTILITY_NAME, 0, 0, NULL, "memory allocation failure");
return STATUS_ERROR;
}
@@ -1897,7 +1910,7 @@ ProcessArgs (
NewList->Str = malloc (strlen (Argv[1]) + 1);
if (NewList->Str == NULL) {
free (NewList);
- Error (PROGRAM_NAME, 0, 0, NULL, "memory allocation failure");
+ Error (UTILITY_NAME, 0, 0, NULL, "memory allocation failure");
return STATUS_ERROR;
}
@@ -1920,13 +1933,13 @@ ProcessArgs (
// Check for one more arg (the database file name)
//
if ((Argc <= 1) || (Argv[1][0] == '-')) {
- Error (PROGRAM_NAME, 0, 0, Argv[0], "missing database file name");
+ Error (UTILITY_NAME, 0, 0, Argv[0], "missing database file name");
return STATUS_ERROR;
}
NewList = malloc (sizeof (TEXT_STRING_LIST));
if (NewList == NULL) {
- Error (PROGRAM_NAME, 0, 0, NULL, "memory allocation failure");
+ Error (UTILITY_NAME, 0, 0, NULL, "memory allocation failure");
return STATUS_ERROR;
}
@@ -1934,7 +1947,7 @@ ProcessArgs (
NewList->Str = malloc (strlen (Argv[1]) + 1);
if (NewList->Str == NULL) {
free (NewList);
- Error (PROGRAM_NAME, 0, 0, NULL, "memory allocation failure");
+ Error (UTILITY_NAME, 0, 0, NULL, "memory allocation failure");
return STATUS_ERROR;
}
@@ -1957,14 +1970,14 @@ ProcessArgs (
// which we can dump our database.
//
if ((Argc <= 1) || (Argv[1][0] == '-')) {
- Error (PROGRAM_NAME, 0, 0, Argv[0], "missing database dump output file name");
+ Error (UTILITY_NAME, 0, 0, Argv[0], "missing database dump output file name");
return STATUS_ERROR;
}
if (mGlobals.DumpUFileName[0] == 0) {
strcpy (mGlobals.DumpUFileName, Argv[1]);
} else {
- Error (PROGRAM_NAME, 0, 0, Argv[1], "-ou option already specified with '%s'", mGlobals.DumpUFileName);
+ Error (UTILITY_NAME, 0, 0, Argv[1], "-ou option already specified with '%s'", mGlobals.DumpUFileName);
return STATUS_ERROR;
}
@@ -1975,14 +1988,14 @@ ProcessArgs (
// -hpk option to create an HII export pack of the input database file
//
if ((Argc <= 1) || (Argv[1][0] == '-')) {
- Error (PROGRAM_NAME, 0, 0, Argv[0], "missing raw string data dump output file name");
+ Error (UTILITY_NAME, 0, 0, Argv[0], "missing raw string data dump output file name");
return STATUS_ERROR;
}
if (mGlobals.HiiExportPackFileName[0] == 0) {
strcpy (mGlobals.HiiExportPackFileName, Argv[1]);
} else {
- Error (PROGRAM_NAME, 0, 0, Argv[1], "-or option already specified with '%s'", mGlobals.HiiExportPackFileName);
+ Error (UTILITY_NAME, 0, 0, Argv[1], "-or option already specified with '%s'", mGlobals.HiiExportPackFileName);
return STATUS_ERROR;
}
@@ -2006,7 +2019,7 @@ ProcessArgs (
// check for one more arg
//
if ((Argc <= 1) || (Argv[1][0] == '-')) {
- Error (PROGRAM_NAME, 0, 0, Argv[0], "missing output C filename");
+ Error (UTILITY_NAME, 0, 0, Argv[0], "missing output C filename");
return STATUS_ERROR;
}
@@ -2018,7 +2031,7 @@ ProcessArgs (
// check for one more arg
//
if ((Argc <= 1) || (Argv[1][0] == '-')) {
- Error (PROGRAM_NAME, 0, 0, Argv[0], "missing base name");
+ Error (UTILITY_NAME, 0, 0, Argv[0], "missing base name");
Usage ();
return STATUS_ERROR;
}
@@ -2031,7 +2044,7 @@ ProcessArgs (
// -oh to specify output .h defines file name
//
if ((Argc <= 1) || (Argv[1][0] == '-')) {
- Error (PROGRAM_NAME, 0, 0, Argv[0], "missing output .h filename");
+ Error (UTILITY_NAME, 0, 0, Argv[0], "missing output .h filename");
return STATUS_ERROR;
}
@@ -2043,7 +2056,7 @@ ProcessArgs (
// -dep to specify output dependency file name
//
if ((Argc <= 1) || (Argv[1][0] == '-')) {
- Error (PROGRAM_NAME, 0, 0, Argv[0], "missing output dependency filename");
+ Error (UTILITY_NAME, 0, 0, Argv[0], "missing output dependency filename");
return STATUS_ERROR;
}
@@ -2055,7 +2068,7 @@ ProcessArgs (
// -skipext to skip scanning of files with certain filename extensions
//
if ((Argc <= 1) || (Argv[1][0] == '-')) {
- Error (PROGRAM_NAME, 0, 0, Argv[0], "missing filename extension");
+ Error (UTILITY_NAME, 0, 0, Argv[0], "missing filename extension");
return STATUS_ERROR;
}
//
@@ -2065,7 +2078,7 @@ ProcessArgs (
//
NewList = malloc (sizeof (TEXT_STRING_LIST));
if (NewList == NULL) {
- Error (PROGRAM_NAME, 0, 0, NULL, "memory allocation failure");
+ Error (UTILITY_NAME, 0, 0, NULL, "memory allocation failure");
return STATUS_ERROR;
}
@@ -2073,7 +2086,7 @@ ProcessArgs (
NewList->Str = malloc (strlen (Argv[1]) + 2);
if (NewList->Str == NULL) {
free (NewList);
- Error (PROGRAM_NAME, 0, 0, NULL, "memory allocation failure");
+ Error (UTILITY_NAME, 0, 0, NULL, "memory allocation failure");
return STATUS_ERROR;
}
@@ -2097,10 +2110,10 @@ ProcessArgs (
Argv++;
} else if (_stricmp (Argv[0], "-lang") == 0) {
//
- // "-lang eng" or "-lang spa+cat" to only output certain languages
+ // "-lang zh-Hans" or "-lang en-US" to only output certain languages
//
if ((Argc <= 1) || (Argv[1][0] == '-')) {
- Error (PROGRAM_NAME, 0, 0, Argv[0], "missing language name");
+ Error (UTILITY_NAME, 0, 0, Argv[0], "missing language name");
Usage ();
return STATUS_ERROR;
}
@@ -2116,18 +2129,78 @@ ProcessArgs (
// Output database file name -- check for another arg
//
if ((Argc <= 1) || (Argv[1][0] == '-')) {
- Error (PROGRAM_NAME, 0, 0, Argv[0], "missing output database file name");
+ Error (UTILITY_NAME, 0, 0, Argv[0], "missing output database file name");
return STATUS_ERROR;
}
strcpy (mGlobals.OutputDatabaseFileName, Argv[1]);
Argv++;
Argc--;
+ } else if (_stricmp (Argv[0], "-ppflag") == 0) {
+ //
+ // -ppflag "Preprocess flags" -- check for another arg
+ //
+ if ((Argc <= 1) || (Argv[1][0] == '-')) {
+ Error (UTILITY_NAME, 0, 0, Argv[0], "missing preprocess flags");
+ Usage ();
+ return STATUS_ERROR;
+ }
+
+ //
+ // Allocate memory for a new list element, fill it in, and
+ // add it to our list of preprocess flag.
+ //
+ NewList = malloc (sizeof (TEXT_STRING_LIST));
+ if (NewList == NULL) {
+ Error (UTILITY_NAME, 0, 0, NULL, "memory allocation failure");
+ return STATUS_ERROR;
+ }
+
+ memset ((char *) NewList, 0, sizeof (TEXT_STRING_LIST));
+ NewList->Str = malloc (strlen (Argv[1]) * 2 + 1);
+ if (NewList->Str == NULL) {
+ free (NewList);
+ Error (UTILITY_NAME, 0, 0, NULL, "memory allocation failure");
+ return STATUS_ERROR;
+ }
+
+ //
+ // Convert '"' to '\"' in preprocess flag
+ //
+ Cptr = Argv[1];
+ Cptr2 = NewList->Str;
+ if (*Cptr == '"') {
+ *Cptr2++ = '\\';
+ *Cptr2++ = '"';
+ Cptr++;
+ }
+ while (*Cptr != '\0') {
+ if ((*Cptr == '"') && (*(Cptr - 1) != '\\')) {
+ *Cptr2++ = '\\';
+ }
+ *Cptr2++ = *Cptr++;
+ }
+ *Cptr2 = '\0';
+
+ //
+ // Add it to our linked list
+ //
+ if (mGlobals.PreprocessFlags == NULL) {
+ mGlobals.PreprocessFlags = NewList;
+ } else {
+ mGlobals.LastPreprocessFlags->Next = NewList;
+ }
+ mGlobals.LastPreprocessFlags = NewList;
+
+ mGlobals.Preprocess = TRUE;
+
+ Argv++;
+ Argc--;
} else {
//
// Unrecognized arg
//
- Error (PROGRAM_NAME, 0, 0, Argv[0], "unrecognized option");
+ Error (UTILITY_NAME, 0, 0, Argv[0], "unrecognized option");
Usage ();
return STATUS_ERROR;
}
@@ -2174,7 +2247,15 @@ ProcessArgs (
//
if (mGlobals.Mode == MODE_SCAN) {
if (Argc < 1) {
- Error (PROGRAM_NAME, 0, 0, NULL, "must specify at least one source file to scan with -scan");
+ Error (UTILITY_NAME, 0, 0, NULL, "must specify at least one source file to scan with -scan");
+ Usage ();
+ return STATUS_ERROR;
+ }
+ //
+ // If -ppflag is specified, -oh should also be specified for preprocess
+ //
+ if (mGlobals.Preprocess && (mGlobals.StringHFileName[0] == 0)) {
+ Error (UTILITY_NAME, 0, 0, NULL, "must specify string defines file name to preprocess before scan");
Usage ();
return STATUS_ERROR;
}
@@ -2184,14 +2265,14 @@ ProcessArgs (
while (Argc > 0) {
NewList = malloc (sizeof (TEXT_STRING_LIST));
if (NewList == NULL) {
- Error (PROGRAM_NAME, 0, 0, "memory allocation failure", NULL);
+ Error (UTILITY_NAME, 0, 0, "memory allocation failure", NULL);
return STATUS_ERROR;
}
memset (NewList, 0, sizeof (TEXT_STRING_LIST));
NewList->Str = (UINT8 *) malloc (strlen (Argv[0]) + 1);
if (NewList->Str == NULL) {
- Error (PROGRAM_NAME, 0, 0, "memory allocation failure", NULL);
+ Error (UTILITY_NAME, 0, 0, "memory allocation failure", NULL);
return STATUS_ERROR;
}
@@ -2211,7 +2292,7 @@ ProcessArgs (
// Parse mode -- must specify an input unicode file name
//
if (Argc < 1) {
- Error (PROGRAM_NAME, 0, 0, NULL, "must specify input unicode string file name with -parse");
+ Error (UTILITY_NAME, 0, 0, NULL, "must specify input unicode string file name with -parse");
Usage ();
return STATUS_ERROR;
}
@@ -2222,7 +2303,7 @@ ProcessArgs (
return STATUS_SUCCESS;
}
//
-// Found "-lang eng,spa+cat" on the command line. Parse the
+// Found "-lang zh-Hans;en-US" on the command line. Parse the
// language list and save the setting for later processing.
//
static
@@ -2231,69 +2312,33 @@ AddCommandLineLanguage (
IN INT8 *Language
)
{
+ char Separator[] = ";";
+ char *Token;
WCHAR_STRING_LIST *WNewList;
- WCHAR *From;
- WCHAR *To;
+
//
// Keep processing the input string until we find the end.
//
- while (*Language) {
- //
- // Allocate memory for a new list element, fill it in, and
- // add it to our list.
- //
+ Token = strtok (Language, Separator);
+ while (Token != NULL) {
WNewList = MALLOC (sizeof (WCHAR_STRING_LIST));
if (WNewList == NULL) {
- Error (PROGRAM_NAME, 0, 0, NULL, "memory allocation failure");
+ Error (UTILITY_NAME, 0, 0, NULL, "memory allocation failure");
return STATUS_ERROR;
}
-
- memset ((char *) WNewList, 0, sizeof (WCHAR_STRING_LIST));
- WNewList->Str = malloc ((strlen (Language) + 1) * sizeof (WCHAR));
+ WNewList->Next = NULL;
+ WNewList->Str = MALLOC ((strlen (Token) + 1) * sizeof (WCHAR));
if (WNewList->Str == NULL) {
free (WNewList);
- Error (PROGRAM_NAME, 0, 0, NULL, "memory allocation failure");
+ Error (UTILITY_NAME, 0, 0, NULL, "memory allocation failure");
return STATUS_ERROR;
}
- //
- // Copy it as unicode to our new structure. Then remove the
- // plus signs in it, and verify each language name is 3 characters
- // long. If we find a comma, then we're done with this group, so
- // break out.
- //
#ifdef USE_VC8
- swprintf (WNewList->Str, (strlen (Language) + 1) * sizeof (WCHAR), L"%S", Language);
+ swprintf (WNewList->Str, (strlen (Token) + 1) * sizeof (WCHAR), L"%S", Token);
#else
- swprintf (WNewList->Str, L"%S", Language);
+ swprintf (WNewList->Str, L"%S", Token);
#endif
- From = To = WNewList->Str;
- while (*From) {
- if (*From == L',') {
- break;
- }
- if ((wcslen (From) < LANGUAGE_IDENTIFIER_NAME_LEN) ||
- (
- (From[LANGUAGE_IDENTIFIER_NAME_LEN] != 0) &&
- (From[LANGUAGE_IDENTIFIER_NAME_LEN] != UNICODE_PLUS_SIGN) &&
- (From[LANGUAGE_IDENTIFIER_NAME_LEN] != L',')
- )
- ) {
- Error (PROGRAM_NAME, 0, 0, Language, "invalid format for language name on command line");
- FREE (WNewList->Str);
- FREE (WNewList);
- return STATUS_ERROR;
- }
-
- wcsncpy (To, From, LANGUAGE_IDENTIFIER_NAME_LEN);
- To += LANGUAGE_IDENTIFIER_NAME_LEN;
- From += LANGUAGE_IDENTIFIER_NAME_LEN;
- if (*From == L'+') {
- From++;
- }
- }
-
- *To = 0;
//
// Add it to our linked list
//
@@ -2304,17 +2349,7 @@ AddCommandLineLanguage (
}
mGlobals.LastLanguage = WNewList;
- //
- // Skip to next entry (comma-separated list)
- //
- while (*Language) {
- if (*Language == L',') {
- Language++;
- break;
- }
-
- Language++;
- }
+ Token = strtok (NULL, Separator);
}
return STATUS_SUCCESS;
@@ -2450,6 +2485,166 @@ Done:
}
static
+INTN
+PreprocessSourceFile (
+ UINT8 *SourceFileName
+ )
+{
+ char *Cptr;
+ FILE *InFptr;
+ FILE *OutFptr;
+ UINT32 CmdLen;
+ char *PreProcessCmd;
+ char BaseName[MAX_PATH];
+ char TempFileName[MAX_PATH];
+ char SourceFileDir[MAX_PATH];
+ char Line[MAX_LINE_LEN];
+ TEXT_STRING_LIST *List;
+ char InsertLine[] = "#undef STRING_TOKEN\n";
+ int Status;
+
+ //
+ // Check whehter source file exist
+ //
+ InFptr = fopen (SourceFileName, "r");
+ if (InFptr == NULL) {
+ Error (NULL, 0, 0, SourceFileName, "failed to open input file for scanning");
+ return STATUS_ERROR;
+ }
+
+ //
+ // Get source file directory
+ //
+ strcpy (SourceFileDir, SourceFileName);
+ Cptr = strrchr (SourceFileDir, '\\');
+ if (Cptr != NULL) {
+ *Cptr = '\0';
+ }
+
+ //
+ // Generate preprocess output file name
+ //
+ strcpy (BaseName, mGlobals.OutputDatabaseFileName);
+ Cptr = strrchr (BaseName, '\\');
+ if (Cptr != NULL) {
+ *++Cptr = '\0';
+ }
+
+ Cptr = strrchr (SourceFileName, '\\');
+ if (Cptr != NULL) {
+ Cptr++;
+ }
+ strcat (BaseName, Cptr);
+
+ Cptr = strrchr (BaseName, '.');
+ if (Cptr != NULL) {
+ *Cptr = '\0';
+ }
+
+ strcpy (mGlobals.PreprocessFileName, BaseName);
+ strcat (mGlobals.PreprocessFileName, PREPROCESS_OUTPUT_FILE_EXTENSION);
+
+ strcpy (TempFileName, BaseName);
+ strcat (TempFileName, PREPROCESS_TEMP_FILE_EXTENSION);
+
+ //
+ // Insert "#undef STRING_TOKEN" after each line of "#include ...", so as to
+ // preserve the STRING_TOKEN() for scanning after preprocess
+ //
+ OutFptr = fopen (TempFileName, "w");
+ if (OutFptr == NULL) {
+ Error (NULL, 0, 0, TempFileName, "failed to open file for write");
+ fclose (InFptr);
+ return STATUS_ERROR;
+ }
+ while (fgets (Line, MAX_LINE_LEN, InFptr) != NULL) {
+ fputs (Line, OutFptr);
+ Cptr = Line;
+
+ //
+ // Skip leading blank space
+ //
+ while (*Cptr == ' ' || *Cptr == '\t') {
+ Cptr++;
+ }
+
+ if (*Cptr == '#' && strncmp (Cptr + 1, "include", 7) == 0){
+ fputs (InsertLine, OutFptr);
+ }
+ }
+ fclose (InFptr);
+ fclose (OutFptr);
+
+ //
+ // Prepare preprocess command
+ //
+ CmdLen = 1;
+ CmdLen += strlen (PREPROCESSOR_COMMAND);
+ CmdLen++;
+ CmdLen += strlen (PREPROCESSOR_OPTIONS);
+ CmdLen++;
+
+ //
+ // "-I SourceFileDir "
+ //
+ CmdLen += strlen (SourceFileDir);
+ CmdLen += 4;
+
+ List = mGlobals.PreprocessFlags;
+ while (List != NULL) {
+ CmdLen += strlen (List->Str);
+ CmdLen++;
+
+ List = List->Next;
+ }
+
+ CmdLen += strlen (TempFileName);
+ CmdLen += 3;
+ CmdLen += strlen (mGlobals.PreprocessFileName);
+
+ PreProcessCmd = malloc (CmdLen);
+ if (PreProcessCmd == NULL) {
+ Error (NULL, 0, 0, UTILITY_NAME, "memory allocation fail (%d bytes)\n", CmdLen);
+ return STATUS_ERROR;
+ }
+
+ strcpy (PreProcessCmd, PREPROCESSOR_COMMAND);
+ strcat (PreProcessCmd, " ");
+ strcat (PreProcessCmd, PREPROCESSOR_OPTIONS);
+ strcat (PreProcessCmd, " ");
+
+
+ strcat (PreProcessCmd, "-I ");
+ strcat (PreProcessCmd, SourceFileDir);
+ strcat (PreProcessCmd, " ");
+
+ List = mGlobals.PreprocessFlags;
+ while (List != NULL) {
+ strcat (PreProcessCmd, List->Str);
+ strcat (PreProcessCmd, " ");
+
+ List = List->Next;
+ }
+
+ strcat (PreProcessCmd, TempFileName);
+ strcat (PreProcessCmd, " > ");
+ strcat (PreProcessCmd, mGlobals.PreprocessFileName);
+
+ //
+ // Preprocess the source file
+ //
+ Status = system (PreProcessCmd);
+ if (Status != 0) {
+ Error (NULL, 0, 0, PreProcessCmd, "failed to spawn C preprocessor on source file\n");
+ free (PreProcessCmd);
+ return STATUS_ERROR;
+ }
+
+ free (PreProcessCmd);
+ return STATUS_SUCCESS;
+}
+
+static
STATUS
ScanFiles (
TEXT_STRING_LIST *ScanFiles
@@ -2457,6 +2652,7 @@ ScanFiles (
{
char Line[MAX_LINE_LEN];
FILE *Fptr;
+ char *FileName;
UINT32 LineNum;
char *Cptr;
char *SavePtr;
@@ -2464,6 +2660,7 @@ ScanFiles (
char *StringTokenPos;
TEXT_STRING_LIST *SList;
BOOLEAN SkipIt;
+ BOOLEAN FileExist;
//
// Put a null-terminator at the end of the line. If we read in
@@ -2474,6 +2671,7 @@ ScanFiles (
// Process each file. If they gave us a skip extension list, then
// skip it if the extension matches.
//
+ FileExist = FALSE;
while (ScanFiles != NULL) {
SkipIt = FALSE;
for (SList = mGlobals.SkipExt; SList != NULL; SList = SList->Next) {
@@ -2493,9 +2691,36 @@ ScanFiles (
printf ("Scanning %s\n", ScanFiles->Str);
}
- Fptr = fopen (ScanFiles->Str, "r");
+ if (mGlobals.Preprocess) {
+ //
+ // Create an empty string defines file for preprocessor
+ //
+ if (!FileExist) {
+ Fptr = fopen (mGlobals.StringHFileName, "w");
+ if (Fptr == NULL) {
+ Error (NULL, 0, 0, mGlobals.StringHFileName, "failed to open file for write");
+ return STATUS_ERROR;
+ }
+
+ fclose (Fptr);
+ FileExist = TRUE;
+ }
+
+ //
+ // Preprocess using C preprocessor
+ //
+ if (PreprocessSourceFile (ScanFiles->Str) != STATUS_SUCCESS) {
+ return STATUS_ERROR;
+ }
+
+ FileName = mGlobals.PreprocessFileName;
+ } else {
+ FileName = ScanFiles->Str;
+ }
+
+ Fptr = fopen (FileName, "r");
if (Fptr == NULL) {
- Error (NULL, 0, 0, ScanFiles->Str, "failed to open input file for scanning");
+ Error (NULL, 0, 0, FileName, "failed to open input file for scanning");
return STATUS_ERROR;
}
@@ -2613,6 +2838,13 @@ ScanFiles (
ScanFiles = ScanFiles->Next;
}
+ //
+ // Remove the empty string defines file
+ //
+ if (FileExist) {
+ remove (mGlobals.StringHFileName);
+ }
+
return STATUS_SUCCESS;
}
//
@@ -2647,6 +2879,15 @@ FreeLists (
mGlobals.ScanFileName = Temp;
}
//
+ // Free up preprocess flags list
+ //
+ while (mGlobals.PreprocessFlags != NULL) {
+ Temp = mGlobals.PreprocessFlags->Next;
+ free (mGlobals.PreprocessFlags->Str);
+ free (mGlobals.PreprocessFlags);
+ mGlobals.PreprocessFlags = Temp;
+ }
+ //
// If they gave us a list of filename extensions to
// skip on scan, then free them up.
//
@@ -2767,7 +3008,7 @@ Usage (
Routine Description:
Print usage information for this utility.
-
+
Arguments:
None.
@@ -2775,51 +3016,62 @@ Arguments:
Returns:
Nothing.
-
+
--*/
{
- int Index;
- static const char *Str[] = {
+ int Index;
+ const char *Str[] = {
+ UTILITY_NAME" "UTILITY_VERSION" - Intel UEFI String Gather Utility",
+ " Copyright (C), 2004 - 2008 Intel Corporation",
+
+#if ( defined(UTILITY_BUILD) && defined(UTILITY_VENDOR) )
+ " Built from "UTILITY_BUILD", project of "UTILITY_VENDOR,
+#endif
"",
- PROGRAM_NAME " version "TOOL_VERSION " -- process unicode strings file",
- " Usage: "PROGRAM_NAME " -parse {parse options} [FileNames]",
- " "PROGRAM_NAME " -scan {scan options} [FileName]",
- " "PROGRAM_NAME " -dump {dump options}",
- " Common options include:",
- " -h or -? for this help information",
- " -db Database required name of output/input database file",
- " -bn BaseName for use in the .h and .c output files",
- " Default = "DEFAULT_BASE_NAME,
- " -v for verbose output",
- " -vdbw for verbose output when writing database",
- " -vdbr for verbose output when reading database",
- " -od FileName to specify an output database file name",
- " Parse options include:",
- " -i IncludePath add IncludePath to list of search paths",
- " -dep FileName to specify an output dependency file name",
- " -newdb to not read in existing database file",
- " -uqs to indicate that unquoted strings are used",
- " FileNames name of one or more unicode files to parse",
- " Scan options include:",
- " -scan scan text file(s) for STRING_TOKEN() usage",
- " -skipext .ext to skip scan of files with .ext filename extension",
- " -ignorenotfound ignore if a given STRING_TOKEN(STR) is not ",
- " found in the database",
- " FileNames one or more files to scan",
- " Dump options include:",
- " -oc FileName write string data to FileName",
- " -oh FileName write string defines to FileName",
- " -ou FileName dump database to unicode file FileName",
- " -lang Lang only dump for the language 'Lang'",
- " -if FileName to specify an indirection file",
- " -hpk FileName to create an HII export pack of the strings",
+ "Usage:",
+ " "UTILITY_NAME" -parse [OPTION] FILE",
+ " "UTILITY_NAME" -scan [OPTION] FILE",
+ " "UTILITY_NAME" -dump [OPTION]",
+ "Description:",
+ " Process unicode strings file.",
+ "Common options include:",
+ " -h or -? for this help information",
+ " -db Database required name of output/input database file",
+ " -bn BaseName for use in the .h and .c output files",
+ " Default = "DEFAULT_BASE_NAME,
+ " -v for verbose output",
+ " -vdbw for verbose output when writing database",
+ " -vdbr for verbose output when reading database",
+ " -od FileName to specify an output database file name",
+ "Parse options include:",
+ " -i IncludePath add IncludePath to list of search paths",
+ " -dep FileName to specify an output dependency file name",
+ " -newdb to not read in existing database file",
+ " -uqs to indicate that unquoted strings are used",
+ " FileNames name of one or more unicode files to parse",
+ "Scan options include:",
+ " -scan scan text file(s) for STRING_TOKEN() usage",
+ " -skipext .ext to skip scan of files with .ext filename extension",
+ " -ppflag \"Flags\" to specify the C preprocessor flags",
+ " -oh FileName to specify string defines file name for preprocessor",
+ " -ignorenotfound ignore if a given STRING_TOKEN(STR) is not ",
+ " found in the database",
+ " FileNames one or more files to scan",
+ "Dump options include:",
+ " -oc FileName write string data to FileName",
+ " -oh FileName write string defines to FileName",
+ " -ou FileName dump database to unicode file FileName",
+ " -lang Lang only dump for the language 'Lang'",
+ " use ';' to separate multiple languages",
+ " -if FileName to specify an indirection file",
+ " -hpk FileName to create an HII export pack of the strings",
"",
- " The expected process is to parse a unicode string file to create an initial",
- " database of string identifier names and string definitions. Then text files",
- " should be scanned for STRING_TOKEN() usages, and the referenced",
- " strings will be tagged as used in the database. After all files have been",
- " scanned, then the database should be dumped to create the necessary output",
- " files.",
+ "The expected process is to parse a unicode string file to create an initial",
+ "database of string identifier names and string definitions. Then text files",
+ "should be scanned for STRING_TOKEN() usages, and the referenced",
+ "strings will be tagged as used in the database. After all files have been",
+ "scanned, then the database should be dumped to create the necessary output",
+ "files.",
"",
NULL
};
diff --git a/EdkCompatibilityPkg/Sample/Tools/Source/UefiStrGather/StrGather.h b/EdkCompatibilityPkg/Sample/Tools/Source/UefiStrGather/StrGather.h
index c45fe28552..4ab20d9359 100644
--- a/EdkCompatibilityPkg/Sample/Tools/Source/UefiStrGather/StrGather.h
+++ b/EdkCompatibilityPkg/Sample/Tools/Source/UefiStrGather/StrGather.h
@@ -1,6 +1,6 @@
/*++
-Copyright (c) 2004, 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
@@ -25,8 +25,6 @@ Abstract:
#define MALLOC(size) malloc (size)
#define FREE(ptr) do { if ((ptr) != NULL) { free (ptr); } } while (0)
-#define PROGRAM_NAME "StrGather"
-
typedef CHAR16 WCHAR;
#define UNICODE_TO_ASCII(w) (INT8) ((w) & 0xFF)
diff --git a/EdkCompatibilityPkg/Sample/Tools/Source/UefiStrGather/StringDB.c b/EdkCompatibilityPkg/Sample/Tools/Source/UefiStrGather/StringDB.c
index 563204bab9..eaa15ad763 100644
--- a/EdkCompatibilityPkg/Sample/Tools/Source/UefiStrGather/StringDB.c
+++ b/EdkCompatibilityPkg/Sample/Tools/Source/UefiStrGather/StringDB.c
@@ -1,6 +1,6 @@
/*++
-Copyright (c) 2004 - 2007, 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
@@ -2559,13 +2559,15 @@ ExportPackOut:
STATUS
StringDBCreateHiiExportPack (
- INT8 *FileName
+ INT8 *FileName,
+ WCHAR_STRING_LIST *LanguagesOfInterest
)
{
- FILE *File = NULL;
- LANGUAGE_LIST *Lang = NULL;
- EFI_HII_STRING_PACKAGE_HDR *StrPkgHdr = NULL;
- SPkgBlkBuffer *BlkList = NULL;
+ FILE *File;
+ LANGUAGE_LIST *Lang;
+ EFI_HII_STRING_PACKAGE_HDR *StrPkgHdr;
+ SPkgBlkBuffer *BlkList;
+ WCHAR_STRING_LIST *LOIPtr;
if (FileName == NULL) {
return STATUS_ERROR;
@@ -2577,18 +2579,26 @@ StringDBCreateHiiExportPack (
}
for (Lang = mDBData.LanguageList; Lang != NULL; Lang = Lang->Next) {
- if (StringDBGenStrPkgHdrAndBlkList(Lang, &StrPkgHdr, &BlkList) != STATUS_SUCCESS) {
- fclose (File);
- return STATUS_SUCCESS;
+ for (LOIPtr = LanguagesOfInterest; LOIPtr != NULL; LOIPtr = LOIPtr->Next) {
+ if (wcscmp (LOIPtr->Str, Lang->LanguageName) == 0) {
+ break;
+ }
}
- StrPkgWriteHdrBinary (File, StrPkgHdr);
- StrPkgWriteBlkListBinary (File, BlkList);
+ if ((LanguagesOfInterest == NULL) ||
+ (LanguagesOfInterest != NULL && LOIPtr != NULL)) {
+ if (StringDBGenStrPkgHdrAndBlkList(Lang, &StrPkgHdr, &BlkList) != STATUS_SUCCESS) {
+ fclose (File);
+ return STATUS_SUCCESS;
+ }
- StrPkgHdrFree (StrPkgHdr);
- StrPkgBlkBufferListFree (BlkList);
- }
+ StrPkgWriteHdrBinary (File, StrPkgHdr);
+ StrPkgWriteBlkListBinary (File, BlkList);
+ StrPkgHdrFree (StrPkgHdr);
+ StrPkgBlkBufferListFree (BlkList);
+ }
+ }
fclose (File);
return STATUS_SUCCESS;
}
@@ -2605,16 +2615,18 @@ static const char *gSourceFileHeader[] = {
STATUS
StringDBDumpCStrings (
INT8 *BaseName,
- INT8 *FileName
+ INT8 *FileName,
+ WCHAR_STRING_LIST *LanguagesOfInterest
)
{
EFI_STATUS Status;
- FILE *File = NULL;
- LANGUAGE_LIST *Lang = NULL;
- EFI_HII_STRING_PACKAGE_HDR **StrPkgHdr = NULL;
- SPkgBlkBuffer **BlkList = NULL;
+ FILE *File;
+ LANGUAGE_LIST *Lang;
+ EFI_HII_STRING_PACKAGE_HDR **StrPkgHdr;
+ SPkgBlkBuffer **BlkList;
UINT32 Index;
- UINT32 LangNumber = 0;
+ UINT32 LangNumber;
+ WCHAR_STRING_LIST *LOIPtr;
if ((BaseName == NULL) || (FileName == NULL)) {
return STATUS_ERROR;
@@ -2631,14 +2643,36 @@ StringDBDumpCStrings (
BlkList = (SPkgBlkBuffer **) malloc (sizeof (SPkgBlkBuffer *) * LangNumber);
for (Index = 0; Index < LangNumber; Index++) {
StrPkgHdr[Index] = NULL;
- BlkList[Index] = NULL;
+ BlkList[Index] = NULL;
}
- for (Index = 0, Lang = mDBData.LanguageList; Lang != NULL; Lang = Lang->Next, Index++) {
- Status = StringDBGenStrPkgHdrAndBlkList(Lang, &StrPkgHdr[Index], &BlkList[Index]);
- if (EFI_ERROR(Status)) {
- return Status;
+ for (Index = 0, Lang = mDBData.LanguageList; Lang != NULL; Lang = Lang->Next) {
+ for (LOIPtr = LanguagesOfInterest; LOIPtr != NULL; LOIPtr = LOIPtr->Next) {
+ if (wcscmp (LOIPtr->Str, Lang->LanguageName) == 0) {
+ break;
+ }
}
+ if ((LanguagesOfInterest == NULL) ||
+ (LanguagesOfInterest != NULL && LOIPtr != NULL)) {
+ Status = StringDBGenStrPkgHdrAndBlkList(Lang, &StrPkgHdr[Index], &BlkList[Index]);
+ Index++;
+ if (EFI_ERROR(Status)) {
+ free (StrPkgHdr);
+ free (BlkList);
+ return STATUS_ERROR;
+ }
+ }
+ }
+
+ //
+ // Update LangNumber after filter
+ //
+ LangNumber = Index;
+
+ if (LangNumber == 0) {
+ free (StrPkgHdr);
+ free (BlkList);
+ return STATUS_SUCCESS;
}
if ((File = fopen (FileName, "w")) == NULL) {
@@ -2657,11 +2691,9 @@ StringDBDumpCStrings (
//
StrPkgWirteArrayLength (File, LangNumber, StrPkgHdr);
- for (Index = 0, Lang = mDBData.LanguageList; Lang != NULL; Lang = Lang->Next, Index++) {
- if (StrPkgHdr[Index] != NULL) {
- StrPkgWriteHdrCFile (File, StrPkgHdr[Index]);
- StrPkgWriteBlkListCFile (File, BlkList[Index], (Lang->Next == NULL) ? TRUE : FALSE);
- }
+ for (Index = 0; Index < LangNumber; Index++) {
+ StrPkgWriteHdrCFile (File, StrPkgHdr[Index]);
+ StrPkgWriteBlkListCFile (File, BlkList[Index], (Index == LangNumber - 1) ? TRUE : FALSE);
StrPkgHdrFree (StrPkgHdr[Index]);
StrPkgBlkBufferListFree (BlkList[Index]);
@@ -2670,5 +2702,7 @@ StringDBDumpCStrings (
fprintf (File, "\n};\n");
fclose (File);
+ free (StrPkgHdr);
+ free (BlkList);
return STATUS_SUCCESS;
}
diff --git a/EdkCompatibilityPkg/Sample/Tools/Source/UefiStrGather/StringDB.h b/EdkCompatibilityPkg/Sample/Tools/Source/UefiStrGather/StringDB.h
index 9e4088bcf8..d98b5b71cc 100644
--- a/EdkCompatibilityPkg/Sample/Tools/Source/UefiStrGather/StringDB.h
+++ b/EdkCompatibilityPkg/Sample/Tools/Source/UefiStrGather/StringDB.h
@@ -1,6 +1,6 @@
/*++
-Copyright (c) 2004, 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
@@ -134,11 +134,13 @@ typedef struct _SPkgBlkBuffer {
void
StringDBConstructor (
void
- );
+ )
+;
void
StringDBDestructor (
void
- );
+ )
+;
STATUS
StringDBAddString (
@@ -148,12 +150,14 @@ StringDBAddString (
WCHAR *String,
BOOLEAN Format,
UINT16 Flags
- );
+ )
+;
STATUS
StringDBSetScope (
WCHAR *Scope
- );
+ )
+;
#define STRING_FLAGS_REFERENCED 0x0001 // if referenced somewhere
#define STRING_FLAGS_UNDEFINED 0x0002 // if we added it for padding purposes
@@ -167,72 +171,92 @@ StringDBAddStringIdentifier (
WCHAR *StringIdentifier,
UINT16 *NewId,
UINT16 Flags
- );
+ )
+;
STATUS
StringDBReadDatabase (
INT8 *DBFileName,
BOOLEAN IgnoreIfNotExist,
BOOLEAN Verbose
- );
+ )
+;
STATUS
StringDBWriteDatabase (
INT8 *DBFileName,
BOOLEAN Verbose
- );
+ )
+;
STATUS
StringDBDumpDatabase (
INT8 *DBFileName,
INT8 *OutputFileName,
BOOLEAN Verbose
- );
+ )
+;
STATUS
StringDBAddLanguage (
WCHAR *LanguageName,
WCHAR *PrintableLanguageName,
WCHAR *SecondaryLanguageList
- );
+ )
+;
STATUS
StringDBAddSecondaryLanguage (
WCHAR *LanguageName,
WCHAR *SecondaryLanguageList
- );
+ )
+;
STATUS
StringDBDumpCStrings (
INT8 *BaseName,
- INT8 *FileName
- );
+ INT8 *FileName,
+ WCHAR_STRING_LIST *LanguagesOfInterests
+ )
+;
+
+STATUS
+StringDBCreateHiiExportPack (
+ INT8 *OutputFileName,
+ WCHAR_STRING_LIST *LanguagesOfInterests
+ )
+;
STATUS
StringDBDumpStringDefines (
INT8 *FileName,
INT8 *BaseName
- );
+ )
+;
STATUS
StringDBSetCurrentLanguage (
WCHAR *LanguageName
- );
+ )
+;
STATUS
StringDBSetStringReferenced (
INT8 *StringIdentifierName,
BOOLEAN IgnoreNotFound
- );
+ )
+;
void
StringDBFormatString (
WCHAR *String
- );
+ )
+;
LANGUAGE_LIST *
StringDBFindLanguageList (
WCHAR *LanguageName
- );
+ )
+;
#endif // #ifndef _STRING_DB_H_
diff --git a/EdkCompatibilityPkg/Sample/Tools/Source/UefiVfrCompile/EfiVfr.h b/EdkCompatibilityPkg/Sample/Tools/Source/UefiVfrCompile/EfiVfr.h
index 55830c9907..b4a849db7b 100644
--- a/EdkCompatibilityPkg/Sample/Tools/Source/UefiVfrCompile/EfiVfr.h
+++ b/EdkCompatibilityPkg/Sample/Tools/Source/UefiVfrCompile/EfiVfr.h
@@ -1,6 +1,6 @@
/*++
-Copyright (c) 2004 - 2007, 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
@@ -15,8 +15,6 @@ Module Name:
Abstract:
- Defines and prototypes for the UEFI VFR compiler internal use.
-
--*/
#ifndef _EFIVFR_H_
diff --git a/EdkCompatibilityPkg/Sample/Tools/Source/UefiVfrCompile/VfrCompiler.cpp b/EdkCompatibilityPkg/Sample/Tools/Source/UefiVfrCompile/VfrCompiler.cpp
index 6adef8a41b..2972e1692a 100644
--- a/EdkCompatibilityPkg/Sample/Tools/Source/UefiVfrCompile/VfrCompiler.cpp
+++ b/EdkCompatibilityPkg/Sample/Tools/Source/UefiVfrCompile/VfrCompiler.cpp
@@ -11,7 +11,7 @@ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
Module Name:
-VfrCompiler.cpp
+ VfrCompiler.cpp
Abstract:
@@ -41,7 +41,7 @@ CVfrCompiler::IS_RUN_STATUS (
VOID
CVfrCompiler::OptionInitialization (
- IN INT32 Argc,
+ IN INT32 Argc,
IN INT8 **Argv
)
{
@@ -57,6 +57,7 @@ CVfrCompiler::OptionInitialization (
mOptions.PreprocessorOutputFileName[0] = '\0';
mOptions.VfrBaseFileName[0] = '\0';
mOptions.IncludePaths = NULL;
+ mOptions.SkipCPreprocessor = FALSE;
mOptions.CPreprocessorOptions = NULL;
for (Index = 1; (Index < Argc) && (Argv[Index][0] == '-'); Index++) {
@@ -70,7 +71,7 @@ CVfrCompiler::OptionInitialization (
} else if (_stricmp(Argv[Index], "-i") == 0) {
Index++;
if ((Index >= Argc) || (Argv[Index][0] == '-')) {
- printf ("%s -i - missing path argument\n", PROGRAM_NAME);
+ printf ("%s -i - missing path argument\n", UTILITY_NAME);
goto Fail;
}
@@ -78,30 +79,33 @@ CVfrCompiler::OptionInitialization (
} else if (_stricmp(Argv[Index], "-od") == 0) {
Index++;
if ((Index >= Argc) || (Argv[Index][0] == '-')) {
- printf ("%s -od - missing output directory name\n", PROGRAM_NAME);
+ printf ("%s -od - missing output directory name\n", UTILITY_NAME);
goto Fail;
}
strcpy (mOptions.OutputDirectory, Argv[Index]);
+ strcat (mOptions.OutputDirectory, "\\");
} else if (_stricmp(Argv[Index], "-ibin") == 0) {
mOptions.CreateIfrPkgFile = TRUE;
} else if (_stricmp(Argv[Index], "-nostrings") == 0) {
+ } else if (_stricmp(Argv[Index], "-nopp") == 0) {
+ mOptions.SkipCPreprocessor = TRUE;
} else if (_stricmp(Argv[Index], "-ppflag") == 0) {
Index++;
if ((Index >= Argc) || (Argv[Index][0] == '-')) {
- printf ("%s -od - missing C-preprocessor argument\n", PROGRAM_NAME);
+ printf ("%s -od - missing C-preprocessor argument\n", UTILITY_NAME);
goto Fail;
}
AppendCPreprocessorOptions (Argv[Index]);
} else {
- printf ("%s unrecognized option %s\n", PROGRAM_NAME, Argv[Index]);
+ printf ("%s unrecognized option %s\n", UTILITY_NAME, Argv[Index]);
Usage ();
goto Fail;
}
}
if (Index != Argc - 1) {
- printf ("%s must specify VFR file name", PROGRAM_NAME);
+ printf ("%s must specify VFR file name\n", UTILITY_NAME);
Usage ();
goto Fail;
} else {
@@ -140,7 +144,7 @@ Fail:
if (mOptions.IncludePaths != NULL) {
delete mOptions.IncludePaths;
mOptions.IncludePaths = NULL;
- }
+ }
if (mOptions.CPreprocessorOptions != NULL) {
delete mOptions.CPreprocessorOptions;
mOptions.CPreprocessorOptions = NULL;
@@ -161,7 +165,7 @@ CVfrCompiler::AppendIncludePath (
}
IncludePaths = new INT8[Len];
if (IncludePaths == NULL) {
- printf ("%s memory allocation failure\n", PROGRAM_NAME);
+ printf ("%s memory allocation failure\n", UTILITY_NAME);
return;
}
IncludePaths[0] = '\0';
@@ -190,7 +194,7 @@ CVfrCompiler::AppendCPreprocessorOptions (
}
Opt = new INT8[Len];
if (Opt == NULL) {
- printf ("%s memory allocation failure\n", PROGRAM_NAME);
+ printf ("%s memory allocation failure\n", UTILITY_NAME);
return;
}
Opt[0] = 0;
@@ -217,7 +221,11 @@ CVfrCompiler::SetBaseFileName (
}
pFileName = mOptions.VfrFileName;
- while ((pPath = strchr (pFileName, '\\')) != NULL) {
+ while (
+ ((pPath = strchr (pFileName, '\\')) != NULL) ||
+ ((pPath = strchr (pFileName, '/')) != NULL)
+ )
+ {
pFileName = pPath + 1;
}
@@ -300,7 +308,7 @@ CVfrCompiler::SetRecordListFileName (
}
CVfrCompiler::CVfrCompiler (
- IN INT32 Argc,
+ IN INT32 Argc,
IN INT8 **Argv
)
{
@@ -333,35 +341,40 @@ CVfrCompiler::~CVfrCompiler (
SET_RUN_STATUS(STATUS_DEAD);
}
-VOID
+VOID
CVfrCompiler::Usage (
VOID
)
{
- UINT32 Index;
- CONST INT8 *Help[] = {
- " ",
- "VfrCompile version " VFR_COMPILER_VERSION,
- " ",
- " Usage: VfrCompile {options} [VfrFile]",
- " ",
- " where options include:",
- " -? or -h prints this help",
- " -l create an output IFR listing file",
- " -i IncPath add IncPath to the search path for VFR included files",
- " -od OutputDir deposit all output files to directory OutputDir (default=cwd)",
- " -ibin create an IFR HII pack file"
- " -ppflag C-preprocessor argument",
- " where parameters include:",
- " VfrFile name of the input VFR script file",
- " ",
+ int Index;
+ const char *Str[] = {
+ UTILITY_NAME" "UTILITY_VERSION" - Intel UEFI VFR Compiler Utility",
+ " Copyright (C), 2004 - 2008 Intel Corporation",
+#if ( defined(UTILITY_BUILD) && defined(UTILITY_VENDOR) )
+ " Built from "UTILITY_BUILD", project of "UTILITY_VENDOR,
+#endif
+ "",
+ "Usage:",
+ " "UTILITY_NAME" [OPTION] VFRFILE",
+ "Description:",
+ " Compile VFRFILE.",
+ "Options:",
+ " -? or -h print this help",
+ " -l create an output IFR listing file",
+ " -i IncPath add IncPath to the search path for VFR included files",
+ " -od OutputDir deposit all output files to directory OutputDir (default=cwd)",
+ " -ibin create an IFR HII pack file",
+ " -ppflag CFlags pass Flags as C-preprocessor-flag",
+ " -v or -version print version information",
NULL
- };
- for (Index = 0; Help[Index] != NULL; Index++) {
- fprintf (stdout, "%s\n", Help[Index]);
+ };
+
+ for (Index = 0; Str[Index] != NULL; Index++) {
+ fprintf (stdout, "%s\n", Str[Index]);
}
}
+
VOID
CVfrCompiler::PreProcess (
VOID
@@ -375,8 +388,12 @@ CVfrCompiler::PreProcess (
goto Fail;
}
+ if (mOptions.SkipCPreprocessor == TRUE) {
+ goto Out;
+ }
+
if ((pVfrFile = fopen (mOptions.VfrFileName, "r")) == NULL) {
- printf ("%s could not open input VFR file - %s\n", PROGRAM_NAME, mOptions.VfrFileName);
+ printf ("%s could not open input VFR file - %s\n", UTILITY_NAME, mOptions.VfrFileName);
goto Fail;
}
fclose (pVfrFile);
@@ -392,7 +409,7 @@ CVfrCompiler::PreProcess (
PreProcessCmd = new INT8[CmdLen + 10];
if (PreProcessCmd == NULL) {
- printf ("%s could not allocate memory\n", PROGRAM_NAME);
+ printf ("%s could not allocate memory\n", UTILITY_NAME);
goto Fail;
}
strcpy (PreProcessCmd, mPreProcessCmd), strcat (PreProcessCmd, " ");
@@ -407,11 +424,13 @@ CVfrCompiler::PreProcess (
strcat (PreProcessCmd, mOptions.PreprocessorOutputFileName);
if (system (PreProcessCmd) != 0) {
- printf ("%s failed to spawn C preprocessor on VFR file \n\t - %s\n", PROGRAM_NAME, PreProcessCmd);
+ printf ("%s failed to spawn C preprocessor on VFR file \n\t - %s\n", UTILITY_NAME, PreProcessCmd);
goto Fail;
}
delete PreProcessCmd;
+
+Out:
SET_RUN_STATUS (STATUS_PREPROCESSED);
return;
@@ -429,22 +448,27 @@ CVfrCompiler::Compile (
VOID
)
{
- FILE *VfrFile = NULL;
+ FILE *pInFile = NULL;
+ INT8 *InFileName = NULL;
if (!IS_RUN_STATUS(STATUS_PREPROCESSED)) {
goto Fail;
}
- if ((VfrFile = fopen (mOptions.PreprocessorOutputFileName, "r")) == NULL) {
- printf ("%s failed to open input VFR preprocessor output file - %s\n", PROGRAM_NAME, mOptions.PreprocessorOutputFileName);
+ InFileName = (mOptions.SkipCPreprocessor == TRUE) ? mOptions.VfrFileName : mOptions.PreprocessorOutputFileName;
+
+ gCVfrErrorHandle.SetInputFile (InFileName);
+
+ if ((pInFile = fopen (InFileName, "r")) == NULL) {
+ printf ("%s failed to open input file - %s\n", UTILITY_NAME, InFileName);
goto Fail;
}
- if (VfrParserStart (VfrFile) != 0) {
+ if (VfrParserStart (pInFile) != 0) {
goto Fail;
}
- fclose (VfrFile);
+ fclose (pInFile);
if (gCFormPkg.HavePendingUnassigned () == TRUE) {
gCFormPkg.PendingAssignPrintAll ();
@@ -456,11 +480,11 @@ CVfrCompiler::Compile (
Fail:
if (!IS_RUN_STATUS(STATUS_DEAD)) {
- printf ("%s compile error!\n", PROGRAM_NAME);
+ printf ("%s compile error!\n", UTILITY_NAME);
SET_RUN_STATUS (STATUS_FAILED);
}
- if (VfrFile != NULL) {
- fclose (VfrFile);
+ if (pInFile != NULL) {
+ fclose (pInFile);
}
}
@@ -477,7 +501,7 @@ CVfrCompiler::GenBinary (
if (mOptions.CreateIfrPkgFile == TRUE) {
if ((pFile = fopen (mOptions.PkgOutputFileName, "wb")) == NULL) {
- printf ("can not open PkgFileName\n", mOptions.PkgOutputFileName);
+ printf ("can not open %s\n", mOptions.PkgOutputFileName);
goto Fail;
}
if (gCFormPkg.BuildPkg (pFile) != VFR_RETURN_SUCCESS) {
@@ -548,27 +572,30 @@ CVfrCompiler::GenRecordListFile (
VOID
)
{
- FILE *pInFile = NULL;
- FILE *pOutFile = NULL;
+ INT8 *InFileName = NULL;
+ FILE *pInFile = NULL;
+ FILE *pOutFile = NULL;
INT8 LineBuf[MAX_LINE_LEN];
UINT32 LineNo;
+ InFileName = (mOptions.SkipCPreprocessor == TRUE) ? mOptions.VfrFileName : mOptions.PreprocessorOutputFileName;
+
if (mOptions.CreateRecordListFile == TRUE) {
- if ((mOptions.PreprocessorOutputFileName[0] == '\0') || (mOptions.RecordListFile[0] == '\0')) {
+ if ((InFileName[0] == '\0') || (mOptions.RecordListFile[0] == '\0')) {
return;
}
- if ((pInFile = fopen (mOptions.PreprocessorOutputFileName, "r")) == NULL) {
- printf ("%s failed to open input VFR preprocessor output file - %s\n", PROGRAM_NAME, mOptions.PreprocessorOutputFileName);
+ if ((pInFile = fopen (InFileName, "r")) == NULL) {
+ printf ("%s failed to open input VFR preprocessor output file - %s\n", UTILITY_NAME, InFileName);
return;
}
if ((pOutFile = fopen (mOptions.RecordListFile, "w")) == NULL) {
- printf ("%s failed to open record list file for writing - %s\n", PROGRAM_NAME, mOptions.RecordListFile);
+ printf ("%s failed to open record list file for writing - %s\n", UTILITY_NAME, mOptions.RecordListFile);
goto Err1;
}
- fprintf (pOutFile, "//\n// VFR compiler version " VFR_COMPILER_VERSION "\n//\n");
+ fprintf (pOutFile, "//\n// VFR compiler version " UTILITY_VERSION "\n//\n");
LineNo = 0;
while (!feof (pInFile)) {
if (fgets (LineBuf, MAX_LINE_LEN, pInFile) != NULL) {
@@ -590,7 +617,7 @@ Err1:
INT32
main (
- IN INT32 Argc,
+ IN INT32 Argc,
IN INT8 **Argv
)
{
diff --git a/EdkCompatibilityPkg/Sample/Tools/Source/UefiVfrCompile/VfrCompiler.h b/EdkCompatibilityPkg/Sample/Tools/Source/UefiVfrCompile/VfrCompiler.h
index 0410f84252..bc487f88ba 100644
--- a/EdkCompatibilityPkg/Sample/Tools/Source/UefiVfrCompile/VfrCompiler.h
+++ b/EdkCompatibilityPkg/Sample/Tools/Source/UefiVfrCompile/VfrCompiler.h
@@ -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"
#include "VfrUtilityLib.h"
-#define PROGRAM_NAME "VfrCompile"
-#define VFR_COMPILER_VERSION "UEFI 2.1"
+#define UTILITY_NAME "VfrCompile"
+#define UTILITY_VERSION "v1.1"
//
// This is how we invoke the C preprocessor on the VFR source file
@@ -56,6 +56,7 @@ typedef struct {
INT8 PreprocessorOutputFileName[MAX_PATH];
INT8 VfrBaseFileName[MAX_PATH]; // name of input VFR file with no path or extension
INT8 *IncludePaths;
+ bool SkipCPreprocessor;
INT8 *CPreprocessorOptions;
} OPTIONS;
diff --git a/EdkCompatibilityPkg/Sample/Tools/Source/UefiVfrCompile/VfrError.cpp b/EdkCompatibilityPkg/Sample/Tools/Source/UefiVfrCompile/VfrError.cpp
index 4a366136bf..d6fc7cf909 100644
--- a/EdkCompatibilityPkg/Sample/Tools/Source/UefiVfrCompile/VfrError.cpp
+++ b/EdkCompatibilityPkg/Sample/Tools/Source/UefiVfrCompile/VfrError.cpp
@@ -11,7 +11,7 @@ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
Module Name:
-VfrError.cpp
+ VfrError.cpp
Abstract:
@@ -25,33 +25,36 @@ Abstract:
static SVFR_ERROR_HANDLE VFR_ERROR_HANDLE_TABLE [] = {
{ VFR_RETURN_SUCCESS, NULL },
{ VFR_RETURN_ERROR_SKIPED, NULL },
- { VFR_RETURN_FATAL_ERROR, "fatal error!!" },
-
- { VFR_RETURN_MISMATCHED, "unexpected token" },
- { VFR_RETURN_INVALID_PARAMETER, "Invalid parameter" },
- { VFR_RETURN_OUT_FOR_RESOURCES, "system out of memory" },
- { VFR_RETURN_UNSUPPORTED, "unsupported" },
- { VFR_RETURN_REDEFINED, "already defined" },
- { VFR_RETURN_FORMID_REDEFINED, "form id already defined" },
- { VFR_RETURN_QUESTIONID_REDEFINED, "question id already defined" },
- { VFR_RETURN_VARSTOREID_REDEFINED, "varstore id already defined" },
- { VFR_RETURN_UNDEFINED, "undefined" },
- { VFR_RETURN_VAR_NOTDEFINED_BY_QUESTION, "some variable has not defined by a question"},
- { VFR_RETURN_GET_EFIVARSTORE_ERROR, "get efi varstore error"},
- { VFR_RETURN_EFIVARSTORE_USE_ERROR, "can not use the efi varstore like this" },
- { VFR_RETURN_EFIVARSTORE_SIZE_ERROR, "unsupport efi varstore size should be <= 8 bytes" },
- { VFR_RETURN_GET_NVVARSTORE_ERROR, "get name value varstore error" },
- { VFR_RETURN_QVAR_REUSE, "variable reused by more than one question" },
- { VFR_RETURN_FLAGS_UNSUPPORTED, "flags unsupported" },
- { VFR_RETURN_ERROR_ARRARY_NUM, "array number error" },
- { VFR_RETURN_DATA_STRING_ERROR, "data field string error or not support"},
- { VFR_RETURN_CODEUNDEFINED, "Undefined Error Code" }
+ { VFR_RETURN_FATAL_ERROR, ": fatal error!!" },
+
+ { VFR_RETURN_MISMATCHED, ": unexpected token" },
+ { VFR_RETURN_INVALID_PARAMETER, ": invalid parameter" },
+ { VFR_RETURN_OUT_FOR_RESOURCES, ": system out of memory" },
+ { VFR_RETURN_UNSUPPORTED, ": unsupported" },
+ { VFR_RETURN_REDEFINED, ": already defined" },
+ { VFR_RETURN_FORMID_REDEFINED, ": form id already defined" },
+ { VFR_RETURN_QUESTIONID_REDEFINED, ": question id already defined" },
+ { VFR_RETURN_VARSTOREID_REDEFINED, ": varstore id already defined" },
+ { VFR_RETURN_UNDEFINED, ": undefined" },
+ { VFR_RETURN_VAR_NOTDEFINED_BY_QUESTION, ": some variable has not defined by a question"},
+ { VFR_RETURN_GET_EFIVARSTORE_ERROR, ": get efi varstore error"},
+ { VFR_RETURN_EFIVARSTORE_USE_ERROR, ": can not use the efi varstore like this" },
+ { VFR_RETURN_EFIVARSTORE_SIZE_ERROR, ": unsupport efi varstore size should be <= 8 bytes" },
+ { VFR_RETURN_GET_NVVARSTORE_ERROR, ": get name value varstore error" },
+ { VFR_RETURN_QVAR_REUSE, ": variable reused by more than one question" },
+ { VFR_RETURN_FLAGS_UNSUPPORTED, ": flags unsupported" },
+ { VFR_RETURN_ERROR_ARRARY_NUM, ": array number error" },
+ { VFR_RETURN_DATA_STRING_ERROR, ": data field string error or not support"},
+ { VFR_RETURN_DEFAULT_VALUE_REDEFINED, ": default value re-defined with different value"},
+ { VFR_RETURN_CONSTANT_ONLY, ": only constant is allowed in the expression"},
+ { VFR_RETURN_CODEUNDEFINED, ": undefined Error Code" }
};
CVfrErrorHandle::CVfrErrorHandle (
VOID
)
{
+ mInputFileName = NULL;
mScopeRecordListHead = NULL;
mScopeRecordListTail = NULL;
mVfrErrorHandleTable = VFR_ERROR_HANDLE_TABLE;
@@ -63,6 +66,10 @@ CVfrErrorHandle::~CVfrErrorHandle (
{
SVfrFileScopeRecord *pNode = NULL;
+ if (mInputFileName != NULL) {
+ delete mInputFileName;
+ }
+
while (mScopeRecordListHead != NULL) {
pNode = mScopeRecordListHead;
mScopeRecordListHead = mScopeRecordListHead->mNext;
@@ -74,8 +81,19 @@ CVfrErrorHandle::~CVfrErrorHandle (
mVfrErrorHandleTable = NULL;
}
+VOID
+CVfrErrorHandle::SetInputFile (
+ IN INT8 *InputFile
+ )
+{
+ if (InputFile != NULL) {
+ mInputFileName = new INT8[strlen(InputFile) + 1];
+ strcpy (mInputFileName, InputFile);
+ }
+}
+
SVfrFileScopeRecord::SVfrFileScopeRecord (
- IN INT8 *Record,
+ IN INT8 *Record,
IN UINT32 LineNum
)
{
@@ -116,7 +134,7 @@ SVfrFileScopeRecord::~SVfrFileScopeRecord (
VOID
CVfrErrorHandle::ParseFileScopeRecord (
- IN INT8 *Record,
+ IN INT8 *Record,
IN UINT32 WholeScopeLine
)
{
@@ -155,6 +173,15 @@ CVfrErrorHandle::GetFileNameLineNum (
*FileName = NULL;
*FileLine = 0xFFFFFFFF;
+ //
+ // Some errors occur before scope record list been built.
+ //
+ if (mScopeRecordListHead == NULL) {
+ *FileLine = LineNum;
+ *FileName = mInputFileName;
+ return ;
+ }
+
for (pNode = mScopeRecordListHead; pNode->mNext != NULL; pNode = pNode->mNext) {
if ((LineNum > pNode->mWholeScopeLine) && (pNode->mNext->mWholeScopeLine > LineNum)) {
*FileName = pNode->mFileName;
@@ -168,9 +195,10 @@ CVfrErrorHandle::GetFileNameLineNum (
}
VOID
-CVfrErrorHandle::PrintError (
+CVfrErrorHandle::PrintMsg (
IN UINT32 LineNum,
IN INT8 *TokName,
+ IN INT8 *MsgType,
IN INT8 *ErrorMsg
)
{
@@ -178,7 +206,7 @@ CVfrErrorHandle::PrintError (
UINT32 FileLine;
GetFileNameLineNum (LineNum, &FileName, &FileLine);
- printf ("%s line %d: error %s %s\n", FileName, FileLine, TokName, ErrorMsg);
+ printf ("%s line %d: %s %s %s\n", FileName, FileLine, MsgType, TokName, ErrorMsg);
}
UINT8
diff --git a/EdkCompatibilityPkg/Sample/Tools/Source/UefiVfrCompile/VfrError.h b/EdkCompatibilityPkg/Sample/Tools/Source/UefiVfrCompile/VfrError.h
index 3becd9b6e1..8c0e4c9a47 100644
--- a/EdkCompatibilityPkg/Sample/Tools/Source/UefiVfrCompile/VfrError.h
+++ b/EdkCompatibilityPkg/Sample/Tools/Source/UefiVfrCompile/VfrError.h
@@ -11,7 +11,7 @@ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
Module Name:
-VfrError.h
+ VfrError.h
Abstract:
@@ -45,6 +45,8 @@ typedef enum {
VFR_RETURN_FLAGS_UNSUPPORTED,
VFR_RETURN_ERROR_ARRARY_NUM,
VFR_RETURN_DATA_STRING_ERROR,
+ VFR_RETURN_DEFAULT_VALUE_REDEFINED,
+ VFR_RETURN_CONSTANT_ONLY,
VFR_RETURN_CODEUNDEFINED
} EFI_VFR_RETURN_CODE;
@@ -65,6 +67,7 @@ struct SVfrFileScopeRecord {
class CVfrErrorHandle {
private:
+ INT8 *mInputFileName;
SVFR_ERROR_HANDLE *mVfrErrorHandleTable;
SVfrFileScopeRecord *mScopeRecordListHead;
SVfrFileScopeRecord *mScopeRecordListTail;
@@ -73,10 +76,11 @@ public:
CVfrErrorHandle (VOID);
~CVfrErrorHandle (VOID);
+ VOID SetInputFile (IN INT8 *);
VOID ParseFileScopeRecord (IN INT8 *, IN UINT32);
VOID GetFileNameLineNum (IN UINT32, OUT INT8 **, OUT UINT32 *);
UINT8 HandleError (IN EFI_VFR_RETURN_CODE, IN UINT32 LineNum = 0, IN INT8 *TokName = "\0");
- VOID PrintError (IN UINT32 LineNum = 0, IN INT8 *TokName = "\0", IN INT8 *ErrorMsg = "\0");
+ VOID PrintMsg (IN UINT32 LineNum = 0, IN INT8 *TokName = "\0", IN INT8 *MsgType = "Error", IN INT8 *ErrorMsg = "\0");
};
#define CHECK_ERROR_RETURN(f, v) do { EFI_VFR_RETURN_CODE r; if ((r = (f)) != (v)) { return r; } } while (0)
diff --git a/EdkCompatibilityPkg/Sample/Tools/Source/UefiVfrCompile/VfrFormPkg.cpp b/EdkCompatibilityPkg/Sample/Tools/Source/UefiVfrCompile/VfrFormPkg.cpp
index ddae865498..50398c6317 100644
--- a/EdkCompatibilityPkg/Sample/Tools/Source/UefiVfrCompile/VfrFormPkg.cpp
+++ b/EdkCompatibilityPkg/Sample/Tools/Source/UefiVfrCompile/VfrFormPkg.cpp
@@ -11,7 +11,7 @@ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
Module Name:
-VfrFormPkg.cpp
+ VfrFormPkg.cpp
Abstract:
@@ -25,25 +25,34 @@ Abstract:
*/
SPendingAssign::SPendingAssign (
- IN INT8 *Key,
- IN VOID *Addr,
- IN UINT32 Len,
- IN UINT32 LineNo
+ IN INT8 *Key,
+ IN VOID *Addr,
+ IN UINT32 Len,
+ IN UINT32 LineNo,
+ IN INT8 *Msg
)
{
+ mKey = NULL;
+ mAddr = Addr;
+ mLen = Len;
+ mFlag = PENDING;
+ mLineNo = LineNo;
+ mMsg = NULL;
+ mNext = NULL;
+
if (Key != NULL) {
mKey = new INT8[strlen (Key) + 1];
if (mKey != NULL) {
strcpy (mKey, Key);
}
- } else {
- mKey = NULL;
}
- mAddr = Addr;
- mLen = Len;
- mFlag = PENDING;
- mLineNo = LineNo;
- mNext = NULL;
+
+ if (Msg != NULL) {
+ mMsg = new INT8[strlen (Msg) + 1];
+ if (mMsg != NULL) {
+ strcpy (mMsg, Msg);
+ }
+ }
}
SPendingAssign::~SPendingAssign (
@@ -56,12 +65,15 @@ SPendingAssign::~SPendingAssign (
mAddr = NULL;
mLen = 0;
mLineNo = 0;
+ if (mMsg != NULL) {
+ delete mMsg;
+ }
mNext = NULL;
}
VOID
SPendingAssign::SetAddrAndLen (
- IN VOID *Addr,
+ IN VOID *Addr,
IN UINT32 LineNo
)
{
@@ -71,7 +83,7 @@ SPendingAssign::SetAddrAndLen (
VOID
SPendingAssign::AssignValue (
- IN VOID *Addr,
+ IN VOID *Addr,
IN UINT32 Len
)
{
@@ -227,7 +239,7 @@ CFormPkg::Close (
UINT32
CFormPkg::Read (
- IN CHAR8 *Buffer,
+ IN CHAR8 *Buffer,
IN UINT32 Size
)
{
@@ -270,7 +282,7 @@ CFormPkg::BuildPkgHdr (
return VFR_RETURN_OUT_FOR_RESOURCES;
}
- (*PkgHdr)->Type = EFI_HII_PACKAGE_FORM;
+ (*PkgHdr)->Type = EFI_HII_PACKAGE_FORMS;
(*PkgHdr)->Length = mPkgLength + sizeof (EFI_HII_PACKAGE_HEADER);
return VFR_RETURN_SUCCESS;
}
@@ -357,7 +369,7 @@ CFormPkg::_WRITE_PKG_END (
#define BYTES_PRE_LINE 0x10
-EFI_VFR_RETURN_CODE
+EFI_VFR_RETURN_CODE
CFormPkg::GenCFile (
IN INT8 *BaseName,
IN FILE *pFile
@@ -407,15 +419,16 @@ CFormPkg::GenCFile (
EFI_VFR_RETURN_CODE
CFormPkg::AssignPending (
- IN INT8 *Key,
- IN VOID *ValAddr,
+ IN INT8 *Key,
+ IN VOID *ValAddr,
IN UINT32 ValLen,
- IN UINT32 LineNo
+ IN UINT32 LineNo,
+ IN INT8 *Msg
)
{
SPendingAssign *pNew;
- pNew = new SPendingAssign (Key, ValAddr, ValLen, LineNo);
+ pNew = new SPendingAssign (Key, ValAddr, ValLen, LineNo, Msg);
if (pNew == NULL) {
return VFR_RETURN_OUT_FOR_RESOURCES;
}
@@ -427,8 +440,8 @@ CFormPkg::AssignPending (
VOID
CFormPkg::DoPendingAssign (
- IN INT8 *Key,
- IN VOID *ValAddr,
+ IN INT8 *Key,
+ IN VOID *ValAddr,
IN UINT32 ValLen
)
{
@@ -470,7 +483,7 @@ CFormPkg::PendingAssignPrintAll (
for (pNode = PendingAssignList; pNode != NULL; pNode = pNode->mNext) {
if (pNode->mFlag == PENDING) {
- gCVfrErrorHandle.PrintError (pNode->mLineNo, pNode->mKey, "can not assign value because not defined");
+ gCVfrErrorHandle.PrintMsg (pNode->mLineNo, pNode->mKey, "Error", pNode->mMsg);
}
}
}
@@ -492,10 +505,7 @@ SIfrRecord::~SIfrRecord (
VOID
)
{
- if (mIfrBinBuf != NULL) {
- delete mIfrBinBuf;
- mIfrBinBuf = NULL;
- }
+ mIfrBinBuf = NULL;
mLineNo = 0xFFFFFFFF;
mOffset = 0xFFFFFFFF;
mBinBufLen = 0;
@@ -537,8 +547,8 @@ CIfrRecordInfoDB::GetRecordInfoFromIdx (
return NULL;
}
- for (Idx = (EFI_IFR_RECORDINFO_IDX_START + 1), pNode = mIfrRecordListHead;
- (Idx != RecordIdx) && (pNode != NULL);
+ for (Idx = (EFI_IFR_RECORDINFO_IDX_START + 1), pNode = mIfrRecordListHead;
+ (Idx != RecordIdx) && (pNode != NULL);
Idx++, pNode = pNode->mNext)
;
@@ -547,8 +557,8 @@ CIfrRecordInfoDB::GetRecordInfoFromIdx (
UINT32
CIfrRecordInfoDB::IfrRecordRegister (
- IN UINT32 LineNo,
- IN CHAR8 *IfrBinBuf,
+ IN UINT32 LineNo,
+ IN CHAR8 *IfrBinBuf,
IN UINT8 BinBufLen,
IN UINT32 Offset
)
@@ -577,7 +587,7 @@ CIfrRecordInfoDB::IfrRecordRegister (
VOID
CIfrRecordInfoDB::IfrRecordInfoUpdate (
- IN UINT32 RecordIdx,
+ IN UINT32 RecordIdx,
IN UINT32 LineNo,
IN CHAR8 *BinBuf,
IN UINT8 BinBufLen,
@@ -585,23 +595,25 @@ CIfrRecordInfoDB::IfrRecordInfoUpdate (
)
{
SIfrRecord *pNode;
+ SIfrRecord *Prev;
if ((pNode = GetRecordInfoFromIdx (RecordIdx)) == NULL) {
return;
}
+ if (LineNo == 0) {
+ //
+ // Line number is not specified explicitly, try to use line number of previous opcode
+ //
+ Prev = GetRecordInfoFromIdx (RecordIdx - 1);
+ if (Prev != NULL) {
+ LineNo = Prev->mLineNo;
+ }
+ }
pNode->mLineNo = LineNo;
pNode->mOffset = Offset;
pNode->mBinBufLen = BinBufLen;
- if (BinBuf != NULL) {
- if (pNode->mIfrBinBuf != NULL) {
- delete pNode->mIfrBinBuf;
- }
- pNode->mIfrBinBuf = new CHAR8[BinBufLen];
- if (pNode->mIfrBinBuf != NULL) {
- memcpy (pNode->mIfrBinBuf, BinBuf, BinBufLen);
- }
- }
+ pNode->mIfrBinBuf = BinBuf;
}
VOID
@@ -626,7 +638,7 @@ CIfrRecordInfoDB::IfrRecordOutput (
fprintf (File, ">%08X: ", pNode->mOffset);
if (pNode->mIfrBinBuf != NULL) {
for (Index = 0; Index < pNode->mBinBufLen; Index++) {
- fprintf (File, "%02X ", pNode->mIfrBinBuf[Index]);
+ fprintf (File, "%02X ", (UINT8)(pNode->mIfrBinBuf[Index]));
}
}
fprintf (File, "\n");
@@ -650,6 +662,7 @@ CIfrObj::_EMIT_PENDING_OBJ (
if (mObjBinBuf != NULL) {
delete mObjBinBuf;
+ mObjBinBuf = ObjBinBuf;
}
}
@@ -689,7 +702,7 @@ static struct {
{ sizeof (EFI_IFR_DATE), 1 }, // EFI_IFR_DATE_OP
{ sizeof (EFI_IFR_TIME), 1 }, // EFI_IFR_TIME_OP
{ sizeof (EFI_IFR_STRING), 1 }, // EFI_IFR_STRING_OP
- { sizeof (EFI_IFR_REFRESH), 1 }, // EFI_IFR_REFRESH_OP
+ { sizeof (EFI_IFR_REFRESH), 0 }, // EFI_IFR_REFRESH_OP
{ sizeof (EFI_IFR_DISABLE_IF), 1 }, // EFI_IFR_DISABLE_IF_OP - 0x1E
{ 0, 0 }, // 0x1F
{ sizeof (EFI_IFR_TO_LOWER), 0 }, // EFI_IFR_TO_LOWER_OP - 0x20
@@ -829,10 +842,10 @@ CIfrObj::~CIfrObj (
UINT8 gScopeCount = 0;
CIfrOpHeader::CIfrOpHeader (
- IN UINT8 OpCode,
+ IN UINT8 OpCode,
IN VOID *StartAddr,
- IN UINT8 Length
- ) : mHeader ((EFI_IFR_OP_HEADER *)StartAddr)
+ IN UINT8 Length
+ ) : mHeader ((EFI_IFR_OP_HEADER *)StartAddr)
{
mHeader->OpCode = OpCode;
mHeader->Length = (Length == 0) ? gOpcodeSizesScopeTable[OpCode].mSize : Length;
diff --git a/EdkCompatibilityPkg/Sample/Tools/Source/UefiVfrCompile/VfrFormPkg.h b/EdkCompatibilityPkg/Sample/Tools/Source/UefiVfrCompile/VfrFormPkg.h
index b890b27a25..c8e7d98756 100644
--- a/EdkCompatibilityPkg/Sample/Tools/Source/UefiVfrCompile/VfrFormPkg.h
+++ b/EdkCompatibilityPkg/Sample/Tools/Source/UefiVfrCompile/VfrFormPkg.h
@@ -11,7 +11,7 @@ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
Module Name:
-VfrFormPkg.h
+ VfrFormPkg.h
Abstract:
@@ -25,6 +25,8 @@ Abstract:
#include "VfrError.h"
#include "VfrUtilityLib.h"
+#define NO_QST_REFED "no question refered"
+
/*
* The functions below are used for flags setting
*/
@@ -75,9 +77,10 @@ struct SPendingAssign {
UINT32 mLen;
ASSIGN_FLAG mFlag;
UINT32 mLineNo;
+ INT8 *mMsg;
struct SPendingAssign *mNext;
- SPendingAssign (IN INT8 *, IN VOID *, IN UINT32, IN UINT32);
+ SPendingAssign (IN INT8 *, IN VOID *, IN UINT32, IN UINT32, IN INT8 *);
~SPendingAssign ();
VOID SetAddrAndLen (IN VOID *, IN UINT32);
@@ -126,7 +129,7 @@ public:
EFI_VFR_RETURN_CODE GenCFile (IN INT8 *, IN FILE *);
public:
- EFI_VFR_RETURN_CODE AssignPending (IN INT8 *, IN VOID *, IN UINT32, IN UINT32);
+ EFI_VFR_RETURN_CODE AssignPending (IN INT8 *, IN VOID *, IN UINT32, IN UINT32, IN INT8 *Msg = NULL);
VOID DoPendingAssign (IN INT8 *, IN VOID *, IN UINT32);
bool HavePendingUnassigned (VOID);
VOID PendingAssignPrintAll (VOID);
@@ -368,48 +371,159 @@ public:
}
};
-static CIfrQuestionHeader *gCurrentQuestion = NULL;
-
/*
* The definition of CIfrMinMaxStepData
*/
class CIfrMinMaxStepData {
private:
MINMAXSTEP_DATA *mMinMaxStepData;
+ BOOLEAN ValueIsSet;
+ BOOLEAN IsNumeric;
public:
- CIfrMinMaxStepData (MINMAXSTEP_DATA *DataAddr) : mMinMaxStepData (DataAddr) {
+ CIfrMinMaxStepData (MINMAXSTEP_DATA *DataAddr, BOOLEAN NumericOpcode=FALSE) : mMinMaxStepData (DataAddr) {
mMinMaxStepData->u64.MinValue = 0;
mMinMaxStepData->u64.MaxValue = 0;
mMinMaxStepData->u64.Step = 0;
+ ValueIsSet = FALSE;
+ IsNumeric = NumericOpcode;
}
VOID SetMinMaxStepData (IN UINT64 MinValue, IN UINT64 MaxValue, IN UINT64 Step) {
- mMinMaxStepData->u64.MinValue = MinValue;
- mMinMaxStepData->u64.MaxValue = MaxValue;
- mMinMaxStepData->u64.Step = Step;
+ if (!ValueIsSet) {
+ mMinMaxStepData->u64.MinValue = MinValue;
+ mMinMaxStepData->u64.MaxValue = MaxValue;
+ ValueIsSet = TRUE;
+ } else {
+ if (MinValue < mMinMaxStepData->u64.MinValue) {
+ mMinMaxStepData->u64.MinValue = MinValue;
+ }
+ if (MaxValue > mMinMaxStepData->u64.MaxValue) {
+ mMinMaxStepData->u64.MaxValue = MaxValue;
+ }
+ }
+ mMinMaxStepData->u64.Step = Step;
}
VOID SetMinMaxStepData (IN UINT32 MinValue, IN UINT32 MaxValue, IN UINT32 Step) {
- mMinMaxStepData->u32.MinValue = MinValue;
- mMinMaxStepData->u32.MaxValue = MaxValue;
- mMinMaxStepData->u32.Step = Step;
+ if (!ValueIsSet) {
+ mMinMaxStepData->u32.MinValue = MinValue;
+ mMinMaxStepData->u32.MaxValue = MaxValue;
+ ValueIsSet = TRUE;
+ } else {
+ if (MinValue < mMinMaxStepData->u32.MinValue) {
+ mMinMaxStepData->u32.MinValue = MinValue;
+ }
+ if (MaxValue > mMinMaxStepData->u32.MaxValue) {
+ mMinMaxStepData->u32.MaxValue = MaxValue;
+ }
+ }
+ mMinMaxStepData->u32.Step = Step;
}
VOID SetMinMaxStepData (IN UINT16 MinValue, IN UINT16 MaxValue, IN UINT16 Step) {
- mMinMaxStepData->u16.MinValue = MinValue;
- mMinMaxStepData->u16.MaxValue = MaxValue;
- mMinMaxStepData->u16.Step = Step;
+ if (!ValueIsSet) {
+ mMinMaxStepData->u16.MinValue = MinValue;
+ mMinMaxStepData->u16.MaxValue = MaxValue;
+ ValueIsSet = TRUE;
+ } else {
+ if (MinValue < mMinMaxStepData->u16.MinValue) {
+ mMinMaxStepData->u16.MinValue = MinValue;
+ }
+ if (MaxValue > mMinMaxStepData->u16.MaxValue) {
+ mMinMaxStepData->u16.MaxValue = MaxValue;
+ }
+ }
+ mMinMaxStepData->u16.Step = Step;
}
VOID SetMinMaxStepData (IN UINT8 MinValue, IN UINT8 MaxValue, IN UINT8 Step) {
- mMinMaxStepData->u8.MinValue = MinValue;
- mMinMaxStepData->u8.MaxValue = MaxValue;
- mMinMaxStepData->u8.Step = Step;
+ if (!ValueIsSet) {
+ mMinMaxStepData->u8.MinValue = MinValue;
+ mMinMaxStepData->u8.MaxValue = MaxValue;
+ ValueIsSet = TRUE;
+ } else {
+ if (MinValue < mMinMaxStepData->u8.MinValue) {
+ mMinMaxStepData->u8.MinValue = MinValue;
+ }
+ if (MaxValue > mMinMaxStepData->u8.MaxValue) {
+ mMinMaxStepData->u8.MaxValue = MaxValue;
+ }
+ }
+ mMinMaxStepData->u8.Step = Step;
+ }
+
+ UINT64 GetMinData (UINT8 VarType) {
+ UINT64 MinValue = 0;
+ switch (VarType) {
+ case EFI_IFR_TYPE_NUM_SIZE_64:
+ MinValue = mMinMaxStepData->u64.MinValue;
+ break;
+ case EFI_IFR_TYPE_NUM_SIZE_32:
+ MinValue = (UINT64) mMinMaxStepData->u32.MinValue;
+ break;
+ case EFI_IFR_TYPE_NUM_SIZE_16:
+ MinValue = (UINT64) mMinMaxStepData->u16.MinValue;
+ break;
+ case EFI_IFR_TYPE_NUM_SIZE_8:
+ MinValue = (UINT64) mMinMaxStepData->u8.MinValue;
+ break;
+ default:
+ break;
+ }
+ return MinValue;
+ }
+
+ UINT64 GetMaxData (UINT8 VarType) {
+ UINT64 MaxValue = 0;
+ switch (VarType) {
+ case EFI_IFR_TYPE_NUM_SIZE_64:
+ MaxValue = mMinMaxStepData->u64.MaxValue;
+ break;
+ case EFI_IFR_TYPE_NUM_SIZE_32:
+ MaxValue = (UINT64) mMinMaxStepData->u32.MaxValue;
+ break;
+ case EFI_IFR_TYPE_NUM_SIZE_16:
+ MaxValue = (UINT64) mMinMaxStepData->u16.MaxValue;
+ break;
+ case EFI_IFR_TYPE_NUM_SIZE_8:
+ MaxValue = (UINT64) mMinMaxStepData->u8.MaxValue;
+ break;
+ default:
+ break;
+ }
+ return MaxValue;
+ }
+
+ UINT64 GetStepData (UINT8 VarType) {
+ UINT64 MaxValue = 0;
+ switch (VarType) {
+ case EFI_IFR_TYPE_NUM_SIZE_64:
+ MaxValue = mMinMaxStepData->u64.Step;
+ break;
+ case EFI_IFR_TYPE_NUM_SIZE_32:
+ MaxValue = (UINT64) mMinMaxStepData->u32.Step;
+ break;
+ case EFI_IFR_TYPE_NUM_SIZE_16:
+ MaxValue = (UINT64) mMinMaxStepData->u16.Step;
+ break;
+ case EFI_IFR_TYPE_NUM_SIZE_8:
+ MaxValue = (UINT64) mMinMaxStepData->u8.Step;
+ break;
+ default:
+ break;
+ }
+ return MaxValue;
}
+ BOOLEAN IsNumericOpcode () {
+ return IsNumeric;
+ }
};
+static CIfrQuestionHeader *gCurrentQuestion = NULL;
+static CIfrMinMaxStepData *gCurrentMinMaxData = NULL;
+
/*
* The definition of all of the UEFI IFR Objects
*/
@@ -418,10 +532,11 @@ private:
EFI_IFR_FORM_SET *mFormSet;
public:
- CIfrFormSet () : CIfrObj (EFI_IFR_FORM_SET_OP, (CHAR8 **)&mFormSet),
- CIfrOpHeader (EFI_IFR_FORM_SET_OP, &mFormSet->Header) {
+ CIfrFormSet (UINT8 Size) : CIfrObj (EFI_IFR_FORM_SET_OP, (CHAR8 **)&mFormSet, Size),
+ CIfrOpHeader (EFI_IFR_FORM_SET_OP, &mFormSet->Header, Size) {
mFormSet->Help = EFI_STRING_ID_INVALID;
mFormSet->FormSetTitle = EFI_STRING_ID_INVALID;
+ mFormSet->Flags = 0;
memset (&mFormSet->Guid, 0, sizeof (EFI_GUID));
}
@@ -436,6 +551,17 @@ public:
VOID SetHelp (IN EFI_STRING_ID Help) {
mFormSet->Help = Help;
}
+
+ VOID SetClassGuid (IN EFI_GUID *Guid) {
+ if (mFormSet->Flags > 0 && ExpendObjBin(sizeof(EFI_GUID))) {
+ IncLength (sizeof (EFI_GUID));
+ }
+ memcpy (&(mFormSet->ClassGuid[mFormSet->Flags++]), Guid, sizeof (EFI_GUID));
+ }
+
+ UINT8 GetFlags() {
+ return mFormSet->Flags;
+ }
};
class CIfrEnd : public CIfrObj, public CIfrOpHeader {
@@ -817,7 +943,7 @@ private:
public:
CIfrResetButton () : CIfrObj (EFI_IFR_RESET_BUTTON_OP, (CHAR8 **)&mResetButton),
CIfrOpHeader (EFI_IFR_RESET_BUTTON_OP, &mResetButton->Header),
- CIfrStatementHeader (&mResetButton->Question.Header) {
+ CIfrStatementHeader (&mResetButton->Statement) {
mResetButton->DefaultId = EFI_HII_DEFAULT_CLASS_STANDARD;
}
@@ -834,7 +960,7 @@ public:
CIfrCheckBox () : CIfrObj (EFI_IFR_CHECKBOX_OP, (CHAR8 **)&mCheckBox),
CIfrOpHeader (EFI_IFR_CHECKBOX_OP, &mCheckBox->Header),
CIfrQuestionHeader (&mCheckBox->Question) {
- mCheckBox->Flags = EFI_IFR_CHECKBOX_DEFAULT;
+ mCheckBox->Flags = 0;
gCurrentQuestion = this;
}
@@ -860,6 +986,10 @@ public:
return _FLAGS_ZERO (LFlags) ? VFR_RETURN_SUCCESS : VFR_RETURN_FLAGS_UNSUPPORTED;
}
+
+ UINT8 GetFlags (VOID) {
+ return mCheckBox->Flags;
+ }
};
class CIfrAction : public CIfrObj, public CIfrOpHeader, public CIfrQuestionHeader {
@@ -929,13 +1059,15 @@ public:
CIfrNumeric () : CIfrObj (EFI_IFR_NUMERIC_OP, (CHAR8 **)&mNumeric),
CIfrOpHeader (EFI_IFR_NUMERIC_OP, &mNumeric->Header),
CIfrQuestionHeader (&mNumeric->Question),
- CIfrMinMaxStepData (&mNumeric->data) {
+ CIfrMinMaxStepData (&mNumeric->data, TRUE) {
mNumeric->Flags = EFI_IFR_NUMERIC_SIZE_1 | EFI_IFR_DISPLAY_UINT_DEC;
- gCurrentQuestion = this;
+ gCurrentQuestion = this;
+ gCurrentMinMaxData = this;
}
~CIfrNumeric () {
- gCurrentQuestion = NULL;
+ gCurrentQuestion = NULL;
+ gCurrentMinMaxData = NULL;
}
EFI_VFR_RETURN_CODE SetFlags (IN UINT8 HFlags, IN UINT8 LFlags) {
@@ -965,11 +1097,13 @@ public:
CIfrQuestionHeader (&mOneOf->Question),
CIfrMinMaxStepData (&mOneOf->data) {
mOneOf->Flags = 0;
- gCurrentQuestion = this;
+ gCurrentQuestion = this;
+ gCurrentMinMaxData = this;
}
~CIfrOneOf () {
- gCurrentQuestion = NULL;
+ gCurrentQuestion = NULL;
+ gCurrentMinMaxData = NULL;
}
EFI_VFR_RETURN_CODE SetFlags (IN UINT8 HFlags, IN UINT8 LFlags) {
@@ -1428,7 +1562,7 @@ public:
if (QuestionId != EFI_QUESTION_ID_INVALID) {
mEqIdId->QuestionId1 = QuestionId;
} else {
- gCFormPkg.AssignPending (VarIdStr, (VOID *)(&mEqIdId->QuestionId1), sizeof (EFI_QUESTION_ID), LineNo);
+ gCFormPkg.AssignPending (VarIdStr, (VOID *)(&mEqIdId->QuestionId1), sizeof (EFI_QUESTION_ID), LineNo, NO_QST_REFED);
}
}
@@ -1440,7 +1574,7 @@ public:
if (QuestionId != EFI_QUESTION_ID_INVALID) {
mEqIdId->QuestionId2 = QuestionId;
} else {
- gCFormPkg.AssignPending (VarIdStr, (VOID *)(&mEqIdId->QuestionId2), sizeof (EFI_QUESTION_ID), LineNo);
+ gCFormPkg.AssignPending (VarIdStr, (VOID *)(&mEqIdId->QuestionId2), sizeof (EFI_QUESTION_ID), LineNo, NO_QST_REFED);
}
}
};
@@ -1466,7 +1600,7 @@ public:
if (QuestionId != EFI_QUESTION_ID_INVALID) {
mEqIdVal->QuestionId = QuestionId;
} else {
- gCFormPkg.AssignPending (VarIdStr, (VOID *)(&mEqIdVal->QuestionId), sizeof (EFI_QUESTION_ID), LineNo);
+ gCFormPkg.AssignPending (VarIdStr, (VOID *)(&mEqIdVal->QuestionId), sizeof (EFI_QUESTION_ID), LineNo, NO_QST_REFED);
}
}
@@ -1498,7 +1632,7 @@ public:
if (QuestionId != EFI_QUESTION_ID_INVALID) {
mEqIdVList->QuestionId = QuestionId;
} else {
- gCFormPkg.AssignPending (VarIdStr, (VOID *)(&mEqIdVList->QuestionId), sizeof (EFI_QUESTION_ID), LineNo);
+ gCFormPkg.AssignPending (VarIdStr, (VOID *)(&mEqIdVList->QuestionId), sizeof (EFI_QUESTION_ID), LineNo, NO_QST_REFED);
}
}
@@ -1540,7 +1674,7 @@ public:
if (QuestionId != EFI_QUESTION_ID_INVALID) {
mQuestionRef1->QuestionId = QuestionId;
} else {
- gCFormPkg.AssignPending (VarIdStr, (VOID *)(&mQuestionRef1->QuestionId), sizeof (EFI_QUESTION_ID), LineNo);
+ gCFormPkg.AssignPending (VarIdStr, (VOID *)(&mQuestionRef1->QuestionId), sizeof (EFI_QUESTION_ID), LineNo, NO_QST_REFED);
}
}
};
diff --git a/EdkCompatibilityPkg/Sample/Tools/Source/UefiVfrCompile/VfrSyntax.g b/EdkCompatibilityPkg/Sample/Tools/Source/UefiVfrCompile/VfrSyntax.g
index 1a31b2e41d..85060c8e84 100644
--- a/EdkCompatibilityPkg/Sample/Tools/Source/UefiVfrCompile/VfrSyntax.g
+++ b/EdkCompatibilityPkg/Sample/Tools/Source/UefiVfrCompile/VfrSyntax.g
@@ -29,7 +29,7 @@ Abstract:
#include "stdio.h"
#include "PBlackBox.h"
#include "DLexerBase.h"
-#include "VfrLexer.h"
+#include "VfrLexer.h"
#include "AToken.h"
#define GET_LINENO(Obj) ((Obj)->getLine())
@@ -42,9 +42,9 @@ class CVfrDLGLexer : public VfrLexer
{
public:
CVfrDLGLexer (DLGFileInput *F) : VfrLexer (F) {};
- INT32 errstd (char *Text)
- {
- printf ("unrecognized input '%s'\n", Text);
+ INT32 errstd (char *Text)
+ {
+ printf ("unrecognized input '%s'\n", Text);
}
};
@@ -70,7 +70,7 @@ VfrParserStart (
// is not preceeded with a backslash.
//
#lexclass QUOTED_STRING
-#token TheString "~[\"]*\"" << mode (START); >>
+#token TheString "~[\"]*\"" << mode (START); >>
//
// Define a lexclass for skipping over C++ style comments
@@ -92,7 +92,7 @@ VfrParserStart (
//
// Skip whitespace
//
-#token "[\ \t]" << skip (); >>
+#token "[\ \t]" << skip (); >>
//
// Skip over newlines, but count them
@@ -128,13 +128,12 @@ VfrParserStart (
#token Title("title") "title"
#token FormId("formid") "formid"
#token OneOf("oneof") "oneof"
-#token EndoneOf("endoneof") "endoneof"
+#token EndOneOf("endoneof") "endoneof"
#token Prompt("prompt") "prompt"
#token OrderedList("orderedlist") "orderedlist"
#token MaxContainers("maxcontainers") "maxcontainers"
#token EndList("endlist") "endlist"
#token EndForm("endform") "endform"
-#token EndOneOf("endoneof") "endoneof"
#token Form("form") "form"
#token Subtitle("subtitle") "subtitle"
#token Help("help") "help"
@@ -157,26 +156,27 @@ VfrParserStart (
#token Inventory("inventory") "inventory"
#token NonNvDataMap("_NON_NV_DATA_MAP") "_NON_NV_DATA_MAP"
#token Struct("struct") "struct"
+#token Boolean("BOOLEAN") "BOOLEAN"
#token Uint64("UINT64") "UINT64"
#token Uint32("UINT32") "UINT32"
#token Uint16("UINT16") "UINT16"
#token Char16("CHAR16") "CHAR16"
#token Uint8("UINT8") "UINT8"
-#token GUID("guid") "guid"
+#token Uuid("guid") "guid"
#token CheckBox("checkbox") "checkbox"
#token EndCheckBox("endcheckbox") "endcheckbox"
#token Numeric("numeric") "numeric"
-#token EndNumeric("endnumeric") "endnumeric"
-#token Minimum("minimum") "minimum"
-#token Maximum("maximum") "maximum"
-#token STEP("step") "step"
-#token Default("default") "default"
-#token Password("password") "password"
-#token EndPassword("endpassword") "endpassword"
+#token EndNumeric("endnumeric") "endnumeric"
+#token Minimum("minimum") "minimum"
+#token Maximum("maximum") "maximum"
+#token STEP("step") "step"
+#token Default("default") "default"
+#token Password("password") "password"
+#token EndPassword("endpassword") "endpassword"
#token String("string") "string"
-#token EndString("endstring") "endstring"
-#token MinSize("minsize") "minsize"
-#token MaxSize("maxsize") "maxsize"
+#token EndString("endstring") "endstring"
+#token MinSize("minsize") "minsize"
+#token MaxSize("maxsize") "maxsize"
#token Encoding("encoding") "encoding"
#token SuppressIf("suppressif") "suppressif"
#token DisableIf("disableif") "disableif"
@@ -198,6 +198,7 @@ VfrParserStart (
#token OptionOnlyFlag("OPTIONS_ONLY") "OPTIONS_ONLY"
#token Class("class") "class"
#token Subclass("subclass") "subclass"
+#token ClassGuid("classguid") "classguid"
#token TypeDef("typedef") "typedef"
#token Restore("restore") "restore"
#token Save("save") "save"
@@ -253,36 +254,71 @@ VfrParserStart (
//
vfrProgram > [UINT8 Return] :
- << mParserStatus = 0; >>
+ <<
+ mParserStatus = 0;
+ mConstantOnlyInExpression = FALSE;
+ >>
(
- (
- "\#pragma" "pack" "\(" A:Number "\)" << _PCATCH(mCVfrVarDataTypeDB.Pack (_STOU32(A->getText())), A); >>
- vfrDataStructDefinition
- "\#pragma" "pack" "\(" "\)" << mCVfrVarDataTypeDB.UnPack (); >>
- )
- |
- (
- vfrDataStructDefinition
- )
+ vfrPragmaPackDefinition
+ | vfrDataStructDefinition
)*
- vfrFromSetDefinition
+ vfrFormSetDefinition
<< $Return = mParserStatus; >>
;
-//*****************************************************************************
-//
-// the syntax of data struct definition
-//
+pragmaPackShowDef :
+ L:"show" << mCVfrVarDataTypeDB.Pack (L->getLine(), VFR_PACK_SHOW); >>
+ ;
+
+pragmaPackStackDef :
+ <<
+ 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); >>
+ ;
+
+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 :
{ TypeDef } Struct << mCVfrVarDataTypeDB.DeclareDataTypeBegin (); >>
- { NonNVDataMap }
+ { NonNvDataMap }
{
N1:StringIdentifier << _PCATCH(mCVfrVarDataTypeDB.SetNewTypeName (N1->getText()), N1); >>
}
- OpenBrace
+ OpenBrace
vfrDataStructFields
- CloseBrace
- {
+ CloseBrace
+ {
N2:StringIdentifier << _PCATCH(mCVfrVarDataTypeDB.SetNewTypeName (N2->getText()), N2); >>
}
";" << mCVfrVarDataTypeDB.DeclareDataTypeEnd (); >>
@@ -290,13 +326,13 @@ vfrDataStructDefinition :
vfrDataStructFields :
(
- dataStructField64 |
- dataStructField32 |
- dataStructField16 |
- dataStructField8 |
+ dataStructField64 |
+ dataStructField32 |
+ dataStructField16 |
+ dataStructField8 |
dataStructFieldBool |
dataStructFieldString |
- dataStructFieldDate |
+ dataStructFieldDate |
dataStructFieldTime |
dataStructFieldUser
)*
@@ -304,8 +340,8 @@ vfrDataStructFields :
dataStructField64 :
<< UINT32 ArrayNum = 0; >>
- "UINT64"
- N:StringIdentifier
+ "UINT64"
+ N:StringIdentifier
{
OpenBracket I:Number CloseBracket << ArrayNum = _STOU32(I->getText()); >>
}
@@ -314,8 +350,8 @@ dataStructField64 :
dataStructField32 :
<< UINT32 ArrayNum = 0; >>
- "UINT32"
- N:StringIdentifier
+ "UINT32"
+ N:StringIdentifier
{
OpenBracket I:Number CloseBracket << ArrayNum = _STOU32(I->getText()); >>
}
@@ -325,7 +361,7 @@ dataStructField32 :
dataStructField16 :
<< UINT32 ArrayNum = 0; >>
("UINT16" | "CHAR16")
- N:StringIdentifier
+ N:StringIdentifier
{
OpenBracket I:Number CloseBracket << ArrayNum = _STOU32(I->getText()); >>
}
@@ -335,7 +371,7 @@ dataStructField16 :
dataStructField8 :
<< UINT32 ArrayNum = 0; >>
"UINT8"
- N:StringIdentifier
+ N:StringIdentifier
{
OpenBracket I:Number CloseBracket << ArrayNum = _STOU32(I->getText()); >>
}
@@ -345,7 +381,7 @@ dataStructField8 :
dataStructFieldBool :
<< UINT32 ArrayNum = 0; >>
"BOOLEAN"
- N:StringIdentifier
+ N:StringIdentifier
{
OpenBracket I:Number CloseBracket << ArrayNum = _STOU32(I->getText()); >>
}
@@ -355,7 +391,7 @@ dataStructFieldBool :
dataStructFieldString :
<< UINT32 ArrayNum = 0; >>
"EFI_STRING_ID"
- N:StringIdentifier
+ N:StringIdentifier
{
OpenBracket I:Number CloseBracket << ArrayNum = _STOU32(I->getText()); >>
}
@@ -364,8 +400,8 @@ dataStructFieldString :
dataStructFieldDate :
<< UINT32 ArrayNum = 0; >>
- "EFI_HII_DATE"
- N:StringIdentifier
+ "EFI_HII_DATE"
+ N:StringIdentifier
{
OpenBracket I:Number CloseBracket << ArrayNum = _STOU32(I->getText()); >>
}
@@ -374,8 +410,8 @@ dataStructFieldDate :
dataStructFieldTime :
<< UINT32 ArrayNum = 0; >>
- "EFI_HII_TIME"
- N:StringIdentifier
+ "EFI_HII_TIME"
+ N:StringIdentifier
{
OpenBracket I:Number CloseBracket << ArrayNum = _STOU32(I->getText()); >>
}
@@ -394,30 +430,89 @@ dataStructFieldUser :
//*****************************************************************************
//
-// the syntax of from set definition
+// the syntax of GUID definition
//
-vfrFromSetDefinition :
+guidSubDefinition [EFI_GUID &Guid] :
+ G4:Number "," G5:Number "," G6:Number "," G7:Number "," G8:Number "," G9:Number "," G10:Number "," G11:Number
+ <<
+ Guid.Data4[0] = _STOU8(G4->getText());
+ Guid.Data4[1] = _STOU8(G5->getText());
+ Guid.Data4[2] = _STOU8(G6->getText());
+ 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());
+ >>
+ ;
+
+guidDefinition [EFI_GUID &Guid] :
+ OpenBrace
+ G1:Number "," G2:Number "," G3:Number ","
+ <<
+ Guid.Data1 = _STOU32 (G1->getText());
+ Guid.Data2 = _STOU16 (G2->getText());
+ Guid.Data3 = _STOU16 (G3->getText());
+ >>
+ (
+ OpenBrace guidSubDefinition[Guid] CloseBrace
+ | guidSubDefinition[Guid]
+ )
+ CloseBrace
+ ;
+
+//*****************************************************************************
+//
+// the syntax of form set definition
+//
+vfrFormSetDefinition :
<<
EFI_GUID Guid;
- CIfrFormSet FSObj;
- UINT16 C, SC;
+ EFI_GUID DefaultClassGuid = EFI_HII_PLATFORM_SETUP_FORMSET_GUID;
+ EFI_GUID ClassGuids[10];
+ UINT8 ClassGuidNum = 0;
+ CIfrFormSet *FSObj = NULL;
+ UINT16 C, SC;
>>
- L:FormSet << SET_LINE_INFO (FSObj, L); >>
- GUID "="
- OpenBrace
- G1:Number "," G2:Number "," G3:Number "," G4:Number "," G5:Number "," G6:Number ","
- G7:Number "," G8:Number "," G9:Number "," G10:Number "," G11:Number
- CloseBrace
- <<
- _CRGUID (&Guid, G1->getText (), G2->getText (), G3->getText (),
- G4->getText (), G5->getText (), G6->getText (),
- G7->getText (), G8->getText (), G9->getText (),
- G10->getText (), G11->getText ());
- FSObj.SetGuid (&Guid);
- >>
- ","
- Title "=" "STRING_TOKEN" "\(" S1:Number "\)" "," << FSObj.SetFormSetTitle (_STOSID(S1->getText())); >>
- Help "=" "STRING_TOKEN" "\(" S2:Number "\)" "," << FSObj.SetHelp (_STOSID(S2->getText())); >>
+ L:FormSet
+ Uuid "=" guidDefinition[Guid] ","
+ Title "=" "STRING_TOKEN" "\(" S1:Number "\)" ","
+ Help "=" "STRING_TOKEN" "\(" S2:Number "\)" ","
+ {
+ ClassGuid "=" guidDefinition[ClassGuids[ClassGuidNum]] << ++ClassGuidNum; >>
+ (
+ "\|" guidDefinition[ClassGuids[ClassGuidNum]] << ++ClassGuidNum; >>
+ )*
+ ","
+ }
+ <<
+ 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()));
+ FSObj->SetHelp (_STOSID(S2->getText()));
+ >>
{
Class "=" classDefinition[C] "," << {CIfrClass CObj; CObj.SetClass(C);} >>
}
@@ -429,7 +524,7 @@ vfrFromSetDefinition :
//_DeclareDefaultLinearVarStore (GET_LINENO (L));
>>
vfrFormSetList
- E:EndFormSet << CRT_END_OP (E); >>
+ E:EndFormSet << CRT_END_OP (E); if (FSObj != NULL) {delete FSObj;}>>
";"
;
@@ -441,7 +536,7 @@ vfrFormSetList :
vfrStatementVarStoreEfi |
vfrStatementVarStoreNameValue |
vfrStatementDefaultStore |
- vfrStatementDisableIfFromSet
+ vfrStatementDisableIfFormSet
)*
;
@@ -452,7 +547,7 @@ vfrStatementDefaultStore :
{
"," Attribute "=" A:Number << DefaultId = _STOU16(A->getText()); >>
}
- <<
+ <<
if (mCVfrDefaultStore.DefaultIdRegistered (DefaultId) == FALSE) {
CIfrDefaultStore DSObj;
_PCATCH(mCVfrDefaultStore.RegisterDefaultStore (DSObj.GetObjBinAddr(), N->getText(), _STOSID(S->getText()), DefaultId)), D->getLine();
@@ -468,7 +563,7 @@ vfrStatementDefaultStore :
vfrStatementVarStoreLinear :
<<
- EFI_GUID Guid;
+ EFI_GUID Guid;
CIfrVarStore VSObj;
INT8 *TypeName;
UINT32 LineNum;
@@ -487,31 +582,28 @@ vfrStatementVarStoreLinear :
)
{ Key "=" Number "," } // Key is used to assign Varid in Framework VFR but no use in UEFI2.1 VFR
{
- VarId "=" ID:Number "," << VarStoreId = _STOU16(ID->getText()); >>
+ VarId "=" ID:Number "," <<
+ _PCATCH(
+ (INTN)(VarStoreId = _STOU16(ID->getText())) != 0,
+ (INTN)TRUE,
+ ID,
+ "varid 0 is not allowed."
+ );
+ >>
}
Name "=" SN:StringIdentifier ","
- GUID "="
- OpenBrace
- G1:Number "," G2:Number "," G3:Number "," G4:Number "," G5:Number "," G6:Number ","
- G7:Number "," G8:Number "," G9:Number "," G10:Number "," G11:Number
- CloseBrace
- <<
- _CRGUID (&Guid, G1->getText (), G2->getText (), G3->getText (),
- G4->getText (), G5->getText (), G6->getText (),
- G7->getText (), G8->getText (), G9->getText (),
- G10->getText (), G11->getText ());
- >>
+ Uuid "=" guidDefinition[Guid]
<<
_PCATCH(mCVfrDataStorage.DeclareBufferVarStore (
- SN->getText(),
- &Guid,
- &mCVfrVarDataTypeDB,
+ SN->getText(),
+ &Guid,
+ &mCVfrVarDataTypeDB,
TypeName,
VarStoreId
), LineNum);
>>
- <<
- VSObj.SetGuid (&Guid);
+ <<
+ VSObj.SetGuid (&Guid);
_PCATCH(mCVfrDataStorage.GetVarStoreId(SN->getText(), &VarStoreId), SN);
VSObj.SetVarStoreId (VarStoreId);
_PCATCH(mCVfrVarDataTypeDB.GetDataTypeSize(TypeName, &Size), LineNum);
@@ -534,22 +626,11 @@ vfrStatementVarStoreEfi :
<< VSEObj.SetAttributes (Attr); >>
Name "=" "STRING_TOKEN" "\(" VN:Number "\)" ","
VarSize "=" N:Number ","
- GUID "="
- OpenBrace
- G1:Number "," G2:Number "," G3:Number "," G4:Number "," G5:Number "," G6:Number ","
- G7:Number "," G8:Number "," G9:Number "," G10:Number "," G11:Number
- CloseBrace
- <<
- _CRGUID (&Guid, G1->getText (), G2->getText (), G3->getText (),
- G4->getText (), G5->getText (), G6->getText (),
- G7->getText (), G8->getText (), G9->getText (),
- G10->getText (), G11->getText ());
- >>
- << mCVfrDataStorage.DeclareEfiVarStore (SN->getText(), &Guid, _STOSID(VN->getText()), _STOU32(N->getText())); >>
- <<
+ Uuid "=" guidDefinition[Guid] << mCVfrDataStorage.DeclareEfiVarStore (SN->getText(), &Guid, _STOSID(VN->getText()), _STOU32(N->getText())); >>
+ <<
VSEObj.SetGuid (&Guid);
_PCATCH(mCVfrDataStorage.GetVarStoreId(SN->getText(), &VarStoreId), SN);
- VSEObj.SetVarStoreId (VarStoreId);
+ VSEObj.SetVarStoreId (VarStoreId);
>>
";"
;
@@ -560,7 +641,7 @@ vfrVarStoreEfiAttr [UINT32 & Attr] :
vfrStatementVarStoreNameValue :
<<
- EFI_GUID Guid;
+ EFI_GUID Guid;
CIfrVarStoreNameValue VSNVObj;
EFI_VARSTORE_ID VarStoreId;
>>
@@ -569,22 +650,11 @@ vfrStatementVarStoreNameValue :
(
Name "=" "STRING_TOKEN" "\(" N:Number "\)" "," << _PCATCH(mCVfrDataStorage.NameTableAddItem (_STOSID(N->getText())), SN); >>
)+
- GUID "="
- OpenBrace
- G1:Number "," G2:Number "," G3:Number "," G4:Number "," G5:Number "," G6:Number ","
- G7:Number "," G8:Number "," G9:Number "," G10:Number "," G11:Number
- CloseBrace
- <<
- _CRGUID (&Guid, G1->getText (), G2->getText (), G3->getText (),
- G4->getText (), G5->getText (), G6->getText (),
- G7->getText (), G8->getText (), G9->getText (),
- G10->getText (), G11->getText ());
- >>
- << _PCATCH(mCVfrDataStorage.DeclareNameVarStoreEnd (&Guid), SN); >>
- <<
+ Uuid "=" guidDefinition[Guid] << _PCATCH(mCVfrDataStorage.DeclareNameVarStoreEnd (&Guid), SN); >>
+ <<
VSNVObj.SetGuid (&Guid);
_PCATCH(mCVfrDataStorage.GetVarStoreId(SN->getText(), &VarStoreId), SN);
- VSNVObj.SetVarStoreId (VarStoreId);
+ VSNVObj.SetVarStoreId (VarStoreId);
>>
";"
;
@@ -597,7 +667,7 @@ classDefinition[UINT16 & Class] :
<< $Class = 0; >>
validClassNames[$Class] ( "\|" validClassNames[$Class] )*
;
-
+
validClassNames[UINT16 & Class] :
ClassNonDevice << $Class |= EFI_NON_DEVICE_CLASS; >>
| ClassDiskDevice << $Class |= EFI_DISK_DEVICE_CLASS; >>
@@ -618,10 +688,13 @@ subclassDefinition[UINT16 & SubClass] :
| N:Number << $SubClass |= _STOU16(N->getText()); >>
;
-vfrStatementDisableIfFromSet :
- << CIfrDisableIf DIObj; >>
+vfrStatementDisableIfFormSet :
+ <<
+ CIfrDisableIf DIObj;
+ UINT32 ExpOpCount = 0;
+ >>
D:DisableIf << DIObj.SetLineNo(D->getLine()); >>
- vfrStatementExpression[0] ";"
+ vfrStatementExpression[0, ExpOpCount] ";" << mConstantOnlyInExpression = FALSE; >>
vfrFormSetList
E:EndIf << CRT_END_OP (E); >>
";"
@@ -638,7 +711,7 @@ vfrStatementHeader[CIfrStatementHeader *SHObj] :
vfrQuestionHeader[CIfrQuestionHeader & QHObj, EFI_QUESION_TYPE QType = QUESTION_NORMAL]:
<<
- EFI_VARSTORE_INFO Info;
+ EFI_VARSTORE_INFO Info;
EFI_QUESTION_ID QId = EFI_QUESTION_ID_INVALID;
INT8 *QName = NULL;
INT8 *VarIdStr = NULL;
@@ -653,10 +726,10 @@ vfrQuestionHeader[CIfrQuestionHeader & QHObj, EFI_QUESION_TYPE QType = QUESTION_
{
QuestionId "=" ID:Number "," <<
QId = _STOQID(ID->getText());
- _PCATCH(mCVfrQuestionDB.FindQuestion (QId), VFR_RETURN_UNDEFINED, ID, "has already been used please assign another number");
+ _PCATCH(mCVfrQuestionDB.FindQuestion (QId), VFR_RETURN_UNDEFINED, ID, "has already been used please assign another number");
>>
}
- <<
+ <<
switch (QType) {
case QUESTION_NORMAL:
mCVfrQuestionDB.RegisterQuestion (QName, VarIdStr, QId);
@@ -692,10 +765,10 @@ vfrQuestionHeaderWithNoStorage[CIfrQuestionHeader *QHObj] :
{
QuestionId "=" ID:Number "," <<
QId = _STOQID(ID->getText());
- _PCATCH(mCVfrQuestionDB.FindQuestion (QId), VFR_RETURN_UNDEFINED, ID, "redefined quesiont ID");
+ _PCATCH(mCVfrQuestionDB.FindQuestion (QId), VFR_RETURN_UNDEFINED, ID, "redefined quesiont ID");
>>
}
- <<
+ <<
mCVfrQuestionDB.RegisterQuestion (QName, NULL, QId);
$QHObj->SetQuestionId (QId);
>>
@@ -718,13 +791,14 @@ vfrStorageVarId[EFI_VARSTORE_INFO & Info, INT8 *&QuestVarIdStr] :
INT8 *VarStr = NULL;
INT8 *SName = NULL;
INT8 *TName = NULL;
+ EFI_IFR_TYPE_VALUE Dummy = {0};
>>
(
SN1:StringIdentifier << SName = SN1->getText(); _STRCAT(&VarIdStr, SN1->getText()); >>
OpenBracket I1:Number CloseBracket << Idx = _STOU32(I1->getText()); _STRCAT(&VarIdStr, "["); _STRCAT(&VarIdStr, I1->getText()); _STRCAT(&VarIdStr, "]"); >>
<<
_PCATCH(mCVfrDataStorage.GetVarStoreType (SName, VarStoreType), SN1);
- _PCATCH(mCVfrDataStorage.GetVarStoreId (SName, &$Info.mVarStoreId), SN1);
+ _PCATCH(mCVfrDataStorage.GetVarStoreId (SName, &$Info.mVarStoreId), SN1);
_PCATCH(mCVfrDataStorage.GetNameVarStoreInfo (&$Info, Idx), SN1);
>>
)
@@ -739,7 +813,7 @@ vfrStorageVarId[EFI_VARSTORE_INFO & Info, INT8 *&QuestVarIdStr] :
_STRCAT(&VarStr, TName);
}
>>
-
+
(
"." <<
_PCATCH(((VarStoreType != EFI_VFR_VARSTORE_BUFFER) ? VFR_RETURN_EFIVARSTORE_USE_ERROR : VFR_RETURN_SUCCESS), SN2);
@@ -750,7 +824,7 @@ vfrStorageVarId[EFI_VARSTORE_INFO & Info, INT8 *&QuestVarIdStr] :
OpenBracket I2:Number CloseBracket << _STRCAT(&VarIdStr, "["); _STRCAT(&VarIdStr, I2->getText()); _STRCAT(&VarIdStr, "]"); >>
<< _STRCAT(&VarStr, "["); _STRCAT(&VarStr, I2->getText()); _STRCAT(&VarStr, "]"); >>
}
- )* <<
+ )* <<
switch (VarStoreType) {
case EFI_VFR_VARSTORE_EFI:
_PCATCH(mCVfrDataStorage.GetEfiVarStoreInfo (&$Info), SN2);
@@ -758,6 +832,19 @@ vfrStorageVarId[EFI_VARSTORE_INFO & Info, INT8 *&QuestVarIdStr] :
case EFI_VFR_VARSTORE_BUFFER:
_PCATCH(mCVfrVarDataTypeDB.GetDataFieldInfo (VarStr, $Info.mInfo.mVarOffset, $Info.mVarType, $Info.mVarTotalSize), SN2->getLine());
//_PCATCH(mCVfrDataStorage.BufferVarStoreRequestElementAdd (SName, Info), SN2);
+ _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;
case EFI_VFR_VARSTORE_NAME:
default: break;
@@ -775,7 +862,11 @@ vfrQuestionDataFieldName [EFI_QUESTION_ID &QId, UINT32 &Mask, INT8 *&VarIdStr, U
SN1:StringIdentifier << _STRCAT(&VarIdStr, SN1->getText()); LineNo = SN1->getLine(); >>
OpenBracket I1:Number CloseBracket << _STRCAT(&VarIdStr, "["); _STRCAT(&VarIdStr, I1->getText()); _STRCAT(&VarIdStr, "]"); >>
<< mCVfrQuestionDB.GetQuestionId (NULL, VarIdStr, $QId, $Mask); >>
- )
+ ) <<
+ if (mConstantOnlyInExpression) {
+ _PCATCH(VFR_RETURN_CONSTANT_ONLY, LineNo);
+ }
+ >>
|
(
SN2:StringIdentifier << _STRCAT (&VarIdStr, SN2->getText()); LineNo = SN2->getLine(); >>
@@ -787,11 +878,15 @@ vfrQuestionDataFieldName [EFI_QUESTION_ID &QId, UINT32 &Mask, INT8 *&VarIdStr, U
}
)*
<< mCVfrQuestionDB.GetQuestionId (NULL, VarIdStr, $QId, $Mask); >>
- )
+ ) <<
+ if (mConstantOnlyInExpression) {
+ _PCATCH(VFR_RETURN_CONSTANT_ONLY, LineNo);
+ }
+ >>
;
vfrConstantValueField[UINT8 Type] > [EFI_IFR_TYPE_VALUE Value] :
- N1:Number <<
+ N1:Number <<
switch ($Type) {
case EFI_IFR_TYPE_NUM_SIZE_8 :
$Value.u8 = _STOU8(N1->getText());
@@ -815,7 +910,7 @@ vfrConstantValueField[UINT8 Type] > [EFI_IFR_TYPE_VALUE Value] :
case EFI_IFR_TYPE_DATE :
default :
break;
- }
+ }
>>
| B1:True << $Value.b = TRUE; >>
| B2:False << $Value.b = FALSE; >>
@@ -845,7 +940,7 @@ vfrFormDefinition :
vfrStatementQuestions |
vfrStatementConditional |
vfrStatementLabel |
- vfrStatementBanner
+ vfrStatementBanner
// Just for framework vfr compatibility
//vfrStatementInvalid
)*
@@ -853,14 +948,17 @@ vfrFormDefinition :
";"
;
-vfrStatementRules :
- << CIfrRule RObj; >>
+vfrStatementRules :
+ <<
+ CIfrRule RObj;
+ UINT32 ExpOpCount = 0;
+ >>
R:Rule << RObj.SetLineNo(R->getLine()); >>
S1:StringIdentifier "," <<
mCVfrRulesDB.RegisterRule (S1->getText());
- RObj.SetRuleId (mCVfrRulesDB.GetRuleId(S1->getText()));
+ RObj.SetRuleId (mCVfrRulesDB.GetRuleId(S1->getText()));
>>
- vfrStatementExpression[0]
+ vfrStatementExpression[0, ExpOpCount]
E:EndRule << CRT_END_OP (E); >>
";"
;
@@ -868,7 +966,7 @@ vfrStatementRules :
vfrStatementDefault :
<<
BOOLEAN IsExp = FALSE;
- EFI_IFR_TYPE_VALUE Val;
+ EFI_IFR_TYPE_VALUE Val = {0};
CIfrDefault DObj;
EFI_DEFAULT_ID DefaultId = EFI_HII_DEFAULT_CLASS_STANDARD;
INT8 *VarStoreName = NULL;
@@ -877,30 +975,40 @@ vfrStatementDefault :
D:Default << DObj.SetLineNo(D->getLine()); >>
(
(
- vfrStatementValue "," << IsExp = TRUE; DObj.SetScope (1); >>
- | "=" vfrConstantValueField[_GET_CURRQEST_DATATYPE()] > [Val] ","
- << DObj.SetType (_GET_CURRQEST_DATATYPE()); DObj.SetValue(Val); >>
+ vfrStatementValue "," << IsExp = TRUE; DObj.SetScope (1); CIfrEnd EndObj1; EndObj1.SetLineNo(D->getLine()); >>
+ | "=" vfrConstantValueField[_GET_CURRQEST_DATATYPE()] > [Val] "," <<
+ if (gCurrentMinMaxData != NULL && gCurrentMinMaxData->IsNumericOpcode()) {
+ //check default value is valid for Numeric Opcode
+ if (Val.u64 < gCurrentMinMaxData->GetMinData(_GET_CURRQEST_DATATYPE()) || Val.u64 > gCurrentMinMaxData->GetMaxData(_GET_CURRQEST_DATATYPE())) {
+ _PCATCH (VFR_RETURN_INVALID_PARAMETER, D->getLine(), "Numeric default value must be between MinValue and MaxValue.");
+ }
+ }
+ DObj.SetType (_GET_CURRQEST_DATATYPE());
+ DObj.SetValue(Val);
+ >>
)
{
DefaultStore "=" SN:StringIdentifier "," << _PCATCH(mCVfrDefaultStore.GetDefaultId (SN->getText(), &DefaultId), SN); DObj.SetDefaultId (DefaultId); >>
}
- <<
- _PCATCH(mCVfrDataStorage.GetVarStoreName (_GET_CURRQEST_VARTINFO().mVarStoreId, &VarStoreName), D->getLine());
- _PCATCH(mCVfrDataStorage.GetVarStoreType (VarStoreName, VarStoreType), D->getLine());
- if ((IsExp == FALSE) && (VarStoreType == EFI_VFR_VARSTORE_BUFFER)) {
- _PCATCH(mCVfrDefaultStore.BufferVarStoreAltConfigAdd (
- DefaultId,
- _GET_CURRQEST_VARTINFO(),
- VarStoreName,
- _GET_CURRQEST_DATATYPE (),
- Val), D->getLine());
- }
- >>
+ <<
+ _PCATCH(mCVfrDataStorage.GetVarStoreName (_GET_CURRQEST_VARTINFO().mVarStoreId, &VarStoreName), D->getLine());
+ _PCATCH(mCVfrDataStorage.GetVarStoreType (VarStoreName, VarStoreType), D->getLine());
+ if ((IsExp == FALSE) && (VarStoreType == EFI_VFR_VARSTORE_BUFFER)) {
+ _PCATCH(mCVfrDefaultStore.BufferVarStoreAltConfigAdd (
+ DefaultId,
+ _GET_CURRQEST_VARTINFO(),
+ VarStoreName,
+ _GET_CURRQEST_DATATYPE (),
+ Val),
+ D->getLine()
+ );
+ }
+ >>
)
;
vfrStatementStat :
- vfrStatementSubTitle |
+ vfrStatementSubTitle |
vfrStatementStaticText |
vfrStatementCrossReference
;
@@ -932,14 +1040,18 @@ vfrStatementInvalid :
;
flagsField :
- Number | InteractiveFlag | ManufacturingFlag | DefaultFlag |
+ Number | InteractiveFlag | ManufacturingFlag | DefaultFlag |
NVAccessFlag | ResetRequiredFlag | LateCheckFlag
;
vfrStatementValue :
- << CIfrValue VObj; >>
+ <<
+ CIfrValue VObj;
+ UINT32 ExpOpCount = 0;
+ >>
V:Value << VObj.SetLineNo(V->getLine()); >>
- "=" vfrStatementExpression[0]
+ "=" vfrStatementExpression[0, ExpOpCount]
+ << { CIfrEnd EndObj; EndObj.SetLineNo(0); } >>
;
vfrStatementSubTitle :
@@ -965,7 +1077,7 @@ subtitleFlagsField [UINT8 & Flags] :
;
vfrStatementStaticText :
- <<
+ <<
UINT8 Flags = 0;
EFI_QUESTION_ID QId = EFI_QUESTION_ID_INVALID;
EFI_STRING_ID TxtTwo = EFI_STRING_ID_INVALID;
@@ -983,6 +1095,7 @@ vfrStatementStaticText :
<<
if (Flags & EFI_IFR_FLAG_CALLBACK) {
CIfrAction AObj;
+ AObj.SetLineNo (T->getLine());
mCVfrQuestionDB.RegisterQuestion (NULL, NULL, QId);
AObj.SetQuestionId (QId);
AObj.SetPrompt (_STOSID(S2->getText()));
@@ -1013,7 +1126,7 @@ vfrStatementCrossReference :
;
vfrStatementGoto :
- <<
+ <<
UINT8 RefType = 1;
EFI_STRING_ID DevPath;
EFI_GUID FSId;
@@ -1030,39 +1143,23 @@ vfrStatementGoto :
(
(
DevicePath "=" "STRING_TOKEN" "\(" P:Number "\)" ","
- FormSetGuid "="
- OpenBrace
- G11:Number "," G12:Number "," G13:Number "," G14:Number "," G15:Number "," G16:Number ","
- G17:Number "," G18:Number "," G19:Number "," G110:Number "," G111:Number
- CloseBrace ","
+ FormSetGuid "=" guidDefinition[FSId] ","
FormId "=" F1:Number ","
Question "=" QN1:Number ","
- <<
+ <<
RefType = 4;
- _CRGUID (&FSId, G11->getText (), G12->getText (), G13->getText (),
- G14->getText (), G15->getText (), G16->getText (),
- G17->getText (), G18->getText (), G19->getText (),
- G110->getText (), G111->getText ());
- DevPath = _STOSID(P->getText());
+ DevPath = _STOSID(P->getText());
FId = _STOFID(F1->getText());
QId = _STOQID(QN1->getText());
>>
)
|
(
- FormSetGuid "="
- OpenBrace
- G21:Number "," G22:Number "," G23:Number "," G24:Number "," G25:Number "," G26:Number ","
- G27:Number "," G28:Number "," G29:Number "," G210:Number "," G211:Number
- CloseBrace ","
+ FormSetGuid "=" guidDefinition[FSId] ","
FormId "=" F2:Number ","
Question "=" QN2:Number ","
<<
RefType = 3;
- _CRGUID (&FSId, G21->getText (), G22->getText (), G23->getText (),
- G24->getText (), G25->getText (), G26->getText (),
- G27->getText (), G28->getText (), G29->getText (),
- G210->getText (), G211->getText ());
FId = _STOFID(F2->getText());
QId = _STOQID(QN2->getText());
>>
@@ -1070,7 +1167,7 @@ vfrStatementGoto :
|
(
FormId "=" F3:Number "," << RefType = 2; FId = _STOFID(F3->getText()); >>
- Question "="
+ Question "="
(
QN3:StringIdentifier "," << mCVfrQuestionDB.GetQuestionId (QN3->getText (), NULL, QId, BitMask); >>
| QN4:Number "," << QId = _STOQID(QN4->getText()); >>
@@ -1078,7 +1175,7 @@ vfrStatementGoto :
)
|
(
- F4:Number "," <<
+ F4:Number "," <<
RefType = 1;
FId = _STOFID(F4->getText());
>>
@@ -1088,31 +1185,31 @@ vfrStatementGoto :
switch (RefType) {
case 4:
{
- R4Obj = new CIfrRef4;
- QHObj = R4Obj;
- R4Obj->SetLineNo(G->getLine());
- R4Obj->SetDevicePath (DevPath);
- R4Obj->SetFormSetId (FSId);
- R4Obj->SetFormId (FId);
- R4Obj->SetQuestionId (QId);
+ R4Obj = new CIfrRef4;
+ QHObj = R4Obj;
+ R4Obj->SetLineNo(G->getLine());
+ R4Obj->SetDevicePath (DevPath);
+ R4Obj->SetFormSetId (FSId);
+ R4Obj->SetFormId (FId);
+ R4Obj->SetQuestionId (QId);
break;
}
case 3:
{
- R3Obj = new CIfrRef3;
- QHObj = R3Obj;
- R3Obj->SetLineNo(G->getLine());
- R3Obj->SetFormSetId (FSId);
- R3Obj->SetFormId (FId);
- R3Obj->SetQuestionId (QId);
+ R3Obj = new CIfrRef3;
+ QHObj = R3Obj;
+ R3Obj->SetLineNo(G->getLine());
+ R3Obj->SetFormSetId (FSId);
+ R3Obj->SetFormId (FId);
+ R3Obj->SetQuestionId (QId);
break;
}
case 2:
{
- R2Obj = new CIfrRef2;
- QHObj = R2Obj;
- R2Obj->SetLineNo(G->getLine());
- R2Obj->SetFormId (FId);
+ R2Obj = new CIfrRef2;
+ QHObj = R2Obj;
+ R2Obj->SetLineNo(G->getLine());
+ R2Obj->SetFormId (FId);
_PCATCH(R2Obj->SetQuestionId (QId), QN3);
break;
}
@@ -1155,12 +1252,12 @@ getStringId :
vfrStatementResetButton :
<<
- CIfrResetButton RBObj;
+ CIfrResetButton RBObj;
UINT16 DefaultId;
>>
L:ResetButton << RBObj.SetLineNo(L->getLine()); >>
- DefaultStore
- "=" N:StringIdentifier "," <<
+ DefaultStore
+ "=" N:StringIdentifier "," <<
_PCATCH(mCVfrDefaultStore.GetDefaultId (N->getText(), &DefaultId), N->getLine());
RBObj.SetDefaultId (DefaultId);
>>
@@ -1184,23 +1281,59 @@ vfrStatementBooleanType :
// prompt = STRING_TOKEN(STR_CHECK_BOX_PROMPT),
// help = STRING_TOKEN(STR_CHECK_BOX_HELP),
// flags = CHECKBOX_DEFAULT | CALLBACK,
-// default value = TRUE, defaultstore = MyDefaultStore,
+// default value = TRUE, defaultstore = MyDefaultStore,
// endcheckbox;
//
vfrStatementCheckBox :
<<
- CIfrCheckBox CBObj;
+ CIfrCheckBox CBObj;
+ EFI_IFR_TYPE_VALUE Val = {0};
+ INT8 *VarStoreName = NULL;
>>
L:CheckBox << CBObj.SetLineNo(L->getLine()); >>
vfrQuestionHeader[CBObj] ","
- { F:FLAGS "=" vfrCheckBoxFlags[CBObj, F->getLine()] "," }
+ {
+ F:FLAGS "=" vfrCheckBoxFlags[CBObj, F->getLine()] ","
+ <<
+ _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"
+ );
+ }
+ >>
+ }
{
Key "=" KN:Number "," << AssignQuestionKey (CBObj, KN); >>
}
vfrStatementQuestionOptionList
E:EndCheckBox << CRT_END_OP (E); >>
";"
- ;
+ ;
vfrCheckBoxFlags [CIfrCheckBox & CBObj, UINT32 LineNum] :
<<
@@ -1256,7 +1389,7 @@ vfrStatementDate :
EFI_QUESTION_ID QId = EFI_QUESTION_ID_INVALID;
INT8 *VarIdStr[3] = {NULL, };
CIfrDate DObj;
- EFI_IFR_TYPE_VALUE Val;
+ EFI_IFR_TYPE_VALUE Val = {0};
>>
L:Date << DObj.SetLineNo(L->getLine()); >>
(
@@ -1285,14 +1418,14 @@ vfrStatementDate :
Help "=" "STRING_TOKEN" "\(" DH:Number "\)" ","
minMaxDateStepDefault[Val.date, 2]
<<
- mCVfrQuestionDB.RegisterOldDateQuestion (VarIdStr[0], VarIdStr[1], VarIdStr[2], QId);
+ mCVfrQuestionDB.RegisterOldDateQuestion (VarIdStr[0], VarIdStr[1], VarIdStr[2], QId);
DObj.SetQuestionId (QId);
DObj.SetFlags (EFI_IFR_QUESTION_FLAG_DEFAULT, QF_DATE_STORAGE_TIME);
DObj.SetPrompt (_STOSID(YP->getText()));
DObj.SetHelp (_STOSID(YH->getText()));
if (VarIdStr[0] != NULL) { delete VarIdStr[0]; } if (VarIdStr[1] != NULL) { delete VarIdStr[1]; } if (VarIdStr[2] != NULL) { delete VarIdStr[2]; }
>>
- << {CIfrDefault DObj(EFI_HII_DEFAULT_CLASS_STANDARD, EFI_IFR_TYPE_DATE, Val);} >>
+ << {CIfrDefault DObj(EFI_HII_DEFAULT_CLASS_STANDARD, EFI_IFR_TYPE_DATE, Val); DObj.SetLineNo (D1Y->getLine());} >>
( vfrStatementInconsistentIf )*
)
)
@@ -1307,10 +1440,10 @@ minMaxDateStepDefault[EFI_HII_DATE & D, UINT8 KeyValue] :
{
"default" "=" N:Number "," <<
switch (KeyValue) {
- case 0: D.Year = _STOU16(N->getText()); break;
- case 1: D.Month = _STOU8(N->getText()); break;
+ case 0: D.Year = _STOU16(N->getText()); break;
+ case 1: D.Month = _STOU8(N->getText()); break;
case 2: D.Day = _STOU8(N->getText()); break;
- }
+ }
>>
}
;
@@ -1400,18 +1533,38 @@ vfrStatementNumeric :
vfrNumericFlags [CIfrNumeric & NObj, UINT32 LineNum] :
<<
- UINT8 LFlags = _GET_CURRQEST_DATATYPE();
+ UINT8 LFlags = _GET_CURRQEST_DATATYPE() & EFI_IFR_NUMERIC_SIZE;
UINT8 HFlags = 0;
+ EFI_VFR_VARSTORE_TYPE VarStoreType = EFI_VFR_VARSTORE_INVALID;
>>
numericFlagsField[HFlags, LFlags] ( "\|" numericFlagsField[HFlags, LFlags] )*
- << _PCATCH(NObj.SetFlags (HFlags, LFlags), LineNum); >>
+ <<
+ //check data type flag
+ VarStoreType = mCVfrDataStorage.GetVarStoreType (_GET_CURRQEST_VARTINFO().mVarStoreId);
+ if (VarStoreType == EFI_VFR_VARSTORE_BUFFER || VarStoreType == EFI_VFR_VARSTORE_EFI) {
+ if (_GET_CURRQEST_DATATYPE() != (LFlags & EFI_IFR_NUMERIC_SIZE)) {
+ _PCATCH(VFR_RETURN_INVALID_PARAMETER, LineNum, "Numeric Flag is not same to Numeric VarData type");
+ }
+ } else {
+ // update data type for name/value store
+ UINT32 DataTypeSize;
+ _GET_CURRQEST_VARTINFO().mVarType = LFlags & EFI_IFR_NUMERIC_SIZE;
+ mCVfrVarDataTypeDB.GetDataTypeSize (_GET_CURRQEST_DATATYPE(), &DataTypeSize);
+ _GET_CURRQEST_VARTINFO().mVarTotalSize = DataTypeSize;
+ }
+ _PCATCH(NObj.SetFlags (HFlags, LFlags), LineNum);
+ >>
;
numericFlagsField [UINT8 & HFlags, UINT8 & LFlags] :
N:Number << _PCATCH(_STOU8(N->getText()) == 0 ? VFR_RETURN_SUCCESS : VFR_RETURN_UNSUPPORTED, N->getLine()); >>
- | "DISPLAY_INT_DEC" << $LFlags |= 0x00; >>
- | "DISPLAY_UINT_DEC" << $LFlags |= 0x10; >>
- | "DISPLAY_UINT_HEX" << $LFlags |= 0x20; >>
+ | "NUMERIC_SIZE_1" << $LFlags = ($LFlags & ~EFI_IFR_NUMERIC_SIZE) | EFI_IFR_NUMERIC_SIZE_1; >>
+ | "NUMERIC_SIZE_2" << $LFlags = ($LFlags & ~EFI_IFR_NUMERIC_SIZE) | EFI_IFR_NUMERIC_SIZE_2; >>
+ | "NUMERIC_SIZE_4" << $LFlags = ($LFlags & ~EFI_IFR_NUMERIC_SIZE) | EFI_IFR_NUMERIC_SIZE_4; >>
+ | "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]
;
@@ -1420,9 +1573,9 @@ vfrStatementOneOf :
CIfrOneOf OObj;
>>
L:OneOf << OObj.SetLineNo(L->getLine()); >>
- vfrQuestionHeader[OObj] ","
+ vfrQuestionHeader[OObj] "," << _PCATCH(OObj.SetFlags (OObj.FLAGS(), _GET_CURRQEST_DATATYPE()), L->getLine()); >>
{ F:FLAGS "=" vfrOneofFlagsField[OObj, F->getLine()] "," }
- {
+ {
vfrSetMinMaxStep[OObj]
}
vfrStatementQuestionOptionList
@@ -1432,11 +1585,27 @@ vfrStatementOneOf :
vfrOneofFlagsField [CIfrOneOf & OObj, UINT32 LineNum] :
<<
- UINT8 LFlags = _GET_CURRQEST_DATATYPE();
+ UINT8 LFlags = _GET_CURRQEST_DATATYPE() & EFI_IFR_NUMERIC_SIZE;
UINT8 HFlags = 0;
+ EFI_VFR_VARSTORE_TYPE VarStoreType = EFI_VFR_VARSTORE_INVALID;
>>
numericFlagsField[HFlags, LFlags] ( "\|" numericFlagsField[HFlags, LFlags] )*
- << _PCATCH(OObj.SetFlags (HFlags, LFlags), LineNum); >>
+ <<
+ //check data type flag
+ VarStoreType = mCVfrDataStorage.GetVarStoreType (_GET_CURRQEST_VARTINFO().mVarStoreId);
+ if (VarStoreType == EFI_VFR_VARSTORE_BUFFER || VarStoreType == EFI_VFR_VARSTORE_EFI) {
+ if (_GET_CURRQEST_DATATYPE() != (LFlags & EFI_IFR_NUMERIC_SIZE)) {
+ _PCATCH(VFR_RETURN_INVALID_PARAMETER, LineNum, "Numeric Flag is not same to Numeric VarData type");
+ }
+ } else {
+ // update data type for Name/Value store
+ UINT32 DataTypeSize;
+ _GET_CURRQEST_VARTINFO().mVarType = LFlags & EFI_IFR_NUMERIC_SIZE;
+ mCVfrVarDataTypeDB.GetDataTypeSize (_GET_CURRQEST_DATATYPE(), &DataTypeSize);
+ _GET_CURRQEST_VARTINFO().mVarTotalSize = DataTypeSize;
+ }
+ _PCATCH(OObj.SetFlags (HFlags, LFlags), LineNum);
+ >>
;
vfrStatementStringType :
@@ -1449,7 +1618,7 @@ vfrStatementString :
CIfrString SObj;
>>
L:String << SObj.SetLineNo(L->getLine()); >>
- vfrQuestionHeader[SObj] "," << _PCATCH(SObj.SetFlags (SObj.FLAGS(), _GET_CURRQEST_DATATYPE()), L->getLine()); >>
+ vfrQuestionHeader[SObj] ","
{ F:FLAGS "=" vfrStringFlagsField[SObj, F->getLine()] "," }
{
Key "=" KN:Number "," << AssignQuestionKey (SObj, KN); >>
@@ -1478,7 +1647,7 @@ stringFlagsField [UINT8 & HFlags, UINT8 & LFlags] :
vfrStatementPassword :
<<
- CIfrPassword PObj;
+ CIfrPassword PObj;
>>
L:Password << PObj.SetLineNo(L->getLine()); >>
vfrQuestionHeader[PObj] ","
@@ -1507,12 +1676,12 @@ passwordFlagsField [UINT8 & HFlags] :
vfrStatementOrderedList :
<<
- CIfrOrderedList OLObj;
+ CIfrOrderedList OLObj;
>>
L:OrderedList << OLObj.SetLineNo(L->getLine()); >>
vfrQuestionHeader[OLObj] ","
- << OLObj.SetMaxContainers ((UINT8)_GET_CURRQEST_VARSIZE()); >>
- {
+ << OLObj.SetMaxContainers ((UINT8)_GET_CURRQEST_ARRAY_SIZE()); >>
+ {
MaxContainers "=" M:Number "," << OLObj.SetMaxContainers (_STOU8(M->getText())); >>
}
{ F:FLAGS "=" vfrOrderedListFlags[OLObj, F->getLine()] }
@@ -1542,14 +1711,14 @@ vfrStatementTime :
EFI_QUESTION_ID QId = EFI_QUESTION_ID_INVALID;
INT8 *VarIdStr[3] = {NULL, };
CIfrTime TObj;
- EFI_IFR_TYPE_VALUE Val;
+ EFI_IFR_TYPE_VALUE Val = {0};
>>
L:Time << TObj.SetLineNo(L->getLine()); >>
(
(
vfrQuestionHeader[TObj, QUESTION_TIME] ","
{ F:FLAGS "=" vfrTimeFlags[TObj, F->getLine()] "," }
- vfrStatementDefault
+ vfrStatementQuestionOptionList
)
|
(
@@ -1571,14 +1740,14 @@ vfrStatementTime :
Help "=" "STRING_TOKEN" "\(" SH:Number "\)" ","
minMaxTimeStepDefault[Val.time, 2]
<<
- mCVfrQuestionDB.RegisterOldTimeQuestion (VarIdStr[0], VarIdStr[1], VarIdStr[2], QId);
+ mCVfrQuestionDB.RegisterOldTimeQuestion (VarIdStr[0], VarIdStr[1], VarIdStr[2], QId);
TObj.SetQuestionId (QId);
TObj.SetFlags (EFI_IFR_QUESTION_FLAG_DEFAULT, QF_TIME_STORAGE_TIME);
TObj.SetPrompt (_STOSID(HP->getText()));
TObj.SetHelp (_STOSID(HH->getText()));
if (VarIdStr[0] != NULL) { delete VarIdStr[0]; } if (VarIdStr[1] != NULL) { delete VarIdStr[1]; } if (VarIdStr[2] != NULL) { delete VarIdStr[2]; }
>>
- << {CIfrDefault DObj(EFI_HII_DEFAULT_CLASS_STANDARD, EFI_IFR_TYPE_TIME, Val);} >>
+ << {CIfrDefault DObj(EFI_HII_DEFAULT_CLASS_STANDARD, EFI_IFR_TYPE_TIME, Val); DObj.SetLineNo (T1H->getLine());} >>
)
)
E:EndTime << CRT_END_OP (E); >>
@@ -1592,10 +1761,10 @@ minMaxTimeStepDefault[EFI_HII_TIME & T, UINT8 KeyValue] :
{
"default" "=" N:Number "," <<
switch (KeyValue) {
- case 0: T.Hour = _STOU8(N->getText()); break;
- case 1: T.Minute = _STOU8(N->getText()); break;
+ case 0: T.Hour = _STOU8(N->getText()); break;
+ case 1: T.Minute = _STOU8(N->getText()); break;
case 2: T.Second = _STOU8(N->getText()); break;
- }
+ }
>>
}
;
@@ -1622,7 +1791,7 @@ vfrStatementQuestionTag :
vfrStatementNoSubmitIf |
vfrStatementDisableIfQuest |
vfrStatementRefresh |
- vfrStatementVarstoreDevice
+ vfrStatementVarstoreDevice
;
vfrStatementQuestionTagList :
@@ -1639,7 +1808,7 @@ vfrStatementQuestionOptionTag :
vfrStatementQuestionOptionList :
(
vfrStatementQuestionTag |
- vfrStatementQuestionOptionTag
+ vfrStatementQuestionOptionTag
)*
;
@@ -1648,34 +1817,43 @@ vfrStatementStatList :
vfrStatementQuestions |
vfrStatementConditional |
// Just for framework vfr compatibility
- vfrStatementLabel
+ vfrStatementLabel
//vfrStatementInvalid
;
vfrStatementDisableIfStat :
- << CIfrDisableIf DIObj; >>
+ <<
+ CIfrDisableIf DIObj;
+ UINT32 ExpOpCount = 0;
+ >>
L:DisableIf << DIObj.SetLineNo(L->getLine()); >>
- vfrStatementExpression[0] ";"
+ vfrStatementExpression[0, ExpOpCount] ";" << mConstantOnlyInExpression = FALSE; >>
( vfrStatementStatList )*
E:EndIf << CRT_END_OP (E); >>
";"
;
vfrStatementSuppressIfStat :
- << CIfrSuppressIf SIObj; >>
+ <<
+ CIfrSuppressIf SIObj;
+ UINT32 ExpOpCount = 0;
+ >>
L:SuppressIf << SIObj.SetLineNo(L->getLine()); >>
{ FLAGS "=" flagsField ( "\|" flagsField )* "," }
- vfrStatementExpression[0] ";"
+ vfrStatementExpression[0, ExpOpCount] ";"
( vfrStatementStatList )*
E:EndIf << CRT_END_OP (E); >>
";"
;
vfrStatementGrayOutIfStat :
- << CIfrGrayOutIf GOIObj; >>
+ <<
+ CIfrGrayOutIf GOIObj;
+ UINT32 ExpOpCount = 0;
+ >>
L:GrayOutIf << GOIObj.SetLineNo(L->getLine()); >>
{ FLAGS "=" flagsField ( "\|" flagsField )* "," }
- vfrStatementExpression[0]
+ vfrStatementExpression[0, ExpOpCount]
";"
( vfrStatementStatList )*
E:EndIf << CRT_END_OP (E); >>
@@ -1712,27 +1890,36 @@ vfrStatementLocked :
;
vfrStatementInconsistentIf :
- << CIfrInconsistentIf IIObj; >>
+ <<
+ CIfrInconsistentIf IIObj;
+ UINT32 ExpOpCount = 0;
+ >>
L:InconsistentIf << IIObj.SetLineNo(L->getLine()); >>
Prompt "=" "STRING_TOKEN" "\(" S:Number "\)" "," << IIObj.SetError (_STOSID(S->getText())); >>
{ FLAGS "=" flagsField ( "\|" flagsField )* "," }
- vfrStatementExpression[0]
+ vfrStatementExpression[0, ExpOpCount]
E:EndIf << CRT_END_OP (E); >>
;
vfrStatementNoSubmitIf :
- << CIfrNoSubmitIf NSIObj; >>
+ <<
+ CIfrNoSubmitIf NSIObj;
+ UINT32 ExpOpCount = 0;
+ >>
L:NoSubmitIf << NSIObj.SetLineNo(L->getLine()); >>
Prompt "=" "STRING_TOKEN" "\(" S:Number "\)" "," << NSIObj.SetError (_STOSID(S->getText())); >>
{ FLAGS "=" flagsField ( "\|" flagsField )* "," }
- vfrStatementExpression[0]
+ vfrStatementExpression[0, ExpOpCount]
E:EndIf << CRT_END_OP (E); >>
;
vfrStatementDisableIfQuest :
- << CIfrDisableIf DIObj; >>
+ <<
+ CIfrDisableIf DIObj;
+ UINT32 ExpOpCount = 0;
+ >>
L:DisableIf << DIObj.SetLineNo(L->getLine()); >>
- vfrStatementExpression[0] ";"
+ vfrStatementExpression[0, ExpOpCount] ";" << mConstantOnlyInExpression = FALSE; >>
vfrStatementQuestionOptionList
E:EndIf << CRT_END_OP (E); >>
;
@@ -1750,10 +1937,13 @@ vfrStatementVarstoreDevice :
;
vfrStatementSuppressIfQuest :
- << CIfrSuppressIf SIObj; >>
+ <<
+ CIfrSuppressIf SIObj;
+ UINT32 ExpOpCount = 0;
+ >>
L:SuppressIf << SIObj.SetLineNo(L->getLine()); >>
{ FLAGS "=" flagsField ( "\|" flagsField )* "," }
- vfrStatementExpression[0] ";"
+ vfrStatementExpression[0, ExpOpCount] ";"
vfrStatementQuestionOptionList
E:EndIf << CRT_END_OP (E); >>
;
@@ -1764,28 +1954,51 @@ vfrStatementOptions :
vfrStatementOneOfOption :
<<
- EFI_IFR_TYPE_VALUE Val;
+ EFI_IFR_TYPE_VALUE Val = {0};
CIfrOneOfOption OOOObj;
INT8 *VarStoreName = NULL;
-
+
>>
L:Option << OOOObj.SetLineNo(L->getLine()); >>
Text "=" "STRING_TOKEN" "\(" S:Number "\)" "," << OOOObj.SetOption (_STOSID(S->getText())); >>
- Value "=" vfrConstantValueField[_GET_CURRQEST_DATATYPE()] >[Val] "," << OOOObj.SetType (_GET_CURRQEST_DATATYPE()); OOOObj.SetValue (Val); >>
+ Value "=" vfrConstantValueField[_GET_CURRQEST_DATATYPE()] >[Val] ","
+ <<
+ if (gCurrentMinMaxData != NULL) {
+ //set min/max value for oneof opcode
+ UINT64 Step = gCurrentMinMaxData->GetStepData(_GET_CURRQEST_DATATYPE());
+ switch (_GET_CURRQEST_DATATYPE()) {
+ case EFI_IFR_TYPE_NUM_SIZE_64:
+ gCurrentMinMaxData->SetMinMaxStepData(Val.u64, Val.u64, Step);
+ break;
+ case EFI_IFR_TYPE_NUM_SIZE_32:
+ gCurrentMinMaxData->SetMinMaxStepData(Val.u32, Val.u32, (UINT32) Step);
+ break;
+ case EFI_IFR_TYPE_NUM_SIZE_16:
+ gCurrentMinMaxData->SetMinMaxStepData(Val.u16, Val.u16, (UINT16) Step);
+ break;
+ case EFI_IFR_TYPE_NUM_SIZE_8:
+ gCurrentMinMaxData->SetMinMaxStepData(Val.u8, Val.u8, (UINT8) Step);
+ break;
+ default:
+ break;
+ }
+ }
+ OOOObj.SetType (_GET_CURRQEST_DATATYPE());
+ OOOObj.SetValue (Val);
+ >>
F:FLAGS "=" vfrOneOfOptionFlags[OOOObj, F->getLine()]
<<
if (OOOObj.GetFlags () & 0x10) {
_PCATCH(mCVfrDataStorage.GetVarStoreName (_GET_CURRQEST_VARTINFO().mVarStoreId, &VarStoreName), L->getLine());
_PCATCH(mCVfrDefaultStore.BufferVarStoreAltConfigAdd (
- EFI_HII_DEFAULT_CLASS_STANDARD,
- _GET_CURRQEST_VARTINFO(),
- VarStoreName,
- _GET_CURRQEST_DATATYPE (),
+ EFI_HII_DEFAULT_CLASS_STANDARD,
+ _GET_CURRQEST_VARTINFO(),
+ VarStoreName,
+ _GET_CURRQEST_DATATYPE (),
Val
), L->getLine());
}
>>
- { "," Key "=" Number } // no use in UEFI2.1 VFR
(
"," vfrImageTag << OOOObj.SetScope (1); CIfrEnd EOOOObj; >>
)*
@@ -1794,7 +2007,7 @@ vfrStatementOneOfOption :
vfrOneOfOptionFlags [CIfrOneOfOption & OOOObj, UINT32 LineNum] :
<<
- UINT8 LFlags = _GET_CURRQEST_DATATYPE();
+ UINT8 LFlags = 0;
UINT8 HFlags = 0;
>>
oneofoptionFlagsField[HFlags, LFlags] ( "\|" oneofoptionFlagsField[HFlags, LFlags] )*
@@ -1814,27 +2027,6 @@ oneofoptionFlagsField [UINT8 & HFlags, UINT8 & LFlags] :
| DefaultFlag << $LFlags |= 0x10; >>
;
-//vfrStatementGuid :
-// <<
-// EFI_GUID Guid;
-// CIfrGuid GObj;
-// >>
-// GuidAction
-// GUID "="
-// OpenBrace
-// G1:Number "," G2:Number "," G3:Number "," G4:Number "," G5:Number "," G6:Number ","
-// G7:Number "," G8:Number "," G9:Number "," G10:Number "," G11:Number
-// CloseBrace
-// <<
-// _CRGUID (&Guid, G1->getText (), G2->getText (), G3->getText (),
-// G4->getText (), G5->getText (), G6->getText (),
-// G7->getText (), G8->getText (), G9->getText (),
-// G10->getText (), G11->getText ());
-// >>
-// << GObj.SetGuid (&Guid); >>
-// ";"
-// ;
-
vfrStatementLabel :
<< CIfrLabel LObj; >>
L:Label << LObj.SetLineNo(L->getLine()); >>
@@ -1847,9 +2039,9 @@ vfrStatementBanner :
B:Banner { "," } << BObj.SetLineNo(B->getLine()); >>
Title "=" "STRING_TOKEN" "\(" S:Number "\)" "," << BObj.SetTitle (_STOSID(S->getText())); >>
(
- (
+ (
Line L:Number "," << BObj.SetLine (_STOU16(L->getText())); >>
- Align
+ Align
(
Left << BObj.SetAlign (0); >>
| Center << BObj.SetAlign (1); >>
@@ -1867,17 +2059,18 @@ vfrStatementBanner :
//
// keep some syntax for compatibility but not generate any IFR object
//
-vfrStatementInvalidHidden :
+vfrStatementInvalidHidden :
Hidden
Value "=" Number ","
Key "=" Number ";"
;
vfrStatementInvalidInconsistentIf :
+ << UINT32 ExpOpCount = 0; >>
InconsistentIf
Prompt "=" "STRING_TOKEN" "\(" S:Number "\)" ","
{ FLAGS "=" flagsField ( "\|" flagsField )* "," }
- vfrStatementExpression[0]
+ vfrStatementExpression[0, ExpOpCount]
EndIf
";"
;
@@ -1889,15 +2082,15 @@ vfrStatementInvalidInventory :
{
Text "=" "STRING_TOKEN" "\(" Number "\)"
}
- ";"
+ ";"
;
-vfrStatementInvalidSaveRestoreDefaults :
+vfrStatementInvalidSaveRestoreDefaults :
(Save | Restore)
Defaults ","
FormId "=" Number ","
Prompt "=" "STRING_TOKEN" "\(" Number "\)" ","
- Help "=" "STRING_TOKEN" "\(" Number "\)"
+ Help "=" "STRING_TOKEN" "\(" Number "\)"
{ "," FLAGS "=" flagsField ( "\|" flagsField )* }
{ "," Key "=" Number }
";"
@@ -1939,13 +2132,13 @@ vfrStatementInvalidSaveRestoreDefaults :
#token QuestionRefVal("questionrefval") "questionrefval"
#token StringRefVal("stringrefval") "stringrefval"
-vfrStatementExpression [UINT32 RootLevel, UINT32 ExpOpCount = 0] :
+vfrStatementExpression [UINT32 RootLevel, UINT32 & ExpOpCount] :
<< if ($RootLevel == 0) {_CLEAR_SAVED_OPHDR ();} >>
andTerm[$RootLevel, $ExpOpCount]
(
L:OR andTerm[$RootLevel, $ExpOpCount] << $ExpOpCount++; CIfrOr OObj(L->getLine()); >>
)*
- << if (($RootLevel == 0) && ($ExpOpCount > 1)) {_SET_SAVED_OPHDR_SCOPE(); CIfrEnd EObj; } >>
+ << if (($RootLevel == 0) && ($ExpOpCount > 1)) {_SET_SAVED_OPHDR_SCOPE(); CIfrEnd EObj; EObj.SetLineNo (0);} >>
;
andTerm[UINT32 & RootLevel, UINT32 & ExpOpCount] :
@@ -1956,7 +2149,7 @@ andTerm[UINT32 & RootLevel, UINT32 & ExpOpCount] :
;
bitwiseorTerm [UINT32 & RootLevel, UINT32 & ExpOpCount]:
- bitwiseandTerm[$RootLevel, $ExpOpCount]
+ bitwiseandTerm[$RootLevel, $ExpOpCount]
(
L:"\|" bitwiseandTerm[$RootLevel, $ExpOpCount] << $ExpOpCount++; CIfrBitWiseOr BWOObj(L->getLine()); >>
)*
@@ -2004,7 +2197,7 @@ compareTerm [UINT32 & RootLevel, UINT32 & ExpOpCount]:
;
shiftTerm [UINT32 & RootLevel, UINT32 & ExpOpCount]:
- addMinusTerm[$RootLevel, $ExpOpCount]
+ addMinusTerm[$RootLevel, $ExpOpCount]
(
(
L1:"\<<" addMinusTerm[$RootLevel, $ExpOpCount] << $ExpOpCount++; CIfrShiftLeft SLObj(L1->getLine()); >>
@@ -2030,20 +2223,42 @@ addMinusTerm [UINT32 & RootLevel, UINT32 & ExpOpCount]:
;
multdivmodTerm [UINT32 & RootLevel, UINT32 & ExpOpCount]:
- atomTerm[$RootLevel, $ExpOpCount]
- (
+ castTerm[$RootLevel, $ExpOpCount]
+ (
(
- L1:"\*" atomTerm[$RootLevel, $ExpOpCount] << $ExpOpCount++; CIfrMultiply MObj(L1->getLine()); >>
+ L1:"\*" castTerm[$RootLevel, $ExpOpCount] << $ExpOpCount++; CIfrMultiply MObj(L1->getLine()); >>
)
|
(
- L2:"/" atomTerm[$RootLevel, $ExpOpCount] << $ExpOpCount++; CIfrDivide DObj(L2->getLine()); >>
+ L2:"/" castTerm[$RootLevel, $ExpOpCount] << $ExpOpCount++; CIfrDivide DObj(L2->getLine()); >>
)
|
(
- L3:"%" atomTerm[$RootLevel, $ExpOpCount] << $ExpOpCount++; CIfrModulo MObj(L3->getLine()); >>
- )
+ L3:"%" castTerm[$RootLevel, $ExpOpCount] << $ExpOpCount++; CIfrModulo MObj(L3->getLine()); >>
+ )
)*
+ ;
+
+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;
+ }
+ >>
;
atomTerm [UINT32 & RootLevel, UINT32 & ExpOpCount]:
@@ -2119,7 +2334,7 @@ ideqvalExp [UINT32 & RootLevel, UINT32 & ExpOpCount] :
_SAVE_OPHDR_COND (EIVObj, ($ExpOpCount == 0));
EIVObj.SetQuestionId (QId, VarIdStr, LineNo);
EIVObj.SetValue (ConstVal);
- $ExpOpCount++;
+ $ExpOpCount++;
} else {
IdEqValDoSpecial ($ExpOpCount, L->getLine(), QId, VarIdStr, Mask, ConstVal, EQUAL);
}
@@ -2163,7 +2378,7 @@ ideqidExp[UINT32 & RootLevel, UINT32 & ExpOpCount] :
vfrQuestionDataFieldName[QId[0], Mask[0], VarIdStr[0], LineNo[0]]
(
(
- "=="
+ "=="
vfrQuestionDataFieldName[QId[1], Mask[1], VarIdStr[1], LineNo[1]]
<<
if (Mask[0] & Mask[1]) {
@@ -2173,7 +2388,7 @@ ideqidExp[UINT32 & RootLevel, UINT32 & ExpOpCount] :
_SAVE_OPHDR_COND (EIIObj, ($ExpOpCount == 0));
EIIObj.SetQuestionId1 (QId[0], VarIdStr[0], LineNo[0]);
EIIObj.SetQuestionId2 (QId[1], VarIdStr[1], LineNo[1]);
- $ExpOpCount++;
+ $ExpOpCount++;
}
>>
)
@@ -2215,7 +2430,7 @@ ideqvallistExp[UINT32 & RootLevel, UINT32 & ExpOpCount] :
>>
L:IdEqValList
vfrQuestionDataFieldName[QId, Mask, VarIdStr, LineNo]
- "=="
+ "=="
(
V:Number << ValueList[ListLen] = _STOU16(V->getText()); ListLen++; >>
)+
@@ -2239,9 +2454,9 @@ ideqvallistExp[UINT32 & RootLevel, UINT32 & ExpOpCount] :
vareqvarlExp[UINT32 & RootLevel, UINT32 & ExpOpCount] :
L:VarEqVal Var "\(" V1:Number "\)" "==" V2:Number <<
{
- CIfrUint64 U64Obj1(L->getLine()), U64Obj2(L->getLine());
- _SAVE_OPHDR_COND (U64Obj1, ($ExpOpCount == 0));
- U64Obj1.SetValue (_STOU64(V1->getText()));
+ CIfrUint64 U64Obj1(L->getLine()), U64Obj2(L->getLine());
+ _SAVE_OPHDR_COND (U64Obj1, ($ExpOpCount == 0));
+ U64Obj1.SetValue (_STOU64(V1->getText()));
U64Obj2.SetValue (_STOU64(V2->getText()));
}
>>
@@ -2267,25 +2482,14 @@ questionref13Exp[UINT32 & RootLevel, UINT32 & ExpOpCount] :
Path "=" "STRING_TOKEN" "\(" S:Number "\)" << Type = 0x4; DevPath = _STOSID(S->getText()); >>
}
{
- GUID "="
- OpenBrace
- G1:Number "," G2:Number "," G3:Number "," G4:Number "," G5:Number "," G6:Number ","
- G7:Number "," G8:Number "," G9:Number "," G10:Number "," G11:Number
- CloseBrace
- <<
- Type = 0x5;
- _CRGUID (&Guid, G1->getText (), G2->getText (), G3->getText (),
- G4->getText (), G5->getText (), G6->getText (),
- G7->getText (), G8->getText (), G9->getText (),
- G10->getText (), G11->getText ());
- >>
+ Uuid "=" guidDefinition[Guid] << Type = 0x5; >>
}
)
|
(
"\("
(
- QN:StringIdentifier <<
+ QN:StringIdentifier <<
QName = QN->getText();
LineNo = QN->getLine();
mCVfrQuestionDB.GetQuestionId (QN->getText(), NULL, QId, BitMask);
@@ -2340,6 +2544,7 @@ vfrExpressionUnaryOp[UINT32 & RootLevel, UINT32 & ExpOpCount] :
| bitwisenotExp[$RootLevel, $ExpOpCount]
| question2refExp[$RootLevel, $ExpOpCount]
| stringref2Exp[$RootLevel, $ExpOpCount]
+ | toboolExp[$RootLevel, $ExpOpCount]
| unintExp[$RootLevel, $ExpOpCount]
| toupperExp[$RootLevel, $ExpOpCount]
| tolwerExp[$RootLevel, $ExpOpCount]
@@ -2433,7 +2638,7 @@ findExp[UINT32 & RootLevel, UINT32 & ExpOpCount] :
findFormat[Format] ( "\|" findFormat[Format] )*
","
vfrStatementExpression[$RootLevel + 1, $ExpOpCount]
- ","
+ ","
vfrStatementExpression[$RootLevel + 1, $ExpOpCount]
","
vfrStatementExpression[$RootLevel + 1, $ExpOpCount]
@@ -2460,7 +2665,7 @@ tokenExp[UINT32 & RootLevel, UINT32 & ExpOpCount] :
vfrStatementExpression[$RootLevel + 1, $ExpOpCount]
","
vfrStatementExpression[$RootLevel + 1, $ExpOpCount]
- ","
+ ","
vfrStatementExpression[$RootLevel + 1, $ExpOpCount]
"\)" << { CIfrToken TObj(L->getLine()); $ExpOpCount++; } >>
;
@@ -2489,12 +2694,13 @@ spanFlags [UINT8 & Flags] :
//******************************************************************************
//
-// Parser class definition.
-//
+// Parser class definition.
+//
class EfiVfrParser {
<<
private:
UINT8 mParserStatus;
+ BOOLEAN mConstantOnlyInExpression;
CVfrDefaultStore mCVfrDefaultStore;
CVfrVarDataTypeDB mCVfrVarDataTypeDB;
@@ -2517,12 +2723,14 @@ private:
UINT8 _GET_CURRQEST_DATATYPE ();
UINT32 _GET_CURRQEST_VARSIZE ();
+ UINT32 _GET_CURRQEST_ARRAY_SIZE ();
public:
- VOID _PCATCH (IN EFI_VFR_RETURN_CODE, IN EFI_VFR_RETURN_CODE, IN ANTLRTokenPtr, IN INT8 *);
+ VOID _PCATCH (IN INTN, IN INTN, IN ANTLRTokenPtr, IN INT8 *);
VOID _PCATCH (IN EFI_VFR_RETURN_CODE);
VOID _PCATCH (IN EFI_VFR_RETURN_CODE, IN ANTLRTokenPtr);
VOID _PCATCH (IN EFI_VFR_RETURN_CODE, IN UINT32);
+ VOID _PCATCH (IN EFI_VFR_RETURN_CODE, IN UINT32, IN INT8 *);
VOID syn (ANTLRAbstractToken *, ANTLRChar *, SetWordType *, ANTLRTokenType, INT32);
@@ -2557,7 +2765,7 @@ public:
<<
VOID
EfiVfrParser::_SAVE_OPHDR_COND (
- IN CIfrOpHeader &OpHdr,
+ IN CIfrOpHeader &OpHdr,
IN BOOLEAN Cond
)
{
@@ -2637,17 +2845,48 @@ EfiVfrParser::_GET_CURRQEST_VARSIZE (
return mCurrQestVarInfo.mVarTotalSize;
}
+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
EfiVfrParser::_PCATCH (
- IN EFI_VFR_RETURN_CODE ReturnCode,
- IN EFI_VFR_RETURN_CODE ExpectCode,
+ IN INTN ReturnCode,
+ IN INTN ExpectCode,
IN ANTLRTokenPtr Tok,
IN INT8 *ErrorMsg
)
{
if (ReturnCode != ExpectCode) {
mParserStatus++;
- gCVfrErrorHandle.PrintError (Tok->getLine(), Tok->getText(), ErrorMsg);
+ gCVfrErrorHandle.PrintMsg (Tok->getLine(), Tok->getText(), "Error", ErrorMsg);
}
}
@@ -2675,14 +2914,24 @@ EfiVfrParser::_PCATCH (
)
{
mParserStatus += gCVfrErrorHandle.HandleError (ReturnCode, LineNum);
+}
+
+VOID
+EfiVfrParser::_PCATCH (
+ IN EFI_VFR_RETURN_CODE ReturnCode,
+ IN UINT32 LineNum,
+ IN INT8 *ErrorMsg
+ )
+{
+ mParserStatus = mParserStatus + gCVfrErrorHandle.HandleError (ReturnCode, LineNum, ErrorMsg);
}
-VOID
+VOID
EfiVfrParser::syn (
- ANTLRAbstractToken *Tok,
- ANTLRChar *Egroup,
- SetWordType *Eset,
- ANTLRTokenType ETok,
+ ANTLRAbstractToken *Tok,
+ ANTLRChar *Egroup,
+ SetWordType *Eset,
+ ANTLRTokenType ETok,
INT32 Huh
)
{
@@ -2737,7 +2986,7 @@ EfiVfrParser::_STOU8 (
}
if (c >= '0' && c <= '9') {
Value += (c - '0');
- }
+ }
}
return Value;
@@ -2767,7 +3016,7 @@ EfiVfrParser::_STOU16 (
}
if (c >= '0' && c <= '9') {
Value += (c - '0');
- }
+ }
}
return Value;
@@ -2797,7 +3046,7 @@ EfiVfrParser::_STOU32 (
}
if (c >= '0' && c <= '9') {
Value += (c - '0');
- }
+ }
}
return Value;
@@ -2807,7 +3056,7 @@ UINT64
EfiVfrParser::_STOU64 (
IN INT8 *Str
)
-{
+{
BOOLEAN IsHex;
UINT64 Value;
INT8 c;
@@ -2827,16 +3076,16 @@ EfiVfrParser::_STOU64 (
}
if (c >= '0' && c <= '9') {
Value += (c - '0');
- }
+ }
}
return Value;
-}
+}
EFI_HII_DATE
EfiVfrParser::_STOD (
- IN INT8 *Year,
- IN INT8 *Month,
+ IN INT8 *Year,
+ IN INT8 *Month,
IN INT8 *Day
)
{
@@ -2851,8 +3100,8 @@ EfiVfrParser::_STOD (
EFI_HII_TIME
EfiVfrParser::_STOT (
- IN INT8 *Hour,
- IN INT8 *Minute,
+ IN INT8 *Hour,
+ IN INT8 *Minute,
IN INT8 *Second
)
{
@@ -2881,7 +3130,7 @@ EfiVfrParser::_STOFID (
return (EFI_FORM_ID)_STOU16(Str);
}
-EFI_QUESTION_ID
+EFI_QUESTION_ID
EfiVfrParser::_STOQID (
IN INT8 *Str
)
@@ -2918,17 +3167,17 @@ EfiVfrParser::_STRCAT (
VOID
EfiVfrParser::_CRGUID (
- IN EFI_GUID *Guid,
- IN INT8 *G1,
- IN INT8 *G2,
- IN INT8 *G3,
- IN INT8 *G4,
- IN INT8 *G5,
- IN INT8 *G6,
- IN INT8 *G7,
- IN INT8 *G8,
- IN INT8 *G9,
- IN INT8 *G10,
+ IN EFI_GUID *Guid,
+ IN INT8 *G1,
+ IN INT8 *G2,
+ IN INT8 *G3,
+ IN INT8 *G4,
+ IN INT8 *G5,
+ IN INT8 *G6,
+ IN INT8 *G7,
+ IN INT8 *G8,
+ IN INT8 *G9,
+ IN INT8 *G10,
IN INT8 *G11
)
{
@@ -2964,9 +3213,9 @@ EfiVfrParser::_DeclareDefaultLinearVarStore (
VSObj.SetLineNo (LineNo);
mCVfrDataStorage.DeclareBufferVarStore (
- TypeNameList[Index],
- &DefaultGuid,
- &mCVfrVarDataTypeDB,
+ TypeNameList[Index],
+ &DefaultGuid,
+ &mCVfrVarDataTypeDB,
TypeNameList[Index],
EFI_VARSTORE_ID_INVALID
);
@@ -2985,9 +3234,9 @@ EfiVfrParser::_DeclareDefaultLinearVarStore (
VSObj.SetLineNo (LineNo);
mCVfrDataStorage.DeclareBufferVarStore (
- "Date",
- &DefaultGuid,
- &mCVfrVarDataTypeDB,
+ "Date",
+ &DefaultGuid,
+ &mCVfrVarDataTypeDB,
"EFI_HII_DATE",
EFI_VARSTORE_ID_INVALID
);
@@ -3006,9 +3255,9 @@ EfiVfrParser::_DeclareDefaultLinearVarStore (
VSObj.SetLineNo (LineNo);
mCVfrDataStorage.DeclareBufferVarStore (
- "Time",
- &DefaultGuid,
- &mCVfrVarDataTypeDB,
+ "Time",
+ &DefaultGuid,
+ &mCVfrVarDataTypeDB,
"EFI_HII_TIME",
EFI_VARSTORE_ID_INVALID
);
@@ -3026,7 +3275,7 @@ EfiVfrParser::_DeclareStandardDefaultStorage (
IN UINT32 LineNo
)
{
- CIfrDefaultStore DSObj;
+ CIfrDefaultStore DSObj;
mCVfrDefaultStore.RegisterDefaultStore (DSObj.GetObjBinAddr(), "Standard Defaults", EFI_STRING_ID_INVALID, EFI_HII_DEFAULT_CLASS_STANDARD);
DSObj.SetLineNo (LineNo);
@@ -3036,7 +3285,7 @@ EfiVfrParser::_DeclareStandardDefaultStorage (
VOID
EfiVfrParser::AssignQuestionKey (
- IN CIfrQuestionHeader &QHObj,
+ IN CIfrQuestionHeader &QHObj,
IN ANTLRTokenPtr KeyTok
)
{
@@ -3059,7 +3308,7 @@ EfiVfrParser::AssignQuestionKey (
VOID
EfiVfrParser::ConvertIdExpr (
- IN UINT32 &ExpOpCount,
+ IN UINT32 &ExpOpCount,
IN UINT32 LineNo,
IN EFI_QUESTION_ID QId,
IN INT8 *VarIdStr,
@@ -3093,7 +3342,7 @@ EfiVfrParser::ConvertIdExpr (
VOID
EfiVfrParser::IdEqValDoSpecial (
- IN UINT32 &ExpOpCount,
+ IN UINT32 &ExpOpCount,
IN UINT32 LineNo,
IN EFI_QUESTION_ID QId,
IN INT8 *VarIdStr,
@@ -3145,7 +3394,7 @@ EfiVfrParser::IdEqValDoSpecial (
VOID
EfiVfrParser::IdEqIdDoSpecial (
- IN UINT32 &ExpOpCount,
+ IN UINT32 &ExpOpCount,
IN UINT32 LineNo,
IN EFI_QUESTION_ID QId1,
IN INT8 *VarId1Str,
@@ -3192,7 +3441,7 @@ EfiVfrParser::IdEqIdDoSpecial (
VOID
EfiVfrParser::IdEqListDoSpecial (
- IN UINT32 &ExpOpCount,
+ IN UINT32 &ExpOpCount,
IN UINT32 LineNo,
IN EFI_QUESTION_ID QId,
IN INT8 *VarIdStr,
diff --git a/EdkCompatibilityPkg/Sample/Tools/Source/UefiVfrCompile/VfrUtilityLib.cpp b/EdkCompatibilityPkg/Sample/Tools/Source/UefiVfrCompile/VfrUtilityLib.cpp
index caadc29da9..d6f5f437f2 100644
--- a/EdkCompatibilityPkg/Sample/Tools/Source/UefiVfrCompile/VfrUtilityLib.cpp
+++ b/EdkCompatibilityPkg/Sample/Tools/Source/UefiVfrCompile/VfrUtilityLib.cpp
@@ -1,5 +1,4 @@
/*++
-
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
@@ -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.
Module Name:
-
-VfrUtilityLib.cpp
+ VfrUtilityLib.cpp
Abstract:
@@ -74,12 +72,13 @@ CVfrBinaryOutput::WriteEnd (
}
SConfigInfo::SConfigInfo (
- IN UINT8 Type,
- IN UINT16 Offset,
- IN UINT32 Width,
+ IN UINT8 Type,
+ IN UINT16 Offset,
+ IN UINT32 Width,
IN EFI_IFR_TYPE_VALUE Value
)
{
+ mNext = NULL;
mOffset = Offset;
mWidth = (UINT16)Width;
mValue = new UINT8[mWidth];
@@ -125,51 +124,51 @@ SConfigInfo::~SConfigInfo (
}
SConfigItem::SConfigItem (
- IN INT8 *Id,
- IN INT8 *Info
+ IN INT8 *Name,
+ IN INT8 *Id
)
{
- mId = NULL;
- mInfo = NULL;
+ mName = NULL;
+ mId = NULL;
mInfoStrList = NULL;
mNext = NULL;
- if (Id != NULL) {
- if ((mId = new INT8[strlen (Id) + 1]) != NULL) {
- strcpy (mId, Id);
+ if (Name != NULL) {
+ if ((mName = new INT8[strlen (Name) + 1]) != NULL) {
+ strcpy (mName, Name);
}
}
- if (Info != NULL) {
- if ((mInfo = new INT8[strlen (Info) + 1]) != NULL) {
- strcpy (mInfo, Info);
+ if (Id != NULL) {
+ if ((mId = new INT8[strlen (Id) + 1]) != NULL) {
+ strcpy (mId, Id);
}
}
}
SConfigItem::SConfigItem (
- IN INT8 *Id,
- IN INT8 *Info,
+ IN INT8 *Name,
+ IN INT8 *Id,
IN UINT8 Type,
IN UINT16 Offset,
IN UINT16 Width,
IN EFI_IFR_TYPE_VALUE Value
)
{
+ mName = NULL;
mId = NULL;
- mInfo = NULL;
mInfoStrList = NULL;
mNext = NULL;
- if (Id != NULL) {
- if ((mId = new INT8[strlen (Id) + 1]) != NULL) {
- strcpy (mId, Id);
+ if (Name != NULL) {
+ if ((mName = new INT8[strlen (Name) + 1]) != NULL) {
+ strcpy (mName, Name);
}
}
- if (Info != NULL) {
- if ((mInfo = new INT8[strlen (Info) + 1]) != NULL) {
- strcpy (mInfo, Info);
+ if (Id != NULL) {
+ if ((mId = new INT8[strlen (Id) + 1]) != NULL) {
+ strcpy (mId, Id);
}
}
@@ -182,8 +181,8 @@ SConfigItem::~SConfigItem (
{
SConfigInfo *Info;
+ BUFFER_SAFE_FREE (mName);
BUFFER_SAFE_FREE (mId);
- BUFFER_SAFE_FREE (mInfo);
while (mInfoStrList != NULL) {
Info = mInfoStrList;
mInfoStrList = mInfoStrList->mNext;
@@ -194,17 +193,17 @@ SConfigItem::~SConfigItem (
UINT8
CVfrBufferConfig::Register (
- IN INT8 *Id,
- IN INT8 *Info
+ IN INT8 *Name,
+ IN INT8 *Id
)
{
SConfigItem *pNew;
- if (Select (Id) == 0) {
+ if (Select (Name) == 0) {
return 1;
}
- if ((pNew = new SConfigItem (Id, Info)) == NULL) {
+ if ((pNew = new SConfigItem (Name, Id)) == NULL) {
return 2;
}
if (mItemListHead == NULL) {
@@ -237,25 +236,27 @@ CVfrBufferConfig::Eof(
UINT8
CVfrBufferConfig::Select (
- IN INT8 *Id,
- IN INT8 *Info
+ IN INT8 *Name,
+ IN INT8 *Id
)
{
SConfigItem *p;
- if (Id == NULL) {
+ if (Name == NULL) {
mItemListPos = mItemListHead;
return 0;
} else {
for (p = mItemListHead; p != NULL; p = p->mNext) {
- if (strcmp (p->mId, Id) != 0) {
+ if (strcmp (p->mName, Name) != 0) {
continue;
}
- if ((p->mInfo != NULL) && (Info != NULL)) {
- if (strcmp (p->mInfo, Info) != 0) {
+ if (Id != NULL) {
+ if (p->mId == NULL || strcmp (p->mId, Id) != 0) {
continue;
}
+ } else if (p->mId != NULL) {
+ continue;
}
mItemListPos = p;
@@ -269,8 +270,8 @@ CVfrBufferConfig::Select (
UINT8
CVfrBufferConfig::Write (
IN CONST CHAR8 Mode,
- IN INT8 *Id,
- IN INT8 *Info,
+ IN INT8 *Name,
+ IN INT8 *Id,
IN UINT8 Type,
IN UINT16 Offset,
IN UINT32 Width,
@@ -281,16 +282,14 @@ CVfrBufferConfig::Write (
SConfigItem *pItem;
SConfigInfo *pInfo;
+ if ((Ret = Select (Name)) != 0) {
+ return Ret;
+ }
+
switch (Mode) {
case 'a' : // add
- if (Select (Id) == 0) {
- if((pInfo = new SConfigInfo (Type, Offset, Width, Value)) == NULL) {
- return 2;
- }
- pInfo->mNext = mItemListPos->mInfoStrList;
- mItemListPos->mInfoStrList = pInfo;
- } else {
- if ((pItem = new SConfigItem (Id, Info, Type, Offset, Width, Value)) == NULL) {
+ if (Select (Name, Id) != 0) {
+ if ((pItem = new SConfigItem (Name, Id, Type, Offset, Width, Value)) == NULL) {
return 2;
}
if (mItemListHead == NULL) {
@@ -301,14 +300,26 @@ CVfrBufferConfig::Write (
mItemListTail = pItem;
}
mItemListPos = pItem;
+ } else {
+ // tranverse the list to find out if there's already the value for the same offset
+ for (pInfo = mItemListPos->mInfoStrList; pInfo != NULL; pInfo = pInfo->mNext) {
+ if (pInfo->mOffset == Offset) {
+ // check if the value and width are the same; return error if not
+ if ((Id != NULL) && (pInfo->mWidth != Width || memcmp(pInfo->mValue, &Value, Width) != 0)) {
+ return VFR_RETURN_DEFAULT_VALUE_REDEFINED;
+ }
+ return 0;
+ }
+ }
+ if((pInfo = new SConfigInfo (Type, Offset, Width, Value)) == NULL) {
+ return 2;
+ }
+ pInfo->mNext = mItemListPos->mInfoStrList;
+ mItemListPos->mInfoStrList = pInfo;
}
break;
case 'd' : // delete
- if ((Ret = Select (Id)) != 0) {
- return Ret;
- }
-
if (mItemListHead == mItemListPos) {
mItemListHead = mItemListPos->mNext;
delete mItemListPos;
@@ -327,18 +338,15 @@ CVfrBufferConfig::Write (
break;
case 'i' : // set info
- if ((Ret = Select (Id)) != 0) {
- return Ret;
- }
- if (mItemListPos->mInfo != NULL) {
- delete mItemListPos->mInfo;
+ if (mItemListPos->mId != NULL) {
+ delete mItemListPos->mId;
}
- mItemListPos->mInfo = NULL;
- if (Info != NULL) {
- if ((mItemListPos->mInfo = new INT8[strlen (Info) + 1]) == NULL) {
+ mItemListPos->mId = NULL;
+ if (Id != NULL) {
+ if ((mItemListPos->mId = new INT8[strlen (Id) + 1]) == NULL) {
return 2;
}
- strcpy (mItemListPos->mInfo, Info);
+ strcpy (mItemListPos->mId, Id);
}
break;
@@ -352,29 +360,29 @@ CVfrBufferConfig::Write (
#if 0
UINT8
CVfrBufferConfig::ReadId (
- OUT INT8 **Id,
- OUT INT8 **Info
+ OUT INT8 **Name,
+ OUT INT8 **Id
)
{
if (mInfoStrItemListPos == NULL) {
return 1; // end read or some error occur
}
+ if (Name != NULL) {
+ *Name = new INT8 (strlen (mInfoStrItemListPos->mName + 1));
+ strcpy (*Name, mInfoStrItemListPos->mName);
+ }
if (Id != NULL) {
*Id = new INT8 (strlen (mInfoStrItemListPos->mId + 1));
strcpy (*Id, mInfoStrItemListPos->mId);
}
- if (Info != NULL) {
- *Info = new INT8 (strlen (mInfoStrItemListPos->mInfo + 1));
- strcpy (*Info, mInfoStrItemListPos->mInfo);
- }
return 0;
}
UINT8
CVfrBufferConfig::ReadInfo (
- IN INT8 *Id,
+ IN INT8 *Name,
IN UINT32 Index,
IN OUT UINT32 &Number,
OUT INT8 *Offset,
@@ -387,8 +395,8 @@ CVfrBufferConfig::ReadInfo (
UINT32 idx;
UINT32 num;
- if (Id != NULL) {
- if ((ret = Select (Id)) != 0) {
+ if (Name != NULL) {
+ if ((ret = Select (Name)) != 0) {
return ret;
}
}
@@ -473,8 +481,28 @@ CVfrBufferConfig::OutputCFile (
}
for (Item = mItemListHead; Item != NULL; Item = Item->mNext) {
- if (Item->mInfoStrList != NULL) {
- fprintf (pFile, "\nunsigned char %s%sDefault%04x[] = {", BaseName, Item->mId, Item->mInfo);
+ if (Item->mId != NULL || Item->mInfoStrList == NULL) {
+ continue;
+ }
+ fprintf (pFile, "\nunsigned char %s%sBlockName[] = {", BaseName, Item->mName);
+
+ TotalLen = sizeof (UINT32);
+ for (Info = Item->mInfoStrList; Info != NULL; Info = Info->mNext) {
+ TotalLen += sizeof (UINT16) * 2;
+ }
+ Output.WriteLine (pFile, BYTES_PRE_LINE, " ", (INT8 *)&TotalLen, sizeof (UINT32));
+
+ for (Info = Item->mInfoStrList; Info != NULL; Info = Info->mNext) {
+ fprintf (pFile, "\n");
+ Output.WriteLine (pFile, BYTES_PRE_LINE, " ", (INT8 *)&Info->mOffset, sizeof (UINT16));
+ Output.WriteLine (pFile, BYTES_PRE_LINE, " ", (INT8 *)&Info->mWidth, sizeof (UINT16));
+ }
+ fprintf (pFile, "\n};\n");
+ }
+
+ for (Item = mItemListHead; Item != NULL; Item = Item->mNext) {
+ if (Item->mId != NULL && Item->mInfoStrList != NULL) {
+ fprintf (pFile, "\nunsigned char %s%sDefault%s[] = {", BaseName, Item->mName, Item->mId);
TotalLen = sizeof (UINT32);
for (Info = Item->mInfoStrList; Info != NULL; Info = Info->mNext) {
@@ -483,6 +511,7 @@ CVfrBufferConfig::OutputCFile (
Output.WriteLine (pFile, BYTES_PRE_LINE, " ", (INT8 *)&TotalLen, sizeof (UINT32));
for (Info = Item->mInfoStrList; Info != NULL; Info = Info->mNext) {
+ fprintf (pFile, "\n");
Output.WriteLine (pFile, BYTES_PRE_LINE, " ", (INT8 *)&Info->mOffset, sizeof (UINT16));
Output.WriteLine (pFile, BYTES_PRE_LINE, " ", (INT8 *)&Info->mWidth, sizeof (UINT16));
if (Info->mNext == NULL) {
@@ -490,9 +519,8 @@ CVfrBufferConfig::OutputCFile (
} else {
Output.WriteLine (pFile, BYTES_PRE_LINE, " ", (INT8 *)Info->mValue, Info->mWidth);
}
- fprintf (pFile, "\n");
}
- fprintf (pFile, "};\n");
+ fprintf (pFile, "\n};\n");
}
}
}
@@ -536,7 +564,7 @@ static struct {
{"UINT16", EFI_IFR_TYPE_NUM_SIZE_16, sizeof (UINT16), sizeof (UINT16)},
{"UINT8", EFI_IFR_TYPE_NUM_SIZE_8, sizeof (UINT8), sizeof (UINT8)},
{"BOOLEAN", EFI_IFR_TYPE_BOOLEAN, sizeof (BOOLEAN), sizeof (BOOLEAN)},
- {"EFI_HII_DATE", EFI_IFR_TYPE_DATE, sizeof (EFI_HII_DATE), sizeof (UINT8)},
+ {"EFI_HII_DATE", EFI_IFR_TYPE_DATE, sizeof (EFI_HII_DATE), sizeof (UINT16)},
{"EFI_STRING_ID", EFI_IFR_TYPE_STRING, sizeof (EFI_STRING_ID),sizeof (EFI_STRING_ID)},
{"EFI_HII_TIME", EFI_IFR_TYPE_TIME, sizeof (EFI_HII_TIME), sizeof (UINT8)},
{NULL, EFI_IFR_TYPE_OTHER, 0, 0}
@@ -610,7 +638,7 @@ _STR2U32 (
}
if (c >= '0' && c <= '9') {
Value += (c - '0');
- }
+ }
}
return Value;
@@ -627,7 +655,7 @@ CVfrVarDataTypeDB::RegisterNewType (
EFI_VFR_RETURN_CODE
CVfrVarDataTypeDB::ExtractStructTypeName (
- IN INT8 *&VarStr,
+ IN INT8 *&VarStr,
OUT INT8 *TName
)
{
@@ -650,7 +678,7 @@ CVfrVarDataTypeDB::ExtractStructTypeName (
EFI_VFR_RETURN_CODE
CVfrVarDataTypeDB::ExtractFieldNameAndArrary (
- IN INT8 *&VarStr,
+ IN INT8 *&VarStr,
IN INT8 *FName,
OUT UINT32 &ArrayIdx
)
@@ -658,15 +686,15 @@ CVfrVarDataTypeDB::ExtractFieldNameAndArrary (
UINT32 Idx;
INT8 ArrayStr[MAX_NAME_LEN + 1];
- ArrayIdx = INVALID_ARRAY_INDEX;
+ ArrayIdx = INVALID_ARRAY_INDEX;
if (FName == NULL) {
return VFR_RETURN_FATAL_ERROR;
}
while((*VarStr != '\0') &&
- (*VarStr != '.') &&
- (*VarStr != '[') &&
+ (*VarStr != '.') &&
+ (*VarStr != '[') &&
(*VarStr != ']')) {
*FName = *VarStr;
VarStr++;
@@ -703,8 +731,8 @@ CVfrVarDataTypeDB::ExtractFieldNameAndArrary (
EFI_VFR_RETURN_CODE
CVfrVarDataTypeDB::GetTypeField (
- IN INT8 *FName,
- IN SVfrDataType *Type,
+ IN INT8 *FName,
+ IN SVfrDataType *Type,
OUT SVfrDataField *&Field
)
{
@@ -726,7 +754,7 @@ CVfrVarDataTypeDB::GetTypeField (
EFI_VFR_RETURN_CODE
CVfrVarDataTypeDB::GetFieldOffset (
- IN SVfrDataField *Field,
+ IN SVfrDataField *Field,
IN UINT32 ArrayIdx,
OUT UINT32 &Offset
)
@@ -834,7 +862,7 @@ CVfrVarDataTypeDB::InternalTypesListInit (
pSecondsField->mNext = NULL;
pSecondsField->mArrayNum = 0;
- New->mMembers = pHoursField;
+ New->mMembers = pHoursField;
} else {
New->mMembers = NULL;
}
@@ -853,6 +881,7 @@ CVfrVarDataTypeDB::CVfrVarDataTypeDB (
mNewDataType = NULL;
mCurrDataField = NULL;
mPackAlign = DEFAULT_PACK_ALIGN;
+ mPackStack = NULL;
InternalTypesListInit ();
}
@@ -861,8 +890,9 @@ CVfrVarDataTypeDB::~CVfrVarDataTypeDB (
VOID
)
{
- SVfrDataType *pType;
- SVfrDataField *pField;
+ SVfrDataType *pType;
+ SVfrDataField *pField;
+ SVfrPackStackNode *pPack;
if (mNewDataType != NULL) {
delete mNewDataType;
@@ -879,30 +909,64 @@ CVfrVarDataTypeDB::~CVfrVarDataTypeDB (
delete pType;
}
+ while (mPackStack != NULL) {
+ pPack = mPackStack;
+ mPackStack = mPackStack->mNext;
+ delete pPack;
+ }
}
EFI_VFR_RETURN_CODE
CVfrVarDataTypeDB::Pack (
- IN UINT32 Align
+ IN UINT32 LineNum,
+ IN UINT8 Action,
+ IN INT8 *Identifier,
+ IN UINT32 Number
)
{
- if (Align == 0) {
- return VFR_RETURN_INVALID_PARAMETER;
- } else if (Align > 1) {
- mPackAlign = Align + Align % 2;
- } else {
- mPackAlign = Align;
+ UINT32 PackAlign;
+ INT8 Msg[64] = {0, };
+
+ if (Action & VFR_PACK_SHOW) {
+ sprintf (Msg, "value of pragma pack(show) == %d", mPackAlign);
+ gCVfrErrorHandle.PrintMsg (LineNum, "", "Warning", Msg);
}
- return VFR_RETURN_SUCCESS;
-}
+ if (Action & VFR_PACK_PUSH) {
+ SVfrPackStackNode *pNew = NULL;
-VOID
-CVfrVarDataTypeDB::UnPack (
- VOID
- )
-{
- mPackAlign = DEFAULT_PACK_ALIGN;
+ if ((pNew = new SVfrPackStackNode (Identifier, mPackAlign)) == NULL) {
+ return VFR_RETURN_FATAL_ERROR;
+ }
+ pNew->mNext = mPackStack;
+ mPackStack = pNew;
+ }
+
+ if (Action & VFR_PACK_POP) {
+ SVfrPackStackNode *pNode = NULL;
+
+ if (mPackStack == NULL) {
+ gCVfrErrorHandle.PrintMsg (LineNum, "", "Warning", "#pragma pack(pop...) : more pops than pushes");
+ }
+
+ for (pNode = mPackStack; pNode != NULL; pNode = pNode->mNext) {
+ if (pNode->Match (Identifier) == TRUE) {
+ mPackAlign = pNode->mNumber;
+ mPackStack = pNode->mNext;
+ }
+ }
+ }
+
+ if (Action & VFR_PACK_ASSIGN) {
+ PackAlign = (Number > 1) ? Number + Number % 2 : Number;
+ if ((PackAlign == 0) || (PackAlign > 16)) {
+ gCVfrErrorHandle.PrintMsg (LineNum, "", "Warning", "expected pragma parameter to be '1', '2', '4', '8', or '16'");
+ } else {
+ mPackAlign = PackAlign;
+ }
+ }
+
+ return VFR_RETURN_SUCCESS;
}
VOID
@@ -952,8 +1016,8 @@ CVfrVarDataTypeDB::SetNewTypeName (
EFI_VFR_RETURN_CODE
CVfrVarDataTypeDB::DataTypeAddField (
- IN INT8 *FieldName,
- IN INT8 *TypeName,
+ IN INT8 *FieldName,
+ IN INT8 *TypeName,
IN UINT32 ArrayNum
)
{
@@ -991,7 +1055,7 @@ CVfrVarDataTypeDB::DataTypeAddField (
mNewDataType->mMembers = pNewField;
pNewField->mNext = NULL;
} else {
- for (pTmp = mNewDataType->mMembers; pTmp->mNext != NULL; pTmp = pTmp->mNext)
+ for (pTmp = mNewDataType->mMembers; pTmp->mNext != NULL; pTmp = pTmp->mNext)
;
pTmp->mNext = pNewField;
pNewField->mNext = NULL;
@@ -1051,6 +1115,38 @@ CVfrVarDataTypeDB::GetDataType (
EFI_VFR_RETURN_CODE
CVfrVarDataTypeDB::GetDataTypeSize (
+ IN UINT8 DataType,
+ OUT UINT32 *Size
+ )
+{
+ SVfrDataType *pDataType = NULL;
+
+ if (Size == NULL) {
+ return VFR_RETURN_FATAL_ERROR;
+ }
+
+ *Size = 0;
+ DataType = DataType & 0x0F;
+
+ //
+ // For user defined data type, the size can't be got by this function.
+ //
+ if (DataType == EFI_IFR_TYPE_OTHER) {
+ return VFR_RETURN_SUCCESS;
+ }
+
+ for (pDataType = mDataTypeList; pDataType != NULL; pDataType = pDataType->mNext) {
+ if (DataType == pDataType->mType) {
+ *Size = pDataType->mTotalSize;
+ return VFR_RETURN_SUCCESS;
+ }
+ }
+
+ return VFR_RETURN_UNDEFINED;
+}
+
+EFI_VFR_RETURN_CODE
+CVfrVarDataTypeDB::GetDataTypeSize (
IN INT8 *TypeName,
OUT UINT32 *Size
)
@@ -1075,9 +1171,9 @@ CVfrVarDataTypeDB::GetDataTypeSize (
EFI_VFR_RETURN_CODE
CVfrVarDataTypeDB::GetDataFieldInfo (
- IN INT8 *VarStr,
- OUT UINT16 &Offset,
- OUT UINT8 &Type,
+ IN INT8 *VarStr,
+ OUT UINT16 &Offset,
+ OUT UINT8 &Type,
OUT UINT32 &Size
)
{
@@ -1113,7 +1209,7 @@ CVfrVarDataTypeDB::GetDataFieldInfo (
EFI_VFR_RETURN_CODE
CVfrVarDataTypeDB::GetUserDefinedTypeNameList (
- OUT INT8 ***NameList,
+ OUT INT8 ***NameList,
OUT UINT32 *ListSize
)
{
@@ -1444,10 +1540,10 @@ CVfrDataStorage::DeclareNameVarStoreEnd (
return VFR_RETURN_SUCCESS;
}
-EFI_VFR_RETURN_CODE
+EFI_VFR_RETURN_CODE
CVfrDataStorage::DeclareEfiVarStore (
- IN INT8 *StoreName,
- IN EFI_GUID *Guid,
+ IN INT8 *StoreName,
+ IN EFI_GUID *Guid,
IN EFI_STRING_ID NameStrId,
IN UINT32 VarSize
)
@@ -1480,10 +1576,10 @@ CVfrDataStorage::DeclareEfiVarStore (
return VFR_RETURN_SUCCESS;
}
-EFI_VFR_RETURN_CODE
+EFI_VFR_RETURN_CODE
CVfrDataStorage::DeclareBufferVarStore (
- IN INT8 *StoreName,
- IN EFI_GUID *Guid,
+ IN INT8 *StoreName,
+ IN EFI_GUID *Guid,
IN CVfrVarDataTypeDB *DataTypeDB,
IN INT8 *TypeName,
IN EFI_VARSTORE_ID VarStoreId
@@ -1521,7 +1617,7 @@ CVfrDataStorage::DeclareBufferVarStore (
return VFR_RETURN_SUCCESS;
}
-EFI_VFR_RETURN_CODE
+EFI_VFR_RETURN_CODE
CVfrDataStorage::GetVarStoreId (
IN INT8 *StoreName,
OUT EFI_VARSTORE_ID *VarStoreId
@@ -1625,9 +1721,47 @@ CVfrDataStorage::GetVarStoreType (
return VFR_RETURN_UNDEFINED;
}
+EFI_VFR_VARSTORE_TYPE
+CVfrDataStorage::GetVarStoreType (
+ IN EFI_VARSTORE_ID VarStoreId
+ )
+{
+ SVfrVarStorageNode *pNode;
+ EFI_VFR_VARSTORE_TYPE VarStoreType;
+
+ VarStoreType = EFI_VFR_VARSTORE_INVALID;
+
+ if (VarStoreId == EFI_VARSTORE_ID_INVALID) {
+ return VarStoreType;
+ }
+
+ for (pNode = mBufferVarStoreList; pNode != NULL; pNode = pNode->mNext) {
+ if (pNode->mVarStoreId == VarStoreId) {
+ VarStoreType = pNode->mVarStoreType;
+ return VarStoreType;
+ }
+ }
+
+ for (pNode = mEfiVarStoreList; pNode != NULL; pNode = pNode->mNext) {
+ if (pNode->mVarStoreId == VarStoreId) {
+ VarStoreType = pNode->mVarStoreType;
+ return VarStoreType;
+ }
+ }
+
+ for (pNode = mNameVarStoreList; pNode != NULL; pNode = pNode->mNext) {
+ if (pNode->mVarStoreId == VarStoreId) {
+ VarStoreType = pNode->mVarStoreType;
+ return VarStoreType;
+ }
+ }
+
+ return VarStoreType;
+}
+
EFI_VFR_RETURN_CODE
CVfrDataStorage::GetVarStoreName (
- IN EFI_VARSTORE_ID VarStoreId,
+ IN EFI_VARSTORE_ID VarStoreId,
OUT INT8 **VarStoreName
)
{
@@ -1725,7 +1859,7 @@ CVfrDataStorage::BufferVarStoreRequestElementAdd (
INT8 NewReqElt[128] = {'\0',};
INT8 *OldReqElt = NULL;
SVfrVarStorageNode *pNode = NULL;
- EFI_IFR_TYPE_VALUE Value;
+ EFI_IFR_TYPE_VALUE Value = {0};
for (pNode = mBufferVarStoreList; pNode != NULL; pNode = pNode->mNext) {
if (strcmp (pNode->mVarStoreName, StoreName) == NULL) {
@@ -1749,8 +1883,8 @@ CVfrDataStorage::BufferVarStoreRequestElementAdd (
SVfrDefaultStoreNode::SVfrDefaultStoreNode (
IN EFI_IFR_DEFAULTSTORE *ObjBinAddr,
- IN INT8 *RefName,
- IN EFI_STRING_ID DefaultStoreNameId,
+ IN INT8 *RefName,
+ IN EFI_STRING_ID DefaultStoreNameId,
IN UINT16 DefaultId
)
{
@@ -1828,7 +1962,7 @@ CVfrDefaultStore::RegisterDefaultStore (
}
/*
- * assign new reference name or new default store name id only if
+ * assign new reference name or new default store name id only if
* the original is invalid
*/
EFI_VFR_RETURN_CODE
@@ -1911,8 +2045,8 @@ CVfrDefaultStore::GetDefaultId (
STATIC
EFI_VFR_RETURN_CODE
AltCfgItemPrintToBuffer (
- IN INT8 *NewAltCfg,
- IN EFI_VARSTORE_INFO Info,
+ IN INT8 *NewAltCfg,
+ IN EFI_VARSTORE_INFO Info,
IN UINT8 Type,
IN EFI_IFR_TYPE_VALUE Value
)
@@ -1923,9 +2057,9 @@ AltCfgItemPrintToBuffer (
if (NewAltCfg != NULL) {
Count = sprintf (
- NewAltCfg,
- "&OFFSET=%x&WIDTH=%x&VALUE=",
- Info.mInfo.mVarOffset,
+ NewAltCfg,
+ "&OFFSET=%x&WIDTH=%x&VALUE=",
+ Info.mInfo.mVarOffset,
Info.mVarTotalSize
);
NewAltCfg += Count;
@@ -1984,7 +2118,7 @@ AltCfgItemPrintToBuffer (
}
}
- return VFR_RETURN_FATAL_ERROR;
+ return VFR_RETURN_FATAL_ERROR;
}
EFI_VFR_RETURN_CODE
@@ -1998,6 +2132,7 @@ CVfrDefaultStore::BufferVarStoreAltConfigAdd (
{
SVfrDefaultStoreNode *pNode = NULL;
INT8 NewAltCfg[2 * 2 * sizeof (UINT16) + 1] = {0,};
+ INTN Returnvalue = 0;
if (VarStoreName == NULL) {
return VFR_RETURN_FATAL_ERROR;
@@ -2016,28 +2151,23 @@ CVfrDefaultStore::BufferVarStoreAltConfigAdd (
gCVfrBufferConfig.Open ();
sprintf (NewAltCfg, "%04x", pNode->mDefaultId);
- if ((gCVfrBufferConfig.Select(VarStoreName) == 0) &&
- (gCVfrBufferConfig.Select(VarStoreName, NewAltCfg) != 0)) {
- if (gCVfrBufferConfig.Write ('i', VarStoreName, NewAltCfg, Type, Info.mInfo.mVarOffset, Info.mVarTotalSize, Value) != 0) {
+ if ((Returnvalue = gCVfrBufferConfig.Select(VarStoreName)) == 0) {
+ if ((Returnvalue = gCVfrBufferConfig.Write ('a', VarStoreName, NewAltCfg, Type, Info.mInfo.mVarOffset, Info.mVarTotalSize, Value)) != 0) {
goto WriteError;
}
}
- if (gCVfrBufferConfig.Write ('a', VarStoreName, NULL, Type, Info.mInfo.mVarOffset, Info.mVarTotalSize, Value) != 0) {
- goto WriteError;
- }
-
gCVfrBufferConfig.Close ();
return VFR_RETURN_SUCCESS;
WriteError:
gCVfrBufferConfig.Close ();
- return VFR_RETURN_FATAL_ERROR;
+ return (EFI_VFR_RETURN_CODE)Returnvalue;
}
SVfrRuleNode::SVfrRuleNode (
- IN INT8 *RuleName,
+ IN INT8 *RuleName,
IN UINT8 RuleId
)
{
@@ -2143,7 +2273,7 @@ EFI_VARSTORE_INFO::EFI_VARSTORE_INFO (
mVarTotalSize = Info.mVarTotalSize;
}
-BOOLEAN
+BOOLEAN
EFI_VARSTORE_INFO::operator == (
IN EFI_VARSTORE_INFO *Info
)
@@ -2195,7 +2325,7 @@ CVfrQuestionDB::ChekQuestionIdFree (
return (mFreeQIdBitMap[Index] & (0x80000000 >> Offset)) == 0;
}
-VOID
+VOID
CVfrQuestionDB::MarkQuestionIdUsed (
IN EFI_QUESTION_ID QId
)
@@ -2206,7 +2336,7 @@ CVfrQuestionDB::MarkQuestionIdUsed (
mFreeQIdBitMap[Index] |= (0x80000000 >> Offset);
}
-VOID
+VOID
CVfrQuestionDB::MarkQuestionIdUnused (
IN EFI_QUESTION_ID QId
)
@@ -2321,9 +2451,9 @@ CVfrQuestionDB::RegisterQuestion (
VOID
CVfrQuestionDB::RegisterOldDateQuestion (
- IN INT8 *YearVarId,
- IN INT8 *MonthVarId,
- IN INT8 *DayVarId,
+ IN INT8 *YearVarId,
+ IN INT8 *MonthVarId,
+ IN INT8 *DayVarId,
IN OUT EFI_QUESTION_ID &QuestionId
)
{
@@ -2379,7 +2509,7 @@ Err:
VOID
CVfrQuestionDB::RegisterNewDateQuestion (
IN INT8 *Name,
- IN INT8 *BaseVarId,
+ IN INT8 *BaseVarId,
IN OUT EFI_QUESTION_ID &QuestionId
)
{
@@ -2463,9 +2593,9 @@ Err:
VOID
CVfrQuestionDB::RegisterOldTimeQuestion (
- IN INT8 *HourVarId,
- IN INT8 *MinuteVarId,
- IN INT8 *SecondVarId,
+ IN INT8 *HourVarId,
+ IN INT8 *MinuteVarId,
+ IN INT8 *SecondVarId,
IN OUT EFI_QUESTION_ID &QuestionId
)
{
@@ -2634,7 +2764,7 @@ CVfrQuestionDB::UpdateQuestionId (
return VFR_RETURN_SUCCESS;
}
-VOID
+VOID
CVfrQuestionDB::GetQuestionId (
IN INT8 *Name,
IN INT8 *VarIdStr,
@@ -2672,7 +2802,7 @@ CVfrQuestionDB::GetQuestionId (
return ;
}
-EFI_VFR_RETURN_CODE
+EFI_VFR_RETURN_CODE
CVfrQuestionDB::FindQuestion (
IN EFI_QUESTION_ID QuestionId
)
@@ -2692,7 +2822,7 @@ CVfrQuestionDB::FindQuestion (
return VFR_RETURN_UNDEFINED;
}
-EFI_VFR_RETURN_CODE
+EFI_VFR_RETURN_CODE
CVfrQuestionDB::FindQuestion (
IN INT8 *Name
)
diff --git a/EdkCompatibilityPkg/Sample/Tools/Source/UefiVfrCompile/VfrUtilityLib.h b/EdkCompatibilityPkg/Sample/Tools/Source/UefiVfrCompile/VfrUtilityLib.h
index 38687b948d..fe37f83e16 100644
--- a/EdkCompatibilityPkg/Sample/Tools/Source/UefiVfrCompile/VfrUtilityLib.h
+++ b/EdkCompatibilityPkg/Sample/Tools/Source/UefiVfrCompile/VfrUtilityLib.h
@@ -1,5 +1,4 @@
/*++
-
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
@@ -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.
Module Name:
-
-VfrUtilityLib.h
+ VfrUtilityLib.h
Abstract:
@@ -28,7 +26,7 @@ Abstract:
#define MAX_NAME_LEN 64
#define DEFAULT_ALIGN 1
-#define DEFAULT_PACK_ALIGN 0xFFFFFFFF
+#define DEFAULT_PACK_ALIGN 0x8
#define DEFAULT_NAME_TABLE_ITEMS 1024
#define EFI_BITS_SHIFT_PER_UINT32 0x5
@@ -58,9 +56,9 @@ struct SConfigInfo {
};
struct SConfigItem {
- INT8 *mId;
- INT8 *mInfo;
- SConfigInfo *mInfoStrList;
+ INT8 *mName; // varstore name
+ INT8 *mId; // varstore ID
+ SConfigInfo *mInfoStrList; // list of Offset/Value in the varstore
SConfigItem *mNext;
public:
@@ -115,10 +113,59 @@ struct SVfrDataType {
SVfrDataType *mNext;
};
+#define VFR_PACK_ASSIGN 0x01
+#define VFR_PACK_SHOW 0x02
+#define VFR_PACK_PUSH 0x04
+#define VFR_PACK_POP 0x08
+
+#define PACKSTACK_MAX_SIZE 0x400
+
+struct SVfrPackStackNode {
+ INT8 *mIdentifier;
+ UINT32 mNumber;
+ SVfrPackStackNode *mNext;
+
+ SVfrPackStackNode (IN INT8 *Identifier, IN UINT32 Number) {
+ mIdentifier = NULL;
+ mNumber = Number;
+ mNext = NULL;
+
+ if (Identifier != NULL) {
+ mIdentifier = new INT8[strlen (Identifier) + 1];
+ strcpy (mIdentifier, Identifier);
+ }
+ }
+
+ ~SVfrPackStackNode (VOID) {
+ if (mIdentifier != NULL) {
+ delete mIdentifier;
+ }
+ mNext = NULL;
+ }
+
+ bool Match (IN INT8 *Identifier) {
+ if (Identifier == NULL) {
+ return TRUE;
+ } else if (mIdentifier == NULL) {
+ return FALSE;
+ } else if (strcmp (Identifier, mIdentifier) == 0) {
+ return TRUE;
+ } else {
+ return FALSE;
+ }
+ }
+};
+
class CVfrVarDataTypeDB {
private:
- SVfrDataType *mDataTypeList;
UINT32 mPackAlign;
+ SVfrPackStackNode *mPackStack;
+
+public:
+ EFI_VFR_RETURN_CODE Pack (IN UINT32, IN UINT8, IN INT8 *Identifier = NULL, IN UINT32 Number = DEFAULT_PACK_ALIGN);
+
+private:
+ SVfrDataType *mDataTypeList;
SVfrDataType *mNewDataType;
SVfrDataType *mCurrDataType;
@@ -138,9 +185,6 @@ public:
CVfrVarDataTypeDB (VOID);
~CVfrVarDataTypeDB (VOID);
- EFI_VFR_RETURN_CODE Pack (IN UINT32);
- VOID UnPack (VOID);
-
VOID DeclareDataTypeBegin (VOID);
EFI_VFR_RETURN_CODE SetNewTypeName (IN INT8 *);
EFI_VFR_RETURN_CODE DataTypeAddField (IN INT8 *, IN INT8 *, IN UINT32);
@@ -148,6 +192,7 @@ public:
EFI_VFR_RETURN_CODE GetDataType (IN INT8 *, OUT SVfrDataType **);
EFI_VFR_RETURN_CODE GetDataTypeSize (IN INT8 *, OUT UINT32 *);
+ EFI_VFR_RETURN_CODE GetDataTypeSize (IN UINT8, OUT UINT32 *);
EFI_VFR_RETURN_CODE GetDataFieldInfo (IN INT8 *, OUT UINT16 &, OUT UINT8 &, OUT UINT32 &);
EFI_VFR_RETURN_CODE GetUserDefinedTypeNameList (OUT INT8 ***, OUT UINT32 *);
@@ -245,6 +290,7 @@ public:
EFI_VFR_RETURN_CODE GetVarStoreId (IN INT8 *, OUT EFI_VARSTORE_ID *);
EFI_VFR_RETURN_CODE GetVarStoreType (IN INT8 *, OUT EFI_VFR_VARSTORE_TYPE &);
+ EFI_VFR_VARSTORE_TYPE GetVarStoreType (IN EFI_VARSTORE_ID);
EFI_VFR_RETURN_CODE GetVarStoreName (IN EFI_VARSTORE_ID, OUT INT8 **);
EFI_VFR_RETURN_CODE GetBufferVarStoreDataTypeName (IN INT8 *, OUT INT8 **);
diff --git a/EdkCompatibilityPkg/Sample/Tools/Source/UefiVfrCompile/makefile b/EdkCompatibilityPkg/Sample/Tools/Source/UefiVfrCompile/makefile
index e4424fcc3f..b266cfe03c 100644
--- a/EdkCompatibilityPkg/Sample/Tools/Source/UefiVfrCompile/makefile
+++ b/EdkCompatibilityPkg/Sample/Tools/Source/UefiVfrCompile/makefile
@@ -1,6 +1,6 @@
#/*++
#
-# Copyright (c) 2004 - 2007, 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
@@ -55,7 +55,8 @@ INC = -I $(SRC) \
ANTLR_FLAGS = -CC -e3 -ck 3 -k 2
DLG_FLAGS = -C2 -i -CC
LINK_FLAGS_PCCTS = /DEBUG /PDB:$*.pdb
-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
+C_FLAGS_PCCTS = -I. -I$(ANTLR_H) /WX /Od /EHsc /Zi /Fd$(ETO)\$(TARGET_NAME)Obj /D _CRT_SECURE_NO_DEPRECATE $(VERSION_FLAGS) \
+ $(BUILD_STRING_FLAGS) /D PCCTS_USE_NAMESPACE_STD #/D CVFR_VARDATATYPEDB_DEBUG /D CIFROBJ_DEUBG /D VFREXP_DEBUG
VFR_GRAMMER_FILE = $(SRC)\VfrSyntax.g
diff --git a/EdkCompatibilityPkg/Sample/Tools/Source/VfrCompile/EfiVfr.h b/EdkCompatibilityPkg/Sample/Tools/Source/VfrCompile/EfiVfr.h
index c520ad28f5..b82713177c 100644
--- a/EdkCompatibilityPkg/Sample/Tools/Source/VfrCompile/EfiVfr.h
+++ b/EdkCompatibilityPkg/Sample/Tools/Source/VfrCompile/EfiVfr.h
@@ -1,6 +1,6 @@
/*++
-Copyright (c) 2004 - 2005, 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
@@ -31,7 +31,8 @@ Abstract:
// This number should be incremented with each change to the VFR compiler.
// We write the version to the output list file for debug purposes.
//
-#define VFR_COMPILER_VERSION "1.88"
+#define UTILITY_VERSION "v1.9"
+#define UTILITY_NAME "VfrCompile"
//
// Maximum file path for filenames
@@ -39,7 +40,6 @@ Abstract:
#define MAX_PATH 255
#define MAX_QUEUE_COUNT 255
#define MAX_LINE_LEN 1024
-#define PROGRAM_NAME "VfrCompile"
//
// We parse C-style structure definitions which can then be referenced
diff --git a/EdkCompatibilityPkg/Sample/Tools/Source/VfrCompile/VfrCompile.g b/EdkCompatibilityPkg/Sample/Tools/Source/VfrCompile/VfrCompile.g
index ce574ada12..7c0d78f010 100644
--- a/EdkCompatibilityPkg/Sample/Tools/Source/VfrCompile/VfrCompile.g
+++ b/EdkCompatibilityPkg/Sample/Tools/Source/VfrCompile/VfrCompile.g
@@ -1,6 +1,6 @@
/*++
-Copyright (c) 2004 - 2007, 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
@@ -130,7 +130,7 @@ Returns:
// Set our program name for the error printing routines.
// Then set printing limits.
//
- SetUtilityName (PROGRAM_NAME);
+ SetUtilityName (UTILITY_NAME);
SetPrintLimits (20, 20, 30);
//
// Process the command-line arguments
@@ -145,7 +145,7 @@ Returns:
// Verify the VFR script file exists
//
if ((VfrFptr = fopen (gOptions.VfrFileName, "r")) == NULL) {
- Error (PROGRAM_NAME, 0, 0, gOptions.VfrFileName, "could not open input VFR file");
+ Error (UTILITY_NAME, 0, 0, gOptions.VfrFileName, "could not open input VFR file");
Cleanup();
return STATUS_ERROR;
}
@@ -164,7 +164,7 @@ Returns:
}
Cmd = (char *)malloc (Len);
if (Cmd == NULL) {
- Error (PROGRAM_NAME, 0, 0, NULL, "could not allocate memory");
+ Error (UTILITY_NAME, 0, 0, NULL, "could not allocate memory");
Cleanup();
return STATUS_ERROR;
}
@@ -182,7 +182,7 @@ Returns:
strcat (Cmd, gOptions.PreprocessorOutputFileName);
Status = system (Cmd);
if (Status != 0) {
- Error (PROGRAM_NAME, 0, 0, gOptions.VfrFileName, "failed to spawn C preprocessor on VFR file");
+ Error (UTILITY_NAME, 0, 0, gOptions.VfrFileName, "failed to spawn C preprocessor on VFR file");
printf ("Command: '%s %s'\n", PREPROCESSOR_COMMAND, Cmd);
Cleanup();
return STATUS_ERROR;
@@ -192,7 +192,7 @@ Returns:
// Open the preprocessor output file
//
if ((VfrFptr = fopen (gOptions.PreprocessorOutputFileName, "r")) == NULL) {
- Error (PROGRAM_NAME, 0, 0, "failed to open input VFR preprocessor output file",
+ Error (UTILITY_NAME, 0, 0, "failed to open input VFR preprocessor output file",
gOptions.PreprocessorOutputFileName);
Cleanup();
return STATUS_ERROR;
@@ -339,7 +339,7 @@ Returns:
//
} else if (_stricmp (Argv[0], "-i") == 0) {
if ((Argc < 2) || (Argv[1][0] == '-')) {
- Error (PROGRAM_NAME, 0, 0, Argv[0], "missing path argument");
+ Error (UTILITY_NAME, 0, 0, Argv[0], "missing path argument");
return STATUS_ERROR;
}
Argc--;
@@ -351,7 +351,7 @@ Returns:
}
IncludePaths = (INT8 *)malloc (Len);
if (IncludePaths == NULL) {
- Error (PROGRAM_NAME, 0, 0, NULL, "memory allocation failure");
+ Error (UTILITY_NAME, 0, 0, NULL, "memory allocation failure");
return STATUS_ERROR;
}
IncludePaths[0] = 0;
@@ -367,7 +367,7 @@ Returns:
//
} else if (_stricmp (Argv[0], "-od") == 0) {
if ((Argc < 2) || (Argv[1][0] == '-')) {
- Error (PROGRAM_NAME, 0, 0, Argv[0], "missing output directory name");
+ Error (UTILITY_NAME, 0, 0, Argv[0], "missing output directory name");
return STATUS_ERROR;
}
Argc--;
@@ -383,7 +383,7 @@ Returns:
//
} else if (_stricmp (Argv[0], "-ppflag") == 0) {
if (Argc < 2) {
- Error (PROGRAM_NAME, 0, 0, Argv[0], "missing C-preprocessor argument");
+ Error (UTILITY_NAME, 0, 0, Argv[0], "missing C-preprocessor argument");
return STATUS_ERROR;
}
Argc--;
@@ -394,7 +394,7 @@ Returns:
}
CPreprocessorOptions = (INT8 *)malloc (Len);
if (CPreprocessorOptions == NULL) {
- Error (PROGRAM_NAME, 0, 0, NULL, "memory allocation failure");
+ Error (UTILITY_NAME, 0, 0, NULL, "memory allocation failure");
return STATUS_ERROR;
}
CPreprocessorOptions[0] = 0;
@@ -406,7 +406,7 @@ Returns:
strcat (CPreprocessorOptions, Argv[0]);
gOptions.CPreprocessorOptions = CPreprocessorOptions;
} else {
- Error (PROGRAM_NAME, 0, 0, Argv[0], "unrecognized option");
+ Error (UTILITY_NAME, 0, 0, Argv[0], "unrecognized option");
return STATUS_ERROR;
}
Argc--;
@@ -416,10 +416,10 @@ Returns:
// Must specify at least the vfr file name
//
if (Argc > 1) {
- Error (PROGRAM_NAME, 0, 0, Argv[1], "unrecognized argument after VFR file name");
+ Error (UTILITY_NAME, 0, 0, Argv[1], "unrecognized argument after VFR file name");
return STATUS_ERROR;
} else if (Argc < 1) {
- Error (PROGRAM_NAME, 0, 0, NULL, "must specify VFR file name");
+ Error (UTILITY_NAME, 0, 0, NULL, "must specify VFR file name");
return STATUS_ERROR;
}
strcpy (gOptions.VfrFileName, Argv[0]);
@@ -501,26 +501,31 @@ Returns:
--*/
{
- int Index;
- const char *Help[] = {
- " ",
- "VfrCompile version " VFR_COMPILER_VERSION,
- " ",
- " Usage: VfrCompile {options} [VfrFile]",
- " ",
- " where options include:",
- " -? or -h prints this help",
- " -l create an output IFR listing file",
- " -i IncPath add IncPath to the search path for VFR included files",
- " -od OutputDir deposit all output files to directory OutputDir (default=cwd)",
- " -ibin create an IFR HII pack file",
- " where parameters include:",
- " VfrFile name of the input VFR script file",
- " ",
+ int Index;
+ const char *Str[] = {
+ UTILITY_NAME" "UTILITY_VERSION" - Intel VFR Compiler Utility",
+ " Copyright (C), 2004 - 2008 Intel Corporation",
+#if ( defined(UTILITY_BUILD) && defined(UTILITY_VENDOR) )
+ " Built from "UTILITY_BUILD", project of "UTILITY_VENDOR,
+#endif
+ "",
+ "Usage:",
+ " "UTILITY_NAME" [OPTION] VFRFILE",
+ "Description:",
+ " Compile VFRFILE.",
+ "Options:",
+ " -? or -h print this help",
+ " -l create an output IFR listing file",
+ " -i IncPath add IncPath to the search path for VFR included files",
+ " -od OutputDir deposit all output files to directory OutputDir (default=cwd)",
+ " -ibin create an IFR HII pack file",
+ " -ppflag CFlags pass Flags as C-preprocessor-flag",
+ " -v or -version print version information",
NULL
- };
- for (Index = 0; Help[Index] != NULL; Index++) {
- fprintf (stdout, "%s\n", Help[Index]);
+ };
+
+ for (Index = 0; Str[Index] != NULL; Index++) {
+ fprintf (stdout, "%s\n", Str[Index]);
}
}
@@ -591,7 +596,7 @@ Returns:
}
gLastLineDefinition = LineDef;
} else {
- Error (PROGRAM_NAME, 0, 0, "invalid line definition in preprocessor output file", TokenString);
+ Error (UTILITY_NAME, 0, 0, "invalid line definition in preprocessor output file", TokenString);
free (LineDef);
return;
}
@@ -2318,7 +2323,7 @@ EfiVfrParser::QueueIdEqValList (
U16 = (UINT16_LIST *)malloc (sizeof (UINT16_LIST));
if (U16 == NULL) {
- Error (PROGRAM_NAME, 0, 0, NULL, "memory allocation failed");
+ Error (UTILITY_NAME, 0, 0, NULL, "memory allocation failed");
} else {
memset ((char *)U16, 0, sizeof (UINT16_LIST));
U16->Value = Value;
@@ -2378,7 +2383,7 @@ EfiVfrParser::PrintErrorMessage (
FileName = ConvertLineNumber ((UINT32 *)&LineNum);
Error (FileName, LineNum, 0, Msg1, Msg2);
} else {
- Error (PROGRAM_NAME, 0, 0, Msg1, Msg2);
+ Error (UTILITY_NAME, 0, 0, Msg1, Msg2);
}
}
VOID
@@ -2394,7 +2399,7 @@ EfiVfrParser::PrintWarningMessage (
FileName = ConvertLineNumber ((UINT32 *)&LineNum);
Warning (FileName, LineNum, 0, Msg1, Msg2);
} else {
- Warning (PROGRAM_NAME, 0, 0, Msg1, Msg2);
+ Warning (UTILITY_NAME, 0, 0, Msg1, Msg2);
}
}
VOID
@@ -3357,7 +3362,7 @@ Returns:
NewRef = (GOTO_REFERENCE *)malloc (sizeof (GOTO_REFERENCE));
if (NewRef == NULL) {
- Error (PROGRAM_NAME, 0, 0, NULL, "memory allocation failure");
+ Error (UTILITY_NAME, 0, 0, NULL, "memory allocation failure");
return;
}
memset ((char *)NewRef, 0, sizeof (GOTO_REFERENCE));
@@ -3423,7 +3428,7 @@ Returns:
//
NewFormId = (FORM_ID_VALUE *)malloc (sizeof (FORM_ID_VALUE));
if (NewFormId == NULL) {
- Error (PROGRAM_NAME, 0, 0, NULL, "memory allocation failure");
+ Error (UTILITY_NAME, 0, 0, NULL, "memory allocation failure");
return;
}
memset ((char *)NewFormId, 0, sizeof (FORM_ID_VALUE));
diff --git a/EdkCompatibilityPkg/Sample/Tools/Source/VfrCompile/VfrServices.cpp b/EdkCompatibilityPkg/Sample/Tools/Source/VfrCompile/VfrServices.cpp
index 4d3ba3d318..8555f2eb73 100644
--- a/EdkCompatibilityPkg/Sample/Tools/Source/VfrCompile/VfrServices.cpp
+++ b/EdkCompatibilityPkg/Sample/Tools/Source/VfrCompile/VfrServices.cpp
@@ -1,6 +1,6 @@
/*++
-Copyright (c) 2004 - 2007, 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
@@ -220,7 +220,7 @@ Returns:
//
if (GetUtilityStatus () != STATUS_ERROR) {
if ((IfrBinFptr = fopen (gOptions.IfrOutputFileName, "w")) == NULL) {
- Error (PROGRAM_NAME, 0, 0, gOptions.IfrOutputFileName, "could not open file for writing");
+ Error (UTILITY_NAME, 0, 0, gOptions.IfrOutputFileName, "could not open file for writing");
return;
}
//
@@ -290,7 +290,7 @@ Returns:
strcat (gOptions.IfrOutputFileName, ".hpk");
}
if ((IfrBinFptr = fopen (gOptions.IfrOutputFileName, "wb")) == NULL) {
- Error (PROGRAM_NAME, 0, 0, gOptions.IfrOutputFileName, "could not open file for writing");
+ Error (UTILITY_NAME, 0, 0, gOptions.IfrOutputFileName, "could not open file for writing");
return;
}
//
@@ -329,10 +329,10 @@ Returns:
// Open the input VFR file and the output list file
//
if ((InFptr = fopen (gOptions.PreprocessorOutputFileName, "r")) == NULL) {
- Warning (PROGRAM_NAME, 0, 0, gOptions.PreprocessorOutputFileName, "could not open file for creating a list file");
+ Warning (UTILITY_NAME, 0, 0, gOptions.PreprocessorOutputFileName, "could not open file for creating a list file");
} else {
if ((OutFptr = fopen (gOptions.VfrListFileName, "w")) == NULL) {
- Warning (PROGRAM_NAME, 0, 0, gOptions.VfrListFileName, "could not open output list file for writing");
+ Warning (UTILITY_NAME, 0, 0, gOptions.VfrListFileName, "could not open output list file for writing");
fclose (InFptr);
InFptr = NULL;
} else {
@@ -350,7 +350,7 @@ Returns:
//
// Write out the VFR compiler version
//
- fprintf (OutFptr, "//\n// VFR compiler version " VFR_COMPILER_VERSION "\n//\n");
+ fprintf (OutFptr, "//\n// VFR compiler version " UTILITY_VERSION "\n//\n");
Curr = mIfrBytes;
while (Curr != NULL) {
//
@@ -590,7 +590,7 @@ Returns:
// Check for buffer overflow
//
if (mQueuedByteCount >= MAX_QUEUE_COUNT) {
- Error (PROGRAM_NAME, 0, 0, NULL, "opcode queue overflow");
+ Error (UTILITY_NAME, 0, 0, NULL, "opcode queue overflow");
} else {
mQueuedBytes[mQueuedByteCount] = ByteVal;
mQueuedKeyBytes[mQueuedByteCount] = KeyByte;
@@ -750,5 +750,5 @@ Returns:
//
// Write out the VFR compiler version
//
- fprintf (OutFptr, "// VFR compiler version " VFR_COMPILER_VERSION "\n//\n");
+ fprintf (OutFptr, "// VFR compiler version " UTILITY_VERSION "\n//\n");
}
diff --git a/EdkCompatibilityPkg/Sample/Tools/Source/VfrCompile/makefile b/EdkCompatibilityPkg/Sample/Tools/Source/VfrCompile/makefile
index b55b09c4ed..1859deb03e 100644
--- a/EdkCompatibilityPkg/Sample/Tools/Source/VfrCompile/makefile
+++ b/EdkCompatibilityPkg/Sample/Tools/Source/VfrCompile/makefile
@@ -1,6 +1,6 @@
#/*++
#
-# Copyright (c) 2004 - 2007, 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
@@ -37,7 +37,7 @@ TOOLCHAIN = TOOLCHAIN_MSVC
TARGET_NAME = VfrCompile
ANTLR_H = $(PCCTS_DIR)\h
-C_FLAGS_PCCTS = -I. -I$(ANTLR_H) /Zi /Fd$(EDK_TOOLS_OUTPUT)\$(TARGET_NAME)Obj /WX /Od /D _CRT_SECURE_NO_DEPRECATE $(VERSION_FLAGS)
+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)
C_FLAGS_PCCTS = $(C_FLAGS_PCCTS)
LINK_FLAGS_PCCTS =
diff --git a/EdkCompatibilityPkg/Sample/Version.env b/EdkCompatibilityPkg/Sample/Version.env
index 1c6e9a9f03..cef19d4ce9 100644
--- a/EdkCompatibilityPkg/Sample/Version.env
+++ b/EdkCompatibilityPkg/Sample/Version.env
@@ -1,6 +1,6 @@
#/*++
#
-# Copyright (c) 2006, Intel Corporation. All rights reserved.<BR>
+# Copyright (c) 2006 - 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
@@ -39,3 +39,5 @@ PI_SPECIFICATION_VERSION = 0x00000009
!ENDIF
TIANO_RELEASE_VERSION = 0x00080006
+
+EDK_BUILD_VERSION = Edk1.06