summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSteven Kinney <steven.kinney@linaro.org>2013-11-22 08:15:09 -0600
committerSteven Kinney <steven.kinney@linaro.org>2013-11-22 08:15:09 -0600
commitaec0833cc55918a9111af736171ba8ceb976824e (patch)
tree3b188d6e0c1075a5df74f724bb302486454e25e8
parente08b4a7ea684e3358f0281da5e23ae03b1b14116 (diff)
parent0caeca1501ec2edee346a3108f45e556e7905204 (diff)
Merging uefi-next/linaro-release into masterlinaro-uefi-2013.11
Signed-off-by: Steven Kinney <steven.kinney@linaro.org>
-rw-r--r--ArmPkg/Drivers/CpuDxe/AArch64/Mmu.c4
-rw-r--r--ArmPkg/Drivers/CpuDxe/ArmV6/ExceptionSupport.S2
-rw-r--r--ArmPkg/Drivers/CpuDxe/ArmV6/ExceptionSupport.asm2
-rw-r--r--ArmPkg/Drivers/CpuDxe/ArmV6/Mmu.c2
-rw-r--r--ArmPkg/Drivers/PL390Gic/PL390GicDxe.c12
-rw-r--r--ArmPkg/Filesystem/SemihostFs/Arm/SemihostFs.c6
-rw-r--r--ArmPkg/Include/Chipset/AArch64Mmu.h6
-rw-r--r--ArmPkg/Library/ArmLib/AArch64/AArch64Support.S6
-rw-r--r--ArmPkg/Library/BdsLib/Arm/BdsLinuxLoader.c26
-rw-r--r--ArmPlatformPkg/ArmPlatformPkg.dec26
-rw-r--r--ArmPlatformPkg/ArmVExpressPkg/ArmFvpDxe/ArmFvpDxe.c73
-rw-r--r--ArmPlatformPkg/ArmVExpressPkg/ArmFvpDxe/ArmFvpDxe.inf35
-rw-r--r--ArmPlatformPkg/ArmVExpressPkg/ArmVExpress-CTA15-A7.dsc9
-rw-r--r--ArmPlatformPkg/ArmVExpressPkg/ArmVExpress-CTA15-A7.fdf19
-rw-r--r--ArmPlatformPkg/ArmVExpressPkg/ArmVExpress-CTA15x2.dsc13
-rw-r--r--ArmPlatformPkg/ArmVExpressPkg/ArmVExpress-CTA15x2.fdf21
-rw-r--r--ArmPlatformPkg/ArmVExpressPkg/ArmVExpress-CTA5s.dsc13
-rw-r--r--ArmPlatformPkg/ArmVExpressPkg/ArmVExpress-CTA5s.fdf23
-rw-r--r--ArmPlatformPkg/ArmVExpressPkg/ArmVExpress-CTA9x4.dsc17
-rw-r--r--ArmPlatformPkg/ArmVExpressPkg/ArmVExpress-CTA9x4.fdf15
-rwxr-xr-xArmPlatformPkg/ArmVExpressPkg/ArmVExpress-FVP-AArch64.dsc27
-rwxr-xr-xArmPlatformPkg/ArmVExpressPkg/ArmVExpress-FVP-AArch64.fdf36
-rw-r--r--ArmPlatformPkg/ArmVExpressPkg/ArmVExpress-RTSM-A15.dsc19
-rw-r--r--ArmPlatformPkg/ArmVExpressPkg/ArmVExpress-RTSM-A15.fdf17
-rw-r--r--ArmPlatformPkg/ArmVExpressPkg/ArmVExpress-RTSM-A15_MPCore.dsc19
-rw-r--r--ArmPlatformPkg/ArmVExpressPkg/ArmVExpress-RTSM-A15_MPCore.fdf18
-rw-r--r--ArmPlatformPkg/ArmVExpressPkg/ArmVExpress-RTSM-A9x4.dsc12
-rw-r--r--ArmPlatformPkg/ArmVExpressPkg/ArmVExpress-RTSM-A9x4.fdf50
-rw-r--r--ArmPlatformPkg/ArmVExpressPkg/ArmVExpress-RTSM-AEMv8Ax4-foundation.dsc23
-rw-r--r--ArmPlatformPkg/ArmVExpressPkg/ArmVExpress-RTSM-AEMv8Ax4-foundation.fdf27
-rw-r--r--ArmPlatformPkg/ArmVExpressPkg/ArmVExpress-RTSM-AEMv8Ax4.dsc22
-rw-r--r--ArmPlatformPkg/ArmVExpressPkg/ArmVExpress-RTSM-AEMv8Ax4.fdf29
-rw-r--r--ArmPlatformPkg/ArmVExpressPkg/ArmVExpress.dsc.inc48
-rw-r--r--ArmPlatformPkg/Bds/Bds.c2
-rw-r--r--ArmPlatformPkg/Bds/BdsHelper.c4
-rw-r--r--ArmPlatformPkg/Bds/BootOption.c2
-rw-r--r--ArmPlatformPkg/Drivers/LcdGraphicsOutputDxe/HdLcd.c4
-rw-r--r--ArmPlatformPkg/Drivers/LcdGraphicsOutputDxe/HdLcdGraphicsOutputDxe.inf3
-rw-r--r--ArmPlatformPkg/Drivers/LcdGraphicsOutputDxe/LcdGraphicsOutputBlt.c2
-rw-r--r--ArmPlatformPkg/Drivers/LcdGraphicsOutputDxe/LcdGraphicsOutputDxe.c20
-rw-r--r--ArmPlatformPkg/Drivers/LcdGraphicsOutputDxe/PL111Lcd.c6
-rw-r--r--ArmPlatformPkg/Drivers/LcdGraphicsOutputDxe/PL111LcdGraphicsOutputDxe.inf3
-rw-r--r--ArmPlatformPkg/Drivers/NorFlashDxe/NorFlashFvbDxe.c2
-rw-r--r--ArmPlatformPkg/Drivers/PL180MciDxe/PL180Mci.c2
-rw-r--r--ArmPlatformPkg/Library/PL031RealTimeClockLib/PL031RealTimeClockLib.c24
-rwxr-xr-xArmPlatformPkg/MemoryInitPei/MemoryInitPeiLib.c4
-rw-r--r--BaseTools/Bin/Win32/BPDG.exebin1042268 -> 1042267 bytes
-rwxr-xr-xBaseTools/Bin/Win32/BootSectImage.exebin434176 -> 434176 bytes
-rwxr-xr-xBaseTools/Bin/Win32/EfiLdrImage.exebin421888 -> 421888 bytes
-rwxr-xr-xBaseTools/Bin/Win32/EfiRom.exebin446464 -> 446464 bytes
-rwxr-xr-xBaseTools/Bin/Win32/GenBootSector.exebin425984 -> 425984 bytes
-rwxr-xr-xBaseTools/Bin/Win32/GenCrc32.exebin425984 -> 425984 bytes
-rwxr-xr-xBaseTools/Bin/Win32/GenDepex.exebin1066588 -> 1066587 bytes
-rwxr-xr-xBaseTools/Bin/Win32/GenFds.exebin1385686 -> 1385762 bytes
-rwxr-xr-xBaseTools/Bin/Win32/GenFfs.exebin430080 -> 430080 bytes
-rwxr-xr-xBaseTools/Bin/Win32/GenFv.exebin479232 -> 479232 bytes
-rwxr-xr-xBaseTools/Bin/Win32/GenFw.exebin499712 -> 499712 bytes
-rwxr-xr-xBaseTools/Bin/Win32/GenPage.exebin425984 -> 425984 bytes
-rwxr-xr-xBaseTools/Bin/Win32/GenPatchPcdTable.exebin1064073 -> 1064072 bytes
-rwxr-xr-xBaseTools/Bin/Win32/GenSec.exebin446464 -> 446464 bytes
-rwxr-xr-xBaseTools/Bin/Win32/GenVtf.exebin446464 -> 446464 bytes
-rwxr-xr-xBaseTools/Bin/Win32/LzmaCompress.exebin397312 -> 397312 bytes
-rwxr-xr-xBaseTools/Bin/Win32/PatchPcdValue.exebin1036121 -> 1036120 bytes
-rwxr-xr-xBaseTools/Bin/Win32/Split.exebin425984 -> 425984 bytes
-rwxr-xr-xBaseTools/Bin/Win32/TargetTool.exebin1044356 -> 1044355 bytes
-rwxr-xr-xBaseTools/Bin/Win32/TianoCompress.exebin434176 -> 434176 bytes
-rwxr-xr-xBaseTools/Bin/Win32/Trim.exebin1103433 -> 1103432 bytes
-rw-r--r--BaseTools/Bin/Win32/UPT.exebin1680092 -> 1680092 bytes
-rwxr-xr-xBaseTools/Bin/Win32/VfrCompile.exebin1282048 -> 1286144 bytes
-rwxr-xr-xBaseTools/Bin/Win32/VolInfo.exebin471040 -> 471040 bytes
-rwxr-xr-xBaseTools/Bin/Win32/build.exebin1785834 -> 1785910 bytes
-rwxr-xr-x[-rw-r--r--]BaseTools/Bin/Win32/python27.dllbin2303488 -> 2303488 bytes
-rw-r--r--BaseTools/Conf/tools_def.template4
-rw-r--r--BaseTools/Source/C/Include/Common/BuildVersion.h2
-rw-r--r--BaseTools/Source/C/Include/Common/UefiInternalFormRepresentation.h9
-rw-r--r--BaseTools/Source/C/VfrCompile/VfrFormPkg.cpp3
-rw-r--r--BaseTools/Source/C/VfrCompile/VfrFormPkg.h20
-rw-r--r--BaseTools/Source/C/VfrCompile/VfrSyntax.g13
-rw-r--r--BaseTools/Source/Python/Common/BuildVersion.py2
-rw-r--r--BaseTools/Source/Python/UPT/BuildVersion.py2
-rw-r--r--BaseTools/Source/Python/Workspace/MetaFileParser.py14
-rwxr-xr-xEdkShellBinPkg/FullShell/AArch64/Shell_Full.efibin0 -> 1047296 bytes
-rwxr-xr-xEdkShellBinPkg/FullShell/Arm/Shell_Full.efibin661792 -> 651936 bytes
-rw-r--r--EdkShellBinPkg/FullShell/FullShell.inf4
-rw-r--r--EdkShellBinPkg/ReadMe.txt2
-rw-r--r--EdkShellPkg/EdkShellPkg.dsc10
-rw-r--r--EdkShellPkg/ReadMe.txt4
-rw-r--r--EdkShellPkg/ShellR64.patch (renamed from EdkShellPkg/ShellR61.patch)10926
-rw-r--r--EmbeddedPkg/Universal/MmcDxe/Diagnostics.c16
-rw-r--r--EmbeddedPkg/Universal/MmcDxe/MmcBlockIo.c86
-rw-r--r--IntelFrameworkModulePkg/Library/DxeCapsuleLib/DxeCapsuleLib.c383
-rw-r--r--IntelFrameworkModulePkg/Library/DxeCapsuleLib/DxeCapsuleLib.inf13
-rw-r--r--IntelFrameworkModulePkg/Library/GenericBdsLib/BdsBoot.c11
-rw-r--r--IntelFrameworkModulePkg/Library/GenericBdsLib/GenericBdsLib.inf3
-rw-r--r--IntelFrameworkModulePkg/Universal/Acpi/AcpiSupportDxe/AcpiSupport.h11
-rw-r--r--IntelFrameworkModulePkg/Universal/Acpi/AcpiSupportDxe/AcpiSupportAcpiSupportProtocol.c36
-rw-r--r--IntelFrameworkModulePkg/Universal/Acpi/AcpiSupportDxe/AcpiSupportDxe.inf9
-rw-r--r--IntelFrameworkModulePkg/Universal/BdsDxe/Bds.h1
-rw-r--r--IntelFrameworkModulePkg/Universal/BdsDxe/BdsDxe.inf1
-rw-r--r--IntelFrameworkModulePkg/Universal/BdsDxe/BdsEntry.c4
-rw-r--r--IntelFrameworkModulePkg/Universal/BdsDxe/BootMaint/BootMaint.c244
-rw-r--r--IntelFrameworkModulePkg/Universal/BdsDxe/Capsules.c36
-rw-r--r--IntelFrameworkModulePkg/Universal/BdsDxe/DeviceMngr/DeviceManager.c33
-rw-r--r--IntelFrameworkModulePkg/Universal/BdsDxe/DeviceMngr/DeviceManager.h17
-rw-r--r--MdeModulePkg/Bus/Ata/AtaAtapiPassThru/AtaAtapiPassThru.c79
-rw-r--r--MdeModulePkg/Bus/Ata/AtaBusDxe/AtaBus.c9
-rw-r--r--MdeModulePkg/Bus/Ata/AtaBusDxe/AtaBus.h48
-rw-r--r--MdeModulePkg/Bus/Ata/AtaBusDxe/AtaPassThruExecute.c68
-rw-r--r--MdeModulePkg/Bus/Pci/NvmExpressDxe/NvmExpress.c11
-rw-r--r--MdeModulePkg/Bus/Pci/NvmExpressDxe/NvmExpress.h8
-rw-r--r--MdeModulePkg/Bus/Pci/NvmExpressDxe/NvmExpressBlockIo.c20
-rw-r--r--MdeModulePkg/Bus/Pci/NvmExpressDxe/NvmExpressHci.c88
-rw-r--r--MdeModulePkg/Bus/Pci/NvmExpressDxe/NvmExpressPassthru.c12
-rw-r--r--MdeModulePkg/Bus/Pci/UhciDxe/UhciDebug.c50
-rw-r--r--MdeModulePkg/Bus/Pci/XhciDxe/Xhci.c9
-rw-r--r--MdeModulePkg/Bus/Pci/XhciDxe/Xhci.h1
-rw-r--r--MdeModulePkg/Bus/Pci/XhciDxe/XhciReg.c30
-rw-r--r--MdeModulePkg/Bus/Pci/XhciDxe/XhciReg.h31
-rw-r--r--MdeModulePkg/Bus/Usb/UsbBusDxe/UsbDesc.c2
-rw-r--r--MdeModulePkg/Bus/Usb/UsbBusDxe/UsbEnumer.c2
-rw-r--r--MdeModulePkg/Core/Dxe/Dispatcher/Dispatcher.c63
-rw-r--r--MdeModulePkg/Core/Dxe/FwVolBlock/FwVolBlock.c31
-rw-r--r--MdeModulePkg/Core/Pei/Dispatcher/Dispatcher.c75
-rw-r--r--MdeModulePkg/Core/Pei/FwVol/FwVol.c596
-rw-r--r--MdeModulePkg/Core/Pei/FwVol/FwVol.h77
-rw-r--r--MdeModulePkg/Core/Pei/Image/Image.c104
-rw-r--r--MdeModulePkg/Core/Pei/PeiMain.h62
-rw-r--r--MdeModulePkg/Core/Pei/PeiMain.inf9
-rw-r--r--MdeModulePkg/Core/Pei/PeiMain/PeiMain.c6
-rw-r--r--MdeModulePkg/Core/Pei/Security/Security.c13
-rw-r--r--MdeModulePkg/Include/Guid/NicIp4ConfigNvData.h2
-rw-r--r--MdeModulePkg/Include/Library/HiiLib.h21
-rw-r--r--MdeModulePkg/Include/Protocol/DisplayProtocol.h2
-rw-r--r--MdeModulePkg/Include/Protocol/FormBrowserEx2.h19
-rw-r--r--MdeModulePkg/Library/CustomizedDisplayLib/CustomizedDisplayLib.c109
-rw-r--r--MdeModulePkg/Library/CustomizedDisplayLib/CustomizedDisplayLib.inf35
-rw-r--r--MdeModulePkg/Library/CustomizedDisplayLib/CustomizedDisplayLibInternal.c100
-rw-r--r--MdeModulePkg/Library/CustomizedDisplayLib/CustomizedDisplayLibInternal.h4
-rw-r--r--MdeModulePkg/Library/UefiHiiLib/HiiLib.c21
-rw-r--r--MdeModulePkg/MdeModulePkg.dec18
-rw-r--r--MdeModulePkg/MdeModulePkg.dsc1
-rw-r--r--MdeModulePkg/Universal/Acpi/AcpiTableDxe/AcpiTable.h11
-rw-r--r--MdeModulePkg/Universal/Acpi/AcpiTableDxe/AcpiTableDxe.inf9
-rw-r--r--MdeModulePkg/Universal/Acpi/AcpiTableDxe/AcpiTableProtocol.c36
-rw-r--r--MdeModulePkg/Universal/Acpi/BootGraphicsResourceTableDxe/BootGraphicsResourceTableDxe.c51
-rw-r--r--MdeModulePkg/Universal/Acpi/BootGraphicsResourceTableDxe/BootGraphicsResourceTableDxe.inf10
-rw-r--r--MdeModulePkg/Universal/Acpi/FirmwarePerformanceDataTableDxe/FirmwarePerformanceDxe.c32
-rw-r--r--MdeModulePkg/Universal/Acpi/FirmwarePerformanceDataTableDxe/FirmwarePerformanceDxe.inf5
-rw-r--r--MdeModulePkg/Universal/CapsuleRuntimeDxe/CapsuleRuntimeDxe.inf6
-rw-r--r--MdeModulePkg/Universal/CapsuleRuntimeDxe/CapsuleService.c49
-rw-r--r--MdeModulePkg/Universal/Disk/DiskIoDxe/DiskIo.c29
-rw-r--r--MdeModulePkg/Universal/Disk/PartitionDxe/Partition.c6
-rw-r--r--MdeModulePkg/Universal/DisplayEngineDxe/FormDisplay.c904
-rw-r--r--MdeModulePkg/Universal/DriverSampleDxe/Vfr.vfr3
-rw-r--r--MdeModulePkg/Universal/DriverSampleDxe/VfrStrings.unibin61006 -> 61410 bytes
-rw-r--r--MdeModulePkg/Universal/FaultTolerantWriteDxe/FaultTolerantWrite.c4
-rw-r--r--MdeModulePkg/Universal/FaultTolerantWriteDxe/UpdateWorkingBlock.c4
-rw-r--r--MdeModulePkg/Universal/HiiDatabaseDxe/ConfigRouting.c108
-rw-r--r--MdeModulePkg/Universal/HiiDatabaseDxe/HiiDatabase.h1
-rw-r--r--MdeModulePkg/Universal/Network/IScsiDxe/IScsiIbft.c8
-rw-r--r--MdeModulePkg/Universal/Network/IScsiDxe/IScsiProto.c5
-rw-r--r--MdeModulePkg/Universal/Network/Ip4ConfigDxe/Ip4Config.c8
-rw-r--r--MdeModulePkg/Universal/Network/Ip4ConfigDxe/Ip4ConfigDriver.c2
-rw-r--r--MdeModulePkg/Universal/Network/Ip4ConfigDxe/Ip4ConfigNv.c2
-rw-r--r--MdeModulePkg/Universal/Network/Ip4Dxe/Ip4Impl.c6
-rw-r--r--MdeModulePkg/Universal/SetupBrowserDxe/IfrParse.c10
-rw-r--r--MdeModulePkg/Universal/SetupBrowserDxe/Presentation.c142
-rw-r--r--MdeModulePkg/Universal/SetupBrowserDxe/Setup.c77
-rw-r--r--MdeModulePkg/Universal/SetupBrowserDxe/Setup.h10
-rw-r--r--MdeModulePkg/Universal/SmbiosDxe/SmbiosDxe.c8
-rw-r--r--MdeModulePkg/Universal/TimestampDxe/TimestampDxe.c166
-rw-r--r--MdeModulePkg/Universal/TimestampDxe/TimestampDxe.inf49
-rw-r--r--MdePkg/Include/Guid/FirmwareContentsSigned.h26
-rw-r--r--MdePkg/Include/Guid/FmpCapsule.h89
-rw-r--r--MdePkg/Include/Guid/StatusCodeDataTypeId.h4
-rw-r--r--MdePkg/Include/IndustryStandard/TcpaAcpi.h58
-rw-r--r--MdePkg/Include/IndustryStandard/Tpm20.h1809
-rw-r--r--MdePkg/Include/IndustryStandard/Tpm2Acpi.h51
-rw-r--r--MdePkg/Include/Library/PeiServicesLib.h90
-rw-r--r--MdePkg/Include/Pi/PiFirmwareVolume.h6
-rw-r--r--MdePkg/Include/Pi/PiPeiCis.h92
-rw-r--r--MdePkg/Include/Ppi/FirmwareVolume.h76
-rw-r--r--MdePkg/Include/Ppi/FirmwareVolumeInfo2.h72
-rw-r--r--MdePkg/Include/Ppi/LoadFile.h7
-rw-r--r--MdePkg/Include/Ppi/Security2.h4
-rw-r--r--MdePkg/Include/Protocol/DriverHealth.h40
-rw-r--r--MdePkg/Include/Protocol/ScsiIo.h27
-rw-r--r--MdePkg/Include/Protocol/Timestamp.h101
-rw-r--r--MdePkg/Include/Protocol/TrEEProtocol.h265
-rw-r--r--MdePkg/Include/Uefi/UefiSpec.h18
-rw-r--r--MdePkg/Library/PeiServicesLib/PeiServicesLib.c224
-rw-r--r--MdePkg/Library/PeiServicesLib/PeiServicesLib.inf3
-rw-r--r--MdePkg/Library/UefiLib/UefiNotTiano.c34
-rw-r--r--MdePkg/MdePkg.dec18
-rw-r--r--NetworkPkg/IScsiDxe/IScsiProto.c16
-rw-r--r--NetworkPkg/UefiPxeBcDxe/PxeBcImpl.c2
-rw-r--r--Nt32Pkg/CpuRuntimeDxe/Cpu.c4
-rw-r--r--Nt32Pkg/CpuRuntimeDxe/CpuIo.c6
-rw-r--r--Nt32Pkg/FvbServicesRuntimeDxe/FWBlockService.c2
-rw-r--r--Nt32Pkg/Include/Common/WinNTInclude.h6
-rw-r--r--Nt32Pkg/Library/DxeNt32OemHookStatusCodeLib/Nt32OemHookStatusCodeLib.c6
-rw-r--r--Nt32Pkg/Library/Nt32PeiPeCoffGetEntryPointLib/PeCoffGetEntryPoint.c4
-rw-r--r--Nt32Pkg/Library/PeiNt32OemHookStatusCodeLib/Nt32OemHookStatusCodeLib.c6
-rw-r--r--Nt32Pkg/Nt32Pkg.dsc39
-rw-r--r--Nt32Pkg/Nt32Pkg.fdf31
-rw-r--r--Nt32Pkg/Sec/SecMain.c14
-rw-r--r--Nt32Pkg/Sec/SecMain.inf11
-rw-r--r--Nt32Pkg/Sec/StackX64.asm110
-rw-r--r--Nt32Pkg/SnpNt32Dxe/SnpNt32.c16
-rw-r--r--Nt32Pkg/StallPei/Stall.c4
-rw-r--r--Nt32Pkg/WinNtBlockIoDxe/WinNtBlockIo.c18
-rw-r--r--Nt32Pkg/WinNtGopDxe/WinNtGopScreen.c16
-rw-r--r--Nt32Pkg/WinNtSimpleFileSystemDxe/WinNtSimpleFileSystem.c6
-rw-r--r--OvmfPkg/Include/IndustryStandard/Virtio.h79
-rw-r--r--OvmfPkg/Include/IndustryStandard/VirtioBlk.h21
-rw-r--r--OvmfPkg/Include/IndustryStandard/VirtioNet.h196
-rw-r--r--OvmfPkg/Include/IndustryStandard/VirtioScsi.h27
-rw-r--r--OvmfPkg/Include/IndustryStandard/X64Paging.h99
-rw-r--r--OvmfPkg/Include/Library/VirtioLib.h77
-rw-r--r--OvmfPkg/Include/Library/VirtioMmioDeviceLib.h65
-rw-r--r--OvmfPkg/Include/Protocol/VirtioDevice.h376
-rw-r--r--OvmfPkg/Library/LoadLinuxLib/Linux.c2
-rw-r--r--OvmfPkg/Library/PlatformBdsLib/QemuBootOrder.c271
-rw-r--r--OvmfPkg/Library/VirtioLib/VirtioLib.c158
-rw-r--r--OvmfPkg/Library/VirtioMmioDeviceLib/VirtioMmioDevice.c204
-rw-r--r--OvmfPkg/Library/VirtioMmioDeviceLib/VirtioMmioDevice.h147
-rw-r--r--OvmfPkg/Library/VirtioMmioDeviceLib/VirtioMmioDeviceFunctions.c304
-rw-r--r--OvmfPkg/Library/VirtioMmioDeviceLib/VirtioMmioDeviceLib.inf43
-rw-r--r--OvmfPkg/OvmfPkg.dec1
-rw-r--r--OvmfPkg/OvmfPkgIa32.dsc2
-rw-r--r--OvmfPkg/OvmfPkgIa32.fdf1
-rw-r--r--OvmfPkg/OvmfPkgIa32X64.dsc2
-rw-r--r--OvmfPkg/OvmfPkgIa32X64.fdf1
-rw-r--r--OvmfPkg/OvmfPkgX64.dsc2
-rw-r--r--OvmfPkg/OvmfPkgX64.fdf7
-rw-r--r--OvmfPkg/PlatformPei/Platform.c5
-rw-r--r--OvmfPkg/ResetVector/Bin/ResetVector.inf29
-rw-r--r--OvmfPkg/ResetVector/Bin/ResetVector.x64.rawbin0 -> 628 bytes
-rw-r--r--OvmfPkg/ResetVector/Build.py58
-rw-r--r--OvmfPkg/ResetVector/Ia32/PageTables64.asm91
-rw-r--r--OvmfPkg/ResetVector/ResetVectorCode.asm53
-rw-r--r--OvmfPkg/ResetVector/Tools/FixupForRawSection.py26
-rw-r--r--OvmfPkg/Sec/SecMain.c144
-rw-r--r--OvmfPkg/VirtioBlkDxe/VirtioBlk.c185
-rw-r--r--OvmfPkg/VirtioBlkDxe/VirtioBlk.h32
-rw-r--r--OvmfPkg/VirtioBlkDxe/VirtioBlk.inf4
-rw-r--r--OvmfPkg/VirtioNetDxe/ComponentName.c6
-rw-r--r--OvmfPkg/VirtioNetDxe/DriverBinding.c130
-rw-r--r--OvmfPkg/VirtioNetDxe/Events.c2
-rw-r--r--OvmfPkg/VirtioNetDxe/SnpGetStatus.c2
-rw-r--r--OvmfPkg/VirtioNetDxe/SnpInitialize.c37
-rw-r--r--OvmfPkg/VirtioNetDxe/SnpReceive.c12
-rw-r--r--OvmfPkg/VirtioNetDxe/SnpShutdown.c2
-rw-r--r--OvmfPkg/VirtioNetDxe/SnpTransmit.c12
-rw-r--r--OvmfPkg/VirtioNetDxe/VirtioNet.h26
-rw-r--r--OvmfPkg/VirtioNetDxe/VirtioNet.inf2
-rw-r--r--OvmfPkg/VirtioPciDeviceDxe/VirtioPciDevice.c667
-rw-r--r--OvmfPkg/VirtioPciDeviceDxe/VirtioPciDevice.h166
-rw-r--r--OvmfPkg/VirtioPciDeviceDxe/VirtioPciDeviceDxe.inf43
-rw-r--r--OvmfPkg/VirtioPciDeviceDxe/VirtioPciFunctions.c285
-rw-r--r--OvmfPkg/VirtioScsiDxe/VirtioScsi.c173
-rw-r--r--OvmfPkg/VirtioScsiDxe/VirtioScsi.h24
-rw-r--r--OvmfPkg/VirtioScsiDxe/VirtioScsi.inf2
-rw-r--r--PerformancePkg/Dp_App/DpUtilities.c18
-rw-r--r--SecurityPkg/Include/Guid/AuthenticatedVariableFormat.h13
-rw-r--r--SecurityPkg/Include/Guid/TpmInstance.h38
-rw-r--r--SecurityPkg/Include/Guid/TrEEConfigHii.h25
-rw-r--r--SecurityPkg/Include/Guid/TrEEPhysicalPresenceData.h62
-rw-r--r--SecurityPkg/Include/Library/HashLib.h169
-rw-r--r--SecurityPkg/Include/Library/Tpm12CommandLib.h58
-rw-r--r--SecurityPkg/Include/Library/Tpm12DeviceLib.h54
-rw-r--r--SecurityPkg/Include/Library/Tpm2CommandLib.h824
-rw-r--r--SecurityPkg/Include/Library/Tpm2DeviceLib.h109
-rw-r--r--SecurityPkg/Include/Library/TrEEPhysicalPresenceLib.h57
-rw-r--r--SecurityPkg/Include/Ppi/FirmwareVolumeInfoMeasurementExcluded.h37
-rw-r--r--SecurityPkg/Library/DxeImageVerificationLib/DxeImageVerificationLib.c21
-rw-r--r--SecurityPkg/Library/DxeImageVerificationLib/DxeImageVerificationLib.inf2
-rw-r--r--SecurityPkg/Library/DxeImageVerificationLib/Measurement.c322
-rw-r--r--SecurityPkg/Library/DxeTcgPhysicalPresenceLib/DxeTcgPhysicalPresenceLib.c12
-rw-r--r--SecurityPkg/Library/DxeTpm2MeasureBootLib/DxeTpm2MeasureBootLib.c700
-rw-r--r--SecurityPkg/Library/DxeTpm2MeasureBootLib/DxeTpm2MeasureBootLib.inf63
-rw-r--r--SecurityPkg/Library/DxeTpmMeasurementLib/DxeTpmMeasurementLib.c77
-rw-r--r--SecurityPkg/Library/DxeTpmMeasurementLib/DxeTpmMeasurementLib.inf7
-rw-r--r--SecurityPkg/Library/DxeTrEEPhysicalPresenceLib/DxeTrEEPhysicalPresenceLib.c716
-rw-r--r--SecurityPkg/Library/DxeTrEEPhysicalPresenceLib/DxeTrEEPhysicalPresenceLib.inf59
-rw-r--r--SecurityPkg/Library/DxeTrEEPhysicalPresenceLib/PhysicalPresenceStrings.unibin0 -> 3690 bytes
-rw-r--r--SecurityPkg/Library/HashInstanceLibSha1/HashInstanceLibSha1.c155
-rw-r--r--SecurityPkg/Library/HashInstanceLibSha1/HashInstanceLibSha1.inf44
-rw-r--r--SecurityPkg/Library/HashInstanceLibSha256/HashInstanceLibSha256.c155
-rw-r--r--SecurityPkg/Library/HashInstanceLibSha256/HashInstanceLibSha256.inf44
-rw-r--r--SecurityPkg/Library/HashLibBaseCryptoRouter/HashLibBaseCryptoRouterCommon.c77
-rw-r--r--SecurityPkg/Library/HashLibBaseCryptoRouter/HashLibBaseCryptoRouterCommon.h44
-rw-r--r--SecurityPkg/Library/HashLibBaseCryptoRouter/HashLibBaseCryptoRouterDxe.c221
-rw-r--r--SecurityPkg/Library/HashLibBaseCryptoRouter/HashLibBaseCryptoRouterDxe.inf49
-rw-r--r--SecurityPkg/Library/HashLibBaseCryptoRouter/HashLibBaseCryptoRouterPei.c288
-rw-r--r--SecurityPkg/Library/HashLibBaseCryptoRouter/HashLibBaseCryptoRouterPei.inf50
-rw-r--r--SecurityPkg/Library/HashLibTpm2/HashLibTpm2.c342
-rw-r--r--SecurityPkg/Library/HashLibTpm2/HashLibTpm2.inf45
-rw-r--r--SecurityPkg/Library/Tpm12CommandLib/Tpm12CommandLib.inf43
-rw-r--r--SecurityPkg/Library/Tpm12CommandLib/Tpm12Ownership.c72
-rw-r--r--SecurityPkg/Library/Tpm12CommandLib/Tpm12Startup.c127
-rw-r--r--SecurityPkg/Library/Tpm12DeviceLibDTpm/Tpm12DeviceLibDTpm.inf44
-rw-r--r--SecurityPkg/Library/Tpm12DeviceLibDTpm/Tpm12Tis.c572
-rw-r--r--SecurityPkg/Library/Tpm12DeviceLibTcg/Tpm12DeviceLibTcg.c108
-rw-r--r--SecurityPkg/Library/Tpm12DeviceLibTcg/Tpm12DeviceLibTcg.inf42
-rw-r--r--SecurityPkg/Library/Tpm2CommandLib/Tpm2Capability.c741
-rw-r--r--SecurityPkg/Library/Tpm2CommandLib/Tpm2CommandLib.inf48
-rw-r--r--SecurityPkg/Library/Tpm2CommandLib/Tpm2DictionaryAttack.c203
-rw-r--r--SecurityPkg/Library/Tpm2CommandLib/Tpm2Help.c166
-rw-r--r--SecurityPkg/Library/Tpm2CommandLib/Tpm2Hierarchy.c635
-rw-r--r--SecurityPkg/Library/Tpm2CommandLib/Tpm2Integrity.c525
-rw-r--r--SecurityPkg/Library/Tpm2CommandLib/Tpm2Miscellaneous.c114
-rw-r--r--SecurityPkg/Library/Tpm2CommandLib/Tpm2NVStorage.c938
-rw-r--r--SecurityPkg/Library/Tpm2CommandLib/Tpm2Sequences.c508
-rw-r--r--SecurityPkg/Library/Tpm2CommandLib/Tpm2Startup.c102
-rw-r--r--SecurityPkg/Library/Tpm2CommandLib/Tpm2Test.c66
-rw-r--r--SecurityPkg/Library/Tpm2DeviceLibDTpm/Tpm2DeviceLibDTpm.c116
-rw-r--r--SecurityPkg/Library/Tpm2DeviceLibDTpm/Tpm2DeviceLibDTpm.inf45
-rw-r--r--SecurityPkg/Library/Tpm2DeviceLibDTpm/Tpm2InstanceLibDTpm.c85
-rw-r--r--SecurityPkg/Library/Tpm2DeviceLibDTpm/Tpm2InstanceLibDTpm.inf47
-rw-r--r--SecurityPkg/Library/Tpm2DeviceLibDTpm/Tpm2Tis.c583
-rw-r--r--SecurityPkg/Library/Tpm2DeviceLibRouter/Tpm2DeviceLibRouterDxe.c98
-rw-r--r--SecurityPkg/Library/Tpm2DeviceLibRouter/Tpm2DeviceLibRouterDxe.inf44
-rw-r--r--SecurityPkg/Library/Tpm2DeviceLibRouter/Tpm2DeviceLibRouterPei.c143
-rw-r--r--SecurityPkg/Library/Tpm2DeviceLibRouter/Tpm2DeviceLibRouterPei.inf46
-rw-r--r--SecurityPkg/Library/Tpm2DeviceLibTrEE/Tpm2DeviceLibTrEE.c125
-rw-r--r--SecurityPkg/Library/Tpm2DeviceLibTrEE/Tpm2DeviceLibTrEE.inf42
-rw-r--r--SecurityPkg/SecurityPkg.dec80
-rw-r--r--SecurityPkg/SecurityPkg.dsc89
-rw-r--r--SecurityPkg/Tcg/MemoryOverwriteControl/TcgMor.inf4
-rw-r--r--SecurityPkg/Tcg/TcgConfigDxe/TcgConfigDriver.c8
-rw-r--r--SecurityPkg/Tcg/TcgConfigDxe/TcgConfigDxe.inf4
-rw-r--r--SecurityPkg/Tcg/TcgDxe/TcgDxe.c57
-rw-r--r--SecurityPkg/Tcg/TcgDxe/TcgDxe.inf10
-rw-r--r--SecurityPkg/Tcg/TcgPei/TcgPei.c52
-rw-r--r--SecurityPkg/Tcg/TcgPei/TcgPei.inf11
-rw-r--r--SecurityPkg/Tcg/TcgSmm/TcgSmm.c6
-rw-r--r--SecurityPkg/Tcg/TcgSmm/TcgSmm.h4
-rw-r--r--SecurityPkg/Tcg/TcgSmm/TcgSmm.inf8
-rw-r--r--SecurityPkg/Tcg/TcgSmm/Tpm.asl4
-rw-r--r--SecurityPkg/Tcg/TrEEConfig/TpmDetection.c107
-rw-r--r--SecurityPkg/Tcg/TrEEConfig/TrEEConfig.vfr67
-rw-r--r--SecurityPkg/Tcg/TrEEConfig/TrEEConfigDriver.c171
-rw-r--r--SecurityPkg/Tcg/TrEEConfig/TrEEConfigDxe.inf74
-rw-r--r--SecurityPkg/Tcg/TrEEConfig/TrEEConfigImpl.c454
-rw-r--r--SecurityPkg/Tcg/TrEEConfig/TrEEConfigImpl.h191
-rw-r--r--SecurityPkg/Tcg/TrEEConfig/TrEEConfigNvData.h66
-rw-r--r--SecurityPkg/Tcg/TrEEConfig/TrEEConfigPei.inf70
-rw-r--r--SecurityPkg/Tcg/TrEEConfig/TrEEConfigPeim.c133
-rw-r--r--SecurityPkg/Tcg/TrEEConfig/TrEEConfigStrings.unibin0 -> 4070 bytes
-rw-r--r--SecurityPkg/Tcg/TrEEDxe/MeasureBootPeCoff.c357
-rw-r--r--SecurityPkg/Tcg/TrEEDxe/TrEEDxe.c1977
-rw-r--r--SecurityPkg/Tcg/TrEEDxe/TrEEDxe.inf91
-rw-r--r--SecurityPkg/Tcg/TrEEPei/TrEEPei.c694
-rw-r--r--SecurityPkg/Tcg/TrEEPei/TrEEPei.inf75
-rw-r--r--SecurityPkg/Tcg/TrEESmm/Tpm.asl354
-rw-r--r--SecurityPkg/Tcg/TrEESmm/TrEESmm.c480
-rw-r--r--SecurityPkg/Tcg/TrEESmm/TrEESmm.h117
-rw-r--r--SecurityPkg/Tcg/TrEESmm/TrEESmm.inf71
-rw-r--r--SecurityPkg/VariableAuthenticated/RuntimeDxe/AuthService.c153
-rw-r--r--SecurityPkg/VariableAuthenticated/RuntimeDxe/Measurement.c255
-rw-r--r--SecurityPkg/VariableAuthenticated/RuntimeDxe/Variable.c31
-rw-r--r--SecurityPkg/VariableAuthenticated/RuntimeDxe/VariableRuntimeDxe.inf3
-rw-r--r--SecurityPkg/VariableAuthenticated/RuntimeDxe/VariableSmm.c17
-rw-r--r--SecurityPkg/VariableAuthenticated/RuntimeDxe/VariableSmm.inf1
-rw-r--r--SecurityPkg/VariableAuthenticated/RuntimeDxe/VariableSmmRuntimeDxe.c23
-rw-r--r--SecurityPkg/VariableAuthenticated/RuntimeDxe/VariableSmmRuntimeDxe.inf3
-rwxr-xr-xShellBinPkg/MinUefiShell/AArch64/Shell.efibin441920 -> 546720 bytes
-rwxr-xr-xShellBinPkg/MinUefiShell/Arm/Shell.efibin0 -> 306912 bytes
-rw-r--r--ShellBinPkg/MinUefiShell/Ia32/Shell.efibin306624 -> 316192 bytes
-rw-r--r--ShellBinPkg/MinUefiShell/X64/Shell.efibin347808 -> 359840 bytes
-rw-r--r--ShellBinPkg/ReadMe.txt4
-rwxr-xr-xShellBinPkg/UefiShell/AArch64/Shell.efibin986976 -> 1201408 bytes
-rwxr-xr-xShellBinPkg/UefiShell/Arm/Shell.efibin731488 -> 749344 bytes
-rw-r--r--ShellBinPkg/UefiShell/Ia32/Shell.efibin763488 -> 783296 bytes
-rw-r--r--ShellBinPkg/UefiShell/X64/Shell.efibin855104 -> 881184 bytes
-rw-r--r--ShellPkg/Application/Shell/Shell.c62
-rw-r--r--ShellPkg/Application/Shell/Shell.inf2
-rw-r--r--ShellPkg/Application/Shell/Shell.unibin4588 -> 4938 bytes
-rw-r--r--ShellPkg/Application/Shell/ShellParametersProtocol.c6
-rw-r--r--ShellPkg/Application/Shell/ShellProtocol.c38
-rw-r--r--ShellPkg/Include/Library/HandleParsingLib.h23
-rw-r--r--ShellPkg/Library/UefiDpLib/DpUtilities.c3
-rw-r--r--ShellPkg/Library/UefiFileHandleLib/UefiFileHandleLib.c4
-rw-r--r--ShellPkg/Library/UefiHandleParsingLib/UefiHandleParsingLib.c32
-rw-r--r--ShellPkg/Library/UefiShellDebug1CommandsLib/EditTitleBar.c3
-rw-r--r--ShellPkg/Library/UefiShellDebug1CommandsLib/SetVar.c4
-rw-r--r--ShellPkg/Library/UefiShellDriver1CommandsLib/Dh.c19
-rw-r--r--ShellPkg/Library/UefiShellDriver1CommandsLib/DrvDiag.c41
-rw-r--r--ShellPkg/Library/UefiShellDriver1CommandsLib/UefiShellDriver1CommandsLib.h1
-rw-r--r--ShellPkg/Library/UefiShellLevel2CommandsLib/Ls.c84
-rw-r--r--ShellPkg/Library/UefiShellLevel2CommandsLib/Mv.c9
-rw-r--r--ShellPkg/Library/UefiShellLevel2CommandsLib/UefiShellLevel2CommandsLib.unibin111572 -> 111846 bytes
-rw-r--r--ShellPkg/Library/UefiShellLevel3CommandsLib/Type.c120
-rw-r--r--ShellPkg/Library/UefiShellLevel3CommandsLib/UefiShellLevel3CommandsLib.inf2
-rw-r--r--ShellPkg/Library/UefiShellLevel3CommandsLib/UefiShellLevel3CommandsLib.unibin42726 -> 42738 bytes
-rw-r--r--ShellPkg/Library/UefiShellLevel3CommandsLib/Ver.c6
-rw-r--r--ShellPkg/Library/UefiShellNetwork1CommandsLib/Ifconfig.c17
-rw-r--r--ShellPkg/Library/UefiShellNetwork1CommandsLib/UefiShellNetwork1CommandsLib.unibin18204 -> 18334 bytes
-rw-r--r--ShellPkg/ShellPkg.dec8
-rw-r--r--StdLib/Include/Ipf/machine/param.h1
-rw-r--r--StdLib/LibC/Containers/Queues/Fifo.c1
-rw-r--r--StdLib/LibC/String/strncasecmp.c41
-rw-r--r--UefiCpuPkg/CpuDxe/CpuDxe.c6
-rw-r--r--UefiCpuPkg/Include/Library/LocalApicLib.h4
-rw-r--r--UefiCpuPkg/Include/Register/LocalApic.h4
-rw-r--r--UefiCpuPkg/Library/BaseXApicLib/BaseXApicLib.c33
-rw-r--r--UefiCpuPkg/Library/BaseXApicX2ApicLib/BaseXApicX2ApicLib.c23
-rw-r--r--UefiCpuPkg/ResetVector/Vtf0/Ia32/Flat32ToFlat64.asm5
-rw-r--r--UefiCpuPkg/ResetVector/Vtf0/Ia32/PageTables64.asm30
-rw-r--r--UefiCpuPkg/ResetVector/Vtf0/ResetVectorCode.asm3
411 files changed, 35460 insertions, 6941 deletions
diff --git a/ArmPkg/Drivers/CpuDxe/AArch64/Mmu.c b/ArmPkg/Drivers/CpuDxe/AArch64/Mmu.c
index 72f9b3cc6..95bf10bcb 100644
--- a/ArmPkg/Drivers/CpuDxe/AArch64/Mmu.c
+++ b/ArmPkg/Drivers/CpuDxe/AArch64/Mmu.c
@@ -90,7 +90,7 @@ GetNextEntryAttribute (
SetGcdMemorySpaceAttributes (MemorySpaceMap, NumberOfDescriptors,
*StartGcdRegion,
(BaseAddress + (Index * TT_ADDRESS_AT_LEVEL(TableLevel))) - *StartGcdRegion,
- PageAttributeToGcdAttribute (EntryAttribute));
+ PageAttributeToGcdAttribute (*PrevEntryAttribute));
}
// Start of the new region
@@ -265,7 +265,7 @@ GetMemoryRegionRec (
BlockEntry = (UINT64*)TT_GET_ENTRY_FOR_ADDRESS (TranslationTable, TableLevel, *BaseAddress);
EntryType = *BlockEntry & TT_TYPE_MASK;
- if (EntryType == TT_TYPE_TABLE_ENTRY) {
+ if ((TableLevel < 3) && (EntryType == TT_TYPE_TABLE_ENTRY)) {
NextTranslationTable = (UINT64*)(*BlockEntry & TT_ADDRESS_MASK_DESCRIPTION_TABLE);
// The entry is a page table, so we go to the next level
diff --git a/ArmPkg/Drivers/CpuDxe/ArmV6/ExceptionSupport.S b/ArmPkg/Drivers/CpuDxe/ArmV6/ExceptionSupport.S
index 948ad6994..612ca02c7 100644
--- a/ArmPkg/Drivers/CpuDxe/ArmV6/ExceptionSupport.S
+++ b/ArmPkg/Drivers/CpuDxe/ArmV6/ExceptionSupport.S
@@ -242,7 +242,7 @@ NoAdjustNeeded:
str R5, [SP, #0x3c] @ Store it in EFI_SYSTEM_CONTEXT_ARM.PC
- sub R1, SP, #0x60 @ We pused 0x60 bytes on the stack
+ add R1, SP, #0x60 @ We pushed 0x60 bytes on the stack
str R1, [SP, #0x34] @ Store it in EFI_SYSTEM_CONTEXT_ARM.SP
@ R0 is ExceptionType
diff --git a/ArmPkg/Drivers/CpuDxe/ArmV6/ExceptionSupport.asm b/ArmPkg/Drivers/CpuDxe/ArmV6/ExceptionSupport.asm
index c3f494ae3..780e1f7cd 100644
--- a/ArmPkg/Drivers/CpuDxe/ArmV6/ExceptionSupport.asm
+++ b/ArmPkg/Drivers/CpuDxe/ArmV6/ExceptionSupport.asm
@@ -237,7 +237,7 @@ NoAdjustNeeded
str R5, [SP, #0x3c] ; Store it in EFI_SYSTEM_CONTEXT_ARM.PC
- sub R1, SP, #0x60 ; We pused 0x60 bytes on the stack
+ add R1, SP, #0x60 ; We pushed 0x60 bytes on the stack
str R1, [SP, #0x34] ; Store it in EFI_SYSTEM_CONTEXT_ARM.SP
; R0 is ExceptionType
diff --git a/ArmPkg/Drivers/CpuDxe/ArmV6/Mmu.c b/ArmPkg/Drivers/CpuDxe/ArmV6/Mmu.c
index 2896f708a..18778f3ac 100644
--- a/ArmPkg/Drivers/CpuDxe/ArmV6/Mmu.c
+++ b/ArmPkg/Drivers/CpuDxe/ArmV6/Mmu.c
@@ -851,7 +851,7 @@ GetMemoryRegion (
SectionDescriptor = FirstLevelTable[TableIndex];
// If the entry is a level-2 page table then we scan it to find the end of the region
- if ((SectionDescriptor & TT_DESCRIPTOR_SECTION_TYPE_MASK) == TT_DESCRIPTOR_SECTION_TYPE_PAGE_TABLE) {
+ if (TT_DESCRIPTOR_SECTION_TYPE_IS_PAGE_TABLE (SectionDescriptor)) {
// Extract the page table location from the descriptor
PageTable = (UINT32*)(SectionDescriptor & TT_DESCRIPTOR_SECTION_PAGETABLE_ADDRESS_MASK);
diff --git a/ArmPkg/Drivers/PL390Gic/PL390GicDxe.c b/ArmPkg/Drivers/PL390Gic/PL390GicDxe.c
index ce96831a4..45a52be1c 100644
--- a/ArmPkg/Drivers/PL390Gic/PL390GicDxe.c
+++ b/ArmPkg/Drivers/PL390Gic/PL390GicDxe.c
@@ -378,12 +378,12 @@ InterruptDxeInitialize (
CpuTarget = MmioRead32 (PcdGet32 (PcdGicDistributorBase) + ARM_GIC_ICDIPTR);
// The CPU target is a bit field mapping each CPU to a GIC CPU Interface. This value
- // cannot be 0.
- ASSERT (CpuTarget != 0);
-
- // The 8 first Interrupt Processor Targets Registers are read-only
- for (Index = 8; Index < (mGicNumInterrupts / 4); Index++) {
- MmioWrite32 (PcdGet32 (PcdGicDistributorBase) + ARM_GIC_ICDIPTR + (Index * 4), CpuTarget);
+ // is 0 when we run on a uniprocessor platform.
+ if (CpuTarget != 0) {
+ // The 8 first Interrupt Processor Targets Registers are read-only
+ for (Index = 8; Index < (mGicNumInterrupts / 4); Index++) {
+ MmioWrite32 (PcdGet32 (PcdGicDistributorBase) + ARM_GIC_ICDIPTR + (Index * 4), CpuTarget);
+ }
}
// Set binary point reg to 0x7 (no preemption)
diff --git a/ArmPkg/Filesystem/SemihostFs/Arm/SemihostFs.c b/ArmPkg/Filesystem/SemihostFs/Arm/SemihostFs.c
index 5f1159d81..447ab5631 100644
--- a/ArmPkg/Filesystem/SemihostFs/Arm/SemihostFs.c
+++ b/ArmPkg/Filesystem/SemihostFs/Arm/SemihostFs.c
@@ -345,7 +345,8 @@ FileWrite (
Fcb = SEMIHOST_FCB_FROM_THIS(File);
// We cannot write a read-only file
- if (Fcb->OpenMode & EFI_FILE_READ_ONLY) {
+ if ((Fcb->Info.Attribute & EFI_FILE_READ_ONLY)
+ || !(Fcb->OpenMode & EFI_FILE_MODE_WRITE)) {
return EFI_ACCESS_DENIED;
}
@@ -567,7 +568,8 @@ FileFlush (
if (Fcb->IsRoot) {
return EFI_SUCCESS;
} else {
- if (Fcb->Info.Attribute & EFI_FILE_READ_ONLY) {
+ if ((Fcb->Info.Attribute & EFI_FILE_READ_ONLY)
+ || !(Fcb->OpenMode & EFI_FILE_MODE_WRITE)) {
return EFI_ACCESS_DENIED;
} else {
return EFI_SUCCESS;
diff --git a/ArmPkg/Include/Chipset/AArch64Mmu.h b/ArmPkg/Include/Chipset/AArch64Mmu.h
index 17c28fa20..7c9890331 100644
--- a/ArmPkg/Include/Chipset/AArch64Mmu.h
+++ b/ArmPkg/Include/Chipset/AArch64Mmu.h
@@ -33,15 +33,15 @@
// The first offset starts at 12bit. There are 4 levels of 9-bit address range from level 3 to level 0
#define TT_ADDRESS_OFFSET_AT_LEVEL(TableLevel) (12 + ((3 - (TableLevel)) * 9))
-#define TT_BLOCK_ENTRY_SIZE_AT_LEVEL(Level) (1 << TT_ADDRESS_OFFSET_AT_LEVEL(Level))
+#define TT_BLOCK_ENTRY_SIZE_AT_LEVEL(Level) (1ULL << TT_ADDRESS_OFFSET_AT_LEVEL(Level))
// Get the associated entry in the given Translation Table
#define TT_GET_ENTRY_FOR_ADDRESS(TranslationTable, Level, Address) \
- ((UINTN)(TranslationTable) + ((((Address) >> TT_ADDRESS_OFFSET_AT_LEVEL(Level)) & (BIT9-1)) * sizeof(UINT64)))
+ ((UINTN)(TranslationTable) + ((((UINTN)(Address) >> TT_ADDRESS_OFFSET_AT_LEVEL(Level)) & (BIT9-1)) * sizeof(UINT64)))
// Return the smallest address granularity from the table level.
// The first offset starts at 12bit. There are 4 levels of 9-bit address range from level 3 to level 0
-#define TT_ADDRESS_AT_LEVEL(TableLevel) (1 << TT_ADDRESS_OFFSET_AT_LEVEL(TableLevel))
+#define TT_ADDRESS_AT_LEVEL(TableLevel) (1ULL << TT_ADDRESS_OFFSET_AT_LEVEL(TableLevel))
#define TT_LAST_BLOCK_ADDRESS(TranslationTable, EntryCount) \
((UINT64*)((EFI_PHYSICAL_ADDRESS)(TranslationTable) + (((EntryCount) - 1) * sizeof(UINT64))))
diff --git a/ArmPkg/Library/ArmLib/AArch64/AArch64Support.S b/ArmPkg/Library/ArmLib/AArch64/AArch64Support.S
index ad9fdda52..29251c996 100644
--- a/ArmPkg/Library/ArmLib/AArch64/AArch64Support.S
+++ b/ArmPkg/Library/ArmLib/AArch64/AArch64Support.S
@@ -320,7 +320,8 @@ ASM_PFX(AArch64AllDataCachesOperation):
mov x1, x0 // Save Function call in x1
mrs x6, clidr_el1 // Read EL1 CLIDR
and x3, x6, #0x7000000 // Mask out all but Level of Coherency (LoC)
- lsr x3, x3, #23 // Left align cache level value
+ lsr x3, x3, #23 // Left align cache level value - the level is shifted by 1 to the
+ // right to ease the access to CSSELR and the Set/Way operation.
cbz x3, L_Finished // No need to clean if LoC is 0
mov x10, #0 // Start clean at cache level 0
b Loop1
@@ -332,7 +333,8 @@ ASM_PFX(AArch64PerformPoUDataCacheOperation):
mov x1, x0 // Save Function call in x1
mrs x6, clidr_el1 // Read EL1 CLIDR
and x3, x6, #0x38000000 // Mask out all but Point of Unification (PoU)
- lsr x3, x3, #26 // Left align cache level value
+ lsr x3, x3, #26 // Left align cache level value - the level is shifted by 1 to the
+ // right to ease the access to CSSELR and the Set/Way operation.
cbz x3, L_Finished // No need to clean if LoC is 0
mov x10, #0 // Start clean at cache level 0
diff --git a/ArmPkg/Library/BdsLib/Arm/BdsLinuxLoader.c b/ArmPkg/Library/BdsLib/Arm/BdsLinuxLoader.c
index d0eb075c6..4805b40bc 100644
--- a/ArmPkg/Library/BdsLib/Arm/BdsLinuxLoader.c
+++ b/ArmPkg/Library/BdsLib/Arm/BdsLinuxLoader.c
@@ -258,19 +258,20 @@ BdsBootLinuxFdt (
Status = BdsLoadImage (InitrdDevicePath, AllocateAnyPages, &InitrdImageBase, &InitrdImageBaseSize);
}
if (EFI_ERROR(Status)) {
- Print (L"ERROR: Did not find initrd image.\n");
- goto EXIT_FREE_LINUX;
- }
-
- // Check if the initrd is a uInitrd
- if (*(UINT32*)((UINTN)InitrdImageBase) == LINUX_UIMAGE_SIGNATURE) {
- // Skip the 64-byte image header
- InitrdImage = (EFI_PHYSICAL_ADDRESS)((UINTN)InitrdImageBase + 64);
- InitrdImageSize = InitrdImageBaseSize - 64;
- } else {
- InitrdImage = InitrdImageBase;
- InitrdImageSize = InitrdImageBaseSize;
+ Print (L"ERROR: Did not find initrd image, you may need to update your config. Attempting to continue without it.\n");
+ InitrdImageBase = 0;
}
+ else {
+ // Check if the initrd is a uInitrd
+ if (*(UINT32*)((UINTN)InitrdImageBase) == LINUX_UIMAGE_SIGNATURE) {
+ // Skip the 64-byte image header
+ InitrdImage = (EFI_PHYSICAL_ADDRESS)((UINTN)InitrdImageBase + 64);
+ InitrdImageSize = InitrdImageBaseSize - 64;
+ } else {
+ InitrdImage = InitrdImageBase;
+ InitrdImageSize = InitrdImageBaseSize;
+ }
+ }
}
// Load the FDT binary from a device path. The FDT will be reloaded later to a more appropriate location for the Linux kernel.
@@ -299,7 +300,6 @@ EXIT_FREE_INITRD:
gBS->FreePages (InitrdImageBase, EFI_SIZE_TO_PAGES (InitrdImageBaseSize));
}
-EXIT_FREE_LINUX:
gBS->FreePages (LinuxImage, EFI_SIZE_TO_PAGES (LinuxImageSize));
return Status;
diff --git a/ArmPlatformPkg/ArmPlatformPkg.dec b/ArmPlatformPkg/ArmPlatformPkg.dec
index 3fc8a7031..b772fc08a 100644
--- a/ArmPlatformPkg/ArmPlatformPkg.dec
+++ b/ArmPlatformPkg/ArmPlatformPkg.dec
@@ -53,7 +53,11 @@
gArmPlatformTokenSpaceGuid.PcdSendSgiToBringUpSecondaryCores|FALSE|BOOLEAN|0x00000004
gArmPlatformTokenSpaceGuid.PcdNorFlashCheckBlockLocked|FALSE|BOOLEAN|0x0000003C
-
+
+ # Disable the GOP controller on ExitBootServices(). By default the value is FALSE,
+ # we assume the OS will handle the FrameBuffer from the UEFI GOP information.
+ gArmPlatformTokenSpaceGuid.PcdGopDisableOnExitBootServices|FALSE|BOOLEAN|0x0000003D
+
[PcdsFixedAtBuild.common]
gArmPlatformTokenSpaceGuid.PcdCoreCount|1|UINT32|0x00000039
gArmPlatformTokenSpaceGuid.PcdClusterCount|1|UINT32|0x00000038
@@ -141,16 +145,16 @@
gArmPlatformTokenSpaceGuid.PcdDefaultConInPaths|L""|VOID*|0x0000001B
gArmPlatformTokenSpaceGuid.PcdDefaultConOutPaths|L""|VOID*|0x0000001C
- #
- # LAN9118 Ethernet Driver PCDs
- #
- gArmPlatformTokenSpaceGuid.PcdLan9118DxeBaseAddress|0x0|UINT32|0x000000FF
-
- #
- # LAN91x Ethernet Driver PCDs
- #
- gArmPlatformTokenSpaceGuid.PcdLan91xDxeBaseAddress|0x0|UINT32|0x000000FE
-
+ #
+ # LAN9118 Ethernet Driver PCDs
+ #
+ gArmPlatformTokenSpaceGuid.PcdLan9118DxeBaseAddress|0x0|UINT32|0x000000FF
+
+ #
+ # LAN91x Ethernet Driver PCDs
+ #
+ gArmPlatformTokenSpaceGuid.PcdLan91xDxeBaseAddress|0x0|UINT32|0x000000FE
+
[PcdsFixedAtBuild.ARM]
# Stack for CPU Cores in Secure Monitor Mode
gArmPlatformTokenSpaceGuid.PcdCPUCoresSecMonStackBase|0|UINT32|0x00000007
diff --git a/ArmPlatformPkg/ArmVExpressPkg/ArmFvpDxe/ArmFvpDxe.c b/ArmPlatformPkg/ArmVExpressPkg/ArmFvpDxe/ArmFvpDxe.c
new file mode 100644
index 000000000..8982568c5
--- /dev/null
+++ b/ArmPlatformPkg/ArmVExpressPkg/ArmFvpDxe/ArmFvpDxe.c
@@ -0,0 +1,73 @@
+/** @file
+
+ Copyright (c) 2013, ARM Ltd. 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.
+
+**/
+
+#include <Library/UefiLib.h>
+#include <Library/VirtioMmioDeviceLib.h>
+#include <Library/DebugLib.h>
+#include <Library/UefiBootServicesTableLib.h>
+
+#define ARM_FVP_BASE_VIRTIO_BLOCK_BASE 0x1c130000
+
+typedef struct {
+ VENDOR_DEVICE_PATH Vendor;
+ EFI_DEVICE_PATH_PROTOCOL End;
+} VIRTIO_BLK_DEVICE_PATH;
+
+VIRTIO_BLK_DEVICE_PATH mVirtioBlockDevicePath =
+{
+ {
+ {
+ HARDWARE_DEVICE_PATH,
+ HW_VENDOR_DP,
+ {
+ (UINT8)( sizeof(VENDOR_DEVICE_PATH) ),
+ (UINT8)((sizeof(VENDOR_DEVICE_PATH)) >> 8)
+ }
+ },
+ EFI_CALLER_ID_GUID,
+ },
+ {
+ END_DEVICE_PATH_TYPE,
+ END_ENTIRE_DEVICE_PATH_SUBTYPE,
+ {
+ sizeof (EFI_DEVICE_PATH_PROTOCOL),
+ 0
+ }
+ }
+};
+
+EFI_STATUS
+EFIAPI
+ArmFvpInitialise (
+ IN EFI_HANDLE ImageHandle,
+ IN EFI_SYSTEM_TABLE *SystemTable
+ )
+{
+ EFI_STATUS Status;
+
+ Status = gBS->InstallProtocolInterface (&ImageHandle,
+ &gEfiDevicePathProtocolGuid, EFI_NATIVE_INTERFACE,
+ &mVirtioBlockDevicePath);
+ if (EFI_ERROR (Status)) {
+ return Status;
+ }
+
+ // Declare the Virtio BlockIo device
+ Status = VirtioMmioInstallDevice (ARM_FVP_BASE_VIRTIO_BLOCK_BASE, ImageHandle);
+ if (EFI_ERROR (Status)) {
+ DEBUG ((EFI_D_ERROR, "ArmFvpDxe: Failed to install Virtio block device\n"));
+ }
+
+ return Status;
+}
diff --git a/ArmPlatformPkg/ArmVExpressPkg/ArmFvpDxe/ArmFvpDxe.inf b/ArmPlatformPkg/ArmVExpressPkg/ArmFvpDxe/ArmFvpDxe.inf
new file mode 100644
index 000000000..893fd8d41
--- /dev/null
+++ b/ArmPlatformPkg/ArmVExpressPkg/ArmFvpDxe/ArmFvpDxe.inf
@@ -0,0 +1,35 @@
+#/** @file
+#
+# Copyright (c) 2013, ARM Ltd. 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.
+#
+#**/
+
+[Defines]
+ INF_VERSION = 0x00010006
+ BASE_NAME = ArmFvpDxe
+ FILE_GUID = fe61bb5f-1b67-4c24-b346-73db42e873e5
+ MODULE_TYPE = UEFI_DRIVER
+ VERSION_STRING = 1.0
+ ENTRY_POINT = ArmFvpInitialise
+
+[Sources.common]
+ ArmFvpDxe.c
+
+[Packages]
+ MdePkg/MdePkg.dec
+ ArmPlatformPkg/ArmPlatformPkg.dec
+ OvmfPkg/OvmfPkg.dec
+
+[LibraryClasses]
+ UefiDriverEntryPoint
+ UefiBootServicesTableLib
+ VirtioMmioDeviceLib
+ BaseMemoryLib
diff --git a/ArmPlatformPkg/ArmVExpressPkg/ArmVExpress-CTA15-A7.dsc b/ArmPlatformPkg/ArmVExpressPkg/ArmVExpress-CTA15-A7.dsc
index 7bbb464e5..abdeeabcb 100644
--- a/ArmPlatformPkg/ArmVExpressPkg/ArmVExpress-CTA15-A7.dsc
+++ b/ArmPlatformPkg/ArmVExpressPkg/ArmVExpress-CTA15-A7.dsc
@@ -251,6 +251,13 @@
MdeModulePkg/Universal/HiiDatabaseDxe/HiiDatabaseDxe.inf
+ #
+ # ACPI Support
+ #
+ MdeModulePkg/Universal/Acpi/AcpiPlatformDxe/AcpiPlatformDxe.inf
+ MdeModulePkg/Universal/Acpi/AcpiTableDxe/AcpiTableDxe.inf
+ ArmPkg/Drivers/AcpiTables/rtsm_ve-v7/AcpiTables.inf
+
ArmPkg/Drivers/PL390Gic/PL390GicDxe.inf
ArmPlatformPkg/Drivers/NorFlashDxe/NorFlashDxe.inf
#ArmPlatformPkg/Drivers/LcdGraphicsOutputDxe/PL111LcdGraphicsOutputDxe.inf
@@ -278,8 +285,6 @@
MdeModulePkg/Universal/Disk/PartitionDxe/PartitionDxe.inf
MdeModulePkg/Universal/Disk/UnicodeCollation/EnglishDxe/EnglishDxe.inf
- MdeModulePkg/Universal/Acpi/AcpiTableDxe/AcpiTableDxe.inf
-
#
# Bds
#
diff --git a/ArmPlatformPkg/ArmVExpressPkg/ArmVExpress-CTA15-A7.fdf b/ArmPlatformPkg/ArmVExpressPkg/ArmVExpress-CTA15-A7.fdf
index 881380763..ffd72cdc4 100644
--- a/ArmPlatformPkg/ArmVExpressPkg/ArmVExpress-CTA15-A7.fdf
+++ b/ArmPlatformPkg/ArmVExpressPkg/ArmVExpress-CTA15-A7.fdf
@@ -82,7 +82,14 @@ READ_LOCK_STATUS = TRUE
INF EmbeddedPkg/MetronomeDxe/MetronomeDxe.inf
INF MdeModulePkg/Universal/HiiDatabaseDxe/HiiDatabaseDxe.inf
-
+
+ #^M
+ # ACPI Support^M
+ #^M
+ INF MdeModulePkg/Universal/Acpi/AcpiPlatformDxe/AcpiPlatformDxe.inf
+ INF MdeModulePkg/Universal/Acpi/AcpiTableDxe/AcpiTableDxe.inf
+ INF RuleOverride=ACPITABLE ArmPkg/Drivers/AcpiTables/rtsm_ve-v7/AcpiTables.inf
+
#
# Multiple Console IO support
#
@@ -120,8 +127,6 @@ READ_LOCK_STATUS = TRUE
INF FatBinPkg/EnhancedFatDxe/Fat.inf
INF MdeModulePkg/Universal/Disk/UnicodeCollation/EnglishDxe/EnglishDxe.inf
- INF MdeModulePkg/Universal/Acpi/AcpiTableDxe/AcpiTableDxe.inf
-
#
# Networking stack
#
@@ -281,3 +286,11 @@ READ_LOCK_STATUS = TRUE
UI STRING="$(MODULE_NAME)" Optional
VERSION STRING="$(INF_VERSION)" Optional BUILD_NUM=$(BUILD_NUMBER)
}
+
+[Rule.Common.USER_DEFINED.ACPITABLE]
+ FILE FREEFORM = $(NAMED_GUID) {
+ RAW ACPI |.acpi
+ RAW ASL |.aml
+ UI STRING="$(MODULE_NAME)" Optional
+ }
+
diff --git a/ArmPlatformPkg/ArmVExpressPkg/ArmVExpress-CTA15x2.dsc b/ArmPlatformPkg/ArmVExpressPkg/ArmVExpress-CTA15x2.dsc
index 7ecd431af..2238936c2 100644
--- a/ArmPlatformPkg/ArmVExpressPkg/ArmVExpress-CTA15x2.dsc
+++ b/ArmPlatformPkg/ArmVExpressPkg/ArmVExpress-CTA15x2.dsc
@@ -279,6 +279,19 @@
MdeModulePkg/Universal/HiiDatabaseDxe/HiiDatabaseDxe.inf
+ #
+ # SMBIOS Support
+ #
+ MdeModulePkg/Universal/SmbiosDxe/SmbiosDxe.inf
+ ArmPkg/Drivers/UpdateSmbios/UpdateSmbios.inf
+
+ #
+ # ACPI Support
+ #
+ MdeModulePkg/Universal/Acpi/AcpiPlatformDxe/AcpiPlatformDxe.inf
+ MdeModulePkg/Universal/Acpi/AcpiTableDxe/AcpiTableDxe.inf
+ ArmPkg/Drivers/AcpiTables/rtsm_ve-v7/AcpiTables.inf
+
ArmPkg/Drivers/PL390Gic/PL390GicDxe.inf
ArmPlatformPkg/Drivers/NorFlashDxe/NorFlashDxe.inf
ArmPlatformPkg/Drivers/SP804TimerDxe/SP804TimerDxe.inf
diff --git a/ArmPlatformPkg/ArmVExpressPkg/ArmVExpress-CTA15x2.fdf b/ArmPlatformPkg/ArmVExpressPkg/ArmVExpress-CTA15x2.fdf
index 4fec30acf..cc53102c8 100644
--- a/ArmPlatformPkg/ArmVExpressPkg/ArmVExpress-CTA15x2.fdf
+++ b/ArmPlatformPkg/ArmVExpressPkg/ArmVExpress-CTA15x2.fdf
@@ -143,6 +143,19 @@ READ_LOCK_STATUS = TRUE
INF MdeModulePkg/Universal/HiiDatabaseDxe/HiiDatabaseDxe.inf
+ #
+ # SMBIOS Support
+ #
+ INF MdeModulePkg/Universal/SmbiosDxe/SmbiosDxe.inf
+ INF ArmPkg/Drivers/UpdateSmbios/UpdateSmbios.inf
+
+ #
+ # ACPI Support
+ #
+ INF MdeModulePkg/Universal/Acpi/AcpiPlatformDxe/AcpiPlatformDxe.inf
+ INF MdeModulePkg/Universal/Acpi/AcpiTableDxe/AcpiTableDxe.inf
+ INF RuleOverride=ACPITABLE ArmPkg/Drivers/AcpiTables/rtsm_ve-v7/AcpiTables.inf
+
INF ArmPkg/Drivers/PL390Gic/PL390GicDxe.inf
INF ArmPlatformPkg/Drivers/SP804TimerDxe/SP804TimerDxe.inf
INF ArmPlatformPkg/Drivers/NorFlashDxe/NorFlashDxe.inf
@@ -341,3 +354,11 @@ READ_LOCK_STATUS = TRUE
UI STRING="$(MODULE_NAME)" Optional
VERSION STRING="$(INF_VERSION)" Optional BUILD_NUM=$(BUILD_NUMBER)
}
+
+[Rule.Common.USER_DEFINED.ACPITABLE]
+ FILE FREEFORM = $(NAMED_GUID) {
+ RAW ACPI |.acpi
+ RAW ASL |.aml
+ UI STRING="$(MODULE_NAME)" Optional
+ }
+
diff --git a/ArmPlatformPkg/ArmVExpressPkg/ArmVExpress-CTA5s.dsc b/ArmPlatformPkg/ArmVExpressPkg/ArmVExpress-CTA5s.dsc
index b4ce23451..8f59e8ba0 100644
--- a/ArmPlatformPkg/ArmVExpressPkg/ArmVExpress-CTA5s.dsc
+++ b/ArmPlatformPkg/ArmVExpressPkg/ArmVExpress-CTA5s.dsc
@@ -270,6 +270,19 @@
MdeModulePkg/Universal/HiiDatabaseDxe/HiiDatabaseDxe.inf
+ #
+ # SMBIOS Support
+ #
+ MdeModulePkg/Universal/SmbiosDxe/SmbiosDxe.inf
+ ArmPkg/Drivers/UpdateSmbios/UpdateSmbios.inf
+
+ #
+ # ACPI Support
+ #
+ MdeModulePkg/Universal/Acpi/AcpiPlatformDxe/AcpiPlatformDxe.inf
+ MdeModulePkg/Universal/Acpi/AcpiTableDxe/AcpiTableDxe.inf
+ ArmPkg/Drivers/AcpiTables/rtsm_ve-v7/AcpiTables.inf
+
ArmPkg/Drivers/PL390Gic/PL390GicDxe.inf
ArmPlatformPkg/Drivers/NorFlashDxe/NorFlashDxe.inf
ArmPlatformPkg/Drivers/SP804TimerDxe/SP804TimerDxe.inf
diff --git a/ArmPlatformPkg/ArmVExpressPkg/ArmVExpress-CTA5s.fdf b/ArmPlatformPkg/ArmVExpressPkg/ArmVExpress-CTA5s.fdf
index a15a72160..dc54a3bf2 100644
--- a/ArmPlatformPkg/ArmVExpressPkg/ArmVExpress-CTA5s.fdf
+++ b/ArmPlatformPkg/ArmVExpressPkg/ArmVExpress-CTA5s.fdf
@@ -74,6 +74,8 @@ FV = FVMAIN_COMPACT
################################################################################
[FV.FVMAIN_SEC]
+FvBaseAddress = 0x0
+FvForceRebase = TRUE
FvAlignment = 8
ERASE_POLARITY = 1
MEMORY_MAPPED = TRUE
@@ -141,6 +143,19 @@ READ_LOCK_STATUS = TRUE
INF MdeModulePkg/Universal/HiiDatabaseDxe/HiiDatabaseDxe.inf
+ #
+ # SMBIOS Support
+ #
+ INF MdeModulePkg/Universal/SmbiosDxe/SmbiosDxe.inf
+ INF ArmPkg/Drivers/UpdateSmbios/UpdateSmbios.inf
+
+ #
+ # ACPI Support
+ #
+ INF MdeModulePkg/Universal/Acpi/AcpiPlatformDxe/AcpiPlatformDxe.inf
+ INF MdeModulePkg/Universal/Acpi/AcpiTableDxe/AcpiTableDxe.inf
+ INF RuleOverride=ACPITABLE ArmPkg/Drivers/AcpiTables/rtsm_ve-v7/AcpiTables.inf
+
INF ArmPkg/Drivers/PL390Gic/PL390GicDxe.inf
INF ArmPlatformPkg/Drivers/SP804TimerDxe/SP804TimerDxe.inf
INF ArmPlatformPkg/Drivers/NorFlashDxe/NorFlashDxe.inf
@@ -322,3 +337,11 @@ READ_LOCK_STATUS = TRUE
UI STRING="$(MODULE_NAME)" Optional
VERSION STRING="$(INF_VERSION)" Optional BUILD_NUM=$(BUILD_NUMBER)
}
+
+[Rule.Common.USER_DEFINED.ACPITABLE]
+ FILE FREEFORM = $(NAMED_GUID) {
+ RAW ACPI |.acpi
+ RAW ASL |.aml
+ UI STRING="$(MODULE_NAME)" Optional
+ }
+
diff --git a/ArmPlatformPkg/ArmVExpressPkg/ArmVExpress-CTA9x4.dsc b/ArmPlatformPkg/ArmVExpressPkg/ArmVExpress-CTA9x4.dsc
index b9ebb9959..875d0a305 100644
--- a/ArmPlatformPkg/ArmVExpressPkg/ArmVExpress-CTA9x4.dsc
+++ b/ArmPlatformPkg/ArmVExpressPkg/ArmVExpress-CTA9x4.dsc
@@ -32,11 +32,11 @@
!ifndef EDK2_ARMVE_STANDALONE
DEFINE EDK2_ARMVE_STANDALONE=1
!endif
-!ifndef $(EDK2_ARMVE_SINGLE_BINARY)
- DEFINE EDK2_ARMVE_SINGLE_BINARY=1
-!endif
-!ifdef $(EDK2_OUT_DIR)
- OUTPUT_DIRECTORY = $(EDK2_OUT_DIR)
+!ifndef $(EDK2_ARMVE_SINGLE_BINARY)
+ DEFINE EDK2_ARMVE_SINGLE_BINARY=1
+!endif
+!ifdef $(EDK2_OUT_DIR)
+ OUTPUT_DIRECTORY = $(EDK2_OUT_DIR)
!else
OUTPUT_DIRECTORY = Build/ArmVExpress-CTA9x4
!endif
@@ -289,6 +289,13 @@
MdeModulePkg/Universal/HiiDatabaseDxe/HiiDatabaseDxe.inf
+ #
+ # ACPI Support
+ #
+ MdeModulePkg/Universal/Acpi/AcpiPlatformDxe/AcpiPlatformDxe.inf
+ MdeModulePkg/Universal/Acpi/AcpiTableDxe/AcpiTableDxe.inf
+ ArmPkg/Drivers/AcpiTables/rtsm_ve-v7/AcpiTables.inf
+
ArmPkg/Drivers/PL390Gic/PL390GicDxe.inf
ArmPlatformPkg/Drivers/NorFlashDxe/NorFlashDxe.inf
ArmPlatformPkg/Drivers/SP804TimerDxe/SP804TimerDxe.inf
diff --git a/ArmPlatformPkg/ArmVExpressPkg/ArmVExpress-CTA9x4.fdf b/ArmPlatformPkg/ArmVExpressPkg/ArmVExpress-CTA9x4.fdf
index 117d8eca7..51646c338 100644
--- a/ArmPlatformPkg/ArmVExpressPkg/ArmVExpress-CTA9x4.fdf
+++ b/ArmPlatformPkg/ArmVExpressPkg/ArmVExpress-CTA9x4.fdf
@@ -187,6 +187,13 @@ READ_LOCK_STATUS = TRUE
INF MdeModulePkg/Universal/HiiDatabaseDxe/HiiDatabaseDxe.inf
+ #
+ # ACPI Support
+ #
+ INF MdeModulePkg/Universal/Acpi/AcpiPlatformDxe/AcpiPlatformDxe.inf
+ INF MdeModulePkg/Universal/Acpi/AcpiTableDxe/AcpiTableDxe.inf
+ INF RuleOverride=ACPITABLE ArmPkg/Drivers/AcpiTables/rtsm_ve-v7/AcpiTables.inf
+
INF ArmPkg/Drivers/PL390Gic/PL390GicDxe.inf
INF ArmPlatformPkg/Drivers/SP804TimerDxe/SP804TimerDxe.inf
INF ArmPlatformPkg/Drivers/NorFlashDxe/NorFlashDxe.inf
@@ -386,3 +393,11 @@ READ_LOCK_STATUS = TRUE
UI STRING="$(MODULE_NAME)" Optional
VERSION STRING="$(INF_VERSION)" Optional BUILD_NUM=$(BUILD_NUMBER)
}
+
+[Rule.Common.USER_DEFINED.ACPITABLE]
+ FILE FREEFORM = $(NAMED_GUID) {
+ RAW ACPI |.acpi
+ RAW ASL |.aml
+ UI STRING="$(MODULE_NAME)" Optional
+ }
+
diff --git a/ArmPlatformPkg/ArmVExpressPkg/ArmVExpress-FVP-AArch64.dsc b/ArmPlatformPkg/ArmVExpressPkg/ArmVExpress-FVP-AArch64.dsc
index 26296baad..194be40a4 100755
--- a/ArmPlatformPkg/ArmVExpressPkg/ArmVExpress-FVP-AArch64.dsc
+++ b/ArmPlatformPkg/ArmVExpressPkg/ArmVExpress-FVP-AArch64.dsc
@@ -40,7 +40,9 @@
ArmPlatformSysConfigLib|ArmPlatformPkg/ArmVExpressPkg/Library/ArmVExpressSysConfigLib/ArmVExpressSysConfigLib.inf
NorFlashPlatformLib|ArmPlatformPkg/ArmVExpressPkg/Library/NorFlashArmVExpressLib/NorFlashArmVExpressLib.inf
+!ifndef ARM_FOUNDATION_FVP
LcdPlatformLib|ArmPlatformPkg/ArmVExpressPkg/Library/PL111LcdArmVExpressLib/PL111LcdArmVExpressLib.inf
+!endif
TimerLib|ArmPkg/Library/ArmArchTimerLib/ArmArchTimerLib.inf
@@ -131,18 +133,28 @@
## PL031 RealTimeClock
gArmPlatformTokenSpaceGuid.PcdPL031RtcBase|0x1C170000
+!ifndef ARM_FOUNDATION_FVP
## PL111 Versatile Express Motherboard controller
gArmPlatformTokenSpaceGuid.PcdPL111LcdBase|0x1C1F0000
## PL180 MMC/SD card controller
gArmPlatformTokenSpaceGuid.PcdPL180SysMciRegAddress|0x1C010048
gArmPlatformTokenSpaceGuid.PcdPL180MciBaseAddress|0x1C050000
+!endif
#
- # ARM PL390 General Interrupt Controller
+ # ARM General Interrupt Controller
#
+!ifdef ARM_FVP_LEGACY_GICV2_LOCATION
+ gArmTokenSpaceGuid.PcdGicDistributorBase|0x2C001000
+ gArmTokenSpaceGuid.PcdGicInterruptInterfaceBase|0x2C002000
+!else
gArmTokenSpaceGuid.PcdGicDistributorBase|0x2f000000
gArmTokenSpaceGuid.PcdGicInterruptInterfaceBase|0x2C000000
+!endif
+
+ # Ethernet (SMSC 91C111)
+ gArmPlatformTokenSpaceGuid.PcdLan91xDxeBaseAddress|0x1A000000
#
# ARM OS Loader
@@ -156,7 +168,7 @@
gArmPlatformTokenSpaceGuid.PcdDefaultBootDevicePath|L"VenHw(C5B9C74A-6D72-4719-99AB-C59F199091EB)/Image"
gArmPlatformTokenSpaceGuid.PcdDefaultBootArgument|"console=ttyAMA0 earlyprintk=pl011,0x1c090000 debug user_debug=31 loglevel=9 root=/dev/vda2"
!endif
- gArmPlatformTokenSpaceGuid.PcdDefaultFdtLocalDevicePath|L"VenHw(C5B9C74A-6D72-4719-99AB-C59F199091EB)/fvp-base-gicv2-psci.dtb"
+ gArmPlatformTokenSpaceGuid.PcdDefaultFdtLocalDevicePath|L"VenHw(C5B9C74A-6D72-4719-99AB-C59F199091EB)/fdt.dtb"
gArmPlatformTokenSpaceGuid.PcdDefaultBootType|3
gArmPlatformTokenSpaceGuid.PcdFdtDevicePath|L"VenHw(C5B9C74A-6D72-4719-99AB-C59F199091EB)/fdt.dtb"
@@ -240,10 +252,19 @@
MdeModulePkg/Universal/HiiDatabaseDxe/HiiDatabaseDxe.inf
+ #^M
+ # ACPI Support^M
+ #^M
+ MdeModulePkg/Universal/Acpi/AcpiPlatformDxe/AcpiPlatformDxe.inf
+ MdeModulePkg/Universal/Acpi/AcpiTableDxe/AcpiTableDxe.inf
+ ArmPkg/Drivers/AcpiTables/rtsm_ve-aemv8a/AcpiTables.inf
+
ArmPkg/Drivers/PL390Gic/PL390GicDxe.inf
ArmPlatformPkg/Drivers/NorFlashDxe/NorFlashDxe.inf
ArmPkg/Drivers/TimerDxe/TimerDxe.inf
+!ifndef ARM_FOUNDATION_FVP
ArmPlatformPkg/Drivers/LcdGraphicsOutputDxe/PL111LcdGraphicsOutputDxe.inf
+!endif
ArmPlatformPkg/Drivers/SP805WatchdogDxe/SP805WatchdogDxe.inf
#
@@ -251,11 +272,13 @@
#
ArmPkg/Filesystem/SemihostFs/SemihostFs.inf
+!ifndef ARM_FOUNDATION_FVP
#
# Multimedia Card Interface
#
EmbeddedPkg/Universal/MmcDxe/MmcDxe.inf
ArmPlatformPkg/Drivers/PL180MciDxe/PL180MciDxe.inf
+!endif
#
# FAT filesystem + GPT/MBR partitioning
diff --git a/ArmPlatformPkg/ArmVExpressPkg/ArmVExpress-FVP-AArch64.fdf b/ArmPlatformPkg/ArmVExpressPkg/ArmVExpress-FVP-AArch64.fdf
index 3bbb34d69..b35a4da7e 100755
--- a/ArmPlatformPkg/ArmVExpressPkg/ArmVExpress-FVP-AArch64.fdf
+++ b/ArmPlatformPkg/ArmVExpressPkg/ArmVExpress-FVP-AArch64.fdf
@@ -139,6 +139,30 @@ READ_LOCK_STATUS = TRUE
INF MdeModulePkg/Universal/HiiDatabaseDxe/HiiDatabaseDxe.inf
#
+ # ACPI Support^M
+ #^M
+ INF MdeModulePkg/Universal/Acpi/AcpiPlatformDxe/AcpiPlatformDxe.inf
+ INF MdeModulePkg/Universal/Acpi/AcpiTableDxe/AcpiTableDxe.inf
+ INF RuleOverride=ACPITABLE ArmPkg/Drivers/AcpiTables/rtsm_ve-aemv8a/AcpiTables.inf
+
+ #
+ # Networking stack
+ #
+ INF MdeModulePkg/Universal/Network/DpcDxe/DpcDxe.inf
+ INF MdeModulePkg/Universal/Network/ArpDxe/ArpDxe.inf
+ INF MdeModulePkg/Universal/Network/Dhcp4Dxe/Dhcp4Dxe.inf
+ INF MdeModulePkg/Universal/Network/Ip4ConfigDxe/Ip4ConfigDxe.inf
+ INF MdeModulePkg/Universal/Network/Ip4Dxe/Ip4Dxe.inf
+ INF MdeModulePkg/Universal/Network/MnpDxe/MnpDxe.inf
+ INF MdeModulePkg/Universal/Network/VlanConfigDxe/VlanConfigDxe.inf
+ INF MdeModulePkg/Universal/Network/Mtftp4Dxe/Mtftp4Dxe.inf
+ INF MdeModulePkg/Universal/Network/Tcp4Dxe/Tcp4Dxe.inf
+ INF MdeModulePkg/Universal/Network/Udp4Dxe/Udp4Dxe.inf
+ INF MdeModulePkg/Universal/Network/UefiPxeBcDxe/UefiPxeBcDxe.inf
+ INF MdeModulePkg/Universal/Network/IScsiDxe/IScsiDxe.inf
+ INF ArmPlatformPkg/Drivers/LAN91xDxe/LAN91xDxe.inf
+
+ #
# Multiple Console IO support
#
INF MdeModulePkg/Universal/Console/ConPlatformDxe/ConPlatformDxe.inf
@@ -150,7 +174,9 @@ READ_LOCK_STATUS = TRUE
INF ArmPkg/Drivers/PL390Gic/PL390GicDxe.inf
INF ArmPkg/Drivers/TimerDxe/TimerDxe.inf
INF ArmPlatformPkg/Drivers/NorFlashDxe/NorFlashDxe.inf
+!ifndef ARM_FOUNDATION_FVP
INF ArmPlatformPkg/Drivers/LcdGraphicsOutputDxe/PL111LcdGraphicsOutputDxe.inf
+!endif
INF ArmPlatformPkg/Drivers/SP805WatchdogDxe/SP805WatchdogDxe.inf
#
@@ -166,11 +192,13 @@ READ_LOCK_STATUS = TRUE
INF FatBinPkg/EnhancedFatDxe/Fat.inf
INF MdeModulePkg/Universal/Disk/UnicodeCollation/EnglishDxe/EnglishDxe.inf
+!ifndef ARM_FOUNDATION_FVP
#
# Multimedia Card Interface
#
INF EmbeddedPkg/Universal/MmcDxe/MmcDxe.inf
INF ArmPlatformPkg/Drivers/PL180MciDxe/PL180MciDxe.inf
+!endif
#
# UEFI application (Shell Embedded Boot Loader)
@@ -321,3 +349,11 @@ READ_LOCK_STATUS = TRUE
UI STRING="$(MODULE_NAME)" Optional
VERSION STRING="$(INF_VERSION)" Optional BUILD_NUM=$(BUILD_NUMBER)
}
+
+[Rule.Common.USER_DEFINED.ACPITABLE]
+ FILE FREEFORM = $(NAMED_GUID) {
+ RAW ACPI |.acpi
+ RAW ASL |.aml
+ UI STRING="$(MODULE_NAME)" Optional
+ }
+
diff --git a/ArmPlatformPkg/ArmVExpressPkg/ArmVExpress-RTSM-A15.dsc b/ArmPlatformPkg/ArmVExpressPkg/ArmVExpress-RTSM-A15.dsc
index ad61f827a..aa124f6a8 100644
--- a/ArmPlatformPkg/ArmVExpressPkg/ArmVExpress-RTSM-A15.dsc
+++ b/ArmPlatformPkg/ArmVExpressPkg/ArmVExpress-RTSM-A15.dsc
@@ -81,12 +81,12 @@
#
# NV Storage PCDs. Use base of 0x0C000000 for NOR1
#
- gEfiMdeModulePkgTokenSpaceGuid.PcdFlashNvStorageVariableBase|0x0FFC0000
- gEfiMdeModulePkgTokenSpaceGuid.PcdFlashNvStorageVariableSize|0x00010000
- gEfiMdeModulePkgTokenSpaceGuid.PcdFlashNvStorageFtwWorkingBase|0x0FFD0000
- gEfiMdeModulePkgTokenSpaceGuid.PcdFlashNvStorageFtwWorkingSize|0x00010000
- gEfiMdeModulePkgTokenSpaceGuid.PcdFlashNvStorageFtwSpareBase|0x0FFE0000
- gEfiMdeModulePkgTokenSpaceGuid.PcdFlashNvStorageFtwSpareSize|0x00010000
+ gEfiMdeModulePkgTokenSpaceGuid.PcdFlashNvStorageVariableBase|0x0FF00000
+ gEfiMdeModulePkgTokenSpaceGuid.PcdFlashNvStorageVariableSize|0x00040000
+ gEfiMdeModulePkgTokenSpaceGuid.PcdFlashNvStorageFtwWorkingBase|0x0FF40000
+ gEfiMdeModulePkgTokenSpaceGuid.PcdFlashNvStorageFtwWorkingSize|0x00040000
+ gEfiMdeModulePkgTokenSpaceGuid.PcdFlashNvStorageFtwSpareBase|0x0FF80000
+ gEfiMdeModulePkgTokenSpaceGuid.PcdFlashNvStorageFtwSpareSize|0x00040000
gArmTokenSpaceGuid.PcdVFPEnabled|1
@@ -246,6 +246,13 @@
MdeModulePkg/Universal/HiiDatabaseDxe/HiiDatabaseDxe.inf
+ #
+ # ACPI Support
+ #
+ MdeModulePkg/Universal/Acpi/AcpiPlatformDxe/AcpiPlatformDxe.inf
+ MdeModulePkg/Universal/Acpi/AcpiTableDxe/AcpiTableDxe.inf
+ ArmPkg/Drivers/AcpiTables/rtsm_ve-v7/AcpiTables.inf
+
ArmPkg/Drivers/PL390Gic/PL390GicDxe.inf
ArmPlatformPkg/Drivers/NorFlashDxe/NorFlashDxe.inf
ArmPkg/Drivers/TimerDxe/TimerDxe.inf
diff --git a/ArmPlatformPkg/ArmVExpressPkg/ArmVExpress-RTSM-A15.fdf b/ArmPlatformPkg/ArmVExpressPkg/ArmVExpress-RTSM-A15.fdf
index be79efdae..5ecfb27a6 100644
--- a/ArmPlatformPkg/ArmVExpressPkg/ArmVExpress-RTSM-A15.fdf
+++ b/ArmPlatformPkg/ArmVExpressPkg/ArmVExpress-RTSM-A15.fdf
@@ -128,7 +128,14 @@ READ_LOCK_STATUS = TRUE
INF EmbeddedPkg/MetronomeDxe/MetronomeDxe.inf
INF MdeModulePkg/Universal/HiiDatabaseDxe/HiiDatabaseDxe.inf
-
+
+ #
+ # ACPI Support
+ #
+ INF MdeModulePkg/Universal/Acpi/AcpiPlatformDxe/AcpiPlatformDxe.inf
+ INF MdeModulePkg/Universal/Acpi/AcpiTableDxe/AcpiTableDxe.inf
+ INF RuleOverride=ACPITABLE ArmPkg/Drivers/AcpiTables/rtsm_ve-v7/AcpiTables.inf
+
#
# Networking stack
#
@@ -333,3 +340,11 @@ READ_LOCK_STATUS = TRUE
UI STRING="$(MODULE_NAME)" Optional
VERSION STRING="$(INF_VERSION)" Optional BUILD_NUM=$(BUILD_NUMBER)
}
+
+[Rule.Common.USER_DEFINED.ACPITABLE]
+ FILE FREEFORM = $(NAMED_GUID) {
+ RAW ACPI |.acpi
+ RAW ASL |.aml
+ UI STRING="$(MODULE_NAME)" Optional
+ }
+
diff --git a/ArmPlatformPkg/ArmVExpressPkg/ArmVExpress-RTSM-A15_MPCore.dsc b/ArmPlatformPkg/ArmVExpressPkg/ArmVExpress-RTSM-A15_MPCore.dsc
index 8f3c11b97..eecb783e8 100644
--- a/ArmPlatformPkg/ArmVExpressPkg/ArmVExpress-RTSM-A15_MPCore.dsc
+++ b/ArmPlatformPkg/ArmVExpressPkg/ArmVExpress-RTSM-A15_MPCore.dsc
@@ -83,12 +83,12 @@
#
# NV Storage PCDs. Use base of 0x0C000000 for NOR1
#
- gEfiMdeModulePkgTokenSpaceGuid.PcdFlashNvStorageVariableBase|0x0FFC0000
- gEfiMdeModulePkgTokenSpaceGuid.PcdFlashNvStorageVariableSize|0x00010000
- gEfiMdeModulePkgTokenSpaceGuid.PcdFlashNvStorageFtwWorkingBase|0x0FFD0000
- gEfiMdeModulePkgTokenSpaceGuid.PcdFlashNvStorageFtwWorkingSize|0x00010000
- gEfiMdeModulePkgTokenSpaceGuid.PcdFlashNvStorageFtwSpareBase|0x0FFE0000
- gEfiMdeModulePkgTokenSpaceGuid.PcdFlashNvStorageFtwSpareSize|0x00010000
+ gEfiMdeModulePkgTokenSpaceGuid.PcdFlashNvStorageVariableBase|0x0FF00000
+ gEfiMdeModulePkgTokenSpaceGuid.PcdFlashNvStorageVariableSize|0x00040000
+ gEfiMdeModulePkgTokenSpaceGuid.PcdFlashNvStorageFtwWorkingBase|0x0FF40000
+ gEfiMdeModulePkgTokenSpaceGuid.PcdFlashNvStorageFtwWorkingSize|0x00040000
+ gEfiMdeModulePkgTokenSpaceGuid.PcdFlashNvStorageFtwSpareBase|0x0FF80000
+ gEfiMdeModulePkgTokenSpaceGuid.PcdFlashNvStorageFtwSpareSize|0x00040000
gArmTokenSpaceGuid.PcdVFPEnabled|1
@@ -248,6 +248,13 @@
MdeModulePkg/Universal/HiiDatabaseDxe/HiiDatabaseDxe.inf
+ #
+ # ACPI Support
+ #
+ MdeModulePkg/Universal/Acpi/AcpiPlatformDxe/AcpiPlatformDxe.inf
+ MdeModulePkg/Universal/Acpi/AcpiTableDxe/AcpiTableDxe.inf
+ ArmPkg/Drivers/AcpiTables/rtsm_ve-v7/AcpiTables.inf
+
ArmPkg/Drivers/PL390Gic/PL390GicDxe.inf
ArmPlatformPkg/Drivers/NorFlashDxe/NorFlashDxe.inf
ArmPkg/Drivers/TimerDxe/TimerDxe.inf
diff --git a/ArmPlatformPkg/ArmVExpressPkg/ArmVExpress-RTSM-A15_MPCore.fdf b/ArmPlatformPkg/ArmVExpressPkg/ArmVExpress-RTSM-A15_MPCore.fdf
index 7bcaca029..97bac4f5b 100644
--- a/ArmPlatformPkg/ArmVExpressPkg/ArmVExpress-RTSM-A15_MPCore.fdf
+++ b/ArmPlatformPkg/ArmVExpressPkg/ArmVExpress-RTSM-A15_MPCore.fdf
@@ -128,7 +128,14 @@ READ_LOCK_STATUS = TRUE
INF EmbeddedPkg/MetronomeDxe/MetronomeDxe.inf
INF MdeModulePkg/Universal/HiiDatabaseDxe/HiiDatabaseDxe.inf
-
+
+ #
+ # ACPI Support
+ #
+ INF MdeModulePkg/Universal/Acpi/AcpiPlatformDxe/AcpiPlatformDxe.inf
+ INF MdeModulePkg/Universal/Acpi/AcpiTableDxe/AcpiTableDxe.inf
+ INF RuleOverride=ACPITABLE ArmPkg/Drivers/AcpiTables/rtsm_ve-v7/AcpiTables.inf
+
#
# Networking stack
#
@@ -145,7 +152,6 @@ READ_LOCK_STATUS = TRUE
INF MdeModulePkg/Universal/Network/UefiPxeBcDxe/UefiPxeBcDxe.inf
INF MdeModulePkg/Universal/Network/IScsiDxe/IScsiDxe.inf
INF ArmPlatformPkg/Drivers/LAN91xDxe/LAN91xDxe.inf
-
#
# Multiple Console IO support
#
@@ -333,3 +339,11 @@ READ_LOCK_STATUS = TRUE
UI STRING="$(MODULE_NAME)" Optional
VERSION STRING="$(INF_VERSION)" Optional BUILD_NUM=$(BUILD_NUMBER)
}
+
+[Rule.Common.USER_DEFINED.ACPITABLE]
+ FILE FREEFORM = $(NAMED_GUID) {
+ RAW ACPI |.acpi
+ RAW ASL |.aml
+ UI STRING="$(MODULE_NAME)" Optional
+ }
+
diff --git a/ArmPlatformPkg/ArmVExpressPkg/ArmVExpress-RTSM-A9x4.dsc b/ArmPlatformPkg/ArmVExpressPkg/ArmVExpress-RTSM-A9x4.dsc
index 9cdce18ff..11f5efbab 100644
--- a/ArmPlatformPkg/ArmVExpressPkg/ArmVExpress-RTSM-A9x4.dsc
+++ b/ArmPlatformPkg/ArmVExpressPkg/ArmVExpress-RTSM-A9x4.dsc
@@ -153,8 +153,9 @@
gArmTokenSpaceGuid.PcdGicDistributorBase|0x2C001000
gArmTokenSpaceGuid.PcdGicInterruptInterfaceBase|0x2C000100
- # Ethernet (SMSC 91C111)
- gArmPlatformTokenSpaceGuid.PcdLan91xDxeBaseAddress|0x1A000000
+ # Ethernet (SMSC 91C111)
+ gArmPlatformTokenSpaceGuid.PcdLan91xDxeBaseAddress|0x1A000000
+
#
# ARM OS Loader
#
@@ -256,6 +257,13 @@
MdeModulePkg/Universal/HiiDatabaseDxe/HiiDatabaseDxe.inf
+ #
+ # ACPI Support
+ #
+ MdeModulePkg/Universal/Acpi/AcpiPlatformDxe/AcpiPlatformDxe.inf
+ MdeModulePkg/Universal/Acpi/AcpiTableDxe/AcpiTableDxe.inf
+ ArmPkg/Drivers/AcpiTables/rtsm_ve-v7/AcpiTables.inf
+
ArmPkg/Drivers/PL390Gic/PL390GicDxe.inf
ArmPlatformPkg/Drivers/NorFlashDxe/NorFlashDxe.inf
ArmPlatformPkg/Drivers/SP804TimerDxe/SP804TimerDxe.inf
diff --git a/ArmPlatformPkg/ArmVExpressPkg/ArmVExpress-RTSM-A9x4.fdf b/ArmPlatformPkg/ArmVExpressPkg/ArmVExpress-RTSM-A9x4.fdf
index 170d598f5..a3e50ff0d 100644
--- a/ArmPlatformPkg/ArmVExpressPkg/ArmVExpress-RTSM-A9x4.fdf
+++ b/ArmPlatformPkg/ArmVExpressPkg/ArmVExpress-RTSM-A9x4.fdf
@@ -127,24 +127,32 @@ READ_LOCK_STATUS = TRUE
INF EmbeddedPkg/MetronomeDxe/MetronomeDxe.inf
INF MdeModulePkg/Universal/HiiDatabaseDxe/HiiDatabaseDxe.inf
-
- #
- # Networking stack
+
#
- INF MdeModulePkg/Universal/Network/DpcDxe/DpcDxe.inf
- INF MdeModulePkg/Universal/Network/ArpDxe/ArpDxe.inf
- INF MdeModulePkg/Universal/Network/Dhcp4Dxe/Dhcp4Dxe.inf
- INF MdeModulePkg/Universal/Network/Ip4ConfigDxe/Ip4ConfigDxe.inf
- INF MdeModulePkg/Universal/Network/Ip4Dxe/Ip4Dxe.inf
- INF MdeModulePkg/Universal/Network/MnpDxe/MnpDxe.inf
- INF MdeModulePkg/Universal/Network/VlanConfigDxe/VlanConfigDxe.inf
- INF MdeModulePkg/Universal/Network/Mtftp4Dxe/Mtftp4Dxe.inf
- INF MdeModulePkg/Universal/Network/Tcp4Dxe/Tcp4Dxe.inf
- INF MdeModulePkg/Universal/Network/Udp4Dxe/Udp4Dxe.inf
- INF MdeModulePkg/Universal/Network/UefiPxeBcDxe/UefiPxeBcDxe.inf
- INF MdeModulePkg/Universal/Network/IScsiDxe/IScsiDxe.inf
- INF ArmPlatformPkg/Drivers/LAN91xDxe/LAN91xDxe.inf
-
+ # ACPI Support
+ #
+ INF MdeModulePkg/Universal/Acpi/AcpiPlatformDxe/AcpiPlatformDxe.inf
+ INF MdeModulePkg/Universal/Acpi/AcpiTableDxe/AcpiTableDxe.inf
+ INF RuleOverride=ACPITABLE ArmPkg/Drivers/AcpiTables/rtsm_ve-v7/AcpiTables.inf
+
+ #
+ # Networking stack
+ #
+ INF MdeModulePkg/Universal/Network/DpcDxe/DpcDxe.inf
+ INF MdeModulePkg/Universal/Network/ArpDxe/ArpDxe.inf
+ INF MdeModulePkg/Universal/Network/Dhcp4Dxe/Dhcp4Dxe.inf
+ INF MdeModulePkg/Universal/Network/Ip4ConfigDxe/Ip4ConfigDxe.inf
+ INF MdeModulePkg/Universal/Network/Ip4Dxe/Ip4Dxe.inf
+ INF MdeModulePkg/Universal/Network/MnpDxe/MnpDxe.inf
+ INF MdeModulePkg/Universal/Network/VlanConfigDxe/VlanConfigDxe.inf
+ INF MdeModulePkg/Universal/Network/Mtftp4Dxe/Mtftp4Dxe.inf
+ INF MdeModulePkg/Universal/Network/Tcp4Dxe/Tcp4Dxe.inf
+ INF MdeModulePkg/Universal/Network/Udp4Dxe/Udp4Dxe.inf
+ INF MdeModulePkg/Universal/Network/UefiPxeBcDxe/UefiPxeBcDxe.inf
+ INF MdeModulePkg/Universal/Network/IScsiDxe/IScsiDxe.inf
+ INF ArmPlatformPkg/Drivers/LAN91xDxe/LAN91xDxe.inf
+
+ #
# Multiple Console IO support
#
INF MdeModulePkg/Universal/Console/ConPlatformDxe/ConPlatformDxe.inf
@@ -331,3 +339,11 @@ READ_LOCK_STATUS = TRUE
UI STRING="$(MODULE_NAME)" Optional
VERSION STRING="$(INF_VERSION)" Optional BUILD_NUM=$(BUILD_NUMBER)
}
+
+[Rule.Common.USER_DEFINED.ACPITABLE]
+ FILE FREEFORM = $(NAMED_GUID) {
+ RAW ACPI |.acpi
+ RAW ASL |.aml
+ UI STRING="$(MODULE_NAME)" Optional
+ }
+
diff --git a/ArmPlatformPkg/ArmVExpressPkg/ArmVExpress-RTSM-AEMv8Ax4-foundation.dsc b/ArmPlatformPkg/ArmVExpressPkg/ArmVExpress-RTSM-AEMv8Ax4-foundation.dsc
index 4ba827b28..29dbbafef 100644
--- a/ArmPlatformPkg/ArmVExpressPkg/ArmVExpress-RTSM-AEMv8Ax4-foundation.dsc
+++ b/ArmPlatformPkg/ArmVExpressPkg/ArmVExpress-RTSM-AEMv8Ax4-foundation.dsc
@@ -34,6 +34,10 @@
ArmCpuLib|ArmPkg/Drivers/ArmCpuLib/ArmCortexAEMv8Lib/ArmCortexAEMv8Lib.inf
ArmPlatformLib|ArmPlatformPkg/ArmVExpressPkg/Library/ArmVExpressLibRTSM/ArmVExpressFoundationLib.inf
+ # Virtio Support
+ VirtioLib|OvmfPkg/Library/VirtioLib/VirtioLib.inf
+ VirtioMmioDeviceLib|OvmfPkg/Library/VirtioMmioDeviceLib/VirtioMmioDeviceLib.inf
+
ArmPlatformSysConfigLib|ArmPlatformPkg/ArmVExpressPkg/Library/ArmVExpressSysConfigLib/ArmVExpressSysConfigLib.inf
TimerLib|ArmPkg/Library/ArmArchTimerLib/ArmArchTimerLib.inf
@@ -214,6 +218,19 @@
EmbeddedPkg/SerialDxe/SerialDxe.inf
MdeModulePkg/Universal/HiiDatabaseDxe/HiiDatabaseDxe.inf
+
+ #
+ # ACPI Support
+ #
+ MdeModulePkg/Universal/Acpi/AcpiPlatformDxe/AcpiPlatformDxe.inf
+ MdeModulePkg/Universal/Acpi/AcpiTableDxe/AcpiTableDxe.inf
+ ArmPkg/Drivers/AcpiTables/foundation-v8/AcpiTables.inf
+
+ #^M
+ # SMBIOS Support^M
+ #^M
+ MdeModulePkg/Universal/SmbiosDxe/SmbiosDxe.inf
+ ArmPkg/Drivers/UpdateSmbios/UpdateSmbios.inf
ArmPkg/Drivers/PL390Gic/PL390GicDxe.inf
ArmPkg/Drivers/TimerDxe/TimerDxe.inf
@@ -225,6 +242,12 @@
ArmPkg/Filesystem/SemihostFs/SemihostFs.inf
#
+ # Platform Driver
+ #
+ ArmPlatformPkg/ArmVExpressPkg/ArmFvpDxe/ArmFvpDxe.inf
+ OvmfPkg/VirtioBlkDxe/VirtioBlk.inf
+
+ #
# FAT filesystem + GPT/MBR partitioning
#
MdeModulePkg/Universal/Disk/DiskIoDxe/DiskIoDxe.inf
diff --git a/ArmPlatformPkg/ArmVExpressPkg/ArmVExpress-RTSM-AEMv8Ax4-foundation.fdf b/ArmPlatformPkg/ArmVExpressPkg/ArmVExpress-RTSM-AEMv8Ax4-foundation.fdf
index a358b061d..9981daf58 100644
--- a/ArmPlatformPkg/ArmVExpressPkg/ArmVExpress-RTSM-AEMv8Ax4-foundation.fdf
+++ b/ArmPlatformPkg/ArmVExpressPkg/ArmVExpress-RTSM-AEMv8Ax4-foundation.fdf
@@ -128,7 +128,20 @@ READ_LOCK_STATUS = TRUE
INF MdeModulePkg/Universal/HiiDatabaseDxe/HiiDatabaseDxe.inf
+ #^M
+ # SMBIOS Support^M
+ #^M
+ INF MdeModulePkg/Universal/SmbiosDxe/SmbiosDxe.inf
+ INF ArmPkg/Drivers/UpdateSmbios/UpdateSmbios.inf
+
#
+ # ACPI Support
+ #
+ INF MdeModulePkg/Universal/Acpi/AcpiPlatformDxe/AcpiPlatformDxe.inf
+ INF MdeModulePkg/Universal/Acpi/AcpiTableDxe/AcpiTableDxe.inf
+ INF RuleOverride=ACPITABLE ArmPkg/Drivers/AcpiTables/foundation-v8/AcpiTables.inf
+
+ #
# Multiple Console IO support
#
INF MdeModulePkg/Universal/Console/ConPlatformDxe/ConPlatformDxe.inf
@@ -155,6 +168,12 @@ READ_LOCK_STATUS = TRUE
INF MdeModulePkg/Universal/Disk/UnicodeCollation/EnglishDxe/EnglishDxe.inf
#
+ # Platform Driver
+ #
+ INF ArmPlatformPkg/ArmVExpressPkg/ArmFvpDxe/ArmFvpDxe.inf
+ INF OvmfPkg/VirtioBlkDxe/VirtioBlk.inf
+
+ #
# UEFI application (Shell Embedded Boot Loader)
#
INF ShellBinPkg/UefiShell/UefiShell.inf
@@ -306,3 +325,11 @@ READ_LOCK_STATUS = TRUE
UI STRING="$(MODULE_NAME)" Optional
VERSION STRING="$(INF_VERSION)" Optional BUILD_NUM=$(BUILD_NUMBER)
}
+
+[Rule.Common.USER_DEFINED.ACPITABLE]
+ FILE FREEFORM = $(NAMED_GUID) {
+ RAW ACPI |.acpi
+ RAW ASL |.aml
+ UI STRING="$(MODULE_NAME)" Optional
+ }
+
diff --git a/ArmPlatformPkg/ArmVExpressPkg/ArmVExpress-RTSM-AEMv8Ax4.dsc b/ArmPlatformPkg/ArmVExpressPkg/ArmVExpress-RTSM-AEMv8Ax4.dsc
index 9c4d0bdb2..cf5823d9a 100644
--- a/ArmPlatformPkg/ArmVExpressPkg/ArmVExpress-RTSM-AEMv8Ax4.dsc
+++ b/ArmPlatformPkg/ArmVExpressPkg/ArmVExpress-RTSM-AEMv8Ax4.dsc
@@ -40,6 +40,10 @@
TimerLib|ArmPkg/Library/ArmArchTimerLib/ArmArchTimerLib.inf
+ # VirtIo Support
+ VirtioLib|OvmfPkg/Library/VirtioLib/VirtioLib.inf
+ VirtioMmioDeviceLib|OvmfPkg/Library/VirtioMmioDeviceLib/VirtioMmioDeviceLib.inf
+
[LibraryClasses.common.SEC]
ArmLib|ArmPkg/Library/ArmLib/AArch64/AArch64LibSec.inf
ArmPlatformSecLib|ArmPlatformPkg/ArmVExpressPkg/Library/ArmVExpressSecLibRTSM/ArmVExpressSecLib.inf
@@ -237,6 +241,18 @@
MdeModulePkg/Universal/HiiDatabaseDxe/HiiDatabaseDxe.inf
+ #
+ # ACPI Support
+ #
+ MdeModulePkg/Universal/Acpi/AcpiPlatformDxe/AcpiPlatformDxe.inf
+ MdeModulePkg/Universal/Acpi/AcpiTableDxe/AcpiTableDxe.inf
+ ArmPkg/Drivers/AcpiTables/rtsm_ve-aemv8a/AcpiTables.inf
+ #^M
+ # SMBIOS Support^M
+ #^M
+ MdeModulePkg/Universal/SmbiosDxe/SmbiosDxe.inf
+ ArmPkg/Drivers/UpdateSmbios/UpdateSmbios.inf
+
ArmPkg/Drivers/PL390Gic/PL390GicDxe.inf
ArmPlatformPkg/Drivers/NorFlashDxe/NorFlashDxe.inf
ArmPkg/Drivers/TimerDxe/TimerDxe.inf
@@ -255,6 +271,12 @@
ArmPlatformPkg/Drivers/PL180MciDxe/PL180MciDxe.inf
#
+ # Platform Driver
+ #
+ ArmPlatformPkg/ArmVExpressPkg/ArmFvpDxe/ArmFvpDxe.inf
+ OvmfPkg/VirtioBlkDxe/VirtioBlk.inf
+
+ #
# FAT filesystem + GPT/MBR partitioning
#
MdeModulePkg/Universal/Disk/DiskIoDxe/DiskIoDxe.inf
diff --git a/ArmPlatformPkg/ArmVExpressPkg/ArmVExpress-RTSM-AEMv8Ax4.fdf b/ArmPlatformPkg/ArmVExpressPkg/ArmVExpress-RTSM-AEMv8Ax4.fdf
index c732442b2..af1b0fa97 100644
--- a/ArmPlatformPkg/ArmVExpressPkg/ArmVExpress-RTSM-AEMv8Ax4.fdf
+++ b/ArmPlatformPkg/ArmVExpressPkg/ArmVExpress-RTSM-AEMv8Ax4.fdf
@@ -130,7 +130,20 @@ READ_LOCK_STATUS = TRUE
INF MdeModulePkg/Universal/HiiDatabaseDxe/HiiDatabaseDxe.inf
+ #^M
+ # SMBIOS Support^M
+ #^M
+ INF MdeModulePkg/Universal/SmbiosDxe/SmbiosDxe.inf
+ INF ArmPkg/Drivers/UpdateSmbios/UpdateSmbios.inf
+
#
+ # ACPI Support
+ #
+ INF MdeModulePkg/Universal/Acpi/AcpiPlatformDxe/AcpiPlatformDxe.inf
+ INF MdeModulePkg/Universal/Acpi/AcpiTableDxe/AcpiTableDxe.inf
+ INF RuleOverride=ACPITABLE ArmPkg/Drivers/AcpiTables/rtsm_ve-aemv8a/AcpiTables.inf
+
+ #
# Multiple Console IO support
#
INF MdeModulePkg/Universal/Console/ConPlatformDxe/ConPlatformDxe.inf
@@ -163,7 +176,13 @@ READ_LOCK_STATUS = TRUE
#
INF EmbeddedPkg/Universal/MmcDxe/MmcDxe.inf
INF ArmPlatformPkg/Drivers/PL180MciDxe/PL180MciDxe.inf
-
+
+ #
+ # Platform Driver
+ #
+ INF ArmPlatformPkg/ArmVExpressPkg/ArmFvpDxe/ArmFvpDxe.inf
+ INF OvmfPkg/VirtioBlkDxe/VirtioBlk.inf
+
#
# UEFI application (Shell Embedded Boot Loader)
#
@@ -317,3 +336,11 @@ READ_LOCK_STATUS = TRUE
UI STRING="$(MODULE_NAME)" Optional
VERSION STRING="$(INF_VERSION)" Optional BUILD_NUM=$(BUILD_NUMBER)
}
+
+[Rule.Common.USER_DEFINED.ACPITABLE]
+ FILE FREEFORM = $(NAMED_GUID) {
+ RAW ACPI |.acpi
+ RAW ASL |.aml
+ UI STRING="$(MODULE_NAME)" Optional
+ }
+
diff --git a/ArmPlatformPkg/ArmVExpressPkg/ArmVExpress.dsc.inc b/ArmPlatformPkg/ArmVExpressPkg/ArmVExpress.dsc.inc
index 1568c9d84..f36df9a13 100644
--- a/ArmPlatformPkg/ArmVExpressPkg/ArmVExpress.dsc.inc
+++ b/ArmPlatformPkg/ArmVExpressPkg/ArmVExpress.dsc.inc
@@ -54,12 +54,12 @@
#BaseMemoryLib|MdePkg/Library/BaseMemoryLib/BaseMemoryLib.inf
BaseMemoryLib|ArmPkg/Library/BaseMemoryLibStm/BaseMemoryLibStm.inf
- # Networking Requirements
- NetLib|MdeModulePkg/Library/DxeNetLib/DxeNetLib.inf
- DpcLib|MdeModulePkg/Library/DxeDpcLib/DxeDpcLib.inf
- UdpIoLib|MdeModulePkg/Library/DxeUdpIoLib/DxeUdpIoLib.inf
- IpIoLib|MdeModulePkg/Library/DxeIpIoLib/DxeIpIoLib.inf
-
+ # Networking Requirements
+ NetLib|MdeModulePkg/Library/DxeNetLib/DxeNetLib.inf
+ DpcLib|MdeModulePkg/Library/DxeDpcLib/DxeDpcLib.inf
+ UdpIoLib|MdeModulePkg/Library/DxeUdpIoLib/DxeUdpIoLib.inf
+ IpIoLib|MdeModulePkg/Library/DxeIpIoLib/DxeIpIoLib.inf
+
# ARM Architectural Libraries
CacheMaintenanceLib|ArmPkg/Library/ArmCacheMaintenanceLib/ArmCacheMaintenanceLib.inf
DefaultExceptionHandlerLib|ArmPkg/Library/DefaultExceptionHandlerLib/DefaultExceptionHandlerLib.inf
@@ -350,21 +350,21 @@
gArmPlatformTokenSpaceGuid.PcdDefaultConInPaths|L"VenHw(D3987D4B-971A-435F-8CAF-4967EB627241)/Uart(38400,8,N,1)/VenPcAnsi()"
gArmPlatformTokenSpaceGuid.PcdPlatformBootTimeOut|10
-[Components.common]
- #
- # Networking stack
- #
- MdeModulePkg/Universal/Network/DpcDxe/DpcDxe.inf
- MdeModulePkg/Universal/Network/ArpDxe/ArpDxe.inf
- MdeModulePkg/Universal/Network/Dhcp4Dxe/Dhcp4Dxe.inf
- MdeModulePkg/Universal/Network/Ip4ConfigDxe/Ip4ConfigDxe.inf
- MdeModulePkg/Universal/Network/Ip4Dxe/Ip4Dxe.inf
- MdeModulePkg/Universal/Network/MnpDxe/MnpDxe.inf
- MdeModulePkg/Universal/Network/VlanConfigDxe/VlanConfigDxe.inf
- MdeModulePkg/Universal/Network/Mtftp4Dxe/Mtftp4Dxe.inf
- MdeModulePkg/Universal/Network/Tcp4Dxe/Tcp4Dxe.inf
- MdeModulePkg/Universal/Network/Udp4Dxe/Udp4Dxe.inf
- MdeModulePkg/Universal/Network/UefiPxeBcDxe/UefiPxeBcDxe.inf
- MdeModulePkg/Universal/Network/IScsiDxe/IScsiDxe.inf
- ArmPlatformPkg/Drivers/LAN9118Dxe/LAN9118Dxe.inf
- ArmPlatformPkg/Drivers/LAN91xDxe/LAN91xDxe.inf
+[Components.common]
+ #
+ # Networking stack
+ #
+ MdeModulePkg/Universal/Network/DpcDxe/DpcDxe.inf
+ MdeModulePkg/Universal/Network/ArpDxe/ArpDxe.inf
+ MdeModulePkg/Universal/Network/Dhcp4Dxe/Dhcp4Dxe.inf
+ MdeModulePkg/Universal/Network/Ip4ConfigDxe/Ip4ConfigDxe.inf
+ MdeModulePkg/Universal/Network/Ip4Dxe/Ip4Dxe.inf
+ MdeModulePkg/Universal/Network/MnpDxe/MnpDxe.inf
+ MdeModulePkg/Universal/Network/VlanConfigDxe/VlanConfigDxe.inf
+ MdeModulePkg/Universal/Network/Mtftp4Dxe/Mtftp4Dxe.inf
+ MdeModulePkg/Universal/Network/Tcp4Dxe/Tcp4Dxe.inf
+ MdeModulePkg/Universal/Network/Udp4Dxe/Udp4Dxe.inf
+ MdeModulePkg/Universal/Network/UefiPxeBcDxe/UefiPxeBcDxe.inf
+ MdeModulePkg/Universal/Network/IScsiDxe/IScsiDxe.inf
+ ArmPlatformPkg/Drivers/LAN9118Dxe/LAN9118Dxe.inf
+ ArmPlatformPkg/Drivers/LAN91xDxe/LAN91xDxe.inf
diff --git a/ArmPlatformPkg/Bds/Bds.c b/ArmPlatformPkg/Bds/Bds.c
index 3a66eb3aa..ee79c4e8e 100644
--- a/ArmPlatformPkg/Bds/Bds.c
+++ b/ArmPlatformPkg/Bds/Bds.c
@@ -281,7 +281,7 @@ DefineDefaultBootEntries (
FdtLocalPath = NULL;
FdtLocalSize = 0;
}
-
+
BootArguments = (ARM_BDS_LOADER_ARGUMENTS*)AllocatePool (sizeof(ARM_BDS_LOADER_ARGUMENTS) + CmdLineSize + InitrdSize + FdtLocalSize);
if ( BootArguments != NULL ) {
BootArguments->LinuxArguments.CmdLineSize = CmdLineSize;
diff --git a/ArmPlatformPkg/Bds/BdsHelper.c b/ArmPlatformPkg/Bds/BdsHelper.c
index a0dc74be4..fb12a8cec 100644
--- a/ArmPlatformPkg/Bds/BdsHelper.c
+++ b/ArmPlatformPkg/Bds/BdsHelper.c
@@ -35,7 +35,7 @@ EditHIInputStr (
Print (CmdLine);
// To prevent a buffer overflow, we only allow to enter (MaxCmdLine-1) characters
- for (CmdLineIndex = StrLen (CmdLine); CmdLineIndex < MaxCmdLine; ) {
+ for (CmdLineIndex = StrLen (CmdLine); CmdLineIndex < MaxCmdLine; ) {
Status = gBS->WaitForEvent (1, &gST->ConIn->WaitForKey, &WaitIndex);
ASSERT_EFI_ERROR (Status);
@@ -62,7 +62,7 @@ EditHIInputStr (
}
} else if ((Key.ScanCode == SCAN_ESC) || (Char == 0x1B) || (Char == 0x0)) {
return EFI_INVALID_PARAMETER;
- } else if (CmdLineIndex < (MaxCmdLine-1)) {
+ } else if (CmdLineIndex < (MaxCmdLine-1)) {
CmdLine[CmdLineIndex++] = Key.UnicodeChar;
Print (L"%c", Key.UnicodeChar);
}
diff --git a/ArmPlatformPkg/Bds/BootOption.c b/ArmPlatformPkg/Bds/BootOption.c
index 7bbd548c8..edd193e3e 100644
--- a/ArmPlatformPkg/Bds/BootOption.c
+++ b/ArmPlatformPkg/Bds/BootOption.c
@@ -73,7 +73,7 @@ BootOptionStart (
if (LoaderType == BDS_LOADER_KERNEL_LINUX_LOCAL_FDT) {
FdtLocalSize = ReadUnaligned16 ((CONST UINT16*)&LinuxArguments->FdtLocalSize);
-
+
if (FdtLocalSize > 0) {
FdtDevicePath = GetAlignedDevicePath ((EFI_DEVICE_PATH*)((UINTN)(LinuxArguments + 1) + CmdLineSize + InitrdSize));
} else {
diff --git a/ArmPlatformPkg/Drivers/LcdGraphicsOutputDxe/HdLcd.c b/ArmPlatformPkg/Drivers/LcdGraphicsOutputDxe/HdLcd.c
index c9baa9822..9186912df 100644
--- a/ArmPlatformPkg/Drivers/LcdGraphicsOutputDxe/HdLcd.c
+++ b/ArmPlatformPkg/Drivers/LcdGraphicsOutputDxe/HdLcd.c
@@ -120,6 +120,6 @@ LcdShutdown (
VOID
)
{
- // Nothing to do in terms of hardware.
- // We could switch off the monitor display if required
+ // Disable the controller
+ MmioWrite32 (HDLCD_REG_COMMAND, HDLCD_DISABLE);
}
diff --git a/ArmPlatformPkg/Drivers/LcdGraphicsOutputDxe/HdLcdGraphicsOutputDxe.inf b/ArmPlatformPkg/Drivers/LcdGraphicsOutputDxe/HdLcdGraphicsOutputDxe.inf
index ac61bf75e..8de4752b7 100644
--- a/ArmPlatformPkg/Drivers/LcdGraphicsOutputDxe/HdLcdGraphicsOutputDxe.inf
+++ b/ArmPlatformPkg/Drivers/LcdGraphicsOutputDxe/HdLcdGraphicsOutputDxe.inf
@@ -56,5 +56,8 @@
[FixedPcd]
gArmPlatformTokenSpaceGuid.PcdArmHdLcdBase
+[FeaturePcd]
+ gArmPlatformTokenSpaceGuid.PcdGopDisableOnExitBootServices
+
[Depex]
gEfiCpuArchProtocolGuid
diff --git a/ArmPlatformPkg/Drivers/LcdGraphicsOutputDxe/LcdGraphicsOutputBlt.c b/ArmPlatformPkg/Drivers/LcdGraphicsOutputDxe/LcdGraphicsOutputBlt.c
index ef85e7125..798f82819 100644
--- a/ArmPlatformPkg/Drivers/LcdGraphicsOutputDxe/LcdGraphicsOutputBlt.c
+++ b/ArmPlatformPkg/Drivers/LcdGraphicsOutputDxe/LcdGraphicsOutputBlt.c
@@ -301,7 +301,7 @@ BltVideoFill (
DestinationAddr = (VOID *)((UINT32 *)FrameBufferBase + DestinationLine * HorizontalResolution + DestinationX);
// Fill the entire line
- SetMemN( DestinationAddr, WidthInBytes, *((UINT32 *)EfiSourcePixel));
+ SetMem32 (DestinationAddr, WidthInBytes, *((UINT32 *)EfiSourcePixel));
}
break;
diff --git a/ArmPlatformPkg/Drivers/LcdGraphicsOutputDxe/LcdGraphicsOutputDxe.c b/ArmPlatformPkg/Drivers/LcdGraphicsOutputDxe/LcdGraphicsOutputDxe.c
index 34a56b3d8..b42336446 100644
--- a/ArmPlatformPkg/Drivers/LcdGraphicsOutputDxe/LcdGraphicsOutputDxe.c
+++ b/ArmPlatformPkg/Drivers/LcdGraphicsOutputDxe/LcdGraphicsOutputDxe.c
@@ -133,7 +133,6 @@ InitializeDisplay (
// Setup all the relevant mode information
Instance->Gop.Mode->SizeOfInfo = sizeof(EFI_GRAPHICS_OUTPUT_MODE_INFORMATION);
Instance->Gop.Mode->FrameBufferBase = VramBaseAddress;
- Instance->Gop.Mode->FrameBufferSize = VramSize;
// Set the flag before changing the mode, to avoid infinite loops
mDisplayInitialized = TRUE;
@@ -225,7 +224,13 @@ LcdGraphicsExitBootServicesEvent (
IN VOID *Context
)
{
- //TODO: Implement me
+ // By default, this PCD is FALSE. But if a platform starts a predefined OS that
+ // does not use a framebuffer then we might want to disable the display controller
+ // to avoid to display corrupted information on the screen.
+ if (FeaturePcdGet (PcdGopDisableOnExitBootServices)) {
+ // Turn-off the Display controller
+ LcdShutdown ();
+ }
}
/***************************************
@@ -291,7 +296,8 @@ LcdGraphicsSetMode (
{
EFI_STATUS Status = EFI_SUCCESS;
EFI_GRAPHICS_OUTPUT_BLT_PIXEL FillColour;
- LCD_INSTANCE* Instance;
+ LCD_INSTANCE* Instance;
+ LCD_BPP Bpp;
Instance = LCD_INSTANCE_FROM_GOP_THIS (This);
@@ -320,6 +326,14 @@ LcdGraphicsSetMode (
// Update the UEFI mode information
This->Mode->Mode = ModeNumber;
LcdPlatformQueryMode (ModeNumber,&Instance->ModeInfo);
+ Status = LcdPlatformGetBpp(ModeNumber, &Bpp);
+ if (EFI_ERROR(Status)) {
+ DEBUG ((DEBUG_ERROR, "LcdGraphicsSetMode: ERROR - Couldn't get bytes per pixel, status: %r\n", Status));
+ goto EXIT;
+ }
+ This->Mode->FrameBufferSize = Instance->ModeInfo.VerticalResolution
+ * Instance->ModeInfo.PixelsPerScanLine
+ * GetBytesPerPixel(Bpp);
// Set the hardware to the new mode
Status = LcdSetMode (ModeNumber);
diff --git a/ArmPlatformPkg/Drivers/LcdGraphicsOutputDxe/PL111Lcd.c b/ArmPlatformPkg/Drivers/LcdGraphicsOutputDxe/PL111Lcd.c
index a955acb4d..ad841cd8d 100644
--- a/ArmPlatformPkg/Drivers/LcdGraphicsOutputDxe/PL111Lcd.c
+++ b/ArmPlatformPkg/Drivers/LcdGraphicsOutputDxe/PL111Lcd.c
@@ -99,8 +99,6 @@ LcdShutdown (
VOID
)
{
- // Nothing to do in terms of hardware.
- // We could switch off the monitor display if required
-
- //TODO: ImplementMe
+ // Disable the controller
+ MmioAnd32 (PL111_REG_LCD_CONTROL, ~PL111_CTRL_LCD_EN);
}
diff --git a/ArmPlatformPkg/Drivers/LcdGraphicsOutputDxe/PL111LcdGraphicsOutputDxe.inf b/ArmPlatformPkg/Drivers/LcdGraphicsOutputDxe/PL111LcdGraphicsOutputDxe.inf
index 5387e53c4..27f00617e 100644
--- a/ArmPlatformPkg/Drivers/LcdGraphicsOutputDxe/PL111LcdGraphicsOutputDxe.inf
+++ b/ArmPlatformPkg/Drivers/LcdGraphicsOutputDxe/PL111LcdGraphicsOutputDxe.inf
@@ -52,5 +52,8 @@
[FixedPcd]
gArmPlatformTokenSpaceGuid.PcdPL111LcdBase
+[FeaturePcd]
+ gArmPlatformTokenSpaceGuid.PcdGopDisableOnExitBootServices
+
[Depex]
gEfiCpuArchProtocolGuid
diff --git a/ArmPlatformPkg/Drivers/NorFlashDxe/NorFlashFvbDxe.c b/ArmPlatformPkg/Drivers/NorFlashDxe/NorFlashFvbDxe.c
index ab6304ba1..4b56f2a40 100644
--- a/ArmPlatformPkg/Drivers/NorFlashDxe/NorFlashFvbDxe.c
+++ b/ArmPlatformPkg/Drivers/NorFlashDxe/NorFlashFvbDxe.c
@@ -608,7 +608,7 @@ FvbWrite (
CopyMem((BlockBuffer + Offset), Buffer, *NumBytes);
// Write the modified buffer back to the NorFlash
- Status = NorFlashWriteBlocks (Instance, Instance->StartLba + Lba, BlockSize, BlockBuffer);
+ TempStatus = NorFlashWriteBlocks (Instance, Instance->StartLba + Lba, BlockSize, BlockBuffer);
if (EFI_ERROR (TempStatus)) {
// Return one of the pre-approved error statuses
Status = EFI_DEVICE_ERROR;
diff --git a/ArmPlatformPkg/Drivers/PL180MciDxe/PL180Mci.c b/ArmPlatformPkg/Drivers/PL180MciDxe/PL180Mci.c
index db8b29fac..f7a4d4431 100644
--- a/ArmPlatformPkg/Drivers/PL180MciDxe/PL180Mci.c
+++ b/ArmPlatformPkg/Drivers/PL180MciDxe/PL180Mci.c
@@ -336,7 +336,7 @@ MciWriteBlockData (
Loop++;
MmioWrite32(MCI_FIFO_REG, Buffer[Loop]);
Loop++;
- } else if ((Status & MCI_STATUS_CMD_TXFIFOEMPTY)) {
+ } else if (!(Status & MCI_STATUS_CMD_TXFIFOFULL)) {
MmioWrite32(MCI_FIFO_REG, Buffer[Loop]);
Loop++;
} else {
diff --git a/ArmPlatformPkg/Library/PL031RealTimeClockLib/PL031RealTimeClockLib.c b/ArmPlatformPkg/Library/PL031RealTimeClockLib/PL031RealTimeClockLib.c
index b7dba087f..980f809b2 100644
--- a/ArmPlatformPkg/Library/PL031RealTimeClockLib/PL031RealTimeClockLib.c
+++ b/ArmPlatformPkg/Library/PL031RealTimeClockLib/PL031RealTimeClockLib.c
@@ -181,7 +181,7 @@ EfiTimeToEpoch (
JulianDate = Time->Day + ((153*m + 2)/5) + (365*y) + (y/4) - (y/100) + (y/400) - 32045;
- ASSERT(JulianDate > EPOCH_JULIAN_DATE);
+ ASSERT (JulianDate >= EPOCH_JULIAN_DATE);
EpochDays = JulianDate - EPOCH_JULIAN_DATE;
EpochSeconds = (EpochDays * SEC_PER_DAY) + ((UINTN)Time->Hour * SEC_PER_HOUR) + (Time->Minute * SEC_PER_MIN) + Time->Second;
@@ -420,16 +420,9 @@ LibSetTime (
EFI_STATUS Status;
UINTN EpochSeconds;
- // Because the PL031 is a 32-bit counter counting seconds,
- // the maximum time span is just over 136 years.
- // Time is stored in Unix Epoch format, so it starts in 1970,
- // Therefore it can not exceed the year 2106.
- // This is not a problem for UEFI, as the current spec limits the years
- // to the range 1998 .. 2011
-
- // Check the input parameters' range.
- if ((Time->Year < 1998) ||
- (Time->Year > 2099) ||
+ // Check the input parameters are within the range specified by UEFI
+ if ((Time->Year < 1900) ||
+ (Time->Year > 9999) ||
(Time->Month < 1 ) ||
(Time->Month > 12 ) ||
(!DayValid (Time) ) ||
@@ -444,6 +437,15 @@ LibSetTime (
goto EXIT;
}
+ // Because the PL031 is a 32-bit counter counting seconds,
+ // the maximum time span is just over 136 years.
+ // Time is stored in Unix Epoch format, so it starts in 1970,
+ // Therefore it can not exceed the year 2106.
+ if ((Time->Year < 1970) || (Time->Year >= 2106)) {
+ Status = EFI_UNSUPPORTED;
+ goto EXIT;
+ }
+
// Initialize the hardware if not already done
if (!mPL031Initialized) {
Status = InitializePL031 ();
diff --git a/ArmPlatformPkg/MemoryInitPei/MemoryInitPeiLib.c b/ArmPlatformPkg/MemoryInitPei/MemoryInitPeiLib.c
index 192486ce5..d1bf394c4 100755
--- a/ArmPlatformPkg/MemoryInitPei/MemoryInitPeiLib.c
+++ b/ArmPlatformPkg/MemoryInitPei/MemoryInitPeiLib.c
@@ -101,8 +101,8 @@ MemoryPeim (
PcdGet32 (PcdSystemMemorySize)
);
- SystemMemoryTop = PcdGet32 (PcdSystemMemoryBase) + PcdGet32 (PcdSystemMemorySize);
- FdTop = PcdGet32(PcdFdBaseAddress) + PcdGet32(PcdFdSize);
+ SystemMemoryTop = (EFI_PHYSICAL_ADDRESS)PcdGet32 (PcdSystemMemoryBase) + (EFI_PHYSICAL_ADDRESS)PcdGet32 (PcdSystemMemorySize);
+ FdTop = (EFI_PHYSICAL_ADDRESS)PcdGet32(PcdFdBaseAddress) + (EFI_PHYSICAL_ADDRESS)PcdGet32(PcdFdSize);
// EDK2 does not have the concept of boot firmware copied into DRAM. To avoid the DXE
// core to overwrite this area we must mark the region with the attribute non-present
diff --git a/BaseTools/Bin/Win32/BPDG.exe b/BaseTools/Bin/Win32/BPDG.exe
index 09137b603..1a684bb87 100644
--- a/BaseTools/Bin/Win32/BPDG.exe
+++ b/BaseTools/Bin/Win32/BPDG.exe
Binary files differ
diff --git a/BaseTools/Bin/Win32/BootSectImage.exe b/BaseTools/Bin/Win32/BootSectImage.exe
index a37e779ae..59b0b8458 100755
--- a/BaseTools/Bin/Win32/BootSectImage.exe
+++ b/BaseTools/Bin/Win32/BootSectImage.exe
Binary files differ
diff --git a/BaseTools/Bin/Win32/EfiLdrImage.exe b/BaseTools/Bin/Win32/EfiLdrImage.exe
index 29db3e2f4..c732a7330 100755
--- a/BaseTools/Bin/Win32/EfiLdrImage.exe
+++ b/BaseTools/Bin/Win32/EfiLdrImage.exe
Binary files differ
diff --git a/BaseTools/Bin/Win32/EfiRom.exe b/BaseTools/Bin/Win32/EfiRom.exe
index 6aefa0d41..2e761cc08 100755
--- a/BaseTools/Bin/Win32/EfiRom.exe
+++ b/BaseTools/Bin/Win32/EfiRom.exe
Binary files differ
diff --git a/BaseTools/Bin/Win32/GenBootSector.exe b/BaseTools/Bin/Win32/GenBootSector.exe
index 8bb35ac83..84d67f9b8 100755
--- a/BaseTools/Bin/Win32/GenBootSector.exe
+++ b/BaseTools/Bin/Win32/GenBootSector.exe
Binary files differ
diff --git a/BaseTools/Bin/Win32/GenCrc32.exe b/BaseTools/Bin/Win32/GenCrc32.exe
index a6009cd72..cdefa7589 100755
--- a/BaseTools/Bin/Win32/GenCrc32.exe
+++ b/BaseTools/Bin/Win32/GenCrc32.exe
Binary files differ
diff --git a/BaseTools/Bin/Win32/GenDepex.exe b/BaseTools/Bin/Win32/GenDepex.exe
index 3d05e7613..2d7e20f60 100755
--- a/BaseTools/Bin/Win32/GenDepex.exe
+++ b/BaseTools/Bin/Win32/GenDepex.exe
Binary files differ
diff --git a/BaseTools/Bin/Win32/GenFds.exe b/BaseTools/Bin/Win32/GenFds.exe
index 9bc45a846..6d2a1aa55 100755
--- a/BaseTools/Bin/Win32/GenFds.exe
+++ b/BaseTools/Bin/Win32/GenFds.exe
Binary files differ
diff --git a/BaseTools/Bin/Win32/GenFfs.exe b/BaseTools/Bin/Win32/GenFfs.exe
index 632f7f3bb..b419b0d17 100755
--- a/BaseTools/Bin/Win32/GenFfs.exe
+++ b/BaseTools/Bin/Win32/GenFfs.exe
Binary files differ
diff --git a/BaseTools/Bin/Win32/GenFv.exe b/BaseTools/Bin/Win32/GenFv.exe
index b87331335..c6e3ad656 100755
--- a/BaseTools/Bin/Win32/GenFv.exe
+++ b/BaseTools/Bin/Win32/GenFv.exe
Binary files differ
diff --git a/BaseTools/Bin/Win32/GenFw.exe b/BaseTools/Bin/Win32/GenFw.exe
index d47991f91..8e19c1724 100755
--- a/BaseTools/Bin/Win32/GenFw.exe
+++ b/BaseTools/Bin/Win32/GenFw.exe
Binary files differ
diff --git a/BaseTools/Bin/Win32/GenPage.exe b/BaseTools/Bin/Win32/GenPage.exe
index 50806487c..a2a95bd30 100755
--- a/BaseTools/Bin/Win32/GenPage.exe
+++ b/BaseTools/Bin/Win32/GenPage.exe
Binary files differ
diff --git a/BaseTools/Bin/Win32/GenPatchPcdTable.exe b/BaseTools/Bin/Win32/GenPatchPcdTable.exe
index a3ce036d4..7f7aa5ab6 100755
--- a/BaseTools/Bin/Win32/GenPatchPcdTable.exe
+++ b/BaseTools/Bin/Win32/GenPatchPcdTable.exe
Binary files differ
diff --git a/BaseTools/Bin/Win32/GenSec.exe b/BaseTools/Bin/Win32/GenSec.exe
index a79833599..2cb0c3b81 100755
--- a/BaseTools/Bin/Win32/GenSec.exe
+++ b/BaseTools/Bin/Win32/GenSec.exe
Binary files differ
diff --git a/BaseTools/Bin/Win32/GenVtf.exe b/BaseTools/Bin/Win32/GenVtf.exe
index a248c31f7..7e38d68ba 100755
--- a/BaseTools/Bin/Win32/GenVtf.exe
+++ b/BaseTools/Bin/Win32/GenVtf.exe
Binary files differ
diff --git a/BaseTools/Bin/Win32/LzmaCompress.exe b/BaseTools/Bin/Win32/LzmaCompress.exe
index 456d67326..9838c0e9b 100755
--- a/BaseTools/Bin/Win32/LzmaCompress.exe
+++ b/BaseTools/Bin/Win32/LzmaCompress.exe
Binary files differ
diff --git a/BaseTools/Bin/Win32/PatchPcdValue.exe b/BaseTools/Bin/Win32/PatchPcdValue.exe
index 48b24e22c..142d59a16 100755
--- a/BaseTools/Bin/Win32/PatchPcdValue.exe
+++ b/BaseTools/Bin/Win32/PatchPcdValue.exe
Binary files differ
diff --git a/BaseTools/Bin/Win32/Split.exe b/BaseTools/Bin/Win32/Split.exe
index 00000ac73..254590bbe 100755
--- a/BaseTools/Bin/Win32/Split.exe
+++ b/BaseTools/Bin/Win32/Split.exe
Binary files differ
diff --git a/BaseTools/Bin/Win32/TargetTool.exe b/BaseTools/Bin/Win32/TargetTool.exe
index bdaaf0726..c8c23d5a3 100755
--- a/BaseTools/Bin/Win32/TargetTool.exe
+++ b/BaseTools/Bin/Win32/TargetTool.exe
Binary files differ
diff --git a/BaseTools/Bin/Win32/TianoCompress.exe b/BaseTools/Bin/Win32/TianoCompress.exe
index a65ba046b..cdbe97f85 100755
--- a/BaseTools/Bin/Win32/TianoCompress.exe
+++ b/BaseTools/Bin/Win32/TianoCompress.exe
Binary files differ
diff --git a/BaseTools/Bin/Win32/Trim.exe b/BaseTools/Bin/Win32/Trim.exe
index 44edbab30..056581b00 100755
--- a/BaseTools/Bin/Win32/Trim.exe
+++ b/BaseTools/Bin/Win32/Trim.exe
Binary files differ
diff --git a/BaseTools/Bin/Win32/UPT.exe b/BaseTools/Bin/Win32/UPT.exe
index a7060c744..3101afd61 100644
--- a/BaseTools/Bin/Win32/UPT.exe
+++ b/BaseTools/Bin/Win32/UPT.exe
Binary files differ
diff --git a/BaseTools/Bin/Win32/VfrCompile.exe b/BaseTools/Bin/Win32/VfrCompile.exe
index 20e1b43c9..1c1ca78f7 100755
--- a/BaseTools/Bin/Win32/VfrCompile.exe
+++ b/BaseTools/Bin/Win32/VfrCompile.exe
Binary files differ
diff --git a/BaseTools/Bin/Win32/VolInfo.exe b/BaseTools/Bin/Win32/VolInfo.exe
index 593784de3..c042d9222 100755
--- a/BaseTools/Bin/Win32/VolInfo.exe
+++ b/BaseTools/Bin/Win32/VolInfo.exe
Binary files differ
diff --git a/BaseTools/Bin/Win32/build.exe b/BaseTools/Bin/Win32/build.exe
index 2b74c9948..3c03283bd 100755
--- a/BaseTools/Bin/Win32/build.exe
+++ b/BaseTools/Bin/Win32/build.exe
Binary files differ
diff --git a/BaseTools/Bin/Win32/python27.dll b/BaseTools/Bin/Win32/python27.dll
index 436f8d203..436f8d203 100644..100755
--- a/BaseTools/Bin/Win32/python27.dll
+++ b/BaseTools/Bin/Win32/python27.dll
Binary files differ
diff --git a/BaseTools/Conf/tools_def.template b/BaseTools/Conf/tools_def.template
index 9824185d4..ecfb55777 100644
--- a/BaseTools/Conf/tools_def.template
+++ b/BaseTools/Conf/tools_def.template
@@ -5625,8 +5625,8 @@ RELEASE_ARMGCC_AARCH64_CC_FLAGS = $(ARCHCC_FLAGS) $(PLATFORM_FLAGS) DEF(GCC_AARC
*_ARMLINUXGCC_*_ASL_FLAGS = DEF(IASL_FLAGS)
*_ARMLINUXGCC_*_ASL_OUTFLAGS = DEF(IASL_OUTFLAGS)
*_ARMLINUXGCC_*_ASLPP_FLAGS = -x c -E -P
-*_ARMLINUXGCC_*_ASLCC_FLAGS = -x c
-*_ARMLINUXGCC_*_ASLDLINK_FLAGS = DEF(GCC_DLINK_FLAGS_COMMON) --entry _ReferenceAcpiTable
+*_ARMLINUXGCC_*_ASLCC_FLAGS = -x c -Dmain=ReferenceAcpiTable
+*_ARMLINUXGCC_*_ASLDLINK_FLAGS = -nostdlib --entry _ReferenceAcpiTable --emit-relocs
##################
# ARM definitions
diff --git a/BaseTools/Source/C/Include/Common/BuildVersion.h b/BaseTools/Source/C/Include/Common/BuildVersion.h
index 764bebfa9..f524cefc9 100644
--- a/BaseTools/Source/C/Include/Common/BuildVersion.h
+++ b/BaseTools/Source/C/Include/Common/BuildVersion.h
@@ -14,4 +14,4 @@
**/
-#define __BUILD_VERSION ""
+#define __BUILD_VERSION "Build 2601"
diff --git a/BaseTools/Source/C/Include/Common/UefiInternalFormRepresentation.h b/BaseTools/Source/C/Include/Common/UefiInternalFormRepresentation.h
index 3cd22d134..ea5f211e9 100644
--- a/BaseTools/Source/C/Include/Common/UefiInternalFormRepresentation.h
+++ b/BaseTools/Source/C/Include/Common/UefiInternalFormRepresentation.h
@@ -3,7 +3,7 @@
IFR is primarily consumed by the EFI presentation engine, and produced by EFI
internal application and drivers as well as all add-in card option-ROM drivers
- Copyright (c) 2006 - 2012, Intel Corporation. All rights reserved.<BR>
+ Copyright (c) 2006 - 2013, 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
@@ -691,6 +691,7 @@ typedef union {
#define EFI_IFR_SECURITY_OP 0x60
#define EFI_IFR_MODAL_TAG_OP 0x61
#define EFI_IFR_REFRESH_ID_OP 0x62
+#define EFI_IFR_WARNING_IF_OP 0x63
typedef struct _EFI_IFR_OP_HEADER {
@@ -1015,6 +1016,12 @@ typedef struct _EFI_IFR_NO_SUBMIT_IF {
EFI_STRING_ID Error;
} EFI_IFR_NO_SUBMIT_IF;
+typedef struct _EFI_IFR_WARNING_IF {
+ EFI_IFR_OP_HEADER Header;
+ EFI_STRING_ID Warning;
+ UINT8 TimeOut;
+} EFI_IFR_WARNING_IF;
+
typedef struct _EFI_IFR_REFRESH {
EFI_IFR_OP_HEADER Header;
UINT8 RefreshInterval;
diff --git a/BaseTools/Source/C/VfrCompile/VfrFormPkg.cpp b/BaseTools/Source/C/VfrCompile/VfrFormPkg.cpp
index 7cadf0f42..363ca82a2 100644
--- a/BaseTools/Source/C/VfrCompile/VfrFormPkg.cpp
+++ b/BaseTools/Source/C/VfrCompile/VfrFormPkg.cpp
@@ -1673,6 +1673,7 @@ static struct {
{ sizeof (EFI_IFR_SECURITY), 0 }, // EFI_IFR_SECURITY_OP - 0x60
{ sizeof (EFI_IFR_MODAL_TAG), 0}, // EFI_IFR_MODAL_TAG_OP - 0x61
{ sizeof (EFI_IFR_REFRESH_ID), 0}, // EFI_IFR_REFRESH_ID_OP - 0x62
+ { sizeof (EFI_IFR_WARNING_IF), 1}, // EFI_IFR_WARNING_IF_OP - 0x63
};
#ifdef CIFROBJ_DEUBG
@@ -1695,7 +1696,7 @@ static struct {
"EFI_IFR_STRING_REF1","EFI_IFR_STRING_REF2", "EFI_IFR_CONDITIONAL", "EFI_IFR_QUESTION_REF3", "EFI_IFR_ZERO", "EFI_IFR_ONE",
"EFI_IFR_ONES", "EFI_IFR_UNDEFINED", "EFI_IFR_LENGTH", "EFI_IFR_DUP", "EFI_IFR_THIS", "EFI_IFR_SPAN",
"EFI_IFR_VALUE", "EFI_IFR_DEFAULT", "EFI_IFR_DEFAULTSTORE", "EFI_IFR_FORM_MAP", "EFI_IFR_CATENATE", "EFI_IFR_GUID",
- "EFI_IFR_SECURITY", "EFI_IFR_MODAL_TAG", "EFI_IFR_REFRESH_ID",
+ "EFI_IFR_SECURITY", "EFI_IFR_MODAL_TAG", "EFI_IFR_REFRESH_ID", "EFI_IFR_WARNING_IF",
};
VOID
diff --git a/BaseTools/Source/C/VfrCompile/VfrFormPkg.h b/BaseTools/Source/C/VfrCompile/VfrFormPkg.h
index 614471060..25280def9 100644
--- a/BaseTools/Source/C/VfrCompile/VfrFormPkg.h
+++ b/BaseTools/Source/C/VfrCompile/VfrFormPkg.h
@@ -1612,6 +1612,26 @@ public:
}
};
+class CIfrWarningIf : public CIfrObj, public CIfrOpHeader {
+private:
+ EFI_IFR_WARNING_IF *mWarningIf;
+
+public:
+ CIfrWarningIf () : CIfrObj (EFI_IFR_WARNING_IF_OP, (CHAR8 **)&mWarningIf),
+ CIfrOpHeader (EFI_IFR_WARNING_IF_OP, &mWarningIf->Header) {
+ mWarningIf->Warning = EFI_STRING_ID_INVALID;
+ mWarningIf->TimeOut = 0;
+ }
+
+ VOID SetWarning (IN EFI_STRING_ID Warning) {
+ mWarningIf->Warning = Warning;
+ }
+
+ VOID SetTimeOut (IN UINT8 TimeOut) {
+ mWarningIf->TimeOut = TimeOut;
+ }
+};
+
class CIfrNoSubmitIf : public CIfrObj, public CIfrOpHeader {
private:
EFI_IFR_NO_SUBMIT_IF *mNoSubmitIf;
diff --git a/BaseTools/Source/C/VfrCompile/VfrSyntax.g b/BaseTools/Source/C/VfrCompile/VfrSyntax.g
index 253834508..61b68f5fb 100644
--- a/BaseTools/Source/C/VfrCompile/VfrSyntax.g
+++ b/BaseTools/Source/C/VfrCompile/VfrSyntax.g
@@ -184,6 +184,7 @@ VfrParserStart (
#token Goto("goto") "goto"
#token FormSetGuid("formsetguid") "formsetguid"
#token InconsistentIf("inconsistentif") "inconsistentif"
+#token WarningIf("warningif") "warningif"
#token NoSubmitIf("nosubmitif") "nosubmitif"
#token EndIf("endif") "endif"
#token Key("key") "key"
@@ -2627,7 +2628,8 @@ vfrStatementQuestionTag :
vfrStatementRefresh |
vfrStatementVarstoreDevice |
vfrStatementExtension |
- vfrStatementRefreshEvent
+ vfrStatementRefreshEvent |
+ vfrStatementWarningIf
;
vfrStatementQuestionTagList :
@@ -2825,6 +2827,15 @@ vfrStatementNoSubmitIf :
E:EndIf << CRT_END_OP (E); >>
;
+vfrStatementWarningIf :
+ << CIfrWarningIf WIObj; >>
+ L:WarningIf << WIObj.SetLineNo(L->getLine()); >>
+ Prompt "=" "STRING_TOKEN" "\(" S:Number "\)" "," << WIObj.SetWarning (_STOSID(S->getText())); >>
+ {Timeout "=" T:Number "," << WIObj.SetTimeOut (_STOU8(T->getText())); >>}
+ vfrStatementExpression[0]
+ E:EndIf << CRT_END_OP (E); >>
+ ;
+
vfrStatementDisableIfQuest :
<<
CIfrDisableIf DIObj;
diff --git a/BaseTools/Source/Python/Common/BuildVersion.py b/BaseTools/Source/Python/Common/BuildVersion.py
index 7414d30f4..25546cdfe 100644
--- a/BaseTools/Source/Python/Common/BuildVersion.py
+++ b/BaseTools/Source/Python/Common/BuildVersion.py
@@ -13,4 +13,4 @@
# WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
#
-gBUILD_VERSION = ""
+gBUILD_VERSION = "Build 2601"
diff --git a/BaseTools/Source/Python/UPT/BuildVersion.py b/BaseTools/Source/Python/UPT/BuildVersion.py
index edd469675..fa6c26aa7 100644
--- a/BaseTools/Source/Python/UPT/BuildVersion.py
+++ b/BaseTools/Source/Python/UPT/BuildVersion.py
@@ -17,4 +17,4 @@
Build version information
'''
-gBUILD_VERSION = ""
+gBUILD_VERSION = "Build 2601"
diff --git a/BaseTools/Source/Python/Workspace/MetaFileParser.py b/BaseTools/Source/Python/Workspace/MetaFileParser.py
index b2e98633a..34000b5e8 100644
--- a/BaseTools/Source/Python/Workspace/MetaFileParser.py
+++ b/BaseTools/Source/Python/Workspace/MetaFileParser.py
@@ -827,6 +827,7 @@ class DscParser(MetaFileParser):
except:
EdkLogger.error("Parser", FILE_READ_FAILURE, ExtraData=self.MetaFile)
+ OwnerId = {}
for Index in range(0, len(Content)):
Line = CleanString(Content[Index])
# skip empty line
@@ -847,6 +848,7 @@ class DscParser(MetaFileParser):
self._SubsectionType = MODEL_UNKNOWN
self._SubsectionName = ''
self._Owner[-1] = -1
+ OwnerId = {}
continue
# subsection header
elif Line[0] == TAB_OPTION_START and Line[-1] == TAB_OPTION_END:
@@ -871,6 +873,9 @@ class DscParser(MetaFileParser):
# LineBegin=-1, ColumnBegin=-1, LineEnd=-1, ColumnEnd=-1, Enabled=-1
#
for Arch, ModuleType in self._Scope:
+ Owner = self._Owner[-1]
+ if self._SubsectionType != MODEL_UNKNOWN:
+ Owner = OwnerId[Arch]
self._LastItem = self._Store(
self._ItemType,
self._ValueList[0],
@@ -878,7 +883,7 @@ class DscParser(MetaFileParser):
self._ValueList[2],
Arch,
ModuleType,
- self._Owner[-1],
+ Owner,
self._From,
self._LineIndex + 1,
- 1,
@@ -886,6 +891,8 @@ class DscParser(MetaFileParser):
- 1,
self._Enabled
)
+ if self._SubsectionType == MODEL_UNKNOWN and self._InSubsection:
+ OwnerId[Arch] = self._LastItem
if self._DirectiveStack:
Type, Line, Text = self._DirectiveStack[-1]
@@ -1040,6 +1047,11 @@ class DscParser(MetaFileParser):
ExtraData=self._CurrentLine + " (<TokenSpaceGuidCName>.<TokenCName>|<PcdValue>)",
File=self.MetaFile, Line=self._LineIndex + 1)
if self._ValueList[2] == '':
+ #
+ # The PCD values are optional for FIXEDATBUILD and PATCHABLEINMODULE
+ #
+ if self._SectionType in (MODEL_PCD_FIXED_AT_BUILD, MODEL_PCD_PATCHABLE_IN_MODULE):
+ return
EdkLogger.error('Parser', FORMAT_INVALID, "No PCD value given",
ExtraData=self._CurrentLine + " (<TokenSpaceGuidCName>.<TokenCName>|<PcdValue>)",
File=self.MetaFile, Line=self._LineIndex + 1)
diff --git a/EdkShellBinPkg/FullShell/AArch64/Shell_Full.efi b/EdkShellBinPkg/FullShell/AArch64/Shell_Full.efi
new file mode 100755
index 000000000..cbd19a94b
--- /dev/null
+++ b/EdkShellBinPkg/FullShell/AArch64/Shell_Full.efi
Binary files differ
diff --git a/EdkShellBinPkg/FullShell/Arm/Shell_Full.efi b/EdkShellBinPkg/FullShell/Arm/Shell_Full.efi
index bdbe3e23a..fe91f26a0 100755
--- a/EdkShellBinPkg/FullShell/Arm/Shell_Full.efi
+++ b/EdkShellBinPkg/FullShell/Arm/Shell_Full.efi
Binary files differ
diff --git a/EdkShellBinPkg/FullShell/FullShell.inf b/EdkShellBinPkg/FullShell/FullShell.inf
index d147ee95c..f4e2548e2 100644
--- a/EdkShellBinPkg/FullShell/FullShell.inf
+++ b/EdkShellBinPkg/FullShell/FullShell.inf
@@ -26,7 +26,7 @@
#
# The following information is for reference only and not required by the build tools.
#
-# VALID_ARCHITECTURES = IA32 X64 IPF
+# VALID_ARCHITECTURES = IA32 X64 IPF ARM AARCH64
#
[Binaries.Ia32]
@@ -41,3 +41,5 @@
[Binaries.ARM]
PE32|Arm/Shell_Full.efi|*
+[Binaries.AARCH64]
+ PE32|AArch64/Shell_Full.efi|*
diff --git a/EdkShellBinPkg/ReadMe.txt b/EdkShellBinPkg/ReadMe.txt
index 29ba4d7a7..41424dd59 100644
--- a/EdkShellBinPkg/ReadMe.txt
+++ b/EdkShellBinPkg/ReadMe.txt
@@ -12,5 +12,5 @@ The following steps can help to re-generate these binaries for customization:
To generate them, execute: "build -a IA32 -a X64 -a IPF -p EdkShellPkg\EdkShellPkg.dsc -m Shell\XXX\*.inf -b RELEASE". XXX means the corresponding module name.
-The Arm binaries of EdkShellBinPkg are generated with EFI shell project (svn r61) and build with Edk Compatibility & BaseTools Package (r13646).
+The Arm binaries of EdkShellBinPkg are generated with EFI shell project (svn r64) and build with Edk Compatibility & BaseTools Package (r14706).
Build Instructions are available on this page http://sourceforge.net/apps/mediawiki/tianocore/index.php?title=ArmPkg/Binaries. \ No newline at end of file
diff --git a/EdkShellPkg/EdkShellPkg.dsc b/EdkShellPkg/EdkShellPkg.dsc
index dcfaa1310..6127919a0 100644
--- a/EdkShellPkg/EdkShellPkg.dsc
+++ b/EdkShellPkg/EdkShellPkg.dsc
@@ -21,7 +21,7 @@
PLATFORM_VERSION = 1.04
DSC_SPECIFICATION = 0x00010005
OUTPUT_DIRECTORY = Build/EdkShellPkg
- SUPPORTED_ARCHITECTURES = IA32|IPF|X64|ARM
+ SUPPORTED_ARCHITECTURES = IA32|IPF|X64|ARM|AARCH64
BUILD_TARGETS = DEBUG|RELEASE
SKUID_IDENTIFIER = DEFAULT
#
@@ -86,7 +86,7 @@ DEFINE GCC_MACRO = -DEFI_SPECIFICATION_VERSION=0x0002000A -DPI_S
[Libraries.IPF]
EdkCompatibilityPkg/Foundation/Cpu/Itanium/CpuIa64Lib/CpuIA64Lib.inf
-[Libraries.ARM]
+[Libraries.ARM, Libraries.AARCH64]
EdkCompatibilityPkg/Foundation/Library/CompilerStub/CompilerStubLib.inf
ArmPkg/Library/CompilerIntrinsicsLib/CompilerIntrinsicsLib.inf
@@ -254,5 +254,7 @@ DEFINE GCC_MACRO = -DEFI_SPECIFICATION_VERSION=0x0002000A -DPI_S
RVCT:*_*_ARM_APP_FLAGS = -DEFIARM $(GCC_MACRO)
RVCT:*_*_ARM_PP_FLAGS = -DEFIARM $(GCC_MACRO)
-
-
+ GCC:*_*_AARCH64_CC_FLAGS = -DEFIAARCH64 $(GCC_MACRO)
+ GCC:*_*_AARCH64_VFRPP_FLAGS = -DEFIAARCH64 $(GCC_MACRO)
+ GCC:*_*_AARCH64_APP_FLAGS = -DEFIAARCH64 $(GCC_MACRO)
+ GCC:*_*_AARCH64_PP_FLAGS = -DEFIAARCH64 $(GCC_MACRO)
diff --git a/EdkShellPkg/ReadMe.txt b/EdkShellPkg/ReadMe.txt
index c05ec8c36..b6ce6f5aa 100644
--- a/EdkShellPkg/ReadMe.txt
+++ b/EdkShellPkg/ReadMe.txt
@@ -15,8 +15,8 @@ This is EDK style package and the following steps can help to build the package:
To use this file, execute the following command under workspace to build EDK Shell source:
build -a IA32 -a X64 -a IPF -p EdkShellPkg\EdkShellPkg.dsc
-4. If you need to compile for GCC or ARM you will need to apply ShellR61.patch.
- cd $(WORKSPACE)/Shell and execute patch -p1 < $(WORKSPACE)/EdkShellPkg/ShellR61.patch.
+4. If you need to compile for GCC or ARM you will need to apply ShellR64.patch.
+ cd $(WORKSPACE)/Shell and execute patch -p0 < $(WORKSPACE)/EdkShellPkg/ShellR64.patch.
If you are using a case sensative file system there are a few case bugs that patch
would not fix. Just fix the case of the file to match its usage and you should be
able to compile.
diff --git a/EdkShellPkg/ShellR61.patch b/EdkShellPkg/ShellR64.patch
index 8fb08413b..066444ae4 100644
--- a/EdkShellPkg/ShellR61.patch
+++ b/EdkShellPkg/ShellR64.patch
@@ -1,75 +1,32 @@
-diff --git a/DeviceTree/devicetree.c b/DeviceTree/devicetree.c
-index 147e2cb..8b0645d 100644
---- a/DeviceTree/devicetree.c
-+++ b/DeviceTree/devicetree.c
-@@ -36,7 +36,7 @@ extern UINT8 STRING_ARRAY_NAME[];
- //
- // Global Variables
- //
--EFI_HII_HANDLE HiiHandle;
-+STATIC EFI_HII_HANDLE HiiHandle;
- EFI_GUID EfiDevicetreeGuid = EFI_DEVICETREE_GUID;
- SHELL_VAR_CHECK_ITEM DevicetreeCheckList[] = {
- {
-diff --git a/DeviceTree/devicetree.inf b/DeviceTree/devicetree.inf
-index a86a1a0..2132c62 100644
---- a/DeviceTree/devicetree.inf
-+++ b/DeviceTree/devicetree.inf
-@@ -40,24 +40,24 @@ COMPONENT_TYPE = APPLICATION
-
-
- [sources.common]
-- ..\ShCommonStrings.uni
-+ ../ShCommonStrings.uni
- DevicetreeStrings.uni
- devicetree.c
- devicetree.h
-
- [includes.common]
- .
-- ..\Inc
-- ..\Library
-- $(EDK_SOURCE)\Foundation
-- $(EDK_SOURCE)\Foundation\Include
-- $(EDK_SOURCE)\Foundation\Include\IndustryStandard
-- $(EDK_SOURCE)\Foundation\Efi
-- $(EDK_SOURCE)\Foundation\Efi\Include
-- $(EDK_SOURCE)\Foundation\FrameWork
-- $(EDK_SOURCE)\Foundation\FrameWork\Include
-- $(EDK_SOURCE)\Foundation\Core\Dxe
-- $(DEST_DIR)\
-+ ../Inc
-+ ../Library
-+ $(EDK_SOURCE)/Foundation
-+ $(EDK_SOURCE)/Foundation/Include
-+ $(EDK_SOURCE)/Foundation/Include/IndustryStandard
-+ $(EDK_SOURCE)/Foundation/Efi
-+ $(EDK_SOURCE)/Foundation/Efi/Include
-+ $(EDK_SOURCE)/Foundation/FrameWork
-+ $(EDK_SOURCE)/Foundation/FrameWork/Include
-+ $(EDK_SOURCE)/Foundation/Core/Dxe
-+ $(DEST_DIR./
+Index: EfiCompress/Compress.h
+===================================================================
+--- EfiCompress/Compress.h (revision 64)
++++ EfiCompress/Compress.h (working copy)
+@@ -57,4 +57,4 @@
- [libraries.common]
- EfiShellLib
-diff --git a/EfiCompress/compress.c b/EfiCompress/compress.c
-index e21c1f6..012bbef 100644
---- a/EfiCompress/compress.c
-+++ b/EfiCompress/compress.c
-@@ -262,7 +262,7 @@ STATIC UINT32 mBufSiz = 0, mOutputPos, mOutputMask, mSubBitBuf, mCrc;
- STATIC UINT32 mCompSize, mOrigSize;
+ --*/
- STATIC UINT16 *mFreq, *mSortPtr, mLenCnt[17], mLeft[2 * NC - 1], mRight[2 * NC - 1],
-- mCrcTable[UINT8_MAX + 1], mCFreq[2 * NC - 1], mCTable[4096], mCCode[NC],
-+ mCrcTable[UINT8_MAX + 1], mCFreq[2 * NC - 1], mCCode[NC],
- mPFreq[2 * NP - 1], mPTCode[NPT], mTFreq[2 * NT - 1];
+-#endif
+\ No newline at end of file
++#endif
+Index: EfiCompress/CompressMain.c
+===================================================================
+--- EfiCompress/CompressMain.c (revision 64)
++++ EfiCompress/CompressMain.c (working copy)
+@@ -50,7 +50,7 @@
+ NULL,
+ 0,
+ 0,
+- 0
++ (SHELL_VAR_CHECK_FLAG_TYPE)0
+ }
+ };
- STATIC NODE mPos, mMatchPos, mAvail, *mPosition, *mParent, *mPrev, *mNext = NULL;
-diff --git a/EfiCompress/compress.inf b/EfiCompress/compress.inf
-index 2e62fbf..c8cb415 100644
---- a/EfiCompress/compress.inf
-+++ b/EfiCompress/compress.inf
-@@ -25,7 +25,7 @@ FILE_GUID = A6A236DB-F3FB-4f7f-93BC-0AF7DAA583B9
+Index: EfiCompress/compress.inf
+===================================================================
+--- EfiCompress/compress.inf (revision 64)
++++ EfiCompress/compress.inf (working copy)
+@@ -25,7 +25,7 @@
COMPONENT_TYPE = APPLICATION
[sources.common]
@@ -78,7 +35,7 @@ index 2e62fbf..c8cb415 100644
CompressStrings.uni
compressMain.c
compress.c
-@@ -34,17 +34,17 @@ compress.h
+@@ -34,17 +34,17 @@
[includes.common]
.
@@ -107,52 +64,54 @@ index 2e62fbf..c8cb415 100644
[libraries.common]
EfiShellLib
-diff --git a/EfiDecompress/Decompress.c b/EfiDecompress/Decompress.c
-index 918f673..a1490a1 100644
---- a/EfiDecompress/Decompress.c
-+++ b/EfiDecompress/Decompress.c
-@@ -22,7 +22,7 @@ Revision History
- --*/
-
- #include "EfiShellLib.h"
--#include "decompress.h"
-+#include "Decompress.h"
+Index: EfiCompress/compress.c
+===================================================================
+--- EfiCompress/compress.c (revision 64)
++++ EfiCompress/compress.c (working copy)
+@@ -262,7 +262,7 @@
+ STATIC UINT32 mCompSize, mOrigSize;
- extern UINT8 STRING_ARRAY_NAME[];
+ STATIC UINT16 *mFreq, *mSortPtr, mLenCnt[17], mLeft[2 * NC - 1], mRight[2 * NC - 1],
+- mCrcTable[UINT8_MAX + 1], mCFreq[2 * NC - 1], mCTable[4096], mCCode[NC],
++ mCrcTable[UINT8_MAX + 1], mCFreq[2 * NC - 1], mCCode[NC],
+ mPFreq[2 * NP - 1], mPTCode[NPT], mTFreq[2 * NT - 1];
-@@ -31,7 +31,7 @@ extern UINT8 STRING_ARRAY_NAME[];
- //
- #include STRING_DEFINES_FILE
+ STATIC NODE mPos, mMatchPos, mAvail, *mPosition, *mParent, *mPrev, *mNext = NULL;
+Index: load/load.c
+===================================================================
+--- load/load.c (revision 64)
++++ load/load.c (working copy)
+@@ -60,7 +60,7 @@
+ NULL,
+ 0,
+ 0,
+- 0
++ (SHELL_VAR_CHECK_FLAG_TYPE) 0
+ }
+ };
--#include EFI_PROTOCOL_DEFINITION (decompress)
-+#include EFI_PROTOCOL_DEFINITION (Decompress)
+Index: load/load.h
+===================================================================
+--- load/load.h (revision 64)
++++ load/load.h (working copy)
+@@ -33,3 +33,4 @@
+ }
- EFI_HII_HANDLE HiiDecompressHandle;
- EFI_GUID EfiDecompressGuid = EFI_DECOMPRESS_GUID;
-@@ -192,7 +192,7 @@ Returns:
- //
- //
- //
-- Status = LibLocateProtocol (&gEfiDecompressProtocolGuid, &Decompress);
-+ Status = LibLocateProtocol (&gEfiDecompressProtocolGuid, (VOID**)&Decompress);
- if (EFI_ERROR (Status)) {
- PrintToken (STRING_TOKEN (STR_DECOMPRESS_PROTOCOL_NOT_FOUND), HiiDecompressHandle, L"efidecompress");
- Status = EFI_UNSUPPORTED;
-diff --git a/EfiDecompress/Decompress.inf b/EfiDecompress/Decompress.inf
-index f955220..6d1e70c 100644
---- a/EfiDecompress/Decompress.inf
-+++ b/EfiDecompress/Decompress.inf
-@@ -25,7 +25,7 @@ FILE_GUID = D9D42564-071C-4d73-8DB0-43C55C62DC4C
+ #endif
++
+Index: load/load.inf
+===================================================================
+--- load/load.inf (revision 64)
++++ load/load.inf (working copy)
+@@ -39,23 +39,23 @@
COMPONENT_TYPE = APPLICATION
[sources.common]
--..\ShCommonStrings.uni
-+../ShCommonStrings.uni
- DecompressStrings.uni
- decompress.c
- decompress.h
-@@ -33,17 +33,17 @@ decompress.h
-
+- ..\ShCommonStrings.uni
++ ../ShCommonStrings.uni
+ LoadStrings.uni
+ load.c
+
[includes.common]
.
- ..\Inc
@@ -180,902 +139,51 @@ index f955220..6d1e70c 100644
[libraries.common]
EfiShellLib
-diff --git a/IfConfig/IfConfig.c b/IfConfig/IfConfig.c
-index 07cedc2..0e17081 100644
---- a/IfConfig/IfConfig.c
-+++ b/IfConfig/IfConfig.c
-@@ -29,7 +29,7 @@ extern UINT8 STRING_ARRAY_NAME[];
- //
- #define NIC_ITEM_CONFIG_SIZE sizeof (NIC_IP4_CONFIG_INFO) + sizeof (EFI_IP4_ROUTE_TABLE) * 16
-
--EFI_HII_HANDLE HiiHandle;
-+STATIC EFI_HII_HANDLE HiiHandle;
-
- EFI_GUID EfiIfConfigGuid = EFI_IFCONFIG_GUID;
-
-@@ -669,7 +669,7 @@ Returns:
- Status = BS->LocateProtocol (
- &gEfiHiiConfigRoutingProtocolGuid,
- NULL,
-- &mHiiConfigRouting
-+ (VOID**)&mHiiConfigRouting
- );
- if (EFI_ERROR (Status)) {
- return EFI_NOT_FOUND;
-diff --git a/IfConfig/IfConfig.inf b/IfConfig/IfConfig.inf
-index b2e4964..e55dc32 100644
---- a/IfConfig/IfConfig.inf
-+++ b/IfConfig/IfConfig.inf
-@@ -25,7 +25,7 @@ FILE_GUID = 6394CF3D-D3DC-4f69-926D-AF9FFE59F922
- COMPONENT_TYPE = APPLICATION
-
- [sources.common]
-- ..\ShCommonStrings.uni
-+ ../ShCommonStrings.uni
- IfConfigStrings.uni
- IfConfig.c
- IfConfig.h
-@@ -33,25 +33,24 @@ COMPONENT_TYPE = APPLICATION
- ShellNetHelper.h
-
- [includes.common]
-- ..\Inc
-- ..\Library
-- $(EDK_SOURCE)\Foundation\Efi
-- $(EDK_SOURCE)\Foundation
-- $(EDK_SOURCE)\Foundation\Efi\Include
-- $(EDK_SOURCE)\Foundation\Include
-- $(EDK_SOURCE)\Foundation\Include\IndustryStandard
-- $(EDK_SOURCE)\Foundation\FrameWork
-- $(EDK_SOURCE)\Foundation\FrameWork\Include
-- $(EDK_SOURCE)\Foundation\Core\Dxe
-- $(EDK_SOURCE)\Foundation\Library\Dxe\Include
-- $(DEST_DIR)\
-+ ../Inc
-+ ../Library
-+ $(EDK_SOURCE)/Foundation/Efi
-+ $(EDK_SOURCE)/Foundation
-+ $(EDK_SOURCE)/Foundation/Efi/Include
-+ $(EDK_SOURCE)/Foundation/Include
-+ $(EDK_SOURCE)/Foundation/Include/IndustryStandard
-+ $(EDK_SOURCE)/Foundation/FrameWork
-+ $(EDK_SOURCE)/Foundation/FrameWork/Include
-+ $(EDK_SOURCE)/Foundation/Core/Dxe
-+ $(EDK_SOURCE)/Foundation/Library/Dxe/Include
-+ $(DEST_DIR./
-
- [libraries.common]
- EfiShellLib
- EdkProtocolLib
- EfiProtocolLib
- EdkGuidLib
-- EfiDriverLib
-
- [nmake.common]
- C_PROJ_FLAGS = $(C_PROJ_FLAGS)
-diff --git a/IpConfig/IpConfig.c b/IpConfig/IpConfig.c
-index 0c3e4c3..b2154aa 100644
---- a/IpConfig/IpConfig.c
-+++ b/IpConfig/IpConfig.c
-@@ -39,7 +39,7 @@ extern UINT8 STRING_ARRAY_NAME[];
+Index: drvdiag/drvdiag.c
+===================================================================
+--- drvdiag/drvdiag.c (revision 64)
++++ drvdiag/drvdiag.c (working copy)
+@@ -41,7 +41,7 @@
//
// Global Variables
//
-EFI_HII_HANDLE HiiHandle;
+STATIC EFI_HII_HANDLE HiiHandle;
- EFI_GUID EfiIpConfigGuid = EFI_IPCONFIG_GUID;
- SHELL_VAR_CHECK_ITEM IpconfigCheckList[] = {
- {
-diff --git a/IpConfig/IpConfig.inf b/IpConfig/IpConfig.inf
-index bc8271c..46d4f52 100644
---- a/IpConfig/IpConfig.inf
-+++ b/IpConfig/IpConfig.inf
-@@ -25,24 +25,24 @@ FILE_GUID = 1D73AC03-AF05-44b3-B21E-93A174893FA6
- COMPONENT_TYPE = APPLICATION
-
- [sources.common]
-- ..\ShCommonStrings.uni
-+ ../ShCommonStrings.uni
- IpConfigStrings.uni
- IpConfig.c
- IpConfig.h
-
- [includes.common]
- .
-- ..\Inc
-- ..\Library
-- $(EDK_SOURCE)\Foundation
-- $(EDK_SOURCE)\Foundation\Include
-- $(EDK_SOURCE)\Foundation\Include\IndustryStandard
-- $(EDK_SOURCE)\Foundation\Efi
-- $(EDK_SOURCE)\Foundation\Efi\Include
-- $(EDK_SOURCE)\Foundation\FrameWork
-- $(EDK_SOURCE)\Foundation\FrameWork\Include
-- $(EDK_SOURCE)\Foundation\Core\Dxe
-- $(DEST_DIR)\
-+ ../Inc
-+ ../Library
-+ $(EDK_SOURCE)/Foundation
-+ $(EDK_SOURCE)/Foundation/Include
-+ $(EDK_SOURCE)/Foundation/Include/IndustryStandard
-+ $(EDK_SOURCE)/Foundation/Efi
-+ $(EDK_SOURCE)/Foundation/Efi/Include
-+ $(EDK_SOURCE)/Foundation/FrameWork
-+ $(EDK_SOURCE)/Foundation/FrameWork/Include
-+ $(EDK_SOURCE)/Foundation/Core/Dxe
-+ $(DEST_DIR./
-
- [libraries.common]
- EfiShellLib
-diff --git a/Library/Arm/efilibplat.h b/Library/Arm/efilibplat.h
-new file mode 100644
-index 0000000..3b284fe
---- /dev/null
-+++ b/Library/Arm/efilibplat.h
-@@ -0,0 +1,38 @@
-+/*++
-+
-+Copyright (c) 2005, Intel Corporation
-+All rights reserved. This program and the accompanying materials
-+are licensed and made available under the terms and conditions of the BSD License
-+which accompanies this distribution. The full text of the license may be found at
-+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:
-+
-+ efilibplat.h
-+
-+Abstract:
-+
-+ EFI to compile bindings
-+
-+
-+
-+
-+Revision History
-+
-+--*/
-+#ifndef _EFI_LIB_PLAT_H_
-+#define _EFI_LIB_PLAT_H_
-+
-+VOID
-+InitializeLibPlatform (
-+ IN EFI_HANDLE ImageHandle,
-+ IN EFI_SYSTEM_TABLE *SystemTable
-+ );
-+
-+#define MIN_ALIGNMENT_SIZE 4
-+
-+#endif
-+
-diff --git a/Library/CRC.c b/Library/CRC.c
-index ce5387b..ebbdf70 100644
---- a/Library/CRC.c
-+++ b/Library/CRC.c
-@@ -21,7 +21,7 @@ Revision History
-
- --*/
-
--#include "EfiShelllib.h"
-+#include "EfiShellLib.h"
-
- UINT32 CRCTable[256] = {
- 0x00000000,
-diff --git a/Library/CRC.h b/Library/CRC.h
-index 326a5e1..b25a275 100644
---- a/Library/CRC.h
-+++ b/Library/CRC.h
-@@ -53,4 +53,5 @@ CalculateCrc (
- UINTN Size
- );
-
--#endif
-\ No newline at end of file
-+#endif
-+
-diff --git a/Library/ConsistMapping.c b/Library/ConsistMapping.c
-index b70fa06..61eda8b 100644
---- a/Library/ConsistMapping.c
-+++ b/Library/ConsistMapping.c
-@@ -21,7 +21,7 @@ Revision History
-
- --*/
-
--#include "EfiShelllib.h"
-+#include "EfiShellLib.h"
-
- MTD_NAME mMTDName[] = {
+ EFI_GUID EfiDrvdiagGuid = EFI_DRVDIAG_GUID;
+ SHELL_VAR_CHECK_ITEM DrvdiagCheckList[] = {
{
-diff --git a/Library/ConsistMapping.h b/Library/ConsistMapping.h
-index bc8d6f0..2efad28 100644
---- a/Library/ConsistMapping.h
-+++ b/Library/ConsistMapping.h
-@@ -79,4 +79,5 @@ DevicePathConsistMappingCompare (
- IN VOID *Buffer2
- );
-
--#endif
-\ No newline at end of file
-+#endif
-+
-diff --git a/Library/DPath.c b/Library/DPath.c
-index f0974ac..73086d7 100644
---- a/Library/DPath.c
-+++ b/Library/DPath.c
-@@ -20,7 +20,7 @@ Revision History
-
- --*/
-
--#include "EfiShelllib.h"
-+#include "EfiShellLib.h"
-
- EFI_GUID mEfiDevicePathMessagingUartFlowControlGuid = DEVICE_PATH_MESSAGING_UART_FLOW_CONTROL;
-
-@@ -1468,7 +1468,7 @@ Returns:
-
- Status = LibLocateProtocol (
- &gEfiDevicePathToTextProtocolGuid,
-- &DevPathToText
-+ (VOID**)&DevPathToText
- );
- if (!EFI_ERROR (Status)) {
- ToText = DevPathToText->ConvertDevicePathToText (
-@@ -1766,7 +1766,7 @@ Returns:
- Status = BS->HandleProtocol (
- Device,
- Protocol,
-- Interface
-+ (VOID**)Interface
- );
- }
- }
-diff --git a/Library/DPath.h b/Library/DPath.h
-index 68da82b..bb7dd93 100644
---- a/Library/DPath.h
-+++ b/Library/DPath.h
-@@ -24,7 +24,7 @@ Revision History
- #ifndef _D_PATH_H
- #define _D_PATH_H
-
--#define NextStrA(a) ((UINT8 *) (((UINT8 *) (a)) + strlena (a) + 1))
-+#define NextStrA(a) (CHAR8*)((UINT8 *) (((UINT8 *) (a)) + strlena (a) + 1))
-
- #include EFI_GUID_DEFINITION (PcAnsi)
-
-diff --git a/Library/Data.c b/Library/Data.c
-index d2ffe4a..979b3dd 100644
---- a/Library/Data.c
-+++ b/Library/Data.c
-@@ -21,7 +21,7 @@ Revision History
-
- --*/
-
--#include "EfiShelllib.h"
-+#include "EfiShellLib.h"
-
- //
- // ShellLibInitialized - TRUE once InitializeShellLib() is called for the first time
-diff --git a/Library/EfiShellLib.h b/Library/EfiShellLib.h
-index 6243d1d..a174758 100644
---- a/Library/EfiShellLib.h
-+++ b/Library/EfiShellLib.h
-@@ -25,7 +25,7 @@ Revision History
- #define _EFI_SHELL_LIB_INCLUDE_
-
- #include "Tiano.h"
--#include "ShellEnv.h"
-+#include "shellenv.h"
- #include "pci22.h"
-
- #include EFI_ARCH_PROTOCOL_DEFINITION (Bds)
-@@ -51,7 +51,7 @@ Revision History
- #include EFI_GUID_DEFINITION (PrimaryConsoleOutDevice)
- #include EFI_GUID_DEFINITION (PrimaryStandardErrorDevice)
- #include EFI_GUID_DEFINITION (SalSystemTable)
--#include EFI_GUID_DEFINITION (Smbios)
-+#include EFI_GUID_DEFINITION (SmBios)
- #include EFI_GUID_DEFINITION (StandardErrorDevice)
- #include EFI_GUID_DEFINITION (FrameworkDevicePath)
- #include EFI_PROTOCOL_DEFINITION (AbsolutePointer)
-@@ -67,7 +67,7 @@ Revision History
- #include EFI_PROTOCOL_DEFINITION (DebugPort)
- #include EFI_PROTOCOL_DEFINITION (DebugSupport)
- #include EFI_PROTOCOL_DEFINITION (Decompress)
--#include EFI_PROTOCOL_DEFINITION (DeviceIO)
-+#include EFI_PROTOCOL_DEFINITION (DeviceIo)
- #include EFI_PROTOCOL_DEFINITION (DevicePath)
- #include EFI_PROTOCOL_DEFINITION (DevicePathFromText)
- #include EFI_PROTOCOL_DEFINITION (DevicePathToText)
-@@ -111,7 +111,7 @@ Revision History
- #include EFI_PROTOCOL_DEFINITION (PciRootBridgeIo)
- #include EFI_PROTOCOL_DEFINITION (PlatformDriverOverride)
- #include EFI_PROTOCOL_DEFINITION (PxeBaseCode)
--#include EFI_PROTOCOL_DEFINITION (PxeBaseCodeCallback)
-+#include EFI_PROTOCOL_DEFINITION (PxeBaseCodeCallBack)
- #include EFI_PROTOCOL_DEFINITION (ScsiIo)
- #include EFI_PROTOCOL_DEFINITION (ScsiPassThru)
- #include EFI_PROTOCOL_DEFINITION (SectionExtraction)
-@@ -152,7 +152,7 @@ Revision History
- #include EFI_PROTOCOL_DEFINITION (PlatformToDriverConfiguration)
-
- #include "efilibplat.h"
--#include "efipart.h"
-+#include "EfiPart.h"
- #include "ShellDebug.h"
- #include "CRC.h"
- #include "DPath.h"
-diff --git a/Library/EfiShellLib.inf b/Library/EfiShellLib.inf
-index d450f9d..2093115 100644
---- a/Library/EfiShellLib.inf
-+++ b/Library/EfiShellLib.inf
-@@ -45,34 +45,38 @@ COMPONENT_TYPE = LIBRARY
- HiiSupport.c
-
- [sources.ia32]
-- ia32\math.c
-- ia32\initplat.c
-+ IA32/math.c
-+ IA32/initplat.c
-
- [sources.ipf]
-- ipf\math.c
-- ipf\initplat.c
-- ipf\palproc.s
-- ipf\salpal.c
-+ IPF/math.c
-+ IPF/initplat.c
-+ IPF/palproc.s
-+ IPF/salpal.c
-
- [sources.EBC]
-- EBC\math.c
-- EBC\initplat.c
-+ Ebc/math.c
-+ Ebc/initplat.c
-
- [sources.x64]
-- ipf\math.c
-- ia32\initplat.c
-+ IPF/math.c
-+ IA32/initplat.c
-+
-+[sources.ARM]
-+ IPF/math.c
-+ IA32/initplat.c
-
- [includes.common]
- .
-- ..\Inc
-- $(EDK_SOURCE)\Foundation
-- $(EDK_SOURCE)\Foundation\Include
-- $(EDK_SOURCE)\Foundation\Efi
-- $(EDK_SOURCE)\Foundation\Efi\Include
-- $(EDK_SOURCE)\Foundation\FrameWork
-- $(EDK_SOURCE)\Foundation\FrameWork\Include
-- $(EDK_SOURCE)\Foundation\Include\IndustryStandard
-- $(EDK_SOURCE)\Foundation\Core\Dxe
-+ ../Inc
-+ $(EDK_SOURCE)/Foundation
-+ $(EDK_SOURCE)/Foundation/Include
-+ $(EDK_SOURCE)/Foundation/Efi
-+ $(EDK_SOURCE)/Foundation/Efi/Include
-+ $(EDK_SOURCE)/Foundation/FrameWork
-+ $(EDK_SOURCE)/Foundation/FrameWork/Include
-+ $(EDK_SOURCE)/Foundation/Include/IndustryStandard
-+ $(EDK_SOURCE)/Foundation/Core/Dxe
-
- [libraries.common]
- EdkFrameworkProtocolLib
-diff --git a/Library/Event.c b/Library/Event.c
-index 4929e4b..a0cbdc2 100644
---- a/Library/Event.c
-+++ b/Library/Event.c
-@@ -21,7 +21,7 @@ Revision History
-
- --*/
-
--#include "EfiShelllib.h"
-+#include "EfiShellLib.h"
-
- EFI_EVENT
- LibCreateProtocolNotifyEvent (
-diff --git a/Library/Event.h b/Library/Event.h
-index b8df801..5de49b4 100644
---- a/Library/Event.h
-+++ b/Library/Event.h
-@@ -50,4 +50,5 @@ WaitForEventWithTimeout (
- OUT EFI_INPUT_KEY *Key
- );
-
--#endif
-\ No newline at end of file
-+#endif
-+
-diff --git a/Library/FileIO.c b/Library/FileIO.c
-index 40c67d1..8820c52 100644
---- a/Library/FileIO.c
-+++ b/Library/FileIO.c
-@@ -21,7 +21,7 @@ Revision History
-
- --*/
-
--#include "EfiShelllib.h"
-+#include "EfiShellLib.h"
-
- typedef struct _PATH_COMPONENTS {
- CHAR16 *Name;
-@@ -719,7 +719,6 @@ LibSplitFsAndPath (
- IN OUT CHAR16 **Path
- )
- {
-- EFI_STATUS Status;
- CHAR16 *p;
- UINTN Size;
-
-@@ -728,7 +727,6 @@ LibSplitFsAndPath (
-
- *Fs = NULL;
- *Path = NULL;
-- Status = EFI_SUCCESS;
-
- p = AbPath;
- while (*p) {
-@@ -1017,13 +1015,11 @@ Return:
- EFI_LIST_ENTRY SrcList;
- EFI_LIST_ENTRY DstList;
- EFI_STATUS Status;
-- EFI_LIST_ENTRY *Link;
- SHELL_FILE_ARG *SrcArg;
- SHELL_FILE_ARG *DstArg;
-
- ASSERT (IsSame != NULL);
-
-- Link = NULL;
- SrcArg = NULL;
- DstArg = NULL;
- InitializeListHead (&SrcList);
-diff --git a/Library/FileIO.h b/Library/FileIO.h
-index bb07d91..54fd6d5 100644
---- a/Library/FileIO.h
-+++ b/Library/FileIO.h
-@@ -208,4 +208,5 @@ CloseSimpleReadFile (
- IN SIMPLE_READ_FILE SimpleReadHandle
- );
-
--#endif
-\ No newline at end of file
-+#endif
-+
-diff --git a/Library/Handle.c b/Library/Handle.c
-index 33f925d..f406d5a 100644
---- a/Library/Handle.c
-+++ b/Library/Handle.c
-@@ -21,7 +21,7 @@ Revision History
-
- --*/
-
--#include "EfiShelllib.h"
-+#include "EfiShellLib.h"
-
- EFI_STATUS
- LibLocateHandle (
-@@ -131,7 +131,6 @@ Returns:
- EFI_HANDLE *BlockIoBuffer;
- EFI_DEVICE_PATH_PROTOCOL *DevicePath;
- UINTN Index;
-- EFI_DEVICE_PATH_PROTOCOL *Start;
- EFI_DEVICE_PATH_PROTOCOL *Next;
- EFI_DEVICE_PATH_PROTOCOL *DevPath;
- HARDDRIVE_DEVICE_PATH *HardDriveDevicePath;
-@@ -204,7 +203,6 @@ Returns:
- PreviousNodeIsHardDriveDevicePath = FALSE;
-
- DevPath = DevicePath;
-- Start = DevPath;
- //
- // Check for end of device path type
- //
-@@ -796,14 +794,12 @@ LibScanHandleDatabase (
- UINTN OpenInfoIndex;
- UINTN ChildIndex;
- BOOLEAN DriverBindingHandleIndexValid;
-- BOOLEAN ControllerHandleIndexValid;
-
- DriverBindingHandleIndexValid = FALSE;
- if (DriverBindingHandleIndex != NULL) {
- *DriverBindingHandleIndex = 0xffffffff;
- }
-
-- ControllerHandleIndexValid = FALSE;
- if (ControllerHandleIndex != NULL) {
- *ControllerHandleIndex = 0xffffffff;
+@@ -90,7 +90,7 @@
+ NULL,
+ 0,
+ 0,
+- 0
++ (SHELL_VAR_CHECK_FLAG_TYPE) 0
}
-@@ -847,7 +843,6 @@ LibScanHandleDatabase (
-
- if (ControllerHandle != NULL && ControllerHandleIndex != NULL && (*HandleBuffer)[HandleIndex] == ControllerHandle) {
- *ControllerHandleIndex = (UINT32) HandleIndex;
-- ControllerHandleIndexValid = TRUE;
- }
+ };
+Index: drvdiag/drvdiag.h
+===================================================================
+--- drvdiag/drvdiag.h (revision 64)
++++ drvdiag/drvdiag.h (working copy)
+@@ -33,3 +33,4 @@
}
-@@ -1286,7 +1281,7 @@ Returns:
- Status = BS->HandleProtocol (
- Handles[Index],
- ProtocolGuid,
-- Interface
-+ (VOID**)Interface
- );
-
- if (!EFI_ERROR (Status)) {
-diff --git a/Library/HiiSupport.c b/Library/HiiSupport.c
-index bce645b..5f70712 100644
---- a/Library/HiiSupport.c
-+++ b/Library/HiiSupport.c
-@@ -21,7 +21,7 @@ Revision History
-
- --*/
-
--#include "EfiShelllib.h"
-+#include "EfiShellLib.h"
-
- #if (EFI_SPECIFICATION_VERSION >= 0x0002000A)
-
-@@ -56,11 +56,11 @@ Returns:
- return EFI_SUCCESS;
- }
-
-- Status = LibLocateProtocol (&gEfiHiiDatabaseProtocolGuid, &gLibHiiDatabase);
-+ Status = LibLocateProtocol (&gEfiHiiDatabaseProtocolGuid, (VOID**)&gLibHiiDatabase);
- if (EFI_ERROR (Status)) {
- return Status;
- }
-- Status = LibLocateProtocol (&gEfiHiiStringProtocolGuid, &gLibHiiString);
-+ Status = LibLocateProtocol (&gEfiHiiStringProtocolGuid, (VOID**)&gLibHiiString);
- if (EFI_ERROR (Status)) {
- return Status;
- }
-diff --git a/Library/IO.c b/Library/IO.c
-index 81f26fd..749aacb 100644
---- a/Library/IO.c
-+++ b/Library/IO.c
-@@ -21,7 +21,7 @@ Revision History
-
- --*/
-
--#include "EfiShelllib.h"
-+#include "EfiShellLib.h"
-
- #define PRINT_STRING_LEN 1024
- #define PRINT_ITEM_BUFFER_LEN 100
-@@ -86,8 +86,8 @@ typedef struct _pstate {
- typedef struct {
- BOOLEAN PageBreak;
- BOOLEAN AutoWrap;
-- INTN MaxRow;
-- INTN MaxColumn;
-+ UINTN MaxRow;
-+ UINTN MaxColumn;
- INTN InitRow;
- INTN Row;
- INTN Column;
-@@ -1575,7 +1575,7 @@ Returns:
- {
- BOOLEAN Done;
- UINTN Column;
-- INTN Row;
-+ UINTN Row;
- UINTN StartColumn;
- UINTN Update;
- UINTN Delete;
-@@ -1928,8 +1928,8 @@ LibGetPageBreak (
- return mPrintMode.PageBreak;
- }
-
-+#if 0
- STATIC
--
- BOOLEAN
- GetOutputPause (
- VOID
-@@ -1937,6 +1937,7 @@ GetOutputPause (
- {
- return mPrintMode.OutputPause;
- }
-+#endif
-
- INTN
- DbgPrint (
-diff --git a/Library/IO.h b/Library/IO.h
-index 7469c32..5d13e17 100644
---- a/Library/IO.h
-+++ b/Library/IO.h
-@@ -157,4 +157,5 @@ LibGetPageBreak (
- );
-
-
--#endif
-\ No newline at end of file
-+#endif
-+
-diff --git a/Library/Init.c b/Library/Init.c
-index 80dc3a3..37d555f 100644
---- a/Library/Init.c
-+++ b/Library/Init.c
-@@ -20,7 +20,7 @@ Revision History
-
- --*/
-
--#include "EfiShelllib.h"
-+#include "EfiShellLib.h"
-
- extern EFI_UNICODE_COLLATION_PROTOCOL LibStubUnicodeInterface;
-
-diff --git a/Library/Lock.c b/Library/Lock.c
-index 8a40db5..b3f9bad 100644
---- a/Library/Lock.c
-+++ b/Library/Lock.c
-@@ -21,7 +21,7 @@ Revision History
-
- --*/
-
--#include "EfiShelllib.h"
-+#include "EfiShellLib.h"
-
- VOID
- InitializeLock (
-diff --git a/Library/Lock.h b/Library/Lock.h
-index 9e35b92..275a221 100644
---- a/Library/Lock.h
-+++ b/Library/Lock.h
-@@ -45,4 +45,5 @@ ReleaseLock (
- IN FLOCK *Lock
- );
-
--#endif
-\ No newline at end of file
-+#endif
-+
-diff --git a/Library/Mem.c b/Library/Mem.c
-index f82cb52..9675b52 100644
---- a/Library/Mem.c
-+++ b/Library/Mem.c
-@@ -21,7 +21,7 @@ Revision History
-
- --*/
-
--#include "EfiShelllib.h"
-+#include "EfiShellLib.h"
-
- VOID
- SetMem (
-diff --git a/Library/Mem.h b/Library/Mem.h
-index bca1e1d..b3d222d 100644
---- a/Library/Mem.h
-+++ b/Library/Mem.h
-@@ -73,4 +73,5 @@ ZeroMem (
- IN UINTN Size
- );
-
--#endif
-\ No newline at end of file
-+#endif
-+
-diff --git a/Library/Misc.c b/Library/Misc.c
-index c778236..b476d08 100644
---- a/Library/Misc.c
-+++ b/Library/Misc.c
-@@ -21,7 +21,7 @@ Revision History
-
- --*/
-
--#include "EfiShelllib.h"
-+#include "EfiShellLib.h"
-
- #if (PLATFORM == NT32)
- #define LOCAL_EFI_WIN_NT_THUNK_PROTOCOL_GUID \
-@@ -348,7 +348,7 @@ Returns:
- ASSERT (Buffer != NULL);
-
- if (mShellEnv == NULL) {
-- Status = LibLocateProtocol (&ShellEnvProtocol, &mShellEnv);
-+ Status = LibLocateProtocol (&ShellEnvProtocol, (VOID**)&mShellEnv);
- if (EFI_ERROR (Status)) {
- mShellEnv = NULL;
- }
-@@ -1171,7 +1171,7 @@ Returns:
- Status = BS->HandleProtocol (
- Image->DeviceHandle,
- &gEfiFirmwareVolumeProtocolGuid,
-- &FV
-+ (VOID**)&FV
- );
- if (!EFI_ERROR (Status)) {
- Status = FV->ReadSection (
-@@ -1192,7 +1192,7 @@ Returns:
- Status = BS->HandleProtocol (
- Image->DeviceHandle,
- &gEfiFirmwareVolume2ProtocolGuid,
-- &FV2
-+ (VOID**)&FV2
- );
- if (!EFI_ERROR (Status)) {
- Status = FV2->ReadSection (
-@@ -1339,7 +1339,7 @@ LibCmdGetStringByToken (
- {
- EFI_STATUS Status;
- CHAR16 *String;
-- EFI_HII_HANDLE HiiHandle;
-+ STATIC EFI_HII_HANDLE HiiHandle;
-
- ASSERT (Str);
-
-diff --git a/Library/Perf.c b/Library/Perf.c
-index 43e09ea..87c4113 100644
---- a/Library/Perf.c
-+++ b/Library/Perf.c
-@@ -19,7 +19,7 @@ Abstract:
-
- --*/
-
--#include "EfiShelllib.h"
-+#include "EfiShellLib.h"
-
- #include EFI_PROTOCOL_DEFINITION (Performance)
-
-diff --git a/Library/RtData.c b/Library/RtData.c
-index af55cb4..145e933 100644
---- a/Library/RtData.c
-+++ b/Library/RtData.c
-@@ -21,7 +21,7 @@ Revision History
-
- --*/
-
--#include "EfiShelllib.h"
-+#include "EfiShellLib.h"
- //
- // RT - pointer to the runtime table
-diff --git a/Library/ShellDebug.c b/Library/ShellDebug.c
-index b31ef06..c8b93d5 100644
---- a/Library/ShellDebug.c
-+++ b/Library/ShellDebug.c
-@@ -19,7 +19,7 @@ Abstract:
-
- --*/
-
--#include "EfiShelllib.h"
-+#include "EfiShellLib.h"
- #include EFI_PROTOCOL_DEFINITION (DebugAssert)
-
- EFI_DEBUG_ASSERT_PROTOCOL *mDebugAssert = NULL;
-diff --git a/Library/ShellEnvInt.c b/Library/ShellEnvInt.c
-index b99d973..53de481 100644
---- a/Library/ShellEnvInt.c
-+++ b/Library/ShellEnvInt.c
-@@ -21,7 +21,7 @@ Revision History
-
- --*/
-
--#include "EfiShelllib.h"
-+#include "EfiShellLib.h"
-
- EFI_STATUS
- ShellExecute (
-diff --git a/Library/ShellEnvInt.h b/Library/ShellEnvInt.h
-index 4182dff..7eef19a 100644
---- a/Library/ShellEnvInt.h
-+++ b/Library/ShellEnvInt.h
-@@ -196,4 +196,5 @@ ShellGetHandleNum (
- VOID
- );
-
--#endif
-\ No newline at end of file
-+#endif
+ #endif
+
-diff --git a/Library/Str.c b/Library/Str.c
-index ca0c76b..d881dae 100644
---- a/Library/Str.c
-+++ b/Library/Str.c
-@@ -22,7 +22,7 @@ Revision History
-
- --*/
-
--#include "EfiShelllib.h"
-+#include "EfiShellLib.h"
-
- INTN
- StrCmp (
-@@ -421,7 +421,7 @@ Returns:
- return (UINTN) -1;
- }
-
-- u = u << 4 | c - (c >= 'A' ? 'A' - 10 : '0');
-+ u = (u << 4) | (c - (c >= 'A' ? 'A' - 10 : '0'));
- } else {
- break;
- }
-@@ -472,7 +472,7 @@ Returns:
- c = *(str++);
- while (c) {
- if (c >= '0' && c <= '9') {
-- if (u > m || u == m && c - '0' > (INTN) n) {
-+ if ((u > m) || ((u == m) && (c - '0' > (INTN) n))) {
- return (UINTN) -1;
- }
-
-diff --git a/Library/VarCheck.c b/Library/VarCheck.c
-index 53597ff..1abec9d 100644
---- a/Library/VarCheck.c
-+++ b/Library/VarCheck.c
-@@ -21,7 +21,7 @@ Revision History
+Index: drvdiag/drvdiag.inf
+===================================================================
+--- drvdiag/drvdiag.inf (revision 64)
++++ drvdiag/drvdiag.inf (working copy)
+@@ -40,7 +40,7 @@
- --*/
-
--#include "EfiShelllib.h"
-+#include "EfiShellLib.h"
-
- VOID
- LibCheckVarFreeVarList (
-diff --git a/Library/VarCheck.h b/Library/VarCheck.h
-index bc1f412..45aba2c 100644
---- a/Library/VarCheck.h
-+++ b/Library/VarCheck.h
-@@ -41,7 +41,7 @@ typedef enum {
- ARG_PARTIALLY_QUOTED = 0x2,
- ARG_FIRST_HALF_QUOTED = 0x4,
- ARG_FIRST_CHAR_IS_ESC = 0x8
--};
-+} SHELL_ARG_EXPR;
-
- typedef struct {
- CHAR16 *FlagStr;
-diff --git a/LoadPciRom/LoadPciRom.c b/LoadPciRom/LoadPciRom.c
-index f8854b7..7afcefd 100644
---- a/LoadPciRom/LoadPciRom.c
-+++ b/LoadPciRom/LoadPciRom.c
-@@ -24,7 +24,7 @@ Revision History
-
- #include "EfiShellLib.h"
- #include "LoadPciRom.h"
--#include "Pci22.h"
-+#include "pci22.h"
-
- extern UINT8 STRING_ARRAY_NAME[];
-
-@@ -56,7 +56,7 @@ LoadEfiDriversFromRomImage (
- );
-
- EFI_HANDLE gMyImageHandle;
--EFI_HII_HANDLE HiiHandle;
-+STATIC EFI_HII_HANDLE HiiHandle;
- EFI_GUID EfiLoadPciRomGuid = EFI_LOADPCIROM_GUID;
- SHELL_VAR_CHECK_ITEM LPRCheckList[] = {
- {
-@@ -377,7 +377,7 @@ Returns:
- }
-
- if (EfiRomHeader->CompressionType == EFI_PCI_EXPANSION_ROM_HEADER_COMPRESSED) {
-- Status = BS->LocateProtocol (&gEfiDecompressProtocolGuid, NULL, &Decompress);
-+ Status = BS->LocateProtocol (&gEfiDecompressProtocolGuid, NULL, (VOID**)&Decompress);
- if (EFI_ERROR (Status)) {
- PrintToken (STRING_TOKEN (STR_LOADPCIROM_DECOMP_NOT_FOUND), HiiHandle);
- SkipImage = TRUE;
-diff --git a/LoadPciRom/LoadPciRom.inf b/LoadPciRom/LoadPciRom.inf
-index 8e79af7..943a148 100644
---- a/LoadPciRom/LoadPciRom.inf
-+++ b/LoadPciRom/LoadPciRom.inf
-@@ -41,23 +41,23 @@ COMPONENT_TYPE = APPLICATION
[sources.common]
- LoadPciRomStrings.uni
- ..\ShCommonStrings.uni
+ ../ShCommonStrings.uni
- LoadPciRom.c
- LoadPciRom.h
+ DrvdiagStrings.uni
+ drvdiag.c
+ drvdiag.h
+@@ -48,17 +48,17 @@
[includes.common]
.
@@ -1104,1254 +212,11 @@ index 8e79af7..943a148 100644
[libraries.common]
EfiShellLib
-diff --git a/Ping/Ping.c b/Ping/Ping.c
-index 7d92881..16b9b4b 100644
---- a/Ping/Ping.c
-+++ b/Ping/Ping.c
-@@ -20,14 +20,14 @@ Abstract:
- --*/
-
- #include "EfiShellLib.h"
--#include "CpuFuncs.h"
-+//#include "CpuFuncs.h"
- #include EFI_ARCH_PROTOCOL_DEFINITION (Cpu)
- #include EFI_PROTOCOL_DEFINITION (Ip4)
- #include "Ping.h"
- #include STRING_DEFINES_FILE
- extern UINT8 STRING_ARRAY_NAME[];
-
--EFI_HII_HANDLE HiiHandle;
-+STATIC EFI_HII_HANDLE HiiHandle;
-
- EFI_GUID EfiPingGuid = EFI_PING_GUID;
- SHELL_VAR_CHECK_ITEM PingCheckList[] = {
-@@ -114,6 +114,8 @@ UINT32 RttSum;
- UINT32 RttMin;
- UINT32 RttMax;
-
-+EFI_CPU_ARCH_PROTOCOL *gCpu = NULL;
-+
- STATIC
- UINT64
- GetTimerValue (
-@@ -135,7 +137,22 @@ Returns:
-
- --*/
- {
-- return EfiReadTsc ();
-+ static UINT64 CurrentTick = 0;
-+ UINT64 TimerPeriod;
-+ EFI_STATUS Status;
-+
-+ ASSERT (gCpu != NULL);
-+
-+ Status = gCpu->GetTimerValue (gCpu, 0, &CurrentTick, &TimerPeriod);
-+ if (EFI_ERROR (Status)) {
-+ //
-+ // The WinntGetTimerValue will return EFI_UNSUPPORTED. Set the
-+ // TimerPeriod by ourselves.
-+ //
-+ CurrentTick += 1000000;
-+ }
-+
-+ return CurrentTick;
- }
-
- STATIC
-@@ -168,7 +185,7 @@ Returns:
- //
- // Locate the Cpu Arch Protocol.
- //
-- Status = BS->LocateProtocol (&gEfiCpuArchProtocolGuid, NULL, &Cpu);
-+ Status = BS->LocateProtocol (&gEfiCpuArchProtocolGuid, NULL, (VOID**)&Cpu);
- if (EFI_ERROR (Status)) {
- return Status;
- }
-diff --git a/Ping/Ping.inf b/Ping/Ping.inf
-index 64dec5c..1052418 100644
---- a/Ping/Ping.inf
-+++ b/Ping/Ping.inf
-@@ -25,24 +25,24 @@ FILE_GUID = FAAA94BA-7095-4c0f-8D69-8E00C8328863
- COMPONENT_TYPE = APPLICATION
-
- [sources.common]
-- ..\ShCommonStrings.uni
-+ ../ShCommonStrings.uni
- PingStrings.uni
- Ping.h
- Ping.c
-
- [includes.common]
-- ..\Inc
-- ..\Library
-- $(EDK_SOURCE)\Foundation\Efi
-- $(EDK_SOURCE)\Foundation
-- $(EDK_SOURCE)\Foundation\Efi\Include
-- $(EDK_SOURCE)\Foundation\Include
-- $(EDK_SOURCE)\Foundation\Include\IndustryStandard
-- $(EDK_SOURCE)\Foundation\FrameWork
-- $(EDK_SOURCE)\Foundation\FrameWork\Include
-- $(EDK_SOURCE)\Foundation\Core\Dxe
-- $(EDK_SOURCE)\Foundation\Library\Dxe\Include
-- $(DEST_DIR)\
-+ ../Inc
-+ ../Library
-+ $(EDK_SOURCE)/Foundation/Efi
-+ $(EDK_SOURCE)/Foundation
-+ $(EDK_SOURCE)/Foundation/Efi/Include
-+ $(EDK_SOURCE)/Foundation/Include
-+ $(EDK_SOURCE)/Foundation/Include/IndustryStandard
-+ $(EDK_SOURCE)/Foundation/FrameWork
-+ $(EDK_SOURCE)/Foundation/FrameWork/Include
-+ $(EDK_SOURCE)/Foundation/Core/Dxe
-+ $(EDK_SOURCE)/Foundation/Library/Dxe/Include
-+ $(DEST_DIR./
-
- [libraries.common]
- EfiShellLib
-@@ -52,7 +52,6 @@ COMPONENT_TYPE = APPLICATION
- ArchProtocolLib
- EdkGuidLib
- EdkFrameworkGuidLib
-- EfiDriverLib
-
- [libraries.Ia32]
- CpuIA32Lib
-diff --git a/Shell.inf b/Shell.inf
-index fee3558..363e165 100644
---- a/Shell.inf
-+++ b/Shell.inf
-@@ -25,179 +25,184 @@ FILE_GUID = c57ad6b7-0515-40a8-9d21-551652854e37
- COMPONENT_TYPE = APPLICATION
-
- [sources.common]
-- Library\ShellDebug.c
-- Library\DPath.c
-- Library\Init.c
-- Library\Lock.c
-- Library\Str.c
-- Library\IO.c
-- Library\Mem.c
-- Library\Misc.c
-- Library\Data.c
-- Library\RtData.c
-- Library\ShellEnvInt.c
-- Library\Handle.c
-- Library\FileIO.c
-- Library\ConsistMapping.c
-- Library\CRC.c
-- Library\Event.c
-- Library\Perf.c
-- Library\VarCheck.c
-- Library\HiiSupport.c
--
-- newshell\NshellStrings.uni
-- newshell\init.c
-- newshell\nshell.h
-- newshell\fakehii.c
-+ Library/ShellDebug.c
-+ Library/DPath.c
-+ Library/Init.c
-+ Library/Lock.c
-+ Library/Str.c
-+ Library/IO.c
-+ Library/Mem.c
-+ Library/Misc.c
-+ Library/Data.c
-+ Library/RtData.c
-+ Library/ShellEnvInt.c
-+ Library/Handle.c
-+ Library/FileIO.c
-+ Library/ConsistMapping.c
-+ Library/CRC.c
-+ Library/Event.c
-+ Library/Perf.c
-+ Library/VarCheck.c
-+ Library/HiiSupport.c
-+
-+ newshell/NshellStrings.uni
-+ newshell/init.c
-+ newshell/nshell.h
-+ newshell/fakehii.c
-
- ShCommonStrings.uni
-- shellenv\ShellenvHelpStrings.uni
-- shellenv\ShellenvStrings.uni
-- shellenv\ScriptCmdStrings.uni
-- shellenv\ConnectStrings.uni
-- shellenv\EchoStrings.uni
-- shellenv\HelpStrings.uni
-- shellenv\MapStrings.uni
-- shellenv\CdStrings.uni
-- shellenv\DhStrings.uni
-+ shellenv/ShellenvHelpStrings.uni
-+ shellenv/ShellenvStrings.uni
-+ shellenv/ScriptCmdStrings.uni
-+ shellenv/ConnectStrings.uni
-+ shellenv/EchoStrings.uni
-+ shellenv/HelpStrings.uni
-+ shellenv/MapStrings.uni
-+ shellenv/CdStrings.uni
-+ shellenv/DhStrings.uni
-
-- shellenv\cmddisp.c
-- shellenv\connect.c
-- shellenv\data.c
-- shellenv\exec.c
-- shellenv\init.c
-- shellenv\protid.c
-- shellenv\var.c
-- shellenv\conio.c
-- shellenv\consoleproxy.c
-- shellenv\handle.c
-- shellenv\dprot.c
-- shellenv\map.c
-- shellenv\marg.c
-- shellenv\batch.c
-- shellenv\if.c
-- shellenv\goto.c
-- shellenv\echo.c
-- shellenv\pause.c
-- shellenv\for.c
-- shellenv\wait.c
-- shellenv\help.c
-- shellenv\shelle.h
-- shellenv\shellenvguid.h
-- shellenv\parsecmd.c
-- shellenv\shift.c
-+ shellenv/cmddisp.c
-+ shellenv/connect.c
-+ shellenv/data.c
-+ shellenv/exec.c
-+ shellenv/init.c
-+ shellenv/protid.c
-+ shellenv/var.c
-+ shellenv/conio.c
-+ shellenv/consoleproxy.c
-+ shellenv/handle.c
-+ shellenv/dprot.c
-+ shellenv/map.c
-+ shellenv/marg.c
-+ shellenv/batch.c
-+ shellenv/if.c
-+ shellenv/goto.c
-+ shellenv/echo.c
-+ shellenv/pause.c
-+ shellenv/for.c
-+ shellenv/wait.c
-+ shellenv/help.c
-+ shellenv/shelle.h
-+ shellenv/shellenvguid.h
-+ shellenv/parsecmd.c
-+ shellenv/shift.c
-
-- unload\UnloadStrings.uni
-- unload\unload.c
-+ unload/UnloadStrings.uni
-+ unload/unload.c
-
-- attrib\AttribStrings.uni
-- attrib\attrib.c
-- attrib\attrib.h
-+ attrib/AttribStrings.uni
-+ attrib/attrib.c
-+ attrib/attrib.h
-
-- cls\clsstrings.uni
-- cls\cls.c
-+ cls/clsstrings.uni
-+ cls/cls.c
-
-- cp\CpStrings.uni
-- cp\cp.h
-- cp\cp.c
-+ cp/CpStrings.uni
-+ cp/cp.h
-+ cp/cp.c
-
-- date\DateStrings.uni
-- date\date.c
-- date\date.h
-+ date/DateStrings.uni
-+ date/date.c
-+ date/date.h
-
-- load\LoadStrings.uni
-- load\load.c
-- load\load.h
-+ load/LoadStrings.uni
-+ load/load.c
-+ load/load.h
-
-- ls\LsStrings.uni
-- ls\ls.h
-- ls\ls.c
-+ ls/LsStrings.uni
-+ ls/ls.h
-+ ls/ls.c
-
-- mkdir\MkdirStrings.uni
-- mkdir\mkdir.c
-- mkdir\mkdir.h
-+ mkdir/MkdirStrings.uni
-+ mkdir/mkdir.c
-+ mkdir/mkdir.h
-
-- mv\MvStrings.uni
-- mv\mv.c
-- mv\mv.h
-+ mv/MvStrings.uni
-+ mv/mv.c
-+ mv/mv.h
-
-- reset\ResetStrings.uni
-- reset\reset.c
-- reset\reset.h
-+ reset/ResetStrings.uni
-+ reset/reset.c
-+ reset/reset.h
-
-- rm\RmStrings.uni
-- rm\rm.h
-- rm\rm.c
-+ rm/RmStrings.uni
-+ rm/rm.h
-+ rm/rm.c
-
-- type\TypeStrings.uni
-- type\type.c
-- type\type.h
-- time\TimeStrings.uni
-- time\time.c
-- time\time.h
--
-- touch\TouchStrings.uni
-- touch\touch.c
-- touch\touch.h
--
-- vol\VolStrings.uni
-- vol\vol.c
-- vol\vol.h
--
-- ver\VerStrings.uni
-- ver\ver.c
-- ver\ver.h
-+ type/TypeStrings.uni
-+ type/type.c
-+ type/type.h
-+ time/TimeStrings.uni
-+ time/time.c
-+ time/time.h
-+
-+ touch/TouchStrings.uni
-+ touch/touch.c
-+ touch/touch.h
-+
-+ vol/VolStrings.uni
-+ vol/vol.c
-+ vol/vol.h
-+
-+ ver/VerStrings.uni
-+ ver/ver.c
-+ ver/ver.h
-
-- drivers\driversStrings.uni
-- drivers\drivers.c
-- drivers\drivers.h
-+ drivers/driversStrings.uni
-+ drivers/drivers.c
-+ drivers/drivers.h
-
-- drvcfg\DrvcfgStrings.uni
-- drvcfg\drvcfg.c
-- drvcfg\drvcfg.h
-+ drvcfg/DrvcfgStrings.uni
-+ drvcfg/drvcfg.c
-+ drvcfg/drvcfg.h
-
-- drvdiag\DrvdiagStrings.uni
-- drvdiag\drvdiag.c
-- drvdiag\drvdiag.h
-+ drvdiag/DrvdiagStrings.uni
-+ drvdiag/drvdiag.c
-+ drvdiag/drvdiag.h
-
-
-
- [sources.ia32]
-- ver\ia32\ver32.c
-- Library\ia32\math.c
-- Library\ia32\initplat.c
-+ ver/IA32/ver32.c
-+ Library/IA32/math.c
-+ Library/IA32/initplat.c
-
-
- [sources.ipf]
-- ver\ipf\ver64.c
-- Library\ipf\math.c
-- Library\ipf\initplat.c
-- Library\ipf\palproc.s
-- Library\ipf\salpal.c
-+ ver/IPF/ver64.c
-+ Library/IPF/math.c
-+ Library/IPF/initplat.c
-+ Library/IPF/palproc.s
-+ Library/IPF/salpal.c
-
- [sources.EBC]
-- ver\ebc\verEbc.c
-- Library\EBC\math.c
-- Library\EBC\initplat.c
-+ ver/ebc/verEbc.c
-+ Library/Ebc/math.c
-+ Library/Ebc/initplat.c
-
- [sources.x64]
-- ver\ia32\ver32.c
-- Library\ipf\math.c
-- Library\ia32\initplat.c
-+ ver/IA32/ver32.c
-+ Library/IPF/math.c
-+ Library/IA32/initplat.c
-+
-+[sources.ARM]
-+ ver/ia32/ver32.c
-+ Library/IPF/math.c
-+ Library/IA32/initplat.c
-
- [includes.common]
- .
-- .\Inc
-- .\ver
-- .\Library
-- $(EDK_SOURCE)\Foundation
-- $(EDK_SOURCE)\Foundation\Include
-- $(EDK_SOURCE)\Foundation\Include\IndustryStandard
-- $(EDK_SOURCE)\Foundation\Efi
-- $(EDK_SOURCE)\Foundation\Efi\Include
-- $(EDK_SOURCE)\Foundation\FrameWork
-- $(EDK_SOURCE)\Foundation\FrameWork\Include
-- $(EDK_SOURCE)\Foundation\Core\Dxe
-+ ./Inc
-+ ./ver
-+ ./Library
-+ $(EDK_SOURCE)/Foundation
-+ $(EDK_SOURCE)/Foundation/Include
-+ $(EDK_SOURCE)/Foundation/Include/IndustryStandard
-+ $(EDK_SOURCE)/Foundation/Efi
-+ $(EDK_SOURCE)/Foundation/Efi/Include
-+ $(EDK_SOURCE)/Foundation/FrameWork
-+ $(EDK_SOURCE)/Foundation/FrameWork/Include
-+ $(EDK_SOURCE)/Foundation/Core/Dxe
- $(DEST_DIR)
-
- [libraries.common]
-@@ -229,4 +234,4 @@ COMPONENT_TYPE = APPLICATION
-
-
-
--
-\ No newline at end of file
-+
-diff --git a/ShellFull.inf b/ShellFull.inf
-index 832dc79..6cca7df 100644
---- a/ShellFull.inf
-+++ b/ShellFull.inf
-@@ -20,300 +20,305 @@
- #--*/
-
- [defines]
--BASE_NAME = Shell
--FILE_GUID = c57ad6b7-0515-40a8-9d21-551652854e37
-+BASE_NAME = ShellFull
-+FILE_GUID = 1903FB23-E526-4BDA-85E4-D68F2EEF0C20
- COMPONENT_TYPE = APPLICATION
-
- [sources.common]
-- Library\ShellDebug.c
-- Library\DPath.c
-- Library\Init.c
-- Library\Lock.c
-- Library\Str.c
-- Library\IO.c
-- Library\Mem.c
-- Library\Misc.c
-- Library\Data.c
-- Library\RtData.c
-- Library\ShellEnvInt.c
-- Library\Handle.c
-- Library\FileIO.c
-- Library\ConsistMapping.c
-- Library\CRC.c
-- Library\Event.c
-- Library\Perf.c
-- Library\VarCheck.c
-- Library\HiiSupport.c
--
-- newshell\NshellStrings.uni
-- newshell\init.c
-- newshell\nshell.h
-- newshell\fakehii.c
-+ Library/ShellDebug.c
-+ Library/DPath.c
-+ Library/Init.c
-+ Library/Lock.c
-+ Library/Str.c
-+ Library/IO.c
-+ Library/Mem.c
-+ Library/Misc.c
-+ Library/Data.c
-+ Library/RtData.c
-+ Library/ShellEnvInt.c
-+ Library/Handle.c
-+ Library/FileIO.c
-+ Library/ConsistMapping.c
-+ Library/CRC.c
-+ Library/Event.c
-+ Library/Perf.c
-+ Library/VarCheck.c
-+ Library/HiiSupport.c
-+
-+ newshell/NshellStrings.uni
-+ newshell/init.c
-+ newshell/nshell.h
-+ newshell/fakehii.c
-
- ShCommonStrings.uni
-- shellenv\ShellenvHelpStrings.uni
-- shellenv\ShellenvStrings.uni
-- shellenv\ScriptCmdStrings.uni
-- shellenv\ConnectStrings.uni
-- shellenv\EchoStrings.uni
-- shellenv\HelpStrings.uni
-- shellenv\MapStrings.uni
-- shellenv\CdStrings.uni
-- shellenv\DhStrings.uni
-+ shellenv/ShellenvHelpStrings.uni
-+ shellenv/ShellenvStrings.uni
-+ shellenv/ScriptCmdStrings.uni
-+ shellenv/ConnectStrings.uni
-+ shellenv/EchoStrings.uni
-+ shellenv/HelpStrings.uni
-+ shellenv/MapStrings.uni
-+ shellenv/CdStrings.uni
-+ shellenv/DhStrings.uni
-
-- shellenv\cmddisp.c
-- shellenv\connect.c
-- shellenv\data.c
-- shellenv\exec.c
-- shellenv\init.c
-- shellenv\protid.c
-- shellenv\var.c
-- shellenv\conio.c
-- shellenv\consoleproxy.c
-- shellenv\handle.c
-- shellenv\dprot.c
-- shellenv\map.c
-- shellenv\marg.c
-- shellenv\batch.c
-- shellenv\if.c
-- shellenv\goto.c
-- shellenv\echo.c
-- shellenv\pause.c
-- shellenv\for.c
-- shellenv\wait.c
-- shellenv\help.c
-- shellenv\shelle.h
-- shellenv\shellenvguid.h
-- shellenv\parsecmd.c
-- shellenv\shift.c
-+ shellenv/cmddisp.c
-+ shellenv/connect.c
-+ shellenv/data.c
-+ shellenv/exec.c
-+ shellenv/init.c
-+ shellenv/protid.c
-+ shellenv/var.c
-+ shellenv/conio.c
-+ shellenv/consoleproxy.c
-+ shellenv/handle.c
-+ shellenv/dprot.c
-+ shellenv/map.c
-+ shellenv/marg.c
-+ shellenv/batch.c
-+ shellenv/if.c
-+ shellenv/goto.c
-+ shellenv/echo.c
-+ shellenv/pause.c
-+ shellenv/for.c
-+ shellenv/wait.c
-+ shellenv/help.c
-+ shellenv/shelle.h
-+ shellenv/shellenvguid.h
-+ shellenv/parsecmd.c
-+ shellenv/shift.c
-
-- unload\UnloadStrings.uni
-- unload\unload.c
-+ unload/UnloadStrings.uni
-+ unload/unload.c
-
-- attrib\AttribStrings.uni
-- attrib\attrib.c
-- attrib\attrib.h
-+ attrib/AttribStrings.uni
-+ attrib/attrib.c
-+ attrib/attrib.h
-
-- cls\clsstrings.uni
-- cls\cls.c
-+ cls/clsstrings.uni
-+ cls/cls.c
-
-- cp\CpStrings.uni
-- cp\cp.h
-- cp\cp.c
-+ cp/CpStrings.uni
-+ cp/cp.h
-+ cp/cp.c
-
-- date\DateStrings.uni
-- date\date.c
-- date\date.h
-+ date/DateStrings.uni
-+ date/date.c
-+ date/date.h
-
-- load\LoadStrings.uni
-- load\load.c
-- load\load.h
-+ load/LoadStrings.uni
-+ load/load.c
-+ load/load.h
-
-- ls\LsStrings.uni
-- ls\ls.h
-- ls\ls.c
-+ ls/LsStrings.uni
-+ ls/ls.h
-+ ls/ls.c
-
-- mkdir\MkdirStrings.uni
-- mkdir\mkdir.c
-- mkdir\mkdir.h
-+ mkdir/MkdirStrings.uni
-+ mkdir/mkdir.c
-+ mkdir/mkdir.h
-
-- mv\MvStrings.uni
-- mv\mv.c
-- mv\mv.h
-+ mv/MvStrings.uni
-+ mv/mv.c
-+ mv/mv.h
-
-- reset\ResetStrings.uni
-- reset\reset.c
-- reset\reset.h
-+ reset/ResetStrings.uni
-+ reset/reset.c
-+ reset/reset.h
-
-- rm\RmStrings.uni
-- rm\rm.h
-- rm\rm.c
-+ rm/RmStrings.uni
-+ rm/rm.h
-+ rm/rm.c
-
-- type\TypeStrings.uni
-- type\type.c
-- type\type.h
-- time\TimeStrings.uni
-- time\time.c
-- time\time.h
--
-- touch\TouchStrings.uni
-- touch\touch.c
-- touch\touch.h
--
-- vol\VolStrings.uni
-- vol\vol.c
-- vol\vol.h
--
-- ver\VerStrings.uni
-- ver\ver.c
-- ver\ver.h
-+ type/TypeStrings.uni
-+ type/type.c
-+ type/type.h
-+ time/TimeStrings.uni
-+ time/time.c
-+ time/time.h
-+
-+ touch/TouchStrings.uni
-+ touch/touch.c
-+ touch/touch.h
-+
-+ vol/VolStrings.uni
-+ vol/vol.c
-+ vol/vol.h
-+
-+ ver/VerStrings.uni
-+ ver/ver.c
-+ ver/ver.h
-
-- drivers\driversStrings.uni
-- drivers\drivers.c
-- drivers\drivers.h
-+ drivers/driversStrings.uni
-+ drivers/drivers.c
-+ drivers/drivers.h
-
-- drvcfg\DrvcfgStrings.uni
-- drvcfg\drvcfg.c
-- drvcfg\drvcfg.h
-+ drvcfg/DrvcfgStrings.uni
-+ drvcfg/drvcfg.c
-+ drvcfg/drvcfg.h
-
-- drvdiag\DrvdiagStrings.uni
-- drvdiag\drvdiag.c
-- drvdiag\drvdiag.h
-+ drvdiag/DrvdiagStrings.uni
-+ drvdiag/drvdiag.c
-+ drvdiag/drvdiag.h
-
-- comp\CompStrings.uni
-- comp\comp.c
-+ comp/CompStrings.uni
-+ comp/comp.c
-
-- dblk\dblkStrings.uni
-- dblk\dblk.c
-- dblk\efidump.c
-+ dblk/dblkStrings.uni
-+ dblk/dblk.c
-+ dblk/efidump.c
-
-- devices\DevicesStrings.uni
-- devices\devices.c
-+ devices/DevicesStrings.uni
-+ devices/devices.c
-
-- devicetree\DevicetreeStrings.uni
-- devicetree\devicetree.c
-+ devicetree/DevicetreeStrings.uni
-+ devicetree/devicetree.c
-
-- dmem\MemStrings.uni
-- dmem\DebugStrings.uni
-- dmem\mem.c
-- dmem\MemCommonPart.c
-- dmem\efidump.c
-+ dmem/MemStrings.uni
-+ dmem/DebugStrings.uni
-+ dmem/mem.c
-+ dmem/MemCommonPart.c
-+ dmem/efidump.c
-
-- dmpstore\DmpstoreStrings.uni
-- dmpstore\dmpstore.c
-+ dmpstore/DmpstoreStrings.uni
-+ dmpstore/dmpstore.c
-
-- edit\EditStrings.uni
-- edit\main.c
-- edit\libFileBuffer.c
-- edit\libEditor.c
-- edit\libTitleBar.c
-- edit\libStatusBar.c
-- edit\libInputBar.c
-- edit\libMenuBar.c
-- edit\libMisc.c
-+ edit/EditStrings.uni
-+ edit/main.c
-+ edit/libFileBuffer.c
-+ edit/libEditor.c
-+ edit/libTitleBar.c
-+ edit/libStatusBar.c
-+ edit/libInputBar.c
-+ edit/libMenuBar.c
-+ edit/libMisc.c
-
-- eficompress\CompressStrings.uni
-- eficompress\compressMain.c
-- eficompress\compress.c
-+ eficompress/CompressStrings.uni
-+ eficompress/compressMain.c
-+ eficompress/compress.c
-
-- efidecompress\DecompressStrings.uni
-- efidecompress\decompress.c
-+ efidecompress/DecompressStrings.uni
-+ efidecompress/decompress.c
-
-- err\ErrStrings.uni
-- err\err.c
-+ err/ErrStrings.uni
-+ err/err.c
-
-- guid\GuidStrings.uni
-- guid\guid.c
-+ guid/GuidStrings.uni
-+ guid/guid.c
-
-- hexedit\HexeditStrings.uni
-- hexedit\main.c
-- hexedit\libBufferImage.c
-- hexedit\libFileImage.c
-- hexedit\libDiskImage.c
-- hexedit\libMemImage.c
-- hexedit\libEditor.c
-- hexedit\libTitleBar.c
-- hexedit\libStatusBar.c
-- hexedit\libInputBar.c
-- hexedit\libMenuBar.c
-- hexedit\libClipBoard.c
-- hexedit\libMisc.c
--
-- IfConfig\IfConfigStrings.uni
-- IfConfig\IfConfig.c
-- IfConfig\IfConfig.h
-- IfConfig\ShellNetHelper.c
--
-- ipconfig\IpConfigStrings.uni
-- ipconfig\IpConfig.c
-+ hexedit/HexeditStrings.uni
-+ hexedit/main.c
-+ hexedit/libBufferImage.c
-+ hexedit/libFileImage.c
-+ hexedit/libDiskImage.c
-+ hexedit/libMemImage.c
-+ hexedit/libEditor.c
-+ hexedit/libTitleBar.c
-+ hexedit/libStatusBar.c
-+ hexedit/libInputBar.c
-+ hexedit/libMenuBar.c
-+ hexedit/libClipBoard.c
-+ hexedit/libMisc.c
-+
-+ IfConfig/IfConfigStrings.uni
-+ IfConfig/IfConfig.c
-+ IfConfig/IfConfig.h
-+ IfConfig/ShellNetHelper.c
-+
-+ IpConfig/IpConfigStrings.uni
-+ IpConfig/IpConfig.c
-
-- loadpcirom\LoadPciRomStrings.uni
-- loadpcirom\LoadPciRom.c
-+ loadpcirom/LoadPciRomStrings.uni
-+ loadpcirom/LoadPciRom.c
-
-- mem\MemStrings.uni
-- mem\DebugStrings.uni
-- mem\mm.c
-- mem\MemCommonPart.c
-- mem\efidump.c
-+ mem/MemStrings.uni
-+ mem/DebugStrings.uni
-+ mem/mm.c
-+ mem/MemCommonPart.c
-+ mem/efidump.c
-
-- memmap\memmapStrings.uni
-- memmap\memmap.c
-+ memmap/memmapStrings.uni
-+ memmap/memmap.c
-
-- mm\MmStrings.uni
-- mm\mm.c
-+ mm/MmStrings.uni
-+ mm/mm.c
-
-- mode\ModeStrings.uni
-- mode\mode.c
-+ mode/ModeStrings.uni
-+ mode/mode.c
-
-- mount\MountStrings.uni
-- mount\mount.c
-+ mount/MountStrings.uni
-+ mount/mount.c
-
-- openinfo\OPeninfoStrings.uni
-- openinfo\openinfo.c
-+ openinfo/OPeninfoStrings.uni
-+ openinfo/openinfo.c
-
-- Ping\PingStrings.uni
-- Ping\Ping.c
-+ Ping/PingStrings.uni
-+ Ping/Ping.c
-
-- pci\PciStrings.uni
-- pci\pci.c
-- pci\pci_class.c
-+ pci/PciStrings.uni
-+ pci/pci.c
-+ pci/pci_class.c
-
-- sermode\SermodeStrings.uni
-- sermode\sermode.c
-+ sermode/SermodeStrings.uni
-+ sermode/sermode.c
-
-- smbiosview\SmBiosViewStrings.uni
-- smbiosview\QueryTable.c
-- smbiosview\EventLogInfo.c
-- smbiosview\PrintInfo.c
-- smbiosview\LibSmbiosView.c
-- smbiosview\smbiosview.c
-- smbiosview\smbios.c
-+ smbiosview/SmBiosViewStrings.uni
-+ smbiosview/QueryTable.c
-+ smbiosview/EventLogInfo.c
-+ smbiosview/PrintInfo.c
-+ smbiosview/LibSmbiosView.c
-+ smbiosview/smbiosview.c
-+ smbiosview/smbios.c
-
-- stall\stallStrings.uni
-- stall\stall.c
-+ stall/stallStrings.uni
-+ stall/stall.c
-
-- telnetmgmt\TelnetMgmtStrings.uni
-- telnetmgmt\TelnetMgmt.c
-+ telnetmgmt/TelnetMgmtStrings.uni
-+ telnetmgmt/TelnetMgmt.c
-
-- tzone\TZoneStrings.uni
-- tzone\tzone.c
-+ tzone/TZoneStrings.uni
-+ tzone/tzone.c
-
- [sources.ia32]
-- ver\ia32\ver32.c
-- Library\ia32\math.c
-- Library\ia32\initplat.c
-+ ver/IA32/ver32.c
-+ Library/IA32/math.c
-+ Library/IA32/initplat.c
-
- [sources.ipf]
-- ver\ipf\ver64.c
-- Library\ipf\math.c
-- Library\ipf\initplat.c
-- Library\ipf\palproc.s
-- Library\ipf\salpal.c
-+ ver/IPF/ver64.c
-+ Library/IPF/math.c
-+ Library/IPF/initplat.c
-+ Library/IPF/palproc.s
-+ Library/IPF/salpal.c
-
- [sources.EBC]
-- ver\ebc\verEbc.c
-- Library\EBC\math.c
-- Library\EBC\initplat.c
-+ ver/ebc/verEbc.c
-+ Library/Ebc/math.c
-+ Library/Ebc/initplat.c
-
- [sources.x64]
-- ver\ia32\ver32.c
-- Library\ipf\math.c
-- Library\ia32\initplat.c
-+ ver/IA32/ver32.c
-+ Library/IPF/math.c
-+ Library/IA32/initplat.c
-+
-+[sources.ARM]
-+ ver/ia32/ver32.c
-+ Library/IPF/math.c
-+ Library/IA32/initplat.c
-
- [includes.common]
- .
-- .\Inc
-- .\ver
-- .\Library
-- $(EDK_SOURCE)\Foundation
-- $(EDK_SOURCE)\Foundation\Include
-- $(EDK_SOURCE)\Foundation\Include\IndustryStandard
-- $(EDK_SOURCE)\Foundation\Efi
-- $(EDK_SOURCE)\Foundation\Efi\Include
-- $(EDK_SOURCE)\Foundation\FrameWork
-- $(EDK_SOURCE)\Foundation\FrameWork\Include
-- $(EDK_SOURCE)\Foundation\Core\Dxe
-- $(EDK_SOURCE)\Foundation\Library\Dxe\Include
-+ ./Inc
-+ ./ver
-+ ./Library
-+ $(EDK_SOURCE)/Foundation
-+ $(EDK_SOURCE)/Foundation/Include
-+ $(EDK_SOURCE)/Foundation/Include/IndustryStandard
-+ $(EDK_SOURCE)/Foundation/Efi
-+ $(EDK_SOURCE)/Foundation/Efi/Include
-+ $(EDK_SOURCE)/Foundation/FrameWork
-+ $(EDK_SOURCE)/Foundation/FrameWork/Include
-+ $(EDK_SOURCE)/Foundation/Core/Dxe
-+ $(EDK_SOURCE)/Foundation/Library/Dxe/Include
- $(DEST_DIR)
-
- [libraries.common]
-@@ -353,4 +358,4 @@ COMPONENT_TYPE = APPLICATION
- EBC_C_STD_FLAGS = $(EBC_C_STD_FLAGS) /DSTRING_DEFINES_FILE=\"$(BASE_NAME)StrDefs.h\"
-
-
--
-\ No newline at end of file
-+
-diff --git a/SmbiosView/EventLogInfo.c b/SmbiosView/EventLogInfo.c
-index 7f9b726..33e3549 100644
---- a/SmbiosView/EventLogInfo.c
-+++ b/SmbiosView/EventLogInfo.c
-@@ -25,7 +25,7 @@ Revision History
- #include "PrintInfo.h"
- #include "QueryTable.h"
- #include "EventLogInfo.h"
--#include "smbios.h"
-+#include "Smbios.h"
- #include STRING_DEFINES_FILE
-
- VOID
-diff --git a/SmbiosView/LibSmbiosView.c b/SmbiosView/LibSmbiosView.c
-index d31ed01..0fb51d5 100644
---- a/SmbiosView/LibSmbiosView.c
-+++ b/SmbiosView/LibSmbiosView.c
-@@ -22,10 +22,10 @@ Revision History
- --*/
-
- #include "EfiShellLib.h"
--#include "LIbSmbios.h"
-+#include "LibSmbios.h"
- #include "LibSmbiosView.h"
- #include "smbiosview.h"
--#include "smbios.h"
-+#include "Smbios.h"
- #include STRING_DEFINES_FILE
-
- STATIC UINT8 mInit = 0;
-@@ -62,7 +62,7 @@ Returns:
- //
- // Get SMBIOS table from System Configure table
- //
-- Status = LibGetSystemConfigurationTable (&gEfiSmbiosTableGuid, &mSmbiosTable);
-+ Status = LibGetSystemConfigurationTable (&gEfiSmbiosTableGuid, (VOID**)&mSmbiosTable);
-
- if (mSmbiosTable == NULL) {
- PrintToken (STRING_TOKEN (STR_SMBIOSVIEW_LIBSMBIOSVIEW_CANNOT_GET_TABLE), HiiHandle);
-diff --git a/SmbiosView/PrintInfo.c b/SmbiosView/PrintInfo.c
-index ff1f63c..1789ef6 100644
---- a/SmbiosView/PrintInfo.c
-+++ b/SmbiosView/PrintInfo.c
-@@ -26,7 +26,7 @@ Revision History
- #include "LibSmbiosView.h"
- #include "QueryTable.h"
- #include "EventLogInfo.h"
--#include "smbios.h"
-+#include "Smbios.h"
- #include STRING_DEFINES_FILE
-
- //
-diff --git a/SmbiosView/QueryTable.c b/SmbiosView/QueryTable.c
-index 4570938..1d9d60f 100644
---- a/SmbiosView/QueryTable.c
-+++ b/SmbiosView/QueryTable.c
-@@ -23,7 +23,7 @@ Revision History
- #include "EfiShellLib.h"
- #include "QueryTable.h"
- #include "PrintInfo.h"
--#include "smbios.h"
-+#include "Smbios.h"
-
- #include STRING_DEFINES_FILE
-
-diff --git a/SmbiosView/Smbiosview.inf b/SmbiosView/Smbiosview.inf
-index f9e8c0b..d65b676 100644
---- a/SmbiosView/Smbiosview.inf
-+++ b/SmbiosView/Smbiosview.inf
-@@ -25,7 +25,7 @@ FILE_GUID = 0F4C0280-B581-4940-AF19-D0CB5559CC95
- COMPONENT_TYPE = APPLICATION
-
- [sources.common]
-- ..\ShCommonStrings.uni
-+ ../ShCommonStrings.uni
- SmBiosViewStrings.uni
- QueryTable.c
- QueryTable.h
-@@ -43,19 +43,19 @@ COMPONENT_TYPE = APPLICATION
-
- [includes.common]
- .
-- ..\Inc
-- ..\Library
-- $(EDK_SOURCE)\Foundation
-- $(EDK_SOURCE)\Foundation\Include
-- $(EDK_SOURCE)\Foundation\Include\IndustryStandard
-- $(EDK_SOURCE)\Foundation\Efi
-- $(EDK_SOURCE)\Foundation\Efi\Include
-- $(EDK_SOURCE)\Foundation\FrameWork
-- $(EDK_SOURCE)\Foundation\FrameWork\Include
-- $(EDK_SOURCE)\Foundation\Core\Dxe
-- $(DEST_DIR)\
-- $(EFI_SOURCE)\Application\Shell\Inc
-- $(EFI_SOURCE)\Application\Shell\Library
-+ ../Inc
-+ ../Library
-+ $(EDK_SOURCE)/Foundation
-+ $(EDK_SOURCE)/Foundation/Include
-+ $(EDK_SOURCE)/Foundation/Include/IndustryStandard
-+ $(EDK_SOURCE)/Foundation/Efi
-+ $(EDK_SOURCE)/Foundation/Efi/Include
-+ $(EDK_SOURCE)/Foundation/FrameWork
-+ $(EDK_SOURCE)/Foundation/FrameWork/Include
-+ $(EDK_SOURCE)/Foundation/Core/Dxe
-+ $(DEST_DIR./
-+ $(EFI_SOURCE)/Applicatio./Shels/Inc
-+ $(EFI_SOURCE)/Applicatio./Shels/Library
-
- [libraries.common]
- EfiShellLib
-diff --git a/SmbiosView/smbiosview.c b/SmbiosView/smbiosview.c
-index 13b4fb7..397ed04 100644
---- a/SmbiosView/smbiosview.c
-+++ b/SmbiosView/smbiosview.c
-@@ -26,7 +26,7 @@ Revision History
- #include "smbiosview.h"
- #include "PrintInfo.h"
- #include "QueryTable.h"
--#include "smbios.h"
-+#include "Smbios.h"
-
- extern UINT8 STRING_ARRAY_NAME[];
-
-diff --git a/TelnetMgmt/TelnetMgmt.c b/TelnetMgmt/TelnetMgmt.c
-index 9d779df..5e097c9 100644
---- a/TelnetMgmt/TelnetMgmt.c
-+++ b/TelnetMgmt/TelnetMgmt.c
-@@ -32,7 +32,7 @@ extern UINT8 STRING_ARRAY_NAME[];
- //
- #include STRING_DEFINES_FILE
-
--EFI_HII_HANDLE HiiHandle;
-+STATIC EFI_HII_HANDLE HiiHandle;
- EFI_GUID EfiTelnetMgmtGuid = EFI_TELNETMGMT_GUID;
- EFI_GUID mEfiTelnetServerGuid = EFI_TELNET_SERVER_PROTOCOL_GUID;
- SHELL_VAR_CHECK_ITEM TelnetmgmtCheckList[] = {
-diff --git a/TelnetMgmt/TelnetMgmt.inf b/TelnetMgmt/TelnetMgmt.inf
-index ad8b8bd..6b0b571 100644
---- a/TelnetMgmt/TelnetMgmt.inf
-+++ b/TelnetMgmt/TelnetMgmt.inf
-@@ -25,23 +25,23 @@ FILE_GUID = 0C6282F4-F575-469d-BD55-7693AAC9D812
- COMPONENT_TYPE = APPLICATION
-
- [sources.common]
-- ..\ShCommonStrings.uni
-+ ../ShCommonStrings.uni
- TelnetMgmtStrings.uni
- TelnetMgmt.c
-
- [includes.common]
- .
-- ..\Inc
-- ..\Library
-- $(EDK_SOURCE)\Foundation
-- $(EDK_SOURCE)\Foundation\Include
-- $(EDK_SOURCE)\Foundation\Include\IndustryStandard
-- $(EDK_SOURCE)\Foundation\Efi
-- $(EDK_SOURCE)\Foundation\Efi\Include
-- $(EDK_SOURCE)\Foundation\FrameWork
-- $(EDK_SOURCE)\Foundation\FrameWork\Include
-- $(EDK_SOURCE)\Foundation\Core\Dxe
-- $(DEST_DIR)\
-+ ../Inc
-+ ../Library
-+ $(EDK_SOURCE)/Foundation
-+ $(EDK_SOURCE)/Foundation/Include
-+ $(EDK_SOURCE)/Foundation/Include/IndustryStandard
-+ $(EDK_SOURCE)/Foundation/Efi
-+ $(EDK_SOURCE)/Foundation/Efi/Include
-+ $(EDK_SOURCE)/Foundation/FrameWork
-+ $(EDK_SOURCE)/Foundation/FrameWork/Include
-+ $(EDK_SOURCE)/Foundation/Core/Dxe
-+ $(DEST_DIR./
-
- [libraries.common]
- EfiShellLib
-diff --git a/attrib/attrib.c b/attrib/attrib.c
-index 3599d6d..a597d9c 100644
---- a/attrib/attrib.c
-+++ b/attrib/attrib.c
-@@ -57,7 +57,7 @@ AttribFile (
- //
- // Global Variables
- //
--EFI_HII_HANDLE HiiHandle;
-+STATIC EFI_HII_HANDLE HiiHandle;
- EFI_GUID EfiAttribGuid = EFI_ATTRIB_GUID;
- SHELL_VAR_CHECK_ITEM AttribCheckList[] = {
- {
-@@ -438,7 +438,7 @@ Returns:
- //
- Info = Arg->Info;
- if (Add || Remove) {
-- Info->Attribute = Info->Attribute & (~Remove) | Add;
-+ Info->Attribute = (Info->Attribute & (~Remove)) | Add;
- Status = Arg->Handle->SetInfo (
- Arg->Handle,
- &gEfiFileInfoGuid,
-diff --git a/attrib/attrib.inf b/attrib/attrib.inf
-index 38cc094..a96ae55 100644
---- a/attrib/attrib.inf
-+++ b/attrib/attrib.inf
-@@ -41,24 +41,24 @@ COMPONENT_TYPE = APPLICATION
-
- [sources.common]
- AttribStrings.uni
-- ..\ShCommonStrings.uni
-+ ../ShCommonStrings.uni
- attrib.c
- attrib.h
-
-
- [includes.common]
- .
-- ..\Inc
-- ..\Library
-- $(EDK_SOURCE)\Foundation
-- $(EDK_SOURCE)\Foundation\Include
-- $(EDK_SOURCE)\Foundation\Include\IndustryStandard
-- $(EDK_SOURCE)\Foundation\Efi
-- $(EDK_SOURCE)\Foundation\Efi\Include
-- $(EDK_SOURCE)\Foundation\FrameWork
-- $(EDK_SOURCE)\Foundation\FrameWork\Include
-- $(EDK_SOURCE)\Foundation\Core\Dxe
-- $(DEST_DIR)\
-+ ../Inc
-+ ../Library
-+ $(EDK_SOURCE)/Foundation
-+ $(EDK_SOURCE)/Foundation/Include
-+ $(EDK_SOURCE)/Foundation/Include/IndustryStandard
-+ $(EDK_SOURCE)/Foundation/Efi
-+ $(EDK_SOURCE)/Foundation/Efi/Include
-+ $(EDK_SOURCE)/Foundation/FrameWork
-+ $(EDK_SOURCE)/Foundation/FrameWork/Include
-+ $(EDK_SOURCE)/Foundation/Core/Dxe
-+ $(DEST_DIR./
-
- [libraries.common]
- EfiShellLib
-diff --git a/cls/cls.c b/cls/cls.c
-index 572cc82..c1f4440 100644
---- a/cls/cls.c
-+++ b/cls/cls.c
-@@ -30,7 +30,7 @@ extern UINT8 STRING_ARRAY_NAME[];
+Index: cls/cls.c
+===================================================================
+--- cls/cls.c (revision 64)
++++ cls/cls.c (working copy)
+@@ -30,7 +30,7 @@
//
#include STRING_DEFINES_FILE
@@ -2360,11 +225,29 @@ index 572cc82..c1f4440 100644
EFI_GUID EfiClsGuid = EFI_CLS_GUID;
SHELL_VAR_CHECK_ITEM ClsCheckList[] = {
{
-diff --git a/cls/cls.inf b/cls/cls.inf
-index 1e5ef66..7d9e924 100644
---- a/cls/cls.inf
-+++ b/cls/cls.inf
-@@ -40,24 +40,24 @@ COMPONENT_TYPE = APPLICATION
+@@ -49,7 +49,7 @@
+ NULL,
+ 0,
+ 0,
+- 0
++ (SHELL_VAR_CHECK_FLAG_TYPE) 0
+ }
+ };
+
+Index: cls/cls.h
+===================================================================
+--- cls/cls.h (revision 64)
++++ cls/cls.h (working copy)
+@@ -36,3 +36,4 @@
+ }
+
+ #endif
++
+Index: cls/cls.inf
+===================================================================
+--- cls/cls.inf (revision 64)
++++ cls/cls.inf (working copy)
+@@ -40,24 +40,24 @@
[sources.common]
@@ -2401,155 +284,20 @@ index 1e5ef66..7d9e924 100644
[libraries.common]
EfiShellLib
-diff --git a/comp/comp.inf b/comp/comp.inf
-index 7a525e4..1da14bc 100644
---- a/comp/comp.inf
-+++ b/comp/comp.inf
-@@ -28,21 +28,21 @@ COMPONENT_TYPE = APPLICATION
- CompStrings.uni
- comp.c
- comp.h
--..\ShCommonStrings.uni
-+../ShCommonStrings.uni
-
- [includes.common]
- .
-- ..\Inc
-- ..\Library
-- $(EDK_SOURCE)\Foundation
-- $(EDK_SOURCE)\Foundation\Include
-- $(EDK_SOURCE)\Foundation\Include\IndustryStandard
-- $(EDK_SOURCE)\Foundation\Efi
-- $(EDK_SOURCE)\Foundation\Efi\Include
-- $(EDK_SOURCE)\Foundation\FrameWork
-- $(EDK_SOURCE)\Foundation\FrameWork\Include
-- $(EDK_SOURCE)\Foundation\Core\Dxe
-- $(DEST_DIR)\
-+ ../Inc
-+ ../Library
-+ $(EDK_SOURCE)/Foundation
-+ $(EDK_SOURCE)/Foundation/Include
-+ $(EDK_SOURCE)/Foundation/Include/IndustryStandard
-+ $(EDK_SOURCE)/Foundation/Efi
-+ $(EDK_SOURCE)/Foundation/Efi/Include
-+ $(EDK_SOURCE)/Foundation/FrameWork
-+ $(EDK_SOURCE)/Foundation/FrameWork/Include
-+ $(EDK_SOURCE)/Foundation/Core/Dxe
-+ $(DEST_DIR./
-
- [libraries.common]
- EfiShellLib
-diff --git a/cp/cp.c b/cp/cp.c
-index 25ac3cf..d79ed13 100644
---- a/cp/cp.c
-+++ b/cp/cp.c
-@@ -578,7 +578,7 @@ Returns:
- //
- if (SrcArg->Status == EFI_SUCCESS &&
- (SrcArg->Info->Attribute & EFI_FILE_DIRECTORY) &&
-- (DstArg->Status == EFI_SUCCESS && (DstArg->Info->Attribute & EFI_FILE_DIRECTORY) || DstMustDir && DstHandle)
-+ (DstArg->Status == EFI_SUCCESS && ((DstArg->Info->Attribute & EFI_FILE_DIRECTORY) || (DstMustDir && DstHandle)))
- ) {
- if (StrCmp (SrcFilePath, DstFilePath) == 0) {
- PrintToken (STRING_TOKEN (STR_CP_CANNOT_COPY_ITSELF), HiiCpyHandle, L"cp/copy", SrcArg->FullName);
-@@ -592,7 +592,7 @@ Returns:
- // we need to compose a full name of dir\file for the source
- //
- if (SrcArg->Status == EFI_SUCCESS &&
-- (DstArg->Status == EFI_SUCCESS && (DstArg->Info->Attribute & EFI_FILE_DIRECTORY) || DstMustDir && DstHandle)) {
-+ (DstArg->Status == EFI_SUCCESS && ((DstArg->Info->Attribute & EFI_FILE_DIRECTORY) || (DstMustDir && DstHandle)))) {
- if (DstFullName) {
- FreePool (DstFullName);
- }
-@@ -1789,7 +1789,7 @@ Returns:
- //
- if (SrcArg->Status == EFI_SUCCESS &&
- !(SrcArg->Info->Attribute & EFI_FILE_DIRECTORY) &&
-- (DstArg->Status == EFI_SUCCESS && (DstArg->Info->Attribute & EFI_FILE_DIRECTORY) || DstDir && DstHandle)
-+ (DstArg->Status == EFI_SUCCESS && ((DstArg->Info->Attribute & EFI_FILE_DIRECTORY) || (DstDir && DstHandle)))
- ) {
- if (DstFullName) {
- FreePool (DstFullName);
-diff --git a/cp/cp.inf b/cp/cp.inf
-index 714c7bb..7303b2f 100644
---- a/cp/cp.inf
-+++ b/cp/cp.inf
-@@ -41,23 +41,23 @@ COMPONENT_TYPE = APPLICATION
+Index: newshell/nshell.inf
+===================================================================
+--- newshell/nshell.inf (revision 64)
++++ newshell/nshell.inf (working copy)
+@@ -26,24 +26,24 @@
[sources.common]
- CpStrings.uni
+ NshellStrings.uni
- ..\ShCommonStrings.uni
+ ../ShCommonStrings.uni
- cp.h
- cp.c
-
- [includes.common]
- .
-- ..\Inc
-- ..\Library
-- $(EDK_SOURCE)\Foundation
-- $(EDK_SOURCE)\Foundation\Include
-- $(EDK_SOURCE)\Foundation\Include\IndustryStandard
-- $(EDK_SOURCE)\Foundation\Efi
-- $(EDK_SOURCE)\Foundation\Efi\Include
-- $(EDK_SOURCE)\Foundation\FrameWork
-- $(EDK_SOURCE)\Foundation\FrameWork\Include
-- $(EDK_SOURCE)\Foundation\Core\Dxe
-- $(DEST_DIR)\
-+ ../Inc
-+ ../Library
-+ $(EDK_SOURCE)/Foundation
-+ $(EDK_SOURCE)/Foundation/Include
-+ $(EDK_SOURCE)/Foundation/Include/IndustryStandard
-+ $(EDK_SOURCE)/Foundation/Efi
-+ $(EDK_SOURCE)/Foundation/Efi/Include
-+ $(EDK_SOURCE)/Foundation/FrameWork
-+ $(EDK_SOURCE)/Foundation/FrameWork/Include
-+ $(EDK_SOURCE)/Foundation/Core/Dxe
-+ $(DEST_DIR./
-
- [libraries.common]
- EfiShellLib
-diff --git a/date/date.c b/date/date.c
-index fb2f765..ff44740 100644
---- a/date/date.c
-+++ b/date/date.c
-@@ -53,8 +53,8 @@ STATIC
- BOOLEAN
- GetNumber (
- IN CHAR16 *Str,
-- IN OUT INTN *Position,
-- IN OUT INTN *Number,
-+ IN OUT UINTN *Position,
-+ IN OUT UINTN *Number,
- IN BOOLEAN EndNum
- );
-
-@@ -330,8 +330,8 @@ STATIC
- BOOLEAN
- GetNumber (
- IN CHAR16 *Str,
-- IN OUT INTN *Position,
-- IN OUT INTN *Number,
-+ IN OUT UINTN *Position,
-+ IN OUT UINTN *Number,
- IN BOOLEAN EndNum
- )
- {
-diff --git a/date/date.inf b/date/date.inf
-index 2c40f72..18cf117 100644
---- a/date/date.inf
-+++ b/date/date.inf
-@@ -40,24 +40,24 @@ COMPONENT_TYPE = APPLICATION
-
+ init.c
+ nshell.h
+ fakehii.c
- [sources.common]
-- ..\ShCommonStrings.uni
-+ ../ShCommonStrings.uni
- DateStrings.uni
- Date.c
- Date.h
-
[includes.common]
.
- ..\Inc
@@ -2577,123 +325,186 @@ index 2c40f72..18cf117 100644
[libraries.common]
EfiShellLib
-diff --git a/dblk/dblk.inf b/dblk/dblk.inf
-index f15392c..3324eb7 100644
---- a/dblk/dblk.inf
-+++ b/dblk/dblk.inf
-@@ -26,23 +26,23 @@ COMPONENT_TYPE = APPLICATION
+Index: newshell/FakeHii.c
+===================================================================
+--- newshell/FakeHii.c (revision 64)
++++ newshell/FakeHii.c (working copy)
+@@ -196,7 +196,7 @@
+ Status = BS->HandleProtocol (
+ mFakeHiiHandle,
+ &gEfiHiiProtocolGuid,
+- &FakeHii
++ (VOID**)&FakeHii
+ );
+ Status = BS->UninstallProtocolInterface (
+ mFakeHiiHandle,
+@@ -320,7 +320,7 @@
+ if (Language == NULL) {
+ return EFI_OUT_OF_RESOURCES;
+ }
+- strcpya (Language, (UINT8 *) PackageHdr + HeaderSize - LanguageSize);
++ strcpya (Language, (CHAR8*) ((UINT8 *) PackageHdr + HeaderSize - LanguageSize));
+ for (Link = PackageList->StringPkgHdr.Flink; Link != &PackageList->StringPkgHdr; Link = Link->Flink) {
+ StringPackage = CR (Link, FAKE_HII_STRING_PACKAGE, Entry, FAKE_HII_STRING_PACKAGE_SIGNATURE);
+ if (CompareLanguage (Language, StringPackage->StringPkgHdr->Language)) {
+@@ -770,7 +770,7 @@
+ StringPackage = NULL;
+ for (Link = DatabaseRecord->StringPkgHdr.Flink; Link != &DatabaseRecord->StringPkgHdr; Link = Link->Flink) {
+ StringPackage = CR (Link, FAKE_HII_STRING_PACKAGE, Entry, FAKE_HII_STRING_PACKAGE_SIGNATURE);
+- if (CompareLanguage (StringPackage->StringPkgHdr->Language, (UINT8 *) Language)) {
++ if (CompareLanguage (StringPackage->StringPkgHdr->Language, (CHAR8 *) Language)) {
+ Matched = TRUE;
+ break;
+ }
+Index: newshell/init.c
+===================================================================
+--- newshell/init.c (revision 64)
++++ newshell/init.c (working copy)
+@@ -23,7 +23,7 @@
+ #include "nshell.h"
- [sources.common]
- DblkStrings.uni
-- ..\ShCommonStrings.uni
-+ ../ShCommonStrings.uni
- dblk.c
- efidump.c
+ extern UINT8 STRING_ARRAY_NAME[];
+-extern BOOLEAN gHiiInitialized = FALSE;
++BOOLEAN gHiiInitialized = FALSE;
- [includes.common]
- .
-- ..\Inc
-- ..\Library
-- $(EDK_SOURCE)\Foundation
-- $(EDK_SOURCE)\Foundation\Include
-- $(EDK_SOURCE)\Foundation\Include\IndustryStandard
-- $(EDK_SOURCE)\Foundation\Efi
-- $(EDK_SOURCE)\Foundation\Efi\Include
-- $(EDK_SOURCE)\Foundation\FrameWork
-- $(EDK_SOURCE)\Foundation\FrameWork\Include
-- $(EDK_SOURCE)\Foundation\Core\Dxe
-- $(DEST_DIR)\
-+ ../Inc
-+ ../Library
-+ $(EDK_SOURCE)/Foundation
-+ $(EDK_SOURCE)/Foundation/Include
-+ $(EDK_SOURCE)/Foundation/Include/IndustryStandard
-+ $(EDK_SOURCE)/Foundation/Efi
-+ $(EDK_SOURCE)/Foundation/Efi/Include
-+ $(EDK_SOURCE)/Foundation/FrameWork
-+ $(EDK_SOURCE)/Foundation/FrameWork/Include
-+ $(EDK_SOURCE)/Foundation/Core/Dxe
-+ $(DEST_DIR./
+ //
+ // This is the generated header file which includes whatever needs to be exported (strings + IFR)
+@@ -99,13 +99,13 @@
+ Status = BS->HandleProtocol (
+ ImgHnd,
+ &gEfiLoadedImageProtocolGuid,
+- &img
++ (VOID**)&img
+ );
+ if (!EFI_ERROR (Status)) {
+ Status = BS->HandleProtocol (
+ img->DeviceHandle,
+ &gEfiDevicePathProtocolGuid,
+- &dp
++ (VOID**)&dp
+ );
+ if (!EFI_ERROR (Status)) {
+ *DevPath = DuplicateDevicePath (dp);
+@@ -220,7 +220,7 @@
+ //
+ Status = LibLocateProtocol (
+ &gEfiConsoleControlProtocolGuid,
+- &ConsoleControl
++ (VOID**)&ConsoleControl
+ );
+ if (!EFI_ERROR (Status)) {
+ Status = ConsoleControl->GetMode (ConsoleControl, &mOldCurrentMode, NULL, NULL);
+@@ -342,7 +342,7 @@
+ Status = _ShellLoadEnvDriver (ImageHandle);
+ )
+ if (EFI_ERROR (Status)) {
+- Status = LibLocateProtocol (&ShellEnvProtocol, &SE);
++ Status = LibLocateProtocol (&ShellEnvProtocol, (VOID**)&SE);
+ if (EFI_ERROR (Status)) {
+ PrintToken (STRING_TOKEN (STR_NSHELL_ENV_DRIVER), HiiNewshellHandle);
+ return Status;
+@@ -372,7 +372,7 @@
+ *IsRootInstance = TRUE;
+ }
- [libraries.common]
- EfiShellLib
-diff --git a/dblk/efidump.c b/dblk/efidump.c
-index 7fc0337..758326e 100644
---- a/dblk/efidump.c
-+++ b/dblk/efidump.c
-@@ -24,7 +24,7 @@ Revision History
- --*/
+- Status = LibLocateProtocol (&ShellEnvProtocol, &SE);
++ Status = LibLocateProtocol (&ShellEnvProtocol, (VOID**)&SE);
+ ASSERT (!EFI_ERROR (Status));
+ SI = SE->NewShell (ImageHandle);
- #include "dblk.h"
--#include "Efipart.h"
-+#include "EfiPart.h"
- #include "EfiShellLib.h"
+@@ -543,7 +543,7 @@
+ //
+ ConsoleControlStatus = LibLocateProtocol (
+ &gEfiConsoleControlProtocolGuid,
+- &ConsoleControl
++ (VOID**)&ConsoleControl
+ );
+ if (!EFI_ERROR (ConsoleControlStatus)) {
+ ConsoleControlStatus = ConsoleControl->GetMode (ConsoleControl, &CurrentMode, NULL, NULL);
+@@ -709,7 +709,7 @@
+ //
+ SE2->IncrementShellNestingLevel ();
- #include STRING_DEFINES_FILE
-@@ -352,8 +352,8 @@ DblkDumpSystemTable (
- PrintToken (STRING_TOKEN (STR_DEBUG_STD_ERROR_ON), HiiDblkHandle, LibDevicePathToStr (DevicePath));
- }
+- while (Status != -1) {
++ while (Status != (EFI_STATUS) -1) {
+ Status = NShellPrompt (ImageHandle);
+ EFI_NT_EMULATOR_CODE (
+ //
+@@ -723,7 +723,7 @@
+ Status = BS->HandleProtocol (
+ ImageHandle,
+ &ShellInterfaceProtocol,
+- &SI
++ (VOID**)&SI
+ );
+ ASSERT (!EFI_ERROR (Status));
+ }
+Index: newshell/FakeHii.h
+===================================================================
+--- newshell/FakeHii.h (revision 64)
++++ newshell/FakeHii.h (working copy)
+@@ -479,3 +479,4 @@
+ #endif
-- PrintToken (STRING_TOKEN (STR_DEBUG_RUNTIME_SERVICES), HiiDblkHandle, (UINT64) Tbl.Sys->RuntimeServices);
-- PrintToken (STRING_TOKEN (STR_DEBUG_BOOT_SERVICES), HiiDblkHandle, (UINT64) Tbl.Sys->BootServices);
-+ PrintToken (STRING_TOKEN (STR_DEBUG_RUNTIME_SERVICES), HiiDblkHandle, (UINT64)(UINTN) Tbl.Sys->RuntimeServices);
-+ PrintToken (STRING_TOKEN (STR_DEBUG_BOOT_SERVICES), HiiDblkHandle, (UINT64)(UINTN) Tbl.Sys->BootServices);
+ #endif
++
+Index: newshell/nshell.h
+===================================================================
+--- newshell/nshell.h (revision 64)
++++ newshell/nshell.h (working copy)
+@@ -58,4 +58,5 @@
+ #define EFI_NO_MONOSHELL_CODE(code) code
+ #endif
- EFI64_CODE (
- Status = LibGetSystemConfigurationTable(&gEfiSalSystemTableGuid, &SalSystemTable);
-@@ -364,22 +364,22 @@ DblkDumpSystemTable (
+-#endif
+\ No newline at end of file
++#endif
++
+Index: type/type.c
+===================================================================
+--- type/type.c (revision 64)
++++ type/type.c (working copy)
+@@ -59,7 +59,7 @@
+ BOOLEAN TypeUnicode;
+ BOOLEAN TypeAuto;
- Status = LibGetSystemConfigurationTable (&gEfiAcpiTableGuid, &AcpiTable);
- if (!EFI_ERROR (Status)) {
-- PrintToken (STRING_TOKEN (STR_DEBUG_ACPI_TABLE), HiiDblkHandle, (UINT64) AcpiTable);
-+ PrintToken (STRING_TOKEN (STR_DEBUG_ACPI_TABLE), HiiDblkHandle, (UINT64)(UINTN) AcpiTable);
+-EFI_HII_HANDLE HiiHandle;
++STATIC EFI_HII_HANDLE HiiHandle;
+ EFI_GUID EfiTypeGuid = EFI_TYPE_GUID;
+ SHELL_VAR_CHECK_ITEM TypeCheckList[] = {
+ {
+@@ -90,7 +90,7 @@
+ NULL,
+ 0,
+ 0,
+- 0
++ (SHELL_VAR_CHECK_FLAG_TYPE) 0
}
+ };
- Status = LibGetSystemConfigurationTable (&gEfiAcpi20TableGuid, &Acpi20Table);
- if (!EFI_ERROR (Status)) {
-- PrintToken (STRING_TOKEN (STR_DEBUG_APCI_2_TABLE), HiiDblkHandle, (UINT64) Acpi20Table);
-+ PrintToken (STRING_TOKEN (STR_DEBUG_APCI_2_TABLE), HiiDblkHandle, (UINT64)(UINTN) Acpi20Table);
+Index: type/type.h
+===================================================================
+--- type/type.h (revision 64)
++++ type/type.h (working copy)
+@@ -30,3 +30,4 @@
}
- Status = LibGetSystemConfigurationTable (&gEfiMpsTableGuid, &MpsTable);
- if (!EFI_ERROR (Status)) {
-- PrintToken (STRING_TOKEN (STR_DEBUG_MPS_TABLE), HiiDblkHandle, (UINT64) MpsTable);
-+ PrintToken (STRING_TOKEN (STR_DEBUG_MPS_TABLE), HiiDblkHandle, (UINT64)(UINTN) MpsTable);
- }
+ #endif
++
+Index: type/type.inf
+===================================================================
+--- type/type.inf (revision 64)
++++ type/type.inf (working copy)
+@@ -40,24 +40,24 @@
- Status = LibGetSystemConfigurationTable (&gEfiSmbiosTableGuid, &SMBIOSTable);
- if (!EFI_ERROR (Status)) {
-- PrintToken (STRING_TOKEN (STR_DEBUG_SMBIOS_TABLE), HiiDblkHandle, (UINT64) SMBIOSTable);
-+ PrintToken (STRING_TOKEN (STR_DEBUG_SMBIOS_TABLE), HiiDblkHandle, (UINT64)(UINTN) SMBIOSTable);
- }
- }
-
-diff --git a/devices/devices.c b/devices/devices.c
-index bcc8beb..56808a4 100644
---- a/devices/devices.c
-+++ b/devices/devices.c
-@@ -36,7 +36,7 @@ extern UINT8 STRING_ARRAY_NAME[];
- //
- // Global Variables
- //
--EFI_HII_HANDLE HiiHandle;
-+STATIC EFI_HII_HANDLE HiiHandle;
- EFI_GUID EfiDevicesGuid = EFI_DEVICES_GUID;
- SHELL_VAR_CHECK_ITEM DevicesCheckList[] = {
- {
-diff --git a/devices/devices.inf b/devices/devices.inf
-index c380f7d..d25b7ab 100644
---- a/devices/devices.inf
-+++ b/devices/devices.inf
-@@ -41,23 +41,23 @@ COMPONENT_TYPE = APPLICATION
[sources.common]
- DevicesStrings.uni
-- ..\ShCommonStrings.uni
-+ ../ShCommonStrings.uni
- devices.c
- devices.h
-
+- ..\ShCommonStrings.uni
++ ../ShCommonStrings.uni
+ TypeStrings.uni
+ type.c
+ type.h
+
[includes.common]
.
- ..\Inc
@@ -2721,11 +532,20 @@ index c380f7d..d25b7ab 100644
[libraries.common]
EfiShellLib
-diff --git a/dmem/MemCommonPart.c b/dmem/MemCommonPart.c
-index 377da17..0b56a02 100644
---- a/dmem/MemCommonPart.c
-+++ b/dmem/MemCommonPart.c
-@@ -148,7 +148,7 @@ Return:
+Index: dmem/MemCommonPart.c
+===================================================================
+--- dmem/MemCommonPart.c (revision 64)
++++ dmem/MemCommonPart.c (working copy)
+@@ -58,7 +58,7 @@
+ NULL,
+ 0,
+ 0,
+- 0
++ (SHELL_VAR_CHECK_FLAG_TYPE) 0
+ }
+ };
+
+@@ -148,7 +148,7 @@
return EFI_SUCCESS;
}
@@ -2734,7 +554,7 @@ index 377da17..0b56a02 100644
Size = (SizeStr) ? Xtoi (SizeStr) : 512;
//
-@@ -156,7 +156,7 @@ Return:
+@@ -156,7 +156,7 @@
//
PrintToken (STRING_TOKEN (STR_DMEM_MEMORY_ADDR), HiiDmemHandle, 2 * sizeof (UINTN), Address, Size);
if (MMIo) {
@@ -2743,7 +563,16 @@ index 377da17..0b56a02 100644
if (EFI_ERROR (Status)) {
PrintToken (STRING_TOKEN (STR_SHELLENV_GNC_LOC_PROT_ERR_EX), HiiDmemHandle, L"dmem", L"PciRootBridgeIo");
return Status;
-@@ -233,7 +233,7 @@ Return:
+@@ -171,7 +171,7 @@
+ return Status;
+ }
+
+- PciRootBridgeIo->Mem.Read (PciRootBridgeIo, EfiPciIoWidthUint8, Address, Size, Buffer);
++ PciRootBridgeIo->Mem.Read (PciRootBridgeIo, EfiPciWidthUint8, Address, Size, Buffer);
+ } else {
+ Buffer = (UINT8 *) (UINTN) Address;
+ }
+@@ -233,7 +233,7 @@
//
MMIo = FALSE;
AddressStr = SizeStr = NULL;
@@ -2752,7 +581,7 @@ index 377da17..0b56a02 100644
Size = 512;
RetCode = LibCheckVariables (SI, DmemCheckList, &ChkPck, &Useful);
if (VarCheckOk != RetCode) {
-@@ -316,7 +316,7 @@ Return:
+@@ -316,7 +316,7 @@
//
PrintToken (STRING_TOKEN (STR_DMEM_NEW_MEMORY_ADDR), HiiDmemHandle, 2 * sizeof (UINTN), Address, Size);
if (MMIo) {
@@ -2761,53 +590,31 @@ index 377da17..0b56a02 100644
if (EFI_ERROR (Status)) {
PrintToken (STRING_TOKEN (STR_SHELLENV_GNC_LOC_PROT_ERR_EX), HiiDmemHandle, L"dmem", L"PciRootBridgeIo");
return Status;
-diff --git a/dmem/dmem.inf b/dmem/dmem.inf
-index ca0dcaf..3360314 100644
---- a/dmem/dmem.inf
-+++ b/dmem/dmem.inf
-@@ -25,7 +25,7 @@ FILE_GUID = 644E259E-FF88-4d31-8092-B99D8777F1C4
- COMPONENT_TYPE = APPLICATION
+@@ -331,7 +331,7 @@
+ return Status;
+ }
- [sources.common]
-- ..\ShCommonStrings.uni
-+ ../ShCommonStrings.uni
- MemStrings.uni
- DebugStrings.uni
- mem.c
-@@ -34,17 +34,17 @@ COMPONENT_TYPE = APPLICATION
-
- [includes.common]
- .
-- ..\Inc
-- ..\Library
-- $(EDK_SOURCE)\Foundation
-- $(EDK_SOURCE)\Foundation\Include
-- $(EDK_SOURCE)\Foundation\Include\IndustryStandard
-- $(EDK_SOURCE)\Foundation\Efi
-- $(EDK_SOURCE)\Foundation\Efi\Include
-- $(EDK_SOURCE)\Foundation\FrameWork
-- $(EDK_SOURCE)\Foundation\FrameWork\Include
-- $(EDK_SOURCE)\Foundation\Core\Dxe
-- $(DEST_DIR)\
-+ ../Inc
-+ ../Library
-+ $(EDK_SOURCE)/Foundation
-+ $(EDK_SOURCE)/Foundation/Include
-+ $(EDK_SOURCE)/Foundation/Include/IndustryStandard
-+ $(EDK_SOURCE)/Foundation/Efi
-+ $(EDK_SOURCE)/Foundation/Efi/Include
-+ $(EDK_SOURCE)/Foundation/FrameWork
-+ $(EDK_SOURCE)/Foundation/FrameWork/Include
-+ $(EDK_SOURCE)/Foundation/Core/Dxe
-+ $(DEST_DIR./
+- PciRootBridgeIo->Mem.Read (PciRootBridgeIo, EfiPciIoWidthUint8, Address, Size, Buffer);
++ PciRootBridgeIo->Mem.Read (PciRootBridgeIo, EfiPciWidthUint8, Address, Size, Buffer);
+ } else {
+ Buffer = (UINT8 *) (UINTN) Address;
+ }
+Index: dmem/MemCommonPart.h
+===================================================================
+--- dmem/MemCommonPart.h (revision 64)
++++ dmem/MemCommonPart.h (working copy)
+@@ -61,4 +61,4 @@
+ IN EFI_BLOCK_IO_PROTOCOL *BlkIo
+ );
- [libraries.common]
- EfiShellLib
-diff --git a/dmem/efidump.c b/dmem/efidump.c
-index 051f6a0..25bd880 100644
---- a/dmem/efidump.c
-+++ b/dmem/efidump.c
-@@ -24,7 +24,7 @@ Revision History
+-#endif
+\ No newline at end of file
++#endif
+Index: dmem/efidump.c
+===================================================================
+--- dmem/efidump.c (revision 64)
++++ dmem/efidump.c (working copy)
+@@ -24,7 +24,7 @@
--*/
#include "debug.h"
@@ -2816,7 +623,21 @@ index 051f6a0..25bd880 100644
#include "EfiShellLib.h"
#include STRING_DEFINES_FILE
-@@ -352,8 +352,8 @@ DumpSystemTable (
+@@ -320,13 +320,11 @@
+ VOID *AcpiTable;
+ VOID *Acpi20Table;
+ VOID *SMBIOSTable;
+- VOID *SalSystemTable;
+ VOID *MpsTable;
+
+ AcpiTable = NULL;
+ Acpi20Table = NULL;
+ SMBIOSTable = NULL;
+- SalSystemTable = NULL;
+ MpsTable = NULL;
+
+ PrintToken (
+@@ -352,11 +350,13 @@
PrintToken (STRING_TOKEN (STR_DEBUG_STD_ERROR_ON), HiiDmemHandle, LibDevicePathToStr (DevicePath));
}
@@ -2826,8 +647,14 @@ index 051f6a0..25bd880 100644
+ PrintToken (STRING_TOKEN (STR_DEBUG_BOOT_SERVICES), HiiDmemHandle, (UINT64)(UINTN) Tbl.Sys->BootServices);
EFI64_CODE (
- Status = LibGetSystemConfigurationTable(&gEfiSalSystemTableGuid, &SalSystemTable);
-@@ -364,22 +364,22 @@ DumpSystemTable (
+- Status = LibGetSystemConfigurationTable(&gEfiSalSystemTableGuid, &SalSystemTable);
++ VOID *SalSystemTable;
++
++ Status = LibGetSystemConfigurationTable(&gEfiSalSystemTableGuid, &SalSystemTable);
+ if (!EFI_ERROR(Status)) {
+ PrintToken (STRING_TOKEN(STR_DEBUG_SAL_SYSTEM_TABLE), HiiDmemHandle, (UINT64)SalSystemTable);
+ }
+@@ -364,22 +364,22 @@
Status = LibGetSystemConfigurationTable (&gEfiAcpiTableGuid, &AcpiTable);
if (!EFI_ERROR (Status)) {
@@ -2854,32 +681,29 @@ index 051f6a0..25bd880 100644
}
}
-diff --git a/dmpstore/dmpstore.c b/dmpstore/dmpstore.c
-index 403e190..4cf7386 100644
---- a/dmpstore/dmpstore.c
-+++ b/dmpstore/dmpstore.c
-@@ -102,7 +102,7 @@ SetFileVariable (
- //
- // Global Variables
- //
--EFI_HII_HANDLE HiiHandle;
-+STATIC EFI_HII_HANDLE HiiHandle;
- EFI_GUID EfiDmpstoreGuid = EFI_DMPSTORE_GUID;
- SHELL_VAR_CHECK_ITEM DmpstoreCheckList[] = {
- {
-diff --git a/dmpstore/dmpstore.inf b/dmpstore/dmpstore.inf
-index f380759..923c24a 100644
---- a/dmpstore/dmpstore.inf
-+++ b/dmpstore/dmpstore.inf
-@@ -25,24 +25,24 @@ FILE_GUID = 7185D15A-A0AE-4dd1-A58F-C6EAD28EC9A8
+Index: dmem/debug.h
+===================================================================
+--- dmem/debug.h (revision 64)
++++ dmem/debug.h (working copy)
+@@ -156,3 +156,4 @@
+ extern EFI_HII_HANDLE HiiDmemHandle;
+
+ #endif
++
+Index: dmem/dmem.inf
+===================================================================
+--- dmem/dmem.inf (revision 64)
++++ dmem/dmem.inf (working copy)
+@@ -25,7 +25,7 @@
COMPONENT_TYPE = APPLICATION
[sources.common]
- ..\ShCommonStrings.uni
+ ../ShCommonStrings.uni
- DmpstoreStrings.uni
- dmpstore.c
- dmpstore.h
+ MemStrings.uni
+ DebugStrings.uni
+ mem.c
+@@ -34,17 +34,17 @@
[includes.common]
.
@@ -2908,34 +732,50 @@ index f380759..923c24a 100644
[libraries.common]
EfiShellLib
-diff --git a/drivers/drivers.c b/drivers/drivers.c
-index 0c6cfc0..50629ab 100644
---- a/drivers/drivers.c
-+++ b/drivers/drivers.c
-@@ -43,7 +43,7 @@ extern UINT8 STRING_ARRAY_NAME[];
+Index: devices/devices.c
+===================================================================
+--- devices/devices.c (revision 64)
++++ devices/devices.c (working copy)
+@@ -36,7 +36,7 @@
//
// Global Variables
//
-EFI_HII_HANDLE HiiHandle;
+STATIC EFI_HII_HANDLE HiiHandle;
- EFI_GUID EfiDriversGuid = EFI_DRIVERS_GUID;
- SHELL_VAR_CHECK_ITEM DriversCheckList[] = {
+ EFI_GUID EfiDevicesGuid = EFI_DEVICES_GUID;
+ SHELL_VAR_CHECK_ITEM DevicesCheckList[] = {
{
-diff --git a/drivers/drivers.inf b/drivers/drivers.inf
-index befa6cd..e4331cf 100644
---- a/drivers/drivers.inf
-+++ b/drivers/drivers.inf
-@@ -40,7 +40,7 @@ COMPONENT_TYPE = APPLICATION
-
+@@ -61,7 +61,7 @@
+ NULL,
+ 0,
+ 0,
+- 0
++ (SHELL_VAR_CHECK_FLAG_TYPE) 0
+ }
+ };
+
+Index: devices/devices.h
+===================================================================
+--- devices/devices.h (revision 64)
++++ devices/devices.h (working copy)
+@@ -32,3 +32,4 @@
+ 0x6fabed98, 0x2a7, 0x46a4, 0x84, 0xd1, 0x76, 0xcd, 0x5c, 0x49, 0x78, 0x74 \
+ }
+ #endif
++
+Index: devices/devices.inf
+===================================================================
+--- devices/devices.inf (revision 64)
++++ devices/devices.inf (working copy)
+@@ -41,23 +41,23 @@
[sources.common]
+ DevicesStrings.uni
- ..\ShCommonStrings.uni
+ ../ShCommonStrings.uni
- DriversStrings.uni
- drivers.c
- drivers.h
-@@ -48,17 +48,17 @@ COMPONENT_TYPE = APPLICATION
-
+ devices.c
+ devices.h
+
[includes.common]
.
- ..\Inc
@@ -2963,33 +803,53 @@ index befa6cd..e4331cf 100644
[libraries.common]
EfiShellLib
-diff --git a/drvcfg/drvcfg.c b/drvcfg/drvcfg.c
-index b604432..1190081 100644
---- a/drvcfg/drvcfg.c
-+++ b/drvcfg/drvcfg.c
-@@ -38,7 +38,7 @@ extern UINT8 STRING_ARRAY_NAME[];
+Index: mv/mv.c
+===================================================================
+--- mv/mv.c (revision 64)
++++ mv/mv.c (working copy)
+@@ -36,7 +36,7 @@
//
// Global Variables
//
-EFI_HII_HANDLE HiiHandle;
+STATIC EFI_HII_HANDLE HiiHandle;
- EFI_GUID EfiDrvcfgGuid = EFI_DRVCFG_GUID;
- SHELL_VAR_CHECK_ITEM DrvcfgCheckList[] = {
+ EFI_GUID EfiMvGuid = EFI_MV_GUID;
+ SHELL_VAR_CHECK_ITEM MvCheckList[] = {
{
-diff --git a/drvcfg/drvcfg.inf b/drvcfg/drvcfg.inf
-index 71b2778..86e80dc 100644
---- a/drvcfg/drvcfg.inf
-+++ b/drvcfg/drvcfg.inf
-@@ -40,24 +40,24 @@ COMPONENT_TYPE = APPLICATION
+@@ -55,7 +55,7 @@
+ NULL,
+ 0,
+ 0,
+- 0
++ (SHELL_VAR_CHECK_FLAG_TYPE) 0
+ }
+ };
+
+Index: mv/mv.h
+===================================================================
+--- mv/mv.h (revision 64)
++++ mv/mv.h (working copy)
+@@ -33,4 +33,4 @@
+
+ #define EFI_FILE_STRING_SIZE 260
+
+-#endif
+\ No newline at end of file
++#endif
+Index: mv/mv.inf
+===================================================================
+--- mv/mv.inf (revision 64)
++++ mv/mv.inf (working copy)
+@@ -40,24 +40,24 @@
[sources.common]
-- ..\ShCommonStrings.uni
-+ ../ShCommonStrings.uni
- DrvcfgStrings.uni
- drvcfg.c
- drvcfg.h
-
+- ..\ShCommonStrings.uni
++ ../ShCommonStrings.uni
+ MvStrings.uni
+ mv.c
+ mv.h
+
[includes.common]
.
- ..\Inc
@@ -3017,34 +877,112 @@ index 71b2778..86e80dc 100644
[libraries.common]
EfiShellLib
-diff --git a/drvdiag/drvdiag.c b/drvdiag/drvdiag.c
-index 3a9435c..4c20f09 100644
---- a/drvdiag/drvdiag.c
-+++ b/drvdiag/drvdiag.c
-@@ -41,7 +41,7 @@ extern UINT8 STRING_ARRAY_NAME[];
- //
- // Global Variables
- //
--EFI_HII_HANDLE HiiHandle;
-+STATIC EFI_HII_HANDLE HiiHandle;
- EFI_GUID EfiDrvdiagGuid = EFI_DRVDIAG_GUID;
- SHELL_VAR_CHECK_ITEM DrvdiagCheckList[] = {
- {
-diff --git a/drvdiag/drvdiag.inf b/drvdiag/drvdiag.inf
-index f27c238..493de6e 100644
---- a/drvdiag/drvdiag.inf
-+++ b/drvdiag/drvdiag.inf
-@@ -40,7 +40,7 @@ COMPONENT_TYPE = APPLICATION
+Index: unload/unload.c
+===================================================================
+--- unload/unload.c (revision 64)
++++ unload/unload.c (working copy)
+@@ -66,7 +66,7 @@
+ NULL,
+ 0,
+ 0,
+- 0
++ (SHELL_VAR_CHECK_FLAG_TYPE) 0
+ }
+ };
+
+@@ -110,7 +110,7 @@
+ *DriverName = LibDevicePathToStr (Image->FilePath);
+ }
+ } else {
+- LibGetDriverName(DriverBindingHandle, Language, DriverName);
++ LibGetDriverName(DriverBindingHandle, (CHAR8*)Language, DriverName);
+ }
+
+ return EFI_SUCCESS;
+@@ -184,7 +184,7 @@
+
+ DevicePath = NULL;
+ BestDeviceName = NULL;
+- Status = BS->HandleProtocol (Handle, &gEfiDevicePathProtocolGuid, &DevicePath);
++ Status = BS->HandleProtocol (Handle, &gEfiDevicePathProtocolGuid, (VOID**)&DevicePath);
+ Print (L"\n");
+ PrintToken (STRING_TOKEN (STR_UNLOAD_CONTROLLER_NAME), HiiUnloadHandle);
+@@ -242,14 +242,14 @@
+ Image = FALSE;
+ Status = _UnloadGetDriverName (
+ DriverBindingHandleBuffer[Index],
+- Language,
++ (UINT8*)Language,
+ FALSE,
+ &DriverName
+ );
+ if (DriverName == NULL) {
+ Status = _UnloadGetDriverName (
+ DriverBindingHandleBuffer[Index],
+- Language,
++ (UINT8*)Language,
+ TRUE,
+ &DriverName
+ );
+@@ -436,7 +436,7 @@
+
+ Status = _UnloadGetDriverName (
+ Handle,
+- Language,
++ (UINT8*)Language,
+ FALSE,
+ &DriverName
+ );
+@@ -450,7 +450,7 @@
+
+ Status = _UnloadGetDriverName (
+ Handle,
+- Language,
++ (UINT8*)Language,
+ TRUE,
+ &DriverName
+ );
+@@ -628,7 +628,7 @@
+
+ if (Prot->Handles[Index] == Handle) {
+ Dump = Verbose ? Prot->DumpInfo : Prot->DumpToken;
+- Status = BS->HandleProtocol (Handle, &Prot->ProtocolId, &Interface);
++ Status = BS->HandleProtocol (Handle, &Prot->ProtocolId, (VOID**)&Interface);
+ if (!EFI_ERROR (Status)) {
+ if (Verbose) {
+ for (Index1 = 0; Index1 < ProtocolBufferCount; Index1++) {
+@@ -676,7 +676,7 @@
+ goto Done;
+ }
+
+- Status = BS->HandleProtocol (Handle, ProtocolBuffer[Index1], &Interface);
++ Status = BS->HandleProtocol (Handle, ProtocolBuffer[Index1], (VOID**)&Interface);
+ if (!EFI_ERROR (Status)) {
+ PrintToken (STRING_TOKEN (STR_UNLOAD_TWO_VARS_HG_NEW), HiiUnloadHandle, ProtocolBuffer[Index1], Interface);
+ }
+Index: unload/unload.h
+===================================================================
+--- unload/unload.h (revision 64)
++++ unload/unload.h (working copy)
+@@ -36,3 +36,4 @@
+ }
+
+ #endif
++
+Index: unload/unload.inf
+===================================================================
+--- unload/unload.inf (revision 64)
++++ unload/unload.inf (working copy)
+@@ -39,23 +39,23 @@
+ COMPONENT_TYPE = APPLICATION
[sources.common]
- ..\ShCommonStrings.uni
+ ../ShCommonStrings.uni
- DrvdiagStrings.uni
- drvdiag.c
- drvdiag.h
-@@ -48,17 +48,17 @@ COMPONENT_TYPE = APPLICATION
-
+ UnloadStrings.uni
+ unload.c
+
[includes.common]
.
- ..\Inc
@@ -3072,21 +1010,20 @@ index f27c238..493de6e 100644
[libraries.common]
EfiShellLib
-diff --git a/edit/edit.inf b/edit/edit.inf
-index 0a48e87..5eba5a4 100644
---- a/edit/edit.inf
-+++ b/edit/edit.inf
-@@ -25,7 +25,7 @@ FILE_GUID = 51A60577-F1F6-444a-A372-244BED272023
- COMPONENT_TYPE = APPLICATION
+Index: mode/mode.inf
+===================================================================
+--- mode/mode.inf (revision 64)
++++ mode/mode.inf (working copy)
+@@ -40,24 +40,24 @@
- [sources.common]
-- ..\ShCommonStrings.uni
-+ ../ShCommonStrings.uni
- EditStrings.uni
- editor.h
- editortype.h
-@@ -41,17 +41,17 @@ COMPONENT_TYPE = APPLICATION
+ [sources.common]
+- ..\ShCommonStrings.uni
++ ../ShCommonStrings.uni
+ ModeStrings.uni
+ mode.c
+ mode.h
+
[includes.common]
.
- ..\Inc
@@ -3114,328 +1051,117 @@ index 0a48e87..5eba5a4 100644
[libraries.common]
EfiShellLib
-diff --git a/edit/editor.h b/edit/editor.h
-index c18db6a..2dd106b 100644
---- a/edit/editor.h
-+++ b/edit/editor.h
-@@ -33,7 +33,7 @@ Abstract:
- #include "libstatusbar.h"
- #include "libinputbar.h"
- #include "libmenubar.h"
--#include "libmisc.h"
-+#include "libMisc.h"
- //
- // This is the generated header file which includes whatever needs to be exported (strings + IFR)
- //
-@@ -43,7 +43,7 @@ extern EFI_EDITOR_GLOBAL_EDITOR MainEditor;
- extern BOOLEAN EditorFirst;
- extern BOOLEAN EditorExit;
-
--extern EFI_HII_HANDLE HiiHandle;
-+extern EFI_HII_HANDLE gEditHiiHandle;
- #if (EFI_SPECIFICATION_VERSION < 0x0002000A)
- extern EFI_HII_PROTOCOL *Hii;
- #endif
-diff --git a/edit/editortype.h b/edit/editortype.h
-index 674f120..df800dc 100644
---- a/edit/editortype.h
-+++ b/edit/editortype.h
-@@ -28,7 +28,7 @@ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
- #define EDITOR_NAME L"EFI Editor\0"
- #define EDITOR_VERSION L"0.99\0"
-
--#define EFI_EDITOR_LINE_LIST 'eell'
-+#define EFI_EDITOR_LINE_LIST EFI_SIGNATURE_32 ('e','e','l','l')
-
- #define INSERT_MODE_STR L"INS"
- #define OVERWR_MODE_STR L"OVR"
-diff --git a/edit/libEditor.c b/edit/libEditor.c
-index b39a2f0..7f32ce1 100644
---- a/edit/libEditor.c
-+++ b/edit/libEditor.c
-@@ -123,7 +123,7 @@ MainEditorInit (
- Status = BS->HandleProtocol (
- In,
- &gEfiSimplePointerProtocolGuid,
-- &MainEditor.MouseInterface
-+ (VOID**)&MainEditor.MouseInterface
- );
- if (EFI_ERROR (Status)) {
- //
-@@ -146,7 +146,7 @@ MainEditorInit (
- Status = BS->HandleProtocol (
- HandleBuffer[Index],
- &gEfiSimplePointerProtocolGuid,
-- &MainEditor.MouseInterface
-+ (VOID**)&MainEditor.MouseInterface
- );
- if (!EFI_ERROR (Status)) {
- break;
-@@ -169,31 +169,31 @@ MainEditorInit (
- //
- Status = MainTitleBarInit ();
- if (EFI_ERROR (Status)) {
-- PrintToken (STRING_TOKEN (STR_EDIT_LIBEDITOR_TITLEBAR), HiiHandle);
-+ PrintToken (STRING_TOKEN (STR_EDIT_LIBEDITOR_TITLEBAR), gEditHiiHandle);
- return EFI_LOAD_ERROR;
+Index: mode/mode.c
+===================================================================
+--- mode/mode.c (revision 64)
++++ mode/mode.c (working copy)
+@@ -53,7 +53,7 @@
+ NULL,
+ 0,
+ 0,
+- 0
++ (SHELL_VAR_CHECK_FLAG_TYPE) 0
}
+ };
- Status = MainMenuBarInit ();
- if (EFI_ERROR (Status)) {
-- PrintToken (STRING_TOKEN (STR_EDIT_LIBEDITOR_MAINMENU), HiiHandle);
-+ PrintToken (STRING_TOKEN (STR_EDIT_LIBEDITOR_MAINMENU), gEditHiiHandle);
- return EFI_LOAD_ERROR;
+Index: mode/mode.h
+===================================================================
+--- mode/mode.h (revision 64)
++++ mode/mode.h (working copy)
+@@ -30,3 +30,4 @@
}
- Status = MainStatusBarInit ();
- if (EFI_ERROR (Status)) {
-- PrintToken (STRING_TOKEN (STR_EDIT_LIBEDITOR_STATUSBAR), HiiHandle);
-+ PrintToken (STRING_TOKEN (STR_EDIT_LIBEDITOR_STATUSBAR), gEditHiiHandle);
- return EFI_LOAD_ERROR;
- }
-
- Status = MainInputBarInit ();
- if (EFI_ERROR (Status)) {
-- PrintToken (STRING_TOKEN (STR_EDIT_LIBEDITOR_INPUTBAR), HiiHandle);
-+ PrintToken (STRING_TOKEN (STR_EDIT_LIBEDITOR_INPUTBAR), gEditHiiHandle);
- return EFI_LOAD_ERROR;
- }
-
- Status = FileBufferInit ();
- if (EFI_ERROR (Status)) {
-- PrintToken (STRING_TOKEN (STR_EDIT_LIBEDITOR_FILEBUFFER), HiiHandle);
-+ PrintToken (STRING_TOKEN (STR_EDIT_LIBEDITOR_FILEBUFFER), gEditHiiHandle);
- return EFI_LOAD_ERROR;
- }
- //
-@@ -234,27 +234,27 @@ MainEditorCleanup (
- //
- Status = MainTitleBarCleanup ();
- if (EFI_ERROR (Status)) {
-- PrintToken (STRING_TOKEN (STR_EDIT_LIBEDITOR_TILEBAR_CLEANUP), HiiHandle);
-+ PrintToken (STRING_TOKEN (STR_EDIT_LIBEDITOR_TILEBAR_CLEANUP), gEditHiiHandle);
- }
-
- Status = MainMenuBarCleanup ();
- if (EFI_ERROR (Status)) {
-- PrintToken (STRING_TOKEN (STR_EDIT_LIBEDITOR_MENUBAR_CLEANUP), HiiHandle);
-+ PrintToken (STRING_TOKEN (STR_EDIT_LIBEDITOR_MENUBAR_CLEANUP), gEditHiiHandle);
- }
-
- Status = MainStatusBarCleanup ();
- if (EFI_ERROR (Status)) {
-- PrintToken (STRING_TOKEN (STR_EDIT_LIBEDITOR_STATUSBAR_CLEANUP), HiiHandle);
-+ PrintToken (STRING_TOKEN (STR_EDIT_LIBEDITOR_STATUSBAR_CLEANUP), gEditHiiHandle);
- }
-
- Status = MainInputBarCleanup ();
- if (EFI_ERROR (Status)) {
-- PrintToken (STRING_TOKEN (STR_EDIT_LIBEDITOR_INPUTBAR_CLEANUP), HiiHandle);
-+ PrintToken (STRING_TOKEN (STR_EDIT_LIBEDITOR_INPUTBAR_CLEANUP), gEditHiiHandle);
- }
-
- Status = FileBufferCleanup ();
- if (EFI_ERROR (Status)) {
-- PrintToken (STRING_TOKEN (STR_EDIT_LIBEDITOR_FILEBUFFER_CLEANUP), HiiHandle);
-+ PrintToken (STRING_TOKEN (STR_EDIT_LIBEDITOR_FILEBUFFER_CLEANUP), gEditHiiHandle);
- }
- //
- // restore old mode
-diff --git a/edit/libInputBar.c b/edit/libInputBar.c
-index 0ec6858..ebd3864 100644
---- a/edit/libInputBar.c
-+++ b/edit/libInputBar.c
-@@ -173,7 +173,7 @@ Returns:
- EditorClearLine (INPUT_BAR_LOCATION);
-
- Out->SetCursorPosition (Out, 0, INPUT_BAR_LOCATION - 1);
-- PrintToken (STRING_TOKEN (STR_EDIT_LIBINPUTBAR_MAININPUTBAR), HiiHandle, MainInputBar.Prompt);
-+ PrintToken (STRING_TOKEN (STR_EDIT_LIBINPUTBAR_MAININPUTBAR), gEditHiiHandle, MainInputBar.Prompt);
-
- //
- // that's the maximum input length that can be displayed on screen
-diff --git a/edit/libMenuBar.c b/edit/libMenuBar.c
-index 32fef4e..f536d76 100644
---- a/edit/libMenuBar.c
-+++ b/edit/libMenuBar.c
-@@ -220,9 +220,9 @@ MainMenuBarRefresh (
- FunctionKeyString = AllocatePool (BufferSize);
-
- #if (EFI_SPECIFICATION_VERSION < 0x0002000A)
-- Status = Hii->GetString (Hii, HiiHandle, Item->NameToken, FALSE, NULL, &BufferSize, NameString);
-+ Status = Hii->GetString (Hii, gEditHiiHandle, Item->NameToken, FALSE, NULL, &BufferSize, NameString);
- #else
-- Status = LibGetString (HiiHandle, Item->NameToken, NameString, &BufferSize);
-+ Status = LibGetString (gEditHiiHandle, Item->NameToken, NameString, &BufferSize);
- #endif
-
- Width = max ((StrLen (NameString) + 6), 20);
-@@ -232,9 +232,9 @@ MainMenuBarRefresh (
- }
-
- #if (EFI_SPECIFICATION_VERSION < 0x0002000A)
-- Status = Hii->GetString (Hii, HiiHandle, Item->FunctionKeyToken, FALSE, NULL, &BufferSize, FunctionKeyString);
-+ Status = Hii->GetString (Hii, gEditHiiHandle, Item->FunctionKeyToken, FALSE, NULL, &BufferSize, FunctionKeyString);
- #else
-- Status = LibGetString (HiiHandle, Item->FunctionKeyToken, FunctionKeyString, &BufferSize);
-+ Status = LibGetString (gEditHiiHandle, Item->FunctionKeyToken, FunctionKeyString, &BufferSize);
- #endif
- PrintAt (Col - 1, Row - 1, L"%E%s%N %H%s%N ", FunctionKeyString, NameString);
-
-diff --git a/edit/main.c b/edit/main.c
-index 9f1c987..0d92c7a 100644
---- a/edit/main.c
-+++ b/edit/main.c
-@@ -34,7 +34,7 @@ EFI_BOOTSHELL_CODE(
- //
- // Global Variables
- //
--EFI_HII_HANDLE HiiHandle;
-+EFI_HII_HANDLE gEditHiiHandle;
- #if (EFI_SPECIFICATION_VERSION < 0x0002000A)
- EFI_HII_PROTOCOL *Hii;
- #endif
-@@ -121,13 +121,13 @@ Returns:
- //
- // There should only be one HII protocol
- //
-- Status = LibLocateProtocol (&gEfiHiiProtocolGuid, &Hii);
-+ Status = LibLocateProtocol (&gEfiHiiProtocolGuid, (VOID**)&Hii);
- if (EFI_ERROR (Status) || NULL == Hii) {
- return EFI_ABORTED;
- }
#endif
++
+Index: attrib/attrib.inf
+===================================================================
+--- attrib/attrib.inf (revision 64)
++++ attrib/attrib.inf (working copy)
+@@ -41,24 +41,24 @@
-- Status = LibInitializeStrings (&HiiHandle, STRING_ARRAY_NAME, &EfiEditGuid);
-+ Status = LibInitializeStrings (&gEditHiiHandle, STRING_ARRAY_NAME, &EfiEditGuid);
-
- if (EFI_ERROR (Status)) {
- return Status;
-@@ -137,7 +137,7 @@ Returns:
- if (VarCheckOk != RetCode) {
- switch (RetCode) {
- case VarCheckUnknown:
-- PrintToken (STRING_TOKEN (STR_SHELLENV_GNC_UNKNOWN_FLAG), HiiHandle, L"edit", Useful);
-+ PrintToken (STRING_TOKEN (STR_SHELLENV_GNC_UNKNOWN_FLAG), gEditHiiHandle, L"edit", Useful);
- break;
-
- default:
-@@ -161,10 +161,10 @@ Returns:
- ChkPck.FlagCount > 2 ||
- (ChkPck.FlagCount == 2 && LibCheckVarGetFlag (&ChkPck, L"-b") == NULL)
- ) {
-- PrintToken (STRING_TOKEN (STR_SHELLENV_GNC_TOO_MANY), HiiHandle, L"edit");
-+ PrintToken (STRING_TOKEN (STR_SHELLENV_GNC_TOO_MANY), gEditHiiHandle, L"edit");
- Status = EFI_INVALID_PARAMETER;
- } else {
-- PrintToken (STRING_TOKEN (STR_EDIT_VERBOSE_HELP), HiiHandle);
-+ PrintToken (STRING_TOKEN (STR_EDIT_VERBOSE_HELP), gEditHiiHandle);
- Status = EFI_SUCCESS;
- }
-
-@@ -172,21 +172,21 @@ Returns:
- }
-
- if (ChkPck.ValueCount > 1) {
-- PrintToken (STRING_TOKEN (STR_SHELLENV_GNC_TOO_MANY), HiiHandle, L"edit");
-+ PrintToken (STRING_TOKEN (STR_SHELLENV_GNC_TOO_MANY), gEditHiiHandle, L"edit");
- Status = EFI_INVALID_PARAMETER;
- goto done;
- }
-
- if (ChkPck.ValueCount == 1) {
- if (!IsValidFileName (ChkPck.VarList->VarStr)) {
-- PrintToken (STRING_TOKEN (STR_EDIT_MAIN_INVALID_FILE_NAME), HiiHandle);
-+ PrintToken (STRING_TOKEN (STR_EDIT_MAIN_INVALID_FILE_NAME), gEditHiiHandle);
- Status = EFI_INVALID_PARAMETER;
- goto done;
- }
- }
-
- if (SI->RedirArgc != 0) {
-- PrintToken (STRING_TOKEN (STR_EDIT_NOREDIRECT), HiiHandle);
-+ PrintToken (STRING_TOKEN (STR_EDIT_NOREDIRECT), gEditHiiHandle);
- Status = EFI_INVALID_PARAMETER;
- goto done;
- }
-@@ -195,7 +195,7 @@ Returns:
- if (EFI_ERROR (Status)) {
- Out->ClearScreen (Out);
- Out->EnableCursor (Out, TRUE);
-- PrintToken (STRING_TOKEN (STR_EDIT_MAIN_INIT_FAILED), HiiHandle);
-+ PrintToken (STRING_TOKEN (STR_EDIT_MAIN_INIT_FAILED), gEditHiiHandle);
- goto done;
- }
+ [sources.common]
+ AttribStrings.uni
+- ..\ShCommonStrings.uni
++ ../ShCommonStrings.uni
+ attrib.c
+ attrib.h
+
-@@ -240,19 +240,19 @@ Returns:
- //
- if (Status == EFI_SUCCESS) {
- } else if (Status == EFI_OUT_OF_RESOURCES) {
-- PrintToken (STRING_TOKEN (STR_SHELLENV_GNC_OUT_RESOURCE), HiiHandle, L"edit");
-+ PrintToken (STRING_TOKEN (STR_SHELLENV_GNC_OUT_RESOURCE), gEditHiiHandle, L"edit");
- } else {
- if (Buffer != NULL) {
- if (StrCmp (Buffer, L"") != 0) {
- //
- // print out the status string
- //
-- PrintToken (STRING_TOKEN (STR_EDIT_MAIN_BUFFER), HiiHandle, Buffer);
-+ PrintToken (STRING_TOKEN (STR_EDIT_MAIN_BUFFER), gEditHiiHandle, Buffer);
- } else {
-- PrintToken (STRING_TOKEN (STR_EDIT_MAIN_UNKNOWN_EDITOR_ERR), HiiHandle);
-+ PrintToken (STRING_TOKEN (STR_EDIT_MAIN_UNKNOWN_EDITOR_ERR), gEditHiiHandle);
- }
- } else {
-- PrintToken (STRING_TOKEN (STR_EDIT_MAIN_UNKNOWN_EDITOR_ERR), HiiHandle);
-+ PrintToken (STRING_TOKEN (STR_EDIT_MAIN_UNKNOWN_EDITOR_ERR), gEditHiiHandle);
- }
- }
+ [includes.common]
+ .
+- ..\Inc
+- ..\Library
+- $(EDK_SOURCE)\Foundation
+- $(EDK_SOURCE)\Foundation\Include
+- $(EDK_SOURCE)\Foundation\Include\IndustryStandard
+- $(EDK_SOURCE)\Foundation\Efi
+- $(EDK_SOURCE)\Foundation\Efi\Include
+- $(EDK_SOURCE)\Foundation\FrameWork
+- $(EDK_SOURCE)\Foundation\FrameWork\Include
+- $(EDK_SOURCE)\Foundation\Core\Dxe
+- $(DEST_DIR)\
++ ../Inc
++ ../Library
++ $(EDK_SOURCE)/Foundation
++ $(EDK_SOURCE)/Foundation/Include
++ $(EDK_SOURCE)/Foundation/Include/IndustryStandard
++ $(EDK_SOURCE)/Foundation/Efi
++ $(EDK_SOURCE)/Foundation/Efi/Include
++ $(EDK_SOURCE)/Foundation/FrameWork
++ $(EDK_SOURCE)/Foundation/FrameWork/Include
++ $(EDK_SOURCE)/Foundation/Core/Dxe
++ $(DEST_DIR./
-diff --git a/err/err.c b/err/err.c
-index e41a9d6..95db9bc 100644
---- a/err/err.c
-+++ b/err/err.c
-@@ -35,7 +35,7 @@ extern UINTN EFIDebug;
+ [libraries.common]
+ EfiShellLib
+Index: attrib/attrib.c
+===================================================================
+--- attrib/attrib.c (revision 64)
++++ attrib/attrib.c (working copy)
+@@ -57,7 +57,7 @@
//
// Global Variables
//
-EFI_HII_HANDLE HiiHandle;
+STATIC EFI_HII_HANDLE HiiHandle;
- EFI_GUID EfiErrGuid = EFI_ERR_GUID;
- SHELL_VAR_CHECK_ITEM ErrCheckList[] = {
+ EFI_GUID EfiAttribGuid = EFI_ATTRIB_GUID;
+ SHELL_VAR_CHECK_ITEM AttribCheckList[] = {
{
-@@ -149,7 +149,7 @@ _DumpHandleMask (
- EFI_DEBUG_MASK_PROTOCOL *dmp;
- UINTN Mask;
-
-- Status = BS->HandleProtocol (Handle, &gEfiDebugMaskProtocolGuid, &dmp);
-+ Status = BS->HandleProtocol (Handle, &gEfiDebugMaskProtocolGuid, (VOID**)&dmp);
- if (!EFI_ERROR (Status)) {
- Status = dmp->GetDebugMask (dmp, &Mask);
- if (!EFI_ERROR (Status)) {
-@@ -278,7 +278,7 @@ _SetDriverMask (
- goto Done;
+@@ -124,7 +124,7 @@
+ NULL,
+ 0,
+ 0,
+- 0
++ (SHELL_VAR_CHECK_FLAG_TYPE) 0
}
+ };
-- Status = BS->HandleProtocol (RealHandle, &gEfiDebugMaskProtocolGuid, &dmp);
-+ Status = BS->HandleProtocol (RealHandle, &gEfiDebugMaskProtocolGuid, (VOID**)&dmp);
- if (EFI_ERROR (Status)) {
- PrintToken (STRING_TOKEN (STR_ERR_HANDLE_NOT_FOUND), HiiHandle, DrvHandle + 1);
- goto Done;
-@@ -336,7 +336,7 @@ _SetAllDriverMask (
- }
-
- for (Index = 0; Index < BufferSize / sizeof(EFI_HANDLE); Index ++) {
-- Status = BS->HandleProtocol (Buffer[Index], &gEfiDebugMaskProtocolGuid, &dmp);
-+ Status = BS->HandleProtocol (Buffer[Index], &gEfiDebugMaskProtocolGuid, (VOID**)&dmp);
- Status = dmp->SetDebugMask (dmp, Msk);
+@@ -438,7 +438,7 @@
+ //
+ Info = Arg->Info;
+ if (Add || Remove) {
+- Info->Attribute = Info->Attribute & (~Remove) | Add;
++ Info->Attribute = (Info->Attribute & (~Remove)) | Add;
+ Status = Arg->Handle->SetInfo (
+ Arg->Handle,
+ &gEfiFileInfoGuid,
+Index: attrib/attrib.h
+===================================================================
+--- attrib/attrib.h (revision 64)
++++ attrib/attrib.h (working copy)
+@@ -29,4 +29,5 @@
+ 0xcd691c77, 0xfc45, 0x4d7b, 0xb8, 0x92, 0x92, 0xa, 0x86, 0x2d, 0x67, 0xdc \
}
-diff --git a/err/err.inf b/err/err.inf
-index 467e734..f1a830b 100644
---- a/err/err.inf
-+++ b/err/err.inf
-@@ -25,7 +25,7 @@ FILE_GUID = 7ED86F56-5558-4d4f-A972-9307909AE9BA
+-#endif
+\ No newline at end of file
++#endif
++
+Index: err/err.inf
+===================================================================
+--- err/err.inf (revision 64)
++++ err/err.inf (working copy)
+@@ -25,7 +25,7 @@
COMPONENT_TYPE = APPLICATION
[sources.common]
@@ -3444,7 +1170,7 @@ index 467e734..f1a830b 100644
ErrStrings.uni
err.c
err.h
-@@ -33,17 +33,17 @@ err.h
+@@ -33,17 +33,17 @@
[includes.common]
.
@@ -3473,32 +1199,104 @@ index 467e734..f1a830b 100644
[libraries.common]
EfiShellLib
-diff --git a/guid/guid.c b/guid/guid.c
-index 7f26e7d..ce86444 100644
---- a/guid/guid.c
-+++ b/guid/guid.c
-@@ -36,7 +36,7 @@ extern UINT8 STRING_ARRAY_NAME[];
+Index: err/DebugMask.h
+===================================================================
+--- err/DebugMask.h (revision 64)
++++ err/DebugMask.h (working copy)
+@@ -67,3 +67,4 @@
+ extern EFI_GUID gEfiDebugMaskProtocolGuid;
+
+ #endif
++
+Index: err/err.c
+===================================================================
+--- err/err.c (revision 64)
++++ err/err.c (working copy)
+@@ -35,7 +35,7 @@
//
// Global Variables
//
-EFI_HII_HANDLE HiiHandle;
+STATIC EFI_HII_HANDLE HiiHandle;
- EFI_GUID EfiGuidGuid = EFI_GUID_GUID;
- SHELL_VAR_CHECK_ITEM GuidCheckList[] = {
+ EFI_GUID EfiErrGuid = EFI_ERR_GUID;
+ SHELL_VAR_CHECK_ITEM ErrCheckList[] = {
{
-diff --git a/guid/guid.inf b/guid/guid.inf
-index 60639d2..8b593b9 100644
---- a/guid/guid.inf
-+++ b/guid/guid.inf
-@@ -37,23 +37,23 @@
- FILE_GUID = CBEB01F8-0912-4d87-8A6B-45D02847A405
- COMPONENT_TYPE = APPLICATION
+@@ -60,7 +60,7 @@
+ NULL,
+ 0,
+ 0,
+- 0
++ (SHELL_VAR_CHECK_FLAG_TYPE) 0
+ }
+ };
+
+@@ -149,7 +149,7 @@
+ EFI_DEBUG_MASK_PROTOCOL *dmp;
+ UINTN Mask;
+
+- Status = BS->HandleProtocol (Handle, &gEfiDebugMaskProtocolGuid, &dmp);
++ Status = BS->HandleProtocol (Handle, &gEfiDebugMaskProtocolGuid, (VOID**)&dmp);
+ if (!EFI_ERROR (Status)) {
+ Status = dmp->GetDebugMask (dmp, &Mask);
+ if (!EFI_ERROR (Status)) {
+@@ -170,13 +170,11 @@
+ UINTN HandleNum;
+ UINTN Index;
+ UINTN DrvHandle;
+- BOOLEAN Found;
+
+ HandleBuf = NULL;
+ HandleNum = 0;
+ DrvHandle = 0;
+ Status = EFI_SUCCESS;
+- Found = FALSE;
+
+ if (NULL != Handle) {
+ DrvHandle = (UINTN) StrToUIntegerBase (Handle, 16, &Status) - 1;
+@@ -278,7 +276,7 @@
+ goto Done;
+ }
+
+- Status = BS->HandleProtocol (RealHandle, &gEfiDebugMaskProtocolGuid, &dmp);
++ Status = BS->HandleProtocol (RealHandle, &gEfiDebugMaskProtocolGuid, (VOID**)&dmp);
+ if (EFI_ERROR (Status)) {
+ PrintToken (STRING_TOKEN (STR_ERR_HANDLE_NOT_FOUND), HiiHandle, DrvHandle + 1);
+ goto Done;
+@@ -336,7 +334,7 @@
+ }
+
+ for (Index = 0; Index < BufferSize / sizeof(EFI_HANDLE); Index ++) {
+- Status = BS->HandleProtocol (Buffer[Index], &gEfiDebugMaskProtocolGuid, &dmp);
++ Status = BS->HandleProtocol (Buffer[Index], &gEfiDebugMaskProtocolGuid, (VOID**)&dmp);
+ Status = dmp->SetDebugMask (dmp, Msk);
+ }
+
+Index: err/err.h
+===================================================================
+--- err/err.h (revision 64)
++++ err/err.h (working copy)
+@@ -29,4 +29,4 @@
+ 0xdaab229b, 0x7883, 0x4f5f, 0xac, 0x6e, 0x15, 0x20, 0xc7, 0xe7, 0x8f, 0xd4 \
+ }
+
+-#endif
+\ No newline at end of file
++#endif
+Index: EfiDecompress/Decompress.inf
+===================================================================
+--- EfiDecompress/Decompress.inf (revision 64)
++++ EfiDecompress/Decompress.inf (working copy)
+@@ -25,7 +25,7 @@
+ COMPONENT_TYPE = APPLICATION
+
[sources.common]
-- ..\ShCommonStrings.uni
-+ ../ShCommonStrings.uni
- GuidStrings.uni
- guid.c
- guid.h
+-..\ShCommonStrings.uni
++../ShCommonStrings.uni
+ DecompressStrings.uni
+ decompress.c
+ decompress.h
+@@ -33,17 +33,17 @@
+
[includes.common]
.
- ..\Inc
@@ -3523,14 +1321,86 @@ index 60639d2..8b593b9 100644
+ $(EDK_SOURCE)/Foundation/FrameWork/Include
+ $(EDK_SOURCE)/Foundation/Core/Dxe
+ $(DEST_DIR./
- [libraries.common]
+
+ [libraries.common]
EfiShellLib
- EdkProtocolLib
-diff --git a/hexedit/heditor.h b/hexedit/heditor.h
-index 09196d6..3cd4d84 100644
---- a/hexedit/heditor.h
-+++ b/hexedit/heditor.h
-@@ -39,7 +39,7 @@ Abstract:
+Index: EfiDecompress/Decompress.c
+===================================================================
+--- EfiDecompress/Decompress.c (revision 64)
++++ EfiDecompress/Decompress.c (working copy)
+@@ -22,7 +22,7 @@
+ --*/
+
+ #include "EfiShellLib.h"
+-#include "decompress.h"
++#include "Decompress.h"
+
+ extern UINT8 STRING_ARRAY_NAME[];
+
+@@ -31,7 +31,7 @@
+ //
+ #include STRING_DEFINES_FILE
+
+-#include EFI_PROTOCOL_DEFINITION (decompress)
++#include EFI_PROTOCOL_DEFINITION (Decompress)
+
+ EFI_HII_HANDLE HiiDecompressHandle;
+ EFI_GUID EfiDecompressGuid = EFI_DECOMPRESS_GUID;
+@@ -52,7 +52,7 @@
+ NULL,
+ 0,
+ 0,
+- 0
++ (SHELL_VAR_CHECK_FLAG_TYPE) 0
+ }
+ };
+
+@@ -192,7 +192,7 @@
+ //
+ //
+ //
+- Status = LibLocateProtocol (&gEfiDecompressProtocolGuid, &Decompress);
++ Status = LibLocateProtocol (&gEfiDecompressProtocolGuid, (VOID**)&Decompress);
+ if (EFI_ERROR (Status)) {
+ PrintToken (STRING_TOKEN (STR_DECOMPRESS_PROTOCOL_NOT_FOUND), HiiDecompressHandle, L"efidecompress");
+ Status = EFI_UNSUPPORTED;
+Index: EfiDecompress/Decompress.h
+===================================================================
+--- EfiDecompress/Decompress.h (revision 64)
++++ EfiDecompress/Decompress.h (working copy)
+@@ -29,4 +29,4 @@
+ 0xe15963a9, 0xa05a, 0x480e, 0x91, 0x49, 0x32, 0xe9, 0x24, 0x5d, 0x98, 0xcb \
+ }
+
+-#endif
+\ No newline at end of file
++#endif
+Index: hexedit/libStatusBar.c
+===================================================================
+--- hexedit/libStatusBar.c (revision 64)
++++ hexedit/libStatusBar.c (working copy)
+@@ -173,6 +173,7 @@
+ // back up the screen attributes
+ //
+ Orig = HMainEditor.ColorAttributes;
++ New.Data = 0;
+ New.Colors.Foreground = Orig.Colors.Background;
+ New.Colors.Background = Orig.Colors.Foreground;
+
+Index: hexedit/libtitlebar.h
+===================================================================
+--- hexedit/libtitlebar.h (revision 64)
++++ hexedit/libtitlebar.h (working copy)
+@@ -46,3 +46,4 @@
+ );
+
+ #endif
++
+Index: hexedit/heditor.h
+===================================================================
+--- hexedit/heditor.h (revision 64)
++++ hexedit/heditor.h (working copy)
+@@ -39,7 +39,7 @@
#include "libinputbar.h"
#include "libmenubar.h"
@@ -3539,7 +1409,7 @@ index 09196d6..3cd4d84 100644
#include "libclipboard.h"
-@@ -52,7 +52,7 @@ extern HEFI_EDITOR_GLOBAL_EDITOR HMainEditor;
+@@ -52,9 +52,10 @@
extern BOOLEAN HEditorFirst;
extern BOOLEAN HEditorExit;
@@ -3548,11 +1418,174 @@ index 09196d6..3cd4d84 100644
#if (EFI_SPECIFICATION_VERSION < 0x0002000A)
extern EFI_HII_PROTOCOL *Hii;
#endif
-diff --git a/hexedit/heditortype.h b/hexedit/heditortype.h
-index 59317a9..0b4e4e2 100644
---- a/hexedit/heditortype.h
-+++ b/hexedit/heditortype.h
-@@ -30,7 +30,7 @@ Abstract:
+
+ #endif // _HEDITOR_H
++
+Index: hexedit/libBufferImage.c
+===================================================================
+--- hexedit/libBufferImage.c (revision 64)
++++ hexedit/libBufferImage.c (working copy)
+@@ -203,6 +203,9 @@
+ case MEM_BUFFER:
+ HMemImageBackup ();
+ break;
++
++ case NO_BUFFER:
++ break;
+ }
+
+ return EFI_SUCCESS;
+@@ -587,7 +590,7 @@
+ UINT8 Value;
+ BOOLEAN HighBits;
+
+- Line = NULL;
++ Line = NULL;
+ if (HMainEditor.MouseSupported) {
+
+ if (HBufferImageMouseNeedRefresh) {
+@@ -610,6 +613,7 @@
+ // backup the old screen attributes
+ //
+ Orig = HMainEditor.ColorAttributes;
++ New.Data = 0;
+ New.Colors.Foreground = Orig.Colors.Background;
+ New.Colors.Background = Orig.Colors.Foreground;
+
+@@ -801,10 +805,10 @@
+ UINTN StartRow;
+ UINTN EndRow;
+ UINTN FStartRow;
+- UINTN FEndRow;
+ UINTN Tmp;
+
+ Orig = HMainEditor.ColorAttributes;
++ New.Data = 0;
+ New.Colors.Foreground = Orig.Colors.Background;
+ New.Colors.Background = Orig.Colors.Foreground;
+
+@@ -870,7 +874,6 @@
+ }
+
+ FStartRow = StartRow;
+- FEndRow = EndRow;
+
+ StartRow = TEXT_START_ROW + StartRow - HBufferImage.LowVisibleRow;
+ EndRow = TEXT_START_ROW + EndRow - HBufferImage.LowVisibleRow;
+@@ -980,6 +983,10 @@
+ case MEM_BUFFER:
+ Status = HMemImageRead (MemOffset, MemSize, Recover);
+ break;
++
++ case NO_BUFFER:
++ Status = EFI_UNSUPPORTED;
++ break;
+ }
+
+ if (EFI_ERROR (Status)) {
+@@ -1030,6 +1037,10 @@
+ case MEM_BUFFER:
+ Status = HMemImageSave (MemOffset, MemSize);
+ break;
++
++ case NO_BUFFER:
++ Status = EFI_UNSUPPORTED;
++ break;
+ }
+
+ if (EFI_ERROR (Status)) {
+@@ -1967,14 +1978,11 @@
+
+ --*/
+ {
+- HEFI_EDITOR_LINE *Line;
+ UINTN FRow;
+ UINTN FCol;
+ UINTN Gap;
+ INTN Retreat;
+
+- Line = HBufferImage.CurrentLine;
+-
+ FRow = HBufferImage.BufferPosition.Row;
+ FCol = HBufferImage.BufferPosition.Column;
+
+@@ -1996,7 +2004,7 @@
+ //
+ // get correct line
+ //
+- Line = HMoveLine (Retreat);
++ HMoveLine (Retreat);
+
+ FRow -= Gap;
+
+@@ -2025,13 +2033,10 @@
+
+ --*/
+ {
+- HEFI_EDITOR_LINE *Line;
+ UINTN FRow;
+ UINTN FCol;
+ BOOLEAN HighBits;
+
+- Line = HBufferImage.CurrentLine;
+-
+ //
+ // curosr will at the high bit
+ //
+@@ -2157,7 +2162,6 @@
+
+ HEFI_EDITOR_LINE *Line;
+ EFI_LIST_ENTRY *Link;
+- UINTN StartRow;
+
+ UINTN OldFCol;
+ UINTN OldFRow;
+@@ -2167,11 +2171,6 @@
+
+ EFI_STATUS Status;
+
+- //
+- // get the line that start position is at
+- //
+- StartRow = Pos / 0x10;
+-
+ Size = HBufferImageGetTotalSize ();
+
+ if (Size < Count) {
+@@ -2300,7 +2299,6 @@
+ HEFI_EDITOR_LINE *Line;
+
+ EFI_LIST_ENTRY *Link;
+- UINTN StartRow;
+
+ UINTN OldFCol;
+ UINTN OldFRow;
+@@ -2308,11 +2306,6 @@
+
+ UINTN NewPos;
+
+- //
+- // get the line that start position is at
+- //
+- StartRow = Pos / 0x10;
+-
+ Size = HBufferImageGetTotalSize ();
+
+ //
+Index: hexedit/libstatusbar.h
+===================================================================
+--- hexedit/libstatusbar.h (revision 64)
++++ hexedit/libstatusbar.h (working copy)
+@@ -55,3 +55,4 @@
+ );
+
+ #endif
++
+Index: hexedit/heditortype.h
+===================================================================
+--- hexedit/heditortype.h (revision 64)
++++ hexedit/heditortype.h (working copy)
+@@ -30,7 +30,7 @@
#define EDITOR_NAME L"EFI Hex Editor\0"
#define EDITOR_VERSION L"0.99\0"
@@ -3561,53 +1594,123 @@ index 59317a9..0b4e4e2 100644
#define FILE_ATTRIBUTES EFI_FILE_MODE_READ | EFI_FILE_MODE_WRITE | EFI_FILE_MODE_CREATE
#define FILE_READ_WRITE EFI_FILE_MODE_READ | EFI_FILE_MODE_WRITE
-diff --git a/hexedit/hexedit.inf b/hexedit/hexedit.inf
-index cf89b9e..0239cb6 100644
---- a/hexedit/hexedit.inf
-+++ b/hexedit/hexedit.inf
-@@ -25,7 +25,7 @@ FILE_GUID = A5A41A42-5B2B-4de6-9556-DDC6DC31231C
- COMPONENT_TYPE = APPLICATION
+@@ -147,8 +147,8 @@
+ } HEFI_EDITOR_MENU_ITEM;
- [sources.common]
-- ..\ShCommonStrings.uni
-+ ../ShCommonStrings.uni
- HexeditStrings.uni
- heditor.h
- heditortype.h
-@@ -45,17 +45,17 @@ COMPONENT_TYPE = APPLICATION
+ typedef struct {
+- UINT32 Foreground : 4;
+- UINT32 Background : 4;
++ UINT8 Foreground : 4;
++ UINT8 Background : 4;
+ } HEFI_EDITOR_COLOR_ATTRIBUTES;
- [includes.common]
- .
-- ..\Inc
-- ..\Library
-- $(EDK_SOURCE)\Foundation
-- $(EDK_SOURCE)\Foundation\Include
-- $(EDK_SOURCE)\Foundation\Include\IndustryStandard
-- $(EDK_SOURCE)\Foundation\Efi
-- $(EDK_SOURCE)\Foundation\Efi\Include
-- $(EDK_SOURCE)\Foundation\FrameWork
-- $(EDK_SOURCE)\Foundation\FrameWork\Include
-- $(EDK_SOURCE)\Foundation\Core\Dxe
-- $(DEST_DIR)\
-+ ../Inc
-+ ../Library
-+ $(EDK_SOURCE)/Foundation
-+ $(EDK_SOURCE)/Foundation/Include
-+ $(EDK_SOURCE)/Foundation/Include/IndustryStandard
-+ $(EDK_SOURCE)/Foundation/Efi
-+ $(EDK_SOURCE)/Foundation/Efi/Include
-+ $(EDK_SOURCE)/Foundation/FrameWork
-+ $(EDK_SOURCE)/Foundation/FrameWork/Include
-+ $(EDK_SOURCE)/Foundation/Core/Dxe
-+ $(DEST_DIR./
+ typedef union {
+@@ -251,3 +251,4 @@
+ } HEFI_EDITOR_GLOBAL_EDITOR;
- [libraries.common]
- EfiShellLib
-diff --git a/hexedit/libEditor.c b/hexedit/libEditor.c
-index f511020..1e0128f 100644
---- a/hexedit/libEditor.c
-+++ b/hexedit/libEditor.c
-@@ -20,7 +20,7 @@ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+ #endif
++
+Index: hexedit/libMemImage.c
+===================================================================
+--- hexedit/libMemImage.c (revision 64)
++++ hexedit/libMemImage.c (working copy)
+@@ -91,7 +91,7 @@
+ Status = BS->LocateProtocol (
+ &gEfiPciRootBridgeIoProtocolGuid,
+ NULL,
+- &HMemImage.IoFncs
++ (VOID**)&HMemImage.IoFncs
+ );
+ if (Status == EFI_NOT_FOUND) {
+ //
+@@ -225,9 +225,6 @@
+ CHAR16 *Str;
+ HEFI_EDITOR_LINE *Line;
+
+- HEFI_EDITOR_ACTIVE_BUFFER_TYPE BufferTypeBackup;
+-
+- BufferTypeBackup = HBufferImage.BufferType;
+ HBufferImage.BufferType = MEM_BUFFER;
+
+ Buffer = AllocatePool (Size);
+@@ -344,8 +341,6 @@
+ EFI_STATUS Status;
+ VOID *Buffer;
+
+- HEFI_EDITOR_ACTIVE_BUFFER_TYPE BufferTypeBackup;
+-
+ //
+ // not modified, so directly return
+ //
+@@ -353,7 +348,6 @@
+ return EFI_SUCCESS;
+ }
+
+- BufferTypeBackup = HBufferImage.BufferType;
+ HBufferImage.BufferType = MEM_BUFFER;
+
+ Buffer = AllocatePool (Size);
+Index: hexedit/libbufferimage.h
+===================================================================
+--- hexedit/libbufferimage.h (revision 64)
++++ hexedit/libbufferimage.h (working copy)
+@@ -253,3 +253,4 @@
+ );
+
+ #endif
++
+Index: hexedit/libInputBar.c
+===================================================================
+--- hexedit/libInputBar.c (revision 64)
++++ hexedit/libInputBar.c (working copy)
+@@ -169,8 +169,6 @@
+ UINTN Size;
+ EFI_STATUS Status;
+ BOOLEAN NoDisplay;
+- UINTN Limit;
+- UINTN PromptLen;
+
+ //
+ // variable initialization
+@@ -190,6 +188,7 @@
+ // back up the old screen attributes
+ //
+ Orig = HMainEditor.ColorAttributes;
++ New.Data = 0;
+ New.Colors.Foreground = Orig.Colors.Background;
+ New.Colors.Background = Orig.Colors.Foreground;
+
+@@ -201,15 +200,9 @@
+ HEditorClearLine (INPUT_BAR_LOCATION);
+
+ Out->SetCursorPosition (Out, 0, INPUT_BAR_LOCATION - 1);
+- PrintToken (STRING_TOKEN (STR_HEXEDIT_LIBINPUTBAR_MAININPUTBAR), HiiHandle, HMainInputBar.Prompt);
++ PrintToken (STRING_TOKEN (STR_HEXEDIT_LIBINPUTBAR_MAININPUTBAR), gHexEditHiiHandle, HMainInputBar.Prompt);
+
+ //
+- // that's the maximum input length that can be displayed on screen
+- //
+- PromptLen = StrLen (HMainInputBar.Prompt);
+- Limit = HMainEditor.ScreenSize.Column - PromptLen;
+-
+- //
+ // this is a selection prompt, cursor will stay in edit area
+ // actually this is for search , search/replace
+ //
+Index: hexedit/libmemimage.h
+===================================================================
+--- hexedit/libmemimage.h (revision 64)
++++ hexedit/libmemimage.h (working copy)
+@@ -55,3 +55,4 @@
+ );
+
+ #endif
++
+Index: hexedit/libEditor.c
+===================================================================
+--- hexedit/libEditor.c (revision 64)
++++ hexedit/libEditor.c (working copy)
+@@ -20,7 +20,7 @@
--*/
@@ -3616,7 +1719,7 @@ index f511020..1e0128f 100644
HEFI_EDITOR_COLOR_ATTRIBUTES HOriginalColors;
INTN HOriginalMode;
-@@ -136,7 +136,7 @@ Returns:
+@@ -136,7 +136,7 @@
Status = BS->HandleProtocol (
In,
&gEfiSimplePointerProtocolGuid,
@@ -3625,7 +1728,7 @@ index f511020..1e0128f 100644
);
if (EFI_ERROR (Status)) {
//
-@@ -159,7 +159,7 @@ Returns:
+@@ -159,7 +159,7 @@
Status = BS->HandleProtocol (
HandleBuffer[Index],
&gEfiSimplePointerProtocolGuid,
@@ -3634,7 +1737,7 @@ index f511020..1e0128f 100644
);
if (!EFI_ERROR (Status)) {
break;
-@@ -182,37 +182,37 @@ Returns:
+@@ -182,37 +182,37 @@
//
Status = HMainTitleBarInit ();
if (EFI_ERROR (Status)) {
@@ -3678,7 +1781,7 @@ index f511020..1e0128f 100644
return EFI_LOAD_ERROR;
}
//
-@@ -259,32 +259,32 @@ Returns:
+@@ -259,32 +259,32 @@
//
Status = HMainTitleBarCleanup ();
if (EFI_ERROR (Status)) {
@@ -3717,154 +1820,163 @@ index f511020..1e0128f 100644
}
//
// restore old mode
-diff --git a/hexedit/libInputBar.c b/hexedit/libInputBar.c
-index 3a4cc7e..caa1ddc 100644
---- a/hexedit/libInputBar.c
-+++ b/hexedit/libInputBar.c
-@@ -201,7 +201,7 @@ Returns:
- HEditorClearLine (INPUT_BAR_LOCATION);
+@@ -732,6 +732,9 @@
+ case MEM_BUFFER:
+ OldSize = HBufferImage.MemImage->Size;
+ break;
++
++ default:
++ break;
+ }
- Out->SetCursorPosition (Out, 0, INPUT_BAR_LOCATION - 1);
-- PrintToken (STRING_TOKEN (STR_HEXEDIT_LIBINPUTBAR_MAININPUTBAR), HiiHandle, HMainInputBar.Prompt);
-+ PrintToken (STRING_TOKEN (STR_HEXEDIT_LIBINPUTBAR_MAININPUTBAR), gHexEditHiiHandle, HMainInputBar.Prompt);
+ if (LengthChange == FALSE) {
+Index: hexedit/libfileimage.h
+===================================================================
+--- hexedit/libfileimage.h (revision 64)
++++ hexedit/libfileimage.h (working copy)
+@@ -59,3 +59,4 @@
+ );
+
+ #endif
++
+Index: hexedit/libinputbar.h
+===================================================================
+--- hexedit/libinputbar.h (revision 64)
++++ hexedit/libinputbar.h (working copy)
+@@ -44,3 +44,4 @@
+ );
+
+ #endif
++
+Index: hexedit/libMenuBar.c
+===================================================================
+--- hexedit/libMenuBar.c (revision 64)
++++ hexedit/libMenuBar.c (working copy)
+@@ -222,7 +222,6 @@
+ CHAR16 *NameString;
+ CHAR16 *FunctionKeyString;
+ UINTN BufferSize;
+- EFI_STATUS Status;
//
- // that's the maximum input length that can be displayed on screen
-diff --git a/hexedit/libMemImage.c b/hexedit/libMemImage.c
-index 407bb2e..d7dbbe8 100644
---- a/hexedit/libMemImage.c
-+++ b/hexedit/libMemImage.c
-@@ -91,7 +91,7 @@ Returns:
- Status = BS->LocateProtocol (
- &gEfiPciRootBridgeIoProtocolGuid,
- NULL,
-- &HMemImage.IoFncs
-+ (VOID**)&HMemImage.IoFncs
- );
- if (Status == EFI_NOT_FOUND) {
- //
-diff --git a/hexedit/libMenuBar.c b/hexedit/libMenuBar.c
-index 5ecb694..d77a1a0 100644
---- a/hexedit/libMenuBar.c
-+++ b/hexedit/libMenuBar.c
-@@ -255,9 +255,9 @@ Returns:
+ // variable initialization
+@@ -255,9 +254,9 @@
FunctionKeyString = AllocatePool (BufferSize);
#if (EFI_SPECIFICATION_VERSION < 0x0002000A)
- Status = Hii->GetString (Hii, HiiHandle, Item->NameToken, FALSE, NULL, &BufferSize, NameString);
-+ Status = Hii->GetString (Hii, gHexEditHiiHandle, Item->NameToken, FALSE, NULL, &BufferSize, NameString);
++ Hii->GetString (Hii, gHexEditHiiHandle, Item->NameToken, FALSE, NULL, &BufferSize, NameString);
#else
- Status = LibGetString (HiiHandle, Item->NameToken, NameString, &BufferSize);
-+ Status = LibGetString (gHexEditHiiHandle, Item->NameToken, NameString, &BufferSize);
++ LibGetString (gHexEditHiiHandle, Item->NameToken, NameString, &BufferSize);
#endif
Width = max ((StrLen (NameString) + 6), 18);
-@@ -267,9 +267,9 @@ Returns:
+@@ -267,9 +266,9 @@
}
#if (EFI_SPECIFICATION_VERSION < 0x0002000A)
- Status = Hii->GetString (Hii, HiiHandle, Item->FunctionKeyToken, FALSE, NULL, &BufferSize, FunctionKeyString);
-+ Status = Hii->GetString (Hii, gHexEditHiiHandle, Item->FunctionKeyToken, FALSE, NULL, &BufferSize, FunctionKeyString);
++ Hii->GetString (Hii, gHexEditHiiHandle, Item->FunctionKeyToken, FALSE, NULL, &BufferSize, FunctionKeyString);
#else
- Status = LibGetString (HiiHandle, Item->FunctionKeyToken, FunctionKeyString, &BufferSize);
-+ Status = LibGetString (gHexEditHiiHandle, Item->FunctionKeyToken, FunctionKeyString, &BufferSize);
++ LibGetString (gHexEditHiiHandle, Item->FunctionKeyToken, FunctionKeyString, &BufferSize);
#endif
if (Index >= 10) {
PrintAt (Col - 1, Row - 1, L"%E%s%N %H%s%N ", FunctionKeyString, NameString);
-diff --git a/hexedit/libMisc.h b/hexedit/libMisc.h
-index 979a7f0..cbf58a8 100644
---- a/hexedit/libMisc.h
-+++ b/hexedit/libMisc.h
-@@ -20,7 +20,7 @@ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
- #ifndef _LIB_MISC_H_
- #define _LIB_MISC_H_
+@@ -1138,7 +1137,6 @@
+ // the file won't be saved
+ //
+ return EFI_SUCCESS;
+- break;
--#include "Heditortype.h"
-+#include "heditortype.h"
+ case L'c':
+ case L'C':
+@@ -1567,7 +1565,6 @@
+ --*/
+ {
+ UINTN Index;
+- HEFI_EDITOR_LINE *Line;
+ EFI_LIST_ENTRY *Link;
+ UINT8 *Buffer;
+ UINTN Count;
+@@ -1592,8 +1589,6 @@
+ Link = Link->Flink;
+ }
- VOID
- HEditorClearLine (
-diff --git a/hexedit/libTitleBar.c b/hexedit/libTitleBar.c
-index 9e7b9e9..09d068e 100644
---- a/hexedit/libTitleBar.c
-+++ b/hexedit/libTitleBar.c
-@@ -212,7 +212,7 @@ Returns:
- // the space for file name is 35 characters
- //
- if (StrLen (FileNameTmp) <= 35) {
-- PrintToken (STRING_TOKEN (STR_HEXEDIT_LIBTITLEBAR_MAINEDITOR), HiiHandle, FileNameTmp);
-+ PrintToken (STRING_TOKEN (STR_HEXEDIT_LIBTITLEBAR_MAINEDITOR), gHexEditHiiHandle, FileNameTmp);
+- Line = CR (Link, HEFI_EDITOR_LINE, Link, EFI_EDITOR_LINE_LIST);
+-
+ Count = HMainEditor.SelectEnd - HMainEditor.SelectStart + 1;
+ Buffer = AllocatePool (Count);
+ if (Buffer == NULL) {
+Index: hexedit/libeditor.h
+===================================================================
+--- hexedit/libeditor.h (revision 64)
++++ hexedit/libeditor.h (working copy)
+@@ -47,3 +47,4 @@
+ );
- for (Index = StrLen (FileNameTmp); Index < 35; Index++) {
- Print (L" ");
-@@ -220,7 +220,7 @@ Returns:
+ #endif
++
+Index: hexedit/hexedit.inf
+===================================================================
+--- hexedit/hexedit.inf (revision 64)
++++ hexedit/hexedit.inf (working copy)
+@@ -25,7 +25,7 @@
+ COMPONENT_TYPE = APPLICATION
- } else {
- for (Index = 0; Index < 32; Index++) {
-- PrintToken (STRING_TOKEN (STR_HEXEDIT_LIBTITLEBAR_MAINEDITOR_C), HiiHandle, FileNameTmp[Index]);
-+ PrintToken (STRING_TOKEN (STR_HEXEDIT_LIBTITLEBAR_MAINEDITOR_C), gHexEditHiiHandle, FileNameTmp[Index]);
- }
- //
- // print "..."
-@@ -234,14 +234,14 @@ Returns:
- if (StrLen (HMainEditor.BufferImage->DiskImage->Name) <= 9) {
- PrintToken (
- STRING_TOKEN (STR_HEXEDIT_LIBTITLEBAR_MAINEDITOR),
-- HiiHandle,
-+ gHexEditHiiHandle,
- HMainEditor.BufferImage->DiskImage->Name
- );
- } else {
- for (Index = 0; Index < 6; Index++) {
- PrintToken (
- STRING_TOKEN (STR_HEXEDIT_LIBTITLEBAR_MAINEDITOR_C),
-- HiiHandle,
-+ gHexEditHiiHandle,
- HMainEditor.BufferImage->DiskImage->Name[Index]
- );
- }
-@@ -253,7 +253,7 @@ Returns:
+ [sources.common]
+- ..\ShCommonStrings.uni
++ ../ShCommonStrings.uni
+ HexeditStrings.uni
+ heditor.h
+ heditortype.h
+@@ -45,17 +45,17 @@
- PrintToken (
- STRING_TOKEN (STR_HEXEDIT_LIBTITLEBAR_MAINEDITOR_TWOVARS),
-- HiiHandle,
-+ gHexEditHiiHandle,
- HMainEditor.BufferImage->DiskImage->Offset,
- HMainEditor.BufferImage->DiskImage->Offset + HMainEditor.BufferImage->DiskImage->Size - 1
- );
-@@ -269,7 +269,7 @@ Returns:
- case MEM_BUFFER:
- PrintToken (
- STRING_TOKEN (STR_HEXEDIT_LIBTITLEBAR_MAINEDITOR_TWOVARS),
-- HiiHandle,
-+ gHexEditHiiHandle,
- HMainEditor.BufferImage->MemImage->Offset,
- HMainEditor.BufferImage->MemImage->Offset + HMainEditor.BufferImage->MemImage->Size - 1
- );
-@@ -286,15 +286,15 @@ Returns:
- //
- switch (HMainEditor.BufferImage->BufferType) {
- case FILE_BUFFER:
-- PrintToken (STRING_TOKEN (STR_HEXEDIT_LIBTITLEBAR_FILE), HiiHandle);
-+ PrintToken (STRING_TOKEN (STR_HEXEDIT_LIBTITLEBAR_FILE), gHexEditHiiHandle);
- break;
+ [includes.common]
+ .
+- ..\Inc
+- ..\Library
+- $(EDK_SOURCE)\Foundation
+- $(EDK_SOURCE)\Foundation\Include
+- $(EDK_SOURCE)\Foundation\Include\IndustryStandard
+- $(EDK_SOURCE)\Foundation\Efi
+- $(EDK_SOURCE)\Foundation\Efi\Include
+- $(EDK_SOURCE)\Foundation\FrameWork
+- $(EDK_SOURCE)\Foundation\FrameWork\Include
+- $(EDK_SOURCE)\Foundation\Core\Dxe
+- $(DEST_DIR)\
++ ../Inc
++ ../Library
++ $(EDK_SOURCE)/Foundation
++ $(EDK_SOURCE)/Foundation/Include
++ $(EDK_SOURCE)/Foundation/Include/IndustryStandard
++ $(EDK_SOURCE)/Foundation/Efi
++ $(EDK_SOURCE)/Foundation/Efi/Include
++ $(EDK_SOURCE)/Foundation/FrameWork
++ $(EDK_SOURCE)/Foundation/FrameWork/Include
++ $(EDK_SOURCE)/Foundation/Core/Dxe
++ $(DEST_DIR./
- case DISK_BUFFER:
-- PrintToken (STRING_TOKEN (STR_HEXEDIT_LIBTITLEBAR_DISK), HiiHandle);
-+ PrintToken (STRING_TOKEN (STR_HEXEDIT_LIBTITLEBAR_DISK), gHexEditHiiHandle);
- break;
+ [libraries.common]
+ EfiShellLib
+Index: hexedit/libdiskimage.c
+===================================================================
+--- hexedit/libdiskimage.c (revision 64)
++++ hexedit/libdiskimage.c (working copy)
+@@ -228,11 +228,7 @@
+ UINTN Bytes;
- case MEM_BUFFER:
-- PrintToken (STRING_TOKEN (STR_HEXEDIT_LIBTITLEBAR_MEM), HiiHandle);
-+ PrintToken (STRING_TOKEN (STR_HEXEDIT_LIBTITLEBAR_MEM), gHexEditHiiHandle);
- break;
- }
- //
-diff --git a/hexedit/libdiskimage.c b/hexedit/libdiskimage.c
-index 7e11ad0..52f177b 100644
---- a/hexedit/libdiskimage.c
-+++ b/hexedit/libdiskimage.c
-@@ -246,7 +246,7 @@ Returns:
+ HEFI_EDITOR_LINE *Line;
+- UINT64 ByteOffset;
+
+- HEFI_EDITOR_ACTIVE_BUFFER_TYPE BufferTypeBackup;
+-
+- BufferTypeBackup = HBufferImage.BufferType;
+ HBufferImage.BufferType = DISK_BUFFER;
+
+ DevicePath = (EFI_DEVICE_PATH_PROTOCOL *) ShellGetMap (DeviceName);
+@@ -246,7 +242,7 @@
Status = LibDevicePathToInterface (
&gEfiBlockIoProtocolGuid,
DevicePath,
@@ -3873,7 +1985,35 @@ index 7e11ad0..52f177b 100644
);
if (EFI_ERROR (Status)) {
HMainStatusBarSetStatusString (L"Read Disk Failed");
-@@ -427,7 +427,7 @@ Returns:
+@@ -269,8 +265,6 @@
+ return EFI_OUT_OF_RESOURCES;
+ }
+
+- ByteOffset = MultU64x32 (Offset, BlkIo->Media->BlockSize);
+-
+ //
+ // read from disk
+ //
+@@ -405,10 +399,6 @@
+ VOID *Buffer;
+ UINTN Bytes;
+
+- UINT64 ByteOffset;
+-
+- HEFI_EDITOR_ACTIVE_BUFFER_TYPE BufferTypeBackup;
+-
+ //
+ // if not modified, directly return
+ //
+@@ -416,7 +406,6 @@
+ return EFI_SUCCESS;
+ }
+
+- BufferTypeBackup = HBufferImage.BufferType;
+ HBufferImage.BufferType = DISK_BUFFER;
+
+ DevicePath = (EFI_DEVICE_PATH_PROTOCOL *) ShellGetMap (DeviceName);
+@@ -427,7 +416,7 @@
Status = LibDevicePathToInterface (
&gEfiBlockIoProtocolGuid,
DevicePath,
@@ -3882,24 +2022,20 @@ index 7e11ad0..52f177b 100644
);
if (EFI_ERROR (Status)) {
return Status;
-diff --git a/hexedit/libmenubar.h b/hexedit/libmenubar.h
-index e3766e2..2c4cff1 100644
---- a/hexedit/libmenubar.h
-+++ b/hexedit/libmenubar.h
-@@ -20,7 +20,7 @@ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
- #ifndef _LIB_MENU_BAR_H_
- #define _LIB_MENU_BAR_H_
-
--#include "Heditortype.h"
-+#include "heditortype.h"
+@@ -448,8 +437,6 @@
+ return Status;
+ }
- EFI_STATUS
- HMainMenuBarInit (
-diff --git a/hexedit/main.c b/hexedit/main.c
-index 9c2a032..0f0dc21 100644
---- a/hexedit/main.c
-+++ b/hexedit/main.c
-@@ -27,7 +27,7 @@ extern UINT8 STRING_ARRAY_NAME[];
+- ByteOffset = MultU64x32 (Offset, BlkIo->Media->BlockSize);
+-
+ //
+ // write the buffer to disk
+ //
+Index: hexedit/main.c
+===================================================================
+--- hexedit/main.c (revision 64)
++++ hexedit/main.c (working copy)
+@@ -27,7 +27,7 @@
//
// Global Variables
//
@@ -3908,7 +2044,16 @@ index 9c2a032..0f0dc21 100644
#if (EFI_SPECIFICATION_VERSION < 0x0002000A)
EFI_HII_PROTOCOL *Hii;
#endif
-@@ -93,10 +93,10 @@ PrintUsage (
+@@ -67,7 +67,7 @@
+ NULL,
+ 0,
+ 0,
+- 0
++ (SHELL_VAR_CHECK_FLAG_TYPE)0
+ }
+ };
+
+@@ -93,10 +93,10 @@
VOID
)
{
@@ -3923,7 +2068,7 @@ index 9c2a032..0f0dc21 100644
Print (L"\n\n");
}
-@@ -147,7 +147,7 @@ Returns:
+@@ -147,7 +147,7 @@
EFI_SHELL_APP_INIT (ImageHandle, SystemTable);
#if (EFI_SPECIFICATION_VERSION < 0x0002000A)
@@ -3932,7 +2077,7 @@ index 9c2a032..0f0dc21 100644
if (EFI_ERROR (Status)) {
return Status;
}
-@@ -158,12 +158,12 @@ Returns:
+@@ -158,12 +158,12 @@
// Register our string package with HII and return the handle to it.
// If previously registered we will simply receive the handle
//
@@ -3947,7 +2092,7 @@ index 9c2a032..0f0dc21 100644
L"hexedit",
EFI_VERSION_1_10
);
-@@ -187,17 +187,17 @@ Returns:
+@@ -187,17 +187,17 @@
switch (RetCode) {
case VarCheckConflict:
@@ -3968,7 +2113,7 @@ index 9c2a032..0f0dc21 100644
break;
default:
-@@ -220,10 +220,10 @@ Returns:
+@@ -220,10 +220,10 @@
ChkPck.FlagCount > 2 ||
(ChkPck.FlagCount == 2 && LibCheckVarGetFlag (&ChkPck, L"-b") == NULL)
) {
@@ -3981,7 +2126,7 @@ index 9c2a032..0f0dc21 100644
Status = EFI_SUCCESS;
}
-@@ -233,13 +233,13 @@ Returns:
+@@ -233,13 +233,13 @@
Item = LibCheckVarGetFlag (&ChkPck, L"-d");
if (Item) {
if (3 < ChkPck.ValueCount) {
@@ -3997,7 +2142,7 @@ index 9c2a032..0f0dc21 100644
Status = EFI_INVALID_PARAMETER;
goto done;
}
-@@ -249,7 +249,7 @@ Returns:
+@@ -249,7 +249,7 @@
Item = Item->Next;
Result = HXtoi (Item->VarStr, &Offset);
if (EFI_ERROR (Result)) {
@@ -4006,7 +2151,7 @@ index 9c2a032..0f0dc21 100644
Status = EFI_INVALID_PARAMETER;
goto done;
}
-@@ -257,13 +257,13 @@ Returns:
+@@ -257,13 +257,13 @@
Item = Item->Next;
Result = HXtoi (Item->VarStr, &Size);
if (EFI_ERROR (Result)) {
@@ -4022,7 +2167,7 @@ index 9c2a032..0f0dc21 100644
Status = EFI_INVALID_PARAMETER;
goto done;
}
-@@ -274,13 +274,13 @@ Returns:
+@@ -274,13 +274,13 @@
Item = LibCheckVarGetFlag (&ChkPck, L"-m");
if (Item) {
if (2 < ChkPck.ValueCount) {
@@ -4038,7 +2183,7 @@ index 9c2a032..0f0dc21 100644
Status = EFI_INVALID_PARAMETER;
goto done;
}
-@@ -288,7 +288,7 @@ Returns:
+@@ -288,7 +288,7 @@
Item = ChkPck.VarList;
Result = HXtoi (Item->VarStr, &Offset);
if (EFI_ERROR (Result)) {
@@ -4047,7 +2192,7 @@ index 9c2a032..0f0dc21 100644
Status = EFI_INVALID_PARAMETER;
goto done;
}
-@@ -296,20 +296,20 @@ Returns:
+@@ -296,20 +296,20 @@
Item = Item->Next;
Result = HXtoi (Item->VarStr, &Size);
if (EFI_ERROR (Result)) {
@@ -4071,7 +2216,7 @@ index 9c2a032..0f0dc21 100644
goto done;
}
-@@ -319,13 +319,13 @@ Returns:
+@@ -319,13 +319,13 @@
Item = LibCheckVarGetFlag (&ChkPck, L"-f");
if (Item) {
if (1 < ChkPck.ValueCount) {
@@ -4087,7 +2232,7 @@ index 9c2a032..0f0dc21 100644
Status = EFI_INVALID_PARAMETER;
goto done;
}
-@@ -333,7 +333,7 @@ Returns:
+@@ -333,7 +333,7 @@
Item = ChkPck.VarList;
Name = Item->VarStr;
if (!HIsValidFileName (Name)) {
@@ -4096,7 +2241,7 @@ index 9c2a032..0f0dc21 100644
Status = EFI_INVALID_PARAMETER;
goto done;
}
-@@ -345,20 +345,20 @@ Returns:
+@@ -345,20 +345,20 @@
if (Name != NULL) {
FreeName = TRUE;
} else {
@@ -4120,7 +2265,7 @@ index 9c2a032..0f0dc21 100644
Status = EFI_INVALID_PARAMETER;
goto done;
}
-@@ -367,7 +367,7 @@ Returns:
+@@ -367,7 +367,7 @@
}
if (SI->RedirArgc != 0) {
@@ -4129,7 +2274,7 @@ index 9c2a032..0f0dc21 100644
Status = EFI_INVALID_PARAMETER;
goto done;
}
-@@ -376,7 +376,7 @@ Returns:
+@@ -376,7 +376,7 @@
if (EFI_ERROR (Status)) {
Out->ClearScreen (Out);
Out->EnableCursor (Out, TRUE);
@@ -4138,7 +2283,18 @@ index 9c2a032..0f0dc21 100644
goto done;
}
-@@ -453,19 +453,19 @@ Returns:
+@@ -421,7 +421,9 @@
+ FALSE
+ );
+ break;
+-
++ case NEW_FILE:
++ Status = EFI_UNSUPPORTED;
++ break;
+ }
+
+ if (!EFI_ERROR (Status)) {
+@@ -453,19 +455,19 @@
//
if (Status == EFI_SUCCESS) {
} else if (Status == EFI_OUT_OF_RESOURCES) {
@@ -4162,227 +2318,345 @@ index 9c2a032..0f0dc21 100644
}
}
-diff --git a/inc/shelltypes.h b/inc/shelltypes.h
-index 1b6cc38..222d165 100644
---- a/inc/shelltypes.h
-+++ b/inc/shelltypes.h
-@@ -36,7 +36,7 @@ extern "C"
+Index: hexedit/libmenubar.h
+===================================================================
+--- hexedit/libmenubar.h (revision 64)
++++ hexedit/libmenubar.h (working copy)
+@@ -20,7 +20,7 @@
+ #ifndef _LIB_MENU_BAR_H_
+ #define _LIB_MENU_BAR_H_
+
+-#include "Heditortype.h"
++#include "heditortype.h"
+
+ EFI_STATUS
+ HMainMenuBarInit (
+@@ -94,3 +94,4 @@
+ );
+
#endif
++
+Index: hexedit/libMisc.h
+===================================================================
+--- hexedit/libMisc.h (revision 64)
++++ hexedit/libMisc.h (working copy)
+@@ -20,7 +20,7 @@
+ #ifndef _LIB_MISC_H_
+ #define _LIB_MISC_H_
- #include "Tiano.h"
--#include "linkedlist.h"
-+#include "LinkedList.h"
+-#include "Heditortype.h"
++#include "heditortype.h"
- #include EFI_PROTOCOL_DEFINITION (FileInfo)
- #include EFI_PROTOCOL_DEFINITION (SimpleFileSystem)
-diff --git a/load/load.inf b/load/load.inf
-index 3ba1dbf..6ce3aae 100644
---- a/load/load.inf
-+++ b/load/load.inf
-@@ -39,23 +39,23 @@ FILE_GUID = 5B93B225-2E47-4a61-8EE5-B8EA42EE3EA8
+ VOID
+ HEditorClearLine (
+@@ -108,3 +108,4 @@
+ );
+
+ #endif
++
+Index: hexedit/libdiskimage.h
+===================================================================
+--- hexedit/libdiskimage.h (revision 64)
++++ hexedit/libdiskimage.h (working copy)
+@@ -58,3 +58,4 @@
+ );
+
+ #endif
++
+Index: hexedit/libclipboard.h
+===================================================================
+--- hexedit/libclipboard.h (revision 64)
++++ hexedit/libclipboard.h (working copy)
+@@ -43,3 +43,4 @@
+ );
+
+ #endif
++
+Index: hexedit/libTitleBar.c
+===================================================================
+--- hexedit/libTitleBar.c (revision 64)
++++ hexedit/libTitleBar.c (working copy)
+@@ -166,6 +166,7 @@
+ // backup the old screen attributes
+ //
+ Orig = HMainEditor.ColorAttributes;
++ New.Data = 0;
+ New.Colors.Foreground = Orig.Colors.Background;
+ New.Colors.Background = Orig.Colors.Foreground;
+
+@@ -212,7 +213,7 @@
+ // the space for file name is 35 characters
+ //
+ if (StrLen (FileNameTmp) <= 35) {
+- PrintToken (STRING_TOKEN (STR_HEXEDIT_LIBTITLEBAR_MAINEDITOR), HiiHandle, FileNameTmp);
++ PrintToken (STRING_TOKEN (STR_HEXEDIT_LIBTITLEBAR_MAINEDITOR), gHexEditHiiHandle, FileNameTmp);
+
+ for (Index = StrLen (FileNameTmp); Index < 35; Index++) {
+ Print (L" ");
+@@ -220,7 +221,7 @@
+
+ } else {
+ for (Index = 0; Index < 32; Index++) {
+- PrintToken (STRING_TOKEN (STR_HEXEDIT_LIBTITLEBAR_MAINEDITOR_C), HiiHandle, FileNameTmp[Index]);
++ PrintToken (STRING_TOKEN (STR_HEXEDIT_LIBTITLEBAR_MAINEDITOR_C), gHexEditHiiHandle, FileNameTmp[Index]);
+ }
+ //
+ // print "..."
+@@ -234,14 +235,14 @@
+ if (StrLen (HMainEditor.BufferImage->DiskImage->Name) <= 9) {
+ PrintToken (
+ STRING_TOKEN (STR_HEXEDIT_LIBTITLEBAR_MAINEDITOR),
+- HiiHandle,
++ gHexEditHiiHandle,
+ HMainEditor.BufferImage->DiskImage->Name
+ );
+ } else {
+ for (Index = 0; Index < 6; Index++) {
+ PrintToken (
+ STRING_TOKEN (STR_HEXEDIT_LIBTITLEBAR_MAINEDITOR_C),
+- HiiHandle,
++ gHexEditHiiHandle,
+ HMainEditor.BufferImage->DiskImage->Name[Index]
+ );
+ }
+@@ -253,7 +254,7 @@
+
+ PrintToken (
+ STRING_TOKEN (STR_HEXEDIT_LIBTITLEBAR_MAINEDITOR_TWOVARS),
+- HiiHandle,
++ gHexEditHiiHandle,
+ HMainEditor.BufferImage->DiskImage->Offset,
+ HMainEditor.BufferImage->DiskImage->Offset + HMainEditor.BufferImage->DiskImage->Size - 1
+ );
+@@ -269,7 +270,7 @@
+ case MEM_BUFFER:
+ PrintToken (
+ STRING_TOKEN (STR_HEXEDIT_LIBTITLEBAR_MAINEDITOR_TWOVARS),
+- HiiHandle,
++ gHexEditHiiHandle,
+ HMainEditor.BufferImage->MemImage->Offset,
+ HMainEditor.BufferImage->MemImage->Offset + HMainEditor.BufferImage->MemImage->Size - 1
+ );
+@@ -280,22 +281,27 @@
+
+ break;
+
++ default:
++ break;
+ }
+ //
+ // 9 characters
+ //
+ switch (HMainEditor.BufferImage->BufferType) {
+ case FILE_BUFFER:
+- PrintToken (STRING_TOKEN (STR_HEXEDIT_LIBTITLEBAR_FILE), HiiHandle);
++ PrintToken (STRING_TOKEN (STR_HEXEDIT_LIBTITLEBAR_FILE), gHexEditHiiHandle);
+ break;
+
+ case DISK_BUFFER:
+- PrintToken (STRING_TOKEN (STR_HEXEDIT_LIBTITLEBAR_DISK), HiiHandle);
++ PrintToken (STRING_TOKEN (STR_HEXEDIT_LIBTITLEBAR_DISK), gHexEditHiiHandle);
+ break;
+
+ case MEM_BUFFER:
+- PrintToken (STRING_TOKEN (STR_HEXEDIT_LIBTITLEBAR_MEM), HiiHandle);
++ PrintToken (STRING_TOKEN (STR_HEXEDIT_LIBTITLEBAR_MEM), gHexEditHiiHandle);
+ break;
++
++ default:
++ break;
+ }
+ //
+ // print modified field
+Index: Ping/Ping.h
+===================================================================
+--- Ping/Ping.h (revision 64)
++++ Ping/Ping.h (working copy)
+@@ -78,3 +78,4 @@
+ } ICMP_TX_INFO;
+
+ #endif
++
+Index: Ping/Ping.inf
+===================================================================
+--- Ping/Ping.inf (revision 64)
++++ Ping/Ping.inf (working copy)
+@@ -25,24 +25,24 @@
COMPONENT_TYPE = APPLICATION
[sources.common]
- ..\ShCommonStrings.uni
+ ../ShCommonStrings.uni
- LoadStrings.uni
- load.c
-
+ PingStrings.uni
+ Ping.h
+ Ping.c
+
[includes.common]
- .
- ..\Inc
- ..\Library
+- $(EDK_SOURCE)\Foundation\Efi
- $(EDK_SOURCE)\Foundation
+- $(EDK_SOURCE)\Foundation\Efi\Include
- $(EDK_SOURCE)\Foundation\Include
- $(EDK_SOURCE)\Foundation\Include\IndustryStandard
-- $(EDK_SOURCE)\Foundation\Efi
-- $(EDK_SOURCE)\Foundation\Efi\Include
- $(EDK_SOURCE)\Foundation\FrameWork
- $(EDK_SOURCE)\Foundation\FrameWork\Include
- $(EDK_SOURCE)\Foundation\Core\Dxe
+- $(EDK_SOURCE)\Foundation\Library\Dxe\Include
- $(DEST_DIR)\
+ ../Inc
+ ../Library
++ $(EDK_SOURCE)/Foundation/Efi
+ $(EDK_SOURCE)/Foundation
++ $(EDK_SOURCE)/Foundation/Efi/Include
+ $(EDK_SOURCE)/Foundation/Include
+ $(EDK_SOURCE)/Foundation/Include/IndustryStandard
-+ $(EDK_SOURCE)/Foundation/Efi
-+ $(EDK_SOURCE)/Foundation/Efi/Include
+ $(EDK_SOURCE)/Foundation/FrameWork
+ $(EDK_SOURCE)/Foundation/FrameWork/Include
+ $(EDK_SOURCE)/Foundation/Core/Dxe
++ $(EDK_SOURCE)/Foundation/Library/Dxe/Include
+ $(DEST_DIR./
[libraries.common]
EfiShellLib
-diff --git a/ls/ls.c b/ls/ls.c
-index bfb4f9c..bc0cb7c 100644
---- a/ls/ls.c
-+++ b/ls/ls.c
-@@ -917,14 +917,14 @@ IsMatch (
+@@ -52,7 +52,6 @@
+ ArchProtocolLib
+ EdkGuidLib
+ EdkFrameworkGuidLib
+- EfiDriverLib
- if ((IsMatch && mIgnoreAttribute) ||
- (IsMatch && !mAttributes && !(Info->Attribute & EFI_FILE_HIDDEN) && !(Info->Attribute & EFI_FILE_SYSTEM)) ||
-- IsMatch &&
-+ (IsMatch &&
- mAttributes &&
- (
- (mAttribA ? (Info->Attribute & EFI_FILE_ARCHIVE ? TRUE : FALSE) : TRUE) &&
- (mAttribH ? (Info->Attribute & EFI_FILE_HIDDEN ? TRUE : FALSE) : TRUE) &&
- (mAttribR ? (Info->Attribute & EFI_FILE_READ_ONLY ? TRUE : FALSE) : TRUE) &&
- (mAttribS ? (Info->Attribute & EFI_FILE_SYSTEM ? TRUE : FALSE) : TRUE) &&
-- (mAttribD ? (Info->Attribute & EFI_FILE_DIRECTORY ? TRUE : FALSE) : TRUE)
-+ (mAttribD ? (Info->Attribute & EFI_FILE_DIRECTORY ? TRUE : FALSE) : TRUE))
- )
- ) {
- IsMatch = TRUE;
-diff --git a/ls/ls.inf b/ls/ls.inf
-index 854a5b1..6717ff9 100644
---- a/ls/ls.inf
-+++ b/ls/ls.inf
-@@ -40,24 +40,24 @@ COMPONENT_TYPE = APPLICATION
+ [libraries.Ia32]
+ CpuIA32Lib
+Index: Ping/Ping.c
+===================================================================
+--- Ping/Ping.c (revision 64)
++++ Ping/Ping.c (working copy)
+@@ -20,14 +20,14 @@
+ --*/
+ #include "EfiShellLib.h"
+-#include "CpuFuncs.h"
++//#include "CpuFuncs.h"
+ #include EFI_ARCH_PROTOCOL_DEFINITION (Cpu)
+ #include EFI_PROTOCOL_DEFINITION (Ip4)
+ #include "Ping.h"
+ #include STRING_DEFINES_FILE
+ extern UINT8 STRING_ARRAY_NAME[];
- [sources.common]
-- ..\ShCommonStrings.uni
-+ ../ShCommonStrings.uni
- LsStrings.uni
- ls.c
- ls.h
-
- [includes.common]
- .
-- ..\Inc
-- ..\Library
-- $(EDK_SOURCE)\Foundation
-- $(EDK_SOURCE)\Foundation\Include
-- $(EDK_SOURCE)\Foundation\Include\IndustryStandard
-- $(EDK_SOURCE)\Foundation\Efi
-- $(EDK_SOURCE)\Foundation\Efi\Include
-- $(EDK_SOURCE)\Foundation\FrameWork
-- $(EDK_SOURCE)\Foundation\FrameWork\Include
-- $(EDK_SOURCE)\Foundation\Core\Dxe
-- $(DEST_DIR)\
-+ ../Inc
-+ ../Library
-+ $(EDK_SOURCE)/Foundation
-+ $(EDK_SOURCE)/Foundation/Include
-+ $(EDK_SOURCE)/Foundation/Include/IndustryStandard
-+ $(EDK_SOURCE)/Foundation/Efi
-+ $(EDK_SOURCE)/Foundation/Efi/Include
-+ $(EDK_SOURCE)/Foundation/FrameWork
-+ $(EDK_SOURCE)/Foundation/FrameWork/Include
-+ $(EDK_SOURCE)/Foundation/Core/Dxe
-+ $(DEST_DIR./
+-EFI_HII_HANDLE HiiHandle;
++STATIC EFI_HII_HANDLE HiiHandle;
- [libraries.common]
- EfiShellLib
-diff --git a/mem/MemCommonPart.c b/mem/MemCommonPart.c
-index 54af027..5e2582c 100644
---- a/mem/MemCommonPart.c
-+++ b/mem/MemCommonPart.c
-@@ -149,7 +149,7 @@ Returns:
- return EFI_SUCCESS;
+ EFI_GUID EfiPingGuid = EFI_PING_GUID;
+ SHELL_VAR_CHECK_ITEM PingCheckList[] = {
+@@ -59,7 +59,7 @@
+ NULL,
+ 0,
+ 0,
+- 0
++ (SHELL_VAR_CHECK_FLAG_TYPE) 0
}
+ };
-- Address = (AddressStr) ? Xtoi (AddressStr) : (UINT64) SystemTable;
-+ Address = (AddressStr) ? Xtoi (AddressStr) : (UINT64)(UINTN) SystemTable;
- Size = (SizeStr) ? Xtoi (SizeStr) : 512;
+@@ -114,6 +114,8 @@
+ UINT32 RttMin;
+ UINT32 RttMax;
- //
-@@ -157,7 +157,7 @@ Returns:
- //
- PrintToken (STRING_TOKEN (STR_MEM_MEMORY_ADDR), HiiMemHandle, 2 * sizeof (UINTN), Address, Size);
- if (MMIo) {
-- Status = BS->LocateProtocol (&gEfiPciRootBridgeIoProtocolGuid, NULL, &PciRootBridgeIo);
-+ Status = BS->LocateProtocol (&gEfiPciRootBridgeIoProtocolGuid, NULL, (VOID**)&PciRootBridgeIo);
- if (EFI_ERROR (Status)) {
- PrintToken (STRING_TOKEN (STR_SHELLENV_GNC_LOC_PROT_ERR_EX), HiiMemHandle, L"mem", L"PciRootBridgeIo");
- return Status;
-@@ -233,7 +233,7 @@ Returns:
- MMIo = FALSE;
- AddressStr = NULL;
- SizeStr = NULL;
-- Address = (UINT64) SystemTable;
-+ Address = (UINT64)(UINTN) SystemTable;
- Size = 512;
- RetCode = LibCheckVariables (SI, MemCheckList, &ChkPck, &Useful);
- if (VarCheckOk != RetCode) {
-@@ -312,7 +312,7 @@ Returns:
- //
- PrintToken (STRING_TOKEN (STR_MEM_NEW_MEMORY_ADDR), HiiMemHandle, 2 * sizeof (UINTN), Address, Size);
- if (MMIo) {
-- Status = BS->LocateProtocol (&gEfiPciRootBridgeIoProtocolGuid, NULL, &PciRootBridgeIo);
-+ Status = BS->LocateProtocol (&gEfiPciRootBridgeIoProtocolGuid, NULL, (VOID**)&PciRootBridgeIo);
- if (EFI_ERROR (Status)) {
- PrintToken (STRING_TOKEN (STR_SHELLENV_GNC_LOC_PROT_ERR_EX), HiiMemHandle, L"mem", L"PciRootBridgeIo");
- return Status;
-diff --git a/mem/efidump.c b/mem/efidump.c
-index d7b22cb..50ba236 100644
---- a/mem/efidump.c
-+++ b/mem/efidump.c
-@@ -24,7 +24,7 @@ Revision History
- --*/
++EFI_CPU_ARCH_PROTOCOL *gCpu = NULL;
++
+ STATIC
+ UINT64
+ GetTimerValue (
+@@ -135,7 +137,22 @@
- #include "debug.h"
--#include "Efipart.h"
-+#include "EfiPart.h"
- #include "EfiShellLib.h"
+ --*/
+ {
+- return EfiReadTsc ();
++ static UINT64 CurrentTick = 0;
++ UINT64 TimerPeriod;
++ EFI_STATUS Status;
++
++ ASSERT (gCpu != NULL);
++
++ Status = gCpu->GetTimerValue (gCpu, 0, &CurrentTick, &TimerPeriod);
++ if (EFI_ERROR (Status)) {
++ //
++ // The WinntGetTimerValue will return EFI_UNSUPPORTED. Set the
++ // TimerPeriod by ourselves.
++ //
++ CurrentTick += 1000000;
++ }
++
++ return CurrentTick;
+ }
- #include STRING_DEFINES_FILE
-@@ -352,8 +352,8 @@ DumpMemSystemTable (
- PrintToken (STRING_TOKEN (STR_DEBUG_STD_ERROR_ON), HiiMemHandle, LibDevicePathToStr (DevicePath));
+ STATIC
+@@ -168,7 +185,7 @@
+ //
+ // Locate the Cpu Arch Protocol.
+ //
+- Status = BS->LocateProtocol (&gEfiCpuArchProtocolGuid, NULL, &Cpu);
++ Status = BS->LocateProtocol (&gEfiCpuArchProtocolGuid, NULL, (VOID**)&Cpu);
+ if (EFI_ERROR (Status)) {
+ return Status;
}
-
-- PrintToken (STRING_TOKEN (STR_DEBUG_RUNTIME_SERVICES), HiiMemHandle, (UINT64) Tbl.Sys->RuntimeServices);
-- PrintToken (STRING_TOKEN (STR_DEBUG_BOOT_SERVICES), HiiMemHandle, (UINT64) Tbl.Sys->BootServices);
-+ PrintToken (STRING_TOKEN (STR_DEBUG_RUNTIME_SERVICES), HiiMemHandle, (UINT64)(UINTN) Tbl.Sys->RuntimeServices);
-+ PrintToken (STRING_TOKEN (STR_DEBUG_BOOT_SERVICES), HiiMemHandle, (UINT64)(UINTN) Tbl.Sys->BootServices);
-
- EFI64_CODE (
- Status = LibGetSystemConfigurationTable(&gEfiSalSystemTableGuid, &SalSystemTable);
-@@ -364,22 +364,22 @@ DumpMemSystemTable (
-
- Status = LibGetSystemConfigurationTable (&gEfiAcpiTableGuid, &AcpiTable);
- if (!EFI_ERROR (Status)) {
-- PrintToken (STRING_TOKEN (STR_DEBUG_ACPI_TABLE), HiiMemHandle, (UINT64) AcpiTable);
-+ PrintToken (STRING_TOKEN (STR_DEBUG_ACPI_TABLE), HiiMemHandle, (UINT64)(UINTN) AcpiTable);
+Index: time/time.c
+===================================================================
+--- time/time.c (revision 64)
++++ time/time.c (working copy)
+@@ -49,7 +49,7 @@
+ NULL,
+ 0,
+ 0,
+- 0
++ (SHELL_VAR_CHECK_FLAG_TYPE) 0
}
+ };
- Status = LibGetSystemConfigurationTable (&gEfiAcpi20TableGuid, &Acpi20Table);
- if (!EFI_ERROR (Status)) {
-- PrintToken (STRING_TOKEN (STR_DEBUG_APCI_2_TABLE), HiiMemHandle, (UINT64) Acpi20Table);
-+ PrintToken (STRING_TOKEN (STR_DEBUG_APCI_2_TABLE), HiiMemHandle, (UINT64)(UINTN) Acpi20Table);
- }
+@@ -64,8 +64,8 @@
+ BOOLEAN
+ GetNumber (
+ IN CHAR16 *Str,
+- IN OUT INTN *Offset,
+- IN OUT INTN *number,
++ IN OUT UINTN *Offset,
++ IN OUT UINTN *number,
+ IN BOOLEAN GetSecond
+ );
- Status = LibGetSystemConfigurationTable (&gEfiMpsTableGuid, &MpsTable);
- if (!EFI_ERROR (Status)) {
-- PrintToken (STRING_TOKEN (STR_DEBUG_MPS_TABLE), HiiMemHandle, (UINT64) MpsTable);
-+ PrintToken (STRING_TOKEN (STR_DEBUG_MPS_TABLE), HiiMemHandle, (UINT64)(UINTN) MpsTable);
+@@ -296,8 +296,8 @@
+ BOOLEAN
+ GetNumber (
+ IN CHAR16 *Str,
+- IN OUT INTN *Offset,
+- IN OUT INTN *Number,
++ IN OUT UINTN *Offset,
++ IN OUT UINTN *Number,
+ IN BOOLEAN GetSecond
+ )
+ {
+Index: time/time.h
+===================================================================
+--- time/time.h (revision 64)
++++ time/time.h (working copy)
+@@ -32,3 +32,4 @@
}
- Status = LibGetSystemConfigurationTable (&gEfiSmbiosTableGuid, &SMBIOSTable);
- if (!EFI_ERROR (Status)) {
-- PrintToken (STRING_TOKEN (STR_DEBUG_SMBIOS_TABLE), HiiMemHandle, (UINT64) SMBIOSTable);
-+ PrintToken (STRING_TOKEN (STR_DEBUG_SMBIOS_TABLE), HiiMemHandle, (UINT64)(UINTN) SMBIOSTable);
- }
- }
+ #endif
++
+Index: time/time.inf
+===================================================================
+--- time/time.inf (revision 64)
++++ time/time.inf (working copy)
+@@ -40,24 +40,24 @@
-diff --git a/mem/mem.inf b/mem/mem.inf
-index 0561176..88090e5 100644
---- a/mem/mem.inf
-+++ b/mem/mem.inf
-@@ -25,7 +25,7 @@ FILE_GUID = 1B0B8206-74DC-4681-AA0D-039A9699EA56
- COMPONENT_TYPE = APPLICATION
[sources.common]
-- ..\ShCommonStrings.uni
-+ ../ShCommonStrings.uni
- MemStrings.uni
- DebugStrings.uni
- mm.c
-@@ -34,17 +34,17 @@ COMPONENT_TYPE = APPLICATION
-
+- ..\ShCommonStrings.uni
++ ../ShCommonStrings.uni
+ TimeStrings.uni
+ Time.c
+ Time.h
+
[includes.common]
.
- ..\Inc
@@ -4410,33 +2684,50 @@ index 0561176..88090e5 100644
[libraries.common]
EfiShellLib
-diff --git a/memmap/memmap.c b/memmap/memmap.c
-index f7353ff..7b0e893 100644
---- a/memmap/memmap.c
-+++ b/memmap/memmap.c
-@@ -35,7 +35,7 @@ extern UINT8 STRING_ARRAY_NAME[];
+Index: mount/mount.c
+===================================================================
+--- mount/mount.c (revision 64)
++++ mount/mount.c (working copy)
+@@ -36,7 +36,7 @@
//
// Global Variables
//
-EFI_HII_HANDLE HiiHandle;
+STATIC EFI_HII_HANDLE HiiHandle;
- EFI_GUID EfiMemmapGuid = EFI_MEMMAP_GUID;
- SHELL_VAR_CHECK_ITEM MemmapCheckList[] = {
+ EFI_GUID EfiMountGuid = EFI_MOUNT_GUID;
+ SHELL_VAR_CHECK_ITEM MountCheckList[] = {
{
-diff --git a/memmap/memmap.inf b/memmap/memmap.inf
-index 1d68c61..fcbcfc7 100644
---- a/memmap/memmap.inf
-+++ b/memmap/memmap.inf
-@@ -40,7 +40,7 @@ COMPONENT_TYPE = APPLICATION
+@@ -55,7 +55,7 @@
+ NULL,
+ 0,
+ 0,
+- 0
++ (SHELL_VAR_CHECK_FLAG_TYPE) 0
+ }
+ };
+
+Index: mount/mount.h
+===================================================================
+--- mount/mount.h (revision 64)
++++ mount/mount.h (working copy)
+@@ -33,3 +33,4 @@
+ }
+
+ #endif
++
+Index: mount/mount.inf
+===================================================================
+--- mount/mount.inf (revision 64)
++++ mount/mount.inf (working copy)
+@@ -40,24 +40,24 @@
[sources.common]
- ..\ShCommonStrings.uni
+ ../ShCommonStrings.uni
- memmapStrings.uni
- memmap.c
- memmap.h
-@@ -48,17 +48,17 @@ COMPONENT_TYPE = APPLICATION
+ MountStrings.uni
+ mount.c
+ mount.h
[includes.common]
.
@@ -4465,24 +2756,11 @@ index 1d68c61..fcbcfc7 100644
[libraries.common]
EfiShellLib
-diff --git a/mkdir/mkdir.c b/mkdir/mkdir.c
-index 79a08ca..c105726 100644
---- a/mkdir/mkdir.c
-+++ b/mkdir/mkdir.c
-@@ -49,7 +49,7 @@ MkDir (
- //
- // Global Variables
- //
--EFI_HII_HANDLE HiiHandle;
-+STATIC EFI_HII_HANDLE HiiHandle;
- EFI_GUID EfiMkdirGuid = EFI_MKDIR_GUID;
- SHELL_VAR_CHECK_ITEM MkdirCheckList[] = {
- {
-diff --git a/mkdir/mkdir.inf b/mkdir/mkdir.inf
-index e49daac..efbc4ab 100644
---- a/mkdir/mkdir.inf
-+++ b/mkdir/mkdir.inf
-@@ -41,23 +41,23 @@ COMPONENT_TYPE = APPLICATION
+Index: mkdir/mkdir.inf
+===================================================================
+--- mkdir/mkdir.inf (revision 64)
++++ mkdir/mkdir.inf (working copy)
+@@ -41,23 +41,23 @@
[sources.common]
MkdirStrings.uni
@@ -4518,41 +2796,86 @@ index e49daac..efbc4ab 100644
[libraries.common]
EfiShellLib
-diff --git a/mm/mm.c b/mm/mm.c
-index 033849b..1c8c51b 100644
---- a/mm/mm.c
-+++ b/mm/mm.c
-@@ -73,7 +73,7 @@ GetHex (
+Index: mkdir/mkdir.c
+===================================================================
+--- mkdir/mkdir.c (revision 64)
++++ mkdir/mkdir.c (working copy)
+@@ -49,7 +49,7 @@
//
// Global Variables
//
--EFI_HII_HANDLE HiiHandle;
-+STATIC EFI_HII_HANDLE HiiHandle;
- EFI_GUID EfiIomodGuid = EFI_IOMOD_GUID;
- SHELL_VAR_CHECK_ITEM IomodCheckList[] = {
+-EFI_HII_HANDLE HiiHandle;
++STATIC EFI_HII_HANDLE HiiHandle;
+ EFI_GUID EfiMkdirGuid = EFI_MKDIR_GUID;
+ SHELL_VAR_CHECK_ITEM MkdirCheckList[] = {
{
-@@ -750,7 +750,7 @@ GetHex (
- }
+@@ -68,7 +68,7 @@
+ NULL,
+ 0,
+ 0,
+- 0
++ (SHELL_VAR_CHECK_FLAG_TYPE) 0
+ }
+ };
+
+Index: mkdir/mkdir.h
+===================================================================
+--- mkdir/mkdir.h (revision 64)
++++ mkdir/mkdir.h (working copy)
+@@ -29,4 +29,5 @@
+ 0x75ecb57f, 0x4264, 0x49d2, 0x98, 0xe6, 0x39, 0x1a, 0x32, 0x17, 0x9d, 0xf2 \
+ }
- if ((c >= '0' && c <= '9') || (c >= 'A' && c <= 'F')) {
-- u = u << 4 | c - (c >= 'A' ? 'A' - 10 : '0');
-+ u = (u << 4) | (c - (c >= 'A' ? 'A' - 10 : '0'));
+-#endif
+\ No newline at end of file
++#endif
++
+Index: pci/pci.h
+===================================================================
+--- pci/pci.h (revision 64)
++++ pci/pci.h (working copy)
+@@ -30,7 +30,7 @@
+ 0x388da6c3, 0x3447, 0x4b1f, 0xa0, 0xba, 0xa9, 0xe8, 0xa2, 0x87, 0xf1, 0x76 \
+ }
- Find = TRUE;
- } else {
-diff --git a/mm/mm.inf b/mm/mm.inf
-index 4857d9e..fa84147 100644
---- a/mm/mm.inf
-+++ b/mm/mm.inf
-@@ -41,23 +41,23 @@ COMPONENT_TYPE = APPLICATION
+-#include "TIANO.h"
++#include "Tiano.h"
+
+ typedef enum {
+ PciDevice,
+@@ -477,3 +477,4 @@
+ #pragma pack()
+
+ #endif // _PCI_H_
++
+Index: pci/pci_class.c
+===================================================================
+--- pci/pci_class.c (revision 64)
++++ pci/pci_class.c (working copy)
+@@ -30,7 +30,7 @@
+ //
+ // Global Variables
+ //
+-EFI_HII_HANDLE HiiHandle;
++STATIC EFI_HII_HANDLE HiiHandle;
+
+ PCI_CLASS_ENTRY gClassStringList[];
+
+Index: pci/pci.inf
+===================================================================
+--- pci/pci.inf (revision 64)
++++ pci/pci.inf (working copy)
+@@ -41,7 +41,7 @@
[sources.common]
- MmStrings.uni
+ PciStrings.uni
- ..\ShCommonStrings.uni
+ ../ShCommonStrings.uni
- mm.c
- mm.h
-
+ pci.c
+ pci.h
+ pci_class.h
+@@ -49,17 +49,17 @@
+
[includes.common]
.
- ..\Inc
@@ -4580,19 +2903,133 @@ index 4857d9e..fa84147 100644
[libraries.common]
EfiShellLib
-diff --git a/mode/mode.inf b/mode/mode.inf
-index 47e5c80..beee5dc 100644
---- a/mode/mode.inf
-+++ b/mode/mode.inf
-@@ -40,24 +40,24 @@ COMPONENT_TYPE = APPLICATION
+Index: pci/pci_class.h
+===================================================================
+--- pci/pci_class.h (revision 64)
++++ pci/pci_class.h (working copy)
+@@ -24,7 +24,7 @@
+ #ifndef _PCI_CLASS_H_
+ #define _PCI_CLASS_H_
+
+-#include "TIANO.h" // for UINT32 etc.
++#include "Tiano.h" // for UINT32 etc.
+ #define PCI_CLASS_STRING_LIMIT 54
+ //
+ // Printable strings for Pci class code
+@@ -58,3 +58,4 @@
+ );
+
+ #endif // _PCI_CLASS_H_
++
+Index: pci/pci.c
+===================================================================
+--- pci/pci.c (revision 64)
++++ pci/pci.c (working copy)
+@@ -334,7 +334,7 @@
+ {
+ 0,
+ 0,
+- 0,
++ (PCIE_CAPREG_FIELD_WIDTH)0,
+ NULL,
+ PcieExplainTypeMax
+ }
+@@ -344,7 +344,7 @@
+ // Global Variables
+ //
+ PCI_CONFIG_SPACE *mConfigSpace;
+-EFI_HII_HANDLE HiiHandle;
++STATIC EFI_HII_HANDLE HiiHandle;
+ EFI_GUID EfiPciGuid = EFI_PCI_GUID;
+ SHELL_VAR_CHECK_ITEM PciCheckList[] = {
+ {
+@@ -375,7 +375,7 @@
+ NULL,
+ 0,
+ 0,
+- 0
++ (SHELL_VAR_CHECK_FLAG_TYPE) 0
+ }
+ };
+
+@@ -1034,7 +1034,7 @@
+ Status = BS->HandleProtocol (
+ Handle,
+ &gEfiPciRootBridgeIoProtocolGuid,
+- IoDev
++ (VOID**)IoDev
+ );
+
+ if (EFI_ERROR (Status)) {
+@@ -1043,7 +1043,7 @@
+ //
+ // Call Configuration() to get address space descriptors
+ //
+- Status = (*IoDev)->Configuration (*IoDev, Descriptors);
++ Status = (*IoDev)->Configuration (*IoDev, (VOID**)Descriptors);
+ if (Status == EFI_UNSUPPORTED) {
+ *Descriptors = NULL;
+ return EFI_SUCCESS;
+@@ -1237,7 +1237,7 @@
+ PrintToken (STRING_TOKEN (STR_PCI2_SINGLE_FUNCTION), HiiHandle);
+ }
+
+- HeaderType = (UINT8) (Common->HeaderType & 0x7f);
++ HeaderType = (PCI_HEADER_TYPE) (Common->HeaderType & 0x7f);
+ switch (HeaderType) {
+ case PciDevice:
+ PrintToken (STRING_TOKEN (STR_PCI2_PCI_DEVICE), HiiHandle);
+@@ -1300,6 +1300,9 @@
+ );
+ CapPtr = ConfigSpace->NonCommon.CardBus.CapabilitiesPtr;
+ break;
++
++ default:
++ Status = EFI_UNSUPPORTED;
+ }
+ //
+ // If Status bit4 is 1, dump or explain capability structure
+@@ -1956,7 +1959,7 @@
+ INDEX_OF (&(CardBus->IoBase0)),
+ Io32Bit ? L" 32 bit" : L" 16 bit",
+ CardBus->IoBase0 & (Io32Bit ? 0xfffffffc : 0x0000fffc),
+- CardBus->IoLimit0 & (Io32Bit ? 0xffffffff : 0x0000ffff) | 0x00000003
++ (CardBus->IoLimit0 & (Io32Bit ? 0xffffffff : 0x0000ffff)) | 0x00000003
+ );
+
+ Io32Bit = (BOOLEAN) (CardBus->IoBase1 & PCI_BIT_0);
+@@ -1966,7 +1969,7 @@
+ INDEX_OF (&(CardBus->IoBase1)),
+ Io32Bit ? L" 32 bit" : L" 16 bit",
+ CardBus->IoBase1 & (Io32Bit ? 0xfffffffc : 0x0000fffc),
+- CardBus->IoLimit1 & (Io32Bit ? 0xffffffff : 0x0000ffff) | 0x00000003
++ (CardBus->IoLimit1 & (Io32Bit ? 0xffffffff : 0x0000ffff)) | 0x00000003
+ );
+
+ //
+Index: memmap/memmap.h
+===================================================================
+--- memmap/memmap.h (revision 64)
++++ memmap/memmap.h (working copy)
+@@ -33,3 +33,4 @@
+ }
+
+ #endif
++
+Index: memmap/memmap.inf
+===================================================================
+--- memmap/memmap.inf (revision 64)
++++ memmap/memmap.inf (working copy)
+@@ -40,7 +40,7 @@
[sources.common]
- ..\ShCommonStrings.uni
+ ../ShCommonStrings.uni
- ModeStrings.uni
- mode.c
- mode.h
+ memmapStrings.uni
+ memmap.c
+ memmap.h
+@@ -48,17 +48,17 @@
[includes.common]
.
@@ -4621,33 +3058,59 @@ index 47e5c80..beee5dc 100644
[libraries.common]
EfiShellLib
-diff --git a/mount/mount.c b/mount/mount.c
-index fa32b1f..fd34238 100644
---- a/mount/mount.c
-+++ b/mount/mount.c
-@@ -36,7 +36,7 @@ extern UINT8 STRING_ARRAY_NAME[];
+Index: memmap/memmap.c
+===================================================================
+--- memmap/memmap.c (revision 64)
++++ memmap/memmap.c (working copy)
+@@ -35,7 +35,7 @@
//
// Global Variables
//
-EFI_HII_HANDLE HiiHandle;
+STATIC EFI_HII_HANDLE HiiHandle;
- EFI_GUID EfiMountGuid = EFI_MOUNT_GUID;
- SHELL_VAR_CHECK_ITEM MountCheckList[] = {
+ EFI_GUID EfiMemmapGuid = EFI_MEMMAP_GUID;
+ SHELL_VAR_CHECK_ITEM MemmapCheckList[] = {
{
-diff --git a/mount/mount.inf b/mount/mount.inf
-index 922c490..71144af 100644
---- a/mount/mount.inf
-+++ b/mount/mount.inf
-@@ -40,24 +40,24 @@ COMPONENT_TYPE = APPLICATION
+@@ -54,7 +54,7 @@
+ NULL,
+ 0,
+ 0,
+- 0
++ (SHELL_VAR_CHECK_FLAG_TYPE) 0
+ }
+ };
+
+@@ -216,7 +216,7 @@
+ }
+ Bytes = LShiftU64 (Desc->NumberOfPages, 12);
+- Ptr = MemoryTypeStr (Desc->Type);
++ Ptr = MemoryTypeStr ((EFI_MEMORY_TYPE)Desc->Type);
+ PrintToken (
+ STRING_TOKEN (STR_MEMMAP_FIVE_ARGS),
+ HiiHandle,
+Index: dblk/dblk.h
+===================================================================
+--- dblk/dblk.h (revision 64)
++++ dblk/dblk.h (working copy)
+@@ -168,3 +168,4 @@
+ extern EFI_HII_HANDLE HiiDblkHandle;
+
+ #endif
++
+Index: dblk/dblk.inf
+===================================================================
+--- dblk/dblk.inf (revision 64)
++++ dblk/dblk.inf (working copy)
+@@ -26,23 +26,23 @@
[sources.common]
+ DblkStrings.uni
- ..\ShCommonStrings.uni
+ ../ShCommonStrings.uni
- MountStrings.uni
- mount.c
- mount.h
-
+ dblk.c
+ efidump.c
+
[includes.common]
.
- ..\Inc
@@ -4675,32 +3138,110 @@ index 922c490..71144af 100644
[libraries.common]
EfiShellLib
-diff --git a/mv/mv.c b/mv/mv.c
-index 3b04021..47617e5 100644
---- a/mv/mv.c
-+++ b/mv/mv.c
-@@ -36,7 +36,7 @@ extern UINT8 STRING_ARRAY_NAME[];
- //
- // Global Variables
- //
--EFI_HII_HANDLE HiiHandle;
-+STATIC EFI_HII_HANDLE HiiHandle;
- EFI_GUID EfiMvGuid = EFI_MV_GUID;
- SHELL_VAR_CHECK_ITEM MvCheckList[] = {
- {
-diff --git a/mv/mv.inf b/mv/mv.inf
-index b52e28d..0a4a326 100644
---- a/mv/mv.inf
-+++ b/mv/mv.inf
-@@ -40,24 +40,24 @@ COMPONENT_TYPE = APPLICATION
+Index: dblk/efidump.c
+===================================================================
+--- dblk/efidump.c (revision 64)
++++ dblk/efidump.c (working copy)
+@@ -24,7 +24,7 @@
+ --*/
+
+ #include "dblk.h"
+-#include "Efipart.h"
++#include "EfiPart.h"
+ #include "EfiShellLib.h"
+
+ #include STRING_DEFINES_FILE
+@@ -320,13 +320,11 @@
+ VOID *AcpiTable;
+ VOID *Acpi20Table;
+ VOID *SMBIOSTable;
+- VOID *SalSystemTable;
+ VOID *MpsTable;
+
+ AcpiTable = NULL;
+ Acpi20Table = NULL;
+ SMBIOSTable = NULL;
+- SalSystemTable = NULL;
+ MpsTable = NULL;
+
+ PrintToken (
+@@ -352,10 +350,12 @@
+ PrintToken (STRING_TOKEN (STR_DEBUG_STD_ERROR_ON), HiiDblkHandle, LibDevicePathToStr (DevicePath));
+ }
+
+- PrintToken (STRING_TOKEN (STR_DEBUG_RUNTIME_SERVICES), HiiDblkHandle, (UINT64) Tbl.Sys->RuntimeServices);
+- PrintToken (STRING_TOKEN (STR_DEBUG_BOOT_SERVICES), HiiDblkHandle, (UINT64) Tbl.Sys->BootServices);
++ PrintToken (STRING_TOKEN (STR_DEBUG_RUNTIME_SERVICES), HiiDblkHandle, (UINT64)(UINTN) Tbl.Sys->RuntimeServices);
++ PrintToken (STRING_TOKEN (STR_DEBUG_BOOT_SERVICES), HiiDblkHandle, (UINT64)(UINTN) Tbl.Sys->BootServices);
+
+ EFI64_CODE (
++ VOID *SalSystemTable;
++
+ Status = LibGetSystemConfigurationTable(&gEfiSalSystemTableGuid, &SalSystemTable);
+ if (!EFI_ERROR(Status)) {
+ PrintToken (STRING_TOKEN(STR_DEBUG_SAL_SYSTEM_TABLE), HiiDblkHandle, (UINT64)SalSystemTable);
+@@ -364,22 +364,22 @@
+
+ Status = LibGetSystemConfigurationTable (&gEfiAcpiTableGuid, &AcpiTable);
+ if (!EFI_ERROR (Status)) {
+- PrintToken (STRING_TOKEN (STR_DEBUG_ACPI_TABLE), HiiDblkHandle, (UINT64) AcpiTable);
++ PrintToken (STRING_TOKEN (STR_DEBUG_ACPI_TABLE), HiiDblkHandle, (UINT64)(UINTN) AcpiTable);
+ }
+
+ Status = LibGetSystemConfigurationTable (&gEfiAcpi20TableGuid, &Acpi20Table);
+ if (!EFI_ERROR (Status)) {
+- PrintToken (STRING_TOKEN (STR_DEBUG_APCI_2_TABLE), HiiDblkHandle, (UINT64) Acpi20Table);
++ PrintToken (STRING_TOKEN (STR_DEBUG_APCI_2_TABLE), HiiDblkHandle, (UINT64)(UINTN) Acpi20Table);
+ }
+
+ Status = LibGetSystemConfigurationTable (&gEfiMpsTableGuid, &MpsTable);
+ if (!EFI_ERROR (Status)) {
+- PrintToken (STRING_TOKEN (STR_DEBUG_MPS_TABLE), HiiDblkHandle, (UINT64) MpsTable);
++ PrintToken (STRING_TOKEN (STR_DEBUG_MPS_TABLE), HiiDblkHandle, (UINT64)(UINTN) MpsTable);
+ }
+
+ Status = LibGetSystemConfigurationTable (&gEfiSmbiosTableGuid, &SMBIOSTable);
+ if (!EFI_ERROR (Status)) {
+- PrintToken (STRING_TOKEN (STR_DEBUG_SMBIOS_TABLE), HiiDblkHandle, (UINT64) SMBIOSTable);
++ PrintToken (STRING_TOKEN (STR_DEBUG_SMBIOS_TABLE), HiiDblkHandle, (UINT64)(UINTN) SMBIOSTable);
+ }
+ }
+
+Index: dblk/dblk.c
+===================================================================
+--- dblk/dblk.c (revision 64)
++++ dblk/dblk.c (working copy)
+@@ -52,7 +52,7 @@
+ NULL,
+ 0,
+ 0,
+- 0
++ (SHELL_VAR_CHECK_FLAG_TYPE) 0
+ }
+ };
+
+Index: date/date.h
+===================================================================
+--- date/date.h (revision 64)
++++ date/date.h (working copy)
+@@ -32,3 +32,4 @@
+ }
+
+ #endif
++
+Index: date/date.inf
+===================================================================
+--- date/date.inf (revision 64)
++++ date/date.inf (working copy)
+@@ -40,24 +40,24 @@
[sources.common]
- ..\ShCommonStrings.uni
+ ../ShCommonStrings.uni
- MvStrings.uni
- mv.c
- mv.h
+ DateStrings.uni
+ Date.c
+ Date.h
[includes.common]
.
@@ -4729,124 +3270,75 @@ index b52e28d..0a4a326 100644
[libraries.common]
EfiShellLib
-diff --git a/newshell/FakeHii.c b/newshell/FakeHii.c
-index c187b47..5dff3ad 100644
---- a/newshell/FakeHii.c
-+++ b/newshell/FakeHii.c
-@@ -196,7 +196,7 @@ FakeUninstallHiiDatabase (
- Status = BS->HandleProtocol (
- mFakeHiiHandle,
- &gEfiHiiProtocolGuid,
-- &FakeHii
-+ (VOID**)&FakeHii
- );
- Status = BS->UninstallProtocolInterface (
- mFakeHiiHandle,
-@@ -320,7 +320,7 @@ InsertStringPackage (
- if (Language == NULL) {
- return EFI_OUT_OF_RESOURCES;
- }
-- strcpya (Language, (UINT8 *) PackageHdr + HeaderSize - LanguageSize);
-+ strcpya (Language, (CHAR8*) ((UINT8 *) PackageHdr + HeaderSize - LanguageSize));
- for (Link = PackageList->StringPkgHdr.Flink; Link != &PackageList->StringPkgHdr; Link = Link->Flink) {
- StringPackage = CR (Link, FAKE_HII_STRING_PACKAGE, Entry, FAKE_HII_STRING_PACKAGE_SIGNATURE);
- if (CompareLanguage (Language, StringPackage->StringPkgHdr->Language)) {
-@@ -770,7 +770,7 @@ FakeHiiGetString (
- StringPackage = NULL;
- for (Link = DatabaseRecord->StringPkgHdr.Flink; Link != &DatabaseRecord->StringPkgHdr; Link = Link->Flink) {
- StringPackage = CR (Link, FAKE_HII_STRING_PACKAGE, Entry, FAKE_HII_STRING_PACKAGE_SIGNATURE);
-- if (CompareLanguage (StringPackage->StringPkgHdr->Language, (UINT8 *) Language)) {
-+ if (CompareLanguage (StringPackage->StringPkgHdr->Language, (CHAR8 *) Language)) {
- Matched = TRUE;
- break;
- }
-diff --git a/newshell/init.c b/newshell/init.c
-index fd4adf6..33fec86 100644
---- a/newshell/init.c
-+++ b/newshell/init.c
-@@ -23,7 +23,7 @@ Abstract:
- #include "nshell.h"
+Index: date/date.c
+===================================================================
+--- date/date.c (revision 64)
++++ date/date.c (working copy)
+@@ -53,8 +53,8 @@
+ BOOLEAN
+ GetNumber (
+ IN CHAR16 *Str,
+- IN OUT INTN *Position,
+- IN OUT INTN *Number,
++ IN OUT UINTN *Position,
++ IN OUT UINTN *Number,
+ IN BOOLEAN EndNum
+ );
- extern UINT8 STRING_ARRAY_NAME[];
--extern BOOLEAN gHiiInitialized = FALSE;
-+BOOLEAN gHiiInitialized = FALSE;
+@@ -92,7 +92,7 @@
+ NULL,
+ 0,
+ 0,
+- 0
++ (SHELL_VAR_CHECK_FLAG_TYPE) 0
+ }
+ };
- //
- // This is the generated header file which includes whatever needs to be exported (strings + IFR)
-@@ -99,13 +99,13 @@ _GetFsDpOfImg (
- Status = BS->HandleProtocol (
- ImgHnd,
- &gEfiLoadedImageProtocolGuid,
-- &img
-+ (VOID**)&img
- );
- if (!EFI_ERROR (Status)) {
- Status = BS->HandleProtocol (
- img->DeviceHandle,
- &gEfiDevicePathProtocolGuid,
-- &dp
-+ (VOID**)&dp
- );
- if (!EFI_ERROR (Status)) {
- *DevPath = DuplicateDevicePath (dp);
-@@ -220,7 +220,7 @@ _DoInit (
- //
- Status = LibLocateProtocol (
- &gEfiConsoleControlProtocolGuid,
-- &ConsoleControl
-+ (VOID**)&ConsoleControl
- );
- if (!EFI_ERROR (Status)) {
- Status = ConsoleControl->GetMode (ConsoleControl, &mOldCurrentMode, NULL, NULL);
-@@ -342,7 +342,7 @@ _EnableShellEnv (
- Status = _ShellLoadEnvDriver (ImageHandle);
- )
- if (EFI_ERROR (Status)) {
-- Status = LibLocateProtocol (&ShellEnvProtocol, &SE);
-+ Status = LibLocateProtocol (&ShellEnvProtocol, (VOID**)&SE);
- if (EFI_ERROR (Status)) {
- PrintToken (STRING_TOKEN (STR_NSHELL_ENV_DRIVER), HiiNewshellHandle);
- return Status;
-@@ -372,7 +372,7 @@ _InstallShellInterface (
- *IsRootInstance = TRUE;
+@@ -330,8 +330,8 @@
+ BOOLEAN
+ GetNumber (
+ IN CHAR16 *Str,
+- IN OUT INTN *Position,
+- IN OUT INTN *Number,
++ IN OUT UINTN *Position,
++ IN OUT UINTN *Number,
+ IN BOOLEAN EndNum
+ )
+ {
+Index: rm/rm.c
+===================================================================
+--- rm/rm.c (revision 64)
++++ rm/rm.c (working copy)
+@@ -54,7 +54,7 @@
+ NULL,
+ 0,
+ 0,
+- FALSE
++ (SHELL_VAR_CHECK_FLAG_TYPE) FALSE
}
+ };
-- Status = LibLocateProtocol (&ShellEnvProtocol, &SE);
-+ Status = LibLocateProtocol (&ShellEnvProtocol, (VOID**)&SE);
- ASSERT (!EFI_ERROR (Status));
- SI = SE->NewShell (ImageHandle);
+Index: rm/rm.h
+===================================================================
+--- rm/rm.h (revision 64)
++++ rm/rm.h (working copy)
+@@ -59,3 +59,4 @@
+ );
-@@ -543,7 +543,7 @@ _CleanUpOnExit (
- //
- ConsoleControlStatus = LibLocateProtocol (
- &gEfiConsoleControlProtocolGuid,
-- &ConsoleControl
-+ (VOID**)&ConsoleControl
- );
- if (!EFI_ERROR (ConsoleControlStatus)) {
- ConsoleControlStatus = ConsoleControl->GetMode (ConsoleControl, &CurrentMode, NULL, NULL);
-@@ -723,7 +723,7 @@ Returns:
- Status = BS->HandleProtocol (
- ImageHandle,
- &ShellInterfaceProtocol,
-- &SI
-+ (VOID**)&SI
- );
- ASSERT (!EFI_ERROR (Status));
- }
-diff --git a/newshell/nshell.inf b/newshell/nshell.inf
-index 22479b0..b69f1a1 100644
---- a/newshell/nshell.inf
-+++ b/newshell/nshell.inf
-@@ -26,24 +26,24 @@ COMPONENT_TYPE = APPLICATION
+ #endif
++
+Index: rm/rm.inf
+===================================================================
+--- rm/rm.inf (revision 64)
++++ rm/rm.inf (working copy)
+@@ -41,23 +41,23 @@
[sources.common]
- NshellStrings.uni
-- ..\ShCommonStrings.uni
-+ ../ShCommonStrings.uni
- init.c
- nshell.h
- fakehii.c
+ RmStrings.uni
+- ..\ShCommonStrings.uni
++ ../ShCommonStrings.uni
+ rm.h
+ rm.c
[includes.common]
.
@@ -4875,32 +3367,98 @@ index 22479b0..b69f1a1 100644
[libraries.common]
EfiShellLib
-diff --git a/openinfo/openinfo.c b/openinfo/openinfo.c
-index 9b3356c..c7dfb9e 100644
---- a/openinfo/openinfo.c
-+++ b/openinfo/openinfo.c
-@@ -36,7 +36,7 @@ extern UINT8 STRING_ARRAY_NAME[];
- //
- // Global Variables
- //
--EFI_HII_HANDLE HiiHandle;
-+STATIC EFI_HII_HANDLE HiiHandle;
- EFI_GUID EfiOpeninfoGuid = EFI_OPENINFO_GUID;
- SHELL_VAR_CHECK_ITEM OpeninfoCheckList[] = {
- {
-diff --git a/openinfo/openinfo.inf b/openinfo/openinfo.inf
-index 638462d..383d58a 100644
---- a/openinfo/openinfo.inf
-+++ b/openinfo/openinfo.inf
-@@ -41,24 +41,24 @@ COMPONENT_TYPE = APPLICATION
+Index: mem/MemCommonPart.c
+===================================================================
+--- mem/MemCommonPart.c (revision 64)
++++ mem/MemCommonPart.c (working copy)
+@@ -58,7 +58,7 @@
+ NULL,
+ 0,
+ 0,
+- 0
++ (SHELL_VAR_CHECK_FLAG_TYPE) 0
+ }
+ };
+
+@@ -149,7 +149,7 @@
+ return EFI_SUCCESS;
+ }
+
+- Address = (AddressStr) ? Xtoi (AddressStr) : (UINT64) SystemTable;
++ Address = (AddressStr) ? Xtoi (AddressStr) : (UINT64)(UINTN) SystemTable;
+ Size = (SizeStr) ? Xtoi (SizeStr) : 512;
+
+ //
+@@ -157,7 +157,7 @@
+ //
+ PrintToken (STRING_TOKEN (STR_MEM_MEMORY_ADDR), HiiMemHandle, 2 * sizeof (UINTN), Address, Size);
+ if (MMIo) {
+- Status = BS->LocateProtocol (&gEfiPciRootBridgeIoProtocolGuid, NULL, &PciRootBridgeIo);
++ Status = BS->LocateProtocol (&gEfiPciRootBridgeIoProtocolGuid, NULL, (VOID**)&PciRootBridgeIo);
+ if (EFI_ERROR (Status)) {
+ PrintToken (STRING_TOKEN (STR_SHELLENV_GNC_LOC_PROT_ERR_EX), HiiMemHandle, L"mem", L"PciRootBridgeIo");
+ return Status;
+@@ -172,7 +172,7 @@
+ return Status;
+ }
+
+- PciRootBridgeIo->Mem.Read (PciRootBridgeIo, EfiPciIoWidthUint8, Address, Size, Buffer);
++ PciRootBridgeIo->Mem.Read (PciRootBridgeIo, EfiPciWidthUint8, Address, Size, Buffer);
+ } else {
+ Buffer = (UINT8 *) (UINTN) Address;
+ }
+@@ -233,7 +233,7 @@
+ MMIo = FALSE;
+ AddressStr = NULL;
+ SizeStr = NULL;
+- Address = (UINT64) SystemTable;
++ Address = (UINT64)(UINTN) SystemTable;
+ Size = 512;
+ RetCode = LibCheckVariables (SI, MemCheckList, &ChkPck, &Useful);
+ if (VarCheckOk != RetCode) {
+@@ -312,7 +312,7 @@
+ //
+ PrintToken (STRING_TOKEN (STR_MEM_NEW_MEMORY_ADDR), HiiMemHandle, 2 * sizeof (UINTN), Address, Size);
+ if (MMIo) {
+- Status = BS->LocateProtocol (&gEfiPciRootBridgeIoProtocolGuid, NULL, &PciRootBridgeIo);
++ Status = BS->LocateProtocol (&gEfiPciRootBridgeIoProtocolGuid, NULL, (VOID**)&PciRootBridgeIo);
+ if (EFI_ERROR (Status)) {
+ PrintToken (STRING_TOKEN (STR_SHELLENV_GNC_LOC_PROT_ERR_EX), HiiMemHandle, L"mem", L"PciRootBridgeIo");
+ return Status;
+@@ -327,7 +327,7 @@
+ return Status;
+ }
+
+- PciRootBridgeIo->Mem.Read (PciRootBridgeIo, EfiPciIoWidthUint8, Address, Size, Buffer);
++ PciRootBridgeIo->Mem.Read (PciRootBridgeIo, EfiPciWidthUint8, Address, Size, Buffer);
+ } else {
+ Buffer = (UINT8 *) (UINTN) Address;
+ }
+Index: mem/MemCommonPart.h
+===================================================================
+--- mem/MemCommonPart.h (revision 64)
++++ mem/MemCommonPart.h (working copy)
+@@ -62,4 +62,4 @@
+ IN EFI_BLOCK_IO_PROTOCOL *BlkIo
+ );
+
+-#endif
+\ No newline at end of file
++#endif
+Index: mem/mem.inf
+===================================================================
+--- mem/mem.inf (revision 64)
++++ mem/mem.inf (working copy)
+@@ -25,7 +25,7 @@
+ COMPONENT_TYPE = APPLICATION
[sources.common]
- OPeninfoStrings.uni
- ..\ShCommonStrings.uni
+ ../ShCommonStrings.uni
- openinfo.c
- openinfo.h
-
+ MemStrings.uni
+ DebugStrings.uni
+ mm.c
+@@ -34,17 +34,17 @@
[includes.common]
.
@@ -4929,83 +3487,175 @@ index 638462d..383d58a 100644
[libraries.common]
EfiShellLib
-diff --git a/pci/pci.c b/pci/pci.c
-index 8dc0dba..b0e5da6 100644
---- a/pci/pci.c
-+++ b/pci/pci.c
-@@ -344,7 +344,7 @@ PCIE_EXPLAIN_STRUCT PcieExplainList[] = {
- // Global Variables
- //
- PCI_CONFIG_SPACE *mConfigSpace;
--EFI_HII_HANDLE HiiHandle;
-+STATIC EFI_HII_HANDLE HiiHandle;
- EFI_GUID EfiPciGuid = EFI_PCI_GUID;
- SHELL_VAR_CHECK_ITEM PciCheckList[] = {
- {
-@@ -1034,7 +1034,7 @@ Returns:
- Status = BS->HandleProtocol (
- Handle,
- &gEfiPciRootBridgeIoProtocolGuid,
-- IoDev
-+ (VOID**)IoDev
- );
+Index: mem/efidump.c
+===================================================================
+--- mem/efidump.c (revision 64)
++++ mem/efidump.c (working copy)
+@@ -24,7 +24,7 @@
+ --*/
- if (EFI_ERROR (Status)) {
-@@ -1043,7 +1043,7 @@ Returns:
- //
- // Call Configuration() to get address space descriptors
- //
-- Status = (*IoDev)->Configuration (*IoDev, Descriptors);
-+ Status = (*IoDev)->Configuration (*IoDev, (VOID**)Descriptors);
- if (Status == EFI_UNSUPPORTED) {
- *Descriptors = NULL;
- return EFI_SUCCESS;
-@@ -1956,7 +1956,7 @@ Returns:
- INDEX_OF (&(CardBus->IoBase0)),
- Io32Bit ? L" 32 bit" : L" 16 bit",
- CardBus->IoBase0 & (Io32Bit ? 0xfffffffc : 0x0000fffc),
-- CardBus->IoLimit0 & (Io32Bit ? 0xffffffff : 0x0000ffff) | 0x00000003
-+ (CardBus->IoLimit0 & (Io32Bit ? 0xffffffff : 0x0000ffff)) | 0x00000003
- );
+ #include "debug.h"
+-#include "Efipart.h"
++#include "EfiPart.h"
+ #include "EfiShellLib.h"
- Io32Bit = (BOOLEAN) (CardBus->IoBase1 & PCI_BIT_0);
-@@ -1966,7 +1966,7 @@ Returns:
- INDEX_OF (&(CardBus->IoBase1)),
- Io32Bit ? L" 32 bit" : L" 16 bit",
- CardBus->IoBase1 & (Io32Bit ? 0xfffffffc : 0x0000fffc),
-- CardBus->IoLimit1 & (Io32Bit ? 0xffffffff : 0x0000ffff) | 0x00000003
-+ (CardBus->IoLimit1 & (Io32Bit ? 0xffffffff : 0x0000ffff)) | 0x00000003
- );
+ #include STRING_DEFINES_FILE
+@@ -320,13 +320,11 @@
+ VOID *AcpiTable;
+ VOID *Acpi20Table;
+ VOID *SMBIOSTable;
+- VOID *SalSystemTable;
+ VOID *MpsTable;
+
+ AcpiTable = NULL;
+ Acpi20Table = NULL;
+ SMBIOSTable = NULL;
+- SalSystemTable = NULL;
+ MpsTable = NULL;
+
+ PrintToken (
+@@ -352,11 +350,13 @@
+ PrintToken (STRING_TOKEN (STR_DEBUG_STD_ERROR_ON), HiiMemHandle, LibDevicePathToStr (DevicePath));
+ }
- //
-diff --git a/pci/pci.h b/pci/pci.h
-index 0716bee..6a3ef76 100644
---- a/pci/pci.h
-+++ b/pci/pci.h
-@@ -30,7 +30,7 @@ Revision History
- 0x388da6c3, 0x3447, 0x4b1f, 0xa0, 0xba, 0xa9, 0xe8, 0xa2, 0x87, 0xf1, 0x76 \
+- PrintToken (STRING_TOKEN (STR_DEBUG_RUNTIME_SERVICES), HiiMemHandle, (UINT64) Tbl.Sys->RuntimeServices);
+- PrintToken (STRING_TOKEN (STR_DEBUG_BOOT_SERVICES), HiiMemHandle, (UINT64) Tbl.Sys->BootServices);
++ PrintToken (STRING_TOKEN (STR_DEBUG_RUNTIME_SERVICES), HiiMemHandle, (UINT64)(UINTN) Tbl.Sys->RuntimeServices);
++ PrintToken (STRING_TOKEN (STR_DEBUG_BOOT_SERVICES), HiiMemHandle, (UINT64)(UINTN) Tbl.Sys->BootServices);
+
+ EFI64_CODE (
+- Status = LibGetSystemConfigurationTable(&gEfiSalSystemTableGuid, &SalSystemTable);
++ VOID *SalSystemTable;
++
++ Status = LibGetSystemConfigurationTable(&gEfiSalSystemTableGuid, &SalSystemTable);
+ if (!EFI_ERROR(Status)) {
+ PrintToken (STRING_TOKEN(STR_DEBUG_SAL_SYSTEM_TABLE), HiiMemHandle, (UINT64)SalSystemTable);
+ }
+@@ -364,22 +364,22 @@
+
+ Status = LibGetSystemConfigurationTable (&gEfiAcpiTableGuid, &AcpiTable);
+ if (!EFI_ERROR (Status)) {
+- PrintToken (STRING_TOKEN (STR_DEBUG_ACPI_TABLE), HiiMemHandle, (UINT64) AcpiTable);
++ PrintToken (STRING_TOKEN (STR_DEBUG_ACPI_TABLE), HiiMemHandle, (UINT64)(UINTN) AcpiTable);
}
--#include "TIANO.h"
-+#include "Tiano.h"
+ Status = LibGetSystemConfigurationTable (&gEfiAcpi20TableGuid, &Acpi20Table);
+ if (!EFI_ERROR (Status)) {
+- PrintToken (STRING_TOKEN (STR_DEBUG_APCI_2_TABLE), HiiMemHandle, (UINT64) Acpi20Table);
++ PrintToken (STRING_TOKEN (STR_DEBUG_APCI_2_TABLE), HiiMemHandle, (UINT64)(UINTN) Acpi20Table);
+ }
- typedef enum {
- PciDevice,
-diff --git a/pci/pci.inf b/pci/pci.inf
-index d4499d6..4691013 100644
---- a/pci/pci.inf
-+++ b/pci/pci.inf
-@@ -41,7 +41,7 @@ COMPONENT_TYPE = APPLICATION
+ Status = LibGetSystemConfigurationTable (&gEfiMpsTableGuid, &MpsTable);
+ if (!EFI_ERROR (Status)) {
+- PrintToken (STRING_TOKEN (STR_DEBUG_MPS_TABLE), HiiMemHandle, (UINT64) MpsTable);
++ PrintToken (STRING_TOKEN (STR_DEBUG_MPS_TABLE), HiiMemHandle, (UINT64)(UINTN) MpsTable);
+ }
- [sources.common]
- PciStrings.uni
-- ..\ShCommonStrings.uni
-+ ../ShCommonStrings.uni
- pci.c
- pci.h
- pci_class.h
-@@ -49,17 +49,17 @@ COMPONENT_TYPE = APPLICATION
+ Status = LibGetSystemConfigurationTable (&gEfiSmbiosTableGuid, &SMBIOSTable);
+ if (!EFI_ERROR (Status)) {
+- PrintToken (STRING_TOKEN (STR_DEBUG_SMBIOS_TABLE), HiiMemHandle, (UINT64) SMBIOSTable);
++ PrintToken (STRING_TOKEN (STR_DEBUG_SMBIOS_TABLE), HiiMemHandle, (UINT64)(UINTN) SMBIOSTable);
+ }
+ }
+
+Index: mem/debug.h
+===================================================================
+--- mem/debug.h (revision 64)
++++ mem/debug.h (working copy)
+@@ -156,3 +156,4 @@
+ extern EFI_HII_HANDLE HiiMemHandle;
+ #endif
++
+Index: ls/ls.c
+===================================================================
+--- ls/ls.c (revision 64)
++++ ls/ls.c (working copy)
+@@ -59,7 +59,7 @@
+ NULL,
+ 0,
+ 0,
+- 0
++ (SHELL_VAR_CHECK_FLAG_TYPE) 0
+ }
+ };
+
+@@ -199,7 +199,6 @@
+ CHAR16 *PtrTwo;
+ CHAR16 *Path;
+ EFI_LIST_ENTRY DirList;
+- EFI_LIST_ENTRY *Link;
+ SHELL_FILE_ARG *Arg;
+ BOOLEAN WildcardsEncountered;
+ CHAR16 *Pattern;
+@@ -210,7 +209,6 @@
+ Argv = SI->Argv;
+ PtrTwo = NULL;
+ InitializeListHead (&DirList);
+- Link = NULL;
+ Arg = NULL;
+ Pattern = NULL;
+ Status = EFI_SUCCESS;
+@@ -815,8 +813,6 @@
+ CHAR16 *Path
+ )
+ {
+-
+- EFI_STATUS Status;
+ CHAR16 *PtrOne;
+ CHAR16 *PtrTwo;
+ UINTN Index1;
+@@ -825,7 +821,6 @@
+ BOOLEAN LeadingBlanks;
+
+ LeadingBlanks = TRUE;
+- Status = EFI_SUCCESS;
+
+ for (PtrOne = PtrTwo = Path; PtrOne < Path + StrLen (Path); PtrOne++) {
+ if ((*PtrOne) == ' ' && LeadingBlanks) {
+@@ -917,14 +912,14 @@
+
+ if ((IsMatch && mIgnoreAttribute) ||
+ (IsMatch && !mAttributes && !(Info->Attribute & EFI_FILE_HIDDEN) && !(Info->Attribute & EFI_FILE_SYSTEM)) ||
+- IsMatch &&
++ (IsMatch &&
+ mAttributes &&
+ (
+ (mAttribA ? (Info->Attribute & EFI_FILE_ARCHIVE ? TRUE : FALSE) : TRUE) &&
+ (mAttribH ? (Info->Attribute & EFI_FILE_HIDDEN ? TRUE : FALSE) : TRUE) &&
+ (mAttribR ? (Info->Attribute & EFI_FILE_READ_ONLY ? TRUE : FALSE) : TRUE) &&
+ (mAttribS ? (Info->Attribute & EFI_FILE_SYSTEM ? TRUE : FALSE) : TRUE) &&
+- (mAttribD ? (Info->Attribute & EFI_FILE_DIRECTORY ? TRUE : FALSE) : TRUE)
++ (mAttribD ? (Info->Attribute & EFI_FILE_DIRECTORY ? TRUE : FALSE) : TRUE))
+ )
+ ) {
+ IsMatch = TRUE;
+Index: ls/ls.h
+===================================================================
+--- ls/ls.h (revision 64)
++++ ls/ls.h (working copy)
+@@ -91,4 +91,5 @@
+ IN UINT16 VHlpToken
+ );
+
+-#endif
+\ No newline at end of file
++#endif
++
+Index: ls/ls.inf
+===================================================================
+--- ls/ls.inf (revision 64)
++++ ls/ls.inf (working copy)
+@@ -40,24 +40,24 @@
+
+
+ [sources.common]
+- ..\ShCommonStrings.uni
++ ../ShCommonStrings.uni
+ LsStrings.uni
+ ls.c
+ ls.h
+
[includes.common]
.
- ..\Inc
@@ -5033,46 +3683,42 @@ index d4499d6..4691013 100644
[libraries.common]
EfiShellLib
-diff --git a/pci/pci_class.c b/pci/pci_class.c
-index caffe6d..14aa88d 100644
---- a/pci/pci_class.c
-+++ b/pci/pci_class.c
-@@ -30,7 +30,7 @@ Revision History
- //
- // Global Variables
- //
--EFI_HII_HANDLE HiiHandle;
-+STATIC EFI_HII_HANDLE HiiHandle;
-
- PCI_CLASS_ENTRY gClassStringList[];
+Index: stall/stall.c
+===================================================================
+--- stall/stall.c (revision 64)
++++ stall/stall.c (working copy)
+@@ -50,7 +50,7 @@
+ NULL,
+ 0,
+ 0,
+- 0
++ (SHELL_VAR_CHECK_FLAG_TYPE) 0
+ }
+ };
-diff --git a/pci/pci_class.h b/pci/pci_class.h
-index c7fff0c..ebaa9f6 100644
---- a/pci/pci_class.h
-+++ b/pci/pci_class.h
-@@ -24,7 +24,7 @@ Revision History
- #ifndef _PCI_CLASS_H_
- #define _PCI_CLASS_H_
+Index: stall/stall.h
+===================================================================
+--- stall/stall.h (revision 64)
++++ stall/stall.h (working copy)
+@@ -30,3 +30,4 @@
+ }
--#include "TIANO.h" // for UINT32 etc.
-+#include "Tiano.h" // for UINT32 etc.
- #define PCI_CLASS_STRING_LIMIT 54
- //
- // Printable strings for Pci class code
-diff --git a/reset/reset.inf b/reset/reset.inf
-index 3af6b2c..b89ae85 100644
---- a/reset/reset.inf
-+++ b/reset/reset.inf
-@@ -40,24 +40,24 @@ COMPONENT_TYPE = APPLICATION
+ #endif
++
+Index: stall/stall.inf
+===================================================================
+--- stall/stall.inf (revision 64)
++++ stall/stall.inf (working copy)
+@@ -40,24 +40,24 @@
[sources.common]
-- ..\ShCommonStrings.uni
-+ ../ShCommonStrings.uni
- ResetStrings.uni
- Reset.c
- Reset.h
-
+- ..\ShCommonStrings.uni
++ ../ShCommonStrings.uni
+ stallStrings.uni
+ stall.c
+ stall.h
+
[includes.common]
.
- ..\Inc
@@ -5100,19 +3746,51 @@ index 3af6b2c..b89ae85 100644
[libraries.common]
EfiShellLib
-diff --git a/rm/rm.inf b/rm/rm.inf
-index 0da05e0..bc7449f 100644
---- a/rm/rm.inf
-+++ b/rm/rm.inf
-@@ -41,23 +41,23 @@ COMPONENT_TYPE = APPLICATION
+Index: DeviceTree/devicetree.c
+===================================================================
+--- DeviceTree/devicetree.c (revision 64)
++++ DeviceTree/devicetree.c (working copy)
+@@ -36,7 +36,7 @@
+ //
+ // Global Variables
+ //
+-EFI_HII_HANDLE HiiHandle;
++STATIC EFI_HII_HANDLE HiiHandle;
+ EFI_GUID EfiDevicetreeGuid = EFI_DEVICETREE_GUID;
+ SHELL_VAR_CHECK_ITEM DevicetreeCheckList[] = {
+ {
+@@ -67,7 +67,7 @@
+ NULL,
+ 0,
+ 0,
+- 0
++ (SHELL_VAR_CHECK_FLAG_TYPE) 0
+ }
+ };
+
+Index: DeviceTree/devicetree.h
+===================================================================
+--- DeviceTree/devicetree.h (revision 64)
++++ DeviceTree/devicetree.h (working copy)
+@@ -32,3 +32,4 @@
+ 0xf21044af, 0xeef6, 0x4d58, 0xb4, 0x56, 0x32, 0x86, 0xa0, 0x2b, 0x7c, 0x49 \
+ }
+ #endif
++
+Index: DeviceTree/devicetree.inf
+===================================================================
+--- DeviceTree/devicetree.inf (revision 64)
++++ DeviceTree/devicetree.inf (working copy)
+@@ -40,24 +40,24 @@
- [sources.common]
- RmStrings.uni
-- ..\ShCommonStrings.uni
-+ ../ShCommonStrings.uni
- rm.h
- rm.c
+ [sources.common]
+- ..\ShCommonStrings.uni
++ ../ShCommonStrings.uni
+ DevicetreeStrings.uni
+ devicetree.c
+ devicetree.h
+
[includes.common]
.
- ..\Inc
@@ -5140,51 +3818,61 @@ index 0da05e0..bc7449f 100644
[libraries.common]
EfiShellLib
-diff --git a/sermode/sermode.c b/sermode/sermode.c
-index b59e801..3340352 100644
---- a/sermode/sermode.c
-+++ b/sermode/sermode.c
-@@ -35,7 +35,7 @@ extern UINT8 STRING_ARRAY_NAME[];
-
- #include EFI_PROTOCOL_DEFINITION (SerialIo)
+Index: TelnetMgmt/TelnetMgmt.c
+===================================================================
+--- TelnetMgmt/TelnetMgmt.c (revision 64)
++++ TelnetMgmt/TelnetMgmt.c (working copy)
+@@ -32,7 +32,7 @@
+ //
+ #include STRING_DEFINES_FILE
-EFI_HII_HANDLE HiiHandle;
+STATIC EFI_HII_HANDLE HiiHandle;
- EFI_GUID EfiSermodeGuid = EFI_SERMODEB_GUID;
- SHELL_VAR_CHECK_ITEM SermodeCheckList[] = {
- {
-@@ -104,7 +104,7 @@ iDisplaySettings (
-
- }
-
-- Status = BS->HandleProtocol (Handles[Index], &gEfiSerialIoProtocolGuid, &SerialIo);
-+ Status = BS->HandleProtocol (Handles[Index], &gEfiSerialIoProtocolGuid, (VOID**)&SerialIo);
- if (!EFI_ERROR (Status)) {
- switch (SerialIo->Mode->Parity) {
- case DefaultParity:
-@@ -454,7 +454,7 @@ Returns:
- continue;
- }
+ EFI_GUID EfiTelnetMgmtGuid = EFI_TELNETMGMT_GUID;
+ EFI_GUID mEfiTelnetServerGuid = EFI_TELNET_SERVER_PROTOCOL_GUID;
+ SHELL_VAR_CHECK_ITEM TelnetmgmtCheckList[] = {
+@@ -58,7 +58,7 @@
+ NULL,
+ 0,
+ 0,
+- 0
++ (SHELL_VAR_CHECK_FLAG_TYPE) 0
+ }
+ };
+
+Index: TelnetMgmt/TelnetMgmt.h
+===================================================================
+--- TelnetMgmt/TelnetMgmt.h (revision 64)
++++ TelnetMgmt/TelnetMgmt.h (working copy)
+@@ -29,4 +29,4 @@
+ 0x55d41b9a, 0x954d, 0x4fbb, 0x8d, 0x6d, 0x24, 0x75, 0xf5, 0x30, 0x9d, 0x37 \
+ }
-- Status = BS->HandleProtocol (Handles[Index], &gEfiSerialIoProtocolGuid, &SerialIo);
-+ Status = BS->HandleProtocol (Handles[Index], &gEfiSerialIoProtocolGuid, (VOID**)&SerialIo);
- if (!EFI_ERROR (Status)) {
- Status = SerialIo->SetAttributes (
- SerialIo,
-diff --git a/sermode/sermode.inf b/sermode/sermode.inf
-index 71f3c66..47ac581 100644
---- a/sermode/sermode.inf
-+++ b/sermode/sermode.inf
-@@ -40,24 +40,24 @@ COMPONENT_TYPE = APPLICATION
+-#endif
+\ No newline at end of file
++#endif
+Index: TelnetMgmt/TelnetServer.h
+===================================================================
+--- TelnetMgmt/TelnetServer.h (revision 64)
++++ TelnetMgmt/TelnetServer.h (working copy)
+@@ -81,3 +81,4 @@
+ extern EFI_GUID gEfiTelnetServerGuid;
+ #endif
++
+Index: TelnetMgmt/TelnetMgmt.inf
+===================================================================
+--- TelnetMgmt/TelnetMgmt.inf (revision 64)
++++ TelnetMgmt/TelnetMgmt.inf (working copy)
+@@ -25,23 +25,23 @@
+ COMPONENT_TYPE = APPLICATION
[sources.common]
- ..\ShCommonStrings.uni
+ ../ShCommonStrings.uni
- SermodeStrings.uni
- sermode.c
- sermode.h
-
+ TelnetMgmtStrings.uni
+ TelnetMgmt.c
+
[includes.common]
.
- ..\Inc
@@ -5212,11 +3900,204 @@ index 71f3c66..47ac581 100644
[libraries.common]
EfiShellLib
-diff --git a/shellenv/Connect.c b/shellenv/Connect.c
-index 71ecf0b..6b26bfe 100644
---- a/shellenv/Connect.c
-+++ b/shellenv/Connect.c
-@@ -333,7 +333,7 @@ Returns:
+Index: shellenv/if.c
+===================================================================
+--- shellenv/if.c (revision 64)
++++ shellenv/if.c (working copy)
+@@ -59,7 +59,6 @@
+ BOOLEAN ExistNot;
+ UINTN NotPos;
+ BOOLEAN ExistI;
+- UINTN IPos;
+ EFI_STATUS Status;
+ CHAR16 *FileName;
+ BOOLEAN FileExists;
+@@ -122,10 +121,8 @@
+ //
+ if ((StriCmp (SI->Argv[1], L"/i") == 0)) {
+ ExistI = TRUE;
+- IPos = 1;
+ } else {
+ ExistI = FALSE;
+- IPos = 0;
+ }
+
+ NotPos = ExistI ? 2 : 1;
+Index: shellenv/init.c
+===================================================================
+--- shellenv/init.c (revision 64)
++++ shellenv/init.c (working copy)
+@@ -143,7 +143,7 @@
+ Status = BS->HandleProtocol (
+ mOldSEnv->Handle,
+ &ShellEnvProtocol,
+- &(mOldSEnv->Interface)
++ (VOID**)&(mOldSEnv->Interface)
+ );
+ ASSERT (!EFI_ERROR (Status));
+ Status = BS->ReinstallProtocolInterface (
+Index: shellenv/echo.c
+===================================================================
+--- shellenv/echo.c (revision 64)
++++ shellenv/echo.c (working copy)
+@@ -52,7 +52,7 @@
+ NULL,
+ 0,
+ 0,
+- 0
++ (SHELL_VAR_CHECK_FLAG_TYPE) 0
+ }
+ };
+
+Index: shellenv/shelle.h
+===================================================================
+--- shellenv/shelle.h (revision 64)
++++ shellenv/shelle.h (working copy)
+@@ -2074,3 +2074,4 @@
+ );
+
+ #endif // _SHELLE_H_
++
+Index: shellenv/batch.c
+===================================================================
+--- shellenv/batch.c (revision 64)
++++ shellenv/batch.c (working copy)
+@@ -2388,7 +2388,6 @@
+
+ --*/
+ {
+- BOOLEAN EndOfFile;
+ EFI_STATUS Status;
+ UINTN BufSize;
+ CHAR16 *CommandLine;
+@@ -2396,7 +2395,6 @@
+ EFI_BATCH_STATEMENT *Stmt;
+ ENV_SHELL_INTERFACE NewShell;
+ UINTN GotoTargetStatus;
+- UINTN SkippedIfCount;
+ BOOLEAN EchoStateValid;
+ BOOLEAN EchoState;
+ EFI_STATUS ExecuteResult;
+@@ -2409,7 +2407,6 @@
+ // Initialize
+ //
+ Status = EFI_SUCCESS;
+- EndOfFile = FALSE;
+ BufSize = 0;
+ EchoStateValid = FALSE;
+ EchoState = FALSE;
+@@ -2468,14 +2465,6 @@
+ EFI_BATCH_SCRIPT_SIGNATURE
+ );
+
+- //
+- // Iterate through the file, reading a line at a time and executing each
+- // line as a shell command. Nested shell scripts will come through
+- // this code path recursively.
+- //
+- EndOfFile = FALSE;
+- SkippedIfCount = 0;
+-
+ while (1) {
+ //
+ // Read a command line from the file
+@@ -2681,7 +2670,7 @@
+ LastError = ExecuteResult;
+ }
+
+- if (ExecuteResult == -1) {
++ if (ExecuteResult == (EFI_STATUS) -1) {
+ SE2->DecrementShellNestingLevel ();
+ if (SE2->IsRootShell ()) {
+ goto Done;
+@@ -2774,7 +2763,7 @@
+ Status = _ResumePreviousMode ();
+ }
+
+- if (LastError == -1) {
++ if (LastError == (UINTN) -1) {
+ return LastError;
+ } else {
+ return Status;
+Index: shellenv/dprot.c
+===================================================================
+--- shellenv/dprot.c (revision 64)
++++ shellenv/dprot.c (working copy)
+@@ -23,7 +23,7 @@
+
+ #include "shelle.h"
+ #include "shellenvguid.h"
+-#include "acpi.h"
++#include "Acpi.h"
+
+ STATIC CHAR16 *SEnvDP_IlleagalStr[] = { L"Illegal" };
+
+@@ -328,7 +328,6 @@
+ I2O_DEVICE_PATH *I2ODevicePath;
+ MAC_ADDR_DEVICE_PATH *MacAddrDevicePath;
+ IPv4_DEVICE_PATH *IPv4DevicePath;
+- IPv6_DEVICE_PATH *IPv6DevicePath;
+ INFINIBAND_DEVICE_PATH *InfinibandDevicePath;
+ UART_DEVICE_PATH *UartDevicePath;
+ VENDOR_DEVICE_PATH *VendorDevicePath;
+@@ -464,7 +463,6 @@
+ break;
+
+ case MSG_IPv6_DP:
+- IPv6DevicePath = (IPv6_DEVICE_PATH *) DevicePath;
+ PrintToken (STRING_TOKEN (STR_SHELLENV_DPROT_NOT_AVAIL), HiiEnvHandle);
+ break;
+
+@@ -1054,6 +1052,8 @@
+ Magic = EFI_IMAGE_NT_OPTIONAL_HDR64_MAGIC;
+ } else if (NtHdr->FileHeader.Machine == EFI_IMAGE_MACHINE_X64) {
+ Magic = EFI_IMAGE_NT_OPTIONAL_HDR64_MAGIC;
++ } else if (NtHdr->FileHeader.Machine == EFI_IMAGE_MACHINE_AARCH64) {
++ Magic = EFI_IMAGE_NT_OPTIONAL_HDR64_MAGIC;
+ } else {
+ Magic = NtHdr->OptionalHeader.Magic;
+ }
+@@ -1294,6 +1294,8 @@
+ case EfiIsaAcpiResourceInterrupt:
+ PrintToken (STRING_TOKEN (STR_SHELLENV_DPROT_INT), HiiEnvHandle);
+ break;
++ case EfiIsaAcpiResourceEndOfList:
++ return;
+ }
+
+ if (IsaIo->ResourceList->ResourceItem[Index].StartRange == IsaIo->ResourceList->ResourceItem[Index].EndRange) {
+Index: shellenv/Connect.c
+===================================================================
+--- shellenv/Connect.c (revision 64)
++++ shellenv/Connect.c (working copy)
+@@ -51,7 +51,7 @@
+ NULL,
+ 0,
+ 0,
+- 0
++ (SHELL_VAR_CHECK_FLAG_TYPE) 0
+ }
+ };
+
+@@ -78,7 +78,7 @@
+ NULL,
+ 0,
+ 0,
+- 0
++ (SHELL_VAR_CHECK_FLAG_TYPE) 0
+ }
+ };
+
+@@ -105,7 +105,7 @@
+ NULL,
+ 0,
+ 0,
+- 0
++ (SHELL_VAR_CHECK_FLAG_TYPE) 0
+ }
+ };
+
+@@ -333,7 +333,7 @@
Status = BS->HandleProtocol (
HandleBuffer[0],
&gEfiDevicePathProtocolGuid,
@@ -5225,7 +4106,7 @@ index 71ecf0b..6b26bfe 100644
);
if (EFI_ERROR (Status)) {
DriverBindingHandleCount = 1;
-@@ -349,7 +349,7 @@ Returns:
+@@ -349,7 +349,7 @@
Status = BS->HandleProtocol (
HandleBuffer[0],
&gEfiDevicePathProtocolGuid,
@@ -5234,7 +4115,7 @@ index 71ecf0b..6b26bfe 100644
);
if (EFI_ERROR (Status)) {
PrintToken (
-@@ -368,7 +368,7 @@ Returns:
+@@ -368,7 +368,7 @@
Status = BS->HandleProtocol (
HandleBuffer[1],
&gEfiDriverBindingProtocolGuid,
@@ -5243,7 +4124,7 @@ index 71ecf0b..6b26bfe 100644
);
if (EFI_ERROR (Status)) {
PrintToken (
-@@ -407,7 +407,7 @@ Returns:
+@@ -407,7 +407,7 @@
Status = BS->HandleProtocol (
AllHandleBuffer[Index],
&gEfiDriverBindingProtocolGuid,
@@ -5252,7 +4133,7 @@ index 71ecf0b..6b26bfe 100644
);
if (EFI_ERROR (Status)) {
DeviceHandleBuffer[DeviceHandleCount++] = AllHandleBuffer[Index];
-@@ -1052,7 +1052,7 @@ SEnvConnectConsole (
+@@ -1052,7 +1052,7 @@
Status = BS->HandleProtocol (
*ConsoleHandle,
ConsoleGuid,
@@ -5261,7 +4142,7 @@ index 71ecf0b..6b26bfe 100644
);
}
-@@ -1079,7 +1079,7 @@ SEnvConnectConsole (
+@@ -1079,7 +1079,7 @@
Status = BS->HandleProtocol (
AllHandleBuffer[Index],
&gEfiDevicePathProtocolGuid,
@@ -5270,7 +4151,7 @@ index 71ecf0b..6b26bfe 100644
);
if (!EFI_ERROR (Status)) {
ConsoleIndex = Index;
-@@ -1095,7 +1095,7 @@ SEnvConnectConsole (
+@@ -1095,7 +1095,7 @@
BS->HandleProtocol (
*ConsoleHandle,
ConsoleGuid,
@@ -5279,102 +4160,29 @@ index 71ecf0b..6b26bfe 100644
);
}
-diff --git a/shellenv/dprot.c b/shellenv/dprot.c
-index 91faa50..c5078c9 100644
---- a/shellenv/dprot.c
-+++ b/shellenv/dprot.c
-@@ -23,7 +23,7 @@ Revision History
-
- #include "shelle.h"
- #include "shellenvguid.h"
--#include "acpi.h"
-+#include "Acpi.h"
-
- STATIC CHAR16 *SEnvDP_IlleagalStr[] = { L"Illegal" };
-
-diff --git a/shellenv/exec.c b/shellenv/exec.c
-index a6c1b73..f825588 100644
---- a/shellenv/exec.c
-+++ b/shellenv/exec.c
-@@ -1872,7 +1872,7 @@ Returns:
- return Status;
- }
- //
-- // Processing foo: or foo:\
-+ // Processing foo:\ or foo:
- //
- if (PathPos != -1 && Ptr1 == NULL) {
- return Status;
-diff --git a/shellenv/for.c b/shellenv/for.c
-index 99664ad..93ab1f2 100644
---- a/shellenv/for.c
-+++ b/shellenv/for.c
-@@ -24,7 +24,7 @@ Revision History
- #include "shelle.h"
- #include "shellenvguid.h"
+Index: shellenv/shellenvguid.h
+===================================================================
+--- shellenv/shellenvguid.h (revision 64)
++++ shellenv/shellenvguid.h (working copy)
+@@ -37,3 +37,4 @@
+ extern EFI_HII_HANDLE HiiEnvHandle;
--/*
-+#if 0
- BOOLEAN
- CheckInterValue (
- IN CHAR16 *wszValueStr,
-@@ -190,7 +190,7 @@ Arguments:
- Returns:
- EFI_SUCCESS The function finished sucessfully
-
----
-+--*/
- {
- EFI_BATCH_STATEMENT *Stmt;
- EFI_LIST_ENTRY FileList;
-@@ -326,7 +326,8 @@ Done:
-
- return Status;
- }
--*/
-+#endif
+ #endif
+
- EFI_STATUS
- SEnvCmdForRun (
- IN EFI_HANDLE hImageHandle,
-diff --git a/shellenv/init.c b/shellenv/init.c
-index dad9002..458c6eb 100644
---- a/shellenv/init.c
-+++ b/shellenv/init.c
-@@ -143,7 +143,7 @@ Returns:
- Status = BS->HandleProtocol (
- mOldSEnv->Handle,
- &ShellEnvProtocol,
-- &(mOldSEnv->Interface)
-+ (VOID**)&(mOldSEnv->Interface)
- );
- ASSERT (!EFI_ERROR (Status));
- Status = BS->ReinstallProtocolInterface (
-diff --git a/shellenv/map.c b/shellenv/map.c
-index 3ebf2b4..297f689 100644
---- a/shellenv/map.c
-+++ b/shellenv/map.c
-@@ -2038,13 +2038,13 @@ Returns:
- goto Done;
+Index: shellenv/protid.c
+===================================================================
+--- shellenv/protid.c (revision 64)
++++ shellenv/protid.c (working copy)
+@@ -628,7 +628,7 @@
+ NULL,
+ 0,
+ 0,
+- FALSE
++ (SHELL_VAR_CHECK_FLAG_TYPE) FALSE
}
+ };
-- Status = BS->HandleProtocol (Handle, &gEfiBlockIoProtocolGuid, &BlockIo);
-+ Status = BS->HandleProtocol (Handle, &gEfiBlockIoProtocolGuid, (VOID**)&BlockIo);
- //
- // This is just for NT32, because fsntx has no block io protocol installed
- // but fsntx has installed simple file system protocol
- //
- if (EFI_ERROR (Status)) {
-- Status = BS->HandleProtocol (Handle, &gEfiSimpleFileSystemProtocolGuid, &BlockIo);
-+ Status = BS->HandleProtocol (Handle, &gEfiSimpleFileSystemProtocolGuid, (VOID**)&BlockIo);
- }
-
- if (EFI_ERROR (Status)) {
-diff --git a/shellenv/protid.c b/shellenv/protid.c
-index 3edca2c..a9401e7 100644
---- a/shellenv/protid.c
-+++ b/shellenv/protid.c
-@@ -1183,7 +1183,7 @@ GetDriverName (
+@@ -1183,7 +1183,7 @@
*DriverName = LibDevicePathToStr (Image->FilePath);
}
} else {
@@ -5383,7 +4191,7 @@ index 3edca2c..a9401e7 100644
}
return EFI_SUCCESS;
-@@ -1539,7 +1539,7 @@ Returns:
+@@ -1539,7 +1539,7 @@
DevicePath = NULL;
BestDeviceName = NULL;
@@ -5392,7 +4200,7 @@ index 3edca2c..a9401e7 100644
Print (L"\n");
PrintToken (STRING_TOKEN (STR_SHELLENV_PROTID_CONTROLLER_NAME), HiiEnvHandle);
-@@ -1598,14 +1598,14 @@ Returns:
+@@ -1598,14 +1598,14 @@
Image = FALSE;
Status = GetDriverName (
DriverBindingHandleBuffer[Index],
@@ -5409,7 +4217,7 @@ index 3edca2c..a9401e7 100644
TRUE,
&DriverName
);
-@@ -1792,7 +1792,7 @@ Returns:
+@@ -1792,7 +1792,7 @@
Status = GetDriverName (
Handle,
@@ -5418,7 +4226,7 @@ index 3edca2c..a9401e7 100644
FALSE,
&DriverName
);
-@@ -1806,7 +1806,7 @@ Returns:
+@@ -1806,7 +1806,7 @@
Status = GetDriverName (
Handle,
@@ -5427,7 +4235,7 @@ index 3edca2c..a9401e7 100644
TRUE,
&DriverName
);
-@@ -1979,7 +1979,7 @@ Returns:
+@@ -1979,7 +1979,7 @@
if (Prot->Handles[Index] == Handle) {
Dump = Verbose ? Prot->DumpInfo : Prot->DumpToken;
@@ -5436,7 +4244,7 @@ index 3edca2c..a9401e7 100644
if (!EFI_ERROR (Status)) {
if (Verbose) {
for (Index1 = 0; Index1 < ProtocolBufferCount; Index1++) {
-@@ -2027,7 +2027,7 @@ Returns:
+@@ -2027,7 +2027,7 @@
goto Done;
}
@@ -5445,20 +4253,427 @@ index 3edca2c..a9401e7 100644
if (!EFI_ERROR (Status)) {
PrintToken (
STRING_TOKEN (STR_SHELLENV_PROTID_TWO_VARS_HG_NEW),
-diff --git a/stall/stall.inf b/stall/stall.inf
-index 58545a5..0c50120 100644
---- a/stall/stall.inf
-+++ b/stall/stall.inf
-@@ -40,24 +40,24 @@ COMPONENT_TYPE = APPLICATION
+@@ -2660,8 +2660,6 @@
+
+ --*/
+ {
+- EFI_STATUS Status;
+-
+ DEVICEPATH_INFO *DevicePathInfo;
+
+ UINTN Index;
+@@ -2688,7 +2686,7 @@
+ //
+ // Establish current device path info list
+ //
+- Status = LibLocateHandle (
++ LibLocateHandle (
+ ByProtocol,
+ Protocol,
+ NULL,
+Index: shellenv/parsecmd.h
+===================================================================
+--- shellenv/parsecmd.h (revision 64)
++++ shellenv/parsecmd.h (working copy)
+@@ -103,4 +103,5 @@
+ IN OUT SHELL_PARSED_ARGS *args
+ );
+
+-#endif
+\ No newline at end of file
++#endif
++
+Index: shellenv/ConsoleProxy.c
+===================================================================
+--- shellenv/ConsoleProxy.c (revision 64)
++++ shellenv/ConsoleProxy.c (working copy)
+@@ -1483,7 +1483,7 @@
+
+ if (!EFI_ERROR (TimerStatus)) {
+ mConInProxy.InputState = INPUT_STATE_DEFAULT;
+- BS->SetTimer (
++ Status = BS->SetTimer (
+ mConInProxy.TwoSecondTimeOut,
+ TimerCancel,
+ 0
+@@ -1496,9 +1496,11 @@
+ (UINT64) 20000000
+ );
+ mConInProxy.InputState = INPUT_STATE_ESC;
++ } else {
++ Status = EFI_UNSUPPORTED;
+ }
+
+- return EFI_SUCCESS;
++ return Status;
+ }
+
+ EFI_STATUS
+Index: shellenv/conio.c
+===================================================================
+--- shellenv/conio.c (revision 64)
++++ shellenv/conio.c (working copy)
+@@ -889,7 +889,7 @@
+ //
+ // If we need to update the output do so now
+ //
+- if (Update != -1) {
++ if (Update != (UINTN) -1) {
+ if ((ConOut->Mode->CursorColumn != (INT32) Column) || (ConOut->Mode->CursorRow != (INT32) Row)) {
+ PrintAt (Column, Row, L"%s%.*s", Str + Update, Delete, L"");
+ } else {
+Index: shellenv/map.c
+===================================================================
+--- shellenv/map.c (revision 64)
++++ shellenv/map.c (working copy)
+@@ -185,7 +185,7 @@
+ NULL,
+ 0,
+ 0,
+- 0
++ (SHELL_VAR_CHECK_FLAG_TYPE) 0
+ }
+ };
+
+@@ -206,7 +206,7 @@
+ NULL,
+ 0,
+ 0,
+- 0
++ (SHELL_VAR_CHECK_FLAG_TYPE) 0
+ }
+ };
+
+@@ -2038,13 +2038,13 @@
+ goto Done;
+ }
+
+- Status = BS->HandleProtocol (Handle, &gEfiBlockIoProtocolGuid, &BlockIo);
++ Status = BS->HandleProtocol (Handle, &gEfiBlockIoProtocolGuid, (VOID**)&BlockIo);
+ //
+ // This is just for NT32, because fsntx has no block io protocol installed
+ // but fsntx has installed simple file system protocol
+ //
+ if (EFI_ERROR (Status)) {
+- Status = BS->HandleProtocol (Handle, &gEfiSimpleFileSystemProtocolGuid, &BlockIo);
++ Status = BS->HandleProtocol (Handle, &gEfiSimpleFileSystemProtocolGuid, (VOID**)&BlockIo);
+ }
+
+ if (EFI_ERROR (Status)) {
+@@ -2630,7 +2630,6 @@
+ UINTN Index;
+ UINTN HandleNo;
+ BOOLEAN EchoStatus;
+- BOOLEAN Same;
+ CHAR16 MapStr[8];
+ EFI_LIST_ENTRY *Link;
+ EFI_LIST_ENTRY *Head;
+@@ -2729,11 +2728,6 @@
+ }
+ }
+ }
+- //
+- // New code, try to make mapping list sequence unchanged if current device
+- // paths and original device paths are the same
+- //
+- Same = FALSE;
+
+ //
+ // Load handle table and handle protocol info so that we can get
+@@ -3410,4 +3404,4 @@
+ FreePool (HistoryNode->DevicePath);
+ FreePool (HistoryNode);
+ }
+-}
+\ No newline at end of file
++}
+Index: shellenv/pause.c
+===================================================================
+--- shellenv/pause.c (revision 64)
++++ shellenv/pause.c (working copy)
+@@ -47,7 +47,7 @@
+ NULL,
+ 0,
+ 0,
+- 0
++ (SHELL_VAR_CHECK_FLAG_TYPE) 0
+ }
+ };
+
+Index: shellenv/exec.c
+===================================================================
+--- shellenv/exec.c (revision 64)
++++ shellenv/exec.c (working copy)
+@@ -105,7 +105,7 @@
+ NULL,
+ 0,
+ 0,
+- 0
++ (SHELL_VAR_CHECK_FLAG_TYPE) 0
+ }
+ };
+
+@@ -126,7 +126,7 @@
+ NULL,
+ 0,
+ 0,
+- 0
++ (SHELL_VAR_CHECK_FLAG_TYPE) 0
+ }
+ };
+
+@@ -1270,7 +1270,6 @@
+ SHELLENV_INTERNAL_COMMAND InternalCommand;
+ EFI_HANDLE NewImage;
+ EFI_FILE_HANDLE Script;
+- BOOLEAN ShowHelp;
+ BOOLEAN ConsoleContextSaved;
+ EFI_HANDLE SavedConsoleInHandle;
+ EFI_HANDLE SavedConsoleOutHandle;
+@@ -1292,7 +1291,6 @@
+ //
+ Status = EFI_SUCCESS;
+ ParentShell = NULL;
+- ShowHelp = FALSE;
+ ConsoleContextSaved = FALSE;
+ SavedConIn = NULL;
+ SavedConOut = NULL;
+@@ -1557,7 +1555,7 @@
+ );
+
+ EFI_SHELL_APP_INIT (ParentImageHandle, ParentSystemTable);
+- if (-2 == Status) {
++ if ((EFI_STATUS) -2 == Status) {
+ //
+ // if status = -2 we assume that a nested shell has just exited.
+ //
+@@ -1613,7 +1611,9 @@
+ Done:
+ DEBUG_CODE (
+ if (EFI_ERROR (Status) && Output) {
+- if ((Status == -1) || (Status == -2) || (Status == EFI_REDIRECTION_NOT_ALLOWED)
++ if ((Status == (EFI_STATUS) -1)
++ || (Status == (EFI_STATUS) -2)
++ || (Status == EFI_REDIRECTION_NOT_ALLOWED)
+ || (Status == EFI_REDIRECTION_SAME)) {
+ } else {
+ PrintToken (STRING_TOKEN (STR_SHELLENV_EXEC_EXIT_STATUS_CODE), HiiEnvHandle, Status);
+@@ -1674,7 +1674,7 @@
+ PrintToken (STRING_TOKEN (STR_SHELLENV_REDIR_NOT_ALLOWED), HiiEnvHandle);
+ }
+
+- if (Status != -1) {
++ if (Status != (EFI_STATUS) -1) {
+ //
+ // Don't Print on a "Disconnect All" exit. The ConOut device may not exist
+ //
+@@ -1872,7 +1872,7 @@
+ return Status;
+ }
+ //
+- // Processing foo: or foo:\
++ // Processing foo:\ or foo:
+ //
+ if (PathPos != -1 && Ptr1 == NULL) {
+ return Status;
+@@ -2638,7 +2638,6 @@
+ EFI_STATUS Status;
+ CHAR16 *Alias;
+ CHAR16 *SubstituteStr;
+- CHAR16 *OldSubstituteStr;
+ BOOLEAN Literal;
+ BOOLEAN Comment;
+ BOOLEAN IsVariable;
+@@ -2735,7 +2734,6 @@
+ // Try to find a shell enviroment variable
+ //
+ QuoteCount = 0;
+- OldSubstituteStr = SubstituteStr;
+ SubstituteStr = Str + 1;
+ while (*SubstituteStr != '%' && *SubstituteStr != 0 && (!IsWhiteSpace (*SubstituteStr) || ParseState->Quote)) {
+ if (*SubstituteStr == '"') {
+Index: shellenv/for.c
+===================================================================
+--- shellenv/for.c (revision 64)
++++ shellenv/for.c (working copy)
+@@ -24,7 +24,7 @@
+ #include "shelle.h"
+ #include "shellenvguid.h"
+
+-/*
++#if 0
+ BOOLEAN
+ CheckInterValue (
+ IN CHAR16 *wszValueStr,
+@@ -190,7 +190,7 @@
+ Returns:
+ EFI_SUCCESS The function finished sucessfully
+
+---
++--*/
+ {
+ EFI_BATCH_STATEMENT *Stmt;
+ EFI_LIST_ENTRY FileList;
+@@ -326,7 +326,8 @@
+
+ return Status;
+ }
+-*/
++#endif
++
+ EFI_STATUS
+ SEnvCmdForRun (
+ IN EFI_HANDLE hImageHandle,
+Index: shellenv/help.c
+===================================================================
+--- shellenv/help.c (revision 64)
++++ shellenv/help.c (working copy)
+@@ -52,7 +52,7 @@
+ NULL,
+ 0,
+ 0,
+- 0
++ (SHELL_VAR_CHECK_FLAG_TYPE) 0
+ }
+ };
+
+Index: shellenv/var.c
+===================================================================
+--- shellenv/var.c (revision 64)
++++ shellenv/var.c (working copy)
+@@ -110,7 +110,7 @@
+ NULL,
+ 0,
+ 0,
+- 0
++ (SHELL_VAR_CHECK_FLAG_TYPE) 0
+ }
+ };
+
+@@ -144,7 +144,6 @@
+ EFI_LIST_ENTRY *ListHead;
+ VARIABLE_ID *Var;
+ EFI_STATUS Status;
+- BOOLEAN IsString;
+ UINT32 Attributes;
+
+ //
+@@ -175,15 +174,12 @@
+ // See if it's a shellenv variable
+ //
+ ListHead = NULL;
+- IsString = FALSE;
+ if (CompareGuid (&Id, &SEnvEnvId) == 0) {
+ ListHead = &SEnvEnv;
+- IsString = TRUE;
+ }
+
+ if (CompareGuid (&Id, &SEnvAliasId) == 0) {
+ ListHead = &SEnvAlias;
+- IsString = TRUE;
+ }
+
+ if (ListHead) {
+Index: reset/reset.c
+===================================================================
+--- reset/reset.c (revision 64)
++++ reset/reset.c (working copy)
+@@ -61,7 +61,7 @@
+ NULL,
+ 0,
+ 0,
+- 0
++ (SHELL_VAR_CHECK_FLAG_TYPE) 0
+ }
+ };
+
+Index: reset/reset.h
+===================================================================
+--- reset/reset.h (revision 64)
++++ reset/reset.h (working copy)
+@@ -32,3 +32,4 @@
+ }
+
+ #endif
++
+Index: reset/reset.inf
+===================================================================
+--- reset/reset.inf (revision 64)
++++ reset/reset.inf (working copy)
+@@ -40,24 +40,24 @@
+
+
+ [sources.common]
+- ..\ShCommonStrings.uni
++ ../ShCommonStrings.uni
+ ResetStrings.uni
+ Reset.c
+ Reset.h
+
+ [includes.common]
+ .
+- ..\Inc
+- ..\Library
+- $(EDK_SOURCE)\Foundation
+- $(EDK_SOURCE)\Foundation\Include
+- $(EDK_SOURCE)\Foundation\Include\IndustryStandard
+- $(EDK_SOURCE)\Foundation\Efi
+- $(EDK_SOURCE)\Foundation\Efi\Include
+- $(EDK_SOURCE)\Foundation\FrameWork
+- $(EDK_SOURCE)\Foundation\FrameWork\Include
+- $(EDK_SOURCE)\Foundation\Core\Dxe
+- $(DEST_DIR)\
++ ../Inc
++ ../Library
++ $(EDK_SOURCE)/Foundation
++ $(EDK_SOURCE)/Foundation/Include
++ $(EDK_SOURCE)/Foundation/Include/IndustryStandard
++ $(EDK_SOURCE)/Foundation/Efi
++ $(EDK_SOURCE)/Foundation/Efi/Include
++ $(EDK_SOURCE)/Foundation/FrameWork
++ $(EDK_SOURCE)/Foundation/FrameWork/Include
++ $(EDK_SOURCE)/Foundation/Core/Dxe
++ $(DEST_DIR./
+
+ [libraries.common]
+ EfiShellLib
+Index: touch/touch.c
+===================================================================
+--- touch/touch.c (revision 64)
++++ touch/touch.c (working copy)
+@@ -64,7 +64,7 @@
+ //
+ // Global Variables
+ //
+-EFI_HII_HANDLE HiiHandle;
++STATIC EFI_HII_HANDLE HiiHandle;
+ EFI_GUID EfiTouchGuid = EFI_TOUCH_GUID;
+ SHELL_VAR_CHECK_ITEM TouchCheckList[] = {
+ {
+Index: touch/touch.h
+===================================================================
+--- touch/touch.h (revision 64)
++++ touch/touch.h (working copy)
+@@ -29,4 +29,4 @@
+ 0xa16a4695, 0x5815, 0x4d4f, 0xb8, 0xe, 0x6a, 0xf, 0x88, 0xac, 0xdb, 0x6c \
+ }
+-#endif
+\ No newline at end of file
++#endif
+Index: touch/touch.inf
+===================================================================
+--- touch/touch.inf (revision 64)
++++ touch/touch.inf (working copy)
+@@ -39,23 +39,23 @@
+ COMPONENT_TYPE = APPLICATION
[sources.common]
- ..\ShCommonStrings.uni
+ ../ShCommonStrings.uni
- stallStrings.uni
- stall.c
- stall.h
-
+ TouchStrings.uni
+ touch.c
+
[includes.common]
.
- ..\Inc
@@ -5486,45 +4701,1458 @@ index 58545a5..0c50120 100644
[libraries.common]
EfiShellLib
-diff --git a/time/time.c b/time/time.c
-index 00dd586..a0adbfe 100644
---- a/time/time.c
-+++ b/time/time.c
-@@ -64,8 +64,8 @@ STATIC
- BOOLEAN
- GetNumber (
- IN CHAR16 *Str,
-- IN OUT INTN *Offset,
-- IN OUT INTN *number,
-+ IN OUT UINTN *Offset,
-+ IN OUT UINTN *number,
- IN BOOLEAN GetSecond
- );
+Index: Shell.inf
+===================================================================
+--- Shell.inf (revision 64)
++++ Shell.inf (working copy)
+@@ -25,179 +25,189 @@
+ COMPONENT_TYPE = APPLICATION
-@@ -296,8 +296,8 @@ STATIC
- BOOLEAN
- GetNumber (
- IN CHAR16 *Str,
-- IN OUT INTN *Offset,
-- IN OUT INTN *Number,
-+ IN OUT UINTN *Offset,
-+ IN OUT UINTN *Number,
- IN BOOLEAN GetSecond
+ [sources.common]
+- Library\ShellDebug.c
+- Library\DPath.c
+- Library\Init.c
+- Library\Lock.c
+- Library\Str.c
+- Library\IO.c
+- Library\Mem.c
+- Library\Misc.c
+- Library\Data.c
+- Library\RtData.c
+- Library\ShellEnvInt.c
+- Library\Handle.c
+- Library\FileIO.c
+- Library\ConsistMapping.c
+- Library\CRC.c
+- Library\Event.c
+- Library\Perf.c
+- Library\VarCheck.c
+- Library\HiiSupport.c
++ Library/ShellDebug.c
++ Library/DPath.c
++ Library/Init.c
++ Library/Lock.c
++ Library/Str.c
++ Library/IO.c
++ Library/Mem.c
++ Library/Misc.c
++ Library/Data.c
++ Library/RtData.c
++ Library/ShellEnvInt.c
++ Library/Handle.c
++ Library/FileIO.c
++ Library/ConsistMapping.c
++ Library/CRC.c
++ Library/Event.c
++ Library/Perf.c
++ Library/VarCheck.c
++ Library/HiiSupport.c
+
+- newshell\NshellStrings.uni
+- newshell\init.c
+- newshell\nshell.h
+- newshell\fakehii.c
++ newshell/NshellStrings.uni
++ newshell/init.c
++ newshell/nshell.h
++ newshell/fakehii.c
+
+ ShCommonStrings.uni
+- shellenv\ShellenvHelpStrings.uni
+- shellenv\ShellenvStrings.uni
+- shellenv\ScriptCmdStrings.uni
+- shellenv\ConnectStrings.uni
+- shellenv\EchoStrings.uni
+- shellenv\HelpStrings.uni
+- shellenv\MapStrings.uni
+- shellenv\CdStrings.uni
+- shellenv\DhStrings.uni
++ shellenv/ShellenvHelpStrings.uni
++ shellenv/ShellenvStrings.uni
++ shellenv/ScriptCmdStrings.uni
++ shellenv/ConnectStrings.uni
++ shellenv/EchoStrings.uni
++ shellenv/HelpStrings.uni
++ shellenv/MapStrings.uni
++ shellenv/CdStrings.uni
++ shellenv/DhStrings.uni
+
+- shellenv\cmddisp.c
+- shellenv\connect.c
+- shellenv\data.c
+- shellenv\exec.c
+- shellenv\init.c
+- shellenv\protid.c
+- shellenv\var.c
+- shellenv\conio.c
+- shellenv\consoleproxy.c
+- shellenv\handle.c
+- shellenv\dprot.c
+- shellenv\map.c
+- shellenv\marg.c
+- shellenv\batch.c
+- shellenv\if.c
+- shellenv\goto.c
+- shellenv\echo.c
+- shellenv\pause.c
+- shellenv\for.c
+- shellenv\wait.c
+- shellenv\help.c
+- shellenv\shelle.h
+- shellenv\shellenvguid.h
+- shellenv\parsecmd.c
+- shellenv\shift.c
++ shellenv/cmddisp.c
++ shellenv/connect.c
++ shellenv/data.c
++ shellenv/exec.c
++ shellenv/init.c
++ shellenv/protid.c
++ shellenv/var.c
++ shellenv/conio.c
++ shellenv/consoleproxy.c
++ shellenv/handle.c
++ shellenv/dprot.c
++ shellenv/map.c
++ shellenv/marg.c
++ shellenv/batch.c
++ shellenv/if.c
++ shellenv/goto.c
++ shellenv/echo.c
++ shellenv/pause.c
++ shellenv/for.c
++ shellenv/wait.c
++ shellenv/help.c
++ shellenv/shelle.h
++ shellenv/shellenvguid.h
++ shellenv/parsecmd.c
++ shellenv/shift.c
+
+- unload\UnloadStrings.uni
+- unload\unload.c
++ unload/UnloadStrings.uni
++ unload/unload.c
+
+- attrib\AttribStrings.uni
+- attrib\attrib.c
+- attrib\attrib.h
++ attrib/AttribStrings.uni
++ attrib/attrib.c
++ attrib/attrib.h
+
+- cls\clsstrings.uni
+- cls\cls.c
++ cls/clsstrings.uni
++ cls/cls.c
+
+- cp\CpStrings.uni
+- cp\cp.h
+- cp\cp.c
++ cp/CpStrings.uni
++ cp/cp.h
++ cp/cp.c
+
+- date\DateStrings.uni
+- date\date.c
+- date\date.h
++ date/DateStrings.uni
++ date/date.c
++ date/date.h
+
+- load\LoadStrings.uni
+- load\load.c
+- load\load.h
++ load/LoadStrings.uni
++ load/load.c
++ load/load.h
+
+- ls\LsStrings.uni
+- ls\ls.h
+- ls\ls.c
++ ls/LsStrings.uni
++ ls/ls.h
++ ls/ls.c
+
+- mkdir\MkdirStrings.uni
+- mkdir\mkdir.c
+- mkdir\mkdir.h
++ mkdir/MkdirStrings.uni
++ mkdir/mkdir.c
++ mkdir/mkdir.h
+
+- mv\MvStrings.uni
+- mv\mv.c
+- mv\mv.h
++ mv/MvStrings.uni
++ mv/mv.c
++ mv/mv.h
+
+- reset\ResetStrings.uni
+- reset\reset.c
+- reset\reset.h
++ reset/ResetStrings.uni
++ reset/reset.c
++ reset/reset.h
+
+- rm\RmStrings.uni
+- rm\rm.h
+- rm\rm.c
++ rm/RmStrings.uni
++ rm/rm.h
++ rm/rm.c
+
+- type\TypeStrings.uni
+- type\type.c
+- type\type.h
+- time\TimeStrings.uni
+- time\time.c
+- time\time.h
++ type/TypeStrings.uni
++ type/type.c
++ type/type.h
++ time/TimeStrings.uni
++ time/time.c
++ time/time.h
+
+- touch\TouchStrings.uni
+- touch\touch.c
+- touch\touch.h
++ touch/TouchStrings.uni
++ touch/touch.c
++ touch/touch.h
+
+- vol\VolStrings.uni
+- vol\vol.c
+- vol\vol.h
++ vol/VolStrings.uni
++ vol/vol.c
++ vol/vol.h
+
+- ver\VerStrings.uni
+- ver\ver.c
+- ver\ver.h
++ ver/VerStrings.uni
++ ver/ver.c
++ ver/ver.h
+
+- drivers\driversStrings.uni
+- drivers\drivers.c
+- drivers\drivers.h
++ drivers/driversStrings.uni
++ drivers/drivers.c
++ drivers/drivers.h
+
+- drvcfg\DrvcfgStrings.uni
+- drvcfg\drvcfg.c
+- drvcfg\drvcfg.h
++ drvcfg/DrvcfgStrings.uni
++ drvcfg/drvcfg.c
++ drvcfg/drvcfg.h
+
+- drvdiag\DrvdiagStrings.uni
+- drvdiag\drvdiag.c
+- drvdiag\drvdiag.h
++ drvdiag/DrvdiagStrings.uni
++ drvdiag/drvdiag.c
++ drvdiag/drvdiag.h
+
+
+
+ [sources.ia32]
+- ver\ia32\ver32.c
+- Library\ia32\math.c
+- Library\ia32\initplat.c
++ ver/IA32/ver32.c
++ Library/IA32/math.c
++ Library/IA32/initplat.c
+
+
+ [sources.ipf]
+- ver\ipf\ver64.c
+- Library\ipf\math.c
+- Library\ipf\initplat.c
+- Library\ipf\palproc.s
+- Library\ipf\salpal.c
++ ver/IPF/ver64.c
++ Library/IPF/math.c
++ Library/IPF/initplat.c
++ Library/IPF/palproc.s
++ Library/IPF/salpal.c
+
+ [sources.EBC]
+- ver\ebc\verEbc.c
+- Library\EBC\math.c
+- Library\EBC\initplat.c
++ ver/ebc/verEbc.c
++ Library/Ebc/math.c
++ Library/Ebc/initplat.c
+
+ [sources.x64]
+- ver\ia32\ver32.c
+- Library\ipf\math.c
+- Library\ia32\initplat.c
++ ver/IA32/ver32.c
++ Library/IPF/math.c
++ Library/IA32/initplat.c
+
++[sources.ARM]
++ ver/ia32/ver32.c
++ Library/IPF/math.c
++ Library/IA32/initplat.c
++
++[sources.AARCH64]
++ ver/ia32/ver32.c
++ Library/IPF/math.c
++ Library/IA32/initplat.c
++
+ [includes.common]
+ .
+- .\Inc
+- .\ver
+- .\Library
+- $(EDK_SOURCE)\Foundation
+- $(EDK_SOURCE)\Foundation\Include
+- $(EDK_SOURCE)\Foundation\Include\IndustryStandard
+- $(EDK_SOURCE)\Foundation\Efi
+- $(EDK_SOURCE)\Foundation\Efi\Include
+- $(EDK_SOURCE)\Foundation\FrameWork
+- $(EDK_SOURCE)\Foundation\FrameWork\Include
+- $(EDK_SOURCE)\Foundation\Core\Dxe
++ ./Inc
++ ./ver
++ ./Library
++ $(EDK_SOURCE)/Foundation
++ $(EDK_SOURCE)/Foundation/Include
++ $(EDK_SOURCE)/Foundation/Include/IndustryStandard
++ $(EDK_SOURCE)/Foundation/Efi
++ $(EDK_SOURCE)/Foundation/Efi/Include
++ $(EDK_SOURCE)/Foundation/FrameWork
++ $(EDK_SOURCE)/Foundation/FrameWork/Include
++ $(EDK_SOURCE)/Foundation/Core/Dxe
+ $(DEST_DIR)
+
+ [libraries.common]
+@@ -229,4 +239,4 @@
+
+
+
+-
+\ No newline at end of file
++
+Index: IfConfig/IfConfig.inf
+===================================================================
+--- IfConfig/IfConfig.inf (revision 64)
++++ IfConfig/IfConfig.inf (working copy)
+@@ -25,7 +25,7 @@
+ COMPONENT_TYPE = APPLICATION
+
+ [sources.common]
+- ..\ShCommonStrings.uni
++ ../ShCommonStrings.uni
+ IfConfigStrings.uni
+ IfConfig.c
+ IfConfig.h
+@@ -33,25 +33,24 @@
+ ShellNetHelper.h
+
+ [includes.common]
+- ..\Inc
+- ..\Library
+- $(EDK_SOURCE)\Foundation\Efi
+- $(EDK_SOURCE)\Foundation
+- $(EDK_SOURCE)\Foundation\Efi\Include
+- $(EDK_SOURCE)\Foundation\Include
+- $(EDK_SOURCE)\Foundation\Include\IndustryStandard
+- $(EDK_SOURCE)\Foundation\FrameWork
+- $(EDK_SOURCE)\Foundation\FrameWork\Include
+- $(EDK_SOURCE)\Foundation\Core\Dxe
+- $(EDK_SOURCE)\Foundation\Library\Dxe\Include
+- $(DEST_DIR)\
++ ../Inc
++ ../Library
++ $(EDK_SOURCE)/Foundation/Efi
++ $(EDK_SOURCE)/Foundation
++ $(EDK_SOURCE)/Foundation/Efi/Include
++ $(EDK_SOURCE)/Foundation/Include
++ $(EDK_SOURCE)/Foundation/Include/IndustryStandard
++ $(EDK_SOURCE)/Foundation/FrameWork
++ $(EDK_SOURCE)/Foundation/FrameWork/Include
++ $(EDK_SOURCE)/Foundation/Core/Dxe
++ $(EDK_SOURCE)/Foundation/Library/Dxe/Include
++ $(DEST_DIR./
+
+ [libraries.common]
+ EfiShellLib
+ EdkProtocolLib
+ EfiProtocolLib
+ EdkGuidLib
+- EfiDriverLib
+
+ [nmake.common]
+ C_PROJ_FLAGS = $(C_PROJ_FLAGS)
+Index: IfConfig/ShellNetHelper.h
+===================================================================
+--- IfConfig/ShellNetHelper.h (revision 64)
++++ IfConfig/ShellNetHelper.h (working copy)
+@@ -87,3 +87,4 @@
+ IN EFI_HANDLE ChildHandle
+ );
+ #endif
++
+Index: IfConfig/IfConfig.c
+===================================================================
+--- IfConfig/IfConfig.c (revision 64)
++++ IfConfig/IfConfig.c (working copy)
+@@ -29,7 +29,7 @@
+ //
+ #define NIC_ITEM_CONFIG_SIZE sizeof (NIC_IP4_CONFIG_INFO) + sizeof (EFI_IP4_ROUTE_TABLE) * 16
+
+-EFI_HII_HANDLE HiiHandle;
++STATIC EFI_HII_HANDLE HiiHandle;
+
+ EFI_GUID EfiIfConfigGuid = EFI_IFCONFIG_GUID;
+
+@@ -75,7 +75,7 @@
+ NULL,
+ 0,
+ 0,
+- 0
++ (SHELL_VAR_CHECK_FLAG_TYPE) 0
+ }
+ };
+
+@@ -669,7 +669,7 @@
+ Status = BS->LocateProtocol (
+ &gEfiHiiConfigRoutingProtocolGuid,
+ NULL,
+- &mHiiConfigRouting
++ (VOID**)&mHiiConfigRouting
+ );
+ if (EFI_ERROR (Status)) {
+ return EFI_NOT_FOUND;
+Index: IfConfig/IfConfig.h
+===================================================================
+--- IfConfig/IfConfig.h (revision 64)
++++ IfConfig/IfConfig.h (working copy)
+@@ -60,3 +60,4 @@
+ } ARP_REQUEST;
+
+ #endif
++
+Index: edit/libStatusBar.c
+===================================================================
+--- edit/libStatusBar.c (revision 64)
++++ edit/libStatusBar.c (working copy)
+@@ -157,11 +157,15 @@
+ // back up the screen attributes
+ //
+ Orig = MainEditor.ColorAttributes;
++ New.Data = 0;
+ New.Colors.Foreground = Orig.Colors.Background;
+ New.Colors.Background = Orig.Colors.Foreground;
+
+ Out->EnableCursor (Out, FALSE);
+- Out->SetAttribute (Out, New.Data);
++ Out->SetAttribute (
++ Out,
++ EFI_TEXT_ATTR (New.Colors.Foreground, New.Colors.Background)
++ );
+
+ //
+ // clear status bar
+@@ -191,7 +195,10 @@
+ //
+ // restore the old screen attributes
+ //
+- Out->SetAttribute (Out, Orig.Data);
++ Out->SetAttribute (
++ Out,
++ EFI_TEXT_ATTR (Orig.Colors.Foreground, Orig.Colors.Background)
++ );
+
+ //
+ // restore position in edit area
+Index: edit/libFileBuffer.c
+===================================================================
+--- edit/libFileBuffer.c (revision 64)
++++ edit/libFileBuffer.c (working copy)
+@@ -196,8 +196,9 @@
+ // backup the old screen attributes
+ //
+ Orig = MainEditor.ColorAttributes;
+- New.Colors.Foreground = Orig.Colors.Background;
+- New.Colors.Background = Orig.Colors.Foreground;
++ New.Data = 0;
++ New.Colors.Foreground = Orig.Colors.Foreground;
++ New.Colors.Background = Orig.Colors.Background;
+
+ //
+ // clear the old mouse position
+@@ -235,10 +236,14 @@
+ Value
+ );
+ }
++
+ //
+ // set the new mouse position
+ //
+- Out->SetAttribute (Out, New.Data);
++ Out->SetAttribute (
++ Out,
++ EFI_TEXT_ATTR (New.Colors.Background, New.Colors.Foreground)
++ );
+
+ //
+ // clear the old mouse position
+@@ -278,7 +283,10 @@
+ //
+ // end of HasCharacter
+ //
+- Out->SetAttribute (Out, Orig.Data);
++ Out->SetAttribute (
++ Out,
++ EFI_TEXT_ATTR (Orig.Colors.Foreground, Orig.Colors.Background)
++ );
+ }
+ //
+ // end of MouseNeedRefresh
+@@ -768,7 +776,7 @@
+ Handle = NULL;
+ FileSize = 0;
+ UnicodeBuffer = NULL;
+- Type = 0;
++ Type = DEFAULT_TYPE;
+
+ //
+ // in this function, when you return error ( except EFI_OUT_OF_RESOURCES )
+@@ -2624,15 +2632,9 @@
+ VOID
)
{
-diff --git a/time/time.inf b/time/time.inf
-index 5181280..5b65e49 100644
---- a/time/time.inf
-+++ b/time/time.inf
-@@ -40,24 +40,24 @@ COMPONENT_TYPE = APPLICATION
+- EFI_EDITOR_LINE *Line;
+ UINTN FRow;
+ UINTN FCol;
+
+- //
+- // go to the first column of the line
+- //
+- Line = FileBuffer.CurrentLine;
+-
+ FRow = FileBuffer.FilePosition.Row;
+ FCol = 1;
+
+Index: edit/libtitlebar.h
+===================================================================
+--- edit/libtitlebar.h (revision 64)
++++ edit/libtitlebar.h (working copy)
+@@ -46,3 +46,4 @@
+ );
+
+ #endif
++
+Index: edit/libstatusbar.h
+===================================================================
+--- edit/libstatusbar.h (revision 64)
++++ edit/libstatusbar.h (working copy)
+@@ -53,3 +53,4 @@
+ );
+
+ #endif
++
+Index: edit/libfilebuffer.h
+===================================================================
+--- edit/libfilebuffer.h (revision 64)
++++ edit/libfilebuffer.h (working copy)
+@@ -209,3 +209,4 @@
+ );
+
+ #endif
++
+Index: edit/libInputBar.c
+===================================================================
+--- edit/libInputBar.c (revision 64)
++++ edit/libInputBar.c (working copy)
+@@ -141,8 +141,6 @@
+ UINTN Size;
+ EFI_STATUS Status;
+ BOOLEAN NoDisplay;
+- UINTN Limit;
+- UINTN PromptLen;
+
+ //
+ // variable initialization
+@@ -162,10 +160,14 @@
+ // back up the old screen attributes
+ //
+ Orig = MainEditor.ColorAttributes;
++ New.Data = 0;
+ New.Colors.Foreground = Orig.Colors.Background;
+ New.Colors.Background = Orig.Colors.Foreground;
+
+- Out->SetAttribute (Out, New.Data);
++ Out->SetAttribute (
++ Out,
++ EFI_TEXT_ATTR (New.Colors.Foreground, New.Colors.Background)
++ );
+
+ //
+ // clear input bar
+@@ -173,22 +175,19 @@
+ EditorClearLine (INPUT_BAR_LOCATION);
+
+ Out->SetCursorPosition (Out, 0, INPUT_BAR_LOCATION - 1);
+- PrintToken (STRING_TOKEN (STR_EDIT_LIBINPUTBAR_MAININPUTBAR), HiiHandle, MainInputBar.Prompt);
++ PrintToken (STRING_TOKEN (STR_EDIT_LIBINPUTBAR_MAININPUTBAR), gEditHiiHandle, MainInputBar.Prompt);
+
+ //
+- // that's the maximum input length that can be displayed on screen
+- //
+- PromptLen = StrLen (MainInputBar.Prompt);
+- Limit = MainEditor.ScreenSize.Column - PromptLen;
+-
+- //
+ // this is a selection prompt, cursor will stay in edit area
+ // actually this is for search , search/replace
+ //
+ if (StrStr (MainInputBar.Prompt, L"Yes/No")) {
+ NoDisplay = TRUE;
+ FileBufferRestorePosition ();
+- Out->SetAttribute (Out, Orig.Data);
++ Out->SetAttribute (
++ Out,
++ EFI_TEXT_ATTR (Orig.Colors.Foreground, Orig.Colors.Background)
++ );
+ } else {
+ NoDisplay = FALSE;
+ }
+@@ -265,7 +264,10 @@
+ //
+ // restore screen attributes
+ //
+- Out->SetAttribute (Out, Orig.Data);
++ Out->SetAttribute (
++ Out,
++ EFI_TEXT_ATTR (Orig.Colors.Foreground, Orig.Colors.Background)
++ );
+
+ StatusBarNeedRefresh = TRUE;
+
+Index: edit/libEditor.c
+===================================================================
+--- edit/libEditor.c (revision 64)
++++ edit/libEditor.c (working copy)
+@@ -123,7 +123,7 @@
+ Status = BS->HandleProtocol (
+ In,
+ &gEfiSimplePointerProtocolGuid,
+- &MainEditor.MouseInterface
++ (VOID**)&MainEditor.MouseInterface
+ );
+ if (EFI_ERROR (Status)) {
+ //
+@@ -146,7 +146,7 @@
+ Status = BS->HandleProtocol (
+ HandleBuffer[Index],
+ &gEfiSimplePointerProtocolGuid,
+- &MainEditor.MouseInterface
++ (VOID**)&MainEditor.MouseInterface
+ );
+ if (!EFI_ERROR (Status)) {
+ break;
+@@ -169,31 +169,31 @@
+ //
+ Status = MainTitleBarInit ();
+ if (EFI_ERROR (Status)) {
+- PrintToken (STRING_TOKEN (STR_EDIT_LIBEDITOR_TITLEBAR), HiiHandle);
++ PrintToken (STRING_TOKEN (STR_EDIT_LIBEDITOR_TITLEBAR), gEditHiiHandle);
+ return EFI_LOAD_ERROR;
+ }
+
+ Status = MainMenuBarInit ();
+ if (EFI_ERROR (Status)) {
+- PrintToken (STRING_TOKEN (STR_EDIT_LIBEDITOR_MAINMENU), HiiHandle);
++ PrintToken (STRING_TOKEN (STR_EDIT_LIBEDITOR_MAINMENU), gEditHiiHandle);
+ return EFI_LOAD_ERROR;
+ }
+
+ Status = MainStatusBarInit ();
+ if (EFI_ERROR (Status)) {
+- PrintToken (STRING_TOKEN (STR_EDIT_LIBEDITOR_STATUSBAR), HiiHandle);
++ PrintToken (STRING_TOKEN (STR_EDIT_LIBEDITOR_STATUSBAR), gEditHiiHandle);
+ return EFI_LOAD_ERROR;
+ }
+
+ Status = MainInputBarInit ();
+ if (EFI_ERROR (Status)) {
+- PrintToken (STRING_TOKEN (STR_EDIT_LIBEDITOR_INPUTBAR), HiiHandle);
++ PrintToken (STRING_TOKEN (STR_EDIT_LIBEDITOR_INPUTBAR), gEditHiiHandle);
+ return EFI_LOAD_ERROR;
+ }
+
+ Status = FileBufferInit ();
+ if (EFI_ERROR (Status)) {
+- PrintToken (STRING_TOKEN (STR_EDIT_LIBEDITOR_FILEBUFFER), HiiHandle);
++ PrintToken (STRING_TOKEN (STR_EDIT_LIBEDITOR_FILEBUFFER), gEditHiiHandle);
+ return EFI_LOAD_ERROR;
+ }
+ //
+@@ -234,27 +234,27 @@
+ //
+ Status = MainTitleBarCleanup ();
+ if (EFI_ERROR (Status)) {
+- PrintToken (STRING_TOKEN (STR_EDIT_LIBEDITOR_TILEBAR_CLEANUP), HiiHandle);
++ PrintToken (STRING_TOKEN (STR_EDIT_LIBEDITOR_TILEBAR_CLEANUP), gEditHiiHandle);
+ }
+
+ Status = MainMenuBarCleanup ();
+ if (EFI_ERROR (Status)) {
+- PrintToken (STRING_TOKEN (STR_EDIT_LIBEDITOR_MENUBAR_CLEANUP), HiiHandle);
++ PrintToken (STRING_TOKEN (STR_EDIT_LIBEDITOR_MENUBAR_CLEANUP), gEditHiiHandle);
+ }
+
+ Status = MainStatusBarCleanup ();
+ if (EFI_ERROR (Status)) {
+- PrintToken (STRING_TOKEN (STR_EDIT_LIBEDITOR_STATUSBAR_CLEANUP), HiiHandle);
++ PrintToken (STRING_TOKEN (STR_EDIT_LIBEDITOR_STATUSBAR_CLEANUP), gEditHiiHandle);
+ }
+
+ Status = MainInputBarCleanup ();
+ if (EFI_ERROR (Status)) {
+- PrintToken (STRING_TOKEN (STR_EDIT_LIBEDITOR_INPUTBAR_CLEANUP), HiiHandle);
++ PrintToken (STRING_TOKEN (STR_EDIT_LIBEDITOR_INPUTBAR_CLEANUP), gEditHiiHandle);
+ }
+
+ Status = FileBufferCleanup ();
+ if (EFI_ERROR (Status)) {
+- PrintToken (STRING_TOKEN (STR_EDIT_LIBEDITOR_FILEBUFFER_CLEANUP), HiiHandle);
++ PrintToken (STRING_TOKEN (STR_EDIT_LIBEDITOR_FILEBUFFER_CLEANUP), gEditHiiHandle);
+ }
+ //
+ // restore old mode
+Index: edit/edit.inf
+===================================================================
+--- edit/edit.inf (revision 64)
++++ edit/edit.inf (working copy)
+@@ -25,7 +25,7 @@
+ COMPONENT_TYPE = APPLICATION
+
+ [sources.common]
+- ..\ShCommonStrings.uni
++ ../ShCommonStrings.uni
+ EditStrings.uni
+ editor.h
+ editortype.h
+@@ -41,17 +41,17 @@
+
+ [includes.common]
+ .
+- ..\Inc
+- ..\Library
+- $(EDK_SOURCE)\Foundation
+- $(EDK_SOURCE)\Foundation\Include
+- $(EDK_SOURCE)\Foundation\Include\IndustryStandard
+- $(EDK_SOURCE)\Foundation\Efi
+- $(EDK_SOURCE)\Foundation\Efi\Include
+- $(EDK_SOURCE)\Foundation\FrameWork
+- $(EDK_SOURCE)\Foundation\FrameWork\Include
+- $(EDK_SOURCE)\Foundation\Core\Dxe
+- $(DEST_DIR)\
++ ../Inc
++ ../Library
++ $(EDK_SOURCE)/Foundation
++ $(EDK_SOURCE)/Foundation/Include
++ $(EDK_SOURCE)/Foundation/Include/IndustryStandard
++ $(EDK_SOURCE)/Foundation/Efi
++ $(EDK_SOURCE)/Foundation/Efi/Include
++ $(EDK_SOURCE)/Foundation/FrameWork
++ $(EDK_SOURCE)/Foundation/FrameWork/Include
++ $(EDK_SOURCE)/Foundation/Core/Dxe
++ $(DEST_DIR./
+
+ [libraries.common]
+ EfiShellLib
+Index: edit/libMenuBar.c
+===================================================================
+--- edit/libMenuBar.c (revision 64)
++++ edit/libMenuBar.c (working copy)
+@@ -189,7 +189,6 @@
+ CHAR16 *NameString;
+ CHAR16 *FunctionKeyString;
+ UINTN BufferSize;
+- EFI_STATUS Status;
+
+ //
+ // variable initialization
+@@ -220,9 +219,9 @@
+ FunctionKeyString = AllocatePool (BufferSize);
+
+ #if (EFI_SPECIFICATION_VERSION < 0x0002000A)
+- Status = Hii->GetString (Hii, HiiHandle, Item->NameToken, FALSE, NULL, &BufferSize, NameString);
++ Hii->GetString (Hii, gEditHiiHandle, Item->NameToken, FALSE, NULL, &BufferSize, NameString);
+ #else
+- Status = LibGetString (HiiHandle, Item->NameToken, NameString, &BufferSize);
++ LibGetString (gEditHiiHandle, Item->NameToken, NameString, &BufferSize);
+ #endif
+
+ Width = max ((StrLen (NameString) + 6), 20);
+@@ -232,9 +231,9 @@
+ }
+
+ #if (EFI_SPECIFICATION_VERSION < 0x0002000A)
+- Status = Hii->GetString (Hii, HiiHandle, Item->FunctionKeyToken, FALSE, NULL, &BufferSize, FunctionKeyString);
++ Hii->GetString (Hii, gEditHiiHandle, Item->FunctionKeyToken, FALSE, NULL, &BufferSize, FunctionKeyString);
+ #else
+- Status = LibGetString (HiiHandle, Item->FunctionKeyToken, FunctionKeyString, &BufferSize);
++ LibGetString (gEditHiiHandle, Item->FunctionKeyToken, FunctionKeyString, &BufferSize);
+ #endif
+ PrintAt (Col - 1, Row - 1, L"%E%s%N %H%s%N ", FunctionKeyString, NameString);
+
+Index: edit/libinputbar.h
+===================================================================
+--- edit/libinputbar.h (revision 64)
++++ edit/libinputbar.h (working copy)
+@@ -44,3 +44,4 @@
+ );
+
+ #endif
++
+Index: edit/libeditor.h
+===================================================================
+--- edit/libeditor.h (revision 64)
++++ edit/libeditor.h (working copy)
+@@ -52,3 +52,4 @@
+ );
+
+ #endif
++
+Index: edit/main.c
+===================================================================
+--- edit/main.c (revision 64)
++++ edit/main.c (working copy)
+@@ -34,7 +34,7 @@
+ //
+ // Global Variables
+ //
+-EFI_HII_HANDLE HiiHandle;
++EFI_HII_HANDLE gEditHiiHandle;
+ #if (EFI_SPECIFICATION_VERSION < 0x0002000A)
+ EFI_HII_PROTOCOL *Hii;
+ #endif
+@@ -56,7 +56,7 @@
+ NULL,
+ 0,
+ 0,
+- 0
++ (SHELL_VAR_CHECK_FLAG_TYPE) 0
+ }
+ };
+
+@@ -121,13 +121,13 @@
+ //
+ // There should only be one HII protocol
+ //
+- Status = LibLocateProtocol (&gEfiHiiProtocolGuid, &Hii);
++ Status = LibLocateProtocol (&gEfiHiiProtocolGuid, (VOID**)&Hii);
+ if (EFI_ERROR (Status) || NULL == Hii) {
+ return EFI_ABORTED;
+ }
+ #endif
+
+- Status = LibInitializeStrings (&HiiHandle, STRING_ARRAY_NAME, &EfiEditGuid);
++ Status = LibInitializeStrings (&gEditHiiHandle, STRING_ARRAY_NAME, &EfiEditGuid);
+
+ if (EFI_ERROR (Status)) {
+ return Status;
+@@ -137,7 +137,7 @@
+ if (VarCheckOk != RetCode) {
+ switch (RetCode) {
+ case VarCheckUnknown:
+- PrintToken (STRING_TOKEN (STR_SHELLENV_GNC_UNKNOWN_FLAG), HiiHandle, L"edit", Useful);
++ PrintToken (STRING_TOKEN (STR_SHELLENV_GNC_UNKNOWN_FLAG), gEditHiiHandle, L"edit", Useful);
+ break;
+
+ default:
+@@ -161,10 +161,10 @@
+ ChkPck.FlagCount > 2 ||
+ (ChkPck.FlagCount == 2 && LibCheckVarGetFlag (&ChkPck, L"-b") == NULL)
+ ) {
+- PrintToken (STRING_TOKEN (STR_SHELLENV_GNC_TOO_MANY), HiiHandle, L"edit");
++ PrintToken (STRING_TOKEN (STR_SHELLENV_GNC_TOO_MANY), gEditHiiHandle, L"edit");
+ Status = EFI_INVALID_PARAMETER;
+ } else {
+- PrintToken (STRING_TOKEN (STR_EDIT_VERBOSE_HELP), HiiHandle);
++ PrintToken (STRING_TOKEN (STR_EDIT_VERBOSE_HELP), gEditHiiHandle);
+ Status = EFI_SUCCESS;
+ }
+
+@@ -172,21 +172,21 @@
+ }
+
+ if (ChkPck.ValueCount > 1) {
+- PrintToken (STRING_TOKEN (STR_SHELLENV_GNC_TOO_MANY), HiiHandle, L"edit");
++ PrintToken (STRING_TOKEN (STR_SHELLENV_GNC_TOO_MANY), gEditHiiHandle, L"edit");
+ Status = EFI_INVALID_PARAMETER;
+ goto done;
+ }
+
+ if (ChkPck.ValueCount == 1) {
+ if (!IsValidFileName (ChkPck.VarList->VarStr)) {
+- PrintToken (STRING_TOKEN (STR_EDIT_MAIN_INVALID_FILE_NAME), HiiHandle);
++ PrintToken (STRING_TOKEN (STR_EDIT_MAIN_INVALID_FILE_NAME), gEditHiiHandle);
+ Status = EFI_INVALID_PARAMETER;
+ goto done;
+ }
+ }
+
+ if (SI->RedirArgc != 0) {
+- PrintToken (STRING_TOKEN (STR_EDIT_NOREDIRECT), HiiHandle);
++ PrintToken (STRING_TOKEN (STR_EDIT_NOREDIRECT), gEditHiiHandle);
+ Status = EFI_INVALID_PARAMETER;
+ goto done;
+ }
+@@ -195,7 +195,7 @@
+ if (EFI_ERROR (Status)) {
+ Out->ClearScreen (Out);
+ Out->EnableCursor (Out, TRUE);
+- PrintToken (STRING_TOKEN (STR_EDIT_MAIN_INIT_FAILED), HiiHandle);
++ PrintToken (STRING_TOKEN (STR_EDIT_MAIN_INIT_FAILED), gEditHiiHandle);
+ goto done;
+ }
+
+@@ -240,19 +240,19 @@
+ //
+ if (Status == EFI_SUCCESS) {
+ } else if (Status == EFI_OUT_OF_RESOURCES) {
+- PrintToken (STRING_TOKEN (STR_SHELLENV_GNC_OUT_RESOURCE), HiiHandle, L"edit");
++ PrintToken (STRING_TOKEN (STR_SHELLENV_GNC_OUT_RESOURCE), gEditHiiHandle, L"edit");
+ } else {
+ if (Buffer != NULL) {
+ if (StrCmp (Buffer, L"") != 0) {
+ //
+ // print out the status string
+ //
+- PrintToken (STRING_TOKEN (STR_EDIT_MAIN_BUFFER), HiiHandle, Buffer);
++ PrintToken (STRING_TOKEN (STR_EDIT_MAIN_BUFFER), gEditHiiHandle, Buffer);
+ } else {
+- PrintToken (STRING_TOKEN (STR_EDIT_MAIN_UNKNOWN_EDITOR_ERR), HiiHandle);
++ PrintToken (STRING_TOKEN (STR_EDIT_MAIN_UNKNOWN_EDITOR_ERR), gEditHiiHandle);
+ }
+ } else {
+- PrintToken (STRING_TOKEN (STR_EDIT_MAIN_UNKNOWN_EDITOR_ERR), HiiHandle);
++ PrintToken (STRING_TOKEN (STR_EDIT_MAIN_UNKNOWN_EDITOR_ERR), gEditHiiHandle);
+ }
+ }
+
+Index: edit/libmenubar.h
+===================================================================
+--- edit/libmenubar.h (revision 64)
++++ edit/libmenubar.h (working copy)
+@@ -85,3 +85,4 @@
+ );
+
+ #endif
++
+Index: edit/libMisc.h
+===================================================================
+--- edit/libMisc.h (revision 64)
++++ edit/libMisc.h (working copy)
+@@ -96,3 +96,4 @@
+ ) ;
+
+ #endif
++
+Index: edit/editor.h
+===================================================================
+--- edit/editor.h (revision 64)
++++ edit/editor.h (working copy)
+@@ -33,7 +33,7 @@
+ #include "libstatusbar.h"
+ #include "libinputbar.h"
+ #include "libmenubar.h"
+-#include "libmisc.h"
++#include "libMisc.h"
+ //
+ // This is the generated header file which includes whatever needs to be exported (strings + IFR)
+ //
+@@ -43,9 +43,10 @@
+ extern BOOLEAN EditorFirst;
+ extern BOOLEAN EditorExit;
+
+-extern EFI_HII_HANDLE HiiHandle;
++extern EFI_HII_HANDLE gEditHiiHandle;
+ #if (EFI_SPECIFICATION_VERSION < 0x0002000A)
+ extern EFI_HII_PROTOCOL *Hii;
+ #endif
+
+ #endif // _EFI_EDITOR_H_
++
+Index: edit/libTitleBar.c
+===================================================================
+--- edit/libTitleBar.c (revision 64)
++++ edit/libTitleBar.c (working copy)
+@@ -120,10 +120,15 @@
+ // backup the old screen attributes
+ //
+ Orig = MainEditor.ColorAttributes;
++
++ New.Data = 0;
+ New.Colors.Foreground = Orig.Colors.Background;
+ New.Colors.Background = Orig.Colors.Foreground;
+
+- Out->SetAttribute (Out, New.Data);
++ Out->SetAttribute (
++ Out,
++ EFI_TEXT_ATTR (New.Colors.Foreground, New.Colors.Background)
++ );
+
+ //
+ // clear the old title bar
+@@ -142,7 +147,10 @@
+ );
+
+ if (MainEditor.FileBuffer->FileName == NULL) {
+- Out->SetAttribute (Out, Orig.Data);
++ Out->SetAttribute (
++ Out,
++ EFI_TEXT_ATTR (Orig.Colors.Foreground, Orig.Colors.Background)
++ );
+ FileBufferRestorePosition ();
+ return EFI_SUCCESS;
+ }
+@@ -204,7 +212,10 @@
+ //
+ // restore the old attribute
+ //
+- Out->SetAttribute (Out, Orig.Data);
++ Out->SetAttribute (
++ Out,
++ EFI_TEXT_ATTR (Orig.Colors.Foreground, Orig.Colors.Background)
++ );
+
+ //
+ // restore edit area cursor position
+Index: edit/editortype.h
+===================================================================
+--- edit/editortype.h (revision 64)
++++ edit/editortype.h (working copy)
+@@ -28,7 +28,7 @@
+ #define EDITOR_NAME L"EFI Editor\0"
+ #define EDITOR_VERSION L"0.99\0"
+
+-#define EFI_EDITOR_LINE_LIST 'eell'
++#define EFI_EDITOR_LINE_LIST EFI_SIGNATURE_32 ('e','e','l','l')
+
+ #define INSERT_MODE_STR L"INS"
+ #define OVERWR_MODE_STR L"OVR"
+@@ -149,8 +149,8 @@
+ } EFI_EDITOR_MENU_ITEM;
+
+ typedef struct {
+- UINT32 Foreground : 4;
+- UINT32 Background : 4;
++ UINT8 Foreground : 4;
++ UINT8 Background : 4;
+ } EFI_EDITOR_COLOR_ATTRIBUTES;
+
+ typedef union {
+@@ -223,3 +223,4 @@
+ } EFI_EDITOR_GLOBAL_EDITOR;
+
+ #endif
++
+Index: SmbiosView/EventLogInfo.c
+===================================================================
+--- SmbiosView/EventLogInfo.c (revision 64)
++++ SmbiosView/EventLogInfo.c (working copy)
+@@ -25,7 +25,7 @@
+ #include "PrintInfo.h"
+ #include "QueryTable.h"
+ #include "EventLogInfo.h"
+-#include "smbios.h"
++#include "Smbios.h"
+ #include STRING_DEFINES_FILE
+
+ VOID
+Index: SmbiosView/Smbios.h
+===================================================================
+--- SmbiosView/Smbios.h (revision 64)
++++ SmbiosView/Smbios.h (working copy)
+@@ -37,3 +37,4 @@
+
+
+ #endif
++
+Index: SmbiosView/EventLogInfo.h
+===================================================================
+--- SmbiosView/EventLogInfo.h (revision 64)
++++ SmbiosView/EventLogInfo.h (working copy)
+@@ -85,3 +85,4 @@
+ );
+
+ #endif
++
+Index: SmbiosView/PrintInfo.c
+===================================================================
+--- SmbiosView/PrintInfo.c (revision 64)
++++ SmbiosView/PrintInfo.c (working copy)
+@@ -26,7 +26,7 @@
+ #include "LibSmbiosView.h"
+ #include "QueryTable.h"
+ #include "EventLogInfo.h"
+-#include "smbios.h"
++#include "Smbios.h"
+ #include STRING_DEFINES_FILE
+
+ //
+Index: SmbiosView/PrintInfo.h
+===================================================================
+--- SmbiosView/PrintInfo.h (revision 64)
++++ SmbiosView/PrintInfo.h (working copy)
+@@ -199,3 +199,4 @@
+ );
+
+ #endif
++
+Index: SmbiosView/QueryTable.c
+===================================================================
+--- SmbiosView/QueryTable.c (revision 64)
++++ SmbiosView/QueryTable.c (working copy)
+@@ -23,7 +23,7 @@
+ #include "EfiShellLib.h"
+ #include "QueryTable.h"
+ #include "PrintInfo.h"
+-#include "smbios.h"
++#include "Smbios.h"
+
+ #include STRING_DEFINES_FILE
+
+Index: SmbiosView/LibSmbiosView.c
+===================================================================
+--- SmbiosView/LibSmbiosView.c (revision 64)
++++ SmbiosView/LibSmbiosView.c (working copy)
+@@ -22,10 +22,10 @@
+ --*/
+
+ #include "EfiShellLib.h"
+-#include "LIbSmbios.h"
++#include "LibSmbios.h"
+ #include "LibSmbiosView.h"
+ #include "smbiosview.h"
+-#include "smbios.h"
++#include "Smbios.h"
+ #include STRING_DEFINES_FILE
+
+ STATIC UINT8 mInit = 0;
+@@ -62,7 +62,7 @@
+ //
+ // Get SMBIOS table from System Configure table
+ //
+- Status = LibGetSystemConfigurationTable (&gEfiSmbiosTableGuid, &mSmbiosTable);
++ Status = LibGetSystemConfigurationTable (&gEfiSmbiosTableGuid, (VOID**)&mSmbiosTable);
+
+ if (mSmbiosTable == NULL) {
+ PrintToken (STRING_TOKEN (STR_SMBIOSVIEW_LIBSMBIOSVIEW_CANNOT_GET_TABLE), HiiHandle);
+Index: SmbiosView/Smbiosview.inf
+===================================================================
+--- SmbiosView/Smbiosview.inf (revision 64)
++++ SmbiosView/Smbiosview.inf (working copy)
+@@ -25,7 +25,7 @@
+ COMPONENT_TYPE = APPLICATION
+
+ [sources.common]
+- ..\ShCommonStrings.uni
++ ../ShCommonStrings.uni
+ SmBiosViewStrings.uni
+ QueryTable.c
+ QueryTable.h
+@@ -43,19 +43,19 @@
+
+ [includes.common]
+ .
+- ..\Inc
+- ..\Library
+- $(EDK_SOURCE)\Foundation
+- $(EDK_SOURCE)\Foundation\Include
+- $(EDK_SOURCE)\Foundation\Include\IndustryStandard
+- $(EDK_SOURCE)\Foundation\Efi
+- $(EDK_SOURCE)\Foundation\Efi\Include
+- $(EDK_SOURCE)\Foundation\FrameWork
+- $(EDK_SOURCE)\Foundation\FrameWork\Include
+- $(EDK_SOURCE)\Foundation\Core\Dxe
+- $(DEST_DIR)\
+- $(EFI_SOURCE)\Application\Shell\Inc
+- $(EFI_SOURCE)\Application\Shell\Library
++ ../Inc
++ ../Library
++ $(EDK_SOURCE)/Foundation
++ $(EDK_SOURCE)/Foundation/Include
++ $(EDK_SOURCE)/Foundation/Include/IndustryStandard
++ $(EDK_SOURCE)/Foundation/Efi
++ $(EDK_SOURCE)/Foundation/Efi/Include
++ $(EDK_SOURCE)/Foundation/FrameWork
++ $(EDK_SOURCE)/Foundation/FrameWork/Include
++ $(EDK_SOURCE)/Foundation/Core/Dxe
++ $(DEST_DIR./
++ $(EFI_SOURCE)/Applicatio./Shels/Inc
++ $(EFI_SOURCE)/Applicatio./Shels/Library
+
+ [libraries.common]
+ EfiShellLib
+Index: SmbiosView/QueryTable.h
+===================================================================
+--- SmbiosView/QueryTable.h (revision 64)
++++ SmbiosView/QueryTable.h (working copy)
+@@ -437,3 +437,4 @@
+ );
+
+ #endif
++
+Index: SmbiosView/LibSmbiosView.h
+===================================================================
+--- SmbiosView/LibSmbiosView.h (revision 64)
++++ SmbiosView/LibSmbiosView.h (working copy)
+@@ -128,3 +128,4 @@
+ );
+
+ #endif
++
+Index: SmbiosView/smbiosview.c
+===================================================================
+--- SmbiosView/smbiosview.c (revision 64)
++++ SmbiosView/smbiosview.c (working copy)
+@@ -26,7 +26,7 @@
+ #include "smbiosview.h"
+ #include "PrintInfo.h"
+ #include "QueryTable.h"
+-#include "smbios.h"
++#include "Smbios.h"
+
+ extern UINT8 STRING_ARRAY_NAME[];
+
+@@ -88,7 +88,7 @@
+ NULL,
+ 0,
+ 0,
+- 0
++ (SHELL_VAR_CHECK_FLAG_TYPE)0
+ }
+ };
+
+Index: SmbiosView/LibSmbios.h
+===================================================================
+--- SmbiosView/LibSmbios.h (revision 64)
++++ SmbiosView/LibSmbios.h (working copy)
+@@ -642,3 +642,4 @@
+
+
+ #endif
++
+Index: SmbiosView/smbiosview.h
+===================================================================
+--- SmbiosView/smbiosview.h (revision 64)
++++ SmbiosView/smbiosview.h (working copy)
+@@ -84,3 +84,4 @@
+ extern UINT8 gShowType;
+
+ #endif
++
+Index: guid/guid.inf
+===================================================================
+--- guid/guid.inf (revision 64)
++++ guid/guid.inf (working copy)
+@@ -37,23 +37,23 @@
+ FILE_GUID = CBEB01F8-0912-4d87-8A6B-45D02847A405
+ COMPONENT_TYPE = APPLICATION
+ [sources.common]
+- ..\ShCommonStrings.uni
++ ../ShCommonStrings.uni
+ GuidStrings.uni
+ guid.c
+ guid.h
+ [includes.common]
+ .
+- ..\Inc
+- ..\Library
+- $(EDK_SOURCE)\Foundation
+- $(EDK_SOURCE)\Foundation\Include
+- $(EDK_SOURCE)\Foundation\Include\IndustryStandard
+- $(EDK_SOURCE)\Foundation\Efi
+- $(EDK_SOURCE)\Foundation\Efi\Include
+- $(EDK_SOURCE)\Foundation\FrameWork
+- $(EDK_SOURCE)\Foundation\FrameWork\Include
+- $(EDK_SOURCE)\Foundation\Core\Dxe
+- $(DEST_DIR)\
++ ../Inc
++ ../Library
++ $(EDK_SOURCE)/Foundation
++ $(EDK_SOURCE)/Foundation/Include
++ $(EDK_SOURCE)/Foundation/Include/IndustryStandard
++ $(EDK_SOURCE)/Foundation/Efi
++ $(EDK_SOURCE)/Foundation/Efi/Include
++ $(EDK_SOURCE)/Foundation/FrameWork
++ $(EDK_SOURCE)/Foundation/FrameWork/Include
++ $(EDK_SOURCE)/Foundation/Core/Dxe
++ $(DEST_DIR./
+ [libraries.common]
+ EfiShellLib
+ EdkProtocolLib
+Index: guid/guid.c
+===================================================================
+--- guid/guid.c (revision 64)
++++ guid/guid.c (working copy)
+@@ -36,7 +36,7 @@
+ //
+ // Global Variables
+ //
+-EFI_HII_HANDLE HiiHandle;
++STATIC EFI_HII_HANDLE HiiHandle;
+ EFI_GUID EfiGuidGuid = EFI_GUID_GUID;
+ SHELL_VAR_CHECK_ITEM GuidCheckList[] = {
+ {
+@@ -55,7 +55,7 @@
+ NULL,
+ 0,
+ 0,
+- 0
++ (SHELL_VAR_CHECK_FLAG_TYPE)0
+ }
+ };
+
+Index: guid/guid.h
+===================================================================
+--- guid/guid.h (revision 64)
++++ guid/guid.h (working copy)
+@@ -31,4 +31,4 @@
+ 0x425bff44, 0x1cae, 0x4c27, 0x98, 0x2c, 0x25, 0xc8, 0x74, 0x59, 0xdf, 0xd6 \
+ }
+
+-#endif
+\ No newline at end of file
++#endif
+Index: LoadPciRom/LoadPciRom.h
+===================================================================
+--- LoadPciRom/LoadPciRom.h (revision 64)
++++ LoadPciRom/LoadPciRom.h (working copy)
+@@ -30,3 +30,4 @@
+ }
+
+ #endif
++
+Index: LoadPciRom/LoadPciRom.inf
+===================================================================
+--- LoadPciRom/LoadPciRom.inf (revision 64)
++++ LoadPciRom/LoadPciRom.inf (working copy)
+@@ -41,23 +41,23 @@
+
+ [sources.common]
+ LoadPciRomStrings.uni
+- ..\ShCommonStrings.uni
++ ../ShCommonStrings.uni
+ LoadPciRom.c
+ LoadPciRom.h
+
+ [includes.common]
+ .
+- ..\Inc
+- ..\Library
+- $(EDK_SOURCE)\Foundation
+- $(EDK_SOURCE)\Foundation\Include
+- $(EDK_SOURCE)\Foundation\Include\IndustryStandard
+- $(EDK_SOURCE)\Foundation\Efi
+- $(EDK_SOURCE)\Foundation\Efi\Include
+- $(EDK_SOURCE)\Foundation\FrameWork
+- $(EDK_SOURCE)\Foundation\FrameWork\Include
+- $(EDK_SOURCE)\Foundation\Core\Dxe
+- $(DEST_DIR)\
++ ../Inc
++ ../Library
++ $(EDK_SOURCE)/Foundation
++ $(EDK_SOURCE)/Foundation/Include
++ $(EDK_SOURCE)/Foundation/Include/IndustryStandard
++ $(EDK_SOURCE)/Foundation/Efi
++ $(EDK_SOURCE)/Foundation/Efi/Include
++ $(EDK_SOURCE)/Foundation/FrameWork
++ $(EDK_SOURCE)/Foundation/FrameWork/Include
++ $(EDK_SOURCE)/Foundation/Core/Dxe
++ $(DEST_DIR./
+
+ [libraries.common]
+ EfiShellLib
+Index: LoadPciRom/LoadPciRom.c
+===================================================================
+--- LoadPciRom/LoadPciRom.c (revision 64)
++++ LoadPciRom/LoadPciRom.c (working copy)
+@@ -24,7 +24,7 @@
+
+ #include "EfiShellLib.h"
+ #include "LoadPciRom.h"
+-#include "Pci22.h"
++#include "pci22.h"
+
+ extern UINT8 STRING_ARRAY_NAME[];
+
+@@ -56,7 +56,7 @@
+ );
+
+ EFI_HANDLE gMyImageHandle;
+-EFI_HII_HANDLE HiiHandle;
++STATIC EFI_HII_HANDLE HiiHandle;
+ EFI_GUID EfiLoadPciRomGuid = EFI_LOADPCIROM_GUID;
+ SHELL_VAR_CHECK_ITEM LPRCheckList[] = {
+ {
+@@ -81,7 +81,7 @@
+ NULL,
+ 0,
+ 0,
+- 0
++ (SHELL_VAR_CHECK_FLAG_TYPE) 0
+ }
+ };
+
+@@ -377,7 +377,7 @@
+ }
+
+ if (EfiRomHeader->CompressionType == EFI_PCI_EXPANSION_ROM_HEADER_COMPRESSED) {
+- Status = BS->LocateProtocol (&gEfiDecompressProtocolGuid, NULL, &Decompress);
++ Status = BS->LocateProtocol (&gEfiDecompressProtocolGuid, NULL, (VOID**)&Decompress);
+ if (EFI_ERROR (Status)) {
+ PrintToken (STRING_TOKEN (STR_LOADPCIROM_DECOMP_NOT_FOUND), HiiHandle);
+ SkipImage = TRUE;
+Index: ver/ver.h
+===================================================================
+--- ver/ver.h (revision 64)
++++ ver/ver.h (working copy)
+@@ -37,3 +37,4 @@
+ IN EFI_SYSTEM_TABLE *SystemTable
+ );
+ #endif
++
+Index: ver/Ver.inf
+===================================================================
+--- ver/Ver.inf (revision 64)
++++ ver/Ver.inf (working copy)
+@@ -40,33 +40,33 @@
[sources.common]
- ..\ShCommonStrings.uni
+ ../ShCommonStrings.uni
- TimeStrings.uni
- Time.c
- Time.h
+ VerStrings.uni
+ Ver.c
+ Ver.h
+
+-[sources.ia32,sources.x64]
+- ia32\ver32.c
++[sources.ia32,sources.x64,sources.ARM,sources.AARCH64]
++ ia32/ver32.c
+
+ [sources.ipf]
+- ipf\ver64.c
++ IPF/ver64.c
+
+ [sources.ebc]
+- ebc\verEbc.c
++ eb./verEbc.c
[includes.common]
.
@@ -5553,32 +6181,213 @@ index 5181280..5b65e49 100644
[libraries.common]
EfiShellLib
-diff --git a/touch/touch.c b/touch/touch.c
-index 0938d34..a5f61b8 100644
---- a/touch/touch.c
-+++ b/touch/touch.c
-@@ -64,7 +64,7 @@ TouchFreeFileArg (
+Index: ver/Ebc/verEbc.c
+===================================================================
+--- ver/Ebc/verEbc.c (revision 64)
++++ ver/Ebc/verEbc.c (working copy)
+@@ -45,7 +45,7 @@
+ Status = BS->LocateProtocol (
+ &gEfiEbcProtocolGuid,
+ NULL,
+- &Ebc
++ (VOID**)&Ebc
+ );
+ if (EFI_ERROR (Status)) {
+ return ;
+Index: ver/ver.c
+===================================================================
+--- ver/ver.c (revision 64)
++++ ver/ver.c (working copy)
+@@ -57,7 +57,7 @@
+ NULL,
+ 0,
+ 0,
+- 0
++ (SHELL_VAR_CHECK_FLAG_TYPE) 0
+ }
+ };
+
+Index: dmpstore/dmpstore.h
+===================================================================
+--- dmpstore/dmpstore.h (revision 64)
++++ dmpstore/dmpstore.h (working copy)
+@@ -40,3 +40,4 @@
+ } DMPSTORE_VARIABLE;
+
+ #endif
++
+Index: dmpstore/dmpstore.inf
+===================================================================
+--- dmpstore/dmpstore.inf (revision 64)
++++ dmpstore/dmpstore.inf (working copy)
+@@ -25,24 +25,24 @@
+ COMPONENT_TYPE = APPLICATION
+
+ [sources.common]
+- ..\ShCommonStrings.uni
++ ../ShCommonStrings.uni
+ DmpstoreStrings.uni
+ dmpstore.c
+ dmpstore.h
+
+ [includes.common]
+ .
+- ..\Inc
+- ..\Library
+- $(EDK_SOURCE)\Foundation
+- $(EDK_SOURCE)\Foundation\Include
+- $(EDK_SOURCE)\Foundation\Include\IndustryStandard
+- $(EDK_SOURCE)\Foundation\Efi
+- $(EDK_SOURCE)\Foundation\Efi\Include
+- $(EDK_SOURCE)\Foundation\FrameWork
+- $(EDK_SOURCE)\Foundation\FrameWork\Include
+- $(EDK_SOURCE)\Foundation\Core\Dxe
+- $(DEST_DIR)\
++ ../Inc
++ ../Library
++ $(EDK_SOURCE)/Foundation
++ $(EDK_SOURCE)/Foundation/Include
++ $(EDK_SOURCE)/Foundation/Include/IndustryStandard
++ $(EDK_SOURCE)/Foundation/Efi
++ $(EDK_SOURCE)/Foundation/Efi/Include
++ $(EDK_SOURCE)/Foundation/FrameWork
++ $(EDK_SOURCE)/Foundation/FrameWork/Include
++ $(EDK_SOURCE)/Foundation/Core/Dxe
++ $(DEST_DIR./
+
+ [libraries.common]
+ EfiShellLib
+Index: dmpstore/dmpstore.c
+===================================================================
+--- dmpstore/dmpstore.c (revision 64)
++++ dmpstore/dmpstore.c (working copy)
+@@ -95,7 +95,7 @@
//
// Global Variables
//
-EFI_HII_HANDLE HiiHandle;
+STATIC EFI_HII_HANDLE HiiHandle;
- EFI_GUID EfiTouchGuid = EFI_TOUCH_GUID;
- SHELL_VAR_CHECK_ITEM TouchCheckList[] = {
+ EFI_GUID EfiDmpstoreGuid = EFI_DMPSTORE_GUID;
+ SHELL_VAR_CHECK_ITEM DmpstoreCheckList[] = {
{
-diff --git a/touch/touch.inf b/touch/touch.inf
-index 5382ff6..1a89a90 100644
---- a/touch/touch.inf
-+++ b/touch/touch.inf
-@@ -39,23 +39,23 @@ FILE_GUID = 2EBB94E8-3792-47bb-8843-4D5ED5B98F28
+@@ -132,7 +132,7 @@
+ NULL,
+ 0,
+ 0,
+- 0
++ (SHELL_VAR_CHECK_FLAG_TYPE) 0
+ }
+ };
+
+Index: comp/comp.c
+===================================================================
+--- comp/comp.c (revision 64)
++++ comp/comp.c (working copy)
+@@ -50,7 +50,7 @@
+ NULL,
+ 0,
+ 0,
+- 0
++ (SHELL_VAR_CHECK_FLAG_TYPE) 0
+ }
+ };
+
+Index: comp/comp.h
+===================================================================
+--- comp/comp.h (revision 64)
++++ comp/comp.h (working copy)
+@@ -29,4 +29,4 @@
+ 0x7761e2c2, 0x7297, 0x434d, 0xb6, 0x52, 0xa9, 0x76, 0x91, 0xb8, 0x66, 0xf3 \
+ }
+
+-#endif
+\ No newline at end of file
++#endif
+Index: comp/comp.inf
+===================================================================
+--- comp/comp.inf (revision 64)
++++ comp/comp.inf (working copy)
+@@ -28,21 +28,21 @@
+ CompStrings.uni
+ comp.c
+ comp.h
+-..\ShCommonStrings.uni
++../ShCommonStrings.uni
+
+ [includes.common]
+ .
+- ..\Inc
+- ..\Library
+- $(EDK_SOURCE)\Foundation
+- $(EDK_SOURCE)\Foundation\Include
+- $(EDK_SOURCE)\Foundation\Include\IndustryStandard
+- $(EDK_SOURCE)\Foundation\Efi
+- $(EDK_SOURCE)\Foundation\Efi\Include
+- $(EDK_SOURCE)\Foundation\FrameWork
+- $(EDK_SOURCE)\Foundation\FrameWork\Include
+- $(EDK_SOURCE)\Foundation\Core\Dxe
+- $(DEST_DIR)\
++ ../Inc
++ ../Library
++ $(EDK_SOURCE)/Foundation
++ $(EDK_SOURCE)/Foundation/Include
++ $(EDK_SOURCE)/Foundation/Include/IndustryStandard
++ $(EDK_SOURCE)/Foundation/Efi
++ $(EDK_SOURCE)/Foundation/Efi/Include
++ $(EDK_SOURCE)/Foundation/FrameWork
++ $(EDK_SOURCE)/Foundation/FrameWork/Include
++ $(EDK_SOURCE)/Foundation/Core/Dxe
++ $(DEST_DIR./
+
+ [libraries.common]
+ EfiShellLib
+Index: IpConfig/IpConfig.c
+===================================================================
+--- IpConfig/IpConfig.c (revision 64)
++++ IpConfig/IpConfig.c (working copy)
+@@ -39,7 +39,7 @@
+ //
+ // Global Variables
+ //
+-EFI_HII_HANDLE HiiHandle;
++STATIC EFI_HII_HANDLE HiiHandle;
+ EFI_GUID EfiIpConfigGuid = EFI_IPCONFIG_GUID;
+ SHELL_VAR_CHECK_ITEM IpconfigCheckList[] = {
+ {
+@@ -76,7 +76,7 @@
+ NULL,
+ 0,
+ 0,
+- 0
++ (SHELL_VAR_CHECK_FLAG_TYPE) 0
+ }
+ };
+
+Index: IpConfig/IpConfig.h
+===================================================================
+--- IpConfig/IpConfig.h (revision 64)
++++ IpConfig/IpConfig.h (working copy)
+@@ -29,4 +29,4 @@
+ 0x8252915c, 0xf1e9, 0x435c, 0x81, 0x91, 0xad, 0x2f, 0x82, 0x62, 0x23, 0x73 \
+ }
+
+-#endif
+\ No newline at end of file
++#endif
+Index: IpConfig/IpConfig.inf
+===================================================================
+--- IpConfig/IpConfig.inf (revision 64)
++++ IpConfig/IpConfig.inf (working copy)
+@@ -25,24 +25,24 @@
COMPONENT_TYPE = APPLICATION
[sources.common]
- ..\ShCommonStrings.uni
+ ../ShCommonStrings.uni
- TouchStrings.uni
- touch.c
-
+ IpConfigStrings.uni
+ IpConfig.c
+ IpConfig.h
+
[includes.common]
.
- ..\Inc
@@ -5606,33 +6415,69 @@ index 5382ff6..1a89a90 100644
[libraries.common]
EfiShellLib
-diff --git a/type/type.c b/type/type.c
-index 129f911..c3855ef 100644
---- a/type/type.c
-+++ b/type/type.c
-@@ -59,7 +59,7 @@ BOOLEAN TypeAscii;
- BOOLEAN TypeUnicode;
- BOOLEAN TypeAuto;
+Index: sermode/sermode.c
+===================================================================
+--- sermode/sermode.c (revision 64)
++++ sermode/sermode.c (working copy)
+@@ -35,7 +35,7 @@
+
+ #include EFI_PROTOCOL_DEFINITION (SerialIo)
-EFI_HII_HANDLE HiiHandle;
+STATIC EFI_HII_HANDLE HiiHandle;
- EFI_GUID EfiTypeGuid = EFI_TYPE_GUID;
- SHELL_VAR_CHECK_ITEM TypeCheckList[] = {
+ EFI_GUID EfiSermodeGuid = EFI_SERMODEB_GUID;
+ SHELL_VAR_CHECK_ITEM SermodeCheckList[] = {
{
-diff --git a/type/type.inf b/type/type.inf
-index efb0a82..23138c6 100644
---- a/type/type.inf
-+++ b/type/type.inf
-@@ -40,24 +40,24 @@ COMPONENT_TYPE = APPLICATION
+@@ -54,7 +54,7 @@
+ NULL,
+ 0,
+ 0,
+- 0
++ (SHELL_VAR_CHECK_FLAG_TYPE) 0
+ }
+ };
+
+@@ -104,7 +104,7 @@
+
+ }
+
+- Status = BS->HandleProtocol (Handles[Index], &gEfiSerialIoProtocolGuid, &SerialIo);
++ Status = BS->HandleProtocol (Handles[Index], &gEfiSerialIoProtocolGuid, (VOID**)&SerialIo);
+ if (!EFI_ERROR (Status)) {
+ switch (SerialIo->Mode->Parity) {
+ case DefaultParity:
+@@ -454,7 +454,7 @@
+ continue;
+ }
+
+- Status = BS->HandleProtocol (Handles[Index], &gEfiSerialIoProtocolGuid, &SerialIo);
++ Status = BS->HandleProtocol (Handles[Index], &gEfiSerialIoProtocolGuid, (VOID**)&SerialIo);
+ if (!EFI_ERROR (Status)) {
+ Status = SerialIo->SetAttributes (
+ SerialIo,
+Index: sermode/sermode.h
+===================================================================
+--- sermode/sermode.h (revision 64)
++++ sermode/sermode.h (working copy)
+@@ -32,3 +32,4 @@
+ }
+
+ #endif
++
+Index: sermode/sermode.inf
+===================================================================
+--- sermode/sermode.inf (revision 64)
++++ sermode/sermode.inf (working copy)
+@@ -40,24 +40,24 @@
[sources.common]
-- ..\ShCommonStrings.uni
-+ ../ShCommonStrings.uni
- TypeStrings.uni
- type.c
- type.h
-
+- ..\ShCommonStrings.uni
++ ../ShCommonStrings.uni
+ SermodeStrings.uni
+ sermode.c
+ sermode.h
+
[includes.common]
.
- ..\Inc
@@ -5660,11 +6505,40 @@ index efb0a82..23138c6 100644
[libraries.common]
EfiShellLib
-diff --git a/tzone/timezone.inf b/tzone/timezone.inf
-index 57834c6..525a9cb 100644
---- a/tzone/timezone.inf
-+++ b/tzone/timezone.inf
-@@ -25,24 +25,24 @@ FILE_GUID = E27B12B9-2647-4af3-ADBC-B5AB5FB50421
+Index: tzone/tzone.c
+===================================================================
+--- tzone/tzone.c (revision 64)
++++ tzone/tzone.c (working copy)
+@@ -65,7 +65,7 @@
+ NULL,
+ 0,
+ 0,
+- 0
++ (SHELL_VAR_CHECK_FLAG_TYPE) 0
+ }
+ };
+
+@@ -258,7 +258,6 @@
+ BOOLEAN bList;
+ BOOLEAN bSet;
+ INT16 nValue;
+- UINTN uValueSize;
+ SHELL_VAR_CHECK_CODE RetCode;
+ CHAR16 *Useful;
+ SHELL_VAR_CHECK_PACKAGE ChkPck;
+@@ -269,7 +268,6 @@
+ bList = FALSE;
+ bSet = FALSE;
+ nValue = 0;
+- uValueSize = sizeof (INTN);
+ ZeroMem (&ChkPck, sizeof (SHELL_VAR_CHECK_PACKAGE));
+ ZeroMem (&Time, sizeof (EFI_TIME));
+ //
+Index: tzone/timezone.inf
+===================================================================
+--- tzone/timezone.inf (revision 64)
++++ tzone/timezone.inf (working copy)
+@@ -25,24 +25,24 @@
COMPONENT_TYPE = APPLICATION
[sources.common]
@@ -5701,94 +6575,1765 @@ index 57834c6..525a9cb 100644
[libraries.common]
EfiShellLib
-diff --git a/unload/unload.c b/unload/unload.c
-index 100f16b..daeaf05 100644
---- a/unload/unload.c
-+++ b/unload/unload.c
-@@ -110,7 +110,7 @@ _UnloadGetDriverName (
- *DriverName = LibDevicePathToStr (Image->FilePath);
+Index: tzone/tzone.h
+===================================================================
+--- tzone/tzone.h (revision 64)
++++ tzone/tzone.h (working copy)
+@@ -35,3 +35,4 @@
+ }
+
+ #endif
++
+Index: vol/vol.c
+===================================================================
+--- vol/vol.c (revision 64)
++++ vol/vol.c (working copy)
+@@ -32,7 +32,7 @@
+ //
+ #include STRING_DEFINES_FILE
+
+-EFI_HII_HANDLE HiiHandle;
++STATIC EFI_HII_HANDLE HiiHandle;
+ EFI_GUID EfiVolGuid = EFI_VOL_GUID;
+ SHELL_VAR_CHECK_ITEM VolCheckList[] = {
+ {
+@@ -63,7 +63,7 @@
+ NULL,
+ 0,
+ 0,
+- 0
++ (SHELL_VAR_CHECK_FLAG_TYPE) 0
+ }
+ };
+
+Index: vol/vol.h
+===================================================================
+--- vol/vol.h (revision 64)
++++ vol/vol.h (working copy)
+@@ -32,3 +32,4 @@
+ }
+
+ #endif
++
+Index: vol/Vol.inf
+===================================================================
+--- vol/Vol.inf (revision 64)
++++ vol/Vol.inf (working copy)
+@@ -40,24 +40,24 @@
+
+
+ [sources.common]
+- ..\ShCommonStrings.uni
++ ../ShCommonStrings.uni
+ VolStrings.uni
+ Vol.c
+ Vol.h
+
+ [includes.common]
+ .
+- ..\Inc
+- ..\Library
+- $(EDK_SOURCE)\Foundation
+- $(EDK_SOURCE)\Foundation\Include
+- $(EDK_SOURCE)\Foundation\Include\IndustryStandard
+- $(EDK_SOURCE)\Foundation\Efi
+- $(EDK_SOURCE)\Foundation\Efi\Include
+- $(EDK_SOURCE)\Foundation\FrameWork
+- $(EDK_SOURCE)\Foundation\FrameWork\Include
+- $(EDK_SOURCE)\Foundation\Core\Dxe
+- $(DEST_DIR)\
++ ../Inc
++ ../Library
++ $(EDK_SOURCE)/Foundation
++ $(EDK_SOURCE)/Foundation/Include
++ $(EDK_SOURCE)/Foundation/Include/IndustryStandard
++ $(EDK_SOURCE)/Foundation/Efi
++ $(EDK_SOURCE)/Foundation/Efi/Include
++ $(EDK_SOURCE)/Foundation/FrameWork
++ $(EDK_SOURCE)/Foundation/FrameWork/Include
++ $(EDK_SOURCE)/Foundation/Core/Dxe
++ $(DEST_DIR./
+
+ [libraries.common]
+ EfiShellLib
+Index: cp/cp.c
+===================================================================
+--- cp/cp.c (revision 64)
++++ cp/cp.c (working copy)
+@@ -66,7 +66,7 @@
+ NULL,
+ 0,
+ 0,
+- 0
++ (SHELL_VAR_CHECK_FLAG_TYPE) 0
+ }
+ };
+
+@@ -578,7 +578,7 @@
+ //
+ if (SrcArg->Status == EFI_SUCCESS &&
+ (SrcArg->Info->Attribute & EFI_FILE_DIRECTORY) &&
+- (DstArg->Status == EFI_SUCCESS && (DstArg->Info->Attribute & EFI_FILE_DIRECTORY) || DstMustDir && DstHandle)
++ (DstArg->Status == EFI_SUCCESS && ((DstArg->Info->Attribute & EFI_FILE_DIRECTORY) || (DstMustDir && DstHandle)))
+ ) {
+ if (StrCmp (SrcFilePath, DstFilePath) == 0) {
+ PrintToken (STRING_TOKEN (STR_CP_CANNOT_COPY_ITSELF), HiiCpyHandle, L"cp/copy", SrcArg->FullName);
+@@ -592,7 +592,7 @@
+ // we need to compose a full name of dir\file for the source
+ //
+ if (SrcArg->Status == EFI_SUCCESS &&
+- (DstArg->Status == EFI_SUCCESS && (DstArg->Info->Attribute & EFI_FILE_DIRECTORY) || DstMustDir && DstHandle)) {
++ (DstArg->Status == EFI_SUCCESS && ((DstArg->Info->Attribute & EFI_FILE_DIRECTORY) || (DstMustDir && DstHandle)))) {
+ if (DstFullName) {
+ FreePool (DstFullName);
+ }
+@@ -869,7 +869,6 @@
+ EFI_STATUS Status;
+ EFI_FILE_INFO *SrcInfo;
+ EFI_FILE_INFO *DstInfo;
+- EFI_SIMPLE_FILE_SYSTEM_PROTOCOL *DstVol;
+ EFI_FILE_SYSTEM_INFO *DstFsInfo;
+ CHAR16 InputString[10];
+ UINTN BufSize;
+@@ -894,7 +893,6 @@
+ SrcInfo = NULL;
+ DstInfo = NULL;
+ FileInfo = NULL;
+- DstVol = NULL;
+ DstFsInfo = NULL;
+ InputString[0] = 0;
+ BufSize = 0;
+@@ -1789,7 +1787,7 @@
+ //
+ if (SrcArg->Status == EFI_SUCCESS &&
+ !(SrcArg->Info->Attribute & EFI_FILE_DIRECTORY) &&
+- (DstArg->Status == EFI_SUCCESS && (DstArg->Info->Attribute & EFI_FILE_DIRECTORY) || DstDir && DstHandle)
++ (DstArg->Status == EFI_SUCCESS && ((DstArg->Info->Attribute & EFI_FILE_DIRECTORY) || (DstDir && DstHandle)))
+ ) {
+ if (DstFullName) {
+ FreePool (DstFullName);
+Index: cp/cp.h
+===================================================================
+--- cp/cp.h (revision 64)
++++ cp/cp.h (working copy)
+@@ -67,4 +67,5 @@
+ IN EFI_SYSTEM_TABLE *SystemTable
+ );
+
+-#endif
+\ No newline at end of file
++#endif
++
+Index: cp/cp.inf
+===================================================================
+--- cp/cp.inf (revision 64)
++++ cp/cp.inf (working copy)
+@@ -41,23 +41,23 @@
+
+ [sources.common]
+ CpStrings.uni
+- ..\ShCommonStrings.uni
++ ../ShCommonStrings.uni
+ cp.h
+ cp.c
+
+ [includes.common]
+ .
+- ..\Inc
+- ..\Library
+- $(EDK_SOURCE)\Foundation
+- $(EDK_SOURCE)\Foundation\Include
+- $(EDK_SOURCE)\Foundation\Include\IndustryStandard
+- $(EDK_SOURCE)\Foundation\Efi
+- $(EDK_SOURCE)\Foundation\Efi\Include
+- $(EDK_SOURCE)\Foundation\FrameWork
+- $(EDK_SOURCE)\Foundation\FrameWork\Include
+- $(EDK_SOURCE)\Foundation\Core\Dxe
+- $(DEST_DIR)\
++ ../Inc
++ ../Library
++ $(EDK_SOURCE)/Foundation
++ $(EDK_SOURCE)/Foundation/Include
++ $(EDK_SOURCE)/Foundation/Include/IndustryStandard
++ $(EDK_SOURCE)/Foundation/Efi
++ $(EDK_SOURCE)/Foundation/Efi/Include
++ $(EDK_SOURCE)/Foundation/FrameWork
++ $(EDK_SOURCE)/Foundation/FrameWork/Include
++ $(EDK_SOURCE)/Foundation/Core/Dxe
++ $(DEST_DIR./
+
+ [libraries.common]
+ EfiShellLib
+Index: Library/EfiPart.h
+===================================================================
+--- Library/EfiPart.h (revision 64)
++++ Library/EfiPart.h (working copy)
+@@ -56,3 +56,4 @@
+ #pragma pack()
+
+ #endif
++
+Index: Library/X64/efilibplat.h
+===================================================================
+--- Library/X64/efilibplat.h (revision 64)
++++ Library/X64/efilibplat.h (working copy)
+@@ -35,3 +35,4 @@
+ #define MIN_ALIGNMENT_SIZE 8
+
+ #endif
++
+Index: Library/ShellEnvInt.h
+===================================================================
+--- Library/ShellEnvInt.h (revision 64)
++++ Library/ShellEnvInt.h (working copy)
+@@ -196,4 +196,6 @@
+ VOID
+ );
+
+-#endif
+\ No newline at end of file
++#endif
++
++
+Index: Library/LinkedList.h
+===================================================================
+--- Library/LinkedList.h (revision 64)
++++ Library/LinkedList.h (working copy)
+@@ -77,11 +77,10 @@
+ }
+
+ #define SwapListEntries(Entry1, Entry2) { \
+- EFI_LIST_ENTRY *Entry1Flink, *Entry1Blink; \
++ EFI_LIST_ENTRY *Entry1Blink; \
+ EFI_LIST_ENTRY *Entry2Flink, *Entry2Blink; \
+ Entry2Flink = (Entry2)->Flink; \
+ Entry2Blink = (Entry2)->Blink; \
+- Entry1Flink = (Entry1)->Flink; \
+ Entry1Blink = (Entry1)->Blink; \
+ Entry2Blink->Flink = Entry2Flink; \
+ Entry2Flink->Blink = Entry2Blink; \
+@@ -100,3 +99,4 @@
+ // A lock structure
+ //
+ #endif
++
+Index: Library/IO.c
+===================================================================
+--- Library/IO.c (revision 64)
++++ Library/IO.c (working copy)
+@@ -21,7 +21,7 @@
+
+ --*/
+
+-#include "EfiShelllib.h"
++#include "EfiShellLib.h"
+
+ #define PRINT_STRING_LEN 1024
+ #define PRINT_ITEM_BUFFER_LEN 100
+@@ -86,8 +86,8 @@
+ typedef struct {
+ BOOLEAN PageBreak;
+ BOOLEAN AutoWrap;
+- INTN MaxRow;
+- INTN MaxColumn;
++ UINTN MaxRow;
++ UINTN MaxColumn;
+ INTN InitRow;
+ INTN Row;
+ INTN Column;
+@@ -1575,7 +1575,7 @@
+ {
+ BOOLEAN Done;
+ UINTN Column;
+- INTN Row;
++ UINTN Row;
+ UINTN StartColumn;
+ UINTN Update;
+ UINTN Delete;
+@@ -1769,7 +1769,7 @@
+ //
+ // If we need to update the output do so now
+ //
+- if (Update != -1) {
++ if (Update != (UINTN) -1) {
+ PrintAt (Column, Row, L"%s%.*s", InStr + Update, Delete, L"");
+ Len = StrLen (InStr);
+
+@@ -1928,8 +1928,8 @@
+ return mPrintMode.PageBreak;
+ }
+
++#if 0
+ STATIC
+-
+ BOOLEAN
+ GetOutputPause (
+ VOID
+@@ -1937,6 +1937,7 @@
+ {
+ return mPrintMode.OutputPause;
+ }
++#endif
+
+ INTN
+ DbgPrint (
+Index: Library/FileIO.c
+===================================================================
+--- Library/FileIO.c (revision 64)
++++ Library/FileIO.c (working copy)
+@@ -21,7 +21,7 @@
+
+ --*/
+
+-#include "EfiShelllib.h"
++#include "EfiShellLib.h"
+
+ typedef struct _PATH_COMPONENTS {
+ CHAR16 *Name;
+@@ -719,7 +719,6 @@
+ IN OUT CHAR16 **Path
+ )
+ {
+- EFI_STATUS Status;
+ CHAR16 *p;
+ UINTN Size;
+
+@@ -728,7 +727,6 @@
+
+ *Fs = NULL;
+ *Path = NULL;
+- Status = EFI_SUCCESS;
+
+ p = AbPath;
+ while (*p) {
+@@ -1017,13 +1015,11 @@
+ EFI_LIST_ENTRY SrcList;
+ EFI_LIST_ENTRY DstList;
+ EFI_STATUS Status;
+- EFI_LIST_ENTRY *Link;
+ SHELL_FILE_ARG *SrcArg;
+ SHELL_FILE_ARG *DstArg;
+
+ ASSERT (IsSame != NULL);
+
+- Link = NULL;
+ SrcArg = NULL;
+ DstArg = NULL;
+ InitializeListHead (&SrcList);
+Index: Library/Aarch64/efilibplat.h
+===================================================================
+--- Library/Aarch64/efilibplat.h (revision 0)
++++ Library/Aarch64/efilibplat.h (revision 0)
+@@ -0,0 +1,38 @@
++/*++
++
++Copyright (c) 2005, Intel Corporation
++All rights reserved. This program and the accompanying materials
++are licensed and made available under the terms and conditions of the BSD License
++which accompanies this distribution. The full text of the license may be found at
++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:
++
++ efilibplat.h
++
++Abstract:
++
++ EFI to compile bindings
++
++
++
++Revision History
++
++--*/
++
++#ifndef _EFI_LIB_PLAT_H
++#define _EFI_LIB_PLAT_H
++
++VOID
++InitializeLibPlatform (
++ IN EFI_HANDLE ImageHandle,
++ IN EFI_SYSTEM_TABLE *SystemTable
++ );
++
++#define MIN_ALIGNMENT_SIZE 8
++
++#endif
++
+Index: Library/Ebc/EfiLibPlat.h
+===================================================================
+--- Library/Ebc/EfiLibPlat.h (revision 64)
++++ Library/Ebc/EfiLibPlat.h (working copy)
+@@ -44,3 +44,4 @@
+ ;
+
+ #define MIN_ALIGNMENT_SIZE 8
++
+Index: Library/Str.c
+===================================================================
+--- Library/Str.c (revision 64)
++++ Library/Str.c (working copy)
+@@ -22,7 +22,7 @@
+
+ --*/
+
+-#include "EfiShelllib.h"
++#include "EfiShellLib.h"
+
+ INTN
+ StrCmp (
+@@ -421,7 +421,7 @@
+ return (UINTN) -1;
+ }
+
+- u = u << 4 | c - (c >= 'A' ? 'A' - 10 : '0');
++ u = (u << 4) | (c - (c >= 'A' ? 'A' - 10 : '0'));
+ } else {
+ break;
}
- } else {
-- LibGetDriverName(DriverBindingHandle, Language, DriverName);
-+ LibGetDriverName(DriverBindingHandle, (CHAR8*)Language, DriverName);
+@@ -472,7 +472,7 @@
+ c = *(str++);
+ while (c) {
+ if (c >= '0' && c <= '9') {
+- if (u > m || u == m && c - '0' > (INTN) n) {
++ if ((u > m) || ((u == m) && (c - '0' > (INTN) n))) {
+ return (UINTN) -1;
+ }
+
+Index: Library/Data.c
+===================================================================
+--- Library/Data.c (revision 64)
++++ Library/Data.c (working copy)
+@@ -21,7 +21,7 @@
+
+ --*/
+
+-#include "EfiShelllib.h"
++#include "EfiShellLib.h"
+
+ //
+ // ShellLibInitialized - TRUE once InitializeShellLib() is called for the first time
+Index: Library/IO.h
+===================================================================
+--- Library/IO.h (revision 64)
++++ Library/IO.h (working copy)
+@@ -157,4 +157,6 @@
+ );
+
+
+-#endif
+\ No newline at end of file
++#endif
++
++
+Index: Library/FileIO.h
+===================================================================
+--- Library/FileIO.h (revision 64)
++++ Library/FileIO.h (working copy)
+@@ -208,4 +208,6 @@
+ IN SIMPLE_READ_FILE SimpleReadHandle
+ );
+
+-#endif
+\ No newline at end of file
++#endif
++
++
+Index: Library/Str.h
+===================================================================
+--- Library/Str.h (revision 64)
++++ Library/Str.h (working copy)
+@@ -248,3 +248,4 @@
+ );
+
+ #endif
++
+Index: Library/Mem.c
+===================================================================
+--- Library/Mem.c (revision 64)
++++ Library/Mem.c (working copy)
+@@ -21,7 +21,7 @@
+
+ --*/
+
+-#include "EfiShelllib.h"
++#include "EfiShellLib.h"
+
+ VOID
+ SetMem (
+Index: Library/RtData.c
+===================================================================
+--- Library/RtData.c (revision 64)
++++ Library/RtData.c (working copy)
+@@ -21,7 +21,7 @@
+
+ --*/
+
+-#include "EfiShelllib.h"
++#include "EfiShellLib.h"
+
+ //
+ // RT - pointer to the runtime table
+Index: Library/Event.c
+===================================================================
+--- Library/Event.c (revision 64)
++++ Library/Event.c (working copy)
+@@ -21,7 +21,7 @@
+
+ --*/
+
+-#include "EfiShelllib.h"
++#include "EfiShellLib.h"
+
+ EFI_EVENT
+ LibCreateProtocolNotifyEvent (
+Index: Library/Mem.h
+===================================================================
+--- Library/Mem.h (revision 64)
++++ Library/Mem.h (working copy)
+@@ -73,4 +73,6 @@
+ IN UINTN Size
+ );
+
+-#endif
+\ No newline at end of file
++#endif
++
++
+Index: Library/Event.h
+===================================================================
+--- Library/Event.h (revision 64)
++++ Library/Event.h (working copy)
+@@ -50,4 +50,6 @@
+ OUT EFI_INPUT_KEY *Key
+ );
+
+-#endif
+\ No newline at end of file
++#endif
++
++
+Index: Library/EfiShellLib.h
+===================================================================
+--- Library/EfiShellLib.h (revision 64)
++++ Library/EfiShellLib.h (working copy)
+@@ -25,7 +25,7 @@
+ #define _EFI_SHELL_LIB_INCLUDE_
+
+ #include "Tiano.h"
+-#include "ShellEnv.h"
++#include "shellenv.h"
+ #include "pci22.h"
+
+ #include EFI_ARCH_PROTOCOL_DEFINITION (Bds)
+@@ -51,7 +51,7 @@
+ #include EFI_GUID_DEFINITION (PrimaryConsoleOutDevice)
+ #include EFI_GUID_DEFINITION (PrimaryStandardErrorDevice)
+ #include EFI_GUID_DEFINITION (SalSystemTable)
+-#include EFI_GUID_DEFINITION (Smbios)
++#include EFI_GUID_DEFINITION (SmBios)
+ #include EFI_GUID_DEFINITION (StandardErrorDevice)
+ #include EFI_GUID_DEFINITION (FrameworkDevicePath)
+ #include EFI_PROTOCOL_DEFINITION (AbsolutePointer)
+@@ -67,7 +67,7 @@
+ #include EFI_PROTOCOL_DEFINITION (DebugPort)
+ #include EFI_PROTOCOL_DEFINITION (DebugSupport)
+ #include EFI_PROTOCOL_DEFINITION (Decompress)
+-#include EFI_PROTOCOL_DEFINITION (DeviceIO)
++#include EFI_PROTOCOL_DEFINITION (DeviceIo)
+ #include EFI_PROTOCOL_DEFINITION (DevicePath)
+ #include EFI_PROTOCOL_DEFINITION (DevicePathFromText)
+ #include EFI_PROTOCOL_DEFINITION (DevicePathToText)
+@@ -111,7 +111,7 @@
+ #include EFI_PROTOCOL_DEFINITION (PciRootBridgeIo)
+ #include EFI_PROTOCOL_DEFINITION (PlatformDriverOverride)
+ #include EFI_PROTOCOL_DEFINITION (PxeBaseCode)
+-#include EFI_PROTOCOL_DEFINITION (PxeBaseCodeCallback)
++#include EFI_PROTOCOL_DEFINITION (PxeBaseCodeCallBack)
+ #include EFI_PROTOCOL_DEFINITION (ScsiIo)
+ #include EFI_PROTOCOL_DEFINITION (ScsiPassThru)
+ #include EFI_PROTOCOL_DEFINITION (SectionExtraction)
+@@ -152,7 +152,7 @@
+ #include EFI_PROTOCOL_DEFINITION (PlatformToDriverConfiguration)
+
+ #include "efilibplat.h"
+-#include "efipart.h"
++#include "EfiPart.h"
+ #include "ShellDebug.h"
+ #include "CRC.h"
+ #include "DPath.h"
+@@ -358,3 +358,4 @@
+ );
+
+ #endif
++
+Index: Library/Handle.c
+===================================================================
+--- Library/Handle.c (revision 64)
++++ Library/Handle.c (working copy)
+@@ -21,7 +21,7 @@
+
+ --*/
+
+-#include "EfiShelllib.h"
++#include "EfiShellLib.h"
+
+ EFI_STATUS
+ LibLocateHandle (
+@@ -131,7 +131,6 @@
+ EFI_HANDLE *BlockIoBuffer;
+ EFI_DEVICE_PATH_PROTOCOL *DevicePath;
+ UINTN Index;
+- EFI_DEVICE_PATH_PROTOCOL *Start;
+ EFI_DEVICE_PATH_PROTOCOL *Next;
+ EFI_DEVICE_PATH_PROTOCOL *DevPath;
+ HARDDRIVE_DEVICE_PATH *HardDriveDevicePath;
+@@ -204,7 +203,6 @@
+ PreviousNodeIsHardDriveDevicePath = FALSE;
+
+ DevPath = DevicePath;
+- Start = DevPath;
+ //
+ // Check for end of device path type
+ //
+@@ -796,14 +794,12 @@
+ UINTN OpenInfoIndex;
+ UINTN ChildIndex;
+ BOOLEAN DriverBindingHandleIndexValid;
+- BOOLEAN ControllerHandleIndexValid;
+
+ DriverBindingHandleIndexValid = FALSE;
+ if (DriverBindingHandleIndex != NULL) {
+ *DriverBindingHandleIndex = 0xffffffff;
}
- return EFI_SUCCESS;
-@@ -184,7 +184,7 @@ Returns:
+- ControllerHandleIndexValid = FALSE;
+ if (ControllerHandleIndex != NULL) {
+ *ControllerHandleIndex = 0xffffffff;
+ }
+@@ -847,7 +843,6 @@
- DevicePath = NULL;
- BestDeviceName = NULL;
-- Status = BS->HandleProtocol (Handle, &gEfiDevicePathProtocolGuid, &DevicePath);
-+ Status = BS->HandleProtocol (Handle, &gEfiDevicePathProtocolGuid, (VOID**)&DevicePath);
+ if (ControllerHandle != NULL && ControllerHandleIndex != NULL && (*HandleBuffer)[HandleIndex] == ControllerHandle) {
+ *ControllerHandleIndex = (UINT32) HandleIndex;
+- ControllerHandleIndexValid = TRUE;
+ }
- Print (L"\n");
- PrintToken (STRING_TOKEN (STR_UNLOAD_CONTROLLER_NAME), HiiUnloadHandle);
-@@ -242,14 +242,14 @@ Returns:
- Image = FALSE;
- Status = _UnloadGetDriverName (
- DriverBindingHandleBuffer[Index],
-- Language,
-+ (UINT8*)Language,
- FALSE,
- &DriverName
+ }
+@@ -1305,7 +1300,7 @@
+ Status = BS->HandleProtocol (
+ Handles[Index],
+ ProtocolGuid,
+- Interface
++ (VOID**)Interface
);
- if (DriverName == NULL) {
- Status = _UnloadGetDriverName (
- DriverBindingHandleBuffer[Index],
-- Language,
-+ (UINT8*)Language,
- TRUE,
- &DriverName
- );
-@@ -436,7 +436,7 @@ Returns:
- Status = _UnloadGetDriverName (
- Handle,
-- Language,
-+ (UINT8*)Language,
- FALSE,
- &DriverName
- );
-@@ -450,7 +450,7 @@ Returns:
+ if (!EFI_ERROR (Status)) {
+Index: Library/Misc.c
+===================================================================
+--- Library/Misc.c (revision 64)
++++ Library/Misc.c (working copy)
+@@ -21,7 +21,7 @@
- Status = _UnloadGetDriverName (
- Handle,
-- Language,
-+ (UINT8*)Language,
- TRUE,
- &DriverName
- );
-@@ -628,7 +628,7 @@ Returns:
+ --*/
- if (Prot->Handles[Index] == Handle) {
- Dump = Verbose ? Prot->DumpInfo : Prot->DumpToken;
-- Status = BS->HandleProtocol (Handle, &Prot->ProtocolId, &Interface);
-+ Status = BS->HandleProtocol (Handle, &Prot->ProtocolId, (VOID**)&Interface);
- if (!EFI_ERROR (Status)) {
- if (Verbose) {
- for (Index1 = 0; Index1 < ProtocolBufferCount; Index1++) {
-@@ -676,7 +676,7 @@ Returns:
- goto Done;
- }
+-#include "EfiShelllib.h"
++#include "EfiShellLib.h"
-- Status = BS->HandleProtocol (Handle, ProtocolBuffer[Index1], &Interface);
-+ Status = BS->HandleProtocol (Handle, ProtocolBuffer[Index1], (VOID**)&Interface);
+ #if (PLATFORM == NT32)
+ #define LOCAL_EFI_WIN_NT_THUNK_PROTOCOL_GUID \
+@@ -348,7 +348,7 @@
+ ASSERT (Buffer != NULL);
+
+ if (mShellEnv == NULL) {
+- Status = LibLocateProtocol (&ShellEnvProtocol, &mShellEnv);
++ Status = LibLocateProtocol (&ShellEnvProtocol, (VOID**)&mShellEnv);
+ if (EFI_ERROR (Status)) {
+ mShellEnv = NULL;
+ }
+@@ -1171,7 +1171,7 @@
+ Status = BS->HandleProtocol (
+ Image->DeviceHandle,
+ &gEfiFirmwareVolumeProtocolGuid,
+- &FV
++ (VOID**)&FV
+ );
+ if (!EFI_ERROR (Status)) {
+ Status = FV->ReadSection (
+@@ -1192,7 +1192,7 @@
+ Status = BS->HandleProtocol (
+ Image->DeviceHandle,
+ &gEfiFirmwareVolume2ProtocolGuid,
+- &FV2
++ (VOID**)&FV2
+ );
if (!EFI_ERROR (Status)) {
- PrintToken (STRING_TOKEN (STR_UNLOAD_TWO_VARS_HG_NEW), HiiUnloadHandle, ProtocolBuffer[Index1], Interface);
- }
-diff --git a/unload/unload.inf b/unload/unload.inf
-index e91869e..d3475e0 100644
---- a/unload/unload.inf
-+++ b/unload/unload.inf
-@@ -39,23 +39,23 @@ FILE_GUID = 409060F4-3E7B-44cc-9DFD-A8E807474888
+ Status = FV2->ReadSection (
+@@ -1339,7 +1339,7 @@
+ {
+ EFI_STATUS Status;
+ CHAR16 *String;
+- EFI_HII_HANDLE HiiHandle;
++ STATIC EFI_HII_HANDLE HiiHandle;
+
+ ASSERT (Str);
+
+@@ -1730,6 +1730,8 @@
+ return L"X64";
+ case EFI_IMAGE_MACHINE_IA64:
+ return L"IA64";
++ case EFI_IMAGE_MACHINE_AARCH64:
++ return L"AARCH64";
+ default:
+ return L"UNKNOWN";
+ }
+@@ -2544,4 +2546,5 @@
+ }
+
+ return Status;
+-}
+\ No newline at end of file
++}
++
+Index: Library/Perf.c
+===================================================================
+--- Library/Perf.c (revision 64)
++++ Library/Perf.c (working copy)
+@@ -19,7 +19,7 @@
+
+ --*/
+
+-#include "EfiShelllib.h"
++#include "EfiShellLib.h"
+
+ #include EFI_PROTOCOL_DEFINITION (Performance)
+
+Index: Library/IPF/efilibplat.h
+===================================================================
+--- Library/IPF/efilibplat.h (revision 64)
++++ Library/IPF/efilibplat.h (working copy)
+@@ -35,3 +35,4 @@
+ #define MIN_ALIGNMENT_SIZE 8
+
+ #endif
++
+Index: Library/IPF/palproc.h
+===================================================================
+--- Library/IPF/palproc.h (revision 64)
++++ Library/IPF/palproc.h (working copy)
+@@ -58,3 +58,4 @@
+ #define PAL_MC_REGISTER_MEM 0x001b
+
+ #endif // _PALPROC_H
++
+Index: Library/IPF/libsalpal.h
+===================================================================
+--- Library/IPF/libsalpal.h (revision 64)
++++ Library/IPF/libsalpal.h (working copy)
+@@ -74,4 +74,4 @@
+ IN UINT64 Arg8
+ );
+
+-#endif
+\ No newline at end of file
++#endif
+Index: Library/Arm/efilibplat.h
+===================================================================
+--- Library/Arm/efilibplat.h (revision 0)
++++ Library/Arm/efilibplat.h (revision 0)
+@@ -0,0 +1,39 @@
++/*++
++
++Copyright (c) 2005, Intel Corporation
++All rights reserved. This program and the accompanying materials
++are licensed and made available under the terms and conditions of the BSD License
++which accompanies this distribution. The full text of the license may be found at
++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:
++
++ efilibplat.h
++
++Abstract:
++
++ EFI to compile bindings
++
++
++
++
++Revision History
++
++--*/
++#ifndef _EFI_LIB_PLAT_H_
++#define _EFI_LIB_PLAT_H_
++
++VOID
++InitializeLibPlatform (
++ IN EFI_HANDLE ImageHandle,
++ IN EFI_SYSTEM_TABLE *SystemTable
++ );
++
++#define MIN_ALIGNMENT_SIZE 4
++
++#endif
++
++
+Index: Library/ConsistMapping.c
+===================================================================
+--- Library/ConsistMapping.c (revision 64)
++++ Library/ConsistMapping.c (working copy)
+@@ -21,7 +21,7 @@
+
+ --*/
+
+-#include "EfiShelllib.h"
++#include "EfiShellLib.h"
+
+ MTD_NAME mMTDName[] = {
+ {
+Index: Library/DPath.c
+===================================================================
+--- Library/DPath.c (revision 64)
++++ Library/DPath.c (working copy)
+@@ -20,7 +20,7 @@
+
+ --*/
+
+-#include "EfiShelllib.h"
++#include "EfiShellLib.h"
+
+ EFI_GUID mEfiDevicePathMessagingUartFlowControlGuid = DEVICE_PATH_MESSAGING_UART_FLOW_CONTROL;
+
+@@ -1468,7 +1468,7 @@
+
+ Status = LibLocateProtocol (
+ &gEfiDevicePathToTextProtocolGuid,
+- &DevPathToText
++ (VOID**)&DevPathToText
+ );
+ if (!EFI_ERROR (Status)) {
+ ToText = DevPathToText->ConvertDevicePathToText (
+@@ -1766,7 +1766,7 @@
+ Status = BS->HandleProtocol (
+ Device,
+ Protocol,
+- Interface
++ (VOID**)Interface
+ );
+ }
+ }
+Index: Library/Handle.h
+===================================================================
+--- Library/Handle.h (revision 64)
++++ Library/Handle.h (working copy)
+@@ -161,3 +161,4 @@
+ );
+
+ #endif
++
+Index: Library/Misc.h
+===================================================================
+--- Library/Misc.h (revision 64)
++++ Library/Misc.h (working copy)
+@@ -258,3 +258,4 @@
+ );
+
+ #endif
++
+Index: Library/ConsistMapping.h
+===================================================================
+--- Library/ConsistMapping.h (revision 64)
++++ Library/ConsistMapping.h (working copy)
+@@ -79,4 +79,6 @@
+ IN VOID *Buffer2
+ );
+
+-#endif
+\ No newline at end of file
++#endif
++
++
+Index: Library/Init.c
+===================================================================
+--- Library/Init.c (revision 64)
++++ Library/Init.c (working copy)
+@@ -20,7 +20,7 @@
+
+ --*/
+
+-#include "EfiShelllib.h"
++#include "EfiShellLib.h"
+
+ extern EFI_UNICODE_COLLATION_PROTOCOL LibStubUnicodeInterface;
+
+Index: Library/DPath.h
+===================================================================
+--- Library/DPath.h (revision 64)
++++ Library/DPath.h (working copy)
+@@ -24,7 +24,7 @@
+ #ifndef _D_PATH_H
+ #define _D_PATH_H
+
+-#define NextStrA(a) ((UINT8 *) (((UINT8 *) (a)) + strlena (a) + 1))
++#define NextStrA(a) (CHAR8*)((UINT8 *) (((UINT8 *) (a)) + strlena (a) + 1))
+
+ #include EFI_GUID_DEFINITION (PcAnsi)
+
+@@ -153,3 +153,4 @@
+ );
+
+ #endif
++
+Index: Library/HiiSupport.c
+===================================================================
+--- Library/HiiSupport.c (revision 64)
++++ Library/HiiSupport.c (working copy)
+@@ -21,7 +21,7 @@
+
+ --*/
+
+-#include "EfiShelllib.h"
++#include "EfiShellLib.h"
+
+ #if (EFI_SPECIFICATION_VERSION >= 0x0002000A)
+
+@@ -56,11 +56,11 @@
+ return EFI_SUCCESS;
+ }
+
+- Status = LibLocateProtocol (&gEfiHiiDatabaseProtocolGuid, &gLibHiiDatabase);
++ Status = LibLocateProtocol (&gEfiHiiDatabaseProtocolGuid, (VOID**)&gLibHiiDatabase);
+ if (EFI_ERROR (Status)) {
+ return Status;
+ }
+- Status = LibLocateProtocol (&gEfiHiiStringProtocolGuid, &gLibHiiString);
++ Status = LibLocateProtocol (&gEfiHiiStringProtocolGuid, (VOID**)&gLibHiiString);
+ if (EFI_ERROR (Status)) {
+ return Status;
+ }
+Index: Library/CRC.c
+===================================================================
+--- Library/CRC.c (revision 64)
++++ Library/CRC.c (working copy)
+@@ -21,7 +21,7 @@
+
+ --*/
+
+-#include "EfiShelllib.h"
++#include "EfiShellLib.h"
+
+ UINT32 CRCTable[256] = {
+ 0x00000000,
+Index: Library/HiiSupport.h
+===================================================================
+--- Library/HiiSupport.h (revision 64)
++++ Library/HiiSupport.h (working copy)
+@@ -142,3 +142,4 @@
+ ;
+
+ #endif
++
+Index: Library/CRC.h
+===================================================================
+--- Library/CRC.h (revision 64)
++++ Library/CRC.h (working copy)
+@@ -53,4 +53,6 @@
+ UINTN Size
+ );
+
+-#endif
+\ No newline at end of file
++#endif
++
++
+Index: Library/EfiShellLib.inf
+===================================================================
+--- Library/EfiShellLib.inf (revision 64)
++++ Library/EfiShellLib.inf (working copy)
+@@ -45,34 +45,42 @@
+ HiiSupport.c
+
+ [sources.ia32]
+- ia32\math.c
+- ia32\initplat.c
++ IA32/math.c
++ IA32/initplat.c
+
+ [sources.ipf]
+- ipf\math.c
+- ipf\initplat.c
+- ipf\palproc.s
+- ipf\salpal.c
++ IPF/math.c
++ IPF/initplat.c
++ IPF/palproc.s
++ IPF/salpal.c
+
+ [sources.EBC]
+- EBC\math.c
+- EBC\initplat.c
+-
++ Ebc/math.c
++ Ebc/initplat.c
++
+ [sources.x64]
+- ipf\math.c
+- ia32\initplat.c
++ IPF/math.c
++ IA32/initplat.c
+
++[sources.ARM]
++ IPF/math.c
++ IA32/initplat.c
++
++[sources.AARCH64]
++ IPF/math.c
++ IA32/initplat.c
++
+ [includes.common]
+ .
+- ..\Inc
+- $(EDK_SOURCE)\Foundation
+- $(EDK_SOURCE)\Foundation\Include
+- $(EDK_SOURCE)\Foundation\Efi
+- $(EDK_SOURCE)\Foundation\Efi\Include
+- $(EDK_SOURCE)\Foundation\FrameWork
+- $(EDK_SOURCE)\Foundation\FrameWork\Include
+- $(EDK_SOURCE)\Foundation\Include\IndustryStandard
+- $(EDK_SOURCE)\Foundation\Core\Dxe
++ ../Inc
++ $(EDK_SOURCE)/Foundation
++ $(EDK_SOURCE)/Foundation/Include
++ $(EDK_SOURCE)/Foundation/Efi
++ $(EDK_SOURCE)/Foundation/Efi/Include
++ $(EDK_SOURCE)/Foundation/FrameWork
++ $(EDK_SOURCE)/Foundation/FrameWork/Include
++ $(EDK_SOURCE)/Foundation/Include/IndustryStandard
++ $(EDK_SOURCE)/Foundation/Core/Dxe
+
+ [libraries.common]
+ EdkFrameworkProtocolLib
+@@ -81,4 +89,11 @@
+ EfiGuidLib
+ EdkGuidLib
+
++[libraries.ARM]
++ CompilerIntrinsicsLib
++
++[libraries.AARCH64]
++ CompilerIntrinsicsLib
++
++
+ [nmake.common]
+Index: Library/IA32/efilibplat.h
+===================================================================
+--- Library/IA32/efilibplat.h (revision 64)
++++ Library/IA32/efilibplat.h (working copy)
+@@ -34,4 +34,4 @@
+
+ #define MIN_ALIGNMENT_SIZE 4
+
+-#endif
+\ No newline at end of file
++#endif
+Index: Library/ShellDebug.c
+===================================================================
+--- Library/ShellDebug.c (revision 64)
++++ Library/ShellDebug.c (working copy)
+@@ -19,7 +19,7 @@
+
+ --*/
+
+-#include "EfiShelllib.h"
++#include "EfiShellLib.h"
+ #include EFI_PROTOCOL_DEFINITION (DebugAssert)
+
+ EFI_DEBUG_ASSERT_PROTOCOL *mDebugAssert = NULL;
+Index: Library/ShellDebug.h
+===================================================================
+--- Library/ShellDebug.h (revision 64)
++++ Library/ShellDebug.h (working copy)
+@@ -99,3 +99,4 @@
+ );
+ #endif
+
++
+Index: Library/VarCheck.c
+===================================================================
+--- Library/VarCheck.c (revision 64)
++++ Library/VarCheck.c (working copy)
+@@ -21,7 +21,7 @@
+
+ --*/
+
+-#include "EfiShelllib.h"
++#include "EfiShellLib.h"
+
+ VOID
+ LibCheckVarFreeVarList (
+Index: Library/Lock.c
+===================================================================
+--- Library/Lock.c (revision 64)
++++ Library/Lock.c (working copy)
+@@ -21,7 +21,7 @@
+
+ --*/
+
+-#include "EfiShelllib.h"
++#include "EfiShellLib.h"
+
+ VOID
+ InitializeLock (
+Index: Library/ShellEnvInt.c
+===================================================================
+--- Library/ShellEnvInt.c (revision 64)
++++ Library/ShellEnvInt.c (working copy)
+@@ -21,7 +21,7 @@
+
+ --*/
+
+-#include "EfiShelllib.h"
++#include "EfiShellLib.h"
+
+ EFI_STATUS
+ ShellExecute (
+Index: Library/VarCheck.h
+===================================================================
+--- Library/VarCheck.h (revision 64)
++++ Library/VarCheck.h (working copy)
+@@ -41,7 +41,7 @@
+ ARG_PARTIALLY_QUOTED = 0x2,
+ ARG_FIRST_HALF_QUOTED = 0x4,
+ ARG_FIRST_CHAR_IS_ESC = 0x8
+-};
++} SHELL_ARG_EXPR;
+
+ typedef struct {
+ CHAR16 *FlagStr;
+@@ -116,3 +116,4 @@
+ );
+
+ #endif
++
+Index: Library/Lock.h
+===================================================================
+--- Library/Lock.h (revision 64)
++++ Library/Lock.h (working copy)
+@@ -45,4 +45,6 @@
+ IN FLOCK *Lock
+ );
+
+-#endif
+\ No newline at end of file
++#endif
++
++
+Index: ShellFull.inf
+===================================================================
+--- ShellFull.inf (revision 64)
++++ ShellFull.inf (working copy)
+@@ -20,300 +20,310 @@
+ #--*/
+
+ [defines]
+-BASE_NAME = Shell
+-FILE_GUID = c57ad6b7-0515-40a8-9d21-551652854e37
++BASE_NAME = ShellFull
++FILE_GUID = 1903FB23-E526-4BDA-85E4-D68F2EEF0C20
COMPONENT_TYPE = APPLICATION
[sources.common]
+- Library\ShellDebug.c
+- Library\DPath.c
+- Library\Init.c
+- Library\Lock.c
+- Library\Str.c
+- Library\IO.c
+- Library\Mem.c
+- Library\Misc.c
+- Library\Data.c
+- Library\RtData.c
+- Library\ShellEnvInt.c
+- Library\Handle.c
+- Library\FileIO.c
+- Library\ConsistMapping.c
+- Library\CRC.c
+- Library\Event.c
+- Library\Perf.c
+- Library\VarCheck.c
+- Library\HiiSupport.c
++ Library/ShellDebug.c
++ Library/DPath.c
++ Library/Init.c
++ Library/Lock.c
++ Library/Str.c
++ Library/IO.c
++ Library/Mem.c
++ Library/Misc.c
++ Library/Data.c
++ Library/RtData.c
++ Library/ShellEnvInt.c
++ Library/Handle.c
++ Library/FileIO.c
++ Library/ConsistMapping.c
++ Library/CRC.c
++ Library/Event.c
++ Library/Perf.c
++ Library/VarCheck.c
++ Library/HiiSupport.c
+
+- newshell\NshellStrings.uni
+- newshell\init.c
+- newshell\nshell.h
+- newshell\fakehii.c
++ newshell/NshellStrings.uni
++ newshell/init.c
++ newshell/nshell.h
++ newshell/fakehii.c
+
+ ShCommonStrings.uni
+- shellenv\ShellenvHelpStrings.uni
+- shellenv\ShellenvStrings.uni
+- shellenv\ScriptCmdStrings.uni
+- shellenv\ConnectStrings.uni
+- shellenv\EchoStrings.uni
+- shellenv\HelpStrings.uni
+- shellenv\MapStrings.uni
+- shellenv\CdStrings.uni
+- shellenv\DhStrings.uni
++ shellenv/ShellenvHelpStrings.uni
++ shellenv/ShellenvStrings.uni
++ shellenv/ScriptCmdStrings.uni
++ shellenv/ConnectStrings.uni
++ shellenv/EchoStrings.uni
++ shellenv/HelpStrings.uni
++ shellenv/MapStrings.uni
++ shellenv/CdStrings.uni
++ shellenv/DhStrings.uni
+
+- shellenv\cmddisp.c
+- shellenv\connect.c
+- shellenv\data.c
+- shellenv\exec.c
+- shellenv\init.c
+- shellenv\protid.c
+- shellenv\var.c
+- shellenv\conio.c
+- shellenv\consoleproxy.c
+- shellenv\handle.c
+- shellenv\dprot.c
+- shellenv\map.c
+- shellenv\marg.c
+- shellenv\batch.c
+- shellenv\if.c
+- shellenv\goto.c
+- shellenv\echo.c
+- shellenv\pause.c
+- shellenv\for.c
+- shellenv\wait.c
+- shellenv\help.c
+- shellenv\shelle.h
+- shellenv\shellenvguid.h
+- shellenv\parsecmd.c
+- shellenv\shift.c
++ shellenv/cmddisp.c
++ shellenv/connect.c
++ shellenv/data.c
++ shellenv/exec.c
++ shellenv/init.c
++ shellenv/protid.c
++ shellenv/var.c
++ shellenv/conio.c
++ shellenv/consoleproxy.c
++ shellenv/handle.c
++ shellenv/dprot.c
++ shellenv/map.c
++ shellenv/marg.c
++ shellenv/batch.c
++ shellenv/if.c
++ shellenv/goto.c
++ shellenv/echo.c
++ shellenv/pause.c
++ shellenv/for.c
++ shellenv/wait.c
++ shellenv/help.c
++ shellenv/shelle.h
++ shellenv/shellenvguid.h
++ shellenv/parsecmd.c
++ shellenv/shift.c
+
+- unload\UnloadStrings.uni
+- unload\unload.c
++ unload/UnloadStrings.uni
++ unload/unload.c
+
+- attrib\AttribStrings.uni
+- attrib\attrib.c
+- attrib\attrib.h
++ attrib/AttribStrings.uni
++ attrib/attrib.c
++ attrib/attrib.h
+
+- cls\clsstrings.uni
+- cls\cls.c
++ cls/clsstrings.uni
++ cls/cls.c
+
+- cp\CpStrings.uni
+- cp\cp.h
+- cp\cp.c
++ cp/CpStrings.uni
++ cp/cp.h
++ cp/cp.c
+
+- date\DateStrings.uni
+- date\date.c
+- date\date.h
++ date/DateStrings.uni
++ date/date.c
++ date/date.h
+
+- load\LoadStrings.uni
+- load\load.c
+- load\load.h
++ load/LoadStrings.uni
++ load/load.c
++ load/load.h
+
+- ls\LsStrings.uni
+- ls\ls.h
+- ls\ls.c
++ ls/LsStrings.uni
++ ls/ls.h
++ ls/ls.c
+
+- mkdir\MkdirStrings.uni
+- mkdir\mkdir.c
+- mkdir\mkdir.h
++ mkdir/MkdirStrings.uni
++ mkdir/mkdir.c
++ mkdir/mkdir.h
+
+- mv\MvStrings.uni
+- mv\mv.c
+- mv\mv.h
++ mv/MvStrings.uni
++ mv/mv.c
++ mv/mv.h
+
+- reset\ResetStrings.uni
+- reset\reset.c
+- reset\reset.h
++ reset/ResetStrings.uni
++ reset/reset.c
++ reset/reset.h
+
+- rm\RmStrings.uni
+- rm\rm.h
+- rm\rm.c
++ rm/RmStrings.uni
++ rm/rm.h
++ rm/rm.c
+
+- type\TypeStrings.uni
+- type\type.c
+- type\type.h
+- time\TimeStrings.uni
+- time\time.c
+- time\time.h
++ type/TypeStrings.uni
++ type/type.c
++ type/type.h
++ time/TimeStrings.uni
++ time/time.c
++ time/time.h
+
+- touch\TouchStrings.uni
+- touch\touch.c
+- touch\touch.h
++ touch/TouchStrings.uni
++ touch/touch.c
++ touch/touch.h
+
+- vol\VolStrings.uni
+- vol\vol.c
+- vol\vol.h
++ vol/VolStrings.uni
++ vol/vol.c
++ vol/vol.h
+
+- ver\VerStrings.uni
+- ver\ver.c
+- ver\ver.h
++ ver/VerStrings.uni
++ ver/ver.c
++ ver/ver.h
+
+- drivers\driversStrings.uni
+- drivers\drivers.c
+- drivers\drivers.h
++ drivers/driversStrings.uni
++ drivers/drivers.c
++ drivers/drivers.h
+
+- drvcfg\DrvcfgStrings.uni
+- drvcfg\drvcfg.c
+- drvcfg\drvcfg.h
++ drvcfg/DrvcfgStrings.uni
++ drvcfg/drvcfg.c
++ drvcfg/drvcfg.h
+
+- drvdiag\DrvdiagStrings.uni
+- drvdiag\drvdiag.c
+- drvdiag\drvdiag.h
++ drvdiag/DrvdiagStrings.uni
++ drvdiag/drvdiag.c
++ drvdiag/drvdiag.h
+
+- comp\CompStrings.uni
+- comp\comp.c
++ comp/CompStrings.uni
++ comp/comp.c
+
+- dblk\dblkStrings.uni
+- dblk\dblk.c
+- dblk\efidump.c
++ dblk/dblkStrings.uni
++ dblk/dblk.c
++ dblk/efidump.c
+
+- devices\DevicesStrings.uni
+- devices\devices.c
++ devices/DevicesStrings.uni
++ devices/devices.c
+
+- devicetree\DevicetreeStrings.uni
+- devicetree\devicetree.c
++ devicetree/DevicetreeStrings.uni
++ devicetree/devicetree.c
+
+- dmem\MemStrings.uni
+- dmem\DebugStrings.uni
+- dmem\mem.c
+- dmem\MemCommonPart.c
+- dmem\efidump.c
++ dmem/MemStrings.uni
++ dmem/DebugStrings.uni
++ dmem/mem.c
++ dmem/MemCommonPart.c
++ dmem/efidump.c
+
+- dmpstore\DmpstoreStrings.uni
+- dmpstore\dmpstore.c
++ dmpstore/DmpstoreStrings.uni
++ dmpstore/dmpstore.c
+
+- edit\EditStrings.uni
+- edit\main.c
+- edit\libFileBuffer.c
+- edit\libEditor.c
+- edit\libTitleBar.c
+- edit\libStatusBar.c
+- edit\libInputBar.c
+- edit\libMenuBar.c
+- edit\libMisc.c
++ edit/EditStrings.uni
++ edit/main.c
++ edit/libFileBuffer.c
++ edit/libEditor.c
++ edit/libTitleBar.c
++ edit/libStatusBar.c
++ edit/libInputBar.c
++ edit/libMenuBar.c
++ edit/libMisc.c
+
+- eficompress\CompressStrings.uni
+- eficompress\compressMain.c
+- eficompress\compress.c
++ eficompress/CompressStrings.uni
++ eficompress/compressMain.c
++ eficompress/compress.c
+
+- efidecompress\DecompressStrings.uni
+- efidecompress\decompress.c
++ efidecompress/DecompressStrings.uni
++ efidecompress/decompress.c
+
+- err\ErrStrings.uni
+- err\err.c
++ err/ErrStrings.uni
++ err/err.c
+
+- guid\GuidStrings.uni
+- guid\guid.c
++ guid/GuidStrings.uni
++ guid/guid.c
+
+- hexedit\HexeditStrings.uni
+- hexedit\main.c
+- hexedit\libBufferImage.c
+- hexedit\libFileImage.c
+- hexedit\libDiskImage.c
+- hexedit\libMemImage.c
+- hexedit\libEditor.c
+- hexedit\libTitleBar.c
+- hexedit\libStatusBar.c
+- hexedit\libInputBar.c
+- hexedit\libMenuBar.c
+- hexedit\libClipBoard.c
+- hexedit\libMisc.c
++ hexedit/HexeditStrings.uni
++ hexedit/main.c
++ hexedit/libBufferImage.c
++ hexedit/libFileImage.c
++ hexedit/libDiskImage.c
++ hexedit/libMemImage.c
++ hexedit/libEditor.c
++ hexedit/libTitleBar.c
++ hexedit/libStatusBar.c
++ hexedit/libInputBar.c
++ hexedit/libMenuBar.c
++ hexedit/libClipBoard.c
++ hexedit/libMisc.c
+
+- IfConfig\IfConfigStrings.uni
+- IfConfig\IfConfig.c
+- IfConfig\IfConfig.h
+- IfConfig\ShellNetHelper.c
++ IfConfig/IfConfigStrings.uni
++ IfConfig/IfConfig.c
++ IfConfig/IfConfig.h
++ IfConfig/ShellNetHelper.c
+
+- ipconfig\IpConfigStrings.uni
+- ipconfig\IpConfig.c
++ IpConfig/IpConfigStrings.uni
++ IpConfig/IpConfig.c
+
+- loadpcirom\LoadPciRomStrings.uni
+- loadpcirom\LoadPciRom.c
++ loadpcirom/LoadPciRomStrings.uni
++ loadpcirom/LoadPciRom.c
+
+- mem\MemStrings.uni
+- mem\DebugStrings.uni
+- mem\mm.c
+- mem\MemCommonPart.c
+- mem\efidump.c
++ mem/MemStrings.uni
++ mem/DebugStrings.uni
++ mem/mm.c
++ mem/MemCommonPart.c
++ mem/efidump.c
+
+- memmap\memmapStrings.uni
+- memmap\memmap.c
++ memmap/memmapStrings.uni
++ memmap/memmap.c
+
+- mm\MmStrings.uni
+- mm\mm.c
++ mm/MmStrings.uni
++ mm/mm.c
+
+- mode\ModeStrings.uni
+- mode\mode.c
++ mode/ModeStrings.uni
++ mode/mode.c
+
+- mount\MountStrings.uni
+- mount\mount.c
++ mount/MountStrings.uni
++ mount/mount.c
+
+- openinfo\OPeninfoStrings.uni
+- openinfo\openinfo.c
++ openinfo/OPeninfoStrings.uni
++ openinfo/openinfo.c
+
+- Ping\PingStrings.uni
+- Ping\Ping.c
++ Ping/PingStrings.uni
++ Ping/Ping.c
+
+- pci\PciStrings.uni
+- pci\pci.c
+- pci\pci_class.c
++ pci/PciStrings.uni
++ pci/pci.c
++ pci/pci_class.c
+
+- sermode\SermodeStrings.uni
+- sermode\sermode.c
++ sermode/SermodeStrings.uni
++ sermode/sermode.c
+
+- smbiosview\SmBiosViewStrings.uni
+- smbiosview\QueryTable.c
+- smbiosview\EventLogInfo.c
+- smbiosview\PrintInfo.c
+- smbiosview\LibSmbiosView.c
+- smbiosview\smbiosview.c
+- smbiosview\smbios.c
++ smbiosview/SmBiosViewStrings.uni
++ smbiosview/QueryTable.c
++ smbiosview/EventLogInfo.c
++ smbiosview/PrintInfo.c
++ smbiosview/LibSmbiosView.c
++ smbiosview/smbiosview.c
++ smbiosview/smbios.c
+
+- stall\stallStrings.uni
+- stall\stall.c
++ stall/stallStrings.uni
++ stall/stall.c
+
+- telnetmgmt\TelnetMgmtStrings.uni
+- telnetmgmt\TelnetMgmt.c
++ telnetmgmt/TelnetMgmtStrings.uni
++ telnetmgmt/TelnetMgmt.c
+
+- tzone\TZoneStrings.uni
+- tzone\tzone.c
++ tzone/TZoneStrings.uni
++ tzone/tzone.c
+
+ [sources.ia32]
+- ver\ia32\ver32.c
+- Library\ia32\math.c
+- Library\ia32\initplat.c
++ ver/IA32/ver32.c
++ Library/IA32/math.c
++ Library/IA32/initplat.c
+
+ [sources.ipf]
+- ver\ipf\ver64.c
+- Library\ipf\math.c
+- Library\ipf\initplat.c
+- Library\ipf\palproc.s
+- Library\ipf\salpal.c
++ ver/IPF/ver64.c
++ Library/IPF/math.c
++ Library/IPF/initplat.c
++ Library/IPF/palproc.s
++ Library/IPF/salpal.c
+
+ [sources.EBC]
+- ver\ebc\verEbc.c
+- Library\EBC\math.c
+- Library\EBC\initplat.c
++ ver/ebc/verEbc.c
++ Library/Ebc/math.c
++ Library/Ebc/initplat.c
+
+ [sources.x64]
+- ver\ia32\ver32.c
+- Library\ipf\math.c
+- Library\ia32\initplat.c
++ ver/IA32/ver32.c
++ Library/IPF/math.c
++ Library/IA32/initplat.c
+
++[sources.ARM]
++ ver/ia32/ver32.c
++ Library/IPF/math.c
++ Library/IA32/initplat.c
++
++[sources.AARCH64]
++ ver/ia32/ver32.c
++ Library/IPF/math.c
++ Library/IA32/initplat.c
++
+ [includes.common]
+ .
+- .\Inc
+- .\ver
+- .\Library
+- $(EDK_SOURCE)\Foundation
+- $(EDK_SOURCE)\Foundation\Include
+- $(EDK_SOURCE)\Foundation\Include\IndustryStandard
+- $(EDK_SOURCE)\Foundation\Efi
+- $(EDK_SOURCE)\Foundation\Efi\Include
+- $(EDK_SOURCE)\Foundation\FrameWork
+- $(EDK_SOURCE)\Foundation\FrameWork\Include
+- $(EDK_SOURCE)\Foundation\Core\Dxe
+- $(EDK_SOURCE)\Foundation\Library\Dxe\Include
++ ./Inc
++ ./ver
++ ./Library
++ $(EDK_SOURCE)/Foundation
++ $(EDK_SOURCE)/Foundation/Include
++ $(EDK_SOURCE)/Foundation/Include/IndustryStandard
++ $(EDK_SOURCE)/Foundation/Efi
++ $(EDK_SOURCE)/Foundation/Efi/Include
++ $(EDK_SOURCE)/Foundation/FrameWork
++ $(EDK_SOURCE)/Foundation/FrameWork/Include
++ $(EDK_SOURCE)/Foundation/Core/Dxe
++ $(EDK_SOURCE)/Foundation/Library/Dxe/Include
+ $(DEST_DIR)
+
+ [libraries.common]
+@@ -353,4 +363,4 @@
+ EBC_C_STD_FLAGS = $(EBC_C_STD_FLAGS) /DSTRING_DEFINES_FILE=\"$(BASE_NAME)StrDefs.h\"
+
+
+-
+\ No newline at end of file
++
+Index: inc/shelltypes.h
+===================================================================
+--- inc/shelltypes.h (revision 64)
++++ inc/shelltypes.h (working copy)
+@@ -36,7 +36,7 @@
+ #endif
+
+ #include "Tiano.h"
+-#include "linkedlist.h"
++#include "LinkedList.h"
+
+ #include EFI_PROTOCOL_DEFINITION (FileInfo)
+ #include EFI_PROTOCOL_DEFINITION (SimpleFileSystem)
+@@ -183,3 +183,4 @@
+ #endif
+
+ #endif
++
+Index: inc/shellenv.h
+===================================================================
+--- inc/shellenv.h (revision 64)
++++ inc/shellenv.h (working copy)
+@@ -492,3 +492,4 @@
+ #endif
+
+ #endif // _SHELLENV_H_
++
+Index: mm/mm.h
+===================================================================
+--- mm/mm.h (revision 64)
++++ mm/mm.h (working copy)
+@@ -33,3 +33,4 @@
+ }
+
+ #endif
++
+Index: mm/mm.inf
+===================================================================
+--- mm/mm.inf (revision 64)
++++ mm/mm.inf (working copy)
+@@ -41,23 +41,23 @@
+
+ [sources.common]
+ MmStrings.uni
- ..\ShCommonStrings.uni
+ ../ShCommonStrings.uni
- UnloadStrings.uni
- unload.c
-
+ mm.c
+ mm.h
+
[includes.common]
.
- ..\Inc
@@ -5816,46 +8361,190 @@ index e91869e..d3475e0 100644
[libraries.common]
EfiShellLib
-diff --git a/ver/Ebc/verEbc.c b/ver/Ebc/verEbc.c
-index 1d7368d..9518e14 100644
---- a/ver/Ebc/verEbc.c
-+++ b/ver/Ebc/verEbc.c
-@@ -45,7 +45,7 @@ DisplayExtendedVersionInfo (
- Status = BS->LocateProtocol (
- &gEfiEbcProtocolGuid,
- NULL,
-- &Ebc
-+ (VOID**)&Ebc
- );
- if (EFI_ERROR (Status)) {
- return ;
-diff --git a/ver/Ver.inf b/ver/Ver.inf
-index 56a135d..574a297 100644
---- a/ver/Ver.inf
-+++ b/ver/Ver.inf
-@@ -40,33 +40,33 @@ COMPONENT_TYPE = APPLICATION
+Index: mm/mm.c
+===================================================================
+--- mm/mm.c (revision 64)
++++ mm/mm.c (working copy)
+@@ -49,18 +49,18 @@
+ VOID
+ ReadMem (
+- IN EFI_IO_WIDTH Width,
+- IN UINT64 Address,
+- IN UINTN Size,
+- IN VOID *Buffer
++ IN EFI_PCI_ROOT_BRIDGE_IO_PROTOCOL_WIDTH Width,
++ IN UINT64 Address,
++ IN UINTN Size,
++ IN VOID *Buffer
+ );
- [sources.common]
-- ..\ShCommonStrings.uni
-+ ../ShCommonStrings.uni
- VerStrings.uni
- Ver.c
- Ver.h
-
--[sources.ia32,sources.x64]
-- ia32\ver32.c
-+[sources.ia32,sources.x64,sources.ARM]
-+ ia32/ver32.c
+ VOID
+ WriteMem (
+- IN EFI_IO_WIDTH Width,
+- IN UINT64 Address,
+- IN UINTN Size,
+- IN VOID *Buffer
++ IN EFI_PCI_ROOT_BRIDGE_IO_PROTOCOL_WIDTH Width,
++ IN UINT64 Address,
++ IN UINTN Size,
++ IN VOID *Buffer
+ );
- [sources.ipf]
-- ipf\ver64.c
-+ IPF/ver64.c
+ STATIC
+@@ -73,7 +73,7 @@
+ //
+ // Global Variables
+ //
+-EFI_HII_HANDLE HiiHandle;
++STATIC EFI_HII_HANDLE HiiHandle;
+ EFI_GUID EfiIomodGuid = EFI_IOMOD_GUID;
+ SHELL_VAR_CHECK_ITEM IomodCheckList[] = {
+ {
+@@ -134,7 +134,7 @@
+ NULL,
+ 0,
+ 0,
+- 0
++ (SHELL_VAR_CHECK_FLAG_TYPE) 0
+ }
+ };
- [sources.ebc]
-- ebc\verEbc.c
-+ eb./verEbc.c
-
+@@ -146,13 +146,13 @@
+
+ EFI_STATUS
+ OldShellParserMM (
+- OUT EFI_IO_WIDTH *Width,
+- OUT EFI_ACCESS_TYPE *AccessType,
+- OUT UINT64 *Address,
+- OUT UINT64 *Value,
+- OUT UINTN *Size,
+- OUT BOOLEAN *Interactive,
+- OUT CHAR16 **ValueStr
++ OUT EFI_PCI_ROOT_BRIDGE_IO_PROTOCOL_WIDTH *Width,
++ OUT EFI_ACCESS_TYPE *AccessType,
++ OUT UINT64 *Address,
++ OUT UINT64 *Value,
++ OUT UINTN *Size,
++ OUT BOOLEAN *Interactive,
++ OUT CHAR16 **ValueStr
+ );
+
+ EFI_STATUS
+@@ -207,12 +207,11 @@
+ UINT64 PciEAddress;
+ UINT64 Value;
+ UINT32 SegmentNumber;
+- EFI_IO_WIDTH Width;
++ EFI_PCI_ROOT_BRIDGE_IO_PROTOCOL_WIDTH Width;
+ EFI_ACCESS_TYPE AccessType;
+ UINT64 Buffer;
+ UINTN Index;
+ UINTN Size;
+- CHAR16 *AddressStr;
+ CHAR16 *ValueStr;
+ BOOLEAN Complete;
+ CHAR16 InputStr[80];
+@@ -261,7 +260,7 @@
+ if (IS_OLD_SHELL) {
+ Status = OldShellParserMM (&Width, &AccessType, &Address, &Value, &Size, &Interactive, &ValueStr);
+ if (EFI_ERROR (Status)) {
+- if (-1 == Status) {
++ if ((EFI_STATUS)-1 == Status) {
+ PrintToken (STRING_TOKEN (STR_HELPINFO_MM_VERBOSEHELP), HiiHandle);
+ Status = EFI_SUCCESS;
+ }
+@@ -274,7 +273,6 @@
+ Width = EfiPciWidthUint8;
+ Size = 1;
+ AccessType = EfiMemory;
+- AddressStr = NULL;
+ ValueStr = NULL;
+ Interactive = TRUE;
+
+@@ -662,10 +660,10 @@
+
+ VOID
+ ReadMem (
+- IN EFI_IO_WIDTH Width,
+- IN UINT64 Address,
+- IN UINTN Size,
+- IN VOID *Buffer
++ IN EFI_PCI_ROOT_BRIDGE_IO_PROTOCOL_WIDTH Width,
++ IN UINT64 Address,
++ IN UINTN Size,
++ IN VOID *Buffer
+ )
+ {
+ do {
+@@ -694,10 +692,10 @@
+
+ VOID
+ WriteMem (
+- IN EFI_IO_WIDTH Width,
+- IN UINT64 Address,
+- IN UINTN Size,
+- IN VOID *Buffer
++ IN EFI_PCI_ROOT_BRIDGE_IO_PROTOCOL_WIDTH Width,
++ IN UINT64 Address,
++ IN UINTN Size,
++ IN VOID *Buffer
+ )
+ {
+ do {
+@@ -750,7 +748,7 @@
+ }
+
+ if ((c >= '0' && c <= '9') || (c >= 'A' && c <= 'F')) {
+- u = u << 4 | c - (c >= 'A' ? 'A' - 10 : '0');
++ u = (u << 4) | (c - (c >= 'A' ? 'A' - 10 : '0'));
+
+ Find = TRUE;
+ } else {
+@@ -766,13 +764,13 @@
+
+ EFI_STATUS
+ OldShellParserMM (
+- OUT EFI_IO_WIDTH *Width,
+- OUT EFI_ACCESS_TYPE *AccessType,
+- OUT UINT64 *Address,
+- OUT UINT64 *Value,
+- OUT UINTN *Size,
+- OUT BOOLEAN *Interactive,
+- OUT CHAR16 **ValueStr
++ OUT EFI_PCI_ROOT_BRIDGE_IO_PROTOCOL_WIDTH *Width,
++ OUT EFI_ACCESS_TYPE *AccessType,
++ OUT UINT64 *Address,
++ OUT UINT64 *Value,
++ OUT UINTN *Size,
++ OUT BOOLEAN *Interactive,
++ OUT CHAR16 **ValueStr
+ )
+ /*++
+
+Index: drvcfg/drvcfg.h
+===================================================================
+--- drvcfg/drvcfg.h (revision 64)
++++ drvcfg/drvcfg.h (working copy)
+@@ -33,3 +33,4 @@
+ }
+
+ #endif
++
+Index: drvcfg/drvcfg.inf
+===================================================================
+--- drvcfg/drvcfg.inf (revision 64)
++++ drvcfg/drvcfg.inf (working copy)
+@@ -40,24 +40,24 @@
+
+
+ [sources.common]
+- ..\ShCommonStrings.uni
++ ../ShCommonStrings.uni
+ DrvcfgStrings.uni
+ drvcfg.c
+ drvcfg.h
+
[includes.common]
.
- ..\Inc
@@ -5883,20 +8572,51 @@ index 56a135d..574a297 100644
[libraries.common]
EfiShellLib
-diff --git a/vol/Vol.inf b/vol/Vol.inf
-index 71d2cb5..c05ddaf 100644
---- a/vol/Vol.inf
-+++ b/vol/Vol.inf
-@@ -40,24 +40,24 @@ COMPONENT_TYPE = APPLICATION
+Index: drvcfg/drvcfg.c
+===================================================================
+--- drvcfg/drvcfg.c (revision 64)
++++ drvcfg/drvcfg.c (working copy)
+@@ -38,7 +38,7 @@
+ //
+ // Global Variables
+ //
+-EFI_HII_HANDLE HiiHandle;
++STATIC EFI_HII_HANDLE HiiHandle;
+ EFI_GUID EfiDrvcfgGuid = EFI_DRVCFG_GUID;
+ SHELL_VAR_CHECK_ITEM DrvcfgCheckList[] = {
+ {
+@@ -87,7 +87,7 @@
+ NULL,
+ 0,
+ 0,
+- 0
++ (SHELL_VAR_CHECK_FLAG_TYPE) 0
+ }
+ };
+Index: openinfo/openinfo.h
+===================================================================
+--- openinfo/openinfo.h (revision 64)
++++ openinfo/openinfo.h (working copy)
+@@ -33,3 +33,4 @@
+ }
+
+ #endif
++
+Index: openinfo/openinfo.inf
+===================================================================
+--- openinfo/openinfo.inf (revision 64)
++++ openinfo/openinfo.inf (working copy)
+@@ -41,24 +41,24 @@
[sources.common]
-- ..\ShCommonStrings.uni
-+ ../ShCommonStrings.uni
- VolStrings.uni
- Vol.c
- Vol.h
-
+ OPeninfoStrings.uni
+- ..\ShCommonStrings.uni
++ ../ShCommonStrings.uni
+ openinfo.c
+ openinfo.h
+
+
[includes.common]
.
- ..\Inc
@@ -5924,16 +8644,114 @@ index 71d2cb5..c05ddaf 100644
[libraries.common]
EfiShellLib
-diff --git a/vol/vol.c b/vol/vol.c
-index 47a4de0..13be9fb 100644
---- a/vol/vol.c
-+++ b/vol/vol.c
-@@ -32,7 +32,7 @@ extern UINT8 STRING_ARRAY_NAME[];
+Index: openinfo/openinfo.c
+===================================================================
+--- openinfo/openinfo.c (revision 64)
++++ openinfo/openinfo.c (working copy)
+@@ -36,7 +36,7 @@
//
- #include STRING_DEFINES_FILE
+ // Global Variables
+ //
+-EFI_HII_HANDLE HiiHandle;
++STATIC EFI_HII_HANDLE HiiHandle;
+ EFI_GUID EfiOpeninfoGuid = EFI_OPENINFO_GUID;
+ SHELL_VAR_CHECK_ITEM OpeninfoCheckList[] = {
+ {
+@@ -55,7 +55,7 @@
+ NULL,
+ 0,
+ 0,
+- 0
++ (SHELL_VAR_CHECK_FLAG_TYPE) 0
+ }
+ };
+Index: drivers/drivers.c
+===================================================================
+--- drivers/drivers.c (revision 64)
++++ drivers/drivers.c (working copy)
+@@ -43,7 +43,7 @@
+ //
+ // Global Variables
+ //
-EFI_HII_HANDLE HiiHandle;
+STATIC EFI_HII_HANDLE HiiHandle;
- EFI_GUID EfiVolGuid = EFI_VOL_GUID;
- SHELL_VAR_CHECK_ITEM VolCheckList[] = {
+ EFI_GUID EfiDriversGuid = EFI_DRIVERS_GUID;
+ SHELL_VAR_CHECK_ITEM DriversCheckList[] = {
{
+@@ -68,7 +68,7 @@
+ NULL,
+ 0,
+ 0,
+- 0
++ (SHELL_VAR_CHECK_FLAG_TYPE) 0
+ }
+ };
+
+@@ -133,7 +133,6 @@
+ EFI_HANDLE *ControllerHandleBuffer;
+ UINTN ChildControllerHandleCount;
+ CHAR16 *ImageName;
+- BOOLEAN IsHelp;
+ SHELL_VAR_CHECK_CODE RetCode;
+ CHAR16 *Useful;
+ SHELL_ARG_LIST *Item;
+@@ -143,7 +142,6 @@
+ Language = NULL;
+ DriverImageHandleCount = 0;
+ DriverImageHandleBuffer = NULL;
+- IsHelp = FALSE;
+ ZeroMem (&ChkPck, sizeof (SHELL_VAR_CHECK_PACKAGE));
+
+ EFI_SHELL_APP_INIT (ImageHandle, SystemTable);
+Index: drivers/drivers.h
+===================================================================
+--- drivers/drivers.h (revision 64)
++++ drivers/drivers.h (working copy)
+@@ -33,3 +33,4 @@
+ }
+
+ #endif
++
+Index: drivers/drivers.inf
+===================================================================
+--- drivers/drivers.inf (revision 64)
++++ drivers/drivers.inf (working copy)
+@@ -40,7 +40,7 @@
+
+
+ [sources.common]
+- ..\ShCommonStrings.uni
++ ../ShCommonStrings.uni
+ DriversStrings.uni
+ drivers.c
+ drivers.h
+@@ -48,17 +48,17 @@
+
+ [includes.common]
+ .
+- ..\Inc
+- ..\Library
+- $(EDK_SOURCE)\Foundation
+- $(EDK_SOURCE)\Foundation\Include
+- $(EDK_SOURCE)\Foundation\Include\IndustryStandard
+- $(EDK_SOURCE)\Foundation\Efi
+- $(EDK_SOURCE)\Foundation\Efi\Include
+- $(EDK_SOURCE)\Foundation\FrameWork
+- $(EDK_SOURCE)\Foundation\FrameWork\Include
+- $(EDK_SOURCE)\Foundation\Core\Dxe
+- $(DEST_DIR)\
++ ../Inc
++ ../Library
++ $(EDK_SOURCE)/Foundation
++ $(EDK_SOURCE)/Foundation/Include
++ $(EDK_SOURCE)/Foundation/Include/IndustryStandard
++ $(EDK_SOURCE)/Foundation/Efi
++ $(EDK_SOURCE)/Foundation/Efi/Include
++ $(EDK_SOURCE)/Foundation/FrameWork
++ $(EDK_SOURCE)/Foundation/FrameWork/Include
++ $(EDK_SOURCE)/Foundation/Core/Dxe
++ $(DEST_DIR./
+
+ [libraries.common]
+ EfiShellLib
diff --git a/EmbeddedPkg/Universal/MmcDxe/Diagnostics.c b/EmbeddedPkg/Universal/MmcDxe/Diagnostics.c
index 516c832bb..14035afb1 100644
--- a/EmbeddedPkg/Universal/MmcDxe/Diagnostics.c
+++ b/EmbeddedPkg/Universal/MmcDxe/Diagnostics.c
@@ -17,6 +17,7 @@
#include <Library/DebugLib.h>
#include <Library/BaseMemoryLib.h>
#include <Library/MemoryAllocationLib.h>
+#include <Library/BaseLib.h>
#include "Mmc.h"
@@ -31,7 +32,7 @@ DiagnosticInitLog (
)
{
mLogRemainChar = MaxBufferChar;
- mLogBuffer = AllocatePool ((UINTN)MaxBufferChar * sizeof(CHAR16));
+ mLogBuffer = AllocatePool ((UINTN)MaxBufferChar * sizeof (CHAR16));
return mLogBuffer;
}
@@ -79,8 +80,8 @@ CompareBuffer (
for (i = 0; i < (BufferSize >> 3); i++) {
if (*BufferA64 != *BufferB64) {
- DEBUG((EFI_D_ERROR, "CompareBuffer: Error at %i", i));
- DEBUG((EFI_D_ERROR, "(0x%lX) != (0x%lX)\n", *BufferA64, *BufferB64));
+ DEBUG ((EFI_D_ERROR, "CompareBuffer: Error at %i", i));
+ DEBUG ((EFI_D_ERROR, "(0x%lX) != (0x%lX)\n", *BufferA64, *BufferB64));
return FALSE;
}
BufferA64++;
@@ -192,6 +193,11 @@ MmcDriverDiagnosticsRunDiagnostics (
return EFI_INVALID_PARAMETER;
}
+ // Check Language is supported (i.e. is "en-*" - only English is supported)
+ if (AsciiStrnCmp (Language, "en", 2) != 0) {
+ return EFI_UNSUPPORTED;
+ }
+
Status = EFI_SUCCESS;
*ErrorType = NULL;
*BufferSize = DIAGNOSTIC_LOGBUFFER_MAXCHAR;
@@ -202,8 +208,8 @@ MmcDriverDiagnosticsRunDiagnostics (
// For each MMC instance
CurrentLink = mMmcHostPool.ForwardLink;
while (CurrentLink != NULL && CurrentLink != &mMmcHostPool && (Status == EFI_SUCCESS)) {
- MmcHostInstance = MMC_HOST_INSTANCE_FROM_LINK(CurrentLink);
- ASSERT(MmcHostInstance != NULL);
+ MmcHostInstance = MMC_HOST_INSTANCE_FROM_LINK (CurrentLink);
+ ASSERT (MmcHostInstance != NULL);
// LBA=1 Size=BlockSize
DiagnosticLog (L"MMC Driver Diagnostics - Test: First Block\n");
diff --git a/EmbeddedPkg/Universal/MmcDxe/MmcBlockIo.c b/EmbeddedPkg/Universal/MmcDxe/MmcBlockIo.c
index a846accf1..82b3e54bb 100644
--- a/EmbeddedPkg/Universal/MmcDxe/MmcBlockIo.c
+++ b/EmbeddedPkg/Universal/MmcDxe/MmcBlockIo.c
@@ -14,50 +14,50 @@
#include <Library/BaseMemoryLib.h>
#include <Library/TimerLib.h>
-#include <Library/UefiBootServicesTableLib.h>
+#include <Library/UefiBootServicesTableLib.h>
#include "Mmc.h"
#define MAX_RETRY_COUNT 1000
#define CMD_RETRY_COUNT 20
-#define TPL_FIRMWARE_INTERRUPTS ((EFI_TPL)((int) TPL_NOTIFY + 1))
-#define TPL_FOR_MMC_BLOCK_IO TPL_FIRMWARE_INTERRUPTS
-
-EFI_TPL
-CurrentTpl() {
- const EFI_TPL Current = gBS->RaiseTPL(TPL_HIGH_LEVEL) ;
- gBS->RestoreTPL(Current) ;
- return Current ;
-}
-
-EFI_TPL
-RaiseTplIfLow() {
- EFI_TPL Current = CurrentTpl() ;
- /*
- UEFI Spec states:
- TPL_CALLBACK Interrupts code executing below TPL_CALLBACK level. Long
- term operations (such as file system operations and disk I/O) can occur
- at this level.
- TPL_NOTIFY Interrupts code executing below TPL_NOTIFY level. Blocking is
- not allowed at this level. Code executes to completion and returns. If
- code requires more processing, it needs to signal an event to wait to
- obtain control again at whatever level it requires. This level is
- typically used to process low level IO to or from a device.
- (Firmware Interrupts) This level is internal to the firmware . It is the
- level at which internal interrupts occur. Code running at this level
- interrupts code running at the TPL_NOTIFY level (or lower levels). If
- the interrupt requires extended time to complete, firmware signals
- another event (or events) to perform the longer term operations so that
- other interrupts can occur.
- */
- if (Current < TPL_FOR_MMC_BLOCK_IO) {
- Current = gBS->RaiseTPL(TPL_FOR_MMC_BLOCK_IO) ;
- }
- return Current ;
-}
-
-
+#define TPL_FIRMWARE_INTERRUPTS ((EFI_TPL)((int) TPL_NOTIFY + 1))
+#define TPL_FOR_MMC_BLOCK_IO TPL_FIRMWARE_INTERRUPTS
+
+EFI_TPL
+CurrentTpl() {
+ const EFI_TPL Current = gBS->RaiseTPL(TPL_HIGH_LEVEL) ;
+ gBS->RestoreTPL(Current) ;
+ return Current ;
+}
+
+EFI_TPL
+RaiseTplIfLow() {
+ EFI_TPL Current = CurrentTpl() ;
+ /*
+ UEFI Spec states:
+ TPL_CALLBACK Interrupts code executing below TPL_CALLBACK level. Long
+ term operations (such as file system operations and disk I/O) can occur
+ at this level.
+ TPL_NOTIFY Interrupts code executing below TPL_NOTIFY level. Blocking is
+ not allowed at this level. Code executes to completion and returns. If
+ code requires more processing, it needs to signal an event to wait to
+ obtain control again at whatever level it requires. This level is
+ typically used to process low level IO to or from a device.
+ (Firmware Interrupts) This level is internal to the firmware . It is the
+ level at which internal interrupts occur. Code running at this level
+ interrupts code running at the TPL_NOTIFY level (or lower levels). If
+ the interrupt requires extended time to complete, firmware signals
+ another event (or events) to perform the longer term operations so that
+ other interrupts can occur.
+ */
+ if (Current < TPL_FOR_MMC_BLOCK_IO) {
+ Current = gBS->RaiseTPL(TPL_FOR_MMC_BLOCK_IO) ;
+ }
+ return Current ;
+}
+
+
EFI_STATUS
MmcNotifyState (
IN MMC_HOST_INSTANCE *MmcHostInstance,
@@ -446,7 +446,7 @@ MmcIoBlocks (
EFI_MMC_HOST_PROTOCOL *MmcHost;
UINTN BytesRemainingToBeTransfered;
UINTN BlockCount;
- EFI_TPL Tpl;
+ EFI_TPL Tpl;
BlockCount = 1;
MmcHostInstance = MMC_HOST_INSTANCE_FROM_BLOCK_IO_THIS (This);
@@ -526,11 +526,11 @@ MmcIoBlocks (
// Write a single block
Cmd = MMC_CMD24;
}
- // Raise Tpl to protect against Timer events between command and block IO
- Tpl = RaiseTplIfLow() ;
+ // Raise Tpl to protect against Timer events between command and block IO
+ Tpl = RaiseTplIfLow() ;
Status = MmcHost->SendCommand (MmcHost, Cmd, CmdArg);
if (EFI_ERROR (Status)) {
- gBS->RestoreTPL(Tpl);
+ gBS->RestoreTPL(Tpl);
DEBUG ((EFI_D_ERROR, "MmcIoBlocks(MMC_CMD%d): Error %r\n", Cmd, Status));
return Status;
}
@@ -538,7 +538,7 @@ MmcIoBlocks (
if (Transfer == MMC_IOBLOCKS_READ) {
// Read one block of Data
Status = MmcHost->ReadBlockData (MmcHost, Lba, This->Media->BlockSize, Buffer);
- gBS->RestoreTPL(Tpl) ;
+ gBS->RestoreTPL(Tpl) ;
if (EFI_ERROR (Status)) {
DEBUG ((EFI_D_BLKIO, "MmcIoBlocks(): Error Read Block Data and Status = %r\n", Status));
MmcStopTransmission (MmcHost);
diff --git a/IntelFrameworkModulePkg/Library/DxeCapsuleLib/DxeCapsuleLib.c b/IntelFrameworkModulePkg/Library/DxeCapsuleLib/DxeCapsuleLib.c
index 6f5ab5b0f..04db1a4f6 100644
--- a/IntelFrameworkModulePkg/Library/DxeCapsuleLib/DxeCapsuleLib.c
+++ b/IntelFrameworkModulePkg/Library/DxeCapsuleLib/DxeCapsuleLib.c
@@ -1,7 +1,7 @@
/** @file
- Capsule Library instance to update capsule image to flash.
+ Capsule Library instance to process capsule images.
- Copyright (c) 2007 - 2010, Intel Corporation. All rights reserved.<BR>
+ Copyright (c) 2007 - 2013, 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
@@ -13,12 +13,368 @@
**/
#include <PiDxe.h>
+
#include <Guid/Capsule.h>
+#include <Guid/FmpCapsule.h>
+
#include <Library/DebugLib.h>
#include <Library/BaseMemoryLib.h>
#include <Library/DxeServicesTableLib.h>
#include <Library/MemoryAllocationLib.h>
#include <Library/CapsuleLib.h>
+#include <Library/GenericBdsLib.h>
+#include <Library/UefiBootServicesTableLib.h>
+#include <Library/BaseLib.h>
+#include <Library/DevicePathLib.h>
+
+#include <Protocol/FirmwareManagement.h>
+#include <Protocol/DevicePath.h>
+
+
+/**
+ Function indicate the current completion progress of the firmware
+ update. Platform may override with own specific progress function.
+
+ @param Completion A value between 1 and 100 indicating the current completion progress of the firmware update
+
+ @retval EFI_SUCESS Input capsule is a correct FMP capsule.
+**/
+EFI_STATUS
+EFIAPI
+Update_Image_Progress (
+ IN UINTN Completion
+)
+{
+ return EFI_SUCCESS;
+}
+
+
+/**
+ Validate Fmp capsules layout.
+
+ @param CapsuleHeader Points to a capsule header.
+
+ @retval EFI_SUCESS Input capsule is a correct FMP capsule.
+ @retval EFI_INVALID_PARAMETER Input capsule is not a correct FMP capsule.
+**/
+EFI_STATUS
+ValidateFmpCapsule (
+ IN EFI_CAPSULE_HEADER *CapsuleHeader
+ )
+{
+ EFI_FIRMWARE_MANAGEMENT_CAPSULE_HEADER *FmpCapsuleHeader;
+ UINT8 *EndOfCapsule;
+ EFI_FIRMWARE_MANAGEMENT_CAPSULE_IMAGE_HEADER *ImageHeader;
+ UINT8 *EndOfPayload;
+ UINT64 *ItemOffsetList;
+ UINT32 ItemNum;
+ UINTN Index;
+
+ FmpCapsuleHeader = (EFI_FIRMWARE_MANAGEMENT_CAPSULE_HEADER *) ((UINT8 *) CapsuleHeader + CapsuleHeader->HeaderSize);
+ EndOfCapsule = (UINT8 *) CapsuleHeader + CapsuleHeader->CapsuleImageSize;
+
+ if (FmpCapsuleHeader->Version > EFI_FIRMWARE_MANAGEMENT_CAPSULE_HEADER_INIT_VERSION) {
+ return EFI_INVALID_PARAMETER;
+ }
+ ItemOffsetList = (UINT64 *)(FmpCapsuleHeader + 1);
+
+ ItemNum = FmpCapsuleHeader->EmbeddedDriverCount + FmpCapsuleHeader->PayloadItemCount;
+
+ if (ItemNum == FmpCapsuleHeader->EmbeddedDriverCount) {
+ //
+ // No payload element
+ //
+ if (((UINT8 *)FmpCapsuleHeader + ItemOffsetList[ItemNum - 1]) < EndOfCapsule) {
+ return EFI_SUCCESS;
+ } else {
+ return EFI_INVALID_PARAMETER;
+ }
+ }
+
+ if (FmpCapsuleHeader->PayloadItemCount != 0) {
+ //
+ // Check if the last payload is within capsule image range
+ //
+ ImageHeader = (EFI_FIRMWARE_MANAGEMENT_CAPSULE_IMAGE_HEADER *)((UINT8 *)FmpCapsuleHeader + ItemOffsetList[ItemNum - 1]);
+ EndOfPayload = (UINT8 *)(ImageHeader + 1) + ImageHeader->UpdateImageSize + ImageHeader->UpdateVendorCodeSize;
+ } else {
+ //
+ // No driver & payload element in FMP
+ //
+ EndOfPayload = (UINT8 *)(FmpCapsuleHeader + 1);
+ }
+
+ if (EndOfPayload != EndOfCapsule) {
+ return EFI_INVALID_PARAMETER;
+ }
+
+ //
+ // All the address in ItemOffsetList must be stored in ascending order
+ //
+ if (ItemNum >= 2) {
+ for (Index = 0; Index < ItemNum - 1; Index++) {
+ if (ItemOffsetList[Index] >= ItemOffsetList[Index + 1]) {
+ return EFI_INVALID_PARAMETER;
+ }
+ }
+ }
+
+ return EFI_SUCCESS;
+}
+
+/**
+ Process Firmware management protocol data capsule.
+
+ @param CapsuleHeader Points to a capsule header.
+
+ @retval EFI_SUCESS Process Capsule Image successfully.
+ @retval EFI_UNSUPPORTED Capsule image is not supported by the firmware.
+ @retval EFI_VOLUME_CORRUPTED FV volume in the capsule is corrupted.
+ @retval EFI_OUT_OF_RESOURCES Not enough memory.
+**/
+EFI_STATUS
+ProcessFmpCapsuleImage (
+ IN EFI_CAPSULE_HEADER *CapsuleHeader
+ )
+{
+ EFI_STATUS Status;
+ EFI_FIRMWARE_MANAGEMENT_CAPSULE_HEADER *FmpCapsuleHeader;
+ UINT8 *EndOfCapsule;
+ EFI_FIRMWARE_MANAGEMENT_CAPSULE_IMAGE_HEADER *ImageHeader;
+ EFI_HANDLE ImageHandle;
+ UINT64 *ItemOffsetList;
+ UINT32 ItemNum;
+ UINTN Index;
+ UINTN ExitDataSize;
+ EFI_HANDLE *HandleBuffer;
+ EFI_FIRMWARE_MANAGEMENT_PROTOCOL *Fmp;
+ UINTN NumberOfHandles;
+ UINTN DescriptorSize;
+ UINT8 FmpImageInfoCount;
+ UINT32 FmpImageInfoDescriptorVer;
+ UINTN ImageInfoSize;
+ UINT32 PackageVersion;
+ CHAR16 *PackageVersionName;
+ CHAR16 *AbortReason;
+ EFI_FIRMWARE_IMAGE_DESCRIPTOR *FmpImageInfoBuf;
+ EFI_FIRMWARE_IMAGE_DESCRIPTOR *TempFmpImageInfo;
+ UINTN DriverLen;
+ UINTN Index1;
+ UINTN Index2;
+ MEMMAP_DEVICE_PATH MemMapNode;
+ EFI_DEVICE_PATH_PROTOCOL *DriverDevicePath;
+
+ Status = EFI_SUCCESS;
+ HandleBuffer = NULL;
+ ExitDataSize = 0;
+ DriverDevicePath = NULL;
+
+ FmpCapsuleHeader = (EFI_FIRMWARE_MANAGEMENT_CAPSULE_HEADER *) ((UINT8 *) CapsuleHeader + CapsuleHeader->HeaderSize);
+ EndOfCapsule = (UINT8 *) CapsuleHeader + CapsuleHeader->CapsuleImageSize;
+
+ if (FmpCapsuleHeader->Version > EFI_FIRMWARE_MANAGEMENT_CAPSULE_HEADER_INIT_VERSION) {
+ return EFI_INVALID_PARAMETER;
+ }
+ ItemOffsetList = (UINT64 *)(FmpCapsuleHeader + 1);
+
+ ItemNum = FmpCapsuleHeader->EmbeddedDriverCount + FmpCapsuleHeader->PayloadItemCount;
+
+ //
+ // capsule in which driver count and payload count are both zero is not processed.
+ //
+ if (ItemNum == 0) {
+ return EFI_SUCCESS;
+ }
+
+ //
+ // 1. ConnectAll to ensure
+ // All the communication protocol required by driver in capsule installed
+ // All FMP protocols are installed
+ //
+ BdsLibConnectAll();
+
+
+ //
+ // 2. Try to load & start all the drivers within capsule
+ //
+ SetDevicePathNodeLength (&MemMapNode.Header, sizeof (MemMapNode));
+ MemMapNode.Header.Type = HARDWARE_DEVICE_PATH;
+ MemMapNode.Header.SubType = HW_MEMMAP_DP;
+ MemMapNode.MemoryType = EfiBootServicesCode;
+ MemMapNode.StartingAddress = (EFI_PHYSICAL_ADDRESS)(UINTN)CapsuleHeader;
+ MemMapNode.EndingAddress = (EFI_PHYSICAL_ADDRESS)(UINTN)((UINT8 *)CapsuleHeader + CapsuleHeader->CapsuleImageSize - 1);
+
+ DriverDevicePath = AppendDevicePathNode (NULL, &MemMapNode.Header);
+ if (DriverDevicePath == NULL) {
+ return EFI_OUT_OF_RESOURCES;
+ }
+
+ for (Index = 0; Index < FmpCapsuleHeader->EmbeddedDriverCount; Index++) {
+ if (FmpCapsuleHeader->PayloadItemCount == 0 && Index == (UINTN)FmpCapsuleHeader->EmbeddedDriverCount - 1) {
+ //
+ // When driver is last element in the ItemOffsetList array, the driver size is calculated by reference CapsuleImageSize in EFI_CAPSULE_HEADER
+ //
+ DriverLen = CapsuleHeader->CapsuleImageSize - CapsuleHeader->HeaderSize - (UINTN)ItemOffsetList[Index];
+ } else {
+ DriverLen = (UINTN)ItemOffsetList[Index + 1] - (UINTN)ItemOffsetList[Index];
+ }
+
+ Status = gBS->LoadImage(
+ FALSE,
+ gImageHandle,
+ DriverDevicePath,
+ (UINT8 *)FmpCapsuleHeader + ItemOffsetList[Index],
+ DriverLen,
+ &ImageHandle
+ );
+ if (EFI_ERROR(Status)) {
+ goto EXIT;
+ }
+
+ Status = gBS->StartImage(
+ ImageHandle,
+ &ExitDataSize,
+ NULL
+ );
+ if (EFI_ERROR(Status)) {
+ DEBUG ((DEBUG_ERROR, "Driver Return Status = %r\n", Status));
+ goto EXIT;
+ }
+ }
+
+ //
+ // Connnect all again to connect drivers within capsule
+ //
+ if (FmpCapsuleHeader->EmbeddedDriverCount > 0) {
+ BdsLibConnectAll();
+ }
+
+ //
+ // 3. Route payload to right FMP instance
+ //
+ Status = gBS->LocateHandleBuffer (
+ ByProtocol,
+ &gEfiFirmwareManagementProtocolGuid,
+ NULL,
+ &NumberOfHandles,
+ &HandleBuffer
+ );
+
+ if (!EFI_ERROR(Status)) {
+ for(Index1 = 0; Index1 < NumberOfHandles; Index1++) {
+ Status = gBS->HandleProtocol(
+ HandleBuffer[Index1],
+ &gEfiFirmwareManagementProtocolGuid,
+ (VOID **)&Fmp
+ );
+ if (EFI_ERROR(Status)) {
+ continue;
+ }
+
+ ImageInfoSize = 0;
+ Status = Fmp->GetImageInfo (
+ Fmp,
+ &ImageInfoSize,
+ NULL,
+ NULL,
+ NULL,
+ NULL,
+ NULL,
+ NULL
+ );
+ if (Status != EFI_BUFFER_TOO_SMALL) {
+ continue;
+ }
+
+ FmpImageInfoBuf = NULL;
+ FmpImageInfoBuf = AllocateZeroPool (ImageInfoSize);
+ if (FmpImageInfoBuf == NULL) {
+ Status = EFI_OUT_OF_RESOURCES;
+ goto EXIT;
+ }
+
+ PackageVersionName = NULL;
+ Status = Fmp->GetImageInfo (
+ Fmp,
+ &ImageInfoSize, // ImageInfoSize
+ FmpImageInfoBuf, // ImageInfo
+ &FmpImageInfoDescriptorVer, // DescriptorVersion
+ &FmpImageInfoCount, // DescriptorCount
+ &DescriptorSize, // DescriptorSize
+ &PackageVersion, // PackageVersion
+ &PackageVersionName // PackageVersionName
+ );
+
+ //
+ // If FMP GetInformation interface failed, skip this resource
+ //
+ if (EFI_ERROR(Status)) {
+ FreePool(FmpImageInfoBuf);
+ continue;
+ }
+
+ if (PackageVersionName != NULL) {
+ FreePool(PackageVersionName);
+ }
+
+ TempFmpImageInfo = FmpImageInfoBuf;
+ for (Index2 = 0; Index2 < FmpImageInfoCount; Index2++) {
+ //
+ // Check all the payload entry in capsule payload list
+ //
+ for (Index = FmpCapsuleHeader->EmbeddedDriverCount; Index < ItemNum; Index++) {
+ ImageHeader = (EFI_FIRMWARE_MANAGEMENT_CAPSULE_IMAGE_HEADER *)((UINT8 *)FmpCapsuleHeader + ItemOffsetList[Index]);
+ if (CompareGuid(&ImageHeader->UpdateImageTypeId, &TempFmpImageInfo->ImageTypeId) &&
+ ImageHeader->UpdateImageIndex == TempFmpImageInfo->ImageIndex) {
+ AbortReason = NULL;
+ if (ImageHeader->UpdateVendorCodeSize == 0) {
+ Status = Fmp->SetImage(
+ Fmp,
+ TempFmpImageInfo->ImageIndex, // ImageIndex
+ (UINT8 *)(ImageHeader + 1), // Image
+ ImageHeader->UpdateImageSize, // ImageSize
+ NULL, // VendorCode
+ Update_Image_Progress, // Progress
+ &AbortReason // AbortReason
+ );
+ } else {
+ Status = Fmp->SetImage(
+ Fmp,
+ TempFmpImageInfo->ImageIndex, // ImageIndex
+ (UINT8 *)(ImageHeader + 1), // Image
+ ImageHeader->UpdateImageSize, // ImageSize
+ (UINT8 *)((UINT8 *) (ImageHeader + 1) + ImageHeader->UpdateImageSize), // VendorCode
+ Update_Image_Progress, // Progress
+ &AbortReason // AbortReason
+ );
+ }
+ if (AbortReason != NULL) {
+ DEBUG ((EFI_D_ERROR, "%s\n", AbortReason));
+ FreePool(AbortReason);
+ }
+ }
+ }
+ //
+ // Use DescriptorSize to move ImageInfo Pointer to stay compatible with different ImageInfo version
+ //
+ TempFmpImageInfo = (EFI_FIRMWARE_IMAGE_DESCRIPTOR *)((UINT8 *)TempFmpImageInfo + DescriptorSize);
+ }
+ FreePool(FmpImageInfoBuf);
+ }
+ }
+
+EXIT:
+
+ if (HandleBuffer != NULL) {
+ FreePool(HandleBuffer);
+ }
+
+ if (DriverDevicePath != NULL) {
+ FreePool(DriverDevicePath);
+ }
+
+ return Status;
+}
/**
Those capsules supported by the firmwares.
@@ -27,6 +383,7 @@
@retval EFI_SUCESS Input capsule is supported by firmware.
@retval EFI_UNSUPPORTED Input capsule is not supported by the firmware.
+ @retval EFI_INVALID_PARAMETER Input capsule layout is not correct
**/
EFI_STATUS
EFIAPI
@@ -38,6 +395,13 @@ SupportCapsuleImage (
return EFI_SUCCESS;
}
+ if (CompareGuid (&gEfiFmpCapsuleGuid, &CapsuleHeader->CapsuleGuid)) {
+ //
+ // Check layout of FMP capsule
+ //
+ return ValidateFmpCapsule(CapsuleHeader);
+ }
+
return EFI_UNSUPPORTED;
}
@@ -73,6 +437,21 @@ ProcessCapsuleImage (
}
//
+ // Check FMP capsule layout
+ //
+ if (CompareGuid (&gEfiFmpCapsuleGuid, &CapsuleHeader->CapsuleGuid)){
+ Status = ValidateFmpCapsule(CapsuleHeader);
+ if (EFI_ERROR(Status)) {
+ return Status;
+ }
+
+ //
+ // Press EFI FMP Capsule
+ //
+ return ProcessFmpCapsuleImage(CapsuleHeader);
+ }
+
+ //
// Skip the capsule header, move to the Firware Volume
//
FvImage = (EFI_FIRMWARE_VOLUME_HEADER *) ((UINT8 *) CapsuleHeader + CapsuleHeader->HeaderSize);
diff --git a/IntelFrameworkModulePkg/Library/DxeCapsuleLib/DxeCapsuleLib.inf b/IntelFrameworkModulePkg/Library/DxeCapsuleLib/DxeCapsuleLib.inf
index c11d8f762..ab66a6814 100644
--- a/IntelFrameworkModulePkg/Library/DxeCapsuleLib/DxeCapsuleLib.inf
+++ b/IntelFrameworkModulePkg/Library/DxeCapsuleLib/DxeCapsuleLib.inf
@@ -1,7 +1,7 @@
## @file
# Capsule library instance for DXE_DRIVER, DXE_RUNTIME_DRIVER
#
-# Copyright (c) 2007 - 2011, Intel Corporation. All rights reserved.<BR>
+# Copyright (c) 2007 - 2013, 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
@@ -33,15 +33,22 @@
[Packages]
MdePkg/MdePkg.dec
- IntelFrameworkPkg/IntelFrameworkPkg.dec
MdeModulePkg/MdeModulePkg.dec
+ IntelFrameworkPkg/IntelFrameworkPkg.dec
+ IntelFrameworkModulePkg/IntelFrameworkModulePkg.dec
[LibraryClasses]
BaseMemoryLib
DebugLib
MemoryAllocationLib
DxeServicesTableLib
+ GenericBdsLib
+ UefiBootServicesTableLib
+ DevicePathLib
+
+[Protocols]
+ gEfiFirmwareManagementProtocolGuid # CONSUMES
[Guids]
gEfiCapsuleGuid # SOMETIMES_CONSUMED
- \ No newline at end of file
+ gEfiFmpCapsuleGuid # SOMETIMES_CONSUMED
diff --git a/IntelFrameworkModulePkg/Library/GenericBdsLib/BdsBoot.c b/IntelFrameworkModulePkg/Library/GenericBdsLib/BdsBoot.c
index 06ba0fcf7..29afe45f3 100644
--- a/IntelFrameworkModulePkg/Library/GenericBdsLib/BdsBoot.c
+++ b/IntelFrameworkModulePkg/Library/GenericBdsLib/BdsBoot.c
@@ -2637,17 +2637,16 @@ BdsExpandPartitionPartialDevicePathToFull (
TempNewDevicePath = CachedDevicePath;
CachedDevicePath = BdsLibDelPartMatchInstance (CachedDevicePath, BlockIoDevicePath);
FreePool(TempNewDevicePath);
+ }
- TempNewDevicePath = CachedDevicePath;
- CachedDevicePath = AppendDevicePathInstance (BlockIoDevicePath, CachedDevicePath);
- if (TempNewDevicePath != NULL) {
- FreePool(TempNewDevicePath);
- }
- } else {
+ if (CachedDevicePath != NULL) {
TempNewDevicePath = CachedDevicePath;
CachedDevicePath = AppendDevicePathInstance (BlockIoDevicePath, CachedDevicePath);
FreePool(TempNewDevicePath);
+ } else {
+ CachedDevicePath = DuplicateDevicePath (BlockIoDevicePath);
}
+
//
// Here limit the device path instance number to 12, which is max number for a system support 3 IDE controller
// If the user try to boot many OS in different HDs or partitions, in theory,
diff --git a/IntelFrameworkModulePkg/Library/GenericBdsLib/GenericBdsLib.inf b/IntelFrameworkModulePkg/Library/GenericBdsLib/GenericBdsLib.inf
index 545709c6e..2fb9916aa 100644
--- a/IntelFrameworkModulePkg/Library/GenericBdsLib/GenericBdsLib.inf
+++ b/IntelFrameworkModulePkg/Library/GenericBdsLib/GenericBdsLib.inf
@@ -22,7 +22,7 @@
FILE_GUID = e405ec31-ccaa-4dd4-83e8-0aec01703f7e
MODULE_TYPE = DXE_DRIVER
VERSION_STRING = 1.0
- LIBRARY_CLASS = GenericBdsLib|DXE_DRIVER UEFI_APPLICATION
+ LIBRARY_CLASS = GenericBdsLib|DXE_DRIVER DXE_RUNTIME_DRIVER UEFI_APPLICATION
CONSTRUCTOR = GenericBdsLibConstructor
#
@@ -78,6 +78,7 @@
gLastEnumLangGuid ## SOMETIMES_PRODUCES ## Variable:L"LastEnumLang" (Platform language at last time enumeration.)
gHdBootDevicePathVariablGuid ## SOMETIMES_PRODUCES ## Variable:L"HDDP" (The device path of Boot file on Hard device.)
gBdsLibStringPackageGuid ## PRODUCES ## GUID (HII String PackageList Guid)
+ gEfiLegacyDevOrderVariableGuid ## CONSUMES ## GUID
[Protocols]
gEfiSimpleFileSystemProtocolGuid # PROTOCOL CONSUMES
diff --git a/IntelFrameworkModulePkg/Universal/Acpi/AcpiSupportDxe/AcpiSupport.h b/IntelFrameworkModulePkg/Universal/Acpi/AcpiSupportDxe/AcpiSupport.h
index b28f1cd19..1bcf1e6ee 100644
--- a/IntelFrameworkModulePkg/Universal/Acpi/AcpiSupportDxe/AcpiSupport.h
+++ b/IntelFrameworkModulePkg/Universal/Acpi/AcpiSupportDxe/AcpiSupport.h
@@ -2,7 +2,7 @@
This is an implementation of the ACPI Support protocol.
It is in compliance with the 0.9 definition of the protocol.
-Copyright (c) 2006 - 2010, Intel Corporation. All rights reserved.<BR>
+Copyright (c) 2006 - 2013, Intel Corporation. All rights reserved.<BR>
This program and the accompanying materials
are licensed and made available under the terms and conditions
@@ -80,15 +80,6 @@ typedef struct {
#define EFI_ACPI_MAX_NUM_TABLES 20
//
-// ACPI table information used to initialize tables.
-//
-#define EFI_ACPI_OEM_ID "INTEL "
-#define EFI_ACPI_OEM_TABLE_ID 0x2020204F4E414954ULL // "TIANO "
-#define EFI_ACPI_OEM_REVISION 0x00000002
-#define EFI_ACPI_CREATOR_ID 0x20202020
-#define EFI_ACPI_CREATOR_REVISION 0x01000013
-
-//
// Protocol private structure definition
//
//
diff --git a/IntelFrameworkModulePkg/Universal/Acpi/AcpiSupportDxe/AcpiSupportAcpiSupportProtocol.c b/IntelFrameworkModulePkg/Universal/Acpi/AcpiSupportDxe/AcpiSupportAcpiSupportProtocol.c
index 107db88ed..3bcff22dc 100644
--- a/IntelFrameworkModulePkg/Universal/Acpi/AcpiSupportDxe/AcpiSupportAcpiSupportProtocol.c
+++ b/IntelFrameworkModulePkg/Universal/Acpi/AcpiSupportDxe/AcpiSupportAcpiSupportProtocol.c
@@ -1,7 +1,7 @@
/** @file
ACPI Support Protocol implementation
-Copyright (c) 2006 - 2012, Intel Corporation. All rights reserved.<BR>
+Copyright (c) 2006 - 2013, Intel Corporation. All rights reserved.<BR>
This program and the accompanying materials
are licensed and made available under the terms and conditions
@@ -1839,13 +1839,13 @@ AcpiSupportAcpiSupportConstructor (
//
CurrentData = EFI_ACPI_1_0_ROOT_SYSTEM_DESCRIPTION_POINTER_SIGNATURE;
CopyMem (&AcpiSupportInstance->Rsdp1->Signature, &CurrentData, sizeof (UINT64));
- CopyMem (AcpiSupportInstance->Rsdp1->OemId, EFI_ACPI_OEM_ID, 6);
+ CopyMem (AcpiSupportInstance->Rsdp1->OemId, PcdGetPtr (PcdAcpiDefaultOemId), sizeof (AcpiSupportInstance->Rsdp1->OemId));
AcpiSupportInstance->Rsdp1->Reserved = EFI_ACPI_RESERVED_BYTE;
AcpiSupportInstance->Rsdp1->RsdtAddress = (UINT32) (UINTN) AcpiSupportInstance->Rsdt1;
CurrentData = EFI_ACPI_3_0_ROOT_SYSTEM_DESCRIPTION_POINTER_SIGNATURE;
CopyMem (&AcpiSupportInstance->Rsdp3->Signature, &CurrentData, sizeof (UINT64));
- CopyMem (AcpiSupportInstance->Rsdp3->OemId, EFI_ACPI_OEM_ID, 6);
+ CopyMem (AcpiSupportInstance->Rsdp3->OemId, PcdGetPtr (PcdAcpiDefaultOemId), sizeof (AcpiSupportInstance->Rsdp3->OemId));
AcpiSupportInstance->Rsdp3->Revision = EFI_ACPI_3_0_ROOT_SYSTEM_DESCRIPTION_POINTER_REVISION;
AcpiSupportInstance->Rsdp3->RsdtAddress = (UINT32) (UINTN) AcpiSupportInstance->Rsdt3;
AcpiSupportInstance->Rsdp3->Length = sizeof (EFI_ACPI_3_0_ROOT_SYSTEM_DESCRIPTION_POINTER);
@@ -1863,12 +1863,12 @@ AcpiSupportAcpiSupportConstructor (
AcpiSupportInstance->Rsdt1->Signature = EFI_ACPI_1_0_ROOT_SYSTEM_DESCRIPTION_TABLE_SIGNATURE;
AcpiSupportInstance->Rsdt1->Length = sizeof (EFI_ACPI_DESCRIPTION_HEADER);
AcpiSupportInstance->Rsdt1->Revision = EFI_ACPI_1_0_ROOT_SYSTEM_DESCRIPTION_TABLE_REVISION;
- CopyMem (AcpiSupportInstance->Rsdt1->OemId, EFI_ACPI_OEM_ID, 6);
- CurrentData = EFI_ACPI_OEM_TABLE_ID;
+ CopyMem (AcpiSupportInstance->Rsdt1->OemId, PcdGetPtr (PcdAcpiDefaultOemId), sizeof (AcpiSupportInstance->Rsdt1->OemId));
+ CurrentData = PcdGet64 (PcdAcpiDefaultOemTableId);
CopyMem (&AcpiSupportInstance->Rsdt1->OemTableId, &CurrentData, sizeof (UINT64));
- AcpiSupportInstance->Rsdt1->OemRevision = EFI_ACPI_OEM_REVISION;
- AcpiSupportInstance->Rsdt1->CreatorId = EFI_ACPI_CREATOR_ID;
- AcpiSupportInstance->Rsdt1->CreatorRevision = EFI_ACPI_CREATOR_REVISION;
+ AcpiSupportInstance->Rsdt1->OemRevision = PcdGet32 (PcdAcpiDefaultOemRevision);
+ AcpiSupportInstance->Rsdt1->CreatorId = PcdGet32 (PcdAcpiDefaultCreatorId);
+ AcpiSupportInstance->Rsdt1->CreatorRevision = PcdGet32 (PcdAcpiDefaultCreatorRevision);
//
// We always reserve first one for FADT
//
@@ -1878,12 +1878,12 @@ AcpiSupportAcpiSupportConstructor (
AcpiSupportInstance->Rsdt3->Signature = EFI_ACPI_3_0_ROOT_SYSTEM_DESCRIPTION_TABLE_SIGNATURE;
AcpiSupportInstance->Rsdt3->Length = sizeof (EFI_ACPI_DESCRIPTION_HEADER);
AcpiSupportInstance->Rsdt3->Revision = EFI_ACPI_3_0_ROOT_SYSTEM_DESCRIPTION_TABLE_REVISION;
- CopyMem (AcpiSupportInstance->Rsdt3->OemId, EFI_ACPI_OEM_ID, 6);
- CurrentData = EFI_ACPI_OEM_TABLE_ID;
+ CopyMem (AcpiSupportInstance->Rsdt3->OemId, PcdGetPtr (PcdAcpiDefaultOemId), sizeof (AcpiSupportInstance->Rsdt3->OemId));
+ CurrentData = PcdGet64 (PcdAcpiDefaultOemTableId);
CopyMem (&AcpiSupportInstance->Rsdt3->OemTableId, &CurrentData, sizeof (UINT64));
- AcpiSupportInstance->Rsdt3->OemRevision = EFI_ACPI_OEM_REVISION;
- AcpiSupportInstance->Rsdt3->CreatorId = EFI_ACPI_CREATOR_ID;
- AcpiSupportInstance->Rsdt3->CreatorRevision = EFI_ACPI_CREATOR_REVISION;
+ AcpiSupportInstance->Rsdt3->OemRevision = PcdGet32 (PcdAcpiDefaultOemRevision);
+ AcpiSupportInstance->Rsdt3->CreatorId = PcdGet32 (PcdAcpiDefaultCreatorId);
+ AcpiSupportInstance->Rsdt3->CreatorRevision = PcdGet32 (PcdAcpiDefaultCreatorRevision);
//
// We always reserve first one for FADT
//
@@ -1896,12 +1896,12 @@ AcpiSupportAcpiSupportConstructor (
AcpiSupportInstance->Xsdt->Signature = EFI_ACPI_3_0_EXTENDED_SYSTEM_DESCRIPTION_TABLE_SIGNATURE;
AcpiSupportInstance->Xsdt->Length = sizeof (EFI_ACPI_DESCRIPTION_HEADER);
AcpiSupportInstance->Xsdt->Revision = EFI_ACPI_3_0_EXTENDED_SYSTEM_DESCRIPTION_TABLE_REVISION;
- CopyMem (AcpiSupportInstance->Xsdt->OemId, EFI_ACPI_OEM_ID, 6);
- CurrentData = EFI_ACPI_OEM_TABLE_ID;
+ CopyMem (AcpiSupportInstance->Xsdt->OemId, PcdGetPtr (PcdAcpiDefaultOemId), sizeof (AcpiSupportInstance->Xsdt->OemId));
+ CurrentData = PcdGet64 (PcdAcpiDefaultOemTableId);
CopyMem (&AcpiSupportInstance->Xsdt->OemTableId, &CurrentData, sizeof (UINT64));
- AcpiSupportInstance->Xsdt->OemRevision = EFI_ACPI_OEM_REVISION;
- AcpiSupportInstance->Xsdt->CreatorId = EFI_ACPI_CREATOR_ID;
- AcpiSupportInstance->Xsdt->CreatorRevision = EFI_ACPI_CREATOR_REVISION;
+ AcpiSupportInstance->Xsdt->OemRevision = PcdGet32 (PcdAcpiDefaultOemRevision);
+ AcpiSupportInstance->Xsdt->CreatorId = PcdGet32 (PcdAcpiDefaultCreatorId);
+ AcpiSupportInstance->Xsdt->CreatorRevision = PcdGet32 (PcdAcpiDefaultCreatorRevision);
//
// We always reserve first one for FADT
//
diff --git a/IntelFrameworkModulePkg/Universal/Acpi/AcpiSupportDxe/AcpiSupportDxe.inf b/IntelFrameworkModulePkg/Universal/Acpi/AcpiSupportDxe/AcpiSupportDxe.inf
index 422856d75..19818064f 100644
--- a/IntelFrameworkModulePkg/Universal/Acpi/AcpiSupportDxe/AcpiSupportDxe.inf
+++ b/IntelFrameworkModulePkg/Universal/Acpi/AcpiSupportDxe/AcpiSupportDxe.inf
@@ -4,7 +4,7 @@
# This driver initializes ACPI support protocol instance data structure and intstall
# ACPI support protocol to provide Get, Set and Publish Table services.
#
-# Copyright (c) 2006 - 2010, Intel Corporation. All rights reserved.<BR>
+# Copyright (c) 2006 - 2013, Intel Corporation. All rights reserved.<BR>
#
# This program and the accompanying materials
# are licensed and made available under the terms and conditions
@@ -62,6 +62,13 @@
[FeaturePcd]
gEfiIntelFrameworkModulePkgTokenSpaceGuid.PcdInstallAcpiSupportProtocol
+[Pcd]
+ gEfiMdeModulePkgTokenSpaceGuid.PcdAcpiDefaultOemId
+ gEfiMdeModulePkgTokenSpaceGuid.PcdAcpiDefaultOemTableId
+ gEfiMdeModulePkgTokenSpaceGuid.PcdAcpiDefaultOemRevision
+ gEfiMdeModulePkgTokenSpaceGuid.PcdAcpiDefaultCreatorId
+ gEfiMdeModulePkgTokenSpaceGuid.PcdAcpiDefaultCreatorRevision
+
[Protocols]
gEfiAcpiTableProtocolGuid # PROTOCOL ALWAYS_PRODUCED
gEfiAcpiSupportProtocolGuid # PROTOCOL ALWAYS_PRODUCED
diff --git a/IntelFrameworkModulePkg/Universal/BdsDxe/Bds.h b/IntelFrameworkModulePkg/Universal/BdsDxe/Bds.h
index 0aba09c1b..e535bc21d 100644
--- a/IntelFrameworkModulePkg/Universal/BdsDxe/Bds.h
+++ b/IntelFrameworkModulePkg/Universal/BdsDxe/Bds.h
@@ -36,6 +36,7 @@ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
#include <Guid/BdsHii.h>
#include <Guid/ConnectConInEvent.h>
#include <Guid/Performance.h>
+#include <Guid/FmpCapsule.h>
#include <Protocol/GenericMemoryTest.h>
#include <Protocol/FormBrowser2.h>
#include <Protocol/HiiConfigAccess.h>
diff --git a/IntelFrameworkModulePkg/Universal/BdsDxe/BdsDxe.inf b/IntelFrameworkModulePkg/Universal/BdsDxe/BdsDxe.inf
index 2424a8a84..b10056491 100644
--- a/IntelFrameworkModulePkg/Universal/BdsDxe/BdsDxe.inf
+++ b/IntelFrameworkModulePkg/Universal/BdsDxe/BdsDxe.inf
@@ -141,6 +141,7 @@
gDeviceManagerFormSetGuid ## SOMETIMES_PRODUCES ## DeviceManager HII Package
gDriverHealthFormSetGuid ## SOMETIMES_PRODUCES ## DriverHealth HII Package
gConnectConInEventGuid ## CONSUMES ## GUID (Connect ConIn Event)
+ gEfiFmpCapsuleGuid ## CONSUMES ## GUID (FMP Capsule)
[Protocols]
gEfiSimpleFileSystemProtocolGuid ## PROTOCOL CONSUMES
diff --git a/IntelFrameworkModulePkg/Universal/BdsDxe/BdsEntry.c b/IntelFrameworkModulePkg/Universal/BdsDxe/BdsEntry.c
index 77c88b0d2..33b3cc2dc 100644
--- a/IntelFrameworkModulePkg/Universal/BdsDxe/BdsEntry.c
+++ b/IntelFrameworkModulePkg/Universal/BdsDxe/BdsEntry.c
@@ -403,7 +403,9 @@ BdsFormalizeEfiGlobalVariable (
//
// OS indicater support variable
//
- OsIndicationSupport = EFI_OS_INDICATIONS_BOOT_TO_FW_UI;
+ OsIndicationSupport = EFI_OS_INDICATIONS_BOOT_TO_FW_UI \
+ | EFI_OS_INDICATIONS_FMP_CAPSULE_SUPPORTED;
+
Status = gRT->SetVariable (
L"OsIndicationsSupported",
&gEfiGlobalVariableGuid,
diff --git a/IntelFrameworkModulePkg/Universal/BdsDxe/BootMaint/BootMaint.c b/IntelFrameworkModulePkg/Universal/BdsDxe/BootMaint/BootMaint.c
index 44d9b71c4..5f200e2e1 100644
--- a/IntelFrameworkModulePkg/Universal/BdsDxe/BootMaint/BootMaint.c
+++ b/IntelFrameworkModulePkg/Universal/BdsDxe/BootMaint/BootMaint.c
@@ -316,6 +316,106 @@ BootMaintCallback (
UpdatePageId (Private, QuestionId);
+ if (QuestionId < FILE_OPTION_OFFSET) {
+ if (QuestionId < CONFIG_OPTION_OFFSET) {
+ switch (QuestionId) {
+ case KEY_VALUE_BOOT_FROM_FILE:
+ Private->FeCurrentState = FileExplorerStateBootFromFile;
+ break;
+
+ case FORM_BOOT_ADD_ID:
+ Private->FeCurrentState = FileExplorerStateAddBootOption;
+ break;
+
+ case FORM_DRV_ADD_FILE_ID:
+ Private->FeCurrentState = FileExplorerStateAddDriverOptionState;
+ break;
+
+ case FORM_DRV_ADD_HANDLE_ID:
+ CleanUpPage (FORM_DRV_ADD_HANDLE_ID, Private);
+ UpdateDrvAddHandlePage (Private);
+ break;
+
+ case FORM_BOOT_DEL_ID:
+ CleanUpPage (FORM_BOOT_DEL_ID, Private);
+ UpdateBootDelPage (Private);
+ break;
+
+ case FORM_BOOT_CHG_ID:
+ case FORM_DRV_CHG_ID:
+ UpdatePageBody (QuestionId, Private);
+ break;
+
+ case FORM_DRV_DEL_ID:
+ CleanUpPage (FORM_DRV_DEL_ID, Private);
+ UpdateDrvDelPage (Private);
+ break;
+
+ case FORM_BOOT_NEXT_ID:
+ CleanUpPage (FORM_BOOT_NEXT_ID, Private);
+ UpdateBootNextPage (Private);
+ break;
+
+ case FORM_TIME_OUT_ID:
+ CleanUpPage (FORM_TIME_OUT_ID, Private);
+ UpdateTimeOutPage (Private);
+ break;
+
+ case FORM_CON_IN_ID:
+ case FORM_CON_OUT_ID:
+ case FORM_CON_ERR_ID:
+ UpdatePageBody (QuestionId, Private);
+ break;
+
+ case FORM_CON_MODE_ID:
+ CleanUpPage (FORM_CON_MODE_ID, Private);
+ UpdateConModePage (Private);
+ break;
+
+ case FORM_CON_COM_ID:
+ CleanUpPage (FORM_CON_COM_ID, Private);
+ UpdateConCOMPage (Private);
+ break;
+
+ case FORM_SET_FD_ORDER_ID:
+ case FORM_SET_HD_ORDER_ID:
+ case FORM_SET_CD_ORDER_ID:
+ case FORM_SET_NET_ORDER_ID:
+ case FORM_SET_BEV_ORDER_ID:
+ CleanUpPage (QuestionId, Private);
+ UpdateSetLegacyDeviceOrderPage (QuestionId, Private);
+ break;
+
+ default:
+ break;
+ }
+ } else if ((QuestionId >= TERMINAL_OPTION_OFFSET) && (QuestionId < CONSOLE_OPTION_OFFSET)) {
+ Index2 = (UINT16) (QuestionId - TERMINAL_OPTION_OFFSET);
+ Private->CurrentTerminal = Index2;
+
+ CleanUpPage (FORM_CON_COM_SETUP_ID, Private);
+ UpdateTerminalPage (Private);
+
+ } else if (QuestionId >= HANDLE_OPTION_OFFSET) {
+ Index2 = (UINT16) (QuestionId - HANDLE_OPTION_OFFSET);
+
+ NewMenuEntry = BOpt_GetMenuEntry (&DriverMenu, Index2);
+ ASSERT (NewMenuEntry != NULL);
+ Private->HandleContext = (BM_HANDLE_CONTEXT *) NewMenuEntry->VariableContext;
+
+ CleanUpPage (FORM_DRV_ADD_HANDLE_DESC_ID, Private);
+
+ Private->MenuEntry = NewMenuEntry;
+ Private->LoadContext->FilePathList = Private->HandleContext->DevicePath;
+
+ UpdateDriverAddHandleDescPage (Private);
+ }
+ }
+ } else if (Action == EFI_BROWSER_ACTION_CHANGED) {
+ if ((Value == NULL) || (ActionRequest == NULL)) {
+ return EFI_INVALID_PARAMETER;
+ }
+
//
// need to be subtituded.
//
@@ -466,133 +566,33 @@ BootMaintCallback (
//
Value->u8 = NewLegacyDev[Index3];
}
- }
-
- if (QuestionId < FILE_OPTION_OFFSET) {
- if (QuestionId < CONFIG_OPTION_OFFSET) {
- switch (QuestionId) {
- case KEY_VALUE_BOOT_FROM_FILE:
- Private->FeCurrentState = FileExplorerStateBootFromFile;
- break;
-
- case FORM_BOOT_ADD_ID:
- Private->FeCurrentState = FileExplorerStateAddBootOption;
- break;
-
- case FORM_DRV_ADD_FILE_ID:
- Private->FeCurrentState = FileExplorerStateAddDriverOptionState;
- break;
-
- case FORM_DRV_ADD_HANDLE_ID:
- CleanUpPage (FORM_DRV_ADD_HANDLE_ID, Private);
- UpdateDrvAddHandlePage (Private);
- break;
-
- case FORM_BOOT_DEL_ID:
- CleanUpPage (FORM_BOOT_DEL_ID, Private);
- UpdateBootDelPage (Private);
- break;
-
- case FORM_BOOT_CHG_ID:
- case FORM_DRV_CHG_ID:
- UpdatePageBody (QuestionId, Private);
- break;
-
- case FORM_DRV_DEL_ID:
- CleanUpPage (FORM_DRV_DEL_ID, Private);
- UpdateDrvDelPage (Private);
- break;
-
- case FORM_BOOT_NEXT_ID:
- CleanUpPage (FORM_BOOT_NEXT_ID, Private);
- UpdateBootNextPage (Private);
- break;
-
- case FORM_TIME_OUT_ID:
- CleanUpPage (FORM_TIME_OUT_ID, Private);
- UpdateTimeOutPage (Private);
- break;
-
- case FORM_CON_IN_ID:
- case FORM_CON_OUT_ID:
- case FORM_CON_ERR_ID:
- UpdatePageBody (QuestionId, Private);
- break;
-
- case FORM_CON_MODE_ID:
- CleanUpPage (FORM_CON_MODE_ID, Private);
- UpdateConModePage (Private);
- break;
-
- case FORM_CON_COM_ID:
- CleanUpPage (FORM_CON_COM_ID, Private);
- UpdateConCOMPage (Private);
- break;
-
- case FORM_SET_FD_ORDER_ID:
- case FORM_SET_HD_ORDER_ID:
- case FORM_SET_CD_ORDER_ID:
- case FORM_SET_NET_ORDER_ID:
- case FORM_SET_BEV_ORDER_ID:
- CleanUpPage (QuestionId, Private);
- UpdateSetLegacyDeviceOrderPage (QuestionId, Private);
- break;
-
- default:
- break;
+ } else {
+ switch (QuestionId) {
+ case KEY_VALUE_SAVE_AND_EXIT:
+ case KEY_VALUE_NO_SAVE_AND_EXIT:
+ if (QuestionId == KEY_VALUE_SAVE_AND_EXIT) {
+ Status = ApplyChangeHandler (Private, CurrentFakeNVMap, Private->BmmPreviousPageId);
+ if (EFI_ERROR (Status)) {
+ return Status;
+ }
+ } else if (QuestionId == KEY_VALUE_NO_SAVE_AND_EXIT) {
+ DiscardChangeHandler (Private, CurrentFakeNVMap);
}
- } else if ((QuestionId >= TERMINAL_OPTION_OFFSET) && (QuestionId < CONSOLE_OPTION_OFFSET)) {
- Index2 = (UINT16) (QuestionId - TERMINAL_OPTION_OFFSET);
- Private->CurrentTerminal = Index2;
-
- CleanUpPage (FORM_CON_COM_SETUP_ID, Private);
- UpdateTerminalPage (Private);
-
- } else if (QuestionId >= HANDLE_OPTION_OFFSET) {
- Index2 = (UINT16) (QuestionId - HANDLE_OPTION_OFFSET);
- NewMenuEntry = BOpt_GetMenuEntry (&DriverMenu, Index2);
- ASSERT (NewMenuEntry != NULL);
- Private->HandleContext = (BM_HANDLE_CONTEXT *) NewMenuEntry->VariableContext;
-
- CleanUpPage (FORM_DRV_ADD_HANDLE_DESC_ID, Private);
+ //
+ // Tell browser not to ask for confirmation of changes,
+ // since we have already applied or discarded.
+ //
+ *ActionRequest = EFI_BROWSER_ACTION_REQUEST_FORM_SUBMIT_EXIT;
+ break;
- Private->MenuEntry = NewMenuEntry;
- Private->LoadContext->FilePathList = Private->HandleContext->DevicePath;
+ case FORM_RESET:
+ gRT->ResetSystem (EfiResetCold, EFI_SUCCESS, 0, NULL);
+ return EFI_UNSUPPORTED;
- UpdateDriverAddHandleDescPage (Private);
- }
- }
- } else if (Action == EFI_BROWSER_ACTION_CHANGED) {
- if ((Value == NULL) || (ActionRequest == NULL)) {
- return EFI_INVALID_PARAMETER;
- }
-
- switch (QuestionId) {
- case KEY_VALUE_SAVE_AND_EXIT:
- case KEY_VALUE_NO_SAVE_AND_EXIT:
- if (QuestionId == KEY_VALUE_SAVE_AND_EXIT) {
- Status = ApplyChangeHandler (Private, CurrentFakeNVMap, Private->BmmPreviousPageId);
- if (EFI_ERROR (Status)) {
- return Status;
- }
- } else if (QuestionId == KEY_VALUE_NO_SAVE_AND_EXIT) {
- DiscardChangeHandler (Private, CurrentFakeNVMap);
+ default:
+ break;
}
-
- //
- // Tell browser not to ask for confirmation of changes,
- // since we have already applied or discarded.
- //
- *ActionRequest = EFI_BROWSER_ACTION_REQUEST_FORM_SUBMIT_EXIT;
- break;
-
- case FORM_RESET:
- gRT->ResetSystem (EfiResetCold, EFI_SUCCESS, 0, NULL);
- return EFI_UNSUPPORTED;
-
- default:
- break;
}
}
diff --git a/IntelFrameworkModulePkg/Universal/BdsDxe/Capsules.c b/IntelFrameworkModulePkg/Universal/BdsDxe/Capsules.c
index 07c12195f..6c7fc7ced 100644
--- a/IntelFrameworkModulePkg/Universal/BdsDxe/Capsules.c
+++ b/IntelFrameworkModulePkg/Universal/BdsDxe/Capsules.c
@@ -1,7 +1,7 @@
/** @file
BDS routines to handle capsules.
-Copyright (c) 2004 - 2011, Intel Corporation. All rights reserved.<BR>
+Copyright (c) 2004 - 2013, 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
@@ -52,14 +52,16 @@ BdsProcessCapsules (
VOID **CapsulePtr;
VOID **CapsulePtrCache;
EFI_GUID *CapsuleGuidCache;
+ BOOLEAN NeedReset;
- CapsuleNumber = 0;
+ CapsuleNumber = 0;
CapsuleTotalNumber = 0;
- CacheIndex = 0;
- CacheNumber = 0;
- CapsulePtr = NULL;
- CapsulePtrCache = NULL;
- CapsuleGuidCache = NULL;
+ CacheIndex = 0;
+ CacheNumber = 0;
+ CapsulePtr = NULL;
+ CapsulePtrCache = NULL;
+ CapsuleGuidCache = NULL;
+ NeedReset = FALSE;
//
// We don't do anything else if the boot mode is not flash-update
@@ -191,12 +193,32 @@ BdsProcessCapsules (
CapsuleHeader = (EFI_CAPSULE_HEADER*) CapsulePtr [Index];
if ((CapsuleHeader->Flags & CAPSULE_FLAGS_POPULATE_SYSTEM_TABLE) == 0) {
//
+ // Always reset system after all capsule processed if FMP capsule exist
+ //
+ if (CompareGuid (&gEfiFmpCapsuleGuid, &CapsuleHeader->CapsuleGuid)){
+ NeedReset = TRUE;
+ }
+
+ //
// Call capsule library to process capsule image.
//
ProcessCapsuleImage (CapsuleHeader);
}
}
+ if (NeedReset) {
+ Print(L"Capsule Request Cold Reboot.\n");
+
+ for (Index = 5; Index > 0; Index--) {
+ Print(L"\rResetting system in %d seconds ...", Index);
+ gBS->Stall (1000000);
+ }
+
+ gRT->ResetSystem (EfiResetCold, EFI_SUCCESS, 0, NULL);
+
+ CpuDeadLoop ();
+ }
+
PlatformBdsLockNonUpdatableFlash ();
//
diff --git a/IntelFrameworkModulePkg/Universal/BdsDxe/DeviceMngr/DeviceManager.c b/IntelFrameworkModulePkg/Universal/BdsDxe/DeviceMngr/DeviceManager.c
index d9ec1f2f1..14e71e3e5 100644
--- a/IntelFrameworkModulePkg/Universal/BdsDxe/DeviceMngr/DeviceManager.c
+++ b/IntelFrameworkModulePkg/Universal/BdsDxe/DeviceMngr/DeviceManager.c
@@ -1,7 +1,7 @@
/** @file
The platform device manager reference implementation
-Copyright (c) 2004 - 2012, Intel Corporation. All rights reserved.<BR>
+Copyright (c) 2004 - 2013, 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
@@ -1943,7 +1943,7 @@ ProcessSingleControllerHealth (
DriverHealth,
ControllerHandle,
ChildHandle,
- (EFI_DRIVER_HEALTH_REPAIR_PROGRESS_NOTIFY) RepairNotify
+ RepairNotify
);
}
//
@@ -2019,24 +2019,20 @@ ProcessSingleControllerHealth (
/**
- Platform specific notification function for controller repair operations.
-
- If the driver for a controller support the Driver Health Protocol and the
- current state of the controller is EfiDriverHealthStatusRepairRequired then
- when the Repair() service of the Driver Health Protocol is called, this
- platform specific notification function can display the progress of the repair
- operation. Some platforms may choose to not display anything, other may choose
- to show the percentage complete on text consoles, and other may choose to render
- a progress bar on text and graphical consoles.
-
- This function displays the percentage of the repair operation that has been
- completed on text consoles. The percentage is Value / Limit * 100%.
-
- @param Value Value in the range 0..Limit the the repair has completed..
- @param Limit The maximum value of Value
+ Reports the progress of a repair operation.
+
+ @param[in] Value A value between 0 and Limit that identifies the current
+ progress of the repair operation.
+
+ @param[in] Limit The maximum value of Value for the current repair operation.
+ For example, a driver that wants to specify progress in
+ percent would use a Limit value of 100.
+
+ @retval EFI_SUCCESS The progress of a repair operation is reported successfully.
**/
-VOID
+EFI_STATUS
+EFIAPI
RepairNotify (
IN UINTN Value,
IN UINTN Limit
@@ -2050,6 +2046,7 @@ RepairNotify (
Percent = Value * 100 / Limit;
Print(L"Repair Progress = %3d%%\n\r", Percent);
}
+ return EFI_SUCCESS;
}
/**
diff --git a/IntelFrameworkModulePkg/Universal/BdsDxe/DeviceMngr/DeviceManager.h b/IntelFrameworkModulePkg/Universal/BdsDxe/DeviceMngr/DeviceManager.h
index ae01b3f60..95bde8de5 100644
--- a/IntelFrameworkModulePkg/Universal/BdsDxe/DeviceMngr/DeviceManager.h
+++ b/IntelFrameworkModulePkg/Universal/BdsDxe/DeviceMngr/DeviceManager.h
@@ -1,7 +1,7 @@
/** @file
The platform device manager reference implement
-Copyright (c) 2004 - 2011, Intel Corporation. All rights reserved.<BR>
+Copyright (c) 2004 - 2013, 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
@@ -313,13 +313,20 @@ ProcessSingleControllerHealth (
);
/**
- Repair notification function, simply print the repair progress.
+ Reports the progress of a repair operation.
- @param Value The value of part has been repaired.
- @param Limit Total value need to be repaired.
+ @param[in] Value A value between 0 and Limit that identifies the current
+ progress of the repair operation.
+
+ @param[in] Limit The maximum value of Value for the current repair operation.
+ For example, a driver that wants to specify progress in
+ percent would use a Limit value of 100.
+
+ @retval EFI_SUCCESS The progress of a repair operation is reported successfully.
**/
-VOID
+EFI_STATUS
+EFIAPI
RepairNotify (
IN UINTN Value,
IN UINTN Limit
diff --git a/MdeModulePkg/Bus/Ata/AtaAtapiPassThru/AtaAtapiPassThru.c b/MdeModulePkg/Bus/Ata/AtaAtapiPassThru/AtaAtapiPassThru.c
index e5bfc3980..cc575b98c 100644
--- a/MdeModulePkg/Bus/Ata/AtaAtapiPassThru/AtaAtapiPassThru.c
+++ b/MdeModulePkg/Bus/Ata/AtaAtapiPassThru/AtaAtapiPassThru.c
@@ -2,7 +2,7 @@
This file implements ATA_PASSTHRU_PROCTOCOL and EXT_SCSI_PASSTHRU_PROTOCOL interfaces
for managed ATA controllers.
- Copyright (c) 2010 - 2012, Intel Corporation. All rights reserved.<BR>
+ Copyright (c) 2010 - 2013, 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
@@ -1265,6 +1265,15 @@ AtaPassThruPassThru (
return EFI_INVALID_PARAMETER;
}
+ Node = SearchDeviceInfoList (Instance, Port, PortMultiplierPort, EfiIdeHarddisk);
+
+ if (Node == NULL) {
+ Node = SearchDeviceInfoList(Instance, Port, PortMultiplierPort, EfiIdeCdrom);
+ if (Node == NULL) {
+ return EFI_INVALID_PARAMETER;
+ }
+ }
+
//
// convert the transfer length from sector count to byte.
//
@@ -1281,12 +1290,6 @@ AtaPassThruPassThru (
Packet->OutTransferLength = Packet->OutTransferLength * 0x200;
}
- Node = SearchDeviceInfoList (Instance, Port, PortMultiplierPort, EfiIdeHarddisk);
-
- if (Node == NULL) {
- return EFI_INVALID_PARAMETER;
- }
-
//
// Check whether this device needs 48-bit addressing (ATAPI-6 ata device).
// Per ATA-6 spec, word83: bit15 is zero and bit14 is one.
@@ -1761,7 +1764,10 @@ AtaPassThruResetPort (
IN UINT16 Port
)
{
- return EFI_UNSUPPORTED;
+ //
+ // Return success directly then upper layer driver could think reset port operation is done.
+ //
+ return EFI_SUCCESS;
}
/**
@@ -1803,7 +1809,21 @@ AtaPassThruResetDevice (
IN UINT16 PortMultiplierPort
)
{
- return EFI_UNSUPPORTED;
+ ATA_ATAPI_PASS_THRU_INSTANCE *Instance;
+ LIST_ENTRY *Node;
+
+ Instance = ATA_PASS_THRU_PRIVATE_DATA_FROM_THIS (This);
+
+ Node = SearchDeviceInfoList (Instance, Port, PortMultiplierPort, EfiIdeHarddisk);
+
+ if (Node == NULL) {
+ return EFI_INVALID_PARAMETER;
+ }
+
+ //
+ // Return success directly then upper layer driver could think reset device operation is done.
+ //
+ return EFI_SUCCESS;
}
/**
@@ -2271,7 +2291,10 @@ ExtScsiPassThruResetChannel (
IN EFI_EXT_SCSI_PASS_THRU_PROTOCOL *This
)
{
- return EFI_UNSUPPORTED;
+ //
+ // Return success directly then upper layer driver could think reset channel operation is done.
+ //
+ return EFI_SUCCESS;
}
/**
@@ -2301,7 +2324,41 @@ ExtScsiPassThruResetTargetLun (
IN UINT64 Lun
)
{
- return EFI_UNSUPPORTED;
+ ATA_ATAPI_PASS_THRU_INSTANCE *Instance;
+ LIST_ENTRY *Node;
+ UINT8 Port;
+ UINT8 PortMultiplier;
+
+ Instance = EXT_SCSI_PASS_THRU_PRIVATE_DATA_FROM_THIS (This);
+ //
+ // For ATAPI device, doesn't support multiple LUN device.
+ //
+ if (Lun != 0) {
+ return EFI_INVALID_PARAMETER;
+ }
+ //
+ // The layout of Target array:
+ // ________________________________________________________________________
+ // | Byte 0 | Byte 1 | ... | TARGET_MAX_BYTES - 1 |
+ // |_____________________|_____________________|_____|______________________|
+ // | | The port multiplier | | |
+ // | The port number | port number | N/A | N/A |
+ // |_____________________|_____________________|_____|______________________|
+ //
+ // For ATAPI device, 2 bytes is enough to represent the location of SCSI device.
+ //
+ Port = Target[0];
+ PortMultiplier = Target[1];
+
+ Node = SearchDeviceInfoList(Instance, Port, PortMultiplier, EfiIdeCdrom);
+ if (Node == NULL) {
+ return EFI_INVALID_PARAMETER;
+ }
+
+ //
+ // Return success directly then upper layer driver could think reset target LUN operation is done.
+ //
+ return EFI_SUCCESS;
}
/**
diff --git a/MdeModulePkg/Bus/Ata/AtaBusDxe/AtaBus.c b/MdeModulePkg/Bus/Ata/AtaBusDxe/AtaBus.c
index 6732fd5e0..b113b8d85 100644
--- a/MdeModulePkg/Bus/Ata/AtaBusDxe/AtaBus.c
+++ b/MdeModulePkg/Bus/Ata/AtaBusDxe/AtaBus.c
@@ -90,7 +90,8 @@ ATA_DEVICE gAtaDeviceTemplate = {
NULL, // ControllerNameTable
{L'\0', }, // ModelName
{NULL, NULL}, // AtaTaskList
- {NULL, NULL} // AtaSubTaskList
+ {NULL, NULL}, // AtaSubTaskList
+ FALSE // Abort
};
/**
@@ -172,7 +173,7 @@ ReleaseAtaResources (
) {
DelEntry = Entry;
Entry = Entry->ForwardLink;
- SubTask = ATA_AYNS_SUB_TASK_FROM_ENTRY (DelEntry);
+ SubTask = ATA_ASYN_SUB_TASK_FROM_ENTRY (DelEntry);
RemoveEntryList (DelEntry);
FreeAtaSubTask (SubTask);
@@ -187,7 +188,7 @@ ReleaseAtaResources (
) {
DelEntry = Entry;
Entry = Entry->ForwardLink;
- AtaTask = ATA_AYNS_TASK_FROM_ENTRY (DelEntry);
+ AtaTask = ATA_ASYN_TASK_FROM_ENTRY (DelEntry);
RemoveEntryList (DelEntry);
FreePool (AtaTask);
@@ -1217,6 +1218,8 @@ AtaBlockIoResetEx (
AtaDevice = ATA_DEVICE_FROM_BLOCK_IO2 (This);
+ AtaTerminateNonBlockingTask (AtaDevice);
+
Status = ResetAtaDevice (AtaDevice);
if (EFI_ERROR (Status)) {
diff --git a/MdeModulePkg/Bus/Ata/AtaBusDxe/AtaBus.h b/MdeModulePkg/Bus/Ata/AtaBusDxe/AtaBus.h
index 4d3d9d54c..04ae47cea 100644
--- a/MdeModulePkg/Bus/Ata/AtaBusDxe/AtaBus.h
+++ b/MdeModulePkg/Bus/Ata/AtaBusDxe/AtaBus.h
@@ -4,7 +4,7 @@
This file defines common data structures, macro definitions and some module
internal function header files.
- Copyright (c) 2009 - 2012, Intel Corporation. All rights reserved.<BR>
+ Copyright (c) 2009 - 2013, 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
@@ -148,6 +148,7 @@ typedef struct {
LIST_ENTRY AtaTaskList;
LIST_ENTRY AtaSubTaskList;
+ BOOLEAN Abort;
} ATA_DEVICE;
//
@@ -181,8 +182,8 @@ typedef struct {
#define ATA_DEVICE_FROM_BLOCK_IO2(a) CR (a, ATA_DEVICE, BlockIo2, ATA_DEVICE_SIGNATURE)
#define ATA_DEVICE_FROM_DISK_INFO(a) CR (a, ATA_DEVICE, DiskInfo, ATA_DEVICE_SIGNATURE)
#define ATA_DEVICE_FROM_STORAGE_SECURITY(a) CR (a, ATA_DEVICE, StorageSecurity, ATA_DEVICE_SIGNATURE)
-#define ATA_AYNS_SUB_TASK_FROM_ENTRY(a) CR (a, ATA_BUS_ASYN_SUB_TASK, TaskEntry, ATA_SUB_TASK_SIGNATURE)
-#define ATA_AYNS_TASK_FROM_ENTRY(a) CR (a, ATA_BUS_ASYN_TASK, TaskEntry, ATA_TASK_SIGNATURE)
+#define ATA_ASYN_SUB_TASK_FROM_ENTRY(a) CR (a, ATA_BUS_ASYN_SUB_TASK, TaskEntry, ATA_SUB_TASK_SIGNATURE)
+#define ATA_ASYN_TASK_FROM_ENTRY(a) CR (a, ATA_BUS_ASYN_TASK, TaskEntry, ATA_TASK_SIGNATURE)
//
// Global Variables
@@ -301,6 +302,7 @@ AccessAtaDevice(
IN BOOLEAN IsWrite,
IN OUT EFI_BLOCK_IO2_TOKEN *Token
);
+
/**
Trust transfer data from/to ATA device.
@@ -805,6 +807,22 @@ AtaBlockIoFlushBlocksEx (
);
/**
+ Terminate any in-flight non-blocking I/O requests by signaling an EFI_ABORTED
+ in the TransactionStatus member of the EFI_BLOCK_IO2_TOKEN for the non-blocking
+ I/O. After that it is safe to free any Token or Buffer data structures that
+ were allocated to initiate the non-blockingI/O requests that were in-flight for
+ this device.
+
+ @param[in] AtaDevice The ATA child device involved for the operation.
+
+**/
+VOID
+EFIAPI
+AtaTerminateNonBlockingTask (
+ IN ATA_DEVICE *AtaDevice
+ );
+
+/**
Provides inquiry information for the controller type.
This function is used by the IDE bus driver to get inquiry data. Data format
@@ -940,20 +958,20 @@ AtaDiskInfoWhichIde (
return EFI_SUCCESS. If the security protocol command completes with an error, the
function shall return EFI_DEVICE_ERROR.
- @param This Indicates a pointer to the calling context.
- @param MediaId ID of the medium to receive data from.
- @param Timeout The timeout, in 100ns units, to use for the execution
+ @param This Indicates a pointer to the calling context.
+ @param MediaId ID of the medium to receive data from.
+ @param Timeout The timeout, in 100ns units, to use for the execution
of the security protocol command. A Timeout value of 0
means that this function will wait indefinitely for the
security protocol command to execute. If Timeout is greater
than zero, then this function will return EFI_TIMEOUT
- if the time required to execute the receive data command
- is greater than Timeout.
+ if the time required to execute the receive data command
+ is greater than Timeout.
@param SecurityProtocolId The value of the "Security Protocol" parameter of
the security protocol command to be sent.
@param SecurityProtocolSpecificData The value of the "Security Protocol Specific" parameter
of the security protocol command to be sent.
- @param PayloadBufferSize Size in bytes of the payload data buffer.
+ @param PayloadBufferSize Size in bytes of the payload data buffer.
@param PayloadBuffer A pointer to a destination buffer to store the security
protocol command specific payload data for the security
protocol command. The caller is responsible for having
@@ -1020,20 +1038,20 @@ AtaStorageSecurityReceiveData (
EFI_SUCCESS. If the security protocol command completes with an error, the function
shall return EFI_DEVICE_ERROR.
- @param This Indicates a pointer to the calling context.
- @param MediaId ID of the medium to receive data from.
- @param Timeout The timeout, in 100ns units, to use for the execution
+ @param This Indicates a pointer to the calling context.
+ @param MediaId ID of the medium to receive data from.
+ @param Timeout The timeout, in 100ns units, to use for the execution
of the security protocol command. A Timeout value of 0
means that this function will wait indefinitely for the
security protocol command to execute. If Timeout is greater
than zero, then this function will return EFI_TIMEOUT
- if the time required to execute the receive data command
- is greater than Timeout.
+ if the time required to execute the receive data command
+ is greater than Timeout.
@param SecurityProtocolId The value of the "Security Protocol" parameter of
the security protocol command to be sent.
@param SecurityProtocolSpecificData The value of the "Security Protocol Specific" parameter
of the security protocol command to be sent.
- @param PayloadBufferSize Size in bytes of the payload data buffer.
+ @param PayloadBufferSize Size in bytes of the payload data buffer.
@param PayloadBuffer A pointer to a destination buffer to store the security
protocol command specific payload data for the security
protocol command.
diff --git a/MdeModulePkg/Bus/Ata/AtaBusDxe/AtaPassThruExecute.c b/MdeModulePkg/Bus/Ata/AtaBusDxe/AtaPassThruExecute.c
index b1bedd80e..a3008f92d 100644
--- a/MdeModulePkg/Bus/Ata/AtaBusDxe/AtaPassThruExecute.c
+++ b/MdeModulePkg/Bus/Ata/AtaBusDxe/AtaPassThruExecute.c
@@ -583,6 +583,62 @@ FreeAtaSubTask (
}
/**
+ Terminate any in-flight non-blocking I/O requests by signaling an EFI_ABORTED
+ in the TransactionStatus member of the EFI_BLOCK_IO2_TOKEN for the non-blocking
+ I/O. After that it is safe to free any Token or Buffer data structures that
+ were allocated to initiate the non-blockingI/O requests that were in-flight for
+ this device.
+
+ @param[in] AtaDevice The ATA child device involved for the operation.
+
+**/
+VOID
+EFIAPI
+AtaTerminateNonBlockingTask (
+ IN ATA_DEVICE *AtaDevice
+ )
+{
+ BOOLEAN SubTaskEmpty;
+ EFI_TPL OldTpl;
+ ATA_BUS_ASYN_TASK *AtaTask;
+ LIST_ENTRY *Entry;
+ LIST_ENTRY *List;
+
+ OldTpl = gBS->RaiseTPL (TPL_NOTIFY);
+ //
+ // Abort all executing tasks from now.
+ //
+ AtaDevice->Abort = TRUE;
+
+ List = &AtaDevice->AtaTaskList;
+ for (Entry = GetFirstNode (List); !IsNull (List, Entry);) {
+ AtaTask = ATA_ASYN_TASK_FROM_ENTRY (Entry);
+ AtaTask->Token->TransactionStatus = EFI_ABORTED;
+ gBS->SignalEvent (AtaTask->Token->Event);
+
+ Entry = RemoveEntryList (Entry);
+ FreePool (AtaTask);
+ }
+ gBS->RestoreTPL (OldTpl);
+
+ do {
+ OldTpl = gBS->RaiseTPL (TPL_NOTIFY);
+ //
+ // Wait for executing subtasks done.
+ //
+ SubTaskEmpty = IsListEmpty (&AtaDevice->AtaSubTaskList);
+ gBS->RestoreTPL (OldTpl);
+ } while (!SubTaskEmpty);
+
+ //
+ // Aborting operation has been done. From now on, don't need to abort normal operation.
+ //
+ OldTpl = gBS->RaiseTPL (TPL_NOTIFY);
+ AtaDevice->Abort = FALSE;
+ gBS->RestoreTPL (OldTpl);
+}
+
+/**
Call back funtion when the event is signaled.
@param[in] Event The Event this notify function registered to.
@@ -617,6 +673,11 @@ AtaNonBlockingCallBack (
if ((!(*Task->IsError)) && ((Task->Packet.Asb->AtaStatus & 0x01) == 0x01)) {
Task->Token->TransactionStatus = EFI_DEVICE_ERROR;
}
+
+ if (AtaDevice->Abort) {
+ Task->Token->TransactionStatus = EFI_ABORTED;
+ }
+
DEBUG ((
EFI_D_BLKIO,
"NON-BLOCKING EVENT FINISHED!- STATUS = %r\n",
@@ -652,7 +713,7 @@ AtaNonBlockingCallBack (
//
if (!IsListEmpty (&AtaDevice->AtaTaskList)) {
Entry = GetFirstNode (&AtaDevice->AtaTaskList);
- AtaTask = ATA_AYNS_TASK_FROM_ENTRY (Entry);
+ AtaTask = ATA_ASYN_TASK_FROM_ENTRY (Entry);
DEBUG ((EFI_D_BLKIO, "Start to embark a new Ata Task\n"));
DEBUG ((EFI_D_BLKIO, "AtaTask->NumberOfBlocks = %x; AtaTask->Token=%x\n", AtaTask->NumberOfBlocks, AtaTask->Token));
Status = AccessAtaDevice (
@@ -737,7 +798,7 @@ AccessAtaDevice(
SubTask = NULL;
SubEvent = NULL;
AtaTask = NULL;
-
+
//
// Ensure AtaDevice->Lba48Bit is a valid boolean value
//
@@ -750,6 +811,7 @@ AccessAtaDevice(
//
if ((Token != NULL) && (Token->Event != NULL)) {
OldTpl = gBS->RaiseTPL (TPL_NOTIFY);
+
if (!IsListEmpty (&AtaDevice->AtaSubTaskList)) {
AtaTask = AllocateZeroPool (sizeof (ATA_BUS_ASYN_TASK));
if (AtaTask == NULL) {
@@ -788,7 +850,7 @@ AccessAtaDevice(
DEBUG ((EFI_D_BLKIO, "AccessAtaDevice, NumberOfBlocks=%x\n", NumberOfBlocks));
DEBUG ((EFI_D_BLKIO, "AccessAtaDevice, MaxTransferBlockNumber=%x\n", MaxTransferBlockNumber));
DEBUG ((EFI_D_BLKIO, "AccessAtaDevice, EventCount=%x\n", TempCount));
- }else {
+ } else {
while (!IsListEmpty (&AtaDevice->AtaTaskList) || !IsListEmpty (&AtaDevice->AtaSubTaskList)) {
//
// Stall for 100us.
diff --git a/MdeModulePkg/Bus/Pci/NvmExpressDxe/NvmExpress.c b/MdeModulePkg/Bus/Pci/NvmExpressDxe/NvmExpress.c
index b6729ce71..ed1c4bf39 100644
--- a/MdeModulePkg/Bus/Pci/NvmExpressDxe/NvmExpress.c
+++ b/MdeModulePkg/Bus/Pci/NvmExpressDxe/NvmExpress.c
@@ -215,6 +215,15 @@ EnumerateNvmeDevNamespace (
);
//
+ // Dump NvmExpress Identify Namespace Data
+ //
+ DEBUG ((EFI_D_INFO, " == NVME IDENTIFY NAMESPACE [%d] DATA ==\n", NamespaceId));
+ DEBUG ((EFI_D_INFO, " NSZE : 0x%x\n", NamespaceData->Nsze));
+ DEBUG ((EFI_D_INFO, " NCAP : 0x%x\n", NamespaceData->Ncap));
+ DEBUG ((EFI_D_INFO, " NUSE : 0x%x\n", NamespaceData->Nuse));
+ DEBUG ((EFI_D_INFO, " LBAF0.LBADS : 0x%x\n", (NamespaceData->LbaFormat[0].Lbads)));
+
+ //
// Build controller name for Component Name (2) protocol.
//
UnicodeSPrintAsciiFormat (Device->ModelName, sizeof (Device->ModelName), "%a-%a-%x", Private->ControllerData->Sn, Private->ControllerData->Mn, NamespaceData->Eui64);
@@ -657,7 +666,7 @@ NvmExpressDriverBindingStart (
PciIo,
AllocateAnyPages,
EfiBootServicesData,
- 6,
+ 4,
(VOID**)&Private->Buffer,
0
);
diff --git a/MdeModulePkg/Bus/Pci/NvmExpressDxe/NvmExpress.h b/MdeModulePkg/Bus/Pci/NvmExpressDxe/NvmExpress.h
index d39b62e10..79ab927ed 100644
--- a/MdeModulePkg/Bus/Pci/NvmExpressDxe/NvmExpress.h
+++ b/MdeModulePkg/Bus/Pci/NvmExpressDxe/NvmExpress.h
@@ -56,11 +56,11 @@ extern EFI_DRIVER_SUPPORTED_EFI_VERSION_PROTOCOL gNvmExpressDriverSupportedEfiV
#define PCI_CLASS_MASS_STORAGE_NVM 0x08 // mass storage sub-class non-volatile memory.
#define PCI_IF_NVMHCI 0x02 // mass storage programming interface NVMHCI.
-#define NVME_ASQ_SIZE 2 // Number of admin submission queue entries
-#define NVME_ACQ_SIZE 2 // Number of admin completion queue entries
+#define NVME_ASQ_SIZE 1 // Number of admin submission queue entries, which is 0-based
+#define NVME_ACQ_SIZE 1 // Number of admin completion queue entries, which is 0-based
-#define NVME_CSQ_SIZE 2 // Number of I/O submission queue entries
-#define NVME_CCQ_SIZE 2 // Number of I/O completion queue entries
+#define NVME_CSQ_SIZE 1 // Number of I/O submission queue entries, which is 0-based
+#define NVME_CCQ_SIZE 1 // Number of I/O completion queue entries, which is 0-based
#define NVME_MAX_IO_QUEUES 2 // Number of I/O queues supported by the driver
diff --git a/MdeModulePkg/Bus/Pci/NvmExpressDxe/NvmExpressBlockIo.c b/MdeModulePkg/Bus/Pci/NvmExpressDxe/NvmExpressBlockIo.c
index 458afd232..c1aad6b81 100644
--- a/MdeModulePkg/Bus/Pci/NvmExpressDxe/NvmExpressBlockIo.c
+++ b/MdeModulePkg/Bus/Pci/NvmExpressDxe/NvmExpressBlockIo.c
@@ -172,10 +172,12 @@ NvmeRead (
UINT32 BlockSize;
NVME_CONTROLLER_PRIVATE_DATA *Controller;
UINT32 MaxTransferBlocks;
+ UINTN OrginalBlocks;
- Status = EFI_SUCCESS;
- Controller = Device->Controller;
- BlockSize = Device->Media.BlockSize;
+ Status = EFI_SUCCESS;
+ Controller = Device->Controller;
+ BlockSize = Device->Media.BlockSize;
+ OrginalBlocks = Blocks;
if (Controller->ControllerData->Mdts != 0) {
MaxTransferBlocks = (1 << (Controller->ControllerData->Mdts)) * (1 << (Controller->Cap.Mpsmin + 12)) / BlockSize;
@@ -200,7 +202,7 @@ NvmeRead (
}
}
- DEBUG ((EFI_D_INFO, "NvmeRead() Lba = %8d, Blocks = %8d, BlockSize = %d Status = %r\n", Lba, Blocks, BlockSize, Status));
+ DEBUG ((EFI_D_INFO, "NvmeRead() Lba = 0x%08x, Original = 0x%08x, Remaining = 0x%08x, BlockSize = 0x%x Status = %r\n", Lba, OrginalBlocks, Blocks, BlockSize, Status));
return Status;
}
@@ -229,10 +231,12 @@ NvmeWrite (
UINT32 BlockSize;
NVME_CONTROLLER_PRIVATE_DATA *Controller;
UINT32 MaxTransferBlocks;
+ UINTN OrginalBlocks;
- Status = EFI_SUCCESS;
- Controller = Device->Controller;
- BlockSize = Device->Media.BlockSize;
+ Status = EFI_SUCCESS;
+ Controller = Device->Controller;
+ BlockSize = Device->Media.BlockSize;
+ OrginalBlocks = Blocks;
if (Controller->ControllerData->Mdts != 0) {
MaxTransferBlocks = (1 << (Controller->ControllerData->Mdts)) * (1 << (Controller->Cap.Mpsmin + 12)) / BlockSize;
@@ -257,7 +261,7 @@ NvmeWrite (
}
}
- DEBUG ((EFI_D_INFO, "NvmeWrite() Lba = %8d, Blocks = %8d, BlockSize = %d Status = %r\n", Lba, Blocks, BlockSize, Status));
+ DEBUG ((EFI_D_INFO, "NvmeWrite() Lba = 0x%08x, Original = 0x%08x, Remaining = 0x%08x, BlockSize = 0x%x Status = %r\n", Lba, OrginalBlocks, Blocks, BlockSize, Status));
return Status;
}
diff --git a/MdeModulePkg/Bus/Pci/NvmExpressDxe/NvmExpressHci.c b/MdeModulePkg/Bus/Pci/NvmExpressDxe/NvmExpressHci.c
index 157e10127..62eb39a7d 100644
--- a/MdeModulePkg/Bus/Pci/NvmExpressDxe/NvmExpressHci.c
+++ b/MdeModulePkg/Bus/Pci/NvmExpressDxe/NvmExpressHci.c
@@ -33,21 +33,23 @@ ReadNvmeControllerCapabilities (
{
EFI_PCI_IO_PROTOCOL *PciIo;
EFI_STATUS Status;
+ UINT64 Data;
PciIo = Private->PciIo;
Status = PciIo->Mem.Read (
PciIo,
- EfiPciIoWidthUint64,
+ EfiPciIoWidthUint32,
NVME_BAR,
NVME_CAP_OFFSET,
- 1,
- Cap
+ 2,
+ &Data
);
if (EFI_ERROR(Status)) {
return Status;
}
+ WriteUnaligned64 ((UINT64*)Cap, Data);
return EFI_SUCCESS;
}
@@ -69,6 +71,7 @@ ReadNvmeControllerConfiguration (
{
EFI_PCI_IO_PROTOCOL *PciIo;
EFI_STATUS Status;
+ UINT32 Data;
PciIo = Private->PciIo;
Status = PciIo->Mem.Read (
@@ -77,13 +80,14 @@ ReadNvmeControllerConfiguration (
NVME_BAR,
NVME_CC_OFFSET,
1,
- Cc
+ &Data
);
if (EFI_ERROR(Status)) {
return Status;
}
+ WriteUnaligned32 ((UINT32*)Cc, Data);
return EFI_SUCCESS;
}
@@ -105,15 +109,17 @@ WriteNvmeControllerConfiguration (
{
EFI_PCI_IO_PROTOCOL *PciIo;
EFI_STATUS Status;
+ UINT32 Data;
PciIo = Private->PciIo;
+ Data = ReadUnaligned32 ((UINT32*)Cc);
Status = PciIo->Mem.Write (
PciIo,
EfiPciIoWidthUint32,
NVME_BAR,
NVME_CC_OFFSET,
1,
- Cc
+ &Data
);
if (EFI_ERROR(Status)) {
@@ -149,6 +155,7 @@ ReadNvmeControllerStatus (
{
EFI_PCI_IO_PROTOCOL *PciIo;
EFI_STATUS Status;
+ UINT32 Data;
PciIo = Private->PciIo;
Status = PciIo->Mem.Read (
@@ -157,13 +164,14 @@ ReadNvmeControllerStatus (
NVME_BAR,
NVME_CSTS_OFFSET,
1,
- Csts
+ &Data
);
if (EFI_ERROR(Status)) {
return Status;
}
+ WriteUnaligned32 ((UINT32*)Csts, Data);
return EFI_SUCCESS;
}
@@ -185,6 +193,7 @@ ReadNvmeAdminQueueAttributes (
{
EFI_PCI_IO_PROTOCOL *PciIo;
EFI_STATUS Status;
+ UINT32 Data;
PciIo = Private->PciIo;
Status = PciIo->Mem.Read (
@@ -193,13 +202,14 @@ ReadNvmeAdminQueueAttributes (
NVME_BAR,
NVME_AQA_OFFSET,
1,
- Aqa
+ &Data
);
if (EFI_ERROR(Status)) {
return Status;
}
+ WriteUnaligned32 ((UINT32*)Aqa, Data);
return EFI_SUCCESS;
}
@@ -221,15 +231,17 @@ WriteNvmeAdminQueueAttributes (
{
EFI_PCI_IO_PROTOCOL *PciIo;
EFI_STATUS Status;
+ UINT32 Data;
PciIo = Private->PciIo;
+ Data = ReadUnaligned32 ((UINT32*)Aqa);
Status = PciIo->Mem.Write (
PciIo,
EfiPciIoWidthUint32,
NVME_BAR,
NVME_AQA_OFFSET,
1,
- Aqa
+ &Data
);
if (EFI_ERROR(Status)) {
@@ -260,21 +272,23 @@ ReadNvmeAdminSubmissionQueueBaseAddress (
{
EFI_PCI_IO_PROTOCOL *PciIo;
EFI_STATUS Status;
+ UINT64 Data;
PciIo = Private->PciIo;
Status = PciIo->Mem.Read (
PciIo,
- EfiPciIoWidthUint64,
+ EfiPciIoWidthUint32,
NVME_BAR,
NVME_ASQ_OFFSET,
- 1,
- Asq
+ 2,
+ &Data
);
if (EFI_ERROR(Status)) {
return Status;
}
+ WriteUnaligned64 ((UINT64*)Asq, Data);
return EFI_SUCCESS;
}
@@ -296,15 +310,18 @@ WriteNvmeAdminSubmissionQueueBaseAddress (
{
EFI_PCI_IO_PROTOCOL *PciIo;
EFI_STATUS Status;
+ UINT64 Data;
PciIo = Private->PciIo;
+ Data = ReadUnaligned64 ((UINT64*)Asq);
+
Status = PciIo->Mem.Write (
PciIo,
- EfiPciIoWidthUint64,
+ EfiPciIoWidthUint32,
NVME_BAR,
NVME_ASQ_OFFSET,
- 1,
- Asq
+ 2,
+ &Data
);
if (EFI_ERROR(Status)) {
@@ -334,21 +351,24 @@ ReadNvmeAdminCompletionQueueBaseAddress (
{
EFI_PCI_IO_PROTOCOL *PciIo;
EFI_STATUS Status;
+ UINT64 Data;
PciIo = Private->PciIo;
+
Status = PciIo->Mem.Read (
PciIo,
- EfiPciIoWidthUint64,
+ EfiPciIoWidthUint32,
NVME_BAR,
NVME_ACQ_OFFSET,
- 1,
- Acq
+ 2,
+ &Data
);
if (EFI_ERROR(Status)) {
return Status;
}
+ WriteUnaligned64 ((UINT64*)Acq, Data);
return EFI_SUCCESS;
}
@@ -370,15 +390,18 @@ WriteNvmeAdminCompletionQueueBaseAddress (
{
EFI_PCI_IO_PROTOCOL *PciIo;
EFI_STATUS Status;
+ UINT64 Data;
PciIo = Private->PciIo;
+ Data = ReadUnaligned64 ((UINT64*)Acq);
+
Status = PciIo->Mem.Write (
PciIo,
- EfiPciIoWidthUint64,
+ EfiPciIoWidthUint32,
NVME_BAR,
NVME_ACQ_OFFSET,
- 1,
- Acq
+ 2,
+ &Data
);
if (EFI_ERROR(Status)) {
@@ -819,8 +842,10 @@ NvmeControllerInit (
//
// set number of entries admin submission & completion queues.
//
- Aqa.Asqs = NVME_ASQ_SIZE;
- Aqa.Acqs = NVME_ACQ_SIZE;
+ Aqa.Asqs = NVME_ASQ_SIZE;
+ Aqa.Rsvd1 = 0;
+ Aqa.Acqs = NVME_ACQ_SIZE;
+ Aqa.Rsvd2 = 0;
//
// Address of admin submission queue.
@@ -921,6 +946,25 @@ NvmeControllerInit (
Private->ControllerData = NULL;
return EFI_NOT_FOUND;
}
+
+ //
+ // Dump NvmExpress Identify Controller Data
+ //
+ Private->ControllerData->Sn[19] = 0;
+ Private->ControllerData->Mn[39] = 0;
+ DEBUG ((EFI_D_INFO, " == NVME IDENTIFY CONTROLLER DATA ==\n"));
+ DEBUG ((EFI_D_INFO, " PCI VID : 0x%x\n", Private->ControllerData->Vid));
+ DEBUG ((EFI_D_INFO, " PCI SSVID : 0x%x\n", Private->ControllerData->Ssvid));
+ DEBUG ((EFI_D_INFO, " SN : %a\n", (CHAR8 *)(Private->ControllerData->Sn)));
+ DEBUG ((EFI_D_INFO, " MN : %a\n", (CHAR8 *)(Private->ControllerData->Mn)));
+ DEBUG ((EFI_D_INFO, " FR : 0x%x\n", *((UINT64*)Private->ControllerData->Fr)));
+ DEBUG ((EFI_D_INFO, " RAB : 0x%x\n", Private->ControllerData->Rab));
+ DEBUG ((EFI_D_INFO, " IEEE : 0x%x\n", *(UINT32*)Private->ControllerData->Ieee_oiu));
+ DEBUG ((EFI_D_INFO, " AERL : 0x%x\n", Private->ControllerData->Aerl));
+ DEBUG ((EFI_D_INFO, " SQES : 0x%x\n", Private->ControllerData->Sqes));
+ DEBUG ((EFI_D_INFO, " CQES : 0x%x\n", Private->ControllerData->Cqes));
+ DEBUG ((EFI_D_INFO, " NN : 0x%x\n", Private->ControllerData->Nn));
+
return Status;
}
diff --git a/MdeModulePkg/Bus/Pci/NvmExpressDxe/NvmExpressPassthru.c b/MdeModulePkg/Bus/Pci/NvmExpressDxe/NvmExpressPassthru.c
index d1231aca8..4320549ed 100644
--- a/MdeModulePkg/Bus/Pci/NvmExpressDxe/NvmExpressPassthru.c
+++ b/MdeModulePkg/Bus/Pci/NvmExpressDxe/NvmExpressPassthru.c
@@ -387,6 +387,7 @@ NvmExpressPassThru (
UINT64 *Prp;
VOID *PrpListHost;
UINTN PrpListNo;
+ UINT32 Data;
//
// check the data fields in Packet parameter.
@@ -431,8 +432,8 @@ NvmExpressPassThru (
//
// Currently we only support PRP for data transfer, SGL is NOT supported.
//
- ASSERT ((Sq->Opc & BIT15) == 0);
- if ((Sq->Opc & BIT15) != 0) {
+ ASSERT (Sq->Psdt == 0);
+ if (Sq->Psdt != 0) {
DEBUG ((EFI_D_ERROR, "NvmExpressPassThru: doesn't support SGL mechanism\n"));
return EFI_UNSUPPORTED;
}
@@ -534,14 +535,14 @@ NvmExpressPassThru (
// Ring the submission queue doorbell.
//
Private->SqTdbl[Qid].Sqt ^= 1;
-
+ Data = ReadUnaligned32 ((UINT32*)&Private->SqTdbl[Qid]);
PciIo->Mem.Write (
PciIo,
EfiPciIoWidthUint32,
NVME_BAR,
NVME_SQTDBL_OFFSET(Qid, Private->Cap.Dstrd),
1,
- &Private->SqTdbl[Qid]
+ &Data
);
Status = gBS->CreateEvent (
@@ -591,13 +592,14 @@ NvmExpressPassThru (
NvmeDumpStatus(Cq);
DEBUG_CODE_END();
+ Data = ReadUnaligned32 ((UINT32*)&Private->CqHdbl[Qid]);
PciIo->Mem.Write (
PciIo,
EfiPciIoWidthUint32,
NVME_BAR,
NVME_CQHDBL_OFFSET(Qid, Private->Cap.Dstrd),
1,
- &Private->CqHdbl[Qid]
+ &Data
);
EXIT:
diff --git a/MdeModulePkg/Bus/Pci/UhciDxe/UhciDebug.c b/MdeModulePkg/Bus/Pci/UhciDxe/UhciDebug.c
index 4e9b534e7..9bf53fd41 100644
--- a/MdeModulePkg/Bus/Pci/UhciDxe/UhciDebug.c
+++ b/MdeModulePkg/Bus/Pci/UhciDxe/UhciDebug.c
@@ -26,12 +26,12 @@ UhciDumpQh (
IN UHCI_QH_SW *QhSw
)
{
- DEBUG ((EFI_D_INFO, "&QhSw @ 0x%p\n", QhSw));
- DEBUG ((EFI_D_INFO, "QhSw.NextQh - 0x%p\n", QhSw->NextQh));
- DEBUG ((EFI_D_INFO, "QhSw.TDs - 0x%p\n", QhSw->TDs));
- DEBUG ((EFI_D_INFO, "QhSw.QhHw:\n"));
- DEBUG ((EFI_D_INFO, " Horizon Link - %x\n", QhSw->QhHw.HorizonLink));
- DEBUG ((EFI_D_INFO, " Vertical Link - %x\n\n", QhSw->QhHw.VerticalLink));
+ DEBUG ((EFI_D_VERBOSE, "&QhSw @ 0x%p\n", QhSw));
+ DEBUG ((EFI_D_VERBOSE, "QhSw.NextQh - 0x%p\n", QhSw->NextQh));
+ DEBUG ((EFI_D_VERBOSE, "QhSw.TDs - 0x%p\n", QhSw->TDs));
+ DEBUG ((EFI_D_VERBOSE, "QhSw.QhHw:\n"));
+ DEBUG ((EFI_D_VERBOSE, " Horizon Link - %x\n", QhSw->QhHw.HorizonLink));
+ DEBUG ((EFI_D_VERBOSE, " Vertical Link - %x\n\n", QhSw->QhHw.VerticalLink));
}
@@ -51,25 +51,25 @@ UhciDumpTds (
CurTdSw = TdSw;
while (CurTdSw != NULL) {
- DEBUG ((EFI_D_INFO, "TdSw @ 0x%p\n", CurTdSw));
- DEBUG ((EFI_D_INFO, "TdSw.NextTd - 0x%p\n", CurTdSw->NextTd));
- DEBUG ((EFI_D_INFO, "TdSw.DataLen - %d\n", CurTdSw->DataLen));
- DEBUG ((EFI_D_INFO, "TdSw.Data - 0x%p\n", CurTdSw->Data));
- DEBUG ((EFI_D_INFO, "TdHw:\n"));
- DEBUG ((EFI_D_INFO, " NextLink - 0x%x\n", CurTdSw->TdHw.NextLink));
- DEBUG ((EFI_D_INFO, " ActualLen - %d\n", CurTdSw->TdHw.ActualLen));
- DEBUG ((EFI_D_INFO, " Status - 0x%x\n", CurTdSw->TdHw.Status));
- DEBUG ((EFI_D_INFO, " IOC - %d\n", CurTdSw->TdHw.IntOnCpl));
- DEBUG ((EFI_D_INFO, " IsIsoCh - %d\n", CurTdSw->TdHw.IsIsoch));
- DEBUG ((EFI_D_INFO, " LowSpeed - %d\n", CurTdSw->TdHw.LowSpeed));
- DEBUG ((EFI_D_INFO, " ErrorCount - %d\n", CurTdSw->TdHw.ErrorCount));
- DEBUG ((EFI_D_INFO, " ShortPacket - %d\n", CurTdSw->TdHw.ShortPacket));
- DEBUG ((EFI_D_INFO, " PidCode - 0x%x\n", CurTdSw->TdHw.PidCode));
- DEBUG ((EFI_D_INFO, " DevAddr - %d\n", CurTdSw->TdHw.DeviceAddr));
- DEBUG ((EFI_D_INFO, " EndPoint - %d\n", CurTdSw->TdHw.EndPoint));
- DEBUG ((EFI_D_INFO, " DataToggle - %d\n", CurTdSw->TdHw.DataToggle));
- DEBUG ((EFI_D_INFO, " MaxPacketLen - %d\n", CurTdSw->TdHw.MaxPacketLen));
- DEBUG ((EFI_D_INFO, " DataBuffer - 0x%x\n\n",CurTdSw->TdHw.DataBuffer));
+ DEBUG ((EFI_D_VERBOSE, "TdSw @ 0x%p\n", CurTdSw));
+ DEBUG ((EFI_D_VERBOSE, "TdSw.NextTd - 0x%p\n", CurTdSw->NextTd));
+ DEBUG ((EFI_D_VERBOSE, "TdSw.DataLen - %d\n", CurTdSw->DataLen));
+ DEBUG ((EFI_D_VERBOSE, "TdSw.Data - 0x%p\n", CurTdSw->Data));
+ DEBUG ((EFI_D_VERBOSE, "TdHw:\n"));
+ DEBUG ((EFI_D_VERBOSE, " NextLink - 0x%x\n", CurTdSw->TdHw.NextLink));
+ DEBUG ((EFI_D_VERBOSE, " ActualLen - %d\n", CurTdSw->TdHw.ActualLen));
+ DEBUG ((EFI_D_VERBOSE, " Status - 0x%x\n", CurTdSw->TdHw.Status));
+ DEBUG ((EFI_D_VERBOSE, " IOC - %d\n", CurTdSw->TdHw.IntOnCpl));
+ DEBUG ((EFI_D_VERBOSE, " IsIsoCh - %d\n", CurTdSw->TdHw.IsIsoch));
+ DEBUG ((EFI_D_VERBOSE, " LowSpeed - %d\n", CurTdSw->TdHw.LowSpeed));
+ DEBUG ((EFI_D_VERBOSE, " ErrorCount - %d\n", CurTdSw->TdHw.ErrorCount));
+ DEBUG ((EFI_D_VERBOSE, " ShortPacket - %d\n", CurTdSw->TdHw.ShortPacket));
+ DEBUG ((EFI_D_VERBOSE, " PidCode - 0x%x\n", CurTdSw->TdHw.PidCode));
+ DEBUG ((EFI_D_VERBOSE, " DevAddr - %d\n", CurTdSw->TdHw.DeviceAddr));
+ DEBUG ((EFI_D_VERBOSE, " EndPoint - %d\n", CurTdSw->TdHw.EndPoint));
+ DEBUG ((EFI_D_VERBOSE, " DataToggle - %d\n", CurTdSw->TdHw.DataToggle));
+ DEBUG ((EFI_D_VERBOSE, " MaxPacketLen - %d\n", CurTdSw->TdHw.MaxPacketLen));
+ DEBUG ((EFI_D_VERBOSE, " DataBuffer - 0x%x\n\n",CurTdSw->TdHw.DataBuffer));
CurTdSw = CurTdSw->NextTd;
}
diff --git a/MdeModulePkg/Bus/Pci/XhciDxe/Xhci.c b/MdeModulePkg/Bus/Pci/XhciDxe/Xhci.c
index 3e578975a..443df729d 100644
--- a/MdeModulePkg/Bus/Pci/XhciDxe/Xhci.c
+++ b/MdeModulePkg/Bus/Pci/XhciDxe/Xhci.c
@@ -164,6 +164,11 @@ XhcReset (
// Flow through, same behavior as Host Controller Reset
//
case EFI_USB_HC_RESET_HOST_CONTROLLER:
+ if ((Xhc->DebugCapSupOffset != 0xFFFFFFFF) && ((XhcReadExtCapReg (Xhc, Xhc->DebugCapSupOffset) & 0xFF) == XHC_CAP_USB_DEBUG) &&
+ ((XhcReadExtCapReg (Xhc, Xhc->DebugCapSupOffset + XHC_DC_DCCTRL) & BIT0) != 0)) {
+ Status = EFI_SUCCESS;
+ goto ON_EXIT;
+ }
//
// Host Controller must be Halt when Reset it
//
@@ -1755,7 +1760,8 @@ XhcCreateUsbHc (
ExtCapReg = (UINT16) (Xhc->HcCParams.Data.ExtCapReg);
Xhc->ExtCapRegBase = ExtCapReg << 2;
- Xhc->UsbLegSupOffset = XhcGetLegSupCapAddr (Xhc);
+ Xhc->UsbLegSupOffset = XhcGetCapabilityAddr (Xhc, XHC_CAP_USB_LEGACY);
+ Xhc->DebugCapSupOffset = XhcGetCapabilityAddr (Xhc, XHC_CAP_USB_DEBUG);
DEBUG ((EFI_D_INFO, "XhcCreateUsb3Hc: Capability length 0x%x\n", Xhc->CapLength));
DEBUG ((EFI_D_INFO, "XhcCreateUsb3Hc: HcSParams1 0x%x\n", Xhc->HcSParams1));
@@ -1764,6 +1770,7 @@ XhcCreateUsbHc (
DEBUG ((EFI_D_INFO, "XhcCreateUsb3Hc: DBOff 0x%x\n", Xhc->DBOff));
DEBUG ((EFI_D_INFO, "XhcCreateUsb3Hc: RTSOff 0x%x\n", Xhc->RTSOff));
DEBUG ((EFI_D_INFO, "XhcCreateUsb3Hc: UsbLegSupOffset 0x%x\n", Xhc->UsbLegSupOffset));
+ DEBUG ((EFI_D_INFO, "XhcCreateUsb3Hc: DebugCapSupOffset 0x%x\n", Xhc->DebugCapSupOffset));
//
// Create AsyncRequest Polling Timer
diff --git a/MdeModulePkg/Bus/Pci/XhciDxe/Xhci.h b/MdeModulePkg/Bus/Pci/XhciDxe/Xhci.h
index fab6a7296..1eb0d0e17 100644
--- a/MdeModulePkg/Bus/Pci/XhciDxe/Xhci.h
+++ b/MdeModulePkg/Bus/Pci/XhciDxe/Xhci.h
@@ -231,6 +231,7 @@ struct _USB_XHCI_INSTANCE {
UINTN *ScratchEntryMap;
UINT32 ExtCapRegBase;
UINT32 UsbLegSupOffset;
+ UINT32 DebugCapSupOffset;
UINT64 *DCBAA;
VOID *DCBAAMap;
UINT32 MaxSlotsEn;
diff --git a/MdeModulePkg/Bus/Pci/XhciDxe/XhciReg.c b/MdeModulePkg/Bus/Pci/XhciDxe/XhciReg.c
index 9d50ef824..a66d7cd95 100644
--- a/MdeModulePkg/Bus/Pci/XhciDxe/XhciReg.c
+++ b/MdeModulePkg/Bus/Pci/XhciDxe/XhciReg.c
@@ -543,6 +543,10 @@ XhcSetBiosOwnership (
{
UINT32 Buffer;
+ if (Xhc->UsbLegSupOffset == 0xFFFFFFFF) {
+ return;
+ }
+
DEBUG ((EFI_D_INFO, "XhcSetBiosOwnership: called to set BIOS ownership\n"));
Buffer = XhcReadExtCapReg (Xhc, Xhc->UsbLegSupOffset);
@@ -563,6 +567,10 @@ XhcClearBiosOwnership (
{
UINT32 Buffer;
+ if (Xhc->UsbLegSupOffset == 0xFFFFFFFF) {
+ return;
+ }
+
DEBUG ((EFI_D_INFO, "XhcClearBiosOwnership: called to clear BIOS ownership\n"));
Buffer = XhcReadExtCapReg (Xhc, Xhc->UsbLegSupOffset);
@@ -571,16 +579,18 @@ XhcClearBiosOwnership (
}
/**
- Calculate the XHCI legacy support capability register offset.
+ Calculate the offset of the XHCI capability.
@param Xhc The XHCI Instance.
+ @param CapId The XHCI Capability ID.
@return The offset of XHCI legacy support capability register.
**/
UINT32
-XhcGetLegSupCapAddr (
- IN USB_XHCI_INSTANCE *Xhc
+XhcGetCapabilityAddr (
+ IN USB_XHCI_INSTANCE *Xhc,
+ IN UINT8 CapId
)
{
UINT32 ExtCapOffset;
@@ -594,7 +604,7 @@ XhcGetLegSupCapAddr (
// Check if the extended capability register's capability id is USB Legacy Support.
//
Data = XhcReadExtCapReg (Xhc, ExtCapOffset);
- if ((Data & 0xFF) == 0x1) {
+ if ((Data & 0xFF) == CapId) {
return ExtCapOffset;
}
//
@@ -604,7 +614,7 @@ XhcGetLegSupCapAddr (
ExtCapOffset += (NextExtCapReg << 2);
} while (NextExtCapReg != 0);
- return 0;
+ return 0xFFFFFFFF;
}
/**
@@ -660,6 +670,8 @@ XhcResetHC (
{
EFI_STATUS Status;
+ Status = EFI_SUCCESS;
+
DEBUG ((EFI_D_INFO, "XhcResetHC!\n"));
//
// Host can only be reset when it is halt. If not so, halt it
@@ -672,8 +684,12 @@ XhcResetHC (
}
}
- XhcSetOpRegBit (Xhc, XHC_USBCMD_OFFSET, XHC_USBCMD_RESET);
- Status = XhcWaitOpRegBit (Xhc, XHC_USBCMD_OFFSET, XHC_USBCMD_RESET, FALSE, Timeout);
+ if ((Xhc->DebugCapSupOffset == 0xFFFFFFFF) || ((XhcReadExtCapReg (Xhc, Xhc->DebugCapSupOffset) & 0xFF) != XHC_CAP_USB_DEBUG) ||
+ ((XhcReadExtCapReg (Xhc, Xhc->DebugCapSupOffset + XHC_DC_DCCTRL) & BIT0) == 0)) {
+ XhcSetOpRegBit (Xhc, XHC_USBCMD_OFFSET, XHC_USBCMD_RESET);
+ Status = XhcWaitOpRegBit (Xhc, XHC_USBCMD_OFFSET, XHC_USBCMD_RESET, FALSE, Timeout);
+ }
+
return Status;
}
diff --git a/MdeModulePkg/Bus/Pci/XhciDxe/XhciReg.h b/MdeModulePkg/Bus/Pci/XhciDxe/XhciReg.h
index eea468bbd..20a5510bf 100644
--- a/MdeModulePkg/Bus/Pci/XhciDxe/XhciReg.h
+++ b/MdeModulePkg/Bus/Pci/XhciDxe/XhciReg.h
@@ -29,6 +29,9 @@ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
#define USB_HUB_CLASS_CODE 0x09
#define USB_HUB_SUBCLASS_CODE 0x00
+#define XHC_CAP_USB_LEGACY 0x01
+#define XHC_CAP_USB_DEBUG 0x0A
+
//============================================//
// XHCI register offset //
//============================================//
@@ -67,6 +70,11 @@ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
#define XHC_ERSTBA_OFFSET 0x30 // Event Ring Segment Table Base Address Register Offset
#define XHC_ERDP_OFFSET 0x38 // Event Ring Dequeue Pointer Register Offset
+//
+// Debug registers offset
+//
+#define XHC_DC_DCCTRL 0x20
+
#define USBLEGSP_BIOS_SEMAPHORE BIT16 // HC BIOS Owned Semaphore
#define USBLEGSP_OS_SEMAPHORE BIT24 // HC OS Owned Semaphore
@@ -448,6 +456,21 @@ XhcClearRuntimeRegBit (
);
/**
+ Read XHCI extended capability register.
+
+ @param Xhc The XHCI Instance.
+ @param Offset The offset of the extended capability register.
+
+ @return The register content read
+
+**/
+UINT32
+XhcReadExtCapReg (
+ IN USB_XHCI_INSTANCE *Xhc,
+ IN UINT32 Offset
+ );
+
+/**
Whether the XHCI host controller is halted.
@param Xhc The XHCI Instance.
@@ -524,16 +547,18 @@ XhcRunHC (
);
/**
- Calculate the XHCI legacy support capability register offset.
+ Calculate the offset of the XHCI capability.
@param Xhc The XHCI Instance.
+ @param CapId The XHCI Capability ID.
@return The offset of XHCI legacy support capability register.
**/
UINT32
-XhcGetLegSupCapAddr (
- IN USB_XHCI_INSTANCE *Xhc
+XhcGetCapabilityAddr (
+ IN USB_XHCI_INSTANCE *Xhc,
+ IN UINT8 CapId
);
#endif
diff --git a/MdeModulePkg/Bus/Usb/UsbBusDxe/UsbDesc.c b/MdeModulePkg/Bus/Usb/UsbBusDxe/UsbDesc.c
index 1713e3c42..b2401ca40 100644
--- a/MdeModulePkg/Bus/Usb/UsbBusDxe/UsbDesc.c
+++ b/MdeModulePkg/Bus/Usb/UsbBusDxe/UsbDesc.c
@@ -847,7 +847,7 @@ UsbBuildDescTable (
Status = UsbBuildLangTable (UsbDev);
if (EFI_ERROR (Status)) {
- DEBUG (( EFI_D_ERROR, "UsbBuildDescTable: get language ID table %r\n", Status));
+ DEBUG (( EFI_D_INFO, "UsbBuildDescTable: get language ID table %r\n", Status));
}
return EFI_SUCCESS;
diff --git a/MdeModulePkg/Bus/Usb/UsbBusDxe/UsbEnumer.c b/MdeModulePkg/Bus/Usb/UsbBusDxe/UsbEnumer.c
index 0aa896173..79635cb18 100644
--- a/MdeModulePkg/Bus/Usb/UsbBusDxe/UsbEnumer.c
+++ b/MdeModulePkg/Bus/Usb/UsbBusDxe/UsbEnumer.c
@@ -921,7 +921,7 @@ UsbEnumeratePort (
// Case4:
// Device connected or disconnected normally.
//
- DEBUG ((EFI_D_ERROR, "UsbEnumeratePort: Device Connect/Disconnect Normally\n", Port));
+ DEBUG ((EFI_D_INFO, "UsbEnumeratePort: Device Connect/Disconnect Normally\n", Port));
}
//
diff --git a/MdeModulePkg/Core/Dxe/Dispatcher/Dispatcher.c b/MdeModulePkg/Core/Dxe/Dispatcher/Dispatcher.c
index 75d6267f6..a70e2e45d 100644
--- a/MdeModulePkg/Core/Dxe/Dispatcher/Dispatcher.c
+++ b/MdeModulePkg/Core/Dxe/Dispatcher/Dispatcher.c
@@ -1036,39 +1036,48 @@ CoreProcessFvImageFile (
//
FvHeader = (EFI_FIRMWARE_VOLUME_HEADER *) Buffer;
//
- // Get FvHeader alignment
+ // If EFI_FVB2_WEAK_ALIGNMENT is set in the volume header then the first byte of the volume
+ // can be aligned on any power-of-two boundary. A weakly aligned volume can not be moved from
+ // its initial linked location and maintain its alignment.
//
- FvAlignment = 1 << ((FvHeader->Attributes & EFI_FVB2_ALIGNMENT) >> 16);
- //
- // FvAlignment must be greater than or equal to 8 bytes of the minimum FFS alignment value.
- //
- if (FvAlignment < 8) {
- FvAlignment = 8;
- }
- //
- // Allocate the aligned buffer for the FvImage.
- //
- AlignedBuffer = AllocateAlignedPages (EFI_SIZE_TO_PAGES (BufferSize), (UINTN) FvAlignment);
- if (AlignedBuffer == NULL) {
- Status = EFI_OUT_OF_RESOURCES;
- } else {
+ if ((FvHeader->Attributes & EFI_FVB2_WEAK_ALIGNMENT) != EFI_FVB2_WEAK_ALIGNMENT) {
//
- // Move FvImage into the aligned buffer and release the original buffer.
+ // Get FvHeader alignment
//
- CopyMem (AlignedBuffer, Buffer, BufferSize);
- CoreFreePool (Buffer);
- Buffer = NULL;
+ FvAlignment = 1 << ((FvHeader->Attributes & EFI_FVB2_ALIGNMENT) >> 16);
//
- // Produce a FVB protocol for the file
+ // FvAlignment must be greater than or equal to 8 bytes of the minimum FFS alignment value.
//
- Status = ProduceFVBProtocolOnBuffer (
- (EFI_PHYSICAL_ADDRESS) (UINTN) AlignedBuffer,
- (UINT64)BufferSize,
- FvHandle,
- AuthenticationStatus,
- NULL
- );
+ if (FvAlignment < 8) {
+ FvAlignment = 8;
+ }
+ //
+ // Allocate the aligned buffer for the FvImage.
+ //
+ AlignedBuffer = AllocateAlignedPages (EFI_SIZE_TO_PAGES (BufferSize), (UINTN) FvAlignment);
+ if (AlignedBuffer == NULL) {
+ FreePool (Buffer);
+ return EFI_OUT_OF_RESOURCES;
+ } else {
+ //
+ // Move FvImage into the aligned buffer and release the original buffer.
+ //
+ CopyMem (AlignedBuffer, Buffer, BufferSize);
+ FvHeader = (EFI_FIRMWARE_VOLUME_HEADER *) AlignedBuffer;
+ CoreFreePool (Buffer);
+ Buffer = NULL;
+ }
}
+ //
+ // Produce a FVB protocol for the file
+ //
+ Status = ProduceFVBProtocolOnBuffer (
+ (EFI_PHYSICAL_ADDRESS) (UINTN) FvHeader,
+ (UINT64)BufferSize,
+ FvHandle,
+ AuthenticationStatus,
+ NULL
+ );
}
if (EFI_ERROR (Status)) {
diff --git a/MdeModulePkg/Core/Dxe/FwVolBlock/FwVolBlock.c b/MdeModulePkg/Core/Dxe/FwVolBlock/FwVolBlock.c
index 523738d52..27a7f43fe 100644
--- a/MdeModulePkg/Core/Dxe/FwVolBlock/FwVolBlock.c
+++ b/MdeModulePkg/Core/Dxe/FwVolBlock/FwVolBlock.c
@@ -474,22 +474,31 @@ ProduceFVBProtocolOnBuffer (
if (FwVolHeader->Signature != EFI_FVH_SIGNATURE) {
return EFI_VOLUME_CORRUPTED;
}
+
//
- // Get FvHeader alignment
- //
- FvAlignment = 1 << ((FwVolHeader->Attributes & EFI_FVB2_ALIGNMENT) >> 16);
- //
- // FvAlignment must be greater than or equal to 8 bytes of the minimum FFS alignment value.
+ // If EFI_FVB2_WEAK_ALIGNMENT is set in the volume header then the first byte of the volume
+ // can be aligned on any power-of-two boundary. A weakly aligned volume can not be moved from
+ // its initial linked location and maintain its alignment.
//
- if (FvAlignment < 8) {
- FvAlignment = 8;
- }
- if ((UINTN)BaseAddress % FvAlignment != 0) {
+ if ((FwVolHeader->Attributes & EFI_FVB2_WEAK_ALIGNMENT) != EFI_FVB2_WEAK_ALIGNMENT) {
//
- // FvImage buffer is not at its required alignment.
+ // Get FvHeader alignment
//
- return EFI_VOLUME_CORRUPTED;
+ FvAlignment = 1 << ((FwVolHeader->Attributes & EFI_FVB2_ALIGNMENT) >> 16);
+ //
+ // FvAlignment must be greater than or equal to 8 bytes of the minimum FFS alignment value.
+ //
+ if (FvAlignment < 8) {
+ FvAlignment = 8;
+ }
+ if ((UINTN)BaseAddress % FvAlignment != 0) {
+ //
+ // FvImage buffer is not at its required alignment.
+ //
+ return EFI_VOLUME_CORRUPTED;
+ }
}
+
//
// Allocate EFI_FW_VOL_BLOCK_DEVICE
//
diff --git a/MdeModulePkg/Core/Pei/Dispatcher/Dispatcher.c b/MdeModulePkg/Core/Pei/Dispatcher/Dispatcher.c
index 2063fa4db..f4392b78d 100644
--- a/MdeModulePkg/Core/Pei/Dispatcher/Dispatcher.c
+++ b/MdeModulePkg/Core/Pei/Dispatcher/Dispatcher.c
@@ -653,7 +653,7 @@ PeiDispatcher (
PeimFileHandle = NULL;
EntryPoint = 0;
- if ((Private->PeiMemoryInstalled) && (Private->HobList.HandoffInformationTable->BootMode != BOOT_ON_S3_RESUME)) {
+ if ((Private->PeiMemoryInstalled) && (Private->HobList.HandoffInformationTable->BootMode != BOOT_ON_S3_RESUME || PcdGetBool (PcdShadowPeimOnS3Boot))) {
//
// Once real memory is available, shadow the RegisterForShadow modules. And meanwhile
// update the modules' status from PEIM_STATE_REGISITER_FOR_SHADOW to PEIM_STATE_DONE.
@@ -764,8 +764,14 @@ PeiDispatcher (
//
// For Fv type file, Produce new FV PPI and FV hob
//
- Status = ProcessFvFile (&Private->Fv[FvCount], PeimFileHandle);
- AuthenticationState = 0;
+ Status = ProcessFvFile (Private, &Private->Fv[FvCount], PeimFileHandle);
+ if (Status == EFI_SUCCESS) {
+ //
+ // PEIM_STATE_NOT_DISPATCHED move to PEIM_STATE_DISPATCHED
+ //
+ Private->Fv[FvCount].PeimState[PeimCount]++;
+ Private->PeimDispatchOnThisPass = TRUE;
+ }
} else {
//
// For PEIM driver, Load its entry point
@@ -777,50 +783,45 @@ PeiDispatcher (
&EntryPoint,
&AuthenticationState
);
- }
-
- if (Status == EFI_SUCCESS) {
- //
- // The PEIM has its dependencies satisfied, and its entry point
- // has been found, so invoke it.
- //
- PERF_START (PeimFileHandle, "PEIM", NULL, 0);
-
- ExtendedData.Handle = (EFI_HANDLE)PeimFileHandle;
-
- REPORT_STATUS_CODE_WITH_EXTENDED_DATA (
- EFI_PROGRESS_CODE,
- (EFI_SOFTWARE_PEI_CORE | EFI_SW_PC_INIT_BEGIN),
- (VOID *)(&ExtendedData),
- sizeof (ExtendedData)
- );
-
- Status = VerifyPeim (Private, CoreFvHandle->FvHandle, PeimFileHandle);
- if (Status != EFI_SECURITY_VIOLATION && (AuthenticationState == 0)) {
+ if (Status == EFI_SUCCESS) {
//
- // PEIM_STATE_NOT_DISPATCHED move to PEIM_STATE_DISPATCHED
+ // The PEIM has its dependencies satisfied, and its entry point
+ // has been found, so invoke it.
//
- Private->Fv[FvCount].PeimState[PeimCount]++;
+ PERF_START (PeimFileHandle, "PEIM", NULL, 0);
- if (FvFileInfo.FileType != EFI_FV_FILETYPE_FIRMWARE_VOLUME_IMAGE) {
+ ExtendedData.Handle = (EFI_HANDLE)PeimFileHandle;
+
+ REPORT_STATUS_CODE_WITH_EXTENDED_DATA (
+ EFI_PROGRESS_CODE,
+ (EFI_SOFTWARE_PEI_CORE | EFI_SW_PC_INIT_BEGIN),
+ (VOID *)(&ExtendedData),
+ sizeof (ExtendedData)
+ );
+
+ Status = VerifyPeim (Private, CoreFvHandle->FvHandle, PeimFileHandle, AuthenticationState);
+ if (Status != EFI_SECURITY_VIOLATION) {
+ //
+ // PEIM_STATE_NOT_DISPATCHED move to PEIM_STATE_DISPATCHED
+ //
+ Private->Fv[FvCount].PeimState[PeimCount]++;
//
// Call the PEIM entry point for PEIM driver
//
PeimEntryPoint = (EFI_PEIM_ENTRY_POINT2)(UINTN)EntryPoint;
PeimEntryPoint (PeimFileHandle, (const EFI_PEI_SERVICES **) PeiServices);
+ Private->PeimDispatchOnThisPass = TRUE;
}
- Private->PeimDispatchOnThisPass = TRUE;
- }
-
- REPORT_STATUS_CODE_WITH_EXTENDED_DATA (
- EFI_PROGRESS_CODE,
- (EFI_SOFTWARE_PEI_CORE | EFI_SW_PC_INIT_END),
- (VOID *)(&ExtendedData),
- sizeof (ExtendedData)
- );
- PERF_END (PeimFileHandle, "PEIM", NULL, 0);
+ REPORT_STATUS_CODE_WITH_EXTENDED_DATA (
+ EFI_PROGRESS_CODE,
+ (EFI_SOFTWARE_PEI_CORE | EFI_SW_PC_INIT_END),
+ (VOID *)(&ExtendedData),
+ sizeof (ExtendedData)
+ );
+ PERF_END (PeimFileHandle, "PEIM", NULL, 0);
+ }
}
if (Private->SwitchStackSignal) {
@@ -972,7 +973,7 @@ PeiDispatcher (
ProcessNotifyList (Private);
if ((Private->PeiMemoryInstalled) && (Private->Fv[FvCount].PeimState[PeimCount] == PEIM_STATE_REGISITER_FOR_SHADOW) && \
- (Private->HobList.HandoffInformationTable->BootMode != BOOT_ON_S3_RESUME)) {
+ (Private->HobList.HandoffInformationTable->BootMode != BOOT_ON_S3_RESUME || PcdGetBool (PcdShadowPeimOnS3Boot))) {
//
// If memory is availble we shadow images by default for performance reasons.
// We call the entry point a 2nd time so the module knows it's shadowed.
diff --git a/MdeModulePkg/Core/Pei/FwVol/FwVol.c b/MdeModulePkg/Core/Pei/FwVol/FwVol.c
index af8f821eb..ec855a8df 100644
--- a/MdeModulePkg/Core/Pei/FwVol/FwVol.c
+++ b/MdeModulePkg/Core/Pei/FwVol/FwVol.c
@@ -1,7 +1,7 @@
/** @file
Pei Core Firmware File System service routines.
-Copyright (c) 2006 - 2012, Intel Corporation. All rights reserved.<BR>
+Copyright (c) 2006 - 2013, 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
@@ -14,10 +14,17 @@ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
#include "FwVol.h"
-EFI_PEI_NOTIFY_DESCRIPTOR mNotifyOnFvInfoList = {
- (EFI_PEI_PPI_DESCRIPTOR_NOTIFY_CALLBACK | EFI_PEI_PPI_DESCRIPTOR_TERMINATE_LIST),
- &gEfiPeiFirmwareVolumeInfoPpiGuid,
- FirmwareVolmeInfoPpiNotifyCallback
+EFI_PEI_NOTIFY_DESCRIPTOR mNotifyOnFvInfoList[] = {
+ {
+ EFI_PEI_PPI_DESCRIPTOR_NOTIFY_CALLBACK,
+ &gEfiPeiFirmwareVolumeInfoPpiGuid,
+ FirmwareVolmeInfoPpiNotifyCallback
+ },
+ {
+ (EFI_PEI_PPI_DESCRIPTOR_NOTIFY_CALLBACK | EFI_PEI_PPI_DESCRIPTOR_TERMINATE_LIST),
+ &gEfiPeiFirmwareVolumeInfo2PpiGuid,
+ FirmwareVolmeInfoPpiNotifyCallback
+ }
};
PEI_FW_VOL_INSTANCE mPeiFfs2FwVol = {
@@ -29,7 +36,11 @@ PEI_FW_VOL_INSTANCE mPeiFfs2FwVol = {
PeiFfsFvPpiFindFileByName,
PeiFfsFvPpiGetFileInfo,
PeiFfsFvPpiGetVolumeInfo,
- PeiFfsFvPpiFindSectionByType
+ PeiFfsFvPpiFindSectionByType,
+ PeiFfsFvPpiGetFileInfo2,
+ PeiFfsFvPpiFindSectionByType2,
+ EFI_PEI_FIRMWARE_VOLUME_PPI_SIGNATURE,
+ EFI_PEI_FIRMWARE_VOLUME_PPI_REVISION
}
};
@@ -42,7 +53,11 @@ PEI_FW_VOL_INSTANCE mPeiFfs3FwVol = {
PeiFfsFvPpiFindFileByName,
PeiFfsFvPpiGetFileInfo,
PeiFfsFvPpiGetVolumeInfo,
- PeiFfsFvPpiFindSectionByType
+ PeiFfsFvPpiFindSectionByType,
+ PeiFfsFvPpiGetFileInfo2,
+ PeiFfsFvPpiFindSectionByType2,
+ EFI_PEI_FIRMWARE_VOLUME_PPI_SIGNATURE,
+ EFI_PEI_FIRMWARE_VOLUME_PPI_REVISION
}
};
@@ -226,7 +241,7 @@ FindFileEx (
IN CONST EFI_GUID *FileName, OPTIONAL
IN EFI_FV_FILETYPE SearchType,
IN OUT EFI_PEI_FILE_HANDLE *FileHandle,
- IN OUT EFI_PEI_FV_HANDLE *AprioriFile OPTIONAL
+ IN OUT EFI_PEI_FILE_HANDLE *AprioriFile OPTIONAL
)
{
EFI_FIRMWARE_VOLUME_HEADER *FwVolHeader;
@@ -461,6 +476,7 @@ PeiInitializeFv (
PrivateData->Fv[PrivateData->FvCount].FvHeader = BfvHeader;
PrivateData->Fv[PrivateData->FvCount].FvPpi = FvPpi;
PrivateData->Fv[PrivateData->FvCount].FvHandle = FvHandle;
+ PrivateData->Fv[PrivateData->FvCount].AuthenticationStatus = 0;
DEBUG ((
EFI_D_INFO,
"The %dth FV start address is 0x%11p, size is 0x%08x, handle is 0x%p\n",
@@ -472,18 +488,18 @@ PeiInitializeFv (
PrivateData->FvCount ++;
//
- // Post a call-back for the FvInfoPPI services to expose
+ // Post a call-back for the FvInfoPPI and FvInfo2PPI services to expose
// additional Fvs to PeiCore.
//
- Status = PeiServicesNotifyPpi (&mNotifyOnFvInfoList);
+ Status = PeiServicesNotifyPpi (mNotifyOnFvInfoList);
ASSERT_EFI_ERROR (Status);
}
/**
- Process Firmware Volum Information once FvInfoPPI install.
+ Process Firmware Volum Information once FvInfoPPI or FvInfo2PPI install.
The FV Info will be registered into PeiCore private data structure.
- And search the inside FV image, if found, the new FV INFO PPI will be installed.
+ And search the inside FV image, if found, the new FV INFO(2) PPI will be installed.
@param PeiServices An indirect pointer to the EFI_PEI_SERVICES table published by the PEI Foundation
@param NotifyDescriptor Address of the notification descriptor data structure.
@@ -501,7 +517,7 @@ FirmwareVolmeInfoPpiNotifyCallback (
IN VOID *Ppi
)
{
- EFI_PEI_FIRMWARE_VOLUME_INFO_PPI *FvInfoPpi;
+ EFI_PEI_FIRMWARE_VOLUME_INFO2_PPI FvInfo2Ppi;
EFI_PEI_FIRMWARE_VOLUME_PPI *FvPpi;
PEI_CORE_INSTANCE *PrivateData;
EFI_STATUS Status;
@@ -519,14 +535,25 @@ FirmwareVolmeInfoPpiNotifyCallback (
ASSERT (FALSE);
}
- FvInfoPpi = (EFI_PEI_FIRMWARE_VOLUME_INFO_PPI *)Ppi;
+ if (CompareGuid (NotifyDescriptor->Guid, &gEfiPeiFirmwareVolumeInfo2PpiGuid)) {
+ //
+ // It is FvInfo2PPI.
+ //
+ CopyMem (&FvInfo2Ppi, Ppi, sizeof (EFI_PEI_FIRMWARE_VOLUME_INFO2_PPI));
+ } else {
+ //
+ // It is FvInfoPPI.
+ //
+ CopyMem (&FvInfo2Ppi, Ppi, sizeof (EFI_PEI_FIRMWARE_VOLUME_INFO_PPI));
+ FvInfo2Ppi.AuthenticationStatus = 0;
+ }
//
// Locate the corresponding FV_PPI according to founded FV's format guid
//
Status = PeiServicesLocatePpi (
- &FvInfoPpi->FvFormat,
- 0,
+ &FvInfo2Ppi.FvFormat,
+ 0,
NULL,
(VOID**)&FvPpi
);
@@ -534,7 +561,7 @@ FirmwareVolmeInfoPpiNotifyCallback (
//
// Process new found FV and get FV handle.
//
- Status = FvPpi->ProcessVolume (FvPpi, FvInfoPpi->FvInfo, FvInfoPpi->FvInfoSize, &FvHandle);
+ Status = FvPpi->ProcessVolume (FvPpi, FvInfo2Ppi.FvInfo, FvInfo2Ppi.FvInfoSize, &FvHandle);
if (EFI_ERROR (Status)) {
DEBUG ((EFI_D_ERROR, "Fail to process new found FV, FV may be corrupted!\n"));
return Status;
@@ -545,7 +572,7 @@ FirmwareVolmeInfoPpiNotifyCallback (
//
for (FvIndex = 0; FvIndex < PrivateData->FvCount; FvIndex ++) {
if (PrivateData->Fv[FvIndex].FvHandle == FvHandle) {
- DEBUG ((EFI_D_INFO, "The Fv %p has already been processed!\n", FvInfoPpi->FvInfo));
+ DEBUG ((EFI_D_INFO, "The Fv %p has already been processed!\n", FvInfo2Ppi.FvInfo));
return EFI_SUCCESS;
}
}
@@ -553,15 +580,16 @@ FirmwareVolmeInfoPpiNotifyCallback (
//
// Update internal PEI_CORE_FV array.
//
- PrivateData->Fv[PrivateData->FvCount].FvHeader = (EFI_FIRMWARE_VOLUME_HEADER*) FvInfoPpi->FvInfo;
+ PrivateData->Fv[PrivateData->FvCount].FvHeader = (EFI_FIRMWARE_VOLUME_HEADER*) FvInfo2Ppi.FvInfo;
PrivateData->Fv[PrivateData->FvCount].FvPpi = FvPpi;
PrivateData->Fv[PrivateData->FvCount].FvHandle = FvHandle;
+ PrivateData->Fv[PrivateData->FvCount].AuthenticationStatus = FvInfo2Ppi.AuthenticationStatus;
DEBUG ((
EFI_D_INFO,
"The %dth FV start address is 0x%11p, size is 0x%08x, handle is 0x%p\n",
(UINT32) PrivateData->FvCount,
- (VOID *) FvInfoPpi->FvInfo,
- FvInfoPpi->FvInfoSize,
+ (VOID *) FvInfo2Ppi.FvInfo,
+ FvInfo2Ppi.FvInfoSize,
FvHandle
));
PrivateData->FvCount ++;
@@ -594,13 +622,13 @@ FirmwareVolmeInfoPpiNotifyCallback (
}
DEBUG ((EFI_D_INFO, "Found firmware volume Image File %p in FV[%d] %p\n", FileHandle, PrivateData->FvCount - 1, FvHandle));
- ProcessFvFile (&PrivateData->Fv[PrivateData->FvCount - 1], FileHandle);
+ ProcessFvFile (PrivateData, &PrivateData->Fv[PrivateData->FvCount - 1], FileHandle);
}
} while (FileHandle != NULL);
} else {
- DEBUG ((EFI_D_ERROR, "Fail to process FV %p because no corresponding EFI_FIRMWARE_VOLUME_PPI is found!\n", FvInfoPpi->FvInfo));
+ DEBUG ((EFI_D_ERROR, "Fail to process FV %p because no corresponding EFI_FIRMWARE_VOLUME_PPI is found!\n", FvInfo2Ppi.FvInfo));
- AddUnknownFormatFvInfo (PrivateData, &FvInfoPpi->FvFormat, FvInfoPpi->FvInfo, FvInfoPpi->FvInfoSize);
+ AddUnknownFormatFvInfo (PrivateData, &FvInfo2Ppi);
}
return EFI_SUCCESS;
@@ -662,10 +690,12 @@ VerifyGuidedSectionGuid (
@param PeiServices An indirect pointer to the EFI_PEI_SERVICES table published by the PEI Foundation.
@param SectionType Filter to find only section of this type.
+ @param SectionInstance Pointer to the filter to find the specific instance of section.
@param Section From where to search.
@param SectionSize The file size to search.
@param OutputBuffer A pointer to the discovered section, if successful.
NULL if section not found
+ @param AuthenticationStatus Updated upon return to point to the authentication status for this section.
@param IsFfs3Fv Indicates the FV format.
@return EFI_NOT_FOUND The match section is not found.
@@ -676,9 +706,11 @@ EFI_STATUS
ProcessSection (
IN CONST EFI_PEI_SERVICES **PeiServices,
IN EFI_SECTION_TYPE SectionType,
+ IN OUT UINTN *SectionInstance,
IN EFI_COMMON_SECTION_HEADER *Section,
IN UINTN SectionSize,
OUT VOID **OutputBuffer,
+ OUT UINT32 *AuthenticationStatus,
IN BOOLEAN IsFfs3Fv
)
{
@@ -693,6 +725,9 @@ ProcessSection (
UINT32 Authentication;
PEI_CORE_INSTANCE *PrivateData;
EFI_GUID *SectionDefinitionGuid;
+ BOOLEAN SectionCached;
+ VOID *TempOutputBuffer;
+ UINT32 TempAuthenticationStatus;
PrivateData = PEI_CORE_INSTANCE_FROM_PS_THIS (PeiServices);
*OutputBuffer = NULL;
@@ -721,82 +756,132 @@ ProcessSection (
}
if (Section->Type == SectionType) {
- if (IS_SECTION2 (Section)) {
- *OutputBuffer = (VOID *)((UINT8 *) Section + sizeof (EFI_COMMON_SECTION_HEADER2));
+ //
+ // The type matches, so check the instance count to see if it's the one we want.
+ //
+ (*SectionInstance)--;
+ if (*SectionInstance == 0) {
+ //
+ // Got it!
+ //
+ if (IS_SECTION2 (Section)) {
+ *OutputBuffer = (VOID *)((UINT8 *) Section + sizeof (EFI_COMMON_SECTION_HEADER2));
+ } else {
+ *OutputBuffer = (VOID *)((UINT8 *) Section + sizeof (EFI_COMMON_SECTION_HEADER));
+ }
+ return EFI_SUCCESS;
} else {
- *OutputBuffer = (VOID *)((UINT8 *) Section + sizeof (EFI_COMMON_SECTION_HEADER));
+ if (IS_SECTION2 (Section)) {
+ SectionLength = SECTION2_SIZE (Section);
+ } else {
+ SectionLength = SECTION_SIZE (Section);
+ }
+ //
+ // SectionLength is adjusted it is 4 byte aligned.
+ // Go to the next section
+ //
+ SectionLength = GET_OCCUPIED_SIZE (SectionLength, 4);
+ ASSERT (SectionLength != 0);
+ ParsedLength += SectionLength;
+ Section = (EFI_COMMON_SECTION_HEADER *)((UINT8 *)Section + SectionLength);
+ continue;
}
- return EFI_SUCCESS;
} else if ((Section->Type == EFI_SECTION_GUID_DEFINED) || (Section->Type == EFI_SECTION_COMPRESSION)) {
//
// Check the encapsulated section is extracted into the cache data.
//
+ SectionCached = FALSE;
for (Index = 0; Index < PrivateData->CacheSection.AllSectionCount; Index ++) {
if (Section == PrivateData->CacheSection.Section[Index]) {
+ SectionCached = TRUE;
PpiOutput = PrivateData->CacheSection.SectionData[Index];
PpiOutputSize = PrivateData->CacheSection.SectionSize[Index];
+ Authentication = PrivateData->CacheSection.AuthenticationStatus[Index];
//
// Search section directly from the cache data.
//
- return ProcessSection (
- PeiServices,
- SectionType,
- PpiOutput,
- PpiOutputSize,
- OutputBuffer,
- IsFfs3Fv
+ TempAuthenticationStatus = 0;
+ Status = ProcessSection (
+ PeiServices,
+ SectionType,
+ SectionInstance,
+ PpiOutput,
+ PpiOutputSize,
+ &TempOutputBuffer,
+ &TempAuthenticationStatus,
+ IsFfs3Fv
);
+ if (!EFI_ERROR (Status)) {
+ *OutputBuffer = TempOutputBuffer;
+ *AuthenticationStatus = TempAuthenticationStatus | Authentication;
+ return EFI_SUCCESS;
+ }
}
}
-
- Status = EFI_NOT_FOUND;
- if (Section->Type == EFI_SECTION_GUID_DEFINED) {
- if (IS_SECTION2 (Section)) {
- SectionDefinitionGuid = &((EFI_GUID_DEFINED_SECTION2 *)Section)->SectionDefinitionGuid;
- } else {
- SectionDefinitionGuid = &((EFI_GUID_DEFINED_SECTION *)Section)->SectionDefinitionGuid;
- }
- if (VerifyGuidedSectionGuid (SectionDefinitionGuid, &GuidSectionPpi)) {
- Status = GuidSectionPpi->ExtractSection (
- GuidSectionPpi,
- Section,
- &PpiOutput,
- &PpiOutputSize,
- &Authentication
- );
+
+ //
+ // If SectionCached is TRUE, the section data has been cached and scanned.
+ //
+ if (!SectionCached) {
+ Status = EFI_NOT_FOUND;
+ Authentication = 0;
+ if (Section->Type == EFI_SECTION_GUID_DEFINED) {
+ if (IS_SECTION2 (Section)) {
+ SectionDefinitionGuid = &((EFI_GUID_DEFINED_SECTION2 *)Section)->SectionDefinitionGuid;
+ } else {
+ SectionDefinitionGuid = &((EFI_GUID_DEFINED_SECTION *)Section)->SectionDefinitionGuid;
+ }
+ if (VerifyGuidedSectionGuid (SectionDefinitionGuid, &GuidSectionPpi)) {
+ Status = GuidSectionPpi->ExtractSection (
+ GuidSectionPpi,
+ Section,
+ &PpiOutput,
+ &PpiOutputSize,
+ &Authentication
+ );
+ }
+ } else if (Section->Type == EFI_SECTION_COMPRESSION) {
+ Status = PeiServicesLocatePpi (&gEfiPeiDecompressPpiGuid, 0, NULL, (VOID **) &DecompressPpi);
+ if (!EFI_ERROR (Status)) {
+ Status = DecompressPpi->Decompress (
+ DecompressPpi,
+ (CONST EFI_COMPRESSION_SECTION*) Section,
+ &PpiOutput,
+ &PpiOutputSize
+ );
+ }
}
- } else if (Section->Type == EFI_SECTION_COMPRESSION) {
- Status = PeiServicesLocatePpi (&gEfiPeiDecompressPpiGuid, 0, NULL, (VOID **) &DecompressPpi);
+
if (!EFI_ERROR (Status)) {
- Status = DecompressPpi->Decompress (
- DecompressPpi,
- (CONST EFI_COMPRESSION_SECTION*) Section,
- &PpiOutput,
- &PpiOutputSize
- );
- }
- }
-
- if (!EFI_ERROR (Status)) {
- //
- // Update cache section data.
- //
- if (PrivateData->CacheSection.AllSectionCount < CACHE_SETION_MAX_NUMBER) {
- PrivateData->CacheSection.AllSectionCount ++;
+ //
+ // Update cache section data.
+ //
+ if (PrivateData->CacheSection.AllSectionCount < CACHE_SETION_MAX_NUMBER) {
+ PrivateData->CacheSection.AllSectionCount ++;
+ }
+ PrivateData->CacheSection.Section [PrivateData->CacheSection.SectionIndex] = Section;
+ PrivateData->CacheSection.SectionData [PrivateData->CacheSection.SectionIndex] = PpiOutput;
+ PrivateData->CacheSection.SectionSize [PrivateData->CacheSection.SectionIndex] = PpiOutputSize;
+ PrivateData->CacheSection.AuthenticationStatus [PrivateData->CacheSection.SectionIndex] = Authentication;
+ PrivateData->CacheSection.SectionIndex = (PrivateData->CacheSection.SectionIndex + 1)%CACHE_SETION_MAX_NUMBER;
+
+ TempAuthenticationStatus = 0;
+ Status = ProcessSection (
+ PeiServices,
+ SectionType,
+ SectionInstance,
+ PpiOutput,
+ PpiOutputSize,
+ &TempOutputBuffer,
+ &TempAuthenticationStatus,
+ IsFfs3Fv
+ );
+ if (!EFI_ERROR (Status)) {
+ *OutputBuffer = TempOutputBuffer;
+ *AuthenticationStatus = TempAuthenticationStatus | Authentication;
+ return EFI_SUCCESS;
+ }
}
- PrivateData->CacheSection.Section [PrivateData->CacheSection.SectionIndex] = Section;
- PrivateData->CacheSection.SectionData [PrivateData->CacheSection.SectionIndex] = PpiOutput;
- PrivateData->CacheSection.SectionSize [PrivateData->CacheSection.SectionIndex] = PpiOutputSize;
- PrivateData->CacheSection.SectionIndex = (PrivateData->CacheSection.SectionIndex + 1)%CACHE_SETION_MAX_NUMBER;
-
- return ProcessSection (
- PeiServices,
- SectionType,
- PpiOutput,
- PpiOutputSize,
- OutputBuffer,
- IsFfs3Fv
- );
}
}
@@ -852,6 +937,49 @@ PeiFfsFindSectionData (
}
/**
+ Searches for the next matching section within the specified file.
+
+ @param PeiServices An indirect pointer to the EFI_PEI_SERVICES table published by the PEI Foundation.
+ @param SectionType The value of the section type to find.
+ @param SectionInstance Section instance to find.
+ @param FileHandle Handle of the firmware file to search.
+ @param SectionData A pointer to the discovered section, if successful.
+ @param AuthenticationStatus A pointer to the authentication status for this section.
+
+ @retval EFI_SUCCESS The section was found.
+ @retval EFI_NOT_FOUND The section was not found.
+
+**/
+EFI_STATUS
+EFIAPI
+PeiFfsFindSectionData3 (
+ IN CONST EFI_PEI_SERVICES **PeiServices,
+ IN EFI_SECTION_TYPE SectionType,
+ IN UINTN SectionInstance,
+ IN EFI_PEI_FILE_HANDLE FileHandle,
+ OUT VOID **SectionData,
+ OUT UINT32 *AuthenticationStatus
+ )
+{
+ PEI_CORE_FV_HANDLE *CoreFvHandle;
+
+ CoreFvHandle = FileHandleToVolume (FileHandle);
+ if ((CoreFvHandle == NULL) || (CoreFvHandle->FvPpi == NULL)) {
+ return EFI_NOT_FOUND;
+ }
+
+ if ((CoreFvHandle->FvPpi->Signature == EFI_PEI_FIRMWARE_VOLUME_PPI_SIGNATURE) &&
+ (CoreFvHandle->FvPpi->Revision == EFI_PEI_FIRMWARE_VOLUME_PPI_REVISION)) {
+ return CoreFvHandle->FvPpi->FindSectionByType2 (CoreFvHandle->FvPpi, SectionType, SectionInstance, FileHandle, SectionData, AuthenticationStatus);
+ }
+ //
+ // The old FvPpi doesn't support to find section by section instance
+ // and return authentication status, so return EFI_UNSUPPORTED.
+ //
+ return EFI_UNSUPPORTED;
+}
+
+/**
Searches for the next matching file in the firmware volume.
@param PeiServices An indirect pointer to the EFI_PEI_SERVICES table published by the PEI Foundation.
@@ -1009,6 +1137,48 @@ PeiFfsGetFileInfo (
return CoreFvHandle->FvPpi->GetFileInfo (CoreFvHandle->FvPpi, FileHandle, FileInfo);
}
+/**
+ Returns information about a specific file.
+
+ @param FileHandle Handle of the file.
+ @param FileInfo Upon exit, points to the file's information.
+
+ @retval EFI_INVALID_PARAMETER If FileInfo is NULL.
+ @retval EFI_INVALID_PARAMETER If FileHandle does not represent a valid file.
+ @retval EFI_SUCCESS File information returned.
+
+**/
+EFI_STATUS
+EFIAPI
+PeiFfsGetFileInfo2 (
+ IN EFI_PEI_FILE_HANDLE FileHandle,
+ OUT EFI_FV_FILE_INFO2 *FileInfo
+ )
+{
+ PEI_CORE_FV_HANDLE *CoreFvHandle;
+
+ if ((FileHandle == NULL) || (FileInfo == NULL)) {
+ return EFI_INVALID_PARAMETER;
+ }
+
+ //
+ // Retrieve the FirmwareVolume which the file resides in.
+ //
+ CoreFvHandle = FileHandleToVolume (FileHandle);
+ if ((CoreFvHandle == NULL) || (CoreFvHandle->FvPpi == NULL)) {
+ return EFI_INVALID_PARAMETER;
+ }
+
+ if ((CoreFvHandle->FvPpi->Signature == EFI_PEI_FIRMWARE_VOLUME_PPI_SIGNATURE) &&
+ (CoreFvHandle->FvPpi->Revision == EFI_PEI_FIRMWARE_VOLUME_PPI_REVISION)) {
+ return CoreFvHandle->FvPpi->GetFileInfo2 (CoreFvHandle->FvPpi, FileHandle, FileInfo);
+ }
+ //
+ // The old FvPpi doesn't support to return file info with authentication status,
+ // so return EFI_UNSUPPORTED.
+ //
+ return EFI_UNSUPPORTED;
+}
/**
Returns information about the specified volume.
@@ -1050,19 +1220,22 @@ PeiFfsGetVolumeInfo (
}
/**
- Get Fv image from the FV type file, then install FV INFO ppi, Build FV hob.
+ Get Fv image from the FV type file, then install FV INFO(2) ppi, Build FV hob.
+ @param PrivateData PeiCore's private data structure
@param ParentFvCoreHandle Pointer of EFI_CORE_FV_HANDLE to parent Fv image that contain this Fv image.
@param ParentFvFileHandle File handle of a Fv type file that contain this Fv image.
@retval EFI_NOT_FOUND FV image can't be found.
@retval EFI_SUCCESS Successfully to process it.
@retval EFI_OUT_OF_RESOURCES Can not allocate page when aligning FV image
+ @retval EFI_SECURITY_VIOLATION Image is illegal
@retval Others Can not find EFI_SECTION_FIRMWARE_VOLUME_IMAGE section
**/
EFI_STATUS
ProcessFvFile (
+ IN PEI_CORE_INSTANCE *PrivateData,
IN PEI_CORE_FV_HANDLE *ParentFvCoreHandle,
IN EFI_PEI_FILE_HANDLE ParentFvFileHandle
)
@@ -1077,6 +1250,7 @@ ProcessFvFile (
EFI_FIRMWARE_VOLUME_HEADER *FvHeader;
EFI_FV_FILE_INFO FileInfo;
UINT64 FvLength;
+ UINT32 AuthenticationStatus;
//
// Check if this EFI_FV_FILETYPE_FIRMWARE_VOLUME_IMAGE file has already
@@ -1100,38 +1274,62 @@ ProcessFvFile (
//
// Find FvImage in FvFile
//
- Status = ParentFvPpi->FindSectionByType (
- ParentFvPpi,
- EFI_SECTION_FIRMWARE_VOLUME_IMAGE,
- ParentFvFileHandle,
- (VOID **)&FvHeader
- );
-
+ AuthenticationStatus = 0;
+ if ((ParentFvPpi->Signature == EFI_PEI_FIRMWARE_VOLUME_PPI_SIGNATURE) &&
+ (ParentFvPpi->Revision == EFI_PEI_FIRMWARE_VOLUME_PPI_REVISION)) {
+ Status = ParentFvPpi->FindSectionByType2 (
+ ParentFvPpi,
+ EFI_SECTION_FIRMWARE_VOLUME_IMAGE,
+ 0,
+ ParentFvFileHandle,
+ (VOID **)&FvHeader,
+ &AuthenticationStatus
+ );
+ } else {
+ Status = ParentFvPpi->FindSectionByType (
+ ParentFvPpi,
+ EFI_SECTION_FIRMWARE_VOLUME_IMAGE,
+ ParentFvFileHandle,
+ (VOID **)&FvHeader
+ );
+ }
if (EFI_ERROR (Status)) {
return Status;
}
- //
- // FvAlignment must be more than 8 bytes required by FvHeader structure.
- //
- FvAlignment = 1 << ((ReadUnaligned32 (&FvHeader->Attributes) & EFI_FVB2_ALIGNMENT) >> 16);
- if (FvAlignment < 8) {
- FvAlignment = 8;
+ Status = VerifyPeim (PrivateData, ParentFvHandle, ParentFvFileHandle, AuthenticationStatus);
+ if (Status == EFI_SECURITY_VIOLATION) {
+ return Status;
}
-
+
//
- // Check FvImage
+ // If EFI_FVB2_WEAK_ALIGNMENT is set in the volume header then the first byte of the volume
+ // can be aligned on any power-of-two boundary. A weakly aligned volume can not be moved from
+ // its initial linked location and maintain its alignment.
//
- if ((UINTN) FvHeader % FvAlignment != 0) {
- FvLength = ReadUnaligned64 (&FvHeader->FvLength);
- NewFvBuffer = AllocateAlignedPages (EFI_SIZE_TO_PAGES ((UINT32) FvLength), FvAlignment);
- if (NewFvBuffer == NULL) {
- return EFI_OUT_OF_RESOURCES;
+ if ((ReadUnaligned32 (&FvHeader->Attributes) & EFI_FVB2_WEAK_ALIGNMENT) != EFI_FVB2_WEAK_ALIGNMENT) {
+ //
+ // FvAlignment must be greater than or equal to 8 bytes of the minimum FFS alignment value.
+ //
+ FvAlignment = 1 << ((ReadUnaligned32 (&FvHeader->Attributes) & EFI_FVB2_ALIGNMENT) >> 16);
+ if (FvAlignment < 8) {
+ FvAlignment = 8;
+ }
+
+ //
+ // Check FvImage
+ //
+ if ((UINTN) FvHeader % FvAlignment != 0) {
+ FvLength = ReadUnaligned64 (&FvHeader->FvLength);
+ NewFvBuffer = AllocateAlignedPages (EFI_SIZE_TO_PAGES ((UINT32) FvLength), FvAlignment);
+ if (NewFvBuffer == NULL) {
+ return EFI_OUT_OF_RESOURCES;
+ }
+ CopyMem (NewFvBuffer, FvHeader, (UINTN) FvLength);
+ FvHeader = (EFI_FIRMWARE_VOLUME_HEADER*) NewFvBuffer;
}
- CopyMem (NewFvBuffer, FvHeader, (UINTN) FvLength);
- FvHeader = (EFI_FIRMWARE_VOLUME_HEADER*) NewFvBuffer;
}
-
+
Status = ParentFvPpi->GetVolumeInfo (ParentFvPpi, ParentFvHandle, &ParentFvImageInfo);
ASSERT_EFI_ERROR (Status);
@@ -1139,14 +1337,15 @@ ProcessFvFile (
ASSERT_EFI_ERROR (Status);
//
- // Install FvPpi and Build FvHob
+ // Install FvInfo2 Ppi and Build FvHob
//
- PeiServicesInstallFvInfoPpi (
+ PeiServicesInstallFvInfo2Ppi (
&FvHeader->FileSystemGuid,
(VOID**) FvHeader,
(UINT32) FvHeader->FvLength,
&ParentFvImageInfo.FvName,
- &FileInfo.FileName
+ &FileInfo.FileName,
+ AuthenticationStatus
);
//
@@ -1402,12 +1601,6 @@ PeiFfsFvPpiGetFileInfo (
}
FileHeader = (EFI_FFS_FILE_HEADER *)FileHandle;
- CopyMem (&FileInfo->FileName, &FileHeader->Name, sizeof(EFI_GUID));
- FileInfo->FileType = FileHeader->Type;
- FileInfo->FileAttributes = FfsAttributes2FvFileAttributes (FileHeader->Attributes);
- if ((CoreFvHandle->FvHeader->Attributes & EFI_FVB2_MEMORY_MAPPED) == EFI_FVB2_MEMORY_MAPPED) {
- FileInfo->FileAttributes |= EFI_FV_FILE_ATTRIB_MEMORY_MAPPED;
- }
if (IS_FFS_FILE2 (FileHeader)) {
ASSERT (FFS_FILE2_SIZE (FileHeader) > 0x00FFFFFF);
if (!FwVolInstance->IsFfs3Fv) {
@@ -1420,9 +1613,65 @@ PeiFfsFvPpiGetFileInfo (
FileInfo->BufferSize = FFS_FILE_SIZE (FileHeader) - sizeof (EFI_FFS_FILE_HEADER);
FileInfo->Buffer = (UINT8 *) FileHeader + sizeof (EFI_FFS_FILE_HEADER);
}
- return EFI_SUCCESS;
-}
-
+ CopyMem (&FileInfo->FileName, &FileHeader->Name, sizeof(EFI_GUID));
+ FileInfo->FileType = FileHeader->Type;
+ FileInfo->FileAttributes = FfsAttributes2FvFileAttributes (FileHeader->Attributes);
+ if ((CoreFvHandle->FvHeader->Attributes & EFI_FVB2_MEMORY_MAPPED) == EFI_FVB2_MEMORY_MAPPED) {
+ FileInfo->FileAttributes |= EFI_FV_FILE_ATTRIB_MEMORY_MAPPED;
+ }
+ return EFI_SUCCESS;
+}
+
+/**
+ Returns information about a specific file.
+
+ This function returns information about a specific
+ file, including its file name, type, attributes, starting
+ address, size and authentication status.
+
+ @param This Points to this instance of the
+ EFI_PEI_FIRMWARE_VOLUME_PPI.
+ @param FileHandle Handle of the file.
+ @param FileInfo Upon exit, points to the file's
+ information.
+
+ @retval EFI_SUCCESS File information returned.
+ @retval EFI_INVALID_PARAMETER If FileHandle does not
+ represent a valid file.
+ @retval EFI_INVALID_PARAMETER If FileInfo is NULL.
+
+**/
+EFI_STATUS
+EFIAPI
+PeiFfsFvPpiGetFileInfo2 (
+ IN CONST EFI_PEI_FIRMWARE_VOLUME_PPI *This,
+ IN EFI_PEI_FILE_HANDLE FileHandle,
+ OUT EFI_FV_FILE_INFO2 *FileInfo
+ )
+{
+ EFI_STATUS Status;
+ PEI_CORE_FV_HANDLE *CoreFvHandle;
+
+ if ((FileHandle == NULL) || (FileInfo == NULL)) {
+ return EFI_INVALID_PARAMETER;
+ }
+
+ //
+ // Retrieve the FirmwareVolume which the file resides in.
+ //
+ CoreFvHandle = FileHandleToVolume (FileHandle);
+ if (CoreFvHandle == NULL) {
+ return EFI_INVALID_PARAMETER;
+ }
+
+ Status = PeiFfsFvPpiGetFileInfo (This, FileHandle, (EFI_FV_FILE_INFO *) FileInfo);
+ if (!EFI_ERROR (Status)) {
+ FileInfo->AuthenticationStatus = CoreFvHandle->AuthenticationStatus;
+ }
+
+ return Status;
+}
+
/**
This function returns information about the firmware volume.
@@ -1508,13 +1757,67 @@ PeiFfsFvPpiFindSectionByType (
OUT VOID **SectionData
)
{
+ UINT32 AuthenticationStatus;
+ return PeiFfsFvPpiFindSectionByType2 (This, SearchType, 0, FileHandle, SectionData, &AuthenticationStatus);
+}
+
+/**
+ Find the next matching section in the firmware file.
+
+ This service enables PEI modules to discover sections
+ of a given instance and type within a valid file.
+
+ @param This Points to this instance of the
+ EFI_PEI_FIRMWARE_VOLUME_PPI.
+ @param SearchType A filter to find only sections of this
+ type.
+ @param SearchInstance A filter to find the specific instance
+ of sections.
+ @param FileHandle Handle of firmware file in which to
+ search.
+ @param SectionData Updated upon return to point to the
+ section found.
+ @param AuthenticationStatus Updated upon return to point to the
+ authentication status for this section.
+
+ @retval EFI_SUCCESS Section was found.
+ @retval EFI_NOT_FOUND Section of the specified type was not
+ found. SectionData contains NULL.
+**/
+EFI_STATUS
+EFIAPI
+PeiFfsFvPpiFindSectionByType2 (
+ IN CONST EFI_PEI_FIRMWARE_VOLUME_PPI *This,
+ IN EFI_SECTION_TYPE SearchType,
+ IN UINTN SearchInstance,
+ IN EFI_PEI_FILE_HANDLE FileHandle,
+ OUT VOID **SectionData,
+ OUT UINT32 *AuthenticationStatus
+ )
+{
+ EFI_STATUS Status;
EFI_FFS_FILE_HEADER *FfsFileHeader;
UINT32 FileSize;
EFI_COMMON_SECTION_HEADER *Section;
PEI_FW_VOL_INSTANCE *FwVolInstance;
+ PEI_CORE_FV_HANDLE *CoreFvHandle;
+ UINTN Instance;
+ UINT32 ExtractedAuthenticationStatus;
+
+ if (SectionData == NULL) {
+ return EFI_NOT_FOUND;
+ }
FwVolInstance = PEI_FW_VOL_INSTANCE_FROM_FV_THIS (This);
+ //
+ // Retrieve the FirmwareVolume which the file resides in.
+ //
+ CoreFvHandle = FileHandleToVolume (FileHandle);
+ if (CoreFvHandle == NULL) {
+ return EFI_NOT_FOUND;
+ }
+
FfsFileHeader = (EFI_FFS_FILE_HEADER *)(FileHandle);
if (IS_FFS_FILE2 (FfsFileHeader)) {
@@ -1530,15 +1833,26 @@ PeiFfsFvPpiFindSectionByType (
FileSize = FFS_FILE_SIZE (FfsFileHeader) - sizeof (EFI_FFS_FILE_HEADER);
}
- return ProcessSection (
- GetPeiServicesTablePointer (),
- SearchType,
- Section,
- FileSize,
- SectionData,
- FwVolInstance->IsFfs3Fv
- );
-}
+ Instance = SearchInstance + 1;
+ ExtractedAuthenticationStatus = 0;
+ Status = ProcessSection (
+ GetPeiServicesTablePointer (),
+ SearchType,
+ &Instance,
+ Section,
+ FileSize,
+ SectionData,
+ &ExtractedAuthenticationStatus,
+ FwVolInstance->IsFfs3Fv
+ );
+ if (!EFI_ERROR (Status)) {
+ //
+ // Inherit the authentication status.
+ //
+ *AuthenticationStatus = ExtractedAuthenticationStatus | CoreFvHandle->AuthenticationStatus;
+ }
+ return Status;
+}
/**
Convert the handle of FV to pointer of corresponding PEI_CORE_FV_HANDLE.
@@ -1725,26 +2039,22 @@ PeiReinitializeFv (
Report the information for a new discoveried FV in unknown third-party format.
If the EFI_PEI_FIRMWARE_VOLUME_PPI has not been installed for third-party FV format, but
- the FV in this format has been discoveried, then this FV's information will be cached into
+ the FV in this format has been discoveried, then this FV's information will be cached into
PEI_CORE_INSTANCE's UnknownFvInfo array.
Also a notification would be installed for unknown third-party FV format guid, if EFI_PEI_FIRMWARE_VOLUME_PPI
is installed later by platform's PEIM, the original unknown third-party FV will be processed by
using new installed EFI_PEI_FIRMWARE_VOLUME_PPI.
@param PrivateData Point to instance of PEI_CORE_INSTANCE
- @param Format Point to the unknown third-party format guid.
- @param FvInfo Point to FvInfo buffer.
- @param FvInfoSize The size of FvInfo buffer.
+ @param FvInfo2Ppi Point to FvInfo2 PPI.
@retval EFI_OUT_OF_RESOURCES The FV info array in PEI_CORE_INSTANCE has no more spaces.
@retval EFI_SUCCESS Success to add the information for unknown FV.
**/
EFI_STATUS
AddUnknownFormatFvInfo (
- IN PEI_CORE_INSTANCE *PrivateData,
- IN EFI_GUID *Format,
- IN VOID *FvInfo,
- IN UINT32 FvInfoSize
+ IN PEI_CORE_INSTANCE *PrivateData,
+ IN EFI_PEI_FIRMWARE_VOLUME_INFO2_PPI *FvInfo2Ppi
)
{
PEI_CORE_UNKNOW_FORMAT_FV_INFO *NewUnknownFv;
@@ -1756,9 +2066,10 @@ AddUnknownFormatFvInfo (
NewUnknownFv = &PrivateData->UnknownFvInfo[PrivateData->UnknownFvInfoCount];
PrivateData->UnknownFvInfoCount ++;
- CopyGuid (&NewUnknownFv->FvFormat, Format);
- NewUnknownFv->FvInfo = FvInfo;
- NewUnknownFv->FvInfoSize = FvInfoSize;
+ CopyGuid (&NewUnknownFv->FvFormat, &FvInfo2Ppi->FvFormat);
+ NewUnknownFv->FvInfo = FvInfo2Ppi->FvInfo;
+ NewUnknownFv->FvInfoSize = FvInfo2Ppi->FvInfoSize;
+ NewUnknownFv->AuthenticationStatus = FvInfo2Ppi->AuthenticationStatus;
NewUnknownFv->NotifyDescriptor.Flags = (EFI_PEI_PPI_DESCRIPTOR_NOTIFY_CALLBACK | EFI_PEI_PPI_DESCRIPTOR_TERMINATE_LIST);
NewUnknownFv->NotifyDescriptor.Guid = &NewUnknownFv->FvFormat;
NewUnknownFv->NotifyDescriptor.Notify = ThirdPartyFvPpiNotifyCallback;
@@ -1777,6 +2088,7 @@ AddUnknownFormatFvInfo (
@param Format Point to given FV format guid
@param FvInfo On return, the pointer of FV information buffer
@param FvInfoSize On return, the size of FV information buffer.
+ @param AuthenticationStatus On return, the authentication status of FV information buffer.
@retval EFI_NOT_FOUND The FV is not found for new installed EFI_PEI_FIRMWARE_VOLUME_PPI
@retval EFI_SUCCESS Success to find a FV which could be processed by new installed EFI_PEI_FIRMWARE_VOLUME_PPI.
@@ -1786,7 +2098,8 @@ FindUnknownFormatFvInfo (
IN PEI_CORE_INSTANCE *PrivateData,
IN EFI_GUID *Format,
OUT VOID **FvInfo,
- OUT UINT32 *FvInfoSize
+ OUT UINT32 *FvInfoSize,
+ OUT UINT32 *AuthenticationStatus
)
{
UINTN Index;
@@ -1805,6 +2118,7 @@ FindUnknownFormatFvInfo (
*FvInfo = PrivateData->UnknownFvInfo[Index].FvInfo;
*FvInfoSize = PrivateData->UnknownFvInfo[Index].FvInfoSize;
+ *AuthenticationStatus = PrivateData->UnknownFvInfo[Index].AuthenticationStatus;
//
// Remove an entry from UnknownFvInfo array.
@@ -1841,6 +2155,7 @@ ThirdPartyFvPpiNotifyCallback (
EFI_PEI_FIRMWARE_VOLUME_PPI *FvPpi;
VOID *FvInfo;
UINT32 FvInfoSize;
+ UINT32 AuthenticationStatus;
EFI_STATUS Status;
EFI_PEI_FV_HANDLE FvHandle;
BOOLEAN IsProcessed;
@@ -1852,7 +2167,7 @@ ThirdPartyFvPpiNotifyCallback (
FvPpi = (EFI_PEI_FIRMWARE_VOLUME_PPI*) Ppi;
do {
- Status = FindUnknownFormatFvInfo (PrivateData, NotifyDescriptor->Guid, &FvInfo, &FvInfoSize);
+ Status = FindUnknownFormatFvInfo (PrivateData, NotifyDescriptor->Guid, &FvInfo, &FvInfoSize, &AuthenticationStatus);
if (EFI_ERROR (Status)) {
return EFI_SUCCESS;
}
@@ -1894,6 +2209,7 @@ ThirdPartyFvPpiNotifyCallback (
PrivateData->Fv[PrivateData->FvCount].FvHeader = (EFI_FIRMWARE_VOLUME_HEADER*) FvInfo;
PrivateData->Fv[PrivateData->FvCount].FvPpi = FvPpi;
PrivateData->Fv[PrivateData->FvCount].FvHandle = FvHandle;
+ PrivateData->Fv[PrivateData->FvCount].AuthenticationStatus = AuthenticationStatus;
DEBUG ((
EFI_D_INFO,
"The %dth FV start address is 0x%11p, size is 0x%08x, handle is 0x%p\n",
@@ -1932,7 +2248,7 @@ ThirdPartyFvPpiNotifyCallback (
}
DEBUG ((EFI_D_INFO, "Found firmware volume Image File %p in FV[%d] %p\n", FileHandle, PrivateData->FvCount - 1, FvHandle));
- ProcessFvFile (&PrivateData->Fv[PrivateData->FvCount - 1], FileHandle);
+ ProcessFvFile (PrivateData, &PrivateData->Fv[PrivateData->FvCount - 1], FileHandle);
}
} while (FileHandle != NULL);
} while (TRUE);
diff --git a/MdeModulePkg/Core/Pei/FwVol/FwVol.h b/MdeModulePkg/Core/Pei/FwVol/FwVol.h
index ed4013017..1daeb6d97 100644
--- a/MdeModulePkg/Core/Pei/FwVol/FwVol.h
+++ b/MdeModulePkg/Core/Pei/FwVol/FwVol.h
@@ -160,6 +160,40 @@ PeiFfsFvPpiFindSectionByType (
);
/**
+ Find the next matching section in the firmware file.
+
+ This service enables PEI modules to discover sections
+ of a given instance and type within a valid file.
+
+ @param This Points to this instance of the
+ EFI_PEI_FIRMWARE_VOLUME_PPI.
+ @param SearchType A filter to find only sections of this
+ type.
+ @param SearchInstance A filter to find the specific instance
+ of sections.
+ @param FileHandle Handle of firmware file in which to
+ search.
+ @param SectionData Updated upon return to point to the
+ section found.
+ @param AuthenticationStatus Updated upon return to point to the
+ authentication status for this section.
+
+ @retval EFI_SUCCESS Section was found.
+ @retval EFI_NOT_FOUND Section of the specified type was not
+ found. SectionData contains NULL.
+**/
+EFI_STATUS
+EFIAPI
+PeiFfsFvPpiFindSectionByType2 (
+ IN CONST EFI_PEI_FIRMWARE_VOLUME_PPI *This,
+ IN EFI_SECTION_TYPE SearchType,
+ IN UINTN SearchInstance,
+ IN EFI_PEI_FILE_HANDLE FileHandle,
+ OUT VOID **SectionData,
+ OUT UINT32 *AuthenticationStatus
+ );
+
+/**
Returns information about a specific file.
This function returns information about a specific
@@ -187,6 +221,33 @@ PeiFfsFvPpiGetFileInfo (
);
/**
+ Returns information about a specific file.
+
+ This function returns information about a specific
+ file, including its file name, type, attributes, starting
+ address, size and authentication status.
+
+ @param This Points to this instance of the
+ EFI_PEI_FIRMWARE_VOLUME_PPI.
+ @param FileHandle Handle of the file.
+ @param FileInfo Upon exit, points to the file's
+ information.
+
+ @retval EFI_SUCCESS File information returned.
+ @retval EFI_INVALID_PARAMETER If FileHandle does not
+ represent a valid file.
+ @retval EFI_INVALID_PARAMETER If FileInfo is NULL.
+
+**/
+EFI_STATUS
+EFIAPI
+PeiFfsFvPpiGetFileInfo2 (
+ IN CONST EFI_PEI_FIRMWARE_VOLUME_PPI *This,
+ IN EFI_PEI_FILE_HANDLE FileHandle,
+ OUT EFI_FV_FILE_INFO2 *FileInfo
+ );
+
+/**
This function returns information about the firmware volume.
@param This Points to this instance of the
@@ -250,7 +311,7 @@ FindFileEx (
/**
Report the information for a new discoveried FV in unknown format.
- If the EFI_PEI_FIRMWARE_VOLUME_PPI has not been install for specifical FV format, but
+ If the EFI_PEI_FIRMWARE_VOLUME_PPI has not been installed for specifical FV format, but
the FV in this FV format has been discoveried, then the information of this FV
will be cached into PEI_CORE_INSTANCE's UnknownFvInfo array.
Also a notification would be installed for unknown FV format guid, if EFI_PEI_FIRMWARE_VOLUME_PPI
@@ -258,19 +319,15 @@ FindFileEx (
using new installed EFI_PEI_FIRMWARE_VOLUME_PPI.
@param PrivateData Point to instance of PEI_CORE_INSTANCE
- @param Format Point to the unknown FV format guid.
- @param FvInfo Point to FvInfo buffer.
- @param FvInfoSize The size of FvInfo buffer.
+ @param FvInfo2Ppi Point to FvInfo2 PPI.
@retval EFI_OUT_OF_RESOURCES The FV info array in PEI_CORE_INSTANCE has no more spaces.
@retval EFI_SUCCESS Success to add the information for unknown FV.
**/
EFI_STATUS
AddUnknownFormatFvInfo (
- IN PEI_CORE_INSTANCE *PrivateData,
- IN EFI_GUID *Format,
- IN VOID *FvInfo,
- IN UINT32 FvInfoSize
+ IN PEI_CORE_INSTANCE *PrivateData,
+ IN EFI_PEI_FIRMWARE_VOLUME_INFO2_PPI *FvInfo2Ppi
);
/**
@@ -283,6 +340,7 @@ AddUnknownFormatFvInfo (
@param Format Point to given FV format guid
@param FvInfo On return, the pointer of FV information buffer in given FV format guid
@param FvInfoSize On return, the size of FV information buffer.
+ @param AuthenticationStatus On return, the authentication status of FV information buffer.
@retval EFI_NOT_FOUND The FV is not found for new installed EFI_PEI_FIRMWARE_VOLUME_PPI
@retval EFI_SUCCESS Success to find a FV which could be processed by new installed EFI_PEI_FIRMWARE_VOLUME_PPI.
@@ -292,7 +350,8 @@ FindUnknownFormatFvInfo (
IN PEI_CORE_INSTANCE *PrivateData,
IN EFI_GUID *Format,
OUT VOID **FvInfo,
- OUT UINT32 *FvInfoSize
+ OUT UINT32 *FvInfoSize,
+ OUT UINT32 *AuthenticationStatus
);
/**
diff --git a/MdeModulePkg/Core/Pei/Image/Image.c b/MdeModulePkg/Core/Pei/Image/Image.c
index 85e5e3fcf..cab08fed9 100644
--- a/MdeModulePkg/Core/Pei/Image/Image.c
+++ b/MdeModulePkg/Core/Pei/Image/Image.c
@@ -117,7 +117,7 @@ GetImageReadFunction (
Private = PEI_CORE_INSTANCE_FROM_PS_THIS (GetPeiServicesTablePointer ());
- if ((Private->PeiMemoryInstalled && !(Private->HobList.HandoffInformationTable->BootMode == BOOT_ON_S3_RESUME)) &&
+ if (Private->PeiMemoryInstalled && ((Private->HobList.HandoffInformationTable->BootMode != BOOT_ON_S3_RESUME) || PcdGetBool (PcdShadowPeimOnS3Boot)) &&
(EFI_IMAGE_MACHINE_TYPE_SUPPORTED(EFI_IMAGE_MACHINE_X64) || EFI_IMAGE_MACHINE_TYPE_SUPPORTED(EFI_IMAGE_MACHINE_IA32))) {
//
// Shadow algorithm makes lots of non ANSI C assumptions and only works for IA32 and X64
@@ -335,6 +335,9 @@ GetPeCoffImageFixLoadingAssignedAddress(
@retval EFI_SUCCESS The file was loaded and relocated
@retval EFI_OUT_OF_RESOURCES There was not enough memory to load and relocate the PE/COFF file
+ @retval EFI_WARN_BUFFER_TOO_SMALL
+ There is not enough heap to allocate the requested size.
+ This will not prevent the XIP image from being invoked.
**/
EFI_STATUS
@@ -349,9 +352,13 @@ LoadAndRelocatePeCoffImage (
PE_COFF_LOADER_IMAGE_CONTEXT ImageContext;
PEI_CORE_INSTANCE *Private;
UINT64 AlignImageSize;
+ BOOLEAN IsXipImage;
+ EFI_STATUS ReturnStatus;
Private = PEI_CORE_INSTANCE_FROM_PS_THIS (GetPeiServicesTablePointer ());
+ ReturnStatus = EFI_SUCCESS;
+ IsXipImage = FALSE;
ZeroMem (&ImageContext, sizeof (ImageContext));
ImageContext.Handle = Pe32Data;
Status = GetImageReadFunction (&ImageContext);
@@ -362,10 +369,18 @@ LoadAndRelocatePeCoffImage (
if (EFI_ERROR (Status)) {
return Status;
}
+
+ //
+ // XIP image that ImageAddress is same to Image handle.
+ //
+ if (ImageContext.ImageAddress == (EFI_PHYSICAL_ADDRESS)(UINTN) Pe32Data) {
+ IsXipImage = TRUE;
+ }
+
//
// When Image has no reloc section, it can't be relocated into memory.
//
- if (ImageContext.RelocationsStripped && (Private->PeiMemoryInstalled) && (Private->HobList.HandoffInformationTable->BootMode != BOOT_ON_S3_RESUME)) {
+ if (ImageContext.RelocationsStripped && (Private->PeiMemoryInstalled) && (Private->HobList.HandoffInformationTable->BootMode != BOOT_ON_S3_RESUME || PcdGetBool (PcdShadowPeimOnS3Boot))) {
DEBUG ((EFI_D_INFO|EFI_D_LOAD, "The image at 0x%08x without reloc section can't be loaded into memory\n", (UINTN) Pe32Data));
}
@@ -377,7 +392,7 @@ LoadAndRelocatePeCoffImage (
//
// Allocate Memory for the image when memory is ready, boot mode is not S3, and image is relocatable.
//
- if ((!ImageContext.RelocationsStripped) && (Private->PeiMemoryInstalled) && (Private->HobList.HandoffInformationTable->BootMode != BOOT_ON_S3_RESUME)) {
+ if ((!ImageContext.RelocationsStripped) && (Private->PeiMemoryInstalled) && (Private->HobList.HandoffInformationTable->BootMode != BOOT_ON_S3_RESUME || PcdGetBool (PcdShadowPeimOnS3Boot))) {
//
// Allocate more buffer to avoid buffer overflow.
//
@@ -391,7 +406,7 @@ LoadAndRelocatePeCoffImage (
AlignImageSize += ImageContext.SectionAlignment;
}
- if (PcdGet64(PcdLoadModuleAtFixAddressEnable) != 0) {
+ if (PcdGet64(PcdLoadModuleAtFixAddressEnable) != 0 && (Private->HobList.HandoffInformationTable->BootMode != BOOT_ON_S3_RESUME)) {
Status = GetPeCoffImageFixLoadingAssignedAddress(&ImageContext, Private);
if (EFI_ERROR (Status)){
DEBUG ((EFI_D_INFO|EFI_D_LOAD, "LOADING MODULE FIXED ERROR: Failed to load module at fixed address. \n"));
@@ -403,27 +418,41 @@ LoadAndRelocatePeCoffImage (
} else {
ImageContext.ImageAddress = (EFI_PHYSICAL_ADDRESS)(UINTN) AllocatePages (EFI_SIZE_TO_PAGES ((UINT32) AlignImageSize));
}
- ASSERT (ImageContext.ImageAddress != 0);
- if (ImageContext.ImageAddress == 0) {
- return EFI_OUT_OF_RESOURCES;
- }
-
- //
- // Adjust the Image Address to make sure it is section alignment.
- //
- if (ImageContext.SectionAlignment > EFI_PAGE_SIZE) {
- ImageContext.ImageAddress =
- (ImageContext.ImageAddress + ImageContext.SectionAlignment - 1) &
- ~((UINTN)ImageContext.SectionAlignment - 1);
- }
- //
- // Fix alignment requirement when Load IPF TeImage into memory.
- // Skip the reserved space for the stripped PeHeader when load TeImage into memory.
- //
- if (ImageContext.IsTeImage) {
- ImageContext.ImageAddress = ImageContext.ImageAddress +
- ((EFI_TE_IMAGE_HEADER *) Pe32Data)->StrippedSize -
- sizeof (EFI_TE_IMAGE_HEADER);
+ if (ImageContext.ImageAddress != 0) {
+ //
+ // Adjust the Image Address to make sure it is section alignment.
+ //
+ if (ImageContext.SectionAlignment > EFI_PAGE_SIZE) {
+ ImageContext.ImageAddress =
+ (ImageContext.ImageAddress + ImageContext.SectionAlignment - 1) &
+ ~((UINTN)ImageContext.SectionAlignment - 1);
+ }
+ //
+ // Fix alignment requirement when Load IPF TeImage into memory.
+ // Skip the reserved space for the stripped PeHeader when load TeImage into memory.
+ //
+ if (ImageContext.IsTeImage) {
+ ImageContext.ImageAddress = ImageContext.ImageAddress +
+ ((EFI_TE_IMAGE_HEADER *) Pe32Data)->StrippedSize -
+ sizeof (EFI_TE_IMAGE_HEADER);
+ }
+ } else {
+ //
+ // No enough memory resource.
+ //
+ if (IsXipImage) {
+ //
+ // XIP image can still be invoked.
+ //
+ ImageContext.ImageAddress = (EFI_PHYSICAL_ADDRESS)(UINTN) Pe32Data;
+ ReturnStatus = EFI_WARN_BUFFER_TOO_SMALL;
+ } else {
+ //
+ // Non XIP image can't be loaded because no enough memory is allocated.
+ //
+ ASSERT (FALSE);
+ return EFI_OUT_OF_RESOURCES;
+ }
}
}
@@ -445,7 +474,7 @@ LoadAndRelocatePeCoffImage (
//
// Flush the instruction cache so the image data is written before we execute it
//
- if ((!ImageContext.RelocationsStripped) && (Private->PeiMemoryInstalled) && (Private->HobList.HandoffInformationTable->BootMode != BOOT_ON_S3_RESUME)) {
+ if (ImageContext.ImageAddress != (EFI_PHYSICAL_ADDRESS)(UINTN) Pe32Data) {
InvalidateInstructionCacheRange ((VOID *)(UINTN)ImageContext.ImageAddress, (UINTN)ImageContext.ImageSize);
}
@@ -453,7 +482,7 @@ LoadAndRelocatePeCoffImage (
*ImageSize = ImageContext.ImageSize;
*EntryPoint = ImageContext.EntryPoint;
- return EFI_SUCCESS;
+ return ReturnStatus;
}
/**
@@ -471,6 +500,9 @@ LoadAndRelocatePeCoffImage (
@retval EFI_SUCCESS Image is successfully loaded.
@retval EFI_NOT_FOUND Fail to locate necessary PPI.
@retval EFI_UNSUPPORTED Image Machine Type is not supported.
+ @retval EFI_WARN_BUFFER_TOO_SMALL
+ There is not enough heap to allocate the requested size.
+ This will not prevent the XIP image from being invoked.
**/
EFI_STATUS
@@ -508,23 +540,27 @@ PeiLoadImageLoadImage (
// Try to find a first exe section (if PcdPeiCoreImageLoaderSearchTeSectionFirst
// is true, TE will be searched first).
//
- Status = PeiServicesFfsFindSectionData (
+ Status = PeiServicesFfsFindSectionData3 (
SearchType1,
+ 0,
FileHandle,
- &Pe32Data
+ &Pe32Data,
+ AuthenticationState
);
//
// If we didn't find a first exe section, try to find the second exe section.
//
if (EFI_ERROR (Status)) {
- Status = PeiServicesFfsFindSectionData (
+ Status = PeiServicesFfsFindSectionData3 (
SearchType2,
+ 0,
FileHandle,
- &Pe32Data
+ &Pe32Data,
+ AuthenticationState
);
if (EFI_ERROR (Status)) {
//
- // PEI core only carry the loader function fro TE and PE32 executables
+ // PEI core only carry the loader function for TE and PE32 executables
// If this two section does not exist, just return.
//
return Status;
@@ -785,7 +821,7 @@ PeiLoadImage (
EntryPoint,
AuthenticationState
);
- if (!EFI_ERROR (Status)) {
+ if (!EFI_ERROR (Status) || Status == EFI_WARN_BUFFER_TOO_SMALL) {
//
// The shadowed PEIM must be relocatable.
//
@@ -804,7 +840,7 @@ PeiLoadImage (
if (!EFI_IMAGE_MACHINE_TYPE_SUPPORTED (PeCoffLoaderGetMachineType ((VOID *) (UINTN) ImageAddress))) {
return EFI_UNSUPPORTED;
}
- return Status;
+ return EFI_SUCCESS;
}
}
Index++;
diff --git a/MdeModulePkg/Core/Pei/PeiMain.h b/MdeModulePkg/Core/Pei/PeiMain.h
index 193704de1..6a9feb03c 100644
--- a/MdeModulePkg/Core/Pei/PeiMain.h
+++ b/MdeModulePkg/Core/Pei/PeiMain.h
@@ -1,7 +1,7 @@
/** @file
Definition of Pei Core Structures and Services
-Copyright (c) 2006 - 2011, Intel Corporation. All rights reserved.<BR>
+Copyright (c) 2006 - 2013, 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,7 @@ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
#include <Ppi/Reset.h>
#include <Ppi/FirmwareVolume.h>
#include <Ppi/FirmwareVolumeInfo.h>
+#include <Ppi/FirmwareVolumeInfo2.h>
#include <Ppi/Decompress.h>
#include <Ppi/GuidedSectionExtraction.h>
#include <Ppi/LoadFile.h>
@@ -110,12 +111,14 @@ typedef struct {
UINT8 PeimState[FixedPcdGet32 (PcdPeiCoreMaxPeimPerFv)];
EFI_PEI_FILE_HANDLE FvFileHandles[FixedPcdGet32 (PcdPeiCoreMaxPeimPerFv)];
BOOLEAN ScanFv;
+ UINT32 AuthenticationStatus;
} PEI_CORE_FV_HANDLE;
typedef struct {
EFI_GUID FvFormat;
VOID *FvInfo;
UINT32 FvInfoSize;
+ UINT32 AuthenticationStatus;
EFI_PEI_NOTIFY_DESCRIPTOR NotifyDescriptor;
} PEI_CORE_UNKNOW_FORMAT_FV_INFO;
@@ -124,6 +127,7 @@ typedef struct {
EFI_COMMON_SECTION_HEADER* Section[CACHE_SETION_MAX_NUMBER];
VOID* SectionData[CACHE_SETION_MAX_NUMBER];
UINTN SectionSize[CACHE_SETION_MAX_NUMBER];
+ UINT32 AuthenticationStatus[CACHE_SETION_MAX_NUMBER];
UINTN AllSectionCount;
UINTN SectionIndex;
} CACHE_SECTION_DATA;
@@ -583,23 +587,23 @@ VerifyFv (
);
/**
-
Provide a callout to the security verification service.
-
@param PrivateData PeiCore's private data structure
@param VolumeHandle Handle of FV
@param FileHandle Handle of PEIM's ffs
+ @param AuthenticationStatus Authentication status
@retval EFI_SUCCESS Image is OK
@retval EFI_SECURITY_VIOLATION Image is illegal
-
+ @retval EFI_NOT_FOUND If security PPI is not installed.
**/
EFI_STATUS
VerifyPeim (
IN PEI_CORE_INSTANCE *PrivateData,
IN EFI_PEI_FV_HANDLE VolumeHandle,
- IN EFI_PEI_FILE_HANDLE FileHandle
+ IN EFI_PEI_FILE_HANDLE FileHandle,
+ IN UINT32 AuthenticationStatus
);
/**
@@ -715,6 +719,31 @@ PeiFfsFindSectionData (
);
/**
+ Searches for the next matching section within the specified file.
+
+ @param PeiServices An indirect pointer to the EFI_PEI_SERVICES table published by the PEI Foundation.
+ @param SectionType The value of the section type to find.
+ @param SectionInstance Section instance to find.
+ @param FileHandle Handle of the firmware file to search.
+ @param SectionData A pointer to the discovered section, if successful.
+ @param AuthenticationStatus A pointer to the authentication status for this section.
+
+ @retval EFI_SUCCESS The section was found.
+ @retval EFI_NOT_FOUND The section was not found.
+
+**/
+EFI_STATUS
+EFIAPI
+PeiFfsFindSectionData3 (
+ IN CONST EFI_PEI_SERVICES **PeiServices,
+ IN EFI_SECTION_TYPE SectionType,
+ IN UINTN SectionInstance,
+ IN EFI_PEI_FILE_HANDLE FileHandle,
+ OUT VOID **SectionData,
+ OUT UINT32 *AuthenticationStatus
+ );
+
+/**
Search the firmware volumes by index
@param PeiServices An indirect pointer to the EFI_PEI_SERVICES table published by the PEI Foundation
@@ -968,6 +997,24 @@ PeiFfsGetFileInfo (
);
/**
+ Returns information about a specific file.
+
+ @param FileHandle Handle of the file.
+ @param FileInfo Upon exit, points to the file's information.
+
+ @retval EFI_INVALID_PARAMETER If FileInfo is NULL.
+ @retval EFI_INVALID_PARAMETER If FileHandle does not represent a valid file.
+ @retval EFI_SUCCESS File information returned.
+
+**/
+EFI_STATUS
+EFIAPI
+PeiFfsGetFileInfo2 (
+ IN EFI_PEI_FILE_HANDLE FileHandle,
+ OUT EFI_FV_FILE_INFO2 *FileInfo
+ );
+
+/**
Returns information about the specified volume.
@param VolumeHandle Handle of the volume.
@@ -1061,19 +1108,22 @@ SecurityPpiNotifyCallback (
);
/**
- Get Fv image from the FV type file, then install FV INFO ppi, Build FV hob.
+ Get Fv image from the FV type file, then install FV INFO(2) ppi, Build FV hob.
+ @param PrivateData PeiCore's private data structure
@param ParentFvCoreHandle Pointer of EFI_CORE_FV_HANDLE to parent Fv image that contain this Fv image.
@param ParentFvFileHandle File handle of a Fv type file that contain this Fv image.
@retval EFI_NOT_FOUND FV image can't be found.
@retval EFI_SUCCESS Successfully to process it.
@retval EFI_OUT_OF_RESOURCES Can not allocate page when aligning FV image
+ @retval EFI_SECURITY_VIOLATION Image is illegal
@retval Others Can not find EFI_SECTION_FIRMWARE_VOLUME_IMAGE section
**/
EFI_STATUS
ProcessFvFile (
+ IN PEI_CORE_INSTANCE *PrivateData,
IN PEI_CORE_FV_HANDLE *ParentFvCoreHandle,
IN EFI_PEI_FILE_HANDLE ParentFvFileHandle
);
diff --git a/MdeModulePkg/Core/Pei/PeiMain.inf b/MdeModulePkg/Core/Pei/PeiMain.inf
index 2cf9df7ce..26d1c49d5 100644
--- a/MdeModulePkg/Core/Pei/PeiMain.inf
+++ b/MdeModulePkg/Core/Pei/PeiMain.inf
@@ -4,7 +4,7 @@
# 2) Dispatch PEIM from discovered FV.
# 3) Handoff control to DxeIpl to load DXE core and enter DXE phase.
#
-# Copyright (c) 2006 - 2012, Intel Corporation. All rights reserved.<BR>
+# Copyright (c) 2006 - 2013, 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
@@ -76,11 +76,12 @@
[Ppis]
gEfiPeiStatusCodePpiGuid ## SOMETIMES_CONSUMES (PeiReportStatusService is not ready if this PPI doesn't exist)
- gEfiPeiResetPpiGuid ## SOMETIMES_CONSUMES (PeiResetService is not ready if this PPI doesn't exist)
+ gEfiPeiResetPpiGuid ## SOMETIMES_CONSUMES (PeiResetService is not ready if this PPI doesn't exist)
gEfiDxeIplPpiGuid ## CONSUMES
gEfiPeiMemoryDiscoveredPpiGuid ## PRODUCES
gEfiPeiDecompressPpiGuid ## CONSUMES
- gEfiPeiFirmwareVolumeInfoPpiGuid ## NOTIFY ## SOMETIMES_PRODUCES (Produce FvInfoPpi if the encapsulated FvImage is found)
+ gEfiPeiFirmwareVolumeInfoPpiGuid ## NOTIFY ## SOMETIMES_PRODUCES (Produce FvInfoPpi if the encapsulated FvImage is found)
+ gEfiPeiFirmwareVolumeInfo2PpiGuid ## NOTIFY ## SOMETIMES_PRODUCES (Produce FvInfo2Ppi if the encapsulated FvImage is found)
gEfiPeiLoadFilePpiGuid ## PRODUCES ## SOMETIMES_CONSUMES (The default load PeImage logic will be used when this PPI doesn't exist)
gEfiPeiSecurity2PpiGuid ## NOTIFY
gEfiTemporaryRamSupportPpiGuid ## CONSUMES
@@ -98,4 +99,4 @@
gEfiMdeModulePkgTokenSpaceGuid.PcdLoadFixAddressBootTimeCodePageNumber ## SOMETIMES_CONSUMES
gEfiMdeModulePkgTokenSpaceGuid.PcdLoadFixAddressRuntimeCodePageNumber ## SOMETIMES_CONSUMES
gEfiMdeModulePkgTokenSpaceGuid.PcdLoadModuleAtFixAddressEnable ## CONSUMES
-
+ gEfiMdeModulePkgTokenSpaceGuid.PcdShadowPeimOnS3Boot ## SOMETIMES_CONSUMES
diff --git a/MdeModulePkg/Core/Pei/PeiMain/PeiMain.c b/MdeModulePkg/Core/Pei/PeiMain/PeiMain.c
index 2f63e4c6a..bf000229a 100644
--- a/MdeModulePkg/Core/Pei/PeiMain/PeiMain.c
+++ b/MdeModulePkg/Core/Pei/PeiMain/PeiMain.c
@@ -1,7 +1,7 @@
/** @file
Pei Core Main Entry Point
-Copyright (c) 2006 - 2011, Intel Corporation. All rights reserved.<BR>
+Copyright (c) 2006 - 2013, 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
@@ -61,7 +61,9 @@ EFI_PEI_SERVICES gPs = {
PeiFfsFindFileByName,
PeiFfsGetFileInfo,
PeiFfsGetVolumeInfo,
- PeiRegisterForShadow
+ PeiRegisterForShadow,
+ PeiFfsFindSectionData3,
+ PeiFfsGetFileInfo2
};
/**
diff --git a/MdeModulePkg/Core/Pei/Security/Security.c b/MdeModulePkg/Core/Pei/Security/Security.c
index a7515ec22..f08926766 100644
--- a/MdeModulePkg/Core/Pei/Security/Security.c
+++ b/MdeModulePkg/Core/Pei/Security/Security.c
@@ -1,7 +1,7 @@
/** @file
EFI PEI Core Security services
-Copyright (c) 2006 - 2010, Intel Corporation. All rights reserved.<BR>
+Copyright (c) 2006 - 2013, 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,13 +78,12 @@ SecurityPpiNotifyCallback (
}
/**
-
Provide a callout to the security verification service.
-
@param PrivateData PeiCore's private data structure
@param VolumeHandle Handle of FV
@param FileHandle Handle of PEIM's ffs
+ @param AuthenticationStatus Authentication status
@retval EFI_SUCCESS Image is OK
@retval EFI_SECURITY_VIOLATION Image is illegal
@@ -94,17 +93,13 @@ EFI_STATUS
VerifyPeim (
IN PEI_CORE_INSTANCE *PrivateData,
IN EFI_PEI_FV_HANDLE VolumeHandle,
- IN EFI_PEI_FILE_HANDLE FileHandle
+ IN EFI_PEI_FILE_HANDLE FileHandle,
+ IN UINT32 AuthenticationStatus
)
{
EFI_STATUS Status;
- UINT32 AuthenticationStatus;
BOOLEAN DeferExection;
- //
- // Set a default authentication state
- //
- AuthenticationStatus = 0;
if (PrivateData->PrivateSecurityPpi == NULL) {
Status = EFI_NOT_FOUND;
diff --git a/MdeModulePkg/Include/Guid/NicIp4ConfigNvData.h b/MdeModulePkg/Include/Guid/NicIp4ConfigNvData.h
index b25308131..d3ce76f05 100644
--- a/MdeModulePkg/Include/Guid/NicIp4ConfigNvData.h
+++ b/MdeModulePkg/Include/Guid/NicIp4ConfigNvData.h
@@ -61,7 +61,7 @@ typedef struct {
typedef struct {
NIC_ADDR NicAddr; ///< Link layer address to identify the NIC.
UINT32 Source; ///< Static or DHCP.
- BOOLEAN Perment; ///< Survive the reboot or not.
+ BOOLEAN Permanent; ///< Survive the reboot or not.
EFI_IP4_IPCONFIG_DATA Ip4Info; ///< IP addresses.
} NIC_IP4_CONFIG_INFO;
diff --git a/MdeModulePkg/Include/Library/HiiLib.h b/MdeModulePkg/Include/Library/HiiLib.h
index 1bdcbfe56..0e323df22 100644
--- a/MdeModulePkg/Include/Library/HiiLib.h
+++ b/MdeModulePkg/Include/Library/HiiLib.h
@@ -732,7 +732,8 @@ HiiCreateGotoExOpCode (
@param[in] OpCodeHandle The handle to the buffer of opcodes.
@param[in] QuestionId The question ID.
@param[in] VarStoreId The storage ID.
- @param[in] VarOffset The offset in Storage.
+ @param[in] VarOffset Offset in Storage or String ID of the name (VarName)
+ for this name/value pair.
@param[in] Prompt The string ID for Prompt.
@param[in] Help The string ID for Help.
@param[in] QuestionFlags The flags in Question Header.
@@ -768,7 +769,8 @@ HiiCreateCheckBoxOpCode (
@param[in] OpCodeHandle The handle to the buffer of opcodes.
@param[in] QuestionId The question ID.
@param[in] VarStoreId The storage ID.
- @param[in] VarOffset The offset in Storage.
+ @param[in] VarOffset Offset in Storage or String ID of the name (VarName)
+ for this name/value pair.
@param[in] Prompt The string ID for Prompt.
@param[in] Help The string ID for Help.
@param[in] QuestionFlags The flags in Question Header.
@@ -810,7 +812,8 @@ HiiCreateNumericOpCode (
@param[in] OpCodeHandle The handle to the buffer of opcodes.
@param[in] QuestionId The question ID.
@param[in] VarStoreId The storage ID.
- @param[in] VarOffset The offset in Storage.
+ @param[in] VarOffset Offset in Storage or String ID of the name (VarName)
+ for this name/value pair.
@param[in] Prompt The string ID for Prompt.
@param[in] Help The string ID for Help.
@param[in] QuestionFlags The flags in Question Header.
@@ -850,7 +853,8 @@ HiiCreateStringOpCode (
@param[in] OpCodeHandle The handle to the buffer of opcodes.
@param[in] QuestionId The question ID.
@param[in] VarStoreId The storage ID.
- @param[in] VarOffset The offset in Storage.
+ @param[in] VarOffset Offset in Storage or String ID of the name (VarName)
+ for this name/value pair.
@param[in] Prompt The string ID for Prompt.
@param[in] Help The string ID for Help.
@param[in] QuestionFlags The flags in Question Header.
@@ -888,7 +892,8 @@ HiiCreateOneOfOpCode (
@param[in] OpCodeHandle The handle to the buffer of opcodes.
@param[in] QuestionId The question ID.
@param[in] VarStoreId The storage ID.
- @param[in] VarOffset The offset in Storage.
+ @param[in] VarOffset Offset in Storage or String ID of the name (VarName)
+ for this name/value pair.
@param[in] Prompt The string ID for Prompt.
@param[in] Help The string ID for Help.
@param[in] QuestionFlags The flags in Question Header.
@@ -954,7 +959,8 @@ HiiCreateTextOpCode (
@param[in] QuestionId Question ID
@param[in] VarStoreId Storage ID, optional. If DateFlags is not
QF_DATE_STORAGE_NORMAL, this parameter is ignored.
- @param[in] VarOffset Offset in Storage, optional. If DateFlags is not
+ @param[in] VarOffset Offset in Storage or String ID of the name (VarName)
+ for this name/value pair, optional. If DateFlags is not
QF_DATE_STORAGE_NORMAL, this parameter is ignored.
@param[in] Prompt String ID for Prompt
@param[in] Help String ID for Help
@@ -992,7 +998,8 @@ HiiCreateDateOpCode (
@param[in] QuestionId Question ID
@param[in] VarStoreId Storage ID, optional. If TimeFlags is not
QF_TIME_STORAGE_NORMAL, this parameter is ignored.
- @param[in] VarOffset Offset in Storage, optional. If TimeFlags is not
+ @param[in] VarOffset Offset in Storage or String ID of the name (VarName)
+ for this name/value pair, optional. If TimeFlags is not
QF_TIME_STORAGE_NORMAL, this parameter is ignored.
@param[in] Prompt String ID for Prompt
@param[in] Help String ID for Help
diff --git a/MdeModulePkg/Include/Protocol/DisplayProtocol.h b/MdeModulePkg/Include/Protocol/DisplayProtocol.h
index d4f0debf9..f8b80f5e4 100644
--- a/MdeModulePkg/Include/Protocol/DisplayProtocol.h
+++ b/MdeModulePkg/Include/Protocol/DisplayProtocol.h
@@ -137,10 +137,12 @@ EFI_STATUS
//
// Attribute for Statement and Form
//
+#define HII_DISPLAY_NONE 0
#define HII_DISPLAY_GRAYOUT BIT0
#define HII_DISPLAY_LOCK BIT1
#define HII_DISPLAY_READONLY BIT2
#define HII_DISPLAY_MODAL BIT3
+#define HII_DISPLAY_SUPPRESS BIT4
struct _FORM_DISPLAY_ENGINE_STATEMENT{
UINTN Signature;
diff --git a/MdeModulePkg/Include/Protocol/FormBrowserEx2.h b/MdeModulePkg/Include/Protocol/FormBrowserEx2.h
index 105ac0308..df583ef86 100644
--- a/MdeModulePkg/Include/Protocol/FormBrowserEx2.h
+++ b/MdeModulePkg/Include/Protocol/FormBrowserEx2.h
@@ -68,6 +68,21 @@ typedef struct {
#define FORM_ENTRY_INFO_FROM_LINK(a) CR (a, FORM_ENTRY_INFO, Link, FORM_ENTRY_INFO_SIGNATURE)
+#define FORM_QUESTION_ATTRIBUTE_OVERRIDE_SIGNATURE SIGNATURE_32 ('f', 'q', 'o', 's')
+
+typedef struct {
+ UINTN Signature;
+ LIST_ENTRY Link;
+
+ EFI_QUESTION_ID QuestionId; // Find the question
+ EFI_FORM_ID FormId; // Find the form
+ EFI_GUID FormSetGuid; // Find the formset.
+ EFI_HII_HANDLE HiiHandle; // Find the HII handle
+ UINT32 Attribute; // Hide or grayout ...
+} QUESTION_ATTRIBUTE_OVERRIDE;
+
+#define FORM_QUESTION_ATTRIBUTE_OVERRIDE_FROM_LINK(a) CR (a, QUESTION_ATTRIBUTE_OVERRIDE, Link, FORM_QUESTION_ATTRIBUTE_OVERRIDE_SIGNATURE)
+
struct _EDKII_FORM_BROWSER_EXTENSION2_PROTOCOL {
///
/// Version for protocol future extension.
@@ -82,6 +97,10 @@ struct _EDKII_FORM_BROWSER_EXTENSION2_PROTOCOL {
/// A list of type FORMID_INFO is Browser View Form History List.
///
LIST_ENTRY FormViewHistoryHead;
+ ///
+ /// A list of type QUESTION_ATTRIBUTE_OVERRIDE.
+ ///
+ LIST_ENTRY OverrideQestListHead;
};
extern EFI_GUID gEdkiiFormBrowserEx2ProtocolGuid;
diff --git a/MdeModulePkg/Library/CustomizedDisplayLib/CustomizedDisplayLib.c b/MdeModulePkg/Library/CustomizedDisplayLib/CustomizedDisplayLib.c
index aa28146b0..92f3a43a7 100644
--- a/MdeModulePkg/Library/CustomizedDisplayLib/CustomizedDisplayLib.c
+++ b/MdeModulePkg/Library/CustomizedDisplayLib/CustomizedDisplayLib.c
@@ -144,6 +144,12 @@ RefreshKeyHelp (
EFI_IFR_DATE *DateOp;
EFI_IFR_TIME *TimeOp;
BOOLEAN HexDisplay;
+ UINTN ColumnWidth1;
+ UINTN ColumnWidth2;
+ UINTN ColumnWidth3;
+ CHAR16 *ColumnStr1;
+ CHAR16 *ColumnStr2;
+ CHAR16 *ColumnStr3;
ASSERT (FormData != NULL);
if (FormData == NULL) {
@@ -161,17 +167,27 @@ RefreshKeyHelp (
StartColumnOfHelp = gScreenDimensions.LeftColumn + 2;
LeftColumnOfHelp = gScreenDimensions.LeftColumn + 1;
- RightColumnOfHelp = gScreenDimensions.RightColumn - 2;
+ RightColumnOfHelp = gScreenDimensions.RightColumn - 1;
TopRowOfHelp = gScreenDimensions.BottomRow - STATUS_BAR_HEIGHT - gFooterHeight + 1;
BottomRowOfHelp = gScreenDimensions.BottomRow - STATUS_BAR_HEIGHT - 2;
- ClearLines (LeftColumnOfHelp, RightColumnOfHelp, TopRowOfHelp, BottomRowOfHelp, KEYHELP_TEXT | KEYHELP_BACKGROUND);
+ ColumnWidth1 = SecCol - StartColumnOfHelp;
+ ColumnWidth2 = ThdCol - SecCol;
+ ColumnWidth3 = RightColumnOfHelp - ThdCol;
+ ColumnStr1 = gLibEmptyString;
+ ColumnStr2 = gLibEmptyString;
+ ColumnStr3 = gLibEmptyString;
+
if (Statement == NULL) {
//
// Print Key for Form without showable statement.
//
- PrintHotKeyHelpString (FormData);
- PrintStringAt (ThdCol, BottomRowOfHelp, gEscapeString);
+ PrintHotKeyHelpString (FormData, TRUE);
+ PrintStringAtWithWidth (StartColumnOfHelp, BottomRowOfHelp, gLibEmptyString, ColumnWidth1);
+ PrintStringAtWithWidth (SecCol, BottomRowOfHelp, gLibEmptyString, ColumnWidth2);
+ PrintStringAtWithWidth (StartColumnOfHelp, TopRowOfHelp, gLibEmptyString, ColumnWidth1);
+ PrintStringAtWithWidth (ThdCol, BottomRowOfHelp, gEscapeString, ColumnWidth3);
+
return;
}
@@ -196,16 +212,17 @@ RefreshKeyHelp (
case EFI_IFR_TIME_OP:
case EFI_IFR_DATE_OP:
if (!Selected) {
- PrintHotKeyHelpString (FormData);
+ PrintHotKeyHelpString (FormData, TRUE);
if (gClassOfVfr == FORMSET_CLASS_PLATFORM_SETUP) {
- PrintStringAt (ThdCol, BottomRowOfHelp, gEscapeString);
+ ColumnStr3 = gEscapeString;
}
+ PrintStringAtWithWidth (ThdCol, BottomRowOfHelp, ColumnStr3, ColumnWidth3);
if ((Statement->OpCode->OpCode == EFI_IFR_DATE_OP) ||
(Statement->OpCode->OpCode == EFI_IFR_TIME_OP)) {
PrintAt (
- 0,
+ ColumnWidth1,
StartColumnOfHelp,
BottomRowOfHelp,
L"%c%c%c%c%s",
@@ -215,17 +232,19 @@ RefreshKeyHelp (
ARROW_LEFT,
gMoveHighlight
);
- PrintStringAt (SecCol, BottomRowOfHelp, gEnterString);
- PrintStringAt (StartColumnOfHelp, TopRowOfHelp, gAdjustNumber);
+ PrintStringAtWithWidth (SecCol, BottomRowOfHelp, gEnterString, ColumnWidth2);
+ PrintStringAtWithWidth (StartColumnOfHelp, TopRowOfHelp, gAdjustNumber, ColumnWidth1);
} else {
- PrintAt (0, StartColumnOfHelp, BottomRowOfHelp, L"%c%c%s", ARROW_UP, ARROW_DOWN, gMoveHighlight);
+ PrintAt (ColumnWidth1, StartColumnOfHelp, BottomRowOfHelp, L"%c%c%s", ARROW_UP, ARROW_DOWN, gMoveHighlight);
if (Statement->OpCode->OpCode == EFI_IFR_NUMERIC_OP && NumericOp != NULL && LibGetFieldFromNum(Statement->OpCode) != 0) {
- PrintStringAt (StartColumnOfHelp, TopRowOfHelp, gAdjustNumber);
- }
- PrintStringAt (SecCol, BottomRowOfHelp, gEnterString);
+ ColumnStr1 = gAdjustNumber;
+ }
+ PrintStringAtWithWidth (StartColumnOfHelp, TopRowOfHelp, ColumnStr1, ColumnWidth1);
+ PrintStringAtWithWidth (SecCol, BottomRowOfHelp, gEnterString, ColumnWidth2);
}
} else {
- PrintStringAt (SecCol, BottomRowOfHelp, gEnterCommitString);
+ PrintHotKeyHelpString (FormData, FALSE);
+ PrintStringAtWithWidth (SecCol, BottomRowOfHelp, gEnterCommitString, ColumnWidth2);
//
// If it is a selected numeric with manual input, display different message
@@ -233,33 +252,35 @@ RefreshKeyHelp (
if ((Statement->OpCode->OpCode == EFI_IFR_NUMERIC_OP) ||
(Statement->OpCode->OpCode == EFI_IFR_DATE_OP) ||
(Statement->OpCode->OpCode == EFI_IFR_TIME_OP)) {
- PrintStringAt (
- SecCol,
- TopRowOfHelp,
- HexDisplay ? gHexNumericInput : gDecNumericInput
- );
- } else if (Statement->OpCode->OpCode != EFI_IFR_ORDERED_LIST_OP) {
- PrintAt (0, StartColumnOfHelp, BottomRowOfHelp, L"%c%c%s", ARROW_UP, ARROW_DOWN, gMoveHighlight);
+ ColumnStr2 = HexDisplay ? gHexNumericInput : gDecNumericInput;
+ PrintStringAtWithWidth (StartColumnOfHelp, BottomRowOfHelp, gLibEmptyString, ColumnWidth1);
+ } else {
+ PrintAt (ColumnWidth1, StartColumnOfHelp, BottomRowOfHelp, L"%c%c%s", ARROW_UP, ARROW_DOWN, gMoveHighlight);
}
if (Statement->OpCode->OpCode == EFI_IFR_ORDERED_LIST_OP) {
- PrintStringAt (StartColumnOfHelp, TopRowOfHelp, gPlusString);
- PrintStringAt (ThdCol, TopRowOfHelp, gMinusString);
+ ColumnStr1 = gPlusString;
+ ColumnStr3 = gMinusString;
}
+ PrintStringAtWithWidth (StartColumnOfHelp, TopRowOfHelp, ColumnStr1, ColumnWidth1);
+ PrintStringAtWithWidth (ThdCol, TopRowOfHelp, ColumnStr3, ColumnWidth3);
+ PrintStringAtWithWidth (SecCol, TopRowOfHelp, ColumnStr2, ColumnWidth2);
- PrintStringAt (ThdCol, BottomRowOfHelp, gEnterEscapeString);
+ PrintStringAtWithWidth (ThdCol, BottomRowOfHelp, gEnterEscapeString, ColumnWidth3);
}
break;
case EFI_IFR_CHECKBOX_OP:
- PrintHotKeyHelpString (FormData);
+ PrintHotKeyHelpString (FormData, TRUE);
if (gClassOfVfr == FORMSET_CLASS_PLATFORM_SETUP) {
- PrintStringAt (ThdCol, BottomRowOfHelp, gEscapeString);
+ ColumnStr3 = gEscapeString;
}
+ PrintStringAtWithWidth (ThdCol, BottomRowOfHelp, ColumnStr3, ColumnWidth3);
- PrintAt (0, StartColumnOfHelp, BottomRowOfHelp, L"%c%c%s", ARROW_UP, ARROW_DOWN, gMoveHighlight);
- PrintStringAt (SecCol, BottomRowOfHelp, gToggleCheckBox);
+ PrintAt (ColumnWidth1, StartColumnOfHelp, BottomRowOfHelp, L"%c%c%s", ARROW_UP, ARROW_DOWN, gMoveHighlight);
+ PrintStringAtWithWidth (SecCol, BottomRowOfHelp, gToggleCheckBox, ColumnWidth2);
+ PrintStringAtWithWidth (StartColumnOfHelp, TopRowOfHelp, gLibEmptyString, ColumnWidth1);
break;
case EFI_IFR_REF_OP:
@@ -270,25 +291,29 @@ RefreshKeyHelp (
case EFI_IFR_RESET_BUTTON_OP:
case EFI_IFR_SUBTITLE_OP:
if (!Selected) {
- PrintHotKeyHelpString (FormData);
+ PrintHotKeyHelpString (FormData, TRUE);
if (gClassOfVfr == FORMSET_CLASS_PLATFORM_SETUP) {
- PrintStringAt (ThdCol, BottomRowOfHelp, gEscapeString);
+ ColumnStr3 = gEscapeString;
}
+ PrintStringAtWithWidth (ThdCol, BottomRowOfHelp, ColumnStr3, ColumnWidth3);
- PrintAt (0, StartColumnOfHelp, BottomRowOfHelp, L"%c%c%s", ARROW_UP, ARROW_DOWN, gMoveHighlight);
+ PrintAt (ColumnWidth1, StartColumnOfHelp, BottomRowOfHelp, L"%c%c%s", ARROW_UP, ARROW_DOWN, gMoveHighlight);
if (Statement->OpCode->OpCode != EFI_IFR_TEXT_OP && Statement->OpCode->OpCode != EFI_IFR_SUBTITLE_OP) {
- PrintStringAt (SecCol, BottomRowOfHelp, gEnterString);
+ ColumnStr2 = gEnterString;
}
+ PrintStringAtWithWidth (SecCol, BottomRowOfHelp, ColumnStr2, ColumnWidth2);
+ PrintStringAtWithWidth (StartColumnOfHelp, TopRowOfHelp, ColumnStr1, ColumnWidth1);
} else {
- if (Statement->OpCode->OpCode != EFI_IFR_REF_OP) {
- PrintStringAt (
- (gScreenDimensions.RightColumn - LibGetStringWidth (gEnterCommitString) / 2) / 2,
- BottomRowOfHelp,
- gEnterCommitString
- );
- PrintStringAt (ThdCol, BottomRowOfHelp, gEnterEscapeString);
+ PrintHotKeyHelpString (FormData, FALSE);
+ if (Statement->OpCode->OpCode != EFI_IFR_REF_OP) {
+ ColumnStr2 = gEnterCommitString;
+ ColumnStr3 = gEnterEscapeString;
}
+ PrintStringAtWithWidth (StartColumnOfHelp, TopRowOfHelp, ColumnStr1, ColumnWidth1);
+ PrintStringAtWithWidth (StartColumnOfHelp, BottomRowOfHelp, ColumnStr1, ColumnWidth1);
+ PrintStringAtWithWidth (SecCol, BottomRowOfHelp, ColumnStr2, ColumnWidth2);
+ PrintStringAtWithWidth (ThdCol, BottomRowOfHelp, ColumnStr3, ColumnWidth3);
}
break;
@@ -395,6 +420,7 @@ CreateDialog (
UINTN DimensionsWidth;
UINTN DimensionsHeight;
UINTN CurrentAttribute;
+ BOOLEAN CursorVisible;
//
// If screen dimension info is not ready, get it from console.
@@ -428,7 +454,8 @@ CreateDialog (
LargestString = DimensionsWidth - 2;
}
- CurrentAttribute = gST->ConOut->Mode->Attribute;
+ CurrentAttribute = gST->ConOut->Mode->Attribute;
+ CursorVisible = gST->ConOut->Mode->CursorVisible;
gST->ConOut->EnableCursor (gST->ConOut, FALSE);
gST->ConOut->SetAttribute (gST->ConOut, GetPopupColor ());
@@ -510,7 +537,7 @@ CreateDialog (
}
gST->ConOut->SetAttribute (gST->ConOut, CurrentAttribute);
- gST->ConOut->EnableCursor (gST->ConOut, TRUE);
+ gST->ConOut->EnableCursor (gST->ConOut, CursorVisible);
}
/**
diff --git a/MdeModulePkg/Library/CustomizedDisplayLib/CustomizedDisplayLib.inf b/MdeModulePkg/Library/CustomizedDisplayLib/CustomizedDisplayLib.inf
index ade45b6a5..841e01318 100644
--- a/MdeModulePkg/Library/CustomizedDisplayLib/CustomizedDisplayLib.inf
+++ b/MdeModulePkg/Library/CustomizedDisplayLib/CustomizedDisplayLib.inf
@@ -1,27 +1,16 @@
-##
-# This file contains an 'Intel Peripheral Driver' and is
-# licensed for Intel CPUs and chipsets under the terms of your
-# license agreement with Intel or your vendor. This file may
-# be modified by the user, subject to additional terms of the
-# license agreement
-##
## @file
-#
-# General BDS defines and produce general interfaces for platform BDS driver including:
-# 1) BDS boot policy interface;
-# 2) BDS boot device connect interface;
-# 3) BDS Misc interfaces for mainting boot variable, ouput string, etc.
-#
-# Copyright (c) 2007 - 2010, Intel Corporation. All rights reserved.<BR>
-# This software and associated documentation (if any) is furnished
-# under a license and may only be used or copied in accordance
-# with the terms of the license. Except as permitted by such
-# license, no part of this software or documentation may be
-# reproduced, stored in a retrieval system, or transmitted in any
-# form or by any means without the express written consent of
-# Intel Corporation.
-#
-##
+# Customize display library used by display engine.
+#
+# Copyright (c) 2013, 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.
+#
+#
[Defines]
INF_VERSION = 0x00010005
diff --git a/MdeModulePkg/Library/CustomizedDisplayLib/CustomizedDisplayLibInternal.c b/MdeModulePkg/Library/CustomizedDisplayLib/CustomizedDisplayLibInternal.c
index b6b4055b6..82ab82bb3 100644
--- a/MdeModulePkg/Library/CustomizedDisplayLib/CustomizedDisplayLibInternal.c
+++ b/MdeModulePkg/Library/CustomizedDisplayLib/CustomizedDisplayLibInternal.c
@@ -144,6 +144,7 @@ PrintFramework (
CHAR16 *Buffer;
UINTN Row;
CHAR16 *TitleStr;
+ UINTN TitleColumn;
if (gClassOfVfr != FORMSET_CLASS_PLATFORM_SETUP) {
//
@@ -190,20 +191,15 @@ PrintFramework (
//
// Print Form Title
//
- ClearLines (
- gScreenDimensions.LeftColumn + 1,
- gScreenDimensions.RightColumn - 1,
- gScreenDimensions.TopRow + 1,
- gScreenDimensions.TopRow + 1,
- TITLE_TEXT | TITLE_BACKGROUND
- );
-
TitleStr = LibGetToken (FormData->FormTitle, FormData->HiiHandle);
ASSERT (TitleStr != NULL);
- PrintStringAt (
- (gScreenDimensions.RightColumn + gScreenDimensions.LeftColumn - LibGetStringWidth (TitleStr) / 2) / 2,
+ TitleColumn = (gScreenDimensions.RightColumn + gScreenDimensions.LeftColumn - LibGetStringWidth (TitleStr) / 2) / 2;
+ PrintStringAtWithWidth (gScreenDimensions.LeftColumn + 1, gScreenDimensions.TopRow + 1, gLibEmptyString, TitleColumn - gScreenDimensions.LeftColumn - 1);
+ PrintStringAtWithWidth (
+ TitleColumn,
gScreenDimensions.TopRow + 1,
- TitleStr
+ TitleStr,
+ gScreenDimensions.RightColumn - 1 - TitleColumn
);
FreePool (TitleStr);
@@ -524,29 +520,32 @@ LibGetStringWidth (
Show all registered HotKey help strings on bottom Rows.
@param FormData The curent input form data info.
+ @param SetState Set HotKey or Clear HotKey
**/
VOID
PrintHotKeyHelpString (
- IN FORM_DISPLAY_ENGINE_FORM *FormData
+ IN FORM_DISPLAY_ENGINE_FORM *FormData,
+ IN BOOLEAN SetState
)
{
UINTN CurrentCol;
UINTN CurrentRow;
UINTN BottomRowOfHotKeyHelp;
+ UINTN ColumnIndexWidth;
UINTN ColumnWidth;
+ UINTN ColumnIndex;
UINTN Index;
EFI_SCREEN_DESCRIPTOR LocalScreen;
LIST_ENTRY *Link;
BROWSER_HOT_KEY *HotKey;
-
- if (IsListEmpty (&FormData->HotKeyListHead)) {
- return;
- }
+ CHAR16 BakChar;
+ CHAR16 *ColumnStr;
CopyMem (&LocalScreen, &gScreenDimensions, sizeof (EFI_SCREEN_DESCRIPTOR));
ColumnWidth = (LocalScreen.RightColumn - LocalScreen.LeftColumn) / 3;
BottomRowOfHotKeyHelp = LocalScreen.BottomRow - STATUS_BAR_HEIGHT - 3;
+ ColumnStr = gLibEmptyString;
//
// Calculate total number of Register HotKeys.
@@ -556,25 +555,41 @@ PrintHotKeyHelpString (
while (!IsNull (&FormData->HotKeyListHead, Link)) {
HotKey = BROWSER_HOT_KEY_FROM_LINK (Link);
//
- // Help string can't exceed ColumnWidth. One Row will show three Help information.
- //
- if (StrLen (HotKey->HelpString) > ColumnWidth) {
- HotKey->HelpString[ColumnWidth] = L'\0';
- }
- //
// Calculate help information Column and Row.
//
- if ((Index % 3) != 2) {
- CurrentCol = LocalScreen.LeftColumn + (2 - Index % 3) * ColumnWidth;
+ ColumnIndex = Index % 3;
+ if (ColumnIndex == 0) {
+ CurrentCol = LocalScreen.LeftColumn + 2 * ColumnWidth;
+ ColumnIndexWidth = ColumnWidth - 1;
+ } else if (ColumnIndex == 1) {
+ CurrentCol = LocalScreen.LeftColumn + ColumnWidth;
+ ColumnIndexWidth = ColumnWidth;
} else {
- CurrentCol = LocalScreen.LeftColumn + 2;
+ CurrentCol = LocalScreen.LeftColumn + 2;
+ ColumnIndexWidth = ColumnWidth - 2;
}
CurrentRow = BottomRowOfHotKeyHelp - Index / 3;
+
+ //
+ // Help string can't exceed ColumnWidth. One Row will show three Help information.
+ //
+ BakChar = L'\0';
+ if (StrLen (HotKey->HelpString) > ColumnIndexWidth) {
+ BakChar = HotKey->HelpString[ColumnIndexWidth];
+ HotKey->HelpString[ColumnIndexWidth] = L'\0';
+ }
+
//
// Print HotKey help string on bottom Row.
//
- PrintStringAt (CurrentCol, CurrentRow, HotKey->HelpString);
+ if (SetState) {
+ ColumnStr = HotKey->HelpString;
+ }
+ PrintStringAtWithWidth (CurrentCol, CurrentRow, ColumnStr, ColumnIndexWidth);
+ if (BakChar != L'\0') {
+ HotKey->HelpString[ColumnIndexWidth] = BakChar;
+ }
//
// Get Next Hot Key.
//
@@ -582,6 +597,25 @@ PrintHotKeyHelpString (
Index ++;
}
+ if (SetState) {
+ //
+ // Clear KeyHelp
+ //
+ CurrentRow = BottomRowOfHotKeyHelp - Index / 3;
+ ColumnIndex = Index % 3;
+ if (ColumnIndex == 0) {
+ CurrentCol = LocalScreen.LeftColumn + 2 * ColumnWidth;
+ ColumnIndexWidth = ColumnWidth - 1;
+ ColumnIndex ++;
+ PrintStringAtWithWidth (CurrentCol, CurrentRow, gLibEmptyString, ColumnIndexWidth);
+ }
+ if (ColumnIndex == 1) {
+ CurrentCol = LocalScreen.LeftColumn + ColumnWidth;
+ ColumnIndexWidth = ColumnWidth;
+ PrintStringAtWithWidth (CurrentCol, CurrentRow, gLibEmptyString, ColumnIndexWidth);
+ }
+ }
+
return;
}
@@ -788,6 +822,7 @@ PrintInternal (
UINTN Index;
UINTN PreviousIndex;
UINTN Count;
+ UINTN TotalCount;
UINTN PrintWidth;
UINTN CharWidth;
@@ -812,6 +847,7 @@ PrintInternal (
Index = 0;
PreviousIndex = 0;
Count = 0;
+ TotalCount = 0;
PrintWidth = 0;
CharWidth = 1;
@@ -823,17 +859,14 @@ PrintInternal (
if (Buffer[Index] == 0) {
break;
}
- //
- // Null-terminate the temporary string
- //
- BackupBuffer[Index] = 0;
//
// Print this out, we are about to switch widths
//
Out->OutputString (Out, &BackupBuffer[PreviousIndex]);
- Count += StrLen (&BackupBuffer[PreviousIndex]);
+ Count = StrLen (&BackupBuffer[PreviousIndex]);
PrintWidth += Count * CharWidth;
+ TotalCount += Count;
//
// Preserve the current index + 1, since this is where we will start printing from next
@@ -867,8 +900,9 @@ PrintInternal (
// We hit the end of the string - print it
//
Out->OutputString (Out, &BackupBuffer[PreviousIndex]);
- Count += StrLen (&BackupBuffer[PreviousIndex]);
+ Count = StrLen (&BackupBuffer[PreviousIndex]);
PrintWidth += Count * CharWidth;
+ TotalCount += Count;
if (PrintWidth < Width) {
Out->Mode->Attribute = Out->Mode->Attribute & 0x7f;
Out->SetAttribute (Out, Out->Mode->Attribute);
@@ -877,7 +911,7 @@ PrintInternal (
FreePool (Buffer);
FreePool (BackupBuffer);
- return Count;
+ return TotalCount;
}
/**
diff --git a/MdeModulePkg/Library/CustomizedDisplayLib/CustomizedDisplayLibInternal.h b/MdeModulePkg/Library/CustomizedDisplayLib/CustomizedDisplayLibInternal.h
index ccbd45f42..7342b508b 100644
--- a/MdeModulePkg/Library/CustomizedDisplayLib/CustomizedDisplayLibInternal.h
+++ b/MdeModulePkg/Library/CustomizedDisplayLib/CustomizedDisplayLibInternal.h
@@ -193,11 +193,13 @@ LibGetStringWidth (
Show all registered HotKey help strings on bottom Rows.
@param FormData The curent input form data info.
+ @param SetState Set HotKey or Clear HotKey
**/
VOID
PrintHotKeyHelpString (
- IN FORM_DISPLAY_ENGINE_FORM *FormData
+ IN FORM_DISPLAY_ENGINE_FORM *FormData,
+ IN BOOLEAN SetState
);
/**
diff --git a/MdeModulePkg/Library/UefiHiiLib/HiiLib.c b/MdeModulePkg/Library/UefiHiiLib/HiiLib.c
index f48f42fcd..09f1ff754 100644
--- a/MdeModulePkg/Library/UefiHiiLib/HiiLib.c
+++ b/MdeModulePkg/Library/UefiHiiLib/HiiLib.c
@@ -3284,7 +3284,8 @@ HiiCreateGotoExOpCode (
@param[in] OpCodeHandle Handle to the buffer of opcodes.
@param[in] QuestionId Question ID
@param[in] VarStoreId Storage ID
- @param[in] VarOffset Offset in Storage
+ @param[in] VarOffset Offset in Storage or String ID of the name (VarName)
+ for this name/value pair.
@param[in] Prompt String ID for Prompt
@param[in] Help String ID for Help
@param[in] QuestionFlags Flags in Question Header
@@ -3345,7 +3346,8 @@ HiiCreateCheckBoxOpCode (
@param[in] OpCodeHandle Handle to the buffer of opcodes.
@param[in] QuestionId Question ID
@param[in] VarStoreId Storage ID
- @param[in] VarOffset Offset in Storage
+ @param[in] VarOffset Offset in Storage or String ID of the name (VarName)
+ for this name/value pair.
@param[in] Prompt String ID for Prompt
@param[in] Help String ID for Help
@param[in] QuestionFlags Flags in Question Header
@@ -3446,7 +3448,8 @@ HiiCreateNumericOpCode (
@param[in] OpCodeHandle Handle to the buffer of opcodes.
@param[in] QuestionId Question ID
@param[in] VarStoreId Storage ID
- @param[in] VarOffset Offset in Storage
+ @param[in] VarOffset Offset in Storage or String ID of the name (VarName)
+ for this name/value pair.
@param[in] Prompt String ID for Prompt
@param[in] Help String ID for Help
@param[in] QuestionFlags Flags in Question Header
@@ -3513,7 +3516,8 @@ HiiCreateStringOpCode (
@param[in] OpCodeHandle Handle to the buffer of opcodes.
@param[in] QuestionId Question ID
@param[in] VarStoreId Storage ID
- @param[in] VarOffset Offset in Storage
+ @param[in] VarOffset Offset in Storage or String ID of the name (VarName)
+ for this name/value pair.
@param[in] Prompt String ID for Prompt
@param[in] Help String ID for Help
@param[in] QuestionFlags Flags in Question Header
@@ -3580,7 +3584,8 @@ HiiCreateOneOfOpCode (
@param[in] OpCodeHandle Handle to the buffer of opcodes.
@param[in] QuestionId Question ID
@param[in] VarStoreId Storage ID
- @param[in] VarOffset Offset in Storage
+ @param[in] VarOffset Offset in Storage or String ID of the name (VarName)
+ for this name/value pair.
@param[in] Prompt String ID for Prompt
@param[in] Help String ID for Help
@param[in] QuestionFlags Flags in Question Header
@@ -3682,7 +3687,8 @@ HiiCreateTextOpCode (
@param[in] QuestionId Question ID
@param[in] VarStoreId Storage ID, optional. If DateFlags is not
QF_DATE_STORAGE_NORMAL, this parameter is ignored.
- @param[in] VarOffset Offset in Storage, optional. If DateFlags is not
+ @param[in] VarOffset Offset in Storage or String ID of the name (VarName)
+ for this name/value pair, optional. If DateFlags is not
QF_DATE_STORAGE_NORMAL, this parameter is ignored.
@param[in] Prompt String ID for Prompt
@param[in] Help String ID for Help
@@ -3746,7 +3752,8 @@ HiiCreateDateOpCode (
@param[in] QuestionId Question ID
@param[in] VarStoreId Storage ID, optional. If TimeFlags is not
QF_TIME_STORAGE_NORMAL, this parameter is ignored.
- @param[in] VarOffset Offset in Storage, optional. If TimeFlags is not
+ @param[in] VarOffset Offset in Storage or String ID of the name (VarName)
+ for this name/value pair, optional. If TimeFlags is not
QF_TIME_STORAGE_NORMAL, this parameter is ignored.
@param[in] Prompt String ID for Prompt
@param[in] Help String ID for Help
diff --git a/MdeModulePkg/MdeModulePkg.dec b/MdeModulePkg/MdeModulePkg.dec
index 895c0497f..fc9f9ccd9 100644
--- a/MdeModulePkg/MdeModulePkg.dec
+++ b/MdeModulePkg/MdeModulePkg.dec
@@ -662,6 +662,24 @@
#
gEfiMdeModulePkgTokenSpaceGuid.PcdMaxEfiSystemTablePointerAddress|0x0|UINT64|0x30001027
+ ## This PCD specifies whether to shadow PEIM on S3 boot path after memory is ready.
+ gEfiMdeModulePkgTokenSpaceGuid.PcdShadowPeimOnS3Boot|FALSE|BOOLEAN|0x30001028
+
+ ## Default OEM ID for ACPI table creation, its length must be 0x6 bytes to follow ACPI specification.
+ gEfiMdeModulePkgTokenSpaceGuid.PcdAcpiDefaultOemId|"INTEL "|VOID*|0x30001034
+
+ ## Default OEM Table ID for ACPI table creation, it is "EDK2 ".
+ gEfiMdeModulePkgTokenSpaceGuid.PcdAcpiDefaultOemTableId|0x20202020324B4445|UINT64|0x30001035
+
+ ## Default OEM Revision for ACPI table creation.
+ gEfiMdeModulePkgTokenSpaceGuid.PcdAcpiDefaultOemRevision|0x00000002|UINT32|0x30001036
+
+ ## Default Creator ID for ACPI table creation.
+ gEfiMdeModulePkgTokenSpaceGuid.PcdAcpiDefaultCreatorId|0x20202020|UINT32|0x30001037
+
+ ## Default Creator Revision for ACPI table creation.
+ gEfiMdeModulePkgTokenSpaceGuid.PcdAcpiDefaultCreatorRevision|0x01000013|UINT32|0x30001038
+
[PcdsPatchableInModule, PcdsDynamic, PcdsDynamicEx]
## This PCD defines the Console output column and the default value is 25 according to UEFI spec.
# This PCD could be set to 0 then console output could be at max column and max row.
diff --git a/MdeModulePkg/MdeModulePkg.dsc b/MdeModulePkg/MdeModulePkg.dsc
index a2248697d..f31a4d156 100644
--- a/MdeModulePkg/MdeModulePkg.dsc
+++ b/MdeModulePkg/MdeModulePkg.dsc
@@ -303,6 +303,7 @@
MdeModulePkg/Universal/FaultTolerantWritePei/FaultTolerantWritePei.inf
MdeModulePkg/Universal/Variable/Pei/VariablePei.inf
MdeModulePkg/Universal/WatchdogTimerDxe/WatchdogTimer.inf
+ MdeModulePkg/Universal/TimestampDxe/TimestampDxe.inf
MdeModulePkg/Universal/FaultTolerantWriteDxe/FaultTolerantWriteDxe.inf
MdeModulePkg/Universal/FaultTolerantWriteDxe/FaultTolerantWriteSmm.inf
diff --git a/MdeModulePkg/Universal/Acpi/AcpiTableDxe/AcpiTable.h b/MdeModulePkg/Universal/Acpi/AcpiTableDxe/AcpiTable.h
index d9e6428cb..6541a8450 100644
--- a/MdeModulePkg/Universal/Acpi/AcpiTableDxe/AcpiTable.h
+++ b/MdeModulePkg/Universal/Acpi/AcpiTableDxe/AcpiTable.h
@@ -1,7 +1,7 @@
/** @file
ACPI Table Protocol Driver
- Copyright (c) 2006 - 2010, Intel Corporation. All rights reserved.<BR>
+ Copyright (c) 2006 - 2013, 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
@@ -107,15 +107,6 @@ typedef struct {
#define EFI_ACPI_MAX_NUM_TABLES 20
//
-// ACPI table information used to initialize tables.
-//
-#define EFI_ACPI_OEM_ID "INTEL "
-#define EFI_ACPI_OEM_TABLE_ID SIGNATURE_64('E', 'D', 'K', '2', ' ', ' ', ' ', ' ')
-#define EFI_ACPI_OEM_REVISION 0x00000002
-#define EFI_ACPI_CREATOR_ID 0x20202020
-#define EFI_ACPI_CREATOR_REVISION 0x01000013
-
-//
// Protocol private structure definition
//
//
diff --git a/MdeModulePkg/Universal/Acpi/AcpiTableDxe/AcpiTableDxe.inf b/MdeModulePkg/Universal/Acpi/AcpiTableDxe/AcpiTableDxe.inf
index 122a1ff76..8f24d0a9c 100644
--- a/MdeModulePkg/Universal/Acpi/AcpiTableDxe/AcpiTableDxe.inf
+++ b/MdeModulePkg/Universal/Acpi/AcpiTableDxe/AcpiTableDxe.inf
@@ -1,7 +1,7 @@
## @file
# ACPI Table Protocol Driver
#
-# Copyright (c) 2006 - 2010, Intel Corporation. All rights reserved.<BR>
+# Copyright (c) 2006 - 2013, 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,6 +60,13 @@
[FeaturePcd]
gEfiMdeModulePkgTokenSpaceGuid.PcdInstallAcpiSdtProtocol
+[Pcd]
+ gEfiMdeModulePkgTokenSpaceGuid.PcdAcpiDefaultOemId
+ gEfiMdeModulePkgTokenSpaceGuid.PcdAcpiDefaultOemTableId
+ gEfiMdeModulePkgTokenSpaceGuid.PcdAcpiDefaultOemRevision
+ gEfiMdeModulePkgTokenSpaceGuid.PcdAcpiDefaultCreatorId
+ gEfiMdeModulePkgTokenSpaceGuid.PcdAcpiDefaultCreatorRevision
+
[Protocols]
gEfiAcpiTableProtocolGuid # PROTOCOL ALWAYS_PRODUCED
gEfiAcpiSdtProtocolGuid # PROTOCOL ALWAYS_PRODUCED
diff --git a/MdeModulePkg/Universal/Acpi/AcpiTableDxe/AcpiTableProtocol.c b/MdeModulePkg/Universal/Acpi/AcpiTableDxe/AcpiTableProtocol.c
index 56a83125e..f8cf99ac2 100644
--- a/MdeModulePkg/Universal/Acpi/AcpiTableDxe/AcpiTableProtocol.c
+++ b/MdeModulePkg/Universal/Acpi/AcpiTableDxe/AcpiTableProtocol.c
@@ -1,7 +1,7 @@
/** @file
ACPI Table Protocol Implementation
- Copyright (c) 2006 - 2012, Intel Corporation. All rights reserved.<BR>
+ Copyright (c) 2006 - 2013, 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
@@ -1795,13 +1795,13 @@ AcpiTableAcpiTableConstructor (
//
CurrentData = EFI_ACPI_1_0_ROOT_SYSTEM_DESCRIPTION_POINTER_SIGNATURE;
CopyMem (&AcpiTableInstance->Rsdp1->Signature, &CurrentData, sizeof (UINT64));
- CopyMem (AcpiTableInstance->Rsdp1->OemId, EFI_ACPI_OEM_ID, 6);
+ CopyMem (AcpiTableInstance->Rsdp1->OemId, PcdGetPtr (PcdAcpiDefaultOemId), sizeof (AcpiTableInstance->Rsdp1->OemId));
AcpiTableInstance->Rsdp1->Reserved = EFI_ACPI_RESERVED_BYTE;
AcpiTableInstance->Rsdp1->RsdtAddress = (UINT32) (UINTN) AcpiTableInstance->Rsdt1;
CurrentData = EFI_ACPI_3_0_ROOT_SYSTEM_DESCRIPTION_POINTER_SIGNATURE;
CopyMem (&AcpiTableInstance->Rsdp3->Signature, &CurrentData, sizeof (UINT64));
- CopyMem (AcpiTableInstance->Rsdp3->OemId, EFI_ACPI_OEM_ID, 6);
+ CopyMem (AcpiTableInstance->Rsdp3->OemId, PcdGetPtr (PcdAcpiDefaultOemId), sizeof (AcpiTableInstance->Rsdp3->OemId));
AcpiTableInstance->Rsdp3->Revision = EFI_ACPI_3_0_ROOT_SYSTEM_DESCRIPTION_POINTER_REVISION;
AcpiTableInstance->Rsdp3->RsdtAddress = (UINT32) (UINTN) AcpiTableInstance->Rsdt3;
AcpiTableInstance->Rsdp3->Length = sizeof (EFI_ACPI_3_0_ROOT_SYSTEM_DESCRIPTION_POINTER);
@@ -1819,12 +1819,12 @@ AcpiTableAcpiTableConstructor (
AcpiTableInstance->Rsdt1->Signature = EFI_ACPI_1_0_ROOT_SYSTEM_DESCRIPTION_TABLE_SIGNATURE;
AcpiTableInstance->Rsdt1->Length = sizeof (EFI_ACPI_DESCRIPTION_HEADER);
AcpiTableInstance->Rsdt1->Revision = EFI_ACPI_1_0_ROOT_SYSTEM_DESCRIPTION_TABLE_REVISION;
- CopyMem (AcpiTableInstance->Rsdt1->OemId, EFI_ACPI_OEM_ID, 6);
- CurrentData = EFI_ACPI_OEM_TABLE_ID;
+ CopyMem (AcpiTableInstance->Rsdt1->OemId, PcdGetPtr (PcdAcpiDefaultOemId), sizeof (AcpiTableInstance->Rsdt1->OemId));
+ CurrentData = PcdGet64 (PcdAcpiDefaultOemTableId);
CopyMem (&AcpiTableInstance->Rsdt1->OemTableId, &CurrentData, sizeof (UINT64));
- AcpiTableInstance->Rsdt1->OemRevision = EFI_ACPI_OEM_REVISION;
- AcpiTableInstance->Rsdt1->CreatorId = EFI_ACPI_CREATOR_ID;
- AcpiTableInstance->Rsdt1->CreatorRevision = EFI_ACPI_CREATOR_REVISION;
+ AcpiTableInstance->Rsdt1->OemRevision = PcdGet32 (PcdAcpiDefaultOemRevision);
+ AcpiTableInstance->Rsdt1->CreatorId = PcdGet32 (PcdAcpiDefaultCreatorId);
+ AcpiTableInstance->Rsdt1->CreatorRevision = PcdGet32 (PcdAcpiDefaultCreatorRevision);
//
// We always reserve first one for FADT
//
@@ -1834,12 +1834,12 @@ AcpiTableAcpiTableConstructor (
AcpiTableInstance->Rsdt3->Signature = EFI_ACPI_3_0_ROOT_SYSTEM_DESCRIPTION_TABLE_SIGNATURE;
AcpiTableInstance->Rsdt3->Length = sizeof (EFI_ACPI_DESCRIPTION_HEADER);
AcpiTableInstance->Rsdt3->Revision = EFI_ACPI_3_0_ROOT_SYSTEM_DESCRIPTION_TABLE_REVISION;
- CopyMem (AcpiTableInstance->Rsdt3->OemId, EFI_ACPI_OEM_ID, 6);
- CurrentData = EFI_ACPI_OEM_TABLE_ID;
+ CopyMem (AcpiTableInstance->Rsdt3->OemId, PcdGetPtr (PcdAcpiDefaultOemId), sizeof (AcpiTableInstance->Rsdt3->OemId));
+ CurrentData = PcdGet64 (PcdAcpiDefaultOemTableId);
CopyMem (&AcpiTableInstance->Rsdt3->OemTableId, &CurrentData, sizeof (UINT64));
- AcpiTableInstance->Rsdt3->OemRevision = EFI_ACPI_OEM_REVISION;
- AcpiTableInstance->Rsdt3->CreatorId = EFI_ACPI_CREATOR_ID;
- AcpiTableInstance->Rsdt3->CreatorRevision = EFI_ACPI_CREATOR_REVISION;
+ AcpiTableInstance->Rsdt3->OemRevision = PcdGet32 (PcdAcpiDefaultOemRevision);
+ AcpiTableInstance->Rsdt3->CreatorId = PcdGet32 (PcdAcpiDefaultCreatorId);
+ AcpiTableInstance->Rsdt3->CreatorRevision = PcdGet32 (PcdAcpiDefaultCreatorRevision);
//
// We always reserve first one for FADT
//
@@ -1852,12 +1852,12 @@ AcpiTableAcpiTableConstructor (
AcpiTableInstance->Xsdt->Signature = EFI_ACPI_3_0_EXTENDED_SYSTEM_DESCRIPTION_TABLE_SIGNATURE;
AcpiTableInstance->Xsdt->Length = sizeof (EFI_ACPI_DESCRIPTION_HEADER);
AcpiTableInstance->Xsdt->Revision = EFI_ACPI_3_0_EXTENDED_SYSTEM_DESCRIPTION_TABLE_REVISION;
- CopyMem (AcpiTableInstance->Xsdt->OemId, EFI_ACPI_OEM_ID, 6);
- CurrentData = EFI_ACPI_OEM_TABLE_ID;
+ CopyMem (AcpiTableInstance->Xsdt->OemId, PcdGetPtr (PcdAcpiDefaultOemId), sizeof (AcpiTableInstance->Xsdt->OemId));
+ CurrentData = PcdGet64 (PcdAcpiDefaultOemTableId);
CopyMem (&AcpiTableInstance->Xsdt->OemTableId, &CurrentData, sizeof (UINT64));
- AcpiTableInstance->Xsdt->OemRevision = EFI_ACPI_OEM_REVISION;
- AcpiTableInstance->Xsdt->CreatorId = EFI_ACPI_CREATOR_ID;
- AcpiTableInstance->Xsdt->CreatorRevision = EFI_ACPI_CREATOR_REVISION;
+ AcpiTableInstance->Xsdt->OemRevision = PcdGet32 (PcdAcpiDefaultOemRevision);
+ AcpiTableInstance->Xsdt->CreatorId = PcdGet32 (PcdAcpiDefaultCreatorId);
+ AcpiTableInstance->Xsdt->CreatorRevision = PcdGet32 (PcdAcpiDefaultCreatorRevision);
//
// We always reserve first one for FADT
//
diff --git a/MdeModulePkg/Universal/Acpi/BootGraphicsResourceTableDxe/BootGraphicsResourceTableDxe.c b/MdeModulePkg/Universal/Acpi/BootGraphicsResourceTableDxe/BootGraphicsResourceTableDxe.c
index 207abf780..804ffa5a6 100644
--- a/MdeModulePkg/Universal/Acpi/BootGraphicsResourceTableDxe/BootGraphicsResourceTableDxe.c
+++ b/MdeModulePkg/Universal/Acpi/BootGraphicsResourceTableDxe/BootGraphicsResourceTableDxe.c
@@ -1,7 +1,7 @@
/** @file
This module install ACPI Boot Graphics Resource Table (BGRT).
- Copyright (c) 2011 - 2012, Intel Corporation. All rights reserved.<BR>
+ Copyright (c) 2011 - 2013, 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,15 +27,7 @@
#include <Library/MemoryAllocationLib.h>
#include <Library/UefiBootServicesTableLib.h>
#include <Library/DebugLib.h>
-
-//
-// ACPI table information used to initialize tables.
-//
-#define EFI_ACPI_OEM_ID "INTEL"
-#define EFI_ACPI_OEM_TABLE_ID 0x2020204F4E414954ULL // "TIANO "
-#define EFI_ACPI_OEM_REVISION 0x00000001
-#define EFI_ACPI_CREATOR_ID 0x5446534D // TBD "MSFT"
-#define EFI_ACPI_CREATOR_REVISION 0x01000013 // TBD
+#include <Library/PcdLib.h>
//
// Module globals.
@@ -81,13 +73,13 @@ EFI_ACPI_5_0_BOOT_GRAPHICS_RESOURCE_TABLE mBootGraphicsResourceTableTemplate = {
EFI_ACPI_5_0_BOOT_GRAPHICS_RESOURCE_TABLE_REVISION, // Revision
0x00, // Checksum will be updated at runtime
//
- // It is expected that these values will be updated at runtime.
+ // It is expected that these values will be updated at EntryPoint.
//
- EFI_ACPI_OEM_ID, // OEMID is a 6 bytes long field
- EFI_ACPI_OEM_TABLE_ID, // OEM table identification(8 bytes long)
- EFI_ACPI_OEM_REVISION, // OEM revision number
- EFI_ACPI_CREATOR_ID, // ASL compiler vendor ID
- EFI_ACPI_CREATOR_REVISION, // ASL compiler revision number
+ {0x00}, // OEM ID is a 6 bytes long field
+ 0x00, // OEM Table ID(8 bytes long)
+ 0x00, // OEM Revision
+ 0x00, // Creator ID
+ 0x00, // Creator Revision
},
EFI_ACPI_5_0_BGRT_VERSION, // Version
EFI_ACPI_5_0_BGRT_STATUS_VALID, // Status
@@ -235,9 +227,9 @@ BgrtAcpiTableChecksum (
}
/**
- Allocate EfiReservedMemoryType below 4G memory address.
+ Allocate EfiBootServicesData below 4G memory address.
- This function allocates EfiReservedMemoryType below 4G memory address.
+ This function allocates EfiBootServicesData below 4G memory address.
@param[in] Size Size of memory to allocate.
@@ -245,7 +237,7 @@ BgrtAcpiTableChecksum (
**/
VOID *
-BgrtAllocateReservedMemoryBelow4G (
+BgrtAllocateBsDataMemoryBelow4G (
IN UINTN Size
)
{
@@ -259,7 +251,7 @@ BgrtAllocateReservedMemoryBelow4G (
Status = gBS->AllocatePages (
AllocateMaxAddress,
- EfiReservedMemoryType,
+ EfiBootServicesData,
Pages,
&Address
);
@@ -361,9 +353,12 @@ InstallBootGraphicsResourceTable (
if (mLogoHeight > (((UINT32) ~0) - sizeof (BMP_IMAGE_HEADER)) / (mLogoWidth * 3 + PaddingSize)) {
return EFI_UNSUPPORTED;
}
-
+
+ //
+ // The image should be stored in EfiBootServicesData, allowing the system to reclaim the memory
+ //
BmpSize = (mLogoWidth * 3 + PaddingSize) * mLogoHeight + sizeof (BMP_IMAGE_HEADER);
- ImageBuffer = BgrtAllocateReservedMemoryBelow4G (BmpSize);
+ ImageBuffer = BgrtAllocateBsDataMemoryBelow4G (BmpSize);
if (ImageBuffer == NULL) {
return EFI_OUT_OF_RESOURCES;
}
@@ -464,6 +459,18 @@ BootGraphicsDxeEntryPoint (
)
{
EFI_STATUS Status;
+ UINT64 OemTableId;
+
+ CopyMem (
+ mBootGraphicsResourceTableTemplate.Header.OemId,
+ PcdGetPtr (PcdAcpiDefaultOemId),
+ sizeof (mBootGraphicsResourceTableTemplate.Header.OemId)
+ );
+ OemTableId = PcdGet64 (PcdAcpiDefaultOemTableId);
+ CopyMem (&mBootGraphicsResourceTableTemplate.Header.OemTableId, &OemTableId, sizeof (UINT64));
+ mBootGraphicsResourceTableTemplate.Header.OemRevision = PcdGet32 (PcdAcpiDefaultOemRevision);
+ mBootGraphicsResourceTableTemplate.Header.CreatorId = PcdGet32 (PcdAcpiDefaultCreatorId);
+ mBootGraphicsResourceTableTemplate.Header.CreatorRevision = PcdGet32 (PcdAcpiDefaultCreatorRevision);
//
// Install Boot Logo protocol.
diff --git a/MdeModulePkg/Universal/Acpi/BootGraphicsResourceTableDxe/BootGraphicsResourceTableDxe.inf b/MdeModulePkg/Universal/Acpi/BootGraphicsResourceTableDxe/BootGraphicsResourceTableDxe.inf
index c2d051862..f953d497d 100644
--- a/MdeModulePkg/Universal/Acpi/BootGraphicsResourceTableDxe/BootGraphicsResourceTableDxe.inf
+++ b/MdeModulePkg/Universal/Acpi/BootGraphicsResourceTableDxe/BootGraphicsResourceTableDxe.inf
@@ -1,7 +1,7 @@
## @file
# This module install ACPI Boot Graphics Resource Table (BGRT).
#
-# Copyright (c) 2011, Intel Corporation. All rights reserved.<BR>
+# Copyright (c) 2011 - 2013, 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,10 +41,18 @@
UefiLib
UefiBootServicesTableLib
DebugLib
+ PcdLib
[Protocols]
gEfiAcpiTableProtocolGuid ## SOMETIMES_CONSUMES
gEfiBootLogoProtocolGuid ## SOMETIMES_CONSUMES
+[Pcd]
+ gEfiMdeModulePkgTokenSpaceGuid.PcdAcpiDefaultOemId
+ gEfiMdeModulePkgTokenSpaceGuid.PcdAcpiDefaultOemTableId
+ gEfiMdeModulePkgTokenSpaceGuid.PcdAcpiDefaultOemRevision
+ gEfiMdeModulePkgTokenSpaceGuid.PcdAcpiDefaultCreatorId
+ gEfiMdeModulePkgTokenSpaceGuid.PcdAcpiDefaultCreatorRevision
+
[Guids]
gEfiEventReadyToBootGuid ## CONSUMES
diff --git a/MdeModulePkg/Universal/Acpi/FirmwarePerformanceDataTableDxe/FirmwarePerformanceDxe.c b/MdeModulePkg/Universal/Acpi/FirmwarePerformanceDataTableDxe/FirmwarePerformanceDxe.c
index f834778ac..9ea8f5c6b 100644
--- a/MdeModulePkg/Universal/Acpi/FirmwarePerformanceDataTableDxe/FirmwarePerformanceDxe.c
+++ b/MdeModulePkg/Universal/Acpi/FirmwarePerformanceDataTableDxe/FirmwarePerformanceDxe.c
@@ -41,14 +41,6 @@
#include <Library/LockBoxLib.h>
#include <Library/UefiLib.h>
-//
-// ACPI table information used to initialize tables.
-//
-#define EFI_ACPI_OEM_ID "INTEL"
-#define EFI_ACPI_OEM_TABLE_ID 0x2020204F4E414954ULL // "TIANO "
-#define EFI_ACPI_OEM_REVISION 0x00000001
-#define EFI_ACPI_CREATOR_ID 0x5446534D // TBD "MSFT"
-#define EFI_ACPI_CREATOR_REVISION 0x01000013 // TBD
#define EXTENSION_RECORD_SIZE 0x10000
#define SMM_BOOT_RECORD_COMM_SIZE OFFSET_OF (EFI_SMM_COMMUNICATE_HEADER, Data) + sizeof(SMM_BOOT_RECORD_COMMUNICATE)
@@ -73,13 +65,13 @@ FIRMWARE_PERFORMANCE_TABLE mFirmwarePerformanceTableTemplate = {
EFI_ACPI_5_0_FIRMWARE_PERFORMANCE_DATA_TABLE_REVISION, // Revision
0x00, // Checksum will be updated at runtime
//
- // It is expected that these values will be updated at runtime.
+ // It is expected that these values will be updated at EntryPoint.
//
- EFI_ACPI_OEM_ID, // OEMID is a 6 bytes long field
- EFI_ACPI_OEM_TABLE_ID, // OEM table identification(8 bytes long)
- EFI_ACPI_OEM_REVISION, // OEM revision number
- EFI_ACPI_CREATOR_ID, // ASL compiler vendor ID
- EFI_ACPI_CREATOR_REVISION, // ASL compiler revision number
+ {0x00}, // OEM ID is a 6 bytes long field
+ 0x00, // OEM Table ID(8 bytes long)
+ 0x00, // OEM Revision
+ 0x00, // Creator ID
+ 0x00, // Creator Revision
},
//
// Firmware Basic Boot Performance Table Pointer Record.
@@ -788,6 +780,18 @@ FirmwarePerformanceDxeEntryPoint (
EFI_HOB_GUID_TYPE *GuidHob;
FIRMWARE_SEC_PERFORMANCE *Performance;
VOID *Registration;
+ UINT64 OemTableId;
+
+ CopyMem (
+ mFirmwarePerformanceTableTemplate.Header.OemId,
+ PcdGetPtr (PcdAcpiDefaultOemId),
+ sizeof (mFirmwarePerformanceTableTemplate.Header.OemId)
+ );
+ OemTableId = PcdGet64 (PcdAcpiDefaultOemTableId);
+ CopyMem (&mFirmwarePerformanceTableTemplate.Header.OemTableId, &OemTableId, sizeof (UINT64));
+ mFirmwarePerformanceTableTemplate.Header.OemRevision = PcdGet32 (PcdAcpiDefaultOemRevision);
+ mFirmwarePerformanceTableTemplate.Header.CreatorId = PcdGet32 (PcdAcpiDefaultCreatorId);
+ mFirmwarePerformanceTableTemplate.Header.CreatorRevision = PcdGet32 (PcdAcpiDefaultCreatorRevision);
//
// Get Report Status Code Handler Protocol.
diff --git a/MdeModulePkg/Universal/Acpi/FirmwarePerformanceDataTableDxe/FirmwarePerformanceDxe.inf b/MdeModulePkg/Universal/Acpi/FirmwarePerformanceDataTableDxe/FirmwarePerformanceDxe.inf
index 5a9628f92..e1c69e0c1 100644
--- a/MdeModulePkg/Universal/Acpi/FirmwarePerformanceDataTableDxe/FirmwarePerformanceDxe.inf
+++ b/MdeModulePkg/Universal/Acpi/FirmwarePerformanceDataTableDxe/FirmwarePerformanceDxe.inf
@@ -75,6 +75,11 @@
gEfiMdeModulePkgTokenSpaceGuid.PcdProgressCodeOsLoaderLoad
gEfiMdeModulePkgTokenSpaceGuid.PcdProgressCodeOsLoaderStart
gEfiMdeModulePkgTokenSpaceGuid.PcdExtFpdtBootRecordPadSize
+ gEfiMdeModulePkgTokenSpaceGuid.PcdAcpiDefaultOemId
+ gEfiMdeModulePkgTokenSpaceGuid.PcdAcpiDefaultOemTableId
+ gEfiMdeModulePkgTokenSpaceGuid.PcdAcpiDefaultOemRevision
+ gEfiMdeModulePkgTokenSpaceGuid.PcdAcpiDefaultCreatorId
+ gEfiMdeModulePkgTokenSpaceGuid.PcdAcpiDefaultCreatorRevision
[FeaturePcd]
gEfiMdeModulePkgTokenSpaceGuid.PcdFirmwarePerformanceDataTableS3Support
diff --git a/MdeModulePkg/Universal/CapsuleRuntimeDxe/CapsuleRuntimeDxe.inf b/MdeModulePkg/Universal/CapsuleRuntimeDxe/CapsuleRuntimeDxe.inf
index 3354fb7fc..7767e6834 100644
--- a/MdeModulePkg/Universal/CapsuleRuntimeDxe/CapsuleRuntimeDxe.inf
+++ b/MdeModulePkg/Universal/CapsuleRuntimeDxe/CapsuleRuntimeDxe.inf
@@ -5,7 +5,7 @@
# It installs the Capsule Architectural Protocol defined in PI1.0a to signify
# the capsule runtime services are ready.
#
-# Copyright (c) 2006 - 2011, Intel Corporation. All rights reserved.<BR>
+# Copyright (c) 2006 - 2013, 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,7 +53,8 @@
UefiRuntimeLib
BaseLib
PrintLib
-
+ BaseMemoryLib
+
[LibraryClasses.X64]
LockBoxLib
UefiLib
@@ -62,6 +63,7 @@
[Guids]
gEfiCapsuleVendorGuid ## SOMETIMES_PRODUCED (Process across reset capsule image) ## Variable:L"CapsuleUpdateData" for capsule updated data
+ gEfiFmpCapsuleGuid ## FMP capsule GUID
[Guids.X64]
gEfiAcpiVariableGuid # ALWAYS_CONSUMED
diff --git a/MdeModulePkg/Universal/CapsuleRuntimeDxe/CapsuleService.c b/MdeModulePkg/Universal/CapsuleRuntimeDxe/CapsuleService.c
index 17f167c97..0861a6477 100644
--- a/MdeModulePkg/Universal/CapsuleRuntimeDxe/CapsuleService.c
+++ b/MdeModulePkg/Universal/CapsuleRuntimeDxe/CapsuleService.c
@@ -4,7 +4,7 @@
It installs the Capsule Architectural Protocol defined in PI1.0a to signify
the capsule runtime services are ready.
-Copyright (c) 2006 - 2011, Intel Corporation. All rights reserved.<BR>
+Copyright (c) 2006 - 2013, 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,6 +19,7 @@ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
#include <Protocol/Capsule.h>
#include <Guid/CapsuleVendor.h>
+#include <Guid/FmpCapsule.h>
#include <Library/DebugLib.h>
#include <Library/PcdLib.h>
@@ -29,7 +30,7 @@ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
#include <Library/UefiRuntimeLib.h>
#include <Library/BaseLib.h>
#include <Library/PrintLib.h>
-
+#include <Library/BaseMemoryLib.h>
//
// Handle for the installation of Capsule Architecture Protocol.
//
@@ -73,6 +74,11 @@ SaveLongModeContext (
@retval EFI_INVALID_PARAMETER CapsuleCount is Zero.
@retval EFI_INVALID_PARAMETER For across reset capsule image, ScatterGatherList is NULL.
@retval EFI_UNSUPPORTED CapsuleImage is not recognized by the firmware.
+ @retval EFI_OUT_OF_RESOURCES When ExitBootServices() has been previously called this error indicates the capsule
+ is compatible with this platform but is not capable of being submitted or processed
+ in runtime. The caller may resubmit the capsule prior to ExitBootServices().
+ @retval EFI_OUT_OF_RESOURCES When ExitBootServices() has not been previously called then this error indicates
+ the capsule is compatible with this platform but there are insufficient resources to process.
**/
EFI_STATUS
@@ -119,12 +125,23 @@ UpdateCapsule (
if ((CapsuleHeader->Flags & (CAPSULE_FLAGS_PERSIST_ACROSS_RESET | CAPSULE_FLAGS_INITIATE_RESET)) == CAPSULE_FLAGS_INITIATE_RESET) {
return EFI_INVALID_PARAMETER;
}
+
+ //
+ // Check FMP capsule flag
+ //
+ if (CompareGuid(&CapsuleHeader->CapsuleGuid, &gEfiFmpCapsuleGuid)
+ && (CapsuleHeader->Flags & CAPSULE_FLAGS_POPULATE_SYSTEM_TABLE) != 0 ) {
+ return EFI_INVALID_PARAMETER;
+ }
+
//
// Check Capsule image without populate flag by firmware support capsule function
//
- if (((CapsuleHeader->Flags & CAPSULE_FLAGS_POPULATE_SYSTEM_TABLE) == 0) &&
- (SupportCapsuleImage (CapsuleHeader) != EFI_SUCCESS)) {
- return EFI_UNSUPPORTED;
+ if ((CapsuleHeader->Flags & CAPSULE_FLAGS_POPULATE_SYSTEM_TABLE) == 0) {
+ Status = SupportCapsuleImage (CapsuleHeader);
+ if (EFI_ERROR(Status)) {
+ return Status;
+ }
}
}
@@ -140,7 +157,7 @@ UpdateCapsule (
//
if ((CapsuleHeader->Flags & CAPSULE_FLAGS_PERSIST_ACROSS_RESET) == 0) {
if (EfiAtRuntime ()) {
- Status = EFI_UNSUPPORTED;
+ Status = EFI_OUT_OF_RESOURCES;
} else {
Status = ProcessCapsuleImage(CapsuleHeader);
}
@@ -245,6 +262,7 @@ QueryCapsuleCapabilities (
OUT EFI_RESET_TYPE *ResetType
)
{
+ EFI_STATUS Status;
UINTN ArrayNumber;
EFI_CAPSULE_HEADER *CapsuleHeader;
BOOLEAN NeedReset;
@@ -282,12 +300,23 @@ QueryCapsuleCapabilities (
if ((CapsuleHeader->Flags & (CAPSULE_FLAGS_PERSIST_ACROSS_RESET | CAPSULE_FLAGS_INITIATE_RESET)) == CAPSULE_FLAGS_INITIATE_RESET) {
return EFI_INVALID_PARAMETER;
}
+
+ //
+ // Check FMP capsule flag
+ //
+ if (CompareGuid(&CapsuleHeader->CapsuleGuid, &gEfiFmpCapsuleGuid)
+ && (CapsuleHeader->Flags & CAPSULE_FLAGS_POPULATE_SYSTEM_TABLE) != 0 ) {
+ return EFI_INVALID_PARAMETER;
+ }
+
//
// Check Capsule image without populate flag is supported by firmware
//
- if (((CapsuleHeader->Flags & CAPSULE_FLAGS_POPULATE_SYSTEM_TABLE) == 0) &&
- (SupportCapsuleImage (CapsuleHeader) != EFI_SUCCESS)) {
- return EFI_UNSUPPORTED;
+ if ((CapsuleHeader->Flags & CAPSULE_FLAGS_POPULATE_SYSTEM_TABLE) == 0) {
+ Status = SupportCapsuleImage (CapsuleHeader);
+ if (EFI_ERROR(Status)) {
+ return Status;
+ }
}
}
@@ -301,7 +330,7 @@ QueryCapsuleCapabilities (
break;
}
}
-
+
if (NeedReset) {
//
//Check if the platform supports update capsule across a system reset
diff --git a/MdeModulePkg/Universal/Disk/DiskIoDxe/DiskIo.c b/MdeModulePkg/Universal/Disk/DiskIoDxe/DiskIo.c
index ba6130091..f53c3d91d 100644
--- a/MdeModulePkg/Universal/Disk/DiskIoDxe/DiskIo.c
+++ b/MdeModulePkg/Universal/Disk/DiskIoDxe/DiskIo.c
@@ -403,8 +403,6 @@ DiskIo2OnReadWriteComplete (
EFI_STATUS TransactionStatus;
DISK_IO_PRIVATE_DATA *Instance;
- gBS->CloseEvent (Event);
-
Subtask = (DISK_IO_SUBTASK *) Context;
TransactionStatus = Subtask->BlockIo2Token.TransactionStatus;
Task = Subtask->Task;
@@ -414,26 +412,13 @@ DiskIo2OnReadWriteComplete (
ASSERT (Instance->Signature == DISK_IO_PRIVATE_DATA_SIGNATURE);
ASSERT (Task->Signature == DISK_IO2_TASK_SIGNATURE);
- if (Subtask->WorkingBuffer != NULL) {
- if (!EFI_ERROR (TransactionStatus) && (Task->Token != NULL) && !Subtask->Write) {
- CopyMem (Subtask->Buffer, Subtask->WorkingBuffer + Subtask->Offset, Subtask->Length);
- }
-
- //
- // The WorkingBuffer of blocking subtask either points to SharedWorkingBuffer
- // or will be used by non-blocking subtask which will be freed below.
- //
- if (!Subtask->Blocking) {
- FreeAlignedPages (
- Subtask->WorkingBuffer,
- Subtask->Length < Instance->BlockIo->Media->BlockSize
- ? EFI_SIZE_TO_PAGES (Instance->BlockIo->Media->BlockSize)
- : EFI_SIZE_TO_PAGES (Subtask->Length)
- );
- }
+ if ((Subtask->WorkingBuffer != NULL) && !EFI_ERROR (TransactionStatus) &&
+ (Task->Token != NULL) && !Subtask->Write
+ ) {
+ CopyMem (Subtask->Buffer, Subtask->WorkingBuffer + Subtask->Offset, Subtask->Length);
}
- RemoveEntryList (&Subtask->Link);
- FreePool (Subtask);
+
+ DiskIoDestroySubtask (Instance, Subtask);
if (EFI_ERROR (TransactionStatus) || IsListEmpty (&Task->Subtasks)) {
if (Task->Token != NULL) {
@@ -961,7 +946,7 @@ DiskIo2ReadWriteDisk (
RemoveEntryList (&Task->Link);
EfiReleaseLock (&Instance->TaskQueueLock);
- if (Task->Token != NULL) {
+ if (!EFI_ERROR (Status) && (Task->Token != NULL)) {
//
// Task->Token should be set to NULL by the DiskIo2OnReadWriteComplete
// It it's not, that means the non-blocking request was downgraded to blocking request.
diff --git a/MdeModulePkg/Universal/Disk/PartitionDxe/Partition.c b/MdeModulePkg/Universal/Disk/PartitionDxe/Partition.c
index 5cc1397e7..7fb2c0dfe 100644
--- a/MdeModulePkg/Universal/Disk/PartitionDxe/Partition.c
+++ b/MdeModulePkg/Universal/Disk/PartitionDxe/Partition.c
@@ -352,11 +352,11 @@ PartitionDriverBindingStart (
ControllerHandle
);
//
- // Close Parent BlockIO2 if has.
+ // Close Parent DiskIo2 if has.
//
gBS->CloseProtocol (
ControllerHandle,
- &gEfiBlockIo2ProtocolGuid,
+ &gEfiDiskIo2ProtocolGuid,
This->DriverBindingHandle,
ControllerHandle
);
@@ -822,7 +822,7 @@ PartitionCreateAccessTask (
Status = gBS->CreateEvent (
EVT_NOTIFY_SIGNAL,
- TPL_CALLBACK,
+ TPL_NOTIFY,
PartitionOnAccessComplete,
Task,
&Task->DiskIo2Token.Event
diff --git a/MdeModulePkg/Universal/DisplayEngineDxe/FormDisplay.c b/MdeModulePkg/Universal/DisplayEngineDxe/FormDisplay.c
index a07cc75a4..9f6c96315 100644
--- a/MdeModulePkg/Universal/DisplayEngineDxe/FormDisplay.c
+++ b/MdeModulePkg/Universal/DisplayEngineDxe/FormDisplay.c
@@ -130,6 +130,7 @@ CHAR16 *gOptionMismatch;
CHAR16 *gFormSuppress;
CHAR16 *gProtocolNotFound;
+CHAR16 gModalSkipColumn;
CHAR16 gPromptBlockWidth;
CHAR16 gOptionBlockWidth;
CHAR16 gHelpBlockWidth;
@@ -258,20 +259,35 @@ GetPrompt (
/**
Get the supported width for a particular op-code
- @param Statement The curent statement.
+ @param MenuOption The menu option.
+ @param AdjustWidth The width which is saved for the space.
@return Returns the number of CHAR16 characters that is support.
**/
UINT16
GetWidth (
- IN FORM_DISPLAY_ENGINE_STATEMENT *Statement
+ IN UI_MENU_OPTION *MenuOption,
+ OUT UINT16 *AdjustWidth
)
{
- CHAR16 *String;
- UINTN Size;
- UINT16 Width;
- EFI_IFR_TEXT *TestOp;
+ CHAR16 *String;
+ UINTN Size;
+ EFI_IFR_TEXT *TestOp;
+ UINT16 ReturnWidth;
+ FORM_DISPLAY_ENGINE_STATEMENT *Statement;
+
+ Statement = MenuOption->ThisTag;
+
+ //
+ // For modal form, clean the entire row.
+ //
+ if ((gFormData->Attribute & HII_DISPLAY_MODAL) != 0) {
+ if (AdjustWidth != NULL) {
+ *AdjustWidth = LEFT_SKIPPED_COLUMNS;
+ }
+ return (UINT16)(gStatementDimensions.RightColumn - gStatementDimensions.LeftColumn - 2 * (gModalSkipColumn + LEFT_SKIPPED_COLUMNS));
+ }
Size = 0;
@@ -297,12 +313,33 @@ GetWidth (
//
((Statement->OpCode->OpCode == EFI_IFR_TEXT_OP) && (Size == 0))
) {
- Width = (UINT16) (gPromptBlockWidth + gOptionBlockWidth);
+
+ //
+ // Return the space width.
+ //
+ if (AdjustWidth != NULL) {
+ *AdjustWidth = 2;
+ }
+ //
+ // Keep consistent with current behavior.
+ //
+ ReturnWidth = (UINT16) (gPromptBlockWidth + gOptionBlockWidth - 2);
} else {
- Width = (UINT16) gPromptBlockWidth;
+ if (AdjustWidth != NULL) {
+ *AdjustWidth = 1;
+ }
+
+ ReturnWidth = (UINT16) (gPromptBlockWidth - 1);
}
- return (UINT16) (Width - LEFT_SKIPPED_COLUMNS);
+ //
+ // For nest in statement, should the subtitle indent.
+ //
+ if (MenuOption->NestInStatement) {
+ ReturnWidth -= SUBTITLE_INDENT;
+ }
+
+ return ReturnWidth;
}
/**
@@ -516,24 +553,7 @@ UiAddMenuOption (
String = GetToken (PromptId, gFormData->HiiHandle);
ASSERT (String != NULL);
- Width = GetWidth (Statement);
- for (; GetLineByWidth (String, Width, &GlyphWidth,&ArrayEntry, &OutputString) != 0x0000;) {
- //
- // If there is more string to process print on the next row and increment the Skip value
- //
- if (StrLen (&String[ArrayEntry]) != 0) {
- NumberOfLines++;
- }
- FreePool (OutputString);
- }
-
if (Statement->OpCode->OpCode == EFI_IFR_DATE_OP || Statement->OpCode->OpCode == EFI_IFR_TIME_OP) {
- //
- // Add three MenuOptions for Date/Time
- // Data format : [01/02/2004] [11:22:33]
- // Line number : 0 0 1 0 0 1
- //
- NumberOfLines = 0;
Count = 3;
}
@@ -548,14 +568,6 @@ UiAddMenuOption (
MenuOption->NestInStatement = NestIn;
MenuOption->EntryNumber = *MenuItemCount;
- if (Index == 2) {
- //
- // Override LineNumber for the MenuOption in Date/Time sequence
- //
- MenuOption->Skip = 1;
- } else {
- MenuOption->Skip = NumberOfLines;
- }
MenuOption->Sequence = Index;
if ((Statement->Attribute & HII_DISPLAY_GRAYOUT) != 0) {
@@ -610,6 +622,37 @@ UiAddMenuOption (
}
}
+ if (Index == 0 &&
+ (Statement->OpCode->OpCode != EFI_IFR_DATE_OP) &&
+ (Statement->OpCode->OpCode != EFI_IFR_TIME_OP)) {
+ Width = GetWidth (MenuOption, NULL);
+ for (; GetLineByWidth (String, Width, &GlyphWidth,&ArrayEntry, &OutputString) != 0x0000;) {
+ //
+ // If there is more string to process print on the next row and increment the Skip value
+ //
+ if (StrLen (&String[ArrayEntry]) != 0) {
+ NumberOfLines++;
+ }
+ FreePool (OutputString);
+ }
+ } else {
+ //
+ // Add three MenuOptions for Date/Time
+ // Data format : [01/02/2004] [11:22:33]
+ // Line number : 0 0 1 0 0 1
+ //
+ NumberOfLines = 0;
+ }
+
+ if (Index == 2) {
+ //
+ // Override LineNumber for the MenuOption in Date/Time sequence
+ //
+ MenuOption->Skip = 1;
+ } else {
+ MenuOption->Skip = NumberOfLines;
+ }
+
InsertTailList (&gMenuOption, &MenuOption->Link);
}
@@ -1438,6 +1481,411 @@ FindTopMenu (
}
/**
+ Update highlight menu info.
+
+ @param MenuOption The menu opton which is highlight.
+
+**/
+VOID
+UpdateHighlightMenuInfo (
+ IN UI_MENU_OPTION *MenuOption
+ )
+{
+ FORM_DISPLAY_ENGINE_STATEMENT *Statement;
+
+ //
+ // This is the current selected statement
+ //
+ Statement = MenuOption->ThisTag;
+
+ //
+ // Get the highlight statement.
+ //
+ gUserInput->SelectedStatement = Statement;
+ gSequence = (UINT16) MenuOption->Sequence;
+
+ //
+ // Record highlight row info for date/time opcode.
+ //
+ if (Statement->OpCode->OpCode == EFI_IFR_DATE_OP || Statement->OpCode->OpCode == EFI_IFR_TIME_OP) {
+ gHighligthMenuInfo.QuestionId = GetQuestionIdInfo(Statement->OpCode);
+ gHighligthMenuInfo.DisplayRow = (UINT16) MenuOption->Row;
+ } else {
+ gHighligthMenuInfo.QuestionId = 0;
+ gHighligthMenuInfo.DisplayRow = 0;
+ }
+
+ RefreshKeyHelp(gFormData, Statement, FALSE);
+}
+
+/**
+ Update attribut for this menu.
+
+ @param MenuOption The menu opton which this attribut used to.
+ @param Highlight Whether this menu will be highlight.
+
+**/
+VOID
+SetDisplayAttribute (
+ IN UI_MENU_OPTION *MenuOption,
+ IN BOOLEAN Highlight
+ )
+{
+ FORM_DISPLAY_ENGINE_STATEMENT *Statement;
+
+ Statement = MenuOption->ThisTag;
+
+ if (Highlight) {
+ gST->ConOut->SetAttribute (gST->ConOut, GetHighlightTextColor ());
+ return;
+ }
+
+ if (MenuOption->GrayOut) {
+ gST->ConOut->SetAttribute (gST->ConOut, GetGrayedTextColor ());
+ } else {
+ if (Statement->OpCode->OpCode == EFI_IFR_SUBTITLE_OP) {
+ gST->ConOut->SetAttribute (gST->ConOut, GetSubTitleTextColor ());
+ } else {
+ gST->ConOut->SetAttribute (gST->ConOut, GetFieldTextColor ());
+ }
+ }
+}
+
+/**
+ Print string for this menu option.
+
+ @param MenuOption The menu opton which this attribut used to.
+ @param Col The column that this string will be print at.
+ @param Row The row that this string will be print at.
+ @param String The string which need to print.
+ @param Width The width need to print, if string is less than the
+ width, the block space will be used.
+ @param Highlight Whether this menu will be highlight.
+
+**/
+VOID
+DisplayMenuString (
+ IN UI_MENU_OPTION *MenuOption,
+ IN UINTN Col,
+ IN UINTN Row,
+ IN CHAR16 *String,
+ IN UINTN Width,
+ IN BOOLEAN Highlight
+ )
+{
+ UINTN Length;
+
+ //
+ // Print string with normal color.
+ //
+ if (!Highlight) {
+ PrintStringAtWithWidth (Col, Row, String, Width);
+ return;
+ }
+
+ //
+ // Print the highlight menu string.
+ // First print the highlight string.
+ //
+ SetDisplayAttribute(MenuOption, TRUE);
+ Length = PrintStringAt (Col, Row, String);
+
+ //
+ // Second, clean the empty after the string.
+ //
+ SetDisplayAttribute(MenuOption, FALSE);
+ PrintStringAtWithWidth (Col + Length, Row, L"", Width - Length);
+}
+
+/**
+ Check whether this menu can has option string.
+
+ @param MenuOption The menu opton which this attribut used to.
+
+ @retval TRUE This menu option can have option string.
+ @retval FALSE This menu option can't have option string.
+
+**/
+BOOLEAN
+HasOptionString (
+ IN UI_MENU_OPTION *MenuOption
+ )
+{
+ FORM_DISPLAY_ENGINE_STATEMENT *Statement;
+ CHAR16 *String;
+ UINTN Size;
+ EFI_IFR_TEXT *TestOp;
+
+ Size = 0;
+ Statement = MenuOption->ThisTag;
+
+ //
+ // See if the second text parameter is really NULL
+ //
+ if (Statement->OpCode->OpCode == EFI_IFR_TEXT_OP) {
+ TestOp = (EFI_IFR_TEXT *) Statement->OpCode;
+ if (TestOp->TextTwo != 0) {
+ String = GetToken (TestOp->TextTwo, gFormData->HiiHandle);
+ Size = StrLen (String);
+ FreePool (String);
+ }
+ }
+
+ if ((Statement->OpCode->OpCode == EFI_IFR_SUBTITLE_OP) ||
+ (Statement->OpCode->OpCode == EFI_IFR_REF_OP) ||
+ (Statement->OpCode->OpCode == EFI_IFR_PASSWORD_OP) ||
+ (Statement->OpCode->OpCode == EFI_IFR_ACTION_OP) ||
+ (Statement->OpCode->OpCode == EFI_IFR_RESET_BUTTON_OP) ||
+ //
+ // Allow a wide display if text op-code and no secondary text op-code
+ //
+ ((Statement->OpCode->OpCode == EFI_IFR_TEXT_OP) && (Size == 0))
+ ) {
+
+ return FALSE;
+ }
+
+ return TRUE;
+}
+
+
+/**
+ Print string for this menu option.
+
+ @param MenuOption The menu opton which this attribut used to.
+ @param SkipWidth The skip width between the left to the start of the prompt.
+ @param BeginCol The begin column for one menu.
+ @param SkipLine The skip line for this menu.
+ @param BottomRow The bottom row for this form.
+ @param Highlight Whether this menu will be highlight.
+
+ @retval EFI_SUCESSS Process the user selection success.
+
+**/
+EFI_STATUS
+DisplayOneMenu (
+ IN UI_MENU_OPTION *MenuOption,
+ IN UINTN SkipWidth,
+ IN UINTN BeginCol,
+ IN UINTN SkipLine,
+ IN UINTN BottomRow,
+ IN BOOLEAN Highlight
+ )
+{
+ FORM_DISPLAY_ENGINE_STATEMENT *Statement;
+ UINTN Index;
+ UINT16 Width;
+ UINT16 PromptWidth;
+ CHAR16 *StringPtr;
+ CHAR16 *OptionString;
+ CHAR16 *OutputString;
+ UINT16 GlyphWidth;
+ UINTN Temp;
+ UINTN Temp2;
+ UINTN Temp3;
+ EFI_STATUS Status;
+ UINTN Row;
+ UINTN Col;
+ UINTN PromptLineNum;
+ UINTN OptionLineNum;
+ CHAR16 AdjustValue;
+ UINTN MaxRow;
+
+ Statement = MenuOption->ThisTag;
+ Temp = SkipLine;
+ Temp2 = SkipLine;
+ Temp3 = SkipLine;
+ AdjustValue = 0;
+ PromptLineNum = 0;
+ OptionLineNum = 0;
+ MaxRow = 0;
+
+ //
+ // Set default color.
+ //
+ SetDisplayAttribute (MenuOption, FALSE);
+
+ //
+ // 1. Paint the option string.
+ //
+ Status = ProcessOptions (MenuOption, FALSE, &OptionString, FALSE);
+ if (EFI_ERROR (Status)) {
+ return Status;
+ }
+
+ if (OptionString != NULL) {
+ if (Statement->OpCode->OpCode == EFI_IFR_DATE_OP || Statement->OpCode->OpCode == EFI_IFR_TIME_OP) {
+ //
+ // Adjust option string for date/time opcode.
+ //
+ ProcessStringForDateTime(MenuOption, OptionString, TRUE);
+ }
+
+ Width = (UINT16) gOptionBlockWidth - 1;
+ Row = MenuOption->Row;
+ GlyphWidth = 1;
+ OptionLineNum = 0;
+
+ for (Index = 0; GetLineByWidth (OptionString, Width, &GlyphWidth, &Index, &OutputString) != 0x0000;) {
+ if (((Temp2 == 0)) && (Row <= BottomRow)) {
+ if (Statement->OpCode->OpCode == EFI_IFR_DATE_OP || Statement->OpCode->OpCode == EFI_IFR_TIME_OP) {
+ //
+ // For date/time question, it has three menu options for this qustion.
+ // The first/second menu options with the skip value is 0. the last one
+ // with skip value is 1.
+ //
+ if (MenuOption->Skip != 0) {
+ //
+ // For date/ time, print the last past (year for date and second for time)
+ // - 7 means skip [##/##/ for date and [##:##: for time.
+ //
+ DisplayMenuString (MenuOption,MenuOption->OptCol, Row, OutputString, Width + 1 - 7, Highlight);
+ } else {
+ //
+ // For date/ time, print the first and second past (year for date and second for time)
+ //
+ DisplayMenuString (MenuOption, MenuOption->OptCol, Row, OutputString, StrLen (OutputString), Highlight);
+ }
+ } else {
+ DisplayMenuString (MenuOption, MenuOption->OptCol, Row, OutputString, Width + 1, Highlight);
+ }
+ OptionLineNum++;
+ }
+
+ //
+ // If there is more string to process print on the next row and increment the Skip value
+ //
+ if (StrLen (&OptionString[Index]) != 0) {
+ if (Temp2 == 0) {
+ Row++;
+ //
+ // Since the Number of lines for this menu entry may or may not be reflected accurately
+ // since the prompt might be 1 lines and option might be many, and vice versa, we need to do
+ // some testing to ensure we are keeping this in-sync.
+ //
+ // If the difference in rows is greater than or equal to the skip value, increase the skip value
+ //
+ if ((Row - MenuOption->Row) >= MenuOption->Skip) {
+ MenuOption->Skip++;
+ }
+ }
+ }
+
+ FreePool (OutputString);
+ if (Temp2 != 0) {
+ Temp2--;
+ }
+ }
+
+ Highlight = FALSE;
+
+ FreePool (OptionString);
+ }
+
+ //
+ // 2. Paint the description.
+ //
+ PromptWidth = GetWidth (MenuOption, &AdjustValue);
+ Row = MenuOption->Row;
+ GlyphWidth = 1;
+ PromptLineNum = 0;
+
+ if (MenuOption->Description == NULL || MenuOption->Description[0] == '\0') {
+ PrintStringAtWithWidth (BeginCol, Row, L"", PromptWidth + AdjustValue + SkipWidth);
+ PromptLineNum++;
+ } else {
+ for (Index = 0; GetLineByWidth (MenuOption->Description, PromptWidth, &GlyphWidth, &Index, &OutputString) != 0x0000;) {
+ if ((Temp == 0) && (Row <= BottomRow)) {
+ //
+ // 1.Clean the start LEFT_SKIPPED_COLUMNS
+ //
+ PrintStringAtWithWidth (BeginCol, Row, L"", SkipWidth);
+
+ if (Statement->OpCode->OpCode == EFI_IFR_REF_OP && MenuOption->Col >= 2) {
+ //
+ // Print Arrow for Goto button.
+ //
+ PrintCharAt (
+ MenuOption->Col - 2,
+ Row,
+ GEOMETRICSHAPE_RIGHT_TRIANGLE
+ );
+ }
+ DisplayMenuString (MenuOption, MenuOption->Col, Row, OutputString, PromptWidth + AdjustValue, Highlight);
+ PromptLineNum ++;
+ }
+ //
+ // If there is more string to process print on the next row and increment the Skip value
+ //
+ if (StrLen (&MenuOption->Description[Index]) != 0) {
+ if (Temp == 0) {
+ Row++;
+ }
+ }
+
+ FreePool (OutputString);
+ if (Temp != 0) {
+ Temp--;
+ }
+ }
+
+ Highlight = FALSE;
+ }
+
+
+ //
+ // 3. If this is a text op with secondary text information
+ //
+ if ((Statement->OpCode->OpCode == EFI_IFR_TEXT_OP) && (((EFI_IFR_TEXT*)Statement->OpCode)->TextTwo != 0)) {
+ StringPtr = GetToken (((EFI_IFR_TEXT*)Statement->OpCode)->TextTwo, gFormData->HiiHandle);
+
+ Width = (UINT16) gOptionBlockWidth - 1;
+ Row = MenuOption->Row;
+ GlyphWidth = 1;
+ OptionLineNum = 0;
+
+ for (Index = 0; GetLineByWidth (StringPtr, Width, &GlyphWidth, &Index, &OutputString) != 0x0000;) {
+ if ((Temp3 == 0) && (Row <= BottomRow)) {
+ DisplayMenuString (MenuOption, MenuOption->OptCol, Row, OutputString, Width + 1, Highlight);
+ OptionLineNum++;
+ }
+ //
+ // If there is more string to process print on the next row and increment the Skip value
+ //
+ if (StrLen (&StringPtr[Index]) != 0) {
+ if (Temp3 == 0) {
+ Row++;
+ }
+ }
+
+ FreePool (OutputString);
+ if (Temp3 != 0) {
+ Temp3--;
+ }
+ }
+
+ FreePool (StringPtr);
+ }
+
+ //
+ // 4.Line number for Option string and prompt string are not equal.
+ // Clean the column whose line number is less.
+ //
+ if (HasOptionString(MenuOption) && (OptionLineNum != PromptLineNum)) {
+ Col = OptionLineNum < PromptLineNum ? MenuOption->OptCol : BeginCol;
+ Row = (OptionLineNum < PromptLineNum ? OptionLineNum : PromptLineNum) + MenuOption->Row;
+ Width = (UINT16) (OptionLineNum < PromptLineNum ? gOptionBlockWidth : PromptWidth + AdjustValue + SkipWidth);
+ MaxRow = (OptionLineNum < PromptLineNum ? PromptLineNum : OptionLineNum) + MenuOption->Row - 1;
+
+ while (Row <= MaxRow) {
+ DisplayMenuString (MenuOption, Col, Row++, L"", Width, FALSE);
+ }
+ }
+
+ return EFI_SUCCESS;
+}
+
+/**
Display menu and wait for user to select one menu option, then return it.
If AutoBoot is enabled, then if user doesn't select any option,
after period of time, it will automatically return the first menu option.
@@ -1458,10 +1906,8 @@ UiDisplayMenu (
UINTN DistanceValue;
UINTN Row;
UINTN Col;
- UINTN TempRightCol;
UINTN Temp;
UINTN Temp2;
- UINTN Temp3;
UINTN TopRow;
UINTN BottomRow;
UINTN OriginalRow;
@@ -1491,7 +1937,6 @@ UiDisplayMenu (
UI_SCREEN_OPERATION ScreenOperation;
UINT16 DefaultId;
FORM_DISPLAY_ENGINE_STATEMENT *Statement;
- UINTN ModalSkipColumn;
BROWSER_HOT_KEY *HotKey;
UINTN HelpPageIndex;
UINTN HelpPageCount;
@@ -1507,6 +1952,7 @@ UiDisplayMenu (
EFI_STRING_ID HelpInfo;
UI_EVENT_TYPE EventType;
FORM_DISPLAY_ENGINE_STATEMENT *InitialHighlight;
+ BOOLEAN SkipHighLight;
EventType = UIEventNone;
Status = EFI_SUCCESS;
@@ -1531,6 +1977,7 @@ UiDisplayMenu (
UpArrow = FALSE;
DownArrow = FALSE;
SkipValue = 0;
+ SkipHighLight = FALSE;
NextMenuOption = NULL;
PreviousMenuOption = NULL;
@@ -1538,21 +1985,27 @@ UiDisplayMenu (
HotKey = NULL;
Repaint = TRUE;
MenuOption = NULL;
- ModalSkipColumn = (gStatementDimensions.RightColumn - gStatementDimensions.LeftColumn) / 6;
+ gModalSkipColumn = (CHAR16) (gStatementDimensions.RightColumn - gStatementDimensions.LeftColumn) / 6;
InitialHighlight = gFormData->HighLightedStatement;
ZeroMem (&Key, sizeof (EFI_INPUT_KEY));
- gOptionBlockWidth = (CHAR16) ((gStatementDimensions.RightColumn - gStatementDimensions.LeftColumn) / 3);
- gPromptBlockWidth = (CHAR16) (gOptionBlockWidth + LEFT_SKIPPED_COLUMNS);
- gHelpBlockWidth = (CHAR16) (gOptionBlockWidth - LEFT_SKIPPED_COLUMNS);
+ //
+ // Left right
+ // |<-.->|<-.........->|<- .........->|<-...........->|
+ // Skip Prompt Option Help
+ //
+ Width = (CHAR16) ((gStatementDimensions.RightColumn - gStatementDimensions.LeftColumn) / 3);
+ gOptionBlockWidth = Width + 1;
+ gHelpBlockWidth = (CHAR16) (Width - LEFT_SKIPPED_COLUMNS);
+ gPromptBlockWidth = (CHAR16) (gStatementDimensions.RightColumn - gStatementDimensions.LeftColumn - 2 * Width - 1);
TopRow = gStatementDimensions.TopRow + SCROLL_ARROW_HEIGHT;
BottomRow = gStatementDimensions.BottomRow - SCROLL_ARROW_HEIGHT - 1;
Row = TopRow;
if ((FormData->Attribute & HII_DISPLAY_MODAL) != 0) {
- Col = gStatementDimensions.LeftColumn + LEFT_SKIPPED_COLUMNS + ModalSkipColumn;
+ Col = gStatementDimensions.LeftColumn + LEFT_SKIPPED_COLUMNS + gModalSkipColumn;
} else {
Col = gStatementDimensions.LeftColumn + LEFT_SKIPPED_COLUMNS;
}
@@ -1565,30 +2018,21 @@ UiDisplayMenu (
while (TRUE) {
switch (ControlFlag) {
case CfInitialization:
- if (IsListEmpty (&gMenuOption)) {
-
- if ((FormData->Attribute & HII_DISPLAY_MODAL) == 0) {
- //
- // Clear Statement range.
- //
- ClearLines (
- gStatementDimensions.LeftColumn,
- gStatementDimensions.RightColumn,
- TopRow - SCROLL_ARROW_HEIGHT,
- BottomRow + SCROLL_ARROW_HEIGHT,
- GetFieldTextColor ()
- );
-
- //
- // Clear Key Range
- //
- RefreshKeyHelp (gFormData, NULL, FALSE);
- }
+ if ((gOldFormEntry.HiiHandle != FormData->HiiHandle) ||
+ (!CompareGuid (&gOldFormEntry.FormSetGuid, &FormData->FormSetGuid))) {
+ //
+ // Clear Statement range if different formset is painted.
+ //
+ ClearLines (
+ gStatementDimensions.LeftColumn,
+ gStatementDimensions.RightColumn,
+ TopRow - SCROLL_ARROW_HEIGHT,
+ BottomRow + SCROLL_ARROW_HEIGHT,
+ GetFieldTextColor ()
+ );
- ControlFlag = CfReadKey;
- } else {
- ControlFlag = CfRepaint;
}
+ ControlFlag = CfRepaint;
break;
case CfRepaint:
@@ -1602,47 +2046,28 @@ UiDisplayMenu (
UpArrow = FALSE;
Row = TopRow;
- Temp = (UINTN) SkipValue;
- Temp2 = (UINTN) SkipValue;
- Temp3 = (UINTN) SkipValue;
-
+ gST->ConOut->SetAttribute (gST->ConOut, GetFieldTextColor ());
+
//
- // 1. Clear the screen.
+ // 1. Check whether need to print the arrow up.
//
+ if (!ValueIsScroll (TRUE, TopOfScreen)) {
+ UpArrow = TRUE;
+ }
+
if ((FormData->Attribute & HII_DISPLAY_MODAL) != 0) {
- ClearLines (
- gStatementDimensions.LeftColumn + ModalSkipColumn,
- gStatementDimensions.LeftColumn + ModalSkipColumn + gPromptBlockWidth + gOptionBlockWidth,
- TopRow - SCROLL_ARROW_HEIGHT,
- BottomRow + SCROLL_ARROW_HEIGHT,
- GetFieldTextColor ()
- );
+ PrintStringAtWithWidth(gStatementDimensions.LeftColumn + gModalSkipColumn, TopRow - 1, L"", gStatementDimensions.RightColumn - gStatementDimensions.LeftColumn - 2 * gModalSkipColumn);
} else {
- TempRightCol = gStatementDimensions.RightColumn;
- if (!mStatementLayoutIsChanged) {
- TempRightCol = gStatementDimensions.RightColumn - gHelpBlockWidth;
- }
- ClearLines (
- gStatementDimensions.LeftColumn,
- gStatementDimensions.RightColumn,
+ PrintStringAtWithWidth(gStatementDimensions.LeftColumn, TopRow - 1, L"", gStatementDimensions.RightColumn - gStatementDimensions.LeftColumn);
+ }
+ if (UpArrow) {
+ gST->ConOut->SetAttribute (gST->ConOut, GetArrowColor ());
+ PrintCharAt (
+ gStatementDimensions.LeftColumn + gPromptBlockWidth + gOptionBlockWidth + 1,
TopRow - SCROLL_ARROW_HEIGHT,
- TopRow - 1,
- GetFieldTextColor ()
- );
- ClearLines (
- gStatementDimensions.LeftColumn,
- TempRightCol,
- TopRow,
- BottomRow,
- GetFieldTextColor ()
- );
- ClearLines (
- gStatementDimensions.LeftColumn,
- gStatementDimensions.RightColumn,
- BottomRow + 1,
- BottomRow + SCROLL_ARROW_HEIGHT,
- GetFieldTextColor ()
+ ARROW_UP
);
+ gST->ConOut->SetAttribute (gST->ConOut, GetFieldTextColor ());
}
//
@@ -1653,169 +2078,44 @@ UiDisplayMenu (
MenuOption->Row = Row;
MenuOption->Col = Col;
if ((FormData->Attribute & HII_DISPLAY_MODAL) != 0) {
- MenuOption->OptCol = gPromptBlockWidth + 1 + gStatementDimensions.LeftColumn + ModalSkipColumn;
+ MenuOption->OptCol = gStatementDimensions.LeftColumn + LEFT_SKIPPED_COLUMNS + gPromptBlockWidth + gModalSkipColumn;
} else {
- MenuOption->OptCol = gPromptBlockWidth + 1 + gStatementDimensions.LeftColumn;
+ MenuOption->OptCol = gStatementDimensions.LeftColumn + LEFT_SKIPPED_COLUMNS + gPromptBlockWidth;
}
- Statement = MenuOption->ThisTag;
if (MenuOption->NestInStatement) {
MenuOption->Col += SUBTITLE_INDENT;
}
- if (MenuOption->GrayOut) {
- gST->ConOut->SetAttribute (gST->ConOut, GetGrayedTextColor ());
- } else {
- if (Statement->OpCode->OpCode == EFI_IFR_SUBTITLE_OP) {
- gST->ConOut->SetAttribute (gST->ConOut, GetSubTitleTextColor ());
- }
- }
-
- Width = GetWidth (Statement);
- OriginalRow = Row;
- GlyphWidth = 1;
-
- if (Statement->OpCode->OpCode == EFI_IFR_REF_OP && MenuOption->Col >= 2) {
- //
- // Print Arrow for Goto button.
- //
- PrintCharAt (
- MenuOption->Col - 2,
- Row,
- GEOMETRICSHAPE_RIGHT_TRIANGLE
- );
- }
-
//
- // 2.1. Paint the description.
+ // Save the highlight menu, will be used in CfRefreshHighLight case.
//
- for (Index = 0; GetLineByWidth (MenuOption->Description, Width, &GlyphWidth, &Index, &OutputString) != 0x0000;) {
- //
- // Temp means need to skip how many lines from the start.
- //
- if ((Temp == 0) && (Row <= BottomRow)) {
- PrintStringAt (MenuOption->Col, Row, OutputString);
- }
- //
- // If there is more string to process print on the next row and increment the Skip value
- //
- if (StrLen (&MenuOption->Description[Index]) != 0) {
- if (Temp == 0) {
- Row++;
- }
- }
-
- FreePool (OutputString);
- if (Temp != 0) {
- Temp--;
- }
+ if (Link == NewPos) {
+ SavedMenuOption = MenuOption;
+ SkipHighLight = TRUE;
}
- Temp = 0;
- Row = OriginalRow;
+ if ((FormData->Attribute & HII_DISPLAY_MODAL) != 0) {
+ Status = DisplayOneMenu (MenuOption,
+ MenuOption->Col - gStatementDimensions.LeftColumn,
+ gStatementDimensions.LeftColumn + gModalSkipColumn,
+ Link == TopOfScreen ? SkipValue : 0,
+ BottomRow,
+ (BOOLEAN) ((Link == NewPos) && IsSelectable(MenuOption))
+ );
+ } else {
+ Status = DisplayOneMenu (MenuOption,
+ MenuOption->Col - gStatementDimensions.LeftColumn,
+ gStatementDimensions.LeftColumn,
+ Link == TopOfScreen ? SkipValue : 0,
+ BottomRow,
+ (BOOLEAN) ((Link == NewPos) && IsSelectable(MenuOption))
+ );
+ }
- //
- // 2.2. Paint the option string.
- //
- Status = ProcessOptions (MenuOption, FALSE, &OptionString, FALSE);
- //
- // If Error occur, question value update in ProcessOptions.
- // Exit current FormDisplay with new question value.
- //
if (EFI_ERROR (Status)) {
return Status;
}
-
- if (OptionString != NULL) {
- if (Statement->OpCode->OpCode == EFI_IFR_DATE_OP || Statement->OpCode->OpCode == EFI_IFR_TIME_OP) {
- ProcessStringForDateTime(MenuOption, OptionString, TRUE);
- }
-
- Width = (UINT16) gOptionBlockWidth;
- OriginalRow = Row;
- GlyphWidth = 1;
-
- for (Index = 0; GetLineByWidth (OptionString, Width, &GlyphWidth, &Index, &OutputString) != 0x0000;) {
- if ((Temp2 == 0) && (Row <= BottomRow)) {
- PrintStringAt (MenuOption->OptCol, Row, OutputString);
- }
- //
- // If there is more string to process print on the next row and increment the Skip value
- //
- if (StrLen (&OptionString[Index]) != 0) {
- if (Temp2 == 0) {
- Row++;
- //
- // Since the Number of lines for this menu entry may or may not be reflected accurately
- // since the prompt might be 1 lines and option might be many, and vice versa, we need to do
- // some testing to ensure we are keeping this in-sync.
- //
- // If the difference in rows is greater than or equal to the skip value, increase the skip value
- //
- if ((Row - OriginalRow) >= MenuOption->Skip) {
- MenuOption->Skip++;
- }
- }
- }
-
- FreePool (OutputString);
- if (Temp2 != 0) {
- Temp2--;
- }
- }
-
- Row = OriginalRow;
-
- FreePool (OptionString);
- }
- Temp2 = 0;
-
- //
- // If this is a text op with secondary text information
- //
- if ((Statement->OpCode->OpCode == EFI_IFR_TEXT_OP) && (((EFI_IFR_TEXT*)Statement->OpCode)->TextTwo != 0)) {
- StringPtr = GetToken (((EFI_IFR_TEXT*)Statement->OpCode)->TextTwo, gFormData->HiiHandle);
-
- Width = (UINT16) gOptionBlockWidth;
- OriginalRow = Row;
- GlyphWidth = 1;
-
- for (Index = 0; GetLineByWidth (StringPtr, Width, &GlyphWidth, &Index, &OutputString) != 0x0000;) {
- if ((Temp3 == 0) && (Row <= BottomRow)) {
- PrintStringAt (MenuOption->OptCol, Row, OutputString);
- }
- //
- // If there is more string to process print on the next row and increment the Skip value
- //
- if (StrLen (&StringPtr[Index]) != 0) {
- if (Temp3 == 0) {
- Row++;
- //
- // Since the Number of lines for this menu entry may or may not be reflected accurately
- // since the prompt might be 1 lines and option might be many, and vice versa, we need to do
- // some testing to ensure we are keeping this in-sync.
- //
- // If the difference in rows is greater than or equal to the skip value, increase the skip value
- //
- if ((Row - OriginalRow) >= MenuOption->Skip) {
- MenuOption->Skip++;
- }
- }
- }
-
- FreePool (OutputString);
- if (Temp3 != 0) {
- Temp3--;
- }
- }
-
- Row = OriginalRow;
- FreePool (StringPtr);
- }
- Temp3 = 0;
-
- gST->ConOut->SetAttribute (gST->ConOut, GetFieldTextColor ());
-
//
// 3. Update the row info which will be used by next menu.
//
@@ -1835,20 +2135,25 @@ UiDisplayMenu (
}
}
- if (!ValueIsScroll (TRUE, TopOfScreen)) {
- UpArrow = TRUE;
+ //
+ // 3. Menus in this form may not cover all form, clean the remain field.
+ //
+ while (Row <= BottomRow) {
+ if ((FormData->Attribute & HII_DISPLAY_MODAL) != 0) {
+ PrintStringAtWithWidth(gStatementDimensions.LeftColumn + gModalSkipColumn, Row++, L"", gStatementDimensions.RightColumn - gStatementDimensions.LeftColumn - 2 * gModalSkipColumn);
+ } else {
+ PrintStringAtWithWidth(gStatementDimensions.LeftColumn, Row++, L"", gStatementDimensions.RightColumn - gHelpBlockWidth - gStatementDimensions.LeftColumn);
+ }
}
- if (UpArrow) {
- gST->ConOut->SetAttribute (gST->ConOut, GetArrowColor ());
- PrintCharAt (
- gStatementDimensions.LeftColumn + gPromptBlockWidth + gOptionBlockWidth + 1,
- TopRow - SCROLL_ARROW_HEIGHT,
- ARROW_UP
- );
- gST->ConOut->SetAttribute (gST->ConOut, GetFieldTextColor ());
+ //
+ // 4. Print the down arrow row.
+ //
+ if ((FormData->Attribute & HII_DISPLAY_MODAL) != 0) {
+ PrintStringAtWithWidth(gStatementDimensions.LeftColumn + gModalSkipColumn, BottomRow + 1, L"", gStatementDimensions.RightColumn - gStatementDimensions.LeftColumn - 2 * + gModalSkipColumn);
+ } else {
+ PrintStringAtWithWidth(gStatementDimensions.LeftColumn, BottomRow + 1, L"", gStatementDimensions.RightColumn - gStatementDimensions.LeftColumn);
}
-
if (DownArrow) {
gST->ConOut->SetAttribute (gST->ConOut, GetArrowColor ());
PrintCharAt (
@@ -1860,6 +2165,10 @@ UiDisplayMenu (
}
MenuOption = NULL;
+
+ if (IsListEmpty (&gMenuOption)) {
+ ControlFlag = CfReadKey;
+ }
}
break;
@@ -1872,6 +2181,13 @@ UiDisplayMenu (
//
ControlFlag = CfUpdateHelpString;
+ if (SkipHighLight) {
+ MenuOption = SavedMenuOption;
+ SkipHighLight = FALSE;
+ UpdateHighlightMenuInfo (MenuOption);
+ break;
+ }
+
if (MenuOption != NULL && TopOfScreen == &MenuOption->Link) {
Temp = SkipValue;
} else {
@@ -1898,7 +2214,7 @@ UiDisplayMenu (
ProcessStringForDateTime(MenuOption, OptionString, FALSE);
}
- Width = (UINT16) gOptionBlockWidth;
+ Width = (UINT16) gOptionBlockWidth - 1;
OriginalRow = MenuOption->Row;
GlyphWidth = 1;
@@ -1933,7 +2249,7 @@ UiDisplayMenu (
}
OriginalRow = MenuOption->Row;
- Width = GetWidth (MenuOption->ThisTag);
+ Width = GetWidth (MenuOption, NULL);
GlyphWidth = 1;
for (Index = 0; GetLineByWidth (MenuOption->Description, Width, &GlyphWidth, &Index, &OutputString) != 0x0000;) {
@@ -1967,25 +2283,9 @@ UiDisplayMenu (
MenuOption = MENU_OPTION_FROM_LINK (NewPos);
Statement = MenuOption->ThisTag;
- //
- // Get the highlight statement.
- //
- gUserInput->SelectedStatement = Statement;
- gSequence = (UINT16) MenuOption->Sequence;
-
- //
- // Record highlight row info for date/time opcode.
- //
- if (Statement->OpCode->OpCode == EFI_IFR_DATE_OP || Statement->OpCode->OpCode == EFI_IFR_TIME_OP) {
- gHighligthMenuInfo.QuestionId = GetQuestionIdInfo(Statement->OpCode);
- gHighligthMenuInfo.DisplayRow = (UINT16) MenuOption->Row;
- } else {
- gHighligthMenuInfo.QuestionId = 0;
- gHighligthMenuInfo.DisplayRow = 0;
- }
+ UpdateHighlightMenuInfo (MenuOption);
if (!IsSelectable (MenuOption)) {
- RefreshKeyHelp(gFormData, Statement, FALSE);
break;
}
@@ -2000,7 +2300,7 @@ UiDisplayMenu (
if (Statement->OpCode->OpCode == EFI_IFR_DATE_OP || Statement->OpCode->OpCode == EFI_IFR_TIME_OP) {
ProcessStringForDateTime(MenuOption, OptionString, FALSE);
}
- Width = (UINT16) gOptionBlockWidth;
+ Width = (UINT16) gOptionBlockWidth - 1;
OriginalRow = MenuOption->Row;
GlyphWidth = 1;
@@ -2031,7 +2331,7 @@ UiDisplayMenu (
if (NewLine) {
OriginalRow = MenuOption->Row;
- Width = GetWidth (Statement);
+ Width = GetWidth (MenuOption, NULL);
GlyphWidth = 1;
for (Index = 0; GetLineByWidth (MenuOption->Description, Width, &GlyphWidth, &Index, &OutputString) != 0x0000;) {
@@ -2058,8 +2358,6 @@ UiDisplayMenu (
}
}
- RefreshKeyHelp(gFormData, MenuOption->ThisTag, FALSE);
-
//
// Clear reverse attribute
//
@@ -2596,6 +2894,11 @@ UiDisplayMenu (
MenuOption = MENU_OPTION_FROM_LINK (SavedListEntry);
UpdateStatusBar (INPUT_ERROR, FALSE);
} else {
+ if (NewPos->ForwardLink == &gMenuOption) {
+ NewLine = FALSE;
+ Repaint = FALSE;
+ break;
+ }
//
// Scroll up to the last page.
//
@@ -2604,6 +2907,7 @@ UiDisplayMenu (
MenuOption = MENU_OPTION_FROM_LINK (SavedListEntry);
ScreenOperation = UiPageUp;
ControlFlag = CfScreenOperation;
+ SkipValue = 0;
}
break;
@@ -2660,23 +2964,32 @@ UiDisplayMenu (
}
if ((Link->BackLink == &gMenuOption) && (Index >= TopRow)) {
- SkipValue = 0;
if (TopOfScreen == &gMenuOption) {
TopOfScreen = gMenuOption.ForwardLink;
NewPos = gMenuOption.BackLink;
MoveToNextStatement (TRUE, &NewPos, BottomRow - TopRow);
- Repaint = FALSE;
+ if (Index < PreviousMenuOption->Skip) {
+ Repaint = TRUE;
+ SkipValue = PreviousMenuOption->Skip - (Index - TopRow);
+ } else {
+ Repaint = FALSE;
+ SkipValue = 0;
+ }
} else if (TopOfScreen != Link) {
TopOfScreen = Link;
NewPos = Link;
MoveToNextStatement (FALSE, &NewPos, BottomRow - TopRow);
+ SkipValue = 0;
} else {
//
// Finally we know that NewPos is the last MenuOption can be focused.
//
- Repaint = FALSE;
+ if (SkipValue == 0) {
+ Repaint = FALSE;
+ }
NewPos = Link;
MoveToNextStatement (FALSE, &NewPos, BottomRow - TopRow);
+ SkipValue = 0;
}
} else {
if (Index > TopRow) {
@@ -2724,6 +3037,13 @@ UiDisplayMenu (
ASSERT (NewPos != NULL);
if (NewPos->ForwardLink == &gMenuOption) {
+ MenuOption = MENU_OPTION_FROM_LINK (NewPos);
+ if (SkipValue + BottomRow - TopRow + 1 < MenuOption->Skip) {
+ SkipValue += BottomRow - TopRow + 1;
+ NewLine = TRUE;
+ Repaint = TRUE;
+ break;
+ }
NewLine = FALSE;
Repaint = FALSE;
break;
@@ -2802,6 +3122,12 @@ UiDisplayMenu (
AdjustDateAndTimePosition (FALSE, &NewPos);
if (NewPos->ForwardLink != &gMenuOption) {
+ if (NewPos == TopOfScreen) {
+ Temp2 = SkipValue;
+ } else {
+ Temp2 = 0;
+ }
+
MenuOption = MENU_OPTION_FROM_LINK (NewPos);
NewLine = TRUE;
NewPos = NewPos->ForwardLink;
@@ -2810,11 +3136,11 @@ UiDisplayMenu (
//
// Current menu not at the bottom of the form.
//
- if (BottomRow >= MenuOption->Row + MenuOption->Skip) {
+ if (BottomRow >= MenuOption->Row + MenuOption->Skip - Temp2) {
//
// Find the next selectable menu.
//
- Difference = MoveToNextStatement (FALSE, &NewPos, BottomRow - MenuOption->Row - MenuOption->Skip);
+ Difference = MoveToNextStatement (FALSE, &NewPos, BottomRow - MenuOption->Row - MenuOption->Skip + Temp2);
//
// We hit the end of MenuOption that can be focused
// so we simply scroll to the first page.
@@ -2846,10 +3172,10 @@ UiDisplayMenu (
if (NextMenuOption->Row == 0) {
UpdateOptionSkipLines (NextMenuOption);
}
- DistanceValue = Difference + NextMenuOption->Skip;
+ DistanceValue = Difference + NextMenuOption->Skip - Temp2;
Temp = MenuOption->Row + MenuOption->Skip + DistanceValue - 1;
- if ((MenuOption->Row + MenuOption->Skip == BottomRow + 1) &&
+ if ((MenuOption->Row + MenuOption->Skip - Temp2 == BottomRow + 1) &&
(NextMenuOption->ThisTag->OpCode->OpCode == EFI_IFR_DATE_OP ||
NextMenuOption->ThisTag->OpCode->OpCode == EFI_IFR_TIME_OP)
) {
@@ -2947,7 +3273,7 @@ UiDisplayMenu (
//
// Scroll to the first page.
//
- if (TopOfScreen != gMenuOption.ForwardLink) {
+ if (TopOfScreen != gMenuOption.ForwardLink || SkipValue != 0) {
TopOfScreen = gMenuOption.ForwardLink;
Repaint = TRUE;
MenuOption = NULL;
diff --git a/MdeModulePkg/Universal/DriverSampleDxe/Vfr.vfr b/MdeModulePkg/Universal/DriverSampleDxe/Vfr.vfr
index affd45ad1..032bf8883 100644
--- a/MdeModulePkg/Universal/DriverSampleDxe/Vfr.vfr
+++ b/MdeModulePkg/Universal/DriverSampleDxe/Vfr.vfr
@@ -259,6 +259,9 @@ formset
help = STRING_TOKEN(STR_ONE_OF_HELP),
option text = STRING_TOKEN(STR_ONE_OF_TEXT1), value = 0, flags = RESET_REQUIRED;
option text = STRING_TOKEN(STR_ONE_OF_TEXT2), value = 1, flags = DEFAULT | RESET_REQUIRED;
+ warningif prompt = STRING_TOKEN(STR_WARNING_POPUP), timeout = 5,
+ ideqval MyIfrNVData.TestLateCheck == 0
+ endif
endoneof;
diff --git a/MdeModulePkg/Universal/DriverSampleDxe/VfrStrings.uni b/MdeModulePkg/Universal/DriverSampleDxe/VfrStrings.uni
index 6693a9ec7..442de3840 100644
--- a/MdeModulePkg/Universal/DriverSampleDxe/VfrStrings.uni
+++ b/MdeModulePkg/Universal/DriverSampleDxe/VfrStrings.uni
Binary files differ
diff --git a/MdeModulePkg/Universal/FaultTolerantWriteDxe/FaultTolerantWrite.c b/MdeModulePkg/Universal/FaultTolerantWriteDxe/FaultTolerantWrite.c
index 3d1d29dfd..714b5d8d7 100644
--- a/MdeModulePkg/Universal/FaultTolerantWriteDxe/FaultTolerantWrite.c
+++ b/MdeModulePkg/Universal/FaultTolerantWriteDxe/FaultTolerantWrite.c
@@ -159,7 +159,7 @@ FtwAllocate (
}
DEBUG (
- (EFI_D_ERROR,
+ (EFI_D_INFO,
"Ftw: Allocate() success, Caller:%g, # %d\n",
CallerId,
NumberOfWrites)
@@ -573,7 +573,7 @@ FtwWrite (
FreePool (SpareBuffer);
DEBUG (
- (EFI_D_ERROR,
+ (EFI_D_INFO,
"Ftw: Write() success, (Lba:Offset)=(%lx:0x%x), Length: 0x%x\n",
Lba,
Offset,
diff --git a/MdeModulePkg/Universal/FaultTolerantWriteDxe/UpdateWorkingBlock.c b/MdeModulePkg/Universal/FaultTolerantWriteDxe/UpdateWorkingBlock.c
index 4c658b297..a5fa12b0a 100644
--- a/MdeModulePkg/Universal/FaultTolerantWriteDxe/UpdateWorkingBlock.c
+++ b/MdeModulePkg/Universal/FaultTolerantWriteDxe/UpdateWorkingBlock.c
@@ -258,7 +258,7 @@ FtwReclaimWorkSpace (
UINT8 *Ptr;
EFI_LBA WorkSpaceLbaOffset;
- DEBUG ((EFI_D_ERROR, "Ftw: start to reclaim work space\n"));
+ DEBUG ((EFI_D_INFO, "Ftw: start to reclaim work space\n"));
WorkSpaceLbaOffset = FtwDevice->FtwWorkSpaceLba - FtwDevice->FtwWorkBlockLba;
@@ -473,7 +473,7 @@ FtwReclaimWorkSpace (
FreePool (SpareBuffer);
- DEBUG ((EFI_D_ERROR, "Ftw: reclaim work space successfully\n"));
+ DEBUG ((EFI_D_INFO, "Ftw: reclaim work space successfully\n"));
return EFI_SUCCESS;
}
diff --git a/MdeModulePkg/Universal/HiiDatabaseDxe/ConfigRouting.c b/MdeModulePkg/Universal/HiiDatabaseDxe/ConfigRouting.c
index 4959d8302..2ed02cdaa 100644
--- a/MdeModulePkg/Universal/HiiDatabaseDxe/ConfigRouting.c
+++ b/MdeModulePkg/Universal/HiiDatabaseDxe/ConfigRouting.c
@@ -1109,6 +1109,7 @@ GetVarStoreType (
{
EFI_STATUS Status;
UINTN IfrOffset;
+ UINTN PackageOffset;
EFI_IFR_OP_HEADER *IfrOpHdr;
CHAR16 *VarStoreName;
EFI_STRING GuidStr;
@@ -1118,6 +1119,7 @@ GetVarStoreType (
UINT8 *HiiFormPackage;
UINTN PackageSize;
EFI_IFR_VARSTORE_EFI *IfrEfiVarStore;
+ EFI_HII_PACKAGE_HEADER *PackageHeader;
HiiFormPackage = NULL;
LengthString = 0;
@@ -1132,10 +1134,26 @@ GetVarStoreType (
return Status;
}
- IfrOffset = sizeof (EFI_HII_PACKAGE_HEADER);
+ IfrOffset = sizeof (EFI_HII_PACKAGE_HEADER);
+ PackageOffset = IfrOffset;
+ PackageHeader = (EFI_HII_PACKAGE_HEADER *) HiiFormPackage;
+
while (IfrOffset < PackageSize) {
- IfrOpHdr = (EFI_IFR_OP_HEADER *) (HiiFormPackage + IfrOffset);
+ //
+ // More than one form packages exist.
+ //
+ if (PackageOffset >= PackageHeader->Length) {
+ //
+ // Process the new form package.
+ //
+ PackageOffset = sizeof (EFI_HII_PACKAGE_HEADER);
+ IfrOffset += PackageOffset;
+ PackageHeader = (EFI_HII_PACKAGE_HEADER *) (HiiFormPackage + IfrOffset);
+ }
+
+ IfrOpHdr = (EFI_IFR_OP_HEADER *) (HiiFormPackage + IfrOffset);
IfrOffset += IfrOpHdr->Length;
+ PackageOffset += IfrOpHdr->Length;
if (IfrOpHdr->OpCode == EFI_IFR_VARSTORE_EFI_OP ) {
IfrEfiVarStore = (EFI_IFR_VARSTORE_EFI *) IfrOpHdr;
@@ -1190,6 +1208,13 @@ GetVarStoreType (
FreePool (GuidStr);
FreePool (NameStr);
FreePool (TempStr);
+
+ //
+ // Already found the varstore, break;
+ //
+ if (*IsEfiVarstore) {
+ break;
+ }
}
}
Done:
@@ -1415,6 +1440,7 @@ ParseIfrData (
{
EFI_STATUS Status;
UINTN IfrOffset;
+ UINTN PackageOffset;
EFI_IFR_VARSTORE *IfrVarStore;
EFI_IFR_VARSTORE_EFI *IfrEfiVarStore;
EFI_IFR_OP_HEADER *IfrOpHdr;
@@ -1438,25 +1464,50 @@ ParseIfrData (
LIST_ENTRY *LinkData;
LIST_ENTRY *LinkDefault;
EFI_IFR_VARSTORE_NAME_VALUE *IfrNameValueVarStore;
+ EFI_HII_PACKAGE_HEADER *PackageHeader;
+ EFI_VARSTORE_ID VarStoreId;
Status = EFI_SUCCESS;
BlockData = NULL;
DefaultDataPtr = NULL;
FirstOneOfOption = FALSE;
+ VarStoreId = 0;
ZeroMem (&DefaultData, sizeof (IFR_DEFAULT_DATA));
//
// Go through the form package to parse OpCode one by one.
//
- IfrOffset = sizeof (EFI_HII_PACKAGE_HEADER);
+ PackageOffset = sizeof (EFI_HII_PACKAGE_HEADER);
+ PackageHeader = (EFI_HII_PACKAGE_HEADER *) Package;
+ IfrOffset = PackageOffset;
while (IfrOffset < PackageLength) {
+
+ //
+ // More than one form package found.
+ //
+ if (PackageOffset >= PackageHeader->Length) {
+ //
+ // Already found varstore for this request, break;
+ //
+ if (VarStoreId != 0) {
+ VarStoreId = 0;
+ }
+
+ //
+ // Get next package header info.
+ //
+ IfrOffset += sizeof (EFI_HII_PACKAGE_HEADER);
+ PackageOffset = sizeof (EFI_HII_PACKAGE_HEADER);
+ PackageHeader = (EFI_HII_PACKAGE_HEADER *) (Package + IfrOffset);
+ }
+
IfrOpHdr = (EFI_IFR_OP_HEADER *) (Package + IfrOffset);
switch (IfrOpHdr->OpCode) {
case EFI_IFR_VARSTORE_OP:
//
// VarStore is found. Don't need to search any more.
//
- if (VarStorageData->VarStoreId != 0) {
+ if (VarStoreId != 0) {
break;
}
@@ -1474,10 +1525,10 @@ ParseIfrData (
// Find the matched VarStore
//
CopyGuid (&VarStorageData->Guid, (EFI_GUID *) (VOID *) &IfrVarStore->Guid);
- VarStorageData->VarStoreId = IfrVarStore->VarStoreId;
VarStorageData->Size = IfrVarStore->Size;
VarStorageData->Name = VarStoreName;
VarStorageData->Type = EFI_HII_VARSTORE_BUFFER;
+ VarStoreId = IfrVarStore->VarStoreId;
}
break;
@@ -1485,7 +1536,7 @@ ParseIfrData (
//
// VarStore is found. Don't need to search any more.
//
- if (VarStorageData->VarStoreId != 0) {
+ if (VarStoreId != 0) {
break;
}
@@ -1512,10 +1563,10 @@ ParseIfrData (
// Find the matched VarStore
//
CopyGuid (&VarStorageData->Guid, (EFI_GUID *) (VOID *) &IfrEfiVarStore->Guid);
- VarStorageData->VarStoreId = IfrEfiVarStore->VarStoreId;
VarStorageData->Size = IfrEfiVarStore->Size;
VarStorageData->Name = VarStoreName;
VarStorageData->Type = EFI_HII_VARSTORE_EFI_VARIABLE_BUFFER;
+ VarStoreId = IfrEfiVarStore->VarStoreId;
}
break;
@@ -1523,7 +1574,7 @@ ParseIfrData (
//
// VarStore is found. Don't need to search any more.
//
- if (VarStorageData->VarStoreId != 0) {
+ if (VarStoreId != 0) {
break;
}
@@ -1534,8 +1585,8 @@ ParseIfrData (
// Find the matched VarStore
//
CopyGuid (&VarStorageData->Guid, (EFI_GUID *) (VOID *) &IfrNameValueVarStore->Guid);
- VarStorageData->VarStoreId = IfrNameValueVarStore->VarStoreId;
VarStorageData->Type = EFI_HII_VARSTORE_NAME_VALUE;
+ VarStoreId = IfrNameValueVarStore->VarStoreId;
}
break;
@@ -1558,7 +1609,7 @@ ParseIfrData (
//
// No matched varstore is found and directly return.
//
- if (VarStorageData->VarStoreId == 0) {
+ if ( VarStoreId == 0) {
Status = EFI_SUCCESS;
goto Done;
}
@@ -1568,7 +1619,7 @@ ParseIfrData (
//
// Ref question is not in IFR Form. This IFR form is not valid.
//
- if (VarStorageData->VarStoreId == 0) {
+ if ( VarStoreId == 0) {
Status = EFI_INVALID_PARAMETER;
goto Done;
}
@@ -1576,7 +1627,7 @@ ParseIfrData (
// Check whether this question is for the requested varstore.
//
IfrRef = (EFI_IFR_REF4 *) IfrOpHdr;
- if (IfrRef->Question.VarStoreId != VarStorageData->VarStoreId) {
+ if (IfrRef->Question.VarStoreId != VarStoreId) {
break;
}
VarWidth = (UINT16) (sizeof (EFI_HII_REF));
@@ -1596,7 +1647,7 @@ ParseIfrData (
//
// Numeric and OneOf question is not in IFR Form. This IFR form is not valid.
//
- if (VarStorageData->VarStoreId == 0) {
+ if (VarStoreId == 0) {
Status = EFI_INVALID_PARAMETER;
goto Done;
}
@@ -1604,7 +1655,7 @@ ParseIfrData (
// Check whether this question is for the requested varstore.
//
IfrOneOf = (EFI_IFR_ONE_OF *) IfrOpHdr;
- if (IfrOneOf->Question.VarStoreId != VarStorageData->VarStoreId) {
+ if (IfrOneOf->Question.VarStoreId != VarStoreId) {
break;
}
VarWidth = (UINT16) (1 << (IfrOneOf->Flags & EFI_IFR_NUMERIC_SIZE));
@@ -1673,7 +1724,7 @@ ParseIfrData (
//
// OrderedList question is not in IFR Form. This IFR form is not valid.
//
- if (VarStorageData->VarStoreId == 0) {
+ if (VarStoreId == 0) {
Status = EFI_INVALID_PARAMETER;
goto Done;
}
@@ -1681,7 +1732,7 @@ ParseIfrData (
// Check whether this question is for the requested varstore.
//
IfrOrderedList = (EFI_IFR_ORDERED_LIST *) IfrOpHdr;
- if (IfrOrderedList->Question.VarStoreId != VarStorageData->VarStoreId) {
+ if (IfrOrderedList->Question.VarStoreId != VarStoreId) {
BlockData = NULL;
break;
}
@@ -1705,7 +1756,7 @@ ParseIfrData (
//
// CheckBox question is not in IFR Form. This IFR form is not valid.
//
- if (VarStorageData->VarStoreId == 0) {
+ if (VarStoreId == 0) {
Status = EFI_INVALID_PARAMETER;
goto Done;
}
@@ -1713,7 +1764,7 @@ ParseIfrData (
// Check whether this question is for the requested varstore.
//
IfrCheckBox = (EFI_IFR_CHECKBOX *) IfrOpHdr;
- if (IfrCheckBox->Question.VarStoreId != VarStorageData->VarStoreId) {
+ if (IfrCheckBox->Question.VarStoreId != VarStoreId) {
break;
}
VarWidth = (UINT16) sizeof (BOOLEAN);
@@ -1792,7 +1843,7 @@ ParseIfrData (
//
// Date question is not in IFR Form. This IFR form is not valid.
//
- if (VarStorageData->VarStoreId == 0) {
+ if (VarStoreId == 0) {
Status = EFI_INVALID_PARAMETER;
goto Done;
}
@@ -1800,7 +1851,7 @@ ParseIfrData (
// Check whether this question is for the requested varstore.
//
IfrDate = (EFI_IFR_DATE *) IfrOpHdr;
- if (IfrDate->Question.VarStoreId != VarStorageData->VarStoreId) {
+ if (IfrDate->Question.VarStoreId != VarStoreId) {
break;
}
@@ -1821,7 +1872,7 @@ ParseIfrData (
//
// Time question is not in IFR Form. This IFR form is not valid.
//
- if (VarStorageData->VarStoreId == 0) {
+ if (VarStoreId == 0) {
Status = EFI_INVALID_PARAMETER;
goto Done;
}
@@ -1829,7 +1880,7 @@ ParseIfrData (
// Check whether this question is for the requested varstore.
//
IfrTime = (EFI_IFR_TIME *) IfrOpHdr;
- if (IfrTime->Question.VarStoreId != VarStorageData->VarStoreId) {
+ if (IfrTime->Question.VarStoreId != VarStoreId) {
break;
}
@@ -1850,7 +1901,7 @@ ParseIfrData (
//
// String question is not in IFR Form. This IFR form is not valid.
//
- if (VarStorageData->VarStoreId == 0) {
+ if (VarStoreId == 0) {
Status = EFI_INVALID_PARAMETER;
goto Done;
}
@@ -1858,7 +1909,7 @@ ParseIfrData (
// Check whether this question is for the requested varstore.
//
IfrString = (EFI_IFR_STRING *) IfrOpHdr;
- if (IfrString->Question.VarStoreId != VarStorageData->VarStoreId) {
+ if (IfrString->Question.VarStoreId != VarStoreId) {
break;
}
@@ -1884,7 +1935,7 @@ ParseIfrData (
//
// Password question is not in IFR Form. This IFR form is not valid.
//
- if (VarStorageData->VarStoreId == 0) {
+ if (VarStoreId == 0) {
Status = EFI_INVALID_PARAMETER;
goto Done;
}
@@ -1892,7 +1943,7 @@ ParseIfrData (
// Check whether this question is for the requested varstore.
//
IfrPassword = (EFI_IFR_PASSWORD *) IfrOpHdr;
- if (IfrPassword->Question.VarStoreId != VarStorageData->VarStoreId) {
+ if (IfrPassword->Question.VarStoreId != VarStoreId) {
break;
}
@@ -2089,7 +2140,8 @@ ParseIfrData (
break;
}
- IfrOffset += IfrOpHdr->Length;
+ IfrOffset += IfrOpHdr->Length;
+ PackageOffset += IfrOpHdr->Length;
}
Done:
@@ -2990,7 +3042,7 @@ GetFullStringFromHiiFormPackages (
//
// No requested varstore in IFR data and directly return
//
- if (VarStorageData->VarStoreId == 0) {
+ if (VarStorageData->Type == 0 && VarStorageData->Name == NULL) {
Status = EFI_SUCCESS;
goto Done;
}
diff --git a/MdeModulePkg/Universal/HiiDatabaseDxe/HiiDatabase.h b/MdeModulePkg/Universal/HiiDatabaseDxe/HiiDatabase.h
index 9046d9057..32e48275b 100644
--- a/MdeModulePkg/Universal/HiiDatabaseDxe/HiiDatabase.h
+++ b/MdeModulePkg/Universal/HiiDatabaseDxe/HiiDatabase.h
@@ -65,7 +65,6 @@ typedef struct {
LIST_ENTRY Entry; // Link to VarStorage
EFI_GUID Guid;
CHAR16 *Name;
- EFI_VARSTORE_ID VarStoreId;
UINT16 Size;
UINT8 Type;
LIST_ENTRY BlockEntry; // Link to its Block array
diff --git a/MdeModulePkg/Universal/Network/IScsiDxe/IScsiIbft.c b/MdeModulePkg/Universal/Network/IScsiDxe/IScsiIbft.c
index dd4189c02..04f5df34a 100644
--- a/MdeModulePkg/Universal/Network/IScsiDxe/IScsiIbft.c
+++ b/MdeModulePkg/Universal/Network/IScsiDxe/IScsiIbft.c
@@ -1,7 +1,7 @@
/** @file
Implementation for iSCSI Boot Firmware Table publication.
-Copyright (c) 2004 - 2011, Intel Corporation. All rights reserved.<BR>
+Copyright (c) 2004 - 2013, 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,12 +37,6 @@ IScsiInitIbfTableHeader (
Header->Length = IBFT_HEAP_OFFSET;
Header->Revision = EFI_ACPI_ISCSI_BOOT_FIRMWARE_TABLE_REVISION;
Header->Checksum = 0;
-
- Header->OemId[0] = 'I';
- Header->OemId[1] = 'N';
- Header->OemId[2] = 'T';
- Header->OemId[3] = 'E';
- Header->OemId[4] = 'L';
CopyMem (Header->OemId, OemId, sizeof (Header->OemId));
CopyMem (&Header->OemTableId, OemTableId, sizeof (UINT64));
diff --git a/MdeModulePkg/Universal/Network/IScsiDxe/IScsiProto.c b/MdeModulePkg/Universal/Network/IScsiDxe/IScsiProto.c
index 5a6002e83..ffe0c6e1a 100644
--- a/MdeModulePkg/Universal/Network/IScsiDxe/IScsiProto.c
+++ b/MdeModulePkg/Universal/Network/IScsiDxe/IScsiProto.c
@@ -2535,7 +2535,8 @@ IScsiExecuteScsiCommand (
Timeout = 0;
if (Session->State != SESSION_STATE_LOGGED_IN) {
- return EFI_DEVICE_ERROR;
+ Status = EFI_DEVICE_ERROR;
+ goto ON_EXIT;
}
Conn = NET_LIST_USER_STRUCT_S (
@@ -2707,7 +2708,7 @@ IScsiSessionReinstatement (
EFI_STATUS Status;
Session = &Private->Session;
- ASSERT (Session->State == SESSION_STATE_LOGGED_IN);
+ ASSERT (Session->State != SESSION_STATE_FREE);
//
// Abort the session and re-init it.
diff --git a/MdeModulePkg/Universal/Network/Ip4ConfigDxe/Ip4Config.c b/MdeModulePkg/Universal/Network/Ip4ConfigDxe/Ip4Config.c
index 5493d07d1..3eff1882e 100644
--- a/MdeModulePkg/Universal/Network/Ip4ConfigDxe/Ip4Config.c
+++ b/MdeModulePkg/Universal/Network/Ip4ConfigDxe/Ip4Config.c
@@ -176,7 +176,7 @@ Ip4ConfigOnDhcp4Complete (
EFI_DHCP4_MODE_DATA Dhcp4Mode;
EFI_IP4_IPCONFIG_DATA *Ip4Config;
EFI_STATUS Status;
- BOOLEAN Perment;
+ BOOLEAN Permanent;
IP4_ADDR Subnet;
IP4_ADDR Ip1;
IP4_ADDR Ip2;
@@ -202,11 +202,11 @@ Ip4ConfigOnDhcp4Complete (
// the instance and to NVRam. So, both the IP4 driver and
// other user can get that address.
//
- Perment = FALSE;
+ Permanent = FALSE;
if (Instance->NicConfig != NULL) {
ASSERT (Instance->NicConfig->Source == IP4_CONFIG_SOURCE_DHCP);
- Perment = Instance->NicConfig->Perment;
+ Permanent = Instance->NicConfig->Permanent;
FreePool (Instance->NicConfig);
}
@@ -221,7 +221,7 @@ Ip4ConfigOnDhcp4Complete (
CopyMem (&Instance->NicConfig->NicAddr, &Instance->NicAddr, sizeof (Instance->NicConfig->NicAddr));
Instance->NicConfig->Source = IP4_CONFIG_SOURCE_DHCP;
- Instance->NicConfig->Perment = Perment;
+ Instance->NicConfig->Permanent = Permanent;
Ip4Config = &Instance->NicConfig->Ip4Info;
Ip4Config->StationAddress = Dhcp4Mode.ClientAddress;
diff --git a/MdeModulePkg/Universal/Network/Ip4ConfigDxe/Ip4ConfigDriver.c b/MdeModulePkg/Universal/Network/Ip4ConfigDxe/Ip4ConfigDriver.c
index 790e44be4..56cce6e6f 100644
--- a/MdeModulePkg/Universal/Network/Ip4ConfigDxe/Ip4ConfigDriver.c
+++ b/MdeModulePkg/Universal/Network/Ip4ConfigDxe/Ip4ConfigDriver.c
@@ -319,7 +319,7 @@ Ip4ConfigDriverBindingStart (
//
NicConfig = Ip4ConfigReadVariable (Instance);
if (NicConfig != NULL) {
- if (!NicConfig->Perment) {
+ if (!NicConfig->Permanent) {
//
// Delete the non-permanent configuration.
//
diff --git a/MdeModulePkg/Universal/Network/Ip4ConfigDxe/Ip4ConfigNv.c b/MdeModulePkg/Universal/Network/Ip4ConfigDxe/Ip4ConfigNv.c
index f09bd5174..89e1ddaf3 100644
--- a/MdeModulePkg/Universal/Network/Ip4ConfigDxe/Ip4ConfigNv.c
+++ b/MdeModulePkg/Universal/Network/Ip4ConfigDxe/Ip4ConfigNv.c
@@ -271,7 +271,7 @@ Ip4ConfigConvertIfrNvDataToDeviceConfigData (
ZeroMem (&Ip4ConfigInstance->Ip4ConfigCallbackInfo.Gateway, sizeof (EFI_IPv4_ADDRESS));
}
- NicInfo->Perment = TRUE;
+ NicInfo->Permanent = TRUE;
CopyMem (&NicInfo->NicAddr, &Ip4ConfigInstance->NicAddr, sizeof (NIC_ADDR));
return EfiNicIp4ConfigSetInfo (Ip4ConfigInstance, NicInfo, TRUE);
diff --git a/MdeModulePkg/Universal/Network/Ip4Dxe/Ip4Impl.c b/MdeModulePkg/Universal/Network/Ip4Dxe/Ip4Impl.c
index 29f07ce4a..cd01685a3 100644
--- a/MdeModulePkg/Universal/Network/Ip4Dxe/Ip4Impl.c
+++ b/MdeModulePkg/Universal/Network/Ip4Dxe/Ip4Impl.c
@@ -2002,7 +2002,8 @@ EfiIp4Transmit (
RawHdrLen = (UINT8) (RawHdrLen & 0x0f);
if (RawHdrLen < 5) {
- return EFI_INVALID_PARAMETER;
+ Status = EFI_INVALID_PARAMETER;
+ goto ON_EXIT;
}
RawHdrLen = (UINT8) (RawHdrLen << 2);
@@ -2014,7 +2015,8 @@ EfiIp4Transmit (
DontFragment = IP4_DO_NOT_FRAGMENT (Head.Fragment);
if (!DontFragment) {
- return EFI_INVALID_PARAMETER;
+ Status = EFI_INVALID_PARAMETER;
+ goto ON_EXIT;
}
GateWay = IP4_ALLZERO_ADDRESS;
diff --git a/MdeModulePkg/Universal/SetupBrowserDxe/IfrParse.c b/MdeModulePkg/Universal/SetupBrowserDxe/IfrParse.c
index ac7dce694..4006fcd6f 100644
--- a/MdeModulePkg/Universal/SetupBrowserDxe/IfrParse.c
+++ b/MdeModulePkg/Universal/SetupBrowserDxe/IfrParse.c
@@ -510,10 +510,6 @@ CreateStorage (
InitializeConfigHdr (FormSet, BrowserStorage);
}
- //
- // Add count because one formset storage use this global storage.
- //
- BrowserStorage->ReferenceCount++;
Storage->BrowserStorage = BrowserStorage;
Storage->ConfigRequest = AllocateCopyPool (StrSize (BrowserStorage->ConfigHdr), BrowserStorage->ConfigHdr);
@@ -742,12 +738,6 @@ DestroyStorage (
FreePool (Storage->ConfigRequest);
}
- //
- // Minus the reference to the global storage.
- //
- ASSERT (Storage->BrowserStorage->ReferenceCount > 0);
- Storage->BrowserStorage->ReferenceCount--;
-
FreePool (Storage);
}
diff --git a/MdeModulePkg/Universal/SetupBrowserDxe/Presentation.c b/MdeModulePkg/Universal/SetupBrowserDxe/Presentation.c
index a5caf4426..8e6dff0dd 100644
--- a/MdeModulePkg/Universal/SetupBrowserDxe/Presentation.c
+++ b/MdeModulePkg/Universal/SetupBrowserDxe/Presentation.c
@@ -160,7 +160,7 @@ UpdateStatement (
//
// Question value may be changed, need invoke its Callback()
//
- ProcessCallBackFunction (gCurrentSelection, Statement, EFI_BROWSER_ACTION_CHANGING, FALSE);
+ ProcessCallBackFunction (gCurrentSelection, gCurrentSelection->FormSet, gCurrentSelection->Form, Statement, EFI_BROWSER_ACTION_RETRIEVE, FALSE);
if (mHiiPackageListUpdated) {
//
@@ -571,6 +571,47 @@ UpdateHotkeyList (
/**
+ Get the extra question attribute from override question list.
+
+ @param QuestionId The question id for this request question.
+
+ @retval The attribute for this question or NULL if not found this
+ question in the list.
+
+**/
+UINT32
+ProcessQuestionExtraAttr (
+ IN EFI_QUESTION_ID QuestionId
+ )
+{
+ LIST_ENTRY *Link;
+ QUESTION_ATTRIBUTE_OVERRIDE *QuestionDesc;
+
+ //
+ // Return HII_DISPLAY_NONE if input a invalid question id.
+ //
+ if (QuestionId == 0) {
+ return HII_DISPLAY_NONE;
+ }
+
+ Link = GetFirstNode (&mPrivateData.FormBrowserEx2.OverrideQestListHead);
+ while (!IsNull (&mPrivateData.FormBrowserEx2.OverrideQestListHead, Link)) {
+ QuestionDesc = FORM_QUESTION_ATTRIBUTE_OVERRIDE_FROM_LINK (Link);
+ Link = GetNextNode (&mPrivateData.FormBrowserEx2.OverrideQestListHead, Link);
+
+ if ((QuestionDesc->QuestionId == QuestionId) &&
+ (QuestionDesc->FormId == gCurrentSelection->FormId) &&
+ (QuestionDesc->HiiHandle == gCurrentSelection->Handle) &&
+ CompareGuid (&QuestionDesc->FormSetGuid, &gCurrentSelection->FormSetGuid)) {
+ return QuestionDesc->Attribute;
+ }
+ }
+
+ return HII_DISPLAY_NONE;
+}
+
+/**
+
Enum all statement in current form, find all the statement can be display and
add to the display form.
@@ -589,6 +630,7 @@ AddStatementToDisplayForm (
EFI_EVENT RefreshIntervalEvent;
FORM_BROWSER_REFRESH_EVENT_NODE *EventNode;
BOOLEAN FormEditable;
+ UINT32 ExtraAttribute;
HostDisplayStatement = NULL;
MinRefreshInterval = 0;
@@ -630,6 +672,14 @@ AddStatementToDisplayForm (
continue;
}
+ //
+ // Check the extra attribute.
+ //
+ ExtraAttribute = ProcessQuestionExtraAttr (Statement->QuestionId);
+ if ((ExtraAttribute & HII_DISPLAY_SUPPRESS) != 0) {
+ continue;
+ }
+
DisplayStatement = AllocateZeroPool (sizeof (FORM_DISPLAY_ENGINE_STATEMENT));
ASSERT (DisplayStatement != NULL);
@@ -639,6 +689,11 @@ AddStatementToDisplayForm (
InitializeDisplayStatement(DisplayStatement, Statement, HostDisplayStatement);
//
+ // Set the extra attribute.
+ //
+ DisplayStatement->Attribute |= ExtraAttribute;
+
+ //
// Save the Host statement info.
// Host statement may has nest statement follow it.
//
@@ -1309,7 +1364,7 @@ ProcessGotoOpCode (
//
// Check whether the device path string is a valid string.
//
- if (Statement->HiiValue.Value.ref.DevicePath != 0 && StringPtr != NULL) {
+ if (Statement->HiiValue.Value.ref.DevicePath != 0 && StringPtr != NULL && StringPtr[0] != L'\0') {
if (Selection->Form->ModalForm) {
return Status;
}
@@ -1618,9 +1673,6 @@ ProcessUserInput (
CopyMem (&Statement->HiiValue, &UserInput->InputValue, sizeof (EFI_HII_VALUE));
break;
}
- if (Statement->Operand != EFI_IFR_PASSWORD_OP) {
- SetQuestionValue (gCurrentSelection->FormSet, gCurrentSelection->Form, Statement, GetSetValueWithEditBuffer);
- }
break;
}
}
@@ -1986,6 +2038,8 @@ FindNextMenu (
about the Selection, form and formset to be displayed.
On output, Selection return the screen item that is selected
by user.
+ @param FormSet The formset this question belong to.
+ @param Form The form this question belong to.
@param Question The Question which need to call.
@param Action The action request.
@param SkipSaveOrDiscard Whether skip save or discard action.
@@ -1996,6 +2050,8 @@ FindNextMenu (
EFI_STATUS
ProcessCallBackFunction (
IN OUT UI_MENU_SELECTION *Selection,
+ IN FORM_BROWSER_FORMSET *FormSet,
+ IN FORM_BROWSER_FORM *Form,
IN FORM_BROWSER_STATEMENT *Question,
IN EFI_BROWSER_ACTION Action,
IN BOOLEAN SkipSaveOrDiscard
@@ -2012,23 +2068,26 @@ ProcessCallBackFunction (
BOOLEAN NeedExit;
LIST_ENTRY *Link;
BROWSER_SETTING_SCOPE SettingLevel;
+ EFI_IFR_TYPE_VALUE BackUpValue;
+ UINT8 *BackUpBuffer;
- ConfigAccess = Selection->FormSet->ConfigAccess;
+ ConfigAccess = FormSet->ConfigAccess;
SubmitFormIsRequired = FALSE;
SettingLevel = FormSetLevel;
DiscardFormIsRequired = FALSE;
NeedExit = FALSE;
Status = EFI_SUCCESS;
ActionRequest = EFI_BROWSER_ACTION_REQUEST_NONE;
+ BackUpBuffer = NULL;
if (ConfigAccess == NULL) {
return EFI_SUCCESS;
}
- Link = GetFirstNode (&Selection->Form->StatementListHead);
- while (!IsNull (&Selection->Form->StatementListHead, Link)) {
+ Link = GetFirstNode (&Form->StatementListHead);
+ while (!IsNull (&Form->StatementListHead, Link)) {
Statement = FORM_BROWSER_STATEMENT_FROM_LINK (Link);
- Link = GetNextNode (&Selection->Form->StatementListHead, Link);
+ Link = GetNextNode (&Form->StatementListHead, Link);
//
// if Question != NULL, only process the question. Else, process all question in this form.
@@ -2045,7 +2104,7 @@ ProcessCallBackFunction (
// Check whether Statement is disabled.
//
if (Statement->Expression != NULL) {
- if (EvaluateExpressionList(Statement->Expression, TRUE, Selection->FormSet, Selection->Form) == ExpressDisable) {
+ if (EvaluateExpressionList(Statement->Expression, TRUE, FormSet, Form) == ExpressDisable) {
continue;
}
}
@@ -2058,7 +2117,18 @@ ProcessCallBackFunction (
//
TypeValue = (EFI_IFR_TYPE_VALUE *) Statement->BufferValue;
}
-
+
+ //
+ // If EFI_BROWSER_ACTION_CHANGING type, back up the new question value.
+ //
+ if (Action == EFI_BROWSER_ACTION_CHANGING) {
+ if (HiiValue->Type == EFI_IFR_TYPE_BUFFER) {
+ BackUpBuffer = AllocateCopyPool(Statement->StorageWidth + sizeof(CHAR16), Statement->BufferValue);
+ } else {
+ CopyMem (&BackUpValue, &HiiValue->Value, sizeof (EFI_IFR_TYPE_VALUE));
+ }
+ }
+
ActionRequest = EFI_BROWSER_ACTION_REQUEST_NONE;
Status = ConfigAccess->Callback (
ConfigAccess,
@@ -2122,15 +2192,31 @@ ProcessCallBackFunction (
// "retrieve" should update to the question's temp buffer.
//
if (Action == EFI_BROWSER_ACTION_CHANGING || Action == EFI_BROWSER_ACTION_RETRIEVE) {
- SetQuestionValue(Selection->FormSet, Selection->Form, Statement, GetSetValueWithEditBuffer);
+ SetQuestionValue(FormSet, Form, Statement, GetSetValueWithEditBuffer);
}
} else {
//
+ // If the callback returns EFI_UNSUPPORTED for EFI_BROWSER_ACTION_CHANGING,
+ // then the browser will use the value passed to Callback() and ignore the
+ // value returned by Callback().
+ //
+ if (Action == EFI_BROWSER_ACTION_CHANGING && Status == EFI_UNSUPPORTED) {
+ if (HiiValue->Type == EFI_IFR_TYPE_BUFFER) {
+ CopyMem (Statement->BufferValue, BackUpBuffer, Statement->StorageWidth + sizeof(CHAR16));
+ } else {
+ CopyMem (&HiiValue->Value, &BackUpValue, sizeof (EFI_IFR_TYPE_VALUE));
+ }
+
+ SetQuestionValue(FormSet, Form, Statement, GetSetValueWithEditBuffer);
+ }
+
+ //
// According the spec, return fail from call back of "changing" and
// "retrieve", should restore the question's value.
//
- if (Action == EFI_BROWSER_ACTION_CHANGING || Action == EFI_BROWSER_ACTION_RETRIEVE) {
- GetQuestionValue(Selection->FormSet, Selection->Form, Statement, GetSetValueWithEditBuffer);
+ if ((Action == EFI_BROWSER_ACTION_CHANGING && Status != EFI_UNSUPPORTED) ||
+ Action == EFI_BROWSER_ACTION_RETRIEVE) {
+ GetQuestionValue(FormSet, Form, Statement, GetSetValueWithEditBuffer);
}
if (Status == EFI_UNSUPPORTED) {
@@ -2140,14 +2226,18 @@ ProcessCallBackFunction (
Status = EFI_SUCCESS;
}
}
+
+ if (BackUpBuffer != NULL) {
+ FreePool (BackUpBuffer);
+ }
}
if (SubmitFormIsRequired && !SkipSaveOrDiscard) {
- SubmitForm (Selection->FormSet, Selection->Form, SettingLevel);
+ SubmitForm (FormSet, Form, SettingLevel);
}
if (DiscardFormIsRequired && !SkipSaveOrDiscard) {
- DiscardForm (Selection->FormSet, Selection->Form, SettingLevel);
+ DiscardForm (FormSet, Form, SettingLevel);
}
if (NeedExit) {
@@ -2249,6 +2339,11 @@ SetupBrowser (
return Status;
}
+ if ((Selection->Handle != mCurrentHiiHandle) ||
+ (!CompareGuid (&Selection->FormSetGuid, &mCurrentFormSetGuid))) {
+ gFinishRetrieveCall = FALSE;
+ }
+
//
// Initialize current settings of Questions in this FormSet
//
@@ -2327,7 +2422,7 @@ SetupBrowser (
CopyGuid (&mCurrentFormSetGuid, &Selection->FormSetGuid);
mCurrentFormId = Selection->FormId;
- Status = ProcessCallBackFunction (Selection, NULL, EFI_BROWSER_ACTION_FORM_OPEN, FALSE);
+ Status = ProcessCallBackFunction (Selection, gCurrentSelection->FormSet, Selection->Form, NULL, EFI_BROWSER_ACTION_FORM_OPEN, FALSE);
if (EFI_ERROR (Status)) {
goto Done;
}
@@ -2351,6 +2446,11 @@ SetupBrowser (
}
//
+ // Finish call RETRIEVE callback for this formset.
+ //
+ gFinishRetrieveCall = TRUE;
+
+ //
// IFR is updated during callback of read value, force to reparse the IFR binary
//
if (mHiiPackageListUpdated) {
@@ -2375,7 +2475,7 @@ SetupBrowser (
if ((ConfigAccess != NULL) &&
((Statement->QuestionFlags & EFI_IFR_FLAG_CALLBACK) == EFI_IFR_FLAG_CALLBACK) &&
(Statement->Operand != EFI_IFR_PASSWORD_OP)) {
- Status = ProcessCallBackFunction(Selection, Statement, EFI_BROWSER_ACTION_CHANGING, FALSE);
+ Status = ProcessCallBackFunction(Selection, Selection->FormSet, Selection->Form, Statement, EFI_BROWSER_ACTION_CHANGING, FALSE);
if (Statement->Operand == EFI_IFR_REF_OP) {
//
// Process dynamic update ref opcode.
@@ -2397,8 +2497,10 @@ SetupBrowser (
}
if (!EFI_ERROR (Status) && Statement->Operand != EFI_IFR_REF_OP) {
- ProcessCallBackFunction(Selection, Statement, EFI_BROWSER_ACTION_CHANGED, FALSE);
+ ProcessCallBackFunction(Selection, Selection->FormSet, Selection->Form, Statement, EFI_BROWSER_ACTION_CHANGED, FALSE);
}
+ } else if (Statement->Operand != EFI_IFR_PASSWORD_OP) {
+ SetQuestionValue (gCurrentSelection->FormSet, gCurrentSelection->Form, Statement, GetSetValueWithEditBuffer);
}
}
@@ -2433,7 +2535,7 @@ SetupBrowser (
(!CompareGuid (&Selection->FormSetGuid, &mCurrentFormSetGuid)) ||
(Selection->FormId != mCurrentFormId))) {
- Status = ProcessCallBackFunction (Selection, NULL, EFI_BROWSER_ACTION_FORM_CLOSE, FALSE);
+ Status = ProcessCallBackFunction (Selection, Selection->FormSet, Selection->Form, NULL, EFI_BROWSER_ACTION_FORM_CLOSE, FALSE);
if (EFI_ERROR (Status)) {
goto Done;
}
diff --git a/MdeModulePkg/Universal/SetupBrowserDxe/Setup.c b/MdeModulePkg/Universal/SetupBrowserDxe/Setup.c
index 6dcb4aa77..7975a1df1 100644
--- a/MdeModulePkg/Universal/SetupBrowserDxe/Setup.c
+++ b/MdeModulePkg/Universal/SetupBrowserDxe/Setup.c
@@ -48,11 +48,13 @@ LIST_ENTRY gBrowserFormSetList = INITIALIZE_LIST_HEAD_VARIABLE (gBrowserFor
LIST_ENTRY gBrowserHotKeyList = INITIALIZE_LIST_HEAD_VARIABLE (gBrowserHotKeyList);
LIST_ENTRY gBrowserStorageList = INITIALIZE_LIST_HEAD_VARIABLE (gBrowserStorageList);
+BOOLEAN gFinishRetrieveCall;
BOOLEAN gResetRequired;
BOOLEAN gExitRequired;
BROWSER_SETTING_SCOPE gBrowserSettingScope = FormSetLevel;
BOOLEAN mBrowserScopeFirstSet = TRUE;
EXIT_HANDLER ExitHandlerFunction = NULL;
+FORM_BROWSER_FORMSET *mSystemLevelFormSet;
//
// Browser Global Strings
@@ -255,6 +257,12 @@ LoadAllHiiFormset (
UINTN Index;
EFI_GUID ZeroGuid;
EFI_STATUS Status;
+ FORM_BROWSER_FORMSET *OldFormset;
+ BOOLEAN OldRetrieveValue;
+
+ OldFormset = mSystemLevelFormSet;
+ OldRetrieveValue = gFinishRetrieveCall;
+ gFinishRetrieveCall = FALSE;
//
// Get all the Hii handles
@@ -278,6 +286,8 @@ LoadAllHiiFormset (
//
LocalFormSet = AllocateZeroPool (sizeof (FORM_BROWSER_FORMSET));
ASSERT (LocalFormSet != NULL);
+ mSystemLevelFormSet = LocalFormSet;
+
ZeroMem (&ZeroGuid, sizeof (ZeroGuid));
Status = InitializeFormSet (HiiHandles[Index], &ZeroGuid, LocalFormSet);
if (EFI_ERROR (Status) || IsListEmpty (&LocalFormSet->FormListHead)) {
@@ -300,6 +310,9 @@ LoadAllHiiFormset (
// Free resources, and restore gOldFormSet and gClassOfVfr
//
FreePool (HiiHandles);
+
+ gFinishRetrieveCall = OldRetrieveValue;
+ mSystemLevelFormSet = OldFormset;
}
/**
@@ -357,6 +370,7 @@ SendForm (
//
SaveBrowserContext ();
+ gFinishRetrieveCall = FALSE;
gResetRequired = FALSE;
gExitRequired = FALSE;
Status = EFI_SUCCESS;
@@ -388,6 +402,7 @@ SendForm (
break;
}
Selection->FormSet = FormSet;
+ mSystemLevelFormSet = FormSet;
//
// Display this formset
@@ -397,6 +412,7 @@ SendForm (
Status = SetupBrowser (Selection);
gCurrentSelection = NULL;
+ mSystemLevelFormSet = NULL;
//
// If no data is changed, don't need to save current FormSet into the maintain list.
@@ -580,7 +596,6 @@ BrowserCallback (
LIST_ENTRY *Link;
BROWSER_STORAGE *Storage;
FORMSET_STORAGE *FormsetStorage;
- FORM_BROWSER_FORMSET *FormSet;
UINTN TotalSize;
BOOLEAN Found;
@@ -650,16 +665,15 @@ BrowserCallback (
//
// GUID/Name is not specified, take the first storage in FormSet
//
- if (gCurrentSelection == NULL) {
+ if (mSystemLevelFormSet == NULL) {
return EFI_NOT_READY;
}
//
// Generate <ConfigResp>
//
- FormSet = gCurrentSelection->FormSet;
- Link = GetFirstNode (&FormSet->StorageListHead);
- if (IsNull (&FormSet->StorageListHead, Link)) {
+ Link = GetFirstNode (&mSystemLevelFormSet->StorageListHead);
+ if (IsNull (&mSystemLevelFormSet->StorageListHead, Link)) {
return EFI_UNSUPPORTED;
}
@@ -766,7 +780,8 @@ InitializeSetup (
//
// Install FormBrowserEx2 protocol
//
- InitializeListHead (&mPrivateData.FormBrowserEx2.FormViewHistoryHead);
+ InitializeListHead (&mPrivateData.FormBrowserEx2.FormViewHistoryHead);
+ InitializeListHead (&mPrivateData.FormBrowserEx2.OverrideQestListHead);
mPrivateData.Handle = NULL;
Status = gBS->InstallProtocolInterface (
&mPrivateData.Handle,
@@ -2360,7 +2375,8 @@ DiscardForm (
LIST_ENTRY *Link;
FORMSET_STORAGE *Storage;
FORM_BROWSER_CONFIG_REQUEST *ConfigInfo;
- FORM_BROWSER_FORMSET *LocalFormSet;
+ FORM_BROWSER_FORMSET *LocalFormSet;
+ FORM_BROWSER_FORMSET *OldFormSet;
//
// Check the supported setting level.
@@ -2439,7 +2455,8 @@ DiscardForm (
//
// System Level Discard.
//
-
+ OldFormSet = mSystemLevelFormSet;
+
//
// Discard changed value for each FormSet in the maintain list.
//
@@ -2450,6 +2467,9 @@ DiscardForm (
if (!ValidateFormSet(LocalFormSet)) {
continue;
}
+
+ mSystemLevelFormSet = LocalFormSet;
+
DiscardForm (LocalFormSet, NULL, FormSetLevel);
if (!IsHiiHandleInBrowserContext (LocalFormSet->HiiHandle)) {
//
@@ -2460,6 +2480,8 @@ DiscardForm (
DestroyFormSet (LocalFormSet);
}
}
+
+ mSystemLevelFormSet = OldFormSet;
}
return EFI_SUCCESS;
@@ -3401,6 +3423,7 @@ ExtractDefault (
LIST_ENTRY *Link;
FORM_BROWSER_STATEMENT *Question;
FORM_BROWSER_FORMSET *LocalFormSet;
+ FORM_BROWSER_FORMSET *OldFormSet;
Status = EFI_SUCCESS;
@@ -3484,7 +3507,9 @@ ExtractDefault (
// Preload all Hii formset.
//
LoadAllHiiFormset();
-
+
+ OldFormSet = mSystemLevelFormSet;
+
//
// Set Default Value for each FormSet in the maintain list.
//
@@ -3495,8 +3520,13 @@ ExtractDefault (
if (!ValidateFormSet(LocalFormSet)) {
continue;
}
+
+ mSystemLevelFormSet = LocalFormSet;
+
ExtractDefault (LocalFormSet, NULL, DefaultId, FormSetLevel, GetDefaultValueScope, Storage, RetrieveValueFirst);
}
+
+ mSystemLevelFormSet = OldFormSet;
}
return EFI_SUCCESS;
@@ -3627,7 +3657,8 @@ LoadFormConfig (
// Call the Retrieve call back function for all questions.
//
if ((FormSet->ConfigAccess != NULL) && (Selection != NULL) &&
- ((Question->QuestionFlags & EFI_IFR_FLAG_CALLBACK) == EFI_IFR_FLAG_CALLBACK)) {
+ ((Question->QuestionFlags & EFI_IFR_FLAG_CALLBACK) == EFI_IFR_FLAG_CALLBACK) &&
+ !gFinishRetrieveCall) {
//
// Check QuestionValue does exist.
//
@@ -3651,7 +3682,7 @@ LoadFormConfig (
);
}
- Status = ProcessCallBackFunction(Selection, Question, EFI_BROWSER_ACTION_RETRIEVE, TRUE);
+ Status = ProcessCallBackFunction(Selection, FormSet, Form, Question, EFI_BROWSER_ACTION_RETRIEVE, TRUE);
}
//
@@ -4209,7 +4240,7 @@ LoadStorage (
return;
case EFI_HII_VARSTORE_EFI_VARIABLE_BUFFER:
- if (Storage->BrowserStorage->ReferenceCount > 1) {
+ if (Storage->BrowserStorage->ConfigRequest != NULL) {
ConfigRequestAdjust(Storage);
return;
}
@@ -4311,6 +4342,17 @@ InitializeCurrentSetting (
FORM_BROWSER_FORMSET *OldFormSet;
//
+ // Try to find pre FormSet in the maintain backup list.
+ // If old formset != NULL, destroy this formset. Add new formset to gBrowserFormSetList.
+ //
+ OldFormSet = GetFormSetFromHiiHandle (FormSet->HiiHandle);
+ if (OldFormSet != NULL) {
+ RemoveEntryList (&OldFormSet->Link);
+ DestroyFormSet (OldFormSet);
+ }
+ InsertTailList (&gBrowserFormSetList, &FormSet->Link);
+
+ //
// Extract default from IFR binary for no storage questions.
//
ExtractDefault (FormSet, NULL, EFI_HII_DEFAULT_CLASS_STANDARD, FormSetLevel, GetDefaultForNoStorage, NULL, TRUE);
@@ -4326,17 +4368,6 @@ InitializeCurrentSetting (
Link = GetNextNode (&FormSet->StorageListHead, Link);
}
-
- //
- // Try to find pre FormSet in the maintain backup list.
- // If old formset != NULL, destroy this formset. Add new formset to gBrowserFormSetList.
- //
- OldFormSet = GetFormSetFromHiiHandle (FormSet->HiiHandle);
- if (OldFormSet != NULL) {
- RemoveEntryList (&OldFormSet->Link);
- DestroyFormSet (OldFormSet);
- }
- InsertTailList (&gBrowserFormSetList, &FormSet->Link);
}
diff --git a/MdeModulePkg/Universal/SetupBrowserDxe/Setup.h b/MdeModulePkg/Universal/SetupBrowserDxe/Setup.h
index 99418543d..77a0ad1ba 100644
--- a/MdeModulePkg/Universal/SetupBrowserDxe/Setup.h
+++ b/MdeModulePkg/Universal/SetupBrowserDxe/Setup.h
@@ -151,7 +151,6 @@ typedef struct {
CHAR16 *ConfigRequest; // <ConfigRequest> = <ConfigHdr> + <RequestElement>
// <RequestElement> includes all fields which is used by current form sets.
UINTN SpareStrLen; // Spare length of ConfigRequest string buffer
- UINT8 ReferenceCount; // How many form set storage refrence this storage.
} BROWSER_STORAGE;
#define BROWSER_STORAGE_FROM_LINK(a) CR (a, BROWSER_STORAGE, Link, BROWSER_STORAGE_SIGNATURE)
@@ -542,12 +541,13 @@ extern EDKII_FORM_DISPLAY_ENGINE_PROTOCOL *mFormDisplay;
extern BOOLEAN gResetRequired;
extern BOOLEAN gExitRequired;
-
+extern BOOLEAN gFinishRetrieveCall;
extern LIST_ENTRY gBrowserFormSetList;
extern LIST_ENTRY gBrowserHotKeyList;
extern BROWSER_SETTING_SCOPE gBrowserSettingScope;
extern EXIT_HANDLER ExitHandlerFunction;
extern EFI_HII_HANDLE mCurrentHiiHandle;
+extern SETUP_DRIVER_PRIVATE_DATA mPrivateData;
//
// Browser Global Strings
//
@@ -1157,7 +1157,9 @@ IsStorageDataChangedForFormSet (
about the Selection, form and formset to be displayed.
On output, Selection return the screen item that is selected
by user.
- @param Statement The Question which need to call.
+ @param FormSet The formset this question belong to.
+ @param Form The form this question belong to.
+ @param Question The Question which need to call.
@param Action The action request.
@param SkipSaveOrDiscard Whether skip save or discard action.
@@ -1167,6 +1169,8 @@ IsStorageDataChangedForFormSet (
EFI_STATUS
ProcessCallBackFunction (
IN OUT UI_MENU_SELECTION *Selection,
+ IN FORM_BROWSER_FORMSET *FormSet,
+ IN FORM_BROWSER_FORM *Form,
IN FORM_BROWSER_STATEMENT *Question,
IN EFI_BROWSER_ACTION Action,
IN BOOLEAN SkipSaveOrDiscard
diff --git a/MdeModulePkg/Universal/SmbiosDxe/SmbiosDxe.c b/MdeModulePkg/Universal/SmbiosDxe/SmbiosDxe.c
index 8bf5d443a..157ea8554 100644
--- a/MdeModulePkg/Universal/SmbiosDxe/SmbiosDxe.c
+++ b/MdeModulePkg/Universal/SmbiosDxe/SmbiosDxe.c
@@ -981,7 +981,7 @@ SmbiosCreateTable (
PhysicalAddress = 0xffffffff;
Status = gBS->AllocatePages (
AllocateMaxAddress,
- EfiReservedMemoryType,
+ EfiRuntimeServicesData,
EFI_SIZE_TO_PAGES (EntryPointStructure->TableLength),
&PhysicalAddress
);
@@ -1093,7 +1093,7 @@ SmbiosDriverEntryPoint (
PhysicalAddress = 0xffffffff;
Status = gBS->AllocatePages (
AllocateMaxAddress,
- EfiReservedMemoryType,
+ EfiRuntimeServicesData,
EFI_SIZE_TO_PAGES (sizeof (SMBIOS_TABLE_ENTRY_POINT)),
&PhysicalAddress
);
@@ -1101,7 +1101,7 @@ SmbiosDriverEntryPoint (
DEBUG ((EFI_D_ERROR, "SmbiosDriverEntryPoint() could not allocate EntryPointStructure < 4GB\n"));
Status = gBS->AllocatePages (
AllocateAnyPages,
- EfiReservedMemoryType,
+ EfiRuntimeServicesData,
EFI_SIZE_TO_PAGES (sizeof (SMBIOS_TABLE_ENTRY_POINT)),
&PhysicalAddress
);
@@ -1127,7 +1127,7 @@ SmbiosDriverEntryPoint (
PhysicalAddress = 0xffffffff;
Status = gBS->AllocatePages (
AllocateMaxAddress,
- EfiReservedMemoryType,
+ EfiRuntimeServicesData,
1,
&PhysicalAddress
);
diff --git a/MdeModulePkg/Universal/TimestampDxe/TimestampDxe.c b/MdeModulePkg/Universal/TimestampDxe/TimestampDxe.c
new file mode 100644
index 000000000..30349b5ec
--- /dev/null
+++ b/MdeModulePkg/Universal/TimestampDxe/TimestampDxe.c
@@ -0,0 +1,166 @@
+/** @file
+ Implementation of Timestamp Protocol using UEFI APIs.
+
+Copyright (c) 2013, 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.
+
+**/
+
+#include <Uefi.h>
+#include <Library/DebugLib.h>
+#include <Library/UefiDriverEntryPoint.h>
+#include <Library/UefiBootServicesTableLib.h>
+#include <Library/TimerLib.h>
+#include <Library/BaseMemoryLib.h>
+#include <Protocol/Timestamp.h>
+
+//
+// The StartValue in TimerLib
+//
+UINT64 mTimerLibStartValue = 0;
+
+//
+// The EndValue in TimerLib
+//
+UINT64 mTimerLibEndValue = 0;
+
+//
+// The properties of timestamp
+//
+EFI_TIMESTAMP_PROPERTIES mTimestampProperties = {
+ 0,
+ 0
+};
+
+/**
+ Retrieves the current value of a 64-bit free running timestamp counter.
+
+ The counter shall count up in proportion to the amount of time that has passed. The counter value
+ will always roll over to zero. The properties of the counter can be retrieved from GetProperties().
+ The caller should be prepared for the function to return the same value twice across successive calls.
+ The counter value will not go backwards other than when wrapping, as defined by EndValue in GetProperties().
+ The frequency of the returned timestamp counter value must remain constant. Power management operations that
+ affect clocking must not change the returned counter frequency. The quantization of counter value updates may
+ vary as long as the value reflecting time passed remains consistent.
+
+ @retval The current value of the free running timestamp counter.
+
+**/
+UINT64
+EFIAPI
+TimestampDriverGetTimestamp (
+ VOID
+ )
+{
+ //
+ // The timestamp of Timestamp Protocol
+ //
+ UINT64 TimestampValue;
+ TimestampValue = 0;
+
+ //
+ // Get the timestamp
+ //
+ if (mTimerLibStartValue > mTimerLibEndValue) {
+ TimestampValue = mTimerLibStartValue - GetPerformanceCounter();
+ } else {
+ TimestampValue = GetPerformanceCounter() - mTimerLibStartValue;
+ }
+
+ return TimestampValue;
+}
+
+/**
+ Obtains timestamp counter properties including frequency and value limits.
+
+ @param[out] Properties The properties of the timestamp counter.
+
+ @retval EFI_SUCCESS The properties were successfully retrieved.
+ @retval EFI_DEVICE_ERROR An error occurred trying to retrieve the properties of the timestamp
+ counter subsystem. Properties is not pedated.
+ @retval EFI_INVALID_PARAMETER Properties is NULL.
+
+**/
+EFI_STATUS
+EFIAPI
+TimestampDriverGetProperties(
+ OUT EFI_TIMESTAMP_PROPERTIES *Properties
+ )
+{
+ if (Properties == NULL) {
+ return EFI_INVALID_PARAMETER;
+ }
+
+ //
+ // Get timestamp properties
+ //
+ CopyMem((VOID *) Properties, (VOID *) &mTimestampProperties, sizeof (mTimestampProperties));
+
+ return EFI_SUCCESS;
+}
+
+//
+// The Timestamp Protocol instance produced by this driver
+//
+EFI_TIMESTAMP_PROTOCOL mTimestamp = {
+ TimestampDriverGetTimestamp,
+ TimestampDriverGetProperties
+};
+
+/**
+ Entry point of the Timestamp Protocol driver.
+
+ @param ImageHandle The image handle of this driver.
+ @param SystemTable The pointer of EFI_SYSTEM_TABLE.
+
+ @retval EFI_SUCCESS Watchdog Timer Architectural Protocol successfully installed.
+
+**/
+EFI_STATUS
+EFIAPI
+TimestampDriverInitialize (
+ IN EFI_HANDLE ImageHandle,
+ IN EFI_SYSTEM_TABLE *SystemTable
+ )
+{
+ EFI_STATUS Status;
+
+ EFI_HANDLE TimestampHandle;
+ TimestampHandle = NULL;
+
+ //
+ // Get the start value, end value and frequency in Timerlib
+ //
+ mTimestampProperties.Frequency = GetPerformanceCounterProperties(&mTimerLibStartValue, &mTimerLibEndValue);
+
+ //
+ // Set the EndValue
+ //
+ if (mTimerLibEndValue > mTimerLibStartValue) {
+ mTimestampProperties.EndValue = mTimerLibEndValue - mTimerLibStartValue;
+ } else {
+ mTimestampProperties.EndValue = mTimerLibStartValue - mTimerLibEndValue;
+ }
+
+ DEBUG ((EFI_D_INFO, "TimerFrequency:0x%lx, TimerLibStartTime:0x%lx, TimerLibEndtime:0x%lx\n", mTimestampProperties.Frequency, mTimerLibStartValue, mTimerLibEndValue));
+
+ //
+ // Install the Timestamp Protocol onto a new handle
+ //
+ Status = gBS->InstallMultipleProtocolInterfaces (
+ &TimestampHandle,
+ &gEfiTimestampProtocolGuid,
+ &mTimestamp,
+ NULL
+ );
+
+ ASSERT_EFI_ERROR (Status);
+
+ return EFI_SUCCESS;
+}
diff --git a/MdeModulePkg/Universal/TimestampDxe/TimestampDxe.inf b/MdeModulePkg/Universal/TimestampDxe/TimestampDxe.inf
new file mode 100644
index 000000000..95b0a0838
--- /dev/null
+++ b/MdeModulePkg/Universal/TimestampDxe/TimestampDxe.inf
@@ -0,0 +1,49 @@
+## @file
+# Generic Timestamp driver produceing Timestamp Protocol using UEFI APIs.
+#
+# Copyright (c) 2013, 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.
+#
+#
+##
+
+[Defines]
+ INF_VERSION = 0x00010005
+ BASE_NAME = TimestampDxe
+ FILE_GUID = C10194E7-DEB2-4AF4-9EEE-BFFDE4D7D4C7
+ MODULE_TYPE = DXE_DRIVER
+ VERSION_STRING = 1.0
+ ENTRY_POINT = TimestampDriverInitialize
+
+#
+# The following information is for reference only and not required by the build tools.
+#
+# VALID_ARCHITECTURES = IA32 X64 IPF EBC
+#
+
+[Packages]
+ MdePkg/MdePkg.dec
+
+[Sources]
+ TimestampDxe.c
+
+[LibraryClasses]
+ UefiBootServicesTableLib
+ UefiDriverEntryPoint
+ TimerLib
+ BaseMemoryLib
+ DebugLib
+
+[Protocols]
+ gEfiTimestampProtocolGuid ## PRODUCES
+
+[depex]
+ TRUE
+
+
diff --git a/MdePkg/Include/Guid/FirmwareContentsSigned.h b/MdePkg/Include/Guid/FirmwareContentsSigned.h
new file mode 100644
index 000000000..5f9d24705
--- /dev/null
+++ b/MdePkg/Include/Guid/FirmwareContentsSigned.h
@@ -0,0 +1,26 @@
+/** @file
+ GUID is used to define the signed section.
+
+ Copyright (c) 2013, 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.
+
+ @par Revision Reference:
+ GUID introduced in PI Version 1.2.1.
+
+**/
+
+#ifndef __FIRMWARE_CONTENTS_SIGNED_GUID_H__
+#define __FIRMWARE_CONTENTS_SIGNED_GUID_H__
+
+#define EFI_FIRMWARE_CONTENTS_SIGNED_GUID \
+ { 0xf9d89e8, 0x9259, 0x4f76, {0xa5, 0xaf, 0xc, 0x89, 0xe3, 0x40, 0x23, 0xdf } }
+
+extern EFI_GUID gEfiFirmwareContentsSignedGuid;
+
+#endif
diff --git a/MdePkg/Include/Guid/FmpCapsule.h b/MdePkg/Include/Guid/FmpCapsule.h
new file mode 100644
index 000000000..ccc6b101b
--- /dev/null
+++ b/MdePkg/Include/Guid/FmpCapsule.h
@@ -0,0 +1,89 @@
+/** @file
+ Guid & data structure used for Delivering Capsules Containing Updates to Firmware
+ Managment Protocol
+
+ Copyright (c) 2013, 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.
+
+ @par Revision Reference:
+ GUIDs defined in UEFI 2.4 spec.
+
+**/
+
+
+#ifndef _FMP_CAPSULE_GUID_H__
+#define _FMP_CAPSULE_GUID_H__
+
+//
+// This is the GUID of the capsule for Firmware Management Protocol.
+//
+#define EFI_FIRMWARE_MANAGEMENT_CAPSULE_ID_GUID \
+ { \
+ 0x6dcbd5ed, 0xe82d, 0x4c44, {0xbd, 0xa1, 0x71, 0x94, 0x19, 0x9a, 0xd9, 0x2a } \
+ }
+
+#pragma pack(1)
+
+typedef struct {
+ UINT32 Version;
+
+ ///
+ /// The number of drivers included in the capsule and the number of corresponding
+ /// offsets stored in ItemOffsetList array.
+ ///
+ UINT16 EmbeddedDriverCount;
+
+ ///
+ /// The number of payload items included in the capsule and the number of
+ /// corresponding offsets stored in the ItemOffsetList array.
+ ///
+ UINT16 PayloadItemCount;
+
+ ///
+ /// Variable length array of dimension [EmbeddedDriverCount + PayloadItemCount]
+ /// containing offsets of each of the drivers and payload items contained within the capsule
+ ///
+ // UINT64 ItemOffsetList[];
+} EFI_FIRMWARE_MANAGEMENT_CAPSULE_HEADER;
+
+typedef struct {
+ UINT32 Version;
+
+ ///
+ /// Used to identifiy device firmware targeted by this update. This guid is matched by
+ /// system firmware against ImageTypeId field within a EFI_FIRMWARE_IMAGE_DESCRIPTOR
+ ///
+ EFI_GUID UpdateImageTypeId;
+
+ ///
+ /// Passed as ImageIndex in call to EFI_FIRMWARE_MANAGEMENT_PROTOCOL.SetImage()
+ ///
+ UINT8 UpdateImageIndex;
+ UINT8 reserved_bytes[3];
+
+ ///
+ /// Size of the binary update image which immediately follows this structure
+ ///
+ UINT32 UpdateImageSize;
+
+ ///
+ ///Size of the VendorCode bytes which optionally immediately follow binary update image in the capsule
+ ///
+ UINT32 UpdateVendorCodeSize;
+} EFI_FIRMWARE_MANAGEMENT_CAPSULE_IMAGE_HEADER;
+
+#pragma pack()
+
+
+#define EFI_FIRMWARE_MANAGEMENT_CAPSULE_HEADER_INIT_VERSION 0x00000001
+#define EFI_FIRMWARE_MANAGEMENT_CAPSULE_IMAGE_HEADER_INIT_VERSION 0x00000001
+
+extern EFI_GUID gEfiFmpCapsuleGuid;
+
+#endif
diff --git a/MdePkg/Include/Guid/StatusCodeDataTypeId.h b/MdePkg/Include/Guid/StatusCodeDataTypeId.h
index de028e70c..21d6359e6 100644
--- a/MdePkg/Include/Guid/StatusCodeDataTypeId.h
+++ b/MdePkg/Include/Guid/StatusCodeDataTypeId.h
@@ -232,12 +232,12 @@ typedef struct {
/// The requested resources in the format of an ACPI 2.0 resource descriptor. This
/// parameter is not a pointer; it is the complete resource descriptor.
///
- // UINT8 ReqRes[…];
+ // UINT8 ReqRes[];
///
/// The allocated resources in the format of an ACPI 2.0 resource descriptor. This
/// parameter is not a pointer; it is the complete resource descriptor.
///
- // UINT8 AllocRes[…];
+ // UINT8 AllocRes[];
} EFI_RESOURCE_ALLOC_FAILURE_ERROR_DATA;
///
diff --git a/MdePkg/Include/IndustryStandard/TcpaAcpi.h b/MdePkg/Include/IndustryStandard/TcpaAcpi.h
new file mode 100644
index 000000000..f9ac17002
--- /dev/null
+++ b/MdePkg/Include/IndustryStandard/TcpaAcpi.h
@@ -0,0 +1,58 @@
+/** @file
+ TCPA ACPI table definition.
+
+Copyright (c) 2013, 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.
+
+**/
+
+#ifndef _TCPA_ACPI_H_
+#define _TCPA_ACPI_H_
+
+#include <IndustryStandard/Acpi.h>
+
+#pragma pack (1)
+
+typedef struct _EFI_TCG_CLIENT_ACPI_TABLE {
+ EFI_ACPI_DESCRIPTION_HEADER Header;
+ UINT16 PlatformClass;
+ UINT32 Laml;
+ UINT64 Lasa;
+} EFI_TCG_CLIENT_ACPI_TABLE;
+
+typedef struct _EFI_TCG_SERVER_ACPI_TABLE {
+ EFI_ACPI_DESCRIPTION_HEADER Header;
+ UINT16 PlatformClass;
+ UINT16 Reserved0;
+ UINT64 Laml;
+ UINT64 Lasa;
+ UINT16 SpecRev;
+ UINT8 DeviceFlags;
+ UINT8 InterruptFlags;
+ UINT8 Gpe;
+ UINT8 Reserved1[3];
+ UINT32 GlobalSysInt;
+ EFI_ACPI_3_0_GENERIC_ADDRESS_STRUCTURE BaseAddress;
+ UINT32 Reserved2;
+ EFI_ACPI_3_0_GENERIC_ADDRESS_STRUCTURE ConfigAddress;
+ UINT8 PciSegNum;
+ UINT8 PciBusNum;
+ UINT8 PciDevNum;
+ UINT8 PciFuncNum;
+} EFI_TCG_SERVER_ACPI_TABLE;
+
+//
+// TCG Platform Type based on TCG ACPI Specification Version 1.00
+//
+#define TCG_PLATFORM_TYPE_CLIENT 0
+#define TCG_PLATFORM_TYPE_SERVER 1
+
+#pragma pack ()
+
+#endif
diff --git a/MdePkg/Include/IndustryStandard/Tpm20.h b/MdePkg/Include/IndustryStandard/Tpm20.h
new file mode 100644
index 000000000..5074d899d
--- /dev/null
+++ b/MdePkg/Include/IndustryStandard/Tpm20.h
@@ -0,0 +1,1809 @@
+/** @file
+ TPM2.0 Specification data structures
+ (Trusted Platform Module Library Specification, Family "2.0", Level 00, Revision 00.96,
+ @http://www.trustedcomputinggroup.org/resources/tpm_library_specification)
+
+ Check http://trustedcomputinggroup.org for latest specification updates.
+
+Copyright (c) 2013, 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.
+
+**/
+
+
+#ifndef _TPM20_H_
+#define _TPM20_H_
+
+#include <IndustryStandard/Tpm12.h>
+
+#pragma pack (1)
+
+// Annex A Algorithm Constants
+
+// Table 205 - Defines for SHA1 Hash Values
+#define SHA1_DIGEST_SIZE 20
+#define SHA1_BLOCK_SIZE 64
+
+// Table 206 - Defines for SHA256 Hash Values
+#define SHA256_DIGEST_SIZE 32
+#define SHA256_BLOCK_SIZE 64
+
+// Table 207 - Defines for SHA384 Hash Values
+#define SHA384_DIGEST_SIZE 48
+#define SHA384_BLOCK_SIZE 128
+
+// Table 208 - Defines for SHA512 Hash Values
+#define SHA512_DIGEST_SIZE 64
+#define SHA512_BLOCK_SIZE 128
+
+// Table 209 - Defines for SM3_256 Hash Values
+#define SM3_256_DIGEST_SIZE 32
+#define SM3_256_BLOCK_SIZE 64
+
+// Table 210 - Defines for Architectural Limits Values
+#define MAX_SESSION_NUMBER 3
+
+// Annex B Implementation Definitions
+
+// Table 211 - Defines for Logic Values
+#define YES 1
+#define NO 0
+#define SET 1
+#define CLEAR 0
+
+// Table 215 - Defines for RSA Algorithm Constants
+#define MAX_RSA_KEY_BITS 2048
+#define MAX_RSA_KEY_BYTES ((MAX_RSA_KEY_BITS + 7) / 8)
+
+// Table 216 - Defines for ECC Algorithm Constants
+#define MAX_ECC_KEY_BITS 256
+#define MAX_ECC_KEY_BYTES ((MAX_ECC_KEY_BITS + 7) / 8)
+
+// Table 217 - Defines for AES Algorithm Constants
+#define MAX_AES_KEY_BITS 128
+#define MAX_AES_BLOCK_SIZE_BYTES 16
+#define MAX_AES_KEY_BYTES ((MAX_AES_KEY_BITS + 7) / 8)
+
+// Table 218 - Defines for SM4 Algorithm Constants
+#define MAX_SM4_KEY_BITS 128
+#define MAX_SM4_BLOCK_SIZE_BYTES 16
+#define MAX_SM4_KEY_BYTES ((MAX_SM4_KEY_BITS + 7) / 8)
+
+// Table 219 - Defines for Symmetric Algorithm Constants
+#define MAX_SYM_KEY_BITS MAX_AES_KEY_BITS
+#define MAX_SYM_KEY_BYTES MAX_AES_KEY_BYTES
+#define MAX_SYM_BLOCK_SIZE MAX_AES_BLOCK_SIZE_BYTES
+
+// Table 220 - Defines for Implementation Values
+typedef UINT16 BSIZE;
+#define BUFFER_ALIGNMENT 4
+#define IMPLEMENTATION_PCR 24
+#define PLATFORM_PCR 24
+#define DRTM_PCR 17
+#define NUM_LOCALITIES 5
+#define MAX_HANDLE_NUM 3
+#define MAX_ACTIVE_SESSIONS 64
+typedef UINT16 CONTEXT_SLOT;
+typedef UINT64 CONTEXT_COUNTER;
+#define MAX_LOADED_SESSIONS 3
+#define MAX_SESSION_NUM 3
+#define MAX_LOADED_OBJECTS 3
+#define MIN_EVICT_OBJECTS 2
+#define PCR_SELECT_MIN ((PLATFORM_PCR + 7) / 8)
+#define PCR_SELECT_MAX ((IMPLEMENTATION_PCR + 7) / 8)
+#define NUM_POLICY_PCR_GROUP 1
+#define NUM_AUTHVALUE_PCR_GROUP 1
+#define MAX_CONTEXT_SIZE 4000
+#define MAX_DIGEST_BUFFER 1024
+#define MAX_NV_INDEX_SIZE 1024
+#define MAX_CAP_BUFFER 1024
+#define NV_MEMORY_SIZE 16384
+#define NUM_STATIC_PCR 16
+#define MAX_ALG_LIST_SIZE 64
+#define TIMER_PRESCALE 100000
+#define PRIMARY_SEED_SIZE 32
+#define CONTEXT_ENCRYPT_ALG TPM_ALG_AES
+#define CONTEXT_ENCRYPT_KEY_BITS MAX_SYM_KEY_BITS
+#define CONTEXT_ENCRYPT_KEY_BYTES ((CONTEXT_ENCRYPT_KEY_BITS + 7) / 8)
+#define CONTEXT_INTEGRITY_HASH_ALG TPM_ALG_SHA256
+#define CONTEXT_INTEGRITY_HASH_SIZE SHA256_DIGEST_SIZE
+#define PROOF_SIZE CONTEXT_INTEGRITY_HASH_SIZE
+#define NV_CLOCK_UPDATE_INTERVAL 12
+#define NUM_POLICY_PCR 1
+#define MAX_COMMAND_SIZE 4096
+#define MAX_RESPONSE_SIZE 4096
+#define ORDERLY_BITS 8
+#define MAX_ORDERLY_COUNT ((1 << ORDERLY_BITS) - 1)
+#define ALG_ID_FIRST TPM_ALG_FIRST
+#define ALG_ID_LAST TPM_ALG_LAST
+#define MAX_SYM_DATA 128
+#define MAX_RNG_ENTROPY_SIZE 64
+#define RAM_INDEX_SPACE 512
+#define RSA_DEFAULT_PUBLIC_EXPONENT 0x00010001
+#define CRT_FORMAT_RSA YES
+#define PRIVATE_VENDOR_SPECIFIC_BYTES ((MAX_RSA_KEY_BYTES / 2) * ( 3 + CRT_FORMAT_RSA * 2))
+
+// Capability related MAX_ value
+#define MAX_CAP_DATA (MAX_CAP_BUFFER - sizeof(TPM_CAP) - sizeof(UINT32))
+#define MAX_CAP_ALGS (MAX_CAP_DATA / sizeof(TPMS_ALG_PROPERTY))
+#define MAX_CAP_HANDLES (MAX_CAP_DATA / sizeof(TPM_HANDLE))
+#define MAX_CAP_CC (MAX_CAP_DATA / sizeof(TPM_CC))
+#define MAX_TPM_PROPERTIES (MAX_CAP_DATA / sizeof(TPMS_TAGGED_PROPERTY))
+#define MAX_PCR_PROPERTIES (MAX_CAP_DATA / sizeof(TPMS_TAGGED_PCR_SELECT))
+#define MAX_ECC_CURVES (MAX_CAP_DATA / sizeof(TPM_ECC_CURVE))
+
+//
+// Always set 5 here, because we want to support all hash algo in BIOS.
+//
+#define HASH_COUNT 5
+
+// 5 Base Types
+
+// Table 3 - Definition of Base Types
+typedef UINT8 BYTE;
+typedef UINT8 BOOL;
+
+// Table 4 - Definition of Types for Documentation Clarity
+//
+// NOTE: Comment because it has same name as TPM1.2 (value is same, so not runtime issue)
+//
+//typedef UINT32 TPM_ALGORITHM_ID;
+//typedef UINT32 TPM_MODIFIER_INDICATOR;
+typedef UINT32 TPM_AUTHORIZATION_SIZE;
+typedef UINT32 TPM_PARAMETER_SIZE;
+typedef UINT16 TPM_KEY_SIZE;
+typedef UINT16 TPM_KEY_BITS;
+
+// 6 Constants
+
+// Table 6 - TPM_GENERATED Constants
+typedef UINT32 TPM_GENERATED;
+#define TPM_GENERATED_VALUE (TPM_GENERATED)(0xff544347)
+
+// Table 7 - TPM_ALG_ID Constants
+typedef UINT16 TPM_ALG_ID;
+//
+// NOTE: Comment some algo which has same name as TPM1.2 (value is same, so not runtime issue)
+//
+#define TPM_ALG_ERROR (TPM_ALG_ID)(0x0000)
+#define TPM_ALG_FIRST (TPM_ALG_ID)(0x0001)
+//#define TPM_ALG_RSA (TPM_ALG_ID)(0x0001)
+//#define TPM_ALG_SHA (TPM_ALG_ID)(0x0004)
+#define TPM_ALG_SHA1 (TPM_ALG_ID)(0x0004)
+//#define TPM_ALG_HMAC (TPM_ALG_ID)(0x0005)
+#define TPM_ALG_AES (TPM_ALG_ID)(0x0006)
+//#define TPM_ALG_MGF1 (TPM_ALG_ID)(0x0007)
+#define TPM_ALG_KEYEDHASH (TPM_ALG_ID)(0x0008)
+//#define TPM_ALG_XOR (TPM_ALG_ID)(0x000A)
+#define TPM_ALG_SHA256 (TPM_ALG_ID)(0x000B)
+#define TPM_ALG_SHA384 (TPM_ALG_ID)(0x000C)
+#define TPM_ALG_SHA512 (TPM_ALG_ID)(0x000D)
+#define TPM_ALG_NULL (TPM_ALG_ID)(0x0010)
+#define TPM_ALG_SM3_256 (TPM_ALG_ID)(0x0012)
+#define TPM_ALG_SM4 (TPM_ALG_ID)(0x0013)
+#define TPM_ALG_RSASSA (TPM_ALG_ID)(0x0014)
+#define TPM_ALG_RSAES (TPM_ALG_ID)(0x0015)
+#define TPM_ALG_RSAPSS (TPM_ALG_ID)(0x0016)
+#define TPM_ALG_OAEP (TPM_ALG_ID)(0x0017)
+#define TPM_ALG_ECDSA (TPM_ALG_ID)(0x0018)
+#define TPM_ALG_ECDH (TPM_ALG_ID)(0x0019)
+#define TPM_ALG_ECDAA (TPM_ALG_ID)(0x001A)
+#define TPM_ALG_SM2 (TPM_ALG_ID)(0x001B)
+#define TPM_ALG_ECSCHNORR (TPM_ALG_ID)(0x001C)
+#define TPM_ALG_ECMQV (TPM_ALG_ID)(0x001D)
+#define TPM_ALG_KDF1_SP800_56a (TPM_ALG_ID)(0x0020)
+#define TPM_ALG_KDF2 (TPM_ALG_ID)(0x0021)
+#define TPM_ALG_KDF1_SP800_108 (TPM_ALG_ID)(0x0022)
+#define TPM_ALG_ECC (TPM_ALG_ID)(0x0023)
+#define TPM_ALG_SYMCIPHER (TPM_ALG_ID)(0x0025)
+#define TPM_ALG_CTR (TPM_ALG_ID)(0x0040)
+#define TPM_ALG_OFB (TPM_ALG_ID)(0x0041)
+#define TPM_ALG_CBC (TPM_ALG_ID)(0x0042)
+#define TPM_ALG_CFB (TPM_ALG_ID)(0x0043)
+#define TPM_ALG_ECB (TPM_ALG_ID)(0x0044)
+#define TPM_ALG_LAST (TPM_ALG_ID)(0x0044)
+
+// Table 8 - TPM_ECC_CURVE Constants
+typedef UINT16 TPM_ECC_CURVE;
+#define TPM_ECC_NONE (TPM_ECC_CURVE)(0x0000)
+#define TPM_ECC_NIST_P192 (TPM_ECC_CURVE)(0x0001)
+#define TPM_ECC_NIST_P224 (TPM_ECC_CURVE)(0x0002)
+#define TPM_ECC_NIST_P256 (TPM_ECC_CURVE)(0x0003)
+#define TPM_ECC_NIST_P384 (TPM_ECC_CURVE)(0x0004)
+#define TPM_ECC_NIST_P521 (TPM_ECC_CURVE)(0x0005)
+#define TPM_ECC_BN_P256 (TPM_ECC_CURVE)(0x0010)
+#define TPM_ECC_BN_P638 (TPM_ECC_CURVE)(0x0011)
+#define TPM_ECC_SM2_P256 (TPM_ECC_CURVE)(0x0020)
+
+// Table 11 - TPM_CC Constants (Numeric Order)
+typedef UINT32 TPM_CC;
+#define TPM_CC_FIRST (TPM_CC)(0x0000011F)
+#define TPM_CC_PP_FIRST (TPM_CC)(0x0000011F)
+#define TPM_CC_NV_UndefineSpaceSpecial (TPM_CC)(0x0000011F)
+#define TPM_CC_EvictControl (TPM_CC)(0x00000120)
+#define TPM_CC_HierarchyControl (TPM_CC)(0x00000121)
+#define TPM_CC_NV_UndefineSpace (TPM_CC)(0x00000122)
+#define TPM_CC_ChangeEPS (TPM_CC)(0x00000124)
+#define TPM_CC_ChangePPS (TPM_CC)(0x00000125)
+#define TPM_CC_Clear (TPM_CC)(0x00000126)
+#define TPM_CC_ClearControl (TPM_CC)(0x00000127)
+#define TPM_CC_ClockSet (TPM_CC)(0x00000128)
+#define TPM_CC_HierarchyChangeAuth (TPM_CC)(0x00000129)
+#define TPM_CC_NV_DefineSpace (TPM_CC)(0x0000012A)
+#define TPM_CC_PCR_Allocate (TPM_CC)(0x0000012B)
+#define TPM_CC_PCR_SetAuthPolicy (TPM_CC)(0x0000012C)
+#define TPM_CC_PP_Commands (TPM_CC)(0x0000012D)
+#define TPM_CC_SetPrimaryPolicy (TPM_CC)(0x0000012E)
+#define TPM_CC_FieldUpgradeStart (TPM_CC)(0x0000012F)
+#define TPM_CC_ClockRateAdjust (TPM_CC)(0x00000130)
+#define TPM_CC_CreatePrimary (TPM_CC)(0x00000131)
+#define TPM_CC_NV_GlobalWriteLock (TPM_CC)(0x00000132)
+#define TPM_CC_PP_LAST (TPM_CC)(0x00000132)
+#define TPM_CC_GetCommandAuditDigest (TPM_CC)(0x00000133)
+#define TPM_CC_NV_Increment (TPM_CC)(0x00000134)
+#define TPM_CC_NV_SetBits (TPM_CC)(0x00000135)
+#define TPM_CC_NV_Extend (TPM_CC)(0x00000136)
+#define TPM_CC_NV_Write (TPM_CC)(0x00000137)
+#define TPM_CC_NV_WriteLock (TPM_CC)(0x00000138)
+#define TPM_CC_DictionaryAttackLockReset (TPM_CC)(0x00000139)
+#define TPM_CC_DictionaryAttackParameters (TPM_CC)(0x0000013A)
+#define TPM_CC_NV_ChangeAuth (TPM_CC)(0x0000013B)
+#define TPM_CC_PCR_Event (TPM_CC)(0x0000013C)
+#define TPM_CC_PCR_Reset (TPM_CC)(0x0000013D)
+#define TPM_CC_SequenceComplete (TPM_CC)(0x0000013E)
+#define TPM_CC_SetAlgorithmSet (TPM_CC)(0x0000013F)
+#define TPM_CC_SetCommandCodeAuditStatus (TPM_CC)(0x00000140)
+#define TPM_CC_FieldUpgradeData (TPM_CC)(0x00000141)
+#define TPM_CC_IncrementalSelfTest (TPM_CC)(0x00000142)
+#define TPM_CC_SelfTest (TPM_CC)(0x00000143)
+#define TPM_CC_Startup (TPM_CC)(0x00000144)
+#define TPM_CC_Shutdown (TPM_CC)(0x00000145)
+#define TPM_CC_StirRandom (TPM_CC)(0x00000146)
+#define TPM_CC_ActivateCredential (TPM_CC)(0x00000147)
+#define TPM_CC_Certify (TPM_CC)(0x00000148)
+#define TPM_CC_PolicyNV (TPM_CC)(0x00000149)
+#define TPM_CC_CertifyCreation (TPM_CC)(0x0000014A)
+#define TPM_CC_Duplicate (TPM_CC)(0x0000014B)
+#define TPM_CC_GetTime (TPM_CC)(0x0000014C)
+#define TPM_CC_GetSessionAuditDigest (TPM_CC)(0x0000014D)
+#define TPM_CC_NV_Read (TPM_CC)(0x0000014E)
+#define TPM_CC_NV_ReadLock (TPM_CC)(0x0000014F)
+#define TPM_CC_ObjectChangeAuth (TPM_CC)(0x00000150)
+#define TPM_CC_PolicySecret (TPM_CC)(0x00000151)
+#define TPM_CC_Rewrap (TPM_CC)(0x00000152)
+#define TPM_CC_Create (TPM_CC)(0x00000153)
+#define TPM_CC_ECDH_ZGen (TPM_CC)(0x00000154)
+#define TPM_CC_HMAC (TPM_CC)(0x00000155)
+#define TPM_CC_Import (TPM_CC)(0x00000156)
+#define TPM_CC_Load (TPM_CC)(0x00000157)
+#define TPM_CC_Quote (TPM_CC)(0x00000158)
+#define TPM_CC_RSA_Decrypt (TPM_CC)(0x00000159)
+#define TPM_CC_HMAC_Start (TPM_CC)(0x0000015B)
+#define TPM_CC_SequenceUpdate (TPM_CC)(0x0000015C)
+#define TPM_CC_Sign (TPM_CC)(0x0000015D)
+#define TPM_CC_Unseal (TPM_CC)(0x0000015E)
+#define TPM_CC_PolicySigned (TPM_CC)(0x00000160)
+#define TPM_CC_ContextLoad (TPM_CC)(0x00000161)
+#define TPM_CC_ContextSave (TPM_CC)(0x00000162)
+#define TPM_CC_ECDH_KeyGen (TPM_CC)(0x00000163)
+#define TPM_CC_EncryptDecrypt (TPM_CC)(0x00000164)
+#define TPM_CC_FlushContext (TPM_CC)(0x00000165)
+#define TPM_CC_LoadExternal (TPM_CC)(0x00000167)
+#define TPM_CC_MakeCredential (TPM_CC)(0x00000168)
+#define TPM_CC_NV_ReadPublic (TPM_CC)(0x00000169)
+#define TPM_CC_PolicyAuthorize (TPM_CC)(0x0000016A)
+#define TPM_CC_PolicyAuthValue (TPM_CC)(0x0000016B)
+#define TPM_CC_PolicyCommandCode (TPM_CC)(0x0000016C)
+#define TPM_CC_PolicyCounterTimer (TPM_CC)(0x0000016D)
+#define TPM_CC_PolicyCpHash (TPM_CC)(0x0000016E)
+#define TPM_CC_PolicyLocality (TPM_CC)(0x0000016F)
+#define TPM_CC_PolicyNameHash (TPM_CC)(0x00000170)
+#define TPM_CC_PolicyOR (TPM_CC)(0x00000171)
+#define TPM_CC_PolicyTicket (TPM_CC)(0x00000172)
+#define TPM_CC_ReadPublic (TPM_CC)(0x00000173)
+#define TPM_CC_RSA_Encrypt (TPM_CC)(0x00000174)
+#define TPM_CC_StartAuthSession (TPM_CC)(0x00000176)
+#define TPM_CC_VerifySignature (TPM_CC)(0x00000177)
+#define TPM_CC_ECC_Parameters (TPM_CC)(0x00000178)
+#define TPM_CC_FirmwareRead (TPM_CC)(0x00000179)
+#define TPM_CC_GetCapability (TPM_CC)(0x0000017A)
+#define TPM_CC_GetRandom (TPM_CC)(0x0000017B)
+#define TPM_CC_GetTestResult (TPM_CC)(0x0000017C)
+#define TPM_CC_Hash (TPM_CC)(0x0000017D)
+#define TPM_CC_PCR_Read (TPM_CC)(0x0000017E)
+#define TPM_CC_PolicyPCR (TPM_CC)(0x0000017F)
+#define TPM_CC_PolicyRestart (TPM_CC)(0x00000180)
+#define TPM_CC_ReadClock (TPM_CC)(0x00000181)
+#define TPM_CC_PCR_Extend (TPM_CC)(0x00000182)
+#define TPM_CC_PCR_SetAuthValue (TPM_CC)(0x00000183)
+#define TPM_CC_NV_Certify (TPM_CC)(0x00000184)
+#define TPM_CC_EventSequenceComplete (TPM_CC)(0x00000185)
+#define TPM_CC_HashSequenceStart (TPM_CC)(0x00000186)
+#define TPM_CC_PolicyPhysicalPresence (TPM_CC)(0x00000187)
+#define TPM_CC_PolicyDuplicationSelect (TPM_CC)(0x00000188)
+#define TPM_CC_PolicyGetDigest (TPM_CC)(0x00000189)
+#define TPM_CC_TestParms (TPM_CC)(0x0000018A)
+#define TPM_CC_Commit (TPM_CC)(0x0000018B)
+#define TPM_CC_PolicyPassword (TPM_CC)(0x0000018C)
+#define TPM_CC_ZGen_2Phase (TPM_CC)(0x0000018D)
+#define TPM_CC_EC_Ephemeral (TPM_CC)(0x0000018E)
+#define TPM_CC_LAST (TPM_CC)(0x0000018E)
+
+// Table 15 - TPM_RC Constants (Actions)
+typedef UINT32 TPM_RC;
+#define TPM_RC_SUCCESS (TPM_RC)(0x000)
+#define TPM_RC_BAD_TAG (TPM_RC)(0x030)
+#define RC_VER1 (TPM_RC)(0x100)
+#define TPM_RC_INITIALIZE (TPM_RC)(RC_VER1 + 0x000)
+#define TPM_RC_FAILURE (TPM_RC)(RC_VER1 + 0x001)
+#define TPM_RC_SEQUENCE (TPM_RC)(RC_VER1 + 0x003)
+#define TPM_RC_PRIVATE (TPM_RC)(RC_VER1 + 0x00B)
+#define TPM_RC_HMAC (TPM_RC)(RC_VER1 + 0x019)
+#define TPM_RC_DISABLED (TPM_RC)(RC_VER1 + 0x020)
+#define TPM_RC_EXCLUSIVE (TPM_RC)(RC_VER1 + 0x021)
+#define TPM_RC_AUTH_TYPE (TPM_RC)(RC_VER1 + 0x024)
+#define TPM_RC_AUTH_MISSING (TPM_RC)(RC_VER1 + 0x025)
+#define TPM_RC_POLICY (TPM_RC)(RC_VER1 + 0x026)
+#define TPM_RC_PCR (TPM_RC)(RC_VER1 + 0x027)
+#define TPM_RC_PCR_CHANGED (TPM_RC)(RC_VER1 + 0x028)
+#define TPM_RC_UPGRADE (TPM_RC)(RC_VER1 + 0x02D)
+#define TPM_RC_TOO_MANY_CONTEXTS (TPM_RC)(RC_VER1 + 0x02E)
+#define TPM_RC_AUTH_UNAVAILABLE (TPM_RC)(RC_VER1 + 0x02F)
+#define TPM_RC_REBOOT (TPM_RC)(RC_VER1 + 0x030)
+#define TPM_RC_UNBALANCED (TPM_RC)(RC_VER1 + 0x031)
+#define TPM_RC_COMMAND_SIZE (TPM_RC)(RC_VER1 + 0x042)
+#define TPM_RC_COMMAND_CODE (TPM_RC)(RC_VER1 + 0x043)
+#define TPM_RC_AUTHSIZE (TPM_RC)(RC_VER1 + 0x044)
+#define TPM_RC_AUTH_CONTEXT (TPM_RC)(RC_VER1 + 0x045)
+#define TPM_RC_NV_RANGE (TPM_RC)(RC_VER1 + 0x046)
+#define TPM_RC_NV_SIZE (TPM_RC)(RC_VER1 + 0x047)
+#define TPM_RC_NV_LOCKED (TPM_RC)(RC_VER1 + 0x048)
+#define TPM_RC_NV_AUTHORIZATION (TPM_RC)(RC_VER1 + 0x049)
+#define TPM_RC_NV_UNINITIALIZED (TPM_RC)(RC_VER1 + 0x04A)
+#define TPM_RC_NV_SPACE (TPM_RC)(RC_VER1 + 0x04B)
+#define TPM_RC_NV_DEFINED (TPM_RC)(RC_VER1 + 0x04C)
+#define TPM_RC_BAD_CONTEXT (TPM_RC)(RC_VER1 + 0x050)
+#define TPM_RC_CPHASH (TPM_RC)(RC_VER1 + 0x051)
+#define TPM_RC_PARENT (TPM_RC)(RC_VER1 + 0x052)
+#define TPM_RC_NEEDS_TEST (TPM_RC)(RC_VER1 + 0x053)
+#define TPM_RC_NO_RESULT (TPM_RC)(RC_VER1 + 0x054)
+#define TPM_RC_SENSITIVE (TPM_RC)(RC_VER1 + 0x055)
+#define RC_MAX_FM0 (TPM_RC)(RC_VER1 + 0x07F)
+#define RC_FMT1 (TPM_RC)(0x080)
+#define TPM_RC_ASYMMETRIC (TPM_RC)(RC_FMT1 + 0x001)
+#define TPM_RC_ATTRIBUTES (TPM_RC)(RC_FMT1 + 0x002)
+#define TPM_RC_HASH (TPM_RC)(RC_FMT1 + 0x003)
+#define TPM_RC_VALUE (TPM_RC)(RC_FMT1 + 0x004)
+#define TPM_RC_HIERARCHY (TPM_RC)(RC_FMT1 + 0x005)
+#define TPM_RC_KEY_SIZE (TPM_RC)(RC_FMT1 + 0x007)
+#define TPM_RC_MGF (TPM_RC)(RC_FMT1 + 0x008)
+#define TPM_RC_MODE (TPM_RC)(RC_FMT1 + 0x009)
+#define TPM_RC_TYPE (TPM_RC)(RC_FMT1 + 0x00A)
+#define TPM_RC_HANDLE (TPM_RC)(RC_FMT1 + 0x00B)
+#define TPM_RC_KDF (TPM_RC)(RC_FMT1 + 0x00C)
+#define TPM_RC_RANGE (TPM_RC)(RC_FMT1 + 0x00D)
+#define TPM_RC_AUTH_FAIL (TPM_RC)(RC_FMT1 + 0x00E)
+#define TPM_RC_NONCE (TPM_RC)(RC_FMT1 + 0x00F)
+#define TPM_RC_PP (TPM_RC)(RC_FMT1 + 0x010)
+#define TPM_RC_SCHEME (TPM_RC)(RC_FMT1 + 0x012)
+#define TPM_RC_SIZE (TPM_RC)(RC_FMT1 + 0x015)
+#define TPM_RC_SYMMETRIC (TPM_RC)(RC_FMT1 + 0x016)
+#define TPM_RC_TAG (TPM_RC)(RC_FMT1 + 0x017)
+#define TPM_RC_SELECTOR (TPM_RC)(RC_FMT1 + 0x018)
+#define TPM_RC_INSUFFICIENT (TPM_RC)(RC_FMT1 + 0x01A)
+#define TPM_RC_SIGNATURE (TPM_RC)(RC_FMT1 + 0x01B)
+#define TPM_RC_KEY (TPM_RC)(RC_FMT1 + 0x01C)
+#define TPM_RC_POLICY_FAIL (TPM_RC)(RC_FMT1 + 0x01D)
+#define TPM_RC_INTEGRITY (TPM_RC)(RC_FMT1 + 0x01F)
+#define TPM_RC_TICKET (TPM_RC)(RC_FMT1 + 0x020)
+#define TPM_RC_RESERVED_BITS (TPM_RC)(RC_FMT1 + 0x021)
+#define TPM_RC_BAD_AUTH (TPM_RC)(RC_FMT1 + 0x022)
+#define TPM_RC_EXPIRED (TPM_RC)(RC_FMT1 + 0x023)
+#define TPM_RC_POLICY_CC (TPM_RC)(RC_FMT1 + 0x024 )
+#define TPM_RC_BINDING (TPM_RC)(RC_FMT1 + 0x025)
+#define TPM_RC_CURVE (TPM_RC)(RC_FMT1 + 0x026)
+#define TPM_RC_ECC_POINT (TPM_RC)(RC_FMT1 + 0x027)
+#define RC_WARN (TPM_RC)(0x900)
+#define TPM_RC_CONTEXT_GAP (TPM_RC)(RC_WARN + 0x001)
+#define TPM_RC_OBJECT_MEMORY (TPM_RC)(RC_WARN + 0x002)
+#define TPM_RC_SESSION_MEMORY (TPM_RC)(RC_WARN + 0x003)
+#define TPM_RC_MEMORY (TPM_RC)(RC_WARN + 0x004)
+#define TPM_RC_SESSION_HANDLES (TPM_RC)(RC_WARN + 0x005)
+#define TPM_RC_OBJECT_HANDLES (TPM_RC)(RC_WARN + 0x006)
+#define TPM_RC_LOCALITY (TPM_RC)(RC_WARN + 0x007)
+#define TPM_RC_YIELDED (TPM_RC)(RC_WARN + 0x008)
+#define TPM_RC_CANCELED (TPM_RC)(RC_WARN + 0x009)
+#define TPM_RC_TESTING (TPM_RC)(RC_WARN + 0x00A)
+#define TPM_RC_REFERENCE_H0 (TPM_RC)(RC_WARN + 0x010)
+#define TPM_RC_REFERENCE_H1 (TPM_RC)(RC_WARN + 0x011)
+#define TPM_RC_REFERENCE_H2 (TPM_RC)(RC_WARN + 0x012)
+#define TPM_RC_REFERENCE_H3 (TPM_RC)(RC_WARN + 0x013)
+#define TPM_RC_REFERENCE_H4 (TPM_RC)(RC_WARN + 0x014)
+#define TPM_RC_REFERENCE_H5 (TPM_RC)(RC_WARN + 0x015)
+#define TPM_RC_REFERENCE_H6 (TPM_RC)(RC_WARN + 0x016)
+#define TPM_RC_REFERENCE_S0 (TPM_RC)(RC_WARN + 0x018)
+#define TPM_RC_REFERENCE_S1 (TPM_RC)(RC_WARN + 0x019)
+#define TPM_RC_REFERENCE_S2 (TPM_RC)(RC_WARN + 0x01A)
+#define TPM_RC_REFERENCE_S3 (TPM_RC)(RC_WARN + 0x01B)
+#define TPM_RC_REFERENCE_S4 (TPM_RC)(RC_WARN + 0x01C)
+#define TPM_RC_REFERENCE_S5 (TPM_RC)(RC_WARN + 0x01D)
+#define TPM_RC_REFERENCE_S6 (TPM_RC)(RC_WARN + 0x01E)
+#define TPM_RC_NV_RATE (TPM_RC)(RC_WARN + 0x020)
+#define TPM_RC_LOCKOUT (TPM_RC)(RC_WARN + 0x021)
+#define TPM_RC_RETRY (TPM_RC)(RC_WARN + 0x022)
+#define TPM_RC_NV_UNAVAILABLE (TPM_RC)(RC_WARN + 0x023)
+#define TPM_RC_NOT_USED (TPM_RC)(RC_WARN + 0x7F)
+#define TPM_RC_H (TPM_RC)(0x000)
+#define TPM_RC_P (TPM_RC)(0x040)
+#define TPM_RC_S (TPM_RC)(0x800)
+#define TPM_RC_1 (TPM_RC)(0x100)
+#define TPM_RC_2 (TPM_RC)(0x200)
+#define TPM_RC_3 (TPM_RC)(0x300)
+#define TPM_RC_4 (TPM_RC)(0x400)
+#define TPM_RC_5 (TPM_RC)(0x500)
+#define TPM_RC_6 (TPM_RC)(0x600)
+#define TPM_RC_7 (TPM_RC)(0x700)
+#define TPM_RC_8 (TPM_RC)(0x800)
+#define TPM_RC_9 (TPM_RC)(0x900)
+#define TPM_RC_A (TPM_RC)(0xA00)
+#define TPM_RC_B (TPM_RC)(0xB00)
+#define TPM_RC_C (TPM_RC)(0xC00)
+#define TPM_RC_D (TPM_RC)(0xD00)
+#define TPM_RC_E (TPM_RC)(0xE00)
+#define TPM_RC_F (TPM_RC)(0xF00)
+#define TPM_RC_N_MASK (TPM_RC)(0xF00)
+
+// Table 16 - TPM_CLOCK_ADJUST Constants
+typedef INT8 TPM_CLOCK_ADJUST;
+#define TPM_CLOCK_COARSE_SLOWER (TPM_CLOCK_ADJUST)(-3)
+#define TPM_CLOCK_MEDIUM_SLOWER (TPM_CLOCK_ADJUST)(-2)
+#define TPM_CLOCK_FINE_SLOWER (TPM_CLOCK_ADJUST)(-1)
+#define TPM_CLOCK_NO_CHANGE (TPM_CLOCK_ADJUST)(0)
+#define TPM_CLOCK_FINE_FASTER (TPM_CLOCK_ADJUST)(1)
+#define TPM_CLOCK_MEDIUM_FASTER (TPM_CLOCK_ADJUST)(2)
+#define TPM_CLOCK_COARSE_FASTER (TPM_CLOCK_ADJUST)(3)
+
+// Table 17 - TPM_EO Constants
+typedef UINT16 TPM_EO;
+#define TPM_EO_EQ (TPM_EO)(0x0000)
+#define TPM_EO_NEQ (TPM_EO)(0x0001)
+#define TPM_EO_SIGNED_GT (TPM_EO)(0x0002)
+#define TPM_EO_UNSIGNED_GT (TPM_EO)(0x0003)
+#define TPM_EO_SIGNED_LT (TPM_EO)(0x0004)
+#define TPM_EO_UNSIGNED_LT (TPM_EO)(0x0005)
+#define TPM_EO_SIGNED_GE (TPM_EO)(0x0006)
+#define TPM_EO_UNSIGNED_GE (TPM_EO)(0x0007)
+#define TPM_EO_SIGNED_LE (TPM_EO)(0x0008)
+#define TPM_EO_UNSIGNED_LE (TPM_EO)(0x0009)
+#define TPM_EO_BITSET (TPM_EO)(0x000A)
+#define TPM_EO_BITCLEAR (TPM_EO)(0x000B)
+
+// Table 18 - TPM_ST Constants
+typedef UINT16 TPM_ST;
+#define TPM_ST_RSP_COMMAND (TPM_ST)(0x00C4)
+#define TPM_ST_NULL (TPM_ST)(0X8000)
+#define TPM_ST_NO_SESSIONS (TPM_ST)(0x8001)
+#define TPM_ST_SESSIONS (TPM_ST)(0x8002)
+#define TPM_ST_ATTEST_NV (TPM_ST)(0x8014)
+#define TPM_ST_ATTEST_COMMAND_AUDIT (TPM_ST)(0x8015)
+#define TPM_ST_ATTEST_SESSION_AUDIT (TPM_ST)(0x8016)
+#define TPM_ST_ATTEST_CERTIFY (TPM_ST)(0x8017)
+#define TPM_ST_ATTEST_QUOTE (TPM_ST)(0x8018)
+#define TPM_ST_ATTEST_TIME (TPM_ST)(0x8019)
+#define TPM_ST_ATTEST_CREATION (TPM_ST)(0x801A)
+#define TPM_ST_CREATION (TPM_ST)(0x8021)
+#define TPM_ST_VERIFIED (TPM_ST)(0x8022)
+#define TPM_ST_AUTH_SECRET (TPM_ST)(0x8023)
+#define TPM_ST_HASHCHECK (TPM_ST)(0x8024)
+#define TPM_ST_AUTH_SIGNED (TPM_ST)(0x8025)
+#define TPM_ST_FU_MANIFEST (TPM_ST)(0x8029)
+
+// Table 19 - TPM_SU Constants
+typedef UINT16 TPM_SU;
+#define TPM_SU_CLEAR (TPM_SU)(0x0000)
+#define TPM_SU_STATE (TPM_SU)(0x0001)
+
+// Table 20 - TPM_SE Constants
+typedef UINT8 TPM_SE;
+#define TPM_SE_HMAC (TPM_SE)(0x00)
+#define TPM_SE_POLICY (TPM_SE)(0x01)
+#define TPM_SE_TRIAL (TPM_SE)(0x03)
+
+// Table 21 - TPM_CAP Constants
+typedef UINT32 TPM_CAP;
+#define TPM_CAP_FIRST (TPM_CAP)(0x00000000)
+#define TPM_CAP_ALGS (TPM_CAP)(0x00000000)
+#define TPM_CAP_HANDLES (TPM_CAP)(0x00000001)
+#define TPM_CAP_COMMANDS (TPM_CAP)(0x00000002)
+#define TPM_CAP_PP_COMMANDS (TPM_CAP)(0x00000003)
+#define TPM_CAP_AUDIT_COMMANDS (TPM_CAP)(0x00000004)
+#define TPM_CAP_PCRS (TPM_CAP)(0x00000005)
+#define TPM_CAP_TPM_PROPERTIES (TPM_CAP)(0x00000006)
+#define TPM_CAP_PCR_PROPERTIES (TPM_CAP)(0x00000007)
+#define TPM_CAP_ECC_CURVES (TPM_CAP)(0x00000008)
+#define TPM_CAP_LAST (TPM_CAP)(0x00000008)
+#define TPM_CAP_VENDOR_PROPERTY (TPM_CAP)(0x00000100)
+
+// Table 22 - TPM_PT Constants
+typedef UINT32 TPM_PT;
+#define TPM_PT_NONE (TPM_PT)(0x00000000)
+#define PT_GROUP (TPM_PT)(0x00000100)
+#define PT_FIXED (TPM_PT)(PT_GROUP * 1)
+#define TPM_PT_FAMILY_INDICATOR (TPM_PT)(PT_FIXED + 0)
+#define TPM_PT_LEVEL (TPM_PT)(PT_FIXED + 1)
+#define TPM_PT_REVISION (TPM_PT)(PT_FIXED + 2)
+#define TPM_PT_DAY_OF_YEAR (TPM_PT)(PT_FIXED + 3)
+#define TPM_PT_YEAR (TPM_PT)(PT_FIXED + 4)
+#define TPM_PT_MANUFACTURER (TPM_PT)(PT_FIXED + 5)
+#define TPM_PT_VENDOR_STRING_1 (TPM_PT)(PT_FIXED + 6)
+#define TPM_PT_VENDOR_STRING_2 (TPM_PT)(PT_FIXED + 7)
+#define TPM_PT_VENDOR_STRING_3 (TPM_PT)(PT_FIXED + 8)
+#define TPM_PT_VENDOR_STRING_4 (TPM_PT)(PT_FIXED + 9)
+#define TPM_PT_VENDOR_TPM_TYPE (TPM_PT)(PT_FIXED + 10)
+#define TPM_PT_FIRMWARE_VERSION_1 (TPM_PT)(PT_FIXED + 11)
+#define TPM_PT_FIRMWARE_VERSION_2 (TPM_PT)(PT_FIXED + 12)
+#define TPM_PT_INPUT_BUFFER (TPM_PT)(PT_FIXED + 13)
+#define TPM_PT_HR_TRANSIENT_MIN (TPM_PT)(PT_FIXED + 14)
+#define TPM_PT_HR_PERSISTENT_MIN (TPM_PT)(PT_FIXED + 15)
+#define TPM_PT_HR_LOADED_MIN (TPM_PT)(PT_FIXED + 16)
+#define TPM_PT_ACTIVE_SESSIONS_MAX (TPM_PT)(PT_FIXED + 17)
+#define TPM_PT_PCR_COUNT (TPM_PT)(PT_FIXED + 18)
+#define TPM_PT_PCR_SELECT_MIN (TPM_PT)(PT_FIXED + 19)
+#define TPM_PT_CONTEXT_GAP_MAX (TPM_PT)(PT_FIXED + 20)
+#define TPM_PT_NV_COUNTERS_MAX (TPM_PT)(PT_FIXED + 22)
+#define TPM_PT_NV_INDEX_MAX (TPM_PT)(PT_FIXED + 23)
+#define TPM_PT_MEMORY (TPM_PT)(PT_FIXED + 24)
+#define TPM_PT_CLOCK_UPDATE (TPM_PT)(PT_FIXED + 25)
+#define TPM_PT_CONTEXT_HASH (TPM_PT)(PT_FIXED + 26)
+#define TPM_PT_CONTEXT_SYM (TPM_PT)(PT_FIXED + 27)
+#define TPM_PT_CONTEXT_SYM_SIZE (TPM_PT)(PT_FIXED + 28)
+#define TPM_PT_ORDERLY_COUNT (TPM_PT)(PT_FIXED + 29)
+#define TPM_PT_MAX_COMMAND_SIZE (TPM_PT)(PT_FIXED + 30)
+#define TPM_PT_MAX_RESPONSE_SIZE (TPM_PT)(PT_FIXED + 31)
+#define TPM_PT_MAX_DIGEST (TPM_PT)(PT_FIXED + 32)
+#define TPM_PT_MAX_OBJECT_CONTEXT (TPM_PT)(PT_FIXED + 33)
+#define TPM_PT_MAX_SESSION_CONTEXT (TPM_PT)(PT_FIXED + 34)
+#define TPM_PT_PS_FAMILY_INDICATOR (TPM_PT)(PT_FIXED + 35)
+#define TPM_PT_PS_LEVEL (TPM_PT)(PT_FIXED + 36)
+#define TPM_PT_PS_REVISION (TPM_PT)(PT_FIXED + 37)
+#define TPM_PT_PS_DAY_OF_YEAR (TPM_PT)(PT_FIXED + 38)
+#define TPM_PT_PS_YEAR (TPM_PT)(PT_FIXED + 39)
+#define TPM_PT_SPLIT_MAX (TPM_PT)(PT_FIXED + 40)
+#define TPM_PT_TOTAL_COMMANDS (TPM_PT)(PT_FIXED + 41)
+#define TPM_PT_LIBRARY_COMMANDS (TPM_PT)(PT_FIXED + 42)
+#define TPM_PT_VENDOR_COMMANDS (TPM_PT)(PT_FIXED + 43)
+#define PT_VAR (TPM_PT)(PT_GROUP * 2)
+#define TPM_PT_PERMANENT (TPM_PT)(PT_VAR + 0)
+#define TPM_PT_STARTUP_CLEAR (TPM_PT)(PT_VAR + 1)
+#define TPM_PT_HR_NV_INDEX (TPM_PT)(PT_VAR + 2)
+#define TPM_PT_HR_LOADED (TPM_PT)(PT_VAR + 3)
+#define TPM_PT_HR_LOADED_AVAIL (TPM_PT)(PT_VAR + 4)
+#define TPM_PT_HR_ACTIVE (TPM_PT)(PT_VAR + 5)
+#define TPM_PT_HR_ACTIVE_AVAIL (TPM_PT)(PT_VAR + 6)
+#define TPM_PT_HR_TRANSIENT_AVAIL (TPM_PT)(PT_VAR + 7)
+#define TPM_PT_HR_PERSISTENT (TPM_PT)(PT_VAR + 8)
+#define TPM_PT_HR_PERSISTENT_AVAIL (TPM_PT)(PT_VAR + 9)
+#define TPM_PT_NV_COUNTERS (TPM_PT)(PT_VAR + 10)
+#define TPM_PT_NV_COUNTERS_AVAIL (TPM_PT)(PT_VAR + 11)
+#define TPM_PT_ALGORITHM_SET (TPM_PT)(PT_VAR + 12)
+#define TPM_PT_LOADED_CURVES (TPM_PT)(PT_VAR + 13)
+#define TPM_PT_LOCKOUT_COUNTER (TPM_PT)(PT_VAR + 14)
+#define TPM_PT_MAX_AUTH_FAIL (TPM_PT)(PT_VAR + 15)
+#define TPM_PT_LOCKOUT_INTERVAL (TPM_PT)(PT_VAR + 16)
+#define TPM_PT_LOCKOUT_RECOVERY (TPM_PT)(PT_VAR + 17)
+#define TPM_PT_NV_WRITE_RECOVERY (TPM_PT)(PT_VAR + 18)
+#define TPM_PT_AUDIT_COUNTER_0 (TPM_PT)(PT_VAR + 19)
+#define TPM_PT_AUDIT_COUNTER_1 (TPM_PT)(PT_VAR + 20)
+
+// Table 23 - TPM_PT_PCR Constants
+typedef UINT32 TPM_PT_PCR;
+#define TPM_PT_PCR_FIRST (TPM_PT_PCR)(0x00000000)
+#define TPM_PT_PCR_SAVE (TPM_PT_PCR)(0x00000000)
+#define TPM_PT_PCR_EXTEND_L0 (TPM_PT_PCR)(0x00000001)
+#define TPM_PT_PCR_RESET_L0 (TPM_PT_PCR)(0x00000002)
+#define TPM_PT_PCR_EXTEND_L1 (TPM_PT_PCR)(0x00000003)
+#define TPM_PT_PCR_RESET_L1 (TPM_PT_PCR)(0x00000004)
+#define TPM_PT_PCR_EXTEND_L2 (TPM_PT_PCR)(0x00000005)
+#define TPM_PT_PCR_RESET_L2 (TPM_PT_PCR)(0x00000006)
+#define TPM_PT_PCR_EXTEND_L3 (TPM_PT_PCR)(0x00000007)
+#define TPM_PT_PCR_RESET_L3 (TPM_PT_PCR)(0x00000008)
+#define TPM_PT_PCR_EXTEND_L4 (TPM_PT_PCR)(0x00000009)
+#define TPM_PT_PCR_RESET_L4 (TPM_PT_PCR)(0x0000000A)
+#define TPM_PT_PCR_NO_INCREMENT (TPM_PT_PCR)(0x00000011)
+#define TPM_PT_PCR_DRTM_RESET (TPM_PT_PCR)(0x00000012)
+#define TPM_PT_PCR_POLICY (TPM_PT_PCR)(0x00000013)
+#define TPM_PT_PCR_AUTH (TPM_PT_PCR)(0x00000014)
+#define TPM_PT_PCR_LAST (TPM_PT_PCR)(0x00000014)
+
+// Table 24 - TPM_PS Constants
+typedef UINT32 TPM_PS;
+#define TPM_PS_MAIN (TPM_PS)(0x00000000)
+#define TPM_PS_PC (TPM_PS)(0x00000001)
+#define TPM_PS_PDA (TPM_PS)(0x00000002)
+#define TPM_PS_CELL_PHONE (TPM_PS)(0x00000003)
+#define TPM_PS_SERVER (TPM_PS)(0x00000004)
+#define TPM_PS_PERIPHERAL (TPM_PS)(0x00000005)
+#define TPM_PS_TSS (TPM_PS)(0x00000006)
+#define TPM_PS_STORAGE (TPM_PS)(0x00000007)
+#define TPM_PS_AUTHENTICATION (TPM_PS)(0x00000008)
+#define TPM_PS_EMBEDDED (TPM_PS)(0x00000009)
+#define TPM_PS_HARDCOPY (TPM_PS)(0x0000000A)
+#define TPM_PS_INFRASTRUCTURE (TPM_PS)(0x0000000B)
+#define TPM_PS_VIRTUALIZATION (TPM_PS)(0x0000000C)
+#define TPM_PS_TNC (TPM_PS)(0x0000000D)
+#define TPM_PS_MULTI_TENANT (TPM_PS)(0x0000000E)
+#define TPM_PS_TC (TPM_PS)(0x0000000F)
+
+// 7 Handles
+
+// Table 25 - Handles Types
+//
+// NOTE: Comment because it has same name as TPM1.2 (value is same, so not runtime issue)
+//
+//typedef UINT32 TPM_HANDLE;
+
+// Table 26 - TPM_HT Constants
+typedef UINT8 TPM_HT;
+#define TPM_HT_PCR (TPM_HT)(0x00)
+#define TPM_HT_NV_INDEX (TPM_HT)(0x01)
+#define TPM_HT_HMAC_SESSION (TPM_HT)(0x02)
+#define TPM_HT_LOADED_SESSION (TPM_HT)(0x02)
+#define TPM_HT_POLICY_SESSION (TPM_HT)(0x03)
+#define TPM_HT_ACTIVE_SESSION (TPM_HT)(0x03)
+#define TPM_HT_PERMANENT (TPM_HT)(0x40)
+#define TPM_HT_TRANSIENT (TPM_HT)(0x80)
+#define TPM_HT_PERSISTENT (TPM_HT)(0x81)
+
+// Table 27 - TPM_RH Constants
+typedef UINT32 TPM_RH;
+#define TPM_RH_FIRST (TPM_RH)(0x40000000)
+#define TPM_RH_SRK (TPM_RH)(0x40000000)
+#define TPM_RH_OWNER (TPM_RH)(0x40000001)
+#define TPM_RH_REVOKE (TPM_RH)(0x40000002)
+#define TPM_RH_TRANSPORT (TPM_RH)(0x40000003)
+#define TPM_RH_OPERATOR (TPM_RH)(0x40000004)
+#define TPM_RH_ADMIN (TPM_RH)(0x40000005)
+#define TPM_RH_EK (TPM_RH)(0x40000006)
+#define TPM_RH_NULL (TPM_RH)(0x40000007)
+#define TPM_RH_UNASSIGNED (TPM_RH)(0x40000008)
+#define TPM_RS_PW (TPM_RH)(0x40000009)
+#define TPM_RH_LOCKOUT (TPM_RH)(0x4000000A)
+#define TPM_RH_ENDORSEMENT (TPM_RH)(0x4000000B)
+#define TPM_RH_PLATFORM (TPM_RH)(0x4000000C)
+#define TPM_RH_LAST (TPM_RH)(0x4000000C)
+
+// Table 28 - TPM_HC Constants
+typedef TPM_HANDLE TPM_HC;
+#define HR_HANDLE_MASK (TPM_HC)(0x00FFFFFF)
+#define HR_RANGE_MASK (TPM_HC)(0xFF000000)
+#define HR_SHIFT (TPM_HC)(24)
+#define HR_PCR (TPM_HC)((TPM_HC)TPM_HT_PCR << HR_SHIFT)
+#define HR_HMAC_SESSION (TPM_HC)((TPM_HC)TPM_HT_HMAC_SESSION << HR_SHIFT)
+#define HR_POLICY_SESSION (TPM_HC)((TPM_HC)TPM_HT_POLICY_SESSION << HR_SHIFT)
+#define HR_TRANSIENT (TPM_HC)((TPM_HC)TPM_HT_TRANSIENT << HR_SHIFT)
+#define HR_PERSISTENT (TPM_HC)((TPM_HC)TPM_HT_PERSISTENT << HR_SHIFT)
+#define HR_NV_INDEX (TPM_HC)((TPM_HC)TPM_HT_NV_INDEX << HR_SHIFT)
+#define HR_PERMANENT (TPM_HC)((TPM_HC)TPM_HT_PERMANENT << HR_SHIFT)
+#define PCR_FIRST (TPM_HC)(HR_PCR + 0)
+#define PCR_LAST (TPM_HC)(PCR_FIRST + IMPLEMENTATION_PCR - 1)
+#define HMAC_SESSION_FIRST (TPM_HC)(HR_HMAC_SESSION + 0)
+#define HMAC_SESSION_LAST (TPM_HC)(HMAC_SESSION_FIRST + MAX_ACTIVE_SESSIONS - 1)
+#define LOADED_SESSION_FIRST (TPM_HC)(HMAC_SESSION_FIRST)
+#define LOADED_SESSION_LAST (TPM_HC)(HMAC_SESSION_LAST)
+#define POLICY_SESSION_FIRST (TPM_HC)(HR_POLICY_SESSION + 0)
+#define POLICY_SESSION_LAST (TPM_HC)(POLICY_SESSION_FIRST + MAX_ACTIVE_SESSIONS - 1)
+#define TRANSIENT_FIRST (TPM_HC)(HR_TRANSIENT + 0)
+#define ACTIVE_SESSION_FIRST (TPM_HC)(POLICY_SESSION_FIRST)
+#define ACTIVE_SESSION_LAST (TPM_HC)(POLICY_SESSION_LAST)
+#define TRANSIENT_LAST (TPM_HC)(TRANSIENT_FIRST+MAX_LOADED_OBJECTS - 1)
+#define PERSISTENT_FIRST (TPM_HC)(HR_PERSISTENT + 0)
+#define PERSISTENT_LAST (TPM_HC)(PERSISTENT_FIRST + 0x00FFFFFF)
+#define PLATFORM_PERSISTENT (TPM_HC)(PERSISTENT_FIRST + 0x00800000)
+#define NV_INDEX_FIRST (TPM_HC)(HR_NV_INDEX + 0)
+#define NV_INDEX_LAST (TPM_HC)(NV_INDEX_FIRST + 0x00FFFFFF)
+#define PERMANENT_FIRST (TPM_HC)(TPM_RH_FIRST)
+#define PERMANENT_LAST (TPM_HC)(TPM_RH_LAST)
+
+// 8 Attribute Structures
+
+// Table 29 - TPMA_ALGORITHM Bits
+typedef struct {
+ UINT32 asymmetric : 1;
+ UINT32 symmetric : 1;
+ UINT32 hash : 1;
+ UINT32 object : 1;
+ UINT32 reserved4_7 : 4;
+ UINT32 signing : 1;
+ UINT32 encrypting : 1;
+ UINT32 method : 1;
+ UINT32 reserved11_31 : 21;
+} TPMA_ALGORITHM;
+
+// Table 30 - TPMA_OBJECT Bits
+typedef struct {
+ UINT32 reserved1 : 1;
+ UINT32 fixedTPM : 1;
+ UINT32 stClear : 1;
+ UINT32 reserved4 : 1;
+ UINT32 fixedParent : 1;
+ UINT32 sensitiveDataOrigin : 1;
+ UINT32 userWithAuth : 1;
+ UINT32 adminWithPolicy : 1;
+ UINT32 reserved8_9 : 2;
+ UINT32 noDA : 1;
+ UINT32 encryptedDuplication : 1;
+ UINT32 reserved12_15 : 4;
+ UINT32 restricted : 1;
+ UINT32 decrypt : 1;
+ UINT32 sign : 1;
+ UINT32 reserved19_31 : 13;
+} TPMA_OBJECT;
+
+// Table 31 - TPMA_SESSION Bits
+typedef struct {
+ UINT8 continueSession : 1;
+ UINT8 auditExclusive : 1;
+ UINT8 auditReset : 1;
+ UINT8 reserved3_4 : 2;
+ UINT8 decrypt : 1;
+ UINT8 encrypt : 1;
+ UINT8 audit : 1;
+} TPMA_SESSION;
+
+// Table 32 - TPMA_LOCALITY Bits
+//
+// NOTE: Use low case here to resolve conflict
+//
+typedef struct {
+ UINT8 locZero : 1;
+ UINT8 locOne : 1;
+ UINT8 locTwo : 1;
+ UINT8 locThree : 1;
+ UINT8 locFour : 1;
+ UINT8 Extended : 3;
+} TPMA_LOCALITY;
+
+// Table 33 - TPMA_PERMANENT Bits
+typedef struct {
+ UINT32 ownerAuthSet : 1;
+ UINT32 endorsementAuthSet : 1;
+ UINT32 lockoutAuthSet : 1;
+ UINT32 reserved3_7 : 5;
+ UINT32 disableClear : 1;
+ UINT32 inLockout : 1;
+ UINT32 tpmGeneratedEPS : 1;
+ UINT32 reserved11_31 : 21;
+} TPMA_PERMANENT;
+
+// Table 34 - TPMA_STARTUP_CLEAR Bits
+typedef struct {
+ UINT32 phEnable : 1;
+ UINT32 shEnable : 1;
+ UINT32 ehEnable : 1;
+ UINT32 reserved3_30 : 28;
+ UINT32 orderly : 1;
+} TPMA_STARTUP_CLEAR;
+
+// Table 35 - TPMA_MEMORY Bits
+typedef struct {
+ UINT32 sharedRAM : 1;
+ UINT32 sharedNV : 1;
+ UINT32 objectCopiedToRam : 1;
+ UINT32 reserved3_31 : 29;
+} TPMA_MEMORY;
+
+// Table 36 - TPMA_CC Bits
+typedef struct {
+ UINT32 commandIndex : 16;
+ UINT32 reserved16_21 : 6;
+ UINT32 nv : 1;
+ UINT32 extensive : 1;
+ UINT32 flushed : 1;
+ UINT32 cHandles : 3;
+ UINT32 rHandle : 1;
+ UINT32 V : 1;
+ UINT32 Res : 2;
+} TPMA_CC;
+
+// 9 Interface Types
+
+// Table 37 - TPMI_YES_NO Type
+typedef BYTE TPMI_YES_NO;
+
+// Table 38 - TPMI_DH_OBJECT Type
+typedef TPM_HANDLE TPMI_DH_OBJECT;
+
+// Table 39 - TPMI_DH_PERSISTENT Type
+typedef TPM_HANDLE TPMI_DH_PERSISTENT;
+
+// Table 40 - TPMI_DH_ENTITY Type
+typedef TPM_HANDLE TPMI_DH_ENTITY;
+
+// Table 41 - TPMI_DH_PCR Type
+typedef TPM_HANDLE TPMI_DH_PCR;
+
+// Table 42 - TPMI_SH_AUTH_SESSION Type
+typedef TPM_HANDLE TPMI_SH_AUTH_SESSION;
+
+// Table 43 - TPMI_SH_HMAC Type
+typedef TPM_HANDLE TPMI_SH_HMAC;
+
+// Table 44 - TPMI_SH_POLICY Type
+typedef TPM_HANDLE TPMI_SH_POLICY;
+
+// Table 45 - TPMI_DH_CONTEXT Type
+typedef TPM_HANDLE TPMI_DH_CONTEXT;
+
+// Table 46 - TPMI_RH_HIERARCHY Type
+typedef TPM_HANDLE TPMI_RH_HIERARCHY;
+
+// Table 47 - TPMI_RH_HIERARCHY_AUTH Type
+typedef TPM_HANDLE TPMI_RH_HIERARCHY_AUTH;
+
+// Table 48 - TPMI_RH_PLATFORM Type
+typedef TPM_HANDLE TPMI_RH_PLATFORM;
+
+// Table 49 - TPMI_RH_OWNER Type
+typedef TPM_HANDLE TPMI_RH_OWNER;
+
+// Table 50 - TPMI_RH_ENDORSEMENT Type
+typedef TPM_HANDLE TPMI_RH_ENDORSEMENT;
+
+// Table 51 - TPMI_RH_PROVISION Type
+typedef TPM_HANDLE TPMI_RH_PROVISION;
+
+// Table 52 - TPMI_RH_CLEAR Type
+typedef TPM_HANDLE TPMI_RH_CLEAR;
+
+// Table 53 - TPMI_RH_NV_AUTH Type
+typedef TPM_HANDLE TPMI_RH_NV_AUTH;
+
+// Table 54 - TPMI_RH_LOCKOUT Type
+typedef TPM_HANDLE TPMI_RH_LOCKOUT;
+
+// Table 55 - TPMI_RH_NV_INDEX Type
+typedef TPM_HANDLE TPMI_RH_NV_INDEX;
+
+// Table 56 - TPMI_ALG_HASH Type
+typedef TPM_ALG_ID TPMI_ALG_HASH;
+
+// Table 57 - TPMI_ALG_ASYM Type
+typedef TPM_ALG_ID TPMI_ALG_ASYM;
+
+// Table 58 - TPMI_ALG_SYM Type
+typedef TPM_ALG_ID TPMI_ALG_SYM;
+
+// Table 59 - TPMI_ALG_SYM_OBJECT Type
+typedef TPM_ALG_ID TPMI_ALG_SYM_OBJECT;
+
+// Table 60 - TPMI_ALG_SYM_MODE Type
+typedef TPM_ALG_ID TPMI_ALG_SYM_MODE;
+
+// Table 61 - TPMI_ALG_KDF Type
+typedef TPM_ALG_ID TPMI_ALG_KDF;
+
+// Table 62 - TPMI_ALG_SIG_SCHEME Type
+typedef TPM_ALG_ID TPMI_ALG_SIG_SCHEME;
+
+// Table 63 - TPMI_ECC_KEY_EXCHANGE Type
+typedef TPM_ALG_ID TPMI_ECC_KEY_EXCHANGE;
+
+// Table 64 - TPMI_ST_COMMAND_TAG Type
+typedef TPM_ST TPMI_ST_COMMAND_TAG;
+
+// 10 Structure Definitions
+
+// Table 65 - TPMS_ALGORITHM_DESCRIPTION Structure
+typedef struct {
+ TPM_ALG_ID alg;
+ TPMA_ALGORITHM attributes;
+} TPMS_ALGORITHM_DESCRIPTION;
+
+// Table 66 - TPMU_HA Union
+typedef union {
+ BYTE sha1[SHA1_DIGEST_SIZE];
+ BYTE sha256[SHA256_DIGEST_SIZE];
+ BYTE sm3_256[SM3_256_DIGEST_SIZE];
+ BYTE sha384[SHA384_DIGEST_SIZE];
+ BYTE sha512[SHA512_DIGEST_SIZE];
+} TPMU_HA;
+
+// Table 67 - TPMT_HA Structure
+typedef struct {
+ TPMI_ALG_HASH hashAlg;
+ TPMU_HA digest;
+} TPMT_HA;
+
+// Table 68 - TPM2B_DIGEST Structure
+typedef struct {
+ UINT16 size;
+ BYTE buffer[sizeof(TPMU_HA)];
+} TPM2B_DIGEST;
+
+// Table 69 - TPM2B_DATA Structure
+typedef struct {
+ UINT16 size;
+ BYTE buffer[sizeof(TPMT_HA)];
+} TPM2B_DATA;
+
+// Table 70 - TPM2B_NONCE Types
+typedef TPM2B_DIGEST TPM2B_NONCE;
+
+// Table 71 - TPM2B_AUTH Types
+typedef TPM2B_DIGEST TPM2B_AUTH;
+
+// Table 72 - TPM2B_OPERAND Types
+typedef TPM2B_DIGEST TPM2B_OPERAND;
+
+// Table 73 - TPM2B_EVENT Structure
+typedef struct {
+ UINT16 size;
+ BYTE buffer[1024];
+} TPM2B_EVENT;
+
+// Table 74 - TPM2B_MAX_BUFFER Structure
+typedef struct {
+ UINT16 size;
+ BYTE buffer[MAX_DIGEST_BUFFER];
+} TPM2B_MAX_BUFFER;
+
+// Table 75 - TPM2B_MAX_NV_BUFFER Structure
+typedef struct {
+ UINT16 size;
+ BYTE buffer[MAX_NV_INDEX_SIZE];
+} TPM2B_MAX_NV_BUFFER;
+
+// Table 76 - TPM2B_TIMEOUT Structure
+typedef struct {
+ UINT16 size;
+ BYTE buffer[sizeof(UINT64)];
+} TPM2B_TIMEOUT;
+
+// Table 77 -- TPM2B_IV Structure <I/O>
+typedef struct {
+ UINT16 size;
+ BYTE buffer[MAX_SYM_BLOCK_SIZE];
+} TPM2B_IV;
+
+// Table 78 - TPMU_NAME Union
+typedef union {
+ TPMT_HA digest;
+ TPM_HANDLE handle;
+} TPMU_NAME;
+
+// Table 79 - TPM2B_NAME Structure
+typedef struct {
+ UINT16 size;
+ BYTE name[sizeof(TPMU_NAME)];
+} TPM2B_NAME;
+
+// Table 80 - TPMS_PCR_SELECT Structure
+typedef struct {
+ UINT8 sizeofSelect;
+ BYTE pcrSelect[PCR_SELECT_MAX];
+} TPMS_PCR_SELECT;
+
+// Table 81 - TPMS_PCR_SELECTION Structure
+typedef struct {
+ TPMI_ALG_HASH hash;
+ UINT8 sizeofSelect;
+ BYTE pcrSelect[PCR_SELECT_MAX];
+} TPMS_PCR_SELECTION;
+
+// Table 84 - TPMT_TK_CREATION Structure
+typedef struct {
+ TPM_ST tag;
+ TPMI_RH_HIERARCHY hierarchy;
+ TPM2B_DIGEST digest;
+} TPMT_TK_CREATION;
+
+// Table 85 - TPMT_TK_VERIFIED Structure
+typedef struct {
+ TPM_ST tag;
+ TPMI_RH_HIERARCHY hierarchy;
+ TPM2B_DIGEST digest;
+} TPMT_TK_VERIFIED;
+
+// Table 86 - TPMT_TK_AUTH Structure
+typedef struct {
+ TPM_ST tag;
+ TPMI_RH_HIERARCHY hierarchy;
+ TPM2B_DIGEST digest;
+} TPMT_TK_AUTH;
+
+// Table 87 - TPMT_TK_HASHCHECK Structure
+typedef struct {
+ TPM_ST tag;
+ TPMI_RH_HIERARCHY hierarchy;
+ TPM2B_DIGEST digest;
+} TPMT_TK_HASHCHECK;
+
+// Table 88 - TPMS_ALG_PROPERTY Structure
+typedef struct {
+ TPM_ALG_ID alg;
+ TPMA_ALGORITHM algProperties;
+} TPMS_ALG_PROPERTY;
+
+// Table 89 - TPMS_TAGGED_PROPERTY Structure
+typedef struct {
+ TPM_PT property;
+ UINT32 value;
+} TPMS_TAGGED_PROPERTY;
+
+// Table 90 - TPMS_TAGGED_PCR_SELECT Structure
+typedef struct {
+ TPM_PT tag;
+ UINT8 sizeofSelect;
+ BYTE pcrSelect[PCR_SELECT_MAX];
+} TPMS_TAGGED_PCR_SELECT;
+
+// Table 91 - TPML_CC Structure
+typedef struct {
+ UINT32 count;
+ TPM_CC commandCodes[MAX_CAP_CC];
+} TPML_CC;
+
+// Table 92 - TPML_CCA Structure
+typedef struct {
+ UINT32 count;
+ TPMA_CC commandAttributes[MAX_CAP_CC];
+} TPML_CCA;
+
+// Table 93 - TPML_ALG Structure
+typedef struct {
+ UINT32 count;
+ TPM_ALG_ID algorithms[MAX_ALG_LIST_SIZE];
+} TPML_ALG;
+
+// Table 94 - TPML_HANDLE Structure
+typedef struct {
+ UINT32 count;
+ TPM_HANDLE handle[MAX_CAP_HANDLES];
+} TPML_HANDLE;
+
+// Table 95 - TPML_DIGEST Structure
+typedef struct {
+ UINT32 count;
+ TPM2B_DIGEST digests[8];
+} TPML_DIGEST;
+
+// Table 96 -- TPML_DIGEST_VALUES Structure <I/O>
+typedef struct {
+ UINT32 count;
+ TPMT_HA digests[HASH_COUNT];
+} TPML_DIGEST_VALUES;
+
+// Table 97 - TPM2B_DIGEST_VALUES Structure
+typedef struct {
+ UINT16 size;
+ BYTE buffer[sizeof(TPML_DIGEST_VALUES)];
+} TPM2B_DIGEST_VALUES;
+
+// Table 98 - TPML_PCR_SELECTION Structure
+typedef struct {
+ UINT32 count;
+ TPMS_PCR_SELECTION pcrSelections[HASH_COUNT];
+} TPML_PCR_SELECTION;
+
+// Table 99 - TPML_ALG_PROPERTY Structure
+typedef struct {
+ UINT32 count;
+ TPMS_ALG_PROPERTY algProperties[MAX_CAP_ALGS];
+} TPML_ALG_PROPERTY;
+
+// Table 100 - TPML_TAGGED_TPM_PROPERTY Structure
+typedef struct {
+ UINT32 count;
+ TPMS_TAGGED_PROPERTY tpmProperty[MAX_TPM_PROPERTIES];
+} TPML_TAGGED_TPM_PROPERTY;
+
+// Table 101 - TPML_TAGGED_PCR_PROPERTY Structure
+typedef struct {
+ UINT32 count;
+ TPMS_TAGGED_PCR_SELECT pcrProperty[MAX_PCR_PROPERTIES];
+} TPML_TAGGED_PCR_PROPERTY;
+
+// Table 102 - TPML_ECC_CURVE Structure
+typedef struct {
+ UINT32 count;
+ TPM_ECC_CURVE eccCurves[MAX_ECC_CURVES];
+} TPML_ECC_CURVE;
+
+// Table 103 - TPMU_CAPABILITIES Union
+typedef union {
+ TPML_ALG_PROPERTY algorithms;
+ TPML_HANDLE handles;
+ TPML_CCA command;
+ TPML_CC ppCommands;
+ TPML_CC auditCommands;
+ TPML_PCR_SELECTION assignedPCR;
+ TPML_TAGGED_TPM_PROPERTY tpmProperties;
+ TPML_TAGGED_PCR_PROPERTY pcrProperties;
+ TPML_ECC_CURVE eccCurves;
+} TPMU_CAPABILITIES;
+
+// Table 104 - TPMS_CAPABILITY_DATA Structure
+typedef struct {
+ TPM_CAP capability;
+ TPMU_CAPABILITIES data;
+} TPMS_CAPABILITY_DATA;
+
+// Table 105 - TPMS_CLOCK_INFO Structure
+typedef struct {
+ UINT64 clock;
+ UINT32 resetCount;
+ UINT32 restartCount;
+ TPMI_YES_NO safe;
+} TPMS_CLOCK_INFO;
+
+// Table 106 - TPMS_TIME_INFO Structure
+typedef struct {
+ UINT64 time;
+ TPMS_CLOCK_INFO clockInfo;
+} TPMS_TIME_INFO;
+
+// Table 107 - TPMS_TIME_ATTEST_INFO Structure
+typedef struct {
+ TPMS_TIME_INFO time;
+ UINT64 firmwareVersion;
+} TPMS_TIME_ATTEST_INFO;
+
+// Table 108 - TPMS_CERTIFY_INFO Structure
+typedef struct {
+ TPM2B_NAME name;
+ TPM2B_NAME qualifiedName;
+} TPMS_CERTIFY_INFO;
+
+// Table 109 - TPMS_QUOTE_INFO Structure
+typedef struct {
+ TPML_PCR_SELECTION pcrSelect;
+ TPM2B_DIGEST pcrDigest;
+} TPMS_QUOTE_INFO;
+
+// Table 110 - TPMS_COMMAND_AUDIT_INFO Structure
+typedef struct {
+ UINT64 auditCounter;
+ TPM_ALG_ID digestAlg;
+ TPM2B_DIGEST auditDigest;
+ TPM2B_DIGEST commandDigest;
+} TPMS_COMMAND_AUDIT_INFO;
+
+// Table 111 - TPMS_SESSION_AUDIT_INFO Structure
+typedef struct {
+ TPMI_YES_NO exclusiveSession;
+ TPM2B_DIGEST sessionDigest;
+} TPMS_SESSION_AUDIT_INFO;
+
+// Table 112 - TPMS_CREATION_INFO Structure
+typedef struct {
+ TPM2B_NAME objectName;
+ TPM2B_DIGEST creationHash;
+} TPMS_CREATION_INFO;
+
+// Table 113 - TPMS_NV_CERTIFY_INFO Structure
+typedef struct {
+ TPM2B_NAME indexName;
+ UINT16 offset;
+ TPM2B_MAX_NV_BUFFER nvContents;
+} TPMS_NV_CERTIFY_INFO;
+
+// Table 114 - TPMI_ST_ATTEST Type
+typedef TPM_ST TPMI_ST_ATTEST;
+
+// Table 115 - TPMU_ATTEST Union
+typedef union {
+ TPMS_CERTIFY_INFO certify;
+ TPMS_CREATION_INFO creation;
+ TPMS_QUOTE_INFO quote;
+ TPMS_COMMAND_AUDIT_INFO commandAudit;
+ TPMS_SESSION_AUDIT_INFO sessionAudit;
+ TPMS_TIME_ATTEST_INFO time;
+ TPMS_NV_CERTIFY_INFO nv;
+} TPMU_ATTEST;
+
+// Table 116 - TPMS_ATTEST Structure
+typedef struct {
+ TPM_GENERATED magic;
+ TPMI_ST_ATTEST type;
+ TPM2B_NAME qualifiedSigner;
+ TPM2B_DATA extraData;
+ TPMS_CLOCK_INFO clockInfo;
+ UINT64 firmwareVersion;
+ TPMU_ATTEST attested;
+} TPMS_ATTEST;
+
+// Table 117 - TPM2B_ATTEST Structure
+typedef struct {
+ UINT16 size;
+ BYTE attestationData[sizeof(TPMS_ATTEST)];
+} TPM2B_ATTEST;
+
+// Table 118 - TPMS_AUTH_COMMAND Structure
+typedef struct {
+ TPMI_SH_AUTH_SESSION sessionHandle;
+ TPM2B_NONCE nonce;
+ TPMA_SESSION sessionAttributes;
+ TPM2B_AUTH hmac;
+} TPMS_AUTH_COMMAND;
+
+// Table 119 - TPMS_AUTH_RESPONSE Structure
+typedef struct {
+ TPM2B_NONCE nonce;
+ TPMA_SESSION sessionAttributes;
+ TPM2B_AUTH hmac;
+} TPMS_AUTH_RESPONSE;
+
+// 11 Algorithm Parameters and Structures
+
+// Table 120 - TPMI_AES_KEY_BITS Type
+typedef TPM_KEY_BITS TPMI_AES_KEY_BITS;
+
+// Table 121 - TPMI_SM4_KEY_BITS Type
+typedef TPM_KEY_BITS TPMI_SM4_KEY_BITS;
+
+// Table 122 - TPMU_SYM_KEY_BITS Union
+typedef union {
+ TPMI_AES_KEY_BITS aes;
+ TPMI_SM4_KEY_BITS SM4;
+ TPM_KEY_BITS sym;
+ TPMI_ALG_HASH xor;
+} TPMU_SYM_KEY_BITS;
+
+// Table 123 - TPMU_SYM_MODE Union
+typedef union {
+ TPMI_ALG_SYM_MODE aes;
+ TPMI_ALG_SYM_MODE SM4;
+ TPMI_ALG_SYM_MODE sym;
+} TPMU_SYM_MODE;
+
+// Table 125 - TPMT_SYM_DEF Structure
+typedef struct {
+ TPMI_ALG_SYM algorithm;
+ TPMU_SYM_KEY_BITS keyBits;
+ TPMU_SYM_MODE mode;
+} TPMT_SYM_DEF;
+
+// Table 126 - TPMT_SYM_DEF_OBJECT Structure
+typedef struct {
+ TPMI_ALG_SYM_OBJECT algorithm;
+ TPMU_SYM_KEY_BITS keyBits;
+ TPMU_SYM_MODE mode;
+} TPMT_SYM_DEF_OBJECT;
+
+// Table 127 - TPM2B_SYM_KEY Structure
+typedef struct {
+ UINT16 size;
+ BYTE buffer[MAX_SYM_KEY_BYTES];
+} TPM2B_SYM_KEY;
+
+// Table 128 - TPMS_SYMCIPHER_PARMS Structure
+typedef struct {
+ TPMT_SYM_DEF_OBJECT sym;
+} TPMS_SYMCIPHER_PARMS;
+
+// Table 129 - TPM2B_SENSITIVE_DATA Structure
+typedef struct {
+ UINT16 size;
+ BYTE buffer[MAX_SYM_DATA];
+} TPM2B_SENSITIVE_DATA;
+
+// Table 130 - TPMS_SENSITIVE_CREATE Structure
+typedef struct {
+ TPM2B_AUTH userAuth;
+ TPM2B_SENSITIVE_DATA data;
+} TPMS_SENSITIVE_CREATE;
+
+// Table 131 - TPM2B_SENSITIVE_CREATE Structure
+typedef struct {
+ UINT16 size;
+ TPMS_SENSITIVE_CREATE sensitive;
+} TPM2B_SENSITIVE_CREATE;
+
+// Table 132 - TPMS_SCHEME_SIGHASH Structure
+typedef struct {
+ TPMI_ALG_HASH hashAlg;
+} TPMS_SCHEME_SIGHASH;
+
+// Table 133 - TPMI_ALG_KEYEDHASH_SCHEME Type
+typedef TPM_ALG_ID TPMI_ALG_KEYEDHASH_SCHEME;
+
+// Table 134 - HMAC_SIG_SCHEME Types
+typedef TPMS_SCHEME_SIGHASH TPMS_SCHEME_HMAC;
+
+// Table 135 - TPMS_SCHEME_XOR Structure
+typedef struct {
+ TPMI_ALG_HASH hashAlg;
+ TPMI_ALG_KDF kdf;
+} TPMS_SCHEME_XOR;
+
+// Table 136 - TPMU_SCHEME_KEYEDHASH Union
+typedef union {
+ TPMS_SCHEME_HMAC hmac;
+ TPMS_SCHEME_XOR xor;
+} TPMU_SCHEME_KEYEDHASH;
+
+// Table 137 - TPMT_KEYEDHASH_SCHEME Structure
+typedef struct {
+ TPMI_ALG_KEYEDHASH_SCHEME scheme;
+ TPMU_SCHEME_KEYEDHASH details;
+} TPMT_KEYEDHASH_SCHEME;
+
+// Table 138 - RSA_SIG_SCHEMES Types
+typedef TPMS_SCHEME_SIGHASH TPMS_SCHEME_RSASSA;
+typedef TPMS_SCHEME_SIGHASH TPMS_SCHEME_RSAPSS;
+
+// Table 139 - ECC_SIG_SCHEMES Types
+typedef TPMS_SCHEME_SIGHASH TPMS_SCHEME_ECDSA;
+typedef TPMS_SCHEME_SIGHASH TPMS_SCHEME_SM2;
+typedef TPMS_SCHEME_SIGHASH TPMS_SCHEME_ECSCHNORR;
+
+// Table 140 - TPMS_SCHEME_ECDAA Structure
+typedef struct {
+ TPMI_ALG_HASH hashAlg;
+ UINT16 count;
+} TPMS_SCHEME_ECDAA;
+
+// Table 141 - TPMU_SIG_SCHEME Union
+typedef union {
+ TPMS_SCHEME_RSASSA rsassa;
+ TPMS_SCHEME_RSAPSS rsapss;
+ TPMS_SCHEME_ECDSA ecdsa;
+ TPMS_SCHEME_ECDAA ecdaa;
+ TPMS_SCHEME_ECSCHNORR ecSchnorr;
+ TPMS_SCHEME_HMAC hmac;
+ TPMS_SCHEME_SIGHASH any;
+} TPMU_SIG_SCHEME;
+
+// Table 142 - TPMT_SIG_SCHEME Structure
+typedef struct {
+ TPMI_ALG_SIG_SCHEME scheme;
+ TPMU_SIG_SCHEME details;
+} TPMT_SIG_SCHEME;
+
+// Table 143 - TPMS_SCHEME_OAEP Structure
+typedef struct {
+ TPMI_ALG_HASH hashAlg;
+} TPMS_SCHEME_OAEP;
+
+// Table 144 - TPMS_SCHEME_ECDH Structure
+typedef struct {
+ TPMI_ALG_HASH hashAlg;
+} TPMS_SCHEME_ECDH;
+
+// Table 145 - TPMS_SCHEME_MGF1 Structure
+typedef struct {
+ TPMI_ALG_HASH hashAlg;
+} TPMS_SCHEME_MGF1;
+
+// Table 146 - TPMS_SCHEME_KDF1_SP800_56a Structure
+typedef struct {
+ TPMI_ALG_HASH hashAlg;
+} TPMS_SCHEME_KDF1_SP800_56a;
+
+// Table 147 - TPMS_SCHEME_KDF2 Structure
+typedef struct {
+ TPMI_ALG_HASH hashAlg;
+} TPMS_SCHEME_KDF2;
+
+// Table 148 - TPMS_SCHEME_KDF1_SP800_108 Structure
+typedef struct {
+ TPMI_ALG_HASH hashAlg;
+} TPMS_SCHEME_KDF1_SP800_108;
+
+// Table 149 - TPMU_KDF_SCHEME Union
+typedef union {
+ TPMS_SCHEME_MGF1 mgf1;
+ TPMS_SCHEME_KDF1_SP800_56a kdf1_SP800_56a;
+ TPMS_SCHEME_KDF2 kdf2;
+ TPMS_SCHEME_KDF1_SP800_108 kdf1_sp800_108;
+} TPMU_KDF_SCHEME;
+
+// Table 150 - TPMT_KDF_SCHEME Structure
+typedef struct {
+ TPMI_ALG_KDF scheme;
+ TPMU_KDF_SCHEME details;
+} TPMT_KDF_SCHEME;
+
+// Table 151 - TPMI_ALG_ASYM_SCHEME Type
+typedef TPM_ALG_ID TPMI_ALG_ASYM_SCHEME;
+
+// Table 152 - TPMU_ASYM_SCHEME Union
+typedef union {
+ TPMS_SCHEME_RSASSA rsassa;
+ TPMS_SCHEME_RSAPSS rsapss;
+ TPMS_SCHEME_OAEP oaep;
+ TPMS_SCHEME_ECDSA ecdsa;
+ TPMS_SCHEME_ECDAA ecdaa;
+ TPMS_SCHEME_ECSCHNORR ecSchnorr;
+ TPMS_SCHEME_SIGHASH anySig;
+} TPMU_ASYM_SCHEME;
+
+// Table 153 - TPMT_ASYM_SCHEME Structure
+typedef struct {
+ TPMI_ALG_ASYM_SCHEME scheme;
+ TPMU_ASYM_SCHEME details;
+} TPMT_ASYM_SCHEME;
+
+// Table 154 - TPMI_ALG_RSA_SCHEME Type
+typedef TPM_ALG_ID TPMI_ALG_RSA_SCHEME;
+
+// Table 155 - TPMT_RSA_SCHEME Structure
+typedef struct {
+ TPMI_ALG_RSA_SCHEME scheme;
+ TPMU_ASYM_SCHEME details;
+} TPMT_RSA_SCHEME;
+
+// Table 156 - TPMI_ALG_RSA_DECRYPT Type
+typedef TPM_ALG_ID TPMI_ALG_RSA_DECRYPT;
+
+// Table 157 - TPMT_RSA_DECRYPT Structure
+typedef struct {
+ TPMI_ALG_RSA_DECRYPT scheme;
+ TPMU_ASYM_SCHEME details;
+} TPMT_RSA_DECRYPT;
+
+// Table 158 - TPM2B_PUBLIC_KEY_RSA Structure
+typedef struct {
+ UINT16 size;
+ BYTE buffer[MAX_RSA_KEY_BYTES];
+} TPM2B_PUBLIC_KEY_RSA;
+
+// Table 159 - TPMI_RSA_KEY_BITS Type
+typedef TPM_KEY_BITS TPMI_RSA_KEY_BITS;
+
+// Table 160 - TPM2B_PRIVATE_KEY_RSA Structure
+typedef struct {
+ UINT16 size;
+ BYTE buffer[MAX_RSA_KEY_BYTES/2];
+} TPM2B_PRIVATE_KEY_RSA;
+
+// Table 161 - TPM2B_ECC_PARAMETER Structure
+typedef struct {
+ UINT16 size;
+ BYTE buffer[MAX_ECC_KEY_BYTES];
+} TPM2B_ECC_PARAMETER;
+
+// Table 162 - TPMS_ECC_POINT Structure
+typedef struct {
+ TPM2B_ECC_PARAMETER x;
+ TPM2B_ECC_PARAMETER y;
+} TPMS_ECC_POINT;
+
+// Table 163 -- TPM2B_ECC_POINT Structure <I/O>
+typedef struct {
+ UINT16 size;
+ TPMS_ECC_POINT point;
+} TPM2B_ECC_POINT;
+
+// Table 164 - TPMI_ALG_ECC_SCHEME Type
+typedef TPM_ALG_ID TPMI_ALG_ECC_SCHEME;
+
+// Table 165 - TPMI_ECC_CURVE Type
+typedef TPM_ECC_CURVE TPMI_ECC_CURVE;
+
+// Table 166 - TPMT_ECC_SCHEME Structure
+typedef struct {
+ TPMI_ALG_ECC_SCHEME scheme;
+ TPMU_SIG_SCHEME details;
+} TPMT_ECC_SCHEME;
+
+// Table 167 - TPMS_ALGORITHM_DETAIL_ECC Structure
+typedef struct {
+ TPM_ECC_CURVE curveID;
+ UINT16 keySize;
+ TPMT_KDF_SCHEME kdf;
+ TPMT_ECC_SCHEME sign;
+ TPM2B_ECC_PARAMETER p;
+ TPM2B_ECC_PARAMETER a;
+ TPM2B_ECC_PARAMETER b;
+ TPM2B_ECC_PARAMETER gX;
+ TPM2B_ECC_PARAMETER gY;
+ TPM2B_ECC_PARAMETER n;
+ TPM2B_ECC_PARAMETER h;
+} TPMS_ALGORITHM_DETAIL_ECC;
+
+// Table 168 - TPMS_SIGNATURE_RSASSA Structure
+typedef struct {
+ TPMI_ALG_HASH hash;
+ TPM2B_PUBLIC_KEY_RSA sig;
+} TPMS_SIGNATURE_RSASSA;
+
+// Table 169 - TPMS_SIGNATURE_RSAPSS Structure
+typedef struct {
+ TPMI_ALG_HASH hash;
+ TPM2B_PUBLIC_KEY_RSA sig;
+} TPMS_SIGNATURE_RSAPSS;
+
+// Table 170 - TPMS_SIGNATURE_ECDSA Structure
+typedef struct {
+ TPMI_ALG_HASH hash;
+ TPM2B_ECC_PARAMETER signatureR;
+ TPM2B_ECC_PARAMETER signatureS;
+} TPMS_SIGNATURE_ECDSA;
+
+// Table 171 - TPMU_SIGNATURE Union
+typedef union {
+ TPMS_SIGNATURE_RSASSA rsassa;
+ TPMS_SIGNATURE_RSAPSS rsapss;
+ TPMS_SIGNATURE_ECDSA ecdsa;
+ TPMS_SIGNATURE_ECDSA sm2;
+ TPMS_SIGNATURE_ECDSA ecdaa;
+ TPMS_SIGNATURE_ECDSA ecschnorr;
+ TPMT_HA hmac;
+ TPMS_SCHEME_SIGHASH any;
+} TPMU_SIGNATURE;
+
+// Table 172 - TPMT_SIGNATURE Structure
+typedef struct {
+ TPMI_ALG_SIG_SCHEME sigAlg;
+ TPMU_SIGNATURE signature;
+} TPMT_SIGNATURE;
+
+// Table 173 - TPMU_ENCRYPTED_SECRET Union
+typedef union {
+ BYTE ecc[sizeof(TPMS_ECC_POINT)];
+ BYTE rsa[MAX_RSA_KEY_BYTES];
+ BYTE symmetric[sizeof(TPM2B_DIGEST)];
+ BYTE keyedHash[sizeof(TPM2B_DIGEST)];
+} TPMU_ENCRYPTED_SECRET;
+
+// Table 174 - TPM2B_ENCRYPTED_SECRET Structure
+typedef struct {
+ UINT16 size;
+ BYTE secret[sizeof(TPMU_ENCRYPTED_SECRET)];
+} TPM2B_ENCRYPTED_SECRET;
+
+// 12 Key/Object Complex
+
+// Table 175 - TPMI_ALG_PUBLIC Type
+typedef TPM_ALG_ID TPMI_ALG_PUBLIC;
+
+// Table 176 - TPMU_PUBLIC_ID Union
+typedef union {
+ TPM2B_DIGEST keyedHash;
+ TPM2B_DIGEST sym;
+ TPM2B_PUBLIC_KEY_RSA rsa;
+ TPMS_ECC_POINT ecc;
+} TPMU_PUBLIC_ID;
+
+// Table 177 - TPMS_KEYEDHASH_PARMS Structure
+typedef struct {
+ TPMT_KEYEDHASH_SCHEME scheme;
+} TPMS_KEYEDHASH_PARMS;
+
+// Table 178 - TPMS_ASYM_PARMS Structure
+typedef struct {
+ TPMT_SYM_DEF_OBJECT symmetric;
+ TPMT_ASYM_SCHEME scheme;
+} TPMS_ASYM_PARMS;
+
+// Table 179 - TPMS_RSA_PARMS Structure
+typedef struct {
+ TPMT_SYM_DEF_OBJECT symmetric;
+ TPMT_RSA_SCHEME scheme;
+ TPMI_RSA_KEY_BITS keyBits;
+ UINT32 exponent;
+} TPMS_RSA_PARMS;
+
+// Table 180 - TPMS_ECC_PARMS Structure
+typedef struct {
+ TPMT_SYM_DEF_OBJECT symmetric;
+ TPMT_ECC_SCHEME scheme;
+ TPMI_ECC_CURVE curveID;
+ TPMT_KDF_SCHEME kdf;
+} TPMS_ECC_PARMS;
+
+// Table 181 - TPMU_PUBLIC_PARMS Union
+typedef union {
+ TPMS_KEYEDHASH_PARMS keyedHashDetail;
+ TPMT_SYM_DEF_OBJECT symDetail;
+ TPMS_RSA_PARMS rsaDetail;
+ TPMS_ECC_PARMS eccDetail;
+ TPMS_ASYM_PARMS asymDetail;
+} TPMU_PUBLIC_PARMS;
+
+// Table 182 - TPMT_PUBLIC_PARMS Structure
+typedef struct {
+ TPMI_ALG_PUBLIC type;
+ TPMU_PUBLIC_PARMS parameters;
+} TPMT_PUBLIC_PARMS;
+
+// Table 183 - TPMT_PUBLIC Structure
+typedef struct {
+ TPMI_ALG_PUBLIC type;
+ TPMI_ALG_HASH nameAlg;
+ TPMA_OBJECT objectAttributes;
+ TPM2B_DIGEST authPolicy;
+ TPMU_PUBLIC_PARMS parameters;
+ TPMU_PUBLIC_ID unique;
+} TPMT_PUBLIC;
+
+// Table 184 - TPM2B_PUBLIC Structure
+typedef struct {
+ UINT16 size;
+ TPMT_PUBLIC publicArea;
+} TPM2B_PUBLIC;
+
+// Table 185 - TPM2B_PRIVATE_VENDOR_SPECIFIC Structure
+typedef struct {
+ UINT16 size;
+ BYTE buffer[PRIVATE_VENDOR_SPECIFIC_BYTES];
+} TPM2B_PRIVATE_VENDOR_SPECIFIC;
+
+// Table 186 - TPMU_SENSITIVE_COMPOSITE Union
+typedef union {
+ TPM2B_PRIVATE_KEY_RSA rsa;
+ TPM2B_ECC_PARAMETER ecc;
+ TPM2B_SENSITIVE_DATA bits;
+ TPM2B_SYM_KEY sym;
+ TPM2B_PRIVATE_VENDOR_SPECIFIC any;
+} TPMU_SENSITIVE_COMPOSITE;
+
+// Table 187 - TPMT_SENSITIVE Structure
+typedef struct {
+ TPMI_ALG_PUBLIC sensitiveType;
+ TPM2B_AUTH authValue;
+ TPM2B_DIGEST seedValue;
+ TPMU_SENSITIVE_COMPOSITE sensitive;
+} TPMT_SENSITIVE;
+
+// Table 188 - TPM2B_SENSITIVE Structure
+typedef struct {
+ UINT16 size;
+ TPMT_SENSITIVE sensitiveArea;
+} TPM2B_SENSITIVE;
+
+// Table 189 - _PRIVATE Structure
+typedef struct {
+ TPM2B_DIGEST integrityOuter;
+ TPM2B_DIGEST integrityInner;
+ TPMT_SENSITIVE sensitive;
+} _PRIVATE;
+
+// Table 190 - TPM2B_PRIVATE Structure
+typedef struct {
+ UINT16 size;
+ BYTE buffer[sizeof(_PRIVATE)];
+} TPM2B_PRIVATE;
+
+// Table 191 - _ID_OBJECT Structure
+typedef struct {
+ TPM2B_DIGEST integrityHMAC;
+ TPM2B_DIGEST encIdentity;
+} _ID_OBJECT;
+
+// Table 192 - TPM2B_ID_OBJECT Structure
+typedef struct {
+ UINT16 size;
+ BYTE credential[sizeof(_ID_OBJECT)];
+} TPM2B_ID_OBJECT;
+
+// 13 NV Storage Structures
+
+// Table 193 - TPM_NV_INDEX Bits
+//
+// NOTE: Comment here to resolve conflict
+//
+//typedef struct {
+// UINT32 index : 22;
+// UINT32 space : 2;
+// UINT32 RH_NV : 8;
+//} TPM_NV_INDEX;
+
+// Table 195 - TPMA_NV Bits
+typedef struct {
+ UINT32 TPMA_NV_PPWRITE : 1;
+ UINT32 TPMA_NV_OWNERWRITE : 1;
+ UINT32 TPMA_NV_AUTHWRITE : 1;
+ UINT32 TPMA_NV_POLICYWRITE : 1;
+ UINT32 TPMA_NV_COUNTER : 1;
+ UINT32 TPMA_NV_BITS : 1;
+ UINT32 TPMA_NV_EXTEND : 1;
+ UINT32 reserved7_9 : 3;
+ UINT32 TPMA_NV_POLICY_DELETE : 1;
+ UINT32 TPMA_NV_WRITELOCKED : 1;
+ UINT32 TPMA_NV_WRITEALL : 1;
+ UINT32 TPMA_NV_WRITEDEFINE : 1;
+ UINT32 TPMA_NV_WRITE_STCLEAR : 1;
+ UINT32 TPMA_NV_GLOBALLOCK : 1;
+ UINT32 TPMA_NV_PPREAD : 1;
+ UINT32 TPMA_NV_OWNERREAD : 1;
+ UINT32 TPMA_NV_AUTHREAD : 1;
+ UINT32 TPMA_NV_POLICYREAD : 1;
+ UINT32 reserved20_24 : 5;
+ UINT32 TPMA_NV_NO_DA : 1;
+ UINT32 TPMA_NV_ORDERLY : 1;
+ UINT32 TPMA_NV_CLEAR_STCLEAR : 1;
+ UINT32 TPMA_NV_READLOCKED : 1;
+ UINT32 TPMA_NV_WRITTEN : 1;
+ UINT32 TPMA_NV_PLATFORMCREATE : 1;
+ UINT32 TPMA_NV_READ_STCLEAR : 1;
+} TPMA_NV;
+
+// Table 196 - TPMS_NV_PUBLIC Structure
+typedef struct {
+ TPMI_RH_NV_INDEX nvIndex;
+ TPMI_ALG_HASH nameAlg;
+ TPMA_NV attributes;
+ TPM2B_DIGEST authPolicy;
+ UINT16 dataSize;
+} TPMS_NV_PUBLIC;
+
+// Table 197 - TPM2B_NV_PUBLIC Structure
+typedef struct {
+ UINT16 size;
+ TPMS_NV_PUBLIC nvPublic;
+} TPM2B_NV_PUBLIC;
+
+// 14 Context Data
+
+// Table 198 - TPM2B_CONTEXT_SENSITIVE Structure
+typedef struct {
+ UINT16 size;
+ BYTE buffer[MAX_CONTEXT_SIZE];
+} TPM2B_CONTEXT_SENSITIVE;
+
+// Table 199 - TPMS_CONTEXT_DATA Structure
+typedef struct {
+ TPM2B_DIGEST integrity;
+ TPM2B_CONTEXT_SENSITIVE encrypted;
+} TPMS_CONTEXT_DATA;
+
+// Table 200 - TPM2B_CONTEXT_DATA Structure
+typedef struct {
+ UINT16 size;
+ BYTE buffer[sizeof(TPMS_CONTEXT_DATA)];
+} TPM2B_CONTEXT_DATA;
+
+// Table 201 - TPMS_CONTEXT Structure
+typedef struct {
+ UINT64 sequence;
+ TPMI_DH_CONTEXT savedHandle;
+ TPMI_RH_HIERARCHY hierarchy;
+ TPM2B_CONTEXT_DATA contextBlob;
+} TPMS_CONTEXT;
+
+// 15 Creation Data
+
+// Table 203 - TPMS_CREATION_DATA Structure
+typedef struct {
+ TPML_PCR_SELECTION pcrSelect;
+ TPM2B_DIGEST pcrDigest;
+ TPMA_LOCALITY locality;
+ TPM_ALG_ID parentNameAlg;
+ TPM2B_NAME parentName;
+ TPM2B_NAME parentQualifiedName;
+ TPM2B_DATA outsideInfo;
+} TPMS_CREATION_DATA;
+
+// Table 204 - TPM2B_CREATION_DATA Structure
+typedef struct {
+ UINT16 size;
+ TPMS_CREATION_DATA creationData;
+} TPM2B_CREATION_DATA;
+
+
+//
+// Command Header
+//
+typedef struct {
+ TPM_ST tag;
+ UINT32 paramSize;
+ TPM_CC commandCode;
+} TPM2_COMMAND_HEADER;
+
+typedef struct {
+ TPM_ST tag;
+ UINT32 paramSize;
+ TPM_RC responseCode;
+} TPM2_RESPONSE_HEADER;
+
+#pragma pack ()
+
+#endif
diff --git a/MdePkg/Include/IndustryStandard/Tpm2Acpi.h b/MdePkg/Include/IndustryStandard/Tpm2Acpi.h
new file mode 100644
index 000000000..73ef56124
--- /dev/null
+++ b/MdePkg/Include/IndustryStandard/Tpm2Acpi.h
@@ -0,0 +1,51 @@
+/** @file
+ TPM2 ACPI table definition.
+
+Copyright (c) 2013, 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.
+
+**/
+
+#ifndef _TPM2_ACPI_H_
+#define _TPM2_ACPI_H_
+
+#include <IndustryStandard/Acpi.h>
+
+#pragma pack (1)
+
+#define EFI_TPM2_ACPI_TABLE_REVISION 3
+
+typedef struct {
+ EFI_ACPI_DESCRIPTION_HEADER Header;
+ UINT32 Flags;
+ UINT64 AddressOfControlArea;
+ UINT32 StartMethod;
+//UINT8 PlatformSpecificParameters[];
+} EFI_TPM2_ACPI_TABLE;
+
+#define EFI_TPM2_ACPI_TABLE_START_METHOD_ACPI 2
+#define EFI_TPM2_ACPI_TABLE_START_METHOD_TIS 6
+#define EFI_TPM2_ACPI_TABLE_START_METHOD_COMMAND_RESPONSE_BUFFER_INTERFACE 7
+#define EFI_TPM2_ACPI_TABLE_START_METHOD_COMMAND_RESPONSE_BUFFER_INTERFACE_WITH_ACPI 8
+
+typedef struct {
+ UINT32 Reserved;
+ UINT32 Error;
+ UINT32 Cancel;
+ UINT32 Start;
+ UINT64 InterruptControl;
+ UINT32 CommandSize;
+ UINT64 Command;
+ UINT32 ResponseSize;
+ UINT64 Response;
+} EFI_TPM2_ACPI_CONTROL_AREA;
+
+#pragma pack ()
+
+#endif
diff --git a/MdePkg/Include/Library/PeiServicesLib.h b/MdePkg/Include/Library/PeiServicesLib.h
index 358c9cddf..2b51d374c 100644
--- a/MdePkg/Include/Library/PeiServicesLib.h
+++ b/MdePkg/Include/Library/PeiServicesLib.h
@@ -221,6 +221,30 @@ PeiServicesFfsFindSectionData (
);
/**
+ This service enables PEIMs to discover sections of a given instance and type within a valid FFS file.
+
+ @param SectionType The value of the section type to find.
+ @param SectionInstance Section instance to find.
+ @param FileHandle A pointer to the file header that contains the set
+ of sections to be searched.
+ @param SectionData A pointer to the discovered section, if successful.
+ @param AuthenticationStatus A pointer to the authentication status for this section.
+
+ @retval EFI_SUCCESS The section was found.
+ @retval EFI_NOT_FOUND The section was not found.
+
+**/
+EFI_STATUS
+EFIAPI
+PeiServicesFfsFindSectionData3 (
+ IN EFI_SECTION_TYPE SectionType,
+ IN UINTN SectionInstance,
+ IN EFI_PEI_FILE_HANDLE FileHandle,
+ OUT VOID **SectionData,
+ OUT UINT32 *AuthenticationStatus
+ );
+
+/**
This service enables PEIMs to register the permanent memory configuration
that has been initialized with the PEI Foundation.
@@ -349,6 +373,31 @@ PeiServicesFfsGetFileInfo (
);
/**
+ This service is a wrapper for the PEI Service FfsGetFileInfo2(), except the pointer to the PEI Services
+ Table has been removed. See the Platform Initialization Pre-EFI Initialization Core Interface
+ Specification for details.
+
+ @param FileHandle Handle of the file.
+
+ @param FileInfo Upon exit, points to the file's
+ information.
+
+ @retval EFI_SUCCESS File information returned.
+
+ @retval EFI_INVALID_PARAMETER If FileHandle does not
+ represent a valid file.
+
+ @retval EFI_INVALID_PARAMETER If FileInfo is NULL.
+
+**/
+EFI_STATUS
+EFIAPI
+PeiServicesFfsGetFileInfo2 (
+ IN CONST EFI_PEI_FILE_HANDLE FileHandle,
+ OUT EFI_FV_FILE_INFO2 *FileInfo
+ );
+
+/**
This service is a wrapper for the PEI Service FfsGetVolumeInfo(), except the pointer to the PEI Services
Table has been removed. See the Platform Initialization Pre-EFI Initialization Core Interface
Specification for details.
@@ -431,4 +480,45 @@ PeiServicesInstallFvInfoPpi (
IN CONST EFI_GUID *ParentFileName OPTIONAL
);
+/**
+ Install a EFI_PEI_FIRMWARE_VOLUME_INFO2_PPI instance so the PEI Core will be notified about a new firmware volume.
+
+ This function allocates, initializes, and installs a new EFI_PEI_FIRMWARE_VOLUME_INFO2_PPI using
+ the parameters passed in to initialize the fields of the EFI_PEI_FIRMWARE_VOLUME_INFO2_PPI instance.
+ If the resources can not be allocated for EFI_PEI_FIRMWARE_VOLUME_INFO2_PPI, then ASSERT().
+ If the EFI_PEI_FIRMWARE_VOLUME_INFO2_PPI can not be installed, then ASSERT().
+
+ @param FvFormat Unique identifier of the format of the memory-mapped
+ firmware volume. This parameter is optional and
+ may be NULL. If NULL is specified, the
+ EFI_FIRMWARE_FILE_SYSTEM2_GUID format is assumed.
+ @param FvInfo Points to a buffer which allows the
+ EFI_PEI_FIRMWARE_VOLUME_PPI to process the volume.
+ The format of this buffer is specific to the FvFormat.
+ For memory-mapped firmware volumes, this typically
+ points to the first byte of the firmware volume.
+ @param FvInfoSize The size, in bytes, of FvInfo. For memory-mapped
+ firmware volumes, this is typically the size of
+ the firmware volume.
+ @param ParentFvName If the new firmware volume originated from a file
+ in a different firmware volume, then this parameter
+ specifies the GUID name of the originating firmware
+ volume. Otherwise, this parameter must be NULL.
+ @param ParentFileName If the new firmware volume originated from a file
+ in a different firmware volume, then this parameter
+ specifies the GUID file name of the originating
+ firmware file. Otherwise, this parameter must be NULL.
+ @param AuthenticationStatus Authentication Status
+**/
+VOID
+EFIAPI
+PeiServicesInstallFvInfo2Ppi (
+ IN CONST EFI_GUID *FvFormat, OPTIONAL
+ IN CONST VOID *FvInfo,
+ IN UINT32 FvInfoSize,
+ IN CONST EFI_GUID *ParentFvName, OPTIONAL
+ IN CONST EFI_GUID *ParentFileName, OPTIONAL
+ IN UINT32 AuthenticationStatus
+ );
+
#endif
diff --git a/MdePkg/Include/Pi/PiFirmwareVolume.h b/MdePkg/Include/Pi/PiFirmwareVolume.h
index f589c20dd..7aa2e5e01 100644
--- a/MdePkg/Include/Pi/PiFirmwareVolume.h
+++ b/MdePkg/Include/Pi/PiFirmwareVolume.h
@@ -1,7 +1,7 @@
/** @file
The firmware volume related definitions in PI.
- Copyright (c) 2006 - 2011, Intel Corporation. All rights reserved.<BR>
+ Copyright (c) 2006 - 2013, 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.
@par Revision Reference:
- PI Version 1.2C
+ PI Version 1.3
**/
@@ -86,7 +86,7 @@ typedef UINT32 EFI_FVB_ATTRIBUTES_2;
#define EFI_FVB2_ALIGNMENT_512M 0x001D0000
#define EFI_FVB2_ALIGNMENT_1G 0x001E0000
#define EFI_FVB2_ALIGNMENT_2G 0x001F0000
-
+#define EFI_FVB2_WEAK_ALIGNMENT 0x80000000
typedef struct {
///
diff --git a/MdePkg/Include/Pi/PiPeiCis.h b/MdePkg/Include/Pi/PiPeiCis.h
index c3d147ac1..f2da20a23 100644
--- a/MdePkg/Include/Pi/PiPeiCis.h
+++ b/MdePkg/Include/Pi/PiPeiCis.h
@@ -1,7 +1,7 @@
/** @file
PI PEI master include file. This file should match the PI spec.
-Copyright (c) 2006 - 2011, Intel Corporation. All rights reserved.<BR>
+Copyright (c) 2006 - 2013, 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 that accompanies this distribution.
The full text of the license may be found at
@@ -396,6 +396,38 @@ EFI_STATUS
);
/**
+ Searches for the next matching section within the specified file.
+
+ This service enables PEI modules to discover the section of a given type within a valid file.
+ This service will search within encapsulation sections (compression and GUIDed) as well. It will
+ search inside of a GUIDed section or a compressed section, but may not, for example, search a
+ GUIDed section inside a GUIDes section.
+ This service will not search within compression sections or GUIDed sections that require
+ extraction if memory is not present.
+
+ @param PeiServices An indirect pointer to the EFI_PEI_SERVICES table published by the PEI Foundation.
+ @param SectionType The value of the section type to find.
+ @param SectionInstance Section instance to find.
+ @param FileHandle Handle of the firmware file to search.
+ @param SectionData A pointer to the discovered section, if successful.
+ @param AuthenticationStatus A pointer to the authentication status for this section.
+
+ @retval EFI_SUCCESS The section was found.
+ @retval EFI_NOT_FOUND The section was not found.
+
+**/
+typedef
+EFI_STATUS
+(EFIAPI *EFI_PEI_FFS_FIND_SECTION_DATA3)(
+ IN CONST EFI_PEI_SERVICES **PeiServices,
+ IN EFI_SECTION_TYPE SectionType,
+ IN UINTN SectionInstance,
+ IN EFI_PEI_FILE_HANDLE FileHandle,
+ OUT VOID **SectionData,
+ OUT UINT32 *AuthenticationStatus
+ );
+
+/**
This function registers the found memory configuration with the PEI Foundation.
@param PeiServices An indirect pointer to the EFI_PEI_SERVICES table published by the PEI Foundation.
@@ -608,6 +640,38 @@ typedef struct {
UINT32 BufferSize;
} EFI_FV_FILE_INFO;
+///
+/// The information with authentication status of the FV file.
+///
+typedef struct {
+ ///
+ /// Name of the file.
+ ///
+ EFI_GUID FileName;
+ ///
+ /// File type.
+ ///
+ EFI_FV_FILETYPE FileType;
+ ///
+ /// Attributes of the file.
+ ///
+ EFI_FV_FILE_ATTRIBUTES FileAttributes;
+ ///
+ /// Points to the file's data (not the header).
+ /// Not valid if EFI_FV_FILE_ATTRIB_MEMORY_MAPPED
+ /// is zero.
+ ///
+ VOID *Buffer;
+ ///
+ /// Size of the file's data.
+ ///
+ UINT32 BufferSize;
+ ///
+ /// Authentication status for this file.
+ ///
+ UINT32 AuthenticationStatus;
+} EFI_FV_FILE_INFO2;
+
/**
Returns information about a specific file.
@@ -633,6 +697,30 @@ EFI_STATUS
OUT EFI_FV_FILE_INFO *FileInfo
);
+/**
+ Returns information about a specific file.
+
+ This function returns information about a specific file,
+ including its file name, type, attributes, starting address, size and authentication status.
+ If the firmware volume is not memory mapped, then the Buffer member will be NULL.
+
+ @param FileHandle The handle of the file.
+ @param FileInfo Upon exit, points to the file's
+ information.
+
+ @retval EFI_SUCCESS File information was returned.
+ @retval EFI_INVALID_PARAMETER FileHandle does not
+ represent a valid file.
+ @retval EFI_INVALID_PARAMETER FileInfo is NULL.
+
+**/
+typedef
+EFI_STATUS
+(EFIAPI *EFI_PEI_FFS_GET_FILE_INFO2)(
+ IN EFI_PEI_FILE_HANDLE FileHandle,
+ OUT EFI_FV_FILE_INFO2 *FileInfo
+ );
+
///
/// The information of the FV volume.
///
@@ -813,6 +901,8 @@ struct _EFI_PEI_SERVICES {
EFI_PEI_FFS_GET_FILE_INFO FfsGetFileInfo;
EFI_PEI_FFS_GET_VOLUME_INFO FfsGetVolumeInfo;
EFI_PEI_REGISTER_FOR_SHADOW RegisterForShadow;
+ EFI_PEI_FFS_FIND_SECTION_DATA3 FindSectionData3;
+ EFI_PEI_FFS_GET_FILE_INFO2 FfsGetFileInfo2;
};
diff --git a/MdePkg/Include/Ppi/FirmwareVolume.h b/MdePkg/Include/Ppi/FirmwareVolume.h
index c8fc77b15..d8998fad1 100644
--- a/MdePkg/Include/Ppi/FirmwareVolume.h
+++ b/MdePkg/Include/Ppi/FirmwareVolume.h
@@ -1,7 +1,7 @@
/** @file
This file provides functions for accessing a memory-mapped firmware volume of a specific format.
- Copyright (c) 2006 - 2008, Intel Corporation. All rights reserved.<BR>
+ Copyright (c) 2006 - 2013, 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
@@ -154,6 +154,33 @@ EFI_STATUS
);
/**
+ Returns information about a specific file.
+
+ This function returns information about a specific
+ file, including its file name, type, attributes, starting
+ address, size and authentication status.
+
+ @param This Points to this instance of the
+ EFI_PEI_FIRMWARE_VOLUME_PPI.
+ @param FileHandle Handle of the file.
+ @param FileInfo Upon exit, points to the file's
+ information.
+
+ @retval EFI_SUCCESS File information returned.
+ @retval EFI_INVALID_PARAMETER If FileHandle does not
+ represent a valid file.
+ @retval EFI_INVALID_PARAMETER If FileInfo is NULL.
+
+**/
+typedef
+EFI_STATUS
+(EFIAPI *EFI_PEI_FV_GET_FILE_INFO2)(
+ IN CONST EFI_PEI_FIRMWARE_VOLUME_PPI *This,
+ IN EFI_PEI_FILE_HANDLE FileHandle,
+ OUT EFI_FV_FILE_INFO2 *FileInfo
+);
+
+/**
This function returns information about the firmware volume.
@param This Points to this instance of the
@@ -203,6 +230,43 @@ EFI_STATUS
OUT VOID **SectionData
);
+/**
+ Find the next matching section in the firmware file.
+
+ This service enables PEI modules to discover sections
+ of a given instance and type within a valid file.
+
+ @param This Points to this instance of the
+ EFI_PEI_FIRMWARE_VOLUME_PPI.
+ @param SearchType A filter to find only sections of this
+ type.
+ @param SearchInstance A filter to find the specific instance
+ of sections.
+ @param FileHandle Handle of firmware file in which to
+ search.
+ @param SectionData Updated upon return to point to the
+ section found.
+ @param AuthenticationStatus Updated upon return to point to the
+ authentication status for this section.
+
+ @retval EFI_SUCCESS Section was found.
+ @retval EFI_NOT_FOUND Section of the specified type was not
+ found. SectionData contains NULL.
+**/
+typedef
+EFI_STATUS
+(EFIAPI *EFI_PEI_FV_FIND_SECTION2)(
+ IN CONST EFI_PEI_FIRMWARE_VOLUME_PPI *This,
+ IN EFI_SECTION_TYPE SearchType,
+ IN UINTN SearchInstance,
+ IN EFI_PEI_FILE_HANDLE FileHandle,
+ OUT VOID **SectionData,
+ OUT UINT32 *AuthenticationStatus
+);
+
+#define EFI_PEI_FIRMWARE_VOLUME_PPI_SIGNATURE SIGNATURE_32 ('P', 'F', 'V', 'P')
+#define EFI_PEI_FIRMWARE_VOLUME_PPI_REVISION 0x00010030
+
///
/// This PPI provides functions for accessing a memory-mapped firmware volume of a specific format.
///
@@ -213,6 +277,16 @@ struct _EFI_PEI_FIRMWARE_VOLUME_PPI {
EFI_PEI_FV_GET_FILE_INFO GetFileInfo;
EFI_PEI_FV_GET_INFO GetVolumeInfo;
EFI_PEI_FV_FIND_SECTION FindSectionByType;
+ EFI_PEI_FV_GET_FILE_INFO2 GetFileInfo2;
+ EFI_PEI_FV_FIND_SECTION2 FindSectionByType2;
+ ///
+ /// Signature is used to keep backward-compatibility, set to {'P','F','V','P'}.
+ ///
+ UINT32 Signature;
+ ///
+ /// Revision for further extension.
+ ///
+ UINT32 Revision;
};
extern EFI_GUID gEfiPeiFirmwareVolumePpiGuid;
diff --git a/MdePkg/Include/Ppi/FirmwareVolumeInfo2.h b/MdePkg/Include/Ppi/FirmwareVolumeInfo2.h
new file mode 100644
index 000000000..6cb66b3c3
--- /dev/null
+++ b/MdePkg/Include/Ppi/FirmwareVolumeInfo2.h
@@ -0,0 +1,72 @@
+/** @file
+ This file provides location, format and authentication status of a firmware volume.
+
+ Copyright (c) 2013, 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.
+
+ @par Revision Reference:
+ This PPI is introduced in PI Version 1.3 errata.
+
+**/
+
+#ifndef __EFI_PEI_FIRMWARE_VOLUME_INFO2_H__
+#define __EFI_PEI_FIRMWARE_VOLUME_INFO2_H__
+
+
+
+#define EFI_PEI_FIRMWARE_VOLUME_INFO2_PPI_GUID \
+{ 0xea7ca24b, 0xded5, 0x4dad, { 0xa3, 0x89, 0xbf, 0x82, 0x7e, 0x8f, 0x9b, 0x38 } }
+
+typedef struct _EFI_PEI_FIRMWARE_VOLUME_INFO2_PPI EFI_PEI_FIRMWARE_VOLUME_INFO2_PPI;
+
+///
+/// This PPI describes the location and format of a firmware volume.
+/// The FvFormat can be EFI_FIRMWARE_FILE_SYSTEM2_GUID or the GUID for
+/// a user-defined format. The EFI_FIRMWARE_FILE_SYSTEM2_GUID is
+/// the PI Firmware Volume format.
+///
+struct _EFI_PEI_FIRMWARE_VOLUME_INFO2_PPI {
+ ///
+ /// Unique identifier of the format of the memory-mapped firmware volume.
+ ///
+ EFI_GUID FvFormat;
+ ///
+ /// Points to a buffer which allows the EFI_PEI_FIRMWARE_VOLUME_PPI to process
+ /// the volume. The format of this buffer is specific to the FvFormat.
+ /// For memory-mapped firmware volumes, this typically points to the first byte
+ /// of the firmware volume.
+ ///
+ VOID *FvInfo;
+ ///
+ /// Size of the data provided by FvInfo. For memory-mapped firmware volumes,
+ /// this is typically the size of the firmware volume.
+ ///
+ UINT32 FvInfoSize;
+ ///
+ /// If the firmware volume originally came from a firmware file, then these
+ /// point to the parent firmware volume name and firmware volume file.
+ /// If it did not originally come from a firmware file, these should be NULL.
+ ///
+ EFI_GUID *ParentFvName;
+ ///
+ /// If the firmware volume originally came from a firmware file, then these
+ /// point to the parent firmware volume name and firmware volume file.
+ /// If it did not originally come from a firmware file, these should be NULL.
+ ///
+ EFI_GUID *ParentFileName;
+ ///
+ /// Authentication Status.
+ ///
+ UINT32 AuthenticationStatus;
+};
+
+extern EFI_GUID gEfiPeiFirmwareVolumeInfo2PpiGuid;
+
+#endif
+
diff --git a/MdePkg/Include/Ppi/LoadFile.h b/MdePkg/Include/Ppi/LoadFile.h
index fdc9ce260..03bfb32af 100644
--- a/MdePkg/Include/Ppi/LoadFile.h
+++ b/MdePkg/Include/Ppi/LoadFile.h
@@ -1,7 +1,7 @@
/** @file
Load image file from fv to memory.
- Copyright (c) 2006 - 2011, Intel Corporation. All rights reserved.<BR>
+ Copyright (c) 2006 - 2013, 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
@@ -47,7 +47,10 @@ typedef struct _EFI_PEI_LOAD_FILE_PPI EFI_PEI_LOAD_FILE_PPI;
@retval EFI_INVALID_PARAMETER EntryPoint was NULL.
@retval EFI_UNSUPPORTED An image requires relocations or is not
memory mapped.
-
+ @retval EFI_WARN_BUFFER_TOO_SMALL
+ There is not enough heap to allocate the requested size.
+ This will not prevent the XIP image from being invoked.
+
**/
typedef
EFI_STATUS
diff --git a/MdePkg/Include/Ppi/Security2.h b/MdePkg/Include/Ppi/Security2.h
index eed56d753..f7aabfca3 100644
--- a/MdePkg/Include/Ppi/Security2.h
+++ b/MdePkg/Include/Ppi/Security2.h
@@ -5,7 +5,7 @@
policy to the PEI Foundation, namely the case of a PEIM's authentication
state being returned during the PEI section extraction process.
- Copyright (c) 2006 - 2008, Intel Corporation. All rights reserved.<BR>
+ Copyright (c) 2006 - 2013, 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,7 +75,7 @@ EFI_STATUS
IN CONST EFI_PEI_SECURITY2_PPI *This,
IN UINT32 AuthenticationStatus,
IN EFI_PEI_FV_HANDLE FvHandle,
- IN EFI_PEI_FV_HANDLE FileHandle,
+ IN EFI_PEI_FILE_HANDLE FileHandle,
IN OUT BOOLEAN *DeferExecution
);
diff --git a/MdePkg/Include/Protocol/DriverHealth.h b/MdePkg/Include/Protocol/DriverHealth.h
index a4c92fbd9..5116162cd 100644
--- a/MdePkg/Include/Protocol/DriverHealth.h
+++ b/MdePkg/Include/Protocol/DriverHealth.h
@@ -20,7 +20,7 @@
may then need to be reconnected or the system may need to be rebooted for the
configuration changes to take affect.
- Copyright (c) 2009 - 2011, Intel Corporation. All rights reserved.<BR>
+ Copyright (c) 2009 - 2013, 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
@@ -74,20 +74,10 @@ typedef struct {
@param[in] Limit The maximum value of Value for the current repair operation.
For example, a driver that wants to specify progress in
percent would use a Limit value of 100.
-
- @retval EFI_SUCCESS An attempt to repair the controller specified by
- ControllerHandle and ChildHandle was performed. The
- result of the repair operation can bet determined by
- calling GetHealthStatus().
- @retval EFI_UNSUPPORTED The driver specified by This is not currently managing the
- controller specified by ControllerHandle and
- ChildHandle.
- @retval EFI_OUT_OF_RESOURCES There are not enough resources to perform the repair operation.
-
**/
typedef
EFI_STATUS
-(EFIAPI *EFI_DRIVER_HEALTH_REPAIR_PROGRESS_NOTIFY)(
+(EFIAPI *EFI_DRIVER_HEALTH_REPAIR_NOTIFY)(
IN UINTN Value,
IN UINTN Limit
);
@@ -193,17 +183,17 @@ EFI_STATUS
Performs a repair operation on a controller in the platform. This function can
optionally report repair progress information back to the platform.
- @param[in] This A pointer to the EFI_DRIVER_HEALTH_PROTOCOL instance.
- @param[in] ControllerHandle The handle of the controller to repair.
- @param[in] ChildHandle The handle of the child controller to repair. This is
- an optional parameter that may be NULL. It will be NULL
- for device drivers. It will also be NULL for bus
- drivers when an attempt is made to repair a bus controller.
- If will not be NULL when an attempt is made to repair a
- child controller produced by the driver.
- @param[in] ProgressNotification A notification function that may be used by a driver to
- report the progress of the repair operation. This is
- an optional parameter that may be NULL.
+ @param[in] This A pointer to the EFI_DRIVER_HEALTH_PROTOCOL instance.
+ @param[in] ControllerHandle The handle of the controller to repair.
+ @param[in] ChildHandle The handle of the child controller to repair. This is
+ an optional parameter that may be NULL. It will be NULL
+ for device drivers. It will also be NULL for bus
+ drivers when an attempt is made to repair a bus controller.
+ If will not be NULL when an attempt is made to repair a
+ child controller produced by the driver.
+ @param[in] RepairNotify A notification function that may be used by a driver to
+ report the progress of the repair operation. This is
+ an optional parameter that may be NULL.
@retval EFI_SUCCESS An attempt to repair the controller specified by
@@ -222,8 +212,8 @@ EFI_STATUS
(EFIAPI *EFI_DRIVER_HEALTH_REPAIR)(
IN EFI_DRIVER_HEALTH_PROTOCOL *This,
IN EFI_HANDLE ControllerHandle,
- IN EFI_HANDLE ChildHandle OPTIONAL,
- IN EFI_DRIVER_HEALTH_REPAIR_PROGRESS_NOTIFY ProgressNotification OPTIONAL
+ IN EFI_HANDLE ChildHandle OPTIONAL,
+ IN EFI_DRIVER_HEALTH_REPAIR_NOTIFY RepairNotify OPTIONAL
);
///
diff --git a/MdePkg/Include/Protocol/ScsiIo.h b/MdePkg/Include/Protocol/ScsiIo.h
index 707aa3f7e..d605b18e0 100644
--- a/MdePkg/Include/Protocol/ScsiIo.h
+++ b/MdePkg/Include/Protocol/ScsiIo.h
@@ -4,7 +4,7 @@
services environment to access SCSI devices. In particular, functions for
managing devices on SCSI buses are defined here.
- Copyright (c) 2006 - 2008, Intel Corporation. All rights reserved.<BR>
+ Copyright (c) 2006 - 2013, 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,6 +29,31 @@
typedef struct _EFI_SCSI_IO_PROTOCOL EFI_SCSI_IO_PROTOCOL;
//
+// SCSI Device type information, defined in the SCSI Primary Commands standard (e.g., SPC-4)
+//
+#define EFI_SCSI_IO_TYPE_DISK 0x00 ///< Disk device
+#define EFI_SCSI_IO_TYPE_TAPE 0x01 ///< Tape device
+#define EFI_SCSI_IO_TYPE_PRINTER 0x02 ///< Printer
+#define EFI_SCSI_IO_TYPE_PROCESSOR 0x03 ///< Processor
+#define EFI_SCSI_IO_TYPE_WORM 0x04 ///< Write-once read-multiple
+#define EFI_SCSI_IO_TYPE_CDROM 0x05 ///< CD or DVD device
+#define EFI_SCSI_IO_TYPE_SCANNER 0x06 ///< Scanner device
+#define EFI_SCSI_IO_TYPE_OPTICAL 0x07 ///< Optical memory device
+#define EFI_SCSI_IO_TYPE_MEDIUMCHANGER 0x08 ///< Medium Changer device
+#define EFI_SCSI_IO_TYPE_COMMUNICATION 0x09 ///< Communications device
+#define MFI_SCSI_IO_TYPE_A 0x0A ///< Obsolete
+#define MFI_SCSI_IO_TYPE_B 0x0B ///< Obsolete
+#define MFI_SCSI_IO_TYPE_RAID 0x0C ///< Storage array controller device (e.g., RAID)
+#define MFI_SCSI_IO_TYPE_SES 0x0D ///< Enclosure services device
+#define MFI_SCSI_IO_TYPE_RBC 0x0E ///< Simplified direct-access device (e.g., magnetic disk)
+#define MFI_SCSI_IO_TYPE_OCRW 0x0F ///< Optical card reader/writer device
+#define MFI_SCSI_IO_TYPE_BRIDGE 0x10 ///< Bridge Controller Commands
+#define MFI_SCSI_IO_TYPE_OSD 0x11 ///< Object-based Storage Device
+#define EFI_SCSI_IO_TYPE_RESERVED_LOW 0x12 ///< Reserved (low)
+#define EFI_SCSI_IO_TYPE_RESERVED_HIGH 0x1E ///< Reserved (high)
+#define EFI_SCSI_IO_TYPE_UNKNOWN 0x1F ///< Unknown no device type
+
+//
// SCSI Data Direction definition
//
#define EFI_SCSI_IO_DATA_DIRECTION_READ 0
diff --git a/MdePkg/Include/Protocol/Timestamp.h b/MdePkg/Include/Protocol/Timestamp.h
new file mode 100644
index 000000000..9be72426e
--- /dev/null
+++ b/MdePkg/Include/Protocol/Timestamp.h
@@ -0,0 +1,101 @@
+/** @file
+ EFI Timestamp Protocol as defined in UEFI2.4 Specification.
+ Used to provide a platform independent interface for retrieving a high resolution timestamp counter.
+
+ Copyright (c) 2013, 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.
+
+ @par Revision Reference:
+ This Protocol is introduced in UEFI Specification 2.4
+
+**/
+
+#ifndef __EFI_TIME_STAMP_PROTOCOL_H__
+#define __EFI_TIME_STAMP_PROTOCOL_H__
+
+
+#define EFI_TIMESTAMP_PROTOCOL_GUID \
+ { 0xafbfde41, 0x2e6e, 0x4262, {0xba, 0x65, 0x62, 0xb9, 0x23, 0x6e, 0x54, 0x95 } }
+
+///
+/// Declare forward reference for the Time Stamp Protocol
+///
+typedef struct _EFI_TIMESTAMP_PROTOCOL EFI_TIMESTAMP_PROTOCOL;
+
+///
+/// EFI_TIMESTAMP_PROPERTIES
+///
+typedef struct {
+ ///
+ /// The frequency of the timestamp counter in Hz.
+ ///
+ UINT64 Frequency;
+ ///
+ /// The value that the timestamp counter ends with immediately before it rolls over.
+ /// For example, a 64-bit free running counter would have an EndValue of 0xFFFFFFFFFFFFFFFF.
+ /// A 24-bit free running counter would have an EndValue of 0xFFFFFF.
+ ///
+ UINT64 EndValue;
+} EFI_TIMESTAMP_PROPERTIES;
+
+/**
+ Retrieves the current value of a 64-bit free running timestamp counter.
+
+ The counter shall count up in proportion to the amount of time that has passed. The counter value
+ will always roll over to zero. The properties of the counter can be retrieved from GetProperties().
+ The caller should be prepared for the function to return the same value twice across successive calls.
+ The counter value will not go backwards other than when wrapping, as defined by EndValue in GetProperties().
+ The frequency of the returned timestamp counter value must remain constant. Power management operations that
+ affect clocking must not change the returned counter frequency. The quantization of counter value updates may
+ vary as long as the value reflecting time passed remains consistent.
+
+ @param None.
+
+ @retval The current value of the free running timestamp counter.
+
+**/
+typedef
+UINT64
+(EFIAPI *TIMESTAMP_GET)(
+ VOID
+ );
+
+/**
+ Obtains timestamp counter properties including frequency and value limits.
+
+ @param[out] Properties The properties of the timestamp counter.
+
+ @retval EFI_SUCCESS The properties were successfully retrieved.
+ @retval EFI_DEVICE_ERROR An error occurred trying to retrieve the properties of the timestamp
+ counter subsystem. Properties is not pedated.
+ @retval EFI_INVALID_PARAMETER Properties is NULL.
+
+**/
+typedef
+EFI_STATUS
+(EFIAPI *TIMESTAMP_GET_PROPERTIES)(
+ OUT EFI_TIMESTAMP_PROPERTIES *Properties
+ );
+
+
+
+///
+/// EFI_TIMESTAMP_PROTOCOL
+/// The protocol provides a platform independent interface for retrieving a high resolution
+/// timestamp counter.
+///
+struct _EFI_TIMESTAMP_PROTOCOL {
+ TIMESTAMP_GET GetTimestamp;
+ TIMESTAMP_GET_PROPERTIES GetProperties;
+};
+
+extern EFI_GUID gEfiTimestampProtocolGuid;
+
+#endif
+
diff --git a/MdePkg/Include/Protocol/TrEEProtocol.h b/MdePkg/Include/Protocol/TrEEProtocol.h
new file mode 100644
index 000000000..2f535348f
--- /dev/null
+++ b/MdePkg/Include/Protocol/TrEEProtocol.h
@@ -0,0 +1,265 @@
+/** @file
+ Ihis protocol is defined to abstract TPM2 hardware access in boot phase.
+
+Copyright (c) 2013, 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.
+
+**/
+
+#ifndef __TREE_H__
+#define __TREE_H__
+
+#include <IndustryStandard/UefiTcgPlatform.h>
+#include <IndustryStandard/Tpm20.h>
+
+#define EFI_TREE_PROTOCOL_GUID \
+ {0x607f766c, 0x7455, 0x42be, 0x93, 0x0b, 0xe4, 0xd7, 0x6d, 0xb2, 0x72, 0x0f}
+
+typedef struct _EFI_TREE_PROTOCOL EFI_TREE_PROTOCOL;
+
+typedef struct _TREE_VERSION {
+ UINT8 Major;
+ UINT8 Minor;
+} TREE_VERSION;
+
+typedef UINT32 TREE_EVENT_LOG_BITMAP;
+typedef UINT32 TREE_EVENT_LOG_FORMAT;
+
+#define TREE_EVENT_LOG_FORMAT_TCG_1_2 0x00000001
+
+typedef struct _TREE_BOOT_SERVICE_CAPABILITY {
+ //
+ // Allocated size of the structure passed in
+ //
+ UINT8 Size;
+ //
+ // Version of the TREE_BOOT_SERVICE_CAPABILITY structure itself.
+ // For this version of the protocol, the Major version shall be set to 1
+ // and the Minor version shall be set to 0.
+ //
+ TREE_VERSION StructureVersion;
+ //
+ // Version of the TrEE protocol.
+ // For this version of the protocol, the Major version shall be set to 1
+ // and the Minor version shall be set to 0.
+ //
+ TREE_VERSION ProtocolVersion;
+ //
+ // Supported hash algorithms
+ //
+ UINT32 HashAlgorithmBitmap;
+ //
+ // Bitmap of supported event log formats
+ //
+ TREE_EVENT_LOG_BITMAP SupportedEventLogs;
+ //
+ // False = TrEE not present
+ //
+ BOOLEAN TrEEPresentFlag;
+ //
+ // Max size (in bytes) of a command that can be sent to the TrEE
+ //
+ UINT16 MaxCommandSize;
+ //
+ // Max size (in bytes) of a response that can be provided by the TrEE
+ //
+ UINT16 MaxResponseSize;
+ //
+ // 4-byte Vendor ID (see Trusted Computing Group, "TCG Vendor ID Registry,"
+ // Version 1.0, Revision 0.1, August 31, 2007, "TPM Capabilities Vendor ID" section)
+ //
+ UINT32 ManufacturerID;
+} TREE_BOOT_SERVICE_CAPABILITY_1_0;
+
+typedef TREE_BOOT_SERVICE_CAPABILITY_1_0 TREE_BOOT_SERVICE_CAPABILITY;
+
+#define TREE_BOOT_HASH_ALG_SHA1 0x00000001
+#define TREE_BOOT_HASH_ALG_SHA256 0x00000002
+#define TREE_BOOT_HASH_ALG_SHA384 0x00000004
+#define TREE_BOOT_HASH_ALG_SHA512 0x00000008
+
+//
+// This bit is shall be set when an event shall be extended but not logged.
+//
+#define TREE_EXTEND_ONLY 0x0000000000000001
+//
+// This bit shall be set when the intent is to measure a PE/COFF image.
+//
+#define PE_COFF_IMAGE 0x0000000000000010
+
+//#define EV_EFI_VARIABLE_DRIVER_CONFIG 0x80000001 // Defined in TCG
+//#define EV_EFI_ACTION 0x80000007 // Defined in TCG
+#define EV_EFI_VARIABLE_AUTHORITY 0x800000E0
+
+#define FIRMWARE_DEBUGGER_EVENT_STRING "UEFI Debug Mode"
+
+#pragma pack(1)
+typedef struct {
+ EFI_GUID VariableName;
+ UINT64 UnicodeNameLength; // The TCG Definition used UINTN
+ UINT64 VariableDataLength; // The TCG Definition used UINTN
+ CHAR16 UnicodeName[1];
+ INT8 VariableData[1];
+} EFI_VARIABLE_DATA_TREE;
+#pragma pack()
+
+typedef UINT32 TrEE_PCRINDEX;
+typedef UINT32 TrEE_EVENTTYPE;
+
+#define MAX_PCR_INDEX 23
+#define TREE_EVENT_HEADER_VERSION 1
+
+#pragma pack(1)
+
+typedef struct {
+ //
+ // Size of the event header itself (sizeof(TrEE_EVENT_HEADER)).
+ //
+ UINT32 HeaderSize;
+ //
+ // Header version. For this version of this specification, the value shall be 1.
+ //
+ UINT16 HeaderVersion;
+ //
+ // Index of the PCR that shall be extended (0 - 23).
+ //
+ TrEE_PCRINDEX PCRIndex;
+ //
+ // Type of the event that shall be extended (and optionally logged).
+ //
+ TrEE_EVENTTYPE EventType;
+} TrEE_EVENT_HEADER;
+
+typedef struct {
+ //
+ // Total size of the event including the Size component, the header and the Event data.
+ //
+ UINT32 Size;
+ TrEE_EVENT_HEADER Header;
+ UINT8 Event[1];
+} TrEE_EVENT;
+
+#pragma pack()
+
+/**
+ The EFI_TREE_PROTOCOL GetCapability function call provides protocol
+ capability information and state information about the TrEE.
+
+ @param[in] This Indicates the calling context
+ @param[out] ProtocolCapability The caller allocates memory for a TREE_BOOT_SERVICE_CAPABILITY
+ structure and sets the size field to the size of the structure allocated.
+ The callee fills in the fields with the EFI protocol capability information
+ and the current TrEE state information up to the number of fields which
+ fit within the size of the structure passed in.
+
+ @retval EFI_SUCCESS Operation completed successfully.
+ @retval EFI_DEVICE_ERROR The command was unsuccessful.
+ The ProtocolCapability variable will not be populated.
+ @retval EFI_INVALID_PARAMETER One or more of the parameters are incorrect.
+ The ProtocolCapability variable will not be populated.
+ @retval EFI_BUFFER_TOO_SMALL The ProtocolCapability variable is too small to hold the full response.
+ It will be partially populated (required Size field will be set).
+**/
+typedef
+EFI_STATUS
+(EFIAPI *EFI_TREE_GET_CAPABILITY) (
+ IN EFI_TREE_PROTOCOL *This,
+ IN OUT TREE_BOOT_SERVICE_CAPABILITY *ProtocolCapability
+ );
+
+/**
+ The EFI_TREE_PROTOCOL Get Event Log function call allows a caller to
+ retrieve the address of a given event log and its last entry.
+
+ @param[in] This Indicates the calling context
+ @param[in] EventLogFormat The type of the event log for which the information is requested.
+ @param[out] EventLogLocation A pointer to the memory address of the event log.
+ @param[out] EventLogLastEntry If the Event Log contains more than one entry, this is a pointer to the
+ address of the start of the last entry in the event log in memory.
+ @param[out] EventLogTruncated If the Event Log is missing at least one entry because an event would
+ have exceeded the area allocated for events, this value is set to TRUE.
+ Otherwise, the value will be FALSE and the Event Log will be complete.
+
+ @retval EFI_SUCCESS Operation completed successfully.
+ @retval EFI_INVALID_PARAMETER One or more of the parameters are incorrect
+ (e.g. asking for an event log whose format is not supported).
+**/
+typedef
+EFI_STATUS
+(EFIAPI *EFI_TREE_GET_EVENT_LOG) (
+ IN EFI_TREE_PROTOCOL *This,
+ IN TREE_EVENT_LOG_FORMAT EventLogFormat,
+ OUT EFI_PHYSICAL_ADDRESS *EventLogLocation,
+ OUT EFI_PHYSICAL_ADDRESS *EventLogLastEntry,
+ OUT BOOLEAN *EventLogTruncated
+ );
+
+/**
+ The EFI_TREE_PROTOCOL HashLogExtendEvent function call provides callers with
+ an opportunity to extend and optionally log events without requiring
+ knowledge of actual TPM commands.
+ The extend operation will occur even if this function cannot create an event
+ log entry (e.g. due to the event log being full).
+
+ @param[in] This Indicates the calling context
+ @param[in] Flags Bitmap providing additional information.
+ @param[in] DataToHash Physical address of the start of the data buffer to be hashed.
+ @param[in] DataToHashLen The length in bytes of the buffer referenced by DataToHash.
+ @param[in] Event Pointer to data buffer containing information about the event.
+
+ @retval EFI_SUCCESS Operation completed successfully.
+ @retval EFI_DEVICE_ERROR The command was unsuccessful.
+ @retval EFI_VOLUME_FULL The extend operation occurred, but the event could not be written to one or more event logs.
+ @retval EFI_INVALID_PARAMETER One or more of the parameters are incorrect.
+ @retval EFI_UNSUPPORTED The PE/COFF image type is not supported.
+**/
+typedef
+EFI_STATUS
+(EFIAPI * EFI_TREE_HASH_LOG_EXTEND_EVENT) (
+ IN EFI_TREE_PROTOCOL *This,
+ IN UINT64 Flags,
+ IN EFI_PHYSICAL_ADDRESS DataToHash,
+ IN UINT64 DataToHashLen,
+ IN TrEE_EVENT *Event
+ );
+
+/**
+ This service enables the sending of commands to the TrEE.
+
+ @param[in] This Indicates the calling context
+ @param[in] InputParameterBlockSize Size of the TrEE input parameter block.
+ @param[in] InputParameterBlock Pointer to the TrEE input parameter block.
+ @param[in] OutputParameterBlockSize Size of the TrEE output parameter block.
+ @param[in] OutputParameterBlock Pointer to the TrEE output parameter block.
+
+ @retval EFI_SUCCESS The command byte stream was successfully sent to the device and a response was successfully received.
+ @retval EFI_DEVICE_ERROR The command was not successfully sent to the device or a response was not successfully received from the device.
+ @retval EFI_INVALID_PARAMETER One or more of the parameters are incorrect.
+ @retval EFI_BUFFER_TOO_SMALL The output parameter block is too small.
+**/
+typedef
+EFI_STATUS
+(EFIAPI *EFI_TREE_SUBMIT_COMMAND) (
+ IN EFI_TREE_PROTOCOL *This,
+ IN UINT32 InputParameterBlockSize,
+ IN UINT8 *InputParameterBlock,
+ IN UINT32 OutputParameterBlockSize,
+ IN UINT8 *OutputParameterBlock
+ );
+
+struct _EFI_TREE_PROTOCOL {
+ EFI_TREE_GET_CAPABILITY GetCapability;
+ EFI_TREE_GET_EVENT_LOG GetEventLog;
+ EFI_TREE_HASH_LOG_EXTEND_EVENT HashLogExtendEvent;
+ EFI_TREE_SUBMIT_COMMAND SubmitCommand;
+};
+
+extern EFI_GUID gEfiTrEEProtocolGuid;
+
+#endif
diff --git a/MdePkg/Include/Uefi/UefiSpec.h b/MdePkg/Include/Uefi/UefiSpec.h
index b44463104..619246b61 100644
--- a/MdePkg/Include/Uefi/UefiSpec.h
+++ b/MdePkg/Include/Uefi/UefiSpec.h
@@ -1671,7 +1671,11 @@ typedef struct {
@retval EFI_INVALID_PARAMETER CapsuleCount is 0.
@retval EFI_DEVICE_ERROR The capsule update was started, but failed due to a device error.
@retval EFI_UNSUPPORTED The capsule type is not supported on this platform.
- @retval EFI_OUT_OF_RESOURCES There were insufficient resources to process the capsule.
+ @retval EFI_OUT_OF_RESOURCES When ExitBootServices() has been previously called this error indicates the capsule
+ is compatible with this platform but is not capable of being submitted or processed
+ in runtime. The caller may resubmit the capsule prior to ExitBootServices().
+ @retval EFI_OUT_OF_RESOURCES When ExitBootServices() has not been previously called then this error indicates
+ the capsule is compatible with this platform but there are insufficient resources to process.
**/
typedef
@@ -1698,7 +1702,11 @@ EFI_STATUS
@retval EFI_UNSUPPORTED The capsule type is not supported on this platform, and
MaximumCapsuleSize and ResetType are undefined.
@retval EFI_INVALID_PARAMETER MaximumCapsuleSize is NULL.
- @retval EFI_OUT_OF_RESOURCES There were insufficient resources to process the query request.
+ @retval EFI_OUT_OF_RESOURCES When ExitBootServices() has been previously called this error indicates the capsule
+ is compatible with this platform but is not capable of being submitted or processed
+ in runtime. The caller may resubmit the capsule prior to ExitBootServices().
+ @retval EFI_OUT_OF_RESOURCES When ExitBootServices() has not been previously called then this error indicates
+ the capsule is compatible with this platform but there are insufficient resources to process.
**/
typedef
@@ -1744,7 +1752,11 @@ EFI_STATUS
//
// Firmware should stop at a firmware user interface on next boot
//
-#define EFI_OS_INDICATIONS_BOOT_TO_FW_UI 0x0000000000000001
+#define EFI_OS_INDICATIONS_BOOT_TO_FW_UI 0x0000000000000001
+#define EFI_OS_INDICATIONS_TIMESTAMP_REVOCATION 0x0000000000000002
+#define EFI_OS_INDICATIONS_FILE_CAPSULE_DELIVERY_SUPPORTED 0x0000000000000004
+#define EFI_OS_INDICATIONS_FMP_CAPSULE_SUPPORTED 0x0000000000000008
+#define EFI_OS_INDICATIONS_CAPSULE_RESULT_VAR_SUPPORTED 0x0000000000000010
//
// EFI Runtime Services Table
diff --git a/MdePkg/Library/PeiServicesLib/PeiServicesLib.c b/MdePkg/Library/PeiServicesLib/PeiServicesLib.c
index 835325cc3..3428addcc 100644
--- a/MdePkg/Library/PeiServicesLib/PeiServicesLib.c
+++ b/MdePkg/Library/PeiServicesLib/PeiServicesLib.c
@@ -1,7 +1,7 @@
/** @file
Implementation for PEI Services Library.
- Copyright (c) 2006 - 2010, Intel Corporation. All rights reserved.<BR>
+ Copyright (c) 2006 - 2013, 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
@@ -16,6 +16,7 @@
#include <PiPei.h>
#include <Ppi/FirmwareVolumeInfo.h>
+#include <Ppi/FirmwareVolumeInfo2.h>
#include <Guid/FirmwareFileSystem2.h>
#include <Library/PeiServicesLib.h>
@@ -24,15 +25,6 @@
#include <Library/MemoryAllocationLib.h>
#include <Library/BaseMemoryLib.h>
-
-GLOBAL_REMOVE_IF_UNREFERENCED CONST EFI_PEI_PPI_DESCRIPTOR mPpiListTemplate[] = {
- {
- (EFI_PEI_PPI_DESCRIPTOR_PPI | EFI_PEI_PPI_DESCRIPTOR_TERMINATE_LIST),
- &gEfiPeiFirmwareVolumeInfoPpiGuid,
- NULL
- }
-};
-
/**
This service enables a given PEIM to register an interface into the PEI Foundation.
@@ -310,6 +302,36 @@ PeiServicesFfsFindSectionData (
}
/**
+ This service enables PEIMs to discover sections of a given instance and type within a valid FFS file.
+
+ @param SectionType The value of the section type to find.
+ @param SectionInstance Section instance to find.
+ @param FileHandle A pointer to the file header that contains the set
+ of sections to be searched.
+ @param SectionData A pointer to the discovered section, if successful.
+ @param AuthenticationStatus A pointer to the authentication status for this section.
+
+ @retval EFI_SUCCESS The section was found.
+ @retval EFI_NOT_FOUND The section was not found.
+
+**/
+EFI_STATUS
+EFIAPI
+PeiServicesFfsFindSectionData3 (
+ IN EFI_SECTION_TYPE SectionType,
+ IN UINTN SectionInstance,
+ IN EFI_PEI_FILE_HANDLE FileHandle,
+ OUT VOID **SectionData,
+ OUT UINT32 *AuthenticationStatus
+ )
+{
+ CONST EFI_PEI_SERVICES **PeiServices;
+
+ PeiServices = GetPeiServicesTablePointer ();
+ return (*PeiServices)->FindSectionData3 (PeiServices, SectionType, SectionInstance, FileHandle, SectionData, AuthenticationStatus);
+}
+
+/**
This service enables PEIMs to register the permanent memory configuration
that has been initialized with the PEI Foundation.
@@ -459,6 +481,30 @@ PeiServicesFfsGetFileInfo (
return (*GetPeiServicesTablePointer())->FfsGetFileInfo (FileHandle, FileInfo);
}
+/**
+ This service is a wrapper for the PEI Service FfsGetFileInfo2(), except the pointer to the PEI Services
+ Table has been removed. See the Platform Initialization Pre-EFI Initialization Core Interface
+ Specification for details.
+
+ @param FileHandle The handle of the file.
+ @param FileInfo Upon exit, points to the file's
+ information.
+
+ @retval EFI_SUCCESS File information returned.
+ @retval EFI_INVALID_PARAMETER If FileHandle does not
+ represent a valid file.
+ @retval EFI_INVALID_PARAMETER FileInfo is NULL.
+
+**/
+EFI_STATUS
+EFIAPI
+PeiServicesFfsGetFileInfo2 (
+ IN CONST EFI_PEI_FILE_HANDLE FileHandle,
+ OUT EFI_FV_FILE_INFO2 *FileInfo
+ )
+{
+ return (*GetPeiServicesTablePointer())->FfsGetFileInfo2 (FileHandle, FileInfo);
+}
/**
This service is a wrapper for the PEI Service FfsFindByName(), except the pointer to the PEI Services
@@ -522,43 +568,46 @@ PeiServicesFfsGetVolumeInfo (
}
/**
- Install a EFI_PEI_FIRMWARE_VOLUME_INFO_PPI instance so the PEI Core will be notified about a new firmware volume.
-
- This function allocates, initializes, and installs a new EFI_PEI_FIRMWARE_VOLUME_INFO_PPI using
- the parameters passed in to initialize the fields of the EFI_PEI_FIRMWARE_VOLUME_INFO_PPI instance.
- If the resources can not be allocated for EFI_PEI_FIRMWARE_VOLUME_INFO_PPI, then ASSERT().
- If the EFI_PEI_FIRMWARE_VOLUME_INFO_PPI can not be installed, then ASSERT().
+ Install a EFI_PEI_FIRMWARE_VOLUME_INFO(2)_PPI instance so the PEI Core will be notified about a new firmware volume.
-
- @param FvFormat Unique identifier of the format of the memory-mapped
- firmware volume. This parameter is optional and
- may be NULL. If NULL is specified, the
+ This function allocates, initializes, and installs a new EFI_PEI_FIRMWARE_VOLUME_INFO(2)_PPI using
+ the parameters passed in to initialize the fields of the EFI_PEI_FIRMWARE_VOLUME_INFO(2)_PPI instance.
+ If the resources can not be allocated for EFI_PEI_FIRMWARE_VOLUME_INFO(2)_PPI, then ASSERT().
+ If the EFI_PEI_FIRMWARE_VOLUME_INFO(2)_PPI can not be installed, then ASSERT().
+
+ @param InstallFvInfoPpi Install FvInfo Ppi if it is TRUE. Otherwise, install FvInfo2 Ppi.
+ @param FvFormat Unique identifier of the format of the memory-mapped
+ firmware volume. This parameter is optional and
+ may be NULL. If NULL is specified, the
EFI_FIRMWARE_FILE_SYSTEM2_GUID format is assumed.
- @param FvInfo Points to a buffer which allows the
- EFI_PEI_FIRMWARE_VOLUME_PPI to process the volume.
- The format of this buffer is specific to the FvFormat.
- For memory-mapped firmware volumes, this typically
+ @param FvInfo Points to a buffer which allows the
+ EFI_PEI_FIRMWARE_VOLUME_PPI to process the volume.
+ The format of this buffer is specific to the FvFormat.
+ For memory-mapped firmware volumes, this typically
points to the first byte of the firmware volume.
- @param FvInfoSize The size, in bytes, of FvInfo. For memory-mapped
- firmware volumes, this is typically the size of
+ @param FvInfoSize The size, in bytes, of FvInfo. For memory-mapped
+ firmware volumes, this is typically the size of
the firmware volume.
- @param ParentFvName If the new firmware volume originated from a file
- in a different firmware volume, then this parameter
+ @param ParentFvName If the new firmware volume originated from a file
+ in a different firmware volume, then this parameter
specifies the GUID name of the originating firmware
volume. Otherwise, this parameter must be NULL.
- @param ParentFileName If the new firmware volume originated from a file
- in a different firmware volume, then this parameter
- specifies the GUID file name of the originating
+ @param ParentFileName If the new firmware volume originated from a file
+ in a different firmware volume, then this parameter
+ specifies the GUID file name of the originating
firmware file. Otherwise, this parameter must be NULL.
+ @param AuthenticationStatus Authentication Status, it will be ignored if InstallFvInfoPpi is TRUE.
**/
VOID
EFIAPI
-PeiServicesInstallFvInfoPpi (
+InternalPeiServicesInstallFvInfoPpi (
+ IN BOOLEAN InstallFvInfoPpi,
IN CONST EFI_GUID *FvFormat, OPTIONAL
IN CONST VOID *FvInfo,
IN UINT32 FvInfoSize,
IN CONST EFI_GUID *ParentFvName, OPTIONAL
- IN CONST EFI_GUID *ParentFileName OPTIONAL
+ IN CONST EFI_GUID *ParentFileName, OPTIONAL
+ IN UINT32 AuthenticationStatus
)
{
EFI_STATUS Status;
@@ -566,11 +615,26 @@ PeiServicesInstallFvInfoPpi (
EFI_PEI_PPI_DESCRIPTOR *FvInfoPpiDescriptor;
EFI_GUID *ParentFvNameValue;
EFI_GUID *ParentFileNameValue;
+ EFI_GUID *PpiGuid;
ParentFvNameValue = NULL;
ParentFileNameValue = NULL;
- FvInfoPpi = AllocateZeroPool (sizeof (EFI_PEI_FIRMWARE_VOLUME_INFO_PPI));
- ASSERT(FvInfoPpi != NULL);
+ if (InstallFvInfoPpi) {
+ //
+ // To install FvInfo Ppi.
+ //
+ FvInfoPpi = AllocateZeroPool (sizeof (EFI_PEI_FIRMWARE_VOLUME_INFO_PPI));
+ ASSERT (FvInfoPpi != NULL);
+ PpiGuid = &gEfiPeiFirmwareVolumeInfoPpiGuid;
+ } else {
+ //
+ // To install FvInfo2 Ppi.
+ //
+ FvInfoPpi = AllocateZeroPool (sizeof (EFI_PEI_FIRMWARE_VOLUME_INFO2_PPI));
+ ASSERT (FvInfoPpi != NULL);
+ ((EFI_PEI_FIRMWARE_VOLUME_INFO2_PPI *) FvInfoPpi)->AuthenticationStatus = AuthenticationStatus;
+ PpiGuid = &gEfiPeiFirmwareVolumeInfo2PpiGuid;
+ }
if (FvFormat != NULL) {
CopyGuid (&FvInfoPpi->FvFormat, FvFormat);
@@ -590,12 +654,100 @@ PeiServicesInstallFvInfoPpi (
FvInfoPpi->ParentFileName = ParentFileNameValue;
}
- FvInfoPpiDescriptor = AllocateCopyPool (sizeof(EFI_PEI_PPI_DESCRIPTOR), mPpiListTemplate);
+ FvInfoPpiDescriptor = AllocatePool (sizeof (EFI_PEI_PPI_DESCRIPTOR));
ASSERT (FvInfoPpiDescriptor != NULL);
+ FvInfoPpiDescriptor->Guid = PpiGuid;
+ FvInfoPpiDescriptor->Flags = EFI_PEI_PPI_DESCRIPTOR_PPI | EFI_PEI_PPI_DESCRIPTOR_TERMINATE_LIST;
FvInfoPpiDescriptor->Ppi = (VOID *) FvInfoPpi;
Status = PeiServicesInstallPpi (FvInfoPpiDescriptor);
ASSERT_EFI_ERROR (Status);
}
+/**
+ Install a EFI_PEI_FIRMWARE_VOLUME_INFO_PPI instance so the PEI Core will be notified about a new firmware volume.
+
+ This function allocates, initializes, and installs a new EFI_PEI_FIRMWARE_VOLUME_INFO_PPI using
+ the parameters passed in to initialize the fields of the EFI_PEI_FIRMWARE_VOLUME_INFO_PPI instance.
+ If the resources can not be allocated for EFI_PEI_FIRMWARE_VOLUME_INFO_PPI, then ASSERT().
+ If the EFI_PEI_FIRMWARE_VOLUME_INFO_PPI can not be installed, then ASSERT().
+
+ @param FvFormat Unique identifier of the format of the memory-mapped
+ firmware volume. This parameter is optional and
+ may be NULL. If NULL is specified, the
+ EFI_FIRMWARE_FILE_SYSTEM2_GUID format is assumed.
+ @param FvInfo Points to a buffer which allows the
+ EFI_PEI_FIRMWARE_VOLUME_PPI to process the volume.
+ The format of this buffer is specific to the FvFormat.
+ For memory-mapped firmware volumes, this typically
+ points to the first byte of the firmware volume.
+ @param FvInfoSize The size, in bytes, of FvInfo. For memory-mapped
+ firmware volumes, this is typically the size of
+ the firmware volume.
+ @param ParentFvName If the new firmware volume originated from a file
+ in a different firmware volume, then this parameter
+ specifies the GUID name of the originating firmware
+ volume. Otherwise, this parameter must be NULL.
+ @param ParentFileName If the new firmware volume originated from a file
+ in a different firmware volume, then this parameter
+ specifies the GUID file name of the originating
+ firmware file. Otherwise, this parameter must be NULL.
+**/
+VOID
+EFIAPI
+PeiServicesInstallFvInfoPpi (
+ IN CONST EFI_GUID *FvFormat, OPTIONAL
+ IN CONST VOID *FvInfo,
+ IN UINT32 FvInfoSize,
+ IN CONST EFI_GUID *ParentFvName, OPTIONAL
+ IN CONST EFI_GUID *ParentFileName OPTIONAL
+ )
+{
+ InternalPeiServicesInstallFvInfoPpi (TRUE, FvFormat, FvInfo, FvInfoSize, ParentFvName, ParentFileName, 0);
+}
+
+/**
+ Install a EFI_PEI_FIRMWARE_VOLUME_INFO2_PPI instance so the PEI Core will be notified about a new firmware volume.
+
+ This function allocates, initializes, and installs a new EFI_PEI_FIRMWARE_VOLUME_INFO2_PPI using
+ the parameters passed in to initialize the fields of the EFI_PEI_FIRMWARE_VOLUME_INFO2_PPI instance.
+ If the resources can not be allocated for EFI_PEI_FIRMWARE_VOLUME_INFO2_PPI, then ASSERT().
+ If the EFI_PEI_FIRMWARE_VOLUME_INFO2_PPI can not be installed, then ASSERT().
+
+ @param FvFormat Unique identifier of the format of the memory-mapped
+ firmware volume. This parameter is optional and
+ may be NULL. If NULL is specified, the
+ EFI_FIRMWARE_FILE_SYSTEM2_GUID format is assumed.
+ @param FvInfo Points to a buffer which allows the
+ EFI_PEI_FIRMWARE_VOLUME_PPI to process the volume.
+ The format of this buffer is specific to the FvFormat.
+ For memory-mapped firmware volumes, this typically
+ points to the first byte of the firmware volume.
+ @param FvInfoSize The size, in bytes, of FvInfo. For memory-mapped
+ firmware volumes, this is typically the size of
+ the firmware volume.
+ @param ParentFvName If the new firmware volume originated from a file
+ in a different firmware volume, then this parameter
+ specifies the GUID name of the originating firmware
+ volume. Otherwise, this parameter must be NULL.
+ @param ParentFileName If the new firmware volume originated from a file
+ in a different firmware volume, then this parameter
+ specifies the GUID file name of the originating
+ firmware file. Otherwise, this parameter must be NULL.
+ @param AuthenticationStatus Authentication Status
+**/
+VOID
+EFIAPI
+PeiServicesInstallFvInfo2Ppi (
+ IN CONST EFI_GUID *FvFormat, OPTIONAL
+ IN CONST VOID *FvInfo,
+ IN UINT32 FvInfoSize,
+ IN CONST EFI_GUID *ParentFvName, OPTIONAL
+ IN CONST EFI_GUID *ParentFileName, OPTIONAL
+ IN UINT32 AuthenticationStatus
+ )
+{
+ InternalPeiServicesInstallFvInfoPpi (FALSE, FvFormat, FvInfo, FvInfoSize, ParentFvName, ParentFileName, AuthenticationStatus);
+}
+
diff --git a/MdePkg/Library/PeiServicesLib/PeiServicesLib.inf b/MdePkg/Library/PeiServicesLib/PeiServicesLib.inf
index cd70de780..1806042a2 100644
--- a/MdePkg/Library/PeiServicesLib/PeiServicesLib.inf
+++ b/MdePkg/Library/PeiServicesLib/PeiServicesLib.inf
@@ -1,7 +1,7 @@
## @file
# PEI Services Library implementation.
#
-# Copyright (c) 2007 - 2010, Intel Corporation. All rights reserved.<BR>
+# Copyright (c) 2007 - 2013, 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
@@ -43,6 +43,7 @@
[Ppis]
gEfiPeiFirmwareVolumeInfoPpiGuid ## PRODUCES
+ gEfiPeiFirmwareVolumeInfo2PpiGuid ## PRODUCES
diff --git a/MdePkg/Library/UefiLib/UefiNotTiano.c b/MdePkg/Library/UefiLib/UefiNotTiano.c
index 1869c066c..9b95be65f 100644
--- a/MdePkg/Library/UefiLib/UefiNotTiano.c
+++ b/MdePkg/Library/UefiLib/UefiNotTiano.c
@@ -34,7 +34,7 @@ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
**/
VOID
EFIAPI
-InternalEmptyFuntion (
+InternalEmptyFunction (
IN EFI_EVENT Event,
IN VOID *Context
)
@@ -67,7 +67,7 @@ EfiCreateEventLegacyBoot (
{
return EfiCreateEventLegacyBootEx (
TPL_CALLBACK,
- InternalEmptyFuntion,
+ InternalEmptyFunction,
NULL,
LegacyBootEvent
);
@@ -101,7 +101,8 @@ EfiCreateEventLegacyBootEx (
OUT EFI_EVENT *LegacyBootEvent
)
{
- EFI_STATUS Status;
+ EFI_STATUS Status;
+ EFI_EVENT_NOTIFY WorkerNotifyFunction;
ASSERT (LegacyBootEvent != NULL);
@@ -114,10 +115,19 @@ EfiCreateEventLegacyBootEx (
//
// For UEFI 2.0 and the future use an Event Group
//
+ if (NotifyFunction == NULL) {
+ //
+ // CreateEventEx will check NotifyFunction is NULL or not and return error.
+ // Use dummy routine for the case NotifyFunction is NULL.
+ //
+ WorkerNotifyFunction = InternalEmptyFunction;
+ } else {
+ WorkerNotifyFunction = NotifyFunction;
+ }
Status = gBS->CreateEventEx (
EVT_NOTIFY_SIGNAL,
NotifyTpl,
- NotifyFunction,
+ WorkerNotifyFunction,
NotifyContext,
&gEfiEventLegacyBootGuid,
LegacyBootEvent
@@ -152,7 +162,7 @@ EfiCreateEventReadyToBoot (
{
return EfiCreateEventReadyToBootEx (
TPL_CALLBACK,
- InternalEmptyFuntion,
+ InternalEmptyFunction,
NULL,
ReadyToBootEvent
);
@@ -186,7 +196,8 @@ EfiCreateEventReadyToBootEx (
OUT EFI_EVENT *ReadyToBootEvent
)
{
- EFI_STATUS Status;
+ EFI_STATUS Status;
+ EFI_EVENT_NOTIFY WorkerNotifyFunction;
ASSERT (ReadyToBootEvent != NULL);
@@ -199,10 +210,19 @@ EfiCreateEventReadyToBootEx (
//
// For UEFI 2.0 and the future use an Event Group
//
+ if (NotifyFunction == NULL) {
+ //
+ // CreateEventEx will check NotifyFunction is NULL or not and return error.
+ // Use dummy routine for the case NotifyFunction is NULL.
+ //
+ WorkerNotifyFunction = InternalEmptyFunction;
+ } else {
+ WorkerNotifyFunction = NotifyFunction;
+ }
Status = gBS->CreateEventEx (
EVT_NOTIFY_SIGNAL,
NotifyTpl,
- NotifyFunction,
+ WorkerNotifyFunction,
NotifyContext,
&gEfiEventReadyToBootGuid,
ReadyToBootEvent
diff --git a/MdePkg/MdePkg.dec b/MdePkg/MdePkg.dec
index 16c278aec..7c85b2804 100644
--- a/MdePkg/MdePkg.dec
+++ b/MdePkg/MdePkg.dec
@@ -515,6 +515,12 @@
gEfiHashAlgorithmSha256NoPadGuid = { 0x8628752a, 0x6cb7, 0x4814, { 0x96, 0xfc, 0x24, 0xa8, 0x15, 0xac, 0x22, 0x26 }}
#
+ # GUIDs defined in UEFI2.4
+ #
+ ## Include/Guid/FmpCapsule.h
+ gEfiFmpCapsuleGuid = { 0x6dcbd5ed, 0xe82d, 0x4c44, {0xbd, 0xa1, 0x71, 0x94, 0x19, 0x9a, 0xd9, 0x2a }}
+
+ #
# GUID defined in PI1.0
#
## Include/Guid/AprioriFileName.h
@@ -589,6 +595,9 @@
#
## Include/Guid/EventGroup.h
gEfiEndOfDxeEventGroupGuid = { 0x2ce967a, 0xdd7e, 0x4ffc, { 0x9e, 0xe7, 0x81, 0xc, 0xf0, 0x47, 0x8, 0x80 }}
+
+ ## Include/Guid/FirmwareContentsSigned.h
+ gEfiFirmwareContentsSignedGuid = { 0xf9d89e8, 0x9259, 0x4f76, { 0xa5, 0xaf, 0xc, 0x89, 0xe3, 0x40, 0x23, 0xdf }}
[Guids.IA32, Guids.X64]
## Include/Guid/Cper.h
@@ -693,6 +702,9 @@
## Include/Ppi/I2cMaster.h
gEfiPeiI2cMasterPpiGuid = { 0xb3bfab9b, 0x9f9c, 0x4e8b, { 0xad, 0x37, 0x7f, 0x8c, 0x51, 0xfc, 0x62, 0x80 }}
+ ## Include/Ppi/FirmwareVolumeInfo2.h
+ gEfiPeiFirmwareVolumeInfo2PpiGuid = { 0xea7ca24b, 0xded5, 0x4dad, { 0xa3, 0x89, 0xbf, 0x82, 0x7e, 0x8f, 0x9b, 0x38 } }
+
[Protocols]
#
# Protocols defined in PI1.0.
@@ -1175,6 +1187,9 @@
## Include/Protocol/TcgService.h
gEfiTcgProtocolGuid = { 0xf541796d, 0xa62e, 0x4954, { 0xa7, 0x75, 0x95, 0x84, 0xf6, 0x1b, 0x9c, 0xdd }}
+ ## Include/Protocol/TrEEProtocol.h
+ gEfiTrEEProtocolGuid = {0x607f766c, 0x7455, 0x42be, { 0x93, 0x0b, 0xe4, 0xd7, 0x6d, 0xb2, 0x72, 0x0f }}
+
## Include/Protocol/FormBrowser2.h
gEfiFormBrowser2ProtocolGuid = {0xb9d4c360, 0xbcfb, 0x4f9b, {0x92, 0x98, 0x53, 0xc1, 0x36, 0x98, 0x22, 0x58}}
@@ -1301,6 +1316,9 @@
## Include/Protocol/DiskIo2.h
gEfiDiskIo2ProtocolGuid = { 0x151c8eae, 0x7f2c, 0x472c, { 0x9e, 0x54, 0x98, 0x28, 0x19, 0x4f, 0x6a, 0x88 }}
+ ## Include/Protocol/Timestamp.h
+ gEfiTimestampProtocolGuid = { 0xafbfde41, 0x2e6e, 0x4262, {0xba, 0x65, 0x62, 0xb9, 0x23, 0x6e, 0x54, 0x95 }}
+
[PcdsFeatureFlag]
## If TRUE, the component name protocol will not be installed.
gEfiMdePkgTokenSpaceGuid.PcdComponentNameDisable|FALSE|BOOLEAN|0x0000000d
diff --git a/NetworkPkg/IScsiDxe/IScsiProto.c b/NetworkPkg/IScsiDxe/IScsiProto.c
index e7493c61f..8c0bbec06 100644
--- a/NetworkPkg/IScsiDxe/IScsiProto.c
+++ b/NetworkPkg/IScsiDxe/IScsiProto.c
@@ -259,15 +259,16 @@ IScsiCreateConnection (
CopyMem (&Tcp4IoConfig->Gateway, &NvData->Gateway, sizeof (EFI_IPv4_ADDRESS));
CopyMem (&Tcp4IoConfig->RemoteIp, &NvData->TargetIp, sizeof (EFI_IPv4_ADDRESS));
- Tcp4IoConfig->RemotePort = NvData->TargetPort;
- Tcp4IoConfig->ActiveFlag = TRUE;
-
+ Tcp4IoConfig->RemotePort = NvData->TargetPort;
+ Tcp4IoConfig->ActiveFlag = TRUE;
+ Tcp4IoConfig->StationPort = 0;
} else {
Tcp6IoConfig = &TcpIoConfig.Tcp6IoConfigData;
CopyMem (&Tcp6IoConfig->RemoteIp, &NvData->TargetIp, sizeof (EFI_IPv6_ADDRESS));
- Tcp6IoConfig->RemotePort = NvData->TargetPort;
- Tcp6IoConfig->ActiveFlag = TRUE;
+ Tcp6IoConfig->RemotePort = NvData->TargetPort;
+ Tcp6IoConfig->ActiveFlag = TRUE;
+ Tcp6IoConfig->StationPort = 0;
}
//
@@ -2851,7 +2852,8 @@ IScsiExecuteScsiCommand (
Timeout = 0;
if (Session->State != SESSION_STATE_LOGGED_IN) {
- return EFI_DEVICE_ERROR;
+ Status = EFI_DEVICE_ERROR;
+ goto ON_EXIT;
}
Conn = NET_LIST_USER_STRUCT_S (
@@ -3025,7 +3027,7 @@ IScsiSessionReinstatement (
{
EFI_STATUS Status;
- ASSERT (Session->State == SESSION_STATE_LOGGED_IN);
+ ASSERT (Session->State != SESSION_STATE_FREE);
//
// Abort the session and re-init it.
diff --git a/NetworkPkg/UefiPxeBcDxe/PxeBcImpl.c b/NetworkPkg/UefiPxeBcDxe/PxeBcImpl.c
index 07f2b6cfc..15cda8cf6 100644
--- a/NetworkPkg/UefiPxeBcDxe/PxeBcImpl.c
+++ b/NetworkPkg/UefiPxeBcDxe/PxeBcImpl.c
@@ -612,7 +612,7 @@ EfiPxeBcDiscover (
if (Index != Info->IpCnt) {
//
// It's invalid if the first server doesn't accecpt any response
- // and meanwhile any of the rest servers accept any reponse.
+ // but any of the other servers does accept any response.
//
Status = EFI_INVALID_PARAMETER;
goto ON_EXIT;
diff --git a/Nt32Pkg/CpuRuntimeDxe/Cpu.c b/Nt32Pkg/CpuRuntimeDxe/Cpu.c
index d15ac989e..9e7dfbb29 100644
--- a/Nt32Pkg/CpuRuntimeDxe/Cpu.c
+++ b/Nt32Pkg/CpuRuntimeDxe/Cpu.c
@@ -1,6 +1,6 @@
/**@file
-Copyright (c) 2006 - 2011, Intel Corporation. All rights reserved.<BR>
+Copyright (c) 2006 - 2013, 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
@@ -467,7 +467,7 @@ Returns:
ASSERT (CpuVerStrLen <= SMBIOS_STRING_MAX_LENGTH);
- TotalSize = sizeof(SMBIOS_TABLE_TYPE4) + CpuVerStrLen + 1 + 1;
+ TotalSize = (UINT32)(sizeof(SMBIOS_TABLE_TYPE4) + CpuVerStrLen + 1 + 1);
SmbiosRecord = AllocatePool(TotalSize);
ZeroMem(SmbiosRecord, TotalSize);
diff --git a/Nt32Pkg/CpuRuntimeDxe/CpuIo.c b/Nt32Pkg/CpuRuntimeDxe/CpuIo.c
index 7f171e609..9c3478f0a 100644
--- a/Nt32Pkg/CpuRuntimeDxe/CpuIo.c
+++ b/Nt32Pkg/CpuRuntimeDxe/CpuIo.c
@@ -1,6 +1,6 @@
/**@file
-Copyright (c) 2006 - 2010, Intel Corporation. All rights reserved.<BR>
+Copyright (c) 2006 - 2013, 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
@@ -326,11 +326,11 @@ Returns:
}
Width = (EFI_CPU_IO_PROTOCOL_WIDTH)(Width & 0x03);
- if (Address - 1 + (1 << Width) * Count > Limit) {
+ if (Address - 1 + ((UINTN)1 << Width) * Count > Limit) {
return EFI_UNSUPPORTED;
}
- AlignMask = (1 << Width) - 1;
+ AlignMask = ((UINTN)1 << Width) - 1;
if ((UINTN) Buffer & AlignMask) {
return EFI_UNSUPPORTED;
}
diff --git a/Nt32Pkg/FvbServicesRuntimeDxe/FWBlockService.c b/Nt32Pkg/FvbServicesRuntimeDxe/FWBlockService.c
index 00a5f18ef..3400516f0 100644
--- a/Nt32Pkg/FvbServicesRuntimeDxe/FWBlockService.c
+++ b/Nt32Pkg/FvbServicesRuntimeDxe/FWBlockService.c
@@ -950,7 +950,7 @@ Returns:
//
// Check input parameters
//
- if (NumOfLba == 0 || (StartingLba + NumOfLba) > NumOfBlocks) {
+ if ((NumOfLba == 0) || ((StartingLba + NumOfLba) > NumOfBlocks)) {
VA_END (args);
return EFI_INVALID_PARAMETER;
}
diff --git a/Nt32Pkg/Include/Common/WinNTInclude.h b/Nt32Pkg/Include/Common/WinNTInclude.h
index 7d62c9d55..3f4fb2373 100644
--- a/Nt32Pkg/Include/Common/WinNTInclude.h
+++ b/Nt32Pkg/Include/Common/WinNTInclude.h
@@ -1,6 +1,6 @@
/**@file
-Copyright (c) 2006, Intel Corporation. All rights reserved.<BR>
+Copyright (c) 2006 - 2013, 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,9 +34,11 @@ Abstract:
#define GUID _WINNT_DUP_GUID_____
#define _LIST_ENTRY _WINNT_DUP_LIST_ENTRY_FORWARD
#define LIST_ENTRY _WINNT_DUP_LIST_ENTRY
+#if defined (MDE_CPU_IA32)
#define InterlockedIncrement _WINNT_DUP_InterlockedIncrement
#define InterlockedDecrement _WINNT_DUP_InterlockedDecrement
#define InterlockedCompareExchange64 _WINNT_DUP_InterlockedCompareExchange64
+#endif
#undef UNALIGNED
#undef CONST
#undef VOID
@@ -45,7 +47,9 @@ Abstract:
// WQBugBug: This typedef is to make "windows.h" buildable.
// It should be removed after the root cause why
// size_t is undefined when go into the line below is found.
+#if defined (MDE_CPU_IA32)
typedef UINT32 size_t ;
+#endif
#include "windows.h"
diff --git a/Nt32Pkg/Library/DxeNt32OemHookStatusCodeLib/Nt32OemHookStatusCodeLib.c b/Nt32Pkg/Library/DxeNt32OemHookStatusCodeLib/Nt32OemHookStatusCodeLib.c
index b024a9157..e6f072e99 100644
--- a/Nt32Pkg/Library/DxeNt32OemHookStatusCodeLib/Nt32OemHookStatusCodeLib.c
+++ b/Nt32Pkg/Library/DxeNt32OemHookStatusCodeLib/Nt32OemHookStatusCodeLib.c
@@ -1,7 +1,7 @@
/** @file
OEM hook status code library functions with no library constructor/destructor
- Copyright (c) 2006 - 2010, Intel Corporation. All rights reserved.<BR>
+ Copyright (c) 2006 - 2013, 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
@@ -145,7 +145,7 @@ OemHookStatusCodeReport (
mWinNt->WriteFile (
mStdOut,
Buffer,
- CharCount,
+ (DWORD)CharCount,
(LPDWORD)&CharCount,
NULL
);
@@ -228,7 +228,7 @@ OemHookStatusCodeReport (
mWinNt->WriteFile (
mStdOut,
Buffer,
- CharCount,
+ (DWORD)CharCount,
(LPDWORD)&CharCount,
NULL
);
diff --git a/Nt32Pkg/Library/Nt32PeiPeCoffGetEntryPointLib/PeCoffGetEntryPoint.c b/Nt32Pkg/Library/Nt32PeiPeCoffGetEntryPointLib/PeCoffGetEntryPoint.c
index cacd78db1..5ae0b25c3 100644
--- a/Nt32Pkg/Library/Nt32PeiPeCoffGetEntryPointLib/PeCoffGetEntryPoint.c
+++ b/Nt32Pkg/Library/Nt32PeiPeCoffGetEntryPointLib/PeCoffGetEntryPoint.c
@@ -1,6 +1,6 @@
/**@file
-Copyright (c) 2006 - 2010, Intel Corporation. All rights reserved.<BR>
+Copyright (c) 2006 - 2013, 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
@@ -319,6 +319,6 @@ PeCoffGetSizeOfHeaders (
SizeOfHeaders = 0;
}
- return SizeOfHeaders;
+ return (UINT32) SizeOfHeaders;
}
diff --git a/Nt32Pkg/Library/PeiNt32OemHookStatusCodeLib/Nt32OemHookStatusCodeLib.c b/Nt32Pkg/Library/PeiNt32OemHookStatusCodeLib/Nt32OemHookStatusCodeLib.c
index 882d1c4f4..4e3768340 100644
--- a/Nt32Pkg/Library/PeiNt32OemHookStatusCodeLib/Nt32OemHookStatusCodeLib.c
+++ b/Nt32Pkg/Library/PeiNt32OemHookStatusCodeLib/Nt32OemHookStatusCodeLib.c
@@ -1,7 +1,7 @@
/** @file
OEM hook status code library functions with no library constructor/destructor
- Copyright (c) 2006 - 2010, Intel Corporation. All rights reserved.<BR>
+ Copyright (c) 2006 - 2013, 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
@@ -154,7 +154,7 @@ OemHookStatusCodeReport (
mWinNt->WriteFile (
mStdOut,
Buffer,
- CharCount,
+ (DWORD)CharCount,
(LPDWORD)&CharCount,
NULL
);
@@ -237,7 +237,7 @@ OemHookStatusCodeReport (
mWinNt->WriteFile (
mStdOut,
Buffer,
- CharCount,
+ (DWORD)CharCount,
(LPDWORD)&CharCount,
NULL
);
diff --git a/Nt32Pkg/Nt32Pkg.dsc b/Nt32Pkg/Nt32Pkg.dsc
index 6656e11a5..59ee48741 100644
--- a/Nt32Pkg/Nt32Pkg.dsc
+++ b/Nt32Pkg/Nt32Pkg.dsc
@@ -26,8 +26,8 @@
PLATFORM_GUID = EB216561-961F-47EE-9EF9-CA426EF547C2
PLATFORM_VERSION = 0.4
DSC_SPECIFICATION = 0x00010005
- OUTPUT_DIRECTORY = Build/NT32
- SUPPORTED_ARCHITECTURES = IA32
+ OUTPUT_DIRECTORY = Build/NT32$(ARCH)
+ SUPPORTED_ARCHITECTURES = IA32|X64
BUILD_TARGETS = DEBUG|RELEASE
SKUID_IDENTIFIER = DEFAULT
FLASH_DEFINITION = Nt32Pkg/Nt32Pkg.fdf
@@ -119,11 +119,13 @@
PerformanceLib|MdePkg/Library/BasePerformanceLibNull/BasePerformanceLibNull.inf
DebugAgentLib|MdeModulePkg/Library/DebugAgentLibNull/DebugAgentLibNull.inf
CpuExceptionHandlerLib|MdeModulePkg/Library/CpuExceptionHandlerLibNull/CpuExceptionHandlerLibNull.inf
+ LockBoxLib|MdeModulePkg/Library/LockBoxNullLib/LockBoxNullLib.inf
!if $(SECURE_BOOT_ENABLE) == TRUE
PlatformSecureLib|Nt32Pkg/Library/PlatformSecureLib/PlatformSecureLib.inf
IntrinsicLib|CryptoPkg/Library/IntrinsicLib/IntrinsicLib.inf
OpensslLib|CryptoPkg/Library/OpensslLib/OpensslLib.inf
+ TpmMeasurementLib|SecurityPkg/Library/DxeTpmMeasurementLib/DxeTpmMeasurementLib.inf
!endif
[LibraryClasses.common.USER_DEFINED]
@@ -207,6 +209,7 @@
[PcdsFeatureFlag]
gEfiMdeModulePkgTokenSpaceGuid.PcdStatusCodeUseSerial|FALSE
gEfiMdeModulePkgTokenSpaceGuid.PcdDxeIplSwitchToLongMode|FALSE
+ gEfiMdeModulePkgTokenSpaceGuid.PcdDxeIplBuildPageTables|FALSE
gEfiMdeModulePkgTokenSpaceGuid.PcdPeiCoreImageLoaderSearchTeSectionFirst|FALSE
gEfiMdeModulePkgTokenSpaceGuid.PcdVariableCollectStatistics|TRUE
@@ -238,7 +241,6 @@
################################################################################
[PcdsDynamicDefault.common.DEFAULT]
gEfiNt32PkgTokenSpaceGuid.PcdWinNtSerialPort|L"COM1!COM2"|VOID*|20
- gEfiNt32PkgTokenSpaceGuid.PcdWinNtFileSystem|L".!..\..\..\..\EdkShellBinPkg\Bin\Ia32\Apps"|VOID*|106
gEfiNt32PkgTokenSpaceGuid.PcdWinNtGop|L"UGA Window 1!UGA Window 2"|VOID*|52
gEfiNt32PkgTokenSpaceGuid.PcdWinNtConsole|L"Bus Driver Console Window"|VOID*|52
gEfiNt32PkgTokenSpaceGuid.PcdWinNtVirtualDisk|L"FW;40960;512"|VOID*|26
@@ -250,6 +252,12 @@
gEfiMdeModulePkgTokenSpaceGuid.PcdFlashNvStorageFtwWorkingBase|0
gEfiMdeModulePkgTokenSpaceGuid.PcdFlashNvStorageVariableBase|0
+[PcdsDynamicDefault.Ia32]
+ gEfiNt32PkgTokenSpaceGuid.PcdWinNtFileSystem|L".!..\..\..\..\EdkShellBinPkg\Bin\Ia32\Apps"|VOID*|106
+
+[PcdsDynamicDefault.x64]
+ gEfiNt32PkgTokenSpaceGuid.PcdWinNtFileSystem|L".!..\..\..\..\EdkShellBinPkg\Bin\X64\Apps"|VOID*|106
+
[PcdsDynamicHii.common.DEFAULT]
gEfiIntelFrameworkModulePkgTokenSpaceGuid.PcdSetupConOutColumn|L"SetupConsoleConfig"|gEfiNt32PkgTokenSpaceGuid|0x0|80
gEfiIntelFrameworkModulePkgTokenSpaceGuid.PcdSetupConOutRow|L"SetupConsoleConfig"|gEfiNt32PkgTokenSpaceGuid|0x4|25
@@ -274,11 +282,15 @@
# generated for it, but the binary will not be put into any firmware volume.
#
###################################################################################################
-[Components.IA32]
+[Components]
##
# SEC Phase modules
##
- Nt32Pkg/Sec/SecMain.inf
+ Nt32Pkg/Sec/SecMain.inf {
+ <BuildOptions>
+ # Add override here, because default X64_CC_FLAGS is already overriden in DSC
+ MSFT:*_*_X64_CC_FLAGS == /nologo /W4 /WX /Gy /c /D UNICODE /Od /FIAutoGen.h /EHs-c- /GF /Gs8192 /Zi /Gm /D _CRT_SECURE_NO_WARNINGS /D _CRT_SECURE_NO_DEPRECATE
+ }
##
# PEI Phase modules
@@ -314,7 +326,7 @@
NULL|MdeModulePkg/Library/DxeCrc32GuidedSectionExtractLib/DxeCrc32GuidedSectionExtractLib.inf
DevicePathLib|MdePkg/Library/UefiDevicePathLib/UefiDevicePathLib.inf
<BuildOptions>
- *_*_IA32_CC_FLAGS =
+ *_*_*_CC_FLAGS =
}
MdeModulePkg/Universal/PCD/Dxe/Pcd.inf {
@@ -428,19 +440,24 @@
#
###################################################################################################
[BuildOptions]
- DEBUG_*_IA32_DLINK_FLAGS = /EXPORT:InitializeDriver=$(IMAGE_ENTRY_POINT) /BASE:0x10000 /ALIGN:4096 /FILEALIGN:4096 /SUBSYSTEM:CONSOLE
- RELEASE_*_IA32_DLINK_FLAGS = /ALIGN:4096 /FILEALIGN:4096
+ DEBUG_*_*_DLINK_FLAGS = /EXPORT:InitializeDriver=$(IMAGE_ENTRY_POINT) /BASE:0x10000 /ALIGN:4096 /FILEALIGN:4096 /SUBSYSTEM:CONSOLE
+ RELEASE_*_*_DLINK_FLAGS = /ALIGN:4096 /FILEALIGN:4096
*_*_IA32_CC_FLAGS = /D EFI_SPECIFICATION_VERSION=0x0002000A /D TIANO_RELEASE_VERSION=0x00080006
+# Add override here, because default X64_CC_FLAGS add /X
+ DEBUG_*_X64_CC_FLAGS == /nologo /c /WX /GS- /W4 /Gs32768 /D UNICODE /O1ib2s /GL /Gy /FIAutoGen.h /EHs-c- /GR- /GF /Zi /Gm /D EFI_SPECIFICATION_VERSION=0x0002000A /D TIANO_RELEASE_VERSION=0x00080006
+RELEASE_*_X64_CC_FLAGS == /nologo /c /WX /GS- /W4 /Gs32768 /D UNICODE /O1ib2s /GL /Gy /FIAutoGen.h /EHs-c- /GR- /GF /D EFI_SPECIFICATION_VERSION=0x0002000A /D TIANO_RELEASE_VERSION=0x00080006
+NOOPT_*_X64_CC_FLAGS == /nologo /c /WX /GS- /W4 /Gs32768 /D UNICODE /Gy /FIAutoGen.h /EHs-c- /GR- /GF /Zi /Gm /Od /D EFI_SPECIFICATION_VERSION=0x0002000A /D TIANO_RELEASE_VERSION=0x00080006
+
#############################################################################################################
# NOTE:
-# The following [Libraries.IA32] section is for building EDK module under the EDKII tool chain.
-# If you want build EDK module for Nt32 platform, please uncomment [Libraries.IA32] section and
+# The following [Libraries] section is for building EDK module under the EDKII tool chain.
+# If you want build EDK module for Nt32 platform, please uncomment [Libraries] section and
# libraries used by that EDK module.
# Currently, Nt32 platform do not has any EDK style module
#
#
-#[Libraries.IA32]
+#[Libraries]
#
# Libraries common to PEI and DXE
#
diff --git a/Nt32Pkg/Nt32Pkg.fdf b/Nt32Pkg/Nt32Pkg.fdf
index 7315d432f..8282fcf2f 100644
--- a/Nt32Pkg/Nt32Pkg.fdf
+++ b/Nt32Pkg/Nt32Pkg.fdf
@@ -270,13 +270,9 @@ INF MdeModulePkg/Universal/Network/IScsiDxe/IScsiDxe.inf
# for binary shell, binary fat and logo module.
#
################################################################################
-FILE APPLICATION = PCD(gEfiIntelFrameworkModulePkgTokenSpaceGuid.PcdShellFile) {
- SECTION PE32 = EdkShellBinPkg/FullShell/Ia32/Shell_Full.efi
- }
+INF EdkShellBinPkg/FullShell/FullShell.inf
-FILE DRIVER = 961578FE-B6B7-44c3-AF35-6BC705CD2B1F {
- SECTION PE32 = FatBinPkg/EnhancedFatDxe/Ia32/Fat.efi
- }
+INF FatBinPkg/EnhancedFatDxe/Fat.inf
FILE FREEFORM = PCD(gEfiIntelFrameworkModulePkgTokenSpaceGuid.PcdLogoFile) {
SECTION RAW = MdeModulePkg/Logo/Logo.bmp
@@ -391,3 +387,26 @@ FILE FREEFORM = PCD(gEfiIntelFrameworkModulePkgTokenSpaceGuid.PcdLogoFile) {
}
}
}
+
+[Rule.Common.UEFI_APPLICATION.BINARY]
+ FILE APPLICATION = $(NAMED_GUID) {
+ COMPRESS PI_STD {
+ GUIDED {
+ PE32 PE32 |.efi
+ UI STRING="$(MODULE_NAME)" Optional
+ VERSION STRING="$(INF_VERSION)" Optional BUILD_NUM=$(BUILD_NUMBER)
+ }
+ }
+ }
+
+[Rule.Common.UEFI_DRIVER.BINARY]
+ FILE DRIVER = $(NAMED_GUID) {
+ DXE_DEPEX DXE_DEPEX Optional |.depex
+ COMPRESS PI_STD {
+ GUIDED {
+ PE32 PE32 |.efi
+ UI STRING="$(MODULE_NAME)" Optional
+ VERSION STRING="$(INF_VERSION)" Optional BUILD_NUM=$(BUILD_NUMBER)
+ }
+ }
+ }
diff --git a/Nt32Pkg/Sec/SecMain.c b/Nt32Pkg/Sec/SecMain.c
index a1d43d2eb..602cca9b1 100644
--- a/Nt32Pkg/Sec/SecMain.c
+++ b/Nt32Pkg/Sec/SecMain.c
@@ -110,6 +110,16 @@ SecNt32PeCoffRelocateImage (
);
VOID
+EFIAPI
+PeiSwitchStacks (
+ IN SWITCH_STACK_ENTRY_POINT EntryPoint,
+ IN VOID *Context1, OPTIONAL
+ IN VOID *Context2, OPTIONAL
+ IN VOID *Context3, OPTIONAL
+ IN VOID *NewStack
+ );
+
+VOID
SecPrint (
CHAR8 *Format,
...
@@ -129,7 +139,7 @@ SecPrint (
WriteFile (
GetStdHandle (STD_OUTPUT_HANDLE),
Buffer,
- CharCount,
+ (DWORD)CharCount,
(LPDWORD)&CharCount,
NULL
);
@@ -505,6 +515,7 @@ Returns:
return EFI_SUCCESS;
}
+#if defined (MDE_CPU_IA32)
/**
Transfers control to a function starting with a new stack.
@@ -562,6 +573,7 @@ PeiSwitchStacks (
//
ASSERT (FALSE);
}
+#endif
VOID
SecLoadFromCore (
diff --git a/Nt32Pkg/Sec/SecMain.inf b/Nt32Pkg/Sec/SecMain.inf
index e9596b9b1..fee68e095 100644
--- a/Nt32Pkg/Sec/SecMain.inf
+++ b/Nt32Pkg/Sec/SecMain.inf
@@ -31,8 +31,13 @@
WinNtThunk.c
FwVol.c
SecMain.c
+
+[Sources.ia32]
Stack.asm
+[Sources.x64]
+ StackX64.asm
+
[Packages]
MdePkg/MdePkg.dec
MdeModulePkg/MdeModulePkg.dec
@@ -68,6 +73,12 @@
MSFT:*_*_IA32_ASM_FLAGS == /nologo /W3 /WX /c /coff /Cx /Zd /W0 /Zi
MSFT:*_*_IA32_ASMLINK_FLAGS == /link /nologo /tiny
+ MSFT:*_*_X64_DLINK_FLAGS == /out:"$(BIN_DIR)\SecMain.exe" /base:0x10000000 /pdb:"$(BIN_DIR)\SecMain.pdb" /LIBPATH:"$(VCINSTALLDIR)\Lib\AMD64" /LIBPATH:"$(VCINSTALLDIR)\PlatformSdk\Lib\AMD64" /NOLOGO /SUBSYSTEM:CONSOLE /NODEFAULTLIB /IGNORE:4086 /MAP /OPT:REF /DEBUG /MACHINE:AMD64 /LTCG Kernel32.lib MSVCRTD.lib Gdi32.lib User32.lib Winmm.lib Advapi32.lib
+ MSFT:*_*_X64_CC_FLAGS == /nologo /W4 /WX /Gy /c /D UNICODE /Od /FIAutoGen.h /EHs-c- /GF /Gs8192 /Zi /Gm /D _CRT_SECURE_NO_WARNINGS /D _CRT_SECURE_NO_DEPRECATE
+ MSFT:*_*_X64_PP_FLAGS == /nologo /E /TC /FIAutoGen.h
+ MSFT:*_*_X64_ASM_FLAGS == /nologo /W3 /WX /c /Cx /Zd /W0 /Zi
+ MSFT:*_*_X64_ASMLINK_FLAGS == /link /nologo
+
INTEL:*_*_IA32_DLINK_FLAGS == /out:"$(BIN_DIR)\SecMain.exe" /base:0x10000000 /pdb:"$(BIN_DIR)\SecMain.pdb" /LIBPATH:"C:\Program Files\Intel\Compiler\C++\9.1\IA32\Lib" /LIBPATH:"$(VCINSTALLDIR)\Lib" /LIBPATH:"$(VCINSTALLDIR)\PlatformSdk\Lib" /NOLOGO /SUBSYSTEM:CONSOLE /NODEFAULTLIB /IGNORE:4086 /MAP /OPT:REF /DEBUG /MACHINE:I386 /LTCG Kernel32.lib MSVCRTD.lib Gdi32.lib User32.lib Winmm.lib
INTEL:*_*_IA32_CC_FLAGS == /nologo /W4 /WX /Gy /c /D UNICODE /Od /FIAutoGen.h /EHs-c- /GF /Gs8192 /Zi /Gm /D _CRT_SECURE_NO_WARNINGS /D _CRT_SECURE_NO_DEPRECATE
INTEL:*_*_IA32_PP_FLAGS == /nologo /E /TC /FIAutoGen.h
diff --git a/Nt32Pkg/Sec/StackX64.asm b/Nt32Pkg/Sec/StackX64.asm
new file mode 100644
index 000000000..2327e2eea
--- /dev/null
+++ b/Nt32Pkg/Sec/StackX64.asm
@@ -0,0 +1,110 @@
+;------------------------------------------------------------------------------
+;
+; Copyright (c) 2013, 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:
+;
+; Stack.asm
+;
+; Abstract:
+;
+; Switch the stack from temporary memory to permenent memory.
+;
+;------------------------------------------------------------------------------
+
+ .code
+
+;------------------------------------------------------------------------------
+; VOID
+; EFIAPI
+; SecSwitchStack (
+; UINT32 TemporaryMemoryBase,
+; UINT32 PermenentMemoryBase
+; );
+;------------------------------------------------------------------------------
+SecSwitchStack PROC
+ mov [rsp + 08h], rcx
+ mov [rsp + 10h], rdx
+
+ ;
+ ; Save three register: eax, ebx, ecx
+ ;
+ push rax
+ push rbx
+ push rcx
+ push rdx
+
+ ;
+ ; !!CAUTION!! this function address's is pushed into stack after
+ ; migration of whole temporary memory, so need save it to permenent
+ ; memory at first!
+ ;
+
+ mov rbx, [rsp + 28h] ; Save the first parameter
+ mov rcx, [rsp + 30h] ; Save the second parameter
+
+ ;
+ ; Save this function's return address into permenent memory at first.
+ ; Then, Fixup the esp point to permenent memory
+ ;
+ mov rax, rsp
+ sub rax, rbx
+ add rax, rcx
+ mov rdx, qword ptr [rsp] ; copy pushed register's value to permenent memory
+ mov qword ptr [rax], rdx
+ mov rdx, qword ptr [rsp + 8]
+ mov qword ptr [rax + 8], rdx
+ mov rdx, qword ptr [rsp + 10h]
+ mov qword ptr [rax + 10h], rdx
+ mov rdx, qword ptr [rsp + 18h]
+ mov qword ptr [rax + 18h], rdx
+ mov rdx, qword ptr [rsp + 20h] ; Update this function's return address into permenent memory
+ mov qword ptr [rax + 20h], rdx
+ mov rsp, rax ; From now, esp is pointed to permenent memory
+
+ ;
+ ; Fixup the ebp point to permenent memory
+ ;
+ mov rax, rbp
+ sub rax, rbx
+ add rax, rcx
+ mov rbp, rax ; From now, ebp is pointed to permenent memory
+
+ pop rdx
+ pop rcx
+ pop rbx
+ pop rax
+ ret
+SecSwitchStack ENDP
+
+;------------------------------------------------------------------------------
+; VOID
+; EFIAPI
+; PeiSwitchStacks (
+; IN SWITCH_STACK_ENTRY_POINT EntryPoint,
+; IN VOID *Context1, OPTIONAL
+; IN VOID *Context2, OPTIONAL
+; IN VOID *Context3, OPTIONAL
+; IN VOID *NewStack
+; )
+;------------------------------------------------------------------------------
+PeiSwitchStacks PROC
+ mov rax, rcx
+ mov rcx, rdx
+ mov rdx, r8
+ mov r8, r9
+ mov rsp, [rsp + 28h]
+ sub rsp, 20h
+ call rax
+ jmp $
+ ret
+PeiSwitchStacks ENDP
+
+ END
diff --git a/Nt32Pkg/SnpNt32Dxe/SnpNt32.c b/Nt32Pkg/SnpNt32Dxe/SnpNt32.c
index 86414696c..4dee182ad 100644
--- a/Nt32Pkg/SnpNt32Dxe/SnpNt32.c
+++ b/Nt32Pkg/SnpNt32Dxe/SnpNt32.c
@@ -1,6 +1,6 @@
/** @file
-Copyright (c) 2006 - 2010, Intel Corporation. All rights reserved.<BR>
+Copyright (c) 2006 - 2013, 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
@@ -704,7 +704,7 @@ SnpNt32ReceiveFilters (
ReturnValue = GlobalData->NtNetUtilityTable.SetReceiveFilter (
Instance->InterfaceInfo.InterfaceIndex,
EnableBits,
- McastFilterCount,
+ (UINT32)McastFilterCount,
McastFilter
);
@@ -863,7 +863,7 @@ SnpNt32GetStatus (
{
if (TxBuffer != NULL) {
- *((UINT8 **) TxBuffer) = (UINT8 *) 1;
+ *((UINT8 **) TxBuffer) = (UINT8 *)(UINTN) 1;
}
if (InterruptStatus != NULL) {
@@ -933,8 +933,8 @@ SnpNt32Transmit (
ReturnValue = GlobalData->NtNetUtilityTable.Transmit (
Instance->InterfaceInfo.InterfaceIndex,
- HeaderSize,
- BufferSize,
+ (UINT32)HeaderSize,
+ (UINT32)BufferSize,
Buffer,
SrcAddr,
DestAddr,
@@ -1189,7 +1189,7 @@ SnpNt32InitializeGlobalData (
//
// Set the interface information.
//
- Instance->InterfaceInfo = NetInterfaceInfoBuffer[Index];
+ CopyMem (&Instance->InterfaceInfo, &NetInterfaceInfoBuffer[Index], sizeof(Instance->InterfaceInfo));
//
// Initialize this instance
//
@@ -1265,8 +1265,8 @@ SnpNt32InitializeInstanceData (
//
// Copy Current/PermanentAddress MAC address
//
- Instance->Mode.CurrentAddress = Instance->InterfaceInfo.MacAddr;
- Instance->Mode.PermanentAddress = Instance->InterfaceInfo.MacAddr;
+ CopyMem (&Instance->Mode.CurrentAddress, &Instance->InterfaceInfo.MacAddr, sizeof(Instance->Mode.CurrentAddress));
+ CopyMem (&Instance->Mode.PermanentAddress, &Instance->InterfaceInfo.MacAddr, sizeof(Instance->Mode.PermanentAddress));
//
// Since the fake SNP is based on a real NIC, to avoid conflict with the host
diff --git a/Nt32Pkg/StallPei/Stall.c b/Nt32Pkg/StallPei/Stall.c
index e89338dcd..c00ada872 100644
--- a/Nt32Pkg/StallPei/Stall.c
+++ b/Nt32Pkg/StallPei/Stall.c
@@ -1,7 +1,7 @@
/**@file
EFI_PEI_STALL implementation for NT32 simulation environment.
-Copyright (c) 2009, Intel Corporation. All rights reserved.<BR>
+Copyright (c) 2009 - 2013, 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
@@ -100,7 +100,7 @@ Stall (
// so micro second units need be divided by 1000 to convert to ms
//
NtThunk = (EFI_WIN_NT_THUNK_PROTOCOL*) PeiNtService->NtThunk();
- NtThunk->Sleep ((Microseconds + 999) / 1000);
+ NtThunk->Sleep ((DWORD)((Microseconds + 999) / 1000));
return EFI_SUCCESS;
}
diff --git a/Nt32Pkg/WinNtBlockIoDxe/WinNtBlockIo.c b/Nt32Pkg/WinNtBlockIoDxe/WinNtBlockIo.c
index 12924e659..f9f286705 100644
--- a/Nt32Pkg/WinNtBlockIoDxe/WinNtBlockIo.c
+++ b/Nt32Pkg/WinNtBlockIoDxe/WinNtBlockIo.c
@@ -529,7 +529,7 @@ Returns:
BlockIo = &Private->BlockIo;
BlockIo->Revision = EFI_BLOCK_IO_PROTOCOL_REVISION;
BlockIo->Media = &Private->Media;
- BlockIo->Media->BlockSize = Private->BlockSize;
+ BlockIo->Media->BlockSize = (UINT32)Private->BlockSize;
BlockIo->Media->LastBlock = Private->NumberOfBlocks - 1;
BlockIo->Media->MediaId = 0;;
@@ -626,10 +626,10 @@ Returns:
//
Private->NtHandle = Private->WinNtThunk->CreateFile (
Private->Filename,
- Private->ReadMode,
- Private->ShareMode,
+ (DWORD)Private->ReadMode,
+ (DWORD)Private->ShareMode,
NULL,
- Private->OpenMode,
+ (DWORD)Private->OpenMode,
0,
NULL
);
@@ -658,7 +658,7 @@ Returns:
Status = SetFilePointer64 (Private, 0, &FileSize, FILE_END);
if (EFI_ERROR (Status)) {
- FileSize = MultU64x32 (Private->NumberOfBlocks, Private->BlockSize);
+ FileSize = MultU64x32 (Private->NumberOfBlocks, (UINT32)Private->BlockSize);
if (Private->DeviceType == EfiWinNtVirtualDisks) {
DEBUG ((EFI_D_ERROR, "PlOpenBlock: Could not get filesize of %s\n", Private->Filename));
Status = EFI_UNSUPPORTED;
@@ -667,10 +667,10 @@ Returns:
}
if (Private->NumberOfBlocks == 0) {
- Private->NumberOfBlocks = DivU64x32 (FileSize, Private->BlockSize);
+ Private->NumberOfBlocks = DivU64x32 (FileSize, (UINT32)Private->BlockSize);
}
- EndOfFile = MultU64x32 (Private->NumberOfBlocks, Private->BlockSize);
+ EndOfFile = MultU64x32 (Private->NumberOfBlocks, (UINT32)Private->BlockSize);
if (FileSize != EndOfFile) {
//
@@ -832,7 +832,7 @@ Returns:
return EFI_MEDIA_CHANGED;
}
- if ((UINT32) Buffer % Private->Media.IoAlign != 0) {
+ if ((UINTN) Buffer % Private->Media.IoAlign != 0) {
return EFI_INVALID_PARAMETER;
}
@@ -858,7 +858,7 @@ Returns:
//
// Seek to End of File
//
- DistanceToMove = MultU64x32 (Lba, BlockSize);
+ DistanceToMove = MultU64x32 (Lba, (UINT32)BlockSize);
Status = SetFilePointer64 (Private, DistanceToMove, &DistanceMoved, FILE_BEGIN);
if (EFI_ERROR (Status)) {
diff --git a/Nt32Pkg/WinNtGopDxe/WinNtGopScreen.c b/Nt32Pkg/WinNtGopDxe/WinNtGopScreen.c
index 607caad2e..b15d621b3 100644
--- a/Nt32Pkg/WinNtGopDxe/WinNtGopScreen.c
+++ b/Nt32Pkg/WinNtGopDxe/WinNtGopScreen.c
@@ -1,6 +1,6 @@
/** @file
-Copyright (c) 2006 - 2011, Intel Corporation. All rights reserved.<BR>
+Copyright (c) 2006 - 2013, 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
@@ -379,7 +379,7 @@ WinNtGopSetMode (
//
// Adjust the window size
//
- Private->WinNtThunk->MoveWindow (Private->WindowHandle, Rect.left, Rect.top, Width, Height, TRUE);
+ Private->WinNtThunk->MoveWindow (Private->WindowHandle, Rect.left, Rect.top, (INT32)Width, (INT32)Height, TRUE);
}
@@ -582,10 +582,10 @@ WinNtGopBlt (
//
// Mark the area we just blted as Invalid so WM_PAINT will update.
//
- Rect.left = DestinationX;
- Rect.top = DestinationY;
- Rect.right = DestinationX + Width;
- Rect.bottom = DestinationY + Height;
+ Rect.left = (LONG)DestinationX;
+ Rect.top = (LONG)DestinationY;
+ Rect.right = (LONG)(DestinationX + Width);
+ Rect.bottom = (LONG)(DestinationY + Height);
Private->WinNtThunk->InvalidateRect (Private->WindowHandle, &Rect, FALSE);
//
@@ -900,7 +900,7 @@ WinNtGopThreadWinMain (
Private->WindowsClass.hInstance = NULL;
Private->WindowsClass.hIcon = Private->WinNtThunk->LoadIcon (NULL, IDI_APPLICATION);
Private->WindowsClass.hCursor = Private->WinNtThunk->LoadCursor (NULL, IDC_ARROW);
- Private->WindowsClass.hbrBackground = (HBRUSH) COLOR_WINDOW;
+ Private->WindowsClass.hbrBackground = (HBRUSH)(UINTN)COLOR_WINDOW;
Private->WindowsClass.lpszMenuName = NULL;
Private->WindowsClass.lpszClassName = WIN_NT_GOP_CLASS_NAME;
Private->WindowsClass.hIconSm = Private->WinNtThunk->LoadIcon (NULL, IDI_APPLICATION);
@@ -963,7 +963,7 @@ WinNtGopThreadWinMain (
Private->WinNtThunk->DispatchMessage (&Message);
}
- return Message.wParam;
+ return (DWORD)Message.wParam;
}
diff --git a/Nt32Pkg/WinNtSimpleFileSystemDxe/WinNtSimpleFileSystem.c b/Nt32Pkg/WinNtSimpleFileSystemDxe/WinNtSimpleFileSystem.c
index 63ab71fb2..1c300b693 100644
--- a/Nt32Pkg/WinNtSimpleFileSystemDxe/WinNtSimpleFileSystem.c
+++ b/Nt32Pkg/WinNtSimpleFileSystemDxe/WinNtSimpleFileSystem.c
@@ -1,6 +1,6 @@
/**@file
-Copyright (c) 2006 - 2011, Intel Corporation. All rights reserved.<BR>
+Copyright (c) 2006 - 2013, 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
@@ -1593,7 +1593,7 @@ Returns:
Status = PrivateFile->WinNtThunk->ReadFile (
PrivateFile->LHandle,
Buffer,
- *BufferSize,
+ (DWORD)*BufferSize,
(LPDWORD)BufferSize,
NULL
) ? EFI_SUCCESS : EFI_DEVICE_ERROR;
@@ -1764,7 +1764,7 @@ Returns:
Status = PrivateFile->WinNtThunk->WriteFile (
PrivateFile->LHandle,
Buffer,
- *BufferSize,
+ (DWORD)*BufferSize,
(LPDWORD)BufferSize,
NULL
) ? EFI_SUCCESS : EFI_DEVICE_ERROR;
diff --git a/OvmfPkg/Include/IndustryStandard/Virtio.h b/OvmfPkg/Include/IndustryStandard/Virtio.h
index 05c658fa5..75c5a9c85 100644
--- a/OvmfPkg/Include/IndustryStandard/Virtio.h
+++ b/OvmfPkg/Include/IndustryStandard/Virtio.h
@@ -4,6 +4,7 @@
specification.
Copyright (C) 2012, Red Hat, Inc.
+ Portion of Copyright (C) 2013, ARM Ltd.
This program and the accompanying materials are licensed and made available
under the terms and conditions of the BSD License which accompanies this
@@ -20,8 +21,68 @@
#include <Base.h>
+//
+// VirtIo Subsystem Device IDs
+//
+#define VIRTIO_SUBSYSTEM_NETWORK_CARD 1
+#define VIRTIO_SUBSYSTEM_BLOCK_DEVICE 2
+#define VIRTIO_SUBSYSTEM_CONSOLE 3
+#define VIRTIO_SUBSYSTEM_ENTROPY_SOURCE 4
+#define VIRTIO_SUBSYSTEM_MEMORY_BALLOONING 5
+#define VIRTIO_SUBSYSTEM_IO_MEMORY 6
+#define VIRTIO_SUBSYSTEM_RPMSG 7
+#define VIRTIO_SUBSYSTEM_SCSI_HOST 8
+#define VIRTIO_SUBSYSTEM_9P_TRANSPORT 9
+#define VIRTIO_SUBSYSTEM_MAC80211_WLAN 10
//
+// Virtio IDs
+//
+#define VIRTIO_VENDOR_ID 0x1AF4
+#define VIRTIO_MMIO_MAGIC 0x74726976 // "virt"
+
+
+//
+// VirtIo Device Specific Configuration Offsets
+//
+#define VIRTIO_DEVICE_SPECIFIC_CONFIGURATION_OFFSET_PCI 20
+#define VIRTIO_DEVICE_SPECIFIC_CONFIGURATION_OFFSET_PCI_WITH_MSI_X 24
+#define VIRTIO_DEVICE_SPECIFIC_CONFIGURATION_OFFSET_MMIO 0x100
+
+// PCI VirtIo Header Offsets
+//
+#define VIRTIO_PCI_OFFSET_DEVICE_FEATURES 0x00
+#define VIRTIO_PCI_OFFSET_GUEST_FEATURES 0x04
+#define VIRTIO_PCI_OFFSET_QUEUE_ADDRESS 0x08
+#define VIRTIO_PCI_OFFSET_QUEUE_SIZE 0x0C
+#define VIRTIO_PCI_OFFSET_QUEUE_SELECT 0x0E
+#define VIRTIO_PCI_OFFSET_QUEUE_NOTIFY 0x10
+#define VIRTIO_PCI_OFFSET_QUEUE_DEVICE_STATUS 0x12
+#define VIRTIO_PCI_OFFSET_QUEUE_DEVICE_ISR 0x13
+
+//
+// MMIO VirtIo Header Offsets
+//
+#define VIRTIO_MMIO_OFFSET_MAGIC 0x00
+#define VIRTIO_MMIO_OFFSET_VERSION 0x04
+#define VIRTIO_MMIO_OFFSET_DEVICE_ID 0x08
+#define VIRTIO_MMIO_OFFSET_VENDOR_ID 0x0C
+#define VIRTIO_MMIO_OFFSET_HOST_FEATURES 0x10
+#define VIRTIO_MMIO_OFFSET_HOST_FEATURES_SEL 0x14
+#define VIRTIO_MMIO_OFFSET_GUEST_FEATURES 0x20
+#define VIRTIO_MMIO_OFFSET_GUEST_FEATURES_SEL 0x24
+#define VIRTIO_MMIO_OFFSET_GUEST_PAGE_SIZE 0x28
+#define VIRTIO_MMIO_OFFSET_QUEUE_SEL 0x30
+#define VIRTIO_MMIO_OFFSET_QUEUE_NUM_MAX 0x34
+#define VIRTIO_MMIO_OFFSET_QUEUE_NUM 0x38
+#define VIRTIO_MMIO_OFFSET_QUEUE_ALIGN 0x3C
+#define VIRTIO_MMIO_OFFSET_QUEUE_PFN 0x40
+#define VIRTIO_MMIO_OFFSET_QUEUE_NOTIFY 0x50
+#define VIRTIO_MMIO_OFFSET_INTERRUPT_STATUS 0x60
+#define VIRTIO_MMIO_OFFSET_INTERRUPT_ACK 0x64
+#define VIRTIO_MMIO_OFFSET_STATUS 0x70
+
+//
// Data in the communication area is defined as packed and accessed as
// volatile.
//
@@ -94,24 +155,6 @@ typedef struct {
UINT16 QueueSize;
} VRING;
-
-//
-// virtio-0.9.5, 2.2.2 Virtio Header -- no MSI-X
-//
-#pragma pack(1)
-typedef struct {
- UINT32 VhdrDeviceFeatureBits;
- UINT32 VhdrGuestFeatureBits;
- UINT32 VhdrQueueAddress;
- UINT16 VhdrQueueSize;
- UINT16 VhdrQueueSelect;
- UINT16 VhdrQueueNotify;
- UINT8 VhdrDeviceStatus;
- UINT8 VhdrISR;
-} VIRTIO_HDR;
-#pragma pack()
-
-
//
// virtio-0.9.5, 2.2.2.1 Device Status
//
diff --git a/OvmfPkg/Include/IndustryStandard/VirtioBlk.h b/OvmfPkg/Include/IndustryStandard/VirtioBlk.h
index b71f224b6..55f6548ed 100644
--- a/OvmfPkg/Include/IndustryStandard/VirtioBlk.h
+++ b/OvmfPkg/Include/IndustryStandard/VirtioBlk.h
@@ -26,19 +26,18 @@
//
#pragma pack(1)
typedef struct {
- VIRTIO_HDR Generic;
- UINT64 VhdrCapacity;
- UINT32 VhdrSizeMax;
- UINT32 VhdrSegMax;
- UINT16 VhdrCylinders;
- UINT8 VhdrHeads;
- UINT8 VhdrSectors;
- UINT32 VhdrBlkSize;
-} VBLK_HDR;
+ UINT64 Capacity;
+ UINT32 SizeMax;
+ UINT32 SegMax;
+ UINT16 Cylinders;
+ UINT8 Heads;
+ UINT8 Sectors;
+ UINT32 BlkSize;
+} VIRTIO_BLK_CONFIG;
#pragma pack()
-#define OFFSET_OF_VBLK(Field) OFFSET_OF (VBLK_HDR, Field)
-#define SIZE_OF_VBLK(Field) (sizeof ((VBLK_HDR *) 0)->Field)
+#define OFFSET_OF_VBLK(Field) OFFSET_OF (VIRTIO_BLK_CONFIG, Field)
+#define SIZE_OF_VBLK(Field) (sizeof ((VIRTIO_BLK_CONFIG *) 0)->Field)
#define VIRTIO_BLK_F_BARRIER BIT0
#define VIRTIO_BLK_F_SIZE_MAX BIT1
diff --git a/OvmfPkg/Include/IndustryStandard/VirtioNet.h b/OvmfPkg/Include/IndustryStandard/VirtioNet.h
index 9f5291a24..90d9702cb 100644
--- a/OvmfPkg/Include/IndustryStandard/VirtioNet.h
+++ b/OvmfPkg/Include/IndustryStandard/VirtioNet.h
@@ -1,99 +1,97 @@
-/** @file
-
- Virtio Network Device specific type and macro definitions corresponding to
- the virtio-0.9.5 specification.
-
- Copyright (C) 2013, Red Hat, Inc.
-
- 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.
-
-**/
-
-#ifndef _VIRTIO_NET_H_
-#define _VIRTIO_NET_H_
-
-#include <IndustryStandard/Virtio.h>
-
-//
-// virtio-0.9.5, Appendix C: Network Device
-//
-#pragma pack(1)
-typedef struct {
- VIRTIO_HDR Generic;
- UINT8 VhdrMac[6];
- UINT16 VhdrLinkStatus;
-} VNET_HDR;
-#pragma pack()
-
-#define OFFSET_OF_VNET(Field) OFFSET_OF (VNET_HDR, Field)
-#define SIZE_OF_VNET(Field) (sizeof ((VNET_HDR *) 0)->Field)
-
-//
-// Queue Identifiers
-//
-#define VIRTIO_NET_Q_RX 0
-#define VIRTIO_NET_Q_TX 1
-
-//
-// Feature Bits
-//
-#define VIRTIO_NET_F_CSUM BIT0 // host to checksum outgoing packets
-#define VIRTIO_NET_F_GUEST_CSUM BIT1 // guest to checksum incoming packets
-#define VIRTIO_NET_F_MAC BIT5 // MAC available to guest
-#define VIRTIO_NET_F_GSO BIT6 // deprecated
-#define VIRTIO_NET_F_GUEST_TSO4 BIT7 // guest can receive TSOv4
-#define VIRTIO_NET_F_GUEST_TSO6 BIT8 // guest can receive TSOv6
-#define VIRTIO_NET_F_GUEST_ECN BIT9 // guest can receive TSO with ECN
-#define VIRTIO_NET_F_GUEST_UFO BIT10 // guest can receive UFO
-#define VIRTIO_NET_F_HOST_TSO4 BIT11 // host can receive TSOv4
-#define VIRTIO_NET_F_HOST_TSO6 BIT12 // host can receive TSOv6
-#define VIRTIO_NET_F_HOST_ECN BIT13 // host can receive TSO with ECN
-#define VIRTIO_NET_F_HOST_UFO BIT14 // host can receive UFO
-#define VIRTIO_NET_F_MRG_RXBUF BIT15 // guest can merge receive buffers
-#define VIRTIO_NET_F_STATUS BIT16 // link status available to guest
-#define VIRTIO_NET_F_CTRL_VQ BIT17 // control channel available
-#define VIRTIO_NET_F_CTRL_RX BIT18 // control channel RX mode support
-#define VIRTIO_NET_F_CTRL_VLAN BIT19 // control channel VLAN filtering
-#define VIRTIO_NET_F_GUEST_ANNOUNCE BIT21 // guest can send gratuitous pkts
-
-//
-// Packet Header
-//
-#pragma pack(1)
-typedef struct {
- UINT8 Flags;
- UINT8 GsoType;
- UINT16 HdrLen;
- UINT16 GsoSize;
- UINT16 CsumStart;
- UINT16 CsumOffset;
-} VIRTIO_NET_REQ;
-#pragma pack()
-
-//
-// Bits in VIRTIO_NET_REQ.Flags
-//
-#define VIRTIO_NET_HDR_F_NEEDS_CSUM BIT0
-
-//
-// Types/Bits for VIRTIO_NET_REQ.GsoType
-//
-#define VIRTIO_NET_HDR_GSO_NONE 0x00
-#define VIRTIO_NET_HDR_GSO_TCPV4 0x01
-#define VIRTIO_NET_HDR_GSO_UDP 0x03
-#define VIRTIO_NET_HDR_GSO_TCPV6 0x04
-#define VIRTIO_NET_HDR_GSO_ECN BIT7
-
-//
-// Link Status Bits in VNET_HDR.VhdrLinkStatus
-//
-#define VIRTIO_NET_S_LINK_UP BIT0
-#define VIRTIO_NET_S_ANNOUNCE BIT1
-
-#endif // _VIRTIO_NET_H_
+/** @file
+ Virtio Network Device specific type and macro definitions corresponding to
+ the virtio-0.9.5 specification.
+
+ Copyright (C) 2013, Red Hat, Inc.
+
+ 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.
+
+**/
+
+#ifndef _VIRTIO_NET_H_
+#define _VIRTIO_NET_H_
+
+#include <IndustryStandard/Virtio.h>
+
+//
+// virtio-0.9.5, Appendix C: Network Device
+//
+#pragma pack(1)
+typedef struct {
+ UINT8 Mac[6];
+ UINT16 LinkStatus;
+} VIRTIO_NET_CONFIG;
+#pragma pack()
+
+#define OFFSET_OF_VNET(Field) OFFSET_OF (VIRTIO_NET_CONFIG, Field)
+#define SIZE_OF_VNET(Field) (sizeof ((VIRTIO_NET_CONFIG *) 0)->Field)
+
+//
+// Queue Identifiers
+//
+#define VIRTIO_NET_Q_RX 0
+#define VIRTIO_NET_Q_TX 1
+
+//
+// Feature Bits
+//
+#define VIRTIO_NET_F_CSUM BIT0 // host to checksum outgoing packets
+#define VIRTIO_NET_F_GUEST_CSUM BIT1 // guest to checksum incoming packets
+#define VIRTIO_NET_F_MAC BIT5 // MAC available to guest
+#define VIRTIO_NET_F_GSO BIT6 // deprecated
+#define VIRTIO_NET_F_GUEST_TSO4 BIT7 // guest can receive TSOv4
+#define VIRTIO_NET_F_GUEST_TSO6 BIT8 // guest can receive TSOv6
+#define VIRTIO_NET_F_GUEST_ECN BIT9 // guest can receive TSO with ECN
+#define VIRTIO_NET_F_GUEST_UFO BIT10 // guest can receive UFO
+#define VIRTIO_NET_F_HOST_TSO4 BIT11 // host can receive TSOv4
+#define VIRTIO_NET_F_HOST_TSO6 BIT12 // host can receive TSOv6
+#define VIRTIO_NET_F_HOST_ECN BIT13 // host can receive TSO with ECN
+#define VIRTIO_NET_F_HOST_UFO BIT14 // host can receive UFO
+#define VIRTIO_NET_F_MRG_RXBUF BIT15 // guest can merge receive buffers
+#define VIRTIO_NET_F_STATUS BIT16 // link status available to guest
+#define VIRTIO_NET_F_CTRL_VQ BIT17 // control channel available
+#define VIRTIO_NET_F_CTRL_RX BIT18 // control channel RX mode support
+#define VIRTIO_NET_F_CTRL_VLAN BIT19 // control channel VLAN filtering
+#define VIRTIO_NET_F_GUEST_ANNOUNCE BIT21 // guest can send gratuitous pkts
+
+//
+// Packet Header
+//
+#pragma pack(1)
+typedef struct {
+ UINT8 Flags;
+ UINT8 GsoType;
+ UINT16 HdrLen;
+ UINT16 GsoSize;
+ UINT16 CsumStart;
+ UINT16 CsumOffset;
+} VIRTIO_NET_REQ;
+#pragma pack()
+
+//
+// Bits in VIRTIO_NET_REQ.Flags
+//
+#define VIRTIO_NET_HDR_F_NEEDS_CSUM BIT0
+
+//
+// Types/Bits for VIRTIO_NET_REQ.GsoType
+//
+#define VIRTIO_NET_HDR_GSO_NONE 0x00
+#define VIRTIO_NET_HDR_GSO_TCPV4 0x01
+#define VIRTIO_NET_HDR_GSO_UDP 0x03
+#define VIRTIO_NET_HDR_GSO_TCPV6 0x04
+#define VIRTIO_NET_HDR_GSO_ECN BIT7
+
+//
+// Link Status Bits in VIRTIO_NET_CONFIG.LinkStatus
+//
+#define VIRTIO_NET_S_LINK_UP BIT0
+#define VIRTIO_NET_S_ANNOUNCE BIT1
+
+#endif // _VIRTIO_NET_H_
diff --git a/OvmfPkg/Include/IndustryStandard/VirtioScsi.h b/OvmfPkg/Include/IndustryStandard/VirtioScsi.h
index 59ce97e07..884e4d642 100644
--- a/OvmfPkg/Include/IndustryStandard/VirtioScsi.h
+++ b/OvmfPkg/Include/IndustryStandard/VirtioScsi.h
@@ -26,22 +26,21 @@
//
#pragma pack(1)
typedef struct {
- VIRTIO_HDR Generic;
- UINT32 VhdrNumQueues;
- UINT32 VhdrSegMax;
- UINT32 VhdrMaxSectors;
- UINT32 VhdrCmdPerLun;
- UINT32 VhdrEventInfoSize;
- UINT32 VhdrSenseSize;
- UINT32 VhdrCdbSize;
- UINT16 VhdrMaxChannel;
- UINT16 VhdrMaxTarget;
- UINT32 VhdrMaxLun;
-} VSCSI_HDR;
+ UINT32 NumQueues;
+ UINT32 SegMax;
+ UINT32 MaxSectors;
+ UINT32 CmdPerLun;
+ UINT32 EventInfoSize;
+ UINT32 SenseSize;
+ UINT32 CdbSize;
+ UINT16 MaxChannel;
+ UINT16 MaxTarget;
+ UINT32 MaxLun;
+} VIRTIO_SCSI_CONFIG;
#pragma pack()
-#define OFFSET_OF_VSCSI(Field) OFFSET_OF (VSCSI_HDR, Field)
-#define SIZE_OF_VSCSI(Field) (sizeof ((VSCSI_HDR *) 0)->Field)
+#define OFFSET_OF_VSCSI(Field) OFFSET_OF (VIRTIO_SCSI_CONFIG, Field)
+#define SIZE_OF_VSCSI(Field) (sizeof ((VIRTIO_SCSI_CONFIG *) 0)->Field)
#define VIRTIO_SCSI_F_INOUT BIT0
#define VIRTIO_SCSI_F_HOTPLUG BIT1
diff --git a/OvmfPkg/Include/IndustryStandard/X64Paging.h b/OvmfPkg/Include/IndustryStandard/X64Paging.h
deleted file mode 100644
index 8450be35d..000000000
--- a/OvmfPkg/Include/IndustryStandard/X64Paging.h
+++ /dev/null
@@ -1,99 +0,0 @@
-/** @file
- X64 Long Mode Virtual Memory Management Definitions
-
- References:
- 1) IA-32 Intel(R) Architecture Software Developer's Manual Volume 1:Basic Architecture, Intel
- 2) IA-32 Intel(R) Architecture Software Developer's Manual Volume 2:Instruction Set Reference, Intel
- 3) IA-32 Intel(R) Architecture Software Developer's Manual Volume 3:System Programmer's Guide, Intel
- 4) AMD64 Architecture Programmer's Manual Volume 2: System Programming
-
-Copyright (c) 2006 - 2011, 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.
-
-**/
-#ifndef _X64_PAGING_H_
-#define _X64_PAGING_H_
-
-#pragma pack(1)
-
-//
-// Page-Map Level-4 Offset (PML4) and
-// Page-Directory-Pointer Offset (PDPE) entries 4K & 2MB
-//
-
-typedef union {
- struct {
- UINT64 Present:1; // 0 = Not present in memory, 1 = Present in memory
- UINT64 ReadWrite:1; // 0 = Read-Only, 1= Read/Write
- UINT64 UserSupervisor:1; // 0 = Supervisor, 1=User
- UINT64 WriteThrough:1; // 0 = Write-Back caching, 1=Write-Through caching
- UINT64 CacheDisabled:1; // 0 = Cached, 1=Non-Cached
- UINT64 Accessed:1; // 0 = Not accessed, 1 = Accessed (set by CPU)
- UINT64 Reserved:1; // Reserved
- UINT64 MustBeZero:2; // Must Be Zero
- UINT64 Available:3; // Available for use by system software
- UINT64 PageTableBaseAddress:40; // Page Table Base Address
- UINT64 AvabilableHigh:11; // Available for use by system software
- UINT64 Nx:1; // No Execute bit
- } Bits;
- UINT64 Uint64;
-} X64_PAGE_MAP_AND_DIRECTORY_POINTER;
-
-//
-// Page Table Entry 2MB
-//
-typedef union {
- struct {
- UINT64 Present:1; // 0 = Not present in memory, 1 = Present in memory
- UINT64 ReadWrite:1; // 0 = Read-Only, 1= Read/Write
- UINT64 UserSupervisor:1; // 0 = Supervisor, 1=User
- UINT64 WriteThrough:1; // 0 = Write-Back caching, 1=Write-Through caching
- UINT64 CacheDisabled:1; // 0 = Cached, 1=Non-Cached
- UINT64 Accessed:1; // 0 = Not accessed, 1 = Accessed (set by CPU)
- UINT64 Dirty:1; // 0 = Not Dirty, 1 = written by processor on access to page
- UINT64 MustBe1:1; // Must be 1
- UINT64 Global:1; // 0 = Not global page, 1 = global page TLB not cleared on CR3 write
- UINT64 Available:3; // Available for use by system software
- UINT64 PAT:1; //
- UINT64 MustBeZero:8; // Must be zero;
- UINT64 PageTableBaseAddress:31; // Page Table Base Address
- UINT64 AvabilableHigh:11; // Available for use by system software
- UINT64 Nx:1; // 0 = Execute Code, 1 = No Code Execution
- } Bits;
- UINT64 Uint64;
-} X64_PAGE_TABLE_ENTRY;
-
-//
-// Page Table Entry 1GB
-//
-typedef union {
- struct {
- UINT64 Present:1; // 0 = Not present in memory, 1 = Present in memory
- UINT64 ReadWrite:1; // 0 = Read-Only, 1= Read/Write
- UINT64 UserSupervisor:1; // 0 = Supervisor, 1=User
- UINT64 WriteThrough:1; // 0 = Write-Back caching, 1=Write-Through caching
- UINT64 CacheDisabled:1; // 0 = Cached, 1=Non-Cached
- UINT64 Accessed:1; // 0 = Not accessed, 1 = Accessed (set by CPU)
- UINT64 Dirty:1; // 0 = Not Dirty, 1 = written by processor on access to page
- UINT64 MustBe1:1; // Must be 1
- UINT64 Global:1; // 0 = Not global page, 1 = global page TLB not cleared on CR3 write
- UINT64 Available:3; // Available for use by system software
- UINT64 PAT:1; //
- UINT64 MustBeZero:17; // Must be zero;
- UINT64 PageTableBaseAddress:22; // Page Table Base Address
- UINT64 AvabilableHigh:11; // Available for use by system software
- UINT64 Nx:1; // 0 = Execute Code, 1 = No Code Execution
- } Bits;
- UINT64 Uint64;
-} X64_PAGE_TABLE_1G_ENTRY;
-
-#pragma pack()
-
-#endif
-
diff --git a/OvmfPkg/Include/Library/VirtioLib.h b/OvmfPkg/Include/Library/VirtioLib.h
index 51303491d..e61a5090e 100644
--- a/OvmfPkg/Include/Library/VirtioLib.h
+++ b/OvmfPkg/Include/Library/VirtioLib.h
@@ -17,71 +17,10 @@
#ifndef _VIRTIO_LIB_H_
#define _VIRTIO_LIB_H_
-#include <Protocol/PciIo.h>
+#include <Protocol/VirtioDevice.h>
+
#include <IndustryStandard/Virtio.h>
-/**
-
- Write a word into Region 0 of the device specified by PciIo.
-
- Region 0 must be an iomem region. This is an internal function for the
- driver-specific VIRTIO_CFG_WRITE() macros.
-
- @param[in] PciIo Target PCI device.
-
- @param[in] FieldOffset Destination offset.
-
- @param[in] FieldSize Destination field size, must be in { 1, 2, 4, 8 }.
-
- @param[in] Value Little endian value to write, converted to UINT64.
- The least significant FieldSize bytes will be used.
-
-
- @return Status code returned by PciIo->Io.Write().
-
-**/
-EFI_STATUS
-EFIAPI
-VirtioWrite (
- IN EFI_PCI_IO_PROTOCOL *PciIo,
- IN UINTN FieldOffset,
- IN UINTN FieldSize,
- IN UINT64 Value
- );
-
-
-/**
-
- Read a word from Region 0 of the device specified by PciIo.
-
- Region 0 must be an iomem region. This is an internal function for the
- driver-specific VIRTIO_CFG_READ() macros.
-
- @param[in] PciIo Source PCI device.
-
- @param[in] FieldOffset Source offset.
-
- @param[in] FieldSize Source field size, must be in { 1, 2, 4, 8 }.
-
- @param[in] BufferSize Number of bytes available in the target buffer. Must
- equal FieldSize.
-
- @param[out] Buffer Target buffer.
-
-
- @return Status code returned by PciIo->Io.Read().
-
-**/
-EFI_STATUS
-EFIAPI
-VirtioRead (
- IN EFI_PCI_IO_PROTOCOL *PciIo,
- IN UINTN FieldOffset,
- IN UINTN FieldSize,
- IN UINTN BufferSize,
- OUT VOID *Buffer
- );
-
/**
@@ -218,7 +157,7 @@ VirtioAppendDesc (
Notify the host about the descriptor chain just built, and wait until the
host processes it.
- @param[in] PciIo The target virtio PCI device to notify.
+ @param[in] VirtIo The target virtio device to notify.
@param[in] VirtQueueId Identifies the queue for the target device.
@@ -229,7 +168,7 @@ VirtioAppendDesc (
of the descriptor chain.
- @return Error code from VirtioWrite() if it fails.
+ @return Error code from VirtioWriteDevice() if it fails.
@retval EFI_SUCCESS Otherwise, the host processed all descriptors.
@@ -237,10 +176,10 @@ VirtioAppendDesc (
EFI_STATUS
EFIAPI
VirtioFlush (
- IN EFI_PCI_IO_PROTOCOL *PciIo,
- IN UINT16 VirtQueueId,
- IN OUT VRING *Ring,
- IN DESC_INDICES *Indices
+ IN VIRTIO_DEVICE_PROTOCOL *VirtIo,
+ IN UINT16 VirtQueueId,
+ IN OUT VRING *Ring,
+ IN DESC_INDICES *Indices
);
#endif // _VIRTIO_LIB_H_
diff --git a/OvmfPkg/Include/Library/VirtioMmioDeviceLib.h b/OvmfPkg/Include/Library/VirtioMmioDeviceLib.h
new file mode 100644
index 000000000..73e5a9e8d
--- /dev/null
+++ b/OvmfPkg/Include/Library/VirtioMmioDeviceLib.h
@@ -0,0 +1,65 @@
+/** @file
+
+ Definitions for the VirtIo MMIO Device Library
+
+ Copyright (C) 2013, ARM Ltd
+
+ 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.
+
+**/
+
+#ifndef _VIRTIO_MMIO_DEVICE_LIB_H_
+#define _VIRTIO_MMIO_DEVICE_LIB_H_
+
+/**
+
+ Initialize VirtIo Device and Install VIRTIO_DEVICE_PROTOCOL protocol
+
+ @param[in] BaseAddress Base Address of the VirtIo MMIO Device
+
+ @param[in] Handle Handle of the device the driver should be attached to.
+
+ @retval EFI_SUCCESS The VirtIo Device has been installed
+ successfully.
+
+ @retval EFI_OUT_OF_RESOURCES The function failed too allocate memory require
+ by the Virtio MMIO device initialization.
+
+ @retval EFI_UNSUPPORTED BaseAddress does not point to a VirtIo MMIO
+ device.
+
+ @return Status code returned by InstallProtocolInterface
+ Boot Service function.
+
+**/
+EFI_STATUS
+VirtioMmioInstallDevice (
+ IN PHYSICAL_ADDRESS BaseAddress,
+ IN EFI_HANDLE Handle
+ );
+
+/**
+
+ Uninstall the VirtIo Device
+
+ @param[in] Handle Handle of the device where the VirtIo Device protocol
+ should have been installed.
+
+ @retval EFI_SUCCESS The device has been un-initialized successfully.
+
+ @return Status code returned by UninstallProtocolInterface
+ Boot Service function.
+
+**/
+EFI_STATUS
+VirtioMmioUninstallDevice (
+ IN EFI_HANDLE Handle
+ );
+
+#endif // _VIRTIO_MMIO_DEVICE_LIB_H_
diff --git a/OvmfPkg/Include/Protocol/VirtioDevice.h b/OvmfPkg/Include/Protocol/VirtioDevice.h
new file mode 100644
index 000000000..cecac0541
--- /dev/null
+++ b/OvmfPkg/Include/Protocol/VirtioDevice.h
@@ -0,0 +1,376 @@
+/** @file
+ Virtio Device
+
+ Copyright (c) 2013, ARM Ltd. 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.
+
+**/
+
+#ifndef __VIRTIO_DEVICE_H__
+#define __VIRTIO_DEVICE_H__
+
+// VirtIo Specification Revision: Major[31:24].Minor[23:16].Revision[15:0
+#define VIRTIO_SPEC_REVISION(major,minor,revision) \
+ ((((major) & 0xFF) << 24) | (((minor) & 0xFF) << 16) | ((revision) & 0xFFFF))
+
+#define VIRTIO_DEVICE_PROTOCOL_GUID { \
+ 0xfa920010, 0x6785, 0x4941, {0xb6, 0xec, 0x49, 0x8c, 0x57, 0x9f, 0x16, 0x0a }\
+ }
+
+typedef struct _VIRTIO_DEVICE_PROTOCOL VIRTIO_DEVICE_PROTOCOL;
+
+/**
+
+ Read a word from the device-specific I/O region of the Virtio Header.
+
+ @param[in] This This instance of VIRTIO_DEVICE_PROTOCOL
+
+ @param[in] FieldOffset Source offset.
+
+ @param[in] FieldSize Source field size in bytes, must be in {1, 2, 4, 8}.
+
+ @param[in] BufferSize Number of bytes available in the target buffer. Must
+ equal FieldSize.
+
+ @param[out] Buffer Target buffer.
+
+ @retval EFI_SUCCESS The data was read successfully.
+ @retval EFI_UNSUPPORTED The underlying IO device doesn't support the
+ provided address offset and read size.
+ @retval EFI_OUT_OF_RESOURCES The request could not be completed due to a
+ lack of resources.
+ @retval EFI_INVALID_PARAMETER One or more parameters are invalid.
+
+**/
+typedef
+EFI_STATUS
+(EFIAPI *VIRTIO_DEVICE_READ) (
+ IN VIRTIO_DEVICE_PROTOCOL *This,
+ IN UINTN FieldOffset,
+ IN UINTN FieldSize,
+ IN UINTN BufferSize,
+ OUT VOID *Buffer
+ );
+
+/**
+
+ Write a word to the device-specific I/O region of the Virtio Header.
+
+ @param[in] This This instance of VIRTIO_DEVICE_PROTOCOL
+
+ @param[in] FieldOffset Destination offset.
+
+ @param[in] FieldSize Destination field size in bytes,
+ must be in {1, 2, 4, 8}.
+
+ @param[out] Value Value to write.
+
+ @retval EFI_SUCCESS The data was written successfully.
+ @retval EFI_UNSUPPORTED The underlying IO device doesn't support the
+ provided address offset and write size.
+ @retval EFI_OUT_OF_RESOURCES The request could not be completed due to a
+ lack of resources.
+ @retval EFI_INVALID_PARAMETER One or more parameters are invalid.
+
+**/
+typedef
+EFI_STATUS
+(EFIAPI *VIRTIO_DEVICE_WRITE) (
+ IN VIRTIO_DEVICE_PROTOCOL *This,
+ IN UINTN FieldOffset,
+ IN UINTN FieldSize,
+ IN UINT64 Value
+ );
+
+/**
+ Read the device features field from the Virtio Header.
+
+ @param[in] This This instance of VIRTIO_DEVICE_PROTOCOL
+
+ @param[out] DeviceFeatures The 32-bit device features field.
+
+ @retval EFI_SUCCESS The data was read successfully.
+ @retval EFI_UNSUPPORTED The underlying IO device doesn't support the
+ provided address offset and read size.
+ @retval EFI_INVALID_PARAMETER DeviceFeatures is NULL
+**/
+typedef
+EFI_STATUS
+(EFIAPI *VIRTIO_GET_DEVICE_FEATURES) (
+ IN VIRTIO_DEVICE_PROTOCOL *This,
+ OUT UINT32 *DeviceFeatures
+ );
+
+/**
+ Write the guest features field in the Virtio Header.
+
+ @param[in] This This instance of VIRTIO_DEVICE_PROTOCOL
+
+ @param[in] Features The 32-bit guest guest features field
+
+**/
+typedef
+EFI_STATUS
+(EFIAPI *VIRTIO_SET_GUEST_FEATURES) (
+ IN VIRTIO_DEVICE_PROTOCOL *This,
+ IN UINT32 Features
+ );
+
+/**
+ Read the queue address field from the Virtio Header.
+
+ QueueAddress is the address of the virtqueue divided by 4096.
+
+ @param[in] This This instance of VIRTIO_DEVICE_PROTOCOL
+
+ @param[out] QueueAddress The 32-bit queue address field.
+
+ @retval EFI_SUCCESS The data was read successfully.
+ @retval EFI_UNSUPPORTED The underlying IO device doesn't support the
+ provided address offset and read size.
+ @retval EFI_INVALID_PARAMETER QueueAddress is NULL
+**/
+typedef
+EFI_STATUS
+(EFIAPI *VIRTIO_GET_QUEUE_ADDRESS) (
+ IN VIRTIO_DEVICE_PROTOCOL *This,
+ OUT UINT32 *QueueAddress
+ );
+
+/**
+ Write the queue address field in the Virtio Header.
+
+ The parameter Address must be the base address of the virtqueue divided
+ by 4096.
+
+ @param[in] This This instance of VIRTIO_DEVICE_PROTOCOL
+
+ @param[in] Address The 32-bit Queue Address field
+
+ @retval EFI_SUCCESS The data was written successfully.
+ @retval EFI_UNSUPPORTED The underlying IO device doesn't support the
+ provided address offset and write size.
+**/
+typedef
+EFI_STATUS
+(EFIAPI *VIRTIO_SET_QUEUE_ADDRESS) (
+ IN VIRTIO_DEVICE_PROTOCOL *This,
+ IN UINT32 Address
+ );
+
+/**
+
+ Write the queue select field in the Virtio Header.
+
+ Writing to the queue select field sets the index of the queue to which
+ operations such as SetQueueAlign and GetQueueNumMax apply.
+
+ @param[in] This This instance of VIRTIO_DEVICE_PROTOCOL
+
+ @param[in] Index The index of the queue to select
+
+ @retval EFI_SUCCESS The data was written successfully.
+ @retval EFI_UNSUPPORTED The underlying IO device doesn't support the
+ provided address offset and write size.
+**/
+typedef
+EFI_STATUS
+(EFIAPI *VIRTIO_SET_QUEUE_SEL) (
+ IN VIRTIO_DEVICE_PROTOCOL *This,
+ IN UINT16 Index
+ );
+
+/**
+
+ Write the queue notify field in the Virtio Header.
+
+ @param[in] This This instance of VIRTIO_DEVICE_PROTOCOL
+
+ @param[in] Address The 32-bit Queue Notify field
+
+ @retval EFI_SUCCESS The data was written successfully.
+ @retval EFI_UNSUPPORTED The underlying IO device doesn't support the
+ provided address offset and write size.
+**/
+typedef
+EFI_STATUS
+(EFIAPI *VIRTIO_SET_QUEUE_NOTIFY) (
+ IN VIRTIO_DEVICE_PROTOCOL *This,
+ IN UINT16 Index
+ );
+
+/**
+ Write the queue alignment field in the Virtio Header.
+
+ The queue to which the alignment applies is selected by the Queue Select
+ field.
+
+ Note: This operation is not implemented by the VirtIo over PCI. The PCI
+ implementation of this protocol returns EFI_SUCCESS.
+
+ @param[in] This This instance of VIRTIO_DEVICE_PROTOCOL
+
+ @param[in] Alignment The alignment boundary of the Used Ring in bytes.
+ Must be a power of 2.
+
+ @retval EFI_SUCCESS The data was written successfully.
+ @retval EFI_UNSUPPORTED The underlying IO device doesn't support the
+ provided address offset and write size.
+**/
+typedef
+EFI_STATUS
+(EFIAPI *VIRTIO_SET_QUEUE_ALIGN) (
+ IN VIRTIO_DEVICE_PROTOCOL *This,
+ IN UINT32 Alignment
+ );
+
+/**
+ Write the guest page size.
+
+ Note: This operation is not implemented by the VirtIo over PCI. The PCI
+ implementation of this protocol returns EFI_SUCCESS.
+
+ @param[in] This This instance of VIRTIO_DEVICE_PROTOCOL
+
+ @param[in] PageSize Size of the Guest page in bytes.
+ Must be a power of 2.
+
+ @retval EFI_SUCCESS The data was written successfully.
+ @retval EFI_UNSUPPORTED The underlying IO device doesn't support the
+ provided address offset and write size.
+**/
+typedef
+EFI_STATUS
+(EFIAPI *VIRTIO_SET_PAGE_SIZE) (
+ IN VIRTIO_DEVICE_PROTOCOL *This,
+ IN UINT32 PageSize
+ );
+
+/**
+
+ Get the size of the virtqueue selected by the queue select field.
+
+ See Virtio spec Section 2.3
+
+ @param[in] This This instance of VIRTIO_DEVICE_PROTOCOL
+
+ @param[out] QueueNumMax The size of the virtqueue in bytes.
+ Always a power of 2.
+
+ @retval EFI_SUCCESS The data was read successfully.
+ @retval EFI_UNSUPPORTED The underlying IO device doesn't support the
+ provided address offset and read size.
+ @retval EFI_INVALID_PARAMETER QueueNumMax is NULL
+**/
+typedef
+EFI_STATUS
+(EFIAPI *VIRTIO_GET_QUEUE_NUM_MAX) (
+ IN VIRTIO_DEVICE_PROTOCOL *This,
+ OUT UINT16 *QueueNumMax
+ );
+
+/**
+
+ Write to the QueueNum field in the Virtio Header.
+
+ This function only applies to Virtio-MMIO and may be a stub for other
+ implementations. See Virtio Spec appendix X.
+
+ @param[in] This This instance of VIRTIO_DEVICE_PROTOCOL
+
+ @param[in] QueueSize The number of elements in the queue.
+
+ @retval EFI_SUCCESS The data was written successfully.
+ @retval EFI_UNSUPPORTED The underlying IO device doesn't support the
+ provided address offset and write size.
+**/
+typedef
+EFI_STATUS
+(EFIAPI *VIRTIO_SET_QUEUE_NUM) (
+ IN VIRTIO_DEVICE_PROTOCOL *This,
+ IN UINT16 QueueSize
+ );
+
+/**
+
+ Get the DeviceStatus field from the Virtio Header.
+
+ @param[in] This This instance of VIRTIO_DEVICE_PROTOCOL
+
+ @param[out] DeviceStatus The 8-bit value for the Device status field
+
+ @retval EFI_SUCCESS The data was read successfully.
+ @retval EFI_UNSUPPORTED The underlying IO device doesn't support the
+ provided address offset and read size.
+ @retval EFI_INVALID_PARAMETER DeviceStatus is NULL
+**/
+typedef
+EFI_STATUS
+(EFIAPI *VIRTIO_GET_DEVICE_STATUS) (
+ IN VIRTIO_DEVICE_PROTOCOL *This,
+ OUT UINT8 *DeviceStatus
+ );
+
+/**
+
+ Write the DeviceStatus field in the Virtio Header.
+
+ @param[in] This This instance of VIRTIO_DEVICE_PROTOCOL
+
+ @param[in] DeviceStatus The 8-bit value for the Device status field
+
+ @retval EFI_SUCCESS The data was written successfully.
+ @retval EFI_UNSUPPORTED The underlying IO device doesn't support the
+ provided address offset and write size.
+**/
+typedef
+EFI_STATUS
+(EFIAPI *VIRTIO_SET_DEVICE_STATUS) (
+ IN VIRTIO_DEVICE_PROTOCOL *This,
+ IN UINT8 DeviceStatus
+ );
+
+
+///
+/// This protocol provides an abstraction over the VirtIo transport layer
+///
+struct _VIRTIO_DEVICE_PROTOCOL {
+ /// VirtIo Specification Revision encoded with VIRTIO_SPEC_REVISION()
+ UINT32 Revision;
+ /// From the Virtio Spec
+ INT32 SubSystemDeviceId;
+
+ VIRTIO_GET_DEVICE_FEATURES GetDeviceFeatures;
+ VIRTIO_SET_GUEST_FEATURES SetGuestFeatures;
+
+ VIRTIO_GET_QUEUE_ADDRESS GetQueueAddress;
+ VIRTIO_SET_QUEUE_ADDRESS SetQueueAddress;
+
+ VIRTIO_SET_QUEUE_SEL SetQueueSel;
+
+ VIRTIO_SET_QUEUE_NOTIFY SetQueueNotify;
+
+ VIRTIO_SET_QUEUE_ALIGN SetQueueAlign;
+ VIRTIO_SET_PAGE_SIZE SetPageSize;
+
+ VIRTIO_GET_QUEUE_NUM_MAX GetQueueNumMax;
+ VIRTIO_SET_QUEUE_NUM SetQueueNum;
+
+ VIRTIO_GET_DEVICE_STATUS GetDeviceStatus;
+ VIRTIO_SET_DEVICE_STATUS SetDeviceStatus;
+
+ // Functions to read/write Device Specific headers
+ VIRTIO_DEVICE_WRITE WriteDevice;
+ VIRTIO_DEVICE_READ ReadDevice;
+};
+
+extern EFI_GUID gVirtioDeviceProtocolGuid;
+
+#endif
diff --git a/OvmfPkg/Library/LoadLinuxLib/Linux.c b/OvmfPkg/Library/LoadLinuxLib/Linux.c
index 4a3e2c13c..37b14f561 100644
--- a/OvmfPkg/Library/LoadLinuxLib/Linux.c
+++ b/OvmfPkg/Library/LoadLinuxLib/Linux.c
@@ -647,7 +647,7 @@ LoadLinux (
Bp->hdr.code32_start = (UINT32)(UINTN) Kernel;
if (Bp->hdr.version >= 0x20c && Bp->hdr.handover_offset &&
- (Bp->hdr.load_flags & (sizeof (UINTN) == 4 ? BIT2 : BIT3))) {
+ (Bp->hdr.xloadflags & (sizeof (UINTN) == 4 ? BIT2 : BIT3))) {
DEBUG ((EFI_D_INFO, "Jumping to kernel EFI handover point at ofs %x\n", Bp->hdr.handover_offset));
DisableInterrupts ();
diff --git a/OvmfPkg/Library/PlatformBdsLib/QemuBootOrder.c b/OvmfPkg/Library/PlatformBdsLib/QemuBootOrder.c
index c9b8556fa..daab658a1 100644
--- a/OvmfPkg/Library/PlatformBdsLib/QemuBootOrder.c
+++ b/OvmfPkg/Library/PlatformBdsLib/QemuBootOrder.c
@@ -2,6 +2,7 @@
Rewrite the BootOrder NvVar based on QEMU's "bootorder" fw_cfg file.
Copyright (C) 2012 - 2013, Red Hat, Inc.
+ Copyright (c) 2013, 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
@@ -238,16 +239,27 @@ typedef struct {
/**
+ Array element tracking an enumerated boot option that has the
+ LOAD_OPTION_ACTIVE attribute.
+**/
+typedef struct {
+ CONST BDS_COMMON_OPTION *BootOption; // reference only, no ownership
+ BOOLEAN Appended; // has been added to a BOOT_ORDER?
+} ACTIVE_OPTION;
+
- Append BootOptionId to BootOrder, reallocating the latter if needed.
+/**
+
+ Append an active boot option to BootOrder, reallocating the latter if needed.
@param[in out] BootOrder The structure pointing to the array and holding
allocation and usage counters.
- @param[in] BootOptionId The value to append to the array.
+ @param[in] ActiveOption The active boot option whose ID should be
+ appended to the array.
- @retval RETURN_SUCCESS BootOptionId appended.
+ @retval RETURN_SUCCESS ID of ActiveOption appended.
@retval RETURN_OUT_OF_RESOURCES Memory reallocation failed.
@@ -255,8 +267,8 @@ typedef struct {
STATIC
RETURN_STATUS
BootOrderAppend (
- IN OUT BOOT_ORDER *BootOrder,
- IN UINT16 BootOptionId
+ IN OUT BOOT_ORDER *BootOrder,
+ IN OUT ACTIVE_OPTION *ActiveOption
)
{
if (BootOrder->Produced == BootOrder->Allocated) {
@@ -277,7 +289,81 @@ BootOrderAppend (
BootOrder->Data = DataNew;
}
- BootOrder->Data[BootOrder->Produced++] = BootOptionId;
+ BootOrder->Data[BootOrder->Produced++] =
+ ActiveOption->BootOption->BootCurrent;
+ ActiveOption->Appended = TRUE;
+ return RETURN_SUCCESS;
+}
+
+
+/**
+
+ Create an array of ACTIVE_OPTION elements for a boot option list.
+
+ @param[in] BootOptionList A boot option list, created with
+ BdsLibEnumerateAllBootOption().
+
+ @param[out] ActiveOption Pointer to the first element in the new array.
+ The caller is responsible for freeing the array
+ with FreePool() after use.
+
+ @param[out] Count Number of elements in the new array.
+
+
+ @retval RETURN_SUCCESS The ActiveOption array has been created.
+
+ @retval RETURN_NOT_FOUND No active entry has been found in
+ BootOptionList.
+
+ @retval RETURN_OUT_OF_RESOURCES Memory allocation failed.
+
+**/
+STATIC
+RETURN_STATUS
+CollectActiveOptions (
+ IN CONST LIST_ENTRY *BootOptionList,
+ OUT ACTIVE_OPTION **ActiveOption,
+ OUT UINTN *Count
+ )
+{
+ UINTN ScanMode;
+
+ *ActiveOption = NULL;
+
+ //
+ // Scan the list twice:
+ // - count active entries,
+ // - store links to active entries.
+ //
+ for (ScanMode = 0; ScanMode < 2; ++ScanMode) {
+ CONST LIST_ENTRY *Link;
+
+ Link = BootOptionList->ForwardLink;
+ *Count = 0;
+ while (Link != BootOptionList) {
+ CONST BDS_COMMON_OPTION *Current;
+
+ Current = CR (Link, BDS_COMMON_OPTION, Link, BDS_LOAD_OPTION_SIGNATURE);
+ if (IS_LOAD_OPTION_TYPE (Current->Attribute, LOAD_OPTION_ACTIVE)) {
+ if (ScanMode == 1) {
+ (*ActiveOption)[*Count].BootOption = Current;
+ (*ActiveOption)[*Count].Appended = FALSE;
+ }
+ ++*Count;
+ }
+ Link = Link->ForwardLink;
+ }
+
+ if (ScanMode == 0) {
+ if (*Count == 0) {
+ return RETURN_NOT_FOUND;
+ }
+ *ActiveOption = AllocatePool (*Count * sizeof **ActiveOption);
+ if (*ActiveOption == NULL) {
+ return RETURN_OUT_OF_RESOURCES;
+ }
+ }
+ }
return RETURN_SUCCESS;
}
@@ -882,6 +968,34 @@ Match (
}
//
+ // Attempt to expand any relative UEFI device path starting with HD() to an
+ // absolute device path first. The logic imitates BdsLibBootViaBootOption().
+ // We don't have to free the absolute device path,
+ // BdsExpandPartitionPartialDevicePathToFull() has internal caching.
+ //
+ Result = FALSE;
+ if (DevicePathType (DevicePath) == MEDIA_DEVICE_PATH &&
+ DevicePathSubType (DevicePath) == MEDIA_HARDDRIVE_DP) {
+ EFI_DEVICE_PATH_PROTOCOL *AbsDevicePath;
+ CHAR16 *AbsConverted;
+
+ AbsDevicePath = BdsExpandPartitionPartialDevicePathToFull (
+ (HARDDRIVE_DEVICE_PATH *) DevicePath);
+ if (AbsDevicePath == NULL) {
+ goto Exit;
+ }
+ AbsConverted = ConvertDevicePathToText (AbsDevicePath, FALSE, FALSE);
+ if (AbsConverted == NULL) {
+ goto Exit;
+ }
+ DEBUG ((DEBUG_VERBOSE,
+ "%a: expanded relative device path \"%s\" for prefix matching\n",
+ __FUNCTION__, Converted));
+ FreePool (Converted);
+ Converted = AbsConverted;
+ }
+
+ //
// Is Translated a prefix of Converted?
//
Result = (BOOLEAN)(StrnCmp (Converted, Translated, TranslatedLength) == 0);
@@ -892,12 +1006,112 @@ Match (
Converted,
Result ? "match" : "no match"
));
+Exit:
FreePool (Converted);
return Result;
}
/**
+ Append some of the unselected active boot options to the boot order.
+
+ This function should accommodate any further policy changes in "boot option
+ survival". Currently we're adding back everything that starts with neither
+ PciRoot() nor HD().
+
+ @param[in,out] BootOrder The structure holding the boot order to
+ complete. The caller is responsible for
+ initializing (and potentially populating) it
+ before calling this function.
+
+ @param[in,out] ActiveOption The array of active boot options to scan.
+ Entries marked as Appended will be skipped.
+ Those of the rest that satisfy the survival
+ policy will be added to BootOrder with
+ BootOrderAppend().
+
+ @param[in] ActiveCount Number of elements in ActiveOption.
+
+
+ @retval RETURN_SUCCESS BootOrder has been extended with any eligible boot
+ options.
+
+ @return Error codes returned by BootOrderAppend().
+**/
+STATIC
+RETURN_STATUS
+BootOrderComplete (
+ IN OUT BOOT_ORDER *BootOrder,
+ IN OUT ACTIVE_OPTION *ActiveOption,
+ IN UINTN ActiveCount
+ )
+{
+ RETURN_STATUS Status;
+ UINTN Idx;
+
+ Status = RETURN_SUCCESS;
+ Idx = 0;
+ while (!RETURN_ERROR (Status) && Idx < ActiveCount) {
+ if (!ActiveOption[Idx].Appended) {
+ CONST BDS_COMMON_OPTION *Current;
+ CONST EFI_DEVICE_PATH_PROTOCOL *FirstNode;
+
+ Current = ActiveOption[Idx].BootOption;
+ FirstNode = Current->DevicePath;
+ if (FirstNode != NULL) {
+ CHAR16 *Converted;
+ STATIC CHAR16 ConvFallBack[] = L"<unable to convert>";
+ BOOLEAN Keep;
+
+ Converted = ConvertDevicePathToText (FirstNode, FALSE, FALSE);
+ if (Converted == NULL) {
+ Converted = ConvFallBack;
+ }
+
+ Keep = TRUE;
+ if (DevicePathType(FirstNode) == MEDIA_DEVICE_PATH &&
+ DevicePathSubType(FirstNode) == MEDIA_HARDDRIVE_DP) {
+ //
+ // drop HD()
+ //
+ Keep = FALSE;
+ } else if (DevicePathType(FirstNode) == ACPI_DEVICE_PATH &&
+ DevicePathSubType(FirstNode) == ACPI_DP) {
+ ACPI_HID_DEVICE_PATH *Acpi;
+
+ Acpi = (ACPI_HID_DEVICE_PATH *) FirstNode;
+ if ((Acpi->HID & PNP_EISA_ID_MASK) == PNP_EISA_ID_CONST &&
+ EISA_ID_TO_NUM (Acpi->HID) == 0x0a03) {
+ //
+ // drop PciRoot()
+ //
+ Keep = FALSE;
+ }
+ }
+
+ if (Keep) {
+ Status = BootOrderAppend (BootOrder, &ActiveOption[Idx]);
+ if (!RETURN_ERROR (Status)) {
+ DEBUG ((DEBUG_VERBOSE, "%a: keeping \"%s\"\n", __FUNCTION__,
+ Converted));
+ }
+ } else {
+ DEBUG ((DEBUG_VERBOSE, "%a: dropping \"%s\"\n", __FUNCTION__,
+ Converted));
+ }
+
+ if (Converted != ConvFallBack) {
+ FreePool (Converted);
+ }
+ }
+ }
+ ++Idx;
+ }
+ return Status;
+}
+
+
+/**
Set the boot order based on configuration retrieved from QEMU.
@@ -938,6 +1152,8 @@ SetBootOrderFromQemu (
CONST CHAR8 *FwCfgPtr;
BOOT_ORDER BootOrder;
+ ACTIVE_OPTION *ActiveOption;
+ UINTN ActiveCount;
UINTN TranslatedSize;
CHAR16 Translated[TRANSLATION_OUTPUT_SIZE];
@@ -978,6 +1194,11 @@ SetBootOrderFromQemu (
goto ErrorFreeFwCfg;
}
+ Status = CollectActiveOptions (BootOptionList, &ActiveOption, &ActiveCount);
+ if (RETURN_ERROR (Status)) {
+ goto ErrorFreeBootOrder;
+ }
+
//
// translate each OpenFirmware path
//
@@ -987,38 +1208,28 @@ SetBootOrderFromQemu (
Status == RETURN_UNSUPPORTED ||
Status == RETURN_BUFFER_TOO_SMALL) {
if (Status == RETURN_SUCCESS) {
- CONST LIST_ENTRY *Link;
+ UINTN Idx;
//
- // match translated OpenFirmware path against all enumerated boot options
+ // match translated OpenFirmware path against all active boot options
//
- for (Link = BootOptionList->ForwardLink; Link != BootOptionList;
- Link = Link->ForwardLink) {
- CONST BDS_COMMON_OPTION *BootOption;
-
- BootOption = CR (
- Link,
- BDS_COMMON_OPTION,
- Link,
- BDS_LOAD_OPTION_SIGNATURE
- );
- if (IS_LOAD_OPTION_TYPE (BootOption->Attribute, LOAD_OPTION_ACTIVE) &&
- Match (
+ for (Idx = 0; Idx < ActiveCount; ++Idx) {
+ if (Match (
Translated,
TranslatedSize, // contains length, not size, in CHAR16's here
- BootOption->DevicePath
+ ActiveOption[Idx].BootOption->DevicePath
)
) {
//
// match found, store ID and continue with next OpenFirmware path
//
- Status = BootOrderAppend (&BootOrder, BootOption->BootCurrent);
+ Status = BootOrderAppend (&BootOrder, &ActiveOption[Idx]);
if (Status != RETURN_SUCCESS) {
- goto ErrorFreeBootOrder;
+ goto ErrorFreeActiveOption;
}
break;
}
- } // scanned all enumerated boot options
+ } // scanned all active boot options
} // translation successful
TranslatedSize = sizeof (Translated) / sizeof (Translated[0]);
@@ -1028,6 +1239,15 @@ SetBootOrderFromQemu (
if (Status == RETURN_NOT_FOUND && BootOrder.Produced > 0) {
//
// No more OpenFirmware paths, some matches found: rewrite BootOrder NvVar.
+ // Some of the active boot options that have not been selected over fw_cfg
+ // should be preserved at the end of the boot order.
+ //
+ Status = BootOrderComplete (&BootOrder, ActiveOption, ActiveCount);
+ if (RETURN_ERROR (Status)) {
+ goto ErrorFreeActiveOption;
+ }
+
+ //
// See Table 10 in the UEFI Spec 2.3.1 with Errata C for the required
// attributes.
//
@@ -1048,6 +1268,9 @@ SetBootOrderFromQemu (
));
}
+ErrorFreeActiveOption:
+ FreePool (ActiveOption);
+
ErrorFreeBootOrder:
FreePool (BootOrder.Data);
diff --git a/OvmfPkg/Library/VirtioLib/VirtioLib.c b/OvmfPkg/Library/VirtioLib/VirtioLib.c
index 959bc5da8..1550318d8 100644
--- a/OvmfPkg/Library/VirtioLib/VirtioLib.c
+++ b/OvmfPkg/Library/VirtioLib/VirtioLib.c
@@ -3,6 +3,7 @@
Utility functions used by virtio device drivers.
Copyright (C) 2012, Red Hat, Inc.
+ Portion of Copyright (C) 2013, ARM Ltd.
This program and the accompanying materials are licensed and made available
under the terms and conditions of the BSD License which accompanies this
@@ -14,7 +15,6 @@
**/
-#include <IndustryStandard/Pci22.h>
#include <Library/BaseLib.h>
#include <Library/BaseMemoryLib.h>
#include <Library/DebugLib.h>
@@ -26,143 +26,6 @@
/**
- Write a word into Region 0 of the device specified by PciIo.
-
- Region 0 must be an iomem region. This is an internal function for the
- driver-specific VIRTIO_CFG_WRITE() macros.
-
- @param[in] PciIo Target PCI device.
-
- @param[in] FieldOffset Destination offset.
-
- @param[in] FieldSize Destination field size, must be in { 1, 2, 4, 8 }.
-
- @param[in] Value Little endian value to write, converted to UINT64.
- The least significant FieldSize bytes will be used.
-
-
- @return Status code returned by PciIo->Io.Write().
-
-**/
-EFI_STATUS
-EFIAPI
-VirtioWrite (
- IN EFI_PCI_IO_PROTOCOL *PciIo,
- IN UINTN FieldOffset,
- IN UINTN FieldSize,
- IN UINT64 Value
- )
-{
- UINTN Count;
- EFI_PCI_IO_PROTOCOL_WIDTH Width;
-
- Count = 1;
- switch (FieldSize) {
- case 1:
- Width = EfiPciIoWidthUint8;
- break;
-
- case 2:
- Width = EfiPciIoWidthUint16;
- break;
-
- case 8:
- Count = 2;
- // fall through
-
- case 4:
- Width = EfiPciIoWidthUint32;
- break;
-
- default:
- ASSERT (FALSE);
- return EFI_INVALID_PARAMETER;
- }
-
- return PciIo->Io.Write (
- PciIo,
- Width,
- PCI_BAR_IDX0,
- FieldOffset,
- Count,
- &Value
- );
-}
-
-
-/**
-
- Read a word from Region 0 of the device specified by PciIo.
-
- Region 0 must be an iomem region. This is an internal function for the
- driver-specific VIRTIO_CFG_READ() macros.
-
- @param[in] PciIo Source PCI device.
-
- @param[in] FieldOffset Source offset.
-
- @param[in] FieldSize Source field size, must be in { 1, 2, 4, 8 }.
-
- @param[in] BufferSize Number of bytes available in the target buffer. Must
- equal FieldSize.
-
- @param[out] Buffer Target buffer.
-
-
- @return Status code returned by PciIo->Io.Read().
-
-**/
-EFI_STATUS
-EFIAPI
-VirtioRead (
- IN EFI_PCI_IO_PROTOCOL *PciIo,
- IN UINTN FieldOffset,
- IN UINTN FieldSize,
- IN UINTN BufferSize,
- OUT VOID *Buffer
- )
-{
- UINTN Count;
- EFI_PCI_IO_PROTOCOL_WIDTH Width;
-
- ASSERT (FieldSize == BufferSize);
-
- Count = 1;
- switch (FieldSize) {
- case 1:
- Width = EfiPciIoWidthUint8;
- break;
-
- case 2:
- Width = EfiPciIoWidthUint16;
- break;
-
- case 8:
- Count = 2;
- // fall through
-
- case 4:
- Width = EfiPciIoWidthUint32;
- break;
-
- default:
- ASSERT (FALSE);
- return EFI_INVALID_PARAMETER;
- }
-
- return PciIo->Io.Read (
- PciIo,
- Width,
- PCI_BAR_IDX0,
- FieldOffset,
- Count,
- Buffer
- );
-}
-
-
-/**
-
Configure a virtio ring.
This function sets up internal storage (the guest-host communication area)
@@ -376,7 +239,7 @@ VirtioAppendDesc (
Notify the host about the descriptor chain just built, and wait until the
host processes it.
- @param[in] PciIo The target virtio PCI device to notify.
+ @param[in] VirtIo The target virtio device to notify.
@param[in] VirtQueueId Identifies the queue for the target device.
@@ -387,7 +250,7 @@ VirtioAppendDesc (
of the descriptor chain.
- @return Error code from VirtioWrite() if it fails.
+ @return Error code from VirtioWriteDevice() if it fails.
@retval EFI_SUCCESS Otherwise, the host processed all descriptors.
@@ -395,10 +258,10 @@ VirtioAppendDesc (
EFI_STATUS
EFIAPI
VirtioFlush (
- IN EFI_PCI_IO_PROTOCOL *PciIo,
- IN UINT16 VirtQueueId,
- IN OUT VRING *Ring,
- IN DESC_INDICES *Indices
+ IN VIRTIO_DEVICE_PROTOCOL *VirtIo,
+ IN UINT16 VirtQueueId,
+ IN OUT VRING *Ring,
+ IN DESC_INDICES *Indices
)
{
UINT16 NextAvailIdx;
@@ -427,12 +290,7 @@ VirtioFlush (
// OK.
//
MemoryFence();
- Status = VirtioWrite (
- PciIo,
- OFFSET_OF (VIRTIO_HDR, VhdrQueueNotify),
- sizeof (UINT16),
- VirtQueueId
- );
+ Status = VirtIo->SetQueueNotify (VirtIo, VirtQueueId);
if (EFI_ERROR (Status)) {
return Status;
}
diff --git a/OvmfPkg/Library/VirtioMmioDeviceLib/VirtioMmioDevice.c b/OvmfPkg/Library/VirtioMmioDeviceLib/VirtioMmioDevice.c
new file mode 100644
index 000000000..f763db5fb
--- /dev/null
+++ b/OvmfPkg/Library/VirtioMmioDeviceLib/VirtioMmioDevice.c
@@ -0,0 +1,204 @@
+/** @file
+
+ This driver produces Virtio Device Protocol instances for Virtio Mmio devices.
+
+ Copyright (C) 2013, ARM Ltd.
+
+ 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.
+
+**/
+
+#include <Library/BaseMemoryLib.h>
+#include <Library/MemoryAllocationLib.h>
+#include <Library/UefiBootServicesTableLib.h>
+
+#include "VirtioMmioDevice.h"
+
+static VIRTIO_DEVICE_PROTOCOL mMmioDeviceProtocolTemplate = {
+ 0, // Revision
+ 0, // SubSystemDeviceId
+ VirtioMmioGetDeviceFeatures, // GetDeviceFeatures
+ VirtioMmioSetGuestFeatures, // SetGuestFeatures
+ VirtioMmioGetQueueAddress, // GetQueueAddress
+ VirtioMmioSetQueueAddress, // SetQueueAddress
+ VirtioMmioSetQueueSel, // SetQueueSel
+ VirtioMmioSetQueueNotify, // SetQueueNotify
+ VirtioMmioSetQueueAlignment, // SetQueueAlign
+ VirtioMmioSetPageSize, // SetPageSize
+ VirtioMmioGetQueueSize, // GetQueueNumMax
+ VirtioMmioSetQueueSize, // SetQueueNum
+ VirtioMmioGetDeviceStatus, // GetDeviceStatus
+ VirtioMmioSetDeviceStatus, // SetDeviceStatus
+ VirtioMmioDeviceWrite, // WriteDevice
+ VirtioMmioDeviceRead // ReadDevice
+};
+
+/**
+
+ Initialize the VirtIo MMIO Device
+
+ @param[in] BaseAddress Base Address of the VirtIo MMIO Device
+
+ @param[in, out] Device The driver instance to configure.
+
+ @retval EFI_SUCCESS Setup complete.
+
+ @retval EFI_UNSUPPORTED The driver is not a VirtIo MMIO device.
+
+**/
+STATIC
+EFI_STATUS
+EFIAPI
+VirtioMmioInit (
+ IN PHYSICAL_ADDRESS BaseAddress,
+ IN OUT VIRTIO_MMIO_DEVICE *Device
+ )
+{
+ UINT32 MagicValue;
+ UINT32 VendorId;
+ UINT32 Version;
+
+ // Initialize VirtIo Mmio Device
+ CopyMem (&Device->VirtioDevice, &mMmioDeviceProtocolTemplate,
+ sizeof (VIRTIO_DEVICE_PROTOCOL));
+ Device->BaseAddress = BaseAddress;
+ Device->VirtioDevice.Revision = VIRTIO_SPEC_REVISION (0, 9, 5);
+ Device->VirtioDevice.SubSystemDeviceId =
+ MmioRead32 (BaseAddress + VIRTIO_MMIO_OFFSET_DEVICE_ID);
+
+ // Double-check MMIO-specific values
+ MagicValue = VIRTIO_CFG_READ (Device, VIRTIO_MMIO_OFFSET_MAGIC);
+ if (MagicValue != VIRTIO_MMIO_MAGIC) {
+ return EFI_UNSUPPORTED;
+ }
+
+ Version = VIRTIO_CFG_READ (Device, VIRTIO_MMIO_OFFSET_VERSION);
+ if (Version != 1) {
+ return EFI_UNSUPPORTED;
+ }
+
+ // Double-check MMIO-specific values
+ VendorId = VIRTIO_CFG_READ (Device, VIRTIO_MMIO_OFFSET_VENDOR_ID);
+ if (VendorId != VIRTIO_VENDOR_ID) {
+ // The ARM Base and Foundation Models do not report a valid VirtIo VendorId.
+ // They return a value of 0x0 for the VendorId.
+ DEBUG((EFI_D_WARN, "VirtioMmioInit: Warning: The VendorId (0x%X) does not "
+ "match the VirtIo VendorId (0x%X).\n",
+ VendorId, VIRTIO_VENDOR_ID));
+ //return EFI_UNSUPPORTED;
+ }
+
+ return EFI_SUCCESS;
+}
+
+
+/**
+
+ Uninitialize the internals of a virtio-mmio device that has been successfully
+ set up with VirtioMmioInit().
+
+ @param[in, out] Device The device to clean up.
+
+**/
+
+STATIC
+VOID
+EFIAPI
+VirtioMmioUninit (
+ IN VIRTIO_MMIO_DEVICE *Device
+ )
+{
+ // Note: This function mirrors VirtioMmioInit() that does not allocate any
+ // resources - there's nothing to free here.
+}
+
+EFI_STATUS
+VirtioMmioInstallDevice (
+ IN PHYSICAL_ADDRESS BaseAddress,
+ IN EFI_HANDLE Handle
+ )
+{
+ EFI_STATUS Status;
+ VIRTIO_MMIO_DEVICE *VirtIo;
+
+ if (!BaseAddress) {
+ return EFI_INVALID_PARAMETER;
+ }
+ if (Handle == NULL) {
+ return EFI_INVALID_PARAMETER;
+ }
+
+ // Allocate VIRTIO_MMIO_DEVICE
+ VirtIo = AllocateZeroPool (sizeof (VIRTIO_MMIO_DEVICE));
+ if (VirtIo == NULL) {
+ return EFI_OUT_OF_RESOURCES;
+ }
+
+ VirtIo->Signature = VIRTIO_MMIO_DEVICE_SIGNATURE;
+
+ Status = VirtioMmioInit (BaseAddress, VirtIo);
+ if (EFI_ERROR (Status)) {
+ goto FreeVirtioMem;
+ }
+
+ // Install VIRTIO_DEVICE_PROTOCOL to Handle
+ Status = gBS->InstallProtocolInterface (&Handle,
+ &gVirtioDeviceProtocolGuid, EFI_NATIVE_INTERFACE,
+ &VirtIo->VirtioDevice);
+ if (EFI_ERROR (Status)) {
+ goto UninitVirtio;
+ }
+
+ return EFI_SUCCESS;
+
+UninitVirtio:
+ VirtioMmioUninit (VirtIo);
+
+FreeVirtioMem:
+ FreePool (VirtIo);
+ return Status;
+}
+
+EFI_STATUS
+VirtioMmioUninstallDevice (
+ IN EFI_HANDLE DeviceHandle
+ )
+{
+ VIRTIO_DEVICE_PROTOCOL *VirtioDevice;
+ VIRTIO_MMIO_DEVICE *MmioDevice;
+ EFI_STATUS Status;
+
+ Status = gBS->OpenProtocol (
+ DeviceHandle, // candidate device
+ &gVirtioDeviceProtocolGuid, // retrieve the VirtIo iface
+ (VOID **)&VirtioDevice, // target pointer
+ DeviceHandle, // requestor driver identity
+ DeviceHandle, // requesting lookup for dev.
+ EFI_OPEN_PROTOCOL_GET_PROTOCOL // lookup only, no ref. added
+ );
+ if (EFI_ERROR (Status)) {
+ return Status;
+ }
+
+ // Get the MMIO device from the VirtIo Device instance
+ MmioDevice = VIRTIO_MMIO_DEVICE_FROM_VIRTIO_DEVICE (VirtioDevice);
+
+ // Uninstall the protocol interface
+ Status = gBS->UninstallProtocolInterface (DeviceHandle,
+ &gVirtioDeviceProtocolGuid, &MmioDevice->VirtioDevice
+ );
+ if (EFI_ERROR (Status)) {
+ return Status;
+ }
+
+ // Uninitialize the VirtIo Device
+ VirtioMmioUninit (MmioDevice);
+
+ return EFI_SUCCESS;
+}
diff --git a/OvmfPkg/Library/VirtioMmioDeviceLib/VirtioMmioDevice.h b/OvmfPkg/Library/VirtioMmioDeviceLib/VirtioMmioDevice.h
new file mode 100644
index 000000000..188d873ae
--- /dev/null
+++ b/OvmfPkg/Library/VirtioMmioDeviceLib/VirtioMmioDevice.h
@@ -0,0 +1,147 @@
+/** @file
+
+ Internal definitions for the VirtIo MMIO Device driver
+
+ Copyright (C) 2013, ARM Ltd
+
+ 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.
+
+**/
+
+#ifndef _VIRTIO_MMIO_DEVICE_INTERNAL_H_
+#define _VIRTIO_MMIO_DEVICE_INTERNAL_H_
+
+#include <Protocol/VirtioDevice.h>
+
+#include <IndustryStandard/Virtio.h>
+
+#include <Library/DebugLib.h>
+#include <Library/IoLib.h>
+#include <Library/UefiLib.h>
+#include <Library/VirtioMmioDeviceLib.h>
+
+#define VIRTIO_MMIO_DEVICE_SIGNATURE SIGNATURE_32 ('V', 'M', 'I', 'O')
+
+typedef struct {
+ UINT32 Signature;
+ VIRTIO_DEVICE_PROTOCOL VirtioDevice;
+ PHYSICAL_ADDRESS BaseAddress;
+} VIRTIO_MMIO_DEVICE;
+
+#define VIRTIO_MMIO_DEVICE_FROM_VIRTIO_DEVICE(Device) \
+ CR (Device, VIRTIO_MMIO_DEVICE, VirtioDevice, VIRTIO_MMIO_DEVICE_SIGNATURE)
+
+#define VIRTIO_CFG_WRITE(Device, Offset, Val) \
+ (MmioWrite32 (Device->BaseAddress + (Offset), Val))
+#define VIRTIO_CFG_READ(Device, Offset) \
+ (MmioRead32 (Device->BaseAddress + (Offset)))
+
+EFI_STATUS
+EFIAPI
+VirtioMmioDeviceRead (
+ IN VIRTIO_DEVICE_PROTOCOL *This,
+ IN UINTN FieldOFfset,
+ IN UINTN FieldSize,
+ IN UINTN BufferSize,
+ OUT VOID* Buffer
+ );
+
+EFI_STATUS
+EFIAPI
+VirtioMmioDeviceWrite (
+ IN VIRTIO_DEVICE_PROTOCOL *This,
+ IN UINTN FieldOffset,
+ IN UINTN FieldSize,
+ IN UINT64 Value
+ );
+
+EFI_STATUS
+EFIAPI
+VirtioMmioGetDeviceFeatures (
+ IN VIRTIO_DEVICE_PROTOCOL *This,
+ OUT UINT32 *DeviceFeatures
+ );
+
+EFI_STATUS
+EFIAPI
+VirtioMmioGetQueueAddress (
+ IN VIRTIO_DEVICE_PROTOCOL *This,
+ OUT UINT32 *QueueAddress
+ );
+
+EFI_STATUS
+EFIAPI
+VirtioMmioGetQueueSize (
+ IN VIRTIO_DEVICE_PROTOCOL *This,
+ OUT UINT16 *QueueNumMax
+ );
+
+EFI_STATUS
+EFIAPI
+VirtioMmioGetDeviceStatus (
+ IN VIRTIO_DEVICE_PROTOCOL *This,
+ OUT UINT8 *DeviceStatus
+ );
+
+EFI_STATUS
+EFIAPI
+VirtioMmioSetQueueSize (
+ VIRTIO_DEVICE_PROTOCOL *This,
+ UINT16 QueueSize
+ );
+
+EFI_STATUS
+EFIAPI
+VirtioMmioSetDeviceStatus (
+ VIRTIO_DEVICE_PROTOCOL *This,
+ UINT8 DeviceStatus
+ );
+
+EFI_STATUS
+EFIAPI
+VirtioMmioSetQueueNotify (
+ VIRTIO_DEVICE_PROTOCOL *This,
+ UINT16 QueueNotify
+ );
+
+EFI_STATUS
+EFIAPI
+VirtioMmioSetQueueSel (
+ VIRTIO_DEVICE_PROTOCOL *This,
+ UINT16 Sel
+ );
+
+EFI_STATUS
+VirtioMmioSetQueueAddress (
+ VIRTIO_DEVICE_PROTOCOL *This,
+ UINT32 Address
+ );
+
+EFI_STATUS
+EFIAPI
+VirtioMmioSetQueueAlignment (
+ VIRTIO_DEVICE_PROTOCOL *This,
+ UINT32 Alignment
+ );
+
+EFI_STATUS
+EFIAPI
+VirtioMmioSetPageSize (
+ VIRTIO_DEVICE_PROTOCOL *This,
+ UINT32 PageSize
+ );
+
+EFI_STATUS
+EFIAPI
+VirtioMmioSetGuestFeatures (
+ VIRTIO_DEVICE_PROTOCOL *This,
+ UINT32 Features
+ );
+
+#endif // _VIRTIO_MMIO_DEVICE_INTERNAL_H_
diff --git a/OvmfPkg/Library/VirtioMmioDeviceLib/VirtioMmioDeviceFunctions.c b/OvmfPkg/Library/VirtioMmioDeviceLib/VirtioMmioDeviceFunctions.c
new file mode 100644
index 000000000..fa76f8ffc
--- /dev/null
+++ b/OvmfPkg/Library/VirtioMmioDeviceLib/VirtioMmioDeviceFunctions.c
@@ -0,0 +1,304 @@
+/** @file
+
+ This driver produces Virtio Device Protocol instances for Virtio MMIO devices.
+
+ Copyright (C) 2012, Red Hat, Inc.
+ Copyright (c) 2012, Intel Corporation. All rights reserved.<BR>
+ Copyright (C) 2013, ARM Ltd.
+
+ 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.
+
+**/
+
+#include "VirtioMmioDevice.h"
+
+EFI_STATUS
+EFIAPI
+VirtioMmioGetDeviceFeatures (
+ IN VIRTIO_DEVICE_PROTOCOL *This,
+ OUT UINT32 *DeviceFeatures
+ )
+{
+ VIRTIO_MMIO_DEVICE *Device;
+
+ if (DeviceFeatures == NULL) {
+ return EFI_INVALID_PARAMETER;
+ }
+
+ Device = VIRTIO_MMIO_DEVICE_FROM_VIRTIO_DEVICE (This);
+
+ *DeviceFeatures = VIRTIO_CFG_READ (Device, VIRTIO_MMIO_OFFSET_HOST_FEATURES);
+
+ return EFI_SUCCESS;
+}
+
+EFI_STATUS
+EFIAPI
+VirtioMmioGetQueueAddress (
+ IN VIRTIO_DEVICE_PROTOCOL *This,
+ OUT UINT32 *QueueAddress
+ )
+{
+ VIRTIO_MMIO_DEVICE *Device;
+
+ if (QueueAddress == NULL) {
+
+ }
+
+ Device = VIRTIO_MMIO_DEVICE_FROM_VIRTIO_DEVICE (This);
+
+ *QueueAddress = VIRTIO_CFG_READ (Device, VIRTIO_MMIO_OFFSET_QUEUE_PFN);
+
+ return EFI_SUCCESS;
+}
+
+EFI_STATUS
+EFIAPI
+VirtioMmioGetQueueSize (
+ IN VIRTIO_DEVICE_PROTOCOL *This,
+ OUT UINT16 *QueueNumMax
+ )
+{
+ VIRTIO_MMIO_DEVICE *Device;
+
+ if (QueueNumMax == NULL) {
+ return EFI_INVALID_PARAMETER;
+ }
+
+ Device = VIRTIO_MMIO_DEVICE_FROM_VIRTIO_DEVICE (This);
+
+ *QueueNumMax = VIRTIO_CFG_READ (Device, VIRTIO_MMIO_OFFSET_QUEUE_NUM_MAX) & 0xFFFF;
+
+ return EFI_SUCCESS;
+}
+
+EFI_STATUS
+EFIAPI
+VirtioMmioGetDeviceStatus (
+ IN VIRTIO_DEVICE_PROTOCOL *This,
+ OUT UINT8 *DeviceStatus
+ )
+{
+ VIRTIO_MMIO_DEVICE *Device;
+
+ if (DeviceStatus == NULL) {
+ return EFI_INVALID_PARAMETER;
+ }
+
+ Device = VIRTIO_MMIO_DEVICE_FROM_VIRTIO_DEVICE (This);
+
+ *DeviceStatus = VIRTIO_CFG_READ (Device, VIRTIO_MMIO_OFFSET_STATUS) & 0xFF;
+
+ return EFI_SUCCESS;
+}
+
+EFI_STATUS
+EFIAPI
+VirtioMmioSetQueueSize (
+ VIRTIO_DEVICE_PROTOCOL *This,
+ UINT16 QueueSize
+ )
+{
+ VIRTIO_MMIO_DEVICE *Device;
+
+ Device = VIRTIO_MMIO_DEVICE_FROM_VIRTIO_DEVICE (This);
+
+ return VIRTIO_CFG_WRITE (Device, VIRTIO_MMIO_OFFSET_QUEUE_NUM, QueueSize);
+}
+
+EFI_STATUS
+EFIAPI
+VirtioMmioSetDeviceStatus (
+ VIRTIO_DEVICE_PROTOCOL *This,
+ UINT8 DeviceStatus
+ )
+{
+ VIRTIO_MMIO_DEVICE *Device;
+
+ Device = VIRTIO_MMIO_DEVICE_FROM_VIRTIO_DEVICE (This);
+
+ VIRTIO_CFG_WRITE (Device, VIRTIO_MMIO_OFFSET_STATUS, DeviceStatus);
+
+ return EFI_SUCCESS;
+}
+
+EFI_STATUS
+EFIAPI
+VirtioMmioSetQueueNotify (
+ VIRTIO_DEVICE_PROTOCOL *This,
+ UINT16 QueueNotify
+ )
+{
+ VIRTIO_MMIO_DEVICE *Device;
+
+ Device = VIRTIO_MMIO_DEVICE_FROM_VIRTIO_DEVICE (This);
+
+ VIRTIO_CFG_WRITE (Device, VIRTIO_MMIO_OFFSET_QUEUE_NOTIFY, QueueNotify);
+
+ return EFI_SUCCESS;
+}
+
+EFI_STATUS
+EFIAPI
+VirtioMmioSetQueueAlignment (
+ VIRTIO_DEVICE_PROTOCOL *This,
+ UINT32 Alignment
+ )
+{
+ VIRTIO_MMIO_DEVICE *Device;
+
+ Device = VIRTIO_MMIO_DEVICE_FROM_VIRTIO_DEVICE (This);
+
+ VIRTIO_CFG_WRITE (Device, VIRTIO_MMIO_OFFSET_QUEUE_ALIGN, Alignment);
+
+ return EFI_SUCCESS;
+}
+
+EFI_STATUS
+EFIAPI
+VirtioMmioSetPageSize (
+ VIRTIO_DEVICE_PROTOCOL *This,
+ UINT32 PageSize
+ )
+{
+ VIRTIO_MMIO_DEVICE *Device;
+
+ ASSERT (PageSize == EFI_PAGE_SIZE);
+
+ Device = VIRTIO_MMIO_DEVICE_FROM_VIRTIO_DEVICE (This);
+
+ VIRTIO_CFG_WRITE (Device, VIRTIO_MMIO_OFFSET_GUEST_PAGE_SIZE, PageSize);
+
+ return EFI_SUCCESS;
+}
+
+EFI_STATUS
+EFIAPI
+VirtioMmioSetQueueSel (
+ VIRTIO_DEVICE_PROTOCOL *This,
+ UINT16 Sel
+ )
+{
+ VIRTIO_MMIO_DEVICE *Device;
+
+ Device = VIRTIO_MMIO_DEVICE_FROM_VIRTIO_DEVICE (This);
+
+ VIRTIO_CFG_WRITE (Device, VIRTIO_MMIO_OFFSET_QUEUE_SEL, Sel);
+
+ return EFI_SUCCESS;
+}
+
+EFI_STATUS
+VirtioMmioSetQueueAddress (
+ VIRTIO_DEVICE_PROTOCOL *This,
+ UINT32 Address
+ )
+{
+ VIRTIO_MMIO_DEVICE *Device;
+
+ Device = VIRTIO_MMIO_DEVICE_FROM_VIRTIO_DEVICE (This);
+
+ VIRTIO_CFG_WRITE (Device, VIRTIO_MMIO_OFFSET_QUEUE_PFN, Address);
+
+ return EFI_SUCCESS;
+}
+
+EFI_STATUS
+EFIAPI
+VirtioMmioSetGuestFeatures (
+ VIRTIO_DEVICE_PROTOCOL *This,
+ UINT32 Features
+ )
+{
+ VIRTIO_MMIO_DEVICE *Device;
+
+ Device = VIRTIO_MMIO_DEVICE_FROM_VIRTIO_DEVICE (This);
+
+ VIRTIO_CFG_WRITE (Device, VIRTIO_MMIO_OFFSET_GUEST_FEATURES, Features);
+
+ return EFI_SUCCESS;
+}
+
+EFI_STATUS
+EFIAPI
+VirtioMmioDeviceWrite (
+ IN VIRTIO_DEVICE_PROTOCOL *This,
+ IN UINTN FieldOffset,
+ IN UINTN FieldSize,
+ IN UINT64 Value
+ )
+{
+ UINTN DstBaseAddress;
+ VIRTIO_MMIO_DEVICE *Device;
+
+ Device = VIRTIO_MMIO_DEVICE_FROM_VIRTIO_DEVICE (This);
+
+ // Double-check fieldsize
+ if (FieldSize > 8) {
+ return EFI_INVALID_PARAMETER;
+ }
+
+ if ((FieldSize != 1) && (FieldSize != 2) &&
+ (FieldSize != 4) && (FieldSize != 8)) {
+ return EFI_INVALID_PARAMETER;
+ }
+
+ // Compute base address
+ DstBaseAddress = Device->BaseAddress +
+ VIRTIO_DEVICE_SPECIFIC_CONFIGURATION_OFFSET_MMIO + FieldOffset;
+
+ //
+ // The device-specific memory area of Virtio-MMIO can only be written in
+ // byte accesses. This is not currently in the Virtio spec.
+ //
+ MmioWriteBuffer8 (DstBaseAddress, FieldSize, (UINT8*)&Value);
+
+ return EFI_SUCCESS;
+}
+
+EFI_STATUS
+EFIAPI
+VirtioMmioDeviceRead (
+ IN VIRTIO_DEVICE_PROTOCOL *This,
+ IN UINTN FieldOffset,
+ IN UINTN FieldSize,
+ IN UINTN BufferSize,
+ OUT VOID *Buffer
+ )
+{
+ UINTN SrcBaseAddress;
+ VIRTIO_MMIO_DEVICE *Device;
+
+ Device = VIRTIO_MMIO_DEVICE_FROM_VIRTIO_DEVICE (This);
+
+ // Parameter validation
+ ASSERT (FieldSize == BufferSize);
+
+ // Double-check fieldsize
+ if (FieldSize > 8) {
+ return EFI_INVALID_PARAMETER;
+ }
+
+ if ((FieldSize != 1) && (FieldSize != 2) &&
+ (FieldSize != 4) && (FieldSize != 8)) {
+ return EFI_INVALID_PARAMETER;
+ }
+
+ // Compute base address
+ SrcBaseAddress = Device->BaseAddress +
+ VIRTIO_DEVICE_SPECIFIC_CONFIGURATION_OFFSET_MMIO + FieldOffset;
+
+ //
+ // The device-specific memory area of Virtio-MMIO can only be read in
+ // byte reads. This is not currently in the Virtio spec.
+ //
+ MmioReadBuffer8 (SrcBaseAddress, BufferSize, Buffer);
+
+ return EFI_SUCCESS;
+}
diff --git a/OvmfPkg/Library/VirtioMmioDeviceLib/VirtioMmioDeviceLib.inf b/OvmfPkg/Library/VirtioMmioDeviceLib/VirtioMmioDeviceLib.inf
new file mode 100644
index 000000000..0758375aa
--- /dev/null
+++ b/OvmfPkg/Library/VirtioMmioDeviceLib/VirtioMmioDeviceLib.inf
@@ -0,0 +1,43 @@
+## @file
+# This driver produces the VirtIo Device Protocol instances for VirtIo Mmio
+# Device
+#
+# Copyright (C) 2013, ARM Ltd
+#
+# 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.
+#
+##
+
+[Defines]
+ INF_VERSION = 0x00010006
+ BASE_NAME = VirtioMmioDeviceLib
+ FILE_GUID = 3b6ed966-b5d1-46a8-965b-867ff22d9c89
+ MODULE_TYPE = UEFI_DRIVER
+ VERSION_STRING = 1.0
+ LIBRARY_CLASS = VirtioMmioDeviceLib
+
+[Sources]
+ VirtioMmioDevice.c
+ VirtioMmioDeviceFunctions.c
+
+[Packages]
+ MdePkg/MdePkg.dec
+ OvmfPkg/OvmfPkg.dec
+
+[LibraryClasses]
+ BaseMemoryLib
+ DebugLib
+ IoLib
+ MemoryAllocationLib
+ UefiBootServicesTableLib
+ UefiDriverEntryPoint
+ UefiLib
+
+[Protocols]
+ gVirtioDeviceProtocolGuid ## PRODUCES
diff --git a/OvmfPkg/OvmfPkg.dec b/OvmfPkg/OvmfPkg.dec
index d874f0c44..11c44534a 100644
--- a/OvmfPkg/OvmfPkg.dec
+++ b/OvmfPkg/OvmfPkg.dec
@@ -44,6 +44,7 @@
gEfiXenInfoGuid = {0xd3b46f3b, 0xd441, 0x1244, {0x9a, 0x12, 0x0, 0x12, 0x27, 0x3f, 0xc1, 0x4d}}
[Protocols]
+ gVirtioDeviceProtocolGuid = {0xfa920010, 0x6785, 0x4941, {0xb6, 0xec, 0x49, 0x8c, 0x57, 0x9f, 0x16, 0x0a}}
gBlockMmioProtocolGuid = {0x6b558ce3, 0x69e5, 0x4c67, {0xa6, 0x34, 0xf7, 0xfe, 0x72, 0xad, 0xbe, 0x84}}
[PcdsFixedAtBuild]
diff --git a/OvmfPkg/OvmfPkgIa32.dsc b/OvmfPkg/OvmfPkgIa32.dsc
index 41c104c6f..c57822bdd 100644
--- a/OvmfPkg/OvmfPkgIa32.dsc
+++ b/OvmfPkg/OvmfPkgIa32.dsc
@@ -119,6 +119,7 @@
PlatformSecureLib|OvmfPkg/Library/PlatformSecureLib/PlatformSecureLib.inf
IntrinsicLib|CryptoPkg/Library/IntrinsicLib/IntrinsicLib.inf
OpensslLib|CryptoPkg/Library/OpensslLib/OpensslLib.inf
+ TpmMeasurementLib|SecurityPkg/Library/DxeTpmMeasurementLib/DxeTpmMeasurementLib.inf
!endif
[LibraryClasses.common]
@@ -407,6 +408,7 @@
}
OvmfPkg/BlockMmioToBlockIoDxe/BlockIo.inf
+ OvmfPkg/VirtioPciDeviceDxe/VirtioPciDeviceDxe.inf
OvmfPkg/VirtioBlkDxe/VirtioBlk.inf
OvmfPkg/VirtioScsiDxe/VirtioScsi.inf
OvmfPkg/EmuVariableFvbRuntimeDxe/Fvb.inf {
diff --git a/OvmfPkg/OvmfPkgIa32.fdf b/OvmfPkg/OvmfPkgIa32.fdf
index df4f2276e..b13cf0589 100644
--- a/OvmfPkg/OvmfPkgIa32.fdf
+++ b/OvmfPkg/OvmfPkgIa32.fdf
@@ -181,6 +181,7 @@ INF MdeModulePkg/Universal/Metronome/Metronome.inf
INF PcAtChipsetPkg/PcatRealTimeClockRuntimeDxe/PcatRealTimeClockRuntimeDxe.inf
INF OvmfPkg/BlockMmioToBlockIoDxe/BlockIo.inf
+INF OvmfPkg/VirtioPciDeviceDxe/VirtioPciDeviceDxe.inf
INF OvmfPkg/VirtioBlkDxe/VirtioBlk.inf
INF OvmfPkg/VirtioScsiDxe/VirtioScsi.inf
INF OvmfPkg/EmuVariableFvbRuntimeDxe/Fvb.inf
diff --git a/OvmfPkg/OvmfPkgIa32X64.dsc b/OvmfPkg/OvmfPkgIa32X64.dsc
index 2c7b45733..171cbe2b7 100644
--- a/OvmfPkg/OvmfPkgIa32X64.dsc
+++ b/OvmfPkg/OvmfPkgIa32X64.dsc
@@ -124,6 +124,7 @@
PlatformSecureLib|OvmfPkg/Library/PlatformSecureLib/PlatformSecureLib.inf
IntrinsicLib|CryptoPkg/Library/IntrinsicLib/IntrinsicLib.inf
OpensslLib|CryptoPkg/Library/OpensslLib/OpensslLib.inf
+ TpmMeasurementLib|SecurityPkg/Library/DxeTpmMeasurementLib/DxeTpmMeasurementLib.inf
!endif
[LibraryClasses.common]
@@ -414,6 +415,7 @@
}
OvmfPkg/BlockMmioToBlockIoDxe/BlockIo.inf
+ OvmfPkg/VirtioPciDeviceDxe/VirtioPciDeviceDxe.inf
OvmfPkg/VirtioBlkDxe/VirtioBlk.inf
OvmfPkg/VirtioScsiDxe/VirtioScsi.inf
OvmfPkg/EmuVariableFvbRuntimeDxe/Fvb.inf {
diff --git a/OvmfPkg/OvmfPkgIa32X64.fdf b/OvmfPkg/OvmfPkgIa32X64.fdf
index d93a7ff2e..9965c3cf5 100644
--- a/OvmfPkg/OvmfPkgIa32X64.fdf
+++ b/OvmfPkg/OvmfPkgIa32X64.fdf
@@ -181,6 +181,7 @@ INF MdeModulePkg/Universal/Metronome/Metronome.inf
INF PcAtChipsetPkg/PcatRealTimeClockRuntimeDxe/PcatRealTimeClockRuntimeDxe.inf
INF OvmfPkg/BlockMmioToBlockIoDxe/BlockIo.inf
+INF OvmfPkg/VirtioPciDeviceDxe/VirtioPciDeviceDxe.inf
INF OvmfPkg/VirtioBlkDxe/VirtioBlk.inf
INF OvmfPkg/VirtioScsiDxe/VirtioScsi.inf
INF OvmfPkg/EmuVariableFvbRuntimeDxe/Fvb.inf
diff --git a/OvmfPkg/OvmfPkgX64.dsc b/OvmfPkg/OvmfPkgX64.dsc
index 9fc0183d3..08c81e4a5 100644
--- a/OvmfPkg/OvmfPkgX64.dsc
+++ b/OvmfPkg/OvmfPkgX64.dsc
@@ -124,6 +124,7 @@
PlatformSecureLib|OvmfPkg/Library/PlatformSecureLib/PlatformSecureLib.inf
IntrinsicLib|CryptoPkg/Library/IntrinsicLib/IntrinsicLib.inf
OpensslLib|CryptoPkg/Library/OpensslLib/OpensslLib.inf
+ TpmMeasurementLib|SecurityPkg/Library/DxeTpmMeasurementLib/DxeTpmMeasurementLib.inf
!endif
[LibraryClasses.common]
@@ -412,6 +413,7 @@
}
OvmfPkg/BlockMmioToBlockIoDxe/BlockIo.inf
+ OvmfPkg/VirtioPciDeviceDxe/VirtioPciDeviceDxe.inf
OvmfPkg/VirtioBlkDxe/VirtioBlk.inf
OvmfPkg/VirtioScsiDxe/VirtioScsi.inf
OvmfPkg/EmuVariableFvbRuntimeDxe/Fvb.inf {
diff --git a/OvmfPkg/OvmfPkgX64.fdf b/OvmfPkg/OvmfPkgX64.fdf
index a7c9bcd6a..e2420c5cf 100644
--- a/OvmfPkg/OvmfPkgX64.fdf
+++ b/OvmfPkg/OvmfPkgX64.fdf
@@ -22,10 +22,10 @@ ErasePolarity = 1
BlockSize = 0x1000
NumBlocks = 0x100
-0x00000000|0x000E6000
+0x00000000|0x000EC000
FV = FVMAIN_COMPACT
-0x000E6000|0x1A000
+0x000EC000|0x14000
FV = SECFV
!else
[FD.OVMF]
@@ -83,7 +83,7 @@ READ_LOCK_STATUS = TRUE
#
INF OvmfPkg/Sec/SecMain.inf
-INF RuleOverride=RESET_VECTOR UefiCpuPkg/ResetVector/Vtf0/Bin/ResetVector.inf
+INF RuleOverride=RESET_VECTOR OvmfPkg/ResetVector/Bin/ResetVector.inf
################################################################################
[FV.MAINFV]
@@ -181,6 +181,7 @@ INF MdeModulePkg/Universal/Metronome/Metronome.inf
INF PcAtChipsetPkg/PcatRealTimeClockRuntimeDxe/PcatRealTimeClockRuntimeDxe.inf
INF OvmfPkg/BlockMmioToBlockIoDxe/BlockIo.inf
+INF OvmfPkg/VirtioPciDeviceDxe/VirtioPciDeviceDxe.inf
INF OvmfPkg/VirtioBlkDxe/VirtioBlk.inf
INF OvmfPkg/VirtioScsiDxe/VirtioScsi.inf
INF OvmfPkg/EmuVariableFvbRuntimeDxe/Fvb.inf
diff --git a/OvmfPkg/PlatformPei/Platform.c b/OvmfPkg/PlatformPei/Platform.c
index e7486b7b7..1d9e93ff4 100644
--- a/OvmfPkg/PlatformPei/Platform.c
+++ b/OvmfPkg/PlatformPei/Platform.c
@@ -287,8 +287,9 @@ ReserveEmuVariableNvStore (
//
VariableStore =
(EFI_PHYSICAL_ADDRESS)(UINTN)
- AllocateRuntimePool (
- 2 * PcdGet32 (PcdFlashNvStorageFtwSpareSize)
+ AllocateAlignedPages (
+ EFI_SIZE_TO_PAGES (2 * PcdGet32 (PcdFlashNvStorageFtwSpareSize)),
+ PcdGet32 (PcdFlashNvStorageFtwSpareSize)
);
DEBUG ((EFI_D_INFO,
"Reserved variable store memory: 0x%lX; size: %dkb\n",
diff --git a/OvmfPkg/ResetVector/Bin/ResetVector.inf b/OvmfPkg/ResetVector/Bin/ResetVector.inf
new file mode 100644
index 000000000..afc80e3cd
--- /dev/null
+++ b/OvmfPkg/ResetVector/Bin/ResetVector.inf
@@ -0,0 +1,29 @@
+## @file
+# Reset Vector binary
+#
+# Copyright (c) 2006 - 2013, 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.
+#
+##
+
+[Defines]
+ INF_VERSION = 0x00010005
+ BASE_NAME = ResetVector
+ FILE_GUID = 1BA0062E-C779-4582-8566-336AE8F78F09
+ MODULE_TYPE = SEC
+ VERSION_STRING = 1.1
+
+#
+# The following information is for reference only and not required by the build tools.
+#
+# VALID_ARCHITECTURES = IA32 X64
+#
+
+[Binaries.X64]
+ RAW|ResetVector.x64.raw|*
diff --git a/OvmfPkg/ResetVector/Bin/ResetVector.x64.raw b/OvmfPkg/ResetVector/Bin/ResetVector.x64.raw
new file mode 100644
index 000000000..237d08a29
--- /dev/null
+++ b/OvmfPkg/ResetVector/Bin/ResetVector.x64.raw
Binary files differ
diff --git a/OvmfPkg/ResetVector/Build.py b/OvmfPkg/ResetVector/Build.py
new file mode 100644
index 000000000..e0a9496e3
--- /dev/null
+++ b/OvmfPkg/ResetVector/Build.py
@@ -0,0 +1,58 @@
+## @file
+# Automate the process of building the various reset vector types
+#
+# Copyright (c) 2009 - 2013, 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.
+#
+
+import glob
+import os
+import subprocess
+import sys
+
+def RunCommand(commandLine):
+ #print ' '.join(commandLine)
+ return subprocess.call(commandLine)
+
+for filename in glob.glob(os.path.join('Bin', '*.raw')):
+ os.remove(filename)
+
+ThisDir = os.path.realpath(os.path.split(sys.argv[0])[0])
+WorkspaceDir = os.path.realpath(os.path.join(ThisDir, '..', '..'))
+UefiCpuPkgVtf0Dir = os.path.join(WorkspaceDir, 'UefiCpuPkg', 'ResetVector', 'Vtf0')
+
+for arch in ('x64',):
+ for debugType in (None,):
+ output = os.path.join('Bin', 'ResetVector')
+ output += '.' + arch
+ if debugType is not None:
+ output += '.' + debugType
+ output += '.raw'
+ commandLine = (
+ 'nasm',
+ '-D', 'ARCH_%s' % arch.upper(),
+ '-D', 'DEBUG_%s' % str(debugType).upper(),
+ '-I', UefiCpuPkgVtf0Dir + os.path.sep,
+ '-o', output,
+ 'ResetVectorCode.asm',
+ )
+ ret = RunCommand(commandLine)
+ print '\tASM\t' + output
+ if ret != 0: sys.exit(ret)
+
+ commandLine = (
+ 'python',
+ 'Tools/FixupForRawSection.py',
+ output,
+ )
+ print '\tFIXUP\t' + output
+ ret = RunCommand(commandLine)
+ if ret != 0: sys.exit(ret)
+
diff --git a/OvmfPkg/ResetVector/Ia32/PageTables64.asm b/OvmfPkg/ResetVector/Ia32/PageTables64.asm
new file mode 100644
index 000000000..8280e8f14
--- /dev/null
+++ b/OvmfPkg/ResetVector/Ia32/PageTables64.asm
@@ -0,0 +1,91 @@
+;------------------------------------------------------------------------------
+; @file
+; Sets the CR3 register for 64-bit paging
+;
+; Copyright (c) 2008 - 2013, 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.
+;
+;------------------------------------------------------------------------------
+
+BITS 32
+
+%define PAGE_PRESENT 0x01
+%define PAGE_READ_WRITE 0x02
+%define PAGE_USER_SUPERVISOR 0x04
+%define PAGE_WRITE_THROUGH 0x08
+%define PAGE_CACHE_DISABLE 0x010
+%define PAGE_ACCESSED 0x020
+%define PAGE_DIRTY 0x040
+%define PAGE_PAT 0x080
+%define PAGE_GLOBAL 0x0100
+%define PAGE_2M_MBO 0x080
+%define PAGE_2M_PAT 0x01000
+
+%define PAGE_2M_PDE_ATTR (PAGE_2M_MBO + \
+ PAGE_ACCESSED + \
+ PAGE_DIRTY + \
+ PAGE_READ_WRITE + \
+ PAGE_PRESENT)
+
+%define PAGE_PDP_ATTR (PAGE_ACCESSED + \
+ PAGE_READ_WRITE + \
+ PAGE_PRESENT)
+
+
+;
+; Modified: EAX, ECX
+;
+SetCr3ForPageTables64:
+
+ ;
+ ; For OVMF, build some initial page tables at 0x80000. This is just
+ ; after the early stack/temp RAM.
+ ;
+ ; At the end of PEI, the pages tables will be rebuilt into a
+ ; more permanent location by DxeIpl.
+ ;
+
+ mov ecx, 6 * 0x1000 / 4
+ xor eax, eax
+clearPageTablesMemoryLoop:
+ mov dword[ecx * 4 + 0x80000 - 4], eax
+ loop clearPageTablesMemoryLoop
+
+ ;
+ ; Top level Page Directory Pointers (1 * 512GB entry)
+ ;
+ mov dword[0x80000], 0x81000 + PAGE_PDP_ATTR
+
+ ;
+ ; Next level Page Directory Pointers (4 * 1GB entries => 4GB)
+ ;
+ mov dword[0x81000], 0x82000 + PAGE_PDP_ATTR
+ mov dword[0x81008], 0x83000 + PAGE_PDP_ATTR
+ mov dword[0x81010], 0x84000 + PAGE_PDP_ATTR
+ mov dword[0x81018], 0x85000 + PAGE_PDP_ATTR
+
+ ;
+ ; Page Table Entries (2048 * 2MB entries => 4GB)
+ ;
+ mov ecx, 0x800
+pageTableEntriesLoop:
+ mov eax, ecx
+ dec eax
+ shl eax, 21
+ add eax, PAGE_2M_PDE_ATTR
+ mov [ecx * 8 + 0x82000 - 8], eax
+ loop pageTableEntriesLoop
+
+ ;
+ ; Set CR3 now that the paging structures are available
+ ;
+ mov eax, 0x80000
+ mov cr3, eax
+
+ OneTimeCallRet SetCr3ForPageTables64
diff --git a/OvmfPkg/ResetVector/ResetVectorCode.asm b/OvmfPkg/ResetVector/ResetVectorCode.asm
new file mode 100644
index 000000000..052c821f2
--- /dev/null
+++ b/OvmfPkg/ResetVector/ResetVectorCode.asm
@@ -0,0 +1,53 @@
+;------------------------------------------------------------------------------
+; @file
+; This file includes all other code files to assemble the reset vector code
+;
+; Copyright (c) 2008 - 2013, 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.
+;
+;------------------------------------------------------------------------------
+
+%ifdef ARCH_IA32
+ %ifdef ARCH_X64
+ %error "Only one of ARCH_IA32 or ARCH_X64 can be defined."
+ %endif
+%elifdef ARCH_X64
+%else
+ %error "Either ARCH_IA32 or ARCH_X64 must be defined."
+%endif
+
+%include "CommonMacros.inc"
+
+%include "PostCodes.inc"
+
+%ifdef DEBUG_NONE
+ %include "DebugDisabled.asm"
+%elifdef DEBUG_PORT80
+ %include "Port80Debug.asm"
+%elifdef DEBUG_SERIAL
+ %include "SerialDebug.asm"
+%else
+ %error "No debug type was specified."
+%endif
+
+%include "Ia32/SearchForBfvBase.asm"
+%include "Ia32/SearchForSecEntry.asm"
+
+%ifdef ARCH_X64
+%include "Ia32/Flat32ToFlat64.asm"
+%include "Ia32/PageTables64.asm"
+%endif
+
+%include "Ia16/Real16ToFlat32.asm"
+%include "Ia16/Init16.asm"
+
+%include "Main.asm"
+
+%include "Ia16/ResetVectorVtf0.asm"
+
diff --git a/OvmfPkg/ResetVector/Tools/FixupForRawSection.py b/OvmfPkg/ResetVector/Tools/FixupForRawSection.py
new file mode 100644
index 000000000..f88c8a4cd
--- /dev/null
+++ b/OvmfPkg/ResetVector/Tools/FixupForRawSection.py
@@ -0,0 +1,26 @@
+## @file
+# Apply fixup to VTF binary image for FFS Raw section
+#
+# Copyright (c) 2008, 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.
+#
+
+import sys
+
+filename = sys.argv[1]
+
+d = open(sys.argv[1], 'rb').read()
+c = ((len(d) + 4 + 7) & ~7) - 4
+if c > len(d):
+ c -= len(d)
+ f = open(sys.argv[1], 'wb')
+ f.write('\x90' * c)
+ f.write(d)
+ f.close()
diff --git a/OvmfPkg/Sec/SecMain.c b/OvmfPkg/Sec/SecMain.c
index 56081c9b4..3882dadd6 100644
--- a/OvmfPkg/Sec/SecMain.c
+++ b/OvmfPkg/Sec/SecMain.c
@@ -1,7 +1,7 @@
/** @file
Main SEC phase code. Transitions to PEI.
- Copyright (c) 2008 - 2013, Intel Corporation. All rights reserved.<BR>
+ Copyright (c) 2008 - 2011, 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
@@ -31,8 +31,6 @@
#include <Ppi/TemporaryRamSupport.h>
-#include <IndustryStandard/X64Paging.h>
-
#define SEC_IDT_ENTRY_COUNT 34
typedef struct _SEC_IDT_TABLE {
@@ -525,137 +523,6 @@ FindImageBase (
}
}
-#if defined (MDE_CPU_X64)
-/**
- Allocates and fills in the Page Directory and Page Table Entries to
- establish a 1:1 Virtual to Physical mapping.
-
- @param Location Memory to build the page tables in
-
-**/
-VOID
-Create4GbIdentityMappingPageTables (
- VOID *Location
- )
-{
- UINT32 RegEax;
- UINT32 RegEdx;
- EFI_PHYSICAL_ADDRESS PageAddress;
- UINTN IndexOfPml4Entries;
- UINTN IndexOfPdpEntries;
- UINTN IndexOfPageDirectoryEntries;
- UINT32 NumberOfPml4EntriesNeeded;
- UINT32 NumberOfPdpEntriesNeeded;
- X64_PAGE_MAP_AND_DIRECTORY_POINTER *PageMapLevel4Entry;
- X64_PAGE_MAP_AND_DIRECTORY_POINTER *PageMap;
- X64_PAGE_MAP_AND_DIRECTORY_POINTER *PageDirectoryPointerEntry;
- X64_PAGE_TABLE_ENTRY *PageDirectoryEntry;
- UINTN NextAllocAddress;
- BOOLEAN Page1GSupport;
- X64_PAGE_TABLE_1G_ENTRY *PageDirectory1GEntry;
-
- Page1GSupport = FALSE;
- AsmCpuid (0x80000000, &RegEax, NULL, NULL, NULL);
- if (RegEax >= 0x80000001) {
- AsmCpuid (0x80000001, NULL, NULL, NULL, &RegEdx);
- if ((RegEdx & BIT26) != 0) {
- Page1GSupport = TRUE;
- }
- }
-
- //
- // Only build entries for the first 4GB at this stage.
- //
- NumberOfPml4EntriesNeeded = 1;
- NumberOfPdpEntriesNeeded = 4;
-
- NextAllocAddress = (UINTN) Location;
-
- //
- // By architecture only one PageMapLevel4 exists - so lets allocate storage for it.
- //
- PageMap = (VOID *) NextAllocAddress;
- NextAllocAddress += SIZE_4KB;
-
- PageMapLevel4Entry = PageMap;
- PageAddress = 0;
- for (IndexOfPml4Entries = 0; IndexOfPml4Entries < NumberOfPml4EntriesNeeded; IndexOfPml4Entries++, PageMapLevel4Entry++) {
- //
- // Each PML4 entry points to a page of Page Directory Pointer entires.
- // So lets allocate space for them and fill them in in the IndexOfPdpEntries loop.
- //
- PageDirectoryPointerEntry = (VOID *) NextAllocAddress;
- NextAllocAddress += SIZE_4KB;
-
- //
- // Make a PML4 Entry
- //
- PageMapLevel4Entry->Uint64 = (UINT64)(UINTN)PageDirectoryPointerEntry;
- PageMapLevel4Entry->Bits.ReadWrite = 1;
- PageMapLevel4Entry->Bits.Present = 1;
-
- if (Page1GSupport) {
- PageDirectory1GEntry = (VOID *) PageDirectoryPointerEntry;
-
- for (IndexOfPageDirectoryEntries = 0; IndexOfPageDirectoryEntries < 512; IndexOfPageDirectoryEntries++, PageDirectory1GEntry++, PageAddress += SIZE_1GB) {
- //
- // Fill in the Page Directory entries
- //
- PageDirectory1GEntry->Uint64 = (UINT64)PageAddress;
- PageDirectory1GEntry->Bits.ReadWrite = 1;
- PageDirectory1GEntry->Bits.Present = 1;
- PageDirectory1GEntry->Bits.MustBe1 = 1;
- }
- } else {
- for (IndexOfPdpEntries = 0; IndexOfPdpEntries < NumberOfPdpEntriesNeeded; IndexOfPdpEntries++, PageDirectoryPointerEntry++) {
- //
- // Each Directory Pointer entries points to a page of Page Directory entires.
- // So allocate space for them and fill them in in the IndexOfPageDirectoryEntries loop.
- //
- PageDirectoryEntry = (VOID *) NextAllocAddress;
- NextAllocAddress += SIZE_4KB;
-
- //
- // Fill in a Page Directory Pointer Entries
- //
- PageDirectoryPointerEntry->Uint64 = (UINT64)(UINTN)PageDirectoryEntry;
- PageDirectoryPointerEntry->Bits.ReadWrite = 1;
- PageDirectoryPointerEntry->Bits.Present = 1;
-
- for (IndexOfPageDirectoryEntries = 0; IndexOfPageDirectoryEntries < 512; IndexOfPageDirectoryEntries++, PageDirectoryEntry++, PageAddress += SIZE_2MB) {
- //
- // Fill in the Page Directory entries
- //
- PageDirectoryEntry->Uint64 = (UINT64)PageAddress;
- PageDirectoryEntry->Bits.ReadWrite = 1;
- PageDirectoryEntry->Bits.Present = 1;
- PageDirectoryEntry->Bits.MustBe1 = 1;
- }
- }
-
- for (; IndexOfPdpEntries < 512; IndexOfPdpEntries++, PageDirectoryPointerEntry++) {
- ZeroMem (
- PageDirectoryPointerEntry,
- sizeof(X64_PAGE_MAP_AND_DIRECTORY_POINTER)
- );
- }
- }
- }
-
- //
- // For the PML4 entries we are not using fill in a null entry.
- //
- for (; IndexOfPml4Entries < 512; IndexOfPml4Entries++, PageMapLevel4Entry++) {
- ZeroMem (
- PageMapLevel4Entry,
- sizeof (X64_PAGE_MAP_AND_DIRECTORY_POINTER)
- );
- }
-
- AsmWriteCr3 ((UINTN) PageMap);
-}
-#endif
-
/*
Find and return Pei Core entry point.
@@ -778,14 +645,7 @@ SecCoreStartupWithStack (
//
IoWrite8 (0x21, 0xff);
IoWrite8 (0xA1, 0xff);
-
-#if defined (MDE_CPU_X64)
- //
- // Create Identity Mapped Pages in RAM
- //
- Create4GbIdentityMappingPageTables (TopOfCurrentStack);
-#endif
-
+
//
// Initialize Debug Agent to support source level debug in SEC/PEI phases before memory ready.
//
diff --git a/OvmfPkg/VirtioBlkDxe/VirtioBlk.c b/OvmfPkg/VirtioBlkDxe/VirtioBlk.c
index b2bfcdf7b..08edf23fc 100644
--- a/OvmfPkg/VirtioBlkDxe/VirtioBlk.c
+++ b/OvmfPkg/VirtioBlkDxe/VirtioBlk.c
@@ -23,7 +23,6 @@
**/
-#include <IndustryStandard/Pci.h>
#include <IndustryStandard/VirtioBlk.h>
#include <Library/BaseMemoryLib.h>
#include <Library/DebugLib.h>
@@ -37,14 +36,14 @@
/**
Convenience macros to read and write region 0 IO space elements of the
- virtio-blk PCI device, for configuration purposes.
+ virtio-blk device, for configuration purposes.
The following macros make it possible to specify only the "core parameters"
for such accesses and to derive the rest. By the time VIRTIO_CFG_WRITE()
returns, the transaction will have been completed.
- @param[in] Dev Pointer to the VBLK_DEV structure whose PCI IO space
- we're accessing. Dev->PciIo must be valid.
+ @param[in] Dev Pointer to the VBLK_DEV structure whose VirtIo space
+ we're accessing. Dev->VirtIo must be valid.
@param[in] Field A field name from VBLK_HDR, identifying the virtio-blk
configuration item to access.
@@ -57,23 +56,23 @@
one of UINT8, UINT16, UINT32, UINT64.
- @return Status code returned by VirtioWrite() / VirtioRead().
+ @return Status code returned by Virtio->WriteDevice() / Virtio->ReadDevice().
**/
-#define VIRTIO_CFG_WRITE(Dev, Field, Value) (VirtioWrite ( \
- (Dev)->PciIo, \
- OFFSET_OF_VBLK (Field), \
- SIZE_OF_VBLK (Field), \
- (Value) \
+#define VIRTIO_CFG_WRITE(Dev, Field, Value) ((Dev)->VirtIo->WriteDevice ( \
+ (Dev)->VirtIo, \
+ OFFSET_OF_VBLK (Field), \
+ SIZE_OF_VBLK (Field), \
+ (Value) \
))
-#define VIRTIO_CFG_READ(Dev, Field, Pointer) (VirtioRead ( \
- (Dev)->PciIo, \
- OFFSET_OF_VBLK (Field), \
- SIZE_OF_VBLK (Field), \
- sizeof *(Pointer), \
- (Pointer) \
+#define VIRTIO_CFG_READ(Dev, Field, Pointer) ((Dev)->VirtIo->ReadDevice ( \
+ (Dev)->VirtIo, \
+ OFFSET_OF_VBLK (Field), \
+ SIZE_OF_VBLK (Field), \
+ sizeof *(Pointer), \
+ (Pointer) \
))
@@ -229,7 +228,7 @@ VerifyReadWriteRequest (
@retval EFI_SUCCESS Transfer complete.
- @retval EFI_DEVICE_ERROR Failed to notify host side via PCI write, or
+ @retval EFI_DEVICE_ERROR Failed to notify host side via VirtIo write, or
unable to parse host response, or host response
is not VIRTIO_BLK_S_OK.
@@ -324,7 +323,7 @@ SynchronousRequest (
//
// virtio-blk's only virtqueue is #0, called "requestq" (see Appendix D).
//
- if (VirtioFlush (Dev->PciIo, 0, &Dev->Ring, &Indices) == EFI_SUCCESS &&
+ if (VirtioFlush (Dev->VirtIo, 0, &Dev->Ring, &Indices) == EFI_SUCCESS &&
HostStatus == VIRTIO_BLK_S_OK) {
return EFI_SUCCESS;
}
@@ -500,11 +499,6 @@ VirtioBlkFlushBlocks (
underlying device
- 9 Driver Binding Protocol -- for exporting ourselves
- Specs relevant in the specific sense:
- - UEFI Spec 2.3.1 + Errata C, 13.4 EFI PCI I/O Protocol
- - Driver Writer's Guide for UEFI 2.3.1 v1.01, 18 PCI Driver Design
- Guidelines, 18.3 PCI drivers.
-
@param[in] This The EFI_DRIVER_BINDING_PROTOCOL object
incorporating this driver (independently of
any device).
@@ -516,11 +510,11 @@ VirtioBlkFlushBlocks (
@retval EFI_SUCCESS The driver supports the device being probed.
- @retval EFI_UNSUPPORTED Based on virtio-blk PCI discovery, we do not support
+ @retval EFI_UNSUPPORTED Based on virtio-blk discovery, we do not support
the device.
@return Error codes from the OpenProtocol() boot service or
- the PciIo protocol.
+ the VirtIo protocol.
**/
@@ -533,56 +527,36 @@ VirtioBlkDriverBindingSupported (
)
{
EFI_STATUS Status;
- EFI_PCI_IO_PROTOCOL *PciIo;
- PCI_TYPE00 Pci;
+ VIRTIO_DEVICE_PROTOCOL *VirtIo;
//
- // Attempt to open the device with the PciIo set of interfaces. On success,
- // the protocol is "instantiated" for the PCI device. Covers duplicate open
+ // Attempt to open the device with the VirtIo set of interfaces. On success,
+ // the protocol is "instantiated" for the VirtIo device. Covers duplicate open
// attempts (EFI_ALREADY_STARTED).
//
Status = gBS->OpenProtocol (
DeviceHandle, // candidate device
- &gEfiPciIoProtocolGuid, // for generic PCI access
- (VOID **)&PciIo, // handle to instantiate
+ &gVirtioDeviceProtocolGuid, // for generic VirtIo access
+ (VOID **)&VirtIo, // handle to instantiate
This->DriverBindingHandle, // requestor driver identity
DeviceHandle, // ControllerHandle, according to
// the UEFI Driver Model
- EFI_OPEN_PROTOCOL_BY_DRIVER // get exclusive PciIo access to
+ EFI_OPEN_PROTOCOL_BY_DRIVER // get exclusive VirtIo access to
// the device; to be released
);
if (EFI_ERROR (Status)) {
return Status;
}
- //
- // Read entire PCI configuration header for more extensive check ahead.
- //
- Status = PciIo->Pci.Read (
- PciIo, // (protocol, device)
- // handle
- EfiPciIoWidthUint32, // access width & copy
- // mode
- 0, // Offset
- sizeof Pci / sizeof (UINT32), // Count
- &Pci // target buffer
- );
-
- if (Status == EFI_SUCCESS) {
- //
- // virtio-0.9.5, 2.1 PCI Discovery
- //
- Status = (Pci.Hdr.VendorId == 0x1AF4 &&
- Pci.Hdr.DeviceId >= 0x1000 && Pci.Hdr.DeviceId <= 0x103F &&
- Pci.Hdr.RevisionID == 0x00 &&
- Pci.Device.SubsystemID == 0x02) ? EFI_SUCCESS : EFI_UNSUPPORTED;
+ if (VirtIo->SubSystemDeviceId != VIRTIO_SUBSYSTEM_BLOCK_DEVICE) {
+ Status = EFI_UNSUPPORTED;
}
//
- // We needed PCI IO access only transitorily, to see whether we support the
+ // We needed VirtIo access only transitorily, to see whether we support the
// device or not.
//
- gBS->CloseProtocol (DeviceHandle, &gEfiPciIoProtocolGuid,
+ gBS->CloseProtocol (DeviceHandle, &gVirtioDeviceProtocolGuid,
This->DriverBindingHandle, DeviceHandle);
return Status;
}
@@ -594,8 +568,8 @@ VirtioBlkDriverBindingSupported (
device.
@param[in out] Dev The driver instance to configure. The caller is
- responsible for Dev->PciIo's validity (ie. working IO
- access to the underlying virtio-blk PCI device).
+ responsible for Dev->VirtIo's validity (ie. working IO
+ access to the underlying virtio-blk device).
@retval EFI_SUCCESS Setup complete.
@@ -626,31 +600,40 @@ VirtioBlkInit (
// Execute virtio-0.9.5, 2.2.1 Device Initialization Sequence.
//
NextDevStat = 0; // step 1 -- reset device
- Status = VIRTIO_CFG_WRITE (Dev, Generic.VhdrDeviceStatus, NextDevStat);
+ Status = Dev->VirtIo->SetDeviceStatus (Dev->VirtIo, NextDevStat);
if (EFI_ERROR (Status)) {
goto Failed;
}
NextDevStat |= VSTAT_ACK; // step 2 -- acknowledge device presence
- Status = VIRTIO_CFG_WRITE (Dev, Generic.VhdrDeviceStatus, NextDevStat);
+ Status = Dev->VirtIo->SetDeviceStatus (Dev->VirtIo, NextDevStat);
if (EFI_ERROR (Status)) {
goto Failed;
}
NextDevStat |= VSTAT_DRIVER; // step 3 -- we know how to drive it
- Status = VIRTIO_CFG_WRITE (Dev, Generic.VhdrDeviceStatus, NextDevStat);
+ Status = Dev->VirtIo->SetDeviceStatus (Dev->VirtIo, NextDevStat);
if (EFI_ERROR (Status)) {
goto Failed;
}
//
+ // Set Page Size - MMIO VirtIo Specific
+ //
+ Status = Dev->VirtIo->SetPageSize (Dev->VirtIo, EFI_PAGE_SIZE);
+ if (EFI_ERROR (Status)) {
+ goto ReleaseQueue;
+ }
+
+ //
// step 4a -- retrieve and validate features
//
- Status = VIRTIO_CFG_READ (Dev, Generic.VhdrDeviceFeatureBits, &Features);
+ Status = Dev->VirtIo->GetDeviceFeatures (Dev->VirtIo, &Features);
if (EFI_ERROR (Status)) {
goto Failed;
}
- Status = VIRTIO_CFG_READ (Dev, VhdrCapacity, &NumSectors);
+
+ Status = VIRTIO_CFG_READ (Dev, Capacity, &NumSectors);
if (EFI_ERROR (Status)) {
goto Failed;
}
@@ -660,7 +643,7 @@ VirtioBlkInit (
}
if (Features & VIRTIO_BLK_F_BLK_SIZE) {
- Status = VIRTIO_CFG_READ (Dev, VhdrBlkSize, &BlockSize);
+ Status = VIRTIO_CFG_READ (Dev, BlkSize, &BlockSize);
if (EFI_ERROR (Status)) {
goto Failed;
}
@@ -681,11 +664,11 @@ VirtioBlkInit (
//
// step 4b -- allocate virtqueue
//
- Status = VIRTIO_CFG_WRITE (Dev, Generic.VhdrQueueSelect, 0);
+ Status = Dev->VirtIo->SetQueueSel (Dev->VirtIo, 0);
if (EFI_ERROR (Status)) {
goto Failed;
}
- Status = VIRTIO_CFG_READ (Dev, Generic.VhdrQueueSize, &QueueSize);
+ Status = Dev->VirtIo->GetQueueNumMax (Dev->VirtIo, &QueueSize);
if (EFI_ERROR (Status)) {
goto Failed;
}
@@ -700,22 +683,31 @@ VirtioBlkInit (
}
//
+ // Additional steps for MMIO: align the queue appropriately, and set the size
+ Dev->VirtIo->SetQueueNum (Dev->VirtIo, QueueSize);
+ Status = Dev->VirtIo->SetQueueAlign (Dev->VirtIo, EFI_PAGE_SIZE);
+ if (EFI_ERROR (Status)) {
+ goto ReleaseQueue;
+ }
+
+ //
// step 4c -- Report GPFN (guest-physical frame number) of queue. If anything
// fails from here on, we must release the ring resources.
//
- Status = VIRTIO_CFG_WRITE (Dev, Generic.VhdrQueueAddress,
- (UINTN) Dev->Ring.Base >> EFI_PAGE_SHIFT);
+ Status = Dev->VirtIo->SetQueueAddress (Dev->VirtIo,
+ (UINTN) Dev->Ring.Base >> EFI_PAGE_SHIFT);
if (EFI_ERROR (Status)) {
goto ReleaseQueue;
}
+
//
// step 5 -- Report understood features. There are no virtio-blk specific
// features to negotiate in virtio-0.9.5, plus we do not want any of the
// device-independent (known or unknown) VIRTIO_F_* capabilities (see
// Appendix B).
//
- Status = VIRTIO_CFG_WRITE (Dev, Generic.VhdrGuestFeatureBits, 0);
+ Status = Dev->VirtIo->SetGuestFeatures (Dev->VirtIo, 0);
if (EFI_ERROR (Status)) {
goto ReleaseQueue;
}
@@ -724,7 +716,7 @@ VirtioBlkInit (
// step 6 -- initialization complete
//
NextDevStat |= VSTAT_DRIVER_OK;
- Status = VIRTIO_CFG_WRITE (Dev, Generic.VhdrDeviceStatus, NextDevStat);
+ Status = Dev->VirtIo->SetDeviceStatus (Dev->VirtIo, NextDevStat);
if (EFI_ERROR (Status)) {
goto ReleaseQueue;
}
@@ -758,10 +750,10 @@ ReleaseQueue:
Failed:
//
// Notify the host about our failure to setup: virtio-0.9.5, 2.2.2.1 Device
- // Status. PCI IO access failure here should not mask the original error.
+ // Status. VirtIo access failure here should not mask the original error.
//
NextDevStat |= VSTAT_FAILED;
- VIRTIO_CFG_WRITE (Dev, Generic.VhdrDeviceStatus, NextDevStat);
+ Dev->VirtIo->SetDeviceStatus (Dev->VirtIo, NextDevStat);
return Status; // reached only via Failed above
}
@@ -788,7 +780,7 @@ VirtioBlkUninit (
// VIRTIO_CFG_WRITE() returns, the host will have learned to stay away from
// the old comms area.
//
- VIRTIO_CFG_WRITE (Dev, Generic.VhdrDeviceStatus, 0);
+ Dev->VirtIo->SetDeviceStatus (Dev->VirtIo, 0);
VirtioRingUninit (&Dev->Ring);
@@ -815,13 +807,13 @@ VirtioBlkUninit (
@retval EFI_SUCCESS Driver instance has been created and
- initialized for the virtio-blk PCI device, it
+ initialized for the virtio-blk device, it
is now accessibla via EFI_BLOCK_IO_PROTOCOL.
@retval EFI_OUT_OF_RESOURCES Memory allocation failed.
@return Error codes from the OpenProtocol() boot
- service, the PciIo protocol, VirtioBlkInit(),
+ service, the VirtIo protocol, VirtioBlkInit(),
or the InstallProtocolInterface() boot service.
**/
@@ -842,43 +834,23 @@ VirtioBlkDriverBindingStart (
return EFI_OUT_OF_RESOURCES;
}
- Status = gBS->OpenProtocol (DeviceHandle, &gEfiPciIoProtocolGuid,
- (VOID **)&Dev->PciIo, This->DriverBindingHandle,
+ Status = gBS->OpenProtocol (DeviceHandle, &gVirtioDeviceProtocolGuid,
+ (VOID **)&Dev->VirtIo, This->DriverBindingHandle,
DeviceHandle, EFI_OPEN_PROTOCOL_BY_DRIVER);
if (EFI_ERROR (Status)) {
goto FreeVirtioBlk;
}
- //
- // We must retain and ultimately restore the original PCI attributes of the
- // device. See Driver Writer's Guide for UEFI 2.3.1 v1.01, 18.3 PCI drivers /
- // 18.3.2 Start() and Stop().
- //
- // The third parameter ("Attributes", input) is ignored by the Get operation.
- // The fourth parameter ("Result", output) is ignored by the Enable and Set
- // operations.
- //
- // For virtio-blk we only need IO space access.
- //
- Status = Dev->PciIo->Attributes (Dev->PciIo, EfiPciIoAttributeOperationGet,
- 0, &Dev->OriginalPciAttributes);
- if (EFI_ERROR (Status)) {
- goto ClosePciIo;
- }
-
- Status = Dev->PciIo->Attributes (Dev->PciIo,
- EfiPciIoAttributeOperationEnable,
- EFI_PCI_IO_ATTRIBUTE_IO, NULL);
- if (EFI_ERROR (Status)) {
- goto ClosePciIo;
+ if (Dev->VirtIo->SubSystemDeviceId != VIRTIO_SUBSYSTEM_BLOCK_DEVICE) {
+ return EFI_UNSUPPORTED;
}
//
- // PCI IO access granted, configure virtio-blk device.
+ // VirtIo access granted, configure virtio-blk device.
//
Status = VirtioBlkInit (Dev);
if (EFI_ERROR (Status)) {
- goto RestorePciAttributes;
+ goto CloseVirtIo;
}
//
@@ -897,12 +869,8 @@ VirtioBlkDriverBindingStart (
UninitDev:
VirtioBlkUninit (Dev);
-RestorePciAttributes:
- Dev->PciIo->Attributes (Dev->PciIo, EfiPciIoAttributeOperationSet,
- Dev->OriginalPciAttributes, NULL);
-
-ClosePciIo:
- gBS->CloseProtocol (DeviceHandle, &gEfiPciIoProtocolGuid,
+CloseVirtIo:
+ gBS->CloseProtocol (DeviceHandle, &gVirtioDeviceProtocolGuid,
This->DriverBindingHandle, DeviceHandle);
FreeVirtioBlk:
@@ -973,10 +941,7 @@ VirtioBlkDriverBindingStop (
VirtioBlkUninit (Dev);
- Dev->PciIo->Attributes (Dev->PciIo, EfiPciIoAttributeOperationSet,
- Dev->OriginalPciAttributes, NULL);
-
- gBS->CloseProtocol (DeviceHandle, &gEfiPciIoProtocolGuid,
+ gBS->CloseProtocol (DeviceHandle, &gVirtioDeviceProtocolGuid,
This->DriverBindingHandle, DeviceHandle);
FreePool (Dev);
diff --git a/OvmfPkg/VirtioBlkDxe/VirtioBlk.h b/OvmfPkg/VirtioBlkDxe/VirtioBlk.h
index d22570def..43dd5064d 100644
--- a/OvmfPkg/VirtioBlkDxe/VirtioBlk.h
+++ b/OvmfPkg/VirtioBlkDxe/VirtioBlk.h
@@ -21,7 +21,6 @@
#include <Protocol/BlockIo.h>
#include <Protocol/ComponentName.h>
#include <Protocol/DriverBinding.h>
-#include <Protocol/PciIo.h>
#include <IndustryStandard/Virtio.h>
@@ -34,14 +33,13 @@ typedef struct {
// at various call depths. The table to the right should make it easier to
// track them.
//
- // field init function init dpth
- // ---------------------- ------------------ ---------
- UINT32 Signature; // DriverBindingStart 0
- EFI_PCI_IO_PROTOCOL *PciIo; // DriverBindingStart 0
- UINT64 OriginalPciAttributes; // DriverBindingStart 0
- VRING Ring; // VirtioRingInit 2
- EFI_BLOCK_IO_PROTOCOL BlockIo; // VirtioBlkInit 1
- EFI_BLOCK_IO_MEDIA BlockIoMedia; // VirtioBlkInit 1
+ // field init function init dpth
+ // --------------------- ------------------ ---------
+ UINT32 Signature; // DriverBindingStart 0
+ VIRTIO_DEVICE_PROTOCOL *VirtIo; // DriverBindingStart 0
+ VRING Ring; // VirtioRingInit 2
+ EFI_BLOCK_IO_PROTOCOL BlockIo; // VirtioBlkInit 1
+ EFI_BLOCK_IO_MEDIA BlockIoMedia; // VirtioBlkInit 1
} VBLK_DEV;
#define VIRTIO_BLK_FROM_BLOCK_IO(BlockIoPointer) \
@@ -66,11 +64,6 @@ typedef struct {
underlying device
- 9 Driver Binding Protocol -- for exporting ourselves
- Specs relevant in the specific sense:
- - UEFI Spec 2.3.1 + Errata C, 13.4 EFI PCI I/O Protocol
- - Driver Writer's Guide for UEFI 2.3.1 v1.01, 18 PCI Driver Design
- Guidelines, 18.3 PCI drivers.
-
@param[in] This The EFI_DRIVER_BINDING_PROTOCOL object
incorporating this driver (independently of
any device).
@@ -82,11 +75,10 @@ typedef struct {
@retval EFI_SUCCESS The driver supports the device being probed.
- @retval EFI_UNSUPPORTED Based on virtio-blk PCI discovery, we do not support
+ @retval EFI_UNSUPPORTED Based on virtio-blk discovery, we do not support
the device.
- @return Error codes from the OpenProtocol() boot service or
- the PciIo protocol.
+ @return Error codes from the OpenProtocol() boot service.
**/
@@ -117,14 +109,14 @@ VirtioBlkDriverBindingSupported (
@retval EFI_SUCCESS Driver instance has been created and
- initialized for the virtio-blk PCI device, it
+ initialized for the virtio-blk device, it
is now accessibla via EFI_BLOCK_IO_PROTOCOL.
@retval EFI_OUT_OF_RESOURCES Memory allocation failed.
@return Error codes from the OpenProtocol() boot
- service, the PciIo protocol, VirtioBlkInit(),
- or the InstallProtocolInterface() boot service.
+ service, VirtioBlkInit(), or the
+ InstallProtocolInterface() boot service.
**/
diff --git a/OvmfPkg/VirtioBlkDxe/VirtioBlk.inf b/OvmfPkg/VirtioBlkDxe/VirtioBlk.inf
index 6dffc3a22..86266b26c 100644
--- a/OvmfPkg/VirtioBlkDxe/VirtioBlk.inf
+++ b/OvmfPkg/VirtioBlkDxe/VirtioBlk.inf
@@ -38,5 +38,5 @@
VirtioLib
[Protocols]
- gEfiBlockIoProtocolGuid ## BY_START
- gEfiPciIoProtocolGuid ## TO_START
+ gEfiBlockIoProtocolGuid ## BY_START
+ gVirtioDeviceProtocolGuid ## TO_START
diff --git a/OvmfPkg/VirtioNetDxe/ComponentName.c b/OvmfPkg/VirtioNetDxe/ComponentName.c
index a291405ee..1a43448fd 100644
--- a/OvmfPkg/VirtioNetDxe/ComponentName.c
+++ b/OvmfPkg/VirtioNetDxe/ComponentName.c
@@ -139,20 +139,20 @@ VirtioNetGetControllerName (
}
//
- // confirm that the device is managed by this driver, using the PCI IO
+ // confirm that the device is managed by this driver, using the VirtIo
// Protocol
//
Status = EfiTestManagedDevice (
ControllerHandle,
gVirtioNetDriverBinding.DriverBindingHandle,
- &gEfiPciIoProtocolGuid
+ &gVirtioDeviceProtocolGuid
);
if (EFI_ERROR (Status)) {
return Status;
}
//
- // we don't give different names to the bus (= parent, = PCI) handle and the
+ // we don't give different names to the bus (= parent) handle and the
// child (= MAC) handle
//
return LookupUnicodeString2 (
diff --git a/OvmfPkg/VirtioNetDxe/DriverBinding.c b/OvmfPkg/VirtioNetDxe/DriverBinding.c
index d9c0096d0..f92a447f0 100644
--- a/OvmfPkg/VirtioNetDxe/DriverBinding.c
+++ b/OvmfPkg/VirtioNetDxe/DriverBinding.c
@@ -15,7 +15,6 @@
**/
-#include <IndustryStandard/Pci.h>
#include <Library/BaseMemoryLib.h>
#include <Library/DevicePathLib.h>
#include <Library/MemoryAllocationLib.h>
@@ -50,7 +49,7 @@
unused.
@retval EFI_UNSUPPORTED The host doesn't supply a MAC address.
- @return Status codes from Dev->PciIo->Io.Read(),
+ @return Status codes from Dev->VirtIo->Io.Read(),
VIRTIO_CFG_READ() and VIRTIO_CFG_WRITE().
@retval EFI_SUCCESS Configuration values retrieved.
*/
@@ -74,19 +73,19 @@ VirtioNetGetFeatures (
// Initialization Sequence), but don't complete setting it up.
//
NextDevStat = 0; // step 1 -- reset device
- Status = VIRTIO_CFG_WRITE (Dev, Generic.VhdrDeviceStatus, NextDevStat);
+ Status = Dev->VirtIo->SetDeviceStatus (Dev->VirtIo, NextDevStat);
if (EFI_ERROR (Status)) {
return Status;
}
NextDevStat |= VSTAT_ACK; // step 2 -- acknowledge device presence
- Status = VIRTIO_CFG_WRITE (Dev, Generic.VhdrDeviceStatus, NextDevStat);
+ Status = Dev->VirtIo->SetDeviceStatus (Dev->VirtIo, NextDevStat);
if (EFI_ERROR (Status)) {
goto YieldDevice;
}
NextDevStat |= VSTAT_DRIVER; // step 3 -- we know how to drive it
- Status = VIRTIO_CFG_WRITE (Dev, Generic.VhdrDeviceStatus, NextDevStat);
+ Status = Dev->VirtIo->SetDeviceStatus (Dev->VirtIo, NextDevStat);
if (EFI_ERROR (Status)) {
goto YieldDevice;
}
@@ -94,7 +93,7 @@ VirtioNetGetFeatures (
//
// step 4a -- retrieve and validate features
//
- Status = VIRTIO_CFG_READ (Dev, Generic.VhdrDeviceFeatureBits, &Features);
+ Status = Dev->VirtIo->GetDeviceFeatures (Dev->VirtIo, &Features);
if (EFI_ERROR (Status)) {
goto YieldDevice;
}
@@ -106,13 +105,12 @@ VirtioNetGetFeatures (
Status = EFI_UNSUPPORTED;
goto YieldDevice;
}
- Status = Dev->PciIo->Io.Read (Dev->PciIo, // PciIo
- EfiPciIoWidthUint8, // Width
- PCI_BAR_IDX0, // BarIndex
- OFFSET_OF_VNET (VhdrMac), // Offset
- SIZE_OF_VNET (VhdrMac), // Count
- MacAddress // Buffer
- );
+ Status = Dev->VirtIo->ReadDevice (Dev->VirtIo,
+ OFFSET_OF_VNET (Mac), // Offset
+ sizeof(UINT8), // FieldSize
+ SIZE_OF_VNET (Mac), // BufferSize
+ MacAddress // Buffer
+ );
if (EFI_ERROR (Status)) {
goto YieldDevice;
@@ -126,7 +124,7 @@ VirtioNetGetFeatures (
}
else {
*MediaPresentSupported = TRUE;
- Status = VIRTIO_CFG_READ (Dev, VhdrLinkStatus, &LinkStatus);
+ Status = VIRTIO_CFG_READ (Dev, LinkStatus, &LinkStatus);
if (EFI_ERROR (Status)) {
goto YieldDevice;
}
@@ -134,7 +132,7 @@ VirtioNetGetFeatures (
}
YieldDevice:
- VIRTIO_CFG_WRITE (Dev, Generic.VhdrDeviceStatus,
+ Dev->VirtIo->SetDeviceStatus (Dev->VirtIo,
EFI_ERROR (Status) ? VSTAT_FAILED : 0);
return Status;
@@ -207,9 +205,9 @@ VirtioNetSnpPopulate (
Dev->Snp.Mode = &Dev->Snm;
Dev->Snm.State = EfiSimpleNetworkStopped;
- Dev->Snm.HwAddressSize = SIZE_OF_VNET (VhdrMac);
- Dev->Snm.MediaHeaderSize = SIZE_OF_VNET (VhdrMac) + // dst MAC
- SIZE_OF_VNET (VhdrMac) + // src MAC
+ Dev->Snm.HwAddressSize = SIZE_OF_VNET (Mac);
+ Dev->Snm.MediaHeaderSize = SIZE_OF_VNET (Mac) + // dst MAC
+ SIZE_OF_VNET (Mac) + // src MAC
2; // Ethertype
Dev->Snm.MaxPacketSize = 1500;
Dev->Snm.NvRamSize = 0;
@@ -222,7 +220,7 @@ VirtioNetSnpPopulate (
Dev->Snm.MacAddressChangeable = FALSE;
Dev->Snm.MultipleTxSupported = TRUE;
- ASSERT (SIZE_OF_VNET (VhdrMac) <= sizeof (EFI_MAC_ADDRESS));
+ ASSERT (SIZE_OF_VNET (Mac) <= sizeof (EFI_MAC_ADDRESS));
Status = VirtioNetGetFeatures (Dev, &Dev->Snm.CurrentAddress,
&Dev->Snm.MediaPresentSupported, &Dev->Snm.MediaPresent);
@@ -230,8 +228,8 @@ VirtioNetSnpPopulate (
goto CloseWaitForPacket;
}
CopyMem (&Dev->Snm.PermanentAddress, &Dev->Snm.CurrentAddress,
- SIZE_OF_VNET (VhdrMac));
- SetMem (&Dev->Snm.BroadcastAddress, SIZE_OF_VNET (VhdrMac), 0xFF);
+ SIZE_OF_VNET (Mac));
+ SetMem (&Dev->Snm.BroadcastAddress, SIZE_OF_VNET (Mac), 0xFF);
//
// VirtioNetExitBoot() is queued by ExitBootServices(); its purpose is to
@@ -348,31 +346,36 @@ VirtioNetDriverBindingSupported (
)
{
EFI_STATUS Status;
- EFI_PCI_IO_PROTOCOL *PciIo;
- PCI_TYPE00 Pci;
-
- Status = gBS->OpenProtocol (DeviceHandle, &gEfiPciIoProtocolGuid,
- (VOID **)&PciIo, This->DriverBindingHandle, DeviceHandle,
- EFI_OPEN_PROTOCOL_BY_DRIVER);
+ VIRTIO_DEVICE_PROTOCOL *VirtIo;
+
+ //
+ // Attempt to open the device with the VirtIo set of interfaces. On success,
+ // the protocol is "instantiated" for the VirtIo device. Covers duplicate open
+ // attempts (EFI_ALREADY_STARTED).
+ //
+ Status = gBS->OpenProtocol (
+ DeviceHandle, // candidate device
+ &gVirtioDeviceProtocolGuid, // for generic VirtIo access
+ (VOID **)&VirtIo, // handle to instantiate
+ This->DriverBindingHandle, // requestor driver identity
+ DeviceHandle, // ControllerHandle, according to
+ // the UEFI Driver Model
+ EFI_OPEN_PROTOCOL_BY_DRIVER // get exclusive VirtIo access to
+ // the device; to be released
+ );
if (EFI_ERROR (Status)) {
return Status;
}
- Status = PciIo->Pci.Read (PciIo, EfiPciIoWidthUint32, 0,
- sizeof Pci / sizeof (UINT32), &Pci);
+ if (VirtIo->SubSystemDeviceId != VIRTIO_SUBSYSTEM_NETWORK_CARD) {
+ Status = EFI_UNSUPPORTED;
+ }
//
- // virtio-0.9.5, 2.1 PCI Discovery:
- // the network device has Subsystem Device ID 1
+ // We needed VirtIo access only transitorily, to see whether we support the
+ // device or not.
//
- if (Status == EFI_SUCCESS) {
- Status = (Pci.Hdr.VendorId == 0x1AF4 &&
- Pci.Hdr.DeviceId >= 0x1000 && Pci.Hdr.DeviceId <= 0x103F &&
- Pci.Hdr.RevisionID == 0x00 &&
- Pci.Device.SubsystemID == 0x01) ? EFI_SUCCESS : EFI_UNSUPPORTED;
- }
-
- gBS->CloseProtocol (DeviceHandle, &gEfiPciIoProtocolGuid,
+ gBS->CloseProtocol (DeviceHandle, &gVirtioDeviceProtocolGuid,
This->DriverBindingHandle, DeviceHandle);
return Status;
}
@@ -438,7 +441,7 @@ VirtioNetDriverBindingStart (
VNET_DEV *Dev;
EFI_DEVICE_PATH_PROTOCOL *DevicePath;
MAC_ADDR_DEVICE_PATH MacNode;
- VOID *ChildPciIo;
+ VOID *ChildVirtIo;
//
// allocate space for the driver instance
@@ -449,30 +452,15 @@ VirtioNetDriverBindingStart (
}
Dev->Signature = VNET_SIG;
- //
- // get PCI access to the device and keep it open
- //
- Status = gBS->OpenProtocol (DeviceHandle, &gEfiPciIoProtocolGuid,
- (VOID **)&Dev->PciIo, This->DriverBindingHandle,
+ Status = gBS->OpenProtocol (DeviceHandle, &gVirtioDeviceProtocolGuid,
+ (VOID **)&Dev->VirtIo, This->DriverBindingHandle,
DeviceHandle, EFI_OPEN_PROTOCOL_BY_DRIVER);
if (EFI_ERROR (Status)) {
goto FreeVirtioNet;
}
- //
- // save original PCI attributes and enable IO space access
- //
- Status = Dev->PciIo->Attributes (Dev->PciIo, EfiPciIoAttributeOperationGet,
- 0, &Dev->OrigPciAttributes);
- if (EFI_ERROR (Status)) {
- goto ClosePciIo;
- }
-
- Status = Dev->PciIo->Attributes (Dev->PciIo,
- EfiPciIoAttributeOperationEnable,
- EFI_PCI_IO_ATTRIBUTE_IO, NULL);
- if (EFI_ERROR (Status)) {
- goto ClosePciIo;
+ if (Dev->VirtIo->SubSystemDeviceId != VIRTIO_SUBSYSTEM_NETWORK_CARD) {
+ return EFI_UNSUPPORTED;
}
//
@@ -481,11 +469,11 @@ VirtioNetDriverBindingStart (
//
Status = VirtioNetSnpPopulate (Dev);
if (EFI_ERROR (Status)) {
- goto RestorePciAttributes;
+ goto CloseVirtIo;
}
//
- // get the device path of the virtio-net PCI device -- one-shot open
+ // get the device path of the virtio-net device -- one-shot open
//
Status = gBS->OpenProtocol (DeviceHandle, &gEfiDevicePathProtocolGuid,
(VOID **)&DevicePath, This->DriverBindingHandle,
@@ -523,11 +511,11 @@ VirtioNetDriverBindingStart (
}
//
- // make a note that we keep this device open with PciIo for the sake of this
+ // make a note that we keep this device open with VirtIo for the sake of this
// child
//
- Status = gBS->OpenProtocol (DeviceHandle, &gEfiPciIoProtocolGuid,
- &ChildPciIo, This->DriverBindingHandle,
+ Status = gBS->OpenProtocol (DeviceHandle, &gVirtioDeviceProtocolGuid,
+ &ChildVirtIo, This->DriverBindingHandle,
Dev->MacHandle, EFI_OPEN_PROTOCOL_BY_CHILD_CONTROLLER);
if (EFI_ERROR (Status)) {
goto UninstallMultiple;
@@ -547,12 +535,8 @@ FreeMacDevicePath:
Evacuate:
VirtioNetSnpEvacuate (Dev);
-RestorePciAttributes:
- Dev->PciIo->Attributes (Dev->PciIo, EfiPciIoAttributeOperationSet,
- Dev->OrigPciAttributes, NULL);
-
-ClosePciIo:
- gBS->CloseProtocol (DeviceHandle, &gEfiPciIoProtocolGuid,
+CloseVirtIo:
+ gBS->CloseProtocol (DeviceHandle, &gVirtioDeviceProtocolGuid,
This->DriverBindingHandle, DeviceHandle);
FreeVirtioNet:
@@ -637,7 +621,7 @@ VirtioNetDriverBindingStop (
Status = EFI_DEVICE_ERROR;
}
else {
- gBS->CloseProtocol (DeviceHandle, &gEfiPciIoProtocolGuid,
+ gBS->CloseProtocol (DeviceHandle, &gVirtioDeviceProtocolGuid,
This->DriverBindingHandle, Dev->MacHandle);
gBS->UninstallMultipleProtocolInterfaces (Dev->MacHandle,
&gEfiDevicePathProtocolGuid, Dev->MacDevicePath,
@@ -645,8 +629,6 @@ VirtioNetDriverBindingStop (
NULL);
FreePool (Dev->MacDevicePath);
VirtioNetSnpEvacuate (Dev);
- Dev->PciIo->Attributes (Dev->PciIo, EfiPciIoAttributeOperationSet,
- Dev->OrigPciAttributes, NULL);
FreePool (Dev);
}
@@ -657,7 +639,7 @@ VirtioNetDriverBindingStop (
//
// release remaining resources, tied directly to the parent handle
//
- gBS->CloseProtocol (DeviceHandle, &gEfiPciIoProtocolGuid,
+ gBS->CloseProtocol (DeviceHandle, &gVirtioDeviceProtocolGuid,
This->DriverBindingHandle, DeviceHandle);
return EFI_SUCCESS;
diff --git a/OvmfPkg/VirtioNetDxe/Events.c b/OvmfPkg/VirtioNetDxe/Events.c
index b9d7bbf6c..4889580f3 100644
--- a/OvmfPkg/VirtioNetDxe/Events.c
+++ b/OvmfPkg/VirtioNetDxe/Events.c
@@ -86,6 +86,6 @@ VirtioNetExitBoot (
Dev = Context;
if (Dev->Snm.State == EfiSimpleNetworkInitialized) {
- VIRTIO_CFG_WRITE (Dev, Generic.VhdrDeviceStatus, 0);
+ Dev->VirtIo->SetDeviceStatus (Dev->VirtIo, 0);
}
}
diff --git a/OvmfPkg/VirtioNetDxe/SnpGetStatus.c b/OvmfPkg/VirtioNetDxe/SnpGetStatus.c
index adb57cf8f..b92011561 100644
--- a/OvmfPkg/VirtioNetDxe/SnpGetStatus.c
+++ b/OvmfPkg/VirtioNetDxe/SnpGetStatus.c
@@ -90,7 +90,7 @@ VirtioNetGetStatus (
if (Dev->Snm.MediaPresentSupported) {
UINT16 LinkStatus;
- Status = VIRTIO_CFG_READ (Dev, VhdrLinkStatus, &LinkStatus);
+ Status = VIRTIO_CFG_READ (Dev, LinkStatus, &LinkStatus);
if (EFI_ERROR (Status)) {
goto Exit;
}
diff --git a/OvmfPkg/VirtioNetDxe/SnpInitialize.c b/OvmfPkg/VirtioNetDxe/SnpInitialize.c
index 6cee01407..4352ab96b 100644
--- a/OvmfPkg/VirtioNetDxe/SnpInitialize.c
+++ b/OvmfPkg/VirtioNetDxe/SnpInitialize.c
@@ -57,14 +57,15 @@ VirtioNetInitRing (
//
// step 4b -- allocate selected queue
//
- Status = VIRTIO_CFG_WRITE (Dev, Generic.VhdrQueueSelect, Selector);
+ Status = Dev->VirtIo->SetQueueSel (Dev->VirtIo, Selector);
if (EFI_ERROR (Status)) {
return Status;
}
- Status = VIRTIO_CFG_READ (Dev, Generic.VhdrQueueSize, &QueueSize);
+ Status = Dev->VirtIo->GetQueueNumMax (Dev->VirtIo, &QueueSize);
if (EFI_ERROR (Status)) {
return Status;
}
+
//
// For each packet (RX and TX alike), we need two descriptors:
// one for the virtio-net request header, and another one for the data
@@ -80,8 +81,8 @@ VirtioNetInitRing (
//
// step 4c -- report GPFN (guest-physical frame number) of queue
//
- Status = VIRTIO_CFG_WRITE (Dev, Generic.VhdrQueueAddress,
- (UINTN) Ring->Base >> EFI_PAGE_SHIFT);
+ Status = Dev->VirtIo->SetQueueAddress (Dev->VirtIo,
+ (UINTN) Ring->Base >> EFI_PAGE_SHIFT);
if (EFI_ERROR (Status)) {
VirtioRingUninit (Ring);
}
@@ -287,10 +288,9 @@ VirtioNetInitRx (
// virtio-0.9.5, 2.4.1.4 Notifying the Device
//
MemoryFence ();
- Status = VIRTIO_CFG_WRITE (Dev, Generic.VhdrQueueNotify, VIRTIO_NET_Q_RX);
-
+ Status = Dev->VirtIo->SetQueueNotify (Dev->VirtIo, VIRTIO_NET_Q_RX);
if (EFI_ERROR (Status)) {
- VIRTIO_CFG_WRITE (Dev, Generic.VhdrDeviceStatus, 0);
+ Dev->VirtIo->SetDeviceStatus (Dev->VirtIo, 0);
FreePool (Dev->RxBuf);
}
@@ -366,25 +366,34 @@ VirtioNetInitialize (
// virtio-0.9.5 spec, 2.2.1 Device Initialization Sequence.
//
NextDevStat = VSTAT_ACK; // step 2 -- acknowledge device presence
- Status = VIRTIO_CFG_WRITE (Dev, Generic.VhdrDeviceStatus, NextDevStat);
+ Status = Dev->VirtIo->SetDeviceStatus (Dev->VirtIo, NextDevStat);
if (EFI_ERROR (Status)) {
goto InitFailed;
}
NextDevStat |= VSTAT_DRIVER; // step 3 -- we know how to drive it
- Status = VIRTIO_CFG_WRITE (Dev, Generic.VhdrDeviceStatus, NextDevStat);
+ Status = Dev->VirtIo->SetDeviceStatus (Dev->VirtIo, NextDevStat);
if (EFI_ERROR (Status)) {
goto DeviceFailed;
}
//
+ // Set Page Size - MMIO VirtIo Specific
+ //
+ Status = Dev->VirtIo->SetPageSize (Dev->VirtIo, EFI_PAGE_SIZE);
+ if (EFI_ERROR (Status)) {
+ goto ReleaseTxRing;
+ }
+
+ //
// step 4a -- retrieve features. Note that we're past validating required
// features in VirtioNetGetFeatures().
//
- Status = VIRTIO_CFG_READ (Dev, Generic.VhdrDeviceFeatureBits, &Features);
+ Status = Dev->VirtIo->GetDeviceFeatures (Dev->VirtIo, &Features);
if (EFI_ERROR (Status)) {
goto DeviceFailed;
}
+
ASSERT (Features & VIRTIO_NET_F_MAC);
ASSERT (Dev->Snm.MediaPresentSupported ==
!!(Features & VIRTIO_NET_F_STATUS));
@@ -406,7 +415,7 @@ VirtioNetInitialize (
// step 5 -- keep only the features we want
//
Features &= VIRTIO_NET_F_MAC | VIRTIO_NET_F_STATUS;
- Status = VIRTIO_CFG_WRITE (Dev, Generic.VhdrGuestFeatureBits, Features);
+ Status = Dev->VirtIo->SetGuestFeatures (Dev->VirtIo, Features);
if (EFI_ERROR (Status)) {
goto ReleaseTxRing;
}
@@ -415,7 +424,7 @@ VirtioNetInitialize (
// step 6 -- virtio-net initialization complete
//
NextDevStat |= VSTAT_DRIVER_OK;
- Status = VIRTIO_CFG_WRITE (Dev, Generic.VhdrDeviceStatus, NextDevStat);
+ Status = Dev->VirtIo->SetDeviceStatus (Dev->VirtIo, NextDevStat);
if (EFI_ERROR (Status)) {
goto ReleaseTxRing;
}
@@ -441,7 +450,7 @@ ReleaseTxAux:
VirtioNetShutdownTx (Dev);
AbortDevice:
- VIRTIO_CFG_WRITE (Dev, Generic.VhdrDeviceStatus, 0);
+ Dev->VirtIo->SetDeviceStatus (Dev->VirtIo, 0);
ReleaseTxRing:
VirtioRingUninit (&Dev->TxRing);
@@ -453,7 +462,7 @@ DeviceFailed:
//
// restore device status invariant for the EfiSimpleNetworkStarted state
//
- VIRTIO_CFG_WRITE (Dev, Generic.VhdrDeviceStatus, 0);
+ Dev->VirtIo->SetDeviceStatus (Dev->VirtIo, 0);
InitFailed:
gBS->RestoreTPL (OldTpl);
diff --git a/OvmfPkg/VirtioNetDxe/SnpReceive.c b/OvmfPkg/VirtioNetDxe/SnpReceive.c
index 87c6ca9b4..ce87978f1 100644
--- a/OvmfPkg/VirtioNetDxe/SnpReceive.c
+++ b/OvmfPkg/VirtioNetDxe/SnpReceive.c
@@ -147,14 +147,14 @@ VirtioNetReceive (
CopyMem (Buffer, RxPtr, RxLen);
if (DestAddr != NULL) {
- CopyMem (DestAddr, RxPtr, SIZE_OF_VNET (VhdrMac));
+ CopyMem (DestAddr, RxPtr, SIZE_OF_VNET (Mac));
}
- RxPtr += SIZE_OF_VNET (VhdrMac);
+ RxPtr += SIZE_OF_VNET (Mac);
if (SrcAddr != NULL) {
- CopyMem (SrcAddr, RxPtr, SIZE_OF_VNET (VhdrMac));
+ CopyMem (SrcAddr, RxPtr, SIZE_OF_VNET (Mac));
}
- RxPtr += SIZE_OF_VNET (VhdrMac);
+ RxPtr += SIZE_OF_VNET (Mac);
if (Protocol != NULL) {
*Protocol = (UINT16) ((RxPtr[0] << 8) | RxPtr[1]);
@@ -177,9 +177,7 @@ RecycleDesc:
*Dev->RxRing.Avail.Idx = AvailIdx;
MemoryFence ();
- NotifyStatus = VIRTIO_CFG_WRITE (Dev, Generic.VhdrQueueNotify,
- VIRTIO_NET_Q_RX);
-
+ NotifyStatus = Dev->VirtIo->SetQueueNotify (Dev->VirtIo, VIRTIO_NET_Q_RX);
if (!EFI_ERROR (Status)) { // earlier error takes precedence
Status = NotifyStatus;
}
diff --git a/OvmfPkg/VirtioNetDxe/SnpShutdown.c b/OvmfPkg/VirtioNetDxe/SnpShutdown.c
index 42aeca167..c05a22f65 100644
--- a/OvmfPkg/VirtioNetDxe/SnpShutdown.c
+++ b/OvmfPkg/VirtioNetDxe/SnpShutdown.c
@@ -63,7 +63,7 @@ VirtioNetShutdown (
break;
}
- VIRTIO_CFG_WRITE (Dev, Generic.VhdrDeviceStatus, 0);
+ Dev->VirtIo->SetDeviceStatus (Dev->VirtIo, 0);
VirtioNetShutdownRx (Dev);
VirtioNetShutdownTx (Dev);
VirtioRingUninit (&Dev->TxRing);
diff --git a/OvmfPkg/VirtioNetDxe/SnpTransmit.c b/OvmfPkg/VirtioNetDxe/SnpTransmit.c
index ff922ca02..b2a364b96 100644
--- a/OvmfPkg/VirtioNetDxe/SnpTransmit.c
+++ b/OvmfPkg/VirtioNetDxe/SnpTransmit.c
@@ -127,15 +127,15 @@ VirtioNetTransmit (
goto Exit;
}
Ptr = Buffer;
- ASSERT (SIZE_OF_VNET (VhdrMac) <= sizeof (EFI_MAC_ADDRESS));
+ ASSERT (SIZE_OF_VNET (Mac) <= sizeof (EFI_MAC_ADDRESS));
- CopyMem (Ptr, DestAddr, SIZE_OF_VNET (VhdrMac));
- Ptr += SIZE_OF_VNET (VhdrMac);
+ CopyMem (Ptr, DestAddr, SIZE_OF_VNET (Mac));
+ Ptr += SIZE_OF_VNET (Mac);
CopyMem (Ptr,
(SrcAddr == NULL) ? &Dev->Snm.CurrentAddress : SrcAddr,
- SIZE_OF_VNET (VhdrMac));
- Ptr += SIZE_OF_VNET (VhdrMac);
+ SIZE_OF_VNET (Mac));
+ Ptr += SIZE_OF_VNET (Mac);
*Ptr++ = (UINT8) (*Protocol >> 8);
*Ptr++ = (UINT8) *Protocol;
@@ -161,7 +161,7 @@ VirtioNetTransmit (
*Dev->TxRing.Avail.Idx = AvailIdx;
MemoryFence ();
- Status = VIRTIO_CFG_WRITE (Dev, Generic.VhdrQueueNotify, VIRTIO_NET_Q_TX);
+ Status = Dev->VirtIo->SetQueueNotify (Dev->VirtIo, VIRTIO_NET_Q_TX);
Exit:
gBS->RestoreTPL (OldTpl);
diff --git a/OvmfPkg/VirtioNetDxe/VirtioNet.h b/OvmfPkg/VirtioNetDxe/VirtioNet.h
index 8c21bcdfa..a0e0b4337 100644
--- a/OvmfPkg/VirtioNetDxe/VirtioNet.h
+++ b/OvmfPkg/VirtioNetDxe/VirtioNet.h
@@ -24,7 +24,6 @@
#include <Protocol/ComponentName2.h>
#include <Protocol/DevicePath.h>
#include <Protocol/DriverBinding.h>
-#include <Protocol/PciIo.h>
#include <Protocol/SimpleNetwork.h>
#define VNET_SIG SIGNATURE_32 ('V', 'N', 'E', 'T')
@@ -75,8 +74,7 @@ typedef struct {
// field init function
// ------------------ ------------------------------
UINT32 Signature; // VirtioNetDriverBindingStart
- EFI_PCI_IO_PROTOCOL *PciIo; // VirtioNetDriverBindingStart
- UINT64 OrigPciAttributes; // VirtioNetDriverBindingStart
+ VIRTIO_DEVICE_PROTOCOL *VirtIo; // VirtioNetDriverBindingStart
EFI_SIMPLE_NETWORK_PROTOCOL Snp; // VirtioNetSnpPopulate
EFI_SIMPLE_NETWORK_MODE Snm; // VirtioNetSnpPopulate
EFI_EVENT ExitBoot; // VirtioNetSnpPopulate
@@ -109,19 +107,19 @@ typedef struct {
#define VIRTIO_NET_FROM_SNP(SnpPointer) \
CR (SnpPointer, VNET_DEV, Snp, VNET_SIG)
-#define VIRTIO_CFG_WRITE(Dev, Field, Value) (VirtioWrite ( \
- (Dev)->PciIo, \
- OFFSET_OF_VNET (Field), \
- SIZE_OF_VNET (Field), \
- (Value) \
+#define VIRTIO_CFG_WRITE(Dev, Field, Value) ((Dev)->VirtIo->WriteDevice ( \
+ (Dev)->VirtIo, \
+ OFFSET_OF_VNET (Field), \
+ SIZE_OF_VNET (Field), \
+ (Value) \
))
-#define VIRTIO_CFG_READ(Dev, Field, Pointer) (VirtioRead ( \
- (Dev)->PciIo, \
- OFFSET_OF_VNET (Field), \
- SIZE_OF_VNET (Field), \
- sizeof *(Pointer), \
- (Pointer) \
+#define VIRTIO_CFG_READ(Dev, Field, Pointer) ((Dev)->VirtIo->ReadDevice ( \
+ (Dev)->VirtIo, \
+ OFFSET_OF_VNET (Field), \
+ SIZE_OF_VNET (Field), \
+ sizeof *(Pointer), \
+ (Pointer) \
))
//
diff --git a/OvmfPkg/VirtioNetDxe/VirtioNet.inf b/OvmfPkg/VirtioNetDxe/VirtioNet.inf
index 408a54112..dea01f3b9 100644
--- a/OvmfPkg/VirtioNetDxe/VirtioNet.inf
+++ b/OvmfPkg/VirtioNetDxe/VirtioNet.inf
@@ -57,4 +57,4 @@
[Protocols]
gEfiSimpleNetworkProtocolGuid ## BY_START
gEfiDevicePathProtocolGuid ## BY_START
- gEfiPciIoProtocolGuid ## TO_START
+ gVirtioDeviceProtocolGuid ## TO_START
diff --git a/OvmfPkg/VirtioPciDeviceDxe/VirtioPciDevice.c b/OvmfPkg/VirtioPciDeviceDxe/VirtioPciDevice.c
new file mode 100644
index 000000000..b120d5f2c
--- /dev/null
+++ b/OvmfPkg/VirtioPciDeviceDxe/VirtioPciDevice.c
@@ -0,0 +1,667 @@
+/** @file
+
+ This driver produces Virtio Device Protocol instances for Virtio PCI devices.
+
+ Copyright (C) 2012, Red Hat, Inc.
+ Copyright (c) 2012, Intel Corporation. All rights reserved.<BR>
+ Copyright (C) 2013, ARM Ltd.
+
+ 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.
+
+**/
+
+#include <IndustryStandard/Pci.h>
+#include <Library/BaseMemoryLib.h>
+#include <Library/DebugLib.h>
+#include <Library/MemoryAllocationLib.h>
+#include <Library/UefiBootServicesTableLib.h>
+#include <Library/UefiLib.h>
+
+#include "VirtioPciDevice.h"
+
+STATIC VIRTIO_DEVICE_PROTOCOL mDeviceProtocolTemplate = {
+ 0, // Revision
+ 0, // SubSystemDeviceId
+ VirtioPciGetDeviceFeatures, // GetDeviceFeatures
+ VirtioPciSetGuestFeatures, // SetGuestFeatures
+ VirtioPciGetQueueAddress, // GetQueueAddress
+ VirtioPciSetQueueAddress, // SetQueueAddress
+ VirtioPciSetQueueSel, // SetQueueSel
+ VirtioPciSetQueueNotify, // SetQueueNotify
+ VirtioPciSetQueueAlignment, // SetQueueAlignment
+ VirtioPciSetPageSize, // SetPageSize
+ VirtioPciGetQueueSize, // GetQueueNumMax
+ VirtioPciSetQueueSize, // SetQueueNum
+ VirtioPciGetDeviceStatus, // GetDeviceStatus
+ VirtioPciSetDeviceStatus, // SetDeviceStatus
+ VirtioPciDeviceWrite, // WriteDevice
+ VirtioPciDeviceRead // ReadDevice
+};
+
+/**
+
+ Read a word from Region 0 of the device specified by PciIo.
+
+ Region 0 must be an iomem region. This is an internal function for the PCI
+ implementation of the protocol.
+
+ @param[in] Dev Virtio PCI device.
+
+ @param[in] FieldOffset Source offset.
+
+ @param[in] FieldSize Source field size, must be in { 1, 2, 4, 8 }.
+
+ @param[in] BufferSize Number of bytes available in the target buffer. Must
+ equal FieldSize.
+
+ @param[out] Buffer Target buffer.
+
+
+ @return Status code returned by PciIo->Io.Read().
+
+**/
+EFI_STATUS
+EFIAPI
+VirtioPciIoRead (
+ IN VIRTIO_PCI_DEVICE *Dev,
+ IN UINTN FieldOffset,
+ IN UINTN FieldSize,
+ IN UINTN BufferSize,
+ OUT VOID *Buffer
+ )
+{
+ UINTN Count;
+ EFI_PCI_IO_PROTOCOL_WIDTH Width;
+ EFI_PCI_IO_PROTOCOL *PciIo;
+
+ // The BufferSize must be a multiple of FieldSize
+ ASSERT ((BufferSize % FieldSize) == 0);
+
+ PciIo = Dev->PciIo;
+ Count = BufferSize / FieldSize;
+
+ switch (FieldSize) {
+ case 1:
+ Width = EfiPciIoWidthUint8;
+ break;
+
+ case 2:
+ Width = EfiPciIoWidthUint16;
+ break;
+
+ case 8:
+ // The 64bit PCI I/O is broken down into two 32bit reads to prevent
+ // any alignment or width issues.
+ // The UEFI spec says under EFI_PCI_IO_PROTOCOL.Io.Write():
+ //
+ // The I/O operations are carried out exactly as requested. The caller
+ // is responsible for any alignment and I/O width issues which the
+ // bus, device, platform, or type of I/O might require. For example on
+ // some platforms, width requests of EfiPciIoWidthUint64 do not work
+ Count = Count * 2;
+ // fall through
+
+ case 4:
+ Width = EfiPciIoWidthUint32;
+ break;
+
+ default:
+ ASSERT (FALSE);
+ return EFI_INVALID_PARAMETER;
+ }
+
+ return PciIo->Io.Read (
+ PciIo,
+ Width,
+ PCI_BAR_IDX0,
+ FieldOffset,
+ Count,
+ Buffer
+ );
+}
+
+/**
+
+ Write a word into Region 0 of the device specified by PciIo.
+
+ Region 0 must be an iomem region. This is an internal function for the PCI
+ implementation of the protocol.
+
+ @param[in] Dev Virtio PCI device.
+
+ @param[in] FieldOffset Destination offset.
+
+ @param[in] FieldSize Destination field size, must be in { 1, 2, 4, 8 }.
+
+ @param[in] Value Little endian value to write, converted to UINT64.
+ The least significant FieldSize bytes will be used.
+
+
+ @return Status code returned by PciIo->Io.Write().
+
+**/
+EFI_STATUS
+EFIAPI
+VirtioPciIoWrite (
+ IN VIRTIO_PCI_DEVICE *Dev,
+ IN UINTN FieldOffset,
+ IN UINTN FieldSize,
+ IN UINT64 Value
+ )
+{
+ UINTN Count;
+ EFI_PCI_IO_PROTOCOL_WIDTH Width;
+ EFI_PCI_IO_PROTOCOL *PciIo;
+
+ PciIo = Dev->PciIo;
+ Count = 1;
+
+ switch (FieldSize) {
+ case 1:
+ Width = EfiPciIoWidthUint8;
+ break;
+
+ case 2:
+ Width = EfiPciIoWidthUint16;
+ break;
+
+ case 8:
+ // The 64bit PCI I/O is broken down into two 32bit writes to prevent
+ // any alignment or width issues.
+ // The UEFI spec says under EFI_PCI_IO_PROTOCOL.Io.Write():
+ //
+ // The I/O operations are carried out exactly as requested. The caller
+ // is responsible for any alignment and I/O width issues which the
+ // bus, device, platform, or type of I/O might require. For example on
+ // some platforms, width requests of EfiPciIoWidthUint64 do not work
+ Count = Count * 2;
+ // fall through
+
+ case 4:
+ Width = EfiPciIoWidthUint32;
+ break;
+
+ default:
+ ASSERT (FALSE);
+ return EFI_INVALID_PARAMETER;
+ }
+
+ return PciIo->Io.Write (
+ PciIo,
+ Width,
+ PCI_BAR_IDX0,
+ FieldOffset,
+ Count,
+ &Value
+ );
+}
+
+/**
+
+ Device probe function for this driver.
+
+ The DXE core calls this function for any given device in order to see if the
+ driver can drive the device.
+
+ @param[in] This The EFI_DRIVER_BINDING_PROTOCOL object
+ incorporating this driver (independently of
+ any device).
+
+ @param[in] DeviceHandle The device to probe.
+
+ @param[in] RemainingDevicePath Relevant only for bus drivers, ignored.
+
+
+ @retval EFI_SUCCESS The driver supports the device being probed.
+
+ @retval EFI_UNSUPPORTED Based on virtio-pci discovery, we do not support
+ the device.
+
+ @return Error codes from the OpenProtocol() boot service or
+ the PciIo protocol.
+
+**/
+STATIC
+EFI_STATUS
+EFIAPI
+VirtioPciDeviceBindingSupported (
+ IN EFI_DRIVER_BINDING_PROTOCOL *This,
+ IN EFI_HANDLE DeviceHandle,
+ IN EFI_DEVICE_PATH_PROTOCOL *RemainingDevicePath
+ )
+{
+ EFI_STATUS Status;
+ EFI_PCI_IO_PROTOCOL *PciIo;
+ PCI_TYPE00 Pci;
+
+ //
+ // Attempt to open the device with the PciIo set of interfaces. On success,
+ // the protocol is "instantiated" for the PCI device. Covers duplicate open
+ // attempts (EFI_ALREADY_STARTED).
+ //
+ Status = gBS->OpenProtocol (
+ DeviceHandle, // candidate device
+ &gEfiPciIoProtocolGuid, // for generic PCI access
+ (VOID **)&PciIo, // handle to instantiate
+ This->DriverBindingHandle, // requestor driver identity
+ DeviceHandle, // ControllerHandle, according to
+ // the UEFI Driver Model
+ EFI_OPEN_PROTOCOL_BY_DRIVER // get exclusive PciIo access to
+ // the device; to be released
+ );
+ if (EFI_ERROR (Status)) {
+ return Status;
+ }
+
+ //
+ // Read entire PCI configuration header for more extensive check ahead.
+ //
+ Status = PciIo->Pci.Read (
+ PciIo, // (protocol, device)
+ // handle
+ EfiPciIoWidthUint32, // access width & copy
+ // mode
+ 0, // Offset
+ sizeof Pci / sizeof (UINT32), // Count
+ &Pci // target buffer
+ );
+
+ if (Status == EFI_SUCCESS) {
+ //
+ // virtio-0.9.5, 2.1 PCI Discovery
+ //
+ if ((Pci.Hdr.VendorId == VIRTIO_VENDOR_ID) &&
+ (Pci.Hdr.DeviceId >= 0x1000) &&
+ (Pci.Hdr.DeviceId <= 0x103F) &&
+ (Pci.Hdr.RevisionID == 0x00)) {
+ Status = EFI_SUCCESS;
+ } else {
+ Status = EFI_UNSUPPORTED;
+ }
+ }
+
+ //
+ // We needed PCI IO access only transitorily, to see whether we support the
+ // device or not.
+ //
+ gBS->CloseProtocol (DeviceHandle, &gEfiPciIoProtocolGuid,
+ This->DriverBindingHandle, DeviceHandle);
+
+ return Status;
+}
+
+/**
+
+ Initialize the VirtIo PCI Device
+
+ @param[in, out] Dev The driver instance to configure. The caller is
+ responsible for Device->PciIo's validity (ie. working IO
+ access to the underlying virtio-pci device).
+
+ @retval EFI_SUCCESS Setup complete.
+
+ @retval EFI_UNSUPPORTED The underlying IO device doesn't support the
+ provided address offset and read size.
+
+ @return Error codes from PciIo->Pci.Read().
+
+**/
+STATIC
+EFI_STATUS
+EFIAPI
+VirtioPciInit (
+ IN OUT VIRTIO_PCI_DEVICE *Device
+ )
+{
+ EFI_STATUS Status;
+ EFI_PCI_IO_PROTOCOL *PciIo;
+ PCI_TYPE00 Pci;
+
+ ASSERT (Device != NULL);
+ PciIo = Device->PciIo;
+ ASSERT (PciIo != NULL);
+ ASSERT (PciIo->Pci.Read != NULL);
+
+ Status = PciIo->Pci.Read (
+ PciIo, // (protocol, device)
+ // handle
+ EfiPciIoWidthUint32, // access width & copy
+ // mode
+ 0, // Offset
+ sizeof (Pci) / sizeof (UINT32), // Count
+ &Pci // target buffer
+ );
+ if (EFI_ERROR (Status)) {
+ return Status;
+ }
+
+ // Copy protocol template
+ CopyMem (&Device->VirtioDevice, &mDeviceProtocolTemplate,
+ sizeof (VIRTIO_DEVICE_PROTOCOL));
+
+ // Initialize the protocol interface attributes
+ Device->VirtioDevice.Revision = VIRTIO_SPEC_REVISION (0, 9, 5);
+ Device->VirtioDevice.SubSystemDeviceId = Pci.Device.SubsystemID;
+
+ // Note: We don't support the MSI-X capability. If we did,
+ // the offset would become 24 after enabling MSI-X.
+ Device->DeviceSpecificConfigurationOffset =
+ VIRTIO_DEVICE_SPECIFIC_CONFIGURATION_OFFSET_PCI;
+
+ return EFI_SUCCESS;
+}
+
+/**
+
+ Uninitialize the internals of a virtio-pci device that has been successfully
+ set up with VirtioPciInit().
+
+ @param[in, out] Dev The device to clean up.
+
+**/
+
+STATIC
+VOID
+EFIAPI
+VirtioPciUninit (
+ IN OUT VIRTIO_PCI_DEVICE *Device
+ )
+{
+ // Note: This function mirrors VirtioPciInit() that does not allocate any
+ // resources - there's nothing to free here.
+}
+
+/**
+
+ After we've pronounced support for a specific device in
+ DriverBindingSupported(), we start managing said device (passed in by the
+ Driver Exeuction Environment) with the following service.
+
+ See DriverBindingSupported() for specification references.
+
+ @param[in] This The EFI_DRIVER_BINDING_PROTOCOL object
+ incorporating this driver (independently of
+ any device).
+
+ @param[in] DeviceHandle The supported device to drive.
+
+ @param[in] RemainingDevicePath Relevant only for bus drivers, ignored.
+
+
+ @retval EFI_SUCCESS Driver instance has been created and
+ initialized for the virtio-pci device, it
+ is now accessible via VIRTIO_DEVICE_PROTOCOL.
+
+ @retval EFI_OUT_OF_RESOURCES Memory allocation failed.
+
+ @return Error codes from the OpenProtocol() boot
+ service, the PciIo protocol, VirtioPciInit(),
+ or the InstallProtocolInterface() boot service.
+
+**/
+STATIC
+EFI_STATUS
+EFIAPI
+VirtioPciDeviceBindingStart (
+ IN EFI_DRIVER_BINDING_PROTOCOL *This,
+ IN EFI_HANDLE DeviceHandle,
+ IN EFI_DEVICE_PATH_PROTOCOL *RemainingDevicePath
+ )
+{
+ VIRTIO_PCI_DEVICE *Device;
+ EFI_STATUS Status;
+
+ Device = (VIRTIO_PCI_DEVICE *) AllocateZeroPool (sizeof *Device);
+ if (Device == NULL) {
+ return EFI_OUT_OF_RESOURCES;
+ }
+
+ Status = gBS->OpenProtocol (DeviceHandle, &gEfiPciIoProtocolGuid,
+ (VOID **)&Device->PciIo, This->DriverBindingHandle,
+ DeviceHandle, EFI_OPEN_PROTOCOL_BY_DRIVER);
+ if (EFI_ERROR (Status)) {
+ goto FreeVirtioPci;
+ }
+
+ //
+ // We must retain and ultimately restore the original PCI attributes of the
+ // device. See Driver Writer's Guide for UEFI 2.3.1 v1.01, 18.3 PCI drivers /
+ // 18.3.2 Start() and Stop().
+ //
+ // The third parameter ("Attributes", input) is ignored by the Get operation.
+ // The fourth parameter ("Result", output) is ignored by the Enable and Set
+ // operations.
+ //
+ // For virtio-pci we only need IO space access.
+ //
+ Status = Device->PciIo->Attributes (Device->PciIo,
+ EfiPciIoAttributeOperationGet, 0, &Device->OriginalPciAttributes);
+ if (EFI_ERROR (Status)) {
+ goto ClosePciIo;
+ }
+
+ Status = Device->PciIo->Attributes (Device->PciIo,
+ EfiPciIoAttributeOperationEnable,
+ EFI_PCI_IO_ATTRIBUTE_IO, NULL);
+ if (EFI_ERROR (Status)) {
+ goto ClosePciIo;
+ }
+
+ //
+ // PCI IO access granted, configure protocol instance
+ //
+
+ Status = VirtioPciInit (Device);
+ if (EFI_ERROR (Status)) {
+ goto RestorePciAttributes;
+ }
+
+ //
+ // Setup complete, attempt to export the driver instance's VirtioDevice
+ // interface.
+ //
+ Device->Signature = VIRTIO_PCI_DEVICE_SIGNATURE;
+ Status = gBS->InstallProtocolInterface (&DeviceHandle,
+ &gVirtioDeviceProtocolGuid, EFI_NATIVE_INTERFACE,
+ &Device->VirtioDevice);
+ if (EFI_ERROR (Status)) {
+ goto UninitDev;
+ }
+
+ return EFI_SUCCESS;
+
+UninitDev:
+ VirtioPciUninit (Device);
+
+RestorePciAttributes:
+ Device->PciIo->Attributes (Device->PciIo, EfiPciIoAttributeOperationSet,
+ Device->OriginalPciAttributes, NULL);
+
+ClosePciIo:
+ gBS->CloseProtocol (DeviceHandle, &gEfiPciIoProtocolGuid,
+ This->DriverBindingHandle, DeviceHandle);
+
+FreeVirtioPci:
+ FreePool (Device);
+
+ return Status;
+}
+
+/**
+
+ Stop driving the Virtio PCI device
+
+ @param[in] This The EFI_DRIVER_BINDING_PROTOCOL object
+ incorporating this driver (independently of any
+ device).
+
+ @param[in] DeviceHandle Stop driving this device.
+
+ @param[in] NumberOfChildren Since this function belongs to a device driver
+ only (as opposed to a bus driver), the caller
+ environment sets NumberOfChildren to zero, and
+ we ignore it.
+
+ @param[in] ChildHandleBuffer Ignored (corresponding to NumberOfChildren).
+
+ @retval EFI_SUCCESS Driver instance has been stopped and the PCI
+ configuration attributes have been restored.
+
+ @return Error codes from the OpenProtocol() or
+ CloseProtocol(), UninstallProtocolInterface()
+ boot services.
+
+**/
+STATIC
+EFI_STATUS
+EFIAPI
+VirtioPciDeviceBindingStop (
+ IN EFI_DRIVER_BINDING_PROTOCOL *This,
+ IN EFI_HANDLE DeviceHandle,
+ IN UINTN NumberOfChildren,
+ IN EFI_HANDLE *ChildHandleBuffer
+ )
+{
+ EFI_STATUS Status;
+ VIRTIO_DEVICE_PROTOCOL *VirtioDevice;
+ VIRTIO_PCI_DEVICE *Device;
+
+ Status = gBS->OpenProtocol (
+ DeviceHandle, // candidate device
+ &gVirtioDeviceProtocolGuid, // retrieve the VirtIo iface
+ (VOID **)&VirtioDevice, // target pointer
+ This->DriverBindingHandle, // requestor driver identity
+ DeviceHandle, // requesting lookup for dev.
+ EFI_OPEN_PROTOCOL_GET_PROTOCOL // lookup only, no ref. added
+ );
+ if (EFI_ERROR (Status)) {
+ return Status;
+ }
+
+ Device = VIRTIO_PCI_DEVICE_FROM_VIRTIO_DEVICE (VirtioDevice);
+
+ //
+ // Handle Stop() requests for in-use driver instances gracefully.
+ //
+ Status = gBS->UninstallProtocolInterface (DeviceHandle,
+ &gVirtioDeviceProtocolGuid, &Device->VirtioDevice);
+ if (EFI_ERROR (Status)) {
+ return Status;
+ }
+
+ VirtioPciUninit (Device);
+
+ Device->PciIo->Attributes (Device->PciIo, EfiPciIoAttributeOperationSet,
+ Device->OriginalPciAttributes, NULL);
+
+ Status = gBS->CloseProtocol (DeviceHandle, &gEfiPciIoProtocolGuid,
+ This->DriverBindingHandle, DeviceHandle);
+
+ FreePool (Device);
+
+ return Status;
+}
+
+
+//
+// The static object that groups the Supported() (ie. probe), Start() and
+// Stop() functions of the driver together. Refer to UEFI Spec 2.3.1 + Errata
+// C, 10.1 EFI Driver Binding Protocol.
+//
+STATIC EFI_DRIVER_BINDING_PROTOCOL gDriverBinding = {
+ &VirtioPciDeviceBindingSupported,
+ &VirtioPciDeviceBindingStart,
+ &VirtioPciDeviceBindingStop,
+ 0x10, // Version, must be in [0x10 .. 0xFFFFFFEF] for IHV-developed drivers
+ NULL, // ImageHandle, to be overwritten by
+ // EfiLibInstallDriverBindingComponentName2() in VirtioPciEntryPoint()
+ NULL // DriverBindingHandle, ditto
+};
+
+
+//
+// The purpose of the following scaffolding (EFI_COMPONENT_NAME_PROTOCOL and
+// EFI_COMPONENT_NAME2_PROTOCOL implementation) is to format the driver's name
+// in English, for display on standard console devices. This is recommended for
+// UEFI drivers that follow the UEFI Driver Model. Refer to the Driver Writer's
+// Guide for UEFI 2.3.1 v1.01, 11 UEFI Driver and Controller Names.
+//
+STATIC
+EFI_UNICODE_STRING_TABLE mDriverNameTable[] = {
+ { "eng;en", L"Virtio PCI Driver" },
+ { NULL, NULL }
+};
+
+STATIC
+EFI_COMPONENT_NAME_PROTOCOL gComponentName;
+
+EFI_STATUS
+EFIAPI
+VirtioPciGetDriverName (
+ IN EFI_COMPONENT_NAME_PROTOCOL *This,
+ IN CHAR8 *Language,
+ OUT CHAR16 **DriverName
+ )
+{
+ return LookupUnicodeString2 (
+ Language,
+ This->SupportedLanguages,
+ mDriverNameTable,
+ DriverName,
+ (BOOLEAN)(This == &gComponentName) // Iso639Language
+ );
+}
+
+EFI_STATUS
+EFIAPI
+VirtioPciGetDeviceName (
+ IN EFI_COMPONENT_NAME_PROTOCOL *This,
+ IN EFI_HANDLE DeviceHandle,
+ IN EFI_HANDLE ChildHandle,
+ IN CHAR8 *Language,
+ OUT CHAR16 **ControllerName
+ )
+{
+ return EFI_UNSUPPORTED;
+}
+
+STATIC
+EFI_COMPONENT_NAME_PROTOCOL gComponentName = {
+ &VirtioPciGetDriverName,
+ &VirtioPciGetDeviceName,
+ "eng" // SupportedLanguages, ISO 639-2 language codes
+};
+
+STATIC
+EFI_COMPONENT_NAME2_PROTOCOL gComponentName2 = {
+ (EFI_COMPONENT_NAME2_GET_DRIVER_NAME) &VirtioPciGetDriverName,
+ (EFI_COMPONENT_NAME2_GET_CONTROLLER_NAME) &VirtioPciGetDeviceName,
+ "en" // SupportedLanguages, RFC 4646 language codes
+};
+
+
+//
+// Entry point of this driver.
+//
+EFI_STATUS
+EFIAPI
+VirtioPciDeviceEntryPoint (
+ IN EFI_HANDLE ImageHandle,
+ IN EFI_SYSTEM_TABLE *SystemTable
+ )
+{
+ return EfiLibInstallDriverBindingComponentName2 (
+ ImageHandle,
+ SystemTable,
+ &gDriverBinding,
+ ImageHandle,
+ &gComponentName,
+ &gComponentName2
+ );
+}
diff --git a/OvmfPkg/VirtioPciDeviceDxe/VirtioPciDevice.h b/OvmfPkg/VirtioPciDeviceDxe/VirtioPciDevice.h
new file mode 100644
index 000000000..bbad164f6
--- /dev/null
+++ b/OvmfPkg/VirtioPciDeviceDxe/VirtioPciDevice.h
@@ -0,0 +1,166 @@
+/** @file
+
+ Internal definitions for the VirtIo PCI Device driver
+
+ Copyright (C) 2013, ARM Ltd
+
+ 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.
+
+**/
+
+#ifndef _VIRTIO_PCI_DEVICE_DXE_H_
+#define _VIRTIO_PCI_DEVICE_DXE_H_
+
+#include <Protocol/ComponentName.h>
+#include <Protocol/DriverBinding.h>
+#include <Protocol/PciIo.h>
+#include <Protocol/VirtioDevice.h>
+
+#include <IndustryStandard/Virtio.h>
+
+#define VIRTIO_PCI_DEVICE_SIGNATURE SIGNATURE_32 ('V', 'P', 'C', 'I')
+
+typedef struct {
+ UINT32 Signature;
+ VIRTIO_DEVICE_PROTOCOL VirtioDevice;
+ EFI_PCI_IO_PROTOCOL *PciIo;
+ UINT64 OriginalPciAttributes;
+ UINT32 DeviceSpecificConfigurationOffset;
+} VIRTIO_PCI_DEVICE;
+
+#define VIRTIO_PCI_DEVICE_FROM_VIRTIO_DEVICE(Device) \
+ CR (Device, VIRTIO_PCI_DEVICE, VirtioDevice, VIRTIO_PCI_DEVICE_SIGNATURE)
+
+
+EFI_STATUS
+EFIAPI
+VirtioPciIoRead (
+ IN VIRTIO_PCI_DEVICE *Dev,
+ IN UINTN FieldOffset,
+ IN UINTN FieldSize,
+ IN UINTN BufferSize,
+ OUT VOID *Buffer
+ );
+
+EFI_STATUS
+EFIAPI
+VirtioPciIoWrite (
+ IN VIRTIO_PCI_DEVICE *Dev,
+ IN UINTN FieldOffset,
+ IN UINTN FieldSize,
+ IN UINT64 Value
+ );
+
+/********************************************
+ * PCI Functions for VIRTIO_DEVICE_PROTOCOL
+ *******************************************/
+EFI_STATUS
+EFIAPI
+VirtioPciDeviceRead (
+ IN VIRTIO_DEVICE_PROTOCOL *This,
+ IN UINTN FieldOffset,
+ IN UINTN FieldSize,
+ IN UINTN BufferSize,
+ OUT VOID *Buffer
+ );
+
+EFI_STATUS
+EFIAPI
+VirtioPciDeviceWrite (
+ IN VIRTIO_DEVICE_PROTOCOL *This,
+ IN UINTN FieldOffset,
+ IN UINTN FieldSize,
+ IN UINT64 Value
+ );
+
+EFI_STATUS
+EFIAPI
+VirtioPciGetDeviceFeatures (
+ IN VIRTIO_DEVICE_PROTOCOL *This,
+ OUT UINT32 *DeviceFeatures
+ );
+
+EFI_STATUS
+EFIAPI
+VirtioPciGetQueueAddress (
+ IN VIRTIO_DEVICE_PROTOCOL *This,
+ OUT UINT32 *QueueAddress
+ );
+
+EFI_STATUS
+EFIAPI
+VirtioPciGetQueueSize (
+ IN VIRTIO_DEVICE_PROTOCOL *This,
+ OUT UINT16 *QueueNumMax
+ );
+
+EFI_STATUS
+EFIAPI
+VirtioPciSetQueueAlignment (
+ VIRTIO_DEVICE_PROTOCOL *This,
+ UINT32 Alignment
+ );
+
+EFI_STATUS
+EFIAPI
+VirtioPciSetPageSize (
+ VIRTIO_DEVICE_PROTOCOL *This,
+ UINT32 PageSize
+ );
+
+EFI_STATUS
+EFIAPI
+VirtioPciGetDeviceStatus (
+ IN VIRTIO_DEVICE_PROTOCOL *This,
+ OUT UINT8 *DeviceStatus
+ );
+
+EFI_STATUS
+EFIAPI
+VirtioPciSetGuestFeatures (
+ IN VIRTIO_DEVICE_PROTOCOL *This,
+ IN UINT32 Features
+ );
+
+EFI_STATUS
+EFIAPI
+VirtioPciSetQueueAddress (
+ VIRTIO_DEVICE_PROTOCOL *This,
+ UINT32 Address
+ );
+
+EFI_STATUS
+EFIAPI
+VirtioPciSetQueueSel (
+ VIRTIO_DEVICE_PROTOCOL *This,
+ UINT16 Sel
+ );
+
+EFI_STATUS
+EFIAPI
+VirtioPciSetQueueNotify (
+ VIRTIO_DEVICE_PROTOCOL *This,
+ UINT16 Index
+ );
+
+EFI_STATUS
+EFIAPI
+VirtioPciSetQueueSize (
+ VIRTIO_DEVICE_PROTOCOL *This,
+ UINT16 Size
+ );
+
+EFI_STATUS
+EFIAPI
+VirtioPciSetDeviceStatus (
+ VIRTIO_DEVICE_PROTOCOL *This,
+ UINT8 DeviceStatus
+ );
+
+#endif // _VIRTIO_PCI_DEVICE_DXE_H_
diff --git a/OvmfPkg/VirtioPciDeviceDxe/VirtioPciDeviceDxe.inf b/OvmfPkg/VirtioPciDeviceDxe/VirtioPciDeviceDxe.inf
new file mode 100644
index 000000000..90a5dbc2b
--- /dev/null
+++ b/OvmfPkg/VirtioPciDeviceDxe/VirtioPciDeviceDxe.inf
@@ -0,0 +1,43 @@
+## @file
+# This driver produces the VirtIo Device Protocol instances for VirtIo PCI
+# Device
+#
+# Copyright (C) 2013, ARM Ltd
+#
+# 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.
+#
+##
+
+[Defines]
+ INF_VERSION = 0x00010006
+ BASE_NAME = VirtioPciDeviceDxe
+ FILE_GUID = 83dd3b39-7caf-4fac-a542-e050b767e3a7
+ MODULE_TYPE = UEFI_DRIVER
+ VERSION_STRING = 1.0
+ ENTRY_POINT = VirtioPciDeviceEntryPoint
+
+[Sources]
+ VirtioPciDevice.c
+ VirtioPciFunctions.c
+
+[Packages]
+ MdePkg/MdePkg.dec
+ OvmfPkg/OvmfPkg.dec
+
+[LibraryClasses]
+ BaseMemoryLib
+ DebugLib
+ MemoryAllocationLib
+ UefiBootServicesTableLib
+ UefiDriverEntryPoint
+ UefiLib
+
+[Protocols]
+ gEfiPciIoProtocolGuid ## TO_START
+ gVirtioDeviceProtocolGuid ## BY_START
diff --git a/OvmfPkg/VirtioPciDeviceDxe/VirtioPciFunctions.c b/OvmfPkg/VirtioPciDeviceDxe/VirtioPciFunctions.c
new file mode 100644
index 000000000..e9e48b945
--- /dev/null
+++ b/OvmfPkg/VirtioPciDeviceDxe/VirtioPciFunctions.c
@@ -0,0 +1,285 @@
+/** @file
+
+ This driver produces Virtio Device Protocol instances for Virtio PCI devices.
+
+ Copyright (C) 2012, Red Hat, Inc.
+ Copyright (c) 2012, Intel Corporation. All rights reserved.<BR>
+ Copyright (C) 2013, ARM Ltd.
+
+ 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.
+
+**/
+#include <Library/BaseMemoryLib.h>
+#include <Library/DebugLib.h>
+#include <Library/MemoryAllocationLib.h>
+#include <Library/UefiBootServicesTableLib.h>
+#include <Library/UefiLib.h>
+#include "VirtioPciDevice.h"
+
+/**
+
+ Read a word from Region 0 of the device specified by PciIo.
+
+ The function implements the ReadDevice protocol member of
+ VIRTIO_DEVICE_PROTOCOL.
+
+ @param[in] PciIo Source PCI device.
+
+ @param[in] FieldOffset Source offset.
+
+ @param[in] FieldSize Source field size, must be in { 1, 2, 4, 8 }.
+
+ @param[in] BufferSize Number of bytes available in the target buffer. Must
+ equal FieldSize.
+
+ @param[out] Buffer Target buffer.
+
+
+ @return Status code returned by PciIo->Io.Read().
+
+**/
+EFI_STATUS
+EFIAPI
+VirtioPciDeviceRead (
+ IN VIRTIO_DEVICE_PROTOCOL *This,
+ IN UINTN FieldOffset,
+ IN UINTN FieldSize,
+ IN UINTN BufferSize,
+ OUT VOID *Buffer
+ )
+{
+ VIRTIO_PCI_DEVICE *Dev;
+
+ Dev = VIRTIO_PCI_DEVICE_FROM_VIRTIO_DEVICE (This);
+
+ return VirtioPciIoRead (Dev,
+ Dev->DeviceSpecificConfigurationOffset + FieldOffset,
+ FieldSize, BufferSize, Buffer);
+}
+
+/**
+
+ Write a word into Region 0 of the device specified by VirtIo Device protocol.
+
+ @param[in] This VirtIo Device protocol.
+
+ @param[in] FieldOffset Destination offset.
+
+ @param[in] FieldSize Destination field size, must be in { 1, 2, 4, 8 }.
+
+ @param[in] Value Little endian value to write, converted to UINT64.
+ The least significant FieldSize bytes will be used.
+
+
+ @return Status code returned by PciIo->Io.Write().
+
+**/
+EFI_STATUS
+EFIAPI
+VirtioPciDeviceWrite (
+ IN VIRTIO_DEVICE_PROTOCOL *This,
+ IN UINTN FieldOffset,
+ IN UINTN FieldSize,
+ IN UINT64 Value
+ )
+{
+ VIRTIO_PCI_DEVICE *Dev;
+
+ Dev = VIRTIO_PCI_DEVICE_FROM_VIRTIO_DEVICE (This);
+
+ return VirtioPciIoWrite (Dev,
+ Dev->DeviceSpecificConfigurationOffset + FieldOffset, FieldSize, Value);
+}
+
+EFI_STATUS
+EFIAPI
+VirtioPciGetDeviceFeatures (
+ IN VIRTIO_DEVICE_PROTOCOL *This,
+ OUT UINT32 *DeviceFeatures
+ )
+{
+ VIRTIO_PCI_DEVICE *Dev;
+
+ if (DeviceFeatures == NULL) {
+ return EFI_INVALID_PARAMETER;
+ }
+
+ Dev = VIRTIO_PCI_DEVICE_FROM_VIRTIO_DEVICE (This);
+
+ return VirtioPciIoRead (Dev, VIRTIO_PCI_OFFSET_DEVICE_FEATURES, sizeof (UINT32),
+ sizeof (UINT32), DeviceFeatures);
+}
+
+EFI_STATUS
+EFIAPI
+VirtioPciGetQueueAddress (
+ IN VIRTIO_DEVICE_PROTOCOL *This,
+ OUT UINT32 *QueueAddress
+ )
+{
+ VIRTIO_PCI_DEVICE *Dev;
+
+ if (QueueAddress == NULL) {
+ return EFI_INVALID_PARAMETER;
+ }
+
+ Dev = VIRTIO_PCI_DEVICE_FROM_VIRTIO_DEVICE (This);
+
+ return VirtioPciIoRead (Dev, VIRTIO_PCI_OFFSET_QUEUE_ADDRESS, sizeof (UINT32),
+ sizeof (UINT32), QueueAddress);
+}
+
+EFI_STATUS
+EFIAPI
+VirtioPciGetQueueSize (
+ IN VIRTIO_DEVICE_PROTOCOL *This,
+ OUT UINT16 *QueueNumMax
+ )
+{
+ VIRTIO_PCI_DEVICE *Dev;
+
+ if (QueueNumMax == NULL) {
+ return EFI_INVALID_PARAMETER;
+ }
+
+ Dev = VIRTIO_PCI_DEVICE_FROM_VIRTIO_DEVICE (This);
+
+ return VirtioPciIoRead (Dev, VIRTIO_PCI_OFFSET_QUEUE_SIZE, sizeof (UINT16),
+ sizeof (UINT16), QueueNumMax);
+}
+
+EFI_STATUS
+EFIAPI
+VirtioPciGetDeviceStatus (
+ IN VIRTIO_DEVICE_PROTOCOL *This,
+ OUT UINT8 *DeviceStatus
+ )
+{
+ VIRTIO_PCI_DEVICE *Dev;
+
+ if (DeviceStatus == NULL) {
+ return EFI_INVALID_PARAMETER;
+ }
+
+ Dev = VIRTIO_PCI_DEVICE_FROM_VIRTIO_DEVICE (This);
+
+ return VirtioPciIoRead (Dev, VIRTIO_PCI_OFFSET_QUEUE_DEVICE_STATUS,
+ sizeof (UINT8), sizeof (UINT8), DeviceStatus);
+}
+
+EFI_STATUS
+EFIAPI
+VirtioPciSetGuestFeatures (
+ IN VIRTIO_DEVICE_PROTOCOL *This,
+ IN UINT32 Features
+ )
+{
+ VIRTIO_PCI_DEVICE *Dev;
+
+ Dev = VIRTIO_PCI_DEVICE_FROM_VIRTIO_DEVICE (This);
+
+ return VirtioPciIoWrite (Dev, VIRTIO_PCI_OFFSET_GUEST_FEATURES,
+ sizeof (UINT32), Features);
+}
+
+EFI_STATUS
+EFIAPI
+VirtioPciSetQueueAddress (
+ VIRTIO_DEVICE_PROTOCOL *This,
+ UINT32 Address
+ )
+{
+ VIRTIO_PCI_DEVICE *Dev;
+
+ Dev = VIRTIO_PCI_DEVICE_FROM_VIRTIO_DEVICE (This);
+
+ return VirtioPciIoWrite (Dev, VIRTIO_PCI_OFFSET_QUEUE_ADDRESS, sizeof (UINT32),
+ Address);
+}
+
+EFI_STATUS
+EFIAPI
+VirtioPciSetQueueSel (
+ VIRTIO_DEVICE_PROTOCOL *This,
+ UINT16 Sel
+ )
+{
+ VIRTIO_PCI_DEVICE *Dev;
+
+ Dev = VIRTIO_PCI_DEVICE_FROM_VIRTIO_DEVICE (This);
+
+ return VirtioPciIoWrite (Dev, VIRTIO_PCI_OFFSET_QUEUE_SELECT, sizeof (UINT16),
+ Sel);
+}
+
+EFI_STATUS
+EFIAPI
+VirtioPciSetQueueAlignment (
+ VIRTIO_DEVICE_PROTOCOL *This,
+ UINT32 Alignment
+ )
+{
+ return EFI_SUCCESS;
+}
+
+EFI_STATUS
+EFIAPI
+VirtioPciSetPageSize (
+ VIRTIO_DEVICE_PROTOCOL *This,
+ UINT32 PageSize
+ )
+{
+ ASSERT (PageSize == EFI_PAGE_SIZE);
+
+ return EFI_SUCCESS;
+}
+
+EFI_STATUS
+EFIAPI
+VirtioPciSetQueueNotify (
+ VIRTIO_DEVICE_PROTOCOL *This,
+ UINT16 Index
+ )
+{
+ VIRTIO_PCI_DEVICE *Dev;
+
+ Dev = VIRTIO_PCI_DEVICE_FROM_VIRTIO_DEVICE (This);
+
+ return VirtioPciIoWrite (Dev, VIRTIO_PCI_OFFSET_QUEUE_NOTIFY, sizeof (UINT16),
+ Index);
+}
+
+EFI_STATUS
+EFIAPI
+VirtioPciSetQueueSize (
+ VIRTIO_DEVICE_PROTOCOL *This,
+ UINT16 Size
+ )
+{
+ //
+ // This function is only applicable in Virtio-MMIO.
+ // (The QueueSize field is read-only in Virtio proper (PCI))
+ //
+ return EFI_SUCCESS;
+}
+
+EFI_STATUS
+EFIAPI
+VirtioPciSetDeviceStatus (
+ VIRTIO_DEVICE_PROTOCOL *This,
+ UINT8 DeviceStatus
+ )
+{
+ VIRTIO_PCI_DEVICE *Dev;
+
+ Dev = VIRTIO_PCI_DEVICE_FROM_VIRTIO_DEVICE (This);
+
+ return VirtioPciIoWrite (Dev, VIRTIO_PCI_OFFSET_QUEUE_DEVICE_STATUS,
+ sizeof (UINT8), DeviceStatus);
+}
diff --git a/OvmfPkg/VirtioScsiDxe/VirtioScsi.c b/OvmfPkg/VirtioScsiDxe/VirtioScsi.c
index e58dd80df..3b6c3ade8 100644
--- a/OvmfPkg/VirtioScsiDxe/VirtioScsi.c
+++ b/OvmfPkg/VirtioScsiDxe/VirtioScsi.c
@@ -38,7 +38,6 @@
**/
-#include <IndustryStandard/Pci.h>
#include <IndustryStandard/VirtioScsi.h>
#include <Library/BaseMemoryLib.h>
#include <Library/DebugLib.h>
@@ -52,14 +51,13 @@
/**
Convenience macros to read and write region 0 IO space elements of the
- virtio-scsi PCI device, for configuration purposes.
+ virtio-scsi VirtIo device, for configuration purposes.
The following macros make it possible to specify only the "core parameters"
for such accesses and to derive the rest. By the time VIRTIO_CFG_WRITE()
returns, the transaction will have been completed.
- @param[in] Dev Pointer to the VSCSI_DEV structure whose PCI IO space
- we're accessing. Dev->PciIo must be valid.
+ @param[in] Dev Pointer to the VirtIo Device Protocol
@param[in] Field A field name from VSCSI_HDR, identifying the virtio-scsi
configuration item to access.
@@ -72,23 +70,23 @@
one of UINT8, UINT16, UINT32, UINT64.
- @return Status codes returned by VirtioWrite() / VirtioRead().
+ @return Status codes returned by Virtio->WriteDevice() / Virtio->ReadDevice().
**/
-#define VIRTIO_CFG_WRITE(Dev, Field, Value) (VirtioWrite ( \
- (Dev)->PciIo, \
- OFFSET_OF_VSCSI (Field), \
- SIZE_OF_VSCSI (Field), \
- (Value) \
+#define VIRTIO_CFG_WRITE(Dev, Field, Value) ((Dev)->VirtIo->WriteDevice ( \
+ (Dev)->VirtIo, \
+ OFFSET_OF_VSCSI (Field), \
+ SIZE_OF_VSCSI (Field), \
+ (Value) \
))
-#define VIRTIO_CFG_READ(Dev, Field, Pointer) (VirtioRead ( \
- (Dev)->PciIo, \
- OFFSET_OF_VSCSI (Field), \
- SIZE_OF_VSCSI (Field), \
- sizeof *(Pointer), \
- (Pointer) \
+#define VIRTIO_CFG_READ(Dev, Field, Pointer) ((Dev)->VirtIo->ReadDevice ( \
+ (Dev)->VirtIo, \
+ OFFSET_OF_VSCSI (Field), \
+ SIZE_OF_VSCSI (Field), \
+ sizeof *(Pointer), \
+ (Pointer) \
))
@@ -471,7 +469,7 @@ VirtioScsiPassThru (
// EFI_NOT_READY would save us the effort, but it would also suggest that the
// caller retry.
//
- if (VirtioFlush (Dev->PciIo, VIRTIO_SCSI_REQUEST_QUEUE, &Dev->Ring,
+ if (VirtioFlush (Dev->VirtIo, VIRTIO_SCSI_REQUEST_QUEUE, &Dev->Ring,
&Indices) != EFI_SUCCESS) {
Packet->InTransferLength = 0;
Packet->OutTransferLength = 0;
@@ -718,33 +716,41 @@ VirtioScsiInit (
// Execute virtio-0.9.5, 2.2.1 Device Initialization Sequence.
//
NextDevStat = 0; // step 1 -- reset device
- Status = VIRTIO_CFG_WRITE (Dev, Generic.VhdrDeviceStatus, NextDevStat);
+ Status = Dev->VirtIo->SetDeviceStatus (Dev->VirtIo, NextDevStat);
if (EFI_ERROR (Status)) {
goto Failed;
}
NextDevStat |= VSTAT_ACK; // step 2 -- acknowledge device presence
- Status = VIRTIO_CFG_WRITE (Dev, Generic.VhdrDeviceStatus, NextDevStat);
+ Status = Dev->VirtIo->SetDeviceStatus (Dev->VirtIo, NextDevStat);
if (EFI_ERROR (Status)) {
goto Failed;
}
NextDevStat |= VSTAT_DRIVER; // step 3 -- we know how to drive it
- Status = VIRTIO_CFG_WRITE (Dev, Generic.VhdrDeviceStatus, NextDevStat);
+ Status = Dev->VirtIo->SetDeviceStatus (Dev->VirtIo, NextDevStat);
if (EFI_ERROR (Status)) {
goto Failed;
}
//
+ // Set Page Size - MMIO VirtIo Specific
+ //
+ Status = Dev->VirtIo->SetPageSize (Dev->VirtIo, EFI_PAGE_SIZE);
+ if (EFI_ERROR (Status)) {
+ goto ReleaseQueue;
+ }
+
+ //
// step 4a -- retrieve and validate features
//
- Status = VIRTIO_CFG_READ (Dev, Generic.VhdrDeviceFeatureBits, &Features);
+ Status = Dev->VirtIo->GetDeviceFeatures (Dev->VirtIo, &Features);
if (EFI_ERROR (Status)) {
goto Failed;
}
Dev->InOutSupported = !!(Features & VIRTIO_SCSI_F_INOUT);
- Status = VIRTIO_CFG_READ (Dev, VhdrMaxChannel, &MaxChannel);
+ Status = VIRTIO_CFG_READ (Dev, MaxChannel, &MaxChannel);
if (EFI_ERROR (Status)) {
goto Failed;
}
@@ -756,7 +762,7 @@ VirtioScsiInit (
goto Failed;
}
- Status = VIRTIO_CFG_READ (Dev, VhdrNumQueues, &NumQueues);
+ Status = VIRTIO_CFG_READ (Dev, NumQueues, &NumQueues);
if (EFI_ERROR (Status)) {
goto Failed;
}
@@ -765,7 +771,7 @@ VirtioScsiInit (
goto Failed;
}
- Status = VIRTIO_CFG_READ (Dev, VhdrMaxTarget, &Dev->MaxTarget);
+ Status = VIRTIO_CFG_READ (Dev, MaxTarget, &Dev->MaxTarget);
if (EFI_ERROR (Status)) {
goto Failed;
}
@@ -773,7 +779,7 @@ VirtioScsiInit (
Dev->MaxTarget = PcdGet16 (PcdVirtioScsiMaxTargetLimit);
}
- Status = VIRTIO_CFG_READ (Dev, VhdrMaxLun, &Dev->MaxLun);
+ Status = VIRTIO_CFG_READ (Dev, MaxLun, &Dev->MaxLun);
if (EFI_ERROR (Status)) {
goto Failed;
}
@@ -781,7 +787,7 @@ VirtioScsiInit (
Dev->MaxLun = PcdGet32 (PcdVirtioScsiMaxLunLimit);
}
- Status = VIRTIO_CFG_READ (Dev, VhdrMaxSectors, &Dev->MaxSectors);
+ Status = VIRTIO_CFG_READ (Dev, MaxSectors, &Dev->MaxSectors);
if (EFI_ERROR (Status)) {
goto Failed;
}
@@ -797,12 +803,11 @@ VirtioScsiInit (
//
// step 4b -- allocate request virtqueue
//
- Status = VIRTIO_CFG_WRITE (Dev, Generic.VhdrQueueSelect,
- VIRTIO_SCSI_REQUEST_QUEUE);
+ Status = Dev->VirtIo->SetQueueSel (Dev->VirtIo, VIRTIO_SCSI_REQUEST_QUEUE);
if (EFI_ERROR (Status)) {
goto Failed;
}
- Status = VIRTIO_CFG_READ (Dev, Generic.VhdrQueueSize, &QueueSize);
+ Status = Dev->VirtIo->GetQueueNumMax (Dev->VirtIo, &QueueSize);
if (EFI_ERROR (Status)) {
goto Failed;
}
@@ -823,8 +828,8 @@ VirtioScsiInit (
// step 4c -- Report GPFN (guest-physical frame number) of queue. If anything
// fails from here on, we must release the ring resources.
//
- Status = VIRTIO_CFG_WRITE (Dev, Generic.VhdrQueueAddress,
- (UINTN) Dev->Ring.Base >> EFI_PAGE_SHIFT);
+ Status = Dev->VirtIo->SetQueueAddress (Dev->VirtIo,
+ (UINTN) Dev->Ring.Base >> EFI_PAGE_SHIFT);
if (EFI_ERROR (Status)) {
goto ReleaseQueue;
}
@@ -834,8 +839,8 @@ VirtioScsiInit (
// the known (or unknown) VIRTIO_SCSI_F_* or VIRTIO_F_* capabilities (see
// virtio-0.9.5, Appendices B and I), except bidirectional transfers.
//
- Status = VIRTIO_CFG_WRITE (Dev, Generic.VhdrGuestFeatureBits,
- Features & VIRTIO_SCSI_F_INOUT);
+ Status = Dev->VirtIo->SetGuestFeatures (Dev->VirtIo,
+ Features & VIRTIO_SCSI_F_INOUT);
if (EFI_ERROR (Status)) {
goto ReleaseQueue;
}
@@ -844,11 +849,11 @@ VirtioScsiInit (
// We expect these maximum sizes from the host. Since they are
// guest-negotiable, ask for them rather than just checking them.
//
- Status = VIRTIO_CFG_WRITE (Dev, VhdrCdbSize, VIRTIO_SCSI_CDB_SIZE);
+ Status = VIRTIO_CFG_WRITE (Dev, CdbSize, VIRTIO_SCSI_CDB_SIZE);
if (EFI_ERROR (Status)) {
goto ReleaseQueue;
}
- Status = VIRTIO_CFG_WRITE (Dev, VhdrSenseSize, VIRTIO_SCSI_SENSE_SIZE);
+ Status = VIRTIO_CFG_WRITE (Dev, SenseSize, VIRTIO_SCSI_SENSE_SIZE);
if (EFI_ERROR (Status)) {
goto ReleaseQueue;
}
@@ -857,7 +862,7 @@ VirtioScsiInit (
// step 6 -- initialization complete
//
NextDevStat |= VSTAT_DRIVER_OK;
- Status = VIRTIO_CFG_WRITE (Dev, Generic.VhdrDeviceStatus, NextDevStat);
+ Status = Dev->VirtIo->SetDeviceStatus (Dev->VirtIo, NextDevStat);
if (EFI_ERROR (Status)) {
goto ReleaseQueue;
}
@@ -901,10 +906,10 @@ ReleaseQueue:
Failed:
//
// Notify the host about our failure to setup: virtio-0.9.5, 2.2.2.1 Device
- // Status. PCI IO access failure here should not mask the original error.
+ // Status. VirtIo access failure here should not mask the original error.
//
NextDevStat |= VSTAT_FAILED;
- VIRTIO_CFG_WRITE (Dev, Generic.VhdrDeviceStatus, NextDevStat);
+ Dev->VirtIo->SetDeviceStatus (Dev->VirtIo, NextDevStat);
Dev->InOutSupported = FALSE;
Dev->MaxTarget = 0;
@@ -928,7 +933,7 @@ VirtioScsiUninit (
// VIRTIO_CFG_WRITE() returns, the host will have learned to stay away from
// the old comms area.
//
- VIRTIO_CFG_WRITE (Dev, Generic.VhdrDeviceStatus, 0);
+ Dev->VirtIo->SetDeviceStatus (Dev->VirtIo, 0);
Dev->InOutSupported = FALSE;
Dev->MaxTarget = 0;
@@ -953,11 +958,8 @@ VirtioScsiUninit (
// The implementation follows:
// - Driver Writer's Guide for UEFI 2.3.1 v1.01
// - 5.1.3.4 OpenProtocol() and CloseProtocol()
-// - 18 PCI Driver Design Guidelines
-// - 18.3 PCI drivers
// - UEFI Spec 2.3.1 + Errata C
// - 6.3 Protocol Handler Services
-// - 13.4 EFI PCI I/O Protocol
//
EFI_STATUS
@@ -968,57 +970,37 @@ VirtioScsiDriverBindingSupported (
IN EFI_DEVICE_PATH_PROTOCOL *RemainingDevicePath
)
{
- EFI_STATUS Status;
- EFI_PCI_IO_PROTOCOL *PciIo;
- PCI_TYPE00 Pci;
+ EFI_STATUS Status;
+ VIRTIO_DEVICE_PROTOCOL *VirtIo;
//
- // Attempt to open the device with the PciIo set of interfaces. On success,
- // the protocol is "instantiated" for the PCI device. Covers duplicate open
+ // Attempt to open the device with the VirtIo set of interfaces. On success,
+ // the protocol is "instantiated" for the VirtIo device. Covers duplicate open
// attempts (EFI_ALREADY_STARTED).
//
Status = gBS->OpenProtocol (
DeviceHandle, // candidate device
- &gEfiPciIoProtocolGuid, // for generic PCI access
- (VOID **)&PciIo, // handle to instantiate
+ &gVirtioDeviceProtocolGuid, // for generic VirtIo access
+ (VOID **)&VirtIo, // handle to instantiate
This->DriverBindingHandle, // requestor driver identity
DeviceHandle, // ControllerHandle, according to
// the UEFI Driver Model
- EFI_OPEN_PROTOCOL_BY_DRIVER // get exclusive PciIo access to
+ EFI_OPEN_PROTOCOL_BY_DRIVER // get exclusive VirtIo access to
// the device; to be released
);
if (EFI_ERROR (Status)) {
return Status;
}
- //
- // Read entire PCI configuration header for more extensive check ahead.
- //
- Status = PciIo->Pci.Read (
- PciIo, // (protocol, device)
- // handle
- EfiPciIoWidthUint32, // access width & copy
- // mode
- 0, // Offset
- sizeof Pci / sizeof (UINT32), // Count
- &Pci // target buffer
- );
-
- if (Status == EFI_SUCCESS) {
- //
- // virtio-0.9.5, 2.1 PCI Discovery
- //
- Status = (Pci.Hdr.VendorId == 0x1AF4 &&
- Pci.Hdr.DeviceId >= 0x1000 && Pci.Hdr.DeviceId <= 0x103F &&
- Pci.Hdr.RevisionID == 0x00 &&
- Pci.Device.SubsystemID == 0x08) ? EFI_SUCCESS : EFI_UNSUPPORTED;
+ if (VirtIo->SubSystemDeviceId != VIRTIO_SUBSYSTEM_SCSI_HOST) {
+ Status = EFI_UNSUPPORTED;
}
//
- // We needed PCI IO access only transitorily, to see whether we support the
+ // We needed VirtIo access only transitorily, to see whether we support the
// device or not.
//
- gBS->CloseProtocol (DeviceHandle, &gEfiPciIoProtocolGuid,
+ gBS->CloseProtocol (DeviceHandle, &gVirtioDeviceProtocolGuid,
This->DriverBindingHandle, DeviceHandle);
return Status;
}
@@ -1040,43 +1022,19 @@ VirtioScsiDriverBindingStart (
return EFI_OUT_OF_RESOURCES;
}
- Status = gBS->OpenProtocol (DeviceHandle, &gEfiPciIoProtocolGuid,
- (VOID **)&Dev->PciIo, This->DriverBindingHandle,
+ Status = gBS->OpenProtocol (DeviceHandle, &gVirtioDeviceProtocolGuid,
+ (VOID **)&Dev->VirtIo, This->DriverBindingHandle,
DeviceHandle, EFI_OPEN_PROTOCOL_BY_DRIVER);
if (EFI_ERROR (Status)) {
goto FreeVirtioScsi;
}
//
- // We must retain and ultimately restore the original PCI attributes of the
- // device. See Driver Writer's Guide for UEFI 2.3.1 v1.01, 18.3 PCI drivers /
- // 18.3.2 Start() and Stop().
- //
- // The third parameter ("Attributes", input) is ignored by the Get operation.
- // The fourth parameter ("Result", output) is ignored by the Enable and Set
- // operations.
- //
- // For virtio-scsi we only need IO space access.
- //
- Status = Dev->PciIo->Attributes (Dev->PciIo, EfiPciIoAttributeOperationGet,
- 0, &Dev->OriginalPciAttributes);
- if (EFI_ERROR (Status)) {
- goto ClosePciIo;
- }
-
- Status = Dev->PciIo->Attributes (Dev->PciIo,
- EfiPciIoAttributeOperationEnable,
- EFI_PCI_IO_ATTRIBUTE_IO, NULL);
- if (EFI_ERROR (Status)) {
- goto ClosePciIo;
- }
-
- //
- // PCI IO access granted, configure virtio-scsi device.
+ // VirtIo access granted, configure virtio-scsi device.
//
Status = VirtioScsiInit (Dev);
if (EFI_ERROR (Status)) {
- goto RestorePciAttributes;
+ goto CloseVirtIo;
}
//
@@ -1096,12 +1054,8 @@ VirtioScsiDriverBindingStart (
UninitDev:
VirtioScsiUninit (Dev);
-RestorePciAttributes:
- Dev->PciIo->Attributes (Dev->PciIo, EfiPciIoAttributeOperationSet,
- Dev->OriginalPciAttributes, NULL);
-
-ClosePciIo:
- gBS->CloseProtocol (DeviceHandle, &gEfiPciIoProtocolGuid,
+CloseVirtIo:
+ gBS->CloseProtocol (DeviceHandle, &gVirtioDeviceProtocolGuid,
This->DriverBindingHandle, DeviceHandle);
FreeVirtioScsi:
@@ -1149,10 +1103,7 @@ VirtioScsiDriverBindingStop (
VirtioScsiUninit (Dev);
- Dev->PciIo->Attributes (Dev->PciIo, EfiPciIoAttributeOperationSet,
- Dev->OriginalPciAttributes, NULL);
-
- gBS->CloseProtocol (DeviceHandle, &gEfiPciIoProtocolGuid,
+ gBS->CloseProtocol (DeviceHandle, &gVirtioDeviceProtocolGuid,
This->DriverBindingHandle, DeviceHandle);
FreePool (Dev);
diff --git a/OvmfPkg/VirtioScsiDxe/VirtioScsi.h b/OvmfPkg/VirtioScsiDxe/VirtioScsi.h
index f5220b221..42d8ed765 100644
--- a/OvmfPkg/VirtioScsiDxe/VirtioScsi.h
+++ b/OvmfPkg/VirtioScsiDxe/VirtioScsi.h
@@ -20,7 +20,6 @@
#include <Protocol/ComponentName.h>
#include <Protocol/DriverBinding.h>
-#include <Protocol/PciIo.h>
#include <Protocol/ScsiPassThruExt.h>
#include <IndustryStandard/Virtio.h>
@@ -49,18 +48,17 @@ typedef struct {
// at various call depths. The table to the right should make it easier to
// track them.
//
- // field init function init depth
- // ---------------------- ------------------ ----------
- UINT32 Signature; // DriverBindingStart 0
- EFI_PCI_IO_PROTOCOL *PciIo; // DriverBindingStart 0
- UINT64 OriginalPciAttributes; // DriverBindingStart 0
- BOOLEAN InOutSupported; // VirtioScsiInit 1
- UINT16 MaxTarget; // VirtioScsiInit 1
- UINT32 MaxLun; // VirtioScsiInit 1
- UINT32 MaxSectors; // VirtioScsiInit 1
- VRING Ring; // VirtioRingInit 2
- EFI_EXT_SCSI_PASS_THRU_PROTOCOL PassThru; // VirtioScsiInit 1
- EFI_EXT_SCSI_PASS_THRU_MODE PassThruMode; // VirtioScsiInit 1
+ // field init function init depth
+ // ---------------- ------------------ ----------
+ UINT32 Signature; // DriverBindingStart 0
+ VIRTIO_DEVICE_PROTOCOL *VirtIo; // DriverBindingStart 0
+ BOOLEAN InOutSupported; // VirtioScsiInit 1
+ UINT16 MaxTarget; // VirtioScsiInit 1
+ UINT32 MaxLun; // VirtioScsiInit 1
+ UINT32 MaxSectors; // VirtioScsiInit 1
+ VRING Ring; // VirtioRingInit 2
+ EFI_EXT_SCSI_PASS_THRU_PROTOCOL PassThru; // VirtioScsiInit 1
+ EFI_EXT_SCSI_PASS_THRU_MODE PassThruMode; // VirtioScsiInit 1
} VSCSI_DEV;
#define VIRTIO_SCSI_FROM_PASS_THRU(PassThruPointer) \
diff --git a/OvmfPkg/VirtioScsiDxe/VirtioScsi.inf b/OvmfPkg/VirtioScsiDxe/VirtioScsi.inf
index 8209c5027..e98780db8 100644
--- a/OvmfPkg/VirtioScsiDxe/VirtioScsi.inf
+++ b/OvmfPkg/VirtioScsiDxe/VirtioScsi.inf
@@ -40,7 +40,7 @@
[Protocols]
gEfiExtScsiPassThruProtocolGuid ## BY_START
- gEfiPciIoProtocolGuid ## TO_START
+ gVirtioDeviceProtocolGuid ## TO_START
[Pcd]
gUefiOvmfPkgTokenSpaceGuid.PcdVirtioScsiMaxTargetLimit ## CONSUMES
diff --git a/PerformancePkg/Dp_App/DpUtilities.c b/PerformancePkg/Dp_App/DpUtilities.c
index 4daca0b85..65efb80c8 100644
--- a/PerformancePkg/Dp_App/DpUtilities.c
+++ b/PerformancePkg/Dp_App/DpUtilities.c
@@ -218,8 +218,12 @@ GetNameFromHandle (
CHAR16 *NameString;
UINTN StringSize;
CHAR8 *PlatformLanguage;
+ CHAR8 *BestLanguage;
EFI_COMPONENT_NAME2_PROTOCOL *ComponentName2;
+ BestLanguage = NULL;
+ PlatformLanguage = NULL;
+
//
// Method 1: Get the name string from image PDB
//
@@ -269,13 +273,23 @@ GetNameFromHandle (
// Get the current platform language setting
//
GetEfiGlobalVariable2 (L"PlatformLang", (VOID**)&PlatformLanguage, NULL);
+
+ BestLanguage = GetBestLanguage(
+ ComponentName2->SupportedLanguages,
+ FALSE,
+ PlatformLanguage,
+ ComponentName2->SupportedLanguages,
+ NULL
+ );
+
+ SafeFreePool (PlatformLanguage);
Status = ComponentName2->GetDriverName (
ComponentName2,
- PlatformLanguage != NULL ? PlatformLanguage : "en-US",
+ BestLanguage,
&StringPtr
);
+ SafeFreePool (BestLanguage);
if (!EFI_ERROR (Status)) {
- SafeFreePool (PlatformLanguage);
StrnCpy (mGaugeString, StringPtr, DP_GAUGE_STRING_LENGTH);
mGaugeString[DP_GAUGE_STRING_LENGTH] = 0;
return;
diff --git a/SecurityPkg/Include/Guid/AuthenticatedVariableFormat.h b/SecurityPkg/Include/Guid/AuthenticatedVariableFormat.h
index 6ffd9f17e..66947e176 100644
--- a/SecurityPkg/Include/Guid/AuthenticatedVariableFormat.h
+++ b/SecurityPkg/Include/Guid/AuthenticatedVariableFormat.h
@@ -4,7 +4,7 @@
AuthenticatedVariableFormat.h defines variable data headers
and variable storage region headers.
-Copyright (c) 2009 - 2012, Intel Corporation. All rights reserved.<BR>
+Copyright (c) 2009 - 2013, 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,6 +29,7 @@ extern EFI_GUID gEfiAuthenticatedVariableGuid;
extern EFI_GUID gEfiSecureBootEnableDisableGuid;
extern EFI_GUID gEfiCertDbGuid;
extern EFI_GUID gEfiCustomModeEnableGuid;
+extern EFI_GUID gEfiVendorKeysNvGuid;
///
/// "SecureBootEnable" variable for the Secure Boot feature enable/disable.
@@ -52,6 +53,16 @@ extern EFI_GUID gEfiCustomModeEnableGuid;
#define STANDARD_SECURE_BOOT_MODE 0
///
+/// "VendorKeysNv" variable to record the out of band secure boot keys modification.
+/// This variable is a read-only NV varaible that indicates whether someone other than
+/// the platform vendor has used a mechanism not defined by the UEFI Specification to
+/// transition the system to setup mode or to update secure boot keys.
+///
+#define EFI_VENDOR_KEYS_NV_VARIABLE_NAME L"VendorKeysNv"
+#define VENDOR_KEYS_VALID 1
+#define VENDOR_KEYS_MODIFIED 0
+
+///
/// Alignment of variable name and data, according to the architecture:
/// * For IA-32 and Intel(R) 64 architectures: 1.
/// * For IA-64 architecture: 8.
diff --git a/SecurityPkg/Include/Guid/TpmInstance.h b/SecurityPkg/Include/Guid/TpmInstance.h
new file mode 100644
index 000000000..27c727baf
--- /dev/null
+++ b/SecurityPkg/Include/Guid/TpmInstance.h
@@ -0,0 +1,38 @@
+/** @file
+ TPM instance guid, used for PcdTpmInstanceGuid.
+
+Copyright (c) 2013, 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.
+
+**/
+
+#ifndef __TPM_INSTANCE_GUID_H__
+#define __TPM_INSTANCE_GUID_H__
+
+#define TPM_DEVICE_INTERFACE_NONE \
+ { 0x00000000, 0x0000, 0x0000, { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 } }
+
+#define TPM_DEVICE_INTERFACE_TPM12 \
+ { 0x8b01e5b6, 0x4f19, 0x46e8, { 0xab, 0x93, 0x1c, 0x53, 0x67, 0x1b, 0x90, 0xcc } }
+
+#define TPM_DEVICE_INTERFACE_TPM20_DTPM \
+ { 0x286bf25a, 0xc2c3, 0x408c, { 0xb3, 0xb4, 0x25, 0xe6, 0x75, 0x8b, 0x73, 0x17 } }
+
+extern EFI_GUID gEfiTpmDeviceInstanceNoneGuid;
+extern EFI_GUID gEfiTpmDeviceInstanceTpm12Guid;
+extern EFI_GUID gEfiTpmDeviceInstanceTpm20DtpmGuid;
+
+
+#define TPM_DEVICE_SELECTED_GUID \
+ { 0x7f4158d3, 0x74d, 0x456d, { 0x8c, 0xb2, 0x1, 0xf9, 0xc8, 0xf7, 0x9d, 0xaa } }
+
+extern EFI_GUID gEfiTpmDeviceSelectedGuid;
+
+#endif
+
diff --git a/SecurityPkg/Include/Guid/TrEEConfigHii.h b/SecurityPkg/Include/Guid/TrEEConfigHii.h
new file mode 100644
index 000000000..b5d1de746
--- /dev/null
+++ b/SecurityPkg/Include/Guid/TrEEConfigHii.h
@@ -0,0 +1,25 @@
+/** @file
+ GUIDs used as HII FormSet and HII Package list GUID in TrEEConfig driver.
+
+Copyright (c) 2013, 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 that 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.
+
+**/
+
+#ifndef __TREE_CONFIG_HII_GUID_H__
+#define __TREE_CONFIG_HII_GUID_H__
+
+#define TREE_CONFIG_FORM_SET_GUID \
+ { \
+ 0xc54b425f, 0xaa79, 0x48b4, { 0x98, 0x1f, 0x99, 0x8b, 0x3c, 0x4b, 0x64, 0x1c } \
+ }
+
+extern EFI_GUID gTrEEConfigFormSetGuid;
+
+#endif
diff --git a/SecurityPkg/Include/Guid/TrEEPhysicalPresenceData.h b/SecurityPkg/Include/Guid/TrEEPhysicalPresenceData.h
new file mode 100644
index 000000000..65750cd7c
--- /dev/null
+++ b/SecurityPkg/Include/Guid/TrEEPhysicalPresenceData.h
@@ -0,0 +1,62 @@
+/** @file
+ Define the variable data structures used for TrEE physical presence.
+ The TPM2 request from firmware or OS is saved to variable. And it is
+ cleared after it is processed in the next boot cycle. The TPM2 response
+ is saved to variable.
+
+Copyright (c) 2013, 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.
+
+**/
+
+#ifndef __TREE_PHYSICAL_PRESENCE_DATA_GUID_H__
+#define __TREE_PHYSICAL_PRESENCE_DATA_GUID_H__
+
+#define EFI_TREE_PHYSICAL_PRESENCE_DATA_GUID \
+ { \
+ 0xf24643c2, 0xc622, 0x494e, { 0x8a, 0xd, 0x46, 0x32, 0x57, 0x9c, 0x2d, 0x5b }\
+ }
+
+#define TREE_PHYSICAL_PRESENCE_VARIABLE L"TrEEPhysicalPresence"
+
+typedef struct {
+ UINT8 PPRequest; ///< Physical Presence request command.
+ UINT8 LastPPRequest;
+ UINT32 PPResponse;
+} EFI_TREE_PHYSICAL_PRESENCE;
+
+//
+// The definition bit of the flags
+//
+#define TREE_FLAG_NO_PPI_CLEAR BIT1
+#define TREE_FLAG_RESET_TRACK BIT3
+
+//
+// This variable is used to save TPM Management Flags and corresponding operations.
+// It should be protected from malicious software (e.g. Set it as read-only variable).
+//
+#define TREE_PHYSICAL_PRESENCE_FLAGS_VARIABLE L"TrEEPhysicalPresenceFlags"
+
+//
+// The definition of physical presence operation actions
+//
+#define TREE_PHYSICAL_PRESENCE_NO_ACTION 0
+#define TREE_PHYSICAL_PRESENCE_CLEAR_CONTROL_CLEAR 5
+#define TREE_PHYSICAL_PRESENCE_CLEAR_CONTROL_CLEAR_2 14
+#define TREE_PHYSICAL_PRESENCE_SET_NO_PPI_CLEAR_FALSE 17
+#define TREE_PHYSICAL_PRESENCE_SET_NO_PPI_CLEAR_TRUE 18
+#define TREE_PHYSICAL_PRESENCE_CLEAR_CONTROL_CLEAR_3 21
+#define TREE_PHYSICAL_PRESENCE_CLEAR_CONTROL_CLEAR_4 22
+
+#define TREE_PHYSICAL_PRESENCE_NO_ACTION_MAX 22
+
+extern EFI_GUID gEfiTrEEPhysicalPresenceGuid;
+
+#endif
+
diff --git a/SecurityPkg/Include/Library/HashLib.h b/SecurityPkg/Include/Library/HashLib.h
new file mode 100644
index 000000000..b85756961
--- /dev/null
+++ b/SecurityPkg/Include/Library/HashLib.h
@@ -0,0 +1,169 @@
+/** @file
+ Ihis library abstract TPM2 hash calculation.
+ The platform can choose multiply hash, while caller just need invoke these API.
+ Then all hash value will be returned and/or extended.
+
+Copyright (c) 2013, 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.
+
+**/
+
+#ifndef _HASH_LIB_H_
+#define _HASH_LIB_H_
+
+#include <Uefi.h>
+#include <Protocol/Hash.h>
+
+typedef UINTN HASH_HANDLE;
+
+/**
+ Start hash sequence.
+
+ @param HashHandle Hash handle.
+
+ @retval EFI_SUCCESS Hash sequence start and HandleHandle returned.
+ @retval EFI_OUT_OF_RESOURCES No enough resource to start hash.
+**/
+EFI_STATUS
+EFIAPI
+HashStart (
+ OUT HASH_HANDLE *HashHandle
+ );
+
+/**
+ Update hash sequence data.
+
+ @param HashHandle Hash handle.
+ @param DataToHash Data to be hashed.
+ @param DataToHashLen Data size.
+
+ @retval EFI_SUCCESS Hash sequence updated.
+**/
+EFI_STATUS
+EFIAPI
+HashUpdate (
+ IN HASH_HANDLE HashHandle,
+ IN VOID *DataToHash,
+ IN UINTN DataToHashLen
+ );
+
+/**
+ Hash sequence complete and extend to PCR.
+
+ @param HashHandle Hash handle.
+ @param PcrIndex PCR to be extended.
+ @param DataToHash Data to be hashed.
+ @param DataToHashLen Data size.
+ @param DigestList Digest list.
+
+ @retval EFI_SUCCESS Hash sequence complete and DigestList is returned.
+**/
+EFI_STATUS
+EFIAPI
+HashCompleteAndExtend (
+ IN HASH_HANDLE HashHandle,
+ IN TPMI_DH_PCR PcrIndex,
+ IN VOID *DataToHash,
+ IN UINTN DataToHashLen,
+ OUT TPML_DIGEST_VALUES *DigestList
+ );
+
+/**
+ Hash data and extend to PCR.
+
+ @param PcrIndex PCR to be extended.
+ @param DataToHash Data to be hashed.
+ @param DataToHashLen Data size.
+ @param DigestList Digest list.
+
+ @retval EFI_SUCCESS Hash data and DigestList is returned.
+**/
+EFI_STATUS
+EFIAPI
+HashAndExtend (
+ IN TPMI_DH_PCR PcrIndex,
+ IN VOID *DataToHash,
+ IN UINTN DataToHashLen,
+ OUT TPML_DIGEST_VALUES *DigestList
+ );
+
+/**
+ Start hash sequence.
+
+ @param HashHandle Hash handle.
+
+ @retval EFI_SUCCESS Hash sequence start and HandleHandle returned.
+ @retval EFI_OUT_OF_RESOURCES No enough resource to start hash.
+**/
+typedef
+EFI_STATUS
+(EFIAPI *HASH_INIT) (
+ OUT HASH_HANDLE *HashHandle
+ );
+
+/**
+ Update hash sequence data.
+
+ @param HashHandle Hash handle.
+ @param DataToHash Data to be hashed.
+ @param DataToHashLen Data size.
+
+ @retval EFI_SUCCESS Hash sequence updated.
+**/
+typedef
+EFI_STATUS
+(EFIAPI *HASH_UPDATE) (
+ IN HASH_HANDLE HashHandle,
+ IN VOID *DataToHash,
+ IN UINTN DataToHashLen
+ );
+
+/**
+ Complete hash sequence complete.
+
+ @param HashHandle Hash handle.
+ @param DigestList Digest list.
+
+ @retval EFI_SUCCESS Hash sequence complete and DigestList is returned.
+**/
+typedef
+EFI_STATUS
+(EFIAPI *HASH_FINAL) (
+ IN HASH_HANDLE HashHandle,
+ OUT TPML_DIGEST_VALUES *DigestList
+ );
+
+#define HASH_ALGORITHM_SHA1_GUID EFI_HASH_ALGORITHM_SHA1_GUID
+#define HASH_ALGORITHM_SHA256_GUID EFI_HASH_ALGORITHM_SHA256_GUID
+#define HASH_ALGORITHM_SHA384_GUID EFI_HASH_ALGORITHM_SHA384_GUID
+#define HASH_ALGORITHM_SHA512_GUID EFI_HASH_ALGORITHM_SHA512_GUID
+
+typedef struct {
+ EFI_GUID HashGuid;
+ HASH_INIT HashInit;
+ HASH_UPDATE HashUpdate;
+ HASH_FINAL HashFinal;
+} HASH_INTERFACE;
+
+/**
+ This service register Hash.
+
+ @param HashInterface Hash interface
+
+ @retval EFI_SUCCESS This hash interface is registered successfully.
+ @retval EFI_UNSUPPORTED System does not support register this interface.
+ @retval EFI_ALREADY_STARTED System already register this interface.
+**/
+EFI_STATUS
+EFIAPI
+RegisterHashInterfaceLib (
+ IN HASH_INTERFACE *HashInterface
+ );
+
+#endif
diff --git a/SecurityPkg/Include/Library/Tpm12CommandLib.h b/SecurityPkg/Include/Library/Tpm12CommandLib.h
new file mode 100644
index 000000000..1dbc7d50c
--- /dev/null
+++ b/SecurityPkg/Include/Library/Tpm12CommandLib.h
@@ -0,0 +1,58 @@
+/** @file
+ This library is used by other modules to send TPM12 command.
+
+Copyright (c) 2013, 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.
+
+**/
+
+#ifndef _TPM12_COMMAND_LIB_H_
+#define _TPM12_COMMAND_LIB_H_
+
+#include <IndustryStandard/Tpm12.h>
+
+/**
+ Send Startup command to TPM1.2.
+
+ @param TpmSt Startup Type.
+
+ @retval EFI_SUCCESS Operation completed successfully.
+ @retval EFI_DEVICE_ERROR Unexpected device behavior.
+**/
+EFI_STATUS
+EFIAPI
+Tpm12Startup (
+ IN TPM_STARTUP_TYPE TpmSt
+ );
+
+/**
+ Send SaveState command to TPM1.2.
+
+ @retval EFI_SUCCESS Operation completed successfully.
+ @retval EFI_DEVICE_ERROR Unexpected device behavior.
+**/
+EFI_STATUS
+EFIAPI
+Tpm12SaveState (
+ VOID
+ );
+
+/**
+ Send ForceClear command to TPM1.2.
+
+ @retval EFI_SUCCESS Operation completed successfully.
+ @retval EFI_DEVICE_ERROR Unexpected device behavior.
+**/
+EFI_STATUS
+EFIAPI
+Tpm12ForceClear (
+ VOID
+ );
+
+#endif
diff --git a/SecurityPkg/Include/Library/Tpm12DeviceLib.h b/SecurityPkg/Include/Library/Tpm12DeviceLib.h
new file mode 100644
index 000000000..ab1f522ad
--- /dev/null
+++ b/SecurityPkg/Include/Library/Tpm12DeviceLib.h
@@ -0,0 +1,54 @@
+/** @file
+ This library abstract how to access TPM12 hardware device.
+
+Copyright (c) 2013, 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.
+
+**/
+
+#ifndef _TPM12_DEVICE_LIB_H_
+#define _TPM12_DEVICE_LIB_H_
+
+#include <IndustryStandard/Tpm12.h>
+
+/**
+ This service enables the sending of commands to the TPM12.
+
+ @param[in] InputParameterBlockSize Size of the TPM12 input parameter block.
+ @param[in] InputParameterBlock Pointer to the TPM12 input parameter block.
+ @param[in,out] OutputParameterBlockSize Size of the TPM12 output parameter block.
+ @param[in] OutputParameterBlock Pointer to the TPM12 output parameter block.
+
+ @retval EFI_SUCCESS The command byte stream was successfully sent to the device and a response was successfully received.
+ @retval EFI_DEVICE_ERROR The command was not successfully sent to the device or a response was not successfully received from the device.
+ @retval EFI_BUFFER_TOO_SMALL The output parameter block is too small.
+**/
+EFI_STATUS
+EFIAPI
+Tpm12SubmitCommand (
+ IN UINT32 InputParameterBlockSize,
+ IN UINT8 *InputParameterBlock,
+ IN OUT UINT32 *OutputParameterBlockSize,
+ IN UINT8 *OutputParameterBlock
+ );
+
+/**
+ This service requests use TPM12.
+
+ @retval EFI_SUCCESS Get the control of TPM12 chip.
+ @retval EFI_NOT_FOUND TPM12 not found.
+ @retval EFI_DEVICE_ERROR Unexpected device behavior.
+**/
+EFI_STATUS
+EFIAPI
+Tpm12RequestUseTpm (
+ VOID
+ );
+
+#endif
diff --git a/SecurityPkg/Include/Library/Tpm2CommandLib.h b/SecurityPkg/Include/Library/Tpm2CommandLib.h
new file mode 100644
index 000000000..5ec3ead05
--- /dev/null
+++ b/SecurityPkg/Include/Library/Tpm2CommandLib.h
@@ -0,0 +1,824 @@
+/** @file
+ This library is used by other modules to send TPM2 command.
+
+Copyright (c) 2013, 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.
+
+**/
+
+#ifndef _TPM2_COMMAND_LIB_H_
+#define _TPM2_COMMAND_LIB_H_
+
+#include <IndustryStandard/Tpm20.h>
+
+/**
+ This command starts a hash or an Event sequence.
+ If hashAlg is an implemented hash, then a hash sequence is started.
+ If hashAlg is TPM_ALG_NULL, then an Event sequence is started.
+
+ @param[in] HashAlg The hash algorithm to use for the hash sequence
+ An Event sequence starts if this is TPM_ALG_NULL.
+ @param[out] SequenceHandle A handle to reference the sequence
+
+ @retval EFI_SUCCESS Operation completed successfully.
+ @retval EFI_DEVICE_ERROR Unexpected device behavior.
+**/
+EFI_STATUS
+EFIAPI
+Tpm2HashSequenceStart (
+ IN TPMI_ALG_HASH HashAlg,
+ OUT TPMI_DH_OBJECT *SequenceHandle
+ );
+
+/**
+ This command is used to add data to a hash or HMAC sequence.
+ The amount of data in buffer may be any size up to the limits of the TPM.
+ NOTE: In all TPM, a buffer size of 1,024 octets is allowed.
+
+ @param[in] SequenceHandle Handle for the sequence object
+ @param[in] Buffer Data to be added to hash
+
+ @retval EFI_SUCCESS Operation completed successfully.
+ @retval EFI_DEVICE_ERROR Unexpected device behavior.
+**/
+EFI_STATUS
+EFIAPI
+Tpm2SequenceUpdate (
+ IN TPMI_DH_OBJECT SequenceHandle,
+ IN TPM2B_MAX_BUFFER *Buffer
+ );
+
+/**
+ This command adds the last part of data, if any, to an Event sequence and returns the result in a digest list.
+ If pcrHandle references a PCR and not TPM_RH_NULL, then the returned digest list is processed in
+ the same manner as the digest list input parameter to TPM2_PCR_Extend() with the pcrHandle in each
+ bank extended with the associated digest value.
+
+ @param[in] PcrHandle PCR to be extended with the Event data
+ @param[in] SequenceHandle Authorization for the sequence
+ @param[in] Buffer Data to be added to the Event
+ @param[out] Results List of digests computed for the PCR
+
+ @retval EFI_SUCCESS Operation completed successfully.
+ @retval EFI_DEVICE_ERROR Unexpected device behavior.
+**/
+EFI_STATUS
+EFIAPI
+Tpm2EventSequenceComplete (
+ IN TPMI_DH_PCR PcrHandle,
+ IN TPMI_DH_OBJECT SequenceHandle,
+ IN TPM2B_MAX_BUFFER *Buffer,
+ OUT TPML_DIGEST_VALUES *Results
+ );
+
+/**
+ This command adds the last part of data, if any, to a hash/HMAC sequence and returns the result.
+
+ @param[in] SequenceHandle Authorization for the sequence
+ @param[in] Buffer Data to be added to the hash/HMAC
+ @param[out] Result The returned HMAC or digest in a sized buffer
+
+ @retval EFI_SUCCESS Operation completed successfully.
+ @retval EFI_DEVICE_ERROR Unexpected device behavior.
+**/
+EFI_STATUS
+EFIAPI
+Tpm2SequenceComplete (
+ IN TPMI_DH_OBJECT SequenceHandle,
+ IN TPM2B_MAX_BUFFER *Buffer,
+ OUT TPM2B_DIGEST *Result
+ );
+
+/**
+ Send Startup command to TPM2.
+
+ @param[in] StartupType TPM_SU_CLEAR or TPM_SU_STATE
+
+ @retval EFI_SUCCESS Operation completed successfully.
+ @retval EFI_DEVICE_ERROR Unexpected device behavior.
+**/
+EFI_STATUS
+EFIAPI
+Tpm2Startup (
+ IN TPM_SU StartupType
+ );
+
+/**
+ Send Shutdown command to TPM2.
+
+ @param[in] ShutdownType TPM_SU_CLEAR or TPM_SU_STATE.
+
+ @retval EFI_SUCCESS Operation completed successfully.
+ @retval EFI_DEVICE_ERROR Unexpected device behavior.
+**/
+EFI_STATUS
+EFIAPI
+Tpm2Shutdown (
+ IN TPM_SU ShutdownType
+ );
+
+/**
+ This command causes the TPM to perform a test of its capabilities.
+ If the fullTest is YES, the TPM will test all functions.
+ If fullTest = NO, the TPM will only test those functions that have not previously been tested.
+
+ @param[in] FullTest YES if full test to be performed
+ NO if only test of untested functions required
+
+ @retval EFI_SUCCESS Operation completed successfully.
+ @retval EFI_DEVICE_ERROR Unexpected device behavior.
+**/
+EFI_STATUS
+EFIAPI
+Tpm2SelfTest (
+ IN TPMI_YES_NO FullTest
+ );
+
+/**
+ This command removes all TPM context associated with a specific Owner.
+
+ @param[in] AuthHandle TPM_RH_LOCKOUT or TPM_RH_PLATFORM+{PP}
+ @param[in] AuthSession Auth Session context
+
+ @retval EFI_SUCCESS Operation completed successfully.
+ @retval EFI_DEVICE_ERROR Unexpected device behavior.
+**/
+EFI_STATUS
+EFIAPI
+Tpm2Clear (
+ IN TPMI_RH_CLEAR AuthHandle,
+ IN TPMS_AUTH_COMMAND *AuthSession OPTIONAL
+ );
+
+/**
+ Disables and enables the execution of TPM2_Clear().
+
+ @param[in] AuthHandle TPM_RH_LOCKOUT or TPM_RH_PLATFORM+{PP}
+ @param[in] AuthSession Auth Session context
+ @param[in] Disable YES if the disableOwnerClear flag is to be SET,
+ NO if the flag is to be CLEAR.
+
+ @retval EFI_SUCCESS Operation completed successfully.
+ @retval EFI_DEVICE_ERROR Unexpected device behavior.
+**/
+EFI_STATUS
+EFIAPI
+Tpm2ClearControl (
+ IN TPMI_RH_CLEAR AuthHandle,
+ IN TPMS_AUTH_COMMAND *AuthSession, OPTIONAL
+ IN TPMI_YES_NO Disable
+ );
+
+/**
+ This command allows the authorization secret for a hierarchy or lockout to be changed using the current
+ authorization value as the command authorization.
+
+ @param[in] AuthHandle TPM_RH_LOCKOUT, TPM_RH_ENDORSEMENT, TPM_RH_OWNER or TPM_RH_PLATFORM+{PP}
+ @param[in] AuthSession Auth Session context
+ @param[in] NewAuth New authorization secret
+
+ @retval EFI_SUCCESS Operation completed successfully.
+ @retval EFI_DEVICE_ERROR Unexpected device behavior.
+**/
+EFI_STATUS
+EFIAPI
+Tpm2HierarchyChangeAuth (
+ IN TPMI_RH_HIERARCHY_AUTH AuthHandle,
+ IN TPMS_AUTH_COMMAND *AuthSession,
+ IN TPM2B_AUTH *NewAuth
+ );
+
+/**
+ This replaces the current EPS with a value from the RNG and sets the Endorsement hierarchy controls to
+ their default initialization values.
+
+ @param[in] AuthHandle TPM_RH_PLATFORM+{PP}
+ @param[in] AuthSession Auth Session context
+
+ @retval EFI_SUCCESS Operation completed successfully.
+ @retval EFI_DEVICE_ERROR Unexpected device behavior.
+**/
+EFI_STATUS
+EFIAPI
+Tpm2ChangeEPS (
+ IN TPMI_RH_PLATFORM AuthHandle,
+ IN TPMS_AUTH_COMMAND *AuthSession
+ );
+
+/**
+ This replaces the current PPS with a value from the RNG and sets platformPolicy to the default
+ initialization value (the Empty Buffer).
+
+ @param[in] AuthHandle TPM_RH_PLATFORM+{PP}
+ @param[in] AuthSession Auth Session context
+
+ @retval EFI_SUCCESS Operation completed successfully.
+ @retval EFI_DEVICE_ERROR Unexpected device behavior.
+**/
+EFI_STATUS
+EFIAPI
+Tpm2ChangePPS (
+ IN TPMI_RH_PLATFORM AuthHandle,
+ IN TPMS_AUTH_COMMAND *AuthSession
+ );
+
+/**
+ This command enables and disables use of a hierarchy.
+
+ @param[in] AuthHandle TPM_RH_ENDORSEMENT, TPM_RH_OWNER or TPM_RH_PLATFORM+{PP}
+ @param[in] AuthSession Auth Session context
+ @param[in] Hierarchy Hierarchy of the enable being modified
+ @param[in] State YES if the enable should be SET,
+ NO if the enable should be CLEAR
+
+ @retval EFI_SUCCESS Operation completed successfully.
+ @retval EFI_DEVICE_ERROR Unexpected device behavior.
+**/
+EFI_STATUS
+EFIAPI
+Tpm2HierarchyControl (
+ IN TPMI_RH_HIERARCHY AuthHandle,
+ IN TPMS_AUTH_COMMAND *AuthSession,
+ IN TPMI_RH_HIERARCHY Hierarchy,
+ IN TPMI_YES_NO State
+ );
+
+/**
+ This command cancels the effect of a TPM lockout due to a number of successive authorization failures.
+ If this command is properly authorized, the lockout counter is set to zero.
+
+ @param[in] LockHandle LockHandle
+ @param[in] AuthSession Auth Session context
+
+ @retval EFI_SUCCESS Operation completed successfully.
+ @retval EFI_DEVICE_ERROR Unexpected device behavior.
+**/
+EFI_STATUS
+EFIAPI
+Tpm2DictionaryAttackLockReset (
+ IN TPMI_RH_LOCKOUT LockHandle,
+ IN TPMS_AUTH_COMMAND *AuthSession
+ );
+
+/**
+ This command cancels the effect of a TPM lockout due to a number of successive authorization failures.
+ If this command is properly authorized, the lockout counter is set to zero.
+
+ @param[in] LockHandle LockHandle
+ @param[in] AuthSession Auth Session context
+ @param[in] NewMaxTries Count of authorization failures before the lockout is imposed
+ @param[in] NewRecoveryTime Time in seconds before the authorization failure count is automatically decremented
+ @param[in] LockoutRecovery Time in seconds after a lockoutAuth failure before use of lockoutAuth is allowed
+
+ @retval EFI_SUCCESS Operation completed successfully.
+ @retval EFI_DEVICE_ERROR Unexpected device behavior.
+**/
+EFI_STATUS
+EFIAPI
+Tpm2DictionaryAttackParameters (
+ IN TPMI_RH_LOCKOUT LockHandle,
+ IN TPMS_AUTH_COMMAND *AuthSession,
+ IN UINT32 NewMaxTries,
+ IN UINT32 NewRecoveryTime,
+ IN UINT32 LockoutRecovery
+ );
+
+/**
+ This command is used to read the public area and Name of an NV Index.
+
+ @param[in] NvIndex The NV Index.
+ @param[out] NvPublic The public area of the index.
+ @param[out] NvName The Name of the nvIndex.
+
+ @retval EFI_SUCCESS Operation completed successfully.
+ @retval EFI_DEVICE_ERROR The command was unsuccessful.
+**/
+EFI_STATUS
+EFIAPI
+Tpm2NvReadPublic (
+ IN TPMI_RH_NV_INDEX NvIndex,
+ OUT TPM2B_NV_PUBLIC *NvPublic,
+ OUT TPM2B_NAME *NvName
+ );
+
+/**
+ This command defines the attributes of an NV Index and causes the TPM to
+ reserve space to hold the data associated with the index.
+ If a definition already exists at the index, the TPM will return TPM_RC_NV_DEFINED.
+
+ @param[in] AuthHandle TPM_RH_OWNER or TPM_RH_PLATFORM+{PP}.
+ @param[in] AuthSession Auth Session context
+ @param[in] Auth The authorization data.
+ @param[in] NvPublic The public area of the index.
+
+ @retval EFI_SUCCESS Operation completed successfully.
+ @retval EFI_DEVICE_ERROR The command was unsuccessful.
+ @retval EFI_ALREADY_STARTED The command was returned successfully, but NvIndex is already defined.
+**/
+EFI_STATUS
+EFIAPI
+Tpm2NvDefineSpace (
+ IN TPMI_RH_PROVISION AuthHandle,
+ IN TPMS_AUTH_COMMAND *AuthSession, OPTIONAL
+ IN TPM2B_AUTH *Auth,
+ IN TPM2B_NV_PUBLIC *NvPublic
+ );
+
+/**
+ This command removes an index from the TPM.
+
+ @param[in] AuthHandle TPM_RH_OWNER or TPM_RH_PLATFORM+{PP}.
+ @param[in] NvIndex The NV Index.
+ @param[in] AuthSession Auth Session context
+
+ @retval EFI_SUCCESS Operation completed successfully.
+ @retval EFI_DEVICE_ERROR The command was unsuccessful.
+ @retval EFI_NOT_FOUND The command was returned successfully, but NvIndex is not found.
+**/
+EFI_STATUS
+EFIAPI
+Tpm2NvUndefineSpace (
+ IN TPMI_RH_PROVISION AuthHandle,
+ IN TPMI_RH_NV_INDEX NvIndex,
+ IN TPMS_AUTH_COMMAND *AuthSession OPTIONAL
+ );
+
+/**
+ This command reads a value from an area in NV memory previously defined by TPM2_NV_DefineSpace().
+
+ @param[in] AuthHandle the handle indicating the source of the authorization value.
+ @param[in] NvIndex The index to be read.
+ @param[in] AuthSession Auth Session context
+ @param[in] Size Number of bytes to read.
+ @param[in] Offset Byte offset into the area.
+ @param[in,out] OutData The data read.
+
+ @retval EFI_SUCCESS Operation completed successfully.
+ @retval EFI_DEVICE_ERROR The command was unsuccessful.
+ @retval EFI_NOT_FOUND The command was returned successfully, but NvIndex is not found.
+**/
+EFI_STATUS
+EFIAPI
+Tpm2NvRead (
+ IN TPMI_RH_NV_AUTH AuthHandle,
+ IN TPMI_RH_NV_INDEX NvIndex,
+ IN TPMS_AUTH_COMMAND *AuthSession, OPTIONAL
+ IN UINT16 Size,
+ IN UINT16 Offset,
+ IN OUT TPM2B_MAX_BUFFER *OutData
+ );
+
+/**
+ This command writes a value to an area in NV memory that was previously defined by TPM2_NV_DefineSpace().
+
+ @param[in] AuthHandle the handle indicating the source of the authorization value.
+ @param[in] NvIndex The NV Index of the area to write.
+ @param[in] AuthSession Auth Session context
+ @param[in] InData The data to write.
+ @param[in] Offset The offset into the NV Area.
+
+ @retval EFI_SUCCESS Operation completed successfully.
+ @retval EFI_DEVICE_ERROR The command was unsuccessful.
+ @retval EFI_NOT_FOUND The command was returned successfully, but NvIndex is not found.
+**/
+EFI_STATUS
+EFIAPI
+Tpm2NvWrite (
+ IN TPMI_RH_NV_AUTH AuthHandle,
+ IN TPMI_RH_NV_INDEX NvIndex,
+ IN TPMS_AUTH_COMMAND *AuthSession, OPTIONAL
+ IN TPM2B_MAX_BUFFER *InData,
+ IN UINT16 Offset
+ );
+
+/**
+ This command may be used to prevent further reads of the Index until the next TPM2_Startup (TPM_SU_CLEAR).
+
+ @param[in] AuthHandle the handle indicating the source of the authorization value.
+ @param[in] NvIndex The NV Index of the area to lock.
+ @param[in] AuthSession Auth Session context
+
+ @retval EFI_SUCCESS Operation completed successfully.
+ @retval EFI_DEVICE_ERROR The command was unsuccessful.
+ @retval EFI_NOT_FOUND The command was returned successfully, but NvIndex is not found.
+**/
+EFI_STATUS
+EFIAPI
+Tpm2NvReadLock (
+ IN TPMI_RH_NV_AUTH AuthHandle,
+ IN TPMI_RH_NV_INDEX NvIndex,
+ IN TPMS_AUTH_COMMAND *AuthSession OPTIONAL
+ );
+
+/**
+ This command may be used to inhibit further writes of the Index.
+
+ @param[in] AuthHandle the handle indicating the source of the authorization value.
+ @param[in] NvIndex The NV Index of the area to lock.
+ @param[in] AuthSession Auth Session context
+
+ @retval EFI_SUCCESS Operation completed successfully.
+ @retval EFI_DEVICE_ERROR The command was unsuccessful.
+ @retval EFI_NOT_FOUND The command was returned successfully, but NvIndex is not found.
+**/
+EFI_STATUS
+EFIAPI
+Tpm2NvWriteLock (
+ IN TPMI_RH_NV_AUTH AuthHandle,
+ IN TPMI_RH_NV_INDEX NvIndex,
+ IN TPMS_AUTH_COMMAND *AuthSession OPTIONAL
+ );
+
+/**
+ The command will SET TPMA_NV_WRITELOCKED for all indexes that have their TPMA_NV_GLOBALLOCK attribute SET.
+
+ @param[in] AuthHandle TPM_RH_OWNER or TPM_RH_PLATFORM+{PP}.
+ @param[in] AuthSession Auth Session context
+
+ @retval EFI_SUCCESS Operation completed successfully.
+ @retval EFI_DEVICE_ERROR The command was unsuccessful.
+ @retval EFI_NOT_FOUND The command was returned successfully, but NvIndex is not found.
+**/
+EFI_STATUS
+EFIAPI
+Tpm2NvGlobalWriteLock (
+ IN TPMI_RH_PROVISION AuthHandle,
+ IN TPMS_AUTH_COMMAND *AuthSession OPTIONAL
+ );
+
+/**
+ This command is used to cause an update to the indicated PCR.
+ The digests parameter contains one or more tagged digest value identified by an algorithm ID.
+ For each digest, the PCR associated with pcrHandle is Extended into the bank identified by the tag (hashAlg).
+
+ @param[in] PcrHandle Handle of the PCR
+ @param[in] Digests List of tagged digest values to be extended
+
+ @retval EFI_SUCCESS Operation completed successfully.
+ @retval EFI_DEVICE_ERROR Unexpected device behavior.
+**/
+EFI_STATUS
+EFIAPI
+Tpm2PcrExtend (
+ IN TPMI_DH_PCR PcrHandle,
+ IN TPML_DIGEST_VALUES *Digests
+ );
+
+/**
+ This command is used to cause an update to the indicated PCR.
+ The data in eventData is hashed using the hash algorithm associated with each bank in which the
+ indicated PCR has been allocated. After the data is hashed, the digests list is returned. If the pcrHandle
+ references an implemented PCR and not TPM_ALG_NULL, digests list is processed as in
+ TPM2_PCR_Extend().
+ A TPM shall support an Event.size of zero through 1,024 inclusive.
+
+ @param[in] PcrHandle Handle of the PCR
+ @param[in] EventData Event data in sized buffer
+ @param[out] Digests List of digest
+
+ @retval EFI_SUCCESS Operation completed successfully.
+ @retval EFI_DEVICE_ERROR Unexpected device behavior.
+**/
+EFI_STATUS
+EFIAPI
+Tpm2PcrEvent (
+ IN TPMI_DH_PCR PcrHandle,
+ IN TPM2B_EVENT *EventData,
+ OUT TPML_DIGEST_VALUES *Digests
+ );
+
+/**
+ This command returns the values of all PCR specified in pcrSelect.
+
+ @param[in] PcrSelectionIn The selection of PCR to read.
+ @param[out] PcrUpdateCounter The current value of the PCR update counter.
+ @param[out] PcrSelectionOut The PCR in the returned list.
+ @param[out] PcrValues The contents of the PCR indicated in pcrSelect.
+
+ @retval EFI_SUCCESS Operation completed successfully.
+ @retval EFI_DEVICE_ERROR The command was unsuccessful.
+**/
+EFI_STATUS
+EFIAPI
+Tpm2PcrRead (
+ IN TPML_PCR_SELECTION *PcrSelectionIn,
+ OUT UINT32 *PcrUpdateCounter,
+ OUT TPML_PCR_SELECTION *PcrSelectionOut,
+ OUT TPML_DIGEST *PcrValues
+ );
+
+/**
+ This command is used to set the desired PCR allocation of PCR and algorithms.
+
+ @param[in] AuthHandle TPM_RH_PLATFORM+{PP}
+ @param[in] AuthSession Auth Session context
+ @param[in] PcrAllocation The requested allocation
+ @param[out] AllocationSuccess YES if the allocation succeeded
+ @param[out] MaxPCR maximum number of PCR that may be in a bank
+ @param[out] SizeNeeded number of octets required to satisfy the request
+ @param[out] SizeAvailable Number of octets available. Computed before the allocation
+
+ @retval EFI_SUCCESS Operation completed successfully.
+ @retval EFI_DEVICE_ERROR The command was unsuccessful.
+**/
+EFI_STATUS
+EFIAPI
+Tpm2PcrAllocate (
+ IN TPMI_RH_PLATFORM AuthHandle,
+ IN TPMS_AUTH_COMMAND *AuthSession,
+ IN TPML_PCR_SELECTION *PcrAllocation,
+ OUT TPMI_YES_NO *AllocationSuccess,
+ OUT UINT32 *MaxPCR,
+ OUT UINT32 *SizeNeeded,
+ OUT UINT32 *SizeAvailable
+ );
+
+/**
+ This command returns various information regarding the TPM and its current state.
+
+ The capability parameter determines the category of data returned. The property parameter
+ selects the first value of the selected category to be returned. If there is no property
+ that corresponds to the value of property, the next higher value is returned, if it exists.
+ The moreData parameter will have a value of YES if there are more values of the requested
+ type that were not returned.
+ If no next capability exists, the TPM will return a zero-length list and moreData will have
+ a value of NO.
+
+ NOTE:
+ To simplify this function, leave returned CapabilityData for caller to unpack since there are
+ many capability categories and only few categories will be used in firmware. It means the caller
+ need swap the byte order for the feilds in CapabilityData.
+
+ @param[in] Capability Group selection; determines the format of the response.
+ @param[in] Property Further definition of information.
+ @param[in] PropertyCount Number of properties of the indicated type to return.
+ @param[out] MoreData Flag to indicate if there are more values of this type.
+ @param[out] CapabilityData The capability data.
+
+ @retval EFI_SUCCESS Operation completed successfully.
+ @retval EFI_DEVICE_ERROR The command was unsuccessful.
+**/
+EFI_STATUS
+EFIAPI
+Tpm2GetCapability (
+ IN TPM_CAP Capability,
+ IN UINT32 Property,
+ IN UINT32 PropertyCount,
+ OUT TPMI_YES_NO *MoreData,
+ OUT TPMS_CAPABILITY_DATA *CapabilityData
+ );
+
+/**
+ This command returns the information of TPM Family.
+
+ This function parse the value got from TPM2_GetCapability and return the Family.
+
+ @param[out] Family The Family of TPM. (a 4-octet character string)
+
+ @retval EFI_SUCCESS Operation completed successfully.
+ @retval EFI_DEVICE_ERROR The command was unsuccessful.
+**/
+EFI_STATUS
+EFIAPI
+Tpm2GetCapabilityFamily (
+ OUT CHAR8 *Family
+ );
+
+/**
+ This command returns the information of TPM manufacture ID.
+
+ This function parse the value got from TPM2_GetCapability and return the TPM manufacture ID.
+
+ @param[out] ManufactureId The manufacture ID of TPM.
+
+ @retval EFI_SUCCESS Operation completed successfully.
+ @retval EFI_DEVICE_ERROR The command was unsuccessful.
+**/
+EFI_STATUS
+EFIAPI
+Tpm2GetCapabilityManufactureID (
+ OUT UINT32 *ManufactureId
+ );
+
+/**
+ This command returns the information of TPM FirmwareVersion.
+
+ This function parse the value got from TPM2_GetCapability and return the TPM FirmwareVersion.
+
+ @param[out] FirmwareVersion1 The FirmwareVersion1.
+ @param[out] FirmwareVersion2 The FirmwareVersion2.
+
+ @retval EFI_SUCCESS Operation completed successfully.
+ @retval EFI_DEVICE_ERROR The command was unsuccessful.
+**/
+EFI_STATUS
+EFIAPI
+Tpm2GetCapabilityFirmwareVersion (
+ OUT UINT32 *FirmwareVersion1,
+ OUT UINT32 *FirmwareVersion2
+ );
+
+/**
+ This command returns the information of the maximum value for commandSize and responseSize in a command.
+
+ This function parse the value got from TPM2_GetCapability and return the max command size and response size
+
+ @param[out] MaxCommandSize The maximum value for commandSize in a command.
+ @param[out] MaxResponseSize The maximum value for responseSize in a command.
+
+ @retval EFI_SUCCESS Operation completed successfully.
+ @retval EFI_DEVICE_ERROR The command was unsuccessful.
+**/
+EFI_STATUS
+EFIAPI
+Tpm2GetCapabilityMaxCommandResponseSize (
+ OUT UINT32 *MaxCommandSize,
+ OUT UINT32 *MaxResponseSize
+ );
+
+/**
+ This command returns Returns a list of TPMS_ALG_PROPERTIES. Each entry is an
+ algorithm ID and a set of properties of the algorithm.
+
+ This function parse the value got from TPM2_GetCapability and return the list.
+
+ @param[out] AlgList List of algorithm.
+
+ @retval EFI_SUCCESS Operation completed successfully.
+ @retval EFI_DEVICE_ERROR The command was unsuccessful.
+**/
+EFI_STATUS
+EFIAPI
+Tpm2GetCapabilitySupportedAlg (
+ OUT TPML_ALG_PROPERTY *AlgList
+ );
+
+/**
+ This command returns the information of TPM LockoutCounter.
+
+ This function parse the value got from TPM2_GetCapability and return the LockoutCounter.
+
+ @param[out] LockoutCounter The LockoutCounter of TPM.
+
+ @retval EFI_SUCCESS Operation completed successfully.
+ @retval EFI_DEVICE_ERROR The command was unsuccessful.
+**/
+EFI_STATUS
+EFIAPI
+Tpm2GetCapabilityLockoutCounter (
+ OUT UINT32 *LockoutCounter
+ );
+
+/**
+ This command returns the information of TPM LockoutInterval.
+
+ This function parse the value got from TPM2_GetCapability and return the LockoutInterval.
+
+ @param[out] LockoutInterval The LockoutInterval of TPM.
+
+ @retval EFI_SUCCESS Operation completed successfully.
+ @retval EFI_DEVICE_ERROR The command was unsuccessful.
+**/
+EFI_STATUS
+EFIAPI
+Tpm2GetCapabilityLockoutInterval (
+ OUT UINT32 *LockoutInterval
+ );
+
+/**
+ This command returns the information of TPM InputBufferSize.
+
+ This function parse the value got from TPM2_GetCapability and return the InputBufferSize.
+
+ @param[out] InputBufferSize The InputBufferSize of TPM.
+ the maximum size of a parameter (typically, a TPM2B_MAX_BUFFER)
+
+ @retval EFI_SUCCESS Operation completed successfully.
+ @retval EFI_DEVICE_ERROR The command was unsuccessful.
+**/
+EFI_STATUS
+EFIAPI
+Tpm2GetCapabilityInputBufferSize (
+ OUT UINT32 *InputBufferSize
+ );
+
+/**
+ This command returns the information of TPM PCRs.
+
+ This function parse the value got from TPM2_GetCapability and return the PcrSelection.
+
+ @param[out] Pcrs The Pcr Selection
+
+ @retval EFI_SUCCESS Operation completed successfully.
+ @retval EFI_DEVICE_ERROR The command was unsuccessful.
+**/
+EFI_STATUS
+EFIAPI
+Tpm2GetCapabilityPcrs (
+ OUT TPML_PCR_SELECTION *Pcrs
+ );
+
+/**
+ This command returns the information of TPM AlgorithmSet.
+
+ This function parse the value got from TPM2_GetCapability and return the AlgorithmSet.
+
+ @param[out] AlgorithmSet The AlgorithmSet of TPM.
+
+ @retval EFI_SUCCESS Operation completed successfully.
+ @retval EFI_DEVICE_ERROR The command was unsuccessful.
+**/
+EFI_STATUS
+EFIAPI
+Tpm2GetCapabilityAlgorithmSet (
+ OUT UINT32 *AlgorithmSet
+ );
+
+/**
+ This command is used to check to see if specific combinations of algorithm parameters are supported.
+
+ @param[in] Parameters Algorithm parameters to be validated
+
+ @retval EFI_SUCCESS Operation completed successfully.
+ @retval EFI_DEVICE_ERROR Unexpected device behavior.
+**/
+EFI_STATUS
+EFIAPI
+Tpm2TestParms (
+ IN TPMT_PUBLIC_PARMS *Parameters
+ );
+
+/**
+ This command allows the platform to change the set of algorithms that are used by the TPM.
+ The algorithmSet setting is a vendor-dependent value.
+
+ @param[in] AuthHandle TPM_RH_PLATFORM
+ @param[in] AuthSession Auth Session context
+ @param[in] AlgorithmSet A TPM vendor-dependent value indicating the
+ algorithm set selection
+
+ @retval EFI_SUCCESS Operation completed successfully.
+ @retval EFI_DEVICE_ERROR Unexpected device behavior.
+**/
+EFI_STATUS
+EFIAPI
+Tpm2SetAlgorithmSet (
+ IN TPMI_RH_PLATFORM AuthHandle,
+ IN TPMS_AUTH_COMMAND *AuthSession,
+ IN UINT32 AlgorithmSet
+ );
+
+//
+// Help function
+//
+
+/**
+ Copy AuthSessionIn to TPM2 command buffer.
+
+ @param [in] AuthSessionIn Input AuthSession data
+ @param [out] AuthSessionOut Output AuthSession data in TPM2 command buffer
+
+ @return AuthSession size
+**/
+UINT32
+EFIAPI
+CopyAuthSessionCommand (
+ IN TPMS_AUTH_COMMAND *AuthSessionIn, OPTIONAL
+ OUT UINT8 *AuthSessionOut
+ );
+
+/**
+ Copy AuthSessionIn from TPM2 response buffer.
+
+ @param [in] AuthSessionIn Input AuthSession data in TPM2 response buffer
+ @param [out] AuthSessionOut Output AuthSession data
+
+ @return AuthSession size
+**/
+UINT32
+EFIAPI
+CopyAuthSessionResponse (
+ IN UINT8 *AuthSessionIn,
+ OUT TPMS_AUTH_RESPONSE *AuthSessionOut OPTIONAL
+ );
+
+/**
+ Return size of digest.
+
+ @param[in] HashAlgo Hash algorithm
+
+ @return size of digest
+**/
+UINT16
+EFIAPI
+GetHashSizeFromAlgo (
+ IN TPMI_ALG_HASH HashAlgo
+ );
+
+#endif
diff --git a/SecurityPkg/Include/Library/Tpm2DeviceLib.h b/SecurityPkg/Include/Library/Tpm2DeviceLib.h
new file mode 100644
index 000000000..67f158ef0
--- /dev/null
+++ b/SecurityPkg/Include/Library/Tpm2DeviceLib.h
@@ -0,0 +1,109 @@
+/** @file
+ This library abstract how to access TPM2 hardware device.
+
+Copyright (c) 2013, 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.
+
+**/
+
+#ifndef _TPM2_DEVICE_LIB_H_
+#define _TPM2_DEVICE_LIB_H_
+
+#include <Uefi.h>
+
+/**
+ This service enables the sending of commands to the TPM2.
+
+ @param[in] InputParameterBlockSize Size of the TPM2 input parameter block.
+ @param[in] InputParameterBlock Pointer to the TPM2 input parameter block.
+ @param[in,out] OutputParameterBlockSize Size of the TPM2 output parameter block.
+ @param[in] OutputParameterBlock Pointer to the TPM2 output parameter block.
+
+ @retval EFI_SUCCESS The command byte stream was successfully sent to the device and a response was successfully received.
+ @retval EFI_DEVICE_ERROR The command was not successfully sent to the device or a response was not successfully received from the device.
+ @retval EFI_BUFFER_TOO_SMALL The output parameter block is too small.
+**/
+EFI_STATUS
+EFIAPI
+Tpm2SubmitCommand (
+ IN UINT32 InputParameterBlockSize,
+ IN UINT8 *InputParameterBlock,
+ IN OUT UINT32 *OutputParameterBlockSize,
+ IN UINT8 *OutputParameterBlock
+ );
+
+/**
+ This service requests use TPM2.
+
+ @retval EFI_SUCCESS Get the control of TPM2 chip.
+ @retval EFI_NOT_FOUND TPM2 not found.
+ @retval EFI_DEVICE_ERROR Unexpected device behavior.
+**/
+EFI_STATUS
+EFIAPI
+Tpm2RequestUseTpm (
+ VOID
+ );
+
+/**
+ This service enables the sending of commands to the TPM2.
+
+ @param[in] InputParameterBlockSize Size of the TPM2 input parameter block.
+ @param[in] InputParameterBlock Pointer to the TPM2 input parameter block.
+ @param[in,out] OutputParameterBlockSize Size of the TPM2 output parameter block.
+ @param[in] OutputParameterBlock Pointer to the TPM2 output parameter block.
+
+ @retval EFI_SUCCESS The command byte stream was successfully sent to the device and a response was successfully received.
+ @retval EFI_DEVICE_ERROR The command was not successfully sent to the device or a response was not successfully received from the device.
+ @retval EFI_BUFFER_TOO_SMALL The output parameter block is too small.
+**/
+typedef
+EFI_STATUS
+(EFIAPI *TPM2_SUBMIT_COMMAND) (
+ IN UINT32 InputParameterBlockSize,
+ IN UINT8 *InputParameterBlock,
+ IN OUT UINT32 *OutputParameterBlockSize,
+ IN UINT8 *OutputParameterBlock
+ );
+
+/**
+ This service requests use TPM2.
+
+ @retval EFI_SUCCESS Get the control of TPM2 chip.
+ @retval EFI_NOT_FOUND TPM2 not found.
+ @retval EFI_DEVICE_ERROR Unexpected device behavior.
+**/
+typedef
+EFI_STATUS
+(EFIAPI *TPM2_REQUEST_USE_TPM) (
+ VOID
+ );
+
+typedef struct {
+ EFI_GUID ProviderGuid;
+ TPM2_SUBMIT_COMMAND Tpm2SubmitCommand;
+ TPM2_REQUEST_USE_TPM Tpm2RequestUseTpm;
+} TPM2_DEVICE_INTERFACE;
+
+/**
+ This service register TPM2 device.
+
+ @param Tpm2Device TPM2 device
+
+ @retval EFI_SUCCESS This TPM2 device is registered successfully.
+ @retval EFI_UNSUPPORTED System does not support register this TPM2 device.
+ @retval EFI_ALREADY_STARTED System already register this TPM2 device.
+**/
+EFI_STATUS
+EFIAPI
+Tpm2RegisterTpm2DeviceLib (
+ IN TPM2_DEVICE_INTERFACE *Tpm2Device
+ );
+
+#endif
diff --git a/SecurityPkg/Include/Library/TrEEPhysicalPresenceLib.h b/SecurityPkg/Include/Library/TrEEPhysicalPresenceLib.h
new file mode 100644
index 000000000..781fd16b7
--- /dev/null
+++ b/SecurityPkg/Include/Library/TrEEPhysicalPresenceLib.h
@@ -0,0 +1,57 @@
+/** @file
+ Ihis library is intended to be used by BDS modules.
+ This library will executing TPM2 request.
+
+Copyright (c) 2013, 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.
+
+**/
+
+#ifndef _TREE_PHYSICAL_PRESENCE_LIB_H_
+#define _TREE_PHYSICAL_PRESENCE_LIB_H_
+
+#include <IndustryStandard/Tpm20.h>
+#include <Protocol/TrEEProtocol.h>
+
+/**
+ Check and execute the pending TPM request.
+
+ The TPM request may come from OS or BIOS. This API will display request information and wait
+ for user confirmation if TPM request exists. The TPM request will be sent to TPM device after
+ the TPM request is confirmed, and one or more reset may be required to make TPM request to
+ take effect.
+
+ This API should be invoked after console in and console out are all ready as they are required
+ to display request information and get user input to confirm the request.
+
+ @param PlatformAuth platform auth value. NULL means no platform auth change.
+**/
+VOID
+EFIAPI
+TrEEPhysicalPresenceLibProcessRequest (
+ IN TPM2B_AUTH *PlatformAuth OPTIONAL
+ );
+
+/**
+ Check if the pending TPM request needs user input to confirm.
+
+ The TPM request may come from OS. This API will check if TPM request exists and need user
+ input to confirmation.
+
+ @retval TRUE TPM needs input to confirm user physical presence.
+ @retval FALSE TPM doesn't need input to confirm user physical presence.
+
+**/
+BOOLEAN
+EFIAPI
+TrEEPhysicalPresenceLibNeedUserConfirm(
+ VOID
+ );
+
+#endif
diff --git a/SecurityPkg/Include/Ppi/FirmwareVolumeInfoMeasurementExcluded.h b/SecurityPkg/Include/Ppi/FirmwareVolumeInfoMeasurementExcluded.h
new file mode 100644
index 000000000..88d09b0d3
--- /dev/null
+++ b/SecurityPkg/Include/Ppi/FirmwareVolumeInfoMeasurementExcluded.h
@@ -0,0 +1,37 @@
+/** @file
+ Ihis PPI means a FV does not need to be extended to PCR by TCG modules.
+
+Copyright (c) 2013, 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.
+
+**/
+
+#ifndef __EFI_PEI_FIRMWARE_VOLUME_INFO_MEASUREMENT_EXCLUDED_H__
+#define __EFI_PEI_FIRMWARE_VOLUME_INFO_MEASUREMENT_EXCLUDED_H__
+
+#define EFI_PEI_FIRMWARE_VOLUME_INFO_MEASUREMENT_EXCLUDED_PPI_GUID \
+ { 0x6e056ff9, 0xc695, 0x4364, { 0x9e, 0x2c, 0x61, 0x26, 0xf5, 0xce, 0xea, 0xae } }
+
+typedef struct {
+ EFI_PHYSICAL_ADDRESS FvBase;
+ UINT64 FvLength;
+} EFI_PEI_FIRMWARE_VOLUME_INFO_MEASUREMENT_EXCLUDED_FV;
+
+//
+// This PPI means a FV does not need to be extended to PCR by TCG modules.
+//
+typedef struct {
+ UINT32 Count;
+ EFI_PEI_FIRMWARE_VOLUME_INFO_MEASUREMENT_EXCLUDED_FV Fv[1];
+} EFI_PEI_FIRMWARE_VOLUME_INFO_MEASUREMENT_EXCLUDED_PPI;
+
+extern EFI_GUID gEfiPeiFirmwareVolumeInfoMeasurementExcludedPpiGuid;
+
+#endif
+
diff --git a/SecurityPkg/Library/DxeImageVerificationLib/DxeImageVerificationLib.c b/SecurityPkg/Library/DxeImageVerificationLib/DxeImageVerificationLib.c
index 2458ee2ae..8860daeaf 100644
--- a/SecurityPkg/Library/DxeImageVerificationLib/DxeImageVerificationLib.c
+++ b/SecurityPkg/Library/DxeImageVerificationLib/DxeImageVerificationLib.c
@@ -72,6 +72,25 @@ HASH_TABLE mHash[] = {
};
/**
+ SecureBoot Hook for processing image verification.
+
+ @param[in] VariableName Name of Variable to be found.
+ @param[in] VendorGuid Variable vendor GUID.
+ @param[in] DataSize Size of Data found. If size is less than the
+ data, this value contains the required size.
+ @param[in] Data Data pointer.
+
+**/
+VOID
+EFIAPI
+SecureBootHook (
+ IN CHAR16 *VariableName,
+ IN EFI_GUID *VendorGuid,
+ IN UINTN DataSize,
+ IN VOID *Data
+ );
+
+/**
Reads contents of a PE/COFF image in memory buffer.
Caution: This function may receive untrusted input.
@@ -846,6 +865,7 @@ IsSignatureFoundInDatabase (
// Find the signature in database.
//
IsFound = TRUE;
+ SecureBootHook (VariableName, &gEfiImageSecurityDatabaseGuid, CertList->SignatureSize, Cert);
break;
}
@@ -948,6 +968,7 @@ IsPkcsSignedDataVerifiedBySignatureList (
mImageDigestSize
);
if (VerifyStatus) {
+ SecureBootHook (VariableName, VendorGuid, CertList->SignatureSize, Cert);
goto Done;
}
Cert = (EFI_SIGNATURE_DATA *) ((UINT8 *) Cert + CertList->SignatureSize);
diff --git a/SecurityPkg/Library/DxeImageVerificationLib/DxeImageVerificationLib.inf b/SecurityPkg/Library/DxeImageVerificationLib/DxeImageVerificationLib.inf
index 0c6ab968f..0e6a5d1ce 100644
--- a/SecurityPkg/Library/DxeImageVerificationLib/DxeImageVerificationLib.inf
+++ b/SecurityPkg/Library/DxeImageVerificationLib/DxeImageVerificationLib.inf
@@ -35,6 +35,7 @@
[Sources]
DxeImageVerificationLib.c
DxeImageVerificationLib.h
+ Measurement.c
[Packages]
MdePkg/MdePkg.dec
@@ -54,6 +55,7 @@
BaseCryptLib
SecurityManagementLib
PeCoffLib
+ TpmMeasurementLib
[Protocols]
gEfiFirmwareVolume2ProtocolGuid
diff --git a/SecurityPkg/Library/DxeImageVerificationLib/Measurement.c b/SecurityPkg/Library/DxeImageVerificationLib/Measurement.c
new file mode 100644
index 000000000..2213423c3
--- /dev/null
+++ b/SecurityPkg/Library/DxeImageVerificationLib/Measurement.c
@@ -0,0 +1,322 @@
+/** @file
+ Measure TrEE required variable.
+
+Copyright (c) 2013, 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.
+
+**/
+
+#include <PiDxe.h>
+#include <Guid/ImageAuthentication.h>
+#include <IndustryStandard/UefiTcgPlatform.h>
+#include <Protocol/TrEEProtocol.h>
+
+#include <Library/UefiBootServicesTableLib.h>
+#include <Library/UefiRuntimeServicesTableLib.h>
+#include <Library/MemoryAllocationLib.h>
+#include <Library/BaseMemoryLib.h>
+#include <Library/DebugLib.h>
+#include <Library/BaseLib.h>
+#include <Library/TpmMeasurementLib.h>
+
+typedef struct {
+ CHAR16 *VariableName;
+ EFI_GUID *VendorGuid;
+} VARIABLE_TYPE;
+
+typedef struct {
+ CHAR16 *VariableName;
+ EFI_GUID *VendorGuid;
+ VOID *Data;
+ UINTN Size;
+} VARIABLE_RECORD;
+
+#define MEASURED_AUTHORITY_COUNT_MAX 0x100
+
+UINTN mMeasuredAuthorityCount = 0;
+UINTN mMeasuredAuthorityCountMax = 0;
+VARIABLE_RECORD *mMeasuredAuthorityList = NULL;
+
+VARIABLE_TYPE mVariableType[] = {
+ {EFI_IMAGE_SECURITY_DATABASE, &gEfiImageSecurityDatabaseGuid},
+};
+
+/**
+ This function will check if VarName should be recorded and return the address of VarName if it is needed.
+
+ @param[in] VarName A Null-terminated string that is the name of the vendor's variable.
+
+ @return the address of VarName.
+**/
+CHAR16 *
+AssignVarName (
+ IN CHAR16 *VarName
+ )
+{
+ UINTN Index;
+
+ for (Index = 0; Index < sizeof(mVariableType)/sizeof(mVariableType[0]); Index++) {
+ if (StrCmp (VarName, mVariableType[Index].VariableName) == 0) {
+ return mVariableType[Index].VariableName;
+ }
+ }
+
+ return NULL;
+}
+
+/**
+ This function will check if VendorGuid should be recorded and return the address of VendorGuid if it is needed.
+
+ @param[in] VendorGuid A unique identifier for the vendor.
+
+ @return the address of VendorGuid.
+**/
+EFI_GUID *
+AssignVendorGuid (
+ IN EFI_GUID *VendorGuid
+ )
+{
+ UINTN Index;
+
+ for (Index = 0; Index < sizeof(mVariableType)/sizeof(mVariableType[0]); Index++) {
+ if (CompareGuid (VendorGuid, mVariableType[Index].VendorGuid)) {
+ return mVariableType[Index].VendorGuid;
+ }
+ }
+
+ return NULL;
+}
+
+/**
+ This function will add variable information to MeasuredAuthorityList.
+
+ @param[in] VarName A Null-terminated string that is the name of the vendor's variable.
+ @param[in] VendorGuid A unique identifier for the vendor.
+ @param[in] VarData The content of the variable data.
+ @param[in] VarSize The size of the variable data.
+
+ @retval EFI_SUCCESS Operation completed successfully.
+ @retval EFI_OUT_OF_RESOURCES Out of memory.
+**/
+EFI_STATUS
+AddDataMeasured (
+ IN CHAR16 *VarName,
+ IN EFI_GUID *VendorGuid,
+ IN VOID *Data,
+ IN UINTN Size
+ )
+{
+ VARIABLE_RECORD *NewMeasuredAuthorityList;
+
+ ASSERT (mMeasuredAuthorityCount <= mMeasuredAuthorityCountMax);
+ if (mMeasuredAuthorityCount == mMeasuredAuthorityCountMax) {
+ //
+ // Need enlarge
+ //
+ NewMeasuredAuthorityList = AllocateZeroPool (sizeof(VARIABLE_RECORD) * (mMeasuredAuthorityCountMax + MEASURED_AUTHORITY_COUNT_MAX));
+ if (NewMeasuredAuthorityList == NULL) {
+ return EFI_OUT_OF_RESOURCES;
+ }
+ if (mMeasuredAuthorityList != NULL) {
+ CopyMem (NewMeasuredAuthorityList, mMeasuredAuthorityList, sizeof(VARIABLE_RECORD) * mMeasuredAuthorityCount);
+ FreePool (mMeasuredAuthorityList);
+ }
+ mMeasuredAuthorityList = NewMeasuredAuthorityList;
+ mMeasuredAuthorityCountMax += MEASURED_AUTHORITY_COUNT_MAX;
+ }
+
+ //
+ // Add new entry
+ //
+ mMeasuredAuthorityList[mMeasuredAuthorityCount].VariableName = AssignVarName (VarName);
+ mMeasuredAuthorityList[mMeasuredAuthorityCount].VendorGuid = AssignVendorGuid (VendorGuid);
+ mMeasuredAuthorityList[mMeasuredAuthorityCount].Size = Size;
+ mMeasuredAuthorityList[mMeasuredAuthorityCount].Data = AllocatePool (Size);
+ if (mMeasuredAuthorityList[mMeasuredAuthorityCount].Data == NULL) {
+ return EFI_OUT_OF_RESOURCES;
+ }
+ CopyMem (mMeasuredAuthorityList[mMeasuredAuthorityCount].Data, Data, Size);
+ mMeasuredAuthorityCount++;
+
+ return EFI_SUCCESS;
+}
+
+/**
+ This function will return if this variable is already measured.
+
+ @param[in] VarName A Null-terminated string that is the name of the vendor's variable.
+ @param[in] VendorGuid A unique identifier for the vendor.
+ @param[in] VarData The content of the variable data.
+ @param[in] VarSize The size of the variable data.
+
+ @retval TRUE The data is already measured.
+ @retval FALSE The data is not measured yet.
+**/
+BOOLEAN
+IsDataMeasured (
+ IN CHAR16 *VarName,
+ IN EFI_GUID *VendorGuid,
+ IN VOID *Data,
+ IN UINTN Size
+ )
+{
+ UINTN Index;
+
+ for (Index = 0; Index < mMeasuredAuthorityCount; Index++) {
+ if ((StrCmp (VarName, mMeasuredAuthorityList[Index].VariableName) == 0) &&
+ (CompareGuid (VendorGuid, mMeasuredAuthorityList[Index].VendorGuid)) &&
+ (CompareMem (Data, mMeasuredAuthorityList[Index].Data, Size) == 0) &&
+ (Size == mMeasuredAuthorityList[Index].Size)) {
+ return TRUE;
+ }
+ }
+
+ return FALSE;
+}
+
+/**
+ This function will return if this variable is SecureAuthority Variable.
+
+ @param[in] VariableName A Null-terminated string that is the name of the vendor's variable.
+ @param[in] VendorGuid A unique identifier for the vendor.
+
+ @retval TRUE This is SecureAuthority Variable
+ @retval FALSE This is not SecureAuthority Variable
+**/
+BOOLEAN
+IsSecureAuthorityVariable (
+ IN CHAR16 *VariableName,
+ IN EFI_GUID *VendorGuid
+ )
+{
+ UINTN Index;
+
+ for (Index = 0; Index < sizeof(mVariableType)/sizeof(mVariableType[0]); Index++) {
+ if ((StrCmp (VariableName, mVariableType[Index].VariableName) == 0) &&
+ (CompareGuid (VendorGuid, mVariableType[Index].VendorGuid))) {
+ return TRUE;
+ }
+ }
+ return FALSE;
+}
+
+/**
+ Measure and log an EFI variable, and extend the measurement result into a specific PCR.
+
+ @param[in] VarName A Null-terminated string that is the name of the vendor's variable.
+ @param[in] VendorGuid A unique identifier for the vendor.
+ @param[in] VarData The content of the variable data.
+ @param[in] VarSize The size of the variable data.
+
+ @retval EFI_SUCCESS Operation completed successfully.
+ @retval EFI_OUT_OF_RESOURCES Out of memory.
+ @retval EFI_DEVICE_ERROR The operation was unsuccessful.
+
+**/
+EFI_STATUS
+EFIAPI
+MeasureVariable (
+ IN CHAR16 *VarName,
+ IN EFI_GUID *VendorGuid,
+ IN VOID *VarData,
+ IN UINTN VarSize
+ )
+{
+ EFI_STATUS Status;
+ UINTN VarNameLength;
+ EFI_VARIABLE_DATA_TREE *VarLog;
+ UINT32 VarLogSize;
+
+ //
+ // The EFI_VARIABLE_DATA_TREE.VariableData value shall be the EFI_SIGNATURE_DATA value
+ // from the EFI_SIGNATURE_LIST that contained the authority that was used to validate the image
+ //
+ VarNameLength = StrLen (VarName);
+ VarLogSize = (UINT32)(sizeof (*VarLog) + VarNameLength * sizeof (*VarName) + VarSize
+ - sizeof (VarLog->UnicodeName) - sizeof (VarLog->VariableData));
+
+ VarLog = (EFI_VARIABLE_DATA_TREE *) AllocateZeroPool (VarLogSize);
+ if (VarLog == NULL) {
+ return EFI_OUT_OF_RESOURCES;
+ }
+
+ CopyMem (&VarLog->VariableName, VendorGuid, sizeof(VarLog->VariableName));
+ VarLog->UnicodeNameLength = VarNameLength;
+ VarLog->VariableDataLength = VarSize;
+ CopyMem (
+ VarLog->UnicodeName,
+ VarName,
+ VarNameLength * sizeof (*VarName)
+ );
+ CopyMem (
+ (CHAR16 *)VarLog->UnicodeName + VarNameLength,
+ VarData,
+ VarSize
+ );
+
+ DEBUG ((EFI_D_INFO, "DxeImageVerification: MeasureVariable (Pcr - %x, EventType - %x, ", (UINTN)7, (UINTN)EV_EFI_VARIABLE_AUTHORITY));
+ DEBUG ((EFI_D_INFO, "VariableName - %s, VendorGuid - %g)\n", VarName, VendorGuid));
+
+ Status = TpmMeasureAndLogData (
+ 7,
+ EV_EFI_VARIABLE_AUTHORITY,
+ VarLog,
+ VarLogSize,
+ VarLog,
+ VarLogSize
+ );
+ FreePool (VarLog);
+
+ return Status;
+}
+
+/**
+ SecureBoot Hook for processing image verification.
+
+ @param[in] VariableName Name of Variable to be found.
+ @param[in] VendorGuid Variable vendor GUID.
+ @param[in] DataSize Size of Data found. If size is less than the
+ data, this value contains the required size.
+ @param[in] Data Data pointer.
+
+**/
+VOID
+EFIAPI
+SecureBootHook (
+ IN CHAR16 *VariableName,
+ IN EFI_GUID *VendorGuid,
+ IN UINTN DataSize,
+ IN VOID *Data
+ )
+{
+ EFI_STATUS Status;
+
+ if (!IsSecureAuthorityVariable (VariableName, VendorGuid)) {
+ return ;
+ }
+
+ if (IsDataMeasured (VariableName, VendorGuid, Data, DataSize)) {
+ DEBUG ((EFI_D_ERROR, "MeasureSecureAuthorityVariable - IsDataMeasured\n"));
+ return ;
+ }
+
+ Status = MeasureVariable (
+ VariableName,
+ VendorGuid,
+ Data,
+ DataSize
+ );
+ DEBUG ((EFI_D_ERROR, "MeasureBootPolicyVariable - %r\n", Status));
+
+ if (!EFI_ERROR (Status)) {
+ AddDataMeasured (VariableName, VendorGuid, Data, DataSize);
+ }
+
+ return ;
+}
diff --git a/SecurityPkg/Library/DxeTcgPhysicalPresenceLib/DxeTcgPhysicalPresenceLib.c b/SecurityPkg/Library/DxeTcgPhysicalPresenceLib/DxeTcgPhysicalPresenceLib.c
index 427cc8d66..ebc7367fa 100644
--- a/SecurityPkg/Library/DxeTcgPhysicalPresenceLib/DxeTcgPhysicalPresenceLib.c
+++ b/SecurityPkg/Library/DxeTcgPhysicalPresenceLib/DxeTcgPhysicalPresenceLib.c
@@ -897,11 +897,12 @@ UserConfirm (
Check if there is a valid physical presence command request. Also updates parameter value
to whether the requested physical presence command already confirmed by user
- @param[in] TcgPpData EFI TCG Physical Presence request data.
- @param[out] RequestConfirmed If the physical presence operation command required user confirm from UI.
- True, it indicates the command doesn't require user confirm, or already confirmed
- in last boot cycle by user.
- False, it indicates the command need user confirm from UI.
+ @param[in] TcgPpData EFI TCG Physical Presence request data.
+ @param[in] Flags The physical presence interface flags.
+ @param[out] RequestConfirmed If the physical presence operation command required user confirm from UI.
+ True, it indicates the command doesn't require user confirm, or already confirmed
+ in last boot cycle by user.
+ False, it indicates the command need user confirm from UI.
@retval TRUE Physical Presence operation command is valid.
@retval FALSE Physical Presence operation command is invalid.
@@ -998,6 +999,7 @@ HaveValidTpmRequest (
@param[in] TcgProtocol EFI TCG Protocol instance.
@param[in] TcgPpData Point to the physical presence NV variable.
+ @param[in] Flags The physical presence interface flags.
**/
VOID
diff --git a/SecurityPkg/Library/DxeTpm2MeasureBootLib/DxeTpm2MeasureBootLib.c b/SecurityPkg/Library/DxeTpm2MeasureBootLib/DxeTpm2MeasureBootLib.c
new file mode 100644
index 000000000..3c81b5af5
--- /dev/null
+++ b/SecurityPkg/Library/DxeTpm2MeasureBootLib/DxeTpm2MeasureBootLib.c
@@ -0,0 +1,700 @@
+/** @file
+ The library instance provides security service of TPM2 measure boot.
+
+ Caution: This file requires additional review when modified.
+ This library will have external input - PE/COFF image and GPT partition.
+ This external input must be validated carefully to avoid security issue like
+ buffer overflow, integer overflow.
+
+ DxeTpm2MeasureBootLibImageRead() function will make sure the PE/COFF image content
+ read is within the image buffer.
+
+ TrEEMeasurePeImage() function will accept untrusted PE/COFF image and validate its
+ data structure within this image buffer before use.
+
+ TrEEMeasureGptTable() function will receive untrusted GPT partition table, and parse
+ partition data carefully.
+
+Copyright (c) 2013, 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.
+
+**/
+
+#include <PiDxe.h>
+
+#include <Protocol/TrEEProtocol.h>
+#include <Protocol/BlockIo.h>
+#include <Protocol/DiskIo.h>
+#include <Protocol/DevicePathToText.h>
+#include <Protocol/FirmwareVolumeBlock.h>
+
+#include <Guid/MeasuredFvHob.h>
+
+#include <Library/BaseLib.h>
+#include <Library/DebugLib.h>
+#include <Library/BaseMemoryLib.h>
+#include <Library/MemoryAllocationLib.h>
+#include <Library/DevicePathLib.h>
+#include <Library/UefiBootServicesTableLib.h>
+#include <Library/BaseCryptLib.h>
+#include <Library/PeCoffLib.h>
+#include <Library/SecurityManagementLib.h>
+#include <Library/HobLib.h>
+
+//
+// Flag to check GPT partition. It only need be measured once.
+//
+BOOLEAN mTrEEMeasureGptTableFlag = FALSE;
+EFI_GUID mTrEEZeroGuid = {0, 0, 0, {0, 0, 0, 0, 0, 0, 0, 0}};
+UINTN mTrEEMeasureGptCount = 0;
+VOID *mTrEEFileBuffer;
+UINTN mTrEEImageSize;
+//
+// Measured FV handle cache
+//
+EFI_HANDLE mTrEECacheMeasuredHandle = NULL;
+MEASURED_HOB_DATA *mTrEEMeasuredHobData = NULL;
+
+/**
+ Reads contents of a PE/COFF image in memory buffer.
+
+ Caution: This function may receive untrusted input.
+ PE/COFF image is external input, so this function will make sure the PE/COFF image content
+ read is within the image buffer.
+
+ @param FileHandle Pointer to the file handle to read the PE/COFF image.
+ @param FileOffset Offset into the PE/COFF image to begin the read operation.
+ @param ReadSize On input, the size in bytes of the requested read operation.
+ On output, the number of bytes actually read.
+ @param Buffer Output buffer that contains the data read from the PE/COFF image.
+
+ @retval EFI_SUCCESS The specified portion of the PE/COFF image was read and the size
+**/
+EFI_STATUS
+EFIAPI
+DxeTpm2MeasureBootLibImageRead (
+ IN VOID *FileHandle,
+ IN UINTN FileOffset,
+ IN OUT UINTN *ReadSize,
+ OUT VOID *Buffer
+ )
+{
+ UINTN EndPosition;
+
+ if (FileHandle == NULL || ReadSize == NULL || Buffer == NULL) {
+ return EFI_INVALID_PARAMETER;
+ }
+
+ if (MAX_ADDRESS - FileOffset < *ReadSize) {
+ return EFI_INVALID_PARAMETER;
+ }
+
+ EndPosition = FileOffset + *ReadSize;
+ if (EndPosition > mTrEEImageSize) {
+ *ReadSize = (UINT32)(mTrEEImageSize - FileOffset);
+ }
+
+ if (FileOffset >= mTrEEImageSize) {
+ *ReadSize = 0;
+ }
+
+ CopyMem (Buffer, (UINT8 *)((UINTN) FileHandle + FileOffset), *ReadSize);
+
+ return EFI_SUCCESS;
+}
+
+/**
+ Measure GPT table data into TPM log.
+
+ Caution: This function may receive untrusted input.
+ The GPT partition table is external input, so this function should parse partition data carefully.
+
+ @param TreeProtocol Pointer to the located TREE protocol instance.
+ @param GptHandle Handle that GPT partition was installed.
+
+ @retval EFI_SUCCESS Successfully measure GPT table.
+ @retval EFI_UNSUPPORTED Not support GPT table on the given handle.
+ @retval EFI_DEVICE_ERROR Can't get GPT table because device error.
+ @retval EFI_OUT_OF_RESOURCES No enough resource to measure GPT table.
+ @retval other error value
+**/
+EFI_STATUS
+EFIAPI
+TrEEMeasureGptTable (
+ IN EFI_TREE_PROTOCOL *TreeProtocol,
+ IN EFI_HANDLE GptHandle
+ )
+{
+ EFI_STATUS Status;
+ EFI_BLOCK_IO_PROTOCOL *BlockIo;
+ EFI_DISK_IO_PROTOCOL *DiskIo;
+ EFI_PARTITION_TABLE_HEADER *PrimaryHeader;
+ EFI_PARTITION_ENTRY *PartitionEntry;
+ UINT8 *EntryPtr;
+ UINTN NumberOfPartition;
+ UINT32 Index;
+ TrEE_EVENT *TreeEvent;
+ EFI_GPT_DATA *GptData;
+ UINT32 EventSize;
+
+ if (mTrEEMeasureGptCount > 0) {
+ return EFI_SUCCESS;
+ }
+
+ Status = gBS->HandleProtocol (GptHandle, &gEfiBlockIoProtocolGuid, (VOID**)&BlockIo);
+ if (EFI_ERROR (Status)) {
+ return EFI_UNSUPPORTED;
+ }
+ Status = gBS->HandleProtocol (GptHandle, &gEfiDiskIoProtocolGuid, (VOID**)&DiskIo);
+ if (EFI_ERROR (Status)) {
+ return EFI_UNSUPPORTED;
+ }
+ //
+ // Read the EFI Partition Table Header
+ //
+ PrimaryHeader = (EFI_PARTITION_TABLE_HEADER *) AllocatePool (BlockIo->Media->BlockSize);
+ if (PrimaryHeader == NULL) {
+ return EFI_OUT_OF_RESOURCES;
+ }
+ Status = DiskIo->ReadDisk (
+ DiskIo,
+ BlockIo->Media->MediaId,
+ 1 * BlockIo->Media->BlockSize,
+ BlockIo->Media->BlockSize,
+ (UINT8 *)PrimaryHeader
+ );
+ if (EFI_ERROR (Status)) {
+ DEBUG ((EFI_D_ERROR, "Failed to Read Partition Table Header!\n"));
+ FreePool (PrimaryHeader);
+ return EFI_DEVICE_ERROR;
+ }
+ //
+ // Read the partition entry.
+ //
+ EntryPtr = (UINT8 *)AllocatePool (PrimaryHeader->NumberOfPartitionEntries * PrimaryHeader->SizeOfPartitionEntry);
+ if (EntryPtr == NULL) {
+ FreePool (PrimaryHeader);
+ return EFI_OUT_OF_RESOURCES;
+ }
+ Status = DiskIo->ReadDisk (
+ DiskIo,
+ BlockIo->Media->MediaId,
+ MultU64x32(PrimaryHeader->PartitionEntryLBA, BlockIo->Media->BlockSize),
+ PrimaryHeader->NumberOfPartitionEntries * PrimaryHeader->SizeOfPartitionEntry,
+ EntryPtr
+ );
+ if (EFI_ERROR (Status)) {
+ FreePool (PrimaryHeader);
+ FreePool (EntryPtr);
+ return EFI_DEVICE_ERROR;
+ }
+
+ //
+ // Count the valid partition
+ //
+ PartitionEntry = (EFI_PARTITION_ENTRY *)EntryPtr;
+ NumberOfPartition = 0;
+ for (Index = 0; Index < PrimaryHeader->NumberOfPartitionEntries; Index++) {
+ if (!CompareGuid (&PartitionEntry->PartitionTypeGUID, &mTrEEZeroGuid)) {
+ NumberOfPartition++;
+ }
+ PartitionEntry = (EFI_PARTITION_ENTRY *)((UINT8 *)PartitionEntry + PrimaryHeader->SizeOfPartitionEntry);
+ }
+
+ //
+ // Prepare Data for Measurement
+ //
+ EventSize = (UINT32)(sizeof (EFI_GPT_DATA) - sizeof (GptData->Partitions)
+ + NumberOfPartition * PrimaryHeader->SizeOfPartitionEntry);
+ TreeEvent = (TrEE_EVENT *) AllocateZeroPool (EventSize + sizeof (TrEE_EVENT) - sizeof(TreeEvent->Event));
+ if (TreeEvent == NULL) {
+ FreePool (PrimaryHeader);
+ FreePool (EntryPtr);
+ return EFI_OUT_OF_RESOURCES;
+ }
+
+ TreeEvent->Size = EventSize + sizeof (TrEE_EVENT) - sizeof(TreeEvent->Event);
+ TreeEvent->Header.HeaderSize = sizeof(TrEE_EVENT_HEADER);
+ TreeEvent->Header.HeaderVersion = TREE_EVENT_HEADER_VERSION;
+ TreeEvent->Header.PCRIndex = 5;
+ TreeEvent->Header.EventType = EV_EFI_GPT_EVENT;
+ GptData = (EFI_GPT_DATA *) TreeEvent->Event;
+
+ //
+ // Copy the EFI_PARTITION_TABLE_HEADER and NumberOfPartition
+ //
+ CopyMem ((UINT8 *)GptData, (UINT8*)PrimaryHeader, sizeof (EFI_PARTITION_TABLE_HEADER));
+ GptData->NumberOfPartitions = NumberOfPartition;
+ //
+ // Copy the valid partition entry
+ //
+ PartitionEntry = (EFI_PARTITION_ENTRY*)EntryPtr;
+ NumberOfPartition = 0;
+ for (Index = 0; Index < PrimaryHeader->NumberOfPartitionEntries; Index++) {
+ if (!CompareGuid (&PartitionEntry->PartitionTypeGUID, &mTrEEZeroGuid)) {
+ CopyMem (
+ (UINT8 *)&GptData->Partitions + NumberOfPartition * PrimaryHeader->SizeOfPartitionEntry,
+ (UINT8 *)PartitionEntry,
+ PrimaryHeader->SizeOfPartitionEntry
+ );
+ NumberOfPartition++;
+ }
+ PartitionEntry =(EFI_PARTITION_ENTRY *)((UINT8 *)PartitionEntry + PrimaryHeader->SizeOfPartitionEntry);
+ }
+
+ //
+ // Measure the GPT data
+ //
+ Status = TreeProtocol->HashLogExtendEvent (
+ TreeProtocol,
+ 0,
+ (EFI_PHYSICAL_ADDRESS) (UINTN) (VOID *) GptData,
+ (UINT64) EventSize,
+ TreeEvent
+ );
+ if (!EFI_ERROR (Status)) {
+ mTrEEMeasureGptCount++;
+ }
+
+ FreePool (PrimaryHeader);
+ FreePool (EntryPtr);
+ FreePool (TreeEvent);
+
+ return Status;
+}
+
+/**
+ Measure PE image into TPM log based on the authenticode image hashing in
+ PE/COFF Specification 8.0 Appendix A.
+
+ Caution: This function may receive untrusted input.
+ PE/COFF image is external input, so this function will validate its data structure
+ within this image buffer before use.
+
+ @param[in] TreeProtocol Pointer to the located TREE protocol instance.
+ @param[in] ImageAddress Start address of image buffer.
+ @param[in] ImageSize Image size
+ @param[in] LinkTimeBase Address that the image is loaded into memory.
+ @param[in] ImageType Image subsystem type.
+ @param[in] FilePath File path is corresponding to the input image.
+
+ @retval EFI_SUCCESS Successfully measure image.
+ @retval EFI_OUT_OF_RESOURCES No enough resource to measure image.
+ @retval EFI_UNSUPPORTED ImageType is unsupported or PE image is mal-format.
+ @retval other error value
+
+**/
+EFI_STATUS
+EFIAPI
+TrEEMeasurePeImage (
+ IN EFI_TREE_PROTOCOL *TreeProtocol,
+ IN EFI_PHYSICAL_ADDRESS ImageAddress,
+ IN UINTN ImageSize,
+ IN UINTN LinkTimeBase,
+ IN UINT16 ImageType,
+ IN EFI_DEVICE_PATH_PROTOCOL *FilePath
+ )
+{
+ EFI_STATUS Status;
+ TrEE_EVENT *TreeEvent;
+ EFI_IMAGE_LOAD_EVENT *ImageLoad;
+ UINT32 FilePathSize;
+ UINT32 EventSize;
+
+ Status = EFI_UNSUPPORTED;
+ ImageLoad = NULL;
+ FilePathSize = (UINT32) GetDevicePathSize (FilePath);
+
+ //
+ // Determine destination PCR by BootPolicy
+ //
+ EventSize = sizeof (*ImageLoad) - sizeof (ImageLoad->DevicePath) + FilePathSize;
+ TreeEvent = AllocateZeroPool (EventSize + sizeof (TrEE_EVENT) - sizeof(TreeEvent->Event));
+ if (TreeEvent == NULL) {
+ return EFI_OUT_OF_RESOURCES;
+ }
+
+ TreeEvent->Size = EventSize + sizeof (TrEE_EVENT) - sizeof(TreeEvent->Event);
+ TreeEvent->Header.HeaderSize = sizeof(TrEE_EVENT_HEADER);
+ TreeEvent->Header.HeaderVersion = TREE_EVENT_HEADER_VERSION;
+ ImageLoad = (EFI_IMAGE_LOAD_EVENT *) TreeEvent->Event;
+
+ switch (ImageType) {
+ case EFI_IMAGE_SUBSYSTEM_EFI_APPLICATION:
+ TreeEvent->Header.EventType = EV_EFI_BOOT_SERVICES_APPLICATION;
+ TreeEvent->Header.PCRIndex = 4;
+ break;
+ case EFI_IMAGE_SUBSYSTEM_EFI_BOOT_SERVICE_DRIVER:
+ TreeEvent->Header.EventType = EV_EFI_BOOT_SERVICES_DRIVER;
+ TreeEvent->Header.PCRIndex = 2;
+ break;
+ case EFI_IMAGE_SUBSYSTEM_EFI_RUNTIME_DRIVER:
+ TreeEvent->Header.EventType = EV_EFI_RUNTIME_SERVICES_DRIVER;
+ TreeEvent->Header.PCRIndex = 2;
+ break;
+ default:
+ DEBUG ((
+ EFI_D_ERROR,
+ "TrEEMeasurePeImage: Unknown subsystem type %d",
+ ImageType
+ ));
+ goto Finish;
+ }
+
+ ImageLoad->ImageLocationInMemory = ImageAddress;
+ ImageLoad->ImageLengthInMemory = ImageSize;
+ ImageLoad->ImageLinkTimeAddress = LinkTimeBase;
+ ImageLoad->LengthOfDevicePath = FilePathSize;
+ CopyMem (ImageLoad->DevicePath, FilePath, FilePathSize);
+
+ //
+ // Log the PE data
+ //
+ Status = TreeProtocol->HashLogExtendEvent (
+ TreeProtocol,
+ PE_COFF_IMAGE,
+ ImageAddress,
+ ImageSize,
+ TreeEvent
+ );
+ if (Status == EFI_VOLUME_FULL) {
+ //
+ // Volume full here means the image is hashed and its result is extended to PCR.
+ // But the event log cann't be saved since log area is full.
+ // Just return EFI_SUCCESS in order not to block the image load.
+ //
+ Status = EFI_SUCCESS;
+ }
+
+Finish:
+ FreePool (TreeEvent);
+
+ return Status;
+}
+
+/**
+ The security handler is used to abstract platform-specific policy
+ from the DXE core response to an attempt to use a file that returns a
+ given status for the authentication check from the section extraction protocol.
+
+ The possible responses in a given SAP implementation may include locking
+ flash upon failure to authenticate, attestation logging for all signed drivers,
+ and other exception operations. The File parameter allows for possible logging
+ within the SAP of the driver.
+
+ If File is NULL, then EFI_INVALID_PARAMETER is returned.
+
+ If the file specified by File with an authentication status specified by
+ AuthenticationStatus is safe for the DXE Core to use, then EFI_SUCCESS is returned.
+
+ If the file specified by File with an authentication status specified by
+ AuthenticationStatus is not safe for the DXE Core to use under any circumstances,
+ then EFI_ACCESS_DENIED is returned.
+
+ If the file specified by File with an authentication status specified by
+ AuthenticationStatus is not safe for the DXE Core to use right now, but it
+ might be possible to use it at a future time, then EFI_SECURITY_VIOLATION is
+ returned.
+
+ @param[in] AuthenticationStatus This is the authentication status returned
+ from the securitymeasurement services for the
+ input file.
+ @param[in] File This is a pointer to the device path of the file that is
+ being dispatched. This will optionally be used for logging.
+ @param[in] FileBuffer File buffer matches the input file device path.
+ @param[in] FileSize Size of File buffer matches the input file device path.
+ @param[in] BootPolicy A boot policy that was used to call LoadImage() UEFI service.
+
+ @retval EFI_SUCCESS The file specified by DevicePath and non-NULL
+ FileBuffer did authenticate, and the platform policy dictates
+ that the DXE Foundation may use the file.
+ @retval other error value
+**/
+EFI_STATUS
+EFIAPI
+DxeTpm2MeasureBootHandler (
+ IN UINT32 AuthenticationStatus,
+ IN CONST EFI_DEVICE_PATH_PROTOCOL *File,
+ IN VOID *FileBuffer,
+ IN UINTN FileSize,
+ IN BOOLEAN BootPolicy
+ )
+{
+ EFI_TREE_PROTOCOL *TreeProtocol;
+ EFI_STATUS Status;
+ TREE_BOOT_SERVICE_CAPABILITY ProtocolCapability;
+ EFI_DEVICE_PATH_PROTOCOL *DevicePathNode;
+ EFI_DEVICE_PATH_PROTOCOL *OrigDevicePathNode;
+ EFI_HANDLE Handle;
+ EFI_HANDLE TempHandle;
+ BOOLEAN ApplicationRequired;
+ PE_COFF_LOADER_IMAGE_CONTEXT ImageContext;
+ EFI_FIRMWARE_VOLUME_BLOCK_PROTOCOL *FvbProtocol;
+ EFI_PHYSICAL_ADDRESS FvAddress;
+ UINT32 Index;
+
+ Status = gBS->LocateProtocol (&gEfiTrEEProtocolGuid, NULL, (VOID **) &TreeProtocol);
+ if (EFI_ERROR (Status)) {
+ //
+ // TrEE protocol is not installed. So, TPM2 is not present.
+ // Don't do any measurement, and directly return EFI_SUCCESS.
+ //
+ DEBUG ((EFI_D_ERROR, "DxeTpm2MeasureBootHandler - TrEE - %r\n", Status));
+ return EFI_SUCCESS;
+ }
+
+ ProtocolCapability.Size = (UINT8) sizeof (ProtocolCapability);
+ Status = TreeProtocol->GetCapability (
+ TreeProtocol,
+ &ProtocolCapability
+ );
+ if (EFI_ERROR (Status) || !ProtocolCapability.TrEEPresentFlag) {
+ //
+ // TPM device doesn't work or activate.
+ //
+ DEBUG ((EFI_D_ERROR, "DxeTpm2MeasureBootHandler (%r) - TrEEPresentFlag - %x\n", Status, ProtocolCapability.TrEEPresentFlag));
+ return EFI_SUCCESS;
+ }
+
+ //
+ // Copy File Device Path
+ //
+ OrigDevicePathNode = DuplicateDevicePath (File);
+
+ //
+ // 1. Check whether this device path support BlockIo protocol.
+ // Is so, this device path may be a GPT device path.
+ //
+ DevicePathNode = OrigDevicePathNode;
+ Status = gBS->LocateDevicePath (&gEfiBlockIoProtocolGuid, &DevicePathNode, &Handle);
+ if (!EFI_ERROR (Status) && !mTrEEMeasureGptTableFlag) {
+ //
+ // Find the gpt partion on the given devicepath
+ //
+ DevicePathNode = OrigDevicePathNode;
+ ASSERT (DevicePathNode != NULL);
+ while (!IsDevicePathEnd (DevicePathNode)) {
+ //
+ // Find the Gpt partition
+ //
+ if (DevicePathType (DevicePathNode) == MEDIA_DEVICE_PATH &&
+ DevicePathSubType (DevicePathNode) == MEDIA_HARDDRIVE_DP) {
+ //
+ // Check whether it is a gpt partition or not
+ //
+ if (((HARDDRIVE_DEVICE_PATH *) DevicePathNode)->MBRType == MBR_TYPE_EFI_PARTITION_TABLE_HEADER &&
+ ((HARDDRIVE_DEVICE_PATH *) DevicePathNode)->SignatureType == SIGNATURE_TYPE_GUID) {
+
+ //
+ // Change the partition device path to its parent device path (disk) and get the handle.
+ //
+ DevicePathNode->Type = END_DEVICE_PATH_TYPE;
+ DevicePathNode->SubType = END_ENTIRE_DEVICE_PATH_SUBTYPE;
+ DevicePathNode = OrigDevicePathNode;
+ Status = gBS->LocateDevicePath (
+ &gEfiDiskIoProtocolGuid,
+ &DevicePathNode,
+ &Handle
+ );
+ if (!EFI_ERROR (Status)) {
+ //
+ // Measure GPT disk.
+ //
+ Status = TrEEMeasureGptTable (TreeProtocol, Handle);
+ DEBUG ((EFI_D_ERROR, "DxeTpm2MeasureBootHandler - TrEEMeasureGptTable - %r\n", Status));
+ if (!EFI_ERROR (Status)) {
+ //
+ // GPT disk check done.
+ //
+ mTrEEMeasureGptTableFlag = TRUE;
+ }
+ }
+ FreePool (OrigDevicePathNode);
+ OrigDevicePathNode = DuplicateDevicePath (File);
+ ASSERT (OrigDevicePathNode != NULL);
+ break;
+ }
+ }
+ DevicePathNode = NextDevicePathNode (DevicePathNode);
+ }
+ }
+
+ //
+ // 2. Measure PE image.
+ //
+ ApplicationRequired = FALSE;
+
+ //
+ // Check whether this device path support FVB protocol.
+ //
+ DevicePathNode = OrigDevicePathNode;
+ Status = gBS->LocateDevicePath (&gEfiFirmwareVolumeBlockProtocolGuid, &DevicePathNode, &Handle);
+ if (!EFI_ERROR (Status)) {
+ //
+ // Don't check FV image, and directly return EFI_SUCCESS.
+ // It can be extended to the specific FV authentication according to the different requirement.
+ //
+ if (IsDevicePathEnd (DevicePathNode)) {
+ return EFI_SUCCESS;
+ }
+ //
+ // The PE image from unmeasured Firmware volume need be measured
+ // The PE image from measured Firmware volume will be mearsured according to policy below.
+ // If it is driver, do not measure
+ // If it is application, still measure.
+ //
+ ApplicationRequired = TRUE;
+
+ if (mTrEECacheMeasuredHandle != Handle && mTrEEMeasuredHobData != NULL) {
+ //
+ // Search for Root FV of this PE image
+ //
+ TempHandle = Handle;
+ do {
+ Status = gBS->HandleProtocol(
+ TempHandle,
+ &gEfiFirmwareVolumeBlockProtocolGuid,
+ (VOID**)&FvbProtocol
+ );
+ TempHandle = FvbProtocol->ParentHandle;
+ } while (!EFI_ERROR(Status) && FvbProtocol->ParentHandle != NULL);
+
+ //
+ // Search in measured FV Hob
+ //
+ Status = FvbProtocol->GetPhysicalAddress(FvbProtocol, &FvAddress);
+ if (EFI_ERROR(Status)){
+ return Status;
+ }
+
+ ApplicationRequired = FALSE;
+
+ for (Index = 0; Index < mTrEEMeasuredHobData->Num; Index++) {
+ if(mTrEEMeasuredHobData->MeasuredFvBuf[Index].BlobBase == FvAddress) {
+ //
+ // Cache measured FV for next measurement
+ //
+ mTrEECacheMeasuredHandle = Handle;
+ ApplicationRequired = TRUE;
+ break;
+ }
+ }
+ }
+ }
+
+ //
+ // File is not found.
+ //
+ if (FileBuffer == NULL) {
+ Status = EFI_SECURITY_VIOLATION;
+ goto Finish;
+ }
+
+ mTrEEImageSize = FileSize;
+ mTrEEFileBuffer = FileBuffer;
+
+ //
+ // Measure PE Image
+ //
+ DevicePathNode = OrigDevicePathNode;
+ ZeroMem (&ImageContext, sizeof (ImageContext));
+ ImageContext.Handle = (VOID *) FileBuffer;
+ ImageContext.ImageRead = (PE_COFF_LOADER_READ_FILE) DxeTpm2MeasureBootLibImageRead;
+
+ //
+ // Get information about the image being loaded
+ //
+ Status = PeCoffLoaderGetImageInfo (&ImageContext);
+ if (EFI_ERROR (Status)) {
+ //
+ // The information can't be got from the invalid PeImage
+ //
+ goto Finish;
+ }
+
+ //
+ // Measure only application if Application flag is set
+ // Measure drivers and applications if Application flag is not set
+ //
+ if ((!ApplicationRequired) ||
+ (ApplicationRequired && ImageContext.ImageType == EFI_IMAGE_SUBSYSTEM_EFI_APPLICATION)) {
+ //
+ // Print the image path to be measured.
+ //
+ DEBUG_CODE_BEGIN ();
+ CHAR16 *ToText;
+ ToText = ConvertDevicePathToText (
+ DevicePathNode,
+ FALSE,
+ TRUE
+ );
+ if (ToText != NULL) {
+ DEBUG ((DEBUG_INFO, "The measured image path is %s.\n", ToText));
+ FreePool (ToText);
+ }
+ DEBUG_CODE_END ();
+
+ //
+ // Measure PE image into TPM log.
+ //
+ Status = TrEEMeasurePeImage (
+ TreeProtocol,
+ (EFI_PHYSICAL_ADDRESS) (UINTN) FileBuffer,
+ FileSize,
+ (UINTN) ImageContext.ImageAddress,
+ ImageContext.ImageType,
+ DevicePathNode
+ );
+ DEBUG ((EFI_D_ERROR, "DxeTpm2MeasureBootHandler - TrEEMeasurePeImage - %r\n", Status));
+ }
+
+ //
+ // Done, free the allocated resource.
+ //
+Finish:
+ if (OrigDevicePathNode != NULL) {
+ FreePool (OrigDevicePathNode);
+ }
+
+ DEBUG ((EFI_D_ERROR, "DxeTpm2MeasureBootHandler - %r\n", Status));
+
+ return Status;
+}
+
+/**
+ Register the security handler to provide TPM measure boot service.
+
+ @param ImageHandle ImageHandle of the loaded driver.
+ @param SystemTable Pointer to the EFI System Table.
+
+ @retval EFI_SUCCESS Register successfully.
+ @retval EFI_OUT_OF_RESOURCES No enough memory to register this handler.
+**/
+EFI_STATUS
+EFIAPI
+DxeTpm2MeasureBootLibConstructor (
+ IN EFI_HANDLE ImageHandle,
+ IN EFI_SYSTEM_TABLE *SystemTable
+ )
+{
+ EFI_HOB_GUID_TYPE *GuidHob;
+
+ GuidHob = NULL;
+
+ GuidHob = GetFirstGuidHob (&gMeasuredFvHobGuid);
+
+ if (GuidHob != NULL) {
+ mTrEEMeasuredHobData = GET_GUID_HOB_DATA (GuidHob);
+ }
+
+ return RegisterSecurity2Handler (
+ DxeTpm2MeasureBootHandler,
+ EFI_AUTH_OPERATION_MEASURE_IMAGE | EFI_AUTH_OPERATION_IMAGE_REQUIRED
+ );
+}
diff --git a/SecurityPkg/Library/DxeTpm2MeasureBootLib/DxeTpm2MeasureBootLib.inf b/SecurityPkg/Library/DxeTpm2MeasureBootLib/DxeTpm2MeasureBootLib.inf
new file mode 100644
index 000000000..4dfd62bd7
--- /dev/null
+++ b/SecurityPkg/Library/DxeTpm2MeasureBootLib/DxeTpm2MeasureBootLib.inf
@@ -0,0 +1,63 @@
+## @file
+# The library instance provides security service of TPM2 measure boot.
+#
+# Caution: This module requires additional review when modified.
+# This library will have external input - PE/COFF image and GPT partition.
+# This external input must be validated carefully to avoid security issue like
+# buffer overflow, integer overflow.
+#
+# Copyright (c) 2013, 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.
+#
+##
+
+[Defines]
+ INF_VERSION = 0x00010005
+ BASE_NAME = DxeTpm2MeasureBootLib
+ FILE_GUID = 778CE4F4-36BD-4ae7-B8F0-10B420B0D174
+ MODULE_TYPE = DXE_DRIVER
+ VERSION_STRING = 1.0
+ LIBRARY_CLASS = NULL|DXE_DRIVER DXE_RUNTIME_DRIVER DXE_SAL_DRIVER DXE_SMM_DRIVER UEFI_APPLICATION UEFI_DRIVER
+ CONSTRUCTOR = DxeTpm2MeasureBootLibConstructor
+
+#
+# The following information is for reference only and not required by the build tools.
+#
+# VALID_ARCHITECTURES = IA32 X64 IPF EBC
+#
+
+[Sources]
+ DxeTpm2MeasureBootLib.c
+
+[Packages]
+ MdePkg/MdePkg.dec
+ MdeModulePkg/MdeModulePkg.dec
+ SecurityPkg/SecurityPkg.dec
+ CryptoPkg/CryptoPkg.dec
+
+[LibraryClasses]
+ BaseMemoryLib
+ DebugLib
+ MemoryAllocationLib
+ DevicePathLib
+ UefiBootServicesTableLib
+ BaseCryptLib
+ PeCoffLib
+ BaseLib
+ SecurityManagementLib
+ HobLib
+
+[Guids]
+ gMeasuredFvHobGuid
+
+[Protocols]
+ gEfiTrEEProtocolGuid ## CONSUMES
+ gEfiFirmwareVolumeBlockProtocolGuid ## CONSUMES
+ gEfiBlockIoProtocolGuid ## CONSUMES
+ gEfiDiskIoProtocolGuid ## CONSUMES
+
diff --git a/SecurityPkg/Library/DxeTpmMeasurementLib/DxeTpmMeasurementLib.c b/SecurityPkg/Library/DxeTpmMeasurementLib/DxeTpmMeasurementLib.c
index b4732bc6f..ffeac59ba 100644
--- a/SecurityPkg/Library/DxeTpmMeasurementLib/DxeTpmMeasurementLib.c
+++ b/SecurityPkg/Library/DxeTpmMeasurementLib/DxeTpmMeasurementLib.c
@@ -1,7 +1,7 @@
/** @file
This library is used by other modules to measure data to TPM.
-Copyright (c) 2012, Intel Corporation. All rights reserved. <BR>
+Copyright (c) 2012 - 2013, 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,6 +15,7 @@ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
#include <PiDxe.h>
#include <Protocol/TcgService.h>
+#include <Protocol/TrEEProtocol.h>
#include <Library/BaseMemoryLib.h>
#include <Library/MemoryAllocationLib.h>
@@ -94,6 +95,67 @@ Tpm12MeasureAndLogData (
}
/**
+ Tpm20 measure and log data, and extend the measurement result into a specific PCR.
+
+ @param[in] PcrIndex PCR Index.
+ @param[in] EventType Event type.
+ @param[in] EventLog Measurement event log.
+ @param[in] LogLen Event log length in bytes.
+ @param[in] HashData The start of the data buffer to be hashed, extended.
+ @param[in] HashDataLen The length, in bytes, of the buffer referenced by HashData
+
+ @retval EFI_SUCCESS Operation completed successfully.
+ @retval EFI_UNSUPPORTED TPM device not available.
+ @retval EFI_OUT_OF_RESOURCES Out of memory.
+ @retval EFI_DEVICE_ERROR The operation was unsuccessful.
+**/
+EFI_STATUS
+Tpm20MeasureAndLogData (
+ IN UINT32 PcrIndex,
+ IN UINT32 EventType,
+ IN VOID *EventLog,
+ IN UINT32 LogLen,
+ IN VOID *HashData,
+ IN UINT64 HashDataLen
+ )
+{
+ EFI_STATUS Status;
+ EFI_TREE_PROTOCOL *TreeProtocol;
+ TrEE_EVENT *TreeEvent;
+
+ //
+ // TrEEPresentFlag is checked in HashLogExtendEvent
+ //
+ Status = gBS->LocateProtocol (&gEfiTrEEProtocolGuid, NULL, (VOID **) &TreeProtocol);
+ if (EFI_ERROR (Status)) {
+ return Status;
+ }
+
+ TreeEvent = (TrEE_EVENT *) AllocateZeroPool (LogLen + sizeof (TrEE_EVENT));
+ if(TreeEvent == NULL) {
+ return EFI_OUT_OF_RESOURCES;
+ }
+
+ TreeEvent->Size = (UINT32)LogLen + sizeof (TrEE_EVENT) - sizeof(TreeEvent->Event);
+ TreeEvent->Header.HeaderSize = sizeof(TrEE_EVENT_HEADER);
+ TreeEvent->Header.HeaderVersion = TREE_EVENT_HEADER_VERSION;
+ TreeEvent->Header.PCRIndex = PcrIndex;
+ TreeEvent->Header.EventType = EventType;
+ CopyMem (&TreeEvent->Event[0], EventLog, LogLen);
+
+ Status = TreeProtocol->HashLogExtendEvent (
+ TreeProtocol,
+ 0,
+ (EFI_PHYSICAL_ADDRESS)(UINTN)HashData,
+ HashDataLen,
+ TreeEvent
+ );
+ FreePool (TreeEvent);
+
+ return Status;
+}
+
+/**
Tpm measure and log data, and extend the measurement result into a specific PCR.
@param[in] PcrIndex PCR Index.
@@ -132,6 +194,19 @@ TpmMeasureAndLogData (
HashData,
HashDataLen
);
+ if (EFI_ERROR (Status)) {
+ //
+ // Try to measure using Tpm20 protocol
+ //
+ Status = Tpm20MeasureAndLogData(
+ PcrIndex,
+ EventType,
+ EventLog,
+ LogLen,
+ HashData,
+ HashDataLen
+ );
+ }
return Status;
}
diff --git a/SecurityPkg/Library/DxeTpmMeasurementLib/DxeTpmMeasurementLib.inf b/SecurityPkg/Library/DxeTpmMeasurementLib/DxeTpmMeasurementLib.inf
index a09900f55..75cc77307 100644
--- a/SecurityPkg/Library/DxeTpmMeasurementLib/DxeTpmMeasurementLib.inf
+++ b/SecurityPkg/Library/DxeTpmMeasurementLib/DxeTpmMeasurementLib.inf
@@ -1,7 +1,7 @@
## @file
-# This library is used by other modules to measure data to TPM 1.2.
+# This library is used by other modules to measure data to TPM 1.2 or TPM 2.0.
#
-# Copyright (c) 2012, Intel Corporation. All rights reserved.<BR>
+# Copyright (c) 2012 - 2013, 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,4 +40,5 @@
UefiBootServicesTableLib
[Protocols]
- gEfiTcgProtocolGuid \ No newline at end of file
+ gEfiTcgProtocolGuid
+ gEfiTrEEProtocolGuid
diff --git a/SecurityPkg/Library/DxeTrEEPhysicalPresenceLib/DxeTrEEPhysicalPresenceLib.c b/SecurityPkg/Library/DxeTrEEPhysicalPresenceLib/DxeTrEEPhysicalPresenceLib.c
new file mode 100644
index 000000000..28b809bce
--- /dev/null
+++ b/SecurityPkg/Library/DxeTrEEPhysicalPresenceLib/DxeTrEEPhysicalPresenceLib.c
@@ -0,0 +1,716 @@
+/** @file
+ Execute pending TPM2 requests from OS or BIOS.
+
+ Caution: This module requires additional review when modified.
+ This driver will have external input - variable.
+ This external input must be validated carefully to avoid security issue.
+
+ TrEEExecutePendingTpmRequest() will receive untrusted input and do validation.
+
+Copyright (c) 2013, 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.
+
+**/
+
+#include <PiDxe.h>
+
+#include <Protocol/TrEEProtocol.h>
+#include <Protocol/VariableLock.h>
+#include <Library/DebugLib.h>
+#include <Library/BaseMemoryLib.h>
+#include <Library/UefiRuntimeServicesTableLib.h>
+#include <Library/UefiDriverEntryPoint.h>
+#include <Library/UefiBootServicesTableLib.h>
+#include <Library/UefiLib.h>
+#include <Library/MemoryAllocationLib.h>
+#include <Library/PrintLib.h>
+#include <Library/HiiLib.h>
+#include <Guid/EventGroup.h>
+#include <Guid/TrEEPhysicalPresenceData.h>
+#include <Library/Tpm2CommandLib.h>
+
+#define TPM_PP_SUCCESS 0
+#define TPM_PP_USER_ABORT ((TPM_RESULT)(-0x10))
+#define TPM_PP_BIOS_FAILURE ((TPM_RESULT)(-0x0f))
+
+#define CONFIRM_BUFFER_SIZE 4096
+
+EFI_HII_HANDLE mTrEEPpStringPackHandle;
+
+/**
+ Get string by string id from HII Interface.
+
+ @param[in] Id String ID.
+
+ @retval CHAR16 * String from ID.
+ @retval NULL If error occurs.
+
+**/
+CHAR16 *
+TrEEPhysicalPresenceGetStringById (
+ IN EFI_STRING_ID Id
+ )
+{
+ return HiiGetString (mTrEEPpStringPackHandle, Id, NULL);
+}
+
+/**
+ Send ClearControl and Clear command to TPM.
+
+ @param[in] PlatformAuth platform auth value. NULL means no platform auth change.
+
+ @retval EFI_SUCCESS Operation completed successfully.
+ @retval EFI_TIMEOUT The register can't run into the expected status in time.
+ @retval EFI_BUFFER_TOO_SMALL Response data buffer is too small.
+ @retval EFI_DEVICE_ERROR Unexpected device behavior.
+
+**/
+EFI_STATUS
+EFIAPI
+TpmCommandClear (
+ IN TPM2B_AUTH *PlatformAuth OPTIONAL
+ )
+{
+ EFI_STATUS Status;
+ TPMS_AUTH_COMMAND *AuthSession;
+ TPMS_AUTH_COMMAND LocalAuthSession;
+
+ if (PlatformAuth == NULL) {
+ AuthSession = NULL;
+ } else {
+ AuthSession = &LocalAuthSession;
+ ZeroMem (&LocalAuthSession, sizeof(LocalAuthSession));
+ LocalAuthSession.sessionHandle = TPM_RS_PW;
+ LocalAuthSession.hmac.size = PlatformAuth->size;
+ CopyMem (LocalAuthSession.hmac.buffer, PlatformAuth->buffer, PlatformAuth->size);
+ }
+
+ DEBUG ((EFI_D_ERROR, "Tpm2ClearControl ... \n"));
+ Status = Tpm2ClearControl (TPM_RH_PLATFORM, AuthSession, NO);
+ DEBUG ((EFI_D_ERROR, "Tpm2ClearControl - %r\n", Status));
+ if (EFI_ERROR (Status)) {
+ goto Done;
+ }
+ DEBUG ((EFI_D_ERROR, "Tpm2Clear ... \n"));
+ Status = Tpm2Clear (TPM_RH_PLATFORM, AuthSession);
+ DEBUG ((EFI_D_ERROR, "Tpm2Clear - %r\n", Status));
+
+Done:
+ ZeroMem (&LocalAuthSession.hmac, sizeof(LocalAuthSession.hmac));
+ return Status;
+}
+
+/**
+ Execute physical presence operation requested by the OS.
+
+ @param[in] PlatformAuth platform auth value. NULL means no platform auth change.
+ @param[in] CommandCode Physical presence operation value.
+ @param[in, out] PpiFlags The physical presence interface flags.
+
+ @retval TPM_PP_BIOS_FAILURE Unknown physical presence operation.
+ @retval TPM_PP_BIOS_FAILURE Error occurred during sending command to TPM or
+ receiving response from TPM.
+ @retval Others Return code from the TPM device after command execution.
+**/
+TPM_RESULT
+TrEEExecutePhysicalPresence (
+ IN TPM2B_AUTH *PlatformAuth, OPTIONAL
+ IN UINT8 CommandCode,
+ IN OUT UINT8 *PpiFlags
+ )
+{
+ EFI_STATUS Status;
+
+ switch (CommandCode) {
+ case TREE_PHYSICAL_PRESENCE_CLEAR_CONTROL_CLEAR:
+ case TREE_PHYSICAL_PRESENCE_CLEAR_CONTROL_CLEAR_2:
+ case TREE_PHYSICAL_PRESENCE_CLEAR_CONTROL_CLEAR_3:
+ case TREE_PHYSICAL_PRESENCE_CLEAR_CONTROL_CLEAR_4:
+ Status = TpmCommandClear (PlatformAuth);
+ if (EFI_ERROR (Status)) {
+ return TPM_PP_BIOS_FAILURE;
+ } else {
+ return TPM_PP_SUCCESS;
+ }
+
+ case TREE_PHYSICAL_PRESENCE_SET_NO_PPI_CLEAR_FALSE:
+ *PpiFlags &= ~TREE_FLAG_NO_PPI_CLEAR;
+ return TPM_PP_SUCCESS;
+
+ case TREE_PHYSICAL_PRESENCE_SET_NO_PPI_CLEAR_TRUE:
+ *PpiFlags |= TREE_FLAG_NO_PPI_CLEAR;
+ return TPM_PP_SUCCESS;
+
+ default:
+ if (CommandCode <= TREE_PHYSICAL_PRESENCE_NO_ACTION_MAX) {
+ return TPM_PP_SUCCESS;
+ } else {
+ return TPM_PP_BIOS_FAILURE;
+ }
+ }
+}
+
+
+/**
+ Read the specified key for user confirmation.
+
+ @param[in] CautionKey If true, F12 is used as confirm key;
+ If false, F10 is used as confirm key.
+
+ @retval TRUE User confirmed the changes by input.
+ @retval FALSE User discarded the changes.
+**/
+BOOLEAN
+TrEEReadUserKey (
+ IN BOOLEAN CautionKey
+ )
+{
+ EFI_STATUS Status;
+ EFI_INPUT_KEY Key;
+ UINT16 InputKey;
+
+ InputKey = 0;
+ do {
+ Status = gBS->CheckEvent (gST->ConIn->WaitForKey);
+ if (!EFI_ERROR (Status)) {
+ Status = gST->ConIn->ReadKeyStroke (gST->ConIn, &Key);
+ if (Key.ScanCode == SCAN_ESC) {
+ InputKey = Key.ScanCode;
+ }
+ if ((Key.ScanCode == SCAN_F10) && !CautionKey) {
+ InputKey = Key.ScanCode;
+ }
+ if ((Key.ScanCode == SCAN_F12) && CautionKey) {
+ InputKey = Key.ScanCode;
+ }
+ }
+ } while (InputKey == 0);
+
+ if (InputKey != SCAN_ESC) {
+ return TRUE;
+ }
+
+ return FALSE;
+}
+
+/**
+ The constructor function register UNI strings into imageHandle.
+
+ It will ASSERT() if that operation fails and it will always return EFI_SUCCESS.
+
+ @param ImageHandle The firmware allocated handle for the EFI image.
+ @param SystemTable A pointer to the EFI System Table.
+
+ @retval EFI_SUCCESS The constructor successfully added string package.
+ @retval Other value The constructor can't add string package.
+**/
+EFI_STATUS
+EFIAPI
+TrEEPhysicalPresenceLibConstructor (
+ IN EFI_HANDLE ImageHandle,
+ IN EFI_SYSTEM_TABLE *SystemTable
+ )
+{
+ mTrEEPpStringPackHandle = HiiAddPackages (&gEfiTrEEPhysicalPresenceGuid, ImageHandle, DxeTrEEPhysicalPresenceLibStrings, NULL);
+ ASSERT (mTrEEPpStringPackHandle != NULL);
+
+ return EFI_SUCCESS;
+}
+
+/**
+ Display the confirm text and get user confirmation.
+
+ @param[in] TpmPpCommand The requested TPM physical presence command.
+
+ @retval TRUE The user has confirmed the changes.
+ @retval FALSE The user doesn't confirm the changes.
+**/
+BOOLEAN
+TrEEUserConfirm (
+ IN UINT8 TpmPpCommand
+ )
+{
+ CHAR16 *ConfirmText;
+ CHAR16 *TmpStr1;
+ CHAR16 *TmpStr2;
+ UINTN BufSize;
+ BOOLEAN CautionKey;
+ UINT16 Index;
+ CHAR16 DstStr[81];
+
+ TmpStr2 = NULL;
+ CautionKey = FALSE;
+ BufSize = CONFIRM_BUFFER_SIZE;
+ ConfirmText = AllocateZeroPool (BufSize);
+ ASSERT (ConfirmText != NULL);
+
+ switch (TpmPpCommand) {
+
+ case TREE_PHYSICAL_PRESENCE_CLEAR_CONTROL_CLEAR:
+ case TREE_PHYSICAL_PRESENCE_CLEAR_CONTROL_CLEAR_2:
+ case TREE_PHYSICAL_PRESENCE_CLEAR_CONTROL_CLEAR_3:
+ case TREE_PHYSICAL_PRESENCE_CLEAR_CONTROL_CLEAR_4:
+ CautionKey = TRUE;
+ TmpStr2 = TrEEPhysicalPresenceGetStringById (STRING_TOKEN (TPM_CLEAR));
+
+ TmpStr1 = TrEEPhysicalPresenceGetStringById (STRING_TOKEN (TPM_HEAD_STR));
+ UnicodeSPrint (ConfirmText, BufSize, TmpStr1, TmpStr2);
+ FreePool (TmpStr1);
+
+ TmpStr1 = TrEEPhysicalPresenceGetStringById (STRING_TOKEN (TPM_WARNING_CLEAR));
+ StrnCat (ConfirmText, TmpStr1, (BufSize / sizeof (CHAR16 *)) - StrLen (ConfirmText) - 1);
+ StrnCat (ConfirmText, L" \n\n", (BufSize / sizeof (CHAR16 *)) - StrLen (ConfirmText) - 1);
+ FreePool (TmpStr1);
+
+ TmpStr1 = TrEEPhysicalPresenceGetStringById (STRING_TOKEN (TPM_CAUTION_KEY));
+ StrnCat (ConfirmText, TmpStr1, (BufSize / sizeof (CHAR16 *)) - StrLen (ConfirmText) - 1);
+ FreePool (TmpStr1);
+ break;
+
+ case TREE_PHYSICAL_PRESENCE_SET_NO_PPI_CLEAR_TRUE:
+ CautionKey = TRUE;
+ TmpStr2 = TrEEPhysicalPresenceGetStringById (STRING_TOKEN (TPM_CLEAR));
+
+ TmpStr1 = TrEEPhysicalPresenceGetStringById (STRING_TOKEN (TPM_PPI_HEAD_STR));
+ UnicodeSPrint (ConfirmText, BufSize, TmpStr1, TmpStr2);
+ FreePool (TmpStr1);
+
+ TmpStr1 = TrEEPhysicalPresenceGetStringById (STRING_TOKEN (TPM_NOTE_CLEAR));
+ StrnCat (ConfirmText, TmpStr1, (BufSize / sizeof (CHAR16 *)) - StrLen (ConfirmText) - 1);
+ FreePool (TmpStr1);
+
+ TmpStr1 = TrEEPhysicalPresenceGetStringById (STRING_TOKEN (TPM_WARNING_CLEAR));
+ StrnCat (ConfirmText, TmpStr1, (BufSize / sizeof (CHAR16 *)) - StrLen (ConfirmText) - 1);
+ StrnCat (ConfirmText, L" \n\n", (BufSize / sizeof (CHAR16 *)) - StrLen (ConfirmText) - 1);
+ FreePool (TmpStr1);
+
+ TmpStr1 = TrEEPhysicalPresenceGetStringById (STRING_TOKEN (TPM_CAUTION_KEY));
+ StrnCat (ConfirmText, TmpStr1, (BufSize / sizeof (CHAR16 *)) - StrLen (ConfirmText) - 1);
+ FreePool (TmpStr1);
+
+ TmpStr1 = TrEEPhysicalPresenceGetStringById (STRING_TOKEN (TPM_NO_PPI_INFO));
+ StrnCat (ConfirmText, TmpStr1, (BufSize / sizeof (CHAR16 *)) - StrLen (ConfirmText) - 1);
+ FreePool (TmpStr1);
+ break;
+
+ default:
+ ;
+ }
+
+ if (TmpStr2 == NULL) {
+ FreePool (ConfirmText);
+ return FALSE;
+ }
+
+ TmpStr1 = TrEEPhysicalPresenceGetStringById (STRING_TOKEN (TPM_REJECT_KEY));
+ BufSize -= StrSize (ConfirmText);
+ UnicodeSPrint (ConfirmText + StrLen (ConfirmText), BufSize, TmpStr1, TmpStr2);
+
+ DstStr[80] = L'\0';
+ for (Index = 0; Index < StrLen (ConfirmText); Index += 80) {
+ StrnCpy(DstStr, ConfirmText + Index, 80);
+ Print (DstStr);
+ }
+
+ FreePool (TmpStr1);
+ FreePool (TmpStr2);
+ FreePool (ConfirmText);
+
+ if (TrEEReadUserKey (CautionKey)) {
+ return TRUE;
+ }
+
+ return FALSE;
+}
+
+/**
+ Check if there is a valid physical presence command request. Also updates parameter value
+ to whether the requested physical presence command already confirmed by user
+
+ @param[in] TcgPpData EFI TrEE Physical Presence request data.
+ @param[in] Flags The physical presence interface flags.
+ @param[out] RequestConfirmed If the physical presence operation command required user confirm from UI.
+ True, it indicates the command doesn't require user confirm, or already confirmed
+ in last boot cycle by user.
+ False, it indicates the command need user confirm from UI.
+
+ @retval TRUE Physical Presence operation command is valid.
+ @retval FALSE Physical Presence operation command is invalid.
+
+**/
+BOOLEAN
+TrEEHaveValidTpmRequest (
+ IN EFI_TREE_PHYSICAL_PRESENCE *TcgPpData,
+ IN UINT8 Flags,
+ OUT BOOLEAN *RequestConfirmed
+ )
+{
+ *RequestConfirmed = FALSE;
+
+ switch (TcgPpData->PPRequest) {
+ case TREE_PHYSICAL_PRESENCE_NO_ACTION:
+ *RequestConfirmed = TRUE;
+ return TRUE;
+ case TREE_PHYSICAL_PRESENCE_CLEAR_CONTROL_CLEAR:
+ case TREE_PHYSICAL_PRESENCE_CLEAR_CONTROL_CLEAR_2:
+ case TREE_PHYSICAL_PRESENCE_CLEAR_CONTROL_CLEAR_3:
+ case TREE_PHYSICAL_PRESENCE_CLEAR_CONTROL_CLEAR_4:
+ if ((Flags & TREE_FLAG_NO_PPI_CLEAR) != 0) {
+ *RequestConfirmed = TRUE;
+ }
+ break;
+
+ case TREE_PHYSICAL_PRESENCE_SET_NO_PPI_CLEAR_FALSE:
+ *RequestConfirmed = TRUE;
+ break;
+
+ case TREE_PHYSICAL_PRESENCE_SET_NO_PPI_CLEAR_TRUE:
+ break;
+
+ default:
+ //
+ // Wrong Physical Presence command
+ //
+ return FALSE;
+ }
+
+ if ((Flags & TREE_FLAG_RESET_TRACK) != 0) {
+ //
+ // It had been confirmed in last boot, it doesn't need confirm again.
+ //
+ *RequestConfirmed = TRUE;
+ }
+
+ //
+ // Physical Presence command is correct
+ //
+ return TRUE;
+}
+
+
+/**
+ Check and execute the requested physical presence command.
+
+ Caution: This function may receive untrusted input.
+ TcgPpData variable is external input, so this function will validate
+ its data structure to be valid value.
+
+ @param[in] PlatformAuth platform auth value. NULL means no platform auth change.
+ @param[in] TcgPpData Point to the physical presence NV variable.
+ @param[in] Flags The physical presence interface flags.
+**/
+VOID
+TrEEExecutePendingTpmRequest (
+ IN TPM2B_AUTH *PlatformAuth, OPTIONAL
+ IN EFI_TREE_PHYSICAL_PRESENCE *TcgPpData,
+ IN UINT8 Flags
+ )
+{
+ EFI_STATUS Status;
+ UINTN DataSize;
+ BOOLEAN RequestConfirmed;
+ UINT8 NewFlags;
+
+ if (TcgPpData->PPRequest == TREE_PHYSICAL_PRESENCE_NO_ACTION) {
+ //
+ // No operation request
+ //
+ return;
+ }
+
+ if (!TrEEHaveValidTpmRequest(TcgPpData, Flags, &RequestConfirmed)) {
+ //
+ // Invalid operation request.
+ //
+ if (TcgPpData->PPRequest <= TREE_PHYSICAL_PRESENCE_NO_ACTION_MAX) {
+ TcgPpData->PPResponse = TPM_PP_SUCCESS;
+ } else {
+ TcgPpData->PPResponse = TPM_PP_BIOS_FAILURE;
+ }
+ TcgPpData->LastPPRequest = TcgPpData->PPRequest;
+ TcgPpData->PPRequest = TREE_PHYSICAL_PRESENCE_NO_ACTION;
+ DataSize = sizeof (EFI_TREE_PHYSICAL_PRESENCE);
+ Status = gRT->SetVariable (
+ TREE_PHYSICAL_PRESENCE_VARIABLE,
+ &gEfiTrEEPhysicalPresenceGuid,
+ EFI_VARIABLE_NON_VOLATILE | EFI_VARIABLE_BOOTSERVICE_ACCESS | EFI_VARIABLE_RUNTIME_ACCESS,
+ DataSize,
+ TcgPpData
+ );
+ return;
+ }
+
+ if (!RequestConfirmed) {
+ //
+ // Print confirm text and wait for approval.
+ //
+ RequestConfirmed = TrEEUserConfirm (TcgPpData->PPRequest
+ );
+ }
+
+ //
+ // Execute requested physical presence command
+ //
+ TcgPpData->PPResponse = TPM_PP_USER_ABORT;
+ NewFlags = Flags;
+ if (RequestConfirmed) {
+ TcgPpData->PPResponse = TrEEExecutePhysicalPresence (PlatformAuth, TcgPpData->PPRequest,
+ &NewFlags);
+ }
+
+ //
+ // Save the flags if it is updated.
+ //
+ if (Flags != NewFlags) {
+ Status = gRT->SetVariable (
+ TREE_PHYSICAL_PRESENCE_FLAGS_VARIABLE,
+ &gEfiTrEEPhysicalPresenceGuid,
+ EFI_VARIABLE_NON_VOLATILE | EFI_VARIABLE_BOOTSERVICE_ACCESS | EFI_VARIABLE_RUNTIME_ACCESS,
+ sizeof (UINT8),
+ &NewFlags
+ );
+ }
+
+ //
+ // Clear request
+ //
+ if ((NewFlags & TREE_FLAG_RESET_TRACK) == 0) {
+ TcgPpData->LastPPRequest = TcgPpData->PPRequest;
+ TcgPpData->PPRequest = TREE_PHYSICAL_PRESENCE_NO_ACTION;
+ }
+
+ //
+ // Save changes
+ //
+ DataSize = sizeof (EFI_TREE_PHYSICAL_PRESENCE);
+ Status = gRT->SetVariable (
+ TREE_PHYSICAL_PRESENCE_VARIABLE,
+ &gEfiTrEEPhysicalPresenceGuid,
+ EFI_VARIABLE_NON_VOLATILE | EFI_VARIABLE_BOOTSERVICE_ACCESS | EFI_VARIABLE_RUNTIME_ACCESS,
+ DataSize,
+ TcgPpData
+ );
+ if (EFI_ERROR (Status)) {
+ return;
+ }
+
+ if (TcgPpData->PPResponse == TPM_PP_USER_ABORT) {
+ return;
+ }
+
+ //
+ // Reset system to make new TPM settings in effect
+ //
+ switch (TcgPpData->LastPPRequest) {
+ case TREE_PHYSICAL_PRESENCE_CLEAR_CONTROL_CLEAR:
+ case TREE_PHYSICAL_PRESENCE_CLEAR_CONTROL_CLEAR_2:
+ case TREE_PHYSICAL_PRESENCE_CLEAR_CONTROL_CLEAR_3:
+ case TREE_PHYSICAL_PRESENCE_CLEAR_CONTROL_CLEAR_4:
+ break;
+ default:
+ if (TcgPpData->PPRequest != TREE_PHYSICAL_PRESENCE_NO_ACTION) {
+ break;
+ }
+ return;
+ }
+
+ Print (L"Rebooting system to make TPM2 settings in effect\n");
+ gRT->ResetSystem (EfiResetCold, EFI_SUCCESS, 0, NULL);
+ ASSERT (FALSE);
+}
+
+/**
+ Check and execute the pending TPM request.
+
+ The TPM request may come from OS or BIOS. This API will display request information and wait
+ for user confirmation if TPM request exists. The TPM request will be sent to TPM device after
+ the TPM request is confirmed, and one or more reset may be required to make TPM request to
+ take effect.
+
+ This API should be invoked after console in and console out are all ready as they are required
+ to display request information and get user input to confirm the request.
+
+ @param[in] PlatformAuth platform auth value. NULL means no platform auth change.
+**/
+VOID
+EFIAPI
+TrEEPhysicalPresenceLibProcessRequest (
+ IN TPM2B_AUTH *PlatformAuth OPTIONAL
+ )
+{
+ EFI_STATUS Status;
+ UINTN DataSize;
+ EFI_TREE_PHYSICAL_PRESENCE TcgPpData;
+ EFI_TREE_PROTOCOL *TreeProtocol;
+ EDKII_VARIABLE_LOCK_PROTOCOL *VariableLockProtocol;
+ UINT8 PpiFlags;
+
+ Status = gBS->LocateProtocol (&gEfiTrEEProtocolGuid, NULL, (VOID **) &TreeProtocol);
+ if (EFI_ERROR (Status)) {
+ return ;
+ }
+
+ //
+ // Initialize physical presence flags.
+ //
+ DataSize = sizeof (UINT8);
+ Status = gRT->GetVariable (
+ TREE_PHYSICAL_PRESENCE_FLAGS_VARIABLE,
+ &gEfiTrEEPhysicalPresenceGuid,
+ NULL,
+ &DataSize,
+ &PpiFlags
+ );
+ if (EFI_ERROR (Status)) {
+ if (Status == EFI_NOT_FOUND) {
+ PpiFlags = 0;
+ Status = gRT->SetVariable (
+ TREE_PHYSICAL_PRESENCE_FLAGS_VARIABLE,
+ &gEfiTrEEPhysicalPresenceGuid,
+ EFI_VARIABLE_NON_VOLATILE | EFI_VARIABLE_BOOTSERVICE_ACCESS | EFI_VARIABLE_RUNTIME_ACCESS,
+ sizeof (UINT8),
+ &PpiFlags
+ );
+ }
+ ASSERT_EFI_ERROR (Status);
+ }
+ DEBUG ((EFI_D_ERROR, "[TPM2] PpiFlags = %x, Status = %r\n", PpiFlags, Status));
+
+ //
+ // This flags variable controls whether physical presence is required for TPM command.
+ // It should be protected from malicious software. We set it as read-only variable here.
+ //
+ Status = gBS->LocateProtocol (&gEdkiiVariableLockProtocolGuid, NULL, (VOID **)&VariableLockProtocol);
+ if (!EFI_ERROR (Status)) {
+ Status = VariableLockProtocol->RequestToLock (
+ VariableLockProtocol,
+ TREE_PHYSICAL_PRESENCE_FLAGS_VARIABLE,
+ &gEfiTrEEPhysicalPresenceGuid
+ );
+ if (EFI_ERROR (Status)) {
+ DEBUG ((EFI_D_ERROR, "[TPM2] Error when lock variable %s, Status = %r\n", TREE_PHYSICAL_PRESENCE_FLAGS_VARIABLE, Status));
+ ASSERT_EFI_ERROR (Status);
+ }
+ }
+
+ //
+ // Initialize physical presence variable.
+ //
+ DataSize = sizeof (EFI_TREE_PHYSICAL_PRESENCE);
+ Status = gRT->GetVariable (
+ TREE_PHYSICAL_PRESENCE_VARIABLE,
+ &gEfiTrEEPhysicalPresenceGuid,
+ NULL,
+ &DataSize,
+ &TcgPpData
+ );
+ if (EFI_ERROR (Status)) {
+ if (Status == EFI_NOT_FOUND) {
+ ZeroMem ((VOID*)&TcgPpData, sizeof (TcgPpData));
+ DataSize = sizeof (EFI_TREE_PHYSICAL_PRESENCE);
+ Status = gRT->SetVariable (
+ TREE_PHYSICAL_PRESENCE_VARIABLE,
+ &gEfiTrEEPhysicalPresenceGuid,
+ EFI_VARIABLE_NON_VOLATILE | EFI_VARIABLE_BOOTSERVICE_ACCESS | EFI_VARIABLE_RUNTIME_ACCESS,
+ DataSize,
+ &TcgPpData
+ );
+ }
+ ASSERT_EFI_ERROR (Status);
+ }
+
+ DEBUG ((EFI_D_ERROR, "[TPM2] Flags=%x, PPRequest=%x (LastPPRequest=%x)\n", PpiFlags, TcgPpData.PPRequest, TcgPpData.LastPPRequest));
+
+ //
+ // Execute pending TPM request.
+ //
+ TrEEExecutePendingTpmRequest (PlatformAuth, &TcgPpData, PpiFlags);
+ DEBUG ((EFI_D_ERROR, "[TPM2] PPResponse = %x (LastPPRequest=%x, Flags=%x)\n", TcgPpData.PPResponse, TcgPpData.LastPPRequest, PpiFlags));
+
+}
+
+/**
+ Check if the pending TPM request needs user input to confirm.
+
+ The TPM request may come from OS. This API will check if TPM request exists and need user
+ input to confirmation.
+
+ @retval TRUE TPM needs input to confirm user physical presence.
+ @retval FALSE TPM doesn't need input to confirm user physical presence.
+
+**/
+BOOLEAN
+EFIAPI
+TrEEPhysicalPresenceLibNeedUserConfirm(
+ VOID
+ )
+{
+ EFI_STATUS Status;
+ EFI_TREE_PHYSICAL_PRESENCE TcgPpData;
+ UINTN DataSize;
+ BOOLEAN RequestConfirmed;
+ EFI_TREE_PROTOCOL *TreeProtocol;
+ UINT8 PpiFlags;
+
+ Status = gBS->LocateProtocol (&gEfiTrEEProtocolGuid, NULL, (VOID **) &TreeProtocol);
+ if (EFI_ERROR (Status)) {
+ return FALSE;
+ }
+
+ //
+ // Check Tpm requests
+ //
+ DataSize = sizeof (EFI_TREE_PHYSICAL_PRESENCE);
+ Status = gRT->GetVariable (
+ TREE_PHYSICAL_PRESENCE_VARIABLE,
+ &gEfiTrEEPhysicalPresenceGuid,
+ NULL,
+ &DataSize,
+ &TcgPpData
+ );
+ if (EFI_ERROR (Status)) {
+ return FALSE;
+ }
+
+ DataSize = sizeof (UINT8);
+ Status = gRT->GetVariable (
+ TREE_PHYSICAL_PRESENCE_FLAGS_VARIABLE,
+ &gEfiTrEEPhysicalPresenceGuid,
+ NULL,
+ &DataSize,
+ &PpiFlags
+ );
+ if (EFI_ERROR (Status)) {
+ return FALSE;
+ }
+
+ if (TcgPpData.PPRequest == TREE_PHYSICAL_PRESENCE_NO_ACTION) {
+ //
+ // No operation request
+ //
+ return FALSE;
+ }
+
+ if (!TrEEHaveValidTpmRequest(&TcgPpData, PpiFlags, &RequestConfirmed)) {
+ //
+ // Invalid operation request.
+ //
+ return FALSE;
+ }
+
+ if (!RequestConfirmed) {
+ //
+ // Need UI to confirm
+ //
+ return TRUE;
+ }
+
+ return FALSE;
+}
+
diff --git a/SecurityPkg/Library/DxeTrEEPhysicalPresenceLib/DxeTrEEPhysicalPresenceLib.inf b/SecurityPkg/Library/DxeTrEEPhysicalPresenceLib/DxeTrEEPhysicalPresenceLib.inf
new file mode 100644
index 000000000..3ef9a82a4
--- /dev/null
+++ b/SecurityPkg/Library/DxeTrEEPhysicalPresenceLib/DxeTrEEPhysicalPresenceLib.inf
@@ -0,0 +1,59 @@
+## @file
+# TrEE physical presence library instance. This library will execute TPM2 request.
+#
+# Caution: This module requires additional review when modified.
+# This driver will have external input - variable.
+# This external input must be validated carefully to avoid security issue.
+#
+# Copyright (c) 2013, 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.
+#
+##
+
+[Defines]
+ INF_VERSION = 0x00010005
+ BASE_NAME = DxeTrEEPhysicalPresenceLib
+ FILE_GUID = 601ECB06-7874-489e-A280-805780F6C861
+ MODULE_TYPE = DXE_DRIVER
+ VERSION_STRING = 1.0
+ LIBRARY_CLASS = TrEEPhysicalPresenceLib|DXE_DRIVER DXE_RUNTIME_DRIVER DXE_SAL_DRIVER UEFI_APPLICATION UEFI_DRIVER
+ CONSTRUCTOR = TrEEPhysicalPresenceLibConstructor
+
+#
+# The following information is for reference only and not required by the build tools.
+#
+# VALID_ARCHITECTURES = IA32 X64 IPF EBC
+#
+
+[Sources]
+ DxeTrEEPhysicalPresenceLib.c
+ PhysicalPresenceStrings.uni
+
+[Packages]
+ MdePkg/MdePkg.dec
+ MdeModulePkg/MdeModulePkg.dec
+ SecurityPkg/SecurityPkg.dec
+
+[LibraryClasses]
+ MemoryAllocationLib
+ UefiLib
+ UefiBootServicesTableLib
+ UefiDriverEntryPoint
+ UefiRuntimeServicesTableLib
+ BaseMemoryLib
+ DebugLib
+ PrintLib
+ HiiLib
+ Tpm2CommandLib
+
+[Protocols]
+ gEfiTrEEProtocolGuid
+ gEdkiiVariableLockProtocolGuid
+
+[Guids]
+ gEfiTrEEPhysicalPresenceGuid
diff --git a/SecurityPkg/Library/DxeTrEEPhysicalPresenceLib/PhysicalPresenceStrings.uni b/SecurityPkg/Library/DxeTrEEPhysicalPresenceLib/PhysicalPresenceStrings.uni
new file mode 100644
index 000000000..26c10ac92
--- /dev/null
+++ b/SecurityPkg/Library/DxeTrEEPhysicalPresenceLib/PhysicalPresenceStrings.uni
Binary files differ
diff --git a/SecurityPkg/Library/HashInstanceLibSha1/HashInstanceLibSha1.c b/SecurityPkg/Library/HashInstanceLibSha1/HashInstanceLibSha1.c
new file mode 100644
index 000000000..a42c60d9b
--- /dev/null
+++ b/SecurityPkg/Library/HashInstanceLibSha1/HashInstanceLibSha1.c
@@ -0,0 +1,155 @@
+/** @file
+ Ihis library is BaseCrypto SHA1 hash instance.
+ It can be registered to BaseCrypto router, to serve as hash engine.
+
+Copyright (c) 2013, 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.
+
+**/
+
+#include <PiPei.h>
+#include <Library/BaseLib.h>
+#include <Library/BaseMemoryLib.h>
+#include <Library/Tpm2CommandLib.h>
+#include <Library/DebugLib.h>
+#include <Library/BaseCryptLib.h>
+#include <Library/MemoryAllocationLib.h>
+#include <Library/HashLib.h>
+
+/**
+ The function set SHA1 to digest list.
+
+ @param DigestList digest list
+ @param Sha1Digest SHA1 digest
+**/
+VOID
+Tpm2SetSha1ToDigestList (
+ IN TPML_DIGEST_VALUES *DigestList,
+ IN UINT8 *Sha1Digest
+ )
+{
+ DigestList->count = 1;
+ DigestList->digests[0].hashAlg = TPM_ALG_SHA1;
+ CopyMem (
+ DigestList->digests[0].digest.sha1,
+ Sha1Digest,
+ SHA1_DIGEST_SIZE
+ );
+}
+
+/**
+ Start hash sequence.
+
+ @param HashHandle Hash handle.
+
+ @retval EFI_SUCCESS Hash sequence start and HandleHandle returned.
+ @retval EFI_OUT_OF_RESOURCES No enough resource to start hash.
+**/
+EFI_STATUS
+EFIAPI
+Sha1HashInit (
+ OUT HASH_HANDLE *HashHandle
+ )
+{
+ VOID *Sha1Ctx;
+ UINTN CtxSize;
+
+ CtxSize = Sha1GetContextSize ();
+ Sha1Ctx = AllocatePool (CtxSize);
+ ASSERT (Sha1Ctx != NULL);
+
+ Sha1Init (Sha1Ctx);
+
+ *HashHandle = (HASH_HANDLE)Sha1Ctx;
+
+ return EFI_SUCCESS;
+}
+
+/**
+ Update hash sequence data.
+
+ @param HashHandle Hash handle.
+ @param DataToHash Data to be hashed.
+ @param DataToHashLen Data size.
+
+ @retval EFI_SUCCESS Hash sequence updated.
+**/
+EFI_STATUS
+EFIAPI
+Sha1HashUpdate (
+ IN HASH_HANDLE HashHandle,
+ IN VOID *DataToHash,
+ IN UINTN DataToHashLen
+ )
+{
+ VOID *Sha1Ctx;
+
+ Sha1Ctx = (VOID *)HashHandle;
+ Sha1Update (Sha1Ctx, DataToHash, DataToHashLen);
+
+ return EFI_SUCCESS;
+}
+
+/**
+ Complete hash sequence complete.
+
+ @param HashHandle Hash handle.
+ @param DigestList Digest list.
+
+ @retval EFI_SUCCESS Hash sequence complete and DigestList is returned.
+**/
+EFI_STATUS
+EFIAPI
+Sha1HashFinal (
+ IN HASH_HANDLE HashHandle,
+ OUT TPML_DIGEST_VALUES *DigestList
+ )
+{
+ UINT8 Digest[SHA1_DIGEST_SIZE];
+ VOID *Sha1Ctx;
+
+ Sha1Ctx = (VOID *)HashHandle;
+ Sha1Final (Sha1Ctx, Digest);
+
+ FreePool (Sha1Ctx);
+
+ Tpm2SetSha1ToDigestList (DigestList, Digest);
+
+ return EFI_SUCCESS;
+}
+
+HASH_INTERFACE mSha1InternalHashInstance = {
+ HASH_ALGORITHM_SHA1_GUID,
+ Sha1HashInit,
+ Sha1HashUpdate,
+ Sha1HashFinal,
+};
+
+/**
+ The function register SHA1 instance.
+
+ @retval EFI_SUCCESS SHA1 instance is registered, or system dose not surpport registr SHA1 instance
+**/
+EFI_STATUS
+EFIAPI
+HashInstanceLibSha1Constructor (
+ VOID
+ )
+{
+ EFI_STATUS Status;
+
+ Status = RegisterHashInterfaceLib (&mSha1InternalHashInstance);
+ if ((Status == EFI_SUCCESS) || (Status == EFI_UNSUPPORTED)) {
+ //
+ // Unsupported means platform policy does not need this instance enabled.
+ //
+ return EFI_SUCCESS;
+ }
+ return Status;
+} \ No newline at end of file
diff --git a/SecurityPkg/Library/HashInstanceLibSha1/HashInstanceLibSha1.inf b/SecurityPkg/Library/HashInstanceLibSha1/HashInstanceLibSha1.inf
new file mode 100644
index 000000000..d5fe6fe2b
--- /dev/null
+++ b/SecurityPkg/Library/HashInstanceLibSha1/HashInstanceLibSha1.inf
@@ -0,0 +1,44 @@
+## @file
+# Ihis library is BaseCrypto SHA1 hash instance.
+# It can be registered to BaseCrypto router, to serve as hash engine.
+#
+# Copyright (c) 2013, 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.
+#
+##
+
+[Defines]
+ INF_VERSION = 0x00010005
+ BASE_NAME = HashInstanceLibSha1
+ FILE_GUID = 9A7A6AB4-9DA6-4aa4-90CB-6D4B79EDA7B9
+ MODULE_TYPE = BASE
+ VERSION_STRING = 1.0
+ LIBRARY_CLASS = NULL
+ CONSTRUCTOR = HashInstanceLibSha1Constructor
+
+#
+# The following information is for reference only and not required by the build tools.
+#
+# VALID_ARCHITECTURES = IA32 X64 IPF
+#
+
+[Sources]
+ HashInstanceLibSha1.c
+
+[Packages]
+ MdePkg/MdePkg.dec
+ SecurityPkg/SecurityPkg.dec
+ CryptoPkg/CryptoPkg.dec
+
+[LibraryClasses]
+ BaseLib
+ BaseMemoryLib
+ DebugLib
+ Tpm2CommandLib
+ MemoryAllocationLib
+ BaseCryptLib
diff --git a/SecurityPkg/Library/HashInstanceLibSha256/HashInstanceLibSha256.c b/SecurityPkg/Library/HashInstanceLibSha256/HashInstanceLibSha256.c
new file mode 100644
index 000000000..abc97b447
--- /dev/null
+++ b/SecurityPkg/Library/HashInstanceLibSha256/HashInstanceLibSha256.c
@@ -0,0 +1,155 @@
+/** @file
+ Ihis library is BaseCrypto SHA256 hash instance.
+ It can be registered to BaseCrypto router, to serve as hash engine.
+
+Copyright (c) 2013, 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.
+
+**/
+
+#include <PiPei.h>
+#include <Library/BaseLib.h>
+#include <Library/BaseMemoryLib.h>
+#include <Library/Tpm2CommandLib.h>
+#include <Library/DebugLib.h>
+#include <Library/BaseCryptLib.h>
+#include <Library/MemoryAllocationLib.h>
+#include <Library/HashLib.h>
+
+/**
+ The function set SHA256 to digest list.
+
+ @param DigestList digest list
+ @param Sha256Digest SHA256 digest
+**/
+VOID
+Tpm2SetSha256ToDigestList (
+ IN TPML_DIGEST_VALUES *DigestList,
+ IN UINT8 *Sha256Digest
+ )
+{
+ DigestList->count = 1;
+ DigestList->digests[0].hashAlg = TPM_ALG_SHA256;
+ CopyMem (
+ DigestList->digests[0].digest.sha256,
+ Sha256Digest,
+ SHA256_DIGEST_SIZE
+ );
+}
+
+/**
+ Start hash sequence.
+
+ @param HashHandle Hash handle.
+
+ @retval EFI_SUCCESS Hash sequence start and HandleHandle returned.
+ @retval EFI_OUT_OF_RESOURCES No enough resource to start hash.
+**/
+EFI_STATUS
+EFIAPI
+Sha256HashInit (
+ OUT HASH_HANDLE *HashHandle
+ )
+{
+ VOID *Sha256Ctx;
+ UINTN CtxSize;
+
+ CtxSize = Sha256GetContextSize ();
+ Sha256Ctx = AllocatePool (CtxSize);
+ ASSERT (Sha256Ctx != NULL);
+
+ Sha256Init (Sha256Ctx);
+
+ *HashHandle = (HASH_HANDLE)Sha256Ctx;
+
+ return EFI_SUCCESS;
+}
+
+/**
+ Update hash sequence data.
+
+ @param HashHandle Hash handle.
+ @param DataToHash Data to be hashed.
+ @param DataToHashLen Data size.
+
+ @retval EFI_SUCCESS Hash sequence updated.
+**/
+EFI_STATUS
+EFIAPI
+Sha256HashUpdate (
+ IN HASH_HANDLE HashHandle,
+ IN VOID *DataToHash,
+ IN UINTN DataToHashLen
+ )
+{
+ VOID *Sha256Ctx;
+
+ Sha256Ctx = (VOID *)HashHandle;
+ Sha256Update (Sha256Ctx, DataToHash, DataToHashLen);
+
+ return EFI_SUCCESS;
+}
+
+/**
+ Complete hash sequence complete.
+
+ @param HashHandle Hash handle.
+ @param DigestList Digest list.
+
+ @retval EFI_SUCCESS Hash sequence complete and DigestList is returned.
+**/
+EFI_STATUS
+EFIAPI
+Sha256HashFinal (
+ IN HASH_HANDLE HashHandle,
+ OUT TPML_DIGEST_VALUES *DigestList
+ )
+{
+ UINT8 Digest[SHA256_DIGEST_SIZE];
+ VOID *Sha256Ctx;
+
+ Sha256Ctx = (VOID *)HashHandle;
+ Sha256Final (Sha256Ctx, Digest);
+
+ FreePool (Sha256Ctx);
+
+ Tpm2SetSha256ToDigestList (DigestList, Digest);
+
+ return EFI_SUCCESS;
+}
+
+HASH_INTERFACE mSha256InternalHashInstance = {
+ HASH_ALGORITHM_SHA256_GUID,
+ Sha256HashInit,
+ Sha256HashUpdate,
+ Sha256HashFinal,
+};
+
+/**
+ The function register SHA256 instance.
+
+ @retval EFI_SUCCESS SHA256 instance is registered, or system dose not surpport registr SHA256 instance
+**/
+EFI_STATUS
+EFIAPI
+HashInstanceLibSha256Constructor (
+ VOID
+ )
+{
+ EFI_STATUS Status;
+
+ Status = RegisterHashInterfaceLib (&mSha256InternalHashInstance);
+ if ((Status == EFI_SUCCESS) || (Status == EFI_UNSUPPORTED)) {
+ //
+ // Unsupported means platform policy does not need this instance enabled.
+ //
+ return EFI_SUCCESS;
+ }
+ return Status;
+} \ No newline at end of file
diff --git a/SecurityPkg/Library/HashInstanceLibSha256/HashInstanceLibSha256.inf b/SecurityPkg/Library/HashInstanceLibSha256/HashInstanceLibSha256.inf
new file mode 100644
index 000000000..a1fb89124
--- /dev/null
+++ b/SecurityPkg/Library/HashInstanceLibSha256/HashInstanceLibSha256.inf
@@ -0,0 +1,44 @@
+## @file
+# Ihis library is BaseCrypto SHA256 hash instance.
+# It can be registered to BaseCrypto router, to serve as hash engine.
+#
+# Copyright (c) 2013, 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.
+#
+##
+
+[Defines]
+ INF_VERSION = 0x00010005
+ BASE_NAME = HashInstanceLibSha256
+ FILE_GUID = 5810798A-ED30-4080-8DD7-B9667A748C02
+ MODULE_TYPE = BASE
+ VERSION_STRING = 1.0
+ LIBRARY_CLASS = NULL
+ CONSTRUCTOR = HashInstanceLibSha256Constructor
+
+#
+# The following information is for reference only and not required by the build tools.
+#
+# VALID_ARCHITECTURES = IA32 X64 IPF
+#
+
+[Sources]
+ HashInstanceLibSha256.c
+
+[Packages]
+ MdePkg/MdePkg.dec
+ SecurityPkg/SecurityPkg.dec
+ CryptoPkg/CryptoPkg.dec
+
+[LibraryClasses]
+ BaseLib
+ BaseMemoryLib
+ DebugLib
+ Tpm2CommandLib
+ MemoryAllocationLib
+ BaseCryptLib
diff --git a/SecurityPkg/Library/HashLibBaseCryptoRouter/HashLibBaseCryptoRouterCommon.c b/SecurityPkg/Library/HashLibBaseCryptoRouter/HashLibBaseCryptoRouterCommon.c
new file mode 100644
index 000000000..833cce2d7
--- /dev/null
+++ b/SecurityPkg/Library/HashLibBaseCryptoRouter/HashLibBaseCryptoRouterCommon.c
@@ -0,0 +1,77 @@
+/** @file
+ Ihis is BaseCrypto router support function.
+
+Copyright (c) 2013, 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.
+
+**/
+
+#include <PiPei.h>
+#include <Library/BaseLib.h>
+#include <Library/BaseMemoryLib.h>
+#include <Library/Tpm2CommandLib.h>
+#include <Library/DebugLib.h>
+#include <Library/MemoryAllocationLib.h>
+#include <Library/HashLib.h>
+#include <Protocol/TrEEProtocol.h>
+
+typedef struct {
+ EFI_GUID Guid;
+ UINT32 Mask;
+} TPM2_HASH_MASK;
+
+TPM2_HASH_MASK mTpm2HashMask[] = {
+ {HASH_ALGORITHM_SHA1_GUID, TREE_BOOT_HASH_ALG_SHA1},
+ {HASH_ALGORITHM_SHA256_GUID, TREE_BOOT_HASH_ALG_SHA256},
+ {HASH_ALGORITHM_SHA384_GUID, TREE_BOOT_HASH_ALG_SHA384},
+ {HASH_ALGORITHM_SHA512_GUID, TREE_BOOT_HASH_ALG_SHA512},
+};
+
+/**
+ The function get hash mask info from algorithm.
+
+ @param HashGuid Hash Guid
+
+ @return HashMask
+**/
+UINT32
+EFIAPI
+Tpm2GetHashMaskFromAlgo (
+ IN EFI_GUID *HashGuid
+ )
+{
+ UINTN Index;
+ for (Index = 0; Index < sizeof(mTpm2HashMask)/sizeof(mTpm2HashMask[0]); Index++) {
+ if (CompareGuid (HashGuid, &mTpm2HashMask[Index].Guid)) {
+ return mTpm2HashMask[Index].Mask;
+ }
+ }
+ return 0;
+}
+
+/**
+ The function set digest to digest list.
+
+ @param DigestList digest list
+ @param Digest digest data
+**/
+VOID
+EFIAPI
+Tpm2SetHashToDigestList (
+ IN OUT TPML_DIGEST_VALUES *DigestList,
+ IN TPML_DIGEST_VALUES *Digest
+ )
+{
+ CopyMem (
+ &DigestList->digests[DigestList->count],
+ &Digest->digests[0],
+ sizeof(Digest->digests[0])
+ );
+ DigestList->count ++;
+}
diff --git a/SecurityPkg/Library/HashLibBaseCryptoRouter/HashLibBaseCryptoRouterCommon.h b/SecurityPkg/Library/HashLibBaseCryptoRouter/HashLibBaseCryptoRouterCommon.h
new file mode 100644
index 000000000..f0ea3ca21
--- /dev/null
+++ b/SecurityPkg/Library/HashLibBaseCryptoRouter/HashLibBaseCryptoRouterCommon.h
@@ -0,0 +1,44 @@
+/** @file
+ Ihis is BaseCrypto router support function definition.
+
+Copyright (c) 2013, 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.
+
+**/
+
+#ifndef _HASH_LIB_BASE_CRYPTO_ROUTER_COMMON_H_
+#define _HASH_LIB_BASE_CRYPTO_ROUTER_COMMON_H_
+
+/**
+ The function get hash mask info from algorithm.
+
+ @param HashGuid Hash Guid
+
+ @return HashMask
+**/
+UINT32
+EFIAPI
+Tpm2GetHashMaskFromAlgo (
+ IN EFI_GUID *HashGuid
+ );
+
+/**
+ The function set digest to digest list.
+
+ @param DigestList digest list
+ @param Digest digest data
+**/
+VOID
+EFIAPI
+Tpm2SetHashToDigestList (
+ IN OUT TPML_DIGEST_VALUES *DigestList,
+ IN TPML_DIGEST_VALUES *Digest
+ );
+
+#endif
diff --git a/SecurityPkg/Library/HashLibBaseCryptoRouter/HashLibBaseCryptoRouterDxe.c b/SecurityPkg/Library/HashLibBaseCryptoRouter/HashLibBaseCryptoRouterDxe.c
new file mode 100644
index 000000000..8e93335e6
--- /dev/null
+++ b/SecurityPkg/Library/HashLibBaseCryptoRouter/HashLibBaseCryptoRouterDxe.c
@@ -0,0 +1,221 @@
+/** @file
+ Ihis library is BaseCrypto router. It will redirect hash request to each individual
+ hash handler registerd, such as SHA1, SHA256.
+ Platform can use PcdTpm2HashMask to mask some hash engines.
+
+Copyright (c) 2013, 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.
+
+**/
+
+#include <PiPei.h>
+#include <Library/BaseLib.h>
+#include <Library/BaseMemoryLib.h>
+#include <Library/Tpm2CommandLib.h>
+#include <Library/DebugLib.h>
+#include <Library/MemoryAllocationLib.h>
+#include <Library/PcdLib.h>
+#include <Library/HashLib.h>
+
+#include "HashLibBaseCryptoRouterCommon.h"
+
+HASH_INTERFACE mHashInterface[HASH_COUNT] = {0};
+UINTN mHashInterfaceCount = 0;
+
+/**
+ Start hash sequence.
+
+ @param HashHandle Hash handle.
+
+ @retval EFI_SUCCESS Hash sequence start and HandleHandle returned.
+ @retval EFI_OUT_OF_RESOURCES No enough resource to start hash.
+**/
+EFI_STATUS
+EFIAPI
+HashStart (
+ OUT HASH_HANDLE *HashHandle
+ )
+{
+ HASH_HANDLE *HashCtx;
+ UINTN Index;
+
+ if (mHashInterfaceCount == 0) {
+ return EFI_UNSUPPORTED;
+ }
+
+ HashCtx = AllocatePool (sizeof(*HashCtx) * mHashInterfaceCount);
+ ASSERT (HashCtx != NULL);
+
+ for (Index = 0; Index < mHashInterfaceCount; Index++) {
+ mHashInterface[Index].HashInit (&HashCtx[Index]);
+ }
+
+ *HashHandle = (HASH_HANDLE)HashCtx;
+
+ return EFI_SUCCESS;
+}
+
+/**
+ Update hash sequence data.
+
+ @param HashHandle Hash handle.
+ @param DataToHash Data to be hashed.
+ @param DataToHashLen Data size.
+
+ @retval EFI_SUCCESS Hash sequence updated.
+**/
+EFI_STATUS
+EFIAPI
+HashUpdate (
+ IN HASH_HANDLE HashHandle,
+ IN VOID *DataToHash,
+ IN UINTN DataToHashLen
+ )
+{
+ HASH_HANDLE *HashCtx;
+ UINTN Index;
+
+ if (mHashInterfaceCount == 0) {
+ return EFI_UNSUPPORTED;
+ }
+
+ HashCtx = (HASH_HANDLE *)HashHandle;
+
+ for (Index = 0; Index < mHashInterfaceCount; Index++) {
+ mHashInterface[Index].HashUpdate (HashCtx[Index], DataToHash, DataToHashLen);
+ }
+
+ return EFI_SUCCESS;
+}
+
+/**
+ Hash sequence complete and extend to PCR.
+
+ @param HashHandle Hash handle.
+ @param PcrIndex PCR to be extended.
+ @param DataToHash Data to be hashed.
+ @param DataToHashLen Data size.
+ @param DigestList Digest list.
+
+ @retval EFI_SUCCESS Hash sequence complete and DigestList is returned.
+**/
+EFI_STATUS
+EFIAPI
+HashCompleteAndExtend (
+ IN HASH_HANDLE HashHandle,
+ IN TPMI_DH_PCR PcrIndex,
+ IN VOID *DataToHash,
+ IN UINTN DataToHashLen,
+ OUT TPML_DIGEST_VALUES *DigestList
+ )
+{
+ TPML_DIGEST_VALUES Digest;
+ HASH_HANDLE *HashCtx;
+ UINTN Index;
+ EFI_STATUS Status;
+
+ if (mHashInterfaceCount == 0) {
+ return EFI_UNSUPPORTED;
+ }
+
+ HashCtx = (HASH_HANDLE *)HashHandle;
+ ZeroMem (DigestList, sizeof(*DigestList));
+
+ for (Index = 0; Index < mHashInterfaceCount; Index++) {
+ mHashInterface[Index].HashUpdate (HashCtx[Index], DataToHash, DataToHashLen);
+ mHashInterface[Index].HashFinal (HashCtx[Index], &Digest);
+ Tpm2SetHashToDigestList (DigestList, &Digest);
+ }
+
+ FreePool (HashCtx);
+
+ Status = Tpm2PcrExtend (
+ PcrIndex,
+ DigestList
+ );
+ return Status;
+}
+
+/**
+ Hash data and extend to PCR.
+
+ @param PcrIndex PCR to be extended.
+ @param DataToHash Data to be hashed.
+ @param DataToHashLen Data size.
+ @param DigestList Digest list.
+
+ @retval EFI_SUCCESS Hash data and DigestList is returned.
+**/
+EFI_STATUS
+EFIAPI
+HashAndExtend (
+ IN TPMI_DH_PCR PcrIndex,
+ IN VOID *DataToHash,
+ IN UINTN DataToHashLen,
+ OUT TPML_DIGEST_VALUES *DigestList
+ )
+{
+ HASH_HANDLE HashHandle;
+ EFI_STATUS Status;
+
+ if (mHashInterfaceCount == 0) {
+ return EFI_UNSUPPORTED;
+ }
+
+ HashStart (&HashHandle);
+ HashUpdate (HashHandle, DataToHash, DataToHashLen);
+ Status = HashCompleteAndExtend (HashHandle, PcrIndex, NULL, 0, DigestList);
+
+ return Status;
+}
+
+/**
+ This service register Hash.
+
+ @param HashInterface Hash interface
+
+ @retval EFI_SUCCESS This hash interface is registered successfully.
+ @retval EFI_UNSUPPORTED System does not support register this interface.
+ @retval EFI_ALREADY_STARTED System already register this interface.
+**/
+EFI_STATUS
+EFIAPI
+RegisterHashInterfaceLib (
+ IN HASH_INTERFACE *HashInterface
+ )
+{
+ UINTN Index;
+ UINT32 HashMask;
+
+ //
+ // Check allow
+ //
+ HashMask = Tpm2GetHashMaskFromAlgo (&HashInterface->HashGuid);
+ if ((HashMask & PcdGet32 (PcdTpm2HashMask)) == 0) {
+ return EFI_UNSUPPORTED;
+ }
+
+ if (mHashInterfaceCount >= sizeof(mHashInterface)/sizeof(mHashInterface[0])) {
+ return EFI_OUT_OF_RESOURCES;
+ }
+
+ //
+ // Check duplication
+ //
+ for (Index = 0; Index < mHashInterfaceCount; Index++) {
+ if (CompareGuid (&mHashInterface[Index].HashGuid, &HashInterface->HashGuid)) {
+ return EFI_ALREADY_STARTED;
+ }
+ }
+
+ CopyMem (&mHashInterface[mHashInterfaceCount], HashInterface, sizeof(*HashInterface));
+ mHashInterfaceCount ++;
+
+ return EFI_SUCCESS;
+} \ No newline at end of file
diff --git a/SecurityPkg/Library/HashLibBaseCryptoRouter/HashLibBaseCryptoRouterDxe.inf b/SecurityPkg/Library/HashLibBaseCryptoRouter/HashLibBaseCryptoRouterDxe.inf
new file mode 100644
index 000000000..a797c0563
--- /dev/null
+++ b/SecurityPkg/Library/HashLibBaseCryptoRouter/HashLibBaseCryptoRouterDxe.inf
@@ -0,0 +1,49 @@
+## @file
+# Ihis library is BaseCrypto router. It will redirect hash request to each individual
+# hash handler registerd, such as SHA1, SHA256.
+# Platform can use PcdTpm2HashMask to mask some hash engines.
+#
+# Copyright (c) 2013, 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.
+#
+##
+
+[Defines]
+ INF_VERSION = 0x00010005
+ BASE_NAME = HashLibBaseCryptoRouterDxe
+ FILE_GUID = 158DC712-F15A-44dc-93BB-1675045BE066
+ MODULE_TYPE = DXE_DRIVER
+ VERSION_STRING = 1.0
+ LIBRARY_CLASS = HashLib|DXE_DRIVER DXE_RUNTIME_DRIVER DXE_SAL_DRIVER DXE_SMM_DRIVER UEFI_APPLICATION UEFI_DRIVER
+
+#
+# The following information is for reference only and not required by the build tools.
+#
+# VALID_ARCHITECTURES = IA32 X64 IPF
+#
+
+[Sources]
+ HashLibBaseCryptoRouterCommon.h
+ HashLibBaseCryptoRouterCommon.c
+ HashLibBaseCryptoRouterDxe.c
+
+[Packages]
+ MdePkg/MdePkg.dec
+ SecurityPkg/SecurityPkg.dec
+
+[LibraryClasses]
+ BaseLib
+ BaseMemoryLib
+ DebugLib
+ Tpm2CommandLib
+ MemoryAllocationLib
+ PcdLib
+
+[Pcd]
+ gEfiSecurityPkgTokenSpaceGuid.PcdTpm2HashMask
+
diff --git a/SecurityPkg/Library/HashLibBaseCryptoRouter/HashLibBaseCryptoRouterPei.c b/SecurityPkg/Library/HashLibBaseCryptoRouter/HashLibBaseCryptoRouterPei.c
new file mode 100644
index 000000000..1e7eb2d77
--- /dev/null
+++ b/SecurityPkg/Library/HashLibBaseCryptoRouter/HashLibBaseCryptoRouterPei.c
@@ -0,0 +1,288 @@
+/** @file
+ Ihis library is BaseCrypto router. It will redirect hash request to each individual
+ hash handler registerd, such as SHA1, SHA256.
+ Platform can use PcdTpm2HashMask to mask some hash engines.
+
+Copyright (c) 2013, 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.
+
+**/
+
+#include <PiPei.h>
+#include <Library/BaseLib.h>
+#include <Library/BaseMemoryLib.h>
+#include <Library/Tpm2CommandLib.h>
+#include <Library/DebugLib.h>
+#include <Library/MemoryAllocationLib.h>
+#include <Library/PcdLib.h>
+#include <Library/HobLib.h>
+#include <Library/HashLib.h>
+
+#include "HashLibBaseCryptoRouterCommon.h"
+
+#define HASH_LIB_PEI_ROUTER_GUID \
+ { 0x84681c08, 0x6873, 0x46f3, { 0x8b, 0xb7, 0xab, 0x66, 0x18, 0x95, 0xa1, 0xb3 } }
+
+EFI_GUID mHashLibPeiRouterGuid = HASH_LIB_PEI_ROUTER_GUID;
+
+typedef struct {
+ UINTN HashInterfaceCount;
+ HASH_INTERFACE HashInterface[HASH_COUNT];
+} HASH_INTERFACE_HOB;
+
+/**
+ This function get hash interface.
+
+ @retval hash interface.
+**/
+HASH_INTERFACE_HOB *
+InternalGetHashInterface (
+ VOID
+ )
+{
+ EFI_HOB_GUID_TYPE *Hob;
+
+ Hob = GetFirstGuidHob (&mHashLibPeiRouterGuid);
+ if (Hob == NULL) {
+ return NULL;
+ }
+ return (HASH_INTERFACE_HOB *)(Hob + 1);
+}
+
+/**
+ Start hash sequence.
+
+ @param HashHandle Hash handle.
+
+ @retval EFI_SUCCESS Hash sequence start and HandleHandle returned.
+ @retval EFI_OUT_OF_RESOURCES No enough resource to start hash.
+**/
+EFI_STATUS
+EFIAPI
+HashStart (
+ OUT HASH_HANDLE *HashHandle
+ )
+{
+ HASH_INTERFACE_HOB *HashInterfaceHob;
+ HASH_HANDLE *HashCtx;
+ UINTN Index;
+
+ HashInterfaceHob = InternalGetHashInterface ();
+ if (HashInterfaceHob == NULL) {
+ return EFI_UNSUPPORTED;
+ }
+
+ if (HashInterfaceHob->HashInterfaceCount == 0) {
+ return EFI_UNSUPPORTED;
+ }
+
+ HashCtx = AllocatePool (sizeof(*HashCtx) * HashInterfaceHob->HashInterfaceCount);
+ ASSERT (HashCtx != NULL);
+
+ for (Index = 0; Index < HashInterfaceHob->HashInterfaceCount; Index++) {
+ HashInterfaceHob->HashInterface[Index].HashInit (&HashCtx[Index]);
+ }
+
+ *HashHandle = (HASH_HANDLE)HashCtx;
+
+ return EFI_SUCCESS;
+}
+
+/**
+ Update hash sequence data.
+
+ @param HashHandle Hash handle.
+ @param DataToHash Data to be hashed.
+ @param DataToHashLen Data size.
+
+ @retval EFI_SUCCESS Hash sequence updated.
+**/
+EFI_STATUS
+EFIAPI
+HashUpdate (
+ IN HASH_HANDLE HashHandle,
+ IN VOID *DataToHash,
+ IN UINTN DataToHashLen
+ )
+{
+ HASH_INTERFACE_HOB *HashInterfaceHob;
+ HASH_HANDLE *HashCtx;
+ UINTN Index;
+
+ HashInterfaceHob = InternalGetHashInterface ();
+ if (HashInterfaceHob == NULL) {
+ return EFI_UNSUPPORTED;
+ }
+
+ if (HashInterfaceHob->HashInterfaceCount == 0) {
+ return EFI_UNSUPPORTED;
+ }
+
+ HashCtx = (HASH_HANDLE *)HashHandle;
+
+ for (Index = 0; Index < HashInterfaceHob->HashInterfaceCount; Index++) {
+ HashInterfaceHob->HashInterface[Index].HashUpdate (HashCtx[Index], DataToHash, DataToHashLen);
+ }
+
+ return EFI_SUCCESS;
+}
+
+/**
+ Hash sequence complete and extend to PCR.
+
+ @param HashHandle Hash handle.
+ @param PcrIndex PCR to be extended.
+ @param DataToHash Data to be hashed.
+ @param DataToHashLen Data size.
+ @param DigestList Digest list.
+
+ @retval EFI_SUCCESS Hash sequence complete and DigestList is returned.
+**/
+EFI_STATUS
+EFIAPI
+HashCompleteAndExtend (
+ IN HASH_HANDLE HashHandle,
+ IN TPMI_DH_PCR PcrIndex,
+ IN VOID *DataToHash,
+ IN UINTN DataToHashLen,
+ OUT TPML_DIGEST_VALUES *DigestList
+ )
+{
+ TPML_DIGEST_VALUES Digest;
+ HASH_INTERFACE_HOB *HashInterfaceHob;
+ HASH_HANDLE *HashCtx;
+ UINTN Index;
+ EFI_STATUS Status;
+
+ HashInterfaceHob = InternalGetHashInterface ();
+ if (HashInterfaceHob == NULL) {
+ return EFI_UNSUPPORTED;
+ }
+
+ if (HashInterfaceHob->HashInterfaceCount == 0) {
+ return EFI_UNSUPPORTED;
+ }
+
+ HashCtx = (HASH_HANDLE *)HashHandle;
+ ZeroMem (DigestList, sizeof(*DigestList));
+
+ for (Index = 0; Index < HashInterfaceHob->HashInterfaceCount; Index++) {
+ HashInterfaceHob->HashInterface[Index].HashUpdate (HashCtx[Index], DataToHash, DataToHashLen);
+ HashInterfaceHob->HashInterface[Index].HashFinal (HashCtx[Index], &Digest);
+ Tpm2SetHashToDigestList (DigestList, &Digest);
+ }
+
+ FreePool (HashCtx);
+
+ Status = Tpm2PcrExtend (
+ PcrIndex,
+ DigestList
+ );
+ return Status;
+}
+
+/**
+ Hash data and extend to PCR.
+
+ @param PcrIndex PCR to be extended.
+ @param DataToHash Data to be hashed.
+ @param DataToHashLen Data size.
+ @param DigestList Digest list.
+
+ @retval EFI_SUCCESS Hash data and DigestList is returned.
+**/
+EFI_STATUS
+EFIAPI
+HashAndExtend (
+ IN TPMI_DH_PCR PcrIndex,
+ IN VOID *DataToHash,
+ IN UINTN DataToHashLen,
+ OUT TPML_DIGEST_VALUES *DigestList
+ )
+{
+ HASH_INTERFACE_HOB *HashInterfaceHob;
+ HASH_HANDLE HashHandle;
+ EFI_STATUS Status;
+
+ HashInterfaceHob = InternalGetHashInterface ();
+ if (HashInterfaceHob == NULL) {
+ return EFI_UNSUPPORTED;
+ }
+
+ if (HashInterfaceHob->HashInterfaceCount == 0) {
+ return EFI_UNSUPPORTED;
+ }
+
+ HashStart (&HashHandle);
+ HashUpdate (HashHandle, DataToHash, DataToHashLen);
+ Status = HashCompleteAndExtend (HashHandle, PcrIndex, NULL, 0, DigestList);
+
+ return Status;
+}
+
+/**
+ This service register Hash.
+
+ @param HashInterface Hash interface
+
+ @retval EFI_SUCCESS This hash interface is registered successfully.
+ @retval EFI_UNSUPPORTED System does not support register this interface.
+ @retval EFI_ALREADY_STARTED System already register this interface.
+**/
+EFI_STATUS
+EFIAPI
+RegisterHashInterfaceLib (
+ IN HASH_INTERFACE *HashInterface
+ )
+{
+ UINTN Index;
+ HASH_INTERFACE_HOB *HashInterfaceHob;
+ HASH_INTERFACE_HOB LocalHashInterfaceHob;
+ UINT32 HashMask;
+
+ //
+ // Check allow
+ //
+ HashMask = Tpm2GetHashMaskFromAlgo (&HashInterface->HashGuid);
+ if ((HashMask & PcdGet32 (PcdTpm2HashMask)) == 0) {
+ return EFI_UNSUPPORTED;
+ }
+
+ HashInterfaceHob = InternalGetHashInterface ();
+ if (HashInterfaceHob == NULL) {
+ ZeroMem (&LocalHashInterfaceHob, sizeof(LocalHashInterfaceHob));
+ HashInterfaceHob = BuildGuidDataHob (&mHashLibPeiRouterGuid, &LocalHashInterfaceHob, sizeof(LocalHashInterfaceHob));
+ if (HashInterfaceHob == NULL) {
+ return EFI_OUT_OF_RESOURCES;
+ }
+ }
+
+ if (HashInterfaceHob->HashInterfaceCount >= HASH_COUNT) {
+ return EFI_OUT_OF_RESOURCES;
+ }
+
+ //
+ // Check duplication
+ //
+ for (Index = 0; Index < HashInterfaceHob->HashInterfaceCount; Index++) {
+ if (CompareGuid (&HashInterfaceHob->HashInterface[Index].HashGuid, &HashInterface->HashGuid)) {
+ //
+ // In PEI phase, there will be shadow driver dispatched again.
+ //
+ DEBUG ((EFI_D_ERROR, "RegisterHashInterfaceLib - Override\n"));
+ CopyMem (&HashInterfaceHob->HashInterface[Index], HashInterface, sizeof(*HashInterface));
+ return EFI_SUCCESS;
+ }
+ }
+
+ CopyMem (&HashInterfaceHob->HashInterface[HashInterfaceHob->HashInterfaceCount], HashInterface, sizeof(*HashInterface));
+ HashInterfaceHob->HashInterfaceCount ++;
+
+ return EFI_SUCCESS;
+} \ No newline at end of file
diff --git a/SecurityPkg/Library/HashLibBaseCryptoRouter/HashLibBaseCryptoRouterPei.inf b/SecurityPkg/Library/HashLibBaseCryptoRouter/HashLibBaseCryptoRouterPei.inf
new file mode 100644
index 000000000..0926a5964
--- /dev/null
+++ b/SecurityPkg/Library/HashLibBaseCryptoRouter/HashLibBaseCryptoRouterPei.inf
@@ -0,0 +1,50 @@
+## @file
+# Ihis library is BaseCrypto router. It will redirect hash request to each individual
+# hash handler registerd, such as SHA1, SHA256.
+# Platform can use PcdTpm2HashMask to mask some hash engines.
+#
+# Copyright (c) 2013, 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.
+#
+##
+
+[Defines]
+ INF_VERSION = 0x00010005
+ BASE_NAME = HashLibBaseCryptoRouterPei
+ FILE_GUID = DDCBCFBA-8EEB-488a-96D6-097831A6E50B
+ MODULE_TYPE = PEIM
+ VERSION_STRING = 1.0
+ LIBRARY_CLASS = HashLib|PEIM
+
+#
+# The following information is for reference only and not required by the build tools.
+#
+# VALID_ARCHITECTURES = IA32 X64 IPF
+#
+
+[Sources]
+ HashLibBaseCryptoRouterCommon.h
+ HashLibBaseCryptoRouterCommon.c
+ HashLibBaseCryptoRouterPei.c
+
+[Packages]
+ MdePkg/MdePkg.dec
+ SecurityPkg/SecurityPkg.dec
+
+[LibraryClasses]
+ BaseLib
+ BaseMemoryLib
+ DebugLib
+ Tpm2CommandLib
+ MemoryAllocationLib
+ PcdLib
+ HobLib
+
+[Pcd]
+ gEfiSecurityPkgTokenSpaceGuid.PcdTpm2HashMask
+
diff --git a/SecurityPkg/Library/HashLibTpm2/HashLibTpm2.c b/SecurityPkg/Library/HashLibTpm2/HashLibTpm2.c
new file mode 100644
index 000000000..b2e01af37
--- /dev/null
+++ b/SecurityPkg/Library/HashLibTpm2/HashLibTpm2.c
@@ -0,0 +1,342 @@
+/** @file
+ Ihis library uses TPM2 device to calculation hash.
+
+Copyright (c) 2013, 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.
+
+**/
+
+#include <PiPei.h>
+#include <Library/BaseLib.h>
+#include <Library/BaseMemoryLib.h>
+#include <Library/Tpm2CommandLib.h>
+#include <Library/DebugLib.h>
+#include <Library/MemoryAllocationLib.h>
+#include <Library/HashLib.h>
+#include <Library/PcdLib.h>
+#include <Protocol/TrEEProtocol.h>
+
+typedef struct {
+ TPM_ALG_ID AlgoId;
+ UINT32 Mask;
+} TPM2_HASH_MASK;
+
+TPM2_HASH_MASK mTpm2HashMask[] = {
+ {TPM_ALG_SHA1, TREE_BOOT_HASH_ALG_SHA1},
+ {TPM_ALG_SHA256, TREE_BOOT_HASH_ALG_SHA256},
+ {TPM_ALG_SHA384, TREE_BOOT_HASH_ALG_SHA384},
+ {TPM_ALG_SHA512, TREE_BOOT_HASH_ALG_SHA512},
+};
+
+/**
+ The function get algorith from hash mask info.
+
+ @return Hash algorithm
+**/
+TPM_ALG_ID
+Tpm2GetAlgoFromHashMask (
+ VOID
+ )
+{
+ UINT32 HashMask;
+ UINTN Index;
+
+ HashMask = PcdGet32 (PcdTpm2HashMask);
+ for (Index = 0; Index < sizeof(mTpm2HashMask)/sizeof(mTpm2HashMask[0]); Index++) {
+ if (mTpm2HashMask[Index].Mask == HashMask) {
+ return mTpm2HashMask[Index].AlgoId;
+ }
+ }
+
+ return TPM_ALG_NULL;
+}
+
+/**
+ Start hash sequence.
+
+ @param HashHandle Hash handle.
+
+ @retval EFI_SUCCESS Hash sequence start and HandleHandle returned.
+ @retval EFI_OUT_OF_RESOURCES No enough resource to start hash.
+**/
+EFI_STATUS
+EFIAPI
+HashStart (
+ OUT HASH_HANDLE *HashHandle
+ )
+{
+ TPMI_DH_OBJECT SequenceHandle;
+ EFI_STATUS Status;
+ TPM_ALG_ID AlgoId;
+
+ AlgoId = Tpm2GetAlgoFromHashMask ();
+
+ Status = Tpm2HashSequenceStart (AlgoId, &SequenceHandle);
+ if (!EFI_ERROR (Status)) {
+ *HashHandle = (HASH_HANDLE)SequenceHandle;
+ }
+ return Status;
+}
+
+/**
+ Update hash sequence data.
+
+ @param HashHandle Hash handle.
+ @param DataToHash Data to be hashed.
+ @param DataToHashLen Data size.
+
+ @retval EFI_SUCCESS Hash sequence updated.
+**/
+EFI_STATUS
+EFIAPI
+HashUpdate (
+ IN HASH_HANDLE HashHandle,
+ IN VOID *DataToHash,
+ IN UINTN DataToHashLen
+ )
+{
+ UINT8 *Buffer;
+ UINT64 HashLen;
+ TPM2B_MAX_BUFFER HashBuffer;
+ EFI_STATUS Status;
+
+ Buffer = (UINT8 *)(UINTN)DataToHash;
+ for (HashLen = DataToHashLen; HashLen > sizeof(HashBuffer.buffer); HashLen -= sizeof(HashBuffer.buffer)) {
+
+ HashBuffer.size = sizeof(HashBuffer.buffer);
+ CopyMem(HashBuffer.buffer, Buffer, sizeof(HashBuffer.buffer));
+ Buffer += sizeof(HashBuffer.buffer);
+
+ Status = Tpm2SequenceUpdate((TPMI_DH_OBJECT)HashHandle, &HashBuffer);
+ if (EFI_ERROR(Status)) {
+ return EFI_DEVICE_ERROR;
+ }
+ }
+
+ //
+ // Last one
+ //
+ HashBuffer.size = (UINT16)HashLen;
+ CopyMem(HashBuffer.buffer, Buffer, (UINTN)HashLen);
+ Status = Tpm2SequenceUpdate((TPMI_DH_OBJECT)HashHandle, &HashBuffer);
+ if (EFI_ERROR(Status)) {
+ return EFI_DEVICE_ERROR;
+ }
+
+ return EFI_SUCCESS;
+}
+
+/**
+ Hash sequence complete and extend to PCR.
+
+ @param HashHandle Hash handle.
+ @param PcrIndex PCR to be extended.
+ @param DataToHash Data to be hashed.
+ @param DataToHashLen Data size.
+ @param DigestList Digest list.
+
+ @retval EFI_SUCCESS Hash sequence complete and DigestList is returned.
+**/
+EFI_STATUS
+EFIAPI
+HashCompleteAndExtend (
+ IN HASH_HANDLE HashHandle,
+ IN TPMI_DH_PCR PcrIndex,
+ IN VOID *DataToHash,
+ IN UINTN DataToHashLen,
+ OUT TPML_DIGEST_VALUES *DigestList
+ )
+{
+ UINT8 *Buffer;
+ UINT64 HashLen;
+ TPM2B_MAX_BUFFER HashBuffer;
+ EFI_STATUS Status;
+ TPM_ALG_ID AlgoId;
+ TPM2B_DIGEST Result;
+
+ AlgoId = Tpm2GetAlgoFromHashMask ();
+
+ Buffer = (UINT8 *)(UINTN)DataToHash;
+ for (HashLen = DataToHashLen; HashLen > sizeof(HashBuffer.buffer); HashLen -= sizeof(HashBuffer.buffer)) {
+
+ HashBuffer.size = sizeof(HashBuffer.buffer);
+ CopyMem(HashBuffer.buffer, Buffer, sizeof(HashBuffer.buffer));
+ Buffer += sizeof(HashBuffer.buffer);
+
+ Status = Tpm2SequenceUpdate((TPMI_DH_OBJECT)HashHandle, &HashBuffer);
+ if (EFI_ERROR(Status)) {
+ return EFI_DEVICE_ERROR;
+ }
+ }
+
+ //
+ // Last one
+ //
+ HashBuffer.size = (UINT16)HashLen;
+ CopyMem(HashBuffer.buffer, Buffer, (UINTN)HashLen);
+
+ ZeroMem(DigestList, sizeof(*DigestList));
+ DigestList->count = HASH_COUNT;
+
+ if (AlgoId == TPM_ALG_NULL) {
+ Status = Tpm2EventSequenceComplete (
+ PcrIndex,
+ (TPMI_DH_OBJECT)HashHandle,
+ &HashBuffer,
+ DigestList
+ );
+ } else {
+ Status = Tpm2SequenceComplete (
+ (TPMI_DH_OBJECT)HashHandle,
+ &HashBuffer,
+ &Result
+ );
+ if (EFI_ERROR(Status)) {
+ return EFI_DEVICE_ERROR;
+ }
+
+ DigestList->count = 1;
+ DigestList->digests[0].hashAlg = AlgoId;
+ CopyMem (&DigestList->digests[0].digest, Result.buffer, Result.size);
+ Status = Tpm2PcrExtend (
+ PcrIndex,
+ DigestList
+ );
+ }
+ if (EFI_ERROR(Status)) {
+ return EFI_DEVICE_ERROR;
+ }
+ return EFI_SUCCESS;
+}
+
+/**
+ Hash data and extend to PCR.
+
+ @param PcrIndex PCR to be extended.
+ @param DataToHash Data to be hashed.
+ @param DataToHashLen Data size.
+ @param DigestList Digest list.
+
+ @retval EFI_SUCCESS Hash data and DigestList is returned.
+**/
+EFI_STATUS
+EFIAPI
+HashAndExtend (
+ IN TPMI_DH_PCR PcrIndex,
+ IN VOID *DataToHash,
+ IN UINTN DataToHashLen,
+ OUT TPML_DIGEST_VALUES *DigestList
+ )
+{
+ EFI_STATUS Status;
+ UINT8 *Buffer;
+ UINT64 HashLen;
+ TPMI_DH_OBJECT SequenceHandle;
+ TPM2B_MAX_BUFFER HashBuffer;
+ TPM_ALG_ID AlgoId;
+ TPM2B_EVENT EventData;
+ TPM2B_DIGEST Result;
+
+ DEBUG((EFI_D_INFO, "\n HashAndExtend Entry \n"));
+
+ SequenceHandle = 0xFFFFFFFF; // Know bad value
+
+ AlgoId = Tpm2GetAlgoFromHashMask ();
+
+ if ((AlgoId == TPM_ALG_NULL) && (DataToHashLen <= sizeof(EventData.buffer))) {
+ EventData.size = (UINT16)DataToHashLen;
+ CopyMem (EventData.buffer, DataToHash, DataToHashLen);
+ Status = Tpm2PcrEvent (PcrIndex, &EventData, DigestList);
+ if (EFI_ERROR(Status)) {
+ return EFI_DEVICE_ERROR;
+ }
+ return EFI_SUCCESS;
+ }
+
+ Status = Tpm2HashSequenceStart(AlgoId, &SequenceHandle);
+ if (EFI_ERROR(Status)) {
+ return EFI_DEVICE_ERROR;
+ }
+ DEBUG((EFI_D_INFO, "\n Tpm2HashSequenceStart Success \n"));
+
+ Buffer = (UINT8 *)(UINTN)DataToHash;
+ for (HashLen = DataToHashLen; HashLen > sizeof(HashBuffer.buffer); HashLen -= sizeof(HashBuffer.buffer)) {
+
+ HashBuffer.size = sizeof(HashBuffer.buffer);
+ CopyMem(HashBuffer.buffer, Buffer, sizeof(HashBuffer.buffer));
+ Buffer += sizeof(HashBuffer.buffer);
+
+ Status = Tpm2SequenceUpdate(SequenceHandle, &HashBuffer);
+ if (EFI_ERROR(Status)) {
+ return EFI_DEVICE_ERROR;
+ }
+ }
+ DEBUG((EFI_D_INFO, "\n Tpm2SequenceUpdate Success \n"));
+
+ HashBuffer.size = (UINT16)HashLen;
+ CopyMem(HashBuffer.buffer, Buffer, (UINTN)HashLen);
+
+ ZeroMem(DigestList, sizeof(*DigestList));
+ DigestList->count = HASH_COUNT;
+
+ if (AlgoId == TPM_ALG_NULL) {
+ Status = Tpm2EventSequenceComplete (
+ PcrIndex,
+ SequenceHandle,
+ &HashBuffer,
+ DigestList
+ );
+ if (EFI_ERROR(Status)) {
+ return EFI_DEVICE_ERROR;
+ }
+ DEBUG((EFI_D_INFO, "\n Tpm2EventSequenceComplete Success \n"));
+ } else {
+ Status = Tpm2SequenceComplete (
+ SequenceHandle,
+ &HashBuffer,
+ &Result
+ );
+ if (EFI_ERROR(Status)) {
+ return EFI_DEVICE_ERROR;
+ }
+ DEBUG((EFI_D_INFO, "\n Tpm2SequenceComplete Success \n"));
+
+ DigestList->count = 1;
+ DigestList->digests[0].hashAlg = AlgoId;
+ CopyMem (&DigestList->digests[0].digest, Result.buffer, Result.size);
+ Status = Tpm2PcrExtend (
+ PcrIndex,
+ DigestList
+ );
+ if (EFI_ERROR(Status)) {
+ return EFI_DEVICE_ERROR;
+ }
+ DEBUG((EFI_D_INFO, "\n Tpm2PcrExtend Success \n"));
+ }
+
+ return EFI_SUCCESS;
+}
+
+/**
+ This service register Hash.
+
+ @param HashInterface Hash interface
+
+ @retval EFI_SUCCESS This hash interface is registered successfully.
+ @retval EFI_UNSUPPORTED System does not support register this interface.
+ @retval EFI_ALREADY_STARTED System already register this interface.
+**/
+EFI_STATUS
+EFIAPI
+RegisterHashInterfaceLib (
+ IN HASH_INTERFACE *HashInterface
+ )
+{
+ return EFI_UNSUPPORTED;
+} \ No newline at end of file
diff --git a/SecurityPkg/Library/HashLibTpm2/HashLibTpm2.inf b/SecurityPkg/Library/HashLibTpm2/HashLibTpm2.inf
new file mode 100644
index 000000000..ffcc8b9e2
--- /dev/null
+++ b/SecurityPkg/Library/HashLibTpm2/HashLibTpm2.inf
@@ -0,0 +1,45 @@
+## @file
+# Ihis library uses TPM2 device to calculation hash.
+#
+# Copyright (c) 2013, 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.
+#
+##
+
+[Defines]
+ INF_VERSION = 0x00010005
+ BASE_NAME = HashLibTpm2
+ FILE_GUID = 1317F0D5-7842-475c-B1CA-6EDC20DCBE7D
+ MODULE_TYPE = BASE
+ VERSION_STRING = 1.0
+ LIBRARY_CLASS = HashLib
+
+#
+# The following information is for reference only and not required by the build tools.
+#
+# VALID_ARCHITECTURES = IA32 X64 IPF
+#
+
+[Sources]
+ HashLibTpm2.c
+
+[Packages]
+ MdePkg/MdePkg.dec
+ SecurityPkg/SecurityPkg.dec
+ CryptoPkg/CryptoPkg.dec
+
+[LibraryClasses]
+ BaseLib
+ BaseMemoryLib
+ DebugLib
+ Tpm2CommandLib
+ MemoryAllocationLib
+ PcdLib
+
+[Pcd]
+ gEfiSecurityPkgTokenSpaceGuid.PcdTpm2HashMask
diff --git a/SecurityPkg/Library/Tpm12CommandLib/Tpm12CommandLib.inf b/SecurityPkg/Library/Tpm12CommandLib/Tpm12CommandLib.inf
new file mode 100644
index 000000000..622eb2b41
--- /dev/null
+++ b/SecurityPkg/Library/Tpm12CommandLib/Tpm12CommandLib.inf
@@ -0,0 +1,43 @@
+## @file
+# This library is used by other modules to send TPM12 command.
+#
+# Copyright (c) 2013, 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.
+#
+##
+
+[Defines]
+ INF_VERSION = 0x00010005
+ BASE_NAME = Tpm12CommandLib
+ FILE_GUID = C595047C-70B3-4731-99CC-A014E956D7A7
+ MODULE_TYPE = BASE
+ VERSION_STRING = 1.0
+ LIBRARY_CLASS = Tpm12CommandLib
+
+#
+# The following information is for reference only and not required by the build tools.
+#
+# VALID_ARCHITECTURES = IA32 X64 IPF
+#
+
+[Sources]
+ Tpm12Startup.c
+ Tpm12Ownership.c
+
+[Packages]
+ MdePkg/MdePkg.dec
+ SecurityPkg/SecurityPkg.dec
+
+[LibraryClasses]
+ BaseLib
+ BaseMemoryLib
+ IoLib
+ TimerLib
+ DebugLib
+ Tpm12DeviceLib
+
diff --git a/SecurityPkg/Library/Tpm12CommandLib/Tpm12Ownership.c b/SecurityPkg/Library/Tpm12CommandLib/Tpm12Ownership.c
new file mode 100644
index 000000000..63cc174a8
--- /dev/null
+++ b/SecurityPkg/Library/Tpm12CommandLib/Tpm12Ownership.c
@@ -0,0 +1,72 @@
+/** @file
+ Implement TPM1.2 Startup related command.
+
+Copyright (c) 2013, 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.
+
+**/
+
+#include <Uefi.h>
+#include <IndustryStandard/Tpm12.h>
+#include <Library/BaseMemoryLib.h>
+#include <Library/BaseLib.h>
+#include <Library/Tpm12DeviceLib.h>
+
+#pragma pack(1)
+
+typedef struct {
+ TPM_RQU_COMMAND_HDR Hdr;
+} TPM_CMD_FORCE_CLEAR;
+
+typedef struct {
+ TPM_RSP_COMMAND_HDR Hdr;
+} TPM_RSP_FORCE_CLEAR;
+
+#pragma pack()
+
+/**
+ Send ForceClear command to TPM1.2.
+
+ @retval EFI_SUCCESS Operation completed successfully.
+ @retval EFI_DEVICE_ERROR Unexpected device behavior.
+**/
+EFI_STATUS
+EFIAPI
+Tpm12ForceClear (
+ VOID
+ )
+{
+ EFI_STATUS Status;
+ UINT32 TpmRecvSize;
+ UINT32 TpmSendSize;
+ TPM_CMD_FORCE_CLEAR SendBuffer;
+ TPM_RSP_FORCE_CLEAR RecvBuffer;
+ UINT32 ReturnCode;
+
+ //
+ // send Tpm command TPM_ORD_ForceClear
+ //
+ TpmRecvSize = sizeof (TPM_RSP_FORCE_CLEAR);
+ TpmSendSize = sizeof (TPM_CMD_FORCE_CLEAR);
+ SendBuffer.Hdr.tag = SwapBytes16 (TPM_TAG_RQU_COMMAND);
+ SendBuffer.Hdr.paramSize = SwapBytes32 (TpmSendSize);
+ SendBuffer.Hdr.ordinal = SwapBytes32 (TPM_ORD_ForceClear);
+
+ Status = Tpm12SubmitCommand (TpmSendSize, (UINT8 *)&SendBuffer, &TpmRecvSize, (UINT8 *)&RecvBuffer);
+ if (EFI_ERROR (Status)) {
+ return Status;
+ }
+ ReturnCode = SwapBytes32(RecvBuffer.Hdr.returnCode);
+ switch (ReturnCode) {
+ case TPM_SUCCESS:
+ return EFI_SUCCESS;
+ default:
+ return EFI_DEVICE_ERROR;
+ }
+} \ No newline at end of file
diff --git a/SecurityPkg/Library/Tpm12CommandLib/Tpm12Startup.c b/SecurityPkg/Library/Tpm12CommandLib/Tpm12Startup.c
new file mode 100644
index 000000000..afbe02e38
--- /dev/null
+++ b/SecurityPkg/Library/Tpm12CommandLib/Tpm12Startup.c
@@ -0,0 +1,127 @@
+/** @file
+ Implement TPM1.2 Startup related command.
+
+Copyright (c) 2013, 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.
+
+**/
+
+#include <Uefi.h>
+#include <IndustryStandard/Tpm12.h>
+#include <Library/BaseMemoryLib.h>
+#include <Library/BaseLib.h>
+#include <Library/Tpm12DeviceLib.h>
+
+#pragma pack(1)
+
+typedef struct {
+ TPM_RQU_COMMAND_HDR Hdr;
+ TPM_STARTUP_TYPE TpmSt;
+} TPM_CMD_START_UP;
+
+typedef struct {
+ TPM_RSP_COMMAND_HDR Hdr;
+} TPM_RSP_START_UP;
+
+typedef struct {
+ TPM_RQU_COMMAND_HDR Hdr;
+} TPM_CMD_SAVE_STATE;
+
+typedef struct {
+ TPM_RSP_COMMAND_HDR Hdr;
+} TPM_RSP_SAVE_STATE;
+
+#pragma pack()
+
+/**
+ Send Startup command to TPM1.2.
+
+ @param TpmSt Startup Type.
+
+ @retval EFI_SUCCESS Operation completed successfully.
+ @retval EFI_DEVICE_ERROR Unexpected device behavior.
+**/
+EFI_STATUS
+EFIAPI
+Tpm12Startup (
+ IN TPM_STARTUP_TYPE TpmSt
+ )
+{
+ EFI_STATUS Status;
+ UINT32 TpmRecvSize;
+ UINT32 TpmSendSize;
+ TPM_CMD_START_UP SendBuffer;
+ TPM_RSP_START_UP RecvBuffer;
+ UINT32 ReturnCode;
+
+ //
+ // send Tpm command TPM_ORD_Startup
+ //
+ TpmRecvSize = sizeof (TPM_RSP_START_UP);
+ TpmSendSize = sizeof (TPM_CMD_START_UP);
+ SendBuffer.Hdr.tag = SwapBytes16 (TPM_TAG_RQU_COMMAND);
+ SendBuffer.Hdr.paramSize = SwapBytes32 (TpmSendSize);
+ SendBuffer.Hdr.ordinal = SwapBytes32 (TPM_ORD_Startup);
+ SendBuffer.TpmSt = SwapBytes16 (TpmSt);
+
+ Status = Tpm12SubmitCommand (TpmSendSize, (UINT8 *)&SendBuffer, &TpmRecvSize, (UINT8 *)&RecvBuffer);
+ if (EFI_ERROR (Status)) {
+ return Status;
+ }
+ ReturnCode = SwapBytes32(RecvBuffer.Hdr.returnCode);
+ switch (ReturnCode) {
+ case TPM_SUCCESS:
+ case TPM_INVALID_POSTINIT:
+ // In warm reset, TPM may response TPM_INVALID_POSTINIT
+ return EFI_SUCCESS;
+ default:
+ return EFI_DEVICE_ERROR;
+ }
+}
+
+/**
+ Send SaveState command to TPM1.2.
+
+ @retval EFI_SUCCESS Operation completed successfully.
+ @retval EFI_DEVICE_ERROR Unexpected device behavior.
+**/
+EFI_STATUS
+EFIAPI
+Tpm12SaveState (
+ VOID
+ )
+{
+ EFI_STATUS Status;
+ UINT32 TpmRecvSize;
+ UINT32 TpmSendSize;
+ TPM_CMD_SAVE_STATE SendBuffer;
+ TPM_RSP_SAVE_STATE RecvBuffer;
+ UINT32 ReturnCode;
+
+ //
+ // send Tpm command TPM_ORD_SaveState
+ //
+ TpmRecvSize = sizeof (TPM_RSP_SAVE_STATE);
+ TpmSendSize = sizeof (TPM_CMD_SAVE_STATE);
+ SendBuffer.Hdr.tag = SwapBytes16 (TPM_TAG_RQU_COMMAND);
+ SendBuffer.Hdr.paramSize = SwapBytes32 (TpmSendSize);
+ SendBuffer.Hdr.ordinal = SwapBytes32 (TPM_ORD_SaveState);
+
+ Status = Tpm12SubmitCommand (TpmSendSize, (UINT8 *)&SendBuffer, &TpmRecvSize, (UINT8 *)&RecvBuffer);
+ if (EFI_ERROR (Status)) {
+ return Status;
+ }
+ ReturnCode = SwapBytes32(RecvBuffer.Hdr.returnCode);
+ switch (ReturnCode) {
+ case TPM_SUCCESS:
+ return EFI_SUCCESS;
+ default:
+ return EFI_DEVICE_ERROR;
+ }
+}
diff --git a/SecurityPkg/Library/Tpm12DeviceLibDTpm/Tpm12DeviceLibDTpm.inf b/SecurityPkg/Library/Tpm12DeviceLibDTpm/Tpm12DeviceLibDTpm.inf
new file mode 100644
index 000000000..0eb91eee4
--- /dev/null
+++ b/SecurityPkg/Library/Tpm12DeviceLibDTpm/Tpm12DeviceLibDTpm.inf
@@ -0,0 +1,44 @@
+## @file
+# Ihis library is TPM2 DTPM device lib.
+# Choosing this library means platform uses and only uses DTPM device as TPM2 engine.
+#
+# Copyright (c) 2013, 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.
+#
+##
+
+[Defines]
+ INF_VERSION = 0x00010005
+ BASE_NAME = Tpm12DeviceLibDTpm
+ FILE_GUID = BC2B7672-A48B-4d58-B39E-AEE3707B5A23
+ MODULE_TYPE = BASE
+ VERSION_STRING = 1.0
+ LIBRARY_CLASS = Tpm12DeviceLib
+
+#
+# The following information is for reference only and not required by the build tools.
+#
+# VALID_ARCHITECTURES = IA32 X64 IPF
+#
+
+[Sources]
+ Tpm12Tis.c
+
+[Packages]
+ MdePkg/MdePkg.dec
+ SecurityPkg/SecurityPkg.dec
+
+[LibraryClasses]
+ BaseLib
+ BaseMemoryLib
+ IoLib
+ TimerLib
+ DebugLib
+
+[Pcd]
+ gEfiSecurityPkgTokenSpaceGuid.PcdTpmBaseAddress \ No newline at end of file
diff --git a/SecurityPkg/Library/Tpm12DeviceLibDTpm/Tpm12Tis.c b/SecurityPkg/Library/Tpm12DeviceLibDTpm/Tpm12Tis.c
new file mode 100644
index 000000000..2ad534592
--- /dev/null
+++ b/SecurityPkg/Library/Tpm12DeviceLibDTpm/Tpm12Tis.c
@@ -0,0 +1,572 @@
+/** @file
+ TIS (TPM Interface Specification) functions used by TPM1.2.
+
+Copyright (c) 2013, 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.
+
+**/
+
+#include <Uefi.h>
+#include <IndustryStandard/Tpm12.h>
+#include <Library/BaseLib.h>
+#include <Library/BaseMemoryLib.h>
+#include <Library/IoLib.h>
+#include <Library/TimerLib.h>
+#include <Library/DebugLib.h>
+#include <Library/Tpm12CommandLib.h>
+#include <Library/PcdLib.h>
+
+//
+// Set structure alignment to 1-byte
+//
+#pragma pack (1)
+
+//
+// Register set map as specified in TIS specification Chapter 10
+//
+typedef struct {
+ ///
+ /// Used to gain ownership for this particular port.
+ ///
+ UINT8 Access; // 0
+ UINT8 Reserved1[7]; // 1
+ ///
+ /// Controls interrupts.
+ ///
+ UINT32 IntEnable; // 8
+ ///
+ /// SIRQ vector to be used by the TPM.
+ ///
+ UINT8 IntVector; // 0ch
+ UINT8 Reserved2[3]; // 0dh
+ ///
+ /// What caused interrupt.
+ ///
+ UINT32 IntSts; // 10h
+ ///
+ /// Shows which interrupts are supported by that particular TPM.
+ ///
+ UINT32 IntfCapability; // 14h
+ ///
+ /// Status Register. Provides status of the TPM.
+ ///
+ UINT8 Status; // 18h
+ ///
+ /// Number of consecutive writes that can be done to the TPM.
+ ///
+ UINT16 BurstCount; // 19h
+ UINT8 Reserved3[9];
+ ///
+ /// Read or write FIFO, depending on transaction.
+ ///
+ UINT32 DataFifo; // 24h
+ UINT8 Reserved4[0xed8]; // 28h
+ ///
+ /// Vendor ID
+ ///
+ UINT16 Vid; // 0f00h
+ ///
+ /// Device ID
+ ///
+ UINT16 Did; // 0f02h
+ ///
+ /// Revision ID
+ ///
+ UINT8 Rid; // 0f04h
+ ///
+ /// TCG defined configuration registers.
+ ///
+ UINT8 TcgDefined[0x7b]; // 0f05h
+ ///
+ /// Alias to I/O legacy space.
+ ///
+ UINT32 LegacyAddress1; // 0f80h
+ ///
+ /// Additional 8 bits for I/O legacy space extension.
+ ///
+ UINT32 LegacyAddress1Ex; // 0f84h
+ ///
+ /// Alias to second I/O legacy space.
+ ///
+ UINT32 LegacyAddress2; // 0f88h
+ ///
+ /// Additional 8 bits for second I/O legacy space extension.
+ ///
+ UINT32 LegacyAddress2Ex; // 0f8ch
+ ///
+ /// Vendor-defined configuration registers.
+ ///
+ UINT8 VendorDefined[0x70];// 0f90h
+} TIS_PC_REGISTERS;
+
+//
+// Restore original structure alignment
+//
+#pragma pack ()
+
+//
+// Define pointer types used to access TIS registers on PC
+//
+typedef TIS_PC_REGISTERS *TIS_PC_REGISTERS_PTR;
+
+//
+// Define bits of ACCESS and STATUS registers
+//
+
+///
+/// This bit is a 1 to indicate that the other bits in this register are valid.
+///
+#define TIS_PC_VALID BIT7
+///
+/// Indicate that this locality is active.
+///
+#define TIS_PC_ACC_ACTIVE BIT5
+///
+/// Set to 1 to indicate that this locality had the TPM taken away while
+/// this locality had the TIS_PC_ACC_ACTIVE bit set.
+///
+#define TIS_PC_ACC_SEIZED BIT4
+///
+/// Set to 1 to indicate that TPM MUST reset the
+/// TIS_PC_ACC_ACTIVE bit and remove ownership for localities less than the
+/// locality that is writing this bit.
+///
+#define TIS_PC_ACC_SEIZE BIT3
+///
+/// When this bit is 1, another locality is requesting usage of the TPM.
+///
+#define TIS_PC_ACC_PENDIND BIT2
+///
+/// Set to 1 to indicate that this locality is requesting to use TPM.
+///
+#define TIS_PC_ACC_RQUUSE BIT1
+///
+/// A value of 1 indicates that a T/OS has not been established on the platform
+///
+#define TIS_PC_ACC_ESTABLISH BIT0
+
+///
+/// When this bit is 1, TPM is in the Ready state,
+/// indicating it is ready to receive a new command.
+///
+#define TIS_PC_STS_READY BIT6
+///
+/// Write a 1 to this bit to cause the TPM to execute that command.
+///
+#define TIS_PC_STS_GO BIT5
+///
+/// This bit indicates that the TPM has data available as a response.
+///
+#define TIS_PC_STS_DATA BIT4
+///
+/// The TPM sets this bit to a value of 1 when it expects another byte of data for a command.
+///
+#define TIS_PC_STS_EXPECT BIT3
+///
+/// Writes a 1 to this bit to force the TPM to re-send the response.
+///
+#define TIS_PC_STS_RETRY BIT1
+
+//
+// Default TimeOut value
+//
+#define TIS_TIMEOUT_A (750 * 1000) // 750ms
+#define TIS_TIMEOUT_B (2000 * 1000) // 2s
+#define TIS_TIMEOUT_C (750 * 1000) // 750ms
+#define TIS_TIMEOUT_D (750 * 1000) // 750ms
+
+//
+// Max TPM command/reponse length
+//
+#define TPMCMDBUFLENGTH 1024
+
+/**
+ Check whether TPM chip exist.
+
+ @param[in] TisReg Pointer to TIS register.
+
+ @retval TRUE TPM chip exists.
+ @retval FALSE TPM chip is not found.
+**/
+BOOLEAN
+Tpm12TisPcPresenceCheck (
+ IN TIS_PC_REGISTERS_PTR TisReg
+ )
+{
+ UINT8 RegRead;
+
+ RegRead = MmioRead8 ((UINTN)&TisReg->Access);
+ return (BOOLEAN)(RegRead != (UINT8)-1);
+}
+
+/**
+ Check whether the value of a TPM chip register satisfies the input BIT setting.
+
+ @param[in] Register Address port of register to be checked.
+ @param[in] BitSet Check these data bits are set.
+ @param[in] BitClear Check these data bits are clear.
+ @param[in] TimeOut The max wait time (unit MicroSecond) when checking register.
+
+ @retval EFI_SUCCESS The register satisfies the check bit.
+ @retval EFI_TIMEOUT The register can't run into the expected status in time.
+**/
+EFI_STATUS
+EFIAPI
+Tpm12TisPcWaitRegisterBits (
+ IN UINT8 *Register,
+ IN UINT8 BitSet,
+ IN UINT8 BitClear,
+ IN UINT32 TimeOut
+ )
+{
+ UINT8 RegRead;
+ UINT32 WaitTime;
+
+ for (WaitTime = 0; WaitTime < TimeOut; WaitTime += 30){
+ RegRead = MmioRead8 ((UINTN)Register);
+ if ((RegRead & BitSet) == BitSet && (RegRead & BitClear) == 0)
+ return EFI_SUCCESS;
+ MicroSecondDelay (30);
+ }
+ return EFI_TIMEOUT;
+}
+
+/**
+ Get BurstCount by reading the burstCount field of a TIS regiger
+ in the time of default TIS_TIMEOUT_D.
+
+ @param[in] TisReg Pointer to TIS register.
+ @param[out] BurstCount Pointer to a buffer to store the got BurstConut.
+
+ @retval EFI_SUCCESS Get BurstCount.
+ @retval EFI_INVALID_PARAMETER TisReg is NULL or BurstCount is NULL.
+ @retval EFI_TIMEOUT BurstCount can't be got in time.
+**/
+EFI_STATUS
+EFIAPI
+Tpm12TisPcReadBurstCount (
+ IN TIS_PC_REGISTERS_PTR TisReg,
+ OUT UINT16 *BurstCount
+ )
+{
+ UINT32 WaitTime;
+ UINT8 DataByte0;
+ UINT8 DataByte1;
+
+ if (BurstCount == NULL || TisReg == NULL) {
+ return EFI_INVALID_PARAMETER;
+ }
+
+ WaitTime = 0;
+ do {
+ //
+ // TIS_PC_REGISTERS_PTR->burstCount is UINT16, but it is not 2bytes aligned,
+ // so it needs to use MmioRead8 to read two times
+ //
+ DataByte0 = MmioRead8 ((UINTN)&TisReg->BurstCount);
+ DataByte1 = MmioRead8 ((UINTN)&TisReg->BurstCount + 1);
+ *BurstCount = (UINT16)((DataByte1 << 8) + DataByte0);
+ if (*BurstCount != 0) {
+ return EFI_SUCCESS;
+ }
+ MicroSecondDelay (30);
+ WaitTime += 30;
+ } while (WaitTime < TIS_TIMEOUT_D);
+
+ return EFI_TIMEOUT;
+}
+
+/**
+ Set TPM chip to ready state by sending ready command TIS_PC_STS_READY
+ to Status Register in time.
+
+ @param[in] TisReg Pointer to TIS register.
+
+ @retval EFI_SUCCESS TPM chip enters into ready state.
+ @retval EFI_INVALID_PARAMETER TisReg is NULL.
+ @retval EFI_TIMEOUT TPM chip can't be set to ready state in time.
+**/
+EFI_STATUS
+EFIAPI
+Tpm12TisPcPrepareCommand (
+ IN TIS_PC_REGISTERS_PTR TisReg
+ )
+{
+ EFI_STATUS Status;
+
+ if (TisReg == NULL) {
+ return EFI_INVALID_PARAMETER;
+ }
+
+ MmioWrite8((UINTN)&TisReg->Status, TIS_PC_STS_READY);
+ Status = Tpm12TisPcWaitRegisterBits (
+ &TisReg->Status,
+ TIS_PC_STS_READY,
+ 0,
+ TIS_TIMEOUT_B
+ );
+ return Status;
+}
+
+/**
+ Get the control of TPM chip by sending requestUse command TIS_PC_ACC_RQUUSE
+ to ACCESS Register in the time of default TIS_TIMEOUT_A.
+
+ @param[in] TisReg Pointer to TIS register.
+
+ @retval EFI_SUCCESS Get the control of TPM chip.
+ @retval EFI_INVALID_PARAMETER TisReg is NULL.
+ @retval EFI_NOT_FOUND TPM chip doesn't exit.
+ @retval EFI_TIMEOUT Can't get the TPM control in time.
+**/
+EFI_STATUS
+EFIAPI
+Tpm12TisPcRequestUseTpm (
+ IN TIS_PC_REGISTERS_PTR TisReg
+ )
+{
+ EFI_STATUS Status;
+
+ if (TisReg == NULL) {
+ return EFI_INVALID_PARAMETER;
+ }
+
+ if (!Tpm12TisPcPresenceCheck (TisReg)) {
+ return EFI_NOT_FOUND;
+ }
+
+ MmioWrite8((UINTN)&TisReg->Access, TIS_PC_ACC_RQUUSE);
+ Status = Tpm12TisPcWaitRegisterBits (
+ &TisReg->Access,
+ (UINT8)(TIS_PC_ACC_ACTIVE |TIS_PC_VALID),
+ 0,
+ TIS_TIMEOUT_A
+ );
+ return Status;
+}
+
+/**
+ Send a command to TPM for execution and return response data.
+
+ @param[in] TisReg TPM register space base address.
+ @param[in] BufferIn Buffer for command data.
+ @param[in] SizeIn Size of command data.
+ @param[in, out] BufferOut Buffer for response data.
+ @param[in, out] SizeOut Size of response data.
+
+ @retval EFI_SUCCESS Operation completed successfully.
+ @retval EFI_TIMEOUT The register can't run into the expected status in time.
+ @retval EFI_BUFFER_TOO_SMALL Response data buffer is too small.
+ @retval EFI_DEVICE_ERROR Unexpected device behavior.
+ @retval EFI_UNSUPPORTED Unsupported TPM version
+
+**/
+EFI_STATUS
+Tpm12TisTpmCommand (
+ IN TIS_PC_REGISTERS_PTR TisReg,
+ IN UINT8 *BufferIn,
+ IN UINT32 SizeIn,
+ IN OUT UINT8 *BufferOut,
+ IN OUT UINT32 *SizeOut
+ )
+{
+ EFI_STATUS Status;
+ UINT16 BurstCount;
+ UINT32 Index;
+ UINT32 TpmOutSize;
+ UINT16 Data16;
+ UINT32 Data32;
+
+ DEBUG_CODE (
+ UINTN DebugSize;
+
+ DEBUG ((EFI_D_INFO, "Tpm12TisTpmCommand Send - "));
+ if (SizeIn > 0x100) {
+ DebugSize = 0x40;
+ } else {
+ DebugSize = SizeIn;
+ }
+ for (Index = 0; Index < DebugSize; Index++) {
+ DEBUG ((EFI_D_INFO, "%02x ", BufferIn[Index]));
+ }
+ if (DebugSize != SizeIn) {
+ DEBUG ((EFI_D_INFO, "...... "));
+ for (Index = SizeIn - 0x20; Index < SizeIn; Index++) {
+ DEBUG ((EFI_D_INFO, "%02x ", BufferIn[Index]));
+ }
+ }
+ DEBUG ((EFI_D_INFO, "\n"));
+ );
+ TpmOutSize = 0;
+
+ Status = Tpm12TisPcPrepareCommand (TisReg);
+ if (EFI_ERROR (Status)){
+ DEBUG ((DEBUG_ERROR, "Tpm12 is not ready for command!\n"));
+ return Status;
+ }
+ //
+ // Send the command data to Tpm
+ //
+ Index = 0;
+ while (Index < SizeIn) {
+ Status = Tpm12TisPcReadBurstCount (TisReg, &BurstCount);
+ if (EFI_ERROR (Status)) {
+ Status = EFI_TIMEOUT;
+ goto Exit;
+ }
+ for (; BurstCount > 0 && Index < SizeIn; BurstCount--) {
+ MmioWrite8((UINTN)&TisReg->DataFifo, *(BufferIn + Index));
+ Index++;
+ }
+ }
+ //
+ // Check the Tpm status STS_EXPECT change from 1 to 0
+ //
+ Status = Tpm12TisPcWaitRegisterBits (
+ &TisReg->Status,
+ (UINT8) TIS_PC_VALID,
+ TIS_PC_STS_EXPECT,
+ TIS_TIMEOUT_C
+ );
+ if (EFI_ERROR (Status)) {
+ DEBUG ((DEBUG_ERROR, "Tpm12 The send buffer too small!\n"));
+ Status = EFI_BUFFER_TOO_SMALL;
+ goto Exit;
+ }
+ //
+ // Executed the TPM command and waiting for the response data ready
+ //
+ MmioWrite8((UINTN)&TisReg->Status, TIS_PC_STS_GO);
+ Status = Tpm12TisPcWaitRegisterBits (
+ &TisReg->Status,
+ (UINT8) (TIS_PC_VALID | TIS_PC_STS_DATA),
+ 0,
+ TIS_TIMEOUT_B
+ );
+ if (EFI_ERROR (Status)) {
+ DEBUG ((DEBUG_ERROR, "Wait for Tpm12 response data time out!!\n"));
+ Status = EFI_TIMEOUT;
+ goto Exit;
+ }
+ //
+ // Get response data header
+ //
+ Index = 0;
+ BurstCount = 0;
+ while (Index < sizeof (TPM_RSP_COMMAND_HDR)) {
+ Status = Tpm12TisPcReadBurstCount (TisReg, &BurstCount);
+ if (EFI_ERROR (Status)) {
+ Status = EFI_TIMEOUT;
+ goto Exit;
+ }
+ for (; BurstCount > 0; BurstCount--) {
+ *(BufferOut + Index) = MmioRead8 ((UINTN)&TisReg->DataFifo);
+ Index++;
+ if (Index == sizeof (TPM_RSP_COMMAND_HDR)) break;
+ }
+ }
+ DEBUG_CODE (
+ DEBUG ((EFI_D_INFO, "Tpm12TisTpmCommand ReceiveHeader - "));
+ for (Index = 0; Index < sizeof (TPM_RSP_COMMAND_HDR); Index++) {
+ DEBUG ((EFI_D_INFO, "%02x ", BufferOut[Index]));
+ }
+ DEBUG ((EFI_D_INFO, "\n"));
+ );
+ //
+ // Check the reponse data header (tag,parasize and returncode )
+ //
+ CopyMem (&Data16, BufferOut, sizeof (UINT16));
+ if (SwapBytes16 (Data16) != TPM_TAG_RSP_COMMAND) {
+ DEBUG ((EFI_D_ERROR, "TPM12: TPM_ST_RSP error - %x\n", TPM_TAG_RSP_COMMAND));
+ Status = EFI_UNSUPPORTED;
+ goto Exit;
+ }
+
+ CopyMem (&Data32, (BufferOut + 2), sizeof (UINT32));
+ TpmOutSize = SwapBytes32 (Data32);
+ if (*SizeOut < TpmOutSize) {
+ Status = EFI_BUFFER_TOO_SMALL;
+ goto Exit;
+ }
+ *SizeOut = TpmOutSize;
+ //
+ // Continue reading the remaining data
+ //
+ while ( Index < TpmOutSize ) {
+ for (; BurstCount > 0; BurstCount--) {
+ *(BufferOut + Index) = MmioRead8 ((UINTN)&TisReg->DataFifo);
+ Index++;
+ if (Index == TpmOutSize) {
+ Status = EFI_SUCCESS;
+ goto Exit;
+ }
+ }
+ Status = Tpm12TisPcReadBurstCount (TisReg, &BurstCount);
+ if (EFI_ERROR (Status)) {
+ Status = EFI_TIMEOUT;
+ goto Exit;
+ }
+ }
+Exit:
+ DEBUG_CODE (
+ DEBUG ((EFI_D_INFO, "Tpm12TisTpmCommand Receive - "));
+ for (Index = 0; Index < TpmOutSize; Index++) {
+ DEBUG ((EFI_D_INFO, "%02x ", BufferOut[Index]));
+ }
+ DEBUG ((EFI_D_INFO, "\n"));
+ );
+ MmioWrite8((UINTN)&TisReg->Status, TIS_PC_STS_READY);
+ return Status;
+}
+
+/**
+ This service enables the sending of commands to the TPM12.
+
+ @param[in] InputParameterBlockSize Size of the TPM12 input parameter block.
+ @param[in] InputParameterBlock Pointer to the TPM12 input parameter block.
+ @param[in,out] OutputParameterBlockSize Size of the TPM12 output parameter block.
+ @param[in] OutputParameterBlock Pointer to the TPM12 output parameter block.
+
+ @retval EFI_SUCCESS The command byte stream was successfully sent to the device and a response was successfully received.
+ @retval EFI_DEVICE_ERROR The command was not successfully sent to the device or a response was not successfully received from the device.
+ @retval EFI_BUFFER_TOO_SMALL The output parameter block is too small.
+**/
+EFI_STATUS
+EFIAPI
+Tpm12SubmitCommand (
+ IN UINT32 InputParameterBlockSize,
+ IN UINT8 *InputParameterBlock,
+ IN OUT UINT32 *OutputParameterBlockSize,
+ IN UINT8 *OutputParameterBlock
+ )
+{
+ return Tpm12TisTpmCommand (
+ (TIS_PC_REGISTERS_PTR) (UINTN) PcdGet64 (PcdTpmBaseAddress),
+ InputParameterBlock,
+ InputParameterBlockSize,
+ OutputParameterBlock,
+ OutputParameterBlockSize
+ );
+}
+
+/**
+ This service requests use TPM12.
+
+ @retval EFI_SUCCESS Get the control of TPM12 chip.
+ @retval EFI_NOT_FOUND TPM12 not found.
+ @retval EFI_DEVICE_ERROR Unexpected device behavior.
+**/
+EFI_STATUS
+EFIAPI
+Tpm12RequestUseTpm (
+ VOID
+ )
+{
+ return Tpm12TisPcRequestUseTpm ((TIS_PC_REGISTERS_PTR) (UINTN) PcdGet64 (PcdTpmBaseAddress));
+}
diff --git a/SecurityPkg/Library/Tpm12DeviceLibTcg/Tpm12DeviceLibTcg.c b/SecurityPkg/Library/Tpm12DeviceLibTcg/Tpm12DeviceLibTcg.c
new file mode 100644
index 000000000..6b793bf6b
--- /dev/null
+++ b/SecurityPkg/Library/Tpm12DeviceLibTcg/Tpm12DeviceLibTcg.c
@@ -0,0 +1,108 @@
+/** @file
+ Ihis library is TPM12 TCG protocol lib.
+
+Copyright (c) 2013, 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.
+
+**/
+
+#include <Uefi.h>
+#include <Library/BaseLib.h>
+#include <Library/BaseMemoryLib.h>
+#include <Library/DebugLib.h>
+#include <Library/UefiBootServicesTableLib.h>
+#include <Library/Tpm12DeviceLib.h>
+#include <Protocol/TcgService.h>
+#include <IndustryStandard/Tpm12.h>
+
+EFI_TCG_PROTOCOL *mTcgProtocol = NULL;
+
+/**
+ This service enables the sending of commands to the TPM12.
+
+ @param[in] InputParameterBlockSize Size of the TPM12 input parameter block.
+ @param[in] InputParameterBlock Pointer to the TPM12 input parameter block.
+ @param[in,out] OutputParameterBlockSize Size of the TPM12 output parameter block.
+ @param[in] OutputParameterBlock Pointer to the TPM12 output parameter block.
+
+ @retval EFI_SUCCESS The command byte stream was successfully sent to the device and a response was successfully received.
+ @retval EFI_DEVICE_ERROR The command was not successfully sent to the device or a response was not successfully received from the device.
+ @retval EFI_BUFFER_TOO_SMALL The output parameter block is too small.
+**/
+EFI_STATUS
+EFIAPI
+Tpm12SubmitCommand (
+ IN UINT32 InputParameterBlockSize,
+ IN UINT8 *InputParameterBlock,
+ IN OUT UINT32 *OutputParameterBlockSize,
+ IN UINT8 *OutputParameterBlock
+ )
+{
+ EFI_STATUS Status;
+ TPM_RSP_COMMAND_HDR *Header;
+
+ if (mTcgProtocol == NULL) {
+ Status = gBS->LocateProtocol (&gEfiTcgProtocolGuid, NULL, (VOID **) &mTcgProtocol);
+ if (EFI_ERROR (Status)) {
+ //
+ // TCG protocol is not installed. So, TPM12 is not present.
+ //
+ DEBUG ((EFI_D_ERROR, "Tpm12SubmitCommand - TCG - %r\n", Status));
+ return EFI_NOT_FOUND;
+ }
+ }
+ //
+ // Assume when TCG Protocol is ready, RequestUseTpm already done.
+ //
+ Status = mTcgProtocol->PassThroughToTpm (
+ mTcgProtocol,
+ InputParameterBlockSize,
+ InputParameterBlock,
+ *OutputParameterBlockSize,
+ OutputParameterBlock
+ );
+ if (EFI_ERROR (Status)) {
+ return Status;
+ }
+ Header = (TPM_RSP_COMMAND_HDR *)OutputParameterBlock;
+ *OutputParameterBlockSize = SwapBytes32 (Header->paramSize);
+
+ return EFI_SUCCESS;
+}
+
+/**
+ This service requests use TPM12.
+
+ @retval EFI_SUCCESS Get the control of TPM12 chip.
+ @retval EFI_NOT_FOUND TPM12 not found.
+ @retval EFI_DEVICE_ERROR Unexpected device behavior.
+**/
+EFI_STATUS
+EFIAPI
+Tpm12RequestUseTpm (
+ VOID
+ )
+{
+ EFI_STATUS Status;
+
+ if (mTcgProtocol == NULL) {
+ Status = gBS->LocateProtocol (&gEfiTcgProtocolGuid, NULL, (VOID **) &mTcgProtocol);
+ if (EFI_ERROR (Status)) {
+ //
+ // TCG protocol is not installed. So, TPM12 is not present.
+ //
+ DEBUG ((EFI_D_ERROR, "Tpm12RequestUseTpm - TCG - %r\n", Status));
+ return EFI_NOT_FOUND;
+ }
+ }
+ //
+ // Assume when TCG Protocol is ready, RequestUseTpm already done.
+ //
+ return EFI_SUCCESS;
+}
diff --git a/SecurityPkg/Library/Tpm12DeviceLibTcg/Tpm12DeviceLibTcg.inf b/SecurityPkg/Library/Tpm12DeviceLibTcg/Tpm12DeviceLibTcg.inf
new file mode 100644
index 000000000..7ab5217bc
--- /dev/null
+++ b/SecurityPkg/Library/Tpm12DeviceLibTcg/Tpm12DeviceLibTcg.inf
@@ -0,0 +1,42 @@
+## @file
+# Ihis library is TPM12 TCG protocol lib.
+#
+# Copyright (c) 2013, 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.
+#
+##
+
+[Defines]
+ INF_VERSION = 0x00010005
+ BASE_NAME = Tpm12DeviceLibTcg
+ FILE_GUID = 4D8B77D9-E923-48f8-B070-4053D78B7E56
+ MODULE_TYPE = BASE
+ VERSION_STRING = 1.0
+ LIBRARY_CLASS = Tpm12DeviceLib|DXE_DRIVER DXE_RUNTIME_DRIVER DXE_SAL_DRIVER UEFI_APPLICATION UEFI_DRIVER
+
+#
+# The following information is for reference only and not required by the build tools.
+#
+# VALID_ARCHITECTURES = IA32 X64 IPF
+#
+
+[Sources]
+ Tpm12DeviceLibTcg.c
+
+[Packages]
+ MdePkg/MdePkg.dec
+ SecurityPkg/SecurityPkg.dec
+
+[LibraryClasses]
+ BaseLib
+ BaseMemoryLib
+ DebugLib
+ UefiBootServicesTableLib
+
+[Protocols]
+ gEfiTcgProtocolGuid ## CONSUMES
diff --git a/SecurityPkg/Library/Tpm2CommandLib/Tpm2Capability.c b/SecurityPkg/Library/Tpm2CommandLib/Tpm2Capability.c
new file mode 100644
index 000000000..0fe2c367d
--- /dev/null
+++ b/SecurityPkg/Library/Tpm2CommandLib/Tpm2Capability.c
@@ -0,0 +1,741 @@
+/** @file
+ Implement TPM2 Capability related command.
+
+Copyright (c) 2013, 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.
+
+**/
+
+#include <IndustryStandard/UefiTcgPlatform.h>
+#include <Library/Tpm2CommandLib.h>
+#include <Library/Tpm2DeviceLib.h>
+#include <Library/BaseMemoryLib.h>
+#include <Library/BaseLib.h>
+#include <Library/DebugLib.h>
+
+#pragma pack(1)
+
+typedef struct {
+ TPM2_COMMAND_HEADER Header;
+ TPM_CAP Capability;
+ UINT32 Property;
+ UINT32 PropertyCount;
+} TPM2_GET_CAPABILITY_COMMAND;
+
+typedef struct {
+ TPM2_RESPONSE_HEADER Header;
+ TPMI_YES_NO MoreData;
+ TPMS_CAPABILITY_DATA CapabilityData;
+} TPM2_GET_CAPABILITY_RESPONSE;
+
+typedef struct {
+ TPM2_COMMAND_HEADER Header;
+ TPMT_PUBLIC_PARMS Parameters;
+} TPM2_TEST_PARMS_COMMAND;
+
+typedef struct {
+ TPM2_RESPONSE_HEADER Header;
+} TPM2_TEST_PARMS_RESPONSE;
+
+#pragma pack()
+
+/**
+ This command returns various information regarding the TPM and its current state.
+
+ The capability parameter determines the category of data returned. The property parameter
+ selects the first value of the selected category to be returned. If there is no property
+ that corresponds to the value of property, the next higher value is returned, if it exists.
+ The moreData parameter will have a value of YES if there are more values of the requested
+ type that were not returned.
+ If no next capability exists, the TPM will return a zero-length list and moreData will have
+ a value of NO.
+
+ NOTE:
+ To simplify this function, leave returned CapabilityData for caller to unpack since there are
+ many capability categories and only few categories will be used in firmware. It means the caller
+ need swap the byte order for the feilds in CapabilityData.
+
+ @param[in] Capability Group selection; determines the format of the response.
+ @param[in] Property Further definition of information.
+ @param[in] PropertyCount Number of properties of the indicated type to return.
+ @param[out] MoreData Flag to indicate if there are more values of this type.
+ @param[out] CapabilityData The capability data.
+
+ @retval EFI_SUCCESS Operation completed successfully.
+ @retval EFI_DEVICE_ERROR The command was unsuccessful.
+**/
+EFI_STATUS
+EFIAPI
+Tpm2GetCapability (
+ IN TPM_CAP Capability,
+ IN UINT32 Property,
+ IN UINT32 PropertyCount,
+ OUT TPMI_YES_NO *MoreData,
+ OUT TPMS_CAPABILITY_DATA *CapabilityData
+ )
+{
+ EFI_STATUS Status;
+ TPM2_GET_CAPABILITY_COMMAND SendBuffer;
+ TPM2_GET_CAPABILITY_RESPONSE RecvBuffer;
+ UINT32 SendBufferSize;
+ UINT32 RecvBufferSize;
+
+ //
+ // Construct command
+ //
+ SendBuffer.Header.tag = SwapBytes16(TPM_ST_NO_SESSIONS);
+ SendBuffer.Header.commandCode = SwapBytes32(TPM_CC_GetCapability);
+
+ SendBuffer.Capability = SwapBytes32 (Capability);
+ SendBuffer.Property = SwapBytes32 (Property);
+ SendBuffer.PropertyCount = SwapBytes32 (PropertyCount);
+
+ SendBufferSize = (UINT32) sizeof (SendBuffer);
+ SendBuffer.Header.paramSize = SwapBytes32 (SendBufferSize);
+
+ //
+ // send Tpm command
+ //
+ RecvBufferSize = sizeof (RecvBuffer);
+ Status = Tpm2SubmitCommand (SendBufferSize, (UINT8 *)&SendBuffer, &RecvBufferSize, (UINT8 *)&RecvBuffer );
+ if (EFI_ERROR (Status)) {
+ return Status;
+ }
+
+ if (RecvBufferSize <= sizeof (TPM2_RESPONSE_HEADER) + sizeof (UINT8)) {
+ return EFI_DEVICE_ERROR;
+ }
+
+ //
+ // Return the response
+ //
+ *MoreData = RecvBuffer.MoreData;
+ //
+ // Does not unpack all possiable property here, the caller should unpack it and note the byte order.
+ //
+ CopyMem (CapabilityData, &RecvBuffer.CapabilityData, RecvBufferSize - sizeof (TPM2_RESPONSE_HEADER) - sizeof (UINT8));
+
+ return EFI_SUCCESS;
+}
+
+/**
+ This command returns the information of TPM Family.
+
+ This function parse the value got from TPM2_GetCapability and return the Family.
+
+ @param[out] Family The Family of TPM. (a 4-octet character string)
+
+ @retval EFI_SUCCESS Operation completed successfully.
+ @retval EFI_DEVICE_ERROR The command was unsuccessful.
+**/
+EFI_STATUS
+EFIAPI
+Tpm2GetCapabilityFamily (
+ OUT CHAR8 *Family
+ )
+{
+ TPMS_CAPABILITY_DATA TpmCap;
+ TPMI_YES_NO MoreData;
+ EFI_STATUS Status;
+
+ Status = Tpm2GetCapability (
+ TPM_CAP_TPM_PROPERTIES,
+ TPM_PT_FAMILY_INDICATOR,
+ 1,
+ &MoreData,
+ &TpmCap
+ );
+ if (EFI_ERROR (Status)) {
+ return Status;
+ }
+ CopyMem (Family, &TpmCap.data.tpmProperties.tpmProperty->value, 4);
+
+ return EFI_SUCCESS;
+}
+
+/**
+ This command returns the information of TPM manufacture ID.
+
+ This function parse the value got from TPM2_GetCapability and return the TPM manufacture ID.
+
+ @param[out] ManufactureId The manufacture ID of TPM.
+
+ @retval EFI_SUCCESS Operation completed successfully.
+ @retval EFI_DEVICE_ERROR The command was unsuccessful.
+**/
+EFI_STATUS
+EFIAPI
+Tpm2GetCapabilityManufactureID (
+ OUT UINT32 *ManufactureId
+ )
+{
+ TPMS_CAPABILITY_DATA TpmCap;
+ TPMI_YES_NO MoreData;
+ EFI_STATUS Status;
+
+ Status = Tpm2GetCapability (
+ TPM_CAP_TPM_PROPERTIES,
+ TPM_PT_MANUFACTURER,
+ 1,
+ &MoreData,
+ &TpmCap
+ );
+ if (EFI_ERROR (Status)) {
+ return Status;
+ }
+ *ManufactureId = SwapBytes32 (TpmCap.data.tpmProperties.tpmProperty->value);
+
+ return EFI_SUCCESS;
+}
+
+/**
+ This command returns the information of TPM FirmwareVersion.
+
+ This function parse the value got from TPM2_GetCapability and return the TPM FirmwareVersion.
+
+ @param[out] FirmwareVersion1 The FirmwareVersion1.
+ @param[out] FirmwareVersion2 The FirmwareVersion2.
+
+ @retval EFI_SUCCESS Operation completed successfully.
+ @retval EFI_DEVICE_ERROR The command was unsuccessful.
+**/
+EFI_STATUS
+EFIAPI
+Tpm2GetCapabilityFirmwareVersion (
+ OUT UINT32 *FirmwareVersion1,
+ OUT UINT32 *FirmwareVersion2
+ )
+{
+ TPMS_CAPABILITY_DATA TpmCap;
+ TPMI_YES_NO MoreData;
+ EFI_STATUS Status;
+
+ Status = Tpm2GetCapability (
+ TPM_CAP_TPM_PROPERTIES,
+ TPM_PT_FIRMWARE_VERSION_1,
+ 1,
+ &MoreData,
+ &TpmCap
+ );
+ if (EFI_ERROR (Status)) {
+ return Status;
+ }
+ *FirmwareVersion1 = SwapBytes32 (TpmCap.data.tpmProperties.tpmProperty->value);
+
+ Status = Tpm2GetCapability (
+ TPM_CAP_TPM_PROPERTIES,
+ TPM_PT_FIRMWARE_VERSION_2,
+ 1,
+ &MoreData,
+ &TpmCap
+ );
+ if (EFI_ERROR (Status)) {
+ return Status;
+ }
+ *FirmwareVersion2 = SwapBytes32 (TpmCap.data.tpmProperties.tpmProperty->value);
+
+ return EFI_SUCCESS;
+}
+
+/**
+ This command returns the information of the maximum value for commandSize and responseSize in a command.
+
+ This function parse the value got from TPM2_GetCapability and return the max command size and response size
+
+ @param[out] MaxCommandSize The maximum value for commandSize in a command.
+ @param[out] MaxResponseSize The maximum value for responseSize in a command.
+
+ @retval EFI_SUCCESS Operation completed successfully.
+ @retval EFI_DEVICE_ERROR The command was unsuccessful.
+**/
+EFI_STATUS
+EFIAPI
+Tpm2GetCapabilityMaxCommandResponseSize (
+ OUT UINT32 *MaxCommandSize,
+ OUT UINT32 *MaxResponseSize
+ )
+{
+ TPMS_CAPABILITY_DATA TpmCap;
+ TPMI_YES_NO MoreData;
+ EFI_STATUS Status;
+
+ Status = Tpm2GetCapability (
+ TPM_CAP_TPM_PROPERTIES,
+ TPM_PT_MAX_COMMAND_SIZE,
+ 1,
+ &MoreData,
+ &TpmCap
+ );
+ if (EFI_ERROR (Status)) {
+ return Status;
+ }
+
+ *MaxCommandSize = SwapBytes32 (TpmCap.data.tpmProperties.tpmProperty->value);
+
+ Status = Tpm2GetCapability (
+ TPM_CAP_TPM_PROPERTIES,
+ TPM_PT_MAX_RESPONSE_SIZE,
+ 1,
+ &MoreData,
+ &TpmCap
+ );
+ if (EFI_ERROR (Status)) {
+ return Status;
+ }
+
+ *MaxResponseSize = SwapBytes32 (TpmCap.data.tpmProperties.tpmProperty->value);
+ return EFI_SUCCESS;
+}
+
+/**
+ This command returns Returns a list of TPMS_ALG_PROPERTIES. Each entry is an
+ algorithm ID and a set of properties of the algorithm.
+
+ This function parse the value got from TPM2_GetCapability and return the list.
+
+ @param[out] AlgList List of algorithm.
+
+ @retval EFI_SUCCESS Operation completed successfully.
+ @retval EFI_DEVICE_ERROR The command was unsuccessful.
+**/
+EFI_STATUS
+EFIAPI
+Tpm2GetCapabilitySupportedAlg (
+ OUT TPML_ALG_PROPERTY *AlgList
+ )
+{
+ TPMS_CAPABILITY_DATA TpmCap;
+ TPMI_YES_NO MoreData;
+ UINTN Index;
+ EFI_STATUS Status;
+
+ Status = Tpm2GetCapability (
+ TPM_CAP_ALGS,
+ 1,
+ MAX_CAP_ALGS,
+ &MoreData,
+ &TpmCap
+ );
+ if (EFI_ERROR (Status)) {
+ return Status;
+ }
+
+ CopyMem (AlgList, &TpmCap.data.algorithms, sizeof (TPML_ALG_PROPERTY));
+
+ AlgList->count = SwapBytes32 (AlgList->count);
+ for (Index = 0; Index < AlgList->count; Index++) {
+ AlgList->algProperties[Index].alg = SwapBytes16 (AlgList->algProperties[Index].alg);
+ WriteUnaligned32 ((UINT32 *)&AlgList->algProperties[Index].algProperties, SwapBytes32 (ReadUnaligned32 ((UINT32 *)&AlgList->algProperties[Index].algProperties)));
+ }
+
+ return EFI_SUCCESS;
+}
+
+/**
+ This command returns the information of TPM LockoutCounter.
+
+ This function parse the value got from TPM2_GetCapability and return the LockoutCounter.
+
+ @param[out] LockoutCounter The LockoutCounter of TPM.
+
+ @retval EFI_SUCCESS Operation completed successfully.
+ @retval EFI_DEVICE_ERROR The command was unsuccessful.
+**/
+EFI_STATUS
+EFIAPI
+Tpm2GetCapabilityLockoutCounter (
+ OUT UINT32 *LockoutCounter
+ )
+{
+ TPMS_CAPABILITY_DATA TpmCap;
+ TPMI_YES_NO MoreData;
+ EFI_STATUS Status;
+
+ Status = Tpm2GetCapability (
+ TPM_CAP_TPM_PROPERTIES,
+ TPM_PT_LOCKOUT_COUNTER,
+ 1,
+ &MoreData,
+ &TpmCap
+ );
+ if (EFI_ERROR (Status)) {
+ return Status;
+ }
+ *LockoutCounter = SwapBytes32 (TpmCap.data.tpmProperties.tpmProperty->value);
+
+ return EFI_SUCCESS;
+}
+
+/**
+ This command returns the information of TPM LockoutInterval.
+
+ This function parse the value got from TPM2_GetCapability and return the LockoutInterval.
+
+ @param[out] LockoutInterval The LockoutInterval of TPM.
+
+ @retval EFI_SUCCESS Operation completed successfully.
+ @retval EFI_DEVICE_ERROR The command was unsuccessful.
+**/
+EFI_STATUS
+EFIAPI
+Tpm2GetCapabilityLockoutInterval (
+ OUT UINT32 *LockoutInterval
+ )
+{
+ TPMS_CAPABILITY_DATA TpmCap;
+ TPMI_YES_NO MoreData;
+ EFI_STATUS Status;
+
+ Status = Tpm2GetCapability (
+ TPM_CAP_TPM_PROPERTIES,
+ TPM_PT_LOCKOUT_INTERVAL,
+ 1,
+ &MoreData,
+ &TpmCap
+ );
+ if (EFI_ERROR (Status)) {
+ return Status;
+ }
+ *LockoutInterval = SwapBytes32 (TpmCap.data.tpmProperties.tpmProperty->value);
+
+ return EFI_SUCCESS;
+}
+
+/**
+ This command returns the information of TPM InputBufferSize.
+
+ This function parse the value got from TPM2_GetCapability and return the InputBufferSize.
+
+ @param[out] InputBufferSize The InputBufferSize of TPM.
+ the maximum size of a parameter (typically, a TPM2B_MAX_BUFFER)
+
+ @retval EFI_SUCCESS Operation completed successfully.
+ @retval EFI_DEVICE_ERROR The command was unsuccessful.
+**/
+EFI_STATUS
+EFIAPI
+Tpm2GetCapabilityInputBufferSize (
+ OUT UINT32 *InputBufferSize
+ )
+{
+ TPMS_CAPABILITY_DATA TpmCap;
+ TPMI_YES_NO MoreData;
+ EFI_STATUS Status;
+
+ Status = Tpm2GetCapability (
+ TPM_CAP_TPM_PROPERTIES,
+ TPM_PT_INPUT_BUFFER,
+ 1,
+ &MoreData,
+ &TpmCap
+ );
+ if (EFI_ERROR (Status)) {
+ return Status;
+ }
+ *InputBufferSize = SwapBytes32 (TpmCap.data.tpmProperties.tpmProperty->value);
+
+ return EFI_SUCCESS;
+}
+
+/**
+ This command returns the information of TPM PCRs.
+
+ This function parse the value got from TPM2_GetCapability and return the PcrSelection.
+
+ @param[out] Pcrs The Pcr Selection
+
+ @retval EFI_SUCCESS Operation completed successfully.
+ @retval EFI_DEVICE_ERROR The command was unsuccessful.
+**/
+EFI_STATUS
+EFIAPI
+Tpm2GetCapabilityPcrs (
+ OUT TPML_PCR_SELECTION *Pcrs
+ )
+{
+ TPMS_CAPABILITY_DATA TpmCap;
+ TPMI_YES_NO MoreData;
+ EFI_STATUS Status;
+ UINTN Index;
+
+ Status = Tpm2GetCapability (
+ TPM_CAP_PCRS,
+ 0,
+ 1,
+ &MoreData,
+ &TpmCap
+ );
+ if (EFI_ERROR (Status)) {
+ return Status;
+ }
+
+ Pcrs->count = SwapBytes32 (TpmCap.data.assignedPCR.count);
+ for (Index = 0; Index < Pcrs->count; Index++) {
+ Pcrs->pcrSelections[Index].hash = SwapBytes16 (TpmCap.data.assignedPCR.pcrSelections[Index].hash);
+ Pcrs->pcrSelections[Index].sizeofSelect = TpmCap.data.assignedPCR.pcrSelections[Index].sizeofSelect;
+ CopyMem (Pcrs->pcrSelections[Index].pcrSelect, TpmCap.data.assignedPCR.pcrSelections[Index].pcrSelect, Pcrs->pcrSelections[Index].sizeofSelect);
+ }
+
+ return EFI_SUCCESS;
+}
+
+/**
+ This command returns the information of TPM AlgorithmSet.
+
+ This function parse the value got from TPM2_GetCapability and return the AlgorithmSet.
+
+ @param[out] AlgorithmSet The AlgorithmSet of TPM.
+
+ @retval EFI_SUCCESS Operation completed successfully.
+ @retval EFI_DEVICE_ERROR The command was unsuccessful.
+**/
+EFI_STATUS
+EFIAPI
+Tpm2GetCapabilityAlgorithmSet (
+ OUT UINT32 *AlgorithmSet
+ )
+{
+ TPMS_CAPABILITY_DATA TpmCap;
+ TPMI_YES_NO MoreData;
+ EFI_STATUS Status;
+
+ Status = Tpm2GetCapability (
+ TPM_CAP_TPM_PROPERTIES,
+ TPM_PT_ALGORITHM_SET,
+ 1,
+ &MoreData,
+ &TpmCap
+ );
+ if (EFI_ERROR (Status)) {
+ return Status;
+ }
+ *AlgorithmSet = SwapBytes32 (TpmCap.data.tpmProperties.tpmProperty->value);
+
+ return EFI_SUCCESS;
+}
+
+/**
+ This command is used to check to see if specific combinations of algorithm parameters are supported.
+
+ @param[in] Parameters Algorithm parameters to be validated
+
+ @retval EFI_SUCCESS Operation completed successfully.
+ @retval EFI_DEVICE_ERROR Unexpected device behavior.
+**/
+EFI_STATUS
+EFIAPI
+Tpm2TestParms (
+ IN TPMT_PUBLIC_PARMS *Parameters
+ )
+{
+ EFI_STATUS Status;
+ TPM2_TEST_PARMS_COMMAND SendBuffer;
+ TPM2_TEST_PARMS_RESPONSE RecvBuffer;
+ UINT32 SendBufferSize;
+ UINT32 RecvBufferSize;
+ UINT8 *Buffer;
+
+ //
+ // Construct command
+ //
+ SendBuffer.Header.tag = SwapBytes16(TPM_ST_NO_SESSIONS);
+ SendBuffer.Header.commandCode = SwapBytes32(TPM_CC_TestParms);
+
+ Buffer = (UINT8 *)&SendBuffer.Parameters;
+ WriteUnaligned16 ((UINT16 *)Buffer, SwapBytes16 (Parameters->type));
+ Buffer += sizeof(UINT16);
+ switch (Parameters->type) {
+ case TPM_ALG_KEYEDHASH:
+ WriteUnaligned16 ((UINT16 *)Buffer, SwapBytes16 (Parameters->parameters.keyedHashDetail.scheme.scheme));
+ Buffer += sizeof(UINT16);
+ switch (Parameters->parameters.keyedHashDetail.scheme.scheme) {
+ case TPM_ALG_HMAC:
+ WriteUnaligned16 ((UINT16 *)Buffer, SwapBytes16 (Parameters->parameters.keyedHashDetail.scheme.details.hmac.hashAlg));
+ Buffer += sizeof(UINT16);
+ break;
+ case TPM_ALG_XOR:
+ WriteUnaligned16 ((UINT16 *)Buffer, SwapBytes16 (Parameters->parameters.keyedHashDetail.scheme.details.xor.hashAlg));
+ Buffer += sizeof(UINT16);
+ WriteUnaligned16 ((UINT16 *)Buffer, SwapBytes16 (Parameters->parameters.keyedHashDetail.scheme.details.xor.kdf));
+ Buffer += sizeof(UINT16);
+ break;
+ default:
+ return EFI_INVALID_PARAMETER;
+ }
+ case TPM_ALG_SYMCIPHER:
+ WriteUnaligned16 ((UINT16 *)Buffer, SwapBytes16 (Parameters->parameters.symDetail.algorithm));
+ Buffer += sizeof(UINT16);
+ switch (Parameters->parameters.symDetail.algorithm) {
+ case TPM_ALG_AES:
+ WriteUnaligned16 ((UINT16 *)Buffer, SwapBytes16 (Parameters->parameters.symDetail.keyBits.aes));
+ Buffer += sizeof(UINT16);
+ WriteUnaligned16 ((UINT16 *)Buffer, SwapBytes16 (Parameters->parameters.symDetail.mode.aes));
+ Buffer += sizeof(UINT16);
+ break;
+ case TPM_ALG_SM4:
+ WriteUnaligned16 ((UINT16 *)Buffer, SwapBytes16 (Parameters->parameters.symDetail.keyBits.SM4));
+ Buffer += sizeof(UINT16);
+ WriteUnaligned16 ((UINT16 *)Buffer, SwapBytes16 (Parameters->parameters.symDetail.mode.SM4));
+ Buffer += sizeof(UINT16);
+ break;
+ case TPM_ALG_XOR:
+ WriteUnaligned16 ((UINT16 *)Buffer, SwapBytes16 (Parameters->parameters.symDetail.keyBits.xor));
+ Buffer += sizeof(UINT16);
+ break;
+ case TPM_ALG_NULL:
+ break;
+ default:
+ return EFI_INVALID_PARAMETER;
+ }
+ break;
+ case TPM_ALG_RSA:
+ WriteUnaligned16 ((UINT16 *)Buffer, SwapBytes16 (Parameters->parameters.rsaDetail.symmetric.algorithm));
+ Buffer += sizeof(UINT16);
+ switch (Parameters->parameters.rsaDetail.symmetric.algorithm) {
+ case TPM_ALG_AES:
+ WriteUnaligned16 ((UINT16 *)Buffer, SwapBytes16 (Parameters->parameters.rsaDetail.symmetric.keyBits.aes));
+ Buffer += sizeof(UINT16);
+ WriteUnaligned16 ((UINT16 *)Buffer, SwapBytes16 (Parameters->parameters.rsaDetail.symmetric.mode.aes));
+ Buffer += sizeof(UINT16);
+ break;
+ case TPM_ALG_SM4:
+ WriteUnaligned16 ((UINT16 *)Buffer, SwapBytes16 (Parameters->parameters.rsaDetail.symmetric.keyBits.SM4));
+ Buffer += sizeof(UINT16);
+ WriteUnaligned16 ((UINT16 *)Buffer, SwapBytes16 (Parameters->parameters.rsaDetail.symmetric.mode.SM4));
+ Buffer += sizeof(UINT16);
+ break;
+ case TPM_ALG_NULL:
+ break;
+ default:
+ return EFI_INVALID_PARAMETER;
+ }
+ WriteUnaligned16 ((UINT16 *)Buffer, SwapBytes16 (Parameters->parameters.rsaDetail.scheme.scheme));
+ Buffer += sizeof(UINT16);
+ switch (Parameters->parameters.rsaDetail.scheme.scheme) {
+ case TPM_ALG_RSASSA:
+ WriteUnaligned16 ((UINT16 *)Buffer, SwapBytes16 (Parameters->parameters.rsaDetail.scheme.details.rsassa.hashAlg));
+ Buffer += sizeof(UINT16);
+ break;
+ case TPM_ALG_RSAPSS:
+ WriteUnaligned16 ((UINT16 *)Buffer, SwapBytes16 (Parameters->parameters.rsaDetail.scheme.details.rsapss.hashAlg));
+ Buffer += sizeof(UINT16);
+ break;
+ case TPM_ALG_RSAES:
+ break;
+ case TPM_ALG_OAEP:
+ WriteUnaligned16 ((UINT16 *)Buffer, SwapBytes16 (Parameters->parameters.rsaDetail.scheme.details.oaep.hashAlg));
+ Buffer += sizeof(UINT16);
+ break;
+ case TPM_ALG_NULL:
+ break;
+ default:
+ return EFI_INVALID_PARAMETER;
+ }
+ WriteUnaligned16 ((UINT16 *)Buffer, SwapBytes16 (Parameters->parameters.rsaDetail.keyBits));
+ Buffer += sizeof(UINT16);
+ WriteUnaligned32 ((UINT32 *)Buffer, SwapBytes32 (Parameters->parameters.rsaDetail.exponent));
+ Buffer += sizeof(UINT32);
+ break;
+ case TPM_ALG_ECC:
+ WriteUnaligned16 ((UINT16 *)Buffer, SwapBytes16 (Parameters->parameters.eccDetail.symmetric.algorithm));
+ Buffer += sizeof(UINT16);
+ switch (Parameters->parameters.eccDetail.symmetric.algorithm) {
+ case TPM_ALG_AES:
+ WriteUnaligned16 ((UINT16 *)Buffer, SwapBytes16 (Parameters->parameters.eccDetail.symmetric.keyBits.aes));
+ Buffer += sizeof(UINT16);
+ WriteUnaligned16 ((UINT16 *)Buffer, SwapBytes16 (Parameters->parameters.eccDetail.symmetric.mode.aes));
+ Buffer += sizeof(UINT16);
+ break;
+ case TPM_ALG_SM4:
+ WriteUnaligned16 ((UINT16 *)Buffer, SwapBytes16 (Parameters->parameters.eccDetail.symmetric.keyBits.SM4));
+ Buffer += sizeof(UINT16);
+ WriteUnaligned16 ((UINT16 *)Buffer, SwapBytes16 (Parameters->parameters.eccDetail.symmetric.mode.SM4));
+ Buffer += sizeof(UINT16);
+ break;
+ case TPM_ALG_NULL:
+ break;
+ default:
+ return EFI_INVALID_PARAMETER;
+ }
+ WriteUnaligned16 ((UINT16 *)Buffer, SwapBytes16 (Parameters->parameters.eccDetail.scheme.scheme));
+ Buffer += sizeof(UINT16);
+ switch (Parameters->parameters.eccDetail.scheme.scheme) {
+ case TPM_ALG_ECDSA:
+ WriteUnaligned16 ((UINT16 *)Buffer, SwapBytes16 (Parameters->parameters.eccDetail.scheme.details.ecdsa.hashAlg));
+ Buffer += sizeof(UINT16);
+ break;
+ case TPM_ALG_ECDAA:
+ WriteUnaligned16 ((UINT16 *)Buffer, SwapBytes16 (Parameters->parameters.eccDetail.scheme.details.ecdaa.hashAlg));
+ Buffer += sizeof(UINT16);
+ break;
+ case TPM_ALG_ECSCHNORR:
+ WriteUnaligned16 ((UINT16 *)Buffer, SwapBytes16 (Parameters->parameters.eccDetail.scheme.details.ecSchnorr.hashAlg));
+ Buffer += sizeof(UINT16);
+ break;
+ case TPM_ALG_ECDH:
+ break;
+ case TPM_ALG_NULL:
+ break;
+ default:
+ return EFI_INVALID_PARAMETER;
+ }
+ WriteUnaligned16 ((UINT16 *)Buffer, SwapBytes16 (Parameters->parameters.eccDetail.curveID));
+ Buffer += sizeof(UINT16);
+ WriteUnaligned16 ((UINT16 *)Buffer, SwapBytes16 (Parameters->parameters.eccDetail.kdf.scheme));
+ Buffer += sizeof(UINT16);
+ switch (Parameters->parameters.eccDetail.kdf.scheme) {
+ case TPM_ALG_MGF1:
+ WriteUnaligned16 ((UINT16 *)Buffer, SwapBytes16 (Parameters->parameters.eccDetail.kdf.details.mgf1.hashAlg));
+ Buffer += sizeof(UINT16);
+ break;
+ case TPM_ALG_KDF1_SP800_108:
+ WriteUnaligned16 ((UINT16 *)Buffer, SwapBytes16 (Parameters->parameters.eccDetail.kdf.details.kdf1_sp800_108.hashAlg));
+ Buffer += sizeof(UINT16);
+ break;
+ case TPM_ALG_KDF1_SP800_56a:
+ WriteUnaligned16 ((UINT16 *)Buffer, SwapBytes16 (Parameters->parameters.eccDetail.kdf.details.kdf1_SP800_56a.hashAlg));
+ Buffer += sizeof(UINT16);
+ break;
+ case TPM_ALG_KDF2:
+ WriteUnaligned16 ((UINT16 *)Buffer, SwapBytes16 (Parameters->parameters.eccDetail.kdf.details.kdf2.hashAlg));
+ Buffer += sizeof(UINT16);
+ break;
+ case TPM_ALG_NULL:
+ break;
+ default:
+ return EFI_INVALID_PARAMETER;
+ }
+ break;
+ default:
+ return EFI_INVALID_PARAMETER;
+ }
+
+ SendBufferSize = (UINT32)((UINTN)Buffer - (UINTN)&SendBuffer);
+ SendBuffer.Header.paramSize = SwapBytes32 (SendBufferSize);
+
+ //
+ // send Tpm command
+ //
+ RecvBufferSize = sizeof (RecvBuffer);
+ Status = Tpm2SubmitCommand (SendBufferSize, (UINT8 *)&SendBuffer, &RecvBufferSize, (UINT8 *)&RecvBuffer);
+ if (EFI_ERROR (Status)) {
+ return Status;
+ }
+
+ if (RecvBufferSize < sizeof (TPM2_RESPONSE_HEADER)) {
+ DEBUG ((EFI_D_ERROR, "Tpm2TestParms - RecvBufferSize Error - %x\n", RecvBufferSize));
+ return EFI_DEVICE_ERROR;
+ }
+ if (SwapBytes32(RecvBuffer.Header.responseCode) != TPM_RC_SUCCESS) {
+ DEBUG ((EFI_D_ERROR, "Tpm2TestParms - responseCode - %x\n", SwapBytes32(RecvBuffer.Header.responseCode)));
+ return EFI_UNSUPPORTED;
+ }
+
+ return EFI_SUCCESS;
+}
diff --git a/SecurityPkg/Library/Tpm2CommandLib/Tpm2CommandLib.inf b/SecurityPkg/Library/Tpm2CommandLib/Tpm2CommandLib.inf
new file mode 100644
index 000000000..804f06342
--- /dev/null
+++ b/SecurityPkg/Library/Tpm2CommandLib/Tpm2CommandLib.inf
@@ -0,0 +1,48 @@
+## @file
+# This library is used by other modules to send TPM2 command.
+#
+# Copyright (c) 2013, 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.
+#
+##
+
+[Defines]
+ INF_VERSION = 0x00010005
+ BASE_NAME = Tpm2CommandLib
+ FILE_GUID = 2F572F32-8BE5-4868-BD1D-7438AD97DC27
+ MODULE_TYPE = BASE
+ VERSION_STRING = 1.0
+ LIBRARY_CLASS = Tpm2CommandLib
+
+#
+# The following information is for reference only and not required by the build tools.
+#
+# VALID_ARCHITECTURES = IA32 X64 IPF
+#
+
+[Sources]
+ Tpm2Capability.c
+ Tpm2Sequences.c
+ Tpm2Integrity.c
+ Tpm2Hierarchy.c
+ Tpm2NVStorage.c
+ Tpm2Startup.c
+ Tpm2Test.c
+ Tpm2DictionaryAttack.c
+ Tpm2Miscellaneous.c
+ Tpm2Help.c
+
+[Packages]
+ MdePkg/MdePkg.dec
+ SecurityPkg/SecurityPkg.dec
+
+[LibraryClasses]
+ BaseLib
+ BaseMemoryLib
+ DebugLib
+ Tpm2DeviceLib
diff --git a/SecurityPkg/Library/Tpm2CommandLib/Tpm2DictionaryAttack.c b/SecurityPkg/Library/Tpm2CommandLib/Tpm2DictionaryAttack.c
new file mode 100644
index 000000000..2f6488fb9
--- /dev/null
+++ b/SecurityPkg/Library/Tpm2CommandLib/Tpm2DictionaryAttack.c
@@ -0,0 +1,203 @@
+/** @file
+ Implement TPM2 DictionaryAttack related command.
+
+Copyright (c) 2013, 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.
+
+**/
+
+#include <IndustryStandard/UefiTcgPlatform.h>
+#include <Library/Tpm2CommandLib.h>
+#include <Library/Tpm2DeviceLib.h>
+#include <Library/BaseMemoryLib.h>
+#include <Library/BaseLib.h>
+#include <Library/DebugLib.h>
+
+#pragma pack(1)
+
+typedef struct {
+ TPM2_COMMAND_HEADER Header;
+ TPMI_RH_LOCKOUT LockHandle;
+ UINT32 AuthSessionSize;
+ TPMS_AUTH_COMMAND AuthSession;
+} TPM2_DICTIONARY_ATTACK_LOCK_RESET_COMMAND;
+
+typedef struct {
+ TPM2_RESPONSE_HEADER Header;
+ UINT32 AuthSessionSize;
+ TPMS_AUTH_RESPONSE AuthSession;
+} TPM2_DICTIONARY_ATTACK_LOCK_RESET_RESPONSE;
+
+typedef struct {
+ TPM2_COMMAND_HEADER Header;
+ TPMI_RH_LOCKOUT LockHandle;
+ UINT32 AuthSessionSize;
+ TPMS_AUTH_COMMAND AuthSession;
+ UINT32 NewMaxTries;
+ UINT32 NewRecoveryTime;
+ UINT32 LockoutRecovery;
+} TPM2_DICTIONARY_ATTACK_PARAMETERS_COMMAND;
+
+typedef struct {
+ TPM2_RESPONSE_HEADER Header;
+ UINT32 AuthSessionSize;
+ TPMS_AUTH_RESPONSE AuthSession;
+} TPM2_DICTIONARY_ATTACK_PARAMETERS_RESPONSE;
+
+#pragma pack()
+
+/**
+ This command cancels the effect of a TPM lockout due to a number of successive authorization failures.
+ If this command is properly authorized, the lockout counter is set to zero.
+
+ @param[in] LockHandle TPM_RH_LOCKOUT
+ @param[in] AuthSession Auth Session context
+
+ @retval EFI_SUCCESS Operation completed successfully.
+ @retval EFI_DEVICE_ERROR Unexpected device behavior.
+**/
+EFI_STATUS
+EFIAPI
+Tpm2DictionaryAttackLockReset (
+ IN TPMI_RH_LOCKOUT LockHandle,
+ IN TPMS_AUTH_COMMAND *AuthSession
+ )
+{
+ EFI_STATUS Status;
+ TPM2_DICTIONARY_ATTACK_LOCK_RESET_COMMAND SendBuffer;
+ TPM2_DICTIONARY_ATTACK_LOCK_RESET_RESPONSE RecvBuffer;
+ UINT32 SendBufferSize;
+ UINT32 RecvBufferSize;
+ UINT8 *Buffer;
+ UINT32 SessionInfoSize;
+
+ //
+ // Construct command
+ //
+ SendBuffer.Header.tag = SwapBytes16(TPM_ST_SESSIONS);
+ SendBuffer.Header.commandCode = SwapBytes32(TPM_CC_DictionaryAttackLockReset);
+
+ SendBuffer.LockHandle = SwapBytes32 (LockHandle);
+
+ //
+ // Add in Auth session
+ //
+ Buffer = (UINT8 *)&SendBuffer.AuthSession;
+
+ // sessionInfoSize
+ SessionInfoSize = CopyAuthSessionCommand (AuthSession, Buffer);
+ Buffer += SessionInfoSize;
+ SendBuffer.AuthSessionSize = SwapBytes32(SessionInfoSize);
+
+ SendBufferSize = (UINT32)((UINTN)Buffer - (UINTN)&SendBuffer);
+ SendBuffer.Header.paramSize = SwapBytes32 (SendBufferSize);
+
+ //
+ // send Tpm command
+ //
+ RecvBufferSize = sizeof (RecvBuffer);
+ Status = Tpm2SubmitCommand (SendBufferSize, (UINT8 *)&SendBuffer, &RecvBufferSize, (UINT8 *)&RecvBuffer);
+ if (EFI_ERROR (Status)) {
+ return Status;
+ }
+
+ if (RecvBufferSize < sizeof (TPM2_RESPONSE_HEADER)) {
+ DEBUG ((EFI_D_ERROR, "Tpm2DictionaryAttackLockReset - RecvBufferSize Error - %x\n", RecvBufferSize));
+ return EFI_DEVICE_ERROR;
+ }
+ if (SwapBytes32(RecvBuffer.Header.responseCode) != TPM_RC_SUCCESS) {
+ DEBUG ((EFI_D_ERROR, "Tpm2DictionaryAttackLockReset - responseCode - %x\n", SwapBytes32(RecvBuffer.Header.responseCode)));
+ return EFI_DEVICE_ERROR;
+ }
+
+ return EFI_SUCCESS;
+}
+
+/**
+ This command cancels the effect of a TPM lockout due to a number of successive authorization failures.
+ If this command is properly authorized, the lockout counter is set to zero.
+
+ @param[in] LockHandle TPM_RH_LOCKOUT
+ @param[in] AuthSession Auth Session context
+ @param[in] NewMaxTries Count of authorization failures before the lockout is imposed
+ @param[in] NewRecoveryTime Time in seconds before the authorization failure count is automatically decremented
+ @param[in] LockoutRecovery Time in seconds after a lockoutAuth failure before use of lockoutAuth is allowed
+
+ @retval EFI_SUCCESS Operation completed successfully.
+ @retval EFI_DEVICE_ERROR Unexpected device behavior.
+**/
+EFI_STATUS
+EFIAPI
+Tpm2DictionaryAttackParameters (
+ IN TPMI_RH_LOCKOUT LockHandle,
+ IN TPMS_AUTH_COMMAND *AuthSession,
+ IN UINT32 NewMaxTries,
+ IN UINT32 NewRecoveryTime,
+ IN UINT32 LockoutRecovery
+ )
+{
+ EFI_STATUS Status;
+ TPM2_DICTIONARY_ATTACK_PARAMETERS_COMMAND SendBuffer;
+ TPM2_DICTIONARY_ATTACK_PARAMETERS_RESPONSE RecvBuffer;
+ UINT32 SendBufferSize;
+ UINT32 RecvBufferSize;
+ UINT8 *Buffer;
+ UINT32 SessionInfoSize;
+
+ //
+ // Construct command
+ //
+ SendBuffer.Header.tag = SwapBytes16(TPM_ST_SESSIONS);
+ SendBuffer.Header.commandCode = SwapBytes32(TPM_CC_DictionaryAttackParameters);
+
+ SendBuffer.LockHandle = SwapBytes32 (LockHandle);
+
+ //
+ // Add in Auth session
+ //
+ Buffer = (UINT8 *)&SendBuffer.AuthSession;
+
+ // sessionInfoSize
+ SessionInfoSize = CopyAuthSessionCommand (AuthSession, Buffer);
+ Buffer += SessionInfoSize;
+ SendBuffer.AuthSessionSize = SwapBytes32(SessionInfoSize);
+
+ //
+ // Real data
+ //
+ WriteUnaligned32 ((UINT32 *)Buffer, SwapBytes32(NewMaxTries));
+ Buffer += sizeof(UINT32);
+ WriteUnaligned32 ((UINT32 *)Buffer, SwapBytes32(NewRecoveryTime));
+ Buffer += sizeof(UINT32);
+ WriteUnaligned32 ((UINT32 *)Buffer, SwapBytes32(LockoutRecovery));
+ Buffer += sizeof(UINT32);
+
+ SendBufferSize = (UINT32)((UINTN)Buffer - (UINTN)&SendBuffer);
+ SendBuffer.Header.paramSize = SwapBytes32 (SendBufferSize);
+
+ //
+ // send Tpm command
+ //
+ RecvBufferSize = sizeof (RecvBuffer);
+ Status = Tpm2SubmitCommand (SendBufferSize, (UINT8 *)&SendBuffer, &RecvBufferSize, (UINT8 *)&RecvBuffer);
+ if (EFI_ERROR (Status)) {
+ return Status;
+ }
+
+ if (RecvBufferSize < sizeof (TPM2_RESPONSE_HEADER)) {
+ DEBUG ((EFI_D_ERROR, "Tpm2DictionaryAttackParameters - RecvBufferSize Error - %x\n", RecvBufferSize));
+ return EFI_DEVICE_ERROR;
+ }
+ if (SwapBytes32(RecvBuffer.Header.responseCode) != TPM_RC_SUCCESS) {
+ DEBUG ((EFI_D_ERROR, "Tpm2DictionaryAttackParameters - responseCode - %x\n", SwapBytes32(RecvBuffer.Header.responseCode)));
+ return EFI_DEVICE_ERROR;
+ }
+
+ return EFI_SUCCESS;
+}
diff --git a/SecurityPkg/Library/Tpm2CommandLib/Tpm2Help.c b/SecurityPkg/Library/Tpm2CommandLib/Tpm2Help.c
new file mode 100644
index 000000000..4f5fcb5a7
--- /dev/null
+++ b/SecurityPkg/Library/Tpm2CommandLib/Tpm2Help.c
@@ -0,0 +1,166 @@
+/** @file
+ Implement TPM2 help.
+
+Copyright (c) 2013, 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.
+
+**/
+
+#include <IndustryStandard/UefiTcgPlatform.h>
+#include <Library/Tpm2CommandLib.h>
+#include <Library/Tpm2DeviceLib.h>
+#include <Library/BaseMemoryLib.h>
+#include <Library/BaseLib.h>
+#include <Library/DebugLib.h>
+
+typedef struct {
+ TPMI_ALG_HASH HashAlgo;
+ UINT16 HashSize;
+} INTERNAL_HASH_INFO;
+
+STATIC INTERNAL_HASH_INFO mHashInfo[] = {
+ {TPM_ALG_SHA1, SHA1_DIGEST_SIZE},
+ {TPM_ALG_SHA256, SHA256_DIGEST_SIZE},
+ {TPM_ALG_SM3_256, SM3_256_DIGEST_SIZE},
+ {TPM_ALG_SHA384, SHA384_DIGEST_SIZE},
+ {TPM_ALG_SHA512, SHA512_DIGEST_SIZE},
+};
+
+/**
+ Return size of digest.
+
+ @param[in] HashAlgo Hash algorithm
+
+ @return size of digest
+**/
+UINT16
+EFIAPI
+GetHashSizeFromAlgo (
+ IN TPMI_ALG_HASH HashAlgo
+ )
+{
+ UINTN Index;
+
+ for (Index = 0; Index < sizeof(mHashInfo)/sizeof(mHashInfo[0]); Index++) {
+ if (mHashInfo[Index].HashAlgo == HashAlgo) {
+ return mHashInfo[Index].HashSize;
+ }
+ }
+ return 0;
+}
+
+/**
+ Copy AuthSessionIn to TPM2 command buffer.
+
+ @param [in] AuthSessionIn Input AuthSession data
+ @param [out] AuthSessionOut Output AuthSession data in TPM2 command buffer
+
+ @return AuthSession size
+**/
+UINT32
+EFIAPI
+CopyAuthSessionCommand (
+ IN TPMS_AUTH_COMMAND *AuthSessionIn, OPTIONAL
+ OUT UINT8 *AuthSessionOut
+ )
+{
+ UINT8 *Buffer;
+
+ Buffer = (UINT8 *)AuthSessionOut;
+
+ //
+ // Add in Auth session
+ //
+ if (AuthSessionIn != NULL) {
+ // sessionHandle
+ WriteUnaligned32 ((UINT32 *)Buffer, SwapBytes32(AuthSessionIn->sessionHandle));
+ Buffer += sizeof(UINT32);
+
+ // nonce
+ WriteUnaligned16 ((UINT16 *)Buffer, SwapBytes16 (AuthSessionIn->nonce.size));
+ Buffer += sizeof(UINT16);
+
+ CopyMem (Buffer, AuthSessionIn->nonce.buffer, AuthSessionIn->nonce.size);
+ Buffer += AuthSessionIn->nonce.size;
+
+ // sessionAttributes
+ *(UINT8 *)Buffer = *(UINT8 *)&AuthSessionIn->sessionAttributes;
+ Buffer += sizeof(UINT8);
+
+ // hmac
+ WriteUnaligned16 ((UINT16 *)Buffer, SwapBytes16 (AuthSessionIn->hmac.size));
+ Buffer += sizeof(UINT16);
+
+ CopyMem (Buffer, AuthSessionIn->hmac.buffer, AuthSessionIn->hmac.size);
+ Buffer += AuthSessionIn->hmac.size;
+ } else {
+ // sessionHandle
+ WriteUnaligned32 ((UINT32 *)Buffer, SwapBytes32(TPM_RS_PW));
+ Buffer += sizeof(UINT32);
+
+ // nonce = nullNonce
+ WriteUnaligned16 ((UINT16 *)Buffer, SwapBytes16(0));
+ Buffer += sizeof(UINT16);
+
+ // sessionAttributes = 0
+ *(UINT8 *)Buffer = 0x00;
+ Buffer += sizeof(UINT8);
+
+ // hmac = nullAuth
+ WriteUnaligned16 ((UINT16 *)Buffer, SwapBytes16(0));
+ Buffer += sizeof(UINT16);
+ }
+
+ return (UINT32)(UINTN)(Buffer - (UINT8 *)AuthSessionOut);
+}
+
+/**
+ Copy AuthSessionIn from TPM2 response buffer.
+
+ @param [in] AuthSessionIn Input AuthSession data in TPM2 response buffer
+ @param [out] AuthSessionOut Output AuthSession data
+
+ @return AuthSession size
+**/
+UINT32
+EFIAPI
+CopyAuthSessionResponse (
+ IN UINT8 *AuthSessionIn,
+ OUT TPMS_AUTH_RESPONSE *AuthSessionOut OPTIONAL
+ )
+{
+ UINT8 *Buffer;
+ TPMS_AUTH_RESPONSE LocalAuthSessionOut;
+
+ if (AuthSessionOut == NULL) {
+ AuthSessionOut = &LocalAuthSessionOut;
+ }
+
+ Buffer = (UINT8 *)AuthSessionIn;
+
+ // nonce
+ AuthSessionOut->nonce.size = SwapBytes16 (ReadUnaligned16 ((UINT16 *)Buffer));
+ Buffer += sizeof(UINT16);
+
+ CopyMem (AuthSessionOut->nonce.buffer, Buffer, AuthSessionOut->nonce.size);
+ Buffer += AuthSessionOut->nonce.size;
+
+ // sessionAttributes
+ *(UINT8 *)&AuthSessionOut->sessionAttributes = *(UINT8 *)Buffer;
+ Buffer += sizeof(UINT8);
+
+ // hmac
+ AuthSessionOut->hmac.size = SwapBytes16 (ReadUnaligned16 ((UINT16 *)Buffer));
+ Buffer += sizeof(UINT16);
+
+ CopyMem (AuthSessionOut->hmac.buffer, Buffer, AuthSessionOut->hmac.size);
+ Buffer += AuthSessionOut->hmac.size;
+
+ return (UINT32)(UINTN)(Buffer - (UINT8 *)AuthSessionIn);
+}
diff --git a/SecurityPkg/Library/Tpm2CommandLib/Tpm2Hierarchy.c b/SecurityPkg/Library/Tpm2CommandLib/Tpm2Hierarchy.c
new file mode 100644
index 000000000..c6935d9a8
--- /dev/null
+++ b/SecurityPkg/Library/Tpm2CommandLib/Tpm2Hierarchy.c
@@ -0,0 +1,635 @@
+/** @file
+ Implement TPM2 Hierarchy related command.
+
+Copyright (c) 2013, 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.
+
+**/
+
+#include <IndustryStandard/UefiTcgPlatform.h>
+#include <Library/Tpm2CommandLib.h>
+#include <Library/Tpm2DeviceLib.h>
+#include <Library/BaseMemoryLib.h>
+#include <Library/BaseLib.h>
+#include <Library/DebugLib.h>
+
+#pragma pack(1)
+
+typedef struct {
+ TPM2_COMMAND_HEADER Header;
+ TPMI_RH_CLEAR AuthHandle;
+ UINT32 AuthorizationSize;
+ TPMS_AUTH_COMMAND AuthSession;
+} TPM2_CLEAR_COMMAND;
+
+typedef struct {
+ TPM2_RESPONSE_HEADER Header;
+ UINT32 ParameterSize;
+ TPMS_AUTH_RESPONSE AuthSession;
+} TPM2_CLEAR_RESPONSE;
+
+typedef struct {
+ TPM2_COMMAND_HEADER Header;
+ TPMI_RH_CLEAR AuthHandle;
+ UINT32 AuthorizationSize;
+ TPMS_AUTH_COMMAND AuthSession;
+ TPMI_YES_NO Disable;
+} TPM2_CLEAR_CONTROL_COMMAND;
+
+typedef struct {
+ TPM2_RESPONSE_HEADER Header;
+ UINT32 ParameterSize;
+ TPMS_AUTH_RESPONSE AuthSession;
+} TPM2_CLEAR_CONTROL_RESPONSE;
+
+typedef struct {
+ TPM2_COMMAND_HEADER Header;
+ TPMI_RH_HIERARCHY_AUTH AuthHandle;
+ UINT32 AuthorizationSize;
+ TPMS_AUTH_COMMAND AuthSession;
+ TPM2B_AUTH NewAuth;
+} TPM2_HIERARCHY_CHANGE_AUTH_COMMAND;
+
+typedef struct {
+ TPM2_RESPONSE_HEADER Header;
+ UINT32 ParameterSize;
+ TPMS_AUTH_RESPONSE AuthSession;
+} TPM2_HIERARCHY_CHANGE_AUTH_RESPONSE;
+
+typedef struct {
+ TPM2_COMMAND_HEADER Header;
+ TPMI_RH_PLATFORM AuthHandle;
+ UINT32 AuthorizationSize;
+ TPMS_AUTH_COMMAND AuthSession;
+} TPM2_CHANGE_EPS_COMMAND;
+
+typedef struct {
+ TPM2_RESPONSE_HEADER Header;
+ UINT32 ParameterSize;
+ TPMS_AUTH_RESPONSE AuthSession;
+} TPM2_CHANGE_EPS_RESPONSE;
+
+typedef struct {
+ TPM2_COMMAND_HEADER Header;
+ TPMI_RH_PLATFORM AuthHandle;
+ UINT32 AuthorizationSize;
+ TPMS_AUTH_COMMAND AuthSession;
+} TPM2_CHANGE_PPS_COMMAND;
+
+typedef struct {
+ TPM2_RESPONSE_HEADER Header;
+ UINT32 ParameterSize;
+ TPMS_AUTH_RESPONSE AuthSession;
+} TPM2_CHANGE_PPS_RESPONSE;
+
+typedef struct {
+ TPM2_COMMAND_HEADER Header;
+ TPMI_RH_HIERARCHY AuthHandle;
+ UINT32 AuthorizationSize;
+ TPMS_AUTH_COMMAND AuthSession;
+ TPMI_RH_HIERARCHY Hierarchy;
+ TPMI_YES_NO State;
+} TPM2_HIERARCHY_CONTROL_COMMAND;
+
+typedef struct {
+ TPM2_RESPONSE_HEADER Header;
+ UINT32 ParameterSize;
+ TPMS_AUTH_RESPONSE AuthSession;
+} TPM2_HIERARCHY_CONTROL_RESPONSE;
+
+#pragma pack()
+
+/**
+ This command removes all TPM context associated with a specific Owner.
+
+ @param[in] AuthHandle TPM_RH_LOCKOUT or TPM_RH_PLATFORM+{PP}
+ @param[in] AuthSession Auth Session context
+
+ @retval EFI_SUCCESS Operation completed successfully.
+ @retval EFI_DEVICE_ERROR Unexpected device behavior.
+**/
+EFI_STATUS
+EFIAPI
+Tpm2Clear (
+ IN TPMI_RH_CLEAR AuthHandle,
+ IN TPMS_AUTH_COMMAND *AuthSession OPTIONAL
+ )
+{
+ EFI_STATUS Status;
+ TPM2_CLEAR_COMMAND Cmd;
+ TPM2_CLEAR_RESPONSE Res;
+ UINT32 ResultBufSize;
+ UINT32 CmdSize;
+ UINT32 RespSize;
+ UINT8 *Buffer;
+ UINT32 SessionInfoSize;
+
+ Cmd.Header.tag = SwapBytes16(TPM_ST_SESSIONS);
+ Cmd.Header.commandCode = SwapBytes32(TPM_CC_Clear);
+ Cmd.AuthHandle = SwapBytes32(AuthHandle);
+
+ //
+ // Add in Auth session
+ //
+ Buffer = (UINT8 *)&Cmd.AuthSession;
+
+ // sessionInfoSize
+ SessionInfoSize = CopyAuthSessionCommand (AuthSession, Buffer);
+ Buffer += SessionInfoSize;
+ Cmd.AuthorizationSize = SwapBytes32(SessionInfoSize);
+
+ CmdSize = (UINT32)(Buffer - (UINT8 *)&Cmd);
+ Cmd.Header.paramSize = SwapBytes32(CmdSize);
+
+ ResultBufSize = sizeof(Res);
+ Status = Tpm2SubmitCommand (CmdSize, (UINT8 *)&Cmd, &ResultBufSize, (UINT8 *)&Res);
+ if (EFI_ERROR(Status)) {
+ return Status;
+ }
+
+ if (ResultBufSize > sizeof(Res)) {
+ DEBUG ((EFI_D_ERROR, "Clear: Failed ExecuteCommand: Buffer Too Small\r\n"));
+ return EFI_BUFFER_TOO_SMALL;
+ }
+
+ //
+ // Validate response headers
+ //
+ RespSize = SwapBytes32(Res.Header.paramSize);
+ if (RespSize > sizeof(Res)) {
+ DEBUG ((EFI_D_ERROR, "Clear: Response size too large! %d\r\n", RespSize));
+ return EFI_BUFFER_TOO_SMALL;
+ }
+
+ //
+ // Fail if command failed
+ //
+ if (SwapBytes32(Res.Header.responseCode) != TPM_RC_SUCCESS) {
+ DEBUG ((EFI_D_ERROR, "Clear: Response Code error! 0x%08x\r\n", SwapBytes32(Res.Header.responseCode)));
+ return EFI_DEVICE_ERROR;
+ }
+
+ //
+ // Unmarshal the response
+ //
+
+ // None
+
+ return EFI_SUCCESS;
+}
+
+/**
+ Disables and enables the execution of TPM2_Clear().
+
+ @param[in] AuthHandle TPM_RH_LOCKOUT or TPM_RH_PLATFORM+{PP}
+ @param[in] AuthSession Auth Session context
+ @param[in] Disable YES if the disableOwnerClear flag is to be SET,
+ NO if the flag is to be CLEAR.
+
+ @retval EFI_SUCCESS Operation completed successfully.
+ @retval EFI_DEVICE_ERROR Unexpected device behavior.
+**/
+EFI_STATUS
+EFIAPI
+Tpm2ClearControl (
+ IN TPMI_RH_CLEAR AuthHandle,
+ IN TPMS_AUTH_COMMAND *AuthSession, OPTIONAL
+ IN TPMI_YES_NO Disable
+ )
+{
+ EFI_STATUS Status;
+ TPM2_CLEAR_CONTROL_COMMAND Cmd;
+ TPM2_CLEAR_CONTROL_RESPONSE Res;
+ UINT32 ResultBufSize;
+ UINT32 CmdSize;
+ UINT32 RespSize;
+ UINT8 *Buffer;
+ UINT32 SessionInfoSize;
+
+ Cmd.Header.tag = SwapBytes16(TPM_ST_SESSIONS);
+ Cmd.Header.commandCode = SwapBytes32(TPM_CC_ClearControl);
+ Cmd.AuthHandle = SwapBytes32(AuthHandle);
+
+ //
+ // Add in Auth session
+ //
+ Buffer = (UINT8 *)&Cmd.AuthSession;
+
+ // sessionInfoSize
+ SessionInfoSize = CopyAuthSessionCommand (AuthSession, Buffer);
+ Buffer += SessionInfoSize;
+ Cmd.AuthorizationSize = SwapBytes32(SessionInfoSize);
+
+ // disable
+ *(UINT8 *)Buffer = Disable;
+ Buffer += sizeof(UINT8);
+
+ CmdSize = (UINT32)(Buffer - (UINT8 *)&Cmd);
+ Cmd.Header.paramSize = SwapBytes32(CmdSize);
+
+ ResultBufSize = sizeof(Res);
+ Status = Tpm2SubmitCommand (CmdSize, (UINT8 *)&Cmd, &ResultBufSize, (UINT8 *)&Res);
+ if (EFI_ERROR(Status)) {
+ return Status;
+ }
+
+ if (ResultBufSize > sizeof(Res)) {
+ DEBUG ((EFI_D_ERROR, "ClearControl: Failed ExecuteCommand: Buffer Too Small\r\n"));
+ return EFI_BUFFER_TOO_SMALL;
+ }
+
+ //
+ // Validate response headers
+ //
+ RespSize = SwapBytes32(Res.Header.paramSize);
+ if (RespSize > sizeof(Res)) {
+ DEBUG ((EFI_D_ERROR, "ClearControl: Response size too large! %d\r\n", RespSize));
+ return EFI_BUFFER_TOO_SMALL;
+ }
+
+ //
+ // Fail if command failed
+ //
+ if (SwapBytes32(Res.Header.responseCode) != TPM_RC_SUCCESS) {
+ DEBUG ((EFI_D_ERROR, "ClearControl: Response Code error! 0x%08x\r\n", SwapBytes32(Res.Header.responseCode)));
+ return EFI_DEVICE_ERROR;
+ }
+
+ //
+ // Unmarshal the response
+ //
+
+ // None
+
+ return EFI_SUCCESS;
+}
+
+/**
+ This command allows the authorization secret for a hierarchy or lockout to be changed using the current
+ authorization value as the command authorization.
+
+ @param[in] AuthHandle TPM_RH_LOCKOUT, TPM_RH_ENDORSEMENT, TPM_RH_OWNER or TPM_RH_PLATFORM+{PP}
+ @param[in] AuthSession Auth Session context
+ @param[in] NewAuth New authorization secret
+
+ @retval EFI_SUCCESS Operation completed successfully.
+ @retval EFI_DEVICE_ERROR Unexpected device behavior.
+**/
+EFI_STATUS
+EFIAPI
+Tpm2HierarchyChangeAuth (
+ IN TPMI_RH_HIERARCHY_AUTH AuthHandle,
+ IN TPMS_AUTH_COMMAND *AuthSession,
+ IN TPM2B_AUTH *NewAuth
+ )
+{
+ EFI_STATUS Status;
+ TPM2_HIERARCHY_CHANGE_AUTH_COMMAND Cmd;
+ TPM2_HIERARCHY_CHANGE_AUTH_RESPONSE Res;
+ UINT32 CmdSize;
+ UINT32 RespSize;
+ UINT8 *Buffer;
+ UINT32 SessionInfoSize;
+ UINT8 *ResultBuf;
+ UINT32 ResultBufSize;
+
+ //
+ // Construct command
+ //
+ Cmd.Header.tag = SwapBytes16(TPM_ST_SESSIONS);
+ Cmd.Header.paramSize = SwapBytes32(sizeof(Cmd));
+ Cmd.Header.commandCode = SwapBytes32(TPM_CC_HierarchyChangeAuth);
+ Cmd.AuthHandle = SwapBytes32(AuthHandle);
+
+ //
+ // Add in Auth session
+ //
+ Buffer = (UINT8 *)&Cmd.AuthSession;
+
+ // sessionInfoSize
+ SessionInfoSize = CopyAuthSessionCommand (AuthSession, Buffer);
+ Buffer += SessionInfoSize;
+ Cmd.AuthorizationSize = SwapBytes32(SessionInfoSize);
+
+ // New Authorization size
+ WriteUnaligned16 ((UINT16 *)Buffer, SwapBytes16(NewAuth->size));
+ Buffer += sizeof(UINT16);
+
+ // New Authorizeation
+ CopyMem(Buffer, NewAuth->buffer, NewAuth->size);
+ Buffer += NewAuth->size;
+
+ CmdSize = (UINT32)(Buffer - (UINT8 *)&Cmd);
+ Cmd.Header.paramSize = SwapBytes32(CmdSize);
+
+ ResultBuf = (UINT8 *) &Res;
+ ResultBufSize = sizeof(Res);
+
+ //
+ // Call the TPM
+ //
+ Status = Tpm2SubmitCommand (
+ CmdSize,
+ (UINT8 *)&Cmd,
+ &ResultBufSize,
+ ResultBuf
+ );
+
+ if (ResultBufSize > sizeof(Res)) {
+ DEBUG ((EFI_D_ERROR, "HierarchyChangeAuth: Failed ExecuteCommand: Buffer Too Small\r\n"));
+ return EFI_BUFFER_TOO_SMALL;
+ }
+
+ //
+ // Validate response headers
+ //
+ RespSize = SwapBytes32(Res.Header.paramSize);
+ if (RespSize > sizeof(Res)) {
+ DEBUG ((EFI_D_ERROR, "HierarchyChangeAuth: Response size too large! %d\r\n", RespSize));
+ return EFI_BUFFER_TOO_SMALL;
+ }
+
+ //
+ // Fail if command failed
+ //
+ if (SwapBytes32(Res.Header.responseCode) != TPM_RC_SUCCESS) {
+ DEBUG((EFI_D_ERROR,"HierarchyChangeAuth: Response Code error! 0x%08x\r\n", SwapBytes32(Res.Header.responseCode)));
+ return EFI_DEVICE_ERROR;
+ }
+
+ return EFI_SUCCESS;
+}
+
+/**
+ This replaces the current EPS with a value from the RNG and sets the Endorsement hierarchy controls to
+ their default initialization values.
+
+ @param[in] AuthHandle TPM_RH_PLATFORM+{PP}
+ @param[in] AuthSession Auth Session context
+
+ @retval EFI_SUCCESS Operation completed successfully.
+ @retval EFI_DEVICE_ERROR Unexpected device behavior.
+**/
+EFI_STATUS
+EFIAPI
+Tpm2ChangeEPS (
+ IN TPMI_RH_PLATFORM AuthHandle,
+ IN TPMS_AUTH_COMMAND *AuthSession
+ )
+{
+ EFI_STATUS Status;
+ TPM2_CHANGE_EPS_COMMAND Cmd;
+ TPM2_CHANGE_EPS_RESPONSE Res;
+ UINT32 CmdSize;
+ UINT32 RespSize;
+ UINT8 *Buffer;
+ UINT32 SessionInfoSize;
+ UINT8 *ResultBuf;
+ UINT32 ResultBufSize;
+
+ //
+ // Construct command
+ //
+ Cmd.Header.tag = SwapBytes16(TPM_ST_SESSIONS);
+ Cmd.Header.paramSize = SwapBytes32(sizeof(Cmd));
+ Cmd.Header.commandCode = SwapBytes32(TPM_CC_ChangeEPS);
+ Cmd.AuthHandle = SwapBytes32(AuthHandle);
+
+ //
+ // Add in Auth session
+ //
+ Buffer = (UINT8 *)&Cmd.AuthSession;
+
+ // sessionInfoSize
+ SessionInfoSize = CopyAuthSessionCommand (AuthSession, Buffer);
+ Buffer += SessionInfoSize;
+ Cmd.AuthorizationSize = SwapBytes32(SessionInfoSize);
+
+ CmdSize = (UINT32)(Buffer - (UINT8 *)&Cmd);
+ Cmd.Header.paramSize = SwapBytes32(CmdSize);
+
+ ResultBuf = (UINT8 *) &Res;
+ ResultBufSize = sizeof(Res);
+
+ //
+ // Call the TPM
+ //
+ Status = Tpm2SubmitCommand (
+ CmdSize,
+ (UINT8 *)&Cmd,
+ &ResultBufSize,
+ ResultBuf
+ );
+
+ if (ResultBufSize > sizeof(Res)) {
+ DEBUG ((EFI_D_ERROR, "ChangeEPS: Failed ExecuteCommand: Buffer Too Small\r\n"));
+ return EFI_BUFFER_TOO_SMALL;
+ }
+
+ //
+ // Validate response headers
+ //
+ RespSize = SwapBytes32(Res.Header.paramSize);
+ if (RespSize > sizeof(Res)) {
+ DEBUG ((EFI_D_ERROR, "ChangeEPS: Response size too large! %d\r\n", RespSize));
+ return EFI_BUFFER_TOO_SMALL;
+ }
+
+ //
+ // Fail if command failed
+ //
+ if (SwapBytes32(Res.Header.responseCode) != TPM_RC_SUCCESS) {
+ DEBUG((EFI_D_ERROR,"ChangeEPS: Response Code error! 0x%08x\r\n", SwapBytes32(Res.Header.responseCode)));
+ return EFI_DEVICE_ERROR;
+ }
+
+ return EFI_SUCCESS;
+}
+
+/**
+ This replaces the current PPS with a value from the RNG and sets platformPolicy to the default
+ initialization value (the Empty Buffer).
+
+ @param[in] AuthHandle TPM_RH_PLATFORM+{PP}
+ @param[in] AuthSession Auth Session context
+
+ @retval EFI_SUCCESS Operation completed successfully.
+ @retval EFI_DEVICE_ERROR Unexpected device behavior.
+**/
+EFI_STATUS
+EFIAPI
+Tpm2ChangePPS (
+ IN TPMI_RH_PLATFORM AuthHandle,
+ IN TPMS_AUTH_COMMAND *AuthSession
+ )
+{
+ EFI_STATUS Status;
+ TPM2_CHANGE_PPS_COMMAND Cmd;
+ TPM2_CHANGE_PPS_RESPONSE Res;
+ UINT32 CmdSize;
+ UINT32 RespSize;
+ UINT8 *Buffer;
+ UINT32 SessionInfoSize;
+ UINT8 *ResultBuf;
+ UINT32 ResultBufSize;
+
+ //
+ // Construct command
+ //
+ Cmd.Header.tag = SwapBytes16(TPM_ST_SESSIONS);
+ Cmd.Header.paramSize = SwapBytes32(sizeof(Cmd));
+ Cmd.Header.commandCode = SwapBytes32(TPM_CC_ChangePPS);
+ Cmd.AuthHandle = SwapBytes32(AuthHandle);
+
+ //
+ // Add in Auth session
+ //
+ Buffer = (UINT8 *)&Cmd.AuthSession;
+
+ // sessionInfoSize
+ SessionInfoSize = CopyAuthSessionCommand (AuthSession, Buffer);
+ Buffer += SessionInfoSize;
+ Cmd.AuthorizationSize = SwapBytes32(SessionInfoSize);
+
+ CmdSize = (UINT32)(Buffer - (UINT8 *)&Cmd);
+ Cmd.Header.paramSize = SwapBytes32(CmdSize);
+
+ ResultBuf = (UINT8 *) &Res;
+ ResultBufSize = sizeof(Res);
+
+ //
+ // Call the TPM
+ //
+ Status = Tpm2SubmitCommand (
+ CmdSize,
+ (UINT8 *)&Cmd,
+ &ResultBufSize,
+ ResultBuf
+ );
+
+ if (ResultBufSize > sizeof(Res)) {
+ DEBUG ((EFI_D_ERROR, "ChangePPS: Failed ExecuteCommand: Buffer Too Small\r\n"));
+ return EFI_BUFFER_TOO_SMALL;
+ }
+
+ //
+ // Validate response headers
+ //
+ RespSize = SwapBytes32(Res.Header.paramSize);
+ if (RespSize > sizeof(Res)) {
+ DEBUG ((EFI_D_ERROR, "ChangePPS: Response size too large! %d\r\n", RespSize));
+ return EFI_BUFFER_TOO_SMALL;
+ }
+
+ //
+ // Fail if command failed
+ //
+ if (SwapBytes32(Res.Header.responseCode) != TPM_RC_SUCCESS) {
+ DEBUG((EFI_D_ERROR,"ChangePPS: Response Code error! 0x%08x\r\n", SwapBytes32(Res.Header.responseCode)));
+ return EFI_DEVICE_ERROR;
+ }
+
+ return EFI_SUCCESS;
+}
+
+/**
+ This command enables and disables use of a hierarchy.
+
+ @param[in] AuthHandle TPM_RH_ENDORSEMENT, TPM_RH_OWNER or TPM_RH_PLATFORM+{PP}
+ @param[in] AuthSession Auth Session context
+ @param[in] Hierarchy Hierarchy of the enable being modified
+ @param[in] State YES if the enable should be SET,
+ NO if the enable should be CLEAR
+
+ @retval EFI_SUCCESS Operation completed successfully.
+ @retval EFI_DEVICE_ERROR Unexpected device behavior.
+**/
+EFI_STATUS
+EFIAPI
+Tpm2HierarchyControl (
+ IN TPMI_RH_HIERARCHY AuthHandle,
+ IN TPMS_AUTH_COMMAND *AuthSession,
+ IN TPMI_RH_HIERARCHY Hierarchy,
+ IN TPMI_YES_NO State
+ )
+{
+ EFI_STATUS Status;
+ TPM2_HIERARCHY_CONTROL_COMMAND Cmd;
+ TPM2_HIERARCHY_CONTROL_RESPONSE Res;
+ UINT32 CmdSize;
+ UINT32 RespSize;
+ UINT8 *Buffer;
+ UINT32 SessionInfoSize;
+ UINT8 *ResultBuf;
+ UINT32 ResultBufSize;
+
+ //
+ // Construct command
+ //
+ Cmd.Header.tag = SwapBytes16(TPM_ST_SESSIONS);
+ Cmd.Header.paramSize = SwapBytes32(sizeof(Cmd));
+ Cmd.Header.commandCode = SwapBytes32(TPM_CC_HierarchyControl);
+ Cmd.AuthHandle = SwapBytes32(AuthHandle);
+
+ //
+ // Add in Auth session
+ //
+ Buffer = (UINT8 *)&Cmd.AuthSession;
+
+ // sessionInfoSize
+ SessionInfoSize = CopyAuthSessionCommand (AuthSession, Buffer);
+ Buffer += SessionInfoSize;
+ Cmd.AuthorizationSize = SwapBytes32(SessionInfoSize);
+
+ WriteUnaligned32 ((UINT32 *)Buffer, SwapBytes32(Hierarchy));
+ Buffer += sizeof(UINT32);
+
+ *(UINT8 *)Buffer = State;
+ Buffer += sizeof(UINT8);
+
+ CmdSize = (UINT32)(Buffer - (UINT8 *)&Cmd);
+ Cmd.Header.paramSize = SwapBytes32(CmdSize);
+
+ ResultBuf = (UINT8 *) &Res;
+ ResultBufSize = sizeof(Res);
+
+ //
+ // Call the TPM
+ //
+ Status = Tpm2SubmitCommand (
+ CmdSize,
+ (UINT8 *)&Cmd,
+ &ResultBufSize,
+ ResultBuf
+ );
+
+ if (ResultBufSize > sizeof(Res)) {
+ DEBUG ((EFI_D_ERROR, "HierarchyControl: Failed ExecuteCommand: Buffer Too Small\r\n"));
+ return EFI_BUFFER_TOO_SMALL;
+ }
+
+ //
+ // Validate response headers
+ //
+ RespSize = SwapBytes32(Res.Header.paramSize);
+ if (RespSize > sizeof(Res)) {
+ DEBUG ((EFI_D_ERROR, "HierarchyControl: Response size too large! %d\r\n", RespSize));
+ return EFI_BUFFER_TOO_SMALL;
+ }
+
+ //
+ // Fail if command failed
+ //
+ if (SwapBytes32(Res.Header.responseCode) != TPM_RC_SUCCESS) {
+ DEBUG((EFI_D_ERROR,"HierarchyControl: Response Code error! 0x%08x\r\n", SwapBytes32(Res.Header.responseCode)));
+ return EFI_DEVICE_ERROR;
+ }
+
+ return EFI_SUCCESS;
+}
diff --git a/SecurityPkg/Library/Tpm2CommandLib/Tpm2Integrity.c b/SecurityPkg/Library/Tpm2CommandLib/Tpm2Integrity.c
new file mode 100644
index 000000000..88dcc0afe
--- /dev/null
+++ b/SecurityPkg/Library/Tpm2CommandLib/Tpm2Integrity.c
@@ -0,0 +1,525 @@
+/** @file
+ Implement TPM2 Integrity related command.
+
+Copyright (c) 2013, 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.
+
+**/
+
+#include <IndustryStandard/UefiTcgPlatform.h>
+#include <Library/Tpm2CommandLib.h>
+#include <Library/Tpm2DeviceLib.h>
+#include <Library/BaseMemoryLib.h>
+#include <Library/BaseLib.h>
+#include <Library/DebugLib.h>
+
+#pragma pack(1)
+
+typedef struct {
+ TPM2_COMMAND_HEADER Header;
+ TPMI_DH_PCR PcrHandle;
+ UINT32 AuthorizationSize;
+ TPMS_AUTH_COMMAND AuthSessionPcr;
+ TPML_DIGEST_VALUES DigestValues;
+} TPM2_PCR_EXTEND_COMMAND;
+
+typedef struct {
+ TPM2_RESPONSE_HEADER Header;
+ UINT32 ParameterSize;
+ TPMS_AUTH_RESPONSE AuthSessionPcr;
+} TPM2_PCR_EXTEND_RESPONSE;
+
+typedef struct {
+ TPM2_COMMAND_HEADER Header;
+ TPMI_DH_PCR PcrHandle;
+ UINT32 AuthorizationSize;
+ TPMS_AUTH_COMMAND AuthSessionPcr;
+ TPM2B_EVENT EventData;
+} TPM2_PCR_EVENT_COMMAND;
+
+typedef struct {
+ TPM2_RESPONSE_HEADER Header;
+ UINT32 ParameterSize;
+ TPML_DIGEST_VALUES Digests;
+ TPMS_AUTH_RESPONSE AuthSessionPcr;
+} TPM2_PCR_EVENT_RESPONSE;
+
+typedef struct {
+ TPM2_COMMAND_HEADER Header;
+ TPML_PCR_SELECTION PcrSelectionIn;
+} TPM2_PCR_READ_COMMAND;
+
+typedef struct {
+ TPM2_RESPONSE_HEADER Header;
+ UINT32 PcrUpdateCounter;
+ TPML_PCR_SELECTION PcrSelectionOut;
+ TPML_DIGEST PcrValues;
+} TPM2_PCR_READ_RESPONSE;
+
+typedef struct {
+ TPM2_COMMAND_HEADER Header;
+ TPMI_RH_PLATFORM AuthHandle;
+ UINT32 AuthSessionSize;
+ TPMS_AUTH_COMMAND AuthSession;
+ TPML_PCR_SELECTION PcrAllocation;
+} TPM2_PCR_ALLOCATE_COMMAND;
+
+typedef struct {
+ TPM2_RESPONSE_HEADER Header;
+ UINT32 AuthSessionSize;
+ TPMI_YES_NO AllocationSuccess;
+ UINT32 MaxPCR;
+ UINT32 SizeNeeded;
+ UINT32 SizeAvailable;
+ TPMS_AUTH_RESPONSE AuthSession;
+} TPM2_PCR_ALLOCATE_RESPONSE;
+
+#pragma pack()
+
+/**
+ This command is used to cause an update to the indicated PCR.
+ The digests parameter contains one or more tagged digest value identified by an algorithm ID.
+ For each digest, the PCR associated with pcrHandle is Extended into the bank identified by the tag (hashAlg).
+
+ @param[in] PcrHandle Handle of the PCR
+ @param[in] Digests List of tagged digest values to be extended
+
+ @retval EFI_SUCCESS Operation completed successfully.
+ @retval EFI_DEVICE_ERROR Unexpected device behavior.
+**/
+EFI_STATUS
+EFIAPI
+Tpm2PcrExtend (
+ IN TPMI_DH_PCR PcrHandle,
+ IN TPML_DIGEST_VALUES *Digests
+ )
+{
+ EFI_STATUS Status;
+ TPM2_PCR_EXTEND_COMMAND Cmd;
+ TPM2_PCR_EXTEND_RESPONSE Res;
+ UINT32 CmdSize;
+ UINT32 RespSize;
+ UINT32 ResultBufSize;
+ UINT8 *Buffer;
+ UINTN Index;
+ UINT32 SessionInfoSize;
+ UINT16 DigestSize;
+
+ Cmd.Header.tag = SwapBytes16(TPM_ST_SESSIONS);
+ Cmd.Header.commandCode = SwapBytes32(TPM_CC_PCR_Extend);
+ Cmd.PcrHandle = SwapBytes32(PcrHandle);
+
+
+ //
+ // Add in Auth session
+ //
+ Buffer = (UINT8 *)&Cmd.AuthSessionPcr;
+
+ // sessionInfoSize
+ SessionInfoSize = CopyAuthSessionCommand (NULL, Buffer);
+ Buffer += SessionInfoSize;
+ Cmd.AuthorizationSize = SwapBytes32(SessionInfoSize);
+
+ //Digest Count
+ WriteUnaligned32 ((UINT32 *)Buffer, SwapBytes32(Digests->count));
+ Buffer += sizeof(UINT32);
+
+ //Digest
+ for (Index = 0; Index < Digests->count; Index++) {
+ WriteUnaligned16 ((UINT16 *)Buffer, SwapBytes16(Digests->digests[Index].hashAlg));
+ Buffer += sizeof(UINT16);
+ DigestSize = GetHashSizeFromAlgo (Digests->digests[Index].hashAlg);
+ if (DigestSize == 0) {
+ DEBUG ((EFI_D_ERROR, "Unknown hash algorithm %d\r\n", Digests->digests[Index].hashAlg));
+ return EFI_DEVICE_ERROR;
+ }
+ CopyMem(
+ Buffer,
+ &Digests->digests[Index].digest,
+ DigestSize
+ );
+ Buffer += DigestSize;
+ }
+
+ CmdSize = (UINT32)((UINTN)Buffer - (UINTN)&Cmd);
+ Cmd.Header.paramSize = SwapBytes32(CmdSize);
+
+ ResultBufSize = sizeof(Res);
+ Status = Tpm2SubmitCommand (CmdSize, (UINT8 *)&Cmd, &ResultBufSize, (UINT8 *)&Res);
+ if (EFI_ERROR(Status)) {
+ return Status;
+ }
+
+ if (ResultBufSize > sizeof(Res)) {
+ DEBUG ((EFI_D_ERROR, "Tpm2PcrExtend: Failed ExecuteCommand: Buffer Too Small\r\n"));
+ return EFI_BUFFER_TOO_SMALL;
+ }
+
+ //
+ // Validate response headers
+ //
+ RespSize = SwapBytes32(Res.Header.paramSize);
+ if (RespSize > sizeof(Res)) {
+ DEBUG ((EFI_D_ERROR, "Tpm2PcrExtend: Response size too large! %d\r\n", RespSize));
+ return EFI_BUFFER_TOO_SMALL;
+ }
+
+ //
+ // Fail if command failed
+ //
+ if (SwapBytes32(Res.Header.responseCode) != TPM_RC_SUCCESS) {
+ DEBUG ((EFI_D_ERROR, "Tpm2PcrExtend: Response Code error! 0x%08x\r\n", SwapBytes32(Res.Header.responseCode)));
+ return EFI_DEVICE_ERROR;
+ }
+
+ //
+ // Unmarshal the response
+ //
+
+ // None
+
+ return EFI_SUCCESS;
+}
+
+/**
+ This command is used to cause an update to the indicated PCR.
+ The data in eventData is hashed using the hash algorithm associated with each bank in which the
+ indicated PCR has been allocated. After the data is hashed, the digests list is returned. If the pcrHandle
+ references an implemented PCR and not TPM_ALG_NULL, digests list is processed as in
+ TPM2_PCR_Extend().
+ A TPM shall support an Event.size of zero through 1,024 inclusive.
+
+ @param[in] PcrHandle Handle of the PCR
+ @param[in] EventData Event data in sized buffer
+ @param[out] Digests List of digest
+
+ @retval EFI_SUCCESS Operation completed successfully.
+ @retval EFI_DEVICE_ERROR Unexpected device behavior.
+**/
+EFI_STATUS
+EFIAPI
+Tpm2PcrEvent (
+ IN TPMI_DH_PCR PcrHandle,
+ IN TPM2B_EVENT *EventData,
+ OUT TPML_DIGEST_VALUES *Digests
+ )
+{
+ EFI_STATUS Status;
+ TPM2_PCR_EVENT_COMMAND Cmd;
+ TPM2_PCR_EVENT_RESPONSE Res;
+ UINT32 CmdSize;
+ UINT32 RespSize;
+ UINT32 ResultBufSize;
+ UINT8 *Buffer;
+ UINTN Index;
+ UINT32 SessionInfoSize;
+ UINT16 DigestSize;
+
+ Cmd.Header.tag = SwapBytes16(TPM_ST_SESSIONS);
+ Cmd.Header.commandCode = SwapBytes32(TPM_CC_PCR_Event);
+ Cmd.PcrHandle = SwapBytes32(PcrHandle);
+
+ //
+ // Add in Auth session
+ //
+ Buffer = (UINT8 *)&Cmd.AuthSessionPcr;
+
+ // sessionInfoSize
+ SessionInfoSize = CopyAuthSessionCommand (NULL, Buffer);
+ Buffer += SessionInfoSize;
+ Cmd.AuthorizationSize = SwapBytes32(SessionInfoSize);
+
+ // Event
+ WriteUnaligned16 ((UINT16 *)Buffer, SwapBytes16(EventData->size));
+ Buffer += sizeof(UINT16);
+
+ CopyMem (Buffer, EventData->buffer, EventData->size);
+ Buffer += EventData->size;
+
+ CmdSize = (UINT32)((UINTN)Buffer - (UINTN)&Cmd);
+ Cmd.Header.paramSize = SwapBytes32(CmdSize);
+
+ ResultBufSize = sizeof(Res);
+ Status = Tpm2SubmitCommand (CmdSize, (UINT8 *)&Cmd, &ResultBufSize, (UINT8 *)&Res);
+ if (EFI_ERROR(Status)) {
+ return Status;
+ }
+
+ if (ResultBufSize > sizeof(Res)) {
+ DEBUG ((EFI_D_ERROR, "Tpm2PcrEvent: Failed ExecuteCommand: Buffer Too Small\r\n"));
+ return EFI_BUFFER_TOO_SMALL;
+ }
+
+ //
+ // Validate response headers
+ //
+ RespSize = SwapBytes32(Res.Header.paramSize);
+ if (RespSize > sizeof(Res)) {
+ DEBUG ((EFI_D_ERROR, "Tpm2PcrEvent: Response size too large! %d\r\n", RespSize));
+ return EFI_BUFFER_TOO_SMALL;
+ }
+
+ //
+ // Fail if command failed
+ //
+ if (SwapBytes32(Res.Header.responseCode) != TPM_RC_SUCCESS) {
+ DEBUG ((EFI_D_ERROR, "Tpm2PcrEvent: Response Code error! 0x%08x\r\n", SwapBytes32(Res.Header.responseCode)));
+ return EFI_DEVICE_ERROR;
+ }
+
+ //
+ // Unmarshal the response
+ //
+ Buffer = (UINT8 *)&Res.Digests;
+
+ Digests->count = SwapBytes32 (ReadUnaligned32 ((UINT32 *)Buffer));
+ Buffer += sizeof(UINT32);
+ for (Index = 0; Index < Digests->count; Index++) {
+ Digests->digests[Index].hashAlg = SwapBytes16 (ReadUnaligned16 ((UINT16 *)Buffer));
+ Buffer += sizeof(UINT16);
+ DigestSize = GetHashSizeFromAlgo (Digests->digests[Index].hashAlg);
+ if (DigestSize == 0) {
+ DEBUG ((EFI_D_ERROR, "Unknown hash algorithm %d\r\n", Digests->digests[Index].hashAlg));
+ return EFI_DEVICE_ERROR;
+ }
+ CopyMem(
+ &Digests->digests[Index].digest,
+ Buffer,
+ DigestSize
+ );
+ Buffer += DigestSize;
+ }
+
+ return EFI_SUCCESS;
+}
+
+/**
+ This command returns the values of all PCR specified in pcrSelect.
+
+ @param[in] PcrSelectionIn The selection of PCR to read.
+ @param[out] PcrUpdateCounter The current value of the PCR update counter.
+ @param[out] PcrSelectionOut The PCR in the returned list.
+ @param[out] PcrValues The contents of the PCR indicated in pcrSelect.
+
+ @retval EFI_SUCCESS Operation completed successfully.
+ @retval EFI_DEVICE_ERROR The command was unsuccessful.
+**/
+EFI_STATUS
+EFIAPI
+Tpm2PcrRead (
+ IN TPML_PCR_SELECTION *PcrSelectionIn,
+ OUT UINT32 *PcrUpdateCounter,
+ OUT TPML_PCR_SELECTION *PcrSelectionOut,
+ OUT TPML_DIGEST *PcrValues
+ )
+{
+ EFI_STATUS Status;
+ TPM2_PCR_READ_COMMAND SendBuffer;
+ TPM2_PCR_READ_RESPONSE RecvBuffer;
+ UINT32 SendBufferSize;
+ UINT32 RecvBufferSize;
+ UINTN Index;
+ TPML_DIGEST *PcrValuesOut;
+ TPM2B_DIGEST *Digests;
+
+ //
+ // Construct command
+ //
+ SendBuffer.Header.tag = SwapBytes16(TPM_ST_NO_SESSIONS);
+ SendBuffer.Header.commandCode = SwapBytes32(TPM_CC_PCR_Read);
+
+ SendBuffer.PcrSelectionIn.count = SwapBytes32(PcrSelectionIn->count);
+ for (Index = 0; Index < PcrSelectionIn->count; Index++) {
+ SendBuffer.PcrSelectionIn.pcrSelections[Index].hash = SwapBytes16(PcrSelectionIn->pcrSelections[Index].hash);
+ SendBuffer.PcrSelectionIn.pcrSelections[Index].sizeofSelect = PcrSelectionIn->pcrSelections[Index].sizeofSelect;
+ CopyMem (&SendBuffer.PcrSelectionIn.pcrSelections[Index].pcrSelect, &PcrSelectionIn->pcrSelections[Index].pcrSelect, SendBuffer.PcrSelectionIn.pcrSelections[Index].sizeofSelect);
+ }
+
+ SendBufferSize = sizeof(SendBuffer.Header) + sizeof(SendBuffer.PcrSelectionIn.count) + sizeof(SendBuffer.PcrSelectionIn.pcrSelections[0]) * PcrSelectionIn->count;
+ SendBuffer.Header.paramSize = SwapBytes32 (SendBufferSize);
+
+ //
+ // send Tpm command
+ //
+ RecvBufferSize = sizeof (RecvBuffer);
+ Status = Tpm2SubmitCommand (SendBufferSize, (UINT8 *)&SendBuffer, &RecvBufferSize, (UINT8 *)&RecvBuffer);
+ if (EFI_ERROR (Status)) {
+ return Status;
+ }
+
+ if (RecvBufferSize < sizeof (TPM2_RESPONSE_HEADER)) {
+ DEBUG ((EFI_D_ERROR, "Tpm2PcrRead - RecvBufferSize Error - %x\n", RecvBufferSize));
+ return EFI_DEVICE_ERROR;
+ }
+ if (SwapBytes32(RecvBuffer.Header.responseCode) != TPM_RC_SUCCESS) {
+ DEBUG ((EFI_D_ERROR, "Tpm2PcrRead - responseCode - %x\n", SwapBytes32(RecvBuffer.Header.responseCode)));
+ return EFI_NOT_FOUND;
+ }
+
+ //
+ // Return the response
+ //
+
+ //
+ // PcrUpdateCounter
+ //
+ if (RecvBufferSize < sizeof (TPM2_RESPONSE_HEADER) + sizeof(RecvBuffer.PcrUpdateCounter)) {
+ DEBUG ((EFI_D_ERROR, "Tpm2PcrRead - RecvBufferSize Error - %x\n", RecvBufferSize));
+ return EFI_DEVICE_ERROR;
+ }
+ *PcrUpdateCounter = SwapBytes32(RecvBuffer.PcrUpdateCounter);
+
+ //
+ // PcrSelectionOut
+ //
+ if (RecvBufferSize < sizeof (TPM2_RESPONSE_HEADER) + sizeof(RecvBuffer.PcrUpdateCounter) + sizeof(RecvBuffer.PcrSelectionOut.count)) {
+ DEBUG ((EFI_D_ERROR, "Tpm2PcrRead - RecvBufferSize Error - %x\n", RecvBufferSize));
+ return EFI_DEVICE_ERROR;
+ }
+ PcrSelectionOut->count = SwapBytes32(RecvBuffer.PcrSelectionOut.count);
+ if (RecvBufferSize < sizeof (TPM2_RESPONSE_HEADER) + sizeof(RecvBuffer.PcrUpdateCounter) + sizeof(RecvBuffer.PcrSelectionOut.count) + sizeof(RecvBuffer.PcrSelectionOut.pcrSelections[0]) * PcrSelectionOut->count) {
+ DEBUG ((EFI_D_ERROR, "Tpm2PcrRead - RecvBufferSize Error - %x\n", RecvBufferSize));
+ return EFI_DEVICE_ERROR;
+ }
+ for (Index = 0; Index < PcrSelectionOut->count; Index++) {
+ PcrSelectionOut->pcrSelections[Index].hash = SwapBytes16(RecvBuffer.PcrSelectionOut.pcrSelections[Index].hash);
+ PcrSelectionOut->pcrSelections[Index].sizeofSelect = RecvBuffer.PcrSelectionOut.pcrSelections[Index].sizeofSelect;
+ CopyMem (&PcrSelectionOut->pcrSelections[Index].pcrSelect, &RecvBuffer.PcrSelectionOut.pcrSelections[Index].pcrSelect, PcrSelectionOut->pcrSelections[Index].sizeofSelect);
+ }
+
+ //
+ // PcrValues
+ //
+ PcrValuesOut = (TPML_DIGEST *)((UINT8 *)&RecvBuffer + sizeof (TPM2_RESPONSE_HEADER) + sizeof(RecvBuffer.PcrUpdateCounter) + sizeof(RecvBuffer.PcrSelectionOut.count) + sizeof(RecvBuffer.PcrSelectionOut.pcrSelections[0]) * PcrSelectionOut->count);
+ PcrValues->count = SwapBytes32(PcrValuesOut->count);
+ Digests = PcrValuesOut->digests;
+ for (Index = 0; Index < PcrValues->count; Index++) {
+ PcrValues->digests[Index].size = SwapBytes16(Digests->size);
+ CopyMem (&PcrValues->digests[Index].buffer, &Digests->buffer, PcrValues->digests[Index].size);
+ Digests = (TPM2B_DIGEST *)((UINT8 *)Digests + sizeof(Digests->size) + PcrValues->digests[Index].size);
+ }
+
+ return EFI_SUCCESS;
+}
+
+/**
+ This command is used to set the desired PCR allocation of PCR and algorithms.
+
+ @param[in] AuthHandle TPM_RH_PLATFORM+{PP}
+ @param[in] AuthSession Auth Session context
+ @param[in] PcrAllocation The requested allocation
+ @param[out] AllocationSuccess YES if the allocation succeeded
+ @param[out] MaxPCR maximum number of PCR that may be in a bank
+ @param[out] SizeNeeded number of octets required to satisfy the request
+ @param[out] SizeAvailable Number of octets available. Computed before the allocation
+
+ @retval EFI_SUCCESS Operation completed successfully.
+ @retval EFI_DEVICE_ERROR The command was unsuccessful.
+**/
+EFI_STATUS
+EFIAPI
+Tpm2PcrAllocate (
+ IN TPMI_RH_PLATFORM AuthHandle,
+ IN TPMS_AUTH_COMMAND *AuthSession,
+ IN TPML_PCR_SELECTION *PcrAllocation,
+ OUT TPMI_YES_NO *AllocationSuccess,
+ OUT UINT32 *MaxPCR,
+ OUT UINT32 *SizeNeeded,
+ OUT UINT32 *SizeAvailable
+ )
+{
+ EFI_STATUS Status;
+ TPM2_PCR_ALLOCATE_COMMAND Cmd;
+ TPM2_PCR_ALLOCATE_RESPONSE Res;
+ UINT32 CmdSize;
+ UINT32 RespSize;
+ UINT8 *Buffer;
+ UINT32 SessionInfoSize;
+ UINT8 *ResultBuf;
+ UINT32 ResultBufSize;
+ UINTN Index;
+
+ //
+ // Construct command
+ //
+ Cmd.Header.tag = SwapBytes16(TPM_ST_SESSIONS);
+ Cmd.Header.paramSize = SwapBytes32(sizeof(Cmd));
+ Cmd.Header.commandCode = SwapBytes32(TPM_CC_PCR_Allocate);
+ Cmd.AuthHandle = SwapBytes32(AuthHandle);
+
+ //
+ // Add in Auth session
+ //
+ Buffer = (UINT8 *)&Cmd.AuthSession;
+
+ // sessionInfoSize
+ SessionInfoSize = CopyAuthSessionCommand (AuthSession, Buffer);
+ Buffer += SessionInfoSize;
+ Cmd.AuthSessionSize = SwapBytes32(SessionInfoSize);
+
+ // Count
+ WriteUnaligned32 ((UINT32 *)Buffer, SwapBytes32(PcrAllocation->count));
+ Buffer += sizeof(UINT32);
+ for (Index = 0; Index < PcrAllocation->count; Index++) {
+ WriteUnaligned16 ((UINT16 *)Buffer, SwapBytes16(PcrAllocation->pcrSelections[Index].hash));
+ Buffer += sizeof(UINT16);
+ *(UINT8 *)Buffer = PcrAllocation->pcrSelections[Index].sizeofSelect;
+ Buffer += sizeof(UINT8);
+ CopyMem (Buffer, PcrAllocation->pcrSelections[Index].pcrSelect, PcrAllocation->pcrSelections[Index].sizeofSelect);
+ Buffer += PcrAllocation->pcrSelections[Index].sizeofSelect;
+ }
+
+ CmdSize = (UINT32)(Buffer - (UINT8 *)&Cmd);
+ Cmd.Header.paramSize = SwapBytes32(CmdSize);
+
+ ResultBuf = (UINT8 *) &Res;
+ ResultBufSize = sizeof(Res);
+
+ //
+ // Call the TPM
+ //
+ Status = Tpm2SubmitCommand (
+ CmdSize,
+ (UINT8 *)&Cmd,
+ &ResultBufSize,
+ ResultBuf
+ );
+
+ if (ResultBufSize > sizeof(Res)) {
+ DEBUG ((EFI_D_ERROR, "Tpm2PcrAllocate: Failed ExecuteCommand: Buffer Too Small\r\n"));
+ return EFI_BUFFER_TOO_SMALL;
+ }
+
+ //
+ // Validate response headers
+ //
+ RespSize = SwapBytes32(Res.Header.paramSize);
+ if (RespSize > sizeof(Res)) {
+ DEBUG ((EFI_D_ERROR, "Tpm2PcrAllocate: Response size too large! %d\r\n", RespSize));
+ return EFI_BUFFER_TOO_SMALL;
+ }
+
+ //
+ // Fail if command failed
+ //
+ if (SwapBytes32(Res.Header.responseCode) != TPM_RC_SUCCESS) {
+ DEBUG((EFI_D_ERROR,"Tpm2PcrAllocate: Response Code error! 0x%08x\r\n", SwapBytes32(Res.Header.responseCode)));
+ return EFI_DEVICE_ERROR;
+ }
+
+ //
+ // Return the response
+ //
+ *AllocationSuccess = Res.AllocationSuccess;
+ *MaxPCR = SwapBytes32(Res.MaxPCR);
+ *SizeNeeded = SwapBytes32(Res.SizeNeeded);
+ *SizeAvailable = SwapBytes32(Res.SizeAvailable);
+
+ return EFI_SUCCESS;
+}
diff --git a/SecurityPkg/Library/Tpm2CommandLib/Tpm2Miscellaneous.c b/SecurityPkg/Library/Tpm2CommandLib/Tpm2Miscellaneous.c
new file mode 100644
index 000000000..914ad7f70
--- /dev/null
+++ b/SecurityPkg/Library/Tpm2CommandLib/Tpm2Miscellaneous.c
@@ -0,0 +1,114 @@
+/** @file
+ Implement TPM2 Miscellanenous related command.
+
+Copyright (c) 2013, 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.
+
+**/
+
+#include <IndustryStandard/UefiTcgPlatform.h>
+#include <Library/Tpm2CommandLib.h>
+#include <Library/Tpm2DeviceLib.h>
+#include <Library/BaseMemoryLib.h>
+#include <Library/BaseLib.h>
+#include <Library/DebugLib.h>
+
+#pragma pack(1)
+
+typedef struct {
+ TPM2_COMMAND_HEADER Header;
+ TPMI_RH_HIERARCHY_AUTH AuthHandle;
+ UINT32 AuthSessionSize;
+ TPMS_AUTH_COMMAND AuthSession;
+ UINT32 AlgorithmSet;
+} TPM2_SET_ALGORITHM_SET_COMMAND;
+
+typedef struct {
+ TPM2_RESPONSE_HEADER Header;
+ UINT32 AuthSessionSize;
+ TPMS_AUTH_RESPONSE AuthSession;
+} TPM2_SET_ALGORITHM_SET_RESPONSE;
+
+#pragma pack()
+
+/**
+ This command allows the platform to change the set of algorithms that are used by the TPM.
+ The algorithmSet setting is a vendor-dependent value.
+
+ @param[in] AuthHandle TPM_RH_PLATFORM
+ @param[in] AuthSession Auth Session context
+ @param[in] AlgorithmSet A TPM vendor-dependent value indicating the
+ algorithm set selection
+
+ @retval EFI_SUCCESS Operation completed successfully.
+ @retval EFI_DEVICE_ERROR Unexpected device behavior.
+**/
+EFI_STATUS
+EFIAPI
+Tpm2SetAlgorithmSet (
+ IN TPMI_RH_PLATFORM AuthHandle,
+ IN TPMS_AUTH_COMMAND *AuthSession,
+ IN UINT32 AlgorithmSet
+ )
+{
+ EFI_STATUS Status;
+ TPM2_SET_ALGORITHM_SET_COMMAND SendBuffer;
+ TPM2_SET_ALGORITHM_SET_RESPONSE RecvBuffer;
+ UINT32 SendBufferSize;
+ UINT32 RecvBufferSize;
+ UINT8 *Buffer;
+ UINT32 SessionInfoSize;
+
+ //
+ // Construct command
+ //
+ SendBuffer.Header.tag = SwapBytes16(TPM_ST_SESSIONS);
+ SendBuffer.Header.commandCode = SwapBytes32(TPM_CC_SetAlgorithmSet);
+
+ SendBuffer.AuthHandle = SwapBytes32 (AuthHandle);
+
+ //
+ // Add in Auth session
+ //
+ Buffer = (UINT8 *)&SendBuffer.AuthSession;
+
+ // sessionInfoSize
+ SessionInfoSize = CopyAuthSessionCommand (AuthSession, Buffer);
+ Buffer += SessionInfoSize;
+ SendBuffer.AuthSessionSize = SwapBytes32(SessionInfoSize);
+
+ //
+ // Real data
+ //
+ WriteUnaligned32 ((UINT32 *)Buffer, SwapBytes32(AlgorithmSet));
+ Buffer += sizeof(UINT32);
+
+ SendBufferSize = (UINT32)((UINTN)Buffer - (UINTN)&SendBuffer);
+ SendBuffer.Header.paramSize = SwapBytes32 (SendBufferSize);
+
+ //
+ // send Tpm command
+ //
+ RecvBufferSize = sizeof (RecvBuffer);
+ Status = Tpm2SubmitCommand (SendBufferSize, (UINT8 *)&SendBuffer, &RecvBufferSize, (UINT8 *)&RecvBuffer);
+ if (EFI_ERROR (Status)) {
+ return Status;
+ }
+
+ if (RecvBufferSize < sizeof (TPM2_RESPONSE_HEADER)) {
+ DEBUG ((EFI_D_ERROR, "Tpm2SetAlgorithmSet - RecvBufferSize Error - %x\n", RecvBufferSize));
+ return EFI_DEVICE_ERROR;
+ }
+ if (SwapBytes32(RecvBuffer.Header.responseCode) != TPM_RC_SUCCESS) {
+ DEBUG ((EFI_D_ERROR, "Tpm2SetAlgorithmSet - responseCode - %x\n", SwapBytes32(RecvBuffer.Header.responseCode)));
+ return EFI_DEVICE_ERROR;
+ }
+
+ return EFI_SUCCESS;
+}
diff --git a/SecurityPkg/Library/Tpm2CommandLib/Tpm2NVStorage.c b/SecurityPkg/Library/Tpm2CommandLib/Tpm2NVStorage.c
new file mode 100644
index 000000000..c4714d3e1
--- /dev/null
+++ b/SecurityPkg/Library/Tpm2CommandLib/Tpm2NVStorage.c
@@ -0,0 +1,938 @@
+/** @file
+ Implement TPM2 NVStorage related command.
+
+Copyright (c) 2013, 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.
+
+**/
+
+#include <IndustryStandard/UefiTcgPlatform.h>
+#include <Library/Tpm2CommandLib.h>
+#include <Library/Tpm2DeviceLib.h>
+#include <Library/BaseMemoryLib.h>
+#include <Library/BaseLib.h>
+#include <Library/DebugLib.h>
+
+#pragma pack(1)
+
+#define RC_NV_ReadPublic_nvIndex (TPM_RC_H + TPM_RC_1)
+
+#define RC_NV_DefineSpace_authHandle (TPM_RC_H + TPM_RC_1)
+#define RC_NV_DefineSpace_auth (TPM_RC_P + TPM_RC_1)
+#define RC_NV_DefineSpace_publicInfo (TPM_RC_P + TPM_RC_2)
+
+#define RC_NV_UndefineSpace_authHandle (TPM_RC_H + TPM_RC_1)
+#define RC_NV_UndefineSpace_nvIndex (TPM_RC_H + TPM_RC_2)
+
+#define RC_NV_Read_authHandle (TPM_RC_H + TPM_RC_1)
+#define RC_NV_Read_nvIndex (TPM_RC_H + TPM_RC_2)
+#define RC_NV_Read_size (TPM_RC_P + TPM_RC_1)
+#define RC_NV_Read_offset (TPM_RC_P + TPM_RC_2)
+
+#define RC_NV_Write_authHandle (TPM_RC_H + TPM_RC_1)
+#define RC_NV_Write_nvIndex (TPM_RC_H + TPM_RC_2)
+#define RC_NV_Write_data (TPM_RC_P + TPM_RC_1)
+#define RC_NV_Write_offset (TPM_RC_P + TPM_RC_2)
+
+typedef struct {
+ TPM2_COMMAND_HEADER Header;
+ TPMI_RH_NV_INDEX NvIndex;
+} TPM2_NV_READPUBLIC_COMMAND;
+
+typedef struct {
+ TPM2_RESPONSE_HEADER Header;
+ TPM2B_NV_PUBLIC NvPublic;
+ TPM2B_NAME NvName;
+} TPM2_NV_READPUBLIC_RESPONSE;
+
+typedef struct {
+ TPM2_COMMAND_HEADER Header;
+ TPMI_RH_PROVISION AuthHandle;
+ UINT32 AuthSessionSize;
+ TPMS_AUTH_COMMAND AuthSession;
+ TPM2B_AUTH Auth;
+ TPM2B_NV_PUBLIC NvPublic;
+} TPM2_NV_DEFINESPACE_COMMAND;
+
+typedef struct {
+ TPM2_RESPONSE_HEADER Header;
+ UINT32 AuthSessionSize;
+ TPMS_AUTH_RESPONSE AuthSession;
+} TPM2_NV_DEFINESPACE_RESPONSE;
+
+typedef struct {
+ TPM2_COMMAND_HEADER Header;
+ TPMI_RH_PROVISION AuthHandle;
+ TPMI_RH_NV_INDEX NvIndex;
+ UINT32 AuthSessionSize;
+ TPMS_AUTH_COMMAND AuthSession;
+} TPM2_NV_UNDEFINESPACE_COMMAND;
+
+typedef struct {
+ TPM2_RESPONSE_HEADER Header;
+ UINT32 AuthSessionSize;
+ TPMS_AUTH_RESPONSE AuthSession;
+} TPM2_NV_UNDEFINESPACE_RESPONSE;
+
+typedef struct {
+ TPM2_COMMAND_HEADER Header;
+ TPMI_RH_NV_AUTH AuthHandle;
+ TPMI_RH_NV_INDEX NvIndex;
+ UINT32 AuthSessionSize;
+ TPMS_AUTH_COMMAND AuthSession;
+ UINT16 Size;
+ UINT16 Offset;
+} TPM2_NV_READ_COMMAND;
+
+typedef struct {
+ TPM2_RESPONSE_HEADER Header;
+ UINT32 AuthSessionSize;
+ TPM2B_MAX_BUFFER Data;
+ TPMS_AUTH_RESPONSE AuthSession;
+} TPM2_NV_READ_RESPONSE;
+
+typedef struct {
+ TPM2_COMMAND_HEADER Header;
+ TPMI_RH_NV_AUTH AuthHandle;
+ TPMI_RH_NV_INDEX NvIndex;
+ UINT32 AuthSessionSize;
+ TPMS_AUTH_COMMAND AuthSession;
+ TPM2B_MAX_BUFFER Data;
+ UINT16 Offset;
+} TPM2_NV_WRITE_COMMAND;
+
+typedef struct {
+ TPM2_RESPONSE_HEADER Header;
+ UINT32 AuthSessionSize;
+ TPMS_AUTH_RESPONSE AuthSession;
+} TPM2_NV_WRITE_RESPONSE;
+
+typedef struct {
+ TPM2_COMMAND_HEADER Header;
+ TPMI_RH_NV_AUTH AuthHandle;
+ TPMI_RH_NV_INDEX NvIndex;
+ UINT32 AuthSessionSize;
+ TPMS_AUTH_COMMAND AuthSession;
+} TPM2_NV_READLOCK_COMMAND;
+
+typedef struct {
+ TPM2_RESPONSE_HEADER Header;
+ UINT32 AuthSessionSize;
+ TPMS_AUTH_RESPONSE AuthSession;
+} TPM2_NV_READLOCK_RESPONSE;
+
+typedef struct {
+ TPM2_COMMAND_HEADER Header;
+ TPMI_RH_NV_AUTH AuthHandle;
+ TPMI_RH_NV_INDEX NvIndex;
+ UINT32 AuthSessionSize;
+ TPMS_AUTH_COMMAND AuthSession;
+} TPM2_NV_WRITELOCK_COMMAND;
+
+typedef struct {
+ TPM2_RESPONSE_HEADER Header;
+ UINT32 AuthSessionSize;
+ TPMS_AUTH_RESPONSE AuthSession;
+} TPM2_NV_WRITELOCK_RESPONSE;
+
+typedef struct {
+ TPM2_COMMAND_HEADER Header;
+ TPMI_RH_PROVISION AuthHandle;
+ UINT32 AuthSessionSize;
+ TPMS_AUTH_COMMAND AuthSession;
+} TPM2_NV_GLOBALWRITELOCK_COMMAND;
+
+typedef struct {
+ TPM2_RESPONSE_HEADER Header;
+ UINT32 AuthSessionSize;
+ TPMS_AUTH_RESPONSE AuthSession;
+} TPM2_NV_GLOBALWRITELOCK_RESPONSE;
+
+#pragma pack()
+
+/**
+ This command is used to read the public area and Name of an NV Index.
+
+ @param[in] NvIndex The NV Index.
+ @param[out] NvPublic The public area of the index.
+ @param[out] NvName The Name of the nvIndex.
+
+ @retval EFI_SUCCESS Operation completed successfully.
+ @retval EFI_DEVICE_ERROR The command was unsuccessful.
+ @retval EFI_NOT_FOUND The command was returned successfully, but NvIndex is not found.
+**/
+EFI_STATUS
+EFIAPI
+Tpm2NvReadPublic (
+ IN TPMI_RH_NV_INDEX NvIndex,
+ OUT TPM2B_NV_PUBLIC *NvPublic,
+ OUT TPM2B_NAME *NvName
+ )
+{
+ EFI_STATUS Status;
+ TPM2_NV_READPUBLIC_COMMAND SendBuffer;
+ TPM2_NV_READPUBLIC_RESPONSE RecvBuffer;
+ UINT32 SendBufferSize;
+ UINT32 RecvBufferSize;
+ UINT16 NvPublicSize;
+ UINT16 NvNameSize;
+ UINT8 *Buffer;
+ TPM_RC ResponseCode;
+
+ //
+ // Construct command
+ //
+ SendBuffer.Header.tag = SwapBytes16(TPM_ST_NO_SESSIONS);
+ SendBuffer.Header.commandCode = SwapBytes32(TPM_CC_NV_ReadPublic);
+
+ SendBuffer.NvIndex = SwapBytes32 (NvIndex);
+
+ SendBufferSize = (UINT32) sizeof (SendBuffer);
+ SendBuffer.Header.paramSize = SwapBytes32 (SendBufferSize);
+
+ //
+ // send Tpm command
+ //
+ RecvBufferSize = sizeof (RecvBuffer);
+ Status = Tpm2SubmitCommand (SendBufferSize, (UINT8 *)&SendBuffer, &RecvBufferSize, (UINT8 *)&RecvBuffer);
+ if (EFI_ERROR (Status)) {
+ return Status;
+ }
+
+ if (RecvBufferSize < sizeof (TPM2_RESPONSE_HEADER)) {
+ DEBUG ((EFI_D_ERROR, "Tpm2NvReadPublic - RecvBufferSize Error - %x\n", RecvBufferSize));
+ return EFI_DEVICE_ERROR;
+ }
+ ResponseCode = SwapBytes32(RecvBuffer.Header.responseCode);
+ if (ResponseCode != TPM_RC_SUCCESS) {
+ DEBUG ((EFI_D_ERROR, "Tpm2NvReadPublic - responseCode - %x\n", SwapBytes32(RecvBuffer.Header.responseCode)));
+ }
+ switch (ResponseCode) {
+ case TPM_RC_SUCCESS:
+ // return data
+ break;
+ case TPM_RC_HANDLE + RC_NV_ReadPublic_nvIndex: // TPM_RC_NV_DEFINED:
+ return EFI_NOT_FOUND;
+ case TPM_RC_VALUE + RC_NV_ReadPublic_nvIndex:
+ return EFI_INVALID_PARAMETER;
+ default:
+ return EFI_DEVICE_ERROR;
+ }
+
+ if (RecvBufferSize <= sizeof (TPM2_RESPONSE_HEADER) + sizeof (UINT16) + sizeof(UINT16)) {
+ DEBUG ((EFI_D_ERROR, "Tpm2NvReadPublic - RecvBufferSize Error - %x\n", RecvBufferSize));
+ return EFI_NOT_FOUND;
+ }
+
+ //
+ // Basic check
+ //
+ NvPublicSize = SwapBytes16 (RecvBuffer.NvPublic.size);
+ NvNameSize = SwapBytes16 (ReadUnaligned16 ((UINT16 *)((UINT8 *)&RecvBuffer + sizeof(TPM2_RESPONSE_HEADER) + sizeof(UINT16) + NvPublicSize)));
+
+ if (RecvBufferSize != sizeof(TPM2_RESPONSE_HEADER) + sizeof(UINT16) + NvPublicSize + sizeof(UINT16) + NvNameSize) {
+ DEBUG ((EFI_D_ERROR, "Tpm2NvReadPublic - RecvBufferSize Error - NvPublicSize %x, NvNameSize %x\n", RecvBufferSize, NvNameSize));
+ return EFI_NOT_FOUND;
+ }
+
+ //
+ // Return the response
+ //
+ CopyMem (NvPublic, &RecvBuffer.NvPublic, sizeof(UINT16) + NvPublicSize);
+ NvPublic->size = NvPublicSize;
+ NvPublic->nvPublic.nvIndex = SwapBytes32 (NvPublic->nvPublic.nvIndex);
+ NvPublic->nvPublic.nameAlg = SwapBytes16 (NvPublic->nvPublic.nameAlg);
+ WriteUnaligned32 ((UINT32 *)&NvPublic->nvPublic.attributes, SwapBytes32 (ReadUnaligned32 ((UINT32 *)&NvPublic->nvPublic.attributes)));
+ NvPublic->nvPublic.authPolicy.size = SwapBytes16 (NvPublic->nvPublic.authPolicy.size);
+ Buffer = (UINT8 *)&NvPublic->nvPublic.authPolicy;
+ Buffer += sizeof(UINT16) + NvPublic->nvPublic.authPolicy.size;
+ NvPublic->nvPublic.dataSize = SwapBytes16 (ReadUnaligned16 ((UINT16 *)Buffer));
+
+ CopyMem (NvName, (UINT8 *)&RecvBuffer + sizeof(TPM2_RESPONSE_HEADER) + sizeof(UINT16) + NvPublicSize, NvNameSize);
+ NvName->size = NvNameSize;
+
+ return EFI_SUCCESS;
+}
+
+/**
+ This command defines the attributes of an NV Index and causes the TPM to
+ reserve space to hold the data associated with the index.
+ If a definition already exists at the index, the TPM will return TPM_RC_NV_DEFINED.
+
+ @param[in] AuthHandle TPM_RH_OWNER or TPM_RH_PLATFORM+{PP}.
+ @param[in] AuthSession Auth Session context
+ @param[in] Auth The authorization data.
+ @param[in] NvPublic The public area of the index.
+
+ @retval EFI_SUCCESS Operation completed successfully.
+ @retval EFI_DEVICE_ERROR The command was unsuccessful.
+ @retval EFI_ALREADY_STARTED The command was returned successfully, but NvIndex is already defined.
+**/
+EFI_STATUS
+EFIAPI
+Tpm2NvDefineSpace (
+ IN TPMI_RH_PROVISION AuthHandle,
+ IN TPMS_AUTH_COMMAND *AuthSession, OPTIONAL
+ IN TPM2B_AUTH *Auth,
+ IN TPM2B_NV_PUBLIC *NvPublic
+ )
+{
+ EFI_STATUS Status;
+ TPM2_NV_DEFINESPACE_COMMAND SendBuffer;
+ TPM2_NV_DEFINESPACE_RESPONSE RecvBuffer;
+ UINT32 SendBufferSize;
+ UINT32 RecvBufferSize;
+ UINT16 NvPublicSize;
+ UINT8 *Buffer;
+ UINT32 SessionInfoSize;
+ TPM_RC ResponseCode;
+
+ //
+ // Construct command
+ //
+ SendBuffer.Header.tag = SwapBytes16(TPM_ST_SESSIONS);
+ SendBuffer.Header.commandCode = SwapBytes32(TPM_CC_NV_DefineSpace);
+ SendBuffer.AuthHandle = SwapBytes32 (AuthHandle);
+
+ //
+ // Add in Auth session
+ //
+ Buffer = (UINT8 *)&SendBuffer.AuthSession;
+
+ // sessionInfoSize
+ SessionInfoSize = CopyAuthSessionCommand (AuthSession, Buffer);
+ Buffer += SessionInfoSize;
+ SendBuffer.AuthSessionSize = SwapBytes32(SessionInfoSize);
+
+ //
+ // IndexAuth
+ //
+ WriteUnaligned16 ((UINT16 *)Buffer, SwapBytes16(Auth->size));
+ Buffer += sizeof(UINT16);
+ CopyMem(Buffer, Auth->buffer, Auth->size);
+ Buffer += Auth->size;
+
+ //
+ // NvPublic
+ //
+ NvPublicSize = NvPublic->size;
+
+ WriteUnaligned16 ((UINT16 *)Buffer, SwapBytes16 (NvPublicSize));
+ Buffer += sizeof(UINT16);
+ WriteUnaligned32 ((UINT32 *)Buffer, SwapBytes32 (NvPublic->nvPublic.nvIndex));
+ Buffer += sizeof(UINT32);
+ WriteUnaligned16 ((UINT16 *)Buffer, SwapBytes16 (NvPublic->nvPublic.nameAlg));
+ Buffer += sizeof(UINT16);
+ WriteUnaligned32 ((UINT32 *)Buffer, SwapBytes32 (ReadUnaligned32 ((UINT32 *)&NvPublic->nvPublic.attributes)));
+ Buffer += sizeof(UINT32);
+ WriteUnaligned16 ((UINT16 *)Buffer, SwapBytes16 (NvPublic->nvPublic.authPolicy.size));
+ Buffer += sizeof(UINT16);
+ CopyMem (Buffer, NvPublic->nvPublic.authPolicy.buffer, NvPublic->nvPublic.authPolicy.size);
+ Buffer += NvPublic->nvPublic.authPolicy.size;
+ WriteUnaligned16 ((UINT16 *)Buffer, SwapBytes16 (NvPublic->nvPublic.dataSize));
+ Buffer += sizeof(UINT16);
+
+ SendBufferSize = (UINT32)(Buffer - (UINT8 *)&SendBuffer);
+ SendBuffer.Header.paramSize = SwapBytes32 (SendBufferSize);
+
+ //
+ // send Tpm command
+ //
+ RecvBufferSize = sizeof (RecvBuffer);
+ Status = Tpm2SubmitCommand (SendBufferSize, (UINT8 *)&SendBuffer, &RecvBufferSize, (UINT8 *)&RecvBuffer);
+ if (EFI_ERROR (Status)) {
+ return Status;
+ }
+
+ if (RecvBufferSize < sizeof (TPM2_RESPONSE_HEADER)) {
+ DEBUG ((EFI_D_ERROR, "Tpm2NvDefineSpace - RecvBufferSize Error - %x\n", RecvBufferSize));
+ return EFI_DEVICE_ERROR;
+ }
+
+ ResponseCode = SwapBytes32(RecvBuffer.Header.responseCode);
+ if (ResponseCode != TPM_RC_SUCCESS) {
+ DEBUG ((EFI_D_ERROR, "Tpm2NvDefineSpace - responseCode - %x\n", SwapBytes32(RecvBuffer.Header.responseCode)));
+ }
+ switch (ResponseCode) {
+ case TPM_RC_SUCCESS:
+ // return data
+ break;
+ case TPM_RC_SIZE + RC_NV_DefineSpace_publicInfo:
+ case TPM_RC_SIZE + RC_NV_DefineSpace_auth:
+ return EFI_BAD_BUFFER_SIZE;
+ case TPM_RC_ATTRIBUTES:
+ case TPM_RC_ATTRIBUTES + RC_NV_DefineSpace_publicInfo:
+ return EFI_UNSUPPORTED;
+ case TPM_RC_ATTRIBUTES + RC_NV_DefineSpace_authHandle:
+ return EFI_INVALID_PARAMETER;
+ case TPM_RC_NV_DEFINED:
+ return EFI_ALREADY_STARTED;
+ case TPM_RC_VALUE + RC_NV_DefineSpace_publicInfo:
+ case TPM_RC_VALUE + RC_NV_DefineSpace_authHandle:
+ return EFI_INVALID_PARAMETER;
+ case TPM_RC_NV_SPACE:
+ return EFI_OUT_OF_RESOURCES;
+ default:
+ return EFI_DEVICE_ERROR;
+ }
+
+ return EFI_SUCCESS;
+}
+
+/**
+ This command removes an index from the TPM.
+
+ @param[in] AuthHandle TPM_RH_OWNER or TPM_RH_PLATFORM+{PP}.
+ @param[in] NvIndex The NV Index.
+ @param[in] AuthSession Auth Session context
+
+ @retval EFI_SUCCESS Operation completed successfully.
+ @retval EFI_DEVICE_ERROR The command was unsuccessful.
+ @retval EFI_NOT_FOUND The command was returned successfully, but NvIndex is not found.
+**/
+EFI_STATUS
+EFIAPI
+Tpm2NvUndefineSpace (
+ IN TPMI_RH_PROVISION AuthHandle,
+ IN TPMI_RH_NV_INDEX NvIndex,
+ IN TPMS_AUTH_COMMAND *AuthSession OPTIONAL
+ )
+{
+ EFI_STATUS Status;
+ TPM2_NV_UNDEFINESPACE_COMMAND SendBuffer;
+ TPM2_NV_UNDEFINESPACE_RESPONSE RecvBuffer;
+ UINT32 SendBufferSize;
+ UINT32 RecvBufferSize;
+ UINT8 *Buffer;
+ UINT32 SessionInfoSize;
+ TPM_RC ResponseCode;
+
+ //
+ // Construct command
+ //
+ SendBuffer.Header.tag = SwapBytes16(TPM_ST_SESSIONS);
+ SendBuffer.Header.commandCode = SwapBytes32(TPM_CC_NV_UndefineSpace);
+
+ SendBuffer.AuthHandle = SwapBytes32 (AuthHandle);
+ SendBuffer.NvIndex = SwapBytes32 (NvIndex);
+
+ //
+ // Add in Auth session
+ //
+ Buffer = (UINT8 *)&SendBuffer.AuthSession;
+
+ // sessionInfoSize
+ SessionInfoSize = CopyAuthSessionCommand (AuthSession, Buffer);
+ Buffer += SessionInfoSize;
+ SendBuffer.AuthSessionSize = SwapBytes32(SessionInfoSize);
+
+ SendBufferSize = (UINT32)(Buffer - (UINT8 *)&SendBuffer);
+ SendBuffer.Header.paramSize = SwapBytes32 (SendBufferSize);
+
+ //
+ // send Tpm command
+ //
+ RecvBufferSize = sizeof (RecvBuffer);
+ Status = Tpm2SubmitCommand (SendBufferSize, (UINT8 *)&SendBuffer, &RecvBufferSize, (UINT8 *)&RecvBuffer);
+ if (EFI_ERROR (Status)) {
+ return Status;
+ }
+
+ if (RecvBufferSize < sizeof (TPM2_RESPONSE_HEADER)) {
+ DEBUG ((EFI_D_ERROR, "Tpm2NvUndefineSpace - RecvBufferSize Error - %x\n", RecvBufferSize));
+ return EFI_DEVICE_ERROR;
+ }
+
+ ResponseCode = SwapBytes32(RecvBuffer.Header.responseCode);
+ if (ResponseCode != TPM_RC_SUCCESS) {
+ DEBUG ((EFI_D_ERROR, "Tpm2NvUndefineSpace - responseCode - %x\n", SwapBytes32(RecvBuffer.Header.responseCode)));
+ }
+ switch (ResponseCode) {
+ case TPM_RC_SUCCESS:
+ // return data
+ break;
+ case TPM_RC_ATTRIBUTES:
+ case TPM_RC_ATTRIBUTES + RC_NV_UndefineSpace_nvIndex:
+ return EFI_UNSUPPORTED;
+ case TPM_RC_NV_AUTHORIZATION:
+ return EFI_SECURITY_VIOLATION;
+ case TPM_RC_HANDLE + RC_NV_UndefineSpace_nvIndex: // TPM_RC_NV_DEFINED:
+ return EFI_NOT_FOUND;
+ case TPM_RC_HANDLE + RC_NV_UndefineSpace_authHandle: // TPM_RC_NV_DEFINED:
+ return EFI_INVALID_PARAMETER;
+ case TPM_RC_VALUE + RC_NV_UndefineSpace_authHandle:
+ case TPM_RC_VALUE + RC_NV_UndefineSpace_nvIndex:
+ return EFI_INVALID_PARAMETER;
+ default:
+ return EFI_DEVICE_ERROR;
+ }
+
+ return EFI_SUCCESS;
+}
+
+/**
+ This command reads a value from an area in NV memory previously defined by TPM2_NV_DefineSpace().
+
+ @param[in] AuthHandle the handle indicating the source of the authorization value.
+ @param[in] NvIndex The index to be read.
+ @param[in] AuthSession Auth Session context
+ @param[in] Size Number of bytes to read.
+ @param[in] Offset Byte offset into the area.
+ @param[in,out] OutData The data read.
+
+ @retval EFI_SUCCESS Operation completed successfully.
+ @retval EFI_DEVICE_ERROR The command was unsuccessful.
+ @retval EFI_NOT_FOUND The command was returned successfully, but NvIndex is not found.
+**/
+EFI_STATUS
+EFIAPI
+Tpm2NvRead (
+ IN TPMI_RH_NV_AUTH AuthHandle,
+ IN TPMI_RH_NV_INDEX NvIndex,
+ IN TPMS_AUTH_COMMAND *AuthSession, OPTIONAL
+ IN UINT16 Size,
+ IN UINT16 Offset,
+ IN OUT TPM2B_MAX_BUFFER *OutData
+ )
+{
+ EFI_STATUS Status;
+ TPM2_NV_READ_COMMAND SendBuffer;
+ TPM2_NV_READ_RESPONSE RecvBuffer;
+ UINT32 SendBufferSize;
+ UINT32 RecvBufferSize;
+ UINT8 *Buffer;
+ UINT32 SessionInfoSize;
+ TPM_RC ResponseCode;
+
+ //
+ // Construct command
+ //
+ SendBuffer.Header.tag = SwapBytes16(TPM_ST_SESSIONS);
+ SendBuffer.Header.commandCode = SwapBytes32(TPM_CC_NV_Read);
+
+ SendBuffer.AuthHandle = SwapBytes32 (AuthHandle);
+ SendBuffer.NvIndex = SwapBytes32 (NvIndex);
+
+ //
+ // Add in Auth session
+ //
+ Buffer = (UINT8 *)&SendBuffer.AuthSession;
+
+ // sessionInfoSize
+ SessionInfoSize = CopyAuthSessionCommand (AuthSession, Buffer);
+ Buffer += SessionInfoSize;
+ SendBuffer.AuthSessionSize = SwapBytes32(SessionInfoSize);
+
+ WriteUnaligned16 ((UINT16 *)Buffer, SwapBytes16 (Size));
+ Buffer += sizeof(UINT16);
+ WriteUnaligned16 ((UINT16 *)Buffer, SwapBytes16 (Offset));
+ Buffer += sizeof(UINT16);
+
+ SendBufferSize = (UINT32)(Buffer - (UINT8 *)&SendBuffer);
+ SendBuffer.Header.paramSize = SwapBytes32 (SendBufferSize);
+
+ //
+ // send Tpm command
+ //
+ RecvBufferSize = sizeof (RecvBuffer);
+ Status = Tpm2SubmitCommand (SendBufferSize, (UINT8 *)&SendBuffer, &RecvBufferSize, (UINT8 *)&RecvBuffer);
+ if (EFI_ERROR (Status)) {
+ return Status;
+ }
+
+ if (RecvBufferSize < sizeof (TPM2_RESPONSE_HEADER)) {
+ DEBUG ((EFI_D_ERROR, "Tpm2NvRead - RecvBufferSize Error - %x\n", RecvBufferSize));
+ return EFI_DEVICE_ERROR;
+ }
+ ResponseCode = SwapBytes32(RecvBuffer.Header.responseCode);
+ if (ResponseCode != TPM_RC_SUCCESS) {
+ DEBUG ((EFI_D_ERROR, "Tpm2NvRead - responseCode - %x\n", ResponseCode));
+ }
+ switch (ResponseCode) {
+ case TPM_RC_SUCCESS:
+ // return data
+ break;
+ case TPM_RC_NV_AUTHORIZATION:
+ return EFI_SECURITY_VIOLATION;
+ case TPM_RC_NV_LOCKED:
+ return EFI_ACCESS_DENIED;
+ case TPM_RC_NV_RANGE:
+ return EFI_BAD_BUFFER_SIZE;
+ case TPM_RC_NV_UNINITIALIZED:
+ return EFI_NOT_READY;
+ case TPM_RC_HANDLE + RC_NV_Read_nvIndex: // TPM_RC_NV_DEFINED:
+ return EFI_NOT_FOUND;
+ case TPM_RC_HANDLE + RC_NV_Read_authHandle: // TPM_RC_NV_DEFINED:
+ return EFI_INVALID_PARAMETER;
+ case TPM_RC_VALUE + RC_NV_Read_nvIndex:
+ case TPM_RC_VALUE + RC_NV_Read_authHandle:
+ return EFI_INVALID_PARAMETER;
+ case TPM_RC_BAD_AUTH + RC_NV_Read_authHandle + TPM_RC_S:
+ return EFI_INVALID_PARAMETER;
+ case TPM_RC_AUTH_UNAVAILABLE:
+ return EFI_INVALID_PARAMETER;
+ case TPM_RC_AUTH_FAIL + RC_NV_Read_authHandle + TPM_RC_S:
+ return EFI_INVALID_PARAMETER;
+ default:
+ return EFI_DEVICE_ERROR;
+ case TPM_RC_ATTRIBUTES + RC_NV_Read_authHandle + TPM_RC_S:
+ return EFI_UNSUPPORTED;
+ }
+
+ //
+ // Return the response
+ //
+ OutData->size = SwapBytes16 (RecvBuffer.Data.size);
+ CopyMem (OutData->buffer, &RecvBuffer.Data.buffer, OutData->size);
+
+ return EFI_SUCCESS;
+}
+
+/**
+ This command writes a value to an area in NV memory that was previously defined by TPM2_NV_DefineSpace().
+
+ @param[in] AuthHandle the handle indicating the source of the authorization value.
+ @param[in] NvIndex The NV Index of the area to write.
+ @param[in] AuthSession Auth Session context
+ @param[in] InData The data to write.
+ @param[in] Offset The offset into the NV Area.
+
+ @retval EFI_SUCCESS Operation completed successfully.
+ @retval EFI_DEVICE_ERROR The command was unsuccessful.
+ @retval EFI_NOT_FOUND The command was returned successfully, but NvIndex is not found.
+**/
+EFI_STATUS
+EFIAPI
+Tpm2NvWrite (
+ IN TPMI_RH_NV_AUTH AuthHandle,
+ IN TPMI_RH_NV_INDEX NvIndex,
+ IN TPMS_AUTH_COMMAND *AuthSession, OPTIONAL
+ IN TPM2B_MAX_BUFFER *InData,
+ IN UINT16 Offset
+ )
+{
+ EFI_STATUS Status;
+ TPM2_NV_WRITE_COMMAND SendBuffer;
+ TPM2_NV_WRITE_RESPONSE RecvBuffer;
+ UINT32 SendBufferSize;
+ UINT32 RecvBufferSize;
+ UINT8 *Buffer;
+ UINT32 SessionInfoSize;
+ TPM_RC ResponseCode;
+
+ //
+ // Construct command
+ //
+ SendBuffer.Header.tag = SwapBytes16(TPM_ST_SESSIONS);
+ SendBuffer.Header.commandCode = SwapBytes32(TPM_CC_NV_Write);
+
+ SendBuffer.AuthHandle = SwapBytes32 (AuthHandle);
+ SendBuffer.NvIndex = SwapBytes32 (NvIndex);
+
+ //
+ // Add in Auth session
+ //
+ Buffer = (UINT8 *)&SendBuffer.AuthSession;
+
+ // sessionInfoSize
+ SessionInfoSize = CopyAuthSessionCommand (AuthSession, Buffer);
+ Buffer += SessionInfoSize;
+ SendBuffer.AuthSessionSize = SwapBytes32(SessionInfoSize);
+
+ WriteUnaligned16 ((UINT16 *)Buffer, SwapBytes16 (InData->size));
+ Buffer += sizeof(UINT16);
+ CopyMem (Buffer, InData->buffer, InData->size);
+ Buffer += InData->size;
+ WriteUnaligned16 ((UINT16 *)Buffer, SwapBytes16 (Offset));
+ Buffer += sizeof(UINT16);
+
+ SendBufferSize = (UINT32) (Buffer - (UINT8 *)&SendBuffer);
+ SendBuffer.Header.paramSize = SwapBytes32 (SendBufferSize);
+
+ //
+ // send Tpm command
+ //
+ RecvBufferSize = sizeof (RecvBuffer);
+ Status = Tpm2SubmitCommand (SendBufferSize, (UINT8 *)&SendBuffer, &RecvBufferSize, (UINT8 *)&RecvBuffer);
+ if (EFI_ERROR (Status)) {
+ return Status;
+ }
+
+ if (RecvBufferSize < sizeof (TPM2_RESPONSE_HEADER)) {
+ DEBUG ((EFI_D_ERROR, "Tpm2NvWrite - RecvBufferSize Error - %x\n", RecvBufferSize));
+ return EFI_DEVICE_ERROR;
+ }
+ ResponseCode = SwapBytes32(RecvBuffer.Header.responseCode);
+ if (ResponseCode != TPM_RC_SUCCESS) {
+ DEBUG ((EFI_D_ERROR, "Tpm2NvWrite - responseCode - %x\n", ResponseCode));
+ }
+ switch (ResponseCode) {
+ case TPM_RC_SUCCESS:
+ return EFI_SUCCESS;
+ case TPM_RC_ATTRIBUTES:
+ return EFI_UNSUPPORTED;
+ case TPM_RC_NV_AUTHORIZATION:
+ return EFI_SECURITY_VIOLATION;
+ case TPM_RC_NV_LOCKED:
+ return EFI_ACCESS_DENIED;
+ case TPM_RC_NV_RANGE:
+ return EFI_BAD_BUFFER_SIZE;
+ case TPM_RC_HANDLE + RC_NV_Write_nvIndex: // TPM_RC_NV_DEFINED:
+ return EFI_NOT_FOUND;
+ case TPM_RC_HANDLE + RC_NV_Write_authHandle: // TPM_RC_NV_DEFINED:
+ return EFI_INVALID_PARAMETER;
+ case TPM_RC_VALUE + RC_NV_Write_nvIndex:
+ case TPM_RC_VALUE + RC_NV_Write_authHandle:
+ return EFI_INVALID_PARAMETER;
+ case TPM_RC_BAD_AUTH + RC_NV_Write_authHandle + TPM_RC_S:
+ return EFI_INVALID_PARAMETER;
+ case TPM_RC_AUTH_UNAVAILABLE:
+ return EFI_INVALID_PARAMETER;
+ case TPM_RC_AUTH_FAIL + RC_NV_Write_authHandle + TPM_RC_S:
+ return EFI_INVALID_PARAMETER;
+ default:
+ return EFI_DEVICE_ERROR;
+ case TPM_RC_ATTRIBUTES + RC_NV_Write_authHandle + TPM_RC_S:
+ return EFI_UNSUPPORTED;
+ }
+}
+
+/**
+ This command may be used to prevent further reads of the Index until the next TPM2_Startup (TPM_SU_CLEAR).
+
+ @param[in] AuthHandle the handle indicating the source of the authorization value.
+ @param[in] NvIndex The NV Index of the area to lock.
+ @param[in] AuthSession Auth Session context
+
+ @retval EFI_SUCCESS Operation completed successfully.
+ @retval EFI_DEVICE_ERROR The command was unsuccessful.
+ @retval EFI_NOT_FOUND The command was returned successfully, but NvIndex is not found.
+**/
+EFI_STATUS
+EFIAPI
+Tpm2NvReadLock (
+ IN TPMI_RH_NV_AUTH AuthHandle,
+ IN TPMI_RH_NV_INDEX NvIndex,
+ IN TPMS_AUTH_COMMAND *AuthSession OPTIONAL
+ )
+{
+ EFI_STATUS Status;
+ TPM2_NV_READLOCK_COMMAND SendBuffer;
+ TPM2_NV_READLOCK_RESPONSE RecvBuffer;
+ UINT32 SendBufferSize;
+ UINT32 RecvBufferSize;
+ UINT8 *Buffer;
+ UINT32 SessionInfoSize;
+ TPM_RC ResponseCode;
+
+ //
+ // Construct command
+ //
+ SendBuffer.Header.tag = SwapBytes16(TPM_ST_SESSIONS);
+ SendBuffer.Header.commandCode = SwapBytes32(TPM_CC_NV_ReadLock);
+
+ SendBuffer.AuthHandle = SwapBytes32 (AuthHandle);
+ SendBuffer.NvIndex = SwapBytes32 (NvIndex);
+
+ //
+ // Add in Auth session
+ //
+ Buffer = (UINT8 *)&SendBuffer.AuthSession;
+
+ // sessionInfoSize
+ SessionInfoSize = CopyAuthSessionCommand (AuthSession, Buffer);
+ Buffer += SessionInfoSize;
+ SendBuffer.AuthSessionSize = SwapBytes32(SessionInfoSize);
+
+ SendBufferSize = (UINT32)(Buffer - (UINT8 *)&SendBuffer);
+ SendBuffer.Header.paramSize = SwapBytes32 (SendBufferSize);
+
+ //
+ // send Tpm command
+ //
+ RecvBufferSize = sizeof (RecvBuffer);
+ Status = Tpm2SubmitCommand (SendBufferSize, (UINT8 *)&SendBuffer, &RecvBufferSize, (UINT8 *)&RecvBuffer);
+ if (EFI_ERROR (Status)) {
+ return Status;
+ }
+
+ if (RecvBufferSize < sizeof (TPM2_RESPONSE_HEADER)) {
+ DEBUG ((EFI_D_ERROR, "Tpm2NvReadLock - RecvBufferSize Error - %x\n", RecvBufferSize));
+ return EFI_DEVICE_ERROR;
+ }
+
+ ResponseCode = SwapBytes32(RecvBuffer.Header.responseCode);
+ if (ResponseCode != TPM_RC_SUCCESS) {
+ DEBUG ((EFI_D_ERROR, "Tpm2NvReadLock - responseCode - %x\n", SwapBytes32(RecvBuffer.Header.responseCode)));
+ }
+ switch (ResponseCode) {
+ case TPM_RC_SUCCESS:
+ // return data
+ break;
+ default:
+ return EFI_DEVICE_ERROR;
+ }
+
+ return EFI_SUCCESS;
+}
+
+/**
+ This command may be used to inhibit further writes of the Index.
+
+ @param[in] AuthHandle the handle indicating the source of the authorization value.
+ @param[in] NvIndex The NV Index of the area to lock.
+ @param[in] AuthSession Auth Session context
+
+ @retval EFI_SUCCESS Operation completed successfully.
+ @retval EFI_DEVICE_ERROR The command was unsuccessful.
+ @retval EFI_NOT_FOUND The command was returned successfully, but NvIndex is not found.
+**/
+EFI_STATUS
+EFIAPI
+Tpm2NvWriteLock (
+ IN TPMI_RH_NV_AUTH AuthHandle,
+ IN TPMI_RH_NV_INDEX NvIndex,
+ IN TPMS_AUTH_COMMAND *AuthSession OPTIONAL
+ )
+{
+ EFI_STATUS Status;
+ TPM2_NV_WRITELOCK_COMMAND SendBuffer;
+ TPM2_NV_WRITELOCK_RESPONSE RecvBuffer;
+ UINT32 SendBufferSize;
+ UINT32 RecvBufferSize;
+ UINT8 *Buffer;
+ UINT32 SessionInfoSize;
+ TPM_RC ResponseCode;
+
+ //
+ // Construct command
+ //
+ SendBuffer.Header.tag = SwapBytes16(TPM_ST_SESSIONS);
+ SendBuffer.Header.commandCode = SwapBytes32(TPM_CC_NV_WriteLock);
+
+ SendBuffer.AuthHandle = SwapBytes32 (AuthHandle);
+ SendBuffer.NvIndex = SwapBytes32 (NvIndex);
+
+ //
+ // Add in Auth session
+ //
+ Buffer = (UINT8 *)&SendBuffer.AuthSession;
+
+ // sessionInfoSize
+ SessionInfoSize = CopyAuthSessionCommand (AuthSession, Buffer);
+ Buffer += SessionInfoSize;
+ SendBuffer.AuthSessionSize = SwapBytes32(SessionInfoSize);
+
+ SendBufferSize = (UINT32)(Buffer - (UINT8 *)&SendBuffer);
+ SendBuffer.Header.paramSize = SwapBytes32 (SendBufferSize);
+
+ //
+ // send Tpm command
+ //
+ RecvBufferSize = sizeof (RecvBuffer);
+ Status = Tpm2SubmitCommand (SendBufferSize, (UINT8 *)&SendBuffer, &RecvBufferSize, (UINT8 *)&RecvBuffer);
+ if (EFI_ERROR (Status)) {
+ return Status;
+ }
+
+ if (RecvBufferSize < sizeof (TPM2_RESPONSE_HEADER)) {
+ DEBUG ((EFI_D_ERROR, "Tpm2NvWriteLock - RecvBufferSize Error - %x\n", RecvBufferSize));
+ return EFI_DEVICE_ERROR;
+ }
+
+ ResponseCode = SwapBytes32(RecvBuffer.Header.responseCode);
+ if (ResponseCode != TPM_RC_SUCCESS) {
+ DEBUG ((EFI_D_ERROR, "Tpm2NvWriteLock - responseCode - %x\n", SwapBytes32(RecvBuffer.Header.responseCode)));
+ }
+ switch (ResponseCode) {
+ case TPM_RC_SUCCESS:
+ // return data
+ break;
+ default:
+ return EFI_DEVICE_ERROR;
+ }
+
+ return EFI_SUCCESS;
+}
+
+/**
+ The command will SET TPMA_NV_WRITELOCKED for all indexes that have their TPMA_NV_GLOBALLOCK attribute SET.
+
+ @param[in] AuthHandle TPM_RH_OWNER or TPM_RH_PLATFORM+{PP}.
+ @param[in] AuthSession Auth Session context
+
+ @retval EFI_SUCCESS Operation completed successfully.
+ @retval EFI_DEVICE_ERROR The command was unsuccessful.
+ @retval EFI_NOT_FOUND The command was returned successfully, but NvIndex is not found.
+**/
+EFI_STATUS
+EFIAPI
+Tpm2NvGlobalWriteLock (
+ IN TPMI_RH_PROVISION AuthHandle,
+ IN TPMS_AUTH_COMMAND *AuthSession OPTIONAL
+ )
+{
+ EFI_STATUS Status;
+ TPM2_NV_GLOBALWRITELOCK_COMMAND SendBuffer;
+ TPM2_NV_GLOBALWRITELOCK_RESPONSE RecvBuffer;
+ UINT32 SendBufferSize;
+ UINT32 RecvBufferSize;
+ UINT8 *Buffer;
+ UINT32 SessionInfoSize;
+ TPM_RC ResponseCode;
+
+ //
+ // Construct command
+ //
+ SendBuffer.Header.tag = SwapBytes16(TPM_ST_SESSIONS);
+ SendBuffer.Header.commandCode = SwapBytes32(TPM_CC_NV_GlobalWriteLock);
+
+ SendBuffer.AuthHandle = SwapBytes32 (AuthHandle);
+
+ //
+ // Add in Auth session
+ //
+ Buffer = (UINT8 *)&SendBuffer.AuthSession;
+
+ // sessionInfoSize
+ SessionInfoSize = CopyAuthSessionCommand (AuthSession, Buffer);
+ Buffer += SessionInfoSize;
+ SendBuffer.AuthSessionSize = SwapBytes32(SessionInfoSize);
+
+ SendBufferSize = (UINT32)(Buffer - (UINT8 *)&SendBuffer);
+ SendBuffer.Header.paramSize = SwapBytes32 (SendBufferSize);
+
+ //
+ // send Tpm command
+ //
+ RecvBufferSize = sizeof (RecvBuffer);
+ Status = Tpm2SubmitCommand (SendBufferSize, (UINT8 *)&SendBuffer, &RecvBufferSize, (UINT8 *)&RecvBuffer);
+ if (EFI_ERROR (Status)) {
+ return Status;
+ }
+
+ if (RecvBufferSize < sizeof (TPM2_RESPONSE_HEADER)) {
+ DEBUG ((EFI_D_ERROR, "Tpm2NvGlobalWriteLock - RecvBufferSize Error - %x\n", RecvBufferSize));
+ return EFI_DEVICE_ERROR;
+ }
+
+ ResponseCode = SwapBytes32(RecvBuffer.Header.responseCode);
+ if (ResponseCode != TPM_RC_SUCCESS) {
+ DEBUG ((EFI_D_ERROR, "Tpm2NvGlobalWriteLock - responseCode - %x\n", SwapBytes32(RecvBuffer.Header.responseCode)));
+ }
+ switch (ResponseCode) {
+ case TPM_RC_SUCCESS:
+ // return data
+ break;
+ default:
+ return EFI_DEVICE_ERROR;
+ }
+
+ return EFI_SUCCESS;
+}
diff --git a/SecurityPkg/Library/Tpm2CommandLib/Tpm2Sequences.c b/SecurityPkg/Library/Tpm2CommandLib/Tpm2Sequences.c
new file mode 100644
index 000000000..305b6f207
--- /dev/null
+++ b/SecurityPkg/Library/Tpm2CommandLib/Tpm2Sequences.c
@@ -0,0 +1,508 @@
+/** @file
+ Implement TPM2 Sequences related command.
+
+Copyright (c) 2013, 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.
+
+**/
+
+#include <IndustryStandard/UefiTcgPlatform.h>
+#include <Library/Tpm2CommandLib.h>
+#include <Library/Tpm2DeviceLib.h>
+#include <Library/BaseMemoryLib.h>
+#include <Library/BaseLib.h>
+#include <Library/DebugLib.h>
+
+#pragma pack(1)
+
+typedef struct {
+ TPM2_COMMAND_HEADER Header;
+ TPM2B_AUTH Auth;
+ TPMI_ALG_HASH HashAlg;
+} TPM2_HASH_SEQUENCE_START_COMMAND;
+
+typedef struct {
+ TPM2_RESPONSE_HEADER Header;
+ TPMI_DH_OBJECT SequenceHandle;
+} TPM2_HASH_SEQUENCE_START_RESPONSE;
+
+typedef struct {
+ TPM2_COMMAND_HEADER Header;
+ TPMI_DH_OBJECT SequenceHandle;
+ UINT32 AuthorizationSize;
+ TPMS_AUTH_COMMAND AuthSessionSeq;
+ TPM2B_MAX_BUFFER Buffer;
+} TPM2_SEQUENCE_UPDATE_COMMAND;
+
+typedef struct {
+ TPM2_RESPONSE_HEADER Header;
+ UINT32 ParameterSize;
+ TPMS_AUTH_RESPONSE AuthSessionSeq;
+} TPM2_SEQUENCE_UPDATE_RESPONSE;
+
+typedef struct {
+ TPM2_COMMAND_HEADER Header;
+ TPMI_DH_PCR PcrHandle;
+ TPMI_DH_OBJECT SequenceHandle;
+ UINT32 AuthorizationSize;
+ TPMS_AUTH_COMMAND AuthSessionPcr;
+ TPMS_AUTH_COMMAND AuthSessionSeq;
+ TPM2B_MAX_BUFFER Buffer;
+} TPM2_EVENT_SEQUENCE_COMPLETE_COMMAND;
+
+typedef struct {
+ TPM2_RESPONSE_HEADER Header;
+ UINT32 ParameterSize;
+ TPML_DIGEST_VALUES Results;
+ TPMS_AUTH_RESPONSE AuthSessionPcr;
+ TPMS_AUTH_RESPONSE AuthSessionSeq;
+} TPM2_EVENT_SEQUENCE_COMPLETE_RESPONSE;
+
+typedef struct {
+ TPM2_COMMAND_HEADER Header;
+ TPMI_DH_OBJECT SequenceHandle;
+ UINT32 AuthorizationSize;
+ TPMS_AUTH_COMMAND AuthSessionSeq;
+ TPM2B_MAX_BUFFER Buffer;
+ TPMI_RH_HIERARCHY Hierarchy;
+} TPM2_SEQUENCE_COMPLETE_COMMAND;
+
+typedef struct {
+ TPM2_RESPONSE_HEADER Header;
+ UINT32 ParameterSize;
+ TPM2B_DIGEST Digest;
+ TPMS_AUTH_RESPONSE AuthSessionSeq;
+} TPM2_SEQUENCE_COMPLETE_RESPONSE;
+
+#pragma pack()
+
+/**
+ This command starts a hash or an Event sequence.
+ If hashAlg is an implemented hash, then a hash sequence is started.
+ If hashAlg is TPM_ALG_NULL, then an Event sequence is started.
+
+ @param[in] HashAlg The hash algorithm to use for the hash sequence
+ An Event sequence starts if this is TPM_ALG_NULL.
+ @param[out] SequenceHandle A handle to reference the sequence
+
+ @retval EFI_SUCCESS Operation completed successfully.
+ @retval EFI_DEVICE_ERROR Unexpected device behavior.
+**/
+EFI_STATUS
+EFIAPI
+Tpm2HashSequenceStart (
+ IN TPMI_ALG_HASH HashAlg,
+ OUT TPMI_DH_OBJECT *SequenceHandle
+ )
+{
+ EFI_STATUS Status;
+ TPM2_HASH_SEQUENCE_START_COMMAND Cmd;
+ TPM2_HASH_SEQUENCE_START_RESPONSE Res;
+ UINT32 CmdSize;
+ UINT32 RespSize;
+ UINT8 *Buffer;
+ UINT32 ResultBufSize;
+
+ ZeroMem(&Cmd, sizeof(Cmd));
+
+ //
+ // Construct command
+ //
+ Cmd.Header.tag = SwapBytes16(TPM_ST_NO_SESSIONS);
+ Cmd.Header.commandCode = SwapBytes32(TPM_CC_HashSequenceStart);
+
+ Buffer = (UINT8 *)&Cmd.Auth;
+
+ // auth = nullAuth
+ WriteUnaligned16 ((UINT16 *)Buffer, SwapBytes16(0));
+ Buffer += sizeof(UINT16);
+
+ // hashAlg
+ WriteUnaligned16 ((UINT16 *)Buffer, SwapBytes16(HashAlg));
+ Buffer += sizeof(UINT16);
+
+ CmdSize = (UINT32)(Buffer - (UINT8 *)&Cmd);
+ Cmd.Header.paramSize = SwapBytes32(CmdSize);
+
+ //
+ // Call the TPM
+ //
+ ResultBufSize = sizeof(Res);
+ Status = Tpm2SubmitCommand (CmdSize, (UINT8 *)&Cmd, &ResultBufSize, (UINT8 *)&Res);
+ if (EFI_ERROR(Status)) {
+ return Status;
+ }
+
+ if (ResultBufSize > sizeof(Res)) {
+ DEBUG ((EFI_D_ERROR, "HashSequenceStart: Failed ExecuteCommand: Buffer Too Small\r\n"));
+ return EFI_BUFFER_TOO_SMALL;
+ }
+
+ //
+ // Validate response headers
+ //
+ RespSize = SwapBytes32(Res.Header.paramSize);
+ if (RespSize > sizeof(Res)) {
+ DEBUG ((EFI_D_ERROR, "HashSequenceStart: Response size too large! %d\r\n", RespSize));
+ return EFI_BUFFER_TOO_SMALL;
+ }
+
+ //
+ // Fail if command failed
+ //
+ if (SwapBytes32(Res.Header.responseCode) != TPM_RC_SUCCESS) {
+ DEBUG ((EFI_D_ERROR, "HashSequenceStart: Response Code error! 0x%08x\r\n", SwapBytes32(Res.Header.responseCode)));
+ return EFI_DEVICE_ERROR;
+ }
+
+ //
+ // Unmarshal the response
+ //
+
+ // sequenceHandle
+ *SequenceHandle = SwapBytes32(Res.SequenceHandle);
+
+ return EFI_SUCCESS;
+}
+
+/**
+ This command is used to add data to a hash or HMAC sequence.
+ The amount of data in buffer may be any size up to the limits of the TPM.
+ NOTE: In all TPM, a buffer size of 1,024 octets is allowed.
+
+ @param[in] SequenceHandle Handle for the sequence object
+ @param[in] Buffer Data to be added to hash
+
+ @retval EFI_SUCCESS Operation completed successfully.
+ @retval EFI_DEVICE_ERROR Unexpected device behavior.
+**/
+EFI_STATUS
+EFIAPI
+Tpm2SequenceUpdate (
+ IN TPMI_DH_OBJECT SequenceHandle,
+ IN TPM2B_MAX_BUFFER *Buffer
+ )
+{
+ EFI_STATUS Status;
+ TPM2_SEQUENCE_UPDATE_COMMAND Cmd;
+ TPM2_SEQUENCE_UPDATE_RESPONSE Res;
+ UINT32 CmdSize;
+ UINT32 RespSize;
+ UINT8 *BufferPtr;
+ UINT32 SessionInfoSize;
+ UINT32 ResultBufSize;
+
+ ZeroMem(&Cmd, sizeof(Cmd));
+
+ //
+ // Construct command
+ //
+ Cmd.Header.tag = SwapBytes16(TPM_ST_SESSIONS);
+ Cmd.Header.commandCode = SwapBytes32(TPM_CC_SequenceUpdate);
+ Cmd.SequenceHandle = SwapBytes32(SequenceHandle);
+
+ //
+ // Add in Auth session
+ //
+ BufferPtr = (UINT8 *)&Cmd.AuthSessionSeq;
+
+ // sessionInfoSize
+ SessionInfoSize = CopyAuthSessionCommand (NULL, BufferPtr);
+ BufferPtr += SessionInfoSize;
+ Cmd.AuthorizationSize = SwapBytes32(SessionInfoSize);
+
+ // buffer.size
+ WriteUnaligned16 ((UINT16 *)BufferPtr, SwapBytes16(Buffer->size));
+ BufferPtr += sizeof(UINT16);
+
+ CopyMem(BufferPtr, &Buffer->buffer, Buffer->size);
+ BufferPtr += Buffer->size;
+
+ CmdSize = (UINT32)(BufferPtr - (UINT8 *)&Cmd);
+ Cmd.Header.paramSize = SwapBytes32(CmdSize);
+
+ //
+ // Call the TPM
+ //
+ ResultBufSize = sizeof(Res);
+ Status = Tpm2SubmitCommand (CmdSize, (UINT8 *)&Cmd,&ResultBufSize, (UINT8 *)&Res);
+ if (EFI_ERROR(Status)) {
+ return Status;
+ }
+
+ if (ResultBufSize > sizeof(Res)) {
+ DEBUG ((EFI_D_ERROR, "SequenceUpdate: Failed ExecuteCommand: Buffer Too Small\r\n"));
+ return EFI_BUFFER_TOO_SMALL;
+ }
+
+ //
+ // Validate response headers
+ //
+ RespSize = SwapBytes32(Res.Header.paramSize);
+ if (RespSize > sizeof(Res)) {
+ DEBUG ((EFI_D_ERROR, "SequenceUpdate: Response size too large! %d\r\n", RespSize));
+ return EFI_BUFFER_TOO_SMALL;
+ }
+
+ //
+ // Fail if command failed
+ //
+ if (SwapBytes32(Res.Header.responseCode) != TPM_RC_SUCCESS) {
+ DEBUG ((EFI_D_ERROR, "SequenceUpdate: Response Code error! 0x%08x\r\n", SwapBytes32(Res.Header.responseCode)));
+ return EFI_DEVICE_ERROR;
+ }
+
+ //
+ // Unmarshal the response
+ //
+
+ // None
+
+ return EFI_SUCCESS;
+}
+
+/**
+ This command adds the last part of data, if any, to an Event sequence and returns the result in a digest list.
+ If pcrHandle references a PCR and not TPM_RH_NULL, then the returned digest list is processed in
+ the same manner as the digest list input parameter to TPM2_PCR_Extend() with the pcrHandle in each
+ bank extended with the associated digest value.
+
+ @param[in] PcrHandle PCR to be extended with the Event data
+ @param[in] SequenceHandle Authorization for the sequence
+ @param[in] Buffer Data to be added to the Event
+ @param[out] Results List of digests computed for the PCR
+
+ @retval EFI_SUCCESS Operation completed successfully.
+ @retval EFI_DEVICE_ERROR Unexpected device behavior.
+**/
+EFI_STATUS
+EFIAPI
+Tpm2EventSequenceComplete (
+ IN TPMI_DH_PCR PcrHandle,
+ IN TPMI_DH_OBJECT SequenceHandle,
+ IN TPM2B_MAX_BUFFER *Buffer,
+ OUT TPML_DIGEST_VALUES *Results
+ )
+{
+ EFI_STATUS Status;
+ TPM2_EVENT_SEQUENCE_COMPLETE_COMMAND Cmd;
+ TPM2_EVENT_SEQUENCE_COMPLETE_RESPONSE Res;
+ UINT32 CmdSize;
+ UINT32 RespSize;
+ UINT8 *BufferPtr;
+ UINT32 SessionInfoSize;
+ UINT32 SessionInfoSize2;
+ UINT32 Index;
+ UINT32 ResultBufSize;
+ UINT16 DigestSize;
+
+ ZeroMem(&Cmd, sizeof(Cmd));
+
+ //
+ // Construct command
+ //
+ Cmd.Header.tag = SwapBytes16(TPM_ST_SESSIONS);
+ Cmd.Header.commandCode = SwapBytes32(TPM_CC_EventSequenceComplete);
+ Cmd.PcrHandle = SwapBytes32(PcrHandle);
+ Cmd.SequenceHandle = SwapBytes32(SequenceHandle);
+
+ //
+ // Add in pcrHandle Auth session
+ //
+ BufferPtr = (UINT8 *)&Cmd.AuthSessionPcr;
+
+ // sessionInfoSize
+ SessionInfoSize = CopyAuthSessionCommand (NULL, BufferPtr);
+ BufferPtr += SessionInfoSize;
+
+ // sessionInfoSize
+ SessionInfoSize2 = CopyAuthSessionCommand (NULL, BufferPtr);
+ BufferPtr += SessionInfoSize2;
+ Cmd.AuthorizationSize = SwapBytes32(SessionInfoSize + SessionInfoSize2);
+
+ // buffer.size
+ WriteUnaligned16 ((UINT16 *)BufferPtr, SwapBytes16(Buffer->size));
+ BufferPtr += sizeof(UINT16);
+
+ CopyMem(BufferPtr, &Buffer->buffer[0], Buffer->size);
+ BufferPtr += Buffer->size;
+
+ CmdSize = (UINT32)(BufferPtr - (UINT8 *)&Cmd);
+ Cmd.Header.paramSize = SwapBytes32(CmdSize);
+
+ //
+ // Call the TPM
+ //
+ ResultBufSize = sizeof(Res);
+ Status = Tpm2SubmitCommand (CmdSize, (UINT8 *)&Cmd, &ResultBufSize, (UINT8 *)&Res);
+ if (EFI_ERROR(Status)) {
+ return Status;
+ }
+
+ if (ResultBufSize > sizeof(Res)) {
+ DEBUG ((EFI_D_ERROR, "EventSequenceComplete: Failed ExecuteCommand: Buffer Too Small\r\n"));
+ return EFI_BUFFER_TOO_SMALL;
+ }
+
+ //
+ // Validate response headers
+ //
+ RespSize = SwapBytes32(Res.Header.paramSize);
+ if (RespSize > sizeof(Res)) {
+ DEBUG ((EFI_D_ERROR, "EventSequenceComplete: Response size too large! %d\r\n", RespSize));
+ return EFI_BUFFER_TOO_SMALL;
+ }
+
+ //
+ // Fail if command failed
+ //
+ if (SwapBytes32(Res.Header.responseCode) != TPM_RC_SUCCESS) {
+ DEBUG ((EFI_D_ERROR, "EventSequenceComplete: Response Code error! 0x%08x\r\n", SwapBytes32(Res.Header.responseCode)));
+ return EFI_DEVICE_ERROR;
+ }
+
+ //
+ // Unmarshal the response
+ //
+
+ BufferPtr = (UINT8 *)&Res.Results;
+
+ // count
+ Results->count = SwapBytes32(ReadUnaligned32 ((UINT32 *)BufferPtr));
+ BufferPtr += sizeof(UINT32);
+
+ for (Index = 0; Index < Results->count; Index++) {
+ Results->digests[Index].hashAlg = SwapBytes16(ReadUnaligned16 ((UINT16 *)BufferPtr));
+ BufferPtr += sizeof(UINT16);
+
+ DigestSize = GetHashSizeFromAlgo (Results->digests[Index].hashAlg);
+ if (DigestSize == 0) {
+ DEBUG ((EFI_D_ERROR, "EventSequenceComplete: Unknown hash algorithm %d\r\n", Results->digests[Index].hashAlg));
+ return EFI_DEVICE_ERROR;
+ }
+ CopyMem(
+ &Results->digests[Index].digest,
+ BufferPtr,
+ DigestSize
+ );
+ BufferPtr += DigestSize;
+ }
+
+ return EFI_SUCCESS;
+}
+
+/**
+ This command adds the last part of data, if any, to a hash/HMAC sequence and returns the result.
+
+ @param[in] SequenceHandle Authorization for the sequence
+ @param[in] Buffer Data to be added to the hash/HMAC
+ @param[out] Result The returned HMAC or digest in a sized buffer
+
+ @retval EFI_SUCCESS Operation completed successfully.
+ @retval EFI_DEVICE_ERROR Unexpected device behavior.
+**/
+EFI_STATUS
+EFIAPI
+Tpm2SequenceComplete (
+ IN TPMI_DH_OBJECT SequenceHandle,
+ IN TPM2B_MAX_BUFFER *Buffer,
+ OUT TPM2B_DIGEST *Result
+ )
+{
+ EFI_STATUS Status;
+ TPM2_SEQUENCE_COMPLETE_COMMAND Cmd;
+ TPM2_SEQUENCE_COMPLETE_RESPONSE Res;
+ UINT32 CmdSize;
+ UINT32 RespSize;
+ UINT8 *BufferPtr;
+ UINT32 SessionInfoSize;
+ UINT32 ResultBufSize;
+
+ ZeroMem(&Cmd, sizeof(Cmd));
+
+ //
+ // Construct command
+ //
+ Cmd.Header.tag = SwapBytes16(TPM_ST_SESSIONS);
+ Cmd.Header.commandCode = SwapBytes32(TPM_CC_SequenceComplete);
+ Cmd.SequenceHandle = SwapBytes32(SequenceHandle);
+
+ //
+ // Add in Auth session
+ //
+ BufferPtr = (UINT8 *)&Cmd.AuthSessionSeq;
+
+ // sessionInfoSize
+ SessionInfoSize = CopyAuthSessionCommand (NULL, BufferPtr);
+ BufferPtr += SessionInfoSize;
+ Cmd.AuthorizationSize = SwapBytes32(SessionInfoSize);
+
+ // buffer.size
+ WriteUnaligned16 ((UINT16 *)BufferPtr, SwapBytes16(Buffer->size));
+ BufferPtr += sizeof(UINT16);
+
+ CopyMem(BufferPtr, &Buffer->buffer[0], Buffer->size);
+ BufferPtr += Buffer->size;
+
+ // Hierarchy
+ WriteUnaligned32 ((UINT32 *)BufferPtr, SwapBytes32 (TPM_RH_NULL));
+ BufferPtr += sizeof (UINT32);
+
+ CmdSize = (UINT32)(BufferPtr - (UINT8 *)&Cmd);
+ Cmd.Header.paramSize = SwapBytes32(CmdSize);
+
+ //
+ // Call the TPM
+ //
+ ResultBufSize = sizeof(Res);
+ Status = Tpm2SubmitCommand (CmdSize, (UINT8 *)&Cmd, &ResultBufSize, (UINT8 *)&Res);
+ if (EFI_ERROR(Status)) {
+ return Status;
+ }
+
+ if (ResultBufSize > sizeof(Res)) {
+ DEBUG ((EFI_D_ERROR, "SequenceComplete: Failed ExecuteCommand: Buffer Too Small\r\n"));
+ return EFI_BUFFER_TOO_SMALL;
+ }
+
+ //
+ // Validate response headers
+ //
+ RespSize = SwapBytes32(Res.Header.paramSize);
+ if (RespSize > sizeof(Res)) {
+ DEBUG ((EFI_D_ERROR, "SequenceComplete: Response size too large! %d\r\n", RespSize));
+ return EFI_BUFFER_TOO_SMALL;
+ }
+
+ //
+ // Fail if command failed
+ //
+ if (SwapBytes32(Res.Header.responseCode) != TPM_RC_SUCCESS) {
+ DEBUG ((EFI_D_ERROR, "SequenceComplete: Response Code error! 0x%08x\r\n", SwapBytes32(Res.Header.responseCode)));
+ return EFI_DEVICE_ERROR;
+ }
+
+ //
+ // Unmarshal the response
+ //
+
+ BufferPtr = (UINT8 *)&Res.Digest;
+
+ // digestSize
+ Result->size = SwapBytes16(ReadUnaligned16 ((UINT16 *)BufferPtr));
+ BufferPtr += sizeof(UINT16);
+
+ CopyMem(
+ Result->buffer,
+ BufferPtr,
+ Result->size
+ );
+
+ return EFI_SUCCESS;
+}
diff --git a/SecurityPkg/Library/Tpm2CommandLib/Tpm2Startup.c b/SecurityPkg/Library/Tpm2CommandLib/Tpm2Startup.c
new file mode 100644
index 000000000..e8af4033c
--- /dev/null
+++ b/SecurityPkg/Library/Tpm2CommandLib/Tpm2Startup.c
@@ -0,0 +1,102 @@
+/** @file
+ Implement TPM2 Startup related command.
+
+Copyright (c) 2013, 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.
+
+**/
+
+#include <IndustryStandard/UefiTcgPlatform.h>
+#include <Library/Tpm2CommandLib.h>
+#include <Library/Tpm2DeviceLib.h>
+#include <Library/BaseMemoryLib.h>
+#include <Library/BaseLib.h>
+#include <Library/DebugLib.h>
+
+#pragma pack(1)
+
+typedef struct {
+ TPM2_COMMAND_HEADER Header;
+ TPM_SU StartupType;
+} TPM2_STARTUP_COMMAND;
+
+typedef struct {
+ TPM2_RESPONSE_HEADER Header;
+} TPM2_STARTUP_RESPONSE;
+
+typedef struct {
+ TPM2_COMMAND_HEADER Header;
+ TPM_SU ShutdownType;
+} TPM2_SHUTDOWN_COMMAND;
+
+typedef struct {
+ TPM2_RESPONSE_HEADER Header;
+} TPM2_SHUTDOWN_RESPONSE;
+
+#pragma pack()
+
+/**
+ Send Startup command to TPM2.
+
+ @param[in] StartupType TPM_SU_CLEAR or TPM_SU_STATE
+
+ @retval EFI_SUCCESS Operation completed successfully.
+ @retval EFI_DEVICE_ERROR Unexpected device behavior.
+**/
+EFI_STATUS
+EFIAPI
+Tpm2Startup (
+ IN TPM_SU StartupType
+ )
+{
+ EFI_STATUS Status;
+ TPM2_STARTUP_COMMAND Cmd;
+ TPM2_STARTUP_RESPONSE Res;
+ UINT32 ResultBufSize;
+
+ Cmd.Header.tag = SwapBytes16(TPM_ST_NO_SESSIONS);
+ Cmd.Header.paramSize = SwapBytes32(sizeof(Cmd));
+ Cmd.Header.commandCode = SwapBytes32(TPM_CC_Startup);
+ Cmd.StartupType = SwapBytes16(StartupType);
+
+ ResultBufSize = sizeof(Res);
+ Status = Tpm2SubmitCommand (sizeof(Cmd), (UINT8 *)&Cmd, &ResultBufSize, (UINT8 *)&Res);
+
+ return Status;
+}
+
+/**
+ Send Shutdown command to TPM2.
+
+ @param[in] ShutdownType TPM_SU_CLEAR or TPM_SU_STATE.
+
+ @retval EFI_SUCCESS Operation completed successfully.
+ @retval EFI_DEVICE_ERROR Unexpected device behavior.
+**/
+EFI_STATUS
+EFIAPI
+Tpm2Shutdown (
+ IN TPM_SU ShutdownType
+ )
+{
+ EFI_STATUS Status;
+ TPM2_SHUTDOWN_COMMAND Cmd;
+ TPM2_SHUTDOWN_RESPONSE Res;
+ UINT32 ResultBufSize;
+
+ Cmd.Header.tag = SwapBytes16(TPM_ST_NO_SESSIONS);
+ Cmd.Header.paramSize = SwapBytes32(sizeof(Cmd));
+ Cmd.Header.commandCode = SwapBytes32(TPM_CC_Shutdown);
+ Cmd.ShutdownType = SwapBytes16(ShutdownType);
+
+ ResultBufSize = sizeof(Res);
+ Status = Tpm2SubmitCommand (sizeof(Cmd), (UINT8 *)&Cmd, &ResultBufSize, (UINT8 *)&Res);
+
+ return Status;
+}
diff --git a/SecurityPkg/Library/Tpm2CommandLib/Tpm2Test.c b/SecurityPkg/Library/Tpm2CommandLib/Tpm2Test.c
new file mode 100644
index 000000000..453351bfb
--- /dev/null
+++ b/SecurityPkg/Library/Tpm2CommandLib/Tpm2Test.c
@@ -0,0 +1,66 @@
+/** @file
+ Implement TPM2 Test related command.
+
+Copyright (c) 2013, 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.
+
+**/
+
+#include <IndustryStandard/UefiTcgPlatform.h>
+#include <Library/Tpm2CommandLib.h>
+#include <Library/Tpm2DeviceLib.h>
+#include <Library/BaseMemoryLib.h>
+#include <Library/BaseLib.h>
+#include <Library/DebugLib.h>
+
+#pragma pack(1)
+
+typedef struct {
+ TPM2_COMMAND_HEADER Header;
+ TPMI_YES_NO FullTest;
+} TPM2_SELF_TEST_COMMAND;
+
+typedef struct {
+ TPM2_RESPONSE_HEADER Header;
+} TPM2_SELF_TEST_RESPONSE;
+
+#pragma pack()
+
+/**
+ This command causes the TPM to perform a test of its capabilities.
+ If the fullTest is YES, the TPM will test all functions.
+ If fullTest = NO, the TPM will only test those functions that have not previously been tested.
+
+ @param[in] FullTest YES if full test to be performed
+ NO if only test of untested functions required
+
+ @retval EFI_SUCCESS Operation completed successfully.
+ @retval EFI_DEVICE_ERROR Unexpected device behavior.
+**/
+EFI_STATUS
+EFIAPI
+Tpm2SelfTest (
+ IN TPMI_YES_NO FullTest
+ )
+{
+ EFI_STATUS Status;
+ TPM2_SELF_TEST_COMMAND Cmd;
+ TPM2_SELF_TEST_RESPONSE Res;
+ UINT32 ResultBufSize;
+
+ Cmd.Header.tag = SwapBytes16(TPM_ST_NO_SESSIONS);
+ Cmd.Header.paramSize = SwapBytes32(sizeof(Cmd));
+ Cmd.Header.commandCode = SwapBytes32(TPM_CC_SelfTest);
+ Cmd.FullTest = FullTest;
+
+ ResultBufSize = sizeof(Res);
+ Status = Tpm2SubmitCommand (sizeof(Cmd), (UINT8 *)&Cmd, &ResultBufSize, (UINT8 *)&Res);
+
+ return Status;
+}
diff --git a/SecurityPkg/Library/Tpm2DeviceLibDTpm/Tpm2DeviceLibDTpm.c b/SecurityPkg/Library/Tpm2DeviceLibDTpm/Tpm2DeviceLibDTpm.c
new file mode 100644
index 000000000..7d10dbbe4
--- /dev/null
+++ b/SecurityPkg/Library/Tpm2DeviceLibDTpm/Tpm2DeviceLibDTpm.c
@@ -0,0 +1,116 @@
+/** @file
+ Ihis library is TPM2 DTPM device lib.
+ Choosing this library means platform uses and only uses DTPM device as TPM2 engine.
+
+Copyright (c) 2013, 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.
+
+**/
+
+#include <Library/BaseLib.h>
+#include <Library/BaseMemoryLib.h>
+#include <Library/DebugLib.h>
+#include <Library/Tpm2DeviceLib.h>
+
+/**
+ This service enables the sending of commands to the TPM2.
+
+ @param[in] InputParameterBlockSize Size of the TPM2 input parameter block.
+ @param[in] InputParameterBlock Pointer to the TPM2 input parameter block.
+ @param[in,out] OutputParameterBlockSize Size of the TPM2 output parameter block.
+ @param[in] OutputParameterBlock Pointer to the TPM2 output parameter block.
+
+ @retval EFI_SUCCESS The command byte stream was successfully sent to the device and a response was successfully received.
+ @retval EFI_DEVICE_ERROR The command was not successfully sent to the device or a response was not successfully received from the device.
+ @retval EFI_BUFFER_TOO_SMALL The output parameter block is too small.
+**/
+EFI_STATUS
+EFIAPI
+DTpm2SubmitCommand (
+ IN UINT32 InputParameterBlockSize,
+ IN UINT8 *InputParameterBlock,
+ IN OUT UINT32 *OutputParameterBlockSize,
+ IN UINT8 *OutputParameterBlock
+ );
+
+/**
+ This service requests use TPM2.
+
+ @retval EFI_SUCCESS Get the control of TPM2 chip.
+ @retval EFI_NOT_FOUND TPM2 not found.
+ @retval EFI_DEVICE_ERROR Unexpected device behavior.
+**/
+EFI_STATUS
+EFIAPI
+DTpm2RequestUseTpm (
+ VOID
+ );
+
+/**
+ This service enables the sending of commands to the TPM2.
+
+ @param[in] InputParameterBlockSize Size of the TPM2 input parameter block.
+ @param[in] InputParameterBlock Pointer to the TPM2 input parameter block.
+ @param[in,out] OutputParameterBlockSize Size of the TPM2 output parameter block.
+ @param[in] OutputParameterBlock Pointer to the TPM2 output parameter block.
+
+ @retval EFI_SUCCESS The command byte stream was successfully sent to the device and a response was successfully received.
+ @retval EFI_DEVICE_ERROR The command was not successfully sent to the device or a response was not successfully received from the device.
+ @retval EFI_BUFFER_TOO_SMALL The output parameter block is too small.
+**/
+EFI_STATUS
+EFIAPI
+Tpm2SubmitCommand (
+ IN UINT32 InputParameterBlockSize,
+ IN UINT8 *InputParameterBlock,
+ IN OUT UINT32 *OutputParameterBlockSize,
+ IN UINT8 *OutputParameterBlock
+ )
+{
+ return DTpm2SubmitCommand (
+ InputParameterBlockSize,
+ InputParameterBlock,
+ OutputParameterBlockSize,
+ OutputParameterBlock
+ );
+}
+
+/**
+ This service requests use TPM2.
+
+ @retval EFI_SUCCESS Get the control of TPM2 chip.
+ @retval EFI_NOT_FOUND TPM2 not found.
+ @retval EFI_DEVICE_ERROR Unexpected device behavior.
+**/
+EFI_STATUS
+EFIAPI
+Tpm2RequestUseTpm (
+ VOID
+ )
+{
+ return DTpm2RequestUseTpm ();
+}
+
+/**
+ This service register TPM2 device.
+
+ @param Tpm2Device TPM2 device
+
+ @retval EFI_SUCCESS This TPM2 device is registered successfully.
+ @retval EFI_UNSUPPORTED System does not support register this TPM2 device.
+ @retval EFI_ALREADY_STARTED System already register this TPM2 device.
+**/
+EFI_STATUS
+EFIAPI
+Tpm2RegisterTpm2DeviceLib (
+ IN TPM2_DEVICE_INTERFACE *Tpm2Device
+ )
+{
+ return EFI_UNSUPPORTED;
+}
diff --git a/SecurityPkg/Library/Tpm2DeviceLibDTpm/Tpm2DeviceLibDTpm.inf b/SecurityPkg/Library/Tpm2DeviceLibDTpm/Tpm2DeviceLibDTpm.inf
new file mode 100644
index 000000000..78df432b6
--- /dev/null
+++ b/SecurityPkg/Library/Tpm2DeviceLibDTpm/Tpm2DeviceLibDTpm.inf
@@ -0,0 +1,45 @@
+## @file
+# Ihis library is TPM2 DTPM device lib.
+# Choosing this library means platform uses and only uses DTPM device as TPM2 engine.
+#
+# Copyright (c) 2013, 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.
+#
+##
+
+[Defines]
+ INF_VERSION = 0x00010005
+ BASE_NAME = Tpm2DeviceLibDTpm
+ FILE_GUID = E54A3327-A345-4068-8842-70AC0D519855
+ MODULE_TYPE = BASE
+ VERSION_STRING = 1.0
+ LIBRARY_CLASS = Tpm2DeviceLib
+
+#
+# The following information is for reference only and not required by the build tools.
+#
+# VALID_ARCHITECTURES = IA32 X64 IPF
+#
+
+[Sources]
+ Tpm2Tis.c
+ Tpm2DeviceLibDTpm.c
+
+[Packages]
+ MdePkg/MdePkg.dec
+ SecurityPkg/SecurityPkg.dec
+
+[LibraryClasses]
+ BaseLib
+ BaseMemoryLib
+ IoLib
+ TimerLib
+ DebugLib
+
+[Pcd]
+ gEfiSecurityPkgTokenSpaceGuid.PcdTpmBaseAddress
diff --git a/SecurityPkg/Library/Tpm2DeviceLibDTpm/Tpm2InstanceLibDTpm.c b/SecurityPkg/Library/Tpm2DeviceLibDTpm/Tpm2InstanceLibDTpm.c
new file mode 100644
index 000000000..6a6a04237
--- /dev/null
+++ b/SecurityPkg/Library/Tpm2DeviceLibDTpm/Tpm2InstanceLibDTpm.c
@@ -0,0 +1,85 @@
+/** @file
+ Ihis library is TPM2 DTPM instance.
+ It can be registered to Tpm2 Device router, to be active TPM2 engine,
+ based on platform setting.
+
+Copyright (c) 2013, 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.
+
+**/
+
+#include <Library/BaseLib.h>
+#include <Library/BaseMemoryLib.h>
+#include <Library/DebugLib.h>
+#include <Library/Tpm2DeviceLib.h>
+
+#include <Guid/TpmInstance.h>
+
+/**
+ This service enables the sending of commands to the TPM2.
+
+ @param[in] InputParameterBlockSize Size of the TPM2 input parameter block.
+ @param[in] InputParameterBlock Pointer to the TPM2 input parameter block.
+ @param[in,out] OutputParameterBlockSize Size of the TPM2 output parameter block.
+ @param[in] OutputParameterBlock Pointer to the TPM2 output parameter block.
+
+ @retval EFI_SUCCESS The command byte stream was successfully sent to the device and a response was successfully received.
+ @retval EFI_DEVICE_ERROR The command was not successfully sent to the device or a response was not successfully received from the device.
+ @retval EFI_BUFFER_TOO_SMALL The output parameter block is too small.
+**/
+EFI_STATUS
+EFIAPI
+DTpm2SubmitCommand (
+ IN UINT32 InputParameterBlockSize,
+ IN UINT8 *InputParameterBlock,
+ IN OUT UINT32 *OutputParameterBlockSize,
+ IN UINT8 *OutputParameterBlock
+ );
+
+/**
+ This service requests use TPM2.
+
+ @retval EFI_SUCCESS Get the control of TPM2 chip.
+ @retval EFI_NOT_FOUND TPM2 not found.
+ @retval EFI_DEVICE_ERROR Unexpected device behavior.
+**/
+EFI_STATUS
+EFIAPI
+DTpm2RequestUseTpm (
+ VOID
+ );
+
+TPM2_DEVICE_INTERFACE mDTpm2InternalTpm2Device = {
+ TPM_DEVICE_INTERFACE_TPM20_DTPM,
+ DTpm2SubmitCommand,
+ DTpm2RequestUseTpm,
+};
+
+/**
+ The function register DTPM2.0 instance.
+
+ @retval EFI_SUCCESS DTPM2.0 instance is registered, or system dose not surpport registr DTPM2.0 instance
+**/
+EFI_STATUS
+EFIAPI
+Tpm2InstanceLibDTpmConstructor (
+ VOID
+ )
+{
+ EFI_STATUS Status;
+
+ Status = Tpm2RegisterTpm2DeviceLib (&mDTpm2InternalTpm2Device);
+ if ((Status == EFI_SUCCESS) || (Status == EFI_UNSUPPORTED)) {
+ //
+ // Unsupported means platform policy does not need this instance enabled.
+ //
+ return EFI_SUCCESS;
+ }
+ return Status;
+}
diff --git a/SecurityPkg/Library/Tpm2DeviceLibDTpm/Tpm2InstanceLibDTpm.inf b/SecurityPkg/Library/Tpm2DeviceLibDTpm/Tpm2InstanceLibDTpm.inf
new file mode 100644
index 000000000..a4d8068df
--- /dev/null
+++ b/SecurityPkg/Library/Tpm2DeviceLibDTpm/Tpm2InstanceLibDTpm.inf
@@ -0,0 +1,47 @@
+## @file
+# Ihis library is TPM2 DTPM instance.
+# It can be registered to Tpm2 Device router, to be active TPM2 engine,
+# based on platform setting.
+#
+# Copyright (c) 2013, 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.
+#
+##
+
+[Defines]
+ INF_VERSION = 0x00010005
+ BASE_NAME = Tpm2InstanceLibDTpm
+ FILE_GUID = 286BF25A-C2C3-408c-B3B4-25E6758B7317
+ MODULE_TYPE = BASE
+ VERSION_STRING = 1.0
+ LIBRARY_CLASS = NULL
+ CONSTRUCTOR = Tpm2InstanceLibDTpmConstructor
+
+#
+# The following information is for reference only and not required by the build tools.
+#
+# VALID_ARCHITECTURES = IA32 X64 IPF
+#
+
+[Sources]
+ Tpm2Tis.c
+ Tpm2InstanceLibDTpm.c
+
+[Packages]
+ MdePkg/MdePkg.dec
+ SecurityPkg/SecurityPkg.dec
+
+[LibraryClasses]
+ BaseLib
+ BaseMemoryLib
+ IoLib
+ TimerLib
+ DebugLib
+
+[Pcd]
+ gEfiSecurityPkgTokenSpaceGuid.PcdTpmBaseAddress
diff --git a/SecurityPkg/Library/Tpm2DeviceLibDTpm/Tpm2Tis.c b/SecurityPkg/Library/Tpm2DeviceLibDTpm/Tpm2Tis.c
new file mode 100644
index 000000000..cf85d4c7e
--- /dev/null
+++ b/SecurityPkg/Library/Tpm2DeviceLibDTpm/Tpm2Tis.c
@@ -0,0 +1,583 @@
+/** @file
+ TIS (TPM Interface Specification) functions used by dTPM2.0 library.
+
+Copyright (c) 2013, 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.
+
+**/
+
+#include <IndustryStandard/Tpm20.h>
+
+#include <Library/BaseLib.h>
+#include <Library/BaseMemoryLib.h>
+#include <Library/IoLib.h>
+#include <Library/TimerLib.h>
+#include <Library/DebugLib.h>
+#include <Library/Tpm2DeviceLib.h>
+#include <Library/PcdLib.h>
+
+//
+// Set structure alignment to 1-byte
+//
+#pragma pack (1)
+
+//
+// Register set map as specified in TIS specification Chapter 10
+//
+typedef struct {
+ ///
+ /// Used to gain ownership for this particular port.
+ ///
+ UINT8 Access; // 0
+ UINT8 Reserved1[7]; // 1
+ ///
+ /// Controls interrupts.
+ ///
+ UINT32 IntEnable; // 8
+ ///
+ /// SIRQ vector to be used by the TPM.
+ ///
+ UINT8 IntVector; // 0ch
+ UINT8 Reserved2[3]; // 0dh
+ ///
+ /// What caused interrupt.
+ ///
+ UINT32 IntSts; // 10h
+ ///
+ /// Shows which interrupts are supported by that particular TPM.
+ ///
+ UINT32 IntfCapability; // 14h
+ ///
+ /// Status Register. Provides status of the TPM.
+ ///
+ UINT8 Status; // 18h
+ ///
+ /// Number of consecutive writes that can be done to the TPM.
+ ///
+ UINT16 BurstCount; // 19h
+ ///
+ /// TPM2 support CANCEL at BIT[24] of STATUS register (WO)
+ ///
+ UINT8 StatusEx; // 1Bh
+ UINT8 Reserved3[8];
+ ///
+ /// Read or write FIFO, depending on transaction.
+ ///
+ UINT32 DataFifo; // 24h
+ UINT8 Reserved4[0xed8]; // 28h
+ ///
+ /// Vendor ID
+ ///
+ UINT16 Vid; // 0f00h
+ ///
+ /// Device ID
+ ///
+ UINT16 Did; // 0f02h
+ ///
+ /// Revision ID
+ ///
+ UINT8 Rid; // 0f04h
+ ///
+ /// TCG defined configuration registers.
+ ///
+ UINT8 TcgDefined[0x7b]; // 0f05h
+ ///
+ /// Alias to I/O legacy space.
+ ///
+ UINT32 LegacyAddress1; // 0f80h
+ ///
+ /// Additional 8 bits for I/O legacy space extension.
+ ///
+ UINT32 LegacyAddress1Ex; // 0f84h
+ ///
+ /// Alias to second I/O legacy space.
+ ///
+ UINT32 LegacyAddress2; // 0f88h
+ ///
+ /// Additional 8 bits for second I/O legacy space extension.
+ ///
+ UINT32 LegacyAddress2Ex; // 0f8ch
+ ///
+ /// Vendor-defined configuration registers.
+ ///
+ UINT8 VendorDefined[0x70];// 0f90h
+} TIS_PC_REGISTERS;
+
+//
+// Restore original structure alignment
+//
+#pragma pack ()
+
+//
+// Define pointer types used to access TIS registers on PC
+//
+typedef TIS_PC_REGISTERS *TIS_PC_REGISTERS_PTR;
+
+//
+// Define bits of ACCESS and STATUS registers
+//
+
+///
+/// This bit is a 1 to indicate that the other bits in this register are valid.
+///
+#define TIS_PC_VALID BIT7
+///
+/// Indicate that this locality is active.
+///
+#define TIS_PC_ACC_ACTIVE BIT5
+///
+/// Set to 1 to indicate that this locality had the TPM taken away while
+/// this locality had the TIS_PC_ACC_ACTIVE bit set.
+///
+#define TIS_PC_ACC_SEIZED BIT4
+///
+/// Set to 1 to indicate that TPM MUST reset the
+/// TIS_PC_ACC_ACTIVE bit and remove ownership for localities less than the
+/// locality that is writing this bit.
+///
+#define TIS_PC_ACC_SEIZE BIT3
+///
+/// When this bit is 1, another locality is requesting usage of the TPM.
+///
+#define TIS_PC_ACC_PENDIND BIT2
+///
+/// Set to 1 to indicate that this locality is requesting to use TPM.
+///
+#define TIS_PC_ACC_RQUUSE BIT1
+///
+/// A value of 1 indicates that a T/OS has not been established on the platform
+///
+#define TIS_PC_ACC_ESTABLISH BIT0
+
+///
+/// When this bit is 1, TPM is in the Ready state,
+/// indicating it is ready to receive a new command.
+///
+#define TIS_PC_STS_READY BIT6
+///
+/// Write a 1 to this bit to cause the TPM to execute that command.
+///
+#define TIS_PC_STS_GO BIT5
+///
+/// This bit indicates that the TPM has data available as a response.
+///
+#define TIS_PC_STS_DATA BIT4
+///
+/// The TPM sets this bit to a value of 1 when it expects another byte of data for a command.
+///
+#define TIS_PC_STS_EXPECT BIT3
+///
+/// Writes a 1 to this bit to force the TPM to re-send the response.
+///
+#define TIS_PC_STS_RETRY BIT1
+
+//
+// Default TimeOut value
+//
+#define TIS_TIMEOUT_A (1000 * 1000) // 1s
+#define TIS_TIMEOUT_B (2000 * 1000) // 2s
+#define TIS_TIMEOUT_C (1000 * 1000) // 1s
+#define TIS_TIMEOUT_D (1000 * 1000) // 1s
+
+#define TIS_TIMEOUT_MAX (90000 * 1000) // 90s
+
+//
+// Max TPM command/reponse length
+//
+#define TPMCMDBUFLENGTH 0x500
+
+/**
+ Check whether TPM chip exist.
+
+ @param[in] TisReg Pointer to TIS register.
+
+ @retval TRUE TPM chip exists.
+ @retval FALSE TPM chip is not found.
+**/
+BOOLEAN
+TisPcPresenceCheck (
+ IN TIS_PC_REGISTERS_PTR TisReg
+ )
+{
+ UINT8 RegRead;
+
+ RegRead = MmioRead8 ((UINTN)&TisReg->Access);
+ return (BOOLEAN)(RegRead != (UINT8)-1);
+}
+
+/**
+ Check whether the value of a TPM chip register satisfies the input BIT setting.
+
+ @param[in] Register Address port of register to be checked.
+ @param[in] BitSet Check these data bits are set.
+ @param[in] BitClear Check these data bits are clear.
+ @param[in] TimeOut The max wait time (unit MicroSecond) when checking register.
+
+ @retval EFI_SUCCESS The register satisfies the check bit.
+ @retval EFI_TIMEOUT The register can't run into the expected status in time.
+**/
+EFI_STATUS
+EFIAPI
+TisPcWaitRegisterBits (
+ IN UINT8 *Register,
+ IN UINT8 BitSet,
+ IN UINT8 BitClear,
+ IN UINT32 TimeOut
+ )
+{
+ UINT8 RegRead;
+ UINT32 WaitTime;
+
+ for (WaitTime = 0; WaitTime < TimeOut; WaitTime += 30){
+ RegRead = MmioRead8 ((UINTN)Register);
+ if ((RegRead & BitSet) == BitSet && (RegRead & BitClear) == 0)
+ return EFI_SUCCESS;
+ MicroSecondDelay (30);
+ }
+ return EFI_TIMEOUT;
+}
+
+/**
+ Get BurstCount by reading the burstCount field of a TIS regiger
+ in the time of default TIS_TIMEOUT_D.
+
+ @param[in] TisReg Pointer to TIS register.
+ @param[out] BurstCount Pointer to a buffer to store the got BurstConut.
+
+ @retval EFI_SUCCESS Get BurstCount.
+ @retval EFI_INVALID_PARAMETER TisReg is NULL or BurstCount is NULL.
+ @retval EFI_TIMEOUT BurstCount can't be got in time.
+**/
+EFI_STATUS
+EFIAPI
+TisPcReadBurstCount (
+ IN TIS_PC_REGISTERS_PTR TisReg,
+ OUT UINT16 *BurstCount
+ )
+{
+ UINT32 WaitTime;
+ UINT8 DataByte0;
+ UINT8 DataByte1;
+
+ if (BurstCount == NULL || TisReg == NULL) {
+ return EFI_INVALID_PARAMETER;
+ }
+
+ WaitTime = 0;
+ do {
+ //
+ // TIS_PC_REGISTERS_PTR->burstCount is UINT16, but it is not 2bytes aligned,
+ // so it needs to use MmioRead8 to read two times
+ //
+ DataByte0 = MmioRead8 ((UINTN)&TisReg->BurstCount);
+ DataByte1 = MmioRead8 ((UINTN)&TisReg->BurstCount + 1);
+ *BurstCount = (UINT16)((DataByte1 << 8) + DataByte0);
+ if (*BurstCount != 0) {
+ return EFI_SUCCESS;
+ }
+ MicroSecondDelay (30);
+ WaitTime += 30;
+ } while (WaitTime < TIS_TIMEOUT_D);
+
+ return EFI_TIMEOUT;
+}
+
+/**
+ Set TPM chip to ready state by sending ready command TIS_PC_STS_READY
+ to Status Register in time.
+
+ @param[in] TisReg Pointer to TIS register.
+
+ @retval EFI_SUCCESS TPM chip enters into ready state.
+ @retval EFI_INVALID_PARAMETER TisReg is NULL.
+ @retval EFI_TIMEOUT TPM chip can't be set to ready state in time.
+**/
+EFI_STATUS
+EFIAPI
+TisPcPrepareCommand (
+ IN TIS_PC_REGISTERS_PTR TisReg
+ )
+{
+ EFI_STATUS Status;
+
+ if (TisReg == NULL) {
+ return EFI_INVALID_PARAMETER;
+ }
+
+ MmioWrite8((UINTN)&TisReg->Status, TIS_PC_STS_READY);
+ Status = TisPcWaitRegisterBits (
+ &TisReg->Status,
+ TIS_PC_STS_READY,
+ 0,
+ TIS_TIMEOUT_B
+ );
+ return Status;
+}
+
+/**
+ Get the control of TPM chip by sending requestUse command TIS_PC_ACC_RQUUSE
+ to ACCESS Register in the time of default TIS_TIMEOUT_A.
+
+ @param[in] TisReg Pointer to TIS register.
+
+ @retval EFI_SUCCESS Get the control of TPM chip.
+ @retval EFI_INVALID_PARAMETER TisReg is NULL.
+ @retval EFI_NOT_FOUND TPM chip doesn't exit.
+ @retval EFI_TIMEOUT Can't get the TPM control in time.
+**/
+EFI_STATUS
+EFIAPI
+TisPcRequestUseTpm (
+ IN TIS_PC_REGISTERS_PTR TisReg
+ )
+{
+ EFI_STATUS Status;
+
+ if (TisReg == NULL) {
+ return EFI_INVALID_PARAMETER;
+ }
+
+ if (!TisPcPresenceCheck (TisReg)) {
+ return EFI_NOT_FOUND;
+ }
+
+ MmioWrite8((UINTN)&TisReg->Access, TIS_PC_ACC_RQUUSE);
+ Status = TisPcWaitRegisterBits (
+ &TisReg->Access,
+ (UINT8)(TIS_PC_ACC_ACTIVE |TIS_PC_VALID),
+ 0,
+ TIS_TIMEOUT_A
+ );
+ return Status;
+}
+
+/**
+ Send a command to TPM for execution and return response data.
+
+ @param[in] TisReg TPM register space base address.
+ @param[in] BufferIn Buffer for command data.
+ @param[in] SizeIn Size of command data.
+ @param[in, out] BufferOut Buffer for response data.
+ @param[in, out] SizeOut Size of response data.
+
+ @retval EFI_SUCCESS Operation completed successfully.
+ @retval EFI_TIMEOUT The register can't run into the expected status in time.
+ @retval EFI_BUFFER_TOO_SMALL Response data buffer is too small.
+ @retval EFI_DEVICE_ERROR Unexpected device behavior.
+ @retval EFI_UNSUPPORTED Unsupported TPM version
+
+**/
+EFI_STATUS
+TisTpmCommand (
+ IN TIS_PC_REGISTERS_PTR TisReg,
+ IN UINT8 *BufferIn,
+ IN UINT32 SizeIn,
+ IN OUT UINT8 *BufferOut,
+ IN OUT UINT32 *SizeOut
+ )
+{
+ EFI_STATUS Status;
+ UINT16 BurstCount;
+ UINT32 Index;
+ UINT32 TpmOutSize;
+ UINT16 Data16;
+ UINT32 Data32;
+
+ DEBUG_CODE (
+ UINTN DebugSize;
+
+ DEBUG ((EFI_D_INFO, "TisTpmCommand Send - "));
+ if (SizeIn > 0x100) {
+ DebugSize = 0x40;
+ } else {
+ DebugSize = SizeIn;
+ }
+ for (Index = 0; Index < DebugSize; Index++) {
+ DEBUG ((EFI_D_INFO, "%02x ", BufferIn[Index]));
+ }
+ if (DebugSize != SizeIn) {
+ DEBUG ((EFI_D_INFO, "...... "));
+ for (Index = SizeIn - 0x20; Index < SizeIn; Index++) {
+ DEBUG ((EFI_D_INFO, "%02x ", BufferIn[Index]));
+ }
+ }
+ DEBUG ((EFI_D_INFO, "\n"));
+ );
+ TpmOutSize = 0;
+
+ Status = TisPcPrepareCommand (TisReg);
+ if (EFI_ERROR (Status)){
+ DEBUG ((DEBUG_ERROR, "Tpm is not ready for command!\n"));
+ return Status;
+ }
+ //
+ // Send the command data to Tpm
+ //
+ Index = 0;
+ while (Index < SizeIn) {
+ Status = TisPcReadBurstCount (TisReg, &BurstCount);
+ if (EFI_ERROR (Status)) {
+ Status = EFI_TIMEOUT;
+ goto Exit;
+ }
+ for (; BurstCount > 0 && Index < SizeIn; BurstCount--) {
+ MmioWrite8((UINTN)&TisReg->DataFifo, *(BufferIn + Index));
+ Index++;
+ }
+ }
+ //
+ // Check the Tpm status STS_EXPECT change from 1 to 0
+ //
+ Status = TisPcWaitRegisterBits (
+ &TisReg->Status,
+ (UINT8) TIS_PC_VALID,
+ TIS_PC_STS_EXPECT,
+ TIS_TIMEOUT_C
+ );
+ if (EFI_ERROR (Status)) {
+ DEBUG ((DEBUG_ERROR, "The send buffer too small!\n"));
+ Status = EFI_BUFFER_TOO_SMALL;
+ goto Exit;
+ }
+ //
+ // Executed the TPM command and waiting for the response data ready
+ //
+ MmioWrite8((UINTN)&TisReg->Status, TIS_PC_STS_GO);
+
+ //
+ // NOTE: That may take many seconds to minutes for certain commands, such as key generation.
+ //
+ Status = TisPcWaitRegisterBits (
+ &TisReg->Status,
+ (UINT8) (TIS_PC_VALID | TIS_PC_STS_DATA),
+ 0,
+ TIS_TIMEOUT_MAX
+ );
+ if (EFI_ERROR (Status)) {
+ DEBUG ((DEBUG_ERROR, "Wait for Tpm response data time out!!\n"));
+ Status = EFI_TIMEOUT;
+ goto Exit;
+ }
+ //
+ // Get response data header
+ //
+ Index = 0;
+ BurstCount = 0;
+ while (Index < sizeof (TPM2_RESPONSE_HEADER)) {
+ Status = TisPcReadBurstCount (TisReg, &BurstCount);
+ if (EFI_ERROR (Status)) {
+ Status = EFI_TIMEOUT;
+ goto Exit;
+ }
+ for (; BurstCount > 0; BurstCount--) {
+ *(BufferOut + Index) = MmioRead8 ((UINTN)&TisReg->DataFifo);
+ Index++;
+ if (Index == sizeof (TPM2_RESPONSE_HEADER)) break;
+ }
+ }
+ DEBUG_CODE (
+ DEBUG ((EFI_D_INFO, "TisTpmCommand ReceiveHeader - "));
+ for (Index = 0; Index < sizeof (TPM2_RESPONSE_HEADER); Index++) {
+ DEBUG ((EFI_D_INFO, "%02x ", BufferOut[Index]));
+ }
+ DEBUG ((EFI_D_INFO, "\n"));
+ );
+ //
+ // Check the reponse data header (tag,parasize and returncode )
+ //
+ CopyMem (&Data16, BufferOut, sizeof (UINT16));
+ // TPM2 should not use this RSP_COMMAND
+ if (SwapBytes16 (Data16) == TPM_ST_RSP_COMMAND) {
+ DEBUG ((EFI_D_ERROR, "TPM_ST_RSP error - %x\n", TPM_ST_RSP_COMMAND));
+ Status = EFI_UNSUPPORTED;
+ goto Exit;
+ }
+
+ CopyMem (&Data32, (BufferOut + 2), sizeof (UINT32));
+ TpmOutSize = SwapBytes32 (Data32);
+ if (*SizeOut < TpmOutSize) {
+ Status = EFI_BUFFER_TOO_SMALL;
+ goto Exit;
+ }
+ *SizeOut = TpmOutSize;
+ //
+ // Continue reading the remaining data
+ //
+ while ( Index < TpmOutSize ) {
+ for (; BurstCount > 0; BurstCount--) {
+ *(BufferOut + Index) = MmioRead8 ((UINTN)&TisReg->DataFifo);
+ Index++;
+ if (Index == TpmOutSize) {
+ Status = EFI_SUCCESS;
+ goto Exit;
+ }
+ }
+ Status = TisPcReadBurstCount (TisReg, &BurstCount);
+ if (EFI_ERROR (Status)) {
+ Status = EFI_TIMEOUT;
+ goto Exit;
+ }
+ }
+Exit:
+ DEBUG_CODE (
+ DEBUG ((EFI_D_INFO, "TisTpmCommand Receive - "));
+ for (Index = 0; Index < TpmOutSize; Index++) {
+ DEBUG ((EFI_D_INFO, "%02x ", BufferOut[Index]));
+ }
+ DEBUG ((EFI_D_INFO, "\n"));
+ );
+ MmioWrite8((UINTN)&TisReg->Status, TIS_PC_STS_READY);
+ return Status;
+}
+
+/**
+ This service enables the sending of commands to the TPM2.
+
+ @param[in] InputParameterBlockSize Size of the TPM2 input parameter block.
+ @param[in] InputParameterBlock Pointer to the TPM2 input parameter block.
+ @param[in,out] OutputParameterBlockSize Size of the TPM2 output parameter block.
+ @param[in] OutputParameterBlock Pointer to the TPM2 output parameter block.
+
+ @retval EFI_SUCCESS The command byte stream was successfully sent to the device and a response was successfully received.
+ @retval EFI_DEVICE_ERROR The command was not successfully sent to the device or a response was not successfully received from the device.
+ @retval EFI_BUFFER_TOO_SMALL The output parameter block is too small.
+**/
+EFI_STATUS
+EFIAPI
+DTpm2SubmitCommand (
+ IN UINT32 InputParameterBlockSize,
+ IN UINT8 *InputParameterBlock,
+ IN OUT UINT32 *OutputParameterBlockSize,
+ IN UINT8 *OutputParameterBlock
+ )
+{
+ return TisTpmCommand (
+ (TIS_PC_REGISTERS_PTR) (UINTN) PcdGet64 (PcdTpmBaseAddress),
+ InputParameterBlock,
+ InputParameterBlockSize,
+ OutputParameterBlock,
+ OutputParameterBlockSize
+ );
+}
+
+/**
+ This service requests use TPM2.
+
+ @retval EFI_SUCCESS Get the control of TPM2 chip.
+ @retval EFI_NOT_FOUND TPM2 not found.
+ @retval EFI_DEVICE_ERROR Unexpected device behavior.
+**/
+EFI_STATUS
+EFIAPI
+DTpm2RequestUseTpm (
+ VOID
+ )
+{
+ return TisPcRequestUseTpm ((TIS_PC_REGISTERS_PTR) (UINTN) PcdGet64 (PcdTpmBaseAddress));
+}
diff --git a/SecurityPkg/Library/Tpm2DeviceLibRouter/Tpm2DeviceLibRouterDxe.c b/SecurityPkg/Library/Tpm2DeviceLibRouter/Tpm2DeviceLibRouterDxe.c
new file mode 100644
index 000000000..5e1501eda
--- /dev/null
+++ b/SecurityPkg/Library/Tpm2DeviceLibRouter/Tpm2DeviceLibRouterDxe.c
@@ -0,0 +1,98 @@
+/** @file
+ Ihis library is TPM2 device router. Platform can register multi TPM2 instance to it
+ via PcdTpmInstanceGuid. Platform need make choice that which one will be final one.
+ At most one TPM2 instance can be finally registered, and other will return unsupported.
+
+Copyright (c) 2013, 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.
+
+**/
+
+#include <Library/BaseLib.h>
+#include <Library/BaseMemoryLib.h>
+#include <Library/DebugLib.h>
+#include <Library/PcdLib.h>
+#include <Library/Tpm2DeviceLib.h>
+
+TPM2_DEVICE_INTERFACE mInternalTpm2DeviceInterface;
+
+/**
+ This service enables the sending of commands to the TPM2.
+
+ @param[in] InputParameterBlockSize Size of the TPM2 input parameter block.
+ @param[in] InputParameterBlock Pointer to the TPM2 input parameter block.
+ @param[in,out] OutputParameterBlockSize Size of the TPM2 output parameter block.
+ @param[in] OutputParameterBlock Pointer to the TPM2 output parameter block.
+
+ @retval EFI_SUCCESS The command byte stream was successfully sent to the device and a response was successfully received.
+ @retval EFI_DEVICE_ERROR The command was not successfully sent to the device or a response was not successfully received from the device.
+ @retval EFI_BUFFER_TOO_SMALL The output parameter block is too small.
+**/
+EFI_STATUS
+EFIAPI
+Tpm2SubmitCommand (
+ IN UINT32 InputParameterBlockSize,
+ IN UINT8 *InputParameterBlock,
+ IN OUT UINT32 *OutputParameterBlockSize,
+ IN UINT8 *OutputParameterBlock
+ )
+{
+ if (mInternalTpm2DeviceInterface.Tpm2SubmitCommand == NULL) {
+ return EFI_UNSUPPORTED;
+ }
+ return mInternalTpm2DeviceInterface.Tpm2SubmitCommand (
+ InputParameterBlockSize,
+ InputParameterBlock,
+ OutputParameterBlockSize,
+ OutputParameterBlock
+ );
+}
+
+/**
+ This service requests use TPM2.
+
+ @retval EFI_SUCCESS Get the control of TPM2 chip.
+ @retval EFI_NOT_FOUND TPM2 not found.
+ @retval EFI_DEVICE_ERROR Unexpected device behavior.
+**/
+EFI_STATUS
+EFIAPI
+Tpm2RequestUseTpm (
+ VOID
+ )
+{
+ if (mInternalTpm2DeviceInterface.Tpm2RequestUseTpm == NULL) {
+ return EFI_UNSUPPORTED;
+ }
+ return mInternalTpm2DeviceInterface.Tpm2RequestUseTpm ();
+}
+
+/**
+ This service register TPM2 device.
+
+ @param Tpm2Device TPM2 device
+
+ @retval EFI_SUCCESS This TPM2 device is registered successfully.
+ @retval EFI_UNSUPPORTED System does not support register this TPM2 device.
+ @retval EFI_ALREADY_STARTED System already register this TPM2 device.
+**/
+EFI_STATUS
+EFIAPI
+Tpm2RegisterTpm2DeviceLib (
+ IN TPM2_DEVICE_INTERFACE *Tpm2Device
+ )
+{
+ if (!CompareGuid (PcdGetPtr(PcdTpmInstanceGuid), &Tpm2Device->ProviderGuid)){
+ DEBUG ((EFI_D_ERROR, "WARNING: Tpm2RegisterTpm2DeviceLib - does not support %g registration\n", &Tpm2Device->ProviderGuid));
+ return EFI_UNSUPPORTED;
+ }
+
+ CopyMem (&mInternalTpm2DeviceInterface, Tpm2Device, sizeof(mInternalTpm2DeviceInterface));
+ return EFI_SUCCESS;
+}
diff --git a/SecurityPkg/Library/Tpm2DeviceLibRouter/Tpm2DeviceLibRouterDxe.inf b/SecurityPkg/Library/Tpm2DeviceLibRouter/Tpm2DeviceLibRouterDxe.inf
new file mode 100644
index 000000000..2e699887e
--- /dev/null
+++ b/SecurityPkg/Library/Tpm2DeviceLibRouter/Tpm2DeviceLibRouterDxe.inf
@@ -0,0 +1,44 @@
+## @file
+# Ihis library is TPM2 device router. Platform can register multi TPM2 instance to it
+# via PcdTpmInstanceGuid. Platform need make choice that which one will be final one.
+# At most one TPM2 instance can be finally registered, and other will return unsupported.
+#
+# Copyright (c) 2013, 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.
+#
+##
+
+[Defines]
+ INF_VERSION = 0x00010005
+ BASE_NAME = Tpm2DeviceLibRouterDxe
+ FILE_GUID = C3D69D87-5200-4aab-A6DB-2569BA1A92FC
+ MODULE_TYPE = DXE_DRIVER
+ VERSION_STRING = 1.0
+ LIBRARY_CLASS = Tpm2DeviceLib|DXE_DRIVER DXE_RUNTIME_DRIVER DXE_SAL_DRIVER DXE_SMM_DRIVER UEFI_APPLICATION UEFI_DRIVER
+
+#
+# The following information is for reference only and not required by the build tools.
+#
+# VALID_ARCHITECTURES = IA32 X64 IPF
+#
+
+[Sources]
+ Tpm2DeviceLibRouterDxe.c
+
+[Packages]
+ MdePkg/MdePkg.dec
+ SecurityPkg/SecurityPkg.dec
+
+[LibraryClasses]
+ BaseLib
+ BaseMemoryLib
+ DebugLib
+ PcdLib
+
+[Pcd]
+ gEfiSecurityPkgTokenSpaceGuid.PcdTpmInstanceGuid
diff --git a/SecurityPkg/Library/Tpm2DeviceLibRouter/Tpm2DeviceLibRouterPei.c b/SecurityPkg/Library/Tpm2DeviceLibRouter/Tpm2DeviceLibRouterPei.c
new file mode 100644
index 000000000..f59b7bf1b
--- /dev/null
+++ b/SecurityPkg/Library/Tpm2DeviceLibRouter/Tpm2DeviceLibRouterPei.c
@@ -0,0 +1,143 @@
+/** @file
+ Ihis library is TPM2 device router. Platform can register multi TPM2 instance to it
+ via PcdTpmInstanceGuid. Platform need make choice that which one will be final one.
+ At most one TPM2 instance can be finally registered, and other will return unsupported.
+
+Copyright (c) 2013, 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.
+
+**/
+
+#include <Library/BaseLib.h>
+#include <Library/BaseMemoryLib.h>
+#include <Library/HobLib.h>
+#include <Library/DebugLib.h>
+#include <Library/PcdLib.h>
+#include <Library/Tpm2DeviceLib.h>
+
+EFI_GUID mInternalTpm2DeviceInterfaceGuid = {
+ 0x349cf818, 0xc0ba, 0x4c43, 0x92, 0x9a, 0xc8, 0xa1, 0xb1, 0xb3, 0xd2, 0x55
+};
+
+/**
+ This function get TPM2.0 interface.
+
+ @retval TPM2.0 interface.
+**/
+TPM2_DEVICE_INTERFACE *
+InternalGetTpm2DeviceInterface (
+ VOID
+ )
+{
+ EFI_HOB_GUID_TYPE *Hob;
+
+ Hob = GetFirstGuidHob (&mInternalTpm2DeviceInterfaceGuid);
+ if (Hob == NULL) {
+ return NULL;
+ }
+ return (TPM2_DEVICE_INTERFACE *)(Hob + 1);
+}
+
+/**
+ This service enables the sending of commands to the TPM2.
+
+ @param[in] InputParameterBlockSize Size of the TPM2 input parameter block.
+ @param[in] InputParameterBlock Pointer to the TPM2 input parameter block.
+ @param[in,out] OutputParameterBlockSize Size of the TPM2 output parameter block.
+ @param[in] OutputParameterBlock Pointer to the TPM2 output parameter block.
+
+ @retval EFI_SUCCESS The command byte stream was successfully sent to the device and a response was successfully received.
+ @retval EFI_DEVICE_ERROR The command was not successfully sent to the device or a response was not successfully received from the device.
+ @retval EFI_BUFFER_TOO_SMALL The output parameter block is too small.
+**/
+EFI_STATUS
+EFIAPI
+Tpm2SubmitCommand (
+ IN UINT32 InputParameterBlockSize,
+ IN UINT8 *InputParameterBlock,
+ IN OUT UINT32 *OutputParameterBlockSize,
+ IN UINT8 *OutputParameterBlock
+ )
+{
+ TPM2_DEVICE_INTERFACE *Tpm2DeviceInterface;
+
+ Tpm2DeviceInterface = InternalGetTpm2DeviceInterface ();
+ if (Tpm2DeviceInterface == NULL) {
+ return EFI_UNSUPPORTED;
+ }
+
+ return Tpm2DeviceInterface->Tpm2SubmitCommand (
+ InputParameterBlockSize,
+ InputParameterBlock,
+ OutputParameterBlockSize,
+ OutputParameterBlock
+ );
+}
+
+/**
+ This service requests use TPM2.
+
+ @retval EFI_SUCCESS Get the control of TPM2 chip.
+ @retval EFI_NOT_FOUND TPM2 not found.
+ @retval EFI_DEVICE_ERROR Unexpected device behavior.
+**/
+EFI_STATUS
+EFIAPI
+Tpm2RequestUseTpm (
+ VOID
+ )
+{
+ TPM2_DEVICE_INTERFACE *Tpm2DeviceInterface;
+
+ Tpm2DeviceInterface = InternalGetTpm2DeviceInterface ();
+ if (Tpm2DeviceInterface == NULL) {
+ return EFI_UNSUPPORTED;
+ }
+ return Tpm2DeviceInterface->Tpm2RequestUseTpm ();
+}
+
+/**
+ This service register TPM2 device.
+
+ @param Tpm2Device TPM2 device
+
+ @retval EFI_SUCCESS This TPM2 device is registered successfully.
+ @retval EFI_UNSUPPORTED System does not support register this TPM2 device.
+ @retval EFI_ALREADY_STARTED System already register this TPM2 device.
+**/
+EFI_STATUS
+EFIAPI
+Tpm2RegisterTpm2DeviceLib (
+ IN TPM2_DEVICE_INTERFACE *Tpm2Device
+ )
+{
+ TPM2_DEVICE_INTERFACE *Tpm2DeviceInterface;
+
+ if (!CompareGuid (PcdGetPtr(PcdTpmInstanceGuid), &Tpm2Device->ProviderGuid)){
+ DEBUG ((EFI_D_ERROR, "WARNING: Tpm2RegisterTpm2DeviceLib - does not support %g registration\n", &Tpm2Device->ProviderGuid));
+ return EFI_UNSUPPORTED;
+ }
+
+ Tpm2DeviceInterface = InternalGetTpm2DeviceInterface ();
+ if (Tpm2DeviceInterface != NULL) {
+ //
+ // In PEI phase, there will be shadow driver dispatched again.
+ //
+ DEBUG ((EFI_D_ERROR, "Tpm2RegisterTpm2DeviceLib - Override\n"));
+ CopyMem (Tpm2DeviceInterface, Tpm2Device, sizeof(*Tpm2Device));
+ return EFI_SUCCESS;
+ } else {
+ Tpm2Device = BuildGuidDataHob (&mInternalTpm2DeviceInterfaceGuid, Tpm2Device, sizeof(*Tpm2Device));
+ if (Tpm2Device != NULL) {
+ return EFI_SUCCESS;
+ } else {
+ return EFI_OUT_OF_RESOURCES;
+ }
+ }
+}
diff --git a/SecurityPkg/Library/Tpm2DeviceLibRouter/Tpm2DeviceLibRouterPei.inf b/SecurityPkg/Library/Tpm2DeviceLibRouter/Tpm2DeviceLibRouterPei.inf
new file mode 100644
index 000000000..dbdfc3dec
--- /dev/null
+++ b/SecurityPkg/Library/Tpm2DeviceLibRouter/Tpm2DeviceLibRouterPei.inf
@@ -0,0 +1,46 @@
+## @file
+# Ihis library is TPM2 device router. Platform can register multi TPM2 instance to it
+# via PcdTpmInstanceGuid. Platform need make choice that which one will be final one.
+# At most one TPM2 instance can be finally registered, and other will return unsupported.
+#
+# Copyright (c) 2013, 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.
+#
+##
+
+[Defines]
+ INF_VERSION = 0x00010005
+ BASE_NAME = Tpm2DeviceLibRouterPei
+ FILE_GUID = 97CDCF04-4C8E-42fe-8015-11CC8A6E9D81
+ MODULE_TYPE = PEIM
+ VERSION_STRING = 1.0
+ LIBRARY_CLASS = Tpm2DeviceLib|PEIM
+
+#
+# The following information is for reference only and not required by the build tools.
+#
+# VALID_ARCHITECTURES = IA32 X64 IPF
+#
+
+[Sources]
+ Tpm2DeviceLibRouterPei.c
+
+[Packages]
+ MdePkg/MdePkg.dec
+ SecurityPkg/SecurityPkg.dec
+
+[LibraryClasses]
+ BaseLib
+ BaseMemoryLib
+ DebugLib
+ HobLib
+ PcdLib
+
+[Pcd]
+ gEfiSecurityPkgTokenSpaceGuid.PcdTpmInstanceGuid
+ \ No newline at end of file
diff --git a/SecurityPkg/Library/Tpm2DeviceLibTrEE/Tpm2DeviceLibTrEE.c b/SecurityPkg/Library/Tpm2DeviceLibTrEE/Tpm2DeviceLibTrEE.c
new file mode 100644
index 000000000..53963b743
--- /dev/null
+++ b/SecurityPkg/Library/Tpm2DeviceLibTrEE/Tpm2DeviceLibTrEE.c
@@ -0,0 +1,125 @@
+/** @file
+ Ihis library is TPM2 TREE protocol lib.
+
+Copyright (c) 2013, 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.
+
+**/
+
+#include <Library/BaseLib.h>
+#include <Library/BaseMemoryLib.h>
+#include <Library/DebugLib.h>
+#include <Library/UefiBootServicesTableLib.h>
+#include <Library/Tpm2DeviceLib.h>
+#include <Protocol/TrEEProtocol.h>
+#include <IndustryStandard/Tpm20.h>
+
+EFI_TREE_PROTOCOL *mTreeProtocol = NULL;
+
+/**
+ This service enables the sending of commands to the TPM2.
+
+ @param[in] InputParameterBlockSize Size of the TPM2 input parameter block.
+ @param[in] InputParameterBlock Pointer to the TPM2 input parameter block.
+ @param[in,out] OutputParameterBlockSize Size of the TPM2 output parameter block.
+ @param[in] OutputParameterBlock Pointer to the TPM2 output parameter block.
+
+ @retval EFI_SUCCESS The command byte stream was successfully sent to the device and a response was successfully received.
+ @retval EFI_DEVICE_ERROR The command was not successfully sent to the device or a response was not successfully received from the device.
+ @retval EFI_BUFFER_TOO_SMALL The output parameter block is too small.
+**/
+EFI_STATUS
+EFIAPI
+Tpm2SubmitCommand (
+ IN UINT32 InputParameterBlockSize,
+ IN UINT8 *InputParameterBlock,
+ IN OUT UINT32 *OutputParameterBlockSize,
+ IN UINT8 *OutputParameterBlock
+ )
+{
+ EFI_STATUS Status;
+ TPM2_RESPONSE_HEADER *Header;
+
+ if (mTreeProtocol == NULL) {
+ Status = gBS->LocateProtocol (&gEfiTrEEProtocolGuid, NULL, (VOID **) &mTreeProtocol);
+ if (EFI_ERROR (Status)) {
+ //
+ // TrEE protocol is not installed. So, TPM2 is not present.
+ //
+ DEBUG ((EFI_D_ERROR, "Tpm2SubmitCommand - TrEE - %r\n", Status));
+ return EFI_NOT_FOUND;
+ }
+ }
+ //
+ // Assume when TrEE Protocol is ready, RequestUseTpm already done.
+ //
+ Status = mTreeProtocol->SubmitCommand (
+ mTreeProtocol,
+ InputParameterBlockSize,
+ InputParameterBlock,
+ *OutputParameterBlockSize,
+ OutputParameterBlock
+ );
+ if (EFI_ERROR (Status)) {
+ return Status;
+ }
+ Header = (TPM2_RESPONSE_HEADER *)OutputParameterBlock;
+ *OutputParameterBlockSize = SwapBytes32 (Header->paramSize);
+
+ return EFI_SUCCESS;
+}
+
+/**
+ This service requests use TPM2.
+
+ @retval EFI_SUCCESS Get the control of TPM2 chip.
+ @retval EFI_NOT_FOUND TPM2 not found.
+ @retval EFI_DEVICE_ERROR Unexpected device behavior.
+**/
+EFI_STATUS
+EFIAPI
+Tpm2RequestUseTpm (
+ VOID
+ )
+{
+ EFI_STATUS Status;
+
+ if (mTreeProtocol == NULL) {
+ Status = gBS->LocateProtocol (&gEfiTrEEProtocolGuid, NULL, (VOID **) &mTreeProtocol);
+ if (EFI_ERROR (Status)) {
+ //
+ // TrEE protocol is not installed. So, TPM2 is not present.
+ //
+ DEBUG ((EFI_D_ERROR, "Tpm2RequestUseTpm - TrEE - %r\n", Status));
+ return EFI_NOT_FOUND;
+ }
+ }
+ //
+ // Assume when TrEE Protocol is ready, RequestUseTpm already done.
+ //
+ return EFI_SUCCESS;
+}
+
+/**
+ This service register TPM2 device.
+
+ @param Tpm2Device TPM2 device
+
+ @retval EFI_SUCCESS This TPM2 device is registered successfully.
+ @retval EFI_UNSUPPORTED System does not support register this TPM2 device.
+ @retval EFI_ALREADY_STARTED System already register this TPM2 device.
+**/
+EFI_STATUS
+EFIAPI
+Tpm2RegisterTpm2DeviceLib (
+ IN TPM2_DEVICE_INTERFACE *Tpm2Device
+ )
+{
+ return EFI_UNSUPPORTED;
+}
diff --git a/SecurityPkg/Library/Tpm2DeviceLibTrEE/Tpm2DeviceLibTrEE.inf b/SecurityPkg/Library/Tpm2DeviceLibTrEE/Tpm2DeviceLibTrEE.inf
new file mode 100644
index 000000000..684b1f136
--- /dev/null
+++ b/SecurityPkg/Library/Tpm2DeviceLibTrEE/Tpm2DeviceLibTrEE.inf
@@ -0,0 +1,42 @@
+## @file
+# Ihis library is TPM2 TREE protocol lib.
+#
+# Copyright (c) 2013, 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.
+#
+##
+
+[Defines]
+ INF_VERSION = 0x00010005
+ BASE_NAME = Tpm2DeviceLibTrEE
+ FILE_GUID = BBCB6F85-303C-4eb9-8182-AF98D4B3020C
+ MODULE_TYPE = DXE_DRIVER
+ VERSION_STRING = 1.0
+ LIBRARY_CLASS = Tpm2DeviceLib|DXE_DRIVER DXE_RUNTIME_DRIVER DXE_SAL_DRIVER DXE_SMM_DRIVER UEFI_APPLICATION UEFI_DRIVER
+
+#
+# The following information is for reference only and not required by the build tools.
+#
+# VALID_ARCHITECTURES = IA32 X64 IPF
+#
+
+[Sources]
+ Tpm2DeviceLibTrEE.c
+
+[Packages]
+ MdePkg/MdePkg.dec
+ SecurityPkg/SecurityPkg.dec
+
+[LibraryClasses]
+ BaseLib
+ BaseMemoryLib
+ DebugLib
+ UefiBootServicesTableLib
+
+[Protocols]
+ gEfiTrEEProtocolGuid ## CONSUMES
diff --git a/SecurityPkg/SecurityPkg.dec b/SecurityPkg/SecurityPkg.dec
index 610682717..c07435e4b 100644
--- a/SecurityPkg/SecurityPkg.dec
+++ b/SecurityPkg/SecurityPkg.dec
@@ -25,7 +25,16 @@
[LibraryClasses]
## @libraryclass Definitions for common TPM commands as library API for TPM
# module use.
+ HashLib|Include/Library/HashLib.h
+ PlatformSecureLib|Include/Library/PlatformSecureLib.h
+ TcgPhysicalPresenceLib|Include/Library/TcgPhysicalPresenceLib.h
+ Tpm2CommandLib|Include/Library/Tpm2CommandLib.h
+ Tpm2DeviceLib|Include/Library/Tpm2DeviceLib.h
+ Tpm12CommandLib|Include/Library/Tpm12CommandLib.h
+ Tpm12DeviceLib|Include/Library/Tpm12DeviceLib.h
TpmCommLib|Include/Library/TpmCommLib.h
+ TpmMeasurementLib|Include/Library/TpmMeasurementLib.h
+ TrEEPhysicalPresenceLib|Include/Library/TrEEPhysicalPresenceLib.h
[Guids]
## Security package token space guid
@@ -42,6 +51,9 @@
gEfiCustomModeEnableGuid = { 0xc076ec0c, 0x7028, 0x4399, { 0xa0, 0x72, 0x71, 0xee, 0x5c, 0x44, 0x8b, 0x9f } }
# Include/Guid/AuthenticatedVariableFormat.h
+ gEfiVendorKeysNvGuid = { 0x9073e4e0, 0x60ec, 0x4b6e, { 0x99, 0x3, 0x4c, 0x22, 0x3c, 0x26, 0xf, 0x3c } }
+
+ # Include/Guid/AuthenticatedVariableFormat.h
gEfiCertDbGuid = { 0xd9bee56e, 0x75dc, 0x49d9, { 0xb4, 0xd7, 0xb5, 0x34, 0x21, 0xf, 0x63, 0x7a } }
## Include/Guid/TcgEventHob.h
@@ -71,6 +83,18 @@
## Include/Guid/SecureBootConfigHii.h
gSecureBootConfigFormSetGuid = { 0x5daf50a5, 0xea81, 0x4de2, {0x8f, 0x9b, 0xca, 0xbd, 0xa9, 0xcf, 0x5c, 0x14}}
+ ## Include/Guid/TrEEPhysicalPresenceData.h
+ gEfiTrEEPhysicalPresenceGuid = { 0xf24643c2, 0xc622, 0x494e, { 0x8a, 0xd, 0x46, 0x32, 0x57, 0x9c, 0x2d, 0x5b }}
+
+ ## Include/Guid/TpmInstance.h
+ gEfiTpmDeviceInstanceNoneGuid = { 0x00000000, 0x0000, 0x0000, { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 } }
+ gEfiTpmDeviceInstanceTpm12Guid = { 0x8b01e5b6, 0x4f19, 0x46e8, { 0xab, 0x93, 0x1c, 0x53, 0x67, 0x1b, 0x90, 0xcc } }
+ gEfiTpmDeviceInstanceTpm20DtpmGuid = { 0x286bf25a, 0xc2c3, 0x408c, { 0xb3, 0xb4, 0x25, 0xe6, 0x75, 0x8b, 0x73, 0x17 } }
+ gEfiTpmDeviceSelectedGuid = { 0x7f4158d3, 0x74d, 0x456d, { 0x8c, 0xb2, 0x1, 0xf9, 0xc8, 0xf7, 0x9d, 0xaa } }
+
+ ## Include/Guid/TrEEConfigHii.h
+ gTrEEConfigFormSetGuid = {0xc54b425f, 0xaa79, 0x48b4, { 0x98, 0x1f, 0x99, 0x8b, 0x3c, 0x4b, 0x64, 0x1c }}
+
[Ppis]
## Include/Ppi/LockPhysicalPresence.h
gPeiLockPhysicalPresencePpiGuid = { 0xef9aefe5, 0x2bd3, 0x4031, { 0xaf, 0x7d, 0x5e, 0xfe, 0x5a, 0xbb, 0x9a, 0xd } }
@@ -78,6 +102,9 @@
## Include/Ppi/TpmInitialized.h
gPeiTpmInitializedPpiGuid = { 0xe9db0d58, 0xd48d, 0x47f6, { 0x9c, 0x6e, 0x6f, 0x40, 0xe8, 0x6c, 0x7b, 0x41 }}
+ ## Include/Ppi/FirmwareVolumeInfoMeasurementExcluded.h
+ gEfiPeiFirmwareVolumeInfoMeasurementExcludedPpiGuid = { 0x6e056ff9, 0xc695, 0x4364, { 0x9e, 0x2c, 0x61, 0x26, 0xf5, 0xce, 0xea, 0xae } }
+
[PcdsFixedAtBuild]
## Pcd for OptionRom.
# Image verification policy settings:
@@ -164,3 +191,56 @@
## This PCD is used to specify the default value for physicalPresenceHWEnable bit when setting physicalPresenceLifetimeLock bit.
## If PcdPhysicalPresenceHwEnable is set to TRUE, physicalPresenceHWEnable bit will be set, else this bit will be cleared.
gEfiSecurityPkgTokenSpaceGuid.PcdPhysicalPresenceHwEnable|TRUE|BOOLEAN|0x00010005
+
+[PcdsFixedAtBuild, PcdsPatchableInModule, PcdsDynamic, PcdsDynamicEx]
+ ## This PCD indicates if debugger exists.
+ gEfiSecurityPkgTokenSpaceGuid.PcdFirmwareDebuggerInitialized|FALSE|BOOLEAN|0x00010009
+
+ ## This PCD indicates the TPM2 initializatin policy.
+ ## 0: No initialization needed - most likely used for chipset SRTM sloution, in which TPM is already initialized.
+ ## 1: Initialization needed.
+ gEfiSecurityPkgTokenSpaceGuid.PcdTpm2InitializationPolicy|1|UINT8|0x0001000A
+
+ ## This PCD indicates the TPM initializatin policy.
+ ## 0: No initialization needed - most likely used for chipset SRTM sloution, in which TPM is already initialized.
+ ## 1: Initialization needed.
+ gEfiSecurityPkgTokenSpaceGuid.PcdTpmInitializationPolicy|1|UINT8|0x0001000B
+
+ ## This PCD indicates the TPM2 SelfTest policy.
+ ## 0: No SelfTest needed - most likely used for fTPM, because it might already be tested.
+ ## 1: SelfTest needed.
+ gEfiSecurityPkgTokenSpaceGuid.PcdTpm2SelfTestPolicy|1|UINT8|0x0001000C
+
+ ## This PCD indicates the TPM2 SCRTM policy.
+ ## 0: No SCRTM needed - In this case, it is already done.
+ ## 1: SCRTM done by BIOS.
+ gEfiSecurityPkgTokenSpaceGuid.PcdTpm2ScrtmPolicy|1|UINT8|0x0001000D
+
+ ## This PCD indicates the TPM SCRTM policy.
+ ## 0: No SCRTM needed - In this case, it is already done.
+ ## 1: SCRTM done by BIOS.
+ gEfiSecurityPkgTokenSpaceGuid.PcdTpmScrtmPolicy|1|UINT8|0x0001000E
+
+ ## Guid name to identify TPM instance
+ ## TPM_DEVICE_INTERFACE_NONE means disable
+ ## TPM_DEVICE_INTERFACE_TPM12 means TPM1.2 DTPM
+ ## TPM_DEVICE_INTERFACE_DTPM2 means TPM2 DTPM
+ gEfiSecurityPkgTokenSpaceGuid.PcdTpmInstanceGuid |{ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 }|VOID*|0x0001000F
+
+ ## This PCD indicates the TPM2 Hash mask.
+ ## BIT0: SHA1
+ ## BIT1: SHA256
+ ## BIT2: SHA384
+ ## BIT3: SHA512
+ ## If this bit is set, that means this algorithm is needed to extend to PCR.
+ ## If this bit is clear, that means this algorithm is NOT needed to extend to PCR.
+ ## 0xFFFFFFFF means extend all.
+ gEfiSecurityPkgTokenSpaceGuid.PcdTpm2HashMask|0xFFFFFFFF|UINT32|0x00010010
+
+ ## This PCD indicates if BIOS auto detect TPM1.2 or dTPM2.0.
+ ## 0: No auto detection.
+ ## 1: Auto detection.
+ gEfiSecurityPkgTokenSpaceGuid.PcdTpmAutoDetection|TRUE|BOOLEAN|0x00010011
+
+ ## This PCD indicates TPM base address.
+ gEfiSecurityPkgTokenSpaceGuid.PcdTpmBaseAddress|0xFED40000|UINT64|0x00010012
diff --git a/SecurityPkg/SecurityPkg.dsc b/SecurityPkg/SecurityPkg.dsc
index 54b5b2464..ebe65b8d0 100644
--- a/SecurityPkg/SecurityPkg.dsc
+++ b/SecurityPkg/SecurityPkg.dsc
@@ -32,6 +32,7 @@
MemoryAllocationLib|MdePkg/Library/UefiMemoryAllocationLib/UefiMemoryAllocationLib.inf
PrintLib|MdePkg/Library/BasePrintLib/BasePrintLib.inf
UefiApplicationEntryPoint|MdePkg/Library/UefiApplicationEntryPoint/UefiApplicationEntryPoint.inf
+ PerformanceLib|MdePkg/Library/BasePerformanceLibNull/BasePerformanceLibNull.inf
DxeServicesLib|MdePkg/Library/DxeServicesLib/DxeServicesLib.inf
UefiDriverEntryPoint|MdePkg/Library/UefiDriverEntryPoint/UefiDriverEntryPoint.inf
@@ -51,6 +52,9 @@
PlatformSecureLib|SecurityPkg/Library/PlatformSecureLibNull/PlatformSecureLibNull.inf
TcgPhysicalPresenceLib|SecurityPkg/Library/DxeTcgPhysicalPresenceLib/DxeTcgPhysicalPresenceLib.inf
TpmMeasurementLib|SecurityPkg/Library/DxeTpmMeasurementLib/DxeTpmMeasurementLib.inf
+ Tpm12CommandLib|SecurityPkg/Library/Tpm12CommandLib/Tpm12CommandLib.inf
+ Tpm2CommandLib|SecurityPkg/Library/Tpm2CommandLib/Tpm2CommandLib.inf
+ TrEEPhysicalPresenceLib|SecurityPkg/Library/DxeTrEEPhysicalPresenceLib/DxeTrEEPhysicalPresenceLib.inf
[LibraryClasses.common.PEIM]
PeimEntryPoint|MdePkg/Library/PeimEntryPoint/PeimEntryPoint.inf
@@ -59,32 +63,60 @@
HobLib|MdePkg/Library/PeiHobLib/PeiHobLib.inf
MemoryAllocationLib|MdePkg/Library/PeiMemoryAllocationLib/PeiMemoryAllocationLib.inf
BaseCryptLib|CryptoPkg/Library/BaseCryptLib/PeiCryptLib.inf
+ HashLib|SecurityPkg/Library/HashLibBaseCryptoRouter/HashLibBaseCryptoRouterPei.inf
+ Tpm12DeviceLib|SecurityPkg/Library/Tpm12DeviceLibDTpm/Tpm12DeviceLibDTpm.inf
+ Tpm2DeviceLib|SecurityPkg/Library/Tpm2DeviceLibDTpm/Tpm2DeviceLibDTpm.inf
[LibraryClasses.common.DXE_DRIVER]
HobLib|MdePkg/Library/DxeHobLib/DxeHobLib.inf
ReportStatusCodeLib|MdeModulePkg/Library/DxeReportStatusCodeLib/DxeReportStatusCodeLib.inf
BaseCryptLib|CryptoPkg/Library/BaseCryptLib/BaseCryptLib.inf
+ HashLib|SecurityPkg/Library/HashLibBaseCryptoRouter/HashLibBaseCryptoRouterDxe.inf
+ Tpm12DeviceLib|SecurityPkg/Library/Tpm12DeviceLibTcg/Tpm12DeviceLibTcg.inf
+ Tpm2DeviceLib|SecurityPkg/Library/Tpm2DeviceLibTrEE/Tpm2DeviceLibTrEE.inf
[LibraryClasses.common.UEFI_DRIVER, LibraryClasses.common.DXE_RUNTIME_DRIVER, LibraryClasses.common.DXE_SAL_DRIVER,]
HobLib|MdePkg/Library/DxeHobLib/DxeHobLib.inf
DebugLib|MdePkg/Library/UefiDebugLibConOut/UefiDebugLibConOut.inf
+ HashLib|SecurityPkg/Library/HashLibBaseCryptoRouter/HashLibBaseCryptoRouterDxe.inf
+ Tpm12DeviceLib|SecurityPkg/Library/Tpm12DeviceLibTcg/Tpm12DeviceLibTcg.inf
+ Tpm2DeviceLib|SecurityPkg/Library/Tpm2DeviceLibTrEE/Tpm2DeviceLibTrEE.inf
[LibraryClasses.common.DXE_RUNTIME_DRIVER]
BaseCryptLib|CryptoPkg/Library/BaseCryptLib/RuntimeCryptLib.inf
+ HashLib|SecurityPkg/Library/HashLibBaseCryptoRouter/HashLibBaseCryptoRouterDxe.inf
+ Tpm12DeviceLib|SecurityPkg/Library/Tpm12DeviceLibTcg/Tpm12DeviceLibTcg.inf
+ Tpm2DeviceLib|SecurityPkg/Library/Tpm2DeviceLibTrEE/Tpm2DeviceLibTrEE.inf
[LibraryClasses.common.UEFI_DRIVER, LibraryClasses.common.UEFI_APPLICATION]
BaseCryptLib|CryptoPkg/Library/BaseCryptLib/BaseCryptLib.inf
+ HashLib|SecurityPkg/Library/HashLibBaseCryptoRouter/HashLibBaseCryptoRouterDxe.inf
+ Tpm12DeviceLib|SecurityPkg/Library/Tpm12DeviceLibTcg/Tpm12DeviceLibTcg.inf
+ Tpm2DeviceLib|SecurityPkg/Library/Tpm2DeviceLibTrEE/Tpm2DeviceLibTrEE.inf
[LibraryClasses.IPF.DXE_SAL_DRIVER]
ExtendedSalLib|MdePkg/Library/DxeRuntimeExtendedSalLib/DxeRuntimeExtendedSalLib.inf
BaseCryptLib|CryptoPkg/Library/BaseCryptLibRuntimeCryptProtocol/BaseCryptLibRuntimeCryptProtocol.inf
+ HashLib|SecurityPkg/Library/HashLibBaseCryptoRouter/HashLibBaseCryptoRouterDxe.inf
+ Tpm12DeviceLib|SecurityPkg/Library/Tpm12DeviceLibTcg/Tpm12DeviceLibTcg.inf
+ Tpm2DeviceLib|SecurityPkg/Library/Tpm2DeviceLibTrEE/Tpm2DeviceLibTrEE.inf
[LibraryClasses.common.DXE_SMM_DRIVER]
HobLib|MdePkg/Library/DxeHobLib/DxeHobLib.inf
SmmServicesTableLib|MdePkg/Library/SmmServicesTableLib/SmmServicesTableLib.inf
MemoryAllocationLib|MdePkg/Library/SmmMemoryAllocationLib/SmmMemoryAllocationLib.inf
BaseCryptLib|CryptoPkg/Library/BaseCryptLib/SmmCryptLib.inf
+ Tpm12DeviceLib|SecurityPkg/Library/Tpm12DeviceLibTcg/Tpm12DeviceLibTcg.inf
+ Tpm2DeviceLib|SecurityPkg/Library/Tpm2DeviceLibTrEE/Tpm2DeviceLibTrEE.inf
+[PcdsDynamicDefault.common.DEFAULT]
+ gEfiSecurityPkgTokenSpaceGuid.PcdTpmInstanceGuid|{0xb6, 0xe5, 0x01, 0x8b, 0x19, 0x4f, 0xe8, 0x46, 0xab, 0x93, 0x1c, 0x53, 0x67, 0x1b, 0x90, 0xcc}
+ gEfiSecurityPkgTokenSpaceGuid.PcdTpm2InitializationPolicy|1
+ gEfiSecurityPkgTokenSpaceGuid.PcdTpm2SelfTestPolicy|1
+ gEfiSecurityPkgTokenSpaceGuid.PcdTpm2ScrtmPolicy|1
+ gEfiSecurityPkgTokenSpaceGuid.PcdTpmInitializationPolicy|1
+ gEfiSecurityPkgTokenSpaceGuid.PcdTpmScrtmPolicy|1
+
[Components]
SecurityPkg/VariableAuthenticated/Pei/VariablePei.inf
SecurityPkg/Library/DxeImageVerificationLib/DxeImageVerificationLib.inf
@@ -103,10 +135,32 @@
#
SecurityPkg/Library/DxeTpmMeasureBootLib/DxeTpmMeasureBootLib.inf
SecurityPkg/Library/TpmCommLib/TpmCommLib.inf
+ SecurityPkg/Library/DxeTcgPhysicalPresenceLib/DxeTcgPhysicalPresenceLib.inf
+ SecurityPkg/Library/Tpm12CommandLib/Tpm12CommandLib.inf
+ SecurityPkg/Library/Tpm12DeviceLibDTpm/Tpm12DeviceLibDTpm.inf
+ SecurityPkg/Library/Tpm12DeviceLibTcg/Tpm12DeviceLibTcg.inf
SecurityPkg/Tcg/PhysicalPresencePei/PhysicalPresencePei.inf
SecurityPkg/Tcg/MemoryOverwriteControl/TcgMor.inf
-
+
+ #
+ # TPM2
+ #
+ SecurityPkg/Library/DxeTpm2MeasureBootLib/DxeTpm2MeasureBootLib.inf
+ SecurityPkg/Library/DxeTrEEPhysicalPresenceLib/DxeTrEEPhysicalPresenceLib.inf
+
+ SecurityPkg/Library/HashLibBaseCryptoRouter/HashLibBaseCryptoRouterDxe.inf
+ SecurityPkg/Library/HashLibBaseCryptoRouter/HashLibBaseCryptoRouterPei.inf
+
+ SecurityPkg/Library/Tpm2CommandLib/Tpm2CommandLib.inf
+ SecurityPkg/Library/Tpm2DeviceLibTrEE/Tpm2DeviceLibTrEE.inf
+ SecurityPkg/Library/Tpm2DeviceLibDTpm/Tpm2DeviceLibDTpm.inf
+ SecurityPkg/Library/Tpm2DeviceLibDTpm/Tpm2InstanceLibDTpm.inf
+ SecurityPkg/Library/Tpm2DeviceLibRouter/Tpm2DeviceLibRouterDxe.inf
+ SecurityPkg/Library/Tpm2DeviceLibRouter/Tpm2DeviceLibRouterPei.inf
+
+ SecurityPkg/Library/HashLibTpm2/HashLibTpm2.inf
+
[Components.IA32, Components.X64, Components.IPF]
SecurityPkg/UserIdentification/PwdCredentialProviderDxe/PwdCredentialProviderDxe.inf
SecurityPkg/UserIdentification/UsbCredentialProviderDxe/UsbCredentialProviderDxe.inf
@@ -123,10 +177,43 @@
PcdLib|MdePkg/Library/DxePcdLib/DxePcdLib.inf
}
+ #
+ # TPM2
+ #
+ SecurityPkg/Library/HashInstanceLibSha1/HashInstanceLibSha1.inf
+ SecurityPkg/Library/HashInstanceLibSha256/HashInstanceLibSha256.inf
+
+ SecurityPkg/Tcg/TrEEConfig/TrEEConfigPei.inf {
+ <LibraryClasses>
+ Tpm12DeviceLib|SecurityPkg/Library/Tpm12DeviceLibDTpm/Tpm12DeviceLibDTpm.inf
+ Tpm2DeviceLib|SecurityPkg/Library/Tpm2DeviceLibDTpm/Tpm2DeviceLibDTpm.inf
+ }
+ SecurityPkg/Tcg/TrEEPei/TrEEPei.inf {
+ <LibraryClasses>
+ Tpm2DeviceLib|SecurityPkg/Library/Tpm2DeviceLibRouter/Tpm2DeviceLibRouterPei.inf
+ NULL|SecurityPkg/Library/Tpm2DeviceLibDTpm/Tpm2InstanceLibDTpm.inf
+ NULL|SecurityPkg/Library/HashInstanceLibSha1/HashInstanceLibSha1.inf
+ NULL|SecurityPkg/Library/HashInstanceLibSha256/HashInstanceLibSha256.inf
+ }
+
+ SecurityPkg/Tcg/TrEEDxe/TrEEDxe.inf {
+ <LibraryClasses>
+ Tpm2DeviceLib|SecurityPkg/Library/Tpm2DeviceLibRouter/Tpm2DeviceLibRouterDxe.inf
+ NULL|SecurityPkg/Library/Tpm2DeviceLibDTpm/Tpm2InstanceLibDTpm.inf
+ NULL|SecurityPkg/Library/HashInstanceLibSha1/HashInstanceLibSha1.inf
+ NULL|SecurityPkg/Library/HashInstanceLibSha256/HashInstanceLibSha256.inf
+ PcdLib|MdePkg/Library/DxePcdLib/DxePcdLib.inf
+ }
+ SecurityPkg/Tcg/TrEEConfig/TrEEConfigDxe.inf {
+ <LibraryClasses>
+ Tpm2DeviceLib|SecurityPkg/Library/Tpm2DeviceLibTrEE/Tpm2DeviceLibTrEE.inf
+ }
+
[Components.IA32, Components.X64]
SecurityPkg/VariableAuthenticated/RuntimeDxe/VariableSmm.inf
SecurityPkg/VariableAuthenticated/RuntimeDxe/VariableSmmRuntimeDxe.inf
SecurityPkg/Tcg/TcgSmm/TcgSmm.inf
+ SecurityPkg/Tcg/TrEESmm/TrEESmm.inf
[Components.IPF]
SecurityPkg/VariableAuthenticated/EsalVariableDxeSal/EsalVariableDxeSal.inf
diff --git a/SecurityPkg/Tcg/MemoryOverwriteControl/TcgMor.inf b/SecurityPkg/Tcg/MemoryOverwriteControl/TcgMor.inf
index 6cf51b78d..1aa296b47 100644
--- a/SecurityPkg/Tcg/MemoryOverwriteControl/TcgMor.inf
+++ b/SecurityPkg/Tcg/MemoryOverwriteControl/TcgMor.inf
@@ -1,7 +1,7 @@
## @file
# Component description file for Memory Overwrite Control driver.
#
-# Copyright (c) 2009 - 2012, Intel Corporation. All rights reserved.<BR>
+# Copyright (c) 2009 - 2013, 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
@@ -47,5 +47,5 @@
[Depex]
gEfiVariableArchProtocolGuid AND
gEfiVariableWriteArchProtocolGuid AND
- gEfiTcgProtocolGuid
+ ( gEfiTcgProtocolGuid OR gEfiTrEEProtocolGuid )
diff --git a/SecurityPkg/Tcg/TcgConfigDxe/TcgConfigDriver.c b/SecurityPkg/Tcg/TcgConfigDxe/TcgConfigDriver.c
index 2d3728cdb..a9a10c9e1 100644
--- a/SecurityPkg/Tcg/TcgConfigDxe/TcgConfigDriver.c
+++ b/SecurityPkg/Tcg/TcgConfigDxe/TcgConfigDriver.c
@@ -1,7 +1,7 @@
/** @file
The module entry point for Tcg configuration module.
-Copyright (c) 2011, Intel Corporation. All rights reserved.<BR>
+Copyright (c) 2011 - 2013, 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
@@ -13,6 +13,7 @@ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
**/
#include "TcgConfigImpl.h"
+#include <Guid/TpmInstance.h>
/**
The entry point for Tcg configuration driver.
@@ -37,6 +38,11 @@ TcgConfigDriverEntryPoint (
TCG_CONFIG_PRIVATE_DATA *PrivateData;
EFI_TCG_PROTOCOL *TcgProtocol;
+ if (!CompareGuid (PcdGetPtr(PcdTpmInstanceGuid), &gEfiTpmDeviceInstanceTpm12Guid)){
+ DEBUG ((EFI_D_ERROR, "No TPM12 instance required!\n"));
+ return EFI_UNSUPPORTED;
+ }
+
Status = TisPcRequestUseTpm ((TIS_TPM_HANDLE) (UINTN) TPM_BASE_ADDRESS);
if (EFI_ERROR (Status)) {
DEBUG ((EFI_D_ERROR, "TPM not detected!\n"));
diff --git a/SecurityPkg/Tcg/TcgConfigDxe/TcgConfigDxe.inf b/SecurityPkg/Tcg/TcgConfigDxe/TcgConfigDxe.inf
index 5edd6ab4b..cdfc89c2e 100644
--- a/SecurityPkg/Tcg/TcgConfigDxe/TcgConfigDxe.inf
+++ b/SecurityPkg/Tcg/TcgConfigDxe/TcgConfigDxe.inf
@@ -1,7 +1,7 @@
## @file
# Component name for Tcg configuration module.
#
-# Copyright (c) 2011, Intel Corporation. All rights reserved.<BR>
+# Copyright (c) 2011 - 2013, 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 @@
gEfiPhysicalPresenceGuid
gEfiIfrTianoGuid
gTcgConfigFormSetGuid
+ gEfiTpmDeviceInstanceTpm12Guid
[Protocols]
gEfiHiiConfigAccessProtocolGuid ## PRODUCES
@@ -67,6 +68,7 @@
[Pcd]
gEfiSecurityPkgTokenSpaceGuid.PcdHideTpm
+ gEfiSecurityPkgTokenSpaceGuid.PcdTpmInstanceGuid
[Depex]
gEfiHiiConfigRoutingProtocolGuid AND
diff --git a/SecurityPkg/Tcg/TcgDxe/TcgDxe.c b/SecurityPkg/Tcg/TcgDxe/TcgDxe.c
index 677923091..322d72603 100644
--- a/SecurityPkg/Tcg/TcgDxe/TcgDxe.c
+++ b/SecurityPkg/Tcg/TcgDxe/TcgDxe.c
@@ -8,7 +8,7 @@ buffer overflow, integer overflow.
TcgDxePassThroughToTpm() will receive untrusted input and do basic validation.
-Copyright (c) 2005 - 2012, Intel Corporation. All rights reserved.<BR>
+Copyright (c) 2005 - 2013, 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,7 @@ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
#include <IndustryStandard/Acpi.h>
#include <IndustryStandard/PeImage.h>
#include <IndustryStandard/SmBios.h>
+#include <IndustryStandard/TcpaAcpi.h>
#include <Guid/GlobalVariable.h>
#include <Guid/SmBios.h>
@@ -31,6 +32,8 @@ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
#include <Guid/TcgEventHob.h>
#include <Guid/EventGroup.h>
#include <Guid/EventExitBootServiceFailed.h>
+#include <Guid/TpmInstance.h>
+
#include <Protocol/DevicePath.h>
#include <Protocol/TcgService.h>
#include <Protocol/AcpiTable.h>
@@ -53,38 +56,6 @@ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
#define EFI_TCG_LOG_AREA_SIZE 0x10000
-#pragma pack (1)
-
-typedef struct _EFI_TCG_CLIENT_ACPI_TABLE {
- EFI_ACPI_DESCRIPTION_HEADER Header;
- UINT16 PlatformClass;
- UINT32 Laml;
- EFI_PHYSICAL_ADDRESS Lasa;
-} EFI_TCG_CLIENT_ACPI_TABLE;
-
-typedef struct _EFI_TCG_SERVER_ACPI_TABLE {
- EFI_ACPI_DESCRIPTION_HEADER Header;
- UINT16 PlatformClass;
- UINT16 Reserved0;
- UINT64 Laml;
- EFI_PHYSICAL_ADDRESS Lasa;
- UINT16 SpecRev;
- UINT8 DeviceFlags;
- UINT8 InterruptFlags;
- UINT8 Gpe;
- UINT8 Reserved1[3];
- UINT32 GlobalSysInt;
- EFI_ACPI_3_0_GENERIC_ADDRESS_STRUCTURE BaseAddress;
- UINT32 Reserved2;
- EFI_ACPI_3_0_GENERIC_ADDRESS_STRUCTURE ConfigAddress;
- UINT8 PciSegNum;
- UINT8 PciBusNum;
- UINT8 PciDevNum;
- UINT8 PciFuncNum;
-} EFI_TCG_SERVER_ACPI_TABLE;
-
-#pragma pack ()
-
#define TCG_DXE_DATA_FROM_THIS(this) \
BASE_CR (this, TCG_DXE_DATA, TcgProtocol)
@@ -1177,6 +1148,7 @@ InstallAcpiTable (
EFI_STATUS Status;
EFI_ACPI_TABLE_PROTOCOL *AcpiTable;
UINT8 Checksum;
+ UINT64 OemTableId;
Status = gBS->LocateProtocol (&gEfiAcpiTableProtocolGuid, NULL, (VOID **)&AcpiTable);
if (EFI_ERROR (Status)) {
@@ -1184,7 +1156,12 @@ InstallAcpiTable (
}
if (PcdGet8 (PcdTpmPlatformClass) == TCG_PLATFORM_TYPE_CLIENT) {
-
+ CopyMem (mTcgClientAcpiTemplate.Header.OemId, PcdGetPtr (PcdAcpiDefaultOemId), sizeof (mTcgClientAcpiTemplate.Header.OemId));
+ OemTableId = PcdGet64 (PcdAcpiDefaultOemTableId);
+ CopyMem (&mTcgClientAcpiTemplate.Header.OemTableId, &OemTableId, sizeof (UINT64));
+ mTcgClientAcpiTemplate.Header.OemRevision = PcdGet32 (PcdAcpiDefaultOemRevision);
+ mTcgClientAcpiTemplate.Header.CreatorId = PcdGet32 (PcdAcpiDefaultCreatorId);
+ mTcgClientAcpiTemplate.Header.CreatorRevision = PcdGet32 (PcdAcpiDefaultCreatorRevision);
//
// The ACPI table must be checksumed before calling the InstallAcpiTable()
// service of the ACPI table protocol to install it.
@@ -1199,7 +1176,12 @@ InstallAcpiTable (
&TableKey
);
} else {
-
+ CopyMem (mTcgServerAcpiTemplate.Header.OemId, PcdGetPtr (PcdAcpiDefaultOemId), sizeof (mTcgServerAcpiTemplate.Header.OemId));
+ OemTableId = PcdGet64 (PcdAcpiDefaultOemTableId);
+ CopyMem (&mTcgServerAcpiTemplate.Header.OemTableId, &OemTableId, sizeof (UINT64));
+ mTcgServerAcpiTemplate.Header.OemRevision = PcdGet32 (PcdAcpiDefaultOemRevision);
+ mTcgServerAcpiTemplate.Header.CreatorId = PcdGet32 (PcdAcpiDefaultCreatorId);
+ mTcgServerAcpiTemplate.Header.CreatorRevision = PcdGet32 (PcdAcpiDefaultCreatorRevision);
//
// The ACPI table must be checksumed before calling the InstallAcpiTable()
// service of the ACPI table protocol to install it.
@@ -1333,6 +1315,11 @@ DriverEntry (
EFI_EVENT Event;
VOID *Registration;
+ if (!CompareGuid (PcdGetPtr(PcdTpmInstanceGuid), &gEfiTpmDeviceInstanceTpm12Guid)){
+ DEBUG ((EFI_D_ERROR, "No TPM12 instance required!\n"));
+ return EFI_UNSUPPORTED;
+ }
+
mTcgDxeData.TpmHandle = (TIS_TPM_HANDLE)(UINTN)TPM_BASE_ADDRESS;
Status = TisPcRequestUseTpm (mTcgDxeData.TpmHandle);
if (EFI_ERROR (Status)) {
diff --git a/SecurityPkg/Tcg/TcgDxe/TcgDxe.inf b/SecurityPkg/Tcg/TcgDxe/TcgDxe.inf
index ba53d328d..40984291f 100644
--- a/SecurityPkg/Tcg/TcgDxe/TcgDxe.inf
+++ b/SecurityPkg/Tcg/TcgDxe/TcgDxe.inf
@@ -2,7 +2,7 @@
# Component file for module TcgDxe.
# This module will produce TCG protocol and measure boot environment.
#
-# Copyright (c) 2006 - 2010, Intel Corporation. All rights reserved.<BR>
+# Copyright (c) 2006 - 2013, 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 @@
TpmCommLib
PrintLib
UefiLib
+ PcdLib
[Guids]
gEfiSmbiosTableGuid # ALWAYS_CONSUMED
@@ -57,6 +58,7 @@
gEfiEventReadyToBootGuid
gEfiEventExitBootServicesGuid
gEventExitBootServicesFailedGuid # ALWAYS_CONSUMED
+ gEfiTpmDeviceInstanceTpm12Guid
[Protocols]
gEfiTcgProtocolGuid ## PRODUCES
@@ -66,6 +68,12 @@
[Pcd]
gEfiSecurityPkgTokenSpaceGuid.PcdTpmPlatformClass
+ gEfiSecurityPkgTokenSpaceGuid.PcdTpmInstanceGuid
+ gEfiMdeModulePkgTokenSpaceGuid.PcdAcpiDefaultOemId
+ gEfiMdeModulePkgTokenSpaceGuid.PcdAcpiDefaultOemTableId
+ gEfiMdeModulePkgTokenSpaceGuid.PcdAcpiDefaultOemRevision
+ gEfiMdeModulePkgTokenSpaceGuid.PcdAcpiDefaultCreatorId
+ gEfiMdeModulePkgTokenSpaceGuid.PcdAcpiDefaultCreatorRevision
[Depex]
TRUE
diff --git a/SecurityPkg/Tcg/TcgPei/TcgPei.c b/SecurityPkg/Tcg/TcgPei/TcgPei.c
index 350e60e56..ae905f765 100644
--- a/SecurityPkg/Tcg/TcgPei/TcgPei.c
+++ b/SecurityPkg/Tcg/TcgPei/TcgPei.c
@@ -1,7 +1,7 @@
/** @file
Initialize TPM device and measure FVs before handing off control to DXE.
-Copyright (c) 2005 - 2012, Intel Corporation. All rights reserved.<BR>
+Copyright (c) 2005 - 2013, 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,13 +17,16 @@ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
#include <IndustryStandard/Tpm12.h>
#include <IndustryStandard/UefiTcgPlatform.h>
#include <Ppi/FirmwareVolumeInfo.h>
+#include <Ppi/FirmwareVolumeInfo2.h>
#include <Ppi/LockPhysicalPresence.h>
#include <Ppi/TpmInitialized.h>
#include <Ppi/FirmwareVolume.h>
#include <Ppi/EndOfPeiPhase.h>
+#include <Ppi/FirmwareVolumeInfoMeasurementExcluded.h>
#include <Guid/TcgEventHob.h>
#include <Guid/MeasuredFvHob.h>
+#include <Guid/TpmInstance.h>
#include <Library/DebugLib.h>
#include <Library/BaseMemoryLib.h>
@@ -51,6 +54,8 @@ UINT32 mMeasuredBaseFvIndex = 0;
EFI_PLATFORM_FIRMWARE_BLOB mMeasuredChildFvInfo[FixedPcdGet32 (PcdPeiCoreMaxFvSupported)];
UINT32 mMeasuredChildFvIndex = 0;
+EFI_PEI_FIRMWARE_VOLUME_INFO_MEASUREMENT_EXCLUDED_PPI *mMeasurementExcludedFvPpi;
+
/**
Lock physical presence if needed.
@@ -119,6 +124,11 @@ EFI_PEI_NOTIFY_DESCRIPTOR mNotifyList[] = {
FirmwareVolmeInfoPpiNotifyCallback
},
{
+ EFI_PEI_PPI_DESCRIPTOR_NOTIFY_CALLBACK,
+ &gEfiPeiFirmwareVolumeInfo2PpiGuid,
+ FirmwareVolmeInfoPpiNotifyCallback
+ },
+ {
(EFI_PEI_PPI_DESCRIPTOR_NOTIFY_CALLBACK | EFI_PEI_PPI_DESCRIPTOR_TERMINATE_LIST),
&gEfiEndOfPeiSignalPpiGuid,
EndofPeiSignalNotifyCallBack
@@ -312,6 +322,19 @@ MeasureFvImage (
TpmHandle = (TIS_TPM_HANDLE) (UINTN) TPM_BASE_ADDRESS;
//
+ // Check if it is in Excluded FV list
+ //
+ if (mMeasurementExcludedFvPpi != NULL) {
+ for (Index = 0; Index < mMeasurementExcludedFvPpi->Count; Index ++) {
+ if (mMeasurementExcludedFvPpi->Fv[Index].FvBase == FvBase) {
+ DEBUG ((DEBUG_INFO, "The FV which is excluded by TcgPei starts at: 0x%x\n", FvBase));
+ DEBUG ((DEBUG_INFO, "The FV which is excluded by TcgPei has the size: 0x%x\n", FvLength));
+ return EFI_SUCCESS;
+ }
+ }
+ }
+
+ //
// Check whether FV is in the measured FV list.
//
for (Index = 0; Index < mMeasuredBaseFvIndex; Index ++) {
@@ -627,6 +650,14 @@ PeimEntryMP (
EFI_STATUS Status;
TIS_TPM_HANDLE TpmHandle;
+ Status = PeiServicesLocatePpi (
+ &gEfiPeiFirmwareVolumeInfoMeasurementExcludedPpiGuid,
+ 0,
+ NULL,
+ (VOID**)&mMeasurementExcludedFvPpi
+ );
+ // Do not check status, because it is optional
+
TpmHandle = (TIS_TPM_HANDLE)(UINTN)TPM_BASE_ADDRESS;
Status = TisPcRequestUseTpm ((TIS_PC_REGISTERS_PTR)TpmHandle);
if (EFI_ERROR (Status)) {
@@ -634,8 +665,10 @@ PeimEntryMP (
}
if (IsTpmUsable (PeiServices, TpmHandle)) {
- Status = MeasureCRTMVersion (PeiServices, TpmHandle);
- ASSERT_EFI_ERROR (Status);
+ if (PcdGet8 (PcdTpmScrtmPolicy) == 1) {
+ Status = MeasureCRTMVersion (PeiServices, TpmHandle);
+ ASSERT_EFI_ERROR (Status);
+ }
Status = MeasureMainBios (PeiServices, TpmHandle);
}
@@ -673,6 +706,11 @@ PeimEntryMA (
EFI_BOOT_MODE BootMode;
TIS_TPM_HANDLE TpmHandle;
+ if (!CompareGuid (PcdGetPtr(PcdTpmInstanceGuid), &gEfiTpmDeviceInstanceTpm12Guid)){
+ DEBUG ((EFI_D_ERROR, "No TPM12 instance required!\n"));
+ return EFI_UNSUPPORTED;
+ }
+
if (PcdGetBool (PcdHideTpmSupport) && PcdGetBool (PcdHideTpm)) {
return EFI_UNSUPPORTED;
}
@@ -703,9 +741,11 @@ PeimEntryMA (
return Status;
}
- Status = TpmCommStartup ((EFI_PEI_SERVICES**)PeiServices, TpmHandle, BootMode);
- if (EFI_ERROR (Status) ) {
- return Status;
+ if (PcdGet8 (PcdTpmInitializationPolicy) == 1) {
+ Status = TpmCommStartup ((EFI_PEI_SERVICES**)PeiServices, TpmHandle, BootMode);
+ if (EFI_ERROR (Status) ) {
+ return Status;
+ }
}
//
diff --git a/SecurityPkg/Tcg/TcgPei/TcgPei.inf b/SecurityPkg/Tcg/TcgPei/TcgPei.inf
index 48d4efce5..48a3e6436 100644
--- a/SecurityPkg/Tcg/TcgPei/TcgPei.inf
+++ b/SecurityPkg/Tcg/TcgPei/TcgPei.inf
@@ -1,7 +1,7 @@
## @file
# This module will initialize TPM device and measure FVs in PEI phase.
#
-# Copyright (c) 2006 - 2012, Intel Corporation. All rights reserved.<BR>
+# Copyright (c) 2006 - 2013, 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
@@ -52,10 +52,13 @@
[Guids]
gTcgEventEntryHobGuid
gMeasuredFvHobGuid
+ gEfiTpmDeviceInstanceTpm12Guid
[Ppis]
gPeiLockPhysicalPresencePpiGuid
gEfiPeiFirmwareVolumeInfoPpiGuid
+ gEfiPeiFirmwareVolumeInfo2PpiGuid
+ gEfiPeiFirmwareVolumeInfoMeasurementExcludedPpiGuid
gPeiTpmInitializedPpiGuid
gEfiEndOfPeiSignalPpiGuid
@@ -65,6 +68,9 @@
gEfiSecurityPkgTokenSpaceGuid.PcdPhysicalPresenceCmdEnable
gEfiSecurityPkgTokenSpaceGuid.PcdPhysicalPresenceHwEnable
gEfiMdeModulePkgTokenSpaceGuid.PcdFirmwareVersionString ## CONSUMES
+ gEfiSecurityPkgTokenSpaceGuid.PcdTpmInstanceGuid
+ gEfiSecurityPkgTokenSpaceGuid.PcdTpmInitializationPolicy
+ gEfiSecurityPkgTokenSpaceGuid.PcdTpmScrtmPolicy
[FixedPcd]
gEfiSecurityPkgTokenSpaceGuid.PcdHideTpmSupport
@@ -72,4 +78,5 @@
[Depex]
gEfiPeiMasterBootModePpiGuid AND
- gEfiPeiReadOnlyVariable2PpiGuid
+ gEfiPeiReadOnlyVariable2PpiGuid AND
+ gEfiTpmDeviceSelectedGuid
diff --git a/SecurityPkg/Tcg/TcgSmm/TcgSmm.c b/SecurityPkg/Tcg/TcgSmm/TcgSmm.c
index 97cd916d0..045c1846f 100644
--- a/SecurityPkg/Tcg/TcgSmm/TcgSmm.c
+++ b/SecurityPkg/Tcg/TcgSmm/TcgSmm.c
@@ -339,6 +339,7 @@ PublishAcpiTable (
ASSERT (Table->OemTableId == SIGNATURE_64 ('T', 'c', 'g', 'T', 'a', 'b', 'l', 'e'));
+ CopyMem (Table->OemId, PcdGetPtr (PcdAcpiDefaultOemId), sizeof (Table->OemId) );
mTcgNvs = AssignOpRegion (Table, SIGNATURE_32 ('T', 'N', 'V', 'S'), (UINT16) sizeof (TCG_NVS));
ASSERT (mTcgNvs != NULL);
@@ -385,6 +386,11 @@ InitializeTcgSmm (
EFI_SMM_SW_REGISTER_CONTEXT SwContext;
EFI_HANDLE SwHandle;
+ if (!CompareGuid (PcdGetPtr(PcdTpmInstanceGuid), &gEfiTpmDeviceInstanceTpm12Guid)){
+ DEBUG ((EFI_D_ERROR, "No TPM12 instance required!\n"));
+ return EFI_UNSUPPORTED;
+ }
+
Status = PublishAcpiTable ();
ASSERT_EFI_ERROR (Status);
diff --git a/SecurityPkg/Tcg/TcgSmm/TcgSmm.h b/SecurityPkg/Tcg/TcgSmm/TcgSmm.h
index b03e49d6c..eee8bc3d7 100644
--- a/SecurityPkg/Tcg/TcgSmm/TcgSmm.h
+++ b/SecurityPkg/Tcg/TcgSmm/TcgSmm.h
@@ -1,7 +1,7 @@
/** @file
The header file for TCG SMM driver.
-Copyright (c) 2012, Intel Corporation. All rights reserved.<BR>
+Copyright (c) 2012 - 2013, 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,7 @@ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
#include <Guid/PhysicalPresenceData.h>
#include <Guid/MemoryOverwriteControl.h>
+#include <Guid/TpmInstance.h>
#include <Protocol/SmmSwDispatch2.h>
#include <Protocol/AcpiTable.h>
@@ -34,6 +35,7 @@ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
#include <Library/UefiBootServicesTableLib.h>
#include <Library/DxeServicesLib.h>
#include <Library/TpmMeasurementLib.h>
+#include <Library/PcdLib.h>
#pragma pack(1)
typedef struct {
diff --git a/SecurityPkg/Tcg/TcgSmm/TcgSmm.inf b/SecurityPkg/Tcg/TcgSmm/TcgSmm.inf
index ff20a4319..5a862b41b 100644
--- a/SecurityPkg/Tcg/TcgSmm/TcgSmm.inf
+++ b/SecurityPkg/Tcg/TcgSmm/TcgSmm.inf
@@ -7,7 +7,7 @@
# This driver will have external input - variable and ACPINvs data in SMM mode.
# This external input must be validated carefully to avoid security issue.
#
-# Copyright (c) 2011 - 2012, Intel Corporation. All rights reserved.<BR>
+# Copyright (c) 2011 - 2013, 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,16 +45,22 @@
DebugLib
DxeServicesLib
TpmMeasurementLib
+ PcdLib
[Guids]
gEfiPhysicalPresenceGuid
gEfiMemoryOverwriteControlDataGuid
+ gEfiTpmDeviceInstanceTpm12Guid
[Protocols]
gEfiSmmSwDispatch2ProtocolGuid # PROTOCOL ALWAYS_CONSUMED
gEfiSmmVariableProtocolGuid # PROTOCOL ALWAYS_CONSUMED
gEfiAcpiTableProtocolGuid # PROTOCOL ALWAYS_CONSUMED
+[Pcd]
+ gEfiSecurityPkgTokenSpaceGuid.PcdTpmInstanceGuid
+ gEfiMdeModulePkgTokenSpaceGuid.PcdAcpiDefaultOemId
+
[Depex]
gEfiAcpiTableProtocolGuid AND
gEfiSmmSwDispatch2ProtocolGuid AND
diff --git a/SecurityPkg/Tcg/TcgSmm/Tpm.asl b/SecurityPkg/Tcg/TcgSmm/Tpm.asl
index 6dafa0277..b90288f4a 100644
--- a/SecurityPkg/Tcg/TcgSmm/Tpm.asl
+++ b/SecurityPkg/Tcg/TcgSmm/Tpm.asl
@@ -2,7 +2,7 @@
The TPM definition block in ACPI table for physical presence
and MemoryClear.
-Copyright (c) 2011 - 2012, Intel Corporation. All rights reserved.<BR>
+Copyright (c) 2011 - 2013, 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,7 +17,7 @@ DefinitionBlock (
"Tpm.aml",
"SSDT",
1,
- "Intel_",
+ "INTEL ",
"TcgTable",
0x1000
)
diff --git a/SecurityPkg/Tcg/TrEEConfig/TpmDetection.c b/SecurityPkg/Tcg/TrEEConfig/TpmDetection.c
new file mode 100644
index 000000000..b8aab1ffd
--- /dev/null
+++ b/SecurityPkg/Tcg/TrEEConfig/TpmDetection.c
@@ -0,0 +1,107 @@
+/** @file
+ TPM1.2/dTPM2.0 auto detection.
+
+Copyright (c) 2013, 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.
+
+**/
+
+
+#include <PiPei.h>
+
+#include <Library/BaseLib.h>
+#include <Library/BaseMemoryLib.h>
+#include <Library/IoLib.h>
+#include <Library/DebugLib.h>
+#include <Library/PeiServicesLib.h>
+#include <Library/PcdLib.h>
+#include <Library/Tpm12DeviceLib.h>
+#include <Library/Tpm12CommandLib.h>
+#include <IndustryStandard/Tpm12.h>
+
+#include "TrEEConfigNvData.h"
+
+/**
+ This routine return if dTPM (1.2 or 2.0) present.
+
+ @retval TRUE dTPM present
+ @retval FALSE dTPM not present
+**/
+BOOLEAN
+IsDtpmPresent (
+ VOID
+ )
+{
+ UINT8 RegRead;
+
+ RegRead = MmioRead8 ((UINTN)PcdGet64 (PcdTpmBaseAddress));
+ if (RegRead == 0xFF) {
+ DEBUG ((EFI_D_ERROR, "DetectTpmDevice: Dtpm not present\n"));
+ return FALSE;
+ } else {
+ DEBUG ((EFI_D_ERROR, "DetectTpmDevice: Dtpm present\n"));
+ return TRUE;
+ }
+}
+
+/**
+ This routine check both SetupVariable and real TPM device, and return final TpmDevice configuration.
+
+ @param SetupTpmDevice TpmDevice configuration in setup driver
+
+ @return TpmDevice configuration
+**/
+UINT8
+DetectTpmDevice (
+ IN UINT8 SetupTpmDevice
+ )
+{
+ EFI_STATUS Status;
+ EFI_BOOT_MODE BootMode;
+
+ Status = PeiServicesGetBootMode (&BootMode);
+ ASSERT_EFI_ERROR (Status);
+
+ //
+ // In S3, we rely on Setup option, because we save to Setup in normal boot.
+ //
+ if (BootMode == BOOT_ON_S3_RESUME) {
+ DEBUG ((EFI_D_ERROR, "DetectTpmDevice: S3 mode\n"));
+ return SetupTpmDevice;
+ }
+
+ if (PcdGetBool (PcdHideTpmSupport) && PcdGetBool (PcdHideTpm)) {
+ DEBUG ((EFI_D_ERROR, "DetectTpmDevice: Tpm is hide\n"));
+ return TPM_DEVICE_NULL;
+ }
+
+ DEBUG ((EFI_D_ERROR, "DetectTpmDevice:\n"));
+ if ((!IsDtpmPresent ()) || (SetupTpmDevice == TPM_DEVICE_NULL)) {
+ // dTPM not available
+ return TPM_DEVICE_NULL;
+ }
+
+ // dTPM available and not disabled by setup
+ // We need check if it is TPM1.2 or TPM2.0
+ // So try TPM1.2 command at first
+
+ Status = Tpm12RequestUseTpm ();
+ if (EFI_ERROR (Status)) {
+ return TPM_DEVICE_2_0_DTPM;
+ }
+
+ Status = Tpm12Startup (TPM_ST_CLEAR);
+ if (EFI_ERROR (Status)) {
+ return TPM_DEVICE_2_0_DTPM;
+ }
+
+ // NO initialization needed again.
+ PcdSet8 (PcdTpmInitializationPolicy, 0);
+ return TPM_DEVICE_1_2;
+}
diff --git a/SecurityPkg/Tcg/TrEEConfig/TrEEConfig.vfr b/SecurityPkg/Tcg/TrEEConfig/TrEEConfig.vfr
new file mode 100644
index 000000000..74e236319
--- /dev/null
+++ b/SecurityPkg/Tcg/TrEEConfig/TrEEConfig.vfr
@@ -0,0 +1,67 @@
+/** @file
+ VFR file used by the TREE configuration component.
+
+Copyright (c) 2013, 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.
+
+**/
+
+#include "TrEEConfigNvData.h"
+
+formset
+ guid = TREE_CONFIG_FORM_SET_GUID,
+ title = STRING_TOKEN(STR_TREE_TITLE),
+ help = STRING_TOKEN(STR_TREE_HELP),
+ classguid = EFI_HII_PLATFORM_SETUP_FORMSET_GUID,
+
+ varstore TREE_CONFIGURATION,
+ varid = TREE_CONFIGURATION_VARSTORE_ID,
+ name = TREE_CONFIGURATION,
+ guid = TREE_CONFIG_FORM_SET_GUID;
+
+ form formid = TREE_CONFIGURATION_FORM_ID,
+ title = STRING_TOKEN(STR_TREE_TITLE);
+
+ subtitle text = STRING_TOKEN(STR_NULL);
+
+ text
+ help = STRING_TOKEN(STR_TREE_DEVICE_STATE_HELP),
+ text = STRING_TOKEN(STR_TREE_DEVICE_STATE_PROMPT),
+ text = STRING_TOKEN(STR_TREE_DEVICE_STATE_CONTENT);
+
+ oneof varid = TREE_CONFIGURATION.TpmDevice,
+ questionid = KEY_TPM_DEVICE,
+ prompt = STRING_TOKEN(STR_TREE_DEVICE_PROMPT),
+ help = STRING_TOKEN(STR_TREE_DEVICE_HELP),
+ flags = INTERACTIVE,
+ option text = STRING_TOKEN(STR_TREE_TPM_DISABLE), value = TPM_DEVICE_NULL, flags = RESET_REQUIRED;
+ option text = STRING_TOKEN(STR_TREE_TPM_1_2), value = TPM_DEVICE_1_2, flags = DEFAULT | MANUFACTURING | RESET_REQUIRED;
+ option text = STRING_TOKEN(STR_TREE_TPM_2_0_DTPM), value = TPM_DEVICE_2_0_DTPM, flags = RESET_REQUIRED;
+ endoneof;
+
+ subtitle text = STRING_TOKEN(STR_NULL);
+
+ suppressif ideqvallist TREE_CONFIGURATION.TpmDevice == TPM_DEVICE_NULL TPM_DEVICE_1_2;
+
+ subtitle text = STRING_TOKEN(STR_NULL);
+ subtitle text = STRING_TOKEN(STR_TREE_PP_OPERATION);
+
+ oneof varid = TREE_CONFIGURATION.Tpm2Operation,
+ prompt = STRING_TOKEN(STR_TREE_OPERATION),
+ help = STRING_TOKEN(STR_TREE_OPERATION_HELP),
+ flags = INTERACTIVE,
+ option text = STRING_TOKEN(STR_TREE_NO_ACTION), value = TREE_PHYSICAL_PRESENCE_NO_ACTION, flags = DEFAULT | MANUFACTURING | RESET_REQUIRED;
+ option text = STRING_TOKEN(STR_TREE_CLEAR), value = TREE_PHYSICAL_PRESENCE_CLEAR_CONTROL_CLEAR, flags = RESET_REQUIRED;
+ endoneof;
+
+ endif;
+
+ endform;
+
+endformset;
diff --git a/SecurityPkg/Tcg/TrEEConfig/TrEEConfigDriver.c b/SecurityPkg/Tcg/TrEEConfig/TrEEConfigDriver.c
new file mode 100644
index 000000000..f3c8e5f65
--- /dev/null
+++ b/SecurityPkg/Tcg/TrEEConfig/TrEEConfigDriver.c
@@ -0,0 +1,171 @@
+/** @file
+ The module entry point for TrEE configuration module.
+
+Copyright (c) 2013, 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.
+
+**/
+
+#include "TrEEConfigImpl.h"
+
+extern TPM_INSTANCE_ID mTpmInstanceId[TPM_DEVICE_MAX + 1];
+
+/**
+ The entry point for TrEE configuration driver.
+
+ @param[in] ImageHandle The image handle of the driver.
+ @param[in] SystemTable The system table.
+
+ @retval EFI_ALREADY_STARTED The driver already exists in system.
+ @retval EFI_OUT_OF_RESOURCES Fail to execute entry point due to lack of resources.
+ @retval EFI_SUCCES All the related protocols are installed on the driver.
+ @retval Others Fail to install protocols as indicated.
+
+**/
+EFI_STATUS
+EFIAPI
+TrEEConfigDriverEntryPoint (
+ IN EFI_HANDLE ImageHandle,
+ IN EFI_SYSTEM_TABLE *SystemTable
+ )
+{
+ EFI_STATUS Status;
+ TREE_CONFIG_PRIVATE_DATA *PrivateData;
+ TREE_CONFIGURATION TrEEConfiguration;
+ UINTN Index;
+ UINTN DataSize;
+
+ Status = gBS->OpenProtocol (
+ ImageHandle,
+ &gEfiCallerIdGuid,
+ NULL,
+ ImageHandle,
+ ImageHandle,
+ EFI_OPEN_PROTOCOL_TEST_PROTOCOL
+ );
+ if (!EFI_ERROR (Status)) {
+ return EFI_ALREADY_STARTED;
+ }
+
+ //
+ // Create a private data structure.
+ //
+ PrivateData = AllocateCopyPool (sizeof (TREE_CONFIG_PRIVATE_DATA), &mTrEEConfigPrivateDateTemplate);
+ ASSERT (PrivateData != NULL);
+
+ //
+ // Install private GUID.
+ //
+ Status = gBS->InstallMultipleProtocolInterfaces (
+ &ImageHandle,
+ &gEfiCallerIdGuid,
+ PrivateData,
+ NULL
+ );
+ ASSERT_EFI_ERROR (Status);
+
+ DataSize = sizeof(TrEEConfiguration);
+ Status = gRT->GetVariable (
+ TREE_STORAGE_NAME,
+ &gTrEEConfigFormSetGuid,
+ NULL,
+ &DataSize,
+ &TrEEConfiguration
+ );
+ if (EFI_ERROR (Status)) {
+ }
+ //
+ // We should always reinit PP request.
+ //
+ TrEEConfiguration.Tpm2Operation = TREE_PHYSICAL_PRESENCE_NO_ACTION;
+
+ //
+ // Sync data from PCD to variable, so that we do not need detect again in S3 phase.
+ //
+
+ //
+ // Get data from PCD to make sure data consistant - platform driver is suppose to construct this PCD accroding to Variable
+ //
+ for (Index = 0; Index < sizeof(mTpmInstanceId)/sizeof(mTpmInstanceId[0]); Index++) {
+ if (CompareGuid (PcdGetPtr(PcdTpmInstanceGuid), &mTpmInstanceId[Index].TpmInstanceGuid)) {
+ TrEEConfiguration.TpmDevice = mTpmInstanceId[Index].TpmDevice;
+ break;
+ }
+ }
+
+ //
+ // Save to variable so platform driver can get it.
+ //
+ Status = gRT->SetVariable (
+ TREE_STORAGE_NAME,
+ &gTrEEConfigFormSetGuid,
+ EFI_VARIABLE_NON_VOLATILE | EFI_VARIABLE_BOOTSERVICE_ACCESS | EFI_VARIABLE_RUNTIME_ACCESS,
+ sizeof(TrEEConfiguration),
+ &TrEEConfiguration
+ );
+ ASSERT_EFI_ERROR (Status);
+
+ //
+ // Install TrEE configuration form
+ //
+ Status = InstallTrEEConfigForm (PrivateData);
+ if (EFI_ERROR (Status)) {
+ goto ErrorExit;
+ }
+
+ return EFI_SUCCESS;
+
+ErrorExit:
+ if (PrivateData != NULL) {
+ UninstallTrEEConfigForm (PrivateData);
+ }
+
+ return Status;
+}
+
+/**
+ Unload the TrEE configuration form.
+
+ @param[in] ImageHandle The driver's image handle.
+
+ @retval EFI_SUCCESS The TrEE configuration form is unloaded.
+ @retval Others Failed to unload the form.
+
+**/
+EFI_STATUS
+EFIAPI
+TrEEConfigDriverUnload (
+ IN EFI_HANDLE ImageHandle
+ )
+{
+ EFI_STATUS Status;
+ TREE_CONFIG_PRIVATE_DATA *PrivateData;
+
+ Status = gBS->HandleProtocol (
+ ImageHandle,
+ &gEfiCallerIdGuid,
+ (VOID **) &PrivateData
+ );
+ if (EFI_ERROR (Status)) {
+ return Status;
+ }
+
+ ASSERT (PrivateData->Signature == TREE_CONFIG_PRIVATE_DATA_SIGNATURE);
+
+ gBS->UninstallMultipleProtocolInterfaces (
+ &ImageHandle,
+ &gEfiCallerIdGuid,
+ PrivateData,
+ NULL
+ );
+
+ UninstallTrEEConfigForm (PrivateData);
+
+ return EFI_SUCCESS;
+}
diff --git a/SecurityPkg/Tcg/TrEEConfig/TrEEConfigDxe.inf b/SecurityPkg/Tcg/TrEEConfig/TrEEConfigDxe.inf
new file mode 100644
index 000000000..0878fb651
--- /dev/null
+++ b/SecurityPkg/Tcg/TrEEConfig/TrEEConfigDxe.inf
@@ -0,0 +1,74 @@
+## @file
+# Component name for TrEE configuration module.
+# NOTE: This module is only for reference only, each platform should have its own setup page.
+#
+# Copyright (c) 2013, 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.
+#
+##
+
+[Defines]
+ INF_VERSION = 0x00010005
+ BASE_NAME = TrEEConfigDxe
+ FILE_GUID = 3141FD4D-EA02-4a70-9BCE-97EE837319AC
+ MODULE_TYPE = DXE_DRIVER
+ VERSION_STRING = 1.0
+ ENTRY_POINT = TrEEConfigDriverEntryPoint
+ UNLOAD_IMAGE = TrEEConfigDriverUnload
+
+#
+# VALID_ARCHITECTURES = IA32 X64 IPF EBC
+#
+
+[Sources]
+ TrEEConfigDriver.c
+ TrEEConfigImpl.c
+ TrEEConfigImpl.h
+ TrEEConfig.vfr
+ TrEEConfigStrings.uni
+ TrEEConfigNvData.h
+
+[Packages]
+ MdePkg/MdePkg.dec
+ MdeModulePkg/MdeModulePkg.dec
+ SecurityPkg/SecurityPkg.dec
+
+[LibraryClasses]
+ BaseLib
+ BaseMemoryLib
+ MemoryAllocationLib
+ UefiLib
+ UefiBootServicesTableLib
+ UefiRuntimeServicesTableLib
+ UefiDriverEntryPoint
+ UefiHiiServicesLib
+ DebugLib
+ HiiLib
+ PcdLib
+ PrintLib
+ Tpm2DeviceLib
+ Tpm12DeviceLib
+ Tpm2CommandLib
+
+[Guids]
+ gEfiTrEEPhysicalPresenceGuid
+ gTrEEConfigFormSetGuid
+
+[Protocols]
+ gEfiHiiConfigAccessProtocolGuid ## PRODUCES
+ gEfiHiiConfigRoutingProtocolGuid ## CONSUMES
+
+[Pcd]
+ gEfiSecurityPkgTokenSpaceGuid.PcdTpmInstanceGuid
+
+[Depex]
+ gEfiTrEEProtocolGuid AND
+ gEfiHiiConfigRoutingProtocolGuid AND
+ gEfiHiiDatabaseProtocolGuid AND
+ gEfiVariableArchProtocolGuid AND
+ gEfiVariableWriteArchProtocolGuid \ No newline at end of file
diff --git a/SecurityPkg/Tcg/TrEEConfig/TrEEConfigImpl.c b/SecurityPkg/Tcg/TrEEConfig/TrEEConfigImpl.c
new file mode 100644
index 000000000..41bafa286
--- /dev/null
+++ b/SecurityPkg/Tcg/TrEEConfig/TrEEConfigImpl.c
@@ -0,0 +1,454 @@
+/** @file
+ HII Config Access protocol implementation of TREE configuration module.
+ NOTE: This module is only for reference only, each platform should have its own setup page.
+
+Copyright (c) 2013, 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.
+
+**/
+
+#include "TrEEConfigImpl.h"
+#include <Library/PcdLib.h>
+#include <Library/Tpm2CommandLib.h>
+#include <Guid/TpmInstance.h>
+
+TPM_INSTANCE_ID mTpmInstanceId[TPM_DEVICE_MAX + 1] = TPM_INSTANCE_ID_LIST;
+
+TREE_CONFIG_PRIVATE_DATA mTrEEConfigPrivateDateTemplate = {
+ TREE_CONFIG_PRIVATE_DATA_SIGNATURE,
+ {
+ TrEEExtractConfig,
+ TrEERouteConfig,
+ TrEECallback
+ }
+};
+
+HII_VENDOR_DEVICE_PATH mTrEEHiiVendorDevicePath = {
+ {
+ {
+ HARDWARE_DEVICE_PATH,
+ HW_VENDOR_DP,
+ {
+ (UINT8) (sizeof (VENDOR_DEVICE_PATH)),
+ (UINT8) ((sizeof (VENDOR_DEVICE_PATH)) >> 8)
+ }
+ },
+ TREE_CONFIG_FORM_SET_GUID
+ },
+ {
+ END_DEVICE_PATH_TYPE,
+ END_ENTIRE_DEVICE_PATH_SUBTYPE,
+ {
+ (UINT8) (END_DEVICE_PATH_LENGTH),
+ (UINT8) ((END_DEVICE_PATH_LENGTH) >> 8)
+ }
+ }
+};
+
+/**
+ This function allows a caller to extract the current configuration for one
+ or more named elements from the target driver.
+
+ @param[in] This Points to the EFI_HII_CONFIG_ACCESS_PROTOCOL.
+ @param[in] Request A null-terminated Unicode string in
+ <ConfigRequest> format.
+ @param[out] Progress On return, points to a character in the Request
+ string. Points to the string's null terminator if
+ request was successful. Points to the most recent
+ '&' before the first failing name/value pair (or
+ the beginning of the string if the failure is in
+ the first name/value pair) if the request was not
+ successful.
+ @param[out] Results A null-terminated Unicode string in
+ <ConfigAltResp> format which has all values filled
+ in for the names in the Request string. String to
+ be allocated by the called function.
+
+ @retval EFI_SUCCESS The Results is filled with the requested values.
+ @retval EFI_OUT_OF_RESOURCES Not enough memory to store the results.
+ @retval EFI_INVALID_PARAMETER Request is illegal syntax, or unknown name.
+ @retval EFI_NOT_FOUND Routing data doesn't match any storage in this
+ driver.
+
+**/
+EFI_STATUS
+EFIAPI
+TrEEExtractConfig (
+ IN CONST EFI_HII_CONFIG_ACCESS_PROTOCOL *This,
+ IN CONST EFI_STRING Request,
+ OUT EFI_STRING *Progress,
+ OUT EFI_STRING *Results
+ )
+{
+ EFI_STATUS Status;
+ UINTN BufferSize;
+ TREE_CONFIGURATION Configuration;
+ TREE_CONFIG_PRIVATE_DATA *PrivateData;
+ EFI_STRING ConfigRequestHdr;
+ EFI_STRING ConfigRequest;
+ BOOLEAN AllocatedRequest;
+ UINTN Size;
+ UINTN Index;
+
+ if (Progress == NULL || Results == NULL) {
+ return EFI_INVALID_PARAMETER;
+ }
+
+ *Progress = Request;
+ if ((Request != NULL) && !HiiIsConfigHdrMatch (Request, &gTrEEConfigFormSetGuid, TREE_STORAGE_NAME)) {
+ return EFI_NOT_FOUND;
+ }
+
+ ConfigRequestHdr = NULL;
+ ConfigRequest = NULL;
+ AllocatedRequest = FALSE;
+ Size = 0;
+
+ PrivateData = TREE_CONFIG_PRIVATE_DATA_FROM_THIS (This);
+
+ //
+ // Convert buffer data to <ConfigResp> by helper function BlockToConfig()
+ //
+ BufferSize = sizeof (Configuration);
+ Status = gRT->GetVariable (
+ TREE_STORAGE_NAME,
+ &gTrEEConfigFormSetGuid,
+ NULL,
+ &BufferSize,
+ &Configuration
+ );
+ ASSERT_EFI_ERROR (Status);
+
+ //
+ // Get data from PCD to make sure data consistant - platform driver is suppose to construct this PCD accroding to Variable
+ //
+ for (Index = 0; Index < sizeof(mTpmInstanceId)/sizeof(mTpmInstanceId[0]); Index++) {
+ if (CompareGuid (PcdGetPtr(PcdTpmInstanceGuid), &mTpmInstanceId[Index].TpmInstanceGuid)) {
+ Configuration.TpmDevice = mTpmInstanceId[Index].TpmDevice;
+ break;
+ }
+ }
+
+ BufferSize = sizeof (Configuration);
+ ConfigRequest = Request;
+ if ((Request == NULL) || (StrStr (Request, L"OFFSET") == NULL)) {
+ //
+ // Request has no request element, construct full request string.
+ // Allocate and fill a buffer large enough to hold the <ConfigHdr> template
+ // followed by "&OFFSET=0&WIDTH=WWWWWWWWWWWWWWWW" followed by a Null-terminator
+ //
+ ConfigRequestHdr = HiiConstructConfigHdr (&gTrEEConfigFormSetGuid, TREE_STORAGE_NAME, PrivateData->DriverHandle);
+ Size = (StrLen (ConfigRequestHdr) + 32 + 1) * sizeof (CHAR16);
+ ConfigRequest = AllocateZeroPool (Size);
+ ASSERT (ConfigRequest != NULL);
+ AllocatedRequest = TRUE;
+ UnicodeSPrint (ConfigRequest, Size, L"%s&OFFSET=0&WIDTH=%016LX", ConfigRequestHdr, (UINT64) BufferSize);
+ FreePool (ConfigRequestHdr);
+ }
+
+ Status = gHiiConfigRouting->BlockToConfig (
+ gHiiConfigRouting,
+ ConfigRequest,
+ (UINT8 *) &Configuration,
+ BufferSize,
+ Results,
+ Progress
+ );
+ //
+ // Free the allocated config request string.
+ //
+ if (AllocatedRequest) {
+ FreePool (ConfigRequest);
+ }
+ //
+ // Set Progress string to the original request string.
+ //
+ if (Request == NULL) {
+ *Progress = NULL;
+ } else if (StrStr (Request, L"OFFSET") == NULL) {
+ *Progress = Request + StrLen (Request);
+ }
+
+ return Status;
+}
+
+/**
+ Save TPM request to variable space.
+
+ @param[in] PpRequest Physical Presence request command.
+
+ @retval EFI_SUCCESS The operation is finished successfully.
+ @retval Others Other errors as indicated.
+
+**/
+EFI_STATUS
+SaveTrEEPpRequest (
+ IN UINT8 PpRequest
+ )
+{
+ EFI_STATUS Status;
+ UINTN DataSize;
+ EFI_TREE_PHYSICAL_PRESENCE PpData;
+
+ //
+ // Save TPM command to variable.
+ //
+ DataSize = sizeof (EFI_TREE_PHYSICAL_PRESENCE);
+ Status = gRT->GetVariable (
+ TREE_PHYSICAL_PRESENCE_VARIABLE,
+ &gEfiTrEEPhysicalPresenceGuid,
+ NULL,
+ &DataSize,
+ &PpData
+ );
+ if (EFI_ERROR (Status)) {
+ return Status;
+ }
+
+ PpData.PPRequest = PpRequest;
+ Status = gRT->SetVariable (
+ TREE_PHYSICAL_PRESENCE_VARIABLE,
+ &gEfiTrEEPhysicalPresenceGuid,
+ EFI_VARIABLE_NON_VOLATILE | EFI_VARIABLE_BOOTSERVICE_ACCESS | EFI_VARIABLE_RUNTIME_ACCESS,
+ DataSize,
+ &PpData
+ );
+ if (EFI_ERROR(Status)) {
+ return Status;
+ }
+
+ return EFI_SUCCESS;
+}
+
+/**
+ This function processes the results of changes in configuration.
+
+ @param[in] This Points to the EFI_HII_CONFIG_ACCESS_PROTOCOL.
+ @param[in] Configuration A null-terminated Unicode string in <ConfigResp>
+ format.
+ @param[out] Progress A pointer to a string filled in with the offset of
+ the most recent '&' before the first failing
+ name/value pair (or the beginning of the string if
+ the failure is in the first name/value pair) or
+ the terminating NULL if all was successful.
+
+ @retval EFI_SUCCESS The Results is processed successfully.
+ @retval EFI_INVALID_PARAMETER Configuration is NULL.
+ @retval EFI_NOT_FOUND Routing data doesn't match any storage in this
+ driver.
+
+**/
+EFI_STATUS
+EFIAPI
+TrEERouteConfig (
+ IN CONST EFI_HII_CONFIG_ACCESS_PROTOCOL *This,
+ IN CONST EFI_STRING Configuration,
+ OUT EFI_STRING *Progress
+ )
+{
+ EFI_STATUS Status;
+ UINTN BufferSize;
+ TREE_CONFIGURATION TrEEConfiguration;
+
+ if (Configuration == NULL || Progress == NULL) {
+ return EFI_INVALID_PARAMETER;
+ }
+
+ *Progress = Configuration;
+ if (!HiiIsConfigHdrMatch (Configuration, &gTrEEConfigFormSetGuid, TREE_STORAGE_NAME)) {
+ return EFI_NOT_FOUND;
+ }
+
+ BufferSize = sizeof (TrEEConfiguration);
+ Status = gRT->GetVariable (
+ TREE_STORAGE_NAME,
+ &gTrEEConfigFormSetGuid,
+ NULL,
+ &BufferSize,
+ &TrEEConfiguration
+ );
+ ASSERT_EFI_ERROR (Status);
+
+ //
+ // Convert <ConfigResp> to buffer data by helper function ConfigToBlock()
+ //
+ BufferSize = sizeof (TREE_CONFIGURATION);
+ Status = gHiiConfigRouting->ConfigToBlock (
+ gHiiConfigRouting,
+ Configuration,
+ (UINT8 *) &TrEEConfiguration,
+ &BufferSize,
+ Progress
+ );
+ if (EFI_ERROR (Status)) {
+ return Status;
+ }
+
+ //
+ // Save to variable so platform driver can get it.
+ //
+ Status = gRT->SetVariable (
+ TREE_STORAGE_NAME,
+ &gTrEEConfigFormSetGuid,
+ EFI_VARIABLE_NON_VOLATILE | EFI_VARIABLE_BOOTSERVICE_ACCESS | EFI_VARIABLE_RUNTIME_ACCESS,
+ sizeof(TrEEConfiguration),
+ &TrEEConfiguration
+ );
+
+ SaveTrEEPpRequest (TrEEConfiguration.Tpm2Operation
+ );
+
+ return Status;
+}
+
+/**
+ This function processes the results of changes in configuration.
+
+ @param[in] This Points to the EFI_HII_CONFIG_ACCESS_PROTOCOL.
+ @param[in] Action Specifies the type of action taken by the browser.
+ @param[in] QuestionId A unique value which is sent to the original
+ exporting driver so that it can identify the type
+ of data to expect.
+ @param[in] Type The type of value for the question.
+ @param[in] Value A pointer to the data being sent to the original
+ exporting driver.
+ @param[out] ActionRequest On return, points to the action requested by the
+ callback function.
+
+ @retval EFI_SUCCESS The callback successfully handled the action.
+ @retval EFI_OUT_OF_RESOURCES Not enough storage is available to hold the
+ variable and its data.
+ @retval EFI_DEVICE_ERROR The variable could not be saved.
+ @retval EFI_UNSUPPORTED The specified Action is not supported by the
+ callback.
+
+**/
+EFI_STATUS
+EFIAPI
+TrEECallback (
+ IN CONST EFI_HII_CONFIG_ACCESS_PROTOCOL *This,
+ IN EFI_BROWSER_ACTION Action,
+ IN EFI_QUESTION_ID QuestionId,
+ IN UINT8 Type,
+ IN EFI_IFR_TYPE_VALUE *Value,
+ OUT EFI_BROWSER_ACTION_REQUEST *ActionRequest
+ )
+{
+ if ((This == NULL) || (Value == NULL) || (ActionRequest == NULL)) {
+ return EFI_INVALID_PARAMETER;
+ }
+
+ if ((Action != EFI_BROWSER_ACTION_CHANGED) ||
+ (QuestionId != KEY_TPM_DEVICE)) {
+ return EFI_UNSUPPORTED;
+ }
+
+ return EFI_SUCCESS;
+}
+
+/**
+ This function publish the TREE configuration Form for TPM device.
+
+ @param[in, out] PrivateData Points to TREE configuration private data.
+
+ @retval EFI_SUCCESS HII Form is installed for this network device.
+ @retval EFI_OUT_OF_RESOURCES Not enough resource for HII Form installation.
+ @retval Others Other errors as indicated.
+
+**/
+EFI_STATUS
+InstallTrEEConfigForm (
+ IN OUT TREE_CONFIG_PRIVATE_DATA *PrivateData
+ )
+{
+ EFI_STATUS Status;
+ EFI_HII_HANDLE HiiHandle;
+ EFI_HANDLE DriverHandle;
+ EFI_HII_CONFIG_ACCESS_PROTOCOL *ConfigAccess;
+
+ DriverHandle = NULL;
+ ConfigAccess = &PrivateData->ConfigAccess;
+ Status = gBS->InstallMultipleProtocolInterfaces (
+ &DriverHandle,
+ &gEfiDevicePathProtocolGuid,
+ &mTrEEHiiVendorDevicePath,
+ &gEfiHiiConfigAccessProtocolGuid,
+ ConfigAccess,
+ NULL
+ );
+ if (EFI_ERROR (Status)) {
+ return Status;
+ }
+
+ PrivateData->DriverHandle = DriverHandle;
+
+ //
+ // Publish the HII package list
+ //
+ HiiHandle = HiiAddPackages (
+ &gTrEEConfigFormSetGuid,
+ DriverHandle,
+ TrEEConfigDxeStrings,
+ TrEEConfigBin,
+ NULL
+ );
+ if (HiiHandle == NULL) {
+ gBS->UninstallMultipleProtocolInterfaces (
+ DriverHandle,
+ &gEfiDevicePathProtocolGuid,
+ &mTrEEHiiVendorDevicePath,
+ &gEfiHiiConfigAccessProtocolGuid,
+ ConfigAccess,
+ NULL
+ );
+
+ return EFI_OUT_OF_RESOURCES;
+ }
+
+ PrivateData->HiiHandle = HiiHandle;
+
+ return EFI_SUCCESS;
+}
+
+/**
+ This function removes TREE configuration Form.
+
+ @param[in, out] PrivateData Points to TREE configuration private data.
+
+**/
+VOID
+UninstallTrEEConfigForm (
+ IN OUT TREE_CONFIG_PRIVATE_DATA *PrivateData
+ )
+{
+ //
+ // Uninstall HII package list
+ //
+ if (PrivateData->HiiHandle != NULL) {
+ HiiRemovePackages (PrivateData->HiiHandle);
+ PrivateData->HiiHandle = NULL;
+ }
+
+ //
+ // Uninstall HII Config Access Protocol
+ //
+ if (PrivateData->DriverHandle != NULL) {
+ gBS->UninstallMultipleProtocolInterfaces (
+ PrivateData->DriverHandle,
+ &gEfiDevicePathProtocolGuid,
+ &mTrEEHiiVendorDevicePath,
+ &gEfiHiiConfigAccessProtocolGuid,
+ &PrivateData->ConfigAccess,
+ NULL
+ );
+ PrivateData->DriverHandle = NULL;
+ }
+
+ FreePool (PrivateData);
+}
diff --git a/SecurityPkg/Tcg/TrEEConfig/TrEEConfigImpl.h b/SecurityPkg/Tcg/TrEEConfig/TrEEConfigImpl.h
new file mode 100644
index 000000000..0d62c831d
--- /dev/null
+++ b/SecurityPkg/Tcg/TrEEConfig/TrEEConfigImpl.h
@@ -0,0 +1,191 @@
+/** @file
+ The header file of HII Config Access protocol implementation of TREE
+ configuration module.
+
+Copyright (c) 2013, 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.
+
+**/
+
+#ifndef __TREE_CONFIG_IMPL_H__
+#define __TREE_CONFIG_IMPL_H__
+
+#include <Uefi.h>
+
+#include <Protocol/HiiConfigAccess.h>
+#include <Protocol/HiiConfigRouting.h>
+#include <Protocol/TrEEProtocol.h>
+
+#include <Library/BaseLib.h>
+#include <Library/BaseMemoryLib.h>
+#include <Library/DebugLib.h>
+#include <Library/MemoryAllocationLib.h>
+#include <Library/UefiBootServicesTableLib.h>
+#include <Library/UefiRuntimeServicesTableLib.h>
+#include <Library/UefiHiiServicesLib.h>
+#include <Library/UefiLib.h>
+#include <Library/HiiLib.h>
+#include <Library/DevicePathLib.h>
+#include <Library/PcdLib.h>
+#include <Library/PrintLib.h>
+
+#include <Guid/MdeModuleHii.h>
+
+#include "TrEEConfigNvData.h"
+
+//
+// Tool generated IFR binary data and String package data
+//
+extern UINT8 TrEEConfigBin[];
+extern UINT8 TrEEConfigDxeStrings[];
+
+///
+/// HII specific Vendor Device Path definition.
+///
+typedef struct {
+ VENDOR_DEVICE_PATH VendorDevicePath;
+ EFI_DEVICE_PATH_PROTOCOL End;
+} HII_VENDOR_DEVICE_PATH;
+
+typedef struct {
+ UINTN Signature;
+
+ EFI_HII_CONFIG_ACCESS_PROTOCOL ConfigAccess;
+ EFI_HII_HANDLE HiiHandle;
+ EFI_HANDLE DriverHandle;
+
+} TREE_CONFIG_PRIVATE_DATA;
+
+extern TREE_CONFIG_PRIVATE_DATA mTrEEConfigPrivateDateTemplate;
+
+#define TREE_CONFIG_PRIVATE_DATA_SIGNATURE SIGNATURE_32 ('T', 'r', 'E', 'D')
+#define TREE_CONFIG_PRIVATE_DATA_FROM_THIS(a) CR (a, TREE_CONFIG_PRIVATE_DATA, ConfigAccess, TREE_CONFIG_PRIVATE_DATA_SIGNATURE)
+
+
+/**
+ This function publish the TREE configuration Form for TPM device.
+
+ @param[in, out] PrivateData Points to TREE configuration private data.
+
+ @retval EFI_SUCCESS HII Form is installed for this network device.
+ @retval EFI_OUT_OF_RESOURCES Not enough resource for HII Form installation.
+ @retval Others Other errors as indicated.
+
+**/
+EFI_STATUS
+InstallTrEEConfigForm (
+ IN OUT TREE_CONFIG_PRIVATE_DATA *PrivateData
+ );
+
+/**
+ This function removes TREE configuration Form.
+
+ @param[in, out] PrivateData Points to TREE configuration private data.
+
+**/
+VOID
+UninstallTrEEConfigForm (
+ IN OUT TREE_CONFIG_PRIVATE_DATA *PrivateData
+ );
+
+/**
+ This function allows a caller to extract the current configuration for one
+ or more named elements from the target driver.
+
+ @param[in] This Points to the EFI_HII_CONFIG_ACCESS_PROTOCOL.
+ @param[in] Request A null-terminated Unicode string in
+ <ConfigRequest> format.
+ @param[out] Progress On return, points to a character in the Request
+ string. Points to the string's null terminator if
+ request was successful. Points to the most recent
+ '&' before the first failing name/value pair (or
+ the beginning of the string if the failure is in
+ the first name/value pair) if the request was not
+ successful.
+ @param[out] Results A null-terminated Unicode string in
+ <ConfigAltResp> format which has all values filled
+ in for the names in the Request string. String to
+ be allocated by the called function.
+
+ @retval EFI_SUCCESS The Results is filled with the requested values.
+ @retval EFI_OUT_OF_RESOURCES Not enough memory to store the results.
+ @retval EFI_INVALID_PARAMETER Request is illegal syntax, or unknown name.
+ @retval EFI_NOT_FOUND Routing data doesn't match any storage in this
+ driver.
+
+**/
+EFI_STATUS
+EFIAPI
+TrEEExtractConfig (
+ IN CONST EFI_HII_CONFIG_ACCESS_PROTOCOL *This,
+ IN CONST EFI_STRING Request,
+ OUT EFI_STRING *Progress,
+ OUT EFI_STRING *Results
+ );
+
+/**
+ This function processes the results of changes in configuration.
+
+ @param[in] This Points to the EFI_HII_CONFIG_ACCESS_PROTOCOL.
+ @param[in] Configuration A null-terminated Unicode string in <ConfigResp>
+ format.
+ @param[out] Progress A pointer to a string filled in with the offset of
+ the most recent '&' before the first failing
+ name/value pair (or the beginning of the string if
+ the failure is in the first name/value pair) or
+ the terminating NULL if all was successful.
+
+ @retval EFI_SUCCESS The Results is processed successfully.
+ @retval EFI_INVALID_PARAMETER Configuration is NULL.
+ @retval EFI_NOT_FOUND Routing data doesn't match any storage in this
+ driver.
+
+**/
+EFI_STATUS
+EFIAPI
+TrEERouteConfig (
+ IN CONST EFI_HII_CONFIG_ACCESS_PROTOCOL *This,
+ IN CONST EFI_STRING Configuration,
+ OUT EFI_STRING *Progress
+ );
+
+/**
+ This function processes the results of changes in configuration.
+
+ @param[in] This Points to the EFI_HII_CONFIG_ACCESS_PROTOCOL.
+ @param[in] Action Specifies the type of action taken by the browser.
+ @param[in] QuestionId A unique value which is sent to the original
+ exporting driver so that it can identify the type
+ of data to expect.
+ @param[in] Type The type of value for the question.
+ @param[in] Value A pointer to the data being sent to the original
+ exporting driver.
+ @param[out] ActionRequest On return, points to the action requested by the
+ callback function.
+
+ @retval EFI_SUCCESS The callback successfully handled the action.
+ @retval EFI_OUT_OF_RESOURCES Not enough storage is available to hold the
+ variable and its data.
+ @retval EFI_DEVICE_ERROR The variable could not be saved.
+ @retval EFI_UNSUPPORTED The specified Action is not supported by the
+ callback.
+
+**/
+EFI_STATUS
+EFIAPI
+TrEECallback (
+ IN CONST EFI_HII_CONFIG_ACCESS_PROTOCOL *This,
+ IN EFI_BROWSER_ACTION Action,
+ IN EFI_QUESTION_ID QuestionId,
+ IN UINT8 Type,
+ IN EFI_IFR_TYPE_VALUE *Value,
+ OUT EFI_BROWSER_ACTION_REQUEST *ActionRequest
+ );
+
+#endif
diff --git a/SecurityPkg/Tcg/TrEEConfig/TrEEConfigNvData.h b/SecurityPkg/Tcg/TrEEConfig/TrEEConfigNvData.h
new file mode 100644
index 000000000..cb9f5a818
--- /dev/null
+++ b/SecurityPkg/Tcg/TrEEConfig/TrEEConfigNvData.h
@@ -0,0 +1,66 @@
+/** @file
+ Header file for NV data structure definition.
+
+Copyright (c) 2013, 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.
+
+**/
+
+#ifndef __TREE_CONFIG_NV_DATA_H__
+#define __TREE_CONFIG_NV_DATA_H__
+
+#include <Guid/HiiPlatformSetupFormset.h>
+#include <Guid/TrEEPhysicalPresenceData.h>
+#include <Guid/TrEEConfigHii.h>
+
+#define TREE_CONFIGURATION_VARSTORE_ID 0x0001
+#define TREE_CONFIGURATION_FORM_ID 0x0001
+
+#define KEY_TPM_DEVICE 0x2000
+
+#define TPM_DEVICE_NULL 0
+#define TPM_DEVICE_1_2 1
+#define TPM_DEVICE_2_0_DTPM 2
+#define TPM_DEVICE_MAX TPM_DEVICE_2_0_DTPM
+#define TPM_DEVICE_DEFAULT TPM_DEVICE_1_2
+
+//
+// Nv Data structure referenced by IFR
+//
+typedef struct {
+ UINT8 TpmDevice;
+ UINT8 Tpm2Operation;
+} TREE_CONFIGURATION;
+
+#define TREE_STORAGE_NAME L"TREE_CONFIGURATION"
+
+#define TPM_INSTANCE_ID_LIST { \
+ {TPM_DEVICE_INTERFACE_NONE, TPM_DEVICE_NULL}, \
+ {TPM_DEVICE_INTERFACE_TPM12, TPM_DEVICE_1_2}, \
+ {TPM_DEVICE_INTERFACE_TPM20_DTPM, TPM_DEVICE_2_0_DTPM}, \
+}
+
+//
+// BUGBUG: In order to pass VfrCompiler, we have to redefine GUID here.
+//
+#ifndef __BASE_H__
+typedef struct {
+ UINT32 Data1;
+ UINT16 Data2;
+ UINT16 Data3;
+ UINT8 Data4[8];
+} GUID;
+#endif
+
+typedef struct {
+ GUID TpmInstanceGuid;
+ UINT8 TpmDevice;
+} TPM_INSTANCE_ID;
+
+#endif
diff --git a/SecurityPkg/Tcg/TrEEConfig/TrEEConfigPei.inf b/SecurityPkg/Tcg/TrEEConfig/TrEEConfigPei.inf
new file mode 100644
index 000000000..c6a489aee
--- /dev/null
+++ b/SecurityPkg/Tcg/TrEEConfig/TrEEConfigPei.inf
@@ -0,0 +1,70 @@
+## @file
+# Component name for TrEE configuration module.
+# NOTE: This module is only for reference only, each platform should have its own setup page.
+#
+# Copyright (c) 2013, 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.
+#
+##
+
+[Defines]
+ INF_VERSION = 0x00010005
+ BASE_NAME = TrEEConfigPei
+ FILE_GUID = A5C1EF72-9379-4370-B4C7-0F5126CAC38E
+ MODULE_TYPE = PEIM
+ VERSION_STRING = 1.0
+ ENTRY_POINT = TrEEConfigPeimEntryPoint
+
+#
+# VALID_ARCHITECTURES = IA32 X64 IPF EBC
+#
+
+[Sources]
+ TrEEConfigPeim.c
+ TrEEConfigNvData.h
+ TpmDetection.c
+
+[Packages]
+ MdePkg/MdePkg.dec
+ MdeModulePkg/MdeModulePkg.dec
+ SecurityPkg/SecurityPkg.dec
+
+[LibraryClasses]
+ BaseLib
+ BaseMemoryLib
+ MemoryAllocationLib
+ PeiServicesLib
+ PeimEntryPoint
+ DebugLib
+ PcdLib
+ TimerLib
+ IoLib
+ Tpm12CommandLib
+ Tpm12DeviceLib
+
+[Guids]
+ gEfiTrEEPhysicalPresenceGuid
+ gTrEEConfigFormSetGuid
+ gEfiTpmDeviceSelectedGuid
+
+[Ppis]
+ gEfiPeiReadOnlyVariable2PpiGuid
+
+[FixedPcd]
+ gEfiSecurityPkgTokenSpaceGuid.PcdHideTpmSupport
+
+[Pcd]
+ gEfiSecurityPkgTokenSpaceGuid.PcdTpmInstanceGuid
+ gEfiSecurityPkgTokenSpaceGuid.PcdHideTpm
+ gEfiSecurityPkgTokenSpaceGuid.PcdTpmInitializationPolicy
+ gEfiSecurityPkgTokenSpaceGuid.PcdTpmAutoDetection
+ gEfiSecurityPkgTokenSpaceGuid.PcdTpmBaseAddress
+
+[Depex]
+ gEfiPeiMasterBootModePpiGuid AND
+ gEfiPeiReadOnlyVariable2PpiGuid \ No newline at end of file
diff --git a/SecurityPkg/Tcg/TrEEConfig/TrEEConfigPeim.c b/SecurityPkg/Tcg/TrEEConfig/TrEEConfigPeim.c
new file mode 100644
index 000000000..77d640dd4
--- /dev/null
+++ b/SecurityPkg/Tcg/TrEEConfig/TrEEConfigPeim.c
@@ -0,0 +1,133 @@
+/** @file
+ The module entry point for TrEE configuration module.
+
+Copyright (c) 2013, 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.
+
+**/
+
+
+#include <PiPei.h>
+
+#include <Guid/TpmInstance.h>
+
+#include <Library/BaseLib.h>
+#include <Library/BaseMemoryLib.h>
+#include <Library/DebugLib.h>
+#include <Library/MemoryAllocationLib.h>
+#include <Library/PeiServicesLib.h>
+#include <Library/PcdLib.h>
+
+#include <Ppi/ReadOnlyVariable2.h>
+#include <Protocol/TrEEProtocol.h>
+
+#include "TrEEConfigNvData.h"
+
+TPM_INSTANCE_ID mTpmInstanceId[] = TPM_INSTANCE_ID_LIST;
+
+CONST EFI_PEI_PPI_DESCRIPTOR gTpmSelectedPpi = {
+ (EFI_PEI_PPI_DESCRIPTOR_PPI | EFI_PEI_PPI_DESCRIPTOR_TERMINATE_LIST),
+ &gEfiTpmDeviceSelectedGuid,
+ NULL
+};
+
+/**
+ This routine check both SetupVariable and real TPM device, and return final TpmDevice configuration.
+
+ @param SetupTpmDevice TpmDevice configuration in setup driver
+
+ @return TpmDevice configuration
+**/
+UINT8
+DetectTpmDevice (
+ IN UINT8 SetupTpmDevice
+ );
+
+/**
+ The entry point for TrEE configuration driver.
+
+ @param FileHandle Handle of the file being invoked.
+ @param PeiServices Describes the list of possible PEI Services.
+
+ @retval EFI_SUCCES Convert variable to PCD successfully.
+ @retval Others Fail to convert variable to PCD.
+**/
+EFI_STATUS
+EFIAPI
+TrEEConfigPeimEntryPoint (
+ IN EFI_PEI_FILE_HANDLE FileHandle,
+ IN CONST EFI_PEI_SERVICES **PeiServices
+ )
+{
+ UINTN Size;
+ EFI_STATUS Status;
+ EFI_PEI_READ_ONLY_VARIABLE2_PPI *VariablePpi;
+ TREE_CONFIGURATION TrEEConfiguration;
+ UINTN Index;
+ UINT8 TpmDevice;
+
+ Status = PeiServicesLocatePpi (&gEfiPeiReadOnlyVariable2PpiGuid, 0, NULL, (VOID **) &VariablePpi);
+ ASSERT_EFI_ERROR (Status);
+
+ Size = sizeof(TrEEConfiguration);
+ Status = VariablePpi->GetVariable (
+ VariablePpi,
+ TREE_STORAGE_NAME,
+ &gTrEEConfigFormSetGuid,
+ NULL,
+ &Size,
+ &TrEEConfiguration
+ );
+ if (EFI_ERROR (Status)) {
+ //
+ // Variable not ready, set default value
+ //
+ TrEEConfiguration.TpmDevice = TPM_DEVICE_DEFAULT;
+ }
+
+ //
+ // Validation
+ //
+ if (TrEEConfiguration.TpmDevice > TPM_DEVICE_MAX) {
+ TrEEConfiguration.TpmDevice = TPM_DEVICE_DEFAULT;
+ }
+
+ //
+ // Although we have SetupVariable info, we still need detect TPM device manually.
+ //
+ DEBUG ((EFI_D_ERROR, "TrEEConfiguration.TpmDevice from Setup: %x\n", TrEEConfiguration.TpmDevice));
+
+ if (PcdGetBool (PcdTpmAutoDetection)) {
+ TpmDevice = DetectTpmDevice (TrEEConfiguration.TpmDevice);
+ DEBUG ((EFI_D_ERROR, "TrEEConfiguration.TpmDevice final: %x\n", TpmDevice));
+ TrEEConfiguration.TpmDevice = TpmDevice;
+ }
+
+ //
+ // Convert variable to PCD.
+ // This is work-around because there is no gurantee DynamicHiiPcd can return correct value in DXE phase.
+ // Using DynamicPcd instead.
+ //
+ for (Index = 0; Index < sizeof(mTpmInstanceId)/sizeof(mTpmInstanceId[0]); Index++) {
+ if (TrEEConfiguration.TpmDevice == mTpmInstanceId[Index].TpmDevice) {
+ Size = sizeof(mTpmInstanceId[Index].TpmInstanceGuid);
+ PcdSetPtr (PcdTpmInstanceGuid, &Size, &mTpmInstanceId[Index].TpmInstanceGuid);
+ DEBUG ((EFI_D_ERROR, "TrEEConfiguration.TpmDevice PCD: %g\n", &mTpmInstanceId[Index].TpmInstanceGuid));
+ break;
+ }
+ }
+
+ //
+ // Selection done
+ //
+ Status = PeiServicesInstallPpi (&gTpmSelectedPpi);
+ ASSERT_EFI_ERROR (Status);
+
+ return Status;
+}
diff --git a/SecurityPkg/Tcg/TrEEConfig/TrEEConfigStrings.uni b/SecurityPkg/Tcg/TrEEConfig/TrEEConfigStrings.uni
new file mode 100644
index 000000000..29c02e7f8
--- /dev/null
+++ b/SecurityPkg/Tcg/TrEEConfig/TrEEConfigStrings.uni
Binary files differ
diff --git a/SecurityPkg/Tcg/TrEEDxe/MeasureBootPeCoff.c b/SecurityPkg/Tcg/TrEEDxe/MeasureBootPeCoff.c
new file mode 100644
index 000000000..e80e02994
--- /dev/null
+++ b/SecurityPkg/Tcg/TrEEDxe/MeasureBootPeCoff.c
@@ -0,0 +1,357 @@
+/** @file
+ This module implements measuring PeCoff image for TrEE Protocol.
+
+ Caution: This file requires additional review when modified.
+ This driver will have external input - PE/COFF image.
+ This external input must be validated carefully to avoid security issue like
+ buffer overflow, integer overflow.
+
+Copyright (c) 2013, 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.
+
+**/
+
+#include <PiDxe.h>
+
+#include <Library/BaseLib.h>
+#include <Library/DebugLib.h>
+#include <Library/BaseMemoryLib.h>
+#include <Library/MemoryAllocationLib.h>
+#include <Library/DevicePathLib.h>
+#include <Library/UefiBootServicesTableLib.h>
+#include <Library/PeCoffLib.h>
+#include <Library/Tpm2CommandLib.h>
+#include <Library/HashLib.h>
+
+/**
+ Measure PE image into TPM log based on the authenticode image hashing in
+ PE/COFF Specification 8.0 Appendix A.
+
+ Caution: This function may receive untrusted input.
+ PE/COFF image is external input, so this function will validate its data structure
+ within this image buffer before use.
+
+ @param[in] PCRIndex TPM PCR index
+ @param[in] ImageAddress Start address of image buffer.
+ @param[in] ImageSize Image size
+ @param[out] DigestList Digeest list of this image.
+
+ @retval EFI_SUCCESS Successfully measure image.
+ @retval EFI_OUT_OF_RESOURCES No enough resource to measure image.
+ @retval other error value
+**/
+EFI_STATUS
+MeasurePeImageAndExtend (
+ IN UINT32 PCRIndex,
+ IN EFI_PHYSICAL_ADDRESS ImageAddress,
+ IN UINTN ImageSize,
+ OUT TPML_DIGEST_VALUES *DigestList
+ )
+{
+ EFI_STATUS Status;
+ EFI_IMAGE_DOS_HEADER *DosHdr;
+ UINT32 PeCoffHeaderOffset;
+ EFI_IMAGE_SECTION_HEADER *Section;
+ UINT8 *HashBase;
+ UINTN HashSize;
+ UINTN SumOfBytesHashed;
+ EFI_IMAGE_SECTION_HEADER *SectionHeader;
+ UINTN Index;
+ UINTN Pos;
+ UINT16 Magic;
+ EFI_IMAGE_OPTIONAL_HEADER_PTR_UNION Hdr;
+ UINT32 NumberOfRvaAndSizes;
+ UINT32 CertSize;
+ HASH_HANDLE HashHandle;
+
+ HashHandle = 0xFFFFFFFF; // Know bad value
+
+ Status = EFI_UNSUPPORTED;
+ SectionHeader = NULL;
+
+ //
+ // Check PE/COFF image
+ //
+ DosHdr = (EFI_IMAGE_DOS_HEADER *) (UINTN) ImageAddress;
+ PeCoffHeaderOffset = 0;
+ if (DosHdr->e_magic == EFI_IMAGE_DOS_SIGNATURE) {
+ PeCoffHeaderOffset = DosHdr->e_lfanew;
+ }
+
+ Hdr.Pe32 = (EFI_IMAGE_NT_HEADERS32 *)((UINT8 *) (UINTN) ImageAddress + PeCoffHeaderOffset);
+ if (Hdr.Pe32->Signature != EFI_IMAGE_NT_SIGNATURE) {
+ Status = EFI_UNSUPPORTED;
+ goto Finish;
+ }
+
+ //
+ // PE/COFF Image Measurement
+ //
+ // NOTE: The following codes/steps are based upon the authenticode image hashing in
+ // PE/COFF Specification 8.0 Appendix A.
+ //
+ //
+
+ // 1. Load the image header into memory.
+
+ // 2. Initialize a SHA hash context.
+
+ Status = HashStart (&HashHandle);
+ if (EFI_ERROR (Status)) {
+ goto Finish;
+ }
+
+ //
+ // Measuring PE/COFF Image Header;
+ // But CheckSum field and SECURITY data directory (certificate) are excluded
+ //
+ if (Hdr.Pe32->FileHeader.Machine == IMAGE_FILE_MACHINE_IA64 && Hdr.Pe32->OptionalHeader.Magic == EFI_IMAGE_NT_OPTIONAL_HDR32_MAGIC) {
+ //
+ // NOTE: Some versions of Linux ELILO for Itanium have an incorrect magic value
+ // in the PE/COFF Header. If the MachineType is Itanium(IA64) and the
+ // Magic value in the OptionalHeader is EFI_IMAGE_NT_OPTIONAL_HDR32_MAGIC
+ // then override the magic value to EFI_IMAGE_NT_OPTIONAL_HDR64_MAGIC
+ //
+ Magic = EFI_IMAGE_NT_OPTIONAL_HDR64_MAGIC;
+ } else {
+ //
+ // Get the magic value from the PE/COFF Optional Header
+ //
+ Magic = Hdr.Pe32->OptionalHeader.Magic;
+ }
+
+ //
+ // 3. Calculate the distance from the base of the image header to the image checksum address.
+ // 4. Hash the image header from its base to beginning of the image checksum.
+ //
+ HashBase = (UINT8 *) (UINTN) ImageAddress;
+ if (Magic == EFI_IMAGE_NT_OPTIONAL_HDR32_MAGIC) {
+ //
+ // Use PE32 offset
+ //
+ NumberOfRvaAndSizes = Hdr.Pe32->OptionalHeader.NumberOfRvaAndSizes;
+ HashSize = (UINTN) ((UINT8 *)(&Hdr.Pe32->OptionalHeader.CheckSum) - HashBase);
+ } else {
+ //
+ // Use PE32+ offset
+ //
+ NumberOfRvaAndSizes = Hdr.Pe32Plus->OptionalHeader.NumberOfRvaAndSizes;
+ HashSize = (UINTN) ((UINT8 *)(&Hdr.Pe32Plus->OptionalHeader.CheckSum) - HashBase);
+ }
+
+ Status = HashUpdate (HashHandle, HashBase, HashSize);
+ if (EFI_ERROR (Status)) {
+ goto Finish;
+ }
+
+ //
+ // 5. Skip over the image checksum (it occupies a single ULONG).
+ //
+ if (NumberOfRvaAndSizes <= EFI_IMAGE_DIRECTORY_ENTRY_SECURITY) {
+ //
+ // 6. Since there is no Cert Directory in optional header, hash everything
+ // from the end of the checksum to the end of image header.
+ //
+ if (Magic == EFI_IMAGE_NT_OPTIONAL_HDR32_MAGIC) {
+ //
+ // Use PE32 offset.
+ //
+ HashBase = (UINT8 *) &Hdr.Pe32->OptionalHeader.CheckSum + sizeof (UINT32);
+ HashSize = Hdr.Pe32->OptionalHeader.SizeOfHeaders - (UINTN) (HashBase - ImageAddress);
+ } else {
+ //
+ // Use PE32+ offset.
+ //
+ HashBase = (UINT8 *) &Hdr.Pe32Plus->OptionalHeader.CheckSum + sizeof (UINT32);
+ HashSize = Hdr.Pe32Plus->OptionalHeader.SizeOfHeaders - (UINTN) (HashBase - ImageAddress);
+ }
+
+ if (HashSize != 0) {
+ Status = HashUpdate (HashHandle, HashBase, HashSize);
+ if (EFI_ERROR (Status)) {
+ goto Finish;
+ }
+ }
+ } else {
+ //
+ // 7. Hash everything from the end of the checksum to the start of the Cert Directory.
+ //
+ if (Magic == EFI_IMAGE_NT_OPTIONAL_HDR32_MAGIC) {
+ //
+ // Use PE32 offset
+ //
+ HashBase = (UINT8 *) &Hdr.Pe32->OptionalHeader.CheckSum + sizeof (UINT32);
+ HashSize = (UINTN) ((UINT8 *)(&Hdr.Pe32->OptionalHeader.DataDirectory[EFI_IMAGE_DIRECTORY_ENTRY_SECURITY]) - HashBase);
+ } else {
+ //
+ // Use PE32+ offset
+ //
+ HashBase = (UINT8 *) &Hdr.Pe32Plus->OptionalHeader.CheckSum + sizeof (UINT32);
+ HashSize = (UINTN) ((UINT8 *)(&Hdr.Pe32Plus->OptionalHeader.DataDirectory[EFI_IMAGE_DIRECTORY_ENTRY_SECURITY]) - HashBase);
+ }
+
+ if (HashSize != 0) {
+ Status = HashUpdate (HashHandle, HashBase, HashSize);
+ if (EFI_ERROR (Status)) {
+ goto Finish;
+ }
+ }
+
+ //
+ // 8. Skip over the Cert Directory. (It is sizeof(IMAGE_DATA_DIRECTORY) bytes.)
+ // 9. Hash everything from the end of the Cert Directory to the end of image header.
+ //
+ if (Magic == EFI_IMAGE_NT_OPTIONAL_HDR32_MAGIC) {
+ //
+ // Use PE32 offset
+ //
+ HashBase = (UINT8 *) &Hdr.Pe32->OptionalHeader.DataDirectory[EFI_IMAGE_DIRECTORY_ENTRY_SECURITY + 1];
+ HashSize = Hdr.Pe32->OptionalHeader.SizeOfHeaders - (UINTN) (HashBase - ImageAddress);
+ } else {
+ //
+ // Use PE32+ offset
+ //
+ HashBase = (UINT8 *) &Hdr.Pe32Plus->OptionalHeader.DataDirectory[EFI_IMAGE_DIRECTORY_ENTRY_SECURITY + 1];
+ HashSize = Hdr.Pe32Plus->OptionalHeader.SizeOfHeaders - (UINTN) (HashBase - ImageAddress);
+ }
+
+ if (HashSize != 0) {
+ Status = HashUpdate (HashHandle, HashBase, HashSize);
+ if (EFI_ERROR (Status)) {
+ goto Finish;
+ }
+ }
+ }
+
+ //
+ // 10. Set the SUM_OF_BYTES_HASHED to the size of the header
+ //
+ if (Magic == EFI_IMAGE_NT_OPTIONAL_HDR32_MAGIC) {
+ //
+ // Use PE32 offset
+ //
+ SumOfBytesHashed = Hdr.Pe32->OptionalHeader.SizeOfHeaders;
+ } else {
+ //
+ // Use PE32+ offset
+ //
+ SumOfBytesHashed = Hdr.Pe32Plus->OptionalHeader.SizeOfHeaders;
+ }
+
+ //
+ // 11. Build a temporary table of pointers to all the IMAGE_SECTION_HEADER
+ // structures in the image. The 'NumberOfSections' field of the image
+ // header indicates how big the table should be. Do not include any
+ // IMAGE_SECTION_HEADERs in the table whose 'SizeOfRawData' field is zero.
+ //
+ SectionHeader = (EFI_IMAGE_SECTION_HEADER *) AllocateZeroPool (sizeof (EFI_IMAGE_SECTION_HEADER) * Hdr.Pe32->FileHeader.NumberOfSections);
+ if (SectionHeader == NULL) {
+ Status = EFI_OUT_OF_RESOURCES;
+ goto Finish;
+ }
+
+ //
+ // 12. Using the 'PointerToRawData' in the referenced section headers as
+ // a key, arrange the elements in the table in ascending order. In other
+ // words, sort the section headers according to the disk-file offset of
+ // the section.
+ //
+ Section = (EFI_IMAGE_SECTION_HEADER *) (
+ (UINT8 *) (UINTN) ImageAddress +
+ PeCoffHeaderOffset +
+ sizeof(UINT32) +
+ sizeof(EFI_IMAGE_FILE_HEADER) +
+ Hdr.Pe32->FileHeader.SizeOfOptionalHeader
+ );
+ for (Index = 0; Index < Hdr.Pe32->FileHeader.NumberOfSections; Index++) {
+ Pos = Index;
+ while ((Pos > 0) && (Section->PointerToRawData < SectionHeader[Pos - 1].PointerToRawData)) {
+ CopyMem (&SectionHeader[Pos], &SectionHeader[Pos - 1], sizeof(EFI_IMAGE_SECTION_HEADER));
+ Pos--;
+ }
+ CopyMem (&SectionHeader[Pos], Section, sizeof(EFI_IMAGE_SECTION_HEADER));
+ Section += 1;
+ }
+
+ //
+ // 13. Walk through the sorted table, bring the corresponding section
+ // into memory, and hash the entire section (using the 'SizeOfRawData'
+ // field in the section header to determine the amount of data to hash).
+ // 14. Add the section's 'SizeOfRawData' to SUM_OF_BYTES_HASHED .
+ // 15. Repeat steps 13 and 14 for all the sections in the sorted table.
+ //
+ for (Index = 0; Index < Hdr.Pe32->FileHeader.NumberOfSections; Index++) {
+ Section = (EFI_IMAGE_SECTION_HEADER *) &SectionHeader[Index];
+ if (Section->SizeOfRawData == 0) {
+ continue;
+ }
+ HashBase = (UINT8 *) (UINTN) ImageAddress + Section->PointerToRawData;
+ HashSize = (UINTN) Section->SizeOfRawData;
+
+ Status = HashUpdate (HashHandle, HashBase, HashSize);
+ if (EFI_ERROR (Status)) {
+ goto Finish;
+ }
+
+ SumOfBytesHashed += HashSize;
+ }
+
+ //
+ // 16. If the file size is greater than SUM_OF_BYTES_HASHED, there is extra
+ // data in the file that needs to be added to the hash. This data begins
+ // at file offset SUM_OF_BYTES_HASHED and its length is:
+ // FileSize - (CertDirectory->Size)
+ //
+ if (ImageSize > SumOfBytesHashed) {
+ HashBase = (UINT8 *) (UINTN) ImageAddress + SumOfBytesHashed;
+
+ if (NumberOfRvaAndSizes <= EFI_IMAGE_DIRECTORY_ENTRY_SECURITY) {
+ CertSize = 0;
+ } else {
+ if (Magic == EFI_IMAGE_NT_OPTIONAL_HDR32_MAGIC) {
+ //
+ // Use PE32 offset.
+ //
+ CertSize = Hdr.Pe32->OptionalHeader.DataDirectory[EFI_IMAGE_DIRECTORY_ENTRY_SECURITY].Size;
+ } else {
+ //
+ // Use PE32+ offset.
+ //
+ CertSize = Hdr.Pe32Plus->OptionalHeader.DataDirectory[EFI_IMAGE_DIRECTORY_ENTRY_SECURITY].Size;
+ }
+ }
+
+ if (ImageSize > CertSize + SumOfBytesHashed) {
+ HashSize = (UINTN) (ImageSize - CertSize - SumOfBytesHashed);
+
+ Status = HashUpdate (HashHandle, HashBase, HashSize);
+ if (EFI_ERROR (Status)) {
+ goto Finish;
+ }
+ } else if (ImageSize < CertSize + SumOfBytesHashed) {
+ Status = EFI_UNSUPPORTED;
+ goto Finish;
+ }
+ }
+
+ //
+ // 17. Finalize the SHA hash.
+ //
+ Status = HashCompleteAndExtend (HashHandle, PCRIndex, NULL, 0, DigestList);
+ if (EFI_ERROR (Status)) {
+ goto Finish;
+ }
+
+Finish:
+ if (SectionHeader != NULL) {
+ FreePool (SectionHeader);
+ }
+
+ return Status;
+}
diff --git a/SecurityPkg/Tcg/TrEEDxe/TrEEDxe.c b/SecurityPkg/Tcg/TrEEDxe/TrEEDxe.c
new file mode 100644
index 000000000..9451b55c3
--- /dev/null
+++ b/SecurityPkg/Tcg/TrEEDxe/TrEEDxe.c
@@ -0,0 +1,1977 @@
+/** @file
+ This module implements TrEE Protocol.
+
+Copyright (c) 2013, 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.
+
+**/
+
+#include <PiDxe.h>
+#include <IndustryStandard/Acpi.h>
+#include <IndustryStandard/PeImage.h>
+#include <IndustryStandard/SmBios.h>
+#include <IndustryStandard/TcpaAcpi.h>
+
+#include <Guid/GlobalVariable.h>
+#include <Guid/SmBios.h>
+#include <Guid/HobList.h>
+#include <Guid/TcgEventHob.h>
+#include <Guid/EventGroup.h>
+#include <Guid/EventExitBootServiceFailed.h>
+#include <Guid/ImageAuthentication.h>
+#include <Guid/TpmInstance.h>
+
+#include <Protocol/DevicePath.h>
+#include <Protocol/AcpiTable.h>
+#include <Protocol/MpService.h>
+#include <Protocol/VariableWrite.h>
+#include <Protocol/TrEEProtocol.h>
+
+#include <Library/DebugLib.h>
+#include <Library/BaseMemoryLib.h>
+#include <Library/UefiRuntimeServicesTableLib.h>
+#include <Library/UefiDriverEntryPoint.h>
+#include <Library/HobLib.h>
+#include <Library/UefiBootServicesTableLib.h>
+#include <Library/BaseLib.h>
+#include <Library/MemoryAllocationLib.h>
+#include <Library/PrintLib.h>
+#include <Library/Tpm2CommandLib.h>
+#include <Library/PcdLib.h>
+#include <Library/UefiLib.h>
+#include <Library/Tpm2DeviceLib.h>
+#include <Library/HashLib.h>
+#include <Library/PerformanceLib.h>
+
+#define PERF_ID_TREE_DXE 0x3120
+
+typedef struct {
+ CHAR16 *VariableName;
+ EFI_GUID *VendorGuid;
+} VARIABLE_TYPE;
+
+#define EFI_TCG_LOG_AREA_SIZE 0x10000
+
+#define TREE_DEFAULT_MAX_COMMAND_SIZE 0x1000
+#define TREE_DEFAULT_MAX_RESPONSE_SIZE 0x1000
+
+typedef struct {
+ EFI_GUID *EventGuid;
+ TREE_EVENT_LOG_FORMAT LogFormat;
+ UINT32 BootHashAlg;
+ UINT16 DigestAlgID;
+ TPMI_ALG_HASH TpmHashAlgo;
+} TREE_EVENT_INFO_STRUCT;
+
+TREE_EVENT_INFO_STRUCT mTreeEventInfo[] = {
+ {&gTcgEventEntryHobGuid, TREE_EVENT_LOG_FORMAT_TCG_1_2, TREE_BOOT_HASH_ALG_SHA1, 0, TPM_ALG_SHA1},
+};
+
+#define TCG_EVENT_LOG_AREA_COUNT_MAX 5
+
+typedef struct {
+ TREE_EVENT_LOG_FORMAT EventLogFormat;
+ EFI_PHYSICAL_ADDRESS Lasa;
+ UINT64 Laml;
+ UINTN EventLogSize;
+ UINT8 *LastEvent;
+ BOOLEAN EventLogStarted;
+ BOOLEAN EventLogTruncated;
+} TCG_EVENT_LOG_AREA_STRUCT;
+
+typedef struct _TCG_DXE_DATA {
+ TREE_BOOT_SERVICE_CAPABILITY BsCap;
+ EFI_TCG_CLIENT_ACPI_TABLE *TcgClientAcpiTable;
+ EFI_TCG_SERVER_ACPI_TABLE *TcgServerAcpiTable;
+ TCG_EVENT_LOG_AREA_STRUCT EventLogAreaStruct[TCG_EVENT_LOG_AREA_COUNT_MAX];
+} TCG_DXE_DATA;
+
+EFI_TCG_CLIENT_ACPI_TABLE mTcgClientAcpiTemplate = {
+ {
+ EFI_ACPI_3_0_TRUSTED_COMPUTING_PLATFORM_ALLIANCE_CAPABILITIES_TABLE_SIGNATURE,
+ sizeof (mTcgClientAcpiTemplate),
+ 0x02 //Revision
+ //
+ // Compiler initializes the remaining bytes to 0
+ // These fields should be filled in in production
+ //
+ },
+ 0, // 0 for PC Client Platform Class
+ 0, // Log Area Max Length
+ (EFI_PHYSICAL_ADDRESS) (SIZE_4GB - 1) // Log Area Start Address
+};
+
+//
+// The following EFI_TCG_SERVER_ACPI_TABLE default setting is just one example,
+// the TPM device connectes to LPC, and also defined the ACPI _UID as 0xFF,
+// this _UID can be changed and should match with the _UID setting of the TPM
+// ACPI device object
+//
+EFI_TCG_SERVER_ACPI_TABLE mTcgServerAcpiTemplate = {
+ {
+ EFI_ACPI_3_0_TRUSTED_COMPUTING_PLATFORM_ALLIANCE_CAPABILITIES_TABLE_SIGNATURE,
+ sizeof (mTcgServerAcpiTemplate),
+ 0x02 //Revision
+ //
+ // Compiler initializes the remaining bytes to 0
+ // These fields should be filled in in production
+ //
+ },
+ 1, // 1 for Server Platform Class
+ 0, // Reserved
+ 0, // Log Area Max Length
+ (EFI_PHYSICAL_ADDRESS) (SIZE_4GB - 1), // Log Area Start Address
+ 0x0100, // TCG Specification revision 1.0
+ 2, // Device Flags
+ 0, // Interrupt Flags
+ 0, // GPE
+ {0}, // Reserved 3 bytes
+ 0, // Global System Interrupt
+ {
+ EFI_ACPI_3_0_SYSTEM_MEMORY,
+ 0,
+ 0,
+ EFI_ACPI_3_0_BYTE,
+ 0x0 // Base Address
+ },
+ 0, // Reserved
+ {0}, // Configuration Address
+ 0xFF, // ACPI _UID value of the device, can be changed for different platforms
+ 0, // ACPI _UID value of the device, can be changed for different platforms
+ 0, // ACPI _UID value of the device, can be changed for different platforms
+ 0 // ACPI _UID value of the device, can be changed for different platforms
+};
+
+TCG_DXE_DATA mTcgDxeData = {
+ {
+ sizeof (TREE_BOOT_SERVICE_CAPABILITY_1_0), // Size
+ { 1, 0 }, // StructureVersion
+ { 1, 0 }, // ProtocolVersion
+ TREE_BOOT_HASH_ALG_SHA1, // HashAlgorithmBitmap
+ TREE_EVENT_LOG_FORMAT_TCG_1_2, // SupportedEventLogs
+ TRUE, // TrEEPresentFlag
+ TREE_DEFAULT_MAX_COMMAND_SIZE, // MaxCommandSize
+ TREE_DEFAULT_MAX_RESPONSE_SIZE, // MaxResponseSize
+ 0 // ManufacturerID
+ },
+ &mTcgClientAcpiTemplate,
+ &mTcgServerAcpiTemplate,
+};
+
+UINTN mBootAttempts = 0;
+CHAR16 mBootVarName[] = L"BootOrder";
+
+VARIABLE_TYPE mVariableType[] = {
+ {EFI_SECURE_BOOT_MODE_NAME, &gEfiGlobalVariableGuid},
+ {EFI_PLATFORM_KEY_NAME, &gEfiGlobalVariableGuid},
+ {EFI_KEY_EXCHANGE_KEY_NAME, &gEfiGlobalVariableGuid},
+ {EFI_IMAGE_SECURITY_DATABASE, &gEfiImageSecurityDatabaseGuid},
+ {EFI_IMAGE_SECURITY_DATABASE1, &gEfiImageSecurityDatabaseGuid},
+};
+
+EFI_HANDLE mImageHandle;
+
+/**
+ Measure PE image into TPM log based on the authenticode image hashing in
+ PE/COFF Specification 8.0 Appendix A.
+
+ Caution: This function may receive untrusted input.
+ PE/COFF image is external input, so this function will validate its data structure
+ within this image buffer before use.
+
+ @param[in] PCRIndex TPM PCR index
+ @param[in] ImageAddress Start address of image buffer.
+ @param[in] ImageSize Image size
+ @param[out] DigestList Digeest list of this image.
+
+ @retval EFI_SUCCESS Successfully measure image.
+ @retval EFI_OUT_OF_RESOURCES No enough resource to measure image.
+ @retval other error value
+**/
+EFI_STATUS
+MeasurePeImageAndExtend (
+ IN UINT32 PCRIndex,
+ IN EFI_PHYSICAL_ADDRESS ImageAddress,
+ IN UINTN ImageSize,
+ OUT TPML_DIGEST_VALUES *DigestList
+ );
+
+/**
+
+ This function dump raw data.
+
+ @param Data raw data
+ @param Size raw data size
+
+**/
+VOID
+InternalDumpData (
+ IN UINT8 *Data,
+ IN UINTN Size
+ )
+{
+ UINTN Index;
+ for (Index = 0; Index < Size; Index++) {
+ DEBUG ((EFI_D_INFO, "%02x", (UINTN)Data[Index]));
+ }
+}
+
+/**
+
+ This function dump raw data with colume format.
+
+ @param Data raw data
+ @param Size raw data size
+
+**/
+VOID
+InternalDumpHex (
+ IN UINT8 *Data,
+ IN UINTN Size
+ )
+{
+ UINTN Index;
+ UINTN Count;
+ UINTN Left;
+
+#define COLUME_SIZE (16 * 2)
+
+ Count = Size / COLUME_SIZE;
+ Left = Size % COLUME_SIZE;
+ for (Index = 0; Index < Count; Index++) {
+ DEBUG ((EFI_D_INFO, "%04x: ", Index * COLUME_SIZE));
+ InternalDumpData (Data + Index * COLUME_SIZE, COLUME_SIZE);
+ DEBUG ((EFI_D_INFO, "\n"));
+ }
+
+ if (Left != 0) {
+ DEBUG ((EFI_D_INFO, "%04x: ", Index * COLUME_SIZE));
+ InternalDumpData (Data + Index * COLUME_SIZE, Left);
+ DEBUG ((EFI_D_INFO, "\n"));
+ }
+}
+
+/**
+ Get All processors EFI_CPU_LOCATION in system. LocationBuf is allocated inside the function
+ Caller is responsible to free LocationBuf.
+
+ @param[out] LocationBuf Returns Processor Location Buffer.
+ @param[out] Num Returns processor number.
+
+ @retval EFI_SUCCESS Operation completed successfully.
+ @retval EFI_UNSUPPORTED MpService protocol not found.
+
+**/
+EFI_STATUS
+GetProcessorsCpuLocation (
+ OUT EFI_CPU_PHYSICAL_LOCATION **LocationBuf,
+ OUT UINTN *Num
+ )
+{
+ EFI_STATUS Status;
+ EFI_MP_SERVICES_PROTOCOL *MpProtocol;
+ UINTN ProcessorNum;
+ UINTN EnabledProcessorNum;
+ EFI_PROCESSOR_INFORMATION ProcessorInfo;
+ EFI_CPU_PHYSICAL_LOCATION *ProcessorLocBuf;
+ UINTN Index;
+
+ Status = gBS->LocateProtocol (&gEfiMpServiceProtocolGuid, NULL, (VOID **) &MpProtocol);
+ if (EFI_ERROR (Status)) {
+ //
+ // MP protocol is not installed
+ //
+ return EFI_UNSUPPORTED;
+ }
+
+ Status = MpProtocol->GetNumberOfProcessors(
+ MpProtocol,
+ &ProcessorNum,
+ &EnabledProcessorNum
+ );
+ if (EFI_ERROR(Status)){
+ return Status;
+ }
+
+ Status = gBS->AllocatePool(
+ EfiBootServicesData,
+ sizeof(EFI_CPU_PHYSICAL_LOCATION) * ProcessorNum,
+ (VOID **) &ProcessorLocBuf
+ );
+ if (EFI_ERROR(Status)){
+ return Status;
+ }
+
+ //
+ // Get each processor Location info
+ //
+ for (Index = 0; Index < ProcessorNum; Index++) {
+ Status = MpProtocol->GetProcessorInfo(
+ MpProtocol,
+ Index,
+ &ProcessorInfo
+ );
+ if (EFI_ERROR(Status)){
+ FreePool(ProcessorLocBuf);
+ return Status;
+ }
+
+ //
+ // Get all Processor Location info & measure
+ //
+ CopyMem(
+ &ProcessorLocBuf[Index],
+ &ProcessorInfo.Location,
+ sizeof(EFI_CPU_PHYSICAL_LOCATION)
+ );
+ }
+
+ *LocationBuf = ProcessorLocBuf;
+ *Num = ProcessorNum;
+
+ return Status;
+}
+
+/**
+ The EFI_TREE_PROTOCOL GetCapability function call provides protocol
+ capability information and state information about the TrEE.
+
+ @param[in] This Indicates the calling context
+ @param[in, out] ProtocolCapability The caller allocates memory for a TREE_BOOT_SERVICE_CAPABILITY
+ structure and sets the size field to the size of the structure allocated.
+ The callee fills in the fields with the EFI protocol capability information
+ and the current TrEE state information up to the number of fields which
+ fit within the size of the structure passed in.
+
+ @retval EFI_SUCCESS Operation completed successfully.
+ @retval EFI_DEVICE_ERROR The command was unsuccessful.
+ The ProtocolCapability variable will not be populated.
+ @retval EFI_INVALID_PARAMETER One or more of the parameters are incorrect.
+ The ProtocolCapability variable will not be populated.
+ @retval EFI_BUFFER_TOO_SMALL The ProtocolCapability variable is too small to hold the full response.
+ It will be partially populated (required Size field will be set).
+**/
+EFI_STATUS
+EFIAPI
+TreeGetCapability (
+ IN EFI_TREE_PROTOCOL *This,
+ IN OUT TREE_BOOT_SERVICE_CAPABILITY *ProtocolCapability
+ )
+{
+ DEBUG ((EFI_D_ERROR, "TreeGetCapability ...\n"));
+
+ if ((This == NULL) || (ProtocolCapability == NULL)) {
+ return EFI_INVALID_PARAMETER;
+ }
+
+ if (ProtocolCapability->Size < mTcgDxeData.BsCap.Size) {
+ ProtocolCapability->Size = mTcgDxeData.BsCap.Size;
+ return EFI_BUFFER_TOO_SMALL;
+ }
+
+ CopyMem (ProtocolCapability, &mTcgDxeData.BsCap, mTcgDxeData.BsCap.Size);
+ DEBUG ((EFI_D_ERROR, "TreeGetCapability - %r\n", EFI_SUCCESS));
+ return EFI_SUCCESS;
+}
+
+/**
+ This function dump event log.
+
+ @param[in] EventLogFormat The type of the event log for which the information is requested.
+ @param[in] EventLogLocation A pointer to the memory address of the event log.
+ @param[in] EventLogLastEntry If the Event Log contains more than one entry, this is a pointer to the
+ address of the start of the last entry in the event log in memory.
+**/
+VOID
+DumpEventLog (
+ IN TREE_EVENT_LOG_FORMAT EventLogFormat,
+ IN EFI_PHYSICAL_ADDRESS EventLogLocation,
+ IN EFI_PHYSICAL_ADDRESS EventLogLastEntry
+ )
+{
+ TCG_PCR_EVENT_HDR *EventHdr;
+ UINTN Index;
+
+ DEBUG ((EFI_D_INFO, "EventLogFormat: (0x%x)\n", EventLogFormat));
+
+ switch (EventLogFormat) {
+ case TREE_EVENT_LOG_FORMAT_TCG_1_2:
+ EventHdr = (TCG_PCR_EVENT_HDR *)(UINTN)EventLogLocation;
+ while ((UINTN)EventHdr <= EventLogLastEntry) {
+ DEBUG ((EFI_D_INFO, " Event:\n"));
+ DEBUG ((EFI_D_INFO, " PCRIndex - %d\n", EventHdr->PCRIndex));
+ DEBUG ((EFI_D_INFO, " EventType - 0x%08x\n", EventHdr->EventType));
+ DEBUG ((EFI_D_INFO, " Digest - "));
+ for (Index = 0; Index < sizeof(TCG_DIGEST); Index++) {
+ DEBUG ((EFI_D_INFO, "%02x ", EventHdr->Digest.digest[Index]));
+ }
+ DEBUG ((EFI_D_INFO, "\n"));
+ DEBUG ((EFI_D_INFO, " EventSize - 0x%08x\n", EventHdr->EventSize));
+ InternalDumpHex ((UINT8 *)(EventHdr + 1), EventHdr->EventSize);
+ EventHdr = (TCG_PCR_EVENT_HDR *)((UINTN)EventHdr + sizeof(TCG_PCR_EVENT_HDR) + EventHdr->EventSize);
+ }
+ break;
+ }
+
+ return ;
+}
+
+/**
+ The EFI_TREE_PROTOCOL Get Event Log function call allows a caller to
+ retrieve the address of a given event log and its last entry.
+
+ @param[in] This Indicates the calling context
+ @param[in] EventLogFormat The type of the event log for which the information is requested.
+ @param[out] EventLogLocation A pointer to the memory address of the event log.
+ @param[out] EventLogLastEntry If the Event Log contains more than one entry, this is a pointer to the
+ address of the start of the last entry in the event log in memory.
+ @param[out] EventLogTruncated If the Event Log is missing at least one entry because an event would
+ have exceeded the area allocated for events, this value is set to TRUE.
+ Otherwise, the value will be FALSE and the Event Log will be complete.
+
+ @retval EFI_SUCCESS Operation completed successfully.
+ @retval EFI_INVALID_PARAMETER One or more of the parameters are incorrect
+ (e.g. asking for an event log whose format is not supported).
+**/
+EFI_STATUS
+EFIAPI
+TreeGetEventLog (
+ IN EFI_TREE_PROTOCOL *This,
+ IN TREE_EVENT_LOG_FORMAT EventLogFormat,
+ OUT EFI_PHYSICAL_ADDRESS *EventLogLocation,
+ OUT EFI_PHYSICAL_ADDRESS *EventLogLastEntry,
+ OUT BOOLEAN *EventLogTruncated
+ )
+{
+ UINTN Index;
+
+ DEBUG ((EFI_D_ERROR, "TreeGetEventLog ...\n"));
+
+ if (This == NULL) {
+ return EFI_INVALID_PARAMETER;
+ }
+
+ for (Index = 0; Index < sizeof(mTreeEventInfo)/sizeof(mTreeEventInfo[0]); Index++) {
+ if (EventLogFormat == mTreeEventInfo[Index].LogFormat) {
+ break;
+ }
+ }
+
+ if (Index == sizeof(mTreeEventInfo)/sizeof(mTreeEventInfo[0])) {
+ return EFI_INVALID_PARAMETER;
+ }
+
+ if (!mTcgDxeData.BsCap.TrEEPresentFlag) {
+ if (EventLogLocation != NULL) {
+ *EventLogLocation = 0;
+ }
+ if (EventLogLastEntry != NULL) {
+ *EventLogLastEntry = 0;
+ }
+ if (EventLogTruncated != NULL) {
+ *EventLogTruncated = FALSE;
+ }
+ return EFI_SUCCESS;
+ }
+
+ if (EventLogLocation != NULL) {
+ *EventLogLocation = mTcgDxeData.EventLogAreaStruct[Index].Lasa;
+ DEBUG ((EFI_D_ERROR, "TreeGetEventLog (EventLogLocation - %x)\n", *EventLogLocation));
+ }
+
+ if (EventLogLastEntry != NULL) {
+ if (!mTcgDxeData.EventLogAreaStruct[Index].EventLogStarted) {
+ *EventLogLastEntry = (EFI_PHYSICAL_ADDRESS)(UINTN)0;
+ } else {
+ *EventLogLastEntry = (EFI_PHYSICAL_ADDRESS)(UINTN)mTcgDxeData.EventLogAreaStruct[Index].LastEvent;
+ }
+ DEBUG ((EFI_D_ERROR, "TreeGetEventLog (EventLogLastEntry - %x)\n", *EventLogLastEntry));
+ }
+
+ if (EventLogTruncated != NULL) {
+ *EventLogTruncated = mTcgDxeData.EventLogAreaStruct[Index].EventLogTruncated;
+ DEBUG ((EFI_D_ERROR, "TreeGetEventLog (EventLogTruncated - %x)\n", *EventLogTruncated));
+ }
+
+ DEBUG ((EFI_D_ERROR, "TreeGetEventLog - %r\n", EFI_SUCCESS));
+
+ // Dump Event Log for debug purpose
+ if ((EventLogLocation != NULL) && (EventLogLastEntry != NULL)) {
+ DumpEventLog (EventLogFormat, *EventLogLocation, *EventLogLastEntry);
+ }
+
+ return EFI_SUCCESS;
+}
+
+/**
+ Add a new entry to the Event Log.
+
+ @param[in, out] EventLogPtr Pointer to the Event Log data.
+ @param[in, out] LogSize Size of the Event Log.
+ @param[in] MaxSize Maximum size of the Event Log.
+ @param[in] NewEventHdr Pointer to a TCG_PCR_EVENT_HDR/TCG_PCR_EVENT_EX data structure.
+ @param[in] NewEventHdrSize New event header size.
+ @param[in] NewEventData Pointer to the new event data.
+ @param[in] NewEventSize New event data size.
+
+ @retval EFI_SUCCESS The new event log entry was added.
+ @retval EFI_OUT_OF_RESOURCES No enough memory to log the new event.
+
+**/
+EFI_STATUS
+TcgCommLogEvent (
+ IN OUT UINT8 **EventLogPtr,
+ IN OUT UINTN *LogSize,
+ IN UINTN MaxSize,
+ IN VOID *NewEventHdr,
+ IN UINT32 NewEventHdrSize,
+ IN UINT8 *NewEventData,
+ IN UINT32 NewEventSize
+ )
+{
+ UINTN NewLogSize;
+
+ if (NewEventSize > MAX_ADDRESS - NewEventHdrSize) {
+ return EFI_OUT_OF_RESOURCES;
+ }
+
+ NewLogSize = NewEventHdrSize + NewEventSize;
+
+ if (NewLogSize > MAX_ADDRESS - *LogSize) {
+ return EFI_OUT_OF_RESOURCES;
+ }
+
+ if (NewLogSize + *LogSize > MaxSize) {
+ DEBUG ((EFI_D_INFO, " MaxSize - 0x%x\n", MaxSize));
+ DEBUG ((EFI_D_INFO, " NewLogSize - 0x%x\n", NewLogSize));
+ DEBUG ((EFI_D_INFO, " LogSize - 0x%x\n", *LogSize));
+ DEBUG ((EFI_D_INFO, "TcgCommLogEvent - %r\n", EFI_OUT_OF_RESOURCES));
+ return EFI_OUT_OF_RESOURCES;
+ }
+
+ *EventLogPtr += *LogSize;
+ *LogSize += NewLogSize;
+ CopyMem (*EventLogPtr, NewEventHdr, NewEventHdrSize);
+ CopyMem (
+ *EventLogPtr + NewEventHdrSize,
+ NewEventData,
+ NewEventSize
+ );
+ return EFI_SUCCESS;
+}
+
+/**
+ Add a new entry to the Event Log.
+
+ @param[in] EventLogFormat The type of the event log for which the information is requested.
+ @param[in] NewEventHdr Pointer to a TCG_PCR_EVENT_HDR/TCG_PCR_EVENT_EX data structure.
+ @param[in] NewEventHdrSize New event header size.
+ @param[in] NewEventData Pointer to the new event data.
+ @param[in] NewEventSize New event data size.
+
+ @retval EFI_SUCCESS The new event log entry was added.
+ @retval EFI_OUT_OF_RESOURCES No enough memory to log the new event.
+
+**/
+EFI_STATUS
+TcgDxeLogEvent (
+ IN TREE_EVENT_LOG_FORMAT EventLogFormat,
+ IN VOID *NewEventHdr,
+ IN UINT32 NewEventHdrSize,
+ IN UINT8 *NewEventData,
+ IN UINT32 NewEventSize
+ )
+{
+ EFI_STATUS Status;
+ UINTN Index;
+
+ for (Index = 0; Index < sizeof(mTreeEventInfo)/sizeof(mTreeEventInfo[0]); Index++) {
+ if (EventLogFormat == mTreeEventInfo[Index].LogFormat) {
+ break;
+ }
+ }
+
+ if (Index == sizeof(mTreeEventInfo)/sizeof(mTreeEventInfo[0])) {
+ return EFI_INVALID_PARAMETER;
+ }
+
+ if (mTcgDxeData.EventLogAreaStruct[Index].EventLogTruncated) {
+ return EFI_VOLUME_FULL;
+ }
+
+ mTcgDxeData.EventLogAreaStruct[Index].LastEvent = (UINT8*)(UINTN)mTcgDxeData.EventLogAreaStruct[Index].Lasa;
+ Status = TcgCommLogEvent (
+ &mTcgDxeData.EventLogAreaStruct[Index].LastEvent,
+ &mTcgDxeData.EventLogAreaStruct[Index].EventLogSize,
+ (UINTN)mTcgDxeData.EventLogAreaStruct[Index].Laml,
+ NewEventHdr,
+ NewEventHdrSize,
+ NewEventData,
+ NewEventSize
+ );
+
+ if (Status == EFI_DEVICE_ERROR) {
+ return EFI_DEVICE_ERROR;
+ } else if (Status == EFI_OUT_OF_RESOURCES) {
+ mTcgDxeData.EventLogAreaStruct[Index].EventLogTruncated = TRUE;
+ return EFI_VOLUME_FULL;
+ } else if (Status == EFI_SUCCESS) {
+ mTcgDxeData.EventLogAreaStruct[Index].EventLogStarted = TRUE;
+ }
+
+ return Status;
+}
+
+/**
+ This function return hash algorithm from event log format.
+
+ @param[in] EventLogFormat Event log format.
+
+ @return hash algorithm.
+**/
+TPMI_ALG_HASH
+TrEEGetHashAlgoFromLogFormat (
+ IN TREE_EVENT_LOG_FORMAT EventLogFormat
+ )
+{
+ UINTN Index;
+
+ for (Index = 0; Index < sizeof(mTreeEventInfo)/sizeof(mTreeEventInfo[0]); Index++) {
+ if (mTreeEventInfo[Index].LogFormat == EventLogFormat) {
+ return mTreeEventInfo[Index].TpmHashAlgo;
+ }
+ }
+ return TPM_ALG_SHA1;
+}
+
+/**
+ This function return hash algorithm ID from event log format.
+
+ @param[in] EventLogFormat Event log format.
+
+ @return hash algorithm ID.
+**/
+UINT16
+TrEEGetAlgIDFromLogFormat (
+ IN TREE_EVENT_LOG_FORMAT EventLogFormat
+ )
+{
+ UINTN Index;
+
+ for (Index = 0; Index < sizeof(mTreeEventInfo)/sizeof(mTreeEventInfo[0]); Index++) {
+ if (mTreeEventInfo[Index].LogFormat == EventLogFormat) {
+ return mTreeEventInfo[Index].DigestAlgID;
+ }
+ }
+ return 0;
+}
+
+/**
+ This function return boot hash algorithm from event log format.
+
+ @param[in] EventLogFormat Event log format.
+
+ @return boot hash algorithm.
+**/
+UINT32
+TrEEGetBootHashAlgFromLogFormat (
+ IN TREE_EVENT_LOG_FORMAT EventLogFormat
+ )
+{
+ UINTN Index;
+
+ for (Index = 0; Index < sizeof(mTreeEventInfo)/sizeof(mTreeEventInfo[0]); Index++) {
+ if (mTreeEventInfo[Index].LogFormat == EventLogFormat) {
+ return mTreeEventInfo[Index].BootHashAlg;
+ }
+ }
+ return TREE_BOOT_HASH_ALG_SHA1;
+}
+
+/**
+ This function get digest from digest list.
+
+ @param HashAlg digest algorithm
+ @param DigestList digest list
+ @param Digest digest
+
+ @retval EFI_SUCCESS Sha1Digest is found and returned.
+ @retval EFI_NOT_FOUND Sha1Digest is not found.
+**/
+EFI_STATUS
+Tpm2GetDigestFromDigestList (
+ IN TPMI_ALG_HASH HashAlg,
+ IN TPML_DIGEST_VALUES *DigestList,
+ IN VOID *Digest
+ )
+{
+ UINTN Index;
+ UINT16 DigestSize;
+
+ DigestSize = GetHashSizeFromAlgo (HashAlg);
+ for (Index = 0; Index < DigestList->count; Index++) {
+ if (DigestList->digests[Index].hashAlg == HashAlg) {
+ CopyMem (
+ Digest,
+ &DigestList->digests[Index].digest,
+ DigestSize
+ );
+ return EFI_SUCCESS;
+ }
+ }
+
+ return EFI_NOT_FOUND;
+}
+
+/**
+ Add a new entry to the Event Log.
+
+ @param[in] DigestList A list of digest.
+ @param[in,out] NewEventHdr Pointer to a TCG_PCR_EVENT_HDR data structure.
+ @param[in] NewEventData Pointer to the new event data.
+
+ @retval EFI_SUCCESS The new event log entry was added.
+ @retval EFI_OUT_OF_RESOURCES No enough memory to log the new event.
+**/
+EFI_STATUS
+TcgDxeLogHashEvent (
+ IN TPML_DIGEST_VALUES *DigestList,
+ IN OUT TCG_PCR_EVENT_HDR *NewEventHdr,
+ IN UINT8 *NewEventData
+ )
+{
+ EFI_STATUS Status;
+ EFI_TPL OldTpl;
+ UINTN Index;
+ EFI_STATUS RetStatus;
+
+ RetStatus = EFI_SUCCESS;
+ for (Index = 0; Index < sizeof(mTreeEventInfo)/sizeof(mTreeEventInfo[0]); Index++) {
+ DEBUG ((EFI_D_INFO, " LogFormat - 0x%08x\n", mTreeEventInfo[Index].LogFormat));
+ switch (mTreeEventInfo[Index].LogFormat) {
+ case TREE_EVENT_LOG_FORMAT_TCG_1_2:
+ Status = Tpm2GetDigestFromDigestList (TPM_ALG_SHA1, DigestList, &NewEventHdr->Digest);
+ if (!EFI_ERROR (Status)) {
+ //
+ // Enter critical region
+ //
+ OldTpl = gBS->RaiseTPL (TPL_HIGH_LEVEL);
+ Status = TcgDxeLogEvent (
+ mTreeEventInfo[Index].LogFormat,
+ NewEventHdr,
+ sizeof(TCG_PCR_EVENT_HDR),
+ NewEventData,
+ NewEventHdr->EventSize
+ );
+ if (Status != EFI_SUCCESS) {
+ RetStatus = Status;
+ }
+ gBS->RestoreTPL (OldTpl);
+ //
+ // Exit critical region
+ //
+ }
+ break;
+ }
+ }
+
+ return RetStatus;
+}
+
+/**
+ Do a hash operation on a data buffer, extend a specific TPM PCR with the hash result,
+ and add an entry to the Event Log.
+
+ @param[in] Flags Bitmap providing additional information.
+ @param[in] HashData Physical address of the start of the data buffer
+ to be hashed, extended, and logged.
+ @param[in] HashDataLen The length, in bytes, of the buffer referenced by HashData
+ @param[in, out] NewEventHdr Pointer to a TCG_PCR_EVENT_HDR data structure.
+ @param[in] NewEventData Pointer to the new event data.
+
+ @retval EFI_SUCCESS Operation completed successfully.
+ @retval EFI_OUT_OF_RESOURCES No enough memory to log the new event.
+ @retval EFI_DEVICE_ERROR The command was unsuccessful.
+
+**/
+EFI_STATUS
+TcgDxeHashLogExtendEvent (
+ IN UINT64 Flags,
+ IN UINT8 *HashData,
+ IN UINT64 HashDataLen,
+ IN OUT TCG_PCR_EVENT_HDR *NewEventHdr,
+ IN UINT8 *NewEventData
+ )
+{
+ EFI_STATUS Status;
+ TPML_DIGEST_VALUES DigestList;
+
+ Status = HashAndExtend (
+ NewEventHdr->PCRIndex,
+ HashData,
+ (UINTN)HashDataLen,
+ &DigestList
+ );
+ if (!EFI_ERROR (Status)) {
+ if ((Flags & TREE_EXTEND_ONLY) == 0) {
+ Status = TcgDxeLogHashEvent (&DigestList, NewEventHdr, NewEventData);
+ }
+ }
+
+ return Status;
+}
+
+/**
+ The EFI_TREE_PROTOCOL HashLogExtendEvent function call provides callers with
+ an opportunity to extend and optionally log events without requiring
+ knowledge of actual TPM commands.
+ The extend operation will occur even if this function cannot create an event
+ log entry (e.g. due to the event log being full).
+
+ @param[in] This Indicates the calling context
+ @param[in] Flags Bitmap providing additional information.
+ @param[in] DataToHash Physical address of the start of the data buffer to be hashed.
+ @param[in] DataToHashLen The length in bytes of the buffer referenced by DataToHash.
+ @param[in] Event Pointer to data buffer containing information about the event.
+
+ @retval EFI_SUCCESS Operation completed successfully.
+ @retval EFI_DEVICE_ERROR The command was unsuccessful.
+ @retval EFI_VOLUME_FULL The extend operation occurred, but the event could not be written to one or more event logs.
+ @retval EFI_INVALID_PARAMETER One or more of the parameters are incorrect.
+ @retval EFI_UNSUPPORTED The PE/COFF image type is not supported.
+**/
+EFI_STATUS
+EFIAPI
+TreeHashLogExtendEvent (
+ IN EFI_TREE_PROTOCOL *This,
+ IN UINT64 Flags,
+ IN EFI_PHYSICAL_ADDRESS DataToHash,
+ IN UINT64 DataToHashLen,
+ IN TrEE_EVENT *Event
+ )
+{
+ EFI_STATUS Status;
+ TCG_PCR_EVENT_HDR NewEventHdr;
+ TPML_DIGEST_VALUES DigestList;
+
+ DEBUG ((EFI_D_ERROR, "TreeHashLogExtendEvent ...\n"));
+
+ if ((This == NULL) || (DataToHash == 0) || (Event == NULL)) {
+ return EFI_INVALID_PARAMETER;
+ }
+
+ if (!mTcgDxeData.BsCap.TrEEPresentFlag) {
+ return EFI_UNSUPPORTED;
+ }
+
+ if (Event->Size < Event->Header.HeaderSize + sizeof(UINT32)) {
+ return EFI_INVALID_PARAMETER;
+ }
+
+ if (Event->Header.PCRIndex > MAX_PCR_INDEX) {
+ return EFI_INVALID_PARAMETER;
+ }
+
+ NewEventHdr.PCRIndex = Event->Header.PCRIndex;
+ NewEventHdr.EventType = Event->Header.EventType;
+ NewEventHdr.EventSize = Event->Size - sizeof(UINT32) - Event->Header.HeaderSize;
+ if ((Flags & PE_COFF_IMAGE) != 0) {
+ Status = MeasurePeImageAndExtend (
+ NewEventHdr.PCRIndex,
+ DataToHash,
+ (UINTN)DataToHashLen,
+ &DigestList
+ );
+ if (!EFI_ERROR (Status)) {
+ if ((Flags & TREE_EXTEND_ONLY) == 0) {
+ Status = TcgDxeLogHashEvent (&DigestList, &NewEventHdr, Event->Event);
+ }
+ }
+ } else {
+ Status = TcgDxeHashLogExtendEvent (
+ Flags,
+ (UINT8 *) (UINTN) DataToHash,
+ DataToHashLen,
+ &NewEventHdr,
+ Event->Event
+ );
+ }
+ DEBUG ((EFI_D_ERROR, "TreeHashLogExtendEvent - %r\n", Status));
+ return Status;
+}
+
+/**
+ This service enables the sending of commands to the TrEE.
+
+ @param[in] This Indicates the calling context
+ @param[in] InputParameterBlockSize Size of the TrEE input parameter block.
+ @param[in] InputParameterBlock Pointer to the TrEE input parameter block.
+ @param[in] OutputParameterBlockSize Size of the TrEE output parameter block.
+ @param[in] OutputParameterBlock Pointer to the TrEE output parameter block.
+
+ @retval EFI_SUCCESS The command byte stream was successfully sent to the device and a response was successfully received.
+ @retval EFI_DEVICE_ERROR The command was not successfully sent to the device or a response was not successfully received from the device.
+ @retval EFI_INVALID_PARAMETER One or more of the parameters are incorrect.
+ @retval EFI_BUFFER_TOO_SMALL The output parameter block is too small.
+**/
+EFI_STATUS
+EFIAPI
+TreeSubmitCommand (
+ IN EFI_TREE_PROTOCOL *This,
+ IN UINT32 InputParameterBlockSize,
+ IN UINT8 *InputParameterBlock,
+ IN UINT32 OutputParameterBlockSize,
+ IN UINT8 *OutputParameterBlock
+ )
+{
+ EFI_STATUS Status;
+
+ DEBUG ((EFI_D_ERROR, "TreeSubmitCommand ...\n"));
+
+ if ((This == NULL) ||
+ (InputParameterBlockSize == 0) || (InputParameterBlock == NULL) ||
+ (OutputParameterBlockSize == 0) || (OutputParameterBlock == NULL)) {
+ return EFI_INVALID_PARAMETER;
+ }
+
+ if (!mTcgDxeData.BsCap.TrEEPresentFlag) {
+ return EFI_UNSUPPORTED;
+ }
+
+ if (InputParameterBlockSize >= mTcgDxeData.BsCap.MaxCommandSize) {
+ return EFI_INVALID_PARAMETER;
+ }
+ if (OutputParameterBlockSize >= mTcgDxeData.BsCap.MaxResponseSize) {
+ return EFI_INVALID_PARAMETER;
+ }
+
+ Status = Tpm2SubmitCommand (
+ InputParameterBlockSize,
+ InputParameterBlock,
+ &OutputParameterBlockSize,
+ OutputParameterBlock
+ );
+ DEBUG ((EFI_D_ERROR, "TreeSubmitCommand - %r\n", Status));
+ return Status;
+}
+
+
+EFI_TREE_PROTOCOL mTreeProtocol = {
+ TreeGetCapability,
+ TreeGetEventLog,
+ TreeHashLogExtendEvent,
+ TreeSubmitCommand
+};
+
+/**
+ Initialize the Event Log and log events passed from the PEI phase.
+
+ @retval EFI_SUCCESS Operation completed successfully.
+ @retval EFI_OUT_OF_RESOURCES Out of memory.
+
+**/
+EFI_STATUS
+SetupEventLog (
+ VOID
+ )
+{
+ EFI_STATUS Status;
+ VOID *TcgEvent;
+ EFI_PEI_HOB_POINTERS GuidHob;
+ EFI_PHYSICAL_ADDRESS Lasa;
+ UINTN Index;
+
+ DEBUG ((EFI_D_INFO, "SetupEventLog\n"));
+
+ //
+ // 1. Create Log Area
+ //
+ for (Index = 0; Index < sizeof(mTreeEventInfo)/sizeof(mTreeEventInfo[0]); Index++) {
+ mTcgDxeData.EventLogAreaStruct[Index].EventLogFormat = mTreeEventInfo[Index].LogFormat;
+ Lasa = (EFI_PHYSICAL_ADDRESS) (SIZE_4GB - 1);
+ Status = gBS->AllocatePages (
+ AllocateMaxAddress,
+ EfiACPIMemoryNVS,
+ EFI_SIZE_TO_PAGES (EFI_TCG_LOG_AREA_SIZE),
+ &Lasa
+ );
+ if (EFI_ERROR (Status)) {
+ return Status;
+ }
+ mTcgDxeData.EventLogAreaStruct[Index].Lasa = Lasa;
+ mTcgDxeData.EventLogAreaStruct[Index].Laml = EFI_TCG_LOG_AREA_SIZE;
+ //
+ // To initialize them as 0xFF is recommended
+ // because the OS can know the last entry for that.
+ //
+ SetMem ((VOID *)(UINTN)Lasa, EFI_TCG_LOG_AREA_SIZE, 0xFF);
+ }
+
+ //
+ // 2. Create ACPI table for TCG1.2 only
+ //
+ if (PcdGet8 (PcdTpmPlatformClass) == TCG_PLATFORM_TYPE_CLIENT) {
+ mTcgClientAcpiTemplate.Lasa = mTcgDxeData.EventLogAreaStruct[0].Lasa;
+ mTcgClientAcpiTemplate.Laml = EFI_TCG_LOG_AREA_SIZE;
+ } else {
+ mTcgServerAcpiTemplate.Lasa = mTcgDxeData.EventLogAreaStruct[0].Lasa;
+ mTcgServerAcpiTemplate.Laml = EFI_TCG_LOG_AREA_SIZE;
+ }
+
+ //
+ // 3. Sync data from PEI to DXE
+ //
+ Status = EFI_SUCCESS;
+ for (Index = 0; Index < sizeof(mTreeEventInfo)/sizeof(mTreeEventInfo[0]); Index++) {
+ GuidHob.Raw = GetHobList ();
+ Status = EFI_SUCCESS;
+ while (!EFI_ERROR (Status) &&
+ (GuidHob.Raw = GetNextGuidHob (mTreeEventInfo[Index].EventGuid, GuidHob.Raw)) != NULL) {
+ TcgEvent = GET_GUID_HOB_DATA (GuidHob.Guid);
+ GuidHob.Raw = GET_NEXT_HOB (GuidHob);
+ switch (mTreeEventInfo[Index].LogFormat) {
+ case TREE_EVENT_LOG_FORMAT_TCG_1_2:
+ Status = TcgDxeLogEvent (
+ mTreeEventInfo[Index].LogFormat,
+ TcgEvent,
+ sizeof(TCG_PCR_EVENT_HDR),
+ ((TCG_PCR_EVENT*)TcgEvent)->Event,
+ ((TCG_PCR_EVENT_HDR*)TcgEvent)->EventSize
+ );
+ break;
+ }
+ }
+ }
+
+ return Status;
+}
+
+/**
+ Measure and log an action string, and extend the measurement result into PCR[5].
+
+ @param[in] String A specific string that indicates an Action event.
+
+ @retval EFI_SUCCESS Operation completed successfully.
+ @retval EFI_DEVICE_ERROR The operation was unsuccessful.
+
+**/
+EFI_STATUS
+TcgMeasureAction (
+ IN CHAR8 *String
+ )
+{
+ TCG_PCR_EVENT_HDR TcgEvent;
+
+ TcgEvent.PCRIndex = 5;
+ TcgEvent.EventType = EV_EFI_ACTION;
+ TcgEvent.EventSize = (UINT32)AsciiStrLen (String);
+ return TcgDxeHashLogExtendEvent (
+ 0,
+ (UINT8*)String,
+ TcgEvent.EventSize,
+ &TcgEvent,
+ (UINT8 *) String
+ );
+}
+
+/**
+ Measure and log EFI handoff tables, and extend the measurement result into PCR[1].
+
+ @retval EFI_SUCCESS Operation completed successfully.
+ @retval EFI_DEVICE_ERROR The operation was unsuccessful.
+
+**/
+EFI_STATUS
+MeasureHandoffTables (
+ VOID
+ )
+{
+ EFI_STATUS Status;
+ SMBIOS_TABLE_ENTRY_POINT *SmbiosTable;
+ TCG_PCR_EVENT_HDR TcgEvent;
+ EFI_HANDOFF_TABLE_POINTERS HandoffTables;
+ UINTN ProcessorNum;
+ EFI_CPU_PHYSICAL_LOCATION *ProcessorLocBuf;
+
+ //
+ // Measure SMBIOS with EV_EFI_HANDOFF_TABLES to PCR[1]
+ //
+ Status = EfiGetSystemConfigurationTable (
+ &gEfiSmbiosTableGuid,
+ (VOID **) &SmbiosTable
+ );
+
+ if (!EFI_ERROR (Status)) {
+ ASSERT (SmbiosTable != NULL);
+
+ TcgEvent.PCRIndex = 1;
+ TcgEvent.EventType = EV_EFI_HANDOFF_TABLES;
+ TcgEvent.EventSize = sizeof (HandoffTables);
+
+ HandoffTables.NumberOfTables = 1;
+ HandoffTables.TableEntry[0].VendorGuid = gEfiSmbiosTableGuid;
+ HandoffTables.TableEntry[0].VendorTable = SmbiosTable;
+
+ DEBUG ((DEBUG_INFO, "The Smbios Table starts at: 0x%x\n", SmbiosTable->TableAddress));
+ DEBUG ((DEBUG_INFO, "The Smbios Table size: 0x%x\n", SmbiosTable->TableLength));
+
+ Status = TcgDxeHashLogExtendEvent (
+ 0,
+ (UINT8*)(UINTN)SmbiosTable->TableAddress,
+ SmbiosTable->TableLength,
+ &TcgEvent,
+ (UINT8*)&HandoffTables
+ );
+ }
+
+ if (PcdGet8 (PcdTpmPlatformClass) == TCG_PLATFORM_TYPE_SERVER) {
+ //
+ // Tcg Server spec.
+ // Measure each processor EFI_CPU_PHYSICAL_LOCATION with EV_TABLE_OF_DEVICES to PCR[1]
+ //
+ Status = GetProcessorsCpuLocation(&ProcessorLocBuf, &ProcessorNum);
+
+ if (!EFI_ERROR(Status)){
+ TcgEvent.PCRIndex = 1;
+ TcgEvent.EventType = EV_TABLE_OF_DEVICES;
+ TcgEvent.EventSize = sizeof (HandoffTables);
+
+ HandoffTables.NumberOfTables = 1;
+ HandoffTables.TableEntry[0].VendorGuid = gEfiMpServiceProtocolGuid;
+ HandoffTables.TableEntry[0].VendorTable = ProcessorLocBuf;
+
+ Status = TcgDxeHashLogExtendEvent (
+ 0,
+ (UINT8*)(UINTN)ProcessorLocBuf,
+ sizeof(EFI_CPU_PHYSICAL_LOCATION) * ProcessorNum,
+ &TcgEvent,
+ (UINT8*)&HandoffTables
+ );
+
+ FreePool(ProcessorLocBuf);
+ }
+ }
+
+ return Status;
+}
+
+/**
+ Measure and log Separator event, and extend the measurement result into a specific PCR.
+
+ @param[in] PCRIndex PCR index.
+
+ @retval EFI_SUCCESS Operation completed successfully.
+ @retval EFI_DEVICE_ERROR The operation was unsuccessful.
+
+**/
+EFI_STATUS
+MeasureSeparatorEvent (
+ IN TPM_PCRINDEX PCRIndex
+ )
+{
+ TCG_PCR_EVENT_HDR TcgEvent;
+ UINT32 EventData;
+
+ DEBUG ((EFI_D_ERROR, "MeasureSeparatorEvent Pcr - %x\n", PCRIndex));
+
+ EventData = 0;
+ TcgEvent.PCRIndex = PCRIndex;
+ TcgEvent.EventType = EV_SEPARATOR;
+ TcgEvent.EventSize = (UINT32)sizeof (EventData);
+ return TcgDxeHashLogExtendEvent (
+ 0,
+ (UINT8 *)&EventData,
+ sizeof (EventData),
+ &TcgEvent,
+ (UINT8 *)&EventData
+ );
+}
+
+/**
+ Measure and log an EFI variable, and extend the measurement result into a specific PCR.
+
+ @param[in] PCRIndex PCR Index.
+ @param[in] EventType Event type.
+ @param[in] VarName A Null-terminated string that is the name of the vendor's variable.
+ @param[in] VendorGuid A unique identifier for the vendor.
+ @param[in] VarData The content of the variable data.
+ @param[in] VarSize The size of the variable data.
+
+ @retval EFI_SUCCESS Operation completed successfully.
+ @retval EFI_OUT_OF_RESOURCES Out of memory.
+ @retval EFI_DEVICE_ERROR The operation was unsuccessful.
+
+**/
+EFI_STATUS
+MeasureVariable (
+ IN TPM_PCRINDEX PCRIndex,
+ IN TCG_EVENTTYPE EventType,
+ IN CHAR16 *VarName,
+ IN EFI_GUID *VendorGuid,
+ IN VOID *VarData,
+ IN UINTN VarSize
+ )
+{
+ EFI_STATUS Status;
+ TCG_PCR_EVENT_HDR TcgEvent;
+ UINTN VarNameLength;
+ EFI_VARIABLE_DATA_TREE *VarLog;
+
+ ASSERT ((VarSize == 0 && VarData == NULL) || (VarSize != 0 && VarData != NULL));
+
+ DEBUG ((EFI_D_ERROR, "TrEEDxe: MeasureVariable (Pcr - %x, EventType - %x, ", (UINTN)PCRIndex, (UINTN)EventType));
+ DEBUG ((EFI_D_ERROR, "VariableName - %s, VendorGuid - %g)\n", VarName, VendorGuid));
+
+ VarNameLength = StrLen (VarName);
+ TcgEvent.PCRIndex = PCRIndex;
+ TcgEvent.EventType = EventType;
+ TcgEvent.EventSize = (UINT32)(sizeof (*VarLog) + VarNameLength * sizeof (*VarName) + VarSize
+ - sizeof (VarLog->UnicodeName) - sizeof (VarLog->VariableData));
+
+ VarLog = (EFI_VARIABLE_DATA_TREE*)AllocatePool (TcgEvent.EventSize);
+ if (VarLog == NULL) {
+ return EFI_OUT_OF_RESOURCES;
+ }
+
+ VarLog->VariableName = *VendorGuid;
+ VarLog->UnicodeNameLength = VarNameLength;
+ VarLog->VariableDataLength = VarSize;
+ CopyMem (
+ VarLog->UnicodeName,
+ VarName,
+ VarNameLength * sizeof (*VarName)
+ );
+ if (VarSize != 0) {
+ CopyMem (
+ (CHAR16 *)VarLog->UnicodeName + VarNameLength,
+ VarData,
+ VarSize
+ );
+ }
+
+ if (EventType == EV_EFI_VARIABLE_DRIVER_CONFIG) {
+ //
+ // Digest is the event data (EFI_VARIABLE_DATA_TREE)
+ //
+ Status = TcgDxeHashLogExtendEvent (
+ 0,
+ (UINT8*)VarLog,
+ TcgEvent.EventSize,
+ &TcgEvent,
+ (UINT8*)VarLog
+ );
+ } else {
+ Status = TcgDxeHashLogExtendEvent (
+ 0,
+ (UINT8*)VarData,
+ VarSize,
+ &TcgEvent,
+ (UINT8*)VarLog
+ );
+ }
+ FreePool (VarLog);
+ return Status;
+}
+
+/**
+ Read then Measure and log an EFI variable, and extend the measurement result into a specific PCR.
+
+ @param[in] PCRIndex PCR Index.
+ @param[in] EventType Event type.
+ @param[in] VarName A Null-terminated string that is the name of the vendor's variable.
+ @param[in] VendorGuid A unique identifier for the vendor.
+ @param[out] VarSize The size of the variable data.
+ @param[out] VarData Pointer to the content of the variable.
+
+ @retval EFI_SUCCESS Operation completed successfully.
+ @retval EFI_OUT_OF_RESOURCES Out of memory.
+ @retval EFI_DEVICE_ERROR The operation was unsuccessful.
+
+**/
+EFI_STATUS
+ReadAndMeasureVariable (
+ IN TPM_PCRINDEX PCRIndex,
+ IN TCG_EVENTTYPE EventType,
+ IN CHAR16 *VarName,
+ IN EFI_GUID *VendorGuid,
+ OUT UINTN *VarSize,
+ OUT VOID **VarData
+ )
+{
+ EFI_STATUS Status;
+
+ Status = GetVariable2 (VarName, VendorGuid, VarData, VarSize);
+ if (EventType == EV_EFI_VARIABLE_DRIVER_CONFIG) {
+ if (EFI_ERROR (Status)) {
+ //
+ // It is valid case, so we need handle it.
+ //
+ *VarData = NULL;
+ *VarSize = 0;
+ }
+ } else {
+ if (EFI_ERROR (Status)) {
+ return Status;
+ }
+ ASSERT (*VarData != NULL);
+ }
+
+ Status = MeasureVariable (
+ PCRIndex,
+ EventType,
+ VarName,
+ VendorGuid,
+ *VarData,
+ *VarSize
+ );
+ return Status;
+}
+
+/**
+ Read then Measure and log an EFI boot variable, and extend the measurement result into PCR[5].
+
+ @param[in] VarName A Null-terminated string that is the name of the vendor's variable.
+ @param[in] VendorGuid A unique identifier for the vendor.
+ @param[out] VarSize The size of the variable data.
+ @param[out] VarData Pointer to the content of the variable.
+
+ @retval EFI_SUCCESS Operation completed successfully.
+ @retval EFI_OUT_OF_RESOURCES Out of memory.
+ @retval EFI_DEVICE_ERROR The operation was unsuccessful.
+
+**/
+EFI_STATUS
+ReadAndMeasureBootVariable (
+ IN CHAR16 *VarName,
+ IN EFI_GUID *VendorGuid,
+ OUT UINTN *VarSize,
+ OUT VOID **VarData
+ )
+{
+ return ReadAndMeasureVariable (
+ 5,
+ EV_EFI_VARIABLE_BOOT,
+ VarName,
+ VendorGuid,
+ VarSize,
+ VarData
+ );
+}
+
+/**
+ Read then Measure and log an EFI Secure variable, and extend the measurement result into PCR[7].
+
+ @param[in] VarName A Null-terminated string that is the name of the vendor's variable.
+ @param[in] VendorGuid A unique identifier for the vendor.
+ @param[out] VarSize The size of the variable data.
+ @param[out] VarData Pointer to the content of the variable.
+
+ @retval EFI_SUCCESS Operation completed successfully.
+ @retval EFI_OUT_OF_RESOURCES Out of memory.
+ @retval EFI_DEVICE_ERROR The operation was unsuccessful.
+
+**/
+EFI_STATUS
+ReadAndMeasureSecureVariable (
+ IN CHAR16 *VarName,
+ IN EFI_GUID *VendorGuid,
+ OUT UINTN *VarSize,
+ OUT VOID **VarData
+ )
+{
+ return ReadAndMeasureVariable (
+ 7,
+ EV_EFI_VARIABLE_DRIVER_CONFIG,
+ VarName,
+ VendorGuid,
+ VarSize,
+ VarData
+ );
+}
+
+/**
+ Measure and log all EFI boot variables, and extend the measurement result into a specific PCR.
+
+ The EFI boot variables are BootOrder and Boot#### variables.
+
+ @retval EFI_SUCCESS Operation completed successfully.
+ @retval EFI_OUT_OF_RESOURCES Out of memory.
+ @retval EFI_DEVICE_ERROR The operation was unsuccessful.
+
+**/
+EFI_STATUS
+MeasureAllBootVariables (
+ VOID
+ )
+{
+ EFI_STATUS Status;
+ UINT16 *BootOrder;
+ UINTN BootCount;
+ UINTN Index;
+ VOID *BootVarData;
+ UINTN Size;
+
+ Status = ReadAndMeasureBootVariable (
+ mBootVarName,
+ &gEfiGlobalVariableGuid,
+ &BootCount,
+ (VOID **) &BootOrder
+ );
+ if (Status == EFI_NOT_FOUND) {
+ return EFI_SUCCESS;
+ }
+ ASSERT (BootOrder != NULL);
+
+ if (EFI_ERROR (Status)) {
+ FreePool (BootOrder);
+ return Status;
+ }
+
+ BootCount /= sizeof (*BootOrder);
+ for (Index = 0; Index < BootCount; Index++) {
+ UnicodeSPrint (mBootVarName, sizeof (mBootVarName), L"Boot%04x", BootOrder[Index]);
+ Status = ReadAndMeasureBootVariable (
+ mBootVarName,
+ &gEfiGlobalVariableGuid,
+ &Size,
+ &BootVarData
+ );
+ if (!EFI_ERROR (Status)) {
+ FreePool (BootVarData);
+ }
+ }
+
+ FreePool (BootOrder);
+ return EFI_SUCCESS;
+}
+
+/**
+ Measure and log all EFI Secure variables, and extend the measurement result into a specific PCR.
+
+ The EFI boot variables are BootOrder and Boot#### variables.
+
+ @retval EFI_SUCCESS Operation completed successfully.
+ @retval EFI_OUT_OF_RESOURCES Out of memory.
+ @retval EFI_DEVICE_ERROR The operation was unsuccessful.
+
+**/
+EFI_STATUS
+MeasureAllSecureVariables (
+ VOID
+ )
+{
+ EFI_STATUS Status;
+ VOID *Data;
+ UINTN DataSize;
+ UINTN Index;
+
+ Status = EFI_NOT_FOUND;
+ for (Index = 0; Index < sizeof(mVariableType)/sizeof(mVariableType[0]); Index++) {
+ Status = ReadAndMeasureSecureVariable (
+ mVariableType[Index].VariableName,
+ mVariableType[Index].VendorGuid,
+ &DataSize,
+ &Data
+ );
+ if (!EFI_ERROR (Status)) {
+ if (Data != NULL) {
+ FreePool (Data);
+ }
+ }
+ }
+
+ return EFI_SUCCESS;
+}
+
+/**
+ Measure and log launch of FirmwareDebugger, and extend the measurement result into a specific PCR.
+
+ @retval EFI_SUCCESS Operation completed successfully.
+ @retval EFI_OUT_OF_RESOURCES Out of memory.
+ @retval EFI_DEVICE_ERROR The operation was unsuccessful.
+
+**/
+EFI_STATUS
+MeasureLaunchOfFirmwareDebugger (
+ VOID
+ )
+{
+ TCG_PCR_EVENT_HDR TcgEvent;
+
+ TcgEvent.PCRIndex = 7;
+ TcgEvent.EventType = EV_EFI_ACTION;
+ TcgEvent.EventSize = sizeof(FIRMWARE_DEBUGGER_EVENT_STRING) - 1;
+ return TcgDxeHashLogExtendEvent (
+ 0,
+ (UINT8 *)FIRMWARE_DEBUGGER_EVENT_STRING,
+ sizeof(FIRMWARE_DEBUGGER_EVENT_STRING) - 1,
+ &TcgEvent,
+ (UINT8 *)FIRMWARE_DEBUGGER_EVENT_STRING
+ );
+}
+
+/**
+ Measure and log all Secure Boot Policy, and extend the measurement result into a specific PCR.
+
+ Platform firmware adhering to the policy must therefore measure the following values into PCR[7]: (in order listed)
+ - The contents of the SecureBoot variable
+ - The contents of the PK variable
+ - The contents of the KEK variable
+ - The contents of the EFI_IMAGE_SECURITY_DATABASE variable
+ - The contents of the EFI_IMAGE_SECURITY_DATABASE1 variable
+ - Separator
+ - Entries in the EFI_IMAGE_SECURITY_DATABASE that are used to validate EFI Drivers or EFI Boot Applications in the boot path
+
+ NOTE: Because of the above, UEFI variables PK, KEK, EFI_IMAGE_SECURITY_DATABASE,
+ EFI_IMAGE_SECURITY_DATABASE1 and SecureBoot SHALL NOT be measured into PCR[3].
+
+ @param[in] Event Event whose notification function is being invoked
+ @param[in] Context Pointer to the notification function's context
+**/
+VOID
+EFIAPI
+MeasureSecureBootPolicy (
+ IN EFI_EVENT Event,
+ IN VOID *Context
+ )
+{
+ EFI_STATUS Status;
+ VOID *Protocol;
+
+ Status = gBS->LocateProtocol (&gEfiVariableWriteArchProtocolGuid, NULL, (VOID **)&Protocol);
+ if (EFI_ERROR (Status)) {
+ return;
+ }
+
+ if (PcdGetBool (PcdFirmwareDebuggerInitialized)) {
+ Status = MeasureLaunchOfFirmwareDebugger ();
+ DEBUG ((EFI_D_ERROR, "MeasureLaunchOfFirmwareDebugger - %r\n", Status));
+ }
+
+ Status = MeasureAllSecureVariables ();
+ DEBUG ((EFI_D_ERROR, "MeasureAllSecureVariables - %r\n", Status));
+
+ //
+ // We need measure Separator(7) here, because this event must be between SecureBootPolicy (Configure)
+ // and ImageVerification (Authority)
+ // There might be a case that we need measure UEFI image from DriverOrder, besides BootOrder. So
+ // the Authority measurement happen before ReadToBoot event.
+ //
+ Status = MeasureSeparatorEvent (7);
+ DEBUG ((EFI_D_ERROR, "MeasureSeparatorEvent - %r\n", Status));
+ return ;
+}
+
+/**
+ Ready to Boot Event notification handler.
+
+ Sequence of OS boot events is measured in this event notification handler.
+
+ @param[in] Event Event whose notification function is being invoked
+ @param[in] Context Pointer to the notification function's context
+
+**/
+VOID
+EFIAPI
+OnReadyToBoot (
+ IN EFI_EVENT Event,
+ IN VOID *Context
+ )
+{
+ EFI_STATUS Status;
+ TPM_PCRINDEX PcrIndex;
+
+ PERF_START_EX (mImageHandle, "EventRec", "TrEEDxe", 0, PERF_ID_TREE_DXE);
+ if (mBootAttempts == 0) {
+
+ //
+ // Measure handoff tables.
+ //
+ Status = MeasureHandoffTables ();
+ if (EFI_ERROR (Status)) {
+ DEBUG ((EFI_D_ERROR, "HOBs not Measured. Error!\n"));
+ }
+
+ //
+ // Measure BootOrder & Boot#### variables.
+ //
+ Status = MeasureAllBootVariables ();
+ if (EFI_ERROR (Status)) {
+ DEBUG ((EFI_D_ERROR, "Boot Variables not Measured. Error!\n"));
+ }
+
+ //
+ // 1. This is the first boot attempt.
+ //
+ Status = TcgMeasureAction (
+ EFI_CALLING_EFI_APPLICATION
+ );
+
+ //
+ // 2. Draw a line between pre-boot env and entering post-boot env.
+ // PCR[7] is already done.
+ //
+ for (PcrIndex = 0; PcrIndex < 7; PcrIndex++) {
+ Status = MeasureSeparatorEvent (PcrIndex);
+ }
+
+ //
+ // 3. Measure GPT. It would be done in SAP driver.
+ //
+
+ //
+ // 4. Measure PE/COFF OS loader. It would be done in SAP driver.
+ //
+
+ //
+ // 5. Read & Measure variable. BootOrder already measured.
+ //
+ } else {
+ //
+ // 6. Not first attempt, meaning a return from last attempt
+ //
+ Status = TcgMeasureAction (
+ EFI_RETURNING_FROM_EFI_APPLICATOIN
+ );
+ }
+
+ DEBUG ((EFI_D_INFO, "TPM2 TrEEDxe Measure Data when ReadyToBoot\n"));
+ //
+ // Increase boot attempt counter.
+ //
+ mBootAttempts++;
+ PERF_END_EX (mImageHandle, "EventRec", "TrEEDxe", 0, PERF_ID_TREE_DXE + 1);
+}
+
+/**
+ Install TCG ACPI Table when ACPI Table Protocol is available.
+
+ A system's firmware uses an ACPI table to identify the system's TCG capabilities
+ to the Post-Boot environment. The information in this ACPI table is not guaranteed
+ to be valid until the Host Platform transitions from pre-boot state to post-boot state.
+
+ @param[in] Event Event whose notification function is being invoked
+ @param[in] Context Pointer to the notification function's context
+**/
+VOID
+EFIAPI
+InstallAcpiTable (
+ IN EFI_EVENT Event,
+ IN VOID *Context
+ )
+{
+ UINTN TableKey;
+ EFI_STATUS Status;
+ EFI_ACPI_TABLE_PROTOCOL *AcpiTable;
+ UINT8 Checksum;
+ UINT64 OemTableId;
+
+ Status = gBS->LocateProtocol (&gEfiAcpiTableProtocolGuid, NULL, (VOID **)&AcpiTable);
+ if (EFI_ERROR (Status)) {
+ return;
+ }
+
+ if (PcdGet8 (PcdTpmPlatformClass) == TCG_PLATFORM_TYPE_CLIENT) {
+ CopyMem (mTcgClientAcpiTemplate.Header.OemId, PcdGetPtr (PcdAcpiDefaultOemId), sizeof (mTcgClientAcpiTemplate.Header.OemId));
+ OemTableId = PcdGet64 (PcdAcpiDefaultOemTableId);
+ CopyMem (&mTcgClientAcpiTemplate.Header.OemTableId, &OemTableId, sizeof (UINT64));
+ mTcgClientAcpiTemplate.Header.OemRevision = PcdGet32 (PcdAcpiDefaultOemRevision);
+ mTcgClientAcpiTemplate.Header.CreatorId = PcdGet32 (PcdAcpiDefaultCreatorId);
+ mTcgClientAcpiTemplate.Header.CreatorRevision = PcdGet32 (PcdAcpiDefaultCreatorRevision);
+ //
+ // The ACPI table must be checksumed before calling the InstallAcpiTable()
+ // service of the ACPI table protocol to install it.
+ //
+ Checksum = CalculateCheckSum8 ((UINT8 *)&mTcgClientAcpiTemplate, sizeof (mTcgClientAcpiTemplate));
+ mTcgClientAcpiTemplate.Header.Checksum = Checksum;
+
+ Status = AcpiTable->InstallAcpiTable (
+ AcpiTable,
+ &mTcgClientAcpiTemplate,
+ sizeof (mTcgClientAcpiTemplate),
+ &TableKey
+ );
+ } else {
+ CopyMem (mTcgServerAcpiTemplate.Header.OemId, PcdGetPtr (PcdAcpiDefaultOemId), sizeof (mTcgServerAcpiTemplate.Header.OemId));
+ OemTableId = PcdGet64 (PcdAcpiDefaultOemTableId);
+ CopyMem (&mTcgServerAcpiTemplate.Header.OemTableId, &OemTableId, sizeof (UINT64));
+ mTcgServerAcpiTemplate.Header.OemRevision = PcdGet32 (PcdAcpiDefaultOemRevision);
+ mTcgServerAcpiTemplate.Header.CreatorId = PcdGet32 (PcdAcpiDefaultCreatorId);
+ mTcgServerAcpiTemplate.Header.CreatorRevision = PcdGet32 (PcdAcpiDefaultCreatorRevision);
+ //
+ // The ACPI table must be checksumed before calling the InstallAcpiTable()
+ // service of the ACPI table protocol to install it.
+ //
+ Checksum = CalculateCheckSum8 ((UINT8 *)&mTcgServerAcpiTemplate, sizeof (mTcgServerAcpiTemplate));
+ mTcgServerAcpiTemplate.Header.Checksum = Checksum;
+
+ mTcgServerAcpiTemplate.BaseAddress.Address = PcdGet64 (PcdTpmBaseAddress);
+ Status = AcpiTable->InstallAcpiTable (
+ AcpiTable,
+ &mTcgServerAcpiTemplate,
+ sizeof (mTcgServerAcpiTemplate),
+ &TableKey
+ );
+ }
+ ASSERT_EFI_ERROR (Status);
+}
+
+/**
+ Exit Boot Services Event notification handler.
+
+ Measure invocation and success of ExitBootServices.
+
+ @param[in] Event Event whose notification function is being invoked
+ @param[in] Context Pointer to the notification function's context
+
+**/
+VOID
+EFIAPI
+OnExitBootServices (
+ IN EFI_EVENT Event,
+ IN VOID *Context
+ )
+{
+ EFI_STATUS Status;
+
+ //
+ // Measure invocation of ExitBootServices,
+ //
+ Status = TcgMeasureAction (
+ EFI_EXIT_BOOT_SERVICES_INVOCATION
+ );
+ ASSERT_EFI_ERROR (Status);
+
+ //
+ // Measure success of ExitBootServices
+ //
+ Status = TcgMeasureAction (
+ EFI_EXIT_BOOT_SERVICES_SUCCEEDED
+ );
+ ASSERT_EFI_ERROR (Status);
+}
+
+/**
+ Exit Boot Services Failed Event notification handler.
+
+ Measure Failure of ExitBootServices.
+
+ @param[in] Event Event whose notification function is being invoked
+ @param[in] Context Pointer to the notification function's context
+
+**/
+VOID
+EFIAPI
+OnExitBootServicesFailed (
+ IN EFI_EVENT Event,
+ IN VOID *Context
+ )
+{
+ EFI_STATUS Status;
+
+ //
+ // Measure Failure of ExitBootServices,
+ //
+ Status = TcgMeasureAction (
+ EFI_EXIT_BOOT_SERVICES_FAILED
+ );
+ ASSERT_EFI_ERROR (Status);
+
+}
+
+/**
+ The function install TrEE protocol.
+
+ @retval EFI_SUCCESS TrEE protocol is installed.
+ @retval other Some error occurs.
+**/
+EFI_STATUS
+InstallTrEE (
+ VOID
+ )
+{
+ EFI_STATUS Status;
+ EFI_HANDLE Handle;
+
+ Handle = NULL;
+ Status = gBS->InstallMultipleProtocolInterfaces (
+ &Handle,
+ &gEfiTrEEProtocolGuid,
+ &mTreeProtocol,
+ NULL
+ );
+ return Status;
+}
+
+/**
+ The driver's entry point. It publishes EFI TrEE Protocol.
+
+ @param[in] ImageHandle The firmware allocated handle for the EFI image.
+ @param[in] SystemTable A pointer to the EFI System Table.
+
+ @retval EFI_SUCCESS The entry point is executed successfully.
+ @retval other Some error occurs when executing this entry point.
+**/
+EFI_STATUS
+EFIAPI
+DriverEntry (
+ IN EFI_HANDLE ImageHandle,
+ IN EFI_SYSTEM_TABLE *SystemTable
+ )
+{
+ EFI_STATUS Status;
+ EFI_EVENT Event;
+ VOID *Registration;
+ UINT32 MaxCommandSize;
+ UINT32 MaxResponseSize;
+ TPML_PCR_SELECTION Pcrs;
+ UINTN Index;
+ UINT32 TpmHashAlgorithmBitmap;
+
+ mImageHandle = ImageHandle;
+
+ if (CompareGuid (PcdGetPtr(PcdTpmInstanceGuid), &gEfiTpmDeviceInstanceNoneGuid) ||
+ CompareGuid (PcdGetPtr(PcdTpmInstanceGuid), &gEfiTpmDeviceInstanceTpm12Guid)){
+ DEBUG ((EFI_D_ERROR, "No TPM2 instance required!\n"));
+ return EFI_UNSUPPORTED;
+ }
+
+ Status = Tpm2RequestUseTpm ();
+ if (EFI_ERROR (Status)) {
+ DEBUG ((EFI_D_ERROR, "TPM not detected!\n"));
+ return Status;
+ }
+
+ //
+ // Fill information
+ //
+ DEBUG ((EFI_D_ERROR, "TrEE.ProtocolVersion - %02x.%02x\n", mTcgDxeData.BsCap.ProtocolVersion.Major, mTcgDxeData.BsCap.ProtocolVersion.Minor));
+ DEBUG ((EFI_D_ERROR, "TrEE.StructureVersion - %02x.%02x\n", mTcgDxeData.BsCap.StructureVersion.Major, mTcgDxeData.BsCap.StructureVersion.Minor));
+
+ Status = Tpm2GetCapabilityManufactureID (&mTcgDxeData.BsCap.ManufacturerID);
+ if (EFI_ERROR (Status)) {
+ DEBUG ((EFI_D_ERROR, "Tpm2GetCapabilityManufactureID fail!\n"));
+ } else {
+ DEBUG ((EFI_D_ERROR, "Tpm2GetCapabilityManufactureID - %08x\n", mTcgDxeData.BsCap.ManufacturerID));
+ }
+
+ DEBUG_CODE (
+ UINT32 FirmwareVersion1;
+ UINT32 FirmwareVersion2;
+
+ Status = Tpm2GetCapabilityFirmwareVersion (&FirmwareVersion1, &FirmwareVersion2);
+ if (EFI_ERROR (Status)) {
+ DEBUG ((EFI_D_ERROR, "Tpm2GetCapabilityFirmwareVersion fail!\n"));
+ } else {
+ DEBUG ((EFI_D_ERROR, "Tpm2GetCapabilityFirmwareVersion - %08x %08x\n", FirmwareVersion1, FirmwareVersion2));
+ }
+ );
+
+ Status = Tpm2GetCapabilityMaxCommandResponseSize (&MaxCommandSize, &MaxResponseSize);
+ if (EFI_ERROR (Status)) {
+ DEBUG ((EFI_D_ERROR, "Tpm2GetCapabilityMaxCommandResponseSize fail!\n"));
+ } else {
+ mTcgDxeData.BsCap.MaxCommandSize = (UINT16)MaxCommandSize;
+ mTcgDxeData.BsCap.MaxResponseSize = (UINT16)MaxResponseSize;
+ DEBUG ((EFI_D_ERROR, "Tpm2GetCapabilityMaxCommandResponseSize - %08x, %08x\n", MaxCommandSize, MaxResponseSize));
+ }
+
+ Status = Tpm2GetCapabilityPcrs (&Pcrs);
+ if (EFI_ERROR (Status)) {
+ DEBUG ((EFI_D_ERROR, "Tpm2GetCapabilityPcrs fail!\n"));
+ TpmHashAlgorithmBitmap = TREE_BOOT_HASH_ALG_SHA1;
+ } else {
+ DEBUG ((EFI_D_ERROR, "Tpm2GetCapabilityPcrs Count - %08x\n", Pcrs.count));
+ TpmHashAlgorithmBitmap = 0;
+ for (Index = 0; Index < Pcrs.count; Index++) {
+ DEBUG ((EFI_D_ERROR, "hash - %x\n", Pcrs.pcrSelections[Index].hash));
+ switch (Pcrs.pcrSelections[Index].hash) {
+ case TPM_ALG_SHA1:
+ TpmHashAlgorithmBitmap |= TREE_BOOT_HASH_ALG_SHA1;
+ break;
+ case TPM_ALG_SHA256:
+ TpmHashAlgorithmBitmap |= TREE_BOOT_HASH_ALG_SHA256;
+ break;
+ case TPM_ALG_SHA384:
+ TpmHashAlgorithmBitmap |= TREE_BOOT_HASH_ALG_SHA384;
+ break;
+ case TPM_ALG_SHA512:
+ TpmHashAlgorithmBitmap |= TREE_BOOT_HASH_ALG_SHA512;
+ break;
+ case TPM_ALG_SM3_256:
+ // TBD: Spec not define TREE_BOOT_HASH_ALG_SM3_256 yet
+ break;
+ }
+ }
+ }
+ DEBUG ((EFI_D_ERROR, "TPM.HashAlgorithmBitmap - 0x%08x\n", TpmHashAlgorithmBitmap));
+
+ DEBUG ((EFI_D_ERROR, "TrEE.SupportedEventLogs - 0x%08x\n", mTcgDxeData.BsCap.SupportedEventLogs));
+ mTcgDxeData.BsCap.HashAlgorithmBitmap = TpmHashAlgorithmBitmap;
+ DEBUG ((EFI_D_ERROR, "TrEE.HashAlgorithmBitmap - 0x%08x\n", mTcgDxeData.BsCap.HashAlgorithmBitmap));
+
+ if (mTcgDxeData.BsCap.TrEEPresentFlag) {
+ //
+ // Setup the log area and copy event log from hob list to it
+ //
+ Status = SetupEventLog ();
+ ASSERT_EFI_ERROR (Status);
+
+ //
+ // Measure handoff tables, Boot#### variables etc.
+ //
+ Status = EfiCreateEventReadyToBootEx (
+ TPL_CALLBACK,
+ OnReadyToBoot,
+ NULL,
+ &Event
+ );
+
+ Status = gBS->CreateEventEx (
+ EVT_NOTIFY_SIGNAL,
+ TPL_NOTIFY,
+ OnExitBootServices,
+ NULL,
+ &gEfiEventExitBootServicesGuid,
+ &Event
+ );
+
+ //
+ // Measure Exit Boot Service failed
+ //
+ Status = gBS->CreateEventEx (
+ EVT_NOTIFY_SIGNAL,
+ TPL_NOTIFY,
+ OnExitBootServicesFailed,
+ NULL,
+ &gEventExitBootServicesFailedGuid,
+ &Event
+ );
+
+ //
+ // Create event callback, because we need access variable on SecureBootPolicyVariable
+ // We should use VariableWriteArch instead of VariableArch, because Variable driver
+ // may update SecureBoot value based on last setting.
+ //
+ EfiCreateProtocolNotifyEvent (&gEfiVariableWriteArchProtocolGuid, TPL_CALLBACK, MeasureSecureBootPolicy, NULL, &Registration);
+ }
+
+ //
+ // Install ACPI Table
+ //
+ EfiCreateProtocolNotifyEvent (&gEfiAcpiTableProtocolGuid, TPL_CALLBACK, InstallAcpiTable, NULL, &Registration);
+
+ //
+ // Install TrEEProtocol
+ //
+ Status = InstallTrEE ();
+ DEBUG ((EFI_D_ERROR, "InstallTrEE - %r\n", Status));
+
+ return Status;
+}
diff --git a/SecurityPkg/Tcg/TrEEDxe/TrEEDxe.inf b/SecurityPkg/Tcg/TrEEDxe/TrEEDxe.inf
new file mode 100644
index 000000000..a1f174192
--- /dev/null
+++ b/SecurityPkg/Tcg/TrEEDxe/TrEEDxe.inf
@@ -0,0 +1,91 @@
+## @file
+# Component file for module TrEEDxe.
+# This module will produce TrEE protocol and measure boot environment.
+#
+# Caution: This module requires additional review when modified.
+# This driver will have external input - PE/COFF image.
+# This external input must be validated carefully to avoid security issue like
+# buffer overflow, integer overflow.
+#
+# Copyright (c) 2013, 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.
+#
+##
+
+[Defines]
+ INF_VERSION = 0x00010005
+ BASE_NAME = TrEEDxe
+ FILE_GUID = 2A7946E3-1AB2-49a9-ACCB-C6275139C1A5
+ MODULE_TYPE = DXE_DRIVER
+ VERSION_STRING = 1.0
+ ENTRY_POINT = DriverEntry
+
+#
+# The following information is for reference only and not required by the build tools.
+#
+# VALID_ARCHITECTURES = IA32 X64 IPF
+#
+
+[Sources]
+ TrEEDxe.c
+ MeasureBootPeCoff.c
+
+[Packages]
+ MdePkg/MdePkg.dec
+ MdeModulePkg/MdeModulePkg.dec
+ SecurityPkg/SecurityPkg.dec
+ CryptoPkg/CryptoPkg.dec
+
+[LibraryClasses]
+ MemoryAllocationLib
+ BaseLib
+ UefiBootServicesTableLib
+ HobLib
+ UefiDriverEntryPoint
+ UefiRuntimeServicesTableLib
+ BaseMemoryLib
+ DebugLib
+ Tpm2CommandLib
+ PrintLib
+ UefiLib
+ Tpm2DeviceLib
+ HashLib
+ PerformanceLib
+
+[Guids]
+ gEfiSmbiosTableGuid # ALWAYS_CONSUMED
+ gEfiGlobalVariableGuid # ALWAYS_CONSUMED
+ gTcgEventEntryHobGuid
+ gEfiEventReadyToBootGuid
+ gEfiEventExitBootServicesGuid
+ gEventExitBootServicesFailedGuid # ALWAYS_CONSUMED
+ gEfiImageSecurityDatabaseGuid
+ gEfiTpmDeviceInstanceNoneGuid
+ gEfiTpmDeviceInstanceTpm12Guid
+
+[Protocols]
+ gEfiTrEEProtocolGuid ## PRODUCES
+ gEfiAcpiTableProtocolGuid # PROTOCOL ALWAYS_CONSUMED
+ gEfiDevicePathProtocolGuid # PROTOCOL ALWAYS_CONSUMED
+ gEfiMpServiceProtocolGuid # PROTOCOL ALWAYS_CONSUMED
+ gEfiVariableWriteArchProtocolGuid # PROTOCOL ALWAYS_CONSUMED
+
+[Pcd]
+ gEfiSecurityPkgTokenSpaceGuid.PcdTpmPlatformClass
+ gEfiSecurityPkgTokenSpaceGuid.PcdFirmwareDebuggerInitialized
+ gEfiSecurityPkgTokenSpaceGuid.PcdTpmInstanceGuid
+ gEfiSecurityPkgTokenSpaceGuid.PcdTpmBaseAddress
+ gEfiMdeModulePkgTokenSpaceGuid.PcdAcpiDefaultOemId
+ gEfiMdeModulePkgTokenSpaceGuid.PcdAcpiDefaultOemTableId
+ gEfiMdeModulePkgTokenSpaceGuid.PcdAcpiDefaultOemRevision
+ gEfiMdeModulePkgTokenSpaceGuid.PcdAcpiDefaultCreatorId
+ gEfiMdeModulePkgTokenSpaceGuid.PcdAcpiDefaultCreatorRevision
+
+[Depex]
+ TRUE
+
diff --git a/SecurityPkg/Tcg/TrEEPei/TrEEPei.c b/SecurityPkg/Tcg/TrEEPei/TrEEPei.c
new file mode 100644
index 000000000..5b5ff6c3a
--- /dev/null
+++ b/SecurityPkg/Tcg/TrEEPei/TrEEPei.c
@@ -0,0 +1,694 @@
+/** @file
+ Initialize TPM2 device and measure FVs before handing off control to DXE.
+
+Copyright (c) 2013, 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.
+
+**/
+
+#include <PiPei.h>
+
+#include <IndustryStandard/UefiTcgPlatform.h>
+#include <Ppi/FirmwareVolumeInfo.h>
+#include <Ppi/LockPhysicalPresence.h>
+#include <Ppi/TpmInitialized.h>
+#include <Ppi/FirmwareVolume.h>
+#include <Ppi/EndOfPeiPhase.h>
+#include <Ppi/FirmwareVolumeInfoMeasurementExcluded.h>
+
+#include <Guid/TcgEventHob.h>
+#include <Guid/MeasuredFvHob.h>
+#include <Guid/TpmInstance.h>
+
+#include <Library/DebugLib.h>
+#include <Library/BaseMemoryLib.h>
+#include <Library/PeiServicesLib.h>
+#include <Library/PeimEntryPoint.h>
+#include <Library/Tpm2CommandLib.h>
+#include <Library/Tpm2DeviceLib.h>
+#include <Library/HashLib.h>
+#include <Library/HobLib.h>
+#include <Library/PcdLib.h>
+#include <Library/PeiServicesTablePointerLib.h>
+#include <Protocol/TrEEProtocol.h>
+#include <Library/PerformanceLib.h>
+
+#define PERF_ID_TREE_PEI 0x3080
+
+typedef struct {
+ EFI_GUID *EventGuid;
+ TREE_EVENT_LOG_FORMAT LogFormat;
+ UINT32 BootHashAlg;
+ UINT16 DigestAlgID;
+ TPMI_ALG_HASH TpmHashAlgo;
+} TREE_EVENT_INFO_STRUCT;
+
+TREE_EVENT_INFO_STRUCT mTreeEventInfo[] = {
+ {&gTcgEventEntryHobGuid, TREE_EVENT_LOG_FORMAT_TCG_1_2, TREE_BOOT_HASH_ALG_SHA1, 0, TPM_ALG_SHA1},
+};
+
+BOOLEAN mImageInMemory = FALSE;
+EFI_PEI_FILE_HANDLE mFileHandle;
+
+EFI_PEI_PPI_DESCRIPTOR mTpmInitializedPpiList = {
+ EFI_PEI_PPI_DESCRIPTOR_PPI | EFI_PEI_PPI_DESCRIPTOR_TERMINATE_LIST,
+ &gPeiTpmInitializedPpiGuid,
+ NULL
+};
+
+EFI_PLATFORM_FIRMWARE_BLOB mMeasuredBaseFvInfo[FixedPcdGet32 (PcdPeiCoreMaxFvSupported)];
+UINT32 mMeasuredBaseFvIndex = 0;
+
+EFI_PLATFORM_FIRMWARE_BLOB mMeasuredChildFvInfo[FixedPcdGet32 (PcdPeiCoreMaxFvSupported)];
+UINT32 mMeasuredChildFvIndex = 0;
+
+/**
+ Measure and record the Firmware Volum Information once FvInfoPPI install.
+
+ @param[in] PeiServices An indirect pointer to the EFI_PEI_SERVICES table published by the PEI Foundation.
+ @param[in] NotifyDescriptor Address of the notification descriptor data structure.
+ @param[in] Ppi Address of the PPI that was installed.
+
+ @retval EFI_SUCCESS The FV Info is measured and recorded to TPM.
+ @return Others Fail to measure FV.
+
+**/
+EFI_STATUS
+EFIAPI
+FirmwareVolmeInfoPpiNotifyCallback (
+ IN EFI_PEI_SERVICES **PeiServices,
+ IN EFI_PEI_NOTIFY_DESCRIPTOR *NotifyDescriptor,
+ IN VOID *Ppi
+ );
+
+/**
+ Record all measured Firmware Volum Information into a Guid Hob
+
+ @param[in] PeiServices An indirect pointer to the EFI_PEI_SERVICES table published by the PEI Foundation.
+ @param[in] NotifyDescriptor Address of the notification descriptor data structure.
+ @param[in] Ppi Address of the PPI that was installed.
+
+ @retval EFI_SUCCESS The FV Info is measured and recorded to TPM.
+ @return Others Fail to measure FV.
+
+**/
+EFI_STATUS
+EFIAPI
+EndofPeiSignalNotifyCallBack (
+ IN EFI_PEI_SERVICES **PeiServices,
+ IN EFI_PEI_NOTIFY_DESCRIPTOR *NotifyDescriptor,
+ IN VOID *Ppi
+ );
+
+EFI_PEI_NOTIFY_DESCRIPTOR mNotifyList[] = {
+ {
+ EFI_PEI_PPI_DESCRIPTOR_NOTIFY_CALLBACK,
+ &gEfiPeiFirmwareVolumeInfoPpiGuid,
+ FirmwareVolmeInfoPpiNotifyCallback
+ },
+ {
+ (EFI_PEI_PPI_DESCRIPTOR_NOTIFY_CALLBACK | EFI_PEI_PPI_DESCRIPTOR_TERMINATE_LIST),
+ &gEfiEndOfPeiSignalPpiGuid,
+ EndofPeiSignalNotifyCallBack
+ }
+};
+
+EFI_PEI_FIRMWARE_VOLUME_INFO_MEASUREMENT_EXCLUDED_PPI *mMeasurementExcludedFvPpi;
+
+/**
+ This function return hash algorithm from event log format.
+
+ @param[in] EventLogFormat Event log format.
+
+ @return hash algorithm.
+**/
+TPMI_ALG_HASH
+TrEEGetHashAlgoFromLogFormat (
+ IN TREE_EVENT_LOG_FORMAT EventLogFormat
+ )
+{
+ UINTN Index;
+
+ for (Index = 0; Index < sizeof(mTreeEventInfo)/sizeof(mTreeEventInfo[0]); Index++) {
+ if (mTreeEventInfo[Index].LogFormat == EventLogFormat) {
+ return mTreeEventInfo[Index].TpmHashAlgo;
+ }
+ }
+ return TPM_ALG_SHA1;
+}
+
+/**
+ This function get digest from digest list.
+
+ @param HashAlg digest algorithm
+ @param DigestList digest list
+ @param Digest digest
+
+ @retval EFI_SUCCESS Sha1Digest is found and returned.
+ @retval EFI_NOT_FOUND Sha1Digest is not found.
+**/
+EFI_STATUS
+Tpm2GetDigestFromDigestList (
+ IN TPMI_ALG_HASH HashAlg,
+ IN TPML_DIGEST_VALUES *DigestList,
+ IN VOID *Digest
+ )
+{
+ UINTN Index;
+ UINT16 DigestSize;
+
+ DigestSize = GetHashSizeFromAlgo (HashAlg);
+ for (Index = 0; Index < DigestList->count; Index++) {
+ if (DigestList->digests[Index].hashAlg == HashAlg) {
+ CopyMem (
+ Digest,
+ &DigestList->digests[Index].digest,
+ DigestSize
+ );
+ return EFI_SUCCESS;
+ }
+ }
+
+ return EFI_NOT_FOUND;
+}
+
+/**
+ Record all measured Firmware Volum Information into a Guid Hob
+ Guid Hob payload layout is
+
+ UINT32 *************************** FIRMWARE_BLOB number
+ EFI_PLATFORM_FIRMWARE_BLOB******** BLOB Array
+
+ @param[in] PeiServices An indirect pointer to the EFI_PEI_SERVICES table published by the PEI Foundation.
+ @param[in] NotifyDescriptor Address of the notification descriptor data structure.
+ @param[in] Ppi Address of the PPI that was installed.
+
+ @retval EFI_SUCCESS The FV Info is measured and recorded to TPM.
+ @return Others Fail to measure FV.
+
+**/
+EFI_STATUS
+EFIAPI
+EndofPeiSignalNotifyCallBack (
+ IN EFI_PEI_SERVICES **PeiServices,
+ IN EFI_PEI_NOTIFY_DESCRIPTOR *NotifyDescriptor,
+ IN VOID *Ppi
+ )
+{
+ MEASURED_HOB_DATA *MeasuredHobData;
+
+ MeasuredHobData = NULL;
+
+ //
+ // Create a Guid hob to save all measured Fv
+ //
+ MeasuredHobData = BuildGuidHob(
+ &gMeasuredFvHobGuid,
+ sizeof(UINTN) + sizeof(EFI_PLATFORM_FIRMWARE_BLOB) * (mMeasuredBaseFvIndex + mMeasuredChildFvIndex)
+ );
+
+ if (MeasuredHobData != NULL){
+ //
+ // Save measured FV info enty number
+ //
+ MeasuredHobData->Num = mMeasuredBaseFvIndex + mMeasuredChildFvIndex;
+
+ //
+ // Save measured base Fv info
+ //
+ CopyMem (MeasuredHobData->MeasuredFvBuf, mMeasuredBaseFvInfo, sizeof(EFI_PLATFORM_FIRMWARE_BLOB) * (mMeasuredBaseFvIndex));
+
+ //
+ // Save measured child Fv info
+ //
+ CopyMem (&MeasuredHobData->MeasuredFvBuf[mMeasuredBaseFvIndex] , mMeasuredChildFvInfo, sizeof(EFI_PLATFORM_FIRMWARE_BLOB) * (mMeasuredChildFvIndex));
+ }
+
+ return EFI_SUCCESS;
+}
+
+/**
+ Add a new entry to the Event Log.
+
+ @param[in] DigestList A list of digest.
+ @param[in,out] NewEventHdr Pointer to a TCG_PCR_EVENT_HDR data structure.
+ @param[in] NewEventData Pointer to the new event data.
+
+ @retval EFI_SUCCESS The new event log entry was added.
+ @retval EFI_OUT_OF_RESOURCES No enough memory to log the new event.
+**/
+EFI_STATUS
+LogHashEvent (
+ IN TPML_DIGEST_VALUES *DigestList,
+ IN OUT TCG_PCR_EVENT_HDR *NewEventHdr,
+ IN UINT8 *NewEventData
+ )
+{
+ VOID *HobData;
+ EFI_STATUS Status;
+ UINTN Index;
+ EFI_STATUS RetStatus;
+
+ RetStatus = EFI_SUCCESS;
+ for (Index = 0; Index < sizeof(mTreeEventInfo)/sizeof(mTreeEventInfo[0]); Index++) {
+ DEBUG ((EFI_D_INFO, " LogFormat - 0x%08x\n", mTreeEventInfo[Index].LogFormat));
+ switch (mTreeEventInfo[Index].LogFormat) {
+ case TREE_EVENT_LOG_FORMAT_TCG_1_2:
+ Status = Tpm2GetDigestFromDigestList (TPM_ALG_SHA1, DigestList, &NewEventHdr->Digest);
+ if (!EFI_ERROR (Status)) {
+ HobData = BuildGuidHob (
+ &gTcgEventEntryHobGuid,
+ sizeof (*NewEventHdr) + NewEventHdr->EventSize
+ );
+ if (HobData == NULL) {
+ RetStatus = EFI_OUT_OF_RESOURCES;
+ break;
+ }
+
+ CopyMem (HobData, NewEventHdr, sizeof (*NewEventHdr));
+ HobData = (VOID *) ((UINT8*)HobData + sizeof (*NewEventHdr));
+ CopyMem (HobData, NewEventData, NewEventHdr->EventSize);
+ }
+ break;
+ }
+ }
+
+ return RetStatus;
+}
+
+/**
+ Do a hash operation on a data buffer, extend a specific TPM PCR with the hash result,
+ and build a GUIDed HOB recording the event which will be passed to the DXE phase and
+ added into the Event Log.
+
+ @param[in] Flags Bitmap providing additional information.
+ @param[in] HashData Physical address of the start of the data buffer
+ to be hashed, extended, and logged.
+ @param[in] HashDataLen The length, in bytes, of the buffer referenced by HashData.
+ @param[in] NewEventHdr Pointer to a TCG_PCR_EVENT_HDR data structure.
+ @param[in] NewEventData Pointer to the new event data.
+
+ @retval EFI_SUCCESS Operation completed successfully.
+ @retval EFI_OUT_OF_RESOURCES No enough memory to log the new event.
+ @retval EFI_DEVICE_ERROR The command was unsuccessful.
+
+**/
+EFI_STATUS
+HashLogExtendEvent (
+ IN UINT64 Flags,
+ IN UINT8 *HashData,
+ IN UINTN HashDataLen,
+ IN TCG_PCR_EVENT_HDR *NewEventHdr,
+ IN UINT8 *NewEventData
+ )
+{
+ EFI_STATUS Status;
+ TPML_DIGEST_VALUES DigestList;
+
+ Status = HashAndExtend (
+ NewEventHdr->PCRIndex,
+ HashData,
+ HashDataLen,
+ &DigestList
+ );
+ if (!EFI_ERROR (Status)) {
+ if ((Flags & TREE_EXTEND_ONLY) == 0) {
+ Status = LogHashEvent (&DigestList, NewEventHdr, NewEventData);
+ }
+ }
+ return Status;
+}
+
+/**
+ Measure CRTM version.
+
+ @retval EFI_SUCCESS Operation completed successfully.
+ @retval EFI_OUT_OF_RESOURCES No enough memory to log the new event.
+ @retval EFI_DEVICE_ERROR The command was unsuccessful.
+
+**/
+EFI_STATUS
+MeasureCRTMVersion (
+ VOID
+ )
+{
+ TCG_PCR_EVENT_HDR TcgEventHdr;
+
+ //
+ // Use FirmwareVersion string to represent CRTM version.
+ // OEMs should get real CRTM version string and measure it.
+ //
+
+ TcgEventHdr.PCRIndex = 0;
+ TcgEventHdr.EventType = EV_S_CRTM_VERSION;
+ TcgEventHdr.EventSize = (UINT32) StrSize((CHAR16*)PcdGetPtr (PcdFirmwareVersionString));
+
+ return HashLogExtendEvent (
+ 0,
+ (UINT8*)PcdGetPtr (PcdFirmwareVersionString),
+ TcgEventHdr.EventSize,
+ &TcgEventHdr,
+ (UINT8*)PcdGetPtr (PcdFirmwareVersionString)
+ );
+}
+
+/**
+ Measure FV image.
+ Add it into the measured FV list after the FV is measured successfully.
+
+ @param[in] FvBase Base address of FV image.
+ @param[in] FvLength Length of FV image.
+
+ @retval EFI_SUCCESS Fv image is measured successfully
+ or it has been already measured.
+ @retval EFI_OUT_OF_RESOURCES No enough memory to log the new event.
+ @retval EFI_DEVICE_ERROR The command was unsuccessful.
+
+**/
+EFI_STATUS
+MeasureFvImage (
+ IN EFI_PHYSICAL_ADDRESS FvBase,
+ IN UINT64 FvLength
+ )
+{
+ UINT32 Index;
+ EFI_STATUS Status;
+ EFI_PLATFORM_FIRMWARE_BLOB FvBlob;
+ TCG_PCR_EVENT_HDR TcgEventHdr;
+
+ //
+ // Check if it is in Excluded FV list
+ //
+ if (mMeasurementExcludedFvPpi != NULL) {
+ for (Index = 0; Index < mMeasurementExcludedFvPpi->Count; Index ++) {
+ if (mMeasurementExcludedFvPpi->Fv[Index].FvBase == FvBase) {
+ DEBUG ((DEBUG_INFO, "The FV which is excluded by TrEEPei starts at: 0x%x\n", FvBase));
+ DEBUG ((DEBUG_INFO, "The FV which is excluded by TrEEPei has the size: 0x%x\n", FvLength));
+ return EFI_SUCCESS;
+ }
+ }
+ }
+
+ //
+ // Check whether FV is in the measured FV list.
+ //
+ for (Index = 0; Index < mMeasuredBaseFvIndex; Index ++) {
+ if (mMeasuredBaseFvInfo[Index].BlobBase == FvBase) {
+ return EFI_SUCCESS;
+ }
+ }
+
+ //
+ // Measure and record the FV to the TPM
+ //
+ FvBlob.BlobBase = FvBase;
+ FvBlob.BlobLength = FvLength;
+
+ DEBUG ((DEBUG_INFO, "The FV which is measured by TrEEPei starts at: 0x%x\n", FvBlob.BlobBase));
+ DEBUG ((DEBUG_INFO, "The FV which is measured by TrEEPei has the size: 0x%x\n", FvBlob.BlobLength));
+
+ TcgEventHdr.PCRIndex = 0;
+ TcgEventHdr.EventType = EV_EFI_PLATFORM_FIRMWARE_BLOB;
+ TcgEventHdr.EventSize = sizeof (FvBlob);
+
+ Status = HashLogExtendEvent (
+ 0,
+ (UINT8*) (UINTN) FvBlob.BlobBase,
+ (UINTN) FvBlob.BlobLength,
+ &TcgEventHdr,
+ (UINT8*) &FvBlob
+ );
+ ASSERT_EFI_ERROR (Status);
+
+ //
+ // Add new FV into the measured FV list.
+ //
+ ASSERT (mMeasuredBaseFvIndex < FixedPcdGet32 (PcdPeiCoreMaxFvSupported));
+ if (mMeasuredBaseFvIndex < FixedPcdGet32 (PcdPeiCoreMaxFvSupported)) {
+ mMeasuredBaseFvInfo[mMeasuredBaseFvIndex].BlobBase = FvBase;
+ mMeasuredBaseFvInfo[mMeasuredBaseFvIndex].BlobLength = FvLength;
+ mMeasuredBaseFvIndex++;
+ }
+
+ return Status;
+}
+
+/**
+ Measure main BIOS.
+
+ @retval EFI_SUCCESS Operation completed successfully.
+ @retval EFI_OUT_OF_RESOURCES No enough memory to log the new event.
+ @retval EFI_DEVICE_ERROR The command was unsuccessful.
+
+**/
+EFI_STATUS
+MeasureMainBios (
+ VOID
+ )
+{
+ EFI_STATUS Status;
+ UINT32 FvInstances;
+ EFI_PEI_FV_HANDLE VolumeHandle;
+ EFI_FV_INFO VolumeInfo;
+ EFI_PEI_FIRMWARE_VOLUME_PPI *FvPpi;
+
+ PERF_START_EX (mFileHandle, "EventRec", "TrEEPei", 0, PERF_ID_TREE_PEI);
+ FvInstances = 0;
+ while (TRUE) {
+ //
+ // Traverse all firmware volume instances of Static Core Root of Trust for Measurement
+ // (S-CRTM), this firmware volume measure policy can be modified/enhanced by special
+ // platform for special CRTM TPM measuring.
+ //
+ Status = PeiServicesFfsFindNextVolume (FvInstances, &VolumeHandle);
+ if (EFI_ERROR (Status)) {
+ break;
+ }
+
+ //
+ // Measure and record the firmware volume that is dispatched by PeiCore
+ //
+ Status = PeiServicesFfsGetVolumeInfo (VolumeHandle, &VolumeInfo);
+ ASSERT_EFI_ERROR (Status);
+ //
+ // Locate the corresponding FV_PPI according to founded FV's format guid
+ //
+ Status = PeiServicesLocatePpi (
+ &VolumeInfo.FvFormat,
+ 0,
+ NULL,
+ (VOID**)&FvPpi
+ );
+ if (!EFI_ERROR (Status)) {
+ MeasureFvImage ((EFI_PHYSICAL_ADDRESS) (UINTN) VolumeInfo.FvStart, VolumeInfo.FvSize);
+ }
+
+ FvInstances++;
+ }
+ PERF_END_EX (mFileHandle, "EventRec", "TrEEPei", 0, PERF_ID_TREE_PEI + 1);
+
+ return EFI_SUCCESS;
+}
+
+/**
+ Measure and record the Firmware Volum Information once FvInfoPPI install.
+
+ @param[in] PeiServices An indirect pointer to the EFI_PEI_SERVICES table published by the PEI Foundation.
+ @param[in] NotifyDescriptor Address of the notification descriptor data structure.
+ @param[in] Ppi Address of the PPI that was installed.
+
+ @retval EFI_SUCCESS The FV Info is measured and recorded to TPM.
+ @return Others Fail to measure FV.
+
+**/
+EFI_STATUS
+EFIAPI
+FirmwareVolmeInfoPpiNotifyCallback (
+ IN EFI_PEI_SERVICES **PeiServices,
+ IN EFI_PEI_NOTIFY_DESCRIPTOR *NotifyDescriptor,
+ IN VOID *Ppi
+ )
+{
+ EFI_PEI_FIRMWARE_VOLUME_INFO_PPI *Fv;
+ EFI_STATUS Status;
+ EFI_PEI_FIRMWARE_VOLUME_PPI *FvPpi;
+
+ Fv = (EFI_PEI_FIRMWARE_VOLUME_INFO_PPI *) Ppi;
+
+ //
+ // The PEI Core can not dispatch or load files from memory mapped FVs that do not support FvPpi.
+ //
+ Status = PeiServicesLocatePpi (
+ &Fv->FvFormat,
+ 0,
+ NULL,
+ (VOID**)&FvPpi
+ );
+ if (EFI_ERROR (Status)) {
+ return EFI_SUCCESS;
+ }
+
+ //
+ // This is an FV from an FFS file, and the parent FV must have already been measured,
+ // No need to measure twice, so just record the FV and return
+ //
+ if (Fv->ParentFvName != NULL || Fv->ParentFileName != NULL ) {
+
+ ASSERT (mMeasuredChildFvIndex < FixedPcdGet32 (PcdPeiCoreMaxFvSupported));
+ if (mMeasuredChildFvIndex < FixedPcdGet32 (PcdPeiCoreMaxFvSupported)) {
+ mMeasuredChildFvInfo[mMeasuredChildFvIndex].BlobBase = (EFI_PHYSICAL_ADDRESS) (UINTN) Fv->FvInfo;
+ mMeasuredChildFvInfo[mMeasuredChildFvIndex].BlobLength = Fv->FvInfoSize;
+ mMeasuredChildFvIndex++;
+ }
+ return EFI_SUCCESS;
+ }
+
+ return MeasureFvImage ((EFI_PHYSICAL_ADDRESS) (UINTN) Fv->FvInfo, Fv->FvInfoSize);
+}
+
+/**
+ Do measurement after memory is ready.
+
+ @param[in] PeiServices Describes the list of possible PEI Services.
+
+ @retval EFI_SUCCESS Operation completed successfully.
+ @retval EFI_OUT_OF_RESOURCES No enough memory to log the new event.
+ @retval EFI_DEVICE_ERROR The command was unsuccessful.
+
+**/
+EFI_STATUS
+PeimEntryMP (
+ IN EFI_PEI_SERVICES **PeiServices
+ )
+{
+ EFI_STATUS Status;
+
+ Status = PeiServicesLocatePpi (
+ &gEfiPeiFirmwareVolumeInfoMeasurementExcludedPpiGuid,
+ 0,
+ NULL,
+ (VOID**)&mMeasurementExcludedFvPpi
+ );
+ // Do not check status, because it is optional
+
+ if (PcdGet8 (PcdTpm2ScrtmPolicy) == 1) {
+ Status = MeasureCRTMVersion ();
+ ASSERT_EFI_ERROR (Status);
+ }
+
+ Status = MeasureMainBios ();
+
+ //
+ // Post callbacks:
+ // for the FvInfoPpi services to measure and record
+ // the additional Fvs to TPM
+ //
+ Status = PeiServicesNotifyPpi (&mNotifyList[0]);
+ ASSERT_EFI_ERROR (Status);
+
+ return Status;
+}
+
+/**
+ Entry point of this module.
+
+ @param[in] FileHandle Handle of the file being invoked.
+ @param[in] PeiServices Describes the list of possible PEI Services.
+
+ @return Status.
+
+**/
+EFI_STATUS
+EFIAPI
+PeimEntryMA (
+ IN EFI_PEI_FILE_HANDLE FileHandle,
+ IN CONST EFI_PEI_SERVICES **PeiServices
+ )
+{
+ EFI_STATUS Status;
+ EFI_BOOT_MODE BootMode;
+
+ if (CompareGuid (PcdGetPtr(PcdTpmInstanceGuid), &gEfiTpmDeviceInstanceNoneGuid) ||
+ CompareGuid (PcdGetPtr(PcdTpmInstanceGuid), &gEfiTpmDeviceInstanceTpm12Guid)){
+ DEBUG ((EFI_D_ERROR, "No TPM2 instance required!\n"));
+ return EFI_UNSUPPORTED;
+ }
+
+ if (PcdGetBool (PcdHideTpmSupport) && PcdGetBool (PcdHideTpm)) {
+ return EFI_UNSUPPORTED;
+ }
+
+ //
+ // Update for Performance optimization
+ //
+ Status = Tpm2RequestUseTpm ();
+ if (EFI_ERROR (Status)) {
+ DEBUG ((DEBUG_ERROR, "TPM not detected!\n"));
+ return Status;
+ }
+
+ Status = PeiServicesGetBootMode (&BootMode);
+ ASSERT_EFI_ERROR (Status);
+
+ //
+ // In S3 path, skip shadow logic. no measurement is required
+ //
+ if (BootMode != BOOT_ON_S3_RESUME) {
+ Status = (**PeiServices).RegisterForShadow(FileHandle);
+ if (Status == EFI_ALREADY_STARTED) {
+ mImageInMemory = TRUE;
+ mFileHandle = FileHandle;
+ } else if (Status == EFI_NOT_FOUND) {
+ ASSERT_EFI_ERROR (Status);
+ }
+ }
+
+ if (!mImageInMemory) {
+ //
+ // Initialize TPM device
+ //
+ if (PcdGet8 (PcdTpm2InitializationPolicy) == 1) {
+ if (BootMode == BOOT_ON_S3_RESUME) {
+ Status = Tpm2Startup (TPM_SU_STATE);
+ if (EFI_ERROR (Status) ) {
+ Status = Tpm2Startup (TPM_SU_CLEAR);
+ }
+ } else {
+ Status = Tpm2Startup (TPM_SU_CLEAR);
+ }
+ if (EFI_ERROR (Status) ) {
+ return Status;
+ }
+ }
+
+ //
+ // TpmSelfTest is optional on S3 path, skip it to save S3 time
+ //
+ if (BootMode != BOOT_ON_S3_RESUME) {
+ if (PcdGet8 (PcdTpm2SelfTestPolicy) == 1) {
+ Status = Tpm2SelfTest (NO);
+ if (EFI_ERROR (Status)) {
+ return Status;
+ }
+ }
+ }
+
+ Status = PeiServicesInstallPpi (&mTpmInitializedPpiList);
+ ASSERT_EFI_ERROR (Status);
+ }
+
+ if (mImageInMemory) {
+ Status = PeimEntryMP ((EFI_PEI_SERVICES**)PeiServices);
+ if (EFI_ERROR (Status)) {
+ return Status;
+ }
+ }
+
+ return Status;
+}
diff --git a/SecurityPkg/Tcg/TrEEPei/TrEEPei.inf b/SecurityPkg/Tcg/TrEEPei/TrEEPei.inf
new file mode 100644
index 000000000..3de112c5c
--- /dev/null
+++ b/SecurityPkg/Tcg/TrEEPei/TrEEPei.inf
@@ -0,0 +1,75 @@
+## @file
+# This module will initialize TPM2 device and measure FVs in PEI phase.
+#
+# Copyright (c) 2013, 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.
+#
+##
+
+[Defines]
+ INF_VERSION = 0x00010005
+ BASE_NAME = TrEEPei
+ FILE_GUID = CA5A1928-6523-409d-A9FE-5DCC87387222
+ MODULE_TYPE = PEIM
+ VERSION_STRING = 1.0
+ ENTRY_POINT = PeimEntryMA
+
+#
+# The following information is for reference only and not required by the build tools.
+#
+# VALID_ARCHITECTURES = IA32 X64 IPF EBC
+#
+
+[Sources]
+ TrEEPei.c
+
+[Packages]
+ MdePkg/MdePkg.dec
+ MdeModulePkg/MdeModulePkg.dec
+ SecurityPkg/SecurityPkg.dec
+
+[LibraryClasses]
+ HobLib
+ PeimEntryPoint
+ PeiServicesLib
+ BaseMemoryLib
+ DebugLib
+ Tpm2CommandLib
+ PeiServicesTablePointerLib
+ Tpm2DeviceLib
+ HashLib
+ PerformanceLib
+
+[Guids]
+ gTcgEventEntryHobGuid
+ gMeasuredFvHobGuid
+ gEfiTpmDeviceInstanceNoneGuid
+ gEfiTpmDeviceInstanceTpm12Guid
+
+[Ppis]
+ gEfiPeiFirmwareVolumeInfoPpiGuid
+ gEfiPeiFirmwareVolumeInfoMeasurementExcludedPpiGuid
+ gPeiTpmInitializedPpiGuid
+ gEfiEndOfPeiSignalPpiGuid
+
+[Pcd]
+ gEfiSecurityPkgTokenSpaceGuid.PcdHideTpm
+ gEfiMdeModulePkgTokenSpaceGuid.PcdFirmwareVersionString ## CONSUMES
+ gEfiSecurityPkgTokenSpaceGuid.PcdTpmInstanceGuid
+ gEfiSecurityPkgTokenSpaceGuid.PcdTpm2InitializationPolicy
+ gEfiSecurityPkgTokenSpaceGuid.PcdTpm2SelfTestPolicy
+ gEfiSecurityPkgTokenSpaceGuid.PcdTpm2ScrtmPolicy
+
+[FixedPcd]
+ gEfiSecurityPkgTokenSpaceGuid.PcdHideTpmSupport
+ gEfiMdeModulePkgTokenSpaceGuid.PcdPeiCoreMaxFvSupported ## CONSUMES
+
+[Depex]
+ gEfiPeiMasterBootModePpiGuid AND
+ gEfiPeiReadOnlyVariable2PpiGuid AND
+ gEfiTpmDeviceSelectedGuid
diff --git a/SecurityPkg/Tcg/TrEESmm/Tpm.asl b/SecurityPkg/Tcg/TrEESmm/Tpm.asl
new file mode 100644
index 000000000..507f99902
--- /dev/null
+++ b/SecurityPkg/Tcg/TrEESmm/Tpm.asl
@@ -0,0 +1,354 @@
+/** @file
+ The TPM2 definition block in ACPI table for TrEE physical presence
+ and MemoryClear.
+
+Copyright (c) 2013, 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.
+
+**/
+
+DefinitionBlock (
+ "Tpm.aml",
+ "SSDT",
+ 1,
+ "INTEL ",
+ "Tpm2Tabl",
+ 0x1000
+ )
+{
+ Scope (\_SB)
+ {
+ Device (TPM)
+ {
+ //
+ // TREE
+ //
+ Name (_HID, "MSFT0101")
+
+ //
+ // Readable name of this device, don't know if this way is correct yet
+ //
+ Name (_STR, Unicode ("TPM 2.0 Device"))
+
+ //
+ // Return the resource consumed by TPM device
+ //
+ Name (_CRS, ResourceTemplate () {
+ Memory32Fixed (ReadOnly, 0xfed40000, 0x5000)
+ })
+
+ //
+ // Operational region for Smi port access
+ //
+ OperationRegion (SMIP, SystemIO, 0xB2, 1)
+ Field (SMIP, ByteAcc, NoLock, Preserve)
+ {
+ IOB2, 8
+ }
+
+ //
+ // Operational region for TPM access
+ //
+ OperationRegion (TPMR, SystemMemory, 0xfed40000, 0x5000)
+ Field (TPMR, AnyAcc, NoLock, Preserve)
+ {
+ ACC0, 8,
+ }
+
+ //
+ // Operational region for TPM support, TPM Physical Presence and TPM Memory Clear
+ // Region Offset 0xFFFF0000 and Length 0xF0 will be fixed in C code.
+ //
+ OperationRegion (TNVS, SystemMemory, 0xFFFF0000, 0xF0)
+ Field (TNVS, AnyAcc, NoLock, Preserve)
+ {
+ PPIN, 8, // Software SMI for Physical Presence Interface
+ PPIP, 32, // Used for save physical presence paramter
+ PPRP, 32, // Physical Presence request operation response
+ PPRQ, 32, // Physical Presence request operation
+ LPPR, 32, // Last Physical Presence request operation
+ FRET, 32, // Physical Presence function return code
+ MCIN, 8, // Software SMI for Memory Clear Interface
+ MCIP, 32, // Used for save the Mor paramter
+ MORD, 32, // Memory Overwrite Request Data
+ MRET, 32 // Memory Overwrite function return code
+ }
+
+ Method (PTS, 1, Serialized)
+ {
+ //
+ // Detect Sx state for MOR, only S4, S5 need to handle
+ //
+ If (LAnd (LLess (Arg0, 6), LGreater (Arg0, 3)))
+ {
+ //
+ // Bit4 -- DisableAutoDetect. 0 -- Firmware MAY autodetect.
+ //
+ If (LNot (And (MORD, 0x10)))
+ {
+ //
+ // Triggle the SMI through ACPI _PTS method.
+ //
+ Store (0x02, MCIP)
+
+ //
+ // Triggle the SMI interrupt
+ //
+ Store (MCIN, IOB2)
+ }
+ }
+ Return (0)
+ }
+
+ Method (_STA, 0)
+ {
+ if (LEqual (ACC0, 0xff))
+ {
+ Return (0)
+ }
+ Return (0x0f)
+ }
+
+ //
+ // TCG Hardware Information
+ //
+ Method (HINF, 3, Serialized, 0, {BuffObj, PkgObj}, {UnknownObj, UnknownObj, UnknownObj}) // IntObj, IntObj, PkgObj
+ {
+ //
+ // Switch by function index
+ //
+ Switch (ToInteger(Arg1))
+ {
+ Case (0)
+ {
+ //
+ // Standard query
+ //
+ Return (Buffer () {0x03})
+ }
+ Case (1)
+ {
+ //
+ // Return failure if no TPM present
+ //
+ Name(TPMV, Package () {0x01, Package () {0x2, 0x0}})
+ if (LEqual (_STA (), 0x00))
+ {
+ Return (Package () {0x00})
+ }
+
+ //
+ // Return TPM version
+ //
+ Return (TPMV)
+ }
+ Default {BreakPoint}
+ }
+ Return (Buffer () {0})
+ }
+
+ Name(TPM2, Package (0x02){
+ Zero,
+ Zero
+ })
+
+ Name(TPM3, Package (0x03){
+ Zero,
+ Zero,
+ Zero
+ })
+
+ //
+ // TCG Physical Presence Interface
+ //
+ Method (TPPI, 3, Serialized, 0, {BuffObj, PkgObj, IntObj, StrObj}, {UnknownObj, UnknownObj, UnknownObj}) // IntObj, IntObj, PkgObj
+ {
+ //
+ // Switch by function index
+ //
+ Switch (ToInteger(Arg1))
+ {
+ Case (0)
+ {
+ //
+ // Standard query, supports function 1-8
+ //
+ Return (Buffer () {0xFF, 0x01})
+ }
+ Case (1)
+ {
+ //
+ // a) Get Physical Presence Interface Version
+ //
+ Return ("1.2")
+ }
+ Case (2)
+ {
+ //
+ // b) Submit TPM Operation Request to Pre-OS Environment
+ //
+
+ Store (DerefOf (Index (Arg2, 0x00)), PPRQ)
+ Store (0x02, PPIP)
+
+ //
+ // Triggle the SMI interrupt
+ //
+ Store (PPIN, IOB2)
+ Return (FRET)
+
+
+ }
+ Case (3)
+ {
+ //
+ // c) Get Pending TPM Operation Requested By the OS
+ //
+
+ Store (PPRQ, Index (TPM2, 0x01))
+ Return (TPM2)
+ }
+ Case (4)
+ {
+ //
+ // d) Get Platform-Specific Action to Transition to Pre-OS Environment
+ //
+ Return (2)
+ }
+ Case (5)
+ {
+ //
+ // e) Return TPM Operation Response to OS Environment
+ //
+ Store (0x05, PPIP)
+
+ //
+ // Triggle the SMI interrupt
+ //
+ Store (PPIN, IOB2)
+
+ Store (LPPR, Index (TPM3, 0x01))
+ Store (PPRP, Index (TPM3, 0x02))
+
+ Return (TPM3)
+ }
+ Case (6)
+ {
+
+ //
+ // f) Submit preferred user language (Not implemented)
+ //
+
+ Return (3)
+
+ }
+ Case (7)
+ {
+ //
+ // g) Submit TPM Operation Request to Pre-OS Environment 2
+ //
+ Store (7, PPIP)
+ Store (DerefOf (Index (Arg2, 0x00)), PPRQ)
+
+ //
+ // Triggle the SMI interrupt
+ //
+ Store (PPIN, IOB2)
+ Return (FRET)
+ }
+ Case (8)
+ {
+ //
+ // e) Get User Confirmation Status for Operation
+ //
+ Store (8, PPIP)
+ Store (DerefOf (Index (Arg2, 0x00)), PPRQ)
+
+ //
+ // Triggle the SMI interrupt
+ //
+ Store (PPIN, IOB2)
+
+ Return (FRET)
+ }
+
+ Default {BreakPoint}
+ }
+ Return (1)
+ }
+
+ Method (TMCI, 3, Serialized, 0, IntObj, {UnknownObj, UnknownObj, UnknownObj}) // IntObj, IntObj, PkgObj
+ {
+ //
+ // Switch by function index
+ //
+ Switch (ToInteger (Arg1))
+ {
+ Case (0)
+ {
+ //
+ // Standard query, supports function 1-1
+ //
+ Return (Buffer () {0x03})
+ }
+ Case (1)
+ {
+ //
+ // Save the Operation Value of the Request to MORD (reserved memory)
+ //
+ Store (DerefOf (Index (Arg2, 0x00)), MORD)
+
+ //
+ // Triggle the SMI through ACPI _DSM method.
+ //
+ Store (0x01, MCIP)
+
+ //
+ // Triggle the SMI interrupt
+ //
+ Store (MCIN, IOB2)
+ Return (MRET)
+ }
+ Default {BreakPoint}
+ }
+ Return (1)
+ }
+
+ Method (_DSM, 4, Serialized, 0, UnknownObj, {BuffObj, IntObj, IntObj, PkgObj})
+ {
+
+ //
+ // TCG Hardware Information
+ //
+ If(LEqual(Arg0, ToUUID ("cf8e16a5-c1e8-4e25-b712-4f54a96702c8")))
+ {
+ Return (HINF (Arg1, Arg2, Arg3))
+ }
+
+ //
+ // TCG Physical Presence Interface
+ //
+ If(LEqual(Arg0, ToUUID ("3dddfaa6-361b-4eb4-a424-8d10089d1653")))
+ {
+ Return (TPPI (Arg1, Arg2, Arg3))
+ }
+
+ //
+ // TCG Memory Clear Interface
+ //
+ If(LEqual(Arg0, ToUUID ("376054ed-cc13-4675-901c-4756d7f2d45d")))
+ {
+ Return (TMCI (Arg1, Arg2, Arg3))
+ }
+
+ Return (Buffer () {0})
+ }
+ }
+ }
+}
diff --git a/SecurityPkg/Tcg/TrEESmm/TrEESmm.c b/SecurityPkg/Tcg/TrEESmm/TrEESmm.c
new file mode 100644
index 000000000..4826b7916
--- /dev/null
+++ b/SecurityPkg/Tcg/TrEESmm/TrEESmm.c
@@ -0,0 +1,480 @@
+/** @file
+ It updates TPM2 items in ACPI table and registers SMI2 callback
+ functions for TrEE physical presence, ClearMemory, and sample
+ for dTPM StartMethod.
+
+ Caution: This module requires additional review when modified.
+ This driver will have external input - variable and ACPINvs data in SMM mode.
+ This external input must be validated carefully to avoid security issue.
+
+ PhysicalPresenceCallback() and MemoryClearCallback() will receive untrusted input and do some check.
+
+Copyright (c) 2013, 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.
+
+**/
+
+#include "TrEESmm.h"
+
+EFI_TPM2_ACPI_TABLE mTpm2AcpiTemplate = {
+ {
+ EFI_ACPI_5_0_TRUSTED_COMPUTING_PLATFORM_2_TABLE_SIGNATURE,
+ sizeof (mTpm2AcpiTemplate),
+ EFI_TPM2_ACPI_TABLE_REVISION,
+ //
+ // Compiler initializes the remaining bytes to 0
+ // These fields should be filled in in production
+ //
+ },
+ 0, // Flags
+ 0, // Control Area
+ EFI_TPM2_ACPI_TABLE_START_METHOD_TIS, // StartMethod
+};
+
+EFI_SMM_VARIABLE_PROTOCOL *mSmmVariable;
+TCG_NVS *mTcgNvs;
+
+/**
+ Software SMI callback for TPM physical presence which is called from ACPI method.
+
+ Caution: This function may receive untrusted input.
+ Variable and ACPINvs are external input, so this function will validate
+ its data structure to be valid value.
+
+ @param[in] DispatchHandle The unique handle assigned to this handler by SmiHandlerRegister().
+ @param[in] Context Points to an optional handler context which was specified when the
+ handler was registered.
+ @param[in, out] CommBuffer A pointer to a collection of data in memory that will
+ be conveyed from a non-SMM environment into an SMM environment.
+ @param[in, out] CommBufferSize The size of the CommBuffer.
+
+ @retval EFI_SUCCESS The interrupt was handled successfully.
+
+**/
+EFI_STATUS
+EFIAPI
+PhysicalPresenceCallback (
+ IN EFI_HANDLE DispatchHandle,
+ IN CONST VOID *Context,
+ IN OUT VOID *CommBuffer,
+ IN OUT UINTN *CommBufferSize
+ )
+{
+ EFI_STATUS Status;
+ UINTN DataSize;
+ EFI_TREE_PHYSICAL_PRESENCE PpData;
+ UINT8 Flags;
+ BOOLEAN RequestConfirmed;
+
+ //
+ // Get the Physical Presence variable
+ //
+ DataSize = sizeof (EFI_TREE_PHYSICAL_PRESENCE);
+ Status = mSmmVariable->SmmGetVariable (
+ TREE_PHYSICAL_PRESENCE_VARIABLE,
+ &gEfiTrEEPhysicalPresenceGuid,
+ NULL,
+ &DataSize,
+ &PpData
+ );
+ if (EFI_ERROR (Status)) {
+ return EFI_SUCCESS;
+ }
+
+ DEBUG ((EFI_D_INFO, "[TPM2] PP callback, Parameter = %x, Request = %x\n", mTcgNvs->PhysicalPresence.Parameter, mTcgNvs->PhysicalPresence.Request));
+
+ if (mTcgNvs->PhysicalPresence.Parameter == ACPI_FUNCTION_RETURN_REQUEST_RESPONSE_TO_OS) {
+ mTcgNvs->PhysicalPresence.LastRequest = PpData.LastPPRequest;
+ mTcgNvs->PhysicalPresence.Response = PpData.PPResponse;
+ } else if ((mTcgNvs->PhysicalPresence.Parameter == ACPI_FUNCTION_SUBMIT_REQUEST_TO_BIOS)
+ || (mTcgNvs->PhysicalPresence.Parameter == ACPI_FUNCTION_SUBMIT_REQUEST_TO_BIOS_2)) {
+ if (mTcgNvs->PhysicalPresence.Request > TREE_PHYSICAL_PRESENCE_NO_ACTION_MAX) {
+ //
+ // This command requires UI to prompt user for Auth data.
+ //
+ mTcgNvs->PhysicalPresence.ReturnCode = PP_SUBMIT_REQUEST_NOT_IMPLEMENTED;
+ return EFI_SUCCESS;
+ }
+
+ if (PpData.PPRequest != mTcgNvs->PhysicalPresence.Request) {
+ PpData.PPRequest = (UINT8) mTcgNvs->PhysicalPresence.Request;
+ DataSize = sizeof (EFI_TREE_PHYSICAL_PRESENCE);
+ Status = mSmmVariable->SmmSetVariable (
+ TREE_PHYSICAL_PRESENCE_VARIABLE,
+ &gEfiTrEEPhysicalPresenceGuid,
+ EFI_VARIABLE_NON_VOLATILE | EFI_VARIABLE_BOOTSERVICE_ACCESS | EFI_VARIABLE_RUNTIME_ACCESS,
+ DataSize,
+ &PpData
+ );
+ }
+
+ if (EFI_ERROR (Status)) {
+ mTcgNvs->PhysicalPresence.ReturnCode = PP_SUBMIT_REQUEST_GENERAL_FAILURE;
+ return EFI_SUCCESS;
+ }
+ mTcgNvs->PhysicalPresence.ReturnCode = PP_SUBMIT_REQUEST_SUCCESS;
+ } else if (mTcgNvs->PhysicalPresence.Parameter == ACPI_FUNCTION_GET_USER_CONFIRMATION_STATUS_FOR_REQUEST) {
+ //
+ // Get the Physical Presence flags
+ //
+ DataSize = sizeof (UINT8);
+ Status = mSmmVariable->SmmGetVariable (
+ TREE_PHYSICAL_PRESENCE_FLAGS_VARIABLE,
+ &gEfiTrEEPhysicalPresenceGuid,
+ NULL,
+ &DataSize,
+ &Flags
+ );
+ if (EFI_ERROR (Status)) {
+ mTcgNvs->PhysicalPresence.ReturnCode = PP_SUBMIT_REQUEST_GENERAL_FAILURE;
+ return EFI_SUCCESS;
+ }
+
+ RequestConfirmed = FALSE;
+
+ switch (mTcgNvs->PhysicalPresence.Request) {
+
+ case TREE_PHYSICAL_PRESENCE_CLEAR_CONTROL_CLEAR:
+ case TREE_PHYSICAL_PRESENCE_CLEAR_CONTROL_CLEAR_2:
+ case TREE_PHYSICAL_PRESENCE_CLEAR_CONTROL_CLEAR_3:
+ case TREE_PHYSICAL_PRESENCE_CLEAR_CONTROL_CLEAR_4:
+ if ((Flags & TREE_FLAG_NO_PPI_CLEAR) != 0) {
+ RequestConfirmed = TRUE;
+ }
+ break;
+
+ case TREE_PHYSICAL_PRESENCE_SET_NO_PPI_CLEAR_FALSE:
+ RequestConfirmed = TRUE;
+ break;
+
+ case TREE_PHYSICAL_PRESENCE_SET_NO_PPI_CLEAR_TRUE:
+ break;
+
+ default:
+ if (mTcgNvs->PhysicalPresence.Request <= TREE_PHYSICAL_PRESENCE_NO_ACTION_MAX) {
+ RequestConfirmed = TRUE;
+ } else {
+ mTcgNvs->PhysicalPresence.ReturnCode = PP_REQUEST_NOT_IMPLEMENTED;
+ return EFI_SUCCESS;
+ }
+ break;
+ }
+
+ if (RequestConfirmed) {
+ mTcgNvs->PhysicalPresence.ReturnCode = PP_REQUEST_ALLOWED_AND_PPUSER_NOT_REQUIRED;
+ } else {
+ mTcgNvs->PhysicalPresence.ReturnCode = PP_REQUEST_ALLOWED_AND_PPUSER_REQUIRED;
+ }
+ }
+
+ return EFI_SUCCESS;
+}
+
+
+/**
+ Software SMI callback for MemoryClear which is called from ACPI method.
+
+ Caution: This function may receive untrusted input.
+ Variable and ACPINvs are external input, so this function will validate
+ its data structure to be valid value.
+
+ @param[in] DispatchHandle The unique handle assigned to this handler by SmiHandlerRegister().
+ @param[in] Context Points to an optional handler context which was specified when the
+ handler was registered.
+ @param[in, out] CommBuffer A pointer to a collection of data in memory that will
+ be conveyed from a non-SMM environment into an SMM environment.
+ @param[in, out] CommBufferSize The size of the CommBuffer.
+
+ @retval EFI_SUCCESS The interrupt was handled successfully.
+
+**/
+EFI_STATUS
+EFIAPI
+MemoryClearCallback (
+ IN EFI_HANDLE DispatchHandle,
+ IN CONST VOID *Context,
+ IN OUT VOID *CommBuffer,
+ IN OUT UINTN *CommBufferSize
+ )
+{
+ EFI_STATUS Status;
+ UINTN DataSize;
+ UINT8 MorControl;
+
+ mTcgNvs->MemoryClear.ReturnCode = MOR_REQUEST_SUCCESS;
+ if (mTcgNvs->MemoryClear.Parameter == ACPI_FUNCTION_DSM_MEMORY_CLEAR_INTERFACE) {
+ MorControl = (UINT8) mTcgNvs->MemoryClear.Request;
+ } else if (mTcgNvs->MemoryClear.Parameter == ACPI_FUNCTION_PTS_CLEAR_MOR_BIT) {
+ DataSize = sizeof (UINT8);
+ Status = mSmmVariable->SmmGetVariable (
+ MEMORY_OVERWRITE_REQUEST_VARIABLE_NAME,
+ &gEfiMemoryOverwriteControlDataGuid,
+ NULL,
+ &DataSize,
+ &MorControl
+ );
+ if (EFI_ERROR (Status)) {
+ return EFI_SUCCESS;
+ }
+
+ if (MOR_CLEAR_MEMORY_VALUE (MorControl) == 0x0) {
+ return EFI_SUCCESS;
+ }
+ MorControl &= ~MOR_CLEAR_MEMORY_BIT_MASK;
+ }
+
+ DataSize = sizeof (UINT8);
+ Status = mSmmVariable->SmmSetVariable (
+ MEMORY_OVERWRITE_REQUEST_VARIABLE_NAME,
+ &gEfiMemoryOverwriteControlDataGuid,
+ EFI_VARIABLE_NON_VOLATILE | EFI_VARIABLE_BOOTSERVICE_ACCESS | EFI_VARIABLE_RUNTIME_ACCESS,
+ DataSize,
+ &MorControl
+ );
+ if (EFI_ERROR (Status)) {
+ mTcgNvs->MemoryClear.ReturnCode = MOR_REQUEST_GENERAL_FAILURE;
+ }
+
+ return EFI_SUCCESS;
+}
+
+/**
+ Find the operation region in TCG ACPI table by given Name and Size,
+ and initialize it if the region is found.
+
+ @param[in, out] Table The TPM item in ACPI table.
+ @param[in] Name The name string to find in TPM table.
+ @param[in] Size The size of the region to find.
+
+ @return The allocated address for the found region.
+
+**/
+VOID *
+AssignOpRegion (
+ EFI_ACPI_DESCRIPTION_HEADER *Table,
+ UINT32 Name,
+ UINT16 Size
+ )
+{
+ EFI_STATUS Status;
+ AML_OP_REGION_32_8 *OpRegion;
+ EFI_PHYSICAL_ADDRESS MemoryAddress;
+
+ MemoryAddress = SIZE_4GB - 1;
+
+ //
+ // Patch some pointers for the ASL code before loading the SSDT.
+ //
+ for (OpRegion = (AML_OP_REGION_32_8 *) (Table + 1);
+ OpRegion <= (AML_OP_REGION_32_8 *) ((UINT8 *) Table + Table->Length);
+ OpRegion = (AML_OP_REGION_32_8 *) ((UINT8 *) OpRegion + 1)) {
+ if ((OpRegion->OpRegionOp == AML_EXT_REGION_OP) &&
+ (OpRegion->NameString == Name) &&
+ (OpRegion->DWordPrefix == AML_DWORD_PREFIX) &&
+ (OpRegion->BytePrefix == AML_BYTE_PREFIX)) {
+
+ Status = gBS->AllocatePages(AllocateMaxAddress, EfiACPIMemoryNVS, EFI_SIZE_TO_PAGES (Size), &MemoryAddress);
+ ASSERT_EFI_ERROR (Status);
+ ZeroMem ((VOID *)(UINTN)MemoryAddress, Size);
+ OpRegion->RegionOffset = (UINT32) (UINTN) MemoryAddress;
+ OpRegion->RegionLen = (UINT8) Size;
+ break;
+ }
+ }
+
+ return (VOID *) (UINTN) MemoryAddress;
+}
+
+/**
+ Initialize and publish TPM items in ACPI table.
+
+ @retval EFI_SUCCESS The TCG ACPI table is published successfully.
+ @retval Others The TCG ACPI table is not published.
+
+**/
+EFI_STATUS
+PublishAcpiTable (
+ VOID
+ )
+{
+ EFI_STATUS Status;
+ EFI_ACPI_TABLE_PROTOCOL *AcpiTable;
+ UINTN TableKey;
+ EFI_ACPI_DESCRIPTION_HEADER *Table;
+ UINTN TableSize;
+
+ Status = GetSectionFromFv (
+ &gEfiCallerIdGuid,
+ EFI_SECTION_RAW,
+ 0,
+ (VOID **) &Table,
+ &TableSize
+ );
+ ASSERT_EFI_ERROR (Status);
+
+
+ //
+ // Measure to PCR[0] with event EV_POST_CODE ACPI DATA
+ //
+ TpmMeasureAndLogData(
+ 0,
+ EV_POST_CODE,
+ EV_POSTCODE_INFO_ACPI_DATA,
+ ACPI_DATA_LEN,
+ Table,
+ TableSize
+ );
+
+
+ ASSERT (Table->OemTableId == SIGNATURE_64 ('T', 'p', 'm', '2', 'T', 'a', 'b', 'l'));
+ CopyMem (Table->OemId, PcdGetPtr (PcdAcpiDefaultOemId), sizeof (Table->OemId) );
+ mTcgNvs = AssignOpRegion (Table, SIGNATURE_32 ('T', 'N', 'V', 'S'), (UINT16) sizeof (TCG_NVS));
+ ASSERT (mTcgNvs != NULL);
+
+ //
+ // Publish the TPM ACPI table
+ //
+ Status = gBS->LocateProtocol (&gEfiAcpiTableProtocolGuid, NULL, (VOID **) &AcpiTable);
+ ASSERT_EFI_ERROR (Status);
+
+ TableKey = 0;
+ Status = AcpiTable->InstallAcpiTable (
+ AcpiTable,
+ Table,
+ TableSize,
+ &TableKey
+ );
+ ASSERT_EFI_ERROR (Status);
+
+ return Status;
+}
+
+/**
+ Publish TPM2 ACPI table
+
+ @retval EFI_SUCCESS The TPM2 ACPI table is published successfully.
+ @retval Others The TPM2 ACPI table is not published.
+
+**/
+EFI_STATUS
+PublishTpm2 (
+ VOID
+ )
+{
+ EFI_STATUS Status;
+ EFI_ACPI_TABLE_PROTOCOL *AcpiTable;
+ UINTN TableKey;
+ UINT64 OemTableId;
+
+ //
+ // Measure to PCR[0] with event EV_POST_CODE ACPI DATA
+ //
+ TpmMeasureAndLogData(
+ 0,
+ EV_POST_CODE,
+ EV_POSTCODE_INFO_ACPI_DATA,
+ ACPI_DATA_LEN,
+ &mTpm2AcpiTemplate,
+ sizeof(mTpm2AcpiTemplate)
+ );
+
+ CopyMem (mTpm2AcpiTemplate.Header.OemId, PcdGetPtr (PcdAcpiDefaultOemId), sizeof (mTpm2AcpiTemplate.Header.OemId));
+ OemTableId = PcdGet64 (PcdAcpiDefaultOemTableId);
+ CopyMem (&mTpm2AcpiTemplate.Header.OemTableId, &OemTableId, sizeof (UINT64));
+ mTpm2AcpiTemplate.Header.OemRevision = PcdGet32 (PcdAcpiDefaultOemRevision);
+ mTpm2AcpiTemplate.Header.CreatorId = PcdGet32 (PcdAcpiDefaultCreatorId);
+ mTpm2AcpiTemplate.Header.CreatorRevision = PcdGet32 (PcdAcpiDefaultCreatorRevision);
+
+ //
+ // Construct ACPI table
+ //
+ Status = gBS->LocateProtocol (&gEfiAcpiTableProtocolGuid, NULL, (VOID **) &AcpiTable);
+ ASSERT_EFI_ERROR (Status);
+
+ Status = AcpiTable->InstallAcpiTable (
+ AcpiTable,
+ &mTpm2AcpiTemplate,
+ sizeof(mTpm2AcpiTemplate),
+ &TableKey
+ );
+ ASSERT_EFI_ERROR (Status);
+
+ return Status;
+}
+
+/**
+ The driver's entry point.
+
+ It install callbacks for TPM physical presence and MemoryClear, and locate
+ SMM variable to be used in the callback function.
+
+ @param[in] ImageHandle The firmware allocated handle for the EFI image.
+ @param[in] SystemTable A pointer to the EFI System Table.
+
+ @retval EFI_SUCCESS The entry point is executed successfully.
+ @retval Others Some error occurs when executing this entry point.
+
+**/
+EFI_STATUS
+EFIAPI
+InitializeTcgSmm (
+ IN EFI_HANDLE ImageHandle,
+ IN EFI_SYSTEM_TABLE *SystemTable
+ )
+{
+ EFI_STATUS Status;
+ EFI_SMM_SW_DISPATCH2_PROTOCOL *SwDispatch;
+ EFI_SMM_SW_REGISTER_CONTEXT SwContext;
+ EFI_HANDLE SwHandle;
+
+ if (!CompareGuid (PcdGetPtr(PcdTpmInstanceGuid), &gEfiTpmDeviceInstanceTpm20DtpmGuid)){
+ DEBUG ((EFI_D_ERROR, "No TPM2 DTPM instance required!\n"));
+ return EFI_UNSUPPORTED;
+ }
+
+ Status = PublishAcpiTable ();
+ ASSERT_EFI_ERROR (Status);
+
+ //
+ // Get the Sw dispatch protocol and register SMI callback functions.
+ //
+ Status = gSmst->SmmLocateProtocol (&gEfiSmmSwDispatch2ProtocolGuid, NULL, (VOID**)&SwDispatch);
+ ASSERT_EFI_ERROR (Status);
+ SwContext.SwSmiInputValue = (UINTN) -1;
+ Status = SwDispatch->Register (SwDispatch, PhysicalPresenceCallback, &SwContext, &SwHandle);
+ ASSERT_EFI_ERROR (Status);
+ if (EFI_ERROR (Status)) {
+ return Status;
+ }
+ mTcgNvs->PhysicalPresence.SoftwareSmi = (UINT8) SwContext.SwSmiInputValue;
+
+ SwContext.SwSmiInputValue = (UINTN) -1;
+ Status = SwDispatch->Register (SwDispatch, MemoryClearCallback, &SwContext, &SwHandle);
+ ASSERT_EFI_ERROR (Status);
+ if (EFI_ERROR (Status)) {
+ return Status;
+ }
+ mTcgNvs->MemoryClear.SoftwareSmi = (UINT8) SwContext.SwSmiInputValue;
+
+ //
+ // Locate SmmVariableProtocol.
+ //
+ Status = gSmst->SmmLocateProtocol (&gEfiSmmVariableProtocolGuid, NULL, (VOID**)&mSmmVariable);
+ ASSERT_EFI_ERROR (Status);
+
+ //
+ // Set TPM2 ACPI table
+ //
+ Status = PublishTpm2 ();
+ ASSERT_EFI_ERROR (Status);
+
+
+ return EFI_SUCCESS;
+}
+
diff --git a/SecurityPkg/Tcg/TrEESmm/TrEESmm.h b/SecurityPkg/Tcg/TrEESmm/TrEESmm.h
new file mode 100644
index 000000000..8f4117e1e
--- /dev/null
+++ b/SecurityPkg/Tcg/TrEESmm/TrEESmm.h
@@ -0,0 +1,117 @@
+/** @file
+ The header file for TrEE SMM driver.
+
+Copyright (c) 2013, 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.
+
+**/
+
+#ifndef __TREE_SMM_H__
+#define __TREE_SMM_H__
+
+#include <PiDxe.h>
+#include <IndustryStandard/Acpi.h>
+#include <IndustryStandard/Tpm2Acpi.h>
+
+#include <Guid/TrEEPhysicalPresenceData.h>
+#include <Guid/MemoryOverwriteControl.h>
+#include <Guid/TpmInstance.h>
+
+#include <Protocol/SmmSwDispatch2.h>
+#include <Protocol/AcpiTable.h>
+#include <Protocol/SmmVariable.h>
+#include <Protocol/TrEEProtocol.h>
+
+#include <Library/BaseLib.h>
+#include <Library/BaseMemoryLib.h>
+#include <Library/DebugLib.h>
+#include <Library/SmmServicesTableLib.h>
+#include <Library/UefiDriverEntryPoint.h>
+#include <Library/UefiBootServicesTableLib.h>
+#include <Library/DxeServicesLib.h>
+#include <Library/TpmMeasurementLib.h>
+#include <Library/Tpm2DeviceLib.h>
+
+#pragma pack(1)
+typedef struct {
+ UINT8 SoftwareSmi;
+ UINT32 Parameter;
+ UINT32 Response;
+ UINT32 Request;
+ UINT32 LastRequest;
+ UINT32 ReturnCode;
+} PHYSICAL_PRESENCE_NVS;
+
+typedef struct {
+ UINT8 SoftwareSmi;
+ UINT32 Parameter;
+ UINT32 Request;
+ UINT32 ReturnCode;
+} MEMORY_CLEAR_NVS;
+
+typedef struct {
+ PHYSICAL_PRESENCE_NVS PhysicalPresence;
+ MEMORY_CLEAR_NVS MemoryClear;
+} TCG_NVS;
+
+typedef struct {
+ UINT8 OpRegionOp;
+ UINT32 NameString;
+ UINT8 RegionSpace;
+ UINT8 DWordPrefix;
+ UINT32 RegionOffset;
+ UINT8 BytePrefix;
+ UINT8 RegionLen;
+} AML_OP_REGION_32_8;
+#pragma pack()
+
+//
+// The definition for TCG physical presence ACPI function
+//
+#define ACPI_FUNCTION_GET_PHYSICAL_PRESENCE_INTERFACE_VERSION 1
+#define ACPI_FUNCTION_SUBMIT_REQUEST_TO_BIOS 2
+#define ACPI_FUNCTION_GET_PENDING_REQUEST_BY_OS 3
+#define ACPI_FUNCTION_GET_PLATFORM_ACTION_TO_TRANSITION_TO_BIOS 4
+#define ACPI_FUNCTION_RETURN_REQUEST_RESPONSE_TO_OS 5
+#define ACPI_FUNCTION_SUBMIT_PREFERRED_USER_LANGUAGE 6
+#define ACPI_FUNCTION_SUBMIT_REQUEST_TO_BIOS_2 7
+#define ACPI_FUNCTION_GET_USER_CONFIRMATION_STATUS_FOR_REQUEST 8
+
+//
+// The return code for Get User Confirmation Status for Operation
+//
+#define PP_REQUEST_NOT_IMPLEMENTED 0
+#define PP_REQUEST_BIOS_ONLY 1
+#define PP_REQUEST_BLOCKED 2
+#define PP_REQUEST_ALLOWED_AND_PPUSER_REQUIRED 3
+#define PP_REQUEST_ALLOWED_AND_PPUSER_NOT_REQUIRED 4
+
+//
+// The return code for Sumbit TPM Request to Pre-OS Environment
+// and Sumbit TPM Request to Pre-OS Environment 2
+//
+#define PP_SUBMIT_REQUEST_SUCCESS 0
+#define PP_SUBMIT_REQUEST_NOT_IMPLEMENTED 1
+#define PP_SUBMIT_REQUEST_GENERAL_FAILURE 2
+#define PP_SUBMIT_REQUEST_BLOCKED_BY_BIOS_SETTINGS 3
+
+
+//
+// The definition for TCG MOR
+//
+#define ACPI_FUNCTION_DSM_MEMORY_CLEAR_INTERFACE 1
+#define ACPI_FUNCTION_PTS_CLEAR_MOR_BIT 2
+
+//
+// The return code for Memory Clear Interface Functions
+//
+#define MOR_REQUEST_SUCCESS 0
+#define MOR_REQUEST_GENERAL_FAILURE 1
+
+#endif // __TCG_SMM_H__
diff --git a/SecurityPkg/Tcg/TrEESmm/TrEESmm.inf b/SecurityPkg/Tcg/TrEESmm/TrEESmm.inf
new file mode 100644
index 000000000..bb251d423
--- /dev/null
+++ b/SecurityPkg/Tcg/TrEESmm/TrEESmm.inf
@@ -0,0 +1,71 @@
+## @file
+# This driver implements TPM2 definition block in ACPI table and
+# registers SMI callback functions for TrEE physical presence and
+# MemoryClear to handle the requests from ACPI method.
+#
+# Caution: This module requires additional review when modified.
+# This driver will have external input - variable and ACPINvs data in SMM mode.
+# This external input must be validated carefully to avoid security issue.
+#
+# Copyright (c) 2013, 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.
+#
+##
+
+[Defines]
+ INF_VERSION = 0x00010005
+ BASE_NAME = TrEESmm
+ FILE_GUID = 114B7105-6CC9-453c-BADC-16DF227BB4EF
+ MODULE_TYPE = DXE_SMM_DRIVER
+ PI_SPECIFICATION_VERSION = 0x0001000A
+ VERSION_STRING = 1.0
+ ENTRY_POINT = InitializeTcgSmm
+
+[Sources]
+ TrEESmm.h
+ TrEESmm.c
+ Tpm.asl
+
+[Packages]
+ MdePkg/MdePkg.dec
+ MdeModulePkg/MdeModulePkg.dec
+ SecurityPkg/SecurityPkg.dec
+
+[LibraryClasses]
+ BaseLib
+ BaseMemoryLib
+ UefiDriverEntryPoint
+ SmmServicesTableLib
+ UefiBootServicesTableLib
+ DebugLib
+ DxeServicesLib
+ TpmMeasurementLib
+ Tpm2DeviceLib
+
+[Guids]
+ gEfiTrEEPhysicalPresenceGuid
+ gEfiMemoryOverwriteControlDataGuid
+ gEfiTpmDeviceInstanceTpm20DtpmGuid
+
+[Protocols]
+ gEfiSmmSwDispatch2ProtocolGuid # PROTOCOL ALWAYS_CONSUMED
+ gEfiSmmVariableProtocolGuid # PROTOCOL ALWAYS_CONSUMED
+ gEfiAcpiTableProtocolGuid # PROTOCOL ALWAYS_CONSUMED
+
+[Pcd]
+ gEfiSecurityPkgTokenSpaceGuid.PcdTpmInstanceGuid
+ gEfiMdeModulePkgTokenSpaceGuid.PcdAcpiDefaultOemId
+ gEfiMdeModulePkgTokenSpaceGuid.PcdAcpiDefaultOemTableId
+ gEfiMdeModulePkgTokenSpaceGuid.PcdAcpiDefaultOemRevision
+ gEfiMdeModulePkgTokenSpaceGuid.PcdAcpiDefaultCreatorId
+ gEfiMdeModulePkgTokenSpaceGuid.PcdAcpiDefaultCreatorRevision
+
+[Depex]
+ gEfiAcpiTableProtocolGuid AND
+ gEfiSmmSwDispatch2ProtocolGuid AND
+ gEfiSmmVariableProtocolGuid
diff --git a/SecurityPkg/VariableAuthenticated/RuntimeDxe/AuthService.c b/SecurityPkg/VariableAuthenticated/RuntimeDxe/AuthService.c
index 7da0d63ab..8e9135709 100644
--- a/SecurityPkg/VariableAuthenticated/RuntimeDxe/AuthService.c
+++ b/SecurityPkg/VariableAuthenticated/RuntimeDxe/AuthService.c
@@ -36,6 +36,8 @@ UINT8 mPubKeyStore[MAX_KEYDB_SIZE];
UINT32 mPubKeyNumber;
UINT8 mCertDbStore[MAX_CERTDB_SIZE];
UINT32 mPlatformMode;
+UINT8 mVendorKeyState;
+
EFI_GUID mSignatureSupport[] = {EFI_CERT_SHA1_GUID, EFI_CERT_SHA256_GUID, EFI_CERT_RSA2048_GUID, EFI_CERT_X509_GUID};
//
// Public Exponent of RSA Key.
@@ -255,7 +257,7 @@ AutenticatedVariableServiceInitialize (
}
//
- // Create "SetupMode" varable with BS+RT attribute set.
+ // Create "SetupMode" variable with BS+RT attribute set.
//
FindVariable (EFI_SETUP_MODE_NAME, &gEfiGlobalVariableGuid, &Variable, &mVariableModuleGlobal->VariableGlobal, FALSE);
if (PkVariable.CurrPtr == NULL) {
@@ -279,7 +281,7 @@ AutenticatedVariableServiceInitialize (
}
//
- // Create "SignatureSupport" varable with BS+RT attribute set.
+ // Create "SignatureSupport" variable with BS+RT attribute set.
//
FindVariable (EFI_SIGNATURE_SUPPORT_NAME, &gEfiGlobalVariableGuid, &Variable, &mVariableModuleGlobal->VariableGlobal, FALSE);
Status = UpdateVariable (
@@ -328,7 +330,7 @@ AutenticatedVariableServiceInitialize (
}
//
- // Create "SecureBoot" varable with BS+RT attribute set.
+ // Create "SecureBoot" variable with BS+RT attribute set.
//
if (SecureBootEnable == SECURE_BOOT_ENABLE && mPlatformMode == USER_MODE) {
SecureBootMode = SECURE_BOOT_MODE_ENABLE;
@@ -409,6 +411,54 @@ AutenticatedVariableServiceInitialize (
}
}
+ //
+ // Check "VendorKeysNv" variable's existence and create "VendorKeys" variable accordingly.
+ //
+ FindVariable (EFI_VENDOR_KEYS_NV_VARIABLE_NAME, &gEfiVendorKeysNvGuid, &Variable, &mVariableModuleGlobal->VariableGlobal, FALSE);
+ if (Variable.CurrPtr != NULL) {
+ mVendorKeyState = *(GetVariableDataPtr (Variable.CurrPtr));
+ } else {
+ //
+ // "VendorKeysNv" not exist, initialize it in VENDOR_KEYS_VALID state.
+ //
+ mVendorKeyState = VENDOR_KEYS_VALID;
+ Status = UpdateVariable (
+ EFI_VENDOR_KEYS_NV_VARIABLE_NAME,
+ &gEfiVendorKeysNvGuid,
+ &mVendorKeyState,
+ sizeof (UINT8),
+ EFI_VARIABLE_NON_VOLATILE | EFI_VARIABLE_BOOTSERVICE_ACCESS | EFI_VARIABLE_TIME_BASED_AUTHENTICATED_WRITE_ACCESS,
+ 0,
+ 0,
+ &Variable,
+ NULL
+ );
+ if (EFI_ERROR (Status)) {
+ return Status;
+ }
+ }
+
+ //
+ // Create "VendorKeys" variable with BS+RT attribute set.
+ //
+ FindVariable (EFI_VENDOR_KEYS_VARIABLE_NAME, &gEfiGlobalVariableGuid, &Variable, &mVariableModuleGlobal->VariableGlobal, FALSE);
+ Status = UpdateVariable (
+ EFI_VENDOR_KEYS_VARIABLE_NAME,
+ &gEfiGlobalVariableGuid,
+ &mVendorKeyState,
+ sizeof (UINT8),
+ EFI_VARIABLE_RUNTIME_ACCESS | EFI_VARIABLE_BOOTSERVICE_ACCESS,
+ 0,
+ 0,
+ &Variable,
+ NULL
+ );
+ if (EFI_ERROR (Status)) {
+ return Status;
+ }
+
+ DEBUG ((EFI_D_INFO, "Variable %s is %x\n", EFI_VENDOR_KEYS_VARIABLE_NAME, mVendorKeyState));
+
return Status;
}
@@ -912,6 +962,56 @@ CheckSignatureListFormat(
}
/**
+ Update "VendorKeys" variable to record the out of band secure boot key modification.
+
+ @return EFI_SUCCESS Variable is updated successfully.
+ @return Others Failed to update variable.
+
+**/
+EFI_STATUS
+VendorKeyIsModified (
+ VOID
+ )
+{
+ EFI_STATUS Status;
+ VARIABLE_POINTER_TRACK Variable;
+
+ if (mVendorKeyState == VENDOR_KEYS_MODIFIED) {
+ return EFI_SUCCESS;
+ }
+ mVendorKeyState = VENDOR_KEYS_MODIFIED;
+
+ FindVariable (EFI_VENDOR_KEYS_NV_VARIABLE_NAME, &gEfiVendorKeysNvGuid, &Variable, &mVariableModuleGlobal->VariableGlobal, FALSE);
+ Status = UpdateVariable (
+ EFI_VENDOR_KEYS_NV_VARIABLE_NAME,
+ &gEfiVendorKeysNvGuid,
+ &mVendorKeyState,
+ sizeof (UINT8),
+ EFI_VARIABLE_NON_VOLATILE | EFI_VARIABLE_BOOTSERVICE_ACCESS | EFI_VARIABLE_TIME_BASED_AUTHENTICATED_WRITE_ACCESS,
+ 0,
+ 0,
+ &Variable,
+ NULL
+ );
+ if (EFI_ERROR (Status)) {
+ return Status;
+ }
+
+ FindVariable (EFI_VENDOR_KEYS_VARIABLE_NAME, &gEfiGlobalVariableGuid, &Variable, &mVariableModuleGlobal->VariableGlobal, FALSE);
+ return UpdateVariable (
+ EFI_VENDOR_KEYS_VARIABLE_NAME,
+ &gEfiGlobalVariableGuid,
+ &mVendorKeyState,
+ sizeof (UINT8),
+ EFI_VARIABLE_RUNTIME_ACCESS | EFI_VARIABLE_BOOTSERVICE_ACCESS,
+ 0,
+ 0,
+ &Variable,
+ NULL
+ );
+}
+
+/**
Process variable with platform key for verification.
Caution: This function may receive untrusted input.
@@ -985,6 +1085,13 @@ ProcessVarWithPk (
Variable,
&((EFI_VARIABLE_AUTHENTICATION_2 *) Data)->TimeStamp
);
+ if (EFI_ERROR(Status)) {
+ return Status;
+ }
+
+ if ((mPlatformMode != SETUP_MODE) || IsPk) {
+ Status = VendorKeyIsModified ();
+ }
} else if (mPlatformMode == USER_MODE) {
//
// Verify against X509 Cert in PK database.
@@ -1117,6 +1224,13 @@ ProcessVarWithKek (
Variable,
&((EFI_VARIABLE_AUTHENTICATION_2 *) Data)->TimeStamp
);
+ if (EFI_ERROR (Status)) {
+ return Status;
+ }
+
+ if (mPlatformMode != SETUP_MODE) {
+ Status = VendorKeyIsModified ();
+ }
}
return Status;
@@ -2081,7 +2195,24 @@ VerifyTimeBasedPayload (
if (AuthVarType == AuthVarTypePk) {
//
- // Get platform key from variable.
+ // Verify that the signature has been made with the current Platform Key (no chaining for PK).
+ // First, get signer's certificates from SignedData.
+ //
+ VerifyStatus = Pkcs7GetSigners (
+ SigData,
+ SigDataSize,
+ &SignerCerts,
+ &CertStackSize,
+ &RootCert,
+ &RootCertSize
+ );
+ if (!VerifyStatus) {
+ goto Exit;
+ }
+
+ //
+ // Second, get the current platform key from variable. Check whether it's identical with signer's certificates
+ // in SignedData. If not, return error immediately.
//
Status = FindVariable (
EFI_PLATFORM_KEY_NAME,
@@ -2091,14 +2222,16 @@ VerifyTimeBasedPayload (
FALSE
);
if (EFI_ERROR (Status)) {
- return Status;
+ VerifyStatus = FALSE;
+ goto Exit;
}
-
CertList = (EFI_SIGNATURE_LIST *) GetVariableDataPtr (PkVariable.CurrPtr);
Cert = (EFI_SIGNATURE_DATA *) ((UINT8 *) CertList + sizeof (EFI_SIGNATURE_LIST) + CertList->SignatureHeaderSize);
- RootCert = Cert->SignatureData;
- RootCertSize = CertList->SignatureSize - (sizeof (EFI_SIGNATURE_DATA) - 1);
-
+ if ((RootCertSize != (CertList->SignatureSize - (sizeof (EFI_SIGNATURE_DATA) - 1))) ||
+ (CompareMem (Cert->SignatureData, RootCert, RootCertSize) != 0)) {
+ VerifyStatus = FALSE;
+ goto Exit;
+ }
//
// Verify Pkcs7 SignedData via Pkcs7Verify library.
@@ -2254,7 +2387,7 @@ VerifyTimeBasedPayload (
Exit:
- if (AuthVarType == AuthVarTypePriv) {
+ if (AuthVarType == AuthVarTypePk || AuthVarType == AuthVarTypePriv) {
Pkcs7FreeSigners (RootCert);
Pkcs7FreeSigners (SignerCerts);
}
diff --git a/SecurityPkg/VariableAuthenticated/RuntimeDxe/Measurement.c b/SecurityPkg/VariableAuthenticated/RuntimeDxe/Measurement.c
new file mode 100644
index 000000000..41e9b6f5e
--- /dev/null
+++ b/SecurityPkg/VariableAuthenticated/RuntimeDxe/Measurement.c
@@ -0,0 +1,255 @@
+/** @file
+ Measure TrEE required variable.
+
+Copyright (c) 2013, 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.
+
+**/
+
+#include <PiDxe.h>
+#include <Guid/ImageAuthentication.h>
+#include <IndustryStandard/UefiTcgPlatform.h>
+#include <Protocol/TrEEProtocol.h>
+
+#include <Library/UefiBootServicesTableLib.h>
+#include <Library/UefiRuntimeServicesTableLib.h>
+#include <Library/MemoryAllocationLib.h>
+#include <Library/BaseMemoryLib.h>
+#include <Library/DebugLib.h>
+#include <Library/BaseLib.h>
+#include <Library/TpmMeasurementLib.h>
+
+typedef struct {
+ CHAR16 *VariableName;
+ EFI_GUID *VendorGuid;
+} VARIABLE_TYPE;
+
+VARIABLE_TYPE mVariableType[] = {
+ {EFI_SECURE_BOOT_MODE_NAME, &gEfiGlobalVariableGuid},
+ {EFI_PLATFORM_KEY_NAME, &gEfiGlobalVariableGuid},
+ {EFI_KEY_EXCHANGE_KEY_NAME, &gEfiGlobalVariableGuid},
+ {EFI_IMAGE_SECURITY_DATABASE, &gEfiImageSecurityDatabaseGuid},
+ {EFI_IMAGE_SECURITY_DATABASE1, &gEfiImageSecurityDatabaseGuid},
+};
+
+/**
+ This function will return if this variable is SecureBootPolicy Variable.
+
+ @param[in] VariableName A Null-terminated string that is the name of the vendor's variable.
+ @param[in] VendorGuid A unique identifier for the vendor.
+
+ @retval TRUE This is SecureBootPolicy Variable
+ @retval FALSE This is not SecureBootPolicy Variable
+**/
+BOOLEAN
+IsSecureBootPolicyVariable (
+ IN CHAR16 *VariableName,
+ IN EFI_GUID *VendorGuid
+ )
+{
+ UINTN Index;
+
+ for (Index = 0; Index < sizeof(mVariableType)/sizeof(mVariableType[0]); Index++) {
+ if ((StrCmp (VariableName, mVariableType[Index].VariableName) == 0) &&
+ (CompareGuid (VendorGuid, mVariableType[Index].VendorGuid))) {
+ return TRUE;
+ }
+ }
+ return FALSE;
+}
+
+/**
+ Measure and log an EFI variable, and extend the measurement result into a specific PCR.
+
+ @param[in] VarName A Null-terminated string that is the name of the vendor's variable.
+ @param[in] VendorGuid A unique identifier for the vendor.
+ @param[in] VarData The content of the variable data.
+ @param[in] VarSize The size of the variable data.
+
+ @retval EFI_SUCCESS Operation completed successfully.
+ @retval EFI_OUT_OF_RESOURCES Out of memory.
+ @retval EFI_DEVICE_ERROR The operation was unsuccessful.
+
+**/
+EFI_STATUS
+EFIAPI
+MeasureVariable (
+ IN CHAR16 *VarName,
+ IN EFI_GUID *VendorGuid,
+ IN VOID *VarData,
+ IN UINTN VarSize
+ )
+{
+ EFI_STATUS Status;
+ UINTN VarNameLength;
+ EFI_VARIABLE_DATA_TREE *VarLog;
+ UINT32 VarLogSize;
+
+ ASSERT ((VarSize == 0 && VarData == NULL) || (VarSize != 0 && VarData != NULL));
+
+ VarNameLength = StrLen (VarName);
+ VarLogSize = (UINT32)(sizeof (*VarLog) + VarNameLength * sizeof (*VarName) + VarSize
+ - sizeof (VarLog->UnicodeName) - sizeof (VarLog->VariableData));
+
+ VarLog = (EFI_VARIABLE_DATA_TREE *) AllocateZeroPool (VarLogSize);
+ if (VarLog == NULL) {
+ return EFI_OUT_OF_RESOURCES;
+ }
+
+ CopyMem (&VarLog->VariableName, VendorGuid, sizeof(VarLog->VariableName));
+ VarLog->UnicodeNameLength = VarNameLength;
+ VarLog->VariableDataLength = VarSize;
+ CopyMem (
+ VarLog->UnicodeName,
+ VarName,
+ VarNameLength * sizeof (*VarName)
+ );
+ if (VarSize != 0) {
+ CopyMem (
+ (CHAR16 *)VarLog->UnicodeName + VarNameLength,
+ VarData,
+ VarSize
+ );
+ }
+
+ DEBUG ((EFI_D_ERROR, "AuthVariableDxe: MeasureVariable (Pcr - %x, EventType - %x, ", (UINTN)7, (UINTN)EV_EFI_VARIABLE_AUTHORITY));
+ DEBUG ((EFI_D_ERROR, "VariableName - %s, VendorGuid - %g)\n", VarName, VendorGuid));
+
+ Status = TpmMeasureAndLogData (
+ 7,
+ EV_EFI_VARIABLE_DRIVER_CONFIG,
+ VarLog,
+ VarLogSize,
+ VarLog,
+ VarLogSize
+ );
+ FreePool (VarLog);
+ return Status;
+}
+
+/**
+ Returns the status whether get the variable success. The function retrieves
+ variable through the UEFI Runtime Service GetVariable(). The
+ returned buffer is allocated using AllocatePool(). The caller is responsible
+ for freeing this buffer with FreePool().
+
+ This API is only invoked in boot time. It may NOT be invoked at runtime.
+
+ @param[in] Name The pointer to a Null-terminated Unicode string.
+ @param[in] Guid The pointer to an EFI_GUID structure
+ @param[out] Value The buffer point saved the variable info.
+ @param[out] Size The buffer size of the variable.
+
+ @return EFI_OUT_OF_RESOURCES Allocate buffer failed.
+ @return EFI_SUCCESS Find the specified variable.
+ @return Others Errors Return errors from call to gRT->GetVariable.
+
+**/
+EFI_STATUS
+InternalGetVariable (
+ IN CONST CHAR16 *Name,
+ IN CONST EFI_GUID *Guid,
+ OUT VOID **Value,
+ OUT UINTN *Size
+ )
+{
+ EFI_STATUS Status;
+ UINTN BufferSize;
+
+ //
+ // Try to get the variable size.
+ //
+ BufferSize = 0;
+ *Value = NULL;
+ if (Size != NULL) {
+ *Size = 0;
+ }
+
+ Status = gRT->GetVariable ((CHAR16 *) Name, (EFI_GUID *) Guid, NULL, &BufferSize, *Value);
+ if (Status != EFI_BUFFER_TOO_SMALL) {
+ return Status;
+ }
+
+ //
+ // Allocate buffer to get the variable.
+ //
+ *Value = AllocatePool (BufferSize);
+ ASSERT (*Value != NULL);
+ if (*Value == NULL) {
+ return EFI_OUT_OF_RESOURCES;
+ }
+
+ //
+ // Get the variable data.
+ //
+ Status = gRT->GetVariable ((CHAR16 *) Name, (EFI_GUID *) Guid, NULL, &BufferSize, *Value);
+ if (EFI_ERROR (Status)) {
+ FreePool(*Value);
+ *Value = NULL;
+ }
+
+ if (Size != NULL) {
+ *Size = BufferSize;
+ }
+
+ return Status;
+}
+
+/**
+ SecureBoot Hook for SetVariable.
+
+ @param[in] VariableName Name of Variable to be found.
+ @param[in] VendorGuid Variable vendor GUID.
+
+**/
+VOID
+EFIAPI
+SecureBootHook (
+ IN CHAR16 *VariableName,
+ IN EFI_GUID *VendorGuid
+ )
+{
+ EFI_STATUS Status;
+ UINTN VariableDataSize;
+ VOID *VariableData;
+
+ if (!IsSecureBootPolicyVariable (VariableName, VendorGuid)) {
+ return ;
+ }
+
+ //
+ // We should NOT use Data and DataSize here,because it may include signature,
+ // or is just partial with append attributes, or is deleted.
+ // We should GetVariable again, to get full variable content.
+ //
+ Status = InternalGetVariable (
+ VariableName,
+ VendorGuid,
+ &VariableData,
+ &VariableDataSize
+ );
+ if (EFI_ERROR (Status)) {
+ VariableData = NULL;
+ VariableDataSize = 0;
+ }
+
+ Status = MeasureVariable (
+ VariableName,
+ VendorGuid,
+ VariableData,
+ VariableDataSize
+ );
+ DEBUG ((EFI_D_ERROR, "MeasureBootPolicyVariable - %r\n", Status));
+
+ if (VariableData != NULL) {
+ FreePool (VariableData);
+ }
+
+ return ;
+}
diff --git a/SecurityPkg/VariableAuthenticated/RuntimeDxe/Variable.c b/SecurityPkg/VariableAuthenticated/RuntimeDxe/Variable.c
index 5261157ff..a0419f080 100644
--- a/SecurityPkg/VariableAuthenticated/RuntimeDxe/Variable.c
+++ b/SecurityPkg/VariableAuthenticated/RuntimeDxe/Variable.c
@@ -105,6 +105,20 @@ GLOBAL_VARIABLE_ENTRY mGlobalVariableList2[] = {
};
/**
+
+ SecureBoot Hook for auth variable update.
+
+ @param[in] VariableName Name of Variable to be found.
+ @param[in] VendorGuid Variable vendor GUID.
+**/
+VOID
+EFIAPI
+SecureBootHook (
+ IN CHAR16 *VariableName,
+ IN EFI_GUID *VendorGuid
+ );
+
+/**
Routine used to track statistical information about variable usage.
The data is stored in the EFI system table so it can be accessed later.
VariableInfo.efi can dump out the table. Only Boot Services variable
@@ -2500,7 +2514,13 @@ IsReadOnlyVariable (
if (CompareGuid (VendorGuid, &gEfiGlobalVariableGuid)) {
if ((StrCmp (VariableName, EFI_SETUP_MODE_NAME) == 0) ||
(StrCmp (VariableName, EFI_SIGNATURE_SUPPORT_NAME) == 0) ||
- (StrCmp (VariableName, EFI_SECURE_BOOT_MODE_NAME) == 0)) {
+ (StrCmp (VariableName, EFI_SECURE_BOOT_MODE_NAME) == 0) ||
+ (StrCmp (VariableName, EFI_VENDOR_KEYS_VARIABLE_NAME) == 0) ||
+ (StrCmp (VariableName, EFI_KEK_DEFAULT_VARIABLE_NAME) == 0) ||
+ (StrCmp (VariableName, EFI_PK_DEFAULT_VARIABLE_NAME) == 0) ||
+ (StrCmp (VariableName, EFI_DB_DEFAULT_VARIABLE_NAME) == 0) ||
+ (StrCmp (VariableName, EFI_DBX_DEFAULT_VARIABLE_NAME) == 0) ||
+ (StrCmp (VariableName, EFI_DBT_DEFAULT_VARIABLE_NAME) == 0)) {
return TRUE;
}
}
@@ -2975,6 +2995,15 @@ Done:
InterlockedDecrement (&mVariableModuleGlobal->VariableGlobal.ReentrantState);
ReleaseLockOnlyAtBootTime (&mVariableModuleGlobal->VariableGlobal.VariableServicesLock);
+ if (!AtRuntime ()) {
+ if (!EFI_ERROR (Status)) {
+ SecureBootHook (
+ VariableName,
+ VendorGuid
+ );
+ }
+ }
+
return Status;
}
diff --git a/SecurityPkg/VariableAuthenticated/RuntimeDxe/VariableRuntimeDxe.inf b/SecurityPkg/VariableAuthenticated/RuntimeDxe/VariableRuntimeDxe.inf
index 4904adae2..47064647f 100644
--- a/SecurityPkg/VariableAuthenticated/RuntimeDxe/VariableRuntimeDxe.inf
+++ b/SecurityPkg/VariableAuthenticated/RuntimeDxe/VariableRuntimeDxe.inf
@@ -39,6 +39,7 @@
Variable.h
AuthService.c
AuthService.h
+ Measurement.c
[Packages]
MdePkg/MdePkg.dec
@@ -61,6 +62,7 @@
BaseCryptLib
PlatformSecureLib
HobLib
+ TpmMeasurementLib
[Protocols]
gEfiFirmwareVolumeBlockProtocolGuid ## SOMETIMES_CONSUMES
@@ -80,6 +82,7 @@
gEfiCertRsa2048Guid
gEfiSecureBootEnableDisableGuid
gEfiCustomModeEnableGuid
+ gEfiVendorKeysNvGuid
gEfiSystemNvDataFvGuid ## CONSUMES
gEfiCertDbGuid
gEfiHardwareErrorVariableGuid ## SOMETIMES_CONSUMES
diff --git a/SecurityPkg/VariableAuthenticated/RuntimeDxe/VariableSmm.c b/SecurityPkg/VariableAuthenticated/RuntimeDxe/VariableSmm.c
index eaef8d182..4ac582d49 100644
--- a/SecurityPkg/VariableAuthenticated/RuntimeDxe/VariableSmm.c
+++ b/SecurityPkg/VariableAuthenticated/RuntimeDxe/VariableSmm.c
@@ -51,6 +51,23 @@ extern BOOLEAN mEndOfDxe;
extern BOOLEAN mEnableLocking;
/**
+ SecureBoot Hook for SetVariable.
+
+ @param[in] VariableName Name of Variable to be found.
+ @param[in] VendorGuid Variable vendor GUID.
+
+**/
+VOID
+EFIAPI
+SecureBootHook (
+ IN CHAR16 *VariableName,
+ IN EFI_GUID *VendorGuid
+ )
+{
+ return ;
+}
+
+/**
This code sets variable in storage blocks (Volatile or Non-Volatile).
diff --git a/SecurityPkg/VariableAuthenticated/RuntimeDxe/VariableSmm.inf b/SecurityPkg/VariableAuthenticated/RuntimeDxe/VariableSmm.inf
index 4180309c7..5a4082309 100644
--- a/SecurityPkg/VariableAuthenticated/RuntimeDxe/VariableSmm.inf
+++ b/SecurityPkg/VariableAuthenticated/RuntimeDxe/VariableSmm.inf
@@ -86,6 +86,7 @@
gEfiCertRsa2048Guid
gEfiSecureBootEnableDisableGuid
gEfiCustomModeEnableGuid
+ gEfiVendorKeysNvGuid
gEfiSystemNvDataFvGuid ## CONSUMES
gEfiCertDbGuid
gEfiHardwareErrorVariableGuid ## SOMETIMES_CONSUMES
diff --git a/SecurityPkg/VariableAuthenticated/RuntimeDxe/VariableSmmRuntimeDxe.c b/SecurityPkg/VariableAuthenticated/RuntimeDxe/VariableSmmRuntimeDxe.c
index 701134387..f550c67be 100644
--- a/SecurityPkg/VariableAuthenticated/RuntimeDxe/VariableSmmRuntimeDxe.c
+++ b/SecurityPkg/VariableAuthenticated/RuntimeDxe/VariableSmmRuntimeDxe.c
@@ -58,6 +58,20 @@ EFI_LOCK mVariableServicesLock;
EDKII_VARIABLE_LOCK_PROTOCOL mVariableLock;
/**
+ SecureBoot Hook for SetVariable.
+
+ @param[in] VariableName Name of Variable to be found.
+ @param[in] VendorGuid Variable vendor GUID.
+
+**/
+VOID
+EFIAPI
+SecureBootHook (
+ IN CHAR16 *VariableName,
+ IN EFI_GUID *VendorGuid
+ );
+
+/**
Acquires lock only at boot time. Simply returns at runtime.
This is a temperary function that will be removed when
@@ -545,6 +559,15 @@ RuntimeServiceSetVariable (
Done:
ReleaseLockOnlyAtBootTime (&mVariableServicesLock);
+
+ if (!EfiAtRuntime ()) {
+ if (!EFI_ERROR (Status)) {
+ SecureBootHook (
+ VariableName,
+ VendorGuid
+ );
+ }
+ }
return Status;
}
diff --git a/SecurityPkg/VariableAuthenticated/RuntimeDxe/VariableSmmRuntimeDxe.inf b/SecurityPkg/VariableAuthenticated/RuntimeDxe/VariableSmmRuntimeDxe.inf
index a28702765..807e99a78 100644
--- a/SecurityPkg/VariableAuthenticated/RuntimeDxe/VariableSmmRuntimeDxe.inf
+++ b/SecurityPkg/VariableAuthenticated/RuntimeDxe/VariableSmmRuntimeDxe.inf
@@ -38,6 +38,7 @@
[Sources]
VariableSmmRuntimeDxe.c
+ Measurement.c
[Packages]
MdePkg/MdePkg.dec
@@ -53,6 +54,7 @@
DxeServicesTableLib
UefiDriverEntryPoint
PcdLib
+ TpmMeasurementLib
[Protocols]
gEfiVariableWriteArchProtocolGuid ## ALWAYS_PRODUCES
@@ -64,6 +66,7 @@
[Guids]
gEfiEventVirtualAddressChangeGuid ## PRODUCES ## Event
gSmmVariableWriteGuid
+ gEfiImageSecurityDatabaseGuid
[Pcd]
gEfiMdeModulePkgTokenSpaceGuid.PcdMaxVariableSize
diff --git a/ShellBinPkg/MinUefiShell/AArch64/Shell.efi b/ShellBinPkg/MinUefiShell/AArch64/Shell.efi
index ba8e20a75..363b524e2 100755
--- a/ShellBinPkg/MinUefiShell/AArch64/Shell.efi
+++ b/ShellBinPkg/MinUefiShell/AArch64/Shell.efi
Binary files differ
diff --git a/ShellBinPkg/MinUefiShell/Arm/Shell.efi b/ShellBinPkg/MinUefiShell/Arm/Shell.efi
new file mode 100755
index 000000000..70801106a
--- /dev/null
+++ b/ShellBinPkg/MinUefiShell/Arm/Shell.efi
Binary files differ
diff --git a/ShellBinPkg/MinUefiShell/Ia32/Shell.efi b/ShellBinPkg/MinUefiShell/Ia32/Shell.efi
index 5142db743..c86d7506f 100644
--- a/ShellBinPkg/MinUefiShell/Ia32/Shell.efi
+++ b/ShellBinPkg/MinUefiShell/Ia32/Shell.efi
Binary files differ
diff --git a/ShellBinPkg/MinUefiShell/X64/Shell.efi b/ShellBinPkg/MinUefiShell/X64/Shell.efi
index 04eed3a74..8939bcb6d 100644
--- a/ShellBinPkg/MinUefiShell/X64/Shell.efi
+++ b/ShellBinPkg/MinUefiShell/X64/Shell.efi
Binary files differ
diff --git a/ShellBinPkg/ReadMe.txt b/ShellBinPkg/ReadMe.txt
index e0aeedfa2..7c6e2b76b 100644
--- a/ShellBinPkg/ReadMe.txt
+++ b/ShellBinPkg/ReadMe.txt
@@ -2,7 +2,7 @@
OVERVIEW
============================================================================
The binaries of ShellBinPkg are generated with ShellPkg project and built with
-BaseTools Package (r14400). The binaries are built with no debug information
+BaseTools Package (r14706). The binaries are built with no debug information
by building with "RELEASE" target.
The following steps can help to re-generate these binaries for customization:
@@ -41,7 +41,5 @@ developer may integrate this code into an existing platform:
1. RM can delete current working directory via other map name.
2. DrvCfg does not overlap boot manager functionality.
3. Shell documentation is in development and forthcoming.
-4. ARM binaries are based on revision 13646. It is expected the binaries to
-sync with the other architectures next time they are rebuilt.
============================================================================
diff --git a/ShellBinPkg/UefiShell/AArch64/Shell.efi b/ShellBinPkg/UefiShell/AArch64/Shell.efi
index d540088bd..7d722d61a 100755
--- a/ShellBinPkg/UefiShell/AArch64/Shell.efi
+++ b/ShellBinPkg/UefiShell/AArch64/Shell.efi
Binary files differ
diff --git a/ShellBinPkg/UefiShell/Arm/Shell.efi b/ShellBinPkg/UefiShell/Arm/Shell.efi
index 33408743a..1761f30cc 100755
--- a/ShellBinPkg/UefiShell/Arm/Shell.efi
+++ b/ShellBinPkg/UefiShell/Arm/Shell.efi
Binary files differ
diff --git a/ShellBinPkg/UefiShell/Ia32/Shell.efi b/ShellBinPkg/UefiShell/Ia32/Shell.efi
index e53bc0e06..a1d52fbfb 100644
--- a/ShellBinPkg/UefiShell/Ia32/Shell.efi
+++ b/ShellBinPkg/UefiShell/Ia32/Shell.efi
Binary files differ
diff --git a/ShellBinPkg/UefiShell/X64/Shell.efi b/ShellBinPkg/UefiShell/X64/Shell.efi
index b7017693b..711640202 100644
--- a/ShellBinPkg/UefiShell/X64/Shell.efi
+++ b/ShellBinPkg/UefiShell/X64/Shell.efi
Binary files differ
diff --git a/ShellPkg/Application/Shell/Shell.c b/ShellPkg/Application/Shell/Shell.c
index 3019c7d41..e5a648833 100644
--- a/ShellPkg/Application/Shell/Shell.c
+++ b/ShellPkg/Application/Shell/Shell.c
@@ -297,11 +297,28 @@ UefiMain (
0,
gST->ConOut->Mode->CursorRow,
NULL,
- STRING_TOKEN (STR_VER_OUTPUT_MAIN),
+ STRING_TOKEN (STR_VER_OUTPUT_MAIN_SHELL),
ShellInfoObject.HiiHandle,
SupportLevel[PcdGet8(PcdShellSupportLevel)],
gEfiShellProtocol->MajorVersion,
- gEfiShellProtocol->MinorVersion,
+ gEfiShellProtocol->MinorVersion
+ );
+
+ ShellPrintHiiEx (
+ -1,
+ -1,
+ NULL,
+ STRING_TOKEN (STR_VER_OUTPUT_MAIN_SUPPLIER),
+ ShellInfoObject.HiiHandle,
+ (CHAR16 *) PcdGetPtr (PcdShellSupplier)
+ );
+
+ ShellPrintHiiEx (
+ -1,
+ -1,
+ NULL,
+ STRING_TOKEN (STR_VER_OUTPUT_MAIN_UEFI),
+ ShellInfoObject.HiiHandle,
(gST->Hdr.Revision&0xffff0000)>>16,
(gST->Hdr.Revision&0x0000ffff),
gST->FirmwareVendor,
@@ -840,12 +857,12 @@ DoStartupScript(
//
// print out our warning and see if they press a key
//
- for ( Status = EFI_UNSUPPORTED, Delay = ShellInfoObject.ShellInitSettings.Delay * 10
+ for ( Status = EFI_UNSUPPORTED, Delay = ShellInfoObject.ShellInitSettings.Delay
; Delay != 0 && EFI_ERROR(Status)
; Delay--
){
- ShellPrintHiiEx(0, gST->ConOut->Mode->CursorRow, NULL, STRING_TOKEN (STR_SHELL_STARTUP_QUESTION), ShellInfoObject.HiiHandle, Delay/10);
- gBS->Stall (100000);
+ ShellPrintHiiEx(0, gST->ConOut->Mode->CursorRow, NULL, STRING_TOKEN (STR_SHELL_STARTUP_QUESTION), ShellInfoObject.HiiHandle, Delay);
+ gBS->Stall (1000000);
if (!ShellInfoObject.ShellInitSettings.BitUnion.Bits.NoConsoleIn) {
Status = gST->ConIn->ReadKeyStroke (gST->ConIn, &Key);
}
@@ -1396,13 +1413,32 @@ RunCommand(
if (CleanOriginal == NULL) {
return (EFI_OUT_OF_RESOURCES);
}
- while (CleanOriginal[StrLen(CleanOriginal)-1] == L' ') {
- CleanOriginal[StrLen(CleanOriginal)-1] = CHAR_NULL;
- }
+
+ //
+ // Remove any spaces at the beginning of the string.
+ //
while (CleanOriginal[0] == L' ') {
CopyMem(CleanOriginal, CleanOriginal+1, StrSize(CleanOriginal) - sizeof(CleanOriginal[0]));
}
+ //
+ // Handle case that passed in command line is just 1 or more " " characters.
+ //
+ if (StrLen (CleanOriginal) == 0) {
+ if (CleanOriginal != NULL) {
+ FreePool(CleanOriginal);
+ CleanOriginal = NULL;
+ }
+ return (EFI_SUCCESS);
+ }
+
+ //
+ // Remove any spaces at the end of the string.
+ //
+ while (CleanOriginal[StrLen(CleanOriginal)-1] == L' ') {
+ CleanOriginal[StrLen(CleanOriginal)-1] = CHAR_NULL;
+ }
+
CommandName = NULL;
if (StrStr(CleanOriginal, L" ") == NULL){
StrnCatGrow(&CommandName, NULL, CleanOriginal, 0);
@@ -1892,9 +1928,15 @@ RunScriptFileHandle (
Status = RunCommand(CommandLine3+1);
//
- // Now restore the pre-'@' echo state.
+ // If command was "@echo -off" or "@echo -on" then don't restore echo state
//
- ShellCommandSetEchoState(PreCommandEchoState);
+ if (StrCmp (L"@echo -off", CommandLine3) != 0 &&
+ StrCmp (L"@echo -on", CommandLine3) != 0) {
+ //
+ // Now restore the pre-'@' echo state.
+ //
+ ShellCommandSetEchoState(PreCommandEchoState);
+ }
} else {
if (ShellCommandGetEchoState()) {
CurDir = ShellInfoObject.NewEfiShellProtocol->GetEnv(L"cwd");
diff --git a/ShellPkg/Application/Shell/Shell.inf b/ShellPkg/Application/Shell/Shell.inf
index c3af61743..801180ea0 100644
--- a/ShellPkg/Application/Shell/Shell.inf
+++ b/ShellPkg/Application/Shell/Shell.inf
@@ -1,6 +1,7 @@
## @file
# This is the shell application
#
+# Copyright (c) 2013, Hewlett-Packard Development Company, L.P.
# Copyright (c) 2009 - 2013, Intel Corporation. All rights reserved.<BR>
#
# This program and the accompanying materials
@@ -106,4 +107,5 @@
gEfiShellPkgTokenSpaceGuid.PcdShellMapNameLength # ALWAYS_CONSUMED
gEfiShellPkgTokenSpaceGuid.PcdShellPrintBufferSize # ALWAYS_CONSUMED
gEfiShellPkgTokenSpaceGuid.PcdShellForceConsole # ALWAYS_CONSUMED
+ gEfiShellPkgTokenSpaceGuid.PcdShellSupplier # ALWAYS_CONSUMED
diff --git a/ShellPkg/Application/Shell/Shell.uni b/ShellPkg/Application/Shell/Shell.uni
index b9ddcaed6..dae54e8c2 100644
--- a/ShellPkg/Application/Shell/Shell.uni
+++ b/ShellPkg/Application/Shell/Shell.uni
Binary files differ
diff --git a/ShellPkg/Application/Shell/ShellParametersProtocol.c b/ShellPkg/Application/Shell/ShellParametersProtocol.c
index 067f6b7cf..2f8c626b0 100644
--- a/ShellPkg/Application/Shell/ShellParametersProtocol.c
+++ b/ShellPkg/Application/Shell/ShellParametersProtocol.c
@@ -2,7 +2,7 @@
Member functions of EFI_SHELL_PARAMETERS_PROTOCOL and functions for creation,
manipulation, and initialization of EFI_SHELL_PARAMETERS_PROTOCOL.
- Copyright (c) 2009 - 2012, Intel Corporation. All rights reserved.<BR>
+ Copyright (c) 2009 - 2013, 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
@@ -313,9 +313,7 @@ CreatePopulateInstallShellParametersProtocol (
FullCommandLine = AllocateZeroPool(Size);
}
if (FullCommandLine != NULL) {
- if (LoadedImage->LoadOptionsSize != 0){
- StrCpy(FullCommandLine, LoadedImage->LoadOptions);
- }
+ CopyMem (FullCommandLine, LoadedImage->LoadOptions, LoadedImage->LoadOptionsSize);
//
// Populate Argc and Argv
//
diff --git a/ShellPkg/Application/Shell/ShellProtocol.c b/ShellPkg/Application/Shell/ShellProtocol.c
index e1aadb845..89132969b 100644
--- a/ShellPkg/Application/Shell/ShellProtocol.c
+++ b/ShellPkg/Application/Shell/ShellProtocol.c
@@ -645,8 +645,6 @@ EfiShellGetDeviceName(
UINTN LoopVar;
CHAR16 *DeviceNameToReturn;
CHAR8 *Lang;
- CHAR8 *TempChar;
-
UINTN ParentControllerCount;
EFI_HANDLE *ParentControllerBuffer;
UINTN ParentDriverCount;
@@ -703,23 +701,7 @@ EfiShellGetDeviceName(
if (EFI_ERROR(Status)) {
continue;
}
- if (Language == NULL) {
- Lang = AllocateZeroPool(AsciiStrSize(CompName2->SupportedLanguages));
- if (Lang == NULL) {
- return (EFI_OUT_OF_RESOURCES);
- }
- AsciiStrCpy(Lang, CompName2->SupportedLanguages);
- TempChar = AsciiStrStr(Lang, ";");
- if (TempChar != NULL){
- *TempChar = CHAR_NULL;
- }
- } else {
- Lang = AllocateZeroPool(AsciiStrSize(Language));
- if (Lang == NULL) {
- return (EFI_OUT_OF_RESOURCES);
- }
- AsciiStrCpy(Lang, Language);
- }
+ Lang = GetBestLanguageForDriver(CompName2->SupportedLanguages, Language, FALSE);
Status = CompName2->GetControllerName(CompName2, DeviceHandle, NULL, Lang, &DeviceNameToReturn);
FreePool(Lang);
Lang = NULL;
@@ -762,23 +744,7 @@ EfiShellGetDeviceName(
if (EFI_ERROR(Status)) {
continue;
}
- if (Language == NULL) {
- Lang = AllocateZeroPool(AsciiStrSize(CompName2->SupportedLanguages));
- if (Lang == NULL) {
- return (EFI_OUT_OF_RESOURCES);
- }
- AsciiStrCpy(Lang, CompName2->SupportedLanguages);
- TempChar = AsciiStrStr(Lang, ";");
- if (TempChar != NULL){
- *TempChar = CHAR_NULL;
- }
- } else {
- Lang = AllocateZeroPool(AsciiStrSize(Language));
- if (Lang == NULL) {
- return (EFI_OUT_OF_RESOURCES);
- }
- AsciiStrCpy(Lang, Language);
- }
+ Lang = GetBestLanguageForDriver(CompName2->SupportedLanguages, Language, FALSE);
Status = CompName2->GetControllerName(CompName2, ParentControllerBuffer[LoopVar], DeviceHandle, Lang, &DeviceNameToReturn);
FreePool(Lang);
Lang = NULL;
diff --git a/ShellPkg/Include/Library/HandleParsingLib.h b/ShellPkg/Include/Library/HandleParsingLib.h
index 8c0b81d12..c2e182bd9 100644
--- a/ShellPkg/Include/Library/HandleParsingLib.h
+++ b/ShellPkg/Include/Library/HandleParsingLib.h
@@ -1,7 +1,7 @@
/** @file
Provides interface to advanced shell functionality for parsing both handle and protocol database.
- Copyright (c) 2010, Intel Corporation. All rights reserved.<BR>
+ Copyright (c) 2010 - 2013, 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
@@ -95,6 +95,27 @@ GetStringNameFromHandle(
IN CONST CHAR8 *Language
);
+/**
+ Get best support language for this driver.
+
+ First base on the user input language to search, second base on the current
+ platform used language to search, third get the first language from the
+ support language list. The caller need to free the buffer of the best language.
+
+ @param[in] SupportedLanguages The support languages for this driver.
+ @param[in] InputLanguage The user input language.
+ @param[in] Iso639Language Whether get language for ISO639.
+
+ @return The best support language for this driver.
+**/
+CHAR8 *
+EFIAPI
+GetBestLanguageForDriver (
+ IN CONST CHAR8 *SupportedLanguages,
+ IN CONST CHAR8 *InputLanguage,
+ IN BOOLEAN Iso639Language
+ );
+
#define HR_UNKNOWN 0
#define HR_IMAGE_HANDLE BIT1
#define HR_DRIVER_BINDING_HANDLE BIT2 // has driver binding
diff --git a/ShellPkg/Library/UefiDpLib/DpUtilities.c b/ShellPkg/Library/UefiDpLib/DpUtilities.c
index 57c81288d..f7e17c252 100644
--- a/ShellPkg/Library/UefiDpLib/DpUtilities.c
+++ b/ShellPkg/Library/UefiDpLib/DpUtilities.c
@@ -23,6 +23,7 @@
#include <Library/PcdLib.h>
#include <Library/UefiLib.h>
#include <Library/DevicePathLib.h>
+#include <Library/HandleParsingLib.h>
#include <Pi/PiFirmwareFile.h>
#include <Library/DxeServicesLib.h>
@@ -252,7 +253,7 @@ GetNameFromHandle (
//
// Get the current platform language setting
//
- GetEfiGlobalVariable2 (L"PlatformLang", (VOID**)&PlatformLanguage, NULL);
+ PlatformLanguage = GetBestLanguageForDriver(ComponentName2->SupportedLanguages, NULL, FALSE);
Status = ComponentName2->GetDriverName (
ComponentName2,
PlatformLanguage != NULL ? PlatformLanguage : "en-US",
diff --git a/ShellPkg/Library/UefiFileHandleLib/UefiFileHandleLib.c b/ShellPkg/Library/UefiFileHandleLib/UefiFileHandleLib.c
index fb9d4ec0b..2085f6c52 100644
--- a/ShellPkg/Library/UefiFileHandleLib/UefiFileHandleLib.c
+++ b/ShellPkg/Library/UefiFileHandleLib/UefiFileHandleLib.c
@@ -84,9 +84,9 @@ FileHandleGetInfo (
//
// if we got an error free the memory and return NULL
//
- if (EFI_ERROR(Status)) {
+ if (EFI_ERROR(Status) && (FileInfo != NULL)) {
FreePool(FileInfo);
- return NULL;
+ FileInfo = NULL;
}
}
return (FileInfo);
diff --git a/ShellPkg/Library/UefiHandleParsingLib/UefiHandleParsingLib.c b/ShellPkg/Library/UefiHandleParsingLib/UefiHandleParsingLib.c
index 0c78d0da2..515fab329 100644
--- a/ShellPkg/Library/UefiHandleParsingLib/UefiHandleParsingLib.c
+++ b/ShellPkg/Library/UefiHandleParsingLib/UefiHandleParsingLib.c
@@ -1,7 +1,7 @@
/** @file
Provides interface to advanced shell functionality for parsing both handle and protocol database.
- Copyright (c) 2010 - 2012, Intel Corporation. All rights reserved.<BR>
+ Copyright (c) 2010 - 2013, 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
@@ -778,18 +778,21 @@ GetGuidFromStringName(
/**
Get best support language for this driver.
- First base on the current platform used language to search,Second base on the
- default language to search. The caller need to free the buffer of the best
- language.
+ First base on the user input language to search, second base on the current
+ platform used language to search, third get the first language from the
+ support language list. The caller need to free the buffer of the best language.
@param[in] SupportedLanguages The support languages for this driver.
+ @param[in] InputLanguage The user input language.
@param[in] Iso639Language Whether get language for ISO639.
@return The best support language for this driver.
**/
CHAR8 *
+EFIAPI
GetBestLanguageForDriver (
- IN CONST CHAR8 *SupportedLanguages,
+ IN CONST CHAR8 *SupportedLanguages,
+ IN CONST CHAR8 *InputLanguage,
IN BOOLEAN Iso639Language
)
{
@@ -801,8 +804,9 @@ GetBestLanguageForDriver (
BestLanguage = GetBestLanguage(
SupportedLanguages,
Iso639Language,
+ (InputLanguage != NULL) ? InputLanguage : "",
(LanguageVariable != NULL) ? LanguageVariable : "",
- Iso639Language ? "en" : "en-US",
+ SupportedLanguages,
NULL
);
@@ -845,12 +849,8 @@ GetStringNameFromHandle(
NULL,
EFI_OPEN_PROTOCOL_GET_PROTOCOL);
if (!EFI_ERROR(Status)) {
- if (Language == NULL) {
- BestLang = GetBestLanguageForDriver (CompNameStruct->SupportedLanguages, FALSE);
- Language = BestLang;
- }
- Status = CompNameStruct->GetDriverName(CompNameStruct, (CHAR8*)Language, &RetVal);
-
+ BestLang = GetBestLanguageForDriver (CompNameStruct->SupportedLanguages, Language, FALSE);
+ Status = CompNameStruct->GetDriverName(CompNameStruct, BestLang, &RetVal);
if (BestLang != NULL) {
FreePool (BestLang);
BestLang = NULL;
@@ -867,12 +867,8 @@ GetStringNameFromHandle(
NULL,
EFI_OPEN_PROTOCOL_GET_PROTOCOL);
if (!EFI_ERROR(Status)) {
- if (Language == NULL) {
- BestLang = GetBestLanguageForDriver (CompNameStruct->SupportedLanguages, FALSE);
- Language = BestLang;
- }
- Status = CompNameStruct->GetDriverName(CompNameStruct, (CHAR8*)Language, &RetVal);
-
+ BestLang = GetBestLanguageForDriver (CompNameStruct->SupportedLanguages, Language, FALSE);
+ Status = CompNameStruct->GetDriverName(CompNameStruct, BestLang, &RetVal);
if (BestLang != NULL) {
FreePool (BestLang);
}
diff --git a/ShellPkg/Library/UefiShellDebug1CommandsLib/EditTitleBar.c b/ShellPkg/Library/UefiShellDebug1CommandsLib/EditTitleBar.c
index ad504561b..23d26105c 100644
--- a/ShellPkg/Library/UefiShellDebug1CommandsLib/EditTitleBar.c
+++ b/ShellPkg/Library/UefiShellDebug1CommandsLib/EditTitleBar.c
@@ -1,6 +1,7 @@
/** @file
Implements titlebar interface functions.
+ Copyright (c) 2013, Hewlett-Packard Development Company, L.P.
Copyright (c) 2005 - 2011, 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
@@ -170,6 +171,8 @@ MainTitleBarRefresh (
case FileTypeAscii:
case FileTypeUnicode:
if (FileType == FileTypeAscii){
+ ShellPrintEx (-1,-1, L" ASCII ");
+ } else {
ShellPrintEx (-1,-1, L" UNICODE ");
}
//
diff --git a/ShellPkg/Library/UefiShellDebug1CommandsLib/SetVar.c b/ShellPkg/Library/UefiShellDebug1CommandsLib/SetVar.c
index 8d26c9d93..7c3aa542b 100644
--- a/ShellPkg/Library/UefiShellDebug1CommandsLib/SetVar.c
+++ b/ShellPkg/Library/UefiShellDebug1CommandsLib/SetVar.c
@@ -176,7 +176,9 @@ ShellCommandRunSetVar (
if (Status == EFI_BUFFER_TOO_SMALL) {
Buffer = AllocateZeroPool(Size);
Status = gRT->GetVariable((CHAR16*)VariableName, &Guid, &Attributes2, &Size, Buffer);
- FreePool(Buffer);
+ if (Buffer != NULL) {
+ FreePool(Buffer);
+ }
Attributes = Attributes2;
}
//
diff --git a/ShellPkg/Library/UefiShellDriver1CommandsLib/Dh.c b/ShellPkg/Library/UefiShellDriver1CommandsLib/Dh.c
index bfbd8d76b..1bb3191f4 100644
--- a/ShellPkg/Library/UefiShellDriver1CommandsLib/Dh.c
+++ b/ShellPkg/Library/UefiShellDriver1CommandsLib/Dh.c
@@ -60,7 +60,6 @@ GetDriverName (
)
{
CHAR8 *Lang;
- CHAR8 *TempChar;
EFI_STATUS Status;
EFI_COMPONENT_NAME2_PROTOCOL *CompName2;
CHAR16 *NameToReturn;
@@ -87,23 +86,7 @@ GetDriverName (
if (EFI_ERROR(Status)) {
return (EFI_NOT_FOUND);
}
- if (Language == NULL) {
- Lang = AllocateZeroPool(AsciiStrSize(CompName2->SupportedLanguages));
- if (Lang == NULL) {
- return (EFI_OUT_OF_RESOURCES);
- }
- AsciiStrCpy(Lang, CompName2->SupportedLanguages);
- TempChar = AsciiStrStr(Lang, ";");
- if (TempChar != NULL){
- *TempChar = CHAR_NULL;
- }
- } else {
- Lang = AllocateZeroPool(AsciiStrSize(Language));
- if (Lang == NULL) {
- return (EFI_OUT_OF_RESOURCES);
- }
- AsciiStrCpy(Lang, Language);
- }
+ Lang = GetBestLanguageForDriver (CompName2->SupportedLanguages, Language, FALSE);
Status = CompName2->GetDriverName(CompName2, Lang, &NameToReturn);
FreePool(Lang);
diff --git a/ShellPkg/Library/UefiShellDriver1CommandsLib/DrvDiag.c b/ShellPkg/Library/UefiShellDriver1CommandsLib/DrvDiag.c
index 986dc3a05..c3c1b575e 100644
--- a/ShellPkg/Library/UefiShellDriver1CommandsLib/DrvDiag.c
+++ b/ShellPkg/Library/UefiShellDriver1CommandsLib/DrvDiag.c
@@ -1,7 +1,7 @@
/** @file
Main file for DrvDiag shell Driver1 function.
- Copyright (c) 2010 - 2011, Intel Corporation. All rights reserved.<BR>
+ Copyright (c) 2010 - 2013, 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
@@ -71,7 +71,6 @@ DoDiagnostics (
UINTN HandleIndex1;
UINTN HandleIndex2;
CHAR8 *Language;
- CHAR8 *TempChar;
BOOLEAN Found;
if ((ChildHandle != NULL && AllChilds) || (Mode >= TestModeMax)){
@@ -180,24 +179,8 @@ DoDiagnostics (
gImageHandle,
NULL,
EFI_OPEN_PROTOCOL_GET_PROTOCOL);
- if (!EFI_ERROR(Status)) {
- if (Lang == NULL) {
- Language = AllocateZeroPool(AsciiStrSize(DriverDiagnostics2->SupportedLanguages));
- if (Language == NULL) {
- return (EFI_OUT_OF_RESOURCES);
- }
- AsciiStrCpy(Language, DriverDiagnostics2->SupportedLanguages);
- TempChar = AsciiStrStr(Language, ";");
- if (TempChar != NULL){
- *TempChar = CHAR_NULL;
- }
- } else {
- Language = AllocateZeroPool(AsciiStrSize(Lang));
- if (Language == NULL) {
- return (EFI_OUT_OF_RESOURCES);
- }
- AsciiStrCpy(Language, Lang);
- }
+ if (!EFI_ERROR(Status) && (DriverDiagnostics2 != NULL)) {
+ Language = GetBestLanguageForDriver(DriverDiagnostics2->SupportedLanguages, Lang, FALSE);
Found = TRUE;
Status = DriverDiagnostics2->RunDiagnostics(
DriverDiagnostics2,
@@ -220,23 +203,7 @@ DoDiagnostics (
NULL,
EFI_OPEN_PROTOCOL_GET_PROTOCOL);
if (!EFI_ERROR(Status)) {
- if (Lang == NULL) {
- Language = AllocateZeroPool(AsciiStrSize(DriverDiagnostics2->SupportedLanguages));
- if (Language == NULL) {
- return (EFI_OUT_OF_RESOURCES);
- }
- AsciiStrCpy(Language, DriverDiagnostics2->SupportedLanguages);
- TempChar = AsciiStrStr(Language, ";");
- if (TempChar != NULL){
- *TempChar = CHAR_NULL;
- }
- } else {
- Language = AllocateZeroPool(AsciiStrSize(Lang));
- if (Language == NULL) {
- return (EFI_OUT_OF_RESOURCES);
- }
- AsciiStrCpy(Language, Lang);
- }
+ Language = GetBestLanguageForDriver(DriverDiagnostics->SupportedLanguages, Lang, FALSE);
Status = DriverDiagnostics->RunDiagnostics(
DriverDiagnostics,
ControllerHandleList[ControllerHandleListLoop],
diff --git a/ShellPkg/Library/UefiShellDriver1CommandsLib/UefiShellDriver1CommandsLib.h b/ShellPkg/Library/UefiShellDriver1CommandsLib/UefiShellDriver1CommandsLib.h
index 46ba8fdd8..8962d3289 100644
--- a/ShellPkg/Library/UefiShellDriver1CommandsLib/UefiShellDriver1CommandsLib.h
+++ b/ShellPkg/Library/UefiShellDriver1CommandsLib/UefiShellDriver1CommandsLib.h
@@ -54,6 +54,7 @@
#include <Library/PrintLib.h>
#include <Library/HandleParsingLib.h>
#include <Library/PeCoffGetEntryPointLib.h>
+#include <Library/HandleParsingLib.h>
extern EFI_HANDLE gShellDriver1HiiHandle;
diff --git a/ShellPkg/Library/UefiShellLevel2CommandsLib/Ls.c b/ShellPkg/Library/UefiShellLevel2CommandsLib/Ls.c
index 55267a467..4d0a1563e 100644
--- a/ShellPkg/Library/UefiShellLevel2CommandsLib/Ls.c
+++ b/ShellPkg/Library/UefiShellLevel2CommandsLib/Ls.c
@@ -1,6 +1,7 @@
/** @file
Main file for ls shell level 2 function.
+ Copyright (c) 2013 Hewlett-Packard Development Company, L.P.
Copyright (c) 2009 - 2012, 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
@@ -72,6 +73,26 @@ PrintLsOutput(
PathCleanUpDirectories(CorrectedPath);
+ if (!Sfo) {
+ //
+ // get directory name from path...
+ //
+ DirectoryName = GetFullyQualifiedPath(CorrectedPath);
+
+ //
+ // print header
+ //
+ ShellPrintHiiEx (
+ 0,
+ gST->ConOut->Mode->CursorRow,
+ NULL,
+ STRING_TOKEN (STR_LS_HEADER_LINE1),
+ gShellLevel2HiiHandle,
+ DirectoryName
+ );
+ FreePool(DirectoryName);
+ }
+
Status = ShellOpenFileMetaArg((CHAR16*)CorrectedPath, EFI_FILE_MODE_READ, &ListHead);
if (EFI_ERROR(Status)) {
SHELL_FREE_NON_NULL(CorrectedPath);
@@ -192,25 +213,6 @@ PrintLsOutput(
}
}
- if (!Sfo) {
- //
- // get directory name from path...
- //
- DirectoryName = GetFullyQualifiedPath(CorrectedPath);
-
- //
- // print header
- //
- ShellPrintHiiEx (
- 0,
- gST->ConOut->Mode->CursorRow,
- NULL,
- STRING_TOKEN (STR_LS_HEADER_LINE1),
- gShellLevel2HiiHandle,
- DirectoryName
- );
- FreePool(DirectoryName);
- }
for ( Node = (EFI_SHELL_FILE_INFO *)GetFirstNode(&ListHead->Link)
; !IsNull(&ListHead->Link, &Node->Link)
; Node = (EFI_SHELL_FILE_INFO *)GetNextNode(&ListHead->Link, &Node->Link)
@@ -230,21 +232,17 @@ PrintLsOutput(
){
continue;
}
- } else if (Attribs != EFI_FILE_VALID_ATTR) {
- if (Count == 1) {
- //
- // the bit must match
- //
- if ( (Node->Info->Attribute & Attribs) != Attribs) {
- continue;
- }
- } else {
- //
- // exact match on all bits
- //
- if ( (Node->Info->Attribute|EFI_FILE_ARCHIVE) != (Attribs|EFI_FILE_ARCHIVE)) {
- continue;
- }
+ } else if ((Attribs != EFI_FILE_VALID_ATTR) ||
+ (Count == 5)) {
+ //
+ // Only matches the bits which "Attribs" contains, not
+ // all files/directories with any of the bits.
+ // Count == 5 is used to tell the difference between a user
+ // specifying all bits (EX: -arhsda) and just specifying
+ // -a (means display all files with any attribute).
+ //
+ if ( (Node->Info->Attribute & Attribs) != Attribs) {
+ continue;
}
}
@@ -543,7 +541,21 @@ ShellCommandRunLs (
ASSERT((FullPath == NULL && Size == 0) || (FullPath != NULL));
StrnCatGrow(&FullPath, &Size, PathName, 0);
if (ShellIsDirectory(PathName) == EFI_SUCCESS) {
- StrnCatGrow(&FullPath, &Size, L"\\*", 0);
+ if (PathName[StrLen (PathName) - 1] == '\\') {
+ //
+ // For path ending with '\', just append '*'.
+ //
+ StrnCatGrow (&FullPath, &Size, L"*", 0);
+ } else if (PathName[StrLen (PathName) - 1] == '*') {
+ //
+ // For path ending with '*', do nothing.
+ //
+ } else {
+ //
+ // Otherwise, append '\*' to directory name.
+ //
+ StrnCatGrow (&FullPath, &Size, L"\\*", 0);
+ }
}
}
} else {
@@ -568,7 +580,7 @@ ShellCommandRunLs (
(INT16)(TheTime.TimeZone==EFI_UNSPECIFIED_TIMEZONE?0:TheTime.TimeZone)
);
if (ShellStatus == SHELL_NOT_FOUND) {
- ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_GEN_NO_FILES), gShellLevel2HiiHandle);
+ ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_LS_FILE_NOT_FOUND), gShellLevel2HiiHandle);
} else if (ShellStatus == SHELL_INVALID_PARAMETER) {
ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_GEN_PARAM_INV), gShellLevel2HiiHandle);
} else if (ShellStatus == SHELL_ABORTED) {
diff --git a/ShellPkg/Library/UefiShellLevel2CommandsLib/Mv.c b/ShellPkg/Library/UefiShellLevel2CommandsLib/Mv.c
index 0d01ad748..65e83ccc0 100644
--- a/ShellPkg/Library/UefiShellLevel2CommandsLib/Mv.c
+++ b/ShellPkg/Library/UefiShellLevel2CommandsLib/Mv.c
@@ -1,6 +1,7 @@
/** @file
Main file for mv shell level 2 function.
+ Copyright (c) 2013, Hewlett-Packard Development Company, L.P.
Copyright (c) 2009 - 2013, 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
@@ -137,6 +138,7 @@ GetDestinationLocation(
EFI_SHELL_FILE_INFO *Node;
CHAR16 *DestPath;
UINTN NewSize;
+ UINTN CurrentSize;
DestList = NULL;
DestPath = NULL;
@@ -151,6 +153,13 @@ GetDestinationLocation(
}
StrCpy(DestPath, Cwd);
while (PathRemoveLastItem(DestPath)) ;
+
+ //
+ // Append DestDir beyond '\' which may be present
+ //
+ CurrentSize = StrSize(DestPath);
+ StrnCatGrow(&DestPath, &CurrentSize, &DestDir[1], 0);
+
*DestPathPointer = DestPath;
return (SHELL_SUCCESS);
}
diff --git a/ShellPkg/Library/UefiShellLevel2CommandsLib/UefiShellLevel2CommandsLib.uni b/ShellPkg/Library/UefiShellLevel2CommandsLib/UefiShellLevel2CommandsLib.uni
index 08372d5ba..f0991507c 100644
--- a/ShellPkg/Library/UefiShellLevel2CommandsLib/UefiShellLevel2CommandsLib.uni
+++ b/ShellPkg/Library/UefiShellLevel2CommandsLib/UefiShellLevel2CommandsLib.uni
Binary files differ
diff --git a/ShellPkg/Library/UefiShellLevel3CommandsLib/Type.c b/ShellPkg/Library/UefiShellLevel3CommandsLib/Type.c
index 50974c3fb..dffefd123 100644
--- a/ShellPkg/Library/UefiShellLevel3CommandsLib/Type.c
+++ b/ShellPkg/Library/UefiShellLevel3CommandsLib/Type.c
@@ -1,6 +1,7 @@
/** @file
Main file for Type shell level 3 function.
+ Copyright (c) 2013, Hewlett-Packard Development Company, L.P.
Copyright (c) 2009 - 2011, 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
@@ -31,59 +32,129 @@
EFI_STATUS
EFIAPI
TypeFileByHandle (
- IN EFI_HANDLE Handle,
- BOOLEAN Ascii,
- BOOLEAN UCS2
+ IN SHELL_FILE_HANDLE Handle,
+ IN BOOLEAN Ascii,
+ IN BOOLEAN UCS2
)
{
UINTN ReadSize;
VOID *Buffer;
+ VOID *AllocatedBuffer;
EFI_STATUS Status;
UINTN LoopVar;
+ UINTN LoopSize;
CHAR16 AsciiChar;
+ CHAR16 Ucs2Char;
ReadSize = PcdGet32(PcdShellFileOperationSize);
- Buffer = AllocateZeroPool(ReadSize);
- if (Buffer == NULL) {
+ AllocatedBuffer = AllocateZeroPool(ReadSize);
+ if (AllocatedBuffer == NULL) {
return (EFI_OUT_OF_RESOURCES);
}
Status = ShellSetFilePosition(Handle, 0);
ASSERT_EFI_ERROR(Status);
- while (ReadSize == ((UINTN)PcdGet32(PcdShellFileOperationSize))){
+ while (ReadSize == ((UINTN)PcdGet32(PcdShellFileOperationSize))) {
+ Buffer = AllocatedBuffer;
ZeroMem(Buffer, ReadSize);
Status = ShellReadFile(Handle, &ReadSize, Buffer);
if (EFI_ERROR(Status)){
break;
}
- if (!(Ascii|UCS2)){
+ if (!(Ascii|UCS2)) {
if (*(UINT16*)Buffer == gUnicodeFileTag) {
UCS2 = TRUE;
- Buffer = ((UINT16*)Buffer) + 1;
} else {
Ascii = TRUE;
}
}
- //
- // We want to use plain Print function here! (no color support for files)
- //
- if (Ascii){
- for (LoopVar = 0 ; LoopVar < ReadSize ; LoopVar++) {
- AsciiChar = CHAR_NULL;
- AsciiChar = ((CHAR8*)Buffer)[LoopVar];
- if (AsciiChar == CHAR_NULL) {
- AsciiChar = '.';
- }
- Print(L"%c", AsciiChar);
+ if (Ascii) {
+ LoopSize = ReadSize;
+ for (LoopVar = 0 ; LoopVar < LoopSize ; LoopVar++) {
+ //
+ // The valid range of ASCII characters is 0x20-0x7E.
+ // Display "." when there is an invalid character.
+ //
+ AsciiChar = CHAR_NULL;
+ AsciiChar = ((CHAR8*)Buffer)[LoopVar];
+ if (AsciiChar == '\r' || AsciiChar == '\n') {
+ //
+ // Allow Line Feed (LF) (0xA) & Carriage Return (CR) (0xD)
+ // characters to be displayed as is.
+ //
+ if (AsciiChar == '\n' && ((CHAR8*)Buffer)[LoopVar-1] != '\r') {
+ //
+ // In case Line Feed (0xA) is encountered & Carriage Return (0xD)
+ // was not the previous character, print CR and LF. This is because
+ // Shell 2.0 requires carriage return with line feed for displaying
+ // each new line from left.
+ //
+ ShellPrintEx (-1, -1, L"\r\n");
+ continue;
+ }
+ } else {
+ //
+ // For all other characters which are not printable, display '.'
+ //
+ if (AsciiChar < 0x20 || AsciiChar >= 0x7F) {
+ AsciiChar = '.';
+ }
+ }
+ ShellPrintEx (-1, -1, L"%c", AsciiChar);
}
} else {
- Print(L"%s", Buffer);
+ if (*(UINT16*)Buffer == gUnicodeFileTag) {
+ //
+ // For unicode files, skip displaying the byte order marker.
+ //
+ Buffer = ((UINT16*)Buffer) + 1;
+ LoopSize = (ReadSize / (sizeof (CHAR16))) - 1;
+ } else {
+ LoopSize = ReadSize / (sizeof (CHAR16));
+ }
+
+ for (LoopVar = 0 ; LoopVar < LoopSize ; LoopVar++) {
+ //
+ // An invalid range of characters is 0x0-0x1F.
+ // Display "." when there is an invalid character.
+ //
+ Ucs2Char = CHAR_NULL;
+ Ucs2Char = ((CHAR16*)Buffer)[LoopVar];
+ if (Ucs2Char == '\r' || Ucs2Char == '\n') {
+ //
+ // Allow Line Feed (LF) (0xA) & Carriage Return (CR) (0xD)
+ // characters to be displayed as is.
+ //
+ if (Ucs2Char == '\n' && ((CHAR16*)Buffer)[LoopVar-1] != '\r') {
+ //
+ // In case Line Feed (0xA) is encountered & Carriage Return (0xD)
+ // was not the previous character, print CR and LF. This is because
+ // Shell 2.0 requires carriage return with line feed for displaying
+ // each new line from left.
+ //
+ ShellPrintEx (-1, -1, L"\r\n");
+ continue;
+ }
+ }
+ else if (Ucs2Char < 0x20) {
+ //
+ // For all other characters which are not printable, display '.'
+ //
+ Ucs2Char = L'.';
+ }
+ ShellPrintEx (-1, -1, L"%c", Ucs2Char);
+ }
+ }
+
+ if (ShellGetExecutionBreakFlag()) {
+ break;
}
}
- Print(L"\r\n", Buffer);
+ FreePool (AllocatedBuffer);
+ ShellPrintEx (-1, -1, L"\r\n");
return (Status);
}
@@ -196,6 +267,11 @@ ShellCommandRunType (
; !IsNull(&FileList->Link, &Node->Link) && !ShellGetExecutionBreakFlag()
; Node = (EFI_SHELL_FILE_INFO*)GetNextNode(&FileList->Link, &Node->Link)
){
+
+ if (ShellGetExecutionBreakFlag()) {
+ break;
+ }
+
//
// make sure the file opened ok
//
@@ -217,7 +293,7 @@ ShellCommandRunType (
//
// do it
//
- Status = TypeFileByHandle(Node->Handle, AsciiMode, UnicodeMode);
+ Status = TypeFileByHandle (Node->Handle, AsciiMode, UnicodeMode);
if (EFI_ERROR(Status)) {
ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_TYP_ERROR), gShellLevel3HiiHandle, Node->FileName, Status);
ShellStatus = SHELL_INVALID_PARAMETER;
diff --git a/ShellPkg/Library/UefiShellLevel3CommandsLib/UefiShellLevel3CommandsLib.inf b/ShellPkg/Library/UefiShellLevel3CommandsLib/UefiShellLevel3CommandsLib.inf
index 936476d0d..7316750fd 100644
--- a/ShellPkg/Library/UefiShellLevel3CommandsLib/UefiShellLevel3CommandsLib.inf
+++ b/ShellPkg/Library/UefiShellLevel3CommandsLib/UefiShellLevel3CommandsLib.inf
@@ -2,6 +2,7 @@
# Provides shell level 3 functions
# Note that the interactive versions of the time, date, and timezone functions are handled in the level 2 library.
#
+# Copyright (c) 2013, Hewlett-Packard Development Company, L.P.
# Copyright (c) 2009-2011, Intel Corporation. All rights reserved. <BR>
#
# This program and the accompanying materials
@@ -66,4 +67,5 @@
[Pcd.common]
gEfiShellPkgTokenSpaceGuid.PcdShellSupportLevel
gEfiShellPkgTokenSpaceGuid.PcdShellFileOperationSize
+ gEfiShellPkgTokenSpaceGuid.PcdShellSupplier
diff --git a/ShellPkg/Library/UefiShellLevel3CommandsLib/UefiShellLevel3CommandsLib.uni b/ShellPkg/Library/UefiShellLevel3CommandsLib/UefiShellLevel3CommandsLib.uni
index 8c3e79dda..1a5232991 100644
--- a/ShellPkg/Library/UefiShellLevel3CommandsLib/UefiShellLevel3CommandsLib.uni
+++ b/ShellPkg/Library/UefiShellLevel3CommandsLib/UefiShellLevel3CommandsLib.uni
Binary files differ
diff --git a/ShellPkg/Library/UefiShellLevel3CommandsLib/Ver.c b/ShellPkg/Library/UefiShellLevel3CommandsLib/Ver.c
index e00f4c90f..765a6a3ab 100644
--- a/ShellPkg/Library/UefiShellLevel3CommandsLib/Ver.c
+++ b/ShellPkg/Library/UefiShellLevel3CommandsLib/Ver.c
@@ -1,6 +1,7 @@
/** @file
Main file for Ver shell level 3 function.
+ Copyright (c) 2013, Hewlett-Packard Development Company, L.P.
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
@@ -108,8 +109,9 @@ ShellCommandRunVer (
-1,
-1,
NULL,
- STRING_TOKEN (STR_VER_EXTRA_STRING),
- gShellLevel3HiiHandle
+ STRING_TOKEN (STR_VER_OUTPUT_SUPPLIER),
+ gShellLevel3HiiHandle,
+ (CHAR16 *) PcdGetPtr (PcdShellSupplier)
);
diff --git a/ShellPkg/Library/UefiShellNetwork1CommandsLib/Ifconfig.c b/ShellPkg/Library/UefiShellNetwork1CommandsLib/Ifconfig.c
index 32a4f7fb4..f837bab45 100644
--- a/ShellPkg/Library/UefiShellNetwork1CommandsLib/Ifconfig.c
+++ b/ShellPkg/Library/UefiShellNetwork1CommandsLib/Ifconfig.c
@@ -1,6 +1,7 @@
/** @file
The implementation for ifcommand shell command.
+ Copyright (c) 2013 Hewlett-Packard Development Company, L.P.
Copyright (c) 2006 - 2012, Intel Corporation. All rights reserved.<BR>
This program and the accompanying materials
@@ -1249,7 +1250,7 @@ IfconfigSetNicAddr (
if (StringNoCaseCompare(&Temp, &DhcpTemp) == 0) {
//
- // Validate the parameter for DHCP, two valid forms: eth0 DHCP and eth0 DHCP perment
+ // Validate the parameter for DHCP, two valid forms: eth0 DHCP and eth0 DHCP permanent
//
if ((Argc != 2) && (Argc!= 3)) {
ShellPrintHiiEx(-1, -1, NULL,STRING_TOKEN (STR_GEN_PROBLEM_VAL), gShellNetwork1HiiHandle, Temp);
@@ -1274,7 +1275,7 @@ IfconfigSetNicAddr (
}
if ((OldConfig != NULL) && (OldConfig->Source == IP4_CONFIG_SOURCE_DHCP) &&
- (OldConfig->Perment == Permanent)) {
+ (OldConfig->Permanent == Permanent)) {
ShellPrintHiiEx(-1, -1, NULL,STRING_TOKEN (STR_IFCONFIG_INTERFACE_CONFIGURED), gShellNetwork1HiiHandle, Info->Name);
ShellStatus = SHELL_ALREADY_STARTED;
@@ -1285,7 +1286,7 @@ IfconfigSetNicAddr (
} else if (StringNoCaseCompare(&Temp, &StaticTemp) == 0) {
//
// validate the parameter, two forms: eth0 static IP NETMASK GATEWAY and
- // eth0 static IP NETMASK GATEWAY perment
+ // eth0 static IP NETMASK GATEWAY permanent
//
if ((Argc != 5) && (Argc != 6)) {
ShellPrintHiiEx(-1, -1, NULL,STRING_TOKEN (STR_GEN_PROBLEM_VAL), gShellNetwork1HiiHandle, Temp);
@@ -1388,7 +1389,7 @@ IfconfigSetNicAddr (
}
CopyMem (&Config->NicAddr, &Info->NicAddress, sizeof (NIC_ADDR));
- Config->Perment = Permanent;
+ Config->Permanent = Permanent;
//
// Use HII service to set NIC address
@@ -1474,9 +1475,9 @@ IfconfigShowNicInfo (
}
ShellPrintHiiEx(-1, -1, NULL,
- STRING_TOKEN (STR_IFCONFIG_PERMENT_STATUS),
+ STRING_TOKEN (STR_IFCONFIG_PERMANENT_STATUS),
gShellNetwork1HiiHandle,
- (NicInfo->ConfigInfo->Perment? L"TRUE":L"FALSE")
+ (NicInfo->ConfigInfo->Permanent? L"TRUE":L"FALSE")
);
Ip4Config = &NicInfo->ConfigInfo->Ip4Info;
@@ -1716,8 +1717,8 @@ ShellCommandRunIfconfig (
//
// The correct command line arguments for setting address are:
- // IfConfig -s eth0 DHCP [perment]
- // IfConfig -s eth0 static ip netmask gateway [perment]
+ // IfConfig -s eth0 DHCP [permanent]
+ // IfConfig -s eth0 static ip netmask gateway [permanent]
//
if (Item == NULL || (CountSubItems(Item) < 2) || (CountSubItems(Item) > 6) || (CountSubItems(Item) == 4)) {
ShellPrintHiiEx(-1, -1, NULL,STRING_TOKEN (STR_GEN_PROBLEM_VAL), gShellNetwork1HiiHandle, L"-s");
diff --git a/ShellPkg/Library/UefiShellNetwork1CommandsLib/UefiShellNetwork1CommandsLib.uni b/ShellPkg/Library/UefiShellNetwork1CommandsLib/UefiShellNetwork1CommandsLib.uni
index bbb75fd26..9723ffaa3 100644
--- a/ShellPkg/Library/UefiShellNetwork1CommandsLib/UefiShellNetwork1CommandsLib.uni
+++ b/ShellPkg/Library/UefiShellNetwork1CommandsLib/UefiShellNetwork1CommandsLib.uni
Binary files differ
diff --git a/ShellPkg/ShellPkg.dec b/ShellPkg/ShellPkg.dec
index 3a2bef637..3d0f5c296 100644
--- a/ShellPkg/ShellPkg.dec
+++ b/ShellPkg/ShellPkg.dec
@@ -2,6 +2,7 @@
#
# This Package provides all definitions for EFI and UEFI Shell
#
+# Copyright (c) 2013, Hewlett-Packard Development Company, L.P.
# Copyright (c) 2009 - 2011, Intel Corporation. All rights reserved.<BR>
#
# This program and the accompanying materials are licensed and made available under
@@ -47,7 +48,7 @@
[Guids]
gEfiShellEnvironment2ExtGuid = {0xd2c18636, 0x40e5, 0x4eb5, {0xa3, 0x1b, 0x36, 0x69, 0x5f, 0xd4, 0x2c, 0x87}}
- gEfiShellPkgTokenSpaceGuid = {0x171e9188, 0x31d3, 0x40f5, {0xb1, 0x0c, 0x53, 0x9b, 0x2d, 0xb9, 0x40, 0xcd}}
+ gEfiShellPkgTokenSpaceGuid = {0x171e9188, 0x31d3, 0x40f5, {0xb1, 0x0c, 0x53, 0x9b, 0x2d, 0xb9, 0x40, 0xcd}}
gShellVariableGuid = {0x158def5a, 0xf656, 0x419c, {0xb0, 0x27, 0x7a, 0x31, 0x92, 0xc0, 0x79, 0xd2}}
gShellMapGuid = {0x51271e13, 0x7de3, 0x43af, {0x8b, 0xc2, 0x71, 0xad, 0x3b, 0x82, 0x43, 0x25}}
gShellAliasGuid = {0x0053d9d6, 0x2659, 0x4599, {0xa2, 0x6b, 0xef, 0x45, 0x36, 0xe6, 0x31, 0xa9}}
@@ -118,4 +119,7 @@
## this flag determins the default number of screens kept for history log.
# the spec defines 3 as the minimum
- gEfiShellPkgTokenSpaceGuid.PcdShellScreenLogCount|3|UINT8|0x00000008 \ No newline at end of file
+ gEfiShellPkgTokenSpaceGuid.PcdShellScreenLogCount|3|UINT8|0x00000008
+
+ ## Unicode string of the shell supplier
+ gEfiShellPkgTokenSpaceGuid.PcdShellSupplier|L"EDK II"|VOID*|0x00000010
diff --git a/StdLib/Include/Ipf/machine/param.h b/StdLib/Include/Ipf/machine/param.h
index c832f3487..4675804ce 100644
--- a/StdLib/Include/Ipf/machine/param.h
+++ b/StdLib/Include/Ipf/machine/param.h
@@ -122,7 +122,6 @@
#else
#define NMBCLUSTERS 1024 /* map size, max cluster allocation */
#endif
-#endif
/*
* Minimum and maximum sizes of the kernel malloc arena in PAGE_SIZE-sized
diff --git a/StdLib/LibC/Containers/Queues/Fifo.c b/StdLib/LibC/Containers/Queues/Fifo.c
index 347ac02fd..996498e1d 100644
--- a/StdLib/LibC/Containers/Queues/Fifo.c
+++ b/StdLib/LibC/Containers/Queues/Fifo.c
@@ -220,7 +220,6 @@ FIFO_Enqueue (
assert(Self != NULL);
assert(pElement != NULL);
- assert(Count >= 0);
if(FIFO_IsFull(Self)) {
Count = 0;
diff --git a/StdLib/LibC/String/strncasecmp.c b/StdLib/LibC/String/strncasecmp.c
index b3f6d0596..9cc1851ee 100644
--- a/StdLib/LibC/String/strncasecmp.c
+++ b/StdLib/LibC/String/strncasecmp.c
@@ -1,4 +1,4 @@
-/** @file
+/** @file
strncasecmp implementation
Copyright (c) 2011, Intel Corporation. All rights reserved.<BR>
@@ -11,7 +11,7 @@
WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
* Copyright (c) 1987, 1993
- * The Regents of the University of California. All rights reserved.
+ * The Regents of the University of California. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
@@ -37,8 +37,8 @@
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
- $NetBSD: strncasecmp.c,v 1.2 2007/06/04 18:19:27 christos Exp $
- strcasecmp.c 8.1 (Berkeley) 6/4/93
+ $NetBSD: strncasecmp.c,v 1.2 2007/06/04 18:19:27 christos Exp $
+ strcasecmp.c 8.1 (Berkeley) 6/4/93
**/
#include <LibConfig.h>
#include <sys/cdefs.h>
@@ -55,25 +55,28 @@ __weak_alias(strncasecmp,_strncasecmp)
#else
#include <lib/libkern/libkern.h>
#include <machine/limits.h>
-#endif
+#endif
int
strncasecmp(const char *s1, const char *s2, size_t n)
{
+ int CompareVal;
- _DIAGASSERT(s1 != NULL);
- _DIAGASSERT(s2 != NULL);
-
- if (n != 0) {
- const unsigned char *us1 = (const unsigned char *)s1,
- *us2 = (const unsigned char *)s2;
+ _DIAGASSERT(s1 != NULL);
+ _DIAGASSERT(s2 != NULL);
- do {
- if (tolower(*us1) != tolower(*us2++))
- return (tolower(*us1) - tolower(*--us2));
- if (*us1++ == '\0')
- break;
- } while (--n != 0);
- }
- return (0);
+ if (n != 0) {
+ do {
+ CompareVal = tolower(*s1) - tolower(*s2);
+ if (CompareVal != 0) {
+ return (CompareVal);
+ }
+ ++s1;
+ ++s2;
+ if (*s1 == '\0') {
+ break;
+ }
+ } while (--n != 0);
+ }
+ return (0);
}
diff --git a/UefiCpuPkg/CpuDxe/CpuDxe.c b/UefiCpuPkg/CpuDxe/CpuDxe.c
index 958711ca4..2dfde0677 100644
--- a/UefiCpuPkg/CpuDxe/CpuDxe.c
+++ b/UefiCpuPkg/CpuDxe/CpuDxe.c
@@ -637,9 +637,9 @@ CpuSetMemoryAttributes (
// to avoid unnecessary computing.
//
if (mIsFlushingGCD) {
- DEBUG((EFI_D_ERROR, " Flushing GCD\n"));
- return EFI_SUCCESS;
- }
+ DEBUG((EFI_D_INFO, " Flushing GCD\n"));
+ return EFI_SUCCESS;
+ }
switch (Attributes) {
case EFI_MEMORY_UC:
diff --git a/UefiCpuPkg/Include/Library/LocalApicLib.h b/UefiCpuPkg/Include/Library/LocalApicLib.h
index ed847b957..896020487 100644
--- a/UefiCpuPkg/Include/Library/LocalApicLib.h
+++ b/UefiCpuPkg/Include/Library/LocalApicLib.h
@@ -4,7 +4,7 @@
Local APIC library assumes local APIC is enabled. It does not
handles cases where local APIC is disabled.
- Copyright (c) 2010 - 2012, Intel Corporation. All rights reserved.<BR>
+ Copyright (c) 2010 - 2013, 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,7 +78,7 @@ SetApicMode (
/**
Get the initial local APIC ID of the executing processor assigned by hardware upon power on or reset.
- In xAPIC mode, the initial local APIC ID is 8-bit, and may be different from current APIC ID.
+ In xAPIC mode, the initial local APIC ID may be different from current APIC ID.
In x2APIC mode, the local APIC ID can't be changed and there is no concept of initial APIC ID. In this case,
the 32-bit local APIC ID is returned as initial APIC ID.
diff --git a/UefiCpuPkg/Include/Register/LocalApic.h b/UefiCpuPkg/Include/Register/LocalApic.h
index bb0e211dc..f49e8f542 100644
--- a/UefiCpuPkg/Include/Register/LocalApic.h
+++ b/UefiCpuPkg/Include/Register/LocalApic.h
@@ -1,7 +1,7 @@
/** @file
IA32 Local APIC Definitions.
- Copyright (c) 2010 - 2011, Intel Corporation. All rights reserved.<BR>
+ Copyright (c) 2010 - 2013, 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,9 @@
//
// Definitions for CPUID instruction
//
+#define CPUID_SIGNATURE 0x0
#define CPUID_VERSION_INFO 0x1
+#define CPUID_EXTENDED_TOPOLOGY 0xB
#define CPUID_EXTENDED_FUNCTION 0x80000000
#define CPUID_VIR_PHY_ADDRESS_SIZE 0x80000008
diff --git a/UefiCpuPkg/Library/BaseXApicLib/BaseXApicLib.c b/UefiCpuPkg/Library/BaseXApicLib/BaseXApicLib.c
index 53c161081..bd97fae9c 100644
--- a/UefiCpuPkg/Library/BaseXApicLib/BaseXApicLib.c
+++ b/UefiCpuPkg/Library/BaseXApicLib/BaseXApicLib.c
@@ -3,7 +3,7 @@
This local APIC library instance supports xAPIC mode only.
- Copyright (c) 2010 - 2012, Intel Corporation. All rights reserved.<BR>
+ Copyright (c) 2010 - 2013, 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
@@ -207,7 +207,7 @@ SetApicMode (
/**
Get the initial local APIC ID of the executing processor assigned by hardware upon power on or reset.
- In xAPIC mode, the initial local APIC ID is 8-bit, and may be different from current APIC ID.
+ In xAPIC mode, the initial local APIC ID may be different from current APIC ID.
In x2APIC mode, the local APIC ID can't be changed and there is no concept of initial APIC ID. In this case,
the 32-bit local APIC ID is returned as initial APIC ID.
@@ -219,10 +219,27 @@ GetInitialApicId (
VOID
)
{
+ UINT32 ApicId;
+ UINT32 MaxCpuIdIndex;
UINT32 RegEbx;
ASSERT (GetApicMode () == LOCAL_APIC_MODE_XAPIC);
+ //
+ // Get the max index of basic CPUID
+ //
+ AsmCpuid (CPUID_SIGNATURE, &MaxCpuIdIndex, NULL, NULL, NULL);
+
+ //
+ // If CPUID Leaf B is supported,
+ // Then the initial 32-bit APIC ID = CPUID.0BH:EDX
+ // Else the initial 8-bit APIC ID = CPUID.1:EBX[31:24]
+ //
+ if (MaxCpuIdIndex >= CPUID_EXTENDED_TOPOLOGY) {
+ AsmCpuidEx (CPUID_EXTENDED_TOPOLOGY, 0, NULL, NULL, NULL, &ApicId);
+ return ApicId;
+ }
+
AsmCpuid (CPUID_VERSION_INFO, NULL, &RegEbx, NULL, NULL);
return RegEbx >> 24;
}
@@ -241,9 +258,15 @@ GetApicId (
UINT32 ApicId;
ASSERT (GetApicMode () == LOCAL_APIC_MODE_XAPIC);
-
- ApicId = ReadLocalApicReg (XAPIC_ID_OFFSET);
- ApicId >>= 24;
+
+ if ((ApicId = GetInitialApicId ()) < 0x100) {
+ //
+ // If the initial local APIC ID is less 0x100, read APIC ID from
+ // XAPIC_ID_OFFSET, otherwise return the initial local APIC ID.
+ //
+ ApicId = ReadLocalApicReg (XAPIC_ID_OFFSET);
+ ApicId >>= 24;
+ }
return ApicId;
}
diff --git a/UefiCpuPkg/Library/BaseXApicX2ApicLib/BaseXApicX2ApicLib.c b/UefiCpuPkg/Library/BaseXApicX2ApicLib/BaseXApicX2ApicLib.c
index 48468e8bc..23dc7910a 100644
--- a/UefiCpuPkg/Library/BaseXApicX2ApicLib/BaseXApicX2ApicLib.c
+++ b/UefiCpuPkg/Library/BaseXApicX2ApicLib/BaseXApicX2ApicLib.c
@@ -4,7 +4,7 @@
This local APIC library instance supports x2APIC capable processors
which have xAPIC and x2APIC modes.
- Copyright (c) 2010 - 2012, Intel Corporation. All rights reserved.<BR>
+ Copyright (c) 2010 - 2013, 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
@@ -290,7 +290,7 @@ SetApicMode (
/**
Get the initial local APIC ID of the executing processor assigned by hardware upon power on or reset.
- In xAPIC mode, the initial local APIC ID is 8-bit, and may be different from current APIC ID.
+ In xAPIC mode, the initial local APIC ID may be different from current APIC ID.
In x2APIC mode, the local APIC ID can't be changed and there is no concept of initial APIC ID. In this case,
the 32-bit local APIC ID is returned as initial APIC ID.
@@ -302,9 +302,24 @@ GetInitialApicId (
VOID
)
{
+ UINT32 ApicId;
+ UINT32 MaxCpuIdIndex;
UINT32 RegEbx;
if (GetApicMode () == LOCAL_APIC_MODE_XAPIC) {
+ //
+ // Get the max index of basic CPUID
+ //
+ AsmCpuid (CPUID_SIGNATURE, &MaxCpuIdIndex, NULL, NULL, NULL);
+ //
+ // If CPUID Leaf B is supported,
+ // Then the initial 32-bit APIC ID = CPUID.0BH:EDX
+ // Else the initial 8-bit APIC ID = CPUID.1:EBX[31:24]
+ //
+ if (MaxCpuIdIndex >= CPUID_EXTENDED_TOPOLOGY) {
+ AsmCpuidEx (CPUID_EXTENDED_TOPOLOGY, 0, NULL, NULL, NULL, &ApicId);
+ return ApicId;
+ }
AsmCpuid (CPUID_VERSION_INFO, NULL, &RegEbx, NULL, NULL);
return RegEbx >> 24;
} else {
@@ -324,11 +339,13 @@ GetApicId (
)
{
UINT32 ApicId;
+ UINT32 InitApicId;
ApicId = ReadLocalApicReg (XAPIC_ID_OFFSET);
if (GetApicMode () == LOCAL_APIC_MODE_XAPIC) {
- ApicId >>= 24;
+ ApicId = ((InitApicId = GetInitialApicId ()) < 0x100) ? (ApicId >> 24) : InitApicId;
}
+
return ApicId;
}
diff --git a/UefiCpuPkg/ResetVector/Vtf0/Ia32/Flat32ToFlat64.asm b/UefiCpuPkg/ResetVector/Vtf0/Ia32/Flat32ToFlat64.asm
index 9eba864c2..62e71da3d 100644
--- a/UefiCpuPkg/ResetVector/Vtf0/Ia32/Flat32ToFlat64.asm
+++ b/UefiCpuPkg/ResetVector/Vtf0/Ia32/Flat32ToFlat64.asm
@@ -2,7 +2,7 @@
; @file
; Transition from 32 bit flat protected mode into 64 bit flat protected mode
;
-; Copyright (c) 2008 - 2009, Intel Corporation. All rights reserved.<BR>
+; Copyright (c) 2008 - 2013, 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,7 @@ BITS 32
;
Transition32FlatTo64Flat:
- mov eax, ((ADDR_OF_START_OF_RESET_CODE & ~0xfff) - 0x1000)
- mov cr3, eax
+ OneTimeCall SetCr3ForPageTables64
mov eax, cr4
bts eax, 5 ; enable PAE
diff --git a/UefiCpuPkg/ResetVector/Vtf0/Ia32/PageTables64.asm b/UefiCpuPkg/ResetVector/Vtf0/Ia32/PageTables64.asm
new file mode 100644
index 000000000..0cfcbae87
--- /dev/null
+++ b/UefiCpuPkg/ResetVector/Vtf0/Ia32/PageTables64.asm
@@ -0,0 +1,30 @@
+;------------------------------------------------------------------------------
+; @file
+; Sets the CR3 register for 64-bit paging
+;
+; Copyright (c) 2008 - 2013, 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.
+;
+;------------------------------------------------------------------------------
+
+BITS 32
+
+;
+; Modified: EAX
+;
+SetCr3ForPageTables64:
+
+ ;
+ ; These pages are built into the ROM image by Tools/FixupForRawSection.py
+ ;
+ mov eax, ((ADDR_OF_START_OF_RESET_CODE & ~0xfff) - 0x1000)
+ mov cr3, eax
+
+ OneTimeCallRet SetCr3ForPageTables64
+
diff --git a/UefiCpuPkg/ResetVector/Vtf0/ResetVectorCode.asm b/UefiCpuPkg/ResetVector/Vtf0/ResetVectorCode.asm
index 96f686b0e..052c821f2 100644
--- a/UefiCpuPkg/ResetVector/Vtf0/ResetVectorCode.asm
+++ b/UefiCpuPkg/ResetVector/Vtf0/ResetVectorCode.asm
@@ -2,7 +2,7 @@
; @file
; This file includes all other code files to assemble the reset vector code
;
-; Copyright (c) 2008 - 2010, Intel Corporation. All rights reserved.<BR>
+; Copyright (c) 2008 - 2013, 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,6 +41,7 @@
%ifdef ARCH_X64
%include "Ia32/Flat32ToFlat64.asm"
+%include "Ia32/PageTables64.asm"
%endif
%include "Ia16/Real16ToFlat32.asm"