summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRyan Harkin <ryan.harkin@linaro.org>2012-11-29 14:09:55 +0000
committerRyan Harkin <ryan.harkin@linaro.org>2012-11-29 14:09:55 +0000
commitefb56459bfd61cce378f5b35cd8a8c6d088799a9 (patch)
tree0e1d6a9aa6c13e44805c8b6960ded5125d31fce5
parentb60dc2d3e998a65b6d34bfd852838ea1149f19f9 (diff)
parent939b6e81660592d245a12e69a94a2590fc0eb505 (diff)
Merge branch 'armlt-tracking' of git://git.linaro.org/arm/uefi/uefi-nextlinaro-uefi-2012.11
Signed-off-by: Ryan Harkin <ryan.harkin@linaro.org>
-rw-r--r--edk2/ArmPkg/Drivers/ArmCpuLib/ArmCortexA5Lib/ArmCortexA5Lib.c5
-rw-r--r--edk2/ArmPkg/Include/Chipset/ArmCortexA5.h36
-rw-r--r--edk2/ArmPlatformPkg/ArmPlatformPkg.dec3
-rw-r--r--edk2/ArmPlatformPkg/ArmVExpressPkg/ArmVExpress-CTA15-A7.dsc6
-rw-r--r--edk2/ArmPlatformPkg/ArmVExpressPkg/ArmVExpress-CTA15x2.dsc5
-rw-r--r--edk2/ArmPlatformPkg/ArmVExpressPkg/ArmVExpress-CTA5s.dsc3
-rw-r--r--edk2/ArmPlatformPkg/ArmVExpressPkg/ArmVExpress-CTA9x4.dsc6
-rw-r--r--edk2/ArmPlatformPkg/ArmVExpressPkg/Library/ArmVExpressLibCTA15x2/CTA15x2Boot.S33
-rw-r--r--edk2/ArmPlatformPkg/ArmVExpressPkg/Library/ArmVExpressLibCTA5s/ArmVExpressLib.inf3
-rw-r--r--edk2/ArmPlatformPkg/ArmVExpressPkg/Library/ArmVExpressLibCTA5s/ArmVExpressSecLib.inf3
-rw-r--r--edk2/ArmPlatformPkg/ArmVExpressPkg/Library/ArmVExpressLibCTA5s/CTA5s.c60
-rw-r--r--edk2/ArmPlatformPkg/ArmVExpressPkg/Library/ArmVExpressLibCTA5s/CTA5sBoot.S397
-rw-r--r--edk2/ArmPlatformPkg/ArmVExpressPkg/Library/ArmVExpressLibCTA9x4/CTA9x4.c8
-rw-r--r--edk2/ArmPlatformPkg/Bds/Bds.c10
-rw-r--r--edk2/ArmPlatformPkg/Bds/Bds.inf1
-rw-r--r--edk2/ArmPlatformPkg/Bds/BdsInternal.h7
-rw-r--r--edk2/ArmPlatformPkg/Bds/BootMenu.c207
-rw-r--r--edk2/ArmPlatformPkg/Bds/BootOption.c44
-rw-r--r--edk2/ArmPlatformPkg/Bds/BootOptionSupport.c18
-rwxr-xr-xedk2/ArmPlatformPkg/Documentation/patches/BaseTools-Pending-Patches.patch231
-rw-r--r--edk2/ArmPlatformPkg/Scripts/Ds5/build_report.py54
-rw-r--r--edk2/ArmPlatformPkg/Scripts/Ds5/cmd_load_symbols.py100
-rw-r--r--edk2/ArmPlatformPkg/Scripts/Ds5/edk2_debugger.py217
-rw-r--r--edk2/ArmPlatformPkg/Scripts/Ds5/firmware_volume.py301
-rw-r--r--edk2/ArmPlatformPkg/Scripts/Ds5/system_table.py129
-rw-r--r--edk2/CryptoPkg/Library/BaseCryptLib/Pk/CryptAuthenticode.c20
-rw-r--r--edk2/CryptoPkg/Library/BaseCryptLib/Pk/CryptPkcs7Verify.c4
-rw-r--r--edk2/CryptoPkg/Library/OpensslLib/EDKII_openssl-0.9.8w.patch39
-rw-r--r--edk2/DuetPkg/Library/DuetBdsLib/BdsPlatform.h12
-rw-r--r--edk2/EmbeddedPkg/Universal/MmcDxe/MmcBlockIo.c12
-rw-r--r--edk2/IntelFrameworkModulePkg/Bus/Isa/Ps2KeyboardDxe/Ps2KbdCtrller.c192
-rw-r--r--edk2/IntelFrameworkModulePkg/Bus/Isa/Ps2KeyboardDxe/Ps2Keyboard.c20
-rw-r--r--edk2/IntelFrameworkModulePkg/Bus/Isa/Ps2KeyboardDxe/Ps2keyboardDxe.inf3
-rw-r--r--edk2/IntelFrameworkModulePkg/Csm/BiosThunk/KeyboardDxe/BiosKeyboard.c250
-rw-r--r--edk2/IntelFrameworkModulePkg/Csm/BiosThunk/KeyboardDxe/KeyboardDxe.inf5
-rw-r--r--edk2/IntelFrameworkModulePkg/IntelFrameworkModulePkg.dec10
-rw-r--r--edk2/IntelFrameworkModulePkg/Universal/Acpi/AcpiS3SaveDxe/AcpiS3Save.c2
-rw-r--r--edk2/IntelFrameworkModulePkg/Universal/BdsDxe/Bds.h3
-rw-r--r--edk2/IntelFrameworkModulePkg/Universal/BdsDxe/BdsDxe.inf2
-rw-r--r--edk2/IntelFrameworkModulePkg/Universal/BdsDxe/BdsEntry.c52
-rw-r--r--edk2/IntelFrameworkModulePkg/Universal/BdsDxe/BootMaint/ConsoleOption.c18
-rw-r--r--edk2/IntelFrameworkModulePkg/Universal/BdsDxe/Hotkey.c389
-rw-r--r--edk2/IntelFrameworkModulePkg/Universal/BdsDxe/Hotkey.h37
-rw-r--r--edk2/MdeModulePkg/Bus/Ata/AtaAtapiPassThru/AtaAtapiPassThru.c12
-rw-r--r--edk2/MdeModulePkg/Bus/Ata/AtaBusDxe/AtaBus.c1
-rw-r--r--edk2/MdeModulePkg/Bus/Ata/AtaBusDxe/AtaPassThruExecute.c8
-rw-r--r--edk2/MdeModulePkg/Bus/Pci/PciBusDxe/PciEnumeratorSupport.c12
-rw-r--r--edk2/MdeModulePkg/Bus/Pci/PciBusDxe/PciLib.c8
-rw-r--r--edk2/MdeModulePkg/Bus/Usb/UsbBusDxe/UsbBus.h10
-rw-r--r--edk2/MdeModulePkg/Bus/Usb/UsbBusDxe/UsbHub.c7
-rw-r--r--edk2/MdeModulePkg/Bus/Usb/UsbBusDxe/UsbHub.h4
-rw-r--r--edk2/MdeModulePkg/Core/Dxe/Gcd/Gcd.c4
-rw-r--r--edk2/MdeModulePkg/Core/PiSmmCore/Smi.c10
-rw-r--r--edk2/MdeModulePkg/Include/Library/UdpIoLib.h4
-rw-r--r--edk2/MdeModulePkg/Library/DxeNetLib/DxeNetLib.c10
-rw-r--r--edk2/MdeModulePkg/Library/DxeUdpIoLib/DxeUdpIoLib.c6
-rw-r--r--edk2/MdeModulePkg/Library/PiDxeS3BootScriptLib/BootScriptSave.c8
-rw-r--r--edk2/MdeModulePkg/Universal/Acpi/AcpiTableDxe/Aml.c288
-rw-r--r--edk2/MdeModulePkg/Universal/Acpi/BootScriptExecutorDxe/ScriptExecute.c2
-rw-r--r--edk2/MdeModulePkg/Universal/Console/ConSplitterDxe/ConSplitter.c131
-rw-r--r--edk2/MdeModulePkg/Universal/Console/GraphicsConsoleDxe/GraphicsConsole.c3
-rw-r--r--edk2/MdeModulePkg/Universal/LockBox/SmmLockBox/SmmLockBox.c9
-rw-r--r--edk2/MdeModulePkg/Universal/LockBox/SmmLockBox/SmmLockBox.inf4
-rw-r--r--edk2/MdeModulePkg/Universal/Network/Dhcp4Dxe/Dhcp4Driver.c26
-rw-r--r--edk2/MdeModulePkg/Universal/Network/Dhcp4Dxe/Dhcp4Impl.h14
-rw-r--r--edk2/MdeModulePkg/Universal/Network/Dhcp4Dxe/Dhcp4Io.c6
-rw-r--r--edk2/MdeModulePkg/Universal/Network/Ip4ConfigDxe/Ip4ConfigDriver.c18
-rw-r--r--edk2/MdeModulePkg/Universal/Network/Ip4Dxe/Ip4Driver.c30
-rw-r--r--edk2/MdeModulePkg/Universal/Network/Ip4Dxe/Ip4If.c6
-rw-r--r--edk2/MdeModulePkg/Universal/Network/Ip4Dxe/Ip4If.h4
-rw-r--r--edk2/MdeModulePkg/Universal/Network/Ip4Dxe/Ip4Impl.c4
-rw-r--r--edk2/MdeModulePkg/Universal/Network/Ip4Dxe/Ip4Impl.h16
-rw-r--r--edk2/MdeModulePkg/Universal/Network/Ip4Dxe/Ip4Input.c4
-rw-r--r--edk2/MdeModulePkg/Universal/Network/Mtftp4Dxe/Mtftp4Driver.c24
-rw-r--r--edk2/MdeModulePkg/Universal/Network/Mtftp4Dxe/Mtftp4Driver.h10
-rw-r--r--edk2/MdeModulePkg/Universal/Network/Mtftp4Dxe/Mtftp4Impl.c4
-rw-r--r--edk2/MdeModulePkg/Universal/Network/Mtftp4Dxe/Mtftp4Impl.h8
-rw-r--r--edk2/MdeModulePkg/Universal/Network/Tcp4Dxe/SockImpl.c6
-rw-r--r--edk2/MdeModulePkg/Universal/Network/Tcp4Dxe/SockInterface.c2
-rw-r--r--edk2/MdeModulePkg/Universal/Network/Tcp4Dxe/Socket.h4
-rw-r--r--edk2/MdeModulePkg/Universal/Network/UefiPxeBcDxe/PxeBcDhcp.c4
-rw-r--r--edk2/MdePkg/Include/IndustryStandard/Acpi50.h2
-rw-r--r--edk2/MdePkg/Include/IndustryStandard/DebugPort2Table.h16
-rw-r--r--edk2/MdePkg/Include/IndustryStandard/DebugPortTable.h16
-rw-r--r--edk2/MdePkg/Include/IndustryStandard/Pal.h9
-rw-r--r--edk2/MdePkg/Include/IndustryStandard/SerialPortConsoleRedirectionTable.h6
-rw-r--r--edk2/NetworkPkg/Application/Ping6/Ping6.c8
-rw-r--r--edk2/NetworkPkg/Dhcp6Dxe/Dhcp6Driver.c26
-rw-r--r--edk2/NetworkPkg/Dhcp6Dxe/Dhcp6Impl.h4
-rw-r--r--edk2/NetworkPkg/Dhcp6Dxe/Dhcp6Io.c6
-rw-r--r--edk2/NetworkPkg/IScsiDxe/IScsiIbft.c14
-rw-r--r--edk2/NetworkPkg/IScsiDxe/IScsiImpl.h3
-rw-r--r--edk2/NetworkPkg/IScsiDxe/IScsiMisc.h7
-rw-r--r--edk2/NetworkPkg/IScsiDxe/IScsiProto.c96
-rw-r--r--edk2/NetworkPkg/Ip6Dxe/Ip6ConfigImpl.c6
-rw-r--r--edk2/NetworkPkg/Ip6Dxe/Ip6ConfigImpl.h6
-rw-r--r--edk2/NetworkPkg/Ip6Dxe/Ip6Driver.c20
-rw-r--r--edk2/NetworkPkg/Ip6Dxe/Ip6Driver.h4
-rw-r--r--edk2/NetworkPkg/Ip6Dxe/Ip6If.c4
-rw-r--r--edk2/NetworkPkg/Ip6Dxe/Ip6Impl.c4
-rw-r--r--edk2/NetworkPkg/Ip6Dxe/Ip6Nd.c4
-rw-r--r--edk2/NetworkPkg/Ip6Dxe/Ip6Nd.h4
-rw-r--r--edk2/NetworkPkg/IpSecDxe/IkeCommon.c4
-rw-r--r--edk2/NetworkPkg/IpSecDxe/IkeService.c12
-rw-r--r--edk2/NetworkPkg/IpSecDxe/IpSecDebug.c14
-rw-r--r--edk2/NetworkPkg/IpSecDxe/IpSecDebug.h2
-rw-r--r--edk2/NetworkPkg/Mtftp6Dxe/Mtftp6Driver.c26
-rw-r--r--edk2/NetworkPkg/Mtftp6Dxe/Mtftp6Impl.c22
-rw-r--r--edk2/NetworkPkg/Mtftp6Dxe/Mtftp6Impl.h6
-rw-r--r--edk2/NetworkPkg/Mtftp6Dxe/Mtftp6Rrq.c16
-rw-r--r--edk2/NetworkPkg/TcpDxe/SockImpl.c6
-rw-r--r--edk2/NetworkPkg/TcpDxe/SockInterface.c4
-rw-r--r--edk2/NetworkPkg/TcpDxe/Socket.h4
-rw-r--r--edk2/NetworkPkg/UefiPxeBcDxe/PxeBcDhcp4.c2
-rw-r--r--edk2/NetworkPkg/UefiPxeBcDxe/PxeBcDhcp6.c2
-rw-r--r--edk2/NetworkPkg/UefiPxeBcDxe/PxeBcDriver.c13
-rw-r--r--edk2/NetworkPkg/UefiPxeBcDxe/PxeBcImpl.c9
-rw-r--r--edk2/NetworkPkg/UefiPxeBcDxe/PxeBcImpl.h1
-rw-r--r--edk2/Omap44xxPkg/Flash/Flash.c782
-rw-r--r--edk2/Omap44xxPkg/Flash/Flash.h106
-rw-r--r--edk2/Omap44xxPkg/Flash/Flash.inf48
-rw-r--r--edk2/Omap44xxPkg/Include/Omap4430/Omap4430.h12
-rw-r--r--edk2/Omap44xxPkg/Include/Omap4430/Omap4430I2c.h42
-rw-r--r--edk2/Omap44xxPkg/Include/TWL6030.h (renamed from edk2/Omap44xxPkg/Include/TPS65950.h)28
-rw-r--r--edk2/Omap44xxPkg/InterruptDxe/HardwareInterrupt.c390
-rw-r--r--edk2/Omap44xxPkg/InterruptDxe/InterruptDxe.inf54
-rw-r--r--edk2/Omap44xxPkg/LcdGraphicsOutputDxe/LcdGraphicsOutputDxe.h2
-rw-r--r--edk2/Omap44xxPkg/Library/RealTimeClockLib/RealTimeClockLib.c36
-rw-r--r--edk2/Omap44xxPkg/Library/SerialPortLib/SerialPortLib.c7
-rw-r--r--edk2/Omap44xxPkg/MMCHSDxe/MMCHS.c1504
-rw-r--r--edk2/Omap44xxPkg/MMCHSDxe/MMCHS.h175
-rw-r--r--edk2/Omap44xxPkg/MMCHSDxe/MMCHS.inf54
-rw-r--r--edk2/Omap44xxPkg/MmcHostDxe/MmcHostDxe.c68
-rwxr-xr-xedk2/Omap44xxPkg/MmcHostDxe/MmcHostDxe.h2
-rw-r--r--edk2/Omap44xxPkg/Omap44xxPkg.dsc12
-rw-r--r--edk2/Omap44xxPkg/PciEmulation/PciEmulation.c12
-rw-r--r--edk2/Omap44xxPkg/PciEmulation/PciEmulation.h2
-rw-r--r--edk2/Omap44xxPkg/TWL6030Dxe/TWL6030.c (renamed from edk2/Omap44xxPkg/TPS65950Dxe/TPS65950.c)4
-rw-r--r--edk2/Omap44xxPkg/TWL6030Dxe/TWL6030.inf (renamed from edk2/Omap44xxPkg/TPS65950Dxe/TPS65950.inf)6
-rw-r--r--edk2/OptionRomPkg/UndiRuntimeDxe/Init.c60
-rw-r--r--edk2/OvmfPkg/AcpiTables/Facp.aslc22
-rw-r--r--edk2/OvmfPkg/AcpiTables/Facs.aslc84
-rw-r--r--edk2/OvmfPkg/AcpiTables/Madt.aslc109
-rw-r--r--edk2/OvmfPkg/EmuVariableFvbRuntimeDxe/Fvb.c18
-rw-r--r--edk2/OvmfPkg/Include/IndustryStandard/Virtio.h131
-rw-r--r--edk2/OvmfPkg/Include/IndustryStandard/VirtioBlk.h80
-rw-r--r--edk2/OvmfPkg/Include/IndustryStandard/VirtioScsi.h100
-rw-r--r--edk2/OvmfPkg/Include/Library/VirtioLib.h251
-rw-r--r--edk2/OvmfPkg/Library/AcpiTimerLib/AcpiTimerLib.c82
-rw-r--r--edk2/OvmfPkg/Library/PlatformBdsLib/QemuBootOrder.c100
-rw-r--r--edk2/OvmfPkg/Library/VirtioLib/VirtioLib.c452
-rw-r--r--edk2/OvmfPkg/Library/VirtioLib/VirtioLib.inf36
-rw-r--r--edk2/OvmfPkg/OvmfPkg.dec11
-rw-r--r--edk2/OvmfPkg/OvmfPkgIa32.dsc3
-rw-r--r--edk2/OvmfPkg/OvmfPkgIa32.fdf17
-rw-r--r--edk2/OvmfPkg/OvmfPkgIa32X64.dsc10
-rw-r--r--edk2/OvmfPkg/OvmfPkgIa32X64.fdf17
-rw-r--r--edk2/OvmfPkg/OvmfPkgX64.dsc8
-rw-r--r--edk2/OvmfPkg/OvmfPkgX64.fdf17
-rw-r--r--edk2/OvmfPkg/VirtioBlkDxe/VirtioBlk.c1089
-rw-r--r--edk2/OvmfPkg/VirtioBlkDxe/VirtioBlk.h298
-rw-r--r--edk2/OvmfPkg/VirtioBlkDxe/VirtioBlk.inf42
-rw-r--r--edk2/OvmfPkg/VirtioScsiDxe/VirtioScsi.c1275
-rw-r--r--edk2/OvmfPkg/VirtioScsiDxe/VirtioScsi.h209
-rw-r--r--edk2/OvmfPkg/VirtioScsiDxe/VirtioScsi.inf47
-rw-r--r--[-rwxr-xr-x]edk2/PandaBoardPkg/Debugger_scripts/rvi_convert_symbols.sh0
-rw-r--r--[-rwxr-xr-x]edk2/PandaBoardPkg/Debugger_scripts/rvi_symbols_macros.inc0
-rw-r--r--[-rwxr-xr-x]edk2/PandaBoardPkg/Debugger_scripts/rvi_unload_symbols.inc0
-rw-r--r--edk2/PandaBoardPkg/Debugger_scripts/trace32_load_symbols.cmm2
-rw-r--r--[-rwxr-xr-x]edk2/PandaBoardPkg/Library/PandaBoardLib/PandaBoard.c0
-rw-r--r--[-rwxr-xr-x]edk2/PandaBoardPkg/Library/PandaBoardLib/PandaBoardHelper.S0
-rw-r--r--edk2/PandaBoardPkg/PandaBoardPkg.dsc36
-rw-r--r--edk2/PandaBoardPkg/PandaBoardPkg.fdf56
-rwxr-xr-xedk2/PandaBoardPkg/build.sh1
-rw-r--r--edk2/PandaBoardPkg/readme.txt62
-rw-r--r--edk2/PcAtChipsetPkg/IsaAcpiDxe/IsaAcpi.c4
-rw-r--r--edk2/PcAtChipsetPkg/PciHostBridgeDxe/PciHostBridge.c37
-rw-r--r--edk2/SecurityPkg/Include/Library/TpmCommLib.h3
-rw-r--r--edk2/SecurityPkg/Library/DxeImageVerificationLib/DxeImageVerificationLib.c11
-rw-r--r--edk2/SecurityPkg/Library/TpmCommLib/TisPc.c9
-rw-r--r--edk2/SecurityPkg/Tcg/TcgPei/TcgPei.c13
-rw-r--r--edk2/SecurityPkg/VariableAuthenticated/RuntimeDxe/AuthService.c16
-rw-r--r--edk2/ShellPkg/Application/Shell/Shell.c32
-rw-r--r--edk2/ShellPkg/Library/UefiHandleParsingLib/UefiHandleParsingLib.c281
-rw-r--r--edk2/ShellPkg/Library/UefiShellCommandLib/ConsistMapping.c212
-rw-r--r--edk2/ShellPkg/Library/UefiShellDebug1CommandsLib/Edit/MainTextEditor.c5
-rw-r--r--edk2/ShellPkg/Library/UefiShellDebug1CommandsLib/HexEdit/MainHexEditor.c5
-rw-r--r--edk2/ShellPkg/Library/UefiShellDriver1CommandsLib/DevTree.c54
-rw-r--r--edk2/ShellPkg/Library/UefiShellDriver1CommandsLib/Dh.c14
-rw-r--r--edk2/ShellPkg/Library/UefiShellDriver1CommandsLib/Disconnect.c6
-rw-r--r--edk2/ShellPkg/Library/UefiShellDriver1CommandsLib/OpenInfo.c10
-rw-r--r--edk2/ShellPkg/Library/UefiShellDriver1CommandsLib/UefiShellDriver1CommandsLib.unibin70094 -> 70090 bytes
-rw-r--r--edk2/ShellPkg/Library/UefiShellInstall1CommandsLib/Bcfg.c4
-rw-r--r--edk2/ShellPkg/Library/UefiShellNetwork1CommandsLib/Ifconfig.c2
-rw-r--r--edk2/ShellPkg/Library/UefiShellNetwork1CommandsLib/Ping.c8
-rw-r--r--edk2/SourceLevelDebugPkg/Library/DebugAgent/DebugAgentCommon/DebugMp.c2
-rw-r--r--edk2/SourceLevelDebugPkg/Library/DebugAgent/DxeDebugAgent/SerialIo.c12
-rw-r--r--edk2/StdLib/BsdSocketLib/close.c17
-rw-r--r--edk2/StdLib/EfiSocketLib/DxeSupport.c98
-rw-r--r--edk2/StdLib/EfiSocketLib/Socket.c167
-rw-r--r--edk2/StdLib/EfiSocketLib/Socket.h22
-rw-r--r--edk2/StdLib/EfiSocketLib/UseEfiSocketLib.c34
-rw-r--r--edk2/StdLib/Include/Protocol/EfiSocket.h20
-rw-r--r--edk2/StdLib/LibC/Locale/multibyte_Utf8.c443
-rw-r--r--edk2/StdLib/LibC/Main/Main.c7
-rw-r--r--edk2/StdLib/UseSocketDxe/UseSocketDxe.c53
-rw-r--r--edk2/UefiCpuPkg/CpuDxe/CpuDxe.c2
-rw-r--r--edk2/UefiCpuPkg/Library/MtrrLib/MtrrLib.c6
-rw-r--r--edk2/UnixPkg/Deprecated.txt5
-rwxr-xr-xedk2/UnixPkg/build.sh1
-rwxr-xr-xedk2/UnixPkg/build64.sh1
-rw-r--r--edk2/UnixPkg/readme.txt4
212 files changed, 8370 insertions, 5417 deletions
diff --git a/edk2/ArmPkg/Drivers/ArmCpuLib/ArmCortexA5Lib/ArmCortexA5Lib.c b/edk2/ArmPkg/Drivers/ArmCpuLib/ArmCortexA5Lib/ArmCortexA5Lib.c
index 716a3d0a4..5dc3e6e94 100644
--- a/edk2/ArmPkg/Drivers/ArmCpuLib/ArmCortexA5Lib/ArmCortexA5Lib.c
+++ b/edk2/ArmPkg/Drivers/ArmCpuLib/ArmCortexA5Lib/ArmCortexA5Lib.c
@@ -15,6 +15,8 @@
#include <Base.h>
#include <Library/ArmLib.h>
#include <Library/ArmCpuLib.h>
+#include <Library/ArmV7ArchTimerLib.h>
+#include <Library/DebugLib.h>
#include <Library/IoLib.h>
#include <Library/PcdLib.h>
@@ -33,9 +35,10 @@ ArmCpuSetup (
// If MPCore then Enable the SCU
if (ArmIsMpCore()) {
- // Signals the Cortex-A5 processor is taking part in coherency
+ // Turn on SMP coherency
ArmSetAuxCrBit (A5_FEATURE_SMP);
}
+
}
diff --git a/edk2/ArmPkg/Include/Chipset/ArmCortexA5.h b/edk2/ArmPkg/Include/Chipset/ArmCortexA5.h
index c9122709f..cba2eb3d9 100644
--- a/edk2/ArmPkg/Include/Chipset/ArmCortexA5.h
+++ b/edk2/ArmPkg/Include/Chipset/ArmCortexA5.h
@@ -1,6 +1,6 @@
/** @file
- Copyright (c) 2011, ARM Limited. All rights reserved.
+ Copyright (c) 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
@@ -20,40 +20,6 @@
//
// Cortex A5 feature bit definitions
//
-#define A5_FEATURE_PARITY (1<<9)
-#define A5_FEATURE_AOW (1<<8)
-#define A5_FEATURE_EXCL (1<<7)
#define A5_FEATURE_SMP (1<<6)
-#define A5_FEATURE_FOZ (1<<3)
-#define A5_FEATURE_DPREF (1<<2)
-#define A5_FEATURE_HINT (1<<1)
-#define A5_FEATURE_FWD (1<<0)
-
-//
-// Cortex A5 Watchdog
-//
-#define ARM_A5_WATCHDOG_REGION 0x600
-
-#define ARM_A5_WATCHDOG_LOAD_REGISTER 0x20
-#define ARM_A5_WATCHDOG_CONTROL_REGISTER 0x28
-
-#define ARM_A5_WATCHDOG_WATCHDOG_MODE (1 << 3)
-#define ARM_A5_WATCHDOG_TIMER_MODE (0 << 3)
-#define ARM_A5_WATCHDOG_SINGLE_SHOT (0 << 1)
-#define ARM_A5_WATCHDOG_AUTORELOAD (1 << 1)
-#define ARM_A5_WATCHDOG_ENABLE 1
-
-//
-// SCU register offsets & masks
-//
-#define A5_SCU_CONTROL_OFFSET 0x0
-#define A5_SCU_CONFIG_OFFSET 0x4
-#define A5_SCU_INVALL_OFFSET 0xC
-#define A5_SCU_FILT_START_OFFSET 0x40
-#define AA5SCU_FILT_END_OFFSET 0x44
-#define A5_SCU_SACR_OFFSET 0x50
-#define A5_SCU_SSACR_OFFSET 0x54
-
#endif
-
diff --git a/edk2/ArmPlatformPkg/ArmPlatformPkg.dec b/edk2/ArmPlatformPkg/ArmPlatformPkg.dec
index 3e2900ba3..07205273b 100644
--- a/edk2/ArmPlatformPkg/ArmPlatformPkg.dec
+++ b/edk2/ArmPlatformPkg/ArmPlatformPkg.dec
@@ -135,7 +135,8 @@
# - 2 = a Linux kernel with FDT support
gArmPlatformTokenSpaceGuid.PcdDefaultBootType|0|UINT32|0x00000010
gArmPlatformTokenSpaceGuid.PcdFdtDevicePath|L""|VOID*|0x00000011
-
+ gArmPlatformTokenSpaceGuid.PcdFdtLocalDevicePath|L""|VOID*|0x0000002E
+
## Timeout value for displaying progressing bar in before boot OS.
# According to UEFI 2.0 spec, the default TimeOut should be 0xffff.
gArmPlatformTokenSpaceGuid.PcdPlatformBootTimeOut|0xffff|UINT16|0x0000001A
diff --git a/edk2/ArmPlatformPkg/ArmVExpressPkg/ArmVExpress-CTA15-A7.dsc b/edk2/ArmPlatformPkg/ArmVExpressPkg/ArmVExpress-CTA15-A7.dsc
index 33ff82cc7..963243d8f 100644
--- a/edk2/ArmPlatformPkg/ArmVExpressPkg/ArmVExpress-CTA15-A7.dsc
+++ b/edk2/ArmPlatformPkg/ArmVExpressPkg/ArmVExpress-CTA15-A7.dsc
@@ -30,7 +30,9 @@
BUILD_TARGETS = DEBUG|RELEASE
SKUID_IDENTIFIER = DEFAULT
FLASH_DEFINITION = ArmPlatformPkg/ArmVExpressPkg/ArmVExpress-CTA15-A7.fdf
+!ifndef $(EDK2_SKIP_PEICORE)
DEFINE EDK2_SKIP_PEICORE=1
+!endif
!include ArmPlatformPkg/ArmVExpressPkg/ArmVExpress.dsc.inc
@@ -125,8 +127,8 @@
# A7_0 = 0x100, GicCoreId = 2
# A7_1 = 0x101, GicCoreId = 3
# A7_2 = 0x102, GicCoreId = 4
- gArmTokenSpaceGuid.PcdArmPrimaryCore|0x100
- gArmTokenSpaceGuid.PcdGicPrimaryCoreId|2
+ gArmTokenSpaceGuid.PcdArmPrimaryCore|0
+ gArmTokenSpaceGuid.PcdGicPrimaryCoreId|0
!endif
#
diff --git a/edk2/ArmPlatformPkg/ArmVExpressPkg/ArmVExpress-CTA15x2.dsc b/edk2/ArmPlatformPkg/ArmVExpressPkg/ArmVExpress-CTA15x2.dsc
index 59368e489..d785eb3d8 100644
--- a/edk2/ArmPlatformPkg/ArmVExpressPkg/ArmVExpress-CTA15x2.dsc
+++ b/edk2/ArmPlatformPkg/ArmVExpressPkg/ArmVExpress-CTA15x2.dsc
@@ -30,6 +30,9 @@
BUILD_TARGETS = DEBUG|RELEASE
SKUID_IDENTIFIER = DEFAULT
FLASH_DEFINITION = ArmPlatformPkg/ArmVExpressPkg/ArmVExpress-CTA15x2.fdf
+!ifndef $(EDK2_ARMVE_STANDALONE)
+ DEFINE EDK2_ARMVE_STANDALONE=1
+!endif
!include ArmPlatformPkg/ArmVExpressPkg/ArmVExpress.dsc.inc
@@ -193,7 +196,7 @@
#
# ARM Architectual Timer Frequency
#
- gArmTokenSpaceGuid.PcdArmArchTimerFreqInHz|60000000
+ gArmTokenSpaceGuid.PcdArmArchTimerFreqInHz|600000000
################################################################################
diff --git a/edk2/ArmPlatformPkg/ArmVExpressPkg/ArmVExpress-CTA5s.dsc b/edk2/ArmPlatformPkg/ArmVExpressPkg/ArmVExpress-CTA5s.dsc
index 67756c063..a41680d23 100644
--- a/edk2/ArmPlatformPkg/ArmVExpressPkg/ArmVExpress-CTA5s.dsc
+++ b/edk2/ArmPlatformPkg/ArmVExpressPkg/ArmVExpress-CTA5s.dsc
@@ -30,6 +30,9 @@
BUILD_TARGETS = DEBUG|RELEASE
SKUID_IDENTIFIER = DEFAULT
FLASH_DEFINITION = ArmPlatformPkg/ArmVExpressPkg/ArmVExpress-CTA5s.fdf
+!ifndef $(EDK2_ARMVE_STANDALONE)
+ DEFINE EDK2_ARMVE_STANDALONE=1
+!endif
!include ArmPlatformPkg/ArmVExpressPkg/ArmVExpress.dsc.inc
diff --git a/edk2/ArmPlatformPkg/ArmVExpressPkg/ArmVExpress-CTA9x4.dsc b/edk2/ArmPlatformPkg/ArmVExpressPkg/ArmVExpress-CTA9x4.dsc
index b4040c28f..11eba89d9 100644
--- a/edk2/ArmPlatformPkg/ArmVExpressPkg/ArmVExpress-CTA9x4.dsc
+++ b/edk2/ArmPlatformPkg/ArmVExpressPkg/ArmVExpress-CTA9x4.dsc
@@ -30,6 +30,12 @@
BUILD_TARGETS = DEBUG|RELEASE
SKUID_IDENTIFIER = DEFAULT
FLASH_DEFINITION = ArmPlatformPkg/ArmVExpressPkg/ArmVExpress-CTA9x4.fdf
+!ifndef $(EDK2_ARMVE_STANDALONE)
+ DEFINE EDK2_ARMVE_STANDALONE=1
+!endif
+!ifndef $(EDK2_ARMVE_SINGLE_BINARY)
+ DEFINE EDK2_ARMVE_SINGLE_BINARY=1
+!endif
!include ArmPlatformPkg/ArmVExpressPkg/ArmVExpress.dsc.inc
diff --git a/edk2/ArmPlatformPkg/ArmVExpressPkg/Library/ArmVExpressLibCTA15x2/CTA15x2Boot.S b/edk2/ArmPlatformPkg/ArmVExpressPkg/Library/ArmVExpressLibCTA15x2/CTA15x2Boot.S
index f09d2cf1e..d865d6701 100644
--- a/edk2/ArmPlatformPkg/ArmVExpressPkg/Library/ArmVExpressLibCTA15x2/CTA15x2Boot.S
+++ b/edk2/ArmPlatformPkg/ArmVExpressPkg/Library/ArmVExpressLibCTA15x2/CTA15x2Boot.S
@@ -74,6 +74,23 @@ ASM_PFX(ArmPlatformSecBootMemoryInit):
**/
smc_init:
+ //
+ // Disable loop buffer for A15
+ //
+ MRC p15, 0, r2, c0, c0, 0
+ MOV r1, r2, lsr #4
+ LDR r0, =0xFFF
+ AND r1, r1, r0
+ LDR r0, =0xC0F // See if A15
+ CMP r1, r0
+ BNE smc_init2 // Go if not
+
+ MRC p15, 0, r1, c1, c0, 1 // Read Aux Ctrl Reg
+ ORR r1, r1, #(1 << 1) // Set Bit 1
+ MCR p15, 0, r1, c1, c0, 1 // and write it back
+
+smc_init2:
+
LDR r0, = ARM_VE_SMC_CTRL_BASE
LDR r2, = ARM_VE_SMB_PERIPH_BASE
@@ -141,6 +158,13 @@ smc_init:
LDR r1, = 0x03C00000
STR r1, [r0, #PL350_SMC_DIRECT_CMD_OFFSET]
+ // Set refresh period
+ LDR r1, = 0x1
+ STR r1, [r0, #0x20]
+
+ LDR r1, = 0x1
+ STR r1, [r0, #0x24]
+
// page mode setup for VRAM
LDR r0, = 0x00FFFFFC
ADD r0, r0, r2
@@ -465,6 +489,15 @@ waitloop_14:
LDR r3, =0
STR r3, [r2, #PHY_PTM_SQU_TRAINING]
+ // For Test Chip Change Program architected timer frequency
+ MRC p15, 0, r0, c0, c1, 1 // CPUID_EXT_PFR1
+ LSR r0, r0, #16
+ ANDS r0, r0, #1 // Check generic timer support
+ BEQ exit
+ LDR r0, = 600000000 // 600MHz timer frequency
+ MCR p15, 0, r0, c14, c0, 0 // CNTFRQ
+
+exit:
bx lr
// end of dmc_init
diff --git a/edk2/ArmPlatformPkg/ArmVExpressPkg/Library/ArmVExpressLibCTA5s/ArmVExpressLib.inf b/edk2/ArmPlatformPkg/ArmVExpressPkg/Library/ArmVExpressLibCTA5s/ArmVExpressLib.inf
index 129660417..c368456d2 100644
--- a/edk2/ArmPlatformPkg/ArmVExpressPkg/Library/ArmVExpressLibCTA5s/ArmVExpressLib.inf
+++ b/edk2/ArmPlatformPkg/ArmVExpressPkg/Library/ArmVExpressLibCTA5s/ArmVExpressLib.inf
@@ -46,6 +46,3 @@
gArmTokenSpaceGuid.PcdSystemMemoryBase
gArmTokenSpaceGuid.PcdSystemMemorySize
gArmTokenSpaceGuid.PcdFvBaseAddress
-
- gArmTokenSpaceGuid.PcdArmPrimaryCoreMask
- gArmTokenSpaceGuid.PcdArmPrimaryCore
diff --git a/edk2/ArmPlatformPkg/ArmVExpressPkg/Library/ArmVExpressLibCTA5s/ArmVExpressSecLib.inf b/edk2/ArmPlatformPkg/ArmVExpressPkg/Library/ArmVExpressLibCTA5s/ArmVExpressSecLib.inf
index f0521b95c..cec7bbe8a 100644
--- a/edk2/ArmPlatformPkg/ArmVExpressPkg/Library/ArmVExpressLibCTA5s/ArmVExpressSecLib.inf
+++ b/edk2/ArmPlatformPkg/ArmVExpressPkg/Library/ArmVExpressLibCTA5s/ArmVExpressSecLib.inf
@@ -48,6 +48,3 @@
[FixedPcd]
gArmTokenSpaceGuid.PcdFvBaseAddress
-
- gArmTokenSpaceGuid.PcdArmPrimaryCoreMask
- gArmTokenSpaceGuid.PcdArmPrimaryCore
diff --git a/edk2/ArmPlatformPkg/ArmVExpressPkg/Library/ArmVExpressLibCTA5s/CTA5s.c b/edk2/ArmPlatformPkg/ArmVExpressPkg/Library/ArmVExpressLibCTA5s/CTA5s.c
index 48934cc6d..227f9e62f 100644
--- a/edk2/ArmPlatformPkg/ArmVExpressPkg/Library/ArmVExpressLibCTA5s/CTA5s.c
+++ b/edk2/ArmPlatformPkg/ArmVExpressPkg/Library/ArmVExpressLibCTA5s/CTA5s.c
@@ -51,39 +51,6 @@ ARM_CORE_INFO mVersatileExpressMpCoreInfoCTA5s[] = {
},
};
-// DDR2 timings
-PL341_DMC_CONFIG DDRTimings = {
- .MaxChip = 1,
- .IsUserCfg = FALSE,
- .User0Cfg = 0x7C924924,
- .User2Cfg = (TC_UIOLHXC_VALUE << TC_UIOLHNC_SHIFT) | (TC_UIOLHXC_VALUE << TC_UIOLHPC_SHIFT) | (0x1 << TC_UIOHOCT_SHIFT) | (0x1 << TC_UIOHSTOP_SHIFT),
- .HasQos = FALSE,
- .RefreshPeriod = 0x3D0,
- .CasLatency = 0xA,
- .WriteLatency = 0x3,
- .t_mrd = 0x2,
- .t_ras = 0xC,
- .t_rc = 0xF,
- .t_rcd = 0x104,
- .t_rfc = 0x1022,
- .t_rp = 0x104,
- .t_rrd = 0x2,
- .t_wr = 0x4,
- .t_wtr = 0x2,
- .t_xp = 0x2,
- .t_xsr = 0xC8,
- .t_esr = 0x4,
- .MemoryCfg = DMC_MEMORY_CONFIG_ACTIVE_CHIP_1 | DMC_MEMORY_CONFIG_BURST_4 |
- DMC_MEMORY_CONFIG_ROW_ADDRESS_14 | DMC_MEMORY_CONFIG_COLUMN_ADDRESS_10,
- .MemoryCfg2 = DMC_MEMORY_CFG2_BANK_BITS_3 | DMC_MEMORY_CFG2_MEM_WIDTH_64,
- .MemoryCfg3 = 0x00000001,
- .ChipCfg0 = 0x000180C0,
- .ChipCfg1 = 0x0000FF00,
- .t_faw = 0x00000407,
- .ModeReg = DDR2_MR_BURST_LENGTH_4 | DDR2_MR_CAS_LATENCY_5 | DDR2_MR_WR_CYCLES_3,
- .ExtModeReg = 0x47,
-};
-
/**
Return the current Boot Mode
@@ -111,15 +78,11 @@ ArmPlatformGetBootMode (
in the PEI phase.
**/
-RETURN_STATUS
-ArmPlatformInitialize (
- IN UINTN MpId
+VOID
+ArmPlatformNormalInitialize (
+ VOID
)
{
- if (!IS_PRIMARY_CORE(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
@@ -128,8 +91,6 @@ ArmPlatformInitialize (
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;
}
/**
@@ -143,7 +104,7 @@ ArmPlatformInitializeSystemMemory (
VOID
)
{
- PL341DmcInit(ARM_VE_DMC_BASE, &DDRTimings);
+ // Memory is initialised in CTA5sBoot.S
}
EFI_STATUS
@@ -194,3 +155,16 @@ 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/edk2/ArmPlatformPkg/ArmVExpressPkg/Library/ArmVExpressLibCTA5s/CTA5sBoot.S b/edk2/ArmPlatformPkg/ArmVExpressPkg/Library/ArmVExpressLibCTA5s/CTA5sBoot.S
index f90546ef2..62750bde2 100644
--- a/edk2/ArmPlatformPkg/ArmVExpressPkg/Library/ArmVExpressLibCTA5s/CTA5sBoot.S
+++ b/edk2/ArmPlatformPkg/ArmVExpressPkg/Library/ArmVExpressLibCTA5s/CTA5sBoot.S
@@ -15,6 +15,7 @@
#include <Base.h>
#include <Library/ArmPlatformLib.h>
#include <Drivers/PL35xSmc.h>
+#include <Drivers/PL341Dmc.h>
#include <ArmPlatform.h>
#include <AutoGen.h>
@@ -23,44 +24,8 @@
GCC_ASM_EXPORT(ArmPlatformSecBootAction)
GCC_ASM_EXPORT(ArmPlatformInitializeBootMemory)
-GCC_ASM_IMPORT(PL35xSmcInitialize)
GCC_ASM_EXPORT(ArmPlatformSecBootMemoryInit)
-//
-// For each Chip Select: ChipSelect / SetCycle / SetOpMode
-//
-VersatileExpressSmcConfiguration:
- // NOR Flash 0
- .word PL350_SMC_DIRECT_CMD_ADDR_CS(0)
- .word PL350_SMC_SET_CYCLE_NAND_T_RC(0xA) | PL350_SMC_SET_CYCLE_NAND_T_WC(0x3) | PL350_SMC_SET_CYCLE_NAND_T_REA(0x1) | PL350_SMC_SET_CYCLE_NAND_T_WP(0x7) | PL350_SMC_SET_CYCLE_NAND_T_AR(0x1)
- .word PL350_SMC_SET_OPMODE_MEM_WIDTH_32 | PL350_SMC_SET_OPMODE_SET_RD_BURST_LENGTH_CONT | PL350_SMC_SET_OPMODE_SET_WR_BURST_LENGTH_CONT | PL350_SMC_SET_OPMODE_SET_ADV
-
- // NOR Flash 1
- .word PL350_SMC_DIRECT_CMD_ADDR_CS(4)
- .word PL350_SMC_SET_CYCLE_NAND_T_RC(0xA) | PL350_SMC_SET_CYCLE_NAND_T_WC(0x3) | PL350_SMC_SET_CYCLE_NAND_T_REA(0x1) | PL350_SMC_SET_CYCLE_NAND_T_WP(0x7) | PL350_SMC_SET_CYCLE_NAND_T_AR(0x1)
- .word PL350_SMC_SET_OPMODE_MEM_WIDTH_32 | PL350_SMC_SET_OPMODE_SET_RD_BURST_LENGTH_CONT | PL350_SMC_SET_OPMODE_SET_WR_BURST_LENGTH_CONT | PL350_SMC_SET_OPMODE_SET_ADV
-
- // SRAM
- .word PL350_SMC_DIRECT_CMD_ADDR_CS(2)
- .word PL350_SMC_SET_CYCLE_SRAM_T_RC(0x8) | PL350_SMC_SET_CYCLE_SRAM_T_WC(0x5) | PL350_SMC_SET_CYCLE_SRAM_T_CEOE(0x1) | PL350_SMC_SET_CYCLE_SRAM_T_WP(0x6) | PL350_SMC_SET_CYCLE_SRAM_T_PC(0x1) | PL350_SMC_SET_CYCLE_SRAM_T_TR(0x1)
- .word PL350_SMC_SET_OPMODE_MEM_WIDTH_32 | PL350_SMC_SET_OPMODE_SET_ADV
-
- // Usb/Eth/VRAM
- .word PL350_SMC_DIRECT_CMD_ADDR_CS(3)
- .word PL350_SMC_SET_CYCLE_SRAM_T_RC(0xA) | PL350_SMC_SET_CYCLE_SRAM_T_WC(0xA) | PL350_SMC_SET_CYCLE_SRAM_T_CEOE(0x2) | PL350_SMC_SET_CYCLE_SRAM_T_WP(0x2) | PL350_SMC_SET_CYCLE_SRAM_T_PC(0x3) | PL350_SMC_SET_CYCLE_SRAM_T_TR(0x6)
- .word PL350_SMC_SET_OPMODE_MEM_WIDTH_32 | PL350_SMC_SET_OPMODE_SET_RD_SYNC | PL350_SMC_SET_OPMODE_SET_WR_SYNC
-
- // Memory Mapped Peripherals
- .word PL350_SMC_DIRECT_CMD_ADDR_CS(7)
- .word PL350_SMC_SET_CYCLE_SRAM_T_RC(0x6) | PL350_SMC_SET_CYCLE_SRAM_T_WC(0x5) | PL350_SMC_SET_CYCLE_SRAM_T_CEOE(0x1) | PL350_SMC_SET_CYCLE_SRAM_T_WP(0x2) | PL350_SMC_SET_CYCLE_SRAM_T_PC(0x1) | PL350_SMC_SET_CYCLE_SRAM_T_TR(0x1)
- .word PL350_SMC_SET_OPMODE_MEM_WIDTH_32 | PL350_SMC_SET_OPMODE_SET_RD_SYNC | PL350_SMC_SET_OPMODE_SET_WR_SYNC
-
- // VRAM
- .word PL350_SMC_DIRECT_CMD_ADDR_CS(1)
- .word 0x00049249
- .word PL350_SMC_SET_OPMODE_MEM_WIDTH_32 | PL350_SMC_SET_OPMODE_SET_RD_SYNC | PL350_SMC_SET_OPMODE_SET_WR_SYNC
-VersatileExpressSmcConfigurationEnd:
-
/**
Call at the beginning of the platform boot up
@@ -84,7 +49,8 @@ ASM_PFX(ArmPlatformSecBootAction):
**/
ASM_PFX(ArmPlatformInitializeBootMemory):
- bx lr
+ bx lr
+
/**
Initialize the memory where the initial stacks will reside
@@ -97,43 +63,324 @@ ASM_PFX(ArmPlatformInitializeBootMemory):
**/
ASM_PFX(ArmPlatformSecBootMemoryInit):
- mov r5, lr
-
- //
- // Initialize PL354 SMC
- //
- LoadConstantToReg (ARM_VE_SMC_CTRL_BASE, r1)
- LoadConstantToReg (VersatileExpressSmcConfiguration, r2)
- LoadConstantToReg (VersatileExpressSmcConfigurationEnd, r3)
- blx ASM_PFX(PL35xSmcInitialize)
-
- //
- // Page mode setup for VRAM
- //
- LoadConstantToReg (VRAM_MOTHERBOARD_BASE, r2)
-
- // Read current state
- ldr r0, [r2, #0]
- ldr r0, [r2, #0]
- ldr r0, = 0x00000000
- str r0, [r2, #0]
- ldr r0, [r2, #0]
-
- // Enable page mode
- ldr r0, [r2, #0]
- ldr r0, [r2, #0]
- ldr r0, = 0x00000000
- str r0, [r2, #0]
- LoadConstantToReg (0x00900090, r0)
- str r0, [r2, #0]
-
- // Confirm page mode enabled
- ldr r0, [r2, #0]
- ldr r0, [r2, #0]
- ldr r0, = 0x00000000
- str r0, [r2, #0]
- ldr r0, [r2, #0]
-
- bx r5
+ mov r8, lr
+ bl smc_init
+ bl dmc_init
+ bx r8
+
+
+/**
+ Initialise the Static Memory Controller
+**/
+smc_init:
+
+ //
+ // Disable loop buffer for A15
+ //
+ MRC p15, 0, r2, c0, c0, 0
+ MOV r1, r2, lsr #4
+ LDR r0, =0xFFF
+ AND r1, r1, r0
+ LDR r0, =0xC0F // See if A15
+ CMP r1, r0
+ BNE smc_init2 // Go if not
+
+ MRC p15, 0, r1, c1, c0, 1 // Read Aux Ctrl Reg
+ ORR r1, r1, #(1 << 1) // Set Bit 1
+ MCR p15, 0, r1, c1, c0, 1 // and write it back
+
+smc_init2:
+
+ LDR r0, = ARM_VE_SMC_CTRL_BASE
+ LDR r2, = ARM_VE_SMB_PERIPH_BASE
+
+ // CS0 - NOR0
+ LDR r1, = 0x0002393A
+ STR r1, [r0, #PL350_SMC_SET_CYCLES_OFFSET]
+ LDR r1, = 0x00000AAA
+ STR r1, [r0, #PL350_SMC_SET_OPMODE_OFFSET]
+ LDR r1, = 0x00400000
+ STR r1, [r0, #PL350_SMC_DIRECT_CMD_OFFSET]
+
+ // CS1 - PSRAM
+ LDR r1, = 0x00027158
+ STR r1, [r0, #PL350_SMC_SET_CYCLES_OFFSET]
+ LDR r1, = 0x00000802
+ STR r1, [r0, #PL350_SMC_SET_OPMODE_OFFSET]
+ LDR r1, = 0x00C00000
+ STR r1, [r0, #PL350_SMC_DIRECT_CMD_OFFSET]
+
+ // CS2 - usb, ethernet and vram
+ LDR r1, = 0x000CD2AA
+ STR r1, [r0, #PL350_SMC_SET_CYCLES_OFFSET]
+ LDR r1, = 0x00000046
+ STR r1, [r0, #PL350_SMC_SET_OPMODE_OFFSET]
+ LDR r1, = 0x01400000
+ STR r1, [r0, #PL350_SMC_DIRECT_CMD_OFFSET]
+
+ // CS3 - IOFPGA peripherals
+ LDR r1, = 0x00025156
+ STR r1, [r0, #PL350_SMC_SET_CYCLES_OFFSET]
+ LDR r1, = 0x00000046
+ STR r1, [r0, #PL350_SMC_SET_OPMODE_OFFSET]
+ LDR r1, = 0x01C00000
+ STR r1, [r0, #PL350_SMC_DIRECT_CMD_OFFSET]
+
+ // CS4 - NOR1
+ LDR r1, = 0x0002393A
+ STR r1, [r0, #PL350_SMC_SET_CYCLES_OFFSET]
+ LDR r1, = 0x00000AAA
+ STR r1, [r0, #PL350_SMC_SET_OPMODE_OFFSET]
+ LDR r1, = 0x02400000
+ STR r1, [r0, #PL350_SMC_DIRECT_CMD_OFFSET]
+
+ // CS5 - unused
+ LDR r1, = 0x0002393A
+ STR r1, [r0, #PL350_SMC_SET_CYCLES_OFFSET]
+ LDR r1, = 0x00000AAA
+ STR r1, [r0, #PL350_SMC_SET_OPMODE_OFFSET]
+ LDR r1, = 0x02C00000
+ STR r1, [r0, #PL350_SMC_DIRECT_CMD_OFFSET]
+
+ // CS6 - unused
+ LDR r1, = 0x0002393A
+ STR r1, [r0, #PL350_SMC_SET_CYCLES_OFFSET]
+ LDR r1, = 0x00000AAA
+ STR r1, [r0, #PL350_SMC_SET_OPMODE_OFFSET]
+ LDR r1, = 0x03400000
+ STR r1, [r0, #PL350_SMC_DIRECT_CMD_OFFSET]
+
+ // CS7 - unused
+ LDR r1, = 0x0002393A
+ STR r1, [r0, #PL350_SMC_SET_CYCLES_OFFSET]
+ LDR r1, = 0x00000AAA
+ STR r1, [r0, #PL350_SMC_SET_OPMODE_OFFSET]
+ LDR r1, = 0x03C00000
+ STR r1, [r0, #PL350_SMC_DIRECT_CMD_OFFSET]
+
+ // Set refresh period
+ LDR r1, = 0x1
+ STR r1, [r0, #0x20]
+
+ LDR r1, = 0x1
+ STR r1, [r0, #0x24]
+
+ // page mode setup for VRAM
+ LDR r0, = 0x00FFFFFC
+ ADD r0, r0, r2
+
+ // read current state
+ LDR r1, [r0, #0]
+ LDR r1, [r0, #0]
+ LDR r1, = 0x00000000
+ STR r1, [r0, #0]
+ LDR r1, [r0, #0]
+
+ // enable page mode
+ LDR r1, [r0, #0]
+ LDR r1, [r0, #0]
+ LDR r1, = 0x00000000
+ STR r1, [r0, #0]
+ LDR r1, = 0x00900090
+ STR r1, [r0, #0]
+
+ // confirm page mode enabled
+ LDR r1, [r0, #0]
+ LDR r1, [r0, #0]
+ LDR r1, = 0x00000000
+ STR r1, [r0, #0]
+ LDR r1, [r0, #0]
+
+ BX lr
+ // end of smc_init
+
+
+/**
+ Initialise the PL341 Dynamic Memory Controller (DMC)
+
+ On A15, the PHY needs to be locked before configuring the DMC.
+ After DMC config, the PHY needs to be trained
+**/
+#define SCC_PHY_RESET_REG_OFFSET 0x04
+
+dmc_init:
+
+ LDR r0, = ARM_VE_DMC_BASE
+ LDR r1, = ARM_VE_BOARD_PERIPH_BASE
+
+ // On entry:-
+ // r0 = base address of ssmc controller
+ // r1 = address of system registers
+
+ // Initializes V2P_CA5 dynamic memory controller
+
+ MOV r2, r1
+
+ // set config mode
+ MOV r1, #0x4
+ STR r1, [r0, #DMC_COMMAND_REG]
+
+ // initialise memory controlller
+
+ // refresh period
+ LDR r1, =0x3D0
+ STR r1, [r0, #DMC_REFRESH_PRD_REG]
+
+ // cas latency
+ MOV r1, #0xA
+ STR r1, [r0, #DMC_CAS_LATENCY_REG]
+
+ // write latency
+ MOV r1, #0x3
+ STR r1, [r0, #DMC_WRITE_LATENCY_REG]
+
+ // t_mrd
+ MOV r1, #0x2
+ STR r1, [r0, #DMC_T_MRD_REG]
+
+ // t_ras
+ MOV r1, #0x0C
+ STR r1, [r0, #DMC_T_RAS_REG]
+
+ // t_rc
+ MOV r1, #0x0F
+ STR r1, [r0, #DMC_T_RC_REG]
+
+ // t_rcd
+ LDR r1, =0x00000104
+ STR r1, [r0,#DMC_T_RCD_REG]
+
+ // t_rfc
+ LDR r1, =0x00001022
+ STR r1, [r0, #DMC_T_RFC_REG]
+
+ // t_rp
+ LDR r1, =0x00000104
+ STR r1, [r0, #DMC_T_RP_REG]
+
+ // t_rrd
+ MOV r1, #0x2
+ STR r1, [r0, #DMC_T_RRD_REG]
+
+ // t_wr
+ MOV r1, #0x4
+ STR r1, [r0, #DMC_T_WR_REG]
+
+ // t_wtr
+ MOV r1, #0x2
+ STR r1, [r0, #DMC_T_WTR_REG]
+
+ // t_xp
+ MOV r1, #0x2
+ STR r1, [r0, #DMC_T_XP_REG]
+
+ // t_xsr
+ MOV r1, #0xC8
+ STR r1, [r0, #DMC_T_XSR_REG]
+
+ // t_esr
+ MOV r1, #0x04
+ STR r1, [r0, #DMC_T_ESR_REG]
+
+ // t_faw
+ LDR r1, =0x00000407
+ STR r1, [r0, #DMC_T_FAW_REG]
+
+ // set memory config
+ LDR r1, =0x0001001A
+ STR r1, [r0, #DMC_MEMORY_CONFIG_REG]
+
+ // set memory config 2
+ LDR r1, =0x000000B0
+ STR r1, [r0, #DMC_MEMORY_CFG2_REG]
+
+ // initialise external memory chips
+ // set chip select for chip configuration
+ LDR r1, =0x000180C0
+ STR r1, [r0, #DMC_CHIP_0_CFG_REG]
+
+ // config memories
+
+ // send nop
+ LDR r1, =0x000C0000
+ STR r1, [r0, #DMC_DIRECT_CMD_REG]
+
+ // delay
+ MOV r1, #0
+B1: LDR r3, [r0, #DMC_STATUS_REG] // read status register
+ ADD r1, r1, #1
+ CMP r1, #10
+ BLT B1
+
+ // pre-charge all
+ MOV r1, #0x0
+ STR r1, [r0, #DMC_DIRECT_CMD_REG]
+
+ // delay
+ MOV r1, #0
+B2: LDR r3, [r0, #DMC_STATUS_REG] // read status register
+ ADD r1, r1, #1
+ CMP r1, #10
+ BLT B2
+
+ // set extended mode register 2
+ LDR r1, =0x000A8000
+ STR r1, [r0, #DMC_DIRECT_CMD_REG]
+
+ // set extended mode register 3
+ MOV r1, #0x000B0000
+ STR r1, [r0, #DMC_DIRECT_CMD_REG]
+
+ // set extended mode register
+ LDR r1, =0x00094005
+ STR r1, [r0, #DMC_DIRECT_CMD_REG]
+
+ // set mode register -DLL reset
+ LDR r1, =0x00080552
+ STR r1, [r0, #DMC_DIRECT_CMD_REG]
+
+ // delay
+ MOV r1, #0
+B3: LDR r3, [r0, #DMC_STATUS_REG] // read status register
+ ADD r1, r1, #1
+ CMP r1, #10
+ BLT B3
+
+ // pre-charge all
+ MOV r1, #0x0
+ STR r1, [r0, #DMC_DIRECT_CMD_REG]
+
+ // auto-refresh
+ MOV r1, #0x00040000
+ STR r1, [r0, #DMC_DIRECT_CMD_REG]
+
+ // auto-refresh
+ MOV r1, #0x00040000
+ STR r1, [r0, #DMC_DIRECT_CMD_REG]
+
+ // set mode register
+ LDR r1, =0x00080452
+ STR r1, [r0, #DMC_DIRECT_CMD_REG]
+
+ // set extended mode register - Enable OCD defaults
+ LDR r1, =0x000943C5
+ STR r1, [r0, #DMC_DIRECT_CMD_REG]
+
+ // set extended mode register - OCD Exit
+ LDR r1, =0x00094047
+ STR r1, [r0, #DMC_DIRECT_CMD_REG]
+
+ //----------------------------------------
+ // go command
+ MOV r1, #0x0
+ STR r1, [r0, #DMC_COMMAND_REG]
+ // wait for ready
+B4: LDR r1, [r0,#DMC_STATUS_REG]
+ TST r1,#1
+ BEQ B4
+
+exit:
+ bx lr
+ // end of dmc_init
diff --git a/edk2/ArmPlatformPkg/ArmVExpressPkg/Library/ArmVExpressLibCTA9x4/CTA9x4.c b/edk2/ArmPlatformPkg/ArmVExpressPkg/Library/ArmVExpressLibCTA9x4/CTA9x4.c
index b7e7b3700..986044156 100644
--- a/edk2/ArmPlatformPkg/ArmVExpressPkg/Library/ArmVExpressLibCTA9x4/CTA9x4.c
+++ b/edk2/ArmPlatformPkg/ArmVExpressPkg/Library/ArmVExpressLibCTA9x4/CTA9x4.c
@@ -212,3 +212,11 @@ ArmPlatformGetPlatformPpiList (
*PpiList = gPlatformPpiTable;
}
+UINTN
+ArmPlatformGetCorePosition (
+ IN UINTN MpId
+ )
+{
+ return 1;
+}
+
diff --git a/edk2/ArmPlatformPkg/Bds/Bds.c b/edk2/ArmPlatformPkg/Bds/Bds.c
index 11a76de90..fe463774e 100644
--- a/edk2/ArmPlatformPkg/Bds/Bds.c
+++ b/edk2/ArmPlatformPkg/Bds/Bds.c
@@ -223,8 +223,10 @@ DefineDefaultBootEntries (
ARM_BDS_LOADER_ARGUMENTS* BootArguments;
ARM_BDS_LOADER_TYPE BootType;
EFI_DEVICE_PATH* InitrdPath;
+ EFI_DEVICE_PATH* FdtLocalPath;
UINTN CmdLineSize;
UINTN InitrdSize;
+ UINTN FdtLocalSize;
//
// If Boot Order does not exist then create a default entry
@@ -262,17 +264,21 @@ DefineDefaultBootEntries (
if (BootDevicePath != NULL) {
BootType = (ARM_BDS_LOADER_TYPE)PcdGet32 (PcdDefaultBootType);
- if ((BootType == BDS_LOADER_KERNEL_LINUX_ATAG) || (BootType == BDS_LOADER_KERNEL_LINUX_FDT)) {
+ if ((BootType == BDS_LOADER_KERNEL_LINUX_ATAG) || (BootType == BDS_LOADER_KERNEL_LINUX_GLOBAL_FDT) || (BootType == BDS_LOADER_KERNEL_LINUX_LOCAL_FDT)) {
CmdLineSize = AsciiStrSize ((CHAR8*)PcdGetPtr(PcdDefaultBootArgument));
InitrdPath = EfiDevicePathFromTextProtocol->ConvertTextToDevicePath ((CHAR16*)PcdGetPtr(PcdDefaultBootInitrdPath));
InitrdSize = GetDevicePathSize (InitrdPath);
+ FdtLocalPath = EfiDevicePathFromTextProtocol->ConvertTextToDevicePath ((CHAR16*)PcdGetPtr(PcdFdtLocalDevicePath));
+ FdtLocalSize = GetDevicePathSize (FdtLocalPath);
- BootArguments = (ARM_BDS_LOADER_ARGUMENTS*)AllocatePool (sizeof(ARM_BDS_LOADER_ARGUMENTS) + CmdLineSize + InitrdSize);
+ 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);
} else {
BootArguments = NULL;
}
diff --git a/edk2/ArmPlatformPkg/Bds/Bds.inf b/edk2/ArmPlatformPkg/Bds/Bds.inf
index 164e2ae52..f48879367 100644
--- a/edk2/ArmPlatformPkg/Bds/Bds.inf
+++ b/edk2/ArmPlatformPkg/Bds/Bds.inf
@@ -67,6 +67,7 @@
gArmPlatformTokenSpaceGuid.PcdDefaultBootArgument
gArmPlatformTokenSpaceGuid.PcdDefaultBootType
gArmPlatformTokenSpaceGuid.PcdFdtDevicePath
+ gArmPlatformTokenSpaceGuid.PcdFdtLocalDevicePath
gArmPlatformTokenSpaceGuid.PcdPlatformBootTimeOut
gArmPlatformTokenSpaceGuid.PcdDefaultConInPaths
gArmPlatformTokenSpaceGuid.PcdDefaultConOutPaths
diff --git a/edk2/ArmPlatformPkg/Bds/BdsInternal.h b/edk2/ArmPlatformPkg/Bds/BdsInternal.h
index 1307e2ae6..9bc8229d7 100644
--- a/edk2/ArmPlatformPkg/Bds/BdsInternal.h
+++ b/edk2/ArmPlatformPkg/Bds/BdsInternal.h
@@ -48,16 +48,19 @@
typedef enum {
BDS_LOADER_EFI_APPLICATION = 0,
BDS_LOADER_KERNEL_LINUX_ATAG,
- BDS_LOADER_KERNEL_LINUX_FDT,
+ BDS_LOADER_KERNEL_LINUX_GLOBAL_FDT,
+ BDS_LOADER_KERNEL_LINUX_LOCAL_FDT,
} ARM_BDS_LOADER_TYPE;
typedef struct {
UINT16 CmdLineSize;
UINT16 InitrdSize;
-
+ UINT16 FdtLocalSize;
+
// These following fields have variable length and are packed:
//CHAR8 *CmdLine;
//EFI_DEVICE_PATH_PROTOCOL *InitrdPathList;
+ //EFI_DEVICE_PATH_PROTOCOL *FdtLocalPathList;
} ARM_BDS_LINUX_ARGUMENTS;
typedef union {
diff --git a/edk2/ArmPlatformPkg/Bds/BootMenu.c b/edk2/ArmPlatformPkg/Bds/BootMenu.c
index 3f443fca8..eeea35cd0 100644
--- a/edk2/ArmPlatformPkg/Bds/BootMenu.c
+++ b/edk2/ArmPlatformPkg/Bds/BootMenu.c
@@ -125,9 +125,12 @@ BootMenuAddBootOption (
EFI_DEVICE_PATH_PROTOCOL *DevicePathNode;
EFI_DEVICE_PATH_PROTOCOL *InitrdPathNode;
EFI_DEVICE_PATH_PROTOCOL *InitrdPath;
+ EFI_DEVICE_PATH_PROTOCOL *FdtLocalPathNode;
+ EFI_DEVICE_PATH_PROTOCOL *FdtLocalPath;
UINTN CmdLineSize;
BOOLEAN InitrdSupport;
UINTN InitrdSize;
+ UINTN FdtLocalSize;
Attributes = 0;
SupportedBootDevice = NULL;
@@ -148,7 +151,7 @@ BootMenuAddBootOption (
// Append the Device Path node to the select device path
DevicePath = AppendDevicePathNode (SupportedBootDevice->DevicePathProtocol, (CONST EFI_DEVICE_PATH_PROTOCOL *)DevicePathNode);
- if ((BootType == BDS_LOADER_KERNEL_LINUX_ATAG) || (BootType == BDS_LOADER_KERNEL_LINUX_FDT)) {
+ if ((BootType == BDS_LOADER_KERNEL_LINUX_ATAG) || (BootType == BDS_LOADER_KERNEL_LINUX_GLOBAL_FDT) || (BootType == BDS_LOADER_KERNEL_LINUX_LOCAL_FDT)) {
Print(L"Add an initrd: ");
Status = GetHIInputBoolean (&InitrdSupport);
if (EFI_ERROR(Status)) {
@@ -181,15 +184,36 @@ BootMenuAddBootOption (
goto FREE_DEVICE_PATH;
}
+ if (BootType == BDS_LOADER_KERNEL_LINUX_LOCAL_FDT) {
+ // Create the specific device path node
+ Status = SupportedBootDevice->Support->CreateDevicePathNode (L"local FDT", &FdtLocalPathNode, 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;
+ }
+
+ if (FdtLocalPathNode != NULL) {
+ // Append the Device Path node to the select device path
+ FdtLocalPath = AppendDevicePathNode (SupportedBootDevice->DevicePathProtocol, (CONST EFI_DEVICE_PATH_PROTOCOL *)FdtLocalPathNode);
+ } else {
+ FdtLocalPath = NULL;
+ }
+ } else {
+ FdtLocalPath = NULL;
+ }
+
CmdLineSize = AsciiStrSize (CmdLine);
InitrdSize = GetDevicePathSize (InitrdPath);
+ FdtLocalSize = GetDevicePathSize (FdtLocalPath);
- BootArguments = (ARM_BDS_LOADER_ARGUMENTS*)AllocatePool (sizeof(ARM_BDS_LOADER_ARGUMENTS) + CmdLineSize + InitrdSize);
+ 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);
} else {
BootArguments = NULL;
}
@@ -264,7 +288,7 @@ BootMenuSelectBootOption (
Print(L"\t- %s\n",DevicePathTxt);
OptionalData = BdsLoadOption->OptionalData;
LoaderType = (ARM_BDS_LOADER_TYPE)ReadUnaligned32 ((CONST UINT32*)&OptionalData->Header.LoaderType);
- if ((LoaderType == BDS_LOADER_KERNEL_LINUX_ATAG) || (LoaderType == BDS_LOADER_KERNEL_LINUX_FDT)) {
+ if ((LoaderType == BDS_LOADER_KERNEL_LINUX_ATAG) || (LoaderType == BDS_LOADER_KERNEL_LINUX_GLOBAL_FDT) || (LoaderType == BDS_LOADER_KERNEL_LINUX_LOCAL_FDT)) {
Print (L"\t- Arguments: %a\n",&OptionalData->Arguments.LinuxArguments + 1);
}
@@ -356,14 +380,19 @@ BootMenuUpdateBootOption (
CHAR8 CmdLine[BOOT_DEVICE_OPTION_MAX];
EFI_DEVICE_PATH *DevicePath;
EFI_DEVICE_PATH *TempInitrdPath;
+ EFI_DEVICE_PATH *TempFdtLocalPath;
ARM_BDS_LOADER_TYPE BootType;
ARM_BDS_LOADER_OPTIONAL_DATA* OptionalData;
ARM_BDS_LINUX_ARGUMENTS* LinuxArguments;
EFI_DEVICE_PATH *InitrdPathNode;
EFI_DEVICE_PATH *InitrdPath;
UINTN InitrdSize;
+ EFI_DEVICE_PATH *FdtLocalPathNode;
+ EFI_DEVICE_PATH *FdtLocalPath;
+ UINTN FdtLocalSize;
UINTN CmdLineSize;
BOOLEAN InitrdSupport;
+ BOOLEAN FdtLocalSupport;
Status = BootMenuSelectBootOption (BootOptionsList, UPDATE_BOOT_ENTRY, TRUE, &BootOptionEntry);
if (EFI_ERROR(Status)) {
@@ -387,7 +416,7 @@ BootMenuUpdateBootOption (
OptionalData = BootOption->OptionalData;
BootType = (ARM_BDS_LOADER_TYPE)ReadUnaligned32 ((UINT32 *)(&OptionalData->Header.LoaderType));
- if ((BootType == BDS_LOADER_KERNEL_LINUX_ATAG) || (BootType == BDS_LOADER_KERNEL_LINUX_FDT)) {
+ if ((BootType == BDS_LOADER_KERNEL_LINUX_ATAG) || (BootType == BDS_LOADER_KERNEL_LINUX_GLOBAL_FDT) || (BootType == BDS_LOADER_KERNEL_LINUX_LOCAL_FDT)) {
LinuxArguments = &OptionalData->Arguments.LinuxArguments;
CmdLineSize = ReadUnaligned16 ((CONST UINT16*)&LinuxArguments->CmdLineSize);
@@ -451,13 +480,65 @@ BootMenuUpdateBootOption (
goto FREE_DEVICE_PATH;
}
+ FdtLocalSize = ReadUnaligned16 ((CONST UINT16*)&LinuxArguments->FdtLocalSize);
+ if (BootType == BDS_LOADER_KERNEL_LINUX_LOCAL_FDT) {
+ if (FdtLocalSize > 0) {
+ Print(L"Keep the local FDT: ");
+ } else {
+ Print(L"Add a local FDT: ");
+ }
+ Status = GetHIInputBoolean (&FdtLocalSupport);
+ if (EFI_ERROR(Status)) {
+ Status = EFI_ABORTED;
+ goto EXIT;
+ }
+ if (FdtLocalSupport && BootType == BDS_LOADER_KERNEL_LINUX_LOCAL_FDT) {
+ if (FdtLocalSize > 0) {
+ // Case we update the FDT local device path
+ Status = DeviceSupport->UpdateDevicePathNode ((EFI_DEVICE_PATH*)((UINTN)(LinuxArguments + 1) + CmdLineSize + InitrdSize), L"local FDT", &FdtLocalPath, NULL, NULL);
+ if (EFI_ERROR(Status) && Status != EFI_NOT_FOUND) {// EFI_NOT_FOUND is returned on empty input string
+ Status = EFI_ABORTED;
+ goto EXIT;
+ }
+ FdtLocalSize = GetDevicePathSize (FdtLocalPath);
+ } else {
+ // Case we create the FdtLocal device path
+
+ Status = DeviceSupport->CreateDevicePathNode (L"local FDT", &FdtLocalPathNode, NULL, NULL);
+ if (EFI_ERROR(Status) && Status != EFI_NOT_FOUND) { // EFI_NOT_FOUND is returned on empty input string
+ Status = EFI_ABORTED;
+ goto EXIT;
+ }
+
+ 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);
+ } else {
+ FdtLocalPath = NULL;
+ }
+ }
+ } else {
+ FdtLocalSize = 0;
+ }
+ } else {
+ FdtLocalSupport = FALSE;
+ }
+
CmdLineSize = AsciiStrSize (CmdLine);
- BootArguments = (ARM_BDS_LOADER_ARGUMENTS*)AllocatePool(sizeof(ARM_BDS_LOADER_ARGUMENTS) + CmdLineSize + InitrdSize);
+ 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);
} else {
BootArguments = NULL;
}
@@ -613,6 +694,9 @@ BootMenuMain (
UINTN Index;
UINTN BootMainEntryCount;
CHAR8 BootOptionSelectedStr[32];
+ EFI_DEVICE_PATH_PROTOCOL* DefaultFdtDevicePath;
+ UINTN FdtDevicePathSize;
+
BootOption = NULL;
BootMainEntryCount = sizeof(BootMainEntries) / sizeof(struct BOOT_MAIN_ENTRY);
@@ -633,45 +717,94 @@ 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;
- ARM_BDS_LOADER_TYPE LoaderType;
-
- Status = gBS->LocateProtocol (&gEfiDevicePathToTextProtocolGuid, NULL, (VOID **)&DevicePathToTextProtocol);
- if (EFI_ERROR(Status)) {
- // You must provide an implementation of DevicePathToTextProtocol in your firmware (eg: DevicePathDxe)
- DEBUG((EFI_D_ERROR,"Error: Bds requires DevicePathToTextProtocol\n"));
- return Status;
- }
- DevicePathTxt = DevicePathToTextProtocol->ConvertDevicePathToText (BootOption->FilePathList, TRUE, TRUE);
-
- Print(L"\t- %s\n",DevicePathTxt);
-
- // If it is a supported BootEntry then print its details
- if (IS_ARM_BDS_BOOTENTRY (BootOption)) {
- OptionalData = BootOption->OptionalData;
- LoaderType = (ARM_BDS_LOADER_TYPE)ReadUnaligned32 ((CONST UINT32*)&OptionalData->Header.LoaderType);
- if ((LoaderType == BDS_LOADER_KERNEL_LINUX_ATAG) || (LoaderType == BDS_LOADER_KERNEL_LINUX_FDT)) {
- if (ReadUnaligned16 (&OptionalData->Arguments.LinuxArguments.InitrdSize) > 0) {
- CmdLineSize = ReadUnaligned16 (&OptionalData->Arguments.LinuxArguments.CmdLineSize);
- DevicePathTxt = DevicePathToTextProtocol->ConvertDevicePathToText (
- GetAlignedDevicePath ((EFI_DEVICE_PATH*)((UINTN)(&OptionalData->Arguments.LinuxArguments + 1) + CmdLineSize)), TRUE, TRUE);
- Print(L"\t- Initrd: %s\n", DevicePathTxt);
- }
- Print(L"\t- Arguments: %a\n", (&OptionalData->Arguments.LinuxArguments + 1));
+ CHAR16* DevicePathTxt;
+ EFI_DEVICE_PATH_TO_TEXT_PROTOCOL* DevicePathToTextProtocol;
+ ARM_BDS_LOADER_OPTIONAL_DATA* OptionalData;
+ UINTN CmdLineSize;
+ UINTN InitrdSize;
+ ARM_BDS_LOADER_TYPE LoaderType;
+
+ Status = gBS->LocateProtocol (&gEfiDevicePathToTextProtocolGuid, NULL, (VOID **)&DevicePathToTextProtocol);
+ if (EFI_ERROR(Status)) {
+ // You must provide an implementation of DevicePathToTextProtocol in your firmware (eg: DevicePathDxe)
+ DEBUG((EFI_D_ERROR,"Error: Bds requires DevicePathToTextProtocol\n"));
+ return Status;
+ }
+ DevicePathTxt = DevicePathToTextProtocol->ConvertDevicePathToText (BootOption->FilePathList, TRUE, TRUE);
+
+ Print(L"\t- %s\n",DevicePathTxt);
+
+ // If it is a supported BootEntry then print its details
+ if (IS_ARM_BDS_BOOTENTRY (BootOption)) {
+ OptionalData = BootOption->OptionalData;
+ LoaderType = (ARM_BDS_LOADER_TYPE)ReadUnaligned32 ((CONST UINT32*)&OptionalData->Header.LoaderType);
+ if ((LoaderType == BDS_LOADER_KERNEL_LINUX_ATAG) || (LoaderType == BDS_LOADER_KERNEL_LINUX_GLOBAL_FDT) || (LoaderType == BDS_LOADER_KERNEL_LINUX_LOCAL_FDT)) {
+ if (ReadUnaligned16 (&OptionalData->Arguments.LinuxArguments.InitrdSize) > 0) {
+ CmdLineSize = ReadUnaligned16 (&OptionalData->Arguments.LinuxArguments.CmdLineSize);
+ DevicePathTxt = DevicePathToTextProtocol->ConvertDevicePathToText (
+ GetAlignedDevicePath ((EFI_DEVICE_PATH*)((UINTN)(&OptionalData->Arguments.LinuxArguments + 1) + CmdLineSize)), TRUE, TRUE);
+ Print(L"\t- Initrd: %s\n", DevicePathTxt);
}
- Print(L"\t- LoaderType: %d\n", LoaderType);
+ Print(L"\t- Arguments: %a\n", (&OptionalData->Arguments.LinuxArguments + 1));
}
- FreePool(DevicePathTxt);
- DEBUG_CODE_END();
+
+ switch (LoaderType) {
+ case BDS_LOADER_EFI_APPLICATION:
+ Print(L"\t- LoaderType: EFI Application\n");
+ break;
+ case BDS_LOADER_KERNEL_LINUX_ATAG:
+ Print(L"\t- LoaderType: Linux kernel with ATAG data\n");
+ break;
+ case BDS_LOADER_KERNEL_LINUX_GLOBAL_FDT:
+ Print(L"\t- LoaderType: Linux kernel with global FDT\n");
+ break;
+ case BDS_LOADER_KERNEL_LINUX_LOCAL_FDT:
+ if (ReadUnaligned16 (&OptionalData->Arguments.LinuxArguments.FdtLocalSize) > 0) {
+ CmdLineSize = ReadUnaligned16 (&OptionalData->Arguments.LinuxArguments.CmdLineSize);
+ InitrdSize = ReadUnaligned16 (&OptionalData->Arguments.LinuxArguments.InitrdSize);
+ DevicePathTxt = DevicePathToTextProtocol->ConvertDevicePathToText (
+ GetAlignedDevicePath ((EFI_DEVICE_PATH*)((UINTN)(&OptionalData->Arguments.LinuxArguments + 1) + CmdLineSize + InitrdSize)), TRUE, TRUE);
+ Print(L"\t- FDT: %s\n", DevicePathTxt);
+ } else {
+ Print(L"\t- FDT: error, local FDT not specified, using global FDT\n");
+ }
+ Print(L"\t- LoaderType: Linux kernel with Local FDT\n");
+ break;
+ default:
+ Print(L"unknown\n");
+ break;
+ }
+ }
+ FreePool(DevicePathTxt);
OptionCount++;
}
BootOptionCount = OptionCount-1;
+ // 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;
+
+ // 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", DefaultFdtDevicePath, &FdtDevicePathSize, (VOID **)&FdtDevicePath);
+ ASSERT_EFI_ERROR(Status);
+
+ // Convert FdtDevicePath to text
+ Status = gBS->LocateProtocol (&gEfiDevicePathToTextProtocolGuid, NULL, (VOID **)&DevicePathToTextProtocol);
+ DevicePathTxt = DevicePathToTextProtocol->ConvertDevicePathToText ( FdtDevicePath, TRUE, TRUE );
+ Print(L"Global FDT Config\n\t- %s\n", DevicePathTxt);
+ }
+
// Display the hardcoded Boot entries
Print(L"-----------------------\n");
for (Index = 0; Index < BootMainEntryCount; Index++) {
diff --git a/edk2/ArmPlatformPkg/Bds/BootOption.c b/edk2/ArmPlatformPkg/Bds/BootOption.c
index 289d36a50..df0a23223 100644
--- a/edk2/ArmPlatformPkg/Bds/BootOption.c
+++ b/edk2/ArmPlatformPkg/Bds/BootOption.c
@@ -32,6 +32,7 @@ BootOptionStart (
UINTN CmdLineSize;
UINTN InitrdSize;
EFI_DEVICE_PATH* Initrd;
+ UINTN FdtLocalSize;
UINT16 LoadOptionIndexSize;
if (IS_ARM_BDS_BOOTENTRY (BootOption)) {
@@ -58,7 +59,7 @@ BootOptionStart (
Status = BdsBootLinuxAtag (BootOption->FilePathList,
Initrd, // Initrd
(CHAR8*)(LinuxArguments + 1)); // CmdLine
- } else if (LoaderType == BDS_LOADER_KERNEL_LINUX_FDT) {
+ } else if ((LoaderType == BDS_LOADER_KERNEL_LINUX_GLOBAL_FDT) || (LoaderType == BDS_LOADER_KERNEL_LINUX_LOCAL_FDT)) {
LinuxArguments = &(OptionalData->Arguments.LinuxArguments);
CmdLineSize = ReadUnaligned16 ((CONST UINT16*)&LinuxArguments->CmdLineSize);
InitrdSize = ReadUnaligned16 ((CONST UINT16*)&LinuxArguments->InitrdSize);
@@ -69,15 +70,25 @@ BootOptionStart (
Initrd = NULL;
}
- // 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", DefaultFdtDevicePath, &FdtDevicePathSize, (VOID **)&FdtDevicePath);
- ASSERT_EFI_ERROR(Status);
+ if (LoaderType == BDS_LOADER_KERNEL_LINUX_LOCAL_FDT) {
+ FdtLocalSize = ReadUnaligned16 ((CONST UINT16*)&LinuxArguments->FdtLocalSize);
+
+ if (FdtLocalSize > 0) {
+ FdtDevicePath = GetAlignedDevicePath ((EFI_DEVICE_PATH*)((UINTN)(LinuxArguments + 1) + CmdLineSize + InitrdSize));
+ } else {
+ FdtDevicePath = NULL;
+ }
+ } else {
+ // 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", DefaultFdtDevicePath, &FdtDevicePathSize, (VOID **)&FdtDevicePath);
+ ASSERT_EFI_ERROR(Status);
+ }
Status = BdsBootLinuxFdt (BootOption->FilePathList,
Initrd, // Initrd
@@ -157,6 +168,7 @@ BootOptionSetFields (
UINT16 FilePathListLength;
UINT8* EfiLoadOptionPtr;
UINT8* InitrdPathListPtr;
+ UINT8* FdtLocalPathListPtr;
UINTN OptionalDataSize;
ARM_BDS_LINUX_ARGUMENTS* DestLinuxArguments;
ARM_BDS_LINUX_ARGUMENTS* SrcLinuxArguments;
@@ -168,8 +180,8 @@ BootOptionSetFields (
BootDescriptionSize = StrSize (BootDescription);
BootOptionalDataSize = sizeof(ARM_BDS_LOADER_OPTIONAL_DATA_HEADER);
- if ((BootType == BDS_LOADER_KERNEL_LINUX_ATAG) || (BootType == BDS_LOADER_KERNEL_LINUX_FDT)) {
- BootOptionalDataSize += sizeof(ARM_BDS_LINUX_ARGUMENTS) + BootArguments->LinuxArguments.CmdLineSize + BootArguments->LinuxArguments.InitrdSize;
+ if ((BootType == BDS_LOADER_KERNEL_LINUX_ATAG) || (BootType == BDS_LOADER_KERNEL_LINUX_GLOBAL_FDT) || (BootType == BDS_LOADER_KERNEL_LINUX_LOCAL_FDT)) {
+ BootOptionalDataSize += sizeof(ARM_BDS_LINUX_ARGUMENTS) + BootArguments->LinuxArguments.CmdLineSize + BootArguments->LinuxArguments.InitrdSize + BootArguments->LinuxArguments.FdtLocalSize;
}
// Compute the size of the FilePath list
@@ -211,12 +223,13 @@ BootOptionSetFields (
OptionalDataSize = sizeof(ARM_BDS_LOADER_OPTIONAL_DATA_HEADER);
- if ((BootType == BDS_LOADER_KERNEL_LINUX_ATAG) || (BootType == BDS_LOADER_KERNEL_LINUX_FDT)) {
+ if ((BootType == BDS_LOADER_KERNEL_LINUX_ATAG) || (BootType == BDS_LOADER_KERNEL_LINUX_GLOBAL_FDT) || (BootType == BDS_LOADER_KERNEL_LINUX_LOCAL_FDT)) {
SrcLinuxArguments = &(BootArguments->LinuxArguments);
DestLinuxArguments = &((ARM_BDS_LOADER_OPTIONAL_DATA*)EfiLoadOptionPtr)->Arguments.LinuxArguments;
WriteUnaligned16 ((UINT16 *)&(DestLinuxArguments->CmdLineSize), SrcLinuxArguments->CmdLineSize);
WriteUnaligned16 ((UINT16 *)&(DestLinuxArguments->InitrdSize), SrcLinuxArguments->InitrdSize);
+ WriteUnaligned16 ((UINT16 *)&(DestLinuxArguments->FdtLocalSize), SrcLinuxArguments->FdtLocalSize);
OptionalDataSize += sizeof (ARM_BDS_LINUX_ARGUMENTS);
if (SrcLinuxArguments->CmdLineSize > 0) {
@@ -228,6 +241,11 @@ BootOptionSetFields (
InitrdPathListPtr = (UINT8*)((UINTN)(DestLinuxArguments + 1) + SrcLinuxArguments->CmdLineSize);
CopyMem (InitrdPathListPtr, (VOID*)((UINTN)(SrcLinuxArguments + 1) + SrcLinuxArguments->CmdLineSize), SrcLinuxArguments->InitrdSize);
}
+
+ if (SrcLinuxArguments->FdtLocalSize > 0) {
+ FdtLocalPathListPtr = (UINT8*)((UINTN)(DestLinuxArguments + 1) + SrcLinuxArguments->CmdLineSize + SrcLinuxArguments->InitrdSize);
+ CopyMem (FdtLocalPathListPtr, (VOID*)((UINTN)(SrcLinuxArguments + 1) + SrcLinuxArguments->CmdLineSize + SrcLinuxArguments->InitrdSize), SrcLinuxArguments->FdtLocalSize);
+ }
}
BootOption->OptionalDataSize = OptionalDataSize;
diff --git a/edk2/ArmPlatformPkg/Bds/BootOptionSupport.c b/edk2/ArmPlatformPkg/Bds/BootOptionSupport.c
index fbdd5947d..897786f5a 100644
--- a/edk2/ArmPlatformPkg/Bds/BootOptionSupport.c
+++ b/edk2/ArmPlatformPkg/Bds/BootOptionSupport.c
@@ -233,7 +233,7 @@ BootDeviceGetType (
EFI_STATUS Status;
BOOLEAN IsEfiApp;
BOOLEAN IsBootLoader;
- BOOLEAN HasFDTSupport;
+ CHAR16 FDTType[16];
if (FileName == NULL) {
Print(L"Is an EFI Application? ");
@@ -258,16 +258,20 @@ BootDeviceGetType (
}
*BootType = BDS_LOADER_EFI_APPLICATION;
} else {
- Print(L"Has FDT support? ");
- Status = GetHIInputBoolean (&HasFDTSupport);
+ Print(L"Boot Type: [a] ATAGS, [g] Global FDT or [l] Local FDT? [a/g/l] ");
+ Status = GetHIInputStr (FDTType, 16);
if (EFI_ERROR(Status)) {
return EFI_ABORTED;
}
- if (HasFDTSupport) {
- *BootType = BDS_LOADER_KERNEL_LINUX_FDT;
- } else {
+ if (StrCmp(FDTType, L"g") == 0) {
+ *BootType = BDS_LOADER_KERNEL_LINUX_GLOBAL_FDT;
+ } else if (StrCmp(FDTType, L"l") == 0) {
+ *BootType = BDS_LOADER_KERNEL_LINUX_LOCAL_FDT;
+ } else if (StrCmp(FDTType, L"a") == 0) {
*BootType = BDS_LOADER_KERNEL_LINUX_ATAG;
- }
+ } else {
+ return EFI_ABORTED;
+ }
}
return EFI_SUCCESS;
diff --git a/edk2/ArmPlatformPkg/Documentation/patches/BaseTools-Pending-Patches.patch b/edk2/ArmPlatformPkg/Documentation/patches/BaseTools-Pending-Patches.patch
index f7dceb62b..fd916602c 100755
--- a/edk2/ArmPlatformPkg/Documentation/patches/BaseTools-Pending-Patches.patch
+++ b/edk2/ArmPlatformPkg/Documentation/patches/BaseTools-Pending-Patches.patch
@@ -1,158 +1,93 @@
-From c23ebebbcd3ee992017d4aad70e523ea7252c884 Mon Sep 17 00:00:00 2001
-From: Olivier Martin <olivier.martin@arm.com>
-Date: Tue, 6 Dec 2011 16:26:30 +0000
-Subject: [PATCH] BaseTools: Pending patches update
-
-Add patch:
-- ARMLINUXGCC: Set the linked base address at 0x0 (0x8000 by default)
----
- BaseTools/Conf/tools_def.template | 2 +-
- BaseTools/Source/C/GenFv/GenFv.c | 7 +---
- BaseTools/Source/C/GenFv/GenFvInternalLib.c | 48 +++++++++++---------------
- 3 files changed, 22 insertions(+), 35 deletions(-)
- mode change 100644 => 100755 BaseTools/Conf/tools_def.template
-
-diff --git a/BaseTools/Conf/tools_def.template b/BaseTools/Conf/tools_def.template
-old mode 100644
-new mode 100755
-index ee7e23e..68caf86
---- a/BaseTools/Conf/tools_def.template
-+++ b/BaseTools/Conf/tools_def.template
-@@ -4320,7 +4320,7 @@ RELEASE_ARMLINUXGCC_ARM_ASM_FLAGS = $(ARCHASM_FLAGS) $(PLATFORM_FLAGS) -mlittl
- *_ARMLINUXGCC_ARM_VFRPP_FLAGS = $(ARCHCC_FLAGS) $(PLATFORM_FLAGS) -x c -E -P -DVFRCOMPILE --include $(DEST_DIR_DEBUG)/$(MODULE_NAME)StrDefs.h
+Index: BaseTools/Conf/tools_def.template
+===================================================================
+--- BaseTools/Conf/tools_def.template (revision 13864)
++++ BaseTools/Conf/tools_def.template (working copy)
+@@ -2541,7 +2541,7 @@
+ DEFINE GCC_IA32_CC_FLAGS = DEF(GCC_ALL_CC_FLAGS) -m32 -malign-double -freorder-blocks -freorder-blocks-and-partition -O2 -mno-stack-arg-probe
+ DEFINE GCC_X64_CC_FLAGS = DEF(GCC_ALL_CC_FLAGS) -mno-red-zone -Wno-address -mno-stack-arg-probe
+ DEFINE GCC_IPF_CC_FLAGS = DEF(GCC_ALL_CC_FLAGS) -minline-int-divide-min-latency
+-DEFINE GCC_ARMGCC_CC_FLAGS = DEF(GCC_ALL_CC_FLAGS) -mword-relocations -mlittle-endian -mabi=aapcs -mapcs -fno-short-enums -save-temps -fsigned-char -ffunction-sections -fdata-sections -fomit-frame-pointer
++DEFINE GCC_ARMGCC_CC_FLAGS = DEF(GCC_ALL_CC_FLAGS) -mword-relocations -mlittle-endian -mabi=aapcs -mapcs -fno-short-enums -save-temps -fsigned-char -ffunction-sections -fdata-sections -fomit-frame-pointer -Wno-address
+ DEFINE GCC_DLINK_FLAGS_COMMON = -nostdlib --pie
+ DEFINE GCC_IA32_X64_DLINK_COMMON = DEF(GCC_DLINK_FLAGS_COMMON) --gc-sections
+ DEFINE GCC_IA32_X64_ASLDLINK_FLAGS = DEF(GCC_IA32_X64_DLINK_COMMON) --entry _ReferenceAcpiTable -u $(IMAGE_ENTRY_POINT)
+@@ -4628,7 +4628,8 @@
+ #
+ ####################################################################################
- *_ARMLINUXGCC_ARM_SLINK_FLAGS = -rc
--*_ARMLINUXGCC_ARM_DLINK_FLAGS = $(ARCHDLINK_FLAGS) --oformat=elf32-littlearm --emit-relocs -nostdlib -u $(IMAGE_ENTRY_POINT) -e $(IMAGE_ENTRY_POINT) -Map $(DEST_DIR_DEBUG)/$(BASE_NAME).map
-+*_ARMLINUXGCC_ARM_DLINK_FLAGS = $(ARCHDLINK_FLAGS) -Ttext=0x0 --oformat=elf32-littlearm --emit-relocs -nostdlib -u $(IMAGE_ENTRY_POINT) -e $(IMAGE_ENTRY_POINT) -Map $(DEST_DIR_DEBUG)/$(BASE_NAME).map
+-DEFINE RVCT_ALL_CC_FLAGS = --c90 -c --no_autoinline --asm --gnu --apcs /interwork --signed_chars --no_unaligned_access --split_sections --enum_is_int --preinclude AutoGen.h --diag_warning 167 --diag_style=ide
++DEFINE RVCT_ALL_ASM_FLAGS = --diag_suppress=1786 --diag_error=warning --apcs /interwork
++DEFINE RVCT_ALL_CC_FLAGS = --c90 -c --no_autoinline --asm --gnu --apcs /interwork --signed_chars --no_unaligned_access --split_sections --enum_is_int --preinclude AutoGen.h --diag_suppress=186 --diag_warning 167 --diag_error=warning --diag_style=ide
+ DEFINE RVCT_ALL_DLINK_FLAGS = --ro-base 0 --no_scanlib --reloc --no_exceptions --datacompressor off --strict --symbols --diag_style=ide
+
+ ####################################################################################
+@@ -4652,13 +4653,13 @@
+ RELEASE_RVCT_ARM_DLINK_FLAGS = $(ARCHDLINK_FLAGS) DEF(RVCT_ALL_DLINK_FLAGS) --entry $(IMAGE_ENTRY_POINT) --map --list $(DEST_DIR_DEBUG)/$(BASE_NAME).map
- DEBUG_ARMLINUXGCC_ARM_CC_FLAGS = $(ARCHCC_FLAGS) $(PLATFORM_FLAGS) DEF(GCC_ARMGCC_CC_FLAGS) -Wno-address -O0
- RELEASE_ARMLINUXGCC_ARM_CC_FLAGS = $(ARCHCC_FLAGS) $(PLATFORM_FLAGS) DEF(GCC_ARMGCC_CC_FLAGS) -Wno-address -Wno-unused-but-set-variable
-diff --git a/BaseTools/Source/C/GenFv/GenFv.c b/BaseTools/Source/C/GenFv/GenFv.c
-index fa86d00..27bd2af 100644
---- a/BaseTools/Source/C/GenFv/GenFv.c
-+++ b/BaseTools/Source/C/GenFv/GenFv.c
-@@ -623,12 +623,7 @@ Returns:
- );
- } else {
- VerboseMsg ("Create Fv image and its map file");
-- //
-- // Will take rebase action at below situation:
-- // 1. ForceRebase Flag specified to TRUE;
-- // 2. ForceRebase Flag not specified, BaseAddress greater than zero.
-- //
-- if (((mFvDataInfo.BaseAddress > 0) && (mFvDataInfo.ForceRebase == -1)) || (mFvDataInfo.ForceRebase == 1)) {
-+ if (mFvDataInfo.BaseAddressSet) {
- VerboseMsg ("FvImage Rebase Address is 0x%llX", (unsigned long long) mFvDataInfo.BaseAddress);
- }
- //
-diff --git a/BaseTools/Source/C/GenFv/GenFvInternalLib.c b/BaseTools/Source/C/GenFv/GenFvInternalLib.c
-index 684933f..aabba5b 100644
---- a/BaseTools/Source/C/GenFv/GenFvInternalLib.c
-+++ b/BaseTools/Source/C/GenFv/GenFvInternalLib.c
-@@ -506,6 +506,7 @@ Returns:
- EFI_STATUS
- AddPadFile (
-+ IN FV_INFO *FvInfo,
- IN OUT MEMORY_FILE *FvImage,
- IN UINT32 DataAlignment,
- IN VOID *FvEnd,
-@@ -537,6 +538,8 @@ Returns:
- {
- EFI_FFS_FILE_HEADER *PadFile;
- UINTN PadFileSize;
-+ UINTN PadFileOffset;
-+ UINTN ExtHeaderSize;
+-*_RVCT_ARM_ASM_FLAGS = $(ARCHASM_FLAGS) $(PLATFORM_FLAGS) --apcs /interwork
++*_RVCT_ARM_ASM_FLAGS = $(ARCHASM_FLAGS) $(PLATFORM_FLAGS) DEF(RVCT_ALL_ASM_FLAGS)
+ *_RVCT_ARM_PP_FLAGS = $(ARCHCC_FLAGS) $(PLATFORM_FLAGS) -E
+ *_RVCT_ARM_VFRPP_FLAGS = $(ARCHCC_FLAGS) $(PLATFORM_FLAGS) -E -DVFRCOMPILE --preinclude $(DEST_DIR_DEBUG)/$(MODULE_NAME)StrDefs.h
+ *_RVCT_ARM_MAKE_PATH = nmake /NOLOGO
+ *_RVCT_ARM_SLINK_FLAGS = --partial -o
+ DEBUG_RVCT_ARM_CC_FLAGS = $(ARCHCC_FLAGS) $(PLATFORM_FLAGS) DEF(RVCT_ALL_CC_FLAGS) -O1 -g
+-RELEASE_RVCT_ARM_CC_FLAGS = $(ARCHCC_FLAGS) $(PLATFORM_FLAGS) DEF(RVCT_ALL_CC_FLAGS) -O2
++RELEASE_RVCT_ARM_CC_FLAGS = $(ARCHCC_FLAGS) $(PLATFORM_FLAGS) --diag_suppress=550 DEF(RVCT_ALL_CC_FLAGS) -O2
- //
- // Verify input parameters.
-@@ -559,32 +562,29 @@ Returns:
- // This is the earliest possible valid offset (current plus pad file header
- // plus the next file header)
- //
-- PadFileSize = (UINTN) FvImage->CurrentFilePointer - (UINTN) FvImage->FileImage + (sizeof (EFI_FFS_FILE_HEADER) * 2);
-+ // The padding is added into its own FFS file (which requires a header) added before the aligned file:
-+ // | ... FV data before AlignedFile ... | Pad File FFS Header | Padding | AlignedFile FFS Header (+ ExtHeader) | AlignedData
+ ##################
+ # ARM definitions
+@@ -4691,13 +4692,13 @@
+ DEBUG_RVCTLINUX_ARM_DLINK_FLAGS = $(ARCHDLINK_FLAGS) DEF(RVCT_ALL_DLINK_FLAGS) --entry $(IMAGE_ENTRY_POINT) --map --list $(DEST_DIR_DEBUG)/$(BASE_NAME).map
+ RELEASE_RVCTLINUX_ARM_DLINK_FLAGS = $(ARCHDLINK_FLAGS) DEF(RVCT_ALL_DLINK_FLAGS) --entry $(IMAGE_ENTRY_POINT) --map --list $(DEST_DIR_DEBUG)/$(BASE_NAME).map
- //
-- // Add whatever it takes to get to the next aligned address
-+ // Calculate the Offset of the Pad File from the beginning of the FV file
- //
-- while ((PadFileSize % DataAlignment) != 0) {
-- PadFileSize++;
-- }
-- //
-- // Subtract the next file header size
-- //
-- PadFileSize -= sizeof (EFI_FFS_FILE_HEADER);
--
-- //
-- // Subtract the starting offset to get size
-- //
-- PadFileSize -= (UINTN) FvImage->CurrentFilePointer - (UINTN) FvImage->FileImage;
-+ PadFileOffset = (UINTN) FvImage->CurrentFilePointer - (UINTN) FvImage->FileImage;
-
- //
-- // Append extension header size
-+ // Get the size of the extension header if exists
- //
- if (ExtHeader != NULL) {
-- PadFileSize = PadFileSize + ExtHeader->ExtHeaderSize;
-+ ExtHeaderSize = ExtHeader->ExtHeaderSize;
-+ } else {
-+ ExtHeaderSize = 0;
- }
+-*_RVCTLINUX_ARM_ASM_FLAGS = $(ARCHASM_FLAGS) $(PLATFORM_FLAGS) --apcs /interwork
++*_RVCTLINUX_ARM_ASM_FLAGS = $(ARCHASM_FLAGS) $(PLATFORM_FLAGS) DEF(RVCT_ALL_ASM_FLAGS)
+ *_RVCTLINUX_ARM_PP_FLAGS = $(ARCHCC_FLAGS) $(PLATFORM_FLAGS) -E
+ *_RVCTLINUX_ARM_VFRPP_FLAGS = $(ARCHCC_FLAGS) $(PLATFORM_FLAGS) -E -DVFRCOMPILE --preinclude $(DEST_DIR_DEBUG)/$(MODULE_NAME)StrDefs.h
+ *_RVCTLINUX_ARM_MAKE_PATH = make
+ *_RVCTLINUX_ARM_SLINK_FLAGS = --partial -o
+ DEBUG_RVCTLINUX_ARM_CC_FLAGS = $(ARCHCC_FLAGS) $(PLATFORM_FLAGS) DEF(RVCT_ALL_CC_FLAGS) -O1 -g
+-RELEASE_RVCTLINUX_ARM_CC_FLAGS = $(ARCHCC_FLAGS) $(PLATFORM_FLAGS) DEF(RVCT_ALL_CC_FLAGS) -O2
++RELEASE_RVCTLINUX_ARM_CC_FLAGS = $(ARCHCC_FLAGS) $(PLATFORM_FLAGS) --diag_suppress=550 DEF(RVCT_ALL_CC_FLAGS) -O2
- //
-+ // Calculate the Size of the Padding to ensure the alignment of the data of the Next file
-+ //
-+ PadFileSize = DataAlignment - ((FvInfo->BaseAddress + PadFileOffset + sizeof (EFI_FFS_FILE_HEADER) + ExtHeaderSize) & (DataAlignment - 1));
-+
-+ //
- // Verify that we have enough space for the file header
- //
- if (((UINTN) FvImage->CurrentFilePointer + PadFileSize) > (UINTN) FvEnd) {
-@@ -1115,7 +1115,7 @@ Returns:
- //
- // Add pad file if necessary
- //
-- Status = AddPadFile (FvImage, 1 << CurrentFileAlignment, *VtfFileImage, NULL);
-+ Status = AddPadFile (FvInfo, FvImage, 1 << CurrentFileAlignment, *VtfFileImage, NULL);
- if (EFI_ERROR (Status)) {
- Error (NULL, 0, 4002, "Resource", "FV space is full, could not add pad file for data alignment property.");
- free (FileBuffer);
-@@ -2304,7 +2304,7 @@ Returns:
- //
- // Add FV Extended Header contents to the FV as a PAD file
- //
-- AddPadFile (&FvImageMemoryFile, 4, VtfFileImage, FvExtHeader);
-+ AddPadFile (&mFvDataInfo, &FvImageMemoryFile, 4, VtfFileImage, FvExtHeader);
+ ##################
+ # ARM definitions
+@@ -4739,13 +4740,13 @@
+ DEBUG_RVCTCYGWIN_ARM_DLINK_FLAGS = "$(DLINKPATH_FLAG)" $(ARCHDLINK_FLAGS) DEF(RVCT_ALL_DLINK_FLAGS) --entry $(IMAGE_ENTRY_POINT) --map --list `cygpath -m $(DEST_DIR_DEBUG)/$(BASE_NAME).map`
+ RELEASE_RVCTCYGWIN_ARM_DLINK_FLAGS = "$(DLINKPATH_FLAG)" $(ARCHDLINK_FLAGS) DEF(RVCT_ALL_DLINK_FLAGS) --entry $(IMAGE_ENTRY_POINT) --map --list `cygpath -m $(DEST_DIR_DEBUG)/$(BASE_NAME).map`
+
+-*_RVCTCYGWIN_ARM_ASM_FLAGS = "$(ASMPATH_FLAG)" $(ARCHASM_FLAGS) $(PLATFORM_FLAGS) --apcs /interwork
++*_RVCTCYGWIN_ARM_ASM_FLAGS = "$(ASMPATH_FLAG)" $(ARCHASM_FLAGS) $(PLATFORM_FLAGS) DEF(RVCT_ALL_ASM_FLAGS)
+ *_RVCTCYGWIN_ARM_PP_FLAGS = "$(CCPATH_FLAG)" $(ARCHCC_FLAGS) $(PLATFORM_FLAGS) -E
+ *_RVCTCYGWIN_ARM_VFRPP_FLAGS = "$(CCPATH_FLAG)" $(ARCHCC_FLAGS) $(PLATFORM_FLAGS) -E -DVFRCOMPILE --preinclude `cygpath -m $(DEST_DIR_DEBUG)/$(MODULE_NAME)StrDefs.h`
+ *_RVCTCYGWIN_ARM_MAKE_PATH = make
+ *_RVCTCYGWIN_ARM_SLINK_FLAGS = "$(SLINKPATH_FLAG)" --partial -o
+ DEBUG_RVCTCYGWIN_ARM_CC_FLAGS = "$(CCPATH_FLAG)" $(ARCHCC_FLAGS) $(PLATFORM_FLAGS) DEF(RVCT_ALL_CC_FLAGS) -O1 -g
+-RELEASE_RVCTCYGWIN_ARM_CC_FLAGS = "$(CCPATH_FLAG)" $(ARCHCC_FLAGS) $(PLATFORM_FLAGS) DEF(RVCT_ALL_CC_FLAGS) -O2
++RELEASE_RVCTCYGWIN_ARM_CC_FLAGS = "$(CCPATH_FLAG)" $(ARCHCC_FLAGS) $(PLATFORM_FLAGS) --diag_suppress=550 DEF(RVCT_ALL_CC_FLAGS) -O2
- //
- // Fv Extension header change update Fv Header Check sum
-@@ -2825,20 +2825,12 @@ Returns:
- PeFileBuffer = NULL;
+ ##################
+ # ARM definitions
+@@ -4813,8 +4814,8 @@
+ *_ARMGCC_ARM_SLINK_FLAGS = -rc
+ *_ARMGCC_ARM_DLINK_FLAGS = $(ARCHDLINK_FLAGS) -Ttext=0x0 --oformat=elf32-littlearm --emit-relocs -nostdlib -u $(IMAGE_ENTRY_POINT) -e $(IMAGE_ENTRY_POINT) -Map $(DEST_DIR_DEBUG)/$(BASE_NAME).map
- //
-- // Don't need to relocate image when BaseAddress is zero and no ForceRebase Flag specified.
-- //
-- if ((FvInfo->BaseAddress == 0) && (FvInfo->ForceRebase == -1)) {
-- return EFI_SUCCESS;
-- }
--
-- //
-- // If ForceRebase Flag specified to FALSE, will always not take rebase action.
-+ // Don't need to relocate image when BaseAddress is not set.
- //
-- if (FvInfo->ForceRebase == 0) {
-+ if (FvInfo->BaseAddressSet == FALSE) {
- return EFI_SUCCESS;
- }
+- DEBUG_ARMGCC_ARM_CC_FLAGS = $(ARCHCC_FLAGS) $(PLATFORM_FLAGS) DEF(GCC_ARMGCC_CC_FLAGS) -combine -O0
+-RELEASE_ARMGCC_ARM_CC_FLAGS = $(ARCHCC_FLAGS) $(PLATFORM_FLAGS) DEF(GCC_ARMGCC_CC_FLAGS) -combine -Wno-unused
++ DEBUG_ARMGCC_ARM_CC_FLAGS = $(ARCHCC_FLAGS) $(PLATFORM_FLAGS) DEF(GCC_ARMGCC_CC_FLAGS) -O0
++RELEASE_ARMGCC_ARM_CC_FLAGS = $(ARCHCC_FLAGS) $(PLATFORM_FLAGS) DEF(GCC_ARMGCC_CC_FLAGS) -Wno-unused
+
+ ####################################################################################
+ #
+@@ -4871,8 +4872,8 @@
+ *_ARMLINUXGCC_ARM_SLINK_FLAGS = -rc
+ *_ARMLINUXGCC_ARM_DLINK_FLAGS = $(ARCHDLINK_FLAGS) -Ttext=0x0 --oformat=elf32-littlearm --emit-relocs -nostdlib -u $(IMAGE_ENTRY_POINT) -e $(IMAGE_ENTRY_POINT) -Map $(DEST_DIR_DEBUG)/$(BASE_NAME).map
--
- XipBase = FvInfo->BaseAddress + XipOffset;
+- DEBUG_ARMLINUXGCC_ARM_CC_FLAGS = $(ARCHCC_FLAGS) $(PLATFORM_FLAGS) DEF(GCC_ARMGCC_CC_FLAGS) -Wno-address -O0
+-RELEASE_ARMLINUXGCC_ARM_CC_FLAGS = $(ARCHCC_FLAGS) $(PLATFORM_FLAGS) DEF(GCC_ARMGCC_CC_FLAGS) -Wno-address -Wno-unused-but-set-variable
++ DEBUG_ARMLINUXGCC_ARM_CC_FLAGS = $(ARCHCC_FLAGS) $(PLATFORM_FLAGS) DEF(GCC_ARMGCC_CC_FLAGS) -fno-stack-protector -mno-unaligned-access -O0
++RELEASE_ARMLINUXGCC_ARM_CC_FLAGS = $(ARCHCC_FLAGS) $(PLATFORM_FLAGS) DEF(GCC_ARMGCC_CC_FLAGS) -fno-stack-protector -mno-unaligned-access -Wno-unused-but-set-variable
- //
---
-1.7.0.4
-
+ #################
+ # ASM 16 linker defintions
diff --git a/edk2/ArmPlatformPkg/Scripts/Ds5/build_report.py b/edk2/ArmPlatformPkg/Scripts/Ds5/build_report.py
new file mode 100644
index 000000000..3805c0b43
--- /dev/null
+++ b/edk2/ArmPlatformPkg/Scripts/Ds5/build_report.py
@@ -0,0 +1,54 @@
+#
+# 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.
+#
+
+import re
+
+class BuildReport:
+ PCDs = {}
+
+ def parse_platform_summary(self, file):
+ pass
+
+ def parse_pcd_report(self, report_file):
+ pcd_reg = re.compile(" (\*P|\*F|\*M| ) (\w+)(\ +)\: (.*) \((\w+)\) = (.*)\n")
+
+ for line in report_file.xreadlines():
+ stripped_line = line.strip()
+ if re.match("\<=+\>", stripped_line):
+ return
+ elif re.match("g.*Guid", stripped_line):
+ guid = stripped_line
+ self.PCDs[guid] = {}
+ else:
+ m = pcd_reg.match(line)
+ if m:
+ self.PCDs[guid][m.group(2)] = (m.group(6).strip(),m.group(5))
+
+ def parse_firmware_device(self, file):
+ pass
+
+ def parse_module_summary(self, file):
+ #print "Module Summary"
+ pass
+
+ CONST_SECTION_HEADERS = [('Platform Summary', parse_platform_summary),
+ ('Platform Configuration Database Report',parse_pcd_report),
+ ('Firmware Device (FD)',parse_firmware_device),
+ ('Module Summary',parse_module_summary)]
+
+ def __init__(self, filename = 'report.log'):
+ report_file = open(filename, 'r')
+ for line in report_file.xreadlines():
+ for section_header in BuildReport.CONST_SECTION_HEADERS:
+ if line.strip() == section_header[0]:
+ section_header[1](self, report_file)
+ #print self.PCDs
diff --git a/edk2/ArmPlatformPkg/Scripts/Ds5/cmd_load_symbols.py b/edk2/ArmPlatformPkg/Scripts/Ds5/cmd_load_symbols.py
new file mode 100644
index 000000000..424eb63cb
--- /dev/null
+++ b/edk2/ArmPlatformPkg/Scripts/Ds5/cmd_load_symbols.py
@@ -0,0 +1,100 @@
+#
+# 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.
+#
+
+from arm_ds.debugger_v1 import Debugger
+from arm_ds.debugger_v1 import DebugException
+
+import re, sys, getopt
+
+import edk2_debugger
+
+# Reload external classes
+reload(edk2_debugger)
+
+def usage():
+ print "-a,--all: Load all symbols"
+ print "-l,--report=: Filename for the EDK2 report log"
+ print "-m,--sysmem=(base,size): System Memory region"
+ print "-f,--fv=(base,size): Firmware region"
+ print "-r,--rom=(base,size): ROM region"
+
+load_all = False
+report_file = None
+regions = []
+opts,args = getopt.getopt(sys.argv[1:], "har:vm:vr:vf:v", ["help","all","report=","sysmem=","rom=","fv="])
+if (opts is None) or (not opts):
+ report_file = '../../../report.log'
+else:
+ region_reg = re.compile("\((.*),(.*)\)")
+ base_reg = re.compile("(.*)")
+
+ for o,a in opts:
+ region_type = None
+ regex = None
+ m = None
+ if o in ("-h","--help"):
+ usage()
+ sys.exit()
+ elif o in ("-a","--all"):
+ load_all = True
+ elif o in ("-l","--report"):
+ report_file = a
+ elif o in ("-m","--sysmem"):
+ region_type = edk2_debugger.ArmPlatformDebugger.REGION_TYPE_SYSMEM
+ regex = region_reg
+ elif o in ("-f","--fv"):
+ region_type = edk2_debugger.ArmPlatformDebugger.REGION_TYPE_FV
+ regex = region_reg
+ elif o in ("-r","--rom"):
+ region_type = edk2_debugger.ArmPlatformDebugger.REGION_TYPE_ROM
+ regex = region_reg
+ else:
+ assert False, "Unhandled option"
+
+ if region_type:
+ m = regex.match(a)
+ if m:
+ if regex.groups == 1:
+ regions.append((region_type,int(m.group(1),0),0))
+ else:
+ regions.append((region_type,int(m.group(1),0),int(m.group(2),0)))
+ else:
+ if regex.groups == 1:
+ raise Exception('cmd_load_symbols', "Expect a base address")
+ else:
+ raise Exception('cmd_load_symbols', "Expect a region format as (base,size)")
+
+# Debugger object for accessing the debugger
+debugger = Debugger()
+
+# Initialisation commands
+ec = debugger.getExecutionContext(0)
+ec.getExecutionService().stop()
+ec.getExecutionService().waitForStop()
+# in case the execution context reference is out of date
+ec = debugger.getExecutionContext(0)
+
+armplatform_debugger = edk2_debugger.ArmPlatformDebugger(ec, report_file, regions)
+
+try:
+ armplatform_debugger = edk2_debugger.ArmPlatformDebugger(ec, report_file, regions)
+
+ if load_all:
+ armplatform_debugger.load_all_symbols()
+ else:
+ armplatform_debugger.load_current_symbols()
+except IOError, (ErrorNumber, ErrorMessage):
+ print "Error: %s" % ErrorMessage
+except Exception, (ErrorClass, ErrorMessage):
+ print "Error(%s): %s" % (ErrorClass, ErrorMessage)
+except DebugException, de:
+ print "DebugError: %s" % (de.getMessage())
diff --git a/edk2/ArmPlatformPkg/Scripts/Ds5/edk2_debugger.py b/edk2/ArmPlatformPkg/Scripts/Ds5/edk2_debugger.py
new file mode 100644
index 000000000..71e5a3ccd
--- /dev/null
+++ b/edk2/ArmPlatformPkg/Scripts/Ds5/edk2_debugger.py
@@ -0,0 +1,217 @@
+#
+# 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.
+#
+
+import os
+
+import firmware_volume
+import build_report
+import system_table
+
+# Reload external classes
+reload(firmware_volume)
+reload(build_report)
+reload(system_table)
+
+def readMem32(executionContext, address):
+ bytes = executionContext.getMemoryService().read(address, 4, 32)
+ return struct.unpack('<I',bytes)[0]
+
+def dump_fv(ec, fv_base, fv_size):
+ fv = firmware_volume.FirmwareVolume(ec,
+ int(build.PCDs['gArmTokenSpaceGuid']['PcdFvBaseAddress'][0],16),
+ int(build.PCDs['gArmTokenSpaceGuid']['PcdFvSize'][0],16))
+
+ ffs = fv.get_next_ffs()
+ while ffs != None:
+ print "# %s" % ffs
+
+ section = ffs.get_next_section()
+ while section != None:
+ print "\t%s" % section
+ try:
+ print "\t\t- %s" % section.get_debug_filepath()
+ except Exception:
+ pass
+ section = ffs.get_next_section(section)
+
+ ffs = fv.get_next_ffs(ffs)
+
+def dump_system_table(ec, mem_base, mem_size):
+ st = system_table.SystemTable(ec, mem_base, mem_size)
+
+ debug_info_table_base = st.get_configuration_table(system_table.DebugInfoTable.CONST_DEBUG_INFO_TABLE_GUID)
+
+ debug_info_table = system_table.DebugInfoTable(ec, debug_info_table_base)
+ debug_info_table.dump()
+
+def load_symbol_from_file(ec, filename, address):
+ try:
+ ec.getImageService().addSymbols(filename, address)
+ except:
+ try:
+ # We could get an exception if the symbols are already loaded
+ ec.getImageService().unloadSymbols(filename)
+ ec.getImageService().addSymbols(filename, address)
+ except:
+ print "Warning: not possible to load symbols from %s" % filename
+ pass
+
+class ArmPlatform:
+ def __init__(self, sysmembase=None, sysmemsize=None, fvs={}):
+ self.sysmembase = sysmembase
+ self.sysmemsize = sysmemsize
+ self.fvs = fvs
+
+class ArmPlatformDebugger:
+ system_table = None
+ firmware_volumes = {}
+
+ REGION_TYPE_SYSMEM = 1
+ REGION_TYPE_ROM = 2
+ REGION_TYPE_FV = 3
+
+ def __init__(self, ec, report_log, regions):
+ self.ec = ec
+ fvs = []
+ sysmem_base = None
+ sysmem_size = None
+
+ if report_log and os.path.isfile(report_log):
+ try:
+ self.build = build_report.BuildReport(report_log)
+ except IOError:
+ raise IOError(2, 'Report \'%s\' isnot valid' % report_log)
+
+ # Generate list of supported Firmware Volumes
+ if self.build.PCDs['gArmTokenSpaceGuid'].has_key('PcdFvSize') and int(self.build.PCDs['gArmTokenSpaceGuid']['PcdFvSize'][0],16) != 0:
+ fvs.append((int(self.build.PCDs['gArmTokenSpaceGuid']['PcdFvBaseAddress'][0],16),int(self.build.PCDs['gArmTokenSpaceGuid']['PcdFvSize'][0],16)))
+ if self.build.PCDs['gArmTokenSpaceGuid'].has_key('PcdSecureFvSize') and int(self.build.PCDs['gArmTokenSpaceGuid']['PcdSecureFvSize'][0],16) != 0:
+ fvs.append((int(self.build.PCDs['gArmTokenSpaceGuid']['PcdSecureFvBaseAddress'][0],16),int(self.build.PCDs['gArmTokenSpaceGuid']['PcdSecureFvSize'][0],16)))
+ if self.build.PCDs['gArmTokenSpaceGuid'].has_key('PcdHypFvSize') and int(self.build.PCDs['gArmTokenSpaceGuid']['PcdHypFvSize'][0],16) != 0:
+ fvs.append((int(self.build.PCDs['gArmTokenSpaceGuid']['PcdHypFvBaseAddress'][0],16),int(self.build.PCDs['gArmTokenSpaceGuid']['PcdHypFvSize'][0],16)))
+
+ sysmem_base = int(self.build.PCDs['gArmTokenSpaceGuid']['PcdSystemMemoryBase'][0],16)
+ sysmem_size = int(self.build.PCDs['gArmTokenSpaceGuid']['PcdSystemMemorySize'][0],16)
+ else:
+ for region in regions:
+ if region[0] == ArmPlatformDebugger.REGION_TYPE_SYSMEM:
+ sysmem_base = region[1]
+ sysmem_size = region[2]
+ elif region[0] == ArmPlatformDebugger.REGION_TYPE_FV:
+ fvs.append((region[1],region[2]))
+ elif region[0] == ArmPlatformDebugger.REGION_TYPE_ROM:
+ for base in xrange(region[1], region[1] + region[2], 0x400000):
+ signature = struct.unpack("cccc", self.ec.getMemoryService().read(base, 4, 32))
+ if signature == FirmwareVolume.CONST_FV_SIGNATURE:
+ fvs.append((base,0))
+ else:
+ print "Region type '%d' Not Supported" % region[0]
+
+ self.platform = ArmPlatform(sysmem_base, sysmem_size, fvs)
+
+ def in_sysmem(self, addr):
+ return (self.platform.sysmembase is not None) and (self.platform.sysmembase <= addr) and (addr < self.platform.sysmembase + self.platform.sysmemsize)
+
+ def in_fv(self, addr):
+ return (self.get_fv_at(addr) != None)
+
+ def get_fv_at(self, addr):
+ for fv in self.platform.fvs:
+ if (fv[0] <= addr) and (addr < fv[0] + fv[1]):
+ return fv
+ return None
+
+ def load_current_symbols(self):
+ pc = int(self.ec.getRegisterService().getValue('PC')) & 0xFFFFFFFF
+ if self.in_fv(pc):
+ debug_infos = []
+
+ (fv_base, fv_size) = self.get_fv_at(pc)
+
+ if self.firmware_volumes.has_key(fv_base) == False:
+ self.firmware_volumes[fv_base] = firmware_volume.FirmwareVolume(self.ec, fv_base, fv_size)
+
+ stack_frame = self.ec.getTopLevelStackFrame()
+ info = self.firmware_volumes[fv_base].load_symbols_at(int(stack_frame.getRegisterService().getValue('PC')) & 0xFFFFFFFF)
+ debug_infos.append(info)
+ while stack_frame.next() is not None:
+ stack_frame = stack_frame.next()
+
+ # Stack frame attached to 'PC'
+ pc = int(stack_frame.getRegisterService().getValue('PC')) & 0xFFFFFFFF
+
+ # Check if the symbols for this stack frame have already been loaded
+ found = False
+ for debug_info in debug_infos:
+ if (pc >= debug_info[0]) and (pc < debug_info[0] + debug_info[1]):
+ found = True
+ if found == False:
+ info = self.firmware_volumes[fv_base].load_symbols_at(pc)
+ debug_infos.append(info)
+
+ #self.firmware_volumes[fv_base].load_symbols_at(pc)
+ elif self.in_sysmem(pc):
+ debug_infos = []
+
+ if self.system_table is None:
+ # Find the System Table
+ self.system_table = system_table.SystemTable(self.ec, self.platform.sysmembase, self.platform.sysmemsize)
+
+ # Find the Debug Info Table
+ debug_info_table_base = self.system_table.get_configuration_table(system_table.DebugInfoTable.CONST_DEBUG_INFO_TABLE_GUID)
+ self.debug_info_table = system_table.DebugInfoTable(self.ec, debug_info_table_base)
+
+ stack_frame = self.ec.getTopLevelStackFrame()
+ info = self.debug_info_table.load_symbols_at(int(stack_frame.getRegisterService().getValue('PC')) & 0xFFFFFFFF)
+ debug_infos.append(info)
+ while stack_frame.next() is not None:
+ stack_frame = stack_frame.next()
+
+ # Stack frame attached to 'PC'
+ pc = int(stack_frame.getRegisterService().getValue('PC')) & 0xFFFFFFFF
+
+ # Check if the symbols for this stack frame have already been loaded
+ found = False
+ for debug_info in debug_infos:
+ if (pc >= debug_info[0]) and (pc < debug_info[0] + debug_info[1]):
+ found = True
+ if found == False:
+ info = self.debug_info_table.load_symbols_at(pc)
+ debug_infos.append(info)
+
+ #self.debug_info_table.load_symbols_at(pc)
+ else:
+ raise Exception('ArmPlatformDebugger', "Not supported region")
+
+ def load_all_symbols(self):
+ # Load all the XIP symbols attached to the Firmware Volume
+ for (fv_base, fv_size) in self.platform.fvs:
+ if self.firmware_volumes.has_key(fv_base) == False:
+ self.firmware_volumes[fv_base] = firmware_volume.FirmwareVolume(self.ec, fv_base, fv_size)
+ self.firmware_volumes[fv_base].load_all_symbols()
+
+ try:
+ # Load all symbols of module loaded into System Memory
+ if self.system_table is None:
+ # Find the System Table
+ self.system_table = system_table.SystemTable(self.ec, self.platform.sysmembase, self.platform.sysmemsize)
+
+
+ # Find the Debug Info Table
+ debug_info_table_base = self.system_table.get_configuration_table(system_table.DebugInfoTable.CONST_DEBUG_INFO_TABLE_GUID)
+ self.debug_info_table = system_table.DebugInfoTable(self.ec, debug_info_table_base)
+
+ self.debug_info_table.load_all_symbols()
+ except:
+ # Debugger exception could be excepted if DRAM has not been initialized or if we have not started to run from DRAM yet
+ print "Note: no symbols have been found in System Memory (possible cause: the UEFI permanent memory has been installed yet)"
+ pass
diff --git a/edk2/ArmPlatformPkg/Scripts/Ds5/firmware_volume.py b/edk2/ArmPlatformPkg/Scripts/Ds5/firmware_volume.py
new file mode 100644
index 000000000..c4e02ece2
--- /dev/null
+++ b/edk2/ArmPlatformPkg/Scripts/Ds5/firmware_volume.py
@@ -0,0 +1,301 @@
+#
+# 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.
+#
+
+from arm_ds.debugger_v1 import DebugException
+
+import struct
+import string
+
+import edk2_debugger
+
+class EfiFileSection(object):
+ EFI_SECTION_PE32 = 0x10
+ EFI_SECTION_PIC = 0x11
+ EFI_SECTION_TE = 0x12
+
+ EFI_IMAGE_DEBUG_TYPE_CODEVIEW = 0x2
+
+ SIZEOF_EFI_FFS_FILE_HEADER = 0x28
+
+ def __init__(self, ec, base):
+ self.base = base
+ self.ec = ec
+
+ def __str__(self):
+ return "FileSection(type:0x%X, size:0x%x)" % (self.get_type(), self.get_size())
+
+ def get_base(self):
+ return self.base
+
+ def get_type(self):
+ return struct.unpack("B", self.ec.getMemoryService().read(self.base + 0x3, 1, 8))[0]
+
+ def get_size(self):
+ return (struct.unpack("<I", self.ec.getMemoryService().read(self.base, 4, 32))[0] & 0x00ffffff)
+
+ def get_debug_filepath(self):
+ type = self.get_type()
+ if type == EfiFileSection.EFI_SECTION_TE:
+ section = EfiSectionTE(self, ec, self.base + 0x4)
+ elif type == EfiFileSection.EFI_SECTION_PE32:
+ section = EfiSectionPE32(self, ec, self.base + 0x4)
+ else:
+ raise Exception("EfiFileSection", "No debug section")
+ return section.get_debug_filepath()
+
+class EfiSectionTE:
+ SIZEOF_EFI_TE_IMAGE_HEADER = 0x28
+ EFI_TE_IMAGE_SIGNATURE = ('V','Z')
+
+ def __init__(self, ec, base_te):
+ self.ec = ec
+ self.base_te = int(base_te)
+ te_sig = struct.unpack("cc", self.ec.getMemoryService().read(self.base_te, 2, 32))
+ if te_sig != EfiSectionTE.EFI_TE_IMAGE_SIGNATURE:
+ raise Exception("EfiFileSectionTE","TE Signature incorrect")
+
+ def get_debug_filepath(self):
+ stripped_size = struct.unpack("<H", self.ec.getMemoryService().read(self.base_te + 0x6, 2, 32))[0]
+ stripped_size -= EfiSectionTE.SIZEOF_EFI_TE_IMAGE_HEADER
+
+ debug_dir_entry_rva = self.ec.getMemoryService().readMemory32(self.base_te + 0x20)
+ if debug_dir_entry_rva == 0:
+ raise Exception("EfiFileSectionTE","No debug directory for image")
+ debug_dir_entry_rva -= stripped_size
+
+ debug_type = self.ec.getMemoryService().readMemory32(self.base_te + debug_dir_entry_rva + 0xC)
+ if (debug_type != 0xdf) and (debug_type != EfiFileSection.EFI_IMAGE_DEBUG_TYPE_CODEVIEW):
+ raise Exception("EfiFileSectionTE","Debug type is not dwarf")
+
+ debug_rva = self.ec.getMemoryService().readMemory32(self.base_te + debug_dir_entry_rva + 0x14)
+ debug_rva -= stripped_size
+
+ dwarf_sig = struct.unpack("cccc", self.ec.getMemoryService().read(self.base_te + debug_rva, 4, 32))
+ if (dwarf_sig != 0x66727764) and (dwarf_sig != FirmwareFile.CONST_NB10_SIGNATURE):
+ raise Exception("EfiFileSectionTE","Dwarf debug signature not found")
+
+ if dwarf_sig == 0x66727764:
+ filename = self.base_te + debug_rva + 0xc
+ else:
+ filename = self.base_te + debug_rva + 0x10
+ filename = struct.unpack("200s", self.ec.getMemoryService().read(filename, 200, 32))[0]
+ return filename[0:string.find(filename,'\0')]
+
+ def get_debug_elfbase(self):
+ stripped_size = struct.unpack("<H", self.ec.getMemoryService().read(self.base_te + 0x6, 2, 32))[0]
+ stripped_size -= EfiSectionTE.SIZEOF_EFI_TE_IMAGE_HEADER
+
+ base_of_code = self.ec.getMemoryService().readMemory32(self.base_te + 0xC)
+
+ return self.base_te + base_of_code - stripped_size
+
+class EfiSectionPE32:
+ def __init__(self, ec, base_pe32):
+ self.ec = ec
+ self.base_pe32 = base_pe32
+
+ def get_debug_filepath(self):
+ # Offset from dos hdr to PE file hdr
+ file_header_offset = self.ec.getMemoryService().readMemory32(self.base_pe32 + 0x3C)
+
+ # Offset to debug dir in PE hdrs
+ debug_dir_entry_rva = self.ec.getMemoryService().readMemory32(self.base_pe32 + file_header_offset + 0xA8)
+ if debug_dir_entry_rva == 0:
+ raise Exception("EfiFileSectionPE32","No Debug Directory")
+
+ debug_type = self.ec.getMemoryService().readMemory32(self.base_pe32 + debug_dir_entry_rva + 0xC)
+ if (debug_type != 0xdf) and (debug_type != EfiFileSection.EFI_IMAGE_DEBUG_TYPE_CODEVIEW):
+ raise Exception("EfiFileSectionPE32","Debug type is not dwarf")
+
+
+ debug_rva = self.ec.getMemoryService().readMemory32(self.base_pe32 + debug_dir_entry_rva + 0x14)
+
+ dwarf_sig = struct.unpack("cccc", self.ec.getMemoryService().read(str(self.base_pe32 + debug_rva), 4, 32))
+ if (dwarf_sig != 0x66727764) and (dwarf_sig != FirmwareFile.CONST_NB10_SIGNATURE):
+ raise Exception("EfiFileSectionPE32","Dwarf debug signature not found")
+
+ if dwarf_sig == 0x66727764:
+ filename = self.base_pe32 + debug_rva + 0xc
+ else:
+ filename = self.base_pe32 + debug_rva + 0x10
+ filename = struct.unpack("200s", self.ec.getMemoryService().read(str(filename), 200, 32))[0]
+ return filename[0:string.find(filename,'\0')]
+
+ def get_debug_elfbase(self):
+ # Offset from dos hdr to PE file hdr
+ pe_file_header = self.base_pe32 + self.ec.getMemoryService().readMemory32(self.base_pe32 + 0x3C)
+
+ base_of_code = self.base_pe32 + self.ec.getMemoryService().readMemory32(pe_file_header + 0x28)
+ base_of_data = self.base_pe32 + self.ec.getMemoryService().readMemory32(pe_file_header + 0x2C)
+
+ if (base_of_code < base_of_data) and (base_of_code != 0):
+ return base_of_code
+ else:
+ return base_of_data
+
+class FirmwareFile:
+ EFI_FV_FILETYPE_RAW = 0x01
+ EFI_FV_FILETYPE_FREEFORM = 0x02
+ EFI_FV_FILETYPE_SECURITY_CORE = 0x03
+ EFI_FV_FILETYPE_PEI_CORE = 0x04
+ EFI_FV_FILETYPE_DXE_CORE = 0x05
+ EFI_FV_FILETYPE_PEIM = 0x06
+ EFI_FV_FILETYPE_DRIVER = 0x07
+ EFI_FV_FILETYPE_COMBINED_PEIM_DRIVER = 0x08
+ EFI_FV_FILETYPE_APPLICATION = 0x09
+ EFI_FV_FILETYPE_FIRMWARE_VOLUME_IMAGE = 0x0B
+ EFI_FV_FILETYPE_FFS_MIN = 0xF0
+
+ CONST_NB10_SIGNATURE = ('N','B','1','0')
+
+ def __init__(self, fv, base, ec):
+ self.fv = fv
+ self.base = base
+ self.ec = ec
+
+ def __str__(self):
+ return "FFS(state:0x%x, type:0x%X, size:0x%x)" % (self.get_state(), self.get_type(), self.get_size())
+
+ def get_base(self):
+ return self.base
+
+ def get_size(self):
+ size = (self.ec.getMemoryService().readMemory32(self.base + 0x14) & 0x00ffffff)
+
+ # Occupied size is the size considering the alignment
+ return size + ((0x8 - (size & 0x7)) & 0x7)
+
+ def get_type(self):
+ return self.ec.getMemoryService().readMemory8(self.base + 0x12)
+
+ def get_state(self):
+ state = self.ec.getMemoryService().readMemory8(self.base + 0x17)
+
+ polarity = self.fv.get_polarity()
+ if polarity:
+ state = ~state
+
+ highest_bit = 0x80;
+ while (highest_bit != 0) and ((highest_bit & state) == 0):
+ highest_bit >>= 1
+
+ return highest_bit
+
+ def get_next_section(self, section=None):
+ if section == None:
+ if self.get_type() != FirmwareFile.EFI_FV_FILETYPE_FFS_MIN:
+ section_base = self.get_base() + 0x18;
+ else:
+ return None
+ else:
+ section_base = int(section.get_base() + section.get_size())
+
+ # Align to next 4 byte boundary
+ if (section_base & 0x3) != 0:
+ section_base = section_base + 0x4 - (section_base & 0x3)
+
+ if section_base < self.get_base() + self.get_size():
+ return EfiFileSection(self.ec, section_base)
+ else:
+ return None
+
+class FirmwareVolume:
+ CONST_FV_SIGNATURE = ('_','F','V','H')
+ EFI_FVB2_ERASE_POLARITY = 0x800
+
+ DebugInfos = []
+
+ def __init__(self, ec, fv_base, fv_size):
+ self.ec = ec
+ self.fv_base = fv_base
+ self.fv_size = fv_size
+
+ try:
+ signature = struct.unpack("cccc", self.ec.getMemoryService().read(fv_base + 0x28, 4, 32))
+ except DebugException:
+ raise Exception("FirmwareVolume", "Not possible to access the defined firmware volume at [0x%X,0x%X]. Could be the used build report does not correspond to your current debugging context." % (int(fv_base),int(fv_base+fv_size)))
+ if signature != FirmwareVolume.CONST_FV_SIGNATURE:
+ raise Exception("FirmwareVolume", "This is not a valid firmware volume")
+
+ def get_size(self):
+ return self.ec.getMemoryService().readMemory32(self.fv_base + 0x20)
+
+ def get_attributes(self):
+ return self.ec.getMemoryService().readMemory32(self.fv_base + 0x2C)
+
+ def get_polarity(self):
+ attributes = self.get_attributes()
+ if attributes & FirmwareVolume.EFI_FVB2_ERASE_POLARITY:
+ return 1
+ else:
+ return 0
+
+ def get_next_ffs(self, ffs=None):
+ if ffs == None:
+ # Get the offset of the first FFS file from the FV header
+ ffs_base = self.fv_base + self.ec.getMemoryService().readMemory16(self.fv_base + 0x30)
+ else:
+ # Goto the next FFS file
+ ffs_base = int(ffs.get_base() + ffs.get_size())
+
+ # Align to next 8 byte boundary
+ if (ffs_base & 0x7) != 0:
+ ffs_base = ffs_base + 0x8 - (ffs_base & 0x7)
+
+ if ffs_base < self.fv_base + self.get_size():
+ return FirmwareFile(self, ffs_base, self.ec)
+ else:
+ return None
+
+ def get_debug_info(self):
+ self.DebugInfos = []
+
+ ffs = self.get_next_ffs()
+ while ffs != None:
+ section = ffs.get_next_section()
+ while section != None:
+ type = section.get_type()
+ if (type == EfiFileSection.EFI_SECTION_TE) or (type == EfiFileSection.EFI_SECTION_PE32):
+ self.DebugInfos.append((section.get_base(), section.get_size(), section.get_type()))
+ section = ffs.get_next_section(section)
+ ffs = self.get_next_ffs(ffs)
+
+ def load_symbols_at(self, addr):
+ if self.DebugInfos == []:
+ self.get_debug_info()
+
+ for debug_info in self.DebugInfos:
+ if (addr >= debug_info[0]) and (addr < debug_info[0] + debug_info[1]):
+ if debug_info[2] == EfiFileSection.EFI_SECTION_TE:
+ section = EfiSectionTE(self.ec, debug_info[0] + 0x4)
+ elif debug_info[2] == EfiFileSection.EFI_SECTION_PE32:
+ section = EfiSectionPE32(self.ec, debug_info[0] + 0x4)
+ else:
+ raise Exception('FirmwareVolume','Section Type not supported')
+
+ edk2_debugger.load_symbol_from_file(self.ec, section.get_debug_filepath(), section.get_debug_elfbase())
+
+ return debug_info
+
+ def load_all_symbols(self):
+ if self.DebugInfos == []:
+ self.get_debug_info()
+
+ for debug_info in self.DebugInfos:
+ if debug_info[2] == EfiFileSection.EFI_SECTION_TE:
+ section = EfiSectionTE(self.ec, debug_info[0] + 0x4)
+ elif debug_info[2] == EfiFileSection.EFI_SECTION_PE32:
+ section = EfiSectionPE32(self.ec, debug_info[0] + 0x4)
+ else:
+ continue
+
+ edk2_debugger.load_symbol_from_file(self.ec, section.get_debug_filepath(), section.get_debug_elfbase())
diff --git a/edk2/ArmPlatformPkg/Scripts/Ds5/system_table.py b/edk2/ArmPlatformPkg/Scripts/Ds5/system_table.py
new file mode 100644
index 000000000..f489e466a
--- /dev/null
+++ b/edk2/ArmPlatformPkg/Scripts/Ds5/system_table.py
@@ -0,0 +1,129 @@
+#
+# 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.
+#
+
+from arm_ds.debugger_v1 import DebugException
+
+import struct
+
+import edk2_debugger
+import firmware_volume
+
+class DebugInfoTable:
+ CONST_DEBUG_INFO_TABLE_GUID = ( 0x49152E77L, 0x47641ADAL, 0xFE7AA2B7L, 0x8B5ED9FEL)
+
+ DebugInfos = []
+
+ def __init__(self, ec, debug_info_table_header_offset):
+ self.ec = ec
+ self.base = debug_info_table_header_offset
+
+ def get_debug_info(self):
+ count = self.ec.getMemoryService().readMemory32(self.base + 0x4)
+ debug_info_table_base = self.ec.getMemoryService().readMemory32(self.base + 0x8)
+
+ self.DebugInfos = []
+
+ for i in range(0, count):
+ # Get the address of the structure EFI_DEBUG_IMAGE_INFO
+ debug_info = self.ec.getMemoryService().readMemory32(debug_info_table_base + (i * 4))
+ if debug_info:
+ debug_info_type = self.ec.getMemoryService().readMemory32(debug_info)
+ # Normal Debug Info Type
+ if debug_info_type == 1:
+ # Get the base address of the structure EFI_LOADED_IMAGE_PROTOCOL
+ loaded_image_protocol = self.ec.getMemoryService().readMemory32(debug_info + 0x4)
+
+ image_base = self.ec.getMemoryService().readMemory32(loaded_image_protocol + 0x20)
+ image_size = self.ec.getMemoryService().readMemory32(loaded_image_protocol + 0x28)
+
+ self.DebugInfos.append((image_base,image_size))
+
+ # Return (base, size)
+ def load_symbols_at(self, addr):
+ if self.DebugInfos == []:
+ self.get_debug_info()
+
+ found = False
+ for debug_info in self.DebugInfos:
+ if (addr >= debug_info[0]) and (addr < debug_info[0] + debug_info[1]):
+ section = firmware_volume.EfiSectionPE32(self.ec, debug_info[0])
+
+ edk2_debugger.load_symbol_from_file(self.ec, section.get_debug_filepath(), section.get_debug_elfbase())
+
+ found = True
+ return debug_info
+
+ if found == False:
+ raise Exception('DebugInfoTable','No symbol found at 0x%x' % addr)
+
+ def load_all_symbols(self):
+ if self.DebugInfos == []:
+ self.get_debug_info()
+
+ for debug_info in self.DebugInfos:
+ section = firmware_volume.EfiSectionPE32(self.ec, debug_info[0])
+
+ edk2_debugger.load_symbol_from_file(self.ec, section.get_debug_filepath(), section.get_debug_elfbase())
+
+ def dump(self):
+ self.get_debug_info()
+ for debug_info in self.DebugInfos:
+ base_pe32 = debug_info[0]
+ section = firmware_volume.EfiSectionPE32(self.ec, base_pe32)
+ print section.get_debug_filepath()
+
+class SystemTable:
+ CONST_ST_SIGNATURE = ('I','B','I',' ','S','Y','S','T')
+
+ def __init__(self, ec, membase, memsize):
+ self.membase = membase
+ self.memsize = memsize
+ self.ec = ec
+
+ found = False
+
+ # Start from the top of the memory
+ offset = self.membase + self.memsize
+ # Align to highest 4MB boundary
+ offset = offset & ~0x3FFFFF
+ # We should not have a System Table at the top of the System Memory
+ offset = offset - 0x400000
+
+ # Start at top and look on 4MB boundaries for system table ptr structure
+ while offset > self.membase:
+ try:
+ signature = struct.unpack("cccccccc", self.ec.getMemoryService().read(str(offset), 8, 32))
+ except DebugException:
+ raise Exception('SystemTable','Fail to access System Memory. Ensure all the memory in the region [0x%x;0x%X] is accessible.' % (membase,membase+memsize))
+ if signature == SystemTable.CONST_ST_SIGNATURE:
+ found = True
+ self.system_table_base = self.ec.getMemoryService().readMemory32(offset + 0x8)
+ break
+ offset = offset - 0x400000
+
+ if not found:
+ raise Exception('SystemTable','System Table not found in System Memory [0x%x;0x%X]' % (membase,membase+memsize))
+
+ def get_configuration_table(self, conf_table_guid):
+ # Number of configuration Table entry
+ conf_table_entry_count = self.ec.getMemoryService().readMemory32(self.system_table_base + 0x40)
+
+ # Get location of the Configuration Table entries
+ conf_table_offset = self.ec.getMemoryService().readMemory32(self.system_table_base + 0x44)
+
+ for i in range(0, conf_table_entry_count):
+ offset = conf_table_offset + (i * 0x14)
+ guid = struct.unpack("<IIII", self.ec.getMemoryService().read(str(offset), 16, 32))
+ if guid == conf_table_guid:
+ return self.ec.getMemoryService().readMemory32(offset + 0x10)
+
+ raise Exception('SystemTable','Configuration Table not found')
diff --git a/edk2/CryptoPkg/Library/BaseCryptLib/Pk/CryptAuthenticode.c b/edk2/CryptoPkg/Library/BaseCryptLib/Pk/CryptAuthenticode.c
index a4f62b22b..bb5f6d4b0 100644
--- a/edk2/CryptoPkg/Library/BaseCryptLib/Pk/CryptAuthenticode.c
+++ b/edk2/CryptoPkg/Library/BaseCryptLib/Pk/CryptAuthenticode.c
@@ -26,6 +26,12 @@ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
#include <openssl/x509.h>
#include <openssl/pkcs7.h>
+//
+// OID ASN.1 Value for SPC_INDIRECT_DATA_OBJID
+//
+UINT8 mSpcIndirectOidValue[] = {
+ 0x2B, 0x06, 0x01, 0x04, 0x01, 0x82, 0x37, 0x02, 0x01, 0x04
+ };
/**
Verifies the validility of a PE/COFF Authenticode Signature as described in "Windows
@@ -70,6 +76,7 @@ AuthenticodeVerify (
UINT8 *SpcIndirectDataContent;
UINT8 Asn1Byte;
UINTN ContentSize;
+ UINT8 *SpcIndirectDataOid;
//
// Check input parameters.
@@ -106,6 +113,19 @@ AuthenticodeVerify (
// some authenticode-specific structure. Use opaque ASN.1 string to retrieve
// PKCS#7 ContentInfo here.
//
+ SpcIndirectDataOid = (UINT8 *)(Pkcs7->d.sign->contents->type->data);
+ if (CompareMem (
+ SpcIndirectDataOid,
+ mSpcIndirectOidValue,
+ sizeof (mSpcIndirectOidValue)
+ ) != 0) {
+ //
+ // Un-matched SPC_INDIRECT_DATA_OBJID.
+ //
+ goto _Exit;
+ }
+
+
SpcIndirectDataContent = (UINT8 *)(Pkcs7->d.sign->contents->d.other->value.asn1_string->data);
//
diff --git a/edk2/CryptoPkg/Library/BaseCryptLib/Pk/CryptPkcs7Verify.c b/edk2/CryptoPkg/Library/BaseCryptLib/Pk/CryptPkcs7Verify.c
index ac481f7e6..745cf8729 100644
--- a/edk2/CryptoPkg/Library/BaseCryptLib/Pk/CryptPkcs7Verify.c
+++ b/edk2/CryptoPkg/Library/BaseCryptLib/Pk/CryptPkcs7Verify.c
@@ -242,8 +242,8 @@ X509PopCertificate (
X509 *X509Cert;
STACK_OF(X509) *CertStack;
BOOLEAN Status;
- int Result;
- int Length;
+ INT32 Result;
+ INT32 Length;
VOID *Buffer;
Status = FALSE;
diff --git a/edk2/CryptoPkg/Library/OpensslLib/EDKII_openssl-0.9.8w.patch b/edk2/CryptoPkg/Library/OpensslLib/EDKII_openssl-0.9.8w.patch
index daeb36079..a2ba8aeb4 100644
--- a/edk2/CryptoPkg/Library/OpensslLib/EDKII_openssl-0.9.8w.patch
+++ b/edk2/CryptoPkg/Library/OpensslLib/EDKII_openssl-0.9.8w.patch
@@ -182,6 +182,45 @@ Index: crypto/pkcs7/pk7_smime.c
PKCS7err(PKCS7_F_PKCS7_SIGN,PKCS7_R_PKCS7_ADD_SIGNATURE_ERROR);
goto err;
}
+@@ -173,7 +176,8 @@
+ STACK_OF(PKCS7_SIGNER_INFO) *sinfos;
+ PKCS7_SIGNER_INFO *si;
+ X509_STORE_CTX cert_ctx;
+- char buf[4096];
++ char *buf = NULL;
++ int bufsiz;
+ int i, j=0, k, ret = 0;
+ BIO *p7bio;
+ BIO *tmpin, *tmpout;
+@@ -284,10 +288,16 @@
+ BIO_set_mem_eof_return(tmpout, 0);
+ } else tmpout = out;
+
++ bufsiz = 4096;
++ buf = OPENSSL_malloc (bufsiz);
++ if (buf == NULL) {
++ goto err;
++ }
++
+ /* We now have to 'read' from p7bio to calculate digests etc. */
+ for (;;)
+ {
+- i=BIO_read(p7bio,buf,sizeof(buf));
++ i=BIO_read(p7bio,buf,bufsiz);
+ if (i <= 0) break;
+ if (tmpout) BIO_write(tmpout, buf, i);
+ }
+@@ -326,6 +336,10 @@
+
+ sk_X509_free(signers);
+
++ if (buf != NULL) {
++ OPENSSL_free (buf);
++ }
++
+ return ret;
+ }
+
Index: crypto/rand/rand_egd.c
===================================================================
--- crypto/rand/rand_egd.c (revision 1)
diff --git a/edk2/DuetPkg/Library/DuetBdsLib/BdsPlatform.h b/edk2/DuetPkg/Library/DuetBdsLib/BdsPlatform.h
index 564d488c1..4abb7b7f6 100644
--- a/edk2/DuetPkg/Library/DuetBdsLib/BdsPlatform.h
+++ b/edk2/DuetPkg/Library/DuetBdsLib/BdsPlatform.h
@@ -1,6 +1,6 @@
/*++
-Copyright (c) 2006 - 2011, Intel Corporation. All rights reserved.<BR>
+Copyright (c) 2006 - 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
which accompanies this distribution. The full text of the license may be found at
@@ -73,11 +73,13 @@ extern VENDOR_DEVICE_PATH gTerminalTypeDeviceNode;
#define PCI_DEVICE_PATH_NODE(Func, Dev) \
{ \
- HARDWARE_DEVICE_PATH, \
- HW_PCI_DP, \
{ \
- (UINT8) (sizeof (PCI_DEVICE_PATH)), \
- (UINT8) ((sizeof (PCI_DEVICE_PATH)) >> 8) \
+ HARDWARE_DEVICE_PATH, \
+ HW_PCI_DP, \
+ { \
+ (UINT8) (sizeof (PCI_DEVICE_PATH)), \
+ (UINT8) ((sizeof (PCI_DEVICE_PATH)) >> 8) \
+ } \
}, \
(Func), \
(Dev) \
diff --git a/edk2/EmbeddedPkg/Universal/MmcDxe/MmcBlockIo.c b/edk2/EmbeddedPkg/Universal/MmcDxe/MmcBlockIo.c
index c33705c80..839f3a003 100644
--- a/edk2/EmbeddedPkg/Universal/MmcDxe/MmcBlockIo.c
+++ b/edk2/EmbeddedPkg/Universal/MmcDxe/MmcBlockIo.c
@@ -215,12 +215,12 @@ MmcIdentificationMode (
DEBUG((EFI_D_ERROR, "MmcIdentificationMode() : Error MmcHwInitializationState\n"));
return Status;
}
- }
-
- Status = MmcHost->SendCommand (MmcHost, MMC_CMD0, 0);
- if (EFI_ERROR(Status)) {
- DEBUG((EFI_D_ERROR, "MmcIdentificationMode(MMC_CMD0): Error\n"));
- return Status;
+ }
+
+ Status = MmcHost->SendCommand (MmcHost, MMC_CMD0, 0);
+ if (EFI_ERROR(Status)) {
+ DEBUG((EFI_D_ERROR, "MmcIdentificationMode(MMC_CMD0): Error\n"));
+ return Status;
}
Status = MmcNotifyState (MmcHostInstance, MmcIdleState);
diff --git a/edk2/IntelFrameworkModulePkg/Bus/Isa/Ps2KeyboardDxe/Ps2KbdCtrller.c b/edk2/IntelFrameworkModulePkg/Bus/Isa/Ps2KeyboardDxe/Ps2KbdCtrller.c
index 4ad80c17c..2a20b789a 100644
--- a/edk2/IntelFrameworkModulePkg/Bus/Isa/Ps2KeyboardDxe/Ps2KbdCtrller.c
+++ b/edk2/IntelFrameworkModulePkg/Bus/Isa/Ps2KeyboardDxe/Ps2KbdCtrller.c
@@ -1519,16 +1519,18 @@ InitKeyboard (
// Perform a read to cleanup the Status Register's
// output buffer full bits within MAX TRY times
//
- while (!EFI_ERROR (Status) && TryTime < KEYBOARD_MAX_TRY) {
- Status = KeyboardRead (ConsoleIn, &CommandByte);
- TryTime ++;
- }
- //
- // Exceed the max try times. The device may be error.
- //
- if (TryTime == KEYBOARD_MAX_TRY) {
- Status = EFI_DEVICE_ERROR;
- goto Done;
+ if ((KeyReadStatusRegister (ConsoleIn) & KEYBOARD_STATUS_REGISTER_HAS_OUTPUT_DATA) != 0) {
+ while (!EFI_ERROR (Status) && TryTime < KEYBOARD_MAX_TRY) {
+ Status = KeyboardRead (ConsoleIn, &CommandByte);
+ TryTime ++;
+ }
+ //
+ // Exceed the max try times. The device may be error.
+ //
+ if (TryTime == KEYBOARD_MAX_TRY) {
+ Status = EFI_DEVICE_ERROR;
+ goto Done;
+ }
}
//
// We should disable mouse interface during the initialization process
@@ -1543,34 +1545,37 @@ InitKeyboard (
// time initialization
//
if ((KeyReadStatusRegister (ConsoleIn) & KEYBOARD_STATUS_REGISTER_SYSTEM_FLAG) != 0) {
- //
- // 8042 controller is already setup (by myself or by mouse driver):
- // See whether mouse interface is already enabled
- // which determines whether we should enable it later
- //
- //
- // Read the command byte of 8042 controller
- //
- Status = KeyboardCommand (ConsoleIn, KEYBOARD_8042_COMMAND_READ);
- if (EFI_ERROR (Status)) {
- KeyboardError (ConsoleIn, L"\n\r");
- goto Done;
- }
-
- Status = KeyboardRead (ConsoleIn, &CommandByte);
- if (EFI_ERROR (Status)) {
- KeyboardError (ConsoleIn, L"\n\r");
- goto Done;
- }
- //
- // Test the mouse enabling bit
- //
- if ((CommandByte & 0x20) != 0) {
- mEnableMouseInterface = FALSE;
+ if (!PcdGetBool (PcdFastPS2Detection)) {
+ //
+ // 8042 controller is already setup (by myself or by mouse driver):
+ // See whether mouse interface is already enabled
+ // which determines whether we should enable it later
+ //
+ //
+ // Read the command byte of 8042 controller
+ //
+ Status = KeyboardCommand (ConsoleIn, KEYBOARD_8042_COMMAND_READ);
+ if (EFI_ERROR (Status)) {
+ KeyboardError (ConsoleIn, L"\n\r");
+ goto Done;
+ }
+
+ Status = KeyboardRead (ConsoleIn, &CommandByte);
+ if (EFI_ERROR (Status)) {
+ KeyboardError (ConsoleIn, L"\n\r");
+ goto Done;
+ }
+ //
+ // Test the mouse enabling bit
+ //
+ if ((CommandByte & 0x20) != 0) {
+ mEnableMouseInterface = FALSE;
+ } else {
+ mEnableMouseInterface = TRUE;
+ }
} else {
- mEnableMouseInterface = TRUE;
- }
-
+ mEnableMouseInterface = FALSE;
+ }
} else {
//
// 8042 controller is not setup yet:
@@ -1580,36 +1585,38 @@ InitKeyboard (
//
// Disable keyboard and mouse interfaces
//
- Status = KeyboardCommand (ConsoleIn, KEYBOARD_8042_COMMAND_DISABLE_KEYBOARD_INTERFACE);
- if (EFI_ERROR (Status)) {
- KeyboardError (ConsoleIn, L"\n\r");
- goto Done;
- }
-
- Status = KeyboardCommand (ConsoleIn, KEYBOARD_8042_COMMAND_DISABLE_MOUSE_INTERFACE);
- if (EFI_ERROR (Status)) {
- KeyboardError (ConsoleIn, L"\n\r");
- goto Done;
- }
-
- REPORT_STATUS_CODE_WITH_DEVICE_PATH (
- EFI_PROGRESS_CODE,
- EFI_PERIPHERAL_KEYBOARD | EFI_P_KEYBOARD_PC_SELF_TEST,
- ConsoleIn->DevicePath
- );
- //
- // 8042 Controller Self Test
- //
- Status = KeyboardCommand (ConsoleIn, KEYBOARD_8042_COMMAND_CONTROLLER_SELF_TEST);
- if (EFI_ERROR (Status)) {
- KeyboardError (ConsoleIn, L"8042 controller command write error!\n\r");
- goto Done;
- }
-
- Status = KeyboardWaitForValue (ConsoleIn, 0x55);
- if (EFI_ERROR (Status)) {
- KeyboardError (ConsoleIn, L"8042 controller self test failed!\n\r");
- goto Done;
+ if (!PcdGetBool (PcdFastPS2Detection)) {
+ Status = KeyboardCommand (ConsoleIn, KEYBOARD_8042_COMMAND_DISABLE_KEYBOARD_INTERFACE);
+ if (EFI_ERROR (Status)) {
+ KeyboardError (ConsoleIn, L"\n\r");
+ goto Done;
+ }
+
+ Status = KeyboardCommand (ConsoleIn, KEYBOARD_8042_COMMAND_DISABLE_MOUSE_INTERFACE);
+ if (EFI_ERROR (Status)) {
+ KeyboardError (ConsoleIn, L"\n\r");
+ goto Done;
+ }
+
+ REPORT_STATUS_CODE_WITH_DEVICE_PATH (
+ EFI_PROGRESS_CODE,
+ EFI_PERIPHERAL_KEYBOARD | EFI_P_KEYBOARD_PC_SELF_TEST,
+ ConsoleIn->DevicePath
+ );
+ //
+ // 8042 Controller Self Test
+ //
+ Status = KeyboardCommand (ConsoleIn, KEYBOARD_8042_COMMAND_CONTROLLER_SELF_TEST);
+ if (EFI_ERROR (Status)) {
+ KeyboardError (ConsoleIn, L"8042 controller command write error!\n\r");
+ goto Done;
+ }
+
+ Status = KeyboardWaitForValue (ConsoleIn, 0x55);
+ if (EFI_ERROR (Status)) {
+ KeyboardError (ConsoleIn, L"8042 controller self test failed!\n\r");
+ goto Done;
+ }
}
//
// Don't enable mouse interface later
@@ -1865,34 +1872,37 @@ CheckKeyboardConnect (
EFI_STATUS Status;
UINTN WaitForValueTimeOutBcakup;
- Status = EFI_SUCCESS;
//
// enable keyboard itself and wait for its ack
// If can't receive ack, Keyboard should not be connected.
//
- Status = KeyboardWrite (
- ConsoleIn,
- KEYBOARD_KBEN
- );
-
- if (EFI_ERROR (Status)) {
- return FALSE;
- }
- //
- // wait for 1s
- //
- WaitForValueTimeOutBcakup = mWaitForValueTimeOut;
- mWaitForValueTimeOut = KEYBOARD_WAITFORVALUE_TIMEOUT;
- Status = KeyboardWaitForValue (
- ConsoleIn,
- KEYBOARD_CMDECHO_ACK
- );
- mWaitForValueTimeOut = WaitForValueTimeOutBcakup;
-
- if (EFI_ERROR (Status)) {
- return FALSE;
+ if (!PcdGetBool (PcdFastPS2Detection)) {
+ Status = KeyboardWrite (
+ ConsoleIn,
+ KEYBOARD_KBEN
+ );
+
+ if (EFI_ERROR (Status)) {
+ return FALSE;
+ }
+ //
+ // wait for 1s
+ //
+ WaitForValueTimeOutBcakup = mWaitForValueTimeOut;
+ mWaitForValueTimeOut = KEYBOARD_WAITFORVALUE_TIMEOUT;
+ Status = KeyboardWaitForValue (
+ ConsoleIn,
+ KEYBOARD_CMDECHO_ACK
+ );
+ mWaitForValueTimeOut = WaitForValueTimeOutBcakup;
+
+ if (EFI_ERROR (Status)) {
+ return FALSE;
+ }
+
+ return TRUE;
+ } else {
+ return TRUE;
}
-
- return TRUE;
}
diff --git a/edk2/IntelFrameworkModulePkg/Bus/Isa/Ps2KeyboardDxe/Ps2Keyboard.c b/edk2/IntelFrameworkModulePkg/Bus/Isa/Ps2KeyboardDxe/Ps2Keyboard.c
index c73cf9361..4f8799087 100644
--- a/edk2/IntelFrameworkModulePkg/Bus/Isa/Ps2KeyboardDxe/Ps2Keyboard.c
+++ b/edk2/IntelFrameworkModulePkg/Bus/Isa/Ps2KeyboardDxe/Ps2Keyboard.c
@@ -263,15 +263,17 @@ KbdControllerDriverStart (
//
// Return code is ignored on purpose.
//
- KeyboardRead (ConsoleIn, &Data);
- if ((KeyReadStatusRegister (ConsoleIn) & (KBC_PARE | KBC_TIM)) == (KBC_PARE | KBC_TIM)) {
- //
- // If nobody decodes KBC I/O port, it will read back as 0xFF.
- // Check the Time-Out and Parity bit to see if it has an active KBC in system
- //
- Status = EFI_DEVICE_ERROR;
- StatusCode = EFI_PERIPHERAL_KEYBOARD | EFI_P_EC_NOT_DETECTED;
- goto ErrorExit;
+ if (!PcdGetBool (PcdFastPS2Detection)) {
+ KeyboardRead (ConsoleIn, &Data);
+ if ((KeyReadStatusRegister (ConsoleIn) & (KBC_PARE | KBC_TIM)) == (KBC_PARE | KBC_TIM)) {
+ //
+ // If nobody decodes KBC I/O port, it will read back as 0xFF.
+ // Check the Time-Out and Parity bit to see if it has an active KBC in system
+ //
+ Status = EFI_DEVICE_ERROR;
+ StatusCode = EFI_PERIPHERAL_KEYBOARD | EFI_P_EC_NOT_DETECTED;
+ goto ErrorExit;
+ }
}
//
diff --git a/edk2/IntelFrameworkModulePkg/Bus/Isa/Ps2KeyboardDxe/Ps2keyboardDxe.inf b/edk2/IntelFrameworkModulePkg/Bus/Isa/Ps2KeyboardDxe/Ps2keyboardDxe.inf
index 61fd036c3..f2cc8b006 100644
--- a/edk2/IntelFrameworkModulePkg/Bus/Isa/Ps2KeyboardDxe/Ps2keyboardDxe.inf
+++ b/edk2/IntelFrameworkModulePkg/Bus/Isa/Ps2KeyboardDxe/Ps2keyboardDxe.inf
@@ -68,6 +68,9 @@
[FeaturePcd]
gEfiIntelFrameworkModulePkgTokenSpaceGuid.PcdPs2KbdExtendedVerification
+[Pcd]
+ gEfiIntelFrameworkModulePkgTokenSpaceGuid.PcdFastPS2Detection
+
# [Event]
# ##
# # Event will be signaled for WaitForKey event.
diff --git a/edk2/IntelFrameworkModulePkg/Csm/BiosThunk/KeyboardDxe/BiosKeyboard.c b/edk2/IntelFrameworkModulePkg/Csm/BiosThunk/KeyboardDxe/BiosKeyboard.c
index 3f0f9b699..4ee20df1f 100644
--- a/edk2/IntelFrameworkModulePkg/Csm/BiosThunk/KeyboardDxe/BiosKeyboard.c
+++ b/edk2/IntelFrameworkModulePkg/Csm/BiosThunk/KeyboardDxe/BiosKeyboard.c
@@ -1037,95 +1037,96 @@ BiosKeyboardReset (
// if not skip step 4&5 and jump to step 6 to selftest KBC and report this
// else go step 4
//
- if ((KeyReadStatusRegister (BiosKeyboardPrivate) & KBC_STSREG_VIA64_SYSF) != 0) {
- //
- // 4
- // CheckMouseStatus to decide enable it later or not
- //
- //
- // Read the command byte of KBC
- //
- Status = KeyboardCommand (
- BiosKeyboardPrivate,
- KBC_CMDREG_VIA64_CMDBYTE_R
- );
-
- if (EFI_ERROR (Status)) {
- Status = EFI_DEVICE_ERROR;
- goto Exit;
- }
-
- Status = KeyboardRead (
- BiosKeyboardPrivate,
- &CommandByte
- );
-
- if (EFI_ERROR (Status)) {
- Status = EFI_DEVICE_ERROR;
- goto Exit;
- }
- //
- // Check mouse enabled or not before
- //
- if ((CommandByte & KB_CMMBYTE_DISABLE_AUX) != 0) {
- MouseEnable = FALSE;
+ if (!PcdGetBool (PcdFastPS2Detection)) {
+ if ((KeyReadStatusRegister (BiosKeyboardPrivate) & KBC_STSREG_VIA64_SYSF) != 0) {
+ //
+ // 4
+ // CheckMouseStatus to decide enable it later or not
+ //
+ //
+ // Read the command byte of KBC
+ //
+ Status = KeyboardCommand (
+ BiosKeyboardPrivate,
+ KBC_CMDREG_VIA64_CMDBYTE_R
+ );
+
+ if (EFI_ERROR (Status)) {
+ Status = EFI_DEVICE_ERROR;
+ goto Exit;
+ }
+
+ Status = KeyboardRead (
+ BiosKeyboardPrivate,
+ &CommandByte
+ );
+
+ if (EFI_ERROR (Status)) {
+ Status = EFI_DEVICE_ERROR;
+ goto Exit;
+ }
+ //
+ // Check mouse enabled or not before
+ //
+ if ((CommandByte & KB_CMMBYTE_DISABLE_AUX) != 0) {
+ MouseEnable = FALSE;
+ } else {
+ MouseEnable = TRUE;
+ }
+ //
+ // 5
+ // disable mouse (via KBC) and Keyborad device
+ //
+ Status = KeyboardCommand (
+ BiosKeyboardPrivate,
+ KBC_CMDREG_VIA64_AUX_DISABLE
+ );
+
+ if (EFI_ERROR (Status)) {
+ Status = EFI_DEVICE_ERROR;
+ goto Exit;
+ }
+
+ Status = KeyboardCommand (
+ BiosKeyboardPrivate,
+ KBC_CMDREG_VIA64_KB_DISABLE
+ );
+
+ if (EFI_ERROR (Status)) {
+ Status = EFI_DEVICE_ERROR;
+ goto Exit;
+ }
} else {
- MouseEnable = TRUE;
- }
- //
- // 5
- // disable mouse (via KBC) and Keyborad device
- //
- Status = KeyboardCommand (
- BiosKeyboardPrivate,
- KBC_CMDREG_VIA64_AUX_DISABLE
- );
-
- if (EFI_ERROR (Status)) {
- Status = EFI_DEVICE_ERROR;
- goto Exit;
- }
-
- Status = KeyboardCommand (
- BiosKeyboardPrivate,
- KBC_CMDREG_VIA64_KB_DISABLE
- );
-
- if (EFI_ERROR (Status)) {
- Status = EFI_DEVICE_ERROR;
- goto Exit;
- }
-
- } else {
- //
- // 6
- // KBC Self Test
- //
- //
- // Report a Progress Code for performing a self test on the keyboard controller
- //
- REPORT_STATUS_CODE (
- EFI_PROGRESS_CODE,
- EFI_PERIPHERAL_KEYBOARD | EFI_P_KEYBOARD_PC_SELF_TEST
- );
-
- Status = KeyboardCommand (
- BiosKeyboardPrivate,
- KBC_CMDREG_VIA64_KBC_SLFTEST
- );
- if (EFI_ERROR (Status)) {
- Status = EFI_DEVICE_ERROR;
- goto Exit;
- }
-
- Status = KeyboardWaitForValue (
- BiosKeyboardPrivate,
- KBC_CMDECHO_KBCSLFTEST_OK,
- KEYBOARD_WAITFORVALUE_TIMEOUT
- );
- if (EFI_ERROR (Status)) {
- Status = EFI_DEVICE_ERROR;
- goto Exit;
+ //
+ // 6
+ // KBC Self Test
+ //
+ //
+ // Report a Progress Code for performing a self test on the keyboard controller
+ //
+ REPORT_STATUS_CODE (
+ EFI_PROGRESS_CODE,
+ EFI_PERIPHERAL_KEYBOARD | EFI_P_KEYBOARD_PC_SELF_TEST
+ );
+
+ Status = KeyboardCommand (
+ BiosKeyboardPrivate,
+ KBC_CMDREG_VIA64_KBC_SLFTEST
+ );
+ if (EFI_ERROR (Status)) {
+ Status = EFI_DEVICE_ERROR;
+ goto Exit;
+ }
+
+ Status = KeyboardWaitForValue (
+ BiosKeyboardPrivate,
+ KBC_CMDECHO_KBCSLFTEST_OK,
+ KEYBOARD_WAITFORVALUE_TIMEOUT
+ );
+ if (EFI_ERROR (Status)) {
+ Status = EFI_DEVICE_ERROR;
+ goto Exit;
+ }
}
}
//
@@ -1321,14 +1322,16 @@ BiosKeyboardReset (
// Done for validating keyboard. Enable keyboard (via KBC)
// and recover the command byte to proper value
//
- Status = KeyboardCommand (
- BiosKeyboardPrivate,
- KBC_CMDREG_VIA64_KB_ENABLE
- );
-
- if (EFI_ERROR (Status)) {
- Status = EFI_DEVICE_ERROR;
- goto Exit;
+ if (!PcdGetBool (PcdFastPS2Detection)) {
+ Status = KeyboardCommand (
+ BiosKeyboardPrivate,
+ KBC_CMDREG_VIA64_KB_ENABLE
+ );
+
+ if (EFI_ERROR (Status)) {
+ Status = EFI_DEVICE_ERROR;
+ goto Exit;
+ }
}
//
@@ -1674,35 +1677,38 @@ CheckKeyboardConnect (
// enable keyboard itself and wait for its ack
// If can't receive ack, Keyboard should not be connected.
//
- Status = KeyboardWrite (
- BiosKeyboardPrivate,
- KBC_INPBUF_VIA60_KBEN
- );
- if (EFI_ERROR (Status)) {
- DEBUG ((EFI_D_ERROR, "[KBD]CheckKeyboardConnect - Keyboard enable failed!\n"));
- REPORT_STATUS_CODE (
- EFI_ERROR_CODE | EFI_ERROR_MINOR,
- EFI_PERIPHERAL_KEYBOARD | EFI_P_EC_CONTROLLER_ERROR
- );
- return FALSE;
- }
+ if (!PcdGetBool (PcdFastPS2Detection)) {
+ Status = KeyboardWrite (
+ BiosKeyboardPrivate,
+ KBC_INPBUF_VIA60_KBEN
+ );
+ if (EFI_ERROR (Status)) {
+ DEBUG ((EFI_D_ERROR, "[KBD]CheckKeyboardConnect - Keyboard enable failed!\n"));
+ REPORT_STATUS_CODE (
+ EFI_ERROR_CODE | EFI_ERROR_MINOR,
+ EFI_PERIPHERAL_KEYBOARD | EFI_P_EC_CONTROLLER_ERROR
+ );
+ return FALSE;
+ }
- Status = KeyboardWaitForValue (
- BiosKeyboardPrivate,
- KBC_CMDECHO_ACK,
- KEYBOARD_WAITFORVALUE_TIMEOUT
- );
+ Status = KeyboardWaitForValue (
+ BiosKeyboardPrivate,
+ KBC_CMDECHO_ACK,
+ KEYBOARD_WAITFORVALUE_TIMEOUT
+ );
- if (EFI_ERROR (Status)) {
- DEBUG ((EFI_D_ERROR, "[KBD]CheckKeyboardConnect - Timeout!\n"));
- REPORT_STATUS_CODE (
- EFI_ERROR_CODE | EFI_ERROR_MINOR,
- EFI_PERIPHERAL_KEYBOARD | EFI_P_EC_CONTROLLER_ERROR
- );
- return FALSE;
+ if (EFI_ERROR (Status)) {
+ DEBUG ((EFI_D_ERROR, "[KBD]CheckKeyboardConnect - Timeout!\n"));
+ REPORT_STATUS_CODE (
+ EFI_ERROR_CODE | EFI_ERROR_MINOR,
+ EFI_PERIPHERAL_KEYBOARD | EFI_P_EC_CONTROLLER_ERROR
+ );
+ return FALSE;
+ }
+ return TRUE;
+ } else {
+ return TRUE;
}
-
- return TRUE;
}
/**
diff --git a/edk2/IntelFrameworkModulePkg/Csm/BiosThunk/KeyboardDxe/KeyboardDxe.inf b/edk2/IntelFrameworkModulePkg/Csm/BiosThunk/KeyboardDxe/KeyboardDxe.inf
index 28ef29bf1..ee79f6b60 100644
--- a/edk2/IntelFrameworkModulePkg/Csm/BiosThunk/KeyboardDxe/KeyboardDxe.inf
+++ b/edk2/IntelFrameworkModulePkg/Csm/BiosThunk/KeyboardDxe/KeyboardDxe.inf
@@ -68,4 +68,7 @@
gEfiDevicePathProtocolGuid # PROTOCOL ALWAYS_CONSUMED
[FeaturePcd]
- gEfiIntelFrameworkModulePkgTokenSpaceGuid.PcdPs2KbdExtendedVerification|FALSE \ No newline at end of file
+ gEfiIntelFrameworkModulePkgTokenSpaceGuid.PcdPs2KbdExtendedVerification|FALSE
+
+[Pcd]
+ gEfiIntelFrameworkModulePkgTokenSpaceGuid.PcdFastPS2Detection \ No newline at end of file
diff --git a/edk2/IntelFrameworkModulePkg/IntelFrameworkModulePkg.dec b/edk2/IntelFrameworkModulePkg/IntelFrameworkModulePkg.dec
index 6a6228837..1625fd5cc 100644
--- a/edk2/IntelFrameworkModulePkg/IntelFrameworkModulePkg.dec
+++ b/edk2/IntelFrameworkModulePkg/IntelFrameworkModulePkg.dec
@@ -144,8 +144,9 @@
gEfiIntelFrameworkModulePkgTokenSpaceGuid.PcdIsaBusSupportedFeatures|0x05|UINT8|0x00010040
[PcdsDynamic, PcdsDynamicEx]
- ## PCD is used to mark if the machine has complete one boot cycle before.
- # After the complete boot, the variable BootState will be set to TRUE.
+ ## The PCD is used to mark whether the machine is in first boot cycle.
+ # TRUE means the machine is in first boot cycle. After completing the first boot,
+ # the PCD's value will be updated to FALSE.
gEfiIntelFrameworkModulePkgTokenSpaceGuid.PcdBootState|TRUE|BOOLEAN|0x0001002f
## Timeout value for displaying progressing bar in before boot OS.
@@ -219,4 +220,7 @@
## The PCD is used to specify the high PMM (Post Memory Manager) size with bytes above 1MB.
# The value should be a multiple of 4KB.
gEfiIntelFrameworkModulePkgTokenSpaceGuid.PcdHighPmmMemorySize|0x400000|UINT32|0x3000000a
- \ No newline at end of file
+
+ ## This PCD specifies whether to use the optimized timing for best PS2 detection performance.
+ # Note this PCD could be set to TRUE for best boot performance and set to FALSE for best device compatibility.
+ gEfiIntelFrameworkModulePkgTokenSpaceGuid.PcdFastPS2Detection|FALSE|BOOLEAN|0x3000000b \ No newline at end of file
diff --git a/edk2/IntelFrameworkModulePkg/Universal/Acpi/AcpiS3SaveDxe/AcpiS3Save.c b/edk2/IntelFrameworkModulePkg/Universal/Acpi/AcpiS3SaveDxe/AcpiS3Save.c
index 5a021d2ca..afdfbf536 100644
--- a/edk2/IntelFrameworkModulePkg/Universal/Acpi/AcpiS3SaveDxe/AcpiS3Save.c
+++ b/edk2/IntelFrameworkModulePkg/Universal/Acpi/AcpiS3SaveDxe/AcpiS3Save.c
@@ -58,7 +58,7 @@ EFI_ACPI_S3_SAVE_PROTOCOL mS3Save = {
};
EFI_GUID mAcpiS3IdtrProfileGuid = {
- 0xdea652b0, 0xd587, 0x4c54, 0xb5, 0xb4, 0xc6, 0x82, 0xe7, 0xa0, 0xaa, 0x3d
+ 0xdea652b0, 0xd587, 0x4c54, { 0xb5, 0xb4, 0xc6, 0x82, 0xe7, 0xa0, 0xaa, 0x3d }
};
/**
diff --git a/edk2/IntelFrameworkModulePkg/Universal/BdsDxe/Bds.h b/edk2/IntelFrameworkModulePkg/Universal/BdsDxe/Bds.h
index 008d13e41..0929f1d27 100644
--- a/edk2/IntelFrameworkModulePkg/Universal/BdsDxe/Bds.h
+++ b/edk2/IntelFrameworkModulePkg/Universal/BdsDxe/Bds.h
@@ -1,7 +1,7 @@
/** @file
Head file for BDS Architectural Protocol implementation
-Copyright (c) 2004 - 2011, Intel Corporation. All rights reserved.<BR>
+Copyright (c) 2004 - 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
which accompanies this distribution. The full text of the license may be found at
@@ -34,6 +34,7 @@ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
#include <Guid/StatusCodeDataTypeId.h>
#include <Guid/LegacyDevOrder.h>
#include <Guid/BdsHii.h>
+#include <Guid/ConnectConInEvent.h>
#include <Protocol/GenericMemoryTest.h>
#include <Protocol/FormBrowser2.h>
#include <Protocol/HiiConfigAccess.h>
diff --git a/edk2/IntelFrameworkModulePkg/Universal/BdsDxe/BdsDxe.inf b/edk2/IntelFrameworkModulePkg/Universal/BdsDxe/BdsDxe.inf
index 0134f9b7d..a60738e94 100644
--- a/edk2/IntelFrameworkModulePkg/Universal/BdsDxe/BdsDxe.inf
+++ b/edk2/IntelFrameworkModulePkg/Universal/BdsDxe/BdsDxe.inf
@@ -116,7 +116,6 @@
## SOMETIMES_PRODUCES ## Variable:L"BootXX" (Boot option variable)
## SOMETIMES_PRODUCES ## Variable:L"PlatformLang" (Platform supported languange in Rfc4646 format)
## SOMETIMES_PRODUCES ## Variable:L"Lang" (Platform supported languange in Iso639 format)
- ## SOMETIMES_PRODUCES ## Variable:L"KeyOrder" (Number of hotkey)
## SOMETIMES_PRODUCES ## Variable:L"KeyXX" (Hotkey option variable)
## PRODUCES ## Variable:L"HwErrRecSupport" (The level of platform supported hardware Error Record Persistence)
## SOMETIMES_PRODUCES ## Variable:L"BootOptionSupport" (The feature supported in boot option menu, value could be: EFI_BOOT_OPTION_SUPPORT_KEY, EFI_BOOT_OPTION_SUPPORT_APP
@@ -141,6 +140,7 @@
gBootManagerFormSetGuid ## SOMETIMES_PRODUCES ## BootManager HII Package
gDeviceManagerFormSetGuid ## SOMETIMES_PRODUCES ## DeviceManager HII Package
gDriverHealthFormSetGuid ## SOMETIMES_PRODUCES ## DriverHealth HII Package
+ gConnectConInEventGuid ## CONSUMES ## GUID (Connect ConIn Event)
[Protocols]
gEfiSimpleFileSystemProtocolGuid ## PROTOCOL CONSUMES
diff --git a/edk2/IntelFrameworkModulePkg/Universal/BdsDxe/BdsEntry.c b/edk2/IntelFrameworkModulePkg/Universal/BdsDxe/BdsEntry.c
index 7949d0995..a91962537 100644
--- a/edk2/IntelFrameworkModulePkg/Universal/BdsDxe/BdsEntry.c
+++ b/edk2/IntelFrameworkModulePkg/Universal/BdsDxe/BdsEntry.c
@@ -72,6 +72,24 @@ BdsInitialize (
return Status;
}
+
+/**
+ An empty function to pass error checking of CreateEventEx ().
+
+ @param Event Event whose notification function is being invoked.
+ @param Context Pointer to the notification function's context,
+ which is implementation-dependent.
+
+**/
+VOID
+EFIAPI
+BdsEmptyCallbackFunction (
+ IN EFI_EVENT Event,
+ IN VOID *Context
+ )
+{
+}
+
/**
This function attempts to boot for the boot order specified
@@ -93,12 +111,14 @@ BdsBootDeviceSelect (
CHAR16 Buffer[20];
BOOLEAN BootNextExist;
LIST_ENTRY *LinkBootNext;
+ EFI_EVENT ConnectConInEvent;
//
// Got the latest boot option
//
BootNextExist = FALSE;
LinkBootNext = NULL;
+ ConnectConInEvent = NULL;
InitializeListHead (&BootLists);
//
@@ -106,6 +126,23 @@ BdsBootDeviceSelect (
//
ZeroMem (Buffer, sizeof (Buffer));
+ //
+ // Create Event to signal ConIn connection request
+ //
+ if (PcdGetBool (PcdConInConnectOnDemand)) {
+ Status = gBS->CreateEventEx (
+ EVT_NOTIFY_SIGNAL,
+ TPL_CALLBACK,
+ BdsEmptyCallbackFunction,
+ NULL,
+ &gConnectConInEventGuid,
+ &ConnectConInEvent
+ );
+ if (EFI_ERROR(Status)) {
+ ConnectConInEvent = NULL;
+ }
+ }
+
if (mBootNext != NULL) {
//
// Indicate we have the boot next variable, so this time
@@ -172,6 +209,13 @@ BdsBootDeviceSelect (
//
if (Link == &BootLists) {
//
+ // When LazyConIn enabled, signal connect ConIn event before enter UI
+ //
+ if (PcdGetBool (PcdConInConnectOnDemand) && ConnectConInEvent != NULL) {
+ gBS->SignalEvent (ConnectConInEvent);
+ }
+
+ //
// There are two ways to enter here:
// 1. There is no active boot option, give user chance to
// add new boot option
@@ -248,6 +292,14 @@ BdsBootDeviceSelect (
// Boot success, then stop process the boot order, and
// present the boot manager menu, front page
//
+
+ //
+ // When LazyConIn enabled, signal connect ConIn Event before enter UI
+ //
+ if (PcdGetBool (PcdConInConnectOnDemand) && ConnectConInEvent != NULL) {
+ gBS->SignalEvent (ConnectConInEvent);
+ }
+
Timeout = 0xffff;
PlatformBdsEnterFrontPage (Timeout, FALSE);
diff --git a/edk2/IntelFrameworkModulePkg/Universal/BdsDxe/BootMaint/ConsoleOption.c b/edk2/IntelFrameworkModulePkg/Universal/BdsDxe/BootMaint/ConsoleOption.c
index ffa88b4d8..f216b4a03 100644
--- a/edk2/IntelFrameworkModulePkg/Universal/BdsDxe/BootMaint/ConsoleOption.c
+++ b/edk2/IntelFrameworkModulePkg/Universal/BdsDxe/BootMaint/ConsoleOption.c
@@ -1,7 +1,7 @@
/** @file
handles console redirection from boot manager
-Copyright (c) 2004 - 2010, Intel Corporation. All rights reserved.<BR>
+Copyright (c) 2004 - 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
which accompanies this distribution. The full text of the license may be found at
@@ -14,12 +14,16 @@ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
#include "BootMaint.h"
-UART_FLOW_CONTROL_DEVICE_PATH mFlowControlDevicePath =
-{
- MESSAGING_DEVICE_PATH,
- MSG_VENDOR_DP,
- (UINT8)(sizeof(UART_FLOW_CONTROL_DEVICE_PATH)),
- (UINT8)((sizeof(UART_FLOW_CONTROL_DEVICE_PATH)) >> 8),
+UART_FLOW_CONTROL_DEVICE_PATH mFlowControlDevicePath =
+{
+ {
+ MESSAGING_DEVICE_PATH,
+ MSG_VENDOR_DP,
+ {
+ (UINT8)(sizeof(UART_FLOW_CONTROL_DEVICE_PATH)),
+ (UINT8)((sizeof(UART_FLOW_CONTROL_DEVICE_PATH)) >> 8)
+ }
+ },
DEVICE_PATH_MESSAGING_UART_FLOW_CONTROL,
UART_FLOW_CONTROL_HARDWARE
};
diff --git a/edk2/IntelFrameworkModulePkg/Universal/BdsDxe/Hotkey.c b/edk2/IntelFrameworkModulePkg/Universal/BdsDxe/Hotkey.c
index 55b615d6d..1a3ec1ff8 100644
--- a/edk2/IntelFrameworkModulePkg/Universal/BdsDxe/Hotkey.c
+++ b/edk2/IntelFrameworkModulePkg/Universal/BdsDxe/Hotkey.c
@@ -65,241 +65,6 @@ IsKeyOptionValid (
}
/**
- Create Key#### for the given hotkey.
-
- @param KeyOption The Hot Key Option to be added.
- @param KeyOptionNumber The key option number for Key#### (optional).
-
- @retval EFI_SUCCESS Register hotkey successfully.
- @retval EFI_INVALID_PARAMETER The hotkey option is invalid.
- @retval EFI_OUT_OF_RESOURCES Fail to allocate memory resource.
-
-**/
-EFI_STATUS
-RegisterHotkey (
- IN EFI_KEY_OPTION *KeyOption,
- OUT UINT16 *KeyOptionNumber
-)
-{
- UINT16 KeyOptionName[10];
- UINT16 *KeyOrder;
- UINTN KeyOrderSize;
- UINT16 *NewKeyOrder;
- UINTN Index;
- UINT16 MaxOptionNumber;
- UINT16 RegisterOptionNumber;
- EFI_KEY_OPTION *TempOption;
- UINTN TempOptionSize;
- EFI_STATUS Status;
- UINTN KeyOptionSize;
- BOOLEAN UpdateBootOption;
-
- //
- // Validate the given key option
- //
- if (!IsKeyOptionValid (KeyOption)) {
- return EFI_INVALID_PARAMETER;
- }
-
- KeyOptionSize = sizeof (EFI_KEY_OPTION) + KEY_OPTION_INPUT_KEY_COUNT (KeyOption) * sizeof (EFI_INPUT_KEY);
- UpdateBootOption = FALSE;
-
- //
- // Check whether HotKey conflict with keys used by Setup Browser
- //
- KeyOrder = BdsLibGetVariableAndSize (
- VAR_KEY_ORDER,
- &gEfiGlobalVariableGuid,
- &KeyOrderSize
- );
- if (KeyOrder == NULL) {
- KeyOrderSize = 0;
- }
-
- //
- // Find free key option number
- //
- MaxOptionNumber = 0;
- TempOption = NULL;
- for (Index = 0; Index < KeyOrderSize / sizeof (UINT16); Index++) {
- if (MaxOptionNumber < KeyOrder[Index]) {
- MaxOptionNumber = KeyOrder[Index];
- }
-
- UnicodeSPrint (KeyOptionName, sizeof (KeyOptionName), L"Key%04x", KeyOrder[Index]);
- TempOption = BdsLibGetVariableAndSize (
- KeyOptionName,
- &gEfiGlobalVariableGuid,
- &TempOptionSize
- );
- ASSERT (TempOption != NULL);
-
- if (CompareMem (TempOption, KeyOption, TempOptionSize) == 0) {
- //
- // Got the option, so just return
- //
- FreePool (TempOption);
- FreePool (KeyOrder);
- return EFI_SUCCESS;
- }
-
- if (KeyOption->KeyData == TempOption->KeyData) {
- if (CompareMem (
- ((UINT8 *) TempOption) + sizeof (EFI_KEY_OPTION),
- ((UINT8 *) KeyOption) + sizeof (EFI_KEY_OPTION),
- KeyOptionSize - sizeof (EFI_KEY_OPTION)
- ) == 0) {
- //
- // Hotkey is the same but BootOption changed, need update
- //
- UpdateBootOption = TRUE;
- break;
- }
- }
-
- FreePool (TempOption);
- }
-
- if (UpdateBootOption) {
- RegisterOptionNumber = KeyOrder[Index];
- FreePool (TempOption);
- } else {
- RegisterOptionNumber = (UINT16) (MaxOptionNumber + 1);
- }
-
- if (KeyOptionNumber != NULL) {
- *KeyOptionNumber = RegisterOptionNumber;
- }
-
- //
- // Create variable Key####
- //
- UnicodeSPrint (KeyOptionName, sizeof (KeyOptionName), L"Key%04x", RegisterOptionNumber);
- Status = gRT->SetVariable (
- KeyOptionName,
- &gEfiGlobalVariableGuid,
- EFI_VARIABLE_BOOTSERVICE_ACCESS | EFI_VARIABLE_RUNTIME_ACCESS | EFI_VARIABLE_NON_VOLATILE,
- KeyOptionSize,
- KeyOption
- );
- if (EFI_ERROR (Status)) {
- FreePool (KeyOrder);
- return Status;
- }
-
- //
- // Update the key order variable - "KeyOrder"
- //
- if (!UpdateBootOption) {
- Index = KeyOrderSize / sizeof (UINT16);
- KeyOrderSize += sizeof (UINT16);
- }
-
- NewKeyOrder = AllocatePool (KeyOrderSize);
- if (NewKeyOrder == NULL) {
- FreePool (KeyOrder);
- return EFI_OUT_OF_RESOURCES;
- }
-
- if (KeyOrder != NULL) {
- CopyMem (NewKeyOrder, KeyOrder, KeyOrderSize);
- }
-
- NewKeyOrder[Index] = RegisterOptionNumber;
-
- Status = gRT->SetVariable (
- VAR_KEY_ORDER,
- &gEfiGlobalVariableGuid,
- EFI_VARIABLE_BOOTSERVICE_ACCESS | EFI_VARIABLE_RUNTIME_ACCESS | EFI_VARIABLE_NON_VOLATILE,
- KeyOrderSize,
- NewKeyOrder
- );
-
- FreePool (KeyOrder);
- FreePool (NewKeyOrder);
-
- return Status;
-}
-
-/**
-
- Delete Key#### for the given Key Option number.
-
- @param KeyOptionNumber Key option number for Key####
-
- @retval EFI_SUCCESS Unregister hotkey successfully.
- @retval EFI_NOT_FOUND No Key#### is found for the given Key Option number.
-
-**/
-EFI_STATUS
-UnregisterHotkey (
- IN UINT16 KeyOptionNumber
-)
-{
- UINT16 KeyOption[10];
- UINTN Index;
- EFI_STATUS Status;
- UINTN Index2Del;
- UINT16 *KeyOrder;
- UINTN KeyOrderSize;
-
- //
- // Delete variable Key####
- //
- UnicodeSPrint (KeyOption, sizeof (KeyOption), L"Key%04x", KeyOptionNumber);
- gRT->SetVariable (
- KeyOption,
- &gEfiGlobalVariableGuid,
- EFI_VARIABLE_BOOTSERVICE_ACCESS | EFI_VARIABLE_RUNTIME_ACCESS | EFI_VARIABLE_NON_VOLATILE,
- 0,
- NULL
- );
-
- //
- // Adjust key order array
- //
- KeyOrder = BdsLibGetVariableAndSize (
- VAR_KEY_ORDER,
- &gEfiGlobalVariableGuid,
- &KeyOrderSize
- );
- if (KeyOrder == NULL) {
- return EFI_SUCCESS;
- }
-
- Index2Del = 0;
- for (Index = 0; Index < KeyOrderSize / sizeof (UINT16); Index++) {
- if (KeyOrder[Index] == KeyOptionNumber) {
- Index2Del = Index;
- break;
- }
- }
-
- if (Index != KeyOrderSize / sizeof (UINT16)) {
- //
- // KeyOptionNumber found in "KeyOrder", delete it
- //
- for (Index = Index2Del; Index < KeyOrderSize / sizeof (UINT16) - 1; Index++) {
- KeyOrder[Index] = KeyOrder[Index + 1];
- }
-
- KeyOrderSize -= sizeof (UINT16);
- }
-
- Status = gRT->SetVariable (
- VAR_KEY_ORDER,
- &gEfiGlobalVariableGuid,
- EFI_VARIABLE_BOOTSERVICE_ACCESS | EFI_VARIABLE_RUNTIME_ACCESS | EFI_VARIABLE_NON_VOLATILE,
- KeyOrderSize,
- KeyOrder
- );
-
- FreePool (KeyOrder);
-
- return Status;
-}
-
-/**
Try to boot the boot option triggered by hotkey.
@retval EFI_SUCCESS There is HotkeyBootOption & it is processed
@retval EFI_NOT_FOUND There is no HotkeyBootOption
@@ -635,11 +400,120 @@ HotkeyInsertList (
}
/**
+ Return TRUE when the variable pointed by Name and Guid is a Key#### variable.
+
+ @param Name The name of the variable.
+ @param Guid The GUID of the variable.
+ @param OptionNumber Return the option number parsed from the Name.
+
+ @retval TRUE The variable pointed by Name and Guid is a Key#### variable.
+ @retval FALSE The variable pointed by Name and Guid isn't a Key#### variable.
+**/
+BOOLEAN
+IsKeyOptionVariable (
+ CHAR16 *Name,
+ EFI_GUID *Guid,
+ UINT16 *OptionNumber
+ )
+{
+ UINTN Index;
+
+ if (!CompareGuid (Guid, &gEfiGlobalVariableGuid) ||
+ (StrSize (Name) != sizeof (L"Key####")) ||
+ (StrnCmp (Name, L"Key", 3) != 0)
+ ) {
+ return FALSE;
+ }
+
+ *OptionNumber = 0;
+ for (Index = 3; Index < 7; Index++) {
+ if ((Name[Index] >= L'0') && (Name[Index] <= L'9')) {
+ *OptionNumber = *OptionNumber * 10 + Name[Index] - L'0';
+ } else if ((Name[Index] >= L'A') && (Name[Index] <= L'F')) {
+ *OptionNumber = *OptionNumber * 10 + Name[Index] - L'A';
+ } else {
+ return FALSE;
+ }
+ }
+
+ return TRUE;
+}
+
+/**
+ Return an array of key option numbers.
+
+ @param Count Return the count of key option numbers.
+
+ @return UINT16* Pointer to an array of key option numbers;
+**/
+UINT16 *
+EFIAPI
+HotkeyGetOptionNumbers (
+ OUT UINTN *Count
+ )
+{
+ EFI_STATUS Status;
+ UINTN Index;
+ CHAR16 *Name;
+ EFI_GUID Guid;
+ UINTN NameSize;
+ UINTN NewNameSize;
+ UINT16 *OptionNumbers;
+ UINT16 OptionNumber;
+
+ if (Count == NULL) {
+ return NULL;
+ }
+
+ *Count = 0;
+ OptionNumbers = NULL;
+
+ NameSize = sizeof (CHAR16);
+ Name = AllocateZeroPool (NameSize);
+ ASSERT (Name != NULL);
+ while (TRUE) {
+ NewNameSize = NameSize;
+ Status = gRT->GetNextVariableName (&NewNameSize, Name, &Guid);
+ if (Status == EFI_BUFFER_TOO_SMALL) {
+ Name = ReallocatePool (NameSize, NewNameSize, Name);
+ ASSERT (Name != NULL);
+ Status = gRT->GetNextVariableName (&NewNameSize, Name, &Guid);
+ NameSize = NewNameSize;
+ }
+
+ if (Status == EFI_NOT_FOUND) {
+ break;
+ }
+ ASSERT_EFI_ERROR (Status);
+
+ if (IsKeyOptionVariable (Name ,&Guid, &OptionNumber)) {
+ OptionNumbers = ReallocatePool (
+ *Count * sizeof (UINT16),
+ (*Count + 1) * sizeof (UINT16),
+ OptionNumbers
+ );
+ ASSERT (OptionNumbers != NULL);
+ for (Index = 0; Index < *Count; Index++) {
+ if (OptionNumber < OptionNumbers[Index]) {
+ break;
+ }
+ }
+ CopyMem (&OptionNumbers[Index + 1], &OptionNumbers[Index], (*Count - Index) * sizeof (UINT16));
+ OptionNumbers[Index] = OptionNumber;
+ (*Count)++;
+ }
+ }
+
+ FreePool (Name);
+
+ return OptionNumbers;
+}
+
+/**
Process all the "Key####" variables, associate Hotkeys with corresponding Boot Options.
@retval EFI_SUCCESS Hotkey services successfully initialized.
- @retval EFI_NOT_FOUND Can not find the "KeyOrder" variable
**/
EFI_STATUS
InitializeHotkeyService (
@@ -648,11 +522,10 @@ InitializeHotkeyService (
{
EFI_STATUS Status;
UINT32 BootOptionSupport;
- UINT16 *KeyOrder;
- UINTN KeyOrderSize;
+ UINT16 *KeyOptionNumbers;
+ UINTN KeyOptionCount;
UINTN Index;
- UINT16 KeyOptionName[8];
- UINTN KeyOptionSize;
+ CHAR16 KeyOptionName[8];
EFI_KEY_OPTION *KeyOption;
//
@@ -673,33 +546,21 @@ InitializeHotkeyService (
sizeof (UINT32),
&BootOptionSupport
);
+ ASSERT_EFI_ERROR (Status);
- //
- // Get valid Key Option List from private EFI variable "KeyOrder"
- //
- KeyOrder = BdsLibGetVariableAndSize (
- VAR_KEY_ORDER,
- &gEfiGlobalVariableGuid,
- &KeyOrderSize
- );
-
- if (KeyOrder == NULL) {
- return EFI_NOT_FOUND;
- }
-
- for (Index = 0; Index < KeyOrderSize / sizeof (UINT16); Index ++) {
- UnicodeSPrint (KeyOptionName, sizeof (KeyOptionName), L"Key%04x", KeyOrder[Index]);
- KeyOption = BdsLibGetVariableAndSize (
- KeyOptionName,
- &gEfiGlobalVariableGuid,
- &KeyOptionSize
- );
-
- if (KeyOption == NULL || !IsKeyOptionValid (KeyOption)) {
- UnregisterHotkey (KeyOrder[Index]);
- } else {
+ KeyOptionNumbers = HotkeyGetOptionNumbers (&KeyOptionCount);
+ for (Index = 0; Index < KeyOptionCount; Index ++) {
+ UnicodeSPrint (KeyOptionName, sizeof (KeyOptionName), L"Key%04x", KeyOptionNumbers[Index]);
+ GetEfiGlobalVariable2 (KeyOptionName, (VOID **) &KeyOption, NULL);
+ ASSERT (KeyOption != NULL);
+ if (IsKeyOptionValid (KeyOption)) {
HotkeyInsertList (KeyOption);
}
+ FreePool (KeyOption);
+ }
+
+ if (KeyOptionNumbers != NULL) {
+ FreePool (KeyOptionNumbers);
}
//
diff --git a/edk2/IntelFrameworkModulePkg/Universal/BdsDxe/Hotkey.h b/edk2/IntelFrameworkModulePkg/Universal/BdsDxe/Hotkey.h
index 5df601441..c67df160c 100644
--- a/edk2/IntelFrameworkModulePkg/Universal/BdsDxe/Hotkey.h
+++ b/edk2/IntelFrameworkModulePkg/Universal/BdsDxe/Hotkey.h
@@ -116,43 +116,6 @@ typedef struct {
#define BDS_HOTKEY_OPTION_FROM_LINK(a) CR (a, BDS_HOTKEY_OPTION, Link, BDS_HOTKEY_OPTION_SIGNATURE)
-#define VAR_KEY_ORDER L"KeyOrder"
-
-/**
-
- Create Key#### for the given hotkey.
-
-
- @param KeyOption - The Hot Key Option to be added.
- @param KeyOptionNumber - The key option number for Key#### (optional).
-
- @retval EFI_SUCCESS Register hotkey successfully.
- @retval EFI_INVALID_PARAMETER The hotkey option is invalid.
-
-**/
-EFI_STATUS
-RegisterHotkey (
- IN EFI_KEY_OPTION *KeyOption,
- OUT UINT16 *KeyOptionNumber
- );
-
-/**
-
- Delete Key#### for the given Key Option number.
-
-
- @param KeyOptionNumber - Key option number for Key####
-
- @retval EFI_SUCCESS Unregister hotkey successfully.
- @retval EFI_NOT_FOUND No Key#### is found for the given Key Option number.
-
-**/
-EFI_STATUS
-UnregisterHotkey (
- IN UINT16 KeyOptionNumber
- );
-
-
/**
Process all the "Key####" variables, associate Hotkeys with corresponding Boot Options.
diff --git a/edk2/MdeModulePkg/Bus/Ata/AtaAtapiPassThru/AtaAtapiPassThru.c b/edk2/MdeModulePkg/Bus/Ata/AtaAtapiPassThru/AtaAtapiPassThru.c
index ee49e6eff..e5bfc3980 100644
--- a/edk2/MdeModulePkg/Bus/Ata/AtaAtapiPassThru/AtaAtapiPassThru.c
+++ b/edk2/MdeModulePkg/Bus/Ata/AtaAtapiPassThru/AtaAtapiPassThru.c
@@ -110,8 +110,10 @@ ATAPI_DEVICE_PATH mAtapiDevicePathTemplate = {
{
MESSAGING_DEVICE_PATH,
MSG_ATAPI_DP,
- (UINT8) (sizeof (ATAPI_DEVICE_PATH)),
- (UINT8) ((sizeof (ATAPI_DEVICE_PATH)) >> 8),
+ {
+ (UINT8) (sizeof (ATAPI_DEVICE_PATH)),
+ (UINT8) ((sizeof (ATAPI_DEVICE_PATH)) >> 8)
+ }
},
0,
0,
@@ -122,8 +124,10 @@ SATA_DEVICE_PATH mSataDevicePathTemplate = {
{
MESSAGING_DEVICE_PATH,
MSG_SATA_DP,
- (UINT8) (sizeof (SATA_DEVICE_PATH)),
- (UINT8) ((sizeof (SATA_DEVICE_PATH)) >> 8),
+ {
+ (UINT8) (sizeof (SATA_DEVICE_PATH)),
+ (UINT8) ((sizeof (SATA_DEVICE_PATH)) >> 8)
+ }
},
0,
0,
diff --git a/edk2/MdeModulePkg/Bus/Ata/AtaBusDxe/AtaBus.c b/edk2/MdeModulePkg/Bus/Ata/AtaBusDxe/AtaBus.c
index 625ba1b5b..51687fe0d 100644
--- a/edk2/MdeModulePkg/Bus/Ata/AtaBusDxe/AtaBus.c
+++ b/edk2/MdeModulePkg/Bus/Ata/AtaBusDxe/AtaBus.c
@@ -464,6 +464,7 @@ UnregisterAtaDevice (
if (BlockIo != NULL) {
AtaDevice = ATA_DEVICE_FROM_BLOCK_IO (BlockIo);
} else {
+ ASSERT (BlockIo2 != NULL);
AtaDevice = ATA_DEVICE_FROM_BLOCK_IO2 (BlockIo2);
}
diff --git a/edk2/MdeModulePkg/Bus/Ata/AtaBusDxe/AtaPassThruExecute.c b/edk2/MdeModulePkg/Bus/Ata/AtaBusDxe/AtaPassThruExecute.c
index 0045cc0d9..b50792438 100644
--- a/edk2/MdeModulePkg/Bus/Ata/AtaBusDxe/AtaPassThruExecute.c
+++ b/edk2/MdeModulePkg/Bus/Ata/AtaBusDxe/AtaPassThruExecute.c
@@ -133,6 +133,10 @@ AtaDevicePassThru (
if (TaskPacket != NULL) {
Packet = TaskPacket;
Packet->Asb = AllocateAlignedBuffer (AtaDevice, sizeof (EFI_ATA_STATUS_BLOCK));
+ if (Packet->Asb == NULL) {
+ return EFI_OUT_OF_RESOURCES;
+ }
+
CopyMem (Packet->Asb, AtaDevice->Asb, sizeof (EFI_ATA_STATUS_BLOCK));
Packet->Acb = AllocateCopyPool (sizeof (EFI_ATA_COMMAND_BLOCK), &AtaDevice->Acb);
} else {
@@ -939,6 +943,10 @@ TrustTransferAtaDevice (
AtaPassThru = AtaDevice->AtaBusDriverData->AtaPassThru;
if ((AtaPassThru->Mode->IoAlign > 1) && !IS_ALIGNED (Buffer, AtaPassThru->Mode->IoAlign)) {
NewBuffer = AllocateAlignedBuffer (AtaDevice, TransferLength);
+ if (NewBuffer == NULL) {
+ return EFI_OUT_OF_RESOURCES;
+ }
+
CopyMem (NewBuffer, Buffer, TransferLength);
FreePool (Buffer);
Buffer = NewBuffer;
diff --git a/edk2/MdeModulePkg/Bus/Pci/PciBusDxe/PciEnumeratorSupport.c b/edk2/MdeModulePkg/Bus/Pci/PciBusDxe/PciEnumeratorSupport.c
index a1627807e..8c31831ad 100644
--- a/edk2/MdeModulePkg/Bus/Pci/PciBusDxe/PciEnumeratorSupport.c
+++ b/edk2/MdeModulePkg/Bus/Pci/PciBusDxe/PciEnumeratorSupport.c
@@ -334,7 +334,7 @@ DumpPciBars (
DEBUG ((
EFI_D_INFO,
- " BAR[%d]: Type = %s; Alignment = 0x%x;\tLength = 0x%x;\tOffset = 0x%02x\n",
+ " BAR[%d]: Type = %s; Alignment = 0x%lx;\tLength = 0x%lx;\tOffset = 0x%02x\n",
Index, mBarTypeStr[MIN (PciIoDevice->PciBar[Index].BarType, PciBarTypeMaxType)],
PciIoDevice->PciBar[Index].Alignment, PciIoDevice->PciBar[Index].Length, PciIoDevice->PciBar[Index].Offset
));
@@ -347,7 +347,7 @@ DumpPciBars (
DEBUG ((
EFI_D_INFO,
- " VFBAR[%d]: Type = %s; Alignment = 0x%x;\tLength = 0x%x;\tOffset = 0x%02x\n",
+ " VFBAR[%d]: Type = %s; Alignment = 0x%lx;\tLength = 0x%lx;\tOffset = 0x%02x\n",
Index, mBarTypeStr[MIN (PciIoDevice->VfPciBar[Index].BarType, PciBarTypeMaxType)],
PciIoDevice->VfPciBar[Index].Alignment, PciIoDevice->VfPciBar[Index].Length, PciIoDevice->VfPciBar[Index].Offset
));
@@ -980,8 +980,8 @@ PciSetDeviceAttribute (
if (IS_PCI_LPC (&PciIoDevice->Pci)) {
Attributes |= EFI_PCI_IO_ATTRIBUTE_ISA_MOTHERBOARD_IO;
- Attributes |= (mReserveIsaAliases ? EFI_PCI_IO_ATTRIBUTE_ISA_IO : \
- EFI_PCI_IO_ATTRIBUTE_ISA_IO_16);
+ Attributes |= (mReserveIsaAliases ? (UINT64) EFI_PCI_IO_ATTRIBUTE_ISA_IO : \
+ (UINT64) EFI_PCI_IO_ATTRIBUTE_ISA_IO_16);
}
if (IS_PCI_BRIDGE (&PciIoDevice->Pci) || IS_CARDBUS_BRIDGE (&PciIoDevice->Pci)) {
@@ -1007,8 +1007,8 @@ PciSetDeviceAttribute (
if (IS_PCI_VGA (&PciIoDevice->Pci)) {
Attributes |= EFI_PCI_IO_ATTRIBUTE_VGA_MEMORY;
- Attributes |= (mReserveVgaAliases ? EFI_PCI_IO_ATTRIBUTE_VGA_IO : \
- EFI_PCI_IO_ATTRIBUTE_VGA_IO_16);
+ Attributes |= (mReserveVgaAliases ? (UINT64) EFI_PCI_IO_ATTRIBUTE_VGA_IO : \
+ (UINT64) EFI_PCI_IO_ATTRIBUTE_VGA_IO_16);
}
}
diff --git a/edk2/MdeModulePkg/Bus/Pci/PciBusDxe/PciLib.c b/edk2/MdeModulePkg/Bus/Pci/PciBusDxe/PciLib.c
index be3a8e88e..4e73b8f56 100644
--- a/edk2/MdeModulePkg/Bus/Pci/PciBusDxe/PciLib.c
+++ b/edk2/MdeModulePkg/Bus/Pci/PciBusDxe/PciLib.c
@@ -1,7 +1,7 @@
/** @file
Internal library implementation for PCI Bus module.
-Copyright (c) 2006 - 2011, Intel Corporation. All rights reserved.<BR>
+Copyright (c) 2006 - 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
which accompanies this distribution. The full text of the license may be found at
@@ -182,7 +182,7 @@ DumpBridgeResource (
if ((BridgeResource != NULL) && (BridgeResource->Length != 0)) {
DEBUG ((
- EFI_D_INFO, "Type = %s; Base = 0x%x;\tLength = 0x%x;\tAlignment = 0x%x\n",
+ EFI_D_INFO, "Type = %s; Base = 0x%lx;\tLength = 0x%lx;\tAlignment = 0x%lx\n",
mBarTypeStr[MIN (BridgeResource->ResType, PciBarTypeMaxType)],
BridgeResource->PciDev->PciBar[BridgeResource->Bar].BaseAddress,
BridgeResource->Length, BridgeResource->Alignment
@@ -195,7 +195,7 @@ DumpBridgeResource (
if (Resource->ResourceUsage == PciResUsageTypical) {
Bar = Resource->Virtual ? Resource->PciDev->VfPciBar : Resource->PciDev->PciBar;
DEBUG ((
- EFI_D_INFO, " Base = 0x%x;\tLength = 0x%x;\tAlignment = 0x%x;\tOwner = %s ",
+ EFI_D_INFO, " Base = 0x%lx;\tLength = 0x%lx;\tAlignment = 0x%lx;\tOwner = %s ",
Bar[Resource->Bar].BaseAddress, Resource->Length, Resource->Alignment,
IS_PCI_BRIDGE (&Resource->PciDev->Pci) ? L"PPB" :
IS_CARDBUS_BRIDGE (&Resource->PciDev->Pci) ? L"P2C" :
@@ -225,7 +225,7 @@ DumpBridgeResource (
));
}
} else {
- DEBUG ((EFI_D_INFO, " Padding:Length = 0x%x;\tAlignment = 0x%x\n", Resource->Length, Resource->Alignment));
+ DEBUG ((EFI_D_INFO, " Padding:Length = 0x%lx;\tAlignment = 0x%lx\n", Resource->Length, Resource->Alignment));
}
}
}
diff --git a/edk2/MdeModulePkg/Bus/Usb/UsbBusDxe/UsbBus.h b/edk2/MdeModulePkg/Bus/Usb/UsbBusDxe/UsbBus.h
index ad2f95261..094aea21c 100644
--- a/edk2/MdeModulePkg/Bus/Usb/UsbBusDxe/UsbBus.h
+++ b/edk2/MdeModulePkg/Bus/Usb/UsbBusDxe/UsbBus.h
@@ -60,10 +60,10 @@ typedef struct _USB_HUB_API USB_HUB_API;
//
// Roothub and hub's polling interval, set by experience,
-// The unit of roothub is 100us, means 1s as interval, and
+// The unit of roothub is 100us, means 100ms as interval, and
// the unit of hub is 1ms, means 64ms as interval.
//
-#define USB_ROOTHUB_POLL_INTERVAL (1000 * 10000U)
+#define USB_ROOTHUB_POLL_INTERVAL (100 * 10000U)
#define USB_HUB_POLL_INTERVAL 64
//
@@ -75,13 +75,13 @@ typedef struct _USB_HUB_API USB_HUB_API;
//
// Wait for port statue reg change, set by experience
//
-#define USB_WAIT_PORT_STS_CHANGE_STALL (5 * USB_BUS_1_MILLISECOND)
+#define USB_WAIT_PORT_STS_CHANGE_STALL (100)
//
// Wait for set device address, refers to specification
// [USB20-9.2.6.3, it says 2ms]
//
-#define USB_SET_DEVICE_ADDRESS_STALL (20 * USB_BUS_1_MILLISECOND)
+#define USB_SET_DEVICE_ADDRESS_STALL (2 * USB_BUS_1_MILLISECOND)
//
// Wait for retry max packet size, set by experience
@@ -99,7 +99,7 @@ typedef struct _USB_HUB_API USB_HUB_API;
// [USB20-7.1.7.5, it says 10ms for hub and 50ms for
// root hub]
//
-#define USB_SET_PORT_RESET_STALL (20 * USB_BUS_1_MILLISECOND)
+#define USB_SET_PORT_RESET_STALL (10 * USB_BUS_1_MILLISECOND)
#define USB_SET_ROOT_PORT_RESET_STALL (50 * USB_BUS_1_MILLISECOND)
//
diff --git a/edk2/MdeModulePkg/Bus/Usb/UsbBusDxe/UsbHub.c b/edk2/MdeModulePkg/Bus/Usb/UsbBusDxe/UsbHub.c
index 78af917ca..2d24bb4b8 100644
--- a/edk2/MdeModulePkg/Bus/Usb/UsbBusDxe/UsbHub.c
+++ b/edk2/MdeModulePkg/Bus/Usb/UsbBusDxe/UsbHub.c
@@ -763,7 +763,12 @@ UsbHubInit (
UsbHubCtrlSetPortFeature (HubIf->Device, Index, (EFI_USB_PORT_FEATURE) USB_HUB_PORT_POWER);
}
- gBS->Stall (HubDesc.PwrOn2PwrGood * USB_SET_PORT_POWER_STALL);
+ //
+ // Update for the usb hub has no power on delay requirement
+ //
+ if (HubDesc.PwrOn2PwrGood > 0) {
+ gBS->Stall (HubDesc.PwrOn2PwrGood * USB_SET_PORT_POWER_STALL);
+ }
UsbHubAckHubStatus (HubIf->Device);
}
diff --git a/edk2/MdeModulePkg/Bus/Usb/UsbBusDxe/UsbHub.h b/edk2/MdeModulePkg/Bus/Usb/UsbBusDxe/UsbHub.h
index c7ee16db4..4e5fcd85e 100644
--- a/edk2/MdeModulePkg/Bus/Usb/UsbBusDxe/UsbHub.h
+++ b/edk2/MdeModulePkg/Bus/Usb/UsbBusDxe/UsbHub.h
@@ -97,9 +97,9 @@ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
//
// Host software return timeout if port status doesn't change
-// after 500ms(LOOP * STALL = 100 * 5ms), set by experience
+// after 500ms(LOOP * STALL = 5000 * 0.1ms), set by experience
//
-#define USB_WAIT_PORT_STS_CHANGE_LOOP 100
+#define USB_WAIT_PORT_STS_CHANGE_LOOP 5000
#pragma pack(1)
//
diff --git a/edk2/MdeModulePkg/Core/Dxe/Gcd/Gcd.c b/edk2/MdeModulePkg/Core/Dxe/Gcd/Gcd.c
index c351d215d..fe2ac1011 100644
--- a/edk2/MdeModulePkg/Core/Dxe/Gcd/Gcd.c
+++ b/edk2/MdeModulePkg/Core/Dxe/Gcd/Gcd.c
@@ -148,7 +148,7 @@ CoreDumpGcdMemorySpaceMap (
UINTN Index;
Status = CoreGetMemorySpaceMap (&NumberOfDescriptors, &MemorySpaceMap);
- ASSERT_EFI_ERROR (Status);
+ ASSERT (Status == EFI_SUCCESS && MemorySpaceMap != NULL);
if (InitialMap) {
DEBUG ((DEBUG_GCD, "GCD:Initial GCD Memory Space Map\n"));
@@ -190,7 +190,7 @@ CoreDumpGcdIoSpaceMap (
UINTN Index;
Status = CoreGetIoSpaceMap (&NumberOfDescriptors, &IoSpaceMap);
- ASSERT_EFI_ERROR (Status);
+ ASSERT (Status == EFI_SUCCESS && IoSpaceMap != NULL);
if (InitialMap) {
DEBUG ((DEBUG_GCD, "GCD:Initial GCD I/O Space Map\n"));
diff --git a/edk2/MdeModulePkg/Core/PiSmmCore/Smi.c b/edk2/MdeModulePkg/Core/PiSmmCore/Smi.c
index 1868bbf9e..1111959c3 100644
--- a/edk2/MdeModulePkg/Core/PiSmmCore/Smi.c
+++ b/edk2/MdeModulePkg/Core/PiSmmCore/Smi.c
@@ -170,14 +170,20 @@ SmiManage (
// If a handler returns EFI_INTERRUPT_PENDING then no additional handlers
// will be processed and EFI_INTERRUPT_PENDING will be returned.
//
- return EFI_INTERRUPT_PENDING;
+ if (HandlerType != NULL) {
+ return EFI_INTERRUPT_PENDING;
+ }
+ break;
case EFI_SUCCESS:
//
// If a handler returns EFI_SUCCESS then no additional handlers will be processed.
// then the function will return EFI_SUCCESS.
//
- return EFI_SUCCESS;
+ if (HandlerType != NULL) {
+ return EFI_SUCCESS;
+ }
+ break;
case EFI_WARN_INTERRUPT_SOURCE_QUIESCED:
//
diff --git a/edk2/MdeModulePkg/Include/Library/UdpIoLib.h b/edk2/MdeModulePkg/Include/Library/UdpIoLib.h
index 32d61e505..e0b44ce18 100644
--- a/edk2/MdeModulePkg/Include/Library/UdpIoLib.h
+++ b/edk2/MdeModulePkg/Include/Library/UdpIoLib.h
@@ -2,7 +2,7 @@
This library is used to share code between UEFI network stack modules.
It provides the helper routines to access UDP service. It is used by both DHCP and MTFTP.
-Copyright (c) 2006 - 2010, Intel Corporation. All rights reserved.<BR>
+Copyright (c) 2006 - 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
which accompanies this distribution. The full text of the license may be found at<BR>
@@ -137,7 +137,7 @@ struct _UDP_IO {
UINT8 UdpVersion;
//
- // Handle used to create/destory UDP child
+ // Handle used to create/destroy UDP child
//
EFI_HANDLE Controller;
EFI_HANDLE Image;
diff --git a/edk2/MdeModulePkg/Library/DxeNetLib/DxeNetLib.c b/edk2/MdeModulePkg/Library/DxeNetLib/DxeNetLib.c
index f74dcdaea..956f73340 100644
--- a/edk2/MdeModulePkg/Library/DxeNetLib/DxeNetLib.c
+++ b/edk2/MdeModulePkg/Library/DxeNetLib/DxeNetLib.c
@@ -1829,7 +1829,7 @@ NetLibCreateServiceChild (
/**
- Destory a child of the service that is identified by ServiceBindingGuid.
+ Destroy a child of the service that is identified by ServiceBindingGuid.
Get the ServiceBinding Protocol first, then use it to destroy a child.
@@ -1838,10 +1838,10 @@ NetLibCreateServiceChild (
@param[in] Controller The controller which has the service installed.
@param[in] Image The image handle used to open service.
@param[in] ServiceBindingGuid The service's Guid.
- @param[in] ChildHandle The child to destory.
+ @param[in] ChildHandle The child to destroy.
- @retval EFI_SUCCESS The child is successfully destoried.
- @retval Others Failed to destory the child.
+ @retval EFI_SUCCESS The child is successfully destroyed.
+ @retval Others Failed to destroy the child.
**/
EFI_STATUS
@@ -1875,7 +1875,7 @@ NetLibDestroyServiceChild (
}
//
- // destory the child
+ // destroy the child
//
Status = Service->DestroyChild (Service, ChildHandle);
return Status;
diff --git a/edk2/MdeModulePkg/Library/DxeUdpIoLib/DxeUdpIoLib.c b/edk2/MdeModulePkg/Library/DxeUdpIoLib/DxeUdpIoLib.c
index bb3955949..e1d72f3f1 100644
--- a/edk2/MdeModulePkg/Library/DxeUdpIoLib/DxeUdpIoLib.c
+++ b/edk2/MdeModulePkg/Library/DxeUdpIoLib/DxeUdpIoLib.c
@@ -1,7 +1,7 @@
/** @file
Help functions to access UDP service, it is used by both the DHCP and MTFTP.
-Copyright (c) 2005 - 2009, Intel Corporation. All rights reserved.<BR>
+Copyright (c) 2005 - 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
which accompanies this distribution. The full text of the license may be found at<BR>
@@ -804,7 +804,7 @@ UdpIoFreeIo (
}
//
- // Close then destory the Udp4 child
+ // Close then destroy the Udp4 child
//
gBS->CloseProtocol (
UdpIo->UdpHandle,
@@ -827,7 +827,7 @@ UdpIoFreeIo (
}
//
- // Close then destory the Udp6 child
+ // Close then destroy the Udp6 child
//
gBS->CloseProtocol (
UdpIo->UdpHandle,
diff --git a/edk2/MdeModulePkg/Library/PiDxeS3BootScriptLib/BootScriptSave.c b/edk2/MdeModulePkg/Library/PiDxeS3BootScriptLib/BootScriptSave.c
index 0ebfdbb1b..32c7a55ac 100644
--- a/edk2/MdeModulePkg/Library/PiDxeS3BootScriptLib/BootScriptSave.c
+++ b/edk2/MdeModulePkg/Library/PiDxeS3BootScriptLib/BootScriptSave.c
@@ -1,7 +1,7 @@
/** @file
Save the S3 data to S3 boot script.
- Copyright (c) 2006 - 2011, Intel Corporation. All rights reserved.<BR>
+ Copyright (c) 2006 - 2012, Intel Corporation. All rights reserved.<BR>
This program and the accompanying materials
are licensed and made available under the terms and conditions
@@ -47,15 +47,15 @@ SCRIPT_TABLE_PRIVATE_DATA mS3BootScriptTable;
UINTN mLockBoxLength;
EFI_GUID mBootScriptDataGuid = {
- 0xaea6b965, 0xdcf5, 0x4311, 0xb4, 0xb8, 0xf, 0x12, 0x46, 0x44, 0x94, 0xd2
+ 0xaea6b965, 0xdcf5, 0x4311, { 0xb4, 0xb8, 0xf, 0x12, 0x46, 0x44, 0x94, 0xd2 }
};
EFI_GUID mBootScriptHeaderDataGuid = {
- 0x1810ab4a, 0x2314, 0x4df6, 0x81, 0xeb, 0x67, 0xc6, 0xec, 0x5, 0x85, 0x91
+ 0x1810ab4a, 0x2314, 0x4df6, { 0x81, 0xeb, 0x67, 0xc6, 0xec, 0x5, 0x85, 0x91 }
};
EFI_GUID mBootScriptInformationGuid = {
- 0x2c680508, 0x2b87, 0x46ab, 0xb9, 0x8a, 0x49, 0xfc, 0x23, 0xf9, 0xf5, 0x95
+ 0x2c680508, 0x2b87, 0x46ab, { 0xb9, 0x8a, 0x49, 0xfc, 0x23, 0xf9, 0xf5, 0x95 }
};
/**
diff --git a/edk2/MdeModulePkg/Universal/Acpi/AcpiTableDxe/Aml.c b/edk2/MdeModulePkg/Universal/Acpi/AcpiTableDxe/Aml.c
index bff81a803..a7b53e27b 100644
--- a/edk2/MdeModulePkg/Universal/Acpi/AcpiTableDxe/Aml.c
+++ b/edk2/MdeModulePkg/Universal/Acpi/AcpiTableDxe/Aml.c
@@ -1,7 +1,7 @@
/** @file
ACPI Sdt Protocol Driver
- Copyright (c) 2010, Intel Corporation. All rights reserved. <BR>
+ Copyright (c) 2010 - 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
which accompanies this distribution. The full text of the license may be found at
@@ -17,149 +17,149 @@
GLOBAL_REMOVE_IF_UNREFERENCED
AML_BYTE_ENCODING mAmlByteEncoding[] = {
// OpCode SubOpCode Num 1 2 3 4 5 6 Attribute
-/* ZeroOp - 0x00 */ {AML_ZERO_OP, 0, 0, AML_NONE, AML_NONE, AML_NONE, AML_NONE, AML_NONE, AML_NONE, 0},
-/* OneOp - 0x01 */ {AML_ONE_OP, 0, 0, AML_NONE, AML_NONE, AML_NONE, AML_NONE, AML_NONE, AML_NONE, 0},
-/* AliasOp - 0x06 */ {AML_ALIAS_OP, 0, 2, AML_NAME, AML_NAME, AML_NONE, AML_NONE, AML_NONE, AML_NONE, AML_IN_NAMESPACE},
-/* NameOp - 0x08 */ {AML_NAME_OP, 0, 2, AML_NAME, AML_OBJECT, AML_NONE, AML_NONE, AML_NONE, AML_NONE, AML_IN_NAMESPACE},
-/* BytePrefix - 0x0A */ {AML_BYTE_PREFIX, 0, 1, AML_UINT8, AML_NONE, AML_NONE, AML_NONE, AML_NONE, AML_NONE, 0},
-/* WordPrefix - 0x0B */ {AML_WORD_PREFIX, 0, 1, AML_UINT16, AML_NONE, AML_NONE, AML_NONE, AML_NONE, AML_NONE, 0},
-/* DWordPrefix - 0x0C */ {AML_DWORD_PREFIX, 0, 1, AML_UINT32, AML_NONE, AML_NONE, AML_NONE, AML_NONE, AML_NONE, 0},
-/* StringPrefix - 0x0D */ {AML_STRING_PREFIX, 0, 1, AML_STRING, AML_NONE, AML_NONE, AML_NONE, AML_NONE, AML_NONE, 0},
-/* QWordPrefix - 0x0E */ {AML_QWORD_PREFIX, 0, 1, AML_UINT64, AML_NONE, AML_NONE, AML_NONE, AML_NONE, AML_NONE, 0},
-/* ScopeOp - 0x10 */ {AML_SCOPE_OP, 0, 1, AML_NAME, AML_NONE, AML_NONE, AML_NONE, AML_NONE, AML_NONE, AML_HAS_PKG_LENGTH | AML_HAS_CHILD_OBJ | AML_IN_NAMESPACE},
-/* BufferOp - 0x11 */ {AML_BUFFER_OP, 0, 1, AML_OBJECT, AML_NONE, AML_NONE, AML_NONE, AML_NONE, AML_NONE, AML_HAS_PKG_LENGTH},
-/* PackageOp - 0x12 */ {AML_PACKAGE_OP, 0, 1, AML_UINT8, AML_NONE, AML_NONE, AML_NONE, AML_NONE, AML_NONE, AML_HAS_PKG_LENGTH | AML_HAS_CHILD_OBJ},
-/* VarPackageOp - 0x13 */ {AML_VAR_PACKAGE_OP, 0, 1, AML_OBJECT, AML_NONE, AML_NONE, AML_NONE, AML_NONE, AML_NONE, AML_HAS_PKG_LENGTH | AML_HAS_CHILD_OBJ},
-/* MethodOp - 0x14 */ {AML_METHOD_OP, 0, 2, AML_NAME, AML_UINT8, AML_NONE, AML_NONE, AML_NONE, AML_NONE, AML_HAS_PKG_LENGTH | AML_HAS_CHILD_OBJ | AML_IN_NAMESPACE},
-/* DualNamePrefix - 0x2F */ {AML_DUAL_NAME_PREFIX, 0, 0, AML_NONE, AML_NONE, AML_NONE, AML_NONE, AML_NONE, AML_NONE, AML_IS_NAME_CHAR},
-/* MultiNamePrefix - 0x2F */ {AML_MULTI_NAME_PREFIX, 0, 0, AML_NONE, AML_NONE, AML_NONE, AML_NONE, AML_NONE, AML_NONE, AML_IS_NAME_CHAR},
-/* NameChar - 0x41 */ {'A', 0, 0, AML_NONE, AML_NONE, AML_NONE, AML_NONE, AML_NONE, AML_NONE, AML_IS_NAME_CHAR},
-/* NameChar - 0x42 */ {'B', 0, 0, AML_NONE, AML_NONE, AML_NONE, AML_NONE, AML_NONE, AML_NONE, AML_IS_NAME_CHAR},
-/* NameChar - 0x43 */ {'C', 0, 0, AML_NONE, AML_NONE, AML_NONE, AML_NONE, AML_NONE, AML_NONE, AML_IS_NAME_CHAR},
-/* NameChar - 0x44 */ {'D', 0, 0, AML_NONE, AML_NONE, AML_NONE, AML_NONE, AML_NONE, AML_NONE, AML_IS_NAME_CHAR},
-/* NameChar - 0x45 */ {'E', 0, 0, AML_NONE, AML_NONE, AML_NONE, AML_NONE, AML_NONE, AML_NONE, AML_IS_NAME_CHAR},
-/* NameChar - 0x46 */ {'F', 0, 0, AML_NONE, AML_NONE, AML_NONE, AML_NONE, AML_NONE, AML_NONE, AML_IS_NAME_CHAR},
-/* NameChar - 0x47 */ {'G', 0, 0, AML_NONE, AML_NONE, AML_NONE, AML_NONE, AML_NONE, AML_NONE, AML_IS_NAME_CHAR},
-/* NameChar - 0x48 */ {'H', 0, 0, AML_NONE, AML_NONE, AML_NONE, AML_NONE, AML_NONE, AML_NONE, AML_IS_NAME_CHAR},
-/* NameChar - 0x49 */ {'I', 0, 0, AML_NONE, AML_NONE, AML_NONE, AML_NONE, AML_NONE, AML_NONE, AML_IS_NAME_CHAR},
-/* NameChar - 0x4A */ {'J', 0, 0, AML_NONE, AML_NONE, AML_NONE, AML_NONE, AML_NONE, AML_NONE, AML_IS_NAME_CHAR},
-/* NameChar - 0x4B */ {'K', 0, 0, AML_NONE, AML_NONE, AML_NONE, AML_NONE, AML_NONE, AML_NONE, AML_IS_NAME_CHAR},
-/* NameChar - 0x4C */ {'L', 0, 0, AML_NONE, AML_NONE, AML_NONE, AML_NONE, AML_NONE, AML_NONE, AML_IS_NAME_CHAR},
-/* NameChar - 0x4D */ {'M', 0, 0, AML_NONE, AML_NONE, AML_NONE, AML_NONE, AML_NONE, AML_NONE, AML_IS_NAME_CHAR},
-/* NameChar - 0x4E */ {'N', 0, 0, AML_NONE, AML_NONE, AML_NONE, AML_NONE, AML_NONE, AML_NONE, AML_IS_NAME_CHAR},
-/* NameChar - 0x4F */ {'O', 0, 0, AML_NONE, AML_NONE, AML_NONE, AML_NONE, AML_NONE, AML_NONE, AML_IS_NAME_CHAR},
-/* NameChar - 0x50 */ {'P', 0, 0, AML_NONE, AML_NONE, AML_NONE, AML_NONE, AML_NONE, AML_NONE, AML_IS_NAME_CHAR},
-/* NameChar - 0x51 */ {'Q', 0, 0, AML_NONE, AML_NONE, AML_NONE, AML_NONE, AML_NONE, AML_NONE, AML_IS_NAME_CHAR},
-/* NameChar - 0x52 */ {'R', 0, 0, AML_NONE, AML_NONE, AML_NONE, AML_NONE, AML_NONE, AML_NONE, AML_IS_NAME_CHAR},
-/* NameChar - 0x53 */ {'S', 0, 0, AML_NONE, AML_NONE, AML_NONE, AML_NONE, AML_NONE, AML_NONE, AML_IS_NAME_CHAR},
-/* NameChar - 0x54 */ {'T', 0, 0, AML_NONE, AML_NONE, AML_NONE, AML_NONE, AML_NONE, AML_NONE, AML_IS_NAME_CHAR},
-/* NameChar - 0x55 */ {'U', 0, 0, AML_NONE, AML_NONE, AML_NONE, AML_NONE, AML_NONE, AML_NONE, AML_IS_NAME_CHAR},
-/* NameChar - 0x56 */ {'V', 0, 0, AML_NONE, AML_NONE, AML_NONE, AML_NONE, AML_NONE, AML_NONE, AML_IS_NAME_CHAR},
-/* NameChar - 0x57 */ {'W', 0, 0, AML_NONE, AML_NONE, AML_NONE, AML_NONE, AML_NONE, AML_NONE, AML_IS_NAME_CHAR},
-/* NameChar - 0x58 */ {'X', 0, 0, AML_NONE, AML_NONE, AML_NONE, AML_NONE, AML_NONE, AML_NONE, AML_IS_NAME_CHAR},
-/* NameChar - 0x59 */ {'Y', 0, 0, AML_NONE, AML_NONE, AML_NONE, AML_NONE, AML_NONE, AML_NONE, AML_IS_NAME_CHAR},
-/* NameChar - 0x5A */ {'Z', 0, 0, AML_NONE, AML_NONE, AML_NONE, AML_NONE, AML_NONE, AML_NONE, AML_IS_NAME_CHAR},
-/* MutexOp - 0x5B 0x01 */ {AML_EXT_OP, AML_EXT_MUTEX_OP, 2, AML_NAME, AML_UINT8, AML_NONE, AML_NONE, AML_NONE, AML_NONE, AML_IN_NAMESPACE},
-/* EventOp - 0x5B 0x02 */ {AML_EXT_OP, AML_EXT_EVENT_OP, 1, AML_NAME, AML_NONE, AML_NONE, AML_NONE, AML_NONE, AML_NONE, AML_IN_NAMESPACE},
-/* CondRefOfOp - 0x5B 0x12 */ {AML_EXT_OP, AML_EXT_COND_REF_OF_OP, 2, AML_OBJECT, AML_OBJECT, AML_NONE, AML_NONE, AML_NONE, AML_NONE, 0},
-/* CreateFieldOp - 0x5B 0x13 */ {AML_EXT_OP, AML_EXT_CREATE_FIELD_OP,4, AML_OBJECT, AML_OBJECT, AML_OBJECT, AML_NAME, AML_NONE, AML_NONE, 0},
-/* LoadTableOp - 0x5B 0x1F */ {AML_EXT_OP, AML_EXT_LOAD_TABLE_OP, 6, AML_OBJECT, AML_OBJECT, AML_OBJECT, AML_OBJECT, AML_OBJECT, AML_OBJECT, 0},
-/* LoadOp - 0x5B 0x20 */ {AML_EXT_OP, AML_EXT_LOAD_OP, 2, AML_NAME, AML_OBJECT, AML_NONE, AML_NONE, AML_NONE, AML_NONE, 0},
-/* StallOp - 0x5B 0x21 */ {AML_EXT_OP, AML_EXT_STALL_OP, 1, AML_OBJECT, AML_NONE, AML_NONE, AML_NONE, AML_NONE, AML_NONE, 0},
-/* SleepOp - 0x5B 0x22 */ {AML_EXT_OP, AML_EXT_SLEEP_OP, 1, AML_OBJECT, AML_NONE, AML_NONE, AML_NONE, AML_NONE, AML_NONE, 0},
-/* AcquireOp - 0x5B 0x23 */ {AML_EXT_OP, AML_EXT_ACQUIRE_OP, 2, AML_OBJECT, AML_UINT16, AML_NONE, AML_NONE, AML_NONE, AML_NONE, 0},
-/* SignalOp - 0x5B 0x24 */ {AML_EXT_OP, AML_EXT_SIGNAL_OP, 1, AML_OBJECT, AML_NONE, AML_NONE, AML_NONE, AML_NONE, AML_NONE, 0},
-/* WaitOp - 0x5B 0x25 */ {AML_EXT_OP, AML_EXT_WAIT_OP, 2, AML_OBJECT, AML_OBJECT, AML_NONE, AML_NONE, AML_NONE, AML_NONE, 0},
-/* ResetOp - 0x5B 0x26 */ {AML_EXT_OP, AML_EXT_RESET_OP, 1, AML_OBJECT, AML_NONE, AML_NONE, AML_NONE, AML_NONE, AML_NONE, 0},
-/* ReleaseOp - 0x5B 0x27 */ {AML_EXT_OP, AML_EXT_RELEASE_OP, 1, AML_OBJECT, AML_NONE, AML_NONE, AML_NONE, AML_NONE, AML_NONE, 0},
-/* FromBCDOp - 0x5B 0x28 */ {AML_EXT_OP, AML_EXT_FROM_BCD_OP, 2, AML_OBJECT, AML_OBJECT, AML_NONE, AML_NONE, AML_NONE, AML_NONE, 0},
-/* ToBCDOp - 0x5B 0x29 */ {AML_EXT_OP, AML_EXT_TO_BCD_OP, 2, AML_OBJECT, AML_OBJECT, AML_NONE, AML_NONE, AML_NONE, AML_NONE, 0},
-/* UnloadOp - 0x5B 0x2A */ {AML_EXT_OP, AML_EXT_UNLOAD_OP, 1, AML_OBJECT, AML_NONE, AML_NONE, AML_NONE, AML_NONE, AML_NONE, 0},
-/* RevisionOp - 0x5B 0x30 */ {AML_EXT_OP, AML_EXT_REVISION_OP, 0, AML_NONE, AML_NONE, AML_NONE, AML_NONE, AML_NONE, AML_NONE, 0},
-/* DebugOp - 0x5B 0x31 */ {AML_EXT_OP, AML_EXT_DEBUG_OP, 0, AML_NONE, AML_NONE, AML_NONE, AML_NONE, AML_NONE, AML_NONE, 0},
-/* FatalOp - 0x5B 0x32 */ {AML_EXT_OP, AML_EXT_FATAL_OP, 3, AML_UINT8, AML_UINT32, AML_OBJECT, AML_NONE, AML_NONE, AML_NONE, 0},
-/* TimerOp - 0x5B 0x33 */ {AML_EXT_OP, AML_EXT_TIMER_OP, 0, AML_NONE, AML_NONE, AML_NONE, AML_NONE, AML_NONE, AML_NONE, 0},
-/* OpRegionOp - 0x5B 0x80 */ {AML_EXT_OP, AML_EXT_REGION_OP, 4, AML_NAME, AML_UINT8, AML_OBJECT, AML_OBJECT, AML_NONE, AML_NONE, AML_IN_NAMESPACE},
-/* FieldOp - 0x5B 0x81 */ {AML_EXT_OP, AML_EXT_FIELD_OP, 2, AML_NAME, AML_UINT8, AML_NONE, AML_NONE, AML_NONE, AML_NONE, AML_HAS_PKG_LENGTH},
-/* DeviceOp - 0x5B 0x82 */ {AML_EXT_OP, AML_EXT_DEVICE_OP, 1, AML_NAME, AML_NONE, AML_NONE, AML_NONE, AML_NONE, AML_NONE, AML_HAS_PKG_LENGTH | AML_HAS_CHILD_OBJ | AML_IN_NAMESPACE},
-/* ProcessorOp - 0x5B 0x83 */ {AML_EXT_OP, AML_EXT_PROCESSOR_OP, 4, AML_NAME, AML_UINT8, AML_UINT32, AML_UINT8, AML_NONE, AML_NONE, AML_HAS_PKG_LENGTH | AML_HAS_CHILD_OBJ | AML_IN_NAMESPACE},
-/* PowerResOp - 0x5B 0x84 */ {AML_EXT_OP, AML_EXT_POWER_RES_OP, 3, AML_NAME, AML_UINT8, AML_UINT16, AML_NONE, AML_NONE, AML_NONE, AML_HAS_PKG_LENGTH | AML_HAS_CHILD_OBJ | AML_IN_NAMESPACE},
-/* ThermalZoneOp - 0x5B 0x85 */ {AML_EXT_OP, AML_EXT_THERMAL_ZONE_OP,1, AML_NAME, AML_NONE, AML_NONE, AML_NONE, AML_NONE, AML_NONE, AML_HAS_PKG_LENGTH | AML_HAS_CHILD_OBJ | AML_IN_NAMESPACE},
-/* IndexFieldOp - 0x5B 0x86 */ {AML_EXT_OP, AML_EXT_INDEX_FIELD_OP, 3, AML_NAME, AML_NAME, AML_UINT8, AML_NONE, AML_NONE, AML_NONE, AML_HAS_PKG_LENGTH},
-/* BankFieldOp - 0x5B 0x87 */ {AML_EXT_OP, AML_EXT_BANK_FIELD_OP, 4, AML_NAME, AML_NAME, AML_OBJECT, AML_UINT8, AML_NONE, AML_NONE, AML_HAS_PKG_LENGTH},
-/* DataRegionOp - 0x5B 0x88 */ {AML_EXT_OP, AML_EXT_DATA_REGION_OP, 4, AML_NAME, AML_OBJECT, AML_OBJECT, AML_OBJECT, AML_NONE, AML_NONE, AML_IN_NAMESPACE},
-/* RootChar - 0x5C */ {AML_ROOT_CHAR, 0, 0, AML_NONE, AML_NONE, AML_NONE, AML_NONE, AML_NONE, AML_NONE, AML_IS_NAME_CHAR},
-/* ParentPrefixChar - 0x5E */ {AML_PARENT_PREFIX_CHAR, 0, 0, AML_NONE, AML_NONE, AML_NONE, AML_NONE, AML_NONE, AML_NONE, AML_IS_NAME_CHAR},
-/* NameChar - 0x5F */ {'_', 0, 0, AML_NONE, AML_NONE, AML_NONE, AML_NONE, AML_NONE, AML_NONE, AML_IS_NAME_CHAR},
-/* Local0Op - 0x60 */ {AML_LOCAL0, 0, 0, AML_NONE, AML_NONE, AML_NONE, AML_NONE, AML_NONE, AML_NONE, 0},
-/* Local1Op - 0x61 */ {AML_LOCAL1, 0, 0, AML_NONE, AML_NONE, AML_NONE, AML_NONE, AML_NONE, AML_NONE, 0},
-/* Local2Op - 0x62 */ {AML_LOCAL2, 0, 0, AML_NONE, AML_NONE, AML_NONE, AML_NONE, AML_NONE, AML_NONE, 0},
-/* Local3Op - 0x63 */ {AML_LOCAL3, 0, 0, AML_NONE, AML_NONE, AML_NONE, AML_NONE, AML_NONE, AML_NONE, 0},
-/* Local4Op - 0x64 */ {AML_LOCAL4, 0, 0, AML_NONE, AML_NONE, AML_NONE, AML_NONE, AML_NONE, AML_NONE, 0},
-/* Local5Op - 0x65 */ {AML_LOCAL5, 0, 0, AML_NONE, AML_NONE, AML_NONE, AML_NONE, AML_NONE, AML_NONE, 0},
-/* Local6Op - 0x66 */ {AML_LOCAL6, 0, 0, AML_NONE, AML_NONE, AML_NONE, AML_NONE, AML_NONE, AML_NONE, 0},
-/* Local7Op - 0x67 */ {AML_LOCAL7, 0, 0, AML_NONE, AML_NONE, AML_NONE, AML_NONE, AML_NONE, AML_NONE, 0},
-/* Arg0Op - 0x68 */ {AML_ARG0, 0, 0, AML_NONE, AML_NONE, AML_NONE, AML_NONE, AML_NONE, AML_NONE, 0},
-/* Arg1Op - 0x69 */ {AML_ARG1, 0, 0, AML_NONE, AML_NONE, AML_NONE, AML_NONE, AML_NONE, AML_NONE, 0},
-/* Arg2Op - 0x6A */ {AML_ARG2, 0, 0, AML_NONE, AML_NONE, AML_NONE, AML_NONE, AML_NONE, AML_NONE, 0},
-/* Arg3Op - 0x6B */ {AML_ARG3, 0, 0, AML_NONE, AML_NONE, AML_NONE, AML_NONE, AML_NONE, AML_NONE, 0},
-/* Arg4Op - 0x6C */ {AML_ARG4, 0, 0, AML_NONE, AML_NONE, AML_NONE, AML_NONE, AML_NONE, AML_NONE, 0},
-/* Arg5Op - 0x6D */ {AML_ARG5, 0, 0, AML_NONE, AML_NONE, AML_NONE, AML_NONE, AML_NONE, AML_NONE, 0},
-/* Arg6Op - 0x6E */ {AML_ARG6, 0, 0, AML_NONE, AML_NONE, AML_NONE, AML_NONE, AML_NONE, AML_NONE, 0},
-/* StoreOp - 0x70 */ {AML_STORE_OP, 0, 2, AML_OBJECT, AML_OBJECT, AML_NONE, AML_NONE, AML_NONE, AML_NONE, 0},
-/* RefOfOp - 0x71 */ {AML_REF_OF_OP, 0, 1, AML_OBJECT, AML_NONE, AML_NONE, AML_NONE, AML_NONE, AML_NONE, 0},
-/* AddOp - 0x72 */ {AML_ADD_OP, 0, 3, AML_OBJECT, AML_OBJECT, AML_OBJECT, AML_NONE, AML_NONE, AML_NONE, 0},
-/* ConcatOp - 0x73 */ {AML_CONCAT_OP, 0, 3, AML_OBJECT, AML_OBJECT, AML_OBJECT, AML_NONE, AML_NONE, AML_NONE, 0},
-/* SubtractOp - 0x74 */ {AML_SUBTRACT_OP, 0, 3, AML_OBJECT, AML_OBJECT, AML_OBJECT, AML_NONE, AML_NONE, AML_NONE, 0},
-/* IncrementOp - 0x75 */ {AML_INCREMENT_OP, 0, 1, AML_OBJECT, AML_NONE, AML_NONE, AML_NONE, AML_NONE, AML_NONE, 0},
-/* DecrementOp - 0x76 */ {AML_DECREMENT_OP, 0, 1, AML_OBJECT, AML_NONE, AML_NONE, AML_NONE, AML_NONE, AML_NONE, 0},
-/* MultiplyOp - 0x77 */ {AML_MULTIPLY_OP, 0, 3, AML_OBJECT, AML_OBJECT, AML_OBJECT, AML_NONE, AML_NONE, AML_NONE, 0},
-/* DivideOp - 0x78 */ {AML_DIVIDE_OP, 0, 4, AML_OBJECT, AML_OBJECT, AML_OBJECT, AML_OBJECT, AML_NONE, AML_NONE, 0},
-/* ShiftLeftOp - 0x79 */ {AML_SHIFT_LEFT_OP, 0, 3, AML_OBJECT, AML_OBJECT, AML_OBJECT, AML_NONE, AML_NONE, AML_NONE, 0},
-/* ShiftRightOp - 0x7A */ {AML_SHIFT_RIGHT_OP, 0, 3, AML_OBJECT, AML_OBJECT, AML_OBJECT, AML_NONE, AML_NONE, AML_NONE, 0},
-/* AndOp - 0x7B */ {AML_AND_OP, 0, 3, AML_OBJECT, AML_OBJECT, AML_OBJECT, AML_NONE, AML_NONE, AML_NONE, 0},
-/* NAndOp - 0x7C */ {AML_NAND_OP, 0, 3, AML_OBJECT, AML_OBJECT, AML_OBJECT, AML_NONE, AML_NONE, AML_NONE, 0},
-/* OrOp - 0x7D */ {AML_OR_OP, 0, 3, AML_OBJECT, AML_OBJECT, AML_OBJECT, AML_NONE, AML_NONE, AML_NONE, 0},
-/* NorOp - 0x7E */ {AML_NOR_OP, 0, 3, AML_OBJECT, AML_OBJECT, AML_OBJECT, AML_NONE, AML_NONE, AML_NONE, 0},
-/* XOrOp - 0x7F */ {AML_XOR_OP, 0, 3, AML_OBJECT, AML_OBJECT, AML_OBJECT, AML_NONE, AML_NONE, AML_NONE, 0},
-/* NotOp - 0x80 */ {AML_NOT_OP, 0, 2, AML_OBJECT, AML_OBJECT, AML_NONE, AML_NONE, AML_NONE, AML_NONE, 0},
-/* FindSetLeftBitOp - 0x81 */ {AML_FIND_SET_LEFT_BIT_OP, 0, 2, AML_OBJECT, AML_OBJECT, AML_NONE, AML_NONE, AML_NONE, AML_NONE, 0},
-/* FindSetRightBitOp - 0x82 */ {AML_FIND_SET_RIGHT_BIT_OP, 0, 2, AML_OBJECT, AML_OBJECT, AML_NONE, AML_NONE, AML_NONE, AML_NONE, 0},
-/* DerefOfOp - 0x83 */ {AML_DEREF_OF_OP, 0, 1, AML_OBJECT, AML_NONE, AML_NONE, AML_NONE, AML_NONE, AML_NONE, 0},
-/* ConcatResOp - 0x84 */ {AML_CONCAT_RES_OP, 0, 3, AML_OBJECT, AML_OBJECT, AML_OBJECT, AML_NONE, AML_NONE, AML_NONE, 0},
-/* ModOp - 0x85 */ {AML_MOD_OP, 0, 3, AML_OBJECT, AML_OBJECT, AML_OBJECT, AML_NONE, AML_NONE, AML_NONE, 0},
-/* NotifyOp - 0x86 */ {AML_NOTIFY_OP, 0, 2, AML_OBJECT, AML_OBJECT, AML_NONE, AML_NONE, AML_NONE, AML_NONE, 0},
-/* SizeOfOp - 0x87 */ {AML_SIZE_OF_OP, 0, 1, AML_OBJECT, AML_NONE, AML_NONE, AML_NONE, AML_NONE, AML_NONE, 0},
-/* IndexOp - 0x88 */ {AML_INDEX_OP, 0, 3, AML_OBJECT, AML_OBJECT, AML_OBJECT, AML_NONE, AML_NONE, AML_NONE, 0},
-/* MatchOp - 0x89 */ {AML_MATCH_OP, 0, 6, AML_OBJECT, AML_UINT8, AML_OBJECT, AML_UINT8, AML_OBJECT, AML_OBJECT, 0},
-/* CreateDWordFieldOp - 0x8A */ {AML_CREATE_DWORD_FIELD_OP, 0, 3, AML_OBJECT, AML_OBJECT, AML_NAME, AML_NONE, AML_NONE, AML_NONE, 0},
-/* CreateWordFieldOp - 0x8B */ {AML_CREATE_WORD_FIELD_OP, 0, 3, AML_OBJECT, AML_OBJECT, AML_NAME, AML_NONE, AML_NONE, AML_NONE, 0},
-/* CreateByteFieldOp - 0x8C */ {AML_CREATE_BYTE_FIELD_OP, 0, 3, AML_OBJECT, AML_OBJECT, AML_NAME, AML_NONE, AML_NONE, AML_NONE, 0},
-/* CreateBitFieldOp - 0x8D */ {AML_CREATE_BIT_FIELD_OP, 0, 3, AML_OBJECT, AML_OBJECT, AML_NAME, AML_NONE, AML_NONE, AML_NONE, 0},
-/* ObjectTypeOp - 0x8E */ {AML_OBJECT_TYPE_OP, 0, 1, AML_OBJECT, AML_NONE, AML_NONE, AML_NONE, AML_NONE, AML_NONE, 0},
-/* CreateQWordFieldOp - 0x8F */ {AML_CREATE_QWORD_FIELD_OP, 0, 3, AML_OBJECT, AML_OBJECT, AML_NAME, AML_NONE, AML_NONE, AML_NONE, 0},
-/* LAndOp - 0x90 */ {AML_LAND_OP, 0, 2, AML_OBJECT, AML_OBJECT, AML_NONE, AML_NONE, AML_NONE, AML_NONE, 0},
-/* LOrOp - 0x91 */ {AML_LOR_OP, 0, 2, AML_OBJECT, AML_OBJECT, AML_NONE, AML_NONE, AML_NONE, AML_NONE, 0},
-/* LNotOp - 0x92 */ {AML_LNOT_OP, 0, 1, AML_OBJECT, AML_NONE, AML_NONE, AML_NONE, AML_NONE, AML_NONE, 0},
-/* LEqualOp - 0x93 */ {AML_LEQUAL_OP, 0, 2, AML_OBJECT, AML_OBJECT, AML_NONE, AML_NONE, AML_NONE, AML_NONE, 0},
-/* LGreaterOp - 0x94 */ {AML_LGREATER_OP, 0, 2, AML_OBJECT, AML_OBJECT, AML_NONE, AML_NONE, AML_NONE, AML_NONE, 0},
-/* LLessOp - 0x95 */ {AML_LLESS_OP, 0, 2, AML_OBJECT, AML_OBJECT, AML_NONE, AML_NONE, AML_NONE, AML_NONE, 0},
-/* ToBufferOp - 0x96 */ {AML_TO_BUFFER_OP, 0, 2, AML_OBJECT, AML_OBJECT, AML_NONE, AML_NONE, AML_NONE, AML_NONE, 0},
-/* ToDecimalStringOp - 0x97 */ {AML_TO_DEC_STRING_OP, 0, 2, AML_OBJECT, AML_OBJECT, AML_NONE, AML_NONE, AML_NONE, AML_NONE, 0},
-/* ToHexStringOp - 0x98 */ {AML_TO_HEX_STRING_OP, 0, 2, AML_OBJECT, AML_OBJECT, AML_NONE, AML_NONE, AML_NONE, AML_NONE, 0},
-/* ToIntegerOp - 0x99 */ {AML_TO_INTEGER_OP, 0, 2, AML_OBJECT, AML_OBJECT, AML_NONE, AML_NONE, AML_NONE, AML_NONE, 0},
-/* ToStringOp - 0x9C */ {AML_TO_STRING_OP, 0, 3, AML_OBJECT, AML_OBJECT, AML_OBJECT, AML_NONE, AML_NONE, AML_NONE, 0},
-/* CopyObjectOp - 0x9D */ {AML_COPY_OBJECT_OP, 0, 2, AML_OBJECT, AML_OBJECT, AML_NONE, AML_NONE, AML_NONE, AML_NONE, 0},
-/* MidOp - 0x9E */ {AML_MID_OP, 0, 3, AML_OBJECT, AML_OBJECT, AML_OBJECT, AML_NONE, AML_NONE, AML_NONE, 0},
-/* ContinueOp - 0x9F */ {AML_CONTINUE_OP, 0, 0, AML_NONE, AML_NONE, AML_NONE, AML_NONE, AML_NONE, AML_NONE, 0},
-/* IfOp - 0xA0 */ {AML_IF_OP, 0, 1, AML_OBJECT, AML_NONE, AML_NONE, AML_NONE, AML_NONE, AML_NONE, AML_HAS_PKG_LENGTH | AML_HAS_CHILD_OBJ},
-/* ElseOp - 0xA1 */ {AML_ELSE_OP, 0, 0, AML_NONE, AML_NONE, AML_NONE, AML_NONE, AML_NONE, AML_NONE, AML_HAS_PKG_LENGTH | AML_HAS_CHILD_OBJ},
-/* WhileOp - 0xA2 */ {AML_WHILE_OP, 0, 1, AML_OBJECT, AML_NONE, AML_NONE, AML_NONE, AML_NONE, AML_NONE, AML_HAS_PKG_LENGTH | AML_HAS_CHILD_OBJ},
-/* NoopOp - 0xA3 */ {AML_NOOP_OP, 0, 0, AML_NONE, AML_NONE, AML_NONE, AML_NONE, AML_NONE, AML_NONE, 0},
-/* ReturnOp - 0xA4 */ {AML_RETURN_OP, 0, 1, AML_OBJECT, AML_NONE, AML_NONE, AML_NONE, AML_NONE, AML_NONE, 0},
-/* BreakOp - 0xA5 */ {AML_BREAK_OP, 0, 0, AML_NONE, AML_NONE, AML_NONE, AML_NONE, AML_NONE, AML_NONE, 0},
-/* BreakPointOp - 0xCC */ {AML_BREAK_POINT_OP, 0, 0, AML_NONE, AML_NONE, AML_NONE, AML_NONE, AML_NONE, AML_NONE, 0},
-/* OnesOp - 0xFF */ {AML_ONES_OP, 0, 0, AML_NONE, AML_NONE, AML_NONE, AML_NONE, AML_NONE, AML_NONE, 0},
+/* ZeroOp - 0x00 */ {AML_ZERO_OP, 0, 0, {AML_NONE, AML_NONE, AML_NONE, AML_NONE, AML_NONE, AML_NONE}, 0},
+/* OneOp - 0x01 */ {AML_ONE_OP, 0, 0, {AML_NONE, AML_NONE, AML_NONE, AML_NONE, AML_NONE, AML_NONE}, 0},
+/* AliasOp - 0x06 */ {AML_ALIAS_OP, 0, 2, {AML_NAME, AML_NAME, AML_NONE, AML_NONE, AML_NONE, AML_NONE}, AML_IN_NAMESPACE},
+/* NameOp - 0x08 */ {AML_NAME_OP, 0, 2, {AML_NAME, AML_OBJECT, AML_NONE, AML_NONE, AML_NONE, AML_NONE}, AML_IN_NAMESPACE},
+/* BytePrefix - 0x0A */ {AML_BYTE_PREFIX, 0, 1, {AML_UINT8, AML_NONE, AML_NONE, AML_NONE, AML_NONE, AML_NONE}, 0},
+/* WordPrefix - 0x0B */ {AML_WORD_PREFIX, 0, 1, {AML_UINT16, AML_NONE, AML_NONE, AML_NONE, AML_NONE, AML_NONE}, 0},
+/* DWordPrefix - 0x0C */ {AML_DWORD_PREFIX, 0, 1, {AML_UINT32, AML_NONE, AML_NONE, AML_NONE, AML_NONE, AML_NONE}, 0},
+/* StringPrefix - 0x0D */ {AML_STRING_PREFIX, 0, 1, {AML_STRING, AML_NONE, AML_NONE, AML_NONE, AML_NONE, AML_NONE}, 0},
+/* QWordPrefix - 0x0E */ {AML_QWORD_PREFIX, 0, 1, {AML_UINT64, AML_NONE, AML_NONE, AML_NONE, AML_NONE, AML_NONE}, 0},
+/* ScopeOp - 0x10 */ {AML_SCOPE_OP, 0, 1, {AML_NAME, AML_NONE, AML_NONE, AML_NONE, AML_NONE, AML_NONE}, AML_HAS_PKG_LENGTH | AML_HAS_CHILD_OBJ | AML_IN_NAMESPACE},
+/* BufferOp - 0x11 */ {AML_BUFFER_OP, 0, 1, {AML_OBJECT, AML_NONE, AML_NONE, AML_NONE, AML_NONE, AML_NONE}, AML_HAS_PKG_LENGTH},
+/* PackageOp - 0x12 */ {AML_PACKAGE_OP, 0, 1, {AML_UINT8, AML_NONE, AML_NONE, AML_NONE, AML_NONE, AML_NONE}, AML_HAS_PKG_LENGTH | AML_HAS_CHILD_OBJ},
+/* VarPackageOp - 0x13 */ {AML_VAR_PACKAGE_OP, 0, 1, {AML_OBJECT, AML_NONE, AML_NONE, AML_NONE, AML_NONE, AML_NONE}, AML_HAS_PKG_LENGTH | AML_HAS_CHILD_OBJ},
+/* MethodOp - 0x14 */ {AML_METHOD_OP, 0, 2, {AML_NAME, AML_UINT8, AML_NONE, AML_NONE, AML_NONE, AML_NONE}, AML_HAS_PKG_LENGTH | AML_HAS_CHILD_OBJ | AML_IN_NAMESPACE},
+/* DualNamePrefix - 0x2F */ {AML_DUAL_NAME_PREFIX, 0, 0, {AML_NONE, AML_NONE, AML_NONE, AML_NONE, AML_NONE, AML_NONE}, AML_IS_NAME_CHAR},
+/* MultiNamePrefix - 0x2F */ {AML_MULTI_NAME_PREFIX, 0, 0, {AML_NONE, AML_NONE, AML_NONE, AML_NONE, AML_NONE, AML_NONE}, AML_IS_NAME_CHAR},
+/* NameChar - 0x41 */ {'A', 0, 0, {AML_NONE, AML_NONE, AML_NONE, AML_NONE, AML_NONE, AML_NONE}, AML_IS_NAME_CHAR},
+/* NameChar - 0x42 */ {'B', 0, 0, {AML_NONE, AML_NONE, AML_NONE, AML_NONE, AML_NONE, AML_NONE}, AML_IS_NAME_CHAR},
+/* NameChar - 0x43 */ {'C', 0, 0, {AML_NONE, AML_NONE, AML_NONE, AML_NONE, AML_NONE, AML_NONE}, AML_IS_NAME_CHAR},
+/* NameChar - 0x44 */ {'D', 0, 0, {AML_NONE, AML_NONE, AML_NONE, AML_NONE, AML_NONE, AML_NONE}, AML_IS_NAME_CHAR},
+/* NameChar - 0x45 */ {'E', 0, 0, {AML_NONE, AML_NONE, AML_NONE, AML_NONE, AML_NONE, AML_NONE}, AML_IS_NAME_CHAR},
+/* NameChar - 0x46 */ {'F', 0, 0, {AML_NONE, AML_NONE, AML_NONE, AML_NONE, AML_NONE, AML_NONE}, AML_IS_NAME_CHAR},
+/* NameChar - 0x47 */ {'G', 0, 0, {AML_NONE, AML_NONE, AML_NONE, AML_NONE, AML_NONE, AML_NONE}, AML_IS_NAME_CHAR},
+/* NameChar - 0x48 */ {'H', 0, 0, {AML_NONE, AML_NONE, AML_NONE, AML_NONE, AML_NONE, AML_NONE}, AML_IS_NAME_CHAR},
+/* NameChar - 0x49 */ {'I', 0, 0, {AML_NONE, AML_NONE, AML_NONE, AML_NONE, AML_NONE, AML_NONE}, AML_IS_NAME_CHAR},
+/* NameChar - 0x4A */ {'J', 0, 0, {AML_NONE, AML_NONE, AML_NONE, AML_NONE, AML_NONE, AML_NONE}, AML_IS_NAME_CHAR},
+/* NameChar - 0x4B */ {'K', 0, 0, {AML_NONE, AML_NONE, AML_NONE, AML_NONE, AML_NONE, AML_NONE}, AML_IS_NAME_CHAR},
+/* NameChar - 0x4C */ {'L', 0, 0, {AML_NONE, AML_NONE, AML_NONE, AML_NONE, AML_NONE, AML_NONE}, AML_IS_NAME_CHAR},
+/* NameChar - 0x4D */ {'M', 0, 0, {AML_NONE, AML_NONE, AML_NONE, AML_NONE, AML_NONE, AML_NONE}, AML_IS_NAME_CHAR},
+/* NameChar - 0x4E */ {'N', 0, 0, {AML_NONE, AML_NONE, AML_NONE, AML_NONE, AML_NONE, AML_NONE}, AML_IS_NAME_CHAR},
+/* NameChar - 0x4F */ {'O', 0, 0, {AML_NONE, AML_NONE, AML_NONE, AML_NONE, AML_NONE, AML_NONE}, AML_IS_NAME_CHAR},
+/* NameChar - 0x50 */ {'P', 0, 0, {AML_NONE, AML_NONE, AML_NONE, AML_NONE, AML_NONE, AML_NONE}, AML_IS_NAME_CHAR},
+/* NameChar - 0x51 */ {'Q', 0, 0, {AML_NONE, AML_NONE, AML_NONE, AML_NONE, AML_NONE, AML_NONE}, AML_IS_NAME_CHAR},
+/* NameChar - 0x52 */ {'R', 0, 0, {AML_NONE, AML_NONE, AML_NONE, AML_NONE, AML_NONE, AML_NONE}, AML_IS_NAME_CHAR},
+/* NameChar - 0x53 */ {'S', 0, 0, {AML_NONE, AML_NONE, AML_NONE, AML_NONE, AML_NONE, AML_NONE}, AML_IS_NAME_CHAR},
+/* NameChar - 0x54 */ {'T', 0, 0, {AML_NONE, AML_NONE, AML_NONE, AML_NONE, AML_NONE, AML_NONE}, AML_IS_NAME_CHAR},
+/* NameChar - 0x55 */ {'U', 0, 0, {AML_NONE, AML_NONE, AML_NONE, AML_NONE, AML_NONE, AML_NONE}, AML_IS_NAME_CHAR},
+/* NameChar - 0x56 */ {'V', 0, 0, {AML_NONE, AML_NONE, AML_NONE, AML_NONE, AML_NONE, AML_NONE}, AML_IS_NAME_CHAR},
+/* NameChar - 0x57 */ {'W', 0, 0, {AML_NONE, AML_NONE, AML_NONE, AML_NONE, AML_NONE, AML_NONE}, AML_IS_NAME_CHAR},
+/* NameChar - 0x58 */ {'X', 0, 0, {AML_NONE, AML_NONE, AML_NONE, AML_NONE, AML_NONE, AML_NONE}, AML_IS_NAME_CHAR},
+/* NameChar - 0x59 */ {'Y', 0, 0, {AML_NONE, AML_NONE, AML_NONE, AML_NONE, AML_NONE, AML_NONE}, AML_IS_NAME_CHAR},
+/* NameChar - 0x5A */ {'Z', 0, 0, {AML_NONE, AML_NONE, AML_NONE, AML_NONE, AML_NONE, AML_NONE}, AML_IS_NAME_CHAR},
+/* MutexOp - 0x5B 0x01 */ {AML_EXT_OP, AML_EXT_MUTEX_OP, 2, {AML_NAME, AML_UINT8, AML_NONE, AML_NONE, AML_NONE, AML_NONE}, AML_IN_NAMESPACE},
+/* EventOp - 0x5B 0x02 */ {AML_EXT_OP, AML_EXT_EVENT_OP, 1, {AML_NAME, AML_NONE, AML_NONE, AML_NONE, AML_NONE, AML_NONE}, AML_IN_NAMESPACE},
+/* CondRefOfOp - 0x5B 0x12 */ {AML_EXT_OP, AML_EXT_COND_REF_OF_OP, 2, {AML_OBJECT, AML_OBJECT, AML_NONE, AML_NONE, AML_NONE, AML_NONE}, 0},
+/* CreateFieldOp - 0x5B 0x13 */ {AML_EXT_OP, AML_EXT_CREATE_FIELD_OP,4, {AML_OBJECT, AML_OBJECT, AML_OBJECT, AML_NAME, AML_NONE, AML_NONE}, 0},
+/* LoadTableOp - 0x5B 0x1F */ {AML_EXT_OP, AML_EXT_LOAD_TABLE_OP, 6, {AML_OBJECT, AML_OBJECT, AML_OBJECT, AML_OBJECT, AML_OBJECT, AML_OBJECT}, 0},
+/* LoadOp - 0x5B 0x20 */ {AML_EXT_OP, AML_EXT_LOAD_OP, 2, {AML_NAME, AML_OBJECT, AML_NONE, AML_NONE, AML_NONE, AML_NONE}, 0},
+/* StallOp - 0x5B 0x21 */ {AML_EXT_OP, AML_EXT_STALL_OP, 1, {AML_OBJECT, AML_NONE, AML_NONE, AML_NONE, AML_NONE, AML_NONE}, 0},
+/* SleepOp - 0x5B 0x22 */ {AML_EXT_OP, AML_EXT_SLEEP_OP, 1, {AML_OBJECT, AML_NONE, AML_NONE, AML_NONE, AML_NONE, AML_NONE}, 0},
+/* AcquireOp - 0x5B 0x23 */ {AML_EXT_OP, AML_EXT_ACQUIRE_OP, 2, {AML_OBJECT, AML_UINT16, AML_NONE, AML_NONE, AML_NONE, AML_NONE}, 0},
+/* SignalOp - 0x5B 0x24 */ {AML_EXT_OP, AML_EXT_SIGNAL_OP, 1, {AML_OBJECT, AML_NONE, AML_NONE, AML_NONE, AML_NONE, AML_NONE}, 0},
+/* WaitOp - 0x5B 0x25 */ {AML_EXT_OP, AML_EXT_WAIT_OP, 2, {AML_OBJECT, AML_OBJECT, AML_NONE, AML_NONE, AML_NONE, AML_NONE}, 0},
+/* ResetOp - 0x5B 0x26 */ {AML_EXT_OP, AML_EXT_RESET_OP, 1, {AML_OBJECT, AML_NONE, AML_NONE, AML_NONE, AML_NONE, AML_NONE}, 0},
+/* ReleaseOp - 0x5B 0x27 */ {AML_EXT_OP, AML_EXT_RELEASE_OP, 1, {AML_OBJECT, AML_NONE, AML_NONE, AML_NONE, AML_NONE, AML_NONE}, 0},
+/* FromBCDOp - 0x5B 0x28 */ {AML_EXT_OP, AML_EXT_FROM_BCD_OP, 2, {AML_OBJECT, AML_OBJECT, AML_NONE, AML_NONE, AML_NONE, AML_NONE}, 0},
+/* ToBCDOp - 0x5B 0x29 */ {AML_EXT_OP, AML_EXT_TO_BCD_OP, 2, {AML_OBJECT, AML_OBJECT, AML_NONE, AML_NONE, AML_NONE, AML_NONE}, 0},
+/* UnloadOp - 0x5B 0x2A */ {AML_EXT_OP, AML_EXT_UNLOAD_OP, 1, {AML_OBJECT, AML_NONE, AML_NONE, AML_NONE, AML_NONE, AML_NONE}, 0},
+/* RevisionOp - 0x5B 0x30 */ {AML_EXT_OP, AML_EXT_REVISION_OP, 0, {AML_NONE, AML_NONE, AML_NONE, AML_NONE, AML_NONE, AML_NONE}, 0},
+/* DebugOp - 0x5B 0x31 */ {AML_EXT_OP, AML_EXT_DEBUG_OP, 0, {AML_NONE, AML_NONE, AML_NONE, AML_NONE, AML_NONE, AML_NONE}, 0},
+/* FatalOp - 0x5B 0x32 */ {AML_EXT_OP, AML_EXT_FATAL_OP, 3, {AML_UINT8, AML_UINT32, AML_OBJECT, AML_NONE, AML_NONE, AML_NONE}, 0},
+/* TimerOp - 0x5B 0x33 */ {AML_EXT_OP, AML_EXT_TIMER_OP, 0, {AML_NONE, AML_NONE, AML_NONE, AML_NONE, AML_NONE, AML_NONE}, 0},
+/* OpRegionOp - 0x5B 0x80 */ {AML_EXT_OP, AML_EXT_REGION_OP, 4, {AML_NAME, AML_UINT8, AML_OBJECT, AML_OBJECT, AML_NONE, AML_NONE}, AML_IN_NAMESPACE},
+/* FieldOp - 0x5B 0x81 */ {AML_EXT_OP, AML_EXT_FIELD_OP, 2, {AML_NAME, AML_UINT8, AML_NONE, AML_NONE, AML_NONE, AML_NONE}, AML_HAS_PKG_LENGTH},
+/* DeviceOp - 0x5B 0x82 */ {AML_EXT_OP, AML_EXT_DEVICE_OP, 1, {AML_NAME, AML_NONE, AML_NONE, AML_NONE, AML_NONE, AML_NONE}, AML_HAS_PKG_LENGTH | AML_HAS_CHILD_OBJ | AML_IN_NAMESPACE},
+/* ProcessorOp - 0x5B 0x83 */ {AML_EXT_OP, AML_EXT_PROCESSOR_OP, 4, {AML_NAME, AML_UINT8, AML_UINT32, AML_UINT8, AML_NONE, AML_NONE}, AML_HAS_PKG_LENGTH | AML_HAS_CHILD_OBJ | AML_IN_NAMESPACE},
+/* PowerResOp - 0x5B 0x84 */ {AML_EXT_OP, AML_EXT_POWER_RES_OP, 3, {AML_NAME, AML_UINT8, AML_UINT16, AML_NONE, AML_NONE, AML_NONE}, AML_HAS_PKG_LENGTH | AML_HAS_CHILD_OBJ | AML_IN_NAMESPACE},
+/* ThermalZoneOp - 0x5B 0x85 */ {AML_EXT_OP, AML_EXT_THERMAL_ZONE_OP,1, {AML_NAME, AML_NONE, AML_NONE, AML_NONE, AML_NONE, AML_NONE}, AML_HAS_PKG_LENGTH | AML_HAS_CHILD_OBJ | AML_IN_NAMESPACE},
+/* IndexFieldOp - 0x5B 0x86 */ {AML_EXT_OP, AML_EXT_INDEX_FIELD_OP, 3, {AML_NAME, AML_NAME, AML_UINT8, AML_NONE, AML_NONE, AML_NONE}, AML_HAS_PKG_LENGTH},
+/* BankFieldOp - 0x5B 0x87 */ {AML_EXT_OP, AML_EXT_BANK_FIELD_OP, 4, {AML_NAME, AML_NAME, AML_OBJECT, AML_UINT8, AML_NONE, AML_NONE}, AML_HAS_PKG_LENGTH},
+/* DataRegionOp - 0x5B 0x88 */ {AML_EXT_OP, AML_EXT_DATA_REGION_OP, 4, {AML_NAME, AML_OBJECT, AML_OBJECT, AML_OBJECT, AML_NONE, AML_NONE}, AML_IN_NAMESPACE},
+/* RootChar - 0x5C */ {AML_ROOT_CHAR, 0, 0, {AML_NONE, AML_NONE, AML_NONE, AML_NONE, AML_NONE, AML_NONE}, AML_IS_NAME_CHAR},
+/* ParentPrefixChar - 0x5E */ {AML_PARENT_PREFIX_CHAR, 0, 0, {AML_NONE, AML_NONE, AML_NONE, AML_NONE, AML_NONE, AML_NONE}, AML_IS_NAME_CHAR},
+/* NameChar - 0x5F */ {'_', 0, 0, {AML_NONE, AML_NONE, AML_NONE, AML_NONE, AML_NONE, AML_NONE}, AML_IS_NAME_CHAR},
+/* Local0Op - 0x60 */ {AML_LOCAL0, 0, 0, {AML_NONE, AML_NONE, AML_NONE, AML_NONE, AML_NONE, AML_NONE}, 0},
+/* Local1Op - 0x61 */ {AML_LOCAL1, 0, 0, {AML_NONE, AML_NONE, AML_NONE, AML_NONE, AML_NONE, AML_NONE}, 0},
+/* Local2Op - 0x62 */ {AML_LOCAL2, 0, 0, {AML_NONE, AML_NONE, AML_NONE, AML_NONE, AML_NONE, AML_NONE}, 0},
+/* Local3Op - 0x63 */ {AML_LOCAL3, 0, 0, {AML_NONE, AML_NONE, AML_NONE, AML_NONE, AML_NONE, AML_NONE}, 0},
+/* Local4Op - 0x64 */ {AML_LOCAL4, 0, 0, {AML_NONE, AML_NONE, AML_NONE, AML_NONE, AML_NONE, AML_NONE}, 0},
+/* Local5Op - 0x65 */ {AML_LOCAL5, 0, 0, {AML_NONE, AML_NONE, AML_NONE, AML_NONE, AML_NONE, AML_NONE}, 0},
+/* Local6Op - 0x66 */ {AML_LOCAL6, 0, 0, {AML_NONE, AML_NONE, AML_NONE, AML_NONE, AML_NONE, AML_NONE}, 0},
+/* Local7Op - 0x67 */ {AML_LOCAL7, 0, 0, {AML_NONE, AML_NONE, AML_NONE, AML_NONE, AML_NONE, AML_NONE}, 0},
+/* Arg0Op - 0x68 */ {AML_ARG0, 0, 0, {AML_NONE, AML_NONE, AML_NONE, AML_NONE, AML_NONE, AML_NONE}, 0},
+/* Arg1Op - 0x69 */ {AML_ARG1, 0, 0, {AML_NONE, AML_NONE, AML_NONE, AML_NONE, AML_NONE, AML_NONE}, 0},
+/* Arg2Op - 0x6A */ {AML_ARG2, 0, 0, {AML_NONE, AML_NONE, AML_NONE, AML_NONE, AML_NONE, AML_NONE}, 0},
+/* Arg3Op - 0x6B */ {AML_ARG3, 0, 0, {AML_NONE, AML_NONE, AML_NONE, AML_NONE, AML_NONE, AML_NONE}, 0},
+/* Arg4Op - 0x6C */ {AML_ARG4, 0, 0, {AML_NONE, AML_NONE, AML_NONE, AML_NONE, AML_NONE, AML_NONE}, 0},
+/* Arg5Op - 0x6D */ {AML_ARG5, 0, 0, {AML_NONE, AML_NONE, AML_NONE, AML_NONE, AML_NONE, AML_NONE}, 0},
+/* Arg6Op - 0x6E */ {AML_ARG6, 0, 0, {AML_NONE, AML_NONE, AML_NONE, AML_NONE, AML_NONE, AML_NONE}, 0},
+/* StoreOp - 0x70 */ {AML_STORE_OP, 0, 2, {AML_OBJECT, AML_OBJECT, AML_NONE, AML_NONE, AML_NONE, AML_NONE}, 0},
+/* RefOfOp - 0x71 */ {AML_REF_OF_OP, 0, 1, {AML_OBJECT, AML_NONE, AML_NONE, AML_NONE, AML_NONE, AML_NONE}, 0},
+/* AddOp - 0x72 */ {AML_ADD_OP, 0, 3, {AML_OBJECT, AML_OBJECT, AML_OBJECT, AML_NONE, AML_NONE, AML_NONE}, 0},
+/* ConcatOp - 0x73 */ {AML_CONCAT_OP, 0, 3, {AML_OBJECT, AML_OBJECT, AML_OBJECT, AML_NONE, AML_NONE, AML_NONE}, 0},
+/* SubtractOp - 0x74 */ {AML_SUBTRACT_OP, 0, 3, {AML_OBJECT, AML_OBJECT, AML_OBJECT, AML_NONE, AML_NONE, AML_NONE}, 0},
+/* IncrementOp - 0x75 */ {AML_INCREMENT_OP, 0, 1, {AML_OBJECT, AML_NONE, AML_NONE, AML_NONE, AML_NONE, AML_NONE}, 0},
+/* DecrementOp - 0x76 */ {AML_DECREMENT_OP, 0, 1, {AML_OBJECT, AML_NONE, AML_NONE, AML_NONE, AML_NONE, AML_NONE}, 0},
+/* MultiplyOp - 0x77 */ {AML_MULTIPLY_OP, 0, 3, {AML_OBJECT, AML_OBJECT, AML_OBJECT, AML_NONE, AML_NONE, AML_NONE}, 0},
+/* DivideOp - 0x78 */ {AML_DIVIDE_OP, 0, 4, {AML_OBJECT, AML_OBJECT, AML_OBJECT, AML_OBJECT, AML_NONE, AML_NONE}, 0},
+/* ShiftLeftOp - 0x79 */ {AML_SHIFT_LEFT_OP, 0, 3, {AML_OBJECT, AML_OBJECT, AML_OBJECT, AML_NONE, AML_NONE, AML_NONE}, 0},
+/* ShiftRightOp - 0x7A */ {AML_SHIFT_RIGHT_OP, 0, 3, {AML_OBJECT, AML_OBJECT, AML_OBJECT, AML_NONE, AML_NONE, AML_NONE}, 0},
+/* AndOp - 0x7B */ {AML_AND_OP, 0, 3, {AML_OBJECT, AML_OBJECT, AML_OBJECT, AML_NONE, AML_NONE, AML_NONE}, 0},
+/* NAndOp - 0x7C */ {AML_NAND_OP, 0, 3, {AML_OBJECT, AML_OBJECT, AML_OBJECT, AML_NONE, AML_NONE, AML_NONE}, 0},
+/* OrOp - 0x7D */ {AML_OR_OP, 0, 3, {AML_OBJECT, AML_OBJECT, AML_OBJECT, AML_NONE, AML_NONE, AML_NONE}, 0},
+/* NorOp - 0x7E */ {AML_NOR_OP, 0, 3, {AML_OBJECT, AML_OBJECT, AML_OBJECT, AML_NONE, AML_NONE, AML_NONE}, 0},
+/* XOrOp - 0x7F */ {AML_XOR_OP, 0, 3, {AML_OBJECT, AML_OBJECT, AML_OBJECT, AML_NONE, AML_NONE, AML_NONE}, 0},
+/* NotOp - 0x80 */ {AML_NOT_OP, 0, 2, {AML_OBJECT, AML_OBJECT, AML_NONE, AML_NONE, AML_NONE, AML_NONE}, 0},
+/* FindSetLeftBitOp - 0x81 */ {AML_FIND_SET_LEFT_BIT_OP, 0, 2, {AML_OBJECT, AML_OBJECT, AML_NONE, AML_NONE, AML_NONE, AML_NONE}, 0},
+/* FindSetRightBitOp - 0x82 */ {AML_FIND_SET_RIGHT_BIT_OP, 0, 2, {AML_OBJECT, AML_OBJECT, AML_NONE, AML_NONE, AML_NONE, AML_NONE}, 0},
+/* DerefOfOp - 0x83 */ {AML_DEREF_OF_OP, 0, 1, {AML_OBJECT, AML_NONE, AML_NONE, AML_NONE, AML_NONE, AML_NONE}, 0},
+/* ConcatResOp - 0x84 */ {AML_CONCAT_RES_OP, 0, 3, {AML_OBJECT, AML_OBJECT, AML_OBJECT, AML_NONE, AML_NONE, AML_NONE}, 0},
+/* ModOp - 0x85 */ {AML_MOD_OP, 0, 3, {AML_OBJECT, AML_OBJECT, AML_OBJECT, AML_NONE, AML_NONE, AML_NONE}, 0},
+/* NotifyOp - 0x86 */ {AML_NOTIFY_OP, 0, 2, {AML_OBJECT, AML_OBJECT, AML_NONE, AML_NONE, AML_NONE, AML_NONE}, 0},
+/* SizeOfOp - 0x87 */ {AML_SIZE_OF_OP, 0, 1, {AML_OBJECT, AML_NONE, AML_NONE, AML_NONE, AML_NONE, AML_NONE}, 0},
+/* IndexOp - 0x88 */ {AML_INDEX_OP, 0, 3, {AML_OBJECT, AML_OBJECT, AML_OBJECT, AML_NONE, AML_NONE, AML_NONE}, 0},
+/* MatchOp - 0x89 */ {AML_MATCH_OP, 0, 6, {AML_OBJECT, AML_UINT8, AML_OBJECT, AML_UINT8, AML_OBJECT, AML_OBJECT}, 0},
+/* CreateDWordFieldOp - 0x8A */ {AML_CREATE_DWORD_FIELD_OP, 0, 3, {AML_OBJECT, AML_OBJECT, AML_NAME, AML_NONE, AML_NONE, AML_NONE}, 0},
+/* CreateWordFieldOp - 0x8B */ {AML_CREATE_WORD_FIELD_OP, 0, 3, {AML_OBJECT, AML_OBJECT, AML_NAME, AML_NONE, AML_NONE, AML_NONE}, 0},
+/* CreateByteFieldOp - 0x8C */ {AML_CREATE_BYTE_FIELD_OP, 0, 3, {AML_OBJECT, AML_OBJECT, AML_NAME, AML_NONE, AML_NONE, AML_NONE}, 0},
+/* CreateBitFieldOp - 0x8D */ {AML_CREATE_BIT_FIELD_OP, 0, 3, {AML_OBJECT, AML_OBJECT, AML_NAME, AML_NONE, AML_NONE, AML_NONE}, 0},
+/* ObjectTypeOp - 0x8E */ {AML_OBJECT_TYPE_OP, 0, 1, {AML_OBJECT, AML_NONE, AML_NONE, AML_NONE, AML_NONE, AML_NONE}, 0},
+/* CreateQWordFieldOp - 0x8F */ {AML_CREATE_QWORD_FIELD_OP, 0, 3, {AML_OBJECT, AML_OBJECT, AML_NAME, AML_NONE, AML_NONE, AML_NONE}, 0},
+/* LAndOp - 0x90 */ {AML_LAND_OP, 0, 2, {AML_OBJECT, AML_OBJECT, AML_NONE, AML_NONE, AML_NONE, AML_NONE}, 0},
+/* LOrOp - 0x91 */ {AML_LOR_OP, 0, 2, {AML_OBJECT, AML_OBJECT, AML_NONE, AML_NONE, AML_NONE, AML_NONE}, 0},
+/* LNotOp - 0x92 */ {AML_LNOT_OP, 0, 1, {AML_OBJECT, AML_NONE, AML_NONE, AML_NONE, AML_NONE, AML_NONE}, 0},
+/* LEqualOp - 0x93 */ {AML_LEQUAL_OP, 0, 2, {AML_OBJECT, AML_OBJECT, AML_NONE, AML_NONE, AML_NONE, AML_NONE}, 0},
+/* LGreaterOp - 0x94 */ {AML_LGREATER_OP, 0, 2, {AML_OBJECT, AML_OBJECT, AML_NONE, AML_NONE, AML_NONE, AML_NONE}, 0},
+/* LLessOp - 0x95 */ {AML_LLESS_OP, 0, 2, {AML_OBJECT, AML_OBJECT, AML_NONE, AML_NONE, AML_NONE, AML_NONE}, 0},
+/* ToBufferOp - 0x96 */ {AML_TO_BUFFER_OP, 0, 2, {AML_OBJECT, AML_OBJECT, AML_NONE, AML_NONE, AML_NONE, AML_NONE}, 0},
+/* ToDecimalStringOp - 0x97 */ {AML_TO_DEC_STRING_OP, 0, 2, {AML_OBJECT, AML_OBJECT, AML_NONE, AML_NONE, AML_NONE, AML_NONE}, 0},
+/* ToHexStringOp - 0x98 */ {AML_TO_HEX_STRING_OP, 0, 2, {AML_OBJECT, AML_OBJECT, AML_NONE, AML_NONE, AML_NONE, AML_NONE}, 0},
+/* ToIntegerOp - 0x99 */ {AML_TO_INTEGER_OP, 0, 2, {AML_OBJECT, AML_OBJECT, AML_NONE, AML_NONE, AML_NONE, AML_NONE}, 0},
+/* ToStringOp - 0x9C */ {AML_TO_STRING_OP, 0, 3, {AML_OBJECT, AML_OBJECT, AML_OBJECT, AML_NONE, AML_NONE, AML_NONE}, 0},
+/* CopyObjectOp - 0x9D */ {AML_COPY_OBJECT_OP, 0, 2, {AML_OBJECT, AML_OBJECT, AML_NONE, AML_NONE, AML_NONE, AML_NONE}, 0},
+/* MidOp - 0x9E */ {AML_MID_OP, 0, 3, {AML_OBJECT, AML_OBJECT, AML_OBJECT, AML_NONE, AML_NONE, AML_NONE}, 0},
+/* ContinueOp - 0x9F */ {AML_CONTINUE_OP, 0, 0, {AML_NONE, AML_NONE, AML_NONE, AML_NONE, AML_NONE, AML_NONE}, 0},
+/* IfOp - 0xA0 */ {AML_IF_OP, 0, 1, {AML_OBJECT, AML_NONE, AML_NONE, AML_NONE, AML_NONE, AML_NONE}, AML_HAS_PKG_LENGTH | AML_HAS_CHILD_OBJ},
+/* ElseOp - 0xA1 */ {AML_ELSE_OP, 0, 0, {AML_NONE, AML_NONE, AML_NONE, AML_NONE, AML_NONE, AML_NONE}, AML_HAS_PKG_LENGTH | AML_HAS_CHILD_OBJ},
+/* WhileOp - 0xA2 */ {AML_WHILE_OP, 0, 1, {AML_OBJECT, AML_NONE, AML_NONE, AML_NONE, AML_NONE, AML_NONE}, AML_HAS_PKG_LENGTH | AML_HAS_CHILD_OBJ},
+/* NoopOp - 0xA3 */ {AML_NOOP_OP, 0, 0, {AML_NONE, AML_NONE, AML_NONE, AML_NONE, AML_NONE, AML_NONE}, 0},
+/* ReturnOp - 0xA4 */ {AML_RETURN_OP, 0, 1, {AML_OBJECT, AML_NONE, AML_NONE, AML_NONE, AML_NONE, AML_NONE}, 0},
+/* BreakOp - 0xA5 */ {AML_BREAK_OP, 0, 0, {AML_NONE, AML_NONE, AML_NONE, AML_NONE, AML_NONE, AML_NONE}, 0},
+/* BreakPointOp - 0xCC */ {AML_BREAK_POINT_OP, 0, 0, {AML_NONE, AML_NONE, AML_NONE, AML_NONE, AML_NONE, AML_NONE}, 0},
+/* OnesOp - 0xFF */ {AML_ONES_OP, 0, 0, {AML_NONE, AML_NONE, AML_NONE, AML_NONE, AML_NONE, AML_NONE}, 0},
};
GLOBAL_REMOVE_IF_UNREFERENCED
diff --git a/edk2/MdeModulePkg/Universal/Acpi/BootScriptExecutorDxe/ScriptExecute.c b/edk2/MdeModulePkg/Universal/Acpi/BootScriptExecutorDxe/ScriptExecute.c
index 50165126c..971e429f3 100644
--- a/edk2/MdeModulePkg/Universal/Acpi/BootScriptExecutorDxe/ScriptExecute.c
+++ b/edk2/MdeModulePkg/Universal/Acpi/BootScriptExecutorDxe/ScriptExecute.c
@@ -19,7 +19,7 @@ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
#include "ScriptExecute.h"
EFI_GUID mBootScriptExecutorImageGuid = {
- 0x9a8d3433, 0x9fe8, 0x42b6, 0x87, 0xb, 0x1e, 0x31, 0xc8, 0x4e, 0xbe, 0x3b
+ 0x9a8d3433, 0x9fe8, 0x42b6, { 0x87, 0xb, 0x1e, 0x31, 0xc8, 0x4e, 0xbe, 0x3b }
};
/**
diff --git a/edk2/MdeModulePkg/Universal/Console/ConSplitterDxe/ConSplitter.c b/edk2/MdeModulePkg/Universal/Console/ConSplitterDxe/ConSplitter.c
index 870d429c7..bcb9fd6f7 100644
--- a/edk2/MdeModulePkg/Universal/Console/ConSplitterDxe/ConSplitter.c
+++ b/edk2/MdeModulePkg/Universal/Console/ConSplitterDxe/ConSplitter.c
@@ -418,49 +418,12 @@ ConSplitterDriverEntry(
//
Status = ConSplitterTextOutConstructor (&mConOut);
if (!EFI_ERROR (Status)) {
- if (!FeaturePcdGet (PcdConOutGopSupport)) {
- //
- // If Graphics Outpurt protocol not supported, UGA Draw protocol is installed
- // on the virtual handle.
- //
- Status = gBS->InstallMultipleProtocolInterfaces (
- &mConOut.VirtualHandle,
- &gEfiSimpleTextOutProtocolGuid,
- &mConOut.TextOut,
- &gEfiUgaDrawProtocolGuid,
- &mConOut.UgaDraw,
- NULL
- );
- } else if (!FeaturePcdGet (PcdConOutUgaSupport)) {
- //
- // If UGA Draw protocol not supported, Graphics Output Protocol is installed
- // on virtual handle.
- //
- Status = gBS->InstallMultipleProtocolInterfaces (
- &mConOut.VirtualHandle,
- &gEfiSimpleTextOutProtocolGuid,
- &mConOut.TextOut,
- &gEfiGraphicsOutputProtocolGuid,
- &mConOut.GraphicsOutput,
- NULL
- );
- } else {
- //
- // Boot Graphics Output protocol and UGA Draw protocol are supported,
- // both they will be installed on virtual handle.
- //
- Status = gBS->InstallMultipleProtocolInterfaces (
- &mConOut.VirtualHandle,
- &gEfiSimpleTextOutProtocolGuid,
- &mConOut.TextOut,
- &gEfiGraphicsOutputProtocolGuid,
- &mConOut.GraphicsOutput,
- &gEfiUgaDrawProtocolGuid,
- &mConOut.UgaDraw,
- NULL
- );
- }
-
+ Status = gBS->InstallMultipleProtocolInterfaces (
+ &mConOut.VirtualHandle,
+ &gEfiSimpleTextOutProtocolGuid,
+ &mConOut.TextOut,
+ NULL
+ );
if (!EFI_ERROR (Status)) {
//
// Update the EFI System Table with new virtual console
@@ -1315,7 +1278,7 @@ ConSplitterConOutDriverBindingStart (
FreePool (Info);
- } else if (UgaDraw != NULL && FeaturePcdGet (PcdUgaConsumeSupport)) {
+ } else if (UgaDraw != NULL) {
Status = UgaDraw->GetMode (
UgaDraw,
&mConOut.UgaHorizontalResolution,
@@ -2146,6 +2109,8 @@ ConSplitterGrowMapTable (
INT32 *OldTextOutModeMap;
INT32 *SrcAddress;
INT32 Index;
+ UINTN OldStepSize;
+ UINTN NewStepSize;
NewSize = Private->TextOutListCount * sizeof (INT32);
OldTextOutModeMap = Private->TextOutModeMap;
@@ -2183,14 +2148,26 @@ ConSplitterGrowMapTable (
Size = Private->CurrentNumberOfConsoles * sizeof (INT32);
Index = 0;
SrcAddress = OldTextOutModeMap;
+ NewStepSize = NewSize / sizeof(INT32);
+ // If Private->CurrentNumberOfConsoles is not zero and OldTextOutModeMap
+ // is not NULL, it indicates that the original TextOutModeMap is not enough
+ // for the new console devices and has been enlarged by CONSOLE_SPLITTER_ALLOC_UNIT columns.
+ //
+ OldStepSize = NewStepSize - CONSOLE_SPLITTER_ALLOC_UNIT;
//
// Copy the old data to the new one
//
while (Index < Private->TextOutMode.MaxMode) {
CopyMem (TextOutModeMap, SrcAddress, Size);
- TextOutModeMap += NewSize;
- SrcAddress += Size;
+ //
+ // Go to next row of new TextOutModeMap.
+ //
+ TextOutModeMap += NewStepSize;
+ //
+ // Go to next row of old TextOutModeMap.
+ //
+ SrcAddress += OldStepSize;
Index++;
}
//
@@ -2798,7 +2775,7 @@ ConSplitterAddGraphicsOutputMode (
}
}
}
- } else if (UgaDraw != NULL && FeaturePcdGet (PcdUgaConsumeSupport)) {
+ } else if (UgaDraw != NULL) {
//
// Graphics console driver can ensure the same mode for all GOP devices
// so we can get the current mode from this video device
@@ -2838,7 +2815,7 @@ Done:
if (GraphicsOutput != NULL) {
Private->CurrentNumberOfGraphicsOutput++;
}
- if (UgaDraw != NULL && FeaturePcdGet (PcdUgaConsumeSupport)) {
+ if (UgaDraw != NULL) {
Private->CurrentNumberOfUgaDraw++;
}
@@ -3061,13 +3038,13 @@ ConSplitterTextOutAddDevice (
ASSERT (MaxMode >= 1);
DeviceStatus = EFI_DEVICE_ERROR;
- if (FeaturePcdGet (PcdConOutGopSupport)) {
- //
- // If GOP is produced by Consplitter, this device display mode will be added into Graphics Ouput modes.
- //
- if ((GraphicsOutput != NULL) || (UgaDraw != NULL && FeaturePcdGet (PcdUgaConsumeSupport))) {
- DeviceStatus = ConSplitterAddGraphicsOutputMode (Private, GraphicsOutput, UgaDraw);
- }
+ Status = EFI_DEVICE_ERROR;
+
+ //
+ // This device display mode will be added into Graphics Ouput modes.
+ //
+ if ((GraphicsOutput != NULL) || (UgaDraw != NULL)) {
+ DeviceStatus = ConSplitterAddGraphicsOutputMode (Private, GraphicsOutput, UgaDraw);
}
if (FeaturePcdGet (PcdConOutUgaSupport)) {
@@ -3086,7 +3063,7 @@ ConSplitterTextOutAddDevice (
FreePool (Info);
- } else if (UgaDraw != NULL && FeaturePcdGet (PcdUgaConsumeSupport)) {
+ } else if (UgaDraw != NULL) {
Status = UgaDraw->GetMode (
UgaDraw,
&UgaHorizontalResolution,
@@ -3121,6 +3098,46 @@ ConSplitterTextOutAddDevice (
}
}
+ if (((!EFI_ERROR (DeviceStatus)) || (!EFI_ERROR (Status))) &&
+ ((Private->CurrentNumberOfGraphicsOutput + Private->CurrentNumberOfUgaDraw) == 1)) {
+ if (!FeaturePcdGet (PcdConOutGopSupport)) {
+ //
+ // If Graphics Outpurt protocol not supported, UGA Draw protocol is installed
+ // on the virtual handle.
+ //
+ Status = gBS->InstallMultipleProtocolInterfaces (
+ &mConOut.VirtualHandle,
+ &gEfiUgaDrawProtocolGuid,
+ &mConOut.UgaDraw,
+ NULL
+ );
+ } else if (!FeaturePcdGet (PcdConOutUgaSupport)) {
+ //
+ // If UGA Draw protocol not supported, Graphics Output Protocol is installed
+ // on virtual handle.
+ //
+ Status = gBS->InstallMultipleProtocolInterfaces (
+ &mConOut.VirtualHandle,
+ &gEfiGraphicsOutputProtocolGuid,
+ &mConOut.GraphicsOutput,
+ NULL
+ );
+ } else {
+ //
+ // Boot Graphics Output protocol and UGA Draw protocol are supported,
+ // both they will be installed on virtual handle.
+ //
+ Status = gBS->InstallMultipleProtocolInterfaces (
+ &mConOut.VirtualHandle,
+ &gEfiGraphicsOutputProtocolGuid,
+ &mConOut.GraphicsOutput,
+ &gEfiUgaDrawProtocolGuid,
+ &mConOut.UgaDraw,
+ NULL
+ );
+ }
+ }
+
//
// After adding new console device, all existing console devices should be
// synced to the current shared mode.
@@ -3161,7 +3178,7 @@ ConSplitterTextOutDeleteDevice (
TextOutList = Private->TextOutList;
while (Index >= 0) {
if (TextOutList->TextOut == TextOut) {
- if (TextOutList->UgaDraw != NULL && FeaturePcdGet (PcdUgaConsumeSupport)) {
+ if (TextOutList->UgaDraw != NULL) {
Private->CurrentNumberOfUgaDraw--;
}
if (TextOutList->GraphicsOutput != NULL) {
diff --git a/edk2/MdeModulePkg/Universal/Console/GraphicsConsoleDxe/GraphicsConsole.c b/edk2/MdeModulePkg/Universal/Console/GraphicsConsoleDxe/GraphicsConsole.c
index 716703384..52b0ec651 100644
--- a/edk2/MdeModulePkg/Universal/Console/GraphicsConsoleDxe/GraphicsConsole.c
+++ b/edk2/MdeModulePkg/Universal/Console/GraphicsConsoleDxe/GraphicsConsole.c
@@ -533,9 +533,6 @@ GraphicsConsoleControllerDriverStart (
goto Error;
}
}
- } else {
- Status = EFI_UNSUPPORTED;
- goto Error;
}
}
diff --git a/edk2/MdeModulePkg/Universal/LockBox/SmmLockBox/SmmLockBox.c b/edk2/MdeModulePkg/Universal/LockBox/SmmLockBox/SmmLockBox.c
index b9c819058..e8b831e1f 100644
--- a/edk2/MdeModulePkg/Universal/LockBox/SmmLockBox/SmmLockBox.c
+++ b/edk2/MdeModulePkg/Universal/LockBox/SmmLockBox/SmmLockBox.c
@@ -1,15 +1,16 @@
/** @file
-
-Copyright (c) 2010 - 2012, Intel Corporation. All rights reserved.<BR>
-
+ LockBox SMM driver.
+
Caution: This module requires additional review when modified.
This driver will have external input - communicate buffer in SMM mode.
This external input must be validated carefully to avoid security issue like
buffer overflow, integer overflow.
-
+
SmmLockBoxHandler(), SmmLockBoxRestore(), SmmLockBoxUpdate(), SmmLockBoxSave()
will receive untrusted input and do basic validation.
+Copyright (c) 2010 - 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 which accompanies this distribution. The
diff --git a/edk2/MdeModulePkg/Universal/LockBox/SmmLockBox/SmmLockBox.inf b/edk2/MdeModulePkg/Universal/LockBox/SmmLockBox/SmmLockBox.inf
index 559d39f34..529ca7775 100644
--- a/edk2/MdeModulePkg/Universal/LockBox/SmmLockBox/SmmLockBox.inf
+++ b/edk2/MdeModulePkg/Universal/LockBox/SmmLockBox/SmmLockBox.inf
@@ -1,13 +1,13 @@
## @file
# Component description file for LockBox SMM driver.
#
-# Copyright (c) 2010 - 2012, Intel Corporation. All rights reserved.<BR>
-#
# Caution: This module requires additional review when modified.
# This driver will have external input - communicate buffer in SMM mode.
# 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>
+#
# This program and the accompanying materials
# are licensed and made available under the terms and conditions
# of the BSD License which accompanies this distribution. The
diff --git a/edk2/MdeModulePkg/Universal/Network/Dhcp4Dxe/Dhcp4Driver.c b/edk2/MdeModulePkg/Universal/Network/Dhcp4Dxe/Dhcp4Driver.c
index cd4fbbd19..8a773d946 100644
--- a/edk2/MdeModulePkg/Universal/Network/Dhcp4Dxe/Dhcp4Driver.c
+++ b/edk2/MdeModulePkg/Universal/Network/Dhcp4Dxe/Dhcp4Driver.c
@@ -1,6 +1,6 @@
/** @file
-Copyright (c) 2006 - 2011, Intel Corporation. All rights reserved.<BR>
+Copyright (c) 2006 - 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
which accompanies this distribution. The full text of the license may be found at
@@ -146,11 +146,11 @@ DhcpConfigUdpIo (
/**
- Destory the DHCP service. The Dhcp4 service may be partly initialized,
+ Destroy the DHCP service. The Dhcp4 service may be partly initialized,
or partly destroyed. If a resource is destroyed, it is marked as so in
case the destroy failed and being called again later.
- @param[in] DhcpSb The DHCP service instance to destory.
+ @param[in] DhcpSb The DHCP service instance to destroy.
@retval EFI_SUCCESS Always return success.
@@ -212,7 +212,7 @@ Dhcp4CreateService (
DhcpSb->Signature = DHCP_SERVICE_SIGNATURE;
DhcpSb->ServiceState = DHCP_UNCONFIGED;
- DhcpSb->InDestory = FALSE;
+ DhcpSb->InDestroy = FALSE;
DhcpSb->Controller = Controller;
DhcpSb->Image = ImageHandle;
InitializeListHead (&DhcpSb->Children);
@@ -414,7 +414,7 @@ Dhcp4DriverBindingStop (
DhcpSb = DHCP_SERVICE_FROM_THIS (ServiceBinding);
- if (DhcpSb->InDestory) {
+ if (DhcpSb->InDestroy) {
return EFI_SUCCESS;
}
@@ -422,8 +422,8 @@ Dhcp4DriverBindingStop (
if (NumberOfChildren == 0) {
- DhcpSb->InDestory = TRUE;
- DhcpSb->ServiceState = DHCP_DESTORY;
+ DhcpSb->InDestroy = TRUE;
+ DhcpSb->ServiceState = DHCP_DESTROY;
gBS->UninstallProtocolInterface (
NicHandle,
@@ -436,7 +436,7 @@ Dhcp4DriverBindingStop (
FreePool (DhcpSb);
} else {
//
- // Don't use NET_LIST_FOR_EACH_SAFE here, Dhcp4ServiceBindingDestoryChild
+ // Don't use NET_LIST_FOR_EACH_SAFE here, Dhcp4ServiceBindingDestroyChild
// may cause other child to be deleted.
//
while (!IsListEmpty (&DhcpSb->Children)) {
@@ -473,7 +473,7 @@ DhcpInitProtocol (
InitializeListHead (&Instance->Link);
Instance->Handle = NULL;
Instance->Service = DhcpSb;
- Instance->InDestory = FALSE;
+ Instance->InDestroy = FALSE;
Instance->CompletionEvent = NULL;
Instance->RenewRebindEvent = NULL;
Instance->Token = NULL;
@@ -640,15 +640,15 @@ Dhcp4ServiceBindingDestroyChild (
//
// A child can be destroyed more than once. For example,
// Dhcp4DriverBindingStop will destroy all of its children.
- // when caller driver is being stopped, it will destory the
+ // when caller driver is being stopped, it will destroy the
// dhcp child it opens.
//
- if (Instance->InDestory) {
+ if (Instance->InDestroy) {
return EFI_SUCCESS;
}
OldTpl = gBS->RaiseTPL (TPL_CALLBACK);
- Instance->InDestory = TRUE;
+ Instance->InDestroy = TRUE;
//
// Close the Udp4 protocol.
@@ -670,7 +670,7 @@ Dhcp4ServiceBindingDestroyChild (
);
if (EFI_ERROR (Status)) {
- Instance->InDestory = FALSE;
+ Instance->InDestroy = FALSE;
gBS->RestoreTPL (OldTpl);
return Status;
diff --git a/edk2/MdeModulePkg/Universal/Network/Dhcp4Dxe/Dhcp4Impl.h b/edk2/MdeModulePkg/Universal/Network/Dhcp4Dxe/Dhcp4Impl.h
index 438f4cddf..08faff020 100644
--- a/edk2/MdeModulePkg/Universal/Network/Dhcp4Dxe/Dhcp4Impl.h
+++ b/edk2/MdeModulePkg/Universal/Network/Dhcp4Dxe/Dhcp4Impl.h
@@ -6,7 +6,7 @@
RFC 1534: Interoperation Between DHCP and BOOTP
RFC 3396: Encoding Long Options in DHCP.
-Copyright (c) 2006 - 2011, Intel Corporation. All rights reserved.<BR>
+Copyright (c) 2006 - 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
which accompanies this distribution. The full text of the license may be found at
@@ -48,12 +48,12 @@ typedef struct _DHCP_PROTOCOL DHCP_PROTOCOL;
// The state of the DHCP service. It starts as UNCONFIGED. If
// and active child configures the service successfully, it
// goes to CONFIGED. If the active child configures NULL, it
-// goes back to UNCONFIGED. It becomes DESTORY if it is (partly)
-// destoried.
+// goes back to UNCONFIGED. It becomes DESTROY if it is (partly)
+// destroyed.
//
#define DHCP_UNCONFIGED 0
#define DHCP_CONFIGED 1
-#define DHCP_DESTORY 2
+#define DHCP_DESTROY 2
struct _DHCP_PROTOCOL {
@@ -63,7 +63,7 @@ struct _DHCP_PROTOCOL {
EFI_HANDLE Handle;
DHCP_SERVICE *Service;
- BOOLEAN InDestory;
+ BOOLEAN InDestroy;
EFI_EVENT CompletionEvent;
EFI_EVENT RenewRebindEvent;
@@ -83,8 +83,8 @@ struct _DHCP_SERVICE {
UINT32 Signature;
EFI_SERVICE_BINDING_PROTOCOL ServiceBinding;
- INTN ServiceState; // CONFIGED, UNCONFIGED, and DESTORY
- BOOLEAN InDestory;
+ INTN ServiceState; // CONFIGED, UNCONFIGED, and DESTROY
+ BOOLEAN InDestroy;
EFI_HANDLE Controller;
EFI_HANDLE Image;
diff --git a/edk2/MdeModulePkg/Universal/Network/Dhcp4Dxe/Dhcp4Io.c b/edk2/MdeModulePkg/Universal/Network/Dhcp4Dxe/Dhcp4Io.c
index b3ac64644..19ad101d5 100644
--- a/edk2/MdeModulePkg/Universal/Network/Dhcp4Dxe/Dhcp4Io.c
+++ b/edk2/MdeModulePkg/Universal/Network/Dhcp4Dxe/Dhcp4Io.c
@@ -1,7 +1,7 @@
/** @file
EFI DHCP protocol implementation.
-Copyright (c) 2006 - 2011, Intel Corporation. All rights reserved.<BR>
+Copyright (c) 2006 - 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
which accompanies this distribution. The full text of the license may be found at
@@ -972,11 +972,11 @@ DhcpInput (
DhcpSb = (DHCP_SERVICE *) Context;
//
- // Don't restart receive if error occurs or DHCP is destoried.
+ // Don't restart receive if error occurs or DHCP is destroyed.
//
if (EFI_ERROR (IoStatus)) {
return ;
- } else if (DhcpSb->ServiceState == DHCP_DESTORY) {
+ } else if (DhcpSb->ServiceState == DHCP_DESTROY) {
NetbufFree (UdpPacket);
return ;
}
diff --git a/edk2/MdeModulePkg/Universal/Network/Ip4ConfigDxe/Ip4ConfigDriver.c b/edk2/MdeModulePkg/Universal/Network/Ip4ConfigDxe/Ip4ConfigDriver.c
index f8aa51c8c..eee306ad3 100644
--- a/edk2/MdeModulePkg/Universal/Network/Ip4ConfigDxe/Ip4ConfigDriver.c
+++ b/edk2/MdeModulePkg/Universal/Network/Ip4ConfigDxe/Ip4ConfigDriver.c
@@ -1,7 +1,7 @@
/** @file
The driver binding for IP4 CONFIG protocol.
-Copyright (c) 2006 - 2011, Intel Corporation. All rights reserved.<BR>
+Copyright (c) 2006 - 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
which accompanies this distribution. The full text of the license may be found at<BR>
@@ -51,13 +51,19 @@ IP4_CONFIG_INSTANCE mIp4ConfigTemplate = {
FALSE,
FALSE,
{
- 0
+ {
+ 0
+ }
},
{
- 0
+ {
+ 0
+ }
},
{
- 0
+ {
+ 0
+ }
}
},
0,
@@ -70,7 +76,9 @@ IP4_CONFIG_INSTANCE mIp4ConfigTemplate = {
0,
0,
{
- 0
+ {
+ 0
+ }
}
},
(CHAR16 *) NULL,
diff --git a/edk2/MdeModulePkg/Universal/Network/Ip4Dxe/Ip4Driver.c b/edk2/MdeModulePkg/Universal/Network/Ip4Dxe/Ip4Driver.c
index 2d69dcfe3..4ce85a3f5 100644
--- a/edk2/MdeModulePkg/Universal/Network/Ip4Dxe/Ip4Driver.c
+++ b/edk2/MdeModulePkg/Universal/Network/Ip4Dxe/Ip4Driver.c
@@ -1,7 +1,7 @@
/** @file
The driver binding and service binding protocol for IP4 driver.
-Copyright (c) 2005 - 2011, Intel Corporation. All rights reserved.<BR>
+Copyright (c) 2005 - 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
which accompanies this distribution. The full text of the license may be found at
@@ -118,7 +118,7 @@ Ip4DriverBindingSupported (
Clean up a IP4 service binding instance. It will release all
the resource allocated by the instance. The instance may be
partly initialized, or partly destroyed. If a resource is
- destroyed, it is marked as that in case the destory failed and
+ destroyed, it is marked as that in case the destroy failed and
being called again later.
@param[in] IpSb The IP4 serviceing binding instance to clean up
@@ -176,7 +176,7 @@ Ip4CreateService (
IpSb->ServiceBinding.CreateChild = Ip4ServiceBindingCreateChild;
IpSb->ServiceBinding.DestroyChild = Ip4ServiceBindingDestroyChild;
IpSb->State = IP4_SERVICE_UNSTARTED;
- IpSb->InDestory = FALSE;
+ IpSb->InDestroy = FALSE;
IpSb->NumChildren = 0;
InitializeListHead (&IpSb->Children);
@@ -315,7 +315,7 @@ ON_ERROR:
Clean up a IP4 service binding instance. It will release all
the resource allocated by the instance. The instance may be
partly initialized, or partly destroyed. If a resource is
- destroyed, it is marked as that in case the destory failed and
+ destroyed, it is marked as that in case the destroy failed and
being called again later.
@param[in] IpSb The IP4 serviceing binding instance to clean up
@@ -581,7 +581,7 @@ Ip4DriverBindingStop (
OldTpl = gBS->RaiseTPL (TPL_CALLBACK);
- if (IpSb->Ip4Config != NULL && (IpSb->State != IP4_SERVICE_DESTORY)) {
+ if (IpSb->Ip4Config != NULL && (IpSb->State != IP4_SERVICE_DESTROY)) {
IpSb->Ip4Config->Stop (IpSb->Ip4Config);
@@ -651,7 +651,7 @@ Ip4DriverBindingStop (
OldTpl = gBS->RaiseTPL (TPL_CALLBACK);
- if (IpSb->InDestory) {
+ if (IpSb->InDestroy) {
gBS->RestoreTPL (OldTpl);
return EFI_SUCCESS;
}
@@ -668,10 +668,10 @@ Ip4DriverBindingStop (
goto ON_ERROR;
}
- IpSb->InDestory = TRUE;
+ IpSb->InDestroy = TRUE;
State = IpSb->State;
- IpSb->State = IP4_SERVICE_DESTORY;
+ IpSb->State = IP4_SERVICE_DESTROY;
//
// Clear the variable data.
@@ -696,10 +696,10 @@ Ip4DriverBindingStop (
FreePool (IpSb);
} else if (NumberOfChildren == 0) {
- IpSb->InDestory = TRUE;
+ IpSb->InDestroy = TRUE;
State = IpSb->State;
- IpSb->State = IP4_SERVICE_DESTORY;
+ IpSb->State = IP4_SERVICE_DESTROY;
//
// Clear the variable data.
@@ -912,18 +912,18 @@ Ip4ServiceBindingDestroyChild (
OldTpl = gBS->RaiseTPL (TPL_CALLBACK);
//
- // A child can be destoried more than once. For example,
- // Ip4DriverBindingStop will destory all of its children.
- // when UDP driver is being stopped, it will destory all
+ // A child can be destroyed more than once. For example,
+ // Ip4DriverBindingStop will destroy all of its children.
+ // when UDP driver is being stopped, it will destroy all
// the IP child it opens.
//
- if (IpInstance->State == IP4_STATE_DESTORY) {
+ if (IpInstance->State == IP4_STATE_DESTROY) {
gBS->RestoreTPL (OldTpl);
return EFI_SUCCESS;
}
State = IpInstance->State;
- IpInstance->State = IP4_STATE_DESTORY;
+ IpInstance->State = IP4_STATE_DESTROY;
//
// Close the Managed Network protocol.
diff --git a/edk2/MdeModulePkg/Universal/Network/Ip4Dxe/Ip4If.c b/edk2/MdeModulePkg/Universal/Network/Ip4Dxe/Ip4If.c
index d97ab412c..224244164 100644
--- a/edk2/MdeModulePkg/Universal/Network/Ip4Dxe/Ip4If.c
+++ b/edk2/MdeModulePkg/Universal/Network/Ip4Dxe/Ip4If.c
@@ -1,7 +1,7 @@
/** @file
Implement IP4 pesudo interface.
-Copyright (c) 2005 - 2009, Intel Corporation. All rights reserved.<BR>
+Copyright (c) 2005 - 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
which accompanies this distribution. The full text of the license may be found at
@@ -745,10 +745,10 @@ Ip4FreeInterface (
}
//
- // Destory the interface if this is the last IP instance that
+ // 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 destory the ARP requests.
+ // one, and destroy the ARP requests.
//
Ip4CancelFrames (Interface, EFI_ABORTED, Ip4CancelInstanceFrame, NULL);
Ip4CancelReceive (Interface);
diff --git a/edk2/MdeModulePkg/Universal/Network/Ip4Dxe/Ip4If.h b/edk2/MdeModulePkg/Universal/Network/Ip4Dxe/Ip4If.h
index d35e5688c..998fb25bc 100644
--- a/edk2/MdeModulePkg/Universal/Network/Ip4Dxe/Ip4If.h
+++ b/edk2/MdeModulePkg/Universal/Network/Ip4Dxe/Ip4If.h
@@ -1,7 +1,7 @@
/** @file
Definition for IP4 pesudo interface structure.
-Copyright (c) 2005 - 2009, Intel Corporation. All rights reserved.<BR>
+Copyright (c) 2005 - 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
which accompanies this distribution. The full text of the license may be found at
@@ -154,7 +154,7 @@ struct _IP4_INTERFACE {
BOOLEAN Configured;
//
- // Handle used to create/destory ARP child. All the IP children
+ // Handle used to create/destroy ARP child. All the IP children
// share one MNP which is owned by IP service binding.
//
EFI_HANDLE Controller;
diff --git a/edk2/MdeModulePkg/Universal/Network/Ip4Dxe/Ip4Impl.c b/edk2/MdeModulePkg/Universal/Network/Ip4Dxe/Ip4Impl.c
index 2cad1f3bb..f4ce3ea02 100644
--- a/edk2/MdeModulePkg/Universal/Network/Ip4Dxe/Ip4Impl.c
+++ b/edk2/MdeModulePkg/Universal/Network/Ip4Dxe/Ip4Impl.c
@@ -1,6 +1,6 @@
/** @file
-Copyright (c) 2005 - 2010, Intel Corporation. All rights reserved.<BR>
+Copyright (c) 2005 - 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
which accompanies this distribution. The full text of the license may be found at
@@ -1256,7 +1256,7 @@ EfiIp4Configure (
Status = Ip4CleanProtocol (IpInstance);
//
- // Don't change the state if it is DESTORY, consider the following
+ // Don't change the state if it is DESTROY, consider the following
// valid sequence: Mnp is unloaded-->Ip Stopped-->Udp Stopped,
// Configure (ThisIp, NULL). If the state is changed to UNCONFIGED,
// the unload fails miserably.
diff --git a/edk2/MdeModulePkg/Universal/Network/Ip4Dxe/Ip4Impl.h b/edk2/MdeModulePkg/Universal/Network/Ip4Dxe/Ip4Impl.h
index 86e6385ec..563cf7f91 100644
--- a/edk2/MdeModulePkg/Universal/Network/Ip4Dxe/Ip4Impl.h
+++ b/edk2/MdeModulePkg/Universal/Network/Ip4Dxe/Ip4Impl.h
@@ -1,7 +1,7 @@
/** @file
Ip4 internal functions and type defintions.
-Copyright (c) 2005 - 2009, Intel Corporation. All rights reserved.<BR>
+Copyright (c) 2005 - 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
which accompanies this distribution. The full text of the license may be found at
@@ -50,23 +50,23 @@ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
//
// The state of IP4 protocol. It starts from UNCONFIGED. if it is
// successfully configured, it goes to CONFIGED. if configure NULL
-// is called, it becomes UNCONFIGED again. If (partly) destoried, it
-// becomes DESTORY.
+// is called, it becomes UNCONFIGED again. If (partly) destroyed, it
+// becomes DESTROY.
//
#define IP4_STATE_UNCONFIGED 0
#define IP4_STATE_CONFIGED 1
-#define IP4_STATE_DESTORY 2
+#define IP4_STATE_DESTROY 2
//
// The state of IP4 service. It starts from UNSTARTED. It transits
// to STARTED if autoconfigure is started. If default address is
-// configured, it becomes CONFIGED. and if partly destoried, it goes
-// to DESTORY.
+// configured, it becomes CONFIGED. and if partly destroyed, it goes
+// to DESTROY.
//
#define IP4_SERVICE_UNSTARTED 0
#define IP4_SERVICE_STARTED 1
#define IP4_SERVICE_CONFIGED 2
-#define IP4_SERVICE_DESTORY 3
+#define IP4_SERVICE_DESTROY 3
///
@@ -160,7 +160,7 @@ struct _IP4_SERVICE {
UINT32 Signature;
EFI_SERVICE_BINDING_PROTOCOL ServiceBinding;
INTN State;
- BOOLEAN InDestory;
+ BOOLEAN InDestroy;
//
// List of all the IP instances and interfaces, and default
diff --git a/edk2/MdeModulePkg/Universal/Network/Ip4Dxe/Ip4Input.c b/edk2/MdeModulePkg/Universal/Network/Ip4Dxe/Ip4Input.c
index 0990d1803..bd15fc2e1 100644
--- a/edk2/MdeModulePkg/Universal/Network/Ip4Dxe/Ip4Input.c
+++ b/edk2/MdeModulePkg/Universal/Network/Ip4Dxe/Ip4Input.c
@@ -1,7 +1,7 @@
/** @file
IP4 input process.
-Copyright (c) 2005 - 2011, Intel Corporation. All rights reserved.<BR>
+Copyright (c) 2005 - 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
which accompanies this distribution. The full text of the license may be found at
@@ -845,7 +845,7 @@ Ip4AccpetFrame (
IpSb = (IP4_SERVICE *) Context;
Option = NULL;
- if (EFI_ERROR (IoStatus) || (IpSb->State == IP4_SERVICE_DESTORY)) {
+ if (EFI_ERROR (IoStatus) || (IpSb->State == IP4_SERVICE_DESTROY)) {
goto DROP;
}
diff --git a/edk2/MdeModulePkg/Universal/Network/Mtftp4Dxe/Mtftp4Driver.c b/edk2/MdeModulePkg/Universal/Network/Mtftp4Dxe/Mtftp4Driver.c
index 1c74b5b08..2a12b1d5e 100644
--- a/edk2/MdeModulePkg/Universal/Network/Mtftp4Dxe/Mtftp4Driver.c
+++ b/edk2/MdeModulePkg/Universal/Network/Mtftp4Dxe/Mtftp4Driver.c
@@ -1,7 +1,7 @@
/** @file
Implementation of Mtftp drivers.
-Copyright (c) 2006 - 2010, Intel Corporation. All rights reserved.<BR>
+Copyright (c) 2006 - 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
which accompanies this distribution. The full text of the license may be found at
@@ -159,7 +159,7 @@ Mtftp4CreateService (
MtftpSb->Signature = MTFTP4_SERVICE_SIGNATURE;
MtftpSb->ServiceBinding = gMtftp4ServiceBindingTemplete;
- MtftpSb->InDestory = FALSE;
+ MtftpSb->InDestroy = FALSE;
MtftpSb->ChildrenNum = 0;
InitializeListHead (&MtftpSb->Children);
@@ -374,7 +374,7 @@ Mtftp4DriverBindingStop (
MtftpSb = MTFTP4_SERVICE_FROM_THIS (ServiceBinding);
- if (MtftpSb->InDestory) {
+ if (MtftpSb->InDestroy) {
return EFI_SUCCESS;
}
@@ -382,7 +382,7 @@ Mtftp4DriverBindingStop (
if (NumberOfChildren == 0) {
- MtftpSb->InDestory = TRUE;
+ MtftpSb->InDestroy = TRUE;
gBS->UninstallProtocolInterface (
NicHandle,
@@ -429,7 +429,7 @@ Mtftp4InitProtocol (
InitializeListHead (&Instance->Link);
CopyMem (&Instance->Mtftp4, &gMtftp4ProtocolTemplate, sizeof (Instance->Mtftp4));
Instance->State = MTFTP4_STATE_UNCONFIGED;
- Instance->InDestory = FALSE;
+ Instance->InDestroy = FALSE;
Instance->Service = MtftpSb;
InitializeListHead (&Instance->Blocks);
@@ -548,14 +548,14 @@ ON_ERROR:
/**
- Destory one of the service binding's child.
+ Destroy one of the service binding's child.
@param This The service binding instance
- @param ChildHandle The child handle to destory
+ @param ChildHandle The child handle to destroy
@retval EFI_INVALID_PARAMETER The parameter is invaid.
- @retval EFI_UNSUPPORTED The child may have already been destoried.
- @retval EFI_SUCCESS The child is destoried and removed from the
+ @retval EFI_UNSUPPORTED The child may have already been destroyed.
+ @retval EFI_SUCCESS The child is destroyed and removed from the
parent's child list.
**/
@@ -599,11 +599,11 @@ Mtftp4ServiceBindingDestroyChild (
return EFI_INVALID_PARAMETER;
}
- if (Instance->InDestory) {
+ if (Instance->InDestroy) {
return EFI_SUCCESS;
}
- Instance->InDestory = TRUE;
+ Instance->InDestroy = TRUE;
//
// Close the Udp4 protocol.
@@ -625,7 +625,7 @@ Mtftp4ServiceBindingDestroyChild (
);
if (EFI_ERROR (Status)) {
- Instance->InDestory = FALSE;
+ Instance->InDestroy = FALSE;
return Status;
}
diff --git a/edk2/MdeModulePkg/Universal/Network/Mtftp4Dxe/Mtftp4Driver.h b/edk2/MdeModulePkg/Universal/Network/Mtftp4Dxe/Mtftp4Driver.h
index 392ea5166..63828bd43 100644
--- a/edk2/MdeModulePkg/Universal/Network/Mtftp4Dxe/Mtftp4Driver.h
+++ b/edk2/MdeModulePkg/Universal/Network/Mtftp4Dxe/Mtftp4Driver.h
@@ -1,7 +1,7 @@
/** @file
Mtftp drivers function header.
-Copyright (c) 2006 - 2007, Intel Corporation. All rights reserved.<BR>
+Copyright (c) 2006 - 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
which accompanies this distribution. The full text of the license may be found at
@@ -113,14 +113,14 @@ Mtftp4ServiceBindingCreateChild (
);
/**
- Destory one of the service binding's child.
+ Destroy one of the service binding's child.
@param This The service binding instance
- @param ChildHandle The child handle to destory
+ @param ChildHandle The child handle to destroy
@retval EFI_INVALID_PARAMETER The parameter is invaid.
- @retval EFI_UNSUPPORTED The child may have already been destoried.
- @retval EFI_SUCCESS The child is destoried and removed from the
+ @retval EFI_UNSUPPORTED The child may have already been destroyed.
+ @retval EFI_SUCCESS The child is destroyed and removed from the
parent's child list.
**/
diff --git a/edk2/MdeModulePkg/Universal/Network/Mtftp4Dxe/Mtftp4Impl.c b/edk2/MdeModulePkg/Universal/Network/Mtftp4Dxe/Mtftp4Impl.c
index 3c68235d4..5183e1a5b 100644
--- a/edk2/MdeModulePkg/Universal/Network/Mtftp4Dxe/Mtftp4Impl.c
+++ b/edk2/MdeModulePkg/Universal/Network/Mtftp4Dxe/Mtftp4Impl.c
@@ -1,7 +1,7 @@
/** @file
Interface routine for Mtftp4.
-Copyright (c) 2006 - 2011, Intel Corporation. All rights reserved.<BR>
+Copyright (c) 2006 - 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
which accompanies this distribution. The full text of the license may be found at
@@ -1073,7 +1073,7 @@ EfiMtftp4Poll (
if (Instance->State == MTFTP4_STATE_UNCONFIGED) {
return EFI_NOT_STARTED;
- } else if (Instance->State == MTFTP4_STATE_DESTORY) {
+ } else if (Instance->State == MTFTP4_STATE_DESTROY) {
return EFI_DEVICE_ERROR;
}
diff --git a/edk2/MdeModulePkg/Universal/Network/Mtftp4Dxe/Mtftp4Impl.h b/edk2/MdeModulePkg/Universal/Network/Mtftp4Dxe/Mtftp4Impl.h
index 502fcaa53..41f524abb 100644
--- a/edk2/MdeModulePkg/Universal/Network/Mtftp4Dxe/Mtftp4Impl.h
+++ b/edk2/MdeModulePkg/Universal/Network/Mtftp4Dxe/Mtftp4Impl.h
@@ -9,7 +9,7 @@
RFC2348 - TFTP Blocksize Option
RFC2349 - TFTP Timeout Interval and Transfer Size Options
-Copyright (c) 2006 - 2009, Intel Corporation. All rights reserved.<BR>
+Copyright (c) 2006 - 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
which accompanies this distribution. The full text of the license may be found at
@@ -59,7 +59,7 @@ typedef struct _MTFTP4_PROTOCOL MTFTP4_PROTOCOL;
#define MTFTP4_STATE_UNCONFIGED 0
#define MTFTP4_STATE_CONFIGED 1
-#define MTFTP4_STATE_DESTORY 2
+#define MTFTP4_STATE_DESTROY 2
///
/// Mtftp service block
@@ -68,7 +68,7 @@ struct _MTFTP4_SERVICE {
UINT32 Signature;
EFI_SERVICE_BINDING_PROTOCOL ServiceBinding;
- BOOLEAN InDestory;
+ BOOLEAN InDestroy;
UINT16 ChildrenNum;
LIST_ENTRY Children;
@@ -99,7 +99,7 @@ struct _MTFTP4_PROTOCOL {
EFI_MTFTP4_PROTOCOL Mtftp4;
INTN State;
- BOOLEAN InDestory;
+ BOOLEAN InDestroy;
MTFTP4_SERVICE *Service;
EFI_HANDLE Handle;
diff --git a/edk2/MdeModulePkg/Universal/Network/Tcp4Dxe/SockImpl.c b/edk2/MdeModulePkg/Universal/Network/Tcp4Dxe/SockImpl.c
index c627a140a..2e3164382 100644
--- a/edk2/MdeModulePkg/Universal/Network/Tcp4Dxe/SockImpl.c
+++ b/edk2/MdeModulePkg/Universal/Network/Tcp4Dxe/SockImpl.c
@@ -1,7 +1,7 @@
/** @file
Implementation of the Socket.
-Copyright (c) 2005 - 2009, Intel Corporation. All rights reserved.<BR>
+Copyright (c) 2005 - 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
which accompanies this distribution. The full text of the license may be found at
@@ -739,7 +739,7 @@ SockDestroy (
}
//
- // Destory the RcvBuffer Queue and SendBuffer Queue
+ // Destroy the RcvBuffer Queue and SendBuffer Queue
//
NetbufQueFree (Sock->RcvBuffer.DataQueue);
NetbufQueFree (Sock->SndBuffer.DataQueue);
@@ -754,7 +754,7 @@ SockDestroy (
DEBUG (
(EFI_D_INFO,
- "SockDestory: Delete a unaccepted socket from parent"
+ "SockDestroy: Delete a unaccepted socket from parent"
"now conncnt is %d\n",
Sock->Parent->ConnCnt)
);
diff --git a/edk2/MdeModulePkg/Universal/Network/Tcp4Dxe/SockInterface.c b/edk2/MdeModulePkg/Universal/Network/Tcp4Dxe/SockInterface.c
index d17bfa8b9..ac36460da 100644
--- a/edk2/MdeModulePkg/Universal/Network/Tcp4Dxe/SockInterface.c
+++ b/edk2/MdeModulePkg/Universal/Network/Tcp4Dxe/SockInterface.c
@@ -131,7 +131,7 @@ SockBufferToken (
/**
- Destory the socket Sock and its associated protocol control block.
+ Destroy the socket Sock and its associated protocol control block.
@param Sock The socket to be destroyed.
diff --git a/edk2/MdeModulePkg/Universal/Network/Tcp4Dxe/Socket.h b/edk2/MdeModulePkg/Universal/Network/Tcp4Dxe/Socket.h
index 0317efa32..b8ace790c 100644
--- a/edk2/MdeModulePkg/Universal/Network/Tcp4Dxe/Socket.h
+++ b/edk2/MdeModulePkg/Universal/Network/Tcp4Dxe/Socket.h
@@ -1,7 +1,7 @@
/** @file
Socket header file.
-Copyright (c) 2005 - 2009, Intel Corporation. All rights reserved.<BR>
+Copyright (c) 2005 - 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
which accompanies this distribution. The full text of the license may be found at
@@ -723,7 +723,7 @@ SockCreateChild (
);
/**
- Destory the socket Sock and its associated protocol control block.
+ Destroy the socket Sock and its associated protocol control block.
@param Sock The socket to be destroyed.
diff --git a/edk2/MdeModulePkg/Universal/Network/UefiPxeBcDxe/PxeBcDhcp.c b/edk2/MdeModulePkg/Universal/Network/UefiPxeBcDxe/PxeBcDhcp.c
index 5f3d91354..fa3594d36 100644
--- a/edk2/MdeModulePkg/Universal/Network/UefiPxeBcDxe/PxeBcDhcp.c
+++ b/edk2/MdeModulePkg/Universal/Network/UefiPxeBcDxe/PxeBcDhcp.c
@@ -1,7 +1,7 @@
/** @file
Support for PxeBc dhcp functions.
-Copyright (c) 2007 - 2011, Intel Corporation. All rights reserved.<BR>
+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
which accompanies this distribution. The full text of the license may be found at
@@ -203,7 +203,7 @@ PxeBcParseCachedDhcpPacket (
(Offer->Dhcp4.Header.BootFileName[0] != 0)) {
//
// If the bootfile is not present and bootfilename is present in dhcp packet, just parse it.
- // And do not count dhcp option header, or else will destory the serverhostname.
+ // And do not count dhcp option header, or else will destroy the serverhostname.
//
Options[PXEBC_DHCP4_TAG_INDEX_BOOTFILE] = (EFI_DHCP4_PACKET_OPTION *) (&Offer->Dhcp4.Header.BootFileName[0] -
OFFSET_OF (EFI_DHCP4_PACKET_OPTION, Data[0]));
diff --git a/edk2/MdePkg/Include/IndustryStandard/Acpi50.h b/edk2/MdePkg/Include/IndustryStandard/Acpi50.h
index 1a893604f..96227c0d9 100644
--- a/edk2/MdePkg/Include/IndustryStandard/Acpi50.h
+++ b/edk2/MdePkg/Include/IndustryStandard/Acpi50.h
@@ -1008,6 +1008,8 @@ typedef struct {
///
typedef struct {
EFI_ACPI_5_0_PMMT_COMMON_MEMORY_AGGREGATOR_DEVICE_STRUCTURE Header;
+ UINT16 SocketIdentifier;
+ UINT16 Reserved;
//EFI_ACPI_5_0_PMMT_MEMORY_CONTROLLER_MEMORY_AGGREGATOR_DEVICE_STRUCTURE MemoryController[];
} EFI_ACPI_5_0_PMMT_SOCKET_MEMORY_AGGREGATOR_DEVICE_STRUCTURE;
diff --git a/edk2/MdePkg/Include/IndustryStandard/DebugPort2Table.h b/edk2/MdePkg/Include/IndustryStandard/DebugPort2Table.h
index b50aff6d0..4014c9fdb 100644
--- a/edk2/MdePkg/Include/IndustryStandard/DebugPort2Table.h
+++ b/edk2/MdePkg/Include/IndustryStandard/DebugPort2Table.h
@@ -2,14 +2,14 @@
ACPI debug port 2 table definition, defined at
Microsoft DebugPort2Specification.
-Copyright (c) 2012, Intel Corporation. All rights reserved.<BR>
-This software and associated documentation (if any) is furnished
-under a license and may only be used or copied in accordance
-with the terms of the license. Except as permitted by such
-license, no part of this software or documentation may be
-reproduced, stored in a retrieval system, or transmitted in any
-form or by any means without the express written consent of
-Intel Corporation.
+ Copyright (c) 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
+ 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.
**/
diff --git a/edk2/MdePkg/Include/IndustryStandard/DebugPortTable.h b/edk2/MdePkg/Include/IndustryStandard/DebugPortTable.h
index 779082996..6c726324a 100644
--- a/edk2/MdePkg/Include/IndustryStandard/DebugPortTable.h
+++ b/edk2/MdePkg/Include/IndustryStandard/DebugPortTable.h
@@ -2,14 +2,14 @@
ACPI debug port table definition, defined at
Microsoft DebugPortSpecification.
-Copyright (c) 2012, Intel Corporation. All rights reserved.<BR>
-This software and associated documentation (if any) is furnished
-under a license and may only be used or copied in accordance
-with the terms of the license. Except as permitted by such
-license, no part of this software or documentation may be
-reproduced, stored in a retrieval system, or transmitted in any
-form or by any means without the express written consent of
-Intel Corporation.
+ Copyright (c) 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
+ 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.
**/
diff --git a/edk2/MdePkg/Include/IndustryStandard/Pal.h b/edk2/MdePkg/Include/IndustryStandard/Pal.h
index 27874553b..aceeaae0a 100644
--- a/edk2/MdePkg/Include/IndustryStandard/Pal.h
+++ b/edk2/MdePkg/Include/IndustryStandard/Pal.h
@@ -1,7 +1,7 @@
/** @file
Main PAL API's defined in Intel Itanium Architecture Software Developer's Manual.
- Copyright (c) 2006 - 2008, Intel Corporation. All rights reserved.<BR>
+ Copyright (c) 2006 - 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
which accompanies this distribution. The full text of the license may be found at
@@ -991,7 +991,7 @@ typedef struct {
///< enabled.
UINT64 ThreadsPerCore:8; ///< Number of threads per core.
UINT64 Reserved1:8;
- UINT64 CoresPerProcessor; ///< Total number of cores on this
+ UINT64 CoresPerProcessor:8; ///< Total number of cores on this
///< physical processor package.
UINT64 Reserved2:8;
UINT64 PhysicalProcessorPackageId:8; ///< Physical processor package
@@ -2708,9 +2708,10 @@ typedef struct {
///< structure hierarchy level-3 4 -
///< Error structure hierarchy level-4
///< All other values are reserved.
- ///< Reserved 63:16 Reserved
- UINT64 Reserved:48;
+ UINT64 Reserved:32; ///< Reserved 47:16 Reserved
+
+ UINT64 ImplSpec:16; ///< Bit63:48, Processor specific error injection capabilities.
} PAL_MC_ERROR_TYPE_INFO;
typedef struct {
diff --git a/edk2/MdePkg/Include/IndustryStandard/SerialPortConsoleRedirectionTable.h b/edk2/MdePkg/Include/IndustryStandard/SerialPortConsoleRedirectionTable.h
index f76f73351..74ea5b3f9 100644
--- a/edk2/MdePkg/Include/IndustryStandard/SerialPortConsoleRedirectionTable.h
+++ b/edk2/MdePkg/Include/IndustryStandard/SerialPortConsoleRedirectionTable.h
@@ -2,7 +2,7 @@
ACPI Serial Port Console Redirection Table as defined by Microsoft in
http://www.microsoft.com/whdc/system/platform/server/spcr.mspx
- Copyright (c) 2007 - 2008, Intel Corporation. All rights reserved.<BR>
+ 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
which accompanies this distribution. The full text of the license may be found at
@@ -96,8 +96,8 @@ typedef struct {
//
#define EFI_ACPI_SERIAL_PORT_CONSOLE_REDIRECTION_TABLE_BAUD_RATE_9600 3
#define EFI_ACPI_SERIAL_PORT_CONSOLE_REDIRECTION_TABLE_BAUD_RATE_19200 4
-#define EFI_ACPI_SERIAL_PORT_CONSOLE_REDIRECTION_TABLE_BAUD_RATE_57600 5
-#define EFI_ACPI_SERIAL_PORT_CONSOLE_REDIRECTION_TABLE_BAUD_RATE_115200 6
+#define EFI_ACPI_SERIAL_PORT_CONSOLE_REDIRECTION_TABLE_BAUD_RATE_57600 6
+#define EFI_ACPI_SERIAL_PORT_CONSOLE_REDIRECTION_TABLE_BAUD_RATE_115200 7
//
// Parity
diff --git a/edk2/NetworkPkg/Application/Ping6/Ping6.c b/edk2/NetworkPkg/Application/Ping6/Ping6.c
index e0f6cd89e..0de332fcc 100644
--- a/edk2/NetworkPkg/Application/Ping6/Ping6.c
+++ b/edk2/NetworkPkg/Application/Ping6/Ping6.c
@@ -1,7 +1,7 @@
/** @file
The implementation for Ping6 application.
- Copyright (c) 2009 - 2011, Intel Corporation. All rights reserved.<BR>
+ Copyright (c) 2009 - 2012, Intel Corporation. All rights reserved.<BR>
This program and the accompanying materials
are licensed and made available under the terms and conditions of the BSD License
@@ -802,13 +802,13 @@ ON_ERROR:
}
/**
- Destory the IP6 instance.
+ Destroy the IP6 instance.
@param[in] Private The pointer of PING6_PRIVATE_DATA.
**/
VOID
-Ping6DestoryIp6Instance (
+Ping6DestroyIp6Instance (
IN PING6_PRIVATE_DATA *Private
)
{
@@ -1019,7 +1019,7 @@ ON_EXIT:
}
if (Private->Ip6ChildHandle != NULL) {
- Ping6DestoryIp6Instance (Private);
+ Ping6DestroyIp6Instance (Private);
}
FreePool (Private);
diff --git a/edk2/NetworkPkg/Dhcp6Dxe/Dhcp6Driver.c b/edk2/NetworkPkg/Dhcp6Dxe/Dhcp6Driver.c
index b789f2a47..346986bd1 100644
--- a/edk2/NetworkPkg/Dhcp6Dxe/Dhcp6Driver.c
+++ b/edk2/NetworkPkg/Dhcp6Dxe/Dhcp6Driver.c
@@ -82,7 +82,7 @@ Dhcp6ConfigureUdpIo (
/**
- Destory the Dhcp6 service. The Dhcp6 service may be partly initialized,
+ Destroy the Dhcp6 service. The Dhcp6 service may be partly initialized,
or partly destroyed. If a resource is destroyed, it is marked as such in
case the destroy failed and being called again later.
@@ -95,7 +95,7 @@ Dhcp6DestroyService (
)
{
//
- // All children instances should have been already destoryed here.
+ // All children instances should have been already destroyed here.
//
ASSERT (Service->NumOfChild == 0);
@@ -155,7 +155,7 @@ Dhcp6CreateService (
// Initialize the fields of the new Dhcp6 service.
//
Dhcp6Srv->Signature = DHCP6_SERVICE_SIGNATURE;
- Dhcp6Srv->InDestory = FALSE;
+ Dhcp6Srv->InDestroy = FALSE;
Dhcp6Srv->Controller = Controller;
Dhcp6Srv->Image = ImageHandle;
Dhcp6Srv->Xid = (0xffffff & NET_RANDOM (NetRandomInitSeed ()));
@@ -294,7 +294,7 @@ Dhcp6CreateInstance (
Dhcp6Ins->Signature = DHCP6_INSTANCE_SIGNATURE;
Dhcp6Ins->UdpSts = EFI_ALREADY_STARTED;
Dhcp6Ins->Service = Service;
- Dhcp6Ins->InDestory = FALSE;
+ Dhcp6Ins->InDestroy = FALSE;
Dhcp6Ins->MediaPresent = TRUE;
CopyMem (
@@ -528,7 +528,7 @@ Dhcp6DriverBindingStop (
Service = DHCP6_SERVICE_FROM_THIS (ServiceBinding);
- if (Service->InDestory) {
+ if (Service->InDestroy) {
return EFI_SUCCESS;
}
@@ -536,9 +536,9 @@ Dhcp6DriverBindingStop (
if (NumberOfChildren == 0) {
//
- // Destory the service itself if no child instance left.
+ // Destroy the service itself if no child instance left.
//
- Service->InDestory = TRUE;
+ Service->InDestroy = TRUE;
Status = gBS->UninstallProtocolInterface (
NicHandle,
@@ -547,7 +547,7 @@ Dhcp6DriverBindingStop (
);
if (EFI_ERROR (Status)) {
- Service->InDestory = FALSE;
+ Service->InDestroy = FALSE;
goto ON_EXIT;
}
@@ -555,7 +555,7 @@ Dhcp6DriverBindingStop (
} else {
//
- // Destory all the children instances before destory the service.
+ // Destroy all the children instances before destroy the service.
//
while (!IsListEmpty (&Service->Child)) {
Instance = NET_LIST_HEAD (&Service->Child, DHCP6_INSTANCE, Link);
@@ -747,13 +747,13 @@ Dhcp6ServiceBindingDestroyChild (
return EFI_INVALID_PARAMETER;
}
- if (Instance->InDestory) {
+ if (Instance->InDestroy) {
return EFI_SUCCESS;
}
OldTpl = gBS->RaiseTPL (TPL_CALLBACK);
- Instance->InDestory = TRUE;
+ Instance->InDestroy = TRUE;
Status = gBS->CloseProtocol (
Service->UdpIo->UdpHandle,
@@ -763,7 +763,7 @@ Dhcp6ServiceBindingDestroyChild (
);
if (EFI_ERROR (Status)) {
- Instance->InDestory = FALSE;
+ Instance->InDestroy = FALSE;
gBS->RestoreTPL (OldTpl);
return Status;
}
@@ -778,7 +778,7 @@ Dhcp6ServiceBindingDestroyChild (
);
if (EFI_ERROR (Status)) {
- Instance->InDestory = FALSE;
+ Instance->InDestroy = FALSE;
gBS->RestoreTPL (OldTpl);
return Status;
}
diff --git a/edk2/NetworkPkg/Dhcp6Dxe/Dhcp6Impl.h b/edk2/NetworkPkg/Dhcp6Dxe/Dhcp6Impl.h
index 0e206cd50..d4e9746be 100644
--- a/edk2/NetworkPkg/Dhcp6Dxe/Dhcp6Impl.h
+++ b/edk2/NetworkPkg/Dhcp6Dxe/Dhcp6Impl.h
@@ -246,7 +246,7 @@ struct _DHCP6_INSTANCE {
UINT8 AdPref;
EFI_IPv6_ADDRESS *Unicast;
EFI_STATUS UdpSts;
- BOOLEAN InDestory;
+ BOOLEAN InDestroy;
BOOLEAN MediaPresent;
UINT64 StartTime;
};
@@ -266,7 +266,7 @@ struct _DHCP6_SERVICE {
UINT32 Xid;
LIST_ENTRY Child;
UINTN NumOfChild;
- BOOLEAN InDestory;
+ BOOLEAN InDestroy;
};
/**
diff --git a/edk2/NetworkPkg/Dhcp6Dxe/Dhcp6Io.c b/edk2/NetworkPkg/Dhcp6Dxe/Dhcp6Io.c
index 656fd8390..f2e33f335 100644
--- a/edk2/NetworkPkg/Dhcp6Dxe/Dhcp6Io.c
+++ b/edk2/NetworkPkg/Dhcp6Dxe/Dhcp6Io.c
@@ -52,7 +52,7 @@ Dhcp6EnqueueRetry (
}
//
- // Save tx packet pointer, and it will be destoryed when reply received.
+ // Save tx packet pointer, and it will be destroyed when reply received.
//
TxCb->TxPacket = Packet;
TxCb->Xid = Packet->Dhcp6.Header.TransactionId;
@@ -2510,7 +2510,7 @@ Dhcp6HandleStateful (
ClientId = Service->ClientId;
Status = EFI_SUCCESS;
- if (Instance->InDestory || Instance->Config == NULL) {
+ if (Instance->InDestroy || Instance->Config == NULL) {
goto ON_CONTINUE;
}
@@ -2624,7 +2624,7 @@ Dhcp6HandleStateless (
IsMatched = FALSE;
InfCb = NULL;
- if (Instance->InDestory) {
+ if (Instance->InDestroy) {
goto ON_EXIT;
}
diff --git a/edk2/NetworkPkg/IScsiDxe/IScsiIbft.c b/edk2/NetworkPkg/IScsiDxe/IScsiIbft.c
index e90c982bc..879d310cc 100644
--- a/edk2/NetworkPkg/IScsiDxe/IScsiIbft.c
+++ b/edk2/NetworkPkg/IScsiDxe/IScsiIbft.c
@@ -1,7 +1,7 @@
/** @file
Implementation for iSCSI Boot Firmware Table publication.
-Copyright (c) 2004 - 2011, Intel Corporation. All rights reserved.<BR>
+Copyright (c) 2004 - 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
which accompanies this distribution. The full text of the license may be found at
@@ -310,18 +310,18 @@ IScsiFillNICAndTargetSections (
//
// Map the various v4 addresses into v6 addresses.
//
- IScsiMapV4ToV6Addr (&NvData->LocalIp, &Nic->Ip);
- IScsiMapV4ToV6Addr (&NvData->Gateway, &Nic->Gateway);
+ IScsiMapV4ToV6Addr (&NvData->LocalIp.v4, &Nic->Ip);
+ IScsiMapV4ToV6Addr (&NvData->Gateway.v4, &Nic->Gateway);
IScsiMapV4ToV6Addr (&Attempt->PrimaryDns.v4, &Nic->PrimaryDns);
IScsiMapV4ToV6Addr (&Attempt->SecondaryDns.v4, &Nic->SecondaryDns);
IScsiMapV4ToV6Addr (&Attempt->DhcpServer.v4, &Nic->DhcpServer);
} else if (NvData->IpMode == IP_MODE_IP6 || NvData->IpMode == IP_MODE_AUTOCONFIG) {
- //
- // TODO: The subnet mask/local ip/gateway/dhcpserver for iBFT-IPv6 needs to be
- // confirmed with spec owner.
- //
+ Nic->SubnetMaskPrefixLength = NvData->PrefixLength;
+ CopyMem (&Nic->Ip, &NvData->LocalIp, sizeof (EFI_IPv6_ADDRESS));
+ CopyMem (&Nic->Gateway, &NvData->Gateway, sizeof (EFI_IPv6_ADDRESS));
+
CopyMem (&Nic->PrimaryDns, &Attempt->PrimaryDns, sizeof (EFI_IPv6_ADDRESS));
CopyMem (&Nic->SecondaryDns, &Attempt->SecondaryDns, sizeof (EFI_IPv6_ADDRESS));
//
diff --git a/edk2/NetworkPkg/IScsiDxe/IScsiImpl.h b/edk2/NetworkPkg/IScsiDxe/IScsiImpl.h
index ccb83edb8..7c8eb3784 100644
--- a/edk2/NetworkPkg/IScsiDxe/IScsiImpl.h
+++ b/edk2/NetworkPkg/IScsiDxe/IScsiImpl.h
@@ -1,7 +1,7 @@
/** @file
The shared head file for iSCSI driver.
-Copyright (c) 2004 - 2011, Intel Corporation. All rights reserved.<BR>
+Copyright (c) 2004 - 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
which accompanies this distribution. The full text of the license may be found at
@@ -23,6 +23,7 @@ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
#include <Protocol/DevicePath.h>
#include <Protocol/HiiConfigAccess.h>
+#include <Protocol/Ip6.h>
#include <Protocol/Dhcp4.h>
#include <Protocol/Dhcp6.h>
#include <Protocol/Tcp4.h>
diff --git a/edk2/NetworkPkg/IScsiDxe/IScsiMisc.h b/edk2/NetworkPkg/IScsiDxe/IScsiMisc.h
index 8646f666a..c9ff96da6 100644
--- a/edk2/NetworkPkg/IScsiDxe/IScsiMisc.h
+++ b/edk2/NetworkPkg/IScsiDxe/IScsiMisc.h
@@ -1,7 +1,7 @@
/** @file
Miscellaneous definitions for iSCSI driver.
-Copyright (c) 2004 - 2011, Intel Corporation. All rights reserved.<BR>
+Copyright (c) 2004 - 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
which accompanies this distribution. The full text of the license may be found at
@@ -23,14 +23,15 @@ typedef struct _ISCSI_SESSION_CONFIG_NVDATA {
UINT8 Enabled;
UINT8 IpMode;
- EFI_IPv4_ADDRESS LocalIp;
+ EFI_IP_ADDRESS LocalIp;
EFI_IPv4_ADDRESS SubnetMask;
- EFI_IPv4_ADDRESS Gateway;
+ EFI_IP_ADDRESS Gateway;
BOOLEAN InitiatorInfoFromDhcp;
BOOLEAN TargetInfoFromDhcp;
CHAR8 TargetName[ISCSI_NAME_MAX_SIZE];
EFI_IP_ADDRESS TargetIp;
+ UINT8 PrefixLength;
UINT8 BootLun[8];
UINT16 ConnectTimeout; ///< timout value in milliseconds
diff --git a/edk2/NetworkPkg/IScsiDxe/IScsiProto.c b/edk2/NetworkPkg/IScsiDxe/IScsiProto.c
index 72c90a7fe..3dabb00d4 100644
--- a/edk2/NetworkPkg/IScsiDxe/IScsiProto.c
+++ b/edk2/NetworkPkg/IScsiDxe/IScsiProto.c
@@ -308,6 +308,98 @@ IScsiDestroyConnection (
FreePool (Conn);
}
+/**
+ Retrieve the IPv6 Address/Prefix/Gateway from the established TCP connection, these informations
+ will be filled in the iSCSI Boot Firmware Table.
+
+ @param[in] Conn The connection used in the iSCSI login phase.
+
+ @retval EFI_SUCCESS Get the NIC information successfully.
+ @retval Others Other errors as indicated.
+
+**/
+EFI_STATUS
+IScsiGetIp6NicInfo (
+ IN ISCSI_CONNECTION *Conn
+ )
+{
+ ISCSI_SESSION_CONFIG_NVDATA *NvData;
+ EFI_TCP6_PROTOCOL *Tcp6;
+ EFI_IP6_MODE_DATA Ip6ModeData;
+ EFI_STATUS Status;
+ EFI_IPv6_ADDRESS *TargetIp;
+ UINTN Index;
+ UINT8 SubnetPrefixLength;
+ UINTN RouteEntry;
+
+ NvData = &Conn->Session->ConfigData->SessionConfigData;
+ TargetIp = &NvData->TargetIp.v6;
+ Tcp6 = Conn->TcpIo.Tcp.Tcp6;
+
+ ZeroMem (&Ip6ModeData, sizeof (EFI_IP6_MODE_DATA));
+ Status = Tcp6->GetModeData (
+ Tcp6,
+ NULL,
+ NULL,
+ &Ip6ModeData,
+ NULL,
+ NULL
+ );
+ if (EFI_ERROR (Status)) {
+ return Status;
+ }
+
+ if (!Ip6ModeData.IsConfigured) {
+ Status = EFI_ABORTED;
+ goto ON_EXIT;
+ }
+
+ IP6_COPY_ADDRESS (&NvData->LocalIp, &Ip6ModeData.ConfigData.StationAddress);
+
+ NvData->PrefixLength = 0;
+ for (Index = 0; Index < Ip6ModeData.AddressCount; Index++) {
+ if (EFI_IP6_EQUAL (&NvData->LocalIp.v6, &Ip6ModeData.AddressList[Index].Address)) {
+ NvData->PrefixLength = Ip6ModeData.AddressList[Index].PrefixLength;
+ break;
+ }
+ }
+
+ SubnetPrefixLength = 0;
+ RouteEntry = Ip6ModeData.RouteCount;
+ for (Index = 0; Index < Ip6ModeData.RouteCount; Index++) {
+ if (NetIp6IsNetEqual (TargetIp, &Ip6ModeData.RouteTable[Index].Destination, Ip6ModeData.RouteTable[Index].PrefixLength)) {
+ if (SubnetPrefixLength < Ip6ModeData.RouteTable[Index].PrefixLength) {
+ SubnetPrefixLength = Ip6ModeData.RouteTable[Index].PrefixLength;
+ RouteEntry = Index;
+ }
+ }
+ }
+ if (RouteEntry != Ip6ModeData.RouteCount) {
+ IP6_COPY_ADDRESS (&NvData->Gateway, &Ip6ModeData.RouteTable[RouteEntry].Gateway);
+ }
+
+ON_EXIT:
+ if (Ip6ModeData.AddressList != NULL) {
+ FreePool (Ip6ModeData.AddressList);
+ }
+ if (Ip6ModeData.GroupTable!= NULL) {
+ FreePool (Ip6ModeData.GroupTable);
+ }
+ if (Ip6ModeData.RouteTable!= NULL) {
+ FreePool (Ip6ModeData.RouteTable);
+ }
+ if (Ip6ModeData.NeighborCache!= NULL) {
+ FreePool (Ip6ModeData.NeighborCache);
+ }
+ if (Ip6ModeData.PrefixTable!= NULL) {
+ FreePool (Ip6ModeData.PrefixTable);
+ }
+ if (Ip6ModeData.IcmpTypeList!= NULL) {
+ FreePool (Ip6ModeData.IcmpTypeList);
+ }
+
+ return Status;
+}
/**
Login the iSCSI session.
@@ -395,6 +487,10 @@ IScsiSessionLogin (
);
ASSERT_EFI_ERROR (Status);
+
+ if (mPrivate->Ipv6Flag) {
+ Status = IScsiGetIp6NicInfo (Conn);
+ }
}
return Status;
diff --git a/edk2/NetworkPkg/Ip6Dxe/Ip6ConfigImpl.c b/edk2/NetworkPkg/Ip6Dxe/Ip6ConfigImpl.c
index 8b389772d..b9840444b 100644
--- a/edk2/NetworkPkg/Ip6Dxe/Ip6ConfigImpl.c
+++ b/edk2/NetworkPkg/Ip6Dxe/Ip6ConfigImpl.c
@@ -1,7 +1,7 @@
/** @file
The implementation of EFI IPv6 Configuration Protocol.
- Copyright (c) 2009 - 2011, Intel Corporation. All rights reserved.<BR>
+ Copyright (c) 2009 - 2012, Intel Corporation. All rights reserved.<BR>
This program and the accompanying materials
are licensed and made available under the terms and conditions of the BSD License
@@ -2316,12 +2316,12 @@ Ip6ConfigCleanInstance (
}
/**
- Destory the Dhcp6 child in IP6_CONFIG_INSTANCE and release the resources.
+ Destroy the Dhcp6 child in IP6_CONFIG_INSTANCE and release the resources.
@param[in, out] Instance The buffer of IP6_CONFIG_INSTANCE to be freed.
@retval EFI_SUCCESS The child was successfully destroyed.
- @retval Others Failed to destory the child.
+ @retval Others Failed to destroy the child.
**/
EFI_STATUS
diff --git a/edk2/NetworkPkg/Ip6Dxe/Ip6ConfigImpl.h b/edk2/NetworkPkg/Ip6Dxe/Ip6ConfigImpl.h
index 5ae483931..ccb09ccc7 100644
--- a/edk2/NetworkPkg/Ip6Dxe/Ip6ConfigImpl.h
+++ b/edk2/NetworkPkg/Ip6Dxe/Ip6ConfigImpl.h
@@ -1,7 +1,7 @@
/** @file
Definitions for EFI IPv6 Configuartion Protocol implementation.
- Copyright (c) 2009 - 2010, Intel Corporation. All rights reserved.<BR>
+ Copyright (c) 2009 - 2012, Intel Corporation. All rights reserved.<BR>
This program and the accompanying materials
are licensed and made available under the terms and conditions of the BSD License
@@ -279,12 +279,12 @@ Ip6ConfigCleanInstance (
);
/**
- Destory the Dhcp6 child in IP6_CONFIG_INSTANCE and release the resources.
+ Destroy the Dhcp6 child in IP6_CONFIG_INSTANCE and release the resources.
@param[in, out] Instance The buffer of IP6_CONFIG_INSTANCE to be freed.
@retval EFI_SUCCESS The child was successfully destroyed.
- @retval Others Failed to destory the child.
+ @retval Others Failed to destroy the child.
**/
EFI_STATUS
diff --git a/edk2/NetworkPkg/Ip6Dxe/Ip6Driver.c b/edk2/NetworkPkg/Ip6Dxe/Ip6Driver.c
index 502c32bd0..3fd1f7319 100644
--- a/edk2/NetworkPkg/Ip6Dxe/Ip6Driver.c
+++ b/edk2/NetworkPkg/Ip6Dxe/Ip6Driver.c
@@ -1,7 +1,7 @@
/** @file
The driver binding and service binding protocol for IP6 driver.
- Copyright (c) 2009 - 2011, Intel Corporation. All rights reserved.<BR>
+ Copyright (c) 2009 - 2012, Intel Corporation. All rights reserved.<BR>
This program and the accompanying materials
are licensed and made available under the terms and conditions of the BSD License
@@ -94,7 +94,7 @@ Ip6DriverBindingSupported (
Clean up an IP6 service binding instance. It releases all
the resource allocated by the instance. The instance may be
partly initialized, or partly destroyed. If a resource is
- destroyed, it is marked as that in case the destory failed and
+ destroyed, it is marked as that in case the destroy failed and
being called again later.
@param[in] IpSb The IP6 service binding instance to clean up.
@@ -472,6 +472,18 @@ Ip6CreateService (
);
}
+ //
+ // If there is any gateway address, set it.
+ //
+ DataItem = &IpSb->Ip6ConfigInstance.DataItem[Ip6ConfigDataTypeGateway];
+ if (DataItem->Data.Ptr != NULL) {
+ DataItem->SetData (
+ &IpSb->Ip6ConfigInstance,
+ DataItem->DataSize,
+ DataItem->Data.Ptr
+ );
+ }
+
InsertHeadList (&IpSb->Interfaces, &IpSb->DefaultInterface->Link);
*Service = IpSb;
@@ -852,8 +864,8 @@ Ip6ServiceBindingDestroyChild (
//
// A child can be destroyed more than once. For example,
- // Ip6DriverBindingStop will destory all of its children.
- // when UDP driver is being stopped, it will destory all
+ // Ip6DriverBindingStop will destroy all of its children.
+ // when UDP driver is being stopped, it will destroy all
// the IP child it opens.
//
if (IpInstance->State == IP6_STATE_DESTROY) {
diff --git a/edk2/NetworkPkg/Ip6Dxe/Ip6Driver.h b/edk2/NetworkPkg/Ip6Dxe/Ip6Driver.h
index 48ffe7b06..4a23d836b 100644
--- a/edk2/NetworkPkg/Ip6Dxe/Ip6Driver.h
+++ b/edk2/NetworkPkg/Ip6Dxe/Ip6Driver.h
@@ -1,7 +1,7 @@
/** @file
The driver binding and service binding protocol for IP6 driver.
- Copyright (c) 2009 - 2011, Intel Corporation. All rights reserved.<BR>
+ Copyright (c) 2009 - 2012, Intel Corporation. All rights reserved.<BR>
This program and the accompanying materials
are licensed and made available under the terms and conditions of the BSD License
@@ -24,7 +24,7 @@ extern EFI_COMPONENT_NAME2_PROTOCOL gIp6ComponentName2;
Clean up an IP6 service binding instance. It releases all
the resource allocated by the instance. The instance may be
partly initialized, or partly destroyed. If a resource is
- destroyed, it is marked as that in case the destory failed and
+ destroyed, it is marked as that in case the destroy failed and
being called again later.
@param[in] IpSb The IP6 service binding instance to clean up.
diff --git a/edk2/NetworkPkg/Ip6Dxe/Ip6If.c b/edk2/NetworkPkg/Ip6Dxe/Ip6If.c
index 198b547ed..a93418847 100644
--- a/edk2/NetworkPkg/Ip6Dxe/Ip6If.c
+++ b/edk2/NetworkPkg/Ip6Dxe/Ip6If.c
@@ -1,7 +1,7 @@
/** @file
Implement IP6 pesudo interface.
- Copyright (c) 2009 - 2010, Intel Corporation. All rights reserved.<BR>
+ Copyright (c) 2009 - 2012, Intel Corporation. All rights reserved.<BR>
This program and the accompanying materials
are licensed and made available under the terms and conditions of the BSD License
@@ -314,7 +314,7 @@ Ip6CleanInterface (
}
//
- // Destory the interface if this is the last IP instance.
+ // Destroy the interface if this is the last IP instance.
// Remove all the system transmitted packets
// from this interface, cancel the receive request if exists.
//
diff --git a/edk2/NetworkPkg/Ip6Dxe/Ip6Impl.c b/edk2/NetworkPkg/Ip6Dxe/Ip6Impl.c
index 9775aec77..44e039251 100644
--- a/edk2/NetworkPkg/Ip6Dxe/Ip6Impl.c
+++ b/edk2/NetworkPkg/Ip6Dxe/Ip6Impl.c
@@ -1,7 +1,7 @@
/** @file
Implementation of EFI_IP6_PROTOCOL protocol interfaces.
- Copyright (c) 2009 - 2010, Intel Corporation. All rights reserved.<BR>
+ Copyright (c) 2009 - 2012, Intel Corporation. All rights reserved.<BR>
This program and the accompanying materials
are licensed and made available under the terms and conditions of the BSD License
@@ -689,7 +689,7 @@ EfiIp6Configure (
Status = Ip6CleanProtocol (IpInstance);
//
- // Don't change the state if it is DESTORY, consider the following
+ // Don't change the state if it is DESTROY, consider the following
// valid sequence: Mnp is unloaded-->Ip Stopped-->Udp Stopped,
// Configure (ThisIp, NULL). If the state is changed to UNCONFIGED,
// the unload fails miserably.
diff --git a/edk2/NetworkPkg/Ip6Dxe/Ip6Nd.c b/edk2/NetworkPkg/Ip6Dxe/Ip6Nd.c
index 4bcf1a6d4..d510f330c 100644
--- a/edk2/NetworkPkg/Ip6Dxe/Ip6Nd.c
+++ b/edk2/NetworkPkg/Ip6Dxe/Ip6Nd.c
@@ -1,7 +1,7 @@
/** @file
Implementation of Neighbor Discovery support routines.
- Copyright (c) 2009 - 2011, Intel Corporation. All rights reserved.<BR>
+ Copyright (c) 2009 - 2012, Intel Corporation. All rights reserved.<BR>
This program and the accompanying materials
are licensed and made available under the terms and conditions of the BSD License
@@ -261,7 +261,7 @@ Ip6CreatePrefixListEntry (
}
/**
- Destory a IP6 prefix list entry.
+ Destroy a IP6 prefix list entry.
@param[in] IpSb The pointer to IP6_SERVICE instance.
@param[in] PrefixEntry The to be destroyed prefix list entry.
diff --git a/edk2/NetworkPkg/Ip6Dxe/Ip6Nd.h b/edk2/NetworkPkg/Ip6Dxe/Ip6Nd.h
index 1ec022ba6..982203ca5 100644
--- a/edk2/NetworkPkg/Ip6Dxe/Ip6Nd.h
+++ b/edk2/NetworkPkg/Ip6Dxe/Ip6Nd.h
@@ -1,7 +1,7 @@
/** @file
Definition of Neighbor Discovery support routines.
- Copyright (c) 2009 - 2011, Intel Corporation. All rights reserved.<BR>
+ Copyright (c) 2009 - 2012, Intel Corporation. All rights reserved.<BR>
This program and the accompanying materials
are licensed and made available under the terms and conditions of the BSD License
@@ -336,7 +336,7 @@ Ip6CreatePrefixListEntry (
);
/**
- Destory a IP6 prefix list entry.
+ Destroy a IP6 prefix list entry.
@param[in] IpSb The pointer to IP6_SERVICE instance.
@param[in] PrefixEntry The to be destroyed prefix list entry.
diff --git a/edk2/NetworkPkg/IpSecDxe/IkeCommon.c b/edk2/NetworkPkg/IpSecDxe/IkeCommon.c
index 7f563653e..898d5d943 100644
--- a/edk2/NetworkPkg/IpSecDxe/IkeCommon.c
+++ b/edk2/NetworkPkg/IpSecDxe/IkeCommon.c
@@ -1,7 +1,7 @@
/** @file
Common operation of the IKE
- Copyright (c) 2010, Intel Corporation. All rights reserved.<BR>
+ Copyright (c) 2010 - 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
@@ -22,7 +22,7 @@
// Initial the SPI
//
UINT32 mNextSpi = IKE_SPI_BASE;
-EFI_GUID mZeroGuid = { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 };
+EFI_GUID mZeroGuid = { 0, 0, 0, { 0, 0, 0, 0, 0, 0, 0, 0 } };
/**
Call Crypto Lib to generate a random value with eight-octet length.
diff --git a/edk2/NetworkPkg/IpSecDxe/IkeService.c b/edk2/NetworkPkg/IpSecDxe/IkeService.c
index 12ee030e7..b68f4567c 100644
--- a/edk2/NetworkPkg/IpSecDxe/IkeService.c
+++ b/edk2/NetworkPkg/IpSecDxe/IkeService.c
@@ -1,7 +1,7 @@
/** @file
Provide IPsec Key Exchange (IKE) service general interfaces.
- Copyright (c) 2010 - 2011, Intel Corporation. All rights reserved.<BR>
+ Copyright (c) 2010 - 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
@@ -36,10 +36,10 @@ EFI_UDP4_CONFIG_DATA mUdp4Conf = {
0,
1000000,
FALSE,
- {0,0,0,0},
- {0,0,0,0},
+ {{0,0,0,0}},
+ {{0,0,0,0}},
IKE_DEFAULT_PORT,
- {0,0,0,0},
+ {{0,0,0,0}},
0
};
@@ -55,9 +55,9 @@ EFI_UDP6_CONFIG_DATA mUdp6Conf = {
0,
1000000,
//Access Point
- {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0},
+ {{0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0}},
IKE_DEFAULT_PORT,
- {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0},
+ {{0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0}},
0
};
diff --git a/edk2/NetworkPkg/IpSecDxe/IpSecDebug.c b/edk2/NetworkPkg/IpSecDxe/IpSecDebug.c
index 56b35a1a1..636e77596 100644
--- a/edk2/NetworkPkg/IpSecDxe/IpSecDebug.c
+++ b/edk2/NetworkPkg/IpSecDxe/IpSecDebug.c
@@ -19,7 +19,7 @@
//
// The print title for IKEv1 variety phase.
//
-CHAR8 *mIkev1StateStr[] = {
+CHAR8 *mIkev1StateStr[IKE_STATE_NUM] = {
"IKEv1_MAIN_1",
"IKEv1_MAIN_2",
"IKEv1_MAIN_3",
@@ -32,7 +32,7 @@ CHAR8 *mIkev1StateStr[] = {
//
// The print title for IKEv2 variety phase.
//
-CHAR8 *mIkev2StateStr[] = {
+CHAR8 *mIkev2StateStr[IKE_STATE_NUM] = {
"IKEv2_STATE_INIT",
"IKEv2_STATE_AUTH",
"IKEv2_STATE_SA_ESTABLISH",
@@ -166,23 +166,23 @@ IkeDumpState (
IN UINT8 IkeVersion
)
{
+ if (Previous >= IKE_STATE_NUM || Current >= IKE_STATE_NUM) {
+ return;
+ }
if (Previous == Current) {
if (IkeVersion == 1) {
DEBUG ((DEBUG_INFO, "\n****Current state is %a\n", mIkev1StateStr[Previous]));
} else if (IkeVersion == 2) {
DEBUG ((DEBUG_INFO, "\n****Current state is %a\n", mIkev2StateStr[Previous]));
- }
-
+ }
} else {
if (IkeVersion == 1) {
DEBUG ((DEBUG_INFO, "\n****Change state from %a to %a\n", mIkev1StateStr[Previous], mIkev1StateStr[Current]));
} else {
DEBUG ((DEBUG_INFO, "\n****Change state from %a to %a\n", mIkev2StateStr[Previous], mIkev2StateStr[Current]));
- }
-
+ }
}
-
}
/**
diff --git a/edk2/NetworkPkg/IpSecDxe/IpSecDebug.h b/edk2/NetworkPkg/IpSecDxe/IpSecDebug.h
index d44677f30..16bbcd53c 100644
--- a/edk2/NetworkPkg/IpSecDxe/IpSecDebug.h
+++ b/edk2/NetworkPkg/IpSecDxe/IpSecDebug.h
@@ -27,6 +27,8 @@
#define IPSEC_DUMP_BUF(Title, Data, DataSize) IpSecDumpBuf (Title, Data, DataSize)
#define IPSEC_DEBUG_BYTE_PER_LINE 8
+#define IKE_STATE_NUM 7
+
/**
diff --git a/edk2/NetworkPkg/Mtftp6Dxe/Mtftp6Driver.c b/edk2/NetworkPkg/Mtftp6Dxe/Mtftp6Driver.c
index 28aacf198..432eea9cd 100644
--- a/edk2/NetworkPkg/Mtftp6Dxe/Mtftp6Driver.c
+++ b/edk2/NetworkPkg/Mtftp6Dxe/Mtftp6Driver.c
@@ -2,7 +2,7 @@
Driver Binding functions and Service Binding functions
implementation for Mtftp6 Driver.
- Copyright (c) 2009 - 2011, Intel Corporation. All rights reserved.<BR>
+ Copyright (c) 2009 - 2012, Intel Corporation. All rights reserved.<BR>
This program and the accompanying materials
are licensed and made available under the terms and conditions of the BSD License
@@ -33,7 +33,7 @@ EFI_SERVICE_BINDING_PROTOCOL gMtftp6ServiceBindingTemplate = {
/**
- Destory the MTFTP6 service. The MTFTP6 service may be partly initialized,
+ Destroy the MTFTP6 service. The MTFTP6 service may be partly initialized,
or partly destroyed. If a resource is destroyed, it is marked as such in
case the destroy failed and is called again later.
@@ -46,7 +46,7 @@ Mtftp6DestroyService (
)
{
//
- // Make sure all children instances have been already destoryed.
+ // Make sure all children instances have been already destroyed.
//
ASSERT (Service->ChildrenNum == 0);
@@ -98,7 +98,7 @@ Mtftp6CreateService (
Mtftp6Srv->Signature = MTFTP6_SERVICE_SIGNATURE;
Mtftp6Srv->Controller = Controller;
Mtftp6Srv->Image = Image;
- Mtftp6Srv->InDestory = FALSE;
+ Mtftp6Srv->InDestroy = FALSE;
Mtftp6Srv->ChildrenNum = 0;
CopyMem (
@@ -219,7 +219,7 @@ Mtftp6CreateInstance (
}
Mtftp6Ins->Signature = MTFTP6_INSTANCE_SIGNATURE;
- Mtftp6Ins->InDestory = FALSE;
+ Mtftp6Ins->InDestroy = FALSE;
Mtftp6Ins->Service = Service;
CopyMem (
@@ -460,7 +460,7 @@ Mtftp6DriverBindingStop (
Service = MTFTP6_SERVICE_FROM_THIS (ServiceBinding);
- if (Service->InDestory) {
+ if (Service->InDestroy) {
return EFI_SUCCESS;
}
@@ -468,9 +468,9 @@ Mtftp6DriverBindingStop (
if (NumberOfChildren == 0) {
//
- // Destory the Mtftp6 service if there is no Mtftp6 child instance left.
+ // Destroy the Mtftp6 service if there is no Mtftp6 child instance left.
//
- Service->InDestory = TRUE;
+ Service->InDestroy = TRUE;
gBS->UninstallProtocolInterface (
NicHandle,
@@ -482,7 +482,7 @@ Mtftp6DriverBindingStop (
} else {
//
- // Destory the Mtftp6 child instance one by one.
+ // Destroy the Mtftp6 child instance one by one.
//
while (!IsListEmpty (&Service->Children)) {
Instance = NET_LIST_HEAD (&Service->Children, MTFTP6_INSTANCE, Link);
@@ -657,15 +657,15 @@ Mtftp6ServiceBindingDestroyChild (
}
//
- // Check whether the instance already in destory state.
+ // Check whether the instance already in Destroy state.
//
- if (Instance->InDestory) {
+ if (Instance->InDestroy) {
return EFI_SUCCESS;
}
OldTpl = gBS->RaiseTPL (TPL_CALLBACK);
- Instance->InDestory = TRUE;
+ Instance->InDestroy = TRUE;
gBS->CloseProtocol (
Service->DummyUdpIo->UdpHandle,
@@ -684,7 +684,7 @@ Mtftp6ServiceBindingDestroyChild (
);
if (EFI_ERROR (Status)) {
- Instance->InDestory = FALSE;
+ Instance->InDestroy = FALSE;
gBS->RestoreTPL (OldTpl);
return Status;
}
diff --git a/edk2/NetworkPkg/Mtftp6Dxe/Mtftp6Impl.c b/edk2/NetworkPkg/Mtftp6Dxe/Mtftp6Impl.c
index 79ae6e074..4a4e5b192 100644
--- a/edk2/NetworkPkg/Mtftp6Dxe/Mtftp6Impl.c
+++ b/edk2/NetworkPkg/Mtftp6Dxe/Mtftp6Impl.c
@@ -8,7 +8,7 @@
RFC2348 - TFTP Blocksize Option
RFC2349 - TFTP Timeout Interval and Transfer Size Options
- Copyright (c) 2009 - 2011, Intel Corporation. All rights reserved.<BR>
+ Copyright (c) 2009 - 2012, Intel Corporation. All rights reserved.<BR>
This program and the accompanying materials
are licensed and made available under the terms and conditions of the BSD License
@@ -189,13 +189,15 @@ EfiMtftp6Configure (
// Don't configure the udpio here because each operation might override
// the configuration, so delay udpio configuration in each operation.
//
- Instance->UdpIo = UdpIoCreateIo (
- Service->Controller,
- Service->Image,
- Mtftp6ConfigDummyUdpIo,
- UDP_IO_UDP6_VERSION,
- NULL
- );
+ if (Instance->UdpIo == NULL) {
+ Instance->UdpIo = UdpIoCreateIo (
+ Service->Controller,
+ Service->Image,
+ Mtftp6ConfigDummyUdpIo,
+ UDP_IO_UDP6_VERSION,
+ NULL
+ );
+ }
if (Instance->UdpIo == NULL) {
Status = EFI_OUT_OF_RESOURCES;
@@ -620,11 +622,11 @@ EfiMtftp6Poll (
Instance = MTFTP6_INSTANCE_FROM_THIS (This);
//
- // Check the instance whether configured or in destory.
+ // Check the instance whether configured or in destroy.
//
if (Instance->Config == NULL) {
return EFI_NOT_STARTED;
- } else if (Instance->InDestory) {
+ } else if (Instance->InDestroy) {
return EFI_DEVICE_ERROR;
}
diff --git a/edk2/NetworkPkg/Mtftp6Dxe/Mtftp6Impl.h b/edk2/NetworkPkg/Mtftp6Dxe/Mtftp6Impl.h
index 626aea0e3..68fa0da11 100644
--- a/edk2/NetworkPkg/Mtftp6Dxe/Mtftp6Impl.h
+++ b/edk2/NetworkPkg/Mtftp6Dxe/Mtftp6Impl.h
@@ -1,7 +1,7 @@
/** @file
Mtftp6 internal data structure and definition declaration.
- Copyright (c) 2009 - 2011, Intel Corporation. All rights reserved. <BR>
+ Copyright (c) 2009 - 2012, Intel Corporation. All rights reserved. <BR>
This program and the accompanying materials
are licensed and made available under the terms and conditions of the BSD License
@@ -94,7 +94,7 @@ struct _MTFTP6_INSTANCE {
EFI_TPL OldTpl;
BOOLEAN IsTransmitted;
BOOLEAN IsMaster;
- BOOLEAN InDestory;
+ BOOLEAN InDestroy;
};
//
@@ -117,7 +117,7 @@ struct _MTFTP6_SERVICE {
// mtftp driver and udp driver.
//
UDP_IO *DummyUdpIo;
- BOOLEAN InDestory;
+ BOOLEAN InDestroy;
};
/**
diff --git a/edk2/NetworkPkg/Mtftp6Dxe/Mtftp6Rrq.c b/edk2/NetworkPkg/Mtftp6Dxe/Mtftp6Rrq.c
index 348a8f29c..7fc613a66 100644
--- a/edk2/NetworkPkg/Mtftp6Dxe/Mtftp6Rrq.c
+++ b/edk2/NetworkPkg/Mtftp6Dxe/Mtftp6Rrq.c
@@ -547,13 +547,15 @@ Mtftp6RrqHandleOack (
);
Instance->McastPort = ExtInfo.McastPort;
- Instance->McastUdpIo = UdpIoCreateIo (
- Instance->Service->Controller,
- Instance->Service->Image,
- Mtftp6RrqConfigMcastUdpIo,
- UDP_IO_UDP6_VERSION,
- Instance
- );
+ if (Instance->McastUdpIo == NULL) {
+ Instance->McastUdpIo = UdpIoCreateIo (
+ Instance->Service->Controller,
+ Instance->Service->Image,
+ Mtftp6RrqConfigMcastUdpIo,
+ UDP_IO_UDP6_VERSION,
+ Instance
+ );
+ }
if (Instance->McastUdpIo == NULL) {
return EFI_DEVICE_ERROR;
diff --git a/edk2/NetworkPkg/TcpDxe/SockImpl.c b/edk2/NetworkPkg/TcpDxe/SockImpl.c
index 7fad042be..f94155640 100644
--- a/edk2/NetworkPkg/TcpDxe/SockImpl.c
+++ b/edk2/NetworkPkg/TcpDxe/SockImpl.c
@@ -1,7 +1,7 @@
/** @file
Implementation of the Socket.
- Copyright (c) 2009 - 2010, Intel Corporation. All rights reserved.<BR>
+ Copyright (c) 2009 - 2012, Intel Corporation. All rights reserved.<BR>
This program and the accompanying materials
are licensed and made available under the terms and conditions of the BSD License
@@ -787,7 +787,7 @@ SockDestroy (
}
//
- // Destory the RcvBuffer Queue and SendBuffer Queue
+ // Destroy the RcvBuffer Queue and SendBuffer Queue
//
NetbufQueFree (Sock->RcvBuffer.DataQueue);
NetbufQueFree (Sock->SndBuffer.DataQueue);
@@ -802,7 +802,7 @@ SockDestroy (
DEBUG (
(EFI_D_WARN,
- "SockDestory: Delete a unaccepted socket from parent now conncnt is %d\n",
+ "SockDestroy: Delete a unaccepted socket from parent now conncnt is %d\n",
Sock->Parent->ConnCnt)
);
diff --git a/edk2/NetworkPkg/TcpDxe/SockInterface.c b/edk2/NetworkPkg/TcpDxe/SockInterface.c
index ebab8c7f1..075e9ada6 100644
--- a/edk2/NetworkPkg/TcpDxe/SockInterface.c
+++ b/edk2/NetworkPkg/TcpDxe/SockInterface.c
@@ -1,7 +1,7 @@
/** @file
Interface function of the Socket.
- Copyright (c) 2009 - 2011, Intel Corporation. All rights reserved.<BR>
+ Copyright (c) 2009 - 2012, Intel Corporation. All rights reserved.<BR>
This program and the accompanying materials
are licensed and made available under the terms and conditions of the BSD License
@@ -129,7 +129,7 @@ SockBufferToken (
}
/**
- Destory the socket Sock and its associated protocol control block.
+ Destroy the socket Sock and its associated protocol control block.
@param[in, out] Sock The socket to be destroyed.
diff --git a/edk2/NetworkPkg/TcpDxe/Socket.h b/edk2/NetworkPkg/TcpDxe/Socket.h
index a00625244..9e2d90715 100644
--- a/edk2/NetworkPkg/TcpDxe/Socket.h
+++ b/edk2/NetworkPkg/TcpDxe/Socket.h
@@ -1,7 +1,7 @@
/** @file
Common head file for TCP socket.
- Copyright (c) 2009 - 2010, Intel Corporation. All rights reserved.<BR>
+ Copyright (c) 2009 - 2012, Intel Corporation. All rights reserved.<BR>
This program and the accompanying materials
are licensed and made available under the terms and conditions of the BSD License
@@ -696,7 +696,7 @@ SockCreateChild (
);
/**
- Destory the socket Sock and its associated protocol control block.
+ Destroy the socket Sock and its associated protocol control block.
@param[in, out] Sock The socket to be destroyed.
diff --git a/edk2/NetworkPkg/UefiPxeBcDxe/PxeBcDhcp4.c b/edk2/NetworkPkg/UefiPxeBcDxe/PxeBcDhcp4.c
index ecafc86a0..23682b245 100644
--- a/edk2/NetworkPkg/UefiPxeBcDxe/PxeBcDhcp4.c
+++ b/edk2/NetworkPkg/UefiPxeBcDxe/PxeBcDhcp4.c
@@ -532,7 +532,7 @@ PxeBcParseDhcp4Packet (
(Offer->Dhcp4.Header.BootFileName[0] != 0)) {
//
// If the bootfile is not present and bootfilename is present in DHCPv4 packet, just parse it.
- // Do not count dhcp option header here, or else will destory the serverhostname.
+ // Do not count dhcp option header here, or else will destroy the serverhostname.
//
Options[PXEBC_DHCP4_TAG_INDEX_BOOTFILE] = (EFI_DHCP4_PACKET_OPTION *)
(&Offer->Dhcp4.Header.BootFileName[0] -
diff --git a/edk2/NetworkPkg/UefiPxeBcDxe/PxeBcDhcp6.c b/edk2/NetworkPkg/UefiPxeBcDxe/PxeBcDhcp6.c
index 6ab2afa08..1eb64a6a0 100644
--- a/edk2/NetworkPkg/UefiPxeBcDxe/PxeBcDhcp6.c
+++ b/edk2/NetworkPkg/UefiPxeBcDxe/PxeBcDhcp6.c
@@ -1748,7 +1748,7 @@ PxeBcDhcp6Sarr (
Config.IaInfoEvent = NULL;
Config.RapidCommit = FALSE;
Config.ReconfigureAccept = FALSE;
- Config.IaDescriptor.IaId = 1;
+ Config.IaDescriptor.IaId = Private->IaId;
Config.IaDescriptor.Type = EFI_DHCP6_IA_TYPE_NA;
Config.SolicitRetransmission = Retransmit;
Retransmit->Irt = 4;
diff --git a/edk2/NetworkPkg/UefiPxeBcDxe/PxeBcDriver.c b/edk2/NetworkPkg/UefiPxeBcDxe/PxeBcDriver.c
index 179009f91..080b751cb 100644
--- a/edk2/NetworkPkg/UefiPxeBcDxe/PxeBcDriver.c
+++ b/edk2/NetworkPkg/UefiPxeBcDxe/PxeBcDriver.c
@@ -1,7 +1,7 @@
/** @file
Driver Binding functions implementationfor for UefiPxeBc Driver.
- Copyright (c) 2007 - 2011, Intel Corporation. All rights reserved.<BR>
+ 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
@@ -779,6 +779,7 @@ PxeBcCreateIp6Children (
EFI_IP6_MODE_DATA Ip6ModeData;
PXEBC_PRIVATE_PROTOCOL *Id;
EFI_SIMPLE_NETWORK_PROTOCOL *Snp;
+ UINTN Index;
if (Private->Ip6Nic != NULL) {
//
@@ -822,6 +823,16 @@ PxeBcCreateIp6Children (
}
//
+ // Generate a random IAID for the Dhcp6 assigned address.
+ //
+ Private->IaId = NET_RANDOM (NetRandomInitSeed ());
+ if (Private->Snp != NULL) {
+ for (Index = 0; Index < Private->Snp->Mode->HwAddressSize; Index++) {
+ Private->IaId |= (Private->Snp->Mode->CurrentAddress.Addr[Index] << ((Index << 3) & 31));
+ }
+ }
+
+ //
// Create Mtftp6 child and open Mtftp6 protocol for PxeBc->Mtftp.
//
Status = NetLibCreateServiceChild (
diff --git a/edk2/NetworkPkg/UefiPxeBcDxe/PxeBcImpl.c b/edk2/NetworkPkg/UefiPxeBcDxe/PxeBcImpl.c
index 5f693729d..183dc0ced 100644
--- a/edk2/NetworkPkg/UefiPxeBcDxe/PxeBcImpl.c
+++ b/edk2/NetworkPkg/UefiPxeBcDxe/PxeBcImpl.c
@@ -2348,6 +2348,15 @@ EfiPxeLoadFile (
// Start Pxe Base Code to initialize PXE boot.
//
Status = PxeBc->Start (PxeBc, UsingIpv6);
+ if (Status == EFI_ALREADY_STARTED && UsingIpv6 != PxeBc->Mode->UsingIpv6) {
+ //
+ // PxeBc protocol has already been started but not on the required IP version, restart it.
+ //
+ Status = PxeBc->Stop (PxeBc);
+ if (!EFI_ERROR (Status)) {
+ Status = PxeBc->Start (PxeBc, UsingIpv6);
+ }
+ }
if (Status == EFI_SUCCESS || Status == EFI_ALREADY_STARTED) {
Status = PxeBcLoadBootFile (Private, BufferSize, Buffer);
}
diff --git a/edk2/NetworkPkg/UefiPxeBcDxe/PxeBcImpl.h b/edk2/NetworkPkg/UefiPxeBcDxe/PxeBcImpl.h
index bea4931ef..1d4381a1f 100644
--- a/edk2/NetworkPkg/UefiPxeBcDxe/PxeBcImpl.h
+++ b/edk2/NetworkPkg/UefiPxeBcDxe/PxeBcImpl.h
@@ -165,6 +165,7 @@ struct _PXEBC_PRIVATE_DATA {
EFI_IP_ADDRESS GatewayIp;
EFI_IP_ADDRESS ServerIp;
UINT16 CurSrcPort;
+ UINT32 IaId;
UINT32 Ip4MaxPacketSize;
UINT32 Ip6MaxPacketSize;
diff --git a/edk2/Omap44xxPkg/Flash/Flash.c b/edk2/Omap44xxPkg/Flash/Flash.c
deleted file mode 100644
index a346d05f1..000000000
--- a/edk2/Omap44xxPkg/Flash/Flash.c
+++ /dev/null
@@ -1,782 +0,0 @@
-/** @file
-
- Copyright (c) 2008 - 2009, Apple Inc. All rights reserved.<BR>
-
- This program and the accompanying materials
- are licensed and made 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 "Flash.h"
-
-NAND_PART_INFO_TABLE gNandPartInfoTable[1] = {
- { 0x2C, 0xBA, 17, 11 }
-};
-
-NAND_FLASH_INFO *gNandFlashInfo = NULL;
-UINT8 *gEccCode;
-UINTN gNum512BytesChunks = 0;
-
-//
-
-// Device path for SemiHosting. It contains our autogened Caller ID GUID.
-
-//
-
-typedef struct {
-
- VENDOR_DEVICE_PATH Guid;
-
- EFI_DEVICE_PATH_PROTOCOL End;
-
-} FLASH_DEVICE_PATH;
-
-
-
-FLASH_DEVICE_PATH gDevicePath = {
-
- {
-
- { HARDWARE_DEVICE_PATH, HW_VENDOR_DP, sizeof (VENDOR_DEVICE_PATH), 0 },
-
- EFI_CALLER_ID_GUID
-
- },
-
- { END_DEVICE_PATH_TYPE, END_ENTIRE_DEVICE_PATH_SUBTYPE, sizeof (EFI_DEVICE_PATH_PROTOCOL), 0}
-
-};
-
-
-
-//Actual page address = Column address + Page address + Block address.
-UINTN
-GetActualPageAddressInBytes (
- UINTN BlockIndex,
- UINTN PageIndex
-)
-{
- //BlockAddressStart = Start of the Block address in actual NAND
- //PageAddressStart = Start of the Page address in actual NAND
- return ((BlockIndex << gNandFlashInfo->BlockAddressStart) + (PageIndex << gNandFlashInfo->PageAddressStart));
-}
-
-VOID
-NandSendCommand (
- UINT8 Command
-)
-{
- MmioWrite16(GPMC_NAND_COMMAND_0, Command);
-}
-
-VOID
-NandSendAddress (
- UINT8 Address
-)
-{
- MmioWrite16(GPMC_NAND_ADDRESS_0, Address);
-}
-
-UINT16
-NandReadStatus (
- VOID
- )
-{
- //Send READ STATUS command
- NandSendCommand(READ_STATUS_CMD);
-
- //Read status.
- return MmioRead16(GPMC_NAND_DATA_0);
-}
-
-VOID
-NandSendAddressCycles (
- UINTN Address
-)
-{
- //Column address
- NandSendAddress(Address & 0xff);
- Address >>= 8;
-
- //Column address
- NandSendAddress(Address & 0x07);
- Address >>= 3;
-
- //Page and Block address
- NandSendAddress(Address & 0xff);
- Address >>= 8;
-
- //Block address
- NandSendAddress(Address & 0xff);
- Address >>= 8;
-
- //Block address
- NandSendAddress(Address & 0x01);
-}
-
-VOID
-GpmcInit (
- VOID
- )
-{
- //Enable Smart-idle mode.
- MmioWrite32 (GPMC_SYSCONFIG, SMARTIDLEMODE);
-
- //Set IRQSTATUS and IRQENABLE to the reset value
- MmioWrite32 (GPMC_IRQSTATUS, 0x0);
- MmioWrite32 (GPMC_IRQENABLE, 0x0);
-
- //Disable GPMC timeout control.
- MmioWrite32 (GPMC_TIMEOUT_CONTROL, TIMEOUTDISABLE);
-
- //Set WRITEPROTECT bit to enable write access.
- MmioWrite32 (GPMC_CONFIG, WRITEPROTECT_HIGH);
-
- //NOTE: Following GPMC_CONFIGi_0 register settings are taken from u-boot memory dump.
- MmioWrite32 (GPMC_CONFIG1_0, DEVICETYPE_NAND | DEVICESIZE_X16);
- MmioWrite32 (GPMC_CONFIG2_0, CSRDOFFTIME | CSWROFFTIME);
- MmioWrite32 (GPMC_CONFIG3_0, ADVRDOFFTIME | ADVWROFFTIME);
- MmioWrite32 (GPMC_CONFIG4_0, OEONTIME | OEOFFTIME | WEONTIME | WEOFFTIME);
- MmioWrite32 (GPMC_CONFIG5_0, RDCYCLETIME | WRCYCLETIME | RDACCESSTIME | PAGEBURSTACCESSTIME);
- MmioWrite32 (GPMC_CONFIG6_0, WRACCESSTIME | WRDATAONADMUXBUS | CYCLE2CYCLEDELAY | CYCLE2CYCLESAMECSEN);
- MmioWrite32 (GPMC_CONFIG7_0, MASKADDRESS_128MB | CSVALID | BASEADDRESS);
-}
-
-EFI_STATUS
-NandDetectPart (
- VOID
-)
-{
- UINT8 NandInfo = 0;
- UINT8 PartInfo[5];
- UINTN Index;
- BOOLEAN Found = FALSE;
-
- //Send READ ID command
- NandSendCommand(READ_ID_CMD);
-
- //Send one address cycle.
- NandSendAddress(0);
-
- //Read 5-bytes to idenfity code programmed into the NAND flash devices.
- //BYTE 0 = Manufacture ID
- //Byte 1 = Device ID
- //Byte 2, 3, 4 = Nand part specific information (Page size, Block size etc)
- for (Index = 0; Index < sizeof(PartInfo); Index++) {
- PartInfo[Index] = MmioRead16(GPMC_NAND_DATA_0);
- }
-
- //Check if the ManufactureId and DeviceId are part of the currently supported nand parts.
- for (Index = 0; Index < sizeof(gNandPartInfoTable)/sizeof(NAND_PART_INFO_TABLE); Index++) {
- if (gNandPartInfoTable[Index].ManufactureId == PartInfo[0] && gNandPartInfoTable[Index].DeviceId == PartInfo[1]) {
- gNandFlashInfo->BlockAddressStart = gNandPartInfoTable[Index].BlockAddressStart;
- gNandFlashInfo->PageAddressStart = gNandPartInfoTable[Index].PageAddressStart;
- Found = TRUE;
- break;
- }
- }
-
- if (Found == FALSE) {
- DEBUG ((EFI_D_ERROR, "Nand part is not currently supported. Manufacture id: %x, Device id: %x\n", PartInfo[0], PartInfo[1]));
- return EFI_NOT_FOUND;
- }
-
- //Populate NAND_FLASH_INFO based on the result of READ ID command.
- gNandFlashInfo->ManufactureId = PartInfo[0];
- gNandFlashInfo->DeviceId = PartInfo[1];
- NandInfo = PartInfo[3];
-
- if (PAGE_SIZE(NandInfo) == PAGE_SIZE_2K_VAL) {
- gNandFlashInfo->PageSize = PAGE_SIZE_2K;
- } else {
- DEBUG ((EFI_D_ERROR, "Unknown Page size.\n"));
- return EFI_DEVICE_ERROR;
- }
-
- if (SPARE_AREA_SIZE(NandInfo) == SPARE_AREA_SIZE_64B_VAL) {
- gNandFlashInfo->SparePageSize = SPARE_AREA_SIZE_64B;
- } else {
- DEBUG ((EFI_D_ERROR, "Unknown Spare area size.\n"));
- return EFI_DEVICE_ERROR;
- }
-
- if (BLOCK_SIZE(NandInfo) == BLOCK_SIZE_128K_VAL) {
- gNandFlashInfo->BlockSize = BLOCK_SIZE_128K;
- } else {
- DEBUG ((EFI_D_ERROR, "Unknown Block size.\n"));
- return EFI_DEVICE_ERROR;
- }
-
- if (ORGANIZATION(NandInfo) == ORGANIZATION_X8) {
- gNandFlashInfo->Organization = 0;
- } else if (ORGANIZATION(NandInfo) == ORGANIZATION_X16) {
- gNandFlashInfo->Organization = 1;
- }
-
- //Calculate total number of blocks.
- gNandFlashInfo->NumPagesPerBlock = DivU64x32(gNandFlashInfo->BlockSize, gNandFlashInfo->PageSize);
-
- return EFI_SUCCESS;
-}
-
-VOID
-NandConfigureEcc (
- VOID
- )
-{
- //Define ECC size 0 and size 1 to 512 bytes
- MmioWrite32 (GPMC_ECC_SIZE_CONFIG, (ECCSIZE0_512BYTES | ECCSIZE1_512BYTES));
-}
-
-VOID
-NandEnableEcc (
- VOID
- )
-{
- //Clear all the ECC result registers and select ECC result register 1
- MmioWrite32 (GPMC_ECC_CONTROL, (ECCCLEAR | ECCPOINTER_REG1));
-
- //Enable ECC engine on CS0
- MmioWrite32 (GPMC_ECC_CONFIG, (ECCENABLE | ECCCS_0 | ECC16B));
-}
-
-VOID
-NandDisableEcc (
- VOID
- )
-{
- //Turn off ECC engine.
- MmioWrite32 (GPMC_ECC_CONFIG, ECCDISABLE);
-}
-
-VOID
-NandCalculateEcc (
- VOID
- )
-{
- UINTN Index;
- UINTN EccResultRegister;
- UINTN EccResult;
-
- //Capture 32-bit ECC result for each 512-bytes chunk.
- //In our case PageSize is 2K so read ECC1-ECC4 result registers and
- //generate total of 12-bytes of ECC code for the particular page.
-
- EccResultRegister = GPMC_ECC1_RESULT;
-
- for (Index = 0; Index < gNum512BytesChunks; Index++) {
-
- EccResult = MmioRead32 (EccResultRegister);
-
- //Calculate ECC code from 32-bit ECC result value.
- //NOTE: Following calculation is not part of TRM. We got this information
- //from Pandaboard mailing list.
- gEccCode[Index * 3] = EccResult & 0xFF;
- gEccCode[(Index * 3) + 1] = (EccResult >> 16) & 0xFF;
- gEccCode[(Index * 3) + 2] = (((EccResult >> 20) & 0xF0) | ((EccResult >> 8) & 0x0F));
-
- //Point to next ECC result register.
- EccResultRegister += 4;
- }
-}
-
-EFI_STATUS
-NandReadPage (
- IN UINTN BlockIndex,
- IN UINTN PageIndex,
- OUT VOID *Buffer,
- OUT UINT8 *SpareBuffer
-)
-{
- UINTN Address;
- UINTN Index;
- UINTN NumMainAreaWords = (gNandFlashInfo->PageSize/2);
- UINTN NumSpareAreaWords = (gNandFlashInfo->SparePageSize/2);
- UINT16 *MainAreaWordBuffer = Buffer;
- UINT16 *SpareAreaWordBuffer = (UINT16 *)SpareBuffer;
- UINTN Timeout = MAX_RETRY_COUNT;
-
- //Generate device address in bytes to access specific block and page index
- Address = GetActualPageAddressInBytes(BlockIndex, PageIndex);
-
- //Send READ command
- NandSendCommand(PAGE_READ_CMD);
-
- //Send 5 Address cycles to access specific device address
- NandSendAddressCycles(Address);
-
- //Send READ CONFIRM command
- NandSendCommand(PAGE_READ_CONFIRM_CMD);
-
- //Poll till device is busy.
- while (Timeout) {
- if ((NandReadStatus() & NAND_READY) == NAND_READY) {
- break;
- }
- Timeout--;
- }
-
- if (Timeout == 0) {
- DEBUG ((EFI_D_ERROR, "Read page timed out.\n"));
- return EFI_TIMEOUT;
- }
-
- //Reissue READ command
- NandSendCommand(PAGE_READ_CMD);
-
- //Enable ECC engine.
- NandEnableEcc();
-
- //Read data into the buffer.
- for (Index = 0; Index < NumMainAreaWords; Index++) {
- *MainAreaWordBuffer++ = MmioRead16(GPMC_NAND_DATA_0);
- }
-
- //Read spare area into the buffer.
- for (Index = 0; Index < NumSpareAreaWords; Index++) {
- *SpareAreaWordBuffer++ = MmioRead16(GPMC_NAND_DATA_0);
- }
-
- //Calculate ECC.
- NandCalculateEcc();
-
- //Turn off ECC engine.
- NandDisableEcc();
-
- //Perform ECC correction.
- //Need to implement..
-
- return EFI_SUCCESS;
-}
-
-EFI_STATUS
-NandWritePage (
- IN UINTN BlockIndex,
- IN UINTN PageIndex,
- OUT VOID *Buffer,
- IN UINT8 *SpareBuffer
-)
-{
- UINTN Address;
- UINT16 *MainAreaWordBuffer = Buffer;
- UINT16 *SpareAreaWordBuffer = (UINT16 *)SpareBuffer;
- UINTN Index;
- UINTN NandStatus;
- UINTN Timeout = MAX_RETRY_COUNT;
-
- //Generate device address in bytes to access specific block and page index
- Address = GetActualPageAddressInBytes(BlockIndex, PageIndex);
-
- //Send SERIAL DATA INPUT command
- NandSendCommand(PROGRAM_PAGE_CMD);
-
- //Send 5 Address cycles to access specific device address
- NandSendAddressCycles(Address);
-
- //Enable ECC engine.
- NandEnableEcc();
-
- //Data input from Buffer
- for (Index = 0; Index < (gNandFlashInfo->PageSize/2); Index++) {
- MmioWrite16(GPMC_NAND_DATA_0, *MainAreaWordBuffer++);
-
- //After each write access, device has to wait to accept data.
- //Currently we may not be programming proper timing parameters to
- //the GPMC_CONFIGi_0 registers and we would need to figure that out.
- //Without following delay, page programming fails.
- gBS->Stall(1);
- }
-
- //Calculate ECC.
- NandCalculateEcc();
-
- //Turn off ECC engine.
- NandDisableEcc();
-
- //Prepare Spare area buffer with ECC codes.
- SetMem(SpareBuffer, gNandFlashInfo->SparePageSize, 0xFF);
- CopyMem(&SpareBuffer[ECC_POSITION], gEccCode, gNum512BytesChunks * 3);
-
- //Program spare area with calculated ECC.
- for (Index = 0; Index < (gNandFlashInfo->SparePageSize/2); Index++) {
- MmioWrite16(GPMC_NAND_DATA_0, *SpareAreaWordBuffer++);
- }
-
- //Send PROGRAM command
- NandSendCommand(PROGRAM_PAGE_CONFIRM_CMD);
-
- //Poll till device is busy.
- while (Timeout) {
- NandStatus = NandReadStatus();
- if ((NandStatus & NAND_READY) == NAND_READY) {
- break;
- }
- Timeout--;
- }
-
- if (Timeout == 0) {
- DEBUG ((EFI_D_ERROR, "Program page timed out.\n"));
- return EFI_TIMEOUT;
- }
-
- //Bit0 indicates Pass/Fail status
- if (NandStatus & NAND_FAILURE) {
- return EFI_DEVICE_ERROR;
- }
-
- return EFI_SUCCESS;
-}
-
-EFI_STATUS
-NandEraseBlock (
- IN UINTN BlockIndex
-)
-{
- UINTN Address;
- UINTN NandStatus;
- UINTN Timeout = MAX_RETRY_COUNT;
-
- //Generate device address in bytes to access specific block and page index
- Address = GetActualPageAddressInBytes(BlockIndex, 0);
-
- //Send ERASE SETUP command
- NandSendCommand(BLOCK_ERASE_CMD);
-
- //Send 3 address cycles to device to access Page address and Block address
- Address >>= 11; //Ignore column addresses
-
- NandSendAddress(Address & 0xff);
- Address >>= 8;
-
- NandSendAddress(Address & 0xff);
- Address >>= 8;
-
- NandSendAddress(Address & 0xff);
-
- //Send ERASE CONFIRM command
- NandSendCommand(BLOCK_ERASE_CONFIRM_CMD);
-
- //Poll till device is busy.
- while (Timeout) {
- NandStatus = NandReadStatus();
- if ((NandStatus & NAND_READY) == NAND_READY) {
- break;
- }
- Timeout--;
- gBS->Stall(1);
- }
-
- if (Timeout == 0) {
- DEBUG ((EFI_D_ERROR, "Erase block timed out for Block: %d.\n", BlockIndex));
- return EFI_TIMEOUT;
- }
-
- //Bit0 indicates Pass/Fail status
- if (NandStatus & NAND_FAILURE) {
- return EFI_DEVICE_ERROR;
- }
-
- return EFI_SUCCESS;
-}
-
-EFI_STATUS
-NandReadBlock (
- IN UINTN StartBlockIndex,
- IN UINTN EndBlockIndex,
- OUT VOID *Buffer,
- OUT VOID *SpareBuffer
-)
-{
- UINTN BlockIndex;
- UINTN PageIndex;
- EFI_STATUS Status = EFI_SUCCESS;
-
- for (BlockIndex = StartBlockIndex; BlockIndex <= EndBlockIndex; BlockIndex++) {
- //For each block read number of pages
- for (PageIndex = 0; PageIndex < gNandFlashInfo->NumPagesPerBlock; PageIndex++) {
- Status = NandReadPage(BlockIndex, PageIndex, Buffer, SpareBuffer);
- if (EFI_ERROR(Status)) {
- return Status;
- }
- Buffer = ((UINT8 *)Buffer + gNandFlashInfo->PageSize);
- }
- }
-
- return Status;
-}
-
-EFI_STATUS
-NandWriteBlock (
- IN UINTN StartBlockIndex,
- IN UINTN EndBlockIndex,
- OUT VOID *Buffer,
- OUT VOID *SpareBuffer
- )
-{
- UINTN BlockIndex;
- UINTN PageIndex;
- EFI_STATUS Status = EFI_SUCCESS;
-
- for (BlockIndex = StartBlockIndex; BlockIndex <= EndBlockIndex; BlockIndex++) {
- //Page programming.
- for (PageIndex = 0; PageIndex < gNandFlashInfo->NumPagesPerBlock; PageIndex++) {
- Status = NandWritePage(BlockIndex, PageIndex, Buffer, SpareBuffer);
- if (EFI_ERROR(Status)) {
- return Status;
- }
- Buffer = ((UINT8 *)Buffer + gNandFlashInfo->PageSize);
- }
- }
-
- return Status;
-}
-
-EFI_STATUS
-EFIAPI
-NandFlashReset (
- IN EFI_BLOCK_IO_PROTOCOL *This,
- IN BOOLEAN ExtendedVerification
- )
-{
- UINTN BusyStall = 50; // microSeconds
- UINTN ResetBusyTimeout = (1000000 / BusyStall); // 1 Second
-
- //Send RESET command to device.
- NandSendCommand(RESET_CMD);
-
- //Wait for 1ms before we check status register.
- gBS->Stall(1000);
-
- //Check BIT#5 & BIT#6 in Status register to make sure RESET is done.
- while ((NandReadStatus() & NAND_RESET_STATUS) != NAND_RESET_STATUS) {
-
- //In case of extended verification, wait for extended amount of time
- //to make sure device is reset.
- if (ExtendedVerification) {
- if (ResetBusyTimeout == 0) {
- return EFI_DEVICE_ERROR;
- }
-
- gBS->Stall(BusyStall);
- ResetBusyTimeout--;
- }
- }
-
- return EFI_SUCCESS;
-}
-
-EFI_STATUS
-EFIAPI
-NandFlashReadBlocks (
- IN EFI_BLOCK_IO_PROTOCOL *This,
- IN UINT32 MediaId,
- IN EFI_LBA Lba,
- IN UINTN BufferSize,
- OUT VOID *Buffer
- )
-{
- UINTN NumBlocks;
- UINTN EndBlockIndex;
- EFI_STATUS Status;
- UINT8 *SpareBuffer = NULL;
-
- if (Buffer == NULL) {
- Status = EFI_INVALID_PARAMETER;
- goto exit;
- }
-
- if (Lba > LAST_BLOCK) {
- Status = EFI_INVALID_PARAMETER;
- goto exit;
- }
-
- if ((BufferSize % gNandFlashInfo->BlockSize) != 0) {
- Status = EFI_BAD_BUFFER_SIZE;
- goto exit;
- }
-
- NumBlocks = DivU64x32(BufferSize, gNandFlashInfo->BlockSize);
- EndBlockIndex = ((UINTN)Lba + NumBlocks) - 1;
-
- SpareBuffer = (UINT8 *)AllocatePool(gNandFlashInfo->SparePageSize);
- if (SpareBuffer == NULL) {
- Status = EFI_OUT_OF_RESOURCES;
- goto exit;
- }
-
- //Read block
- Status = NandReadBlock((UINTN)Lba, EndBlockIndex, Buffer, SpareBuffer);
- if (EFI_ERROR(Status)) {
- DEBUG((EFI_D_ERROR, "Read block fails: %x\n", Status));
- goto exit;
- }
-
-exit:
- if (SpareBuffer != NULL) {
- FreePool (SpareBuffer);
- }
-
- return Status;
-}
-
-EFI_STATUS
-EFIAPI
-NandFlashWriteBlocks (
- IN EFI_BLOCK_IO_PROTOCOL *This,
- IN UINT32 MediaId,
- IN EFI_LBA Lba,
- IN UINTN BufferSize,
- IN VOID *Buffer
- )
-{
- UINTN BlockIndex;
- UINTN NumBlocks;
- UINTN EndBlockIndex;
- EFI_STATUS Status;
- UINT8 *SpareBuffer = NULL;
-
- if (Buffer == NULL) {
- Status = EFI_INVALID_PARAMETER;
- goto exit;
- }
-
- if (Lba > LAST_BLOCK) {
- Status = EFI_INVALID_PARAMETER;
- goto exit;
- }
-
- if ((BufferSize % gNandFlashInfo->BlockSize) != 0) {
- Status = EFI_BAD_BUFFER_SIZE;
- goto exit;
- }
-
- NumBlocks = DivU64x32(BufferSize, gNandFlashInfo->BlockSize);
- EndBlockIndex = ((UINTN)Lba + NumBlocks) - 1;
-
- SpareBuffer = (UINT8 *)AllocatePool(gNandFlashInfo->SparePageSize);
- if (SpareBuffer == NULL) {
- Status = EFI_OUT_OF_RESOURCES;
- goto exit;
- }
-
- // Erase block
- for (BlockIndex = (UINTN)Lba; BlockIndex <= EndBlockIndex; BlockIndex++) {
- Status = NandEraseBlock(BlockIndex);
- if (EFI_ERROR(Status)) {
- DEBUG((EFI_D_ERROR, "Erase block failed. Status: %x\n", Status));
- goto exit;
- }
- }
-
- // Program data
- Status = NandWriteBlock((UINTN)Lba, EndBlockIndex, Buffer, SpareBuffer);
- if (EFI_ERROR(Status)) {
- DEBUG((EFI_D_ERROR, "Block write fails: %x\n", Status));
- goto exit;
- }
-
-exit:
- if (SpareBuffer != NULL) {
- FreePool (SpareBuffer);
- }
-
- return Status;
-}
-
-EFI_STATUS
-EFIAPI
-NandFlashFlushBlocks (
- IN EFI_BLOCK_IO_PROTOCOL *This
- )
-{
- return EFI_SUCCESS;
-}
-
-
-
-EFI_BLOCK_IO_MEDIA gNandFlashMedia = {
- SIGNATURE_32('n','a','n','d'), // MediaId
- FALSE, // RemovableMedia
- TRUE, // MediaPresent
- FALSE, // LogicalPartition
- FALSE, // ReadOnly
- FALSE, // WriteCaching
- 0, // BlockSize
- 2, // IoAlign
- 0, // Pad
- 0 // LastBlock
-};
-
-EFI_BLOCK_IO_PROTOCOL BlockIo =
-{
- EFI_BLOCK_IO_INTERFACE_REVISION, // Revision
- &gNandFlashMedia, // *Media
- NandFlashReset, // Reset
- NandFlashReadBlocks, // ReadBlocks
- NandFlashWriteBlocks, // WriteBlocks
- NandFlashFlushBlocks // FlushBlocks
-};
-
-EFI_STATUS
-NandFlashInitialize (
- IN EFI_HANDLE ImageHandle,
- IN EFI_SYSTEM_TABLE *SystemTable
- )
-{
- EFI_STATUS Status;
-
- gNandFlashInfo = (NAND_FLASH_INFO *)AllocateZeroPool (sizeof(NAND_FLASH_INFO));
-
- // TODO
- // Currently this driver makes boot up crashing on Panda
- return (EFI_SUCCESS);
-
- //Initialize GPMC module.
- GpmcInit();
-
- //Reset NAND part
- NandFlashReset(&BlockIo, FALSE);
-
- //Detect NAND part and populate gNandFlashInfo structure
- Status = NandDetectPart ();
- if (EFI_ERROR(Status)) {
- DEBUG((EFI_D_ERROR, "Nand part id detection failure: Status: %x\n", Status));
- return Status;
- }
-
- //Count total number of 512Bytes chunk based on the page size.
- if (gNandFlashInfo->PageSize == PAGE_SIZE_512B) {
- gNum512BytesChunks = 1;
- } else if (gNandFlashInfo->PageSize == PAGE_SIZE_2K) {
- gNum512BytesChunks = 4;
- } else if (gNandFlashInfo->PageSize == PAGE_SIZE_4K) {
- gNum512BytesChunks = 8;
- }
-
- gEccCode = (UINT8 *)AllocatePool(gNum512BytesChunks * 3);
- if (gEccCode == NULL) {
- return EFI_OUT_OF_RESOURCES;
- }
-
- //Configure ECC
- NandConfigureEcc ();
-
- //Patch EFI_BLOCK_IO_MEDIA structure.
- gNandFlashMedia.BlockSize = gNandFlashInfo->BlockSize;
- gNandFlashMedia.LastBlock = LAST_BLOCK;
-
- //Publish BlockIO.
- Status = gBS->InstallMultipleProtocolInterfaces (
- &ImageHandle,
- &gEfiBlockIoProtocolGuid, &BlockIo,
- &gEfiDevicePathProtocolGuid, &gDevicePath,
- NULL
- );
- return Status;
-}
-
diff --git a/edk2/Omap44xxPkg/Flash/Flash.h b/edk2/Omap44xxPkg/Flash/Flash.h
deleted file mode 100644
index daa1c9a9f..000000000
--- a/edk2/Omap44xxPkg/Flash/Flash.h
+++ /dev/null
@@ -1,106 +0,0 @@
-/** @file
-
- Copyright (c) 2008 - 2009, Apple Inc. All rights reserved.<BR>
-
- This program and the accompanying materials
- are licensed and made 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 FLASH_H
-#define FLASH_H
-
-#include <Uefi.h>
-
-#include <Library/BaseLib.h>
-#include <Library/BaseMemoryLib.h>
-#include <Library/MemoryAllocationLib.h>
-#include <Library/DebugLib.h>
-#include <Library/IoLib.h>
-#include <Library/PcdLib.h>
-#include <Library/UefiBootServicesTableLib.h>
-#include <Library/IoLib.h>
-
-#include <Protocol/BlockIo.h>
-#include <Protocol/Cpu.h>
-#include <Omap4430/Omap4430.h>
-
-#define PAGE_SIZE(x) ((x) & 0x01)
-#define PAGE_SIZE_2K_VAL (0x01UL)
-
-#define SPARE_AREA_SIZE(x) (((x) >> 2) & 0x01)
-#define SPARE_AREA_SIZE_64B_VAL (0x1UL)
-
-#define BLOCK_SIZE(x) (((x) >> 4) & 0x01)
-#define BLOCK_SIZE_128K_VAL (0x01UL)
-
-#define ORGANIZATION(x) (((x) >> 6) & 0x01)
-#define ORGANIZATION_X8 (0x0UL)
-#define ORGANIZATION_X16 (0x1UL)
-
-#define PAGE_SIZE_512B (512)
-#define PAGE_SIZE_2K (2048)
-#define PAGE_SIZE_4K (4096)
-#define SPARE_AREA_SIZE_16B (16)
-#define SPARE_AREA_SIZE_64B (64)
-
-#define BLOCK_SIZE_16K (16*1024)
-#define BLOCK_SIZE_128K (128*1024)
-
-#define BLOCK_COUNT (2048)
-#define LAST_BLOCK (BLOCK_COUNT - 1)
-
-#define ECC_POSITION 2
-
-//List of commands.
-#define RESET_CMD 0xFF
-#define READ_ID_CMD 0x90
-
-#define READ_STATUS_CMD 0x70
-
-#define PAGE_READ_CMD 0x00
-#define PAGE_READ_CONFIRM_CMD 0x30
-
-#define BLOCK_ERASE_CMD 0x60
-#define BLOCK_ERASE_CONFIRM_CMD 0xD0
-
-#define PROGRAM_PAGE_CMD 0x80
-#define PROGRAM_PAGE_CONFIRM_CMD 0x10
-
-//Nand status register bit definition
-#define NAND_SUCCESS (0x0UL << 0)
-#define NAND_FAILURE BIT0
-
-#define NAND_BUSY (0x0UL << 6)
-#define NAND_READY BIT6
-
-#define NAND_RESET_STATUS (0x60UL << 0)
-
-#define MAX_RETRY_COUNT 1500
-
-
-typedef struct {
- UINT8 ManufactureId;
- UINT8 DeviceId;
- UINT8 BlockAddressStart; //Start of the Block address in actual NAND
- UINT8 PageAddressStart; //Start of the Page address in actual NAND
-} NAND_PART_INFO_TABLE;
-
-typedef struct {
- UINT8 ManufactureId;
- UINT8 DeviceId;
- UINT8 Organization; //x8 or x16
- UINT32 PageSize;
- UINT32 SparePageSize;
- UINT32 BlockSize;
- UINT32 NumPagesPerBlock;
- UINT8 BlockAddressStart; //Start of the Block address in actual NAND
- UINT8 PageAddressStart; //Start of the Page address in actual NAND
-} NAND_FLASH_INFO;
-
-#endif //FLASH_H
diff --git a/edk2/Omap44xxPkg/Flash/Flash.inf b/edk2/Omap44xxPkg/Flash/Flash.inf
deleted file mode 100644
index 48af1f8d8..000000000
--- a/edk2/Omap44xxPkg/Flash/Flash.inf
+++ /dev/null
@@ -1,48 +0,0 @@
-#/** @file
-#
-# Copyright (c) 2008 - 2010, Apple Inc. All rights reserved.<BR>
-# This program and the accompanying materials
-# are licensed and made available under the terms and conditions of the BSD License
-# which accompanies this distribution. The full text of the license may be found at
-# http://opensource.org/licenses/bsd-license.php
-#
-# THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
-# WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
-#
-#**/
-
-[Defines]
- INF_VERSION = 0x00010005
- BASE_NAME = NandFlash
- FILE_GUID = 4d00ef14-c4e0-426b-81b7-30a00a14aad6
- MODULE_TYPE = DXE_DRIVER
- VERSION_STRING = 1.0
-
- ENTRY_POINT = NandFlashInitialize
-
-
-[Sources.common]
- Flash.c
-
-[Packages]
- MdePkg/MdePkg.dec
- Omap44xxPkg/Omap44xxPkg.dec
-
-[LibraryClasses]
- PcdLib
- UefiLib
- UefiDriverEntryPoint
- MemoryAllocationLib
- IoLib
-
-[Guids]
-
-[Protocols]
- gEfiBlockIoProtocolGuid
- gEfiCpuArchProtocolGuid
-
-[Pcd]
- gOmap44xxTokenSpaceGuid.PcdOmap44xxGpmcOffset
-
-[depex]
- TRUE \ No newline at end of file
diff --git a/edk2/Omap44xxPkg/Include/Omap4430/Omap4430.h b/edk2/Omap44xxPkg/Include/Omap4430/Omap4430.h
index 65da46cba..c127398cb 100644
--- a/edk2/Omap44xxPkg/Include/Omap4430/Omap4430.h
+++ b/edk2/Omap44xxPkg/Include/Omap4430/Omap4430.h
@@ -29,12 +29,12 @@
//CONTROL_PBIAS_LITE
-#define CONTROL_PBIAS_LITE 0x48002520
-#define PBIASLITEVMODE0 BIT0
-#define PBIASLITEPWRDNZ0 BIT1
-#define PBIASSPEEDCTRL0 BIT2
-#define PBIASLITEVMODE1 BIT8
-#define PBIASLITEWRDNZ1 BIT9
+#define CONTROL_PBIAS_LITE 0x4a100600
+#define PBIASVMODE3V BIT21
+#define PBIASLITEPWRDNZ BIT22
+#define PBIASVMODEERR BIT23
+#define PBIASHIZ BIT25
+#define PBIASPWRDNZ BIT26
#endif // __OMAP4430_H__
diff --git a/edk2/Omap44xxPkg/Include/Omap4430/Omap4430I2c.h b/edk2/Omap44xxPkg/Include/Omap4430/Omap4430I2c.h
index c593063ac..50d5a4a05 100644
--- a/edk2/Omap44xxPkg/Include/Omap4430/Omap4430I2c.h
+++ b/edk2/Omap44xxPkg/Include/Omap4430/Omap4430I2c.h
@@ -18,27 +18,27 @@
//I2C register definitions.
#define I2C1BASE 0x48070000
-#define I2C_IE (I2C1BASE + 0x4)
+#define I2C_IE (I2C1BASE + 0x84)
#define XRDY_IE BIT4
#define RRDY_IE BIT3
#define ARDY_IE BIT2
#define NACK_IE BIT1
-#define I2C_STAT (I2C1BASE + 0x8)
+#define I2C_STAT (I2C1BASE + 0x88)
#define BB BIT12
#define XRDY BIT4
#define RRDY BIT3
#define ARDY BIT2
#define NACK BIT1
-#define I2C_WE (I2C1BASE + 0xC)
-#define I2C_SYSS (I2C1BASE + 0x10)
-#define I2C_BUF (I2C1BASE + 0x14)
-#define I2C_CNT (I2C1BASE + 0x18)
-#define I2C_DATA (I2C1BASE + 0x1C)
-#define I2C_SYSC (I2C1BASE + 0x20)
+#define I2C_WE (I2C1BASE + 0x34)
+#define I2C_SYSS (I2C1BASE + 0x90)
+#define I2C_BUF (I2C1BASE + 0x94)
+#define I2C_CNT (I2C1BASE + 0x98)
+#define I2C_DATA (I2C1BASE + 0x9C)
+#define I2C_SYSC (I2C1BASE + 0x10)
-#define I2C_CON (I2C1BASE + 0x24)
+#define I2C_CON (I2C1BASE + 0xA4)
#define STT BIT0
#define STP BIT1
#define XSA BIT8
@@ -46,17 +46,17 @@
#define MST BIT10
#define I2C_EN BIT15
-#define I2C_OA0 (I2C1BASE + 0x28)
-#define I2C_SA (I2C1BASE + 0x2C)
-#define I2C_PSC (I2C1BASE + 0x30)
-#define I2C_SCLL (I2C1BASE + 0x34)
-#define I2C_SCLH (I2C1BASE + 0x38)
-#define I2C_SYSTEST (I2C1BASE + 0x3C)
-#define I2C_BUFSTAT (I2C1BASE + 0x40)
-#define I2C_OA1 (I2C1BASE + 0x44)
-#define I2C_OA2 (I2C1BASE + 0x48)
-#define I2C_OA3 (I2C1BASE + 0x4C)
-#define I2C_ACTOA (I2C1BASE + 0x50)
-#define I2C_SBLOCK (I2C1BASE + 0x54)
+//#define I2C_OA0 (I2C1BASE + 0x28)
+#define I2C_SA (I2C1BASE + 0xAC)
+#define I2C_PSC (I2C1BASE + 0xB0)
+#define I2C_SCLL (I2C1BASE + 0xB4)
+#define I2C_SCLH (I2C1BASE + 0xB8)
+#define I2C_SYSTEST (I2C1BASE + 0xBC)
+#define I2C_BUFSTAT (I2C1BASE + 0xC0)
+#define I2C_OA1 (I2C1BASE + 0xC4)
+#define I2C_OA2 (I2C1BASE + 0xC8)
+#define I2C_OA3 (I2C1BASE + 0xCC)
+#define I2C_ACTOA (I2C1BASE + 0xD0)
+#define I2C_SBLOCK (I2C1BASE + 0xD4)
#endif //__OMAP4430I2C_H__
diff --git a/edk2/Omap44xxPkg/Include/TPS65950.h b/edk2/Omap44xxPkg/Include/TWL6030.h
index cd708d979..8126ca7c2 100644
--- a/edk2/Omap44xxPkg/Include/TPS65950.h
+++ b/edk2/Omap44xxPkg/Include/TWL6030.h
@@ -12,8 +12,8 @@
**/
-#ifndef __TPS65950_H__
-#define __TPS65950_H__
+#ifndef __TWL6030_H__
+#define __TWL6030_H__
#define EXTERNAL_DEVICE_REGISTER_TO_SLAVE_ADDRESS(x) (((x) >> 8) & 0xFF)
#define EXTERNAL_DEVICE_REGISTER_TO_REGISTER(x) ((x) & 0xFF)
@@ -27,21 +27,19 @@
#define I2C_ADDR_GRP_ID5 0x12
// MMC definitions.
-#define VMMC1_DEV_GRP 0x82
-#define DEV_GRP_P1 BIT5
+#define VMMC_CFG_GRP 0x98
+#define DEV_GRP_APP BIT0
-#define VMMC1_DEDICATED_REG 0x85
-#define VSEL_1_85V 0x0
-#define VSEL_2_85V 0x1
-#define VSEL_3_00V 0x2
-#define VSEL_3_15V 0x3
+#define VMMC_CFG_STATE 0x9A
+#define VMMC_CFG_STATE_OFF 0xE0
+#define VMMC_CFG_STATE_ON 0xE1
-#define TPS65950_GPIO_CTRL 0xaa //I2C_ADDR_GRP_ID2
-#define CARD_DETECT_ENABLE (BIT2 | BIT0) // GPIO ON + GPIO CD1 enabled
+#define VMMC_CFG_VOLTAGE 0x9B
+#define VSEL_3_00V 0x15
-
-#define GPIODATAIN1 0x98 //I2C_ADDR_GRP_ID2
-#define CARD_DETECT_BIT BIT0
+#define MMCCTRL 0xEE
+#define CARD_DET_STS_MMC BIT0
+#define CARD_DET_CFG BIT3
// LEDEN register
#define LEDEN 0xEE
@@ -77,4 +75,4 @@
#define GPIODATADIR1 0x9B
#define SETGPIODATAOUT1 0xA4
-#endif //__TPS65950_H__
+#endif //__TWL6030_H__
diff --git a/edk2/Omap44xxPkg/InterruptDxe/HardwareInterrupt.c b/edk2/Omap44xxPkg/InterruptDxe/HardwareInterrupt.c
deleted file mode 100644
index ad694dba5..000000000
--- a/edk2/Omap44xxPkg/InterruptDxe/HardwareInterrupt.c
+++ /dev/null
@@ -1,390 +0,0 @@
-/** @file
- Handle OMAP44xx interrupt controller
-
- Copyright (c) 2008 - 2010, Apple Inc. All rights reserved.<BR>
-
- This program and the accompanying materials
- are licensed and made available under the terms and conditions of the BSD License
- which accompanies this distribution. The full text of the license may be found at
- http://opensource.org/licenses/bsd-license.php
-
- THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
- WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
-
-**/
-#include <PiDxe.h>
-
-#include <Library/BaseLib.h>
-#include <Library/DebugLib.h>
-#include <Library/BaseMemoryLib.h>
-#include <Library/UefiBootServicesTableLib.h>
-#include <Library/UefiLib.h>
-#include <Library/PcdLib.h>
-#include <Library/IoLib.h>
-#include <Library/ArmLib.h>
-
-#include <Protocol/Cpu.h>
-#include <Protocol/HardwareInterrupt.h>
-
-#include <Omap4430/Omap4430.h>
-
-//
-// Notifications
-//
-EFI_EVENT EfiExitBootServicesEvent = (EFI_EVENT)NULL;
-
-
-HARDWARE_INTERRUPT_HANDLER gRegisteredInterruptHandlers[INT_NROF_VECTORS];
-
-/**
- Shutdown our hardware
-
- DXE Core will disable interrupts and turn off the timer and disable interrupts
- after all the event handlers have run.
-
- @param[in] Event The Event that is being processed
- @param[in] Context Event Context
-**/
-VOID
-EFIAPI
-ExitBootServicesEvent (
- IN EFI_EVENT Event,
- IN VOID *Context
- )
-{
- // TODO: adapt to GIC
-
- // Add code here to disable all FIQs as debugger may have turned one on
-}
-
-/**
- Register Handler for the specified interrupt source.
-
- @param This Instance pointer for this protocol
- @param Source Hardware source of the interrupt
- @param Handler Callback for interrupt. NULL to unregister
-
- @retval EFI_SUCCESS Source was updated to support Handler.
- @retval EFI_DEVICE_ERROR Hardware could not be programmed.
-
-**/
-EFI_STATUS
-EFIAPI
-RegisterInterruptSource (
- IN EFI_HARDWARE_INTERRUPT_PROTOCOL *This,
- IN HARDWARE_INTERRUPT_SOURCE Source,
- IN HARDWARE_INTERRUPT_HANDLER Handler
- )
-{
- if (Source > MAX_VECTOR) {
- ASSERT(FALSE);
- return EFI_UNSUPPORTED;
- }
-
- // TODO: adapt to GIC
-
-#if 0
- if ((MmioRead32 (INTCPS_ILR(Source)) & INTCPS_ILR_FIQ) == INTCPS_ILR_FIQ) {
- // This vector has been programmed as FIQ so we can't use it for IRQ
- // EFI does not use FIQ, but the debugger can use it to check for
- // ctrl-c. So this ASSERT means you have a conflict with the debug agent
- ASSERT (FALSE);
- return EFI_UNSUPPORTED;
- }
-#endif
-
- if ((Handler == NULL) && (gRegisteredInterruptHandlers[Source] == NULL)) {
- return EFI_INVALID_PARAMETER;
- }
-
- if ((Handler != NULL) && (gRegisteredInterruptHandlers[Source] != NULL)) {
- return EFI_ALREADY_STARTED;
- }
-
- gRegisteredInterruptHandlers[Source] = Handler;
- return This->EnableInterruptSource(This, Source);
-}
-
-
-/**
- Enable interrupt source Source.
-
- @param This Instance pointer for this protocol
- @param Source Hardware source of the interrupt
-
- @retval EFI_SUCCESS Source interrupt enabled.
- @retval EFI_DEVICE_ERROR Hardware could not be programmed.
-
-**/
-EFI_STATUS
-EFIAPI
-EnableInterruptSource (
- IN EFI_HARDWARE_INTERRUPT_PROTOCOL *This,
- IN HARDWARE_INTERRUPT_SOURCE Source
- )
-{
-#if 0
- UINTN Bank;
- UINTN Bit;
-#endif
-
- if (Source > MAX_VECTOR) {
- ASSERT(FALSE);
- return EFI_UNSUPPORTED;
- }
-
- // TODO: adapt to GIC
-#if 0
- Bank = Source / 32;
- Bit = 1UL << (Source % 32);
-
- MmioWrite32 (INTCPS_MIR_CLEAR(Bank), Bit);
-#endif
-
- return EFI_SUCCESS;
-}
-
-
-/**
- Disable interrupt source Source.
-
- @param This Instance pointer for this protocol
- @param Source Hardware source of the interrupt
-
- @retval EFI_SUCCESS Source interrupt disabled.
- @retval EFI_DEVICE_ERROR Hardware could not be programmed.
-
-**/
-EFI_STATUS
-EFIAPI
-DisableInterruptSource (
- IN EFI_HARDWARE_INTERRUPT_PROTOCOL *This,
- IN HARDWARE_INTERRUPT_SOURCE Source
- )
-{
-#if 0
- UINTN Bank;
- UINTN Bit;
-#endif
-
- if (Source > MAX_VECTOR) {
- ASSERT(FALSE);
- return EFI_UNSUPPORTED;
- }
-
- // TODO: adapt to GIC
-#if 0
- Bank = Source / 32;
- Bit = 1UL << (Source % 32);
-
- MmioWrite32 (INTCPS_MIR_SET(Bank), Bit);
-#endif
-
- return EFI_SUCCESS;
-}
-
-
-
-/**
- Return current state of interrupt source Source.
-
- @param This Instance pointer for this protocol
- @param Source Hardware source of the interrupt
- @param InterruptState TRUE: source enabled, FALSE: source disabled.
-
- @retval EFI_SUCCESS InterruptState is valid
- @retval EFI_DEVICE_ERROR InterruptState is not valid
-
-**/
-EFI_STATUS
-EFIAPI
-GetInterruptSourceState (
- IN EFI_HARDWARE_INTERRUPT_PROTOCOL *This,
- IN HARDWARE_INTERRUPT_SOURCE Source,
- IN BOOLEAN *InterruptState
- )
-{
-#if 0
- UINTN Bank;
- UINTN Bit;
-#endif
-
- if (InterruptState == NULL) {
- return EFI_INVALID_PARAMETER;
- }
-
- if (Source > MAX_VECTOR) {
- ASSERT(FALSE);
- return EFI_UNSUPPORTED;
- }
-
- // TODO: adapt to GIC
-#if 0
- Bank = Source / 32;
- Bit = 1UL << (Source % 32);
-
- if ((MmioRead32(INTCPS_MIR(Bank)) & Bit) == Bit) {
- *InterruptState = FALSE;
- } else {
- *InterruptState = TRUE;
- }
-#else
- *InterruptState = TRUE;
-#endif
-
- return EFI_SUCCESS;
-}
-
-/**
- Signal to the hardware that the End Of Intrrupt state
- has been reached.
-
- @param This Instance pointer for this protocol
- @param Source Hardware source of the interrupt
-
- @retval EFI_SUCCESS Source interrupt EOI'ed.
- @retval EFI_DEVICE_ERROR Hardware could not be programmed.
-
-**/
-EFI_STATUS
-EFIAPI
-EndOfInterrupt (
- IN EFI_HARDWARE_INTERRUPT_PROTOCOL *This,
- IN HARDWARE_INTERRUPT_SOURCE Source
- )
-{
- // TODO: adapt to GIC
-
-#if 0
- MmioWrite32 (INTCPS_CONTROL, INTCPS_CONTROL_NEWIRQAGR);
-#endif
-
- ArmDataSyncronizationBarrier ();
- return EFI_SUCCESS;
-}
-
-
-/**
- EFI_CPU_INTERRUPT_HANDLER that is called when a processor interrupt occurs.
-
- @param InterruptType Defines the type of interrupt or exception that
- occurred on the processor.This parameter is processor architecture specific.
- @param SystemContext A pointer to the processor context when
- the interrupt occurred on the processor.
-
- @return None
-
-**/
-VOID
-EFIAPI
-IrqInterruptHandler (
- IN EFI_EXCEPTION_TYPE InterruptType,
- IN EFI_SYSTEM_CONTEXT SystemContext
- )
-{
- UINT32 Vector;
-
- HARDWARE_INTERRUPT_HANDLER InterruptHandler;
-
- // TODO: adapt to GIC and code clean up
-#if 0
- Vector = MmioRead32 (INTCPS_SIR_IRQ) & INTCPS_SIR_IRQ_MASK;
-
- // Needed to prevent infinite nesting when Time Driver lowers TPL
- MmioWrite32 (INTCPS_CONTROL, INTCPS_CONTROL_NEWIRQAGR);
-#endif
-
- Vector = MmioRead32 (0x4824010c);
-
- ArmDataSyncronizationBarrier ();
-
- InterruptHandler = gRegisteredInterruptHandlers[Vector-32];
- if (InterruptHandler != NULL) {
- // Call the registered interrupt handler.
- InterruptHandler (Vector, SystemContext);
- }
-
- // Needed to clear after running the handler
- MmioWrite32 (0x48240110, Vector);
-
- ArmDataSyncronizationBarrier ();
-}
-
-//
-// Making this global saves a few bytes in image size
-//
-EFI_HANDLE gHardwareInterruptHandle = NULL;
-
-//
-// The protocol instance produced by this driver
-//
-EFI_HARDWARE_INTERRUPT_PROTOCOL gHardwareInterruptProtocol = {
- RegisterInterruptSource,
- EnableInterruptSource,
- DisableInterruptSource,
- GetInterruptSourceState,
- EndOfInterrupt
-};
-
-/**
- Initialize the state information for the CPU Architectural Protocol
-
- @param ImageHandle of the loaded driver
- @param SystemTable Pointer to the System Table
-
- @retval EFI_SUCCESS Protocol registered
- @retval EFI_OUT_OF_RESOURCES Cannot allocate protocol data structure
- @retval EFI_DEVICE_ERROR Hardware problems
-
-**/
-EFI_STATUS
-InterruptDxeInitialize (
- IN EFI_HANDLE ImageHandle,
- IN EFI_SYSTEM_TABLE *SystemTable
- )
-{
- EFI_STATUS Status;
- EFI_CPU_ARCH_PROTOCOL *Cpu;
-
- // Make sure the Interrupt Controller Protocol is not already installed in the system.
- ASSERT_PROTOCOL_ALREADY_INSTALLED (NULL, &gHardwareInterruptProtocolGuid);
-
- // TODO: adapt to GIC
-#if 0
- // Make sure all interrupts are disabled by default.
- MmioWrite32 (INTCPS_MIR(0), 0xFFFFFFFF);
- MmioWrite32 (INTCPS_MIR(1), 0xFFFFFFFF);
- MmioWrite32 (INTCPS_MIR(2), 0xFFFFFFFF);
- MmioOr32 (INTCPS_CONTROL, INTCPS_CONTROL_NEWIRQAGR);
-#endif
-
- Status = gBS->InstallMultipleProtocolInterfaces(&gHardwareInterruptHandle,
- &gHardwareInterruptProtocolGuid, &gHardwareInterruptProtocol,
- NULL);
- ASSERT_EFI_ERROR(Status);
-
- //
- // Get the CPU protocol that this driver requires.
- //
- Status = gBS->LocateProtocol(&gEfiCpuArchProtocolGuid, NULL, (VOID **)&Cpu);
- ASSERT_EFI_ERROR(Status);
-
- //
- // Unregister the default exception handler.
- //
- Status = Cpu->RegisterInterruptHandler(Cpu, EXCEPT_ARM_IRQ, NULL);
- ASSERT_EFI_ERROR(Status);
-
- //
- // Register to receive interrupts
- //
- Status = Cpu->RegisterInterruptHandler(Cpu, EXCEPT_ARM_IRQ, IrqInterruptHandler);
- ASSERT_EFI_ERROR(Status);
-
- // Register for an ExitBootServicesEvent
- Status = gBS->CreateEvent(EVT_SIGNAL_EXIT_BOOT_SERVICES, TPL_NOTIFY, ExitBootServicesEvent, NULL, &EfiExitBootServicesEvent);
- ASSERT_EFI_ERROR(Status);
-
- return Status;
-}
-
diff --git a/edk2/Omap44xxPkg/InterruptDxe/InterruptDxe.inf b/edk2/Omap44xxPkg/InterruptDxe/InterruptDxe.inf
deleted file mode 100644
index 2b556bf0b..000000000
--- a/edk2/Omap44xxPkg/InterruptDxe/InterruptDxe.inf
+++ /dev/null
@@ -1,54 +0,0 @@
-#/** @file
-#
-# Interrupt DXE driver
-#
-# Copyright (c) 2008 - 2010, Apple Inc. All rights reserved.<BR>
-# This program and the accompanying materials
-# are licensed and made available under the terms and conditions of the BSD License
-# which accompanies this distribution. The full text of the license may be found at
-# http://opensource.org/licenses/bsd-license.php
-#
-# THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
-# WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
-#
-#**/
-
-[Defines]
- INF_VERSION = 0x00010005
- BASE_NAME = Omap44xxBoardInterruptDxe
- FILE_GUID = 23eed05d-1b93-4a1a-8e1b-931d69e37952
- MODULE_TYPE = DXE_DRIVER
- VERSION_STRING = 1.0
-
- ENTRY_POINT = InterruptDxeInitialize
-
-
-[Sources.common]
- HardwareInterrupt.c
-
-
-[Packages]
- ArmPkg/ArmPkg.dec
- Omap44xxPkg/Omap44xxPkg.dec
- MdePkg/MdePkg.dec
- EmbeddedPkg/EmbeddedPkg.dec
-
-[LibraryClasses]
- BaseLib
- UefiLib
- UefiBootServicesTableLib
- DebugLib
- PrintLib
- UefiDriverEntryPoint
- IoLib
- ArmLib
-
-[Protocols]
- gHardwareInterruptProtocolGuid
- gEfiCpuArchProtocolGuid
-
-[FixedPcd.common]
- gEmbeddedTokenSpaceGuid.PcdInterruptBaseAddress
-
-[Depex]
- gEfiCpuArchProtocolGuid
diff --git a/edk2/Omap44xxPkg/LcdGraphicsOutputDxe/LcdGraphicsOutputDxe.h b/edk2/Omap44xxPkg/LcdGraphicsOutputDxe/LcdGraphicsOutputDxe.h
index 85364458e..721859724 100644
--- a/edk2/Omap44xxPkg/LcdGraphicsOutputDxe/LcdGraphicsOutputDxe.h
+++ b/edk2/Omap44xxPkg/LcdGraphicsOutputDxe/LcdGraphicsOutputDxe.h
@@ -27,7 +27,7 @@
#include <Guid/GlobalVariable.h>
#include <Omap4430/Omap4430.h>
-#include <TPS65950.h>
+#include <TWL6030.h>
typedef struct {
VENDOR_DEVICE_PATH Guid;
diff --git a/edk2/Omap44xxPkg/Library/RealTimeClockLib/RealTimeClockLib.c b/edk2/Omap44xxPkg/Library/RealTimeClockLib/RealTimeClockLib.c
index ba471380a..b215b5512 100644
--- a/edk2/Omap44xxPkg/Library/RealTimeClockLib/RealTimeClockLib.c
+++ b/edk2/Omap44xxPkg/Library/RealTimeClockLib/RealTimeClockLib.c
@@ -24,10 +24,10 @@
#include <Protocol/EmbeddedExternalDevice.h>
#include <Omap4430/Omap4430.h>
-#include <TPS65950.h>
+#include <TWL6030.h>
-EMBEDDED_EXTERNAL_DEVICE *gTPS65950;
+EMBEDDED_EXTERNAL_DEVICE *gTWL6030;
INT16 TimeZone = EFI_UNSPECIFIED_TIMEZONE;
/**
@@ -64,34 +64,34 @@ LibGetTime (
ZeroMem(Time, sizeof(EFI_TIME));
// Latch values
- Status = gTPS65950->Read (gTPS65950, EXTERNAL_DEVICE_REGISTER(I2C_ADDR_GRP_ID4, RTC_CTRL_REG), 1, &Data);
+ Status = gTWL6030->Read (gTWL6030, EXTERNAL_DEVICE_REGISTER(I2C_ADDR_GRP_ID4, RTC_CTRL_REG), 1, &Data);
if (Status != EFI_SUCCESS) goto EXIT;
Data |= BIT6;
- Status = gTPS65950->Write (gTPS65950, EXTERNAL_DEVICE_REGISTER(I2C_ADDR_GRP_ID4, RTC_CTRL_REG), 1, &Data);
+ Status = gTWL6030->Write (gTWL6030, EXTERNAL_DEVICE_REGISTER(I2C_ADDR_GRP_ID4, RTC_CTRL_REG), 1, &Data);
if (Status != EFI_SUCCESS) goto EXIT;
// Read registers
- Status = gTPS65950->Read (gTPS65950, EXTERNAL_DEVICE_REGISTER(I2C_ADDR_GRP_ID4, YEARS_REG), 1, &Data);
+ Status = gTWL6030->Read (gTWL6030, EXTERNAL_DEVICE_REGISTER(I2C_ADDR_GRP_ID4, YEARS_REG), 1, &Data);
if (Status != EFI_SUCCESS) goto EXIT;
Time->Year = 2000 + ((Data >> 4) & 0xF) * 10 + (Data & 0xF);
- Status = gTPS65950->Read (gTPS65950, EXTERNAL_DEVICE_REGISTER(I2C_ADDR_GRP_ID4, MONTHS_REG), 1, &Data);
+ Status = gTWL6030->Read (gTWL6030, EXTERNAL_DEVICE_REGISTER(I2C_ADDR_GRP_ID4, MONTHS_REG), 1, &Data);
if (Status != EFI_SUCCESS) goto EXIT;
Time->Month = ((Data >> 4) & 0x1) * 10 + (Data & 0xF);
- Status = gTPS65950->Read (gTPS65950, EXTERNAL_DEVICE_REGISTER(I2C_ADDR_GRP_ID4, DAYS_REG), 1, &Data);
+ Status = gTWL6030->Read (gTWL6030, EXTERNAL_DEVICE_REGISTER(I2C_ADDR_GRP_ID4, DAYS_REG), 1, &Data);
if (Status != EFI_SUCCESS) goto EXIT;
Time->Day = ((Data >> 4) & 0x3) * 10 + (Data & 0xF);
- Status = gTPS65950->Read (gTPS65950, EXTERNAL_DEVICE_REGISTER(I2C_ADDR_GRP_ID4, HOURS_REG), 1, &Data);
+ Status = gTWL6030->Read (gTWL6030, EXTERNAL_DEVICE_REGISTER(I2C_ADDR_GRP_ID4, HOURS_REG), 1, &Data);
if (Status != EFI_SUCCESS) goto EXIT;
Time->Hour = ((Data >> 4) & 0x3) * 10 + (Data & 0xF);
- Status = gTPS65950->Read (gTPS65950, EXTERNAL_DEVICE_REGISTER(I2C_ADDR_GRP_ID4, MINUTES_REG), 1, &Data);
+ Status = gTWL6030->Read (gTWL6030, EXTERNAL_DEVICE_REGISTER(I2C_ADDR_GRP_ID4, MINUTES_REG), 1, &Data);
if (Status != EFI_SUCCESS) goto EXIT;
Time->Minute = ((Data >> 4) & 0x7) * 10 + (Data & 0xF);
- Status = gTPS65950->Read (gTPS65950, EXTERNAL_DEVICE_REGISTER(I2C_ADDR_GRP_ID4, SECONDS_REG), 1, &Data);
+ Status = gTWL6030->Read (gTWL6030, EXTERNAL_DEVICE_REGISTER(I2C_ADDR_GRP_ID4, SECONDS_REG), 1, &Data);
if (Status != EFI_SUCCESS) goto EXIT;
Time->Second = ((Data >> 4) & 0x7) * 10 + (Data & 0xF);
@@ -153,27 +153,27 @@ LibSetTime (
OldTpl = gBS->RaiseTPL(TPL_NOTIFY);
Data = Time->Year - 2000;
- Status = gTPS65950->Write (gTPS65950, EXTERNAL_DEVICE_REGISTER(I2C_ADDR_GRP_ID4, YEARS_REG), 1, &Data);
+ Status = gTWL6030->Write (gTWL6030, EXTERNAL_DEVICE_REGISTER(I2C_ADDR_GRP_ID4, YEARS_REG), 1, &Data);
if (Status != EFI_SUCCESS) goto EXIT;
Data = ((Time->Month / 10) << 4) | (Time->Month % 10);
- Status = gTPS65950->Write (gTPS65950, EXTERNAL_DEVICE_REGISTER(I2C_ADDR_GRP_ID4, MONTHS_REG), 1, &Data);
+ Status = gTWL6030->Write (gTWL6030, EXTERNAL_DEVICE_REGISTER(I2C_ADDR_GRP_ID4, MONTHS_REG), 1, &Data);
if (Status != EFI_SUCCESS) goto EXIT;
Data = ((Time->Day / 10) << 4) | (Time->Day % 10);
- Status = gTPS65950->Write (gTPS65950, EXTERNAL_DEVICE_REGISTER(I2C_ADDR_GRP_ID4, DAYS_REG), 1, &Data);
+ Status = gTWL6030->Write (gTWL6030, EXTERNAL_DEVICE_REGISTER(I2C_ADDR_GRP_ID4, DAYS_REG), 1, &Data);
if (Status != EFI_SUCCESS) goto EXIT;
Data = ((Time->Hour / 10) << 4) | (Time->Hour % 10);
- Status = gTPS65950->Write (gTPS65950, EXTERNAL_DEVICE_REGISTER(I2C_ADDR_GRP_ID4, HOURS_REG), 1, &Data);
+ Status = gTWL6030->Write (gTWL6030, EXTERNAL_DEVICE_REGISTER(I2C_ADDR_GRP_ID4, HOURS_REG), 1, &Data);
if (Status != EFI_SUCCESS) goto EXIT;
Data = ((Time->Minute / 10) << 4) | (Time->Minute % 10);
- Status = gTPS65950->Write (gTPS65950, EXTERNAL_DEVICE_REGISTER(I2C_ADDR_GRP_ID4, MINUTES_REG), 1, &Data);
+ Status = gTWL6030->Write (gTWL6030, EXTERNAL_DEVICE_REGISTER(I2C_ADDR_GRP_ID4, MINUTES_REG), 1, &Data);
if (Status != EFI_SUCCESS) goto EXIT;
Data = ((Time->Second / 10) << 4) | (Time->Second % 10);
- Status = gTPS65950->Write (gTPS65950, EXTERNAL_DEVICE_REGISTER(I2C_ADDR_GRP_ID4, SECONDS_REG), 1, &Data);
+ Status = gTWL6030->Write (gTWL6030, EXTERNAL_DEVICE_REGISTER(I2C_ADDR_GRP_ID4, SECONDS_REG), 1, &Data);
if (Status != EFI_SUCCESS) goto EXIT;
TimeZone = Time->TimeZone;
@@ -256,13 +256,13 @@ LibRtcInitialize (
EFI_TPL OldTpl;
#endif
- Status = gBS->LocateProtocol (&gEmbeddedExternalDeviceProtocolGuid, NULL, (VOID **)&gTPS65950);
+ Status = gBS->LocateProtocol (&gEmbeddedExternalDeviceProtocolGuid, NULL, (VOID **)&gTWL6030);
ASSERT_EFI_ERROR(Status);
#if 0
OldTpl = gBS->RaiseTPL(TPL_NOTIFY);
Data = 1;
- Status = gTPS65950->Write (gTPS65950, EXTERNAL_DEVICE_REGISTER(I2C_ADDR_GRP_ID4, RTC_CTRL_REG), 1, &Data);
+ Status = gTWL6030->Write (gTWL6030, EXTERNAL_DEVICE_REGISTER(I2C_ADDR_GRP_ID4, RTC_CTRL_REG), 1, &Data);
ASSERT_EFI_ERROR(Status);
gBS->RestoreTPL(OldTpl);
#endif
diff --git a/edk2/Omap44xxPkg/Library/SerialPortLib/SerialPortLib.c b/edk2/Omap44xxPkg/Library/SerialPortLib/SerialPortLib.c
index 22c197ecb..1a37e0f16 100644
--- a/edk2/Omap44xxPkg/Library/SerialPortLib/SerialPortLib.c
+++ b/edk2/Omap44xxPkg/Library/SerialPortLib/SerialPortLib.c
@@ -183,6 +183,13 @@ SerialPortGetControl (
OUT UINT32 *Control
)
{
+ if (SerialPortPoll ()) {
+ // If a character is pending don't set EFI_SERIAL_INPUT_BUFFER_EMPTY
+ *Control = EFI_SERIAL_OUTPUT_BUFFER_EMPTY;
+ } else {
+ *Control = EFI_SERIAL_INPUT_BUFFER_EMPTY | EFI_SERIAL_OUTPUT_BUFFER_EMPTY;
+ }
+
return RETURN_SUCCESS;
}
diff --git a/edk2/Omap44xxPkg/MMCHSDxe/MMCHS.c b/edk2/Omap44xxPkg/MMCHSDxe/MMCHS.c
deleted file mode 100644
index e78f3bcea..000000000
--- a/edk2/Omap44xxPkg/MMCHSDxe/MMCHS.c
+++ /dev/null
@@ -1,1504 +0,0 @@
-/** @file
- MMC/SD Card driver for OMAP (SDIO not supported)
-
- This driver always produces a BlockIo protocol but it starts off with no Media
- present. A TimerCallBack detects when media is inserted or removed and after
- a media change event a call to BlockIo ReadBlocks/WriteBlocks will cause the
- media to be detected (or removed) and the BlockIo Media structure will get
- updated. No MMC/SD Card harward registers are updated until the first BlockIo
- ReadBlocks/WriteBlocks after media has been insterted (booting with a card
- plugged in counts as an insertion event).
-
- Copyright (c) 2008 - 2009, Apple Inc. All rights reserved.<BR>
-
- This program and the accompanying materials
- are licensed and made 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 "MMCHS.h"
-
-EFI_BLOCK_IO_MEDIA gMMCHSMedia = {
- SIGNATURE_32('s','d','i','o'), // MediaId
- TRUE, // RemovableMedia
- FALSE, // MediaPresent
- FALSE, // LogicalPartition
- FALSE, // ReadOnly
- FALSE, // WriteCaching
- 512, // BlockSize
- 4, // IoAlign
- 0, // Pad
- 0 // LastBlock
-};
-
-typedef struct {
- VENDOR_DEVICE_PATH Mmc;
- EFI_DEVICE_PATH End;
-} MMCHS_DEVICE_PATH;
-
-MMCHS_DEVICE_PATH gMmcHsDevicePath = {
- {
- HARDWARE_DEVICE_PATH,
- HW_VENDOR_DP,
- (UINT8)(sizeof(VENDOR_DEVICE_PATH)),
- (UINT8)((sizeof(VENDOR_DEVICE_PATH)) >> 8),
- 0xb615f1f5, 0x5088, 0x43cd, 0x80, 0x9c, 0xa1, 0x6e, 0x52, 0x48, 0x7d, 0x00
- },
- {
- END_DEVICE_PATH_TYPE,
- END_ENTIRE_DEVICE_PATH_SUBTYPE,
- sizeof (EFI_DEVICE_PATH_PROTOCOL),
- 0
- }
-};
-
-CARD_INFO gCardInfo;
-EMBEDDED_EXTERNAL_DEVICE *gTPS65950;
-EFI_EVENT gTimerEvent;
-
-// TODO: card detect not yet implemented on Panda hence forcing this flag
-BOOLEAN gMediaChange = TRUE;
-
-//
-// Internal Functions
-//
-
-
-VOID
-ParseCardCIDData (
- UINT32 Response0,
- UINT32 Response1,
- UINT32 Response2,
- UINT32 Response3
- )
-{
- gCardInfo.CIDData.MDT = ((Response0 >> 8) & 0xFFF);
- gCardInfo.CIDData.PSN = (((Response0 >> 24) & 0xFF) | ((Response1 & 0xFFFFFF) << 8));
- gCardInfo.CIDData.PRV = ((Response1 >> 24) & 0xFF);
- gCardInfo.CIDData.PNM[4] = ((Response2) & 0xFF);
- gCardInfo.CIDData.PNM[3] = ((Response2 >> 8) & 0xFF);
- gCardInfo.CIDData.PNM[2] = ((Response2 >> 16) & 0xFF);
- gCardInfo.CIDData.PNM[1] = ((Response2 >> 24) & 0xFF);
- gCardInfo.CIDData.PNM[0] = ((Response3) & 0xFF);
- gCardInfo.CIDData.OID = ((Response3 >> 8) & 0xFFFF);
- gCardInfo.CIDData.MID = ((Response3 >> 24) & 0xFF);
-}
-
-
-VOID
-UpdateMMCHSClkFrequency (
- UINTN NewCLKD
- )
-{
- //Set Clock enable to 0x0 to not provide the clock to the card
- MmioAnd32 (MMCHS_SYSCTL, ~CEN);
-
- //Set new clock frequency.
- MmioAndThenOr32 (MMCHS_SYSCTL, ~CLKD_MASK, NewCLKD << 6);
-
- //Poll till Internal Clock Stable
- while ((MmioRead32 (MMCHS_SYSCTL) & ICS_MASK) != ICS);
-
- //Set Clock enable to 0x1 to provide the clock to the card
- MmioOr32 (MMCHS_SYSCTL, CEN);
-}
-
-
-EFI_STATUS
-SendCmd (
- UINTN Cmd,
- UINTN CmdInterruptEnableVal,
- UINTN CmdArgument
- )
-{
- UINTN MmcStatus;
- UINTN RetryCount = 0;
-
- //Check if command line is in use or not. Poll till command line is available.
- while ((MmioRead32 (MMCHS_PSTATE) & DATI_MASK) == DATI_NOT_ALLOWED);
-
- //Provide the block size.
- MmioWrite32 (MMCHS_BLK, BLEN_512BYTES);
-
- //Setting Data timeout counter value to max value.
- MmioAndThenOr32 (MMCHS_SYSCTL, ~DTO_MASK, DTO_VAL);
-
- //Clear Status register.
- MmioWrite32 (MMCHS_STAT, 0xFFFFFFFF);
-
- //Set command argument register
- MmioWrite32 (MMCHS_ARG, CmdArgument);
-
- //Enable interrupt enable events to occur
- MmioWrite32 (MMCHS_IE, CmdInterruptEnableVal);
-
- //Send a command
- MmioWrite32 (MMCHS_CMD, Cmd);
-
- //Check for the command status.
- while (RetryCount < MAX_RETRY_COUNT) {
- do {
- MmcStatus = MmioRead32 (MMCHS_STAT);
- } while (MmcStatus == 0);
-
- //Read status of command response
- if ((MmcStatus & ERRI) != 0) {
-
- //Perform soft-reset for mmci_cmd line.
- MmioOr32 (MMCHS_SYSCTL, SRC);
- while ((MmioRead32 (MMCHS_SYSCTL) & SRC));
-
- DEBUG ((EFI_D_INFO, "MmcStatus: %x\n", MmcStatus));
- return EFI_DEVICE_ERROR;
- }
-
- //Check if command is completed.
- if ((MmcStatus & CC) == CC) {
- MmioWrite32 (MMCHS_STAT, CC);
- break;
- }
-
- RetryCount++;
- }
-
- if (RetryCount == MAX_RETRY_COUNT) {
- return EFI_TIMEOUT;
- }
-
- return EFI_SUCCESS;
-}
-
-
-VOID
-GetBlockInformation (
- UINTN *BlockSize,
- UINTN *NumBlocks
- )
-{
- CSD_SDV2 *CsdSDV2Data;
- UINTN CardSize;
-
- if (gCardInfo.CardType == SD_CARD_2_HIGH) {
- CsdSDV2Data = (CSD_SDV2 *)&gCardInfo.CSDData;
-
- //Populate BlockSize.
- *BlockSize = (0x1UL << CsdSDV2Data->READ_BL_LEN);
-
- //Calculate Total number of blocks.
- CardSize = CsdSDV2Data->C_SIZELow16 | (CsdSDV2Data->C_SIZEHigh6 << 2);
- *NumBlocks = ((CardSize + 1) * 1024);
- } else {
- //Populate BlockSize.
- *BlockSize = (0x1UL << gCardInfo.CSDData.READ_BL_LEN);
-
- //Calculate Total number of blocks.
- CardSize = gCardInfo.CSDData.C_SIZELow2 | (gCardInfo.CSDData.C_SIZEHigh10 << 2);
- *NumBlocks = (CardSize + 1) * (1 << (gCardInfo.CSDData.C_SIZE_MULT + 2));
- }
-
- //For >=2G card, BlockSize may be 1K, but the transfer size is 512 bytes.
- if (*BlockSize > 512) {
- *NumBlocks = MultU64x32(*NumBlocks, *BlockSize/2);
- *BlockSize = 512;
- }
-
- DEBUG ((EFI_D_INFO, "Card type: %x, BlockSize: %x, NumBlocks: %x\n", gCardInfo.CardType, *BlockSize, *NumBlocks));
-}
-
-
-VOID
-CalculateCardCLKD (
- UINTN *ClockFrequencySelect
- )
-{
- UINT8 MaxDataTransferRate;
- UINTN TransferRateValue = 0;
- UINTN TimeValue = 0 ;
- UINTN Frequency = 0;
-
- MaxDataTransferRate = gCardInfo.CSDData.TRAN_SPEED;
-
- // For SD Cards we would need to send CMD6 to set
- // speeds abouve 25MHz. High Speed mode 50 MHz and up
-
- //Calculate Transfer rate unit (Bits 2:0 of TRAN_SPEED)
- switch (MaxDataTransferRate & 0x7) {
- case 0:
- TransferRateValue = 100 * 1000;
- break;
-
- case 1:
- TransferRateValue = 1 * 1000 * 1000;
- break;
-
- case 2:
- TransferRateValue = 10 * 1000 * 1000;
- break;
-
- case 3:
- TransferRateValue = 100 * 1000 * 1000;
- break;
-
- default:
- DEBUG((EFI_D_ERROR, "Invalid parameter.\n"));
- ASSERT(FALSE);
- }
-
- //Calculate Time value (Bits 6:3 of TRAN_SPEED)
- switch ((MaxDataTransferRate >> 3) & 0xF) {
- case 1:
- TimeValue = 10;
- break;
-
- case 2:
- TimeValue = 12;
- break;
-
- case 3:
- TimeValue = 13;
- break;
-
- case 4:
- TimeValue = 15;
- break;
-
- case 5:
- TimeValue = 20;
- break;
-
- case 6:
- TimeValue = 25;
- break;
-
- case 7:
- TimeValue = 30;
- break;
-
- case 8:
- TimeValue = 35;
- break;
-
- case 9:
- TimeValue = 40;
- break;
-
- case 10:
- TimeValue = 45;
- break;
-
- case 11:
- TimeValue = 50;
- break;
-
- case 12:
- TimeValue = 55;
- break;
-
- case 13:
- TimeValue = 60;
- break;
-
- case 14:
- TimeValue = 70;
- break;
-
- case 15:
- TimeValue = 80;
- break;
-
- default:
- DEBUG((EFI_D_ERROR, "Invalid parameter.\n"));
- ASSERT(FALSE);
- }
-
- Frequency = TransferRateValue * TimeValue/10;
-
- //Calculate Clock divider value to program in MMCHS_SYSCTL[CLKD] field.
- *ClockFrequencySelect = ((MMC_REFERENCE_CLK/Frequency) + 1);
-
- DEBUG ((EFI_D_INFO, "MaxDataTransferRate: 0x%x, Frequency: %d KHz, ClockFrequencySelect: %x\n", MaxDataTransferRate, Frequency/1000, *ClockFrequencySelect));
-}
-
-
-VOID
-GetCardConfigurationData (
- VOID
- )
-{
- UINTN BlockSize;
- UINTN NumBlocks;
- UINTN ClockFrequencySelect;
-
- //Calculate BlockSize and Total number of blocks in the detected card.
- GetBlockInformation(&BlockSize, &NumBlocks);
- gCardInfo.BlockSize = BlockSize;
- gCardInfo.NumBlocks = NumBlocks;
-
- //Calculate Card clock divider value.
- CalculateCardCLKD(&ClockFrequencySelect);
- gCardInfo.ClockFrequencySelect = ClockFrequencySelect;
-}
-
-
-EFI_STATUS
-InitializeMMCHS (
- VOID
- )
-{
- // TODO: adapt to Panda
-
-#if 0
- UINT8 Data = 0;
- EFI_STATUS Status;
-
- //Select Device group to belong to P1 device group in Power IC.
- Data = DEV_GRP_P1;
- Status = gTPS65950->Write (gTPS65950, EXTERNAL_DEVICE_REGISTER(I2C_ADDR_GRP_ID4, VMMC1_DEV_GRP), 1, &Data);
- ASSERT_EFI_ERROR(Status);
-
- //Configure voltage regulator for MMC1 in Power IC to output 3.0 voltage.
- Data = VSEL_3_00V;
- Status = gTPS65950->Write (gTPS65950, EXTERNAL_DEVICE_REGISTER(I2C_ADDR_GRP_ID4, VMMC1_DEDICATED_REG), 1, &Data);
- ASSERT_EFI_ERROR(Status);
-
- //After ramping up voltage, set VDDS stable bit to indicate that voltage level is stable.
- MmioOr32 (CONTROL_PBIAS_LITE, (PBIASLITEVMODE0 | PBIASLITEPWRDNZ0 | PBIASSPEEDCTRL0 | PBIASLITEVMODE1 | PBIASLITEWRDNZ1));
-
- // Enable WP GPIO
- MmioAndThenOr32 (GPIO1_BASE + GPIO_OE, ~BIT23, BIT23);
-
- // Enable Card Detect
- Data = CARD_DETECT_ENABLE;
- gTPS65950->Write (gTPS65950, EXTERNAL_DEVICE_REGISTER(I2C_ADDR_GRP_ID2, TPS65950_GPIO_CTRL), 1, &Data);
-#endif
-
- return (1);
-}
-
-
-EFI_STATUS
-PerformCardIdenfication (
- VOID
- )
-{
- EFI_STATUS Status;
- UINTN CmdArgument = 0;
- UINTN Response = 0;
- UINTN RetryCount = 0;
- BOOLEAN SDCmd8Supported = FALSE;
-
- //Enable interrupts.
- MmioWrite32 (MMCHS_IE, (BADA_EN | CERR_EN | DEB_EN | DCRC_EN | DTO_EN | CIE_EN |
- CEB_EN | CCRC_EN | CTO_EN | BRR_EN | BWR_EN | TC_EN | CC_EN));
-
- //Controller INIT procedure start.
- MmioOr32 (MMCHS_CON, INIT);
- MmioWrite32 (MMCHS_CMD, 0x00000000);
- while (!(MmioRead32 (MMCHS_STAT) & CC));
-
- //Wait for 1 ms
- gBS->Stall(1000);
-
- //Set CC bit to 0x1 to clear the flag
- MmioOr32 (MMCHS_STAT, CC);
-
- //Retry INIT procedure.
- MmioWrite32 (MMCHS_CMD, 0x00000000);
- while (!(MmioRead32 (MMCHS_STAT) & CC));
-
- //End initialization sequence
- MmioAnd32 (MMCHS_CON, ~INIT);
-
- MmioOr32 (MMCHS_HCTL, (SDVS_3_0_V | DTW_1_BIT | SDBP_ON));
-
- //Change clock frequency to 400KHz to fit protocol
- UpdateMMCHSClkFrequency(CLKD_400KHZ);
-
- MmioOr32 (MMCHS_CON, OD);
-
- //Send CMD0 command.
- Status = SendCmd (CMD0, CMD0_INT_EN, CmdArgument);
- if (EFI_ERROR(Status)) {
- DEBUG ((EFI_D_ERROR, "Cmd0 fails.\n"));
- return Status;
- }
-
- DEBUG ((EFI_D_INFO, "CMD0 response: %x\n", MmioRead32 (MMCHS_RSP10)));
-
- //Send CMD5 command.
- Status = SendCmd (CMD5, CMD5_INT_EN, CmdArgument);
- if (Status == EFI_SUCCESS) {
- DEBUG ((EFI_D_ERROR, "CMD5 Success. SDIO card. Follow SDIO card specification.\n"));
- DEBUG ((EFI_D_INFO, "CMD5 response: %x\n", MmioRead32 (MMCHS_RSP10)));
- //NOTE: Returning unsupported error for now. Need to implement SDIO specification.
- return EFI_UNSUPPORTED;
- } else {
- DEBUG ((EFI_D_INFO, "CMD5 fails. Not an SDIO card.\n"));
- }
-
- MmioOr32 (MMCHS_SYSCTL, SRC);
- gBS->Stall(1000);
- while ((MmioRead32 (MMCHS_SYSCTL) & SRC));
-
- //Send CMD8 command. (New v2.00 command for Voltage check)
- //Only 2.7V - 3.6V is supported for SD2.0, only SD 2.0 card can pass.
- //MMC & SD1.1 card will fail this command.
- CmdArgument = CMD8_ARG;
- Status = SendCmd (CMD8, CMD8_INT_EN, CmdArgument);
- if (Status == EFI_SUCCESS) {
- Response = MmioRead32 (MMCHS_RSP10);
- DEBUG ((EFI_D_INFO, "CMD8 success. CMD8 response: %x\n", Response));
- if (Response != CmdArgument) {
- return EFI_DEVICE_ERROR;
- }
- DEBUG ((EFI_D_INFO, "Card is SD2.0\n"));
- SDCmd8Supported = TRUE; //Supports high capacity.
- } else {
- DEBUG ((EFI_D_INFO, "CMD8 fails. Not an SD2.0 card.\n"));
- }
-
- MmioOr32 (MMCHS_SYSCTL, SRC);
- gBS->Stall(1000);
- while ((MmioRead32 (MMCHS_SYSCTL) & SRC));
-
- //Poll till card is busy
- while (RetryCount < MAX_RETRY_COUNT) {
- //Send CMD55 command.
- CmdArgument = 0;
- Status = SendCmd (CMD55, CMD55_INT_EN, CmdArgument);
- if (Status == EFI_SUCCESS) {
- DEBUG ((EFI_D_INFO, "CMD55 success. CMD55 response: %x\n", MmioRead32 (MMCHS_RSP10)));
- gCardInfo.CardType = SD_CARD;
- } else {
- DEBUG ((EFI_D_INFO, "CMD55 fails.\n"));
- gCardInfo.CardType = MMC_CARD;
- }
-
- //Send appropriate command for the card type which got detected.
- if (gCardInfo.CardType == SD_CARD) {
- CmdArgument = ((UINTN *) &(gCardInfo.OCRData))[0];
-
- //Set HCS bit.
- if (SDCmd8Supported) {
- CmdArgument |= HCS;
- }
-
- Status = SendCmd (ACMD41, ACMD41_INT_EN, CmdArgument);
- if (EFI_ERROR(Status)) {
- DEBUG ((EFI_D_INFO, "ACMD41 fails.\n"));
- return Status;
- }
- ((UINT32 *) &(gCardInfo.OCRData))[0] = MmioRead32 (MMCHS_RSP10);
- DEBUG ((EFI_D_INFO, "SD card detected. ACMD41 OCR: %x\n", ((UINT32 *) &(gCardInfo.OCRData))[0]));
- } else if (gCardInfo.CardType == MMC_CARD) {
- CmdArgument = 0;
- Status = SendCmd (CMD1, CMD1_INT_EN, CmdArgument);
- if (EFI_ERROR(Status)) {
- DEBUG ((EFI_D_INFO, "CMD1 fails.\n"));
- return Status;
- }
- Response = MmioRead32 (MMCHS_RSP10);
- DEBUG ((EFI_D_INFO, "MMC card detected.. CMD1 response: %x\n", Response));
-
- //NOTE: For now, I am skipping this since I only have an SD card.
- //Compare card OCR and host OCR (Section 22.6.1.3.2.4)
- return EFI_UNSUPPORTED; //For now, MMC is not supported.
- }
-
- //Poll the card until it is out of its power-up sequence.
- if (gCardInfo.OCRData.Busy == 1) {
-
- if (SDCmd8Supported) {
- gCardInfo.CardType = SD_CARD_2;
- }
-
- //Card is ready. Check CCS (Card capacity status) bit (bit#30).
- //SD 2.0 standard card will response with CCS 0, SD high capacity card will respond with CCS 1.
- if (gCardInfo.OCRData.AccessMode & BIT1) {
- gCardInfo.CardType = SD_CARD_2_HIGH;
- DEBUG ((EFI_D_INFO, "High capacity card.\n"));
- } else {
- DEBUG ((EFI_D_INFO, "Standard capacity card.\n"));
- }
-
- break;
- }
-
- gBS->Stall(1000);
- RetryCount++;
- }
-
- if (RetryCount == MAX_RETRY_COUNT) {
- DEBUG ((EFI_D_ERROR, "Timeout error. RetryCount: %d\n", RetryCount));
- return EFI_TIMEOUT;
- }
-
- //Read CID data.
- CmdArgument = 0;
- Status = SendCmd (CMD2, CMD2_INT_EN, CmdArgument);
- if (EFI_ERROR(Status)) {
- DEBUG ((EFI_D_ERROR, "CMD2 fails. Status: %x\n", Status));
- return Status;
- }
-
- DEBUG ((EFI_D_INFO, "CMD2 response: %x %x %x %x\n", MmioRead32 (MMCHS_RSP10), MmioRead32 (MMCHS_RSP32), MmioRead32 (MMCHS_RSP54), MmioRead32 (MMCHS_RSP76)));
-
- //Parse CID register data.
- ParseCardCIDData(MmioRead32 (MMCHS_RSP10), MmioRead32 (MMCHS_RSP32), MmioRead32 (MMCHS_RSP54), MmioRead32 (MMCHS_RSP76));
-
- //Read RCA
- CmdArgument = 0;
- Status = SendCmd (CMD3, CMD3_INT_EN, CmdArgument);
- if (EFI_ERROR(Status)) {
- DEBUG ((EFI_D_ERROR, "CMD3 fails. Status: %x\n", Status));
- return Status;
- }
-
- //Set RCA for the detected card. RCA is CMD3 response.
- gCardInfo.RCA = (MmioRead32 (MMCHS_RSP10) >> 16);
- DEBUG ((EFI_D_INFO, "CMD3 response: RCA %x\n", gCardInfo.RCA));
-
- //MMC Bus setting change after card identification.
- MmioAnd32 (MMCHS_CON, ~OD);
- MmioOr32 (MMCHS_HCTL, SDVS_3_0_V);
- UpdateMMCHSClkFrequency(CLKD_400KHZ); //Set the clock frequency to 400KHz.
-
- return EFI_SUCCESS;
-}
-
-
-EFI_STATUS
-GetCardSpecificData (
- VOID
- )
-{
- EFI_STATUS Status;
- UINTN CmdArgument;
-
- //Send CMD9 to retrieve CSD.
- CmdArgument = gCardInfo.RCA << 16;
- Status = SendCmd (CMD9, CMD9_INT_EN, CmdArgument);
- if (EFI_ERROR(Status)) {
- DEBUG ((EFI_D_ERROR, "CMD9 fails. Status: %x\n", Status));
- return Status;
- }
-
- //Populate 128-bit CSD register data.
- ((UINT32 *)&(gCardInfo.CSDData))[0] = MmioRead32 (MMCHS_RSP10);
- ((UINT32 *)&(gCardInfo.CSDData))[1] = MmioRead32 (MMCHS_RSP32);
- ((UINT32 *)&(gCardInfo.CSDData))[2] = MmioRead32 (MMCHS_RSP54);
- ((UINT32 *)&(gCardInfo.CSDData))[3] = MmioRead32 (MMCHS_RSP76);
-
- DEBUG ((EFI_D_INFO, "CMD9 response: %x %x %x %x\n", MmioRead32 (MMCHS_RSP10), MmioRead32 (MMCHS_RSP32), MmioRead32 (MMCHS_RSP54), MmioRead32 (MMCHS_RSP76)));
-
- //Calculate total number of blocks and max. data transfer rate supported by the detected card.
- GetCardConfigurationData();
-
- return Status;
-}
-
-
-EFI_STATUS
-PerformCardConfiguration (
- VOID
- )
-{
- UINTN CmdArgument = 0;
- EFI_STATUS Status;
-
- //Send CMD7
- CmdArgument = gCardInfo.RCA << 16;
- Status = SendCmd (CMD7, CMD7_INT_EN, CmdArgument);
- if (EFI_ERROR(Status)) {
- DEBUG ((EFI_D_ERROR, "CMD7 fails. Status: %x\n", Status));
- return Status;
- }
-
- if ((gCardInfo.CardType != UNKNOWN_CARD) && (gCardInfo.CardType != MMC_CARD)) {
- // We could read SCR register, but SD Card Phys spec stats any SD Card shall
- // set SCR.SD_BUS_WIDTHS to support 4-bit mode, so why bother?
-
- // Send ACMD6 (application specific commands must be prefixed with CMD55)
- Status = SendCmd (CMD55, CMD55_INT_EN, CmdArgument);
- if (!EFI_ERROR (Status)) {
- // set device into 4-bit data bus mode
- Status = SendCmd (ACMD6, ACMD6_INT_EN, 0x2);
- if (!EFI_ERROR (Status)) {
- // Set host controler into 4-bit mode
- MmioOr32 (MMCHS_HCTL, DTW_4_BIT);
- DEBUG ((EFI_D_INFO, "SD Memory Card set to 4-bit mode\n"));
- }
- }
- }
-
- //Send CMD16 to set the block length
- CmdArgument = gCardInfo.BlockSize;
- Status = SendCmd (CMD16, CMD16_INT_EN, CmdArgument);
- if (EFI_ERROR(Status)) {
- DEBUG ((EFI_D_ERROR, "CMD16 fails. Status: %x\n", Status));
- return Status;
- }
-
- //Change MMCHS clock frequency to what detected card can support.
- UpdateMMCHSClkFrequency(gCardInfo.ClockFrequencySelect);
-
- return EFI_SUCCESS;
-}
-
-
-EFI_STATUS
-ReadBlockData (
- IN EFI_BLOCK_IO_PROTOCOL *This,
- OUT VOID *Buffer
- )
-{
- UINTN MmcStatus;
- UINTN *DataBuffer = Buffer;
- UINTN DataSize = This->Media->BlockSize/4;
- UINTN Count;
- UINTN RetryCount = 0;
-
- //Check controller status to make sure there is no error.
- while (RetryCount < MAX_RETRY_COUNT) {
- do {
- //Read Status.
- MmcStatus = MmioRead32 (MMCHS_STAT);
- } while(MmcStatus == 0);
-
- //Check if Buffer read ready (BRR) bit is set?
- if (MmcStatus & BRR) {
-
- //Clear BRR bit
- MmioOr32 (MMCHS_STAT, BRR);
-
- //Read block worth of data.
- for (Count = 0; Count < DataSize; Count++) {
- *DataBuffer++ = MmioRead32 (MMCHS_DATA);
- }
- break;
- }
- RetryCount++;
- }
-
- if (RetryCount == MAX_RETRY_COUNT) {
- return EFI_TIMEOUT;
- }
-
- return EFI_SUCCESS;
-}
-
-
-EFI_STATUS
-WriteBlockData (
- IN EFI_BLOCK_IO_PROTOCOL *This,
- OUT VOID *Buffer
- )
-{
- UINTN MmcStatus;
- UINTN *DataBuffer = Buffer;
- UINTN DataSize = This->Media->BlockSize/4;
- UINTN Count;
- UINTN RetryCount = 0;
-
- //Check controller status to make sure there is no error.
- while (RetryCount < MAX_RETRY_COUNT) {
- do {
- //Read Status.
- MmcStatus = MmioRead32 (MMCHS_STAT);
- } while(MmcStatus == 0);
-
- //Check if Buffer write ready (BWR) bit is set?
- if (MmcStatus & BWR) {
-
- //Clear BWR bit
- MmioOr32 (MMCHS_STAT, BWR);
-
- //Write block worth of data.
- for (Count = 0; Count < DataSize; Count++) {
- MmioWrite32 (MMCHS_DATA, *DataBuffer++);
- }
-
- break;
- }
- RetryCount++;
- }
-
- if (RetryCount == MAX_RETRY_COUNT) {
- return EFI_TIMEOUT;
- }
-
- return EFI_SUCCESS;
-}
-
-EFI_STATUS
-DmaBlocks (
- IN EFI_BLOCK_IO_PROTOCOL *This,
- IN UINTN Lba,
- IN OUT VOID *Buffer,
- IN UINTN BlockCount,
- IN OPERATION_TYPE OperationType
- )
-{
- EFI_STATUS Status;
- UINTN DmaSize = 0;
- UINTN Cmd = 0;
- UINTN CmdInterruptEnable;
- UINTN CmdArgument;
- VOID *BufferMap;
- EFI_PHYSICAL_ADDRESS BufferAddress;
- OMAP_DMA4 Dma4;
- DMA_MAP_OPERATION DmaOperation;
- EFI_STATUS MmcStatus;
- UINTN RetryCount = 0;
-
-CpuDeadLoop ();
- // Map passed in buffer for DMA xfer
- DmaSize = BlockCount * This->Media->BlockSize;
- Status = DmaMap (DmaOperation, Buffer, &DmaSize, &BufferAddress, &BufferMap);
- if (EFI_ERROR (Status)) {
- return Status;
- }
-
- ZeroMem (&DmaOperation, sizeof (DMA_MAP_OPERATION));
-
-
- Dma4.DataType = 2; // DMA4_CSDPi[1:0] 32-bit elements from MMCHS_DATA
-
- Dma4.SourceEndiansim = 0; // DMA4_CSDPi[21]
-
- Dma4.DestinationEndianism = 0; // DMA4_CSDPi[19]
-
- Dma4.SourcePacked = 0; // DMA4_CSDPi[6]
-
- Dma4.DestinationPacked = 0; // DMA4_CSDPi[13]
-
- Dma4.NumberOfElementPerFrame = This->Media->BlockSize/4; // DMA4_CENi (TRM 4K is optimum value)
-
- Dma4.NumberOfFramePerTransferBlock = BlockCount; // DMA4_CFNi
-
- Dma4.ReadPriority = 0; // DMA4_CCRi[6] Low priority read
-
- Dma4.WritePriority = 0; // DMA4_CCRi[23] Prefetech disabled
-
-
- //Populate the command information based on the operation type.
- if (OperationType == READ) {
- Cmd = CMD18; //Multiple block read
- CmdInterruptEnable = CMD18_INT_EN;
- DmaOperation = MapOperationBusMasterCommonBuffer;
-
- Dma4.ReadPortAccessType =0 ; // DMA4_CSDPi[8:7] Can not burst MMCHS_DATA reg
-
- Dma4.WritePortAccessType = 3; // DMA4_CSDPi[15:14] Memory burst 16x32
-
- Dma4.WriteMode = 1; // DMA4_CSDPi[17:16] Write posted
-
-
-
- Dma4.SourceStartAddress = MMCHS_DATA; // DMA4_CSSAi
-
- Dma4.DestinationStartAddress = (UINT32)BufferAddress; // DMA4_CDSAi
-
- Dma4.SourceElementIndex = 1; // DMA4_CSEi
-
- Dma4.SourceFrameIndex = 0x200; // DMA4_CSFi
-
- Dma4.DestinationElementIndex = 1; // DMA4_CDEi
-
- Dma4.DestinationFrameIndex = 0; // DMA4_CDFi
-
-
-
- Dma4.ReadPortAccessMode = 0; // DMA4_CCRi[13:12] Always read MMCHS_DATA
-
- Dma4.WritePortAccessMode = 1; // DMA4_CCRi[15:14] Post increment memory address
-
- Dma4.ReadRequestNumber = 0x1e; // DMA4_CCRi[4:0] Syncro with MMCA_DMA_RX (61)
-
- Dma4.WriteRequestNumber = 1; // DMA4_CCRi[20:19] Syncro upper 0x3e == 62 (one based)
-
- } else if (OperationType == WRITE) {
- Cmd = CMD25; //Multiple block write
- CmdInterruptEnable = CMD25_INT_EN;
- DmaOperation = MapOperationBusMasterRead;
-
- Dma4.ReadPortAccessType = 3; // DMA4_CSDPi[8:7] Memory burst 16x32
-
- Dma4.WritePortAccessType = 0; // DMA4_CSDPi[15:14] Can not burst MMCHS_DATA reg
-
- Dma4.WriteMode = 1; // DMA4_CSDPi[17:16] Write posted ???
-
-
-
- Dma4.SourceStartAddress = (UINT32)BufferAddress; // DMA4_CSSAi
-
- Dma4.DestinationStartAddress = MMCHS_DATA; // DMA4_CDSAi
-
- Dma4.SourceElementIndex = 1; // DMA4_CSEi
-
- Dma4.SourceFrameIndex = 0x200; // DMA4_CSFi
-
- Dma4.DestinationElementIndex = 1; // DMA4_CDEi
-
- Dma4.DestinationFrameIndex = 0; // DMA4_CDFi
-
-
-
- Dma4.ReadPortAccessMode = 1; // DMA4_CCRi[13:12] Post increment memory address
-
- Dma4.WritePortAccessMode = 0; // DMA4_CCRi[15:14] Always write MMCHS_DATA
-
- Dma4.ReadRequestNumber = 0x1d; // DMA4_CCRi[4:0] Syncro with MMCA_DMA_TX (60)
-
- Dma4.WriteRequestNumber = 1; // DMA4_CCRi[20:19] Syncro upper 0x3d == 61 (one based)
-
- } else {
- return EFI_INVALID_PARAMETER;
- }
-
-
- EnableDmaChannel (2, &Dma4);
-
-
- //Set command argument based on the card access mode (Byte mode or Block mode)
- if (gCardInfo.OCRData.AccessMode & BIT1) {
- CmdArgument = Lba;
- } else {
- CmdArgument = Lba * This->Media->BlockSize;
- }
-
- //Send Command.
- Status = SendCmd (Cmd, CmdInterruptEnable, CmdArgument);
- if (EFI_ERROR (Status)) {
- DEBUG ((EFI_D_ERROR, "CMD fails. Status: %x\n", Status));
- return Status;
- }
-
- //Check for the Transfer completion.
- while (RetryCount < MAX_RETRY_COUNT) {
- //Read Status
- do {
- MmcStatus = MmioRead32 (MMCHS_STAT);
- } while (MmcStatus == 0);
-
- //Check if Transfer complete (TC) bit is set?
- if (MmcStatus & TC) {
- break;
- } else {
- DEBUG ((EFI_D_ERROR, "MmcStatus for TC: %x\n", MmcStatus));
- //Check if DEB, DCRC or DTO interrupt occured.
- if ((MmcStatus & DEB) | (MmcStatus & DCRC) | (MmcStatus & DTO)) {
- //There was an error during the data transfer.
-
- //Set SRD bit to 1 and wait until it return to 0x0.
- MmioOr32 (MMCHS_SYSCTL, SRD);
- while((MmioRead32 (MMCHS_SYSCTL) & SRD) != 0x0);
-
- DisableDmaChannel (2, DMA4_CSR_BLOCK, DMA4_CSR_ERR);
- DmaUnmap (BufferMap);
- return EFI_DEVICE_ERROR;
- }
- }
- RetryCount++;
- }
-
- DisableDmaChannel (2, DMA4_CSR_BLOCK, DMA4_CSR_ERR);
- Status = DmaUnmap (BufferMap);
-
- if (RetryCount == MAX_RETRY_COUNT) {
- DEBUG ((EFI_D_ERROR, "TransferBlockData timed out.\n"));
- return EFI_TIMEOUT;
- }
-
- return Status;
-}
-
-
-EFI_STATUS
-TransferBlock (
- IN EFI_BLOCK_IO_PROTOCOL *This,
- IN UINTN Lba,
- IN OUT VOID *Buffer,
- IN OPERATION_TYPE OperationType
- )
-{
- EFI_STATUS Status;
- UINTN MmcStatus;
- UINTN RetryCount = 0;
- UINTN Cmd = 0;
- UINTN CmdInterruptEnable = 0;
- UINTN CmdArgument = 0;
-
-
- //Populate the command information based on the operation type.
- if (OperationType == READ) {
- Cmd = CMD17; //Single block read
- CmdInterruptEnable = CMD18_INT_EN;
- } else if (OperationType == WRITE) {
- Cmd = CMD24; //Single block write
- CmdInterruptEnable = CMD24_INT_EN;
- }
-
- //Set command argument based on the card access mode (Byte mode or Block mode)
- if (gCardInfo.OCRData.AccessMode & BIT1) {
- CmdArgument = Lba;
- } else {
- CmdArgument = Lba * This->Media->BlockSize;
- }
-
- //Send Command.
- Status = SendCmd (Cmd, CmdInterruptEnable, CmdArgument);
- if (EFI_ERROR(Status)) {
- DEBUG ((EFI_D_ERROR, "CMD fails. Status: %x\n", Status));
- return Status;
- }
-
- //Read or Write data.
- if (OperationType == READ) {
- Status = ReadBlockData (This, Buffer);
- if (EFI_ERROR(Status)) {
- DEBUG((EFI_D_ERROR, "ReadBlockData fails.\n"));
- return Status;
- }
- } else if (OperationType == WRITE) {
- Status = WriteBlockData (This, Buffer);
- if (EFI_ERROR(Status)) {
- DEBUG((EFI_D_ERROR, "WriteBlockData fails.\n"));
- return Status;
- }
- }
-
- //Check for the Transfer completion.
- while (RetryCount < MAX_RETRY_COUNT) {
- //Read Status
- do {
- MmcStatus = MmioRead32 (MMCHS_STAT);
- } while (MmcStatus == 0);
-
- //Check if Transfer complete (TC) bit is set?
- if (MmcStatus & TC) {
- break;
- } else {
- DEBUG ((EFI_D_ERROR, "MmcStatus for TC: %x\n", MmcStatus));
- //Check if DEB, DCRC or DTO interrupt occured.
- if ((MmcStatus & DEB) | (MmcStatus & DCRC) | (MmcStatus & DTO)) {
- //There was an error during the data transfer.
-
- //Set SRD bit to 1 and wait until it return to 0x0.
- MmioOr32 (MMCHS_SYSCTL, SRD);
- while((MmioRead32 (MMCHS_SYSCTL) & SRD) != 0x0);
-
- return EFI_DEVICE_ERROR;
- }
- }
- RetryCount++;
- }
-
- if (RetryCount == MAX_RETRY_COUNT) {
- DEBUG ((EFI_D_ERROR, "TransferBlockData timed out.\n"));
- return EFI_TIMEOUT;
- }
-
- return EFI_SUCCESS;
-}
-
-BOOLEAN
-CardPresent (
- VOID
- )
-{
- EFI_STATUS Status;
- UINT8 Data;
-
- // TODO: adapt to Panda
- // Always return card present presently
- return TRUE;
-
- //
- // Card detect is a GPIO0 on the TPS65950
- //
- Status = gTPS65950->Read (gTPS65950, EXTERNAL_DEVICE_REGISTER(I2C_ADDR_GRP_ID2, GPIODATAIN1), 1, &Data);
- if (EFI_ERROR (Status)) {
- return FALSE;
- }
-
- if ((Data & CARD_DETECT_BIT) == CARD_DETECT_BIT) {
- // No Card present
- return FALSE;
- } else {
- return TRUE;
- }
-}
-
-EFI_STATUS
-DetectCard (
- VOID
- )
-{
- EFI_STATUS Status;
-
- if (!CardPresent ()) {
- return EFI_NO_MEDIA;
- }
-
- //Initialize MMC host controller clocks.
- Status = InitializeMMCHS ();
- if (EFI_ERROR(Status)) {
- DEBUG ((EFI_D_ERROR, "Initialize MMC host controller fails. Status: %x\n", Status));
- return Status;
- }
-
- //Software reset of the MMCHS host controller.
- MmioWrite32 (MMCHS_SYSCONFIG, SOFTRESET);
- gBS->Stall(1000);
- while ((MmioRead32 (MMCHS_SYSSTATUS) & RESETDONE_MASK) != RESETDONE);
-
- //Soft reset for all.
- MmioWrite32 (MMCHS_SYSCTL, SRA);
- gBS->Stall(1000);
- while ((MmioRead32 (MMCHS_SYSCTL) & SRA) != 0x0);
-
- //Voltage capabilities initialization. Activate VS18 and VS30.
- MmioOr32 (MMCHS_CAPA, (VS30 | VS18));
-
- //Wakeup configuration
- MmioOr32 (MMCHS_SYSCONFIG, ENAWAKEUP);
- MmioOr32 (MMCHS_HCTL, IWE);
-
- //MMCHS Controller default initialization
- MmioOr32 (MMCHS_CON, (OD | DW8_1_4_BIT | CEATA_OFF));
-
- MmioWrite32 (MMCHS_HCTL, (SDVS_3_0_V | DTW_1_BIT | SDBP_OFF));
-
- //Enable internal clock
- MmioOr32 (MMCHS_SYSCTL, ICE);
-
- //Set the clock frequency to 80KHz.
- UpdateMMCHSClkFrequency (CLKD_80KHZ);
-
- //Enable SD bus power.
- MmioOr32 (MMCHS_HCTL, (SDBP_ON));
-
- //Poll till SD bus power bit is set.
- while ((MmioRead32 (MMCHS_HCTL) & SDBP_MASK) != SDBP_ON);
-
- //Card idenfication
- Status = PerformCardIdenfication ();
- if (EFI_ERROR(Status)) {
- DEBUG ((EFI_D_ERROR, "No MMC/SD card detected.\n"));
- return Status;
- }
-
- //Get CSD (Card specific data) for the detected card.
- Status = GetCardSpecificData();
- if (EFI_ERROR(Status)) {
- return Status;
- }
-
- //Configure the card in data transfer mode.
- Status = PerformCardConfiguration();
- if (EFI_ERROR(Status)) {
- return Status;
- }
-
- //Patch the Media structure.
- gMMCHSMedia.LastBlock = (gCardInfo.NumBlocks - 1);
- gMMCHSMedia.BlockSize = gCardInfo.BlockSize;
- gMMCHSMedia.ReadOnly = (MmioRead32 (GPIO1_BASE + GPIO_DATAIN) & BIT23) == BIT23;
- gMMCHSMedia.MediaPresent = TRUE;
- gMMCHSMedia.MediaId++;
-
- DEBUG ((EFI_D_INFO, "SD Card Media Change on Handle 0x%08x\n", gImageHandle));
-
- return Status;
-}
-
-#define MAX_MMCHS_TRANSFER_SIZE 0x4000
-
-EFI_STATUS
-SdReadWrite (
- IN EFI_BLOCK_IO_PROTOCOL *This,
- IN UINTN Lba,
- OUT VOID *Buffer,
- IN UINTN BufferSize,
- IN OPERATION_TYPE OperationType
- )
-{
- EFI_STATUS Status = EFI_SUCCESS;
- UINTN RetryCount = 0;
- UINTN BlockCount;
- UINTN BytesToBeTranferedThisPass = 0;
- UINTN BytesRemainingToBeTransfered;
- EFI_TPL OldTpl;
-
- BOOLEAN Update;
-
-
-
- Update = FALSE;
-
- if (gMediaChange) {
- Update = TRUE;
- Status = DetectCard ();
- if (EFI_ERROR (Status)) {
- // We detected a removal
- gMMCHSMedia.MediaPresent = FALSE;
- gMMCHSMedia.LastBlock = 0;
- gMMCHSMedia.BlockSize = 512; // Should be zero but there is a bug in DiskIo
- gMMCHSMedia.ReadOnly = FALSE;
- }
- gMediaChange = FALSE;
- } else if (!gMMCHSMedia.MediaPresent) {
- Status = EFI_NO_MEDIA;
- goto Done;
- }
-
- if (Update) {
- DEBUG ((EFI_D_INFO, "SD Card ReinstallProtocolInterface ()\n"));
- gBS->ReinstallProtocolInterface (
- gImageHandle,
- &gEfiBlockIoProtocolGuid,
- &gBlockIo,
- &gBlockIo
- );
- return EFI_MEDIA_CHANGED;
- }
-
- if (EFI_ERROR (Status)) {
- goto Done;
- }
-
- if (Buffer == NULL) {
- Status = EFI_INVALID_PARAMETER;
- goto Done;
- }
-
- if (Lba > This->Media->LastBlock) {
- Status = EFI_INVALID_PARAMETER;
- goto Done;
- }
-
- if ((BufferSize % This->Media->BlockSize) != 0) {
- Status = EFI_BAD_BUFFER_SIZE;
- goto Done;
- }
-
- //Check if the data lines are not in use.
- while ((RetryCount++ < MAX_RETRY_COUNT) && ((MmioRead32 (MMCHS_PSTATE) & DATI_MASK) != DATI_ALLOWED));
- if (RetryCount == MAX_RETRY_COUNT) {
- Status = EFI_TIMEOUT;
- goto Done;
- }
-
- OldTpl = gBS->RaiseTPL (TPL_NOTIFY);
-
- BytesRemainingToBeTransfered = BufferSize;
- while (BytesRemainingToBeTransfered > 0) {
-
- if (gMediaChange) {
- Status = EFI_NO_MEDIA;
- DEBUG ((EFI_D_INFO, "SdReadWrite() EFI_NO_MEDIA due to gMediaChange\n"));
- goto DoneRestoreTPL;
- }
-
- // Turn OFF DMA path until it is debugged
- // BytesToBeTranferedThisPass = (BytesToBeTranferedThisPass >= MAX_MMCHS_TRANSFER_SIZE) ? MAX_MMCHS_TRANSFER_SIZE : BytesRemainingToBeTransfered;
- BytesToBeTranferedThisPass = This->Media->BlockSize;
-
- BlockCount = BytesToBeTranferedThisPass/This->Media->BlockSize;
-
- if (BlockCount > 1) {
- Status = DmaBlocks (This, Lba, Buffer, BlockCount, OperationType);
- } else {
- //Transfer a block worth of data.
- Status = TransferBlock (This, Lba, Buffer, OperationType);
- }
-
- if (EFI_ERROR(Status)) {
- DEBUG ((EFI_D_ERROR, "TransferBlockData fails. %x\n", Status));
- goto DoneRestoreTPL;
- }
-
- BytesRemainingToBeTransfered -= BytesToBeTranferedThisPass;
- Lba += BlockCount;
- Buffer = (UINT8 *)Buffer + This->Media->BlockSize;
- }
-
-DoneRestoreTPL:
-
- gBS->RestoreTPL (OldTpl);
-
-Done:
-
- return Status;
-
-}
-
-
-/**
-
- Reset the Block Device.
-
-
-
- @param This Indicates a pointer to the calling context.
-
- @param ExtendedVerification Driver may perform diagnostics on reset.
-
-
-
- @retval EFI_SUCCESS The device was reset.
-
- @retval EFI_DEVICE_ERROR The device is not functioning properly and could
-
- not be reset.
-
-
-
-**/
-EFI_STATUS
-EFIAPI
-MMCHSReset (
- IN EFI_BLOCK_IO_PROTOCOL *This,
- IN BOOLEAN ExtendedVerification
- )
-{
- return EFI_SUCCESS;
-}
-
-
-/**
-
- Read BufferSize bytes from Lba into Buffer.
-
-
-
- @param This Indicates a pointer to the calling context.
-
- @param MediaId Id of the media, changes every time the media is replaced.
-
- @param Lba The starting Logical Block Address to read from
-
- @param BufferSize Size of Buffer, must be a multiple of device block size.
-
- @param Buffer A pointer to the destination buffer for the data. The caller is
-
- responsible for either having implicit or explicit ownership of the buffer.
-
-
-
- @retval EFI_SUCCESS The data was read correctly from the device.
-
- @retval EFI_DEVICE_ERROR The device reported an error while performing the read.
-
- @retval EFI_NO_MEDIA There is no media in the device.
-
- @retval EFI_MEDIA_CHANGED The MediaId does not matched the current device.
-
- @retval EFI_BAD_BUFFER_SIZE The Buffer was not a multiple of the block size of the device.
-
- @retval EFI_INVALID_PARAMETER The read request contains LBAs that are not valid,
-
- or the buffer is not on proper alignment.
-
-EFI_STATUS
-
-**/
-EFI_STATUS
-EFIAPI
-MMCHSReadBlocks (
- IN EFI_BLOCK_IO_PROTOCOL *This,
- IN UINT32 MediaId,
- IN EFI_LBA Lba,
- IN UINTN BufferSize,
- OUT VOID *Buffer
- )
-{
- EFI_STATUS Status;
-
- //Perform Read operation.
- Status = SdReadWrite (This, (UINTN)Lba, Buffer, BufferSize, READ);
-
- return Status;
-
-}
-
-
-/**
-
- Write BufferSize bytes from Lba into Buffer.
-
-
-
- @param This Indicates a pointer to the calling context.
-
- @param MediaId The media ID that the write request is for.
-
- @param Lba The starting logical block address to be written. The caller is
-
- responsible for writing to only legitimate locations.
-
- @param BufferSize Size of Buffer, must be a multiple of device block size.
-
- @param Buffer A pointer to the source buffer for the data.
-
-
-
- @retval EFI_SUCCESS The data was written correctly to the device.
-
- @retval EFI_WRITE_PROTECTED The device can not be written to.
-
- @retval EFI_DEVICE_ERROR The device reported an error while performing the write.
-
- @retval EFI_NO_MEDIA There is no media in the device.
-
- @retval EFI_MEDIA_CHNAGED The MediaId does not matched the current device.
-
- @retval EFI_BAD_BUFFER_SIZE The Buffer was not a multiple of the block size of the device.
-
- @retval EFI_INVALID_PARAMETER The write request contains LBAs that are not valid,
-
- or the buffer is not on proper alignment.
-
-
-
-**/
-EFI_STATUS
-EFIAPI
-MMCHSWriteBlocks (
- IN EFI_BLOCK_IO_PROTOCOL *This,
- IN UINT32 MediaId,
- IN EFI_LBA Lba,
- IN UINTN BufferSize,
- IN VOID *Buffer
- )
-{
- EFI_STATUS Status;
-
- //Perform write operation.
- Status = SdReadWrite (This, (UINTN)Lba, Buffer, BufferSize, WRITE);
-
-
- return Status;
-
-}
-
-
-/**
-
- Flush the Block Device.
-
-
-
- @param This Indicates a pointer to the calling context.
-
-
-
- @retval EFI_SUCCESS All outstanding data was written to the device
-
- @retval EFI_DEVICE_ERROR The device reported an error while writting back the data
-
- @retval EFI_NO_MEDIA There is no media in the device.
-
-
-
-**/
-EFI_STATUS
-EFIAPI
-MMCHSFlushBlocks (
- IN EFI_BLOCK_IO_PROTOCOL *This
- )
-{
- return EFI_SUCCESS;
-}
-
-
-EFI_BLOCK_IO_PROTOCOL gBlockIo = {
- EFI_BLOCK_IO_INTERFACE_REVISION, // Revision
- &gMMCHSMedia, // *Media
- MMCHSReset, // Reset
- MMCHSReadBlocks, // ReadBlocks
- MMCHSWriteBlocks, // WriteBlocks
- MMCHSFlushBlocks // FlushBlocks
-};
-
-
-/**
-
- Timer callback to convert card present hardware into a boolean that indicates
-
- a media change event has happened. If you just check the GPIO you could see
-
- card 1 and then check again after card 1 was removed and card 2 was inserted
-
- and you would still see media present. Thus you need the timer tick to catch
-
- the toggle event.
-
-
-
- @param Event Event whose notification function is being invoked.
-
- @param Context The pointer to the notification function's context,
-
- which is implementation-dependent. Not used.
-
-
-
-**/
-VOID
-EFIAPI
-TimerCallback (
- IN EFI_EVENT Event,
- IN VOID *Context
- )
-{
- BOOLEAN Present;
-
- Present = CardPresent ();
- if (gMMCHSMedia.MediaPresent) {
- if (!Present && !gMediaChange) {
- gMediaChange = TRUE;
- }
- } else {
- if (Present && !gMediaChange) {
- gMediaChange = TRUE;
- }
- }
-}
-
-
-EFI_STATUS
-EFIAPI
-MMCHSInitialize (
- IN EFI_HANDLE ImageHandle,
- IN EFI_SYSTEM_TABLE *SystemTable
- )
-{
- EFI_STATUS Status;
-
- Status = gBS->LocateProtocol (&gEmbeddedExternalDeviceProtocolGuid, NULL, (VOID **)&gTPS65950);
- ASSERT_EFI_ERROR(Status);
-
- ZeroMem (&gCardInfo, sizeof (CARD_INFO));
-
- Status = gBS->CreateEvent (EVT_TIMER | EVT_NOTIFY_SIGNAL, TPL_CALLBACK, TimerCallback, NULL, &gTimerEvent);
- ASSERT_EFI_ERROR (Status);
-
- Status = gBS->SetTimer (gTimerEvent, TimerPeriodic, FixedPcdGet32 (PcdMmchsTimerFreq100NanoSeconds));
- ASSERT_EFI_ERROR (Status);
-
- //Publish BlockIO.
- Status = gBS->InstallMultipleProtocolInterfaces (
- &ImageHandle,
- &gEfiBlockIoProtocolGuid, &gBlockIo,
- &gEfiDevicePathProtocolGuid, &gMmcHsDevicePath,
- NULL
- );
- return Status;
-}
diff --git a/edk2/Omap44xxPkg/MMCHSDxe/MMCHS.h b/edk2/Omap44xxPkg/MMCHSDxe/MMCHS.h
deleted file mode 100644
index 79456d251..000000000
--- a/edk2/Omap44xxPkg/MMCHSDxe/MMCHS.h
+++ /dev/null
@@ -1,175 +0,0 @@
-/** @file
-
- Copyright (c) 2008 - 2009, Apple Inc. All rights reserved.<BR>
-
- This program and the accompanying materials
- are licensed and made 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 _MMCHS_H_
-#define _MMCHS_H_
-
-#include <Uefi.h>
-
-#include <Library/BaseLib.h>
-#include <Library/MemoryAllocationLib.h>
-#include <Library/DebugLib.h>
-#include <Library/IoLib.h>
-#include <Library/PcdLib.h>
-#include <Library/UefiBootServicesTableLib.h>
-#include <Library/BaseMemoryLib.h>
-#include <Library/OmapLib.h>
-#include <Library/OmapDmaLib.h>
-#include <Library/DmaLib.h>
-
-#include <Protocol/EmbeddedExternalDevice.h>
-#include <Protocol/BlockIo.h>
-#include <Protocol/DevicePath.h>
-
-#include <Omap4430/Omap4430.h>
-#include <TPS65950.h>
-
-#define MAX_RETRY_COUNT (100*5)
-
-#define HCS BIT30 //Host capacity support/1 = Supporting high capacity
-#define CCS BIT30 //Card capacity status/1 = High capacity card
-typedef struct {
- UINT32 Reserved0: 7; // 0
- UINT32 V170_V195: 1; // 1.70V - 1.95V
- UINT32 V200_V260: 7; // 2.00V - 2.60V
- UINT32 V270_V360: 9; // 2.70V - 3.60V
- UINT32 RESERVED_1: 5; // Reserved
- UINT32 AccessMode: 2; // 00b (byte mode), 10b (sector mode)
- UINT32 Busy: 1; // This bit is set to LOW if the card has not finished the power up routine
-}OCR;
-
-typedef struct {
- UINT32 NOT_USED; // 1 [0:0]
- UINT32 CRC; // CRC7 checksum [7:1]
- UINT32 MDT; // Manufacturing date [19:8]
- UINT32 RESERVED_1; // Reserved [23:20]
- UINT32 PSN; // Product serial number [55:24]
- UINT8 PRV; // Product revision [63:56]
- UINT8 PNM[5]; // Product name [64:103]
- UINT16 OID; // OEM/Application ID [119:104]
- UINT8 MID; // Manufacturer ID [127:120]
-}CID;
-
-typedef struct {
- UINT8 NOT_USED: 1; // Not used, always 1 [0:0]
- UINT8 CRC: 7; // CRC [7:1]
-
- UINT8 RESERVED_1: 2; // Reserved [9:8]
- UINT8 FILE_FORMAT: 2; // File format [11:10]
- UINT8 TMP_WRITE_PROTECT: 1; // Temporary write protection [12:12]
- UINT8 PERM_WRITE_PROTECT: 1; // Permanent write protection [13:13]
- UINT8 COPY: 1; // Copy flag (OTP) [14:14]
- UINT8 FILE_FORMAT_GRP: 1; // File format group [15:15]
-
- UINT16 RESERVED_2: 5; // Reserved [20:16]
- UINT16 WRITE_BL_PARTIAL: 1; // Partial blocks for write allowed [21:21]
- UINT16 WRITE_BL_LEN: 4; // Max. write data block length [25:22]
- UINT16 R2W_FACTOR: 3; // Write speed factor [28:26]
- UINT16 RESERVED_3: 2; // Reserved [30:29]
- UINT16 WP_GRP_ENABLE: 1; // Write protect group enable [31:31]
-
- UINT32 WP_GRP_SIZE: 7; // Write protect group size [38:32]
- UINT32 SECTOR_SIZE: 7; // Erase sector size [45:39]
- UINT32 ERASE_BLK_EN: 1; // Erase single block enable [46:46]
- UINT32 C_SIZE_MULT: 3; // Device size multiplier [49:47]
- UINT32 VDD_W_CURR_MAX: 3; // Max. write current @ VDD max [52:50]
- UINT32 VDD_W_CURR_MIN: 3; // Max. write current @ VDD min [55:53]
- UINT32 VDD_R_CURR_MAX: 3; // Max. read current @ VDD max [58:56]
- UINT32 VDD_R_CURR_MIN: 3; // Max. read current @ VDD min [61:59]
- UINT32 C_SIZELow2: 2; // Device size [63:62]
-
- UINT32 C_SIZEHigh10: 10;// Device size [73:64]
- UINT32 RESERVED_4: 2; // Reserved [75:74]
- UINT32 DSR_IMP: 1; // DSR implemented [76:76]
- UINT32 READ_BLK_MISALIGN: 1; // Read block misalignment [77:77]
- UINT32 WRITE_BLK_MISALIGN: 1; // Write block misalignment [78:78]
- UINT32 READ_BL_PARTIAL: 1; // Partial blocks for read allowed [79:79]
- UINT32 READ_BL_LEN: 4; // Max. read data block length [83:80]
- UINT32 CCC: 12;// Card command classes [95:84]
-
- UINT8 TRAN_SPEED ; // Max. bus clock frequency [103:96]
- UINT8 NSAC ; // Data read access-time 2 in CLK cycles (NSAC*100) [111:104]
- UINT8 TAAC ; // Data read access-time 1 [119:112]
-
- UINT8 RESERVED_5: 6; // Reserved [125:120]
- UINT8 CSD_STRUCTURE: 2; // CSD structure [127:126]
-}CSD;
-
-typedef struct {
- UINT8 NOT_USED: 1; // Not used, always 1 [0:0]
- UINT8 CRC: 7; // CRC [7:1]
- UINT8 RESERVED_1: 2; // Reserved [9:8]
- UINT8 FILE_FORMAT: 2; // File format [11:10]
- UINT8 TMP_WRITE_PROTECT: 1; // Temporary write protection [12:12]
- UINT8 PERM_WRITE_PROTECT: 1; // Permanent write protection [13:13]
- UINT8 COPY: 1; // Copy flag (OTP) [14:14]
- UINT8 FILE_FORMAT_GRP: 1; // File format group [15:15]
- UINT16 RESERVED_2: 5; // Reserved [20:16]
- UINT16 WRITE_BL_PARTIAL: 1; // Partial blocks for write allowed [21:21]
- UINT16 WRITE_BL_LEN: 4; // Max. write data block length [25:22]
- UINT16 R2W_FACTOR: 3; // Write speed factor [28:26]
- UINT16 RESERVED_3: 2; // Reserved [30:29]
- UINT16 WP_GRP_ENABLE: 1; // Write protect group enable [31:31]
- UINT16 WP_GRP_SIZE: 7; // Write protect group size [38:32]
- UINT16 SECTOR_SIZE: 7; // Erase sector size [45:39]
- UINT16 ERASE_BLK_EN: 1; // Erase single block enable [46:46]
- UINT16 RESERVED_4: 1; // Reserved [47:47]
- UINT32 C_SIZELow16: 16;// Device size [69:48]
- UINT32 C_SIZEHigh6: 6; // Device size [69:48]
- UINT32 RESERVED_5: 6; // Reserved [75:70]
- UINT32 DSR_IMP: 1; // DSR implemented [76:76]
- UINT32 READ_BLK_MISALIGN: 1; // Read block misalignment [77:77]
- UINT32 WRITE_BLK_MISALIGN: 1; // Write block misalignment [78:78]
- UINT32 READ_BL_PARTIAL: 1; // Partial blocks for read allowed [79:79]
- UINT16 READ_BL_LEN: 4; // Max. read data block length [83:80]
- UINT16 CCC: 12;// Card command classes [95:84]
- UINT8 TRAN_SPEED ; // Max. bus clock frequency [103:96]
- UINT8 NSAC ; // Data read access-time 2 in CLK cycles (NSAC*100) [111:104]
- UINT8 TAAC ; // Data read access-time 1 [119:112]
- UINT8 RESERVED_6: 6; // 0 [125:120]
- UINT8 CSD_STRUCTURE: 2; // CSD structure [127:126]
-}CSD_SDV2;
-
-typedef enum {
- UNKNOWN_CARD,
- MMC_CARD, //MMC card
- SD_CARD, //SD 1.1 card
- SD_CARD_2, //SD 2.0 or above standard card
- SD_CARD_2_HIGH //SD 2.0 or above high capacity card
-} CARD_TYPE;
-
-typedef enum {
- READ,
- WRITE
-} OPERATION_TYPE;
-
-typedef struct {
- UINT16 RCA;
- UINTN BlockSize;
- UINTN NumBlocks;
- UINTN ClockFrequencySelect;
- CARD_TYPE CardType;
- OCR OCRData;
- CID CIDData;
- CSD CSDData;
-} CARD_INFO;
-
-EFI_STATUS
-DetectCard (
- VOID
- );
-
-extern EFI_BLOCK_IO_PROTOCOL gBlockIo;
-
-#endif
diff --git a/edk2/Omap44xxPkg/MMCHSDxe/MMCHS.inf b/edk2/Omap44xxPkg/MMCHSDxe/MMCHS.inf
deleted file mode 100644
index 86db8dd6c..000000000
--- a/edk2/Omap44xxPkg/MMCHSDxe/MMCHS.inf
+++ /dev/null
@@ -1,54 +0,0 @@
-#/** @file
-#
-# Copyright (c) 2008 - 2010, Apple Inc. All rights reserved.<BR>
-# This program and the accompanying materials
-# are licensed and made available under the terms and conditions of the BSD License
-# which accompanies this distribution. The full text of the license may be found at
-# http://opensource.org/licenses/bsd-license.php
-#
-# THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
-# WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
-#
-#**/
-
-[Defines]
- INF_VERSION = 0x00010005
- BASE_NAME = MMCHS
- FILE_GUID = 100c2cfa-b586-4198-9b4c-1683d195b1da
- MODULE_TYPE = DXE_DRIVER
- VERSION_STRING = 1.0
-
- ENTRY_POINT = MMCHSInitialize
-
-
-[Sources.common]
- MMCHS.c
-
-[Packages]
- MdePkg/MdePkg.dec
- EmbeddedPkg/EmbeddedPkg.dec
- Omap44xxPkg/Omap44xxPkg.dec
-
-[LibraryClasses]
- PcdLib
- UefiLib
- UefiDriverEntryPoint
- MemoryAllocationLib
- IoLib
- OmapDmaLib
- DmaLib
-
-[Guids]
-
-[Protocols]
- gEfiBlockIoProtocolGuid
- gEfiCpuArchProtocolGuid
- gEfiDevicePathProtocolGuid
- gEmbeddedExternalDeviceProtocolGuid
-
-[Pcd]
- gOmap44xxTokenSpaceGuid.PcdOmap44xxMMCHS1Base
- gOmap44xxTokenSpaceGuid.PcdMmchsTimerFreq100NanoSeconds
-
-[depex]
- gEmbeddedExternalDeviceProtocolGuid
diff --git a/edk2/Omap44xxPkg/MmcHostDxe/MmcHostDxe.c b/edk2/Omap44xxPkg/MmcHostDxe/MmcHostDxe.c
index 1812dbb11..f2ac0bbcc 100644
--- a/edk2/Omap44xxPkg/MmcHostDxe/MmcHostDxe.c
+++ b/edk2/Omap44xxPkg/MmcHostDxe/MmcHostDxe.c
@@ -15,7 +15,7 @@
#include "MmcHostDxe.h"
-EMBEDDED_EXTERNAL_DEVICE *gTPS65950;
+EMBEDDED_EXTERNAL_DEVICE *gTWL6030;
UINT8 mMaxDataTransferRate = 0;
UINT32 mRca = 0;
BOOLEAN mBitModeSet = FALSE;
@@ -250,39 +250,51 @@ InitializeMMCHS (
VOID
)
{
- // TODO: adapt to Panda
-#if 0
UINT8 Data;
EFI_STATUS Status;
-#endif
DEBUG ((DEBUG_BLKIO, "InitializeMMCHS()\n"));
-#if 0
- // Select Device group to belong to P1 device group in Power IC.
- Data = DEV_GRP_P1;
- Status = gTPS65950->Write (gTPS65950, EXTERNAL_DEVICE_REGISTER(I2C_ADDR_GRP_ID4, VMMC1_DEV_GRP), 1, &Data);
+ // Disconnect PBIAS prior to voltage change
+ MmioAnd32 (CONTROL_PBIAS_LITE, ~(PBIASPWRDNZ | PBIASLITEPWRDNZ));
+
+ // Disable VMMC LDO
+ Data = VMMC_CFG_STATE_OFF;
+ Status = gTWL6030->Write (gTWL6030, EXTERNAL_DEVICE_REGISTER(I2C_ADDR_GRP_ID1, VMMC_CFG_STATE), 1, &Data);
ASSERT_EFI_ERROR(Status);
- // Configure voltage regulator for MMC1 in Power IC to output 3.0 voltage.
+ // Wait for stabilization
+ gBS->Stall(500);
+
+ // Configure VMMC LDO to output 3.0 voltage.
Data = VSEL_3_00V;
- Status = gTPS65950->Write (gTPS65950, EXTERNAL_DEVICE_REGISTER(I2C_ADDR_GRP_ID4, VMMC1_DEDICATED_REG), 1, &Data);
+ Status = gTWL6030->Write (gTWL6030, EXTERNAL_DEVICE_REGISTER(I2C_ADDR_GRP_ID1, VMMC_CFG_VOLTAGE), 1, &Data);
ASSERT_EFI_ERROR(Status);
-
- // After ramping up voltage, set VDDS stable bit to indicate that voltage level is stable.
- MmioOr32 (CONTROL_PBIAS_LITE, (PBIASLITEVMODE0 | PBIASLITEPWRDNZ0 | PBIASSPEEDCTRL0 | PBIASLITEVMODE1 | PBIASLITEWRDNZ1));
- // Enable WP GPIO
- MmioAndThenOr32 (GPIO1_BASE + GPIO_OE, ~BIT23, BIT23);
+ // Enable VMMC LDO
+ Data = VMMC_CFG_STATE_ON;
+ Status = gTWL6030->Write (gTWL6030, EXTERNAL_DEVICE_REGISTER(I2C_ADDR_GRP_ID1, VMMC_CFG_STATE), 1, &Data);
+ ASSERT_EFI_ERROR(Status);
+
+ // Wait for stabilization
+ gBS->Stall(500);
- // Enable Card Detect
- Data = CARD_DETECT_ENABLE;
- gTPS65950->Write (gTPS65950, EXTERNAL_DEVICE_REGISTER(I2C_ADDR_GRP_ID2, TPS65950_GPIO_CTRL), 1, &Data);
+ // PBIAS in normal operating mode (not HiZ)
+ MmioAnd32 (CONTROL_PBIAS_LITE, ~PBIASHIZ);
- return Status;
-#endif
+ // Select VMODE=3V and connect VDDS_MMC1 to PBIAS
+ MmioOr32 (CONTROL_PBIAS_LITE, (PBIASVMODE3V|PBIASLITEPWRDNZ));
- return (1);
+ // Wait for PBIAS supply detection
+ gBS->Stall(100);
+
+ // Connect pads
+ MmioOr32 (CONTROL_PBIAS_LITE, PBIASPWRDNZ);
+
+ // Stop here if supply detector did not sense 3V
+ ASSERT( !(MmioRead32(CONTROL_PBIAS_LITE) & PBIASVMODEERR) );
+
+ return Status;
}
BOOLEAN
@@ -290,24 +302,18 @@ MMCIsCardPresent (
IN EFI_MMC_HOST_PROTOCOL *This
)
{
- // TODO: adapt to Panda
- // Always return card present presently
- return (1);
-
-#if 0
EFI_STATUS Status;
UINT8 Data;
//
- // Card detect is a GPIO0 on the TPS65950
+ // Card detect is a GPIO0 on the TWL6030
//
- Status = gTPS65950->Read (gTPS65950, EXTERNAL_DEVICE_REGISTER(I2C_ADDR_GRP_ID2, GPIODATAIN1), 1, &Data);
+ Status = gTWL6030->Read (gTWL6030, EXTERNAL_DEVICE_REGISTER(I2C_ADDR_GRP_ID1, MMCCTRL), 1, &Data);
if (EFI_ERROR (Status)) {
return FALSE;
}
- return !(Data & CARD_DETECT_BIT);
-#endif
+ return !(Data & CARD_DET_STS_MMC);
}
@@ -677,7 +683,7 @@ MMCInitialize (
DEBUG ((DEBUG_BLKIO, "MMCInitialize()\n"));
- Status = gBS->LocateProtocol (&gEmbeddedExternalDeviceProtocolGuid, NULL, (VOID **)&gTPS65950);
+ Status = gBS->LocateProtocol (&gEmbeddedExternalDeviceProtocolGuid, NULL, (VOID **)&gTWL6030);
ASSERT_EFI_ERROR(Status);
Status = gBS->InstallMultipleProtocolInterfaces (
diff --git a/edk2/Omap44xxPkg/MmcHostDxe/MmcHostDxe.h b/edk2/Omap44xxPkg/MmcHostDxe/MmcHostDxe.h
index a7bea5a37..4b9da8527 100755
--- a/edk2/Omap44xxPkg/MmcHostDxe/MmcHostDxe.h
+++ b/edk2/Omap44xxPkg/MmcHostDxe/MmcHostDxe.h
@@ -35,7 +35,7 @@
#include <Protocol/MmcHost.h>
#include <Omap4430/Omap4430.h>
-#include <TPS65950.h>
+#include <TWL6030.h>
#define MAX_RETRY_COUNT (100*5)
diff --git a/edk2/Omap44xxPkg/Omap44xxPkg.dsc b/edk2/Omap44xxPkg/Omap44xxPkg.dsc
index 77f77dc6e..b8b20eaf4 100644
--- a/edk2/Omap44xxPkg/Omap44xxPkg.dsc
+++ b/edk2/Omap44xxPkg/Omap44xxPkg.dsc
@@ -147,20 +147,16 @@
gArmTokenSpaceGuid.PcdCpuVectorBaseAddress|0x80000000
gArmTokenSpaceGuid.PcdCpuResetAddress|0x80008000
- gOmap44xxTokenSpaceGuid.PcdOmap44xxGpmcOffset|0x6E000000
+ gOmap44xxTokenSpaceGuid.PcdOmap44xxGpmcOffset|0x50000000
gOmap44xxTokenSpaceGuid.PcdOmap44xxMMCHS1Base|0x4809C000
- # Console
+ # Console
gOmap44xxTokenSpaceGuid.PcdOmap44xxConsoleUart|3
# Timers
gOmap44xxTokenSpaceGuid.PcdOmap44xxArchTimer|3
gOmap44xxTokenSpaceGuid.PcdOmap44xxFreeTimer|4
gEmbeddedTokenSpaceGuid.PcdTimerPeriod|100000
-
-# gEmbeddedTokenSpaceGuid.PcdEmbeddedPerformanceCounterPeriodInNanoseconds|77
-# gEmbeddedTokenSpaceGuid.PcdEmbeddedPerformanceCounterFrequencyInHz|13000000
-
gEmbeddedTokenSpaceGuid.PcdEmbeddedPerformanceCounterPeriodInNanoseconds|26
gEmbeddedTokenSpaceGuid.PcdEmbeddedPerformanceCounterFrequencyInHz|38400000
@@ -178,12 +174,8 @@
Omap44xxPkg/Library/Omap44xxTimerLib/Omap44xxTimerLib.inf
Omap44xxPkg/Library/OmapLib/OmapLib.inf
Omap44xxPkg/Library/OmapDmaLib/OmapDmaLib.inf
-
- Omap44xxPkg/Flash/Flash.inf
- Omap44xxPkg/MMCHSDxe/MMCHS.inf
Omap44xxPkg/SmbusDxe/Smbus.inf
Omap44xxPkg/Gpio/Gpio.inf
- Omap44xxPkg/InterruptDxe/InterruptDxe.inf
Omap44xxPkg/TimerDxe/TimerDxe.inf
Omap44xxPkg/TPS65950Dxe/TPS65950.inf
diff --git a/edk2/Omap44xxPkg/PciEmulation/PciEmulation.c b/edk2/Omap44xxPkg/PciEmulation/PciEmulation.c
index 8565fd9c5..dc9109f91 100644
--- a/edk2/Omap44xxPkg/PciEmulation/PciEmulation.c
+++ b/edk2/Omap44xxPkg/PciEmulation/PciEmulation.c
@@ -14,7 +14,7 @@
#include "PciEmulation.h"
-EMBEDDED_EXTERNAL_DEVICE *gTPS65950;
+EMBEDDED_EXTERNAL_DEVICE *gTWL6030;
#define HOST_CONTROLLER_OPERATION_REG_SIZE 0x44
@@ -81,27 +81,27 @@ ConfigureUSBHost (
MmioWrite32 (GPIO5_BASE + GPIO_SETDATAOUT, BIT19);
// Get the Power IC protocol
- Status = gBS->LocateProtocol (&gEmbeddedExternalDeviceProtocolGuid, NULL, (VOID **)&gTPS65950);
+ Status = gBS->LocateProtocol (&gEmbeddedExternalDeviceProtocolGuid, NULL, (VOID **)&gTWL6030);
ASSERT_EFI_ERROR (Status);
// Power the USB PHY
Data = VAUX_DEV_GRP_P1;
- Status = gTPS65950->Write (gTPS65950, EXTERNAL_DEVICE_REGISTER(I2C_ADDR_GRP_ID4, VAUX2_DEV_GRP), 1, &Data);
+ Status = gTWL6030->Write (gTWL6030, EXTERNAL_DEVICE_REGISTER(I2C_ADDR_GRP_ID4, VAUX2_DEV_GRP), 1, &Data);
ASSERT_EFI_ERROR(Status);
Data = VAUX_DEDICATED_18V;
- Status = gTPS65950->Write (gTPS65950, EXTERNAL_DEVICE_REGISTER(I2C_ADDR_GRP_ID4, VAUX2_DEDICATED), 1, &Data);
+ Status = gTWL6030->Write (gTWL6030, EXTERNAL_DEVICE_REGISTER(I2C_ADDR_GRP_ID4, VAUX2_DEDICATED), 1, &Data);
ASSERT_EFI_ERROR (Status);
// Enable power to the USB hub
- Status = gTPS65950->Read (gTPS65950, EXTERNAL_DEVICE_REGISTER(I2C_ADDR_GRP_ID3, LEDEN), 1, &Data);
+ Status = gTWL6030->Read (gTWL6030, EXTERNAL_DEVICE_REGISTER(I2C_ADDR_GRP_ID3, LEDEN), 1, &Data);
ASSERT_EFI_ERROR (Status);
// LEDAON controls the power to the USB host, PWM is disabled
Data &= ~LEDAPWM;
Data |= LEDAON;
- Status = gTPS65950->Write (gTPS65950, EXTERNAL_DEVICE_REGISTER(I2C_ADDR_GRP_ID3, LEDEN), 1, &Data);
+ Status = gTWL6030->Write (gTWL6030, EXTERNAL_DEVICE_REGISTER(I2C_ADDR_GRP_ID3, LEDEN), 1, &Data);
ASSERT_EFI_ERROR (Status);
}
diff --git a/edk2/Omap44xxPkg/PciEmulation/PciEmulation.h b/edk2/Omap44xxPkg/PciEmulation/PciEmulation.h
index a0ccb1e1d..ba719e1db 100644
--- a/edk2/Omap44xxPkg/PciEmulation/PciEmulation.h
+++ b/edk2/Omap44xxPkg/PciEmulation/PciEmulation.h
@@ -17,7 +17,7 @@
#include <PiDxe.h>
-#include <TPS65950.h>
+#include <TWL6030.h>
#include <Library/BaseLib.h>
#include <Library/BaseMemoryLib.h>
diff --git a/edk2/Omap44xxPkg/TPS65950Dxe/TPS65950.c b/edk2/Omap44xxPkg/TWL6030Dxe/TWL6030.c
index 6b76da507..f4027bfa8 100644
--- a/edk2/Omap44xxPkg/TPS65950Dxe/TPS65950.c
+++ b/edk2/Omap44xxPkg/TWL6030Dxe/TWL6030.c
@@ -14,7 +14,7 @@
#include <Uefi.h>
-#include <TPS65950.h>
+#include <TWL6030.h>
#include <Library/BaseMemoryLib.h>
#include <Library/DebugLib.h>
@@ -101,7 +101,7 @@ EMBEDDED_EXTERNAL_DEVICE ExternalDevice = {
};
EFI_STATUS
-TPS65950Initialize (
+TWL6030Initialize (
IN EFI_HANDLE ImageHandle,
IN EFI_SYSTEM_TABLE *SystemTable
)
diff --git a/edk2/Omap44xxPkg/TPS65950Dxe/TPS65950.inf b/edk2/Omap44xxPkg/TWL6030Dxe/TWL6030.inf
index 36e124179..a539bfaae 100644
--- a/edk2/Omap44xxPkg/TPS65950Dxe/TPS65950.inf
+++ b/edk2/Omap44xxPkg/TWL6030Dxe/TWL6030.inf
@@ -13,16 +13,16 @@
[Defines]
INF_VERSION = 0x00010005
- BASE_NAME = TPS65950
+ BASE_NAME = TWL6030
FILE_GUID = 71fe861a-5450-48b6-bfb0-b93522616f99
MODULE_TYPE = DXE_DRIVER
VERSION_STRING = 1.0
- ENTRY_POINT = TPS65950Initialize
+ ENTRY_POINT = TWL6030Initialize
[Sources.common]
- TPS65950.c
+ TWL6030.c
[Packages]
MdePkg/MdePkg.dec
diff --git a/edk2/OptionRomPkg/UndiRuntimeDxe/Init.c b/edk2/OptionRomPkg/UndiRuntimeDxe/Init.c
index 10c26ad43..49ec0d5de 100644
--- a/edk2/OptionRomPkg/UndiRuntimeDxe/Init.c
+++ b/edk2/OptionRomPkg/UndiRuntimeDxe/Init.c
@@ -1,7 +1,7 @@
/** @file
Initialization functions for EFI UNDI32 driver.
-Copyright (c) 2006 - 2011, Intel Corporation. All rights reserved.<BR>
+Copyright (c) 2006 - 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
which accompanies this distribution. The full text of the license may be found at
@@ -616,38 +616,38 @@ UndiDriverStop (
UNDI32Device = UNDI_DEV_FROM_THIS (NIIProtocol);
- Status = gBS->UninstallMultipleProtocolInterfaces (
- ChildHandleBuffer[Index],
- &gEfiDevicePathProtocolGuid,
- UNDI32Device->Undi32DevPath,
- &gEfiNetworkInterfaceIdentifierProtocolGuid_31,
- &UNDI32Device->NIIProtocol_31,
- NULL
+ Status = gBS->CloseProtocol (
+ Controller,
+ &gEfiPciIoProtocolGuid,
+ This->DriverBindingHandle,
+ ChildHandleBuffer[Index]
);
if (!EFI_ERROR (Status)) {
- //
- // Restore original PCI attributes
- //
- Status = UNDI32Device->NicInfo.Io_Function->Attributes (
- UNDI32Device->NicInfo.Io_Function,
- EfiPciIoAttributeOperationSet,
- UNDI32Device->NicInfo.OriginalPciAttributes,
- NULL
- );
- ASSERT_EFI_ERROR (Status);
-
- Status = gBS->CloseProtocol (
- Controller,
- &gEfiPciIoProtocolGuid,
- This->DriverBindingHandle,
- ChildHandleBuffer[Index]
+ Status = gBS->UninstallMultipleProtocolInterfaces (
+ ChildHandleBuffer[Index],
+ &gEfiDevicePathProtocolGuid,
+ UNDI32Device->Undi32DevPath,
+ &gEfiNetworkInterfaceIdentifierProtocolGuid_31,
+ &UNDI32Device->NIIProtocol_31,
+ NULL
);
-
- ASSERT_EFI_ERROR (Status);
-
- gBS->FreePool (UNDI32Device->Undi32DevPath);
- gBS->FreePool (UNDI32Device);
-
+ if (!EFI_ERROR (Status)) {
+ //
+ // Restore original PCI attributes
+ //
+ Status = UNDI32Device->NicInfo.Io_Function->Attributes (
+ UNDI32Device->NicInfo.Io_Function,
+ EfiPciIoAttributeOperationSet,
+ UNDI32Device->NicInfo.OriginalPciAttributes,
+ NULL
+ );
+
+ ASSERT_EFI_ERROR (Status);
+
+ gBS->FreePool (UNDI32Device->Undi32DevPath);
+ gBS->FreePool (UNDI32Device);
+
+ }
}
}
diff --git a/edk2/OvmfPkg/AcpiTables/Facp.aslc b/edk2/OvmfPkg/AcpiTables/Facp.aslc
index 125e9b441..b48af760e 100644
--- a/edk2/OvmfPkg/AcpiTables/Facp.aslc
+++ b/edk2/OvmfPkg/AcpiTables/Facp.aslc
@@ -1,7 +1,7 @@
/** @file
FACP Table
- Copyright (c) 2008 - 2009, Intel Corporation. All rights reserved.<BR>
+ Copyright (c) 2008 - 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
which accompanies this distribution. The full text of the license may be found at
@@ -15,15 +15,17 @@
#include "Platform.h"
EFI_ACPI_1_0_FIXED_ACPI_DESCRIPTION_TABLE FACP = {
- EFI_ACPI_1_0_FIXED_ACPI_DESCRIPTION_TABLE_SIGNATURE,
- sizeof (EFI_ACPI_1_0_FIXED_ACPI_DESCRIPTION_TABLE),
- EFI_ACPI_1_0_FIXED_ACPI_DESCRIPTION_TABLE_REVISION,
- 0, // to make sum of entire table == 0
- EFI_ACPI_OEM_ID, // OEMID is a 6 bytes long field
- EFI_ACPI_OEM_TABLE_ID, // OEM table identification(8 bytes long)
- EFI_ACPI_OEM_REVISION, // OEM revision number
- EFI_ACPI_CREATOR_ID, // ASL compiler vendor ID
- EFI_ACPI_CREATOR_REVISION, // ASL compiler revision number
+ {
+ EFI_ACPI_1_0_FIXED_ACPI_DESCRIPTION_TABLE_SIGNATURE,
+ sizeof (EFI_ACPI_1_0_FIXED_ACPI_DESCRIPTION_TABLE),
+ EFI_ACPI_1_0_FIXED_ACPI_DESCRIPTION_TABLE_REVISION,
+ 0, // to make sum of entire table == 0
+ {EFI_ACPI_OEM_ID}, // OEMID is a 6 bytes long field
+ EFI_ACPI_OEM_TABLE_ID, // OEM table identification(8 bytes long)
+ EFI_ACPI_OEM_REVISION, // OEM revision number
+ EFI_ACPI_CREATOR_ID, // ASL compiler vendor ID
+ EFI_ACPI_CREATOR_REVISION // ASL compiler revision number
+ },
0, // Physical addesss of FACS
0, // Physical address of DSDT
INT_MODEL, // System Interrupt Model
diff --git a/edk2/OvmfPkg/AcpiTables/Facs.aslc b/edk2/OvmfPkg/AcpiTables/Facs.aslc
index 169ec867b..53bb0fcb8 100644
--- a/edk2/OvmfPkg/AcpiTables/Facs.aslc
+++ b/edk2/OvmfPkg/AcpiTables/Facs.aslc
@@ -1,7 +1,7 @@
/** @file
FACS Table
- Copyright (c) 2008 - 2009, Intel Corporation. All rights reserved.<BR>
+ Copyright (c) 2008 - 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
which accompanies this distribution. The full text of the license may be found at
@@ -25,46 +25,48 @@ EFI_ACPI_1_0_FIRMWARE_ACPI_CONTROL_STRUCTURE FACS = {
0x00,
0x00,
0x00,
- EFI_ACPI_RESERVED_BYTE,
- EFI_ACPI_RESERVED_BYTE,
- EFI_ACPI_RESERVED_BYTE,
- EFI_ACPI_RESERVED_BYTE,
- EFI_ACPI_RESERVED_BYTE,
- EFI_ACPI_RESERVED_BYTE,
- EFI_ACPI_RESERVED_BYTE,
- EFI_ACPI_RESERVED_BYTE,
- EFI_ACPI_RESERVED_BYTE,
- EFI_ACPI_RESERVED_BYTE,
- EFI_ACPI_RESERVED_BYTE,
- EFI_ACPI_RESERVED_BYTE,
- EFI_ACPI_RESERVED_BYTE,
- EFI_ACPI_RESERVED_BYTE,
- EFI_ACPI_RESERVED_BYTE,
- EFI_ACPI_RESERVED_BYTE,
- EFI_ACPI_RESERVED_BYTE,
- EFI_ACPI_RESERVED_BYTE,
- EFI_ACPI_RESERVED_BYTE,
- EFI_ACPI_RESERVED_BYTE,
- EFI_ACPI_RESERVED_BYTE,
- EFI_ACPI_RESERVED_BYTE,
- EFI_ACPI_RESERVED_BYTE,
- EFI_ACPI_RESERVED_BYTE,
- EFI_ACPI_RESERVED_BYTE,
- EFI_ACPI_RESERVED_BYTE,
- EFI_ACPI_RESERVED_BYTE,
- EFI_ACPI_RESERVED_BYTE,
- EFI_ACPI_RESERVED_BYTE,
- EFI_ACPI_RESERVED_BYTE,
- EFI_ACPI_RESERVED_BYTE,
- EFI_ACPI_RESERVED_BYTE,
- EFI_ACPI_RESERVED_BYTE,
- EFI_ACPI_RESERVED_BYTE,
- EFI_ACPI_RESERVED_BYTE,
- EFI_ACPI_RESERVED_BYTE,
- EFI_ACPI_RESERVED_BYTE,
- EFI_ACPI_RESERVED_BYTE,
- EFI_ACPI_RESERVED_BYTE,
- EFI_ACPI_RESERVED_BYTE
+ {
+ EFI_ACPI_RESERVED_BYTE,
+ EFI_ACPI_RESERVED_BYTE,
+ EFI_ACPI_RESERVED_BYTE,
+ EFI_ACPI_RESERVED_BYTE,
+ EFI_ACPI_RESERVED_BYTE,
+ EFI_ACPI_RESERVED_BYTE,
+ EFI_ACPI_RESERVED_BYTE,
+ EFI_ACPI_RESERVED_BYTE,
+ EFI_ACPI_RESERVED_BYTE,
+ EFI_ACPI_RESERVED_BYTE,
+ EFI_ACPI_RESERVED_BYTE,
+ EFI_ACPI_RESERVED_BYTE,
+ EFI_ACPI_RESERVED_BYTE,
+ EFI_ACPI_RESERVED_BYTE,
+ EFI_ACPI_RESERVED_BYTE,
+ EFI_ACPI_RESERVED_BYTE,
+ EFI_ACPI_RESERVED_BYTE,
+ EFI_ACPI_RESERVED_BYTE,
+ EFI_ACPI_RESERVED_BYTE,
+ EFI_ACPI_RESERVED_BYTE,
+ EFI_ACPI_RESERVED_BYTE,
+ EFI_ACPI_RESERVED_BYTE,
+ EFI_ACPI_RESERVED_BYTE,
+ EFI_ACPI_RESERVED_BYTE,
+ EFI_ACPI_RESERVED_BYTE,
+ EFI_ACPI_RESERVED_BYTE,
+ EFI_ACPI_RESERVED_BYTE,
+ EFI_ACPI_RESERVED_BYTE,
+ EFI_ACPI_RESERVED_BYTE,
+ EFI_ACPI_RESERVED_BYTE,
+ EFI_ACPI_RESERVED_BYTE,
+ EFI_ACPI_RESERVED_BYTE,
+ EFI_ACPI_RESERVED_BYTE,
+ EFI_ACPI_RESERVED_BYTE,
+ EFI_ACPI_RESERVED_BYTE,
+ EFI_ACPI_RESERVED_BYTE,
+ EFI_ACPI_RESERVED_BYTE,
+ EFI_ACPI_RESERVED_BYTE,
+ EFI_ACPI_RESERVED_BYTE,
+ EFI_ACPI_RESERVED_BYTE
+ }
};
diff --git a/edk2/OvmfPkg/AcpiTables/Madt.aslc b/edk2/OvmfPkg/AcpiTables/Madt.aslc
index 62bf2c7fd..8a3b836bc 100644
--- a/edk2/OvmfPkg/AcpiTables/Madt.aslc
+++ b/edk2/OvmfPkg/AcpiTables/Madt.aslc
@@ -67,65 +67,82 @@ typedef struct {
// Multiple APIC Description Table
//
EFI_ACPI_1_0_MULTIPLE_APIC_DESCRIPTION_TABLE Madt = {
- EFI_ACPI_1_0_APIC_SIGNATURE,
- sizeof (EFI_ACPI_1_0_MULTIPLE_APIC_DESCRIPTION_TABLE),
- EFI_ACPI_1_0_MULTIPLE_APIC_DESCRIPTION_TABLE_REVISION,
- 0x00, // Checksum will be updated at runtime
- EFI_ACPI_OEM_ID,
- EFI_ACPI_OEM_TABLE_ID,
- EFI_ACPI_OEM_REVISION,
- EFI_ACPI_CREATOR_ID,
- EFI_ACPI_CREATOR_REVISION,
-
- //
- // MADT specific fields
- //
- EFI_ACPI_LOCAL_APIC_ADDRESS,
- EFI_ACPI_1_0_MULTIPLE_APIC_FLAGS,
+ {
+ {
+ EFI_ACPI_1_0_APIC_SIGNATURE,
+ sizeof (EFI_ACPI_1_0_MULTIPLE_APIC_DESCRIPTION_TABLE),
+ EFI_ACPI_1_0_MULTIPLE_APIC_DESCRIPTION_TABLE_REVISION,
+ 0x00, // Checksum will be updated at runtime
+ {EFI_ACPI_OEM_ID},
+ EFI_ACPI_OEM_TABLE_ID,
+ EFI_ACPI_OEM_REVISION,
+ EFI_ACPI_CREATOR_ID,
+ EFI_ACPI_CREATOR_REVISION
+ },
+
+ //
+ // MADT specific fields
+ //
+ EFI_ACPI_LOCAL_APIC_ADDRESS,
+ EFI_ACPI_1_0_MULTIPLE_APIC_FLAGS,
+ },
//
// Processor Local APIC Structure
//
-
- EFI_ACPI_1_0_PROCESSOR_LOCAL_APIC, // Type
- sizeof (EFI_ACPI_1_0_PROCESSOR_LOCAL_APIC_STRUCTURE), // Length
- 0x00, // Processor ID
- 0x00, // Local APIC ID
- 0x00000001, // Flags - Enabled by default
+ {
+ {
+ EFI_ACPI_1_0_PROCESSOR_LOCAL_APIC, // Type
+ sizeof (EFI_ACPI_1_0_PROCESSOR_LOCAL_APIC_STRUCTURE), // Length
+ 0x00, // Processor ID
+ 0x00, // Local APIC ID
+ 0x00000001 // Flags - Enabled by default
+ }
+ },
//
// Interrupt Source Override Structure
//
- //
- // IRQ0=>IRQ2 Interrupt Source Override Structure
- //
- EFI_ACPI_1_0_INTERRUPT_SOURCE_OVERRIDE, // Type
- sizeof (EFI_ACPI_1_0_INTERRUPT_SOURCE_OVERRIDE_STRUCTURE),// Length
- 0x00, // Bus - ISA
- 0x00, // Source - IRQ0
- 0x00000002, // Global System Interrupt - IRQ2
- 0x0000, // Flags - Conforms to specifications of the bus
-
- //
- // ISO (SCI Active High) Interrupt Source Override Structure
- //
- EFI_ACPI_1_0_INTERRUPT_SOURCE_OVERRIDE, // Type
- sizeof (EFI_ACPI_1_0_INTERRUPT_SOURCE_OVERRIDE_STRUCTURE),// Length
- 0x00, // Bus - ISA
- 0x09, // Source - IRQ0
- 0x00000009, // Global System Interrupt - IRQ2
- 0x000D, // Flags - Level-tiggered, Active High
+ {
+ {
+ //
+ // IRQ0=>IRQ2 Interrupt Source Override Structure
+ //
+ EFI_ACPI_1_0_INTERRUPT_SOURCE_OVERRIDE, // Type
+ sizeof (EFI_ACPI_1_0_INTERRUPT_SOURCE_OVERRIDE_STRUCTURE),// Length
+ 0x00, // Bus - ISA
+ 0x00, // Source - IRQ0
+ 0x00000002, // Global System Interrupt - IRQ2
+ 0x0000 // Flags - Conforms to specifications of the bus
+ },
+
+ {
+ //
+ // ISO (SCI Active High) Interrupt Source Override Structure
+ //
+ EFI_ACPI_1_0_INTERRUPT_SOURCE_OVERRIDE, // Type
+ sizeof (EFI_ACPI_1_0_INTERRUPT_SOURCE_OVERRIDE_STRUCTURE),// Length
+ 0x00, // Bus - ISA
+ 0x09, // Source - IRQ0
+ 0x00000009, // Global System Interrupt - IRQ2
+ 0x000D // Flags - Level-tiggered, Active High
+ }
+ },
//
// IO APIC Structure
//
- EFI_ACPI_1_0_IO_APIC, // Type
- sizeof (EFI_ACPI_1_0_IO_APIC_STRUCTURE), // Length
- 0x02, // IO APIC ID
- EFI_ACPI_RESERVED_BYTE, // Reserved
- 0xFEC00000, // IO APIC Address (physical)
- 0x00000000 // Global System Interrupt Base
+ {
+ {
+ EFI_ACPI_1_0_IO_APIC, // Type
+ sizeof (EFI_ACPI_1_0_IO_APIC_STRUCTURE), // Length
+ 0x02, // IO APIC ID
+ EFI_ACPI_RESERVED_BYTE, // Reserved
+ 0xFEC00000, // IO APIC Address (physical)
+ 0x00000000 // Global System Interrupt Base
+ }
+ },
};
diff --git a/edk2/OvmfPkg/EmuVariableFvbRuntimeDxe/Fvb.c b/edk2/OvmfPkg/EmuVariableFvbRuntimeDxe/Fvb.c
index c1f46a7d9..72efba091 100644
--- a/edk2/OvmfPkg/EmuVariableFvbRuntimeDxe/Fvb.c
+++ b/edk2/OvmfPkg/EmuVariableFvbRuntimeDxe/Fvb.c
@@ -655,14 +655,17 @@ InitializeFvAndVariableStoreHeaders (
0,
// UINT8 Reserved[1];
- 0,
+ {0},
// UINT8 Revision;
EFI_FVH_REVISION,
// EFI_FV_BLOCK_MAP_ENTRY BlockMap[1];
- { 2, // UINT32 NumBlocks;
- EMU_FVB_BLOCK_SIZE // UINT32 Length;
+ {
+ {
+ 2, // UINT32 NumBlocks;
+ EMU_FVB_BLOCK_SIZE // UINT32 Length;
+ }
}
},
// EFI_FV_BLOCK_MAP_ENTRY EndBlockMap;
@@ -721,14 +724,17 @@ InitializeFvAndVariableStoreHeaders (
0,
// UINT8 Reserved[1];
- 0,
+ {0},
// UINT8 Revision;
EFI_FVH_REVISION,
// EFI_FV_BLOCK_MAP_ENTRY BlockMap[1];
- { 2, // UINT32 NumBlocks;
- EMU_FVB_BLOCK_SIZE // UINT32 Length;
+ {
+ {
+ 2, // UINT32 NumBlocks;
+ EMU_FVB_BLOCK_SIZE // UINT32 Length;
+ }
}
},
// EFI_FV_BLOCK_MAP_ENTRY EndBlockMap;
diff --git a/edk2/OvmfPkg/Include/IndustryStandard/Virtio.h b/edk2/OvmfPkg/Include/IndustryStandard/Virtio.h
new file mode 100644
index 000000000..05c658fa5
--- /dev/null
+++ b/edk2/OvmfPkg/Include/IndustryStandard/Virtio.h
@@ -0,0 +1,131 @@
+/** @file
+
+ Generic type and macro definitions corresponding to the virtio-0.9.5
+ specification.
+
+ Copyright (C) 2012, Red Hat, Inc.
+
+ This program and the accompanying materials are licensed and made available
+ under the terms and conditions of the BSD License which accompanies this
+ distribution. The full text of the license may be found at
+ http://opensource.org/licenses/bsd-license.php
+
+ THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, WITHOUT
+ WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+
+**/
+
+#ifndef _VIRTIO_H_
+#define _VIRTIO_H_
+
+#include <Base.h>
+
+
+//
+// Data in the communication area is defined as packed and accessed as
+// volatile.
+//
+// Some structures contain arrays with dynamically determined size. In such
+// cases the array and its sibling fields are replaced with pointers.
+//
+// All indices (variables and fields named *Idx) are free-running and wrap
+// around after 0xFFFF. The queue size reported by the host is always an
+// integral power of 2, not greater than 32768. Actual array indices are
+// consistently calculated by taking the remainder of a given Idx object modulo
+// QueueSize. Since 0x10000 is an integral multiple of the QueueSize, UINT16
+// wraparound is a correct wraparound modulo QueueSize too (it doesn't offset
+// the remainder class).
+//
+// virtio-0.9.5, 2.3.4 Available Ring
+//
+#define VRING_AVAIL_F_NO_INTERRUPT BIT0
+
+typedef struct {
+ volatile UINT16 *Flags;
+ volatile UINT16 *Idx;
+
+ volatile UINT16 *Ring; // QueueSize elements
+ volatile UINT16 *UsedEvent; // unused as per negotiation
+} VRING_AVAIL;
+
+
+//
+// virtio-0.9.5, 2.3.5 Used Ring
+//
+#define VRING_USED_F_NO_NOTIFY BIT0
+
+#pragma pack(1)
+typedef struct {
+ UINT32 Id;
+ UINT32 Len;
+} VRING_USED_ELEM;
+#pragma pack()
+
+typedef struct {
+ volatile UINT16 *Flags;
+ volatile UINT16 *Idx;
+ volatile VRING_USED_ELEM *UsedElem; // QueueSize elements
+ volatile UINT16 *AvailEvent; // unused as per negotiation
+} VRING_USED;
+
+
+//
+// virtio-0.9.5, 2.3.2 Descriptor Table
+//
+#define VRING_DESC_F_NEXT BIT0 // more descriptors in this request
+#define VRING_DESC_F_WRITE BIT1 // buffer to be written *by the host*
+#define VRING_DESC_F_INDIRECT BIT2 // unused
+
+#pragma pack(1)
+typedef struct {
+ UINT64 Addr;
+ UINT32 Len;
+ UINT16 Flags;
+ UINT16 Next;
+} VRING_DESC;
+#pragma pack()
+
+typedef struct {
+ UINTN NumPages;
+ VOID *Base; // deallocate only this field
+ volatile VRING_DESC *Desc; // QueueSize elements
+ VRING_AVAIL Avail;
+ VRING_USED Used;
+ UINT16 QueueSize;
+} VRING;
+
+
+//
+// virtio-0.9.5, 2.2.2 Virtio Header -- no MSI-X
+//
+#pragma pack(1)
+typedef struct {
+ UINT32 VhdrDeviceFeatureBits;
+ UINT32 VhdrGuestFeatureBits;
+ UINT32 VhdrQueueAddress;
+ UINT16 VhdrQueueSize;
+ UINT16 VhdrQueueSelect;
+ UINT16 VhdrQueueNotify;
+ UINT8 VhdrDeviceStatus;
+ UINT8 VhdrISR;
+} VIRTIO_HDR;
+#pragma pack()
+
+
+//
+// virtio-0.9.5, 2.2.2.1 Device Status
+//
+#define VSTAT_ACK BIT0
+#define VSTAT_DRIVER BIT1
+#define VSTAT_DRIVER_OK BIT2
+#define VSTAT_FAILED BIT7
+
+//
+// virtio-0.9.5, Appendix B: Reserved (Device-Independent) Feature Bits
+//
+#define VIRTIO_F_NOTIFY_ON_EMPTY BIT24
+#define VIRTIO_F_RING_INDIRECT_DESC BIT28
+#define VIRTIO_F_RING_EVENT_IDX BIT29
+
+
+#endif // _VIRTIO_H_
diff --git a/edk2/OvmfPkg/Include/IndustryStandard/VirtioBlk.h b/edk2/OvmfPkg/Include/IndustryStandard/VirtioBlk.h
new file mode 100644
index 000000000..b71f224b6
--- /dev/null
+++ b/edk2/OvmfPkg/Include/IndustryStandard/VirtioBlk.h
@@ -0,0 +1,80 @@
+/** @file
+
+ Virtio Block Device specific type and macro definitions corresponding to the
+ virtio-0.9.5 specification.
+
+ Copyright (C) 2012, Red Hat, Inc.
+
+ This program and the accompanying materials are licensed and made available
+ under the terms and conditions of the BSD License which accompanies this
+ distribution. The full text of the license may be found at
+ http://opensource.org/licenses/bsd-license.php
+
+ THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, WITHOUT
+ WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+
+**/
+
+#ifndef _VIRTIO_BLK_H_
+#define _VIRTIO_BLK_H_
+
+#include <IndustryStandard/Virtio.h>
+
+
+//
+// virtio-0.9.5, Appendix D: Block Device
+//
+#pragma pack(1)
+typedef struct {
+ VIRTIO_HDR Generic;
+ UINT64 VhdrCapacity;
+ UINT32 VhdrSizeMax;
+ UINT32 VhdrSegMax;
+ UINT16 VhdrCylinders;
+ UINT8 VhdrHeads;
+ UINT8 VhdrSectors;
+ UINT32 VhdrBlkSize;
+} VBLK_HDR;
+#pragma pack()
+
+#define OFFSET_OF_VBLK(Field) OFFSET_OF (VBLK_HDR, Field)
+#define SIZE_OF_VBLK(Field) (sizeof ((VBLK_HDR *) 0)->Field)
+
+#define VIRTIO_BLK_F_BARRIER BIT0
+#define VIRTIO_BLK_F_SIZE_MAX BIT1
+#define VIRTIO_BLK_F_SEG_MAX BIT2
+#define VIRTIO_BLK_F_GEOMETRY BIT4
+#define VIRTIO_BLK_F_RO BIT5
+#define VIRTIO_BLK_F_BLK_SIZE BIT6 // treated as "logical block size" in
+ // practice; actual host side implementation
+ // negotiates "optimal" block size
+ // separately
+#define VIRTIO_BLK_F_SCSI BIT7
+#define VIRTIO_BLK_F_FLUSH BIT9 // identical to "write cache enabled"
+
+//
+// We keep the status byte separate from the rest of the virtio-blk request
+// header. See description of historical scattering at the end of Appendix D:
+// we're going to put the status byte in a separate VRING_DESC.
+//
+#pragma pack(1)
+typedef struct {
+ UINT32 Type;
+ UINT32 IoPrio;
+ UINT64 Sector;
+} VIRTIO_BLK_REQ;
+#pragma pack()
+
+#define VIRTIO_BLK_T_IN 0x00000000
+#define VIRTIO_BLK_T_OUT 0x00000001
+#define VIRTIO_BLK_T_SCSI_CMD 0x00000002
+#define VIRTIO_BLK_T_SCSI_CMD_OUT 0x00000003
+#define VIRTIO_BLK_T_FLUSH 0x00000004
+#define VIRTIO_BLK_T_FLUSH_OUT 0x00000005
+#define VIRTIO_BLK_T_BARRIER BIT31
+
+#define VIRTIO_BLK_S_OK 0x00
+#define VIRTIO_BLK_S_IOERR 0x01
+#define VIRTIO_BLK_S_UNSUPP 0x02
+
+#endif // _VIRTIO_BLK_H_
diff --git a/edk2/OvmfPkg/Include/IndustryStandard/VirtioScsi.h b/edk2/OvmfPkg/Include/IndustryStandard/VirtioScsi.h
new file mode 100644
index 000000000..59ce97e07
--- /dev/null
+++ b/edk2/OvmfPkg/Include/IndustryStandard/VirtioScsi.h
@@ -0,0 +1,100 @@
+/** @file
+
+ Virtio SCSI Host Device specific type and macro definitions corresponding to
+ the virtio-0.9.5 specification.
+
+ Copyright (C) 2012, Red Hat, Inc.
+
+ This program and the accompanying materials are licensed and made available
+ under the terms and conditions of the BSD License which accompanies this
+ distribution. The full text of the license may be found at
+ http://opensource.org/licenses/bsd-license.php
+
+ THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, WITHOUT
+ WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+
+**/
+
+#ifndef _VIRTIO_SCSI_H_
+#define _VIRTIO_SCSI_H_
+
+#include <IndustryStandard/Virtio.h>
+
+
+//
+// virtio-0.9.5, Appendix I: SCSI Host Device
+//
+#pragma pack(1)
+typedef struct {
+ VIRTIO_HDR Generic;
+ UINT32 VhdrNumQueues;
+ UINT32 VhdrSegMax;
+ UINT32 VhdrMaxSectors;
+ UINT32 VhdrCmdPerLun;
+ UINT32 VhdrEventInfoSize;
+ UINT32 VhdrSenseSize;
+ UINT32 VhdrCdbSize;
+ UINT16 VhdrMaxChannel;
+ UINT16 VhdrMaxTarget;
+ UINT32 VhdrMaxLun;
+} VSCSI_HDR;
+#pragma pack()
+
+#define OFFSET_OF_VSCSI(Field) OFFSET_OF (VSCSI_HDR, Field)
+#define SIZE_OF_VSCSI(Field) (sizeof ((VSCSI_HDR *) 0)->Field)
+
+#define VIRTIO_SCSI_F_INOUT BIT0
+#define VIRTIO_SCSI_F_HOTPLUG BIT1
+
+//
+// We expect these maximum sizes from the host. Also we force the CdbLength and
+// SenseDataLength parameters of EFI_EXT_SCSI_PASS_THRU_PROTOCOL.PassThru() not
+// to exceed these limits. See UEFI 2.3.1 errata C 14.7.
+//
+#define VIRTIO_SCSI_CDB_SIZE 32
+#define VIRTIO_SCSI_SENSE_SIZE 96
+
+//
+// We pass the dynamically sized buffers ("dataout", "datain") in separate ring
+// descriptors.
+//
+#pragma pack(1)
+typedef struct {
+ UINT8 Lun[8];
+ UINT64 Id;
+ UINT8 TaskAttr;
+ UINT8 Prio;
+ UINT8 Crn;
+ UINT8 Cdb[VIRTIO_SCSI_CDB_SIZE];
+} VIRTIO_SCSI_REQ;
+
+typedef struct {
+ UINT32 SenseLen;
+ UINT32 Residual;
+ UINT16 StatusQualifier;
+ UINT8 Status;
+ UINT8 Response;
+ UINT8 Sense[VIRTIO_SCSI_SENSE_SIZE];
+} VIRTIO_SCSI_RESP;
+#pragma pack()
+
+//
+// selector of first virtio queue usable for request transfer
+//
+#define VIRTIO_SCSI_REQUEST_QUEUE 2
+
+//
+// host response codes
+//
+#define VIRTIO_SCSI_S_OK 0
+#define VIRTIO_SCSI_S_OVERRUN 1
+#define VIRTIO_SCSI_S_ABORTED 2
+#define VIRTIO_SCSI_S_BAD_TARGET 3
+#define VIRTIO_SCSI_S_RESET 4
+#define VIRTIO_SCSI_S_BUSY 5
+#define VIRTIO_SCSI_S_TRANSPORT_FAILURE 6
+#define VIRTIO_SCSI_S_TARGET_FAILURE 7
+#define VIRTIO_SCSI_S_NEXUS_FAILURE 8
+#define VIRTIO_SCSI_S_FAILURE 9
+
+#endif // _VIRTIO_SCSI_H_
diff --git a/edk2/OvmfPkg/Include/Library/VirtioLib.h b/edk2/OvmfPkg/Include/Library/VirtioLib.h
new file mode 100644
index 000000000..448dd2b57
--- /dev/null
+++ b/edk2/OvmfPkg/Include/Library/VirtioLib.h
@@ -0,0 +1,251 @@
+/** @file
+
+ Declarations of utility functions used by virtio device drivers.
+
+ Copyright (C) 2012, Red Hat, Inc.
+
+ This program and the accompanying materials are licensed and made available
+ under the terms and conditions of the BSD License which accompanies this
+ distribution. The full text of the license may be found at
+ http://opensource.org/licenses/bsd-license.php
+
+ THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, WITHOUT
+ WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+
+**/
+
+#ifndef _VIRTIO_LIB_H_
+#define _VIRTIO_LIB_H_
+
+#include <Protocol/PciIo.h>
+#include <IndustryStandard/Virtio.h>
+
+/**
+
+ Write a word into Region 0 of the device specified by PciIo.
+
+ Region 0 must be an iomem region. This is an internal function for the
+ driver-specific VIRTIO_CFG_WRITE() macros.
+
+ @param[in] PciIo Target PCI device.
+
+ @param[in] FieldOffset Destination offset.
+
+ @param[in] FieldSize Destination field size, must be in { 1, 2, 4, 8 }.
+
+ @param[in] Value Little endian value to write, converted to UINT64.
+ The least significant FieldSize bytes will be used.
+
+
+ @return Status code returned by PciIo->Io.Write().
+
+**/
+EFI_STATUS
+EFIAPI
+VirtioWrite (
+ IN EFI_PCI_IO_PROTOCOL *PciIo,
+ IN UINTN FieldOffset,
+ IN UINTN FieldSize,
+ IN UINT64 Value
+ );
+
+
+/**
+
+ Read a word from Region 0 of the device specified by PciIo.
+
+ Region 0 must be an iomem region. This is an internal function for the
+ driver-specific VIRTIO_CFG_READ() macros.
+
+ @param[in] PciIo Source PCI device.
+
+ @param[in] FieldOffset Source offset.
+
+ @param[in] FieldSize Source field size, must be in { 1, 2, 4, 8 }.
+
+ @param[in] BufferSize Number of bytes available in the target buffer. Must
+ equal FieldSize.
+
+ @param[out] Buffer Target buffer.
+
+
+ @return Status code returned by PciIo->Io.Read().
+
+**/
+EFI_STATUS
+EFIAPI
+VirtioRead (
+ IN EFI_PCI_IO_PROTOCOL *PciIo,
+ IN UINTN FieldOffset,
+ IN UINTN FieldSize,
+ IN UINTN BufferSize,
+ OUT VOID *Buffer
+ );
+
+
+/**
+
+ Configure a virtio ring.
+
+ This function sets up internal storage (the guest-host communication area)
+ and lays out several "navigation" (ie. no-ownership) pointers to parts of
+ that storage.
+
+ Relevant sections from the virtio-0.9.5 spec:
+ - 1.1 Virtqueues,
+ - 2.3 Virtqueue Configuration.
+
+ @param[in] The number of descriptors to allocate for the
+ virtio ring, as requested by the host.
+
+ @param[out] Ring The virtio ring to set up.
+
+ @retval EFI_OUT_OF_RESOURCES AllocatePages() failed to allocate contiguous
+ pages for the requested QueueSize. Fields of
+ Ring have indeterminate value.
+
+ @retval EFI_SUCCESS Allocation and setup successful. Ring->Base
+ (and nothing else) is responsible for
+ deallocation.
+
+**/
+EFI_STATUS
+EFIAPI
+VirtioRingInit (
+ IN UINT16 QueueSize,
+ OUT VRING *Ring
+ );
+
+
+/**
+
+ Tear down the internal resources of a configured virtio ring.
+
+ The caller is responsible to stop the host from using this ring before
+ invoking this function: the VSTAT_DRIVER_OK bit must be clear in
+ VhdrDeviceStatus.
+
+ @param[out] Ring The virtio ring to clean up.
+
+**/
+VOID
+EFIAPI
+VirtioRingUninit (
+ IN OUT VRING *Ring
+ );
+
+
+//
+// Internal use structure for tracking the submission of a multi-descriptor
+// request.
+//
+typedef struct {
+ UINT16 HeadIdx;
+ UINT16 NextAvailIdx;
+} DESC_INDICES;
+
+
+/**
+
+ Turn off interrupt notifications from the host, and prepare for appending
+ multiple descriptors to the virtio ring.
+
+ The calling driver must be in VSTAT_DRIVER_OK state.
+
+ @param[in out] Ring The virtio ring we intend to append descriptors to.
+
+ @param[out] Indices The DESC_INDICES structure to initialize.
+
+**/
+VOID
+EFIAPI
+VirtioPrepare (
+ IN OUT VRING *Ring,
+ OUT DESC_INDICES *Indices
+ );
+
+
+/**
+
+ Append a contiguous buffer for transmission / reception via the virtio ring.
+
+ This function implements the following sections 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
+ request submission. It is the calling driver's responsibility to verify the
+ ring size in advance.
+
+ 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] 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.
+
+ 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.
+
+**/
+VOID
+EFIAPI
+VirtioAppendDesc (
+ IN OUT VRING *Ring,
+ IN UINTN BufferPhysAddr,
+ IN UINT32 BufferSize,
+ IN UINT16 Flags,
+ IN OUT DESC_INDICES *Indices
+ );
+
+
+/**
+
+ Notify the host about appended descriptors and wait until it processes the
+ last one (ie. all of them).
+
+ @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] Indices The function waits until the host processes
+ descriptors up to Indices->NextAvailIdx.
+
+
+ @return Error code from VirtioWrite() if it fails.
+
+ @retval EFI_SUCCESS Otherwise, the host processed all descriptors.
+
+**/
+EFI_STATUS
+EFIAPI
+VirtioFlush (
+ IN EFI_PCI_IO_PROTOCOL *PciIo,
+ IN UINT16 VirtQueueId,
+ IN OUT VRING *Ring,
+ IN DESC_INDICES *Indices
+ );
+
+#endif // _VIRTIO_LIB_H_
diff --git a/edk2/OvmfPkg/Library/AcpiTimerLib/AcpiTimerLib.c b/edk2/OvmfPkg/Library/AcpiTimerLib/AcpiTimerLib.c
index 201ef48d2..c6441281b 100644
--- a/edk2/OvmfPkg/Library/AcpiTimerLib/AcpiTimerLib.c
+++ b/edk2/OvmfPkg/Library/AcpiTimerLib/AcpiTimerLib.c
@@ -1,7 +1,7 @@
/** @file
ACPI Timer implements one instance of Timer Library.
- Copyright (c) 2008 - 2011, Intel Corporation. All rights reserved.<BR>
+ Copyright (c) 2008 - 2012, Intel Corporation. All rights reserved.<BR>
Copyright (c) 2011, Andrei Warkentin <andreiw@motorola.com>
This program and the accompanying materials are
@@ -22,15 +22,42 @@
#include <Library/DebugLib.h>
#include <Library/PcdLib.h>
#include <IndustryStandard/Pci22.h>
+#include <IndustryStandard/Acpi.h>
//
-// PIIX4 Power Management Base Address
+// PCI Location of PIIX4 Power Management PCI Configuration Registers
//
-STATIC UINT32 mPmba;
+#define PIIX4_POWER_MANAGEMENT_BUS 0x00
+#define PIIX4_POWER_MANAGEMENT_DEVICE 0x01
+#define PIIX4_POWER_MANAGEMENT_FUNCTION 0x03
-#define PCI_BAR_IO 0x1
-#define ACPI_TIMER_FREQUENCY 3579545
-#define ACPI_TIMER_COUNT_SIZE 0x01000000
+//
+// Macro to access PIIX4 Power Management PCI Configuration Registers
+//
+#define PIIX4_PCI_POWER_MANAGEMENT_REGISTER(Register) \
+ PCI_LIB_ADDRESS ( \
+ PIIX4_POWER_MANAGEMENT_BUS, \
+ PIIX4_POWER_MANAGEMENT_DEVICE, \
+ PIIX4_POWER_MANAGEMENT_FUNCTION, \
+ Register \
+ )
+
+//
+// PIIX4 Power Management PCI Configuration Registers
+//
+#define PMBA PIIX4_PCI_POWER_MANAGEMENT_REGISTER (0x40)
+#define PMBA_RTE BIT0
+#define PMREGMISC PIIX4_PCI_POWER_MANAGEMENT_REGISTER (0x80)
+#define PMIOSE BIT0
+
+//
+// The ACPI Time in the PIIX4 is a 24-bit counter
+//
+#define ACPI_TIMER_COUNT_SIZE BIT24
+
+//
+// Offset in the PIIX4 Power Management Base Address to the ACPI Timer
+//
#define ACPI_TIMER_OFFSET 0x8
/**
@@ -48,30 +75,22 @@ AcpiTimerLibConstructor (
VOID
)
{
- UINT8 Device;
-
- Device = 1;
- // Device = 7;
-
- if (PciRead8 (PCI_LIB_ADDRESS (0,Device,3,0x80)) & 1) {
- mPmba = PciRead32 (PCI_LIB_ADDRESS (0,Device,3,0x40));
- ASSERT (mPmba & PCI_BAR_IO);
- mPmba &= ~PCI_BAR_IO;
- } else {
- mPmba = PcdGet16 (PcdAcpiPmBaseAddress);
-
- PciAndThenOr32 (PCI_LIB_ADDRESS (0,Device,3,0x40),
- (UINT32) ~0xFFC0, mPmba);
- PciOr8 (
- PCI_LIB_ADDRESS (0, Device, 3, PCI_COMMAND_OFFSET),
- EFI_PCI_COMMAND_IO_SPACE
- );
- }
-
//
- // ACPI Timer enable is in Bus 0, Device ?, Function 3
+ // Check to see if the PIIX4 Power Management Base Address is already enabled
//
- PciOr8 (PCI_LIB_ADDRESS (0,Device,3,0x80), 0x01);
+ if ((PciRead8 (PMREGMISC) & PMIOSE) == 0) {
+ //
+ // If the PIIX4 Power Management Base Address is not programmed,
+ // then program the PIIX4 Power Management Base Address from a PCD.
+ //
+ PciAndThenOr32 (PMBA, (UINT32)(~0x0000FFC0), PcdGet16 (PcdAcpiPmBaseAddress));
+
+ //
+ // Enable PMBA I/O port decodes in PMREGMISC
+ //
+ PciOr8 (PMREGMISC, PMIOSE);
+ }
+
return RETURN_SUCCESS;
}
@@ -83,13 +102,15 @@ AcpiTimerLibConstructor (
@return The tick counter read.
**/
-STATIC
UINT32
InternalAcpiGetTimerTick (
VOID
)
{
- return IoRead32 (mPmba + ACPI_TIMER_OFFSET);
+ //
+ // Read PMBA to read and return the current ACPI timer value.
+ //
+ return IoRead32 ((PciRead32 (PMBA) & ~PMBA_RTE) + ACPI_TIMER_OFFSET);
}
/**
@@ -101,7 +122,6 @@ InternalAcpiGetTimerTick (
@param Delay A period of time to delay in ticks.
**/
-STATIC
VOID
InternalAcpiDelay (
IN UINT32 Delay
diff --git a/edk2/OvmfPkg/Library/PlatformBdsLib/QemuBootOrder.c b/edk2/OvmfPkg/Library/PlatformBdsLib/QemuBootOrder.c
index 2273d829c..d2d60c389 100644
--- a/edk2/OvmfPkg/Library/PlatformBdsLib/QemuBootOrder.c
+++ b/edk2/OvmfPkg/Library/PlatformBdsLib/QemuBootOrder.c
@@ -31,9 +31,10 @@
/**
- Number of nodes in OpenFirmware device paths that is required and examined.
+ Numbers of nodes in OpenFirmware device paths that are required and examined.
**/
-#define FIXED_OFW_NODES 4
+#define REQUIRED_OFW_NODES 2
+#define EXAMINED_OFW_NODES 4
/**
@@ -118,7 +119,7 @@ SubstringEq (
++Chr;
}
- return (Pos == Substring.Len && *Chr == '\0');
+ return (BOOLEAN)(Pos == Substring.Len && *Chr == '\0');
}
@@ -497,7 +498,7 @@ TranslateOfwNodes (
//
// Get PCI device and optional PCI function. Assume a single PCI root.
//
- if (NumNodes < FIXED_OFW_NODES ||
+ if (NumNodes < REQUIRED_OFW_NODES ||
!SubstringEq (OfwNode[0].DriverName, "pci")
) {
return RETURN_UNSUPPORTED;
@@ -513,7 +514,8 @@ TranslateOfwNodes (
return RETURN_UNSUPPORTED;
}
- if (SubstringEq (OfwNode[1].DriverName, "ide") &&
+ if (NumNodes >= 4 &&
+ SubstringEq (OfwNode[1].DriverName, "ide") &&
SubstringEq (OfwNode[2].DriverName, "drive") &&
SubstringEq (OfwNode[3].DriverName, "disk")
) {
@@ -562,7 +564,8 @@ TranslateOfwNodes (
Secondary ? "Secondary" : "Primary",
Slave ? "Slave" : "Master"
);
- } else if (SubstringEq (OfwNode[1].DriverName, "isa") &&
+ } else if (NumNodes >= 4 &&
+ SubstringEq (OfwNode[1].DriverName, "isa") &&
SubstringEq (OfwNode[2].DriverName, "fdc") &&
SubstringEq (OfwNode[3].DriverName, "floppy")
) {
@@ -603,9 +606,80 @@ TranslateOfwNodes (
PciDevFun[1],
AcpiUid
);
- } else {
- return RETURN_UNSUPPORTED;
- }
+ } else if (NumNodes >= 3 &&
+ SubstringEq (OfwNode[1].DriverName, "scsi") &&
+ SubstringEq (OfwNode[2].DriverName, "disk")
+ ) {
+ //
+ // OpenFirmware device path (virtio-blk disk):
+ //
+ // /pci@i0cf8/scsi@6[,3]/disk@0,0
+ // ^ ^ ^ ^ ^
+ // | | | fixed
+ // | | PCI function corresponding to disk (optional)
+ // | PCI slot holding disk
+ // PCI root at system bus port, PIO
+ //
+ // UEFI device path prefix:
+ //
+ // PciRoot(0x0)/Pci(0x6,0x0)/HD( -- if PCI function is 0 or absent
+ // PciRoot(0x0)/Pci(0x6,0x3)/HD( -- if PCI function is present and nonzero
+ //
+ Written = UnicodeSPrintAsciiFormat (
+ Translated,
+ *TranslatedSize * sizeof (*Translated), // BufferSize in bytes
+ "PciRoot(0x0)/Pci(0x%x,0x%x)/HD(",
+ PciDevFun[0],
+ PciDevFun[1]
+ );
+ } else if (NumNodes >= 4 &&
+ SubstringEq (OfwNode[1].DriverName, "scsi") &&
+ SubstringEq (OfwNode[2].DriverName, "channel") &&
+ SubstringEq (OfwNode[3].DriverName, "disk")
+ ) {
+ //
+ // OpenFirmware device path (virtio-scsi disk):
+ //
+ // /pci@i0cf8/scsi@7[,3]/channel@0/disk@2,3
+ // ^ ^ ^ ^ ^
+ // | | | | LUN
+ // | | | target
+ // | | channel (unused, fixed 0)
+ // | PCI slot[, function] holding SCSI controller
+ // PCI root at system bus port, PIO
+ //
+ // UEFI device path prefix:
+ //
+ // PciRoot(0x0)/Pci(0x7,0x0)/Scsi(0x2,0x3)
+ // -- if PCI function is 0 or absent
+ // PciRoot(0x0)/Pci(0x7,0x3)/Scsi(0x2,0x3)
+ // -- if PCI function is present and nonzero
+ //
+ UINT32 TargetLun[2];
+
+ TargetLun[1] = 0;
+ NumEntries = sizeof (TargetLun) / sizeof (TargetLun[0]);
+ if (ParseUnitAddressHexList (
+ OfwNode[3].UnitAddress,
+ TargetLun,
+ &NumEntries
+ ) != RETURN_SUCCESS
+ ) {
+ return RETURN_UNSUPPORTED;
+ }
+
+ Written = UnicodeSPrintAsciiFormat (
+ Translated,
+ *TranslatedSize * sizeof (*Translated), // BufferSize in bytes
+ "PciRoot(0x0)/Pci(0x%x,0x%x)/Scsi(0x%x,0x%x)",
+ PciDevFun[0],
+ PciDevFun[1],
+ TargetLun[0],
+ TargetLun[1]
+ );
+ } else {
+ return RETURN_UNSUPPORTED;
+ }
//
// There's no way to differentiate between "completely used up without
@@ -676,7 +750,7 @@ TranslateOfwPath (
{
UINTN NumNodes;
RETURN_STATUS Status;
- OFW_NODE Node[FIXED_OFW_NODES];
+ OFW_NODE Node[EXAMINED_OFW_NODES];
BOOLEAN IsFinal;
OFW_NODE Skip;
@@ -692,7 +766,7 @@ TranslateOfwPath (
++NumNodes;
Status = ParseOfwNode (
Ptr,
- (NumNodes < FIXED_OFW_NODES) ? &Node[NumNodes] : &Skip,
+ (NumNodes < EXAMINED_OFW_NODES) ? &Node[NumNodes] : &Skip,
&IsFinal
);
}
@@ -712,7 +786,7 @@ TranslateOfwPath (
Status = TranslateOfwNodes (
Node,
- NumNodes < FIXED_OFW_NODES ? NumNodes : FIXED_OFW_NODES,
+ NumNodes < EXAMINED_OFW_NODES ? NumNodes : EXAMINED_OFW_NODES,
Translated,
TranslatedSize);
switch (Status) {
@@ -782,7 +856,7 @@ Match (
//
// Is Translated a prefix of Converted?
//
- Result = (StrnCmp (Converted, Translated, TranslatedLength) == 0);
+ Result = (BOOLEAN)(StrnCmp (Converted, Translated, TranslatedLength) == 0);
DEBUG ((
DEBUG_VERBOSE,
"%a: against \"%s\": %a\n",
diff --git a/edk2/OvmfPkg/Library/VirtioLib/VirtioLib.c b/edk2/OvmfPkg/Library/VirtioLib/VirtioLib.c
new file mode 100644
index 000000000..8398c9db4
--- /dev/null
+++ b/edk2/OvmfPkg/Library/VirtioLib/VirtioLib.c
@@ -0,0 +1,452 @@
+/** @file
+
+ Utility functions used by virtio device drivers.
+
+ Copyright (C) 2012, Red Hat, Inc.
+
+ This program and the accompanying materials are licensed and made available
+ under the terms and conditions of the BSD License which accompanies this
+ distribution. The full text of the license may be found at
+ http://opensource.org/licenses/bsd-license.php
+
+ THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, WITHOUT
+ WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+
+**/
+
+#include <IndustryStandard/Pci22.h>
+#include <Library/BaseLib.h>
+#include <Library/BaseMemoryLib.h>
+#include <Library/DebugLib.h>
+#include <Library/MemoryAllocationLib.h>
+#include <Library/UefiBootServicesTableLib.h>
+
+#include <Library/VirtioLib.h>
+
+
+/**
+
+ Write a word into Region 0 of the device specified by PciIo.
+
+ Region 0 must be an iomem region. This is an internal function for the
+ driver-specific VIRTIO_CFG_WRITE() macros.
+
+ @param[in] PciIo Target PCI device.
+
+ @param[in] FieldOffset Destination offset.
+
+ @param[in] FieldSize Destination field size, must be in { 1, 2, 4, 8 }.
+
+ @param[in] Value Little endian value to write, converted to UINT64.
+ The least significant FieldSize bytes will be used.
+
+
+ @return Status code returned by PciIo->Io.Write().
+
+**/
+EFI_STATUS
+EFIAPI
+VirtioWrite (
+ IN EFI_PCI_IO_PROTOCOL *PciIo,
+ IN UINTN FieldOffset,
+ IN UINTN FieldSize,
+ IN UINT64 Value
+ )
+{
+ UINTN Count;
+ EFI_PCI_IO_PROTOCOL_WIDTH Width;
+
+ Count = 1;
+ switch (FieldSize) {
+ case 1:
+ Width = EfiPciIoWidthUint8;
+ break;
+
+ case 2:
+ Width = EfiPciIoWidthUint16;
+ break;
+
+ case 8:
+ Count = 2;
+ // fall through
+
+ case 4:
+ Width = EfiPciIoWidthUint32;
+ break;
+
+ default:
+ ASSERT (FALSE);
+ return EFI_INVALID_PARAMETER;
+ }
+
+ return PciIo->Io.Write (
+ PciIo,
+ Width,
+ PCI_BAR_IDX0,
+ FieldOffset,
+ Count,
+ &Value
+ );
+}
+
+
+/**
+
+ Read a word from Region 0 of the device specified by PciIo.
+
+ Region 0 must be an iomem region. This is an internal function for the
+ driver-specific VIRTIO_CFG_READ() macros.
+
+ @param[in] PciIo Source PCI device.
+
+ @param[in] FieldOffset Source offset.
+
+ @param[in] FieldSize Source field size, must be in { 1, 2, 4, 8 }.
+
+ @param[in] BufferSize Number of bytes available in the target buffer. Must
+ equal FieldSize.
+
+ @param[out] Buffer Target buffer.
+
+
+ @return Status code returned by PciIo->Io.Read().
+
+**/
+EFI_STATUS
+EFIAPI
+VirtioRead (
+ IN EFI_PCI_IO_PROTOCOL *PciIo,
+ IN UINTN FieldOffset,
+ IN UINTN FieldSize,
+ IN UINTN BufferSize,
+ OUT VOID *Buffer
+ )
+{
+ UINTN Count;
+ EFI_PCI_IO_PROTOCOL_WIDTH Width;
+
+ ASSERT (FieldSize == BufferSize);
+
+ Count = 1;
+ switch (FieldSize) {
+ case 1:
+ Width = EfiPciIoWidthUint8;
+ break;
+
+ case 2:
+ Width = EfiPciIoWidthUint16;
+ break;
+
+ case 8:
+ Count = 2;
+ // fall through
+
+ case 4:
+ Width = EfiPciIoWidthUint32;
+ break;
+
+ default:
+ ASSERT (FALSE);
+ return EFI_INVALID_PARAMETER;
+ }
+
+ return PciIo->Io.Read (
+ PciIo,
+ Width,
+ PCI_BAR_IDX0,
+ FieldOffset,
+ Count,
+ Buffer
+ );
+}
+
+
+/**
+
+ Configure a virtio ring.
+
+ This function sets up internal storage (the guest-host communication area)
+ and lays out several "navigation" (ie. no-ownership) pointers to parts of
+ that storage.
+
+ Relevant sections from the virtio-0.9.5 spec:
+ - 1.1 Virtqueues,
+ - 2.3 Virtqueue Configuration.
+
+ @param[in] The number of descriptors to allocate for the
+ virtio ring, as requested by the host.
+
+ @param[out] Ring The virtio ring to set up.
+
+ @retval EFI_OUT_OF_RESOURCES AllocatePages() failed to allocate contiguous
+ pages for the requested QueueSize. Fields of
+ Ring have indeterminate value.
+
+ @retval EFI_SUCCESS Allocation and setup successful. Ring->Base
+ (and nothing else) is responsible for
+ deallocation.
+
+**/
+EFI_STATUS
+EFIAPI
+VirtioRingInit (
+ IN UINT16 QueueSize,
+ OUT VRING *Ring
+ )
+{
+ UINTN RingSize;
+ volatile UINT8 *RingPagesPtr;
+
+ RingSize = ALIGN_VALUE (
+ sizeof *Ring->Desc * QueueSize +
+ sizeof *Ring->Avail.Flags +
+ sizeof *Ring->Avail.Idx +
+ sizeof *Ring->Avail.Ring * QueueSize +
+ sizeof *Ring->Avail.UsedEvent,
+ EFI_PAGE_SIZE);
+
+ RingSize += ALIGN_VALUE (
+ sizeof *Ring->Used.Flags +
+ sizeof *Ring->Used.Idx +
+ sizeof *Ring->Used.UsedElem * QueueSize +
+ sizeof *Ring->Used.AvailEvent,
+ EFI_PAGE_SIZE);
+
+ Ring->NumPages = EFI_SIZE_TO_PAGES (RingSize);
+ Ring->Base = AllocatePages (Ring->NumPages);
+ if (Ring->Base == NULL) {
+ return EFI_OUT_OF_RESOURCES;
+ }
+ SetMem (Ring->Base, RingSize, 0x00);
+ RingPagesPtr = Ring->Base;
+
+ Ring->Desc = (volatile VOID *) RingPagesPtr;
+ RingPagesPtr += sizeof *Ring->Desc * QueueSize;
+
+ Ring->Avail.Flags = (volatile VOID *) RingPagesPtr;
+ RingPagesPtr += sizeof *Ring->Avail.Flags;
+
+ Ring->Avail.Idx = (volatile VOID *) RingPagesPtr;
+ RingPagesPtr += sizeof *Ring->Avail.Idx;
+
+ Ring->Avail.Ring = (volatile VOID *) RingPagesPtr;
+ RingPagesPtr += sizeof *Ring->Avail.Ring * QueueSize;
+
+ Ring->Avail.UsedEvent = (volatile VOID *) RingPagesPtr;
+ RingPagesPtr += sizeof *Ring->Avail.UsedEvent;
+
+ RingPagesPtr = (volatile UINT8 *) Ring->Base +
+ ALIGN_VALUE (RingPagesPtr - (volatile UINT8 *) Ring->Base,
+ EFI_PAGE_SIZE);
+
+ Ring->Used.Flags = (volatile VOID *) RingPagesPtr;
+ RingPagesPtr += sizeof *Ring->Used.Flags;
+
+ Ring->Used.Idx = (volatile VOID *) RingPagesPtr;
+ RingPagesPtr += sizeof *Ring->Used.Idx;
+
+ Ring->Used.UsedElem = (volatile VOID *) RingPagesPtr;
+ RingPagesPtr += sizeof *Ring->Used.UsedElem * QueueSize;
+
+ Ring->Used.AvailEvent = (volatile VOID *) RingPagesPtr;
+ RingPagesPtr += sizeof *Ring->Used.AvailEvent;
+
+ Ring->QueueSize = QueueSize;
+ return EFI_SUCCESS;
+}
+
+
+/**
+
+ Tear down the internal resources of a configured virtio ring.
+
+ The caller is responsible to stop the host from using this ring before
+ invoking this function: the VSTAT_DRIVER_OK bit must be clear in
+ VhdrDeviceStatus.
+
+ @param[out] Ring The virtio ring to clean up.
+
+**/
+VOID
+EFIAPI
+VirtioRingUninit (
+ IN OUT VRING *Ring
+ )
+{
+ FreePages (Ring->Base, Ring->NumPages);
+ SetMem (Ring, sizeof *Ring, 0x00);
+}
+
+
+/**
+
+ Turn off interrupt notifications from the host, and prepare for appending
+ multiple descriptors to the virtio ring.
+
+ The calling driver must be in VSTAT_DRIVER_OK state.
+
+ @param[in out] Ring The virtio ring we intend to append descriptors to.
+
+ @param[out] Indices The DESC_INDICES structure to initialize.
+
+**/
+VOID
+EFIAPI
+VirtioPrepare (
+ IN OUT VRING *Ring,
+ OUT DESC_INDICES *Indices
+ )
+{
+ //
+ // Prepare for virtio-0.9.5, 2.4.2 Receiving Used Buffers From the Device.
+ // We're going to poll the answer, the host should not send an interrupt.
+ //
+ *Ring->Avail.Flags = (UINT16) VRING_AVAIL_F_NO_INTERRUPT;
+
+ //
+ // Prepare for virtio-0.9.5, 2.4.1 Supplying Buffers to the Device.
+ //
+ Indices->HeadIdx = *Ring->Avail.Idx;
+ Indices->NextAvailIdx = Indices->HeadIdx;
+}
+
+
+/**
+
+ Append a contiguous buffer for transmission / reception via the virtio ring.
+
+ This function implements the following sections 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
+ request submission. It is the calling driver's responsibility to verify the
+ ring size in advance.
+
+ 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] 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.
+
+ 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.
+
+**/
+VOID
+EFIAPI
+VirtioAppendDesc (
+ IN OUT VRING *Ring,
+ IN UINTN BufferPhysAddr,
+ IN UINT32 BufferSize,
+ IN UINT16 Flags,
+ IN OUT DESC_INDICES *Indices
+ )
+{
+ volatile VRING_DESC *Desc;
+
+ Desc = &Ring->Desc[Indices->NextAvailIdx % 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;
+}
+
+
+/**
+
+ Notify the host about appended descriptors and wait until it processes the
+ last one (ie. all of them).
+
+ @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] Indices The function waits until the host processes
+ descriptors up to Indices->NextAvailIdx.
+
+
+ @return Error code from VirtioWrite() if it fails.
+
+ @retval EFI_SUCCESS Otherwise, the host processed all descriptors.
+
+**/
+EFI_STATUS
+EFIAPI
+VirtioFlush (
+ IN EFI_PCI_IO_PROTOCOL *PciIo,
+ IN UINT16 VirtQueueId,
+ IN OUT VRING *Ring,
+ IN DESC_INDICES *Indices
+ )
+{
+ EFI_STATUS Status;
+ UINTN PollPeriodUsecs;
+
+ //
+ // virtio-0.9.5, 2.4.1.3 Updating the Index Field
+ //
+ MemoryFence();
+ *Ring->Avail.Idx = Indices->NextAvailIdx;
+
+ //
+ // virtio-0.9.5, 2.4.1.4 Notifying the Device -- gratuitous notifications are
+ // OK.
+ //
+ MemoryFence();
+ Status = VirtioWrite (
+ PciIo,
+ OFFSET_OF (VIRTIO_HDR, VhdrQueueNotify),
+ sizeof (UINT16),
+ VirtQueueId
+ );
+ if (EFI_ERROR (Status)) {
+ return Status;
+ }
+
+ //
+ // virtio-0.9.5, 2.4.2 Receiving Used Buffers From the Device
+ // Wait until the host processes and acknowledges our descriptor chain. The
+ // condition we use for polling is greatly simplified and relies on the
+ // synchronous, lock-step progress.
+ //
+ // Keep slowing down until we reach a poll period of slightly above 1 ms.
+ //
+ PollPeriodUsecs = 1;
+ MemoryFence();
+ while (*Ring->Used.Idx != Indices->NextAvailIdx) {
+ gBS->Stall (PollPeriodUsecs); // calls AcpiTimerLib::MicroSecondDelay
+
+ if (PollPeriodUsecs < 1024) {
+ PollPeriodUsecs *= 2;
+ }
+ MemoryFence();
+ }
+
+ return EFI_SUCCESS;
+}
diff --git a/edk2/OvmfPkg/Library/VirtioLib/VirtioLib.inf b/edk2/OvmfPkg/Library/VirtioLib/VirtioLib.inf
new file mode 100644
index 000000000..fb5897a88
--- /dev/null
+++ b/edk2/OvmfPkg/Library/VirtioLib/VirtioLib.inf
@@ -0,0 +1,36 @@
+## @file
+# Library of virtio utility functions.
+#
+# Copyright (C) 2012, Red Hat, Inc.
+#
+# This program and the accompanying materials are licensed and made available
+# under the terms and conditions of the BSD License which accompanies this
+# distribution. The full text of the license may be found at
+# http://opensource.org/licenses/bsd-license.php
+#
+# THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, WITHOUT
+# WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+#
+##
+
+[Defines]
+ INF_VERSION = 0x00010005
+ BASE_NAME = VirtioLib
+ FILE_GUID = 90CED1D9-18F2-47CC-BF24-41EC29406637
+ MODULE_TYPE = UEFI_DRIVER
+ VERSION_STRING = 1.0
+ LIBRARY_CLASS = VirtioLib
+
+[Sources]
+ VirtioLib.c
+
+[Packages]
+ MdePkg/MdePkg.dec
+ OvmfPkg/OvmfPkg.dec
+
+[LibraryClasses]
+ BaseLib
+ BaseMemoryLib
+ DebugLib
+ MemoryAllocationLib
+ UefiBootServicesTableLib
diff --git a/edk2/OvmfPkg/OvmfPkg.dec b/edk2/OvmfPkg/OvmfPkg.dec
index 26600dcf4..73db6af77 100644
--- a/edk2/OvmfPkg/OvmfPkg.dec
+++ b/edk2/OvmfPkg/OvmfPkg.dec
@@ -53,6 +53,17 @@
# to PIIX4 function 3 offset 0x40-0x43 bits [15:6].
gUefiOvmfPkgTokenSpaceGuid.PcdAcpiPmBaseAddress|0xB000|UINT16|5
+ ## When VirtioScsiDxe is instantiated for a HBA, the numbers of targets and
+ # LUNs are retrieved from the host during virtio-scsi setup.
+ # MdeModulePkg/Bus/Scsi/ScsiBusDxe then scans all MaxTarget * MaxLun
+ # possible devices. This can take extremely long, for example with
+ # MaxTarget=255 and MaxLun=16383. The *inclusive* constants below limit
+ # MaxTarget and MaxLun, independently, should the host report higher values,
+ # so that scanning the number of devices given by their product is still
+ # acceptably fast.
+ gUefiOvmfPkgTokenSpaceGuid.PcdVirtioScsiMaxTargetLimit|31|UINT16|6
+ gUefiOvmfPkgTokenSpaceGuid.PcdVirtioScsiMaxLunLimit|7|UINT32|7
+
[PcdsDynamic, PcdsDynamicEx]
gUefiOvmfPkgTokenSpaceGuid.PcdEmuVariableEvent|0|UINT64|2
diff --git a/edk2/OvmfPkg/OvmfPkgIa32.dsc b/edk2/OvmfPkg/OvmfPkgIa32.dsc
index e1cf6f4e2..bd8657241 100644
--- a/edk2/OvmfPkg/OvmfPkgIa32.dsc
+++ b/edk2/OvmfPkg/OvmfPkgIa32.dsc
@@ -97,6 +97,7 @@
UefiUsbLib|MdePkg/Library/UefiUsbLib/UefiUsbLib.inf
SerializeVariablesLib|OvmfPkg/Library/SerializeVariablesLib/SerializeVariablesLib.inf
QemuFwCfgLib|OvmfPkg/Library/QemuFwCfgLib/QemuFwCfgLib.inf
+ VirtioLib|OvmfPkg/Library/VirtioLib/VirtioLib.inf
LockBoxLib|MdeModulePkg/Library/LockBoxNullLib/LockBoxNullLib.inf
!ifdef $(SOURCE_DEBUG_ENABLE)
@@ -407,6 +408,8 @@
}
OvmfPkg/BlockMmioToBlockIoDxe/BlockIo.inf
+ OvmfPkg/VirtioBlkDxe/VirtioBlk.inf
+ OvmfPkg/VirtioScsiDxe/VirtioScsi.inf
OvmfPkg/EmuVariableFvbRuntimeDxe/Fvb.inf {
<LibraryClasses>
PlatformFvbLib|OvmfPkg/Library/EmuVariableFvbLib/EmuVariableFvbLib.inf
diff --git a/edk2/OvmfPkg/OvmfPkgIa32.fdf b/edk2/OvmfPkg/OvmfPkgIa32.fdf
index f819e6b59..36c975665 100644
--- a/edk2/OvmfPkg/OvmfPkgIa32.fdf
+++ b/edk2/OvmfPkg/OvmfPkgIa32.fdf
@@ -14,6 +14,7 @@
##
################################################################################
+!ifndef $(FD_SIZE_2MB)
[FD.OVMF]
BaseAddress = 0xFFF00000
Size = 0x00100000
@@ -26,6 +27,20 @@ FV = FVMAIN_COMPACT
0x000EC000|0x14000
FV = SECFV
+!else
+[FD.OVMF]
+BaseAddress = 0xFFE00000
+Size = 0x00200000
+ErasePolarity = 1
+BlockSize = 0x1000
+NumBlocks = 0x200
+
+0x00000000|0x001CC000
+FV = FVMAIN_COMPACT
+
+0x001CC000|0x34000
+FV = SECFV
+!endif
################################################################################
@@ -165,6 +180,8 @@ INF MdeModulePkg/Universal/Metronome/Metronome.inf
INF PcAtChipsetPkg/PcatRealTimeClockRuntimeDxe/PcatRealTimeClockRuntimeDxe.inf
INF OvmfPkg/BlockMmioToBlockIoDxe/BlockIo.inf
+INF OvmfPkg/VirtioBlkDxe/VirtioBlk.inf
+INF OvmfPkg/VirtioScsiDxe/VirtioScsi.inf
INF OvmfPkg/EmuVariableFvbRuntimeDxe/Fvb.inf
INF MdeModulePkg/Universal/FaultTolerantWriteDxe/FaultTolerantWriteDxe.inf
diff --git a/edk2/OvmfPkg/OvmfPkgIa32X64.dsc b/edk2/OvmfPkg/OvmfPkgIa32X64.dsc
index 9b2ba8626..0a1609f31 100644
--- a/edk2/OvmfPkg/OvmfPkgIa32X64.dsc
+++ b/edk2/OvmfPkg/OvmfPkgIa32X64.dsc
@@ -41,7 +41,12 @@
INTEL:RELEASE_*_*_CC_FLAGS = /D MDEPKG_NDEBUG
MSFT:RELEASE_*_*_CC_FLAGS = /D MDEPKG_NDEBUG
GCC:*_*_*_CC_FLAGS = -mno-mmx -mno-sse
-
+!ifdef $(SOURCE_DEBUG_ENABLE)
+ MSFT:*_*_X64_GENFW_FLAGS = --keepexceptiontable
+ GCC:*_*_X64_GENFW_FLAGS = --keepexceptiontable
+ INTEL:*_*_X64_GENFW_FLAGS = --keepexceptiontable
+!endif
+
################################################################################
#
# SKU Identification section - list of all SKU IDs supported by this Platform.
@@ -97,6 +102,7 @@
UefiUsbLib|MdePkg/Library/UefiUsbLib/UefiUsbLib.inf
SerializeVariablesLib|OvmfPkg/Library/SerializeVariablesLib/SerializeVariablesLib.inf
QemuFwCfgLib|OvmfPkg/Library/QemuFwCfgLib/QemuFwCfgLib.inf
+ VirtioLib|OvmfPkg/Library/VirtioLib/VirtioLib.inf
LockBoxLib|MdeModulePkg/Library/LockBoxNullLib/LockBoxNullLib.inf
!ifdef $(SOURCE_DEBUG_ENABLE)
@@ -409,6 +415,8 @@
}
OvmfPkg/BlockMmioToBlockIoDxe/BlockIo.inf
+ OvmfPkg/VirtioBlkDxe/VirtioBlk.inf
+ OvmfPkg/VirtioScsiDxe/VirtioScsi.inf
OvmfPkg/EmuVariableFvbRuntimeDxe/Fvb.inf {
<LibraryClasses>
PlatformFvbLib|OvmfPkg/Library/EmuVariableFvbLib/EmuVariableFvbLib.inf
diff --git a/edk2/OvmfPkg/OvmfPkgIa32X64.fdf b/edk2/OvmfPkg/OvmfPkgIa32X64.fdf
index 399f01321..a762dc9f2 100644
--- a/edk2/OvmfPkg/OvmfPkgIa32X64.fdf
+++ b/edk2/OvmfPkg/OvmfPkgIa32X64.fdf
@@ -14,6 +14,7 @@
##
################################################################################
+!ifndef $(FD_SIZE_2MB)
[FD.OVMF]
BaseAddress = 0xFFF00000
Size = 0x00100000
@@ -26,6 +27,20 @@ FV = FVMAIN_COMPACT
0x000EC000|0x14000
FV = SECFV
+!else
+[FD.OVMF]
+BaseAddress = 0xFFE00000
+Size = 0x00200000
+ErasePolarity = 1
+BlockSize = 0x1000
+NumBlocks = 0x200
+
+0x00000000|0x001CC000
+FV = FVMAIN_COMPACT
+
+0x001CC000|0x34000
+FV = SECFV
+!endif
################################################################################
@@ -165,6 +180,8 @@ INF MdeModulePkg/Universal/Metronome/Metronome.inf
INF PcAtChipsetPkg/PcatRealTimeClockRuntimeDxe/PcatRealTimeClockRuntimeDxe.inf
INF OvmfPkg/BlockMmioToBlockIoDxe/BlockIo.inf
+INF OvmfPkg/VirtioBlkDxe/VirtioBlk.inf
+INF OvmfPkg/VirtioScsiDxe/VirtioScsi.inf
INF OvmfPkg/EmuVariableFvbRuntimeDxe/Fvb.inf
INF MdeModulePkg/Universal/FaultTolerantWriteDxe/FaultTolerantWriteDxe.inf
diff --git a/edk2/OvmfPkg/OvmfPkgX64.dsc b/edk2/OvmfPkg/OvmfPkgX64.dsc
index 9ff4a5de1..b24d1b9df 100644
--- a/edk2/OvmfPkg/OvmfPkgX64.dsc
+++ b/edk2/OvmfPkg/OvmfPkgX64.dsc
@@ -41,6 +41,11 @@
INTEL:RELEASE_*_*_CC_FLAGS = /D MDEPKG_NDEBUG
MSFT:RELEASE_*_*_CC_FLAGS = /D MDEPKG_NDEBUG
GCC:*_*_*_CC_FLAGS = -mno-mmx -mno-sse
+!ifdef $(SOURCE_DEBUG_ENABLE)
+ MSFT:*_*_X64_GENFW_FLAGS = --keepexceptiontable
+ GCC:*_*_X64_GENFW_FLAGS = --keepexceptiontable
+ INTEL:*_*_X64_GENFW_FLAGS = --keepexceptiontable
+!endif
################################################################################
#
@@ -97,6 +102,7 @@
UefiUsbLib|MdePkg/Library/UefiUsbLib/UefiUsbLib.inf
SerializeVariablesLib|OvmfPkg/Library/SerializeVariablesLib/SerializeVariablesLib.inf
QemuFwCfgLib|OvmfPkg/Library/QemuFwCfgLib/QemuFwCfgLib.inf
+ VirtioLib|OvmfPkg/Library/VirtioLib/VirtioLib.inf
LockBoxLib|MdeModulePkg/Library/LockBoxNullLib/LockBoxNullLib.inf
!ifdef $(SOURCE_DEBUG_ENABLE)
@@ -407,6 +413,8 @@
}
OvmfPkg/BlockMmioToBlockIoDxe/BlockIo.inf
+ OvmfPkg/VirtioBlkDxe/VirtioBlk.inf
+ OvmfPkg/VirtioScsiDxe/VirtioScsi.inf
OvmfPkg/EmuVariableFvbRuntimeDxe/Fvb.inf {
<LibraryClasses>
PlatformFvbLib|OvmfPkg/Library/EmuVariableFvbLib/EmuVariableFvbLib.inf
diff --git a/edk2/OvmfPkg/OvmfPkgX64.fdf b/edk2/OvmfPkg/OvmfPkgX64.fdf
index 74ae134cd..fcdac0316 100644
--- a/edk2/OvmfPkg/OvmfPkgX64.fdf
+++ b/edk2/OvmfPkg/OvmfPkgX64.fdf
@@ -14,6 +14,7 @@
##
################################################################################
+!ifndef $(FD_SIZE_2MB)
[FD.OVMF]
BaseAddress = 0xFFF00000
Size = 0x00100000
@@ -26,6 +27,20 @@ FV = FVMAIN_COMPACT
0x000E6000|0x1A000
FV = SECFV
+!else
+[FD.OVMF]
+BaseAddress = 0xFFE00000
+Size = 0x00200000
+ErasePolarity = 1
+BlockSize = 0x1000
+NumBlocks = 0x200
+
+0x00000000|0x001CC000
+FV = FVMAIN_COMPACT
+
+0x001CC000|0x34000
+FV = SECFV
+!endif
################################################################################
@@ -165,6 +180,8 @@ INF MdeModulePkg/Universal/Metronome/Metronome.inf
INF PcAtChipsetPkg/PcatRealTimeClockRuntimeDxe/PcatRealTimeClockRuntimeDxe.inf
INF OvmfPkg/BlockMmioToBlockIoDxe/BlockIo.inf
+INF OvmfPkg/VirtioBlkDxe/VirtioBlk.inf
+INF OvmfPkg/VirtioScsiDxe/VirtioScsi.inf
INF OvmfPkg/EmuVariableFvbRuntimeDxe/Fvb.inf
INF MdeModulePkg/Universal/FaultTolerantWriteDxe/FaultTolerantWriteDxe.inf
diff --git a/edk2/OvmfPkg/VirtioBlkDxe/VirtioBlk.c b/edk2/OvmfPkg/VirtioBlkDxe/VirtioBlk.c
new file mode 100644
index 000000000..b2bfcdf7b
--- /dev/null
+++ b/edk2/OvmfPkg/VirtioBlkDxe/VirtioBlk.c
@@ -0,0 +1,1089 @@
+/** @file
+
+ This driver produces Block I/O Protocol instances for virtio-blk devices.
+
+ The implementation is basic:
+
+ - No attach/detach (ie. removable media).
+
+ - Although the non-blocking interfaces of EFI_BLOCK_IO2_PROTOCOL could be a
+ good match for multiple in-flight virtio-blk requests, we stick to
+ synchronous requests and EFI_BLOCK_IO_PROTOCOL for now.
+
+ Copyright (C) 2012, Red Hat, Inc.
+ Copyright (c) 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 which accompanies this
+ distribution. The full text of the license may be found at
+ http://opensource.org/licenses/bsd-license.php
+
+ THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, WITHOUT
+ WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+
+**/
+
+#include <IndustryStandard/Pci.h>
+#include <IndustryStandard/VirtioBlk.h>
+#include <Library/BaseMemoryLib.h>
+#include <Library/DebugLib.h>
+#include <Library/MemoryAllocationLib.h>
+#include <Library/UefiBootServicesTableLib.h>
+#include <Library/UefiLib.h>
+#include <Library/VirtioLib.h>
+
+#include "VirtioBlk.h"
+
+/**
+
+ Convenience macros to read and write region 0 IO space elements of the
+ virtio-blk PCI device, for configuration purposes.
+
+ The following macros make it possible to specify only the "core parameters"
+ for such accesses and to derive the rest. By the time VIRTIO_CFG_WRITE()
+ returns, the transaction will have been completed.
+
+ @param[in] Dev Pointer to the VBLK_DEV structure whose PCI IO space
+ we're accessing. Dev->PciIo must be valid.
+
+ @param[in] Field A field name from VBLK_HDR, identifying the virtio-blk
+ configuration item to access.
+
+ @param[in] Value (VIRTIO_CFG_WRITE() only.) The value to write to the
+ selected configuration item.
+
+ @param[out] Pointer (VIRTIO_CFG_READ() only.) The object to receive the
+ value read from the configuration item. Its type must be
+ one of UINT8, UINT16, UINT32, UINT64.
+
+
+ @return Status code returned by VirtioWrite() / VirtioRead().
+
+**/
+
+#define VIRTIO_CFG_WRITE(Dev, Field, Value) (VirtioWrite ( \
+ (Dev)->PciIo, \
+ OFFSET_OF_VBLK (Field), \
+ SIZE_OF_VBLK (Field), \
+ (Value) \
+ ))
+
+#define VIRTIO_CFG_READ(Dev, Field, Pointer) (VirtioRead ( \
+ (Dev)->PciIo, \
+ OFFSET_OF_VBLK (Field), \
+ SIZE_OF_VBLK (Field), \
+ sizeof *(Pointer), \
+ (Pointer) \
+ ))
+
+
+//
+// UEFI Spec 2.3.1 + Errata C, 12.8 EFI Block I/O Protocol
+// Driver Writer's Guide for UEFI 2.3.1 v1.01,
+// 24.2 Block I/O Protocol Implementations
+//
+EFI_STATUS
+EFIAPI
+VirtioBlkReset (
+ IN EFI_BLOCK_IO_PROTOCOL *This,
+ IN BOOLEAN ExtendedVerification
+ )
+{
+ //
+ // If we managed to initialize and install the driver, then the device is
+ // working correctly.
+ //
+ return EFI_SUCCESS;
+}
+
+/**
+
+ Verify correctness of the read/write (not flush) request submitted to the
+ EFI_BLOCK_IO_PROTOCOL instance.
+
+ This function provides most verification steps described in:
+
+ UEFI Spec 2.3.1 + Errata C, 12.8 EFI Block I/O Protocol, 12.8 EFI Block I/O
+ Protocol,
+ - EFI_BLOCK_IO_PROTOCOL.ReadBlocks()
+ - EFI_BLOCK_IO_PROTOCOL.WriteBlocks()
+
+ Driver Writer's Guide for UEFI 2.3.1 v1.01,
+ - 24.2.2. ReadBlocks() and ReadBlocksEx() Implementation
+ - 24.2.3 WriteBlocks() and WriteBlockEx() Implementation
+
+ Request sizes are limited to 1 GB (checked). This is not a practical
+ limitation, just conformance to virtio-0.9.5, 2.3.2 Descriptor Table: "no
+ descriptor chain may be more than 2^32 bytes long in total".
+
+ Some Media characteristics are hardcoded in VirtioBlkInit() below (like
+ non-removable media, no restriction on buffer alignment etc); we rely on
+ those here without explicit mention.
+
+ @param[in] Media The EFI_BLOCK_IO_MEDIA characteristics for
+ this driver instance, extracted from the
+ underlying virtio-blk device at initialization
+ time. We validate the request against this set
+ of attributes.
+
+
+ @param[in] Lba Logical Block Address: number of logical
+ blocks to skip from the beginning of the
+ device.
+
+ @param[in] PositiveBufferSize Size of buffer to transfer, in bytes. The
+ caller is responsible to ensure this parameter
+ is positive.
+
+ @param[in] RequestIsWrite TRUE iff data transfer goes from guest to
+ device.
+
+
+ @@return Validation result to be forwarded outwards by
+ ReadBlocks() and WriteBlocks, as required by
+ the specs above.
+
+**/
+STATIC
+EFI_STATUS
+EFIAPI
+VerifyReadWriteRequest (
+ IN EFI_BLOCK_IO_MEDIA *Media,
+ IN EFI_LBA Lba,
+ IN UINTN PositiveBufferSize,
+ IN BOOLEAN RequestIsWrite
+ )
+{
+ UINTN BlockCount;
+
+ ASSERT (PositiveBufferSize > 0);
+
+ if (PositiveBufferSize > SIZE_1GB ||
+ PositiveBufferSize % Media->BlockSize > 0) {
+ return EFI_BAD_BUFFER_SIZE;
+ }
+ BlockCount = PositiveBufferSize / Media->BlockSize;
+
+ //
+ // Avoid unsigned wraparound on either side in the second comparison.
+ //
+ if (Lba > Media->LastBlock || BlockCount - 1 > Media->LastBlock - Lba) {
+ return EFI_INVALID_PARAMETER;
+ }
+
+ if (RequestIsWrite && Media->ReadOnly) {
+ return EFI_WRITE_PROTECTED;
+ }
+
+ return EFI_SUCCESS;
+}
+
+
+
+
+/**
+
+ Format a read / write / flush request as three consecutive virtio
+ descriptors, push them to the host, and poll for the response.
+
+ This is the main workhorse function. Two use cases are supported, read/write
+ and flush. The function may only be called after the request parameters have
+ been verified by
+ - specific checks in ReadBlocks() / WriteBlocks() / FlushBlocks(), and
+ - VerifyReadWriteRequest() (for read/write only).
+
+ Parameters handled commonly:
+
+ @param[in] Dev The virtio-blk device the request is targeted
+ at.
+
+ Flush request:
+
+ @param[in] Lba Must be zero.
+
+ @param[in] BufferSize Must be zero.
+
+ @param[in out] Buffer Ignored by the function.
+
+ @param[in] RequestIsWrite Must be TRUE.
+
+ Read/Write request:
+
+ @param[in] Lba Logical Block Address: number of logical blocks
+ to skip from the beginning of the device.
+
+ @param[in] BufferSize Size of buffer to transfer, in bytes. The caller
+ is responsible to ensure this parameter is
+ positive.
+
+ @param[in out] Buffer The guest side area to read data from the device
+ into, or write data to the device from.
+
+ @param[in] RequestIsWrite TRUE iff data transfer goes from guest to
+ device.
+
+ Return values are common to both use cases, and are appropriate to be
+ forwarded by the EFI_BLOCK_IO_PROTOCOL functions (ReadBlocks(),
+ WriteBlocks(), FlushBlocks()).
+
+
+ @retval EFI_SUCCESS Transfer complete.
+
+ @retval EFI_DEVICE_ERROR Failed to notify host side via PCI write, or
+ unable to parse host response, or host response
+ is not VIRTIO_BLK_S_OK.
+
+**/
+
+STATIC
+EFI_STATUS
+EFIAPI
+SynchronousRequest (
+ IN VBLK_DEV *Dev,
+ IN EFI_LBA Lba,
+ IN UINTN BufferSize,
+ IN OUT volatile VOID *Buffer,
+ IN BOOLEAN RequestIsWrite
+ )
+{
+ UINT32 BlockSize;
+ volatile VIRTIO_BLK_REQ Request;
+ volatile UINT8 HostStatus;
+ DESC_INDICES Indices;
+
+ BlockSize = Dev->BlockIoMedia.BlockSize;
+
+ //
+ // ensured by VirtioBlkInit()
+ //
+ ASSERT (BlockSize > 0);
+ ASSERT (BlockSize % 512 == 0);
+
+ //
+ // ensured by contract above, plus VerifyReadWriteRequest()
+ //
+ ASSERT (BufferSize % BlockSize == 0);
+
+ //
+ // Prepare virtio-blk request header, setting zero size for flush.
+ // IO Priority is homogeneously 0.
+ //
+ Request.Type = RequestIsWrite ?
+ (BufferSize == 0 ? VIRTIO_BLK_T_FLUSH : VIRTIO_BLK_T_OUT) :
+ VIRTIO_BLK_T_IN;
+ Request.IoPrio = 0;
+ Request.Sector = MultU64x32(Lba, BlockSize / 512);
+
+ VirtioPrepare (&Dev->Ring, &Indices);
+
+ //
+ // preset a host status for ourselves that we do not accept as success
+ //
+ HostStatus = VIRTIO_BLK_S_IOERR;
+
+ //
+ // ensured by VirtioBlkInit() -- this predicate, in combination with the
+ // lock-step progress, ensures we don't have to track free descriptors.
+ //
+ ASSERT (Dev->Ring.QueueSize >= 3);
+
+ //
+ // virtio-blk header in first desc
+ //
+ VirtioAppendDesc (&Dev->Ring, (UINTN) &Request, sizeof Request,
+ VRING_DESC_F_NEXT, &Indices);
+
+ //
+ // data buffer for read/write in second desc
+ //
+ if (BufferSize > 0) {
+ //
+ // From virtio-0.9.5, 2.3.2 Descriptor Table:
+ // "no descriptor chain may be more than 2^32 bytes long in total".
+ //
+ // The predicate is ensured by the call contract above (for flush), or
+ // VerifyReadWriteRequest() (for read/write). It also implies that
+ // converting BufferSize to UINT32 will not truncate it.
+ //
+ ASSERT (BufferSize <= SIZE_1GB);
+
+ //
+ // VRING_DESC_F_WRITE is interpreted from the host's point of view.
+ //
+ VirtioAppendDesc (&Dev->Ring, (UINTN) Buffer, (UINT32) BufferSize,
+ VRING_DESC_F_NEXT | (RequestIsWrite ? 0 : VRING_DESC_F_WRITE),
+ &Indices);
+ }
+
+ //
+ // host status in last (second or third) desc
+ //
+ VirtioAppendDesc (&Dev->Ring, (UINTN) &HostStatus, sizeof HostStatus,
+ VRING_DESC_F_WRITE, &Indices);
+
+ //
+ // virtio-blk's only virtqueue is #0, called "requestq" (see Appendix D).
+ //
+ if (VirtioFlush (Dev->PciIo, 0, &Dev->Ring, &Indices) == EFI_SUCCESS &&
+ HostStatus == VIRTIO_BLK_S_OK) {
+ return EFI_SUCCESS;
+ }
+
+ return EFI_DEVICE_ERROR;
+}
+
+
+/**
+
+ ReadBlocks() operation for virtio-blk.
+
+ See
+ - UEFI Spec 2.3.1 + Errata C, 12.8 EFI Block I/O Protocol, 12.8 EFI Block I/O
+ Protocol, EFI_BLOCK_IO_PROTOCOL.ReadBlocks().
+ - Driver Writer's Guide for UEFI 2.3.1 v1.01, 24.2.2. ReadBlocks() and
+ ReadBlocksEx() Implementation.
+
+ Parameter checks and conformant return values are implemented in
+ VerifyReadWriteRequest() and SynchronousRequest().
+
+ A zero BufferSize doesn't seem to be prohibited, so do nothing in that case,
+ successfully.
+
+**/
+
+EFI_STATUS
+EFIAPI
+VirtioBlkReadBlocks (
+ IN EFI_BLOCK_IO_PROTOCOL *This,
+ IN UINT32 MediaId,
+ IN EFI_LBA Lba,
+ IN UINTN BufferSize,
+ OUT VOID *Buffer
+ )
+{
+ VBLK_DEV *Dev;
+ EFI_STATUS Status;
+
+ if (BufferSize == 0) {
+ return EFI_SUCCESS;
+ }
+
+ Dev = VIRTIO_BLK_FROM_BLOCK_IO (This);
+ Status = VerifyReadWriteRequest (
+ &Dev->BlockIoMedia,
+ Lba,
+ BufferSize,
+ FALSE // RequestIsWrite
+ );
+ if (EFI_ERROR (Status)) {
+ return Status;
+ }
+
+ return SynchronousRequest (
+ Dev,
+ Lba,
+ BufferSize,
+ Buffer,
+ FALSE // RequestIsWrite
+ );
+}
+
+/**
+
+ WriteBlocks() operation for virtio-blk.
+
+ See
+ - UEFI Spec 2.3.1 + Errata C, 12.8 EFI Block I/O Protocol, 12.8 EFI Block I/O
+ Protocol, EFI_BLOCK_IO_PROTOCOL.WriteBlocks().
+ - Driver Writer's Guide for UEFI 2.3.1 v1.01, 24.2.3 WriteBlocks() and
+ WriteBlockEx() Implementation.
+
+ Parameter checks and conformant return values are implemented in
+ VerifyReadWriteRequest() and SynchronousRequest().
+
+ A zero BufferSize doesn't seem to be prohibited, so do nothing in that case,
+ successfully.
+
+**/
+
+EFI_STATUS
+EFIAPI
+VirtioBlkWriteBlocks (
+ IN EFI_BLOCK_IO_PROTOCOL *This,
+ IN UINT32 MediaId,
+ IN EFI_LBA Lba,
+ IN UINTN BufferSize,
+ IN VOID *Buffer
+ )
+{
+ VBLK_DEV *Dev;
+ EFI_STATUS Status;
+
+ if (BufferSize == 0) {
+ return EFI_SUCCESS;
+ }
+
+ Dev = VIRTIO_BLK_FROM_BLOCK_IO (This);
+ Status = VerifyReadWriteRequest (
+ &Dev->BlockIoMedia,
+ Lba,
+ BufferSize,
+ TRUE // RequestIsWrite
+ );
+ if (EFI_ERROR (Status)) {
+ return Status;
+ }
+
+ return SynchronousRequest (
+ Dev,
+ Lba,
+ BufferSize,
+ Buffer,
+ TRUE // RequestIsWrite
+ );
+}
+
+
+/**
+
+ FlushBlocks() operation for virtio-blk.
+
+ See
+ - UEFI Spec 2.3.1 + Errata C, 12.8 EFI Block I/O Protocol, 12.8 EFI Block I/O
+ Protocol, EFI_BLOCK_IO_PROTOCOL.FlushBlocks().
+ - Driver Writer's Guide for UEFI 2.3.1 v1.01, 24.2.4 FlushBlocks() and
+ FlushBlocksEx() Implementation.
+
+ If the underlying virtio-blk device doesn't support flushing (ie.
+ write-caching), then this function should not be called by higher layers,
+ according to EFI_BLOCK_IO_MEDIA characteristics set in VirtioBlkInit().
+ Should they do nonetheless, we do nothing, successfully.
+
+**/
+
+EFI_STATUS
+EFIAPI
+VirtioBlkFlushBlocks (
+ IN EFI_BLOCK_IO_PROTOCOL *This
+ )
+{
+ VBLK_DEV *Dev;
+
+ Dev = VIRTIO_BLK_FROM_BLOCK_IO (This);
+ return Dev->BlockIoMedia.WriteCaching ?
+ SynchronousRequest (
+ Dev,
+ 0, // Lba
+ 0, // BufferSize
+ NULL, // Buffer
+ TRUE // RequestIsWrite
+ ) :
+ EFI_SUCCESS;
+}
+
+
+/**
+
+ Device probe function for this driver.
+
+ The DXE core calls this function for any given device in order to see if the
+ driver can drive the device.
+
+ Specs relevant in the general sense:
+
+ - UEFI Spec 2.3.1 + Errata C:
+ - 6.3 Protocol Handler Services -- for accessing the underlying device
+ - 10.1 EFI Driver Binding Protocol -- for exporting ourselves
+
+ - Driver Writer's Guide for UEFI 2.3.1 v1.01:
+ - 5.1.3.4 OpenProtocol() and CloseProtocol() -- for accessing the
+ underlying device
+ - 9 Driver Binding Protocol -- for exporting ourselves
+
+ Specs relevant in the specific sense:
+ - UEFI Spec 2.3.1 + Errata C, 13.4 EFI PCI I/O Protocol
+ - Driver Writer's Guide for UEFI 2.3.1 v1.01, 18 PCI Driver Design
+ Guidelines, 18.3 PCI drivers.
+
+ @param[in] This The EFI_DRIVER_BINDING_PROTOCOL object
+ incorporating this driver (independently of
+ any device).
+
+ @param[in] DeviceHandle The device to probe.
+
+ @param[in] RemainingDevicePath Relevant only for bus drivers, ignored.
+
+
+ @retval EFI_SUCCESS The driver supports the device being probed.
+
+ @retval EFI_UNSUPPORTED Based on virtio-blk PCI discovery, we do not support
+ the device.
+
+ @return Error codes from the OpenProtocol() boot service or
+ the PciIo protocol.
+
+**/
+
+EFI_STATUS
+EFIAPI
+VirtioBlkDriverBindingSupported (
+ IN EFI_DRIVER_BINDING_PROTOCOL *This,
+ IN EFI_HANDLE DeviceHandle,
+ IN EFI_DEVICE_PATH_PROTOCOL *RemainingDevicePath
+ )
+{
+ EFI_STATUS Status;
+ EFI_PCI_IO_PROTOCOL *PciIo;
+ PCI_TYPE00 Pci;
+
+ //
+ // Attempt to open the device with the PciIo set of interfaces. On success,
+ // the protocol is "instantiated" for the PCI device. Covers duplicate open
+ // attempts (EFI_ALREADY_STARTED).
+ //
+ Status = gBS->OpenProtocol (
+ DeviceHandle, // candidate device
+ &gEfiPciIoProtocolGuid, // for generic PCI access
+ (VOID **)&PciIo, // handle to instantiate
+ This->DriverBindingHandle, // requestor driver identity
+ DeviceHandle, // ControllerHandle, according to
+ // the UEFI Driver Model
+ EFI_OPEN_PROTOCOL_BY_DRIVER // get exclusive PciIo access to
+ // the device; to be released
+ );
+ if (EFI_ERROR (Status)) {
+ return Status;
+ }
+
+ //
+ // Read entire PCI configuration header for more extensive check ahead.
+ //
+ Status = PciIo->Pci.Read (
+ PciIo, // (protocol, device)
+ // handle
+ EfiPciIoWidthUint32, // access width & copy
+ // mode
+ 0, // Offset
+ sizeof Pci / sizeof (UINT32), // Count
+ &Pci // target buffer
+ );
+
+ if (Status == EFI_SUCCESS) {
+ //
+ // virtio-0.9.5, 2.1 PCI Discovery
+ //
+ Status = (Pci.Hdr.VendorId == 0x1AF4 &&
+ Pci.Hdr.DeviceId >= 0x1000 && Pci.Hdr.DeviceId <= 0x103F &&
+ Pci.Hdr.RevisionID == 0x00 &&
+ Pci.Device.SubsystemID == 0x02) ? EFI_SUCCESS : EFI_UNSUPPORTED;
+ }
+
+ //
+ // We needed PCI IO access only transitorily, to see whether we support the
+ // device or not.
+ //
+ gBS->CloseProtocol (DeviceHandle, &gEfiPciIoProtocolGuid,
+ This->DriverBindingHandle, DeviceHandle);
+ return Status;
+}
+
+
+/**
+
+ Set up all BlockIo and virtio-blk aspects of this driver for the specified
+ device.
+
+ @param[in out] Dev The driver instance to configure. The caller is
+ responsible for Dev->PciIo's validity (ie. working IO
+ access to the underlying virtio-blk PCI device).
+
+ @retval EFI_SUCCESS Setup complete.
+
+ @retval EFI_UNSUPPORTED The driver is unable to work with the virtio ring or
+ virtio-blk attributes the host provides.
+
+ @return Error codes from VirtioRingInit() or
+ VIRTIO_CFG_READ() / VIRTIO_CFG_WRITE().
+
+**/
+
+STATIC
+EFI_STATUS
+EFIAPI
+VirtioBlkInit (
+ IN OUT VBLK_DEV *Dev
+ )
+{
+ UINT8 NextDevStat;
+ EFI_STATUS Status;
+
+ UINT32 Features;
+ UINT64 NumSectors;
+ UINT32 BlockSize;
+ UINT16 QueueSize;
+
+ //
+ // Execute virtio-0.9.5, 2.2.1 Device Initialization Sequence.
+ //
+ NextDevStat = 0; // step 1 -- reset device
+ Status = VIRTIO_CFG_WRITE (Dev, Generic.VhdrDeviceStatus, NextDevStat);
+ if (EFI_ERROR (Status)) {
+ goto Failed;
+ }
+
+ NextDevStat |= VSTAT_ACK; // step 2 -- acknowledge device presence
+ Status = VIRTIO_CFG_WRITE (Dev, Generic.VhdrDeviceStatus, NextDevStat);
+ if (EFI_ERROR (Status)) {
+ goto Failed;
+ }
+
+ NextDevStat |= VSTAT_DRIVER; // step 3 -- we know how to drive it
+ Status = VIRTIO_CFG_WRITE (Dev, Generic.VhdrDeviceStatus, NextDevStat);
+ if (EFI_ERROR (Status)) {
+ goto Failed;
+ }
+
+ //
+ // step 4a -- retrieve and validate features
+ //
+ Status = VIRTIO_CFG_READ (Dev, Generic.VhdrDeviceFeatureBits, &Features);
+ if (EFI_ERROR (Status)) {
+ goto Failed;
+ }
+ Status = VIRTIO_CFG_READ (Dev, VhdrCapacity, &NumSectors);
+ if (EFI_ERROR (Status)) {
+ goto Failed;
+ }
+ if (NumSectors == 0) {
+ Status = EFI_UNSUPPORTED;
+ goto Failed;
+ }
+
+ if (Features & VIRTIO_BLK_F_BLK_SIZE) {
+ Status = VIRTIO_CFG_READ (Dev, VhdrBlkSize, &BlockSize);
+ if (EFI_ERROR (Status)) {
+ goto Failed;
+ }
+ if (BlockSize == 0 || BlockSize % 512 != 0 ||
+ ModU64x32 (NumSectors, BlockSize / 512) != 0) {
+ //
+ // We can only handle a logical block consisting of whole sectors,
+ // and only a disk composed of whole logical blocks.
+ //
+ Status = EFI_UNSUPPORTED;
+ goto Failed;
+ }
+ }
+ else {
+ BlockSize = 512;
+ }
+
+ //
+ // step 4b -- allocate virtqueue
+ //
+ Status = VIRTIO_CFG_WRITE (Dev, Generic.VhdrQueueSelect, 0);
+ if (EFI_ERROR (Status)) {
+ goto Failed;
+ }
+ Status = VIRTIO_CFG_READ (Dev, Generic.VhdrQueueSize, &QueueSize);
+ if (EFI_ERROR (Status)) {
+ goto Failed;
+ }
+ if (QueueSize < 3) { // SynchronousRequest() uses at most three descriptors
+ Status = EFI_UNSUPPORTED;
+ goto Failed;
+ }
+
+ Status = VirtioRingInit (QueueSize, &Dev->Ring);
+ if (EFI_ERROR (Status)) {
+ goto Failed;
+ }
+
+ //
+ // step 4c -- Report GPFN (guest-physical frame number) of queue. If anything
+ // fails from here on, we must release the ring resources.
+ //
+ Status = VIRTIO_CFG_WRITE (Dev, Generic.VhdrQueueAddress,
+ (UINTN) Dev->Ring.Base >> EFI_PAGE_SHIFT);
+ if (EFI_ERROR (Status)) {
+ goto ReleaseQueue;
+ }
+
+ //
+ // step 5 -- Report understood features. There are no virtio-blk specific
+ // features to negotiate in virtio-0.9.5, plus we do not want any of the
+ // device-independent (known or unknown) VIRTIO_F_* capabilities (see
+ // Appendix B).
+ //
+ Status = VIRTIO_CFG_WRITE (Dev, Generic.VhdrGuestFeatureBits, 0);
+ if (EFI_ERROR (Status)) {
+ goto ReleaseQueue;
+ }
+
+ //
+ // step 6 -- initialization complete
+ //
+ NextDevStat |= VSTAT_DRIVER_OK;
+ Status = VIRTIO_CFG_WRITE (Dev, Generic.VhdrDeviceStatus, NextDevStat);
+ if (EFI_ERROR (Status)) {
+ goto ReleaseQueue;
+ }
+
+ //
+ // Populate the exported interface's attributes; see UEFI spec v2.3.1 +
+ // Errata C, 12.8 EFI Block I/O Protocol. We stick to the lowest possible
+ // EFI_BLOCK_IO_PROTOCOL revision for now.
+ //
+ Dev->BlockIo.Revision = 0;
+ Dev->BlockIo.Media = &Dev->BlockIoMedia;
+ Dev->BlockIo.Reset = &VirtioBlkReset;
+ Dev->BlockIo.ReadBlocks = &VirtioBlkReadBlocks;
+ Dev->BlockIo.WriteBlocks = &VirtioBlkWriteBlocks;
+ Dev->BlockIo.FlushBlocks = &VirtioBlkFlushBlocks;
+ Dev->BlockIoMedia.MediaId = 0;
+ Dev->BlockIoMedia.RemovableMedia = FALSE;
+ Dev->BlockIoMedia.MediaPresent = TRUE;
+ Dev->BlockIoMedia.LogicalPartition = FALSE;
+ Dev->BlockIoMedia.ReadOnly = !!(Features & VIRTIO_BLK_F_RO);
+ Dev->BlockIoMedia.WriteCaching = !!(Features & VIRTIO_BLK_F_FLUSH);
+ Dev->BlockIoMedia.BlockSize = BlockSize;
+ Dev->BlockIoMedia.IoAlign = 0;
+ Dev->BlockIoMedia.LastBlock = DivU64x32 (NumSectors,
+ BlockSize / 512) - 1;
+ return EFI_SUCCESS;
+
+ReleaseQueue:
+ VirtioRingUninit (&Dev->Ring);
+
+Failed:
+ //
+ // Notify the host about our failure to setup: virtio-0.9.5, 2.2.2.1 Device
+ // Status. PCI IO access failure here should not mask the original error.
+ //
+ NextDevStat |= VSTAT_FAILED;
+ VIRTIO_CFG_WRITE (Dev, Generic.VhdrDeviceStatus, NextDevStat);
+
+ return Status; // reached only via Failed above
+}
+
+
+/**
+
+ Uninitialize the internals of a virtio-blk device that has been successfully
+ set up with VirtioBlkInit().
+
+ @param[in out] Dev The device to clean up.
+
+**/
+
+STATIC
+VOID
+EFIAPI
+VirtioBlkUninit (
+ IN OUT VBLK_DEV *Dev
+ )
+{
+ //
+ // Reset the virtual device -- see virtio-0.9.5, 2.2.2.1 Device Status. When
+ // VIRTIO_CFG_WRITE() returns, the host will have learned to stay away from
+ // the old comms area.
+ //
+ VIRTIO_CFG_WRITE (Dev, Generic.VhdrDeviceStatus, 0);
+
+ VirtioRingUninit (&Dev->Ring);
+
+ SetMem (&Dev->BlockIo, sizeof Dev->BlockIo, 0x00);
+ SetMem (&Dev->BlockIoMedia, sizeof Dev->BlockIoMedia, 0x00);
+}
+
+
+/**
+
+ After we've pronounced support for a specific device in
+ DriverBindingSupported(), we start managing said device (passed in by the
+ Driver Exeuction Environment) with the following service.
+
+ See DriverBindingSupported() for specification references.
+
+ @param[in] This The EFI_DRIVER_BINDING_PROTOCOL object
+ incorporating this driver (independently of
+ any device).
+
+ @param[in] DeviceHandle The supported device to drive.
+
+ @param[in] RemainingDevicePath Relevant only for bus drivers, ignored.
+
+
+ @retval EFI_SUCCESS Driver instance has been created and
+ initialized for the virtio-blk PCI device, it
+ is now accessibla via EFI_BLOCK_IO_PROTOCOL.
+
+ @retval EFI_OUT_OF_RESOURCES Memory allocation failed.
+
+ @return Error codes from the OpenProtocol() boot
+ service, the PciIo protocol, VirtioBlkInit(),
+ or the InstallProtocolInterface() boot service.
+
+**/
+
+EFI_STATUS
+EFIAPI
+VirtioBlkDriverBindingStart (
+ IN EFI_DRIVER_BINDING_PROTOCOL *This,
+ IN EFI_HANDLE DeviceHandle,
+ IN EFI_DEVICE_PATH_PROTOCOL *RemainingDevicePath
+ )
+{
+ VBLK_DEV *Dev;
+ EFI_STATUS Status;
+
+ Dev = (VBLK_DEV *) AllocateZeroPool (sizeof *Dev);
+ if (Dev == NULL) {
+ return EFI_OUT_OF_RESOURCES;
+ }
+
+ Status = gBS->OpenProtocol (DeviceHandle, &gEfiPciIoProtocolGuid,
+ (VOID **)&Dev->PciIo, This->DriverBindingHandle,
+ DeviceHandle, EFI_OPEN_PROTOCOL_BY_DRIVER);
+ if (EFI_ERROR (Status)) {
+ goto FreeVirtioBlk;
+ }
+
+ //
+ // We must retain and ultimately restore the original PCI attributes of the
+ // device. See Driver Writer's Guide for UEFI 2.3.1 v1.01, 18.3 PCI drivers /
+ // 18.3.2 Start() and Stop().
+ //
+ // The third parameter ("Attributes", input) is ignored by the Get operation.
+ // The fourth parameter ("Result", output) is ignored by the Enable and Set
+ // operations.
+ //
+ // For virtio-blk we only need IO space access.
+ //
+ Status = Dev->PciIo->Attributes (Dev->PciIo, EfiPciIoAttributeOperationGet,
+ 0, &Dev->OriginalPciAttributes);
+ if (EFI_ERROR (Status)) {
+ goto ClosePciIo;
+ }
+
+ Status = Dev->PciIo->Attributes (Dev->PciIo,
+ EfiPciIoAttributeOperationEnable,
+ EFI_PCI_IO_ATTRIBUTE_IO, NULL);
+ if (EFI_ERROR (Status)) {
+ goto ClosePciIo;
+ }
+
+ //
+ // PCI IO access granted, configure virtio-blk device.
+ //
+ Status = VirtioBlkInit (Dev);
+ if (EFI_ERROR (Status)) {
+ goto RestorePciAttributes;
+ }
+
+ //
+ // Setup complete, attempt to export the driver instance's BlockIo interface.
+ //
+ Dev->Signature = VBLK_SIG;
+ Status = gBS->InstallProtocolInterface (&DeviceHandle,
+ &gEfiBlockIoProtocolGuid, EFI_NATIVE_INTERFACE,
+ &Dev->BlockIo);
+ if (EFI_ERROR (Status)) {
+ goto UninitDev;
+ }
+
+ return EFI_SUCCESS;
+
+UninitDev:
+ VirtioBlkUninit (Dev);
+
+RestorePciAttributes:
+ Dev->PciIo->Attributes (Dev->PciIo, EfiPciIoAttributeOperationSet,
+ Dev->OriginalPciAttributes, NULL);
+
+ClosePciIo:
+ gBS->CloseProtocol (DeviceHandle, &gEfiPciIoProtocolGuid,
+ This->DriverBindingHandle, DeviceHandle);
+
+FreeVirtioBlk:
+ FreePool (Dev);
+
+ return Status;
+}
+
+
+/**
+
+ Stop driving a virtio-blk device and remove its BlockIo interface.
+
+ This function replays the success path of DriverBindingStart() in reverse.
+ The host side virtio-blk device is reset, so that the OS boot loader or the
+ OS may reinitialize it.
+
+ @param[in] This The EFI_DRIVER_BINDING_PROTOCOL object
+ incorporating this driver (independently of any
+ device).
+
+ @param[in] DeviceHandle Stop driving this device.
+
+ @param[in] NumberOfChildren Since this function belongs to a device driver
+ only (as opposed to a bus driver), the caller
+ environment sets NumberOfChildren to zero, and
+ we ignore it.
+
+ @param[in] ChildHandleBuffer Ignored (corresponding to NumberOfChildren).
+
+**/
+
+EFI_STATUS
+EFIAPI
+VirtioBlkDriverBindingStop (
+ IN EFI_DRIVER_BINDING_PROTOCOL *This,
+ IN EFI_HANDLE DeviceHandle,
+ IN UINTN NumberOfChildren,
+ IN EFI_HANDLE *ChildHandleBuffer
+ )
+{
+ EFI_STATUS Status;
+ EFI_BLOCK_IO_PROTOCOL *BlockIo;
+ VBLK_DEV *Dev;
+
+ Status = gBS->OpenProtocol (
+ DeviceHandle, // candidate device
+ &gEfiBlockIoProtocolGuid, // retrieve the BlockIo iface
+ (VOID **)&BlockIo, // target pointer
+ This->DriverBindingHandle, // requestor driver identity
+ DeviceHandle, // requesting lookup for dev.
+ EFI_OPEN_PROTOCOL_GET_PROTOCOL // lookup only, no ref. added
+ );
+ if (EFI_ERROR (Status)) {
+ return Status;
+ }
+
+ Dev = VIRTIO_BLK_FROM_BLOCK_IO (BlockIo);
+
+ //
+ // Handle Stop() requests for in-use driver instances gracefully.
+ //
+ Status = gBS->UninstallProtocolInterface (DeviceHandle,
+ &gEfiBlockIoProtocolGuid, &Dev->BlockIo);
+ if (EFI_ERROR (Status)) {
+ return Status;
+ }
+
+ VirtioBlkUninit (Dev);
+
+ Dev->PciIo->Attributes (Dev->PciIo, EfiPciIoAttributeOperationSet,
+ Dev->OriginalPciAttributes, NULL);
+
+ gBS->CloseProtocol (DeviceHandle, &gEfiPciIoProtocolGuid,
+ This->DriverBindingHandle, DeviceHandle);
+
+ FreePool (Dev);
+
+ return EFI_SUCCESS;
+}
+
+
+//
+// The static object that groups the Supported() (ie. probe), Start() and
+// Stop() functions of the driver together. Refer to UEFI Spec 2.3.1 + Errata
+// C, 10.1 EFI Driver Binding Protocol.
+//
+STATIC EFI_DRIVER_BINDING_PROTOCOL gDriverBinding = {
+ &VirtioBlkDriverBindingSupported,
+ &VirtioBlkDriverBindingStart,
+ &VirtioBlkDriverBindingStop,
+ 0x10, // Version, must be in [0x10 .. 0xFFFFFFEF] for IHV-developed drivers
+ NULL, // ImageHandle, to be overwritten by
+ // EfiLibInstallDriverBindingComponentName2() in VirtioBlkEntryPoint()
+ NULL // DriverBindingHandle, ditto
+};
+
+
+//
+// The purpose of the following scaffolding (EFI_COMPONENT_NAME_PROTOCOL and
+// EFI_COMPONENT_NAME2_PROTOCOL implementation) is to format the driver's name
+// in English, for display on standard console devices. This is recommended for
+// UEFI drivers that follow the UEFI Driver Model. Refer to the Driver Writer's
+// Guide for UEFI 2.3.1 v1.01, 11 UEFI Driver and Controller Names.
+//
+// Device type names ("Virtio Block Device") are not formatted because the
+// driver supports only that device type. Therefore the driver name suffices
+// for unambiguous identification.
+//
+
+STATIC
+EFI_UNICODE_STRING_TABLE mDriverNameTable[] = {
+ { "eng;en", L"Virtio Block Driver" },
+ { NULL, NULL }
+};
+
+STATIC
+EFI_COMPONENT_NAME_PROTOCOL gComponentName;
+
+EFI_STATUS
+EFIAPI
+VirtioBlkGetDriverName (
+ IN EFI_COMPONENT_NAME_PROTOCOL *This,
+ IN CHAR8 *Language,
+ OUT CHAR16 **DriverName
+ )
+{
+ return LookupUnicodeString2 (
+ Language,
+ This->SupportedLanguages,
+ mDriverNameTable,
+ DriverName,
+ (BOOLEAN)(This == &gComponentName) // Iso639Language
+ );
+}
+
+EFI_STATUS
+EFIAPI
+VirtioBlkGetDeviceName (
+ IN EFI_COMPONENT_NAME_PROTOCOL *This,
+ IN EFI_HANDLE DeviceHandle,
+ IN EFI_HANDLE ChildHandle,
+ IN CHAR8 *Language,
+ OUT CHAR16 **ControllerName
+ )
+{
+ return EFI_UNSUPPORTED;
+}
+
+STATIC
+EFI_COMPONENT_NAME_PROTOCOL gComponentName = {
+ &VirtioBlkGetDriverName,
+ &VirtioBlkGetDeviceName,
+ "eng" // SupportedLanguages, ISO 639-2 language codes
+};
+
+STATIC
+EFI_COMPONENT_NAME2_PROTOCOL gComponentName2 = {
+ (EFI_COMPONENT_NAME2_GET_DRIVER_NAME) &VirtioBlkGetDriverName,
+ (EFI_COMPONENT_NAME2_GET_CONTROLLER_NAME) &VirtioBlkGetDeviceName,
+ "en" // SupportedLanguages, RFC 4646 language codes
+};
+
+
+//
+// Entry point of this driver.
+//
+EFI_STATUS
+EFIAPI
+VirtioBlkEntryPoint (
+ IN EFI_HANDLE ImageHandle,
+ IN EFI_SYSTEM_TABLE *SystemTable
+ )
+{
+ return EfiLibInstallDriverBindingComponentName2 (
+ ImageHandle,
+ SystemTable,
+ &gDriverBinding,
+ ImageHandle,
+ &gComponentName,
+ &gComponentName2
+ );
+}
+
diff --git a/edk2/OvmfPkg/VirtioBlkDxe/VirtioBlk.h b/edk2/OvmfPkg/VirtioBlkDxe/VirtioBlk.h
new file mode 100644
index 000000000..d22570def
--- /dev/null
+++ b/edk2/OvmfPkg/VirtioBlkDxe/VirtioBlk.h
@@ -0,0 +1,298 @@
+/** @file
+
+ Internal definitions for the virtio-blk driver, which produces Block I/O
+ Protocol instances for virtio-blk devices.
+
+ Copyright (C) 2012, Red Hat, Inc.
+
+ This program and the accompanying materials are licensed and made available
+ under the terms and conditions of the BSD License which accompanies this
+ distribution. The full text of the license may be found at
+ http://opensource.org/licenses/bsd-license.php
+
+ THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, WITHOUT
+ WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+
+**/
+
+#ifndef _VIRTIO_BLK_DXE_H_
+#define _VIRTIO_BLK_DXE_H_
+
+#include <Protocol/BlockIo.h>
+#include <Protocol/ComponentName.h>
+#include <Protocol/DriverBinding.h>
+#include <Protocol/PciIo.h>
+
+#include <IndustryStandard/Virtio.h>
+
+
+#define VBLK_SIG SIGNATURE_32 ('V', 'B', 'L', 'K')
+
+typedef struct {
+ //
+ // Parts of this structure are initialized / torn down in various functions
+ // at various call depths. The table to the right should make it easier to
+ // track them.
+ //
+ // field init function init dpth
+ // ---------------------- ------------------ ---------
+ UINT32 Signature; // DriverBindingStart 0
+ EFI_PCI_IO_PROTOCOL *PciIo; // DriverBindingStart 0
+ UINT64 OriginalPciAttributes; // DriverBindingStart 0
+ VRING Ring; // VirtioRingInit 2
+ EFI_BLOCK_IO_PROTOCOL BlockIo; // VirtioBlkInit 1
+ EFI_BLOCK_IO_MEDIA BlockIoMedia; // VirtioBlkInit 1
+} VBLK_DEV;
+
+#define VIRTIO_BLK_FROM_BLOCK_IO(BlockIoPointer) \
+ CR (BlockIoPointer, VBLK_DEV, BlockIo, VBLK_SIG)
+
+
+/**
+
+ Device probe function for this driver.
+
+ The DXE core calls this function for any given device in order to see if the
+ driver can drive the device.
+
+ Specs relevant in the general sense:
+
+ - UEFI Spec 2.3.1 + Errata C:
+ - 6.3 Protocol Handler Services -- for accessing the underlying device
+ - 10.1 EFI Driver Binding Protocol -- for exporting ourselves
+
+ - Driver Writer's Guide for UEFI 2.3.1 v1.01:
+ - 5.1.3.4 OpenProtocol() and CloseProtocol() -- for accessing the
+ underlying device
+ - 9 Driver Binding Protocol -- for exporting ourselves
+
+ Specs relevant in the specific sense:
+ - UEFI Spec 2.3.1 + Errata C, 13.4 EFI PCI I/O Protocol
+ - Driver Writer's Guide for UEFI 2.3.1 v1.01, 18 PCI Driver Design
+ Guidelines, 18.3 PCI drivers.
+
+ @param[in] This The EFI_DRIVER_BINDING_PROTOCOL object
+ incorporating this driver (independently of
+ any device).
+
+ @param[in] DeviceHandle The device to probe.
+
+ @param[in] RemainingDevicePath Relevant only for bus drivers, ignored.
+
+
+ @retval EFI_SUCCESS The driver supports the device being probed.
+
+ @retval EFI_UNSUPPORTED Based on virtio-blk PCI discovery, we do not support
+ the device.
+
+ @return Error codes from the OpenProtocol() boot service or
+ the PciIo protocol.
+
+**/
+
+EFI_STATUS
+EFIAPI
+VirtioBlkDriverBindingSupported (
+ IN EFI_DRIVER_BINDING_PROTOCOL *This,
+ IN EFI_HANDLE DeviceHandle,
+ IN EFI_DEVICE_PATH_PROTOCOL *RemainingDevicePath
+ );
+
+
+/**
+
+ After we've pronounced support for a specific device in
+ DriverBindingSupported(), we start managing said device (passed in by the
+ Driver Exeuction Environment) with the following service.
+
+ See DriverBindingSupported() for specification references.
+
+ @param[in] This The EFI_DRIVER_BINDING_PROTOCOL object
+ incorporating this driver (independently of
+ any device).
+
+ @param[in] DeviceHandle The supported device to drive.
+
+ @param[in] RemainingDevicePath Relevant only for bus drivers, ignored.
+
+
+ @retval EFI_SUCCESS Driver instance has been created and
+ initialized for the virtio-blk PCI device, it
+ is now accessibla via EFI_BLOCK_IO_PROTOCOL.
+
+ @retval EFI_OUT_OF_RESOURCES Memory allocation failed.
+
+ @return Error codes from the OpenProtocol() boot
+ service, the PciIo protocol, VirtioBlkInit(),
+ or the InstallProtocolInterface() boot service.
+
+**/
+
+EFI_STATUS
+EFIAPI
+VirtioBlkDriverBindingStart (
+ IN EFI_DRIVER_BINDING_PROTOCOL *This,
+ IN EFI_HANDLE DeviceHandle,
+ IN EFI_DEVICE_PATH_PROTOCOL *RemainingDevicePath
+ );
+
+
+/**
+
+ Stop driving a virtio-blk device and remove its BlockIo interface.
+
+ This function replays the success path of DriverBindingStart() in reverse.
+ The host side virtio-blk device is reset, so that the OS boot loader or the
+ OS may reinitialize it.
+
+ @param[in] This The EFI_DRIVER_BINDING_PROTOCOL object
+ incorporating this driver (independently of any
+ device).
+
+ @param[in] DeviceHandle Stop driving this device.
+
+ @param[in] NumberOfChildren Since this function belongs to a device driver
+ only (as opposed to a bus driver), the caller
+ environment sets NumberOfChildren to zero, and
+ we ignore it.
+
+ @param[in] ChildHandleBuffer Ignored (corresponding to NumberOfChildren).
+
+**/
+
+EFI_STATUS
+EFIAPI
+VirtioBlkDriverBindingStop (
+ IN EFI_DRIVER_BINDING_PROTOCOL *This,
+ IN EFI_HANDLE DeviceHandle,
+ IN UINTN NumberOfChildren,
+ IN EFI_HANDLE *ChildHandleBuffer
+ );
+
+
+//
+// UEFI Spec 2.3.1 + Errata C, 12.8 EFI Block I/O Protocol
+// Driver Writer's Guide for UEFI 2.3.1 v1.01,
+// 24.2 Block I/O Protocol Implementations
+//
+EFI_STATUS
+EFIAPI
+VirtioBlkReset (
+ IN EFI_BLOCK_IO_PROTOCOL *This,
+ IN BOOLEAN ExtendedVerification
+ );
+
+
+/**
+
+ ReadBlocks() operation for virtio-blk.
+
+ See
+ - UEFI Spec 2.3.1 + Errata C, 12.8 EFI Block I/O Protocol, 12.8 EFI Block I/O
+ Protocol, EFI_BLOCK_IO_PROTOCOL.ReadBlocks().
+ - Driver Writer's Guide for UEFI 2.3.1 v1.01, 24.2.2. ReadBlocks() and
+ ReadBlocksEx() Implementation.
+
+ Parameter checks and conformant return values are implemented in
+ VerifyReadWriteRequest() and SynchronousRequest().
+
+ A zero BufferSize doesn't seem to be prohibited, so do nothing in that case,
+ successfully.
+
+**/
+
+EFI_STATUS
+EFIAPI
+VirtioBlkReadBlocks (
+ IN EFI_BLOCK_IO_PROTOCOL *This,
+ IN UINT32 MediaId,
+ IN EFI_LBA Lba,
+ IN UINTN BufferSize,
+ OUT VOID *Buffer
+ );
+
+
+/**
+
+ WriteBlocks() operation for virtio-blk.
+
+ See
+ - UEFI Spec 2.3.1 + Errata C, 12.8 EFI Block I/O Protocol, 12.8 EFI Block I/O
+ Protocol, EFI_BLOCK_IO_PROTOCOL.WriteBlocks().
+ - Driver Writer's Guide for UEFI 2.3.1 v1.01, 24.2.3 WriteBlocks() and
+ WriteBlockEx() Implementation.
+
+ Parameter checks and conformant return values are implemented in
+ VerifyReadWriteRequest() and SynchronousRequest().
+
+ A zero BufferSize doesn't seem to be prohibited, so do nothing in that case,
+ successfully.
+
+**/
+
+EFI_STATUS
+EFIAPI
+VirtioBlkWriteBlocks (
+ IN EFI_BLOCK_IO_PROTOCOL *This,
+ IN UINT32 MediaId,
+ IN EFI_LBA Lba,
+ IN UINTN BufferSize,
+ IN VOID *Buffer
+ );
+
+
+/**
+
+ FlushBlocks() operation for virtio-blk.
+
+ See
+ - UEFI Spec 2.3.1 + Errata C, 12.8 EFI Block I/O Protocol, 12.8 EFI Block I/O
+ Protocol, EFI_BLOCK_IO_PROTOCOL.FlushBlocks().
+ - Driver Writer's Guide for UEFI 2.3.1 v1.01, 24.2.4 FlushBlocks() and
+ FlushBlocksEx() Implementation.
+
+ If the underlying virtio-blk device doesn't support flushing (ie.
+ write-caching), then this function should not be called by higher layers,
+ according to EFI_BLOCK_IO_MEDIA characteristics set in VirtioBlkInit().
+ Should they do nonetheless, we do nothing, successfully.
+
+**/
+
+EFI_STATUS
+EFIAPI
+VirtioBlkFlushBlocks (
+ IN EFI_BLOCK_IO_PROTOCOL *This
+ );
+
+
+//
+// The purpose of the following scaffolding (EFI_COMPONENT_NAME_PROTOCOL and
+// EFI_COMPONENT_NAME2_PROTOCOL implementation) is to format the driver's name
+// in English, for display on standard console devices. This is recommended for
+// UEFI drivers that follow the UEFI Driver Model. Refer to the Driver Writer's
+// Guide for UEFI 2.3.1 v1.01, 11 UEFI Driver and Controller Names.
+//
+// Device type names ("Virtio Block Device") are not formatted because the
+// driver supports only that device type. Therefore the driver name suffices
+// for unambiguous identification.
+//
+
+EFI_STATUS
+EFIAPI
+VirtioBlkGetDriverName (
+ IN EFI_COMPONENT_NAME_PROTOCOL *This,
+ IN CHAR8 *Language,
+ OUT CHAR16 **DriverName
+ );
+
+EFI_STATUS
+EFIAPI
+VirtioBlkGetDeviceName (
+ IN EFI_COMPONENT_NAME_PROTOCOL *This,
+ IN EFI_HANDLE DeviceHandle,
+ IN EFI_HANDLE ChildHandle,
+ IN CHAR8 *Language,
+ OUT CHAR16 **ControllerName
+ );
+
+#endif // _VIRTIO_BLK_DXE_H_
diff --git a/edk2/OvmfPkg/VirtioBlkDxe/VirtioBlk.inf b/edk2/OvmfPkg/VirtioBlkDxe/VirtioBlk.inf
new file mode 100644
index 000000000..6dffc3a22
--- /dev/null
+++ b/edk2/OvmfPkg/VirtioBlkDxe/VirtioBlk.inf
@@ -0,0 +1,42 @@
+## @file
+# This driver produces Block I/O Protocol instances for virtio-blk devices.
+#
+# Copyright (C) 2012, Red Hat, Inc.
+#
+# This program and the accompanying materials are licensed and made available
+# under the terms and conditions of the BSD License which accompanies this
+# distribution. The full text of the license may be found at
+# http://opensource.org/licenses/bsd-license.php
+#
+# THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, WITHOUT
+# WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+#
+##
+
+[Defines]
+ INF_VERSION = 0x00010005
+ BASE_NAME = VirtioBlkDxe
+ FILE_GUID = 11D92DFB-3CA9-4F93-BA2E-4780ED3E03B5
+ MODULE_TYPE = UEFI_DRIVER
+ VERSION_STRING = 1.0
+ ENTRY_POINT = VirtioBlkEntryPoint
+
+[Sources]
+ VirtioBlk.c
+
+[Packages]
+ MdePkg/MdePkg.dec
+ OvmfPkg/OvmfPkg.dec
+
+[LibraryClasses]
+ BaseMemoryLib
+ DebugLib
+ MemoryAllocationLib
+ UefiBootServicesTableLib
+ UefiDriverEntryPoint
+ UefiLib
+ VirtioLib
+
+[Protocols]
+ gEfiBlockIoProtocolGuid ## BY_START
+ gEfiPciIoProtocolGuid ## TO_START
diff --git a/edk2/OvmfPkg/VirtioScsiDxe/VirtioScsi.c b/edk2/OvmfPkg/VirtioScsiDxe/VirtioScsi.c
new file mode 100644
index 000000000..66f6d31d7
--- /dev/null
+++ b/edk2/OvmfPkg/VirtioScsiDxe/VirtioScsi.c
@@ -0,0 +1,1275 @@
+/** @file
+
+ This driver produces Extended SCSI Pass Thru Protocol instances for
+ virtio-scsi devices.
+
+ The implementation is basic:
+
+ - No hotplug / hot-unplug.
+
+ - Although EFI_EXT_SCSI_PASS_THRU_PROTOCOL.PassThru() could be a good match
+ for multiple in-flight virtio-scsi requests, we stick to synchronous
+ requests for now.
+
+ - Timeouts are not supported for EFI_EXT_SCSI_PASS_THRU_PROTOCOL.PassThru().
+
+ - Only one channel is supported. (At the time of this writing, host-side
+ virtio-scsi supports a single channel too.)
+
+ - Only one request queue is used (for the one synchronous request).
+
+ - The ResetChannel() and ResetTargetLun() functions of
+ EFI_EXT_SCSI_PASS_THRU_PROTOCOL are not supported (which is allowed by the
+ UEFI 2.3.1 Errata C specification), although
+ VIRTIO_SCSI_T_TMF_LOGICAL_UNIT_RESET could be a good match. That would
+ however require client code for the control queue, which is deemed
+ unreasonable for now.
+
+ Copyright (C) 2012, Red Hat, Inc.
+ Copyright (c) 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 which accompanies this
+ distribution. The full text of the license may be found at
+ http://opensource.org/licenses/bsd-license.php
+
+ THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, WITHOUT
+ WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+
+**/
+
+#include <IndustryStandard/Pci.h>
+#include <IndustryStandard/VirtioScsi.h>
+#include <Library/BaseMemoryLib.h>
+#include <Library/DebugLib.h>
+#include <Library/MemoryAllocationLib.h>
+#include <Library/UefiBootServicesTableLib.h>
+#include <Library/UefiLib.h>
+#include <Library/VirtioLib.h>
+
+#include "VirtioScsi.h"
+
+/**
+
+ Convenience macros to read and write region 0 IO space elements of the
+ virtio-scsi PCI device, for configuration purposes.
+
+ The following macros make it possible to specify only the "core parameters"
+ for such accesses and to derive the rest. By the time VIRTIO_CFG_WRITE()
+ returns, the transaction will have been completed.
+
+ @param[in] Dev Pointer to the VSCSI_DEV structure whose PCI IO space
+ we're accessing. Dev->PciIo must be valid.
+
+ @param[in] Field A field name from VSCSI_HDR, identifying the virtio-scsi
+ configuration item to access.
+
+ @param[in] Value (VIRTIO_CFG_WRITE() only.) The value to write to the
+ selected configuration item.
+
+ @param[out] Pointer (VIRTIO_CFG_READ() only.) The object to receive the
+ value read from the configuration item. Its type must be
+ one of UINT8, UINT16, UINT32, UINT64.
+
+
+ @return Status codes returned by VirtioWrite() / VirtioRead().
+
+**/
+
+#define VIRTIO_CFG_WRITE(Dev, Field, Value) (VirtioWrite ( \
+ (Dev)->PciIo, \
+ OFFSET_OF_VSCSI (Field), \
+ SIZE_OF_VSCSI (Field), \
+ (Value) \
+ ))
+
+#define VIRTIO_CFG_READ(Dev, Field, Pointer) (VirtioRead ( \
+ (Dev)->PciIo, \
+ OFFSET_OF_VSCSI (Field), \
+ SIZE_OF_VSCSI (Field), \
+ sizeof *(Pointer), \
+ (Pointer) \
+ ))
+
+
+//
+// UEFI Spec 2.3.1 + Errata C, 14.7 Extended SCSI Pass Thru Protocol specifies
+// the PassThru() interface. Beside returning a status code, the function must
+// set some fields in the EFI_EXT_SCSI_PASS_THRU_SCSI_REQUEST_PACKET in/out
+// parameter on return. The following is a full list of those fields, for
+// easier validation of PopulateRequest(), ParseResponse(), and
+// VirtioScsiPassThru() below.
+//
+// - InTransferLength
+// - OutTransferLength
+// - HostAdapterStatus
+// - TargetStatus
+// - SenseDataLength
+// - SenseData
+//
+// On any return from the PassThru() interface, these fields must be set,
+// except if the returned status code is explicitly exempt. (Actually the
+// implementation here conservatively sets these fields even in case not all
+// of them would be required by the specification.)
+//
+
+/**
+
+ Populate a virtio-scsi request from the Extended SCSI Pass Thru Protocol
+ packet.
+
+ The caller is responsible for pre-zeroing the virtio-scsi request. The
+ Extended SCSI Pass Thru Protocol packet is modified, to be forwarded outwards
+ by VirtioScsiPassThru(), if invalid or unsupported parameters are detected.
+
+ @param[in] Dev The virtio-scsi host device the packet targets.
+
+ @param[in] Target The SCSI target controlled by the virtio-scsi host
+ device.
+
+ @param[in] Lun The Logical Unit Number under the SCSI target.
+
+ @param[in out] Packet The Extended SCSI Pass Thru Protocol packet the
+ function translates to a virtio-scsi request. On
+ failure this parameter relays error contents.
+
+ @param[out] Request The pre-zeroed virtio-scsi request to populate. This
+ parameter is volatile-qualified because we expect the
+ caller to append it to a virtio ring, thus
+ assignments to Request must be visible when the
+ function returns.
+
+
+ @retval EFI_SUCCESS The Extended SCSI Pass Thru Protocol packet was valid,
+ Request has been populated.
+
+ @return Otherwise, invalid or unsupported parameters were
+ detected. Status codes are meant for direct forwarding
+ by the EFI_EXT_SCSI_PASS_THRU_PROTOCOL.PassThru()
+ implementation.
+
+**/
+STATIC
+EFI_STATUS
+EFIAPI
+PopulateRequest (
+ IN CONST VSCSI_DEV *Dev,
+ IN UINT16 Target,
+ IN UINT64 Lun,
+ IN OUT EFI_EXT_SCSI_PASS_THRU_SCSI_REQUEST_PACKET *Packet,
+ OUT volatile VIRTIO_SCSI_REQ *Request
+ )
+{
+ UINTN Idx;
+
+ if (
+ //
+ // bidirectional transfer was requested, but the host doesn't support it
+ //
+ (Packet->InTransferLength > 0 && Packet->OutTransferLength > 0 &&
+ !Dev->InOutSupported) ||
+
+ //
+ // a target / LUN was addressed that's impossible to encode for the host
+ //
+ Target > 0xFF || Lun >= 0x4000 ||
+
+ //
+ // Command Descriptor Block bigger than VIRTIO_SCSI_CDB_SIZE
+ //
+ Packet->CdbLength > VIRTIO_SCSI_CDB_SIZE ||
+
+ //
+ // From virtio-0.9.5, 2.3.2 Descriptor Table:
+ // "no descriptor chain may be more than 2^32 bytes long in total".
+ //
+ (UINT64) Packet->InTransferLength + Packet->OutTransferLength > SIZE_1GB
+ ) {
+
+ //
+ // this error code doesn't require updates to the Packet output fields
+ //
+ return EFI_UNSUPPORTED;
+ }
+
+ if (
+ //
+ // addressed invalid device
+ //
+ Target > Dev->MaxTarget || Lun > Dev->MaxLun ||
+
+ //
+ // invalid direction (there doesn't seem to be a macro for the "no data
+ // transferred" "direction", eg. for TEST UNIT READY)
+ //
+ Packet->DataDirection > EFI_EXT_SCSI_DATA_DIRECTION_BIDIRECTIONAL ||
+
+ //
+ // trying to receive, but destination pointer is NULL, or contradicting
+ // transfer direction
+ //
+ (Packet->InTransferLength > 0 &&
+ (Packet->InDataBuffer == NULL ||
+ Packet->DataDirection == EFI_EXT_SCSI_DATA_DIRECTION_WRITE
+ )
+ ) ||
+
+ //
+ // trying to send, but source pointer is NULL, or contradicting transfer
+ // direction
+ //
+ (Packet->OutTransferLength > 0 &&
+ (Packet->OutDataBuffer == NULL ||
+ Packet->DataDirection == EFI_EXT_SCSI_DATA_DIRECTION_READ
+ )
+ )
+ ) {
+
+ //
+ // this error code doesn't require updates to the Packet output fields
+ //
+ return EFI_INVALID_PARAMETER;
+ }
+
+ //
+ // Catch oversized requests eagerly. If this condition evaluates to false,
+ // then the combined size of a bidirectional request will not exceed the
+ // virtio-scsi device's transfer limit either.
+ //
+ if (ALIGN_VALUE (Packet->OutTransferLength, 512) / 512
+ > Dev->MaxSectors / 2 ||
+ ALIGN_VALUE (Packet->InTransferLength, 512) / 512
+ > Dev->MaxSectors / 2) {
+ Packet->InTransferLength = (Dev->MaxSectors / 2) * 512;
+ Packet->OutTransferLength = (Dev->MaxSectors / 2) * 512;
+ Packet->HostAdapterStatus =
+ EFI_EXT_SCSI_STATUS_HOST_ADAPTER_DATA_OVERRUN_UNDERRUN;
+ Packet->TargetStatus = EFI_EXT_SCSI_STATUS_TARGET_GOOD;
+ Packet->SenseDataLength = 0;
+ return EFI_BAD_BUFFER_SIZE;
+ }
+
+ //
+ // target & LUN encoding: see virtio-0.9.5, Appendix I: SCSI Host Device,
+ // Device Operation: request queues
+ //
+ Request->Lun[0] = 1;
+ Request->Lun[1] = (UINT8) Target;
+ Request->Lun[2] = (UINT8) ((Lun >> 8) | 0x40);
+ Request->Lun[3] = (UINT8) Lun;
+
+ //
+ // CopyMem() would cast away the "volatile" qualifier before access, which is
+ // undefined behavior (ISO C99 6.7.3p5)
+ //
+ for (Idx = 0; Idx < Packet->CdbLength; ++Idx) {
+ Request->Cdb[Idx] = ((UINT8 *) Packet->Cdb)[Idx];
+ }
+
+ return EFI_SUCCESS;
+}
+
+
+/**
+
+ Parse the virtio-scsi device's response, translate it to an EFI status code,
+ and update the Extended SCSI Pass Thru Protocol packet, to be returned by
+ the EFI_EXT_SCSI_PASS_THRU_PROTOCOL.PassThru() implementation.
+
+ @param[in out] Packet The Extended SCSI Pass Thru Protocol packet that has
+ been translated to a virtio-scsi request with
+ PopulateRequest(), and processed by the host. On
+ output this parameter is updated with response or
+ error contents.
+
+ @param[in] Response The virtio-scsi response structure to parse. We expect
+ it to come from a virtio ring, thus it is qualified
+ volatile.
+
+
+ @return PassThru() status codes mandated by UEFI Spec 2.3.1 + Errata C, 14.7
+ Extended SCSI Pass Thru Protocol.
+
+**/
+STATIC
+EFI_STATUS
+EFIAPI
+ParseResponse (
+ IN OUT EFI_EXT_SCSI_PASS_THRU_SCSI_REQUEST_PACKET *Packet,
+ IN CONST volatile VIRTIO_SCSI_RESP *Response
+ )
+{
+ UINTN ResponseSenseLen;
+ UINTN Idx;
+
+ //
+ // return sense data (length and contents) in all cases, truncated if needed
+ //
+ ResponseSenseLen = MIN (Response->SenseLen, VIRTIO_SCSI_SENSE_SIZE);
+ if (Packet->SenseDataLength > ResponseSenseLen) {
+ Packet->SenseDataLength = (UINT8) ResponseSenseLen;
+ }
+ for (Idx = 0; Idx < Packet->SenseDataLength; ++Idx) {
+ ((UINT8 *) Packet->SenseData)[Idx] = Response->Sense[Idx];
+ }
+
+ //
+ // Report actual transfer lengths. The logic below covers all three
+ // DataDirections (read, write, bidirectional).
+ //
+ // -+- @ 0
+ // |
+ // | write ^ @ Residual (unprocessed)
+ // | |
+ // -+- @ OutTransferLength -+- @ InTransferLength
+ // | |
+ // | read |
+ // | |
+ // V @ OutTransferLength + InTransferLength -+- @ 0
+ //
+ if (Response->Residual <= Packet->InTransferLength) {
+ Packet->InTransferLength -= Response->Residual;
+ }
+ else {
+ Packet->OutTransferLength -= Response->Residual - Packet->InTransferLength;
+ Packet->InTransferLength = 0;
+ }
+
+ //
+ // report target status in all cases
+ //
+ Packet->TargetStatus = Response->Status;
+
+ //
+ // host adapter status and function return value depend on virtio-scsi
+ // response code
+ //
+ switch (Response->Response) {
+ case VIRTIO_SCSI_S_OK:
+ Packet->HostAdapterStatus = EFI_EXT_SCSI_STATUS_HOST_ADAPTER_OK;
+ return EFI_SUCCESS;
+
+ case VIRTIO_SCSI_S_OVERRUN:
+ Packet->HostAdapterStatus =
+ EFI_EXT_SCSI_STATUS_HOST_ADAPTER_DATA_OVERRUN_UNDERRUN;
+ break;
+
+ case VIRTIO_SCSI_S_BAD_TARGET:
+ //
+ // This is non-intuitive but explicitly required by the
+ // EFI_EXT_SCSI_PASS_THRU_PROTOCOL.PassThru() specification for
+ // disconnected (but otherwise valid) target / LUN addresses.
+ //
+ Packet->HostAdapterStatus =
+ EFI_EXT_SCSI_STATUS_HOST_ADAPTER_TIMEOUT_COMMAND;
+ return EFI_TIMEOUT;
+
+ case VIRTIO_SCSI_S_RESET:
+ Packet->HostAdapterStatus = EFI_EXT_SCSI_STATUS_HOST_ADAPTER_BUS_RESET;
+ break;
+
+ case VIRTIO_SCSI_S_BUSY:
+ Packet->HostAdapterStatus = EFI_EXT_SCSI_STATUS_HOST_ADAPTER_OK;
+ return EFI_NOT_READY;
+
+ //
+ // Lump together the rest. The mapping for VIRTIO_SCSI_S_ABORTED is
+ // intentional as well, not an oversight.
+ //
+ case VIRTIO_SCSI_S_ABORTED:
+ case VIRTIO_SCSI_S_TRANSPORT_FAILURE:
+ case VIRTIO_SCSI_S_TARGET_FAILURE:
+ case VIRTIO_SCSI_S_NEXUS_FAILURE:
+ case VIRTIO_SCSI_S_FAILURE:
+ default:
+ Packet->HostAdapterStatus = EFI_EXT_SCSI_STATUS_HOST_ADAPTER_OTHER;
+ }
+
+ return EFI_DEVICE_ERROR;
+}
+
+
+//
+// The next seven functions implement EFI_EXT_SCSI_PASS_THRU_PROTOCOL
+// for the virtio-scsi HBA. Refer to UEFI Spec 2.3.1 + Errata C, sections
+// - 14.1 SCSI Driver Model Overview,
+// - 14.7 Extended SCSI Pass Thru Protocol.
+//
+
+EFI_STATUS
+EFIAPI
+VirtioScsiPassThru (
+ IN EFI_EXT_SCSI_PASS_THRU_PROTOCOL *This,
+ IN UINT8 *Target,
+ IN UINT64 Lun,
+ IN OUT EFI_EXT_SCSI_PASS_THRU_SCSI_REQUEST_PACKET *Packet,
+ IN EFI_EVENT Event OPTIONAL
+ )
+{
+ VSCSI_DEV *Dev;
+ UINT16 TargetValue;
+ EFI_STATUS Status;
+ volatile VIRTIO_SCSI_REQ Request;
+ volatile VIRTIO_SCSI_RESP Response;
+ DESC_INDICES Indices;
+
+ //
+ // Zero-initialization of Request & Response with "= { 0 };" doesn't build
+ // with gcc-4.4: "undefined reference to `memset'". Direct SetMem() is not
+ // allowed as it would cast away the volatile qualifier. Work it around.
+ //
+ union {
+ VIRTIO_SCSI_REQ Request;
+ VIRTIO_SCSI_RESP Response;
+ } Zero;
+
+ SetMem (&Zero, sizeof Zero, 0x00);
+ Request = Zero.Request;
+ Response = Zero.Response;
+
+ Dev = VIRTIO_SCSI_FROM_PASS_THRU (This);
+ CopyMem (&TargetValue, Target, sizeof TargetValue);
+
+ Status = PopulateRequest (Dev, TargetValue, Lun, Packet, &Request);
+ if (EFI_ERROR (Status)) {
+ return Status;
+ }
+
+ VirtioPrepare (&Dev->Ring, &Indices);
+
+ //
+ // preset a host status for ourselves that we do not accept as success
+ //
+ Response.Response = VIRTIO_SCSI_S_FAILURE;
+
+ //
+ // ensured by VirtioScsiInit() -- this predicate, in combination with the
+ // lock-step progress, ensures we don't have to track free descriptors.
+ //
+ ASSERT (Dev->Ring.QueueSize >= 4);
+
+ //
+ // enqueue Request
+ //
+ VirtioAppendDesc (&Dev->Ring, (UINTN) &Request, sizeof Request,
+ VRING_DESC_F_NEXT, &Indices);
+
+ //
+ // enqueue "dataout" if any
+ //
+ if (Packet->OutTransferLength > 0) {
+ VirtioAppendDesc (&Dev->Ring, (UINTN) Packet->OutDataBuffer,
+ Packet->OutTransferLength, VRING_DESC_F_NEXT, &Indices);
+ }
+
+ //
+ // enqueue Response, to be written by the host
+ //
+ VirtioAppendDesc (&Dev->Ring, (UINTN) &Response, sizeof Response,
+ VRING_DESC_F_WRITE | (Packet->InTransferLength > 0 ?
+ VRING_DESC_F_NEXT : 0),
+ &Indices);
+
+ //
+ // enqueue "datain" if any, to be written by the host
+ //
+ if (Packet->InTransferLength > 0) {
+ VirtioAppendDesc (&Dev->Ring, (UINTN) Packet->InDataBuffer,
+ Packet->InTransferLength, VRING_DESC_F_WRITE, &Indices);
+ }
+
+ // If kicking the host fails, we must fake a host adapter error.
+ // EFI_NOT_READY would save us the effort, but it would also suggest that the
+ // caller retry.
+ //
+ if (VirtioFlush (Dev->PciIo, VIRTIO_SCSI_REQUEST_QUEUE, &Dev->Ring,
+ &Indices) != EFI_SUCCESS) {
+ Packet->InTransferLength = 0;
+ Packet->OutTransferLength = 0;
+ Packet->HostAdapterStatus = EFI_EXT_SCSI_STATUS_HOST_ADAPTER_OTHER;
+ Packet->TargetStatus = EFI_EXT_SCSI_STATUS_TARGET_GOOD;
+ Packet->SenseDataLength = 0;
+ return EFI_DEVICE_ERROR;
+ }
+
+ return ParseResponse (Packet, &Response);
+}
+
+
+EFI_STATUS
+EFIAPI
+VirtioScsiGetNextTargetLun (
+ IN EFI_EXT_SCSI_PASS_THRU_PROTOCOL *This,
+ IN OUT UINT8 **TargetPointer,
+ IN OUT UINT64 *Lun
+ )
+{
+ UINT8 *Target;
+ UINTN Idx;
+ UINT16 LastTarget;
+ VSCSI_DEV *Dev;
+
+ //
+ // the TargetPointer input parameter is unnecessarily a pointer-to-pointer
+ //
+ Target = *TargetPointer;
+
+ //
+ // Search for first non-0xFF byte. If not found, return first target & LUN.
+ //
+ for (Idx = 0; Idx < TARGET_MAX_BYTES && Target[Idx] == 0xFF; ++Idx)
+ ;
+ if (Idx == TARGET_MAX_BYTES) {
+ SetMem (Target, TARGET_MAX_BYTES, 0x00);
+ *Lun = 0;
+ return EFI_SUCCESS;
+ }
+
+ //
+ // see the TARGET_MAX_BYTES check in "VirtioScsi.h"
+ //
+ CopyMem (&LastTarget, Target, sizeof LastTarget);
+
+ //
+ // increment (target, LUN) pair if valid on input
+ //
+ Dev = VIRTIO_SCSI_FROM_PASS_THRU (This);
+ if (LastTarget > Dev->MaxTarget || *Lun > Dev->MaxLun) {
+ return EFI_INVALID_PARAMETER;
+ }
+
+ if (*Lun < Dev->MaxLun) {
+ ++*Lun;
+ return EFI_SUCCESS;
+ }
+
+ if (LastTarget < Dev->MaxTarget) {
+ *Lun = 0;
+ ++LastTarget;
+ CopyMem (Target, &LastTarget, sizeof LastTarget);
+ return EFI_SUCCESS;
+ }
+
+ return EFI_NOT_FOUND;
+}
+
+
+EFI_STATUS
+EFIAPI
+VirtioScsiBuildDevicePath (
+ IN EFI_EXT_SCSI_PASS_THRU_PROTOCOL *This,
+ IN UINT8 *Target,
+ IN UINT64 Lun,
+ IN OUT EFI_DEVICE_PATH_PROTOCOL **DevicePath
+ )
+{
+ UINT16 TargetValue;
+ VSCSI_DEV *Dev;
+ SCSI_DEVICE_PATH *ScsiDevicePath;
+
+ if (DevicePath == NULL) {
+ return EFI_INVALID_PARAMETER;
+ }
+
+ CopyMem (&TargetValue, Target, sizeof TargetValue);
+ Dev = VIRTIO_SCSI_FROM_PASS_THRU (This);
+ if (TargetValue > Dev->MaxTarget || Lun > Dev->MaxLun || Lun > 0xFFFF) {
+ return EFI_NOT_FOUND;
+ }
+
+ ScsiDevicePath = AllocatePool (sizeof *ScsiDevicePath);
+ if (ScsiDevicePath == NULL) {
+ return EFI_OUT_OF_RESOURCES;
+ }
+
+ ScsiDevicePath->Header.Type = MESSAGING_DEVICE_PATH;
+ ScsiDevicePath->Header.SubType = MSG_SCSI_DP;
+ ScsiDevicePath->Header.Length[0] = (UINT8) sizeof *ScsiDevicePath;
+ ScsiDevicePath->Header.Length[1] = (UINT8) (sizeof *ScsiDevicePath >> 8);
+ ScsiDevicePath->Pun = TargetValue;
+ ScsiDevicePath->Lun = (UINT16) Lun;
+
+ *DevicePath = &ScsiDevicePath->Header;
+ return EFI_SUCCESS;
+}
+
+
+EFI_STATUS
+EFIAPI
+VirtioScsiGetTargetLun (
+ IN EFI_EXT_SCSI_PASS_THRU_PROTOCOL *This,
+ IN EFI_DEVICE_PATH_PROTOCOL *DevicePath,
+ OUT UINT8 **TargetPointer,
+ OUT UINT64 *Lun
+ )
+{
+ SCSI_DEVICE_PATH *ScsiDevicePath;
+ VSCSI_DEV *Dev;
+ UINT8 *Target;
+
+ if (DevicePath == NULL || TargetPointer == NULL || *TargetPointer == NULL ||
+ Lun == NULL) {
+ return EFI_INVALID_PARAMETER;
+ }
+
+ if (DevicePath->Type != MESSAGING_DEVICE_PATH ||
+ DevicePath->SubType != MSG_SCSI_DP) {
+ return EFI_UNSUPPORTED;
+ }
+
+ ScsiDevicePath = (SCSI_DEVICE_PATH *) DevicePath;
+ Dev = VIRTIO_SCSI_FROM_PASS_THRU (This);
+ if (ScsiDevicePath->Pun > Dev->MaxTarget ||
+ ScsiDevicePath->Lun > Dev->MaxLun) {
+ return EFI_NOT_FOUND;
+ }
+
+ //
+ // a) the TargetPointer input parameter is unnecessarily a pointer-to-pointer
+ // b) see the TARGET_MAX_BYTES check in "VirtioScsi.h"
+ // c) ScsiDevicePath->Pun is an UINT16
+ //
+ Target = *TargetPointer;
+ CopyMem (Target, &ScsiDevicePath->Pun, 2);
+ SetMem (Target + 2, TARGET_MAX_BYTES - 2, 0x00);
+
+ *Lun = ScsiDevicePath->Lun;
+ return EFI_SUCCESS;
+}
+
+
+EFI_STATUS
+EFIAPI
+VirtioScsiResetChannel (
+ IN EFI_EXT_SCSI_PASS_THRU_PROTOCOL *This
+ )
+{
+ return EFI_UNSUPPORTED;
+}
+
+
+EFI_STATUS
+EFIAPI
+VirtioScsiResetTargetLun (
+ IN EFI_EXT_SCSI_PASS_THRU_PROTOCOL *This,
+ IN UINT8 *Target,
+ IN UINT64 Lun
+ )
+{
+ return EFI_UNSUPPORTED;
+}
+
+
+EFI_STATUS
+EFIAPI
+VirtioScsiGetNextTarget (
+ IN EFI_EXT_SCSI_PASS_THRU_PROTOCOL *This,
+ IN OUT UINT8 **TargetPointer
+ )
+{
+ UINT8 *Target;
+ UINTN Idx;
+ UINT16 LastTarget;
+ VSCSI_DEV *Dev;
+
+ //
+ // the TargetPointer input parameter is unnecessarily a pointer-to-pointer
+ //
+ Target = *TargetPointer;
+
+ //
+ // Search for first non-0xFF byte. If not found, return first target.
+ //
+ for (Idx = 0; Idx < TARGET_MAX_BYTES && Target[Idx] == 0xFF; ++Idx)
+ ;
+ if (Idx == TARGET_MAX_BYTES) {
+ SetMem (Target, TARGET_MAX_BYTES, 0x00);
+ return EFI_SUCCESS;
+ }
+
+ //
+ // see the TARGET_MAX_BYTES check in "VirtioScsi.h"
+ //
+ CopyMem (&LastTarget, Target, sizeof LastTarget);
+
+ //
+ // increment target if valid on input
+ //
+ Dev = VIRTIO_SCSI_FROM_PASS_THRU (This);
+ if (LastTarget > Dev->MaxTarget) {
+ return EFI_INVALID_PARAMETER;
+ }
+
+ if (LastTarget < Dev->MaxTarget) {
+ ++LastTarget;
+ CopyMem (Target, &LastTarget, sizeof LastTarget);
+ return EFI_SUCCESS;
+ }
+
+ return EFI_NOT_FOUND;
+}
+
+
+STATIC
+EFI_STATUS
+EFIAPI
+VirtioScsiInit (
+ IN OUT VSCSI_DEV *Dev
+ )
+{
+ UINT8 NextDevStat;
+ EFI_STATUS Status;
+
+ UINT32 Features;
+ UINT16 MaxChannel; // for validation only
+ UINT32 NumQueues; // for validation only
+ UINT16 QueueSize;
+
+ //
+ // Execute virtio-0.9.5, 2.2.1 Device Initialization Sequence.
+ //
+ NextDevStat = 0; // step 1 -- reset device
+ Status = VIRTIO_CFG_WRITE (Dev, Generic.VhdrDeviceStatus, NextDevStat);
+ if (EFI_ERROR (Status)) {
+ goto Failed;
+ }
+
+ NextDevStat |= VSTAT_ACK; // step 2 -- acknowledge device presence
+ Status = VIRTIO_CFG_WRITE (Dev, Generic.VhdrDeviceStatus, NextDevStat);
+ if (EFI_ERROR (Status)) {
+ goto Failed;
+ }
+
+ NextDevStat |= VSTAT_DRIVER; // step 3 -- we know how to drive it
+ Status = VIRTIO_CFG_WRITE (Dev, Generic.VhdrDeviceStatus, NextDevStat);
+ if (EFI_ERROR (Status)) {
+ goto Failed;
+ }
+
+ //
+ // step 4a -- retrieve and validate features
+ //
+ Status = VIRTIO_CFG_READ (Dev, Generic.VhdrDeviceFeatureBits, &Features);
+ if (EFI_ERROR (Status)) {
+ goto Failed;
+ }
+ Dev->InOutSupported = !!(Features & VIRTIO_SCSI_F_INOUT);
+
+ Status = VIRTIO_CFG_READ (Dev, VhdrMaxChannel, &MaxChannel);
+ if (EFI_ERROR (Status)) {
+ goto Failed;
+ }
+ if (MaxChannel != 0) {
+ //
+ // this driver is for a single-channel virtio-scsi HBA
+ //
+ Status = EFI_UNSUPPORTED;
+ goto Failed;
+ }
+
+ Status = VIRTIO_CFG_READ (Dev, VhdrNumQueues, &NumQueues);
+ if (EFI_ERROR (Status)) {
+ goto Failed;
+ }
+ if (NumQueues < 1) {
+ Status = EFI_UNSUPPORTED;
+ goto Failed;
+ }
+
+ Status = VIRTIO_CFG_READ (Dev, VhdrMaxTarget, &Dev->MaxTarget);
+ if (EFI_ERROR (Status)) {
+ goto Failed;
+ }
+ if (Dev->MaxTarget > PcdGet16 (PcdVirtioScsiMaxTargetLimit)) {
+ Dev->MaxTarget = PcdGet16 (PcdVirtioScsiMaxTargetLimit);
+ }
+
+ Status = VIRTIO_CFG_READ (Dev, VhdrMaxLun, &Dev->MaxLun);
+ if (EFI_ERROR (Status)) {
+ goto Failed;
+ }
+ if (Dev->MaxLun > PcdGet32 (PcdVirtioScsiMaxLunLimit)) {
+ Dev->MaxLun = PcdGet32 (PcdVirtioScsiMaxLunLimit);
+ }
+
+ Status = VIRTIO_CFG_READ (Dev, VhdrMaxSectors, &Dev->MaxSectors);
+ if (EFI_ERROR (Status)) {
+ goto Failed;
+ }
+ if (Dev->MaxSectors < 2) {
+ //
+ // We must be able to halve it for bidirectional transfers
+ // (see EFI_BAD_BUFFER_SIZE in PopulateRequest()).
+ //
+ Status = EFI_UNSUPPORTED;
+ goto Failed;
+ }
+
+ //
+ // step 4b -- allocate request virtqueue
+ //
+ Status = VIRTIO_CFG_WRITE (Dev, Generic.VhdrQueueSelect,
+ VIRTIO_SCSI_REQUEST_QUEUE);
+ if (EFI_ERROR (Status)) {
+ goto Failed;
+ }
+ Status = VIRTIO_CFG_READ (Dev, Generic.VhdrQueueSize, &QueueSize);
+ if (EFI_ERROR (Status)) {
+ goto Failed;
+ }
+ //
+ // VirtioScsiPassThru() uses at most four descriptors
+ //
+ if (QueueSize < 4) {
+ Status = EFI_UNSUPPORTED;
+ goto Failed;
+ }
+
+ Status = VirtioRingInit (QueueSize, &Dev->Ring);
+ if (EFI_ERROR (Status)) {
+ goto Failed;
+ }
+
+ //
+ // step 4c -- Report GPFN (guest-physical frame number) of queue. If anything
+ // fails from here on, we must release the ring resources.
+ //
+ Status = VIRTIO_CFG_WRITE (Dev, Generic.VhdrQueueAddress,
+ (UINTN) Dev->Ring.Base >> EFI_PAGE_SHIFT);
+ if (EFI_ERROR (Status)) {
+ goto ReleaseQueue;
+ }
+
+ //
+ // step 5 -- Report understood features and guest-tuneables. We want none of
+ // the known (or unknown) VIRTIO_SCSI_F_* or VIRTIO_F_* capabilities (see
+ // virtio-0.9.5, Appendices B and I), except bidirectional transfers.
+ //
+ Status = VIRTIO_CFG_WRITE (Dev, Generic.VhdrGuestFeatureBits,
+ Features & VIRTIO_SCSI_F_INOUT);
+ if (EFI_ERROR (Status)) {
+ goto ReleaseQueue;
+ }
+
+ //
+ // We expect these maximum sizes from the host. Since they are
+ // guest-negotiable, ask for them rather than just checking them.
+ //
+ Status = VIRTIO_CFG_WRITE (Dev, VhdrCdbSize, VIRTIO_SCSI_CDB_SIZE);
+ if (EFI_ERROR (Status)) {
+ goto ReleaseQueue;
+ }
+ Status = VIRTIO_CFG_WRITE (Dev, VhdrSenseSize, VIRTIO_SCSI_SENSE_SIZE);
+ if (EFI_ERROR (Status)) {
+ goto ReleaseQueue;
+ }
+
+ //
+ // step 6 -- initialization complete
+ //
+ NextDevStat |= VSTAT_DRIVER_OK;
+ Status = VIRTIO_CFG_WRITE (Dev, Generic.VhdrDeviceStatus, NextDevStat);
+ if (EFI_ERROR (Status)) {
+ goto ReleaseQueue;
+ }
+
+ //
+ // populate the exported interface's attributes
+ //
+ Dev->PassThru.Mode = &Dev->PassThruMode;
+ Dev->PassThru.PassThru = &VirtioScsiPassThru;
+ Dev->PassThru.GetNextTargetLun = &VirtioScsiGetNextTargetLun;
+ Dev->PassThru.BuildDevicePath = &VirtioScsiBuildDevicePath;
+ Dev->PassThru.GetTargetLun = &VirtioScsiGetTargetLun;
+ Dev->PassThru.ResetChannel = &VirtioScsiResetChannel;
+ Dev->PassThru.ResetTargetLun = &VirtioScsiResetTargetLun;
+ Dev->PassThru.GetNextTarget = &VirtioScsiGetNextTarget;
+
+ //
+ // AdapterId is a target for which no handle will be created during bus scan.
+ // Prevent any conflict with real devices.
+ //
+ Dev->PassThruMode.AdapterId = 0xFFFFFFFF;
+
+ //
+ // Set both physical and logical attributes for non-RAID SCSI channel. See
+ // Driver Writer's Guide for UEFI 2.3.1 v1.01, 20.1.5 Implementing Extended
+ // SCSI Pass Thru Protocol.
+ //
+ Dev->PassThruMode.Attributes = EFI_EXT_SCSI_PASS_THRU_ATTRIBUTES_PHYSICAL |
+ EFI_EXT_SCSI_PASS_THRU_ATTRIBUTES_LOGICAL;
+
+ //
+ // no restriction on transfer buffer alignment
+ //
+ Dev->PassThruMode.IoAlign = 0;
+
+ return EFI_SUCCESS;
+
+ReleaseQueue:
+ VirtioRingUninit (&Dev->Ring);
+
+Failed:
+ //
+ // Notify the host about our failure to setup: virtio-0.9.5, 2.2.2.1 Device
+ // Status. PCI IO access failure here should not mask the original error.
+ //
+ NextDevStat |= VSTAT_FAILED;
+ VIRTIO_CFG_WRITE (Dev, Generic.VhdrDeviceStatus, NextDevStat);
+
+ Dev->InOutSupported = FALSE;
+ Dev->MaxTarget = 0;
+ Dev->MaxLun = 0;
+ Dev->MaxSectors = 0;
+
+ return Status; // reached only via Failed above
+}
+
+
+
+STATIC
+VOID
+EFIAPI
+VirtioScsiUninit (
+ IN OUT VSCSI_DEV *Dev
+ )
+{
+ //
+ // Reset the virtual device -- see virtio-0.9.5, 2.2.2.1 Device Status. When
+ // VIRTIO_CFG_WRITE() returns, the host will have learned to stay away from
+ // the old comms area.
+ //
+ VIRTIO_CFG_WRITE (Dev, Generic.VhdrDeviceStatus, 0);
+
+ Dev->InOutSupported = FALSE;
+ Dev->MaxTarget = 0;
+ Dev->MaxLun = 0;
+ Dev->MaxSectors = 0;
+
+ VirtioRingUninit (&Dev->Ring);
+
+ SetMem (&Dev->PassThru, sizeof Dev->PassThru, 0x00);
+ SetMem (&Dev->PassThruMode, sizeof Dev->PassThruMode, 0x00);
+}
+
+
+//
+// Probe, start and stop functions of this driver, called by the DXE core for
+// specific devices.
+//
+// The following specifications document these interfaces:
+// - Driver Writer's Guide for UEFI 2.3.1 v1.01, 9 Driver Binding Protocol
+// - UEFI Spec 2.3.1 + Errata C, 10.1 EFI Driver Binding Protocol
+//
+// The implementation follows:
+// - Driver Writer's Guide for UEFI 2.3.1 v1.01
+// - 5.1.3.4 OpenProtocol() and CloseProtocol()
+// - 18 PCI Driver Design Guidelines
+// - 18.3 PCI drivers
+// - UEFI Spec 2.3.1 + Errata C
+// - 6.3 Protocol Handler Services
+// - 13.4 EFI PCI I/O Protocol
+//
+
+EFI_STATUS
+EFIAPI
+VirtioScsiDriverBindingSupported (
+ IN EFI_DRIVER_BINDING_PROTOCOL *This,
+ IN EFI_HANDLE DeviceHandle,
+ IN EFI_DEVICE_PATH_PROTOCOL *RemainingDevicePath
+ )
+{
+ EFI_STATUS Status;
+ EFI_PCI_IO_PROTOCOL *PciIo;
+ PCI_TYPE00 Pci;
+
+ //
+ // Attempt to open the device with the PciIo set of interfaces. On success,
+ // the protocol is "instantiated" for the PCI device. Covers duplicate open
+ // attempts (EFI_ALREADY_STARTED).
+ //
+ Status = gBS->OpenProtocol (
+ DeviceHandle, // candidate device
+ &gEfiPciIoProtocolGuid, // for generic PCI access
+ (VOID **)&PciIo, // handle to instantiate
+ This->DriverBindingHandle, // requestor driver identity
+ DeviceHandle, // ControllerHandle, according to
+ // the UEFI Driver Model
+ EFI_OPEN_PROTOCOL_BY_DRIVER // get exclusive PciIo access to
+ // the device; to be released
+ );
+ if (EFI_ERROR (Status)) {
+ return Status;
+ }
+
+ //
+ // Read entire PCI configuration header for more extensive check ahead.
+ //
+ Status = PciIo->Pci.Read (
+ PciIo, // (protocol, device)
+ // handle
+ EfiPciIoWidthUint32, // access width & copy
+ // mode
+ 0, // Offset
+ sizeof Pci / sizeof (UINT32), // Count
+ &Pci // target buffer
+ );
+
+ if (Status == EFI_SUCCESS) {
+ //
+ // virtio-0.9.5, 2.1 PCI Discovery
+ //
+ Status = (Pci.Hdr.VendorId == 0x1AF4 &&
+ Pci.Hdr.DeviceId >= 0x1000 && Pci.Hdr.DeviceId <= 0x103F &&
+ Pci.Hdr.RevisionID == 0x00 &&
+ Pci.Device.SubsystemID == 0x08) ? EFI_SUCCESS : EFI_UNSUPPORTED;
+ }
+
+ //
+ // We needed PCI IO access only transitorily, to see whether we support the
+ // device or not.
+ //
+ gBS->CloseProtocol (DeviceHandle, &gEfiPciIoProtocolGuid,
+ This->DriverBindingHandle, DeviceHandle);
+ return Status;
+}
+
+
+EFI_STATUS
+EFIAPI
+VirtioScsiDriverBindingStart (
+ IN EFI_DRIVER_BINDING_PROTOCOL *This,
+ IN EFI_HANDLE DeviceHandle,
+ IN EFI_DEVICE_PATH_PROTOCOL *RemainingDevicePath
+ )
+{
+ VSCSI_DEV *Dev;
+ EFI_STATUS Status;
+
+ Dev = (VSCSI_DEV *) AllocateZeroPool (sizeof *Dev);
+ if (Dev == NULL) {
+ return EFI_OUT_OF_RESOURCES;
+ }
+
+ Status = gBS->OpenProtocol (DeviceHandle, &gEfiPciIoProtocolGuid,
+ (VOID **)&Dev->PciIo, This->DriverBindingHandle,
+ DeviceHandle, EFI_OPEN_PROTOCOL_BY_DRIVER);
+ if (EFI_ERROR (Status)) {
+ goto FreeVirtioScsi;
+ }
+
+ //
+ // We must retain and ultimately restore the original PCI attributes of the
+ // device. See Driver Writer's Guide for UEFI 2.3.1 v1.01, 18.3 PCI drivers /
+ // 18.3.2 Start() and Stop().
+ //
+ // The third parameter ("Attributes", input) is ignored by the Get operation.
+ // The fourth parameter ("Result", output) is ignored by the Enable and Set
+ // operations.
+ //
+ // For virtio-scsi we only need IO space access.
+ //
+ Status = Dev->PciIo->Attributes (Dev->PciIo, EfiPciIoAttributeOperationGet,
+ 0, &Dev->OriginalPciAttributes);
+ if (EFI_ERROR (Status)) {
+ goto ClosePciIo;
+ }
+
+ Status = Dev->PciIo->Attributes (Dev->PciIo,
+ EfiPciIoAttributeOperationEnable,
+ EFI_PCI_IO_ATTRIBUTE_IO, NULL);
+ if (EFI_ERROR (Status)) {
+ goto ClosePciIo;
+ }
+
+ //
+ // PCI IO access granted, configure virtio-scsi device.
+ //
+ Status = VirtioScsiInit (Dev);
+ if (EFI_ERROR (Status)) {
+ goto RestorePciAttributes;
+ }
+
+ //
+ // Setup complete, attempt to export the driver instance's PassThru
+ // interface.
+ //
+ Dev->Signature = VSCSI_SIG;
+ Status = gBS->InstallProtocolInterface (&DeviceHandle,
+ &gEfiExtScsiPassThruProtocolGuid, EFI_NATIVE_INTERFACE,
+ &Dev->PassThru);
+ if (EFI_ERROR (Status)) {
+ goto UninitDev;
+ }
+
+ return EFI_SUCCESS;
+
+UninitDev:
+ VirtioScsiUninit (Dev);
+
+RestorePciAttributes:
+ Dev->PciIo->Attributes (Dev->PciIo, EfiPciIoAttributeOperationSet,
+ Dev->OriginalPciAttributes, NULL);
+
+ClosePciIo:
+ gBS->CloseProtocol (DeviceHandle, &gEfiPciIoProtocolGuid,
+ This->DriverBindingHandle, DeviceHandle);
+
+FreeVirtioScsi:
+ FreePool (Dev);
+
+ return Status;
+}
+
+
+EFI_STATUS
+EFIAPI
+VirtioScsiDriverBindingStop (
+ IN EFI_DRIVER_BINDING_PROTOCOL *This,
+ IN EFI_HANDLE DeviceHandle,
+ IN UINTN NumberOfChildren,
+ IN EFI_HANDLE *ChildHandleBuffer
+ )
+{
+ EFI_STATUS Status;
+ EFI_EXT_SCSI_PASS_THRU_PROTOCOL *PassThru;
+ VSCSI_DEV *Dev;
+
+ Status = gBS->OpenProtocol (
+ DeviceHandle, // candidate device
+ &gEfiExtScsiPassThruProtocolGuid, // retrieve the SCSI iface
+ (VOID **)&PassThru, // target pointer
+ This->DriverBindingHandle, // requestor driver ident.
+ DeviceHandle, // lookup req. for dev.
+ EFI_OPEN_PROTOCOL_GET_PROTOCOL // lookup only, no new ref.
+ );
+ if (EFI_ERROR (Status)) {
+ return Status;
+ }
+
+ Dev = VIRTIO_SCSI_FROM_PASS_THRU (PassThru);
+
+ //
+ // Handle Stop() requests for in-use driver instances gracefully.
+ //
+ Status = gBS->UninstallProtocolInterface (DeviceHandle,
+ &gEfiExtScsiPassThruProtocolGuid, &Dev->PassThru);
+ if (EFI_ERROR (Status)) {
+ return Status;
+ }
+
+ VirtioScsiUninit (Dev);
+
+ Dev->PciIo->Attributes (Dev->PciIo, EfiPciIoAttributeOperationSet,
+ Dev->OriginalPciAttributes, NULL);
+
+ gBS->CloseProtocol (DeviceHandle, &gEfiPciIoProtocolGuid,
+ This->DriverBindingHandle, DeviceHandle);
+
+ FreePool (Dev);
+
+ return EFI_SUCCESS;
+}
+
+
+//
+// The static object that groups the Supported() (ie. probe), Start() and
+// Stop() functions of the driver together. Refer to UEFI Spec 2.3.1 + Errata
+// C, 10.1 EFI Driver Binding Protocol.
+//
+STATIC EFI_DRIVER_BINDING_PROTOCOL gDriverBinding = {
+ &VirtioScsiDriverBindingSupported,
+ &VirtioScsiDriverBindingStart,
+ &VirtioScsiDriverBindingStop,
+ 0x10, // Version, must be in [0x10 .. 0xFFFFFFEF] for IHV-developed drivers
+ NULL, // ImageHandle, to be overwritten by
+ // EfiLibInstallDriverBindingComponentName2() in VirtioScsiEntryPoint()
+ NULL // DriverBindingHandle, ditto
+};
+
+
+//
+// The purpose of the following scaffolding (EFI_COMPONENT_NAME_PROTOCOL and
+// EFI_COMPONENT_NAME2_PROTOCOL implementation) is to format the driver's name
+// in English, for display on standard console devices. This is recommended for
+// UEFI drivers that follow the UEFI Driver Model. Refer to the Driver Writer's
+// Guide for UEFI 2.3.1 v1.01, 11 UEFI Driver and Controller Names.
+//
+// Device type names ("Virtio SCSI Host Device") are not formatted because the
+// driver supports only that device type. Therefore the driver name suffices
+// for unambiguous identification.
+//
+
+STATIC
+EFI_UNICODE_STRING_TABLE mDriverNameTable[] = {
+ { "eng;en", L"Virtio SCSI Host Driver" },
+ { NULL, NULL }
+};
+
+STATIC
+EFI_COMPONENT_NAME_PROTOCOL gComponentName;
+
+EFI_STATUS
+EFIAPI
+VirtioScsiGetDriverName (
+ IN EFI_COMPONENT_NAME_PROTOCOL *This,
+ IN CHAR8 *Language,
+ OUT CHAR16 **DriverName
+ )
+{
+ return LookupUnicodeString2 (
+ Language,
+ This->SupportedLanguages,
+ mDriverNameTable,
+ DriverName,
+ (BOOLEAN)(This == &gComponentName) // Iso639Language
+ );
+}
+
+EFI_STATUS
+EFIAPI
+VirtioScsiGetDeviceName (
+ IN EFI_COMPONENT_NAME_PROTOCOL *This,
+ IN EFI_HANDLE DeviceHandle,
+ IN EFI_HANDLE ChildHandle,
+ IN CHAR8 *Language,
+ OUT CHAR16 **ControllerName
+ )
+{
+ return EFI_UNSUPPORTED;
+}
+
+STATIC
+EFI_COMPONENT_NAME_PROTOCOL gComponentName = {
+ &VirtioScsiGetDriverName,
+ &VirtioScsiGetDeviceName,
+ "eng" // SupportedLanguages, ISO 639-2 language codes
+};
+
+STATIC
+EFI_COMPONENT_NAME2_PROTOCOL gComponentName2 = {
+ (EFI_COMPONENT_NAME2_GET_DRIVER_NAME) &VirtioScsiGetDriverName,
+ (EFI_COMPONENT_NAME2_GET_CONTROLLER_NAME) &VirtioScsiGetDeviceName,
+ "en" // SupportedLanguages, RFC 4646 language codes
+};
+
+
+//
+// Entry point of this driver.
+//
+EFI_STATUS
+EFIAPI
+VirtioScsiEntryPoint (
+ IN EFI_HANDLE ImageHandle,
+ IN EFI_SYSTEM_TABLE *SystemTable
+ )
+{
+ return EfiLibInstallDriverBindingComponentName2 (
+ ImageHandle,
+ SystemTable,
+ &gDriverBinding,
+ ImageHandle,
+ &gComponentName,
+ &gComponentName2
+ );
+}
diff --git a/edk2/OvmfPkg/VirtioScsiDxe/VirtioScsi.h b/edk2/OvmfPkg/VirtioScsiDxe/VirtioScsi.h
new file mode 100644
index 000000000..f5220b221
--- /dev/null
+++ b/edk2/OvmfPkg/VirtioScsiDxe/VirtioScsi.h
@@ -0,0 +1,209 @@
+/** @file
+
+ Internal definitions for the virtio-scsi driver, which produces Extended SCSI
+ Pass Thru Protocol instances for virtio-scsi devices.
+
+ Copyright (C) 2012, Red Hat, Inc.
+
+ This program and the accompanying materials are licensed and made available
+ under the terms and conditions of the BSD License which accompanies this
+ distribution. The full text of the license may be found at
+ http://opensource.org/licenses/bsd-license.php
+
+ THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, WITHOUT
+ WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+
+**/
+
+#ifndef _VIRTIO_SCSI_DXE_H_
+#define _VIRTIO_SCSI_DXE_H_
+
+#include <Protocol/ComponentName.h>
+#include <Protocol/DriverBinding.h>
+#include <Protocol/PciIo.h>
+#include <Protocol/ScsiPassThruExt.h>
+
+#include <IndustryStandard/Virtio.h>
+
+
+//
+// This driver supports 2-byte target identifiers and 4-byte LUN identifiers.
+//
+// EFI_EXT_SCSI_PASS_THRU_PROTOCOL provides TARGET_MAX_BYTES bytes for target
+// identification, and 8 bytes for LUN identification.
+//
+// EFI_EXT_SCSI_PASS_THRU_MODE.AdapterId is also a target identifier,
+// consisting of 4 bytes. Make sure TARGET_MAX_BYTES can accomodate both
+// AdapterId and our target identifiers.
+//
+#if TARGET_MAX_BYTES < 4
+# error "virtio-scsi requires TARGET_MAX_BYTES >= 4"
+#endif
+
+
+#define VSCSI_SIG SIGNATURE_32 ('V', 'S', 'C', 'S')
+
+typedef struct {
+ //
+ // Parts of this structure are initialized / torn down in various functions
+ // at various call depths. The table to the right should make it easier to
+ // track them.
+ //
+ // field init function init depth
+ // ---------------------- ------------------ ----------
+ UINT32 Signature; // DriverBindingStart 0
+ EFI_PCI_IO_PROTOCOL *PciIo; // DriverBindingStart 0
+ UINT64 OriginalPciAttributes; // DriverBindingStart 0
+ BOOLEAN InOutSupported; // VirtioScsiInit 1
+ UINT16 MaxTarget; // VirtioScsiInit 1
+ UINT32 MaxLun; // VirtioScsiInit 1
+ UINT32 MaxSectors; // VirtioScsiInit 1
+ VRING Ring; // VirtioRingInit 2
+ EFI_EXT_SCSI_PASS_THRU_PROTOCOL PassThru; // VirtioScsiInit 1
+ EFI_EXT_SCSI_PASS_THRU_MODE PassThruMode; // VirtioScsiInit 1
+} VSCSI_DEV;
+
+#define VIRTIO_SCSI_FROM_PASS_THRU(PassThruPointer) \
+ CR (PassThruPointer, VSCSI_DEV, PassThru, VSCSI_SIG)
+
+
+//
+// Probe, start and stop functions of this driver, called by the DXE core for
+// specific devices.
+//
+// The following specifications document these interfaces:
+// - Driver Writer's Guide for UEFI 2.3.1 v1.01, 9 Driver Binding Protocol
+// - UEFI Spec 2.3.1 + Errata C, 10.1 EFI Driver Binding Protocol
+//
+
+EFI_STATUS
+EFIAPI
+VirtioScsiDriverBindingSupported (
+ IN EFI_DRIVER_BINDING_PROTOCOL *This,
+ IN EFI_HANDLE DeviceHandle,
+ IN EFI_DEVICE_PATH_PROTOCOL *RemainingDevicePath
+ );
+
+
+EFI_STATUS
+EFIAPI
+VirtioScsiDriverBindingStart (
+ IN EFI_DRIVER_BINDING_PROTOCOL *This,
+ IN EFI_HANDLE DeviceHandle,
+ IN EFI_DEVICE_PATH_PROTOCOL *RemainingDevicePath
+ );
+
+
+EFI_STATUS
+EFIAPI
+VirtioScsiDriverBindingStop (
+ IN EFI_DRIVER_BINDING_PROTOCOL *This,
+ IN EFI_HANDLE DeviceHandle,
+ IN UINTN NumberOfChildren,
+ IN EFI_HANDLE *ChildHandleBuffer
+ );
+
+
+//
+// The next seven functions implement EFI_EXT_SCSI_PASS_THRU_PROTOCOL
+// for the virtio-scsi HBA. Refer to UEFI Spec 2.3.1 + Errata C, sections
+// - 14.1 SCSI Driver Model Overview,
+// - 14.7 Extended SCSI Pass Thru Protocol.
+//
+
+EFI_STATUS
+EFIAPI
+VirtioScsiPassThru (
+ IN EFI_EXT_SCSI_PASS_THRU_PROTOCOL *This,
+ IN UINT8 *Target,
+ IN UINT64 Lun,
+ IN OUT EFI_EXT_SCSI_PASS_THRU_SCSI_REQUEST_PACKET *Packet,
+ IN EFI_EVENT Event OPTIONAL
+ );
+
+
+EFI_STATUS
+EFIAPI
+VirtioScsiGetNextTargetLun (
+ IN EFI_EXT_SCSI_PASS_THRU_PROTOCOL *This,
+ IN OUT UINT8 **Target,
+ IN OUT UINT64 *Lun
+ );
+
+
+EFI_STATUS
+EFIAPI
+VirtioScsiBuildDevicePath (
+ IN EFI_EXT_SCSI_PASS_THRU_PROTOCOL *This,
+ IN UINT8 *Target,
+ IN UINT64 Lun,
+ IN OUT EFI_DEVICE_PATH_PROTOCOL **DevicePath
+ );
+
+
+EFI_STATUS
+EFIAPI
+VirtioScsiGetTargetLun (
+ IN EFI_EXT_SCSI_PASS_THRU_PROTOCOL *This,
+ IN EFI_DEVICE_PATH_PROTOCOL *DevicePath,
+ OUT UINT8 **Target,
+ OUT UINT64 *Lun
+ );
+
+
+EFI_STATUS
+EFIAPI
+VirtioScsiResetChannel (
+ IN EFI_EXT_SCSI_PASS_THRU_PROTOCOL *This
+ );
+
+
+EFI_STATUS
+EFIAPI
+VirtioScsiResetTargetLun (
+ IN EFI_EXT_SCSI_PASS_THRU_PROTOCOL *This,
+ IN UINT8 *Target,
+ IN UINT64 Lun
+ );
+
+
+EFI_STATUS
+EFIAPI
+VirtioScsiGetNextTarget (
+ IN EFI_EXT_SCSI_PASS_THRU_PROTOCOL *This,
+ IN OUT UINT8 **Target
+ );
+
+
+//
+// The purpose of the following scaffolding (EFI_COMPONENT_NAME_PROTOCOL and
+// EFI_COMPONENT_NAME2_PROTOCOL implementation) is to format the driver's name
+// in English, for display on standard console devices. This is recommended for
+// UEFI drivers that follow the UEFI Driver Model. Refer to the Driver Writer's
+// Guide for UEFI 2.3.1 v1.01, 11 UEFI Driver and Controller Names.
+//
+// Device type names ("Virtio SCSI Host Device") are not formatted because the
+// driver supports only that device type. Therefore the driver name suffices
+// for unambiguous identification.
+//
+
+EFI_STATUS
+EFIAPI
+VirtioScsiGetDriverName (
+ IN EFI_COMPONENT_NAME_PROTOCOL *This,
+ IN CHAR8 *Language,
+ OUT CHAR16 **DriverName
+ );
+
+
+EFI_STATUS
+EFIAPI
+VirtioScsiGetDeviceName (
+ IN EFI_COMPONENT_NAME_PROTOCOL *This,
+ IN EFI_HANDLE DeviceHandle,
+ IN EFI_HANDLE ChildHandle,
+ IN CHAR8 *Language,
+ OUT CHAR16 **ControllerName
+ );
+
+#endif // _VIRTIO_SCSI_DXE_H_
diff --git a/edk2/OvmfPkg/VirtioScsiDxe/VirtioScsi.inf b/edk2/OvmfPkg/VirtioScsiDxe/VirtioScsi.inf
new file mode 100644
index 000000000..8209c5027
--- /dev/null
+++ b/edk2/OvmfPkg/VirtioScsiDxe/VirtioScsi.inf
@@ -0,0 +1,47 @@
+## @file
+# This driver produces Extended SCSI Pass Thru Protocol instances for
+# virtio-scsi devices.
+#
+# Copyright (C) 2012, Red Hat, Inc.
+#
+# This program and the accompanying materials are licensed and made available
+# under the terms and conditions of the BSD License which accompanies this
+# distribution. The full text of the license may be found at
+# http://opensource.org/licenses/bsd-license.php
+#
+# THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, WITHOUT
+# WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+#
+##
+
+[Defines]
+ INF_VERSION = 0x00010005
+ BASE_NAME = VirtioScsiDxe
+ FILE_GUID = FAB5D4F4-83C0-4AAF-8480-442D11DF6CEA
+ MODULE_TYPE = UEFI_DRIVER
+ VERSION_STRING = 1.0
+ ENTRY_POINT = VirtioScsiEntryPoint
+
+[Sources]
+ VirtioScsi.c
+
+[Packages]
+ MdePkg/MdePkg.dec
+ OvmfPkg/OvmfPkg.dec
+
+[LibraryClasses]
+ BaseMemoryLib
+ DebugLib
+ MemoryAllocationLib
+ UefiBootServicesTableLib
+ UefiDriverEntryPoint
+ UefiLib
+ VirtioLib
+
+[Protocols]
+ gEfiExtScsiPassThruProtocolGuid ## BY_START
+ gEfiPciIoProtocolGuid ## TO_START
+
+[Pcd]
+ gUefiOvmfPkgTokenSpaceGuid.PcdVirtioScsiMaxTargetLimit ## CONSUMES
+ gUefiOvmfPkgTokenSpaceGuid.PcdVirtioScsiMaxLunLimit ## CONSUMES
diff --git a/edk2/PandaBoardPkg/Debugger_scripts/rvi_convert_symbols.sh b/edk2/PandaBoardPkg/Debugger_scripts/rvi_convert_symbols.sh
index 9567f5c62..9567f5c62 100755..100644
--- a/edk2/PandaBoardPkg/Debugger_scripts/rvi_convert_symbols.sh
+++ b/edk2/PandaBoardPkg/Debugger_scripts/rvi_convert_symbols.sh
diff --git a/edk2/PandaBoardPkg/Debugger_scripts/rvi_symbols_macros.inc b/edk2/PandaBoardPkg/Debugger_scripts/rvi_symbols_macros.inc
index 9e7f42774..9e7f42774 100755..100644
--- a/edk2/PandaBoardPkg/Debugger_scripts/rvi_symbols_macros.inc
+++ b/edk2/PandaBoardPkg/Debugger_scripts/rvi_symbols_macros.inc
diff --git a/edk2/PandaBoardPkg/Debugger_scripts/rvi_unload_symbols.inc b/edk2/PandaBoardPkg/Debugger_scripts/rvi_unload_symbols.inc
index 546c4f960..546c4f960 100755..100644
--- a/edk2/PandaBoardPkg/Debugger_scripts/rvi_unload_symbols.inc
+++ b/edk2/PandaBoardPkg/Debugger_scripts/rvi_unload_symbols.inc
diff --git a/edk2/PandaBoardPkg/Debugger_scripts/trace32_load_symbols.cmm b/edk2/PandaBoardPkg/Debugger_scripts/trace32_load_symbols.cmm
index c2178e26b..c70a67393 100644
--- a/edk2/PandaBoardPkg/Debugger_scripts/trace32_load_symbols.cmm
+++ b/edk2/PandaBoardPkg/Debugger_scripts/trace32_load_symbols.cmm
@@ -178,7 +178,7 @@ load_symbol_file:
ENTRY &filestring
// the below has to be customized per your environment
- &filestring="y:"+string.mid("&filestring", 32., string.len("&filestring"))
+ &filestring="x:"+string.mid("&filestring", 36., string.len("&filestring"))
PRINT "&filestring 0x" &load_address
TDIAG Data.load.elf &filestring &load_address /nocode /noclear
diff --git a/edk2/PandaBoardPkg/Library/PandaBoardLib/PandaBoard.c b/edk2/PandaBoardPkg/Library/PandaBoardLib/PandaBoard.c
index c04fc6af6..c04fc6af6 100755..100644
--- a/edk2/PandaBoardPkg/Library/PandaBoardLib/PandaBoard.c
+++ b/edk2/PandaBoardPkg/Library/PandaBoardLib/PandaBoard.c
diff --git a/edk2/PandaBoardPkg/Library/PandaBoardLib/PandaBoardHelper.S b/edk2/PandaBoardPkg/Library/PandaBoardLib/PandaBoardHelper.S
index 26624b80f..26624b80f 100755..100644
--- a/edk2/PandaBoardPkg/Library/PandaBoardLib/PandaBoardHelper.S
+++ b/edk2/PandaBoardPkg/Library/PandaBoardLib/PandaBoardHelper.S
diff --git a/edk2/PandaBoardPkg/PandaBoardPkg.dsc b/edk2/PandaBoardPkg/PandaBoardPkg.dsc
index fc62a5819..c99775912 100644
--- a/edk2/PandaBoardPkg/PandaBoardPkg.dsc
+++ b/edk2/PandaBoardPkg/PandaBoardPkg.dsc
@@ -77,6 +77,7 @@
# PeCoffExtraActionLib|ArmPkg/Library/RvdPeCoffExtraActionLib/RvdPeCoffExtraActionLib.inf
PeCoffExtraActionLib|ArmPkg/Library/DebugPeCoffExtraActionLib/DebugPeCoffExtraActionLib.inf
# PeCoffExtraActionLib|MdePkg/Library/BasePeCoffExtraActionLibNull/BasePeCoffExtraActionLibNull.inf
+
CacheMaintenanceLib|ArmPkg/Library/ArmCacheMaintenanceLib/ArmCacheMaintenanceLib.inf
DefaultExceptionHandlerLib|ArmPkg/Library/DefaultExceptionHandlerLib/DefaultExceptionHandlerLib.inf
@@ -85,7 +86,7 @@
SerialPortLib|Omap44xxPkg/Library/SerialPortLib/SerialPortLib.inf
SemihostLib|ArmPkg/Library/SemihostLib/SemihostLib.inf
-
+
RealTimeClockLib|Omap44xxPkg/Library/RealTimeClockLib/RealTimeClockLib.inf
IoLib|MdePkg/Library/BaseIoLibIntrinsic/BaseIoLibIntrinsic.inf
@@ -192,6 +193,7 @@
UefiDecompressLib|IntelFrameworkModulePkg/Library/BaseUefiTianoCustomDecompressLib/BaseUefiTianoCustomDecompressLib.inf
ExtractGuidedSectionLib|MdePkg/Library/DxeExtractGuidedSectionLib/DxeExtractGuidedSectionLib.inf
PerformanceLib|MdeModulePkg/Library/DxePerformanceLib/DxePerformanceLib.inf
+ DxeServicesLib|MdePkg/Library/DxeServicesLib/DxeServicesLib.inf
[LibraryClasses.common.DXE_RUNTIME_DRIVER]
HobLib|MdePkg/Library/DxeHobLib/DxeHobLib.inf
@@ -262,7 +264,7 @@
gEmbeddedTokenSpaceGuid.PcdEmbeddedPrompt|"PandaEdk2"
gEmbeddedTokenSpaceGuid.PcdPrePiCpuMemorySize|32
gEmbeddedTokenSpaceGuid.PcdPrePiCpuIoSize|0
- gArmPlatformTokenSpaceGuid.PcdCoreCount|4
+ gArmPlatformTokenSpaceGuid.PcdCoreCount|2
gEfiMdePkgTokenSpaceGuid.PcdMaximumUnicodeStringLength|1000000
gEfiMdePkgTokenSpaceGuid.PcdMaximumAsciiStringLength|1000000
gEfiMdePkgTokenSpaceGuid.PcdMaximumLinkedListLength|1000000
@@ -342,9 +344,6 @@
gArmTokenSpaceGuid.PcdGicDistributorBase|0x48241000
gArmTokenSpaceGuid.PcdGicInterruptInterfaceBase|0x48240100
- gEmbeddedTokenSpaceGuid.PcdMemoryBase|0x80000000
- gEmbeddedTokenSpaceGuid.PcdMemorySize|0x08000000
-
gArmTokenSpaceGuid.PcdSystemMemoryBase|0x80000000
gArmTokenSpaceGuid.PcdSystemMemorySize|0x08000000
@@ -367,12 +366,10 @@
gArmTokenSpaceGuid.PcdArmUncachedMemoryMask|0x0000000040000000
gArmPlatformTokenSpaceGuid.PcdDefaultBootDescription|L"Linux from SD"
- gArmPlatformTokenSpaceGuid.PcdDefaultBootDevicePath|L"VenHw(100C2CFA-B586-4198-9B4C-1683D195B1DA)/HD(1,MBR,0x00000000,0x3F,0x2348A)/zImage"
-
- gArmPlatformTokenSpaceGuid.PcdDefaultBootArgument|"console=ttyO2,115200n8 mem=456M@0x80000000 root=/dev/mmcblk0p2 rw rootdelay=2 init=/linuxrc vram='10M' omapfb.vram='0:4M' earlyprintk loglevel=7"
-
- gArmPlatformTokenSpaceGuid.PcdDefaultBootType|1
+ gArmPlatformTokenSpaceGuid.PcdDefaultBootDevicePath|L"VenHw(100C2CFA-B586-4198-9B4C-1683D195B1DA)/HD(1,MBR,0xB663049F,0x3F,0x13986)/zImage"
+ gArmPlatformTokenSpaceGuid.PcdDefaultBootType|2
gArmPlatformTokenSpaceGuid.PcdPlatformBootTimeOut|3
+ gArmPlatformTokenSpaceGuid.PcdFdtDevicePath|L"VenHw(100C2CFA-B586-4198-9B4C-1683D195B1DA)/HD(1,MBR,0xB663049F,0x3F,0x13986)/omap4-panda.dtb"
gArmPlatformTokenSpaceGuid.PcdDefaultConOutPaths|L"VenHw(D3987D4B-971A-435F-8CAF-4967EB627241)/Uart(115200,8,N,1)/VenPcAnsi();VenHw(E68088EF-D1A4-4336-C1DB-4D3A204730A6)"
gArmPlatformTokenSpaceGuid.PcdDefaultConInPaths|L"VenHw(D3987D4B-971A-435F-8CAF-4967EB627241)/Uart(115200,8,N,1)/VenPcAnsi()"
@@ -381,7 +378,7 @@
# ARM OS Loader
#
# PandaBoard machine type required for ARM Linux:
- gArmTokenSpaceGuid.PcdArmMachineType|2160
+ gArmTokenSpaceGuid.PcdArmMachineType|2791
################################################################################
#
@@ -420,8 +417,7 @@
MdeModulePkg/Universal/Console/ConSplitterDxe/ConSplitterDxe.inf
MdeModulePkg/Universal/Console/GraphicsConsoleDxe/GraphicsConsoleDxe.inf
EmbeddedPkg/SerialDxe/SerialDxe.inf
- MdeModulePkg/Universal/Console/TerminalDxe/TerminalDxe.inf
-
+ MdeModulePkg/Universal/Console/TerminalDxe/TerminalDxe.inf
#
# This version uses semi-hosting console
# EmbeddedPkg/SimpleTextInOutSerial/SimpleTextInOutSerial.inf {
@@ -432,11 +428,6 @@
EmbeddedPkg/ResetRuntimeDxe/ResetRuntimeDxe.inf
EmbeddedPkg/RealTimeClockRuntimeDxe/RealTimeClockRuntimeDxe.inf
EmbeddedPkg/MetronomeDxe/MetronomeDxe.inf
-
- #
- # Semi-hosting filesystem
- #
- ArmPkg/Filesystem/SemihostFs/SemihostFs.inf
#
# FAT filesystem + GPT/MBR partitioning
@@ -462,11 +453,6 @@
MdeModulePkg/Bus/Usb/UsbMassStorageDxe/UsbMassStorageDxe.inf
#
- # Nand Flash
- #
- Omap44xxPkg/Flash/Flash.inf
-
- #
# MMC/SD
#
EmbeddedPkg/Universal/MmcDxe/MmcDxe.inf
@@ -481,15 +467,13 @@
# SoC Drivers
#
Omap44xxPkg/Gpio/Gpio.inf
-# Omap44xxPkg/InterruptDxe/InterruptDxe.inf
-
Omap44xxPkg/TimerDxe/TimerDxe.inf
Omap44xxPkg/LcdGraphicsOutputDxe/LcdGraphicsOutputDxe.inf
#
# Power IC
#
- Omap44xxPkg/TPS65950Dxe/TPS65950.inf
+ Omap44xxPkg/TWL6030Dxe/TWL6030.inf
#
# Application
diff --git a/edk2/PandaBoardPkg/PandaBoardPkg.fdf b/edk2/PandaBoardPkg/PandaBoardPkg.fdf
index 4b86f6957..04486dfd7 100644
--- a/edk2/PandaBoardPkg/PandaBoardPkg.fdf
+++ b/edk2/PandaBoardPkg/PandaBoardPkg.fdf
@@ -28,10 +28,10 @@
[FD.PandaBoard_EFI]
BaseAddress = 0x80008000|gArmTokenSpaceGuid.PcdFdBaseAddress #The base address of the FLASH Device.
-Size = 0x00080000|gArmTokenSpaceGuid.PcdFdSize #The size in bytes of the FLASH Device
+Size = 0x00100000|gArmTokenSpaceGuid.PcdFdSize #The size in bytes of the FLASH Device
ErasePolarity = 1
BlockSize = 0x1
-NumBlocks = 0x80000
+NumBlocks = 0x100000
################################################################################
#
@@ -49,12 +49,12 @@ NumBlocks = 0x80000
#
################################################################################
!if $(EDK2_SECOND_STAGE_BOOTOLADER) == 1
-0x00000000|0x00080000
+0x00000000|0x00100000
!else
# 512 bytes of configuration header & 8 bytes of image header
0x00000000|0x00000208
-0x00000208|0x0007FDF8
+0x00000208|0x000FFDF8
!endif
gArmTokenSpaceGuid.PcdFvBaseAddress|gArmTokenSpaceGuid.PcdFvSize
FV = FVMAIN_COMPACT
@@ -109,24 +109,12 @@ READ_LOCK_STATUS = TRUE
INF MdeModulePkg/Universal/Console/ConSplitterDxe/ConSplitterDxe.inf
INF MdeModulePkg/Universal/Console/GraphicsConsoleDxe/GraphicsConsoleDxe.inf
INF EmbeddedPkg/SerialDxe/SerialDxe.inf
- INF MdeModulePkg/Universal/Console/TerminalDxe/TerminalDxe.inf
+ INF MdeModulePkg/Universal/Console/TerminalDxe/TerminalDxe.inf
INF EmbeddedPkg/ResetRuntimeDxe/ResetRuntimeDxe.inf
INF EmbeddedPkg/RealTimeClockRuntimeDxe/RealTimeClockRuntimeDxe.inf
INF EmbeddedPkg/MetronomeDxe/MetronomeDxe.inf
-!if $(TARGET) == RELEASE
- #
- # Semi-hosting filesystem
- #
- INF ArmPkg/Filesystem/SemihostFs/SemihostFs.inf
-!endif
-
- #
- # Nand Flash
- #
- INF Omap44xxPkg/Flash/Flash.inf
-
#
# MMC/SD
#
@@ -142,16 +130,13 @@ READ_LOCK_STATUS = TRUE
# SoC Drivers
#
INF Omap44xxPkg/Gpio/Gpio.inf
-
-# INF Omap44xxPkg/InterruptDxe/InterruptDxe.inf
-
INF Omap44xxPkg/TimerDxe/TimerDxe.inf
INF Omap44xxPkg/LcdGraphicsOutputDxe/LcdGraphicsOutputDxe.inf
#
# Power IC
#
- INF Omap44xxPkg/TPS65950Dxe/TPS65950.inf
+ INF Omap44xxPkg/TWL6030Dxe/TWL6030.inf
#
# FAT filesystem + GPT/MBR partitioning
@@ -162,19 +147,18 @@ READ_LOCK_STATUS = TRUE
INF MdeModulePkg/Universal/Disk/UnicodeCollation/EnglishDxe/EnglishDxe.inf
#
- # USB Support
+ # USB Support (not supported currently)
#
- INF Omap44xxPkg/PciEmulation/PciEmulation.inf
-
- INF MdeModulePkg/Bus/Pci/EhciDxe/EhciDxe.inf
- INF MdeModulePkg/Bus/Usb/UsbBusDxe/UsbBusDxe.inf
- INF MdeModulePkg/Bus/Usb/UsbMassStorageDxe/UsbMassStorageDxe.inf
+ #INF Omap44xxPkg/PciEmulation/PciEmulation.inf
+ #INF MdeModulePkg/Bus/Pci/EhciDxe/EhciDxe.inf
+ #INF MdeModulePkg/Bus/Usb/UsbBusDxe/UsbBusDxe.inf
+ #INF MdeModulePkg/Bus/Usb/UsbMassStorageDxe/UsbMassStorageDxe.inf
#
# UEFI application (Shell Embedded Boot Loader)
#
- INF EmbeddedPkg/Ebl/Ebl.inf
+ INF ShellBinPkg/UefiShell/UefiShell.inf
#
# Bds
@@ -294,9 +278,23 @@ READ_LOCK_STATUS = TRUE
UI STRING="$(MODULE_NAME)" Optional
}
-
[Rule.Common.UEFI_APPLICATION]
FILE APPLICATION = $(NAMED_GUID) {
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/edk2/PandaBoardPkg/build.sh b/edk2/PandaBoardPkg/build.sh
index f1102062b..3c2c7a0c5 100755
--- a/edk2/PandaBoardPkg/build.sh
+++ b/edk2/PandaBoardPkg/build.sh
@@ -145,6 +145,7 @@ rm -f $FLASH_BOOT
#
$WORKSPACE/PandaBoardPkg/Tools/mkheader.pl $BUILD_ROOT/FV/PANDABOARD_EFI.fd $FLASH_BOOT
$GENERATE_IMAGE -p OMAP4 -i $WORKSPACE/PandaBoardPkg/ConfigurationHeader.dat -O $FLASH_BOOT
+rm -f $WORKSPACE/PandaBoardPkg/tmp.bin
cp $FLASH_BOOT $BUILD_ROOT/FV/MLO
echo Creating debugger scripts
diff --git a/edk2/PandaBoardPkg/readme.txt b/edk2/PandaBoardPkg/readme.txt
index 0d6f4b597..0d7a1ca9c 100644
--- a/edk2/PandaBoardPkg/readme.txt
+++ b/edk2/PandaBoardPkg/readme.txt
@@ -1,12 +1,28 @@
+Overview
+=========
+
+The Panda packages are hosted on http://gitorious.org/omap-romcode/omap-edk2
+This repository contains the latest developments concerning UEFI on PandaBoard.
+Contact: o-deprez@ti.com
+
+Patches from omap-edk2 tree are regularly merged on need basis to
+http://git.linaro.org/gitweb?p=arm/uefi/uefi-next.git by ARM LT team.
+
History
========
-PANDA_EDK2_080912
+11/09/2012 PANDA_EDK2_110912
+ Rebased to uefi-next commit-id 99af201b87a6048c26f372e3f75a46d291b2f683
+ Fix build.sh removing tmp.bin temporary file
+ Fix SerialPollGetControl with returning correct Control parm
+ Comment out Semihostfs from PandaBoardPkg.fdf
+
+08/09/2012 PANDA_EDK2_080912
Rebased to linaro-uefi-2012.04 label
Boots linux "OMAP Ubuntu Core" kernel
-PANDA_EDK2_062512
+06/25/2012 PANDA_EDK2_062512
First drop able to boot EBL
Environment setup
@@ -46,36 +62,8 @@ Note: the build was done an Ubuntu 10.04 machine.
Building
=========
- 1. Clone PandaBoardPkg/Omap44xxPkg
-
-cd $PANDA_UEFI
-git clone git://gitorious.org/omap-romcode/omap-edk2.git
-cd omap-edk2
-git checkout PANDA_EDK2_080912
-
- 2. Clone EDK2 from linaro
-
-cd $PANDA_UEFI
-git clone git://git.linaro.org/arm/uefi/uefi.git linaro-uefi-2012.04
-cd linaro-uefi-2012.04
-git checkout linaro-uefi-2012.04
-
- 3. Link Panda pkgs to EDK2
-
-ln -s $PANDA_UEFI/omap-edk2/PandaBoardPkg $PANDA_UEFI/linaro-uefi-2012.04/edk2
-ln -s $PANDA_UEFI/omap-edk2/Omap44xxPkg $PANDA_UEFI/linaro-uefi-2012.04/edk2
-
- 4. Apply PandaBoardPkg patch for fixing SD card driver
-
-patch -p1 < edk2/PandaBoardPkg/patches/0001-fixes-sd-card-identification-on-panda.patch
-patch -p1 < edk2/PandaBoardPkg/patches/0001-remove-ASSERT-because-serial-not-yet-initialized.patch
-
- 5. Apply base tools patches from ARM pkg
-
-cd edk2; patch -p1 < ArmPlatformPkg/Documentation/patches/BaseTools-Pending-Patches.patch
-[accept changes, push enter on default choice]
-
- 6. Build
+Build information is found on uefi-next summary page:
+http://git.linaro.org/gitweb?p=arm/uefi/uefi-next.git;a=summary
cd PandaBoardPkg
./build.sh RELEASE
@@ -91,7 +79,7 @@ Running EDK2 on Panda
If you just intend to see how UEFI boots up and make a try with EBL, you
can just do a raw copy of the firmware image to an SD card (e.g. /dev/sdc):
- dd if=$PANDA_UEFI/linaro-uefi-2012.04/edk2/Build/PandaBoard/RELEASE_ARMGCC/FV/MLO of=/dev/sdc
+ dd if=edk2/Build/PandaBoard/RELEASE_ARMGCC/FV/MLO of=/dev/sdc
Open your favorite serial terminal e.g.
minicom -b 115200 -D /dev/ttyS0 -8 --color=on -w -o
@@ -143,7 +131,7 @@ More information on how to format an SD card here:
*http://www.omappedia.com/wiki/SD_Configuration
5. Drop following files in FAT32 partition:
- $PANDA_UEFI/linaro-uefi-2012.04/edk2/Build/PandaBoard/RELEASE_ARMGCC/FV/MLO
+ edk2/Build/PandaBoard/RELEASE_ARMGCC/FV/MLO
linux/arch/arm/boot/zImage generated at step 1
6. Insert SD card and boot up Panda board.
@@ -159,9 +147,9 @@ PandaBoard ES Rev B1 - EBL (PANDA_EDK2_062512)
chtool
=======
-The PandaBoardPkg/Tools contains a tool called chtool for creating a Configuration Header
-block for use with the ROM Code boot sequence (in this port it serves as configuration of
-OMAP DPLLs, system clocks, and initlization of external SDRAM).
+The PandaBoardPkg/Tools directory contains a tool called chtool for creating
+a Configuration Header block for use with the ROM Code boot sequence (in this port
+it serves as configuration of OMAP DPLLs, system clocks, and initlization of external SDRAM).
This tool is tracked in the following tree: git://gitorious.org/omap-romcode/chtool.git
diff --git a/edk2/PcAtChipsetPkg/IsaAcpiDxe/IsaAcpi.c b/edk2/PcAtChipsetPkg/IsaAcpiDxe/IsaAcpi.c
index 119401627..7b1ab1c8d 100644
--- a/edk2/PcAtChipsetPkg/IsaAcpiDxe/IsaAcpi.c
+++ b/edk2/PcAtChipsetPkg/IsaAcpiDxe/IsaAcpi.c
@@ -1,7 +1,7 @@
/** @file
ISA ACPI Protocol Implementation
-Copyright (c) 2006 - 2011, Intel Corporation. All rights reserved.<BR>
+Copyright (c) 2006 - 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
which accompanies this distribution. The full text of the license may be found at
@@ -101,7 +101,7 @@ EFI_ISA_ACPI_RESOURCE_LIST mPcatIsaAcpiFloppyBDevice = {
//
// Table of ISA Controllers
//
-EFI_ISA_ACPI_RESOURCE_LIST gPcatIsaAcpiDeviceList[7] = {0};
+EFI_ISA_ACPI_RESOURCE_LIST gPcatIsaAcpiDeviceList[7] = {{{0, 0}, NULL}};
/**
Initialize gPcatIsaAcpiDeviceList.
diff --git a/edk2/PcAtChipsetPkg/PciHostBridgeDxe/PciHostBridge.c b/edk2/PcAtChipsetPkg/PciHostBridgeDxe/PciHostBridge.c
index 994bfeb60..f14700e3c 100644
--- a/edk2/PcAtChipsetPkg/PciHostBridgeDxe/PciHostBridge.c
+++ b/edk2/PcAtChipsetPkg/PciHostBridgeDxe/PciHostBridge.c
@@ -22,25 +22,38 @@ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
//
UINTN RootBridgeNumber[1] = { 1 };
-UINT64 RootBridgeAttribute[1][1] = { EFI_PCI_HOST_BRIDGE_COMBINE_MEM_PMEM };
+UINT64 RootBridgeAttribute[1][1] = { { EFI_PCI_HOST_BRIDGE_COMBINE_MEM_PMEM } };
EFI_PCI_ROOT_BRIDGE_DEVICE_PATH mEfiPciRootBridgeDevicePath[1][1] = {
{
- ACPI_DEVICE_PATH,
- ACPI_DP,
- (UINT8) (sizeof(ACPI_HID_DEVICE_PATH)),
- (UINT8) ((sizeof(ACPI_HID_DEVICE_PATH)) >> 8),
- EISA_PNP_ID(0x0A03),
- 0,
- END_DEVICE_PATH_TYPE,
- END_ENTIRE_DEVICE_PATH_SUBTYPE,
- END_DEVICE_PATH_LENGTH,
- 0
+ {
+ {
+ {
+ ACPI_DEVICE_PATH,
+ ACPI_DP,
+ {
+ (UINT8) (sizeof(ACPI_HID_DEVICE_PATH)),
+ (UINT8) ((sizeof(ACPI_HID_DEVICE_PATH)) >> 8)
+ }
+ },
+ EISA_PNP_ID(0x0A03),
+ 0
+ },
+
+ {
+ END_DEVICE_PATH_TYPE,
+ END_ENTIRE_DEVICE_PATH_SUBTYPE,
+ {
+ END_DEVICE_PATH_LENGTH,
+ 0
+ }
+ }
+ }
}
};
PCI_ROOT_BRIDGE_RESOURCE_APPETURE mResAppeture[1][1] = {
- {0, 0xff, 0x80000000, 0xffffffff, 0, 0xffff}
+ {{0, 0xff, 0x80000000, 0xffffffff, 0, 0xffff}}
};
EFI_HANDLE mDriverImageHandle;
diff --git a/edk2/SecurityPkg/Include/Library/TpmCommLib.h b/edk2/SecurityPkg/Include/Library/TpmCommLib.h
index 175dd8d9b..9bca341bb 100644
--- a/edk2/SecurityPkg/Include/Library/TpmCommLib.h
+++ b/edk2/SecurityPkg/Include/Library/TpmCommLib.h
@@ -2,7 +2,7 @@
Ihis library is only intended to be used by TPM modules.
It provides basic TPM Interface Specification (TIS) and Command functions.
-Copyright (c) 2005 - 2011, Intel Corporation. All rights reserved.<BR>
+Copyright (c) 2005 - 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
which accompanies this distribution. The full text of the license may be found at
@@ -185,6 +185,7 @@ typedef TIS_PC_REGISTERS *TIS_PC_REGISTERS_PTR;
//
// Default TimeOut value
//
+#define TIS_TIMEOUT_A 750 * 1000 // 750ms
#define TIS_TIMEOUT_B 2000 * 1000 // 2s
#define TIS_TIMEOUT_C 750 * 1000 // 750ms
#define TIS_TIMEOUT_D 750 * 1000 // 750ms
diff --git a/edk2/SecurityPkg/Library/DxeImageVerificationLib/DxeImageVerificationLib.c b/edk2/SecurityPkg/Library/DxeImageVerificationLib/DxeImageVerificationLib.c
index 9ea3a28ad..c41a379b8 100644
--- a/edk2/SecurityPkg/Library/DxeImageVerificationLib/DxeImageVerificationLib.c
+++ b/edk2/SecurityPkg/Library/DxeImageVerificationLib/DxeImageVerificationLib.c
@@ -56,7 +56,6 @@ CONST UINT8 mRsaE[] = { 0x01, 0x00, 0x01 };
// OID ASN.1 Value for Hash Algorithms
//
UINT8 mHashOidValue[] = {
- 0x2A, 0x86, 0x48, 0x86, 0xF7, 0x0D, 0x02, 0x05, // OBJ_md5
0x2B, 0x0E, 0x03, 0x02, 0x1A, // OBJ_sha1
0x60, 0x86, 0x48, 0x01, 0x65, 0x03, 0x04, 0x02, 0x04, // OBJ_sha224
0x60, 0x86, 0x48, 0x01, 0x65, 0x03, 0x04, 0x02, 0x01, // OBJ_sha256
@@ -65,11 +64,11 @@ UINT8 mHashOidValue[] = {
};
HASH_TABLE mHash[] = {
- { L"SHA1", 20, &mHashOidValue[8], 5, Sha1GetContextSize, Sha1Init, Sha1Update, Sha1Final },
- { L"SHA224", 28, &mHashOidValue[13], 9, NULL, NULL, NULL, NULL },
- { L"SHA256", 32, &mHashOidValue[22], 9, Sha256GetContextSize,Sha256Init, Sha256Update, Sha256Final},
- { L"SHA384", 48, &mHashOidValue[31], 9, NULL, NULL, NULL, NULL },
- { L"SHA512", 64, &mHashOidValue[40], 9, NULL, NULL, NULL, NULL }
+ { L"SHA1", 20, &mHashOidValue[0], 5, Sha1GetContextSize, Sha1Init, Sha1Update, Sha1Final },
+ { L"SHA224", 28, &mHashOidValue[5], 9, NULL, NULL, NULL, NULL },
+ { L"SHA256", 32, &mHashOidValue[14], 9, Sha256GetContextSize,Sha256Init, Sha256Update, Sha256Final},
+ { L"SHA384", 48, &mHashOidValue[23], 9, NULL, NULL, NULL, NULL },
+ { L"SHA512", 64, &mHashOidValue[32], 9, NULL, NULL, NULL, NULL }
};
/**
diff --git a/edk2/SecurityPkg/Library/TpmCommLib/TisPc.c b/edk2/SecurityPkg/Library/TpmCommLib/TisPc.c
index 3d74a012d..c157d41b7 100644
--- a/edk2/SecurityPkg/Library/TpmCommLib/TisPc.c
+++ b/edk2/SecurityPkg/Library/TpmCommLib/TisPc.c
@@ -1,7 +1,7 @@
/** @file
Basic TIS (TPM Interface Specification) functions.
-Copyright (c) 2005 - 2011, Intel Corporation. All rights reserved.<BR>
+Copyright (c) 2005 - 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
which accompanies this distribution. The full text of the license may be found at
@@ -144,7 +144,7 @@ TisPcPrepareCommand (
/**
Get the control of TPM chip by sending requestUse command TIS_PC_ACC_RQUUSE
- to ACCESS Register in the time of default TIS_TIMEOUT_D.
+ to ACCESS Register in the time of default TIS_TIMEOUT_A.
@param[in] TisReg Pointer to TIS register.
@@ -170,11 +170,14 @@ TisPcRequestUseTpm (
}
MmioWrite8((UINTN)&TisReg->Access, TIS_PC_ACC_RQUUSE);
+ //
+ // No locality set before, ACCESS_X.activeLocality MUST be valid within TIMEOUT_A
+ //
Status = TisPcWaitRegisterBits (
&TisReg->Access,
(UINT8)(TIS_PC_ACC_ACTIVE |TIS_PC_VALID),
0,
- TIS_TIMEOUT_D
+ TIS_TIMEOUT_A
);
return Status;
}
diff --git a/edk2/SecurityPkg/Tcg/TcgPei/TcgPei.c b/edk2/SecurityPkg/Tcg/TcgPei/TcgPei.c
index 60d919210..350e60e56 100644
--- a/edk2/SecurityPkg/Tcg/TcgPei/TcgPei.c
+++ b/edk2/SecurityPkg/Tcg/TcgPei/TcgPei.c
@@ -707,10 +707,17 @@ PeimEntryMA (
if (EFI_ERROR (Status) ) {
return Status;
}
- Status = TpmCommContinueSelfTest ((EFI_PEI_SERVICES**)PeiServices, TpmHandle);
- if (EFI_ERROR (Status)) {
- return Status;
+
+ //
+ // TpmSelfTest is optional on S3 path, skip it to save S3 time
+ //
+ if (BootMode != BOOT_ON_S3_RESUME) {
+ Status = TpmCommContinueSelfTest ((EFI_PEI_SERVICES**)PeiServices, TpmHandle);
+ if (EFI_ERROR (Status)) {
+ return Status;
+ }
}
+
Status = PeiServicesInstallPpi (&mTpmInitializedPpiList);
ASSERT_EFI_ERROR (Status);
}
diff --git a/edk2/SecurityPkg/VariableAuthenticated/RuntimeDxe/AuthService.c b/edk2/SecurityPkg/VariableAuthenticated/RuntimeDxe/AuthService.c
index cf8ad9969..6576e681c 100644
--- a/edk2/SecurityPkg/VariableAuthenticated/RuntimeDxe/AuthService.c
+++ b/edk2/SecurityPkg/VariableAuthenticated/RuntimeDxe/AuthService.c
@@ -1138,6 +1138,22 @@ ProcessVariable (
}
//
+ // A time-based authenticated variable and a count-based authenticated variable
+ // can't be updated by each other.
+ //
+ if (Variable->CurrPtr != NULL) {
+ if (((Attributes & EFI_VARIABLE_AUTHENTICATED_WRITE_ACCESS) != 0) &&
+ ((Variable->CurrPtr->Attributes & EFI_VARIABLE_TIME_BASED_AUTHENTICATED_WRITE_ACCESS) != 0)) {
+ return EFI_SECURITY_VIOLATION;
+ }
+
+ if (((Attributes & EFI_VARIABLE_TIME_BASED_AUTHENTICATED_WRITE_ACCESS) != 0) &&
+ ((Variable->CurrPtr->Attributes & EFI_VARIABLE_AUTHENTICATED_WRITE_ACCESS) != 0)) {
+ return EFI_SECURITY_VIOLATION;
+ }
+ }
+
+ //
// Process Time-based Authenticated variable.
//
if ((Attributes & EFI_VARIABLE_TIME_BASED_AUTHENTICATED_WRITE_ACCESS) != 0) {
diff --git a/edk2/ShellPkg/Application/Shell/Shell.c b/edk2/ShellPkg/Application/Shell/Shell.c
index 182f896db..3e4706c28 100644
--- a/edk2/ShellPkg/Application/Shell/Shell.c
+++ b/edk2/ShellPkg/Application/Shell/Shell.c
@@ -23,22 +23,24 @@ SHELL_INFO ShellInfoObject = {
FALSE,
FALSE,
{
- 0,
- 0,
- 0,
- 0,
- 0,
- 0,
- 0,
- 0,
- 0,
+ {{
+ 0,
+ 0,
+ 0,
+ 0,
+ 0,
+ 0,
+ 0,
+ 0,
+ 0
+ }},
0,
NULL,
NULL
},
- {0,0},
+ {{NULL, NULL}, NULL},
{
- {0,0},
+ {{NULL, NULL}, NULL},
0,
0,
TRUE
@@ -50,8 +52,12 @@ SHELL_INFO ShellInfoObject = {
NULL,
NULL,
NULL,
- {0,0,NULL,NULL},
- {0,0},
+ {{NULL, NULL}, NULL, NULL},
+ {{NULL, NULL}, NULL, NULL},
+ NULL,
+ NULL,
+ NULL,
+ NULL,
NULL,
NULL,
NULL,
diff --git a/edk2/ShellPkg/Library/UefiHandleParsingLib/UefiHandleParsingLib.c b/edk2/ShellPkg/Library/UefiHandleParsingLib/UefiHandleParsingLib.c
index e9e3d8204..37ac6e428 100644
--- a/edk2/ShellPkg/Library/UefiHandleParsingLib/UefiHandleParsingLib.c
+++ b/edk2/ShellPkg/Library/UefiHandleParsingLib/UefiHandleParsingLib.c
@@ -442,17 +442,17 @@ DevicePathProtocolDumpInformation(
//
#define LOCAL_EFI_WIN_NT_THUNK_PROTOCOL_GUID \
{ \
- 0x58c518b1, 0x76f3, 0x11d4, 0xbc, 0xea, 0x0, 0x80, 0xc7, 0x3c, 0x88, 0x81 \
+ 0x58c518b1, 0x76f3, 0x11d4, { 0xbc, 0xea, 0x0, 0x80, 0xc7, 0x3c, 0x88, 0x81 } \
}
#define LOCAL_EFI_WIN_NT_BUS_DRIVER_IO_PROTOCOL_GUID \
{ \
- 0x96eb4ad6, 0xa32a, 0x11d4, 0xbc, 0xfd, 0x0, 0x80, 0xc7, 0x3c, 0x88, 0x81 \
+ 0x96eb4ad6, 0xa32a, 0x11d4, { 0xbc, 0xfd, 0x0, 0x80, 0xc7, 0x3c, 0x88, 0x81 } \
}
#define LOCAL_EFI_WIN_NT_SERIAL_PORT_GUID \
{ \
- 0xc95a93d, 0xa006, 0x11d4, 0xbc, 0xfa, 0x0, 0x80, 0xc7, 0x3c, 0x88, 0x81 \
+ 0xc95a93d, 0xa006, 0x11d4, { 0xbc, 0xfa, 0x0, 0x80, 0xc7, 0x3c, 0x88, 0x81 } \
}
STATIC CONST EFI_GUID WinNtThunkProtocolGuid = LOCAL_EFI_WIN_NT_THUNK_PROTOCOL_GUID;
STATIC CONST EFI_GUID WinNtIoProtocolGuid = LOCAL_EFI_WIN_NT_BUS_DRIVER_IO_PROTOCOL_GUID;
@@ -948,7 +948,11 @@ ConvertHandleToHandleIndex(
IN CONST EFI_HANDLE TheHandle
)
{
- HANDLE_LIST *ListWalker;
+ EFI_STATUS Status;
+ EFI_GUID **ProtocolBuffer;
+ UINTN ProtocolCount;
+ HANDLE_LIST *ListWalker;
+
if (TheHandle == NULL) {
return 0;
}
@@ -960,9 +964,34 @@ ConvertHandleToHandleIndex(
; ListWalker = (HANDLE_LIST*)GetNextNode(&mHandleList.List.Link,&ListWalker->Link)
){
if (ListWalker->TheHandle == TheHandle) {
+ //
+ // Verify that TheHandle is still present in the Handle Database
+ //
+ Status = gBS->ProtocolsPerHandle(TheHandle, &ProtocolBuffer, &ProtocolCount);
+ if (EFI_ERROR (Status)) {
+ //
+ // TheHandle is not present in the Handle Database, so delete from the handle list
+ //
+ RemoveEntryList (&ListWalker->Link);
+ return 0;
+ }
+ FreePool (ProtocolBuffer);
return (ListWalker->TheIndex);
}
}
+
+ //
+ // Verify that TheHandle is valid handle
+ //
+ Status = gBS->ProtocolsPerHandle(TheHandle, &ProtocolBuffer, &ProtocolCount);
+ if (EFI_ERROR (Status)) {
+ //
+ // TheHandle is not valid, so do not add to handle list
+ //
+ return 0;
+ }
+ FreePool (ProtocolBuffer);
+
ListWalker = AllocateZeroPool(sizeof(HANDLE_LIST));
ASSERT(ListWalker != NULL);
ListWalker->TheHandle = TheHandle;
@@ -988,23 +1017,36 @@ ConvertHandleIndexToHandle(
IN CONST UINTN TheIndex
)
{
+ EFI_STATUS Status;
+ EFI_GUID **ProtocolBuffer;
+ UINTN ProtocolCount;
HANDLE_LIST *ListWalker;
InternalShellInitHandleList();
if (TheIndex >= mHandleList.NextIndex) {
- return (NULL);
+ return NULL;
}
for (ListWalker = (HANDLE_LIST*)GetFirstNode(&mHandleList.List.Link)
; !IsNull(&mHandleList.List.Link,&ListWalker->Link)
; ListWalker = (HANDLE_LIST*)GetNextNode(&mHandleList.List.Link,&ListWalker->Link)
){
- if (ListWalker->TheIndex == TheIndex) {
+ if (ListWalker->TheIndex == TheIndex && ListWalker->TheHandle != NULL) {
+ //
+ // Verify that LinkWalker->TheHandle is valid handle
+ //
+ Status = gBS->ProtocolsPerHandle(ListWalker->TheHandle, &ProtocolBuffer, &ProtocolCount);
+ if (EFI_ERROR (Status)) {
+ //
+ // TheHandle is not valid, so do not add to handle list
+ //
+ ListWalker->TheHandle = NULL;
+ }
return (ListWalker->TheHandle);
}
}
- return (NULL);
+ return NULL;
}
/**
@@ -1052,6 +1094,7 @@ ParseHandleDatabaseByRelationshipWithType (
UINTN OpenInfoCount;
UINTN OpenInfoIndex;
UINTN ChildIndex;
+ INTN DriverBindingHandleIndex;
ASSERT(HandleCount != NULL);
ASSERT(HandleBuffer != NULL);
@@ -1079,6 +1122,13 @@ ParseHandleDatabaseByRelationshipWithType (
*HandleType = AllocateZeroPool (*HandleCount * sizeof (UINTN));
ASSERT(*HandleType != NULL);
+ DriverBindingHandleIndex = -1;
+ for (HandleIndex = 0; HandleIndex < *HandleCount; HandleIndex++) {
+ if (DriverBindingHandle != NULL && (*HandleBuffer)[HandleIndex] == DriverBindingHandle) {
+ DriverBindingHandleIndex = (INTN)HandleIndex;
+ }
+ }
+
for (HandleIndex = 0; HandleIndex < *HandleCount; HandleIndex++) {
//
// Retrieve the list of all the protocols on each handle
@@ -1088,102 +1138,150 @@ ParseHandleDatabaseByRelationshipWithType (
&ProtocolGuidArray,
&ArrayCount
);
- if (!EFI_ERROR (Status)) {
+ if (EFI_ERROR (Status)) {
+ continue;
+ }
- for (ProtocolIndex = 0; ProtocolIndex < ArrayCount; ProtocolIndex++) {
+ for (ProtocolIndex = 0; ProtocolIndex < ArrayCount; ProtocolIndex++) {
- //
- // Set the bit describing what this handle has
- //
- if (CompareGuid (ProtocolGuidArray[ProtocolIndex], &gEfiLoadedImageProtocolGuid) ) {
- (*HandleType)[HandleIndex] |= HR_IMAGE_HANDLE;
- } else if (CompareGuid (ProtocolGuidArray[ProtocolIndex], &gEfiDriverBindingProtocolGuid) ) {
- (*HandleType)[HandleIndex] |= HR_DRIVER_BINDING_HANDLE;
- } else if (CompareGuid (ProtocolGuidArray[ProtocolIndex], &gEfiDriverConfiguration2ProtocolGuid)) {
- (*HandleType)[HandleIndex] |= HR_DRIVER_CONFIGURATION_HANDLE;
- } else if (CompareGuid (ProtocolGuidArray[ProtocolIndex], &gEfiDriverConfigurationProtocolGuid) ) {
- (*HandleType)[HandleIndex] |= HR_DRIVER_CONFIGURATION_HANDLE;
- } else if (CompareGuid (ProtocolGuidArray[ProtocolIndex], &gEfiDriverDiagnostics2ProtocolGuid) ) {
- (*HandleType)[HandleIndex] |= HR_DRIVER_DIAGNOSTICS_HANDLE;
- } else if (CompareGuid (ProtocolGuidArray[ProtocolIndex], &gEfiDriverDiagnosticsProtocolGuid) ) {
- (*HandleType)[HandleIndex] |= HR_DRIVER_DIAGNOSTICS_HANDLE;
- } else if (CompareGuid (ProtocolGuidArray[ProtocolIndex], &gEfiComponentName2ProtocolGuid) ) {
- (*HandleType)[HandleIndex] |= HR_COMPONENT_NAME_HANDLE;
- } else if (CompareGuid (ProtocolGuidArray[ProtocolIndex], &gEfiComponentNameProtocolGuid) ) {
- (*HandleType)[HandleIndex] |= HR_COMPONENT_NAME_HANDLE;
- } else if (CompareGuid (ProtocolGuidArray[ProtocolIndex], &gEfiDevicePathProtocolGuid) ) {
- (*HandleType)[HandleIndex] |= HR_DEVICE_HANDLE;
- } else {
- DEBUG_CODE_BEGIN();
- ASSERT((*HandleType)[HandleIndex] == (*HandleType)[HandleIndex]);
- DEBUG_CODE_END();
- }
- //
- // Retrieve the list of agents that have opened each protocol
- //
- Status = gBS->OpenProtocolInformation (
+ //
+ // Set the bit describing what this handle has
+ //
+ if (CompareGuid (ProtocolGuidArray[ProtocolIndex], &gEfiLoadedImageProtocolGuid) ) {
+ (*HandleType)[HandleIndex] |= HR_IMAGE_HANDLE;
+ } else if (CompareGuid (ProtocolGuidArray[ProtocolIndex], &gEfiDriverBindingProtocolGuid) ) {
+ (*HandleType)[HandleIndex] |= HR_DRIVER_BINDING_HANDLE;
+ } else if (CompareGuid (ProtocolGuidArray[ProtocolIndex], &gEfiDriverConfiguration2ProtocolGuid)) {
+ (*HandleType)[HandleIndex] |= HR_DRIVER_CONFIGURATION_HANDLE;
+ } else if (CompareGuid (ProtocolGuidArray[ProtocolIndex], &gEfiDriverConfigurationProtocolGuid) ) {
+ (*HandleType)[HandleIndex] |= HR_DRIVER_CONFIGURATION_HANDLE;
+ } else if (CompareGuid (ProtocolGuidArray[ProtocolIndex], &gEfiDriverDiagnostics2ProtocolGuid) ) {
+ (*HandleType)[HandleIndex] |= HR_DRIVER_DIAGNOSTICS_HANDLE;
+ } else if (CompareGuid (ProtocolGuidArray[ProtocolIndex], &gEfiDriverDiagnosticsProtocolGuid) ) {
+ (*HandleType)[HandleIndex] |= HR_DRIVER_DIAGNOSTICS_HANDLE;
+ } else if (CompareGuid (ProtocolGuidArray[ProtocolIndex], &gEfiComponentName2ProtocolGuid) ) {
+ (*HandleType)[HandleIndex] |= HR_COMPONENT_NAME_HANDLE;
+ } else if (CompareGuid (ProtocolGuidArray[ProtocolIndex], &gEfiComponentNameProtocolGuid) ) {
+ (*HandleType)[HandleIndex] |= HR_COMPONENT_NAME_HANDLE;
+ } else if (CompareGuid (ProtocolGuidArray[ProtocolIndex], &gEfiDevicePathProtocolGuid) ) {
+ (*HandleType)[HandleIndex] |= HR_DEVICE_HANDLE;
+ } else {
+ DEBUG_CODE_BEGIN();
+ ASSERT((*HandleType)[HandleIndex] == (*HandleType)[HandleIndex]);
+ DEBUG_CODE_END();
+ }
+ //
+ // Retrieve the list of agents that have opened each protocol
+ //
+ Status = gBS->OpenProtocolInformation (
(*HandleBuffer)[HandleIndex],
ProtocolGuidArray[ProtocolIndex],
&OpenInfo,
&OpenInfoCount
);
- if (!EFI_ERROR (Status)) {
+ if (EFI_ERROR (Status)) {
+ continue;
+ }
+
+ if (ControllerHandle == NULL) {
+ //
+ // ControllerHandle == NULL and DriverBindingHandle != NULL.
+ // Return information on all the controller handles that the driver specified by DriverBindingHandle is managing
+ //
+ for (OpenInfoIndex = 0; OpenInfoIndex < OpenInfoCount; OpenInfoIndex++) {
+ if (OpenInfo[OpenInfoIndex].AgentHandle == DriverBindingHandle && (OpenInfo[OpenInfoIndex].Attributes & EFI_OPEN_PROTOCOL_BY_DRIVER) != 0) {
+ (*HandleType)[HandleIndex] |= (HR_DEVICE_HANDLE | HR_CONTROLLER_HANDLE);
+ if (DriverBindingHandleIndex != -1) {
+ (*HandleType)[DriverBindingHandleIndex] |= HR_DEVICE_DRIVER;
+ }
+ }
+ if (OpenInfo[OpenInfoIndex].AgentHandle == DriverBindingHandle && (OpenInfo[OpenInfoIndex].Attributes & EFI_OPEN_PROTOCOL_BY_CHILD_CONTROLLER) != 0) {
+ (*HandleType)[HandleIndex] |= (HR_DEVICE_HANDLE | HR_CONTROLLER_HANDLE);
+ if (DriverBindingHandleIndex != -1) {
+ (*HandleType)[DriverBindingHandleIndex] |= (HR_BUS_DRIVER | HR_DEVICE_DRIVER);
+ }
+ for (ChildIndex = 0; ChildIndex < *HandleCount; ChildIndex++) {
+ if (OpenInfo[OpenInfoIndex].ControllerHandle == (*HandleBuffer)[ChildIndex]) {
+ (*HandleType)[ChildIndex] |= (HR_DEVICE_HANDLE | HR_CHILD_HANDLE);
+ }
+ }
+ }
+ }
+ }
+ if (DriverBindingHandle == NULL && ControllerHandle != NULL) {
+ if (ControllerHandle == (*HandleBuffer)[HandleIndex]) {
+ (*HandleType)[HandleIndex] |= (HR_DEVICE_HANDLE | HR_CONTROLLER_HANDLE);
for (OpenInfoIndex = 0; OpenInfoIndex < OpenInfoCount; OpenInfoIndex++) {
- if (DriverBindingHandle != NULL && OpenInfo[OpenInfoIndex].AgentHandle == DriverBindingHandle) {
- if ((OpenInfo[OpenInfoIndex].Attributes & EFI_OPEN_PROTOCOL_BY_DRIVER) == EFI_OPEN_PROTOCOL_BY_DRIVER) {
- (*HandleType)[HandleIndex] |= (HR_DEVICE_HANDLE | HR_CONTROLLER_HANDLE);
+ if ((OpenInfo[OpenInfoIndex].Attributes & EFI_OPEN_PROTOCOL_BY_DRIVER) != 0) {
+ for (ChildIndex = 0; ChildIndex < *HandleCount; ChildIndex++) {
+ if (OpenInfo[OpenInfoIndex].AgentHandle == (*HandleBuffer)[ChildIndex]) {
+ (*HandleType)[ChildIndex] |= HR_DEVICE_DRIVER;
+ }
}
- if (ControllerHandle != NULL && (*HandleBuffer)[HandleIndex] == ControllerHandle) {
- if ((OpenInfo[OpenInfoIndex].Attributes & EFI_OPEN_PROTOCOL_BY_CHILD_CONTROLLER) == EFI_OPEN_PROTOCOL_BY_CHILD_CONTROLLER) {
- for (ChildIndex = 0; ChildIndex < *HandleCount; ChildIndex++) {
- if ((*HandleBuffer)[ChildIndex] == OpenInfo[OpenInfoIndex].ControllerHandle) {
- (*HandleType)[ChildIndex] |= (HR_DEVICE_HANDLE | HR_CHILD_HANDLE);
- }
- }
+ }
+ if ((OpenInfo[OpenInfoIndex].Attributes & EFI_OPEN_PROTOCOL_BY_CHILD_CONTROLLER) != 0) {
+ for (ChildIndex = 0; ChildIndex < *HandleCount; ChildIndex++) {
+ if (OpenInfo[OpenInfoIndex].AgentHandle == (*HandleBuffer)[ChildIndex]) {
+ (*HandleType)[ChildIndex] |= (HR_BUS_DRIVER | HR_DEVICE_DRIVER);
+ }
+ if (OpenInfo[OpenInfoIndex].ControllerHandle == (*HandleBuffer)[ChildIndex]) {
+ (*HandleType)[ChildIndex] |= (HR_DEVICE_HANDLE | HR_CHILD_HANDLE);
}
}
}
- if (DriverBindingHandle == NULL && OpenInfo[OpenInfoIndex].ControllerHandle == ControllerHandle) {
- if ((OpenInfo[OpenInfoIndex].Attributes & EFI_OPEN_PROTOCOL_BY_DRIVER) == EFI_OPEN_PROTOCOL_BY_DRIVER) {
- for (ChildIndex = 0; ChildIndex < *HandleCount; ChildIndex++) {
- if ((*HandleBuffer)[ChildIndex] == OpenInfo[OpenInfoIndex].AgentHandle) {
- (*HandleType)[ChildIndex] |= HR_DEVICE_DRIVER;
- }
+ }
+ } else {
+ for (OpenInfoIndex = 0; OpenInfoIndex < OpenInfoCount; OpenInfoIndex++) {
+ if ((OpenInfo[OpenInfoIndex].Attributes & EFI_OPEN_PROTOCOL_BY_CHILD_CONTROLLER) != 0) {
+ if (OpenInfo[OpenInfoIndex].ControllerHandle == ControllerHandle) {
+ (*HandleType)[HandleIndex] |= (HR_DEVICE_HANDLE | HR_PARENT_HANDLE);
+ }
+ }
+ }
+ }
+ }
+ if (DriverBindingHandle != NULL && ControllerHandle != NULL) {
+ if (ControllerHandle == (*HandleBuffer)[HandleIndex]) {
+ (*HandleType)[HandleIndex] |= (HR_DEVICE_HANDLE | HR_CONTROLLER_HANDLE);
+ for (OpenInfoIndex = 0; OpenInfoIndex < OpenInfoCount; OpenInfoIndex++) {
+ if ((OpenInfo[OpenInfoIndex].Attributes & EFI_OPEN_PROTOCOL_BY_DRIVER) != 0) {
+ if (OpenInfo[OpenInfoIndex].AgentHandle == DriverBindingHandle) {
+ if (DriverBindingHandleIndex != -1) {
+ (*HandleType)[DriverBindingHandleIndex] |= HR_DEVICE_DRIVER;
}
}
- if ((OpenInfo[OpenInfoIndex].Attributes & EFI_OPEN_PROTOCOL_BY_CHILD_CONTROLLER) == EFI_OPEN_PROTOCOL_BY_CHILD_CONTROLLER) {
- (*HandleType)[HandleIndex] |= HR_PARENT_HANDLE;
+ }
+ if ((OpenInfo[OpenInfoIndex].Attributes & EFI_OPEN_PROTOCOL_BY_CHILD_CONTROLLER) != 0) {
+ if (OpenInfo[OpenInfoIndex].AgentHandle == DriverBindingHandle) {
for (ChildIndex = 0; ChildIndex < *HandleCount; ChildIndex++) {
- if ((*HandleBuffer)[ChildIndex] == OpenInfo[OpenInfoIndex].AgentHandle) {
- (*HandleType)[ChildIndex] |= HR_BUS_DRIVER;
+ if (OpenInfo[OpenInfoIndex].ControllerHandle == (*HandleBuffer)[ChildIndex]) {
+ (*HandleType)[ChildIndex] |= (HR_DEVICE_HANDLE | HR_CHILD_HANDLE);
}
}
}
+
+ for (ChildIndex = 0; ChildIndex < *HandleCount; ChildIndex++) {
+ if (OpenInfo[OpenInfoIndex].AgentHandle == (*HandleBuffer)[ChildIndex]) {
+ (*HandleType)[ChildIndex] |= (HR_BUS_DRIVER | HR_DEVICE_DRIVER);
+ }
+ }
+ }
+ }
+ } else {
+ for (OpenInfoIndex = 0; OpenInfoIndex < OpenInfoCount; OpenInfoIndex++) {
+ if ((OpenInfo[OpenInfoIndex].Attributes & EFI_OPEN_PROTOCOL_BY_CHILD_CONTROLLER) != 0) {
+ if (OpenInfo[OpenInfoIndex].ControllerHandle == ControllerHandle) {
+ (*HandleType)[HandleIndex] |= (HR_DEVICE_HANDLE | HR_PARENT_HANDLE);
+ }
}
}
-
- FreePool (OpenInfo);
}
}
-
- FreePool (ProtocolGuidArray);
+ FreePool (OpenInfo);
}
+ FreePool (ProtocolGuidArray);
}
-
- if (EFI_ERROR(Status)) {
- if (*HandleType != NULL) {
- FreePool (*HandleType);
- }
- if (*HandleBuffer != NULL) {
- FreePool (*HandleBuffer);
- }
-
- *HandleCount = 0;
- *HandleBuffer = NULL;
- *HandleType = NULL;
- }
-
- return Status;
+ return EFI_SUCCESS;
}
/**
@@ -1338,14 +1436,13 @@ ParseHandleDatabaseForChildControllers(
)
{
EFI_STATUS Status;
-// UINTN HandleIndex;
+ UINTN HandleIndex;
UINTN DriverBindingHandleCount;
EFI_HANDLE *DriverBindingHandleBuffer;
UINTN DriverBindingHandleIndex;
UINTN ChildControllerHandleCount;
EFI_HANDLE *ChildControllerHandleBuffer;
UINTN ChildControllerHandleIndex;
-// BOOLEAN Found;
EFI_HANDLE *HandleBufferForReturn;
if (MatchingHandleCount == NULL) {
@@ -1365,7 +1462,7 @@ ParseHandleDatabaseForChildControllers(
//
// Get a buffer big enough for all the controllers.
//
- HandleBufferForReturn = GetHandleListByProtocol(&gEfiDevicePathProtocolGuid);
+ HandleBufferForReturn = GetHandleListByProtocol(NULL);
if (HandleBufferForReturn == NULL) {
FreePool (DriverBindingHandleBuffer);
return (EFI_NOT_FOUND);
@@ -1386,18 +1483,14 @@ ParseHandleDatabaseForChildControllers(
ChildControllerHandleIndex < ChildControllerHandleCount;
ChildControllerHandleIndex++
) {
-// Found = FALSE;
- HandleBufferForReturn[(*MatchingHandleCount)++] = ChildControllerHandleBuffer[ChildControllerHandleIndex];
-// for (HandleIndex = 0; HandleBufferForReturn[HandleIndex] != NULL; HandleIndex++) {
-// if (HandleBufferForReturn[HandleIndex] == ChildControllerHandleBuffer[ChildControllerHandleIndex]) {
-// Found = TRUE;
-// break;
-// }
-// }
-
-// if (Found) {
-// HandleBufferForReturn[(*MatchingHandleCount)++] = ChildControllerHandleBuffer[ChildControllerHandleIndex];
-// }
+ for (HandleIndex = 0; HandleIndex < *MatchingHandleCount; HandleIndex++) {
+ if (HandleBufferForReturn[HandleIndex] == ChildControllerHandleBuffer[ChildControllerHandleIndex]) {
+ break;
+ }
+ }
+ if (HandleIndex >= *MatchingHandleCount) {
+ HandleBufferForReturn[(*MatchingHandleCount)++] = ChildControllerHandleBuffer[ChildControllerHandleIndex];
+ }
}
FreePool (ChildControllerHandleBuffer);
diff --git a/edk2/ShellPkg/Library/UefiShellCommandLib/ConsistMapping.c b/edk2/ShellPkg/Library/UefiShellCommandLib/ConsistMapping.c
index 9fbcbb3eb..23ff12370 100644
--- a/edk2/ShellPkg/Library/UefiShellCommandLib/ConsistMapping.c
+++ b/edk2/ShellPkg/Library/UefiShellCommandLib/ConsistMapping.c
@@ -1,7 +1,7 @@
/** @file
Main file for support of shell consist mapping.
- Copyright (c) 2005 - 2011, Intel Corporation. All rights reserved.<BR>
+ Copyright (c) 2005 - 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
which accompanies this distribution. The full text of the license may be found at
@@ -950,90 +950,132 @@ DevPathSerialDefault (
}
DEV_PATH_CONSIST_MAPPING_TABLE DevPathConsistMappingTable[] = {
- HARDWARE_DEVICE_PATH,
- HW_PCI_DP,
- DevPathSerialDefault,
- DevPathComparePci,
- ACPI_DEVICE_PATH,
- ACPI_DP,
- DevPathSerialAcpi,
- DevPathCompareAcpi,
- MESSAGING_DEVICE_PATH,
- MSG_ATAPI_DP,
- DevPathSerialAtapi,
- DevPathCompareDefault,
- MESSAGING_DEVICE_PATH,
- MSG_SCSI_DP,
- DevPathSerialScsi,
- DevPathCompareDefault,
- MESSAGING_DEVICE_PATH,
- MSG_FIBRECHANNEL_DP,
- DevPathSerialFibre,
- DevPathCompareDefault,
- MESSAGING_DEVICE_PATH,
- MSG_1394_DP,
- DevPathSerial1394,
- DevPathCompareDefault,
- MESSAGING_DEVICE_PATH,
- MSG_USB_DP,
- DevPathSerialUsb,
- DevPathCompareDefault,
- MESSAGING_DEVICE_PATH,
- MSG_I2O_DP,
- DevPathSerialI2O,
- DevPathCompareDefault,
- MESSAGING_DEVICE_PATH,
- MSG_MAC_ADDR_DP,
- DevPathSerialMacAddr,
- DevPathCompareDefault,
- MESSAGING_DEVICE_PATH,
- MSG_IPv4_DP,
- DevPathSerialIPv4,
- DevPathCompareDefault,
- MESSAGING_DEVICE_PATH,
- MSG_IPv6_DP,
- DevPathSerialIPv6,
- DevPathCompareDefault,
- MESSAGING_DEVICE_PATH,
- MSG_INFINIBAND_DP,
- DevPathSerialInfiniBand,
- DevPathCompareDefault,
- MESSAGING_DEVICE_PATH,
- MSG_UART_DP,
- DevPathSerialUart,
- DevPathCompareDefault,
- MESSAGING_DEVICE_PATH,
- MSG_VENDOR_DP,
- DevPathSerialVendor,
- DevPathCompareDefault,
- MESSAGING_DEVICE_PATH,
- MSG_DEVICE_LOGICAL_UNIT_DP,
- DevPathSerialLun,
- DevPathCompareDefault,
- MESSAGING_DEVICE_PATH,
- MSG_SATA_DP,
- DevPathSerialSata,
- DevPathCompareDefault,
- MESSAGING_DEVICE_PATH,
- MSG_ISCSI_DP,
- DevPathSerialIScsi,
- DevPathCompareDefault,
- MEDIA_DEVICE_PATH,
- MEDIA_HARDDRIVE_DP,
- DevPathSerialHardDrive,
- DevPathCompareDefault,
- MEDIA_DEVICE_PATH,
- MEDIA_CDROM_DP,
- DevPathSerialCdRom,
- DevPathCompareDefault,
- MEDIA_DEVICE_PATH,
- MEDIA_VENDOR_DP,
- DevPathSerialVendor,
- DevPathCompareDefault,
- 0,
- 0,
- NULL,
- NULL
+ {
+ HARDWARE_DEVICE_PATH,
+ HW_PCI_DP,
+ DevPathSerialDefault,
+ DevPathComparePci
+ },
+ {
+ ACPI_DEVICE_PATH,
+ ACPI_DP,
+ DevPathSerialAcpi,
+ DevPathCompareAcpi
+ },
+ {
+ MESSAGING_DEVICE_PATH,
+ MSG_ATAPI_DP,
+ DevPathSerialAtapi,
+ DevPathCompareDefault
+ },
+ {
+ MESSAGING_DEVICE_PATH,
+ MSG_SCSI_DP,
+ DevPathSerialScsi,
+ DevPathCompareDefault
+ },
+ {
+ MESSAGING_DEVICE_PATH,
+ MSG_FIBRECHANNEL_DP,
+ DevPathSerialFibre,
+ DevPathCompareDefault
+ },
+ {
+ MESSAGING_DEVICE_PATH,
+ MSG_1394_DP,
+ DevPathSerial1394,
+ DevPathCompareDefault
+ },
+ {
+ MESSAGING_DEVICE_PATH,
+ MSG_USB_DP,
+ DevPathSerialUsb,
+ DevPathCompareDefault
+ },
+ {
+ MESSAGING_DEVICE_PATH,
+ MSG_I2O_DP,
+ DevPathSerialI2O,
+ DevPathCompareDefault
+ },
+ {
+ MESSAGING_DEVICE_PATH,
+ MSG_MAC_ADDR_DP,
+ DevPathSerialMacAddr,
+ DevPathCompareDefault
+ },
+ {
+ MESSAGING_DEVICE_PATH,
+ MSG_IPv4_DP,
+ DevPathSerialIPv4,
+ DevPathCompareDefault
+ },
+ {
+ MESSAGING_DEVICE_PATH,
+ MSG_IPv6_DP,
+ DevPathSerialIPv6,
+ DevPathCompareDefault
+ },
+ {
+ MESSAGING_DEVICE_PATH,
+ MSG_INFINIBAND_DP,
+ DevPathSerialInfiniBand,
+ DevPathCompareDefault
+ },
+ {
+ MESSAGING_DEVICE_PATH,
+ MSG_UART_DP,
+ DevPathSerialUart,
+ DevPathCompareDefault
+ },
+ {
+ MESSAGING_DEVICE_PATH,
+ MSG_VENDOR_DP,
+ DevPathSerialVendor,
+ DevPathCompareDefault
+ },
+ {
+ MESSAGING_DEVICE_PATH,
+ MSG_DEVICE_LOGICAL_UNIT_DP,
+ DevPathSerialLun,
+ DevPathCompareDefault
+ },
+ {
+ MESSAGING_DEVICE_PATH,
+ MSG_SATA_DP,
+ DevPathSerialSata,
+ DevPathCompareDefault
+ },
+ {
+ MESSAGING_DEVICE_PATH,
+ MSG_ISCSI_DP,
+ DevPathSerialIScsi,
+ DevPathCompareDefault
+ },
+ {
+ MEDIA_DEVICE_PATH,
+ MEDIA_HARDDRIVE_DP,
+ DevPathSerialHardDrive,
+ DevPathCompareDefault
+ },
+ {
+ MEDIA_DEVICE_PATH,
+ MEDIA_CDROM_DP,
+ DevPathSerialCdRom,
+ DevPathCompareDefault
+ },
+ {
+ MEDIA_DEVICE_PATH,
+ MEDIA_VENDOR_DP,
+ DevPathSerialVendor,
+ DevPathCompareDefault
+ },
+ {
+ 0,
+ 0,
+ NULL,
+ NULL
+ }
};
/**
diff --git a/edk2/ShellPkg/Library/UefiShellDebug1CommandsLib/Edit/MainTextEditor.c b/edk2/ShellPkg/Library/UefiShellDebug1CommandsLib/Edit/MainTextEditor.c
index c5e47b105..3583dd3df 100644
--- a/edk2/ShellPkg/Library/UefiShellDebug1CommandsLib/Edit/MainTextEditor.c
+++ b/edk2/ShellPkg/Library/UefiShellDebug1CommandsLib/Edit/MainTextEditor.c
@@ -1,7 +1,7 @@
/** @file
Implements editor interface functions.
- Copyright (c) 2005 - 2011, Intel Corporation. All rights reserved. <BR>
+ Copyright (c) 2005 - 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
which accompanies this distribution. The full text of the license may be found at
@@ -1399,8 +1399,7 @@ INTN OriginalMode;
EFI_EDITOR_GLOBAL_EDITOR MainEditorConst = {
&FileBuffer,
{
- 0,
- 0
+ {0, 0}
},
{
0,
diff --git a/edk2/ShellPkg/Library/UefiShellDebug1CommandsLib/HexEdit/MainHexEditor.c b/edk2/ShellPkg/Library/UefiShellDebug1CommandsLib/HexEdit/MainHexEditor.c
index 808f7a56c..446dac7e0 100644
--- a/edk2/ShellPkg/Library/UefiShellDebug1CommandsLib/HexEdit/MainHexEditor.c
+++ b/edk2/ShellPkg/Library/UefiShellDebug1CommandsLib/HexEdit/MainHexEditor.c
@@ -4,7 +4,7 @@
- Instances of the other objects of the editor
- Main Interfaces
- Copyright (c) 2005 - 2011, Intel Corporation. All rights reserved. <BR>
+ Copyright (c) 2005 - 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
which accompanies this distribution. The full text of the license may be found at
@@ -50,8 +50,7 @@ HEFI_EDITOR_GLOBAL_EDITOR HMainEditorBackupVar;
HEFI_EDITOR_GLOBAL_EDITOR HMainEditorConst = {
&HBufferImage,
{
- 0,
- 0
+ {0, 0}
},
{
0,
diff --git a/edk2/ShellPkg/Library/UefiShellDriver1CommandsLib/DevTree.c b/edk2/ShellPkg/Library/UefiShellDriver1CommandsLib/DevTree.c
index a66bdec06..154877037 100644
--- a/edk2/ShellPkg/Library/UefiShellDriver1CommandsLib/DevTree.c
+++ b/edk2/ShellPkg/Library/UefiShellDriver1CommandsLib/DevTree.c
@@ -1,7 +1,7 @@
/** @file
Main file for DevTree shell Driver1 function.
- Copyright (c) 2010 - 2011, Intel Corporation. All rights reserved.<BR>
+ Copyright (c) 2010 - 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
which accompanies this distribution. The full text of the license may be found at
@@ -84,23 +84,6 @@ DoDevTreeForHandle(
return SHELL_SUCCESS;
}
- //
- // If we are at the begining then we want root handles they have no parents and do have device path.
- //
- if (IndentCharCount == 0) {
- Status = gBS->OpenProtocol (
- TheHandle,
- &gEfiDevicePathProtocolGuid,
- NULL,
- NULL,
- NULL,
- EFI_OPEN_PROTOCOL_TEST_PROTOCOL
- );
- if (EFI_ERROR (Status)) {
- return SHELL_SUCCESS;
- }
- }
-
FormatString = AllocateZeroPool(StrSize(HiiString) + (10)*sizeof(FormatString[0]));
ASSERT(HiiString != NULL);
@@ -169,6 +152,8 @@ ShellCommandRunDevTree (
EFI_HANDLE TheHandle;
BOOLEAN FlagD;
UINT64 Intermediate;
+ UINTN ParentControllerHandleCount;
+ EFI_HANDLE *ParentControllerHandleBuffer;
ShellStatus = SHELL_SUCCESS;
Status = EFI_SUCCESS;
@@ -226,6 +211,39 @@ ShellCommandRunDevTree (
if (TheHandle == NULL){
break;
}
+
+ //
+ // Skip handles that do not have device path protocol
+ //
+ Status = gBS->OpenProtocol (
+ TheHandle,
+ &gEfiDevicePathProtocolGuid,
+ NULL,
+ NULL,
+ NULL,
+ EFI_OPEN_PROTOCOL_TEST_PROTOCOL
+ );
+ if (EFI_ERROR (Status)) {
+ continue;
+ }
+
+ //
+ // Skip handles that do have parents
+ //
+ ParentControllerHandleBuffer = NULL;
+ Status = PARSE_HANDLE_DATABASE_PARENTS (
+ TheHandle,
+ &ParentControllerHandleCount,
+ &ParentControllerHandleBuffer
+ );
+ SHELL_FREE_NON_NULL (ParentControllerHandleBuffer);
+ if (ParentControllerHandleCount > 0) {
+ continue;
+ }
+
+ //
+ // Start a devtree from TheHandle that has a device path and no parents
+ //
ShellStatus = DoDevTreeForHandle(TheHandle, Language, FlagD, 0, HiiString);
}
} else {
diff --git a/edk2/ShellPkg/Library/UefiShellDriver1CommandsLib/Dh.c b/edk2/ShellPkg/Library/UefiShellDriver1CommandsLib/Dh.c
index 1b42b23ad..a0dc13941 100644
--- a/edk2/ShellPkg/Library/UefiShellDriver1CommandsLib/Dh.c
+++ b/edk2/ShellPkg/Library/UefiShellDriver1CommandsLib/Dh.c
@@ -1,7 +1,7 @@
/** @file
Main file for Dh shell Driver1 function.
- Copyright (c) 2010 - 2011, Intel Corporation. All rights reserved.<BR>
+ Copyright (c) 2010 - 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
which accompanies this distribution. The full text of the license may be found at
@@ -394,11 +394,14 @@ DisplayDriverModelHandle (
Language,
&DriverName
);
- if (DriverName == NULL) {
+ if (EFI_ERROR (Status)) {
Status = GetDriverImageName (
DriverBindingHandleBuffer[Index],
&DriverName
);
+ if (EFI_ERROR (Status)) {
+ DriverName = NULL;
+ }
}
if (Image) {
@@ -537,6 +540,9 @@ DisplayDriverModelHandle (
}
Status = GetDriverName (Handle, Language, &DriverName);
+ if (EFI_ERROR (Status)) {
+ DriverName = NULL;
+ }
ShellPrintHiiEx(
-1,
@@ -548,11 +554,13 @@ DisplayDriverModelHandle (
DriverName!=NULL?DriverName:L"<Unknown>"
);
SHELL_FREE_NON_NULL(DriverName);
- DriverName = NULL;
Status = GetDriverImageName (
Handle,
&DriverName
);
+ if (EFI_ERROR (Status)) {
+ DriverName = NULL;
+ }
ShellPrintHiiEx(
-1,
-1,
diff --git a/edk2/ShellPkg/Library/UefiShellDriver1CommandsLib/Disconnect.c b/edk2/ShellPkg/Library/UefiShellDriver1CommandsLib/Disconnect.c
index 96233f9b5..a33bed9dc 100644
--- a/edk2/ShellPkg/Library/UefiShellDriver1CommandsLib/Disconnect.c
+++ b/edk2/ShellPkg/Library/UefiShellDriver1CommandsLib/Disconnect.c
@@ -1,7 +1,7 @@
/** @file
Main file for Disconnect shell Driver1 function.
- Copyright (c) 2010 - 2011, Intel Corporation. All rights reserved.<BR>
+ Copyright (c) 2010 - 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
which accompanies this distribution. The full text of the license may be found at
@@ -163,10 +163,6 @@ ShellCommandRunDisconnect (
} else if (Param3 != NULL && Handle3 == NULL) {
ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_GEN_INV_HANDLE), gShellDriver1HiiHandle, Param3);
ShellStatus = SHELL_INVALID_PARAMETER;
- } else if (EFI_ERROR(gBS->OpenProtocol(Handle1, &gEfiDevicePathProtocolGuid, NULL, gImageHandle, NULL, EFI_OPEN_PROTOCOL_TEST_PROTOCOL))) {
- ASSERT(Param1 != NULL);
- ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_GEN_HANDLE_NOT), gShellDriver1HiiHandle, ShellStrToUintn(Param1), L"controller handle");
- ShellStatus = SHELL_INVALID_PARAMETER;
} else if (Handle2 != NULL && EFI_ERROR(gBS->OpenProtocol(Handle2, &gEfiDriverBindingProtocolGuid, NULL, gImageHandle, NULL, EFI_OPEN_PROTOCOL_TEST_PROTOCOL))) {
ASSERT(Param2 != NULL);
ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_GEN_HANDLE_NOT), gShellDriver1HiiHandle, ShellStrToUintn(Param2), L"driver handle");
diff --git a/edk2/ShellPkg/Library/UefiShellDriver1CommandsLib/OpenInfo.c b/edk2/ShellPkg/Library/UefiShellDriver1CommandsLib/OpenInfo.c
index 368948307..2922f42d1 100644
--- a/edk2/ShellPkg/Library/UefiShellDriver1CommandsLib/OpenInfo.c
+++ b/edk2/ShellPkg/Library/UefiShellDriver1CommandsLib/OpenInfo.c
@@ -48,6 +48,7 @@ TraverseHandleDatabase (
CHAR16 *TempString;
UINTN HandleIndex;
CONST CHAR16 *Name;
+ UINTN ControllerIndex;
if (TheHandle == NULL) {
return (EFI_INVALID_PARAMETER);
@@ -98,9 +99,10 @@ TraverseHandleDatabase (
OpenTypeString = StringDriverEx; break;
default: OpenTypeString = StringUnknown; break;
}
- HandleIndex = ConvertHandleToHandleIndex(OpenInfo[OpenInfoIndex].AgentHandle);
- Name = GetStringNameFromHandle(OpenInfo[OpenInfoIndex].AgentHandle, NULL);
- if (OpenInfo[OpenInfoIndex].ControllerHandle!=NULL) {
+ HandleIndex = ConvertHandleToHandleIndex(OpenInfo[OpenInfoIndex].AgentHandle);
+ Name = GetStringNameFromHandle(OpenInfo[OpenInfoIndex].AgentHandle, NULL);
+ ControllerIndex = ConvertHandleToHandleIndex(OpenInfo[OpenInfoIndex].ControllerHandle);
+ if (ControllerIndex != 0) {
ShellPrintHiiEx(
-1,
-1,
@@ -108,7 +110,7 @@ TraverseHandleDatabase (
STRING_TOKEN(STR_OPENINFO_LINE),
gShellDriver1HiiHandle,
HandleIndex,
- ConvertHandleToHandleIndex(OpenInfo[OpenInfoIndex].ControllerHandle),
+ ControllerIndex,
OpenInfo[OpenInfoIndex].OpenCount,
OpenTypeString,
Name
diff --git a/edk2/ShellPkg/Library/UefiShellDriver1CommandsLib/UefiShellDriver1CommandsLib.uni b/edk2/ShellPkg/Library/UefiShellDriver1CommandsLib/UefiShellDriver1CommandsLib.uni
index 6c669795a..9ffad7ec0 100644
--- a/edk2/ShellPkg/Library/UefiShellDriver1CommandsLib/UefiShellDriver1CommandsLib.uni
+++ b/edk2/ShellPkg/Library/UefiShellDriver1CommandsLib/UefiShellDriver1CommandsLib.uni
Binary files differ
diff --git a/edk2/ShellPkg/Library/UefiShellInstall1CommandsLib/Bcfg.c b/edk2/ShellPkg/Library/UefiShellInstall1CommandsLib/Bcfg.c
index 22f6c6f61..a7a10bf3b 100644
--- a/edk2/ShellPkg/Library/UefiShellInstall1CommandsLib/Bcfg.c
+++ b/edk2/ShellPkg/Library/UefiShellInstall1CommandsLib/Bcfg.c
@@ -857,7 +857,7 @@ BcfgAddOptInstall1(
// Now we know how many EFI_INPUT_KEY structs we need to attach to the end of the EFI_KEY_OPTION struct.
// Re-allocate with the added information.
//
- KeyOptionBuffer = AllocateCopyPool(sizeof(EFI_KEY_OPTION) + (sizeof(EFI_KEY_DATA) * KEY_OPTION_INPUT_KEY_COUNT (&NewKeyOption)), &NewKeyOption);
+ KeyOptionBuffer = AllocateCopyPool(sizeof(EFI_KEY_OPTION) + (sizeof(EFI_INPUT_KEY) * KEY_OPTION_INPUT_KEY_COUNT (&NewKeyOption)), &NewKeyOption);
if (KeyOptionBuffer == NULL) {
ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_GEN_NO_MEM), gShellInstall1HiiHandle);
ShellStatus = SHELL_OUT_OF_RESOURCES;
@@ -929,7 +929,7 @@ BcfgAddOptInstall1(
VariableName,
(EFI_GUID*)&gEfiGlobalVariableGuid,
EFI_VARIABLE_NON_VOLATILE|EFI_VARIABLE_BOOTSERVICE_ACCESS|EFI_VARIABLE_RUNTIME_ACCESS,
- sizeof(EFI_KEY_OPTION) + (sizeof(EFI_KEY_DATA) * KEY_OPTION_INPUT_KEY_COUNT (&NewKeyOption)),
+ sizeof(EFI_KEY_OPTION) + (sizeof(EFI_INPUT_KEY) * KEY_OPTION_INPUT_KEY_COUNT (&NewKeyOption)),
KeyOptionBuffer);
if (EFI_ERROR(Status)) {
ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_BCFG_SET_VAR_FAIL), gShellInstall1HiiHandle, VariableName, Status);
diff --git a/edk2/ShellPkg/Library/UefiShellNetwork1CommandsLib/Ifconfig.c b/edk2/ShellPkg/Library/UefiShellNetwork1CommandsLib/Ifconfig.c
index 7d03b68d9..32a4f7fb4 100644
--- a/edk2/ShellPkg/Library/UefiShellNetwork1CommandsLib/Ifconfig.c
+++ b/edk2/ShellPkg/Library/UefiShellNetwork1CommandsLib/Ifconfig.c
@@ -1042,7 +1042,7 @@ TimeoutToGetMap (
}
/**
- Create an IP child, use it to start the auto configuration, then destory it.
+ Create an IP child, use it to start the auto configuration, then destroy it.
@param[in] NicInfo The pointer to the NIC_INFO of the Nic to be configured.
diff --git a/edk2/ShellPkg/Library/UefiShellNetwork1CommandsLib/Ping.c b/edk2/ShellPkg/Library/UefiShellNetwork1CommandsLib/Ping.c
index f24a55c87..fd4aa8d81 100644
--- a/edk2/ShellPkg/Library/UefiShellNetwork1CommandsLib/Ping.c
+++ b/edk2/ShellPkg/Library/UefiShellNetwork1CommandsLib/Ping.c
@@ -1,7 +1,7 @@
/** @file
The implementation for Ping shell command.
- Copyright (c) 2009 - 2011, Intel Corporation. All rights reserved.<BR>
+ Copyright (c) 2009 - 2012, Intel Corporation. All rights reserved.<BR>
This program and the accompanying materials
are licensed and made available under the terms and conditions of the BSD License
@@ -1190,14 +1190,14 @@ ON_ERROR:
}
/**
- Destory the IP instance.
+ Destroy the IP instance.
@param[in] Private The pointer of PING_PRIVATE_DATA.
**/
VOID
EFIAPI
-Ping6DestoryIp6Instance (
+Ping6DestroyIp6Instance (
IN PING_PRIVATE_DATA *Private
)
{
@@ -1414,7 +1414,7 @@ ON_EXIT:
}
if (Private->IpChildHandle != NULL) {
- Ping6DestoryIp6Instance (Private);
+ Ping6DestroyIp6Instance (Private);
}
FreePool (Private);
diff --git a/edk2/SourceLevelDebugPkg/Library/DebugAgent/DebugAgentCommon/DebugMp.c b/edk2/SourceLevelDebugPkg/Library/DebugAgent/DebugAgentCommon/DebugMp.c
index 5275b096b..d7df6ad20 100644
--- a/edk2/SourceLevelDebugPkg/Library/DebugAgent/DebugAgentCommon/DebugMp.c
+++ b/edk2/SourceLevelDebugPkg/Library/DebugAgent/DebugAgentCommon/DebugMp.c
@@ -14,7 +14,7 @@
#include "DebugAgent.h"
-DEBUG_MP_CONTEXT volatile mDebugMpContext = {0,0,0,0,0,0,0,0,FALSE,FALSE};
+DEBUG_MP_CONTEXT volatile mDebugMpContext = {0,0,{0},{0},0,0,0,0,FALSE,FALSE};
DEBUG_CPU_DATA volatile mDebugCpuData = {0};
diff --git a/edk2/SourceLevelDebugPkg/Library/DebugAgent/DxeDebugAgent/SerialIo.c b/edk2/SourceLevelDebugPkg/Library/DebugAgent/DxeDebugAgent/SerialIo.c
index 726eec69c..0cb7c5255 100644
--- a/edk2/SourceLevelDebugPkg/Library/DebugAgent/DxeDebugAgent/SerialIo.c
+++ b/edk2/SourceLevelDebugPkg/Library/DebugAgent/DxeDebugAgent/SerialIo.c
@@ -187,8 +187,10 @@ SERIAL_IO_DEVICE_PATH mSerialIoDevicePath = {
{
HARDWARE_DEVICE_PATH,
HW_VENDOR_DP,
- (UINT8) (sizeof (VENDOR_DEVICE_PATH)),
- (UINT8) ((sizeof (VENDOR_DEVICE_PATH)) >> 8)
+ {
+ (UINT8) (sizeof (VENDOR_DEVICE_PATH)),
+ (UINT8) ((sizeof (VENDOR_DEVICE_PATH)) >> 8)
+ }
},
EFI_DEBUG_AGENT_GUID,
},
@@ -196,8 +198,10 @@ SERIAL_IO_DEVICE_PATH mSerialIoDevicePath = {
{
MESSAGING_DEVICE_PATH,
MSG_UART_DP,
- (UINT8) (sizeof (UART_DEVICE_PATH)),
- (UINT8) ((sizeof (UART_DEVICE_PATH)) >> 8)
+ {
+ (UINT8) (sizeof (UART_DEVICE_PATH)),
+ (UINT8) ((sizeof (UART_DEVICE_PATH)) >> 8)
+ }
},
0,
0, // BaudRate
diff --git a/edk2/StdLib/BsdSocketLib/close.c b/edk2/StdLib/BsdSocketLib/close.c
index f3f7e98cb..01eb48ecb 100644
--- a/edk2/StdLib/BsdSocketLib/close.c
+++ b/edk2/StdLib/BsdSocketLib/close.c
@@ -31,7 +31,6 @@ BslSocketCloseWork (
IN int * pErrno
)
{
- EFI_SERVICE_BINDING_PROTOCOL * pServiceBinding;
EFI_STATUS Status;
//
@@ -50,21 +49,9 @@ BslSocketCloseWork (
}
if ( !EFI_ERROR ( Status )) {
//
- // Locate the socket protocol
+ // Release the socket resources
//
- Status = gBS->LocateProtocol ( &gEfiSocketServiceBindingProtocolGuid,
- NULL,
- (VOID **) &pServiceBinding );
- if ( !EFI_ERROR ( Status )) {
- //
- // Release the handle
- //
- Status = pServiceBinding->DestroyChild ( pServiceBinding,
- pSocketProtocol->SocketHandle );
- }
- if ( EFI_ERROR ( Status )) {
- *pErrno = EIO;
- }
+ *pErrno = EslServiceFreeProtocol ( pSocketProtocol );
}
else {
DEBUG (( DEBUG_ERROR,
diff --git a/edk2/StdLib/EfiSocketLib/DxeSupport.c b/edk2/StdLib/EfiSocketLib/DxeSupport.c
index 284fa9cdf..808b710d2 100644
--- a/edk2/StdLib/EfiSocketLib/DxeSupport.c
+++ b/edk2/StdLib/EfiSocketLib/DxeSupport.c
@@ -91,11 +91,8 @@ EslDxeDestroyChild (
)
{
ESL_LAYER * pLayer;
- ESL_SOCKET * pSocket;
- ESL_SOCKET * pSocketPrevious;
EFI_SOCKET_PROTOCOL * pSocketProtocol;
EFI_STATUS Status;
- EFI_TPL TplPrevious;
DBG_ENTER ( );
@@ -112,101 +109,10 @@ EslDxeDestroyChild (
EFI_OPEN_PROTOCOL_GET_PROTOCOL
);
if ( !EFI_ERROR ( Status )) {
- pSocket = SOCKET_FROM_PROTOCOL ( pSocketProtocol );
-
- //
- // Synchronize with the socket layer
- //
- RAISE_TPL ( TplPrevious, TPL_SOCKETS );
-
- //
- // Walk the socket list
- //
- pSocketPrevious = pLayer->pSocketList;
- if ( NULL != pSocketPrevious ) {
- if ( pSocket == pSocketPrevious ) {
- //
- // Remove the socket from the head of the list
- //
- pLayer->pSocketList = pSocket->pNext;
- }
- else {
- //
- // Find the socket in the middle of the list
- //
- while (( NULL != pSocketPrevious )
- && ( pSocket != pSocketPrevious->pNext )) {
- //
- // Set the next socket
- //
- pSocketPrevious = pSocketPrevious->pNext;
- }
- if ( NULL != pSocketPrevious ) {
- //
- // Remove the socket from the middle of the list
- //
- pSocketPrevious = pSocket->pNext;
- }
- }
- }
- else {
- DEBUG (( DEBUG_ERROR | DEBUG_POOL,
- "ERROR - Socket list is empty!\r\n" ));
- }
-
- //
- // Release the socket layer synchronization
- //
- RESTORE_TPL ( TplPrevious );
-
//
- // Determine if the socket was found
+ // Free the socket resources
//
- if ( NULL != pSocketPrevious ) {
- pSocket->pNext = NULL;
-
- //
- // Remove the socket protocol
- //
- Status = gBS->UninstallMultipleProtocolInterfaces (
- ChildHandle,
- &gEfiSocketProtocolGuid,
- &pSocket->SocketProtocol,
- NULL );
- if ( !EFI_ERROR ( Status )) {
- DEBUG (( DEBUG_POOL | DEBUG_INFO,
- "Removed: gEfiSocketProtocolGuid from 0x%08x\r\n",
- ChildHandle ));
-
- //
- // Free the socket structure
- //
- Status = gBS->FreePool ( pSocket );
- if ( !EFI_ERROR ( Status )) {
- DEBUG (( DEBUG_POOL,
- "0x%08x: Free pSocket, %d bytes\r\n",
- pSocket,
- sizeof ( *pSocket )));
- }
- else {
- DEBUG (( DEBUG_ERROR | DEBUG_POOL,
- "ERROR - Failed to free pSocket 0x%08x, Status: %r\r\n",
- pSocket,
- Status ));
- }
- }
- else {
- DEBUG (( DEBUG_ERROR | DEBUG_POOL | DEBUG_INFO,
- "ERROR - Failed to remove gEfiSocketProtocolGuid from 0x%08x, Status: %r\r\n",
- ChildHandle,
- Status ));
- }
- }
- else {
- DEBUG (( DEBUG_ERROR | DEBUG_INFO,
- "ERROR - The socket was not in the socket list!\r\n" ));
- Status = EFI_NOT_FOUND;
- }
+ Status = EslSocketFree ( pSocketProtocol, NULL );
}
else {
DEBUG (( DEBUG_ERROR,
diff --git a/edk2/StdLib/EfiSocketLib/Socket.c b/edk2/StdLib/EfiSocketLib/Socket.c
index e718e9bdf..a74dcd07f 100644
--- a/edk2/StdLib/EfiSocketLib/Socket.c
+++ b/edk2/StdLib/EfiSocketLib/Socket.c
@@ -1791,6 +1791,11 @@ EslSocketConnect (
case SOCKET_STATE_CONNECTING:
//
+ // Poll the network adapter
+ //
+ EslSocketRxPoll ( pSocket );
+
+ //
// Poll for connection completion
//
if ( NULL == pSocket->pApi->pfnConnectPoll ) {
@@ -1946,6 +1951,168 @@ EslSocketCopyFragmentedBuffer (
/**
+ Free the socket.
+
+ This routine frees the socket structure and handle resources.
+
+ The ::close routine calls EslServiceFreeProtocol which then calls
+ this routine to free the socket context structure and close the
+ handle.
+
+ @param [in] pSocketProtocol Address of an ::EFI_SOCKET_PROTOCOL structure.
+
+ @param [out] pErrno Address to receive the errno value upon completion.
+
+ @retval EFI_SUCCESS The socket resources were returned successfully.
+
+ **/
+EFI_STATUS
+EslSocketFree (
+ IN EFI_SOCKET_PROTOCOL * pSocketProtocol,
+ IN int * pErrno
+ )
+{
+ EFI_HANDLE ChildHandle;
+ int errno;
+ ESL_LAYER * pLayer;
+ ESL_SOCKET * pSocket;
+ ESL_SOCKET * pSocketPrevious;
+ EFI_STATUS Status;
+ EFI_TPL TplPrevious;
+
+ DBG_ENTER ( );
+
+ //
+ // Assume failure
+ //
+ errno = EIO;
+ pSocket = NULL;
+ Status = EFI_INVALID_PARAMETER;
+
+ //
+ // Validate the socket
+ //
+ pLayer = &mEslLayer;
+ if ( NULL != pSocketProtocol ) {
+ pSocket = SOCKET_FROM_PROTOCOL ( pSocketProtocol );
+
+ //
+ // Synchronize with the socket layer
+ //
+ RAISE_TPL ( TplPrevious, TPL_SOCKETS );
+
+ //
+ // Walk the socket list
+ //
+ pSocketPrevious = pLayer->pSocketList;
+ if ( NULL != pSocketPrevious ) {
+ if ( pSocket == pSocketPrevious ) {
+ //
+ // Remove the socket from the head of the list
+ //
+ pLayer->pSocketList = pSocket->pNext;
+ }
+ else {
+ //
+ // Find the socket in the middle of the list
+ //
+ while (( NULL != pSocketPrevious )
+ && ( pSocket != pSocketPrevious->pNext )) {
+ //
+ // Set the next socket
+ //
+ pSocketPrevious = pSocketPrevious->pNext;
+ }
+ if ( NULL != pSocketPrevious ) {
+ //
+ // Remove the socket from the middle of the list
+ //
+ pSocketPrevious = pSocket->pNext;
+ }
+ }
+ }
+ else {
+ DEBUG (( DEBUG_ERROR | DEBUG_POOL,
+ "ERROR - Socket list is empty!\r\n" ));
+ }
+
+ //
+ // Release the socket layer synchronization
+ //
+ RESTORE_TPL ( TplPrevious );
+
+ //
+ // Determine if the socket was found
+ //
+ if ( NULL != pSocketPrevious ) {
+ pSocket->pNext = NULL;
+
+ //
+ // Remove the socket protocol
+ //
+ ChildHandle = pSocket->SocketProtocol.SocketHandle;
+ Status = gBS->UninstallMultipleProtocolInterfaces (
+ ChildHandle,
+ &gEfiSocketProtocolGuid,
+ &pSocket->SocketProtocol,
+ NULL );
+ if ( !EFI_ERROR ( Status )) {
+ DEBUG (( DEBUG_POOL | DEBUG_INFO,
+ "Removed: gEfiSocketProtocolGuid from 0x%08x\r\n",
+ ChildHandle ));
+
+ //
+ // Free the socket structure
+ //
+ Status = gBS->FreePool ( pSocket );
+ if ( !EFI_ERROR ( Status )) {
+ DEBUG (( DEBUG_POOL,
+ "0x%08x: Free pSocket, %d bytes\r\n",
+ pSocket,
+ sizeof ( *pSocket )));
+ errno = 0;
+ }
+ else {
+ DEBUG (( DEBUG_ERROR | DEBUG_POOL,
+ "ERROR - Failed to free pSocket 0x%08x, Status: %r\r\n",
+ pSocket,
+ Status ));
+ }
+ }
+ else {
+ DEBUG (( DEBUG_ERROR | DEBUG_POOL | DEBUG_INFO,
+ "ERROR - Failed to remove gEfiSocketProtocolGuid from 0x%08x, Status: %r\r\n",
+ ChildHandle,
+ Status ));
+ }
+ }
+ else {
+ DEBUG (( DEBUG_ERROR | DEBUG_INFO,
+ "ERROR - The socket was not in the socket list!\r\n" ));
+ Status = EFI_NOT_FOUND;
+ }
+ }
+ else {
+ DEBUG (( DEBUG_ERROR,
+ "ERROR - Invalid parameter pSocketProtocol is NULL\r\n" ));
+ }
+
+ //
+ // Return the errno value if possible
+ //
+ if ( NULL != pErrno ) {
+ *pErrno = errno;
+ }
+
+ //
+ // Return the operation status
+ //
+ DBG_EXIT_STATUS ( Status );
+ return Status;
+}
+
+
+/**
Get the local address.
This routine calls the network specific layer to get the network
diff --git a/edk2/StdLib/EfiSocketLib/Socket.h b/edk2/StdLib/EfiSocketLib/Socket.h
index f2fbdb57b..43a7084f9 100644
--- a/edk2/StdLib/EfiSocketLib/Socket.h
+++ b/edk2/StdLib/EfiSocketLib/Socket.h
@@ -1188,6 +1188,28 @@ EslSocketCopyFragmentedBuffer (
);
/**
+ Free the socket.
+
+ This routine frees the socket structure and handle resources.
+
+ The ::close routine calls EslServiceFreeProtocol which then calls
+ this routine to free the socket context structure and close the
+ handle.
+
+ @param [in] pSocketProtocol Address of an ::EFI_SOCKET_PROTOCOL structure.
+
+ @param [out] pErrno Address to receive the errno value upon completion.
+
+ @retval EFI_SUCCESS The socket resources were returned successfully.
+
+ **/
+EFI_STATUS
+EslSocketFree (
+ IN EFI_SOCKET_PROTOCOL * pSocketProtocol,
+ IN int * pErrno
+ );
+
+/**
Free the ESL_IO_MGMT event and structure
This support routine walks the free list to close the event in
diff --git a/edk2/StdLib/EfiSocketLib/UseEfiSocketLib.c b/edk2/StdLib/EfiSocketLib/UseEfiSocketLib.c
index e44a72043..060598af3 100644
--- a/edk2/StdLib/EfiSocketLib/UseEfiSocketLib.c
+++ b/edk2/StdLib/EfiSocketLib/UseEfiSocketLib.c
@@ -69,6 +69,40 @@ CONST EFI_GUID mEslUdp6ServiceGuid __attribute__((weak)) = {
/**
+ Free the socket resources
+
+ This releases the socket resources allocated by calling
+ EslServiceGetProtocol.
+
+ This routine is called from the ::close routine in BsdSocketLib
+ to release the socket resources.
+
+ @param [in] pSocketProtocol Address of an ::EFI_SOCKET_PROTOCOL
+ structure
+
+ @return Value for ::errno, zero (0) indicates success.
+
+ **/
+int
+EslServiceFreeProtocol (
+ IN EFI_SOCKET_PROTOCOL * pSocketProtocol
+ )
+{
+ int RetVal;
+
+ //
+ // Release the socket resources
+ //
+ EslSocketFree ( pSocketProtocol, &RetVal );
+
+ //
+ // Return the operation status
+ //
+ return RetVal;
+}
+
+
+/**
Connect to the EFI socket library
This routine creates the ::ESL_SOCKET structure and returns
diff --git a/edk2/StdLib/Include/Protocol/EfiSocket.h b/edk2/StdLib/Include/Protocol/EfiSocket.h
index 2664f01bd..022a6a5f2 100644
--- a/edk2/StdLib/Include/Protocol/EfiSocket.h
+++ b/edk2/StdLib/Include/Protocol/EfiSocket.h
@@ -613,6 +613,26 @@ AcceptNB (
);
/**
+ Free the socket resources
+
+ This releases the socket resources allocated by calling
+ EslServiceGetProtocol.
+
+ This routine is called from the ::close routine in BsdSocketLib
+ to release the socket resources.
+
+ @param [in] pSocketProtocol Address of an ::EFI_SOCKET_PROTOCOL
+ structure
+
+ @return Value for ::errno, zero (0) indicates success.
+
+ **/
+int
+EslServiceFreeProtocol (
+ IN EFI_SOCKET_PROTOCOL * pSocketProtocol
+ );
+
+/**
Connect to the EFI socket library
@param [in] ppSocketProtocol Address to receive the socket protocol address
diff --git a/edk2/StdLib/LibC/Locale/multibyte_Utf8.c b/edk2/StdLib/LibC/Locale/multibyte_Utf8.c
index 3f29f2942..36e2cb379 100644
--- a/edk2/StdLib/LibC/Locale/multibyte_Utf8.c
+++ b/edk2/StdLib/LibC/Locale/multibyte_Utf8.c
@@ -15,9 +15,9 @@
#include <wchar.h>
#include <sys/types.h>
-typedef int ch_UCS4;
+typedef int ch_UCS4;
-static mbstate_t LocalConvState = {0};
+static mbstate_t LocalConvState = {0};
/** Map a UTF-8 encoded prefix byte to a sequence length.
Zero means illegal prefix, but valid surrogate if < 0xC0.
@@ -59,12 +59,12 @@ UINT8 utf8_code_length[256] = {
/** Process one byte of a multibyte character.
- @param ch
- @param ps
+ @param[in] ch One byte of a multibyte character.
+ @param[in,out] ps Pointer to a conversion state object.
- @retval -2
- @retval -1
- @retval 1:4
+ @retval -2 ch is an incomplete but potentially valid character.
+ @retval -1 ch is not valid in this context.
+ @retval 1:4 The length, in bytes, of the character ch just completed.
**/
static
int
@@ -174,10 +174,10 @@ ProcessOneByte(unsigned char ch, mbstate_t *ps)
/** Convert one Multibyte sequence.
- @param Dest
- @param Src
- @param Len
- @param pS
+ @param[out] Dest Pointer to output location, or NULL
+ @param[in] Src Multibyte Source (UTF8)
+ @param[in] Len Max Number of bytes to convert
+ @param[in] pS Pointer to State struct., or NULL
@retval -2 Bytes processed comprise an incomplete, but potentially valid, character.
@retval -1 An encoding error was encountered. ps->E indicates the number of bytes consumed.
@@ -219,87 +219,212 @@ DecodeOneStateful(
return NumConv;
}
-/** Convert wide characters (UTF16) into multibyte characters (UTF8)
+/* Determine the number of bytes needed to represent a Wide character
+ as a MBCS character.
+
+ A single wide character may convert into a one, two, three, or four byte
+ narrow (MBCS or UTF-8) character. The number of MBCS bytes can be determined
+ as follows.
+
+ If WCS char < 0x00000080 One Byte
+ Else if WCS char < 0x0000D800 Two Bytes
+ Else Three Bytes
+
+ Since UEFI only supports the Unicode Base Multilingual Plane (BMP),
+ Four-byte characters are not supported.
+
+ @param[in] InCh Wide character to test.
+
+ @retval -1 Improperly formed character
+ @retval 0 InCh is 0x0000
+ @retval >0 Number of bytes needed for the MBCS character
+*/
+int
+EFIAPI
+OneWcToMcLen(const wchar_t InCh)
+{
+ ssize_t NumBytes;
+
+ if(InCh == 0) { // Is this a NUL, 0x0000 ?
+ NumBytes = 0;
+ }
+ else if(InCh < 0x0080) { // Is this a 1-byte character?
+ NumBytes = 1;
+ }
+ else if(InCh < 0x0800) { // Is this a 2-byte character?
+ NumBytes = 2;
+ }
+ else if((InCh >= 0xD800) && (InCh < 0xE000)) { // Is this a surrogate?
+ NumBytes = -1;
+ }
+ else {
+ NumBytes = 3; // Otherwise, it must be a 3-byte character.
+ }
+ return (int)NumBytes; // Return extimate of required bytes.
+}
+
+/* Determine the number of bytes needed to represent a Wide character string
+ as a MBCS string of given maximum length. Will optionally return the number
+ of wide characters that would be consumed.
+
+ A single wide character may convert into a one, two, three, or four byte
+ narrow (MBCS or UTF-8) character. The number of MBCS bytes can be determined
+ as follows.
+
+ If WCS char < 0x00000080 One Byte
+ Else if WCS char < 0x00000800 Two Bytes
+ Else if WCS char < 0x00010000 Three Bytes
+ Else Four Bytes
+
+ Since UEFI only supports the Unicode Base Multilingual Plane (BMP),
+ Four-byte characters should not be encountered.
+
+ @param[in] Src Pointer to a wide character string.
+ @param[in] Limit Maximum number of bytes the converted string may occupy.
+ @param[out] NumChar Pointer to where to store the number of wide characters, or NULL.
+
+ @return The number of bytes required to convert Src to MBCS,
+ not including the terminating NUL. If NumChar is not NULL, the number
+ of characters represented by the return value will be written to
+ where it points.
+*/
+size_t
+EFIAPI
+EstimateWtoM(const wchar_t * Src, size_t Limit, size_t *NumChar)
+{
+ ssize_t Estimate;
+ size_t CharCount;
+ ssize_t NumBytes;
+ wchar_t EChar;
+
+ Estimate = 0;
+ CharCount = 0;
+ EChar = *Src++; // Get the initial character and point to next
+ while(((NumBytes = OneWcToMcLen(EChar)) > 0) &&
+ ((size_t)(Estimate + NumBytes) < Limit))
+ { // Until one of the source characters is NUL
+ ++CharCount; // Count this character.
+ Estimate += NumBytes; // Count the Bytes for this character
+ EChar = *Src++; // Get the next source character and point to the next.
+ }
+ if(NumChar != NULL) {
+ *NumChar = CharCount;
+ }
+ return (size_t)Estimate; // Return esimate of required bytes.
+}
+
+/* Determine the number of characters in a MBCS string.
+ MBCS characters are one to four bytes long. By examining the first byte
+ of a MBCS character, one can determine the number of bytes comprising the
+ character.
+
+ 0x00 - 0x7F One
+ 0xC0 - 0xDF Two
+ 0xE0 - 0xEF Three
+ 0xF0 - 0xF7 Four
+
+ Since UEFI only supports the Unicode Base Multilingual Plane (BMP),
+ Four-byte characters should not be encountered.
+
+ @param[in] Src The string to examine
+
+ @return The number of characters represented by the MBCS string.
+**/
+size_t
+EFIAPI
+CountMbcsChars(const char *Src)
+{
+ size_t Count;
+ char EChar;
+
+ Count = 0;
+ EChar = *Src++;
+ while(EChar != 0) {
+ if(EChar < 0x80) {
+ ++Count;
+ }
+ else if(EChar < 0xE0) {
+ Count += 2;
+ ++Src;
+ }
+ else if(EChar < 0xF0) {
+ Count += 3;
+ Src += 2;
+ }
+ else {
+ // Ill-formed character
+ break;
+ }
+ }
+ return Count;
+}
+
+/** Convert a wide character (UTF16) into a multibyte character (UTF8)
+
+ Converts a wide character into a corresponding multibyte character that
+ begins in the conversion state described by the object pointed to by ps.
+ If dst is not a null pointer, the converted character is then stored into
+ the array pointed to by dst.
+
+ It is the caller's responsibility to ensure that Dest is large enough to
+ hold the resulting MBCS sequence.
@param s Pointer to the wide-character string to convert
- @param size Number of wide characters in s. size <= wcslen(s);
+ @param Dest Pointer to the buffer in which to place the converted sequence, or NULL.
- @return A newly allocated buffer containing the converted string is returned,
- or NULL if an error occurred. Global variable errno contains more
- information if NULL is returned.
+ @retval -1 An error occurred. The error reason is in errno.
+ @retval >=0 The number of bytes stored into Dest.
**/
ssize_t
-EncodeUtf8(char *Dest, wchar_t *s, ssize_t size)
+EncodeUtf8(char *Dest, wchar_t ch)
{
char *p; /* next free byte in build buffer */
- char *v; /* next free byte in destination */
- ssize_t nneeded; /* number of result bytes needed */
- int i; /* index into s of next input byte */
int NumInBuff; // number of bytes in Buff
char Buff[4]; // Buffer into which each character is built
- assert(s != NULL);
- assert(size >= 0);
-
- v = Dest;
- nneeded = 0;
- if((size * MB_LEN_MAX) / MB_LEN_MAX != size) {
- // size is too large and resulted in overflow when multiplied by MB_LEN_MAX
- errno = EINVAL;
- return (ssize_t)-1;
- }
-
- for (i = 0; i < size;) {
- ch_UCS4 ch = s[i++];
p = Buff;
- if (ch < 0x80) {
- /* Encode ASCII -- One Byte */
- *p++ = (char) ch;
- }
- else if (ch < 0x0800) {
- /* Encode Latin-1 -- Two Byte */
- *p++ = (char)(0xc0 | (ch >> 6));
- *p++ = (char)(0x80 | (ch & 0x3f));
- }
- else {
+ NumInBuff = 0;
+ if (ch < 0x80) {
+ /* Encode ASCII -- One Byte */
+ *p++ = (char) ch;
+ NumInBuff = 1;
+ }
+ else if (ch < 0x0800) {
+ /* Encode Latin-1 -- Two Byte */
+ *p++ = (char)(0xc0 | (ch >> 6));
+ *p++ = (char)(0x80 | (ch & 0x3f));
+ NumInBuff = 2;
+ }
+ else {
/* Encode UCS2 Unicode ordinals -- Three Byte */
- /* Special case: check for high surrogate -- Shouldn't happen in UEFI */
- if (0xD800 <= ch && ch <= 0xDBFF && i < size) {
- ch_UCS4 ch2 = s[i];
- /* Check for low surrogate and combine the two to
- form a UCS4 value */
- if (0xDC00 <= ch2 && ch2 <= 0xDFFF) {
- ch = ((ch - 0xD800) << 10 | (ch2 - 0xDC00)) + 0x10000;
- i++;
- /* Encode UCS4 Unicode ordinals -- Four Byte */
- *p++ = (char)(0xf0 | (ch >> 18));
- *p++ = (char)(0x80 | ((ch >> 12) & 0x3f));
- *p++ = (char)(0x80 | ((ch >> 6) & 0x3f));
- *p++ = (char)(0x80 | (ch & 0x3f));
- continue;
- }
- /* Fall through: handles isolated high surrogates */
+ /* Special case: check for surrogate -- Shouldn't happen in UEFI */
+ if (0xD800 <= ch && ch < 0xE000) {
+ errno = EILSEQ;
+ return -1;
}
+ else {
*p++ = (char)(0xe0 | (ch >> 12));
*p++ = (char)(0x80 | ((ch >> 6) & 0x3f));
*p++ = (char)(0x80 | (ch & 0x3f));
+ NumInBuff = 3;
}
- /* At this point, Buff holds the converted character which is NumInBuff bytes long.
- NumInBuff is the value 1, 2, 3, or 4
- */
- NumInBuff = (int)(p - Buff); // Number of bytes in Buff
- if(Dest != NULL) { // Save character if Dest is not NULL
- memcpy(v, Buff, NumInBuff);
- v += NumInBuff;
- }
- nneeded += NumInBuff; // Keep track of the number of bytes put into Dest
}
- if(Dest != NULL) {
- // Terminate the destination string.
- *v = '\0';
+ /* At this point, Buff holds the converted character which is NumInBuff bytes long.
+ NumInBuff is the value 1, 2, 3, or 4
+ */
+ 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 nneeded; // Tell the caller
+ return NumInBuff; // Tell the caller
}
// ######################## Narrow to Wide Conversions #######################
@@ -307,6 +432,8 @@ EncodeUtf8(char *Dest, wchar_t *s, ssize_t size)
/** If ps is not a null pointer, the mbsinit function determines whether the
pointed-to mbstate_t object describes an initial conversion state.
+ @param[in] ps Pointer to the conversion state object to test.
+
@return The mbsinit function returns nonzero if ps is a null pointer
or if the pointed-to object describes an initial conversion
state; otherwise, it returns zero.
@@ -329,8 +456,14 @@ mbsinit(const mbstate_t *ps)
where internal is the mbstate_t object for the mbrlen function, except that
the expression designated by ps is evaluated only once.
- @return The mbrlen function returns a value between zero and n,
- inclusive, (size_t)(-2), or (size_t)(-1).
+ @param[in] s Pointer to a multibyte character sequence.
+ @param[in] n Maximum number of bytes to examine.
+ @param[in] pS Pointer to the conversion state object.
+
+ @retval 0 The next n or fewer characters complete a NUL.
+ @retval 1..n The number of bytes that complete the multibyte character.
+ @retval -2 The next n bytes contribute to an incomplete (but potentially valid) multibyte character.
+ @retval -1 An encoding error occurred.
Declared in: wchar.h
**/
@@ -338,10 +471,10 @@ size_t
mbrlen(
const char *s,
size_t n,
- mbstate_t *ps
+ mbstate_t *pS
)
{
- return mbrtowc(NULL, s, n, ps);
+ return mbrtowc(NULL, s, n, pS);
}
/** Determine the number of bytes comprising a multibyte character.
@@ -392,6 +525,11 @@ corresponding wide character and then, if pwc is not a null pointer, stores that
the object pointed to by pwc. If the corresponding wide character is the null wide
character, the resulting state described is the initial conversion state.
+ @param[out] pwc Pointer to where the resulting wide character is to be stored.
+ @param[in] s Pointer to a multibyte character "string".
+ @param[in] n The maximum number of bytes to inspect.
+ @param[in] ps Pointer to a conversion state object.
+
@retval 0 if the next n or fewer bytes complete the multibyte
character that corresponds to the null wide
character (which is the value stored).
@@ -480,6 +618,11 @@ just past the last multibyte character converted (if any). If conversion stopped
reaching a terminating null character and if dst is not a null pointer, the resulting state
described is the initial conversion state.
+ @param[out] dst Pointer to where the resulting wide character sequence is stored.
+ @param[in] src Pointer to a pointer to the multibyte character sequence to convert.
+ @param[in] len Maximum number of wide characters to be stored into dst.
+ @param[in] ps Pointer to a conversion state object.
+
@return If the input conversion encounters a sequence of bytes that do
not form a valid multibyte character, an encoding error occurs:
the mbsrtowcs function stores the value of the macro EILSEQ in
@@ -564,21 +707,23 @@ mbsrtowcs(
**/
size_t
mbstowcs(
- wchar_t *pwcs,
- const char *s,
- size_t n
+ wchar_t *Dest,
+ const char *Src,
+ size_t Limit
)
{
- /* pwcs may be NULL */
- /* s may be NULL */
+ /* Dest may be NULL */
+ /* Src may be NULL */
- return mbsrtowcs(pwcs, &s, n, NULL);
+ return mbsrtowcs(Dest, &Src, Limit, NULL);
}
/** The btowc function determines whether C constitutes a valid single-byte
character in the initial shift state.
+ @param[in] C A narrow character to test or convert to wide.
+
@return The btowc function returns WEOF if c has the value EOF or if
(unsigned char)C does not constitute a valid single-byte
character in the initial shift state. Otherwise, it returns the
@@ -621,6 +766,12 @@ array whose first element is pointed to by S. At most MB_CUR_MAX bytes are store
wc is a null wide character, a null byte is stored, preceded by any shift sequence needed
to restore the initial shift state; the resulting state described is the initial conversion state.
+ @param[out] Dest Pointer to the location in which to store the resulting
+ multibyte character. Otherwise, NULL to reset the
+ conversion state.
+ @param[in] wchar The wide character to convert.
+ @param[in,out] pS Pointer to a conversion state object, or NULL.
+
@return The wcrtomb function returns the number of bytes stored in the
array object (including any shift sequences). When wc is not a
valid wide character, an encoding error occurs: the function
@@ -631,26 +782,31 @@ to restore the initial shift state; the resulting state described is the initial
**/
size_t
wcrtomb(
- char *s,
+ char *Dest,
wchar_t wchar,
- mbstate_t *ps
+ mbstate_t *pS
)
{
size_t RetVal;
- /* s may be NULL */
- if (s == NULL) {
+ /* Dest may be NULL */
+ if (Dest == NULL) {
RetVal = 1;
}
else {
if (wchar == L'\0') {
- *s = '\0';
+ *Dest = '\0';
RetVal = 1;
}
else {
- RetVal = EncodeUtf8(s, &wchar, 1);
+ RetVal = EncodeUtf8(Dest, wchar);
}
}
+ if(pS == NULL) {
+ pS = &LocalConvState;
+ }
+ pS->A = 0; // Set ps to the initial conversion state
+
return RetVal;
}
@@ -698,27 +854,31 @@ wctomb(
}
/** The wcsrtombs function converts a sequence of wide characters from the array
- indirectly pointed to by S into a sequence of corresponding multibyte
+ indirectly pointed to by Dest into a sequence of corresponding multibyte
characters that begins in the conversion state described by the object
pointed to by ps.
- If S is not a null pointer, the converted characters
- are then stored into the array pointed to by S. Conversion continues
- up to and including a terminating null wide character, which is also
- stored. Conversion stops earlier in two cases: when a wide character is
- reached that does not correspond to a valid multibyte character, or
- (if S is not a null pointer) when the next multibyte character would
- exceed the limit of N total bytes to be stored into the array pointed
- to by S. Each conversion takes place as if by a call to the wcrtomb
- function.)
-
- If S is not a null pointer, the pointer object pointed to by pwcs is
+ If Dest is not a null pointer, the converted characters are stored into the
+ array pointed to by Dest. Conversion continues up to and including a
+ terminating null wide character, which is also stored. Conversion stops
+ earlier in two cases: when a wide character is reached that does not
+ correspond to a valid multibyte character, or (if Dest is not a null
+ pointer) when the next multibyte character would exceed the limit of Limit
+ total bytes to be stored into the array pointed to by Dest. Each conversion
+ takes place as if by a call to the wcrtomb function.)
+
+ If Dest is not a null pointer, the pointer object pointed to by Src is
assigned either a null pointer (if conversion stopped due to reaching
a terminating null wide character) or the address just past the last wide
character converted (if any). If conversion stopped due to reaching a
terminating null wide character, the resulting state described is the
initial conversion state.
+ @param[in] Dest
+ @param[in,out] Src
+ @param[in] Limit Max number of bytes to store in Dest.
+ @param[in,out] ps
+
@return If conversion stops because a wide character is reached that
does not correspond to a valid multibyte character, an
encoding error occurs: the wcsrtombs function stores the
@@ -731,38 +891,50 @@ wctomb(
**/
size_t
wcsrtombs(
- char *s,
- const wchar_t **pwcs,
- size_t n,
- mbstate_t *ps
+ char *Dest,
+ const wchar_t **Src,
+ size_t Limit,
+ mbstate_t *ps
)
{
- int count = 0;
+ size_t NumStored;
+ ssize_t MaxBytes;
+ int count;
+ wchar_t InCh;
- /* s may be NULL */
- /* pwcs may be NULL */
+ NumStored = 0;
+ MaxBytes = (ssize_t)Limit;
+
+ /* Dest may be NULL */
+ /* Src may be NULL */
/* ps appears to be unused */
- if (pwcs == NULL || *pwcs == NULL)
+ if (Src == NULL || *Src == NULL)
return (0);
- if (s == NULL) {
- while (*(*pwcs)++ != 0)
- count++;
- return(count);
+ if (Dest == NULL) {
+ NumStored = EstimateWtoM(*Src, MaxBytes, NULL);
}
-
- if (n != 0) {
- do {
- if ((*s++ = (char) *(*pwcs)++) == 0) {
- *pwcs = NULL;
+ else {
+ while (OneWcToMcLen(InCh = *(*Src)++) <= MaxBytes) {
+ if(InCh == 0) {
+ *Src = NULL;
break;
}
- count++;
- } while (--n != 0);
+ count = (int)wcrtomb(Dest, InCh, NULL);
+ if(count >= 0) {
+ Dest += count;
+ MaxBytes -= count;
+ NumStored += count;
+ }
+ else {
+ NumStored = (size_t)(-1);
+ }
+ }
}
- return count;
+
+ return NumStored;
}
/** Convert a wide-character string into a multibyte character string.
@@ -794,19 +966,23 @@ wcsrtombs(
**/
size_t
wcstombs(
- char *s,
- const wchar_t *pwcs,
- size_t n
+ char *Dest,
+ const wchar_t *Src,
+ size_t Limit
)
{
- /* s may be NULL */
- return wcsrtombs(s, &pwcs, n, NULL);
+ /* Dest may be NULL */
+ return wcsrtombs(Dest, &Src, Limit, NULL);
}
/** The wctob function determines whether C corresponds to a member of the extended
character set whose multibyte character representation is a single byte when in the initial
shift state.
+ wctob needs to be consistent with wcrtomb.
+ If wcrtomb says that a character is representable in 1 byte,
+ then wctob needs to also represent the character as 1 byte.
+
@return The wctob function returns EOF if C does not correspond to a multibyte
character with length one in the initial shift state. Otherwise, it
returns the single-byte representation of that character as an
@@ -817,13 +993,14 @@ wcstombs(
int
wctob(wint_t c)
{
- /* wctob needs to be consistent with wcrtomb.
- if wcrtomb says that a character is representable in 1 byte,
- which this implementation always says, then wctob needs to
- also represent the character as 1 byte.
- */
- if (c == WEOF) {
- return EOF;
+ int RetVal;
+
+ RetVal = EOF;
+ if(c == 0) {
+ RetVal = 0;
+ }
+ else if (OneWcToMcLen((const wchar_t)c) == 1) {
+ RetVal = (int)(c & 0xFF);
}
- return (int)(c & 0xFF);
+ return RetVal;
}
diff --git a/edk2/StdLib/LibC/Main/Main.c b/edk2/StdLib/LibC/Main/Main.c
index 523965fa4..5736428db 100644
--- a/edk2/StdLib/LibC/Main/Main.c
+++ b/edk2/StdLib/LibC/Main/Main.c
@@ -112,11 +112,10 @@ DEBUG_CODE_END();
string = gMD->NCmdLine;
for(count = 0; count < Argc; ++count) {
nArgv[count] = string;
- AVsz = wcstombs(string, Argv[count], nArgvSize);
- string[AVsz] = 0; /* NULL terminate the argument */
+ AVsz = wcstombs(string, Argv[count], nArgvSize) + 1;
DEBUG((DEBUG_INFO, "Cvt[%d] %d \"%s\" --> \"%a\"\n", (INT32)count, (INT32)AVsz, Argv[count], nArgv[count]));
- string += AVsz + 1;
- nArgvSize -= AVsz + 1;
+ string += AVsz;
+ nArgvSize -= AVsz;
if(nArgvSize < 0) {
Print(L"ABORTING: Internal Argv[%d] conversion error.\n", count);
exit(EXIT_FAILURE);
diff --git a/edk2/StdLib/UseSocketDxe/UseSocketDxe.c b/edk2/StdLib/UseSocketDxe/UseSocketDxe.c
index 607414326..423419c23 100644
--- a/edk2/StdLib/UseSocketDxe/UseSocketDxe.c
+++ b/edk2/StdLib/UseSocketDxe/UseSocketDxe.c
@@ -23,6 +23,59 @@
/**
+ Free the socket resources
+
+ This releases the socket resources allocated by calling
+ EslServiceGetProtocol.
+
+ This routine is called from the ::close routine in BsdSocketLib
+ to release the socket resources.
+
+ @param [in] pSocketProtocol Address of an ::EFI_SOCKET_PROTOCOL
+ structure
+
+ @return Value for ::errno, zero (0) indicates success.
+
+ **/
+int
+EslServiceFreeProtocol (
+ IN EFI_SOCKET_PROTOCOL * pSocketProtocol
+ )
+{
+ EFI_SERVICE_BINDING_PROTOCOL * pServiceBinding;
+ int RetVal;
+ EFI_STATUS Status;
+
+ //
+ // Assume success
+ //
+ RetVal = 0;
+
+ //
+ // Locate the socket protocol
+ //
+ Status = gBS->LocateProtocol ( &gEfiSocketServiceBindingProtocolGuid,
+ NULL,
+ (VOID **) &pServiceBinding );
+ if ( !EFI_ERROR ( Status )) {
+ //
+ // Release the handle
+ //
+ Status = pServiceBinding->DestroyChild ( pServiceBinding,
+ pSocketProtocol->SocketHandle );
+ }
+ if ( EFI_ERROR ( Status )) {
+ RetVal = EIO;
+ }
+
+ //
+ // Return the operation status
+ //
+ return RetVal;
+}
+
+
+/**
Connect to the EFI socket library
This routine establishes a connection to the socket driver
diff --git a/edk2/UefiCpuPkg/CpuDxe/CpuDxe.c b/edk2/UefiCpuPkg/CpuDxe/CpuDxe.c
index 34dfbf1e7..958711ca4 100644
--- a/edk2/UefiCpuPkg/CpuDxe/CpuDxe.c
+++ b/edk2/UefiCpuPkg/CpuDxe/CpuDxe.c
@@ -17,7 +17,7 @@
//
// Global Variables
//
-IA32_IDT_GATE_DESCRIPTOR gIdtTable[INTERRUPT_VECTOR_NUMBER] = { 0 };
+IA32_IDT_GATE_DESCRIPTOR gIdtTable[INTERRUPT_VECTOR_NUMBER] = { { { 0 } } };
EFI_CPU_INTERRUPT_HANDLER ExternalVectorTable[0x100];
BOOLEAN InterruptState = FALSE;
diff --git a/edk2/UefiCpuPkg/Library/MtrrLib/MtrrLib.c b/edk2/UefiCpuPkg/Library/MtrrLib/MtrrLib.c
index dea474dd9..586c620bd 100644
--- a/edk2/UefiCpuPkg/Library/MtrrLib/MtrrLib.c
+++ b/edk2/UefiCpuPkg/Library/MtrrLib/MtrrLib.c
@@ -174,7 +174,7 @@ MtrrGetDefaultMemoryType (
This function will do some preparation for programming MTRRs:
disable cache, invalid cache and disable MTRR caching functionality
- @param[out] Pointer to context to save
+ @param[out] MtrrContext Pointer to context to save
**/
VOID
@@ -215,7 +215,7 @@ PreMtrrChange (
This function will do some clean up after programming MTRRs:
Flush all TLBs, re-enable caching, restore CR4.
- @param[in] Pointer to context to restore
+ @param[in] MtrrContext Pointer to context to restore
**/
VOID
@@ -250,7 +250,7 @@ PostMtrrChangeEnableCache (
This function will do some clean up after programming MTRRs:
enable MTRR caching functionality, and enable cache
- @param[in] Pointer to context to restore
+ @param[in] MtrrContext Pointer to context to restore
**/
VOID
diff --git a/edk2/UnixPkg/Deprecated.txt b/edk2/UnixPkg/Deprecated.txt
new file mode 100644
index 000000000..5ffad5fd2
--- /dev/null
+++ b/edk2/UnixPkg/Deprecated.txt
@@ -0,0 +1,5 @@
+UnixPkg is deprecated.
+
+The same functionality is supported using the EmulatorPkg.
+Please see EmulatorPkg/README for more information about EmulatorPkg.
+
diff --git a/edk2/UnixPkg/build.sh b/edk2/UnixPkg/build.sh
index 2498914e1..5d3d8a5e5 100755
--- a/edk2/UnixPkg/build.sh
+++ b/edk2/UnixPkg/build.sh
@@ -118,5 +118,6 @@ done
echo $PATH
echo `which build`
build -p $WORKSPACE/UnixPkg/UnixPkg.dsc -a IA32 -t $TARGET_TOOLS $NETWORK_SUPPORT -n 3 $1 $2 $3 $4 $5 $6 $7 $8
+echo NOTE: UnixPkg is deprecated. Please see UnixPkg/Deprecated.txt for more information.
exit $?
diff --git a/edk2/UnixPkg/build64.sh b/edk2/UnixPkg/build64.sh
index e524faf29..7f2206f3f 100755
--- a/edk2/UnixPkg/build64.sh
+++ b/edk2/UnixPkg/build64.sh
@@ -124,5 +124,6 @@ echo `which build`
build -p $WORKSPACE/UnixPkg/UnixPkgX64.dsc -a X64 -t $TARGET_TOOLS -D SEC_ONLY -n 3 $1 $2 $3 $4 $5 $6 $7 $8 modules
build -p $WORKSPACE/UnixPkg/UnixPkgX64.dsc -a X64 -t $UNIXPKG_TOOLS $NETWORK_SUPPORT -n 3 $1 $2 $3 $4 $5 $6 $7 $8
cp $WORKSPACE/Build/UnixX64/DEBUG_"$TARGET_TOOLS"/X64/SecMain $WORKSPACE/Build/UnixX64/DEBUG_"$UNIXPKG_TOOLS"/X64
+echo NOTE: UnixPkg is deprecated. Please see UnixPkg/Deprecated.txt for more information.
exit $?
diff --git a/edk2/UnixPkg/readme.txt b/edk2/UnixPkg/readme.txt
index f28d626f9..4166306d2 100644
--- a/edk2/UnixPkg/readme.txt
+++ b/edk2/UnixPkg/readme.txt
@@ -1,3 +1,7 @@
+Deprecation Notice
+==================
+UnixPkg is deprecated. Please see UnixPkg/Deprecated.txt for more information.
+
Unix Simulation Platform
========================