summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLeif Lindholm <leif.lindholm@linaro.org>2013-06-19 11:07:03 +0100
committerLeif Lindholm <leif.lindholm@linaro.org>2013-06-19 11:07:03 +0100
commit4a21c40a5f30d67cdf876bc50f48abd37d9eea68 (patch)
tree49f9dd09a6ad18c45a9c1a5b9eca633a6f1a9f32
parent4cbfd417d24602d2d9c05cc5693a6e6087d1c96d (diff)
parent162fed6be629c847e162462331565e9204e47fa2 (diff)
Merging linaro-tracking-2013.06 into linaro-releaselinaro-uefi-2013.06
Signed-off-by: Leif Lindholm <leif.lindholm@linaro.org>
-rw-r--r--.gitignore22
-rw-r--r--ArmPkg/ArmPkg.dec19
-rw-r--r--ArmPkg/Drivers/ArmCpuLib/ArmCortexA15Lib/ArmCortexA15Lib.c2
-rw-r--r--ArmPkg/Drivers/ArmCpuLib/ArmCortexA15Lib/ArmCortexA15Lib.inf5
-rw-r--r--ArmPkg/Drivers/ArmCpuLib/ArmCortexA9Lib/ArmCortexA9Lib.c3
-rw-r--r--ArmPkg/Drivers/ArmCpuLib/ArmCortexA9Lib/ArmCortexA9Lib.inf9
-rw-r--r--ArmPkg/Drivers/PL390Gic/PL390GicSec.c18
-rw-r--r--ArmPkg/Drivers/PL390Gic/PL390GicSecLib.inf6
-rw-r--r--ArmPkg/Filesystem/SemihostFs/Arm/SemihostFs.c152
-rw-r--r--ArmPkg/Include/AsmMacroIoLib.h14
-rw-r--r--ArmPkg/Include/AsmMacroIoLib.inc7
-rw-r--r--ArmPkg/Include/IndustryStandard/ArmTrustZoneSmc.h2
-rw-r--r--ArmPkg/Include/Library/ArmLib.h2
-rw-r--r--ArmPkg/Library/BdsLib/BdsLib.inf2
-rw-r--r--ArmPkg/Library/BdsLib/BdsLinuxFdt.c285
-rw-r--r--ArmPlatformPkg/ArmRealViewEbPkg/ArmRealViewEb-RTSM-A8.dsc5
-rw-r--r--ArmPlatformPkg/ArmRealViewEbPkg/Library/ArmRealViewEbLibRTSM/ArmRealViewEb.c2
-rw-r--r--ArmPlatformPkg/ArmRealViewEbPkg/Library/ArmRealViewEbLibRTSM/ArmRealViewEbHelper.S53
-rw-r--r--ArmPlatformPkg/ArmRealViewEbPkg/Library/ArmRealViewEbLibRTSM/ArmRealViewEbHelper.asm59
-rw-r--r--ArmPlatformPkg/ArmRealViewEbPkg/Library/ArmRealViewEbLibRTSM/ArmRealViewEbLib.inf6
-rw-r--r--ArmPlatformPkg/ArmRealViewEbPkg/Library/ArmRealViewEbLibRTSM/ArmRealViewEbLibSec.inf2
-rw-r--r--ArmPlatformPkg/ArmRealViewEbPkg/Library/ArmRealViewEbLibRTSM/ArmRealViewEbMem.c18
-rw-r--r--ArmPlatformPkg/ArmRealViewEbPkg/Library/ArmRealViewEbSecLibRTSM/ArmRealViewEbSec.c3
-rw-r--r--ArmPlatformPkg/ArmRealViewEbPkg/Library/ArmRealViewEbSecLibRTSM/ArmRealViewEbSecLib.inf3
-rw-r--r--ArmPlatformPkg/ArmVExpressPkg/ArmVExpress-CTA15-A7.dsc6
-rw-r--r--ArmPlatformPkg/ArmVExpressPkg/ArmVExpress-CTA15x2.dsc17
-rw-r--r--ArmPlatformPkg/ArmVExpressPkg/ArmVExpress-CTA15x2.fdf28
-rw-r--r--ArmPlatformPkg/ArmVExpressPkg/ArmVExpress-CTA5s.dsc17
-rw-r--r--ArmPlatformPkg/ArmVExpressPkg/ArmVExpress-CTA5s.fdf28
-rw-r--r--ArmPlatformPkg/ArmVExpressPkg/ArmVExpress-CTA9x4.dsc7
-rw-r--r--ArmPlatformPkg/ArmVExpressPkg/ArmVExpress-RTSM-A15.dsc20
-rw-r--r--ArmPlatformPkg/ArmVExpressPkg/ArmVExpress-RTSM-A15_MPCore.dsc22
-rw-r--r--ArmPlatformPkg/ArmVExpressPkg/ArmVExpress-RTSM-A9x4.dsc15
-rw-r--r--ArmPlatformPkg/ArmVExpressPkg/Library/ArmVExpressLibCTA15-A7/ArmVExpressLib.inf3
-rw-r--r--ArmPlatformPkg/ArmVExpressPkg/Library/ArmVExpressLibCTA15-A7/CTA15-A7.c2
-rw-r--r--ArmPlatformPkg/ArmVExpressPkg/Library/ArmVExpressLibCTA15-A7/CTA15-A7Helper.S42
-rw-r--r--ArmPlatformPkg/ArmVExpressPkg/Library/ArmVExpressLibCTA15-A7/CTA15-A7Helper.asm42
-rw-r--r--ArmPlatformPkg/ArmVExpressPkg/Library/ArmVExpressLibCTA15-A7/CTA15-A7Mem.c18
-rw-r--r--ArmPlatformPkg/ArmVExpressPkg/Library/ArmVExpressLibCTA15x2/ArmVExpressLib.inf6
-rw-r--r--ArmPlatformPkg/ArmVExpressPkg/Library/ArmVExpressLibCTA15x2/ArmVExpressSecLib.inf3
-rw-r--r--ArmPlatformPkg/ArmVExpressPkg/Library/ArmVExpressLibCTA15x2/CTA15x2.c26
-rw-r--r--ArmPlatformPkg/ArmVExpressPkg/Library/ArmVExpressLibCTA15x2/CTA15x2Helper.S62
-rw-r--r--ArmPlatformPkg/ArmVExpressPkg/Library/ArmVExpressLibCTA15x2/CTA15x2Helper.asm70
-rw-r--r--ArmPlatformPkg/ArmVExpressPkg/Library/ArmVExpressLibCTA15x2/CTA15x2Mem.c18
-rw-r--r--ArmPlatformPkg/ArmVExpressPkg/Library/ArmVExpressLibCTA5s/ArmVExpressLib.inf6
-rw-r--r--ArmPlatformPkg/ArmVExpressPkg/Library/ArmVExpressLibCTA5s/ArmVExpressSecLib.inf3
-rw-r--r--ArmPlatformPkg/ArmVExpressPkg/Library/ArmVExpressLibCTA5s/CTA5Helper.S62
-rw-r--r--ArmPlatformPkg/ArmVExpressPkg/Library/ArmVExpressLibCTA5s/CTA5Helper.asm70
-rw-r--r--ArmPlatformPkg/ArmVExpressPkg/Library/ArmVExpressLibCTA5s/CTA5s.c26
-rw-r--r--ArmPlatformPkg/ArmVExpressPkg/Library/ArmVExpressLibCTA5s/CTA5sMem.c18
-rw-r--r--ArmPlatformPkg/ArmVExpressPkg/Library/ArmVExpressLibCTA9x4/ArmVExpressLib.inf6
-rw-r--r--ArmPlatformPkg/ArmVExpressPkg/Library/ArmVExpressLibCTA9x4/ArmVExpressLibSec.inf2
-rw-r--r--ArmPlatformPkg/ArmVExpressPkg/Library/ArmVExpressLibCTA9x4/CTA9x4.c3
-rw-r--r--ArmPlatformPkg/ArmVExpressPkg/Library/ArmVExpressLibCTA9x4/CTA9x4Helper.S62
-rw-r--r--ArmPlatformPkg/ArmVExpressPkg/Library/ArmVExpressLibCTA9x4/CTA9x4Helper.asm70
-rw-r--r--ArmPlatformPkg/ArmVExpressPkg/Library/ArmVExpressLibCTA9x4/CTA9x4Mem.c18
-rw-r--r--ArmPlatformPkg/ArmVExpressPkg/Library/ArmVExpressLibRTSM/Arm/RTSMHelper.S53
-rw-r--r--ArmPlatformPkg/ArmVExpressPkg/Library/ArmVExpressLibRTSM/Arm/RTSMHelper.asm59
-rw-r--r--ArmPlatformPkg/ArmVExpressPkg/Library/ArmVExpressLibRTSM/RTSM.c2
-rw-r--r--ArmPlatformPkg/ArmVExpressPkg/Library/ArmVExpressLibRTSM/RTSMMem.c19
-rw-r--r--ArmPlatformPkg/ArmVExpressPkg/Library/ArmVExpressSecLibCTA9x4/CTA9x4Sec.c4
-rw-r--r--ArmPlatformPkg/ArmVExpressPkg/Library/ArmVExpressSecLibRTSM/Arm/RTSMHelper.S71
-rw-r--r--ArmPlatformPkg/ArmVExpressPkg/Library/ArmVExpressSecLibRTSM/Arm/RTSMHelper.asm73
-rw-r--r--ArmPlatformPkg/ArmVExpressPkg/Library/ArmVExpressSecLibRTSM/ArmVExpressSecLib.inf2
-rw-r--r--ArmPlatformPkg/ArmVExpressPkg/Library/ArmVExpressSecLibRTSM/RTSMSec.c2
-rw-r--r--ArmPlatformPkg/ArmVExpressPkg/Library/ResetSystemLib/ResetSystemLib.c9
-rw-r--r--ArmPlatformPkg/Bds/Bds.c33
-rw-r--r--ArmPlatformPkg/Bds/BdsHelper.c11
-rw-r--r--ArmPlatformPkg/Bds/BdsInternal.h5
-rw-r--r--ArmPlatformPkg/Bds/BootMenu.c169
-rw-r--r--ArmPlatformPkg/Bds/BootOption.c1
-rw-r--r--ArmPlatformPkg/Bds/BootOptionSupport.c2
-rw-r--r--ArmPlatformPkg/Drivers/NorFlashDxe/NorFlashBlockIoDxe.c18
-rw-r--r--ArmPlatformPkg/Drivers/NorFlashDxe/NorFlashDxe.c15
-rw-r--r--ArmPlatformPkg/Drivers/PL011Uart/PL011Uart.c57
-rw-r--r--ArmPlatformPkg/Drivers/PL011Uart/PL011Uart.inf5
-rw-r--r--ArmPlatformPkg/Include/Drivers/PL011Uart.h12
-rw-r--r--ArmPlatformPkg/Include/Library/ArmPlatformLib.h56
-rw-r--r--ArmPlatformPkg/Library/ArmPlatformLibNull/Arm/ArmPlatformHelper.S37
-rw-r--r--ArmPlatformPkg/Library/ArmPlatformLibNull/Arm/ArmPlatformHelper.asm38
-rw-r--r--ArmPlatformPkg/Library/ArmPlatformLibNull/ArmPlatformLibNull.c2
-rw-r--r--ArmPlatformPkg/Library/ArmPlatformLibNull/ArmPlatformLibNullMem.c18
-rw-r--r--ArmPlatformPkg/Library/ArmPlatformSecLibNull/ArmPlatformLibNullSec.c4
-rwxr-xr-xArmPlatformPkg/Library/DebugSecExtraActionLib/DebugSecExtraActionLib.c5
-rwxr-xr-xArmPlatformPkg/Library/DebugSecExtraActionLib/DebugSecExtraActionLib.inf5
-rw-r--r--ArmPlatformPkg/Library/PL011SerialPortLib/PL011SerialPortExtLib.c14
-rw-r--r--ArmPlatformPkg/Library/PL011SerialPortLib/PL011SerialPortLib.c20
-rw-r--r--ArmPlatformPkg/PrePeiCore/Arm/PrePeiCoreEntryPoint.S31
-rw-r--r--ArmPlatformPkg/PrePeiCore/Arm/PrePeiCoreEntryPoint.asm29
-rw-r--r--ArmPlatformPkg/PrePeiCore/PrePeiCore.c2
-rw-r--r--ArmPlatformPkg/PrePeiCore/PrePeiCoreMPCore.inf1
-rw-r--r--ArmPlatformPkg/PrePeiCore/PrePeiCoreUniCore.inf3
-rw-r--r--ArmPlatformPkg/PrePi/Arm/ModuleEntryPoint.S14
-rw-r--r--ArmPlatformPkg/PrePi/Arm/ModuleEntryPoint.asm14
-rwxr-xr-xArmPlatformPkg/PrePi/PeiMPCore.inf1
-rwxr-xr-xArmPlatformPkg/PrePi/PeiUniCore.inf2
-rwxr-xr-xArmPlatformPkg/PrePi/PrePi.c6
-rw-r--r--ArmPlatformPkg/Sec/Arm/Helper.S4
-rw-r--r--ArmPlatformPkg/Sec/Arm/SecEntryPoint.S27
-rw-r--r--ArmPlatformPkg/Sec/Arm/SecEntryPoint.asm31
-rw-r--r--ArmPlatformPkg/Sec/Sec.c6
-rw-r--r--ArmPlatformPkg/Sec/Sec.inf6
-rw-r--r--ArmPlatformPkg/Sec/SecInternal.h1
-rwxr-xr-xBaseTools/Conf/tools_def.template20
-rw-r--r--BaseTools/Source/C/Include/Arm/ProcessorBind.h2
-rw-r--r--BaseTools/Source/C/Makefiles/header.makefile11
-rwxr-xr-xBaseTools/toolsetup.bat4
-rw-r--r--BeagleBoardPkg/Library/BeagleBoardLib/BeagleBoardHelper.S35
-rw-r--r--BeagleBoardPkg/Library/BeagleBoardLib/BeagleBoardHelper.asm40
-rwxr-xr-xBeagleBoardPkg/Library/BeagleBoardLib/BeagleBoardLib.inf9
-rwxr-xr-xBeagleBoardPkg/Library/BeagleBoardLib/BeagleBoardMem.c18
-rw-r--r--CryptoPkg/Library/BaseCryptLib/Pk/CryptRsaBasic.c87
-rw-r--r--CryptoPkg/Library/BaseCryptLib/Pk/CryptRsaExt.c145
-rw-r--r--CryptoPkg/Library/BaseCryptLib/Rand/CryptRand.c6
-rw-r--r--CryptoPkg/Library/BaseCryptLib/Rand/CryptRandItc.c6
-rw-r--r--CryptoPkg/Library/BaseCryptLib/Rand/CryptRandTsc.c6
-rw-r--r--EdkCompatibilityPkg/Compatibility/SmmBaseHelper/SmmBaseHelper.c31
-rw-r--r--EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/BasePrintLib/PrintLib.c11
-rw-r--r--EdkShellBinPkg/Bin/Ia32/Apps/dmpstore.efibin26208 -> 26112 bytes
-rw-r--r--EdkShellBinPkg/Bin/Ipf/Apps/dmpstore.efibin77440 -> 77344 bytes
-rw-r--r--EdkShellBinPkg/Bin/X64/Apps/dmpstore.efibin32832 -> 32704 bytes
-rw-r--r--EdkShellBinPkg/FullShell/Ia32/Shell_Full.efibin683904 -> 683968 bytes
-rw-r--r--EdkShellBinPkg/FullShell/Ipf/Shell_Full.efibin1331488 -> 1331776 bytes
-rw-r--r--EdkShellBinPkg/FullShell/X64/Shell_Full.efibin771072 -> 771136 bytes
-rw-r--r--EdkShellBinPkg/ReadMe.txt4
-rw-r--r--EmbeddedPkg/Include/Guid/._ExtractSection.hbin4096 -> 0 bytes
-rw-r--r--EmbeddedPkg/Include/Library/SerialPortExtLib.h12
-rw-r--r--EmbeddedPkg/Library/TemplateSerialPortExtLib/TemplateSerialPortExtLib.c12
-rw-r--r--EmbeddedPkg/SerialDxe/SerialIo.c3
-rw-r--r--EmbeddedPkg/Universal/MmcDxe/MmcBlockIo.c213
-rw-r--r--EmulatorPkg/EmulatorPkg.dsc1
-rw-r--r--EmulatorPkg/Library/DxeEmuSerialPortLib/DxeEmuSerialPortLib.c55
-rw-r--r--EmulatorPkg/Library/PeiEmuSerialPortLib/PeiEmuSerialPortLib.c56
-rw-r--r--IntelFrameworkModulePkg/Bus/Isa/IsaFloppyPei/FloppyPeim.c18
-rw-r--r--IntelFrameworkModulePkg/Csm/LegacyBiosDxe/LegacyPci.c12
-rw-r--r--IntelFrameworkModulePkg/IntelFrameworkModulePkg.dsc5
-rw-r--r--IntelFrameworkModulePkg/Library/GenericBdsLib/BdsBoot.c6
-rw-r--r--IntelFrameworkModulePkg/Library/GenericBdsLib/InternalBdsLib.h10
-rw-r--r--IntelFrameworkModulePkg/Library/GenericBdsLib/Performance.c61
-rw-r--r--IntelFrameworkModulePkg/Universal/BdsDxe/Bds.h5
-rw-r--r--IntelFrameworkModulePkg/Universal/BdsDxe/BdsDxe.inf3
-rw-r--r--IntelFrameworkModulePkg/Universal/BdsDxe/BdsEntry.c89
-rw-r--r--IntelFrameworkModulePkg/Universal/BdsDxe/Language.c205
-rw-r--r--MdeModulePkg/Bus/Ata/AtaBusDxe/AtaBus.c27
-rw-r--r--MdeModulePkg/Bus/Pci/PciBusDxe/PciResourceSupport.c46
-rw-r--r--MdeModulePkg/Bus/Pci/XhciDxe/Xhci.c8
-rw-r--r--MdeModulePkg/Bus/Usb/UsbBusDxe/UsbDesc.c9
-rw-r--r--MdeModulePkg/Include/Guid/FirmwarePerformance.h14
-rw-r--r--MdeModulePkg/Include/Guid/Performance.h3
-rw-r--r--MdeModulePkg/Include/Guid/SmmVariableCommon.h10
-rw-r--r--MdeModulePkg/Include/Protocol/VariableLock.h63
-rw-r--r--MdeModulePkg/Library/DxeNetLib/DxeNetLib.c43
-rw-r--r--MdeModulePkg/Library/SmmCorePerformanceLib/SmmCorePerformanceLib.c89
-rw-r--r--MdeModulePkg/MdeModulePkg.dec5
-rw-r--r--MdeModulePkg/MdeModulePkg.dsc8
-rw-r--r--MdeModulePkg/Universal/Acpi/BootScriptExecutorDxe/X64/S3Asm.S8
-rw-r--r--MdeModulePkg/Universal/Acpi/FirmwarePerformanceDataTableDxe/FirmwarePerformanceDxe.c240
-rw-r--r--MdeModulePkg/Universal/Acpi/FirmwarePerformanceDataTableDxe/FirmwarePerformanceDxe.inf7
-rw-r--r--MdeModulePkg/Universal/Acpi/FirmwarePerformanceDataTablePei/FirmwarePerformancePei.c37
-rw-r--r--MdeModulePkg/Universal/Acpi/FirmwarePerformanceDataTablePei/FirmwarePerformancePei.inf4
-rw-r--r--MdeModulePkg/Universal/Acpi/FirmwarePerformanceDataTableSmm/FirmwarePerformanceSmm.c50
-rw-r--r--MdeModulePkg/Universal/DevicePathDxe/DevicePathFromText.c100
-rw-r--r--MdeModulePkg/Universal/DevicePathDxe/DevicePathToText.c36
-rw-r--r--MdeModulePkg/Universal/FaultTolerantWriteDxe/FaultTolerantWriteSmm.c184
-rw-r--r--MdeModulePkg/Universal/FaultTolerantWriteDxe/FaultTolerantWriteSmm.inf3
-rw-r--r--MdeModulePkg/Universal/FaultTolerantWriteDxe/FaultTolerantWriteSmmDxe.c10
-rw-r--r--MdeModulePkg/Universal/FaultTolerantWriteDxe/FaultTolerantWriteSmmDxe.inf7
-rw-r--r--MdeModulePkg/Universal/LockBox/SmmLockBox/SmmLockBox.c80
-rw-r--r--MdeModulePkg/Universal/Network/IScsiDxe/IScsiProto.c4
-rw-r--r--MdeModulePkg/Universal/Network/Ip4ConfigDxe/Ip4ConfigDriver.c6
-rw-r--r--MdeModulePkg/Universal/Network/Ip4Dxe/Ip4Driver.c33
-rw-r--r--MdeModulePkg/Universal/Network/Ip4Dxe/Ip4If.c36
-rw-r--r--MdeModulePkg/Universal/Network/Tcp4Dxe/Tcp4Driver.c14
-rw-r--r--MdeModulePkg/Universal/Network/UefiPxeBcDxe/PxeBcDhcp.c14
-rw-r--r--MdeModulePkg/Universal/Network/UefiPxeBcDxe/PxeBcDhcp.h3
-rw-r--r--MdeModulePkg/Universal/Network/UefiPxeBcDxe/UefiPxeBcDxe.inf5
-rw-r--r--MdeModulePkg/Universal/SetupBrowserDxe/IfrParse.c398
-rw-r--r--MdeModulePkg/Universal/SetupBrowserDxe/InputHandler.c30
-rw-r--r--MdeModulePkg/Universal/SetupBrowserDxe/Setup.c557
-rw-r--r--MdeModulePkg/Universal/SetupBrowserDxe/Setup.h54
-rw-r--r--MdeModulePkg/Universal/Variable/EmuRuntimeDxe/EmuVariable.c17
-rw-r--r--MdeModulePkg/Universal/Variable/RuntimeDxe/Variable.c118
-rw-r--r--MdeModulePkg/Universal/Variable/RuntimeDxe/Variable.h32
-rw-r--r--MdeModulePkg/Universal/Variable/RuntimeDxe/VariableDxe.c51
-rw-r--r--MdeModulePkg/Universal/Variable/RuntimeDxe/VariableRuntimeDxe.inf6
-rw-r--r--MdeModulePkg/Universal/Variable/RuntimeDxe/VariableSmm.c288
-rw-r--r--MdeModulePkg/Universal/Variable/RuntimeDxe/VariableSmm.inf3
-rw-r--r--MdeModulePkg/Universal/Variable/RuntimeDxe/VariableSmmRuntimeDxe.c194
-rw-r--r--MdeModulePkg/Universal/Variable/RuntimeDxe/VariableSmmRuntimeDxe.inf3
-rw-r--r--MdePkg/Include/IndustryStandard/Pci.h5
-rw-r--r--MdePkg/Library/BasePrintLib/PrintLibInternal.c16
-rw-r--r--NetworkPkg/Application/VConfig/VConfig.c2
-rw-r--r--NetworkPkg/Application/VConfig/VConfigStrings.unibin8624 -> 8624 bytes
-rw-r--r--NetworkPkg/IScsiDxe/IScsiDriver.c615
-rw-r--r--NetworkPkg/IScsiDxe/IScsiDriver.h136
-rw-r--r--NetworkPkg/IScsiDxe/IScsiProto.c2
-rw-r--r--NetworkPkg/IpSecDxe/IkeService.c18
-rw-r--r--NetworkPkg/IpSecDxe/IkeService.h10
-rw-r--r--NetworkPkg/IpSecDxe/IpSecDriver.c472
-rw-r--r--NetworkPkg/NetworkPkg.dsc11
-rw-r--r--NetworkPkg/TcpDxe/TcpDriver.c277
-rw-r--r--NetworkPkg/TcpDxe/TcpDriver.h75
-rw-r--r--NetworkPkg/UefiPxeBcDxe/PxeBcBoot.c11
-rw-r--r--NetworkPkg/UefiPxeBcDxe/PxeBcDhcp4.h4
-rw-r--r--NetworkPkg/UefiPxeBcDxe/PxeBcDriver.c435
-rw-r--r--NetworkPkg/UefiPxeBcDxe/PxeBcDriver.h87
-rw-r--r--NetworkPkg/UefiPxeBcDxe/UefiPxeBcDxe.inf7
-rw-r--r--OptionRomPkg/OptionRomPkg.dsc6
-rw-r--r--OvmfPkg/Include/Library/VirtioLib.h57
-rw-r--r--OvmfPkg/Library/PlatformBdsLib/QemuBootOrder.c29
-rw-r--r--OvmfPkg/Library/SerializeVariablesLib/SerializeVariablesLib.c27
-rw-r--r--OvmfPkg/Library/VirtioLib/VirtioLib.c82
-rw-r--r--OvmfPkg/OvmfPkgIa32.dsc2
-rw-r--r--OvmfPkg/OvmfPkgIa32.fdf4
-rw-r--r--OvmfPkg/OvmfPkgIa32X64.dsc2
-rw-r--r--OvmfPkg/OvmfPkgIa32X64.fdf4
-rw-r--r--OvmfPkg/OvmfPkgX64.dsc2
-rw-r--r--OvmfPkg/OvmfPkgX64.fdf4
-rw-r--r--OvmfPkg/README107
-rw-r--r--[-rwxr-xr-x]PandaBoardPkg/Include/PandaBoard.h0
-rw-r--r--[-rwxr-xr-x]PandaBoardPkg/Library/PandaBoardLib/Clock.c0
-rw-r--r--[-rwxr-xr-x]PandaBoardPkg/Library/PandaBoardLib/PadConfiguration.c0
-rw-r--r--PerformancePkg/PerformancePkg.dsc5
-rw-r--r--SamsungPlatformPkg/ArndaleBoardPkg/Library/ArndaleBoardLib/Exynos5250/BoardHelper.S25
-rwxr-xr-xSamsungPlatformPkg/ArndaleBoardPkg/arndale-Exynos5250.dsc16
-rwxr-xr-xSamsungPlatformPkg/ArndaleBoardPkg/arndale-Exynos5250.fdf15
-rw-r--r--SamsungPlatformPkg/ExynosPkg/Exynos5250/Drivers/Gic400Dxe/PL390GicSec.c3
-rw-r--r--SamsungPlatformPkg/ExynosPkg/Exynos5250/Drivers/Gic400Dxe/PL390GicSecLib.inf5
-rw-r--r--SamsungPlatformPkg/ExynosPkg/Exynos5250/Sec/Sec.c5
-rw-r--r--SamsungPlatformPkg/ExynosPkg/Exynos5250/Sec/Sec.inf3
-rw-r--r--SamsungPlatformPkg/ExynosPkg/Exynos5250/Sec/SecEntryPoint.S25
-rw-r--r--SecurityPkg/Library/DxeImageVerificationLib/DxeImageVerificationLib.c60
-rw-r--r--SecurityPkg/Library/DxeImageVerificationLib/DxeImageVerificationLib.inf3
-rw-r--r--SecurityPkg/Library/DxeTpmMeasureBootLib/DxeTpmMeasureBootLib.c10
-rw-r--r--SecurityPkg/SecurityPkg.dsc30
-rw-r--r--SecurityPkg/VariableAuthenticated/EsalVariableDxeSal/Variable.c16
-rw-r--r--SecurityPkg/VariableAuthenticated/RuntimeDxe/AuthService.c37
-rw-r--r--SecurityPkg/VariableAuthenticated/RuntimeDxe/AuthService.h20
-rw-r--r--SecurityPkg/VariableAuthenticated/RuntimeDxe/Variable.c168
-rw-r--r--SecurityPkg/VariableAuthenticated/RuntimeDxe/Variable.h32
-rw-r--r--SecurityPkg/VariableAuthenticated/RuntimeDxe/VariableDxe.c57
-rw-r--r--SecurityPkg/VariableAuthenticated/RuntimeDxe/VariableRuntimeDxe.inf4
-rw-r--r--SecurityPkg/VariableAuthenticated/RuntimeDxe/VariableSmm.c286
-rw-r--r--SecurityPkg/VariableAuthenticated/RuntimeDxe/VariableSmm.inf1
-rw-r--r--SecurityPkg/VariableAuthenticated/RuntimeDxe/VariableSmmRuntimeDxe.c195
-rw-r--r--SecurityPkg/VariableAuthenticated/RuntimeDxe/VariableSmmRuntimeDxe.inf1
-rw-r--r--SecurityPkg/VariableAuthenticated/SecureBootConfigDxe/SecureBootConfig.vfr2
-rw-r--r--SecurityPkg/VariableAuthenticated/SecureBootConfigDxe/SecureBootConfigFileExplorer.c8
-rw-r--r--SecurityPkg/VariableAuthenticated/SecureBootConfigDxe/SecureBootConfigImpl.c83
-rw-r--r--SecurityPkg/VariableAuthenticated/SecureBootConfigDxe/SecureBootConfigNvData.h1
-rw-r--r--ShellPkg/Application/Shell/ShellProtocol.c2
-rw-r--r--ShellPkg/Library/UefiShellCEntryLib/UefiShellCEntryLib.c12
-rw-r--r--ShellPkg/Library/UefiShellCommandLib/UefiShellCommandLib.c8
-rw-r--r--ShellPkg/Library/UefiShellDebug1CommandsLib/Bcfg.c4
-rw-r--r--ShellPkg/Library/UefiShellDebug1CommandsLib/DmpStore.c4
-rw-r--r--ShellPkg/Library/UefiShellDebug1CommandsLib/EditInputBar.c8
-rw-r--r--ShellPkg/Library/UefiShellDebug1CommandsLib/HexEdit/BufferImage.c25
-rw-r--r--ShellPkg/Library/UefiShellDebug1CommandsLib/HexEdit/DiskImage.c13
-rw-r--r--ShellPkg/Library/UefiShellDebug1CommandsLib/HexEdit/HexEdit.c6
-rw-r--r--ShellPkg/Library/UefiShellDebug1CommandsLib/HexEdit/MainHexEditor.c3
-rw-r--r--ShellPkg/Library/UefiShellDebug1CommandsLib/HexEdit/MemImage.c6
-rw-r--r--ShellPkg/Library/UefiShellDebug1CommandsLib/MemMap.c4
-rw-r--r--ShellPkg/Library/UefiShellDebug1CommandsLib/Mm.c2
-rw-r--r--ShellPkg/Library/UefiShellDebug1CommandsLib/Mode.c4
-rw-r--r--ShellPkg/Library/UefiShellDebug1CommandsLib/Pci.c2
-rw-r--r--ShellPkg/Library/UefiShellDebug1CommandsLib/UefiShellDebug1CommandsLib.c2
-rw-r--r--ShellPkg/Library/UefiShellDriver1CommandsLib/Dh.c2
-rw-r--r--ShellPkg/Library/UefiShellInstall1CommandsLib/Bcfg.c4
-rw-r--r--ShellPkg/Library/UefiShellLevel1CommandsLib/If.c5
-rw-r--r--ShellPkg/Library/UefiShellLevel2CommandsLib/Cp.c44
-rw-r--r--ShellPkg/Library/UefiShellLevel2CommandsLib/Load.c2
-rw-r--r--ShellPkg/Library/UefiShellLevel2CommandsLib/Map.c25
-rw-r--r--ShellPkg/Library/UefiShellLevel2CommandsLib/Mv.c34
-rw-r--r--ShellPkg/Library/UefiShellLevel2CommandsLib/Rm.c5
-rw-r--r--ShellPkg/Library/UefiShellLevel2CommandsLib/TimeDate.c29
-rw-r--r--ShellPkg/Library/UefiShellLevel3CommandsLib/Cls.c9
-rw-r--r--ShellPkg/Library/UefiShellLevel3CommandsLib/GetMtc.c19
-rw-r--r--ShellPkg/Library/UefiShellLevel3CommandsLib/Help.c2
-rw-r--r--ShellPkg/Library/UefiShellLevel3CommandsLib/Touch.c6
-rw-r--r--ShellPkg/Library/UefiShellLevel3CommandsLib/UefiShellLevel3CommandsLib.unibin42896 -> 42726 bytes
-rw-r--r--SourceLevelDebugPkg/Library/DebugAgent/DebugAgentCommon/DebugAgent.c154
-rw-r--r--SourceLevelDebugPkg/Library/DebugAgent/DebugAgentCommon/DebugAgent.h5
-rw-r--r--SourceLevelDebugPkg/Library/DebugAgent/DxeDebugAgent/DxeDebugAgentLib.c26
-rw-r--r--SourceLevelDebugPkg/Library/DebugAgent/DxeDebugAgentLib.inf1
-rw-r--r--SourceLevelDebugPkg/Library/DebugAgent/SecPeiDebugAgent/SecPeiDebugAgentLib.c71
-rw-r--r--SourceLevelDebugPkg/Library/DebugCommunicationLibUsb/DebugCommunicationLibUsb.c10
-rw-r--r--StdLib/LibC/Locale/multibyte_Utf8.c46
287 files changed, 7512 insertions, 3371 deletions
diff --git a/.gitignore b/.gitignore
new file mode 100644
index 0000000000..70df4bdd17
--- /dev/null
+++ b/.gitignore
@@ -0,0 +1,22 @@
+*.d
+*.o
+*.pyc
+BaseTools/Source/C/VfrCompile/EfiVfrParser.cpp
+BaseTools/Source/C/VfrCompile/EfiVfrParser.h
+BaseTools/Source/C/VfrCompile/Pccts/antlr/antlr
+BaseTools/Source/C/VfrCompile/Pccts/dlg/dlg
+BaseTools/Source/C/VfrCompile/VfrLexer.cpp
+BaseTools/Source/C/VfrCompile/VfrLexer.h
+BaseTools/Source/C/VfrCompile/VfrParser.dlg
+BaseTools/Source/C/VfrCompile/VfrSyntax.cpp
+BaseTools/Source/C/VfrCompile/VfrTokens.h
+BaseTools/Source/C/bin/
+BaseTools/Source/C/libs/
+Build/
+Conf/.cache/
+Conf/BuildEnv.sh
+Conf/build_rule.txt
+Conf/target.txt
+Conf/tools_def.txt
+PandaBoardPkg/Tools/chtool
+tmp.bin
diff --git a/ArmPkg/ArmPkg.dec b/ArmPkg/ArmPkg.dec
index 86a3dba7c3..81c4db6a6f 100644
--- a/ArmPkg/ArmPkg.dec
+++ b/ArmPkg/ArmPkg.dec
@@ -2,7 +2,7 @@
# ARM processor package.
#
# Copyright (c) 2009 - 2010, Apple Inc. All rights reserved.<BR>
-# Copyright (c) 2011 - 2012, ARM Limited. All rights reserved.
+# Copyright (c) 2011 - 2013, ARM Limited. All rights reserved.
#
# This program and the accompanying materials
# are licensed and made available under the terms and conditions of the BSD License
@@ -137,8 +137,6 @@
# 0xC00 = cp10 | cp11
gArmTokenSpaceGuid.PcdArmNsacr|0xC00|UINT32|0x00000039
- gArmTokenSpaceGuid.PcdArmNonSecModeTransition|0x0|UINT32|0x0000003E
-
# System Memory (DRAM): These PCDs define the region of in-built system memory
# Some platforms can get DRAM extensions, these additional regions will be declared
# to UEFI by ArmPLatformPlib
@@ -163,15 +161,10 @@
# BdsLib
#
gArmTokenSpaceGuid.PcdArmMachineType|0|UINT32|0x0000001E
- # The compressed Linux kernel is expected to load at MemStart + 0x8000 (e.g. 0x8000_8000)
- gArmTokenSpaceGuid.PcdArmLinuxKernelFixedOffset|0x00008000|UINT32|0x00000027
# The compressed Linux kernel is expected to be under 128MB from the beginning of the System Memory
gArmTokenSpaceGuid.PcdArmLinuxKernelMaxOffset|0x08000000|UINT32|0x0000001F
# The Linux ATAGs are expected to be under 0x4000 (16KB) from the beginning of the System Memory
gArmTokenSpaceGuid.PcdArmLinuxAtagMaxOffset|0x4000|UINT32|0x00000020
- # If the fixed FDT address is not available, then it should be loaded the below the kernel
- # The recommandation from the Linux kernel is to have the FDT below 16KB
- gArmTokenSpaceGuid.PcdArmLinuxFdtMaxOffset|0x4000|UINT32|0x00000023
#
# ARM Architectural Timer
@@ -180,3 +173,13 @@
# ARM Architectural Timer Interrupt(GIC PPI) number
gArmTokenSpaceGuid.PcdArmArchTimerSecIntrNum|29|UINT32|0x00000035
gArmTokenSpaceGuid.PcdArmArchTimerIntrNum|30|UINT32|0x00000036
+
+[PcdsFixedAtBuild.ARM]
+ # By default we do not do a transition to non-secure mode
+ gArmTokenSpaceGuid.PcdArmNonSecModeTransition|0x0|UINT32|0x0000003E
+ # If the fixed FDT address is not available, then it should be loaded below the kernel.
+ # The recommendation from the Linux kernel is to have the FDT below 16KB.
+ # (see the kernel doc: Documentation/arm/Booting)
+ gArmTokenSpaceGuid.PcdArmLinuxFdtMaxOffset|0x4000|UINT32|0x00000023
+ # The FDT blob must be loaded at a 64bit aligned address.
+ gArmTokenSpaceGuid.PcdArmLinuxFdtAlignment|0x8|UINT32|0x00000026
diff --git a/ArmPkg/Drivers/ArmCpuLib/ArmCortexA15Lib/ArmCortexA15Lib.c b/ArmPkg/Drivers/ArmCpuLib/ArmCortexA15Lib/ArmCortexA15Lib.c
index 95ab073e18..b15597893a 100644
--- a/ArmPkg/Drivers/ArmCpuLib/ArmCortexA15Lib/ArmCortexA15Lib.c
+++ b/ArmPkg/Drivers/ArmCpuLib/ArmCortexA15Lib/ArmCortexA15Lib.c
@@ -55,7 +55,7 @@ ArmCpuSetupSmpNonSecure (
)
{
/*// Make the SCU accessible in Non Secure world
- if (IS_PRIMARY_CORE(MpId)) {
+ if (ArmPlatformIsPrimaryCore (MpId)) {
ScuBase = ArmGetScuBaseAddress();
// Allow NS access to SCU register
diff --git a/ArmPkg/Drivers/ArmCpuLib/ArmCortexA15Lib/ArmCortexA15Lib.inf b/ArmPkg/Drivers/ArmCpuLib/ArmCortexA15Lib/ArmCortexA15Lib.inf
index bcf7f6bfba..3ddd4c5704 100644
--- a/ArmPkg/Drivers/ArmCpuLib/ArmCortexA15Lib/ArmCortexA15Lib.inf
+++ b/ArmPkg/Drivers/ArmCpuLib/ArmCortexA15Lib/ArmCortexA15Lib.inf
@@ -31,10 +31,5 @@
[Sources.common]
ArmCortexA15Lib.c
-[FeaturePcd]
-
[FixedPcd]
- gArmTokenSpaceGuid.PcdArmPrimaryCoreMask
- gArmTokenSpaceGuid.PcdArmPrimaryCore
-
gArmTokenSpaceGuid.PcdArmArchTimerFreqInHz
diff --git a/ArmPkg/Drivers/ArmCpuLib/ArmCortexA9Lib/ArmCortexA9Lib.c b/ArmPkg/Drivers/ArmCpuLib/ArmCortexA9Lib/ArmCortexA9Lib.c
index 2bf2d81070..aed43cb3ef 100644
--- a/ArmPkg/Drivers/ArmCpuLib/ArmCortexA9Lib/ArmCortexA9Lib.c
+++ b/ArmPkg/Drivers/ArmCpuLib/ArmCortexA9Lib/ArmCortexA9Lib.c
@@ -15,6 +15,7 @@
#include <Base.h>
#include <Library/ArmLib.h>
#include <Library/ArmCpuLib.h>
+#include <Library/ArmPlatformLib.h>
#include <Library/IoLib.h>
#include <Library/PcdLib.h>
@@ -63,7 +64,7 @@ ArmCpuSetupSmpNonSecure (
ArmSetAuxCrBit (A9_FEATURE_SMP);
// Make the SCU accessible in Non Secure world
- if (IS_PRIMARY_CORE(MpId)) {
+ if (ArmPlatformIsPrimaryCore (MpId)) {
ScuBase = ArmGetScuBaseAddress();
// Allow NS access to SCU register
diff --git a/ArmPkg/Drivers/ArmCpuLib/ArmCortexA9Lib/ArmCortexA9Lib.inf b/ArmPkg/Drivers/ArmCpuLib/ArmCortexA9Lib/ArmCortexA9Lib.inf
index 866736f6ff..a84501dea4 100644
--- a/ArmPkg/Drivers/ArmCpuLib/ArmCortexA9Lib/ArmCortexA9Lib.inf
+++ b/ArmPkg/Drivers/ArmCpuLib/ArmCortexA9Lib/ArmCortexA9Lib.inf
@@ -1,5 +1,5 @@
#/* @file
-# Copyright (c) 2011-2012, ARM Limited. All rights reserved.
+# Copyright (c) 2011-2013, ARM Limited. All rights reserved.
#
# This program and the accompanying materials
# are licensed and made available under the terms and conditions of the BSD License
@@ -22,9 +22,11 @@
[Packages]
MdePkg/MdePkg.dec
ArmPkg/ArmPkg.dec
+ ArmPlatformPkg/ArmPlatformPkg.dec
[LibraryClasses]
ArmLib
+ ArmPlatformLib
IoLib
PcdLib
@@ -33,8 +35,3 @@
ArmCortexA9Helper.asm | RVCT
ArmCortexA9Helper.S | GCC
-[FeaturePcd]
-
-[FixedPcd]
- gArmTokenSpaceGuid.PcdArmPrimaryCoreMask
- gArmTokenSpaceGuid.PcdArmPrimaryCore
diff --git a/ArmPkg/Drivers/PL390Gic/PL390GicSec.c b/ArmPkg/Drivers/PL390Gic/PL390GicSec.c
index e47e23d581..bae76e441b 100644
--- a/ArmPkg/Drivers/PL390Gic/PL390GicSec.c
+++ b/ArmPkg/Drivers/PL390Gic/PL390GicSec.c
@@ -1,6 +1,6 @@
/** @file
*
-* Copyright (c) 2011-2012, ARM Limited. All rights reserved.
+* Copyright (c) 2011-2013, ARM Limited. All rights reserved.
*
* This program and the accompanying materials
* are licensed and made available under the terms and conditions of the BSD License
@@ -14,6 +14,7 @@
#include <Base.h>
#include <Library/ArmLib.h>
+#include <Library/ArmPlatformLib.h>
#include <Library/DebugLib.h>
#include <Library/IoLib.h>
#include <Library/ArmGicLib.h>
@@ -39,18 +40,19 @@ ArmGicSetupNonSecure (
// Set priority Mask so that no interrupts get through to CPU
MmioWrite32 (GicInterruptInterfaceBase + ARM_GIC_ICCPMR, 0);
- // Check if there are any pending interrupts
- //TODO: could be extended to take Peripheral interrupts into consideration, but at the moment only SGI's are taken into consideration.
- while(0 != (MmioRead32 (GicDistributorBase + ARM_GIC_ICDICPR) & 0xF)) {
- // Some of the SGI's are still pending, read Ack register and send End of Interrupt Signal
- InterruptId = MmioRead32 (GicInterruptInterfaceBase + ARM_GIC_ICCIAR);
+ InterruptId = MmioRead32 (GicInterruptInterfaceBase + ARM_GIC_ICCIAR);
- // Write to End of interrupt signal
+ // Only try to clear valid interrupts. Ignore spurious interrupts.
+ while ((InterruptId & 0x3FF) < ArmGicGetMaxNumInterrupts (GicDistributorBase)) {
+ // Some of the SGI's are still pending, read Ack register and send End of Interrupt Signal
MmioWrite32 (GicInterruptInterfaceBase + ARM_GIC_ICCEIOR, InterruptId);
+
+ // Next
+ InterruptId = MmioRead32 (GicInterruptInterfaceBase + ARM_GIC_ICCIAR);
}
// Only the primary core should set the Non Secure bit to the SPIs (Shared Peripheral Interrupt).
- if (IS_PRIMARY_CORE(MpId)) {
+ if (ArmPlatformIsPrimaryCore (MpId)) {
// Ensure all GIC interrupts are Non-Secure
for (Index = 0; Index < (ArmGicGetMaxNumInterrupts (GicDistributorBase) / 32); Index++) {
MmioWrite32 (GicDistributorBase + ARM_GIC_ICDISR + (Index * 4), 0xffffffff);
diff --git a/ArmPkg/Drivers/PL390Gic/PL390GicSecLib.inf b/ArmPkg/Drivers/PL390Gic/PL390GicSecLib.inf
index 73faa39b66..205e503427 100644
--- a/ArmPkg/Drivers/PL390Gic/PL390GicSecLib.inf
+++ b/ArmPkg/Drivers/PL390Gic/PL390GicSecLib.inf
@@ -25,14 +25,14 @@
[Packages]
ArmPkg/ArmPkg.dec
+ ArmPlatformPkg/ArmPlatformPkg.dec
MdePkg/MdePkg.dec
+ MdeModulePkg/MdeModulePkg.dec
[LibraryClasses]
ArmLib
+ ArmPlatformLib
DebugLib
IoLib
PcdLib
-[FixedPcd.common]
- gArmTokenSpaceGuid.PcdArmPrimaryCoreMask
- gArmTokenSpaceGuid.PcdArmPrimaryCore
diff --git a/ArmPkg/Filesystem/SemihostFs/Arm/SemihostFs.c b/ArmPkg/Filesystem/SemihostFs/Arm/SemihostFs.c
index b04e866a99..5f1159d81a 100644
--- a/ArmPkg/Filesystem/SemihostFs/Arm/SemihostFs.c
+++ b/ArmPkg/Filesystem/SemihostFs/Arm/SemihostFs.c
@@ -2,7 +2,7 @@
Support a Semi Host file system over a debuggers JTAG
Copyright (c) 2008 - 2009, Apple Inc. All rights reserved.<BR>
- Portions copyright (c) 2011-2013, ARM Ltd. All rights reserved.<BR>
+ Portions copyright (c) 2011 - 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
@@ -18,6 +18,7 @@
#include <Guid/FileInfo.h>
#include <Guid/FileSystemInfo.h>
+#include <Guid/FileSystemVolumeLabelInfo.h>
#include <Library/BaseLib.h>
#include <Library/BaseMemoryLib.h>
@@ -32,6 +33,9 @@
#include "SemihostFs.h"
+#define DEFAULT_SEMIHOST_FS_LABEL L"SemihostFs"
+
+STATIC CHAR16 *mSemihostFsLabel;
EFI_SIMPLE_FILE_SYSTEM_PROTOCOL gSemihostFs = {
EFI_SIMPLE_FILE_SYSTEM_PROTOCOL_REVISION,
@@ -69,13 +73,15 @@ SEMIHOST_DEVICE_PATH gDevicePath = {
};
typedef struct {
- LIST_ENTRY Link;
- UINT64 Signature;
- EFI_FILE File;
- CHAR8 *FileName;
- UINT32 Position;
- UINTN SemihostHandle;
- BOOLEAN IsRoot;
+ LIST_ENTRY Link;
+ UINT64 Signature;
+ EFI_FILE File;
+ CHAR8 *FileName;
+ UINT64 OpenMode;
+ UINT32 Position;
+ UINTN SemihostHandle;
+ BOOLEAN IsRoot;
+ EFI_FILE_INFO Info;
} SEMIHOST_FCB;
#define SEMIHOST_FCB_SIGNATURE SIGNATURE_32( 'S', 'H', 'F', 'C' )
@@ -134,6 +140,7 @@ VolumeOpen (
}
RootFcb->IsRoot = TRUE;
+ RootFcb->Info.Attribute = EFI_FILE_READ_ONLY | EFI_FILE_DIRECTORY;
InsertTailList (&gFileList, &RootFcb->Link);
@@ -157,11 +164,17 @@ FileOpen (
CHAR8 *AsciiFileName;
UINT32 SemihostMode;
BOOLEAN IsRoot;
+ UINTN Length;
if ((FileName == NULL) || (NewHandle == NULL)) {
return EFI_INVALID_PARAMETER;
}
+ // Semihosting does not support directories
+ if (Attributes & EFI_FILE_DIRECTORY) {
+ return EFI_UNSUPPORTED;
+ }
+
// Semihost interface requires ASCII filenames
AsciiFileName = AllocatePool ((StrLen (FileName) + 1) * sizeof (CHAR8));
if (AsciiFileName == NULL) {
@@ -213,6 +226,18 @@ FileOpen (
FileFcb->SemihostHandle = SemihostHandle;
FileFcb->Position = 0;
FileFcb->IsRoot = IsRoot;
+ FileFcb->OpenMode = OpenMode;
+
+ if (!IsRoot) {
+ Status = SemihostFileLength (SemihostHandle, &Length);
+ if (EFI_ERROR(Status)) {
+ return Status;
+ }
+
+ FileFcb->Info.FileSize = Length;
+ FileFcb->Info.PhysicalSize = Length;
+ FileFcb->Info.Attribute = Attributes;
+ }
InsertTailList (&gFileList, &FileFcb->Link);
@@ -271,8 +296,11 @@ FileDelete (
// Call the semihost interface to delete the file.
Status = SemihostFileRemove (FileName);
+ if (EFI_ERROR(Status)) {
+ Status = EFI_WARN_DELETE_FAILURE;
+ }
} else {
- Status = EFI_UNSUPPORTED;
+ Status = EFI_WARN_DELETE_FAILURE;
}
return Status;
@@ -316,6 +344,11 @@ FileWrite (
Fcb = SEMIHOST_FCB_FROM_THIS(File);
+ // We cannot write a read-only file
+ if (Fcb->OpenMode & EFI_FILE_READ_ONLY) {
+ return EFI_ACCESS_DENIED;
+ }
+
Status = SemihostFileWrite (Fcb->SemihostHandle, &WriteSize, Buffer);
if (!EFI_ERROR(Status)) {
@@ -388,8 +421,6 @@ GetFileInfo (
UINTN NameSize = 0;
UINTN ResultSize;
UINTN Index;
- UINTN Length;
- EFI_STATUS Status;
if (Fcb->IsRoot == TRUE) {
ResultSize = SIZE_OF_EFI_FILE_INFO + sizeof(CHAR16);
@@ -405,30 +436,20 @@ GetFileInfo (
Info = Buffer;
- // Zero out the structure
- ZeroMem (Info, SIZE_OF_EFI_FILE_INFO);
+ // Copy the current file info
+ CopyMem (Info, &Fcb->Info, SIZE_OF_EFI_FILE_INFO);
// Fill in the structure
Info->Size = ResultSize;
if (Fcb->IsRoot == TRUE) {
- Info->Attribute = EFI_FILE_READ_ONLY | EFI_FILE_DIRECTORY;
Info->FileName[0] = L'\0';
} else {
- Status = SemihostFileLength (Fcb->SemihostHandle, &Length);
- if (EFI_ERROR(Status)) {
- return Status;
- }
-
- Info->FileSize = Length;
- Info->PhysicalSize = Length;
-
for (Index = 0; Index < NameSize; Index++) {
Info->FileName[Index] = Fcb->FileName[Index];
}
}
-
*BufferSize = ResultSize;
return EFI_SUCCESS;
@@ -444,10 +465,9 @@ GetFilesystemInfo (
{
EFI_FILE_SYSTEM_INFO *Info = NULL;
EFI_STATUS Status;
- STATIC CHAR16 Label[] = L"SemihostFs";
- UINTN ResultSize = SIZE_OF_EFI_FILE_SYSTEM_INFO + StrSize(Label);
+ UINTN ResultSize = SIZE_OF_EFI_FILE_SYSTEM_INFO + StrSize (mSemihostFsLabel);
- if(*BufferSize >= ResultSize) {
+ if (*BufferSize >= ResultSize) {
ZeroMem (Buffer, ResultSize);
Status = EFI_SUCCESS;
@@ -459,7 +479,7 @@ GetFilesystemInfo (
Info->FreeSpace = 0;
Info->BlockSize = 0;
- StrCpy (Info->VolumeLabel, Label);
+ StrCpy (Info->VolumeLabel, mSemihostFsLabel);
} else {
Status = EFI_BUFFER_TOO_SMALL;
}
@@ -476,17 +496,31 @@ FileGetInfo (
OUT VOID *Buffer
)
{
- SEMIHOST_FCB *Fcb = NULL;
- EFI_STATUS Status = EFI_UNSUPPORTED;
+ SEMIHOST_FCB *Fcb;
+ EFI_STATUS Status;
+ UINTN ResultSize;
Fcb = SEMIHOST_FCB_FROM_THIS(File);
- if (CompareGuid(InformationType, &gEfiFileSystemInfoGuid) != 0) {
- Status = GetFilesystemInfo(Fcb, BufferSize, Buffer);
- } else if (CompareGuid(InformationType, &gEfiFileInfoGuid) != 0) {
- Status = GetFileInfo(Fcb, BufferSize, Buffer);
+ if (CompareGuid (InformationType, &gEfiFileSystemInfoGuid) != 0) {
+ Status = GetFilesystemInfo (Fcb, BufferSize, Buffer);
+ } else if (CompareGuid (InformationType, &gEfiFileInfoGuid) != 0) {
+ Status = GetFileInfo (Fcb, BufferSize, Buffer);
+ } else if (CompareGuid (InformationType, &gEfiFileSystemVolumeLabelInfoIdGuid) != 0) {
+ ResultSize = StrSize (mSemihostFsLabel);
+
+ if (*BufferSize >= ResultSize) {
+ StrCpy (Buffer, mSemihostFsLabel);
+ Status = EFI_SUCCESS;
+ } else {
+ Status = EFI_BUFFER_TOO_SMALL;
+ }
+
+ *BufferSize = ResultSize;
+ } else {
+ Status = EFI_UNSUPPORTED;
}
-
+
return Status;
}
@@ -498,7 +532,27 @@ FileSetInfo (
IN VOID *Buffer
)
{
- return EFI_UNSUPPORTED;
+ EFI_STATUS Status;
+
+ if (Buffer == NULL) {
+ return EFI_INVALID_PARAMETER;
+ }
+
+ Status = EFI_UNSUPPORTED;
+
+ if (CompareGuid (InformationType, &gEfiFileSystemInfoGuid) != 0) {
+ //Status = SetFilesystemInfo (Fcb, BufferSize, Buffer);
+ } else if (CompareGuid (InformationType, &gEfiFileInfoGuid) != 0) {
+ //Status = SetFileInfo (Fcb, BufferSize, Buffer);
+ } else if (CompareGuid (InformationType, &gEfiFileSystemVolumeLabelInfoIdGuid) != 0) {
+ if (StrSize (Buffer) > 0) {
+ FreePool (mSemihostFsLabel);
+ mSemihostFsLabel = AllocateCopyPool (StrSize (Buffer), Buffer);
+ Status = EFI_SUCCESS;
+ }
+ }
+
+ return Status;
}
EFI_STATUS
@@ -506,7 +560,19 @@ FileFlush (
IN EFI_FILE *File
)
{
- return EFI_SUCCESS;
+ SEMIHOST_FCB *Fcb;
+
+ Fcb = SEMIHOST_FCB_FROM_THIS(File);
+
+ if (Fcb->IsRoot) {
+ return EFI_SUCCESS;
+ } else {
+ if (Fcb->Info.Attribute & EFI_FILE_READ_ONLY) {
+ return EFI_ACCESS_DENIED;
+ } else {
+ return EFI_SUCCESS;
+ }
+ }
}
EFI_STATUS
@@ -515,17 +581,27 @@ SemihostFsEntryPoint (
IN EFI_SYSTEM_TABLE *SystemTable
)
{
- EFI_STATUS Status = EFI_NOT_FOUND;
+ EFI_STATUS Status;
+
+ Status = EFI_NOT_FOUND;
if (SemihostConnectionSupported ()) {
+ mSemihostFsLabel = AllocateCopyPool (StrSize (DEFAULT_SEMIHOST_FS_LABEL), DEFAULT_SEMIHOST_FS_LABEL);
+ if (mSemihostFsLabel == NULL) {
+ return EFI_OUT_OF_RESOURCES;
+ }
+
Status = gBS->InstallMultipleProtocolInterfaces (
&gInstallHandle,
&gEfiSimpleFileSystemProtocolGuid, &gSemihostFs,
&gEfiDevicePathProtocolGuid, &gDevicePath,
NULL
);
+
+ if (EFI_ERROR(Status)) {
+ FreePool (mSemihostFsLabel);
+ }
}
return Status;
}
-
diff --git a/ArmPkg/Include/AsmMacroIoLib.h b/ArmPkg/Include/AsmMacroIoLib.h
index c8692fcfd7..dac2e150cc 100644
--- a/ArmPkg/Include/AsmMacroIoLib.h
+++ b/ArmPkg/Include/AsmMacroIoLib.h
@@ -120,13 +120,6 @@
.long (_Data) ; \
1:
-// Convert the (ClusterId,CoreId) into a Core Position
-// We assume there are 4 cores per cluster
-#define GetCorePositionFromMpId(Pos, MpId, Tmp) \
- lsr Pos, MpId, #6 ; \
- and Tmp, MpId, #3 ; \
- add Pos, Pos, Tmp
-
// Reserve a region at the top of the Primary Core stack
// for Global variables for the XIP phase
#define SetPrimaryStack(StackTop, GlobalSize, Tmp) \
@@ -207,11 +200,6 @@ _InitializePrimaryStackEnd:
#define LoadConstantToReg(Data, Reg) \
ldr Reg, =Data
-
-#define GetCorePositionFromMpId(Pos, MpId, Tmp) \
- lsr Pos, MpId, #6 ; \
- and Tmp, MpId, #3 ; \
- add Pos, Pos, Tmp
#define SetPrimaryStack(StackTop, GlobalSize, Tmp) \
and Tmp, GlobalSize, #7 ; \
@@ -305,8 +293,6 @@ _InitializePrimaryStackEnd:
// conditional load testing eq flag
#define LoadConstantToRegIfEq(Data, Reg) LoadConstantToRegIfEqMacro Data, Reg
-#define GetCorePositionFromMpId(Pos, MpId, Tmp) GetCorePositionFromMpId Pos, MpId, Tmp
-
#define SetPrimaryStack(StackTop,GlobalSize,Tmp) SetPrimaryStack StackTop, GlobalSize, Tmp
// Initialize the Global Variable with '0'
diff --git a/ArmPkg/Include/AsmMacroIoLib.inc b/ArmPkg/Include/AsmMacroIoLib.inc
index 1ca99fdd1d..54c32d4c34 100644
--- a/ArmPkg/Include/AsmMacroIoLib.inc
+++ b/ArmPkg/Include/AsmMacroIoLib.inc
@@ -80,13 +80,6 @@
ldr $Reg, =($Data)
MEND
- MACRO
- GetCorePositionFromMpId $Pos, $MpId, $Tmp
- lsr $Pos, $MpId, #6
- and $Tmp, $MpId, #3
- add $Pos, $Pos, $Tmp
- MEND
-
; The reserved place must be 8-bytes aligned for pushing 64-bit variable on the stack
; Note: Global Size will be modified
MACRO
diff --git a/ArmPkg/Include/IndustryStandard/ArmTrustZoneSmc.h b/ArmPkg/Include/IndustryStandard/ArmTrustZoneSmc.h
index 62f8f61a7e..71b4327ebf 100644
--- a/ArmPkg/Include/IndustryStandard/ArmTrustZoneSmc.h
+++ b/ArmPkg/Include/IndustryStandard/ArmTrustZoneSmc.h
@@ -18,6 +18,8 @@
#define ARM_TRUSTZONE_UID_4LETTERID 0x1
#define ARM_TRUSTZONE_UID_MD5 0x2
+#define ARM_TRUSTZONE_ARM_UID 0x40524d48 // "ARMH"
+
#define IS_ARM_TRUSTZONE_SUPPORTED_SMC(Rx,Region) (((UINTN)(Rx) >= (UINTN)ARM_TRUSTZONE_##Region##_SMC_ID_START) && ((UINTN)(Rx) <= (UINTN)ARM_TRUSTZONE_##Region##_SMC_ID_END))
#define IS_ARM_TRUSTZONE_DEPRECIATED_SMC(Rx) ((UINTN)(Rx) <= (UINTN)ARM_TRUSTZONE_DEPRECIATED_SMC_ID_END)
diff --git a/ArmPkg/Include/Library/ArmLib.h b/ArmPkg/Include/Library/ArmLib.h
index b12be1424e..5663844b1f 100644
--- a/ArmPkg/Include/Library/ArmLib.h
+++ b/ArmPkg/Include/Library/ArmLib.h
@@ -112,11 +112,11 @@ typedef enum {
//
// ARM MP Core IDs
//
-#define IS_PRIMARY_CORE(MpId) (((MpId) & PcdGet32(PcdArmPrimaryCoreMask)) == PcdGet32(PcdArmPrimaryCore))
#define ARM_CORE_MASK 0xFF
#define ARM_CLUSTER_MASK (0xFF << 8)
#define GET_CORE_ID(MpId) ((MpId) & ARM_CORE_MASK)
#define GET_CLUSTER_ID(MpId) (((MpId) & ARM_CLUSTER_MASK) >> 8)
+#define GET_MPID(ClusterId, CoreId) (((ClusterId) << 8) | (CoreId))
// Get the position of the core for the Stack Offset (4 Core per Cluster)
// Position = (ClusterId * 4) + CoreId
#define GET_CORE_POS(MpId) ((((MpId) & ARM_CLUSTER_MASK) >> 6) + ((MpId) & ARM_CORE_MASK))
diff --git a/ArmPkg/Library/BdsLib/BdsLib.inf b/ArmPkg/Library/BdsLib/BdsLib.inf
index ccca39ab91..b6712a4fe2 100644
--- a/ArmPkg/Library/BdsLib/BdsLib.inf
+++ b/ArmPkg/Library/BdsLib/BdsLib.inf
@@ -76,7 +76,7 @@
gArmTokenSpaceGuid.PcdArmMachineType
gArmTokenSpaceGuid.PcdArmLinuxFdtMaxOffset
- gArmTokenSpaceGuid.PcdArmLinuxKernelFixedOffset
+ gArmTokenSpaceGuid.PcdArmLinuxFdtAlignment
gArmTokenSpaceGuid.PcdArmLinuxKernelMaxOffset
gArmTokenSpaceGuid.PcdArmLinuxAtagMaxOffset
diff --git a/ArmPkg/Library/BdsLib/BdsLinuxFdt.c b/ArmPkg/Library/BdsLib/BdsLinuxFdt.c
index b5dd237136..4ff0afeb7d 100644
--- a/ArmPkg/Library/BdsLib/BdsLinuxFdt.c
+++ b/ArmPkg/Library/BdsLib/BdsLinuxFdt.c
@@ -25,6 +25,22 @@
#define PALIGN(p, a) ((void *)(ALIGN((unsigned long)(p), (a))))
#define GET_CELL(p) (p += 4, *((const UINT32 *)(p-4)))
+STATIC inline
+UINTN
+cpu_to_fdtn (UINTN x) {
+ if (sizeof (UINTN) == sizeof (UINT32)) {
+ return cpu_to_fdt32 (x);
+ } else {
+ return cpu_to_fdt64 (x);
+ }
+}
+
+typedef struct {
+ UINTN Base;
+ UINTN Size;
+} FdtRegion;
+
+
STATIC
UINTN
IsPrintableString (
@@ -198,10 +214,110 @@ IsLinuxReservedRegion (
}
-typedef struct {
- UINTN Base;
- UINTN Size;
-} FdtRegion;
+STATIC
+BOOLEAN
+IsPsciSmcSupported (
+ VOID
+ )
+{
+ BOOLEAN PsciSmcSupported;
+ UINTN Rx;
+
+ PsciSmcSupported = FALSE;
+
+ // Check the SMC response to the Presence SMC
+ Rx = ARM_SMC_ID_PRESENCE;
+ ArmCallSmc (&Rx);
+ if (Rx == 1) {
+ // Check the SMC UID
+ Rx = ARM_SMC_ID_UID;
+ ArmCallSmc (&Rx);
+ if (Rx == ARM_TRUSTZONE_UID_4LETTERID) {
+ Rx = ARM_SMC_ID_UID + 1;
+ ArmCallSmc (&Rx);
+ if (Rx == ARM_TRUSTZONE_ARM_UID) {
+ PsciSmcSupported = TRUE;
+ }
+ }
+ }
+
+ return PsciSmcSupported;
+}
+
+
+/**
+** Relocate the FDT blob to a more appropriate location for the Linux kernel.
+** This function will allocate memory for the relocated FDT blob.
+**
+** @retval EFI_SUCCESS on success.
+** @retval EFI_OUT_OF_RESOURCES or EFI_INVALID_PARAMETER on failure.
+*/
+STATIC
+EFI_STATUS
+RelocateFdt (
+ EFI_PHYSICAL_ADDRESS OriginalFdt,
+ UINTN OriginalFdtSize,
+ EFI_PHYSICAL_ADDRESS *RelocatedFdt,
+ UINTN *RelocatedFdtSize,
+ EFI_PHYSICAL_ADDRESS *RelocatedFdtAlloc
+ )
+{
+ EFI_STATUS Status;
+ INTN Error;
+ UINT32 FdtAlignment;
+
+ *RelocatedFdtSize = OriginalFdtSize + FDT_ADDITIONAL_ENTRIES_SIZE;
+
+ // If FDT load address needs to be aligned, allocate more space.
+ FdtAlignment = PcdGet32 (PcdArmLinuxFdtAlignment);
+ if (FdtAlignment != 0) {
+ *RelocatedFdtSize += FdtAlignment;
+ }
+
+ // Try below a watermark address.
+ Status = EFI_NOT_FOUND;
+ if (PcdGet32 (PcdArmLinuxFdtMaxOffset) != 0) {
+ *RelocatedFdt = LINUX_FDT_MAX_OFFSET;
+ Status = gBS->AllocatePages (AllocateMaxAddress, EfiBootServicesData,
+ EFI_SIZE_TO_PAGES (*RelocatedFdtSize), RelocatedFdt);
+ if (EFI_ERROR (Status)) {
+ DEBUG ((EFI_D_WARN, "Warning: Failed to load FDT below address 0x%lX (%r). Will try again at a random address anywhere.\n", *RelocatedFdt, Status));
+ }
+ }
+
+ // Try anywhere there is available space.
+ if (EFI_ERROR (Status)) {
+ Status = gBS->AllocatePages (AllocateAnyPages, EfiBootServicesData,
+ EFI_SIZE_TO_PAGES (*RelocatedFdtSize), RelocatedFdt);
+ if (EFI_ERROR (Status)) {
+ ASSERT_EFI_ERROR (Status);
+ return EFI_OUT_OF_RESOURCES;
+ } else {
+ DEBUG ((EFI_D_WARN, "WARNING: Loaded FDT at random address 0x%lX.\nWARNING: There is a risk of accidental overwriting by other code/data.\n", *RelocatedFdt));
+ }
+ }
+
+ *RelocatedFdtAlloc = *RelocatedFdt;
+ if (FdtAlignment != 0) {
+ *RelocatedFdt = ALIGN (*RelocatedFdt, FdtAlignment);
+ }
+
+ // Load the Original FDT tree into the new region
+ Error = fdt_open_into ((VOID*)(UINTN) OriginalFdt,
+ (VOID*)(UINTN)(*RelocatedFdt), *RelocatedFdtSize);
+ if (Error) {
+ DEBUG ((EFI_D_ERROR, "fdt_open_into(): %a\n", fdt_strerror (Error)));
+ gBS->FreePages (*RelocatedFdtAlloc, EFI_SIZE_TO_PAGES (*RelocatedFdtSize));
+ return EFI_INVALID_PARAMETER;
+ }
+
+ DEBUG_CODE_BEGIN();
+ //DebugDumpFdt (fdt);
+ DEBUG_CODE_END();
+
+ return EFI_SUCCESS;
+}
+
EFI_STATUS
PrepareFdt (
@@ -214,6 +330,7 @@ PrepareFdt (
{
EFI_STATUS Status;
EFI_PHYSICAL_ADDRESS NewFdtBlobBase;
+ EFI_PHYSICAL_ADDRESS NewFdtBlobAllocation;
UINTN NewFdtBlobSize;
VOID* fdt;
INTN err;
@@ -242,35 +359,12 @@ PrepareFdt (
UINT32 DescriptorVersion;
UINTN Pages;
BOOLEAN PsciSmcSupported;
- UINTN Rx;
UINTN OriginalFdtSize;
+ BOOLEAN CpusNodeExist;
+ UINTN CoreMpId;
+ UINTN Smc;
- //
- // Ensure the Power State Coordination Interface (PSCI) SMCs are there if supported
- //
- PsciSmcSupported = FALSE;
- if (FeaturePcdGet (PcdArmPsciSupport) == TRUE) {
- // Check the SMC response to the Presence SMC
- Rx = ARM_SMC_ID_PRESENCE;
- ArmCallSmc (&Rx);
- if (Rx == 1) {
- // Check the SMC UID
- Rx = ARM_SMC_ID_UID;
- ArmCallSmc (&Rx);
- if (Rx == ARM_TRUSTZONE_UID_4LETTERID) {
- Rx = ARM_SMC_ID_UID + 1;
- ArmCallSmc (&Rx);
- //TODO: Replace ARM magic number
- if (Rx == 0x40524d48) {
- PsciSmcSupported = TRUE;
- }
- }
- if (PsciSmcSupported == FALSE) {
- DEBUG((EFI_D_ERROR,"Warning: The Power State Coordination Interface (PSCI) is not supported"
- "by your platform Trusted Firmware.\n"));
- }
- }
- }
+ NewFdtBlobAllocation = 0;
//
// Sanity checks on the original FDT blob.
@@ -291,52 +385,35 @@ PrepareFdt (
}
//
- // Allocate memory for the new FDT
+ // Relocate the FDT to its final location.
//
- NewFdtBlobSize = OriginalFdtSize + FDT_ADDITIONAL_ENTRIES_SIZE;
-
- // Try below a watermark address
- Status = EFI_NOT_FOUND;
- if (PcdGet32(PcdArmLinuxFdtMaxOffset) != 0) {
- NewFdtBlobBase = LINUX_FDT_MAX_OFFSET;
- Status = gBS->AllocatePages (AllocateMaxAddress, EfiBootServicesData, EFI_SIZE_TO_PAGES(NewFdtBlobSize), &NewFdtBlobBase);
- if (EFI_ERROR(Status)) {
- DEBUG ((EFI_D_WARN, "Warning: Failed to load FDT below address 0x%lX (%r). Will try again at a random address anywhere.\n", NewFdtBlobBase, Status));
- }
+ Status = RelocateFdt (*FdtBlobBase, OriginalFdtSize,
+ &NewFdtBlobBase, &NewFdtBlobSize, &NewFdtBlobAllocation);
+ if (EFI_ERROR (Status)) {
+ goto FAIL_RELOCATE_FDT;
}
- // Try anywhere there is available space
- if (EFI_ERROR(Status)) {
- Status = gBS->AllocatePages (AllocateAnyPages, EfiBootServicesData, EFI_SIZE_TO_PAGES(NewFdtBlobSize), &NewFdtBlobBase);
- if (EFI_ERROR(Status)) {
- ASSERT_EFI_ERROR(Status);
- goto FAIL_ALLOCATE_NEW_FDT;
- } else {
- DEBUG ((EFI_D_WARN, "WARNING: Loaded FDT at random address 0x%lX.\nWARNING: There is a risk of accidental overwriting by other code/data.\n", NewFdtBlobBase));
+ //
+ // Ensure the Power State Coordination Interface (PSCI) SMCs are there if supported
+ //
+ PsciSmcSupported = FALSE;
+ if (FeaturePcdGet (PcdArmPsciSupport) == TRUE) {
+ PsciSmcSupported = IsPsciSmcSupported();
+ if (PsciSmcSupported == FALSE) {
+ DEBUG ((EFI_D_ERROR, "Warning: The Power State Coordination Interface (PSCI) is not supported by your platform Trusted Firmware.\n"));
}
}
- // Load the Original FDT tree into the new region
fdt = (VOID*)(UINTN)NewFdtBlobBase;
- err = fdt_open_into((VOID*)(UINTN)(*FdtBlobBase), fdt, NewFdtBlobSize);
- if (err) {
- DEBUG((EFI_D_ERROR, "fdt_open_into(): %a\n", fdt_strerror(err)));
- Status = EFI_INVALID_PARAMETER;
- goto FAIL_NEW_FDT;
- }
-
- DEBUG_CODE_BEGIN();
- //DebugDumpFdt (fdt);
- DEBUG_CODE_END();
- node = fdt_subnode_offset(fdt, 0, "chosen");
+ node = fdt_subnode_offset (fdt, 0, "chosen");
if (node < 0) {
// The 'chosen' node does not exist, create it
node = fdt_add_subnode(fdt, 0, "chosen");
if (node < 0) {
DEBUG((EFI_D_ERROR,"Error on finding 'chosen' node\n"));
Status = EFI_INVALID_PARAMETER;
- goto FAIL_NEW_FDT;
+ goto FAIL_COMPLETE_FDT;
}
}
@@ -387,13 +464,8 @@ PrepareFdt (
GetSystemMemoryResources (&ResourceList);
Resource = (BDS_SYSTEM_MEMORY_RESOURCE*)ResourceList.ForwardLink;
- if (sizeof(UINTN) == sizeof(UINT32)) {
- Region.Base = cpu_to_fdt32((UINTN)Resource->PhysicalStart);
- Region.Size = cpu_to_fdt32((UINTN)Resource->ResourceLength);
- } else {
- Region.Base = cpu_to_fdt64((UINTN)Resource->PhysicalStart);
- Region.Size = cpu_to_fdt64((UINTN)Resource->ResourceLength);
- }
+ Region.Base = cpu_to_fdtn ((UINTN)Resource->PhysicalStart);
+ Region.Size = cpu_to_fdtn ((UINTN)Resource->ResourceLength);
err = fdt_setprop(fdt, node, "reg", &Region, sizeof(Region));
if (err) {
@@ -433,7 +505,11 @@ PrepareFdt (
}
//
- // Setup Arm Mpcore Info if it is a multi-core or multi-cluster platforms
+ // Setup Arm Mpcore Info if it is a multi-core or multi-cluster platforms.
+ //
+ // For 'cpus' and 'cpu' device tree nodes bindings, refer to this file
+ // in the kernel documentation:
+ // Documentation/devicetree/bindings/arm/cpus.txt
//
for (Index=0; Index < gST->NumberOfTableEntries; Index++) {
// Check for correct GUID type
@@ -447,8 +523,11 @@ PrepareFdt (
// Create the /cpus node
node = fdt_add_subnode(fdt, 0, "cpus");
fdt_setprop_string(fdt, node, "name", "cpus");
- fdt_setprop_cell(fdt, node, "#address-cells", 1);
+ fdt_setprop_cell (fdt, node, "#address-cells", sizeof (UINTN) / 4);
fdt_setprop_cell(fdt, node, "#size-cells", 0);
+ CpusNodeExist = FALSE;
+ } else {
+ CpusNodeExist = TRUE;
}
// Get pointer to ARM processor table
@@ -457,16 +536,33 @@ PrepareFdt (
for (Index = 0; Index < ArmProcessorTable->NumberOfEntries; Index++) {
AsciiSPrint (Name, 10, "cpu@%d", Index);
- cpu_node = fdt_subnode_offset(fdt, node, Name);
- if (cpu_node < 0) {
- cpu_node = fdt_add_subnode(fdt, node, Name);
- fdt_setprop_string(fdt, cpu_node, "device-type", "cpu");
- fdt_setprop(fdt, cpu_node, "reg", &Index, sizeof(Index));
+
+ // If the 'cpus' node did not exist then create all the 'cpu' nodes.
+ // In case 'cpus' node is provided in the original FDT then we do not add
+ // any 'cpu' node.
+ if (!CpusNodeExist) {
+ cpu_node = fdt_add_subnode (fdt, node, Name);
+ if (cpu_node < 0) {
+ DEBUG ((EFI_D_ERROR, "Error on creating '%s' node\n", Name));
+ Status = EFI_INVALID_PARAMETER;
+ goto FAIL_COMPLETE_FDT;
+ }
+
+ fdt_setprop_string (fdt, cpu_node, "device_type", "cpu");
+ CoreMpId = (UINTN) GET_MPID (ArmCoreInfoTable[Index].ClusterId,
+ ArmCoreInfoTable[Index].CoreId);
+ CoreMpId = cpu_to_fdtn (CoreMpId);
+ fdt_setprop (fdt, cpu_node, "reg", &CoreMpId, sizeof (CoreMpId));
+ if (PsciSmcSupported) {
+ fdt_setprop_string (fdt, cpu_node, "enable-method", "psci");
+ }
+ } else {
+ cpu_node = fdt_subnode_offset(fdt, node, Name);
}
// If Power State Coordination Interface (PSCI) is not supported then it is expected the secondary
// cores are spinning waiting for the Operating System to release them
- if (PsciSmcSupported == FALSE) {
+ if ((PsciSmcSupported == FALSE) && (cpu_node >= 0)) {
// We as the bootloader are responsible for either creating or updating
// these entries. Do not trust the entries in the DT. We only know about
// 'spin-table' type. Do not try to update other types if defined.
@@ -499,14 +595,22 @@ PrepareFdt (
if (node < 0) {
DEBUG((EFI_D_ERROR,"Error on creating 'psci' node\n"));
Status = EFI_INVALID_PARAMETER;
- goto FAIL_NEW_FDT;
+ goto FAIL_COMPLETE_FDT;
} else {
- fdt_setprop_string(fdt, node, "compatible", "arm,psci");
- fdt_setprop_string(fdt, node, "method", "smc");
- fdt_setprop_cell(fdt, node, "cpu_suspend", ARM_SMC_ARM_CPU_SUSPEND);
- fdt_setprop_cell(fdt, node, "cpu_off", ARM_SMC_ARM_CPU_OFF);
- fdt_setprop_cell(fdt, node, "cpu_on", ARM_SMC_ARM_CPU_ON);
- fdt_setprop_cell(fdt, node, "cpu_migrate", ARM_SMC_ARM_MIGRATE);
+ fdt_setprop_string (fdt, node, "compatible", "arm,psci");
+ fdt_setprop_string (fdt, node, "method", "smc");
+
+ Smc = cpu_to_fdtn (ARM_SMC_ARM_CPU_SUSPEND);
+ fdt_setprop (fdt, node, "cpu_suspend", &Smc, sizeof (Smc));
+
+ Smc = cpu_to_fdtn (ARM_SMC_ARM_CPU_OFF);
+ fdt_setprop (fdt, node, "cpu_off", &Smc, sizeof (Smc));
+
+ Smc = cpu_to_fdtn (ARM_SMC_ARM_CPU_ON);
+ fdt_setprop (fdt, node, "cpu_on", &Smc, sizeof (Smc));
+
+ Smc = cpu_to_fdtn (ARM_SMC_ARM_MIGRATE);
+ fdt_setprop (fdt, node, "migrate", &Smc, sizeof (Smc));
}
}
}
@@ -522,13 +626,12 @@ PrepareFdt (
*FdtBlobSize = (UINTN)fdt_totalsize ((VOID*)(UINTN)(NewFdtBlobBase));
return EFI_SUCCESS;
-FAIL_NEW_FDT:
- gBS->FreePages (NewFdtBlobBase, EFI_SIZE_TO_PAGES (NewFdtBlobSize));
+FAIL_COMPLETE_FDT:
+ gBS->FreePages (NewFdtBlobAllocation, EFI_SIZE_TO_PAGES (NewFdtBlobSize));
-FAIL_ALLOCATE_NEW_FDT:
+FAIL_RELOCATE_FDT:
*FdtBlobSize = (UINTN)fdt_totalsize ((VOID*)(UINTN)(*FdtBlobBase));
- // Return success even if we failed to update the FDT blob. The original one is still valid.
+ // Return success even if we failed to update the FDT blob.
+ // The original one is still valid.
return EFI_SUCCESS;
}
-
-
diff --git a/ArmPlatformPkg/ArmRealViewEbPkg/ArmRealViewEb-RTSM-A8.dsc b/ArmPlatformPkg/ArmRealViewEbPkg/ArmRealViewEb-RTSM-A8.dsc
index c43b885758..0b262d3990 100644
--- a/ArmPlatformPkg/ArmRealViewEbPkg/ArmRealViewEb-RTSM-A8.dsc
+++ b/ArmPlatformPkg/ArmRealViewEbPkg/ArmRealViewEb-RTSM-A8.dsc
@@ -128,11 +128,6 @@
gArmTokenSpaceGuid.PcdGicDistributorBase|0x10041000
gArmTokenSpaceGuid.PcdGicInterruptInterfaceBase|0x10040000
- #
- # ARM L2x0 PCDs
- #
- gArmTokenSpaceGuid.PcdL2x0ControllerBase|0x1F002000
-
################################################################################
#
diff --git a/ArmPlatformPkg/ArmRealViewEbPkg/Library/ArmRealViewEbLibRTSM/ArmRealViewEb.c b/ArmPlatformPkg/ArmRealViewEbPkg/Library/ArmRealViewEbLibRTSM/ArmRealViewEb.c
index 77d48acce1..8351b43d80 100644
--- a/ArmPlatformPkg/ArmRealViewEbPkg/Library/ArmRealViewEbLibRTSM/ArmRealViewEb.c
+++ b/ArmPlatformPkg/ArmRealViewEbPkg/Library/ArmRealViewEbLibRTSM/ArmRealViewEb.c
@@ -74,7 +74,7 @@ ArmPlatformInitialize (
IN UINTN MpId
)
{
- if (!IS_PRIMARY_CORE(MpId)) {
+ if (!ArmPlatformIsPrimaryCore (MpId)) {
return RETURN_SUCCESS;
}
diff --git a/ArmPlatformPkg/ArmRealViewEbPkg/Library/ArmRealViewEbLibRTSM/ArmRealViewEbHelper.S b/ArmPlatformPkg/ArmRealViewEbPkg/Library/ArmRealViewEbLibRTSM/ArmRealViewEbHelper.S
new file mode 100644
index 0000000000..3baad66431
--- /dev/null
+++ b/ArmPlatformPkg/ArmRealViewEbPkg/Library/ArmRealViewEbLibRTSM/ArmRealViewEbHelper.S
@@ -0,0 +1,53 @@
+//
+// Copyright (c) 2012-2013, ARM Limited. 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.
+//
+//
+
+#include <AsmMacroIoLib.h>
+#include <Library/ArmLib.h>
+
+.text
+.align 2
+
+GCC_ASM_EXPORT(ArmPlatformPeiBootAction)
+GCC_ASM_EXPORT(ArmPlatformGetCorePosition)
+GCC_ASM_EXPORT(ArmPlatformIsPrimaryCore)
+
+GCC_ASM_IMPORT(_gPcd_FixedAtBuild_PcdArmPrimaryCore)
+GCC_ASM_IMPORT(_gPcd_FixedAtBuild_PcdArmPrimaryCoreMask)
+
+//UINTN
+//ArmPlatformGetCorePosition (
+// IN UINTN MpId
+// );
+ASM_PFX(ArmPlatformGetCorePosition):
+ and r1, r0, #ARM_CORE_MASK
+ and r0, r0, #ARM_CLUSTER_MASK
+ add r0, r1, r0, LSR #7
+ bx lr
+
+//UINTN
+//ArmPlatformIsPrimaryCore (
+// IN UINTN MpId
+// );
+ASM_PFX(ArmPlatformIsPrimaryCore):
+ LoadConstantToReg (_gPcd_FixedAtBuild_PcdArmPrimaryCoreMask, r1)
+ ldr r1, [r1]
+ and r0, r0, r1
+ LoadConstantToReg (_gPcd_FixedAtBuild_PcdArmPrimaryCore, r1)
+ ldr r1, [r1]
+ cmp r0, r1
+ moveq r0, #1
+ movne r0, #0
+ bx lr
+
+ASM_PFX(ArmPlatformPeiBootAction):
+ bx lr
diff --git a/ArmPlatformPkg/ArmRealViewEbPkg/Library/ArmRealViewEbLibRTSM/ArmRealViewEbHelper.asm b/ArmPlatformPkg/ArmRealViewEbPkg/Library/ArmRealViewEbLibRTSM/ArmRealViewEbHelper.asm
new file mode 100644
index 0000000000..55b211ea12
--- /dev/null
+++ b/ArmPlatformPkg/ArmRealViewEbPkg/Library/ArmRealViewEbLibRTSM/ArmRealViewEbHelper.asm
@@ -0,0 +1,59 @@
+//
+// Copyright (c) 2012-2013, ARM Limited. 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.
+//
+//
+
+#include <AsmMacroIoLib.h>
+#include <Library/ArmLib.h>
+
+ INCLUDE AsmMacroIoLib.inc
+
+ EXPORT ArmPlatformPeiBootAction
+ EXPORT ArmPlatformGetCorePosition
+ EXPORT ArmPlatformIsPrimaryCore
+
+ IMPORT _gPcd_FixedAtBuild_PcdArmPrimaryCore
+ IMPORT _gPcd_FixedAtBuild_PcdArmPrimaryCoreMask
+
+ AREA ArmRealViewEbHelper, CODE, READONLY
+
+//UINTN
+//ArmPlatformGetCorePosition (
+// IN UINTN MpId
+// );
+ArmPlatformGetCorePosition FUNCTION
+ and r1, r0, #ARM_CORE_MASK
+ and r0, r0, #ARM_CLUSTER_MASK
+ add r0, r1, r0, LSR #7
+ bx lr
+ ENDFUNC
+
+//UINTN
+//ArmPlatformIsPrimaryCore (
+// IN UINTN MpId
+// );
+ArmPlatformIsPrimaryCore FUNCTION
+ LoadConstantToReg (_gPcd_FixedAtBuild_PcdArmPrimaryCoreMask, r1)
+ ldr r1, [r1]
+ and r0, r0, r1
+ LoadConstantToReg (_gPcd_FixedAtBuild_PcdArmPrimaryCore, r1)
+ ldr r1, [r1]
+ cmp r0, r1
+ moveq r0, #1
+ movne r0, #0
+ bx lr
+ ENDFUNC
+
+ArmPlatformPeiBootAction FUNCTION
+ bx lr
+ ENDFUNC
+
+ END
diff --git a/ArmPlatformPkg/ArmRealViewEbPkg/Library/ArmRealViewEbLibRTSM/ArmRealViewEbLib.inf b/ArmPlatformPkg/ArmRealViewEbPkg/Library/ArmRealViewEbLibRTSM/ArmRealViewEbLib.inf
index 6c45d35d80..a97ee41c4a 100644
--- a/ArmPlatformPkg/ArmRealViewEbPkg/Library/ArmRealViewEbLibRTSM/ArmRealViewEbLib.inf
+++ b/ArmPlatformPkg/ArmRealViewEbPkg/Library/ArmRealViewEbLibRTSM/ArmRealViewEbLib.inf
@@ -1,5 +1,5 @@
#/* @file
-# Copyright (c) 2011-2012, ARM Limited. All rights reserved.
+# Copyright (c) 2011-2013, ARM Limited. All rights reserved.
#
# This program and the accompanying materials
# are licensed and made available under the terms and conditions of the BSD License
@@ -32,8 +32,12 @@
MemoryAllocationLib
[Sources.common]
+ ArmRealViewEbHelper.asm | RVCT
+ ArmRealViewEbHelper.S | GCC
ArmRealViewEb.c
ArmRealViewEbMem.c
+ ArmRealViewEbHelper.asm | RVCT
+ ArmRealViewEbHelper.S | GCC
[FeaturePcd]
gEmbeddedTokenSpaceGuid.PcdCacheEnable
diff --git a/ArmPlatformPkg/ArmRealViewEbPkg/Library/ArmRealViewEbLibRTSM/ArmRealViewEbLibSec.inf b/ArmPlatformPkg/ArmRealViewEbPkg/Library/ArmRealViewEbLibRTSM/ArmRealViewEbLibSec.inf
index 652211d991..9be6a3755d 100644
--- a/ArmPlatformPkg/ArmRealViewEbPkg/Library/ArmRealViewEbLibRTSM/ArmRealViewEbLibSec.inf
+++ b/ArmPlatformPkg/ArmRealViewEbPkg/Library/ArmRealViewEbLibRTSM/ArmRealViewEbLibSec.inf
@@ -32,6 +32,8 @@
[Sources.common]
ArmRealViewEb.c
+ ArmRealViewEbHelper.asm | RVCT
+ ArmRealViewEbHelper.S | GCC
[FeaturePcd]
gEmbeddedTokenSpaceGuid.PcdCacheEnable
diff --git a/ArmPlatformPkg/ArmRealViewEbPkg/Library/ArmRealViewEbLibRTSM/ArmRealViewEbMem.c b/ArmPlatformPkg/ArmRealViewEbPkg/Library/ArmRealViewEbLibRTSM/ArmRealViewEbMem.c
index d1a55a8360..c7a413dc2e 100644
--- a/ArmPlatformPkg/ArmRealViewEbPkg/Library/ArmRealViewEbLibRTSM/ArmRealViewEbMem.c
+++ b/ArmPlatformPkg/ArmRealViewEbPkg/Library/ArmRealViewEbLibRTSM/ArmRealViewEbMem.c
@@ -114,21 +114,3 @@ ArmPlatformGetVirtualMemoryMap (
*VirtualMemoryMap = VirtualMemoryTable;
}
-
-/**
- Return the EFI Memory Map of your platform
-
- This EFI Memory Map of the System Memory is used by MemoryInitPei module to create the Resource
- Descriptor HOBs used by DXE core.
-
- @param[out] EfiMemoryMap Array of ARM_SYSTEM_MEMORY_REGION_DESCRIPTOR describing an
- EFI Memory region. This array must be ended by a zero-filled entry
-
-**/
-EFI_STATUS
-ArmPlatformGetAdditionalSystemMemory (
- OUT ARM_SYSTEM_MEMORY_REGION_DESCRIPTOR** EfiMemoryMap
- )
-{
- return EFI_UNSUPPORTED;
-}
diff --git a/ArmPlatformPkg/ArmRealViewEbPkg/Library/ArmRealViewEbSecLibRTSM/ArmRealViewEbSec.c b/ArmPlatformPkg/ArmRealViewEbPkg/Library/ArmRealViewEbSecLibRTSM/ArmRealViewEbSec.c
index 033c9d7ea0..1d3233ec4a 100644
--- a/ArmPlatformPkg/ArmRealViewEbPkg/Library/ArmRealViewEbSecLibRTSM/ArmRealViewEbSec.c
+++ b/ArmPlatformPkg/ArmRealViewEbPkg/Library/ArmRealViewEbSecLibRTSM/ArmRealViewEbSec.c
@@ -14,6 +14,7 @@
#include <Library/IoLib.h>
#include <Library/ArmLib.h>
+#include <Library/ArmPlatformLib.h>
#include <Library/ArmPlatformSecLib.h>
#include <Library/DebugLib.h>
#include <Library/PcdLib.h>
@@ -51,7 +52,7 @@ ArmPlatformSecInitialize (
)
{
// If it is not the primary core then there is nothing to do
- if (!IS_PRIMARY_CORE(MpId)) {
+ if (!ArmPlatformIsPrimaryCore (MpId)) {
return RETURN_SUCCESS;
}
diff --git a/ArmPlatformPkg/ArmRealViewEbPkg/Library/ArmRealViewEbSecLibRTSM/ArmRealViewEbSecLib.inf b/ArmPlatformPkg/ArmRealViewEbPkg/Library/ArmRealViewEbSecLibRTSM/ArmRealViewEbSecLib.inf
index b6971bc768..d4e383aceb 100644
--- a/ArmPlatformPkg/ArmRealViewEbPkg/Library/ArmRealViewEbSecLibRTSM/ArmRealViewEbSecLib.inf
+++ b/ArmPlatformPkg/ArmRealViewEbPkg/Library/ArmRealViewEbSecLibRTSM/ArmRealViewEbSecLib.inf
@@ -29,6 +29,7 @@
[LibraryClasses]
IoLib
ArmLib
+ ArmPlatformLib
[Sources.common]
ArmRealViewEbSec.c
@@ -41,5 +42,3 @@
[FixedPcd]
gArmTokenSpaceGuid.PcdFvBaseAddress
- gArmTokenSpaceGuid.PcdArmPrimaryCoreMask
- gArmTokenSpaceGuid.PcdArmPrimaryCore
diff --git a/ArmPlatformPkg/ArmVExpressPkg/ArmVExpress-CTA15-A7.dsc b/ArmPlatformPkg/ArmVExpressPkg/ArmVExpress-CTA15-A7.dsc
index 4b0666f3d9..f66f6671dc 100644
--- a/ArmPlatformPkg/ArmVExpressPkg/ArmVExpress-CTA15-A7.dsc
+++ b/ArmPlatformPkg/ArmVExpressPkg/ArmVExpress-CTA15-A7.dsc
@@ -127,8 +127,8 @@
# A7_0 = 0x100, GicCoreId = 2
# A7_1 = 0x101, GicCoreId = 3
# A7_2 = 0x102, GicCoreId = 4
- gArmTokenSpaceGuid.PcdArmPrimaryCore|0x100
- gArmTokenSpaceGuid.PcdGicPrimaryCoreId|0x100
+ gArmTokenSpaceGuid.PcdArmPrimaryCore|0x100
+ gArmTokenSpaceGuid.PcdGicPrimaryCoreId|2
!endif
#
@@ -184,7 +184,7 @@
gArmPlatformTokenSpaceGuid.PcdDefaultBootDevicePath|L"VenHw(09831032-6FA3-4484-AF4F-0A000A8D3A82)/HD(1,MBR,0x00000000,0x3F,0x19FC0)/uImage"
gArmPlatformTokenSpaceGuid.PcdDefaultBootInitrdPath|L"VenHw(09831032-6FA3-4484-AF4F-0A000A8D3A82)/HD(1,MBR,0x00000000,0x3F,0x19FC0)/uInitrd"
gArmPlatformTokenSpaceGuid.PcdDefaultFdtLocalDevicePath|L"VenHw(09831032-6FA3-4484-AF4F-0A000A8D3A82)/HD(1,MBR,0x00000000,0x3F,0x19FC0)/v2p-ca15-tc2.dtb"
- gArmPlatformTokenSpaceGuid.PcdDefaultBootArgument|"console=tty0 console=ttyAMA0,38400n8 root=/dev/mmcblk0p2 rootwait ro androidboot.console=ttyAMA0 mmci.fmax=12000000"
+ gArmPlatformTokenSpaceGuid.PcdDefaultBootArgument|"console=ttyAMA0,38400n8 root=/dev/mmcblk0p2 rootwait ro androidboot.console=ttyAMA0 mmci.fmax=12000000"
gArmPlatformTokenSpaceGuid.PcdDefaultBootType|3
gArmPlatformTokenSpaceGuid.PcdFdtDevicePath|L"VenHw(09831032-6FA3-4484-AF4F-0A000A8D3A82)/HD(1,MBR,0x00000000,0x3F,0x19FC0)/v2p-ca15-tc2.dtb"
diff --git a/ArmPlatformPkg/ArmVExpressPkg/ArmVExpress-CTA15x2.dsc b/ArmPlatformPkg/ArmVExpressPkg/ArmVExpress-CTA15x2.dsc
index 0feee1f8e5..37765e9297 100644
--- a/ArmPlatformPkg/ArmVExpressPkg/ArmVExpress-CTA15x2.dsc
+++ b/ArmPlatformPkg/ArmVExpressPkg/ArmVExpress-CTA15x2.dsc
@@ -99,6 +99,7 @@
[PcdsFixedAtBuild.common]
gArmPlatformTokenSpaceGuid.PcdFirmwareVendor|"ARM Versatile Express"
gEmbeddedTokenSpaceGuid.PcdEmbeddedPrompt|"ArmVExpress"
+ gArmPlatformTokenSpaceGuid.PcdCoreCount|2
#
# NV Storage PCDs. Use base of 0x00000000 for NOR1
@@ -128,9 +129,6 @@
gArmTokenSpaceGuid.PcdSystemMemoryBase|0x80000000
gArmTokenSpaceGuid.PcdSystemMemorySize|0x40000000
- # Size of the region used by UEFI in permanent memory (Reserved 64MB)
- gArmPlatformTokenSpaceGuid.PcdSystemMemoryUefiRegionSize|0x04000000
-
#
# ARM Pcds
#
@@ -154,9 +152,6 @@
## PL011 - Serial Terminal
gEfiMdeModulePkgTokenSpaceGuid.PcdSerialRegisterBase|0x1c090000
gEfiMdePkgTokenSpaceGuid.PcdUartDefaultBaudRate|38400
- gEfiMdePkgTokenSpaceGuid.PcdUartDefaultDataBits|8
- gEfiMdePkgTokenSpaceGuid.PcdUartDefaultParity|1
- gEfiMdePkgTokenSpaceGuid.PcdUartDefaultStopBits|1
## PL031 RealTimeClock
gArmPlatformTokenSpaceGuid.PcdPL031RtcBase|0x1C170000
@@ -183,7 +178,7 @@
gArmPlatformTokenSpaceGuid.PcdDefaultBootDevicePath|L"VenHw(09831032-6FA3-4484-AF4F-0A000A8D3A82)/HD(1,MBR,0x00000000,0x3F,0x19FC0)/uImage"
gArmPlatformTokenSpaceGuid.PcdDefaultBootInitrdPath|L"VenHw(09831032-6FA3-4484-AF4F-0A000A8D3A82)/HD(1,MBR,0x00000000,0x3F,0x19FC0)/uInitrd"
gArmPlatformTokenSpaceGuid.PcdDefaultFdtLocalDevicePath|L"VenHw(09831032-6FA3-4484-AF4F-0A000A8D3A82)/HD(1,MBR,0x00000000,0x3F,0x19FC0)/v2p-ca15-tc1.dtb"
- gArmPlatformTokenSpaceGuid.PcdDefaultBootArgument|"console=tty0 console=ttyAMA0,38400n8 root=/dev/mmcblk0p2 rootwait ro androidboot.console=ttyAMA0 mmci.fmax=12000000"
+ gArmPlatformTokenSpaceGuid.PcdDefaultBootArgument|"console=ttyAMA0,38400n8 root=/dev/mmcblk0p2 rootwait ro androidboot.console=ttyAMA0 mmci.fmax=12000000"
gArmPlatformTokenSpaceGuid.PcdDefaultBootType|3
gArmPlatformTokenSpaceGuid.PcdFdtDevicePath|L"VenHw(09831032-6FA3-4484-AF4F-0A000A8D3A82)/HD(1,MBR,0x00000000,0x3F,0x19FC0)/v2p-ca15-tc1.dtb"
@@ -288,7 +283,7 @@
ArmPlatformPkg/Drivers/SP805WatchdogDxe/SP805WatchdogDxe.inf
#
- # Semi-hosting filesystem
+ # Filesystems
#
ArmPkg/Filesystem/SemihostFs/SemihostFs.inf
@@ -303,15 +298,9 @@
#
MdeModulePkg/Universal/Disk/DiskIoDxe/DiskIoDxe.inf
MdeModulePkg/Universal/Disk/PartitionDxe/PartitionDxe.inf
- FatPkg/EnhancedFatDxe/Fat.inf
MdeModulePkg/Universal/Disk/UnicodeCollation/EnglishDxe/EnglishDxe.inf
#
- # Application
- #
- EmbeddedPkg/Ebl/Ebl.inf
-
- #
# Bds
#
MdeModulePkg/Universal/DevicePathDxe/DevicePathDxe.inf
diff --git a/ArmPlatformPkg/ArmVExpressPkg/ArmVExpress-CTA15x2.fdf b/ArmPlatformPkg/ArmVExpressPkg/ArmVExpress-CTA15x2.fdf
index 6cd7b17080..c3e5a90756 100644
--- a/ArmPlatformPkg/ArmVExpressPkg/ArmVExpress-CTA15x2.fdf
+++ b/ArmPlatformPkg/ArmVExpressPkg/ArmVExpress-CTA15x2.fdf
@@ -161,7 +161,7 @@ READ_LOCK_STATUS = TRUE
#
INF MdeModulePkg/Universal/Disk/DiskIoDxe/DiskIoDxe.inf
INF MdeModulePkg/Universal/Disk/PartitionDxe/PartitionDxe.inf
- INF FatPkg/EnhancedFatDxe/Fat.inf
+ INF FatBinPkg/EnhancedFatDxe/Fat.inf
INF MdeModulePkg/Universal/Disk/UnicodeCollation/EnglishDxe/EnglishDxe.inf
#
@@ -171,21 +171,16 @@ READ_LOCK_STATUS = TRUE
INF ArmPlatformPkg/Drivers/PL180MciDxe/PL180MciDxe.inf
#
- # UEFI application (Shell Embedded Boot Loader)
+ # UEFI application
#
- INF EmbeddedPkg/Ebl/Ebl.inf
-
-!if $(EDK2_ARMVE_UEFI2_SHELL) == 1
- INF ShellPkg/Application/Shell/Shell.inf
-!endif
-
+ INF ShellBinPkg/UefiShell/UefiShell.inf
+
#
# Bds
#
INF MdeModulePkg/Universal/DevicePathDxe/DevicePathDxe.inf
INF ArmPlatformPkg/Bds/Bds.inf
-
[FV.FVMAIN_COMPACT]
FvAlignment = 8
ERASE_POLARITY = 1
@@ -312,3 +307,18 @@ READ_LOCK_STATUS = TRUE
UI STRING ="$(MODULE_NAME)" Optional
PE32 PE32 $(INF_OUTPUT)/$(MODULE_NAME).efi
}
+
+[Rule.Common.UEFI_DRIVER.BINARY]
+ FILE DRIVER = $(NAMED_GUID) {
+ DXE_DEPEX DXE_DEPEX Optional |.depex
+ PE32 PE32 |.efi
+ UI STRING="$(MODULE_NAME)" Optional
+ VERSION STRING="$(INF_VERSION)" Optional BUILD_NUM=$(BUILD_NUMBER)
+ }
+
+[Rule.Common.UEFI_APPLICATION.BINARY]
+ FILE APPLICATION = $(NAMED_GUID) {
+ PE32 PE32 |.efi
+ UI STRING="$(MODULE_NAME)" Optional
+ VERSION STRING="$(INF_VERSION)" Optional BUILD_NUM=$(BUILD_NUMBER)
+ }
diff --git a/ArmPlatformPkg/ArmVExpressPkg/ArmVExpress-CTA5s.dsc b/ArmPlatformPkg/ArmVExpressPkg/ArmVExpress-CTA5s.dsc
index 03d1d09511..b4ce23451c 100644
--- a/ArmPlatformPkg/ArmVExpressPkg/ArmVExpress-CTA5s.dsc
+++ b/ArmPlatformPkg/ArmVExpressPkg/ArmVExpress-CTA5s.dsc
@@ -99,6 +99,7 @@
[PcdsFixedAtBuild.common]
gArmPlatformTokenSpaceGuid.PcdFirmwareVendor|"ARM Versatile Express"
gEmbeddedTokenSpaceGuid.PcdEmbeddedPrompt|"ArmVExpress"
+ gArmPlatformTokenSpaceGuid.PcdCoreCount|2
#
# NV Storage PCDs. Use base of 0x0C000000 for NOR1
@@ -128,9 +129,6 @@
gArmTokenSpaceGuid.PcdSystemMemoryBase|0x80000000
gArmTokenSpaceGuid.PcdSystemMemorySize|0x40000000
- # Size of the region used by UEFI in permanent memory (Reserved 64MB)
- gArmPlatformTokenSpaceGuid.PcdSystemMemoryUefiRegionSize|0x04000000
-
#
# ARM Pcds
#
@@ -154,9 +152,6 @@
## PL011 - Serial Terminal
gEfiMdeModulePkgTokenSpaceGuid.PcdSerialRegisterBase|0x1c090000
gEfiMdePkgTokenSpaceGuid.PcdUartDefaultBaudRate|38400
- gEfiMdePkgTokenSpaceGuid.PcdUartDefaultDataBits|8
- gEfiMdePkgTokenSpaceGuid.PcdUartDefaultParity|1
- gEfiMdePkgTokenSpaceGuid.PcdUartDefaultStopBits|1
## PL031 RealTimeClock
gArmPlatformTokenSpaceGuid.PcdPL031RtcBase|0x1C170000
@@ -183,7 +178,7 @@
gArmPlatformTokenSpaceGuid.PcdDefaultBootDevicePath|L"VenHw(09831032-6FA3-4484-AF4F-0A000A8D3A82)/HD(1,MBR,0x00000000,0x3F,0x19FC0)/uImage"
gArmPlatformTokenSpaceGuid.PcdDefaultBootInitrdPath|L"VenHw(09831032-6FA3-4484-AF4F-0A000A8D3A82)/HD(1,MBR,0x00000000,0x3F,0x19FC0)/uInitrd"
gArmPlatformTokenSpaceGuid.PcdDefaultFdtLocalDevicePath|L"VenHw(09831032-6FA3-4484-AF4F-0A000A8D3A82)/HD(1,MBR,0x00000000,0x3F,0x19FC0)/v2p-ca5s.dtb"
- gArmPlatformTokenSpaceGuid.PcdDefaultBootArgument|"console=tty0 console=ttyAMA0,38400n8 root=/dev/mmcblk0p2 rootwait ro androidboot.console=ttyAMA0 mmci.fmax=12000000"
+ gArmPlatformTokenSpaceGuid.PcdDefaultBootArgument|"console=ttyAMA0,38400n8 root=/dev/mmcblk0p2 rootwait ro androidboot.console=ttyAMA0 mmci.fmax=12000000"
gArmPlatformTokenSpaceGuid.PcdDefaultBootType|3
gArmPlatformTokenSpaceGuid.PcdFdtDevicePath|L"VenHw(09831032-6FA3-4484-AF4F-0A000A8D3A82)/HD(1,MBR,0x00000000,0x3F,0x19FC0)/v2p-ca5s.dtb"
@@ -282,7 +277,7 @@
ArmPlatformPkg/Drivers/SP805WatchdogDxe/SP805WatchdogDxe.inf
#
- # Semi-hosting filesystem
+ # Filesystems
#
ArmPkg/Filesystem/SemihostFs/SemihostFs.inf
@@ -297,15 +292,9 @@
#
MdeModulePkg/Universal/Disk/DiskIoDxe/DiskIoDxe.inf
MdeModulePkg/Universal/Disk/PartitionDxe/PartitionDxe.inf
- FatPkg/EnhancedFatDxe/Fat.inf
MdeModulePkg/Universal/Disk/UnicodeCollation/EnglishDxe/EnglishDxe.inf
#
- # Application
- #
- EmbeddedPkg/Ebl/Ebl.inf
-
- #
# Bds
#
MdeModulePkg/Universal/DevicePathDxe/DevicePathDxe.inf
diff --git a/ArmPlatformPkg/ArmVExpressPkg/ArmVExpress-CTA5s.fdf b/ArmPlatformPkg/ArmVExpressPkg/ArmVExpress-CTA5s.fdf
index 6cd7b17080..c3e5a90756 100644
--- a/ArmPlatformPkg/ArmVExpressPkg/ArmVExpress-CTA5s.fdf
+++ b/ArmPlatformPkg/ArmVExpressPkg/ArmVExpress-CTA5s.fdf
@@ -161,7 +161,7 @@ READ_LOCK_STATUS = TRUE
#
INF MdeModulePkg/Universal/Disk/DiskIoDxe/DiskIoDxe.inf
INF MdeModulePkg/Universal/Disk/PartitionDxe/PartitionDxe.inf
- INF FatPkg/EnhancedFatDxe/Fat.inf
+ INF FatBinPkg/EnhancedFatDxe/Fat.inf
INF MdeModulePkg/Universal/Disk/UnicodeCollation/EnglishDxe/EnglishDxe.inf
#
@@ -171,21 +171,16 @@ READ_LOCK_STATUS = TRUE
INF ArmPlatformPkg/Drivers/PL180MciDxe/PL180MciDxe.inf
#
- # UEFI application (Shell Embedded Boot Loader)
+ # UEFI application
#
- INF EmbeddedPkg/Ebl/Ebl.inf
-
-!if $(EDK2_ARMVE_UEFI2_SHELL) == 1
- INF ShellPkg/Application/Shell/Shell.inf
-!endif
-
+ INF ShellBinPkg/UefiShell/UefiShell.inf
+
#
# Bds
#
INF MdeModulePkg/Universal/DevicePathDxe/DevicePathDxe.inf
INF ArmPlatformPkg/Bds/Bds.inf
-
[FV.FVMAIN_COMPACT]
FvAlignment = 8
ERASE_POLARITY = 1
@@ -312,3 +307,18 @@ READ_LOCK_STATUS = TRUE
UI STRING ="$(MODULE_NAME)" Optional
PE32 PE32 $(INF_OUTPUT)/$(MODULE_NAME).efi
}
+
+[Rule.Common.UEFI_DRIVER.BINARY]
+ FILE DRIVER = $(NAMED_GUID) {
+ DXE_DEPEX DXE_DEPEX Optional |.depex
+ PE32 PE32 |.efi
+ UI STRING="$(MODULE_NAME)" Optional
+ VERSION STRING="$(INF_VERSION)" Optional BUILD_NUM=$(BUILD_NUMBER)
+ }
+
+[Rule.Common.UEFI_APPLICATION.BINARY]
+ FILE APPLICATION = $(NAMED_GUID) {
+ PE32 PE32 |.efi
+ UI STRING="$(MODULE_NAME)" Optional
+ VERSION STRING="$(INF_VERSION)" Optional BUILD_NUM=$(BUILD_NUMBER)
+ }
diff --git a/ArmPlatformPkg/ArmVExpressPkg/ArmVExpress-CTA9x4.dsc b/ArmPlatformPkg/ArmVExpressPkg/ArmVExpress-CTA9x4.dsc
index 1171e90fad..e7f3afcc7a 100644
--- a/ArmPlatformPkg/ArmVExpressPkg/ArmVExpress-CTA9x4.dsc
+++ b/ArmPlatformPkg/ArmVExpressPkg/ArmVExpress-CTA9x4.dsc
@@ -176,11 +176,12 @@
#
# Versatile Express machine type (ARM VERSATILE EXPRESS = 2272) required for ARM Linux:
gArmTokenSpaceGuid.PcdArmMachineType|2272
- gArmPlatformTokenSpaceGuid.PcdDefaultBootDescription|L"Linaro image on SD card"
+ gArmPlatformTokenSpaceGuid.PcdDefaultBootDescription|L"Linaro image on SD card"
gArmPlatformTokenSpaceGuid.PcdDefaultBootDevicePath|L"VenHw(09831032-6FA3-4484-AF4F-0A000A8D3A82)/HD(1,MBR,0x00000000,0x3F,0x19FC0)/uImage"
gArmPlatformTokenSpaceGuid.PcdDefaultBootInitrdPath|L"VenHw(09831032-6FA3-4484-AF4F-0A000A8D3A82)/HD(1,MBR,0x00000000,0x3F,0x19FC0)/uInitrd"
- gArmPlatformTokenSpaceGuid.PcdDefaultBootArgument|"console=tty0 console=ttyAMA0,38400n8 root=/dev/mmcblk0p2 rootwait ro androidboot.console=ttyAMA0 mmci.fmax=12000000"
- gArmPlatformTokenSpaceGuid.PcdDefaultBootType|1
+ gArmPlatformTokenSpaceGuid.PcdDefaultFdtLocalDevicePath|L"VenHw(09831032-6FA3-4484-AF4F-0A000A8D3A82)/HD(1,MBR,0x00000000,0x3F,0x19FC0)/v2p-ca9.dtb"
+ gArmPlatformTokenSpaceGuid.PcdDefaultBootArgument|"console=ttyAMA0,38400n8 root=/dev/mmcblk0p2 rootwait ro androidboot.console=ttyAMA0 mmci.fmax=12000000"
+ gArmPlatformTokenSpaceGuid.PcdDefaultBootType|3
gArmPlatformTokenSpaceGuid.PcdFdtDevicePath|L"VenHw(09831032-6FA3-4484-AF4F-0A000A8D3A82)/HD(1,MBR,0x00000000,0x3F,0x19FC0)/v2p-ca9.dtb"
# Use the serial console (ConIn & ConOut) and the Graphic driver (ConOut)
diff --git a/ArmPlatformPkg/ArmVExpressPkg/ArmVExpress-RTSM-A15.dsc b/ArmPlatformPkg/ArmVExpressPkg/ArmVExpress-RTSM-A15.dsc
index 09dfe7f542..b515ce6927 100644
--- a/ArmPlatformPkg/ArmVExpressPkg/ArmVExpress-RTSM-A15.dsc
+++ b/ArmPlatformPkg/ArmVExpressPkg/ArmVExpress-RTSM-A15.dsc
@@ -21,7 +21,11 @@
PLATFORM_GUID = 1665b5b1-529d-4ba1-bd51-c3c9b29a2274
PLATFORM_VERSION = 0.1
DSC_SPECIFICATION = 0x00010005
+!ifdef $(EDK2_OUT_DIR)
+ OUTPUT_DIRECTORY = $(EDK2_OUT_DIR)
+!else
OUTPUT_DIRECTORY = Build/ArmVExpress-RTSM-A15
+!endif
SUPPORTED_ARCHITECTURES = ARM
BUILD_TARGETS = DEBUG|RELEASE
SKUID_IDENTIFIER = DEFAULT
@@ -142,21 +146,19 @@
#
# Versatile Express machine type (ARM VERSATILE EXPRESS = 2272) required for ARM Linux:
gArmTokenSpaceGuid.PcdArmMachineType|2272
- gArmPlatformTokenSpaceGuid.PcdDefaultBootDescription|L"SemiHosting"
- gArmPlatformTokenSpaceGuid.PcdDefaultBootDevicePath|L"VenHw(C5B9C74A-6D72-4719-99AB-C59F199091EB)/zImage"
- gArmPlatformTokenSpaceGuid.PcdDefaultBootArgument|""
- gArmPlatformTokenSpaceGuid.PcdDefaultBootType|1
+ gArmPlatformTokenSpaceGuid.PcdDefaultBootDescription|L"Linaro image on SD card"
+ gArmPlatformTokenSpaceGuid.PcdDefaultBootDevicePath|L"VenHw(09831032-6FA3-4484-AF4F-0A000A8D3A82)/HD(1,MBR,0x00000000,0x3F,0x19FC0)/uImage"
+ gArmPlatformTokenSpaceGuid.PcdDefaultBootInitrdPath|L"VenHw(09831032-6FA3-4484-AF4F-0A000A8D3A82)/HD(1,MBR,0x00000000,0x3F,0x19FC0)/uInitrd"
+ gArmPlatformTokenSpaceGuid.PcdDefaultFdtLocalDevicePath|L"VenHw(09831032-6FA3-4484-AF4F-0A000A8D3A82)/HD(1,MBR,0x00000000,0x3F,0x19FC0)/rtsm\\rtsm_ve-ca15x1.dtb"
+ gArmPlatformTokenSpaceGuid.PcdDefaultBootArgument|"console=ttyAMA0,38400n8 root=/dev/mmcblk0p2 rootwait ro androidboot.console=ttyAMA0 mmci.fmax=12000000"
+ gArmPlatformTokenSpaceGuid.PcdDefaultBootType|3
+ gArmPlatformTokenSpaceGuid.PcdFdtDevicePath|L"VenHw(09831032-6FA3-4484-AF4F-0A000A8D3A82)/HD(1,MBR,0x00000000,0x3F,0x19FC0)/rtsm\\rtsm_ve-ca15x1.dtb"
# Use the serial console (ConIn & ConOut) and the Graphic driver (ConOut)
gArmPlatformTokenSpaceGuid.PcdDefaultConOutPaths|L"VenHw(D3987D4B-971A-435F-8CAF-4967EB627241)/Uart(38400,8,N,1)/VenPcAnsi();VenHw(407B4008-BF5B-11DF-9547-CF16E0D72085)"
gArmPlatformTokenSpaceGuid.PcdDefaultConInPaths|L"VenHw(D3987D4B-971A-435F-8CAF-4967EB627241)/Uart(38400,8,N,1)/VenPcAnsi()"
#
- # ARM L2x0 PCDs
- #
- gArmTokenSpaceGuid.PcdL2x0ControllerBase|0x1E00A000
-
- #
# ARM Architectual Timer Frequency
#
gArmTokenSpaceGuid.PcdArmArchTimerFreqInHz|60000000
diff --git a/ArmPlatformPkg/ArmVExpressPkg/ArmVExpress-RTSM-A15_MPCore.dsc b/ArmPlatformPkg/ArmVExpressPkg/ArmVExpress-RTSM-A15_MPCore.dsc
index 7934d1e545..868a5ad4c9 100644
--- a/ArmPlatformPkg/ArmVExpressPkg/ArmVExpress-RTSM-A15_MPCore.dsc
+++ b/ArmPlatformPkg/ArmVExpressPkg/ArmVExpress-RTSM-A15_MPCore.dsc
@@ -1,5 +1,5 @@
#
-# Copyright (c) 2011-2012, ARM Limited. All rights reserved.
+# Copyright (c) 2011-2013, ARM Limited. All rights reserved.
#
# This program and the accompanying materials
# are licensed and made available under the terms and conditions of the BSD License
@@ -21,7 +21,11 @@
PLATFORM_GUID = 3a91a0f8-3af4-409d-a71d-a199dc134357
PLATFORM_VERSION = 0.1
DSC_SPECIFICATION = 0x00010005
+!ifdef $(EDK2_OUT_DIR)
+ OUTPUT_DIRECTORY = $(EDK2_OUT_DIR)
+!else
OUTPUT_DIRECTORY = Build/ArmVExpress-RTSM-A15_MPCore
+!endif
SUPPORTED_ARCHITECTURES = ARM
BUILD_TARGETS = DEBUG|RELEASE
SKUID_IDENTIFIER = DEFAULT
@@ -144,21 +148,19 @@
#
# Versatile Express machine type (ARM VERSATILE EXPRESS = 2272) required for ARM Linux:
gArmTokenSpaceGuid.PcdArmMachineType|2272
- gArmPlatformTokenSpaceGuid.PcdDefaultBootDescription|L"SemiHosting"
- gArmPlatformTokenSpaceGuid.PcdDefaultBootDevicePath|L"VenHw(C5B9C74A-6D72-4719-99AB-C59F199091EB)/zImage"
- gArmPlatformTokenSpaceGuid.PcdDefaultBootArgument|""
- gArmPlatformTokenSpaceGuid.PcdDefaultBootType|1
+ gArmPlatformTokenSpaceGuid.PcdDefaultBootDescription|L"Linaro image on SD card"
+ gArmPlatformTokenSpaceGuid.PcdDefaultBootDevicePath|L"VenHw(09831032-6FA3-4484-AF4F-0A000A8D3A82)/HD(1,MBR,0x00000000,0x3F,0x19FC0)/uImage"
+ gArmPlatformTokenSpaceGuid.PcdDefaultBootInitrdPath|L"VenHw(09831032-6FA3-4484-AF4F-0A000A8D3A82)/HD(1,MBR,0x00000000,0x3F,0x19FC0)/uInitrd"
+ gArmPlatformTokenSpaceGuid.PcdDefaultFdtLocalDevicePath|L"VenHw(09831032-6FA3-4484-AF4F-0A000A8D3A82)/HD(1,MBR,0x00000000,0x3F,0x19FC0)/rtsm\\rtsm_ve-ca15x4.dtb"
+ gArmPlatformTokenSpaceGuid.PcdDefaultBootArgument|"console=ttyAMA0,38400n8 root=/dev/mmcblk0p2 rootwait ro androidboot.console=ttyAMA0 mmci.fmax=12000000"
+ gArmPlatformTokenSpaceGuid.PcdDefaultBootType|3
+ gArmPlatformTokenSpaceGuid.PcdFdtDevicePath|L"VenHw(09831032-6FA3-4484-AF4F-0A000A8D3A82)/HD(1,MBR,0x00000000,0x3F,0x19FC0)/rtsm\\rtsm_ve-ca15x4.dtb"
# Use the serial console (ConIn & ConOut) and the Graphic driver (ConOut)
gArmPlatformTokenSpaceGuid.PcdDefaultConOutPaths|L"VenHw(D3987D4B-971A-435F-8CAF-4967EB627241)/Uart(38400,8,N,1)/VenPcAnsi();VenHw(407B4008-BF5B-11DF-9547-CF16E0D72085)"
gArmPlatformTokenSpaceGuid.PcdDefaultConInPaths|L"VenHw(D3987D4B-971A-435F-8CAF-4967EB627241)/Uart(38400,8,N,1)/VenPcAnsi()"
#
- # ARM L2x0 PCDs
- #
- gArmTokenSpaceGuid.PcdL2x0ControllerBase|0x1E00A000
-
- #
# ARM Architectual Timer Frequency
#
gArmTokenSpaceGuid.PcdArmArchTimerFreqInHz|60000000
diff --git a/ArmPlatformPkg/ArmVExpressPkg/ArmVExpress-RTSM-A9x4.dsc b/ArmPlatformPkg/ArmVExpressPkg/ArmVExpress-RTSM-A9x4.dsc
index 99272a9900..97449d6109 100644
--- a/ArmPlatformPkg/ArmVExpressPkg/ArmVExpress-RTSM-A9x4.dsc
+++ b/ArmPlatformPkg/ArmVExpressPkg/ArmVExpress-RTSM-A9x4.dsc
@@ -21,7 +21,11 @@
PLATFORM_GUID = e46039e0-5bb3-11e0-a9d6-0002a5d5c51b
PLATFORM_VERSION = 0.1
DSC_SPECIFICATION = 0x00010005
+!ifdef $(EDK2_OUT_DIR)
+ OUTPUT_DIRECTORY = $(EDK2_OUT_DIR)
+!else
OUTPUT_DIRECTORY = Build/ArmVExpress-RTSM-A9x4
+!endif
SUPPORTED_ARCHITECTURES = ARM
BUILD_TARGETS = DEBUG|RELEASE
SKUID_IDENTIFIER = DEFAULT
@@ -154,10 +158,13 @@
#
# Versatile Express machine type (ARM VERSATILE EXPRESS = 2272) required for ARM Linux:
gArmTokenSpaceGuid.PcdArmMachineType|2272
- gArmPlatformTokenSpaceGuid.PcdDefaultBootDescription|L"SemiHosting"
- gArmPlatformTokenSpaceGuid.PcdDefaultBootDevicePath|L"VenHw(C5B9C74A-6D72-4719-99AB-C59F199091EB)/zImage"
- gArmPlatformTokenSpaceGuid.PcdDefaultBootArgument|""
- gArmPlatformTokenSpaceGuid.PcdDefaultBootType|1
+ gArmPlatformTokenSpaceGuid.PcdDefaultBootDescription|L"Linaro image on SD card"
+ gArmPlatformTokenSpaceGuid.PcdDefaultBootDevicePath|L"VenHw(09831032-6FA3-4484-AF4F-0A000A8D3A82)/HD(1,MBR,0x00000000,0x3F,0x19FC0)/uImage"
+ gArmPlatformTokenSpaceGuid.PcdDefaultBootInitrdPath|L"VenHw(09831032-6FA3-4484-AF4F-0A000A8D3A82)/HD(1,MBR,0x00000000,0x3F,0x19FC0)/uInitrd"
+ gArmPlatformTokenSpaceGuid.PcdDefaultFdtLocalDevicePath|L"VenHw(09831032-6FA3-4484-AF4F-0A000A8D3A82)/HD(1,MBR,0x00000000,0x3F,0x19FC0)/rtsm\\rtsm_ve-ca9x4.dtb"
+ gArmPlatformTokenSpaceGuid.PcdDefaultBootArgument|"console=ttyAMA0,38400n8 root=/dev/mmcblk0p2 rootwait ro androidboot.console=ttyAMA0 mmci.fmax=12000000"
+ gArmPlatformTokenSpaceGuid.PcdDefaultBootType|3
+ gArmPlatformTokenSpaceGuid.PcdFdtDevicePath|L"VenHw(09831032-6FA3-4484-AF4F-0A000A8D3A82)/HD(1,MBR,0x00000000,0x3F,0x19FC0)/rtsm\\rtsm_ve-ca9x4.dtb"
# Use the serial console (ConIn & ConOut) and the Graphic driver (ConOut)
gArmPlatformTokenSpaceGuid.PcdDefaultConOutPaths|L"VenHw(D3987D4B-971A-435F-8CAF-4967EB627241)/Uart(38400,8,N,1)/VenPcAnsi();VenHw(407B4008-BF5B-11DF-9547-CF16E0D72085)"
diff --git a/ArmPlatformPkg/ArmVExpressPkg/Library/ArmVExpressLibCTA15-A7/ArmVExpressLib.inf b/ArmPlatformPkg/ArmVExpressPkg/Library/ArmVExpressLibCTA15-A7/ArmVExpressLib.inf
index 6ec75dc0d2..373a8e9e98 100644
--- a/ArmPlatformPkg/ArmVExpressPkg/Library/ArmVExpressLibCTA15-A7/ArmVExpressLib.inf
+++ b/ArmPlatformPkg/ArmVExpressPkg/Library/ArmVExpressLibCTA15-A7/ArmVExpressLib.inf
@@ -51,6 +51,3 @@
gArmTokenSpaceGuid.PcdSystemMemoryBase
gArmTokenSpaceGuid.PcdSystemMemorySize
gArmTokenSpaceGuid.PcdFvBaseAddress
-
- gArmTokenSpaceGuid.PcdArmPrimaryCoreMask
- gArmTokenSpaceGuid.PcdArmPrimaryCore
diff --git a/ArmPlatformPkg/ArmVExpressPkg/Library/ArmVExpressLibCTA15-A7/CTA15-A7.c b/ArmPlatformPkg/ArmVExpressPkg/Library/ArmVExpressLibCTA15-A7/CTA15-A7.c
index 87f41c7ae0..32ce23dff7 100644
--- a/ArmPlatformPkg/ArmVExpressPkg/Library/ArmVExpressLibCTA15-A7/CTA15-A7.c
+++ b/ArmPlatformPkg/ArmVExpressPkg/Library/ArmVExpressLibCTA15-A7/CTA15-A7.c
@@ -140,7 +140,7 @@ ArmPlatformInitialize (
IN UINTN MpId
)
{
- if (!IS_PRIMARY_CORE(MpId)) {
+ if (!ArmPlatformIsPrimaryCore (MpId)) {
return RETURN_SUCCESS;
}
diff --git a/ArmPlatformPkg/ArmVExpressPkg/Library/ArmVExpressLibCTA15-A7/CTA15-A7Helper.S b/ArmPlatformPkg/ArmVExpressPkg/Library/ArmVExpressLibCTA15-A7/CTA15-A7Helper.S
index 286327956a..b560f56c51 100644
--- a/ArmPlatformPkg/ArmVExpressPkg/Library/ArmVExpressLibCTA15-A7/CTA15-A7Helper.S
+++ b/ArmPlatformPkg/ArmVExpressPkg/Library/ArmVExpressLibCTA15-A7/CTA15-A7Helper.S
@@ -1,5 +1,5 @@
//
-// Copyright (c) 2012, ARM Limited. All rights reserved.
+// Copyright (c) 2012-2013, ARM Limited. All rights reserved.
//
// This program and the accompanying materials
// are licensed and made available under the terms and conditions of the BSD License
@@ -11,12 +11,20 @@
//
//
+#include <AsmMacroIoLib.h>
#include <Library/ArmLib.h>
+#include <ArmPlatform.h>
+
.text
-.align 3
+.align 2
+GCC_ASM_EXPORT(ArmPlatformPeiBootAction)
GCC_ASM_EXPORT(ArmPlatformGetCorePosition)
+GCC_ASM_EXPORT(ArmPlatformIsPrimaryCore)
+
+ASM_PFX(ArmPlatformPeiBootAction):
+ bx lr
//UINTN
//ArmPlatformGetCorePosition (
@@ -28,3 +36,33 @@ ASM_PFX(ArmPlatformGetCorePosition):
add r0, r1, r0, LSR #7
bx lr
+//UINTN
+//ArmPlatformIsPrimaryCore (
+// IN UINTN MpId
+// );
+ASM_PFX(ArmPlatformIsPrimaryCore):
+ // Extract cpu_id and cluster_id from ARM_SCC_CFGREG48
+ // with cpu_id[0:3] and cluster_id[4:7]
+ LoadConstantToReg (ARM_CTA15A7_SCC_CFGREG48, r1)
+ ldr r1, [r1]
+ lsr r1, #24
+
+ // Shift the SCC value to get the cluster ID at the offset #8
+ lsl r2, r1, #4
+ and r2, r2, #0xF00
+
+ // Keep only the cpu ID from the original SCC
+ and r1, r1, #0x0F
+ // Add the Cluster ID to the Cpu ID
+ orr r1, r1, r2
+
+ // Keep the Cluster ID and Core ID from the MPID
+ LoadConstantToReg (ARM_CLUSTER_MASK | ARM_CORE_MASK, r2)
+ and r0, r0, r2
+
+ // Compare mpid and boot cpu from ARM_SCC_CFGREG48
+ cmp r0, r1
+ moveq r0, #1
+ movne r0, #0
+ bx lr
+
diff --git a/ArmPlatformPkg/ArmVExpressPkg/Library/ArmVExpressLibCTA15-A7/CTA15-A7Helper.asm b/ArmPlatformPkg/ArmVExpressPkg/Library/ArmVExpressLibCTA15-A7/CTA15-A7Helper.asm
index 73b3d97d66..0ae95f5dbd 100644
--- a/ArmPlatformPkg/ArmVExpressPkg/Library/ArmVExpressLibCTA15-A7/CTA15-A7Helper.asm
+++ b/ArmPlatformPkg/ArmVExpressPkg/Library/ArmVExpressLibCTA15-A7/CTA15-A7Helper.asm
@@ -1,5 +1,5 @@
//
-// Copyright (c) 2012, ARM Limited. All rights reserved.
+// Copyright (c) 2012-2013, ARM Limited. All rights reserved.
//
// This program and the accompanying materials
// are licensed and made available under the terms and conditions of the BSD License
@@ -11,15 +11,24 @@
//
//
+#include <AsmMacroIoLib.h>
#include <Library/ArmLib.h>
+#include <ArmPlatform.h>
+
INCLUDE AsmMacroIoLib.inc
+ EXPORT ArmPlatformPeiBootAction
EXPORT ArmPlatformGetCorePosition
+ EXPORT ArmPlatformIsPrimaryCore
PRESERVE8
AREA CTA15A7Helper, CODE, READONLY
+ArmPlatformPeiBootAction FUNCTION
+ bx lr
+ ENDFUNC
+
//UINTN
//ArmPlatformGetCorePosition (
// IN UINTN MpId
@@ -31,4 +40,35 @@ ArmPlatformGetCorePosition FUNCTION
bx lr
ENDFUNC
+//UINTN
+//ArmPlatformIsPrimaryCore (
+// IN UINTN MpId
+// );
+ArmPlatformIsPrimaryCore FUNCTION
+ // Extract cpu_id and cluster_id from ARM_SCC_CFGREG48
+ // with cpu_id[0:3] and cluster_id[4:7]
+ LoadConstantToReg (ARM_CTA15A7_SCC_CFGREG48, r1)
+ ldr r1, [r1]
+ lsr r1, #24
+
+ // Shift the SCC value to get the cluster ID at the offset #8
+ lsl r2, r1, #4
+ and r2, r2, #0xF00
+
+ // Keep only the cpu ID from the original SCC
+ and r1, r1, #0x0F
+ // Add the Cluster ID to the Cpu ID
+ orr r1, r1, r2
+
+ // Keep the Cluster ID and Core ID from the MPID
+ LoadConstantToReg (ARM_CLUSTER_MASK | ARM_CORE_MASK, r2)
+ and r0, r0, r2
+
+ // Compare mpid and boot cpu from ARM_SCC_CFGREG48
+ cmp r0, r1
+ moveq r0, #1
+ movne r0, #0
+ bx lr
+ ENDFUNC
+
END
diff --git a/ArmPlatformPkg/ArmVExpressPkg/Library/ArmVExpressLibCTA15-A7/CTA15-A7Mem.c b/ArmPlatformPkg/ArmVExpressPkg/Library/ArmVExpressLibCTA15-A7/CTA15-A7Mem.c
index 7698aa61ff..d71e58ae89 100644
--- a/ArmPlatformPkg/ArmVExpressPkg/Library/ArmVExpressLibCTA15-A7/CTA15-A7Mem.c
+++ b/ArmPlatformPkg/ArmVExpressPkg/Library/ArmVExpressLibCTA15-A7/CTA15-A7Mem.c
@@ -174,21 +174,3 @@ ArmPlatformGetVirtualMemoryMap (
*VirtualMemoryMap = VirtualMemoryTable;
}
-
-/**
- Return the EFI Memory Map provided by extension memory on your platform
-
- This EFI Memory Map of the System Memory is used by MemoryInitPei module to create the Resource
- Descriptor HOBs used by DXE core.
-
- @param[out] EfiMemoryMap Array of ARM_SYSTEM_MEMORY_REGION_DESCRIPTOR describing an
- EFI Memory region. This array must be ended by a zero-filled entry
-
-**/
-EFI_STATUS
-ArmPlatformGetAdditionalSystemMemory (
- OUT ARM_SYSTEM_MEMORY_REGION_DESCRIPTOR** EfiMemoryMap
- )
-{
- return EFI_UNSUPPORTED;
-}
diff --git a/ArmPlatformPkg/ArmVExpressPkg/Library/ArmVExpressLibCTA15x2/ArmVExpressLib.inf b/ArmPlatformPkg/ArmVExpressPkg/Library/ArmVExpressLibCTA15x2/ArmVExpressLib.inf
index 39f7df6dc8..ef209e18c9 100644
--- a/ArmPlatformPkg/ArmVExpressPkg/Library/ArmVExpressLibCTA15x2/ArmVExpressLib.inf
+++ b/ArmPlatformPkg/ArmVExpressPkg/Library/ArmVExpressLibCTA15x2/ArmVExpressLib.inf
@@ -37,12 +37,18 @@
[Sources.common]
CTA15x2.c
CTA15x2Mem.c
+ CTA15x2Helper.asm | RVCT
+ CTA15x2Helper.S | GCC
[FeaturePcd]
gEmbeddedTokenSpaceGuid.PcdCacheEnable
gArmPlatformTokenSpaceGuid.PcdNorFlashRemapping
[FixedPcd]
+ gArmPlatformTokenSpaceGuid.PcdCoreCount
gArmTokenSpaceGuid.PcdSystemMemoryBase
gArmTokenSpaceGuid.PcdSystemMemorySize
gArmTokenSpaceGuid.PcdFvBaseAddress
+
+ gArmTokenSpaceGuid.PcdArmPrimaryCoreMask
+ gArmTokenSpaceGuid.PcdArmPrimaryCore
diff --git a/ArmPlatformPkg/ArmVExpressPkg/Library/ArmVExpressLibCTA15x2/ArmVExpressSecLib.inf b/ArmPlatformPkg/ArmVExpressPkg/Library/ArmVExpressLibCTA15x2/ArmVExpressSecLib.inf
index b5d75fdf50..b576c14962 100644
--- a/ArmPlatformPkg/ArmVExpressPkg/Library/ArmVExpressLibCTA15x2/ArmVExpressSecLib.inf
+++ b/ArmPlatformPkg/ArmVExpressPkg/Library/ArmVExpressLibCTA15x2/ArmVExpressSecLib.inf
@@ -48,3 +48,6 @@
[FixedPcd]
gArmTokenSpaceGuid.PcdFvBaseAddress
+
+ gArmTokenSpaceGuid.PcdArmPrimaryCoreMask
+ gArmTokenSpaceGuid.PcdArmPrimaryCore
diff --git a/ArmPlatformPkg/ArmVExpressPkg/Library/ArmVExpressLibCTA15x2/CTA15x2.c b/ArmPlatformPkg/ArmVExpressPkg/Library/ArmVExpressLibCTA15x2/CTA15x2.c
index 6991cae5ed..b91a93b44d 100644
--- a/ArmPlatformPkg/ArmVExpressPkg/Library/ArmVExpressLibCTA15x2/CTA15x2.c
+++ b/ArmPlatformPkg/ArmVExpressPkg/Library/ArmVExpressLibCTA15x2/CTA15x2.c
@@ -78,11 +78,15 @@ ArmPlatformGetBootMode (
in the PEI phase.
**/
-VOID
-ArmPlatformNormalInitialize (
- VOID
+RETURN_STATUS
+ArmPlatformInitialize (
+ IN UINTN MpId
)
{
+ if (!ArmPlatformIsPrimaryCore (MpId)) {
+ return RETURN_SUCCESS;
+ }
+
// Configure periodic timer (TIMER0) for 1MHz operation
MmioOr32 (SP810_CTRL_BASE + SP810_SYS_CTRL_REG, SP810_SYS_CTRL_TIMER0_TIMCLK);
// Configure 1MHz clock
@@ -91,6 +95,8 @@ ArmPlatformNormalInitialize (
MmioAndThenOr32 (SP810_CTRL_BASE + SP810_SYS_CTRL_REG, ~SP810_SYS_CTRL_TIMER2_EN, SP810_SYS_CTRL_TIMER2_TIMCLK);
// Configure SP810 to use 1MHz clock and disable
MmioAndThenOr32 (SP810_CTRL_BASE + SP810_SYS_CTRL_REG, ~SP810_SYS_CTRL_TIMER3_EN, SP810_SYS_CTRL_TIMER3_TIMCLK);
+
+ return RETURN_SUCCESS;
}
/**
@@ -154,17 +160,3 @@ ArmPlatformSecTrustzoneInit (
)
{
}
-
- /**
- This function is called by the ArmPlatformPkg/PrePi or ArmPlatformPkg/PlatformPei
- in the PEI phase.
-
-**/
-RETURN_STATUS
-ArmPlatformInitialize (
- IN UINTN MpId
- )
-{
- return RETURN_SUCCESS;
-}
-
diff --git a/ArmPlatformPkg/ArmVExpressPkg/Library/ArmVExpressLibCTA15x2/CTA15x2Helper.S b/ArmPlatformPkg/ArmVExpressPkg/Library/ArmVExpressLibCTA15x2/CTA15x2Helper.S
new file mode 100644
index 0000000000..e12b8cd4e9
--- /dev/null
+++ b/ArmPlatformPkg/ArmVExpressPkg/Library/ArmVExpressLibCTA15x2/CTA15x2Helper.S
@@ -0,0 +1,62 @@
+#
+# Copyright (c) 2011-2013, ARM Limited. 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.
+#
+#
+
+#include <AsmMacroIoLib.h>
+#include <Library/ArmLib.h>
+
+.text
+.align 2
+
+GCC_ASM_EXPORT(ArmPlatformPeiBootAction)
+GCC_ASM_EXPORT(ArmPlatformIsPrimaryCore)
+GCC_ASM_EXPORT(ArmPlatformGetCorePosition)
+
+GCC_ASM_IMPORT(_gPcd_FixedAtBuild_PcdArmPrimaryCore)
+GCC_ASM_IMPORT(_gPcd_FixedAtBuild_PcdArmPrimaryCoreMask)
+
+//UINTN
+//ArmPlatformGetPrimaryCoreMpId (
+// VOID
+// );
+ASM_PFX(ArmPlatformGetPrimaryCoreMpId):
+ LoadConstantToReg (_gPcd_FixedAtBuild_PcdArmPrimaryCoreMask, r0)
+ ldr r0, [r0]
+ bx lr
+
+//UINTN
+//ArmPlatformIsPrimaryCore (
+// IN UINTN MpId
+// );
+ASM_PFX(ArmPlatformIsPrimaryCore):
+ LoadConstantToReg (_gPcd_FixedAtBuild_PcdArmPrimaryCoreMask, r1)
+ ldr r1, [r1]
+ and r0, r0, r1
+ LoadConstantToReg (_gPcd_FixedAtBuild_PcdArmPrimaryCore, r1)
+ ldr r1, [r1]
+ cmp r0, r1
+ moveq r0, #1
+ movne r0, #0
+ bx lr
+
+//UINTN
+//ArmPlatformGetCorePosition (
+// IN UINTN MpId
+// );
+ASM_PFX(ArmPlatformGetCorePosition):
+ and r0, r0, #ARM_CORE_MASK
+ bx lr
+
+ASM_PFX(ArmPlatformPeiBootAction):
+ bx lr
+
+ASM_FUNCTION_REMOVE_IF_UNREFERENCED
diff --git a/ArmPlatformPkg/ArmVExpressPkg/Library/ArmVExpressLibCTA15x2/CTA15x2Helper.asm b/ArmPlatformPkg/ArmVExpressPkg/Library/ArmVExpressLibCTA15x2/CTA15x2Helper.asm
new file mode 100644
index 0000000000..9508cedd84
--- /dev/null
+++ b/ArmPlatformPkg/ArmVExpressPkg/Library/ArmVExpressLibCTA15x2/CTA15x2Helper.asm
@@ -0,0 +1,70 @@
+//
+// Copyright (c) 2013, ARM Limited. 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.
+//
+//
+
+#include <AsmMacroIoLib.h>
+#include <Library/ArmLib.h>
+
+#include <AutoGen.h>
+
+ INCLUDE AsmMacroIoLib.inc
+
+ EXPORT ArmPlatformPeiBootAction
+ EXPORT ArmPlatformIsPrimaryCore
+ EXPORT ArmPlatformGetPrimaryCoreMpId
+ EXPORT ArmPlatformGetCorePosition
+
+ IMPORT _gPcd_FixedAtBuild_PcdArmPrimaryCore
+ IMPORT _gPcd_FixedAtBuild_PcdArmPrimaryCoreMask
+
+ AREA CTA9x4Helper, CODE, READONLY
+
+//UINTN
+//ArmPlatformGetPrimaryCoreMpId (
+// VOID
+// );
+ArmPlatformGetPrimaryCoreMpId FUNCTION
+ LoadConstantToReg (_gPcd_FixedAtBuild_PcdArmPrimaryCoreMask, r0)
+ ldr r0, [r0]
+ bx lr
+ ENDFUNC
+
+//UINTN
+//ArmPlatformIsPrimaryCore (
+// IN UINTN MpId
+// );
+ArmPlatformIsPrimaryCore FUNCTION
+ LoadConstantToReg (_gPcd_FixedAtBuild_PcdArmPrimaryCoreMask, r1)
+ ldr r1, [r1]
+ and r0, r0, r1
+ LoadConstantToReg (_gPcd_FixedAtBuild_PcdArmPrimaryCore, r1)
+ ldr r1, [r1]
+ cmp r0, r1
+ moveq r0, #1
+ movne r0, #0
+ bx lr
+ ENDFUNC
+
+//UINTN
+//ArmPlatformGetCorePosition (
+// IN UINTN MpId
+// );
+ArmPlatformGetCorePosition FUNCTION
+ and r0, r0, #ARM_CORE_MASK
+ bx lr
+ ENDFUNC
+
+ArmPlatformPeiBootAction FUNCTION
+ bx lr
+ ENDFUNC
+
+ END
diff --git a/ArmPlatformPkg/ArmVExpressPkg/Library/ArmVExpressLibCTA15x2/CTA15x2Mem.c b/ArmPlatformPkg/ArmVExpressPkg/Library/ArmVExpressLibCTA15x2/CTA15x2Mem.c
index bdc4e903cf..eee3c3c9f9 100644
--- a/ArmPlatformPkg/ArmVExpressPkg/Library/ArmVExpressLibCTA15x2/CTA15x2Mem.c
+++ b/ArmPlatformPkg/ArmVExpressPkg/Library/ArmVExpressLibCTA15x2/CTA15x2Mem.c
@@ -126,21 +126,3 @@ ArmPlatformGetVirtualMemoryMap (
*VirtualMemoryMap = VirtualMemoryTable;
}
-
-/**
- Return the EFI Memory Map provided by extension memory on your platform
-
- This EFI Memory Map of the System Memory is used by MemoryInitPei module to create the Resource
- Descriptor HOBs used by DXE core.
-
- @param[out] EfiMemoryMap Array of ARM_SYSTEM_MEMORY_REGION_DESCRIPTOR describing an
- EFI Memory region. This array must be ended by a zero-filled entry
-
-**/
-EFI_STATUS
-ArmPlatformGetAdditionalSystemMemory (
- OUT ARM_SYSTEM_MEMORY_REGION_DESCRIPTOR** EfiMemoryMap
- )
-{
- return EFI_UNSUPPORTED;
-}
diff --git a/ArmPlatformPkg/ArmVExpressPkg/Library/ArmVExpressLibCTA5s/ArmVExpressLib.inf b/ArmPlatformPkg/ArmVExpressPkg/Library/ArmVExpressLibCTA5s/ArmVExpressLib.inf
index c368456d26..de141a86bd 100644
--- a/ArmPlatformPkg/ArmVExpressPkg/Library/ArmVExpressLibCTA5s/ArmVExpressLib.inf
+++ b/ArmPlatformPkg/ArmVExpressPkg/Library/ArmVExpressLibCTA5s/ArmVExpressLib.inf
@@ -37,12 +37,18 @@
[Sources.common]
CTA5s.c
CTA5sMem.c
+ CTA5Helper.asm | RVCT
+ CTA5Helper.S | GCC
[FeaturePcd]
gEmbeddedTokenSpaceGuid.PcdCacheEnable
gArmPlatformTokenSpaceGuid.PcdNorFlashRemapping
[FixedPcd]
+ gArmPlatformTokenSpaceGuid.PcdCoreCount
gArmTokenSpaceGuid.PcdSystemMemoryBase
gArmTokenSpaceGuid.PcdSystemMemorySize
gArmTokenSpaceGuid.PcdFvBaseAddress
+
+ gArmTokenSpaceGuid.PcdArmPrimaryCoreMask
+ gArmTokenSpaceGuid.PcdArmPrimaryCore
diff --git a/ArmPlatformPkg/ArmVExpressPkg/Library/ArmVExpressLibCTA5s/ArmVExpressSecLib.inf b/ArmPlatformPkg/ArmVExpressPkg/Library/ArmVExpressLibCTA5s/ArmVExpressSecLib.inf
index cec7bbe8a2..f0521b95cb 100644
--- a/ArmPlatformPkg/ArmVExpressPkg/Library/ArmVExpressLibCTA5s/ArmVExpressSecLib.inf
+++ b/ArmPlatformPkg/ArmVExpressPkg/Library/ArmVExpressLibCTA5s/ArmVExpressSecLib.inf
@@ -48,3 +48,6 @@
[FixedPcd]
gArmTokenSpaceGuid.PcdFvBaseAddress
+
+ gArmTokenSpaceGuid.PcdArmPrimaryCoreMask
+ gArmTokenSpaceGuid.PcdArmPrimaryCore
diff --git a/ArmPlatformPkg/ArmVExpressPkg/Library/ArmVExpressLibCTA5s/CTA5Helper.S b/ArmPlatformPkg/ArmVExpressPkg/Library/ArmVExpressLibCTA5s/CTA5Helper.S
new file mode 100644
index 0000000000..e12b8cd4e9
--- /dev/null
+++ b/ArmPlatformPkg/ArmVExpressPkg/Library/ArmVExpressLibCTA5s/CTA5Helper.S
@@ -0,0 +1,62 @@
+#
+# Copyright (c) 2011-2013, ARM Limited. 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.
+#
+#
+
+#include <AsmMacroIoLib.h>
+#include <Library/ArmLib.h>
+
+.text
+.align 2
+
+GCC_ASM_EXPORT(ArmPlatformPeiBootAction)
+GCC_ASM_EXPORT(ArmPlatformIsPrimaryCore)
+GCC_ASM_EXPORT(ArmPlatformGetCorePosition)
+
+GCC_ASM_IMPORT(_gPcd_FixedAtBuild_PcdArmPrimaryCore)
+GCC_ASM_IMPORT(_gPcd_FixedAtBuild_PcdArmPrimaryCoreMask)
+
+//UINTN
+//ArmPlatformGetPrimaryCoreMpId (
+// VOID
+// );
+ASM_PFX(ArmPlatformGetPrimaryCoreMpId):
+ LoadConstantToReg (_gPcd_FixedAtBuild_PcdArmPrimaryCoreMask, r0)
+ ldr r0, [r0]
+ bx lr
+
+//UINTN
+//ArmPlatformIsPrimaryCore (
+// IN UINTN MpId
+// );
+ASM_PFX(ArmPlatformIsPrimaryCore):
+ LoadConstantToReg (_gPcd_FixedAtBuild_PcdArmPrimaryCoreMask, r1)
+ ldr r1, [r1]
+ and r0, r0, r1
+ LoadConstantToReg (_gPcd_FixedAtBuild_PcdArmPrimaryCore, r1)
+ ldr r1, [r1]
+ cmp r0, r1
+ moveq r0, #1
+ movne r0, #0
+ bx lr
+
+//UINTN
+//ArmPlatformGetCorePosition (
+// IN UINTN MpId
+// );
+ASM_PFX(ArmPlatformGetCorePosition):
+ and r0, r0, #ARM_CORE_MASK
+ bx lr
+
+ASM_PFX(ArmPlatformPeiBootAction):
+ bx lr
+
+ASM_FUNCTION_REMOVE_IF_UNREFERENCED
diff --git a/ArmPlatformPkg/ArmVExpressPkg/Library/ArmVExpressLibCTA5s/CTA5Helper.asm b/ArmPlatformPkg/ArmVExpressPkg/Library/ArmVExpressLibCTA5s/CTA5Helper.asm
new file mode 100644
index 0000000000..9508cedd84
--- /dev/null
+++ b/ArmPlatformPkg/ArmVExpressPkg/Library/ArmVExpressLibCTA5s/CTA5Helper.asm
@@ -0,0 +1,70 @@
+//
+// Copyright (c) 2013, ARM Limited. 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.
+//
+//
+
+#include <AsmMacroIoLib.h>
+#include <Library/ArmLib.h>
+
+#include <AutoGen.h>
+
+ INCLUDE AsmMacroIoLib.inc
+
+ EXPORT ArmPlatformPeiBootAction
+ EXPORT ArmPlatformIsPrimaryCore
+ EXPORT ArmPlatformGetPrimaryCoreMpId
+ EXPORT ArmPlatformGetCorePosition
+
+ IMPORT _gPcd_FixedAtBuild_PcdArmPrimaryCore
+ IMPORT _gPcd_FixedAtBuild_PcdArmPrimaryCoreMask
+
+ AREA CTA9x4Helper, CODE, READONLY
+
+//UINTN
+//ArmPlatformGetPrimaryCoreMpId (
+// VOID
+// );
+ArmPlatformGetPrimaryCoreMpId FUNCTION
+ LoadConstantToReg (_gPcd_FixedAtBuild_PcdArmPrimaryCoreMask, r0)
+ ldr r0, [r0]
+ bx lr
+ ENDFUNC
+
+//UINTN
+//ArmPlatformIsPrimaryCore (
+// IN UINTN MpId
+// );
+ArmPlatformIsPrimaryCore FUNCTION
+ LoadConstantToReg (_gPcd_FixedAtBuild_PcdArmPrimaryCoreMask, r1)
+ ldr r1, [r1]
+ and r0, r0, r1
+ LoadConstantToReg (_gPcd_FixedAtBuild_PcdArmPrimaryCore, r1)
+ ldr r1, [r1]
+ cmp r0, r1
+ moveq r0, #1
+ movne r0, #0
+ bx lr
+ ENDFUNC
+
+//UINTN
+//ArmPlatformGetCorePosition (
+// IN UINTN MpId
+// );
+ArmPlatformGetCorePosition FUNCTION
+ and r0, r0, #ARM_CORE_MASK
+ bx lr
+ ENDFUNC
+
+ArmPlatformPeiBootAction FUNCTION
+ bx lr
+ ENDFUNC
+
+ END
diff --git a/ArmPlatformPkg/ArmVExpressPkg/Library/ArmVExpressLibCTA5s/CTA5s.c b/ArmPlatformPkg/ArmVExpressPkg/Library/ArmVExpressLibCTA5s/CTA5s.c
index 227f9e62f8..ccf6fe0a68 100644
--- a/ArmPlatformPkg/ArmVExpressPkg/Library/ArmVExpressLibCTA5s/CTA5s.c
+++ b/ArmPlatformPkg/ArmVExpressPkg/Library/ArmVExpressLibCTA5s/CTA5s.c
@@ -78,11 +78,15 @@ ArmPlatformGetBootMode (
in the PEI phase.
**/
-VOID
-ArmPlatformNormalInitialize (
- VOID
+RETURN_STATUS
+ArmPlatformInitialize (
+ IN UINTN MpId
)
{
+ if (!ArmPlatformIsPrimaryCore (MpId)) {
+ return RETURN_SUCCESS;
+ }
+
// Configure periodic timer (TIMER0) for 1MHz operation
MmioOr32 (SP810_CTRL_BASE + SP810_SYS_CTRL_REG, SP810_SYS_CTRL_TIMER0_TIMCLK);
// Configure 1MHz clock
@@ -91,6 +95,8 @@ ArmPlatformNormalInitialize (
MmioAndThenOr32 (SP810_CTRL_BASE + SP810_SYS_CTRL_REG, ~SP810_SYS_CTRL_TIMER2_EN, SP810_SYS_CTRL_TIMER2_TIMCLK);
// Configure SP810 to use 1MHz clock and disable
MmioAndThenOr32 (SP810_CTRL_BASE + SP810_SYS_CTRL_REG, ~SP810_SYS_CTRL_TIMER3_EN, SP810_SYS_CTRL_TIMER3_TIMCLK);
+
+ return RETURN_SUCCESS;
}
/**
@@ -154,17 +160,3 @@ ArmPlatformSecTrustzoneInit (
)
{
}
-
- /**
- This function is called by the ArmPlatformPkg/PrePi or ArmPlatformPkg/PlatformPei
- in the PEI phase.
-
-**/
-RETURN_STATUS
-ArmPlatformInitialize (
- IN UINTN MpId
- )
-{
- return RETURN_SUCCESS;
-}
-
diff --git a/ArmPlatformPkg/ArmVExpressPkg/Library/ArmVExpressLibCTA5s/CTA5sMem.c b/ArmPlatformPkg/ArmVExpressPkg/Library/ArmVExpressLibCTA5s/CTA5sMem.c
index bdc4e903cf..eee3c3c9f9 100644
--- a/ArmPlatformPkg/ArmVExpressPkg/Library/ArmVExpressLibCTA5s/CTA5sMem.c
+++ b/ArmPlatformPkg/ArmVExpressPkg/Library/ArmVExpressLibCTA5s/CTA5sMem.c
@@ -126,21 +126,3 @@ ArmPlatformGetVirtualMemoryMap (
*VirtualMemoryMap = VirtualMemoryTable;
}
-
-/**
- Return the EFI Memory Map provided by extension memory on your platform
-
- This EFI Memory Map of the System Memory is used by MemoryInitPei module to create the Resource
- Descriptor HOBs used by DXE core.
-
- @param[out] EfiMemoryMap Array of ARM_SYSTEM_MEMORY_REGION_DESCRIPTOR describing an
- EFI Memory region. This array must be ended by a zero-filled entry
-
-**/
-EFI_STATUS
-ArmPlatformGetAdditionalSystemMemory (
- OUT ARM_SYSTEM_MEMORY_REGION_DESCRIPTOR** EfiMemoryMap
- )
-{
- return EFI_UNSUPPORTED;
-}
diff --git a/ArmPlatformPkg/ArmVExpressPkg/Library/ArmVExpressLibCTA9x4/ArmVExpressLib.inf b/ArmPlatformPkg/ArmVExpressPkg/Library/ArmVExpressLibCTA9x4/ArmVExpressLib.inf
index a255c40b3e..d160a4fc91 100644
--- a/ArmPlatformPkg/ArmVExpressPkg/Library/ArmVExpressLibCTA9x4/ArmVExpressLib.inf
+++ b/ArmPlatformPkg/ArmVExpressPkg/Library/ArmVExpressLibCTA9x4/ArmVExpressLib.inf
@@ -1,5 +1,5 @@
#/* @file
-# Copyright (c) 2011-2012, ARM Limited. All rights reserved.
+# Copyright (c) 2011-2013, ARM Limited. All rights reserved.
#
# This program and the accompanying materials
# are licensed and made available under the terms and conditions of the BSD License
@@ -37,8 +37,12 @@
SerialPortLib
[Sources.common]
+ CTA9x4Helper.asm | RVCT
+ CTA9x4Helper.S | GCC
CTA9x4.c
CTA9x4Mem.c
+ CTA9x4Helper.S | GCC
+ CTA9x4Helper.asm | RVCT
[FeaturePcd]
gEmbeddedTokenSpaceGuid.PcdCacheEnable
diff --git a/ArmPlatformPkg/ArmVExpressPkg/Library/ArmVExpressLibCTA9x4/ArmVExpressLibSec.inf b/ArmPlatformPkg/ArmVExpressPkg/Library/ArmVExpressLibCTA9x4/ArmVExpressLibSec.inf
index 36784c0b49..4d9699d4a3 100644
--- a/ArmPlatformPkg/ArmVExpressPkg/Library/ArmVExpressLibCTA9x4/ArmVExpressLibSec.inf
+++ b/ArmPlatformPkg/ArmVExpressPkg/Library/ArmVExpressLibCTA9x4/ArmVExpressLibSec.inf
@@ -36,6 +36,8 @@
[Sources.common]
CTA9x4.c
+ CTA9x4Helper.S | GCC
+ CTA9x4Helper.asm | RVCT
[FeaturePcd]
gEmbeddedTokenSpaceGuid.PcdCacheEnable
diff --git a/ArmPlatformPkg/ArmVExpressPkg/Library/ArmVExpressLibCTA9x4/CTA9x4.c b/ArmPlatformPkg/ArmVExpressPkg/Library/ArmVExpressLibCTA9x4/CTA9x4.c
index fb920aa497..55b611190a 100644
--- a/ArmPlatformPkg/ArmVExpressPkg/Library/ArmVExpressLibCTA9x4/CTA9x4.c
+++ b/ArmPlatformPkg/ArmVExpressPkg/Library/ArmVExpressLibCTA9x4/CTA9x4.c
@@ -136,7 +136,7 @@ ArmPlatformInitialize (
IN UINTN MpId
)
{
- if (!IS_PRIMARY_CORE(MpId)) {
+ if (!ArmPlatformIsPrimaryCore (MpId)) {
return RETURN_SUCCESS;
}
@@ -211,3 +211,4 @@ ArmPlatformGetPlatformPpiList (
*PpiListSize = sizeof(gPlatformPpiTable);
*PpiList = gPlatformPpiTable;
}
+
diff --git a/ArmPlatformPkg/ArmVExpressPkg/Library/ArmVExpressLibCTA9x4/CTA9x4Helper.S b/ArmPlatformPkg/ArmVExpressPkg/Library/ArmVExpressLibCTA9x4/CTA9x4Helper.S
new file mode 100644
index 0000000000..e12b8cd4e9
--- /dev/null
+++ b/ArmPlatformPkg/ArmVExpressPkg/Library/ArmVExpressLibCTA9x4/CTA9x4Helper.S
@@ -0,0 +1,62 @@
+#
+# Copyright (c) 2011-2013, ARM Limited. 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.
+#
+#
+
+#include <AsmMacroIoLib.h>
+#include <Library/ArmLib.h>
+
+.text
+.align 2
+
+GCC_ASM_EXPORT(ArmPlatformPeiBootAction)
+GCC_ASM_EXPORT(ArmPlatformIsPrimaryCore)
+GCC_ASM_EXPORT(ArmPlatformGetCorePosition)
+
+GCC_ASM_IMPORT(_gPcd_FixedAtBuild_PcdArmPrimaryCore)
+GCC_ASM_IMPORT(_gPcd_FixedAtBuild_PcdArmPrimaryCoreMask)
+
+//UINTN
+//ArmPlatformGetPrimaryCoreMpId (
+// VOID
+// );
+ASM_PFX(ArmPlatformGetPrimaryCoreMpId):
+ LoadConstantToReg (_gPcd_FixedAtBuild_PcdArmPrimaryCoreMask, r0)
+ ldr r0, [r0]
+ bx lr
+
+//UINTN
+//ArmPlatformIsPrimaryCore (
+// IN UINTN MpId
+// );
+ASM_PFX(ArmPlatformIsPrimaryCore):
+ LoadConstantToReg (_gPcd_FixedAtBuild_PcdArmPrimaryCoreMask, r1)
+ ldr r1, [r1]
+ and r0, r0, r1
+ LoadConstantToReg (_gPcd_FixedAtBuild_PcdArmPrimaryCore, r1)
+ ldr r1, [r1]
+ cmp r0, r1
+ moveq r0, #1
+ movne r0, #0
+ bx lr
+
+//UINTN
+//ArmPlatformGetCorePosition (
+// IN UINTN MpId
+// );
+ASM_PFX(ArmPlatformGetCorePosition):
+ and r0, r0, #ARM_CORE_MASK
+ bx lr
+
+ASM_PFX(ArmPlatformPeiBootAction):
+ bx lr
+
+ASM_FUNCTION_REMOVE_IF_UNREFERENCED
diff --git a/ArmPlatformPkg/ArmVExpressPkg/Library/ArmVExpressLibCTA9x4/CTA9x4Helper.asm b/ArmPlatformPkg/ArmVExpressPkg/Library/ArmVExpressLibCTA9x4/CTA9x4Helper.asm
new file mode 100644
index 0000000000..9508cedd84
--- /dev/null
+++ b/ArmPlatformPkg/ArmVExpressPkg/Library/ArmVExpressLibCTA9x4/CTA9x4Helper.asm
@@ -0,0 +1,70 @@
+//
+// Copyright (c) 2013, ARM Limited. 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.
+//
+//
+
+#include <AsmMacroIoLib.h>
+#include <Library/ArmLib.h>
+
+#include <AutoGen.h>
+
+ INCLUDE AsmMacroIoLib.inc
+
+ EXPORT ArmPlatformPeiBootAction
+ EXPORT ArmPlatformIsPrimaryCore
+ EXPORT ArmPlatformGetPrimaryCoreMpId
+ EXPORT ArmPlatformGetCorePosition
+
+ IMPORT _gPcd_FixedAtBuild_PcdArmPrimaryCore
+ IMPORT _gPcd_FixedAtBuild_PcdArmPrimaryCoreMask
+
+ AREA CTA9x4Helper, CODE, READONLY
+
+//UINTN
+//ArmPlatformGetPrimaryCoreMpId (
+// VOID
+// );
+ArmPlatformGetPrimaryCoreMpId FUNCTION
+ LoadConstantToReg (_gPcd_FixedAtBuild_PcdArmPrimaryCoreMask, r0)
+ ldr r0, [r0]
+ bx lr
+ ENDFUNC
+
+//UINTN
+//ArmPlatformIsPrimaryCore (
+// IN UINTN MpId
+// );
+ArmPlatformIsPrimaryCore FUNCTION
+ LoadConstantToReg (_gPcd_FixedAtBuild_PcdArmPrimaryCoreMask, r1)
+ ldr r1, [r1]
+ and r0, r0, r1
+ LoadConstantToReg (_gPcd_FixedAtBuild_PcdArmPrimaryCore, r1)
+ ldr r1, [r1]
+ cmp r0, r1
+ moveq r0, #1
+ movne r0, #0
+ bx lr
+ ENDFUNC
+
+//UINTN
+//ArmPlatformGetCorePosition (
+// IN UINTN MpId
+// );
+ArmPlatformGetCorePosition FUNCTION
+ and r0, r0, #ARM_CORE_MASK
+ bx lr
+ ENDFUNC
+
+ArmPlatformPeiBootAction FUNCTION
+ bx lr
+ ENDFUNC
+
+ END
diff --git a/ArmPlatformPkg/ArmVExpressPkg/Library/ArmVExpressLibCTA9x4/CTA9x4Mem.c b/ArmPlatformPkg/ArmVExpressPkg/Library/ArmVExpressLibCTA9x4/CTA9x4Mem.c
index ef8fa4191a..f647d2575a 100644
--- a/ArmPlatformPkg/ArmVExpressPkg/Library/ArmVExpressLibCTA9x4/CTA9x4Mem.c
+++ b/ArmPlatformPkg/ArmVExpressPkg/Library/ArmVExpressLibCTA9x4/CTA9x4Mem.c
@@ -117,21 +117,3 @@ ArmPlatformGetVirtualMemoryMap (
*VirtualMemoryMap = VirtualMemoryTable;
}
-
-/**
- Return the EFI Memory Map provided by extension memory on your platform
-
- This EFI Memory Map of the System Memory is used by MemoryInitPei module to create the Resource
- Descriptor HOBs used by DXE core.
-
- @param[out] EfiMemoryMap Array of ARM_SYSTEM_MEMORY_REGION_DESCRIPTOR describing an
- EFI Memory region. This array must be ended by a zero-filled entry
-
-**/
-EFI_STATUS
-ArmPlatformGetAdditionalSystemMemory (
- OUT ARM_SYSTEM_MEMORY_REGION_DESCRIPTOR** EfiMemoryMap
- )
-{
- return EFI_UNSUPPORTED;
-}
diff --git a/ArmPlatformPkg/ArmVExpressPkg/Library/ArmVExpressLibRTSM/Arm/RTSMHelper.S b/ArmPlatformPkg/ArmVExpressPkg/Library/ArmVExpressLibRTSM/Arm/RTSMHelper.S
index 949e7a3014..95006c5f25 100644
--- a/ArmPlatformPkg/ArmVExpressPkg/Library/ArmVExpressLibRTSM/Arm/RTSMHelper.S
+++ b/ArmPlatformPkg/ArmVExpressPkg/Library/ArmVExpressLibRTSM/Arm/RTSMHelper.S
@@ -1,10 +1,10 @@
#
-# Copyright (c) 2011, ARM Limited. All rights reserved.
+# Copyright (c) 2011-2013, ARM Limited. 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
+# 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.
@@ -13,16 +13,27 @@
#include <AsmMacroIoLib.h>
#include <Base.h>
+#include <Library/ArmLib.h>
#include <Library/PcdLib.h>
#include <AutoGen.h>
-#.include AsmMacroIoLib.inc
+#include "AsmMacroIoLib.inc"
#include <Chipset/ArmCortexA9.h>
.text
.align 2
+GCC_ASM_EXPORT(ArmPlatformPeiBootAction)
GCC_ASM_EXPORT(ArmGetCpuCountPerCluster)
+GCC_ASM_EXPORT(ArmPlatformIsPrimaryCore)
+GCC_ASM_EXPORT(ArmPlatformGetPrimaryCoreMpId)
+GCC_ASM_EXPORT(ArmPlatformGetCorePosition)
+
+GCC_ASM_IMPORT(_gPcd_FixedAtBuild_PcdArmPrimaryCore)
+GCC_ASM_IMPORT(_gPcd_FixedAtBuild_PcdArmPrimaryCoreMask)
+
+ASM_PFX(ArmPlatformPeiBootAction):
+ bx lr
# IN None
# OUT r0 = SCU Base Address
@@ -31,7 +42,16 @@ ASM_PFX(ArmGetScuBaseAddress):
# the Configuration BAR as a stack is not necessary setup. The SCU is at the
# offset 0x0000 from the Private Memory Region.
mrc p15, 4, r0, c15, c0, 0
- bx lr
+ bx lr
+
+//UINTN
+//ArmPlatformGetPrimaryCoreMpId (
+// VOID
+// );
+ASM_PFX(ArmPlatformGetPrimaryCoreMpId):
+ LoadConstantToReg (_gPcd_FixedAtBuild_PcdArmPrimaryCoreMask, r0)
+ ldr r0, [r0]
+ bx lr
# IN None
# OUT r0 = number of cores present in the system
@@ -68,4 +88,29 @@ _Return:
ldmfd SP!, {r1-r2}
bx lr
+//UINTN
+//ArmPlatformIsPrimaryCore (
+// IN UINTN MpId
+// );
+ASM_PFX(ArmPlatformIsPrimaryCore):
+ LoadConstantToReg (_gPcd_FixedAtBuild_PcdArmPrimaryCoreMask, r1)
+ ldr r1, [r1]
+ and r0, r0, r1
+ LoadConstantToReg (_gPcd_FixedAtBuild_PcdArmPrimaryCore, r1)
+ ldr r1, [r1]
+ cmp r0, r1
+ moveq r0, #1
+ movne r0, #0
+ bx lr
+
+//UINTN
+//ArmPlatformGetCorePosition (
+// IN UINTN MpId
+// );
+ASM_PFX(ArmPlatformGetCorePosition):
+ and r1, r0, #ARM_CORE_MASK
+ and r0, r0, #ARM_CLUSTER_MASK
+ add r0, r1, r0, LSR #7
+ bx lr
+
ASM_FUNCTION_REMOVE_IF_UNREFERENCED
diff --git a/ArmPlatformPkg/ArmVExpressPkg/Library/ArmVExpressLibRTSM/Arm/RTSMHelper.asm b/ArmPlatformPkg/ArmVExpressPkg/Library/ArmVExpressLibRTSM/Arm/RTSMHelper.asm
index 7326237bc7..5befec31ef 100644
--- a/ArmPlatformPkg/ArmVExpressPkg/Library/ArmVExpressLibRTSM/Arm/RTSMHelper.asm
+++ b/ArmPlatformPkg/ArmVExpressPkg/Library/ArmVExpressLibRTSM/Arm/RTSMHelper.asm
@@ -1,5 +1,5 @@
//
-// Copyright (c) 2011, ARM Limited. All rights reserved.
+// Copyright (c) 2011-2013, ARM Limited. All rights reserved.
//
// This program and the accompanying materials
// are licensed and made available under the terms and conditions of the BSD License
@@ -13,6 +13,7 @@
#include <AsmMacroIoLib.h>
#include <Base.h>
+#include <Library/ArmLib.h>
#include <Library/PcdLib.h>
#include <Chipset/ArmCortexA9.h>
@@ -21,22 +22,44 @@
INCLUDE AsmMacroIoLib.inc
+ EXPORT ArmPlatformPeiBootAction
EXPORT ArmGetCpuCountPerCluster
-
+ EXPORT ArmPlatformIsPrimaryCore
+ EXPORT ArmPlatformGetPrimaryCoreMpId
+ EXPORT ArmPlatformGetCorePosition
+
+ IMPORT _gPcd_FixedAtBuild_PcdArmPrimaryCore
+ IMPORT _gPcd_FixedAtBuild_PcdArmPrimaryCoreMask
+
AREA RTSMHelper, CODE, READONLY
+ArmPlatformPeiBootAction FUNCTION
+ bx lr
+ ENDFUNC
+
// IN None
// OUT r0 = SCU Base Address
-ArmGetScuBaseAddress
+ArmGetScuBaseAddress FUNCTION
// Read Configuration Base Address Register. ArmCBar cannot be called to get
// the Configuration BAR as a stack is not necessary setup. The SCU is at the
// offset 0x0000 from the Private Memory Region.
mrc p15, 4, r0, c15, c0, 0
bx lr
+ ENDFUNC
+
+//UINTN
+//ArmPlatformGetPrimaryCoreMpId (
+// VOID
+// );
+ArmPlatformGetPrimaryCoreMpId FUNCTION
+ LoadConstantToReg (_gPcd_FixedAtBuild_PcdArmPrimaryCoreMask, r0)
+ ldr r0, [r0]
+ bx lr
+ ENDFUNC
// IN None
// OUT r0 = number of cores present in the system
-ArmGetCpuCountPerCluster
+ArmGetCpuCountPerCluster FUNCTION
stmfd SP!, {r1-r2}
// Read CP15 MIDR
@@ -69,5 +92,33 @@ _Return
add r0, r0, #1
ldmfd SP!, {r1-r2}
bx lr
+ ENDFUNC
+
+//UINTN
+//ArmPlatformIsPrimaryCore (
+// IN UINTN MpId
+// );
+ArmPlatformIsPrimaryCore FUNCTION
+ LoadConstantToReg (_gPcd_FixedAtBuild_PcdArmPrimaryCoreMask, r1)
+ ldr r1, [r1]
+ and r0, r0, r1
+ LoadConstantToReg (_gPcd_FixedAtBuild_PcdArmPrimaryCore, r1)
+ ldr r1, [r1]
+ cmp r0, r1
+ moveq r0, #1
+ movne r0, #0
+ bx lr
+ ENDFUNC
+
+//UINTN
+//ArmPlatformGetCorePosition (
+// IN UINTN MpId
+// );
+ArmPlatformGetCorePosition FUNCTION
+ and r1, r0, #ARM_CORE_MASK
+ and r0, r0, #ARM_CLUSTER_MASK
+ add r0, r1, r0, LSR #7
+ bx lr
+ ENDFUNC
END
diff --git a/ArmPlatformPkg/ArmVExpressPkg/Library/ArmVExpressLibRTSM/RTSM.c b/ArmPlatformPkg/ArmVExpressPkg/Library/ArmVExpressLibRTSM/RTSM.c
index f055608abc..5cafda8365 100644
--- a/ArmPlatformPkg/ArmVExpressPkg/Library/ArmVExpressLibRTSM/RTSM.c
+++ b/ArmPlatformPkg/ArmVExpressPkg/Library/ArmVExpressLibRTSM/RTSM.c
@@ -97,7 +97,7 @@ ArmPlatformInitialize (
IN UINTN MpId
)
{
- if (!IS_PRIMARY_CORE(MpId)) {
+ if (!ArmPlatformIsPrimaryCore (MpId)) {
return RETURN_SUCCESS;
}
diff --git a/ArmPlatformPkg/ArmVExpressPkg/Library/ArmVExpressLibRTSM/RTSMMem.c b/ArmPlatformPkg/ArmVExpressPkg/Library/ArmVExpressLibRTSM/RTSMMem.c
index cb6376f65e..68efde7065 100644
--- a/ArmPlatformPkg/ArmVExpressPkg/Library/ArmVExpressLibRTSM/RTSMMem.c
+++ b/ArmPlatformPkg/ArmVExpressPkg/Library/ArmVExpressLibRTSM/RTSMMem.c
@@ -126,22 +126,3 @@ ArmPlatformGetVirtualMemoryMap (
*VirtualMemoryMap = VirtualMemoryTable;
}
-
-/**
- Return the EFI Memory Map provided by extension memory on your platform
-
- This EFI Memory Map of the System Memory is used by MemoryInitPei module to create the Resource
- Descriptor HOBs used by DXE core.
- TODO: CompleteMe .... say this is the memory not covered by the System Memory PCDs
-
- @param[out] EfiMemoryMap Array of ARM_SYSTEM_MEMORY_REGION_DESCRIPTOR describing an
- EFI Memory region. This array must be ended by a zero-filled entry
-
-**/
-EFI_STATUS
-ArmPlatformGetAdditionalSystemMemory (
- OUT ARM_SYSTEM_MEMORY_REGION_DESCRIPTOR** EfiMemoryMap
- )
-{
- return EFI_UNSUPPORTED;
-}
diff --git a/ArmPlatformPkg/ArmVExpressPkg/Library/ArmVExpressSecLibCTA9x4/CTA9x4Sec.c b/ArmPlatformPkg/ArmVExpressPkg/Library/ArmVExpressSecLibCTA9x4/CTA9x4Sec.c
index 228a0fb0f8..a671f130f2 100644
--- a/ArmPlatformPkg/ArmVExpressPkg/Library/ArmVExpressSecLibCTA9x4/CTA9x4Sec.c
+++ b/ArmPlatformPkg/ArmVExpressPkg/Library/ArmVExpressSecLibCTA9x4/CTA9x4Sec.c
@@ -36,7 +36,7 @@ ArmPlatformSecTrustzoneInit (
)
{
// Nothing to do
- if (!IS_PRIMARY_CORE(MpId)) {
+ if (!ArmPlatformIsPrimaryCore (MpId)) {
return;
}
@@ -120,7 +120,7 @@ ArmPlatformSecInitialize (
)
{
// If it is not the primary core then there is nothing to do
- if (!IS_PRIMARY_CORE(MpId)) {
+ if (!ArmPlatformIsPrimaryCore (MpId)) {
return RETURN_SUCCESS;
}
diff --git a/ArmPlatformPkg/ArmVExpressPkg/Library/ArmVExpressSecLibRTSM/Arm/RTSMHelper.S b/ArmPlatformPkg/ArmVExpressPkg/Library/ArmVExpressSecLibRTSM/Arm/RTSMHelper.S
deleted file mode 100644
index f47a5312ff..0000000000
--- a/ArmPlatformPkg/ArmVExpressPkg/Library/ArmVExpressSecLibRTSM/Arm/RTSMHelper.S
+++ /dev/null
@@ -1,71 +0,0 @@
-#
-# Copyright (c) 2011-2012, ARM Limited. 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.
-#
-#
-
-#include <AsmMacroIoLib.h>
-#include <Base.h>
-#include <Library/PcdLib.h>
-#include <AutoGen.h>
-#.include AsmMacroIoLib.inc
-
-#include <Chipset/ArmCortexA9.h>
-
-.text
-.align 2
-
-GCC_ASM_EXPORT(ArmGetCpuCountPerCluster)
-
-# IN None
-# OUT r0 = SCU Base Address
-ASM_PFX(ArmGetScuBaseAddress):
- # Read Configuration Base Address Register. ArmCBar cannot be called to get
- # the Configuration BAR as a stack is not necessary setup. The SCU is at the
- # offset 0x0000 from the Private Memory Region.
- mrc p15, 4, r0, c15, c0, 0
- bx lr
-
-# IN None
-# OUT r0 = number of cores present in the system
-ASM_PFX(ArmGetCpuCountPerCluster):
- stmfd SP!, {r1-r2}
-
- # Read CP15 MIDR
- mrc p15, 0, r1, c0, c0, 0
-
- # Check if the CPU is A15
- mov r1, r1, LSR #4
- LoadConstantToReg (ARM_CPU_TYPE_MASK, r0)
- and r1, r1, r0
-
- LoadConstantToReg (ARM_CPU_TYPE_A15, r0)
- cmp r1, r0
- beq _Read_cp15_reg
-
-_CPU_is_not_A15:
- mov r2, lr @ Save link register
- bl ArmGetScuBaseAddress @ Read SCU Base Address
- mov lr, r2 @ Restore link register val
- ldr r0, [r0, #A9_SCU_CONFIG_OFFSET] @ Read SCU Config reg to get CPU count
- b _Return
-
-_Read_cp15_reg:
- mrc p15, 1, r0, c9, c0, 2 @ Read C9 register of CP15 to get CPU count
- lsr r0, #24
-
-_Return:
- and r0, r0, #3
- # Add '1' to the number of CPU on the Cluster
- add r0, r0, #1
- ldmfd SP!, {r1-r2}
- bx lr
-
-ASM_FUNCTION_REMOVE_IF_UNREFERENCED
diff --git a/ArmPlatformPkg/ArmVExpressPkg/Library/ArmVExpressSecLibRTSM/Arm/RTSMHelper.asm b/ArmPlatformPkg/ArmVExpressPkg/Library/ArmVExpressSecLibRTSM/Arm/RTSMHelper.asm
deleted file mode 100644
index 402db58278..0000000000
--- a/ArmPlatformPkg/ArmVExpressPkg/Library/ArmVExpressSecLibRTSM/Arm/RTSMHelper.asm
+++ /dev/null
@@ -1,73 +0,0 @@
-//
-// Copyright (c) 2011-2012, ARM Limited. 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.
-//
-//
-
-#include <AsmMacroIoLib.h>
-#include <Base.h>
-#include <Library/PcdLib.h>
-
-#include <Chipset/ArmCortexA9.h>
-
-#include <AutoGen.h>
-
- INCLUDE AsmMacroIoLib.inc
-
- EXPORT ArmGetCpuCountPerCluster
-
- AREA RTSMHelper, CODE, READONLY
-
-// IN None
-// OUT r0 = SCU Base Address
-ArmGetScuBaseAddress
- // Read Configuration Base Address Register. ArmCBar cannot be called to get
- // the Configuration BAR as a stack is not necessary setup. The SCU is at the
- // offset 0x0000 from the Private Memory Region.
- mrc p15, 4, r0, c15, c0, 0
- bx lr
-
-// IN None
-// OUT r0 = number of cores present in the system
-ArmGetCpuCountPerCluster
- stmfd SP!, {r1-r2}
-
- // Read CP15 MIDR
- mrc p15, 0, r1, c0, c0, 0
-
- // Check if the CPU is A15
- mov r1, r1, LSR #4
- mov r0, #ARM_CPU_TYPE_MASK
- and r1, r1, r0
-
- mov r0, #ARM_CPU_TYPE_A15
- cmp r1, r0
- beq _Read_cp15_reg
-
-_CPU_is_not_A15
- mov r2, lr ; Save link register
- bl ArmGetScuBaseAddress ; Read SCU Base Address
- mov lr, r2 ; Restore link register val
- ldr r0, [r0, #A9_SCU_CONFIG_OFFSET] ; Read SCU Config reg to get CPU count
- b _Return
-
-_Read_cp15_reg
- mrc p15, 1, r0, c9, c0, 2 ; Read C9 register of CP15 to get CPU count
- lsr r0, #24
-
-
-_Return
- and r0, r0, #3
- // Add '1' to the number of CPU on the Cluster
- add r0, r0, #1
- ldmfd SP!, {r1-r2}
- bx lr
-
- END
diff --git a/ArmPlatformPkg/ArmVExpressPkg/Library/ArmVExpressSecLibRTSM/ArmVExpressSecLib.inf b/ArmPlatformPkg/ArmVExpressPkg/Library/ArmVExpressSecLibRTSM/ArmVExpressSecLib.inf
index ff8476718f..f1e29ff01b 100644
--- a/ArmPlatformPkg/ArmVExpressPkg/Library/ArmVExpressSecLibRTSM/ArmVExpressSecLib.inf
+++ b/ArmPlatformPkg/ArmVExpressPkg/Library/ArmVExpressSecLibRTSM/ArmVExpressSecLib.inf
@@ -37,8 +37,6 @@
[Sources.ARM]
Arm/RTSMBoot.asm | RVCT
Arm/RTSMBoot.S | GCC
- Arm/RTSMHelper.asm | RVCT
- Arm/RTSMHelper.S | GCC
[FeaturePcd]
gEmbeddedTokenSpaceGuid.PcdCacheEnable
diff --git a/ArmPlatformPkg/ArmVExpressPkg/Library/ArmVExpressSecLibRTSM/RTSMSec.c b/ArmPlatformPkg/ArmVExpressPkg/Library/ArmVExpressSecLibRTSM/RTSMSec.c
index 92df56cd57..bce834eea9 100644
--- a/ArmPlatformPkg/ArmVExpressPkg/Library/ArmVExpressSecLibRTSM/RTSMSec.c
+++ b/ArmPlatformPkg/ArmVExpressPkg/Library/ArmVExpressSecLibRTSM/RTSMSec.c
@@ -50,7 +50,7 @@ ArmPlatformSecInitialize (
)
{
// If it is not the primary core then there is nothing to do
- if (!IS_PRIMARY_CORE(MpId)) {
+ if (!ArmPlatformIsPrimaryCore (MpId)) {
return RETURN_SUCCESS;
}
diff --git a/ArmPlatformPkg/ArmVExpressPkg/Library/ResetSystemLib/ResetSystemLib.c b/ArmPlatformPkg/ArmVExpressPkg/Library/ResetSystemLib/ResetSystemLib.c
index f858317550..f32b533094 100644
--- a/ArmPlatformPkg/ArmVExpressPkg/Library/ResetSystemLib/ResetSystemLib.c
+++ b/ArmPlatformPkg/ArmVExpressPkg/Library/ResetSystemLib/ResetSystemLib.c
@@ -49,12 +49,19 @@ LibResetSystem (
case EfiResetWarm:
// Map a warm reset into a cold reset
case EfiResetCold:
- case EfiResetShutdown:
// Send the REBOOT function to the platform microcontroller
ArmPlatformSysConfigSet (SYS_CFG_REBOOT, 0);
// We should never be here
while(1);
+ break;
+ case EfiResetShutdown:
+ // Send the SHUTDOWN function to the platform microcontroller
+ ArmPlatformSysConfigSet (SYS_CFG_SHUTDOWN, 0);
+
+ // We should never be here
+ while(1);
+ break;
}
ASSERT(FALSE);
diff --git a/ArmPlatformPkg/Bds/Bds.c b/ArmPlatformPkg/Bds/Bds.c
index d1a17f1a7e..d0fc6a333f 100644
--- a/ArmPlatformPkg/Bds/Bds.c
+++ b/ArmPlatformPkg/Bds/Bds.c
@@ -277,13 +277,17 @@ DefineDefaultBootEntries (
}
BootArguments = (ARM_BDS_LOADER_ARGUMENTS*)AllocatePool (sizeof(ARM_BDS_LOADER_ARGUMENTS) + CmdLineSize + InitrdSize + FdtLocalSize);
- BootArguments->LinuxArguments.CmdLineSize = CmdLineSize;
- BootArguments->LinuxArguments.InitrdSize = InitrdSize;
- BootArguments->LinuxArguments.FdtLocalSize = FdtLocalSize;
-
- CopyMem ((VOID*)(BootArguments + 1), (CHAR8*)PcdGetPtr(PcdDefaultBootArgument), CmdLineSize);
- CopyMem ((VOID*)((UINTN)(BootArguments + 1) + CmdLineSize), InitrdPath, InitrdSize);
- CopyMem ((VOID*)((UINTN)(BootArguments + 1) + CmdLineSize + InitrdSize), FdtLocalPath, FdtLocalSize);
+ if ( BootArguments != NULL ) {
+ BootArguments->LinuxArguments.CmdLineSize = CmdLineSize;
+ BootArguments->LinuxArguments.InitrdSize = InitrdSize;
+ BootArguments->LinuxArguments.FdtLocalSize = FdtLocalSize;
+
+ CopyMem ((VOID*)(BootArguments + 1), (CHAR8*)PcdGetPtr(PcdDefaultBootArgument), CmdLineSize);
+ CopyMem ((VOID*)((UINTN)(BootArguments + 1) + CmdLineSize), InitrdPath, InitrdSize);
+ CopyMem ((VOID*)((UINTN)(BootArguments + 1) + CmdLineSize + InitrdSize), FdtLocalPath, FdtLocalSize);
+ }
+ FreePool (FdtLocalPath);
+ FreePool (InitrdPath);
} else {
BootArguments = NULL;
}
@@ -296,6 +300,7 @@ DefineDefaultBootEntries (
&BdsLoadOption
);
FreePool (BdsLoadOption);
+ FreePool (BootDevicePath);
} else {
Status = EFI_UNSUPPORTED;
}
@@ -417,6 +422,13 @@ BdsEntry (
UnicodeSPrint (gST->FirmwareVendor, Size, L"%a EFI %a %a", PcdGetPtr(PcdFirmwareVendor), __DATE__, __TIME__);
}
+ //
+ // Fixup Table CRC after we updated Firmware Vendor
+ //
+ gST->Hdr.CRC32 = 0;
+ Status = gBS->CalculateCrc32 ((VOID*)gST, gST->Hdr.HeaderSize, &gST->Hdr.CRC32);
+ ASSERT_EFI_ERROR (Status);
+
// If BootNext environment variable is defined then we just load it !
BootNextSize = sizeof(UINT16);
Status = GetGlobalEnvironmentVariable (L"BootNext", NULL, &BootNextSize, (VOID**)&BootNext);
@@ -459,6 +471,13 @@ BdsEntry (
// Now we need to setup the EFI System Table with information about the console devices.
InitializeConsole ();
+ //
+ // Update the CRC32 in the EFI System Table header
+ //
+ gST->Hdr.CRC32 = 0;
+ Status = gBS->CalculateCrc32 ((VOID*)gST, gST->Hdr.HeaderSize, &gST->Hdr.CRC32);
+ ASSERT_EFI_ERROR (Status);
+
// Timer before initiating the default boot selection
StartDefaultBootOnTimeout ();
diff --git a/ArmPlatformPkg/Bds/BdsHelper.c b/ArmPlatformPkg/Bds/BdsHelper.c
index cd7c8a5830..d1889f4396 100644
--- a/ArmPlatformPkg/Bds/BdsHelper.c
+++ b/ArmPlatformPkg/Bds/BdsHelper.c
@@ -1,6 +1,6 @@
/** @file
*
-* Copyright (c) 2011-2012, ARM Limited. All rights reserved.
+* Copyright (c) 2011-2013, ARM Limited. All rights reserved.
*
* This program and the accompanying materials
* are licensed and made available under the terms and conditions of the BSD License
@@ -26,9 +26,16 @@ EditHIInputStr (
EFI_INPUT_KEY Key;
EFI_STATUS Status;
+ // The command line must be at least one character long
+ ASSERT (MaxCmdLine > 0);
+
Print (CmdLine);
- for (CmdLineIndex = StrLen (CmdLine); CmdLineIndex < MaxCmdLine; ) {
+ // Ensure the last character of the buffer is the NULL character
+ CmdLine[MaxCmdLine - 1] = '\0';
+
+ // To prevent a buffer overflow, we only allow to enter (MaxCmdLine-1) characters
+ for (CmdLineIndex = StrLen (CmdLine); CmdLineIndex < MaxCmdLine-1; ) {
Status = gBS->WaitForEvent (1, &gST->ConIn->WaitForKey, &WaitIndex);
ASSERT_EFI_ERROR (Status);
diff --git a/ArmPlatformPkg/Bds/BdsInternal.h b/ArmPlatformPkg/Bds/BdsInternal.h
index aab37d0e0b..78300660cc 100644
--- a/ArmPlatformPkg/Bds/BdsInternal.h
+++ b/ArmPlatformPkg/Bds/BdsInternal.h
@@ -38,6 +38,11 @@
#define BOOT_DEVICE_OPTION_MAX 300
#define BOOT_DEVICE_ADDRESS_MAX (sizeof(L"0x0000000000000000"))
+// Length of the buffer used to hold the user input for the main menu
+// This includes the NULL terminator
+// 1 chars + newline + NULL gives room for up to 9 boot device configs
+#define BOOT_OPTION_LEN 3
+
#define ARM_BDS_OPTIONAL_DATA_SIGNATURE SIGNATURE_32('a', 'b', 'o', 'd')
#define IS_ARM_BDS_BOOTENTRY(ptr) (ReadUnaligned32 ((CONST UINT32*)&((ARM_BDS_LOADER_OPTIONAL_DATA*)((ptr)->OptionalData))->Header.Signature) == ARM_BDS_OPTIONAL_DATA_SIGNATURE)
diff --git a/ArmPlatformPkg/Bds/BootMenu.c b/ArmPlatformPkg/Bds/BootMenu.c
index 2280e8c3cb..de2117b248 100644
--- a/ArmPlatformPkg/Bds/BootMenu.c
+++ b/ArmPlatformPkg/Bds/BootMenu.c
@@ -163,7 +163,7 @@ BootMenuAddBootOption (
Status = GetHIInputBoolean (&InitrdSupport);
if (EFI_ERROR(Status)) {
Status = EFI_ABORTED;
- goto EXIT;
+ goto FREE_DEVICE_PATH;
}
if (InitrdSupport) {
@@ -171,7 +171,7 @@ BootMenuAddBootOption (
Status = SupportedBootDevice->Support->CreateDevicePathNode (L"initrd", &InitrdPathNodes, NULL, NULL);
if (EFI_ERROR(Status) && Status != EFI_NOT_FOUND) { // EFI_NOT_FOUND is returned on empty input string, but we can boot without an initrd
Status = EFI_ABORTED;
- goto EXIT;
+ goto FREE_DEVICE_PATH;
}
if (InitrdPathNodes != NULL) {
@@ -179,7 +179,7 @@ BootMenuAddBootOption (
InitrdPath = AppendDevicePath (SupportedBootDevice->DevicePathProtocol, (CONST EFI_DEVICE_PATH_PROTOCOL *)InitrdPathNodes);
if (InitrdPath == NULL) {
Status = EFI_OUT_OF_RESOURCES;
- goto EXIT;
+ goto FREE_DEVICE_PATH;
}
} else {
InitrdPath = NULL;
@@ -200,7 +200,7 @@ BootMenuAddBootOption (
Status = SupportedBootDevice->Support->CreateDevicePathNode (L"local FDT", &FdtLocalPathNode, NULL, NULL);
if (EFI_ERROR(Status) || (FdtLocalPathNode == NULL)) {
Status = EFI_ABORTED;
- goto EXIT;
+ goto FREE_DEVICE_PATH;
}
if (FdtLocalPathNode != NULL) {
@@ -218,13 +218,14 @@ BootMenuAddBootOption (
FdtLocalSize = GetDevicePathSize (FdtLocalPath);
BootArguments = (ARM_BDS_LOADER_ARGUMENTS*)AllocatePool (sizeof(ARM_BDS_LOADER_ARGUMENTS) + CmdLineSize + InitrdSize + FdtLocalSize);
-
- BootArguments->LinuxArguments.CmdLineSize = CmdLineSize;
- BootArguments->LinuxArguments.InitrdSize = InitrdSize;
- BootArguments->LinuxArguments.FdtLocalSize = FdtLocalSize;
- CopyMem ((VOID*)(&BootArguments->LinuxArguments + 1), CmdLine, CmdLineSize);
- CopyMem ((VOID*)((UINTN)(&BootArguments->LinuxArguments + 1) + CmdLineSize), InitrdPath, InitrdSize);
- CopyMem ((VOID*)((UINTN)(&BootArguments->LinuxArguments + 1) + CmdLineSize + InitrdSize), FdtLocalPath, FdtLocalSize);
+ if ( BootArguments != NULL ) {
+ BootArguments->LinuxArguments.CmdLineSize = CmdLineSize;
+ BootArguments->LinuxArguments.InitrdSize = InitrdSize;
+ BootArguments->LinuxArguments.FdtLocalSize = FdtLocalSize;
+ CopyMem ((VOID*)(&BootArguments->LinuxArguments + 1), CmdLine, CmdLineSize);
+ CopyMem ((VOID*)((UINTN)(&BootArguments->LinuxArguments + 1) + CmdLineSize), InitrdPath, InitrdSize);
+ CopyMem ((VOID*)((UINTN)(&BootArguments->LinuxArguments + 1) + CmdLineSize + InitrdSize), FdtLocalPath, FdtLocalSize);
+ }
} else {
BootArguments = NULL;
}
@@ -238,6 +239,10 @@ BootMenuAddBootOption (
// Create new entry
BdsLoadOptionEntry = (BDS_LOAD_OPTION_ENTRY*)AllocatePool (sizeof(BDS_LOAD_OPTION_ENTRY));
+ if ( BdsLoadOptionEntry == NULL ) {
+ Status = EFI_ABORTED;
+ goto FREE_DEVICE_PATH;
+ }
Status = BootOptionCreate (Attributes, BootDescription, DevicePath, BootType, BootArguments, &BdsLoadOptionEntry->BdsLoadOption);
if (!EFI_ERROR(Status)) {
InsertTailList (BootOptionsList, &BdsLoadOptionEntry->Link);
@@ -466,12 +471,14 @@ BootMenuUpdateBootOption (
if (FdtLocalPathNode != NULL) {
// Duplicate Linux kernel Device Path
TempFdtLocalPath = DuplicateDevicePath (BootOption->FilePathList);
- // Replace Linux kernel Node by EndNode
- SetDevicePathEndNode (GetLastDevicePathNode (TempFdtLocalPath));
- // Append the Device Path node to the select device path
- FdtLocalPath = AppendDevicePathNode (TempFdtLocalPath, (CONST EFI_DEVICE_PATH_PROTOCOL *)FdtLocalPathNode);
- FreePool (TempFdtLocalPath);
- FdtLocalSize = GetDevicePathSize (FdtLocalPath);
+ if ( TempFdtLocalPath != NULL ) {
+ // Replace Linux kernel Node by EndNode
+ SetDevicePathEndNode (GetLastDevicePathNode (TempFdtLocalPath));
+ // Append the Device Path node to the select device path
+ FdtLocalPath = AppendDevicePathNode (TempFdtLocalPath, (CONST EFI_DEVICE_PATH_PROTOCOL *)FdtLocalPathNode);
+ FreePool (TempFdtLocalPath);
+ FdtLocalSize = GetDevicePathSize (FdtLocalPath);
+ }
} else {
FdtLocalPath = NULL;
}
@@ -548,12 +555,14 @@ BootMenuUpdateBootOption (
CmdLineSize = AsciiStrSize (CmdLine);
BootArguments = (ARM_BDS_LOADER_ARGUMENTS*)AllocatePool(sizeof(ARM_BDS_LOADER_ARGUMENTS) + CmdLineSize + InitrdSize + FdtLocalSize);
- BootArguments->LinuxArguments.CmdLineSize = CmdLineSize;
- BootArguments->LinuxArguments.InitrdSize = InitrdSize;
- BootArguments->LinuxArguments.FdtLocalSize = FdtLocalSize;
- CopyMem (&BootArguments->LinuxArguments + 1, CmdLine, CmdLineSize);
- CopyMem ((VOID*)((UINTN)(&BootArguments->LinuxArguments + 1) + CmdLineSize), InitrdPath, InitrdSize);
- CopyMem ((VOID*)((UINTN)(&BootArguments->LinuxArguments + 1) + CmdLineSize + InitrdSize), FdtLocalPath, FdtLocalSize);
+ if ( BootArguments != NULL ) {
+ BootArguments->LinuxArguments.CmdLineSize = CmdLineSize;
+ BootArguments->LinuxArguments.InitrdSize = InitrdSize;
+ BootArguments->LinuxArguments.FdtLocalSize = FdtLocalSize;
+ CopyMem (&BootArguments->LinuxArguments + 1, CmdLine, CmdLineSize);
+ CopyMem ((VOID*)((UINTN)(&BootArguments->LinuxArguments + 1) + CmdLineSize), InitrdPath, InitrdSize);
+ CopyMem ((VOID*)((UINTN)(&BootArguments->LinuxArguments + 1) + CmdLineSize + InitrdSize), FdtLocalPath, FdtLocalSize);
+ }
} else {
BootArguments = NULL;
}
@@ -696,12 +705,32 @@ BootShell (
return Status;
}
+EFI_STATUS
+Reboot (
+ IN LIST_ENTRY *BootOptionsList
+ )
+{
+ gRT->ResetSystem(EfiResetCold, EFI_SUCCESS, 0, NULL);
+ return EFI_UNSUPPORTED;
+}
+
+EFI_STATUS
+Shutdown (
+ IN LIST_ENTRY *BootOptionsList
+ )
+{
+ gRT->ResetSystem(EfiResetShutdown, EFI_SUCCESS, 0, NULL);
+ return EFI_UNSUPPORTED;
+}
+
struct BOOT_MAIN_ENTRY {
CONST CHAR16* Description;
EFI_STATUS (*Callback) (IN LIST_ENTRY *BootOptionsList);
} BootMainEntries[] = {
{ L"Boot Manager", BootMenuManager },
{ L"Shell", BootShell },
+ { L"Reboot", Reboot },
+ { L"Shutdown", Shutdown },
};
@@ -710,19 +739,20 @@ BootMenuMain (
VOID
)
{
- LIST_ENTRY BootOptionsList;
- UINTN OptionCount;
- UINTN HardCodedOptionCount;
- UINTN BootOptionCount;
- EFI_STATUS Status;
- LIST_ENTRY* Entry;
- BDS_LOAD_OPTION* BootOption;
- UINTN BootOptionSelected;
- UINTN Index;
- UINTN BootMainEntryCount;
- CHAR8 BootOptionSelectedStr[32];
- EFI_DEVICE_PATH_PROTOCOL* DefaultFdtDevicePath;
- UINTN FdtDevicePathSize;
+ LIST_ENTRY BootOptionsList;
+ UINTN OptionCount;
+ UINTN BootOptionCount;
+ EFI_STATUS Status;
+ LIST_ENTRY* Entry;
+ BDS_LOAD_OPTION* BootOption;
+ UINTN BootOptionSelected;
+ UINTN Index;
+ UINTN BootMainEntryCount;
+ CHAR8 BootOptionSelectedStr[BOOT_OPTION_LEN];
+ EFI_DEVICE_PATH_PROTOCOL* DefaultFdtDevicePath;
+ UINTN FdtDevicePathSize;
+ EFI_DEVICE_PATH_TO_TEXT_PROTOCOL* DevicePathToTextProtocol;
+ CHAR16* DevicePathTxt;
BootOption = NULL;
@@ -745,8 +775,6 @@ BootMenuMain (
Print(L"[%d] %s\n", OptionCount, BootOption->Description);
//DEBUG_CODE_BEGIN();
- CHAR16* DevicePathTxt;
- EFI_DEVICE_PATH_TO_TEXT_PROTOCOL* DevicePathToTextProtocol;
ARM_BDS_LOADER_OPTIONAL_DATA* OptionalData;
UINTN CmdLineSize;
UINTN InitrdSize;
@@ -814,55 +842,56 @@ BootMenuMain (
// Display the global FDT config
Print(L"-----------------------\n");
- {
- EFI_DEVICE_PATH_FROM_TEXT_PROTOCOL* EfiDevicePathFromTextProtocol;
- EFI_DEVICE_PATH_PROTOCOL* FdtDevicePath;
- EFI_DEVICE_PATH_TO_TEXT_PROTOCOL* DevicePathToTextProtocol;
- CHAR16* DevicePathTxt;
+ {
+ EFI_DEVICE_PATH_FROM_TEXT_PROTOCOL* EfiDevicePathFromTextProtocol;
+ EFI_DEVICE_PATH_PROTOCOL* FdtDevicePath;
- // Get the default FDT device path
- Status = gBS->LocateProtocol (&gEfiDevicePathFromTextProtocolGuid, NULL, (VOID **)&EfiDevicePathFromTextProtocol);
- ASSERT_EFI_ERROR(Status);
- DefaultFdtDevicePath = EfiDevicePathFromTextProtocol->ConvertTextToDevicePath ((CHAR16*)PcdGetPtr(PcdFdtDevicePath));
+ // Get the default FDT device path
+ Status = gBS->LocateProtocol (&gEfiDevicePathFromTextProtocolGuid, NULL, (VOID **)&EfiDevicePathFromTextProtocol);
+ ASSERT_EFI_ERROR(Status);
+ DefaultFdtDevicePath = EfiDevicePathFromTextProtocol->ConvertTextToDevicePath ((CHAR16*)PcdGetPtr(PcdFdtDevicePath));
- // Get the FDT device path
- FdtDevicePathSize = GetDevicePathSize (DefaultFdtDevicePath);
- Status = GetEnvironmentVariable ((CHAR16 *)L"Fdt", &gArmGlobalVariableGuid, DefaultFdtDevicePath, &FdtDevicePathSize, (VOID **)&FdtDevicePath);
+ // Get the FDT device path
+ FdtDevicePathSize = GetDevicePathSize (DefaultFdtDevicePath);
+ Status = GetEnvironmentVariable ((CHAR16 *)L"Fdt", &gArmGlobalVariableGuid, DefaultFdtDevicePath, &FdtDevicePathSize, (VOID **)&FdtDevicePath);
- // Convert FdtDevicePath to text
- if (EFI_ERROR(Status)) {
- DevicePathTxt = L"not configured";
- } else {
- Status = gBS->LocateProtocol (&gEfiDevicePathToTextProtocolGuid, NULL, (VOID **)&DevicePathToTextProtocol);
- DevicePathTxt = DevicePathToTextProtocol->ConvertDevicePathToText ( FdtDevicePath, TRUE, TRUE );
- }
- Print(L"Global FDT Config\n\t- %s\n", DevicePathTxt);
+ // Convert FdtDevicePath to text
+ if (EFI_ERROR(Status)) {
+ DevicePathTxt = L"not configured";
+ } else {
+ Status = gBS->LocateProtocol (&gEfiDevicePathToTextProtocolGuid, NULL, (VOID **)&DevicePathToTextProtocol);
+ DevicePathTxt = DevicePathToTextProtocol->ConvertDevicePathToText ( FdtDevicePath, TRUE, TRUE );
}
+ Print(L"Global FDT Config\n\t- %s\n", DevicePathTxt);
+ FreePool(DevicePathTxt);
+ FreePool(DefaultFdtDevicePath);
+ }
// Display the hardcoded Boot entries
Print(L"-----------------------\n");
for (Index = 0; Index < BootMainEntryCount; Index++) {
- Print(L"[%c] %s\n", ('a'+Index), BootMainEntries[Index]);
+ Print(L"[%c] %s\n", ('a' + Index), BootMainEntries[Index]);
OptionCount++;
}
- HardCodedOptionCount=Index;
// Request the boot entry from the user
BootOptionSelected = 0;
while (BootOptionSelected == 0) {
Print(L"Start: ");
- Status = GetHIInputAscii (BootOptionSelectedStr,8);
+ Status = GetHIInputAscii (BootOptionSelectedStr, BOOT_OPTION_LEN);
- if (BootOptionSelectedStr[0]-'0' <= OptionCount) {
- BootOptionSelected = BootOptionSelectedStr[0] - '0';
- } else if (BootOptionSelectedStr[0]-'a' <= HardCodedOptionCount) {
- BootOptionSelected = BootOptionCount + 1 + BootOptionSelectedStr[0] - 'a';
- }
+ if (!EFI_ERROR(Status)) {
+ if ((BootOptionSelectedStr[0] - '0') < OptionCount) {
+ BootOptionSelected = BootOptionSelectedStr[0] - '0';
+ } else if ((BootOptionSelectedStr[0] - 'a') < BootMainEntryCount) {
+ BootOptionSelected = BootOptionCount + 1 + BootOptionSelectedStr[0] - 'a';
+ }
- if (EFI_ERROR(Status) || (BootOptionSelected == 0) || (BootOptionSelected > OptionCount)) {
- Print(L"Invalid input (max %d)\n",(OptionCount-1));
- BootOptionSelected = 0;
- }
+ if ((BootOptionSelected == 0) || (BootOptionSelected > OptionCount)) {
+ Print(L"Invalid input, please choose a menu option from the list above\n");
+ BootOptionSelected = 0;
+ }
+ }
}
// Start the selected entry
diff --git a/ArmPlatformPkg/Bds/BootOption.c b/ArmPlatformPkg/Bds/BootOption.c
index 0ecccd3121..6b756a30c0 100644
--- a/ArmPlatformPkg/Bds/BootOption.c
+++ b/ArmPlatformPkg/Bds/BootOption.c
@@ -90,6 +90,7 @@ BootOptionStart (
Status = GetEnvironmentVariable ((CHAR16 *)L"Fdt", &gArmGlobalVariableGuid,
DefaultFdtDevicePath, &FdtDevicePathSize, (VOID **)&FdtDevicePath);
ASSERT_EFI_ERROR(Status);
+ FreePool (DefaultFdtDevicePath);
}
Status = BdsBootLinuxFdt (BootOption->FilePathList,
Initrd, // Initrd
diff --git a/ArmPlatformPkg/Bds/BootOptionSupport.c b/ArmPlatformPkg/Bds/BootOptionSupport.c
index cf69175d8c..c2df7f9cc2 100644
--- a/ArmPlatformPkg/Bds/BootOptionSupport.c
+++ b/ArmPlatformPkg/Bds/BootOptionSupport.c
@@ -25,7 +25,7 @@
#include <Guid/FileSystemInfo.h>
#define IS_DEVICE_PATH_NODE(node,type,subtype) (((node)->Type == (type)) && ((node)->SubType == (subtype)))
-#define LOCAL_FDT_RESPONSE_LEN 2 // 1 character, plus carriage return
+#define LOCAL_FDT_RESPONSE_LEN 2 // 1 character, plus carriage return
EFI_STATUS
BdsLoadOptionFileSystemList (
diff --git a/ArmPlatformPkg/Drivers/NorFlashDxe/NorFlashBlockIoDxe.c b/ArmPlatformPkg/Drivers/NorFlashDxe/NorFlashBlockIoDxe.c
index 21fceac1dc..279b77c75e 100644
--- a/ArmPlatformPkg/Drivers/NorFlashDxe/NorFlashBlockIoDxe.c
+++ b/ArmPlatformPkg/Drivers/NorFlashDxe/NorFlashBlockIoDxe.c
@@ -1,6 +1,6 @@
/** @file NorFlashBlockIoDxe.c
- Copyright (c) 2011-2012, ARM Ltd. All rights reserved.<BR>
+ Copyright (c) 2011-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
@@ -51,17 +51,27 @@ NorFlashBlockIoReadBlocks (
{
NOR_FLASH_INSTANCE *Instance;
EFI_STATUS Status;
+ EFI_BLOCK_IO_MEDIA *Media;
+
+ if (This == NULL) {
+ return EFI_INVALID_PARAMETER;
+ }
Instance = INSTANCE_FROM_BLKIO_THIS(This);
+ Media = This->Media;
DEBUG ((DEBUG_BLKIO, "NorFlashBlockIoReadBlocks(MediaId=0x%x, Lba=%ld, BufferSize=0x%x bytes (%d kB), BufferPtr @ 0x%08x)\n", MediaId, Lba, BufferSizeInBytes, Buffer));
- if( !This->Media->MediaPresent ) {
+ if (!Media) {
+ Status = EFI_INVALID_PARAMETER;
+ } else if (!Media->MediaPresent) {
Status = EFI_NO_MEDIA;
- } else if( This->Media->MediaId != MediaId ) {
+ } else if (Media->MediaId != MediaId) {
Status = EFI_MEDIA_CHANGED;
+ } else if ((Media->IoAlign > 2) && (((UINTN)Buffer & (Media->IoAlign - 1)) != 0)) {
+ Status = EFI_INVALID_PARAMETER;
} else {
- Status = NorFlashReadBlocks (Instance,Lba,BufferSizeInBytes,Buffer);
+ Status = NorFlashReadBlocks (Instance, Lba, BufferSizeInBytes, Buffer);
}
return Status;
diff --git a/ArmPlatformPkg/Drivers/NorFlashDxe/NorFlashDxe.c b/ArmPlatformPkg/Drivers/NorFlashDxe/NorFlashDxe.c
index a9c589b744..7953b6c9f5 100644
--- a/ArmPlatformPkg/Drivers/NorFlashDxe/NorFlashDxe.c
+++ b/ArmPlatformPkg/Drivers/NorFlashDxe/NorFlashDxe.c
@@ -1,6 +1,6 @@
/** @file NorFlashDxe.c
- Copyright (c) 2011-2012, ARM Ltd. All rights reserved.<BR>
+ Copyright (c) 2011-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
@@ -721,19 +721,20 @@ NorFlashReadBlocks (
UINT32 NumBlocks;
UINTN StartAddress;
+ DEBUG((DEBUG_BLKIO, "NorFlashReadBlocks: BufferSize=0x%xB BlockSize=0x%xB LastBlock=%ld, Lba=%ld.\n",
+ BufferSizeInBytes, Instance->Media.BlockSize, Instance->Media.LastBlock, Lba));
+
// The buffer must be valid
if (Buffer == NULL) {
return EFI_INVALID_PARAMETER;
}
- // We must have some bytes to read
- DEBUG((DEBUG_BLKIO, "NorFlashReadBlocks: BufferSize=0x%x bytes.\n", BufferSizeInBytes));
- if(BufferSizeInBytes == 0) {
- return EFI_BAD_BUFFER_SIZE;
+ // Return if we have not any byte to read
+ if (BufferSizeInBytes == 0) {
+ return EFI_SUCCESS;
}
// The size of the buffer must be a multiple of the block size
- DEBUG((DEBUG_BLKIO, "NorFlashReadBlocks: BlockSize=0x%x bytes.\n", Instance->Media.BlockSize));
if ((BufferSizeInBytes % Instance->Media.BlockSize) != 0) {
return EFI_BAD_BUFFER_SIZE;
}
@@ -741,8 +742,6 @@ NorFlashReadBlocks (
// All blocks must be within the device
NumBlocks = ((UINT32)BufferSizeInBytes) / Instance->Media.BlockSize ;
- DEBUG((DEBUG_BLKIO, "NorFlashReadBlocks: NumBlocks=%d, LastBlock=%ld, Lba=%ld\n", NumBlocks, Instance->Media.LastBlock, Lba));
-
if ((Lba + NumBlocks) > (Instance->Media.LastBlock + 1)) {
DEBUG((EFI_D_ERROR, "NorFlashReadBlocks: ERROR - Read will exceed last block\n"));
return EFI_INVALID_PARAMETER;
diff --git a/ArmPlatformPkg/Drivers/PL011Uart/PL011Uart.c b/ArmPlatformPkg/Drivers/PL011Uart/PL011Uart.c
index 2af207829d..fdb9ff490e 100644
--- a/ArmPlatformPkg/Drivers/PL011Uart/PL011Uart.c
+++ b/ArmPlatformPkg/Drivers/PL011Uart/PL011Uart.c
@@ -2,7 +2,7 @@
Serial I/O Port library functions with no library constructor/destructor
Copyright (c) 2008 - 2010, Apple Inc. All rights reserved.<BR>
- Copyright (c) 2011 - 2012, ARM Ltd. All rights reserved.<BR>
+ Copyright (c) 2011 - 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
@@ -31,40 +31,37 @@
RETURN_STATUS
EFIAPI
PL011UartInitializePort (
- IN UINTN UartBase,
- IN UINT64 BaudRate,
- IN UINT32 ReceiveFifoDepth,
- IN EFI_PARITY_TYPE Parity,
- IN UINT8 DataBits,
- IN EFI_STOP_BITS_TYPE StopBits
+ IN OUT UINTN UartBase,
+ IN OUT UINT64 *BaudRate,
+ IN OUT UINT32 *ReceiveFifoDepth,
+ IN OUT EFI_PARITY_TYPE *Parity,
+ IN OUT UINT8 *DataBits,
+ IN OUT EFI_STOP_BITS_TYPE *StopBits
)
{
UINT32 LineControl;
UINT32 Divisor;
- // The BaudRate must be passed
- if (BaudRate == 0) {
- return RETURN_INVALID_PARAMETER;
- }
-
LineControl = 0;
// The PL011 supports a buffer of either 1 or 32 chars. Therefore we can accept
// 1 char buffer as the minimum fifo size. Because everything can be rounded down,
// there is no maximum fifo size.
- if (ReceiveFifoDepth == 0) {
+ if ((*ReceiveFifoDepth == 0) || (*ReceiveFifoDepth >= 32)) {
LineControl |= PL011_UARTLCR_H_FEN;
- } else if (ReceiveFifoDepth < 32) {
+ *ReceiveFifoDepth = 32;
+ } else {
+ ASSERT (*ReceiveFifoDepth < 32);
// Nothing else to do. 1 byte fifo is default.
- } else if (ReceiveFifoDepth >= 32) {
- LineControl |= PL011_UARTLCR_H_FEN;
+ *ReceiveFifoDepth = 1;
}
//
// Parity
//
- switch (Parity) {
+ switch (*Parity) {
case DefaultParity:
+ *Parity = NoParity;
case NoParity:
// Nothing to do. Parity is disabled by default.
break;
@@ -87,8 +84,9 @@ PL011UartInitializePort (
//
// Data Bits
//
- switch (DataBits) {
+ switch (*DataBits) {
case 0:
+ *DataBits = 8;
case 8:
LineControl |= PL011_UARTLCR_H_WLEN_8;
break;
@@ -108,8 +106,9 @@ PL011UartInitializePort (
//
// Stop Bits
//
- switch (StopBits) {
+ switch (*StopBits) {
case DefaultStopBits:
+ *StopBits = OneStopBit;
case OneStopBit:
// Nothing to do. One stop bit is enabled by default.
break;
@@ -130,11 +129,21 @@ PL011UartInitializePort (
//
// Baud Rate
//
- if (PcdGet32(PL011UartInteger) != 0) {
- MmioWrite32 (UartBase + UARTIBRD, PcdGet32(PL011UartInteger));
- MmioWrite32 (UartBase + UARTFBRD, PcdGet32(PL011UartFractional));
- } else {
- Divisor = (PcdGet32 (PL011UartClkInHz) * 4) / BaudRate;
+
+ // If BaudRate is zero then use default baud rate
+ if (BaudRate == 0) {
+ if (PcdGet32 (PL011UartInteger) != 0) {
+ MmioWrite32 (UartBase + UARTIBRD, PcdGet32 (PL011UartInteger));
+ MmioWrite32 (UartBase + UARTFBRD, PcdGet32 (PL011UartFractional));
+ } else {
+ *BaudRate = PcdGet32 (PcdSerialBaudRate);
+ ASSERT (*BaudRate != 0);
+ }
+ }
+
+ // If BaudRate != 0 then we must calculate the divisor from the value
+ if (*BaudRate != 0) {
+ Divisor = (PcdGet32 (PL011UartClkInHz) * 4) / *BaudRate;
MmioWrite32 (UartBase + UARTIBRD, Divisor >> 6);
MmioWrite32 (UartBase + UARTFBRD, Divisor & 0x3F);
}
diff --git a/ArmPlatformPkg/Drivers/PL011Uart/PL011Uart.inf b/ArmPlatformPkg/Drivers/PL011Uart/PL011Uart.inf
index 6347ba63f3..7f7709aecf 100644
--- a/ArmPlatformPkg/Drivers/PL011Uart/PL011Uart.inf
+++ b/ArmPlatformPkg/Drivers/PL011Uart/PL011Uart.inf
@@ -2,7 +2,7 @@
#
# Component description file for PL011Uart module
#
-# Copyright (c) 2011-2012, ARM Ltd. All rights reserved.<BR>
+# Copyright (c) 2011-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
@@ -31,9 +31,12 @@
[Packages]
MdePkg/MdePkg.dec
+ MdeModulePkg/MdeModulePkg.dec
ArmPlatformPkg/ArmPlatformPkg.dec
[Pcd]
+ gEfiMdeModulePkgTokenSpaceGuid.PcdSerialBaudRate
+
gArmPlatformTokenSpaceGuid.PL011UartClkInHz
gArmPlatformTokenSpaceGuid.PL011UartInteger
gArmPlatformTokenSpaceGuid.PL011UartFractional
diff --git a/ArmPlatformPkg/Include/Drivers/PL011Uart.h b/ArmPlatformPkg/Include/Drivers/PL011Uart.h
index 354f111032..23e9a94347 100644
--- a/ArmPlatformPkg/Include/Drivers/PL011Uart.h
+++ b/ArmPlatformPkg/Include/Drivers/PL011Uart.h
@@ -91,12 +91,12 @@
RETURN_STATUS
EFIAPI
PL011UartInitializePort (
- IN UINTN UartBase,
- IN UINT64 BaudRate,
- IN UINT32 ReceiveFifoDepth,
- IN EFI_PARITY_TYPE Parity,
- IN UINT8 DataBits,
- IN EFI_STOP_BITS_TYPE StopBits
+ IN OUT UINTN UartBase,
+ IN OUT UINT64 *BaudRate,
+ IN OUT UINT32 *ReceiveFifoDepth,
+ IN OUT EFI_PARITY_TYPE *Parity,
+ IN OUT UINT8 *DataBits,
+ IN OUT EFI_STOP_BITS_TYPE *StopBits
);
/**
diff --git a/ArmPlatformPkg/Include/Library/ArmPlatformLib.h b/ArmPlatformPkg/Include/Library/ArmPlatformLib.h
index 7bbd966470..94ad5c176f 100644
--- a/ArmPlatformPkg/Include/Library/ArmPlatformLib.h
+++ b/ArmPlatformPkg/Include/Library/ArmPlatformLib.h
@@ -1,6 +1,6 @@
/** @file
*
-* Copyright (c) 2011-2012, ARM Limited. All rights reserved.
+* Copyright (c) 2011-2013, ARM Limited. All rights reserved.
*
* This program and the accompanying materials
* are licensed and made available under the terms and conditions of the BSD License
@@ -24,7 +24,6 @@
//
#include <Ppi/MasterBootMode.h>
#include <Ppi/BootInRecoveryMode.h>
-#include <Guid/MemoryTypeInformation.h>
#include <Library/ArmLib.h>
@@ -41,12 +40,50 @@ typedef struct {
UINT64 NumberOfBytes;
} ARM_SYSTEM_MEMORY_REGION_DESCRIPTOR;
+/**
+ Return the core position from the value of its MpId register
+
+ This function returns the core position from the position 0 in the processor.
+ This function might be called from assembler before any stack is set.
+
+ @return Return the core position
+
+**/
UINTN
ArmPlatformGetCorePosition (
IN UINTN MpId
);
/**
+ Return a non-zero value if the callee is the primary core
+
+ This function returns a non-zero value if the callee is the primary core.
+ The primary core is the core responsible to initialize the hardware and run UEFI.
+ This function might be called from assembler before any stack is set.
+
+ @return Return a non-zero value if the callee is the primary core.
+
+**/
+UINTN
+ArmPlatformIsPrimaryCore (
+ IN UINTN MpId
+ );
+
+/**
+ Return the MpId of the primary core
+
+ This function returns the MpId of the primary core.
+ This function might be called from assembler before any stack is set.
+
+ @return Return the MpId of the primary core
+
+**/
+UINTN
+ArmPlatformGetPrimaryCoreMpId (
+ VOID
+ );
+
+/**
Return the current Boot Mode
This function returns the boot reason on the platform
@@ -98,21 +135,6 @@ ArmPlatformGetVirtualMemoryMap (
);
/**
- Return the EFI Memory Map of your platform
-
- This EFI Memory Map of the System Memory is used by MemoryInitPei module to create the Resource
- Descriptor HOBs used by DXE core.
-
- @param[out] EfiMemoryMap Array of ARM_SYSTEM_MEMORY_REGION_DESCRIPTOR describing an
- EFI Memory region. This array must be ended by a zero-filled entry
-
-**/
-EFI_STATUS
-ArmPlatformGetAdditionalSystemMemory (
- OUT ARM_SYSTEM_MEMORY_REGION_DESCRIPTOR** EfiMemoryMap
- );
-
-/**
Return the Platform specific PPIs
This function exposes the Platform Specific PPIs. They can be used by any PrePi modules or passed
diff --git a/ArmPlatformPkg/Library/ArmPlatformLibNull/Arm/ArmPlatformHelper.S b/ArmPlatformPkg/Library/ArmPlatformLibNull/Arm/ArmPlatformHelper.S
index 286327956a..49f3fde667 100644
--- a/ArmPlatformPkg/Library/ArmPlatformLibNull/Arm/ArmPlatformHelper.S
+++ b/ArmPlatformPkg/Library/ArmPlatformLibNull/Arm/ArmPlatformHelper.S
@@ -1,5 +1,5 @@
//
-// Copyright (c) 2012, ARM Limited. All rights reserved.
+// Copyright (c) 2012-2013, ARM Limited. All rights reserved.
//
// This program and the accompanying materials
// are licensed and made available under the terms and conditions of the BSD License
@@ -11,12 +11,22 @@
//
//
+#include <AsmMacroIoLib.h>
#include <Library/ArmLib.h>
.text
-.align 3
+.align 2
+GCC_ASM_EXPORT(ArmPlatformPeiBootAction)
GCC_ASM_EXPORT(ArmPlatformGetCorePosition)
+GCC_ASM_EXPORT(ArmPlatformGetPrimaryCoreMpId)
+GCC_ASM_EXPORT(ArmPlatformIsPrimaryCore)
+
+GCC_ASM_IMPORT(_gPcd_FixedAtBuild_PcdArmPrimaryCore)
+GCC_ASM_IMPORT(_gPcd_FixedAtBuild_PcdArmPrimaryCoreMask)
+
+ASM_PFX(ArmPlatformPeiBootAction):
+ bx lr
//UINTN
//ArmPlatformGetCorePosition (
@@ -28,3 +38,26 @@ ASM_PFX(ArmPlatformGetCorePosition):
add r0, r1, r0, LSR #7
bx lr
+//UINTN
+//ArmPlatformGetPrimaryCoreMpId (
+// VOID
+// );
+ASM_PFX(ArmPlatformGetPrimaryCoreMpId):
+ LoadConstantToReg (_gPcd_FixedAtBuild_PcdArmPrimaryCoreMask, r0)
+ ldr r0, [r0]
+ bx lr
+
+//UINTN
+//ArmPlatformIsPrimaryCore (
+// IN UINTN MpId
+// );
+ASM_PFX(ArmPlatformIsPrimaryCore):
+ LoadConstantToReg (_gPcd_FixedAtBuild_PcdArmPrimaryCoreMask, r1)
+ ldr r1, [r1]
+ and r0, r0, r1
+ LoadConstantToReg (_gPcd_FixedAtBuild_PcdArmPrimaryCore, r1)
+ ldr r1, [r1]
+ cmp r0, r1
+ moveq r0, #1
+ movne r0, #0
+ bx lr
diff --git a/ArmPlatformPkg/Library/ArmPlatformLibNull/Arm/ArmPlatformHelper.asm b/ArmPlatformPkg/Library/ArmPlatformLibNull/Arm/ArmPlatformHelper.asm
index 620562136e..6047ca25c4 100644
--- a/ArmPlatformPkg/Library/ArmPlatformLibNull/Arm/ArmPlatformHelper.asm
+++ b/ArmPlatformPkg/Library/ArmPlatformLibNull/Arm/ArmPlatformHelper.asm
@@ -1,5 +1,5 @@
//
-// Copyright (c) 2012, ARM Limited. All rights reserved.
+// Copyright (c) 2012-2013, ARM Limited. All rights reserved.
//
// This program and the accompanying materials
// are licensed and made available under the terms and conditions of the BSD License
@@ -16,11 +16,21 @@
INCLUDE AsmMacroIoLib.inc
+ EXPORT ArmPlatformPeiBootAction
EXPORT ArmPlatformGetCorePosition
+ EXPORT ArmPlatformGetPrimaryCoreMpId
+ EXPORT ArmPlatformIsPrimaryCore
+ IMPORT _gPcd_FixedAtBuild_PcdArmPrimaryCore
+ IMPORT _gPcd_FixedAtBuild_PcdArmPrimaryCoreMask
+
PRESERVE8
AREA ArmPlatformNullHelper, CODE, READONLY
+ArmPlatformPeiBootAction FUNCTION
+ bx lr
+ ENDFUNC
+
//UINTN
//ArmPlatformGetCorePosition (
// IN UINTN MpId
@@ -32,5 +42,31 @@ ArmPlatformGetCorePosition FUNCTION
bx lr
ENDFUNC
+//UINTN
+//ArmPlatformGetPrimaryCoreMpId (
+// VOID
+// );
+ArmPlatformGetPrimaryCoreMpId FUNCTION
+ LoadConstantToReg (_gPcd_FixedAtBuild_PcdArmPrimaryCoreMask, r0)
+ ldr r0, [r0]
+ bx lr
+ ENDFUNC
+
+//UINTN
+//ArmPlatformIsPrimaryCore (
+// IN UINTN MpId
+// );
+ArmPlatformIsPrimaryCore FUNCTION
+ LoadConstantToReg (_gPcd_FixedAtBuild_PcdArmPrimaryCoreMask, r1)
+ ldr r1, [r1]
+ and r0, r0, r1
+ LoadConstantToReg (_gPcd_FixedAtBuild_PcdArmPrimaryCore, r1)
+ ldr r1, [r1]
+ cmp r0, r1
+ moveq r0, #1
+ movne r0, #0
+ bx lr
+ ENDFUNC
+
END
diff --git a/ArmPlatformPkg/Library/ArmPlatformLibNull/ArmPlatformLibNull.c b/ArmPlatformPkg/Library/ArmPlatformLibNull/ArmPlatformLibNull.c
index f3a7efcae0..b45c11b4e1 100644
--- a/ArmPlatformPkg/Library/ArmPlatformLibNull/ArmPlatformLibNull.c
+++ b/ArmPlatformPkg/Library/ArmPlatformLibNull/ArmPlatformLibNull.c
@@ -97,7 +97,7 @@ ArmPlatformInitialize (
IN UINTN MpId
)
{
- if (!IS_PRIMARY_CORE(MpId)) {
+ if (!ArmPlatformIsPrimaryCore (MpId)) {
return RETURN_SUCCESS;
}
diff --git a/ArmPlatformPkg/Library/ArmPlatformLibNull/ArmPlatformLibNullMem.c b/ArmPlatformPkg/Library/ArmPlatformLibNull/ArmPlatformLibNullMem.c
index 3b44f82f39..aafb797683 100644
--- a/ArmPlatformPkg/Library/ArmPlatformLibNull/ArmPlatformLibNullMem.c
+++ b/ArmPlatformPkg/Library/ArmPlatformLibNull/ArmPlatformLibNullMem.c
@@ -32,21 +32,3 @@ ArmPlatformGetVirtualMemoryMap (
{
ASSERT(0);
}
-
-/**
- Return the EFI Memory Map of your platform
-
- This EFI Memory Map of the System Memory is used by MemoryInitPei module to create the Resource
- Descriptor HOBs used by DXE core.
-
- @param[out] EfiMemoryMap Array of ARM_SYSTEM_MEMORY_REGION_DESCRIPTOR describing an
- EFI Memory region. This array must be ended by a zero-filled entry
-
-**/
-EFI_STATUS
-ArmPlatformGetAdditionalSystemMemory (
- OUT ARM_SYSTEM_MEMORY_REGION_DESCRIPTOR** EfiMemoryMap
- )
-{
- return EFI_UNSUPPORTED;
-}
diff --git a/ArmPlatformPkg/Library/ArmPlatformSecLibNull/ArmPlatformLibNullSec.c b/ArmPlatformPkg/Library/ArmPlatformSecLibNull/ArmPlatformLibNullSec.c
index 1a83882030..41f4f74085 100644
--- a/ArmPlatformPkg/Library/ArmPlatformSecLibNull/ArmPlatformLibNullSec.c
+++ b/ArmPlatformPkg/Library/ArmPlatformSecLibNull/ArmPlatformLibNullSec.c
@@ -29,7 +29,7 @@ ArmPlatformSecTrustzoneInit (
)
{
// Secondary cores might have to set the Secure SGIs into the GICD_IGROUPR0
- if (!IS_PRIMARY_CORE(MpId)) {
+ if (!ArmPlatformIsPrimaryCore (MpId)) {
return;
}
@@ -49,7 +49,7 @@ ArmPlatformSecInitialize (
)
{
// If it is not the primary core then there is nothing to do
- if (!IS_PRIMARY_CORE(MpId)) {
+ if (!ArmPlatformIsPrimaryCore (MpId)) {
return RETURN_SUCCESS;
}
diff --git a/ArmPlatformPkg/Library/DebugSecExtraActionLib/DebugSecExtraActionLib.c b/ArmPlatformPkg/Library/DebugSecExtraActionLib/DebugSecExtraActionLib.c
index 9e78d7eadf..f7c3ab214c 100755
--- a/ArmPlatformPkg/Library/DebugSecExtraActionLib/DebugSecExtraActionLib.c
+++ b/ArmPlatformPkg/Library/DebugSecExtraActionLib/DebugSecExtraActionLib.c
@@ -16,6 +16,7 @@
#include <Library/ArmLib.h>
#include <Library/ArmGicLib.h>
+#include <Library/ArmPlatformLib.h>
#include <Library/ArmPlatformSecLib.h>
#include <Library/DebugLib.h>
#include <Library/PcdLib.h>
@@ -70,7 +71,7 @@ ArmPlatformSecExtraAction (
// Warning: This code assumes the DRAM has already been initialized by ArmPlatformSecLib
//
- if (IS_PRIMARY_CORE(MpId)) {
+ if (ArmPlatformIsPrimaryCore (MpId)) {
UINTN* StartAddress = (UINTN*)PcdGet32(PcdFvBaseAddress);
// Patch the DRAM to make an infinite loop at the start address
@@ -96,7 +97,7 @@ ArmPlatformSecExtraAction (
// Warning: This code assumes the DRAM has already been initialized by ArmPlatformSecLib
//
- if (IS_PRIMARY_CORE(MpId)) {
+ if (ArmPlatformIsPrimaryCore (MpId)) {
// Signal the secondary cores they can jump to PEI phase
ArmGicSendSgiTo (PcdGet32(PcdGicDistributorBase), ARM_GIC_ICDSGIR_FILTER_EVERYONEELSE, 0x0E, PcdGet32 (PcdGicSgiIntId));
diff --git a/ArmPlatformPkg/Library/DebugSecExtraActionLib/DebugSecExtraActionLib.inf b/ArmPlatformPkg/Library/DebugSecExtraActionLib/DebugSecExtraActionLib.inf
index 26afb34b23..5a2d28876a 100755
--- a/ArmPlatformPkg/Library/DebugSecExtraActionLib/DebugSecExtraActionLib.inf
+++ b/ArmPlatformPkg/Library/DebugSecExtraActionLib/DebugSecExtraActionLib.inf
@@ -30,10 +30,12 @@
[Packages]
MdePkg/MdePkg.dec
+ MdeModulePkg/MdeModulePkg.dec
ArmPkg/ArmPkg.dec
ArmPlatformPkg/ArmPlatformPkg.dec
[LibraryClasses]
+ ArmPlatformLib
DebugLib
PcdLib
ArmGicLib
@@ -46,9 +48,6 @@
[FixedPcd]
gArmTokenSpaceGuid.PcdFvBaseAddress
-
- gArmTokenSpaceGuid.PcdArmPrimaryCoreMask
- gArmTokenSpaceGuid.PcdArmPrimaryCore
gArmTokenSpaceGuid.PcdGicDistributorBase
gArmTokenSpaceGuid.PcdGicInterruptInterfaceBase
diff --git a/ArmPlatformPkg/Library/PL011SerialPortLib/PL011SerialPortExtLib.c b/ArmPlatformPkg/Library/PL011SerialPortLib/PL011SerialPortExtLib.c
index 9bfe42e60c..57f3fa0eea 100644
--- a/ArmPlatformPkg/Library/PL011SerialPortLib/PL011SerialPortExtLib.c
+++ b/ArmPlatformPkg/Library/PL011SerialPortLib/PL011SerialPortExtLib.c
@@ -1,7 +1,7 @@
/** @file
Serial I/O Port library functions with no library constructor/destructor
- Copyright (c) 2012, ARM Ltd. All rights reserved.<BR>
+ Copyright (c) 2012-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
@@ -47,12 +47,12 @@
RETURN_STATUS
EFIAPI
SerialPortSetAttributes (
- IN UINT64 BaudRate,
- IN UINT32 ReceiveFifoDepth,
- IN UINT32 Timeout,
- IN EFI_PARITY_TYPE Parity,
- IN UINT8 DataBits,
- IN EFI_STOP_BITS_TYPE StopBits
+ IN OUT UINT64 *BaudRate,
+ IN OUT UINT32 *ReceiveFifoDepth,
+ IN OUT UINT32 *Timeout,
+ IN OUT EFI_PARITY_TYPE *Parity,
+ IN OUT UINT8 *DataBits,
+ IN OUT EFI_STOP_BITS_TYPE *StopBits
)
{
return PL011UartInitializePort (
diff --git a/ArmPlatformPkg/Library/PL011SerialPortLib/PL011SerialPortLib.c b/ArmPlatformPkg/Library/PL011SerialPortLib/PL011SerialPortLib.c
index 09033dbd76..4f628086ac 100644
--- a/ArmPlatformPkg/Library/PL011SerialPortLib/PL011SerialPortLib.c
+++ b/ArmPlatformPkg/Library/PL011SerialPortLib/PL011SerialPortLib.c
@@ -2,7 +2,7 @@
Serial I/O Port library functions with no library constructor/destructor
Copyright (c) 2008 - 2010, Apple Inc. All rights reserved.<BR>
- Copyright (c) 2012, ARM Ltd. All rights reserved.<BR>
+ Copyright (c) 2012 - 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
@@ -37,13 +37,21 @@ SerialPortInitialize (
VOID
)
{
+ UINT64 BaudRate;
+ UINT32 ReceiveFifoDepth;
+ EFI_PARITY_TYPE Parity;
+ UINT8 DataBits;
+ EFI_STOP_BITS_TYPE StopBits;
+
+ BaudRate = (UINTN)PcdGet64 (PcdUartDefaultBaudRate);
+ ReceiveFifoDepth = 0; // Use the default value for Fifo depth
+ Parity = (EFI_PARITY_TYPE)PcdGet8 (PcdUartDefaultParity);
+ DataBits = PcdGet8 (PcdUartDefaultDataBits);
+ StopBits = (EFI_STOP_BITS_TYPE) PcdGet8 (PcdUartDefaultStopBits);
+
return PL011UartInitializePort (
(UINTN)PcdGet64 (PcdSerialRegisterBase),
- (UINTN)PcdGet64 (PcdUartDefaultBaudRate),
- 0, // Use the default value for Fifo depth
- (EFI_PARITY_TYPE)PcdGet8 (PcdUartDefaultParity),
- PcdGet8 (PcdUartDefaultDataBits),
- (EFI_STOP_BITS_TYPE) PcdGet8 (PcdUartDefaultStopBits));
+ &BaudRate, &ReceiveFifoDepth, &Parity, &DataBits, &StopBits);
}
/**
diff --git a/ArmPlatformPkg/PrePeiCore/Arm/PrePeiCoreEntryPoint.S b/ArmPlatformPkg/PrePeiCore/Arm/PrePeiCoreEntryPoint.S
index f902a251c2..af4350b0cb 100644
--- a/ArmPlatformPkg/PrePeiCore/Arm/PrePeiCoreEntryPoint.S
+++ b/ArmPlatformPkg/PrePeiCore/Arm/PrePeiCoreEntryPoint.S
@@ -1,5 +1,5 @@
//
-// Copyright (c) 2011, ARM Limited. All rights reserved.
+// Copyright (c) 2011-2013, ARM Limited. All rights reserved.
//
// This program and the accompanying materials
// are licensed and made available under the terms and conditions of the BSD License
@@ -20,33 +20,42 @@
.align 3
GCC_ASM_IMPORT(CEntryPoint)
+GCC_ASM_IMPORT(ArmPlatformGetCorePosition)
+GCC_ASM_IMPORT(ArmPlatformIsPrimaryCore)
GCC_ASM_IMPORT(ArmReadMpidr)
+GCC_ASM_IMPORT(ArmPlatformPeiBootAction)
GCC_ASM_EXPORT(_ModuleEntryPoint)
StartupAddr: .word CEntryPoint
ASM_PFX(_ModuleEntryPoint):
+ // Do early platform specific actions
+ bl ASM_PFX(ArmPlatformPeiBootAction)
+
// Identify CPU ID
bl ASM_PFX(ArmReadMpidr)
- // Get ID of this CPU in Multicore system
- LoadConstantToReg (FixedPcdGet32(PcdArmPrimaryCoreMask), r1)
- and r5, r0, r1
-
+ // Keep a copy of the MpId register value
+ mov r5, r0
+
+ // Is it the Primary Core ?
+ bl ASM_PFX(ArmPlatformIsPrimaryCore)
+
// Get the top of the primary stacks (and the base of the secondary stacks)
LoadConstantToReg (FixedPcdGet32(PcdCPUCoresStackBase), r1)
LoadConstantToReg (FixedPcdGet32(PcdCPUCorePrimaryStackSize), r2)
add r1, r1, r2
- // Is it the Primary Core ?
- LoadConstantToReg (FixedPcdGet32(PcdArmPrimaryCore), r3)
- cmp r5, r3
+ // r0 is equal to 1 if I am the primary core
+ cmp r0, #1
beq _SetupPrimaryCoreStack
_SetupSecondaryCoreStack:
// r1 contains the base of the secondary stacks
- // Get the Core Position (ClusterId * 4) + CoreId
- GetCorePositionFromMpId(r0, r5, r2)
+ // Get the Core Position
+ mov r6, r1 // Save base of the secondary stacks
+ mov r0, r5
+ bl ASM_PFX(ArmPlatformGetCorePosition)
// The stack starts at the top of the stack region. Add '1' to the Core Position to get the top of the stack
add r0, r0, #1
@@ -54,7 +63,7 @@ _SetupSecondaryCoreStack:
LoadConstantToReg (FixedPcdGet32(PcdCPUCoreSecondaryStackSize), r2)
mul r0, r0, r2
// SP = StackBase + StackOffset
- add sp, r1, r0
+ add sp, r6, r0
_PrepareArguments:
// The PEI Core Entry Point has been computed by GenFV and stored in the second entry of the Reset Vector
diff --git a/ArmPlatformPkg/PrePeiCore/Arm/PrePeiCoreEntryPoint.asm b/ArmPlatformPkg/PrePeiCore/Arm/PrePeiCoreEntryPoint.asm
index a3dd1fb2c6..be1a767696 100644
--- a/ArmPlatformPkg/PrePeiCore/Arm/PrePeiCoreEntryPoint.asm
+++ b/ArmPlatformPkg/PrePeiCore/Arm/PrePeiCoreEntryPoint.asm
@@ -1,5 +1,5 @@
//
-// Copyright (c) 2011, ARM Limited. All rights reserved.
+// Copyright (c) 2011-2013, ARM Limited. All rights reserved.
//
// This program and the accompanying materials
// are licensed and made available under the terms and conditions of the BSD License
@@ -19,7 +19,10 @@
INCLUDE AsmMacroIoLib.inc
IMPORT CEntryPoint
+ IMPORT ArmPlatformGetCorePosition
+ IMPORT ArmPlatformIsPrimaryCore
IMPORT ArmReadMpidr
+ IMPORT ArmPlatformPeiBootAction
EXPORT _ModuleEntryPoint
PRESERVE8
@@ -28,27 +31,33 @@
StartupAddr DCD CEntryPoint
_ModuleEntryPoint
+ // Do early platform specific actions
+ bl ArmPlatformPeiBootAction
+
// Identify CPU ID
bl ArmReadMpidr
- // Get ID of this CPU in Multicore system
- LoadConstantToReg (FixedPcdGet32(PcdArmPrimaryCoreMask), r1)
- and r5, r0, r1
+ // Keep a copy of the MpId register value
+ mov r5, r0
+ // Is it the Primary Core ?
+ bl ArmPlatformIsPrimaryCore
+
// Get the top of the primary stacks (and the base of the secondary stacks)
LoadConstantToReg (FixedPcdGet32(PcdCPUCoresStackBase), r1)
LoadConstantToReg (FixedPcdGet32(PcdCPUCorePrimaryStackSize), r2)
add r1, r1, r2
- // Is it the Primary Core ?
- LoadConstantToReg (FixedPcdGet32(PcdArmPrimaryCore), r3)
- cmp r5, r3
+ // r0 is equal to 1 if I am the primary core
+ cmp r0, #1
beq _SetupPrimaryCoreStack
_SetupSecondaryCoreStack
// r1 contains the base of the secondary stacks
- // Get the Core Position (ClusterId * 4) + CoreId
- GetCorePositionFromMpId(r0, r5, r2)
+ // Get the Core Position
+ mov r6, r1 // Save base of the secondary stacks
+ mov r0, r5
+ bl ArmPlatformGetCorePosition
// The stack starts at the top of the stack region. Add '1' to the Core Position to get the top of the stack
add r0, r0, #1
@@ -56,7 +65,7 @@ _SetupSecondaryCoreStack
LoadConstantToReg (FixedPcdGet32(PcdCPUCoreSecondaryStackSize), r2)
mul r0, r0, r2
// SP = StackBase + StackOffset
- add sp, r1, r0
+ add sp, r6, r0
_PrepareArguments
// The PEI Core Entry Point has been computed by GenFV and stored in the second entry of the Reset Vector
diff --git a/ArmPlatformPkg/PrePeiCore/PrePeiCore.c b/ArmPlatformPkg/PrePeiCore/PrePeiCore.c
index fdd8697edf..ececd4c763 100644
--- a/ArmPlatformPkg/PrePeiCore/PrePeiCore.c
+++ b/ArmPlatformPkg/PrePeiCore/PrePeiCore.c
@@ -93,7 +93,7 @@ CEntryPoint (
//Note: The MMU will be enabled by MemoryPeim. Only the primary core will have the MMU on.
// If not primary Jump to Secondary Main
- if (IS_PRIMARY_CORE(MpId)) {
+ if (ArmPlatformIsPrimaryCore (MpId)) {
// Initialize the Debug Agent for Source Level Debugging
InitializeDebugAgent (DEBUG_AGENT_INIT_POSTMEM_SEC, NULL, NULL);
SaveAndSetDebugTimerInterrupt (TRUE);
diff --git a/ArmPlatformPkg/PrePeiCore/PrePeiCoreMPCore.inf b/ArmPlatformPkg/PrePeiCore/PrePeiCoreMPCore.inf
index 91f9b3a784..4658486336 100644
--- a/ArmPlatformPkg/PrePeiCore/PrePeiCoreMPCore.inf
+++ b/ArmPlatformPkg/PrePeiCore/PrePeiCoreMPCore.inf
@@ -62,7 +62,6 @@
gArmTokenSpaceGuid.PcdFvBaseAddress
gArmTokenSpaceGuid.PcdFvSize
- gArmTokenSpaceGuid.PcdArmPrimaryCoreMask
gArmTokenSpaceGuid.PcdArmPrimaryCore
gArmTokenSpaceGuid.PcdGicPrimaryCoreId
diff --git a/ArmPlatformPkg/PrePeiCore/PrePeiCoreUniCore.inf b/ArmPlatformPkg/PrePeiCore/PrePeiCoreUniCore.inf
index bf590dbac0..13f86902b6 100644
--- a/ArmPlatformPkg/PrePeiCore/PrePeiCoreUniCore.inf
+++ b/ArmPlatformPkg/PrePeiCore/PrePeiCoreUniCore.inf
@@ -60,9 +60,6 @@
gArmTokenSpaceGuid.PcdFvBaseAddress
gArmTokenSpaceGuid.PcdFvSize
- gArmTokenSpaceGuid.PcdArmPrimaryCoreMask
- gArmTokenSpaceGuid.PcdArmPrimaryCore
-
gArmPlatformTokenSpaceGuid.PcdCPUCoresStackBase
gArmPlatformTokenSpaceGuid.PcdCPUCorePrimaryStackSize
gArmPlatformTokenSpaceGuid.PcdCPUCoreSecondaryStackSize
diff --git a/ArmPlatformPkg/PrePi/Arm/ModuleEntryPoint.S b/ArmPlatformPkg/PrePi/Arm/ModuleEntryPoint.S
index c0c20a9206..3d4e1e9279 100644
--- a/ArmPlatformPkg/PrePi/Arm/ModuleEntryPoint.S
+++ b/ArmPlatformPkg/PrePi/Arm/ModuleEntryPoint.S
@@ -22,7 +22,9 @@
.align 3
GCC_ASM_IMPORT(CEntryPoint)
+GCC_ASM_IMPORT(ArmPlatformIsPrimaryCore)
GCC_ASM_IMPORT(ArmReadMpidr)
+GCC_ASM_IMPORT(ArmPlatformPeiBootAction)
GCC_ASM_IMPORT(ArmPlatformStackSet)
GCC_ASM_EXPORT(_ModuleEntryPoint)
@@ -30,10 +32,13 @@ StartupAddr: .word CEntryPoint
ASM_PFX(_ModuleEntryPoint):
+ // Do early platform specific actions
+ bl ASM_PFX(ArmPlatformPeiBootAction)
+
// Get ID of this CPU in Multicore system
bl ASM_PFX(ArmReadMpidr)
- LoadConstantToReg (FixedPcdGet32(PcdArmPrimaryCoreMask), r1)
- and r6, r0, r1
+ // Keep a copy of the MpId register value
+ mov r6, r0
_SetSVCMode:
// Enter SVC mode, Disable FIQ and IRQ
@@ -118,8 +123,9 @@ _GetStackBase:
bl ASM_PFX(ArmPlatformStackSet)
// Is it the Primary Core ?
- LoadConstantToReg (FixedPcdGet32(PcdArmPrimaryCore), r4)
- cmp r6, r4
+ mov r0, r6
+ bl ASM_PFX(ArmPlatformIsPrimaryCore)
+ cmp r0, #1
bne _PrepareArguments
_ReserveGlobalVariable:
diff --git a/ArmPlatformPkg/PrePi/Arm/ModuleEntryPoint.asm b/ArmPlatformPkg/PrePi/Arm/ModuleEntryPoint.asm
index 5efdb532af..993fccfa47 100644
--- a/ArmPlatformPkg/PrePi/Arm/ModuleEntryPoint.asm
+++ b/ArmPlatformPkg/PrePi/Arm/ModuleEntryPoint.asm
@@ -21,7 +21,9 @@
INCLUDE AsmMacroIoLib.inc
IMPORT CEntryPoint
+ IMPORT ArmPlatformIsPrimaryCore
IMPORT ArmReadMpidr
+ IMPORT ArmPlatformPeiBootAction
IMPORT ArmPlatformStackSet
EXPORT _ModuleEntryPoint
@@ -32,10 +34,13 @@
StartupAddr DCD CEntryPoint
_ModuleEntryPoint
+ // Do early platform specific actions
+ bl ArmPlatformPeiBootAction
+
// Get ID of this CPU in Multicore system
bl ArmReadMpidr
- LoadConstantToReg (FixedPcdGet32(PcdArmPrimaryCoreMask), r1)
- and r6, r0, r1
+ // Keep a copy of the MpId register value
+ mov r6, r0
_SetSVCMode
// Enter SVC mode, Disable FIQ and IRQ
@@ -120,8 +125,9 @@ _GetStackBase
bl ArmPlatformStackSet
// Is it the Primary Core ?
- LoadConstantToReg (FixedPcdGet32(PcdArmPrimaryCore), r4)
- cmp r6, r4
+ mov r0, r6
+ bl ArmPlatformIsPrimaryCore
+ cmp r0, #1
bne _PrepareArguments
_ReserveGlobalVariable
diff --git a/ArmPlatformPkg/PrePi/PeiMPCore.inf b/ArmPlatformPkg/PrePi/PeiMPCore.inf
index 3a3614192a..359e7717ef 100755
--- a/ArmPlatformPkg/PrePi/PeiMPCore.inf
+++ b/ArmPlatformPkg/PrePi/PeiMPCore.inf
@@ -95,7 +95,6 @@
gArmPlatformTokenSpaceGuid.PcdCoreCount
gArmPlatformTokenSpaceGuid.PcdClusterCount
- gArmTokenSpaceGuid.PcdArmPrimaryCoreMask
gArmTokenSpaceGuid.PcdArmPrimaryCore
gArmTokenSpaceGuid.PcdGicPrimaryCoreId
diff --git a/ArmPlatformPkg/PrePi/PeiUniCore.inf b/ArmPlatformPkg/PrePi/PeiUniCore.inf
index 823a956074..dd6b82ed38 100755
--- a/ArmPlatformPkg/PrePi/PeiUniCore.inf
+++ b/ArmPlatformPkg/PrePi/PeiUniCore.inf
@@ -90,8 +90,6 @@
gArmPlatformTokenSpaceGuid.PcdCoreCount
gArmPlatformTokenSpaceGuid.PcdClusterCount
- gArmTokenSpaceGuid.PcdArmPrimaryCoreMask
- gArmTokenSpaceGuid.PcdArmPrimaryCore
gEmbeddedTokenSpaceGuid.PcdPrePiCpuMemorySize
gEmbeddedTokenSpaceGuid.PcdPrePiCpuIoSize
diff --git a/ArmPlatformPkg/PrePi/PrePi.c b/ArmPlatformPkg/PrePi/PrePi.c
index bdeb60d84c..238b0989ab 100755
--- a/ArmPlatformPkg/PrePi/PrePi.c
+++ b/ArmPlatformPkg/PrePi/PrePi.c
@@ -217,7 +217,7 @@ CEntryPoint (
// Initialize the platform specific controllers
ArmPlatformInitialize (MpId);
- if (IS_PRIMARY_CORE(MpId) && PerformanceMeasurementEnabled ()) {
+ if (ArmPlatformIsPrimaryCore (MpId) && PerformanceMeasurementEnabled ()) {
// Initialize the Timer Library to setup the Timer HW controller
TimerConstructor ();
// We cannot call yet the PerformanceLib because the HOB List has not been initialized
@@ -240,7 +240,7 @@ CEntryPoint (
// Define the Global Variable region when we are not running in XIP
if (!IS_XIP()) {
- if (IS_PRIMARY_CORE(MpId)) {
+ if (ArmPlatformIsPrimaryCore (MpId)) {
mGlobalVariableBase = GlobalVariableBase;
if (ArmIsMpCore()) {
// Signal the Global Variable Region is defined (event: ARM_CPU_EVENT_DEFAULT)
@@ -253,7 +253,7 @@ CEntryPoint (
}
// If not primary Jump to Secondary Main
- if (IS_PRIMARY_CORE(MpId)) {
+ if (ArmPlatformIsPrimaryCore (MpId)) {
// Goto primary Main.
PrimaryMain (UefiMemoryBase, StacksBase, GlobalVariableBase, StartTimeStamp);
} else {
diff --git a/ArmPlatformPkg/Sec/Arm/Helper.S b/ArmPlatformPkg/Sec/Arm/Helper.S
index 4eede5faba..c99987d3a1 100644
--- a/ArmPlatformPkg/Sec/Arm/Helper.S
+++ b/ArmPlatformPkg/Sec/Arm/Helper.S
@@ -1,10 +1,10 @@
#========================================================================================
-# Copyright (c) 2011-2012, ARM Limited. All rights reserved.
+# Copyright (c) 2011-2013, ARM Limited. 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
+# 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.
diff --git a/ArmPlatformPkg/Sec/Arm/SecEntryPoint.S b/ArmPlatformPkg/Sec/Arm/SecEntryPoint.S
index 92035a1ffe..5096251a74 100644
--- a/ArmPlatformPkg/Sec/Arm/SecEntryPoint.S
+++ b/ArmPlatformPkg/Sec/Arm/SecEntryPoint.S
@@ -1,5 +1,5 @@
//
-// Copyright (c) 2011-2012, ARM Limited. All rights reserved.
+// Copyright (c) 2011-2013, ARM Limited. All rights reserved.
//
// This program and the accompanying materials
// are licensed and made available under the terms and conditions of the BSD License
@@ -19,6 +19,8 @@
.align 3
GCC_ASM_IMPORT(CEntryPoint)
+GCC_ASM_IMPORT(ArmPlatformIsPrimaryCore)
+GCC_ASM_IMPORT(ArmPlatformGetCorePosition)
GCC_ASM_IMPORT(ArmPlatformSecBootAction)
GCC_ASM_IMPORT(ArmPlatformSecBootMemoryInit)
GCC_ASM_IMPORT(ArmDisableInterrupts)
@@ -45,13 +47,12 @@ ASM_PFX(_ModuleEntryPoint):
_IdentifyCpu:
// Identify CPU ID
bl ASM_PFX(ArmReadMpidr)
- // Get ID of this CPU in Multicore system
- LoadConstantToReg (FixedPcdGet32(PcdArmPrimaryCoreMask), r1)
- and r5, r0, r1
+ // Keep a copy of the MpId register value
+ mov r9, r0
// Is it the Primary Core ?
- LoadConstantToReg (FixedPcdGet32(PcdArmPrimaryCore), r3)
- cmp r5, r3
+ bl ASM_PFX(ArmPlatformIsPrimaryCore)
+ cmp r0, #1
// Only the primary core initialize the memory (SMC)
beq _InitMem
@@ -74,9 +75,6 @@ _InitMem:
// Initialize Init Boot Memory
bl ASM_PFX(ArmPlatformSecBootMemoryInit)
- // Only Primary CPU could run this line (the secondary cores have jumped from _IdentifyCpu to _SetupStack)
- LoadConstantToReg (FixedPcdGet32(PcdArmPrimaryCore), r5)
-
_SetupPrimaryCoreStack:
// Get the top of the primary stacks (and the base of the secondary stacks)
LoadConstantToReg (FixedPcdGet32(PcdCPUCoresSecStackBase), r1)
@@ -94,10 +92,11 @@ _SetupSecondaryCoreStack:
// Get the top of the primary stacks (and the base of the secondary stacks)
LoadConstantToReg (FixedPcdGet32(PcdCPUCoresSecStackBase), r1)
LoadConstantToReg (FixedPcdGet32(PcdCPUCoreSecPrimaryStackSize), r2)
- add r1, r1, r2
+ add r6, r1, r2
- // Get the Core Position (ClusterId * 4) + CoreId
- GetCorePositionFromMpId(r0, r5, r2)
+ // Get the Core Position
+ mov r0, r9
+ bl ASM_PFX(ArmPlatformGetCorePosition)
// The stack starts at the top of the stack region. Add '1' to the Core Position to get the top of the stack
add r0, r0, #1
@@ -105,7 +104,7 @@ _SetupSecondaryCoreStack:
LoadConstantToReg (FixedPcdGet32(PcdCPUCoreSecSecondaryStackSize), r2)
mul r0, r0, r2
// SP = StackBase + StackOffset
- add sp, r1, r0
+ add sp, r6, r0
_PrepareArguments:
// Move sec startup address into a data register
@@ -115,7 +114,7 @@ _PrepareArguments:
// Jump to SEC C code
// r0 = mp_id
// r1 = Boot Mode
- mov r0, r5
+ mov r0, r9
mov r1, r10
blx r3
diff --git a/ArmPlatformPkg/Sec/Arm/SecEntryPoint.asm b/ArmPlatformPkg/Sec/Arm/SecEntryPoint.asm
index 42d2b0268f..14f7e9c663 100644
--- a/ArmPlatformPkg/Sec/Arm/SecEntryPoint.asm
+++ b/ArmPlatformPkg/Sec/Arm/SecEntryPoint.asm
@@ -1,5 +1,5 @@
//
-// Copyright (c) 2011-2012, ARM Limited. All rights reserved.
+// Copyright (c) 2011-2013, ARM Limited. All rights reserved.
//
// This program and the accompanying materials
// are licensed and made available under the terms and conditions of the BSD License
@@ -18,6 +18,8 @@
INCLUDE AsmMacroIoLib.inc
IMPORT CEntryPoint
+ IMPORT ArmPlatformIsPrimaryCore
+ IMPORT ArmPlatformGetCorePosition
IMPORT ArmPlatformSecBootAction
IMPORT ArmPlatformSecBootMemoryInit
IMPORT ArmDisableInterrupts
@@ -33,10 +35,10 @@ StartupAddr DCD CEntryPoint
_ModuleEntryPoint FUNCTION
// First ensure all interrupts are disabled
- blx ArmDisableInterrupts
+ bl ArmDisableInterrupts
// Ensure that the MMU and caches are off
- blx ArmDisableCachesAndMmu
+ bl ArmDisableCachesAndMmu
// By default, we are doing a cold boot
mov r10, #ARM_SEC_COLD_BOOT
@@ -47,13 +49,12 @@ _ModuleEntryPoint FUNCTION
_IdentifyCpu
// Identify CPU ID
bl ArmReadMpidr
- // Get ID of this CPU in Multicore system
- LoadConstantToReg (FixedPcdGet32(PcdArmPrimaryCoreMask), r1)
- and r5, r0, r1
+ // Keep a copy of the MpId register value
+ mov r9, r0
// Is it the Primary Core ?
- LoadConstantToReg (FixedPcdGet32(PcdArmPrimaryCore), r3)
- cmp r5, r3
+ bl ArmPlatformIsPrimaryCore
+ cmp r0, #1
// Only the primary core initialize the memory (SMC)
beq _InitMem
@@ -76,9 +77,6 @@ _InitMem
// Initialize Init Boot Memory
bl ArmPlatformSecBootMemoryInit
- // Only Primary CPU could run this line (the secondary cores have jumped from _IdentifyCpu to _SetupStack)
- LoadConstantToReg (FixedPcdGet32(PcdArmPrimaryCore), r5)
-
_SetupPrimaryCoreStack
// Get the top of the primary stacks (and the base of the secondary stacks)
LoadConstantToReg (FixedPcdGet32(PcdCPUCoresSecStackBase), r1)
@@ -96,10 +94,11 @@ _SetupSecondaryCoreStack
// Get the top of the primary stacks (and the base of the secondary stacks)
LoadConstantToReg (FixedPcdGet32(PcdCPUCoresSecStackBase), r1)
LoadConstantToReg (FixedPcdGet32(PcdCPUCoreSecPrimaryStackSize), r2)
- add r1, r1, r2
+ add r6, r1, r2
- // Get the Core Position (ClusterId * 4) + CoreId
- GetCorePositionFromMpId(r0, r5, r2)
+ // Get the Core Position
+ mov r0, r9
+ bl ArmPlatformGetCorePosition
// The stack starts at the top of the stack region. Add '1' to the Core Position to get the top of the stack
add r0, r0, #1
@@ -107,7 +106,7 @@ _SetupSecondaryCoreStack
LoadConstantToReg (FixedPcdGet32(PcdCPUCoreSecSecondaryStackSize), r2)
mul r0, r0, r2
// SP = StackBase + StackOffset
- add sp, r1, r0
+ add sp, r6, r0
_PrepareArguments
// Move sec startup address into a data register
@@ -117,7 +116,7 @@ _PrepareArguments
// Jump to SEC C code
// r0 = mp_id
// r1 = Boot Mode
- mov r0, r5
+ mov r0, r9
mov r1, r10
blx r3
ENDFUNC
diff --git a/ArmPlatformPkg/Sec/Sec.c b/ArmPlatformPkg/Sec/Sec.c
index 52fa53a647..5282d68ec7 100644
--- a/ArmPlatformPkg/Sec/Sec.c
+++ b/ArmPlatformPkg/Sec/Sec.c
@@ -56,7 +56,7 @@ CEntryPoint (
ArmPlatformSecInitialize (MpId);
// Primary CPU clears out the SCU tag RAMs, secondaries wait
- if (IS_PRIMARY_CORE(MpId) && (SecBootMode == ARM_SEC_COLD_BOOT)) {
+ if (ArmPlatformIsPrimaryCore (MpId) && (SecBootMode == ARM_SEC_COLD_BOOT)) {
if (ArmIsMpCore()) {
// Signal for the initial memory is configured (event: BOOT_MEM_INIT)
ArmCallSEV ();
@@ -108,7 +108,7 @@ CEntryPoint (
// Enter Monitor Mode
enter_monitor_mode ((UINTN)TrustedWorldInitialization, MpId, SecBootMode, (VOID*)(PcdGet32(PcdCPUCoresSecMonStackBase) + (PcdGet32(PcdCPUCoreSecMonStackSize) * (GET_CORE_POS(MpId) + 1))));
} else {
- if (IS_PRIMARY_CORE(MpId)) {
+ if (ArmPlatformIsPrimaryCore (MpId)) {
SerialPrint ("Trust Zone Configuration is disabled\n\r");
}
@@ -147,7 +147,7 @@ TrustedWorldInitialization (
// Setup the Trustzone Chipsets
if (SecBootMode == ARM_SEC_COLD_BOOT) {
- if (IS_PRIMARY_CORE(MpId)) {
+ if (ArmPlatformIsPrimaryCore (MpId)) {
if (ArmIsMpCore()) {
// Signal the secondary core the Security settings is done (event: EVENT_SECURE_INIT)
ArmCallSEV ();
diff --git a/ArmPlatformPkg/Sec/Sec.inf b/ArmPlatformPkg/Sec/Sec.inf
index 3cf9f339e0..8e64a73142 100644
--- a/ArmPlatformPkg/Sec/Sec.inf
+++ b/ArmPlatformPkg/Sec/Sec.inf
@@ -38,6 +38,7 @@
[LibraryClasses]
ArmCpuLib
ArmLib
+ ArmPlatformLib
ArmPlatformSecLib
ArmTrustedMonitorLib
BaseLib
@@ -61,14 +62,11 @@
gArmTokenSpaceGuid.PcdArmNsacr
gArmTokenSpaceGuid.PcdArmNonSecModeTransition
- gArmTokenSpaceGuid.PcdArmPrimaryCoreMask
- gArmTokenSpaceGuid.PcdArmPrimaryCore
-
gArmTokenSpaceGuid.PcdSecureFvBaseAddress
gArmTokenSpaceGuid.PcdSecureFvSize
gArmTokenSpaceGuid.PcdFvBaseAddress
-
+
gArmPlatformTokenSpaceGuid.PcdCPUCoresSecStackBase
gArmPlatformTokenSpaceGuid.PcdCPUCoreSecPrimaryStackSize
gArmPlatformTokenSpaceGuid.PcdCPUCoreSecSecondaryStackSize
diff --git a/ArmPlatformPkg/Sec/SecInternal.h b/ArmPlatformPkg/Sec/SecInternal.h
index eeaf40c0c8..255059af5f 100644
--- a/ArmPlatformPkg/Sec/SecInternal.h
+++ b/ArmPlatformPkg/Sec/SecInternal.h
@@ -19,6 +19,7 @@
#include <Base.h>
#include <Library/ArmLib.h>
#include <Library/ArmCpuLib.h>
+#include <Library/ArmPlatformLib.h>
#include <Library/ArmPlatformSecLib.h>
#include <Library/BaseLib.h>
#include <Library/DebugLib.h>
diff --git a/BaseTools/Conf/tools_def.template b/BaseTools/Conf/tools_def.template
index 8e3053dc25..6756002e2f 100755
--- a/BaseTools/Conf/tools_def.template
+++ b/BaseTools/Conf/tools_def.template
@@ -4894,16 +4894,16 @@ RELEASE_RVCTCYGWIN_ARM_CC_FLAGS = "$(CCPATH_FLAG)" $(ARCHCC_FLAGS) $(PLATFORM_F
# ARM definitions
##################
-*_ARMGCC_ARM_ASLCC_PATH = ENV(ARMGCC_TOOLS_PATH)arm-none-eabi-gcc
-*_ARMGCC_ARM_ASLDLINK_PATH = ENV(ARMGCC_TOOLS_PATH)arm-none-eabi-ld
-*_ARMGCC_ARM_ASLPP_PATH = ENV(ARMGCC_TOOLS_PATH)arm-none-eabi-gcc
-
-*_ARMGCC_ARM_CC_PATH = ENV(ARMGCC_TOOLS_PATH)arm-none-eabi-gcc
-*_ARMGCC_ARM_SLINK_PATH = ENV(ARMGCC_TOOLS_PATH)arm-none-eabi-ar
-*_ARMGCC_ARM_DLINK_PATH = ENV(ARMGCC_TOOLS_PATH)arm-none-eabi-ld
-*_ARMGCC_ARM_ASM_PATH = ENV(ARMGCC_TOOLS_PATH)arm-none-eabi-as
-*_ARMGCC_ARM_PP_PATH = ENV(ARMGCC_TOOLS_PATH)arm-none-eabi-gcc
-*_ARMGCC_ARM_VFRPP_PATH = ENV(ARMGCC_TOOLS_PATH)arm-none-eabi-gcc
+*_ARMGCC_ARM_ASLCC_PATH = ENV(CROSS_COMPILE)gcc
+*_ARMGCC_ARM_ASLDLINK_PATH = ENV(CROSS_COMPILE)ld
+*_ARMGCC_ARM_ASLPP_PATH = ENV(CROSS_COMPILE)gcc
+
+*_ARMGCC_ARM_CC_PATH = ENV(CROSS_COMPILE)gcc
+*_ARMGCC_ARM_SLINK_PATH = ENV(CROSS_COMPILE)ar
+*_ARMGCC_ARM_DLINK_PATH = ENV(CROSS_COMPILE)ld
+*_ARMGCC_ARM_ASM_PATH = ENV(CROSS_COMPILE)as
+*_ARMGCC_ARM_PP_PATH = ENV(CROSS_COMPILE)gcc
+*_ARMGCC_ARM_VFRPP_PATH = ENV(CROSS_COMPILE)gcc
#
# Use default values, or override in DSC file
diff --git a/BaseTools/Source/C/Include/Arm/ProcessorBind.h b/BaseTools/Source/C/Include/Arm/ProcessorBind.h
index 3a47ed3873..1ca26ab6f3 100644
--- a/BaseTools/Source/C/Include/Arm/ProcessorBind.h
+++ b/BaseTools/Source/C/Include/Arm/ProcessorBind.h
@@ -46,9 +46,7 @@
#else
//
// Assume standard ARM alignment.
- // Need to check portability of long long
//
-// #include <stdint.h>
typedef unsigned long long UINT64;
typedef long long INT64;
typedef unsigned int UINT32;
diff --git a/BaseTools/Source/C/Makefiles/header.makefile b/BaseTools/Source/C/Makefiles/header.makefile
index 9971c477be..6895f98c6e 100644
--- a/BaseTools/Source/C/Makefiles/header.makefile
+++ b/BaseTools/Source/C/Makefiles/header.makefile
@@ -4,7 +4,7 @@
# ARCH = x86_64 or x64 for EM64T build
# ARCH = ia32 or IA32 for IA32 build
# ARCH = ia64 or IA64 for IA64 build
-# ARCH = Arm or ARM for ARM build
+# ARCH = Arm or ARM for ARM build
#
# Copyright (c) 2007 - 2010, Intel Corporation. All rights reserved.<BR>
# This program and the accompanying materials
@@ -35,11 +35,10 @@ ifeq ($(ARCH), X64)
ARCH_INCLUDE = -I $(MAKEROOT)/Include/X64/
endif
-ifeq ($(ARCH), ARM)
-ARCH_INCLUDE = -I $(MAKEROOT)/Include/Arm/
-endif
-
-
+ifeq ($(ARCH), ARM)
+ARCH_INCLUDE = -I $(MAKEROOT)/Include/Arm/
+endif
+
INCLUDE = $(TOOL_INCLUDE) -I $(MAKEROOT) -I $(MAKEROOT)/Include/Common -I $(MAKEROOT)/Include/ -I $(MAKEROOT)/Include/IndustryStandard -I $(MAKEROOT)/Common/ -I .. -I . $(ARCH_INCLUDE)
CPPFLAGS = $(INCLUDE)
CFLAGS = -MD -fshort-wchar -fno-strict-aliasing -fno-merge-constants -nostdlib -Wall -Werror -c -g
diff --git a/BaseTools/toolsetup.bat b/BaseTools/toolsetup.bat
index 561cc408cb..98d0247aa1 100755
--- a/BaseTools/toolsetup.bat
+++ b/BaseTools/toolsetup.bat
@@ -3,10 +3,10 @@
@REM however it may be executed directly from the BaseTools project folder
@REM if the file is not executed within a WORKSPACE\BaseTools folder.
@REM
-@REM Copyright (c) 2006 - 2012, Intel Corporation. All rights reserved.<BR>
+@REM Copyright (c) 2006 - 2013, Intel Corporation. All rights reserved.<BR>
@REM
@REM This program and the accompanying materials are licensed and made available
-@REM under the terms and conditions of the BSD Licensewhich accompanies this
+@REM under the terms and conditions of the BSD License which accompanies this
@REM distribution. The full text of the license may be found at:
@REM http://opensource.org/licenses/bsd-license.php
@REM
diff --git a/BeagleBoardPkg/Library/BeagleBoardLib/BeagleBoardHelper.S b/BeagleBoardPkg/Library/BeagleBoardLib/BeagleBoardHelper.S
new file mode 100644
index 0000000000..1d0b090774
--- /dev/null
+++ b/BeagleBoardPkg/Library/BeagleBoardLib/BeagleBoardHelper.S
@@ -0,0 +1,35 @@
+#
+# Copyright (c) 2012-2013, ARM Limited. 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.
+#
+#
+
+#include <AsmMacroIoLib.h>
+#include <AutoGen.h>
+
+.text
+.align 2
+
+GCC_ASM_EXPORT(ArmPlatformIsPrimaryCore)
+GCC_ASM_EXPORT(ArmPlatformPeiBootAction)
+
+//UINTN
+//ArmPlatformIsPrimaryCore (
+// IN UINTN MpId
+// );
+ASM_PFX(ArmPlatformIsPrimaryCore):
+ // BeagleBoard has a single core. We must always return 1.
+ mov r0, #1
+ bx lr
+
+ASM_PFX(ArmPlatformPeiBootAction):
+ bx lr
+
+ASM_FUNCTION_REMOVE_IF_UNREFERENCED
diff --git a/BeagleBoardPkg/Library/BeagleBoardLib/BeagleBoardHelper.asm b/BeagleBoardPkg/Library/BeagleBoardLib/BeagleBoardHelper.asm
new file mode 100644
index 0000000000..a05747717f
--- /dev/null
+++ b/BeagleBoardPkg/Library/BeagleBoardLib/BeagleBoardHelper.asm
@@ -0,0 +1,40 @@
+//
+// Copyright (c) 2012-2013, ARM Limited. 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.
+//
+//
+
+#include <AsmMacroIoLib.h>
+#include <Base.h>
+
+#include <AutoGen.h>
+
+ INCLUDE AsmMacroIoLib.inc
+
+ EXPORT ArmPlatformPeiBootAction
+ EXPORT ArmPlatformIsPrimaryCore
+
+ AREA BeagleBoardHelper, CODE, READONLY
+
+//UINTN
+//ArmPlatformIsPrimaryCore (
+// IN UINTN MpId
+// );
+ArmPlatformIsPrimaryCore FUNCTION
+ // BeagleBoard has a single core. We must always return 1.
+ mov r0, #1
+ bx lr
+ ENDFUNC
+
+ArmPlatformPeiBootAction FUNCTION
+ bx lr
+ ENDFUNC
+
+ END
diff --git a/BeagleBoardPkg/Library/BeagleBoardLib/BeagleBoardLib.inf b/BeagleBoardPkg/Library/BeagleBoardLib/BeagleBoardLib.inf
index 7ca98c2bbb..f3242729b7 100755
--- a/BeagleBoardPkg/Library/BeagleBoardLib/BeagleBoardLib.inf
+++ b/BeagleBoardPkg/Library/BeagleBoardLib/BeagleBoardLib.inf
@@ -1,5 +1,5 @@
#/* @file
-# Copyright (c) 2011-2012, ARM Limited. All rights reserved.
+# Copyright (c) 2011-2013, ARM Limited. All rights reserved.
#
# This program and the accompanying materials
# are licensed and made available under the terms and conditions of the BSD License
@@ -31,16 +31,17 @@
[LibraryClasses]
IoLib
ArmLib
-# OmapLib
MemoryAllocationLib
[Sources.common]
+ BeagleBoardHelper.asm | RVCT
+ BeagleBoardHelper.S | GCC
BeagleBoard.c
BeagleBoardMem.c
PadConfiguration.c
Clock.c
-
-[Protocols]
+ BeagleBoardHelper.S | GCC
+ BeagleBoardHelper.asm | RVCT
[FeaturePcd]
gEmbeddedTokenSpaceGuid.PcdCacheEnable
diff --git a/BeagleBoardPkg/Library/BeagleBoardLib/BeagleBoardMem.c b/BeagleBoardPkg/Library/BeagleBoardLib/BeagleBoardMem.c
index 6af30730ed..5524ddbcad 100755
--- a/BeagleBoardPkg/Library/BeagleBoardLib/BeagleBoardMem.c
+++ b/BeagleBoardPkg/Library/BeagleBoardLib/BeagleBoardMem.c
@@ -82,21 +82,3 @@ ArmPlatformGetVirtualMemoryMap (
*VirtualMemoryMap = VirtualMemoryTable;
}
-
-/**
- Return the EFI Memory Map of your platform
-
- This EFI Memory Map of the System Memory is used by MemoryInitPei module to create the Resource
- Descriptor HOBs used by DXE core.
-
- @param[out] EfiMemoryMap Array of ARM_SYSTEM_MEMORY_REGION_DESCRIPTOR describing an
- EFI Memory region. This array must be ended by a zero-filled entry
-
-**/
-EFI_STATUS
-ArmPlatformGetAdditionalSystemMemory (
- OUT ARM_SYSTEM_MEMORY_REGION_DESCRIPTOR** EfiMemoryMap
- )
-{
- return EFI_UNSUPPORTED;
-}
diff --git a/CryptoPkg/Library/BaseCryptLib/Pk/CryptRsaBasic.c b/CryptoPkg/Library/BaseCryptLib/Pk/CryptRsaBasic.c
index cbe3c50fed..3e4309899c 100644
--- a/CryptoPkg/Library/BaseCryptLib/Pk/CryptRsaBasic.c
+++ b/CryptoPkg/Library/BaseCryptLib/Pk/CryptRsaBasic.c
@@ -7,7 +7,7 @@
3) RsaSetKey
4) RsaPkcs1Verify
-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
@@ -21,8 +21,7 @@ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
#include "InternalCryptLib.h"
#include <openssl/rsa.h>
-#include <openssl/err.h>
-
+#include <openssl/objects.h>
/**
Allocates and initializes one RSA context for subsequent use.
@@ -289,8 +288,8 @@ RsaPkcs1Verify (
IN UINTN SigSize
)
{
- INTN Length;
- UINT8 *DecryptedSigature;
+ INT32 DigestType;
+ UINT8 *SigBuf;
//
// Check input parameters.
@@ -302,65 +301,35 @@ RsaPkcs1Verify (
if (SigSize > INT_MAX || SigSize == 0) {
return FALSE;
}
-
- //
- // Check for unsupported hash size:
- // Only MD5, SHA-1 or SHA-256 digest size is supported
- //
- if (HashSize != MD5_DIGEST_SIZE && HashSize != SHA1_DIGEST_SIZE && HashSize != SHA256_DIGEST_SIZE) {
- return FALSE;
- }
-
- //
- // Prepare buffer to store decrypted signature.
- //
- DecryptedSigature = (UINT8 *) malloc (SigSize);
- if (DecryptedSigature == NULL) {
- return FALSE;
- }
//
- // RSA PKCS#1 Signature Decoding using OpenSSL RSA Decryption with Public Key
+ // Determine the message digest algorithm according to digest size.
+ // Only MD5, SHA-1 or SHA-256 algorithm is supported.
//
- Length = RSA_public_decrypt (
- (UINT32) SigSize,
- Signature,
- DecryptedSigature,
- RsaContext,
- RSA_PKCS1_PADDING
- );
+ switch (HashSize) {
+ case MD5_DIGEST_SIZE:
+ DigestType = NID_md5;
+ break;
+
+ case SHA1_DIGEST_SIZE:
+ DigestType = NID_sha1;
+ break;
+
+ case SHA256_DIGEST_SIZE:
+ DigestType = NID_sha256;
+ break;
- //
- // Invalid RSA Key or PKCS#1 Padding Checking Failed (if Length < 0)
- // NOTE: Length should be the addition of HashSize and some DER value.
- // Ignore more strict length checking here.
- //
- if (Length < (INTN) HashSize) {
- free (DecryptedSigature);
+ default:
return FALSE;
}
- //
- // Validate the MessageHash and Decoded Signature
- // NOTE: The decoded Signature should be the DER encoding of the DigestInfo value
- // DigestInfo ::= SEQUENCE {
- // digestAlgorithm AlgorithmIdentifier
- // digest OCTET STRING
- // }
- // Then Memory Comparing should skip the DER value of the underlying SEQUENCE
- // type and AlgorithmIdentifier.
- //
- if (CompareMem (MessageHash, DecryptedSigature + Length - HashSize, HashSize) == 0) {
- //
- // Valid RSA PKCS#1 Signature
- //
- free (DecryptedSigature);
- return TRUE;
- } else {
- //
- // Failed to verification
- //
- free (DecryptedSigature);
- return FALSE;
- }
+ SigBuf = (UINT8 *) Signature;
+ return (BOOLEAN) RSA_verify (
+ DigestType,
+ MessageHash,
+ (UINT32) HashSize,
+ SigBuf,
+ (UINT32) SigSize,
+ (RSA *) RsaContext
+ );
}
diff --git a/CryptoPkg/Library/BaseCryptLib/Pk/CryptRsaExt.c b/CryptoPkg/Library/BaseCryptLib/Pk/CryptRsaExt.c
index b4faafa0c3..5c21d121f5 100644
--- a/CryptoPkg/Library/BaseCryptLib/Pk/CryptRsaExt.c
+++ b/CryptoPkg/Library/BaseCryptLib/Pk/CryptRsaExt.c
@@ -7,7 +7,7 @@
3) RsaCheckKey
4) RsaPkcs1Sign
-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
@@ -22,26 +22,7 @@ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
#include <openssl/rsa.h>
#include <openssl/err.h>
-
-//
-// ASN.1 value for Hash Algorithm ID with the Distringuished Encoding Rules (DER)
-// Refer to Section 9.2 of PKCS#1 v2.1
-//
-CONST UINT8 Asn1IdMd5[] = {
- 0x30, 0x20, 0x30, 0x0c, 0x06, 0x08, 0x2a, 0x86,
- 0xf7, 0x0d, 0x02, 0x05, 0x05, 0x00, 0x04, 0x10
- };
-
-CONST UINT8 Asn1IdSha1[] = {
- 0x30, 0x21, 0x30, 0x09, 0x06, 0x05, 0x2b, 0x0e,
- 0x03, 0x02, 0x1a, 0x05, 0x00, 0x04, 0x14
- };
-
-CONST UINT8 Asn1IdSha256[] = {
- 0x30, 0x31, 0x30, 0x0d, 0x06, 0x09, 0x60, 0x86,
- 0x48, 0x01, 0x65, 0x03, 0x04, 0x02, 0x01, 0x05,
- 0x00, 0x04, 0x20
- };
+#include <openssl/objects.h>
/**
Gets the tag-designated RSA key component from the established RSA context.
@@ -307,75 +288,6 @@ RsaCheckKey (
}
/**
- Performs the PKCS1-v1_5 encoding methods defined in RSA PKCS #1.
-
- @param[in] Message Message buffer to be encoded.
- @param[in] MessageSize Size of message buffer in bytes.
- @param[out] DigestInfo Pointer to buffer of digest info for output.
- @param[in,out] DigestInfoSize On input, the size of DigestInfo buffer in bytes.
- On output, the size of data returned in DigestInfo
- buffer in bytes.
-
- @retval TRUE PKCS1-v1_5 encoding finished successfully.
- @retval FALSE Any input parameter is invalid.
- @retval FALSE DigestInfo buffer is not large enough.
-
-**/
-BOOLEAN
-DigestInfoEncoding (
- IN CONST UINT8 *Message,
- IN UINTN MessageSize,
- OUT UINT8 *DigestInfo,
- IN OUT UINTN *DigestInfoSize
- )
-{
- CONST UINT8 *HashDer;
- UINTN DerSize;
-
- //
- // Check input parameters.
- //
- if (Message == NULL || DigestInfo == NULL || DigestInfoSize == NULL) {
- return FALSE;
- }
-
- //
- // The original message length is used to determine the hash algorithm since
- // message is digest value hashed by the specified algorithm.
- //
- switch (MessageSize) {
- case MD5_DIGEST_SIZE:
- HashDer = Asn1IdMd5;
- DerSize = sizeof (Asn1IdMd5);
- break;
-
- case SHA1_DIGEST_SIZE:
- HashDer = Asn1IdSha1;
- DerSize = sizeof (Asn1IdSha1);
- break;
-
- case SHA256_DIGEST_SIZE:
- HashDer = Asn1IdSha256;
- DerSize = sizeof (Asn1IdSha256);
- break;
-
- default:
- return FALSE;
- }
-
- if (*DigestInfoSize < DerSize + MessageSize) {
- *DigestInfoSize = DerSize + MessageSize;
- return FALSE;
- }
-
- CopyMem (DigestInfo, HashDer, DerSize);
- CopyMem (DigestInfo + DerSize, Message, MessageSize);
-
- *DigestInfoSize = DerSize + MessageSize;
- return TRUE;
-}
-
-/**
Carries out the RSA-SSA signature generation with EMSA-PKCS1-v1_5 encoding scheme.
This function carries out the RSA-SSA signature generation with EMSA-PKCS1-v1_5 encoding scheme defined in
@@ -412,13 +324,12 @@ RsaPkcs1Sign (
{
RSA *Rsa;
UINTN Size;
- INTN ReturnVal;
+ INT32 DigestType;
//
// Check input parameters.
//
- if (RsaContext == NULL || MessageHash == NULL ||
- (HashSize != MD5_DIGEST_SIZE && HashSize != SHA1_DIGEST_SIZE && HashSize != SHA256_DIGEST_SIZE)) {
+ if (RsaContext == NULL || MessageHash == NULL) {
return FALSE;
}
@@ -429,28 +340,38 @@ RsaPkcs1Sign (
*SigSize = Size;
return FALSE;
}
-
+
if (Signature == NULL) {
return FALSE;
}
+
+ //
+ // Determine the message digest algorithm according to digest size.
+ // Only MD5, SHA-1 or SHA-256 algorithm is supported.
+ //
+ switch (HashSize) {
+ case MD5_DIGEST_SIZE:
+ DigestType = NID_md5;
+ break;
+
+ case SHA1_DIGEST_SIZE:
+ DigestType = NID_sha1;
+ break;
+
+ case SHA256_DIGEST_SIZE:
+ DigestType = NID_sha256;
+ break;
- if (!DigestInfoEncoding (MessageHash, HashSize, Signature, SigSize)) {
- return FALSE;
- }
-
- ReturnVal = RSA_private_encrypt (
- (UINT32) *SigSize,
- Signature,
- Signature,
- Rsa,
- RSA_PKCS1_PADDING
- );
-
- if (ReturnVal < (INTN) *SigSize) {
+ default:
return FALSE;
- }
-
- *SigSize = (UINTN) ReturnVal;
- return TRUE;
+ }
+
+ return (BOOLEAN) RSA_sign (
+ DigestType,
+ MessageHash,
+ (UINT32) HashSize,
+ Signature,
+ (UINT32 *) SigSize,
+ (RSA *) RsaContext
+ );
}
-
diff --git a/CryptoPkg/Library/BaseCryptLib/Rand/CryptRand.c b/CryptoPkg/Library/BaseCryptLib/Rand/CryptRand.c
index 4a056e89d8..dc3ab992d0 100644
--- a/CryptoPkg/Library/BaseCryptLib/Rand/CryptRand.c
+++ b/CryptoPkg/Library/BaseCryptLib/Rand/CryptRand.c
@@ -57,7 +57,11 @@ RandomSeed (
RAND_seed (DefaultSeed, sizeof (DefaultSeed));
}
- return TRUE;
+ if (RAND_status () == 1) {
+ return TRUE;
+ }
+
+ return FALSE;
}
/**
diff --git a/CryptoPkg/Library/BaseCryptLib/Rand/CryptRandItc.c b/CryptoPkg/Library/BaseCryptLib/Rand/CryptRandItc.c
index dcc1853f13..0f27f253d2 100644
--- a/CryptoPkg/Library/BaseCryptLib/Rand/CryptRandItc.c
+++ b/CryptoPkg/Library/BaseCryptLib/Rand/CryptRandItc.c
@@ -65,7 +65,11 @@ RandomSeed (
RAND_seed (DefaultSeed, sizeof (DefaultSeed));
}
- return TRUE;
+ if (RAND_status () == 1) {
+ return TRUE;
+ }
+
+ return FALSE;
}
/**
diff --git a/CryptoPkg/Library/BaseCryptLib/Rand/CryptRandTsc.c b/CryptoPkg/Library/BaseCryptLib/Rand/CryptRandTsc.c
index 7259ed50da..dbdd6383a4 100644
--- a/CryptoPkg/Library/BaseCryptLib/Rand/CryptRandTsc.c
+++ b/CryptoPkg/Library/BaseCryptLib/Rand/CryptRandTsc.c
@@ -65,7 +65,11 @@ RandomSeed (
RAND_seed (DefaultSeed, sizeof (DefaultSeed));
}
- return TRUE;
+ if (RAND_status () == 1) {
+ return TRUE;
+ }
+
+ return FALSE;
}
/**
diff --git a/EdkCompatibilityPkg/Compatibility/SmmBaseHelper/SmmBaseHelper.c b/EdkCompatibilityPkg/Compatibility/SmmBaseHelper/SmmBaseHelper.c
index 193ab19756..a2d89eaa21 100644
--- a/EdkCompatibilityPkg/Compatibility/SmmBaseHelper/SmmBaseHelper.c
+++ b/EdkCompatibilityPkg/Compatibility/SmmBaseHelper/SmmBaseHelper.c
@@ -11,7 +11,7 @@
SmmHandlerEntry() will receive untrusted input and do validation.
- 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
@@ -732,6 +732,33 @@ IsAddressInSmram (
return FALSE;
}
+/**
+ This function check if the address refered by Buffer and Length is valid.
+
+ @param Buffer the buffer address to be checked.
+ @param Length the buffer length to be checked.
+
+ @retval TRUE this address is valid.
+ @retval FALSE this address is NOT valid.
+**/
+BOOLEAN
+IsAddressValid (
+ IN UINTN Buffer,
+ IN UINTN Length
+ )
+{
+ if (Buffer > (MAX_ADDRESS - Length)) {
+ //
+ // Overflow happen
+ //
+ return FALSE;
+ }
+ if (IsAddressInSmram ((EFI_PHYSICAL_ADDRESS)Buffer, (UINT64)Length)) {
+ return FALSE;
+ }
+ return TRUE;
+}
+
/**
Thunk service of EFI_SMM_BASE_PROTOCOL.Register().
@@ -1068,7 +1095,7 @@ SmmHandlerEntry (
ASSERT (CommBufferSize != NULL);
if (*CommBufferSize == sizeof (SMMBASE_FUNCTION_DATA) &&
- !IsAddressInSmram ((EFI_PHYSICAL_ADDRESS)(UINTN)CommBuffer, *CommBufferSize)) {
+ IsAddressValid ((UINTN)CommBuffer, *CommBufferSize)) {
FunctionData = (SMMBASE_FUNCTION_DATA *)CommBuffer;
switch (FunctionData->Function) {
diff --git a/EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/BasePrintLib/PrintLib.c b/EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/BasePrintLib/PrintLib.c
index 3258b016b5..4a2168c24d 100644
--- a/EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/BasePrintLib/PrintLib.c
+++ b/EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/BasePrintLib/PrintLib.c
@@ -23,7 +23,7 @@ Abstract:
#include "PrintLibInternal.h"
#define WARNING_STATUS_NUMBER 4
-#define ERROR_STATUS_NUMBER 24
+#define ERROR_STATUS_NUMBER 31
#define ASSERT_UNICODE_BUFFER(Buffer) ASSERT ((((UINTN) (Buffer)) & 0x01) == 0)
GLOBAL_REMOVE_IF_UNREFERENCED CONST CHAR8 *StatusString [] = {
@@ -55,7 +55,14 @@ GLOBAL_REMOVE_IF_UNREFERENCED CONST CHAR8 *StatusString [] = {
"Aborted", // RETURN_ABORTED = 21 | MAX_BIT
"ICMP Error", // RETURN_ICMP_ERROR = 22 | MAX_BIT
"TFTP Error", // RETURN_TFTP_ERROR = 23 | MAX_BIT
- "Protocol Error" // RETURN_PROTOCOL_ERROR = 24 | MAX_BIT
+ "Protocol Error", // RETURN_PROTOCOL_ERROR = 24 | MAX_BIT
+ "Incompatible Version", // RETURN_INCOMPATIBLE_VERSION = 25 | MAX_BIT
+ "Security Violation", // RETURN_SECURITY_VIOLATION = 26 | MAX_BIT
+ "CRC Error", // RETURN_CRC_ERROR = 27 | MAX_BIT
+ "End of Media", // RETURN_END_OF_MEDIA = 28 | MAX_BIT
+ "Reserved (29)", // RESERVED = 29 | MAX_BIT
+ "Reserved (30)", // RESERVED = 30 | MAX_BIT
+ "End of File" // RETURN_END_OF_FILE = 31 | MAX_BIT
};
/**
diff --git a/EdkShellBinPkg/Bin/Ia32/Apps/dmpstore.efi b/EdkShellBinPkg/Bin/Ia32/Apps/dmpstore.efi
index a152dd1f6b..abfbd74b19 100644
--- a/EdkShellBinPkg/Bin/Ia32/Apps/dmpstore.efi
+++ b/EdkShellBinPkg/Bin/Ia32/Apps/dmpstore.efi
Binary files differ
diff --git a/EdkShellBinPkg/Bin/Ipf/Apps/dmpstore.efi b/EdkShellBinPkg/Bin/Ipf/Apps/dmpstore.efi
index ea657c894d..843f729c74 100644
--- a/EdkShellBinPkg/Bin/Ipf/Apps/dmpstore.efi
+++ b/EdkShellBinPkg/Bin/Ipf/Apps/dmpstore.efi
Binary files differ
diff --git a/EdkShellBinPkg/Bin/X64/Apps/dmpstore.efi b/EdkShellBinPkg/Bin/X64/Apps/dmpstore.efi
index e8e161f97c..e1670ff6a6 100644
--- a/EdkShellBinPkg/Bin/X64/Apps/dmpstore.efi
+++ b/EdkShellBinPkg/Bin/X64/Apps/dmpstore.efi
Binary files differ
diff --git a/EdkShellBinPkg/FullShell/Ia32/Shell_Full.efi b/EdkShellBinPkg/FullShell/Ia32/Shell_Full.efi
index f6587d8bd1..4f411f602e 100644
--- a/EdkShellBinPkg/FullShell/Ia32/Shell_Full.efi
+++ b/EdkShellBinPkg/FullShell/Ia32/Shell_Full.efi
Binary files differ
diff --git a/EdkShellBinPkg/FullShell/Ipf/Shell_Full.efi b/EdkShellBinPkg/FullShell/Ipf/Shell_Full.efi
index 72949ad963..58225be57b 100644
--- a/EdkShellBinPkg/FullShell/Ipf/Shell_Full.efi
+++ b/EdkShellBinPkg/FullShell/Ipf/Shell_Full.efi
Binary files differ
diff --git a/EdkShellBinPkg/FullShell/X64/Shell_Full.efi b/EdkShellBinPkg/FullShell/X64/Shell_Full.efi
index a5bbd0b90e..f954bff97c 100644
--- a/EdkShellBinPkg/FullShell/X64/Shell_Full.efi
+++ b/EdkShellBinPkg/FullShell/X64/Shell_Full.efi
Binary files differ
diff --git a/EdkShellBinPkg/ReadMe.txt b/EdkShellBinPkg/ReadMe.txt
index 3ff5067821..0064d0987f 100644
--- a/EdkShellBinPkg/ReadMe.txt
+++ b/EdkShellBinPkg/ReadMe.txt
@@ -1,9 +1,9 @@
-The Ia32/Ipf/X64 binaries of EdkShellBinPkg are generated with EFI shell project (svn r62) and build with Edk Compatibility & BaseTools Package (r12898). The binaries are built with no debug information by building with "RELEASE" target.
+The Ia32/Ipf/X64 binaries of EdkShellBinPkg are generated with EFI shell project (svn r63) and build with Edk Compatibility & BaseTools Package (r12898). 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:
1. Check out EdkCompatibilityPkg (r12898) to $(WORKSPACE)\EdkCompatibilityPkg (svn https://edk2.svn.sourceforge.net/svnroot/edk2/trunk/edk2/EdkCompatibilityPkg).
2. Check out EdkShellPkg (r12898) to $(WORKSPACE)\EdkShellPkg (svn https://edk2.svn.sourceforge.net/svnroot/edk2/trunk/edk2/EdkShellPkg).
-3. Check out Edk Shell project source (r62) to $(WORKSPACE)\Shell (svn https://efi-shell.svn.sourceforge.net/svnroot/efi-shell/trunk/Shell).
+3. Check out Edk Shell project source (r63) to $(WORKSPACE)\Shell (svn https://efi-shell.svn.sourceforge.net/svnroot/efi-shell/trunk/Shell).
4. Check out BaseTools (r12898) to $(WORKSPACE)\BaseTools (svn https://edk2.svn.sourceforge.net/svnroot/edk2/trunk/edk2/BaseTools).
5. Under $(WORKSPACE) directory (i.e. c:\EdkII),
To generate Minimum Shell, execute: "build -a IA32 -a X64 -a IPF -p EdkShellPkg\EdkShellPkg.dsc -m Shell\Shell.inf -b RELEASE".
diff --git a/EmbeddedPkg/Include/Guid/._ExtractSection.h b/EmbeddedPkg/Include/Guid/._ExtractSection.h
deleted file mode 100644
index 951a1f164d..0000000000
--- a/EmbeddedPkg/Include/Guid/._ExtractSection.h
+++ /dev/null
Binary files differ
diff --git a/EmbeddedPkg/Include/Library/SerialPortExtLib.h b/EmbeddedPkg/Include/Library/SerialPortExtLib.h
index a12847ca94..a32365bf78 100644
--- a/EmbeddedPkg/Include/Library/SerialPortExtLib.h
+++ b/EmbeddedPkg/Include/Library/SerialPortExtLib.h
@@ -54,12 +54,12 @@ SerialPortGetControl (
RETURN_STATUS
EFIAPI
SerialPortSetAttributes (
- IN UINT64 BaudRate,
- IN UINT32 ReceiveFifoDepth,
- IN UINT32 Timeout,
- IN EFI_PARITY_TYPE Parity,
- IN UINT8 DataBits,
- IN EFI_STOP_BITS_TYPE StopBits
+ IN OUT UINT64 *BaudRate,
+ IN OUT UINT32 *ReceiveFifoDepth,
+ IN OUT UINT32 *Timeout,
+ IN OUT EFI_PARITY_TYPE *Parity,
+ IN OUT UINT8 *DataBits,
+ IN OUT EFI_STOP_BITS_TYPE *StopBits
);
#endif
diff --git a/EmbeddedPkg/Library/TemplateSerialPortExtLib/TemplateSerialPortExtLib.c b/EmbeddedPkg/Library/TemplateSerialPortExtLib/TemplateSerialPortExtLib.c
index 5a007c25f6..f993cbf5c0 100644
--- a/EmbeddedPkg/Library/TemplateSerialPortExtLib/TemplateSerialPortExtLib.c
+++ b/EmbeddedPkg/Library/TemplateSerialPortExtLib/TemplateSerialPortExtLib.c
@@ -66,12 +66,12 @@ SerialPortGetControl (
RETURN_STATUS
EFIAPI
SerialPortSetAttributes (
- IN UINT64 BaudRate,
- IN UINT32 ReceiveFifoDepth,
- IN UINT32 Timeout,
- IN EFI_PARITY_TYPE Parity,
- IN UINT8 DataBits,
- IN EFI_STOP_BITS_TYPE StopBits
+ IN OUT UINT64 *BaudRate,
+ IN OUT UINT32 *ReceiveFifoDepth,
+ IN OUT UINT32 *Timeout,
+ IN OUT EFI_PARITY_TYPE *Parity,
+ IN OUT UINT8 *DataBits,
+ IN OUT EFI_STOP_BITS_TYPE *StopBits
)
{
return RETURN_UNSUPPORTED;
diff --git a/EmbeddedPkg/SerialDxe/SerialIo.c b/EmbeddedPkg/SerialDxe/SerialIo.c
index a94bacaf40..288f353cba 100644
--- a/EmbeddedPkg/SerialDxe/SerialIo.c
+++ b/EmbeddedPkg/SerialDxe/SerialIo.c
@@ -7,6 +7,7 @@
Copyright (c) 2008 - 2009, Apple Inc. All rights reserved.<BR>
+ 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
@@ -165,7 +166,7 @@ SerialSetAttributes (
EFI_STATUS Status;
EFI_TPL Tpl;
- Status = SerialPortSetAttributes (BaudRate, ReceiveFifoDepth, Timeout, Parity, DataBits, StopBits);
+ Status = SerialPortSetAttributes (&BaudRate, &ReceiveFifoDepth, &Timeout, &Parity, &DataBits, &StopBits);
if (EFI_ERROR(Status)) {
return Status;
}
diff --git a/EmbeddedPkg/Universal/MmcDxe/MmcBlockIo.c b/EmbeddedPkg/Universal/MmcDxe/MmcBlockIo.c
index 9a0320b2be..0fae25c436 100644
--- a/EmbeddedPkg/Universal/MmcDxe/MmcBlockIo.c
+++ b/EmbeddedPkg/Universal/MmcDxe/MmcBlockIo.c
@@ -1,14 +1,14 @@
/** @file
*
* Copyright (c) 2011-2013, ARM Limited. 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.
+* This program and the accompanying materials
+* are licensed and made 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.
*
**/
@@ -16,15 +16,50 @@
#include <Library/DebugLib.h>
#include <Library/BaseMemoryLib.h>
#include <Library/TimerLib.h>
+#include <Library/UefiBootServicesTableLib.h>
#include "Mmc.h"
-// Untested ...
-//#define USE_STREAM
-
#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 ;
+}
+
+
EFI_STATUS
MmcNotifyState (
IN MMC_HOST_INSTANCE *MmcHostInstance,
@@ -236,10 +271,7 @@ MmcIdentificationMode (
// Are we using SDIO ?
Status = MmcHost->SendCommand (MmcHost, MMC_CMD5, 0);
-#if 1 // Added for Panda Board
- /* It seems few SD cards need some time to recover from this command? */
- MicroSecondDelay(1000);
-#endif
+ MicroSecondDelay(1000); /* It seems some SD cards need time to recover from this command? */
if (Status == EFI_SUCCESS) {
DEBUG ((EFI_D_ERROR, "MmcIdentificationMode(MMC_CMD5): Error - SDIO not supported.\n"));
@@ -269,44 +301,44 @@ MmcIdentificationMode (
// SD Card or MMC Card ? CMD55 indicates to the card that the next command is an application specific command
Status = MmcHost->SendCommand (MmcHost, MMC_CMD55, 0);
if (Status == EFI_SUCCESS) {
- DEBUG ((EFI_D_INFO, "Card should be SD\n"));
- if (IsHCS) {
- MmcHostInstance->CardInfo.CardType = SD_CARD_2;
- } else {
- MmcHostInstance->CardInfo.CardType = SD_CARD;
- }
+ DEBUG ((EFI_D_INFO, "Card should be SD\n"));
+ if (IsHCS) {
+ MmcHostInstance->CardInfo.CardType = SD_CARD_2;
+ } else {
+ MmcHostInstance->CardInfo.CardType = SD_CARD;
+ }
- // Note: The first time CmdArg will be zero
- CmdArg = ((UINTN *) &(MmcHostInstance->CardInfo.OCRData))[0];
- if (IsHCS) {
- CmdArg |= BIT30;
- }
- Status = MmcHost->SendCommand (MmcHost, MMC_ACMD41, CmdArg);
- if (!EFI_ERROR (Status)) {
- MmcHost->ReceiveResponse (MmcHost, MMC_RESPONSE_TYPE_OCR, Response);
- ((UINT32 *) &(MmcHostInstance->CardInfo.OCRData))[0] = Response[0];
- }
+ // Note: The first time CmdArg will be zero
+ CmdArg = ((UINTN *) &(MmcHostInstance->CardInfo.OCRData))[0];
+ if (IsHCS) {
+ CmdArg |= BIT30;
+ }
+ Status = MmcHost->SendCommand (MmcHost, MMC_ACMD41, CmdArg);
+ if (!EFI_ERROR (Status)) {
+ MmcHost->ReceiveResponse (MmcHost, MMC_RESPONSE_TYPE_OCR, Response);
+ ((UINT32 *) &(MmcHostInstance->CardInfo.OCRData))[0] = Response[0];
+ }
} else {
- DEBUG ((EFI_D_INFO, "Card should be MMC\n"));
- MmcHostInstance->CardInfo.CardType = MMC_CARD;
+ DEBUG ((EFI_D_INFO, "Card should be MMC\n"));
+ MmcHostInstance->CardInfo.CardType = MMC_CARD;
- Status = MmcHost->SendCommand (MmcHost, MMC_CMD1, 0x800000);
- if (!EFI_ERROR (Status)) {
- MmcHost->ReceiveResponse (MmcHost, MMC_RESPONSE_TYPE_OCR, Response);
- ((UINT32 *) &(MmcHostInstance->CardInfo.OCRData))[0] = Response[0];
- }
+ Status = MmcHost->SendCommand (MmcHost, MMC_CMD1, 0x800000);
+ if (!EFI_ERROR (Status)) {
+ MmcHost->ReceiveResponse (MmcHost, MMC_RESPONSE_TYPE_OCR, Response);
+ ((UINT32 *) &(MmcHostInstance->CardInfo.OCRData))[0] = Response[0];
+ }
}
if (!EFI_ERROR (Status)) {
if (!MmcHostInstance->CardInfo.OCRData.PowerUp) {
- MicroSecondDelay (1);
- Timeout--;
+ MicroSecondDelay (1);
+ Timeout--;
} else {
- if ((MmcHostInstance->CardInfo.CardType == SD_CARD_2) && (MmcHostInstance->CardInfo.OCRData.AccessMode & BIT1)) {
- MmcHostInstance->CardInfo.CardType = SD_CARD_2_HIGH;
- DEBUG ((EFI_D_ERROR, "High capacity card.\n"));
- }
- break; // The MMC/SD card is ready. Continue the Identification Mode
+ if ((MmcHostInstance->CardInfo.CardType == SD_CARD_2) && (MmcHostInstance->CardInfo.OCRData.AccessMode & BIT1)) {
+ MmcHostInstance->CardInfo.CardType = SD_CARD_2_HIGH;
+ DEBUG ((EFI_D_ERROR, "High capacity card.\n"));
+ }
+ break; // The MMC/SD card is ready. Continue the Identification Mode
}
} else {
MicroSecondDelay (1);
@@ -380,8 +412,9 @@ EFI_STATUS InitializeMmcDevice (
EFI_STATUS Status;
UINTN CardSize, NumBlocks, BlockSize, CmdArg;
EFI_MMC_HOST_PROTOCOL *MmcHost;
- UINTN BlockCount = 1;
-
+ UINTN BlockCount;
+
+ BlockCount = 1;
MmcHost = MmcHostInstance->MmcHost;
MmcIdentificationMode (MmcHostInstance);
@@ -390,7 +423,7 @@ EFI_STATUS InitializeMmcDevice (
CmdArg = MmcHostInstance->CardInfo.RCA << 16;
Status = MmcHost->SendCommand (MmcHost, MMC_CMD9, CmdArg);
if (EFI_ERROR (Status)) {
- DEBUG ((EFI_D_ERROR, "MmcIdentificationMode(MMC_CMD9): Error, Status=%r\n", Status));
+ DEBUG((EFI_D_ERROR, "%a(MMC_CMD9): Error, Status=%r\n", __FUNCTION__, Status));
return Status;
}
//Read Response
@@ -422,20 +455,21 @@ EFI_STATUS InitializeMmcDevice (
CmdArg = MmcHostInstance->CardInfo.RCA << 16;
Status = MmcHost->SendCommand (MmcHost, MMC_CMD7, CmdArg);
if (EFI_ERROR (Status)) {
- DEBUG ((EFI_D_ERROR, "MmcIdentificationMode(MMC_CMD7): Error and Status = %r\n", Status));
+ DEBUG((EFI_D_ERROR, "%a(MMC_CMD7): Error and Status = %r\n", __FUNCTION__, Status));
return Status;
}
Status = MmcNotifyState (MmcHostInstance, MmcTransferState);
if (EFI_ERROR (Status)) {
- DEBUG ((EFI_D_ERROR, "MmcIdentificationMode() : Error MmcTransferState\n"));
+ DEBUG((EFI_D_ERROR, "%a(): Error MmcTransferState\n", __FUNCTION__));
return Status;
}
// Set Block Length
Status = MmcHost->SendCommand (MmcHost, MMC_CMD16, MmcHostInstance->BlockIo.Media->BlockSize);
if (EFI_ERROR (Status)) {
- DEBUG ((EFI_D_ERROR, "MmcIdentificationMode(MMC_CMD16): Error MmcHostInstance->BlockIo.Media->BlockSize: %d and Error = %r\n", MmcHostInstance->BlockIo.Media->BlockSize, Status));
+ DEBUG((EFI_D_ERROR, "%a(MMC_CMD16): Error MmcHostInstance->BlockIo.Media->BlockSize: %d and Error = %r\n",
+ __FUNCTION__, MmcHostInstance->BlockIo.Media->BlockSize, Status));
return Status;
}
@@ -493,6 +527,22 @@ MmcDetectCard (
}
}
+EFI_STATUS
+MmcStopTransmission (
+ EFI_MMC_HOST_PROTOCOL *MmcHost
+ )
+{
+ EFI_STATUS Status;
+ UINT32 Response[4];
+ // Command 12 - Stop transmission (ends read or write)
+ // Normally only needed for streaming transfers or after error.
+ Status = MmcHost->SendCommand (MmcHost, MMC_CMD12, 0);
+ if (!EFI_ERROR (Status)) {
+ MmcHost->ReceiveResponse (MmcHost, MMC_RESPONSE_TYPE_R1b, Response);
+ }
+ return Status;
+}
+
#define MMCI0_BLOCKLEN 512
#define MMCI0_TIMEOUT 10000
@@ -514,14 +564,20 @@ MmcIoBlocks (
MMC_HOST_INSTANCE *MmcHostInstance;
EFI_MMC_HOST_PROTOCOL *MmcHost;
UINTN BytesRemainingToBeTransfered;
- UINTN BlockCount = 1;
+ UINTN BlockCount;
+ EFI_TPL Tpl;
+ BlockCount = 1;
MmcHostInstance = MMC_HOST_INSTANCE_FROM_BLOCK_IO_THIS (This);
- ASSERT (MmcHostInstance != 0);
+ ASSERT(MmcHostInstance != NULL);
MmcHost = MmcHostInstance->MmcHost;
ASSERT (MmcHost);
- if ((MmcHost == 0)|| (Buffer == NULL)) {
+ if (This->Media->MediaId != MediaId) {
+ return EFI_MEDIA_CHANGED;
+ }
+
+ if ((MmcHost == NULL) || (Buffer == NULL)) {
return EFI_INVALID_PARAMETER;
}
@@ -535,17 +591,23 @@ MmcIoBlocks (
return EFI_INVALID_PARAMETER;
}
- // The buffer size must not be zero and it must be an exact multiple of the block size
- if ((BufferSize == 0) || ((BufferSize % This->Media->BlockSize) != 0)) {
- return EFI_BAD_BUFFER_SIZE;
+ if((Transfer == MMC_IOBLOCKS_WRITE) && (This->Media->ReadOnly == TRUE)) {
+ return EFI_WRITE_PROTECTED;
}
- if (This->Media->MediaId != MediaId) {
- return EFI_MEDIA_CHANGED;
+ // Reading 0 Byte is valid
+ if (BufferSize == 0) {
+ return EFI_SUCCESS;
}
- if((Transfer == MMC_IOBLOCKS_WRITE) && (This->Media->ReadOnly == TRUE)) {
- return EFI_WRITE_PROTECTED;
+ // The buffer size must be an exact multiple of the block size
+ if ((BufferSize % This->Media->BlockSize) != 0) {
+ return EFI_BAD_BUFFER_SIZE;
+ }
+
+ // Check the alignment
+ if ((This->Media->IoAlign > 2) && (((UINTN)Buffer & (This->Media->IoAlign - 1)) != 0)) {
+ return EFI_INVALID_PARAMETER;
}
BytesRemainingToBeTransfered = BufferSize;
@@ -577,61 +639,44 @@ MmcIoBlocks (
}
if (Transfer == MMC_IOBLOCKS_READ) {
-#ifndef USE_STREAM
// Read a single block
Cmd = MMC_CMD17;
-#else
- //TODO: Should we support read stream (MMC_CMD11)
-#endif
} else {
-#ifndef USE_STREAM
// Write a single block
Cmd = MMC_CMD24;
-#else
- //TODO: Should we support write stream (MMC_CMD20)
-#endif
}
+ // 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);
DEBUG ((EFI_D_ERROR, "MmcIoBlocks(MMC_CMD%d): Error %r\n", Cmd, Status));
return Status;
}
if (Transfer == MMC_IOBLOCKS_READ) {
-#ifndef USE_STREAM
// Read one block of Data
Status = MmcHost->ReadBlockData (MmcHost, Lba, This->Media->BlockSize, Buffer);
+ gBS->RestoreTPL(Tpl) ;
if (EFI_ERROR (Status)) {
DEBUG ((EFI_D_BLKIO, "MmcIoBlocks(): Error Read Block Data and Status = %r\n", Status));
+ MmcStopTransmission(MmcHost) ;
return Status;
}
-#else
- //TODO: Read a stream
- ASSERT (0);
-#endif
Status = MmcNotifyState (MmcHostInstance, MmcProgrammingState);
if (EFI_ERROR (Status)) {
DEBUG ((EFI_D_ERROR, "MmcIoBlocks() : Error MmcProgrammingState\n"));
return Status;
}
} else {
-#ifndef USE_STREAM
// Write one block of Data
Status = MmcHost->WriteBlockData (MmcHost, Lba, This->Media->BlockSize, Buffer);
+ gBS->RestoreTPL(Tpl) ;
if (EFI_ERROR (Status)) {
DEBUG ((EFI_D_BLKIO, "MmcIoBlocks(): Error Write Block Data and Status = %r\n", Status));
+ MmcStopTransmission(MmcHost) ;
return Status;
}
-#else
- //TODO: Write a stream
- ASSERT (0);
-#endif
- }
-
- // Command 12 - Stop transmission (ends read)
- Status = MmcHost->SendCommand (MmcHost, MMC_CMD12, 0);
- if (!EFI_ERROR (Status)) {
- MmcHost->ReceiveResponse (MmcHost, MMC_RESPONSE_TYPE_R1b, Response);
}
// Command 13 - Read status and wait for programming to complete (return to tran)
diff --git a/EmulatorPkg/EmulatorPkg.dsc b/EmulatorPkg/EmulatorPkg.dsc
index 1c71269d3d..ae318bd096 100644
--- a/EmulatorPkg/EmulatorPkg.dsc
+++ b/EmulatorPkg/EmulatorPkg.dsc
@@ -86,6 +86,7 @@
SecurityManagementLib|MdeModulePkg/Library/DxeSecurityManagementLib/DxeSecurityManagementLib.inf
TimerLib|MdePkg/Library/BaseTimerLibNullTemplate/BaseTimerLibNullTemplate.inf
SerialPortLib|MdePkg/Library/BaseSerialPortLibNull/BaseSerialPortLibNull.inf
+ SerialPortExtLib|EmbeddedPkg/Library/TemplateSerialPortExtLib/TemplateSerialPortExtLib.inf
CapsuleLib|MdeModulePkg/Library/DxeCapsuleLibNull/DxeCapsuleLibNull.inf
#
# Platform
diff --git a/EmulatorPkg/Library/DxeEmuSerialPortLib/DxeEmuSerialPortLib.c b/EmulatorPkg/Library/DxeEmuSerialPortLib/DxeEmuSerialPortLib.c
index 2efb8400fa..792bd62a1c 100644
--- a/EmulatorPkg/Library/DxeEmuSerialPortLib/DxeEmuSerialPortLib.c
+++ b/EmulatorPkg/Library/DxeEmuSerialPortLib/DxeEmuSerialPortLib.c
@@ -17,7 +17,6 @@
#include <PiDxe.h>
#include <Library/SerialPortLib.h>
-#include <Library/SerialPortExtLib.h>
#include <Library/EmuThunkLib.h>
@@ -117,57 +116,3 @@ SerialPortPoll (
return gEmuThunk->PollStdIn ();
}
-/**
- Set the serial device control bits.
-
- @return Always return EFI_UNSUPPORTED.
-
-**/
-RETURN_STATUS
-EFIAPI
-SerialPortSetControl (
- IN UINT32 Control
- )
-{
- return RETURN_SUCCESS;
-}
-
-/**
- Get the serial device control bits.
-
- @param Control Control signals read from the serial device.
-
- @retval EFI_SUCCESS The control bits were read from the serial device.
- @retval EFI_DEVICE_ERROR The serial device is not functioning correctly.
-
-**/
-RETURN_STATUS
-EFIAPI
-SerialPortGetControl (
- OUT UINT32 *Control
- )
-{
- return RETURN_SUCCESS;
-}
-
-
-/**
- Set the serial device attributes.
-
- @return Always return EFI_UNSUPPORTED.
-
-**/
-RETURN_STATUS
-EFIAPI
-SerialPortSetAttributes (
- IN UINT64 BaudRate,
- IN UINT32 ReceiveFifoDepth,
- IN UINT32 Timeout,
- IN EFI_PARITY_TYPE Parity,
- IN UINT8 DataBits,
- IN EFI_STOP_BITS_TYPE StopBits
- )
-{
- return RETURN_SUCCESS;
-}
-
diff --git a/EmulatorPkg/Library/PeiEmuSerialPortLib/PeiEmuSerialPortLib.c b/EmulatorPkg/Library/PeiEmuSerialPortLib/PeiEmuSerialPortLib.c
index 3b74a0c325..b3a20a9811 100644
--- a/EmulatorPkg/Library/PeiEmuSerialPortLib/PeiEmuSerialPortLib.c
+++ b/EmulatorPkg/Library/PeiEmuSerialPortLib/PeiEmuSerialPortLib.c
@@ -18,7 +18,6 @@
#include <PiPei.h>
#include <Library/SerialPortLib.h>
-#include <Library/SerialPortExtLib.h>
#include <Library/PeiServicesLib.h>
#include <Ppi/EmuThunk.h>
@@ -138,58 +137,3 @@ SerialPortPoll (
return FALSE;
}
-/**
- Set the serial device control bits.
-
- @return Always return EFI_UNSUPPORTED.
-
-**/
-RETURN_STATUS
-EFIAPI
-SerialPortSetControl (
- IN UINT32 Control
- )
-{
- return RETURN_SUCCESS;
-}
-
-/**
- Get the serial device control bits.
-
- @param Control Control signals read from the serial device.
-
- @retval EFI_SUCCESS The control bits were read from the serial device.
- @retval EFI_DEVICE_ERROR The serial device is not functioning correctly.
-
-**/
-RETURN_STATUS
-EFIAPI
-SerialPortGetControl (
- OUT UINT32 *Control
- )
-{
- return RETURN_SUCCESS;
-}
-
-
-/**
- Set the serial device attributes.
-
- @return Always return EFI_UNSUPPORTED.
-
-**/
-RETURN_STATUS
-EFIAPI
-SerialPortSetAttributes (
- IN UINT64 BaudRate,
- IN UINT32 ReceiveFifoDepth,
- IN UINT32 Timeout,
- IN EFI_PARITY_TYPE Parity,
- IN UINT8 DataBits,
- IN EFI_STOP_BITS_TYPE StopBits
- )
-{
- return RETURN_SUCCESS;
-}
-
-
diff --git a/IntelFrameworkModulePkg/Bus/Isa/IsaFloppyPei/FloppyPeim.c b/IntelFrameworkModulePkg/Bus/Isa/IsaFloppyPei/FloppyPeim.c
index afeb2213c0..d1b7dcf416 100644
--- a/IntelFrameworkModulePkg/Bus/Isa/IsaFloppyPei/FloppyPeim.c
+++ b/IntelFrameworkModulePkg/Bus/Isa/IsaFloppyPei/FloppyPeim.c
@@ -1,7 +1,7 @@
/** @file
Floppy Peim to support Recovery function from Floppy device.
-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
@@ -1018,22 +1018,12 @@ DiscoverFdcDevice (
// Check Media
//
Status = DisketChanged (FdcBlkIoDev, Info);
- switch (Status) {
- case EFI_NO_MEDIA:
+ if (Status == EFI_NO_MEDIA) {
//
// No diskette in floppy.
//
- MediaInfo->MediaPresent = FALSE;
- break;
-
- case EFI_MEDIA_CHANGED:
- case EFI_SUCCESS:
- //
- // Diskette exists in floppy.
- //
- break;
-
- default:
+ MediaInfo->MediaPresent = FALSE;
+ } else if (Status != EFI_MEDIA_CHANGED && Status != EFI_SUCCESS) {
//
// EFI_DEVICE_ERROR
//
diff --git a/IntelFrameworkModulePkg/Csm/LegacyBiosDxe/LegacyPci.c b/IntelFrameworkModulePkg/Csm/LegacyBiosDxe/LegacyPci.c
index 5b1117eb1b..fd5641a874 100644
--- a/IntelFrameworkModulePkg/Csm/LegacyBiosDxe/LegacyPci.c
+++ b/IntelFrameworkModulePkg/Csm/LegacyBiosDxe/LegacyPci.c
@@ -2914,7 +2914,15 @@ LegacyBiosInstallPciRom (
return EFI_UNSUPPORTED;
}
- if (!Private->VgaInstalled) {
+ Status = Private->LegacyBiosPlatform->GetPlatformHandle (
+ Private->LegacyBiosPlatform,
+ EfiGetPlatformVgaHandle,
+ 0,
+ &HandleBuffer,
+ &HandleCount,
+ NULL
+ );
+ if ((!EFI_ERROR (Status)) && (!Private->VgaInstalled)) {
//
// A return status of EFI_NOT_FOUND is considered valid (No EFI
// driver is controlling video.
@@ -2942,7 +2950,7 @@ LegacyBiosInstallPciRom (
Pcir = (PCI_3_0_DATA_STRUCTURE *)
((UINT8 *) LocalRomImage + ((PCI_EXPANSION_ROM_HEADER *) LocalRomImage)->PcirOffset);
- if (Pcir->Signature != PCI_DATA_STRUCTURE_SIGNATURE) {
+ if ((Pcir->Signature != PCI_DATA_STRUCTURE_SIGNATURE) || (Pcir->CodeType != PCI_CODE_TYPE_PCAT_IMAGE)) {
mVgaInstallationInProgress = FALSE;
return EFI_UNSUPPORTED;
}
diff --git a/IntelFrameworkModulePkg/IntelFrameworkModulePkg.dsc b/IntelFrameworkModulePkg/IntelFrameworkModulePkg.dsc
index b004067155..4f4d63dc4a 100644
--- a/IntelFrameworkModulePkg/IntelFrameworkModulePkg.dsc
+++ b/IntelFrameworkModulePkg/IntelFrameworkModulePkg.dsc
@@ -3,7 +3,7 @@
#
# This file is used to build all modules in IntelFrameworkModulePkg.
#
-#Copyright (c) 2007 - 2012, 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 that accompanies this distribution.
#The full text of the license may be found at
@@ -80,6 +80,9 @@
PcdLib|MdePkg/Library/PeiPcdLib/PeiPcdLib.inf
MemoryAllocationLib|MdePkg/Library/PeiMemoryAllocationLib/PeiMemoryAllocationLib.inf
+[LibraryClasses.EBC.PEIM]
+ IoLib|MdePkg/Library/PeiIoLibCpuIo/PeiIoLibCpuIo.inf
+
[LibraryClasses.common.DXE_DRIVER]
LockBoxLib|MdeModulePkg/Library/SmmLockBoxLib/SmmLockBoxDxeLib.inf
diff --git a/IntelFrameworkModulePkg/Library/GenericBdsLib/BdsBoot.c b/IntelFrameworkModulePkg/Library/GenericBdsLib/BdsBoot.c
index c04c586f50..06ba0fcf79 100644
--- a/IntelFrameworkModulePkg/Library/GenericBdsLib/BdsBoot.c
+++ b/IntelFrameworkModulePkg/Library/GenericBdsLib/BdsBoot.c
@@ -1,7 +1,7 @@
/** @file
BDS Lib functions which relate with create or process the boot option.
-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
@@ -2229,10 +2229,6 @@ BdsLibBootViaBootOption (
LIST_ENTRY TempBootLists;
EFI_BOOT_LOGO_PROTOCOL *BootLogo;
- PERF_CODE (
- AllocateMemoryForPerformanceData ();
- );
-
*ExitDataSize = 0;
*ExitData = NULL;
diff --git a/IntelFrameworkModulePkg/Library/GenericBdsLib/InternalBdsLib.h b/IntelFrameworkModulePkg/Library/GenericBdsLib/InternalBdsLib.h
index 5d51635bf1..1384febc98 100644
--- a/IntelFrameworkModulePkg/Library/GenericBdsLib/InternalBdsLib.h
+++ b/IntelFrameworkModulePkg/Library/GenericBdsLib/InternalBdsLib.h
@@ -87,16 +87,6 @@ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
/**
- Allocates a block of memory to store performance data.
-
-**/
-VOID
-AllocateMemoryForPerformanceData (
- VOID
- );
-
-/**
-
Writes performance data of booting into the allocated memory.
OS can process these records.
diff --git a/IntelFrameworkModulePkg/Library/GenericBdsLib/Performance.c b/IntelFrameworkModulePkg/Library/GenericBdsLib/Performance.c
index 7e6d358d84..047d2a7dbc 100644
--- a/IntelFrameworkModulePkg/Library/GenericBdsLib/Performance.c
+++ b/IntelFrameworkModulePkg/Library/GenericBdsLib/Performance.c
@@ -3,7 +3,7 @@
performance, all the function will only include if the performance
switch is set.
-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
@@ -19,7 +19,6 @@ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
PERF_HEADER mPerfHeader;
PERF_DATA mPerfData;
EFI_PHYSICAL_ADDRESS mAcpiLowMemoryBase = 0x0FFFFFFFFULL;
-UINT32 mAcpiLowMemoryLength = 0x4000;
/**
Get the short verion of PDB file name to be
@@ -136,40 +135,6 @@ GetNameFromHandle (
/**
- Allocates a block of memory to store performance data.
-
-**/
-VOID
-AllocateMemoryForPerformanceData (
- VOID
- )
-{
- EFI_STATUS Status;
-
- if (mAcpiLowMemoryBase == 0x0FFFFFFFF) {
- //
- // Allocate a block of memory that contain performance data to OS
- //
- Status = gBS->AllocatePages (
- AllocateMaxAddress,
- EfiReservedMemoryType,
- EFI_SIZE_TO_PAGES (mAcpiLowMemoryLength),
- &mAcpiLowMemoryBase
- );
- if (!EFI_ERROR (Status)) {
- gRT->SetVariable (
- L"PerfDataMemAddr",
- &gPerformanceProtocolGuid,
- EFI_VARIABLE_NON_VOLATILE | EFI_VARIABLE_BOOTSERVICE_ACCESS | EFI_VARIABLE_RUNTIME_ACCESS,
- sizeof (EFI_PHYSICAL_ADDRESS),
- &mAcpiLowMemoryBase
- );
- }
- }
-}
-
-/**
-
Writes performance data of booting into the allocated memory.
OS can process these records.
@@ -209,16 +174,13 @@ WriteBootToOsPerformanceData (
// List of flags indicating PerfEntry contains DXE handle
//
BOOLEAN *PerfEntriesAsDxeHandle;
+ UINTN VarSize;
//
// Record the performance data for End of BDS
//
PERF_END(NULL, "BDS", NULL, 0);
- if (mAcpiLowMemoryBase == 0x0FFFFFFFF) {
- return;
- }
-
//
// Retrieve time stamp count as early as possible
//
@@ -241,6 +203,23 @@ WriteBootToOsPerformanceData (
CountUp = FALSE;
}
+ if (mAcpiLowMemoryBase == 0x0FFFFFFFF) {
+ VarSize = sizeof (EFI_PHYSICAL_ADDRESS);
+ Status = gRT->GetVariable (
+ L"PerfDataMemAddr",
+ &gPerformanceProtocolGuid,
+ NULL,
+ &VarSize,
+ &mAcpiLowMemoryBase
+ );
+ if (EFI_ERROR (Status)) {
+ //
+ // Fail to get the variable, return.
+ //
+ return;
+ }
+ }
+
//
// Put Detailed performance data into memory
//
@@ -257,7 +236,7 @@ WriteBootToOsPerformanceData (
}
Ptr = (UINT8 *) ((UINT32) mAcpiLowMemoryBase + sizeof (PERF_HEADER));
- LimitCount = (mAcpiLowMemoryLength - sizeof (PERF_HEADER)) / sizeof (PERF_DATA);
+ LimitCount = (UINT32) (PERF_DATA_MAX_LENGTH - sizeof (PERF_HEADER)) / sizeof (PERF_DATA);
NumPerfEntries = 0;
LogEntryKey = 0;
diff --git a/IntelFrameworkModulePkg/Universal/BdsDxe/Bds.h b/IntelFrameworkModulePkg/Universal/BdsDxe/Bds.h
index 0929f1d27b..0aba09c1bf 100644
--- a/IntelFrameworkModulePkg/Universal/BdsDxe/Bds.h
+++ b/IntelFrameworkModulePkg/Universal/BdsDxe/Bds.h
@@ -1,7 +1,7 @@
/** @file
Head file for BDS Architectural Protocol 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
@@ -35,6 +35,7 @@ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
#include <Guid/LegacyDevOrder.h>
#include <Guid/BdsHii.h>
#include <Guid/ConnectConInEvent.h>
+#include <Guid/Performance.h>
#include <Protocol/GenericMemoryTest.h>
#include <Protocol/FormBrowser2.h>
#include <Protocol/HiiConfigAccess.h>
@@ -47,6 +48,7 @@ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
#include <Protocol/SimpleTextInEx.h>
#include <Protocol/DriverHealth.h>
#include <Protocol/BootLogo.h>
+#include <Protocol/VariableLock.h>
#include <Library/UefiDriverEntryPoint.h>
#include <Library/PrintLib.h>
@@ -65,7 +67,6 @@ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
#include <Library/CapsuleLib.h>
#include <Library/HiiLib.h>
#include <Library/DevicePathLib.h>
-#include <Library/PcdLib.h>
#include <Library/UefiHiiServicesLib.h>
#include <Library/GenericBdsLib.h>
diff --git a/IntelFrameworkModulePkg/Universal/BdsDxe/BdsDxe.inf b/IntelFrameworkModulePkg/Universal/BdsDxe/BdsDxe.inf
index a60738e946..2424a8a842 100644
--- a/IntelFrameworkModulePkg/Universal/BdsDxe/BdsDxe.inf
+++ b/IntelFrameworkModulePkg/Universal/BdsDxe/BdsDxe.inf
@@ -14,7 +14,7 @@
# BDSDxe also maintain the UI for "Boot Manager, Boot Maintaince Manager, Device Manager" which
# is used for user to configure boot option or maintain hardware device.
#
-# Copyright (c) 2008 - 2012, 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
@@ -160,6 +160,7 @@
gEfiDriverHealthProtocolGuid ## PROTOCOL SOMETIMES_CONSUMES
gEfiPciIoProtocolGuid ## PROTOCOL CONSUMES
gEfiBootLogoProtocolGuid ## PROTOCOL SOMETIMES_CONSUMES
+ gEdkiiVariableLockProtocolGuid ## PROTOCOL CONSUMES
[FeaturePcd]
gEfiMdePkgTokenSpaceGuid.PcdUefiVariableDefaultLangDeprecate
diff --git a/IntelFrameworkModulePkg/Universal/BdsDxe/BdsEntry.c b/IntelFrameworkModulePkg/Universal/BdsDxe/BdsEntry.c
index 6eaec886f2..77c88b0d24 100644
--- a/IntelFrameworkModulePkg/Universal/BdsDxe/BdsEntry.c
+++ b/IntelFrameworkModulePkg/Universal/BdsDxe/BdsEntry.c
@@ -38,6 +38,17 @@ EFI_BDS_ARCH_PROTOCOL gBds = {
UINT16 *mBootNext = NULL;
+///
+/// The read-only variables defined in UEFI Spec.
+///
+CHAR16 *mReadOnlyVariables[] = {
+ L"PlatformLangCodes",
+ L"LangCodes",
+ L"BootOptionSupport",
+ L"HwErrRecSupport",
+ L"OsIndicationsSupported"
+ };
+
/**
Install Boot Device Selection Protocol
@@ -441,6 +452,54 @@ BdsFormalizeEfiGlobalVariable (
/**
+ Allocate a block of memory that will contain performance data to OS.
+
+**/
+VOID
+BdsAllocateMemoryForPerformanceData (
+ VOID
+ )
+{
+ EFI_STATUS Status;
+ EFI_PHYSICAL_ADDRESS AcpiLowMemoryBase;
+ EDKII_VARIABLE_LOCK_PROTOCOL *VariableLock;
+
+ AcpiLowMemoryBase = 0x0FFFFFFFFULL;
+
+ //
+ // Allocate a block of memory that will contain performance data to OS.
+ //
+ Status = gBS->AllocatePages (
+ AllocateMaxAddress,
+ EfiReservedMemoryType,
+ EFI_SIZE_TO_PAGES (PERF_DATA_MAX_LENGTH),
+ &AcpiLowMemoryBase
+ );
+ if (!EFI_ERROR (Status)) {
+ //
+ // Save the pointer to variable for use in S3 resume.
+ //
+ Status = gRT->SetVariable (
+ L"PerfDataMemAddr",
+ &gPerformanceProtocolGuid,
+ EFI_VARIABLE_NON_VOLATILE | EFI_VARIABLE_BOOTSERVICE_ACCESS | EFI_VARIABLE_RUNTIME_ACCESS,
+ sizeof (EFI_PHYSICAL_ADDRESS),
+ &AcpiLowMemoryBase
+ );
+ ASSERT_EFI_ERROR (Status);
+ //
+ // Mark L"PerfDataMemAddr" variable to read-only if the Variable Lock protocol exists
+ //
+ Status = gBS->LocateProtocol (&gEdkiiVariableLockProtocolGuid, NULL, (VOID **) &VariableLock);
+ if (!EFI_ERROR (Status)) {
+ Status = VariableLock->RequestToLock (VariableLock, L"PerfDataMemAddr", &gPerformanceProtocolGuid);
+ ASSERT_EFI_ERROR (Status);
+ }
+ }
+}
+
+/**
+
Service routine for BdsInstance->Entry(). Devices are connected, the
consoles are initialized, and the boot options are tried.
@@ -459,6 +518,8 @@ BdsEntry (
CHAR16 *FirmwareVendor;
EFI_STATUS Status;
UINT16 BootTimeOut;
+ UINTN Index;
+ EDKII_VARIABLE_LOCK_PROTOCOL *VariableLock;
//
// Insert the performance probe
@@ -466,6 +527,10 @@ BdsEntry (
PERF_END (NULL, "DXE", NULL, 0);
PERF_START (NULL, "BDS", NULL, 0);
+ PERF_CODE (
+ BdsAllocateMemoryForPerformanceData ();
+ );
+
//
// Initialize the global system boot option and driver option
//
@@ -497,6 +562,18 @@ BdsEntry (
BdsFormalizeEfiGlobalVariable();
//
+ // Mark the read-only variables if the Variable Lock protocol exists
+ //
+ Status = gBS->LocateProtocol (&gEdkiiVariableLockProtocolGuid, NULL, (VOID **) &VariableLock);
+ DEBUG ((EFI_D_INFO, "[BdsDxe] Locate Variable Lock protocol - %r\n", Status));
+ if (!EFI_ERROR (Status)) {
+ for (Index = 0; Index < sizeof (mReadOnlyVariables) / sizeof (mReadOnlyVariables[0]); Index++) {
+ Status = VariableLock->RequestToLock (VariableLock, mReadOnlyVariables[Index], &gEfiGlobalVariableGuid);
+ ASSERT_EFI_ERROR (Status);
+ }
+ }
+
+ //
// Report Status Code to indicate connecting drivers will happen
//
REPORT_STATUS_CODE (
@@ -504,12 +581,6 @@ BdsEntry (
(EFI_SOFTWARE_DXE_BS_DRIVER | EFI_SW_DXE_BS_PC_BEGIN_CONNECTING_DRIVERS)
);
- //
- // Do the platform init, can be customized by OEM/IBV
- //
- PERF_START (NULL, "PlatformBds", "BDS", 0);
- PlatformBdsInit ();
-
InitializeHwErrRecSupport();
//
@@ -540,6 +611,12 @@ BdsEntry (
InitializeFrontPage (TRUE);
//
+ // Do the platform init, can be customized by OEM/IBV
+ //
+ PERF_START (NULL, "PlatformBds", "BDS", 0);
+ PlatformBdsInit ();
+
+ //
// Set up the device list based on EFI 1.1 variables
// process Driver#### and Load the driver's in the
// driver option list
diff --git a/IntelFrameworkModulePkg/Universal/BdsDxe/Language.c b/IntelFrameworkModulePkg/Universal/BdsDxe/Language.c
index ef2e2d860e..6d25bfe237 100644
--- a/IntelFrameworkModulePkg/Universal/BdsDxe/Language.c
+++ b/IntelFrameworkModulePkg/Universal/BdsDxe/Language.c
@@ -1,7 +1,7 @@
/** @file
Language settings
-Copyright (c) 2004 - 2010, 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
@@ -312,10 +312,138 @@ GetNextLanguage (
}
/**
+ Check if lang is in supported language codes according to language string.
+
+ This code is used to check if lang is in in supported language codes. It can handle
+ RFC4646 and ISO639 language tags.
+ In ISO639 language tags, take 3-characters as a delimitation to find matched string.
+ In RFC4646 language tags, take semicolon as a delimitation to find matched string.
+
+ For example:
+ SupportedLang = "engfraengfra"
+ Iso639Language = TRUE
+ Lang = "eng", the return value is "TRUE", or
+ Lang = "chs", the return value is "FALSE".
+ Another example:
+ SupportedLang = "en;fr;en-US;fr-FR"
+ Iso639Language = FALSE
+ Lang = "en", the return value is "TRUE", or
+ Lang = "zh", the return value is "FALSE".
+
+ @param SupportedLang Platform supported language codes.
+ @param Lang Configured language.
+ @param Iso639Language A bool value to signify if the handler is operated on ISO639 or RFC4646.
+
+ @retval TRUE lang is in supported language codes.
+ @retval FALSE lang is not in supported language codes.
+
+**/
+BOOLEAN
+IsLangInSupportedLangCodes(
+ IN CHAR8 *SupportedLang,
+ IN CHAR8 *Lang,
+ IN BOOLEAN Iso639Language
+ )
+{
+ UINTN Index;
+ UINTN CompareLength;
+ UINTN LanguageLength;
+
+ if (Iso639Language) {
+ CompareLength = ISO_639_2_ENTRY_SIZE;
+ for (Index = 0; Index < AsciiStrLen (SupportedLang); Index += CompareLength) {
+ if (AsciiStrnCmp (Lang, SupportedLang + Index, CompareLength) == 0) {
+ //
+ // Successfully find the Lang string in SupportedLang string.
+ //
+ return TRUE;
+ }
+ }
+ return FALSE;
+ } else {
+ //
+ // Compare RFC4646 language code
+ //
+ for (LanguageLength = 0; Lang[LanguageLength] != '\0'; LanguageLength++);
+
+ for (; *SupportedLang != '\0'; SupportedLang += CompareLength) {
+ //
+ // Skip ';' characters in SupportedLang
+ //
+ for (; *SupportedLang != '\0' && *SupportedLang == ';'; SupportedLang++);
+ //
+ // Determine the length of the next language code in SupportedLang
+ //
+ for (CompareLength = 0; SupportedLang[CompareLength] != '\0' && SupportedLang[CompareLength] != ';'; CompareLength++);
+
+ if ((CompareLength == LanguageLength) &&
+ (AsciiStrnCmp (Lang, SupportedLang, CompareLength) == 0)) {
+ //
+ // Successfully find the Lang string in SupportedLang string.
+ //
+ return TRUE;
+ }
+ }
+ return FALSE;
+ }
+}
+
+/**
+ Initialize Lang or PlatformLang variable, if Lang or PlatformLang variable is not found,
+ or it has been set to an unsupported value(not one of platform supported language codes),
+ set the default language code to it.
+
+ @param LangName Language name, L"Lang" or L"PlatformLang".
+ @param SupportedLang Platform supported language codes.
+ @param DefaultLang Default language code.
+ @param Iso639Language A bool value to signify if the handler is operated on ISO639 or RFC4646,
+ TRUE for L"Lang" LangName or FALSE for L"PlatformLang" LangName.
+
+**/
+VOID
+InitializeLangVariable (
+ IN CHAR16 *LangName,
+ IN CHAR8 *SupportedLang,
+ IN CHAR8 *DefaultLang,
+ IN BOOLEAN Iso639Language
+ )
+{
+ EFI_STATUS Status;
+ CHAR8 *Lang;
+
+ //
+ // Find current Lang or PlatformLang from EFI Variable.
+ //
+ Status = GetEfiGlobalVariable2 (LangName, (VOID **) &Lang, NULL);
+ //
+ // If Lang or PlatformLang variable is not found,
+ // or it has been set to an unsupported value(not one of the supported language codes),
+ // set the default language code to it.
+ //
+ if (EFI_ERROR (Status) || !IsLangInSupportedLangCodes (SupportedLang, Lang, Iso639Language)) {
+ //
+ // The default language code should be one of the supported language codes.
+ //
+ ASSERT (IsLangInSupportedLangCodes (SupportedLang, DefaultLang, Iso639Language));
+ Status = gRT->SetVariable (
+ LangName,
+ &gEfiGlobalVariableGuid,
+ EFI_VARIABLE_NON_VOLATILE | EFI_VARIABLE_BOOTSERVICE_ACCESS | EFI_VARIABLE_RUNTIME_ACCESS,
+ AsciiStrSize (DefaultLang),
+ DefaultLang
+ );
+ }
+
+ if (Lang != NULL) {
+ FreePool (Lang);
+ }
+}
+
+/**
Determine the current language that will be used
based on language related EFI Variables.
- @param LangCodesSettingRequired - If required to set LangCode variable
+ @param LangCodesSettingRequired - If required to set LangCodes variable
**/
VOID
@@ -324,18 +452,13 @@ InitializeLanguage (
)
{
EFI_STATUS Status;
- UINTN Size;
- CHAR8 *Lang;
- CHAR8 LangCode[ISO_639_2_ENTRY_SIZE + 1];
CHAR8 *LangCodes;
- CHAR8 *PlatformLang;
CHAR8 *PlatformLangCodes;
- UINTN Index;
- BOOLEAN Invalid;
ExportFonts ();
LangCodes = (CHAR8 *)PcdGetPtr (PcdUefiVariableDefaultLangCodes);
+ PlatformLangCodes = (CHAR8 *)PcdGetPtr (PcdUefiVariableDefaultPlatformLangCodes);
if (LangCodesSettingRequired) {
if (!FeaturePcdGet (PcdUefiVariableDefaultLangDeprecate)) {
//
@@ -350,8 +473,6 @@ InitializeLanguage (
);
}
-
- PlatformLangCodes = (CHAR8 *)PcdGetPtr (PcdUefiVariableDefaultPlatformLangCodes);
Status = gRT->SetVariable (
L"PlatformLangCodes",
&gEfiGlobalVariableGuid,
@@ -365,67 +486,7 @@ InitializeLanguage (
//
// UEFI 2.1 depricated this variable so we support turning it off
//
-
- //
- // Find current LangCode from Lang NV Variable
- //
- Size = ISO_639_2_ENTRY_SIZE + 1;
- Status = gRT->GetVariable (
- L"Lang",
- &gEfiGlobalVariableGuid,
- NULL,
- &Size,
- &LangCode
- );
- if (!EFI_ERROR (Status)) {
- Status = EFI_NOT_FOUND;
- for (Index = 0; LangCodes[Index] != 0; Index += ISO_639_2_ENTRY_SIZE) {
- if (CompareMem (&LangCodes[Index], LangCode, ISO_639_2_ENTRY_SIZE) == 0) {
- Status = EFI_SUCCESS;
- break;
- }
- }
- }
-
- //
- // If we cannot get language code from Lang variable,
- // or LangCode cannot be found from language table,
- // set the mDefaultLangCode to Lang variable.
- //
- if (EFI_ERROR (Status)) {
- Lang = (CHAR8 *)PcdGetPtr (PcdUefiVariableDefaultLang);
- Status = gRT->SetVariable (
- L"Lang",
- &gEfiGlobalVariableGuid,
- EFI_VARIABLE_NON_VOLATILE | EFI_VARIABLE_BOOTSERVICE_ACCESS | EFI_VARIABLE_RUNTIME_ACCESS,
- ISO_639_2_ENTRY_SIZE + 1,
- Lang
- );
- }
- }
-
- Invalid = FALSE;
- PlatformLang = BdsLibGetVariableAndSize (L"PlatformLang", &gEfiGlobalVariableGuid, &Size);
- if (PlatformLang != NULL) {
- //
- // Check Current PlatformLang value against PlatformLangCode. Need a library that is TBD
- // Set Invalid based on state of PlatformLang.
- //
-
- FreePool (PlatformLang);
- } else {
- // No valid variable is set
- Invalid = TRUE;
- }
-
- if (Invalid) {
- PlatformLang = (CHAR8 *)PcdGetPtr (PcdUefiVariableDefaultPlatformLang);
- Status = gRT->SetVariable (
- L"PlatformLang",
- &gEfiGlobalVariableGuid,
- EFI_VARIABLE_NON_VOLATILE | EFI_VARIABLE_BOOTSERVICE_ACCESS | EFI_VARIABLE_RUNTIME_ACCESS,
- AsciiStrSize (PlatformLang),
- PlatformLang
- );
+ InitializeLangVariable (L"Lang", LangCodes, (CHAR8 *) PcdGetPtr (PcdUefiVariableDefaultLang), TRUE);
}
+ InitializeLangVariable (L"PlatformLang", PlatformLangCodes, (CHAR8 *) PcdGetPtr (PcdUefiVariableDefaultPlatformLang), FALSE);
}
diff --git a/MdeModulePkg/Bus/Ata/AtaBusDxe/AtaBus.c b/MdeModulePkg/Bus/Ata/AtaBusDxe/AtaBus.c
index 11e90f97a9..6732fd5e0d 100644
--- a/MdeModulePkg/Bus/Ata/AtaBusDxe/AtaBus.c
+++ b/MdeModulePkg/Bus/Ata/AtaBusDxe/AtaBus.c
@@ -4,7 +4,7 @@
This file implements protocol interfaces: Driver Binding protocol,
Block IO protocol and DiskInfo 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
@@ -630,11 +630,36 @@ AtaBusDriverBindingSupported (
}
//
+ // Test to see if this ATA Pass Thru Protocol is for a LOGICAL channel
+ //
+ if ((AtaPassThru->Mode->Attributes & EFI_ATA_PASS_THRU_ATTRIBUTES_LOGICAL) == 0) {
+ //
+ // Close the I/O Abstraction(s) used to perform the supported test
+ //
+ gBS->CloseProtocol (
+ Controller,
+ &gEfiAtaPassThruProtocolGuid,
+ This->DriverBindingHandle,
+ Controller
+ );
+ return EFI_UNSUPPORTED;
+ }
+
+ //
// Test RemainingDevicePath is valid or not.
//
if ((RemainingDevicePath != NULL) && !IsDevicePathEnd (RemainingDevicePath)) {
Status = AtaPassThru->GetDevice (AtaPassThru, RemainingDevicePath, &Port, &PortMultiplierPort);
if (EFI_ERROR (Status)) {
+ //
+ // Close the I/O Abstraction(s) used to perform the supported test
+ //
+ gBS->CloseProtocol (
+ Controller,
+ &gEfiAtaPassThruProtocolGuid,
+ This->DriverBindingHandle,
+ Controller
+ );
return Status;
}
}
diff --git a/MdeModulePkg/Bus/Pci/PciBusDxe/PciResourceSupport.c b/MdeModulePkg/Bus/Pci/PciBusDxe/PciResourceSupport.c
index e17f4bae44..d8d988cbfc 100644
--- a/MdeModulePkg/Bus/Pci/PciBusDxe/PciResourceSupport.c
+++ b/MdeModulePkg/Bus/Pci/PciBusDxe/PciResourceSupport.c
@@ -1,7 +1,7 @@
/** @file
PCI resouces support functions implemntation for PCI Bus module.
-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
@@ -1472,7 +1472,14 @@ ProgramPpbApperture (
case PPB_BAR_0:
case PPB_BAR_1:
- PciIo->Pci.Write (
+ switch ((Node->PciDev->PciBar[Node->Bar]).BarType) {
+
+ case PciBarTypeIo16:
+ case PciBarTypeIo32:
+ case PciBarTypeMem32:
+ case PciBarTypePMem32:
+
+ PciIo->Pci.Write (
PciIo,
EfiPciIoWidthUint32,
(Node->PciDev->PciBar[Node->Bar]).Offset,
@@ -1480,9 +1487,40 @@ ProgramPpbApperture (
&Address
);
- Node->PciDev->PciBar[Node->Bar].BaseAddress = Address;
- Node->PciDev->PciBar[Node->Bar].Length = Node->Length;
+ Node->PciDev->PciBar[Node->Bar].BaseAddress = Address;
+ Node->PciDev->PciBar[Node->Bar].Length = Node->Length;
+ break;
+
+ case PciBarTypeMem64:
+ case PciBarTypePMem64:
+ Address32 = (UINT32) (Address & 0x00000000FFFFFFFF);
+
+ PciIo->Pci.Write (
+ PciIo,
+ EfiPciIoWidthUint32,
+ (Node->PciDev->PciBar[Node->Bar]).Offset,
+ 1,
+ &Address32
+ );
+
+ Address32 = (UINT32) RShiftU64 (Address, 32);
+
+ PciIo->Pci.Write (
+ PciIo,
+ EfiPciIoWidthUint32,
+ (UINT8) ((Node->PciDev->PciBar[Node->Bar]).Offset + 4),
+ 1,
+ &Address32
+ );
+
+ Node->PciDev->PciBar[Node->Bar].BaseAddress = Address;
+ Node->PciDev->PciBar[Node->Bar].Length = Node->Length;
+ break;
+
+ default:
+ break;
+ }
break;
case PPB_IO_RANGE:
diff --git a/MdeModulePkg/Bus/Pci/XhciDxe/Xhci.c b/MdeModulePkg/Bus/Pci/XhciDxe/Xhci.c
index 5809a0f914..8e6bc6ff64 100644
--- a/MdeModulePkg/Bus/Pci/XhciDxe/Xhci.c
+++ b/MdeModulePkg/Bus/Pci/XhciDxe/Xhci.c
@@ -932,9 +932,9 @@ XhcControlTransfer (
}
Xhc->UsbDevContext[SlotId].ConfDesc = AllocateZeroPool (Xhc->UsbDevContext[SlotId].DevDesc.NumConfigurations * sizeof (EFI_USB_CONFIG_DESCRIPTOR *));
if (Xhc->HcCParams.Data.Csz == 0) {
- Status = XhcEvaluateContext (Xhc, SlotId, MaxPacket0);
+ Status = XhcEvaluateContext (Xhc, SlotId, MaxPacket0);
} else {
- Status = XhcEvaluateContext64 (Xhc, SlotId, MaxPacket0);
+ Status = XhcEvaluateContext64 (Xhc, SlotId, MaxPacket0);
}
ASSERT_EFI_ERROR (Status);
} else if (DescriptorType == USB_DESC_TYPE_CONFIG) {
@@ -1802,6 +1802,8 @@ XhcExitBootService (
gBS->CloseEvent (Xhc->PollTimer);
}
+ XhcClearBiosOwnership (Xhc);
+
//
// Restore original PCI attributes
//
@@ -1811,8 +1813,6 @@ XhcExitBootService (
Xhc->OriginalPciAttributes,
NULL
);
-
- XhcClearBiosOwnership (Xhc);
}
/**
diff --git a/MdeModulePkg/Bus/Usb/UsbBusDxe/UsbDesc.c b/MdeModulePkg/Bus/Usb/UsbBusDxe/UsbDesc.c
index 35cdaf5527..1713e3c421 100644
--- a/MdeModulePkg/Bus/Usb/UsbBusDxe/UsbDesc.c
+++ b/MdeModulePkg/Bus/Usb/UsbBusDxe/UsbDesc.c
@@ -786,10 +786,13 @@ UsbBuildDescTable (
return Status;
}
- DevDesc = UsbDev->DevDesc;
- NumConfig = DevDesc->Desc.NumConfigurations;
- DevDesc->Configs = AllocateZeroPool (NumConfig * sizeof (USB_CONFIG_DESC *));
+ DevDesc = UsbDev->DevDesc;
+ NumConfig = DevDesc->Desc.NumConfigurations;
+ if (NumConfig == 0) {
+ return EFI_DEVICE_ERROR;
+ }
+ DevDesc->Configs = AllocateZeroPool (NumConfig * sizeof (USB_CONFIG_DESC *));
if (DevDesc->Configs == NULL) {
return EFI_OUT_OF_RESOURCES;
}
diff --git a/MdeModulePkg/Include/Guid/FirmwarePerformance.h b/MdeModulePkg/Include/Guid/FirmwarePerformance.h
index 7da07f9ea7..a4aeda2759 100644
--- a/MdeModulePkg/Include/Guid/FirmwarePerformance.h
+++ b/MdeModulePkg/Include/Guid/FirmwarePerformance.h
@@ -1,7 +1,7 @@
/** @file
ACPI Firmware Performance Data Table (FPDT) implementation specific definitions.
- 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
@@ -50,6 +50,15 @@
#define EFI_FIRMWARE_PERFORMANCE_VARIABLE_NAME L"FirmwarePerformance"
+/// LockBox:
+/// GUID - gFirmwarePerformanceS3PointerGuid
+/// Data - S3 performance table pointer
+///
+#define FIRMWARE_PERFORMANCE_S3_POINTER_GUID \
+ { \
+ 0xdc65adc, 0xa973, 0x4130, { 0x8d, 0xf0, 0x2a, 0xdb, 0xeb, 0x9e, 0x4a, 0x31 } \
+ }
+
#pragma pack(1)
///
@@ -95,7 +104,7 @@ typedef struct {
///
/// Variable defined for FPDT implementation.
-/// This Variable is produced by FPDT DXE module and consumed by FPDT PEIM.
+/// This Variable is produced by FPDT DXE module.
///
typedef struct {
EFI_PHYSICAL_ADDRESS BootPerformanceTablePointer; ///< Pointer to Boot Performance Table.
@@ -118,5 +127,6 @@ typedef struct {
} SMM_BOOT_RECORD_COMMUNICATE;
extern EFI_GUID gEfiFirmwarePerformanceGuid;
+extern EFI_GUID gFirmwarePerformanceS3PointerGuid;
#endif
diff --git a/MdeModulePkg/Include/Guid/Performance.h b/MdeModulePkg/Include/Guid/Performance.h
index d7768e1fc1..c40046c878 100644
--- a/MdeModulePkg/Include/Guid/Performance.h
+++ b/MdeModulePkg/Include/Guid/Performance.h
@@ -4,7 +4,7 @@
* performance protocol interfaces.
* performance variables.
-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 that accompanies this distribution.
The full text of the license may be found at
@@ -48,6 +48,7 @@ typedef struct {
#define PERF_TOKEN_SIZE 28
#define PERF_TOKEN_LENGTH (PERF_TOKEN_SIZE - 1)
#define PERF_PEI_ENTRY_MAX_NUM 50
+#define PERF_DATA_MAX_LENGTH 0x4000
typedef struct {
CHAR8 Token[PERF_TOKEN_SIZE];
diff --git a/MdeModulePkg/Include/Guid/SmmVariableCommon.h b/MdeModulePkg/Include/Guid/SmmVariableCommon.h
index c7fde00ca2..a2daae8fe3 100644
--- a/MdeModulePkg/Include/Guid/SmmVariableCommon.h
+++ b/MdeModulePkg/Include/Guid/SmmVariableCommon.h
@@ -1,7 +1,7 @@
/** @file
The file defined some common structures used for communicating between SMM variable module and SMM variable wrapper 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 that accompanies this distribution.
The full text of the license may be found at
@@ -60,6 +60,10 @@ typedef struct {
// is gEfiSmmVariableProtocolGuid.
//
#define SMM_VARIABLE_FUNCTION_GET_STATISTICS 7
+//
+// The payload for this function is SMM_VARIABLE_COMMUNICATE_LOCK_VARIABLE
+//
+#define SMM_VARIABLE_FUNCTION_LOCK_VARIABLE 8
///
/// Size of SMM communicate header, without including the payload.
@@ -87,7 +91,7 @@ typedef struct {
///
typedef struct {
EFI_GUID Guid;
- UINTN NameSize;
+ UINTN NameSize; // Return name buffer size
CHAR16 Name[1];
} SMM_VARIABLE_COMMUNICATE_GET_NEXT_VARIABLE_NAME;
@@ -101,4 +105,6 @@ typedef struct {
UINT32 Attributes;
} SMM_VARIABLE_COMMUNICATE_QUERY_VARIABLE_INFO;
+typedef SMM_VARIABLE_COMMUNICATE_GET_NEXT_VARIABLE_NAME SMM_VARIABLE_COMMUNICATE_LOCK_VARIABLE;
+
#endif // _SMM_VARIABLE_COMMON_H_ \ No newline at end of file
diff --git a/MdeModulePkg/Include/Protocol/VariableLock.h b/MdeModulePkg/Include/Protocol/VariableLock.h
new file mode 100644
index 0000000000..a2a73bc161
--- /dev/null
+++ b/MdeModulePkg/Include/Protocol/VariableLock.h
@@ -0,0 +1,63 @@
+/** @file
+ Variable Lock Protocol is related to EDK II-specific implementation of variables
+ and intended for use as a means to mark a variable read-only after the event
+ EFI_END_OF_DXE_EVENT_GUID is signaled.
+
+ 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 __VARIABLE_LOCK_H__
+#define __VARIABLE_LOCK_H__
+
+#define EDKII_VARIABLE_LOCK_PROTOCOL_GUID \
+ { \
+ 0xcd3d0a05, 0x9e24, 0x437c, { 0xa8, 0x91, 0x1e, 0xe0, 0x53, 0xdb, 0x76, 0x38 } \
+ }
+
+typedef struct _EDKII_VARIABLE_LOCK_PROTOCOL EDKII_VARIABLE_LOCK_PROTOCOL;
+
+/**
+ Mark a variable that will become read-only after leaving the DXE phase of execution.
+ Write request coming from SMM environment through EFI_SMM_VARIABLE_PROTOCOL is allowed.
+
+ @param[in] This The EDKII_VARIABLE_LOCK_PROTOCOL instance.
+ @param[in] VariableName A pointer to the variable name that will be made read-only subsequently.
+ @param[in] VendorGuid A pointer to the vendor GUID that will be made read-only subsequently.
+
+ @retval EFI_SUCCESS The variable specified by the VariableName and the VendorGuid was marked
+ as pending to be read-only.
+ @retval EFI_INVALID_PARAMETER VariableName or VendorGuid is NULL.
+ Or VariableName is an empty string.
+ @retval EFI_ACCESS_DENIED EFI_END_OF_DXE_EVENT_GROUP_GUID or EFI_EVENT_GROUP_READY_TO_BOOT has
+ already been signaled.
+ @retval EFI_OUT_OF_RESOURCES There is not enough resource to hold the lock request.
+**/
+typedef
+EFI_STATUS
+(EFIAPI * EDKII_VARIABLE_LOCK_PROTOCOL_REQUEST_TO_LOCK) (
+ IN CONST EDKII_VARIABLE_LOCK_PROTOCOL *This,
+ IN CHAR16 *VariableName,
+ IN EFI_GUID *VendorGuid
+ );
+
+///
+/// Variable Lock Protocol is related to EDK II-specific implementation of variables
+/// and intended for use as a means to mark a variable read-only after the event
+/// EFI_END_OF_DXE_EVENT_GUID is signaled.
+///
+struct _EDKII_VARIABLE_LOCK_PROTOCOL {
+ EDKII_VARIABLE_LOCK_PROTOCOL_REQUEST_TO_LOCK RequestToLock;
+};
+
+extern EFI_GUID gEdkiiVariableLockProtocolGuid;
+
+#endif
+
diff --git a/MdeModulePkg/Library/DxeNetLib/DxeNetLib.c b/MdeModulePkg/Library/DxeNetLib/DxeNetLib.c
index 61e4c8c9d1..cfda3962bb 100644
--- a/MdeModulePkg/Library/DxeNetLib/DxeNetLib.c
+++ b/MdeModulePkg/Library/DxeNetLib/DxeNetLib.c
@@ -1,7 +1,7 @@
/** @file
Network library.
-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
@@ -1788,6 +1788,7 @@ NetLibDefaultUnload (
EFI_HANDLE *DeviceHandleBuffer;
UINTN DeviceHandleCount;
UINTN Index;
+ UINTN Index2;
EFI_DRIVER_BINDING_PROTOCOL *DriverBinding;
EFI_COMPONENT_NAME_PROTOCOL *ComponentName;
EFI_COMPONENT_NAME2_PROTOCOL *ComponentName2;
@@ -1809,28 +1810,12 @@ NetLibDefaultUnload (
return Status;
}
- //
- // Disconnect the driver specified by ImageHandle from all
- // the devices in the handle database.
- //
- for (Index = 0; Index < DeviceHandleCount; Index++) {
- Status = gBS->DisconnectController (
- DeviceHandleBuffer[Index],
- ImageHandle,
- NULL
- );
- }
-
- //
- // Uninstall all the protocols installed in the driver entry point
- //
for (Index = 0; Index < DeviceHandleCount; Index++) {
Status = gBS->HandleProtocol (
DeviceHandleBuffer[Index],
&gEfiDriverBindingProtocolGuid,
(VOID **) &DriverBinding
);
-
if (EFI_ERROR (Status)) {
continue;
}
@@ -1838,12 +1823,28 @@ NetLibDefaultUnload (
if (DriverBinding->ImageHandle != ImageHandle) {
continue;
}
-
+
+ //
+ // Disconnect the driver specified by ImageHandle from all
+ // the devices in the handle database.
+ //
+ for (Index2 = 0; Index2 < DeviceHandleCount; Index2++) {
+ Status = gBS->DisconnectController (
+ DeviceHandleBuffer[Index2],
+ DriverBinding->DriverBindingHandle,
+ NULL
+ );
+ }
+
+ //
+ // Uninstall all the protocols installed in the driver entry point
+ //
gBS->UninstallProtocolInterface (
- ImageHandle,
+ DriverBinding->DriverBindingHandle,
&gEfiDriverBindingProtocolGuid,
DriverBinding
);
+
Status = gBS->HandleProtocol (
DeviceHandleBuffer[Index],
&gEfiComponentNameProtocolGuid,
@@ -1851,7 +1852,7 @@ NetLibDefaultUnload (
);
if (!EFI_ERROR (Status)) {
gBS->UninstallProtocolInterface (
- ImageHandle,
+ DriverBinding->DriverBindingHandle,
&gEfiComponentNameProtocolGuid,
ComponentName
);
@@ -1864,7 +1865,7 @@ NetLibDefaultUnload (
);
if (!EFI_ERROR (Status)) {
gBS->UninstallProtocolInterface (
- ImageHandle,
+ DriverBinding->DriverBindingHandle,
&gEfiComponentName2ProtocolGuid,
ComponentName2
);
diff --git a/MdeModulePkg/Library/SmmCorePerformanceLib/SmmCorePerformanceLib.c b/MdeModulePkg/Library/SmmCorePerformanceLib/SmmCorePerformanceLib.c
index 314d46d03a..f95079bd27 100644
--- a/MdeModulePkg/Library/SmmCorePerformanceLib/SmmCorePerformanceLib.c
+++ b/MdeModulePkg/Library/SmmCorePerformanceLib/SmmCorePerformanceLib.c
@@ -16,7 +16,7 @@
SmmPerformanceHandlerEx(), SmmPerformanceHandler() will receive untrusted input and do basic validation.
-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
@@ -478,6 +478,33 @@ IsAddressInSmram (
}
/**
+ This function check if the address refered by Buffer and Length is valid.
+
+ @param Buffer the buffer address to be checked.
+ @param Length the buffer length to be checked.
+
+ @retval TRUE this address is valid.
+ @retval FALSE this address is NOT valid.
+**/
+BOOLEAN
+IsAddressValid (
+ IN UINTN Buffer,
+ IN UINTN Length
+ )
+{
+ if (Buffer > (MAX_ADDRESS - Length)) {
+ //
+ // Overflow happen
+ //
+ return FALSE;
+ }
+ if (IsAddressInSmram ((EFI_PHYSICAL_ADDRESS)Buffer, (UINT64)Length)) {
+ return FALSE;
+ }
+ return TRUE;
+}
+
+/**
Communication service SMI Handler entry.
This SMI handler provides services for the performance wrapper driver.
@@ -513,6 +540,10 @@ SmmPerformanceHandlerEx (
SMM_PERF_COMMUNICATE_EX *SmmPerfCommData;
GAUGE_DATA_ENTRY_EX *GaugeEntryExArray;
UINTN DataSize;
+ GAUGE_DATA_ENTRY_EX *GaugeDataEx;
+ UINTN NumberOfEntries;
+ UINTN LogEntryKey;
+ UINTN TempCommBufferSize;
GaugeEntryExArray = NULL;
@@ -523,12 +554,14 @@ SmmPerformanceHandlerEx (
return EFI_SUCCESS;
}
- if(*CommBufferSize < sizeof (SMM_PERF_COMMUNICATE_EX)) {
+ TempCommBufferSize = *CommBufferSize;
+
+ if(TempCommBufferSize < sizeof (SMM_PERF_COMMUNICATE_EX)) {
return EFI_SUCCESS;
}
- if (IsAddressInSmram ((EFI_PHYSICAL_ADDRESS)(UINTN)CommBuffer, *CommBufferSize)) {
- DEBUG ((EFI_D_ERROR, "SMM communcation data buffer is in SMRAM!\n"));
+ if (!IsAddressValid ((UINTN)CommBuffer, TempCommBufferSize)) {
+ DEBUG ((EFI_D_ERROR, "SmmPerformanceHandlerEx: SMM communcation data buffer in SMRAM or overflow!\n"));
return EFI_SUCCESS;
}
@@ -541,8 +574,11 @@ SmmPerformanceHandlerEx (
break;
case SMM_PERF_FUNCTION_GET_GAUGE_DATA :
- if ( SmmPerfCommData->GaugeDataEx == NULL || SmmPerfCommData->NumberOfEntries == 0 ||
- (SmmPerfCommData->LogEntryKey + SmmPerfCommData->NumberOfEntries) > mGaugeData->NumberOfEntries) {
+ GaugeDataEx = SmmPerfCommData->GaugeDataEx;
+ NumberOfEntries = SmmPerfCommData->NumberOfEntries;
+ LogEntryKey = SmmPerfCommData->LogEntryKey;
+ if (GaugeDataEx == NULL || NumberOfEntries == 0 || LogEntryKey > mGaugeData->NumberOfEntries ||
+ NumberOfEntries > mGaugeData->NumberOfEntries || (LogEntryKey + NumberOfEntries) > mGaugeData->NumberOfEntries) {
Status = EFI_INVALID_PARAMETER;
break;
}
@@ -550,17 +586,17 @@ SmmPerformanceHandlerEx (
//
// Sanity check
//
- DataSize = SmmPerfCommData->NumberOfEntries * sizeof(GAUGE_DATA_ENTRY_EX);
- if (IsAddressInSmram ((EFI_PHYSICAL_ADDRESS)(UINTN)SmmPerfCommData->GaugeDataEx, DataSize)) {
- DEBUG ((EFI_D_ERROR, "SMM Performance Data buffer is in SMRAM!\n"));
+ DataSize = NumberOfEntries * sizeof(GAUGE_DATA_ENTRY_EX);
+ if (!IsAddressValid ((UINTN)GaugeDataEx, DataSize)) {
+ DEBUG ((EFI_D_ERROR, "SmmPerformanceHandlerEx: SMM Performance Data buffer in SMRAM or overflow!\n"));
Status = EFI_ACCESS_DENIED;
break;
}
GaugeEntryExArray = (GAUGE_DATA_ENTRY_EX *) (mGaugeData + 1);
CopyMem(
- (UINT8 *) (SmmPerfCommData->GaugeDataEx),
- (UINT8 *) &GaugeEntryExArray[SmmPerfCommData->LogEntryKey],
+ (UINT8 *) GaugeDataEx,
+ (UINT8 *) &GaugeEntryExArray[LogEntryKey],
DataSize
);
Status = EFI_SUCCESS;
@@ -613,8 +649,11 @@ SmmPerformanceHandler (
GAUGE_DATA_ENTRY_EX *GaugeEntryExArray;
UINTN DataSize;
UINTN Index;
+ GAUGE_DATA_ENTRY *GaugeData;
+ UINTN NumberOfEntries;
UINTN LogEntryKey;
-
+ UINTN TempCommBufferSize;
+
GaugeEntryExArray = NULL;
//
@@ -624,12 +663,14 @@ SmmPerformanceHandler (
return EFI_SUCCESS;
}
- if(*CommBufferSize < sizeof (SMM_PERF_COMMUNICATE)) {
+ TempCommBufferSize = *CommBufferSize;
+
+ if(TempCommBufferSize < sizeof (SMM_PERF_COMMUNICATE)) {
return EFI_SUCCESS;
}
- if (IsAddressInSmram ((EFI_PHYSICAL_ADDRESS)(UINTN)CommBuffer, *CommBufferSize)) {
- DEBUG ((EFI_D_ERROR, "SMM communcation data buffer is in SMRAM!\n"));
+ if (!IsAddressValid ((UINTN)CommBuffer, TempCommBufferSize)) {
+ DEBUG ((EFI_D_ERROR, "SmmPerformanceHandler: SMM communcation data buffer in SMRAM or overflow!\n"));
return EFI_SUCCESS;
}
@@ -642,8 +683,11 @@ SmmPerformanceHandler (
break;
case SMM_PERF_FUNCTION_GET_GAUGE_DATA :
- if ( SmmPerfCommData->GaugeData == NULL || SmmPerfCommData->NumberOfEntries == 0 ||
- (SmmPerfCommData->LogEntryKey + SmmPerfCommData->NumberOfEntries) > mGaugeData->NumberOfEntries) {
+ GaugeData = SmmPerfCommData->GaugeData;
+ NumberOfEntries = SmmPerfCommData->NumberOfEntries;
+ LogEntryKey = SmmPerfCommData->LogEntryKey;
+ if (GaugeData == NULL || NumberOfEntries == 0 || LogEntryKey > mGaugeData->NumberOfEntries ||
+ NumberOfEntries > mGaugeData->NumberOfEntries || (LogEntryKey + NumberOfEntries) > mGaugeData->NumberOfEntries) {
Status = EFI_INVALID_PARAMETER;
break;
}
@@ -651,19 +695,18 @@ SmmPerformanceHandler (
//
// Sanity check
//
- DataSize = SmmPerfCommData->NumberOfEntries * sizeof(GAUGE_DATA_ENTRY);
- if (IsAddressInSmram ((EFI_PHYSICAL_ADDRESS)(UINTN)SmmPerfCommData->GaugeData, DataSize)) {
- DEBUG ((EFI_D_ERROR, "SMM Performance Data buffer is in SMRAM!\n"));
+ DataSize = NumberOfEntries * sizeof(GAUGE_DATA_ENTRY);
+ if (!IsAddressValid ((UINTN)GaugeData, DataSize)) {
+ DEBUG ((EFI_D_ERROR, "SmmPerformanceHandler: SMM Performance Data buffer in SMRAM or overflow!\n"));
Status = EFI_ACCESS_DENIED;
break;
}
GaugeEntryExArray = (GAUGE_DATA_ENTRY_EX *) (mGaugeData + 1);
- LogEntryKey = SmmPerfCommData->LogEntryKey;
- for (Index = 0; Index < SmmPerfCommData->NumberOfEntries; Index++) {
+ for (Index = 0; Index < NumberOfEntries; Index++) {
CopyMem(
- (UINT8 *) &(SmmPerfCommData->GaugeData[Index]),
+ (UINT8 *) &GaugeData[Index],
(UINT8 *) &GaugeEntryExArray[LogEntryKey++],
sizeof (GAUGE_DATA_ENTRY)
);
diff --git a/MdeModulePkg/MdeModulePkg.dec b/MdeModulePkg/MdeModulePkg.dec
index ba80b809dc..3c07c69a97 100644
--- a/MdeModulePkg/MdeModulePkg.dec
+++ b/MdeModulePkg/MdeModulePkg.dec
@@ -246,6 +246,7 @@
## Guid for Firmware Performance Data Table (FPDT) implementation.
# Include/Guid/FirmwarePerformance.h
gEfiFirmwarePerformanceGuid = { 0xc095791a, 0x3001, 0x47b2, { 0x80, 0xc9, 0xea, 0xc7, 0x31, 0x9f, 0x2f, 0xa4 }}
+ gFirmwarePerformanceS3PointerGuid = { 0xdc65adc, 0xa973, 0x4130, { 0x8d, 0xf0, 0x2a, 0xdb, 0xeb, 0x9e, 0x4a, 0x31 }}
## Include/Guid/ExitBootServiceFailed.h
gEventExitBootServicesFailedGuid = { 0x4f6c5507, 0x232f, 0x4787, { 0xb9, 0x5e, 0x72, 0xf8, 0x62, 0x49, 0xc, 0xb1 } }
@@ -325,6 +326,10 @@
# Include/Protocol/SmmVariableProtocol.h
gEfiSmmVariableProtocolGuid = { 0xed32d533, 0x99e6, 0x4209, { 0x9c, 0xc0, 0x2d, 0x72, 0xcd, 0xd9, 0x98, 0xa7 }}
+ ## This protocol is intended for use as a means to mark a variable read-only after the event EFI_END_OF_DXE_EVENT_GUID is signaled.
+ # Include/Protocol/VariableLock.h
+ gEdkiiVariableLockProtocolGuid = { 0xcd3d0a05, 0x9e24, 0x437c, { 0xa8, 0x91, 0x1e, 0xe0, 0x53, 0xdb, 0x76, 0x38 }}
+
## This protocol is similar with DXE FVB protocol and used in the UEFI SMM evvironment.
# Include/Protocol/SmmFirmwareVolumeBlock.h
gEfiSmmFirmwareVolumeBlockProtocolGuid = { 0xd326d041, 0xbd31, 0x4c01, { 0xb5, 0xa8, 0x62, 0x8b, 0xe8, 0x7f, 0x6, 0x53 }}
diff --git a/MdeModulePkg/MdeModulePkg.dsc b/MdeModulePkg/MdeModulePkg.dsc
index 835f621b69..444cd8358c 100644
--- a/MdeModulePkg/MdeModulePkg.dsc
+++ b/MdeModulePkg/MdeModulePkg.dsc
@@ -1,7 +1,7 @@
## @file
# EFI/PI Reference Module Package for All Architectures
#
-# Copyright (c) 2007 - 2012, 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
@@ -151,6 +151,8 @@
#
NULL|ArmPkg/Library/CompilerIntrinsicsLib/CompilerIntrinsicsLib.inf
+[LibraryClasses.EBC]
+ LockBoxLib|MdeModulePkg/Library/LockBoxNullLib/LockBoxNullLib.inf
[PcdsFeatureFlag]
gEfiMdePkgTokenSpaceGuid.PcdDriverDiagnostics2Disable|TRUE
@@ -242,8 +244,6 @@
MdeModulePkg/Library/BaseSerialPortLib16550/BaseSerialPortLib16550.inf
MdeModulePkg/Library/BasePlatformHookLibNull/BasePlatformHookLibNull.inf
MdeModulePkg/Library/DxeDebugPrintErrorLevelLib/DxeDebugPrintErrorLevelLib.inf
- MdeModulePkg/Library/SmmLockBoxLib/SmmLockBoxDxeLib.inf
- MdeModulePkg/Library/SmmLockBoxLib/SmmLockBoxSmmLib.inf
MdeModulePkg/Library/PiDxeS3BootScriptLib/DxeS3BootScriptLib.inf
MdeModulePkg/Library/PeiDebugPrintHobLib/PeiDebugPrintHobLib.inf
MdeModulePkg/Library/CpuExceptionHandlerLibNull/CpuExceptionHandlerLibNull.inf
@@ -336,6 +336,8 @@
MdeModulePkg/Library/SmmPerformanceLib/SmmPerformanceLib.inf
MdeModulePkg/Library/DxeSmmPerformanceLib/DxeSmmPerformanceLib.inf
MdeModulePkg/Library/SmmLockBoxLib/SmmLockBoxPeiLib.inf
+ MdeModulePkg/Library/SmmLockBoxLib/SmmLockBoxDxeLib.inf
+ MdeModulePkg/Library/SmmLockBoxLib/SmmLockBoxSmmLib.inf
MdeModulePkg/Library/SmmCorePlatformHookLibNull/SmmCorePlatformHookLibNull.inf
MdeModulePkg/Universal/Acpi/BootScriptExecutorDxe/BootScriptExecutorDxe.inf
MdeModulePkg/Universal/Acpi/S3SaveStateDxe/S3SaveStateDxe.inf
diff --git a/MdeModulePkg/Universal/Acpi/BootScriptExecutorDxe/X64/S3Asm.S b/MdeModulePkg/Universal/Acpi/BootScriptExecutorDxe/X64/S3Asm.S
index dcce6fb6ae..e59fd048b0 100644
--- a/MdeModulePkg/Universal/Acpi/BootScriptExecutorDxe/X64/S3Asm.S
+++ b/MdeModulePkg/Universal/Acpi/BootScriptExecutorDxe/X64/S3Asm.S
@@ -2,7 +2,7 @@
# This is the assembly code for transferring to control to OS S3 waking vector
# for X64 platform
#
-# 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
@@ -18,14 +18,14 @@ ASM_GLOBAL ASM_PFX(AsmTransferControl)
ASM_PFX(AsmTransferControl):
# rcx S3WakingVector :DWORD
# rdx AcpiLowMemoryBase :DWORD
- lea _AsmTransferControl_al_0000, %eax
+ lea _AsmTransferControl_al_0000(%rip), %eax
movq $0x2800000000, %r8
orq %r8, %rax
pushq %rax
shrd $20, %ecx, %ebx
andl $0x0f, %ecx
movw %cx, %bx
- movl %ebx, jmp_addr
+ movl %ebx, jmp_addr(%rip)
lret
_AsmTransferControl_al_0000:
.byte 0x0b8, 0x30, 0 # mov ax, 30h as selector
@@ -124,7 +124,7 @@ ASM_PFX(PageFaultHandlerHook):
popq %rcx
popq %rax # restore all volatile registers
jnz L1
- jmpq *ASM_PFX(mOriginalHandler)
+ jmpq *ASM_PFX(mOriginalHandler)(%rip)
L1:
addq $0x08, %rsp # skip error code for PF
iretq
diff --git a/MdeModulePkg/Universal/Acpi/FirmwarePerformanceDataTableDxe/FirmwarePerformanceDxe.c b/MdeModulePkg/Universal/Acpi/FirmwarePerformanceDataTableDxe/FirmwarePerformanceDxe.c
index ce17e4f928..f834778acd 100644
--- a/MdeModulePkg/Universal/Acpi/FirmwarePerformanceDataTableDxe/FirmwarePerformanceDxe.c
+++ b/MdeModulePkg/Universal/Acpi/FirmwarePerformanceDataTableDxe/FirmwarePerformanceDxe.c
@@ -5,7 +5,7 @@
for Firmware Basic Boot Performance Record and other boot performance records,
and install FPDT to ACPI table.
- 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
@@ -21,6 +21,8 @@
#include <Protocol/ReportStatusCodeHandler.h>
#include <Protocol/AcpiTable.h>
#include <Protocol/SmmCommunication.h>
+#include <Protocol/LockBox.h>
+#include <Protocol/Variable.h>
#include <Guid/Acpi.h>
#include <Guid/FirmwarePerformance.h>
@@ -36,7 +38,8 @@
#include <Library/MemoryAllocationLib.h>
#include <Library/PcdLib.h>
#include <Library/HobLib.h>
-#include <Library/PcdLib.h>
+#include <Library/LockBoxLib.h>
+#include <Library/UefiLib.h>
//
// ACPI table information used to initialize tables.
@@ -51,6 +54,7 @@
EFI_RSC_HANDLER_PROTOCOL *mRscHandlerProtocol = NULL;
+BOOLEAN mLockBoxReady = FALSE;
EFI_EVENT mReadyToBootEvent;
EFI_EVENT mLegacyBootEvent;
EFI_EVENT mExitBootServicesEvent;
@@ -206,6 +210,7 @@ FpdtAllocateReservedMemoryBelow4G (
EFI_STATUS Status;
VOID *Buffer;
+ Buffer = NULL;
Pages = EFI_SIZE_TO_PAGES (Size);
Address = 0xffffffff;
@@ -217,13 +222,107 @@ FpdtAllocateReservedMemoryBelow4G (
);
ASSERT_EFI_ERROR (Status);
- Buffer = (VOID *) (UINTN) Address;
- ZeroMem (Buffer, Size);
+ if (!EFI_ERROR (Status)) {
+ Buffer = (VOID *) (UINTN) Address;
+ ZeroMem (Buffer, Size);
+ }
return Buffer;
}
/**
+ Callback function upon VariableArchProtocol and LockBoxProtocol
+ to allocate S3 performance table memory and save the pointer to LockBox.
+
+ @param[in] Event Event whose notification function is being invoked.
+ @param[in] Context Pointer to the notification function's context.
+**/
+VOID
+EFIAPI
+FpdtAllocateS3PerformanceTableMemory (
+ IN EFI_EVENT Event,
+ IN VOID *Context
+ )
+{
+ EFI_STATUS Status;
+ VOID *Interface;
+ FIRMWARE_PERFORMANCE_VARIABLE PerformanceVariable;
+ UINTN Size;
+ EFI_PHYSICAL_ADDRESS S3PerformanceTablePointer;
+
+ if (mLockBoxReady && (mAcpiS3PerformanceTable != NULL)) {
+ //
+ // The memory for S3 performance table should have been ready,
+ // and the pointer should have been saved to LockBox, just return.
+ //
+ return;
+ }
+
+ if (!mLockBoxReady) {
+ Status = gBS->LocateProtocol (&gEfiLockBoxProtocolGuid, NULL, &Interface);
+ if (!EFI_ERROR (Status)) {
+ //
+ // LockBox services has been ready.
+ //
+ mLockBoxReady = TRUE;
+ }
+ }
+
+ if (mAcpiS3PerformanceTable == NULL) {
+ Status = gBS->LocateProtocol (&gEfiVariableArchProtocolGuid, NULL, &Interface);
+ if (!EFI_ERROR (Status)) {
+ //
+ // Try to allocate the same runtime buffer as last time boot.
+ //
+ ZeroMem (&PerformanceVariable, sizeof (PerformanceVariable));
+ Size = sizeof (PerformanceVariable);
+ Status = gRT->GetVariable (
+ EFI_FIRMWARE_PERFORMANCE_VARIABLE_NAME,
+ &gEfiFirmwarePerformanceGuid,
+ NULL,
+ &Size,
+ &PerformanceVariable
+ );
+ if (!EFI_ERROR (Status)) {
+ Status = gBS->AllocatePages (
+ AllocateAddress,
+ EfiReservedMemoryType,
+ EFI_SIZE_TO_PAGES (sizeof (S3_PERFORMANCE_TABLE)),
+ &PerformanceVariable.S3PerformanceTablePointer
+ );
+ if (!EFI_ERROR (Status)) {
+ mAcpiS3PerformanceTable = (S3_PERFORMANCE_TABLE *) (UINTN) PerformanceVariable.S3PerformanceTablePointer;
+ }
+ }
+ if (mAcpiS3PerformanceTable == NULL) {
+ //
+ // Fail to allocate at specified address, continue to allocate at any address.
+ //
+ mAcpiS3PerformanceTable = (S3_PERFORMANCE_TABLE *) FpdtAllocateReservedMemoryBelow4G (sizeof (S3_PERFORMANCE_TABLE));
+ }
+ DEBUG ((EFI_D_INFO, "FPDT: ACPI S3 Performance Table address = 0x%x\n", mAcpiS3PerformanceTable));
+ if (mAcpiS3PerformanceTable != NULL) {
+ CopyMem (mAcpiS3PerformanceTable, &mS3PerformanceTableTemplate, sizeof (mS3PerformanceTableTemplate));
+ }
+ }
+ }
+
+ if (mLockBoxReady && (mAcpiS3PerformanceTable != NULL)) {
+ //
+ // If LockBox services has been ready and memory for FPDT S3 performance table has been allocated,
+ // save the pointer to LockBox for use in S3 resume.
+ //
+ S3PerformanceTablePointer = (EFI_PHYSICAL_ADDRESS) (UINTN) mAcpiS3PerformanceTable;
+ Status = SaveLockBox (
+ &gFirmwarePerformanceS3PointerGuid,
+ &S3PerformanceTablePointer,
+ sizeof (EFI_PHYSICAL_ADDRESS)
+ );
+ ASSERT_EFI_ERROR (Status);
+ }
+}
+
+/**
Install ACPI Firmware Performance Data Table (FPDT).
@return Status code.
@@ -236,15 +335,13 @@ InstallFirmwarePerformanceDataTable (
{
EFI_STATUS Status;
EFI_ACPI_TABLE_PROTOCOL *AcpiTableProtocol;
- EFI_PHYSICAL_ADDRESS Address;
UINTN Size;
- UINT8 SmmBootRecordCommBuffer[SMM_BOOT_RECORD_COMM_SIZE];
+ UINT8 *SmmBootRecordCommBuffer;
EFI_SMM_COMMUNICATE_HEADER *SmmCommBufferHeader;
SMM_BOOT_RECORD_COMMUNICATE *SmmCommData;
UINTN CommSize;
- UINTN PerformanceRuntimeDataSize;
- UINT8 *PerformanceRuntimeData;
- UINT8 *PerformanceRuntimeDataHead;
+ UINTN BootPerformanceDataSize;
+ UINT8 *BootPerformanceData;
EFI_SMM_COMMUNICATION_PROTOCOL *Communication;
FIRMWARE_PERFORMANCE_VARIABLE PerformanceVariable;
@@ -259,12 +356,15 @@ InstallFirmwarePerformanceDataTable (
//
// Collect boot records from SMM drivers.
//
- SmmCommData = NULL;
+ SmmBootRecordCommBuffer = NULL;
+ SmmCommData = NULL;
Status = gBS->LocateProtocol (&gEfiSmmCommunicationProtocolGuid, NULL, (VOID **) &Communication);
if (!EFI_ERROR (Status)) {
//
// Initialize communicate buffer
//
+ SmmBootRecordCommBuffer = AllocateZeroPool (SMM_BOOT_RECORD_COMM_SIZE);
+ ASSERT (SmmBootRecordCommBuffer != NULL);
SmmCommBufferHeader = (EFI_SMM_COMMUNICATE_HEADER*)SmmBootRecordCommBuffer;
SmmCommData = (SMM_BOOT_RECORD_COMMUNICATE*)SmmCommBufferHeader->Data;
ZeroMem((UINT8*)SmmCommData, sizeof(SMM_BOOT_RECORD_COMMUNICATE));
@@ -296,15 +396,12 @@ InstallFirmwarePerformanceDataTable (
}
//
- // Prepare memory for runtime Performance Record.
- // Runtime performance records includes two tables S3 performance table and Boot performance table.
- // S3 Performance table includes S3Resume and S3Suspend records.
+ // Prepare memory for Boot Performance table.
// Boot Performance table includes BasicBoot record, and one or more appended Boot Records.
//
- PerformanceRuntimeData = NULL;
- PerformanceRuntimeDataSize = sizeof (S3_PERFORMANCE_TABLE) + sizeof (BOOT_PERFORMANCE_TABLE) + mBootRecordSize + PcdGet32 (PcdExtFpdtBootRecordPadSize);
+ BootPerformanceDataSize = sizeof (BOOT_PERFORMANCE_TABLE) + mBootRecordSize + PcdGet32 (PcdExtFpdtBootRecordPadSize);
if (SmmCommData != NULL) {
- PerformanceRuntimeDataSize += SmmCommData->BootRecordSize;
+ BootPerformanceDataSize += SmmCommData->BootRecordSize;
}
//
@@ -320,87 +417,66 @@ InstallFirmwarePerformanceDataTable (
&PerformanceVariable
);
if (!EFI_ERROR (Status)) {
- Address = PerformanceVariable.S3PerformanceTablePointer;
Status = gBS->AllocatePages (
AllocateAddress,
EfiReservedMemoryType,
- EFI_SIZE_TO_PAGES (PerformanceRuntimeDataSize),
- &Address
+ EFI_SIZE_TO_PAGES (BootPerformanceDataSize),
+ &PerformanceVariable.BootPerformanceTablePointer
);
if (!EFI_ERROR (Status)) {
- PerformanceRuntimeData = (UINT8 *) (UINTN) Address;
+ mAcpiBootPerformanceTable = (BOOT_PERFORMANCE_TABLE *) (UINTN) PerformanceVariable.BootPerformanceTablePointer;
}
}
- if (PerformanceRuntimeData == NULL) {
+ if (mAcpiBootPerformanceTable == NULL) {
//
// Fail to allocate at specified address, continue to allocate at any address.
//
- PerformanceRuntimeData = FpdtAllocateReservedMemoryBelow4G (PerformanceRuntimeDataSize);
+ mAcpiBootPerformanceTable = (BOOT_PERFORMANCE_TABLE *) FpdtAllocateReservedMemoryBelow4G (BootPerformanceDataSize);
}
- DEBUG ((EFI_D_INFO, "FPDT: Performance Runtime Data address = 0x%x\n", PerformanceRuntimeData));
+ DEBUG ((EFI_D_INFO, "FPDT: ACPI Boot Performance Table address = 0x%x\n", mAcpiBootPerformanceTable));
- if (PerformanceRuntimeData == NULL) {
+ if (mAcpiBootPerformanceTable == NULL) {
if (SmmCommData != NULL && SmmCommData->BootRecordData != NULL) {
FreePool (SmmCommData->BootRecordData);
}
+ if (SmmBootRecordCommBuffer != NULL) {
+ FreePool (SmmBootRecordCommBuffer);
+ }
+ if (mAcpiS3PerformanceTable != NULL) {
+ FreePages (mAcpiS3PerformanceTable, EFI_SIZE_TO_PAGES (sizeof (S3_PERFORMANCE_TABLE)));
+ }
return EFI_OUT_OF_RESOURCES;
}
-
- PerformanceRuntimeDataHead = PerformanceRuntimeData;
-
- if (FeaturePcdGet (PcdFirmwarePerformanceDataTableS3Support)) {
- //
- // Prepare S3 Performance Table.
- //
- mAcpiS3PerformanceTable = (S3_PERFORMANCE_TABLE *) PerformanceRuntimeData;
- CopyMem (mAcpiS3PerformanceTable, &mS3PerformanceTableTemplate, sizeof (mS3PerformanceTableTemplate));
- PerformanceRuntimeData = PerformanceRuntimeData + mAcpiS3PerformanceTable->Header.Length;
- DEBUG ((EFI_D_INFO, "FPDT: ACPI S3 Performance Table address = 0x%x\n", mAcpiS3PerformanceTable));
- //
- // Save S3 Performance Table address to Variable for use in Firmware Performance PEIM.
- //
- PerformanceVariable.S3PerformanceTablePointer = (EFI_PHYSICAL_ADDRESS) (UINTN) mAcpiS3PerformanceTable;
- //
- // Update S3 Performance Table Pointer in template.
- //
- mFirmwarePerformanceTableTemplate.S3PointerRecord.S3PerformanceTablePointer = (UINT64) PerformanceVariable.S3PerformanceTablePointer;
- } else {
- //
- // Exclude S3 Performance Table Pointer from FPDT table template.
- //
- mFirmwarePerformanceTableTemplate.Header.Length -= sizeof (EFI_ACPI_5_0_FPDT_S3_PERFORMANCE_TABLE_POINTER_RECORD);
- }
//
// Prepare Boot Performance Table.
//
- mAcpiBootPerformanceTable = (BOOT_PERFORMANCE_TABLE *) PerformanceRuntimeData;
+ BootPerformanceData = (UINT8 *) mAcpiBootPerformanceTable;
//
// Fill Basic Boot record to Boot Performance Table.
//
- CopyMem (PerformanceRuntimeData, &mBootPerformanceTableTemplate, sizeof (mBootPerformanceTableTemplate));
- PerformanceRuntimeData = PerformanceRuntimeData + mAcpiBootPerformanceTable->Header.Length;
+ CopyMem (mAcpiBootPerformanceTable, &mBootPerformanceTableTemplate, sizeof (mBootPerformanceTableTemplate));
+ BootPerformanceData = BootPerformanceData + mAcpiBootPerformanceTable->Header.Length;
//
// Fill Boot records from boot drivers.
//
- CopyMem (PerformanceRuntimeData, mBootRecordBuffer, mBootRecordSize);
+ CopyMem (BootPerformanceData, mBootRecordBuffer, mBootRecordSize);
mAcpiBootPerformanceTable->Header.Length += mBootRecordSize;
- PerformanceRuntimeData = PerformanceRuntimeData + mBootRecordSize;
+ BootPerformanceData = BootPerformanceData + mBootRecordSize;
if (SmmCommData != NULL && SmmCommData->BootRecordData != NULL) {
//
// Fill Boot records from SMM drivers.
//
- CopyMem (PerformanceRuntimeData, SmmCommData->BootRecordData, SmmCommData->BootRecordSize);
+ CopyMem (BootPerformanceData, SmmCommData->BootRecordData, SmmCommData->BootRecordSize);
FreePool (SmmCommData->BootRecordData);
mAcpiBootPerformanceTable->Header.Length = (UINT32) (mAcpiBootPerformanceTable->Header.Length + SmmCommData->BootRecordSize);
- PerformanceRuntimeData = PerformanceRuntimeData + SmmCommData->BootRecordSize;
+ BootPerformanceData = BootPerformanceData + SmmCommData->BootRecordSize;
}
- //
- // Reserve space for boot records after ReadyToBoot.
- //
- PerformanceRuntimeData = PerformanceRuntimeData + PcdGet32 (PcdExtFpdtBootRecordPadSize);
- DEBUG ((EFI_D_INFO, "FPDT: ACPI Boot Performance Table address = 0x%x\n", mAcpiBootPerformanceTable));
+ if (SmmBootRecordCommBuffer != NULL) {
+ FreePool (SmmBootRecordCommBuffer);
+ }
+
//
// Save Boot Performance Table address to Variable for use in S4 resume.
//
@@ -411,12 +487,20 @@ InstallFirmwarePerformanceDataTable (
mFirmwarePerformanceTableTemplate.BootPointerRecord.BootPerformanceTablePointer = (UINT64) (UINTN) mAcpiBootPerformanceTable;
//
+ // Save S3 Performance Table address to Variable for use in S4 resume.
+ //
+ PerformanceVariable.S3PerformanceTablePointer = (EFI_PHYSICAL_ADDRESS) (UINTN) mAcpiS3PerformanceTable;
+ //
+ // Update S3 Performance Table Pointer in template.
+ //
+ mFirmwarePerformanceTableTemplate.S3PointerRecord.S3PerformanceTablePointer = (UINT64) (UINTN) mAcpiS3PerformanceTable;
+ //
// Save Runtime Performance Table pointers to Variable.
//
Status = gRT->SetVariable (
EFI_FIRMWARE_PERFORMANCE_VARIABLE_NAME,
&gEfiFirmwarePerformanceGuid,
- EFI_VARIABLE_NON_VOLATILE | EFI_VARIABLE_BOOTSERVICE_ACCESS | EFI_VARIABLE_RUNTIME_ACCESS,
+ EFI_VARIABLE_NON_VOLATILE | EFI_VARIABLE_BOOTSERVICE_ACCESS,
sizeof (PerformanceVariable),
&PerformanceVariable
);
@@ -433,7 +517,10 @@ InstallFirmwarePerformanceDataTable (
&mFirmwarePerformanceTableTemplateKey
);
if (EFI_ERROR (Status)) {
- FreePool (PerformanceRuntimeDataHead);
+ FreePages (mAcpiBootPerformanceTable, EFI_SIZE_TO_PAGES (BootPerformanceDataSize));
+ if (mAcpiS3PerformanceTable != NULL) {
+ FreePages (mAcpiS3PerformanceTable, EFI_SIZE_TO_PAGES (sizeof (S3_PERFORMANCE_TABLE)));
+ }
mAcpiBootPerformanceTable = NULL;
mAcpiS3PerformanceTable = NULL;
return Status;
@@ -700,6 +787,7 @@ FirmwarePerformanceDxeEntryPoint (
EFI_STATUS Status;
EFI_HOB_GUID_TYPE *GuidHob;
FIRMWARE_SEC_PERFORMANCE *Performance;
+ VOID *Registration;
//
// Get Report Status Code Handler Protocol.
@@ -766,5 +854,31 @@ FirmwarePerformanceDxeEntryPoint (
DEBUG ((EFI_D_ERROR, "FPDT: WARNING: SEC Performance Data Hob not found, ResetEnd will be set to 0!\n"));
}
+ if (FeaturePcdGet (PcdFirmwarePerformanceDataTableS3Support)) {
+ //
+ // Register callback function upon VariableArchProtocol and LockBoxProtocol
+ // to allocate S3 performance table memory and save the pointer to LockBox.
+ //
+ EfiCreateProtocolNotifyEvent (
+ &gEfiVariableArchProtocolGuid,
+ TPL_CALLBACK,
+ FpdtAllocateS3PerformanceTableMemory,
+ NULL,
+ &Registration
+ );
+ EfiCreateProtocolNotifyEvent (
+ &gEfiLockBoxProtocolGuid,
+ TPL_CALLBACK,
+ FpdtAllocateS3PerformanceTableMemory,
+ NULL,
+ &Registration
+ );
+ } else {
+ //
+ // Exclude S3 Performance Table Pointer from FPDT table template.
+ //
+ mFirmwarePerformanceTableTemplate.Header.Length -= sizeof (EFI_ACPI_5_0_FPDT_S3_PERFORMANCE_TABLE_POINTER_RECORD);
+ }
+
return EFI_SUCCESS;
}
diff --git a/MdeModulePkg/Universal/Acpi/FirmwarePerformanceDataTableDxe/FirmwarePerformanceDxe.inf b/MdeModulePkg/Universal/Acpi/FirmwarePerformanceDataTableDxe/FirmwarePerformanceDxe.inf
index 89424acaae..5a9628f924 100644
--- a/MdeModulePkg/Universal/Acpi/FirmwarePerformanceDataTableDxe/FirmwarePerformanceDxe.inf
+++ b/MdeModulePkg/Universal/Acpi/FirmwarePerformanceDataTableDxe/FirmwarePerformanceDxe.inf
@@ -5,7 +5,7 @@
# for Firmware Basic Boot Performance Record and other boot performance records,
# and install FPDT to ACPI table.
#
-# 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
@@ -48,11 +48,15 @@
MemoryAllocationLib
PcdLib
HobLib
+ LockBoxLib
+ UefiLib
[Protocols]
gEfiAcpiTableProtocolGuid ## SOMETIMES_CONSUMES
gEfiRscHandlerProtocolGuid ## CONSUMES
gEfiSmmCommunicationProtocolGuid ## SOMETIMES_CONSUMES
+ gEfiVariableArchProtocolGuid ## SOMETIMES_CONSUMES
+ gEfiLockBoxProtocolGuid ## SOMETIMES_CONSUMES
[Guids]
gEfiEventExitBootServicesGuid ## CONSUMES
@@ -65,6 +69,7 @@
gEfiFirmwarePerformanceGuid ## SOMETIMES_CONSUMES ## Hob
gEfiFirmwarePerformanceGuid ## SOMETIMES_CONSUMES ## SmiHandler
gEfiFirmwarePerformanceGuid ## SOMETIMES_CONSUMES ## StatusCode Data
+ gFirmwarePerformanceS3PointerGuid ## SOMETIMES_PRODUCES # SaveLockBox
[Pcd]
gEfiMdeModulePkgTokenSpaceGuid.PcdProgressCodeOsLoaderLoad
diff --git a/MdeModulePkg/Universal/Acpi/FirmwarePerformanceDataTablePei/FirmwarePerformancePei.c b/MdeModulePkg/Universal/Acpi/FirmwarePerformanceDataTablePei/FirmwarePerformancePei.c
index af9b4e3c65..70592cbc3c 100644
--- a/MdeModulePkg/Universal/Acpi/FirmwarePerformanceDataTablePei/FirmwarePerformancePei.c
+++ b/MdeModulePkg/Universal/Acpi/FirmwarePerformanceDataTablePei/FirmwarePerformancePei.c
@@ -7,7 +7,7 @@
This module register report status code listener to collect performance data
for S3 Resume Performance Record on S3 resume boot path.
- 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
@@ -20,7 +20,6 @@
#include <PiPei.h>
-#include <Ppi/ReadOnlyVariable2.h>
#include <Ppi/ReportStatusCodeHandler.h>
#include <Ppi/SecPerformance.h>
@@ -68,9 +67,8 @@ FpdtStatusCodeListenerPei (
{
EFI_STATUS Status;
UINT64 CurrentTime;
- EFI_PEI_READ_ONLY_VARIABLE2_PPI *VariableServices;
UINTN VarSize;
- FIRMWARE_PERFORMANCE_VARIABLE PerformanceVariable;
+ EFI_PHYSICAL_ADDRESS S3PerformanceTablePointer;
S3_PERFORMANCE_TABLE *AcpiS3PerformanceTable;
EFI_ACPI_5_0_FPDT_S3_RESUME_RECORD *AcpiS3ResumeRecord;
UINT64 S3ResumeTotal;
@@ -90,33 +88,20 @@ FpdtStatusCodeListenerPei (
//
CurrentTime = GetTimeInNanoSecond (GetPerformanceCounter ());
- Status = PeiServicesLocatePpi (
- &gEfiPeiReadOnlyVariable2PpiGuid,
- 0,
- NULL,
- (VOID **) &VariableServices
- );
- ASSERT_EFI_ERROR (Status);
-
//
// Update S3 Resume Performance Record.
//
- VarSize = sizeof (FIRMWARE_PERFORMANCE_VARIABLE);
- Status = VariableServices->GetVariable (
- VariableServices,
- EFI_FIRMWARE_PERFORMANCE_VARIABLE_NAME,
- &gEfiFirmwarePerformanceGuid,
- NULL,
- &VarSize,
- &PerformanceVariable
- );
- if (EFI_ERROR (Status)) {
- return Status;
- }
+ S3PerformanceTablePointer = 0;
+ VarSize = sizeof (EFI_PHYSICAL_ADDRESS);
+ Status = RestoreLockBox (&gFirmwarePerformanceS3PointerGuid, &S3PerformanceTablePointer, &VarSize);
+ ASSERT_EFI_ERROR (Status);
- AcpiS3PerformanceTable = (S3_PERFORMANCE_TABLE *) (UINTN) PerformanceVariable.S3PerformanceTablePointer;
+ AcpiS3PerformanceTable = (S3_PERFORMANCE_TABLE *) (UINTN) S3PerformanceTablePointer;
ASSERT (AcpiS3PerformanceTable != NULL);
- ASSERT (AcpiS3PerformanceTable->Header.Signature == EFI_ACPI_5_0_FPDT_S3_PERFORMANCE_TABLE_SIGNATURE);
+ if (AcpiS3PerformanceTable->Header.Signature != EFI_ACPI_5_0_FPDT_S3_PERFORMANCE_TABLE_SIGNATURE) {
+ DEBUG ((EFI_D_ERROR, "FPDT S3 performance data in ACPI memory get corrupted\n"));
+ return EFI_ABORTED;
+ }
AcpiS3ResumeRecord = &AcpiS3PerformanceTable->S3Resume;
AcpiS3ResumeRecord->FullResume = CurrentTime;
//
diff --git a/MdeModulePkg/Universal/Acpi/FirmwarePerformanceDataTablePei/FirmwarePerformancePei.inf b/MdeModulePkg/Universal/Acpi/FirmwarePerformanceDataTablePei/FirmwarePerformancePei.inf
index 0694899bcb..aced5c521e 100644
--- a/MdeModulePkg/Universal/Acpi/FirmwarePerformanceDataTablePei/FirmwarePerformancePei.inf
+++ b/MdeModulePkg/Universal/Acpi/FirmwarePerformanceDataTablePei/FirmwarePerformancePei.inf
@@ -7,7 +7,7 @@
# This module register report status code listener to collect performance data
# for S3 Resume Performance Record on S3 resume boot path.
#
-# 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
@@ -52,11 +52,11 @@
[Ppis]
gEfiPeiRscHandlerPpiGuid ## CONSUMES
- gEfiPeiReadOnlyVariable2PpiGuid ## SOMETIMES_CONSUMES
gPeiSecPerformancePpiGuid ## CONSUMES
[Guids]
gEfiFirmwarePerformanceGuid ## CONSUMES
+ gFirmwarePerformanceS3PointerGuid ## CONSUMES
[FeaturePcd]
gEfiMdeModulePkgTokenSpaceGuid.PcdFirmwarePerformanceDataTableS3Support
diff --git a/MdeModulePkg/Universal/Acpi/FirmwarePerformanceDataTableSmm/FirmwarePerformanceSmm.c b/MdeModulePkg/Universal/Acpi/FirmwarePerformanceDataTableSmm/FirmwarePerformanceSmm.c
index 54a2275d4e..9c5fd4db85 100644
--- a/MdeModulePkg/Universal/Acpi/FirmwarePerformanceDataTableSmm/FirmwarePerformanceSmm.c
+++ b/MdeModulePkg/Universal/Acpi/FirmwarePerformanceDataTableSmm/FirmwarePerformanceSmm.c
@@ -11,7 +11,7 @@
FpdtSmiHandler() will receive untrusted input and do basic validation.
- 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
@@ -205,6 +205,33 @@ InternalIsAddressInSmram (
}
/**
+ This function check if the address refered by Buffer and Length is valid.
+
+ @param Buffer the buffer address to be checked.
+ @param Length the buffer length to be checked.
+
+ @retval TRUE this address is valid.
+ @retval FALSE this address is NOT valid.
+**/
+BOOLEAN
+InternalIsAddressValid (
+ IN UINTN Buffer,
+ IN UINTN Length
+ )
+{
+ if (Buffer > (MAX_ADDRESS - Length)) {
+ //
+ // Overflow happen
+ //
+ return FALSE;
+ }
+ if (InternalIsAddressInSmram ((EFI_PHYSICAL_ADDRESS)Buffer, (UINT64)Length)) {
+ return FALSE;
+ }
+ return TRUE;
+}
+
+/**
Communication service SMI Handler entry.
This SMI handler provides services for report SMM boot records.
@@ -239,6 +266,9 @@ FpdtSmiHandler (
{
EFI_STATUS Status;
SMM_BOOT_RECORD_COMMUNICATE *SmmCommData;
+ UINTN BootRecordSize;
+ VOID *BootRecordData;
+ UINTN TempCommBufferSize;
//
// If input is invalid, stop processing this SMI
@@ -247,12 +277,14 @@ FpdtSmiHandler (
return EFI_SUCCESS;
}
- if(*CommBufferSize < sizeof (SMM_BOOT_RECORD_COMMUNICATE)) {
+ TempCommBufferSize = *CommBufferSize;
+
+ if(TempCommBufferSize < sizeof (SMM_BOOT_RECORD_COMMUNICATE)) {
return EFI_SUCCESS;
}
- if (InternalIsAddressInSmram ((EFI_PHYSICAL_ADDRESS)(UINTN)CommBuffer, *CommBufferSize)) {
- DEBUG ((EFI_D_ERROR, "SMM communication data buffer is in SMRAM!\n"));
+ if (!InternalIsAddressValid ((UINTN)CommBuffer, TempCommBufferSize)) {
+ DEBUG ((EFI_D_ERROR, "FpdtSmiHandler: SMM communication data buffer in SMRAM or overflow!\n"));
return EFI_SUCCESS;
}
@@ -266,7 +298,9 @@ FpdtSmiHandler (
break;
case SMM_FPDT_FUNCTION_GET_BOOT_RECORD_DATA :
- if (SmmCommData->BootRecordData == NULL || SmmCommData->BootRecordSize < mBootRecordSize) {
+ BootRecordData = SmmCommData->BootRecordData;
+ BootRecordSize = SmmCommData->BootRecordSize;
+ if (BootRecordData == NULL || BootRecordSize < mBootRecordSize) {
Status = EFI_INVALID_PARAMETER;
break;
}
@@ -275,14 +309,14 @@ FpdtSmiHandler (
// Sanity check
//
SmmCommData->BootRecordSize = mBootRecordSize;
- if (InternalIsAddressInSmram ((EFI_PHYSICAL_ADDRESS)(UINTN)SmmCommData->BootRecordData, mBootRecordSize)) {
- DEBUG ((EFI_D_ERROR, "SMM Data buffer is in SMRAM!\n"));
+ if (!InternalIsAddressValid ((UINTN)BootRecordData, mBootRecordSize)) {
+ DEBUG ((EFI_D_ERROR, "FpdtSmiHandler: SMM Data buffer in SMRAM or overflow!\n"));
Status = EFI_ACCESS_DENIED;
break;
}
CopyMem (
- (UINT8*)SmmCommData->BootRecordData,
+ (UINT8*)BootRecordData,
mBootRecordBuffer,
mBootRecordSize
);
diff --git a/MdeModulePkg/Universal/DevicePathDxe/DevicePathFromText.c b/MdeModulePkg/Universal/DevicePathDxe/DevicePathFromText.c
index d94e149e58..f96bea1477 100644
--- a/MdeModulePkg/Universal/DevicePathDxe/DevicePathFromText.c
+++ b/MdeModulePkg/Universal/DevicePathDxe/DevicePathFromText.c
@@ -1,7 +1,7 @@
/** @file
DevicePathFromText protocol as defined in the UEFI 2.0 specification.
-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
@@ -1636,6 +1636,7 @@ DevPathFromTextSAS (
CHAR16 *DriveBayStr;
CHAR16 *ReservedStr;
UINT16 Info;
+ UINT16 Uint16;
SAS_DEVICE_PATH *Sas;
AddressStr = GetNextParamStr (&TextDeviceNode);
@@ -1646,7 +1647,6 @@ DevPathFromTextSAS (
ConnectStr = GetNextParamStr (&TextDeviceNode);
DriveBayStr = GetNextParamStr (&TextDeviceNode);
ReservedStr = GetNextParamStr (&TextDeviceNode);
- Info = 0x0000;
Sas = (SAS_DEVICE_PATH *) CreateDeviceNode (
MESSAGING_DEVICE_PATH,
MSG_VENDOR_DP,
@@ -1657,25 +1657,51 @@ DevPathFromTextSAS (
Strtoi64 (AddressStr, &Sas->SasAddress);
Strtoi64 (LunStr, &Sas->Lun);
Sas->RelativeTargetPort = (UINT16) Strtoi (RTPStr);
- if (StrCmp (SASSATAStr, L"NoTopology") != 0) {
- if (StrCmp (DriveBayStr, L"0") == 0) {
- Info |= 0x0001;
+
+ if (StrCmp (SASSATAStr, L"NoTopology") == 0) {
+ Info = 0x0;
+
+ } else if ((StrCmp (SASSATAStr, L"SATA") == 0) || (StrCmp (SASSATAStr, L"SAS") == 0)) {
+
+ Uint16 = (UINT16) Strtoi (DriveBayStr);
+ if (Uint16 == 0) {
+ Info = 0x1;
} else {
- Info |= 0x0002;
- Info = (UINT16) (Info | (Strtoi (DriveBayStr) << 8));
+ Info = (UINT16) (0x2 | ((Uint16 - 1) << 8));
}
if (StrCmp (SASSATAStr, L"SATA") == 0) {
- Info |= 0x0010;
+ Info |= BIT4;
}
+ //
+ // Location is an integer between 0 and 1 or else
+ // the keyword Internal (0) or External (1).
+ //
if (StrCmp (LocationStr, L"External") == 0) {
- Info |= 0x0020;
+ Uint16 = 1;
+ } else if (StrCmp (LocationStr, L"Internal") == 0) {
+ Uint16 = 0;
+ } else {
+ Uint16 = ((UINT16) Strtoi (LocationStr) & BIT0);
}
+ Info |= (Uint16 << 5);
+ //
+ // Connect is an integer between 0 and 3 or else
+ // the keyword Direct (0) or Expanded (1).
+ //
if (StrCmp (ConnectStr, L"Expanded") == 0) {
- Info |= 0x0040;
+ Uint16 = 1;
+ } else if (StrCmp (ConnectStr, L"Direct") == 0) {
+ Uint16 = 0;
+ } else {
+ Uint16 = ((UINT16) Strtoi (ConnectStr) & (BIT0 | BIT1));
}
+ Info |= (Uint16 << 6);
+
+ } else {
+ Info = (UINT16) Strtoi (SASSATAStr);
}
Sas->DeviceTopology = Info;
@@ -1705,6 +1731,9 @@ DevPathFromTextSasEx (
CHAR16 *ConnectStr;
CHAR16 *DriveBayStr;
UINT16 Info;
+ UINT16 Uint16;
+ UINT64 SasAddress;
+ UINT64 Lun;
SASEX_DEVICE_PATH *SasEx;
AddressStr = GetNextParamStr (&TextDeviceNode);
@@ -1714,37 +1743,62 @@ DevPathFromTextSasEx (
LocationStr = GetNextParamStr (&TextDeviceNode);
ConnectStr = GetNextParamStr (&TextDeviceNode);
DriveBayStr = GetNextParamStr (&TextDeviceNode);
- Info = 0x0000;
SasEx = (SASEX_DEVICE_PATH *) CreateDeviceNode (
MESSAGING_DEVICE_PATH,
MSG_SASEX_DP,
(UINT16) sizeof (SASEX_DEVICE_PATH)
);
- Strtoi64 (AddressStr, (UINT64 *) &SasEx->SasAddress);
- Strtoi64 (LunStr, (UINT64 *) &SasEx->Lun);
- *(UINT64 *) &SasEx->SasAddress = SwapBytes64 (*(UINT64 *) &SasEx->SasAddress);
- *(UINT64 *) &SasEx->Lun = SwapBytes64 (*(UINT64 *) &SasEx->Lun);
+ Strtoi64 (AddressStr, &SasAddress);
+ Strtoi64 (LunStr, &Lun);
+ WriteUnaligned64 ((UINT64 *) &SasEx->SasAddress, SwapBytes64 (SasAddress));
+ WriteUnaligned64 ((UINT64 *) &SasEx->Lun, SwapBytes64 (Lun));
SasEx->RelativeTargetPort = (UINT16) Strtoi (RTPStr);
- if (StrCmp (SASSATAStr, L"NoTopology") != 0) {
- if (StrCmp (DriveBayStr, L"0") == 0) {
- Info |= 0x0001;
+
+ if (StrCmp (SASSATAStr, L"NoTopology") == 0) {
+ Info = 0x0;
+
+ } else if ((StrCmp (SASSATAStr, L"SATA") == 0) || (StrCmp (SASSATAStr, L"SAS") == 0)) {
+
+ Uint16 = (UINT16) Strtoi (DriveBayStr);
+ if (Uint16 == 0) {
+ Info = 0x1;
} else {
- Info |= 0x0002;
- Info = (UINT16) (Info | (Strtoi (DriveBayStr) << 8));
+ Info = (UINT16) (0x2 | ((Uint16 - 1) << 8));
}
if (StrCmp (SASSATAStr, L"SATA") == 0) {
- Info |= 0x0010;
+ Info |= BIT4;
}
+ //
+ // Location is an integer between 0 and 1 or else
+ // the keyword Internal (0) or External (1).
+ //
if (StrCmp (LocationStr, L"External") == 0) {
- Info |= 0x0020;
+ Uint16 = 1;
+ } else if (StrCmp (LocationStr, L"Internal") == 0) {
+ Uint16 = 0;
+ } else {
+ Uint16 = ((UINT16) Strtoi (LocationStr) & BIT0);
}
+ Info |= (Uint16 << 5);
+ //
+ // Connect is an integer between 0 and 3 or else
+ // the keyword Direct (0) or Expanded (1).
+ //
if (StrCmp (ConnectStr, L"Expanded") == 0) {
- Info |= 0x0040;
+ Uint16 = 1;
+ } else if (StrCmp (ConnectStr, L"Direct") == 0) {
+ Uint16 = 0;
+ } else {
+ Uint16 = ((UINT16) Strtoi (ConnectStr) & (BIT0 | BIT1));
}
+ Info |= (Uint16 << 6);
+
+ } else {
+ Info = (UINT16) Strtoi (SASSATAStr);
}
SasEx->DeviceTopology = Info;
diff --git a/MdeModulePkg/Universal/DevicePathDxe/DevicePathToText.c b/MdeModulePkg/Universal/DevicePathDxe/DevicePathToText.c
index 1f90f64204..3d9d7c7a7e 100644
--- a/MdeModulePkg/Universal/DevicePathDxe/DevicePathToText.c
+++ b/MdeModulePkg/Universal/DevicePathDxe/DevicePathToText.c
@@ -1,7 +1,7 @@
/** @file
DevicePathToText protocol as defined in the UEFI 2.0 specification.
-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
@@ -234,23 +234,26 @@ DevPathToTextVendor (
((SAS_DEVICE_PATH *) Vendor)->RelativeTargetPort
);
Info = (((SAS_DEVICE_PATH *) Vendor)->DeviceTopology);
- if ((Info & 0x0f) == 0) {
+ if (((Info & 0x0f) == 0) && ((Info & BIT7) == 0)) {
CatPrint (Str, L"NoTopology,0,0,0,");
- } else if (((Info & 0x0f) == 1) || ((Info & 0x0f) == 2)) {
+ } else if (((Info & 0x0f) <= 2) && ((Info & BIT7) == 0)) {
CatPrint (
Str,
L"%s,%s,%s,",
- ((Info & (0x1 << 4)) != 0) ? L"SATA" : L"SAS",
- ((Info & (0x1 << 5)) != 0) ? L"External" : L"Internal",
- ((Info & (0x1 << 6)) != 0) ? L"Expanded" : L"Direct"
+ ((Info & BIT4) != 0) ? L"SATA" : L"SAS",
+ ((Info & BIT5) != 0) ? L"External" : L"Internal",
+ ((Info & BIT6) != 0) ? L"Expanded" : L"Direct"
);
if ((Info & 0x0f) == 1) {
CatPrint (Str, L"0,");
} else {
- CatPrint (Str, L"0x%x,", (Info >> 8) & 0xff);
+ //
+ // Value 0x0 thru 0xFF -> Drive 1 thru Drive 256
+ //
+ CatPrint (Str, L"0x%x,", ((Info >> 8) & 0xff) + 1);
}
} else {
- CatPrint (Str, L"0,0,0,0,");
+ CatPrint (Str, L"0x%x,0,0,0,", Info);
}
CatPrint (Str, L"0x%x)", ((SAS_DEVICE_PATH *) Vendor)->Reserved);
@@ -689,23 +692,26 @@ DevPathToTextSasEx (
}
CatPrint (Str, L",0x%x,", SasEx->RelativeTargetPort);
- if ((SasEx->DeviceTopology & 0x0f) == 0) {
+ if (((SasEx->DeviceTopology & 0x0f) == 0) && ((SasEx->DeviceTopology & BIT7) == 0)) {
CatPrint (Str, L"NoTopology,0,0,0");
- } else if (((SasEx->DeviceTopology & 0x0f) == 1) || ((SasEx->DeviceTopology & 0x0f) == 2)) {
+ } else if (((SasEx->DeviceTopology & 0x0f) <= 2) && ((SasEx->DeviceTopology & BIT7) == 0)) {
CatPrint (
Str,
L"%s,%s,%s,",
- ((SasEx->DeviceTopology & (0x1 << 4)) != 0) ? L"SATA" : L"SAS",
- ((SasEx->DeviceTopology & (0x1 << 5)) != 0) ? L"External" : L"Internal",
- ((SasEx->DeviceTopology & (0x1 << 6)) != 0) ? L"Expanded" : L"Direct"
+ ((SasEx->DeviceTopology & BIT4) != 0) ? L"SATA" : L"SAS",
+ ((SasEx->DeviceTopology & BIT5) != 0) ? L"External" : L"Internal",
+ ((SasEx->DeviceTopology & BIT6) != 0) ? L"Expanded" : L"Direct"
);
if ((SasEx->DeviceTopology & 0x0f) == 1) {
CatPrint (Str, L"0");
} else {
- CatPrint (Str, L"0x%x", (SasEx->DeviceTopology >> 8) & 0xff);
+ //
+ // Value 0x0 thru 0xFF -> Drive 1 thru Drive 256
+ //
+ CatPrint (Str, L"0x%x", ((SasEx->DeviceTopology >> 8) & 0xff) + 1);
}
} else {
- CatPrint (Str, L"0,0,0,0");
+ CatPrint (Str, L"0x%x,0,0,0", SasEx->DeviceTopology);
}
CatPrint (Str, L")");
diff --git a/MdeModulePkg/Universal/FaultTolerantWriteDxe/FaultTolerantWriteSmm.c b/MdeModulePkg/Universal/FaultTolerantWriteDxe/FaultTolerantWriteSmm.c
index e7d79c1aa5..2b3a63081d 100644
--- a/MdeModulePkg/Universal/FaultTolerantWriteDxe/FaultTolerantWriteSmm.c
+++ b/MdeModulePkg/Universal/FaultTolerantWriteDxe/FaultTolerantWriteSmm.c
@@ -43,7 +43,7 @@
Caution: This module requires additional review when modified.
This driver need to make sure the CommBuffer is not in the SMRAM range.
-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
@@ -60,12 +60,17 @@ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
#include "FaultTolerantWrite.h"
#include "FaultTolerantWriteSmmCommon.h"
#include <Protocol/SmmAccess2.h>
+#include <Protocol/SmmEndOfDxe.h>
EFI_EVENT mFvbRegistration = NULL;
EFI_FTW_DEVICE *mFtwDevice = NULL;
EFI_SMRAM_DESCRIPTOR *mSmramRanges;
UINTN mSmramRangeCount;
+///
+/// The flag to indicate whether the platform has left the DXE phase of execution.
+///
+BOOLEAN mEndOfDxe = FALSE;
/**
This function check if the address is in SMRAM.
@@ -94,6 +99,32 @@ InternalIsAddressInSmram (
return FALSE;
}
+/**
+ This function check if the address refered by Buffer and Length is valid.
+
+ @param Buffer the buffer address to be checked.
+ @param Length the buffer length to be checked.
+
+ @retval TRUE this address is valid.
+ @retval FALSE this address is NOT valid.
+**/
+BOOLEAN
+InternalIsAddressValid (
+ IN UINTN Buffer,
+ IN UINTN Length
+ )
+{
+ if (Buffer > (MAX_ADDRESS - Length)) {
+ //
+ // Overflow happen
+ //
+ return FALSE;
+ }
+ if (InternalIsAddressInSmram ((EFI_PHYSICAL_ADDRESS)Buffer, (UINT64)Length)) {
+ return FALSE;
+ }
+ return TRUE;
+}
/**
Retrive the SMM FVB protocol interface by HANDLE.
@@ -338,7 +369,10 @@ SmmFaultTolerantWriteHandler (
VOID *PrivateData;
EFI_HANDLE SmmFvbHandle;
UINTN InfoSize;
-
+ UINTN CommBufferPayloadSize;
+ UINTN PrivateDataSize;
+ UINTN Length;
+ UINTN TempCommBufferSize;
//
// If input is invalid, stop processing this SMI
@@ -347,29 +381,37 @@ SmmFaultTolerantWriteHandler (
return EFI_SUCCESS;
}
- if (*CommBufferSize < SMM_FTW_COMMUNICATE_HEADER_SIZE) {
+ TempCommBufferSize = *CommBufferSize;
+
+ if (TempCommBufferSize < SMM_FTW_COMMUNICATE_HEADER_SIZE) {
+ DEBUG ((EFI_D_ERROR, "SmmFtwHandler: SMM communication buffer size invalid!\n"));
return EFI_SUCCESS;
}
+ CommBufferPayloadSize = TempCommBufferSize - SMM_FTW_COMMUNICATE_HEADER_SIZE;
- if (InternalIsAddressInSmram ((EFI_PHYSICAL_ADDRESS)(UINTN)CommBuffer, *CommBufferSize)) {
- DEBUG ((EFI_D_ERROR, "SMM communication buffer size is in SMRAM!\n"));
+ if (!InternalIsAddressValid ((UINTN)CommBuffer, TempCommBufferSize)) {
+ DEBUG ((EFI_D_ERROR, "SmmFtwHandler: SMM communication buffer in SMRAM or overflow!\n"));
return EFI_SUCCESS;
}
SmmFtwFunctionHeader = (SMM_FTW_COMMUNICATE_FUNCTION_HEADER *)CommBuffer;
+
+ if (mEndOfDxe) {
+ //
+ // It will be not safe to expose the operations after End Of Dxe.
+ //
+ DEBUG ((EFI_D_ERROR, "SmmFtwHandler: Not safe to do the operation: %x after End Of Dxe, so access denied!\n", SmmFtwFunctionHeader->Function));
+ SmmFtwFunctionHeader->ReturnStatus = EFI_ACCESS_DENIED;
+ return EFI_SUCCESS;
+ }
+
switch (SmmFtwFunctionHeader->Function) {
case FTW_FUNCTION_GET_MAX_BLOCK_SIZE:
- SmmGetMaxBlockSizeHeader = (SMM_FTW_GET_MAX_BLOCK_SIZE_HEADER *) SmmFtwFunctionHeader->Data;
- InfoSize = sizeof (SMM_FTW_GET_MAX_BLOCK_SIZE_HEADER);
-
- //
- // SMRAM range check already covered before
- //
- if (InfoSize > *CommBufferSize - SMM_FTW_COMMUNICATE_HEADER_SIZE) {
- DEBUG ((EFI_D_ERROR, "Data size exceed communication buffer size limit!\n"));
- Status = EFI_ACCESS_DENIED;
- break;
+ if (CommBufferPayloadSize < sizeof (SMM_FTW_GET_MAX_BLOCK_SIZE_HEADER)) {
+ DEBUG ((EFI_D_ERROR, "GetMaxBlockSize: SMM communication buffer size invalid!\n"));
+ return EFI_SUCCESS;
}
+ SmmGetMaxBlockSizeHeader = (SMM_FTW_GET_MAX_BLOCK_SIZE_HEADER *) SmmFtwFunctionHeader->Data;
Status = FtwGetMaxBlockSize (
&mFtwDevice->FtwInstance,
@@ -378,6 +420,10 @@ SmmFaultTolerantWriteHandler (
break;
case FTW_FUNCTION_ALLOCATE:
+ if (CommBufferPayloadSize < sizeof (SMM_FTW_ALLOCATE_HEADER)) {
+ DEBUG ((EFI_D_ERROR, "Allocate: SMM communication buffer size invalid!\n"));
+ return EFI_SUCCESS;
+ }
SmmFtwAllocateHeader = (SMM_FTW_ALLOCATE_HEADER *) SmmFtwFunctionHeader->Data;
Status = FtwAllocate (
&mFtwDevice->FtwInstance,
@@ -388,11 +434,36 @@ SmmFaultTolerantWriteHandler (
break;
case FTW_FUNCTION_WRITE:
+ if (CommBufferPayloadSize < OFFSET_OF (SMM_FTW_WRITE_HEADER, Data)) {
+ DEBUG ((EFI_D_ERROR, "Write: SMM communication buffer size invalid!\n"));
+ return EFI_SUCCESS;
+ }
SmmFtwWriteHeader = (SMM_FTW_WRITE_HEADER *) SmmFtwFunctionHeader->Data;
- if (SmmFtwWriteHeader->PrivateDataSize == 0) {
+ Length = SmmFtwWriteHeader->Length;
+ PrivateDataSize = SmmFtwWriteHeader->PrivateDataSize;
+ if (((UINTN)(~0) - Length < OFFSET_OF (SMM_FTW_WRITE_HEADER, Data)) ||
+ ((UINTN)(~0) - PrivateDataSize < OFFSET_OF (SMM_FTW_WRITE_HEADER, Data) + Length)) {
+ //
+ // Prevent InfoSize overflow
+ //
+ Status = EFI_ACCESS_DENIED;
+ break;
+ }
+ InfoSize = OFFSET_OF (SMM_FTW_WRITE_HEADER, Data) + Length + PrivateDataSize;
+
+ //
+ // SMRAM range check already covered before
+ //
+ if (InfoSize > CommBufferPayloadSize) {
+ DEBUG ((EFI_D_ERROR, "Write: Data size exceed communication buffer size limit!\n"));
+ Status = EFI_ACCESS_DENIED;
+ break;
+ }
+
+ if (PrivateDataSize == 0) {
PrivateData = NULL;
} else {
- PrivateData = (VOID *)&SmmFtwWriteHeader->Data[SmmFtwWriteHeader->Length];
+ PrivateData = (VOID *)&SmmFtwWriteHeader->Data[Length];
}
Status = GetFvbByAddressAndAttribute (
SmmFtwWriteHeader->FvbBaseAddress,
@@ -404,7 +475,7 @@ SmmFaultTolerantWriteHandler (
&mFtwDevice->FtwInstance,
SmmFtwWriteHeader->Lba,
SmmFtwWriteHeader->Offset,
- SmmFtwWriteHeader->Length,
+ Length,
PrivateData,
SmmFvbHandle,
SmmFtwWriteHeader->Data
@@ -413,6 +484,10 @@ SmmFaultTolerantWriteHandler (
break;
case FTW_FUNCTION_RESTART:
+ if (CommBufferPayloadSize < sizeof (SMM_FTW_RESTART_HEADER)) {
+ DEBUG ((EFI_D_ERROR, "Restart: SMM communication buffer size invalid!\n"));
+ return EFI_SUCCESS;
+ }
SmmFtwRestartHeader = (SMM_FTW_RESTART_HEADER *) SmmFtwFunctionHeader->Data;
Status = GetFvbByAddressAndAttribute (
SmmFtwRestartHeader->FvbBaseAddress,
@@ -429,13 +504,25 @@ SmmFaultTolerantWriteHandler (
break;
case FTW_FUNCTION_GET_LAST_WRITE:
+ if (CommBufferPayloadSize < OFFSET_OF (SMM_FTW_GET_LAST_WRITE_HEADER, Data)) {
+ DEBUG ((EFI_D_ERROR, "GetLastWrite: SMM communication buffer size invalid!\n"));
+ return EFI_SUCCESS;
+ }
SmmFtwGetLastWriteHeader = (SMM_FTW_GET_LAST_WRITE_HEADER *) SmmFtwFunctionHeader->Data;
- InfoSize = OFFSET_OF (SMM_FTW_GET_LAST_WRITE_HEADER, Data) + SmmFtwGetLastWriteHeader->PrivateDataSize;
+ PrivateDataSize = SmmFtwGetLastWriteHeader->PrivateDataSize;
+ if ((UINTN)(~0) - PrivateDataSize < OFFSET_OF (SMM_FTW_GET_LAST_WRITE_HEADER, Data)){
+ //
+ // Prevent InfoSize overflow
+ //
+ Status = EFI_ACCESS_DENIED;
+ break;
+ }
+ InfoSize = OFFSET_OF (SMM_FTW_GET_LAST_WRITE_HEADER, Data) + PrivateDataSize;
//
// SMRAM range check already covered before
//
- if (InfoSize > *CommBufferSize - SMM_FTW_COMMUNICATE_HEADER_SIZE) {
+ if (InfoSize > CommBufferPayloadSize) {
DEBUG ((EFI_D_ERROR, "Data size exceed communication buffer size limit!\n"));
Status = EFI_ACCESS_DENIED;
break;
@@ -447,10 +534,11 @@ SmmFaultTolerantWriteHandler (
&SmmFtwGetLastWriteHeader->Lba,
&SmmFtwGetLastWriteHeader->Offset,
&SmmFtwGetLastWriteHeader->Length,
- &SmmFtwGetLastWriteHeader->PrivateDataSize,
+ &PrivateDataSize,
(VOID *)SmmFtwGetLastWriteHeader->Data,
&SmmFtwGetLastWriteHeader->Complete
);
+ SmmFtwGetLastWriteHeader->PrivateDataSize = PrivateDataSize;
break;
default:
@@ -484,6 +572,7 @@ FvbNotificationEvent (
EFI_STATUS Status;
EFI_SMM_FAULT_TOLERANT_WRITE_PROTOCOL *FtwProtocol;
EFI_HANDLE SmmFtwHandle;
+ EFI_HANDLE FtwHandle;
//
// Just return to avoid install SMM FaultTolerantWriteProtocol again
@@ -505,7 +594,7 @@ FvbNotificationEvent (
if (EFI_ERROR(Status)) {
return Status;
}
-
+
//
// Install protocol interface
//
@@ -517,12 +606,18 @@ FvbNotificationEvent (
);
ASSERT_EFI_ERROR (Status);
+ ///
+ /// Register SMM FTW SMI handler
+ ///
+ Status = gSmst->SmiHandlerRegister (SmmFaultTolerantWriteHandler, &gEfiSmmFaultTolerantWriteProtocolGuid, &SmmFtwHandle);
+ ASSERT_EFI_ERROR (Status);
+
//
// Notify the Ftw wrapper driver SMM Ftw is ready
//
- SmmFtwHandle = NULL;
+ FtwHandle = NULL;
Status = gBS->InstallProtocolInterface (
- &SmmFtwHandle,
+ &FtwHandle,
&gEfiSmmFaultTolerantWriteProtocolGuid,
EFI_NATIVE_INTERFACE,
NULL
@@ -532,6 +627,27 @@ FvbNotificationEvent (
return EFI_SUCCESS;
}
+/**
+ SMM END_OF_DXE protocol notification event handler.
+
+ @param Protocol Points to the protocol's unique identifier
+ @param Interface Points to the interface instance
+ @param Handle The handle on which the interface was installed
+
+ @retval EFI_SUCCESS SmmEndOfDxeCallback runs successfully
+
+**/
+EFI_STATUS
+EFIAPI
+SmmEndOfDxeCallback (
+ IN CONST EFI_GUID *Protocol,
+ IN VOID *Interface,
+ IN EFI_HANDLE Handle
+ )
+{
+ mEndOfDxe = TRUE;
+ return EFI_SUCCESS;
+}
/**
This function is the entry point of the Fault Tolerant Write driver.
@@ -552,10 +668,10 @@ SmmFaultTolerantWriteInitialize (
)
{
EFI_STATUS Status;
- EFI_HANDLE FtwHandle;
EFI_SMM_ACCESS2_PROTOCOL *SmmAccess;
UINTN Size;
-
+ VOID *SmmEndOfDxeRegistration;
+
//
// Allocate private data structure for SMM FTW protocol and do some initialization
//
@@ -587,6 +703,16 @@ SmmFaultTolerantWriteInitialize (
mSmramRangeCount = Size / sizeof (EFI_SMRAM_DESCRIPTOR);
//
+ // Register EFI_SMM_END_OF_DXE_PROTOCOL_GUID notify function.
+ //
+ Status = gSmst->SmmRegisterProtocolNotify (
+ &gEfiSmmEndOfDxeProtocolGuid,
+ SmmEndOfDxeCallback,
+ &SmmEndOfDxeRegistration
+ );
+ ASSERT_EFI_ERROR (Status);
+
+ //
// Register FvbNotificationEvent () notify function.
//
Status = gSmst->SmmRegisterProtocolNotify (
@@ -597,12 +723,6 @@ SmmFaultTolerantWriteInitialize (
ASSERT_EFI_ERROR (Status);
FvbNotificationEvent (NULL, NULL, NULL);
-
- ///
- /// Register SMM FTW SMI handler
- ///
- Status = gSmst->SmiHandlerRegister (SmmFaultTolerantWriteHandler, &gEfiSmmFaultTolerantWriteProtocolGuid, &FtwHandle);
- ASSERT_EFI_ERROR (Status);
return EFI_SUCCESS;
}
diff --git a/MdeModulePkg/Universal/FaultTolerantWriteDxe/FaultTolerantWriteSmm.inf b/MdeModulePkg/Universal/FaultTolerantWriteDxe/FaultTolerantWriteSmm.inf
index 7e07dc850d..c39f84ca3c 100644
--- a/MdeModulePkg/Universal/FaultTolerantWriteDxe/FaultTolerantWriteSmm.inf
+++ b/MdeModulePkg/Universal/FaultTolerantWriteDxe/FaultTolerantWriteSmm.inf
@@ -4,7 +4,7 @@
# depends on the full functionality SMM FVB protocol that support read, write/erase
# flash access.
#
-# 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
@@ -59,6 +59,7 @@
gEfiSmmFirmwareVolumeBlockProtocolGuid ## CONSUMES
gEfiSmmFaultTolerantWriteProtocolGuid ## PRODUCES
gEfiSmmAccess2ProtocolGuid ## CONSUMES
+ gEfiSmmEndOfDxeProtocolGuid ## CONSUMES
[FeaturePcd]
gEfiMdeModulePkgTokenSpaceGuid.PcdFullFtwServiceEnable
diff --git a/MdeModulePkg/Universal/FaultTolerantWriteDxe/FaultTolerantWriteSmmDxe.c b/MdeModulePkg/Universal/FaultTolerantWriteDxe/FaultTolerantWriteSmmDxe.c
index 24b157df08..772d10dcd4 100644
--- a/MdeModulePkg/Universal/FaultTolerantWriteDxe/FaultTolerantWriteSmmDxe.c
+++ b/MdeModulePkg/Universal/FaultTolerantWriteDxe/FaultTolerantWriteSmmDxe.c
@@ -3,7 +3,7 @@
Implement the Fault Tolerant Write (FTW) protocol based on SMM FTW
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
@@ -463,13 +463,17 @@ FtwGetLastWrite (
// Get data from SMM
//
*PrivateDataSize = SmmFtwGetLastWriteHeader->PrivateDataSize;
- if (!EFI_ERROR (Status)) {
+ if (Status == EFI_SUCCESS || Status == EFI_BUFFER_TOO_SMALL) {
*Lba = SmmFtwGetLastWriteHeader->Lba;
*Offset = SmmFtwGetLastWriteHeader->Offset;
*Length = SmmFtwGetLastWriteHeader->Length;
*Complete = SmmFtwGetLastWriteHeader->Complete;
CopyGuid (CallerId, &SmmFtwGetLastWriteHeader->CallerId);
- CopyMem (PrivateData, SmmFtwGetLastWriteHeader->Data, *PrivateDataSize);
+ if (Status == EFI_SUCCESS) {
+ CopyMem (PrivateData, SmmFtwGetLastWriteHeader->Data, *PrivateDataSize);
+ }
+ } else if (Status == EFI_NOT_FOUND) {
+ *Complete = SmmFtwGetLastWriteHeader->Complete;
}
FreePool (SmmCommunicateHeader);
diff --git a/MdeModulePkg/Universal/FaultTolerantWriteDxe/FaultTolerantWriteSmmDxe.inf b/MdeModulePkg/Universal/FaultTolerantWriteDxe/FaultTolerantWriteSmmDxe.inf
index 3ed0393229..a0dda0588b 100644
--- a/MdeModulePkg/Universal/FaultTolerantWriteDxe/FaultTolerantWriteSmmDxe.inf
+++ b/MdeModulePkg/Universal/FaultTolerantWriteDxe/FaultTolerantWriteSmmDxe.inf
@@ -1,8 +1,11 @@
## @file
-# This module is the Runtime DXE part corresponding to SMM Fault Tolerant Write (FTW) module.
+# This module is the DXE part corresponding to SMM Fault Tolerant Write (FTW) module.
# It installs FTW protocol and works with SMM FTW module together.
+# The FTW protocol will not work after End Of Dxe because it will be not safe to expose
+# the related operations in SMM handler in SMM FTW module. You can use the FTW protocol
+# before End Of Dxe or use FaultTolerantWriteDxe module instead if you really want to.
#
-# 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
diff --git a/MdeModulePkg/Universal/LockBox/SmmLockBox/SmmLockBox.c b/MdeModulePkg/Universal/LockBox/SmmLockBox/SmmLockBox.c
index e8b831e1fb..ad4b2645cb 100644
--- a/MdeModulePkg/Universal/LockBox/SmmLockBox/SmmLockBox.c
+++ b/MdeModulePkg/Universal/LockBox/SmmLockBox/SmmLockBox.c
@@ -9,7 +9,7 @@
SmmLockBoxHandler(), SmmLockBoxRestore(), SmmLockBoxUpdate(), SmmLockBoxSave()
will receive untrusted input and do basic validation.
-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
@@ -111,6 +111,7 @@ SmmLockBoxSave (
)
{
EFI_STATUS Status;
+ EFI_SMM_LOCK_BOX_PARAMETER_SAVE TempLockBoxParameterSave;
//
// Sanity check
@@ -121,11 +122,13 @@ SmmLockBoxSave (
return ;
}
+ CopyMem (&TempLockBoxParameterSave, LockBoxParameterSave, sizeof (EFI_SMM_LOCK_BOX_PARAMETER_SAVE));
+
//
// Sanity check
//
- if (!IsAddressValid ((UINTN)LockBoxParameterSave->Buffer, (UINTN)LockBoxParameterSave->Length)) {
- DEBUG ((EFI_D_ERROR, "SmmLockBox Save address in SMRAM!\n"));
+ if (!IsAddressValid ((UINTN)TempLockBoxParameterSave.Buffer, (UINTN)TempLockBoxParameterSave.Length)) {
+ DEBUG ((EFI_D_ERROR, "SmmLockBox Save address in SMRAM or buffer overflow!\n"));
LockBoxParameterSave->Header.ReturnStatus = (UINT64)EFI_ACCESS_DENIED;
return ;
}
@@ -134,9 +137,9 @@ SmmLockBoxSave (
// Save data
//
Status = SaveLockBox (
- &LockBoxParameterSave->Guid,
- (VOID *)(UINTN)LockBoxParameterSave->Buffer,
- (UINTN)LockBoxParameterSave->Length
+ &TempLockBoxParameterSave.Guid,
+ (VOID *)(UINTN)TempLockBoxParameterSave.Buffer,
+ (UINTN)TempLockBoxParameterSave.Length
);
LockBoxParameterSave->Header.ReturnStatus = (UINT64)Status;
return ;
@@ -153,6 +156,7 @@ SmmLockBoxSetAttributes (
)
{
EFI_STATUS Status;
+ EFI_SMM_LOCK_BOX_PARAMETER_SET_ATTRIBUTES TempLockBoxParameterSetAttributes;
//
// Sanity check
@@ -163,12 +167,14 @@ SmmLockBoxSetAttributes (
return ;
}
+ CopyMem (&TempLockBoxParameterSetAttributes, LockBoxParameterSetAttributes, sizeof (EFI_SMM_LOCK_BOX_PARAMETER_SET_ATTRIBUTES));
+
//
// Update data
//
Status = SetLockBoxAttributes (
- &LockBoxParameterSetAttributes->Guid,
- LockBoxParameterSetAttributes->Attributes
+ &TempLockBoxParameterSetAttributes.Guid,
+ TempLockBoxParameterSetAttributes.Attributes
);
LockBoxParameterSetAttributes->Header.ReturnStatus = (UINT64)Status;
return ;
@@ -189,6 +195,7 @@ SmmLockBoxUpdate (
)
{
EFI_STATUS Status;
+ EFI_SMM_LOCK_BOX_PARAMETER_UPDATE TempLockBoxParameterUpdate;
//
// Sanity check
@@ -199,11 +206,13 @@ SmmLockBoxUpdate (
return ;
}
+ CopyMem (&TempLockBoxParameterUpdate, LockBoxParameterUpdate, sizeof (EFI_SMM_LOCK_BOX_PARAMETER_UPDATE));
+
//
// Sanity check
//
- if (!IsAddressValid ((UINTN)LockBoxParameterUpdate->Buffer, (UINTN)LockBoxParameterUpdate->Length)) {
- DEBUG ((EFI_D_ERROR, "SmmLockBox Update address in SMRAM!\n"));
+ if (!IsAddressValid ((UINTN)TempLockBoxParameterUpdate.Buffer, (UINTN)TempLockBoxParameterUpdate.Length)) {
+ DEBUG ((EFI_D_ERROR, "SmmLockBox Update address in SMRAM or buffer overflow!\n"));
LockBoxParameterUpdate->Header.ReturnStatus = (UINT64)EFI_ACCESS_DENIED;
return ;
}
@@ -212,10 +221,10 @@ SmmLockBoxUpdate (
// Update data
//
Status = UpdateLockBox (
- &LockBoxParameterUpdate->Guid,
- (UINTN)LockBoxParameterUpdate->Offset,
- (VOID *)(UINTN)LockBoxParameterUpdate->Buffer,
- (UINTN)LockBoxParameterUpdate->Length
+ &TempLockBoxParameterUpdate.Guid,
+ (UINTN)TempLockBoxParameterUpdate.Offset,
+ (VOID *)(UINTN)TempLockBoxParameterUpdate.Buffer,
+ (UINTN)TempLockBoxParameterUpdate.Length
);
LockBoxParameterUpdate->Header.ReturnStatus = (UINT64)Status;
return ;
@@ -236,12 +245,15 @@ SmmLockBoxRestore (
)
{
EFI_STATUS Status;
+ EFI_SMM_LOCK_BOX_PARAMETER_RESTORE TempLockBoxParameterRestore;
+
+ CopyMem (&TempLockBoxParameterRestore, LockBoxParameterRestore, sizeof (EFI_SMM_LOCK_BOX_PARAMETER_RESTORE));
//
// Sanity check
//
- if (!IsAddressValid ((UINTN)LockBoxParameterRestore->Buffer, (UINTN)LockBoxParameterRestore->Length)) {
- DEBUG ((EFI_D_ERROR, "SmmLockBox Restore address in SMRAM!\n"));
+ if (!IsAddressValid ((UINTN)TempLockBoxParameterRestore.Buffer, (UINTN)TempLockBoxParameterRestore.Length)) {
+ DEBUG ((EFI_D_ERROR, "SmmLockBox Restore address in SMRAM or buffer overflow!\n"));
LockBoxParameterRestore->Header.ReturnStatus = (UINT64)EFI_ACCESS_DENIED;
return ;
}
@@ -249,17 +261,17 @@ SmmLockBoxRestore (
//
// Restore data
//
- if ((LockBoxParameterRestore->Length == 0) && (LockBoxParameterRestore->Buffer == 0)) {
+ if ((TempLockBoxParameterRestore.Length == 0) && (TempLockBoxParameterRestore.Buffer == 0)) {
Status = RestoreLockBox (
- &LockBoxParameterRestore->Guid,
+ &TempLockBoxParameterRestore.Guid,
NULL,
NULL
);
} else {
Status = RestoreLockBox (
- &LockBoxParameterRestore->Guid,
- (VOID *)(UINTN)LockBoxParameterRestore->Buffer,
- (UINTN *)&LockBoxParameterRestore->Length
+ &TempLockBoxParameterRestore.Guid,
+ (VOID *)(UINTN)TempLockBoxParameterRestore.Buffer,
+ (UINTN *)&TempLockBoxParameterRestore.Length
);
}
LockBoxParameterRestore->Header.ReturnStatus = (UINT64)Status;
@@ -309,18 +321,28 @@ SmmLockBoxHandler (
)
{
EFI_SMM_LOCK_BOX_PARAMETER_HEADER *LockBoxParameterHeader;
+ UINTN TempCommBufferSize;
DEBUG ((EFI_D_ERROR, "SmmLockBox SmmLockBoxHandler Enter\n"));
//
+ // If input is invalid, stop processing this SMI
+ //
+ if (CommBuffer == NULL || CommBufferSize == NULL) {
+ return EFI_SUCCESS;
+ }
+
+ TempCommBufferSize = *CommBufferSize;
+
+ //
// Sanity check
//
- if (*CommBufferSize < sizeof(EFI_SMM_LOCK_BOX_PARAMETER_HEADER)) {
+ if (TempCommBufferSize < sizeof(EFI_SMM_LOCK_BOX_PARAMETER_HEADER)) {
DEBUG ((EFI_D_ERROR, "SmmLockBox Command Buffer Size invalid!\n"));
return EFI_SUCCESS;
}
- if (!IsAddressValid ((UINTN)CommBuffer, *CommBufferSize)) {
- DEBUG ((EFI_D_ERROR, "SmmLockBox Command Buffer in SMRAM!\n"));
+ if (!IsAddressValid ((UINTN)CommBuffer, TempCommBufferSize)) {
+ DEBUG ((EFI_D_ERROR, "SmmLockBox Command Buffer in SMRAM or overflow!\n"));
return EFI_SUCCESS;
}
@@ -334,35 +356,35 @@ SmmLockBoxHandler (
switch (LockBoxParameterHeader->Command) {
case EFI_SMM_LOCK_BOX_COMMAND_SAVE:
- if (*CommBufferSize < sizeof(EFI_SMM_LOCK_BOX_PARAMETER_SAVE)) {
+ if (TempCommBufferSize < sizeof(EFI_SMM_LOCK_BOX_PARAMETER_SAVE)) {
DEBUG ((EFI_D_ERROR, "SmmLockBox Command Buffer Size for SAVE invalid!\n"));
break;
}
SmmLockBoxSave ((EFI_SMM_LOCK_BOX_PARAMETER_SAVE *)(UINTN)LockBoxParameterHeader);
break;
case EFI_SMM_LOCK_BOX_COMMAND_UPDATE:
- if (*CommBufferSize < sizeof(EFI_SMM_LOCK_BOX_PARAMETER_UPDATE)) {
+ if (TempCommBufferSize < sizeof(EFI_SMM_LOCK_BOX_PARAMETER_UPDATE)) {
DEBUG ((EFI_D_ERROR, "SmmLockBox Command Buffer Size for UPDATE invalid!\n"));
break;
}
SmmLockBoxUpdate ((EFI_SMM_LOCK_BOX_PARAMETER_UPDATE *)(UINTN)LockBoxParameterHeader);
break;
case EFI_SMM_LOCK_BOX_COMMAND_RESTORE:
- if (*CommBufferSize < sizeof(EFI_SMM_LOCK_BOX_PARAMETER_RESTORE)) {
+ if (TempCommBufferSize < sizeof(EFI_SMM_LOCK_BOX_PARAMETER_RESTORE)) {
DEBUG ((EFI_D_ERROR, "SmmLockBox Command Buffer Size for RESTORE invalid!\n"));
break;
}
SmmLockBoxRestore ((EFI_SMM_LOCK_BOX_PARAMETER_RESTORE *)(UINTN)LockBoxParameterHeader);
break;
case EFI_SMM_LOCK_BOX_COMMAND_SET_ATTRIBUTES:
- if (*CommBufferSize < sizeof(EFI_SMM_LOCK_BOX_PARAMETER_SET_ATTRIBUTES)) {
+ if (TempCommBufferSize < sizeof(EFI_SMM_LOCK_BOX_PARAMETER_SET_ATTRIBUTES)) {
DEBUG ((EFI_D_ERROR, "SmmLockBox Command Buffer Size for SET_ATTRIBUTES invalid!\n"));
break;
}
SmmLockBoxSetAttributes ((EFI_SMM_LOCK_BOX_PARAMETER_SET_ATTRIBUTES *)(UINTN)LockBoxParameterHeader);
break;
case EFI_SMM_LOCK_BOX_COMMAND_RESTORE_ALL_IN_PLACE:
- if (*CommBufferSize < sizeof(EFI_SMM_LOCK_BOX_PARAMETER_RESTORE_ALL_IN_PLACE)) {
+ if (TempCommBufferSize < sizeof(EFI_SMM_LOCK_BOX_PARAMETER_RESTORE_ALL_IN_PLACE)) {
DEBUG ((EFI_D_ERROR, "SmmLockBox Command Buffer Size for RESTORE_ALL_IN_PLACE invalid!\n"));
break;
}
diff --git a/MdeModulePkg/Universal/Network/IScsiDxe/IScsiProto.c b/MdeModulePkg/Universal/Network/IScsiDxe/IScsiProto.c
index b1f250b55e..aff036bb7a 100644
--- a/MdeModulePkg/Universal/Network/IScsiDxe/IScsiProto.c
+++ b/MdeModulePkg/Universal/Network/IScsiDxe/IScsiProto.c
@@ -1,7 +1,7 @@
/** @file
The implementation of iSCSI protocol based on RFC3720.
-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
@@ -742,7 +742,7 @@ IScsiProcessLoginRsp (
NetbufQueAppend (&Conn->RspQue, Pdu);
Conn->PartialRspRcvd = Continue;
- if (Continue) {
+ if ((!Transit) || Continue) {
//
// It's a partial response, have to wait for another or more Request/Response
// conversations to get the full response.
diff --git a/MdeModulePkg/Universal/Network/Ip4ConfigDxe/Ip4ConfigDriver.c b/MdeModulePkg/Universal/Network/Ip4ConfigDxe/Ip4ConfigDriver.c
index 2a9fcb94e5..790e44be4c 100644
--- a/MdeModulePkg/Universal/Network/Ip4ConfigDxe/Ip4ConfigDriver.c
+++ b/MdeModulePkg/Universal/Network/Ip4ConfigDxe/Ip4ConfigDriver.c
@@ -1,7 +1,7 @@
/** @file
The driver binding for IP4 CONFIG protocol.
-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<BR>
@@ -71,7 +71,7 @@ IP4_CONFIG_INSTANCE mIp4ConfigTemplate = {
NULL,
NULL,
NULL,
- EFI_NOT_READY,
+ 0,
{
0,
0,
@@ -109,6 +109,8 @@ Ip4ConfigDriverEntryPoint (
IN EFI_SYSTEM_TABLE *SystemTable
)
{
+ mIp4ConfigTemplate.Result = EFI_NOT_READY;
+
return EfiLibInstallDriverBindingComponentName2 (
ImageHandle,
SystemTable,
diff --git a/MdeModulePkg/Universal/Network/Ip4Dxe/Ip4Driver.c b/MdeModulePkg/Universal/Network/Ip4Dxe/Ip4Driver.c
index 4a3d342711..73b4e246e0 100644
--- a/MdeModulePkg/Universal/Network/Ip4Dxe/Ip4Driver.c
+++ b/MdeModulePkg/Universal/Network/Ip4Dxe/Ip4Driver.c
@@ -1,7 +1,7 @@
/** @file
The driver binding and service binding protocol for IP4 driver.
-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
@@ -572,6 +572,8 @@ Ip4DriverBindingStop (
INTN State;
LIST_ENTRY *List;
IP4_DESTROY_CHILD_IN_HANDLE_BUF_CONTEXT Context;
+ IP4_INTERFACE *IpIf;
+ IP4_ROUTE_TABLE *RouteTable;
//
// IP4 driver opens the MNP child, ARP children or the IP4_CONFIG protocol
@@ -681,6 +683,35 @@ Ip4DriverBindingStop (
&Context,
NULL
);
+ } else if (IpSb->DefaultInterface->ArpHandle == ControllerHandle) {
+ //
+ // The ARP protocol for the default interface is being uninstalled and all
+ // its IP child handles should have been destroyed before. So, release the
+ // default interface and route table, create a new one and mark it as not started.
+ //
+ Ip4CancelReceive (IpSb->DefaultInterface);
+ Ip4FreeInterface (IpSb->DefaultInterface, NULL);
+ Ip4FreeRouteTable (IpSb->DefaultRouteTable);
+
+ IpIf = Ip4CreateInterface (IpSb->Mnp, IpSb->Controller, IpSb->Image);
+ if (IpIf == NULL) {
+ goto ON_ERROR;
+ }
+ RouteTable = Ip4CreateRouteTable ();
+ if (RouteTable == NULL) {
+ Ip4FreeInterface (IpIf, NULL);
+ goto ON_ERROR;;
+ }
+
+ IpSb->DefaultInterface = IpIf;
+ InsertHeadList (&IpSb->Interfaces, &IpIf->Link);
+ IpSb->DefaultRouteTable = RouteTable;
+ Ip4ReceiveFrame (IpIf, NULL, Ip4AccpetFrame, IpSb);
+
+ if (IpSb->Ip4Config != NULL && IpSb->State != IP4_SERVICE_DESTROY) {
+ IpSb->Ip4Config->Stop (IpSb->Ip4Config);
+ }
+ IpSb->State = IP4_SERVICE_UNSTARTED;
} else if (IsListEmpty (&IpSb->Children)) {
State = IpSb->State;
IpSb->State = IP4_SERVICE_DESTROY;
diff --git a/MdeModulePkg/Universal/Network/Ip4Dxe/Ip4If.c b/MdeModulePkg/Universal/Network/Ip4Dxe/Ip4If.c
index 6711636333..e4ab17a37e 100644
--- a/MdeModulePkg/Universal/Network/Ip4Dxe/Ip4If.c
+++ b/MdeModulePkg/Universal/Network/Ip4Dxe/Ip4If.c
@@ -740,11 +740,24 @@ Ip4FreeInterface (
//
Ip4CancelFrames (Interface, EFI_ABORTED, Ip4CancelInstanceFrame, IpInstance);
+ if (--Interface->RefCnt > 0) {
+ return EFI_SUCCESS;
+ }
+
//
- // Destroy the ARP instance if this is the last IP instance that
- // has the address.
+ // Destroy the interface if this is the last IP instance that
+ // has the address. Remove all the system transmitted packets
+ // from this interface, cancel the receive request if there is
+ // one, and destroy the ARP requests.
//
- if (Interface->Arp != NULL && IsListEmpty (&Interface->IpInstances)) {
+ Ip4CancelFrames (Interface, EFI_ABORTED, Ip4CancelInstanceFrame, NULL);
+ Ip4CancelReceive (Interface);
+
+ ASSERT (IsListEmpty (&Interface->IpInstances));
+ ASSERT (IsListEmpty (&Interface->ArpQues));
+ ASSERT (IsListEmpty (&Interface->SentFrames));
+
+ if (Interface->Arp != NULL) {
gBS->CloseProtocol (
Interface->ArpHandle,
&gEfiArpProtocolGuid,
@@ -758,25 +771,8 @@ Ip4FreeInterface (
&gEfiArpServiceBindingProtocolGuid,
Interface->ArpHandle
);
- Interface->Arp = NULL;
- }
-
- if (--Interface->RefCnt > 0) {
- return EFI_SUCCESS;
}
- //
- // Destroy the interface if it is not referenced by any IP instance (for common Interface)
- // or the IP service (for the DefaultInterface). Remove all the system transmitted packets
- // from this interface, cancel the receive request if there is one.
- //
- Ip4CancelFrames (Interface, EFI_ABORTED, Ip4CancelInstanceFrame, NULL);
- Ip4CancelReceive (Interface);
-
- ASSERT (IsListEmpty (&Interface->IpInstances));
- ASSERT (IsListEmpty (&Interface->ArpQues));
- ASSERT (IsListEmpty (&Interface->SentFrames));
-
RemoveEntryList (&Interface->Link);
FreePool (Interface);
diff --git a/MdeModulePkg/Universal/Network/Tcp4Dxe/Tcp4Driver.c b/MdeModulePkg/Universal/Network/Tcp4Dxe/Tcp4Driver.c
index 76eac722cb..29a0cf76c2 100644
--- a/MdeModulePkg/Universal/Network/Tcp4Dxe/Tcp4Driver.c
+++ b/MdeModulePkg/Universal/Network/Tcp4Dxe/Tcp4Driver.c
@@ -1,7 +1,7 @@
/** @file
Tcp driver function.
-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
@@ -607,7 +607,7 @@ Tcp4CreateSocketCallback (
(VOID **) &This->ParentDevicePath,
TcpServiceData->DriverBindingHandle,
This->SockHandle,
- EFI_OPEN_PROTOCOL_BY_CHILD_CONTROLLER
+ EFI_OPEN_PROTOCOL_GET_PROTOCOL
);
if (EFI_ERROR (Status)) {
gBS->CloseProtocol (
@@ -649,16 +649,6 @@ Tcp4DestroySocketCallback (
RemoveEntryList (&This->Link);
//
- // Close the device path protocol
- //
- gBS->CloseProtocol (
- TcpServiceData->ControllerHandle,
- &gEfiDevicePathProtocolGuid,
- TcpServiceData->DriverBindingHandle,
- This->SockHandle
- );
-
- //
// Close the Ip4 protocol.
//
gBS->CloseProtocol (
diff --git a/MdeModulePkg/Universal/Network/UefiPxeBcDxe/PxeBcDhcp.c b/MdeModulePkg/Universal/Network/UefiPxeBcDxe/PxeBcDhcp.c
index fa3594d36b..8be753151c 100644
--- a/MdeModulePkg/Universal/Network/UefiPxeBcDxe/PxeBcDhcp.c
+++ b/MdeModulePkg/Universal/Network/UefiPxeBcDxe/PxeBcDhcp.c
@@ -1,6 +1,7 @@
/** @file
Support for PxeBc dhcp functions.
+Copyright (c) 2013, Red Hat, Inc.
Copyright (c) 2007 - 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
@@ -1536,6 +1537,19 @@ PxeBcSelectBootPrompt (
}
VendorOpt = &Packet->PxeVendorOption;
+ //
+ // According to the PXE specification 2.1, Table 2-1 PXE DHCP Options (Full
+ // List), we must not consider a boot prompt or boot menu if all of the
+ // following hold:
+ // - the PXE_DISCOVERY_CONTROL PXE tag is present inside the Vendor Options
+ // (=43) DHCP tag, and
+ // - the PXE_DISCOVERY_CONTROL PXE tag has bit 3 set, and
+ // - a boot file name has been presented with DHCP option 67.
+ //
+ if (IS_DISABLE_PROMPT_MENU (VendorOpt->DiscoverCtrl) &&
+ Packet->Dhcp4Option[PXEBC_DHCP4_TAG_INDEX_BOOTFILE] != NULL) {
+ return EFI_ABORTED;
+ }
if (!IS_VALID_BOOT_PROMPT (VendorOpt->BitMap)) {
return EFI_SUCCESS;
diff --git a/MdeModulePkg/Universal/Network/UefiPxeBcDxe/PxeBcDhcp.h b/MdeModulePkg/Universal/Network/UefiPxeBcDxe/PxeBcDhcp.h
index 5e37228efa..b56d10d82a 100644
--- a/MdeModulePkg/Universal/Network/UefiPxeBcDxe/PxeBcDhcp.h
+++ b/MdeModulePkg/Universal/Network/UefiPxeBcDxe/PxeBcDhcp.h
@@ -1,6 +1,7 @@
/** @file
Dhcp and Discover routines for PxeBc.
+Copyright (c) 2013, Red Hat, Inc.
Copyright (c) 2007 - 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
@@ -160,7 +161,7 @@ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
#define IS_DISABLE_BCAST_DISCOVER(x) (((x) & BIT (0)) == BIT (0))
#define IS_DISABLE_MCAST_DISCOVER(x) (((x) & BIT (1)) == BIT (1))
#define IS_ENABLE_USE_SERVER_LIST(x) (((x) & BIT (2)) == BIT (2))
-#define IS_ENABLE_BOOT_FILE_NAME(x) (((x) & BIT (3)) == BIT (3))
+#define IS_DISABLE_PROMPT_MENU(x) (((x) & BIT (3)) == BIT (3))
#define SET_VENDOR_OPTION_BIT_MAP(x, y) (((x)[(y) / 32]) = (UINT32) ((x)[(y) / 32]) | BIT ((y) % 32))
diff --git a/MdeModulePkg/Universal/Network/UefiPxeBcDxe/UefiPxeBcDxe.inf b/MdeModulePkg/Universal/Network/UefiPxeBcDxe/UefiPxeBcDxe.inf
index 3ac4fb041f..423555aecc 100644
--- a/MdeModulePkg/Universal/Network/UefiPxeBcDxe/UefiPxeBcDxe.inf
+++ b/MdeModulePkg/Universal/Network/UefiPxeBcDxe/UefiPxeBcDxe.inf
@@ -1,7 +1,7 @@
## @file
# Component name for module UefiPxeBc
#
-# 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
@@ -66,9 +66,6 @@
DpcLib
PcdLib
-[Guids]
- gEfiSmbiosTableGuid # ALWAYS_CONSUMED
-
[Protocols]
gEfiArpServiceBindingProtocolGuid # PROTOCOL ALWAYS_CONSUMED
gEfiArpProtocolGuid # PROTOCOL ALWAYS_CONSUMED
diff --git a/MdeModulePkg/Universal/SetupBrowserDxe/IfrParse.c b/MdeModulePkg/Universal/SetupBrowserDxe/IfrParse.c
index cc3823f0ef..2464aebd09 100644
--- a/MdeModulePkg/Universal/SetupBrowserDxe/IfrParse.c
+++ b/MdeModulePkg/Universal/SetupBrowserDxe/IfrParse.c
@@ -18,6 +18,7 @@ UINT16 mStatementIndex;
UINT16 mExpressionOpCodeIndex;
BOOLEAN mInScopeSubtitle;
+extern LIST_ENTRY gBrowserStorageList;
/**
Initialize Statement header members.
@@ -179,6 +180,7 @@ CreateQuestion (
FORMSET_STORAGE *Storage;
NAME_VALUE_NODE *NameValueNode;
EFI_STATUS Status;
+ BOOLEAN Find;
Statement = CreateStatement (OpCodeData, FormSet, Form);
if (Statement == NULL) {
@@ -220,7 +222,7 @@ CreateQuestion (
Storage = FORMSET_STORAGE_FROM_LINK (Link);
if (Storage->VarStoreId == Statement->VarStoreId) {
- Statement->Storage = Storage;
+ Statement->Storage = Storage->BrowserStorage;
break;
}
@@ -238,19 +240,39 @@ CreateQuestion (
if (Statement->Storage->Type == EFI_HII_VARSTORE_NAME_VALUE) {
//
- // Insert to Name/Value varstore list
+ // Check whether old string node already exist.
//
- NameValueNode = AllocateZeroPool (sizeof (NAME_VALUE_NODE));
- ASSERT (NameValueNode != NULL);
- NameValueNode->Signature = NAME_VALUE_NODE_SIGNATURE;
- NameValueNode->Name = AllocateCopyPool (StrSize (Statement->VariableName), Statement->VariableName);
- ASSERT (NameValueNode->Name != NULL);
- NameValueNode->Value = AllocateZeroPool (0x10);
- ASSERT (NameValueNode->Value != NULL);
- NameValueNode->EditValue = AllocateZeroPool (0x10);
- ASSERT (NameValueNode->EditValue != NULL);
+ Find = FALSE;
+ if (!IsListEmpty(&Statement->Storage->NameValueListHead)) {
+ Link = GetFirstNode (&Statement->Storage->NameValueListHead);
+ while (!IsNull (&Statement->Storage->NameValueListHead, Link)) {
+ NameValueNode = NAME_VALUE_NODE_FROM_LINK (Link);
- InsertTailList (&Statement->Storage->NameValueListHead, &NameValueNode->Link);
+ if (StrCmp (Statement->VariableName, NameValueNode->Name) == 0) {
+ Find = TRUE;
+ break;
+ }
+
+ Link = GetNextNode (&Statement->Storage->NameValueListHead, Link);
+ }
+ }
+
+ if (!Find) {
+ //
+ // Insert to Name/Value varstore list
+ //
+ NameValueNode = AllocateZeroPool (sizeof (NAME_VALUE_NODE));
+ ASSERT (NameValueNode != NULL);
+ NameValueNode->Signature = NAME_VALUE_NODE_SIGNATURE;
+ NameValueNode->Name = AllocateCopyPool (StrSize (Statement->VariableName), Statement->VariableName);
+ ASSERT (NameValueNode->Name != NULL);
+ NameValueNode->Value = AllocateZeroPool (0x10);
+ ASSERT (NameValueNode->Value != NULL);
+ NameValueNode->EditValue = AllocateZeroPool (0x10);
+ ASSERT (NameValueNode->EditValue != NULL);
+
+ InsertTailList (&Statement->Storage->NameValueListHead, &NameValueNode->Link);
+ }
}
}
@@ -281,32 +303,6 @@ CreateExpression (
return Expression;
}
-
-/**
- Allocate a FORMSET_STORAGE data structure and insert to FormSet Storage List.
-
- @param FormSet Pointer of the current FormSet
-
- @return Pointer to a FORMSET_STORAGE data structure.
-
-**/
-FORMSET_STORAGE *
-CreateStorage (
- IN FORM_BROWSER_FORMSET *FormSet
- )
-{
- FORMSET_STORAGE *Storage;
-
- Storage = AllocateZeroPool (sizeof (FORMSET_STORAGE));
- ASSERT (Storage != NULL);
- Storage->Signature = FORMSET_STORAGE_SIGNATURE;
- InitializeListHead (&Storage->NameValueListHead);
- InsertTailList (&FormSet->StorageListHead, &Storage->Link);
-
- return Storage;
-}
-
-
/**
Create ConfigHdr string for a storage.
@@ -319,7 +315,7 @@ CreateStorage (
EFI_STATUS
InitializeConfigHdr (
IN FORM_BROWSER_FORMSET *FormSet,
- IN OUT FORMSET_STORAGE *Storage
+ IN OUT BROWSER_STORAGE *Storage
)
{
CHAR16 *Name;
@@ -341,12 +337,185 @@ InitializeConfigHdr (
return EFI_NOT_FOUND;
}
- Storage->ConfigRequest = AllocateCopyPool (StrSize (Storage->ConfigHdr), Storage->ConfigHdr);
- Storage->SpareStrLen = 0;
-
return EFI_SUCCESS;
}
+/**
+ Find the global storage link base on the input storate type, name and guid.
+
+ @param StorageType Storage type.
+ @param StorageGuid Storage guid.
+ @param StorageName Storage Name.
+
+ @return Pointer to a GLOBAL_STORAGE data structure.
+
+**/
+BROWSER_STORAGE *
+FindStorageInList (
+ IN UINT8 StorageType,
+ IN EFI_GUID *StorageGuid,
+ IN CHAR16 *StorageName
+ )
+{
+ LIST_ENTRY *Link;
+ BROWSER_STORAGE *BrowserStorage;
+
+ Link = GetFirstNode (&gBrowserStorageList);
+ while (!IsNull (&gBrowserStorageList, Link)) {
+ BrowserStorage = BROWSER_STORAGE_FROM_LINK (Link);
+
+ if ((BrowserStorage->Type == StorageType) && CompareGuid (&BrowserStorage->Guid, StorageGuid)) {
+ if (StorageType == EFI_HII_VARSTORE_NAME_VALUE) {
+ return BrowserStorage;
+ }
+
+ if (StrCmp (BrowserStorage->Name, StorageName) == 0) {
+ return BrowserStorage;
+ }
+ }
+
+ //
+ // Get Next Storage.
+ //
+ Link = GetNextNode (&gBrowserStorageList, Link);
+ }
+
+ return NULL;
+}
+
+/**
+ Intialize the Global Storage.
+
+ @param BrowserStorage Pointer to the global storage.
+ @param StorageType Storage type.
+ @param OpCodeData Binary data for this opcode.
+
+**/
+VOID
+IntializeBrowserStorage (
+ IN BROWSER_STORAGE *BrowserStorage,
+ IN UINT8 StorageType,
+ IN UINT8 *OpCodeData
+ )
+{
+ switch (StorageType) {
+ case EFI_HII_VARSTORE_BUFFER:
+ CopyMem (&BrowserStorage->Guid, &((EFI_IFR_VARSTORE *) OpCodeData)->Guid, sizeof (EFI_GUID));
+ CopyMem (&BrowserStorage->Size, &((EFI_IFR_VARSTORE *) OpCodeData)->Size, sizeof (UINT16));
+
+ BrowserStorage->Buffer = AllocateZeroPool (BrowserStorage->Size);
+ BrowserStorage->EditBuffer = AllocateZeroPool (BrowserStorage->Size);
+ break;
+
+ case EFI_HII_VARSTORE_EFI_VARIABLE:
+ case EFI_HII_VARSTORE_EFI_VARIABLE_BUFFER:
+ CopyMem (&BrowserStorage->Guid, &((EFI_IFR_VARSTORE_EFI *) OpCodeData)->Guid, sizeof (EFI_GUID));
+ CopyMem (&BrowserStorage->Attributes, &((EFI_IFR_VARSTORE_EFI *) OpCodeData)->Attributes, sizeof (UINT32));
+ CopyMem (&BrowserStorage->Size, &((EFI_IFR_VARSTORE_EFI *) OpCodeData)->Size, sizeof (UINT16));
+
+ if (StorageType == EFI_HII_VARSTORE_EFI_VARIABLE_BUFFER) {
+ BrowserStorage->Buffer = AllocateZeroPool (BrowserStorage->Size);
+ BrowserStorage->EditBuffer = AllocateZeroPool (BrowserStorage->Size);
+ }
+ break;
+
+ case EFI_HII_VARSTORE_NAME_VALUE:
+ CopyMem (&BrowserStorage->Guid, &((EFI_IFR_VARSTORE_NAME_VALUE *) OpCodeData)->Guid, sizeof (EFI_GUID));
+
+ InitializeListHead (&BrowserStorage->NameValueListHead);
+ break;
+
+ default:
+ break;
+ }
+}
+
+/**
+ Allocate a FORMSET_STORAGE data structure and insert to FormSet Storage List.
+
+ @param FormSet Pointer of the current FormSet
+ @param StorageType Storage type.
+ @param OpCodeData Binary data for this opcode.
+
+ @return Pointer to a FORMSET_STORAGE data structure.
+
+**/
+FORMSET_STORAGE *
+CreateStorage (
+ IN FORM_BROWSER_FORMSET *FormSet,
+ IN UINT8 StorageType,
+ IN UINT8 *OpCodeData
+ )
+{
+ FORMSET_STORAGE *Storage;
+ CHAR16 *UnicodeString;
+ UINT16 Index;
+ BROWSER_STORAGE *BrowserStorage;
+ EFI_GUID *StorageGuid;
+ CHAR8 *StorageName;
+
+ UnicodeString = NULL;
+ StorageName = NULL;
+ switch (StorageType) {
+ case EFI_HII_VARSTORE_BUFFER:
+ StorageGuid = (EFI_GUID *) (CHAR8*) &((EFI_IFR_VARSTORE *) OpCodeData)->Guid;
+ StorageName = (CHAR8 *) ((EFI_IFR_VARSTORE *) OpCodeData)->Name;
+ break;
+
+ case EFI_HII_VARSTORE_EFI_VARIABLE:
+ case EFI_HII_VARSTORE_EFI_VARIABLE_BUFFER:
+ StorageGuid = (EFI_GUID *) (CHAR8*) &((EFI_IFR_VARSTORE_EFI *) OpCodeData)->Guid;
+ StorageName = (CHAR8 *) ((EFI_IFR_VARSTORE_EFI *) OpCodeData)->Name;
+ break;
+
+ default:
+ ASSERT (StorageType == EFI_HII_VARSTORE_NAME_VALUE);
+ StorageGuid = &((EFI_IFR_VARSTORE_NAME_VALUE *) OpCodeData)->Guid;
+ break;
+ }
+
+ if (StorageType != EFI_HII_VARSTORE_NAME_VALUE) {
+ ASSERT (StorageName != NULL);
+
+ UnicodeString = AllocateZeroPool (AsciiStrSize (StorageName) * 2);
+ ASSERT (UnicodeString != NULL);
+ for (Index = 0; StorageName[Index] != 0; Index++) {
+ UnicodeString[Index] = (CHAR16) StorageName[Index];
+ }
+ }
+
+ Storage = AllocateZeroPool (sizeof (FORMSET_STORAGE));
+ ASSERT (Storage != NULL);
+ Storage->Signature = FORMSET_STORAGE_SIGNATURE;
+ InsertTailList (&FormSet->StorageListHead, &Storage->Link);
+
+ BrowserStorage = FindStorageInList(StorageType, StorageGuid, UnicodeString);
+ if (BrowserStorage == NULL) {
+ BrowserStorage = AllocateZeroPool (sizeof (BROWSER_STORAGE));
+ ASSERT (BrowserStorage != NULL);
+
+ BrowserStorage->Signature = BROWSER_STORAGE_SIGNATURE;
+ InsertTailList (&gBrowserStorageList, &BrowserStorage->Link);
+
+ IntializeBrowserStorage (BrowserStorage, StorageType, OpCodeData);
+ BrowserStorage->Type = StorageType;
+ if (StorageType != EFI_HII_VARSTORE_NAME_VALUE) {
+ BrowserStorage->Name = UnicodeString;
+ }
+
+ 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);
+ Storage->SpareStrLen = 0;
+
+ return Storage;
+}
/**
Initialize Request Element of a Question. <RequestElement> ::= '&'<BlockName> | '&'<Label>
@@ -366,7 +535,8 @@ InitializeRequestElement (
IN OUT FORM_BROWSER_FORM *Form
)
{
- FORMSET_STORAGE *Storage;
+ BROWSER_STORAGE *Storage;
+ FORMSET_STORAGE *FormsetStorage;
UINTN StrLen;
UINTN StringSize;
CHAR16 *NewStr;
@@ -414,26 +584,42 @@ InitializeRequestElement (
}
//
+ // Find Formset Storage for this Question
+ //
+ FormsetStorage = NULL;
+ Link = GetFirstNode (&FormSet->StorageListHead);
+ while (!IsNull (&FormSet->StorageListHead, Link)) {
+ FormsetStorage = FORMSET_STORAGE_FROM_LINK (Link);
+
+ if (FormsetStorage->VarStoreId == Question->VarStoreId) {
+ break;
+ }
+
+ Link = GetNextNode (&FormSet->StorageListHead, Link);
+ }
+ ASSERT (FormsetStorage != NULL);
+
+ //
// Append <RequestElement> to <ConfigRequest>
//
- if (StrLen > Storage->SpareStrLen) {
+ if (StrLen > FormsetStorage->SpareStrLen) {
//
// Old String buffer is not sufficient for RequestElement, allocate a new one
//
- StringSize = (Storage->ConfigRequest != NULL) ? StrSize (Storage->ConfigRequest) : sizeof (CHAR16);
+ StringSize = (FormsetStorage->ConfigRequest != NULL) ? StrSize (FormsetStorage->ConfigRequest) : sizeof (CHAR16);
NewStr = AllocateZeroPool (StringSize + CONFIG_REQUEST_STRING_INCREMENTAL * sizeof (CHAR16));
ASSERT (NewStr != NULL);
- if (Storage->ConfigRequest != NULL) {
- CopyMem (NewStr, Storage->ConfigRequest, StringSize);
- FreePool (Storage->ConfigRequest);
+ if (FormsetStorage->ConfigRequest != NULL) {
+ CopyMem (NewStr, FormsetStorage->ConfigRequest, StringSize);
+ FreePool (FormsetStorage->ConfigRequest);
}
- Storage->ConfigRequest = NewStr;
- Storage->SpareStrLen = CONFIG_REQUEST_STRING_INCREMENTAL;
+ FormsetStorage->ConfigRequest = NewStr;
+ FormsetStorage->SpareStrLen = CONFIG_REQUEST_STRING_INCREMENTAL;
}
- StrCat (Storage->ConfigRequest, RequestElement);
- Storage->ElementCount++;
- Storage->SpareStrLen -= StrLen;
+ StrCat (FormsetStorage->ConfigRequest, RequestElement);
+ FormsetStorage->ElementCount++;
+ FormsetStorage->SpareStrLen -= StrLen;
//
// Update the Config Request info saved in the form.
@@ -444,7 +630,7 @@ InitializeRequestElement (
while (!IsNull (&Form->ConfigRequestHead, Link)) {
ConfigInfo = FORM_BROWSER_CONFIG_REQUEST_FROM_LINK (Link);
- if (ConfigInfo != NULL && ConfigInfo->Storage->VarStoreId == Storage->VarStoreId) {
+ if (ConfigInfo != NULL && ConfigInfo->Storage == Storage) {
Find = TRUE;
break;
}
@@ -532,7 +718,6 @@ DestroyExpression (
FreePool (Expression);
}
-
/**
Free resources of a storage.
@@ -544,47 +729,20 @@ DestroyStorage (
IN FORMSET_STORAGE *Storage
)
{
- LIST_ENTRY *Link;
- NAME_VALUE_NODE *NameValueNode;
-
if (Storage == NULL) {
return;
}
- if (Storage->Name != NULL) {
- FreePool (Storage->Name);
- }
- if (Storage->Buffer != NULL) {
- FreePool (Storage->Buffer);
- }
- if (Storage->EditBuffer != NULL) {
- FreePool (Storage->EditBuffer);
- }
-
- while (!IsListEmpty (&Storage->NameValueListHead)) {
- Link = GetFirstNode (&Storage->NameValueListHead);
- NameValueNode = NAME_VALUE_NODE_FROM_LINK (Link);
- RemoveEntryList (&NameValueNode->Link);
-
- if (NameValueNode->Name != NULL) {
- FreePool (NameValueNode->Name);
- }
- if (NameValueNode->Value != NULL) {
- FreePool (NameValueNode->Value);
- }
- if (NameValueNode->EditValue != NULL) {
- FreePool (NameValueNode->EditValue);
- }
- FreePool (NameValueNode);
- }
-
- if (Storage->ConfigHdr != NULL) {
- FreePool (Storage->ConfigHdr);
- }
if (Storage->ConfigRequest != NULL) {
FreePool (Storage->ConfigRequest);
}
+ //
+ // Minus the reference to the global storage.
+ //
+ ASSERT (Storage->BrowserStorage->ReferenceCount > 0);
+ Storage->BrowserStorage->ReferenceCount--;
+
FreePool (Storage);
}
@@ -915,7 +1073,6 @@ ParseOpCodes (
)
{
EFI_STATUS Status;
- UINT16 Index;
FORM_BROWSER_FORM *CurrentForm;
FORM_BROWSER_STATEMENT *CurrentStatement;
EXPRESSION_OPCODE *ExpressionOpCode;
@@ -931,7 +1088,6 @@ ParseOpCodes (
QUESTION_DEFAULT *CurrentDefault;
QUESTION_OPTION *CurrentOption;
UINT8 Width;
- CHAR8 *AsciiString;
UINT16 NumberOfStatement;
UINT16 NumberOfExpression;
EFI_IMAGE_ID *ImageId;
@@ -1104,7 +1260,7 @@ ParseOpCodes (
while (!IsNull (&FormSet->StorageListHead, Link)) {
VarStorage = FORMSET_STORAGE_FROM_LINK (Link);
if (VarStorage->VarStoreId == ((EFI_IFR_GET *) OpCodeData)->VarStoreId) {
- ExpressionOpCode->VarStorage = VarStorage;
+ ExpressionOpCode->VarStorage = VarStorage->BrowserStorage;
break;
}
Link = GetNextNode (&FormSet->StorageListHead, Link);
@@ -1448,76 +1604,28 @@ ParseOpCodes (
//
// Create a buffer Storage for this FormSet
//
- Storage = CreateStorage (FormSet);
- Storage->Type = EFI_HII_VARSTORE_BUFFER;
-
+ Storage = CreateStorage (FormSet, EFI_HII_VARSTORE_BUFFER, OpCodeData);
CopyMem (&Storage->VarStoreId, &((EFI_IFR_VARSTORE *) OpCodeData)->VarStoreId, sizeof (EFI_VARSTORE_ID));
- CopyMem (&Storage->Guid, &((EFI_IFR_VARSTORE *) OpCodeData)->Guid, sizeof (EFI_GUID));
- CopyMem (&Storage->Size, &((EFI_IFR_VARSTORE *) OpCodeData)->Size, sizeof (UINT16));
-
- Storage->Buffer = AllocateZeroPool (Storage->Size);
- Storage->EditBuffer = AllocateZeroPool (Storage->Size);
-
- AsciiString = (CHAR8 *) ((EFI_IFR_VARSTORE *) OpCodeData)->Name;
- Storage->Name = AllocateZeroPool (AsciiStrSize (AsciiString) * 2);
- ASSERT (Storage->Name != NULL);
- for (Index = 0; AsciiString[Index] != 0; Index++) {
- Storage->Name[Index] = (CHAR16) AsciiString[Index];
- }
-
- //
- // Initialize <ConfigHdr>
- //
- InitializeConfigHdr (FormSet, Storage);
break;
case EFI_IFR_VARSTORE_NAME_VALUE_OP:
//
// Create a name/value Storage for this FormSet
//
- Storage = CreateStorage (FormSet);
- Storage->Type = EFI_HII_VARSTORE_NAME_VALUE;
-
+ Storage = CreateStorage (FormSet, EFI_HII_VARSTORE_NAME_VALUE, OpCodeData);
CopyMem (&Storage->VarStoreId, &((EFI_IFR_VARSTORE_NAME_VALUE *) OpCodeData)->VarStoreId, sizeof (EFI_VARSTORE_ID));
- CopyMem (&Storage->Guid, &((EFI_IFR_VARSTORE_NAME_VALUE *) OpCodeData)->Guid, sizeof (EFI_GUID));
-
- //
- // Initialize <ConfigHdr>
- //
- InitializeConfigHdr (FormSet, Storage);
break;
case EFI_IFR_VARSTORE_EFI_OP:
//
// Create a EFI variable Storage for this FormSet
//
- Storage = CreateStorage (FormSet);
-
- CopyMem (&Storage->VarStoreId, &((EFI_IFR_VARSTORE_EFI *) OpCodeData)->VarStoreId, sizeof (EFI_VARSTORE_ID));
- CopyMem (&Storage->Guid, &((EFI_IFR_VARSTORE_EFI *) OpCodeData)->Guid, sizeof (EFI_GUID));
- CopyMem (&Storage->Attributes, &((EFI_IFR_VARSTORE_EFI *) OpCodeData)->Attributes, sizeof (UINT32));
- CopyMem (&Storage->Size, &((EFI_IFR_VARSTORE_EFI *) OpCodeData)->Size, sizeof (UINT16));
-
if (OpCodeLength < sizeof (EFI_IFR_VARSTORE_EFI)) {
- Storage->Type = EFI_HII_VARSTORE_EFI_VARIABLE;
- break;
- }
-
- Storage->Type = EFI_HII_VARSTORE_EFI_VARIABLE_BUFFER;
- Storage->Buffer = AllocateZeroPool (Storage->Size);
- Storage->EditBuffer = AllocateZeroPool (Storage->Size);
-
- AsciiString = (CHAR8 *) ((EFI_IFR_VARSTORE_EFI *) OpCodeData)->Name;
- Storage->Name = AllocateZeroPool (AsciiStrSize (AsciiString) * 2);
- ASSERT (Storage->Name != NULL);
- for (Index = 0; AsciiString[Index] != 0; Index++) {
- Storage->Name[Index] = (CHAR16) AsciiString[Index];
+ Storage = CreateStorage (FormSet, EFI_HII_VARSTORE_EFI_VARIABLE, OpCodeData);
+ } else {
+ Storage = CreateStorage (FormSet, EFI_HII_VARSTORE_EFI_VARIABLE_BUFFER, OpCodeData);
}
-
- //
- // Initialize <ConfigHdr>
- //
- InitializeConfigHdr (FormSet, Storage);
+ CopyMem (&Storage->VarStoreId, &((EFI_IFR_VARSTORE_EFI *) OpCodeData)->VarStoreId, sizeof (EFI_VARSTORE_ID));
break;
//
diff --git a/MdeModulePkg/Universal/SetupBrowserDxe/InputHandler.c b/MdeModulePkg/Universal/SetupBrowserDxe/InputHandler.c
index ae783b4ae3..844590770a 100644
--- a/MdeModulePkg/Universal/SetupBrowserDxe/InputHandler.c
+++ b/MdeModulePkg/Universal/SetupBrowserDxe/InputHandler.c
@@ -1023,10 +1023,10 @@ GetSelectionInputPopUp (
for (Index = 0; Index < OptionCount; Index++) {
OneOfOption = QUESTION_OPTION_FROM_LINK (Link);
Link = GetNextNode (&Question->OptionListHead, Link);
- if ((OneOfOption->SuppressExpression == NULL) ||
- EvaluateExpressionList(OneOfOption->SuppressExpression, FALSE, NULL, NULL) == ExpressFalse) {
- RemoveEntryList (&OneOfOption->Link);
- InsertHeadList (&Question->OptionListHead, &OneOfOption->Link);
+ if ((OneOfOption->SuppressExpression != NULL) &&
+ EvaluateExpressionList(OneOfOption->SuppressExpression, FALSE, NULL, NULL) > ExpressFalse) {
+ continue;
+ } else {
PopUpMenuLines++;
}
}
@@ -1040,6 +1040,13 @@ GetSelectionInputPopUp (
Link = GetFirstNode (&Question->OptionListHead);
for (Index = 0; Index < PopUpMenuLines; Index++) {
OneOfOption = QUESTION_OPTION_FROM_LINK (Link);
+ Link = GetNextNode (&Question->OptionListHead, Link);
+
+ if (!OrderedList && (OneOfOption->SuppressExpression != NULL) &&
+ EvaluateExpressionList(OneOfOption->SuppressExpression, FALSE, NULL, NULL) > ExpressFalse) {
+ Index--;
+ continue;
+ }
StringPtr = GetToken (OneOfOption->Text, MenuOption->Handle);
if (StrLen (StringPtr) > PopUpWidth) {
@@ -1053,8 +1060,6 @@ GetSelectionInputPopUp (
//
HighlightOptionIndex = Index;
}
-
- Link = GetNextNode (&Question->OptionListHead, Link);
}
//
@@ -1123,6 +1128,13 @@ GetSelectionInputPopUp (
Link = GetFirstNode (&Question->OptionListHead);
for (Index = 0; Index < TopOptionIndex; Index++) {
Link = GetNextNode (&Question->OptionListHead, Link);
+
+ OneOfOption = QUESTION_OPTION_FROM_LINK (Link);
+ if (!OrderedList && (OneOfOption->SuppressExpression != NULL) &&
+ EvaluateExpressionList(OneOfOption->SuppressExpression, FALSE, NULL, NULL) > ExpressFalse) {
+ Index--;
+ continue;
+ }
}
//
@@ -1133,6 +1145,12 @@ GetSelectionInputPopUp (
OneOfOption = QUESTION_OPTION_FROM_LINK (Link);
Link = GetNextNode (&Question->OptionListHead, Link);
+ if (!OrderedList && (OneOfOption->SuppressExpression != NULL) &&
+ EvaluateExpressionList(OneOfOption->SuppressExpression, FALSE, NULL, NULL) > ExpressFalse) {
+ Index--;
+ continue;
+ }
+
StringPtr = GetToken (OneOfOption->Text, MenuOption->Handle);
ASSERT (StringPtr != NULL);
//
diff --git a/MdeModulePkg/Universal/SetupBrowserDxe/Setup.c b/MdeModulePkg/Universal/SetupBrowserDxe/Setup.c
index 6c019f0454..ed904161b6 100644
--- a/MdeModulePkg/Universal/SetupBrowserDxe/Setup.c
+++ b/MdeModulePkg/Universal/SetupBrowserDxe/Setup.c
@@ -38,6 +38,7 @@ UINTN gBrowserContextCount = 0;
LIST_ENTRY gBrowserContextList = INITIALIZE_LIST_HEAD_VARIABLE (gBrowserContextList);
LIST_ENTRY gBrowserFormSetList = INITIALIZE_LIST_HEAD_VARIABLE (gBrowserFormSetList);
LIST_ENTRY gBrowserHotKeyList = INITIALIZE_LIST_HEAD_VARIABLE (gBrowserHotKeyList);
+LIST_ENTRY gBrowserStorageList = INITIALIZE_LIST_HEAD_VARIABLE (gBrowserStorageList);
BANNER_DATA *gBannerData;
EFI_HII_HANDLE gFrontPageHandle;
@@ -366,6 +367,7 @@ SendForm (
// If no data is changed, don't need to save current FormSet into the maintain list.
//
if (!IsNvUpdateRequired (gOldFormSet)) {
+ CleanBrowserStorage(gOldFormSet);
RemoveEntryList (&gOldFormSet->Link);
DestroyFormSet (gOldFormSet);
}
@@ -475,9 +477,9 @@ BrowserCallback (
Storage = FORMSET_STORAGE_FROM_LINK (Link);
Link = GetNextNode (&FormSet->StorageListHead, Link);
- if (CompareGuid (&Storage->Guid, (EFI_GUID *) VariableGuid)) {
- if (Storage->Type == EFI_HII_VARSTORE_BUFFER ||
- Storage->Type == EFI_HII_VARSTORE_EFI_VARIABLE_BUFFER) {
+ if (CompareGuid (&Storage->BrowserStorage->Guid, (EFI_GUID *) VariableGuid)) {
+ if (Storage->BrowserStorage->Type == EFI_HII_VARSTORE_BUFFER ||
+ Storage->BrowserStorage->Type == EFI_HII_VARSTORE_EFI_VARIABLE_BUFFER) {
//
// Buffer storage require both GUID and Name
//
@@ -485,7 +487,7 @@ BrowserCallback (
return EFI_NOT_FOUND;
}
- if (StrCmp (Storage->Name, (CHAR16 *) VariableName) != 0) {
+ if (StrCmp (Storage->BrowserStorage->Name, (CHAR16 *) VariableName) != 0) {
continue;
}
}
@@ -515,7 +517,7 @@ BrowserCallback (
//
// Generate <ConfigResp>
//
- Status = StorageToConfigResp (Storage, &ConfigResp, FALSE);
+ Status = StorageToConfigResp (Storage->BrowserStorage, &ConfigResp, Storage->ConfigRequest);
if (EFI_ERROR (Status)) {
return Status;
}
@@ -523,7 +525,7 @@ BrowserCallback (
//
// Skip <ConfigHdr> and '&' to point to <ConfigBody>
//
- StrPtr = ConfigResp + StrLen (Storage->ConfigHdr) + 1;
+ StrPtr = ConfigResp + StrLen (Storage->BrowserStorage->ConfigHdr) + 1;
BufferSize = StrSize (StrPtr);
if (*ResultsDataSize < BufferSize) {
@@ -542,18 +544,18 @@ BrowserCallback (
// Prepare <ConfigResp>
//
TmpSize = StrLen (ResultsData);
- BufferSize = (TmpSize + StrLen (Storage->ConfigHdr) + 2) * sizeof (CHAR16);
+ BufferSize = (TmpSize + StrLen (Storage->BrowserStorage->ConfigHdr) + 2) * sizeof (CHAR16);
ConfigResp = AllocateZeroPool (BufferSize);
ASSERT (ConfigResp != NULL);
- StrCpy (ConfigResp, Storage->ConfigHdr);
+ StrCpy (ConfigResp, Storage->BrowserStorage->ConfigHdr);
StrCat (ConfigResp, L"&");
StrCat (ConfigResp, ResultsData);
//
// Update Browser uncommited data
//
- Status = ConfigRespToStorage (Storage, ConfigResp);
+ Status = ConfigRespToStorage (Storage->BrowserStorage, ConfigResp);
if (EFI_ERROR (Status)) {
return Status;
}
@@ -826,7 +828,7 @@ NewStringCat (
**/
VOID
SynchronizeStorage (
- IN FORMSET_STORAGE *Storage,
+ IN BROWSER_STORAGE *Storage,
IN BOOLEAN SyncOrRestore
)
{
@@ -879,7 +881,7 @@ SynchronizeStorage (
**/
EFI_STATUS
GetValueByName (
- IN FORMSET_STORAGE *Storage,
+ IN BROWSER_STORAGE *Storage,
IN CHAR16 *Name,
IN OUT CHAR16 **Value,
IN GET_SET_QUESTION_VALUE_WITH GetValueFrom
@@ -928,7 +930,7 @@ GetValueByName (
**/
EFI_STATUS
SetValueByName (
- IN FORMSET_STORAGE *Storage,
+ IN BROWSER_STORAGE *Storage,
IN CHAR16 *Name,
IN CHAR16 *Value,
IN GET_SET_QUESTION_VALUE_WITH SetValueTo
@@ -975,9 +977,9 @@ SetValueByName (
/**
Convert setting of Buffer Storage or NameValue Storage to <ConfigResp>.
- @param Buffer The Storage to be conveted.
+ @param Storage The Storage to be conveted.
@param ConfigResp The returned <ConfigResp>.
- @param SingleForm Whether update data for single form or formset level.
+ @param ConfigRequest The ConfigRequest string.
@retval EFI_SUCCESS Convert success.
@retval EFI_INVALID_PARAMETER Incorrect storage type.
@@ -985,28 +987,17 @@ SetValueByName (
**/
EFI_STATUS
StorageToConfigResp (
- IN VOID *Buffer,
+ IN BROWSER_STORAGE *Storage,
IN CHAR16 **ConfigResp,
- IN BOOLEAN SingleForm
+ IN CHAR16 *ConfigRequest
)
{
- EFI_STATUS Status;
- EFI_STRING Progress;
+ EFI_STATUS Status;
+ EFI_STRING Progress;
LIST_ENTRY *Link;
NAME_VALUE_NODE *Node;
- CHAR16 *ConfigRequest;
- FORMSET_STORAGE *Storage;
- FORM_BROWSER_CONFIG_REQUEST *ConfigInfo;
Status = EFI_SUCCESS;
- if (SingleForm) {
- ConfigInfo = (FORM_BROWSER_CONFIG_REQUEST *) Buffer;
- Storage = ConfigInfo->Storage;
- ConfigRequest = ConfigInfo->ConfigRequest;
- } else {
- Storage = (FORMSET_STORAGE *) Buffer;
- ConfigRequest = Storage->ConfigRequest;
- }
switch (Storage->Type) {
case EFI_HII_VARSTORE_BUFFER:
@@ -1061,7 +1052,7 @@ StorageToConfigResp (
**/
EFI_STATUS
ConfigRespToStorage (
- IN FORMSET_STORAGE *Storage,
+ IN BROWSER_STORAGE *Storage,
IN CHAR16 *ConfigResp
)
{
@@ -1153,7 +1144,7 @@ GetQuestionValue (
UINT8 *Dst;
UINTN StorageWidth;
EFI_TIME EfiTime;
- FORMSET_STORAGE *Storage;
+ BROWSER_STORAGE *Storage;
EFI_IFR_TYPE_VALUE *QuestionValue;
CHAR16 *ConfigRequest;
CHAR16 *Progress;
@@ -1578,7 +1569,7 @@ SetQuestionValue (
EFI_TIME EfiTime;
UINTN BufferLen;
UINTN StorageWidth;
- FORMSET_STORAGE *Storage;
+ BROWSER_STORAGE *Storage;
EFI_IFR_TYPE_VALUE *QuestionValue;
CHAR16 *ConfigResp;
CHAR16 *Progress;
@@ -2225,6 +2216,7 @@ ValidateFormSet (
}
if (!Find) {
+ CleanBrowserStorage(FormSet);
RemoveEntryList (&FormSet->Link);
DestroyFormSet (FormSet);
}
@@ -2304,7 +2296,7 @@ DiscardForm (
Storage = FORMSET_STORAGE_FROM_LINK (Link);
Link = GetNextNode (&FormSet->StorageListHead, Link);
- if (Storage->Type == EFI_HII_VARSTORE_EFI_VARIABLE) {
+ if (Storage->BrowserStorage->Type == EFI_HII_VARSTORE_EFI_VARIABLE) {
continue;
}
@@ -2315,7 +2307,7 @@ DiscardForm (
continue;
}
- SynchronizeStorage(Storage, FALSE);
+ SynchronizeStorage(Storage->BrowserStorage, FALSE);
}
Link = GetFirstNode (&FormSet->FormListHead);
@@ -2350,6 +2342,7 @@ DiscardForm (
//
// Remove maintain backup list after discard except for the current using FormSet.
//
+ CleanBrowserStorage(LocalFormSet);
RemoveEntryList (&LocalFormSet->Link);
DestroyFormSet (LocalFormSet);
}
@@ -2381,7 +2374,8 @@ SubmitForm (
LIST_ENTRY *Link;
EFI_STRING ConfigResp;
EFI_STRING Progress;
- FORMSET_STORAGE *Storage;
+ BROWSER_STORAGE *Storage;
+ FORMSET_STORAGE *FormSetStorage;
UINTN BufferSize;
UINT8 *TmpBuf;
FORM_BROWSER_FORMSET *LocalFormSet;
@@ -2429,7 +2423,7 @@ SubmitForm (
//
// 1. Prepare <ConfigResp>
//
- Status = StorageToConfigResp (ConfigInfo, &ConfigResp, TRUE);
+ Status = StorageToConfigResp (ConfigInfo->Storage, &ConfigResp, ConfigInfo->ConfigRequest);
if (EFI_ERROR (Status)) {
return Status;
}
@@ -2518,7 +2512,8 @@ SubmitForm (
//
Link = GetFirstNode (&FormSet->StorageListHead);
while (!IsNull (&FormSet->StorageListHead, Link)) {
- Storage = FORMSET_STORAGE_FROM_LINK (Link);
+ FormSetStorage = (FORMSET_STORAGE_FROM_LINK (Link));
+ Storage = FormSetStorage->BrowserStorage;
Link = GetNextNode (&FormSet->StorageListHead, Link);
if (Storage->Type == EFI_HII_VARSTORE_EFI_VARIABLE) {
@@ -2528,14 +2523,14 @@ SubmitForm (
//
// Skip if there is no RequestElement
//
- if (Storage->ElementCount == 0) {
+ if (FormSetStorage->ElementCount == 0) {
continue;
}
//
// 1. Prepare <ConfigResp>
//
- Status = StorageToConfigResp (Storage, &ConfigResp, FALSE);
+ Status = StorageToConfigResp (Storage, &ConfigResp, FormSetStorage->ConfigRequest);
if (EFI_ERROR (Status)) {
return Status;
}
@@ -2634,6 +2629,7 @@ SubmitForm (
//
// Remove maintain backup list after save except for the current using FormSet.
//
+ CleanBrowserStorage(LocalFormSet);
RemoveEntryList (&LocalFormSet->Link);
DestroyFormSet (LocalFormSet);
}
@@ -2663,7 +2659,7 @@ GetDefaultValueFromAltCfg (
BOOLEAN IsBufferStorage;
BOOLEAN IsString;
UINTN Length;
- FORMSET_STORAGE *Storage;
+ BROWSER_STORAGE *Storage;
CHAR16 *ConfigRequest;
CHAR16 *Progress;
CHAR16 *Result;
@@ -3151,7 +3147,7 @@ ExtractDefault (
IN UINT16 DefaultId,
IN BROWSER_SETTING_SCOPE SettingScope,
IN BROWSER_GET_DEFAULT_VALUE GetDefaultValueScope,
- IN FORMSET_STORAGE *Storage OPTIONAL,
+ IN BROWSER_STORAGE *Storage OPTIONAL,
IN BOOLEAN RetrieveValueFirst
)
{
@@ -3445,200 +3441,405 @@ LoadFormSetConfig (
}
/**
- Fill storage's edit copy with settings requested from Configuration Driver.
+ Remove the Request element from the Config Request.
- @param FormSet FormSet data structure.
- @param Storage Buffer Storage.
-
- @retval EFI_SUCCESS The function completed successfully.
+ @param Storage Pointer to the browser storage.
+ @param RequestElement The pointer to the Request element.
**/
-EFI_STATUS
-LoadStorage (
- IN FORM_BROWSER_FORMSET *FormSet,
- IN FORMSET_STORAGE *Storage
+VOID
+RemoveElement (
+ IN OUT BROWSER_STORAGE *Storage,
+ IN CHAR16 *RequestElement
)
{
- EFI_STATUS Status;
- EFI_STRING Progress;
- EFI_STRING Result;
- CHAR16 *StrPtr;
+ CHAR16 *NewStr;
+ CHAR16 *DestStr;
- if (Storage->Type == EFI_HII_VARSTORE_EFI_VARIABLE) {
- return EFI_SUCCESS;
- }
+ ASSERT (Storage->ConfigRequest != NULL && RequestElement != NULL);
- if (Storage->Type == EFI_HII_VARSTORE_EFI_VARIABLE_BUFFER) {
- Status = gRT->GetVariable (
- Storage->Name,
- &Storage->Guid,
- NULL,
- (UINTN*)&Storage->Size,
- Storage->EditBuffer
- );
- return Status;
- }
+ NewStr = StrStr (Storage->ConfigRequest, RequestElement);
- if (FormSet->ConfigAccess == NULL) {
- return EFI_NOT_FOUND;
+ if (NewStr == NULL) {
+ return;
}
- if (Storage->ElementCount == 0) {
+ //
+ // Remove this element from this ConfigRequest.
+ //
+ DestStr = NewStr;
+ NewStr += StrLen (RequestElement);
+ CopyMem (DestStr, NewStr, StrSize (NewStr));
+
+ Storage->SpareStrLen += StrLen (RequestElement);
+}
+
+/**
+ Adjust config request in storage, remove the request elements existed in the input ConfigRequest.
+
+ @param Storage Pointer to the browser storage.
+ @param ConfigRequest The pointer to the Request element.
+
+**/
+VOID
+RemoveConfigRequest (
+ BROWSER_STORAGE *Storage,
+ CHAR16 *ConfigRequest
+ )
+{
+ CHAR16 *RequestElement;
+ CHAR16 *NextRequestElement;
+ CHAR16 *SearchKey;
+
+ if (Storage->Type == EFI_HII_VARSTORE_NAME_VALUE) {
//
- // Skip if there is no RequestElement
+ // "&Name1&Name2" section for EFI_HII_VARSTORE_NAME_VALUE storage
//
- return EFI_SUCCESS;
+ SearchKey = L"&";
+ } else {
+ //
+ // "&OFFSET=####&WIDTH=####" section for EFI_HII_VARSTORE_BUFFER storage
+ //
+ SearchKey = L"&OFFSET";
}
//
- // Request current settings from Configuration Driver
+ // Find SearchKey storage
//
- Status = FormSet->ConfigAccess->ExtractConfig (
- FormSet->ConfigAccess,
- Storage->ConfigRequest,
- &Progress,
- &Result
- );
- if (EFI_ERROR (Status)) {
- return Status;
+ if (Storage->Type == EFI_HII_VARSTORE_NAME_VALUE) {
+ RequestElement = StrStr (ConfigRequest, L"PATH");
+ ASSERT (RequestElement != NULL);
+ RequestElement = StrStr (RequestElement, SearchKey);
+ } else {
+ RequestElement = StrStr (ConfigRequest, SearchKey);
+ }
+
+ while (RequestElement != NULL) {
+ //
+ // +1 to avoid find header itself.
+ //
+ NextRequestElement = StrStr (RequestElement + 1, SearchKey);
+
+ //
+ // The last Request element in configRequest string.
+ //
+ if (NextRequestElement != NULL) {
+ //
+ // Replace "&" with '\0'.
+ //
+ *NextRequestElement = L'\0';
+ }
+
+ RemoveElement (Storage, RequestElement);
+
+ if (NextRequestElement != NULL) {
+ //
+ // Restore '&' with '\0' for later used.
+ //
+ *NextRequestElement = L'&';
+ }
+
+ RequestElement = NextRequestElement;
}
//
- // Convert Result from <ConfigAltResp> to <ConfigResp>
+ // If no request element remain, just remove the ConfigRequest string.
//
- StrPtr = StrStr (Result, L"&GUID=");
- if (StrPtr != NULL) {
- *StrPtr = L'\0';
+ if (StrCmp (Storage->ConfigRequest, Storage->ConfigHdr) == 0) {
+ FreePool (Storage->ConfigRequest);
+ Storage->ConfigRequest = NULL;
+ Storage->SpareStrLen = 0;
}
-
- Status = ConfigRespToStorage (Storage, Result);
- FreePool (Result);
- return Status;
}
+/**
+ Base on the current formset info, clean the ConfigRequest string in browser storage.
+
+ @param FormSet Pointer of the FormSet
+
+**/
+VOID
+CleanBrowserStorage (
+ IN OUT FORM_BROWSER_FORMSET *FormSet
+ )
+{
+ LIST_ENTRY *Link;
+ FORMSET_STORAGE *Storage;
+
+ Link = GetFirstNode (&FormSet->StorageListHead);
+ while (!IsNull (&FormSet->StorageListHead, Link)) {
+ Storage = FORMSET_STORAGE_FROM_LINK (Link);
+ Link = GetNextNode (&FormSet->StorageListHead, Link);
+
+ if ((Storage->BrowserStorage->Type != EFI_HII_VARSTORE_BUFFER) &&
+ (Storage->BrowserStorage->Type != EFI_HII_VARSTORE_NAME_VALUE)) {
+ continue;
+ }
+
+ if (Storage->ConfigRequest == NULL || Storage->BrowserStorage->ConfigRequest == NULL) {
+ continue;
+ }
+
+ RemoveConfigRequest (Storage->BrowserStorage, Storage->ConfigRequest);
+ }
+}
/**
- Copy uncommitted data from source Storage to destination Storage.
+ Check whether current element in the ConfigReqeust string.
- @param Dst Target Storage for uncommitted data.
- @param Src Source Storage for uncommitted data.
+ @param BrowserStorage Storage which includes ConfigReqeust.
+ @param RequestElement New element need to check.
- @retval EFI_SUCCESS The function completed successfully.
- @retval EFI_INVALID_PARAMETER Source and destination Storage is not the same type.
+ @retval TRUE The Element is in the ConfigReqeust string.
+ @retval FALSE The Element not in the configReqeust String.
**/
-EFI_STATUS
-CopyStorage (
- IN OUT FORMSET_STORAGE *Dst,
- IN FORMSET_STORAGE *Src
+BOOLEAN
+ElementValidation (
+ BROWSER_STORAGE *BrowserStorage,
+ CHAR16 *RequestElement
)
{
- LIST_ENTRY *Link;
- NAME_VALUE_NODE *Node;
+ return StrStr (BrowserStorage->ConfigRequest, RequestElement) != NULL ? TRUE : FALSE;
+}
- if ((Dst->Type != Src->Type) || (Dst->Size != Src->Size)) {
- return EFI_INVALID_PARAMETER;
- }
+/**
+ Append the Request element to the Config Request.
- switch (Src->Type) {
- case EFI_HII_VARSTORE_BUFFER:
- case EFI_HII_VARSTORE_EFI_VARIABLE_BUFFER:
- CopyMem (Dst->EditBuffer, Src->EditBuffer, Src->Size);
- CopyMem (Dst->Buffer, Src->Buffer, Src->Size);
- break;
+ @param ConfigRequest Current ConfigRequest info.
+ @param SpareStrLen Current remain free buffer for config reqeust.
+ @param RequestElement New Request element.
- case EFI_HII_VARSTORE_NAME_VALUE:
- Link = GetFirstNode (&Src->NameValueListHead);
- while (!IsNull (&Src->NameValueListHead, Link)) {
- Node = NAME_VALUE_NODE_FROM_LINK (Link);
+**/
+VOID
+AppendConfigRequest (
+ IN OUT CHAR16 **ConfigRequest,
+ IN OUT UINTN *SpareStrLen,
+ IN CHAR16 *RequestElement
+ )
+{
+ CHAR16 *NewStr;
+ UINTN StringSize;
+ UINTN StrLength;
- SetValueByName (Dst, Node->Name, Node->EditValue, GetSetValueWithEditBuffer);
- SetValueByName (Dst, Node->Name, Node->Value, GetSetValueWithBuffer);
+ StrLength = StrLen (RequestElement);
- Link = GetNextNode (&Src->NameValueListHead, Link);
- }
- break;
+ //
+ // Append <RequestElement> to <ConfigRequest>
+ //
+ if (StrLength > *SpareStrLen) {
+ //
+ // Old String buffer is not sufficient for RequestElement, allocate a new one
+ //
+ StringSize = (*ConfigRequest != NULL) ? StrSize (*ConfigRequest) : sizeof (CHAR16);
+ NewStr = AllocateZeroPool (StringSize + CONFIG_REQUEST_STRING_INCREMENTAL * sizeof (CHAR16));
+ ASSERT (NewStr != NULL);
- case EFI_HII_VARSTORE_EFI_VARIABLE:
- default:
- break;
+ if (*ConfigRequest != NULL) {
+ CopyMem (NewStr, *ConfigRequest, StringSize);
+ FreePool (*ConfigRequest);
+ }
+ *ConfigRequest = NewStr;
+ *SpareStrLen = CONFIG_REQUEST_STRING_INCREMENTAL;
}
- return EFI_SUCCESS;
+ StrCat (*ConfigRequest, RequestElement);
+ *SpareStrLen -= StrLength;
}
/**
- Get old question value from the saved formset.
+ Adjust the config request info, remove the request elements which already in AllConfigRequest string.
+
+ @param Storage Form set Storage.
+ @param ConfigRequest Return the ConfigRequest info.
- @param Statement The question which need to get old question value.
- @param OldFormSet FormSet data structure saved in the list.
+ @retval TRUE Has element not covered by current used elements, need to continue to call ExtractConfig
+ @retval FALSE All elements covered by current used elements.
**/
-VOID
-GetOldQuestionValue (
- IN OUT FORM_BROWSER_STATEMENT *Statement,
- IN FORM_BROWSER_FORMSET *OldFormSet
+BOOLEAN
+ConfigRequestAdjust (
+ IN FORMSET_STORAGE *Storage,
+ OUT CHAR16 **ConfigRequest
)
{
- LIST_ENTRY *FormLink;
- LIST_ENTRY *Link;
- FORM_BROWSER_STATEMENT *Question;
- FORM_BROWSER_FORM *Form;
+ CHAR16 *RequestElement;
+ CHAR16 *NextRequestElement;
+ CHAR16 *RetBuf;
+ UINTN SpareBufLen;
+ CHAR16 *SearchKey;
+ BOOLEAN RetVal;
+
+ SpareBufLen = 0;
+ RetBuf = NULL;
+ RetVal = FALSE;
+
+ if (Storage->BrowserStorage->ConfigRequest == NULL) {
+ Storage->BrowserStorage->ConfigRequest = AllocateCopyPool (StrSize (Storage->ConfigRequest), Storage->ConfigRequest);
+ *ConfigRequest = AllocateCopyPool (StrSize (Storage->ConfigRequest), Storage->ConfigRequest);
+ return TRUE;
+ }
- FormLink = GetFirstNode (&OldFormSet->FormListHead);
- while (!IsNull (&OldFormSet->FormListHead, FormLink)) {
- Form = FORM_BROWSER_FORM_FROM_LINK (FormLink);
- FormLink = GetNextNode (&OldFormSet->FormListHead, FormLink);
+ if (Storage->BrowserStorage->Type == EFI_HII_VARSTORE_NAME_VALUE) {
+ //
+ // "&Name1&Name2" section for EFI_HII_VARSTORE_NAME_VALUE storage
+ //
+ SearchKey = L"&";
+ } else {
+ //
+ // "&OFFSET=####&WIDTH=####" section for EFI_HII_VARSTORE_BUFFER storage
+ //
+ SearchKey = L"&OFFSET";
+ }
- Link = GetFirstNode (&Form->StatementListHead);
- while (!IsNull (&Form->StatementListHead, Link)) {
- Question = FORM_BROWSER_STATEMENT_FROM_LINK (Link);
- Link = GetNextNode (&Form->StatementListHead, Link);
+ //
+ // Prepare the config header.
+ //
+ RetBuf = AllocateCopyPool(StrSize (Storage->BrowserStorage->ConfigHdr), Storage->BrowserStorage->ConfigHdr);
+ ASSERT (RetBuf != NULL);
- if (Question->QuestionId != Statement->QuestionId) {
- continue;
- }
+ //
+ // Find SearchKey storage
+ //
+ if (Storage->BrowserStorage->Type == EFI_HII_VARSTORE_NAME_VALUE) {
+ RequestElement = StrStr (Storage->ConfigRequest, L"PATH");
+ ASSERT (RequestElement != NULL);
+ RequestElement = StrStr (RequestElement, SearchKey);
+ } else {
+ RequestElement = StrStr (Storage->ConfigRequest, SearchKey);
+ }
+
+ while (RequestElement != NULL) {
+ //
+ // +1 to avoid find header itself.
+ //
+ NextRequestElement = StrStr (RequestElement + 1, SearchKey);
- CopyMem (&Statement->HiiValue, &Question->HiiValue, sizeof (EFI_HII_VALUE));
- return;
+ //
+ // The last Request element in configRequest string.
+ //
+ if (NextRequestElement != NULL) {
+ //
+ // Replace "&" with '\0'.
+ //
+ *NextRequestElement = L'\0';
}
+
+ if (!ElementValidation (Storage->BrowserStorage, RequestElement)) {
+ //
+ // Add this element to the Storage->BrowserStorage->AllRequestElement.
+ //
+ AppendConfigRequest(&Storage->BrowserStorage->ConfigRequest, &Storage->BrowserStorage->SpareStrLen, RequestElement);
+ AppendConfigRequest (&RetBuf, &SpareBufLen, RequestElement);
+ RetVal = TRUE;
+ }
+
+ if (NextRequestElement != NULL) {
+ //
+ // Restore '&' with '\0' for later used.
+ //
+ *NextRequestElement = L'&';
+ }
+
+ RequestElement = NextRequestElement;
}
+
+ if (RetVal) {
+ *ConfigRequest = RetBuf;
+ } else {
+ FreePool (RetBuf);
+ }
+
+ return RetVal;
}
/**
- Get old question value from the saved formset, all these questions not have
- storage.
+ Fill storage's edit copy with settings requested from Configuration Driver.
+
+ @param FormSet FormSet data structure.
+ @param Storage Buffer Storage.
- @param FormSet FormSet data structure which is used now.
- @param OldFormSet FormSet data structure saved in the list.
+ @retval EFI_SUCCESS The function completed successfully.
**/
-VOID
-CopyOldValueForNoStorageQst (
- IN OUT FORM_BROWSER_FORMSET *FormSet,
- IN FORM_BROWSER_FORMSET *OldFormSet
+EFI_STATUS
+LoadStorage (
+ IN FORM_BROWSER_FORMSET *FormSet,
+ IN FORMSET_STORAGE *Storage
)
{
- LIST_ENTRY *FormLink;
- LIST_ENTRY *Link;
- FORM_BROWSER_STATEMENT *Question;
- FORM_BROWSER_FORM *Form;
-
- FormLink = GetFirstNode (&FormSet->FormListHead);
- while (!IsNull (&FormSet->FormListHead, FormLink)) {
- Form = FORM_BROWSER_FORM_FROM_LINK (FormLink);
- FormLink = GetNextNode (&FormSet->FormListHead, FormLink);
+ EFI_STATUS Status;
+ EFI_STRING Progress;
+ EFI_STRING Result;
+ CHAR16 *StrPtr;
+ CHAR16 *ConfigRequest;
- Link = GetFirstNode (&Form->StatementListHead);
- while (!IsNull (&Form->StatementListHead, Link)) {
- Question = FORM_BROWSER_STATEMENT_FROM_LINK (Link);
- Link = GetNextNode (&Form->StatementListHead, Link);
+ if (Storage->BrowserStorage->Type == EFI_HII_VARSTORE_EFI_VARIABLE) {
+ return EFI_SUCCESS;
+ }
- if (Question->Storage == NULL) {
- GetOldQuestionValue (Question, OldFormSet);
- }
+ if (Storage->BrowserStorage->Type == EFI_HII_VARSTORE_EFI_VARIABLE_BUFFER) {
+ Status = EFI_SUCCESS;
+ //
+ // EFI varstore data all get from variable, so no need to get again.
+ //
+ if (Storage->BrowserStorage->ReferenceCount == 1) {
+ Status = gRT->GetVariable (
+ Storage->BrowserStorage->Name,
+ &Storage->BrowserStorage->Guid,
+ NULL,
+ (UINTN*)&Storage->BrowserStorage->Size,
+ Storage->BrowserStorage->EditBuffer
+ );
}
+ return Status;
}
+
+ if (FormSet->ConfigAccess == NULL) {
+ return EFI_NOT_FOUND;
+ }
+
+ if (Storage->ElementCount == 0) {
+ //
+ // Skip if there is no RequestElement
+ //
+ return EFI_SUCCESS;
+ }
+
+ //
+ // Adjust the ConfigRequest string, only the field not saved in BrowserStorage->AllConfig
+ // will used to call ExtractConfig.
+ //
+ if (!ConfigRequestAdjust(Storage, &ConfigRequest)) {
+ return EFI_SUCCESS;
+ }
+
+ //
+ // Request current settings from Configuration Driver
+ //
+ Status = FormSet->ConfigAccess->ExtractConfig (
+ FormSet->ConfigAccess,
+ ConfigRequest,
+ &Progress,
+ &Result
+ );
+ FreePool (ConfigRequest);
+
+ if (EFI_ERROR (Status)) {
+ return Status;
+ }
+
+ //
+ // Convert Result from <ConfigAltResp> to <ConfigResp>
+ //
+ StrPtr = StrStr (Result, L"&GUID=");
+ if (StrPtr != NULL) {
+ *StrPtr = L'\0';
+ }
+
+ Status = ConfigRespToStorage (Storage->BrowserStorage, Result);
+ FreePool (Result);
+ return Status;
}
/**
@@ -3693,17 +3894,18 @@ InitializeCurrentSetting (
}
}
+ //
+ // Storage is not found in backup formset and current global storage not has other driver used,
+ // request it from ConfigDriver
+ //
if (OldStorage == NULL) {
- //
- // Storage is not found in backup formset, request it from ConfigDriver
- //
Status = LoadStorage (FormSet, Storage);
if (EFI_ERROR (Status)) {
//
// If get last time changed value failed, extract default from IFR binary
//
- ExtractDefault (FormSet, NULL, EFI_HII_DEFAULT_CLASS_STANDARD, FormSetLevel, GetDefaultForStorage, Storage, TRUE);
+ ExtractDefault (FormSet, NULL, EFI_HII_DEFAULT_CLASS_STANDARD, FormSetLevel, GetDefaultForStorage, Storage->BrowserStorage, TRUE);
//
// ExtractDefault will set the NV flag to TRUE, so need this function to clean the flag
// in current situation.
@@ -3715,12 +3917,7 @@ InitializeCurrentSetting (
// Now Edit Buffer is filled with default values(lower priority) or current
// settings(higher priority), sychronize it to shadow Buffer
//
- SynchronizeStorage (Storage, TRUE);
- } else {
- //
- // Storage found in backup formset, use it
- //
- Status = CopyStorage (Storage, OldStorage);
+ SynchronizeStorage (Storage->BrowserStorage, TRUE);
}
Link = GetNextNode (&FormSet->StorageListHead, Link);
diff --git a/MdeModulePkg/Universal/SetupBrowserDxe/Setup.h b/MdeModulePkg/Universal/SetupBrowserDxe/Setup.h
index 8e32cb4e4a..9a0c739094 100644
--- a/MdeModulePkg/Universal/SetupBrowserDxe/Setup.h
+++ b/MdeModulePkg/Universal/SetupBrowserDxe/Setup.h
@@ -216,7 +216,7 @@ typedef struct {
#define NAME_VALUE_NODE_FROM_LINK(a) CR (a, NAME_VALUE_NODE, Link, NAME_VALUE_NODE_SIGNATURE)
-#define FORMSET_STORAGE_SIGNATURE SIGNATURE_32 ('F', 'S', 'T', 'G')
+#define BROWSER_STORAGE_SIGNATURE SIGNATURE_32 ('B', 'S', 'T', 'G')
typedef struct {
UINTN Signature;
@@ -224,7 +224,6 @@ typedef struct {
UINT8 Type; // Storage type
- UINT16 VarStoreId;
EFI_GUID Guid;
CHAR16 *Name; // For EFI_IFR_VARSTORE
@@ -238,6 +237,24 @@ typedef struct {
CHAR16 *ConfigHdr; // <ConfigHdr>
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)
+
+#define FORMSET_STORAGE_SIGNATURE SIGNATURE_32 ('F', 'S', 'T', 'G')
+
+typedef struct {
+ UINTN Signature;
+ LIST_ENTRY Link;
+
+ UINT16 VarStoreId;
+
+ BROWSER_STORAGE *BrowserStorage;
+
+ CHAR16 *ConfigRequest; // <ConfigRequest> = <ConfigHdr> + <RequestElement>
UINTN ElementCount; // Number of <RequestElement> in the <ConfigRequest>
UINTN SpareStrLen; // Spare length of ConfigRequest string buffer
} FORMSET_STORAGE;
@@ -272,7 +289,7 @@ typedef struct {
EFI_STRING_ID DevicePath; // For EFI_IFR_QUESTION_REF3_2, EFI_IFR_QUESTION_REF3_3
EFI_GUID Guid;
- FORMSET_STORAGE *VarStorage; // For EFI_IFR_SET, EFI_IFR_GET
+ BROWSER_STORAGE *VarStorage; // For EFI_IFR_SET, EFI_IFR_GET
VAR_STORE_INFO VarStoreInfo;// For EFI_IFR_SET, EFI_IFR_GET
UINT8 ValueType; // For EFI_IFR_SET, EFI_IFR_GET
UINT8 ValueWidth; // For EFI_IFR_SET, EFI_IFR_GET
@@ -372,7 +389,7 @@ typedef struct {
//
EFI_QUESTION_ID QuestionId; // The value of zero is reserved
EFI_VARSTORE_ID VarStoreId; // A value of zero indicates no variable storage
- FORMSET_STORAGE *Storage;
+ BROWSER_STORAGE *Storage;
VAR_STORE_INFO VarStoreInfo;
UINT16 StorageWidth;
UINT8 QuestionFlags;
@@ -430,7 +447,7 @@ typedef struct {
UINTN ElementCount; // Number of <RequestElement> in the <ConfigRequest>
UINTN SpareStrLen;
- FORMSET_STORAGE *Storage;
+ BROWSER_STORAGE *Storage;
} FORM_BROWSER_CONFIG_REQUEST;
#define FORM_BROWSER_CONFIG_REQUEST_FROM_LINK(a) CR (a, FORM_BROWSER_CONFIG_REQUEST, Link, FORM_BROWSER_CONFIG_REQUEST_SIGNATURE)
@@ -909,7 +926,7 @@ CreateDialog (
**/
EFI_STATUS
GetValueByName (
- IN FORMSET_STORAGE *Storage,
+ IN BROWSER_STORAGE *Storage,
IN CHAR16 *Name,
IN OUT CHAR16 **Value,
IN GET_SET_QUESTION_VALUE_WITH GetValueFrom
@@ -929,7 +946,7 @@ GetValueByName (
**/
EFI_STATUS
SetValueByName (
- IN FORMSET_STORAGE *Storage,
+ IN BROWSER_STORAGE *Storage,
IN CHAR16 *Name,
IN CHAR16 *Value,
IN GET_SET_QUESTION_VALUE_WITH SetValueTo
@@ -1111,7 +1128,7 @@ ExtractDefault (
IN UINT16 DefaultId,
IN BROWSER_SETTING_SCOPE SettingScope,
IN BROWSER_GET_DEFAULT_VALUE GetDefaultValueScope,
- IN FORMSET_STORAGE *Storage,
+ IN BROWSER_STORAGE *Storage,
IN BOOLEAN RetrieveValueFirst
);
@@ -1156,9 +1173,9 @@ LoadFormSetConfig (
/**
Convert setting of Buffer Storage or NameValue Storage to <ConfigResp>.
- @param Buffer The Storage to be conveted.
+ @param Storage The Storage to be conveted.
@param ConfigResp The returned <ConfigResp>.
- @param SingleForm Whether update data for single form or formset level.
+ @param ConfigRequest The ConfigRequest string.
@retval EFI_SUCCESS Convert success.
@retval EFI_INVALID_PARAMETER Incorrect storage type.
@@ -1166,9 +1183,9 @@ LoadFormSetConfig (
**/
EFI_STATUS
StorageToConfigResp (
- IN VOID *Buffer,
+ IN BROWSER_STORAGE *Storage,
IN CHAR16 **ConfigResp,
- IN BOOLEAN SingleForm
+ IN CHAR16 *ConfigRequest
);
/**
@@ -1183,7 +1200,7 @@ StorageToConfigResp (
**/
EFI_STATUS
ConfigRespToStorage (
- IN FORMSET_STORAGE *Storage,
+ IN BROWSER_STORAGE *Storage,
IN CHAR16 *ConfigResp
);
@@ -1527,4 +1544,15 @@ GetHotKeyFromRegisterList (
IN EFI_INPUT_KEY *KeyData
);
+/**
+ Base on the current formset info, clean the ConfigRequest string in browser storage.
+
+ @param FormSet Pointer of the FormSet
+
+**/
+VOID
+CleanBrowserStorage (
+ IN OUT FORM_BROWSER_FORMSET *FormSet
+ );
+
#endif
diff --git a/MdeModulePkg/Universal/Variable/EmuRuntimeDxe/EmuVariable.c b/MdeModulePkg/Universal/Variable/EmuRuntimeDxe/EmuVariable.c
index 84d22d8dcf..ae31e3ac59 100644
--- a/MdeModulePkg/Universal/Variable/EmuRuntimeDxe/EmuVariable.c
+++ b/MdeModulePkg/Universal/Variable/EmuRuntimeDxe/EmuVariable.c
@@ -3,7 +3,7 @@
Emulation Variable services operate on the runtime volatile memory.
The nonvolatile variable space doesn't exist.
-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
@@ -1397,14 +1397,22 @@ EmuSetVariable (
if ((Attributes & (EFI_VARIABLE_RUNTIME_ACCESS | EFI_VARIABLE_BOOTSERVICE_ACCESS)) == EFI_VARIABLE_RUNTIME_ACCESS) {
return EFI_INVALID_PARAMETER;
}
+
+
+ if ((UINTN)(~0) - DataSize < StrSize(VariableName)){
+ //
+ // Prevent whole variable size overflow
+ //
+ return EFI_INVALID_PARAMETER;
+ }
+
//
// The size of the VariableName, including the Unicode Null in bytes plus
// the DataSize is limited to maximum size of PcdGet32 (PcdMaxHardwareErrorVariableSize)
// bytes for HwErrRec, and PcdGet32 (PcdMaxVariableSize) bytes for the others.
//
if ((Attributes & EFI_VARIABLE_HARDWARE_ERROR_RECORD) == EFI_VARIABLE_HARDWARE_ERROR_RECORD) {
- if ((DataSize > PcdGet32 (PcdMaxHardwareErrorVariableSize)) ||
- (sizeof (VARIABLE_HEADER) + StrSize (VariableName) + DataSize > PcdGet32 (PcdMaxHardwareErrorVariableSize))) {
+ if (StrSize (VariableName) + DataSize > PcdGet32 (PcdMaxHardwareErrorVariableSize) - sizeof (VARIABLE_HEADER)) {
return EFI_INVALID_PARAMETER;
}
//
@@ -1418,8 +1426,7 @@ EmuSetVariable (
// The size of the VariableName, including the Unicode Null in bytes plus
// the DataSize is limited to maximum size of PcdGet32 (PcdMaxVariableSize) bytes.
//
- if ((DataSize > PcdGet32 (PcdMaxVariableSize)) ||
- (sizeof (VARIABLE_HEADER) + StrSize (VariableName) + DataSize > PcdGet32 (PcdMaxVariableSize))) {
+ if (StrSize (VariableName) + DataSize > PcdGet32 (PcdMaxVariableSize) - sizeof (VARIABLE_HEADER)) {
return EFI_INVALID_PARAMETER;
}
}
diff --git a/MdeModulePkg/Universal/Variable/RuntimeDxe/Variable.c b/MdeModulePkg/Universal/Variable/RuntimeDxe/Variable.c
index 956c1f2ae1..9f983ffc9f 100644
--- a/MdeModulePkg/Universal/Variable/RuntimeDxe/Variable.c
+++ b/MdeModulePkg/Universal/Variable/RuntimeDxe/Variable.c
@@ -21,12 +21,28 @@ VARIABLE_MODULE_GLOBAL *mVariableModuleGlobal;
///
/// Define a memory cache that improves the search performance for a variable.
///
-VARIABLE_STORE_HEADER *mNvVariableCache = NULL;
+VARIABLE_STORE_HEADER *mNvVariableCache = NULL;
///
/// The memory entry used for variable statistics data.
///
-VARIABLE_INFO_ENTRY *gVariableInfo = NULL;
+VARIABLE_INFO_ENTRY *gVariableInfo = NULL;
+
+///
+/// The list to store the variables which cannot be set after the EFI_END_OF_DXE_EVENT_GROUP_GUID
+/// or EVT_GROUP_READY_TO_BOOT event.
+///
+LIST_ENTRY mLockedVariableList = INITIALIZE_LIST_HEAD_VARIABLE (mLockedVariableList);
+
+///
+/// The flag to indicate whether the platform has left the DXE phase of execution.
+///
+BOOLEAN mEndOfDxe = FALSE;
+
+///
+/// The flag to indicate whether the variable storage locking is enabled.
+///
+BOOLEAN mEnableLocking = TRUE;
/**
@@ -1919,6 +1935,58 @@ IsHwErrRecVariable (
}
/**
+ Mark a variable that will become read-only after leaving the DXE phase of execution.
+
+ @param[in] This The VARIABLE_LOCK_PROTOCOL instance.
+ @param[in] VariableName A pointer to the variable name that will be made read-only subsequently.
+ @param[in] VendorGuid A pointer to the vendor GUID that will be made read-only subsequently.
+
+ @retval EFI_SUCCESS The variable specified by the VariableName and the VendorGuid was marked
+ as pending to be read-only.
+ @retval EFI_INVALID_PARAMETER VariableName or VendorGuid is NULL.
+ Or VariableName is an empty string.
+ @retval EFI_ACCESS_DENIED EFI_END_OF_DXE_EVENT_GROUP_GUID or EFI_EVENT_GROUP_READY_TO_BOOT has
+ already been signaled.
+ @retval EFI_OUT_OF_RESOURCES There is not enough resource to hold the lock request.
+**/
+EFI_STATUS
+EFIAPI
+VariableLockRequestToLock (
+ IN CONST EDKII_VARIABLE_LOCK_PROTOCOL *This,
+ IN CHAR16 *VariableName,
+ IN EFI_GUID *VendorGuid
+ )
+{
+ VARIABLE_ENTRY *Entry;
+
+ if (VariableName == NULL || VariableName[0] == 0 || VendorGuid == NULL) {
+ return EFI_INVALID_PARAMETER;
+ }
+
+ if (mEndOfDxe) {
+ return EFI_ACCESS_DENIED;
+ }
+
+ Entry = AllocateRuntimePool (sizeof (*Entry) + StrSize (VariableName));
+ if (Entry == NULL) {
+ return EFI_OUT_OF_RESOURCES;
+ }
+
+ DEBUG ((EFI_D_INFO, "[Variable] Lock: %g:%s\n", VendorGuid, VariableName));
+
+ AcquireLockOnlyAtBootTime(&mVariableModuleGlobal->VariableGlobal.VariableServicesLock);
+
+ Entry->Name = (CHAR16 *) (Entry + 1);
+ StrCpy (Entry->Name, VariableName);
+ CopyGuid (&Entry->Guid, VendorGuid);
+ InsertTailList (&mLockedVariableList, &Entry->Link);
+
+ ReleaseLockOnlyAtBootTime (&mVariableModuleGlobal->VariableGlobal.VariableServicesLock);
+
+ return EFI_SUCCESS;
+}
+
+/**
This code finds variable in storage blocks (Volatile or Non-Volatile).
@@ -2192,6 +2260,8 @@ VariableServiceSetVariable (
EFI_STATUS Status;
VARIABLE_HEADER *NextVariable;
EFI_PHYSICAL_ADDRESS Point;
+ LIST_ENTRY *Link;
+ VARIABLE_ENTRY *Entry;
//
// Check input parameters.
@@ -2218,14 +2288,20 @@ VariableServiceSetVariable (
return EFI_INVALID_PARAMETER;
}
+ if ((UINTN)(~0) - DataSize < StrSize(VariableName)){
+ //
+ // Prevent whole variable size overflow
+ //
+ return EFI_INVALID_PARAMETER;
+ }
+
//
// The size of the VariableName, including the Unicode Null in bytes plus
// the DataSize is limited to maximum size of PcdGet32 (PcdMaxHardwareErrorVariableSize)
// bytes for HwErrRec, and PcdGet32 (PcdMaxVariableSize) bytes for the others.
//
if ((Attributes & EFI_VARIABLE_HARDWARE_ERROR_RECORD) == EFI_VARIABLE_HARDWARE_ERROR_RECORD) {
- if ((DataSize > PcdGet32 (PcdMaxHardwareErrorVariableSize)) ||
- (sizeof (VARIABLE_HEADER) + StrSize (VariableName) + DataSize > PcdGet32 (PcdMaxHardwareErrorVariableSize))) {
+ if ( StrSize (VariableName) + DataSize > PcdGet32 (PcdMaxHardwareErrorVariableSize) - sizeof (VARIABLE_HEADER)) {
return EFI_INVALID_PARAMETER;
}
if (!IsHwErrRecVariable(VariableName, VendorGuid)) {
@@ -2236,22 +2312,11 @@ VariableServiceSetVariable (
// The size of the VariableName, including the Unicode Null in bytes plus
// the DataSize is limited to maximum size of PcdGet32 (PcdMaxVariableSize) bytes.
//
- if ((DataSize > PcdGet32 (PcdMaxVariableSize)) ||
- (sizeof (VARIABLE_HEADER) + StrSize (VariableName) + DataSize > PcdGet32 (PcdMaxVariableSize))) {
+ if (StrSize (VariableName) + DataSize > PcdGet32 (PcdMaxVariableSize) - sizeof (VARIABLE_HEADER)) {
return EFI_INVALID_PARAMETER;
}
}
- if (AtRuntime ()) {
- //
- // HwErrRecSupport Global Variable identifies the level of hardware error record persistence
- // support implemented by the platform. This variable is only modified by firmware and is read-only to the OS.
- //
- if (CompareGuid (VendorGuid, &gEfiGlobalVariableGuid) && (StrCmp (VariableName, L"HwErrRecSupport") == 0)) {
- return EFI_WRITE_PROTECTED;
- }
- }
-
AcquireLockOnlyAtBootTime(&mVariableModuleGlobal->VariableGlobal.VariableServicesLock);
//
@@ -2270,13 +2335,31 @@ VariableServiceSetVariable (
mVariableModuleGlobal->NonVolatileLastVariableOffset = (UINTN) NextVariable - (UINTN) Point;
}
+ if (mEndOfDxe && mEnableLocking) {
+ //
+ // Treat the variables listed in the forbidden variable list as read-only after leaving DXE phase.
+ //
+ for ( Link = GetFirstNode (&mLockedVariableList)
+ ; !IsNull (&mLockedVariableList, Link)
+ ; Link = GetNextNode (&mLockedVariableList, Link)
+ ) {
+ Entry = BASE_CR (Link, VARIABLE_ENTRY, Link);
+ if (CompareGuid (&Entry->Guid, VendorGuid) && (StrCmp (Entry->Name, VariableName) == 0)) {
+ Status = EFI_WRITE_PROTECTED;
+ DEBUG ((EFI_D_INFO, "[Variable]: Changing readonly variable after leaving DXE phase - %g:%s\n", VendorGuid, VariableName));
+ goto Done;
+ }
+ }
+ }
+
//
// Check whether the input variable is already existed.
//
Status = FindVariable (VariableName, VendorGuid, &Variable, &mVariableModuleGlobal->VariableGlobal, TRUE);
if (!EFI_ERROR (Status)) {
if (((Variable.CurrPtr->Attributes & EFI_VARIABLE_RUNTIME_ACCESS) == 0) && AtRuntime ()) {
- return EFI_WRITE_PROTECTED;
+ Status = EFI_WRITE_PROTECTED;
+ goto Done;
}
}
@@ -2287,6 +2370,7 @@ VariableServiceSetVariable (
Status = UpdateVariable (VariableName, VendorGuid, Data, DataSize, Attributes, &Variable);
+Done:
InterlockedDecrement (&mVariableModuleGlobal->VariableGlobal.ReentrantState);
ReleaseLockOnlyAtBootTime (&mVariableModuleGlobal->VariableGlobal.VariableServicesLock);
diff --git a/MdeModulePkg/Universal/Variable/RuntimeDxe/Variable.h b/MdeModulePkg/Universal/Variable/RuntimeDxe/Variable.h
index 8504ce05f7..b5e6edec93 100644
--- a/MdeModulePkg/Universal/Variable/RuntimeDxe/Variable.h
+++ b/MdeModulePkg/Universal/Variable/RuntimeDxe/Variable.h
@@ -22,6 +22,7 @@ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
#include <Protocol/FaultTolerantWrite.h>
#include <Protocol/FirmwareVolumeBlock.h>
#include <Protocol/Variable.h>
+#include <Protocol/VariableLock.h>
#include <Library/PcdLib.h>
#include <Library/HobLib.h>
#include <Library/UefiDriverEntryPoint.h>
@@ -97,6 +98,12 @@ typedef struct {
VOID *Data;
} VARIABLE_CACHE_ENTRY;
+typedef struct {
+ EFI_GUID Guid;
+ CHAR16 *Name;
+ LIST_ENTRY Link;
+} VARIABLE_ENTRY;
+
/**
Flush the HOB variable to flash.
@@ -456,7 +463,30 @@ VariableServiceQueryVariableInfo (
OUT UINT64 *RemainingVariableStorageSize,
OUT UINT64 *MaximumVariableSize
);
-
+
+/**
+ Mark a variable that will become read-only after leaving the DXE phase of execution.
+
+ @param[in] This The VARIABLE_LOCK_PROTOCOL instance.
+ @param[in] VariableName A pointer to the variable name that will be made read-only subsequently.
+ @param[in] VendorGuid A pointer to the vendor GUID that will be made read-only subsequently.
+
+ @retval EFI_SUCCESS The variable specified by the VariableName and the VendorGuid was marked
+ as pending to be read-only.
+ @retval EFI_INVALID_PARAMETER VariableName or VendorGuid is NULL.
+ Or VariableName is an empty string.
+ @retval EFI_ACCESS_DENIED EFI_END_OF_DXE_EVENT_GROUP_GUID or EFI_EVENT_GROUP_READY_TO_BOOT has
+ already been signaled.
+ @retval EFI_OUT_OF_RESOURCES There is not enough resource to hold the lock request.
+**/
+EFI_STATUS
+EFIAPI
+VariableLockRequestToLock (
+ IN CONST EDKII_VARIABLE_LOCK_PROTOCOL *This,
+ IN CHAR16 *VariableName,
+ IN EFI_GUID *VendorGuid
+ );
+
extern VARIABLE_MODULE_GLOBAL *mVariableModuleGlobal;
#endif
diff --git a/MdeModulePkg/Universal/Variable/RuntimeDxe/VariableDxe.c b/MdeModulePkg/Universal/Variable/RuntimeDxe/VariableDxe.c
index ba4d29ab30..3cb2c6bcf3 100644
--- a/MdeModulePkg/Universal/Variable/RuntimeDxe/VariableDxe.c
+++ b/MdeModulePkg/Universal/Variable/RuntimeDxe/VariableDxe.c
@@ -3,7 +3,7 @@
Implement all four UEFI Runtime Variable services for the nonvolatile
and volatile storage space and install variable architecture protocol.
-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
@@ -21,6 +21,8 @@ extern VARIABLE_INFO_ENTRY *gVariableInfo;
EFI_HANDLE mHandle = NULL;
EFI_EVENT mVirtualAddressChangeEvent = NULL;
EFI_EVENT mFtwRegistration = NULL;
+extern BOOLEAN mEndOfDxe;
+EDKII_VARIABLE_LOCK_PROTOCOL mVariableLock = { VariableLockRequestToLock };
/**
Return TRUE if ExitBootServices () has been called.
@@ -255,12 +257,34 @@ OnReadyToBoot (
VOID *Context
)
{
+ //
+ // Set the End Of DXE bit in case the EFI_END_OF_DXE_EVENT_GROUP_GUID event is not signaled.
+ //
+ mEndOfDxe = TRUE;
ReclaimForOS ();
if (FeaturePcdGet (PcdVariableCollectStatistics)) {
gBS->InstallConfigurationTable (&gEfiVariableGuid, gVariableInfo);
}
}
+/**
+ Notification function of EFI_END_OF_DXE_EVENT_GROUP_GUID event group.
+
+ This is a notification function registered on EFI_END_OF_DXE_EVENT_GROUP_GUID event group.
+
+ @param Event Event whose notification function is being invoked.
+ @param Context Pointer to the notification function's context.
+
+**/
+VOID
+EFIAPI
+OnEndOfDxe (
+ EFI_EVENT Event,
+ VOID *Context
+ )
+{
+ mEndOfDxe = TRUE;
+}
/**
Fault Tolerant Write protocol notification event handler.
@@ -375,11 +399,20 @@ VariableServiceInitialize (
)
{
EFI_STATUS Status;
- EFI_EVENT ReadyToBootEvent;
+ EFI_EVENT ReadyToBootEvent;
+ EFI_EVENT EndOfDxeEvent;
Status = VariableCommonInitialize ();
ASSERT_EFI_ERROR (Status);
+ Status = gBS->InstallMultipleProtocolInterfaces (
+ &mHandle,
+ &gEdkiiVariableLockProtocolGuid,
+ &mVariableLock,
+ NULL
+ );
+ ASSERT_EFI_ERROR (Status);
+
SystemTable->RuntimeServices->GetVariable = VariableServiceGetVariable;
SystemTable->RuntimeServices->GetNextVariableName = VariableServiceGetNextVariableName;
SystemTable->RuntimeServices->SetVariable = VariableServiceSetVariable;
@@ -426,6 +459,20 @@ VariableServiceInitialize (
NULL,
&ReadyToBootEvent
);
+ ASSERT_EFI_ERROR (Status);
+
+ //
+ // Register the event handling function to set the End Of DXE flag.
+ //
+ Status = gBS->CreateEventEx (
+ EVT_NOTIFY_SIGNAL,
+ TPL_NOTIFY,
+ OnEndOfDxe,
+ NULL,
+ &gEfiEndOfDxeEventGroupGuid,
+ &EndOfDxeEvent
+ );
+ ASSERT_EFI_ERROR (Status);
return EFI_SUCCESS;
}
diff --git a/MdeModulePkg/Universal/Variable/RuntimeDxe/VariableRuntimeDxe.inf b/MdeModulePkg/Universal/Variable/RuntimeDxe/VariableRuntimeDxe.inf
index 28b69c34de..8cbefefa1b 100644
--- a/MdeModulePkg/Universal/Variable/RuntimeDxe/VariableRuntimeDxe.inf
+++ b/MdeModulePkg/Universal/Variable/RuntimeDxe/VariableRuntimeDxe.inf
@@ -2,7 +2,7 @@
# Component description file for Variable module.
#
# This module installs three EFI_RUNTIME_SERVICES: SetVariable, GetVariable, GetNextVariableName.
-# 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
@@ -59,13 +59,15 @@
gEfiVariableWriteArchProtocolGuid ## ALWAYS_PRODUCES
gEfiVariableArchProtocolGuid ## ALWAYS_PRODUCES
gEfiFaultTolerantWriteProtocolGuid ## SOMETIMES_CONSUMES
+ gEdkiiVariableLockProtocolGuid ## ALWAYS_PRODUCES
[Guids]
gEfiVariableGuid ## PRODUCES ## Configuration Table Guid
gEfiGlobalVariableGuid ## PRODUCES ## Variable Guid
- gEfiEventVirtualAddressChangeGuid ## PRODUCES ## Event
+ gEfiEventVirtualAddressChangeGuid ## CONSUMES ## Event
gEfiSystemNvDataFvGuid ## CONSUMES
gEfiHardwareErrorVariableGuid ## SOMETIMES_CONSUMES
+ gEfiEndOfDxeEventGroupGuid ## CONSUMES ## Event
[Pcd]
gEfiMdeModulePkgTokenSpaceGuid.PcdFlashNvStorageVariableSize
diff --git a/MdeModulePkg/Universal/Variable/RuntimeDxe/VariableSmm.c b/MdeModulePkg/Universal/Variable/RuntimeDxe/VariableSmm.c
index 550f01a525..1ffa74e6cc 100644
--- a/MdeModulePkg/Universal/Variable/RuntimeDxe/VariableSmm.c
+++ b/MdeModulePkg/Universal/Variable/RuntimeDxe/VariableSmm.c
@@ -15,7 +15,7 @@
VariableServiceSetVariable(), VariableServiceQueryVariableInfo(), ReclaimForOS(),
SmmVariableGetStatistics() should also do validation based on its own knowledge.
-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
@@ -29,6 +29,7 @@ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
#include <Protocol/SmmFirmwareVolumeBlock.h>
#include <Protocol/SmmFaultTolerantWrite.h>
#include <Protocol/SmmAccess2.h>
+#include <Protocol/SmmEndOfDxe.h>
#include <Library/SmmServicesTableLib.h>
@@ -44,15 +45,63 @@ EFI_HANDLE mSmmVariableHandle = N
EFI_HANDLE mVariableHandle = NULL;
BOOLEAN mAtRuntime = FALSE;
EFI_GUID mZeroGuid = {0, 0, 0, {0, 0, 0, 0, 0, 0, 0, 0}};
-
+UINT8 *mVariableBufferPayload = NULL;
+UINTN mVariableBufferPayloadSize;
+extern BOOLEAN mEndOfDxe;
+extern BOOLEAN mEnableLocking;
+
+/**
+
+ This code sets variable in storage blocks (Volatile or Non-Volatile).
+
+ @param VariableName Name of Variable to be found.
+ @param VendorGuid Variable vendor GUID.
+ @param Attributes Attribute value of the variable found
+ @param DataSize Size of Data found. If size is less than the
+ data, this value contains the required size.
+ @param Data Data pointer.
+
+ @return EFI_INVALID_PARAMETER Invalid parameter.
+ @return EFI_SUCCESS Set successfully.
+ @return EFI_OUT_OF_RESOURCES Resource not enough to set variable.
+ @return EFI_NOT_FOUND Not found.
+ @return EFI_WRITE_PROTECTED Variable is read-only.
+
+**/
+EFI_STATUS
+EFIAPI
+SmmVariableSetVariable (
+ IN CHAR16 *VariableName,
+ IN EFI_GUID *VendorGuid,
+ IN UINT32 Attributes,
+ IN UINTN DataSize,
+ IN VOID *Data
+ )
+{
+ EFI_STATUS Status;
+
+ //
+ // Disable write protection when the calling SetVariable() through EFI_SMM_VARIABLE_PROTOCOL.
+ //
+ mEnableLocking = FALSE;
+ Status = VariableServiceSetVariable (
+ VariableName,
+ VendorGuid,
+ Attributes,
+ DataSize,
+ Data
+ );
+ mEnableLocking = TRUE;
+ return Status;
+}
+
EFI_SMM_VARIABLE_PROTOCOL gSmmVariable = {
VariableServiceGetVariable,
VariableServiceGetNextVariableName,
- VariableServiceSetVariable,
+ SmmVariableSetVariable,
VariableServiceQueryVariableInfo
};
-
/**
Return TRUE if ExitBootServices () has been called.
@@ -93,6 +142,32 @@ InternalIsAddressInSmram (
return FALSE;
}
+/**
+ This function check if the address refered by Buffer and Length is valid.
+
+ @param Buffer the buffer address to be checked.
+ @param Length the buffer length to be checked.
+
+ @retval TRUE this address is valid.
+ @retval FALSE this address is NOT valid.
+**/
+BOOLEAN
+InternalIsAddressValid (
+ IN UINTN Buffer,
+ IN UINTN Length
+ )
+{
+ if (Buffer > (MAX_ADDRESS - Length)) {
+ //
+ // Overflow happen
+ //
+ return FALSE;
+ }
+ if (InternalIsAddressInSmram ((EFI_PHYSICAL_ADDRESS)Buffer, (UINT64)Length)) {
+ return FALSE;
+ }
+ return TRUE;
+}
/**
Initializes a basic mutual exclusion lock.
@@ -276,6 +351,8 @@ GetFvbCountAndBuffer (
*NumberHandles = BufferSize / sizeof(EFI_HANDLE);
if (EFI_ERROR(Status)) {
*NumberHandles = 0;
+ FreePool (*Buffer);
+ *Buffer = NULL;
}
return Status;
@@ -311,7 +388,8 @@ SmmVariableGetStatistics (
UINTN NameLength;
UINTN StatisticsInfoSize;
CHAR16 *InfoName;
-
+ EFI_GUID VendorGuid;
+
ASSERT (InfoEntry != NULL);
VariableInfo = gVariableInfo;
if (VariableInfo == NULL) {
@@ -325,7 +403,9 @@ SmmVariableGetStatistics (
}
InfoName = (CHAR16 *)(InfoEntry + 1);
- if (CompareGuid (&InfoEntry->VendorGuid, &mZeroGuid)) {
+ CopyGuid (&VendorGuid, &InfoEntry->VendorGuid);
+
+ if (CompareGuid (&VendorGuid, &mZeroGuid)) {
//
// Return the first variable info
//
@@ -339,7 +419,7 @@ SmmVariableGetStatistics (
// Get the next variable info
//
while (VariableInfo != NULL) {
- if (CompareGuid (&VariableInfo->VendorGuid, &InfoEntry->VendorGuid)) {
+ if (CompareGuid (&VariableInfo->VendorGuid, &VendorGuid)) {
NameLength = StrSize (VariableInfo->Name);
if (NameLength == StrSize (InfoName)) {
if (CompareMem (VariableInfo->Name, InfoName, NameLength) == 0) {
@@ -417,7 +497,11 @@ SmmVariableHandler (
SMM_VARIABLE_COMMUNICATE_GET_NEXT_VARIABLE_NAME *GetNextVariableName;
SMM_VARIABLE_COMMUNICATE_QUERY_VARIABLE_INFO *QueryVariableInfo;
VARIABLE_INFO_ENTRY *VariableInfo;
+ SMM_VARIABLE_COMMUNICATE_LOCK_VARIABLE *VariableToLock;
UINTN InfoSize;
+ UINTN NameBufferSize;
+ UINTN CommBufferPayloadSize;
+ UINTN TempCommBufferSize;
//
// If input is invalid, stop processing this SMI
@@ -426,27 +510,59 @@ SmmVariableHandler (
return EFI_SUCCESS;
}
- if (*CommBufferSize < SMM_VARIABLE_COMMUNICATE_HEADER_SIZE) {
+ TempCommBufferSize = *CommBufferSize;
+
+ if (TempCommBufferSize < SMM_VARIABLE_COMMUNICATE_HEADER_SIZE) {
+ DEBUG ((EFI_D_ERROR, "SmmVariableHandler: SMM communication buffer size invalid!\n"));
+ return EFI_SUCCESS;
+ }
+ CommBufferPayloadSize = TempCommBufferSize - SMM_VARIABLE_COMMUNICATE_HEADER_SIZE;
+ if (CommBufferPayloadSize > mVariableBufferPayloadSize) {
+ DEBUG ((EFI_D_ERROR, "SmmVariableHandler: SMM communication buffer payload size invalid!\n"));
return EFI_SUCCESS;
}
- if (InternalIsAddressInSmram ((EFI_PHYSICAL_ADDRESS)(UINTN)CommBuffer, *CommBufferSize)) {
- DEBUG ((EFI_D_ERROR, "SMM communication buffer size is in SMRAM!\n"));
+ if (!InternalIsAddressValid ((UINTN)CommBuffer, TempCommBufferSize)) {
+ DEBUG ((EFI_D_ERROR, "SmmVariableHandler: SMM communication buffer in SMRAM or overflow!\n"));
return EFI_SUCCESS;
}
SmmVariableFunctionHeader = (SMM_VARIABLE_COMMUNICATE_HEADER *)CommBuffer;
switch (SmmVariableFunctionHeader->Function) {
case SMM_VARIABLE_FUNCTION_GET_VARIABLE:
- SmmVariableHeader = (SMM_VARIABLE_COMMUNICATE_ACCESS_VARIABLE *) SmmVariableFunctionHeader->Data;
+ if (CommBufferPayloadSize < OFFSET_OF(SMM_VARIABLE_COMMUNICATE_ACCESS_VARIABLE, Name)) {
+ DEBUG ((EFI_D_ERROR, "GetVariable: SMM communication buffer size invalid!\n"));
+ return EFI_SUCCESS;
+ }
+ //
+ // Copy the input communicate buffer payload to pre-allocated SMM variable buffer payload.
+ //
+ CopyMem (mVariableBufferPayload, SmmVariableFunctionHeader->Data, CommBufferPayloadSize);
+ SmmVariableHeader = (SMM_VARIABLE_COMMUNICATE_ACCESS_VARIABLE *) mVariableBufferPayload;
+ if (((UINTN)(~0) - SmmVariableHeader->DataSize < OFFSET_OF(SMM_VARIABLE_COMMUNICATE_ACCESS_VARIABLE, Name)) ||
+ ((UINTN)(~0) - SmmVariableHeader->NameSize < OFFSET_OF(SMM_VARIABLE_COMMUNICATE_ACCESS_VARIABLE, Name) + SmmVariableHeader->DataSize)) {
+ //
+ // Prevent InfoSize overflow happen
+ //
+ Status = EFI_ACCESS_DENIED;
+ goto EXIT;
+ }
InfoSize = OFFSET_OF(SMM_VARIABLE_COMMUNICATE_ACCESS_VARIABLE, Name)
+ SmmVariableHeader->DataSize + SmmVariableHeader->NameSize;
//
// SMRAM range check already covered before
//
- if (InfoSize > *CommBufferSize - SMM_VARIABLE_COMMUNICATE_HEADER_SIZE) {
- DEBUG ((EFI_D_ERROR, "Data size exceed communication buffer size limit!\n"));
+ if (InfoSize > CommBufferPayloadSize) {
+ DEBUG ((EFI_D_ERROR, "GetVariable: Data size exceed communication buffer size limit!\n"));
+ Status = EFI_ACCESS_DENIED;
+ goto EXIT;
+ }
+
+ if (SmmVariableHeader->NameSize < sizeof (CHAR16) || SmmVariableHeader->Name[SmmVariableHeader->NameSize/sizeof (CHAR16) - 1] != L'\0') {
+ //
+ // Make sure VariableName is A Null-terminated string.
+ //
Status = EFI_ACCESS_DENIED;
goto EXIT;
}
@@ -458,17 +574,42 @@ SmmVariableHandler (
&SmmVariableHeader->DataSize,
(UINT8 *)SmmVariableHeader->Name + SmmVariableHeader->NameSize
);
+ CopyMem (SmmVariableFunctionHeader->Data, mVariableBufferPayload, CommBufferPayloadSize);
break;
case SMM_VARIABLE_FUNCTION_GET_NEXT_VARIABLE_NAME:
- GetNextVariableName = (SMM_VARIABLE_COMMUNICATE_GET_NEXT_VARIABLE_NAME *) SmmVariableFunctionHeader->Data;
+ if (CommBufferPayloadSize < OFFSET_OF(SMM_VARIABLE_COMMUNICATE_GET_NEXT_VARIABLE_NAME, Name)) {
+ DEBUG ((EFI_D_ERROR, "GetNextVariableName: SMM communication buffer size invalid!\n"));
+ return EFI_SUCCESS;
+ }
+ //
+ // Copy the input communicate buffer payload to pre-allocated SMM variable buffer payload.
+ //
+ CopyMem (mVariableBufferPayload, SmmVariableFunctionHeader->Data, CommBufferPayloadSize);
+ GetNextVariableName = (SMM_VARIABLE_COMMUNICATE_GET_NEXT_VARIABLE_NAME *) mVariableBufferPayload;
+ if ((UINTN)(~0) - GetNextVariableName->NameSize < OFFSET_OF(SMM_VARIABLE_COMMUNICATE_GET_NEXT_VARIABLE_NAME, Name)) {
+ //
+ // Prevent InfoSize overflow happen
+ //
+ Status = EFI_ACCESS_DENIED;
+ goto EXIT;
+ }
InfoSize = OFFSET_OF(SMM_VARIABLE_COMMUNICATE_GET_NEXT_VARIABLE_NAME, Name) + GetNextVariableName->NameSize;
//
// SMRAM range check already covered before
//
- if (InfoSize > *CommBufferSize - SMM_VARIABLE_COMMUNICATE_HEADER_SIZE) {
- DEBUG ((EFI_D_ERROR, "Data size exceed communication buffer size limit!\n"));
+ if (InfoSize > CommBufferPayloadSize) {
+ DEBUG ((EFI_D_ERROR, "GetNextVariableName: Data size exceed communication buffer size limit!\n"));
+ Status = EFI_ACCESS_DENIED;
+ goto EXIT;
+ }
+
+ NameBufferSize = CommBufferPayloadSize - OFFSET_OF(SMM_VARIABLE_COMMUNICATE_GET_NEXT_VARIABLE_NAME, Name);
+ if (NameBufferSize < sizeof (CHAR16) || GetNextVariableName->Name[NameBufferSize/sizeof (CHAR16) - 1] != L'\0') {
+ //
+ // Make sure input VariableName is A Null-terminated string.
+ //
Status = EFI_ACCESS_DENIED;
goto EXIT;
}
@@ -478,10 +619,48 @@ SmmVariableHandler (
GetNextVariableName->Name,
&GetNextVariableName->Guid
);
+ CopyMem (SmmVariableFunctionHeader->Data, mVariableBufferPayload, CommBufferPayloadSize);
break;
case SMM_VARIABLE_FUNCTION_SET_VARIABLE:
- SmmVariableHeader = (SMM_VARIABLE_COMMUNICATE_ACCESS_VARIABLE *) SmmVariableFunctionHeader->Data;
+ if (CommBufferPayloadSize < OFFSET_OF(SMM_VARIABLE_COMMUNICATE_ACCESS_VARIABLE, Name)) {
+ DEBUG ((EFI_D_ERROR, "SetVariable: SMM communication buffer size invalid!\n"));
+ return EFI_SUCCESS;
+ }
+ //
+ // Copy the input communicate buffer payload to pre-allocated SMM variable buffer payload.
+ //
+ CopyMem (mVariableBufferPayload, SmmVariableFunctionHeader->Data, CommBufferPayloadSize);
+ SmmVariableHeader = (SMM_VARIABLE_COMMUNICATE_ACCESS_VARIABLE *) mVariableBufferPayload;
+ if (((UINTN)(~0) - SmmVariableHeader->DataSize < OFFSET_OF(SMM_VARIABLE_COMMUNICATE_ACCESS_VARIABLE, Name)) ||
+ ((UINTN)(~0) - SmmVariableHeader->NameSize < OFFSET_OF(SMM_VARIABLE_COMMUNICATE_ACCESS_VARIABLE, Name) + SmmVariableHeader->DataSize)) {
+ //
+ // Prevent InfoSize overflow happen
+ //
+ Status = EFI_ACCESS_DENIED;
+ goto EXIT;
+ }
+ InfoSize = OFFSET_OF(SMM_VARIABLE_COMMUNICATE_ACCESS_VARIABLE, Name)
+ + SmmVariableHeader->DataSize + SmmVariableHeader->NameSize;
+
+ //
+ // SMRAM range check already covered before
+ // Data buffer should not contain SMM range
+ //
+ if (InfoSize > CommBufferPayloadSize) {
+ DEBUG ((EFI_D_ERROR, "SetVariable: Data size exceed communication buffer size limit!\n"));
+ Status = EFI_ACCESS_DENIED;
+ goto EXIT;
+ }
+
+ if (SmmVariableHeader->NameSize < sizeof (CHAR16) || SmmVariableHeader->Name[SmmVariableHeader->NameSize/sizeof (CHAR16) - 1] != L'\0') {
+ //
+ // Make sure VariableName is A Null-terminated string.
+ //
+ Status = EFI_ACCESS_DENIED;
+ goto EXIT;
+ }
+
Status = VariableServiceSetVariable (
SmmVariableHeader->Name,
&SmmVariableHeader->Guid,
@@ -492,17 +671,11 @@ SmmVariableHandler (
break;
case SMM_VARIABLE_FUNCTION_QUERY_VARIABLE_INFO:
- QueryVariableInfo = (SMM_VARIABLE_COMMUNICATE_QUERY_VARIABLE_INFO *) SmmVariableFunctionHeader->Data;
- InfoSize = sizeof(SMM_VARIABLE_COMMUNICATE_QUERY_VARIABLE_INFO);
-
- //
- // SMRAM range check already covered before
- //
- if (InfoSize > *CommBufferSize - SMM_VARIABLE_COMMUNICATE_HEADER_SIZE) {
- DEBUG ((EFI_D_ERROR, "Data size exceed communication buffer size limit!\n"));
- Status = EFI_ACCESS_DENIED;
- goto EXIT;
+ if (CommBufferPayloadSize < sizeof (SMM_VARIABLE_COMMUNICATE_QUERY_VARIABLE_INFO)) {
+ DEBUG ((EFI_D_ERROR, "QueryVariableInfo: SMM communication buffer size invalid!\n"));
+ return EFI_SUCCESS;
}
+ QueryVariableInfo = (SMM_VARIABLE_COMMUNICATE_QUERY_VARIABLE_INFO *) SmmVariableFunctionHeader->Data;
Status = VariableServiceQueryVariableInfo (
QueryVariableInfo->Attributes,
@@ -513,6 +686,7 @@ SmmVariableHandler (
break;
case SMM_VARIABLE_FUNCTION_READY_TO_BOOT:
+ mEndOfDxe = TRUE;
if (AtRuntime()) {
Status = EFI_UNSUPPORTED;
break;
@@ -528,7 +702,7 @@ SmmVariableHandler (
case SMM_VARIABLE_FUNCTION_GET_STATISTICS:
VariableInfo = (VARIABLE_INFO_ENTRY *) SmmVariableFunctionHeader->Data;
- InfoSize = *CommBufferSize - SMM_VARIABLE_COMMUNICATE_HEADER_SIZE;
+ InfoSize = TempCommBufferSize - SMM_VARIABLE_COMMUNICATE_HEADER_SIZE;
//
// Do not need to check SmmVariableFunctionHeader->Data in SMRAM here.
@@ -536,7 +710,7 @@ SmmVariableHandler (
//
if (InternalIsAddressInSmram ((EFI_PHYSICAL_ADDRESS)(UINTN)CommBufferSize, sizeof(UINTN))) {
- DEBUG ((EFI_D_ERROR, "SMM communication buffer size is in SMRAM!\n"));
+ DEBUG ((EFI_D_ERROR, "GetStatistics: SMM communication buffer in SMRAM!\n"));
Status = EFI_ACCESS_DENIED;
goto EXIT;
}
@@ -545,6 +719,19 @@ SmmVariableHandler (
*CommBufferSize = InfoSize + SMM_VARIABLE_COMMUNICATE_HEADER_SIZE;
break;
+ case SMM_VARIABLE_FUNCTION_LOCK_VARIABLE:
+ if (mEndOfDxe) {
+ Status = EFI_ACCESS_DENIED;
+ } else {
+ VariableToLock = (SMM_VARIABLE_COMMUNICATE_LOCK_VARIABLE *) SmmVariableFunctionHeader->Data;
+ Status = VariableLockRequestToLock (
+ NULL,
+ VariableToLock->Name,
+ &VariableToLock->Guid
+ );
+ }
+ break;
+
default:
Status = EFI_UNSUPPORTED;
}
@@ -556,6 +743,28 @@ EXIT:
return EFI_SUCCESS;
}
+/**
+ SMM END_OF_DXE protocol notification event handler.
+
+ @param Protocol Points to the protocol's unique identifier
+ @param Interface Points to the interface instance
+ @param Handle The handle on which the interface was installed
+
+ @retval EFI_SUCCESS SmmEndOfDxeCallback runs successfully
+
+**/
+EFI_STATUS
+EFIAPI
+SmmEndOfDxeCallback (
+ IN CONST EFI_GUID *Protocol,
+ IN VOID *Interface,
+ IN EFI_HANDLE Handle
+ )
+{
+ DEBUG ((EFI_D_INFO, "[Variable]END_OF_DXE is signaled\n"));
+ mEndOfDxe = TRUE;
+ return EFI_SUCCESS;
+}
/**
SMM Fault Tolerant Write protocol notification event handler.
@@ -652,6 +861,7 @@ VariableServiceInitialize (
VOID *SmmFtwRegistration;
EFI_SMM_ACCESS2_PROTOCOL *SmmAccess;
UINTN Size;
+ VOID *SmmEndOfDxeRegistration;
//
// Variable initialize.
@@ -693,6 +903,16 @@ VariableServiceInitialize (
mSmramRangeCount = Size / sizeof (EFI_SMRAM_DESCRIPTOR);
+ mVariableBufferPayloadSize = MAX (PcdGet32 (PcdMaxVariableSize), PcdGet32 (PcdMaxHardwareErrorVariableSize)) +
+ OFFSET_OF (SMM_VARIABLE_COMMUNICATE_ACCESS_VARIABLE, Name) - sizeof (VARIABLE_HEADER);
+
+ Status = gSmst->SmmAllocatePool (
+ EfiRuntimeServicesData,
+ mVariableBufferPayloadSize,
+ (VOID **)&mVariableBufferPayload
+ );
+ ASSERT_EFI_ERROR (Status);
+
///
/// Register SMM variable SMI handler
///
@@ -712,6 +932,16 @@ VariableServiceInitialize (
ASSERT_EFI_ERROR (Status);
//
+ // Register EFI_SMM_END_OF_DXE_PROTOCOL_GUID notify function.
+ //
+ Status = gSmst->SmmRegisterProtocolNotify (
+ &gEfiSmmEndOfDxeProtocolGuid,
+ SmmEndOfDxeCallback,
+ &SmmEndOfDxeRegistration
+ );
+ ASSERT_EFI_ERROR (Status);
+
+ //
// Register FtwNotificationEvent () notify function.
//
Status = gSmst->SmmRegisterProtocolNotify (
diff --git a/MdeModulePkg/Universal/Variable/RuntimeDxe/VariableSmm.inf b/MdeModulePkg/Universal/Variable/RuntimeDxe/VariableSmm.inf
index e2c5d9c40d..c229805bc9 100644
--- a/MdeModulePkg/Universal/Variable/RuntimeDxe/VariableSmm.inf
+++ b/MdeModulePkg/Universal/Variable/RuntimeDxe/VariableSmm.inf
@@ -14,7 +14,7 @@
# This external input must be validated carefully to avoid security issue like
# buffer overflow, integer overflow.
#
-# 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
@@ -69,6 +69,7 @@
gEfiSmmVariableProtocolGuid ## ALWAYS_PRODUCES
gEfiSmmFaultTolerantWriteProtocolGuid ## SOMETIMES_CONSUMES
gEfiSmmAccess2ProtocolGuid ## ALWAYS_CONSUMES
+ gEfiSmmEndOfDxeProtocolGuid ## ALWAYS_CONSUMES
[Guids]
gEfiVariableGuid ## PRODUCES ## Configuration Table Guid
diff --git a/MdeModulePkg/Universal/Variable/RuntimeDxe/VariableSmmRuntimeDxe.c b/MdeModulePkg/Universal/Variable/RuntimeDxe/VariableSmmRuntimeDxe.c
index 2fca25981a..e7b10149fb 100644
--- a/MdeModulePkg/Universal/Variable/RuntimeDxe/VariableSmmRuntimeDxe.c
+++ b/MdeModulePkg/Universal/Variable/RuntimeDxe/VariableSmmRuntimeDxe.c
@@ -19,6 +19,7 @@ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
#include <Protocol/Variable.h>
#include <Protocol/SmmCommunication.h>
#include <Protocol/SmmVariable.h>
+#include <Protocol/VariableLock.h>
#include <Library/UefiBootServicesTableLib.h>
#include <Library/UefiRuntimeServicesTableLib.h>
@@ -42,7 +43,9 @@ EFI_SMM_COMMUNICATION_PROTOCOL *mSmmCommunication = NULL;
UINT8 *mVariableBuffer = NULL;
UINT8 *mVariableBufferPhysical = NULL;
UINTN mVariableBufferSize;
+UINTN mVariableBufferPayloadSize;
EFI_LOCK mVariableServicesLock;
+EDKII_VARIABLE_LOCK_PROTOCOL mVariableLock;
/**
Acquires lock only at boot time. Simply returns at runtime.
@@ -159,6 +162,73 @@ SendCommunicateBuffer (
return SmmVariableFunctionHeader->ReturnStatus;
}
+/**
+ Mark a variable that will become read-only after leaving the DXE phase of execution.
+
+ @param[in] This The VARIABLE_LOCK_PROTOCOL instance.
+ @param[in] VariableName A pointer to the variable name that will be made read-only subsequently.
+ @param[in] VendorGuid A pointer to the vendor GUID that will be made read-only subsequently.
+
+ @retval EFI_SUCCESS The variable specified by the VariableName and the VendorGuid was marked
+ as pending to be read-only.
+ @retval EFI_INVALID_PARAMETER VariableName or VendorGuid is NULL.
+ Or VariableName is an empty string.
+ @retval EFI_ACCESS_DENIED EFI_END_OF_DXE_EVENT_GROUP_GUID or EFI_EVENT_GROUP_READY_TO_BOOT has
+ already been signaled.
+ @retval EFI_OUT_OF_RESOURCES There is not enough resource to hold the lock request.
+**/
+EFI_STATUS
+EFIAPI
+VariableLockRequestToLock (
+ IN CONST EDKII_VARIABLE_LOCK_PROTOCOL *This,
+ IN CHAR16 *VariableName,
+ IN EFI_GUID *VendorGuid
+ )
+{
+ EFI_STATUS Status;
+ UINTN VariableNameSize;
+ UINTN PayloadSize;
+ SMM_VARIABLE_COMMUNICATE_LOCK_VARIABLE *VariableToLock;
+
+ if (VariableName == NULL || VariableName[0] == 0 || VendorGuid == NULL) {
+ return EFI_INVALID_PARAMETER;
+ }
+
+ VariableNameSize = StrSize (VariableName);
+
+ //
+ // If VariableName exceeds SMM payload limit. Return failure
+ //
+ if (VariableNameSize > mVariableBufferPayloadSize - OFFSET_OF (SMM_VARIABLE_COMMUNICATE_LOCK_VARIABLE, Name)) {
+ return EFI_INVALID_PARAMETER;
+ }
+
+ AcquireLockOnlyAtBootTime(&mVariableServicesLock);
+
+ //
+ // Init the communicate buffer. The buffer data size is:
+ // SMM_COMMUNICATE_HEADER_SIZE + SMM_VARIABLE_COMMUNICATE_HEADER_SIZE + PayloadSize.
+ //
+ PayloadSize = OFFSET_OF (SMM_VARIABLE_COMMUNICATE_LOCK_VARIABLE, Name) + VariableNameSize;
+ Status = InitCommunicateBuffer ((VOID **) &VariableToLock, PayloadSize, SMM_VARIABLE_FUNCTION_LOCK_VARIABLE);
+ if (EFI_ERROR (Status)) {
+ goto Done;
+ }
+ ASSERT (VariableToLock != NULL);
+
+ CopyGuid (&VariableToLock->Guid, VendorGuid);
+ VariableToLock->NameSize = VariableNameSize;
+ CopyMem (VariableToLock->Name, VariableName, VariableToLock->NameSize);
+
+ //
+ // Send data to SMM.
+ //
+ Status = SendCommunicateBuffer (PayloadSize);
+
+Done:
+ ReleaseLockOnlyAtBootTime (&mVariableServicesLock);
+ return Status;
+}
/**
This code finds variable in storage blocks (Volatile or Non-Volatile).
@@ -189,6 +259,8 @@ RuntimeServiceGetVariable (
EFI_STATUS Status;
UINTN PayloadSize;
SMM_VARIABLE_COMMUNICATE_ACCESS_VARIABLE *SmmVariableHeader;
+ UINTN TempDataSize;
+ UINTN VariableNameSize;
if (VariableName == NULL || VendorGuid == NULL || DataSize == NULL) {
return EFI_INVALID_PARAMETER;
@@ -198,13 +270,13 @@ RuntimeServiceGetVariable (
return EFI_INVALID_PARAMETER;
}
- if (*DataSize >= mVariableBufferSize) {
- //
- // DataSize may be near MAX_ADDRESS incorrectly, this can cause the computed PayLoadSize to
- // overflow to a small value and pass the check in InitCommunicateBuffer().
- // To protect against this vulnerability, return EFI_INVALID_PARAMETER if DataSize is >= mVariableBufferSize.
- // And there will be further check to ensure the total size is also not > mVariableBufferSize.
- //
+ TempDataSize = *DataSize;
+ VariableNameSize = StrSize (VariableName);
+
+ //
+ // If VariableName exceeds SMM payload limit. Return failure
+ //
+ if (VariableNameSize > mVariableBufferPayloadSize - OFFSET_OF (SMM_VARIABLE_COMMUNICATE_ACCESS_VARIABLE, Name)) {
return EFI_INVALID_PARAMETER;
}
@@ -214,7 +286,14 @@ RuntimeServiceGetVariable (
// Init the communicate buffer. The buffer data size is:
// SMM_COMMUNICATE_HEADER_SIZE + SMM_VARIABLE_COMMUNICATE_HEADER_SIZE + PayloadSize.
//
- PayloadSize = OFFSET_OF (SMM_VARIABLE_COMMUNICATE_ACCESS_VARIABLE, Name) + StrSize (VariableName) + *DataSize;
+ if (TempDataSize > mVariableBufferPayloadSize - OFFSET_OF (SMM_VARIABLE_COMMUNICATE_ACCESS_VARIABLE, Name) - VariableNameSize) {
+ //
+ // If output data buffer exceed SMM payload limit. Trim output buffer to SMM payload size
+ //
+ TempDataSize = mVariableBufferPayloadSize - OFFSET_OF (SMM_VARIABLE_COMMUNICATE_ACCESS_VARIABLE, Name) - VariableNameSize;
+ }
+ PayloadSize = OFFSET_OF (SMM_VARIABLE_COMMUNICATE_ACCESS_VARIABLE, Name) + VariableNameSize + TempDataSize;
+
Status = InitCommunicateBuffer ((VOID **)&SmmVariableHeader, PayloadSize, SMM_VARIABLE_FUNCTION_GET_VARIABLE);
if (EFI_ERROR (Status)) {
goto Done;
@@ -222,8 +301,8 @@ RuntimeServiceGetVariable (
ASSERT (SmmVariableHeader != NULL);
CopyGuid (&SmmVariableHeader->Guid, VendorGuid);
- SmmVariableHeader->DataSize = *DataSize;
- SmmVariableHeader->NameSize = StrSize (VariableName);
+ SmmVariableHeader->DataSize = TempDataSize;
+ SmmVariableHeader->NameSize = VariableNameSize;
if (Attributes == NULL) {
SmmVariableHeader->Attributes = 0;
} else {
@@ -239,7 +318,13 @@ RuntimeServiceGetVariable (
//
// Get data from SMM.
//
- *DataSize = SmmVariableHeader->DataSize;
+ if (Status == EFI_SUCCESS || Status == EFI_BUFFER_TOO_SMALL) {
+ //
+ // SMM CommBuffer DataSize can be a trimed value
+ // Only update DataSize when needed
+ //
+ *DataSize = SmmVariableHeader->DataSize;
+ }
if (Attributes != NULL) {
*Attributes = SmmVariableHeader->Attributes;
}
@@ -280,18 +365,20 @@ RuntimeServiceGetNextVariableName (
EFI_STATUS Status;
UINTN PayloadSize;
SMM_VARIABLE_COMMUNICATE_GET_NEXT_VARIABLE_NAME *SmmGetNextVariableName;
+ UINTN OutVariableNameSize;
+ UINTN InVariableNameSize;
if (VariableNameSize == NULL || VariableName == NULL || VendorGuid == NULL) {
return EFI_INVALID_PARAMETER;
}
- if (*VariableNameSize >= mVariableBufferSize) {
- //
- // VariableNameSize may be near MAX_ADDRESS incorrectly, this can cause the computed PayLoadSize to
- // overflow to a small value and pass the check in InitCommunicateBuffer().
- // To protect against this vulnerability, return EFI_INVALID_PARAMETER if VariableNameSize is >= mVariableBufferSize.
- // And there will be further check to ensure the total size is also not > mVariableBufferSize.
- //
+ OutVariableNameSize = *VariableNameSize;
+ InVariableNameSize = StrSize (VariableName);
+
+ //
+ // If input string exceeds SMM payload limit. Return failure
+ //
+ if (InVariableNameSize > mVariableBufferPayloadSize - OFFSET_OF (SMM_VARIABLE_COMMUNICATE_GET_NEXT_VARIABLE_NAME, Name)) {
return EFI_INVALID_PARAMETER;
}
@@ -301,16 +388,37 @@ RuntimeServiceGetNextVariableName (
// Init the communicate buffer. The buffer data size is:
// SMM_COMMUNICATE_HEADER_SIZE + SMM_VARIABLE_COMMUNICATE_HEADER_SIZE + PayloadSize.
//
- PayloadSize = OFFSET_OF (SMM_VARIABLE_COMMUNICATE_GET_NEXT_VARIABLE_NAME, Name) + *VariableNameSize;
+ if (OutVariableNameSize > mVariableBufferPayloadSize - OFFSET_OF (SMM_VARIABLE_COMMUNICATE_GET_NEXT_VARIABLE_NAME, Name)) {
+ //
+ // If output buffer exceed SMM payload limit. Trim output buffer to SMM payload size
+ //
+ OutVariableNameSize = mVariableBufferPayloadSize - OFFSET_OF (SMM_VARIABLE_COMMUNICATE_GET_NEXT_VARIABLE_NAME, Name);
+ }
+ //
+ // Payload should be Guid + NameSize + MAX of Input & Output buffer
+ //
+ PayloadSize = OFFSET_OF (SMM_VARIABLE_COMMUNICATE_GET_NEXT_VARIABLE_NAME, Name) + MAX (OutVariableNameSize, InVariableNameSize);
+
+
Status = InitCommunicateBuffer ((VOID **)&SmmGetNextVariableName, PayloadSize, SMM_VARIABLE_FUNCTION_GET_NEXT_VARIABLE_NAME);
if (EFI_ERROR (Status)) {
goto Done;
}
ASSERT (SmmGetNextVariableName != NULL);
- SmmGetNextVariableName->NameSize = *VariableNameSize;
+ //
+ // SMM comm buffer->NameSize is buffer size for return string
+ //
+ SmmGetNextVariableName->NameSize = OutVariableNameSize;
+
CopyGuid (&SmmGetNextVariableName->Guid, VendorGuid);
- CopyMem (SmmGetNextVariableName->Name, VariableName, *VariableNameSize);
+ //
+ // Copy whole string
+ //
+ CopyMem (SmmGetNextVariableName->Name, VariableName, InVariableNameSize);
+ if (OutVariableNameSize > InVariableNameSize) {
+ ZeroMem ((UINT8 *) SmmGetNextVariableName->Name + InVariableNameSize, OutVariableNameSize - InVariableNameSize);
+ }
//
// Send data to SMM
@@ -320,7 +428,13 @@ RuntimeServiceGetNextVariableName (
//
// Get data from SMM.
//
- *VariableNameSize = SmmGetNextVariableName->NameSize;
+ if (Status == EFI_SUCCESS || Status == EFI_BUFFER_TOO_SMALL) {
+ //
+ // SMM CommBuffer NameSize can be a trimed value
+ // Only update VariableNameSize when needed
+ //
+ *VariableNameSize = SmmGetNextVariableName->NameSize;
+ }
if (EFI_ERROR (Status)) {
goto Done;
}
@@ -363,6 +477,7 @@ RuntimeServiceSetVariable (
EFI_STATUS Status;
UINTN PayloadSize;
SMM_VARIABLE_COMMUNICATE_ACCESS_VARIABLE *SmmVariableHeader;
+ UINTN VariableNameSize;
//
// Check input parameters.
@@ -375,13 +490,13 @@ RuntimeServiceSetVariable (
return EFI_INVALID_PARAMETER;
}
- if (DataSize >= mVariableBufferSize) {
- //
- // DataSize may be near MAX_ADDRESS incorrectly, this can cause the computed PayLoadSize to
- // overflow to a small value and pass the check in InitCommunicateBuffer().
- // To protect against this vulnerability, return EFI_INVALID_PARAMETER if DataSize is >= mVariableBufferSize.
- // And there will be further check to ensure the total size is also not > mVariableBufferSize.
- //
+ VariableNameSize = StrSize (VariableName);
+
+ //
+ // If VariableName or DataSize exceeds SMM payload limit. Return failure
+ //
+ if ((VariableNameSize > mVariableBufferPayloadSize - OFFSET_OF (SMM_VARIABLE_COMMUNICATE_ACCESS_VARIABLE, Name)) ||
+ (DataSize > mVariableBufferPayloadSize - OFFSET_OF (SMM_VARIABLE_COMMUNICATE_ACCESS_VARIABLE, Name) - VariableNameSize)){
return EFI_INVALID_PARAMETER;
}
@@ -391,7 +506,7 @@ RuntimeServiceSetVariable (
// Init the communicate buffer. The buffer data size is:
// SMM_COMMUNICATE_HEADER_SIZE + SMM_VARIABLE_COMMUNICATE_HEADER_SIZE + PayloadSize.
//
- PayloadSize = OFFSET_OF (SMM_VARIABLE_COMMUNICATE_ACCESS_VARIABLE, Name) + StrSize (VariableName) + DataSize;
+ PayloadSize = OFFSET_OF (SMM_VARIABLE_COMMUNICATE_ACCESS_VARIABLE, Name) + VariableNameSize + DataSize;
Status = InitCommunicateBuffer ((VOID **)&SmmVariableHeader, PayloadSize, SMM_VARIABLE_FUNCTION_SET_VARIABLE);
if (EFI_ERROR (Status)) {
goto Done;
@@ -400,7 +515,7 @@ RuntimeServiceSetVariable (
CopyGuid ((EFI_GUID *) &SmmVariableHeader->Guid, VendorGuid);
SmmVariableHeader->DataSize = DataSize;
- SmmVariableHeader->NameSize = StrSize (VariableName);
+ SmmVariableHeader->NameSize = VariableNameSize;
SmmVariableHeader->Attributes = Attributes;
CopyMem (SmmVariableHeader->Name, VariableName, SmmVariableHeader->NameSize);
CopyMem ((UINT8 *) SmmVariableHeader->Name + SmmVariableHeader->NameSize, Data, DataSize);
@@ -591,10 +706,11 @@ SmmVariableReady (
ASSERT_EFI_ERROR (Status);
//
- // Allocate memory for variable store.
+ // Allocate memory for variable communicate buffer.
//
- mVariableBufferSize = SMM_COMMUNICATE_HEADER_SIZE + SMM_VARIABLE_COMMUNICATE_HEADER_SIZE;
- mVariableBufferSize += MAX (PcdGet32 (PcdMaxVariableSize), PcdGet32 (PcdMaxHardwareErrorVariableSize));
+ mVariableBufferPayloadSize = MAX (PcdGet32 (PcdMaxVariableSize), PcdGet32 (PcdMaxHardwareErrorVariableSize)) +
+ OFFSET_OF (SMM_VARIABLE_COMMUNICATE_ACCESS_VARIABLE, Name) - sizeof (VARIABLE_HEADER);
+ mVariableBufferSize = SMM_COMMUNICATE_HEADER_SIZE + SMM_VARIABLE_COMMUNICATE_HEADER_SIZE + mVariableBufferPayloadSize;
mVariableBuffer = AllocateRuntimePool (mVariableBufferSize);
ASSERT (mVariableBuffer != NULL);
@@ -675,6 +791,7 @@ VariableSmmRuntimeInitialize (
IN EFI_SYSTEM_TABLE *SystemTable
)
{
+ EFI_STATUS Status;
VOID *SmmVariableRegistration;
VOID *SmmVariableWriteRegistration;
EFI_EVENT OnReadyToBootEvent;
@@ -682,6 +799,15 @@ VariableSmmRuntimeInitialize (
EfiInitializeLock (&mVariableServicesLock, TPL_NOTIFY);
+ mVariableLock.RequestToLock = VariableLockRequestToLock;
+ Status = gBS->InstallMultipleProtocolInterfaces (
+ &mHandle,
+ &gEdkiiVariableLockProtocolGuid,
+ &mVariableLock,
+ NULL
+ );
+ ASSERT_EFI_ERROR (Status);
+
//
// Smm variable service is ready
//
diff --git a/MdeModulePkg/Universal/Variable/RuntimeDxe/VariableSmmRuntimeDxe.inf b/MdeModulePkg/Universal/Variable/RuntimeDxe/VariableSmmRuntimeDxe.inf
index 05dd49d368..761ea66e6b 100644
--- a/MdeModulePkg/Universal/Variable/RuntimeDxe/VariableSmmRuntimeDxe.inf
+++ b/MdeModulePkg/Universal/Variable/RuntimeDxe/VariableSmmRuntimeDxe.inf
@@ -4,7 +4,7 @@
# This module is the Runtime DXE part correspond to SMM variable module. It
# installs variable arch protocol and variable write arch protocol and works
# with SMM variable module together.
-# 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
@@ -54,6 +54,7 @@
gEfiVariableArchProtocolGuid ## ALWAYS_PRODUCES
gEfiSmmCommunicationProtocolGuid
gEfiSmmVariableProtocolGuid
+ gEdkiiVariableLockProtocolGuid ## ALWAYS_PRODUCES
[Guids]
gEfiEventVirtualAddressChangeGuid ## PRODUCES ## Event
diff --git a/MdePkg/Include/IndustryStandard/Pci.h b/MdePkg/Include/IndustryStandard/Pci.h
index 32dd543232..ed59a45710 100644
--- a/MdePkg/Include/IndustryStandard/Pci.h
+++ b/MdePkg/Include/IndustryStandard/Pci.h
@@ -1,7 +1,7 @@
/** @file
Support for the latest PCI standard.
-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 that accompanies this distribution.
The full text of the license may be found at
@@ -10,9 +10,6 @@ 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.
- 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 _PCI_H_
diff --git a/MdePkg/Library/BasePrintLib/PrintLibInternal.c b/MdePkg/Library/BasePrintLib/PrintLibInternal.c
index 34e9d12767..c4fd755eec 100644
--- a/MdePkg/Library/BasePrintLib/PrintLibInternal.c
+++ b/MdePkg/Library/BasePrintLib/PrintLibInternal.c
@@ -14,8 +14,8 @@
#include "PrintLibInternal.h"
-#define WARNING_STATUS_NUMBER 4
-#define ERROR_STATUS_NUMBER 24
+#define WARNING_STATUS_NUMBER 5
+#define ERROR_STATUS_NUMBER 33
GLOBAL_REMOVE_IF_UNREFERENCED CONST CHAR8 mHexStr[] = {'0','1','2','3','4','5','6','7','8','9','A','B','C','D','E','F'};
@@ -25,6 +25,7 @@ GLOBAL_REMOVE_IF_UNREFERENCED CONST CHAR8 *mStatusString[] = {
"Warning Delete Failure", // RETURN_WARN_DELETE_FAILURE = 2
"Warning Write Failure", // RETURN_WARN_WRITE_FAILURE = 3
"Warning Buffer Too Small", // RETURN_WARN_BUFFER_TOO_SMALL = 4
+ "Warning Stale Data", // RETURN_WARN_STALE_DATA = 5
"Load Error", // RETURN_LOAD_ERROR = 1 | MAX_BIT
"Invalid Parameter", // RETURN_INVALID_PARAMETER = 2 | MAX_BIT
"Unsupported", // RETURN_UNSUPPORTED = 3 | MAX_BIT
@@ -48,7 +49,16 @@ GLOBAL_REMOVE_IF_UNREFERENCED CONST CHAR8 *mStatusString[] = {
"Aborted", // RETURN_ABORTED = 21 | MAX_BIT
"ICMP Error", // RETURN_ICMP_ERROR = 22 | MAX_BIT
"TFTP Error", // RETURN_TFTP_ERROR = 23 | MAX_BIT
- "Protocol Error" // RETURN_PROTOCOL_ERROR = 24 | MAX_BIT
+ "Protocol Error", // RETURN_PROTOCOL_ERROR = 24 | MAX_BIT
+ "Incompatible Version", // RETURN_INCOMPATIBLE_VERSION = 25 | MAX_BIT
+ "Security Violation", // RETURN_SECURITY_VIOLATION = 26 | MAX_BIT
+ "CRC Error", // RETURN_CRC_ERROR = 27 | MAX_BIT
+ "End of Media", // RETURN_END_OF_MEDIA = 28 | MAX_BIT
+ "Reserved (29)", // RESERVED = 29 | MAX_BIT
+ "Reserved (30)", // RESERVED = 30 | MAX_BIT
+ "End of File", // RETURN_END_OF_FILE = 31 | MAX_BIT
+ "Invalid Language", // RETURN_INVALID_LANGUAGE = 32 | MAX_BIT
+ "Compromised Data" // RETURN_COMPROMISED_DATA = 33 | MAX_BIT
};
diff --git a/NetworkPkg/Application/VConfig/VConfig.c b/NetworkPkg/Application/VConfig/VConfig.c
index 73217580f8..ba1720705c 100644
--- a/NetworkPkg/Application/VConfig/VConfig.c
+++ b/NetworkPkg/Application/VConfig/VConfig.c
@@ -1,7 +1,7 @@
/** @file
Shell application for VLAN configuration.
- 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
diff --git a/NetworkPkg/Application/VConfig/VConfigStrings.uni b/NetworkPkg/Application/VConfig/VConfigStrings.uni
index e8bdcefee8..5cab8ba543 100644
--- a/NetworkPkg/Application/VConfig/VConfigStrings.uni
+++ b/NetworkPkg/Application/VConfig/VConfigStrings.uni
Binary files differ
diff --git a/NetworkPkg/IScsiDxe/IScsiDriver.c b/NetworkPkg/IScsiDxe/IScsiDriver.c
index 2fd4c95a08..cc452e7110 100644
--- a/NetworkPkg/IScsiDxe/IScsiDriver.c
+++ b/NetworkPkg/IScsiDxe/IScsiDriver.c
@@ -1,7 +1,7 @@
/** @file
The entry point of IScsi driver.
-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
@@ -14,10 +14,19 @@ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
#include "IScsiImpl.h"
-EFI_DRIVER_BINDING_PROTOCOL gIScsiDriverBinding = {
- IScsiDriverBindingSupported,
- IScsiDriverBindingStart,
- IScsiDriverBindingStop,
+EFI_DRIVER_BINDING_PROTOCOL gIScsiIp4DriverBinding = {
+ IScsiIp4DriverBindingSupported,
+ IScsiIp4DriverBindingStart,
+ IScsiIp4DriverBindingStop,
+ 0xa,
+ NULL,
+ NULL
+};
+
+EFI_DRIVER_BINDING_PROTOCOL gIScsiIp6DriverBinding = {
+ IScsiIp6DriverBindingSupported,
+ IScsiIp6DriverBindingStart,
+ IScsiIp6DriverBindingStop,
0xa,
NULL,
NULL
@@ -28,7 +37,7 @@ EFI_GUID gIScsiV6PrivateGuid = ISCSI_V6_PRIVATE_GUID;
ISCSI_PRIVATE_DATA *mPrivate = NULL;
/**
- Tests to see if this driver supports the RemainingDevicePath.
+ Tests to see if this driver supports the RemainingDevicePath.
@param[in] RemainingDevicePath A pointer to the remaining portion of a device path. This
parameter is ignored by device drivers, and is optional for bus
@@ -67,22 +76,8 @@ IScsiIsDevicePathSupported (
/**
- Tests to see if this driver supports a given controller. If a child device is provided,
- it further tests to see if this driver supports creating a handle for the specified child device.
-
- This function checks to see if the driver specified by This supports the device specified by
- ControllerHandle. Drivers typically use the device path attached to
- ControllerHandle and/or the services from the bus I/O abstraction attached to
- ControllerHandle to determine if the driver supports ControllerHandle. This function
- may be called many times during platform initialization. In order to reduce boot times, the tests
- performed by this function must be very small and take as little time as possible to execute. This
- function must not change the state of any hardware devices, and this function must be aware that the
- device specified by ControllerHandle may already be managed by the same driver or a
- different driver. This function must match its calls to AllocatePages() with FreePages(),
- AllocatePool() with FreePool(), and OpenProtocol() with CloseProtocol().
- Since ControllerHandle may have been previously started by the same driver, if a protocol is
- already in the opened state, then it must not be closed with CloseProtocol(). This is required
- to guarantee the state of ControllerHandle is not modified by this function.
+ Tests to see if this driver supports a given controller. This is the worker function for
+ IScsiIp4(6)DriverBindingSupported.
@param[in] This A pointer to the EFI_DRIVER_BINDING_PROTOCOL instance.
@param[in] ControllerHandle The handle of the controller to test. This handle
@@ -95,75 +90,51 @@ IScsiIsDevicePathSupported (
by ControllerHandle and the child controller specified
by RemainingDevicePath are both supported by this
bus driver.
+ @param[in] IpVersion IP_VERSION_4 or IP_VERSION_6.
@retval EFI_SUCCESS The device specified by ControllerHandle and
RemainingDevicePath is supported by the driver specified by This.
@retval EFI_ALREADY_STARTED The device specified by ControllerHandle and
RemainingDevicePath is already being managed by the driver
specified by This.
- @retval EFI_ACCESS_DENIED The device specified by ControllerHandle and
- RemainingDevicePath is already being managed by a different
- driver or an application that requires exclusive access.
- Currently not implemented.
@retval EFI_UNSUPPORTED The device specified by ControllerHandle and
RemainingDevicePath is not supported by the driver specified by This.
**/
EFI_STATUS
EFIAPI
-IScsiDriverBindingSupported (
+IScsiSupported (
IN EFI_DRIVER_BINDING_PROTOCOL *This,
IN EFI_HANDLE ControllerHandle,
- IN EFI_DEVICE_PATH_PROTOCOL *RemainingDevicePath OPTIONAL
+ IN EFI_DEVICE_PATH_PROTOCOL *RemainingDevicePath OPTIONAL,
+ IN UINT8 IpVersion
)
{
EFI_STATUS Status;
- BOOLEAN IsIscsi4Started;
+ EFI_GUID *IScsiServiceBindingGuid;
+ EFI_GUID *TcpServiceBindingGuid;
- Status = gBS->OpenProtocol (
- ControllerHandle,
- &gIScsiV4PrivateGuid,
- NULL,
- This->DriverBindingHandle,
- ControllerHandle,
- EFI_OPEN_PROTOCOL_TEST_PROTOCOL
- );
- if (!EFI_ERROR (Status)) {
- IsIscsi4Started = TRUE;
+ if (IpVersion == IP_VERSION_4) {
+ IScsiServiceBindingGuid = &gIScsiV4PrivateGuid;
+ TcpServiceBindingGuid = &gEfiTcp4ServiceBindingProtocolGuid;
} else {
- Status = gBS->OpenProtocol (
- ControllerHandle,
- &gEfiTcp4ServiceBindingProtocolGuid,
- NULL,
- This->DriverBindingHandle,
- ControllerHandle,
- EFI_OPEN_PROTOCOL_TEST_PROTOCOL
- );
- if (!EFI_ERROR (Status)) {
- Status = IScsiIsDevicePathSupported (RemainingDevicePath);
- if (!EFI_ERROR (Status)) {
- return EFI_SUCCESS;
- }
- }
-
- IsIscsi4Started = FALSE;
+ IScsiServiceBindingGuid = &gIScsiV6PrivateGuid;
+ TcpServiceBindingGuid = &gEfiTcp6ServiceBindingProtocolGuid;
}
Status = gBS->OpenProtocol (
ControllerHandle,
- &gIScsiV6PrivateGuid,
+ IScsiServiceBindingGuid,
NULL,
This->DriverBindingHandle,
ControllerHandle,
EFI_OPEN_PROTOCOL_TEST_PROTOCOL
);
if (!EFI_ERROR (Status)) {
- if (IsIscsi4Started) {
- return EFI_ALREADY_STARTED;
- }
+ return EFI_ALREADY_STARTED;
} else {
Status = gBS->OpenProtocol (
ControllerHandle,
- &gEfiTcp6ServiceBindingProtocolGuid,
+ TcpServiceBindingGuid,
NULL,
This->DriverBindingHandle,
ControllerHandle,
@@ -183,13 +154,13 @@ IScsiDriverBindingSupported (
/**
Start to manage the controller. This is the worker function for
- IScsiDriverBindingStart.
+ IScsiIp4(6)DriverBindingStart.
@param[in] Image Handle of the image.
@param[in] ControllerHandle Handle of the controller.
- @param[in] IpVersion Ip4 or Ip6
+ @param[in] IpVersion IP_VERSION_4 or IP_VERSION_6.
- @retval EFI_SUCCES This driver supports this device.
+ @retval EFI_SUCCES This driver was started.
@retval EFI_ALREADY_STARTED This driver is already running on this device.
@retval EFI_INVALID_PARAMETER Any input parameter is invalid.
@retval EFI_NOT_FOUND There is no sufficient information to establish
@@ -777,83 +748,8 @@ ON_ERROR:
}
/**
- Starts a device controller or a bus controller.
-
- The Start() function is designed to be invoked from the EFI boot service ConnectController().
- As a result, much of the error checking on the parameters to Start() has been moved into this
- common boot service. It is legal to call Start() from other locations,
- but the following calling restrictions must be followed or the system behavior will not be deterministic.
- 1. ControllerHandle must be a valid EFI_HANDLE.
- 2. If RemainingDevicePath is not NULL, then it must be a pointer to a naturally aligned
- EFI_DEVICE_PATH_PROTOCOL.
- 3. Prior to calling Start(), the Supported() function for the driver specified by This must
- have been called with the same calling parameters, and Supported() must have returned EFI_SUCCESS.
-
- @param[in] This A pointer to the EFI_DRIVER_BINDING_PROTOCOL instance.
- @param[in] ControllerHandle The handle of the controller to start. This handle
- must support a protocol interface that supplies
- an I/O abstraction to the driver.
- @param[in] RemainingDevicePath A pointer to the remaining portion of a device path. This
- parameter is ignored by device drivers, and is optional for bus
- drivers. For a bus driver, if this parameter is NULL, then handles
- for all the children of Controller are created by this driver.
- If this parameter is not NULL and the first Device Path Node is
- not the End of Device Path Node, then only the handle for the
- child device specified by the first Device Path Node of
- RemainingDevicePath is created by this driver.
- If the first Device Path Node of RemainingDevicePath is
- the End of Device Path Node, no child handle is created by this
- driver.
-
- @retval EFI_SUCCESS The device was started.
- @retval EFI_DEVICE_ERROR The device could not be started due to a device error.Currently not implemented.
- @retval EFI_OUT_OF_RESOURCES The request could not be completed due to a lack of resources.
- @retval Others The driver failed to start the device.
-
-**/
-EFI_STATUS
-EFIAPI
-IScsiDriverBindingStart (
- IN EFI_DRIVER_BINDING_PROTOCOL *This,
- IN EFI_HANDLE ControllerHandle,
- IN EFI_DEVICE_PATH_PROTOCOL *RemainingDevicePath OPTIONAL
- )
-{
- EFI_STATUS V4Status;
- EFI_STATUS V6Status;
-
- V4Status = IScsiStart (This->DriverBindingHandle, ControllerHandle, IP_VERSION_4);
- if (V4Status == EFI_ALREADY_STARTED) {
- V4Status = EFI_SUCCESS;
- }
-
- V6Status = IScsiStart (This->DriverBindingHandle, ControllerHandle, IP_VERSION_6);
- if (V6Status == EFI_ALREADY_STARTED) {
- V6Status = EFI_SUCCESS;
- }
-
- if (!EFI_ERROR (V4Status) || !EFI_ERROR (V6Status)) {
- return EFI_SUCCESS;
- } else if (EFI_ERROR (V4Status)) {
- return V4Status;
- } else {
- return V6Status;
- }
-}
-
-/**
- Stops a device controller or a bus controller.
-
- The Stop() function is designed to be invoked from the EFI boot service DisconnectController().
- As a result, much of the error checking on the parameters to Stop() has been moved
- into this common boot service. It is legal to call Stop() from other locations,
- but the following calling restrictions must be followed or the system behavior will not be deterministic.
- 1. ControllerHandle must be a valid EFI_HANDLE that was used on a previous call to this
- same driver's Start() function.
- 2. The first NumberOfChildren handles of ChildHandleBuffer must all be a valid
- EFI_HANDLE. In addition, all of these handles must have been created in this driver's
- Start() function, and the Start() function must have called OpenProtocol() on
- ControllerHandle with an Attribute of EFI_OPEN_PROTOCOL_BY_CHILD_CONTROLLER.
+ Stops a device controller or a bus controller. This is the worker function for
+ IScsiIp4(6)DriverBindingStop.
@param[in] This A pointer to the EFI_DRIVER_BINDING_PROTOCOL instance.
@param[in] ControllerHandle A handle to the device being stopped. The handle must
@@ -862,18 +758,20 @@ IScsiDriverBindingStart (
@param[in] NumberOfChildren The number of child device handles in ChildHandleBuffer.
@param[in] ChildHandleBuffer An array of child handles to be freed. May be NULL
if NumberOfChildren is 0.
-
+ @param[in] IpVersion IP_VERSION_4 or IP_VERSION_6.
+
@retval EFI_SUCCESS The device was stopped.
@retval EFI_DEVICE_ERROR The device could not be stopped due to a device error.
**/
EFI_STATUS
EFIAPI
-IScsiDriverBindingStop (
+IScsiStop (
IN EFI_DRIVER_BINDING_PROTOCOL *This,
IN EFI_HANDLE ControllerHandle,
IN UINTN NumberOfChildren,
- IN EFI_HANDLE *ChildHandleBuffer OPTIONAL
+ IN EFI_HANDLE *ChildHandleBuffer OPTIONAL,
+ IN UINT8 IpVersion
)
{
EFI_HANDLE IScsiController;
@@ -911,7 +809,7 @@ IScsiDriverBindingStop (
// the protocol here, but do not uninstall the device path protocol and
// EXT SCSI PASS THRU protocol installed on ExtScsiPassThruHandle.
//
- if (!Conn->Ipv6Flag) {
+ if (IpVersion == IP_VERSION_4) {
ProtocolGuid = &gEfiTcp4ProtocolGuid;
} else {
ProtocolGuid = &gEfiTcp6ProtocolGuid;
@@ -929,18 +827,19 @@ IScsiDriverBindingStop (
//
// Get the handle of the controller we are controling.
//
- IScsiController = NetLibGetNicHandle (ControllerHandle, &gEfiTcp4ProtocolGuid);
- if (IScsiController != NULL) {
+ if (IpVersion == IP_VERSION_4) {
ProtocolGuid = &gIScsiV4PrivateGuid;
TcpProtocolGuid = &gEfiTcp4ProtocolGuid;
TcpServiceBindingGuid = &gEfiTcp4ServiceBindingProtocolGuid;
} else {
- IScsiController = NetLibGetNicHandle (ControllerHandle, &gEfiTcp6ProtocolGuid);
- ASSERT (IScsiController != NULL);
ProtocolGuid = &gIScsiV6PrivateGuid;
TcpProtocolGuid = &gEfiTcp6ProtocolGuid;
TcpServiceBindingGuid = &gEfiTcp6ServiceBindingProtocolGuid;
}
+ IScsiController = NetLibGetNicHandle (ControllerHandle, TcpProtocolGuid);
+ if (IScsiController == NULL) {
+ return EFI_SUCCESS;
+ }
Status = gBS->OpenProtocol (
IScsiController,
@@ -1002,6 +901,315 @@ IScsiDriverBindingStop (
return EFI_SUCCESS;
}
+/**
+ Tests to see if this driver supports a given controller. If a child device is provided,
+ it tests to see if this driver supports creating a handle for the specified child device.
+
+ This function checks to see if the driver specified by This supports the device specified by
+ ControllerHandle. Drivers typically use the device path attached to
+ ControllerHandle and/or the services from the bus I/O abstraction attached to
+ ControllerHandle to determine if the driver supports ControllerHandle. This function
+ may be called many times during platform initialization. In order to reduce boot times, the tests
+ performed by this function must be very small and take as little time as possible to execute. This
+ function must not change the state of any hardware devices, and this function must be aware that the
+ device specified by ControllerHandle may already be managed by the same driver or a
+ different driver. This function must match its calls to AllocatePages() with FreePages(),
+ AllocatePool() with FreePool(), and OpenProtocol() with CloseProtocol().
+ Since ControllerHandle may have been previously started by the same driver, if a protocol is
+ already in the opened state, then it must not be closed with CloseProtocol(). This is required
+ to guarantee the state of ControllerHandle is not modified by this function.
+
+ @param[in] This A pointer to the EFI_DRIVER_BINDING_PROTOCOL instance.
+ @param[in] ControllerHandle The handle of the controller to test. This handle
+ must support a protocol interface that supplies
+ an I/O abstraction to the driver.
+ @param[in] RemainingDevicePath A pointer to the remaining portion of a device path. This
+ parameter is ignored by device drivers, and is optional for bus
+ drivers. For bus drivers, if this parameter is not NULL, then
+ the bus driver must determine if the bus controller specified
+ by ControllerHandle and the child controller specified
+ by RemainingDevicePath are both supported by this
+ bus driver.
+
+ @retval EFI_SUCCESS The device specified by ControllerHandle and
+ RemainingDevicePath is supported by the driver specified by This.
+ @retval EFI_ALREADY_STARTED The device specified by ControllerHandle and
+ RemainingDevicePath is already managed by the driver
+ specified by This.
+ @retval EFI_ACCESS_DENIED The device specified by ControllerHandle and
+ RemainingDevicePath is already managed by a different
+ driver or an application that requires exclusive access.
+ Currently not implemented.
+ @retval EFI_UNSUPPORTED The device specified by ControllerHandle and
+ RemainingDevicePath is not supported by the driver specified by This.
+**/
+EFI_STATUS
+EFIAPI
+IScsiIp4DriverBindingSupported (
+ IN EFI_DRIVER_BINDING_PROTOCOL *This,
+ IN EFI_HANDLE ControllerHandle,
+ IN EFI_DEVICE_PATH_PROTOCOL *RemainingDevicePath OPTIONAL
+ )
+{
+ return IScsiSupported (
+ This,
+ ControllerHandle,
+ RemainingDevicePath,
+ IP_VERSION_4
+ );
+}
+
+/**
+ Starts a device controller or a bus controller.
+
+ The Start() function is designed to be invoked from the EFI boot service ConnectController().
+ As a result, much of the error checking on the parameters to Start() has been moved into this
+ common boot service. It is legal to call Start() from other locations,
+ but the following calling restrictions must be followed or the system behavior will not be deterministic.
+ 1. ControllerHandle must be a valid EFI_HANDLE.
+ 2. If RemainingDevicePath is not NULL, then it must be a pointer to a naturally aligned
+ EFI_DEVICE_PATH_PROTOCOL.
+ 3. Prior to calling Start(), the Supported() function for the driver specified by This must
+ have been called with the same calling parameters, and Supported() must have returned EFI_SUCCESS.
+
+ @param[in] This A pointer to the EFI_DRIVER_BINDING_PROTOCOL instance.
+ @param[in] ControllerHandle The handle of the controller to start. This handle
+ must support a protocol interface that supplies
+ an I/O abstraction to the driver.
+ @param[in] RemainingDevicePath A pointer to the remaining portion of a device path. This
+ parameter is ignored by device drivers, and is optional for bus
+ drivers. For a bus driver, if this parameter is NULL, then handles
+ for all the children of Controller are created by this driver.
+ If this parameter is not NULL and the first Device Path Node is
+ not the End of Device Path Node, then only the handle for the
+ child device specified by the first Device Path Node of
+ RemainingDevicePath is created by this driver.
+ If the first Device Path Node of RemainingDevicePath is
+ the End of Device Path Node, no child handle is created by this
+ driver.
+
+ @retval EFI_SUCCESS The device was started.
+ @retval EFI_DEVICE_ERROR The device could not be started due to a device error. Currently not implemented.
+ @retval EFI_OUT_OF_RESOURCES The request could not be completed due to a lack of resources.
+ @retval Others The driver failed to start the device.
+
+**/
+EFI_STATUS
+EFIAPI
+IScsiIp4DriverBindingStart (
+ IN EFI_DRIVER_BINDING_PROTOCOL *This,
+ IN EFI_HANDLE ControllerHandle,
+ IN EFI_DEVICE_PATH_PROTOCOL *RemainingDevicePath OPTIONAL
+ )
+{
+ EFI_STATUS Status;
+
+ Status = IScsiStart (This->DriverBindingHandle, ControllerHandle, IP_VERSION_4);
+ if (Status == EFI_ALREADY_STARTED) {
+ Status = EFI_SUCCESS;
+ }
+
+ return Status;
+}
+
+/**
+ Stops a device controller or a bus controller.
+
+ The Stop() function is designed to be invoked from the EFI boot service DisconnectController().
+ As a result, much of the error checking on the parameters to Stop() has been moved
+ into this common boot service. It is legal to call Stop() from other locations,
+ but the following calling restrictions must be followed or the system behavior will not be deterministic.
+ 1. ControllerHandle must be a valid EFI_HANDLE that was used on a previous call to this
+ same driver's Start() function.
+ 2. The first NumberOfChildren handles of ChildHandleBuffer must all be a valid
+ EFI_HANDLE. In addition, all of these handles must have been created in this driver's
+ Start() function, and the Start() function must have called OpenProtocol() on
+ ControllerHandle with an Attribute of EFI_OPEN_PROTOCOL_BY_CHILD_CONTROLLER.
+
+ @param[in] This A pointer to the EFI_DRIVER_BINDING_PROTOCOL instance.
+ @param[in] ControllerHandle A handle to the device being stopped. The handle must
+ support a bus specific I/O protocol for the driver
+ to use to stop the device.
+ @param[in] NumberOfChildren The number of child device handles in ChildHandleBuffer.
+ @param[in] ChildHandleBuffer An array of child handles to be freed. May be NULL
+ if NumberOfChildren is 0.
+
+ @retval EFI_SUCCESS The device was stopped.
+ @retval EFI_DEVICE_ERROR The device could not be stopped due to a device error.
+
+**/
+EFI_STATUS
+EFIAPI
+IScsiIp4DriverBindingStop (
+ IN EFI_DRIVER_BINDING_PROTOCOL *This,
+ IN EFI_HANDLE ControllerHandle,
+ IN UINTN NumberOfChildren,
+ IN EFI_HANDLE *ChildHandleBuffer OPTIONAL
+ )
+{
+ return IScsiStop (
+ This,
+ ControllerHandle,
+ NumberOfChildren,
+ ChildHandleBuffer,
+ IP_VERSION_4
+ );
+}
+
+/**
+ Tests to see if this driver supports a given controller. If a child device is provided,
+ it tests to see if this driver supports creating a handle for the specified child device.
+
+ This function checks to see if the driver specified by This supports the device specified by
+ ControllerHandle. Drivers typically use the device path attached to
+ ControllerHandle and/or the services from the bus I/O abstraction attached to
+ ControllerHandle to determine if the driver supports ControllerHandle. This function
+ may be called many times during platform initialization. In order to reduce boot times, the tests
+ performed by this function must be very small and take as little time as possible to execute. This
+ function must not change the state of any hardware devices, and this function must be aware that the
+ device specified by ControllerHandle may already be managed by the same driver or a
+ different driver. This function must match its calls to AllocatePages() with FreePages(),
+ AllocatePool() with FreePool(), and OpenProtocol() with CloseProtocol().
+ Since ControllerHandle may have been previously started by the same driver, if a protocol is
+ already in the opened state, then it must not be closed with CloseProtocol(). This is required
+ to guarantee the state of ControllerHandle is not modified by this function.
+
+ @param[in] This A pointer to the EFI_DRIVER_BINDING_PROTOCOL instance.
+ @param[in] ControllerHandle The handle of the controller to test. This handle
+ must support a protocol interface that supplies
+ an I/O abstraction to the driver.
+ @param[in] RemainingDevicePath A pointer to the remaining portion of a device path. This
+ parameter is ignored by device drivers, and is optional for bus
+ drivers. For bus drivers, if this parameter is not NULL, then
+ the bus driver must determine if the bus controller specified
+ by ControllerHandle and the child controller specified
+ by RemainingDevicePath are both supported by this
+ bus driver.
+
+ @retval EFI_SUCCESS The device specified by ControllerHandle and
+ RemainingDevicePath is supported by the driver specified by This.
+ @retval EFI_ALREADY_STARTED The device specified by ControllerHandle and
+ RemainingDevicePath is already managed by the driver
+ specified by This.
+ @retval EFI_ACCESS_DENIED The device specified by ControllerHandle and
+ RemainingDevicePath is already managed by a different
+ driver or an application that requires exclusive access.
+ Currently not implemented.
+ @retval EFI_UNSUPPORTED The device specified by ControllerHandle and
+ RemainingDevicePath is not supported by the driver specified by This.
+**/
+EFI_STATUS
+EFIAPI
+IScsiIp6DriverBindingSupported (
+ IN EFI_DRIVER_BINDING_PROTOCOL *This,
+ IN EFI_HANDLE ControllerHandle,
+ IN EFI_DEVICE_PATH_PROTOCOL *RemainingDevicePath OPTIONAL
+ )
+{
+ return IScsiSupported (
+ This,
+ ControllerHandle,
+ RemainingDevicePath,
+ IP_VERSION_6
+ );
+}
+
+/**
+ Starts a device controller or a bus controller.
+
+ The Start() function is designed to be invoked from the EFI boot service ConnectController().
+ As a result, much of the error checking on the parameters to Start() has been moved into this
+ common boot service. It is legal to call Start() from other locations,
+ but the following calling restrictions must be followed or the system behavior will not be deterministic.
+ 1. ControllerHandle must be a valid EFI_HANDLE.
+ 2. If RemainingDevicePath is not NULL, then it must be a pointer to a naturally aligned
+ EFI_DEVICE_PATH_PROTOCOL.
+ 3. Prior to calling Start(), the Supported() function for the driver specified by This must
+ have been called with the same calling parameters, and Supported() must have returned EFI_SUCCESS.
+
+ @param[in] This A pointer to the EFI_DRIVER_BINDING_PROTOCOL instance.
+ @param[in] ControllerHandle The handle of the controller to start. This handle
+ must support a protocol interface that supplies
+ an I/O abstraction to the driver.
+ @param[in] RemainingDevicePath A pointer to the remaining portion of a device path. This
+ parameter is ignored by device drivers, and is optional for bus
+ drivers. For a bus driver, if this parameter is NULL, then handles
+ for all the children of Controller are created by this driver.
+ If this parameter is not NULL and the first Device Path Node is
+ not the End of Device Path Node, then only the handle for the
+ child device specified by the first Device Path Node of
+ RemainingDevicePath is created by this driver.
+ If the first Device Path Node of RemainingDevicePath is
+ the End of Device Path Node, no child handle is created by this
+ driver.
+
+ @retval EFI_SUCCESS The device was started.
+ @retval EFI_DEVICE_ERROR The device could not be started due to a device error. Currently not implemented.
+ @retval EFI_OUT_OF_RESOURCES The request could not be completed due to a lack of resources.
+ @retval Others The driver failed to start the device.
+
+**/
+EFI_STATUS
+EFIAPI
+IScsiIp6DriverBindingStart (
+ IN EFI_DRIVER_BINDING_PROTOCOL *This,
+ IN EFI_HANDLE ControllerHandle,
+ IN EFI_DEVICE_PATH_PROTOCOL *RemainingDevicePath OPTIONAL
+ )
+{
+ EFI_STATUS Status;
+
+ Status = IScsiStart (This->DriverBindingHandle, ControllerHandle, IP_VERSION_6);
+ if (Status == EFI_ALREADY_STARTED) {
+ Status = EFI_SUCCESS;
+ }
+
+ return Status;
+}
+
+/**
+ Stops a device controller or a bus controller.
+
+ The Stop() function is designed to be invoked from the EFI boot service DisconnectController().
+ As a result, much of the error checking on the parameters to Stop() has been moved
+ into this common boot service. It is legal to call Stop() from other locations,
+ but the following calling restrictions must be followed or the system behavior will not be deterministic.
+ 1. ControllerHandle must be a valid EFI_HANDLE that was used on a previous call to this
+ same driver's Start() function.
+ 2. The first NumberOfChildren handles of ChildHandleBuffer must all be a valid
+ EFI_HANDLE. In addition, all of these handles must have been created in this driver's
+ Start() function, and the Start() function must have called OpenProtocol() on
+ ControllerHandle with an Attribute of EFI_OPEN_PROTOCOL_BY_CHILD_CONTROLLER.
+
+ @param[in] This A pointer to the EFI_DRIVER_BINDING_PROTOCOL instance.
+ @param[in] ControllerHandle A handle to the device being stopped. The handle must
+ support a bus specific I/O protocol for the driver
+ to use to stop the device.
+ @param[in] NumberOfChildren The number of child device handles in ChildHandleBuffer.
+ @param[in] ChildHandleBuffer An array of child handles to be freed. May be NULL
+ if NumberOfChildren is 0.
+
+ @retval EFI_SUCCESS The device was stopped.
+ @retval EFI_DEVICE_ERROR The device could not be stopped due to a device error.
+
+**/
+EFI_STATUS
+EFIAPI
+IScsiIp6DriverBindingStop (
+ IN EFI_DRIVER_BINDING_PROTOCOL *This,
+ IN EFI_HANDLE ControllerHandle,
+ IN UINTN NumberOfChildren,
+ IN EFI_HANDLE *ChildHandleBuffer OPTIONAL
+ )
+{
+ return IScsiStop (
+ This,
+ ControllerHandle,
+ NumberOfChildren,
+ ChildHandleBuffer,
+ IP_VERSION_6
+ );
+}
/**
Unload the iSCSI driver.
@@ -1033,23 +1241,27 @@ IScsiUnload (
&DeviceHandleCount,
&DeviceHandleBuffer
);
- if (!EFI_ERROR (Status)) {
- for (Index = 0; Index < DeviceHandleCount; Index++) {
- Status = gBS->DisconnectController (
- DeviceHandleBuffer[Index],
- ImageHandle,
- NULL
- );
- }
+ if (EFI_ERROR (Status)) {
+ return Status;
+ }
- if (DeviceHandleBuffer != NULL) {
- FreePool (DeviceHandleBuffer);
- }
+ for (Index = 0; Index < DeviceHandleCount; Index++) {
+ gBS->DisconnectController (
+ DeviceHandleBuffer[Index],
+ gIScsiIp4DriverBinding.DriverBindingHandle,
+ NULL
+ );
+ gBS->DisconnectController (
+ DeviceHandleBuffer[Index],
+ gIScsiIp6DriverBinding.DriverBindingHandle,
+ NULL
+ );
}
+
//
// Unload the iSCSI configuration form.
//
- IScsiConfigFormUnload (gIScsiDriverBinding.DriverBindingHandle);
+ IScsiConfigFormUnload (gIScsiIp4DriverBinding.DriverBindingHandle);
//
// Uninstall the protocols installed by iSCSI driver.
@@ -1066,18 +1278,31 @@ IScsiUnload (
gIScsiControllerNameTable = NULL;
}
- return gBS->UninstallMultipleProtocolInterfaces (
- ImageHandle,
- &gEfiDriverBindingProtocolGuid,
- &gIScsiDriverBinding,
- &gEfiComponentName2ProtocolGuid,
- &gIScsiComponentName2,
- &gEfiComponentNameProtocolGuid,
- &gIScsiComponentName,
- &gEfiIScsiInitiatorNameProtocolGuid,
- &gIScsiInitiatorName,
- NULL
- );
+ gBS->UninstallMultipleProtocolInterfaces (
+ gIScsiIp4DriverBinding.DriverBindingHandle,
+ &gEfiDriverBindingProtocolGuid,
+ &gIScsiIp4DriverBinding,
+ &gEfiComponentName2ProtocolGuid,
+ &gIScsiComponentName2,
+ &gEfiComponentNameProtocolGuid,
+ &gIScsiComponentName,
+ &gEfiIScsiInitiatorNameProtocolGuid,
+ &gIScsiInitiatorName,
+ NULL
+ );
+
+ gBS->UninstallMultipleProtocolInterfaces (
+ gIScsiIp6DriverBinding.DriverBindingHandle,
+ &gEfiDriverBindingProtocolGuid,
+ &gIScsiIp6DriverBinding,
+ &gEfiComponentName2ProtocolGuid,
+ &gIScsiComponentName2,
+ &gEfiComponentNameProtocolGuid,
+ &gIScsiComponentName,
+ NULL
+ );
+
+ return EFI_SUCCESS;
}
/**
@@ -1125,7 +1350,7 @@ IScsiDriverEntryPoint (
Status = EfiLibInstallDriverBindingComponentName2 (
ImageHandle,
SystemTable,
- &gIScsiDriverBinding,
+ &gIScsiIp4DriverBinding,
ImageHandle,
&gIScsiComponentName,
&gIScsiComponentName2
@@ -1134,6 +1359,18 @@ IScsiDriverEntryPoint (
return Status;
}
+ Status = EfiLibInstallDriverBindingComponentName2 (
+ ImageHandle,
+ SystemTable,
+ &gIScsiIp6DriverBinding,
+ NULL,
+ &gIScsiComponentName,
+ &gIScsiComponentName2
+ );
+ if (EFI_ERROR (Status)) {
+ goto Error1;
+ }
+
//
// Install the iSCSI Initiator Name Protocol.
//
@@ -1144,7 +1381,7 @@ IScsiDriverEntryPoint (
&gIScsiInitiatorName
);
if (EFI_ERROR (Status)) {
- goto Error1;
+ goto Error2;
}
//
@@ -1153,7 +1390,7 @@ IScsiDriverEntryPoint (
mPrivate = AllocateZeroPool (sizeof (ISCSI_PRIVATE_DATA));
if (mPrivate == NULL) {
Status = EFI_OUT_OF_RESOURCES;
- goto Error2;
+ goto Error3;
}
InitializeListHead (&mPrivate->NicInfoList);
@@ -1162,9 +1399,9 @@ IScsiDriverEntryPoint (
//
// Initialize the configuration form of iSCSI.
//
- Status = IScsiConfigFormInit (gIScsiDriverBinding.DriverBindingHandle);
+ Status = IScsiConfigFormInit (gIScsiIp4DriverBinding.DriverBindingHandle);
if (EFI_ERROR (Status)) {
- goto Error3;
+ goto Error4;
}
//
@@ -1184,19 +1421,19 @@ IScsiDriverEntryPoint (
&gIScsiAuthenticationInfo
);
if (EFI_ERROR (Status)) {
- goto Error4;
+ goto Error5;
}
}
return EFI_SUCCESS;
-Error4:
- IScsiConfigFormUnload (gIScsiDriverBinding.DriverBindingHandle);
+Error5:
+ IScsiConfigFormUnload (gIScsiIp4DriverBinding.DriverBindingHandle);
-Error3:
+Error4:
FreePool (mPrivate);
-Error2:
+Error3:
gBS->UninstallMultipleProtocolInterfaces (
ImageHandle,
&gEfiIScsiInitiatorNameProtocolGuid,
@@ -1204,11 +1441,23 @@ Error2:
NULL
);
+Error2:
+ gBS->UninstallMultipleProtocolInterfaces (
+ gIScsiIp6DriverBinding.DriverBindingHandle,
+ &gEfiDriverBindingProtocolGuid,
+ &gIScsiIp6DriverBinding,
+ &gEfiComponentName2ProtocolGuid,
+ &gIScsiComponentName2,
+ &gEfiComponentNameProtocolGuid,
+ &gIScsiComponentName,
+ NULL
+ );
+
Error1:
gBS->UninstallMultipleProtocolInterfaces (
ImageHandle,
&gEfiDriverBindingProtocolGuid,
- &gIScsiDriverBinding,
+ &gIScsiIp4DriverBinding,
&gEfiComponentName2ProtocolGuid,
&gIScsiComponentName2,
&gEfiComponentNameProtocolGuid,
diff --git a/NetworkPkg/IScsiDxe/IScsiDriver.h b/NetworkPkg/IScsiDxe/IScsiDriver.h
index 8c266fe763..825394a1d2 100644
--- a/NetworkPkg/IScsiDxe/IScsiDriver.h
+++ b/NetworkPkg/IScsiDxe/IScsiDriver.h
@@ -1,7 +1,7 @@
/** @file
The header file of IScsiDriver.c.
-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
@@ -126,7 +126,7 @@ typedef struct _ISCSI_PRIVATE_PROTOCOL {
**/
EFI_STATUS
EFIAPI
-IScsiDriverBindingSupported (
+IScsiIp4DriverBindingSupported (
IN EFI_DRIVER_BINDING_PROTOCOL *This,
IN EFI_HANDLE ControllerHandle,
IN EFI_DEVICE_PATH_PROTOCOL *RemainingDevicePath OPTIONAL
@@ -169,7 +169,7 @@ IScsiDriverBindingSupported (
**/
EFI_STATUS
EFIAPI
-IScsiDriverBindingStart (
+IScsiIp4DriverBindingStart (
IN EFI_DRIVER_BINDING_PROTOCOL *This,
IN EFI_HANDLE ControllerHandle,
IN EFI_DEVICE_PATH_PROTOCOL *RemainingDevicePath OPTIONAL
@@ -203,7 +203,135 @@ IScsiDriverBindingStart (
**/
EFI_STATUS
EFIAPI
-IScsiDriverBindingStop (
+IScsiIp4DriverBindingStop (
+ IN EFI_DRIVER_BINDING_PROTOCOL *This,
+ IN EFI_HANDLE ControllerHandle,
+ IN UINTN NumberOfChildren,
+ IN EFI_HANDLE *ChildHandleBuffer OPTIONAL
+ );
+
+/**
+ Tests to see if this driver supports a given controller. If a child device is provided,
+ it tests to see if this driver supports creating a handle for the specified child device.
+
+ This function checks to see if the driver specified by This supports the device specified by
+ ControllerHandle. Drivers typically use the device path attached to
+ ControllerHandle and/or the services from the bus I/O abstraction attached to
+ ControllerHandle to determine if the driver supports ControllerHandle. This function
+ may be called many times during platform initialization. In order to reduce boot times, the tests
+ performed by this function must be very small and take as little time as possible to execute. This
+ function must not change the state of any hardware devices, and this function must be aware that the
+ device specified by ControllerHandle may already be managed by the same driver or a
+ different driver. This function must match its calls to AllocatePages() with FreePages(),
+ AllocatePool() with FreePool(), and OpenProtocol() with CloseProtocol().
+ Since ControllerHandle may have been previously started by the same driver, if a protocol is
+ already in the opened state, then it must not be closed with CloseProtocol(). This is required
+ to guarantee the state of ControllerHandle is not modified by this function.
+
+ @param[in] This A pointer to the EFI_DRIVER_BINDING_PROTOCOL instance.
+ @param[in] ControllerHandle The handle of the controller to test. This handle
+ must support a protocol interface that supplies
+ an I/O abstraction to the driver.
+ @param[in] RemainingDevicePath A pointer to the remaining portion of a device path. This
+ parameter is ignored by device drivers, and is optional for bus
+ drivers. For bus drivers, if this parameter is not NULL, then
+ the bus driver must determine if the bus controller specified
+ by ControllerHandle and the child controller specified
+ by RemainingDevicePath are both supported by this
+ bus driver.
+
+ @retval EFI_SUCCESS The device specified by ControllerHandle and
+ RemainingDevicePath is supported by the driver specified by This.
+ @retval EFI_ALREADY_STARTED The device specified by ControllerHandle and
+ RemainingDevicePath is already managed by the driver
+ specified by This.
+ @retval EFI_ACCESS_DENIED The device specified by ControllerHandle and
+ RemainingDevicePath is already managed by a different
+ driver or an application that requires exclusive access.
+ Currently not implemented.
+ @retval EFI_UNSUPPORTED The device specified by ControllerHandle and
+ RemainingDevicePath is not supported by the driver specified by This.
+**/
+EFI_STATUS
+EFIAPI
+IScsiIp6DriverBindingSupported (
+ IN EFI_DRIVER_BINDING_PROTOCOL *This,
+ IN EFI_HANDLE ControllerHandle,
+ IN EFI_DEVICE_PATH_PROTOCOL *RemainingDevicePath OPTIONAL
+ );
+
+/**
+ Starts a device controller or a bus controller.
+
+ The Start() function is designed to be invoked from the EFI boot service ConnectController().
+ As a result, much of the error checking on the parameters to Start() has been moved into this
+ common boot service. It is legal to call Start() from other locations,
+ but the following calling restrictions must be followed or the system behavior will not be deterministic.
+ 1. ControllerHandle must be a valid EFI_HANDLE.
+ 2. If RemainingDevicePath is not NULL, then it must be a pointer to a naturally aligned
+ EFI_DEVICE_PATH_PROTOCOL.
+ 3. Prior to calling Start(), the Supported() function for the driver specified by This must
+ have been called with the same calling parameters, and Supported() must have returned EFI_SUCCESS.
+
+ @param[in] This A pointer to the EFI_DRIVER_BINDING_PROTOCOL instance.
+ @param[in] ControllerHandle The handle of the controller to start. This handle
+ must support a protocol interface that supplies
+ an I/O abstraction to the driver.
+ @param[in] RemainingDevicePath A pointer to the remaining portion of a device path. This
+ parameter is ignored by device drivers, and is optional for bus
+ drivers. For a bus driver, if this parameter is NULL, then handles
+ for all the children of Controller are created by this driver.
+ If this parameter is not NULL and the first Device Path Node is
+ not the End of Device Path Node, then only the handle for the
+ child device specified by the first Device Path Node of
+ RemainingDevicePath is created by this driver.
+ If the first Device Path Node of RemainingDevicePath is
+ the End of Device Path Node, no child handle is created by this
+ driver.
+
+ @retval EFI_SUCCESS The device was started.
+ @retval EFI_DEVICE_ERROR The device could not be started due to a device error. Currently not implemented.
+ @retval EFI_OUT_OF_RESOURCES The request could not be completed due to a lack of resources.
+ @retval Others The driver failed to start the device.
+
+**/
+EFI_STATUS
+EFIAPI
+IScsiIp6DriverBindingStart (
+ IN EFI_DRIVER_BINDING_PROTOCOL *This,
+ IN EFI_HANDLE ControllerHandle,
+ IN EFI_DEVICE_PATH_PROTOCOL *RemainingDevicePath OPTIONAL
+ );
+
+/**
+ Stops a device controller or a bus controller.
+
+ The Stop() function is designed to be invoked from the EFI boot service DisconnectController().
+ As a result, much of the error checking on the parameters to Stop() has been moved
+ into this common boot service. It is legal to call Stop() from other locations,
+ but the following calling restrictions must be followed or the system behavior will not be deterministic.
+ 1. ControllerHandle must be a valid EFI_HANDLE that was used on a previous call to this
+ same driver's Start() function.
+ 2. The first NumberOfChildren handles of ChildHandleBuffer must all be a valid
+ EFI_HANDLE. In addition, all of these handles must have been created in this driver's
+ Start() function, and the Start() function must have called OpenProtocol() on
+ ControllerHandle with an Attribute of EFI_OPEN_PROTOCOL_BY_CHILD_CONTROLLER.
+
+ @param[in] This A pointer to the EFI_DRIVER_BINDING_PROTOCOL instance.
+ @param[in] ControllerHandle A handle to the device being stopped. The handle must
+ support a bus specific I/O protocol for the driver
+ to use to stop the device.
+ @param[in] NumberOfChildren The number of child device handles in ChildHandleBuffer.
+ @param[in] ChildHandleBuffer An array of child handles to be freed. May be NULL
+ if NumberOfChildren is 0.
+
+ @retval EFI_SUCCESS The device was stopped.
+ @retval EFI_DEVICE_ERROR The device could not be stopped due to a device error.
+
+**/
+EFI_STATUS
+EFIAPI
+IScsiIp6DriverBindingStop (
IN EFI_DRIVER_BINDING_PROTOCOL *This,
IN EFI_HANDLE ControllerHandle,
IN UINTN NumberOfChildren,
diff --git a/NetworkPkg/IScsiDxe/IScsiProto.c b/NetworkPkg/IScsiDxe/IScsiProto.c
index 3dabb00d4a..d5e0994b53 100644
--- a/NetworkPkg/IScsiDxe/IScsiProto.c
+++ b/NetworkPkg/IScsiDxe/IScsiProto.c
@@ -975,7 +975,7 @@ IScsiProcessLoginRsp (
NetbufQueAppend (&Conn->RspQue, Pdu);
Conn->PartialRspRcvd = Continue;
- if (Continue) {
+ if ((!Transit) || Continue) {
//
// It is a partial response; must wait for another or more Request/Response
// conversations to get the full response.
diff --git a/NetworkPkg/IpSecDxe/IkeService.c b/NetworkPkg/IpSecDxe/IkeService.c
index b68f4567c5..8e2c794dc3 100644
--- a/NetworkPkg/IpSecDxe/IkeService.c
+++ b/NetworkPkg/IpSecDxe/IkeService.c
@@ -1,7 +1,7 @@
/** @file
Provide IPsec Key Exchange (IKE) service general interfaces.
- 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
@@ -346,6 +346,7 @@ ON_EXIT:
@param[in] Private Point to IPSEC_PRIVATE_DATA
@param[in] Controller Handler for NIC card.
+ @param[in] ImageHandle The handle that contains the EFI_DRIVER_BINDING_PROTOCOL instance.
@retval EFI_SUCCESS The Operation is successful.
@retval EFI_OUT_OF_RESOURCE The required system resource can't be allocated.
@@ -354,7 +355,8 @@ ON_EXIT:
EFI_STATUS
IkeOpenInputUdp4 (
IN IPSEC_PRIVATE_DATA *Private,
- IN EFI_HANDLE Controller
+ IN EFI_HANDLE Controller,
+ IN EFI_HANDLE ImageHandle
)
{
IKE_UDP_SERVICE *Udp4Srv;
@@ -378,7 +380,7 @@ IkeOpenInputUdp4 (
//
Udp4Srv->Input = UdpIoCreateIo (
Controller,
- Private->ImageHandle,
+ ImageHandle,
IkeConfigUdp4,
UDP_IO_UDP4_VERSION,
NULL
@@ -390,7 +392,7 @@ IkeOpenInputUdp4 (
}
Udp4Srv->NicHandle = Controller;
- Udp4Srv->ImageHandle = Private->ImageHandle;
+ Udp4Srv->ImageHandle = ImageHandle;
Udp4Srv->ListHead = &(Private->Udp4List);
Udp4Srv->IpVersion = UDP_IO_UDP4_VERSION;
Udp4Srv->IsConfigured = FALSE;
@@ -417,6 +419,7 @@ IkeOpenInputUdp4 (
@param[in] Private Point to IPSEC_PRIVATE_DATA
@param[in] Controller Handler for NIC card.
+ @param[in] ImageHandle The handle that contains the EFI_DRIVER_BINDING_PROTOCOL instance.
@retval EFI_SUCCESS The Operation is successful.
@retval EFI_OUT_OF_RESOURCE The required system resource can't be allocated.
@@ -425,7 +428,8 @@ IkeOpenInputUdp4 (
EFI_STATUS
IkeOpenInputUdp6 (
IN IPSEC_PRIVATE_DATA *Private,
- IN EFI_HANDLE Controller
+ IN EFI_HANDLE Controller,
+ IN EFI_HANDLE ImageHandle
)
{
IKE_UDP_SERVICE *Udp6Srv;
@@ -446,7 +450,7 @@ IkeOpenInputUdp6 (
//
Udp6Srv->Input = UdpIoCreateIo (
Controller,
- Private->ImageHandle,
+ ImageHandle,
IkeConfigUdp6,
UDP_IO_UDP6_VERSION,
NULL
@@ -458,7 +462,7 @@ IkeOpenInputUdp6 (
}
Udp6Srv->NicHandle = Controller;
- Udp6Srv->ImageHandle = Private->ImageHandle;
+ Udp6Srv->ImageHandle = ImageHandle;
Udp6Srv->ListHead = &(Private->Udp6List);
Udp6Srv->IpVersion = UDP_IO_UDP6_VERSION;
Udp6Srv->IsConfigured = FALSE;
diff --git a/NetworkPkg/IpSecDxe/IkeService.h b/NetworkPkg/IpSecDxe/IkeService.h
index cc21154ac6..3ebd17919a 100644
--- a/NetworkPkg/IpSecDxe/IkeService.h
+++ b/NetworkPkg/IpSecDxe/IkeService.h
@@ -1,7 +1,7 @@
/** @file
Prototypes definitions of IKE service.
- 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
@@ -143,6 +143,7 @@ typedef struct _IKE_EXCHANGE_INTERFACE {
@param[in] Private Point to IPSEC_PRIVATE_DATA
@param[in] Controller Handler for NIC card.
+ @param[in] ImageHandle The handle that contains the EFI_DRIVER_BINDING_PROTOCOL instance.
@retval EFI_SUCCESS The Operation is successful.
@retval EFI_OUT_OF_RESOURCE The required system resource can't be allocated.
@@ -151,7 +152,8 @@ typedef struct _IKE_EXCHANGE_INTERFACE {
EFI_STATUS
IkeOpenInputUdp4 (
IN IPSEC_PRIVATE_DATA *Private,
- IN EFI_HANDLE Controller
+ IN EFI_HANDLE Controller,
+ IN EFI_HANDLE ImageHandle
);
/**
@@ -162,6 +164,7 @@ IkeOpenInputUdp4 (
@param[in] Private Point to IPSEC_PRIVATE_DATA
@param[in] Controller Handler for NIC card.
+ @param[in] ImageHandle The handle that contains the EFI_DRIVER_BINDING_PROTOCOL instance.
@retval EFI_SUCCESS The Operation is successful.
@retval EFI_OUT_OF_RESOURCE The required system resource can't be allocated.
@@ -170,7 +173,8 @@ IkeOpenInputUdp4 (
EFI_STATUS
IkeOpenInputUdp6 (
IN IPSEC_PRIVATE_DATA *Private,
- IN EFI_HANDLE Controller
+ IN EFI_HANDLE Controller,
+ IN EFI_HANDLE ImageHandle
);
/**
diff --git a/NetworkPkg/IpSecDxe/IpSecDriver.c b/NetworkPkg/IpSecDxe/IpSecDriver.c
index 753c70db54..454d218c75 100644
--- a/NetworkPkg/IpSecDxe/IpSecDriver.c
+++ b/NetworkPkg/IpSecDxe/IpSecDriver.c
@@ -1,7 +1,7 @@
/** @file
Driver Binding Protocol for IPsec Driver.
- 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
@@ -20,13 +20,15 @@
#include "IpSecDebug.h"
/**
- Test to see if this driver supports ControllerHandle.
+ Test to see if this driver supports ControllerHandle. This is the worker function
+ for IpSec4(6)DriverbindingSupported.
@param[in] This Protocol instance pointer.
@param[in] ControllerHandle Handle of device to test.
@param[in] RemainingDevicePath Optional parameter used to pick a specific child
device to start.
-
+ @param[in] IpVersion IP_VERSION_4 or IP_VERSION_6.
+
@retval EFI_SUCCES This driver supports this device.
@retval EFI_ALREADY_STARTED This driver is already running on this device.
@retval other This driver does not support this device.
@@ -34,50 +36,45 @@
**/
EFI_STATUS
EFIAPI
-IpSecDriverBindingSupported (
+IpSecSupported (
IN EFI_DRIVER_BINDING_PROTOCOL *This,
IN EFI_HANDLE ControllerHandle,
- IN EFI_DEVICE_PATH_PROTOCOL *RemainingDevicePath OPTIONAL
+ IN EFI_DEVICE_PATH_PROTOCOL *RemainingDevicePath OPTIONAL,
+ IN UINT8 IpVersion
)
{
- EFI_STATUS Udp4Status;
- EFI_STATUS Udp6Status;
-
- Udp4Status = gBS->OpenProtocol (
- ControllerHandle,
- &gEfiUdp4ServiceBindingProtocolGuid,
- NULL,
- This->DriverBindingHandle,
- ControllerHandle,
- EFI_OPEN_PROTOCOL_TEST_PROTOCOL
- );
-
- Udp6Status = gBS->OpenProtocol (
- ControllerHandle,
- &gEfiUdp6ServiceBindingProtocolGuid,
- NULL,
- This->DriverBindingHandle,
- ControllerHandle,
- EFI_OPEN_PROTOCOL_TEST_PROTOCOL
- );
-
- //
- // The controller with either Udp4Sb or Udp6Sb is supported.
- //
- if (!EFI_ERROR (Udp4Status) || !EFI_ERROR (Udp6Status)) {
- return EFI_SUCCESS;
+ EFI_STATUS Status;
+ EFI_GUID *UdpServiceBindingGuid;
+
+ if (IpVersion == IP_VERSION_4) {
+ UdpServiceBindingGuid = &gEfiUdp4ServiceBindingProtocolGuid;
+ } else {
+ UdpServiceBindingGuid = &gEfiUdp6ServiceBindingProtocolGuid;
}
- return EFI_UNSUPPORTED;
+ Status = gBS->OpenProtocol (
+ ControllerHandle,
+ UdpServiceBindingGuid,
+ NULL,
+ This->DriverBindingHandle,
+ ControllerHandle,
+ EFI_OPEN_PROTOCOL_TEST_PROTOCOL
+ );
+ if (EFI_ERROR (Status)) {
+ return EFI_UNSUPPORTED;
+ }
+ return EFI_SUCCESS;
}
/**
- Start this driver on ControllerHandle.
+ Start this driver on ControllerHandle. This is the worker function
+ for IpSec4(6)DriverbindingStart.
@param[in] This Protocol instance pointer.
@param[in] ControllerHandle Handle of device to bind driver to.
@param[in] RemainingDevicePath Optional parameter used to pick a specific child
device to start.
+ @param[in] IpVersion IP_VERSION_4 or IP_VERSION_6.
@retval EFI_SUCCES This driver is added to ControllerHandle
@retval EFI_ALREADY_STARTED This driver is already running on ControllerHandle
@@ -88,16 +85,15 @@ IpSecDriverBindingSupported (
**/
EFI_STATUS
EFIAPI
-IpSecDriverBindingStart (
+IpSecStart (
IN EFI_DRIVER_BINDING_PROTOCOL *This,
IN EFI_HANDLE ControllerHandle,
- IN EFI_DEVICE_PATH_PROTOCOL *RemainingDevicePath OPTIONAL
+ IN EFI_DEVICE_PATH_PROTOCOL *RemainingDevicePath OPTIONAL,
+ IN UINT8 IpVersion
)
{
EFI_IPSEC2_PROTOCOL *IpSec;
EFI_STATUS Status;
- EFI_STATUS Udp4Status;
- EFI_STATUS Udp6Status;
IPSEC_PRIVATE_DATA *Private;
//
@@ -111,52 +107,56 @@ IpSecDriverBindingStart (
Private = IPSEC_PRIVATE_DATA_FROM_IPSEC (IpSec);
- //
- // If udp4 sb is on the controller, try to open a udp4 io for input.
- //
- Udp4Status = gBS->OpenProtocol (
- ControllerHandle,
- &gEfiUdp4ServiceBindingProtocolGuid,
- NULL,
- This->DriverBindingHandle,
- ControllerHandle,
- EFI_OPEN_PROTOCOL_TEST_PROTOCOL
- );
-
- if (!EFI_ERROR (Udp4Status)) {
- Udp4Status = IkeOpenInputUdp4 (Private, ControllerHandle);
- }
- //
- // If udp6 sb is on the controller, try to open a udp6 io for input.
- //
- Udp6Status = gBS->OpenProtocol (
- ControllerHandle,
- &gEfiUdp6ServiceBindingProtocolGuid,
- NULL,
- This->DriverBindingHandle,
- ControllerHandle,
- EFI_OPEN_PROTOCOL_TEST_PROTOCOL
- );
-
- if (!EFI_ERROR (Udp6Status)) {
- Udp6Status = IkeOpenInputUdp6 (Private, ControllerHandle);
+ if (IpVersion == IP_VERSION_4) {
+ //
+ // Try to open a udp4 io for input.
+ //
+ Status = gBS->OpenProtocol (
+ ControllerHandle,
+ &gEfiUdp4ServiceBindingProtocolGuid,
+ NULL,
+ This->DriverBindingHandle,
+ ControllerHandle,
+ EFI_OPEN_PROTOCOL_TEST_PROTOCOL
+ );
+
+ if (!EFI_ERROR (Status)) {
+ Status = IkeOpenInputUdp4 (Private, ControllerHandle, This->DriverBindingHandle);
+ }
+ } else {
+ //
+ // Try to open a udp6 io for input.
+ //
+ Status = gBS->OpenProtocol (
+ ControllerHandle,
+ &gEfiUdp6ServiceBindingProtocolGuid,
+ NULL,
+ This->DriverBindingHandle,
+ ControllerHandle,
+ EFI_OPEN_PROTOCOL_TEST_PROTOCOL
+ );
+
+ if (!EFI_ERROR (Status)) {
+ Status = IkeOpenInputUdp6 (Private, ControllerHandle, This->DriverBindingHandle);
+ }
}
- if (!EFI_ERROR (Udp4Status) || !EFI_ERROR (Udp6Status)) {
- return EFI_SUCCESS;
+ if (EFI_ERROR (Status)) {
+ return EFI_DEVICE_ERROR;
}
-
- return EFI_DEVICE_ERROR;
+ return EFI_SUCCESS;
}
/**
- Stop this driver on ControllerHandle.
+ Stop this driver on ControllerHandle. This is the worker function
+ for IpSec4(6)DriverbindingStop.
@param[in] This Protocol instance pointer.
@param[in] ControllerHandle Handle of a device to stop the driver on.
@param[in] NumberOfChildren Number of Handles in ChildHandleBuffer. If the number of
children is zero, stop the entire bus driver.
@param[in] ChildHandleBuffer List of Child Handles to Stop.
+ @param[in] IpVersion IP_VERSION_4 or IP_VERSION_6.
@retval EFI_SUCCES This driver removed ControllerHandle.
@retval other This driver was not removed from this device.
@@ -164,11 +164,12 @@ IpSecDriverBindingStart (
**/
EFI_STATUS
EFIAPI
-IpSecDriverBindingStop (
+IpSecStop (
IN EFI_DRIVER_BINDING_PROTOCOL *This,
IN EFI_HANDLE ControllerHandle,
IN UINTN NumberOfChildren,
- IN EFI_HANDLE *ChildHandleBuffer
+ IN EFI_HANDLE *ChildHandleBuffer,
+ IN UINT8 IpVersion
)
{
EFI_IPSEC2_PROTOCOL *IpSec;
@@ -190,69 +191,268 @@ IpSecDriverBindingStop (
Private = IPSEC_PRIVATE_DATA_FROM_IPSEC (IpSec);
//
- // Delete all SAs before stop Ipsec.
- //
- IkeDeleteAllSas (Private, FALSE);
+ // The SAs are shared by both IP4 and IP6 stack. So we skip the cleanup
+ // and leave the SAs unchanged if the other IP stack is still running.
//
- // If has udp4 io opened on the controller, close and free it.
- //
- NET_LIST_FOR_EACH_SAFE (Entry, Next, &Private->Udp4List) {
+ if ((IpVersion == IP_VERSION_4 && Private->Udp6Num ==0) ||
+ (IpVersion == IP_VERSION_6 && Private->Udp4Num ==0)) {
+ IkeDeleteAllSas (Private, FALSE);
+ }
- UdpSrv = IPSEC_UDP_SERVICE_FROM_LIST (Entry);
+ if (IpVersion == IP_VERSION_4) {
//
- // Find the right udp service which installed on the appointed nic handle.
+ // If has udp4 io opened on the controller, close and free it.
//
- if (UdpSrv->Input != NULL && ControllerHandle == UdpSrv->Input->UdpHandle) {
- UdpIoFreeIo (UdpSrv->Input);
- UdpSrv->Input = NULL;
+ NET_LIST_FOR_EACH_SAFE (Entry, Next, &Private->Udp4List) {
+
+ UdpSrv = IPSEC_UDP_SERVICE_FROM_LIST (Entry);
+ //
+ // Find the right udp service which installed on the appointed nic handle.
+ //
+ if (UdpSrv->Input != NULL && ControllerHandle == UdpSrv->Input->UdpHandle) {
+ UdpIoFreeIo (UdpSrv->Input);
+ UdpSrv->Input = NULL;
+ }
+
+ if (UdpSrv->Output != NULL && ControllerHandle == UdpSrv->Output->UdpHandle) {
+ UdpIoFreeIo (UdpSrv->Output);
+ UdpSrv->Output = NULL;
+ }
+
+ if (UdpSrv->Input == NULL && UdpSrv->Output == NULL) {
+ RemoveEntryList (&UdpSrv->List);
+ FreePool (UdpSrv);
+ ASSERT (Private->Udp4Num > 0);
+ Private->Udp4Num--;
+ }
}
-
- if (UdpSrv->Output != NULL && ControllerHandle == UdpSrv->Output->UdpHandle) {
- UdpIoFreeIo (UdpSrv->Output);
- UdpSrv->Output = NULL;
- }
-
- if (UdpSrv->Input == NULL && UdpSrv->Output == NULL) {
- RemoveEntryList (&UdpSrv->List);
- FreePool (UdpSrv);
- ASSERT (Private->Udp4Num > 0);
- Private->Udp4Num--;
- }
- }
- //
- // If has udp6 io opened on the controller, close and free it.
- //
- NET_LIST_FOR_EACH_SAFE (Entry, Next, &Private->Udp6List) {
-
- UdpSrv = IPSEC_UDP_SERVICE_FROM_LIST (Entry);
+ } else {
//
- // Find the right udp service which installed on the appointed nic handle.
+ // If has udp6 io opened on the controller, close and free it.
//
- if (UdpSrv->Input != NULL && ControllerHandle == UdpSrv->Input->UdpHandle) {
- UdpIoFreeIo (UdpSrv->Input);
- UdpSrv->Input = NULL;
- }
-
- if (UdpSrv->Output != NULL && ControllerHandle == UdpSrv->Output->UdpHandle) {
- UdpIoFreeIo (UdpSrv->Output);
- UdpSrv->Output = NULL;
- }
-
- if (UdpSrv->Input == NULL && UdpSrv->Output == NULL) {
- RemoveEntryList (&UdpSrv->List);
- FreePool (UdpSrv);
- ASSERT (Private->Udp6Num > 0);
- Private->Udp6Num--;
+ NET_LIST_FOR_EACH_SAFE (Entry, Next, &Private->Udp6List) {
+
+ UdpSrv = IPSEC_UDP_SERVICE_FROM_LIST (Entry);
+ //
+ // Find the right udp service which installed on the appointed nic handle.
+ //
+ if (UdpSrv->Input != NULL && ControllerHandle == UdpSrv->Input->UdpHandle) {
+ UdpIoFreeIo (UdpSrv->Input);
+ UdpSrv->Input = NULL;
+ }
+
+ if (UdpSrv->Output != NULL && ControllerHandle == UdpSrv->Output->UdpHandle) {
+ UdpIoFreeIo (UdpSrv->Output);
+ UdpSrv->Output = NULL;
+ }
+
+ if (UdpSrv->Input == NULL && UdpSrv->Output == NULL) {
+ RemoveEntryList (&UdpSrv->List);
+ FreePool (UdpSrv);
+ ASSERT (Private->Udp6Num > 0);
+ Private->Udp6Num--;
+ }
}
}
return EFI_SUCCESS;
}
-EFI_DRIVER_BINDING_PROTOCOL gIpSecDriverBinding = {
- IpSecDriverBindingSupported,
- IpSecDriverBindingStart,
- IpSecDriverBindingStop,
+/**
+ Test to see if this driver supports ControllerHandle.
+
+ @param[in] This Protocol instance pointer.
+ @param[in] ControllerHandle Handle of device to test.
+ @param[in] RemainingDevicePath Optional parameter used to pick a specific child
+ device to start.
+
+ @retval EFI_SUCCES This driver supports this device.
+ @retval EFI_ALREADY_STARTED This driver is already running on this device.
+ @retval other This driver does not support this device.
+
+**/
+EFI_STATUS
+EFIAPI
+IpSec4DriverBindingSupported (
+ IN EFI_DRIVER_BINDING_PROTOCOL *This,
+ IN EFI_HANDLE ControllerHandle,
+ IN EFI_DEVICE_PATH_PROTOCOL *RemainingDevicePath OPTIONAL
+ )
+{
+ return IpSecSupported (
+ This,
+ ControllerHandle,
+ RemainingDevicePath,
+ IP_VERSION_4
+ );
+}
+
+/**
+ Start this driver on ControllerHandle.
+
+ @param[in] This Protocol instance pointer.
+ @param[in] ControllerHandle Handle of device to bind driver to.
+ @param[in] RemainingDevicePath Optional parameter used to pick a specific child
+ device to start.
+
+ @retval EFI_SUCCES This driver is added to ControllerHandle
+ @retval EFI_ALREADY_STARTED This driver is already running on ControllerHandle
+ @retval EFI_DEVICE_ERROR The device could not be started due to a device error.
+ Currently not implemented.
+ @retval other This driver does not support this device
+
+**/
+EFI_STATUS
+EFIAPI
+IpSec4DriverBindingStart (
+ IN EFI_DRIVER_BINDING_PROTOCOL *This,
+ IN EFI_HANDLE ControllerHandle,
+ IN EFI_DEVICE_PATH_PROTOCOL *RemainingDevicePath OPTIONAL
+ )
+{
+ return IpSecStart (
+ This,
+ ControllerHandle,
+ RemainingDevicePath,
+ IP_VERSION_4
+ );
+}
+
+/**
+ Stop this driver on ControllerHandle.
+
+ @param[in] This Protocol instance pointer.
+ @param[in] ControllerHandle Handle of a device to stop the driver on.
+ @param[in] NumberOfChildren Number of Handles in ChildHandleBuffer. If the number of
+ children is zero, stop the entire bus driver.
+ @param[in] ChildHandleBuffer List of Child Handles to Stop.
+
+ @retval EFI_SUCCES This driver removed ControllerHandle.
+ @retval other This driver was not removed from this device.
+
+**/
+EFI_STATUS
+EFIAPI
+IpSec4DriverBindingStop (
+ IN EFI_DRIVER_BINDING_PROTOCOL *This,
+ IN EFI_HANDLE ControllerHandle,
+ IN UINTN NumberOfChildren,
+ IN EFI_HANDLE *ChildHandleBuffer
+ )
+{
+ return IpSecStop (
+ This,
+ ControllerHandle,
+ NumberOfChildren,
+ ChildHandleBuffer,
+ IP_VERSION_4
+ );
+}
+
+/**
+ Test to see if this driver supports ControllerHandle.
+
+ @param[in] This Protocol instance pointer.
+ @param[in] ControllerHandle Handle of device to test.
+ @param[in] RemainingDevicePath Optional parameter used to pick a specific child
+ device to start.
+
+ @retval EFI_SUCCES This driver supports this device.
+ @retval EFI_ALREADY_STARTED This driver is already running on this device.
+ @retval other This driver does not support this device.
+
+**/
+EFI_STATUS
+EFIAPI
+IpSec6DriverBindingSupported (
+ IN EFI_DRIVER_BINDING_PROTOCOL *This,
+ IN EFI_HANDLE ControllerHandle,
+ IN EFI_DEVICE_PATH_PROTOCOL *RemainingDevicePath OPTIONAL
+ )
+{
+ return IpSecSupported (
+ This,
+ ControllerHandle,
+ RemainingDevicePath,
+ IP_VERSION_6
+ );
+}
+
+/**
+ Start this driver on ControllerHandle.
+
+ @param[in] This Protocol instance pointer.
+ @param[in] ControllerHandle Handle of device to bind driver to.
+ @param[in] RemainingDevicePath Optional parameter used to pick a specific child
+ device to start.
+
+ @retval EFI_SUCCES This driver is added to ControllerHandle
+ @retval EFI_ALREADY_STARTED This driver is already running on ControllerHandle
+ @retval EFI_DEVICE_ERROR The device could not be started due to a device error.
+ Currently not implemented.
+ @retval other This driver does not support this device
+
+**/
+EFI_STATUS
+EFIAPI
+IpSec6DriverBindingStart (
+ IN EFI_DRIVER_BINDING_PROTOCOL *This,
+ IN EFI_HANDLE ControllerHandle,
+ IN EFI_DEVICE_PATH_PROTOCOL *RemainingDevicePath OPTIONAL
+ )
+{
+ return IpSecStart (
+ This,
+ ControllerHandle,
+ RemainingDevicePath,
+ IP_VERSION_6
+ );
+}
+
+/**
+ Stop this driver on ControllerHandle.
+
+ @param[in] This Protocol instance pointer.
+ @param[in] ControllerHandle Handle of a device to stop the driver on.
+ @param[in] NumberOfChildren Number of Handles in ChildHandleBuffer. If the number of
+ children is zero, stop the entire bus driver.
+ @param[in] ChildHandleBuffer List of Child Handles to Stop.
+
+ @retval EFI_SUCCES This driver removed ControllerHandle.
+ @retval other This driver was not removed from this device.
+
+**/
+EFI_STATUS
+EFIAPI
+IpSec6DriverBindingStop (
+ IN EFI_DRIVER_BINDING_PROTOCOL *This,
+ IN EFI_HANDLE ControllerHandle,
+ IN UINTN NumberOfChildren,
+ IN EFI_HANDLE *ChildHandleBuffer
+ )
+{
+ return IpSecStop (
+ This,
+ ControllerHandle,
+ NumberOfChildren,
+ ChildHandleBuffer,
+ IP_VERSION_6
+ );
+}
+
+EFI_DRIVER_BINDING_PROTOCOL gIpSec4DriverBinding = {
+ IpSec4DriverBindingSupported,
+ IpSec4DriverBindingStart,
+ IpSec4DriverBindingStop,
+ 0xa,
+ NULL,
+ NULL
+};
+
+EFI_DRIVER_BINDING_PROTOCOL gIpSec6DriverBinding = {
+ IpSec6DriverBindingSupported,
+ IpSec6DriverBindingStart,
+ IpSec6DriverBindingStop,
0xa,
NULL,
NULL
@@ -386,7 +586,7 @@ IpSecDriverEntryPoint (
Status = EfiLibInstallDriverBindingComponentName2 (
ImageHandle,
SystemTable,
- &gIpSecDriverBinding,
+ &gIpSec4DriverBinding,
ImageHandle,
&gIpSecComponentName,
&gIpSecComponentName2
@@ -395,8 +595,32 @@ IpSecDriverEntryPoint (
goto ON_UNINSTALL_IPSEC;
}
+ Status = EfiLibInstallDriverBindingComponentName2 (
+ ImageHandle,
+ SystemTable,
+ &gIpSec6DriverBinding,
+ NULL,
+ &gIpSecComponentName,
+ &gIpSecComponentName2
+ );
+ if (EFI_ERROR (Status)) {
+ goto ON_UNINSTALL_IPSEC4_DB;
+ }
+
return Status;
+ON_UNINSTALL_IPSEC4_DB:
+ gBS->UninstallMultipleProtocolInterfaces (
+ ImageHandle,
+ &gEfiDriverBindingProtocolGuid,
+ &gIpSec4DriverBinding,
+ &gEfiComponentName2ProtocolGuid,
+ &gIpSecComponentName2,
+ &gEfiComponentNameProtocolGuid,
+ &gIpSecComponentName,
+ NULL
+ );
+
ON_UNINSTALL_IPSEC:
gBS->UninstallProtocolInterface (
Private->Handle,
diff --git a/NetworkPkg/NetworkPkg.dsc b/NetworkPkg/NetworkPkg.dsc
index 3055cf675d..b5848b7e95 100644
--- a/NetworkPkg/NetworkPkg.dsc
+++ b/NetworkPkg/NetworkPkg.dsc
@@ -1,7 +1,7 @@
## @file
# UEFI 2.2 Network Module Package for All Architectures
#
-# 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
@@ -85,17 +85,18 @@
###################################################################################################
[Components]
- NetworkPkg/IpSecDxe/IpSecDxe.inf
NetworkPkg/Ip6Dxe/Ip6Dxe.inf
NetworkPkg/TcpDxe/TcpDxe.inf
NetworkPkg/Udp6Dxe/Udp6Dxe.inf
NetworkPkg/Dhcp6Dxe/Dhcp6Dxe.inf
NetworkPkg/Mtftp6Dxe/Mtftp6Dxe.inf
+ NetworkPkg/Application/IfConfig6/IfConfig6.inf
+ NetworkPkg/Application/IpsecConfig/IpSecConfig.inf
+ NetworkPkg/Application/VConfig/VConfig.inf
+
[Components.IA32, Components.X64, Components.IPF]
+ NetworkPkg/IpSecDxe/IpSecDxe.inf
NetworkPkg/IScsiDxe/IScsiDxe.inf
NetworkPkg/UefiPxeBcDxe/UefiPxeBcDxe.inf
NetworkPkg/Application/Ping6/Ping6.inf
- NetworkPkg/Application/IfConfig6/IfConfig6.inf
- NetworkPkg/Application/IpsecConfig/IpSecConfig.inf
- NetworkPkg/Application/VConfig/VConfig.inf
diff --git a/NetworkPkg/TcpDxe/TcpDriver.c b/NetworkPkg/TcpDxe/TcpDriver.c
index 74af7969f7..1f0d371654 100644
--- a/NetworkPkg/TcpDxe/TcpDriver.c
+++ b/NetworkPkg/TcpDxe/TcpDriver.c
@@ -1,7 +1,7 @@
/** @file
The driver binding and service binding protocol for the TCP 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
@@ -66,10 +66,19 @@ SOCK_INIT_DATA mTcpDefaultSockData = {
NULL,
};
-EFI_DRIVER_BINDING_PROTOCOL gTcpDriverBinding = {
- TcpDriverBindingSupported,
- TcpDriverBindingStart,
- TcpDriverBindingStop,
+EFI_DRIVER_BINDING_PROTOCOL gTcp4DriverBinding = {
+ Tcp4DriverBindingSupported,
+ Tcp4DriverBindingStart,
+ Tcp4DriverBindingStop,
+ 0xa,
+ NULL,
+ NULL
+};
+
+EFI_DRIVER_BINDING_PROTOCOL gTcp6DriverBinding = {
+ Tcp6DriverBindingSupported,
+ Tcp6DriverBindingStart,
+ Tcp6DriverBindingStop,
0xa,
NULL,
NULL
@@ -172,7 +181,7 @@ TcpDriverEntryPoint (
Status = EfiLibInstallDriverBindingComponentName2 (
ImageHandle,
SystemTable,
- &gTcpDriverBinding,
+ &gTcp4DriverBinding,
ImageHandle,
&gTcpComponentName,
&gTcpComponentName2
@@ -182,6 +191,31 @@ TcpDriverEntryPoint (
}
//
+ // Install the TCP Driver Binding Protocol
+ //
+ Status = EfiLibInstallDriverBindingComponentName2 (
+ ImageHandle,
+ SystemTable,
+ &gTcp6DriverBinding,
+ NULL,
+ &gTcpComponentName,
+ &gTcpComponentName2
+ );
+ if (EFI_ERROR (Status)) {
+ gBS->UninstallMultipleProtocolInterfaces (
+ ImageHandle,
+ &gEfiDriverBindingProtocolGuid,
+ &gTcp4DriverBinding,
+ &gEfiComponentName2ProtocolGuid,
+ &gTcpComponentName2,
+ &gEfiComponentNameProtocolGuid,
+ &gTcpComponentName,
+ NULL
+ );
+ return Status;
+ }
+
+ //
// Initialize ISS and random port.
//
Seed = NetRandomInitSeed ();
@@ -496,14 +530,13 @@ TcpDestroyService (
**/
EFI_STATUS
EFIAPI
-TcpDriverBindingSupported (
+Tcp4DriverBindingSupported (
IN EFI_DRIVER_BINDING_PROTOCOL *This,
IN EFI_HANDLE ControllerHandle,
IN EFI_DEVICE_PATH_PROTOCOL *RemainingDevicePath OPTIONAL
)
{
EFI_STATUS Status;
- BOOLEAN IsTcp4Started;
//
// Test for the Tcp4ServiceBinding Protocol
@@ -516,29 +549,114 @@ TcpDriverBindingSupported (
ControllerHandle,
EFI_OPEN_PROTOCOL_TEST_PROTOCOL
);
- if (EFI_ERROR (Status)) {
- //
- // Test for the Ip4ServiceBinding Protocol
- //
- Status = gBS->OpenProtocol (
- ControllerHandle,
- &gEfiIp4ServiceBindingProtocolGuid,
- NULL,
- This->DriverBindingHandle,
- ControllerHandle,
- EFI_OPEN_PROTOCOL_TEST_PROTOCOL
- );
- if (!EFI_ERROR (Status)) {
- return EFI_SUCCESS;
- }
+ if (!EFI_ERROR (Status)) {
+ return EFI_ALREADY_STARTED;
+ }
+
+ //
+ // Test for the Ip4ServiceBinding Protocol
+ //
+ Status = gBS->OpenProtocol (
+ ControllerHandle,
+ &gEfiIp4ServiceBindingProtocolGuid,
+ NULL,
+ This->DriverBindingHandle,
+ ControllerHandle,
+ EFI_OPEN_PROTOCOL_TEST_PROTOCOL
+ );
+ return Status;
+}
- IsTcp4Started = FALSE;
- } else {
- IsTcp4Started = TRUE;
+/**
+ Start this driver on ControllerHandle.
+
+ @param[in] This Protocol instance pointer.
+ @param[in] ControllerHandle Handle of device to bind driver to.
+ @param[in] RemainingDevicePath Optional parameter use to pick a specific child
+ device to start.
+
+ @retval EFI_SUCCESS The driver is added to ControllerHandle.
+ @retval EFI_OUT_OF_RESOURCES There are not enough resources to start the
+ driver.
+ @retval other The driver cannot be added to ControllerHandle.
+
+**/
+EFI_STATUS
+EFIAPI
+Tcp4DriverBindingStart (
+ IN EFI_DRIVER_BINDING_PROTOCOL *This,
+ IN EFI_HANDLE ControllerHandle,
+ IN EFI_DEVICE_PATH_PROTOCOL *RemainingDevicePath OPTIONAL
+ )
+{
+ EFI_STATUS Status;
+
+ Status = TcpCreateService (ControllerHandle, This->DriverBindingHandle, IP_VERSION_4);
+ if ((Status == EFI_ALREADY_STARTED) || (Status == EFI_UNSUPPORTED)) {
+ Status = EFI_SUCCESS;
}
+ return Status;
+}
+
+/**
+ Stop this driver on ControllerHandle.
+
+ @param[in] This A pointer to the EFI_DRIVER_BINDING_PROTOCOL instance.
+ @param[in] ControllerHandle A handle to the device being stopped. The handle must
+ support a bus specific I/O protocol for the driver
+ to use to stop the device.
+ @param[in] NumberOfChildren The number of child device handles in ChildHandleBuffer.
+ @param[in] ChildHandleBuffer An array of child handles to be freed. May be NULL
+ if NumberOfChildren is 0.
+
+ @retval EFI_SUCCESS The device was stopped.
+ @retval EFI_DEVICE_ERROR The device could not be stopped due to a device error.
+
+**/
+EFI_STATUS
+EFIAPI
+Tcp4DriverBindingStop (
+ IN EFI_DRIVER_BINDING_PROTOCOL *This,
+ IN EFI_HANDLE ControllerHandle,
+ IN UINTN NumberOfChildren,
+ IN EFI_HANDLE *ChildHandleBuffer OPTIONAL
+ )
+{
+ return TcpDestroyService (
+ ControllerHandle,
+ This->DriverBindingHandle,
+ NumberOfChildren,
+ ChildHandleBuffer,
+ IP_VERSION_4
+ );
+}
+
+/**
+ Test to see if this driver supports ControllerHandle.
+
+ @param[in] This Protocol instance pointer.
+ @param[in] ControllerHandle Handle of device to test.
+ @param[in] RemainingDevicePath Optional parameter use to pick a specific
+ child device to start.
+
+ @retval EFI_SUCCESS This driver supports this device.
+ @retval EFI_ALREADY_STARTED This driver is already running on this device.
+ @retval other This driver does not support this device.
+
+**/
+EFI_STATUS
+EFIAPI
+Tcp6DriverBindingSupported (
+ IN EFI_DRIVER_BINDING_PROTOCOL *This,
+ IN EFI_HANDLE ControllerHandle,
+ IN EFI_DEVICE_PATH_PROTOCOL *RemainingDevicePath OPTIONAL
+ )
+{
+ EFI_STATUS Status;
+
//
- // Check the Tcp6ServiceBinding Protocol
+ // Test for the Tcp6ServiceBinding Protocol
//
Status = gBS->OpenProtocol (
ControllerHandle,
@@ -548,26 +666,22 @@ TcpDriverBindingSupported (
ControllerHandle,
EFI_OPEN_PROTOCOL_TEST_PROTOCOL
);
- if (EFI_ERROR (Status)) {
- //
- // Test for the Ip6ServiceBinding Protocol
- //
- Status = gBS->OpenProtocol (
- ControllerHandle,
- &gEfiIp6ServiceBindingProtocolGuid,
- NULL,
- This->DriverBindingHandle,
- ControllerHandle,
- EFI_OPEN_PROTOCOL_TEST_PROTOCOL
- );
- if (!EFI_ERROR (Status)) {
- return EFI_SUCCESS;
- }
- } else if (IsTcp4Started) {
+ if (!EFI_ERROR (Status)) {
return EFI_ALREADY_STARTED;
}
-
- return EFI_UNSUPPORTED;
+
+ //
+ // Test for the Ip6ServiceBinding Protocol
+ //
+ Status = gBS->OpenProtocol (
+ ControllerHandle,
+ &gEfiIp6ServiceBindingProtocolGuid,
+ NULL,
+ This->DriverBindingHandle,
+ ControllerHandle,
+ EFI_OPEN_PROTOCOL_TEST_PROTOCOL
+ );
+ return Status;
}
/**
@@ -586,32 +700,20 @@ TcpDriverBindingSupported (
**/
EFI_STATUS
EFIAPI
-TcpDriverBindingStart (
+Tcp6DriverBindingStart (
IN EFI_DRIVER_BINDING_PROTOCOL *This,
IN EFI_HANDLE ControllerHandle,
IN EFI_DEVICE_PATH_PROTOCOL *RemainingDevicePath OPTIONAL
)
{
- EFI_STATUS Tcp4Status;
- EFI_STATUS Tcp6Status;
-
- Tcp4Status = TcpCreateService (ControllerHandle, This->DriverBindingHandle, IP_VERSION_4);
- if ((Tcp4Status == EFI_ALREADY_STARTED) || (Tcp4Status == EFI_UNSUPPORTED)) {
- Tcp4Status = EFI_SUCCESS;
- }
+ EFI_STATUS Status;
- Tcp6Status = TcpCreateService (ControllerHandle, This->DriverBindingHandle, IP_VERSION_6);
- if ((Tcp6Status == EFI_ALREADY_STARTED) || (Tcp6Status == EFI_UNSUPPORTED)) {
- Tcp6Status = EFI_SUCCESS;
+ Status = TcpCreateService (ControllerHandle, This->DriverBindingHandle, IP_VERSION_6);
+ if ((Status == EFI_ALREADY_STARTED) || (Status == EFI_UNSUPPORTED)) {
+ Status = EFI_SUCCESS;
}
- if (!EFI_ERROR (Tcp4Status) || !EFI_ERROR (Tcp6Status)) {
- return EFI_SUCCESS;
- } else if (EFI_ERROR (Tcp4Status)) {
- return Tcp4Status;
- } else {
- return Tcp6Status;
- }
+ return Status;
}
/**
@@ -631,37 +733,20 @@ TcpDriverBindingStart (
**/
EFI_STATUS
EFIAPI
-TcpDriverBindingStop (
+Tcp6DriverBindingStop (
IN EFI_DRIVER_BINDING_PROTOCOL *This,
IN EFI_HANDLE ControllerHandle,
IN UINTN NumberOfChildren,
IN EFI_HANDLE *ChildHandleBuffer OPTIONAL
)
{
- EFI_STATUS Tcp4Status;
- EFI_STATUS Tcp6Status;
-
- Tcp4Status = TcpDestroyService (
- ControllerHandle,
- This->DriverBindingHandle,
- NumberOfChildren,
- ChildHandleBuffer,
- IP_VERSION_4
- );
-
- Tcp6Status = TcpDestroyService (
- ControllerHandle,
- This->DriverBindingHandle,
- NumberOfChildren,
- ChildHandleBuffer,
- IP_VERSION_6
- );
-
- if (EFI_ERROR (Tcp4Status) && EFI_ERROR (Tcp6Status)) {
- return EFI_DEVICE_ERROR;
- } else {
- return EFI_SUCCESS;
- }
+ return TcpDestroyService (
+ ControllerHandle,
+ This->DriverBindingHandle,
+ NumberOfChildren,
+ ChildHandleBuffer,
+ IP_VERSION_6
+ );
}
/**
@@ -717,7 +802,7 @@ TcpCreateSocketCallback (
(VOID **) &This->ParentDevicePath,
TcpServiceData->DriverBindingHandle,
This->SockHandle,
- EFI_OPEN_PROTOCOL_BY_CHILD_CONTROLLER
+ EFI_OPEN_PROTOCOL_GET_PROTOCOL
);
if (EFI_ERROR (Status)) {
gBS->CloseProtocol (
@@ -766,16 +851,6 @@ TcpDestroySocketCallback (
RemoveEntryList (&This->Link);
//
- // Close the device path protocol
- //
- gBS->CloseProtocol (
- TcpServiceData->ControllerHandle,
- &gEfiDevicePathProtocolGuid,
- TcpServiceData->DriverBindingHandle,
- This->SockHandle
- );
-
- //
// Close the IP protocol.
//
gBS->CloseProtocol (
@@ -903,7 +978,7 @@ TcpServiceBindingDestroyChild (
ChildHandle,
&gEfiTcp4ProtocolGuid,
&Tcp,
- gTcpDriverBinding.DriverBindingHandle,
+ gTcp4DriverBinding.DriverBindingHandle,
ChildHandle,
EFI_OPEN_PROTOCOL_GET_PROTOCOL
);
@@ -915,7 +990,7 @@ TcpServiceBindingDestroyChild (
ChildHandle,
&gEfiTcp6ProtocolGuid,
&Tcp,
- gTcpDriverBinding.DriverBindingHandle,
+ gTcp6DriverBinding.DriverBindingHandle,
ChildHandle,
EFI_OPEN_PROTOCOL_GET_PROTOCOL
);
diff --git a/NetworkPkg/TcpDxe/TcpDriver.h b/NetworkPkg/TcpDxe/TcpDriver.h
index 3949cd1543..5208048edf 100644
--- a/NetworkPkg/TcpDxe/TcpDriver.h
+++ b/NetworkPkg/TcpDxe/TcpDriver.h
@@ -1,7 +1,7 @@
/** @file
The prototype of driver binding and service binding protocol for TCP driver.
- 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
@@ -90,7 +90,7 @@ TcpDriverEntryPoint (
**/
EFI_STATUS
EFIAPI
-TcpDriverBindingSupported (
+Tcp4DriverBindingSupported (
IN EFI_DRIVER_BINDING_PROTOCOL *This,
IN EFI_HANDLE ControllerHandle,
IN EFI_DEVICE_PATH_PROTOCOL *RemainingDevicePath OPTIONAL
@@ -112,7 +112,7 @@ TcpDriverBindingSupported (
**/
EFI_STATUS
EFIAPI
-TcpDriverBindingStart (
+Tcp4DriverBindingStart (
IN EFI_DRIVER_BINDING_PROTOCOL *This,
IN EFI_HANDLE ControllerHandle,
IN EFI_DEVICE_PATH_PROTOCOL *RemainingDevicePath OPTIONAL
@@ -135,7 +135,74 @@ TcpDriverBindingStart (
**/
EFI_STATUS
EFIAPI
-TcpDriverBindingStop (
+Tcp4DriverBindingStop (
+ IN EFI_DRIVER_BINDING_PROTOCOL *This,
+ IN EFI_HANDLE ControllerHandle,
+ IN UINTN NumberOfChildren,
+ IN EFI_HANDLE *ChildHandleBuffer OPTIONAL
+ );
+
+/**
+ Test to see if this driver supports ControllerHandle.
+
+ @param[in] This Protocol instance pointer.
+ @param[in] ControllerHandle Handle of the device to test.
+ @param[in] RemainingDevicePath Optional parameter use to pick a specific
+ child device to start.
+
+ @retval EFI_SUCCESS This driver supports this device.
+ @retval EFI_ALREADY_STARTED This driver is already running on this device.
+ @retval other This driver does not support this device.
+
+**/
+EFI_STATUS
+EFIAPI
+Tcp6DriverBindingSupported (
+ IN EFI_DRIVER_BINDING_PROTOCOL *This,
+ IN EFI_HANDLE ControllerHandle,
+ IN EFI_DEVICE_PATH_PROTOCOL *RemainingDevicePath OPTIONAL
+ );
+
+/**
+ Start this driver on ControllerHandle.
+
+ @param[in] This Protocol instance pointer.
+ @param[in] ControllerHandle Handle of device to bind driver to.
+ @param[in] RemainingDevicePath Optional parameter use to pick a specific child
+ device to start.
+
+ @retval EFI_SUCCESS The driver was added to ControllerHandle.
+ @retval EFI_OUT_OF_RESOURCES There are not enough resources to start the
+ driver.
+ @retval other The driver cannot be added to ControllerHandle.
+
+**/
+EFI_STATUS
+EFIAPI
+Tcp6DriverBindingStart (
+ IN EFI_DRIVER_BINDING_PROTOCOL *This,
+ IN EFI_HANDLE ControllerHandle,
+ IN EFI_DEVICE_PATH_PROTOCOL *RemainingDevicePath OPTIONAL
+ );
+
+/**
+ Stop this driver on ControllerHandle.
+
+ @param[in] This A pointer to the EFI_DRIVER_BINDING_PROTOCOL instance.
+ @param[in] ControllerHandle A handle to the device being stopped. The handle must
+ support a bus specific I/O protocol for the driver
+ to use to stop the device.
+ @param[in] NumberOfChildren The number of child device handles in ChildHandleBuffer.
+ @param[in] ChildHandleBuffer An array of child handles to be freed. May be NULL
+ if NumberOfChildren is 0.
+
+ @retval EFI_SUCCESS The device was stopped.
+ @retval EFI_DEVICE_ERROR The device could not be stopped due to a device error.
+
+**/
+EFI_STATUS
+EFIAPI
+Tcp6DriverBindingStop (
IN EFI_DRIVER_BINDING_PROTOCOL *This,
IN EFI_HANDLE ControllerHandle,
IN UINTN NumberOfChildren,
diff --git a/NetworkPkg/UefiPxeBcDxe/PxeBcBoot.c b/NetworkPkg/UefiPxeBcDxe/PxeBcBoot.c
index 540adee311..5bbefcee9d 100644
--- a/NetworkPkg/UefiPxeBcDxe/PxeBcBoot.c
+++ b/NetworkPkg/UefiPxeBcDxe/PxeBcBoot.c
@@ -98,6 +98,17 @@ PxeBcSelectBootPrompt (
ASSERT (!Mode->UsingIpv6);
VendorOpt = &Cache->Dhcp4.VendorOpt;
+ //
+ // According to the PXE specification 2.1, Table 2-1 PXE DHCP Options,
+ // we must not consider a boot prompt or boot menu if all of the following hold:
+ // - the PXE_DISCOVERY_CONTROL tag(6) is present inside the Vendor Options(43), and has bit 3 set
+ // - a boot file name has been presented in the initial DHCP or ProxyDHCP offer packet.
+ //
+ if (IS_DISABLE_PROMPT_MENU (VendorOpt->DiscoverCtrl) &&
+ Cache->Dhcp4.OptList[PXEBC_DHCP4_TAG_INDEX_BOOTFILE] != NULL) {
+ return EFI_ABORTED;
+ }
+
if (!IS_VALID_BOOT_PROMPT (VendorOpt->BitMap)) {
return EFI_TIMEOUT;
}
diff --git a/NetworkPkg/UefiPxeBcDxe/PxeBcDhcp4.h b/NetworkPkg/UefiPxeBcDxe/PxeBcDhcp4.h
index 37747ac74f..ee519d9ee2 100644
--- a/NetworkPkg/UefiPxeBcDxe/PxeBcDhcp4.h
+++ b/NetworkPkg/UefiPxeBcDxe/PxeBcDhcp4.h
@@ -1,7 +1,7 @@
/** @file
Functions declaration related with DHCPv4 for UefiPxeBc 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
@@ -200,7 +200,7 @@ typedef enum {
#define IS_ENABLE_USE_SERVER_LIST(x) \
(((x) & BIT (2)) == BIT (2))
-#define IS_ENABLE_BOOT_FILE_NAME(x) \
+#define IS_DISABLE_PROMPT_MENU(x) \
(((x) & BIT (3)) == BIT (3))
diff --git a/NetworkPkg/UefiPxeBcDxe/PxeBcDriver.c b/NetworkPkg/UefiPxeBcDxe/PxeBcDriver.c
index b29df68bbd..8ee831f521 100644
--- a/NetworkPkg/UefiPxeBcDxe/PxeBcDriver.c
+++ b/NetworkPkg/UefiPxeBcDxe/PxeBcDriver.c
@@ -1,7 +1,7 @@
/** @file
Driver Binding functions implementationfor for UefiPxeBc Driver.
- Copyright (c) 2007 - 2012, 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
@@ -16,10 +16,19 @@
#include "PxeBcImpl.h"
-EFI_DRIVER_BINDING_PROTOCOL gPxeBcDriverBinding = {
- PxeBcDriverBindingSupported,
- PxeBcDriverBindingStart,
- PxeBcDriverBindingStop,
+EFI_DRIVER_BINDING_PROTOCOL gPxeBcIp4DriverBinding = {
+ PxeBcIp4DriverBindingSupported,
+ PxeBcIp4DriverBindingStart,
+ PxeBcIp4DriverBindingStop,
+ 0xa,
+ NULL,
+ NULL
+};
+
+EFI_DRIVER_BINDING_PROTOCOL gPxeBcIp6DriverBinding = {
+ PxeBcIp6DriverBindingSupported,
+ PxeBcIp6DriverBindingStart,
+ PxeBcIp6DriverBindingStop,
0xa,
NULL,
NULL
@@ -1089,82 +1098,94 @@ PxeBcDriverEntryPoint (
IN EFI_SYSTEM_TABLE *SystemTable
)
{
- return EfiLibInstallDriverBindingComponentName2 (
- ImageHandle,
- SystemTable,
- &gPxeBcDriverBinding,
+ EFI_STATUS Status;
+
+ Status = EfiLibInstallDriverBindingComponentName2 (
+ ImageHandle,
+ SystemTable,
+ &gPxeBcIp4DriverBinding,
+ ImageHandle,
+ &gPxeBcComponentName,
+ &gPxeBcComponentName2
+ );
+ if (EFI_ERROR (Status)) {
+ return Status;
+ }
+
+ Status = EfiLibInstallDriverBindingComponentName2 (
+ ImageHandle,
+ SystemTable,
+ &gPxeBcIp6DriverBinding,
+ NULL,
+ &gPxeBcComponentName,
+ &gPxeBcComponentName2
+ );
+ if (EFI_ERROR (Status)) {
+ gBS->UninstallMultipleProtocolInterfaces (
ImageHandle,
+ &gEfiDriverBindingProtocolGuid,
+ &gPxeBcIp4DriverBinding,
+ &gEfiComponentName2ProtocolGuid,
+ &gPxeBcComponentName2,
+ &gEfiComponentNameProtocolGuid,
&gPxeBcComponentName,
- &gPxeBcComponentName2
+ NULL
);
-}
+ }
+ return Status;
+}
/**
- Test to see if this driver supports ControllerHandle. This service
- is called by the EFI boot service ConnectController(). In
- order to make drivers as small as possible, there are a few calling
- restrictions for this service. ConnectController() must
- follow these calling restrictions. If any other agent wishes to call
- Supported() it must also follow these calling restrictions.
+ Test to see if this driver supports ControllerHandle. This is the worker function for
+ PxeBcIp4(6)DriverBindingSupported.
@param[in] This The pointer to the driver binding protocol.
@param[in] ControllerHandle The handle of device to be tested.
@param[in] RemainingDevicePath Optional parameter used to pick a specific child
device to be started.
-
+ @param[in] IpVersion IP_VERSION_4 or IP_VERSION_6.
+
@retval EFI_SUCCESS This driver supports this device.
@retval EFI_UNSUPPORTED This driver does not support this device.
**/
EFI_STATUS
EFIAPI
-PxeBcDriverBindingSupported (
+PxeBcSupported (
IN EFI_DRIVER_BINDING_PROTOCOL *This,
IN EFI_HANDLE ControllerHandle,
- IN EFI_DEVICE_PATH_PROTOCOL *RemainingDevicePath OPTIONAL
+ IN EFI_DEVICE_PATH_PROTOCOL *RemainingDevicePath OPTIONAL,
+ IN UINT8 IpVersion
)
{
- EFI_STATUS Ip4Status;
- EFI_STATUS Ip6Status;
-
- //
- // Try to open the Mtftp4 and Dhcp4 protocol to test whether IPv4 stack is ready.
- //
- Ip4Status = gBS->OpenProtocol (
- ControllerHandle,
- &gEfiDhcp4ServiceBindingProtocolGuid,
- NULL,
- This->DriverBindingHandle,
- ControllerHandle,
- EFI_OPEN_PROTOCOL_TEST_PROTOCOL
- );
- if (!EFI_ERROR (Ip4Status)) {
- Ip4Status = gBS->OpenProtocol (
- ControllerHandle,
- &gEfiMtftp4ServiceBindingProtocolGuid,
- NULL,
- This->DriverBindingHandle,
- ControllerHandle,
- EFI_OPEN_PROTOCOL_TEST_PROTOCOL
- );
+ EFI_STATUS Status;
+ EFI_GUID *DhcpServiceBindingGuid;
+ EFI_GUID *MtftpServiceBindingGuid;
+
+ if (IpVersion == IP_VERSION_4) {
+ DhcpServiceBindingGuid = &gEfiDhcp4ServiceBindingProtocolGuid;
+ MtftpServiceBindingGuid = &gEfiMtftp4ServiceBindingProtocolGuid;
+ } else {
+ DhcpServiceBindingGuid = &gEfiDhcp6ServiceBindingProtocolGuid;
+ MtftpServiceBindingGuid = &gEfiMtftp6ServiceBindingProtocolGuid;
}
//
- // Try to open the Mtftp6 and Dhcp6 protocol to test whether IPv4 stack is ready.
+ // Try to open the Mtftp and Dhcp protocol to test whether IP stack is ready.
//
- Ip6Status = gBS->OpenProtocol (
+ Status = gBS->OpenProtocol (
ControllerHandle,
- &gEfiDhcp6ServiceBindingProtocolGuid,
+ DhcpServiceBindingGuid,
NULL,
This->DriverBindingHandle,
ControllerHandle,
EFI_OPEN_PROTOCOL_TEST_PROTOCOL
);
- if (!EFI_ERROR (Ip6Status)) {
- Ip6Status = gBS->OpenProtocol (
+ if (!EFI_ERROR (Status)) {
+ Status = gBS->OpenProtocol (
ControllerHandle,
- &gEfiMtftp6ServiceBindingProtocolGuid,
+ MtftpServiceBindingGuid,
NULL,
This->DriverBindingHandle,
ControllerHandle,
@@ -1173,28 +1194,25 @@ PxeBcDriverBindingSupported (
}
//
- // It's unsupported case if both stack are not ready.
+ // It's unsupported case if IP stack are not ready.
//
- if (EFI_ERROR (Ip4Status) && EFI_ERROR (Ip6Status)) {
+ if (EFI_ERROR (Status)) {
return EFI_UNSUPPORTED;
}
return EFI_SUCCESS;
}
-
/**
- Start this driver on ControllerHandle. This service is called by the
- EFI boot service ConnectController(). In order to make
- drivers as small as possible, there are a few calling restrictions for
- this service. ConnectController() must follow these
- calling restrictions. If any other agent wishes to call Start() it
- must also follow these calling restrictions.
+ Start this driver on ControllerHandle. This is the worker function for
+ PxeBcIp4(6)DriverBindingStart.
@param[in] This The pointer to the driver binding protocol.
@param[in] ControllerHandle The handle of device to be started.
@param[in] RemainingDevicePath Optional parameter used to pick a specific child
device to be started.
+ @param[in] IpVersion IP_VERSION_4 or IP_VERSION_6.
+
@retval EFI_SUCCESS This driver is installed to ControllerHandle.
@retval EFI_ALREADY_STARTED This driver is already running on ControllerHandle.
@@ -1203,18 +1221,19 @@ PxeBcDriverBindingSupported (
**/
EFI_STATUS
EFIAPI
-PxeBcDriverBindingStart (
+PxeBcStart (
IN EFI_DRIVER_BINDING_PROTOCOL *This,
IN EFI_HANDLE ControllerHandle,
- IN EFI_DEVICE_PATH_PROTOCOL *RemainingDevicePath OPTIONAL
+ IN EFI_DEVICE_PATH_PROTOCOL *RemainingDevicePath OPTIONAL,
+ IN UINT8 IpVersion
)
{
PXEBC_PRIVATE_DATA *Private;
EFI_STATUS Status;
- EFI_STATUS Ip4Status;
- EFI_STATUS Ip6Status;
PXEBC_PRIVATE_PROTOCOL *Id;
+ BOOLEAN FirstStart;
+ FirstStart = FALSE;
Status = gBS->OpenProtocol (
ControllerHandle,
&gEfiCallerIdGuid,
@@ -1229,6 +1248,7 @@ PxeBcDriverBindingStart (
//
Private = PXEBC_PRIVATE_DATA_FROM_ID (Id);
} else {
+ FirstStart = TRUE;
//
// If the driver has not been started yet, it should do initialization.
//
@@ -1305,17 +1325,18 @@ PxeBcDriverBindingStart (
NetLibGetSnpHandle(ControllerHandle, &Private->Snp);
}
- //
- // Try to create virtual NIC handle for IPv4.
- //
- Ip4Status = PxeBcCreateIp4Children (This, ControllerHandle, Private);
-
- //
- // Try to create virtual NIC handle for IPv6.
- //
- Ip6Status = PxeBcCreateIp6Children (This, ControllerHandle, Private);
-
- if (EFI_ERROR (Ip4Status) && EFI_ERROR (Ip6Status)) {
+ if (IpVersion == IP_VERSION_4) {
+ //
+ // Try to create virtual NIC handle for IPv4.
+ //
+ Status = PxeBcCreateIp4Children (This, ControllerHandle, Private);
+ } else {
+ //
+ // Try to create virtual NIC handle for IPv6.
+ //
+ Status = PxeBcCreateIp6Children (This, ControllerHandle, Private);
+ }
+ if (EFI_ERROR (Status)) {
//
// Failed to start PXE driver if IPv4 and IPv6 stack are both not available.
//
@@ -1326,32 +1347,38 @@ PxeBcDriverBindingStart (
return EFI_SUCCESS;
ON_ERROR:
- gBS->UninstallProtocolInterface (
- ControllerHandle,
- &gEfiCallerIdGuid,
- &Private->Id
- );
- PxeBcDestroyIp4Children (This, Private);
- PxeBcDestroyIp6Children (This, Private);
- FreePool (Private);
+ if (FirstStart) {
+ gBS->UninstallProtocolInterface (
+ ControllerHandle,
+ &gEfiCallerIdGuid,
+ &Private->Id
+ );
+ }
+
+ if (IpVersion == IP_VERSION_4) {
+ PxeBcDestroyIp4Children (This, Private);
+ } else {
+ PxeBcDestroyIp6Children (This, Private);
+ }
+
+ if (FirstStart && Private != NULL) {
+ FreePool (Private);
+ }
return Status;
}
/**
- Stop this driver on ControllerHandle. This service is called by the
- EFI boot service DisconnectController(). In order to
- make drivers as small as possible, there are a few calling
- restrictions for this service. DisconnectController()
- must follow these calling restrictions. If any other agent wishes
- to call Stop() it must also follow these calling restrictions.
+ Stop this driver on ControllerHandle. This is the worker function for
+ PxeBcIp4(6)DriverBindingStop.
@param[in] This Protocol instance pointer.
@param[in] ControllerHandle Handle of device to stop driver on.
@param[in] NumberOfChildren Number of Handles in ChildHandleBuffer. If number of
children is zero stop the entire bus driver.
@param[in] ChildHandleBuffer List of Child Handles to Stop.
+ @param[in] IpVersion IP_VERSION_4 or IP_VERSION_6.
@retval EFI_SUCCESS This driver was removed ControllerHandle.
@retval EFI_DEVICE_ERROR An unexpected system or network error occurred.
@@ -1360,11 +1387,12 @@ ON_ERROR:
**/
EFI_STATUS
EFIAPI
-PxeBcDriverBindingStop (
+PxeBcStop (
IN EFI_DRIVER_BINDING_PROTOCOL *This,
IN EFI_HANDLE ControllerHandle,
IN UINTN NumberOfChildren,
- IN EFI_HANDLE *ChildHandleBuffer
+ IN EFI_HANDLE *ChildHandleBuffer,
+ IN UINT8 IpVersion
)
{
PXEBC_PRIVATE_DATA *Private;
@@ -1394,14 +1422,13 @@ PxeBcDriverBindingStop (
//
// Get the Nic handle by any pass-over service child handle.
//
- NicHandle = PxeBcGetNicByIp4Children (ControllerHandle);
- if (NicHandle == NULL) {
+ if (IpVersion == IP_VERSION_4) {
+ NicHandle = PxeBcGetNicByIp4Children (ControllerHandle);
+ } else {
NicHandle = PxeBcGetNicByIp6Children (ControllerHandle);
- if (NicHandle == NULL) {
- return EFI_SUCCESS;
- } else {
- IsIpv6 = TRUE;
- }
+ }
+ if (NicHandle == NULL) {
+ return EFI_SUCCESS;
}
//
@@ -1439,10 +1466,6 @@ PxeBcDriverBindingStop (
VirtualNic = PXEBC_VIRTUAL_NIC_FROM_LOADFILE (LoadFile);
Private = VirtualNic->Private;
NicHandle = Private->Controller;
-
- if (Private->Ip6Nic == VirtualNic) {
- IsIpv6 = TRUE;
- }
}
//
@@ -1454,11 +1477,11 @@ PxeBcDriverBindingStop (
}
- if (Private->Ip4Nic != NULL && !IsIpv6) {
+ if (Private->Ip4Nic != NULL && IpVersion == IP_VERSION_4) {
PxeBcDestroyIp4Children (This, Private);
}
- if (Private->Ip6Nic != NULL && IsIpv6) {
+ if (Private->Ip6Nic != NULL && IpVersion == IP_VERSION_6) {
PxeBcDestroyIp6Children (This, Private);
}
@@ -1473,3 +1496,211 @@ PxeBcDriverBindingStop (
return EFI_SUCCESS;
}
+
+/**
+ Test to see if this driver supports ControllerHandle. This service
+ is called by the EFI boot service ConnectController(). In
+ order to make drivers as small as possible, there are a few calling
+ restrictions for this service. ConnectController() must
+ follow these calling restrictions. If any other agent wishes to call
+ Supported() it must also follow these calling restrictions.
+
+ @param[in] This The pointer to the driver binding protocol.
+ @param[in] ControllerHandle The handle of device to be tested.
+ @param[in] RemainingDevicePath Optional parameter used to pick a specific child
+ device to be started.
+
+ @retval EFI_SUCCESS This driver supports this device.
+ @retval EFI_UNSUPPORTED This driver does not support this device.
+
+**/
+EFI_STATUS
+EFIAPI
+PxeBcIp4DriverBindingSupported (
+ IN EFI_DRIVER_BINDING_PROTOCOL *This,
+ IN EFI_HANDLE ControllerHandle,
+ IN EFI_DEVICE_PATH_PROTOCOL *RemainingDevicePath OPTIONAL
+ )
+{
+ return PxeBcSupported (
+ This,
+ ControllerHandle,
+ RemainingDevicePath,
+ IP_VERSION_4
+ );
+}
+
+/**
+ Start this driver on ControllerHandle. This service is called by the
+ EFI boot service ConnectController(). In order to make
+ drivers as small as possible, there are a few calling restrictions for
+ this service. ConnectController() must follow these
+ calling restrictions. If any other agent wishes to call Start() it
+ must also follow these calling restrictions.
+
+ @param[in] This The pointer to the driver binding protocol.
+ @param[in] ControllerHandle The handle of device to be started.
+ @param[in] RemainingDevicePath Optional parameter used to pick a specific child
+ device to be started.
+
+ @retval EFI_SUCCESS This driver is installed to ControllerHandle.
+ @retval EFI_ALREADY_STARTED This driver is already running on ControllerHandle.
+ @retval other This driver does not support this device.
+
+**/
+EFI_STATUS
+EFIAPI
+PxeBcIp4DriverBindingStart (
+ IN EFI_DRIVER_BINDING_PROTOCOL *This,
+ IN EFI_HANDLE ControllerHandle,
+ IN EFI_DEVICE_PATH_PROTOCOL *RemainingDevicePath OPTIONAL
+ )
+{
+ return PxeBcStart (
+ This,
+ ControllerHandle,
+ RemainingDevicePath,
+ IP_VERSION_4
+ );
+}
+
+/**
+ Stop this driver on ControllerHandle. This service is called by the
+ EFI boot service DisconnectController(). In order to
+ make drivers as small as possible, there are a few calling
+ restrictions for this service. DisconnectController()
+ must follow these calling restrictions. If any other agent wishes
+ to call Stop() it must also follow these calling restrictions.
+
+ @param[in] This Protocol instance pointer.
+ @param[in] ControllerHandle Handle of device to stop driver on
+ @param[in] NumberOfChildren Number of Handles in ChildHandleBuffer. If number of
+ children is zero stop the entire bus driver.
+ @param[in] ChildHandleBuffer List of Child Handles to Stop.
+
+ @retval EFI_SUCCESS This driver is removed ControllerHandle
+ @retval EFI_DEVICE_ERROR An unexpected system or network error occurred.
+ @retval Others This driver was not removed from this device.
+
+**/
+EFI_STATUS
+EFIAPI
+PxeBcIp4DriverBindingStop (
+ IN EFI_DRIVER_BINDING_PROTOCOL *This,
+ IN EFI_HANDLE ControllerHandle,
+ IN UINTN NumberOfChildren,
+ IN EFI_HANDLE *ChildHandleBuffer
+ )
+{
+ return PxeBcStop (
+ This,
+ ControllerHandle,
+ NumberOfChildren,
+ ChildHandleBuffer,
+ IP_VERSION_4
+ );
+}
+
+/**
+ Test to see if this driver supports ControllerHandle. This service
+ is called by the EFI boot service ConnectController(). In
+ order to make drivers as small as possible, there are a few calling
+ restrictions for this service. ConnectController() must
+ follow these calling restrictions. If any other agent wishes to call
+ Supported() it must also follow these calling restrictions.
+
+ @param[in] This The pointer to the driver binding protocol.
+ @param[in] ControllerHandle The handle of device to be tested.
+ @param[in] RemainingDevicePath Optional parameter use to pick a specific child
+ device to be started.
+
+ @retval EFI_SUCCESS This driver supports this device.
+ @retval EFI_UNSUPPORTED This driver does not support this device.
+
+**/
+EFI_STATUS
+EFIAPI
+PxeBcIp6DriverBindingSupported (
+ IN EFI_DRIVER_BINDING_PROTOCOL *This,
+ IN EFI_HANDLE ControllerHandle,
+ IN EFI_DEVICE_PATH_PROTOCOL *RemainingDevicePath OPTIONAL
+ )
+{
+ return PxeBcSupported (
+ This,
+ ControllerHandle,
+ RemainingDevicePath,
+ IP_VERSION_6
+ );
+}
+
+/**
+ Start this driver on ControllerHandle. This service is called by the
+ EFI boot service ConnectController(). In order to make
+ drivers as small as possible, there are a few calling restrictions for
+ this service. ConnectController() must follow these
+ calling restrictions. If any other agent wishes to call Start() it
+ must also follow these calling restrictions.
+
+ @param[in] This The pointer to the driver binding protocol.
+ @param[in] ControllerHandle The handle of device to be started.
+ @param[in] RemainingDevicePath Optional parameter used to pick a specific child
+ device to be started.
+
+ @retval EFI_SUCCESS This driver is installed to ControllerHandle.
+ @retval EFI_ALREADY_STARTED This driver is already running on ControllerHandle.
+ @retval other This driver does not support this device.
+
+**/
+EFI_STATUS
+EFIAPI
+PxeBcIp6DriverBindingStart (
+ IN EFI_DRIVER_BINDING_PROTOCOL *This,
+ IN EFI_HANDLE ControllerHandle,
+ IN EFI_DEVICE_PATH_PROTOCOL *RemainingDevicePath OPTIONAL
+ )
+{
+ return PxeBcStart (
+ This,
+ ControllerHandle,
+ RemainingDevicePath,
+ IP_VERSION_6
+ );
+}
+
+/**
+ Stop this driver on ControllerHandle. This service is called by the
+ EFI boot service DisconnectController(). In order to
+ make drivers as small as possible, there are a few calling
+ restrictions for this service. DisconnectController()
+ must follow these calling restrictions. If any other agent wishes
+ to call Stop() it must also follow these calling restrictions.
+
+ @param[in] This Protocol instance pointer.
+ @param[in] ControllerHandle Handle of device to stop driver on
+ @param[in] NumberOfChildren Number of Handles in ChildHandleBuffer. If number of
+ children is zero stop the entire bus driver.
+ @param[in] ChildHandleBuffer List of Child Handles to Stop.
+
+ @retval EFI_SUCCESS This driver is removed ControllerHandle
+ @retval EFI_DEVICE_ERROR An unexpected system or network error occurred.
+ @retval Others This driver was not removed from this device.
+
+**/
+EFI_STATUS
+EFIAPI
+PxeBcIp6DriverBindingStop (
+ IN EFI_DRIVER_BINDING_PROTOCOL *This,
+ IN EFI_HANDLE ControllerHandle,
+ IN UINTN NumberOfChildren,
+ IN EFI_HANDLE *ChildHandleBuffer
+ )
+{
+ return PxeBcStop (
+ This,
+ ControllerHandle,
+ NumberOfChildren,
+ ChildHandleBuffer,
+ IP_VERSION_6
+ );
+}
diff --git a/NetworkPkg/UefiPxeBcDxe/PxeBcDriver.h b/NetworkPkg/UefiPxeBcDxe/PxeBcDriver.h
index 8df4bae27b..f22f0f6bb3 100644
--- a/NetworkPkg/UefiPxeBcDxe/PxeBcDriver.h
+++ b/NetworkPkg/UefiPxeBcDxe/PxeBcDriver.h
@@ -1,7 +1,7 @@
/** @file
Driver Binding functions declaration for UefiPxeBc Driver.
- 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
@@ -38,13 +38,12 @@ extern EFI_COMPONENT_NAME2_PROTOCOL gPxeBcComponentName2;
**/
EFI_STATUS
EFIAPI
-PxeBcDriverBindingSupported (
+PxeBcIp4DriverBindingSupported (
IN EFI_DRIVER_BINDING_PROTOCOL *This,
IN EFI_HANDLE ControllerHandle,
IN EFI_DEVICE_PATH_PROTOCOL *RemainingDevicePath OPTIONAL
);
-
/**
Start this driver on ControllerHandle. This service is called by the
EFI boot service ConnectController(). In order to make
@@ -65,7 +64,7 @@ PxeBcDriverBindingSupported (
**/
EFI_STATUS
EFIAPI
-PxeBcDriverBindingStart (
+PxeBcIp4DriverBindingStart (
IN EFI_DRIVER_BINDING_PROTOCOL *This,
IN EFI_HANDLE ControllerHandle,
IN EFI_DEVICE_PATH_PROTOCOL *RemainingDevicePath OPTIONAL
@@ -93,12 +92,90 @@ PxeBcDriverBindingStart (
**/
EFI_STATUS
EFIAPI
-PxeBcDriverBindingStop (
+PxeBcIp4DriverBindingStop (
IN EFI_DRIVER_BINDING_PROTOCOL *This,
IN EFI_HANDLE ControllerHandle,
IN UINTN NumberOfChildren,
IN EFI_HANDLE *ChildHandleBuffer
);
+/**
+ Test to see if this driver supports ControllerHandle. This service
+ is called by the EFI boot service ConnectController(). In
+ order to make drivers as small as possible, there are a few calling
+ restrictions for this service. ConnectController() must
+ follow these calling restrictions. If any other agent wishes to call
+ Supported() it must also follow these calling restrictions.
+
+ @param[in] This The pointer to the driver binding protocol.
+ @param[in] ControllerHandle The handle of device to be tested.
+ @param[in] RemainingDevicePath Optional parameter use to pick a specific child
+ device to be started.
+
+ @retval EFI_SUCCESS This driver supports this device.
+ @retval EFI_UNSUPPORTED This driver does not support this device.
+
+**/
+EFI_STATUS
+EFIAPI
+PxeBcIp6DriverBindingSupported (
+ IN EFI_DRIVER_BINDING_PROTOCOL *This,
+ IN EFI_HANDLE ControllerHandle,
+ IN EFI_DEVICE_PATH_PROTOCOL *RemainingDevicePath OPTIONAL
+ );
+
+/**
+ Start this driver on ControllerHandle. This service is called by the
+ EFI boot service ConnectController(). In order to make
+ drivers as small as possible, there are a few calling restrictions for
+ this service. ConnectController() must follow these
+ calling restrictions. If any other agent wishes to call Start() it
+ must also follow these calling restrictions.
+
+ @param[in] This The pointer to the driver binding protocol.
+ @param[in] ControllerHandle The handle of device to be started.
+ @param[in] RemainingDevicePath Optional parameter used to pick a specific child
+ device to be started.
+
+ @retval EFI_SUCCESS This driver is installed to ControllerHandle.
+ @retval EFI_ALREADY_STARTED This driver is already running on ControllerHandle.
+ @retval other This driver does not support this device.
+
+**/
+EFI_STATUS
+EFIAPI
+PxeBcIp6DriverBindingStart (
+ IN EFI_DRIVER_BINDING_PROTOCOL *This,
+ IN EFI_HANDLE ControllerHandle,
+ IN EFI_DEVICE_PATH_PROTOCOL *RemainingDevicePath OPTIONAL
+ );
+
+/**
+ Stop this driver on ControllerHandle. This service is called by the
+ EFI boot service DisconnectController(). In order to
+ make drivers as small as possible, there are a few calling
+ restrictions for this service. DisconnectController()
+ must follow these calling restrictions. If any other agent wishes
+ to call Stop() it must also follow these calling restrictions.
+
+ @param[in] This Protocol instance pointer.
+ @param[in] ControllerHandle Handle of device to stop driver on
+ @param[in] NumberOfChildren Number of Handles in ChildHandleBuffer. If number of
+ children is zero stop the entire bus driver.
+ @param[in] ChildHandleBuffer List of Child Handles to Stop.
+
+ @retval EFI_SUCCESS This driver is removed ControllerHandle
+ @retval EFI_DEVICE_ERROR An unexpected system or network error occurred.
+ @retval Others This driver was not removed from this device.
+
+**/
+EFI_STATUS
+EFIAPI
+PxeBcIp6DriverBindingStop (
+ IN EFI_DRIVER_BINDING_PROTOCOL *This,
+ IN EFI_HANDLE ControllerHandle,
+ IN UINTN NumberOfChildren,
+ IN EFI_HANDLE *ChildHandleBuffer
+ );
#endif
diff --git a/NetworkPkg/UefiPxeBcDxe/UefiPxeBcDxe.inf b/NetworkPkg/UefiPxeBcDxe/UefiPxeBcDxe.inf
index 1e690b882f..51c046cef6 100644
--- a/NetworkPkg/UefiPxeBcDxe/UefiPxeBcDxe.inf
+++ b/NetworkPkg/UefiPxeBcDxe/UefiPxeBcDxe.inf
@@ -1,7 +1,7 @@
## @file
# Component name for module PxeBc
#
-# 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
@@ -63,11 +63,6 @@
DevicePathLib
PcdLib
-
-[Guids]
- gEfiSmbiosTableGuid
-
-
[Protocols]
gEfiDevicePathProtocolGuid
gEfiNetworkInterfaceIdentifierProtocolGuid_31
diff --git a/OptionRomPkg/OptionRomPkg.dsc b/OptionRomPkg/OptionRomPkg.dsc
index 522038f280..4fdcf6d9b3 100644
--- a/OptionRomPkg/OptionRomPkg.dsc
+++ b/OptionRomPkg/OptionRomPkg.dsc
@@ -6,7 +6,7 @@
# Option ROM image for all CPU architectures, including EBC target.
# A single driver can support mixes of EFI 1.1, UEFI 2.0 and UEFI 2.1.
#
-# 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
@@ -101,9 +101,9 @@
OptionRomPkg/Library/FrameBufferBltLib/FrameBufferBltLib.inf
OptionRomPkg/Library/GopBltLib/GopBltLib.inf
- OptionRomPkg/Application/BltLibSample/BltLibSample.inf
-
OptionRomPkg/AtapiPassThruDxe/AtapiPassThruDxe.inf
OptionRomPkg/CirrusLogic5430Dxe/CirrusLogic5430Dxe.inf
OptionRomPkg/UndiRuntimeDxe/UndiRuntimeDxe.inf
+[Components.IA32, Components.X64, Components.IPF]
+ OptionRomPkg/Application/BltLibSample/BltLibSample.inf
diff --git a/OvmfPkg/Include/Library/VirtioLib.h b/OvmfPkg/Include/Library/VirtioLib.h
index 448dd2b578..51303491d0 100644
--- a/OvmfPkg/Include/Library/VirtioLib.h
+++ b/OvmfPkg/Include/Library/VirtioLib.h
@@ -140,8 +140,8 @@ VirtioRingUninit (
// request.
//
typedef struct {
- UINT16 HeadIdx;
- UINT16 NextAvailIdx;
+ UINT16 HeadDescIdx;
+ UINT16 NextDescIdx;
} DESC_INDICES;
@@ -152,7 +152,7 @@ typedef struct {
The calling driver must be in VSTAT_DRIVER_OK state.
- @param[in out] Ring The virtio ring we intend to append descriptors to.
+ @param[in,out] Ring The virtio ring we intend to append descriptors to.
@param[out] Indices The DESC_INDICES structure to initialize.
@@ -169,9 +169,8 @@ VirtioPrepare (
Append a contiguous buffer for transmission / reception via the virtio ring.
- This function implements the following sections from virtio-0.9.5:
+ This function implements the following section from virtio-0.9.5:
- 2.4.1.1 Placing Buffers into the Descriptor Table
- - 2.4.1.2 Updating the Available Ring
Free space is taken as granted, since the individual drivers support only
synchronous requests and host side status is processed in lock-step with
@@ -181,31 +180,26 @@ VirtioPrepare (
The caller is responsible for initializing *Indices with VirtioPrepare()
first.
- @param[in out] Ring The virtio ring to append the buffer to, as a
- descriptor.
+ @param[in,out] Ring The virtio ring to append the buffer to, as a
+ descriptor.
- @param [in] BufferPhysAddr (Guest pseudo-physical) start address of the
- transmit / receive buffer.
+ @param[in] BufferPhysAddr (Guest pseudo-physical) start address of the
+ transmit / receive buffer.
- @param [in] BufferSize Number of bytes to transmit or receive.
+ @param[in] BufferSize Number of bytes to transmit or receive.
- @param [in] Flags A bitmask of VRING_DESC_F_* flags. The caller
- computes this mask dependent on further buffers
- to append and transfer direction.
- VRING_DESC_F_INDIRECT is unsupported. The
- VRING_DESC.Next field is always set, but the
- host only interprets it dependent on
- VRING_DESC_F_NEXT.
+ @param[in] Flags A bitmask of VRING_DESC_F_* flags. The caller
+ computes this mask dependent on further buffers to
+ append and transfer direction.
+ VRING_DESC_F_INDIRECT is unsupported. The
+ VRING_DESC.Next field is always set, but the host
+ only interprets it dependent on VRING_DESC_F_NEXT.
- In *Indices:
-
- @param [in] HeadIdx The index identifying the head buffer (first
- buffer appended) belonging to this same
- request.
-
- @param [in out] NextAvailIdx On input, the index identifying the next
- descriptor available to carry the buffer. On
- output, incremented by one, modulo 2^16.
+ @param[in,out] Indices Indices->HeadDescIdx is not accessed.
+ On input, Indices->NextDescIdx identifies the next
+ descriptor to carry the buffer. On output,
+ Indices->NextDescIdx is incremented by one, modulo
+ 2^16.
**/
VOID
@@ -221,17 +215,18 @@ VirtioAppendDesc (
/**
- Notify the host about appended descriptors and wait until it processes the
- last one (ie. all of them).
+ 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] VirtQueueId Identifies the queue for the target device.
- @param[in out] Ring The virtio ring with descriptors to submit.
+ @param[in,out] Ring The virtio ring with descriptors to submit.
- @param[in] Indices The function waits until the host processes
- descriptors up to Indices->NextAvailIdx.
+ @param[in] Indices Indices->NextDescIdx is not accessed.
+ Indices->HeadDescIdx identifies the head descriptor
+ of the descriptor chain.
@return Error code from VirtioWrite() if it fails.
diff --git a/OvmfPkg/Library/PlatformBdsLib/QemuBootOrder.c b/OvmfPkg/Library/PlatformBdsLib/QemuBootOrder.c
index d2d60c389f..9f94e2424a 100644
--- a/OvmfPkg/Library/PlatformBdsLib/QemuBootOrder.c
+++ b/OvmfPkg/Library/PlatformBdsLib/QemuBootOrder.c
@@ -677,6 +677,35 @@ TranslateOfwNodes (
TargetLun[0],
TargetLun[1]
);
+ } else if (NumNodes >= 3 &&
+ SubstringEq (OfwNode[1].DriverName, "ethernet") &&
+ SubstringEq (OfwNode[2].DriverName, "ethernet-phy")
+ ) {
+ //
+ // OpenFirmware device path (Ethernet NIC):
+ //
+ // /pci@i0cf8/ethernet@3[,2]/ethernet-phy@0
+ // ^ ^ ^
+ // | | fixed
+ // | PCI slot[, function] holding Ethernet card
+ // PCI root at system bus port, PIO
+ //
+ // UEFI device path prefix (dependent on presence of nonzero PCI function):
+ //
+ // PciRoot(0x0)/Pci(0x3,0x0)/MAC(525400E15EEF,0x1)
+ // PciRoot(0x0)/Pci(0x3,0x2)/MAC(525400E15EEF,0x1)
+ // ^ ^
+ // MAC address IfType (1 == Ethernet)
+ //
+ // (Some UEFI NIC drivers don't set 0x1 for IfType.)
+ //
+ Written = UnicodeSPrintAsciiFormat (
+ Translated,
+ *TranslatedSize * sizeof (*Translated), // BufferSize in bytes
+ "PciRoot(0x0)/Pci(0x%x,0x%x)/MAC",
+ PciDevFun[0],
+ PciDevFun[1]
+ );
} else {
return RETURN_UNSUPPORTED;
}
diff --git a/OvmfPkg/Library/SerializeVariablesLib/SerializeVariablesLib.c b/OvmfPkg/Library/SerializeVariablesLib/SerializeVariablesLib.c
index 112f20e052..19569b2ae0 100644
--- a/OvmfPkg/Library/SerializeVariablesLib/SerializeVariablesLib.c
+++ b/OvmfPkg/Library/SerializeVariablesLib/SerializeVariablesLib.c
@@ -284,13 +284,26 @@ IterateVariablesCallbackSetSystemVariable (
IN VOID *Data
)
{
- return gRT->SetVariable (
- VariableName,
- VendorGuid,
- Attributes,
- DataSize,
- Data
- );
+ EFI_STATUS Status;
+ STATIC CONST UINT32 AuthMask =
+ EFI_VARIABLE_AUTHENTICATED_WRITE_ACCESS |
+ EFI_VARIABLE_TIME_BASED_AUTHENTICATED_WRITE_ACCESS;
+
+ Status = gRT->SetVariable (
+ VariableName,
+ VendorGuid,
+ Attributes,
+ DataSize,
+ Data
+ );
+
+ if (Status == EFI_SECURITY_VIOLATION && (Attributes & AuthMask) != 0) {
+ DEBUG ((DEBUG_WARN, "%a: setting authenticated variable \"%s\" "
+ "failed with EFI_SECURITY_VIOLATION, ignoring\n", __FUNCTION__,
+ VariableName));
+ Status = EFI_SUCCESS;
+ }
+ return Status;
}
diff --git a/OvmfPkg/Library/VirtioLib/VirtioLib.c b/OvmfPkg/Library/VirtioLib/VirtioLib.c
index 8398c9db4c..87797e10e7 100644
--- a/OvmfPkg/Library/VirtioLib/VirtioLib.c
+++ b/OvmfPkg/Library/VirtioLib/VirtioLib.c
@@ -285,7 +285,7 @@ VirtioRingUninit (
The calling driver must be in VSTAT_DRIVER_OK state.
- @param[in out] Ring The virtio ring we intend to append descriptors to.
+ @param[in,out] Ring The virtio ring we intend to append descriptors to.
@param[out] Indices The DESC_INDICES structure to initialize.
@@ -306,8 +306,11 @@ VirtioPrepare (
//
// Prepare for virtio-0.9.5, 2.4.1 Supplying Buffers to the Device.
//
- Indices->HeadIdx = *Ring->Avail.Idx;
- Indices->NextAvailIdx = Indices->HeadIdx;
+ // Since we support only one in-flight descriptor chain, we can always build
+ // that chain starting at entry #0 of the descriptor table.
+ //
+ Indices->HeadDescIdx = 0;
+ Indices->NextDescIdx = Indices->HeadDescIdx;
}
@@ -315,9 +318,8 @@ VirtioPrepare (
Append a contiguous buffer for transmission / reception via the virtio ring.
- This function implements the following sections from virtio-0.9.5:
+ This function implements the following section from virtio-0.9.5:
- 2.4.1.1 Placing Buffers into the Descriptor Table
- - 2.4.1.2 Updating the Available Ring
Free space is taken as granted, since the individual drivers support only
synchronous requests and host side status is processed in lock-step with
@@ -327,31 +329,26 @@ VirtioPrepare (
The caller is responsible for initializing *Indices with VirtioPrepare()
first.
- @param[in out] Ring The virtio ring to append the buffer to, as a
- descriptor.
-
- @param [in] BufferPhysAddr (Guest pseudo-physical) start address of the
- transmit / receive buffer.
+ @param[in,out] Ring The virtio ring to append the buffer to, as a
+ descriptor.
- @param [in] BufferSize Number of bytes to transmit or receive.
+ @param[in] BufferPhysAddr (Guest pseudo-physical) start address of the
+ transmit / receive buffer.
- @param [in] Flags A bitmask of VRING_DESC_F_* flags. The caller
- computes this mask dependent on further buffers
- to append and transfer direction.
- VRING_DESC_F_INDIRECT is unsupported. The
- VRING_DESC.Next field is always set, but the
- host only interprets it dependent on
- VRING_DESC_F_NEXT.
+ @param[in] BufferSize Number of bytes to transmit or receive.
- In *Indices:
+ @param[in] Flags A bitmask of VRING_DESC_F_* flags. The caller
+ computes this mask dependent on further buffers to
+ append and transfer direction.
+ VRING_DESC_F_INDIRECT is unsupported. The
+ VRING_DESC.Next field is always set, but the host
+ only interprets it dependent on VRING_DESC_F_NEXT.
- @param [in] HeadIdx The index identifying the head buffer (first
- buffer appended) belonging to this same
- request.
-
- @param [in out] NextAvailIdx On input, the index identifying the next
- descriptor available to carry the buffer. On
- output, incremented by one, modulo 2^16.
+ @param[in,out] Indices Indices->HeadDescIdx is not accessed.
+ On input, Indices->NextDescIdx identifies the next
+ descriptor to carry the buffer. On output,
+ Indices->NextDescIdx is incremented by one, modulo
+ 2^16.
**/
VOID
@@ -366,29 +363,28 @@ VirtioAppendDesc (
{
volatile VRING_DESC *Desc;
- Desc = &Ring->Desc[Indices->NextAvailIdx % Ring->QueueSize];
+ Desc = &Ring->Desc[Indices->NextDescIdx++ % Ring->QueueSize];
Desc->Addr = BufferPhysAddr;
Desc->Len = BufferSize;
Desc->Flags = Flags;
- Ring->Avail.Ring[Indices->NextAvailIdx++ % Ring->QueueSize] =
- Indices->HeadIdx % Ring->QueueSize;
- Desc->Next = Indices->NextAvailIdx % Ring->QueueSize;
+ Desc->Next = Indices->NextDescIdx % Ring->QueueSize;
}
/**
- Notify the host about appended descriptors and wait until it processes the
- last one (ie. all of them).
+ 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] VirtQueueId Identifies the queue for the target device.
- @param[in out] Ring The virtio ring with descriptors to submit.
+ @param[in,out] Ring The virtio ring with descriptors to submit.
- @param[in] Indices The function waits until the host processes
- descriptors up to Indices->NextAvailIdx.
+ @param[in] Indices Indices->NextDescIdx is not accessed.
+ Indices->HeadDescIdx identifies the head descriptor
+ of the descriptor chain.
@return Error code from VirtioWrite() if it fails.
@@ -405,14 +401,26 @@ VirtioFlush (
IN DESC_INDICES *Indices
)
{
+ UINT16 NextAvailIdx;
EFI_STATUS Status;
UINTN PollPeriodUsecs;
//
+ // virtio-0.9.5, 2.4.1.2 Updating the Available Ring
+ //
+ // It is not exactly clear from the wording of the virtio-0.9.5
+ // specification, but each entry in the Available Ring references only the
+ // head descriptor of any given descriptor chain.
+ //
+ NextAvailIdx = *Ring->Avail.Idx;
+ Ring->Avail.Ring[NextAvailIdx++ % Ring->QueueSize] =
+ Indices->HeadDescIdx % Ring->QueueSize;
+
+ //
// virtio-0.9.5, 2.4.1.3 Updating the Index Field
//
MemoryFence();
- *Ring->Avail.Idx = Indices->NextAvailIdx;
+ *Ring->Avail.Idx = NextAvailIdx;
//
// virtio-0.9.5, 2.4.1.4 Notifying the Device -- gratuitous notifications are
@@ -439,7 +447,7 @@ VirtioFlush (
//
PollPeriodUsecs = 1;
MemoryFence();
- while (*Ring->Used.Idx != Indices->NextAvailIdx) {
+ while (*Ring->Used.Idx != NextAvailIdx) {
gBS->Stall (PollPeriodUsecs); // calls AcpiTimerLib::MicroSecondDelay
if (PollPeriodUsecs < 1024) {
diff --git a/OvmfPkg/OvmfPkgIa32.dsc b/OvmfPkg/OvmfPkgIa32.dsc
index c99cee3965..0e6d1879b5 100644
--- a/OvmfPkg/OvmfPkgIa32.dsc
+++ b/OvmfPkg/OvmfPkgIa32.dsc
@@ -467,7 +467,6 @@
#
# Network Support
#
-!if $(NETWORK_ENABLE)
MdeModulePkg/Universal/Network/SnpDxe/SnpDxe.inf
MdeModulePkg/Universal/Network/DpcDxe/DpcDxe.inf
MdeModulePkg/Universal/Network/MnpDxe/MnpDxe.inf
@@ -481,7 +480,6 @@
MdeModulePkg/Universal/Network/Udp4Dxe/Udp4Dxe.inf
MdeModulePkg/Universal/Network/UefiPxeBcDxe/UefiPxeBcDxe.inf
MdeModulePkg/Universal/Network/IScsiDxe/IScsiDxe.inf
-!endif
#
# Usb Support
diff --git a/OvmfPkg/OvmfPkgIa32.fdf b/OvmfPkg/OvmfPkgIa32.fdf
index 8861980b9d..4665b9e1bd 100644
--- a/OvmfPkg/OvmfPkgIa32.fdf
+++ b/OvmfPkg/OvmfPkgIa32.fdf
@@ -249,10 +249,11 @@ FILE FREEFORM = PCD(gEfiIntelFrameworkModulePkgTokenSpaceGuid.PcdLogoFile) {
#
# Network modules
#
-!if $(NETWORK_ENABLE)
+!if $(E1000_ENABLE)
FILE DRIVER = 5D695E11-9B3F-4b83-B25F-4A8D5D69BE07 {
SECTION PE32 = Intel3.5/EFI32/E3507E2.EFI
}
+!endif
INF MdeModulePkg/Universal/Network/SnpDxe/SnpDxe.inf
INF MdeModulePkg/Universal/Network/DpcDxe/DpcDxe.inf
INF MdeModulePkg/Universal/Network/MnpDxe/MnpDxe.inf
@@ -266,7 +267,6 @@ FILE FREEFORM = PCD(gEfiIntelFrameworkModulePkgTokenSpaceGuid.PcdLogoFile) {
INF MdeModulePkg/Universal/Network/Udp4Dxe/Udp4Dxe.inf
INF MdeModulePkg/Universal/Network/UefiPxeBcDxe/UefiPxeBcDxe.inf
INF MdeModulePkg/Universal/Network/IScsiDxe/IScsiDxe.inf
-!endif
#
# Usb Support
diff --git a/OvmfPkg/OvmfPkgIa32X64.dsc b/OvmfPkg/OvmfPkgIa32X64.dsc
index 9173aae70e..48da5328e0 100644
--- a/OvmfPkg/OvmfPkgIa32X64.dsc
+++ b/OvmfPkg/OvmfPkgIa32X64.dsc
@@ -474,7 +474,6 @@
#
# Network Support
#
-!if $(NETWORK_ENABLE)
MdeModulePkg/Universal/Network/SnpDxe/SnpDxe.inf
MdeModulePkg/Universal/Network/DpcDxe/DpcDxe.inf
MdeModulePkg/Universal/Network/MnpDxe/MnpDxe.inf
@@ -488,7 +487,6 @@
MdeModulePkg/Universal/Network/Udp4Dxe/Udp4Dxe.inf
MdeModulePkg/Universal/Network/UefiPxeBcDxe/UefiPxeBcDxe.inf
MdeModulePkg/Universal/Network/IScsiDxe/IScsiDxe.inf
-!endif
#
# Usb Support
diff --git a/OvmfPkg/OvmfPkgIa32X64.fdf b/OvmfPkg/OvmfPkgIa32X64.fdf
index 93a36b7cca..177c880d4b 100644
--- a/OvmfPkg/OvmfPkgIa32X64.fdf
+++ b/OvmfPkg/OvmfPkgIa32X64.fdf
@@ -249,10 +249,11 @@ FILE FREEFORM = PCD(gEfiIntelFrameworkModulePkgTokenSpaceGuid.PcdLogoFile) {
#
# Network modules
#
-!if $(NETWORK_ENABLE)
+!if $(E1000_ENABLE)
FILE DRIVER = 5D695E11-9B3F-4b83-B25F-4A8D5D69BE07 {
SECTION PE32 = Intel3.5/EFIX64/E3507X2.EFI
}
+!endif
INF MdeModulePkg/Universal/Network/SnpDxe/SnpDxe.inf
INF MdeModulePkg/Universal/Network/DpcDxe/DpcDxe.inf
INF MdeModulePkg/Universal/Network/MnpDxe/MnpDxe.inf
@@ -266,7 +267,6 @@ FILE FREEFORM = PCD(gEfiIntelFrameworkModulePkgTokenSpaceGuid.PcdLogoFile) {
INF MdeModulePkg/Universal/Network/Udp4Dxe/Udp4Dxe.inf
INF MdeModulePkg/Universal/Network/UefiPxeBcDxe/UefiPxeBcDxe.inf
INF MdeModulePkg/Universal/Network/IScsiDxe/IScsiDxe.inf
-!endif
#
# Usb Support
diff --git a/OvmfPkg/OvmfPkgX64.dsc b/OvmfPkg/OvmfPkgX64.dsc
index dce9ce1086..7f138ce48d 100644
--- a/OvmfPkg/OvmfPkgX64.dsc
+++ b/OvmfPkg/OvmfPkgX64.dsc
@@ -472,7 +472,6 @@
#
# Network Support
#
-!if $(NETWORK_ENABLE)
MdeModulePkg/Universal/Network/SnpDxe/SnpDxe.inf
MdeModulePkg/Universal/Network/DpcDxe/DpcDxe.inf
MdeModulePkg/Universal/Network/MnpDxe/MnpDxe.inf
@@ -486,7 +485,6 @@
MdeModulePkg/Universal/Network/Udp4Dxe/Udp4Dxe.inf
MdeModulePkg/Universal/Network/UefiPxeBcDxe/UefiPxeBcDxe.inf
MdeModulePkg/Universal/Network/IScsiDxe/IScsiDxe.inf
-!endif
#
# Usb Support
diff --git a/OvmfPkg/OvmfPkgX64.fdf b/OvmfPkg/OvmfPkgX64.fdf
index d023cb19b0..1d3ba8e52f 100644
--- a/OvmfPkg/OvmfPkgX64.fdf
+++ b/OvmfPkg/OvmfPkgX64.fdf
@@ -249,10 +249,11 @@ FILE FREEFORM = PCD(gEfiIntelFrameworkModulePkgTokenSpaceGuid.PcdLogoFile) {
#
# Network modules
#
-!if $(NETWORK_ENABLE)
+!if $(E1000_ENABLE)
FILE DRIVER = 5D695E11-9B3F-4b83-B25F-4A8D5D69BE07 {
SECTION PE32 = Intel3.5/EFIX64/E3507X2.EFI
}
+!endif
INF MdeModulePkg/Universal/Network/SnpDxe/SnpDxe.inf
INF MdeModulePkg/Universal/Network/DpcDxe/DpcDxe.inf
INF MdeModulePkg/Universal/Network/MnpDxe/MnpDxe.inf
@@ -266,7 +267,6 @@ FILE FREEFORM = PCD(gEfiIntelFrameworkModulePkgTokenSpaceGuid.PcdLogoFile) {
INF MdeModulePkg/Universal/Network/Udp4Dxe/Udp4Dxe.inf
INF MdeModulePkg/Universal/Network/UefiPxeBcDxe/UefiPxeBcDxe.inf
INF MdeModulePkg/Universal/Network/IScsiDxe/IScsiDxe.inf
-!endif
#
# Usb Support
diff --git a/OvmfPkg/README b/OvmfPkg/README
index 0c0a81a670..13058eae47 100644
--- a/OvmfPkg/README
+++ b/OvmfPkg/README
@@ -66,13 +66,30 @@ http://sourceforge.net/apps/mediawiki/tianocore/index.php?title=How_to_build_OVM
(qemu-system-x86_64 works for the IA32 firmware as well, of course.)
* Use the QEMU -L parameter to specify the directory where the bios.bin
file is located.
-* Optionally you can use the QEMU -serial command to capture the
- OVMF debug messages. For example: -serial file:serial.log
* The EFI shell is built into OVMF builds at this time, so it should
run automatically if a UEFI boot application is not found on the
removable media.
* On Linux, newer version of QEMU may enable KVM feature, and this might
cause OVMF to fail to boot. The QEMU '-no-kvm' may allow OVMF to boot.
+* Capturing OVMF debug messages on qemu:
+ - The default OVMF build writes debug messages to IO port 0x402. The
+ following qemu command line options save them in the file called
+ debug.log: '-debugcon file:debug.log -global isa-debugcon.iobase=0x402'.
+ - It is possible to revert to the original behavior, when debug messages were
+ written to the emulated serial port (potentially intermixing OVMF debug
+ output with UEFI serial console output). For this the
+ '-D DEBUG_ON_SERIAL_PORT' option has to be passed to the build command (see
+ the next section), and in order to capture the serial output qemu needs to
+ be started with eg. '-serial file:serial.log'.
+ - Debug messages fall into several categories. Logged vs. suppressed
+ categories are controlled at OVMF build time by the
+ 'gEfiMdePkgTokenSpaceGuid.PcdDebugPrintErrorLevel' bitmask (an UINT32
+ value) in the selected .dsc file. Individual bits of this bitmask are
+ defined in <MdePkg/Include/Library/DebugLib.h>. One non-default bit (with
+ some performance impact) that is frequently set for debugging is 0x00400000
+ (DEBUG_VERBOSE).
+ - The RELEASE build target ('-b RELEASE' build option, see below) disables
+ all debug messages. The default build target is DEBUG.
=== Build Scripts ===
@@ -86,36 +103,70 @@ $ OvmfPkg/build.sh -a X64 qemu
And to run a 64-bit UEFI bootable ISO image:
$ OvmfPkg/build.sh -a X64 qemu -cdrom /path/to/disk-image.iso
-To build a 32-bit OVMF without debug serial messages using GCC 4.5:
+To build a 32-bit OVMF without debug messages using GCC 4.5:
$ OvmfPkg/build.sh -a IA32 -b RELEASE -t GCC45
=== Network Support ===
-To add network drivers to OVMF:
-
-* Download UEFI drivers for the e1000 NIC
- - http://downloadcenter.intel.com/Detail_Desc.aspx?agr=Y&DwnldID=17515&lang=eng
- - Install the drivers into a directory called Intel3.5 in your WORKSPACE
-
-* Include the drivers in OVMF during the build:
- - Add '-D NETWORK_ENABLE' to your build command
- - For example: build -D NETWORK_ENABLE
-
-* Use the QEMU -net parameter to enable NIC support.
- - QEMU does not support UEFI DHCP or UEFI PXE Boot, so long timeouts will
- occur when NICs are enabled. The long timeouts can be avoided by
- interrupts the boot sequence by pressing a key when the logo appears.
- - Example: Enable e1000 NIC with a DHCP server and restrict packet
- forwarding:
- -net nic,model=e1000 -net user,restrict=yes -net user,dhcpstart=10.0.2.10
- - Example: Enable e1000 NIC with a DHCP server, restrict packet forwarding,
- and generate PCAP file:
- -net nic,model=e1000 -net user,restrict=yes -net user,dhcpstart=10.0.2.10
- -net dump,file=a.pcap
- - Example: Enable 2 e1000 NICs with a DHCP server and restrict
- packet forwarding:
- -net nic,model=e1000,addr=3 -net nic,model=e1000,addr=4
- -net user,restrict=yes -net user,dhcpstart=10.0.2.10
+OVMF provides a generic UEFI network stack by default, with the lowest level
+driver (the NIC driver) missing in the default build. In order to complete the
+stack and make eg. DHCP, PXE Boot, and socket test utilities from the StdLib
+edk2 package work, (1) qemu has to be configured to emulate a NIC, (2) a
+matching UEFI NIC driver must be available when OVMF boots.
+
+(If a NIC is configured for the virtual machine, and -- dependent on boot order
+-- PXE booting is attempted, but no DHCP server responds to OVMF's DHCP
+DISCOVER message at startup, the boot process may take approx. 3 seconds
+longer.)
+
+* For each NIC emulated by qemu, a GPLv2 licensed UEFI driver is available from
+ the iPXE project. The qemu source distribution, starting with version 1.5,
+ contains prebuilt binaries of these drivers (and of course allows one to
+ rebuild them from source as well).
+
+* Use the qemu -netdev and -device options, or the legacy -net option, to
+ enable NIC support: <http://wiki.qemu.org/Documentation/Networking>.
+
+* For a qemu >= 1.5 binary running *without* any "-M machine" option where
+ "machine" would identify a < qemu-1.5 configuration (for example: "-M
+ pc-i440fx-1.4" or "-M pc-0.13"), the drivers are available from the default
+ qemu installation to OVMF without further settings.
+
+* For a qemu binary in [0.13, 1.5), or a qemu >= 1.5 binary with an "-M
+ machine" option where "machine" selects a < qemu-1.5 configuration:
+
+ - download a >= 1.5.0-rc1 source tarball from <http://wiki.qemu.org/Download>,
+
+ - extract the following files from the tarball and install them in a
+ location that is accessible to qemu processes (this may depend on your
+ SELinux configuration, for example):
+
+ qemu-VERSION/pc-bios/efi-e1000.rom
+ qemu-VERSION/pc-bios/efi-ne2k_pci.rom
+ qemu-VERSION/pc-bios/efi-pcnet.rom
+ qemu-VERSION/pc-bios/efi-rtl8139.rom
+ qemu-VERSION/pc-bios/efi-virtio.rom
+
+ - extend the NIC's -device option on the qemu command line with a matching
+ "romfile=" optarg:
+
+ -device e1000,...,romfile=/full/path/to/efi-e1000.rom
+ -device ne2k_pci,...,romfile=/full/path/to/efi-ne2k_pci.rom
+ -device pcnet,...,romfile=/full/path/to/efi-pcnet.rom
+ -device rtl8139,...,romfile=/full/path/to/efi-rtl8139.rom
+ -device virtio-net-pci,...,romfile=/full/path/to/efi-virtio.rom
+
+* Independently of the iPXE NIC drivers, Intel's proprietary E1000 NIC driver
+ can be embedded in the OVMF image at build time, as an alternative guest
+ driver for "-device e1000":
+
+ - Download UEFI drivers for the e1000 NIC
+ - http://downloadcenter.intel.com/Detail_Desc.aspx?agr=Y&DwnldID=17515&lang=eng
+ - Install the drivers into a directory called Intel3.5 in your WORKSPACE.
+
+ - Include the driver in OVMF during the build:
+ - Add "-D E1000_ENABLE -D FD_SIZE_2MB" to your build command,
+ - For example: "build -D E1000_ENABLE -D FD_SIZE_2MB".
=== UNIXGCC Debug ===
diff --git a/PandaBoardPkg/Include/PandaBoard.h b/PandaBoardPkg/Include/PandaBoard.h
index 3f806e8e21..3f806e8e21 100755..100644
--- a/PandaBoardPkg/Include/PandaBoard.h
+++ b/PandaBoardPkg/Include/PandaBoard.h
diff --git a/PandaBoardPkg/Library/PandaBoardLib/Clock.c b/PandaBoardPkg/Library/PandaBoardLib/Clock.c
index 6e3ffbf47b..6e3ffbf47b 100755..100644
--- a/PandaBoardPkg/Library/PandaBoardLib/Clock.c
+++ b/PandaBoardPkg/Library/PandaBoardLib/Clock.c
diff --git a/PandaBoardPkg/Library/PandaBoardLib/PadConfiguration.c b/PandaBoardPkg/Library/PandaBoardLib/PadConfiguration.c
index 41dae5b4eb..41dae5b4eb 100755..100644
--- a/PandaBoardPkg/Library/PandaBoardLib/PadConfiguration.c
+++ b/PandaBoardPkg/Library/PandaBoardLib/PadConfiguration.c
diff --git a/PerformancePkg/PerformancePkg.dsc b/PerformancePkg/PerformancePkg.dsc
index 0274229e22..6d48ae30a5 100644
--- a/PerformancePkg/PerformancePkg.dsc
+++ b/PerformancePkg/PerformancePkg.dsc
@@ -1,7 +1,7 @@
## @file
# Build description file to generate Shell DP application.
#
-# 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
@@ -70,6 +70,9 @@
PalLib|MdePkg/Library/UefiPalLib/UefiPalLib.inf
TimerLib|MdePkg/Library/BaseTimerLibNullTemplate/BaseTimerLibNullTemplate.inf
+[LibraryClasses.EBC]
+ TimerLib|MdePkg/Library/BaseTimerLibNullTemplate/BaseTimerLibNullTemplate.inf
+
[Components.IA32, Components.X64]
PerformancePkg/Library/TscTimerLib/DxeTscTimerLib.inf
PerformancePkg/Library/TscTimerLib/PeiTscTimerLib.inf
diff --git a/SamsungPlatformPkg/ArndaleBoardPkg/Library/ArndaleBoardLib/Exynos5250/BoardHelper.S b/SamsungPlatformPkg/ArndaleBoardPkg/Library/ArndaleBoardLib/Exynos5250/BoardHelper.S
index 1975e6517e..d5858630f3 100644
--- a/SamsungPlatformPkg/ArndaleBoardPkg/Library/ArndaleBoardLib/Exynos5250/BoardHelper.S
+++ b/SamsungPlatformPkg/ArndaleBoardPkg/Library/ArndaleBoardLib/Exynos5250/BoardHelper.S
@@ -14,6 +14,7 @@
#include <AsmMacroIoLib.h>
#include <Base.h>
#include <Library/PcdLib.h>
+#include <Library/ArmLib.h>
#include <AutoGen.h>
#.include AsmMacroIoLib.inc
@@ -23,6 +24,9 @@
.align 2
GCC_ASM_EXPORT(ArmGetCpuCountPerCluster)
+GCC_ASM_EXPORT(ArmPlatformGetCorePosition)
+GCC_ASM_EXPORT(ArmPlatformIsPrimaryCore)
+GCC_ASM_EXPORT(ArmPlatformPeiBootAction)
# IN None
# OUT r0 = SCU Base Address
@@ -68,4 +72,25 @@ _Return:
ldmfd SP!, {r1-r2}
bx lr
+ASM_PFX(ArmPlatformIsPrimaryCore):
+ #last 2 bit of mpid register in 5250 is CPU ID
+ ldr r1, =0x3
+ and r0, r0, r1
+ #id for core0 should be 0
+ ldr r1, =0x0
+ cmp r0, r1
+ moveq r0, #1
+ movne r0, #0
+ mov pc, lr
+
+ASM_PFX(ArmPlatformGetCorePosition):
+ and r1, r0, #0x03 //cpu core mask last 2 bits
+ and r0, r0, #(0x0f<<8) //cpu cluster mask bit 8-11
+ add r0, r1, r0, LSR #7
+ mov pc, lr
+
+
+ASM_PFX(ArmPlatformPeiBootAction):
+ mov pc, lr
+
ASM_FUNCTION_REMOVE_IF_UNREFERENCED
diff --git a/SamsungPlatformPkg/ArndaleBoardPkg/arndale-Exynos5250.dsc b/SamsungPlatformPkg/ArndaleBoardPkg/arndale-Exynos5250.dsc
index 941c6e55c6..ade2997028 100755
--- a/SamsungPlatformPkg/ArndaleBoardPkg/arndale-Exynos5250.dsc
+++ b/SamsungPlatformPkg/ArndaleBoardPkg/arndale-Exynos5250.dsc
@@ -56,7 +56,6 @@
[BuildOptions]
RVCT:*_*_ARM_PLATFORM_FLAGS == --cpu Cortex-A8 --fpu=softvfp -I$(WORKSPACE)/SamsungPlatformPkg/ExynosPkg/Exynos5250/Include/Platform
- #GCC:*_*_ARM_PLATFORM_FLAGS == -mcpu=cortex-a8 -I$(WORKSPACE)/SamsungPlatformPkg/ExynosPkg/Exynos5250/Include/Platform
GCC:*_*_ARM_PLATFORM_FLAGS == -march=armv7-a -I$(WORKSPACE)/SamsungPlatformPkg/ExynosPkg/Exynos5250/Include/Platform
XCODE:*_*_ARM_PLATFORM_FLAGS == -arch armv7 -I$(WORKSPACE)/SamsungPlatformPkg/ExynosPkg/Exynos5250/Include/Platform
@@ -242,7 +241,6 @@
SamsungPlatformPkg/ExynosPkg/Exynos5250/MemoryInitPei/MemoryInitPeim.inf
ArmPkg/Drivers/CpuPei/CpuPei.inf
IntelFrameworkModulePkg/Universal/StatusCode/Pei/StatusCodePei.inf
- #Nt32Pkg/BootModePei/BootModePei.inf
MdeModulePkg/Universal/Variable/Pei/VariablePei.inf
MdeModulePkg/Core/DxeIplPeim/DxeIpl.inf {
<LibraryClasses>
@@ -268,22 +266,17 @@
MdeModulePkg/Universal/WatchdogTimerDxe/WatchdogTimer.inf
MdeModulePkg/Universal/CapsuleRuntimeDxe/CapsuleRuntimeDxe.inf
MdeModulePkg/Universal/Variable/EmuRuntimeDxe/EmuVariableRuntimeDxe.inf
- #MdeModulePkg/Universal/FaultTolerantWriteDxe/FaultTolerantWriteDxe.inf
- #MdeModulePkg/Universal/Variable/RuntimeDxe/VariableRuntimeDxe.inf
MdeModulePkg/Universal/MonotonicCounterRuntimeDxe/MonotonicCounterRuntimeDxe.inf
EmbeddedPkg/ResetRuntimeDxe/ResetRuntimeDxe.inf
EmbeddedPkg/RealTimeClockRuntimeDxe/RealTimeClockRuntimeDxe.inf
EmbeddedPkg/MetronomeDxe/MetronomeDxe.inf
MdeModulePkg/Universal/Console/ConPlatformDxe/ConPlatformDxe.inf
- #MdeModulePkg/Universal/Console/ConSplitterDxe/ConSplitterDxe.inf
MdeModulePkg/Universal/Console/GraphicsConsoleDxe/GraphicsConsoleDxe.inf
MdeModulePkg/Universal/Console/TerminalDxe/TerminalDxe.inf
EmbeddedPkg/SimpleTextInOutSerial/SimpleTextInOutSerial.inf
- #EmbeddedPkg/SerialDxe/SerialDxe.inf
MdeModulePkg/Universal/HiiDatabaseDxe/HiiDatabaseDxe.inf
- #MdeModulePkg/Universal/SetupBrowserDxe/SetupBrowserDxe.inf
SamsungPlatformPkg/ArndaleBoardPkg/FvbDxe/FvbDxe.inf
SamsungPlatformPkg/ExynosPkg/Exynos5250/Drivers/TimerDxe/TimerDxe.inf
@@ -318,9 +311,6 @@
#
# Application
#
- #SamsungPlatformPkg/Apps/TestApps/HashServicesTest/HashServicesTest.inf
- #SamsungPlatformPkg/Apps/TestApps/RngServicesTest/RngServicesTest.inf
-
#
# Bds
#
@@ -346,9 +336,7 @@
# usb host : ehci + bus + pci_emul + mass_storage
#
SamsungPlatformPkg/ExynosPkg/Exynos5250/Drivers/PciEmulation/PciEmulation.inf
- #SamsungPlatformPkg/ExynosPkg/Exynos5250/OhciDxe/OhciDxe.inf
MdeModulePkg/Bus/Pci/EhciDxe/EhciDxe.inf
- #MdeModulePkg/Bus/Pci/XhciDxe/XhciDxe.inf
MdeModulePkg/Bus/Usb/UsbBusDxe/UsbBusDxe.inf
MdeModulePkg/Bus/Usb/UsbMassStorageDxe/UsbMassStorageDxe.inf
@@ -363,8 +351,6 @@
<LibraryClasses>
LockBoxLib|MdeModulePkg/Library/LockBoxNullLib/LockBoxNullLib.inf
}
- MdeModulePkg/Universal/Acpi/FirmwarePerformanceDataTableDxe/FirmwarePerformanceDxe.inf
- #MdeModulePkg/Universal/Acpi/BootGraphicsResourceTableDxe/BootGraphicsResourceTableDxe.inf
MdeModulePkg/Universal/SmbiosDxe/SmbiosDxe.inf
SamsungPlatformPkg/Apps/Tools/fwupdate/fwupdate_5250.inf
@@ -372,9 +358,7 @@
#
# Crypto for Exynos
#
- #SamsungPlatformPkg/ExynosPkg/Exynos5250/Drivers/HashDxe/HashDxe.inf
#
# Rng for Exynos
#
- #SamsungPlatformPkg/ExynosPkg/Exynos5250/Drivers/RngDxe/RngDxe.inf
diff --git a/SamsungPlatformPkg/ArndaleBoardPkg/arndale-Exynos5250.fdf b/SamsungPlatformPkg/ArndaleBoardPkg/arndale-Exynos5250.fdf
index 8b5a5a7274..9bccd79bf6 100755
--- a/SamsungPlatformPkg/ArndaleBoardPkg/arndale-Exynos5250.fdf
+++ b/SamsungPlatformPkg/ArndaleBoardPkg/arndale-Exynos5250.fdf
@@ -120,7 +120,6 @@ READ_STATUS = TRUE
READ_LOCK_CAP = TRUE
READ_LOCK_STATUS = TRUE
- #INF ArmPlatformPkg/Sec/Sec.inf
INF SamsungPlatformPkg/ExynosPkg/Exynos5250/Sec/Sec.inf
@@ -155,8 +154,6 @@ READ_LOCK_STATUS = TRUE
INF MdeModulePkg/Universal/WatchdogTimerDxe/WatchdogTimer.inf
INF MdeModulePkg/Universal/CapsuleRuntimeDxe/CapsuleRuntimeDxe.inf
INF MdeModulePkg/Universal/Variable/EmuRuntimeDxe/EmuVariableRuntimeDxe.inf
- #INF MdeModulePkg/Universal/Variable/RuntimeDxe/VariableRuntimeDxe.inf
- #INF MdeModulePkg/Universal/FaultTolerantWriteDxe/FaultTolerantWriteDxe.inf
INF MdeModulePkg/Universal/MonotonicCounterRuntimeDxe/MonotonicCounterRuntimeDxe.inf
INF EmbeddedPkg/ResetRuntimeDxe/ResetRuntimeDxe.inf
INF EmbeddedPkg/RealTimeClockRuntimeDxe/RealTimeClockRuntimeDxe.inf
@@ -166,14 +163,10 @@ READ_LOCK_STATUS = TRUE
# Multiple Console IO support
#
INF MdeModulePkg/Universal/Console/ConPlatformDxe/ConPlatformDxe.inf
- #INF MdeModulePkg/Universal/Console/ConSplitterDxe/ConSplitterDxe.inf
INF MdeModulePkg/Universal/Console/GraphicsConsoleDxe/GraphicsConsoleDxe.inf
INF MdeModulePkg/Universal/Console/TerminalDxe/TerminalDxe.inf
INF EmbeddedPkg/SimpleTextInOutSerial/SimpleTextInOutSerial.inf
- #INF EmbeddedPkg/SerialDxe/SerialDxe.inf
-
INF MdeModulePkg/Universal/HiiDatabaseDxe/HiiDatabaseDxe.inf
- #INF MdeModulePkg/Universal/SetupBrowserDxe/SetupBrowserDxe.inf
!ifdef $(EXYNOS5250_EVT1)
INF SamsungPlatformPkg/ExynosPkg/Exynos5250/Drivers/Gic400Dxe/PL390GicDxe.inf
@@ -207,9 +200,7 @@ READ_LOCK_STATUS = TRUE
# USB HOST STACK
#
INF SamsungPlatformPkg/ExynosPkg/Exynos5250/Drivers/PciEmulation/PciEmulation.inf
- #INF SamsungPlatformPkg/ExynosPkg/Exynos5250/OhciDxe/OhciDxe.inf
INF MdeModulePkg/Bus/Pci/EhciDxe/EhciDxe.inf
- #INF MdeModulePkg/Bus/Pci/XhciDxe/XhciDxe.inf
INF MdeModulePkg/Bus/Usb/UsbBusDxe/UsbBusDxe.inf
INF MdeModulePkg/Bus/Usb/UsbMassStorageDxe/UsbMassStorageDxe.inf
@@ -223,20 +214,14 @@ READ_LOCK_STATUS = TRUE
INF MdeModulePkg/Universal/ReportStatusCodeRouter/Pei/ReportStatusCodeRouterPei.inf
INF MdeModulePkg/Universal/ReportStatusCodeRouter/RuntimeDxe/ReportStatusCodeRouterRuntimeDxe.inf
INF MdeModulePkg/Universal/Acpi/FirmwarePerformanceDataTablePei/FirmwarePerformancePei.inf
- INF MdeModulePkg/Universal/Acpi/FirmwarePerformanceDataTableDxe/FirmwarePerformanceDxe.inf
- #INF MdeModulePkg/Universal/Acpi/BootGraphicsResourceTableDxe/BootGraphicsResourceTableDxe.inf
# Crypto for Exynos
#
- #INF SamsungPlatformPkg/ExynosPkg/Exynos5250/Drivers/HashDxe/HashDxe.inf
- #INF SamsungPlatformPkg/ExynosPkg/Exynos5250/Drivers/RngDxe/RngDxe.inf
#
# UEFI application (Shell Embedded Boot Loader)
#
INF ShellBinPkg/UefiShell/UefiShell.inf
- #INF SamsungPlatformPkg/Apps/TestApps/HashServicesTest/HashServicesTest.inf
- #INF SamsungPlatformPkg/Apps/TestApps/RngServicesTest/RngServicesTest.inf
#
# Bds
diff --git a/SamsungPlatformPkg/ExynosPkg/Exynos5250/Drivers/Gic400Dxe/PL390GicSec.c b/SamsungPlatformPkg/ExynosPkg/Exynos5250/Drivers/Gic400Dxe/PL390GicSec.c
index f7b6d7c3a4..82ecfde6ea 100644
--- a/SamsungPlatformPkg/ExynosPkg/Exynos5250/Drivers/Gic400Dxe/PL390GicSec.c
+++ b/SamsungPlatformPkg/ExynosPkg/Exynos5250/Drivers/Gic400Dxe/PL390GicSec.c
@@ -15,6 +15,7 @@
#include <Base.h>
#include <Library/ArmLib.h>
#include <Library/DebugLib.h>
+#include <Library/ArmPlatformLib.h>
#include <Library/IoLib.h>
#include <Library/ArmGicLib.h>
@@ -50,7 +51,7 @@ ArmGicSetupNonSecure (
}
// Only the primary core should set the Non Secure bit to the SPIs (Shared Peripheral Interrupt).
- if (IS_PRIMARY_CORE(MpId)) {
+ if (ArmPlatformIsPrimaryCore (MpId)) {
// Ensure all GIC interrupts are Non-Secure
for (Index = 0; Index < (ArmGicGetMaxNumInterrupts (GicDistributorBase) / 32); Index++) {
MmioWrite32 (GicDistributorBase + ARM_GIC_ICDISR + (Index * 4), 0xffffffff);
diff --git a/SamsungPlatformPkg/ExynosPkg/Exynos5250/Drivers/Gic400Dxe/PL390GicSecLib.inf b/SamsungPlatformPkg/ExynosPkg/Exynos5250/Drivers/Gic400Dxe/PL390GicSecLib.inf
index 9e1fd09667..ab399b4fb0 100644
--- a/SamsungPlatformPkg/ExynosPkg/Exynos5250/Drivers/Gic400Dxe/PL390GicSecLib.inf
+++ b/SamsungPlatformPkg/ExynosPkg/Exynos5250/Drivers/Gic400Dxe/PL390GicSecLib.inf
@@ -25,7 +25,9 @@
[Packages]
ArmPkg/ArmPkg.dec
+ ArmPlatformPkg/ArmPlatformPkg.dec
MdePkg/MdePkg.dec
+ MdeModulePkg/MdeModulePkg.dec
[LibraryClasses]
ArmLib
@@ -33,6 +35,3 @@
IoLib
PcdLib
-[FixedPcd.common]
- gArmTokenSpaceGuid.PcdArmPrimaryCoreMask
- gArmTokenSpaceGuid.PcdArmPrimaryCore
diff --git a/SamsungPlatformPkg/ExynosPkg/Exynos5250/Sec/Sec.c b/SamsungPlatformPkg/ExynosPkg/Exynos5250/Sec/Sec.c
index 549171b3ba..3c4f4983fc 100644
--- a/SamsungPlatformPkg/ExynosPkg/Exynos5250/Sec/Sec.c
+++ b/SamsungPlatformPkg/ExynosPkg/Exynos5250/Sec/Sec.c
@@ -21,6 +21,7 @@
#include <Library/ArmGicLib.h>
#include <Library/ArmCpuLib.h>
#include <Library/IoLib.h>
+#include <Library/ArmPlatformLib.h>
#include "SecInternal.h"
#include "Smc.h"
@@ -94,7 +95,7 @@ CEntryPoint (
}
// Primary CPU clears out the SCU tag RAMs, secondaries wait
- if (IS_PRIMARY_CORE(MpId)) {
+ if (ArmPlatformIsPrimaryCore (MpId)) {
if (ArmIsMpCore()) {
// Is UEFI built as it is assumed that TZSW is running?
// PcdTrustzoneSupport==1: YES.
@@ -174,7 +175,7 @@ TrustedWorldInitialization (
ArmPlatformSecTrustzoneInit (MpId);
// Setup the Trustzone Chipsets
- if (IS_PRIMARY_CORE(MpId)) {
+ if (ArmPlatformIsPrimaryCore (MpId)) {
if (ArmIsMpCore()) {
// Signal the secondary core the Security settings is done (event: EVENT_SECURE_INIT)
ArmCallSEV ();
diff --git a/SamsungPlatformPkg/ExynosPkg/Exynos5250/Sec/Sec.inf b/SamsungPlatformPkg/ExynosPkg/Exynos5250/Sec/Sec.inf
index 854b26971b..1cda8c3adc 100644
--- a/SamsungPlatformPkg/ExynosPkg/Exynos5250/Sec/Sec.inf
+++ b/SamsungPlatformPkg/ExynosPkg/Exynos5250/Sec/Sec.inf
@@ -62,9 +62,6 @@
gArmTokenSpaceGuid.PcdArmNsacr
gArmTokenSpaceGuid.PcdArmNonSecModeTransition
- gArmTokenSpaceGuid.PcdArmPrimaryCoreMask
- gArmTokenSpaceGuid.PcdArmPrimaryCore
-
gArmTokenSpaceGuid.PcdSecureFvBaseAddress
gArmTokenSpaceGuid.PcdSecureFvSize
diff --git a/SamsungPlatformPkg/ExynosPkg/Exynos5250/Sec/SecEntryPoint.S b/SamsungPlatformPkg/ExynosPkg/Exynos5250/Sec/SecEntryPoint.S
index 08a893cb04..aecbc939f0 100644
--- a/SamsungPlatformPkg/ExynosPkg/Exynos5250/Sec/SecEntryPoint.S
+++ b/SamsungPlatformPkg/ExynosPkg/Exynos5250/Sec/SecEntryPoint.S
@@ -14,12 +14,14 @@
#include <AutoGen.h>
#include <AsmMacroIoLib.h>
#include <Library/ArmPlatformLib.h>
+#include <ArmPlatform.h>
#include "SecInternal.h"
.text
.align 3
GCC_ASM_IMPORT(CEntryPoint)
+GCC_ASM_IMPORT(ArmPlatformIsPrimaryCore)
GCC_ASM_IMPORT(CopyFirmwareFromEMMC)
GCC_ASM_IMPORT(CopyFirmwareFromSDMMC)
GCC_ASM_IMPORT(ArmPlatformClockInitialize)
@@ -36,6 +38,16 @@ GCC_ASM_EXPORT(_ModuleEntryPoint)
SecStartupAddr: .word ASM_PFX(_SecEntryFromTzsw)
StartupAddr: .word ASM_PFX(CEntryPoint)
+// Convert the (ClusterId,CoreId) into a Core Position
+// 0x0F03 is the magic value for ARM_CORE_MASK | ARM_CLUSTER_MASK
+//Core is 0-1 bits and cluster is 8-11 bits
+#define GetCorePositionFromMpId(Pos, MpId, Tmp) \
+ ldr Tmp, =0x0F03 ; \
+ and MpId, Tmp ; \
+ lsr Pos, MpId, #6 ; \
+ and Tmp, MpId, #3 ; \
+ add Pos, Pos, Tmp
+
// Reserve a region at the top of the IRAM Core stack
// for Global variables for the XIP phase
#define SetiRamStack(StackTop, GlobalSize, Tmp) \
@@ -85,13 +97,13 @@ ASM_PFX(_ModuleEntryPoint):
_IdentifyCpu:
// Identify CPU ID
bl ASM_PFX(ArmReadMpidr)
- // Get ID of this CPU in Multicore system
- LoadConstantToReg (FixedPcdGet32(PcdArmPrimaryCoreMask), r1)
- and r5, r0, r1
+ // Keep a copy of the MpId register value
+ mov r5, r0
// Is it the Primary Core ?
- LoadConstantToReg (FixedPcdGet32(PcdArmPrimaryCore), r3)
- cmp r5, r3
+ bl ASM_PFX(ArmPlatformIsPrimaryCore)
+ cmp r0, #1
+
// Only the primary core initialize the memory (SMC)
beq _InitMem
@@ -119,9 +131,6 @@ _InitMem:
bl ASM_PFX(ArmPlatformSecBootMemoryInit)
- // Only Primary CPU could run this line (the secondary cores have jumped from _IdentifyCpu to _SetupStack)
- LoadConstantToReg (FixedPcdGet32(PcdArmPrimaryCore), r5)
-
_SetupPrimaryCoreStack:
// Get the top of the primary stacks (and the base of the secondary stacks)
LoadConstantToReg (FixedPcdGet32(PcdCPUCoresSecStackBase), r1)
diff --git a/SecurityPkg/Library/DxeImageVerificationLib/DxeImageVerificationLib.c b/SecurityPkg/Library/DxeImageVerificationLib/DxeImageVerificationLib.c
index 5bc29cf145..9e4bf8681b 100644
--- a/SecurityPkg/Library/DxeImageVerificationLib/DxeImageVerificationLib.c
+++ b/SecurityPkg/Library/DxeImageVerificationLib/DxeImageVerificationLib.c
@@ -1348,53 +1348,6 @@ Done:
}
/**
- When VariableWriteArchProtocol install, create "SecureBoot" variable.
-
- @param[in] Event Event whose notification function is being invoked.
- @param[in] Context Pointer to the notification function's context.
-
-**/
-VOID
-EFIAPI
-VariableWriteCallBack (
- IN EFI_EVENT Event,
- IN VOID *Context
- )
-{
- UINT8 SecureBootMode;
- UINT8 *SecureBootModePtr;
- EFI_STATUS Status;
- VOID *ProtocolPointer;
-
- Status = gBS->LocateProtocol (&gEfiVariableWriteArchProtocolGuid, NULL, &ProtocolPointer);
- if (EFI_ERROR (Status)) {
- return;
- }
-
- //
- // Check whether "SecureBoot" variable exists.
- // If this library is built-in, it means firmware has capability to perform
- // driver signing verification.
- //
- GetEfiGlobalVariable2 (EFI_SECURE_BOOT_MODE_NAME, (VOID**)&SecureBootModePtr, NULL);
- if (SecureBootModePtr == NULL) {
- SecureBootMode = SECURE_BOOT_MODE_DISABLE;
- //
- // Authenticated variable driver will update "SecureBoot" depending on SetupMode variable.
- //
- gRT->SetVariable (
- EFI_SECURE_BOOT_MODE_NAME,
- &gEfiGlobalVariableGuid,
- EFI_VARIABLE_BOOTSERVICE_ACCESS | EFI_VARIABLE_RUNTIME_ACCESS | EFI_VARIABLE_NON_VOLATILE,
- sizeof (UINT8),
- &SecureBootMode
- );
- } else {
- FreePool (SecureBootModePtr);
- }
-}
-
-/**
Register security measurement handler.
@param ImageHandle ImageHandle of the loaded driver.
@@ -1409,19 +1362,6 @@ DxeImageVerificationLibConstructor (
IN EFI_SYSTEM_TABLE *SystemTable
)
{
- VOID *Registration;
-
- //
- // Register callback function upon VariableWriteArchProtocol.
- //
- EfiCreateProtocolNotifyEvent (
- &gEfiVariableWriteArchProtocolGuid,
- TPL_CALLBACK,
- VariableWriteCallBack,
- NULL,
- &Registration
- );
-
return RegisterSecurity2Handler (
DxeImageVerificationHandler,
EFI_AUTH_OPERATION_VERIFY_IMAGE | EFI_AUTH_OPERATION_IMAGE_REQUIRED
diff --git a/SecurityPkg/Library/DxeImageVerificationLib/DxeImageVerificationLib.inf b/SecurityPkg/Library/DxeImageVerificationLib/DxeImageVerificationLib.inf
index dd03b0bf8a..0c6ab968f0 100644
--- a/SecurityPkg/Library/DxeImageVerificationLib/DxeImageVerificationLib.inf
+++ b/SecurityPkg/Library/DxeImageVerificationLib/DxeImageVerificationLib.inf
@@ -7,7 +7,7 @@
# This external input must be validated carefully to avoid security issue like
# buffer overflow, integer overflow.
#
-# 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
@@ -59,7 +59,6 @@
gEfiFirmwareVolume2ProtocolGuid
gEfiBlockIoProtocolGuid
gEfiSimpleFileSystemProtocolGuid
- gEfiVariableWriteArchProtocolGuid
[Guids]
gEfiCertTypeRsa2048Sha256Guid
diff --git a/SecurityPkg/Library/DxeTpmMeasureBootLib/DxeTpmMeasureBootLib.c b/SecurityPkg/Library/DxeTpmMeasureBootLib/DxeTpmMeasureBootLib.c
index eae68eab6b..665e4b6c80 100644
--- a/SecurityPkg/Library/DxeTpmMeasureBootLib/DxeTpmMeasureBootLib.c
+++ b/SecurityPkg/Library/DxeTpmMeasureBootLib/DxeTpmMeasureBootLib.c
@@ -15,7 +15,7 @@
TcgMeasureGptTable() function will receive untrusted GPT partition table, and parse
partition data carefully.
-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
@@ -664,6 +664,14 @@ TcgMeasurePeImage (
&EventNumber,
&EventLogLastEntry
);
+ if (Status == EFI_OUT_OF_RESOURCES) {
+ //
+ // Out of resource 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 (TcgEvent);
diff --git a/SecurityPkg/SecurityPkg.dsc b/SecurityPkg/SecurityPkg.dsc
index 9c8c9060e8..54b5b2464d 100644
--- a/SecurityPkg/SecurityPkg.dsc
+++ b/SecurityPkg/SecurityPkg.dsc
@@ -1,7 +1,7 @@
## @file
# Security Module Package for All Architectures.
#
-# 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
@@ -92,8 +92,6 @@
SecurityPkg/Library/DxeImageAuthenticationStatusLib/DxeImageAuthenticationStatusLib.inf
SecurityPkg/UserIdentification/UserIdentifyManagerDxe/UserIdentifyManagerDxe.inf
SecurityPkg/UserIdentification/UserProfileManagerDxe/UserProfileManagerDxe.inf
- SecurityPkg/UserIdentification/PwdCredentialProviderDxe/PwdCredentialProviderDxe.inf
- SecurityPkg/UserIdentification/UsbCredentialProviderDxe/UsbCredentialProviderDxe.inf
#
# Application
@@ -104,29 +102,35 @@
# TPM
#
SecurityPkg/Library/DxeTpmMeasureBootLib/DxeTpmMeasureBootLib.inf
- SecurityPkg/Tcg/TcgPei/TcgPei.inf
- SecurityPkg/Tcg/TcgDxe/TcgDxe.inf
+ SecurityPkg/Library/TpmCommLib/TpmCommLib.inf
+
SecurityPkg/Tcg/PhysicalPresencePei/PhysicalPresencePei.inf
SecurityPkg/Tcg/MemoryOverwriteControl/TcgMor.inf
+
+[Components.IA32, Components.X64, Components.IPF]
+ SecurityPkg/UserIdentification/PwdCredentialProviderDxe/PwdCredentialProviderDxe.inf
+ SecurityPkg/UserIdentification/UsbCredentialProviderDxe/UsbCredentialProviderDxe.inf
+ SecurityPkg/VariableAuthenticated/SecureBootConfigDxe/SecureBootConfigDxe.inf
+ SecurityPkg/VariableAuthenticated/RuntimeDxe/VariableRuntimeDxe.inf
+
+ #
+ # TPM
+ #
+ SecurityPkg/Tcg/TcgPei/TcgPei.inf
+ SecurityPkg/Tcg/TcgDxe/TcgDxe.inf
SecurityPkg/Tcg/TcgConfigDxe/TcgConfigDxe.inf {
<LibraryClasses>
PcdLib|MdePkg/Library/DxePcdLib/DxePcdLib.inf
}
- SecurityPkg/Tcg/TcgSmm/TcgSmm.inf
- SecurityPkg/VariableAuthenticated/SecureBootConfigDxe/SecureBootConfigDxe.inf
-
+
[Components.IA32, Components.X64]
- SecurityPkg/VariableAuthenticated/RuntimeDxe/VariableRuntimeDxe.inf
SecurityPkg/VariableAuthenticated/RuntimeDxe/VariableSmm.inf
SecurityPkg/VariableAuthenticated/RuntimeDxe/VariableSmmRuntimeDxe.inf
+ SecurityPkg/Tcg/TcgSmm/TcgSmm.inf
[Components.IPF]
SecurityPkg/VariableAuthenticated/EsalVariableDxeSal/EsalVariableDxeSal.inf
-[Components.EBC]
-# Build only
- SecurityPkg/VariableAuthenticated/RuntimeDxe/VariableRuntimeDxe.inf
-
[BuildOptions]
MSFT:*_*_IA32_DLINK_FLAGS = /ALIGN:256
INTEL:*_*_IA32_DLINK_FLAGS = /ALIGN:256
diff --git a/SecurityPkg/VariableAuthenticated/EsalVariableDxeSal/Variable.c b/SecurityPkg/VariableAuthenticated/EsalVariableDxeSal/Variable.c
index d0269c9da7..e098c81df3 100644
--- a/SecurityPkg/VariableAuthenticated/EsalVariableDxeSal/Variable.c
+++ b/SecurityPkg/VariableAuthenticated/EsalVariableDxeSal/Variable.c
@@ -1,7 +1,7 @@
/** @file
The implementation of Extended SAL variable services.
-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
@@ -2591,6 +2591,14 @@ EsalSetVariable (
PayloadSize = DataSize;
}
+
+ if ((UINTN)(~0) - PayloadSize < StrSize(VariableName)){
+ //
+ // Prevent whole variable size overflow
+ //
+ return EFI_INVALID_PARAMETER;
+ }
+
VariableGlobal = &Global->VariableGlobal[VirtualMode];
Instance = Global->FvbInstance;
@@ -2599,8 +2607,7 @@ EsalSetVariable (
// For variable for hardware error record, the size of the VariableName, including the Unicode Null
// in bytes plus the DataSize is limited to maximum size of PcdGet32(PcdMaxHardwareErrorVariableSize) bytes.
//
- if ((PayloadSize > PcdGet32(PcdMaxHardwareErrorVariableSize)) ||
- (sizeof (VARIABLE_HEADER) + StrSize (VariableName) + PayloadSize > PcdGet32(PcdMaxHardwareErrorVariableSize))) {
+ if (StrSize (VariableName) + PayloadSize > PcdGet32(PcdMaxHardwareErrorVariableSize) - sizeof (VARIABLE_HEADER)) {
return EFI_INVALID_PARAMETER;
}
//
@@ -2616,8 +2623,7 @@ EsalSetVariable (
// For variable not for hardware error record, the size of the VariableName, including the
// Unicode Null in bytes plus the DataSize is limited to maximum size of PcdGet32(PcdMaxVariableSize) bytes.
//
- if ((PayloadSize > PcdGet32(PcdMaxVariableSize)) ||
- (sizeof (VARIABLE_HEADER) + StrSize (VariableName) + PayloadSize > PcdGet32(PcdMaxVariableSize))) {
+ if (StrSize (VariableName) + PayloadSize > PcdGet32(PcdMaxVariableSize) - sizeof (VARIABLE_HEADER)) {
return EFI_INVALID_PARAMETER;
}
}
diff --git a/SecurityPkg/VariableAuthenticated/RuntimeDxe/AuthService.c b/SecurityPkg/VariableAuthenticated/RuntimeDxe/AuthService.c
index 6f8808a756..7da0d63aba 100644
--- a/SecurityPkg/VariableAuthenticated/RuntimeDxe/AuthService.c
+++ b/SecurityPkg/VariableAuthenticated/RuntimeDxe/AuthService.c
@@ -192,7 +192,7 @@ AutenticatedVariableServiceInitialize (
//
// Reserved runtime buffer for "Append" operation in virtual mode.
//
- mStorageArea = AllocateRuntimePool (PcdGet32 (PcdMaxVariableSize));
+ mStorageArea = AllocateRuntimePool (MAX (PcdGet32 (PcdMaxVariableSize), PcdGet32 (PcdMaxHardwareErrorVariableSize)));
if (mStorageArea == NULL) {
return EFI_OUT_OF_RESOURCES;
}
@@ -675,7 +675,6 @@ UpdatePlatformMode (
{
EFI_STATUS Status;
VARIABLE_POINTER_TRACK Variable;
- UINT32 VarAttr;
UINT8 SecureBootMode;
UINT8 SecureBootEnable;
UINTN VariableDataSize;
@@ -736,13 +735,12 @@ UpdatePlatformMode (
}
}
- VarAttr = EFI_VARIABLE_NON_VOLATILE | EFI_VARIABLE_RUNTIME_ACCESS | EFI_VARIABLE_BOOTSERVICE_ACCESS | EFI_VARIABLE_AUTHENTICATED_WRITE_ACCESS;
Status = UpdateVariable (
EFI_SECURE_BOOT_MODE_NAME,
&gEfiGlobalVariableGuid,
&SecureBootMode,
sizeof(UINT8),
- VarAttr,
+ EFI_VARIABLE_RUNTIME_ACCESS | EFI_VARIABLE_BOOTSERVICE_ACCESS,
0,
0,
&Variable,
@@ -1316,20 +1314,24 @@ ProcessVariable (
will be appended to the original EFI_SIGNATURE_LIST, duplicate EFI_SIGNATURE_DATA
will be ignored.
- @param[in, out] Data Pointer to original EFI_SIGNATURE_LIST.
- @param[in] DataSize Size of Data buffer.
- @param[in] NewData Pointer to new EFI_SIGNATURE_LIST to be appended.
- @param[in] NewDataSize Size of NewData buffer.
+ @param[in, out] Data Pointer to original EFI_SIGNATURE_LIST.
+ @param[in] DataSize Size of Data buffer.
+ @param[in] FreeBufSize Size of free data buffer
+ @param[in] NewData Pointer to new EFI_SIGNATURE_LIST to be appended.
+ @param[in] NewDataSize Size of NewData buffer.
+ @param[out] MergedBufSize Size of the merged buffer
- @return Size of the merged buffer.
+ @return EFI_BUFFER_TOO_SMALL if input Data buffer overflowed
**/
-UINTN
+EFI_STATUS
AppendSignatureList (
IN OUT VOID *Data,
IN UINTN DataSize,
+ IN UINTN FreeBufSize,
IN VOID *NewData,
- IN UINTN NewDataSize
+ IN UINTN NewDataSize,
+ OUT UINTN *MergedBufSize
)
{
EFI_SIGNATURE_LIST *CertList;
@@ -1388,15 +1390,25 @@ AppendSignatureList (
// New EFI_SIGNATURE_DATA, append it.
//
if (CopiedCount == 0) {
+ if (FreeBufSize < sizeof (EFI_SIGNATURE_LIST) + NewCertList->SignatureHeaderSize) {
+ return EFI_BUFFER_TOO_SMALL;
+ }
+
//
// Copy EFI_SIGNATURE_LIST header for only once.
//
+
CopyMem (Tail, NewCertList, sizeof (EFI_SIGNATURE_LIST) + NewCertList->SignatureHeaderSize);
Tail = Tail + sizeof (EFI_SIGNATURE_LIST) + NewCertList->SignatureHeaderSize;
+ FreeBufSize -= sizeof (EFI_SIGNATURE_LIST) + NewCertList->SignatureHeaderSize;
}
+ if (FreeBufSize < NewCertList->SignatureSize) {
+ return EFI_BUFFER_TOO_SMALL;
+ }
CopyMem (Tail, NewCert, NewCertList->SignatureSize);
Tail += NewCertList->SignatureSize;
+ FreeBufSize -= NewCertList->SignatureSize;
CopiedCount++;
}
@@ -1416,7 +1428,8 @@ AppendSignatureList (
NewCertList = (EFI_SIGNATURE_LIST *) ((UINT8 *) NewCertList + NewCertList->SignatureListSize);
}
- return (Tail - (UINT8 *) Data);
+ *MergedBufSize = (Tail - (UINT8 *) Data);
+ return EFI_SUCCESS;
}
/**
diff --git a/SecurityPkg/VariableAuthenticated/RuntimeDxe/AuthService.h b/SecurityPkg/VariableAuthenticated/RuntimeDxe/AuthService.h
index 510030d705..1fd687b033 100644
--- a/SecurityPkg/VariableAuthenticated/RuntimeDxe/AuthService.h
+++ b/SecurityPkg/VariableAuthenticated/RuntimeDxe/AuthService.h
@@ -2,7 +2,7 @@
The internal header file includes the common header files, defines
internal structure and functions used by AuthService module.
-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
@@ -249,20 +249,24 @@ ProcessVarWithKek (
will be appended to the original EFI_SIGNATURE_LIST, duplicate EFI_SIGNATURE_DATA
will be ignored.
- @param[in, out] Data Pointer to original EFI_SIGNATURE_LIST.
- @param[in] DataSize Size of Data buffer.
- @param[in] NewData Pointer to new EFI_SIGNATURE_LIST to be appended.
- @param[in] NewDataSize Size of NewData buffer.
+ @param[in, out] Data Pointer to original EFI_SIGNATURE_LIST.
+ @param[in] DataSize Size of Data buffer.
+ @param[in] FreeBufSize Size of free data buffer
+ @param[in] NewData Pointer to new EFI_SIGNATURE_LIST to be appended.
+ @param[in] NewDataSize Size of NewData buffer.
+ @param[out] MergedBufSize Size of the merged buffer
- @return Size of the merged buffer.
+ @return EFI_BUFFER_TOO_SMALL if input Data buffer overflowed
**/
-UINTN
+EFI_STATUS
AppendSignatureList (
IN OUT VOID *Data,
IN UINTN DataSize,
+ IN UINTN FreeBufSize,
IN VOID *NewData,
- IN UINTN NewDataSize
+ IN UINTN NewDataSize,
+ OUT UINTN *MergedBufSize
);
/**
diff --git a/SecurityPkg/VariableAuthenticated/RuntimeDxe/Variable.c b/SecurityPkg/VariableAuthenticated/RuntimeDxe/Variable.c
index 1595c8c206..576623e88b 100644
--- a/SecurityPkg/VariableAuthenticated/RuntimeDxe/Variable.c
+++ b/SecurityPkg/VariableAuthenticated/RuntimeDxe/Variable.c
@@ -35,12 +35,28 @@ VARIABLE_MODULE_GLOBAL *mVariableModuleGlobal;
///
/// Define a memory cache that improves the search performance for a variable.
///
-VARIABLE_STORE_HEADER *mNvVariableCache = NULL;
+VARIABLE_STORE_HEADER *mNvVariableCache = NULL;
///
/// The memory entry used for variable statistics data.
///
-VARIABLE_INFO_ENTRY *gVariableInfo = NULL;
+VARIABLE_INFO_ENTRY *gVariableInfo = NULL;
+
+///
+/// The list to store the variables which cannot be set after the EFI_END_OF_DXE_EVENT_GROUP_GUID
+/// or EVT_GROUP_READY_TO_BOOT event.
+///
+LIST_ENTRY mLockedVariableList = INITIALIZE_LIST_HEAD_VARIABLE (mLockedVariableList);
+
+///
+/// The flag to indicate whether the platform has left the DXE phase of execution.
+///
+BOOLEAN mEndOfDxe = FALSE;
+
+///
+/// The flag to indicate whether the variable storage locking is enabled.
+///
+BOOLEAN mEnableLocking = TRUE;
/**
@@ -1649,7 +1665,7 @@ UpdateVariable (
EFI_STATUS Status;
VARIABLE_HEADER *NextVariable;
UINTN ScratchSize;
- UINTN ScratchDataSize;
+ UINTN MaxDataSize;
UINTN NonVolatileVarableStoreSize;
UINTN VarNameOffset;
UINTN VarDataOffset;
@@ -1664,7 +1680,6 @@ UpdateVariable (
UINTN CacheOffset;
UINTN BufSize;
UINTN DataOffset;
- UINTN RevBufSize;
if (mVariableModuleGlobal->FvbInstance == NULL) {
//
@@ -1713,7 +1728,7 @@ UpdateVariable (
//
NextVariable = GetEndPointer ((VARIABLE_STORE_HEADER *) ((UINTN) mVariableModuleGlobal->VariableGlobal.VolatileVariableBase));
ScratchSize = MAX (PcdGet32 (PcdMaxVariableSize), PcdGet32 (PcdMaxHardwareErrorVariableSize));
- ScratchDataSize = ScratchSize - sizeof (VARIABLE_HEADER) - StrSize (VariableName) - GET_PAD_SIZE (StrSize (VariableName));
+
if (Variable->CurrPtr != NULL) {
//
@@ -1827,14 +1842,36 @@ UpdateVariable (
DataOffset = sizeof (VARIABLE_HEADER) + Variable->CurrPtr->NameSize + GET_PAD_SIZE (Variable->CurrPtr->NameSize);
CopyMem (mStorageArea, (UINT8*)((UINTN) Variable->CurrPtr + DataOffset), Variable->CurrPtr->DataSize);
+ //
+ // Set Max Common Variable Data Size as default MaxDataSize
+ //
+ MaxDataSize = PcdGet32 (PcdMaxVariableSize) - sizeof (VARIABLE_HEADER) - StrSize (VariableName) - GET_PAD_SIZE (StrSize (VariableName));
+
+
if ((CompareGuid (VendorGuid, &gEfiImageSecurityDatabaseGuid) &&
((StrCmp (VariableName, EFI_IMAGE_SECURITY_DATABASE) == 0) || (StrCmp (VariableName, EFI_IMAGE_SECURITY_DATABASE1) == 0))) ||
(CompareGuid (VendorGuid, &gEfiGlobalVariableGuid) && (StrCmp (VariableName, EFI_KEY_EXCHANGE_KEY_NAME) == 0))) {
+
//
// For variables with formatted as EFI_SIGNATURE_LIST, the driver shall not perform an append of
// EFI_SIGNATURE_DATA values that are already part of the existing variable value.
//
- BufSize = AppendSignatureList (mStorageArea, Variable->CurrPtr->DataSize, Data, DataSize);
+ Status = AppendSignatureList (
+ mStorageArea,
+ Variable->CurrPtr->DataSize,
+ MaxDataSize - Variable->CurrPtr->DataSize,
+ Data,
+ DataSize,
+ &BufSize
+ );
+ if (Status == EFI_BUFFER_TOO_SMALL) {
+ //
+ // Signture List is too long, Failed to Append
+ //
+ Status = EFI_INVALID_PARAMETER;
+ goto Done;
+ }
+
if (BufSize == Variable->CurrPtr->DataSize) {
if ((TimeStamp == NULL) || CompareTimeStamp (TimeStamp, &Variable->CurrPtr->TimeStamp)) {
//
@@ -1849,20 +1886,23 @@ UpdateVariable (
} else {
//
// For other Variables, append the new data to the end of previous data.
+ // Max Harware error record variable data size is different from common variable
//
+ if ((Attributes & EFI_VARIABLE_HARDWARE_ERROR_RECORD) == EFI_VARIABLE_HARDWARE_ERROR_RECORD) {
+ MaxDataSize = PcdGet32 (PcdMaxHardwareErrorVariableSize) - sizeof (VARIABLE_HEADER) - StrSize (VariableName) - GET_PAD_SIZE (StrSize (VariableName));
+ }
+
+ if (Variable->CurrPtr->DataSize + DataSize > MaxDataSize) {
+ //
+ // Exsiting data + Appended data exceed maximum variable size limitation
+ //
+ Status = EFI_INVALID_PARAMETER;
+ goto Done;
+ }
CopyMem ((UINT8*)((UINTN) mStorageArea + Variable->CurrPtr->DataSize), Data, DataSize);
BufSize = Variable->CurrPtr->DataSize + DataSize;
}
- RevBufSize = MIN (PcdGet32 (PcdMaxVariableSize), ScratchDataSize);
- if (BufSize > RevBufSize) {
- //
- // If variable size (previous + current) is bigger than reserved buffer in runtime,
- // return EFI_OUT_OF_RESOURCES.
- //
- return EFI_OUT_OF_RESOURCES;
- }
-
//
// Override Data and DataSize which are used for combined data area including previous and new data.
//
@@ -2288,6 +2328,58 @@ IsHwErrRecVariable (
}
/**
+ Mark a variable that will become read-only after leaving the DXE phase of execution.
+
+ @param[in] This The VARIABLE_LOCK_PROTOCOL instance.
+ @param[in] VariableName A pointer to the variable name that will be made read-only subsequently.
+ @param[in] VendorGuid A pointer to the vendor GUID that will be made read-only subsequently.
+
+ @retval EFI_SUCCESS The variable specified by the VariableName and the VendorGuid was marked
+ as pending to be read-only.
+ @retval EFI_INVALID_PARAMETER VariableName or VendorGuid is NULL.
+ Or VariableName is an empty string.
+ @retval EFI_ACCESS_DENIED EFI_END_OF_DXE_EVENT_GROUP_GUID or EFI_EVENT_GROUP_READY_TO_BOOT has
+ already been signaled.
+ @retval EFI_OUT_OF_RESOURCES There is not enough resource to hold the lock request.
+**/
+EFI_STATUS
+EFIAPI
+VariableLockRequestToLock (
+ IN CONST EDKII_VARIABLE_LOCK_PROTOCOL *This,
+ IN CHAR16 *VariableName,
+ IN EFI_GUID *VendorGuid
+ )
+{
+ VARIABLE_ENTRY *Entry;
+
+ if (VariableName == NULL || VariableName[0] == 0 || VendorGuid == NULL) {
+ return EFI_INVALID_PARAMETER;
+ }
+
+ if (mEndOfDxe) {
+ return EFI_ACCESS_DENIED;
+ }
+
+ Entry = AllocateRuntimePool (sizeof (*Entry) + StrSize (VariableName));
+ if (Entry == NULL) {
+ return EFI_OUT_OF_RESOURCES;
+ }
+
+ DEBUG ((EFI_D_INFO, "[Variable] Lock: %g:%s\n", VendorGuid, VariableName));
+
+ AcquireLockOnlyAtBootTime(&mVariableModuleGlobal->VariableGlobal.VariableServicesLock);
+
+ Entry->Name = (CHAR16 *) (Entry + 1);
+ StrCpy (Entry->Name, VariableName);
+ CopyGuid (&Entry->Guid, VendorGuid);
+ InsertTailList (&mLockedVariableList, &Entry->Link);
+
+ ReleaseLockOnlyAtBootTime (&mVariableModuleGlobal->VariableGlobal.VariableServicesLock);
+
+ return EFI_SUCCESS;
+}
+
+/**
This code checks if variable should be treated as read-only variable.
@param[in] VariableName Name of the Variable.
@@ -2603,6 +2695,8 @@ VariableServiceSetVariable (
VARIABLE_HEADER *NextVariable;
EFI_PHYSICAL_ADDRESS Point;
UINTN PayloadSize;
+ LIST_ENTRY *Link;
+ VARIABLE_ENTRY *Entry;
//
// Check input parameters.
@@ -2664,14 +2758,20 @@ VariableServiceSetVariable (
PayloadSize = DataSize;
}
+ if ((UINTN)(~0) - PayloadSize < StrSize(VariableName)){
+ //
+ // Prevent whole variable size overflow
+ //
+ return EFI_INVALID_PARAMETER;
+ }
+
//
// The size of the VariableName, including the Unicode Null in bytes plus
// the DataSize is limited to maximum size of PcdGet32 (PcdMaxHardwareErrorVariableSize)
// bytes for HwErrRec, and PcdGet32 (PcdMaxVariableSize) bytes for the others.
//
if ((Attributes & EFI_VARIABLE_HARDWARE_ERROR_RECORD) == EFI_VARIABLE_HARDWARE_ERROR_RECORD) {
- if ((PayloadSize > PcdGet32 (PcdMaxHardwareErrorVariableSize)) ||
- (sizeof (VARIABLE_HEADER) + StrSize (VariableName) + PayloadSize > PcdGet32 (PcdMaxHardwareErrorVariableSize))) {
+ if (StrSize (VariableName) + PayloadSize > PcdGet32 (PcdMaxHardwareErrorVariableSize) - sizeof (VARIABLE_HEADER)) {
return EFI_INVALID_PARAMETER;
}
if (!IsHwErrRecVariable(VariableName, VendorGuid)) {
@@ -2682,22 +2782,11 @@ VariableServiceSetVariable (
// The size of the VariableName, including the Unicode Null in bytes plus
// the DataSize is limited to maximum size of PcdGet32 (PcdMaxVariableSize) bytes.
//
- if ((PayloadSize > PcdGet32 (PcdMaxVariableSize)) ||
- (sizeof (VARIABLE_HEADER) + StrSize (VariableName) + PayloadSize > PcdGet32 (PcdMaxVariableSize))) {
+ if (StrSize (VariableName) + PayloadSize > PcdGet32 (PcdMaxVariableSize) - sizeof (VARIABLE_HEADER)) {
return EFI_INVALID_PARAMETER;
}
}
- if (AtRuntime ()) {
- //
- // HwErrRecSupport Global Variable identifies the level of hardware error record persistence
- // support implemented by the platform. This variable is only modified by firmware and is read-only to the OS.
- //
- if (CompareGuid (VendorGuid, &gEfiGlobalVariableGuid) && (StrCmp (VariableName, L"HwErrRecSupport") == 0)) {
- return EFI_WRITE_PROTECTED;
- }
- }
-
AcquireLockOnlyAtBootTime(&mVariableModuleGlobal->VariableGlobal.VariableServicesLock);
//
@@ -2716,13 +2805,31 @@ VariableServiceSetVariable (
mVariableModuleGlobal->NonVolatileLastVariableOffset = (UINTN) NextVariable - (UINTN) Point;
}
+ if (mEndOfDxe && mEnableLocking) {
+ //
+ // Treat the variables listed in the forbidden variable list as read-only after leaving DXE phase.
+ //
+ for ( Link = GetFirstNode (&mLockedVariableList)
+ ; !IsNull (&mLockedVariableList, Link)
+ ; Link = GetNextNode (&mLockedVariableList, Link)
+ ) {
+ Entry = BASE_CR (Link, VARIABLE_ENTRY, Link);
+ if (CompareGuid (&Entry->Guid, VendorGuid) && (StrCmp (Entry->Name, VariableName) == 0)) {
+ Status = EFI_WRITE_PROTECTED;
+ DEBUG ((EFI_D_INFO, "[Variable]: Changing readonly variable after leaving DXE phase - %g:%s\n", VendorGuid, VariableName));
+ goto Done;
+ }
+ }
+ }
+
//
// Check whether the input variable is already existed.
//
Status = FindVariable (VariableName, VendorGuid, &Variable, &mVariableModuleGlobal->VariableGlobal, TRUE);
if (!EFI_ERROR (Status)) {
if (((Variable.CurrPtr->Attributes & EFI_VARIABLE_RUNTIME_ACCESS) == 0) && AtRuntime ()) {
- return EFI_WRITE_PROTECTED;
+ Status = EFI_WRITE_PROTECTED;
+ goto Done;
}
}
@@ -2747,6 +2854,7 @@ VariableServiceSetVariable (
Status = ProcessVariable (VariableName, VendorGuid, Data, DataSize, &Variable, Attributes);
}
+Done:
InterlockedDecrement (&mVariableModuleGlobal->VariableGlobal.ReentrantState);
ReleaseLockOnlyAtBootTime (&mVariableModuleGlobal->VariableGlobal.VariableServicesLock);
diff --git a/SecurityPkg/VariableAuthenticated/RuntimeDxe/Variable.h b/SecurityPkg/VariableAuthenticated/RuntimeDxe/Variable.h
index 4501583648..f394414b3f 100644
--- a/SecurityPkg/VariableAuthenticated/RuntimeDxe/Variable.h
+++ b/SecurityPkg/VariableAuthenticated/RuntimeDxe/Variable.h
@@ -21,6 +21,7 @@ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
#include <Protocol/FaultTolerantWrite.h>
#include <Protocol/FirmwareVolumeBlock.h>
#include <Protocol/Variable.h>
+#include <Protocol/VariableLock.h>
#include <Library/PcdLib.h>
#include <Library/HobLib.h>
#include <Library/UefiDriverEntryPoint.h>
@@ -106,6 +107,12 @@ typedef struct {
VOID *Data;
} VARIABLE_CACHE_ENTRY;
+typedef struct {
+ EFI_GUID Guid;
+ CHAR16 *Name;
+ LIST_ENTRY Link;
+} VARIABLE_ENTRY;
+
/**
Flush the HOB variable to flash.
@@ -577,7 +584,30 @@ VariableServiceQueryVariableInfo (
OUT UINT64 *RemainingVariableStorageSize,
OUT UINT64 *MaximumVariableSize
);
-
+
+/**
+ Mark a variable that will become read-only after leaving the DXE phase of execution.
+
+ @param[in] This The VARIABLE_LOCK_PROTOCOL instance.
+ @param[in] VariableName A pointer to the variable name that will be made read-only subsequently.
+ @param[in] VendorGuid A pointer to the vendor GUID that will be made read-only subsequently.
+
+ @retval EFI_SUCCESS The variable specified by the VariableName and the VendorGuid was marked
+ as pending to be read-only.
+ @retval EFI_INVALID_PARAMETER VariableName or VendorGuid is NULL.
+ Or VariableName is an empty string.
+ @retval EFI_ACCESS_DENIED EFI_END_OF_DXE_EVENT_GROUP_GUID or EFI_EVENT_GROUP_READY_TO_BOOT has
+ already been signaled.
+ @retval EFI_OUT_OF_RESOURCES There is not enough resource to hold the lock request.
+**/
+EFI_STATUS
+EFIAPI
+VariableLockRequestToLock (
+ IN CONST EDKII_VARIABLE_LOCK_PROTOCOL *This,
+ IN CHAR16 *VariableName,
+ IN EFI_GUID *VendorGuid
+ );
+
extern VARIABLE_MODULE_GLOBAL *mVariableModuleGlobal;
#endif
diff --git a/SecurityPkg/VariableAuthenticated/RuntimeDxe/VariableDxe.c b/SecurityPkg/VariableAuthenticated/RuntimeDxe/VariableDxe.c
index f91cb5dc56..a2e764cf61 100644
--- a/SecurityPkg/VariableAuthenticated/RuntimeDxe/VariableDxe.c
+++ b/SecurityPkg/VariableAuthenticated/RuntimeDxe/VariableDxe.c
@@ -16,11 +16,13 @@ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
#include "Variable.h"
#include "AuthService.h"
-extern VARIABLE_STORE_HEADER *mNvVariableCache;
-extern VARIABLE_INFO_ENTRY *gVariableInfo;
-EFI_HANDLE mHandle = NULL;
-EFI_EVENT mVirtualAddressChangeEvent = NULL;
-EFI_EVENT mFtwRegistration = NULL;
+extern VARIABLE_STORE_HEADER *mNvVariableCache;
+extern VARIABLE_INFO_ENTRY *gVariableInfo;
+EFI_HANDLE mHandle = NULL;
+EFI_EVENT mVirtualAddressChangeEvent = NULL;
+EFI_EVENT mFtwRegistration = NULL;
+extern BOOLEAN mEndOfDxe;
+EDKII_VARIABLE_LOCK_PROTOCOL mVariableLock = { VariableLockRequestToLock };
/**
Return TRUE if ExitBootServices () has been called.
@@ -257,12 +259,34 @@ OnReadyToBoot (
VOID *Context
)
{
+ //
+ // Set the End Of DXE bit in case the EFI_END_OF_DXE_EVENT_GROUP_GUID event is not signaled.
+ //
+ mEndOfDxe = TRUE;
ReclaimForOS ();
if (FeaturePcdGet (PcdVariableCollectStatistics)) {
gBS->InstallConfigurationTable (&gEfiAuthenticatedVariableGuid, gVariableInfo);
}
}
+/**
+ Notification function of EFI_END_OF_DXE_EVENT_GROUP_GUID event group.
+
+ This is a notification function registered on EFI_END_OF_DXE_EVENT_GROUP_GUID event group.
+
+ @param Event Event whose notification function is being invoked.
+ @param Context Pointer to the notification function's context.
+
+**/
+VOID
+EFIAPI
+OnEndOfDxe (
+ EFI_EVENT Event,
+ VOID *Context
+ )
+{
+ mEndOfDxe = TRUE;
+}
/**
Fault Tolerant Write protocol notification event handler.
@@ -378,10 +402,19 @@ VariableServiceInitialize (
{
EFI_STATUS Status;
EFI_EVENT ReadyToBootEvent;
+ EFI_EVENT EndOfDxeEvent;
Status = VariableCommonInitialize ();
ASSERT_EFI_ERROR (Status);
+ Status = gBS->InstallMultipleProtocolInterfaces (
+ &mHandle,
+ &gEdkiiVariableLockProtocolGuid,
+ &mVariableLock,
+ NULL
+ );
+ ASSERT_EFI_ERROR (Status);
+
SystemTable->RuntimeServices->GetVariable = VariableServiceGetVariable;
SystemTable->RuntimeServices->GetNextVariableName = VariableServiceGetNextVariableName;
SystemTable->RuntimeServices->SetVariable = VariableServiceSetVariable;
@@ -428,6 +461,20 @@ VariableServiceInitialize (
NULL,
&ReadyToBootEvent
);
+ ASSERT_EFI_ERROR (Status);
+
+ //
+ // Register the event handling function to set the End Of DXE flag.
+ //
+ Status = gBS->CreateEventEx (
+ EVT_NOTIFY_SIGNAL,
+ TPL_NOTIFY,
+ OnEndOfDxe,
+ NULL,
+ &gEfiEndOfDxeEventGroupGuid,
+ &EndOfDxeEvent
+ );
+ ASSERT_EFI_ERROR (Status);
return EFI_SUCCESS;
}
diff --git a/SecurityPkg/VariableAuthenticated/RuntimeDxe/VariableRuntimeDxe.inf b/SecurityPkg/VariableAuthenticated/RuntimeDxe/VariableRuntimeDxe.inf
index ab676f456a..dbd7d6e470 100644
--- a/SecurityPkg/VariableAuthenticated/RuntimeDxe/VariableRuntimeDxe.inf
+++ b/SecurityPkg/VariableAuthenticated/RuntimeDxe/VariableRuntimeDxe.inf
@@ -67,11 +67,12 @@
gEfiVariableWriteArchProtocolGuid ## ALWAYS_PRODUCES
gEfiVariableArchProtocolGuid ## ALWAYS_PRODUCES
gEfiFaultTolerantWriteProtocolGuid ## SOMETIMES_CONSUMES
+ gEdkiiVariableLockProtocolGuid ## ALWAYS_PRODUCES
[Guids]
gEfiAuthenticatedVariableGuid ## PRODUCES ## Configuration Table Guid
gEfiGlobalVariableGuid ## PRODUCES ## Variable Guid
- gEfiEventVirtualAddressChangeGuid ## PRODUCES ## Event
+ gEfiEventVirtualAddressChangeGuid ## CONSUMES ## Event
gEfiCertTypeRsa2048Sha256Guid
gEfiImageSecurityDatabaseGuid
gEfiCertX509Guid
@@ -82,6 +83,7 @@
gEfiSystemNvDataFvGuid ## CONSUMES
gEfiCertDbGuid
gEfiHardwareErrorVariableGuid ## SOMETIMES_CONSUMES
+ gEfiEndOfDxeEventGroupGuid ## CONSUMES ## Event
[Pcd]
gEfiMdeModulePkgTokenSpaceGuid.PcdFlashNvStorageVariableSize
diff --git a/SecurityPkg/VariableAuthenticated/RuntimeDxe/VariableSmm.c b/SecurityPkg/VariableAuthenticated/RuntimeDxe/VariableSmm.c
index 316845f045..0be4f254d7 100644
--- a/SecurityPkg/VariableAuthenticated/RuntimeDxe/VariableSmm.c
+++ b/SecurityPkg/VariableAuthenticated/RuntimeDxe/VariableSmm.c
@@ -14,7 +14,7 @@
VariableServiceSetVariable(), VariableServiceQueryVariableInfo(), ReclaimForOS(),
SmmVariableGetStatistics() should also do validation based on its own knowledge.
-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
@@ -29,6 +29,7 @@ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
#include <Protocol/SmmFirmwareVolumeBlock.h>
#include <Protocol/SmmFaultTolerantWrite.h>
#include <Protocol/SmmAccess2.h>
+#include <Protocol/SmmEndOfDxe.h>
#include <Library/SmmServicesTableLib.h>
@@ -44,15 +45,63 @@ EFI_HANDLE mSmmVariableHandle = N
EFI_HANDLE mVariableHandle = NULL;
BOOLEAN mAtRuntime = FALSE;
EFI_GUID mZeroGuid = {0, 0, 0, {0, 0, 0, 0, 0, 0, 0, 0}};
-
+UINT8 *mVariableBufferPayload = NULL;
+UINTN mVariableBufferPayloadSize;
+extern BOOLEAN mEndOfDxe;
+extern BOOLEAN mEnableLocking;
+
+/**
+
+ This code sets variable in storage blocks (Volatile or Non-Volatile).
+
+ @param VariableName Name of Variable to be found.
+ @param VendorGuid Variable vendor GUID.
+ @param Attributes Attribute value of the variable found
+ @param DataSize Size of Data found. If size is less than the
+ data, this value contains the required size.
+ @param Data Data pointer.
+
+ @return EFI_INVALID_PARAMETER Invalid parameter.
+ @return EFI_SUCCESS Set successfully.
+ @return EFI_OUT_OF_RESOURCES Resource not enough to set variable.
+ @return EFI_NOT_FOUND Not found.
+ @return EFI_WRITE_PROTECTED Variable is read-only.
+
+**/
+EFI_STATUS
+EFIAPI
+SmmVariableSetVariable (
+ IN CHAR16 *VariableName,
+ IN EFI_GUID *VendorGuid,
+ IN UINT32 Attributes,
+ IN UINTN DataSize,
+ IN VOID *Data
+ )
+{
+ EFI_STATUS Status;
+
+ //
+ // Disable write protection when the calling SetVariable() through EFI_SMM_VARIABLE_PROTOCOL.
+ //
+ mEnableLocking = FALSE;
+ Status = VariableServiceSetVariable (
+ VariableName,
+ VendorGuid,
+ Attributes,
+ DataSize,
+ Data
+ );
+ mEnableLocking = TRUE;
+ return Status;
+}
+
EFI_SMM_VARIABLE_PROTOCOL gSmmVariable = {
VariableServiceGetVariable,
VariableServiceGetNextVariableName,
- VariableServiceSetVariable,
+ SmmVariableSetVariable,
VariableServiceQueryVariableInfo
};
-
/**
Return TRUE if ExitBootServices () has been called.
@@ -93,6 +142,32 @@ InternalIsAddressInSmram (
return FALSE;
}
+/**
+ This function check if the address refered by Buffer and Length is valid.
+
+ @param Buffer the buffer address to be checked.
+ @param Length the buffer length to be checked.
+
+ @retval TRUE this address is valid.
+ @retval FALSE this address is NOT valid.
+**/
+BOOLEAN
+InternalIsAddressValid (
+ IN UINTN Buffer,
+ IN UINTN Length
+ )
+{
+ if (Buffer > (MAX_ADDRESS - Length)) {
+ //
+ // Overflow happen
+ //
+ return FALSE;
+ }
+ if (InternalIsAddressInSmram ((EFI_PHYSICAL_ADDRESS)Buffer, (UINT64)Length)) {
+ return FALSE;
+ }
+ return TRUE;
+}
/**
Initializes a basic mutual exclusion lock.
@@ -276,6 +351,8 @@ GetFvbCountAndBuffer (
*NumberHandles = BufferSize / sizeof(EFI_HANDLE);
if (EFI_ERROR(Status)) {
*NumberHandles = 0;
+ FreePool (*Buffer);
+ *Buffer = NULL;
}
return Status;
@@ -312,6 +389,7 @@ SmmVariableGetStatistics (
UINTN NameLength;
UINTN StatisticsInfoSize;
CHAR16 *InfoName;
+ EFI_GUID VendorGuid;
if (InfoEntry == NULL) {
return EFI_INVALID_PARAMETER;
@@ -329,7 +407,9 @@ SmmVariableGetStatistics (
}
InfoName = (CHAR16 *)(InfoEntry + 1);
- if (CompareGuid (&InfoEntry->VendorGuid, &mZeroGuid)) {
+ CopyGuid (&VendorGuid, &InfoEntry->VendorGuid);
+
+ if (CompareGuid (&VendorGuid, &mZeroGuid)) {
//
// Return the first variable info
//
@@ -343,7 +423,7 @@ SmmVariableGetStatistics (
// Get the next variable info
//
while (VariableInfo != NULL) {
- if (CompareGuid (&VariableInfo->VendorGuid, &InfoEntry->VendorGuid)) {
+ if (CompareGuid (&VariableInfo->VendorGuid, &VendorGuid)) {
NameLength = StrSize (VariableInfo->Name);
if (NameLength == StrSize (InfoName)) {
if (CompareMem (VariableInfo->Name, InfoName, NameLength) == 0) {
@@ -422,7 +502,11 @@ SmmVariableHandler (
SMM_VARIABLE_COMMUNICATE_GET_NEXT_VARIABLE_NAME *GetNextVariableName;
SMM_VARIABLE_COMMUNICATE_QUERY_VARIABLE_INFO *QueryVariableInfo;
VARIABLE_INFO_ENTRY *VariableInfo;
+ SMM_VARIABLE_COMMUNICATE_LOCK_VARIABLE *VariableToLock;
UINTN InfoSize;
+ UINTN NameBufferSize;
+ UINTN CommBufferPayloadSize;
+ UINTN TempCommBufferSize;
//
// If input is invalid, stop processing this SMI
@@ -431,12 +515,20 @@ SmmVariableHandler (
return EFI_SUCCESS;
}
- if (*CommBufferSize < SMM_VARIABLE_COMMUNICATE_HEADER_SIZE) {
+ TempCommBufferSize = *CommBufferSize;
+
+ if (TempCommBufferSize < SMM_VARIABLE_COMMUNICATE_HEADER_SIZE) {
+ DEBUG ((EFI_D_ERROR, "SmmVariableHandler: SMM communication buffer size invalid!\n"));
+ return EFI_SUCCESS;
+ }
+ CommBufferPayloadSize = TempCommBufferSize - SMM_VARIABLE_COMMUNICATE_HEADER_SIZE;
+ if (CommBufferPayloadSize > mVariableBufferPayloadSize) {
+ DEBUG ((EFI_D_ERROR, "SmmVariableHandler: SMM communication buffer payload size invalid!\n"));
return EFI_SUCCESS;
}
- if (InternalIsAddressInSmram ((EFI_PHYSICAL_ADDRESS)(UINTN)CommBuffer, *CommBufferSize)) {
- DEBUG ((EFI_D_ERROR, "SMM communication buffer size is in SMRAM!\n"));
+ if (!InternalIsAddressValid ((UINTN)CommBuffer, TempCommBufferSize)) {
+ DEBUG ((EFI_D_ERROR, "SmmVariableHandler: SMM communication buffer in SMRAM or overflow!\n"));
return EFI_SUCCESS;
}
@@ -444,15 +536,39 @@ SmmVariableHandler (
switch (SmmVariableFunctionHeader->Function) {
case SMM_VARIABLE_FUNCTION_GET_VARIABLE:
- SmmVariableHeader = (SMM_VARIABLE_COMMUNICATE_ACCESS_VARIABLE *) SmmVariableFunctionHeader->Data;
+ if (CommBufferPayloadSize < OFFSET_OF(SMM_VARIABLE_COMMUNICATE_ACCESS_VARIABLE, Name)) {
+ DEBUG ((EFI_D_ERROR, "GetVariable: SMM communication buffer size invalid!\n"));
+ return EFI_SUCCESS;
+ }
+ //
+ // Copy the input communicate buffer payload to pre-allocated SMM variable buffer payload.
+ //
+ CopyMem (mVariableBufferPayload, SmmVariableFunctionHeader->Data, CommBufferPayloadSize);
+ SmmVariableHeader = (SMM_VARIABLE_COMMUNICATE_ACCESS_VARIABLE *) mVariableBufferPayload;
+ if (((UINTN)(~0) - SmmVariableHeader->DataSize < OFFSET_OF(SMM_VARIABLE_COMMUNICATE_ACCESS_VARIABLE, Name)) ||
+ ((UINTN)(~0) - SmmVariableHeader->NameSize < OFFSET_OF(SMM_VARIABLE_COMMUNICATE_ACCESS_VARIABLE, Name) + SmmVariableHeader->DataSize)) {
+ //
+ // Prevent InfoSize overflow happen
+ //
+ Status = EFI_ACCESS_DENIED;
+ goto EXIT;
+ }
InfoSize = OFFSET_OF(SMM_VARIABLE_COMMUNICATE_ACCESS_VARIABLE, Name)
+ SmmVariableHeader->DataSize + SmmVariableHeader->NameSize;
//
// SMRAM range check already covered before
//
- if (InfoSize > *CommBufferSize - SMM_VARIABLE_COMMUNICATE_HEADER_SIZE) {
- DEBUG ((EFI_D_ERROR, "Data size exceed communication buffer size limit!\n"));
+ if (InfoSize > CommBufferPayloadSize) {
+ DEBUG ((EFI_D_ERROR, "GetVariable: Data size exceed communication buffer size limit!\n"));
+ Status = EFI_ACCESS_DENIED;
+ goto EXIT;
+ }
+
+ if (SmmVariableHeader->NameSize < sizeof (CHAR16) || SmmVariableHeader->Name[SmmVariableHeader->NameSize/sizeof (CHAR16) - 1] != L'\0') {
+ //
+ // Make sure VariableName is A Null-terminated string.
+ //
Status = EFI_ACCESS_DENIED;
goto EXIT;
}
@@ -464,17 +580,42 @@ SmmVariableHandler (
&SmmVariableHeader->DataSize,
(UINT8 *)SmmVariableHeader->Name + SmmVariableHeader->NameSize
);
+ CopyMem (SmmVariableFunctionHeader->Data, mVariableBufferPayload, CommBufferPayloadSize);
break;
case SMM_VARIABLE_FUNCTION_GET_NEXT_VARIABLE_NAME:
- GetNextVariableName = (SMM_VARIABLE_COMMUNICATE_GET_NEXT_VARIABLE_NAME *) SmmVariableFunctionHeader->Data;
+ if (CommBufferPayloadSize < OFFSET_OF(SMM_VARIABLE_COMMUNICATE_GET_NEXT_VARIABLE_NAME, Name)) {
+ DEBUG ((EFI_D_ERROR, "GetNextVariableName: SMM communication buffer size invalid!\n"));
+ return EFI_SUCCESS;
+ }
+ //
+ // Copy the input communicate buffer payload to pre-allocated SMM variable buffer payload.
+ //
+ CopyMem (mVariableBufferPayload, SmmVariableFunctionHeader->Data, CommBufferPayloadSize);
+ GetNextVariableName = (SMM_VARIABLE_COMMUNICATE_GET_NEXT_VARIABLE_NAME *) mVariableBufferPayload;
+ if ((UINTN)(~0) - GetNextVariableName->NameSize < OFFSET_OF(SMM_VARIABLE_COMMUNICATE_GET_NEXT_VARIABLE_NAME, Name)) {
+ //
+ // Prevent InfoSize overflow happen
+ //
+ Status = EFI_ACCESS_DENIED;
+ goto EXIT;
+ }
InfoSize = OFFSET_OF(SMM_VARIABLE_COMMUNICATE_GET_NEXT_VARIABLE_NAME, Name) + GetNextVariableName->NameSize;
//
// SMRAM range check already covered before
//
- if (InfoSize > *CommBufferSize - SMM_VARIABLE_COMMUNICATE_HEADER_SIZE) {
- DEBUG ((EFI_D_ERROR, "Data size exceed communication buffer size limit!\n"));
+ if (InfoSize > CommBufferPayloadSize) {
+ DEBUG ((EFI_D_ERROR, "GetNextVariableName: Data size exceed communication buffer size limit!\n"));
+ Status = EFI_ACCESS_DENIED;
+ goto EXIT;
+ }
+
+ NameBufferSize = CommBufferPayloadSize - OFFSET_OF(SMM_VARIABLE_COMMUNICATE_GET_NEXT_VARIABLE_NAME, Name);
+ if (NameBufferSize < sizeof (CHAR16) || GetNextVariableName->Name[NameBufferSize/sizeof (CHAR16) - 1] != L'\0') {
+ //
+ // Make sure input VariableName is A Null-terminated string.
+ //
Status = EFI_ACCESS_DENIED;
goto EXIT;
}
@@ -484,10 +625,48 @@ SmmVariableHandler (
GetNextVariableName->Name,
&GetNextVariableName->Guid
);
+ CopyMem (SmmVariableFunctionHeader->Data, mVariableBufferPayload, CommBufferPayloadSize);
break;
case SMM_VARIABLE_FUNCTION_SET_VARIABLE:
- SmmVariableHeader = (SMM_VARIABLE_COMMUNICATE_ACCESS_VARIABLE *) SmmVariableFunctionHeader->Data;
+ if (CommBufferPayloadSize < OFFSET_OF(SMM_VARIABLE_COMMUNICATE_ACCESS_VARIABLE, Name)) {
+ DEBUG ((EFI_D_ERROR, "SetVariable: SMM communication buffer size invalid!\n"));
+ return EFI_SUCCESS;
+ }
+ //
+ // Copy the input communicate buffer payload to pre-allocated SMM variable buffer payload.
+ //
+ CopyMem (mVariableBufferPayload, SmmVariableFunctionHeader->Data, CommBufferPayloadSize);
+ SmmVariableHeader = (SMM_VARIABLE_COMMUNICATE_ACCESS_VARIABLE *) mVariableBufferPayload;
+ if (((UINTN)(~0) - SmmVariableHeader->DataSize < OFFSET_OF(SMM_VARIABLE_COMMUNICATE_ACCESS_VARIABLE, Name)) ||
+ ((UINTN)(~0) - SmmVariableHeader->NameSize < OFFSET_OF(SMM_VARIABLE_COMMUNICATE_ACCESS_VARIABLE, Name) + SmmVariableHeader->DataSize)) {
+ //
+ // Prevent InfoSize overflow happen
+ //
+ Status = EFI_ACCESS_DENIED;
+ goto EXIT;
+ }
+ InfoSize = OFFSET_OF(SMM_VARIABLE_COMMUNICATE_ACCESS_VARIABLE, Name)
+ + SmmVariableHeader->DataSize + SmmVariableHeader->NameSize;
+
+ //
+ // SMRAM range check already covered before
+ // Data buffer should not contain SMM range
+ //
+ if (InfoSize > CommBufferPayloadSize) {
+ DEBUG ((EFI_D_ERROR, "SetVariable: Data size exceed communication buffer size limit!\n"));
+ Status = EFI_ACCESS_DENIED;
+ goto EXIT;
+ }
+
+ if (SmmVariableHeader->NameSize < sizeof (CHAR16) || SmmVariableHeader->Name[SmmVariableHeader->NameSize/sizeof (CHAR16) - 1] != L'\0') {
+ //
+ // Make sure VariableName is A Null-terminated string.
+ //
+ Status = EFI_ACCESS_DENIED;
+ goto EXIT;
+ }
+
Status = VariableServiceSetVariable (
SmmVariableHeader->Name,
&SmmVariableHeader->Guid,
@@ -498,17 +677,11 @@ SmmVariableHandler (
break;
case SMM_VARIABLE_FUNCTION_QUERY_VARIABLE_INFO:
- QueryVariableInfo = (SMM_VARIABLE_COMMUNICATE_QUERY_VARIABLE_INFO *) SmmVariableFunctionHeader->Data;
- InfoSize = sizeof(SMM_VARIABLE_COMMUNICATE_QUERY_VARIABLE_INFO);
-
- //
- // SMRAM range check already covered before
- //
- if (InfoSize > *CommBufferSize - SMM_VARIABLE_COMMUNICATE_HEADER_SIZE) {
- DEBUG ((EFI_D_ERROR, "Data size exceed communication buffer size limit!\n"));
- Status = EFI_ACCESS_DENIED;
- goto EXIT;
+ if (CommBufferPayloadSize < sizeof (SMM_VARIABLE_COMMUNICATE_QUERY_VARIABLE_INFO)) {
+ DEBUG ((EFI_D_ERROR, "QueryVariableInfo: SMM communication buffer size invalid!\n"));
+ return EFI_SUCCESS;
}
+ QueryVariableInfo = (SMM_VARIABLE_COMMUNICATE_QUERY_VARIABLE_INFO *) SmmVariableFunctionHeader->Data;
Status = VariableServiceQueryVariableInfo (
QueryVariableInfo->Attributes,
@@ -519,6 +692,7 @@ SmmVariableHandler (
break;
case SMM_VARIABLE_FUNCTION_READY_TO_BOOT:
+ mEndOfDxe = TRUE;
if (AtRuntime()) {
Status = EFI_UNSUPPORTED;
break;
@@ -534,7 +708,7 @@ SmmVariableHandler (
case SMM_VARIABLE_FUNCTION_GET_STATISTICS:
VariableInfo = (VARIABLE_INFO_ENTRY *) SmmVariableFunctionHeader->Data;
- InfoSize = *CommBufferSize - SMM_VARIABLE_COMMUNICATE_HEADER_SIZE;
+ InfoSize = TempCommBufferSize - SMM_VARIABLE_COMMUNICATE_HEADER_SIZE;
//
// Do not need to check SmmVariableFunctionHeader->Data in SMRAM here.
@@ -542,7 +716,7 @@ SmmVariableHandler (
//
if (InternalIsAddressInSmram ((EFI_PHYSICAL_ADDRESS)(UINTN)CommBufferSize, sizeof(UINTN))) {
- DEBUG ((EFI_D_ERROR, "SMM communication buffer size is in SMRAM!\n"));
+ DEBUG ((EFI_D_ERROR, "GetStatistics: SMM communication buffer in SMRAM!\n"));
Status = EFI_ACCESS_DENIED;
goto EXIT;
}
@@ -551,6 +725,19 @@ SmmVariableHandler (
*CommBufferSize = InfoSize + SMM_VARIABLE_COMMUNICATE_HEADER_SIZE;
break;
+ case SMM_VARIABLE_FUNCTION_LOCK_VARIABLE:
+ if (mEndOfDxe) {
+ Status = EFI_ACCESS_DENIED;
+ } else {
+ VariableToLock = (SMM_VARIABLE_COMMUNICATE_LOCK_VARIABLE *) SmmVariableFunctionHeader->Data;
+ Status = VariableLockRequestToLock (
+ NULL,
+ VariableToLock->Name,
+ &VariableToLock->Guid
+ );
+ }
+ break;
+
default:
Status = EFI_UNSUPPORTED;
}
@@ -561,6 +748,28 @@ EXIT:
return EFI_SUCCESS;
}
+/**
+ SMM END_OF_DXE protocol notification event handler.
+
+ @param Protocol Points to the protocol's unique identifier
+ @param Interface Points to the interface instance
+ @param Handle The handle on which the interface was installed
+
+ @retval EFI_SUCCESS SmmEndOfDxeCallback runs successfully
+
+**/
+EFI_STATUS
+EFIAPI
+SmmEndOfDxeCallback (
+ IN CONST EFI_GUID *Protocol,
+ IN VOID *Interface,
+ IN EFI_HANDLE Handle
+ )
+{
+ DEBUG ((EFI_D_INFO, "[Variable]END_OF_DXE is signaled\n"));
+ mEndOfDxe = TRUE;
+ return EFI_SUCCESS;
+}
/**
SMM Fault Tolerant Write protocol notification event handler.
@@ -657,6 +866,7 @@ VariableServiceInitialize (
VOID *SmmFtwRegistration;
EFI_SMM_ACCESS2_PROTOCOL *SmmAccess;
UINTN Size;
+ VOID *SmmEndOfDxeRegistration;
//
// Variable initialize.
@@ -698,6 +908,16 @@ VariableServiceInitialize (
mSmramRangeCount = Size / sizeof (EFI_SMRAM_DESCRIPTOR);
+ mVariableBufferPayloadSize = MAX (PcdGet32 (PcdMaxVariableSize), PcdGet32 (PcdMaxHardwareErrorVariableSize)) +
+ OFFSET_OF (SMM_VARIABLE_COMMUNICATE_ACCESS_VARIABLE, Name) - sizeof (VARIABLE_HEADER);
+
+ Status = gSmst->SmmAllocatePool (
+ EfiRuntimeServicesData,
+ mVariableBufferPayloadSize,
+ (VOID **)&mVariableBufferPayload
+ );
+ ASSERT_EFI_ERROR (Status);
+
///
/// Register SMM variable SMI handler
///
@@ -717,6 +937,16 @@ VariableServiceInitialize (
ASSERT_EFI_ERROR (Status);
//
+ // Register EFI_SMM_END_OF_DXE_PROTOCOL_GUID notify function.
+ //
+ Status = gSmst->SmmRegisterProtocolNotify (
+ &gEfiSmmEndOfDxeProtocolGuid,
+ SmmEndOfDxeCallback,
+ &SmmEndOfDxeRegistration
+ );
+ ASSERT_EFI_ERROR (Status);
+
+ //
// Register FtwNotificationEvent () notify function.
//
Status = gSmst->SmmRegisterProtocolNotify (
diff --git a/SecurityPkg/VariableAuthenticated/RuntimeDxe/VariableSmm.inf b/SecurityPkg/VariableAuthenticated/RuntimeDxe/VariableSmm.inf
index e0aa40ac6d..a9a10976eb 100644
--- a/SecurityPkg/VariableAuthenticated/RuntimeDxe/VariableSmm.inf
+++ b/SecurityPkg/VariableAuthenticated/RuntimeDxe/VariableSmm.inf
@@ -73,6 +73,7 @@
gEfiSmmVariableProtocolGuid ## ALWAYS_PRODUCES
gEfiSmmFaultTolerantWriteProtocolGuid ## SOMETIMES_CONSUMES
gEfiSmmAccess2ProtocolGuid ## ALWAYS_CONSUMES
+ gEfiSmmEndOfDxeProtocolGuid ## ALWAYS_CONSUMES
[Guids]
gEfiAuthenticatedVariableGuid ## PRODUCES ## Configuration Table Guid
diff --git a/SecurityPkg/VariableAuthenticated/RuntimeDxe/VariableSmmRuntimeDxe.c b/SecurityPkg/VariableAuthenticated/RuntimeDxe/VariableSmmRuntimeDxe.c
index 103a12914a..7011343872 100644
--- a/SecurityPkg/VariableAuthenticated/RuntimeDxe/VariableSmmRuntimeDxe.c
+++ b/SecurityPkg/VariableAuthenticated/RuntimeDxe/VariableSmmRuntimeDxe.c
@@ -29,6 +29,7 @@ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
#include <Protocol/Variable.h>
#include <Protocol/SmmCommunication.h>
#include <Protocol/SmmVariable.h>
+#include <Protocol/VariableLock.h>
#include <Library/UefiBootServicesTableLib.h>
#include <Library/UefiRuntimeServicesTableLib.h>
@@ -52,7 +53,9 @@ EFI_SMM_COMMUNICATION_PROTOCOL *mSmmCommunication = NULL;
UINT8 *mVariableBuffer = NULL;
UINT8 *mVariableBufferPhysical = NULL;
UINTN mVariableBufferSize;
+UINTN mVariableBufferPayloadSize;
EFI_LOCK mVariableServicesLock;
+EDKII_VARIABLE_LOCK_PROTOCOL mVariableLock;
/**
Acquires lock only at boot time. Simply returns at runtime.
@@ -172,6 +175,73 @@ SendCommunicateBuffer (
return SmmVariableFunctionHeader->ReturnStatus;
}
+/**
+ Mark a variable that will become read-only after leaving the DXE phase of execution.
+
+ @param[in] This The VARIABLE_LOCK_PROTOCOL instance.
+ @param[in] VariableName A pointer to the variable name that will be made read-only subsequently.
+ @param[in] VendorGuid A pointer to the vendor GUID that will be made read-only subsequently.
+
+ @retval EFI_SUCCESS The variable specified by the VariableName and the VendorGuid was marked
+ as pending to be read-only.
+ @retval EFI_INVALID_PARAMETER VariableName or VendorGuid is NULL.
+ Or VariableName is an empty string.
+ @retval EFI_ACCESS_DENIED EFI_END_OF_DXE_EVENT_GROUP_GUID or EFI_EVENT_GROUP_READY_TO_BOOT has
+ already been signaled.
+ @retval EFI_OUT_OF_RESOURCES There is not enough resource to hold the lock request.
+**/
+EFI_STATUS
+EFIAPI
+VariableLockRequestToLock (
+ IN CONST EDKII_VARIABLE_LOCK_PROTOCOL *This,
+ IN CHAR16 *VariableName,
+ IN EFI_GUID *VendorGuid
+ )
+{
+ EFI_STATUS Status;
+ UINTN VariableNameSize;
+ UINTN PayloadSize;
+ SMM_VARIABLE_COMMUNICATE_LOCK_VARIABLE *VariableToLock;
+
+ if (VariableName == NULL || VariableName[0] == 0 || VendorGuid == NULL) {
+ return EFI_INVALID_PARAMETER;
+ }
+
+ VariableNameSize = StrSize (VariableName);
+
+ //
+ // If VariableName exceeds SMM payload limit. Return failure
+ //
+ if (VariableNameSize > mVariableBufferPayloadSize - OFFSET_OF (SMM_VARIABLE_COMMUNICATE_LOCK_VARIABLE, Name)) {
+ return EFI_INVALID_PARAMETER;
+ }
+
+ AcquireLockOnlyAtBootTime(&mVariableServicesLock);
+
+ //
+ // Init the communicate buffer. The buffer data size is:
+ // SMM_COMMUNICATE_HEADER_SIZE + SMM_VARIABLE_COMMUNICATE_HEADER_SIZE + PayloadSize.
+ //
+ PayloadSize = OFFSET_OF (SMM_VARIABLE_COMMUNICATE_LOCK_VARIABLE, Name) + VariableNameSize;
+ Status = InitCommunicateBuffer ((VOID **) &VariableToLock, PayloadSize, SMM_VARIABLE_FUNCTION_LOCK_VARIABLE);
+ if (EFI_ERROR (Status)) {
+ goto Done;
+ }
+ ASSERT (VariableToLock != NULL);
+
+ CopyGuid (&VariableToLock->Guid, VendorGuid);
+ VariableToLock->NameSize = VariableNameSize;
+ CopyMem (VariableToLock->Name, VariableName, VariableToLock->NameSize);
+
+ //
+ // Send data to SMM.
+ //
+ Status = SendCommunicateBuffer (PayloadSize);
+
+Done:
+ ReleaseLockOnlyAtBootTime (&mVariableServicesLock);
+ return Status;
+}
/**
This code finds variable in storage blocks (Volatile or Non-Volatile).
@@ -205,6 +275,8 @@ RuntimeServiceGetVariable (
EFI_STATUS Status;
UINTN PayloadSize;
SMM_VARIABLE_COMMUNICATE_ACCESS_VARIABLE *SmmVariableHeader;
+ UINTN TempDataSize;
+ UINTN VariableNameSize;
if (VariableName == NULL || VendorGuid == NULL || DataSize == NULL) {
return EFI_INVALID_PARAMETER;
@@ -214,13 +286,13 @@ RuntimeServiceGetVariable (
return EFI_INVALID_PARAMETER;
}
- if (*DataSize >= mVariableBufferSize) {
- //
- // DataSize may be near MAX_ADDRESS incorrectly, this can cause the computed PayLoadSize to
- // overflow to a small value and pass the check in InitCommunicateBuffer().
- // To protect against this vulnerability, return EFI_INVALID_PARAMETER if DataSize is >= mVariableBufferSize.
- // And there will be further check to ensure the total size is also not > mVariableBufferSize.
- //
+ TempDataSize = *DataSize;
+ VariableNameSize = StrSize (VariableName);
+
+ //
+ // If VariableName exceeds SMM payload limit. Return failure
+ //
+ if (VariableNameSize > mVariableBufferPayloadSize - OFFSET_OF (SMM_VARIABLE_COMMUNICATE_ACCESS_VARIABLE, Name)) {
return EFI_INVALID_PARAMETER;
}
@@ -230,7 +302,14 @@ RuntimeServiceGetVariable (
// Init the communicate buffer. The buffer data size is:
// SMM_COMMUNICATE_HEADER_SIZE + SMM_VARIABLE_COMMUNICATE_HEADER_SIZE + PayloadSize.
//
- PayloadSize = OFFSET_OF (SMM_VARIABLE_COMMUNICATE_ACCESS_VARIABLE, Name) + StrSize (VariableName) + *DataSize;
+ if (TempDataSize > mVariableBufferPayloadSize - OFFSET_OF (SMM_VARIABLE_COMMUNICATE_ACCESS_VARIABLE, Name) - VariableNameSize) {
+ //
+ // If output data buffer exceed SMM payload limit. Trim output buffer to SMM payload size
+ //
+ TempDataSize = mVariableBufferPayloadSize - OFFSET_OF (SMM_VARIABLE_COMMUNICATE_ACCESS_VARIABLE, Name) - VariableNameSize;
+ }
+ PayloadSize = OFFSET_OF (SMM_VARIABLE_COMMUNICATE_ACCESS_VARIABLE, Name) + VariableNameSize + TempDataSize;
+
Status = InitCommunicateBuffer ((VOID **)&SmmVariableHeader, PayloadSize, SMM_VARIABLE_FUNCTION_GET_VARIABLE);
if (EFI_ERROR (Status)) {
goto Done;
@@ -238,8 +317,8 @@ RuntimeServiceGetVariable (
ASSERT (SmmVariableHeader != NULL);
CopyGuid (&SmmVariableHeader->Guid, VendorGuid);
- SmmVariableHeader->DataSize = *DataSize;
- SmmVariableHeader->NameSize = StrSize (VariableName);
+ SmmVariableHeader->DataSize = TempDataSize;
+ SmmVariableHeader->NameSize = VariableNameSize;
if (Attributes == NULL) {
SmmVariableHeader->Attributes = 0;
} else {
@@ -255,7 +334,13 @@ RuntimeServiceGetVariable (
//
// Get data from SMM.
//
- *DataSize = SmmVariableHeader->DataSize;
+ if (Status == EFI_SUCCESS || Status == EFI_BUFFER_TOO_SMALL) {
+ //
+ // SMM CommBuffer DataSize can be a trimed value
+ // Only update DataSize when needed
+ //
+ *DataSize = SmmVariableHeader->DataSize;
+ }
if (Attributes != NULL) {
*Attributes = SmmVariableHeader->Attributes;
}
@@ -296,18 +381,20 @@ RuntimeServiceGetNextVariableName (
EFI_STATUS Status;
UINTN PayloadSize;
SMM_VARIABLE_COMMUNICATE_GET_NEXT_VARIABLE_NAME *SmmGetNextVariableName;
+ UINTN OutVariableNameSize;
+ UINTN InVariableNameSize;
if (VariableNameSize == NULL || VariableName == NULL || VendorGuid == NULL) {
return EFI_INVALID_PARAMETER;
}
- if (*VariableNameSize >= mVariableBufferSize) {
- //
- // VariableNameSize may be near MAX_ADDRESS incorrectly, this can cause the computed PayLoadSize to
- // overflow to a small value and pass the check in InitCommunicateBuffer().
- // To protect against this vulnerability, return EFI_INVALID_PARAMETER if VariableNameSize is >= mVariableBufferSize.
- // And there will be further check to ensure the total size is also not > mVariableBufferSize.
- //
+ OutVariableNameSize = *VariableNameSize;
+ InVariableNameSize = StrSize (VariableName);
+
+ //
+ // If input string exceeds SMM payload limit. Return failure
+ //
+ if (InVariableNameSize > mVariableBufferPayloadSize - OFFSET_OF (SMM_VARIABLE_COMMUNICATE_GET_NEXT_VARIABLE_NAME, Name)) {
return EFI_INVALID_PARAMETER;
}
@@ -317,16 +404,36 @@ RuntimeServiceGetNextVariableName (
// Init the communicate buffer. The buffer data size is:
// SMM_COMMUNICATE_HEADER_SIZE + SMM_VARIABLE_COMMUNICATE_HEADER_SIZE + PayloadSize.
//
- PayloadSize = OFFSET_OF (SMM_VARIABLE_COMMUNICATE_GET_NEXT_VARIABLE_NAME, Name) + *VariableNameSize;
+ if (OutVariableNameSize > mVariableBufferPayloadSize - OFFSET_OF (SMM_VARIABLE_COMMUNICATE_GET_NEXT_VARIABLE_NAME, Name)) {
+ //
+ // If output buffer exceed SMM payload limit. Trim output buffer to SMM payload size
+ //
+ OutVariableNameSize = mVariableBufferPayloadSize - OFFSET_OF (SMM_VARIABLE_COMMUNICATE_GET_NEXT_VARIABLE_NAME, Name);
+ }
+ //
+ // Payload should be Guid + NameSize + MAX of Input & Output buffer
+ //
+ PayloadSize = OFFSET_OF (SMM_VARIABLE_COMMUNICATE_GET_NEXT_VARIABLE_NAME, Name) + MAX (OutVariableNameSize, InVariableNameSize);
+
Status = InitCommunicateBuffer ((VOID **)&SmmGetNextVariableName, PayloadSize, SMM_VARIABLE_FUNCTION_GET_NEXT_VARIABLE_NAME);
if (EFI_ERROR (Status)) {
goto Done;
}
ASSERT (SmmGetNextVariableName != NULL);
- SmmGetNextVariableName->NameSize = *VariableNameSize;
+ //
+ // SMM comm buffer->NameSize is buffer size for return string
+ //
+ SmmGetNextVariableName->NameSize = OutVariableNameSize;
+
CopyGuid (&SmmGetNextVariableName->Guid, VendorGuid);
- CopyMem (SmmGetNextVariableName->Name, VariableName, *VariableNameSize);
+ //
+ // Copy whole string
+ //
+ CopyMem (SmmGetNextVariableName->Name, VariableName, InVariableNameSize);
+ if (OutVariableNameSize > InVariableNameSize) {
+ ZeroMem ((UINT8 *) SmmGetNextVariableName->Name + InVariableNameSize, OutVariableNameSize - InVariableNameSize);
+ }
//
// Send data to SMM
@@ -336,7 +443,13 @@ RuntimeServiceGetNextVariableName (
//
// Get data from SMM.
//
- *VariableNameSize = SmmGetNextVariableName->NameSize;
+ if (Status == EFI_SUCCESS || Status == EFI_BUFFER_TOO_SMALL) {
+ //
+ // SMM CommBuffer NameSize can be a trimed value
+ // Only update VariableNameSize when needed
+ //
+ *VariableNameSize = SmmGetNextVariableName->NameSize;
+ }
if (EFI_ERROR (Status)) {
goto Done;
}
@@ -382,6 +495,7 @@ RuntimeServiceSetVariable (
EFI_STATUS Status;
UINTN PayloadSize;
SMM_VARIABLE_COMMUNICATE_ACCESS_VARIABLE *SmmVariableHeader;
+ UINTN VariableNameSize;
//
// Check input parameters.
@@ -394,23 +508,23 @@ RuntimeServiceSetVariable (
return EFI_INVALID_PARAMETER;
}
- if (DataSize >= mVariableBufferSize) {
- //
- // DataSize may be near MAX_ADDRESS incorrectly, this can cause the computed PayLoadSize to
- // overflow to a small value and pass the check in InitCommunicateBuffer().
- // To protect against this vulnerability, return EFI_INVALID_PARAMETER if DataSize is >= mVariableBufferSize.
- // And there will be further check to ensure the total size is also not > mVariableBufferSize.
- //
+ VariableNameSize = StrSize (VariableName);
+
+ //
+ // If VariableName or DataSize exceeds SMM payload limit. Return failure
+ //
+ if ((VariableNameSize > mVariableBufferPayloadSize - OFFSET_OF (SMM_VARIABLE_COMMUNICATE_ACCESS_VARIABLE, Name)) ||
+ (DataSize > mVariableBufferPayloadSize - OFFSET_OF (SMM_VARIABLE_COMMUNICATE_ACCESS_VARIABLE, Name) - VariableNameSize)){
return EFI_INVALID_PARAMETER;
}
AcquireLockOnlyAtBootTime(&mVariableServicesLock);
-
+
//
// Init the communicate buffer. The buffer data size is:
// SMM_COMMUNICATE_HEADER_SIZE + SMM_VARIABLE_COMMUNICATE_HEADER_SIZE + PayloadSize.
//
- PayloadSize = OFFSET_OF (SMM_VARIABLE_COMMUNICATE_ACCESS_VARIABLE, Name) + StrSize (VariableName) + DataSize;
+ PayloadSize = OFFSET_OF (SMM_VARIABLE_COMMUNICATE_ACCESS_VARIABLE, Name) + VariableNameSize + DataSize;
Status = InitCommunicateBuffer ((VOID **)&SmmVariableHeader, PayloadSize, SMM_VARIABLE_FUNCTION_SET_VARIABLE);
if (EFI_ERROR (Status)) {
goto Done;
@@ -419,7 +533,7 @@ RuntimeServiceSetVariable (
CopyGuid ((EFI_GUID *) &SmmVariableHeader->Guid, VendorGuid);
SmmVariableHeader->DataSize = DataSize;
- SmmVariableHeader->NameSize = StrSize (VariableName);
+ SmmVariableHeader->NameSize = VariableNameSize;
SmmVariableHeader->Attributes = Attributes;
CopyMem (SmmVariableHeader->Name, VariableName, SmmVariableHeader->NameSize);
CopyMem ((UINT8 *) SmmVariableHeader->Name + SmmVariableHeader->NameSize, Data, DataSize);
@@ -610,10 +724,11 @@ SmmVariableReady (
ASSERT_EFI_ERROR (Status);
//
- // Allocate memory for variable store.
+ // Allocate memory for variable communicate buffer.
//
- mVariableBufferSize = SMM_COMMUNICATE_HEADER_SIZE + SMM_VARIABLE_COMMUNICATE_HEADER_SIZE;
- mVariableBufferSize += MAX (PcdGet32 (PcdMaxVariableSize), PcdGet32 (PcdMaxHardwareErrorVariableSize));
+ mVariableBufferPayloadSize = MAX (PcdGet32 (PcdMaxVariableSize), PcdGet32 (PcdMaxHardwareErrorVariableSize)) +
+ OFFSET_OF (SMM_VARIABLE_COMMUNICATE_ACCESS_VARIABLE, Name) - sizeof (VARIABLE_HEADER);
+ mVariableBufferSize = SMM_COMMUNICATE_HEADER_SIZE + SMM_VARIABLE_COMMUNICATE_HEADER_SIZE + mVariableBufferPayloadSize;
mVariableBuffer = AllocateRuntimePool (mVariableBufferSize);
ASSERT (mVariableBuffer != NULL);
@@ -694,6 +809,7 @@ VariableSmmRuntimeInitialize (
IN EFI_SYSTEM_TABLE *SystemTable
)
{
+ EFI_STATUS Status;
VOID *SmmVariableRegistration;
VOID *SmmVariableWriteRegistration;
EFI_EVENT OnReadyToBootEvent;
@@ -701,6 +817,15 @@ VariableSmmRuntimeInitialize (
EfiInitializeLock (&mVariableServicesLock, TPL_NOTIFY);
+ mVariableLock.RequestToLock = VariableLockRequestToLock;
+ Status = gBS->InstallMultipleProtocolInterfaces (
+ &mHandle,
+ &gEdkiiVariableLockProtocolGuid,
+ &mVariableLock,
+ NULL
+ );
+ ASSERT_EFI_ERROR (Status);
+
//
// Smm variable service is ready
//
diff --git a/SecurityPkg/VariableAuthenticated/RuntimeDxe/VariableSmmRuntimeDxe.inf b/SecurityPkg/VariableAuthenticated/RuntimeDxe/VariableSmmRuntimeDxe.inf
index 3842f0105d..a28702765b 100644
--- a/SecurityPkg/VariableAuthenticated/RuntimeDxe/VariableSmmRuntimeDxe.inf
+++ b/SecurityPkg/VariableAuthenticated/RuntimeDxe/VariableSmmRuntimeDxe.inf
@@ -59,6 +59,7 @@
gEfiVariableArchProtocolGuid ## ALWAYS_PRODUCES
gEfiSmmCommunicationProtocolGuid
gEfiSmmVariableProtocolGuid
+ gEdkiiVariableLockProtocolGuid ## ALWAYS_PRODUCES
[Guids]
gEfiEventVirtualAddressChangeGuid ## PRODUCES ## Event
diff --git a/SecurityPkg/VariableAuthenticated/SecureBootConfigDxe/SecureBootConfig.vfr b/SecurityPkg/VariableAuthenticated/SecureBootConfigDxe/SecureBootConfig.vfr
index ae4b71bffd..656befbb44 100644
--- a/SecurityPkg/VariableAuthenticated/SecureBootConfigDxe/SecureBootConfig.vfr
+++ b/SecurityPkg/VariableAuthenticated/SecureBootConfigDxe/SecureBootConfig.vfr
@@ -43,8 +43,10 @@ formset
//
suppressif TRUE;
checkbox varid = SECUREBOOT_CONFIGURATION.HideSecureBoot,
+ questionid = KEY_HIDE_SECURE_BOOT,
prompt = STRING_TOKEN(STR_NULL),
help = STRING_TOKEN(STR_NULL),
+ flags = INTERACTIVE,
endcheckbox;
endif;
diff --git a/SecurityPkg/VariableAuthenticated/SecureBootConfigDxe/SecureBootConfigFileExplorer.c b/SecurityPkg/VariableAuthenticated/SecureBootConfigDxe/SecureBootConfigFileExplorer.c
index deff87bcbd..548d95df53 100644
--- a/SecurityPkg/VariableAuthenticated/SecureBootConfigDxe/SecureBootConfigFileExplorer.c
+++ b/SecurityPkg/VariableAuthenticated/SecureBootConfigDxe/SecureBootConfigFileExplorer.c
@@ -1,7 +1,7 @@
/** @file
Internal file explorer functions for SecureBoot configuration module.
-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
@@ -323,7 +323,7 @@ DestroyMenuEntry (
FileContext = (SECUREBOOT_FILE_CONTEXT *) MenuEntry->FileContext;
- if (!FileContext->IsRoot) {
+ if (!FileContext->IsRoot && FileContext->DevicePath != NULL) {
FreePool (FileContext->DevicePath);
} else {
if (FileContext->FHandle != NULL) {
@@ -340,7 +340,9 @@ DestroyMenuEntry (
FreePool (FileContext);
- FreePool (MenuEntry->DisplayString);
+ if (MenuEntry->DisplayString != NULL) {
+ FreePool (MenuEntry->DisplayString);
+ }
if (MenuEntry->HelpString != NULL) {
FreePool (MenuEntry->HelpString);
}
diff --git a/SecurityPkg/VariableAuthenticated/SecureBootConfigDxe/SecureBootConfigImpl.c b/SecurityPkg/VariableAuthenticated/SecureBootConfigDxe/SecureBootConfigImpl.c
index 51da86b6fd..e8beecbf58 100644
--- a/SecurityPkg/VariableAuthenticated/SecureBootConfigDxe/SecureBootConfigImpl.c
+++ b/SecurityPkg/VariableAuthenticated/SecureBootConfigDxe/SecureBootConfigImpl.c
@@ -2378,6 +2378,11 @@ SecureBootRouteConfig (
OUT EFI_STRING *Progress
)
{
+ UINT8 *SecureBootEnable;
+ SECUREBOOT_CONFIGURATION IfrNvData;
+ UINTN BufferSize;
+ EFI_STATUS Status;
+
if (Configuration == NULL || Progress == NULL) {
return EFI_INVALID_PARAMETER;
}
@@ -2387,6 +2392,31 @@ SecureBootRouteConfig (
return EFI_NOT_FOUND;
}
+ BufferSize = sizeof (SECUREBOOT_CONFIGURATION);
+ Status = gHiiConfigRouting->ConfigToBlock (
+ gHiiConfigRouting,
+ Configuration,
+ (UINT8 *)&IfrNvData,
+ &BufferSize,
+ Progress
+ );
+ if (EFI_ERROR (Status)) {
+ return Status;
+ }
+
+ //
+ // Store Buffer Storage back to EFI variable if needed
+ //
+ SecureBootEnable = NULL;
+ GetVariable2 (EFI_SECURE_BOOT_ENABLE_NAME, &gEfiSecureBootEnableDisableGuid, (VOID**)&SecureBootEnable, NULL);
+ if (NULL != SecureBootEnable) {
+ FreePool (SecureBootEnable);
+ Status = SaveSecureBootVariable (IfrNvData.AttemptSecureBoot);
+ if (EFI_ERROR (Status)) {
+ return Status;
+ }
+ }
+
*Progress = Configuration + StrLen (Configuration);
return EFI_SUCCESS;
}
@@ -2445,7 +2475,8 @@ SecureBootCallback (
if ((Action != EFI_BROWSER_ACTION_CHANGED) &&
(Action != EFI_BROWSER_ACTION_CHANGING) &&
- (Action != EFI_BROWSER_ACTION_FORM_CLOSE)) {
+ (Action != EFI_BROWSER_ACTION_FORM_CLOSE) &&
+ (Action != EFI_BROWSER_ACTION_DEFAULT_STANDARD)) {
return EFI_UNSUPPORTED;
}
@@ -2601,14 +2632,41 @@ SecureBootCallback (
case KEY_VALUE_SAVE_AND_EXIT_KEK:
Status = EnrollKeyExchangeKey (Private);
+ if (EFI_ERROR (Status)) {
+ CreatePopUp (
+ EFI_LIGHTGRAY | EFI_BACKGROUND_BLUE,
+ &Key,
+ L"ERROR: Unsupported file type!",
+ L"Only supports DER-encoded X509 certificate",
+ NULL
+ );
+ }
break;
case KEY_VALUE_SAVE_AND_EXIT_DB:
Status = EnrollSignatureDatabase (Private, EFI_IMAGE_SECURITY_DATABASE);
+ if (EFI_ERROR (Status)) {
+ CreatePopUp (
+ EFI_LIGHTGRAY | EFI_BACKGROUND_BLUE,
+ &Key,
+ L"ERROR: Unsupported file type!",
+ L"Only supports DER-encoded X509 certificate and executable EFI image",
+ NULL
+ );
+ }
break;
case KEY_VALUE_SAVE_AND_EXIT_DBX:
Status = EnrollSignatureDatabase (Private, EFI_IMAGE_SECURITY_DATABASE1);
+ if (EFI_ERROR (Status)) {
+ CreatePopUp (
+ EFI_LIGHTGRAY | EFI_BACKGROUND_BLUE,
+ &Key,
+ L"ERROR: Unsupported file type!",
+ L"Only supports DER-encoded X509 certificate and executable EFI image",
+ NULL
+ );
+ }
break;
default:
@@ -2649,13 +2707,13 @@ SecureBootCallback (
break;
case KEY_VALUE_SAVE_AND_EXIT_PK:
Status = EnrollPlatformKey (Private);
- UnicodeSPrint (
- PromptString,
- sizeof (PromptString),
- L"Only DER encoded certificate file (%s) is supported.",
- mSupportX509Suffix
- );
if (EFI_ERROR (Status)) {
+ UnicodeSPrint (
+ PromptString,
+ sizeof (PromptString),
+ L"Only DER encoded certificate file (%s) is supported.",
+ mSupportX509Suffix
+ );
CreatePopUp (
EFI_LIGHTGRAY | EFI_BACKGROUND_BLUE,
&Key,
@@ -2733,6 +2791,17 @@ SecureBootCallback (
}
break;
}
+ } else if (Action == EFI_BROWSER_ACTION_DEFAULT_STANDARD) {
+ if (QuestionId == KEY_HIDE_SECURE_BOOT) {
+ GetVariable2 (EFI_SECURE_BOOT_ENABLE_NAME, &gEfiSecureBootEnableDisableGuid, (VOID**)&SecureBootEnable, NULL);
+ if (SecureBootEnable == NULL) {
+ IfrNvData->HideSecureBoot = TRUE;
+ } else {
+ FreePool (SecureBootEnable);
+ IfrNvData->HideSecureBoot = FALSE;
+ }
+ Value->b = IfrNvData->HideSecureBoot;
+ }
} else if (Action == EFI_BROWSER_ACTION_FORM_CLOSE) {
//
// Force the platform back to Standard Mode once user leave the setup screen.
diff --git a/SecurityPkg/VariableAuthenticated/SecureBootConfigDxe/SecureBootConfigNvData.h b/SecurityPkg/VariableAuthenticated/SecureBootConfigDxe/SecureBootConfigNvData.h
index ea43192900..c15869a625 100644
--- a/SecurityPkg/VariableAuthenticated/SecureBootConfigDxe/SecureBootConfigNvData.h
+++ b/SecurityPkg/VariableAuthenticated/SecureBootConfigDxe/SecureBootConfigNvData.h
@@ -55,6 +55,7 @@ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
#define KEY_VALUE_NO_SAVE_AND_EXIT_KEK 0x1009
#define KEY_VALUE_SAVE_AND_EXIT_DBX 0x100a
#define KEY_VALUE_NO_SAVE_AND_EXIT_DBX 0x100b
+#define KEY_HIDE_SECURE_BOOT 0x100c
#define KEY_SECURE_BOOT_OPTION 0x1100
#define KEY_SECURE_BOOT_PK_OPTION 0x1101
diff --git a/ShellPkg/Application/Shell/ShellProtocol.c b/ShellPkg/Application/Shell/ShellProtocol.c
index 68d4fb4d92..c5b836aaf9 100644
--- a/ShellPkg/Application/Shell/ShellProtocol.c
+++ b/ShellPkg/Application/Shell/ShellProtocol.c
@@ -994,7 +994,6 @@ InternalOpenFileDevicePath(
SHELL_FILE_HANDLE ShellHandle;
EFI_FILE_PROTOCOL *Handle1;
EFI_FILE_PROTOCOL *Handle2;
- EFI_DEVICE_PATH_PROTOCOL *DpCopy;
FILEPATH_DEVICE_PATH *AlignedNode;
if (FileHandle == NULL) {
@@ -1004,7 +1003,6 @@ InternalOpenFileDevicePath(
Handle1 = NULL;
Handle2 = NULL;
Handle = NULL;
- DpCopy = DevicePath;
ShellHandle = NULL;
FilePathNode = NULL;
AlignedNode = NULL;
diff --git a/ShellPkg/Library/UefiShellCEntryLib/UefiShellCEntryLib.c b/ShellPkg/Library/UefiShellCEntryLib/UefiShellCEntryLib.c
index 60b15fe8a0..525c1f14cf 100644
--- a/ShellPkg/Library/UefiShellCEntryLib/UefiShellCEntryLib.c
+++ b/ShellPkg/Library/UefiShellCEntryLib/UefiShellCEntryLib.c
@@ -1,7 +1,7 @@
/** @file
Provides application point extension for "C" style main funciton
- Copyright (c) 2009 - 2010, 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
@@ -30,6 +30,10 @@
An application that uses UefiShellCEntryLib must have a ShellAppMain
function as prototyped in Include/Library/ShellCEntryLib.h.
+ Note that the Shell uses POSITIVE integers for error values, while UEFI
+ uses NEGATIVE values. If the application is to be used within a script,
+ it needs to return one of the SHELL_STATUS values defined in ShellBase.h.
+
@param ImageHandle The image handle of the UEFI Application.
@param SystemTable A pointer to the EFI System Table.
@@ -91,9 +95,5 @@ ShellCEntryLib (
ASSERT(FALSE);
}
}
- if (ReturnFromMain == 0) {
- return (EFI_SUCCESS);
- } else {
- return (EFI_UNSUPPORTED);
- }
+ return ReturnFromMain;
}
diff --git a/ShellPkg/Library/UefiShellCommandLib/UefiShellCommandLib.c b/ShellPkg/Library/UefiShellCommandLib/UefiShellCommandLib.c
index 66a242f66f..88c78ee15e 100644
--- a/ShellPkg/Library/UefiShellCommandLib/UefiShellCommandLib.c
+++ b/ShellPkg/Library/UefiShellCommandLib/UefiShellCommandLib.c
@@ -1,7 +1,7 @@
/** @file
Provides interface to shell internal functions for shell commands.
- 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
@@ -14,12 +14,6 @@
#include "UefiShellCommandLib.h"
-/// The tag for use in identifying UNICODE files.
-/// If the file is UNICODE, the first 16 bits of the file will equal this value.
-enum {
- gUnicodeFileTag = 0xFEFF
-};
-
// STATIC local variables
STATIC SHELL_COMMAND_INTERNAL_LIST_ENTRY mCommandList;
STATIC SCRIPT_FILE_LIST mScriptList;
diff --git a/ShellPkg/Library/UefiShellDebug1CommandsLib/Bcfg.c b/ShellPkg/Library/UefiShellDebug1CommandsLib/Bcfg.c
index 095a9460e6..c26fad7b38 100644
--- a/ShellPkg/Library/UefiShellDebug1CommandsLib/Bcfg.c
+++ b/ShellPkg/Library/UefiShellDebug1CommandsLib/Bcfg.c
@@ -293,7 +293,7 @@ BcfgAddDebug1(
EFI_STATUS Status;
EFI_DEVICE_PATH_PROTOCOL *DevicePath;
EFI_DEVICE_PATH_PROTOCOL *FilePath;
- EFI_DEVICE_PATH_PROTOCOL *FileNode;
+ /* EFI_DEVICE_PATH_PROTOCOL *FileNode; */
CHAR16 *Str;
UINT8 *TempByteBuffer;
UINT8 *TempByteStart;
@@ -328,7 +328,7 @@ BcfgAddDebug1(
Str = NULL;
FilePath = NULL;
- FileNode = NULL;
+ /* FileNode = NULL; */
FileList = NULL;
Handles = NULL;
ShellStatus = SHELL_SUCCESS;
diff --git a/ShellPkg/Library/UefiShellDebug1CommandsLib/DmpStore.c b/ShellPkg/Library/UefiShellDebug1CommandsLib/DmpStore.c
index 8aafcced24..3445b7f7e2 100644
--- a/ShellPkg/Library/UefiShellDebug1CommandsLib/DmpStore.c
+++ b/ShellPkg/Library/UefiShellDebug1CommandsLib/DmpStore.c
@@ -1,7 +1,7 @@
/** @file
Main file for DmpStore shell Debug1 function.
- 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
@@ -248,7 +248,7 @@ ProcessVariables (
}
return (SHELL_NOT_FOUND);
}
- return (SHELL_SUCCESS);
+ return (ShellStatus);
}
STATIC CONST SHELL_PARAM_ITEM ParamList[] = {
diff --git a/ShellPkg/Library/UefiShellDebug1CommandsLib/EditInputBar.c b/ShellPkg/Library/UefiShellDebug1CommandsLib/EditInputBar.c
index 978ce7f13a..649ed57955 100644
--- a/ShellPkg/Library/UefiShellDebug1CommandsLib/EditInputBar.c
+++ b/ShellPkg/Library/UefiShellDebug1CommandsLib/EditInputBar.c
@@ -133,8 +133,6 @@ InputBarRefresh (
UINTN Size;
EFI_STATUS Status;
BOOLEAN NoDisplay;
- UINTN Limit;
- UINTN mPromptLen;
UINTN EventIndex;
UINTN CursorRow;
UINTN CursorCol;
@@ -165,12 +163,6 @@ InputBarRefresh (
ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN(STR_EDIT_LIBINPUTBAR_MAININPUTBAR), gShellDebug1HiiHandle, mPrompt);
//
- // that's the maximum input length that can be displayed on screen
- //
- mPromptLen = StrLen (mPrompt);
- Limit = LastColumn - mPromptLen;
-
- //
// this is a selection mPrompt, cursor will stay in edit area
// actually this is for search , search/replace
//
diff --git a/ShellPkg/Library/UefiShellDebug1CommandsLib/HexEdit/BufferImage.c b/ShellPkg/Library/UefiShellDebug1CommandsLib/HexEdit/BufferImage.c
index 46926320a6..bfedf58d78 100644
--- a/ShellPkg/Library/UefiShellDebug1CommandsLib/HexEdit/BufferImage.c
+++ b/ShellPkg/Library/UefiShellDebug1CommandsLib/HexEdit/BufferImage.c
@@ -752,7 +752,6 @@ HBufferImageRefresh (
UINTN StartRow;
UINTN EndRow;
UINTN FStartRow;
- UINTN FEndRow;
UINTN Tmp;
Orig = HMainEditor.ColorAttributes;
@@ -821,7 +820,6 @@ HBufferImageRefresh (
}
FStartRow = StartRow;
- FEndRow = EndRow;
StartRow = 2 + StartRow - HBufferImage.LowVisibleRow;
EndRow = 2 + EndRow - HBufferImage.LowVisibleRow;
@@ -1750,14 +1748,11 @@ HBufferImagePageUp (
VOID
)
{
- HEFI_EDITOR_LINE *Line;
UINTN FRow;
UINTN FCol;
UINTN Gap;
INTN Retreat;
- Line = HBufferImage.CurrentLine;
-
FRow = HBufferImage.BufferPosition.Row;
FCol = HBufferImage.BufferPosition.Column;
@@ -1776,11 +1771,6 @@ HBufferImagePageUp (
Retreat = Gap;
Retreat = -Retreat;
- //
- // get correct line
- //
- Line = HMoveLine (Retreat);
-
FRow -= Gap;
HBufferImageMovePosition (FRow, FCol, HBufferImage.HighBits);
@@ -1798,13 +1788,10 @@ HBufferImageHome (
VOID
)
{
- HEFI_EDITOR_LINE *Line;
UINTN FRow;
UINTN FCol;
BOOLEAN HighBits;
- Line = HBufferImage.CurrentLine;
-
//
// curosr will at the high bit
//
@@ -1918,7 +1905,6 @@ HBufferImageDeleteCharacterFromBuffer (
HEFI_EDITOR_LINE *Line;
LIST_ENTRY *Link;
- UINTN StartRow;
UINTN OldFCol;
UINTN OldFRow;
@@ -1928,11 +1914,6 @@ HBufferImageDeleteCharacterFromBuffer (
EFI_STATUS Status;
- //
- // get the line that start position is at
- //
- StartRow = Pos / 0x10;
-
Size = HBufferImageGetTotalSize ();
if (Size < Count) {
@@ -2054,7 +2035,6 @@ HBufferImageAddCharacterToBuffer (
HEFI_EDITOR_LINE *Line;
LIST_ENTRY *Link;
- UINTN StartRow;
UINTN OldFCol;
UINTN OldFRow;
@@ -2062,11 +2042,6 @@ HBufferImageAddCharacterToBuffer (
UINTN NewPos;
- //
- // get the line that start position is at
- //
- StartRow = Pos / 0x10;
-
Size = HBufferImageGetTotalSize ();
//
diff --git a/ShellPkg/Library/UefiShellDebug1CommandsLib/HexEdit/DiskImage.c b/ShellPkg/Library/UefiShellDebug1CommandsLib/HexEdit/DiskImage.c
index c956f77b28..a50b52f5f2 100644
--- a/ShellPkg/Library/UefiShellDebug1CommandsLib/HexEdit/DiskImage.c
+++ b/ShellPkg/Library/UefiShellDebug1CommandsLib/HexEdit/DiskImage.c
@@ -181,11 +181,7 @@ HDiskImageRead (
UINTN Bytes;
HEFI_EDITOR_LINE *Line;
- UINT64 ByteOffset;
- EDIT_FILE_TYPE BufferTypeBackup;
-
- BufferTypeBackup = HBufferImage.BufferType;
HBufferImage.BufferType = FileTypeDiskBuffer;
DevicePath = gEfiShellProtocol->GetDevicePathFromMap(DeviceName);
@@ -226,8 +222,6 @@ HDiskImageRead (
return EFI_OUT_OF_RESOURCES;
}
- ByteOffset = MultU64x32 (Offset, BlkIo->Media->BlockSize);
-
//
// read from disk
//
@@ -355,10 +349,6 @@ HDiskImageSave (
VOID *Buffer;
UINTN Bytes;
- UINT64 ByteOffset;
-
- EDIT_FILE_TYPE BufferTypeBackup;
-
//
// if not modified, directly return
//
@@ -366,7 +356,6 @@ HDiskImageSave (
return EFI_SUCCESS;
}
- BufferTypeBackup = HBufferImage.BufferType;
HBufferImage.BufferType = FileTypeDiskBuffer;
DevicePath = gEfiShellProtocol->GetDevicePathFromMap(DeviceName);
@@ -406,8 +395,6 @@ HDiskImageSave (
return Status;
}
- ByteOffset = MultU64x32 (Offset, BlkIo->Media->BlockSize);
-
//
// write the buffer to disk
//
diff --git a/ShellPkg/Library/UefiShellDebug1CommandsLib/HexEdit/HexEdit.c b/ShellPkg/Library/UefiShellDebug1CommandsLib/HexEdit/HexEdit.c
index 68074d4244..8cbfd2c8f6 100644
--- a/ShellPkg/Library/UefiShellDebug1CommandsLib/HexEdit/HexEdit.c
+++ b/ShellPkg/Library/UefiShellDebug1CommandsLib/HexEdit/HexEdit.c
@@ -43,25 +43,19 @@ ShellCommandRunHexEdit (
CHAR16 *ProblemParam;
SHELL_STATUS ShellStatus;
LIST_ENTRY *Package;
- CONST CHAR16 *Cwd;
CHAR16 *NewName;
- CHAR16 *Spot;
CONST CHAR16 *Name;
UINTN Offset;
UINTN Size;
- UINT64 LastOffset;
EDIT_FILE_TYPE WhatToDo;
Buffer = NULL;
ShellStatus = SHELL_SUCCESS;
NewName = NULL;
- Cwd = NULL;
Buffer = NULL;
Name = NULL;
- Spot = NULL;
Offset = 0;
Size = 0;
- LastOffset = 0;
WhatToDo = FileTypeNone;
//
diff --git a/ShellPkg/Library/UefiShellDebug1CommandsLib/HexEdit/MainHexEditor.c b/ShellPkg/Library/UefiShellDebug1CommandsLib/HexEdit/MainHexEditor.c
index 09213d897d..a40388ff40 100644
--- a/ShellPkg/Library/UefiShellDebug1CommandsLib/HexEdit/MainHexEditor.c
+++ b/ShellPkg/Library/UefiShellDebug1CommandsLib/HexEdit/MainHexEditor.c
@@ -598,7 +598,6 @@ HMainCommandCut (
)
{
UINTN Index;
- HEFI_EDITOR_LINE *Line;
LIST_ENTRY *Link;
UINT8 *Buffer;
UINTN Count;
@@ -623,8 +622,6 @@ HMainCommandCut (
Link = Link->ForwardLink;
}
- Line = CR (Link, HEFI_EDITOR_LINE, Link, EFI_EDITOR_LINE_LIST);
-
Count = HMainEditor.SelectEnd - HMainEditor.SelectStart + 1;
Buffer = AllocateZeroPool (Count);
if (Buffer == NULL) {
diff --git a/ShellPkg/Library/UefiShellDebug1CommandsLib/HexEdit/MemImage.c b/ShellPkg/Library/UefiShellDebug1CommandsLib/HexEdit/MemImage.c
index 9d44abddd7..300c67f0d4 100644
--- a/ShellPkg/Library/UefiShellDebug1CommandsLib/HexEdit/MemImage.c
+++ b/ShellPkg/Library/UefiShellDebug1CommandsLib/HexEdit/MemImage.c
@@ -190,9 +190,6 @@ HMemImageRead (
CHAR16 *Str;
HEFI_EDITOR_LINE *Line;
- EDIT_FILE_TYPE BufferTypeBackup;
-
- BufferTypeBackup = HBufferImage.BufferType;
HBufferImage.BufferType = FileTypeMemBuffer;
Buffer = AllocateZeroPool (Size);
@@ -301,8 +298,6 @@ HMemImageSave (
EFI_STATUS Status;
VOID *Buffer;
- EDIT_FILE_TYPE BufferTypeBackup;
-
//
// not modified, so directly return
//
@@ -310,7 +305,6 @@ HMemImageSave (
return EFI_SUCCESS;
}
- BufferTypeBackup = HBufferImage.BufferType;
HBufferImage.BufferType = FileTypeMemBuffer;
Buffer = AllocateZeroPool (Size);
diff --git a/ShellPkg/Library/UefiShellDebug1CommandsLib/MemMap.c b/ShellPkg/Library/UefiShellDebug1CommandsLib/MemMap.c
index 59900d3256..cfcfd2b0db 100644
--- a/ShellPkg/Library/UefiShellDebug1CommandsLib/MemMap.c
+++ b/ShellPkg/Library/UefiShellDebug1CommandsLib/MemMap.c
@@ -1,8 +1,8 @@
/** @file
Main file for Mode shell Debug1 function.
- Copyright (c) 2010 - 2011, Intel Corporation. All rights reserved.<BR>
- This program and the acModeanying materials
+ 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 acModeanies this distribution. The full text of the license may be found at
http://opensource.org/licenses/bsd-license.php
diff --git a/ShellPkg/Library/UefiShellDebug1CommandsLib/Mm.c b/ShellPkg/Library/UefiShellDebug1CommandsLib/Mm.c
index c251ea3574..5bb3cff2d1 100644
--- a/ShellPkg/Library/UefiShellDebug1CommandsLib/Mm.c
+++ b/ShellPkg/Library/UefiShellDebug1CommandsLib/Mm.c
@@ -217,7 +217,6 @@ ShellCommandRunMm (
UINT64 Buffer;
UINTN Index;
UINTN Size;
- CHAR16 *AddressStr;
// CHAR16 *ValueStr;
BOOLEAN Complete;
CHAR16 *InputStr;
@@ -245,7 +244,6 @@ ShellCommandRunMm (
Width = EfiPciWidthUint8;
Size = 1;
AccessType = EfiMemory;
- AddressStr = NULL;
// ValueStr = NULL;
Interactive = TRUE;
Package = NULL;
diff --git a/ShellPkg/Library/UefiShellDebug1CommandsLib/Mode.c b/ShellPkg/Library/UefiShellDebug1CommandsLib/Mode.c
index d2b67d5760..ca7648720f 100644
--- a/ShellPkg/Library/UefiShellDebug1CommandsLib/Mode.c
+++ b/ShellPkg/Library/UefiShellDebug1CommandsLib/Mode.c
@@ -1,8 +1,8 @@
/** @file
Main file for Mode shell Debug1 function.
- Copyright (c) 2010 - 2011, Intel Corporation. All rights reserved.<BR>
- This program and the acModeanying materials
+ 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 acModeanies this distribution. The full text of the license may be found at
http://opensource.org/licenses/bsd-license.php
diff --git a/ShellPkg/Library/UefiShellDebug1CommandsLib/Pci.c b/ShellPkg/Library/UefiShellDebug1CommandsLib/Pci.c
index ce55d6e332..4ca1fd1bdd 100644
--- a/ShellPkg/Library/UefiShellDebug1CommandsLib/Pci.c
+++ b/ShellPkg/Library/UefiShellDebug1CommandsLib/Pci.c
@@ -2054,13 +2054,11 @@ ShellCommandRunPci (
LIST_ENTRY *Package;
CHAR16 *ProblemParam;
SHELL_STATUS ShellStatus;
- UINTN Size;
CONST CHAR16 *Temp;
ShellStatus = SHELL_SUCCESS;
Status = EFI_SUCCESS;
Address = 0;
- Size = 0;
IoDev = NULL;
HandleBuf = NULL;
Package = NULL;
diff --git a/ShellPkg/Library/UefiShellDebug1CommandsLib/UefiShellDebug1CommandsLib.c b/ShellPkg/Library/UefiShellDebug1CommandsLib/UefiShellDebug1CommandsLib.c
index 1d72ea6c3a..c601abebcb 100644
--- a/ShellPkg/Library/UefiShellDebug1CommandsLib/UefiShellDebug1CommandsLib.c
+++ b/ShellPkg/Library/UefiShellDebug1CommandsLib/UefiShellDebug1CommandsLib.c
@@ -490,11 +490,9 @@ EditGetDefaultFileName (
{
EFI_STATUS Status;
UINTN Suffix;
- BOOLEAN FoundNewFile;
CHAR16 *FileNameTmp;
Suffix = 0;
- FoundNewFile = FALSE;
do {
FileNameTmp = CatSPrint (NULL, L"NewFile%d.%s", Suffix, Extension);
diff --git a/ShellPkg/Library/UefiShellDriver1CommandsLib/Dh.c b/ShellPkg/Library/UefiShellDriver1CommandsLib/Dh.c
index a0dc139411..9947c56117 100644
--- a/ShellPkg/Library/UefiShellDriver1CommandsLib/Dh.c
+++ b/ShellPkg/Library/UefiShellDriver1CommandsLib/Dh.c
@@ -674,9 +674,7 @@ DoDhByHandle(
{
CHAR16 *ProtocolInfoString;
SHELL_STATUS ShellStatus;
- EFI_STATUS Status;
- Status = EFI_SUCCESS;
ShellStatus = SHELL_SUCCESS;
ProtocolInfoString = NULL;
diff --git a/ShellPkg/Library/UefiShellInstall1CommandsLib/Bcfg.c b/ShellPkg/Library/UefiShellInstall1CommandsLib/Bcfg.c
index a7a10bf3bb..5dcbfb6950 100644
--- a/ShellPkg/Library/UefiShellInstall1CommandsLib/Bcfg.c
+++ b/ShellPkg/Library/UefiShellInstall1CommandsLib/Bcfg.c
@@ -1,7 +1,7 @@
/** @file
Main file for bcfg shell Install1 function.
- 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
@@ -293,7 +293,6 @@ BcfgAddInstall1(
EFI_STATUS Status;
EFI_DEVICE_PATH_PROTOCOL *DevicePath;
EFI_DEVICE_PATH_PROTOCOL *FilePath;
- EFI_DEVICE_PATH_PROTOCOL *FileNode;
CHAR16 *Str;
UINT8 *TempByteBuffer;
UINT8 *TempByteStart;
@@ -328,7 +327,6 @@ BcfgAddInstall1(
Str = NULL;
FilePath = NULL;
- FileNode = NULL;
FileList = NULL;
Handles = NULL;
ShellStatus = SHELL_SUCCESS;
diff --git a/ShellPkg/Library/UefiShellLevel1CommandsLib/If.c b/ShellPkg/Library/UefiShellLevel1CommandsLib/If.c
index 08927319d3..54ed23b59b 100644
--- a/ShellPkg/Library/UefiShellLevel1CommandsLib/If.c
+++ b/ShellPkg/Library/UefiShellLevel1CommandsLib/If.c
@@ -662,12 +662,9 @@ BuildNextStatement (
OUT END_TAG_TYPE *EndTag
)
{
- CHAR16 *Buffer;
- UINTN BufferSize;
-
*EndTag = EndTagMax;
- for(Buffer = NULL, BufferSize = 0
+ for(
; ParameterNumber < gEfiShellParametersProtocol->Argc
; ParameterNumber++
) {
diff --git a/ShellPkg/Library/UefiShellLevel2CommandsLib/Cp.c b/ShellPkg/Library/UefiShellLevel2CommandsLib/Cp.c
index eb2b2cc5f3..80d2dd02bc 100644
--- a/ShellPkg/Library/UefiShellLevel2CommandsLib/Cp.c
+++ b/ShellPkg/Library/UefiShellLevel2CommandsLib/Cp.c
@@ -87,6 +87,7 @@ CopySingleFile(
Response = *Resp;
List = NULL;
DestVolumeInfo = NULL;
+ ShellStatus = SHELL_SUCCESS;
ReadSize = PcdGet16(PcdShellFileOperationSize);
// Why bother copying a file to itself
@@ -219,7 +220,7 @@ CopySingleFile(
//
//check if enough space available on destination drive to complete copy
//
- if (DestVolumeInfo->FreeSpace < SourceFileSize) {
+ if (DestVolumeInfo!= NULL && (DestVolumeInfo->FreeSpace < SourceFileSize)) {
//
//not enough space on destination directory to copy file
//
@@ -255,7 +256,7 @@ CopySingleFile(
//
// return
//
- return (SHELL_SUCCESS);
+ return ShellStatus;
}
/**
@@ -314,11 +315,6 @@ ValidateAndCopyFiles(
ASSERT(DestDir != NULL);
//
- // We already verified that this was present.
- //
- ASSERT(Cwd != NULL);
-
- //
// If we are trying to copy multiple files... make sure we got a directory for the target...
//
if (EFI_ERROR(ShellIsDirectory(DestDir)) && FileList->Link.ForwardLink != FileList->Link.BackLink) {
@@ -341,7 +337,7 @@ ValidateAndCopyFiles(
NewSize = StrSize(DestDir);
NewSize += StrSize(Node->FullName);
- NewSize += StrSize(Cwd);
+ NewSize += (Cwd == NULL)? 0 : StrSize(Cwd);
if (NewSize > PathLen) {
PathLen = NewSize;
}
@@ -404,7 +400,12 @@ ValidateAndCopyFiles(
//
// simple copy of a single file
//
- StrCpy(DestPath, Cwd);
+ if (Cwd != NULL) {
+ StrCpy(DestPath, Cwd);
+ } else {
+ ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_GEN_DIR_NF), gShellLevel2HiiHandle, DestDir);
+ return (SHELL_INVALID_PARAMETER);
+ }
if (DestPath[StrLen(DestPath)-1] != L'\\' && DestDir[0] != L'\\') {
StrCat(DestPath, L"\\");
} else if (DestPath[StrLen(DestPath)-1] == L'\\' && DestDir[0] == L'\\') {
@@ -423,15 +424,25 @@ ValidateAndCopyFiles(
// Check for leading slash
//
if (DestDir[0] == L'\\') {
- //
- // Copy to the root of CWD
- //
- StrCpy(DestPath, Cwd);
+ //
+ // Copy to the root of CWD
+ //
+ if (Cwd != NULL) {
+ StrCpy(DestPath, Cwd);
+ } else {
+ ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_GEN_DIR_NF), gShellLevel2HiiHandle, DestDir);
+ return (SHELL_INVALID_PARAMETER);
+ }
while (PathRemoveLastItem(DestPath));
StrCat(DestPath, DestDir+1);
StrCat(DestPath, Node->FileName);
} else if (StrStr(DestDir, L":") == NULL) {
- StrCpy(DestPath, Cwd);
+ if (Cwd != NULL) {
+ StrCpy(DestPath, Cwd);
+ } else {
+ ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_GEN_DIR_NF), gShellLevel2HiiHandle, DestDir);
+ return (SHELL_INVALID_PARAMETER);
+ }
if (DestPath[StrLen(DestPath)-1] != L'\\' && DestDir[0] != L'\\') {
StrCat(DestPath, L"\\");
} else if (DestPath[StrLen(DestPath)-1] == L'\\' && DestDir[0] == L'\\') {
@@ -537,12 +548,11 @@ ProcessValidateAndCopyFiles(
{
SHELL_STATUS ShellStatus;
EFI_SHELL_FILE_INFO *List;
- EFI_STATUS Status;
EFI_FILE_INFO *FileInfo;
List = NULL;
- Status = ShellOpenFileMetaArg((CHAR16*)DestDir, EFI_FILE_MODE_READ, &List);
+ ShellOpenFileMetaArg((CHAR16*)DestDir, EFI_FILE_MODE_READ, &List);
if (List != NULL && List->Link.ForwardLink != List->Link.BackLink) {
ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_GEN_MARG_ERROR), gShellLevel2HiiHandle, DestDir);
ShellStatus = SHELL_INVALID_PARAMETER;
@@ -562,7 +572,7 @@ ProcessValidateAndCopyFiles(
SHELL_FREE_NON_NULL(FileInfo);
ShellCloseFileMetaArg(&List);
} else {
- ShellStatus = ValidateAndCopyFiles(FileList, DestDir, SilentMode, RecursiveMode, NULL);
+ ShellStatus = ValidateAndCopyFiles(FileList, DestDir, SilentMode, RecursiveMode, NULL);
}
return (ShellStatus);
diff --git a/ShellPkg/Library/UefiShellLevel2CommandsLib/Load.c b/ShellPkg/Library/UefiShellLevel2CommandsLib/Load.c
index 5edb9d7735..98ef4b88f3 100644
--- a/ShellPkg/Library/UefiShellLevel2CommandsLib/Load.c
+++ b/ShellPkg/Library/UefiShellLevel2CommandsLib/Load.c
@@ -81,13 +81,11 @@ LoadDriver(
{
EFI_HANDLE LoadedDriverHandle;
EFI_STATUS Status;
- EFI_DEVICE_PATH_PROTOCOL *Node;
EFI_DEVICE_PATH_PROTOCOL *FilePath;
EFI_LOADED_IMAGE_PROTOCOL *LoadedDriverImage;
LoadedDriverImage = NULL;
FilePath = NULL;
- Node = NULL;
LoadedDriverHandle = NULL;
Status = EFI_SUCCESS;
diff --git a/ShellPkg/Library/UefiShellLevel2CommandsLib/Map.c b/ShellPkg/Library/UefiShellLevel2CommandsLib/Map.c
index a1f9448df9..2725f4ad39 100644
--- a/ShellPkg/Library/UefiShellLevel2CommandsLib/Map.c
+++ b/ShellPkg/Library/UefiShellLevel2CommandsLib/Map.c
@@ -1,7 +1,7 @@
/** @file
Main file for map shell level 2 command.
- 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
@@ -1025,7 +1025,6 @@ ShellCommandRunMap (
CONST CHAR16 *SName;
CONST CHAR16 *Mapping;
EFI_HANDLE MapAsHandle;
- CONST EFI_DEVICE_PATH_PROTOCOL *DevPath;
SHELL_STATUS ShellStatus;
BOOLEAN SfoMode;
BOOLEAN ConstMode;
@@ -1037,7 +1036,6 @@ ShellCommandRunMap (
ProblemParam = NULL;
Mapping = NULL;
SName = NULL;
- DevPath = NULL;
ShellStatus = SHELL_SUCCESS;
MapAsHandle = NULL;
@@ -1093,18 +1091,15 @@ ShellCommandRunMap (
if (SName != NULL) {
Status = PerformMappingDelete(SName);
if (EFI_ERROR(Status)) {
- switch (Status) {
- case EFI_ACCESS_DENIED:
- ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_GEN_ERR_AD), gShellLevel2HiiHandle);
- ShellStatus = SHELL_ACCESS_DENIED;
- break;
- case EFI_NOT_FOUND:
- ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_MAP_NF), gShellLevel2HiiHandle, SName);
- ShellStatus = SHELL_INVALID_PARAMETER;
- break;
- default:
- ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_GEN_ERR_UK), gShellLevel2HiiHandle, Status);
- ShellStatus = SHELL_UNSUPPORTED;
+ if (Status == EFI_ACCESS_DENIED) {
+ ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_GEN_ERR_AD), gShellLevel2HiiHandle);
+ ShellStatus = SHELL_ACCESS_DENIED;
+ } else if (Status == EFI_NOT_FOUND) {
+ ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_MAP_NF), gShellLevel2HiiHandle, SName);
+ ShellStatus = SHELL_INVALID_PARAMETER;
+ } else {
+ ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_GEN_ERR_UK), gShellLevel2HiiHandle, Status);
+ ShellStatus = SHELL_UNSUPPORTED;
}
}
} else {
diff --git a/ShellPkg/Library/UefiShellLevel2CommandsLib/Mv.c b/ShellPkg/Library/UefiShellLevel2CommandsLib/Mv.c
index 541e782925..9ce915b96c 100644
--- a/ShellPkg/Library/UefiShellLevel2CommandsLib/Mv.c
+++ b/ShellPkg/Library/UefiShellLevel2CommandsLib/Mv.c
@@ -1,7 +1,7 @@
/** @file
Main file for mv shell level 2 function.
- 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
@@ -135,7 +135,6 @@ GetDestinationLocation(
{
EFI_SHELL_FILE_INFO *DestList;
EFI_SHELL_FILE_INFO *Node;
- EFI_STATUS Status;
CHAR16 *DestPath;
CHAR16 *TempLocation;
UINTN NewSize;
@@ -159,7 +158,7 @@ GetDestinationLocation(
//
// get the destination path
//
- Status = ShellOpenFileMetaArg((CHAR16*)DestDir, EFI_FILE_MODE_WRITE|EFI_FILE_MODE_READ|EFI_FILE_MODE_CREATE, &DestList);
+ ShellOpenFileMetaArg((CHAR16*)DestDir, EFI_FILE_MODE_WRITE|EFI_FILE_MODE_READ|EFI_FILE_MODE_CREATE, &DestList);
if (DestList == NULL || IsListEmpty(&DestList->Link)) {
//
// Not existing... must be renaming
@@ -405,23 +404,18 @@ ValidateAndMoveFiles(
//
if (EFI_ERROR(Status)) {
ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_GEN_ERR_UK), gShellLevel2HiiHandle, Status);
- //
- // move failed
- //
- switch(Status){
- default:
- ShellStatus = SHELL_INVALID_PARAMETER;
- case EFI_SECURITY_VIOLATION:
- ShellStatus = SHELL_SECURITY_VIOLATION;
- case EFI_WRITE_PROTECTED:
- ShellStatus = SHELL_WRITE_PROTECTED;
- case EFI_OUT_OF_RESOURCES:
- ShellStatus = SHELL_OUT_OF_RESOURCES;
- case EFI_DEVICE_ERROR:
- ShellStatus = SHELL_DEVICE_ERROR;
- case EFI_ACCESS_DENIED:
- ShellStatus = SHELL_ACCESS_DENIED;
- } // switch
+ ShellStatus = SHELL_INVALID_PARAMETER;
+ if (Status == EFI_SECURITY_VIOLATION) {
+ ShellStatus = SHELL_SECURITY_VIOLATION;
+ } else if (Status == EFI_WRITE_PROTECTED) {
+ ShellStatus = SHELL_WRITE_PROTECTED;
+ } else if (Status == EFI_OUT_OF_RESOURCES) {
+ ShellStatus = SHELL_OUT_OF_RESOURCES;
+ } else if (Status == EFI_DEVICE_ERROR) {
+ ShellStatus = SHELL_DEVICE_ERROR;
+ } else if (Status == EFI_ACCESS_DENIED) {
+ ShellStatus = SHELL_ACCESS_DENIED;
+ }
} else {
ShellPrintEx(-1, -1, L"%s", HiiResultOk);
}
diff --git a/ShellPkg/Library/UefiShellLevel2CommandsLib/Rm.c b/ShellPkg/Library/UefiShellLevel2CommandsLib/Rm.c
index d167b36fb4..2eb54d3e39 100644
--- a/ShellPkg/Library/UefiShellLevel2CommandsLib/Rm.c
+++ b/ShellPkg/Library/UefiShellLevel2CommandsLib/Rm.c
@@ -33,7 +33,6 @@ IsDirectoryEmpty (
IN EFI_HANDLE FileHandle
)
{
- EFI_STATUS Status;
EFI_FILE_INFO *FileInfo;
BOOLEAN NoFile;
BOOLEAN RetVal;
@@ -41,9 +40,9 @@ IsDirectoryEmpty (
RetVal = TRUE;
NoFile = FALSE;
- for (Status = FileHandleFindFirstFile(FileHandle, &FileInfo)
+ for (FileHandleFindFirstFile(FileHandle, &FileInfo)
; !NoFile
- ; Status = FileHandleFindNextFile(FileHandle, FileInfo, &NoFile)
+ ; FileHandleFindNextFile(FileHandle, FileInfo, &NoFile)
){
if (StrStr(FileInfo->FileName, L".") != FileInfo->FileName
&&StrStr(FileInfo->FileName, L"..") != FileInfo->FileName) {
diff --git a/ShellPkg/Library/UefiShellLevel2CommandsLib/TimeDate.c b/ShellPkg/Library/UefiShellLevel2CommandsLib/TimeDate.c
index dfe03fdd20..6fbb3e59a9 100644
--- a/ShellPkg/Library/UefiShellLevel2CommandsLib/TimeDate.c
+++ b/ShellPkg/Library/UefiShellLevel2CommandsLib/TimeDate.c
@@ -221,7 +221,10 @@ ShellCommandRunDate (
// get the current date
//
Status = gRT->GetTime(&TheTime, NULL);
- ASSERT_EFI_ERROR(Status);
+ if (EFI_ERROR(Status)) {
+ ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_GEN_UEFI_FUNC_WARN), gShellLevel2HiiHandle, L"gRT->GetTime", Status);
+ return (SHELL_DEVICE_ERROR);
+ }
//
// ShellPrintEx the date in SFO or regular format
@@ -312,7 +315,10 @@ CheckAndSetTime (
}
Status = gRT->GetTime(&TheTime, NULL);
- ASSERT_EFI_ERROR(Status);
+ if (EFI_ERROR(Status)) {
+ ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_GEN_UEFI_FUNC_WARN), gShellLevel2HiiHandle, L"gRT->GetTime", Status);
+ return (SHELL_DEVICE_ERROR);
+ }
if (TimeString != NULL) {
TimeStringCopy = NULL;
@@ -378,7 +384,6 @@ ShellCommandRunTime (
{
EFI_STATUS Status;
LIST_ENTRY *Package;
- CHAR16 *Message;
EFI_TIME TheTime;
CHAR16 *ProblemParam;
SHELL_STATUS ShellStatus;
@@ -387,13 +392,11 @@ ShellCommandRunTime (
CONST CHAR16 *TempLocation;
UINTN TzMinutes;
- ShellStatus = SHELL_SUCCESS;
- ProblemParam = NULL;
-
//
// Initialize variables
//
- Message = NULL;
+ ShellStatus = SHELL_SUCCESS;
+ ProblemParam = NULL;
//
// initialize the shell lib (we must be in non-auto-init...)
@@ -423,7 +426,11 @@ ShellCommandRunTime (
// check for "-?"
//
Status = gRT->GetTime(&TheTime, NULL);
- ASSERT_EFI_ERROR(Status);
+ if (EFI_ERROR(Status)) {
+ ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_GEN_UEFI_FUNC_WARN), gShellLevel2HiiHandle, L"gRT->GetTime", Status);
+ return (SHELL_DEVICE_ERROR);
+ }
+
if (ShellCommandLineGetFlag(Package, L"-?")) {
ASSERT(FALSE);
} else if (ShellCommandLineGetRawValue(Package, 2) != NULL) {
@@ -643,6 +650,7 @@ CheckAndSetTimeZone (
Status = gRT->GetTime(&TheTime, NULL);
if (EFI_ERROR(Status)) {
+ ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_GEN_UEFI_FUNC_WARN), gShellLevel2HiiHandle, L"gRT->GetTime", Status);
return (SHELL_DEVICE_ERROR);
}
@@ -788,7 +796,10 @@ ShellCommandRunTimeZone (
// Get Current Time Zone Info
//
Status = gRT->GetTime(&TheTime, NULL);
- ASSERT_EFI_ERROR(Status);
+ if (EFI_ERROR(Status)) {
+ ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_GEN_UEFI_FUNC_WARN), gShellLevel2HiiHandle, L"gRT->GetTime", Status);
+ return (SHELL_DEVICE_ERROR);
+ }
if (TheTime.TimeZone != EFI_UNSPECIFIED_TIMEZONE) {
Found = FALSE;
diff --git a/ShellPkg/Library/UefiShellLevel3CommandsLib/Cls.c b/ShellPkg/Library/UefiShellLevel3CommandsLib/Cls.c
index dec24776ff..8cb1aedf43 100644
--- a/ShellPkg/Library/UefiShellLevel3CommandsLib/Cls.c
+++ b/ShellPkg/Library/UefiShellLevel3CommandsLib/Cls.c
@@ -29,21 +29,18 @@ ShellCommandRunCls (
{
EFI_STATUS Status;
LIST_ENTRY *Package;
- CHAR16 *Message;
UINTN Background;
UINTN ForeColor;
CHAR16 *ProblemParam;
SHELL_STATUS ShellStatus;
CONST CHAR16 *Param1;
- ShellStatus = SHELL_SUCCESS;
- ProblemParam = NULL;
- Background = 0;
-
//
// Initialize variables
//
- Message = NULL;
+ ShellStatus = SHELL_SUCCESS;
+ ProblemParam = NULL;
+ Background = 0;
//
// initialize the shell lib (we must be in non-auto-init...)
diff --git a/ShellPkg/Library/UefiShellLevel3CommandsLib/GetMtc.c b/ShellPkg/Library/UefiShellLevel3CommandsLib/GetMtc.c
index ce1eb1fcf0..f1b20a13e3 100644
--- a/ShellPkg/Library/UefiShellLevel3CommandsLib/GetMtc.c
+++ b/ShellPkg/Library/UefiShellLevel3CommandsLib/GetMtc.c
@@ -1,7 +1,7 @@
/** @file
Main file for GetMtc shell level 3 function.
- Copyright (c) 2009 - 2010, 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
@@ -70,17 +70,12 @@ ShellCommandRunGetMtc (
// Get the monotonic counter count
//
Status = gBS->GetNextMonotonicCount(&Mtc);
- switch(Status) {
- case EFI_DEVICE_ERROR:
- ShellStatus = SHELL_DEVICE_ERROR;
- break;
- case EFI_SECURITY_VIOLATION:
- ShellStatus = SHELL_SECURITY_VIOLATION;
- break;
- default:
- if (EFI_ERROR(Status)) {
- ShellStatus = SHELL_DEVICE_ERROR;
- }
+ if (Status == EFI_DEVICE_ERROR) {
+ ShellStatus = SHELL_DEVICE_ERROR;
+ } else if (Status == EFI_SECURITY_VIOLATION) {
+ ShellStatus = SHELL_SECURITY_VIOLATION;
+ } else if (EFI_ERROR(Status)) {
+ ShellStatus = SHELL_DEVICE_ERROR;
}
//
diff --git a/ShellPkg/Library/UefiShellLevel3CommandsLib/Help.c b/ShellPkg/Library/UefiShellLevel3CommandsLib/Help.c
index c4acc0b499..cd03ff7f07 100644
--- a/ShellPkg/Library/UefiShellLevel3CommandsLib/Help.c
+++ b/ShellPkg/Library/UefiShellLevel3CommandsLib/Help.c
@@ -41,7 +41,6 @@ ShellCommandRunHelp (
LIST_ENTRY *Package;
CHAR16 *ProblemParam;
SHELL_STATUS ShellStatus;
- CHAR16 *OutText;
CONST COMMAND_LIST *CommandList;
CONST COMMAND_LIST *Node;
CHAR16 *CommandToGetHelpOn;
@@ -53,7 +52,6 @@ ShellCommandRunHelp (
PrintCommandText = TRUE;
ProblemParam = NULL;
ShellStatus = SHELL_SUCCESS;
- OutText = NULL;
CommandToGetHelpOn = NULL;
SectionToGetHelpOn = NULL;
Found = FALSE;
diff --git a/ShellPkg/Library/UefiShellLevel3CommandsLib/Touch.c b/ShellPkg/Library/UefiShellLevel3CommandsLib/Touch.c
index 29f6be3931..f5e27ef1a9 100644
--- a/ShellPkg/Library/UefiShellLevel3CommandsLib/Touch.c
+++ b/ShellPkg/Library/UefiShellLevel3CommandsLib/Touch.c
@@ -38,7 +38,11 @@ TouchFileByHandle (
return (EFI_ACCESS_DENIED);
}
Status = gRT->GetTime(&FileInfo->ModificationTime, NULL);
- ASSERT_EFI_ERROR(Status);
+ if (EFI_ERROR(Status)) {
+ ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_GEN_PROBLEM), gShellLevel3HiiHandle, L"gRT->GetTime", Status);
+ return (SHELL_DEVICE_ERROR);
+ }
+
CopyMem(&FileInfo->LastAccessTime, &FileInfo->ModificationTime, sizeof(EFI_TIME));
Status = gEfiShellProtocol->SetFileInfo(Handle, FileInfo);
diff --git a/ShellPkg/Library/UefiShellLevel3CommandsLib/UefiShellLevel3CommandsLib.uni b/ShellPkg/Library/UefiShellLevel3CommandsLib/UefiShellLevel3CommandsLib.uni
index 55b2806098..8c3e79dda7 100644
--- a/ShellPkg/Library/UefiShellLevel3CommandsLib/UefiShellLevel3CommandsLib.uni
+++ b/ShellPkg/Library/UefiShellLevel3CommandsLib/UefiShellLevel3CommandsLib.uni
Binary files differ
diff --git a/SourceLevelDebugPkg/Library/DebugAgent/DebugAgentCommon/DebugAgent.c b/SourceLevelDebugPkg/Library/DebugAgent/DebugAgentCommon/DebugAgent.c
index f4039f4995..01711ff085 100644
--- a/SourceLevelDebugPkg/Library/DebugAgent/DebugAgentCommon/DebugAgent.c
+++ b/SourceLevelDebugPkg/Library/DebugAgent/DebugAgentCommon/DebugAgent.c
@@ -19,7 +19,7 @@
#include "Ia32/DebugException.h"
CHAR8 mErrorMsgVersionAlert[] = "\rThe SourceLevelDebugPkg you are using requires a newer version of the Intel(R) UDK Debugger Tool.\r\n";
-CHAR8 mErrorMsgSendInitPacket[] = "\rSend INIT break packet and try to connect the HOST (Intel(R) UDK Debugger Tool v1.3) ...\r\n";
+CHAR8 mErrorMsgSendInitPacket[] = "\rSend INIT break packet and try to connect the HOST (Intel(R) UDK Debugger Tool v1.3.1) ...\r\n";
CHAR8 mErrorMsgConnectOK[] = "HOST connection is successful!\r\n";
CHAR8 mErrorMsgConnectFail[] = "HOST connection is failed!\r\n";
CHAR8 mWarningMsgIngoreBreakpoint[] = "Ignore break point in SMM for SMI issued during DXE debugging!\r\n";
@@ -1110,55 +1110,127 @@ GetBreakCause (
}
/**
- Send packet with response data to HOST.
+ Copy memory from source to destination with specified width.
+
+ @param[out] Dest A pointer to the destination buffer of the memory copy.
+ @param[in] Src A pointer to the source buffer of the memory copy.
+ @param[in] Count The number of data with specified width to copy from source to destination.
+ @param[in] Width Data width in byte.
+
+**/
+VOID
+CopyMemByWidth (
+ OUT UINT8 *Dest,
+ IN UINT8 *Src,
+ IN UINT16 Count,
+ IN UINT8 Width
+ )
+{
+ UINT8 *Destination;
+ UINT8 *Source;
+ INT8 Step;
+
+ if (Src > Dest) {
+ Destination = Dest;
+ Source = Src;
+ Step = Width;
+ } else {
+ //
+ // Copy memory from tail to avoid memory overlap
+ //
+ Destination = Dest + (Count - 1) * Width;
+ Source = Src + (Count - 1) * Width;
+ Step = -Width;
+ }
+
+ while (Count-- != 0) {
+ switch (Width) {
+ case 1:
+ *(UINT8 *) Destination = MmioRead8 ((UINTN) Source);
+ break;
+ case 2:
+ *(UINT16 *) Destination = MmioRead16 ((UINTN) Source);
+ break;
+ case 4:
+ *(UINT32 *) Destination = MmioRead32 ((UINTN) Source);
+ break;
+ case 8:
+ *(UINT64 *) Destination = MmioRead64 ((UINTN) Source);
+ break;
+ default:
+ ASSERT (FALSE);
+ }
+ Source += Step;
+ Destination += Step;
+ }
+}
+
+/**
+ Read memory with speicifed width and send packet with response data to HOST.
@param[in] Data Pointer to response data buffer.
- @param[in] DataSize Size of response data in byte.
+ @param[in] Count The number of data with specified Width.
+ @param[in] Width Data width in byte.
@retval RETURN_SUCCESS Response data was sent successfully.
**/
RETURN_STATUS
-SendDataResponsePacket (
+ReadMemoryAndSendResponsePacket (
IN UINT8 *Data,
- IN UINT16 DataSize
+ IN UINT16 Count,
+ IN UINT8 Width
)
{
RETURN_STATUS Status;
DEBUG_PACKET_HEADER *DebugHeader;
BOOLEAN LastPacket;
DEBUG_PACKET_HEADER *AckDebugHeader;
- UINT8 DebugPacket[DEBUG_DATA_UPPER_LIMIT];
+ UINT8 DebugPacket[DEBUG_DATA_UPPER_LIMIT + sizeof (UINT64) - 1];
UINT8 InputPacketBuffer[DEBUG_DATA_UPPER_LIMIT];
DEBUG_PORT_HANDLE Handle;
UINT8 SequenceNo;
+ UINTN RemainingDataSize;
+ UINTN CurrentDataSize;
Handle = GetDebugPortHandle();
- DebugHeader = (DEBUG_PACKET_HEADER *) &DebugPacket;
+ //
+ // Data is appended end of Debug Packet header, make sure data address
+ // in Debug Packet 8-byte alignment always
+ //
+ DebugHeader = (DEBUG_PACKET_HEADER *) (ALIGN_VALUE ((UINTN)&DebugPacket + sizeof (DEBUG_PACKET_HEADER), sizeof (UINT64))
+ - sizeof (DEBUG_PACKET_HEADER));
DebugHeader->StartSymbol = DEBUG_STARTING_SYMBOL_NORMAL;
+ RemainingDataSize = Count * Width;
while (TRUE) {
SequenceNo = GetMailboxPointer()->HostSequenceNo;
- if (DataSize <= DEBUG_DATA_MAXIMUM_REAL_DATA) {
+ if (RemainingDataSize <= DEBUG_DATA_MAXIMUM_REAL_DATA) {
+ //
+ // If the remaining data is less one real packet size, this is the last data packet
+ //
+ CurrentDataSize = RemainingDataSize;
LastPacket = TRUE;
- DebugHeader->Command = DEBUG_COMMAND_OK;
- DebugHeader->Length = (UINT8) (DataSize + sizeof (DEBUG_PACKET_HEADER));
- DebugHeader->SequenceNo = SequenceNo;
- DebugHeader->Crc = 0;
- CopyMem (DebugHeader + 1, Data, DataSize);
-
+ DebugHeader->Command = DEBUG_COMMAND_OK;
} else {
+ //
+ // Data is too larger to be sent in one packet, calculate the actual data size could
+ // be sent in one Maximum data packet
+ //
+ CurrentDataSize = (DEBUG_DATA_MAXIMUM_REAL_DATA / Width) * Width;
LastPacket = FALSE;
- DebugHeader->Command = DEBUG_COMMAND_IN_PROGRESS;
- DebugHeader->Length = DEBUG_DATA_MAXIMUM_REAL_DATA + sizeof (DEBUG_PACKET_HEADER);
- DebugHeader->SequenceNo = SequenceNo;
- DebugHeader->Crc = 0;
- CopyMem (DebugHeader + 1, Data, DEBUG_DATA_MAXIMUM_REAL_DATA);
+ DebugHeader->Command = DEBUG_COMMAND_IN_PROGRESS;
}
-
//
- // Calculate and fill the checksum
+ // Construct the rest Debug header
+ //
+ DebugHeader->Length = (UINT8)(CurrentDataSize + sizeof (DEBUG_PACKET_HEADER));
+ DebugHeader->SequenceNo = SequenceNo;
+ DebugHeader->Crc = 0;
+ CopyMemByWidth ((UINT8 *)(DebugHeader + 1), Data, (UINT16) CurrentDataSize / Width, Width);
+ //
+ // Calculate and fill the checksum, DebugHeader->Crc should be 0 before invoking CalculateCrc16 ()
//
DebugHeader->Crc = CalculateCrc16 ((UINT8 *) DebugHeader, DebugHeader->Length, 0);
@@ -1184,10 +1256,10 @@ SendDataResponsePacket (
}
if ((SequenceNo == (UINT8) (DebugHeader->SequenceNo + 1)) && (AckDebugHeader->Command == DEBUG_COMMAND_CONTINUE)) {
//
- // Send the rest packet
+ // Calculate the rest data size
//
- Data += DEBUG_DATA_MAXIMUM_REAL_DATA;
- DataSize -= DEBUG_DATA_MAXIMUM_REAL_DATA;
+ Data += CurrentDataSize;
+ RemainingDataSize -= CurrentDataSize;
UpdateMailboxContent (GetMailboxPointer(), DEBUG_MAILBOX_HOST_SEQUENCE_NO_INDEX, (UINT8) SequenceNo);
break;
}
@@ -1200,6 +1272,24 @@ SendDataResponsePacket (
}
/**
+ Send packet with response data to HOST.
+
+ @param[in] Data Pointer to response data buffer.
+ @param[in] DataSize Size of response data in byte.
+
+ @retval RETURN_SUCCESS Response data was sent successfully.
+
+**/
+RETURN_STATUS
+SendDataResponsePacket (
+ IN UINT8 *Data,
+ IN UINT16 DataSize
+ )
+{
+ return ReadMemoryAndSendResponsePacket (Data, DataSize, 1);
+}
+
+/**
Send break cause packet to HOST.
@param[in] Vector Vector value of exception or interrutp.
@@ -1349,7 +1439,7 @@ CommandCommunication (
)
{
RETURN_STATUS Status;
- UINT8 InputPacketBuffer[DEBUG_DATA_UPPER_LIMIT];
+ UINT8 InputPacketBuffer[DEBUG_DATA_UPPER_LIMIT + sizeof (UINT64) - 1];
DEBUG_PACKET_HEADER *DebugHeader;
UINT8 Width;
UINT8 Data8;
@@ -1376,6 +1466,7 @@ CommandCommunication (
DEBUG_AGENT_EXCEPTION_BUFFER AgentExceptionBuffer;
UINT32 IssuedViewPoint;
DEBUG_AGENT_MAILBOX *Mailbox;
+ UINT8 *AlignedDataPtr;
ProcessorIndex = 0;
IssuedViewPoint = 0;
@@ -1644,12 +1735,19 @@ CommandCommunication (
case DEBUG_COMMAND_READ_MEMORY:
MemoryRead = (DEBUG_DATA_READ_MEMORY *) (DebugHeader + 1);
- Status = SendDataResponsePacket ((UINT8 *) (UINTN) MemoryRead->Address, (UINT16) (MemoryRead->Count * MemoryRead->Width));
+ Status = ReadMemoryAndSendResponsePacket ((UINT8 *) (UINTN) MemoryRead->Address, MemoryRead->Count, MemoryRead->Width);
break;
case DEBUG_COMMAND_WRITE_MEMORY:
MemoryWrite = (DEBUG_DATA_WRITE_MEMORY *) (DebugHeader + 1);
- CopyMem ((VOID *) (UINTN) MemoryWrite->Address, &MemoryWrite->Data, MemoryWrite->Count * MemoryWrite->Width);
+ //
+ // Copy data into one memory with 8-byte alignment address
+ //
+ AlignedDataPtr = ALIGN_POINTER ((UINT8 *) &MemoryWrite->Data, sizeof (UINT64));
+ if (AlignedDataPtr != (UINT8 *) &MemoryWrite->Data) {
+ CopyMem (AlignedDataPtr, (UINT8 *) &MemoryWrite->Data, MemoryWrite->Count * MemoryWrite->Width);
+ }
+ CopyMemByWidth ((UINT8 *) (UINTN) MemoryWrite->Address, AlignedDataPtr, MemoryWrite->Count, MemoryWrite->Width);
SendAckPacket (DEBUG_COMMAND_OK);
break;
@@ -1915,7 +2013,7 @@ InterruptProcess (
// the saved CPU content in CommandCommunication()
//
if (GetDebugFlag (DEBUG_AGENT_FLAG_AGENT_IN_PROGRESS) == 1) {
- DebugAgentMsgPrint (DEBUG_AGENT_ERROR, "Debug agent meet one Exception, ExceptionNum is %d.\n", Vector);
+ DebugAgentMsgPrint (DEBUG_AGENT_ERROR, "Debug agent meet one Exception, ExceptionNum is %d, EIP = 0x%x.\n", Vector, (UINTN)CpuContext->Eip);
ExceptionBuffer = (DEBUG_AGENT_EXCEPTION_BUFFER *) (UINTN) GetMailboxPointer()->ExceptionBufferPointer;
ExceptionBuffer->ExceptionContent.ExceptionNum = (UINT8) Vector;
ExceptionBuffer->ExceptionContent.ExceptionData = (UINT32) CpuContext->ExceptionData;
diff --git a/SourceLevelDebugPkg/Library/DebugAgent/DebugAgentCommon/DebugAgent.h b/SourceLevelDebugPkg/Library/DebugAgent/DebugAgentCommon/DebugAgent.h
index 5eb50d038c..748d562a59 100644
--- a/SourceLevelDebugPkg/Library/DebugAgent/DebugAgentCommon/DebugAgent.h
+++ b/SourceLevelDebugPkg/Library/DebugAgent/DebugAgentCommon/DebugAgent.h
@@ -89,6 +89,7 @@ typedef struct {
#define DEBUG_AGENT_FLAG_MEMORY_READY BIT2
#define DEBUG_AGENT_FLAG_STEPPING BIT3
#define DEBUG_AGENT_FLAG_CHECK_MAILBOX_IN_HOB BIT4
+#define DEBUG_AGENT_FLAG_INIT_ARCH BIT5|BIT6
#define DEBUG_AGENT_FLAG_BREAK_ON_NEXT_SMI BIT32
#define DEBUG_AGENT_FLAG_PRINT_ERROR_LEVEL (BIT33|BIT34|BIT35|BIT36)
#define DEBUG_AGENT_FLAG_BREAK_BOOT_SCRIPT BIT37
@@ -111,8 +112,8 @@ typedef union {
UINT32 MemoryReady : 1; // 1: Memory is ready
UINT32 SteppingFlag : 1; // 1: Agent is running stepping command
UINT32 CheckMailboxInHob : 1; // 1: Need to check mailbox saved in HOB
- UINT32 SendingPacket : 1; // 1: TARGET is sending debug packet to HOST
- UINT32 Reserved1 : 26;
+ UINT32 InitArch : 2; // value of DEBUG_DATA_RESPONSE_ARCH_MODE
+ UINT32 Reserved1 : 25;
//
// Higher 32bits to control the behavior of DebugAgent
//
diff --git a/SourceLevelDebugPkg/Library/DebugAgent/DxeDebugAgent/DxeDebugAgentLib.c b/SourceLevelDebugPkg/Library/DebugAgent/DxeDebugAgent/DxeDebugAgentLib.c
index 35c6acfd9d..d560b52359 100644
--- a/SourceLevelDebugPkg/Library/DebugAgent/DxeDebugAgent/DxeDebugAgentLib.c
+++ b/SourceLevelDebugPkg/Library/DebugAgent/DxeDebugAgent/DxeDebugAgentLib.c
@@ -55,6 +55,8 @@ InternalConstructorWorker (
EFI_STATUS Status;
EFI_PHYSICAL_ADDRESS Address;
BOOLEAN DebugTimerInterruptState;
+ DEBUG_AGENT_MAILBOX *Mailbox;
+ DEBUG_AGENT_MAILBOX *NewMailbox;
//
// Install EFI Serial IO protocol on debug port
@@ -65,20 +67,28 @@ InternalConstructorWorker (
Status = gBS->AllocatePages (
AllocateAnyPages,
EfiACPIMemoryNVS,
- EFI_SIZE_TO_PAGES (sizeof (DEBUG_AGENT_MAILBOX)),
+ EFI_SIZE_TO_PAGES (sizeof(DEBUG_AGENT_MAILBOX) + PcdGet16(PcdDebugPortHandleBufferSize)),
&Address
);
ASSERT_EFI_ERROR (Status);
DebugTimerInterruptState = SaveAndSetDebugTimerInterrupt (FALSE);
- CopyMem (
- (UINT8 *) (UINTN) Address,
- (UINT8 *) (UINTN) GetMailboxPointer (),
- sizeof (DEBUG_AGENT_MAILBOX)
- );
- DebugTimerInterruptState = SaveAndSetDebugTimerInterrupt (DebugTimerInterruptState);
- mMailboxPointer = (DEBUG_AGENT_MAILBOX *) (UINTN) Address;
+ NewMailbox = (DEBUG_AGENT_MAILBOX *) (UINTN) Address;
+ //
+ // Copy Mailbox and Debug Port Handle buffer to new location in ACPI NVS memory, because original Mailbox
+ // and Debug Port Handle buffer may be free at runtime, SMM debug agent needs to access them
+ //
+ Mailbox = GetMailboxPointer ();
+ CopyMem (NewMailbox, Mailbox, sizeof (DEBUG_AGENT_MAILBOX));
+ CopyMem (NewMailbox + 1, (VOID *)(UINTN)Mailbox->DebugPortHandle, PcdGet16(PcdDebugPortHandleBufferSize));
+ //
+ // Update Debug Port Handle in new Mailbox
+ //
+ UpdateMailboxContent (NewMailbox, DEBUG_MAILBOX_DEBUG_PORT_HANDLE_INDEX, (UINT64)(UINTN)(NewMailbox + 1));
+ mMailboxPointer = NewMailbox;
+
+ DebugTimerInterruptState = SaveAndSetDebugTimerInterrupt (DebugTimerInterruptState);
Status = gBS->InstallConfigurationTable (&gEfiDebugAgentGuid, (VOID *) mMailboxPointer);
ASSERT_EFI_ERROR (Status);
diff --git a/SourceLevelDebugPkg/Library/DebugAgent/DxeDebugAgentLib.inf b/SourceLevelDebugPkg/Library/DebugAgent/DxeDebugAgentLib.inf
index f73385ce71..cc9b48191d 100644
--- a/SourceLevelDebugPkg/Library/DebugAgent/DxeDebugAgentLib.inf
+++ b/SourceLevelDebugPkg/Library/DebugAgent/DxeDebugAgentLib.inf
@@ -90,4 +90,5 @@
[Pcd]
gEfiMdePkgTokenSpaceGuid.PcdFSBClock ## CONSUMES
gEfiSourceLevelDebugPkgTokenSpaceGuid.PcdExceptionsIgnoredByDebugger ## CONSUMES
+ gEfiSourceLevelDebugPkgTokenSpaceGuid.PcdDebugPortHandleBufferSize ## CONSUMES
diff --git a/SourceLevelDebugPkg/Library/DebugAgent/SecPeiDebugAgent/SecPeiDebugAgentLib.c b/SourceLevelDebugPkg/Library/DebugAgent/SecPeiDebugAgent/SecPeiDebugAgentLib.c
index 49c8268e09..c253fa59a3 100644
--- a/SourceLevelDebugPkg/Library/DebugAgent/SecPeiDebugAgent/SecPeiDebugAgentLib.c
+++ b/SourceLevelDebugPkg/Library/DebugAgent/SecPeiDebugAgent/SecPeiDebugAgentLib.c
@@ -174,19 +174,22 @@ GetMailboxPointer (
MailboxLocationInIdt = GetLocationSavedMailboxPointerInIdtEntry ();
Mailbox = (DEBUG_AGENT_MAILBOX *)(UINTN)(*MailboxLocationInIdt);
//
- // Check if mailbox was setup in PEI firstly, cannot used GetDebugFlag() to
- // get CheckMailboxInHob flag to avoid GetMailboxPointer() nesting.
+ // Cannot used GetDebugFlag() to get Debug Flag to avoid GetMailboxPointer() nested
//
- if (Mailbox->DebugFlag.Bits.CheckMailboxInHob != 1) {
- //
- // If mailbox in IDT entry has already been the final one
+ if (Mailbox->DebugFlag.Bits.CheckMailboxInHob != 1 ||
+ Mailbox->DebugFlag.Bits.InitArch != DEBUG_ARCH_SYMBOL) {
//
+ // If mailbox was setup in SEC or the current CPU arch is different from the init arch
+ // Debug Agent initialized, return the mailbox from IDT entry directly.
+ // Otherwise, we need to check the mailbox location saved in GUIDed HOB further.
+ //
return Mailbox;
}
MailboxLocationInHob = GetMailboxLocationFromHob ();
//
- // Compare mailbox in IDT enry with mailbox in HOB
+ // Compare mailbox in IDT enry with mailbox in HOB,
+ // need to fix mailbox location if HOB moved by PEI CORE
//
if (MailboxLocationInHob != MailboxLocationInIdt && MailboxLocationInHob != NULL) {
Mailbox = (DEBUG_AGENT_MAILBOX *)(UINTN)(*MailboxLocationInHob);
@@ -244,23 +247,52 @@ DebugAgentCallbackMemoryDiscoveredPpi (
IN VOID *Ppi
)
{
+ EFI_STATUS Status;
DEBUG_AGENT_MAILBOX *Mailbox;
BOOLEAN InterruptStatus;
-
+ EFI_PHYSICAL_ADDRESS Address;
+ DEBUG_AGENT_MAILBOX *NewMailbox;
+ UINT64 *MailboxLocationInHob;
+
//
// Save and disable original interrupt status
//
InterruptStatus = SaveAndDisableInterrupts ();
-
+
//
- // Set physical memory ready flag
+ // Allocate ACPI NVS memory for new Mailbox and Debug Port Handle buffer
+ //
+ Status = PeiServicesAllocatePages (
+ EfiACPIMemoryNVS,
+ EFI_SIZE_TO_PAGES (sizeof(DEBUG_AGENT_MAILBOX) + PcdGet16(PcdDebugPortHandleBufferSize)),
+ &Address
+ );
+ ASSERT_EFI_ERROR (Status);
+ NewMailbox = (DEBUG_AGENT_MAILBOX *) (UINTN) Address;
+ //
+ // Copy Mailbox and Debug Port Handle buffer to new location in ACPI NVS memory, because original Mailbox
+ // and Debug Port Handle buffer in the allocated pool that may be marked as free by DXE Core after DXE Core
+ // reallocates the HOB.
//
Mailbox = GetMailboxPointer ();
- SetDebugFlag (DEBUG_AGENT_FLAG_MEMORY_READY, 1);
-
+ CopyMem (NewMailbox, Mailbox, sizeof (DEBUG_AGENT_MAILBOX));
+ CopyMem (NewMailbox + 1, (VOID *)(UINTN)Mailbox->DebugPortHandle, PcdGet16(PcdDebugPortHandleBufferSize));
+ //
+ // Update Mailbox Location pointer in GUIDed HOB and IDT entry with new one
+ //
+ MailboxLocationInHob = GetMailboxLocationFromHob ();
+ ASSERT (MailboxLocationInHob != NULL);
+ *MailboxLocationInHob = (UINT64)(UINTN)NewMailbox;
+ SetLocationSavedMailboxPointerInIdtEntry (MailboxLocationInHob);
+ //
+ // Update Debug Port Handle in new Mailbox
//
- // Memory has been ready
+ UpdateMailboxContent (NewMailbox, DEBUG_MAILBOX_DEBUG_PORT_HANDLE_INDEX, (UINT64)(UINTN)(NewMailbox + 1));
//
+ // Set physical memory ready flag
+ //
+ SetDebugFlag (DEBUG_AGENT_FLAG_MEMORY_READY, 1);
+
if (IsHostAttached ()) {
//
// Trigger one software interrupt to inform HOST
@@ -341,7 +373,14 @@ InitializeDebugAgent (
// Get and save debug port handle and set the length of memory block.
//
SetLocationSavedMailboxPointerInIdtEntry (&MailboxLocation);
+ //
+ // Force error message could be printed during the first shakehand between Target/HOST.
+ //
SetDebugFlag (DEBUG_AGENT_FLAG_PRINT_ERROR_LEVEL, DEBUG_AGENT_ERROR);
+ //
+ // Save init arch type when debug agent initialized
+ //
+ SetDebugFlag (DEBUG_AGENT_FLAG_INIT_ARCH, DEBUG_ARCH_SYMBOL);
InitializeDebugTimer ();
@@ -425,6 +464,10 @@ InitializeDebugAgent (
//
SetLocationSavedMailboxPointerInIdtEntry (MailboxLocationPointer);
//
+ // Save init arch type when debug agent initialized
+ //
+ SetDebugFlag (DEBUG_AGENT_FLAG_INIT_ARCH, DEBUG_ARCH_SYMBOL);
+ //
// Register for a callback once memory has been initialized.
// If memery has been ready, the callback funtion will be invoked immediately
//
@@ -455,6 +498,9 @@ InitializeDebugAgent (
MailboxLocationPointer = (UINT64 *) (UINTN) (Ia32IdtEntry[DEBUG_MAILBOX_VECTOR].Bits.OffsetLow +
(Ia32IdtEntry[DEBUG_MAILBOX_VECTOR].Bits.OffsetHigh << 16));
Mailbox = (DEBUG_AGENT_MAILBOX *) (UINTN)(*MailboxLocationPointer);
+ //
+ // Mailbox should valid and setup before executing thunk code
+ //
VerifyMailboxChecksum (Mailbox);
DebugPortHandle = (UINT64) (UINTN)DebugPortInitialize ((VOID *)(UINTN)Mailbox->DebugPortHandle, NULL);
@@ -480,7 +526,6 @@ InitializeDebugAgent (
DEBUG ((EFI_D_ERROR, "Debug Agent: The InitFlag value is not allowed!\n"));
CpuDeadLoop ();
break;
-
}
EnableInterrupts ();
diff --git a/SourceLevelDebugPkg/Library/DebugCommunicationLibUsb/DebugCommunicationLibUsb.c b/SourceLevelDebugPkg/Library/DebugCommunicationLibUsb/DebugCommunicationLibUsb.c
index c08d45b787..54aaa71d75 100644
--- a/SourceLevelDebugPkg/Library/DebugCommunicationLibUsb/DebugCommunicationLibUsb.c
+++ b/SourceLevelDebugPkg/Library/DebugCommunicationLibUsb/DebugCommunicationLibUsb.c
@@ -674,10 +674,16 @@ InitializeUsbDebugHardware (
//
if (((MmioRead32((UINTN)&UsbDebugPortRegister->ControlStatus) & (USB_DEBUG_PORT_OWNER | USB_DEBUG_PORT_IN_USE))
!= (USB_DEBUG_PORT_OWNER | USB_DEBUG_PORT_IN_USE)) || (Handle->Initialized == USBDBG_RESET)) {
+ DEBUG ((
+ EFI_D_INFO,
+ "UsbDbg: Need to reset the host controller. ControlStatus = %08x\n",
+ MmioRead32((UINTN)&UsbDebugPortRegister->ControlStatus)
+ ));
//
// If the host controller is halted, then reset and restart it.
//
if ((MmioRead32((UINTN)UsbStatus) & BIT12) != 0) {
+ DEBUG ((EFI_D_INFO, "UsbDbg: Reset the host controller.\n"));
//
// reset the host controller.
//
@@ -712,7 +718,9 @@ InitializeUsbDebugHardware (
return RETURN_NOT_FOUND;
}
- if (Handle->Initialized != USBDBG_INIT_DONE) {
+ if (Handle->Initialized != USBDBG_INIT_DONE ||
+ (MmioRead32 ((UINTN) &UsbDebugPortRegister->ControlStatus) & USB_DEBUG_PORT_ENABLE) == 0) {
+ DEBUG ((EFI_D_INFO, "UsbDbg: Reset the debug port.\n"));
//
// Reset the debug port
//
diff --git a/StdLib/LibC/Locale/multibyte_Utf8.c b/StdLib/LibC/Locale/multibyte_Utf8.c
index ec9b012658..ffe3dee231 100644
--- a/StdLib/LibC/Locale/multibyte_Utf8.c
+++ b/StdLib/LibC/Locale/multibyte_Utf8.c
@@ -197,19 +197,24 @@ DecodeOneStateful(
int NumConv;
unsigned char ch;
- if((Src == NULL) || (*Src == '\0')) {
- return 0;
- }
if(pS == NULL) {
pS = &LocalConvState;
}
- SrcEnd = Src + Len;
NumConv = 0;
- while(Src < SrcEnd) {
- ch = (unsigned char)*Src++;
- NumConv = ProcessOneByte(ch, pS);
- if(NumConv != -2)
- break;
+ if(Src != NULL) {
+ if(*Src != 0) {
+ SrcEnd = Src + Len;
+ while(Src < SrcEnd) {
+ ch = (unsigned char)*Src++;
+ NumConv = ProcessOneByte(ch, pS);
+ if(NumConv != -2) {
+ break;
+ }
+ }
+ }
+ else if(Dest != NULL) {
+ *Dest = 0;
+ }
}
if((NumConv > 0) && (Dest != NULL)) {
Dest[0] = pS->D[0];
@@ -416,14 +421,6 @@ EncodeUtf8(char *Dest, wchar_t ch)
*/
if(Dest != NULL) { // Save character if Dest is not NULL
memcpy(Dest, Buff, NumInBuff);
-
- if(ch != 0) {
- // Terminate the destination string.
- Dest[NumInBuff] = '\0';
- }
- else {
- NumInBuff = 0;
- }
}
return NumInBuff; // Tell the caller
}
@@ -646,7 +643,7 @@ mbsrtowcs(
size_t RetVal = 0;
const char *MySrc;
- if((src == NULL) || (*src == NULL) || (**src == '\0')) {
+ if((src == NULL) || (*src == NULL)) {
return 0;
}
@@ -855,7 +852,7 @@ wctomb(
}
/** The wcsrtombs function converts a sequence of wide characters from the array
- indirectly pointed to by Dest into a sequence of corresponding multibyte
+ indirectly pointed to by Src into a sequence of corresponding multibyte
characters that begins in the conversion state described by the object
pointed to by ps.
@@ -914,15 +911,16 @@ wcsrtombs(
return (0);
if (Dest == NULL) {
- if(MaxBytes <= 0) {
- MaxBytes = ASCII_STRING_MAX;
- }
- NumStored = EstimateWtoM(*Src, MaxBytes, NULL);
+ NumStored = EstimateWtoM(*Src, ASCII_STRING_MAX, NULL);
}
else {
- while (OneWcToMcLen(InCh = *(*Src)++) <= MaxBytes) {
+ if((MaxBytes < 0) || (MaxBytes > ASCII_STRING_MAX)) {
+ MaxBytes = ASCII_STRING_MAX;
+ }
+ while ((MaxBytes > 0) && (OneWcToMcLen(InCh = *(*Src)++) <= MaxBytes)) {
if(InCh == 0) {
*Src = NULL;
+ *Dest = 0; // NUL terminate Dest string, but don't count the NUL
break;
}
count = (int)wcrtomb(Dest, InCh, NULL);