From 6eb5ba855628a90a3f628891cfc036b4c3ae8ca9 Mon Sep 17 00:00:00 2001 From: Guo Mang Date: Thu, 27 Apr 2017 11:38:23 +0800 Subject: OvmfPkg: Remove unused Package Contributed-under: TianoCore Contribution Agreement 1.0 Signed-off-by: Guo Mang --- OvmfPkg/AcpiPlatformDxe/AcpiPlatform.c | 261 --- OvmfPkg/AcpiPlatformDxe/AcpiPlatform.h | 122 -- OvmfPkg/AcpiPlatformDxe/AcpiPlatformDxe.inf | 77 - OvmfPkg/AcpiPlatformDxe/BootScript.c | 266 --- OvmfPkg/AcpiPlatformDxe/EntryPoint.c | 96 - OvmfPkg/AcpiPlatformDxe/PciDecoding.c | 198 -- OvmfPkg/AcpiPlatformDxe/Qemu.c | 518 ------ OvmfPkg/AcpiPlatformDxe/QemuFwCfgAcpi.c | 1017 ---------- OvmfPkg/AcpiPlatformDxe/QemuFwCfgAcpiPlatform.c | 39 - .../AcpiPlatformDxe/QemuFwCfgAcpiPlatformDxe.inf | 62 - OvmfPkg/AcpiPlatformDxe/QemuLoader.h | 112 -- OvmfPkg/AcpiPlatformDxe/Xen.c | 318 ---- OvmfPkg/AcpiTables/AcpiTables.inf | 44 - OvmfPkg/AcpiTables/Dsdt.asl | 698 ------- OvmfPkg/AcpiTables/Facp.aslc | 95 - OvmfPkg/AcpiTables/Facs.aslc | 84 - OvmfPkg/AcpiTables/Madt.aslc | 159 -- OvmfPkg/AcpiTables/Platform.h | 74 - OvmfPkg/AcpiTables/Ssdt.asl | 19 - OvmfPkg/BlockMmioToBlockIoDxe/BlockIo.c | 528 ------ OvmfPkg/BlockMmioToBlockIoDxe/BlockIo.h | 346 ---- OvmfPkg/BlockMmioToBlockIoDxe/BlockIo.inf | 55 - OvmfPkg/BlockMmioToBlockIoDxe/ComponentName.c | 162 -- OvmfPkg/Contributions.txt | 218 --- OvmfPkg/Csm/Csm16/Csm16.inf | 23 - OvmfPkg/Csm/Csm16/ReadMe.txt | 12 - OvmfPkg/Csm/CsmSupportLib/CsmSupportLib.c | 38 - OvmfPkg/Csm/CsmSupportLib/CsmSupportLib.h | 55 - OvmfPkg/Csm/CsmSupportLib/CsmSupportLib.inf | 58 - OvmfPkg/Csm/CsmSupportLib/LegacyInterrupt.c | 220 --- OvmfPkg/Csm/CsmSupportLib/LegacyInterrupt.h | 123 -- OvmfPkg/Csm/CsmSupportLib/LegacyPlatform.c | 1066 ----------- OvmfPkg/Csm/CsmSupportLib/LegacyPlatform.h | 104 -- OvmfPkg/Csm/CsmSupportLib/LegacyRegion.c | 504 ----- OvmfPkg/Csm/CsmSupportLib/LegacyRegion.h | 229 --- OvmfPkg/DecomprScratchEnd.fdf.inc | 72 - OvmfPkg/EmuVariableFvbRuntimeDxe/Fvb.c | 923 ---------- OvmfPkg/EmuVariableFvbRuntimeDxe/Fvb.h | 140 -- OvmfPkg/EmuVariableFvbRuntimeDxe/Fvb.inf | 76 - OvmfPkg/Include/Guid/OvmfPlatformConfig.h | 24 - .../Include/Guid/RootBridgesConnectedEventGroup.h | 33 - OvmfPkg/Include/Guid/VirtioMmioTransport.h | 25 - OvmfPkg/Include/Guid/XenBusRootDevice.h | 24 - OvmfPkg/Include/Guid/XenInfo.h | 42 - OvmfPkg/Include/IndustryStandard/E820.h | 46 - OvmfPkg/Include/IndustryStandard/I440FxPiix4.h | 42 - OvmfPkg/Include/IndustryStandard/LegacyVgaBios.h | 97 - OvmfPkg/Include/IndustryStandard/LinuxBzimage.h | 164 -- OvmfPkg/Include/IndustryStandard/Q35MchIch9.h | 112 -- OvmfPkg/Include/IndustryStandard/QemuFwCfg.h | 104 -- OvmfPkg/Include/IndustryStandard/Virtio.h | 24 - OvmfPkg/Include/IndustryStandard/Virtio095.h | 175 -- OvmfPkg/Include/IndustryStandard/Virtio095Net.h | 97 - OvmfPkg/Include/IndustryStandard/Virtio10.h | 86 - OvmfPkg/Include/IndustryStandard/Virtio10Net.h | 32 - OvmfPkg/Include/IndustryStandard/VirtioBlk.h | 89 - OvmfPkg/Include/IndustryStandard/VirtioGpu.h | 216 --- OvmfPkg/Include/IndustryStandard/VirtioNet.h | 22 - OvmfPkg/Include/IndustryStandard/VirtioScsi.h | 99 - OvmfPkg/Include/IndustryStandard/Xen/README | 37 - .../Include/IndustryStandard/Xen/arch-arm/xen.h | 436 ----- .../IndustryStandard/Xen/arch-x86/xen-x86_32.h | 59 - .../IndustryStandard/Xen/arch-x86/xen-x86_64.h | 59 - .../Include/IndustryStandard/Xen/arch-x86/xen.h | 112 -- .../Include/IndustryStandard/Xen/event_channel.h | 118 -- OvmfPkg/Include/IndustryStandard/Xen/grant_table.h | 444 ----- OvmfPkg/Include/IndustryStandard/Xen/hvm/hvm_op.h | 37 - OvmfPkg/Include/IndustryStandard/Xen/hvm/params.h | 150 -- OvmfPkg/Include/IndustryStandard/Xen/io/blkif.h | 619 ------- OvmfPkg/Include/IndustryStandard/Xen/io/console.h | 51 - .../Include/IndustryStandard/Xen/io/protocols.h | 40 - OvmfPkg/Include/IndustryStandard/Xen/io/ring.h | 312 ---- OvmfPkg/Include/IndustryStandard/Xen/io/xenbus.h | 80 - OvmfPkg/Include/IndustryStandard/Xen/io/xs_wire.h | 149 -- OvmfPkg/Include/IndustryStandard/Xen/memory.h | 94 - OvmfPkg/Include/IndustryStandard/Xen/xen-compat.h | 44 - OvmfPkg/Include/IndustryStandard/Xen/xen.h | 346 ---- OvmfPkg/Include/Library/LoadLinuxLib.h | 211 --- OvmfPkg/Include/Library/NvVarsFileLib.h | 51 - OvmfPkg/Include/Library/PlatformFvbLib.h | 87 - OvmfPkg/Include/Library/QemuBootOrderLib.h | 68 - OvmfPkg/Include/Library/QemuFwCfgLib.h | 183 -- OvmfPkg/Include/Library/QemuFwCfgS3Lib.h | 361 ---- OvmfPkg/Include/Library/SerializeVariablesLib.h | 229 --- OvmfPkg/Include/Library/VirtioLib.h | 238 --- OvmfPkg/Include/Library/VirtioMmioDeviceLib.h | 66 - OvmfPkg/Include/Library/XenHypercallLib.h | 98 - OvmfPkg/Include/Library/XenIoMmioLib.h | 64 - OvmfPkg/Include/OvmfPlatforms.h | 46 - OvmfPkg/Include/Protocol/BlockMmio.h | 50 - OvmfPkg/Include/Protocol/VirtioDevice.h | 360 ---- OvmfPkg/Include/Protocol/XenBus.h | 416 ----- OvmfPkg/Include/Protocol/XenIo.h | 48 - OvmfPkg/Include/Register/QemuSmramSaveStateMap.h | 184 -- .../IncompatiblePciDeviceSupport.c | 354 ---- .../IncompatiblePciDeviceSupport.inf | 50 - OvmfPkg/Library/AcpiTimerLib/AcpiTimerLib.c | 216 --- OvmfPkg/Library/AcpiTimerLib/AcpiTimerLib.h | 29 - OvmfPkg/Library/AcpiTimerLib/BaseAcpiTimerLib.c | 109 -- OvmfPkg/Library/AcpiTimerLib/BaseAcpiTimerLib.inf | 37 - OvmfPkg/Library/AcpiTimerLib/BaseRomAcpiTimerLib.c | 127 -- .../Library/AcpiTimerLib/BaseRomAcpiTimerLib.inf | 36 - OvmfPkg/Library/AcpiTimerLib/DxeAcpiTimerLib.c | 89 - OvmfPkg/Library/AcpiTimerLib/DxeAcpiTimerLib.inf | 40 - .../DxePciLibI440FxQ35/DxePciLibI440FxQ35.inf | 47 - OvmfPkg/Library/DxePciLibI440FxQ35/PciLib.c | 1229 ------------- .../Library/EmuVariableFvbLib/EmuVariableFvbLib.c | 103 -- .../EmuVariableFvbLib/EmuVariableFvbLib.inf | 48 - .../Library/LoadLinuxLib/Ia32/JumpToKernel.nasm | 49 - OvmfPkg/Library/LoadLinuxLib/Linux.c | 670 ------- OvmfPkg/Library/LoadLinuxLib/LinuxGdt.c | 181 -- OvmfPkg/Library/LoadLinuxLib/LoadLinuxLib.h | 59 - OvmfPkg/Library/LoadLinuxLib/LoadLinuxLib.inf | 48 - OvmfPkg/Library/LoadLinuxLib/X64/JumpToKernel.nasm | 93 - OvmfPkg/Library/LockBoxLib/LockBoxBase.c | 42 - OvmfPkg/Library/LockBoxLib/LockBoxBaseLib.inf | 47 - OvmfPkg/Library/LockBoxLib/LockBoxDxe.c | 147 -- OvmfPkg/Library/LockBoxLib/LockBoxDxeLib.inf | 53 - OvmfPkg/Library/LockBoxLib/LockBoxLib.c | 378 ---- OvmfPkg/Library/LockBoxLib/LockBoxLib.h | 60 - OvmfPkg/Library/NvVarsFileLib/FsAccess.c | 514 ------ OvmfPkg/Library/NvVarsFileLib/NvVarsFileLib.c | 83 - OvmfPkg/Library/NvVarsFileLib/NvVarsFileLib.h | 61 - OvmfPkg/Library/NvVarsFileLib/NvVarsFileLib.inf | 60 - OvmfPkg/Library/PciHostBridgeLib/PciHostBridge.h | 75 - .../Library/PciHostBridgeLib/PciHostBridgeLib.c | 445 ----- .../Library/PciHostBridgeLib/PciHostBridgeLib.inf | 59 - OvmfPkg/Library/PciHostBridgeLib/XenSupport.c | 456 ----- .../Library/PlatformBootManagerLib/BdsPlatform.c | 1608 ---------------- .../Library/PlatformBootManagerLib/BdsPlatform.h | 195 -- .../PlatformBootManagerLib.inf | 81 - .../Library/PlatformBootManagerLib/PlatformData.c | 93 - .../Library/PlatformBootManagerLib/QemuKernel.c | 170 -- OvmfPkg/Library/PlatformDebugLibIoPort/DebugLib.c | 287 --- .../PlatformDebugLibIoPort.inf | 51 - .../PlatformFvbLibNull/PlatformFvbLibNull.c | 89 - .../PlatformFvbLibNull/PlatformFvbLibNull.inf | 39 - .../Library/PlatformSecureLib/PlatformSecureLib.c | 40 - .../PlatformSecureLib/PlatformSecureLib.inf | 33 - OvmfPkg/Library/QemuBootOrderLib/ExtraRootBusMap.c | 313 ---- OvmfPkg/Library/QemuBootOrderLib/ExtraRootBusMap.h | 40 - .../Library/QemuBootOrderLib/QemuBootOrderLib.c | 1944 -------------------- .../Library/QemuBootOrderLib/QemuBootOrderLib.inf | 68 - OvmfPkg/Library/QemuFwCfgLib/QemuFwCfgLib.c | 370 ---- OvmfPkg/Library/QemuFwCfgLib/QemuFwCfgLib.inf | 50 - .../Library/QemuFwCfgLib/QemuFwCfgLibInternal.h | 46 - OvmfPkg/Library/QemuFwCfgLib/QemuFwCfgPeiDxe.c | 116 -- OvmfPkg/Library/QemuFwCfgLib/QemuFwCfgSec.c | 96 - OvmfPkg/Library/QemuFwCfgLib/QemuFwCfgSecLib.inf | 48 - .../QemuFwCfgS3Lib/BaseQemuFwCfgS3LibNull.inf | 43 - .../QemuFwCfgS3Lib/DxeQemuFwCfgS3LibFwCfg.inf | 46 - .../QemuFwCfgS3Lib/PeiQemuFwCfgS3LibFwCfg.inf | 44 - OvmfPkg/Library/QemuFwCfgS3Lib/QemuFwCfgS3Base.c | 111 -- .../Library/QemuFwCfgS3Lib/QemuFwCfgS3BasePei.c | 227 --- OvmfPkg/Library/QemuFwCfgS3Lib/QemuFwCfgS3Dxe.c | 792 -------- OvmfPkg/Library/QemuFwCfgS3Lib/QemuFwCfgS3Pei.c | 86 - OvmfPkg/Library/QemuFwCfgS3Lib/QemuFwCfgS3PeiDxe.c | 48 - OvmfPkg/Library/ResetSystemLib/ResetSystemLib.c | 148 -- OvmfPkg/Library/ResetSystemLib/ResetSystemLib.inf | 39 - .../SerializeVariablesLib/SerializeVariablesLib.c | 875 --------- .../SerializeVariablesLib/SerializeVariablesLib.h | 39 - .../SerializeVariablesLib.inf | 41 - .../SmbiosVersionLib/DetectSmbiosVersionLib.c | 111 -- .../SmbiosVersionLib/DetectSmbiosVersionLib.inf | 53 - .../Library/SmmCpuFeaturesLib/SmmCpuFeaturesLib.c | 834 --------- .../SmmCpuFeaturesLib/SmmCpuFeaturesLib.inf | 38 - OvmfPkg/Library/VirtioLib/VirtioLib.c | 416 ----- OvmfPkg/Library/VirtioLib/VirtioLib.inf | 36 - .../Library/VirtioMmioDeviceLib/VirtioMmioDevice.c | 223 --- .../Library/VirtioMmioDeviceLib/VirtioMmioDevice.h | 140 -- .../VirtioMmioDeviceFunctions.c | 295 --- .../VirtioMmioDeviceLib/VirtioMmioDeviceLib.inf | 42 - .../XenConsoleSerialPortLib.c | 301 --- .../XenConsoleSerialPortLib.inf | 35 - .../Library/XenHypercallLib/Aarch64/Hypercall.S | 26 - OvmfPkg/Library/XenHypercallLib/Arm/Hypercall.S | 26 - OvmfPkg/Library/XenHypercallLib/ArmXenHypercall.c | 44 - .../Library/XenHypercallLib/Ia32/hypercall.nasm | 25 - OvmfPkg/Library/XenHypercallLib/X64/hypercall.nasm | 26 - OvmfPkg/Library/XenHypercallLib/X86XenHypercall.c | 102 - OvmfPkg/Library/XenHypercallLib/XenHypercall.c | 66 - .../Library/XenHypercallLib/XenHypercallLib.inf | 66 - OvmfPkg/Library/XenIoMmioLib/XenIoMmioLib.c | 166 -- OvmfPkg/Library/XenIoMmioLib/XenIoMmioLib.inf | 40 - OvmfPkg/License.txt | 50 - OvmfPkg/OvmfPkg.dec | 151 -- OvmfPkg/OvmfPkg.fdf.inc | 70 - OvmfPkg/OvmfPkgIa32.dsc | 848 --------- OvmfPkg/OvmfPkgIa32.fdf | 527 ------ OvmfPkg/OvmfPkgIa32X64.dsc | 857 --------- OvmfPkg/OvmfPkgIa32X64.fdf | 527 ------ OvmfPkg/OvmfPkgX64.dsc | 855 --------- OvmfPkg/OvmfPkgX64.fdf | 527 ------ OvmfPkg/PciHotPlugInitDxe/PciHotPlugInit.c | 342 ---- OvmfPkg/PciHotPlugInitDxe/PciHotPlugInit.inf | 42 - OvmfPkg/PlatformDxe/Platform.c | 875 --------- OvmfPkg/PlatformDxe/Platform.h | 43 - OvmfPkg/PlatformDxe/Platform.inf | 69 - OvmfPkg/PlatformDxe/Platform.uni | 38 - OvmfPkg/PlatformDxe/PlatformConfig.c | 131 -- OvmfPkg/PlatformDxe/PlatformConfig.h | 59 - OvmfPkg/PlatformDxe/PlatformForms.vfr | 74 - OvmfPkg/PlatformPei/Cmos.c | 64 - OvmfPkg/PlatformPei/Cmos.h | 56 - OvmfPkg/PlatformPei/FeatureControl.c | 134 -- OvmfPkg/PlatformPei/Fv.c | 100 - OvmfPkg/PlatformPei/MemDetect.c | 616 ------- OvmfPkg/PlatformPei/Platform.c | 674 ------- OvmfPkg/PlatformPei/Platform.h | 106 -- OvmfPkg/PlatformPei/PlatformPei.inf | 114 -- OvmfPkg/PlatformPei/Xen.c | 231 --- OvmfPkg/PlatformPei/Xen.h | 45 - OvmfPkg/QemuFlashFvbServicesRuntimeDxe/FvbInfo.c | 135 -- .../FvbServicesRuntimeDxe.inf | 92 - .../FvbServicesSmm.inf | 91 - .../FwBlockService.c | 1129 ------------ .../FwBlockService.h | 192 -- .../FwBlockServiceDxe.c | 157 -- .../FwBlockServiceSmm.c | 69 - OvmfPkg/QemuFlashFvbServicesRuntimeDxe/QemuFlash.c | 254 --- OvmfPkg/QemuFlashFvbServicesRuntimeDxe/QemuFlash.h | 92 - .../QemuFlashFvbServicesRuntimeDxe/QemuFlashDxe.c | 28 - OvmfPkg/QemuVideoDxe/ComponentName.c | 212 --- OvmfPkg/QemuVideoDxe/Driver.c | 977 ---------- OvmfPkg/QemuVideoDxe/DriverSupportedEfiVersion.c | 21 - OvmfPkg/QemuVideoDxe/Gop.c | 405 ---- OvmfPkg/QemuVideoDxe/Initialize.c | 348 ---- OvmfPkg/QemuVideoDxe/Qemu.h | 510 ----- OvmfPkg/QemuVideoDxe/QemuVideoDxe.inf | 72 - OvmfPkg/QemuVideoDxe/VbeShim.asm | 287 --- OvmfPkg/QemuVideoDxe/VbeShim.c | 275 --- OvmfPkg/QemuVideoDxe/VbeShim.h | 701 ------- OvmfPkg/QemuVideoDxe/VbeShim.sh | 85 - OvmfPkg/README | 311 ---- OvmfPkg/ResetVector/Ia32/PageTables64.asm | 94 - OvmfPkg/ResetVector/ResetVector.inf | 42 - OvmfPkg/ResetVector/ResetVector.nasmb | 73 - OvmfPkg/SataControllerDxe/ComponentName.c | 176 -- OvmfPkg/SataControllerDxe/SataController.c | 1088 ----------- OvmfPkg/SataControllerDxe/SataController.h | 547 ------ OvmfPkg/SataControllerDxe/SataControllerDxe.inf | 49 - OvmfPkg/Sec/Ia32/SecEntry.nasm | 56 - OvmfPkg/Sec/SecMain.c | 945 ---------- OvmfPkg/Sec/SecMain.inf | 76 - OvmfPkg/Sec/X64/SecEntry.nasm | 56 - OvmfPkg/SmbiosPlatformDxe/ArmXen.c | 34 - OvmfPkg/SmbiosPlatformDxe/Qemu.c | 54 - OvmfPkg/SmbiosPlatformDxe/SmbiosPlatformDxe.c | 217 --- OvmfPkg/SmbiosPlatformDxe/SmbiosPlatformDxe.h | 54 - OvmfPkg/SmbiosPlatformDxe/SmbiosPlatformDxe.inf | 69 - OvmfPkg/SmbiosPlatformDxe/X86Xen.c | 98 - OvmfPkg/SmmAccess/SmmAccess2Dxe.c | 156 -- OvmfPkg/SmmAccess/SmmAccess2Dxe.inf | 58 - OvmfPkg/SmmAccess/SmmAccessPei.c | 393 ---- OvmfPkg/SmmAccess/SmmAccessPei.inf | 69 - OvmfPkg/SmmAccess/SmramInternal.c | 188 -- OvmfPkg/SmmAccess/SmramInternal.h | 89 - OvmfPkg/SmmControl2Dxe/SmiFeatures.c | 246 --- OvmfPkg/SmmControl2Dxe/SmiFeatures.h | 46 - OvmfPkg/SmmControl2Dxe/SmmControl2Dxe.c | 392 ---- OvmfPkg/SmmControl2Dxe/SmmControl2Dxe.inf | 75 - OvmfPkg/VarStore.fdf.inc | 72 - OvmfPkg/Virtio10Dxe/Virtio10.c | 1073 ----------- OvmfPkg/Virtio10Dxe/Virtio10.h | 56 - OvmfPkg/Virtio10Dxe/Virtio10.inf | 40 - OvmfPkg/VirtioBlkDxe/VirtioBlk.c | 1158 ------------ OvmfPkg/VirtioBlkDxe/VirtioBlk.h | 291 --- OvmfPkg/VirtioBlkDxe/VirtioBlk.inf | 42 - OvmfPkg/VirtioGpuDxe/Commands.c | 560 ------ OvmfPkg/VirtioGpuDxe/DriverBinding.c | 844 --------- OvmfPkg/VirtioGpuDxe/Gop.c | 646 ------- OvmfPkg/VirtioGpuDxe/VirtioGpu.h | 327 ---- OvmfPkg/VirtioGpuDxe/VirtioGpu.inf | 51 - OvmfPkg/VirtioNetDxe/ComponentName.c | 177 -- OvmfPkg/VirtioNetDxe/DriverBinding.c | 653 ------- OvmfPkg/VirtioNetDxe/EntryPoint.c | 50 - OvmfPkg/VirtioNetDxe/Events.c | 91 - OvmfPkg/VirtioNetDxe/SnpGetStatus.c | 160 -- OvmfPkg/VirtioNetDxe/SnpInitialize.c | 526 ------ OvmfPkg/VirtioNetDxe/SnpMcastIpToMac.c | 108 -- OvmfPkg/VirtioNetDxe/SnpReceive.c | 188 -- OvmfPkg/VirtioNetDxe/SnpReceiveFilters.c | 105 -- OvmfPkg/VirtioNetDxe/SnpSharedHelpers.c | 53 - OvmfPkg/VirtioNetDxe/SnpShutdown.c | 78 - OvmfPkg/VirtioNetDxe/SnpStart.c | 64 - OvmfPkg/VirtioNetDxe/SnpStop.c | 65 - OvmfPkg/VirtioNetDxe/SnpTransmit.c | 169 -- OvmfPkg/VirtioNetDxe/SnpUnsupported.c | 160 -- OvmfPkg/VirtioNetDxe/TechNotes.txt | 355 ---- OvmfPkg/VirtioNetDxe/VirtioNet.h | 283 --- OvmfPkg/VirtioNetDxe/VirtioNet.inf | 60 - OvmfPkg/VirtioPciDeviceDxe/VirtioPciDevice.c | 679 ------- OvmfPkg/VirtioPciDeviceDxe/VirtioPciDevice.h | 159 -- OvmfPkg/VirtioPciDeviceDxe/VirtioPciDeviceDxe.inf | 43 - OvmfPkg/VirtioPciDeviceDxe/VirtioPciFunctions.c | 273 --- OvmfPkg/VirtioRngDxe/VirtioRng.c | 666 ------- OvmfPkg/VirtioRngDxe/VirtioRng.h | 46 - OvmfPkg/VirtioRngDxe/VirtioRng.inf | 45 - OvmfPkg/VirtioScsiDxe/VirtioScsi.c | 1276 ------------- OvmfPkg/VirtioScsiDxe/VirtioScsi.h | 208 --- OvmfPkg/VirtioScsiDxe/VirtioScsi.inf | 47 - OvmfPkg/XenBusDxe/ComponentName.c | 174 -- OvmfPkg/XenBusDxe/ComponentName.h | 94 - OvmfPkg/XenBusDxe/DriverBinding.h | 128 -- OvmfPkg/XenBusDxe/EventChannel.c | 84 - OvmfPkg/XenBusDxe/EventChannel.h | 88 - OvmfPkg/XenBusDxe/GrantTable.c | 221 --- OvmfPkg/XenBusDxe/GrantTable.h | 76 - OvmfPkg/XenBusDxe/Helpers.c | 9 - OvmfPkg/XenBusDxe/TestAndClearBit.c | 46 - OvmfPkg/XenBusDxe/XenBus.c | 386 ---- OvmfPkg/XenBusDxe/XenBus.h | 44 - OvmfPkg/XenBusDxe/XenBusDxe.c | 492 ----- OvmfPkg/XenBusDxe/XenBusDxe.h | 133 -- OvmfPkg/XenBusDxe/XenBusDxe.inf | 67 - OvmfPkg/XenBusDxe/XenStore.c | 1554 ---------------- OvmfPkg/XenBusDxe/XenStore.h | 380 ---- OvmfPkg/XenIoPciDxe/XenIoPciDxe.c | 367 ---- OvmfPkg/XenIoPciDxe/XenIoPciDxe.inf | 45 - OvmfPkg/XenPvBlkDxe/BlockFront.c | 658 ------- OvmfPkg/XenPvBlkDxe/BlockFront.h | 101 - OvmfPkg/XenPvBlkDxe/BlockIo.c | 276 --- OvmfPkg/XenPvBlkDxe/BlockIo.h | 108 -- OvmfPkg/XenPvBlkDxe/ComponentName.c | 176 -- OvmfPkg/XenPvBlkDxe/ComponentName.h | 94 - OvmfPkg/XenPvBlkDxe/DriverBinding.h | 143 -- OvmfPkg/XenPvBlkDxe/XenPvBlkDxe.c | 394 ---- OvmfPkg/XenPvBlkDxe/XenPvBlkDxe.h | 79 - OvmfPkg/XenPvBlkDxe/XenPvBlkDxe.inf | 63 - OvmfPkg/build.sh | 302 --- OvmfPkg/create-release.py | 208 --- 331 files changed, 73277 deletions(-) delete mode 100644 OvmfPkg/AcpiPlatformDxe/AcpiPlatform.c delete mode 100644 OvmfPkg/AcpiPlatformDxe/AcpiPlatform.h delete mode 100644 OvmfPkg/AcpiPlatformDxe/AcpiPlatformDxe.inf delete mode 100644 OvmfPkg/AcpiPlatformDxe/BootScript.c delete mode 100644 OvmfPkg/AcpiPlatformDxe/EntryPoint.c delete mode 100644 OvmfPkg/AcpiPlatformDxe/PciDecoding.c delete mode 100644 OvmfPkg/AcpiPlatformDxe/Qemu.c delete mode 100644 OvmfPkg/AcpiPlatformDxe/QemuFwCfgAcpi.c delete mode 100644 OvmfPkg/AcpiPlatformDxe/QemuFwCfgAcpiPlatform.c delete mode 100644 OvmfPkg/AcpiPlatformDxe/QemuFwCfgAcpiPlatformDxe.inf delete mode 100644 OvmfPkg/AcpiPlatformDxe/QemuLoader.h delete mode 100644 OvmfPkg/AcpiPlatformDxe/Xen.c delete mode 100644 OvmfPkg/AcpiTables/AcpiTables.inf delete mode 100644 OvmfPkg/AcpiTables/Dsdt.asl delete mode 100644 OvmfPkg/AcpiTables/Facp.aslc delete mode 100644 OvmfPkg/AcpiTables/Facs.aslc delete mode 100644 OvmfPkg/AcpiTables/Madt.aslc delete mode 100644 OvmfPkg/AcpiTables/Platform.h delete mode 100644 OvmfPkg/AcpiTables/Ssdt.asl delete mode 100644 OvmfPkg/BlockMmioToBlockIoDxe/BlockIo.c delete mode 100644 OvmfPkg/BlockMmioToBlockIoDxe/BlockIo.h delete mode 100644 OvmfPkg/BlockMmioToBlockIoDxe/BlockIo.inf delete mode 100644 OvmfPkg/BlockMmioToBlockIoDxe/ComponentName.c delete mode 100644 OvmfPkg/Contributions.txt delete mode 100644 OvmfPkg/Csm/Csm16/Csm16.inf delete mode 100644 OvmfPkg/Csm/Csm16/ReadMe.txt delete mode 100644 OvmfPkg/Csm/CsmSupportLib/CsmSupportLib.c delete mode 100644 OvmfPkg/Csm/CsmSupportLib/CsmSupportLib.h delete mode 100644 OvmfPkg/Csm/CsmSupportLib/CsmSupportLib.inf delete mode 100644 OvmfPkg/Csm/CsmSupportLib/LegacyInterrupt.c delete mode 100644 OvmfPkg/Csm/CsmSupportLib/LegacyInterrupt.h delete mode 100644 OvmfPkg/Csm/CsmSupportLib/LegacyPlatform.c delete mode 100644 OvmfPkg/Csm/CsmSupportLib/LegacyPlatform.h delete mode 100644 OvmfPkg/Csm/CsmSupportLib/LegacyRegion.c delete mode 100644 OvmfPkg/Csm/CsmSupportLib/LegacyRegion.h delete mode 100644 OvmfPkg/DecomprScratchEnd.fdf.inc delete mode 100644 OvmfPkg/EmuVariableFvbRuntimeDxe/Fvb.c delete mode 100644 OvmfPkg/EmuVariableFvbRuntimeDxe/Fvb.h delete mode 100644 OvmfPkg/EmuVariableFvbRuntimeDxe/Fvb.inf delete mode 100644 OvmfPkg/Include/Guid/OvmfPlatformConfig.h delete mode 100644 OvmfPkg/Include/Guid/RootBridgesConnectedEventGroup.h delete mode 100644 OvmfPkg/Include/Guid/VirtioMmioTransport.h delete mode 100644 OvmfPkg/Include/Guid/XenBusRootDevice.h delete mode 100644 OvmfPkg/Include/Guid/XenInfo.h delete mode 100644 OvmfPkg/Include/IndustryStandard/E820.h delete mode 100644 OvmfPkg/Include/IndustryStandard/I440FxPiix4.h delete mode 100644 OvmfPkg/Include/IndustryStandard/LegacyVgaBios.h delete mode 100644 OvmfPkg/Include/IndustryStandard/LinuxBzimage.h delete mode 100644 OvmfPkg/Include/IndustryStandard/Q35MchIch9.h delete mode 100644 OvmfPkg/Include/IndustryStandard/QemuFwCfg.h delete mode 100644 OvmfPkg/Include/IndustryStandard/Virtio.h delete mode 100644 OvmfPkg/Include/IndustryStandard/Virtio095.h delete mode 100644 OvmfPkg/Include/IndustryStandard/Virtio095Net.h delete mode 100644 OvmfPkg/Include/IndustryStandard/Virtio10.h delete mode 100644 OvmfPkg/Include/IndustryStandard/Virtio10Net.h delete mode 100644 OvmfPkg/Include/IndustryStandard/VirtioBlk.h delete mode 100644 OvmfPkg/Include/IndustryStandard/VirtioGpu.h delete mode 100644 OvmfPkg/Include/IndustryStandard/VirtioNet.h delete mode 100644 OvmfPkg/Include/IndustryStandard/VirtioScsi.h delete mode 100644 OvmfPkg/Include/IndustryStandard/Xen/README delete mode 100644 OvmfPkg/Include/IndustryStandard/Xen/arch-arm/xen.h delete mode 100644 OvmfPkg/Include/IndustryStandard/Xen/arch-x86/xen-x86_32.h delete mode 100644 OvmfPkg/Include/IndustryStandard/Xen/arch-x86/xen-x86_64.h delete mode 100644 OvmfPkg/Include/IndustryStandard/Xen/arch-x86/xen.h delete mode 100644 OvmfPkg/Include/IndustryStandard/Xen/event_channel.h delete mode 100644 OvmfPkg/Include/IndustryStandard/Xen/grant_table.h delete mode 100644 OvmfPkg/Include/IndustryStandard/Xen/hvm/hvm_op.h delete mode 100644 OvmfPkg/Include/IndustryStandard/Xen/hvm/params.h delete mode 100644 OvmfPkg/Include/IndustryStandard/Xen/io/blkif.h delete mode 100644 OvmfPkg/Include/IndustryStandard/Xen/io/console.h delete mode 100644 OvmfPkg/Include/IndustryStandard/Xen/io/protocols.h delete mode 100644 OvmfPkg/Include/IndustryStandard/Xen/io/ring.h delete mode 100644 OvmfPkg/Include/IndustryStandard/Xen/io/xenbus.h delete mode 100644 OvmfPkg/Include/IndustryStandard/Xen/io/xs_wire.h delete mode 100644 OvmfPkg/Include/IndustryStandard/Xen/memory.h delete mode 100644 OvmfPkg/Include/IndustryStandard/Xen/xen-compat.h delete mode 100644 OvmfPkg/Include/IndustryStandard/Xen/xen.h delete mode 100644 OvmfPkg/Include/Library/LoadLinuxLib.h delete mode 100644 OvmfPkg/Include/Library/NvVarsFileLib.h delete mode 100644 OvmfPkg/Include/Library/PlatformFvbLib.h delete mode 100644 OvmfPkg/Include/Library/QemuBootOrderLib.h delete mode 100644 OvmfPkg/Include/Library/QemuFwCfgLib.h delete mode 100644 OvmfPkg/Include/Library/QemuFwCfgS3Lib.h delete mode 100644 OvmfPkg/Include/Library/SerializeVariablesLib.h delete mode 100644 OvmfPkg/Include/Library/VirtioLib.h delete mode 100644 OvmfPkg/Include/Library/VirtioMmioDeviceLib.h delete mode 100644 OvmfPkg/Include/Library/XenHypercallLib.h delete mode 100644 OvmfPkg/Include/Library/XenIoMmioLib.h delete mode 100644 OvmfPkg/Include/OvmfPlatforms.h delete mode 100644 OvmfPkg/Include/Protocol/BlockMmio.h delete mode 100644 OvmfPkg/Include/Protocol/VirtioDevice.h delete mode 100644 OvmfPkg/Include/Protocol/XenBus.h delete mode 100644 OvmfPkg/Include/Protocol/XenIo.h delete mode 100644 OvmfPkg/Include/Register/QemuSmramSaveStateMap.h delete mode 100644 OvmfPkg/IncompatiblePciDeviceSupportDxe/IncompatiblePciDeviceSupport.c delete mode 100644 OvmfPkg/IncompatiblePciDeviceSupportDxe/IncompatiblePciDeviceSupport.inf delete mode 100644 OvmfPkg/Library/AcpiTimerLib/AcpiTimerLib.c delete mode 100644 OvmfPkg/Library/AcpiTimerLib/AcpiTimerLib.h delete mode 100644 OvmfPkg/Library/AcpiTimerLib/BaseAcpiTimerLib.c delete mode 100644 OvmfPkg/Library/AcpiTimerLib/BaseAcpiTimerLib.inf delete mode 100644 OvmfPkg/Library/AcpiTimerLib/BaseRomAcpiTimerLib.c delete mode 100644 OvmfPkg/Library/AcpiTimerLib/BaseRomAcpiTimerLib.inf delete mode 100644 OvmfPkg/Library/AcpiTimerLib/DxeAcpiTimerLib.c delete mode 100644 OvmfPkg/Library/AcpiTimerLib/DxeAcpiTimerLib.inf delete mode 100644 OvmfPkg/Library/DxePciLibI440FxQ35/DxePciLibI440FxQ35.inf delete mode 100644 OvmfPkg/Library/DxePciLibI440FxQ35/PciLib.c delete mode 100644 OvmfPkg/Library/EmuVariableFvbLib/EmuVariableFvbLib.c delete mode 100644 OvmfPkg/Library/EmuVariableFvbLib/EmuVariableFvbLib.inf delete mode 100644 OvmfPkg/Library/LoadLinuxLib/Ia32/JumpToKernel.nasm delete mode 100644 OvmfPkg/Library/LoadLinuxLib/Linux.c delete mode 100644 OvmfPkg/Library/LoadLinuxLib/LinuxGdt.c delete mode 100644 OvmfPkg/Library/LoadLinuxLib/LoadLinuxLib.h delete mode 100644 OvmfPkg/Library/LoadLinuxLib/LoadLinuxLib.inf delete mode 100644 OvmfPkg/Library/LoadLinuxLib/X64/JumpToKernel.nasm delete mode 100644 OvmfPkg/Library/LockBoxLib/LockBoxBase.c delete mode 100644 OvmfPkg/Library/LockBoxLib/LockBoxBaseLib.inf delete mode 100644 OvmfPkg/Library/LockBoxLib/LockBoxDxe.c delete mode 100644 OvmfPkg/Library/LockBoxLib/LockBoxDxeLib.inf delete mode 100644 OvmfPkg/Library/LockBoxLib/LockBoxLib.c delete mode 100644 OvmfPkg/Library/LockBoxLib/LockBoxLib.h delete mode 100644 OvmfPkg/Library/NvVarsFileLib/FsAccess.c delete mode 100644 OvmfPkg/Library/NvVarsFileLib/NvVarsFileLib.c delete mode 100644 OvmfPkg/Library/NvVarsFileLib/NvVarsFileLib.h delete mode 100644 OvmfPkg/Library/NvVarsFileLib/NvVarsFileLib.inf delete mode 100644 OvmfPkg/Library/PciHostBridgeLib/PciHostBridge.h delete mode 100644 OvmfPkg/Library/PciHostBridgeLib/PciHostBridgeLib.c delete mode 100644 OvmfPkg/Library/PciHostBridgeLib/PciHostBridgeLib.inf delete mode 100644 OvmfPkg/Library/PciHostBridgeLib/XenSupport.c delete mode 100644 OvmfPkg/Library/PlatformBootManagerLib/BdsPlatform.c delete mode 100644 OvmfPkg/Library/PlatformBootManagerLib/BdsPlatform.h delete mode 100644 OvmfPkg/Library/PlatformBootManagerLib/PlatformBootManagerLib.inf delete mode 100644 OvmfPkg/Library/PlatformBootManagerLib/PlatformData.c delete mode 100644 OvmfPkg/Library/PlatformBootManagerLib/QemuKernel.c delete mode 100644 OvmfPkg/Library/PlatformDebugLibIoPort/DebugLib.c delete mode 100644 OvmfPkg/Library/PlatformDebugLibIoPort/PlatformDebugLibIoPort.inf delete mode 100644 OvmfPkg/Library/PlatformFvbLibNull/PlatformFvbLibNull.c delete mode 100644 OvmfPkg/Library/PlatformFvbLibNull/PlatformFvbLibNull.inf delete mode 100644 OvmfPkg/Library/PlatformSecureLib/PlatformSecureLib.c delete mode 100644 OvmfPkg/Library/PlatformSecureLib/PlatformSecureLib.inf delete mode 100644 OvmfPkg/Library/QemuBootOrderLib/ExtraRootBusMap.c delete mode 100644 OvmfPkg/Library/QemuBootOrderLib/ExtraRootBusMap.h delete mode 100644 OvmfPkg/Library/QemuBootOrderLib/QemuBootOrderLib.c delete mode 100644 OvmfPkg/Library/QemuBootOrderLib/QemuBootOrderLib.inf delete mode 100644 OvmfPkg/Library/QemuFwCfgLib/QemuFwCfgLib.c delete mode 100644 OvmfPkg/Library/QemuFwCfgLib/QemuFwCfgLib.inf delete mode 100644 OvmfPkg/Library/QemuFwCfgLib/QemuFwCfgLibInternal.h delete mode 100644 OvmfPkg/Library/QemuFwCfgLib/QemuFwCfgPeiDxe.c delete mode 100644 OvmfPkg/Library/QemuFwCfgLib/QemuFwCfgSec.c delete mode 100644 OvmfPkg/Library/QemuFwCfgLib/QemuFwCfgSecLib.inf delete mode 100644 OvmfPkg/Library/QemuFwCfgS3Lib/BaseQemuFwCfgS3LibNull.inf delete mode 100644 OvmfPkg/Library/QemuFwCfgS3Lib/DxeQemuFwCfgS3LibFwCfg.inf delete mode 100644 OvmfPkg/Library/QemuFwCfgS3Lib/PeiQemuFwCfgS3LibFwCfg.inf delete mode 100644 OvmfPkg/Library/QemuFwCfgS3Lib/QemuFwCfgS3Base.c delete mode 100644 OvmfPkg/Library/QemuFwCfgS3Lib/QemuFwCfgS3BasePei.c delete mode 100644 OvmfPkg/Library/QemuFwCfgS3Lib/QemuFwCfgS3Dxe.c delete mode 100644 OvmfPkg/Library/QemuFwCfgS3Lib/QemuFwCfgS3Pei.c delete mode 100644 OvmfPkg/Library/QemuFwCfgS3Lib/QemuFwCfgS3PeiDxe.c delete mode 100644 OvmfPkg/Library/ResetSystemLib/ResetSystemLib.c delete mode 100644 OvmfPkg/Library/ResetSystemLib/ResetSystemLib.inf delete mode 100644 OvmfPkg/Library/SerializeVariablesLib/SerializeVariablesLib.c delete mode 100644 OvmfPkg/Library/SerializeVariablesLib/SerializeVariablesLib.h delete mode 100644 OvmfPkg/Library/SerializeVariablesLib/SerializeVariablesLib.inf delete mode 100644 OvmfPkg/Library/SmbiosVersionLib/DetectSmbiosVersionLib.c delete mode 100644 OvmfPkg/Library/SmbiosVersionLib/DetectSmbiosVersionLib.inf delete mode 100644 OvmfPkg/Library/SmmCpuFeaturesLib/SmmCpuFeaturesLib.c delete mode 100644 OvmfPkg/Library/SmmCpuFeaturesLib/SmmCpuFeaturesLib.inf delete mode 100644 OvmfPkg/Library/VirtioLib/VirtioLib.c delete mode 100644 OvmfPkg/Library/VirtioLib/VirtioLib.inf delete mode 100644 OvmfPkg/Library/VirtioMmioDeviceLib/VirtioMmioDevice.c delete mode 100644 OvmfPkg/Library/VirtioMmioDeviceLib/VirtioMmioDevice.h delete mode 100644 OvmfPkg/Library/VirtioMmioDeviceLib/VirtioMmioDeviceFunctions.c delete mode 100644 OvmfPkg/Library/VirtioMmioDeviceLib/VirtioMmioDeviceLib.inf delete mode 100644 OvmfPkg/Library/XenConsoleSerialPortLib/XenConsoleSerialPortLib.c delete mode 100644 OvmfPkg/Library/XenConsoleSerialPortLib/XenConsoleSerialPortLib.inf delete mode 100644 OvmfPkg/Library/XenHypercallLib/Aarch64/Hypercall.S delete mode 100644 OvmfPkg/Library/XenHypercallLib/Arm/Hypercall.S delete mode 100644 OvmfPkg/Library/XenHypercallLib/ArmXenHypercall.c delete mode 100644 OvmfPkg/Library/XenHypercallLib/Ia32/hypercall.nasm delete mode 100644 OvmfPkg/Library/XenHypercallLib/X64/hypercall.nasm delete mode 100644 OvmfPkg/Library/XenHypercallLib/X86XenHypercall.c delete mode 100644 OvmfPkg/Library/XenHypercallLib/XenHypercall.c delete mode 100644 OvmfPkg/Library/XenHypercallLib/XenHypercallLib.inf delete mode 100644 OvmfPkg/Library/XenIoMmioLib/XenIoMmioLib.c delete mode 100644 OvmfPkg/Library/XenIoMmioLib/XenIoMmioLib.inf delete mode 100644 OvmfPkg/License.txt delete mode 100644 OvmfPkg/OvmfPkg.dec delete mode 100644 OvmfPkg/OvmfPkg.fdf.inc delete mode 100644 OvmfPkg/OvmfPkgIa32.dsc delete mode 100644 OvmfPkg/OvmfPkgIa32.fdf delete mode 100644 OvmfPkg/OvmfPkgIa32X64.dsc delete mode 100644 OvmfPkg/OvmfPkgIa32X64.fdf delete mode 100644 OvmfPkg/OvmfPkgX64.dsc delete mode 100644 OvmfPkg/OvmfPkgX64.fdf delete mode 100644 OvmfPkg/PciHotPlugInitDxe/PciHotPlugInit.c delete mode 100644 OvmfPkg/PciHotPlugInitDxe/PciHotPlugInit.inf delete mode 100644 OvmfPkg/PlatformDxe/Platform.c delete mode 100644 OvmfPkg/PlatformDxe/Platform.h delete mode 100644 OvmfPkg/PlatformDxe/Platform.inf delete mode 100644 OvmfPkg/PlatformDxe/Platform.uni delete mode 100644 OvmfPkg/PlatformDxe/PlatformConfig.c delete mode 100644 OvmfPkg/PlatformDxe/PlatformConfig.h delete mode 100644 OvmfPkg/PlatformDxe/PlatformForms.vfr delete mode 100644 OvmfPkg/PlatformPei/Cmos.c delete mode 100644 OvmfPkg/PlatformPei/Cmos.h delete mode 100644 OvmfPkg/PlatformPei/FeatureControl.c delete mode 100644 OvmfPkg/PlatformPei/Fv.c delete mode 100644 OvmfPkg/PlatformPei/MemDetect.c delete mode 100644 OvmfPkg/PlatformPei/Platform.c delete mode 100644 OvmfPkg/PlatformPei/Platform.h delete mode 100644 OvmfPkg/PlatformPei/PlatformPei.inf delete mode 100644 OvmfPkg/PlatformPei/Xen.c delete mode 100644 OvmfPkg/PlatformPei/Xen.h delete mode 100644 OvmfPkg/QemuFlashFvbServicesRuntimeDxe/FvbInfo.c delete mode 100644 OvmfPkg/QemuFlashFvbServicesRuntimeDxe/FvbServicesRuntimeDxe.inf delete mode 100644 OvmfPkg/QemuFlashFvbServicesRuntimeDxe/FvbServicesSmm.inf delete mode 100644 OvmfPkg/QemuFlashFvbServicesRuntimeDxe/FwBlockService.c delete mode 100644 OvmfPkg/QemuFlashFvbServicesRuntimeDxe/FwBlockService.h delete mode 100644 OvmfPkg/QemuFlashFvbServicesRuntimeDxe/FwBlockServiceDxe.c delete mode 100644 OvmfPkg/QemuFlashFvbServicesRuntimeDxe/FwBlockServiceSmm.c delete mode 100644 OvmfPkg/QemuFlashFvbServicesRuntimeDxe/QemuFlash.c delete mode 100644 OvmfPkg/QemuFlashFvbServicesRuntimeDxe/QemuFlash.h delete mode 100644 OvmfPkg/QemuFlashFvbServicesRuntimeDxe/QemuFlashDxe.c delete mode 100644 OvmfPkg/QemuVideoDxe/ComponentName.c delete mode 100644 OvmfPkg/QemuVideoDxe/Driver.c delete mode 100644 OvmfPkg/QemuVideoDxe/DriverSupportedEfiVersion.c delete mode 100644 OvmfPkg/QemuVideoDxe/Gop.c delete mode 100644 OvmfPkg/QemuVideoDxe/Initialize.c delete mode 100644 OvmfPkg/QemuVideoDxe/Qemu.h delete mode 100644 OvmfPkg/QemuVideoDxe/QemuVideoDxe.inf delete mode 100644 OvmfPkg/QemuVideoDxe/VbeShim.asm delete mode 100644 OvmfPkg/QemuVideoDxe/VbeShim.c delete mode 100644 OvmfPkg/QemuVideoDxe/VbeShim.h delete mode 100755 OvmfPkg/QemuVideoDxe/VbeShim.sh delete mode 100644 OvmfPkg/README delete mode 100644 OvmfPkg/ResetVector/Ia32/PageTables64.asm delete mode 100644 OvmfPkg/ResetVector/ResetVector.inf delete mode 100644 OvmfPkg/ResetVector/ResetVector.nasmb delete mode 100644 OvmfPkg/SataControllerDxe/ComponentName.c delete mode 100644 OvmfPkg/SataControllerDxe/SataController.c delete mode 100644 OvmfPkg/SataControllerDxe/SataController.h delete mode 100644 OvmfPkg/SataControllerDxe/SataControllerDxe.inf delete mode 100644 OvmfPkg/Sec/Ia32/SecEntry.nasm delete mode 100644 OvmfPkg/Sec/SecMain.c delete mode 100644 OvmfPkg/Sec/SecMain.inf delete mode 100644 OvmfPkg/Sec/X64/SecEntry.nasm delete mode 100644 OvmfPkg/SmbiosPlatformDxe/ArmXen.c delete mode 100644 OvmfPkg/SmbiosPlatformDxe/Qemu.c delete mode 100644 OvmfPkg/SmbiosPlatformDxe/SmbiosPlatformDxe.c delete mode 100644 OvmfPkg/SmbiosPlatformDxe/SmbiosPlatformDxe.h delete mode 100644 OvmfPkg/SmbiosPlatformDxe/SmbiosPlatformDxe.inf delete mode 100644 OvmfPkg/SmbiosPlatformDxe/X86Xen.c delete mode 100644 OvmfPkg/SmmAccess/SmmAccess2Dxe.c delete mode 100644 OvmfPkg/SmmAccess/SmmAccess2Dxe.inf delete mode 100644 OvmfPkg/SmmAccess/SmmAccessPei.c delete mode 100644 OvmfPkg/SmmAccess/SmmAccessPei.inf delete mode 100644 OvmfPkg/SmmAccess/SmramInternal.c delete mode 100644 OvmfPkg/SmmAccess/SmramInternal.h delete mode 100644 OvmfPkg/SmmControl2Dxe/SmiFeatures.c delete mode 100644 OvmfPkg/SmmControl2Dxe/SmiFeatures.h delete mode 100644 OvmfPkg/SmmControl2Dxe/SmmControl2Dxe.c delete mode 100644 OvmfPkg/SmmControl2Dxe/SmmControl2Dxe.inf delete mode 100644 OvmfPkg/VarStore.fdf.inc delete mode 100644 OvmfPkg/Virtio10Dxe/Virtio10.c delete mode 100644 OvmfPkg/Virtio10Dxe/Virtio10.h delete mode 100644 OvmfPkg/Virtio10Dxe/Virtio10.inf delete mode 100644 OvmfPkg/VirtioBlkDxe/VirtioBlk.c delete mode 100644 OvmfPkg/VirtioBlkDxe/VirtioBlk.h delete mode 100644 OvmfPkg/VirtioBlkDxe/VirtioBlk.inf delete mode 100644 OvmfPkg/VirtioGpuDxe/Commands.c delete mode 100644 OvmfPkg/VirtioGpuDxe/DriverBinding.c delete mode 100644 OvmfPkg/VirtioGpuDxe/Gop.c delete mode 100644 OvmfPkg/VirtioGpuDxe/VirtioGpu.h delete mode 100644 OvmfPkg/VirtioGpuDxe/VirtioGpu.inf delete mode 100644 OvmfPkg/VirtioNetDxe/ComponentName.c delete mode 100644 OvmfPkg/VirtioNetDxe/DriverBinding.c delete mode 100644 OvmfPkg/VirtioNetDxe/EntryPoint.c delete mode 100644 OvmfPkg/VirtioNetDxe/Events.c delete mode 100644 OvmfPkg/VirtioNetDxe/SnpGetStatus.c delete mode 100644 OvmfPkg/VirtioNetDxe/SnpInitialize.c delete mode 100644 OvmfPkg/VirtioNetDxe/SnpMcastIpToMac.c delete mode 100644 OvmfPkg/VirtioNetDxe/SnpReceive.c delete mode 100644 OvmfPkg/VirtioNetDxe/SnpReceiveFilters.c delete mode 100644 OvmfPkg/VirtioNetDxe/SnpSharedHelpers.c delete mode 100644 OvmfPkg/VirtioNetDxe/SnpShutdown.c delete mode 100644 OvmfPkg/VirtioNetDxe/SnpStart.c delete mode 100644 OvmfPkg/VirtioNetDxe/SnpStop.c delete mode 100644 OvmfPkg/VirtioNetDxe/SnpTransmit.c delete mode 100644 OvmfPkg/VirtioNetDxe/SnpUnsupported.c delete mode 100644 OvmfPkg/VirtioNetDxe/TechNotes.txt delete mode 100644 OvmfPkg/VirtioNetDxe/VirtioNet.h delete mode 100644 OvmfPkg/VirtioNetDxe/VirtioNet.inf delete mode 100644 OvmfPkg/VirtioPciDeviceDxe/VirtioPciDevice.c delete mode 100644 OvmfPkg/VirtioPciDeviceDxe/VirtioPciDevice.h delete mode 100644 OvmfPkg/VirtioPciDeviceDxe/VirtioPciDeviceDxe.inf delete mode 100644 OvmfPkg/VirtioPciDeviceDxe/VirtioPciFunctions.c delete mode 100644 OvmfPkg/VirtioRngDxe/VirtioRng.c delete mode 100644 OvmfPkg/VirtioRngDxe/VirtioRng.h delete mode 100644 OvmfPkg/VirtioRngDxe/VirtioRng.inf delete mode 100644 OvmfPkg/VirtioScsiDxe/VirtioScsi.c delete mode 100644 OvmfPkg/VirtioScsiDxe/VirtioScsi.h delete mode 100644 OvmfPkg/VirtioScsiDxe/VirtioScsi.inf delete mode 100644 OvmfPkg/XenBusDxe/ComponentName.c delete mode 100644 OvmfPkg/XenBusDxe/ComponentName.h delete mode 100644 OvmfPkg/XenBusDxe/DriverBinding.h delete mode 100644 OvmfPkg/XenBusDxe/EventChannel.c delete mode 100644 OvmfPkg/XenBusDxe/EventChannel.h delete mode 100644 OvmfPkg/XenBusDxe/GrantTable.c delete mode 100644 OvmfPkg/XenBusDxe/GrantTable.h delete mode 100644 OvmfPkg/XenBusDxe/Helpers.c delete mode 100644 OvmfPkg/XenBusDxe/TestAndClearBit.c delete mode 100644 OvmfPkg/XenBusDxe/XenBus.c delete mode 100644 OvmfPkg/XenBusDxe/XenBus.h delete mode 100644 OvmfPkg/XenBusDxe/XenBusDxe.c delete mode 100644 OvmfPkg/XenBusDxe/XenBusDxe.h delete mode 100644 OvmfPkg/XenBusDxe/XenBusDxe.inf delete mode 100644 OvmfPkg/XenBusDxe/XenStore.c delete mode 100644 OvmfPkg/XenBusDxe/XenStore.h delete mode 100644 OvmfPkg/XenIoPciDxe/XenIoPciDxe.c delete mode 100644 OvmfPkg/XenIoPciDxe/XenIoPciDxe.inf delete mode 100644 OvmfPkg/XenPvBlkDxe/BlockFront.c delete mode 100644 OvmfPkg/XenPvBlkDxe/BlockFront.h delete mode 100644 OvmfPkg/XenPvBlkDxe/BlockIo.c delete mode 100644 OvmfPkg/XenPvBlkDxe/BlockIo.h delete mode 100644 OvmfPkg/XenPvBlkDxe/ComponentName.c delete mode 100644 OvmfPkg/XenPvBlkDxe/ComponentName.h delete mode 100644 OvmfPkg/XenPvBlkDxe/DriverBinding.h delete mode 100644 OvmfPkg/XenPvBlkDxe/XenPvBlkDxe.c delete mode 100644 OvmfPkg/XenPvBlkDxe/XenPvBlkDxe.h delete mode 100644 OvmfPkg/XenPvBlkDxe/XenPvBlkDxe.inf delete mode 100755 OvmfPkg/build.sh delete mode 100755 OvmfPkg/create-release.py (limited to 'OvmfPkg') diff --git a/OvmfPkg/AcpiPlatformDxe/AcpiPlatform.c b/OvmfPkg/AcpiPlatformDxe/AcpiPlatform.c deleted file mode 100644 index 61166c65c3..0000000000 --- a/OvmfPkg/AcpiPlatformDxe/AcpiPlatform.c +++ /dev/null @@ -1,261 +0,0 @@ -/** @file - OVMF ACPI Platform Driver - - Copyright (c) 2008 - 2012, Intel Corporation. All rights reserved.
- This program and the accompanying materials - are licensed and made available under the terms and conditions of the BSD License - which accompanies this distribution. The full text of the license may be found at - http://opensource.org/licenses/bsd-license.php - - THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, - WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. - -**/ - -#include "AcpiPlatform.h" - -EFI_STATUS -EFIAPI -InstallAcpiTable ( - IN EFI_ACPI_TABLE_PROTOCOL *AcpiProtocol, - IN VOID *AcpiTableBuffer, - IN UINTN AcpiTableBufferSize, - OUT UINTN *TableKey - ) -{ - return AcpiProtocol->InstallAcpiTable ( - AcpiProtocol, - AcpiTableBuffer, - AcpiTableBufferSize, - TableKey - ); -} - - -/** - Locate the first instance of a protocol. If the protocol requested is an - FV protocol, then it will return the first FV that contains the ACPI table - storage file. - - @param Instance Return pointer to the first instance of the protocol - - @return EFI_SUCCESS The function completed successfully. - @return EFI_NOT_FOUND The protocol could not be located. - @return EFI_OUT_OF_RESOURCES There are not enough resources to find the protocol. - -**/ -EFI_STATUS -LocateFvInstanceWithTables ( - OUT EFI_FIRMWARE_VOLUME2_PROTOCOL **Instance - ) -{ - EFI_STATUS Status; - EFI_HANDLE *HandleBuffer; - UINTN NumberOfHandles; - EFI_FV_FILETYPE FileType; - UINT32 FvStatus; - EFI_FV_FILE_ATTRIBUTES Attributes; - UINTN Size; - UINTN Index; - EFI_FIRMWARE_VOLUME2_PROTOCOL *FvInstance; - - FvStatus = 0; - - // - // Locate protocol. - // - Status = gBS->LocateHandleBuffer ( - ByProtocol, - &gEfiFirmwareVolume2ProtocolGuid, - NULL, - &NumberOfHandles, - &HandleBuffer - ); - if (EFI_ERROR (Status)) { - // - // Defined errors at this time are not found and out of resources. - // - return Status; - } - - // - // Looking for FV with ACPI storage file - // - for (Index = 0; Index < NumberOfHandles; Index++) { - // - // Get the protocol on this handle - // This should not fail because of LocateHandleBuffer - // - Status = gBS->HandleProtocol ( - HandleBuffer[Index], - &gEfiFirmwareVolume2ProtocolGuid, - (VOID**) &FvInstance - ); - ASSERT_EFI_ERROR (Status); - - // - // See if it has the ACPI storage file - // - Status = FvInstance->ReadFile ( - FvInstance, - (EFI_GUID*)PcdGetPtr (PcdAcpiTableStorageFile), - NULL, - &Size, - &FileType, - &Attributes, - &FvStatus - ); - - // - // If we found it, then we are done - // - if (Status == EFI_SUCCESS) { - *Instance = FvInstance; - break; - } - } - - // - // Our exit status is determined by the success of the previous operations - // If the protocol was found, Instance already points to it. - // - - // - // Free any allocated buffers - // - gBS->FreePool (HandleBuffer); - - return Status; -} - - -/** - Find ACPI tables in an FV and install them. - - This is now a fall-back path. Normally, we will search for tables provided - by the VMM first. - - If that fails, we use this function to load the ACPI tables from an FV. The - sources for the FV based tables is located under OvmfPkg/AcpiTables. - - @param AcpiTable Protocol instance pointer - -**/ -EFI_STATUS -EFIAPI -InstallOvmfFvTables ( - IN EFI_ACPI_TABLE_PROTOCOL *AcpiTable - ) -{ - EFI_STATUS Status; - EFI_FIRMWARE_VOLUME2_PROTOCOL *FwVol; - INTN Instance; - EFI_ACPI_COMMON_HEADER *CurrentTable; - UINTN TableHandle; - UINT32 FvStatus; - UINTN TableSize; - UINTN Size; - EFI_ACPI_TABLE_INSTALL_ACPI_TABLE TableInstallFunction; - - Instance = 0; - CurrentTable = NULL; - TableHandle = 0; - - if (QemuDetected ()) { - TableInstallFunction = QemuInstallAcpiTable; - } else { - TableInstallFunction = InstallAcpiTable; - } - - // - // Locate the firmware volume protocol - // - Status = LocateFvInstanceWithTables (&FwVol); - if (EFI_ERROR (Status)) { - return EFI_ABORTED; - } - // - // Read tables from the storage file. - // - while (Status == EFI_SUCCESS) { - - Status = FwVol->ReadSection ( - FwVol, - (EFI_GUID*)PcdGetPtr (PcdAcpiTableStorageFile), - EFI_SECTION_RAW, - Instance, - (VOID**) &CurrentTable, - &Size, - &FvStatus - ); - if (!EFI_ERROR (Status)) { - // - // Add the table - // - TableHandle = 0; - - TableSize = ((EFI_ACPI_DESCRIPTION_HEADER *) CurrentTable)->Length; - ASSERT (Size >= TableSize); - - // - // Install ACPI table - // - Status = TableInstallFunction ( - AcpiTable, - CurrentTable, - TableSize, - &TableHandle - ); - - // - // Free memory allocated by ReadSection - // - gBS->FreePool (CurrentTable); - - if (EFI_ERROR (Status)) { - return EFI_ABORTED; - } - - // - // Increment the instance - // - Instance++; - CurrentTable = NULL; - } - } - - return EFI_SUCCESS; -} - -/** - Effective entrypoint of Acpi Platform driver. - - @param ImageHandle - @param SystemTable - - @return EFI_SUCCESS - @return EFI_LOAD_ERROR - @return EFI_OUT_OF_RESOURCES - -**/ -EFI_STATUS -EFIAPI -InstallAcpiTables ( - IN EFI_ACPI_TABLE_PROTOCOL *AcpiTable - ) -{ - EFI_STATUS Status; - - if (XenDetected ()) { - Status = InstallXenTables (AcpiTable); - } else { - Status = InstallQemuFwCfgTables (AcpiTable); - } - - if (EFI_ERROR (Status)) { - Status = InstallOvmfFvTables (AcpiTable); - } - - return Status; -} - diff --git a/OvmfPkg/AcpiPlatformDxe/AcpiPlatform.h b/OvmfPkg/AcpiPlatformDxe/AcpiPlatform.h deleted file mode 100644 index 83b981ee00..0000000000 --- a/OvmfPkg/AcpiPlatformDxe/AcpiPlatform.h +++ /dev/null @@ -1,122 +0,0 @@ -/** @file - Sample ACPI Platform Driver - - Copyright (c) 2008 - 2012, Intel Corporation. All rights reserved.
- This program and the accompanying materials - are licensed and made available under the terms and conditions of the BSD License - which accompanies this distribution. The full text of the license may be found at - http://opensource.org/licenses/bsd-license.php - - THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, - WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. - -**/ - -#ifndef _ACPI_PLATFORM_H_INCLUDED_ -#define _ACPI_PLATFORM_H_INCLUDED_ - -#include - -#include -#include -#include - -#include -#include -#include -#include - -#include - -typedef struct { - EFI_PCI_IO_PROTOCOL *PciIo; - UINT64 PciAttributes; -} ORIGINAL_ATTRIBUTES; - -typedef struct S3_CONTEXT S3_CONTEXT; - -EFI_STATUS -EFIAPI -InstallAcpiTable ( - IN EFI_ACPI_TABLE_PROTOCOL *AcpiProtocol, - IN VOID *AcpiTableBuffer, - IN UINTN AcpiTableBufferSize, - OUT UINTN *TableKey - ); - -BOOLEAN -QemuDetected ( - VOID - ); - -EFI_STATUS -EFIAPI -QemuInstallAcpiTable ( - IN EFI_ACPI_TABLE_PROTOCOL *AcpiProtocol, - IN VOID *AcpiTableBuffer, - IN UINTN AcpiTableBufferSize, - OUT UINTN *TableKey - ); - -BOOLEAN -XenDetected ( - VOID - ); - -EFI_STATUS -EFIAPI -InstallXenTables ( - IN EFI_ACPI_TABLE_PROTOCOL *AcpiProtocol - ); - -EFI_STATUS -EFIAPI -InstallQemuFwCfgTables ( - IN EFI_ACPI_TABLE_PROTOCOL *AcpiProtocol - ); - -EFI_STATUS -EFIAPI -InstallAcpiTables ( - IN EFI_ACPI_TABLE_PROTOCOL *AcpiTable - ); - -VOID -EnablePciDecoding ( - OUT ORIGINAL_ATTRIBUTES **OriginalAttributes, - OUT UINTN *Count - ); - -VOID -RestorePciDecoding ( - IN ORIGINAL_ATTRIBUTES *OriginalAttributes, - IN UINTN Count - ); - -EFI_STATUS -AllocateS3Context ( - OUT S3_CONTEXT **S3Context, - IN UINTN WritePointerCount - ); - -VOID -ReleaseS3Context ( - IN S3_CONTEXT *S3Context - ); - -EFI_STATUS -SaveCondensedWritePointerToS3Context ( - IN OUT S3_CONTEXT *S3Context, - IN UINT16 PointerItem, - IN UINT8 PointerSize, - IN UINT32 PointerOffset, - IN UINT64 PointerValue - ); - -EFI_STATUS -TransferS3ContextToBootScript ( - IN S3_CONTEXT *S3Context - ); - -#endif - diff --git a/OvmfPkg/AcpiPlatformDxe/AcpiPlatformDxe.inf b/OvmfPkg/AcpiPlatformDxe/AcpiPlatformDxe.inf deleted file mode 100644 index 9a9b2e6bb2..0000000000 --- a/OvmfPkg/AcpiPlatformDxe/AcpiPlatformDxe.inf +++ /dev/null @@ -1,77 +0,0 @@ -## @file -# OVMF ACPI Platform Driver -# -# Copyright (c) 2008 - 2012, Intel Corporation. All rights reserved.
-# This program and the accompanying materials -# are licensed and made available under the terms and conditions of the BSD License -# which accompanies this distribution. The full text of the license may be found at -# http://opensource.org/licenses/bsd-license.php -# -# THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, -# WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. -# -## - -[Defines] - INF_VERSION = 0x00010005 - BASE_NAME = AcpiPlatform - FILE_GUID = 49970331-E3FA-4637-9ABC-3B7868676970 - MODULE_TYPE = DXE_DRIVER - VERSION_STRING = 1.0 - ENTRY_POINT = AcpiPlatformEntryPoint - -# -# The following information is for reference only and not required by the build tools. -# -# VALID_ARCHITECTURES = IA32 X64 IPF EBC -# - -[Sources] - AcpiPlatform.c - Qemu.c - QemuFwCfgAcpi.c - Xen.c - EntryPoint.c - PciDecoding.c - BootScript.c - -[Packages] - MdePkg/MdePkg.dec - MdeModulePkg/MdeModulePkg.dec - OvmfPkg/OvmfPkg.dec - UefiCpuPkg/UefiCpuPkg.dec - PcAtChipsetPkg/PcAtChipsetPkg.dec - -[LibraryClasses] - UefiLib - DxeServicesLib - PcdLib - BaseMemoryLib - DebugLib - UefiBootServicesTableLib - UefiDriverEntryPoint - HobLib - QemuFwCfgLib - QemuFwCfgS3Lib - MemoryAllocationLib - BaseLib - DxeServicesTableLib - OrderedCollectionLib - -[Protocols] - gEfiAcpiTableProtocolGuid # PROTOCOL ALWAYS_CONSUMED - gEfiPciIoProtocolGuid # PROTOCOL SOMETIMES_CONSUMED - -[Guids] - gEfiXenInfoGuid - gRootBridgesConnectedEventGroupGuid - -[Pcd] - gEfiMdeModulePkgTokenSpaceGuid.PcdAcpiTableStorageFile - gEfiMdeModulePkgTokenSpaceGuid.PcdPciDisableBusEnumeration - gUefiCpuPkgTokenSpaceGuid.PcdCpuLocalApicBaseAddress - gPcAtChipsetPkgTokenSpaceGuid.Pcd8259LegacyModeEdgeLevel - gUefiOvmfPkgTokenSpaceGuid.PcdOvmfFdBaseAddress - -[Depex] - gEfiAcpiTableProtocolGuid diff --git a/OvmfPkg/AcpiPlatformDxe/BootScript.c b/OvmfPkg/AcpiPlatformDxe/BootScript.c deleted file mode 100644 index a7d2f9e38f..0000000000 --- a/OvmfPkg/AcpiPlatformDxe/BootScript.c +++ /dev/null @@ -1,266 +0,0 @@ -/** @file - Append an ACPI S3 Boot Script fragment from the QEMU_LOADER_WRITE_POINTER - commands of QEMU's fully processed table linker/loader script. - - Copyright (C) 2017, 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 -#include -#include - -#include "AcpiPlatform.h" - - -// -// Condensed structure for capturing the fw_cfg operations -- select, skip, -// write -- inherent in executing a QEMU_LOADER_WRITE_POINTER command. -// -typedef struct { - UINT16 PointerItem; // resolved from QEMU_LOADER_WRITE_POINTER.PointerFile - UINT8 PointerSize; // copied as-is from QEMU_LOADER_WRITE_POINTER - UINT32 PointerOffset; // copied as-is from QEMU_LOADER_WRITE_POINTER - UINT64 PointerValue; // resolved from QEMU_LOADER_WRITE_POINTER.PointeeFile - // and QEMU_LOADER_WRITE_POINTER.PointeeOffset -} CONDENSED_WRITE_POINTER; - - -// -// Context structure to accumulate CONDENSED_WRITE_POINTER objects from -// QEMU_LOADER_WRITE_POINTER commands. -// -// Any pointers in this structure own the pointed-to objects; that is, when the -// context structure is released, all pointed-to objects must be released too. -// -struct S3_CONTEXT { - CONDENSED_WRITE_POINTER *WritePointers; // one array element per processed - // QEMU_LOADER_WRITE_POINTER - // command - UINTN Allocated; // number of elements allocated for - // WritePointers - UINTN Used; // number of elements populated in - // WritePointers -}; - - -// -// Scratch buffer, allocated in EfiReservedMemoryType type memory, for the ACPI -// S3 Boot Script opcodes to work on. -// -#pragma pack (1) -typedef union { - UINT64 PointerValue; // filled in from CONDENSED_WRITE_POINTER.PointerValue -} SCRATCH_BUFFER; -#pragma pack () - - -/** - Allocate an S3_CONTEXT object. - - @param[out] S3Context The allocated S3_CONTEXT object is returned - through this parameter. - - @param[in] WritePointerCount Number of CONDENSED_WRITE_POINTER elements to - allocate room for. WritePointerCount must be - positive. - - @retval EFI_SUCCESS Allocation successful. - - @retval EFI_OUT_OF_RESOURCES Out of memory. - - @retval EFI_INVALID_PARAMETER WritePointerCount is zero. -**/ -EFI_STATUS -AllocateS3Context ( - OUT S3_CONTEXT **S3Context, - IN UINTN WritePointerCount - ) -{ - EFI_STATUS Status; - S3_CONTEXT *Context; - - if (WritePointerCount == 0) { - return EFI_INVALID_PARAMETER; - } - - Context = AllocateZeroPool (sizeof *Context); - if (Context == NULL) { - return EFI_OUT_OF_RESOURCES; - } - - Context->WritePointers = AllocatePool (WritePointerCount * - sizeof *Context->WritePointers); - if (Context->WritePointers == NULL) { - Status = EFI_OUT_OF_RESOURCES; - goto FreeContext; - } - - Context->Allocated = WritePointerCount; - *S3Context = Context; - return EFI_SUCCESS; - -FreeContext: - FreePool (Context); - - return Status; -} - - -/** - Release an S3_CONTEXT object. - - @param[in] S3Context The object to release. -**/ -VOID -ReleaseS3Context ( - IN S3_CONTEXT *S3Context - ) -{ - FreePool (S3Context->WritePointers); - FreePool (S3Context); -} - - -/** - Save the information necessary to replicate a QEMU_LOADER_WRITE_POINTER - command during S3 resume, in condensed format. - - This function is to be called from ProcessCmdWritePointer(), after all the - sanity checks have passed, and before the fw_cfg operations are performed. - - @param[in,out] S3Context The S3_CONTEXT object into which the caller wants - to save the information that was derived from - QEMU_LOADER_WRITE_POINTER. - - @param[in] PointerItem The FIRMWARE_CONFIG_ITEM that - QEMU_LOADER_WRITE_POINTER.PointerFile was resolved - to, expressed as a UINT16 value. - - @param[in] PointerSize Copied directly from - QEMU_LOADER_WRITE_POINTER.PointerSize. - - @param[in] PointerOffset Copied directly from - QEMU_LOADER_WRITE_POINTER.PointerOffset. - - @param[in] PointerValue The base address of the allocated / downloaded - fw_cfg blob that is identified by - QEMU_LOADER_WRITE_POINTER.PointeeFile, plus - QEMU_LOADER_WRITE_POINTER.PointeeOffset. - - @retval EFI_SUCCESS The information derived from - QEMU_LOADER_WRITE_POINTER has been successfully - absorbed into S3Context. - - @retval EFI_OUT_OF_RESOURCES No room available in S3Context. -**/ -EFI_STATUS -SaveCondensedWritePointerToS3Context ( - IN OUT S3_CONTEXT *S3Context, - IN UINT16 PointerItem, - IN UINT8 PointerSize, - IN UINT32 PointerOffset, - IN UINT64 PointerValue - ) -{ - CONDENSED_WRITE_POINTER *Condensed; - - if (S3Context->Used == S3Context->Allocated) { - return EFI_OUT_OF_RESOURCES; - } - Condensed = S3Context->WritePointers + S3Context->Used; - Condensed->PointerItem = PointerItem; - Condensed->PointerSize = PointerSize; - Condensed->PointerOffset = PointerOffset; - Condensed->PointerValue = PointerValue; - DEBUG ((DEBUG_VERBOSE, "%a: 0x%04x/[0x%08x+%d] := 0x%Lx (%Lu)\n", - __FUNCTION__, PointerItem, PointerOffset, PointerSize, PointerValue, - (UINT64)S3Context->Used)); - ++S3Context->Used; - return EFI_SUCCESS; -} - - -/** - FW_CFG_BOOT_SCRIPT_CALLBACK_FUNCTION provided to QemuFwCfgS3Lib. -**/ -STATIC -VOID -EFIAPI -AppendFwCfgBootScript ( - IN OUT VOID *Context, OPTIONAL - IN OUT VOID *ExternalScratchBuffer - ) -{ - S3_CONTEXT *S3Context; - SCRATCH_BUFFER *ScratchBuffer; - UINTN Index; - - S3Context = Context; - ScratchBuffer = ExternalScratchBuffer; - - for (Index = 0; Index < S3Context->Used; ++Index) { - CONST CONDENSED_WRITE_POINTER *Condensed; - RETURN_STATUS Status; - - Condensed = &S3Context->WritePointers[Index]; - - Status = QemuFwCfgS3ScriptSkipBytes (Condensed->PointerItem, - Condensed->PointerOffset); - if (RETURN_ERROR (Status)) { - goto FatalError; - } - - ScratchBuffer->PointerValue = Condensed->PointerValue; - Status = QemuFwCfgS3ScriptWriteBytes (-1, Condensed->PointerSize); - if (RETURN_ERROR (Status)) { - goto FatalError; - } - } - - DEBUG ((DEBUG_VERBOSE, "%a: boot script fragment saved\n", __FUNCTION__)); - - ReleaseS3Context (S3Context); - return; - -FatalError: - ASSERT (FALSE); - CpuDeadLoop (); -} - - -/** - Translate and append the information from an S3_CONTEXT object to the ACPI S3 - Boot Script. - - The effects of a successful call to this function cannot be undone. - - @param[in] S3Context The S3_CONTEXT object to translate to ACPI S3 Boot - Script opcodes. If the function returns successfully, - the caller must set the S3Context pointer -- originally - returned by AllocateS3Context() -- immediately to NULL, - because the ownership of S3Context has been transfered. - - @retval EFI_SUCCESS The translation of S3Context to ACPI S3 Boot Script - opcodes has been successfully executed or queued. - - @return Error codes from underlying functions. -**/ -EFI_STATUS -TransferS3ContextToBootScript ( - IN S3_CONTEXT *S3Context - ) -{ - RETURN_STATUS Status; - - Status = QemuFwCfgS3CallWhenBootScriptReady (AppendFwCfgBootScript, - S3Context, sizeof (SCRATCH_BUFFER)); - return (EFI_STATUS)Status; -} diff --git a/OvmfPkg/AcpiPlatformDxe/EntryPoint.c b/OvmfPkg/AcpiPlatformDxe/EntryPoint.c deleted file mode 100644 index 1bfd31a037..0000000000 --- a/OvmfPkg/AcpiPlatformDxe/EntryPoint.c +++ /dev/null @@ -1,96 +0,0 @@ -/** @file - Entry point of OVMF ACPI Platform Driver - - Copyright (C) 2015, Red Hat, Inc. - Copyright (c) 2008 - 2015, Intel Corporation. All rights reserved.
- - This program and the accompanying materials are licensed and made available - under the terms and conditions of the BSD License which accompanies this - distribution. The full text of the license may be found at - http://opensource.org/licenses/bsd-license.php - - THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, WITHOUT - WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. -**/ - -#include -#include "AcpiPlatform.h" - -STATIC -EFI_ACPI_TABLE_PROTOCOL * -FindAcpiTableProtocol ( - VOID - ) -{ - EFI_STATUS Status; - EFI_ACPI_TABLE_PROTOCOL *AcpiTable; - - Status = gBS->LocateProtocol ( - &gEfiAcpiTableProtocolGuid, - NULL, - (VOID**)&AcpiTable - ); - ASSERT_EFI_ERROR (Status); - return AcpiTable; -} - - -STATIC -VOID -EFIAPI -OnRootBridgesConnected ( - IN EFI_EVENT Event, - IN VOID *Context - ) -{ - EFI_STATUS Status; - - DEBUG ((EFI_D_INFO, - "%a: root bridges have been connected, installing ACPI tables\n", - __FUNCTION__)); - Status = InstallAcpiTables (FindAcpiTableProtocol ()); - if (EFI_ERROR (Status)) { - DEBUG ((EFI_D_ERROR, "%a: InstallAcpiTables: %r\n", __FUNCTION__, Status)); - } - gBS->CloseEvent (Event); -} - - -EFI_STATUS -EFIAPI -AcpiPlatformEntryPoint ( - IN EFI_HANDLE ImageHandle, - IN EFI_SYSTEM_TABLE *SystemTable - ) -{ - EFI_STATUS Status; - EFI_EVENT RootBridgesConnected; - - // - // If the platform doesn't support PCI, or PCI enumeration has been disabled, - // install the tables at once, and let the entry point's return code reflect - // the full functionality. - // - if (PcdGetBool (PcdPciDisableBusEnumeration)) { - DEBUG ((EFI_D_INFO, "%a: PCI or its enumeration disabled, installing " - "ACPI tables\n", __FUNCTION__)); - return InstallAcpiTables (FindAcpiTableProtocol ()); - } - - // - // Otherwise, delay installing the ACPI tables until root bridges are - // connected. The entry point's return status will only reflect the callback - // setup. (Note that we're a DXE_DRIVER; our entry point function is invoked - // strictly before BDS is entered and can connect the root bridges.) - // - Status = gBS->CreateEventEx (EVT_NOTIFY_SIGNAL, TPL_CALLBACK, - OnRootBridgesConnected, NULL /* Context */, - &gRootBridgesConnectedEventGroupGuid, &RootBridgesConnected); - if (!EFI_ERROR (Status)) { - DEBUG ((EFI_D_INFO, - "%a: waiting for root bridges to be connected, registered callback\n", - __FUNCTION__)); - } - - return Status; -} diff --git a/OvmfPkg/AcpiPlatformDxe/PciDecoding.c b/OvmfPkg/AcpiPlatformDxe/PciDecoding.c deleted file mode 100644 index d63b57e701..0000000000 --- a/OvmfPkg/AcpiPlatformDxe/PciDecoding.c +++ /dev/null @@ -1,198 +0,0 @@ -/** @file - Temporarily enable IO and MMIO decoding for all PCI devices while QEMU - regenerates the ACPI tables. - - Copyright (C) 2016, 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 - -#include "AcpiPlatform.h" - - -/** - Collect all PciIo protocol instances in the system. Save their original - attributes, and enable IO and MMIO decoding for each. - - This is a best effort function; it doesn't return status codes. Its - caller is supposed to proceed even if this function fails. - - @param[out] OriginalAttributes On output, a dynamically allocated array of - ORIGINAL_ATTRIBUTES elements. The array lists - the PciIo protocol instances found in the - system at the time of the call, plus the - original PCI attributes for each. - - Before returning, the function enables IO and - MMIO decoding for each PciIo instance it - finds. - - On error, or when no such instances are - found, OriginalAttributes is set to NULL. - - @param[out] Count On output, the number of elements in - OriginalAttributes. On error it is set to - zero. -**/ -VOID -EnablePciDecoding ( - OUT ORIGINAL_ATTRIBUTES **OriginalAttributes, - OUT UINTN *Count - ) -{ - EFI_STATUS Status; - UINTN NoHandles; - EFI_HANDLE *Handles; - ORIGINAL_ATTRIBUTES *OrigAttrs; - UINTN Idx; - - *OriginalAttributes = NULL; - *Count = 0; - - if (PcdGetBool (PcdPciDisableBusEnumeration)) { - // - // The platform downloads ACPI tables from QEMU in general, but there are - // no root bridges in this execution. We're done. - // - return; - } - - Status = gBS->LocateHandleBuffer (ByProtocol, &gEfiPciIoProtocolGuid, - NULL /* SearchKey */, &NoHandles, &Handles); - if (Status == EFI_NOT_FOUND) { - // - // No PCI devices were found on either of the root bridges. We're done. - // - return; - } - - if (EFI_ERROR (Status)) { - DEBUG ((EFI_D_WARN, "%a: LocateHandleBuffer(): %r\n", __FUNCTION__, - Status)); - return; - } - - OrigAttrs = AllocatePool (NoHandles * sizeof *OrigAttrs); - if (OrigAttrs == NULL) { - DEBUG ((EFI_D_WARN, "%a: AllocatePool(): out of resources\n", - __FUNCTION__)); - goto FreeHandles; - } - - for (Idx = 0; Idx < NoHandles; ++Idx) { - EFI_PCI_IO_PROTOCOL *PciIo; - UINT64 Attributes; - - // - // Look up PciIo on the handle and stash it - // - Status = gBS->HandleProtocol (Handles[Idx], &gEfiPciIoProtocolGuid, - (VOID**)&PciIo); - ASSERT_EFI_ERROR (Status); - OrigAttrs[Idx].PciIo = PciIo; - - // - // Stash the current attributes - // - Status = PciIo->Attributes (PciIo, EfiPciIoAttributeOperationGet, 0, - &OrigAttrs[Idx].PciAttributes); - if (EFI_ERROR (Status)) { - DEBUG ((EFI_D_WARN, "%a: EfiPciIoAttributeOperationGet: %r\n", - __FUNCTION__, Status)); - goto RestoreAttributes; - } - - // - // Retrieve supported attributes - // - Status = PciIo->Attributes (PciIo, EfiPciIoAttributeOperationSupported, 0, - &Attributes); - if (EFI_ERROR (Status)) { - DEBUG ((EFI_D_WARN, "%a: EfiPciIoAttributeOperationSupported: %r\n", - __FUNCTION__, Status)); - goto RestoreAttributes; - } - - // - // Enable IO and MMIO decoding - // - Attributes &= EFI_PCI_IO_ATTRIBUTE_IO | EFI_PCI_IO_ATTRIBUTE_MEMORY; - Status = PciIo->Attributes (PciIo, EfiPciIoAttributeOperationEnable, - Attributes, NULL); - if (EFI_ERROR (Status)) { - DEBUG ((EFI_D_WARN, "%a: EfiPciIoAttributeOperationEnable: %r\n", - __FUNCTION__, Status)); - goto RestoreAttributes; - } - } - - // - // Success - // - FreePool (Handles); - *OriginalAttributes = OrigAttrs; - *Count = NoHandles; - return; - -RestoreAttributes: - while (Idx > 0) { - --Idx; - OrigAttrs[Idx].PciIo->Attributes (OrigAttrs[Idx].PciIo, - EfiPciIoAttributeOperationSet, - OrigAttrs[Idx].PciAttributes, - NULL - ); - } - FreePool (OrigAttrs); - -FreeHandles: - FreePool (Handles); -} - - -/** - Restore the original PCI attributes saved with EnablePciDecoding(). - - @param[in] OriginalAttributes The array allocated and populated by - EnablePciDecoding(). This parameter may be - NULL. If OriginalAttributes is NULL, then the - function is a no-op; otherwise the PciIo - attributes will be restored, and the - OriginalAttributes array will be freed. - - @param[in] Count The Count value stored by EnablePciDecoding(), - the number of elements in OriginalAttributes. - Count may be zero if and only if - OriginalAttributes is NULL. -**/ -VOID -RestorePciDecoding ( - IN ORIGINAL_ATTRIBUTES *OriginalAttributes, - IN UINTN Count - ) -{ - UINTN Idx; - - ASSERT ((OriginalAttributes == NULL) == (Count == 0)); - if (OriginalAttributes == NULL) { - return; - } - - for (Idx = 0; Idx < Count; ++Idx) { - OriginalAttributes[Idx].PciIo->Attributes ( - OriginalAttributes[Idx].PciIo, - EfiPciIoAttributeOperationSet, - OriginalAttributes[Idx].PciAttributes, - NULL - ); - } - FreePool (OriginalAttributes); -} diff --git a/OvmfPkg/AcpiPlatformDxe/Qemu.c b/OvmfPkg/AcpiPlatformDxe/Qemu.c deleted file mode 100644 index 90f06bba63..0000000000 --- a/OvmfPkg/AcpiPlatformDxe/Qemu.c +++ /dev/null @@ -1,518 +0,0 @@ -/** @file - OVMF ACPI QEMU support - - Copyright (c) 2008 - 2014, Intel Corporation. All rights reserved.
- - Copyright (C) 2012-2014, 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 "AcpiPlatform.h" -#include "QemuLoader.h" -#include -#include -#include -#include -#include -#include -#include - -BOOLEAN -QemuDetected ( - VOID - ) -{ - if (!QemuFwCfgIsAvailable ()) { - return FALSE; - } - - return TRUE; -} - - -STATIC -UINTN -CountBits16 ( - UINT16 Mask - ) -{ - // - // For all N >= 1, N bits are enough to represent the number of bits set - // among N bits. It's true for N == 1. When adding a new bit (N := N+1), - // the maximum number of possibly set bits increases by one, while the - // representable maximum doubles. - // - Mask = ((Mask & 0xAAAA) >> 1) + (Mask & 0x5555); - Mask = ((Mask & 0xCCCC) >> 2) + (Mask & 0x3333); - Mask = ((Mask & 0xF0F0) >> 4) + (Mask & 0x0F0F); - Mask = ((Mask & 0xFF00) >> 8) + (Mask & 0x00FF); - - return Mask; -} - - -STATIC -EFI_STATUS -EFIAPI -QemuInstallAcpiMadtTable ( - IN EFI_ACPI_TABLE_PROTOCOL *AcpiProtocol, - IN VOID *AcpiTableBuffer, - IN UINTN AcpiTableBufferSize, - OUT UINTN *TableKey - ) -{ - UINTN CpuCount; - UINTN PciLinkIsoCount; - UINTN NewBufferSize; - EFI_ACPI_1_0_MULTIPLE_APIC_DESCRIPTION_TABLE_HEADER *Madt; - EFI_ACPI_1_0_PROCESSOR_LOCAL_APIC_STRUCTURE *LocalApic; - EFI_ACPI_1_0_IO_APIC_STRUCTURE *IoApic; - EFI_ACPI_1_0_INTERRUPT_SOURCE_OVERRIDE_STRUCTURE *Iso; - EFI_ACPI_1_0_LOCAL_APIC_NMI_STRUCTURE *LocalApicNmi; - VOID *Ptr; - UINTN Loop; - EFI_STATUS Status; - - ASSERT (AcpiTableBufferSize >= sizeof (EFI_ACPI_DESCRIPTION_HEADER)); - - QemuFwCfgSelectItem (QemuFwCfgItemSmpCpuCount); - CpuCount = QemuFwCfgRead16 (); - ASSERT (CpuCount >= 1); - - // - // Set Level-tiggered, Active High for these identity mapped IRQs. The bitset - // corresponds to the union of all possible interrupt assignments for the LNKA, - // LNKB, LNKC, LNKD PCI interrupt lines. See the DSDT. - // - PciLinkIsoCount = CountBits16 (PcdGet16 (Pcd8259LegacyModeEdgeLevel)); - - NewBufferSize = 1 * sizeof (*Madt) + - CpuCount * sizeof (*LocalApic) + - 1 * sizeof (*IoApic) + - (1 + PciLinkIsoCount) * sizeof (*Iso) + - 1 * sizeof (*LocalApicNmi); - - Madt = AllocatePool (NewBufferSize); - if (Madt == NULL) { - return EFI_OUT_OF_RESOURCES; - } - - CopyMem (&(Madt->Header), AcpiTableBuffer, sizeof (EFI_ACPI_DESCRIPTION_HEADER)); - Madt->Header.Length = (UINT32) NewBufferSize; - Madt->LocalApicAddress = PcdGet32 (PcdCpuLocalApicBaseAddress); - Madt->Flags = EFI_ACPI_1_0_PCAT_COMPAT; - Ptr = Madt + 1; - - LocalApic = Ptr; - for (Loop = 0; Loop < CpuCount; ++Loop) { - LocalApic->Type = EFI_ACPI_1_0_PROCESSOR_LOCAL_APIC; - LocalApic->Length = sizeof (*LocalApic); - LocalApic->AcpiProcessorId = (UINT8) Loop; - LocalApic->ApicId = (UINT8) Loop; - LocalApic->Flags = 1; // enabled - ++LocalApic; - } - Ptr = LocalApic; - - IoApic = Ptr; - IoApic->Type = EFI_ACPI_1_0_IO_APIC; - IoApic->Length = sizeof (*IoApic); - IoApic->IoApicId = (UINT8) CpuCount; - IoApic->Reserved = EFI_ACPI_RESERVED_BYTE; - IoApic->IoApicAddress = 0xFEC00000; - IoApic->SystemVectorBase = 0x00000000; - Ptr = IoApic + 1; - - // - // IRQ0 (8254 Timer) => IRQ2 (PIC) Interrupt Source Override Structure - // - Iso = Ptr; - Iso->Type = EFI_ACPI_1_0_INTERRUPT_SOURCE_OVERRIDE; - Iso->Length = sizeof (*Iso); - Iso->Bus = 0x00; // ISA - Iso->Source = 0x00; // IRQ0 - Iso->GlobalSystemInterruptVector = 0x00000002; - Iso->Flags = 0x0000; // Conforms to specs of the bus - ++Iso; - - // - // Set Level-tiggered, Active High for all possible PCI link targets. - // - for (Loop = 0; Loop < 16; ++Loop) { - if ((PcdGet16 (Pcd8259LegacyModeEdgeLevel) & (1 << Loop)) == 0) { - continue; - } - Iso->Type = EFI_ACPI_1_0_INTERRUPT_SOURCE_OVERRIDE; - Iso->Length = sizeof (*Iso); - Iso->Bus = 0x00; // ISA - Iso->Source = (UINT8) Loop; - Iso->GlobalSystemInterruptVector = (UINT32) Loop; - Iso->Flags = 0x000D; // Level-tiggered, Active High - ++Iso; - } - ASSERT ( - (UINTN) (Iso - (EFI_ACPI_1_0_INTERRUPT_SOURCE_OVERRIDE_STRUCTURE *)Ptr) == - 1 + PciLinkIsoCount - ); - Ptr = Iso; - - LocalApicNmi = Ptr; - LocalApicNmi->Type = EFI_ACPI_1_0_LOCAL_APIC_NMI; - LocalApicNmi->Length = sizeof (*LocalApicNmi); - LocalApicNmi->AcpiProcessorId = 0xFF; // applies to all processors - // - // polarity and trigger mode of the APIC I/O input signals conform to the - // specifications of the bus - // - LocalApicNmi->Flags = 0x0000; - // - // Local APIC interrupt input LINTn to which NMI is connected. - // - LocalApicNmi->LocalApicInti = 0x01; - Ptr = LocalApicNmi + 1; - - ASSERT ((UINTN) ((UINT8 *)Ptr - (UINT8 *)Madt) == NewBufferSize); - Status = InstallAcpiTable (AcpiProtocol, Madt, NewBufferSize, TableKey); - - FreePool (Madt); - - return Status; -} - - -#pragma pack(1) - -typedef struct { - UINT64 Base; - UINT64 End; - UINT64 Length; -} PCI_WINDOW; - -typedef struct { - PCI_WINDOW PciWindow32; - PCI_WINDOW PciWindow64; -} FIRMWARE_DATA; - -typedef struct { - UINT8 BytePrefix; - UINT8 ByteValue; -} AML_BYTE; - -typedef struct { - UINT8 NameOp; - UINT8 RootChar; - UINT8 NameChar[4]; - UINT8 PackageOp; - UINT8 PkgLength; - UINT8 NumElements; - AML_BYTE Pm1aCntSlpTyp; - AML_BYTE Pm1bCntSlpTyp; - AML_BYTE Reserved[2]; -} SYSTEM_STATE_PACKAGE; - -#pragma pack() - - -STATIC -EFI_STATUS -EFIAPI -PopulateFwData( - OUT FIRMWARE_DATA *FwData - ) -{ - EFI_STATUS Status; - UINTN NumDesc; - EFI_GCD_MEMORY_SPACE_DESCRIPTOR *AllDesc; - - Status = gDS->GetMemorySpaceMap (&NumDesc, &AllDesc); - if (Status == EFI_SUCCESS) { - UINT64 NonMmio32MaxExclTop; - UINT64 Mmio32MinBase; - UINT64 Mmio32MaxExclTop; - UINTN CurDesc; - - Status = EFI_UNSUPPORTED; - - NonMmio32MaxExclTop = 0; - Mmio32MinBase = BASE_4GB; - Mmio32MaxExclTop = 0; - - for (CurDesc = 0; CurDesc < NumDesc; ++CurDesc) { - CONST EFI_GCD_MEMORY_SPACE_DESCRIPTOR *Desc; - UINT64 ExclTop; - - Desc = &AllDesc[CurDesc]; - ExclTop = Desc->BaseAddress + Desc->Length; - - if (ExclTop <= (UINT64) PcdGet32 (PcdOvmfFdBaseAddress)) { - switch (Desc->GcdMemoryType) { - case EfiGcdMemoryTypeNonExistent: - break; - - case EfiGcdMemoryTypeReserved: - case EfiGcdMemoryTypeSystemMemory: - if (NonMmio32MaxExclTop < ExclTop) { - NonMmio32MaxExclTop = ExclTop; - } - break; - - case EfiGcdMemoryTypeMemoryMappedIo: - if (Mmio32MinBase > Desc->BaseAddress) { - Mmio32MinBase = Desc->BaseAddress; - } - if (Mmio32MaxExclTop < ExclTop) { - Mmio32MaxExclTop = ExclTop; - } - break; - - default: - ASSERT(0); - } - } - } - - if (Mmio32MinBase < NonMmio32MaxExclTop) { - Mmio32MinBase = NonMmio32MaxExclTop; - } - - if (Mmio32MinBase < Mmio32MaxExclTop) { - FwData->PciWindow32.Base = Mmio32MinBase; - FwData->PciWindow32.End = Mmio32MaxExclTop - 1; - FwData->PciWindow32.Length = Mmio32MaxExclTop - Mmio32MinBase; - - FwData->PciWindow64.Base = 0; - FwData->PciWindow64.End = 0; - FwData->PciWindow64.Length = 0; - - Status = EFI_SUCCESS; - } - - FreePool (AllDesc); - } - - DEBUG (( - DEBUG_INFO, - "ACPI PciWindow32: Base=0x%08lx End=0x%08lx Length=0x%08lx\n", - FwData->PciWindow32.Base, - FwData->PciWindow32.End, - FwData->PciWindow32.Length - )); - DEBUG (( - DEBUG_INFO, - "ACPI PciWindow64: Base=0x%08lx End=0x%08lx Length=0x%08lx\n", - FwData->PciWindow64.Base, - FwData->PciWindow64.End, - FwData->PciWindow64.Length - )); - - return Status; -} - - -STATIC -VOID -EFIAPI -GetSuspendStates ( - UINTN *SuspendToRamSize, - SYSTEM_STATE_PACKAGE *SuspendToRam, - UINTN *SuspendToDiskSize, - SYSTEM_STATE_PACKAGE *SuspendToDisk - ) -{ - STATIC CONST SYSTEM_STATE_PACKAGE Template = { - 0x08, // NameOp - '\\', // RootChar - { '_', 'S', 'x', '_' }, // NameChar[4] - 0x12, // PackageOp - 0x0A, // PkgLength - 0x04, // NumElements - { 0x0A, 0x00 }, // Pm1aCntSlpTyp - { 0x0A, 0x00 }, // Pm1bCntSlpTyp -- we don't support it - { // Reserved[2] - { 0x0A, 0x00 }, - { 0x0A, 0x00 } - } - }; - RETURN_STATUS Status; - FIRMWARE_CONFIG_ITEM FwCfgItem; - UINTN FwCfgSize; - UINT8 SystemStates[6]; - - // - // configure defaults - // - *SuspendToRamSize = sizeof Template; - CopyMem (SuspendToRam, &Template, sizeof Template); - SuspendToRam->NameChar[2] = '3'; // S3 - SuspendToRam->Pm1aCntSlpTyp.ByteValue = 1; // PIIX4: STR - - *SuspendToDiskSize = sizeof Template; - CopyMem (SuspendToDisk, &Template, sizeof Template); - SuspendToDisk->NameChar[2] = '4'; // S4 - SuspendToDisk->Pm1aCntSlpTyp.ByteValue = 2; // PIIX4: POSCL - - // - // check for overrides - // - Status = QemuFwCfgFindFile ("etc/system-states", &FwCfgItem, &FwCfgSize); - if (Status != RETURN_SUCCESS || FwCfgSize != sizeof SystemStates) { - DEBUG ((DEBUG_INFO, "ACPI using S3/S4 defaults\n")); - return; - } - QemuFwCfgSelectItem (FwCfgItem); - QemuFwCfgReadBytes (sizeof SystemStates, SystemStates); - - // - // Each byte corresponds to a system state. In each byte, the MSB tells us - // whether the given state is enabled. If so, the three LSBs specify the - // value to be written to the PM control register's SUS_TYP bits. - // - if (SystemStates[3] & BIT7) { - SuspendToRam->Pm1aCntSlpTyp.ByteValue = - SystemStates[3] & (BIT2 | BIT1 | BIT0); - DEBUG ((DEBUG_INFO, "ACPI S3 value: %d\n", - SuspendToRam->Pm1aCntSlpTyp.ByteValue)); - } else { - *SuspendToRamSize = 0; - DEBUG ((DEBUG_INFO, "ACPI S3 disabled\n")); - } - - if (SystemStates[4] & BIT7) { - SuspendToDisk->Pm1aCntSlpTyp.ByteValue = - SystemStates[4] & (BIT2 | BIT1 | BIT0); - DEBUG ((DEBUG_INFO, "ACPI S4 value: %d\n", - SuspendToDisk->Pm1aCntSlpTyp.ByteValue)); - } else { - *SuspendToDiskSize = 0; - DEBUG ((DEBUG_INFO, "ACPI S4 disabled\n")); - } -} - - -STATIC -EFI_STATUS -EFIAPI -QemuInstallAcpiSsdtTable ( - IN EFI_ACPI_TABLE_PROTOCOL *AcpiProtocol, - IN VOID *AcpiTableBuffer, - IN UINTN AcpiTableBufferSize, - OUT UINTN *TableKey - ) -{ - EFI_STATUS Status; - FIRMWARE_DATA *FwData; - - Status = EFI_OUT_OF_RESOURCES; - - FwData = AllocateReservedPool (sizeof (*FwData)); - if (FwData != NULL) { - UINTN SuspendToRamSize; - SYSTEM_STATE_PACKAGE SuspendToRam; - UINTN SuspendToDiskSize; - SYSTEM_STATE_PACKAGE SuspendToDisk; - UINTN SsdtSize; - UINT8 *Ssdt; - - GetSuspendStates (&SuspendToRamSize, &SuspendToRam, - &SuspendToDiskSize, &SuspendToDisk); - SsdtSize = AcpiTableBufferSize + 17 + SuspendToRamSize + SuspendToDiskSize; - Ssdt = AllocatePool (SsdtSize); - - if (Ssdt != NULL) { - Status = PopulateFwData (FwData); - - if (Status == EFI_SUCCESS) { - UINT8 *SsdtPtr; - - SsdtPtr = Ssdt; - - CopyMem (SsdtPtr, AcpiTableBuffer, AcpiTableBufferSize); - SsdtPtr += AcpiTableBufferSize; - - // - // build "OperationRegion(FWDT, SystemMemory, 0x12345678, 0x87654321)" - // - *(SsdtPtr++) = 0x5B; // ExtOpPrefix - *(SsdtPtr++) = 0x80; // OpRegionOp - *(SsdtPtr++) = 'F'; - *(SsdtPtr++) = 'W'; - *(SsdtPtr++) = 'D'; - *(SsdtPtr++) = 'T'; - *(SsdtPtr++) = 0x00; // SystemMemory - *(SsdtPtr++) = 0x0C; // DWordPrefix - - // - // no virtual addressing yet, take the four least significant bytes - // - CopyMem(SsdtPtr, &FwData, 4); - SsdtPtr += 4; - - *(SsdtPtr++) = 0x0C; // DWordPrefix - - *(UINT32*) SsdtPtr = sizeof (*FwData); - SsdtPtr += 4; - - // - // add suspend system states - // - CopyMem (SsdtPtr, &SuspendToRam, SuspendToRamSize); - SsdtPtr += SuspendToRamSize; - CopyMem (SsdtPtr, &SuspendToDisk, SuspendToDiskSize); - SsdtPtr += SuspendToDiskSize; - - ASSERT((UINTN) (SsdtPtr - Ssdt) == SsdtSize); - ((EFI_ACPI_DESCRIPTION_HEADER *) Ssdt)->Length = (UINT32) SsdtSize; - Status = InstallAcpiTable (AcpiProtocol, Ssdt, SsdtSize, TableKey); - } - - FreePool(Ssdt); - } - - if (Status != EFI_SUCCESS) { - FreePool(FwData); - } - } - - return Status; -} - - -EFI_STATUS -EFIAPI -QemuInstallAcpiTable ( - IN EFI_ACPI_TABLE_PROTOCOL *AcpiProtocol, - IN VOID *AcpiTableBuffer, - IN UINTN AcpiTableBufferSize, - OUT UINTN *TableKey - ) -{ - EFI_ACPI_DESCRIPTION_HEADER *Hdr; - EFI_ACPI_TABLE_INSTALL_ACPI_TABLE TableInstallFunction; - - Hdr = (EFI_ACPI_DESCRIPTION_HEADER*) AcpiTableBuffer; - switch (Hdr->Signature) { - case EFI_ACPI_1_0_APIC_SIGNATURE: - TableInstallFunction = QemuInstallAcpiMadtTable; - break; - case EFI_ACPI_1_0_SECONDARY_SYSTEM_DESCRIPTION_TABLE_SIGNATURE: - TableInstallFunction = QemuInstallAcpiSsdtTable; - break; - default: - TableInstallFunction = InstallAcpiTable; - } - - return TableInstallFunction ( - AcpiProtocol, - AcpiTableBuffer, - AcpiTableBufferSize, - TableKey - ); -} diff --git a/OvmfPkg/AcpiPlatformDxe/QemuFwCfgAcpi.c b/OvmfPkg/AcpiPlatformDxe/QemuFwCfgAcpi.c deleted file mode 100644 index 1bc5fe297a..0000000000 --- a/OvmfPkg/AcpiPlatformDxe/QemuFwCfgAcpi.c +++ /dev/null @@ -1,1017 +0,0 @@ -/** @file - OVMF ACPI support using QEMU's fw-cfg interface - - Copyright (c) 2008 - 2014, Intel Corporation. All rights reserved.
- Copyright (C) 2012-2014, 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 "AcpiPlatform.h" -#include "QemuLoader.h" -#include -#include -#include -#include -#include -#include -#include -#include - - -// -// The user structure for the ordered collection that will track the fw_cfg -// blobs under processing. -// -typedef struct { - UINT8 File[QEMU_LOADER_FNAME_SIZE]; // NUL-terminated name of the fw_cfg - // blob. This is the ordering / search - // key. - UINTN Size; // The number of bytes in this blob. - UINT8 *Base; // Pointer to the blob data. - BOOLEAN HostsOnlyTableData; // TRUE iff the blob has been found to - // only contain data that is directly - // part of ACPI tables. -} BLOB; - - -/** - Compare a standalone key against a user structure containing an embedded key. - - @param[in] StandaloneKey Pointer to the bare key. - - @param[in] UserStruct Pointer to the user structure with the embedded - key. - - @retval <0 If StandaloneKey compares less than UserStruct's key. - - @retval 0 If StandaloneKey compares equal to UserStruct's key. - - @retval >0 If StandaloneKey compares greater than UserStruct's key. -**/ -STATIC -INTN -EFIAPI -BlobKeyCompare ( - IN CONST VOID *StandaloneKey, - IN CONST VOID *UserStruct - ) -{ - CONST BLOB *Blob; - - Blob = UserStruct; - return AsciiStrCmp (StandaloneKey, (CONST CHAR8 *)Blob->File); -} - - -/** - Comparator function for two user structures. - - @param[in] UserStruct1 Pointer to the first user structure. - - @param[in] UserStruct2 Pointer to the second user structure. - - @retval <0 If UserStruct1 compares less than UserStruct2. - - @retval 0 If UserStruct1 compares equal to UserStruct2. - - @retval >0 If UserStruct1 compares greater than UserStruct2. -**/ -STATIC -INTN -EFIAPI -BlobCompare ( - IN CONST VOID *UserStruct1, - IN CONST VOID *UserStruct2 - ) -{ - CONST BLOB *Blob1; - - Blob1 = UserStruct1; - return BlobKeyCompare (Blob1->File, UserStruct2); -} - - -/** - Comparator function for two opaque pointers, ordering on (unsigned) pointer - value itself. - Can be used as both Key and UserStruct comparator. - - @param[in] Pointer1 First pointer. - - @param[in] Pointer2 Second pointer. - - @retval <0 If Pointer1 compares less than Pointer2. - - @retval 0 If Pointer1 compares equal to Pointer2. - - @retval >0 If Pointer1 compares greater than Pointer2. -**/ -STATIC -INTN -EFIAPI -PointerCompare ( - IN CONST VOID *Pointer1, - IN CONST VOID *Pointer2 - ) -{ - if (Pointer1 == Pointer2) { - return 0; - } - if ((UINTN)Pointer1 < (UINTN)Pointer2) { - return -1; - } - return 1; -} - - -/** - Process a QEMU_LOADER_ALLOCATE command. - - @param[in] Allocate The QEMU_LOADER_ALLOCATE command to process. - - @param[in,out] Tracker The ORDERED_COLLECTION tracking the BLOB user - structures created thus far. - - @retval EFI_SUCCESS An area of whole AcpiNVS pages has been - allocated for the blob contents, and the - contents have been saved. A BLOB object (user - structure) has been allocated from pool memory, - referencing the blob contents. The BLOB user - structure has been linked into Tracker. - - @retval EFI_PROTOCOL_ERROR Malformed fw_cfg file name has been found in - Allocate, or the Allocate command references a - file that is already known by Tracker. - - @retval EFI_UNSUPPORTED Unsupported alignment request has been found in - Allocate. - - @retval EFI_OUT_OF_RESOURCES Pool allocation failed. - - @return Error codes from QemuFwCfgFindFile() and - gBS->AllocatePages(). -**/ -STATIC -EFI_STATUS -EFIAPI -ProcessCmdAllocate ( - IN CONST QEMU_LOADER_ALLOCATE *Allocate, - IN OUT ORDERED_COLLECTION *Tracker - ) -{ - FIRMWARE_CONFIG_ITEM FwCfgItem; - UINTN FwCfgSize; - EFI_STATUS Status; - UINTN NumPages; - EFI_PHYSICAL_ADDRESS Address; - BLOB *Blob; - - if (Allocate->File[QEMU_LOADER_FNAME_SIZE - 1] != '\0') { - DEBUG ((EFI_D_ERROR, "%a: malformed file name\n", __FUNCTION__)); - return EFI_PROTOCOL_ERROR; - } - - if (Allocate->Alignment > EFI_PAGE_SIZE) { - DEBUG ((EFI_D_ERROR, "%a: unsupported alignment 0x%x\n", __FUNCTION__, - Allocate->Alignment)); - return EFI_UNSUPPORTED; - } - - Status = QemuFwCfgFindFile ((CHAR8 *)Allocate->File, &FwCfgItem, &FwCfgSize); - if (EFI_ERROR (Status)) { - DEBUG ((EFI_D_ERROR, "%a: QemuFwCfgFindFile(\"%a\"): %r\n", __FUNCTION__, - Allocate->File, Status)); - return Status; - } - - NumPages = EFI_SIZE_TO_PAGES (FwCfgSize); - Address = 0xFFFFFFFF; - Status = gBS->AllocatePages (AllocateMaxAddress, EfiACPIMemoryNVS, NumPages, - &Address); - if (EFI_ERROR (Status)) { - return Status; - } - - Blob = AllocatePool (sizeof *Blob); - if (Blob == NULL) { - Status = EFI_OUT_OF_RESOURCES; - goto FreePages; - } - CopyMem (Blob->File, Allocate->File, QEMU_LOADER_FNAME_SIZE); - Blob->Size = FwCfgSize; - Blob->Base = (VOID *)(UINTN)Address; - Blob->HostsOnlyTableData = TRUE; - - Status = OrderedCollectionInsert (Tracker, NULL, Blob); - if (Status == RETURN_ALREADY_STARTED) { - DEBUG ((EFI_D_ERROR, "%a: duplicated file \"%a\"\n", __FUNCTION__, - Allocate->File)); - Status = EFI_PROTOCOL_ERROR; - } - if (EFI_ERROR (Status)) { - goto FreeBlob; - } - - QemuFwCfgSelectItem (FwCfgItem); - QemuFwCfgReadBytes (FwCfgSize, Blob->Base); - ZeroMem (Blob->Base + Blob->Size, EFI_PAGES_TO_SIZE (NumPages) - Blob->Size); - - DEBUG ((EFI_D_VERBOSE, "%a: File=\"%a\" Alignment=0x%x Zone=%d Size=0x%Lx " - "Address=0x%Lx\n", __FUNCTION__, Allocate->File, Allocate->Alignment, - Allocate->Zone, (UINT64)Blob->Size, (UINT64)(UINTN)Blob->Base)); - return EFI_SUCCESS; - -FreeBlob: - FreePool (Blob); - -FreePages: - gBS->FreePages (Address, NumPages); - - return Status; -} - - -/** - Process a QEMU_LOADER_ADD_POINTER command. - - @param[in] AddPointer The QEMU_LOADER_ADD_POINTER command to process. - - @param[in] Tracker The ORDERED_COLLECTION tracking the BLOB user - structures created thus far. - - @retval EFI_PROTOCOL_ERROR Malformed fw_cfg file name(s) have been found in - AddPointer, or the AddPointer command references - a file unknown to Tracker, or the pointer to - relocate has invalid location, size, or value, or - the relocated pointer value is not representable - in the given pointer size. - - @retval EFI_SUCCESS The pointer field inside the pointer blob has - been relocated. -**/ -STATIC -EFI_STATUS -EFIAPI -ProcessCmdAddPointer ( - IN CONST QEMU_LOADER_ADD_POINTER *AddPointer, - IN CONST ORDERED_COLLECTION *Tracker - ) -{ - ORDERED_COLLECTION_ENTRY *TrackerEntry, *TrackerEntry2; - BLOB *Blob, *Blob2; - UINT8 *PointerField; - UINT64 PointerValue; - - if (AddPointer->PointerFile[QEMU_LOADER_FNAME_SIZE - 1] != '\0' || - AddPointer->PointeeFile[QEMU_LOADER_FNAME_SIZE - 1] != '\0') { - DEBUG ((EFI_D_ERROR, "%a: malformed file name\n", __FUNCTION__)); - return EFI_PROTOCOL_ERROR; - } - - TrackerEntry = OrderedCollectionFind (Tracker, AddPointer->PointerFile); - TrackerEntry2 = OrderedCollectionFind (Tracker, AddPointer->PointeeFile); - if (TrackerEntry == NULL || TrackerEntry2 == NULL) { - DEBUG ((EFI_D_ERROR, "%a: invalid blob reference(s) \"%a\" / \"%a\"\n", - __FUNCTION__, AddPointer->PointerFile, AddPointer->PointeeFile)); - return EFI_PROTOCOL_ERROR; - } - - Blob = OrderedCollectionUserStruct (TrackerEntry); - Blob2 = OrderedCollectionUserStruct (TrackerEntry2); - if ((AddPointer->PointerSize != 1 && AddPointer->PointerSize != 2 && - AddPointer->PointerSize != 4 && AddPointer->PointerSize != 8) || - Blob->Size < AddPointer->PointerSize || - Blob->Size - AddPointer->PointerSize < AddPointer->PointerOffset) { - DEBUG ((EFI_D_ERROR, "%a: invalid pointer location or size in \"%a\"\n", - __FUNCTION__, AddPointer->PointerFile)); - return EFI_PROTOCOL_ERROR; - } - - PointerField = Blob->Base + AddPointer->PointerOffset; - PointerValue = 0; - CopyMem (&PointerValue, PointerField, AddPointer->PointerSize); - if (PointerValue >= Blob2->Size) { - DEBUG ((EFI_D_ERROR, "%a: invalid pointer value in \"%a\"\n", __FUNCTION__, - AddPointer->PointerFile)); - return EFI_PROTOCOL_ERROR; - } - - // - // The memory allocation system ensures that the address of the byte past the - // last byte of any allocated object is expressible (no wraparound). - // - ASSERT ((UINTN)Blob2->Base <= MAX_ADDRESS - Blob2->Size); - - PointerValue += (UINT64)(UINTN)Blob2->Base; - if (AddPointer->PointerSize < 8 && - RShiftU64 (PointerValue, AddPointer->PointerSize * 8) != 0) { - DEBUG ((EFI_D_ERROR, "%a: relocated pointer value unrepresentable in " - "\"%a\"\n", __FUNCTION__, AddPointer->PointerFile)); - return EFI_PROTOCOL_ERROR; - } - - CopyMem (PointerField, &PointerValue, AddPointer->PointerSize); - - DEBUG ((EFI_D_VERBOSE, "%a: PointerFile=\"%a\" PointeeFile=\"%a\" " - "PointerOffset=0x%x PointerSize=%d\n", __FUNCTION__, - AddPointer->PointerFile, AddPointer->PointeeFile, - AddPointer->PointerOffset, AddPointer->PointerSize)); - return EFI_SUCCESS; -} - - -/** - Process a QEMU_LOADER_ADD_CHECKSUM command. - - @param[in] AddChecksum The QEMU_LOADER_ADD_CHECKSUM command to process. - - @param[in] Tracker The ORDERED_COLLECTION tracking the BLOB user - structures created thus far. - - @retval EFI_PROTOCOL_ERROR Malformed fw_cfg file name has been found in - AddChecksum, or the AddChecksum command - references a file unknown to Tracker, or the - range to checksum is invalid. - - @retval EFI_SUCCESS The requested range has been checksummed. -**/ -STATIC -EFI_STATUS -EFIAPI -ProcessCmdAddChecksum ( - IN CONST QEMU_LOADER_ADD_CHECKSUM *AddChecksum, - IN CONST ORDERED_COLLECTION *Tracker - ) -{ - ORDERED_COLLECTION_ENTRY *TrackerEntry; - BLOB *Blob; - - if (AddChecksum->File[QEMU_LOADER_FNAME_SIZE - 1] != '\0') { - DEBUG ((EFI_D_ERROR, "%a: malformed file name\n", __FUNCTION__)); - return EFI_PROTOCOL_ERROR; - } - - TrackerEntry = OrderedCollectionFind (Tracker, AddChecksum->File); - if (TrackerEntry == NULL) { - DEBUG ((EFI_D_ERROR, "%a: invalid blob reference \"%a\"\n", __FUNCTION__, - AddChecksum->File)); - return EFI_PROTOCOL_ERROR; - } - - Blob = OrderedCollectionUserStruct (TrackerEntry); - if (Blob->Size <= AddChecksum->ResultOffset || - Blob->Size < AddChecksum->Length || - Blob->Size - AddChecksum->Length < AddChecksum->Start) { - DEBUG ((EFI_D_ERROR, "%a: invalid checksum range in \"%a\"\n", - __FUNCTION__, AddChecksum->File)); - return EFI_PROTOCOL_ERROR; - } - - Blob->Base[AddChecksum->ResultOffset] = CalculateCheckSum8 ( - Blob->Base + AddChecksum->Start, - AddChecksum->Length - ); - DEBUG ((EFI_D_VERBOSE, "%a: File=\"%a\" ResultOffset=0x%x Start=0x%x " - "Length=0x%x\n", __FUNCTION__, AddChecksum->File, - AddChecksum->ResultOffset, AddChecksum->Start, AddChecksum->Length)); - return EFI_SUCCESS; -} - - -/** - Process a QEMU_LOADER_WRITE_POINTER command. - - @param[in] WritePointer The QEMU_LOADER_WRITE_POINTER command to process. - - @param[in] Tracker The ORDERED_COLLECTION tracking the BLOB user - structures created thus far. - - @param[in,out] S3Context The S3_CONTEXT object capturing the fw_cfg actions - of successfully processed QEMU_LOADER_WRITE_POINTER - commands, to be replayed at S3 resume. S3Context - may be NULL if S3 is disabled. - - @retval EFI_PROTOCOL_ERROR Malformed fw_cfg file name(s) have been found in - WritePointer. Or, the WritePointer command - references a file unknown to Tracker or the - fw_cfg directory. Or, the pointer object to - rewrite has invalid location, size, or initial - relative value. Or, the pointer value to store - does not fit in the given pointer size. - - @retval EFI_SUCCESS The pointer object inside the writeable fw_cfg - file has been written. If S3Context is not NULL, - then WritePointer has been condensed into - S3Context. - - @return Error codes propagated from - SaveCondensedWritePointerToS3Context(). The - pointer object inside the writeable fw_cfg file - has not been written. -**/ -STATIC -EFI_STATUS -ProcessCmdWritePointer ( - IN CONST QEMU_LOADER_WRITE_POINTER *WritePointer, - IN CONST ORDERED_COLLECTION *Tracker, - IN OUT S3_CONTEXT *S3Context OPTIONAL - ) -{ - RETURN_STATUS Status; - FIRMWARE_CONFIG_ITEM PointerItem; - UINTN PointerItemSize; - ORDERED_COLLECTION_ENTRY *PointeeEntry; - BLOB *PointeeBlob; - UINT64 PointerValue; - - if (WritePointer->PointerFile[QEMU_LOADER_FNAME_SIZE - 1] != '\0' || - WritePointer->PointeeFile[QEMU_LOADER_FNAME_SIZE - 1] != '\0') { - DEBUG ((DEBUG_ERROR, "%a: malformed file name\n", __FUNCTION__)); - return EFI_PROTOCOL_ERROR; - } - - Status = QemuFwCfgFindFile ((CONST CHAR8 *)WritePointer->PointerFile, - &PointerItem, &PointerItemSize); - PointeeEntry = OrderedCollectionFind (Tracker, WritePointer->PointeeFile); - if (RETURN_ERROR (Status) || PointeeEntry == NULL) { - DEBUG ((DEBUG_ERROR, - "%a: invalid fw_cfg file or blob reference \"%a\" / \"%a\"\n", - __FUNCTION__, WritePointer->PointerFile, WritePointer->PointeeFile)); - return EFI_PROTOCOL_ERROR; - } - - if ((WritePointer->PointerSize != 1 && WritePointer->PointerSize != 2 && - WritePointer->PointerSize != 4 && WritePointer->PointerSize != 8) || - (PointerItemSize < WritePointer->PointerSize) || - (PointerItemSize - WritePointer->PointerSize < - WritePointer->PointerOffset)) { - DEBUG ((DEBUG_ERROR, "%a: invalid pointer location or size in \"%a\"\n", - __FUNCTION__, WritePointer->PointerFile)); - return EFI_PROTOCOL_ERROR; - } - - PointeeBlob = OrderedCollectionUserStruct (PointeeEntry); - PointerValue = WritePointer->PointeeOffset; - if (PointerValue >= PointeeBlob->Size) { - DEBUG ((DEBUG_ERROR, "%a: invalid PointeeOffset\n", __FUNCTION__)); - return EFI_PROTOCOL_ERROR; - } - - // - // The memory allocation system ensures that the address of the byte past the - // last byte of any allocated object is expressible (no wraparound). - // - ASSERT ((UINTN)PointeeBlob->Base <= MAX_ADDRESS - PointeeBlob->Size); - - PointerValue += (UINT64)(UINTN)PointeeBlob->Base; - if (WritePointer->PointerSize < 8 && - RShiftU64 (PointerValue, WritePointer->PointerSize * 8) != 0) { - DEBUG ((DEBUG_ERROR, "%a: pointer value unrepresentable in \"%a\"\n", - __FUNCTION__, WritePointer->PointerFile)); - return EFI_PROTOCOL_ERROR; - } - - // - // If S3 is enabled, we have to capture the below fw_cfg actions in condensed - // form, to be replayed during S3 resume. - // - if (S3Context != NULL) { - EFI_STATUS SaveStatus; - - SaveStatus = SaveCondensedWritePointerToS3Context ( - S3Context, - (UINT16)PointerItem, - WritePointer->PointerSize, - WritePointer->PointerOffset, - PointerValue - ); - if (EFI_ERROR (SaveStatus)) { - return SaveStatus; - } - } - - QemuFwCfgSelectItem (PointerItem); - QemuFwCfgSkipBytes (WritePointer->PointerOffset); - QemuFwCfgWriteBytes (WritePointer->PointerSize, &PointerValue); - - // - // Because QEMU has now learned PointeeBlob->Base, we must mark PointeeBlob - // as unreleasable, for the case when the whole linker/loader script is - // handled successfully. - // - PointeeBlob->HostsOnlyTableData = FALSE; - - DEBUG ((DEBUG_VERBOSE, "%a: PointerFile=\"%a\" PointeeFile=\"%a\" " - "PointerOffset=0x%x PointeeOffset=0x%x PointerSize=%d\n", __FUNCTION__, - WritePointer->PointerFile, WritePointer->PointeeFile, - WritePointer->PointerOffset, WritePointer->PointeeOffset, - WritePointer->PointerSize)); - return EFI_SUCCESS; -} - - -/** - Undo a QEMU_LOADER_WRITE_POINTER command. - - This function revokes (zeroes out) a guest memory reference communicated to - QEMU earlier. The caller is responsible for invoking this function only on - such QEMU_LOADER_WRITE_POINTER commands that have been successfully processed - by ProcessCmdWritePointer(). - - @param[in] WritePointer The QEMU_LOADER_WRITE_POINTER command to undo. -**/ -STATIC -VOID -UndoCmdWritePointer ( - IN CONST QEMU_LOADER_WRITE_POINTER *WritePointer - ) -{ - RETURN_STATUS Status; - FIRMWARE_CONFIG_ITEM PointerItem; - UINTN PointerItemSize; - UINT64 PointerValue; - - Status = QemuFwCfgFindFile ((CONST CHAR8 *)WritePointer->PointerFile, - &PointerItem, &PointerItemSize); - ASSERT_RETURN_ERROR (Status); - - PointerValue = 0; - QemuFwCfgSelectItem (PointerItem); - QemuFwCfgSkipBytes (WritePointer->PointerOffset); - QemuFwCfgWriteBytes (WritePointer->PointerSize, &PointerValue); - - DEBUG ((DEBUG_VERBOSE, - "%a: PointerFile=\"%a\" PointerOffset=0x%x PointerSize=%d\n", __FUNCTION__, - WritePointer->PointerFile, WritePointer->PointerOffset, - WritePointer->PointerSize)); -} - - -// -// We'll be saving the keys of installed tables so that we can roll them back -// in case of failure. 128 tables should be enough for anyone (TM). -// -#define INSTALLED_TABLES_MAX 128 - -/** - Process a QEMU_LOADER_ADD_POINTER command in order to see if its target byte - array is an ACPI table, and if so, install it. - - This function assumes that the entire QEMU linker/loader command file has - been processed successfully in a prior first pass. - - @param[in] AddPointer The QEMU_LOADER_ADD_POINTER command to process. - - @param[in] Tracker The ORDERED_COLLECTION tracking the BLOB user - structures. - - @param[in] AcpiProtocol The ACPI table protocol used to install tables. - - @param[in,out] InstalledKey On input, an array of INSTALLED_TABLES_MAX UINTN - elements, allocated by the caller. On output, - the function will have stored (appended) the - AcpiProtocol-internal key of the ACPI table that - the function has installed, if the AddPointer - command identified an ACPI table that is - different from RSDT and XSDT. - - @param[in,out] NumInstalled On input, the number of entries already used in - InstalledKey; it must be in [0, - INSTALLED_TABLES_MAX] inclusive. On output, the - parameter is incremented if the AddPointer - command identified an ACPI table that is - different from RSDT and XSDT. - - @param[in,out] SeenPointers The ORDERED_COLLECTION tracking the absolute - target addresses that have been pointed-to by - QEMU_LOADER_ADD_POINTER commands thus far. If a - target address is encountered for the first - time, and it identifies an ACPI table that is - different from RDST and XSDT, the table is - installed. If a target address is seen for the - second or later times, it is skipped without - taking any action. - - @retval EFI_INVALID_PARAMETER NumInstalled was outside the allowed range on - input. - - @retval EFI_OUT_OF_RESOURCES The AddPointer command identified an ACPI - table different from RSDT and XSDT, but there - was no more room in InstalledKey. - - @retval EFI_SUCCESS AddPointer has been processed. Either its - absolute target address has been encountered - before, or an ACPI table different from RSDT - and XSDT has been installed (reflected by - InstalledKey and NumInstalled), or RSDT or - XSDT has been identified but not installed, or - the fw_cfg blob pointed-into by AddPointer has - been marked as hosting something else than - just direct ACPI table contents. - - @return Error codes returned by - AcpiProtocol->InstallAcpiTable(). -**/ -STATIC -EFI_STATUS -EFIAPI -Process2ndPassCmdAddPointer ( - IN CONST QEMU_LOADER_ADD_POINTER *AddPointer, - IN CONST ORDERED_COLLECTION *Tracker, - IN EFI_ACPI_TABLE_PROTOCOL *AcpiProtocol, - IN OUT UINTN InstalledKey[INSTALLED_TABLES_MAX], - IN OUT INT32 *NumInstalled, - IN OUT ORDERED_COLLECTION *SeenPointers - ) -{ - CONST ORDERED_COLLECTION_ENTRY *TrackerEntry; - CONST ORDERED_COLLECTION_ENTRY *TrackerEntry2; - ORDERED_COLLECTION_ENTRY *SeenPointerEntry; - CONST BLOB *Blob; - BLOB *Blob2; - CONST UINT8 *PointerField; - UINT64 PointerValue; - UINTN Blob2Remaining; - UINTN TableSize; - CONST EFI_ACPI_1_0_FIRMWARE_ACPI_CONTROL_STRUCTURE *Facs; - CONST EFI_ACPI_DESCRIPTION_HEADER *Header; - EFI_STATUS Status; - - if (*NumInstalled < 0 || *NumInstalled > INSTALLED_TABLES_MAX) { - return EFI_INVALID_PARAMETER; - } - - TrackerEntry = OrderedCollectionFind (Tracker, AddPointer->PointerFile); - TrackerEntry2 = OrderedCollectionFind (Tracker, AddPointer->PointeeFile); - Blob = OrderedCollectionUserStruct (TrackerEntry); - Blob2 = OrderedCollectionUserStruct (TrackerEntry2); - PointerField = Blob->Base + AddPointer->PointerOffset; - PointerValue = 0; - CopyMem (&PointerValue, PointerField, AddPointer->PointerSize); - - // - // We assert that PointerValue falls inside Blob2's contents. This is ensured - // by the Blob2->Size check and later checks in ProcessCmdAddPointer(). - // - Blob2Remaining = (UINTN)Blob2->Base; - ASSERT(PointerValue >= Blob2Remaining); - Blob2Remaining += Blob2->Size; - ASSERT (PointerValue < Blob2Remaining); - - Status = OrderedCollectionInsert ( - SeenPointers, - &SeenPointerEntry, // for reverting insertion in error case - (VOID *)(UINTN)PointerValue - ); - if (EFI_ERROR (Status)) { - if (Status == RETURN_ALREADY_STARTED) { - // - // Already seen this pointer, don't try to process it again. - // - DEBUG (( - DEBUG_VERBOSE, - "%a: PointerValue=0x%Lx already processed, skipping.\n", - __FUNCTION__, - PointerValue - )); - Status = EFI_SUCCESS; - } - return Status; - } - - Blob2Remaining -= (UINTN) PointerValue; - DEBUG ((EFI_D_VERBOSE, "%a: checking for ACPI header in \"%a\" at 0x%Lx " - "(remaining: 0x%Lx): ", __FUNCTION__, AddPointer->PointeeFile, - PointerValue, (UINT64)Blob2Remaining)); - - TableSize = 0; - - // - // To make our job simple, the FACS has a custom header. Sigh. - // - if (sizeof *Facs <= Blob2Remaining) { - Facs = (EFI_ACPI_1_0_FIRMWARE_ACPI_CONTROL_STRUCTURE *)(UINTN)PointerValue; - - if (Facs->Length >= sizeof *Facs && - Facs->Length <= Blob2Remaining && - Facs->Signature == - EFI_ACPI_1_0_FIRMWARE_ACPI_CONTROL_STRUCTURE_SIGNATURE) { - DEBUG ((EFI_D_VERBOSE, "found \"%-4.4a\" size 0x%x\n", - (CONST CHAR8 *)&Facs->Signature, Facs->Length)); - TableSize = Facs->Length; - } - } - - // - // check for the uniform tables - // - if (TableSize == 0 && sizeof *Header <= Blob2Remaining) { - Header = (EFI_ACPI_DESCRIPTION_HEADER *)(UINTN)PointerValue; - - if (Header->Length >= sizeof *Header && - Header->Length <= Blob2Remaining && - CalculateSum8 ((CONST UINT8 *)Header, Header->Length) == 0) { - // - // This looks very much like an ACPI table from QEMU: - // - Length field consistent with both ACPI and containing blob size - // - checksum is correct - // - DEBUG ((EFI_D_VERBOSE, "found \"%-4.4a\" size 0x%x\n", - (CONST CHAR8 *)&Header->Signature, Header->Length)); - TableSize = Header->Length; - - // - // Skip RSDT and XSDT because those are handled by - // EFI_ACPI_TABLE_PROTOCOL automatically. - if (Header->Signature == - EFI_ACPI_1_0_ROOT_SYSTEM_DESCRIPTION_TABLE_SIGNATURE || - Header->Signature == - EFI_ACPI_2_0_EXTENDED_SYSTEM_DESCRIPTION_TABLE_SIGNATURE) { - return EFI_SUCCESS; - } - } - } - - if (TableSize == 0) { - DEBUG ((EFI_D_VERBOSE, "not found; marking fw_cfg blob as opaque\n")); - Blob2->HostsOnlyTableData = FALSE; - return EFI_SUCCESS; - } - - if (*NumInstalled == INSTALLED_TABLES_MAX) { - DEBUG ((EFI_D_ERROR, "%a: can't install more than %d tables\n", - __FUNCTION__, INSTALLED_TABLES_MAX)); - Status = EFI_OUT_OF_RESOURCES; - goto RollbackSeenPointer; - } - - Status = AcpiProtocol->InstallAcpiTable (AcpiProtocol, - (VOID *)(UINTN)PointerValue, TableSize, - &InstalledKey[*NumInstalled]); - if (EFI_ERROR (Status)) { - DEBUG ((EFI_D_ERROR, "%a: InstallAcpiTable(): %r\n", __FUNCTION__, - Status)); - goto RollbackSeenPointer; - } - ++*NumInstalled; - return EFI_SUCCESS; - -RollbackSeenPointer: - OrderedCollectionDelete (SeenPointers, SeenPointerEntry, NULL); - return Status; -} - - -/** - Download, process, and install ACPI table data from the QEMU loader - interface. - - @param[in] AcpiProtocol The ACPI table protocol used to install tables. - - @retval EFI_UNSUPPORTED Firmware configuration is unavailable, or QEMU - loader command with unsupported parameters - has been found. - - @retval EFI_NOT_FOUND The host doesn't export the required fw_cfg - files. - - @retval EFI_OUT_OF_RESOURCES Memory allocation failed, or more than - INSTALLED_TABLES_MAX tables found. - - @retval EFI_PROTOCOL_ERROR Found invalid fw_cfg contents. - - @return Status codes returned by - AcpiProtocol->InstallAcpiTable(). - -**/ -EFI_STATUS -EFIAPI -InstallQemuFwCfgTables ( - IN EFI_ACPI_TABLE_PROTOCOL *AcpiProtocol - ) -{ - EFI_STATUS Status; - FIRMWARE_CONFIG_ITEM FwCfgItem; - UINTN FwCfgSize; - QEMU_LOADER_ENTRY *LoaderStart; - CONST QEMU_LOADER_ENTRY *LoaderEntry, *LoaderEnd; - CONST QEMU_LOADER_ENTRY *WritePointerSubsetEnd; - ORIGINAL_ATTRIBUTES *OriginalPciAttributes; - UINTN OriginalPciAttributesCount; - S3_CONTEXT *S3Context; - ORDERED_COLLECTION *Tracker; - UINTN *InstalledKey; - INT32 Installed; - ORDERED_COLLECTION_ENTRY *TrackerEntry, *TrackerEntry2; - ORDERED_COLLECTION *SeenPointers; - ORDERED_COLLECTION_ENTRY *SeenPointerEntry, *SeenPointerEntry2; - - Status = QemuFwCfgFindFile ("etc/table-loader", &FwCfgItem, &FwCfgSize); - if (EFI_ERROR (Status)) { - return Status; - } - if (FwCfgSize % sizeof *LoaderEntry != 0) { - DEBUG ((EFI_D_ERROR, "%a: \"etc/table-loader\" has invalid size 0x%Lx\n", - __FUNCTION__, (UINT64)FwCfgSize)); - return EFI_PROTOCOL_ERROR; - } - - LoaderStart = AllocatePool (FwCfgSize); - if (LoaderStart == NULL) { - return EFI_OUT_OF_RESOURCES; - } - EnablePciDecoding (&OriginalPciAttributes, &OriginalPciAttributesCount); - QemuFwCfgSelectItem (FwCfgItem); - QemuFwCfgReadBytes (FwCfgSize, LoaderStart); - RestorePciDecoding (OriginalPciAttributes, OriginalPciAttributesCount); - LoaderEnd = LoaderStart + FwCfgSize / sizeof *LoaderEntry; - - S3Context = NULL; - if (QemuFwCfgS3Enabled ()) { - // - // Size the allocation pessimistically, assuming that all commands in the - // script are QEMU_LOADER_WRITE_POINTER commands. - // - Status = AllocateS3Context (&S3Context, LoaderEnd - LoaderStart); - if (EFI_ERROR (Status)) { - goto FreeLoader; - } - } - - Tracker = OrderedCollectionInit (BlobCompare, BlobKeyCompare); - if (Tracker == NULL) { - Status = EFI_OUT_OF_RESOURCES; - goto FreeS3Context; - } - - // - // first pass: process the commands - // - // "WritePointerSubsetEnd" points one past the last successful - // QEMU_LOADER_WRITE_POINTER command. Now when we're about to start the first - // pass, no such command has been encountered yet. - // - WritePointerSubsetEnd = LoaderStart; - for (LoaderEntry = LoaderStart; LoaderEntry < LoaderEnd; ++LoaderEntry) { - switch (LoaderEntry->Type) { - case QemuLoaderCmdAllocate: - Status = ProcessCmdAllocate (&LoaderEntry->Command.Allocate, Tracker); - break; - - case QemuLoaderCmdAddPointer: - Status = ProcessCmdAddPointer (&LoaderEntry->Command.AddPointer, - Tracker); - break; - - case QemuLoaderCmdAddChecksum: - Status = ProcessCmdAddChecksum (&LoaderEntry->Command.AddChecksum, - Tracker); - break; - - case QemuLoaderCmdWritePointer: - Status = ProcessCmdWritePointer (&LoaderEntry->Command.WritePointer, - Tracker, S3Context); - if (!EFI_ERROR (Status)) { - WritePointerSubsetEnd = LoaderEntry + 1; - } - break; - - default: - DEBUG ((EFI_D_VERBOSE, "%a: unknown loader command: 0x%x\n", - __FUNCTION__, LoaderEntry->Type)); - break; - } - - if (EFI_ERROR (Status)) { - goto RollbackWritePointersAndFreeTracker; - } - } - - InstalledKey = AllocatePool (INSTALLED_TABLES_MAX * sizeof *InstalledKey); - if (InstalledKey == NULL) { - Status = EFI_OUT_OF_RESOURCES; - goto RollbackWritePointersAndFreeTracker; - } - - SeenPointers = OrderedCollectionInit (PointerCompare, PointerCompare); - if (SeenPointers == NULL) { - Status = EFI_OUT_OF_RESOURCES; - goto FreeKeys; - } - - // - // second pass: identify and install ACPI tables - // - Installed = 0; - for (LoaderEntry = LoaderStart; LoaderEntry < LoaderEnd; ++LoaderEntry) { - if (LoaderEntry->Type == QemuLoaderCmdAddPointer) { - Status = Process2ndPassCmdAddPointer ( - &LoaderEntry->Command.AddPointer, - Tracker, - AcpiProtocol, - InstalledKey, - &Installed, - SeenPointers - ); - if (EFI_ERROR (Status)) { - goto UninstallAcpiTables; - } - } - } - - // - // Translating the condensed QEMU_LOADER_WRITE_POINTER commands to ACPI S3 - // Boot Script opcodes has to be the last operation in this function, because - // if it succeeds, it cannot be undone. - // - if (S3Context != NULL) { - Status = TransferS3ContextToBootScript (S3Context); - if (EFI_ERROR (Status)) { - goto UninstallAcpiTables; - } - // - // Ownership of S3Context has been transfered. - // - S3Context = NULL; - } - -UninstallAcpiTables: - if (EFI_ERROR (Status)) { - // - // roll back partial installation - // - while (Installed > 0) { - --Installed; - AcpiProtocol->UninstallAcpiTable (AcpiProtocol, InstalledKey[Installed]); - } - } else { - DEBUG ((EFI_D_INFO, "%a: installed %d tables\n", __FUNCTION__, Installed)); - } - - for (SeenPointerEntry = OrderedCollectionMin (SeenPointers); - SeenPointerEntry != NULL; - SeenPointerEntry = SeenPointerEntry2) { - SeenPointerEntry2 = OrderedCollectionNext (SeenPointerEntry); - OrderedCollectionDelete (SeenPointers, SeenPointerEntry, NULL); - } - OrderedCollectionUninit (SeenPointers); - -FreeKeys: - FreePool (InstalledKey); - -RollbackWritePointersAndFreeTracker: - // - // In case of failure, revoke any allocation addresses that were communicated - // to QEMU previously, before we release all the blobs. - // - if (EFI_ERROR (Status)) { - LoaderEntry = WritePointerSubsetEnd; - while (LoaderEntry > LoaderStart) { - --LoaderEntry; - if (LoaderEntry->Type == QemuLoaderCmdWritePointer) { - UndoCmdWritePointer (&LoaderEntry->Command.WritePointer); - } - } - } - - // - // Tear down the tracker infrastructure. Each fw_cfg blob will be left in - // place only if we're exiting with success and the blob hosts data that is - // not directly part of some ACPI table. - // - for (TrackerEntry = OrderedCollectionMin (Tracker); TrackerEntry != NULL; - TrackerEntry = TrackerEntry2) { - VOID *UserStruct; - BLOB *Blob; - - TrackerEntry2 = OrderedCollectionNext (TrackerEntry); - OrderedCollectionDelete (Tracker, TrackerEntry, &UserStruct); - Blob = UserStruct; - - if (EFI_ERROR (Status) || Blob->HostsOnlyTableData) { - DEBUG ((EFI_D_VERBOSE, "%a: freeing \"%a\"\n", __FUNCTION__, - Blob->File)); - gBS->FreePages ((UINTN)Blob->Base, EFI_SIZE_TO_PAGES (Blob->Size)); - } - FreePool (Blob); - } - OrderedCollectionUninit (Tracker); - -FreeS3Context: - if (S3Context != NULL) { - ReleaseS3Context (S3Context); - } - -FreeLoader: - FreePool (LoaderStart); - - return Status; -} diff --git a/OvmfPkg/AcpiPlatformDxe/QemuFwCfgAcpiPlatform.c b/OvmfPkg/AcpiPlatformDxe/QemuFwCfgAcpiPlatform.c deleted file mode 100644 index 5cb3bac9db..0000000000 --- a/OvmfPkg/AcpiPlatformDxe/QemuFwCfgAcpiPlatform.c +++ /dev/null @@ -1,39 +0,0 @@ -/** @file - OVMF ACPI Platform Driver using QEMU's fw-cfg interface - - Copyright (C) 2015, Red Hat, Inc. - Copyright (c) 2008 - 2014, Intel Corporation. All rights reserved.
- - This program and the accompanying materials are licensed and made available - under the terms and conditions of the BSD License which accompanies this - distribution. The full text of the license may be found at - http://opensource.org/licenses/bsd-license.php - - THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, WITHOUT - WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. -**/ - -#include "AcpiPlatform.h" - -/** - Effective entrypoint of QEMU fw-cfg Acpi Platform driver. - - @param ImageHandle - @param SystemTable - - @return EFI_SUCCESS - @return EFI_LOAD_ERROR - @return EFI_OUT_OF_RESOURCES - -**/ -EFI_STATUS -EFIAPI -InstallAcpiTables ( - IN EFI_ACPI_TABLE_PROTOCOL *AcpiTable - ) -{ - EFI_STATUS Status; - - Status = InstallQemuFwCfgTables (AcpiTable); - return Status; -} diff --git a/OvmfPkg/AcpiPlatformDxe/QemuFwCfgAcpiPlatformDxe.inf b/OvmfPkg/AcpiPlatformDxe/QemuFwCfgAcpiPlatformDxe.inf deleted file mode 100644 index adc50cfd9f..0000000000 --- a/OvmfPkg/AcpiPlatformDxe/QemuFwCfgAcpiPlatformDxe.inf +++ /dev/null @@ -1,62 +0,0 @@ -## @file -# OVMF ACPI Platform Driver using QEMU's fw-cfg interface -# -# Copyright (c) 2008 - 2014, Intel Corporation. All rights reserved.
-# This program and the accompanying materials -# are licensed and made available under the terms and conditions of the BSD License -# which accompanies this distribution. The full text of the license may be found at -# http://opensource.org/licenses/bsd-license.php -# -# THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, -# WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. -# -## - -[Defines] - INF_VERSION = 0x00010005 - BASE_NAME = QemuFwCfgAcpiPlatform - FILE_GUID = 17985e6f-e778-4d94-aefa-c5dd2b77e186 - MODULE_TYPE = DXE_DRIVER - VERSION_STRING = 1.0 - ENTRY_POINT = AcpiPlatformEntryPoint - -# -# The following information is for reference only and not required by the build tools. -# -# VALID_ARCHITECTURES = IA32 X64 ARM AARCH64 -# - -[Sources] - QemuFwCfgAcpiPlatform.c - QemuFwCfgAcpi.c - EntryPoint.c - PciDecoding.c - BootScript.c - -[Packages] - MdePkg/MdePkg.dec - MdeModulePkg/MdeModulePkg.dec - OvmfPkg/OvmfPkg.dec - -[LibraryClasses] - BaseLib - DebugLib - MemoryAllocationLib - OrderedCollectionLib - QemuFwCfgLib - QemuFwCfgS3Lib - UefiBootServicesTableLib - UefiDriverEntryPoint - -[Protocols] - gEfiAcpiTableProtocolGuid # PROTOCOL ALWAYS_CONSUMED - gEfiPciIoProtocolGuid # PROTOCOL SOMETIMES_CONSUMED - -[Guids] - gRootBridgesConnectedEventGroupGuid - -[Pcd] - gEfiMdeModulePkgTokenSpaceGuid.PcdPciDisableBusEnumeration - -[Depex] - gEfiAcpiTableProtocolGuid diff --git a/OvmfPkg/AcpiPlatformDxe/QemuLoader.h b/OvmfPkg/AcpiPlatformDxe/QemuLoader.h deleted file mode 100644 index 437776d86d..0000000000 --- a/OvmfPkg/AcpiPlatformDxe/QemuLoader.h +++ /dev/null @@ -1,112 +0,0 @@ -/** @file - Command structures for the QEMU FwCfg table loader interface. - - Copyright (C) 2014, 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 __QEMU_LOADER_H__ -#define __QEMU_LOADER_H__ - -#include -#include - -// -// The types and the documentation reflects the SeaBIOS interface. -// -#define QEMU_LOADER_FNAME_SIZE QEMU_FW_CFG_FNAME_SIZE - -typedef enum { - QemuLoaderCmdAllocate = 1, - QemuLoaderCmdAddPointer, - QemuLoaderCmdAddChecksum, - QemuLoaderCmdWritePointer, -} QEMU_LOADER_COMMAND_TYPE; - -typedef enum { - QemuLoaderAllocHigh = 1, - QemuLoaderAllocFSeg -} QEMU_LOADER_ALLOC_ZONE; - -#pragma pack (1) -// -// QemuLoaderCmdAllocate: download the fw_cfg file named File, to a buffer -// allocated in the zone specified by Zone, aligned at a multiple of Alignment. -// -typedef struct { - UINT8 File[QEMU_LOADER_FNAME_SIZE]; // NUL-terminated - UINT32 Alignment; // power of two - UINT8 Zone; // QEMU_LOADER_ALLOC_ZONE values -} QEMU_LOADER_ALLOCATE; - -// -// QemuLoaderCmdAddPointer: the bytes at -// [PointerOffset..PointerOffset+PointerSize) in the file PointerFile contain a -// relative pointer (an offset) into PointeeFile. Increment the relative -// pointer's value by the base address of where PointeeFile's contents have -// been placed (when QemuLoaderCmdAllocate has been executed for PointeeFile). -// -typedef struct { - UINT8 PointerFile[QEMU_LOADER_FNAME_SIZE]; // NUL-terminated - UINT8 PointeeFile[QEMU_LOADER_FNAME_SIZE]; // NUL-terminated - UINT32 PointerOffset; - UINT8 PointerSize; // one of 1, 2, 4, 8 -} QEMU_LOADER_ADD_POINTER; - -// -// QemuLoaderCmdAddChecksum: calculate the UINT8 checksum (as per -// CalculateChecksum8()) of the range [Start..Start+Length) in File. Store the -// UINT8 result at ResultOffset in the same File. -// -typedef struct { - UINT8 File[QEMU_LOADER_FNAME_SIZE]; // NUL-terminated - UINT32 ResultOffset; - UINT32 Start; - UINT32 Length; -} QEMU_LOADER_ADD_CHECKSUM; - -// -// QemuLoaderCmdWritePointer: the bytes at -// [PointerOffset..PointerOffset+PointerSize) in the writeable fw_cfg file -// PointerFile are to receive the absolute address of PointeeFile, as allocated -// and downloaded by the firmware, incremented by the value of PointeeOffset. -// Store the sum of (a) the base address of where PointeeFile's contents have -// been placed (when QemuLoaderCmdAllocate has been executed for PointeeFile) -// and (b) PointeeOffset, to this portion of PointerFile. -// -// This command is similar to QemuLoaderCmdAddPointer; the difference is that -// the "pointer to patch" does not exist in guest-physical address space, only -// in "fw_cfg file space". In addition, the "pointer to patch" is not -// initialized by QEMU in-place with a possibly nonzero offset value: the -// relative offset into PointeeFile comes from the explicit PointeeOffset -// field. -// -typedef struct { - UINT8 PointerFile[QEMU_LOADER_FNAME_SIZE]; // NUL-terminated - UINT8 PointeeFile[QEMU_LOADER_FNAME_SIZE]; // NUL-terminated - UINT32 PointerOffset; - UINT32 PointeeOffset; - UINT8 PointerSize; // one of 1, 2, 4, 8 -} QEMU_LOADER_WRITE_POINTER; - -typedef struct { - UINT32 Type; // QEMU_LOADER_COMMAND_TYPE values - union { - QEMU_LOADER_ALLOCATE Allocate; - QEMU_LOADER_ADD_POINTER AddPointer; - QEMU_LOADER_ADD_CHECKSUM AddChecksum; - QEMU_LOADER_WRITE_POINTER WritePointer; - UINT8 Padding[124]; - } Command; -} QEMU_LOADER_ENTRY; -#pragma pack () - -#endif diff --git a/OvmfPkg/AcpiPlatformDxe/Xen.c b/OvmfPkg/AcpiPlatformDxe/Xen.c deleted file mode 100644 index 618ac58b42..0000000000 --- a/OvmfPkg/AcpiPlatformDxe/Xen.c +++ /dev/null @@ -1,318 +0,0 @@ -/** @file - OVMF ACPI Xen support - - Copyright (c) 2008 - 2012, Intel Corporation. All rights reserved.
- Copyright (c) 2012, Bei Guan - - This program and the accompanying materials - are licensed and made 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 "AcpiPlatform.h" -#include -#include -#include - -#define XEN_ACPI_PHYSICAL_ADDRESS 0x000EA020 -#define XEN_BIOS_PHYSICAL_END 0x000FFFFF - -EFI_ACPI_2_0_ROOT_SYSTEM_DESCRIPTION_POINTER *XenAcpiRsdpStructurePtr = NULL; - -/** - This function detects if OVMF is running on Xen. - -**/ -BOOLEAN -XenDetected ( - VOID - ) -{ - EFI_HOB_GUID_TYPE *GuidHob; - - // - // See if a XenInfo HOB is available - // - GuidHob = GetFirstGuidHob (&gEfiXenInfoGuid); - if (GuidHob == NULL) { - return FALSE; - } - - return TRUE; -} - -/** - Get the address of Xen ACPI Root System Description Pointer (RSDP) - structure. - - @param RsdpStructurePtr Return pointer to RSDP structure - - @return EFI_SUCCESS Find Xen RSDP structure successfully. - @return EFI_NOT_FOUND Don't find Xen RSDP structure. - @return EFI_ABORTED Find Xen RSDP structure, but it's not integrated. - -**/ -EFI_STATUS -EFIAPI -GetXenAcpiRsdp ( - OUT EFI_ACPI_2_0_ROOT_SYSTEM_DESCRIPTION_POINTER **RsdpPtr - ) -{ - EFI_ACPI_2_0_ROOT_SYSTEM_DESCRIPTION_POINTER *RsdpStructurePtr; - UINT8 *XenAcpiPtr; - UINT8 Sum; - - // - // Detect the RSDP structure - // - for (XenAcpiPtr = (UINT8*)(UINTN) XEN_ACPI_PHYSICAL_ADDRESS; - XenAcpiPtr < (UINT8*)(UINTN) XEN_BIOS_PHYSICAL_END; - XenAcpiPtr += 0x10) { - - RsdpStructurePtr = (EFI_ACPI_2_0_ROOT_SYSTEM_DESCRIPTION_POINTER *) - (UINTN) XenAcpiPtr; - - if (!AsciiStrnCmp ((CHAR8 *) &RsdpStructurePtr->Signature, "RSD PTR ", 8)) { - // - // RSDP ACPI 1.0 checksum for 1.0/2.0/3.0 table. - // This is only the first 20 bytes of the structure - // - Sum = CalculateSum8 ( - (CONST UINT8 *)RsdpStructurePtr, - sizeof (EFI_ACPI_1_0_ROOT_SYSTEM_DESCRIPTION_POINTER) - ); - if (Sum != 0) { - return EFI_ABORTED; - } - - if (RsdpStructurePtr->Revision >= 2) { - // - // RSDP ACPI 2.0/3.0 checksum, this is the entire table - // - Sum = CalculateSum8 ( - (CONST UINT8 *)RsdpStructurePtr, - sizeof (EFI_ACPI_2_0_ROOT_SYSTEM_DESCRIPTION_POINTER) - ); - if (Sum != 0) { - return EFI_ABORTED; - } - } - *RsdpPtr = RsdpStructurePtr; - return EFI_SUCCESS; - } - } - - return EFI_NOT_FOUND; -} - -/** - Get Xen Acpi tables from the RSDP structure. And installs Xen ACPI tables - into the RSDT/XSDT using InstallAcpiTable. Some signature of the installed - ACPI tables are: FACP, APIC, HPET, WAET, SSDT, FACS, DSDT. - - @param AcpiProtocol Protocol instance pointer. - - @return EFI_SUCCESS The table was successfully inserted. - @return EFI_INVALID_PARAMETER Either AcpiTableBuffer is NULL, TableHandle is - NULL, or AcpiTableBufferSize and the size - field embedded in the ACPI table pointed to - by AcpiTableBuffer are not in sync. - @return EFI_OUT_OF_RESOURCES Insufficient resources exist to complete the request. - -**/ -EFI_STATUS -EFIAPI -InstallXenTables ( - IN EFI_ACPI_TABLE_PROTOCOL *AcpiProtocol - ) -{ - EFI_STATUS Status; - UINTN TableHandle; - - EFI_ACPI_DESCRIPTION_HEADER *Rsdt; - EFI_ACPI_DESCRIPTION_HEADER *Xsdt; - VOID *CurrentTableEntry; - UINTN CurrentTablePointer; - EFI_ACPI_DESCRIPTION_HEADER *CurrentTable; - UINTN Index; - UINTN NumberOfTableEntries; - EFI_ACPI_2_0_FIXED_ACPI_DESCRIPTION_TABLE *Fadt2Table; - EFI_ACPI_1_0_FIXED_ACPI_DESCRIPTION_TABLE *Fadt1Table; - EFI_ACPI_2_0_FIRMWARE_ACPI_CONTROL_STRUCTURE *Facs2Table; - EFI_ACPI_1_0_FIRMWARE_ACPI_CONTROL_STRUCTURE *Facs1Table; - EFI_ACPI_DESCRIPTION_HEADER *DsdtTable; - - Fadt2Table = NULL; - Fadt1Table = NULL; - Facs2Table = NULL; - Facs1Table = NULL; - DsdtTable = NULL; - TableHandle = 0; - NumberOfTableEntries = 0; - - // - // Try to find Xen ACPI tables - // - Status = GetXenAcpiRsdp (&XenAcpiRsdpStructurePtr); - if (EFI_ERROR (Status)) { - return Status; - } - - // - // If XSDT table is find, just install its tables. - // Otherwise, try to find and install the RSDT tables. - // - if (XenAcpiRsdpStructurePtr->XsdtAddress) { - // - // Retrieve the addresses of XSDT and - // calculate the number of its table entries. - // - Xsdt = (EFI_ACPI_DESCRIPTION_HEADER *) (UINTN) - XenAcpiRsdpStructurePtr->XsdtAddress; - NumberOfTableEntries = (Xsdt->Length - - sizeof (EFI_ACPI_DESCRIPTION_HEADER)) / - sizeof (UINT64); - - // - // Install ACPI tables found in XSDT. - // - for (Index = 0; Index < NumberOfTableEntries; Index++) { - // - // Get the table entry from XSDT - // - CurrentTableEntry = (VOID *) ((UINT8 *) Xsdt + - sizeof (EFI_ACPI_DESCRIPTION_HEADER) + - Index * sizeof (UINT64)); - CurrentTablePointer = (UINTN) *(UINT64 *)CurrentTableEntry; - CurrentTable = (EFI_ACPI_DESCRIPTION_HEADER *) CurrentTablePointer; - - // - // Install the XSDT tables - // - Status = InstallAcpiTable ( - AcpiProtocol, - CurrentTable, - CurrentTable->Length, - &TableHandle - ); - - if (EFI_ERROR (Status)) { - return Status; - } - - // - // Get the FACS and DSDT table address from the table FADT - // - if (!AsciiStrnCmp ((CHAR8 *) &CurrentTable->Signature, "FACP", 4)) { - Fadt2Table = (EFI_ACPI_2_0_FIXED_ACPI_DESCRIPTION_TABLE *) - (UINTN) CurrentTablePointer; - Facs2Table = (EFI_ACPI_2_0_FIRMWARE_ACPI_CONTROL_STRUCTURE *) - (UINTN) Fadt2Table->FirmwareCtrl; - DsdtTable = (EFI_ACPI_DESCRIPTION_HEADER *) (UINTN) Fadt2Table->Dsdt; - } - } - } - else if (XenAcpiRsdpStructurePtr->RsdtAddress) { - // - // Retrieve the addresses of RSDT and - // calculate the number of its table entries. - // - Rsdt = (EFI_ACPI_DESCRIPTION_HEADER *) (UINTN) - XenAcpiRsdpStructurePtr->RsdtAddress; - NumberOfTableEntries = (Rsdt->Length - - sizeof (EFI_ACPI_DESCRIPTION_HEADER)) / - sizeof (UINT32); - - // - // Install ACPI tables found in XSDT. - // - for (Index = 0; Index < NumberOfTableEntries; Index++) { - // - // Get the table entry from RSDT - // - CurrentTableEntry = (UINT32 *) ((UINT8 *) Rsdt + - sizeof (EFI_ACPI_DESCRIPTION_HEADER) + - Index * sizeof (UINT32)); - CurrentTablePointer = *(UINT32 *)CurrentTableEntry; - CurrentTable = (EFI_ACPI_DESCRIPTION_HEADER *) CurrentTablePointer; - - // - // Install the RSDT tables - // - Status = InstallAcpiTable ( - AcpiProtocol, - CurrentTable, - CurrentTable->Length, - &TableHandle - ); - - if (EFI_ERROR (Status)) { - return Status; - } - - // - // Get the FACS and DSDT table address from the table FADT - // - if (!AsciiStrnCmp ((CHAR8 *) &CurrentTable->Signature, "FACP", 4)) { - Fadt1Table = (EFI_ACPI_1_0_FIXED_ACPI_DESCRIPTION_TABLE *) - (UINTN) CurrentTablePointer; - Facs1Table = (EFI_ACPI_1_0_FIRMWARE_ACPI_CONTROL_STRUCTURE *) - (UINTN) Fadt1Table->FirmwareCtrl; - DsdtTable = (EFI_ACPI_DESCRIPTION_HEADER *) (UINTN) Fadt1Table->Dsdt; - } - } - } - - // - // Install the FACS table. - // - if (Fadt2Table) { - // - // FACS 2.0 - // - Status = InstallAcpiTable ( - AcpiProtocol, - Facs2Table, - Facs2Table->Length, - &TableHandle - ); - if (EFI_ERROR (Status)) { - return Status; - } - } - else if (Fadt1Table) { - // - // FACS 1.0 - // - Status = InstallAcpiTable ( - AcpiProtocol, - Facs1Table, - Facs1Table->Length, - &TableHandle - ); - if (EFI_ERROR (Status)) { - return Status; - } - } - - // - // Install DSDT table. - // - Status = InstallAcpiTable ( - AcpiProtocol, - DsdtTable, - DsdtTable->Length, - &TableHandle - ); - if (EFI_ERROR (Status)) { - return Status; - } - - return EFI_SUCCESS; -} - diff --git a/OvmfPkg/AcpiTables/AcpiTables.inf b/OvmfPkg/AcpiTables/AcpiTables.inf deleted file mode 100644 index 2c604c34d5..0000000000 --- a/OvmfPkg/AcpiTables/AcpiTables.inf +++ /dev/null @@ -1,44 +0,0 @@ -## @file -# Component description file for PlatformAcpiTables module. -# -# ACPI table data and ASL sources required to boot the platform. -# -# Copyright (c) 2008 - 2010, Intel Corporation. All rights reserved.
-# This program and the accompanying materials -# are licensed and made available under the terms and conditions of the BSD License -# which accompanies this distribution. The full text of the license may be found at -# http://opensource.org/licenses/bsd-license.php -# -# THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, -# WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. -# -## - -[Defines] - INF_VERSION = 0x00010005 - BASE_NAME = PlatformAcpiTables - FILE_GUID = 7E374E25-8E01-4FEE-87F2-390C23C606CD - MODULE_TYPE = USER_DEFINED - VERSION_STRING = 1.0 - -# -# The following information is for reference only and not required by the build tools. -# -# VALID_ARCHITECTURES = IA32 X64 IPF EBC -# - -[Sources] - Platform.h - Madt.aslc - Facp.aslc - Facs.aslc - Dsdt.asl - Ssdt.asl - -[Packages] - MdePkg/MdePkg.dec - OvmfPkg/OvmfPkg.dec - -[Pcd] - gUefiOvmfPkgTokenSpaceGuid.PcdDebugIoPort - diff --git a/OvmfPkg/AcpiTables/Dsdt.asl b/OvmfPkg/AcpiTables/Dsdt.asl deleted file mode 100644 index 0397722039..0000000000 --- a/OvmfPkg/AcpiTables/Dsdt.asl +++ /dev/null @@ -1,698 +0,0 @@ -/** @file - Contains root level name space objects for the platform - - Copyright (c) 2008, Intel Corporation. All rights reserved.
- This program and the accompanying materials are - licensed and made available under the terms and conditions of the BSD License - which accompanies this distribution. The full text of the license may be found at - http://opensource.org/licenses/bsd-license.php - - THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, - WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. - -**/ - -DefinitionBlock ("Dsdt.aml", "DSDT", 1, "INTEL ", "OVMF ", 4) { - // - // System Sleep States - // - // We build S3 and S4 with GetSuspendStates() in - // "OvmfPkg/AcpiPlatformDxe/Qemu.c". - // - Name (\_S0, Package () {5, 0, 0, 0}) // Working - Name (\_S5, Package () {0, 0, 0, 0}) // Soft Off - - // - // System Bus - // - Scope (\_SB) { - // - // PCI Root Bridge - // - Device (PCI0) { - Name (_HID, EISAID ("PNP0A03")) - Name (_ADR, 0x00000000) - Name (_BBN, 0x00) - Name (_UID, 0x00) - - // - // BUS, I/O, and MMIO resources - // - Name (CRES, ResourceTemplate () { - WORDBusNumber ( // Bus number resource (0); the bridge produces bus numbers for its subsequent buses - ResourceProducer, // bit 0 of general flags is 1 - MinFixed, // Range is fixed - MaxFixed, // Range is fixed - PosDecode, // PosDecode - 0x0000, // Granularity - 0x0000, // Min - 0x00FF, // Max - 0x0000, // Translation - 0x0100 // Range Length = Max-Min+1 - ) - - IO (Decode16, 0xCF8, 0xCF8, 0x01, 0x08) //Consumed resource (0xCF8-0xCFF) - - WORDIO ( // Consumed-and-produced resource (all I/O below CF8) - ResourceProducer, // bit 0 of general flags is 0 - MinFixed, // Range is fixed - MaxFixed, // Range is fixed - PosDecode, - EntireRange, - 0x0000, // Granularity - 0x0000, // Min - 0x0CF7, // Max - 0x0000, // Translation - 0x0CF8 // Range Length - ) - - WORDIO ( // Consumed-and-produced resource (all I/O above CFF) - ResourceProducer, // bit 0 of general flags is 0 - MinFixed, // Range is fixed - MaxFixed, // Range is fixed - PosDecode, - EntireRange, - 0x0000, // Granularity - 0x0D00, // Min - 0xFFFF, // Max - 0x0000, // Translation - 0xF300 // Range Length - ) - - DWORDMEMORY ( // Descriptor for legacy VGA video RAM - ResourceProducer, // bit 0 of general flags is 0 - PosDecode, - MinFixed, // Range is fixed - MaxFixed, // Range is Fixed - Cacheable, - ReadWrite, - 0x00000000, // Granularity - 0x000A0000, // Min - 0x000BFFFF, // Max - 0x00000000, // Translation - 0x00020000 // Range Length - ) - - DWORDMEMORY ( // Descriptor for 32-bit MMIO - ResourceProducer, // bit 0 of general flags is 0 - PosDecode, - MinFixed, // Range is fixed - MaxFixed, // Range is Fixed - NonCacheable, - ReadWrite, - 0x00000000, // Granularity - 0xF8000000, // Min - 0xFFFBFFFF, // Max - 0x00000000, // Translation - 0x07FC0000, // Range Length - , // ResourceSourceIndex - , // ResourceSource - PW32 // DescriptorName - ) - }) - - Name (CR64, ResourceTemplate () { - QWordMemory ( // Descriptor for 64-bit MMIO - ResourceProducer, // bit 0 of general flags is 0 - PosDecode, - MinFixed, // Range is fixed - MaxFixed, // Range is Fixed - Cacheable, - ReadWrite, - 0x00000000, // Granularity - 0x8000000000, // Min - 0xFFFFFFFFFF, // Max - 0x00000000, // Translation - 0x8000000000, // Range Length - , // ResourceSourceIndex - , // ResourceSource - PW64 // DescriptorName - ) - }) - - Method (_CRS, 0, Serialized) { - // - // see the FIRMWARE_DATA structure in "OvmfPkg/AcpiPlatformDxe/Qemu.c" - // - External (FWDT, OpRegionObj) - Field(FWDT, QWordAcc, NoLock, Preserve) { - P0S, 64, // PciWindow32.Base - P0E, 64, // PciWindow32.End - P0L, 64, // PciWindow32.Length - P1S, 64, // PciWindow64.Base - P1E, 64, // PciWindow64.End - P1L, 64 // PciWindow64.Length - } - Field(FWDT, DWordAcc, NoLock, Preserve) { - P0SL, 32, // PciWindow32.Base, low 32 bits - P0SH, 32, // PciWindow32.Base, high 32 bits - P0EL, 32, // PciWindow32.End, low 32 bits - P0EH, 32, // PciWindow32.End, high 32 bits - P0LL, 32, // PciWindow32.Length, low 32 bits - P0LH, 32, // PciWindow32.Length, high 32 bits - P1SL, 32, // PciWindow64.Base, low 32 bits - P1SH, 32, // PciWindow64.Base, high 32 bits - P1EL, 32, // PciWindow64.End, low 32 bits - P1EH, 32, // PciWindow64.End, high 32 bits - P1LL, 32, // PciWindow64.Length, low 32 bits - P1LH, 32 // PciWindow64.Length, high 32 bits - } - - // - // fixup 32-bit PCI IO window - // - CreateDWordField (CRES, \_SB.PCI0.PW32._MIN, PS32) - CreateDWordField (CRES, \_SB.PCI0.PW32._MAX, PE32) - CreateDWordField (CRES, \_SB.PCI0.PW32._LEN, PL32) - Store (P0SL, PS32) - Store (P0EL, PE32) - Store (P0LL, PL32) - - If (LAnd (LEqual (P1SL, 0x00), LEqual (P1SH, 0x00))) { - Return (CRES) - } Else { - // - // fixup 64-bit PCI IO window - // - CreateQWordField (CR64, \_SB.PCI0.PW64._MIN, PS64) - CreateQWordField (CR64, \_SB.PCI0.PW64._MAX, PE64) - CreateQWordField (CR64, \_SB.PCI0.PW64._LEN, PL64) - Store (P1S, PS64) - Store (P1E, PE64) - Store (P1L, PL64) - - // - // add window and return result - // - ConcatenateResTemplate (CRES, CR64, Local0) - Return (Local0) - } - } - - // - // PCI Interrupt Routing Table - PIC Mode Only - // - Method (_PRT, 0, NotSerialized) { - Return ( - Package () { - // - // Bus 0; Devices 0 to 15 - // - Package () {0x0000FFFF, 0x00, \_SB.PCI0.LPC.LNKD, 0x00}, - Package () {0x0000FFFF, 0x01, \_SB.PCI0.LPC.LNKA, 0x00}, - Package () {0x0000FFFF, 0x02, \_SB.PCI0.LPC.LNKB, 0x00}, - Package () {0x0000FFFF, 0x03, \_SB.PCI0.LPC.LNKC, 0x00}, - - // - // Bus 0, Device 1, Pin 0 (INTA) is special; it corresponds to the - // internally generated SCI (System Control Interrupt), which is - // always routed to GSI 9. By setting the third (= Source) field to - // zero, we could use the fourth (= Source Index) field to hardwire - // the pin to GSI 9 directly. - // - // That way however, in accordance with the ACPI spec's description - // of SCI, the interrupt would be treated as "active low, - // shareable, level", and that doesn't match qemu. - // - // In QemuInstallAcpiMadtTable() [OvmfPkg/AcpiPlatformDxe/Qemu.c] - // we install an Interrupt Override Structure for the identity - // mapped IRQ#9 / GSI 9 (the corresponding bit being set in - // Pcd8259LegacyModeEdgeLevel), which describes the correct - // polarity (active high). As a consequence, some OS'en (eg. Linux) - // override the default (active low) polarity originating from the - // _PRT; others (eg. FreeBSD) don't. Therefore we need a separate - // link device just to specify a polarity that matches the MADT. - // - Package () {0x0001FFFF, 0x00, \_SB.PCI0.LPC.LNKS, 0x00}, - - Package () {0x0001FFFF, 0x01, \_SB.PCI0.LPC.LNKB, 0x00}, - Package () {0x0001FFFF, 0x02, \_SB.PCI0.LPC.LNKC, 0x00}, - Package () {0x0001FFFF, 0x03, \_SB.PCI0.LPC.LNKD, 0x00}, - - Package () {0x0002FFFF, 0x00, \_SB.PCI0.LPC.LNKB, 0x00}, - Package () {0x0002FFFF, 0x01, \_SB.PCI0.LPC.LNKC, 0x00}, - Package () {0x0002FFFF, 0x02, \_SB.PCI0.LPC.LNKD, 0x00}, - Package () {0x0002FFFF, 0x03, \_SB.PCI0.LPC.LNKA, 0x00}, - - Package () {0x0003FFFF, 0x00, \_SB.PCI0.LPC.LNKC, 0x00}, - Package () {0x0003FFFF, 0x01, \_SB.PCI0.LPC.LNKD, 0x00}, - Package () {0x0003FFFF, 0x02, \_SB.PCI0.LPC.LNKA, 0x00}, - Package () {0x0003FFFF, 0x03, \_SB.PCI0.LPC.LNKB, 0x00}, - - Package () {0x0004FFFF, 0x00, \_SB.PCI0.LPC.LNKD, 0x00}, - Package () {0x0004FFFF, 0x01, \_SB.PCI0.LPC.LNKA, 0x00}, - Package () {0x0004FFFF, 0x02, \_SB.PCI0.LPC.LNKB, 0x00}, - Package () {0x0004FFFF, 0x03, \_SB.PCI0.LPC.LNKC, 0x00}, - - Package () {0x0005FFFF, 0x00, \_SB.PCI0.LPC.LNKA, 0x00}, - Package () {0x0005FFFF, 0x01, \_SB.PCI0.LPC.LNKB, 0x00}, - Package () {0x0005FFFF, 0x02, \_SB.PCI0.LPC.LNKC, 0x00}, - Package () {0x0005FFFF, 0x03, \_SB.PCI0.LPC.LNKD, 0x00}, - - Package () {0x0006FFFF, 0x00, \_SB.PCI0.LPC.LNKB, 0x00}, - Package () {0x0006FFFF, 0x01, \_SB.PCI0.LPC.LNKC, 0x00}, - Package () {0x0006FFFF, 0x02, \_SB.PCI0.LPC.LNKD, 0x00}, - Package () {0x0006FFFF, 0x03, \_SB.PCI0.LPC.LNKA, 0x00}, - - Package () {0x0007FFFF, 0x00, \_SB.PCI0.LPC.LNKC, 0x00}, - Package () {0x0007FFFF, 0x01, \_SB.PCI0.LPC.LNKD, 0x00}, - Package () {0x0007FFFF, 0x02, \_SB.PCI0.LPC.LNKA, 0x00}, - Package () {0x0007FFFF, 0x03, \_SB.PCI0.LPC.LNKB, 0x00}, - - Package () {0x0008FFFF, 0x00, \_SB.PCI0.LPC.LNKD, 0x00}, - Package () {0x0008FFFF, 0x01, \_SB.PCI0.LPC.LNKA, 0x00}, - Package () {0x0008FFFF, 0x02, \_SB.PCI0.LPC.LNKB, 0x00}, - Package () {0x0008FFFF, 0x03, \_SB.PCI0.LPC.LNKC, 0x00}, - - Package () {0x0009FFFF, 0x00, \_SB.PCI0.LPC.LNKA, 0x00}, - Package () {0x0009FFFF, 0x01, \_SB.PCI0.LPC.LNKB, 0x00}, - Package () {0x0009FFFF, 0x02, \_SB.PCI0.LPC.LNKC, 0x00}, - Package () {0x0009FFFF, 0x03, \_SB.PCI0.LPC.LNKD, 0x00}, - - Package () {0x000AFFFF, 0x00, \_SB.PCI0.LPC.LNKB, 0x00}, - Package () {0x000AFFFF, 0x01, \_SB.PCI0.LPC.LNKC, 0x00}, - Package () {0x000AFFFF, 0x02, \_SB.PCI0.LPC.LNKD, 0x00}, - Package () {0x000AFFFF, 0x03, \_SB.PCI0.LPC.LNKA, 0x00}, - - Package () {0x000BFFFF, 0x00, \_SB.PCI0.LPC.LNKC, 0x00}, - Package () {0x000BFFFF, 0x01, \_SB.PCI0.LPC.LNKD, 0x00}, - Package () {0x000BFFFF, 0x02, \_SB.PCI0.LPC.LNKA, 0x00}, - Package () {0x000BFFFF, 0x03, \_SB.PCI0.LPC.LNKB, 0x00}, - - Package () {0x000CFFFF, 0x00, \_SB.PCI0.LPC.LNKD, 0x00}, - Package () {0x000CFFFF, 0x01, \_SB.PCI0.LPC.LNKA, 0x00}, - Package () {0x000CFFFF, 0x02, \_SB.PCI0.LPC.LNKB, 0x00}, - Package () {0x000CFFFF, 0x03, \_SB.PCI0.LPC.LNKC, 0x00}, - - Package () {0x000DFFFF, 0x00, \_SB.PCI0.LPC.LNKA, 0x00}, - Package () {0x000DFFFF, 0x01, \_SB.PCI0.LPC.LNKB, 0x00}, - Package () {0x000DFFFF, 0x02, \_SB.PCI0.LPC.LNKC, 0x00}, - Package () {0x000DFFFF, 0x03, \_SB.PCI0.LPC.LNKD, 0x00}, - - Package () {0x000EFFFF, 0x00, \_SB.PCI0.LPC.LNKB, 0x00}, - Package () {0x000EFFFF, 0x01, \_SB.PCI0.LPC.LNKC, 0x00}, - Package () {0x000EFFFF, 0x02, \_SB.PCI0.LPC.LNKD, 0x00}, - Package () {0x000EFFFF, 0x03, \_SB.PCI0.LPC.LNKA, 0x00}, - - Package () {0x000FFFFF, 0x00, \_SB.PCI0.LPC.LNKC, 0x00}, - Package () {0x000FFFFF, 0x01, \_SB.PCI0.LPC.LNKD, 0x00}, - Package () {0x000FFFFF, 0x02, \_SB.PCI0.LPC.LNKA, 0x00}, - Package () {0x000FFFFF, 0x03, \_SB.PCI0.LPC.LNKB, 0x00} - } - ) - } - - // - // PCI to ISA Bridge (Bus 0, Device 1, Function 0) - // "Low Pin Count" - // - Device (LPC) { - Name (_ADR, 0x00010000) - - // - // The SCI cannot be rerouted or disabled with PIRQRC[A:D]; we only - // need this link device in order to specify the polarity. - // - Device (LNKS) { - Name (_HID, EISAID("PNP0C0F")) - Name (_UID, 0) - - Name (_STA, 0xB) // 0x1: device present - // 0x2: enabled and decoding resources - // 0x8: functioning properly - - Method (_SRS, 1, NotSerialized) { /* no-op */ } - Method (_DIS, 0, NotSerialized) { /* no-op */ } - - Name (_PRS, ResourceTemplate () { - Interrupt (ResourceConsumer, Level, ActiveHigh, Shared) { 9 } - // - // list of IRQs occupied thus far: 9 - // - }) - Method (_CRS, 0, NotSerialized) { Return (_PRS) } - } - - // - // PCI Interrupt Routing Configuration Registers, PIRQRC[A:D] - // - OperationRegion (PRR0, PCI_Config, 0x60, 0x04) - Field (PRR0, ANYACC, NOLOCK, PRESERVE) { - PIRA, 8, - PIRB, 8, - PIRC, 8, - PIRD, 8 - } - - // - // _STA method for LNKA, LNKB, LNKC, LNKD - // Arg0[in]: value of PIRA / PIRB / PIRC / PIRD - // - Method (PSTA, 1, NotSerialized) { - If (And (Arg0, 0x80)) { // disable-bit set? - Return (0x9) // "device present" | "functioning properly" - } Else { - Return (0xB) // same | "enabled and decoding resources" - } - } - - // - // _CRS method for LNKA, LNKB, LNKC, LNKD - // Arg0[in]: value of PIRA / PIRB / PIRC / PIRD - // - Method (PCRS, 1, Serialized) { - // - // create temporary buffer with an Extended Interrupt Descriptor - // whose single vector defaults to zero - // - Name (BUF0, ResourceTemplate () { - Interrupt (ResourceConsumer, Level, ActiveHigh, Shared){0} - } - ) - - // - // define reference to first interrupt vector in buffer - // - CreateDWordField (BUF0, 0x05, IRQW) - - // - // If the disable-bit is clear, overwrite the default zero vector - // with the value in Arg0 (ie. PIRQRC[A:D]). Reserved bits are read - // as 0. - // - If (LNot (And (Arg0, 0x80))) { - Store (Arg0, IRQW) - } - Return (BUF0) - } - - // - // _PRS resource for LNKA, LNKB, LNKC, LNKD - // - Name (PPRS, ResourceTemplate () { - Interrupt (ResourceConsumer, Level, ActiveHigh, Shared) {5, 10, 11} - // - // list of IRQs occupied thus far: 9, 5, 10, 11 - // - }) - - // - // PCI IRQ Link A - // - Device (LNKA) { - Name (_HID, EISAID("PNP0C0F")) - Name (_UID, 1) - - Method (_STA, 0, NotSerialized) { Return (PSTA (PIRA)) } - Method (_DIS, 0, NotSerialized) { - Or (PIRA, 0x80, PIRA) // set disable-bit - } - Method (_CRS, 0, NotSerialized) { Return (PCRS (PIRA)) } - Method (_PRS, 0, NotSerialized) { Return (PPRS) } - Method (_SRS, 1, NotSerialized) { - CreateDWordField (Arg0, 0x05, IRQW) - Store (IRQW, PIRA) - } - } - - // - // PCI IRQ Link B - // - Device (LNKB) { - Name (_HID, EISAID("PNP0C0F")) - Name (_UID, 2) - - Method (_STA, 0, NotSerialized) { Return (PSTA (PIRB)) } - Method (_DIS, 0, NotSerialized) { - Or (PIRB, 0x80, PIRB) // set disable-bit - } - Method (_CRS, 0, NotSerialized) { Return (PCRS (PIRB)) } - Method (_PRS, 0, NotSerialized) { Return (PPRS) } - Method (_SRS, 1, NotSerialized) { - CreateDWordField (Arg0, 0x05, IRQW) - Store (IRQW, PIRB) - } - } - - // - // PCI IRQ Link C - // - Device (LNKC) { - Name (_HID, EISAID("PNP0C0F")) - Name (_UID, 3) - - Method (_STA, 0, NotSerialized) { Return (PSTA (PIRC)) } - Method (_DIS, 0, NotSerialized) { - Or (PIRC, 0x80, PIRC) // set disable-bit - } - Method (_CRS, 0, NotSerialized) { Return (PCRS (PIRC)) } - Method (_PRS, 0, NotSerialized) { Return (PPRS) } - Method (_SRS, 1, NotSerialized) { - CreateDWordField (Arg0, 0x05, IRQW) - Store (IRQW, PIRC) - } - } - - // - // PCI IRQ Link D - // - Device (LNKD) { - Name (_HID, EISAID("PNP0C0F")) - Name (_UID, 4) - - Method (_STA, 0, NotSerialized) { Return (PSTA (PIRD)) } - Method (_DIS, 0, NotSerialized) { - Or (PIRD, 0x80, PIRD) // set disable-bit - } - Method (_CRS, 0, NotSerialized) { Return (PCRS (PIRD)) } - Method (_PRS, 0, NotSerialized) { Return (PPRS) } - Method (_SRS, 1, NotSerialized) { - CreateDWordField (Arg0, 0x05, IRQW) - Store (IRQW, PIRD) - } - } - - // - // Programmable Interrupt Controller (PIC) - // - Device(PIC) { - Name (_HID, EISAID ("PNP0000")) - Name (_CRS, ResourceTemplate () { - IO (Decode16, 0x020, 0x020, 0x00, 0x02) - IO (Decode16, 0x0A0, 0x0A0, 0x00, 0x02) - IO (Decode16, 0x4D0, 0x4D0, 0x00, 0x02) - IRQNoFlags () {2} - // - // list of IRQs occupied thus far: 9, 5, 10, 11, 2 - // - }) - } - - // - // ISA DMA - // - Device (DMAC) { - Name (_HID, EISAID ("PNP0200")) - Name (_CRS, ResourceTemplate () { - IO (Decode16, 0x00, 0x00, 0, 0x10) - IO (Decode16, 0x81, 0x81, 0, 0x03) - IO (Decode16, 0x87, 0x87, 0, 0x01) - IO (Decode16, 0x89, 0x89, 0, 0x03) - IO (Decode16, 0x8f, 0x8f, 0, 0x01) - IO (Decode16, 0xc0, 0xc0, 0, 0x20) - DMA (Compatibility, NotBusMaster, Transfer8) {4} - }) - } - - // - // 8254 Timer - // - Device(TMR) { - Name(_HID,EISAID("PNP0100")) - Name(_CRS, ResourceTemplate () { - IO (Decode16, 0x40, 0x40, 0x00, 0x04) - IRQNoFlags () {0} - // - // list of IRQs occupied thus far: 9, 5, 10, 11, 2, 0 - // - }) - } - - // - // Real Time Clock - // - Device (RTC) { - Name (_HID, EISAID ("PNP0B00")) - Name (_CRS, ResourceTemplate () { - IO (Decode16, 0x70, 0x70, 0x00, 0x02) - IRQNoFlags () {8} - // - // list of IRQs occupied thus far: 9, 5, 10, 11, 2, 0, 8 - // - }) - } - - // - // PCAT Speaker - // - Device(SPKR) { - Name (_HID, EISAID("PNP0800")) - Name (_CRS, ResourceTemplate () { - IO (Decode16, 0x61, 0x61, 0x01, 0x01) - }) - } - - // - // Floating Point Coprocessor - // - Device(FPU) { - Name (_HID, EISAID("PNP0C04")) - Name (_CRS, ResourceTemplate () { - IO (Decode16, 0xF0, 0xF0, 0x00, 0x10) - IRQNoFlags () {13} - // - // list of IRQs occupied thus far: 9, 5, 10, 11, 2, 0, 8, 13 - // - }) - } - - // - // Generic motherboard devices and pieces that don't fit anywhere else - // - Device(XTRA) { - Name (_HID, EISAID ("PNP0C02")) - Name (_UID, 0x01) - Name (_CRS, ResourceTemplate () { - IO (Decode16, 0x010, 0x010, 0x00, 0x10) - IO (Decode16, 0x022, 0x022, 0x00, 0x1E) - IO (Decode16, 0x044, 0x044, 0x00, 0x1C) - IO (Decode16, 0x062, 0x062, 0x00, 0x02) - IO (Decode16, 0x065, 0x065, 0x00, 0x0B) - IO (Decode16, 0x072, 0x072, 0x00, 0x0E) - IO (Decode16, 0x080, 0x080, 0x00, 0x01) - IO (Decode16, 0x084, 0x084, 0x00, 0x03) - IO (Decode16, 0x088, 0x088, 0x00, 0x01) - IO (Decode16, 0x08c, 0x08c, 0x00, 0x03) - IO (Decode16, 0x090, 0x090, 0x00, 0x10) - IO (Decode16, 0x0A2, 0x0A2, 0x00, 0x1E) - IO (Decode16, 0x0E0, 0x0E0, 0x00, 0x10) - IO (Decode16, 0x1E0, 0x1E0, 0x00, 0x10) - IO (Decode16, 0x160, 0x160, 0x00, 0x10) - IO (Decode16, 0x278, 0x278, 0x00, 0x08) - IO (Decode16, 0x370, 0x370, 0x00, 0x02) - IO (Decode16, 0x378, 0x378, 0x00, 0x08) - IO (Decode16, FixedPcdGet16 (PcdDebugIoPort), FixedPcdGet16 (PcdDebugIoPort), 0x00, 0x01) - IO (Decode16, 0x440, 0x440, 0x00, 0x10) - IO (Decode16, 0x678, 0x678, 0x00, 0x08) - IO (Decode16, 0x778, 0x778, 0x00, 0x08) - IO (Decode16, 0xafe0, 0xafe0, 0x00, 0x04) // QEMU GPE0 BLK - IO (Decode16, 0xb000, 0xb000, 0x00, 0x40) // PMBLK1 - Memory32Fixed (ReadOnly, 0xFEC00000, 0x1000) // IO APIC - Memory32Fixed (ReadOnly, 0xFEE00000, 0x100000) // LAPIC - }) - } - - // - // PS/2 Keyboard and PC/AT Enhanced Keyboard 101/102 - // - Device (PS2K) { - Name (_HID, EISAID ("PNP0303")) - Name (_CID, EISAID ("PNP030B")) - Name(_CRS,ResourceTemplate() { - IO (Decode16, 0x60, 0x60, 0x00, 0x01) - IO (Decode16, 0x64, 0x64, 0x00, 0x01) - IRQNoFlags () {1} - // - // list of IRQs occupied thus far: 9, 5, 10, 11, 2, 0, 8, 13, 1 - // - }) - } - - // - // PS/2 Mouse and Microsoft Mouse - // - Device (PS2M) { // PS/2 stype mouse port - Name (_HID, EISAID ("PNP0F03")) - Name (_CID, EISAID ("PNP0F13")) - Name (_CRS, ResourceTemplate() { - IRQNoFlags () {12} - // - // list of IRQs occupied thus far: - // 9, 5, 10, 11, 2, 0, 8, 13, 1, 12 - // - }) - } - - // - // UART Serial Port - COM1 - // - Device (UAR1) { - Name (_HID, EISAID ("PNP0501")) - Name (_DDN, "COM1") - Name (_UID, 0x01) - Name(_CRS,ResourceTemplate() { - IO (Decode16, 0x3F8, 0x3F8, 0x01, 0x08) - IRQ (Edge, ActiveHigh, Exclusive, ) {4} - // - // list of IRQs occupied thus far: - // 9, 5, 10, 11, 2, 0, 8, 13, 1, 12, 4 - // - }) - } - - // - // UART Serial Port - COM2 - // - Device (UAR2) { - Name (_HID, EISAID ("PNP0501")) - Name (_DDN, "COM2") - Name (_UID, 0x02) - Name(_CRS,ResourceTemplate() { - IO (Decode16, 0x2F8, 0x2F8, 0x01, 0x08) - IRQ (Edge, ActiveHigh, Exclusive, ) {3} - // - // list of IRQs occupied thus far: - // 9, 5, 10, 11, 2, 0, 8, 13, 1, 12, 4, 3 - // - }) - } - - // - // Floppy Disk Controller - // - Device (FDC) { - Name (_HID, EISAID ("PNP0700")) - Name (_CRS,ResourceTemplate() { - IO (Decode16, 0x3F0, 0x3F0, 0x01, 0x06) - IO (Decode16, 0x3F7, 0x3F7, 0x01, 0x01) - IRQNoFlags () {6} - // - // list of IRQs occupied thus far: - // 9, 5, 10, 11, 2, 0, 8, 13, 1, 12, 4, 3, 6 - // - DMA (Compatibility, NotBusMaster, Transfer8) {2} - }) - } - - // - // parallel port -- no DMA for now - // - Device (PAR1) { - Name (_HID, EISAID ("PNP0400")) - Name (_DDN, "LPT1") - Name (_UID, 0x01) - Name(_CRS, ResourceTemplate() { - IO (Decode16, 0x0378, 0x0378, 0x00, 0x08) - IRQNoFlags () {7} - // - // list of IRQs occupied thus far: - // 9, 5, 10, 11, 2, 0, 8, 13, 1, 12, 4, 3, 6, 7 - // in order: - // 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13 - // - }) - } - } - } - } -} diff --git a/OvmfPkg/AcpiTables/Facp.aslc b/OvmfPkg/AcpiTables/Facp.aslc deleted file mode 100644 index df35285c9c..0000000000 --- a/OvmfPkg/AcpiTables/Facp.aslc +++ /dev/null @@ -1,95 +0,0 @@ -/** @file - FACP Table - - Copyright (c) 2013, Red Hat, Inc. - Copyright (c) 2008 - 2012, Intel Corporation. All rights reserved.
- This program and the accompanying materials are - licensed and made available under the terms and conditions of the BSD License - which accompanies this distribution. The full text of the license may be found at - http://opensource.org/licenses/bsd-license.php - - THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, - WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. - -**/ - -#include "Platform.h" - -EFI_ACPI_2_0_FIXED_ACPI_DESCRIPTION_TABLE FACP = { - { - EFI_ACPI_2_0_FIXED_ACPI_DESCRIPTION_TABLE_SIGNATURE, - sizeof (EFI_ACPI_2_0_FIXED_ACPI_DESCRIPTION_TABLE), - EFI_ACPI_2_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 - RESERVED, // System Interrupt Model in ACPI 1.0, eliminated in 2.0 - EFI_ACPI_2_0_PM_PROFILE_UNSPECIFIED, // Preferred PM profile - SCI_INT_VECTOR, // System vector of SCI interrupt - SMI_CMD_IO_PORT, // Port address of SMI command port - ACPI_ENABLE, // value to write to port smi_cmd to enable ACPI - ACPI_DISABLE, // value to write to port smi_cmd to disable ACPI - S4BIOS_REQ, // Value to write to SMI CMD port to enter the S4BIOS state - 0, // PState control - PM1a_EVT_BLK, // Port address of Power Mgt 1a Event Reg Blk - 0, // Power Mgt 1b Event Reg Blk unsupported - PM1a_CNT_BLK, // Port address of Power Mgt 1a Ctrl Reg Blk - 0, // Power Mgt 1b Ctrl Reg Blk unsupported - 0, // Power Mgt 2 Ctrl Reg Blk unsupported - PM_TMR_BLK, // Port address of Power Mgt Timer Ctrl Reg Blk - GPE0_BLK, // Port addr of General Purpose Event 0 Reg Blk - 0, // General Purpose Event 1 Reg Blk unsupported - PM1_EVT_LEN, // Byte Length of ports at pm1X_evt_blk - PM1_CNT_LEN, // Byte Length of ports at pm1X_cnt_blk - 0, // Power Mgt 2 Ctrl Reg Blk unsupported - PM_TM_LEN, // Byte Length of ports at pm_tm_blk - GPE0_BLK_LEN, // Byte Length of ports at gpe0_blk - 0, // General Purpose Event 1 Reg Blk unsupported - 0, // General Purpose Event 1 Reg Blk unsupported - 0, // _CST support - P_LVL2_LAT, // worst case HW latency to enter/exit C2 state - P_LVL3_LAT, // worst case HW latency to enter/exit C3 state - FLUSH_SIZE, // Size of area read to flush caches - FLUSH_STRIDE, // Stride used in flushing caches - DUTY_OFFSET, // bit location of duty cycle field in p_cnt reg - DUTY_WIDTH, // bit width of duty cycle field in p_cnt reg - DAY_ALRM, // index to day-of-month alarm in RTC CMOS RAM - MON_ALRM, // index to month-of-year alarm in RTC CMOS RAM - CENTURY, // index to century in RTC CMOS RAM - 0x0000, // Boot architecture flag (16-bit) - RESERVED, // reserved - FLAG, // Fixed feature flags - GAS2_IO(RESET_REG, 1), // Extended address of the Reset Register - RESET_VALUE, // Value for the Reset Register to reset the system - { RESERVED }, // reserved[3] - 0, // 64-bit physical addesss of FACS, set at installation - 0, // 64-bit physical addesss of DSDT, set at installation - - GAS2_IO(PM1a_EVT_BLK, PM1_EVT_LEN), // Ext. addr. of PM 1a Event Reg Blk - { 0 }, // PM 1b Event Reg Blk unsupported - GAS2_IO(PM1a_CNT_BLK, PM1_CNT_LEN), // Ext. addr. of PM 1a Ctrl Reg Blk - { 0 }, // PM 1b Ctrl Reg Blk unsupported - { 0 }, // PM 2 Ctrl Reg Blk unsupported - GAS2_IO(PM_TMR_BLK, PM_TM_LEN), // Ext. addr. of PM Timer Ctrl Reg Blk - GAS2_IO(GPE0_BLK, GPE0_BLK_LEN), // Ext. addr. of GPE 0 Reg Blk - { 0 } // GPE 1 Reg Blk unsupported -}; - - -VOID* -ReferenceAcpiTable ( - VOID - ) -{ - // - // Reference the table being generated to prevent the optimizer from removing the - // data structure from the exeutable - // - return (VOID*)&FACP; -} diff --git a/OvmfPkg/AcpiTables/Facs.aslc b/OvmfPkg/AcpiTables/Facs.aslc deleted file mode 100644 index 53bb0fcb86..0000000000 --- a/OvmfPkg/AcpiTables/Facs.aslc +++ /dev/null @@ -1,84 +0,0 @@ -/** @file - FACS Table - - Copyright (c) 2008 - 2012, Intel Corporation. All rights reserved.
- This program and the accompanying materials are - licensed and made available under the terms and conditions of the BSD License - which accompanies this distribution. The full text of the license may be found at - http://opensource.org/licenses/bsd-license.php - - THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, - WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. - -**/ - -#include - -EFI_ACPI_1_0_FIRMWARE_ACPI_CONTROL_STRUCTURE FACS = { - EFI_ACPI_1_0_FIRMWARE_ACPI_CONTROL_STRUCTURE_SIGNATURE, - sizeof (EFI_ACPI_1_0_FIRMWARE_ACPI_CONTROL_STRUCTURE), - - // - // Hardware Signature will be updated at runtime - // - 0x00000000, - 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 - } -}; - - -VOID* -ReferenceAcpiTable ( - VOID - ) -{ - // - // Reference the table being generated to prevent the optimizer from removing the - // data structure from the exeutable - // - return (VOID*)&FACS; -} - diff --git a/OvmfPkg/AcpiTables/Madt.aslc b/OvmfPkg/AcpiTables/Madt.aslc deleted file mode 100644 index 8a3b836bcd..0000000000 --- a/OvmfPkg/AcpiTables/Madt.aslc +++ /dev/null @@ -1,159 +0,0 @@ -/** @file - MADT Table - - This file contains a structure definition for the ACPI 1.0 Multiple APIC - Description Table (MADT). - - Copyright (c) 2008 - 2012, Intel Corporation. All rights reserved.
- This program and the accompanying materials are - licensed and made available under the terms and conditions of the BSD License - which accompanies this distribution. The full text of the license may be found at - http://opensource.org/licenses/bsd-license.php - - THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, - WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. - -**/ - -#include -#include - -// -// Local APIC address -// -#define EFI_ACPI_LOCAL_APIC_ADDRESS 0xFEE00000 // TBD - -// -// Multiple APIC Flags are defined in AcpiX.0.h -// -#define EFI_ACPI_1_0_MULTIPLE_APIC_FLAGS (EFI_ACPI_1_0_PCAT_COMPAT) - -// -// Define the number of each table type. -// This is where the table layout is modified. -// -#define EFI_ACPI_PROCESSOR_LOCAL_APIC_COUNT 1 -#define EFI_ACPI_INTERRUPT_SOURCE_OVERRIDE_COUNT 2 -#define EFI_ACPI_IO_APIC_COUNT 1 - -// -// Ensure proper structure formats -// -#pragma pack (1) - -// -// ACPI 1.0 MADT structure -// -typedef struct { - EFI_ACPI_1_0_MULTIPLE_APIC_DESCRIPTION_TABLE_HEADER Header; - -#if EFI_ACPI_PROCESSOR_LOCAL_APIC_COUNT > 0 - EFI_ACPI_1_0_PROCESSOR_LOCAL_APIC_STRUCTURE LocalApic[EFI_ACPI_PROCESSOR_LOCAL_APIC_COUNT]; -#endif - -#if EFI_ACPI_INTERRUPT_SOURCE_OVERRIDE_COUNT > 0 - EFI_ACPI_1_0_INTERRUPT_SOURCE_OVERRIDE_STRUCTURE Iso[EFI_ACPI_INTERRUPT_SOURCE_OVERRIDE_COUNT]; -#endif - -#if EFI_ACPI_IO_APIC_COUNT > 0 - EFI_ACPI_1_0_IO_APIC_STRUCTURE IoApic[EFI_ACPI_IO_APIC_COUNT]; -#endif - -} EFI_ACPI_1_0_MULTIPLE_APIC_DESCRIPTION_TABLE; - -#pragma pack () - -// -// 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, - }, - - // - // 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 - } - }, - - // - // 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 - } - }, - - // - // 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 - } - }, -}; - - -VOID* -ReferenceAcpiTable ( - VOID - ) -{ - // - // Reference the table being generated to prevent the optimizer from removing the - // data structure from the exeutable - // - return (VOID*)&Madt; -} diff --git a/OvmfPkg/AcpiTables/Platform.h b/OvmfPkg/AcpiTables/Platform.h deleted file mode 100644 index d96b847239..0000000000 --- a/OvmfPkg/AcpiTables/Platform.h +++ /dev/null @@ -1,74 +0,0 @@ -/** @file - Platform specific defines for constructing ACPI tables - - Copyright (c) 2012, 2013, Red Hat, Inc. - Copyright (c) 2008, Intel Corporation. All rights reserved.
- This program and the accompanying materials are - licensed and made available under the terms and conditions of the BSD License - which accompanies this distribution. The full text of the license may be found at - http://opensource.org/licenses/bsd-license.php - - THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, - WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. - -**/ - -#ifndef _Platform_h_INCLUDED_ -#define _Platform_h_INCLUDED_ - -#include -#include - -// -// ACPI table information used to initialize tables. -// -#define EFI_ACPI_OEM_ID 'O','V','M','F',' ',' ' // OEMID 6 bytes long -#define EFI_ACPI_OEM_TABLE_ID SIGNATURE_64('O','V','M','F','E','D','K','2') // OEM table id 8 bytes long -#define EFI_ACPI_OEM_REVISION 0x20130221 -#define EFI_ACPI_CREATOR_ID SIGNATURE_32('O','V','M','F') -#define EFI_ACPI_CREATOR_REVISION 0x00000099 - -#define SCI_INT_VECTOR 0x0009 -#define SMI_CMD_IO_PORT 0xB2 -#define ACPI_ENABLE 0xF1 -#define ACPI_DISABLE 0xF0 -#define S4BIOS_REQ 0x00 -#define PM1a_EVT_BLK 0x0000b000 -#define PM1a_CNT_BLK 0x0000b004 -#define PM_TMR_BLK 0x0000b008 -#define GPE0_BLK 0x0000afe0 -#define PM1_EVT_LEN 0x04 -#define PM1_CNT_LEN 0x02 -#define PM_TM_LEN 0x04 -#define GPE0_BLK_LEN 0x04 -#define RESERVED 0x00 -#define P_LVL2_LAT 0x0065 -#define P_LVL3_LAT 0x03E9 -#define FLUSH_SIZE 0x0000 -#define FLUSH_STRIDE 0x0000 -#define DUTY_OFFSET 0x00 -#define DUTY_WIDTH 0x00 -#define DAY_ALRM 0x00 -#define MON_ALRM 0x00 -#define CENTURY 0x00 -#define FLAG (EFI_ACPI_2_0_WBINVD | \ - EFI_ACPI_2_0_PROC_C1 | \ - EFI_ACPI_2_0_SLP_BUTTON | \ - EFI_ACPI_2_0_RTC_S4 | \ - EFI_ACPI_2_0_RESET_REG_SUP) -#define RESET_REG 0xCF9 -#define RESET_VALUE (BIT2 | BIT1) // PIIX3 Reset CPU + System Reset - -// -// Byte-aligned IO port register block initializer for -// EFI_ACPI_2_0_GENERIC_ADDRESS_STRUCTURE -// -#define GAS2_IO(Base, Size) { \ - EFI_ACPI_2_0_SYSTEM_IO, /* AddressSpaceId */ \ - (Size) * 8, /* RegisterBitWidth */ \ - 0, /* RegisterBitOffset */ \ - 0, /* Reserved */ \ - (Base) /* Address */ \ - } - -#endif diff --git a/OvmfPkg/AcpiTables/Ssdt.asl b/OvmfPkg/AcpiTables/Ssdt.asl deleted file mode 100644 index 67c5fdb3a4..0000000000 --- a/OvmfPkg/AcpiTables/Ssdt.asl +++ /dev/null @@ -1,19 +0,0 @@ -/** @file - Placeholder for runtime-generated objects. - - This empty table provides only a header for dynamic copying and extension, - and a trigger for QemuInstallAcpiSsdtTable(). - - 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. -**/ - -DefinitionBlock ("Ssdt.aml", "SSDT", 1, "REDHAT", "OVMF ", 1) { -} diff --git a/OvmfPkg/BlockMmioToBlockIoDxe/BlockIo.c b/OvmfPkg/BlockMmioToBlockIoDxe/BlockIo.c deleted file mode 100644 index 939792f2ad..0000000000 --- a/OvmfPkg/BlockMmioToBlockIoDxe/BlockIo.c +++ /dev/null @@ -1,528 +0,0 @@ -/** @file - The driver wrappers BlockMmio protocol instances to produce - Block I/O Protocol instances. - - Copyright (c) 2007 - 2012, Intel Corporation. All rights reserved.
- This program and the accompanying materials - are licensed and made available under the terms and conditions of the BSD License - which accompanies this distribution. The full text of the license may be found at - http://opensource.org/licenses/bsd-license.php - - THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, - WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. - -**/ - -#include "BlockIo.h" - -EFI_DRIVER_BINDING_PROTOCOL gBlockIoDriverBinding = { - BlockIoDriverBindingSupported, - BlockIoDriverBindingStart, - BlockIoDriverBindingStop, - 0x11, - NULL, - NULL -}; - -/** - Reset the block device. - - This function implements EFI_BLOCK_IO_PROTOCOL.Reset(). - It resets the block device hardware. - ExtendedVerification is ignored in this implementation. - - @param This Indicates a pointer to the calling context. - @param ExtendedVerification Indicates that the driver may perform a more exhaustive - verification operation of the device during reset. - - @retval EFI_SUCCESS The block device was reset. - @retval EFI_DEVICE_ERROR The block device is not functioning correctly and could not be reset. - -**/ -EFI_STATUS -EFIAPI -BlockIoReset ( - IN EFI_BLOCK_IO_PROTOCOL *This, - IN BOOLEAN ExtendedVerification - ) -{ - return EFI_SUCCESS; -} - -/** - Reads the requested number of blocks from the device. - - This function implements EFI_BLOCK_IO_PROTOCOL.ReadBlocks(). - It reads the requested number of blocks from the device. - All the blocks are read, or an error is returned. - - @param This Indicates a pointer to the calling context. - @param ReadData If TRUE then read data. If FALSE then write data. - @param MediaId The media ID that the read request is for. - @param Lba The starting logical block address to read from on the device. - @param BufferSize The size of the Buffer in bytes. - This must be a multiple of the intrinsic block size of the device. - @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 attempting to perform the read operation. - @retval EFI_NO_MEDIA There is no media in the device. - @retval EFI_MEDIA_CHANGED The MediaId is not for the current media. - @retval EFI_BAD_BUFFER_SIZE The BufferSize parameter is not a multiple of the intrinsic 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 -EFIAPI -ReadOrWriteBlocks ( - IN EFI_BLOCK_IO_PROTOCOL *This, - IN BOOLEAN ReadData, - IN UINT32 MediaId, - IN EFI_LBA Lba, - IN UINTN BufferSize, - OUT VOID *Buffer - ) -{ - EFI_STATUS Status; - BLOCK_MMIO_TO_BLOCK_IO_DEVICE *Private; - UINTN TotalBlock; - EFI_BLOCK_IO_MEDIA *Media; - UINT64 Address; - UINTN Count; - EFI_CPU_IO_PROTOCOL_IO_MEM CpuAccessFunction; - - // - // First, validate the parameters - // - if ((Buffer == NULL) || (BufferSize == 0)) { - return EFI_INVALID_PARAMETER; - } - - // - // Get private data structure - // - Private = PRIVATE_FROM_BLOCK_IO (This); - Media = Private->BlockMmio->Media; - - // - // BufferSize must be a multiple of the intrinsic block size of the device. - // - if (ModU64x32 (BufferSize, Media->BlockSize) != 0) { - return EFI_BAD_BUFFER_SIZE; - } - - TotalBlock = (UINTN) DivU64x32 (BufferSize, Media->BlockSize); - - // - // Make sure the range to read is valid. - // - if (Lba + TotalBlock - 1 > Media->LastBlock) { - return EFI_INVALID_PARAMETER; - } - - if (!(Media->MediaPresent)) { - return EFI_NO_MEDIA; - } - - if (MediaId != Media->MediaId) { - return EFI_MEDIA_CHANGED; - } - - Address = Private->BlockMmio->BaseAddress; - Address += MultU64x32 (Lba, Media->BlockSize); - - Count = BufferSize >> 3; - - if (ReadData) { - CpuAccessFunction = Private->CpuIo->Mem.Read; - } else { - CpuAccessFunction = Private->CpuIo->Mem.Write; - } - - Status = (CpuAccessFunction) ( - Private->CpuIo, - EfiCpuIoWidthUint64, - Address, - Count, - Buffer - ); - - return Status; -} - - -/** - Reads the requested number of blocks from the device. - - This function implements EFI_BLOCK_IO_PROTOCOL.ReadBlocks(). - It reads the requested number of blocks from the device. - All the blocks are read, or an error is returned. - - @param This Indicates a pointer to the calling context. - @param MediaId The media ID that the read request is for. - @param Lba The starting logical block address to read from on the device. - @param BufferSize The size of the Buffer in bytes. - This must be a multiple of the intrinsic block size of the device. - @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 attempting to perform the read operation. - @retval EFI_NO_MEDIA There is no media in the device. - @retval EFI_MEDIA_CHANGED The MediaId is not for the current media. - @retval EFI_BAD_BUFFER_SIZE The BufferSize parameter is not a multiple of the intrinsic 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 -EFIAPI -BlockIoReadBlocks ( - IN EFI_BLOCK_IO_PROTOCOL *This, - IN UINT32 MediaId, - IN EFI_LBA Lba, - IN UINTN BufferSize, - OUT VOID *Buffer - ) -{ - DEBUG ((EFI_D_INFO, "BlockIo (MMIO) ReadBlocks: lba=0x%Lx, size=0x%Lx\n", - Lba, (UINT64)BufferSize)); - return ReadOrWriteBlocks ( - This, - TRUE, - MediaId, - Lba, - BufferSize, - Buffer - ); -} - - -/** - Writes a specified number of blocks to the device. - - This function implements EFI_BLOCK_IO_PROTOCOL.WriteBlocks(). - It writes a specified number of blocks to the device. - All blocks are written, or an error is returned. - - @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. - @param BufferSize The size of the Buffer in bytes. - This must be a multiple of the intrinsic block size of the device. - @param Buffer Pointer to the source buffer for the data. - - @retval EFI_SUCCESS The data were written correctly to the device. - @retval EFI_WRITE_PROTECTED The device cannot be written to. - @retval EFI_NO_MEDIA There is no media in the device. - @retval EFI_MEDIA_CHANGED The MediaId is not for the current media. - @retval EFI_DEVICE_ERROR The device reported an error while attempting to perform the write operation. - @retval EFI_BAD_BUFFER_SIZE The BufferSize parameter is not a multiple of the intrinsic - 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 -BlockIoWriteBlocks ( - IN EFI_BLOCK_IO_PROTOCOL *This, - IN UINT32 MediaId, - IN EFI_LBA Lba, - IN UINTN BufferSize, - IN VOID *Buffer - ) -{ - DEBUG ((EFI_D_INFO, "BlockIo (MMIO) WriteBlocks: lba=0x%Lx, size=0x%Lx\n", - Lba, (UINT64)BufferSize)); - return ReadOrWriteBlocks ( - This, - FALSE, - MediaId, - Lba, - BufferSize, - Buffer - ); -} - -/** - Flushes all modified data to a physical block device. - - @param This Indicates a pointer to the calling context. - - @retval EFI_SUCCESS All outstanding data were written correctly to the device. - @retval EFI_DEVICE_ERROR The device reported an error while attempting to write data. - @retval EFI_NO_MEDIA There is no media in the device. - -**/ -EFI_STATUS -EFIAPI -BlockIoFlushBlocks ( - IN EFI_BLOCK_IO_PROTOCOL *This - ) -{ - return EFI_SUCCESS; -} - - -/** - Initialize data for device that does not support multiple LUNSs. - - @param This The Driver Binding Protocol instance. - @param Controller The device to initialize. - @param BlockMmio Pointer to USB_MASS_TRANSPORT. - @param Context Parameter for USB_MASS_DEVICE.Context. - - @retval EFI_SUCCESS Initialization succeeds. - @retval Other Initialization fails. - -**/ -EFI_STATUS -BlockIoInit ( - IN EFI_DRIVER_BINDING_PROTOCOL *This, - IN EFI_HANDLE Controller - ) -{ - EFI_STATUS Status; - BLOCK_MMIO_TO_BLOCK_IO_DEVICE *Private; - BLOCK_MMIO_PROTOCOL *BlockMmio; - - Private = (BLOCK_MMIO_TO_BLOCK_IO_DEVICE*) AllocateZeroPool (sizeof (*Private)); - ASSERT (Private != NULL); - - Status = gBS->LocateProtocol ( - &gEfiCpuIo2ProtocolGuid, - NULL, - (VOID **) &(Private->CpuIo) - ); - ASSERT_EFI_ERROR (Status); - - Status = gBS->OpenProtocol ( - Controller, - &gBlockMmioProtocolGuid, - (VOID **) &BlockMmio, - This->DriverBindingHandle, - Controller, - EFI_OPEN_PROTOCOL_BY_DRIVER - ); - if (EFI_ERROR (Status)) { - DEBUG ((EFI_D_ERROR, "BlockIoInit: OpenBlockMmioProtocol By Driver (%r)\n", Status)); - goto ON_ERROR; - } - DEBUG ((EFI_D_INFO, "BlockMmio: %p\n", BlockMmio)); - DEBUG ((EFI_D_INFO, "BlockMmio->Media->LastBlock: 0x%lx\n", BlockMmio->Media->LastBlock)); - - Private->Signature = BLOCK_MMIO_TO_BLOCK_IO_SIGNATURE; - Private->Controller = Controller; - Private->BlockMmio = BlockMmio; - Private->BlockIo.Media = BlockMmio->Media; - Private->BlockIo.Reset = BlockIoReset; - Private->BlockIo.ReadBlocks = BlockIoReadBlocks; - Private->BlockIo.WriteBlocks = BlockIoWriteBlocks; - Private->BlockIo.FlushBlocks = BlockIoFlushBlocks; - - DEBUG ((EFI_D_INFO, "Private->BlockIo.Media->LastBlock: 0x%lx\n", Private->BlockIo.Media->LastBlock)); - - Status = gBS->InstallProtocolInterface ( - &Controller, - &gEfiBlockIoProtocolGuid, - EFI_NATIVE_INTERFACE, - &Private->BlockIo - ); - if (EFI_ERROR (Status)) { - goto ON_ERROR; - } - - return EFI_SUCCESS; - -ON_ERROR: - if (Private != NULL) { - FreePool (Private); - } - if (BlockMmio != NULL) { - gBS->CloseProtocol ( - Controller, - &gBlockMmioProtocolGuid, - This->DriverBindingHandle, - Controller - ); - } - return Status; -} - - -/** - Check whether the controller is a supported USB mass storage. - - @param This The USB mass storage driver binding protocol. - @param Controller The controller handle to check. - @param RemainingDevicePath The remaining device path. - - @retval EFI_SUCCESS The driver supports this controller. - @retval other This device isn't supported. - -**/ -EFI_STATUS -EFIAPI -BlockIoDriverBindingSupported ( - IN EFI_DRIVER_BINDING_PROTOCOL *This, - IN EFI_HANDLE Controller, - IN EFI_DEVICE_PATH_PROTOCOL *RemainingDevicePath - ) -{ - EFI_STATUS Status; - BLOCK_MMIO_PROTOCOL *BlockMmio; - - Status = gBS->OpenProtocol ( - Controller, - &gBlockMmioProtocolGuid, - (VOID **) &BlockMmio, - This->DriverBindingHandle, - Controller, - EFI_OPEN_PROTOCOL_BY_DRIVER - ); - if (EFI_ERROR (Status)) { - return Status; - } - - gBS->CloseProtocol ( - Controller, - &gBlockMmioProtocolGuid, - This->DriverBindingHandle, - Controller - ); - - return Status; -} - -/** - Starts the USB mass storage device with this driver. - - This function consumes USB I/O Portocol, intializes USB mass storage device, - installs Block I/O Protocol, and submits Asynchronous Interrupt - Transfer to manage the USB mass storage device. - - @param This The USB mass storage driver binding protocol. - @param Controller The USB mass storage device to start on - @param RemainingDevicePath The remaining device path. - - @retval EFI_SUCCESS This driver supports this device. - @retval EFI_UNSUPPORTED This driver does not support this device. - @retval EFI_DEVICE_ERROR This driver cannot be started due to device Error. - @retval EFI_OUT_OF_RESOURCES Can't allocate memory resources. - @retval EFI_ALREADY_STARTED This driver has been started. - -**/ -EFI_STATUS -EFIAPI -BlockIoDriverBindingStart ( - IN EFI_DRIVER_BINDING_PROTOCOL *This, - IN EFI_HANDLE Controller, - IN EFI_DEVICE_PATH_PROTOCOL *RemainingDevicePath - ) -{ - EFI_STATUS Status; - - Status = BlockIoInit (This, Controller); - if (EFI_ERROR (Status)) { - DEBUG ((EFI_D_ERROR, "BlockIoDriverBindingStart: BlockIoInit (%r)\n", Status)); - return Status; - } - - DEBUG ((EFI_D_INIT, "BlockIoDriverBindingStart: Successfully started\n")); - return Status; -} - - -/** - Stop controlling the device. - - @param This The USB mass storage driver binding - @param Controller The device controller controlled by the driver. - @param NumberOfChildren The number of children of this device - @param ChildHandleBuffer The buffer of children handle. - - @retval EFI_SUCCESS The driver stopped from controlling the device. - @retval EFI_DEVICE_ERROR The device could not be stopped due to a device error. - @retval EFI_UNSUPPORTED Block I/O Protocol is not installed on Controller. - @retval Others Failed to stop the driver - -**/ -EFI_STATUS -EFIAPI -BlockIoDriverBindingStop ( - IN EFI_DRIVER_BINDING_PROTOCOL *This, - IN EFI_HANDLE Controller, - IN UINTN NumberOfChildren, - IN EFI_HANDLE *ChildHandleBuffer - ) -{ - EFI_STATUS Status; - BLOCK_MMIO_TO_BLOCK_IO_DEVICE *Private; - - Private = PRIVATE_FROM_BLOCK_IO (This); - - // - // Uninstall Block I/O protocol from the device handle, - // then call the transport protocol to stop itself. - // - Status = gBS->UninstallProtocolInterface ( - Controller, - &gEfiBlockIoProtocolGuid, - &Private->BlockIo - ); - if (EFI_ERROR (Status)) { - return Status; - } - - gBS->CloseProtocol ( - Controller, - &gBlockMmioProtocolGuid, - This->DriverBindingHandle, - Controller - ); - - FreePool (Private); - - DEBUG ((EFI_D_INFO, "Successfully stopped BlockIo on BlockMmio\n")); - return EFI_SUCCESS; -} - -/** - Entrypoint of Block MMIO to Block IO Driver. - - This function is the entrypoint of USB Mass Storage Driver. It installs Driver Binding - Protocol together with Component Name Protocols. - - @param ImageHandle The firmware allocated handle for the EFI image. - @param SystemTable A pointer to the EFI System Table. - - @retval EFI_SUCCESS The entry point is executed successfully. - -**/ -EFI_STATUS -EFIAPI -BlockMmioToBlockIoEntryPoint ( - IN EFI_HANDLE ImageHandle, - IN EFI_SYSTEM_TABLE *SystemTable - ) -{ - EFI_STATUS Status; - - // - // Install driver binding protocol - // - Status = EfiLibInstallDriverBindingComponentName2 ( - ImageHandle, - SystemTable, - &gBlockIoDriverBinding, - ImageHandle, - &gBlockMmioToBlockIoComponentName, - &gBlockMmioToBlockIoComponentName2 - ); - ASSERT_EFI_ERROR (Status); - - return EFI_SUCCESS; -} diff --git a/OvmfPkg/BlockMmioToBlockIoDxe/BlockIo.h b/OvmfPkg/BlockMmioToBlockIoDxe/BlockIo.h deleted file mode 100644 index d33f56448a..0000000000 --- a/OvmfPkg/BlockMmioToBlockIoDxe/BlockIo.h +++ /dev/null @@ -1,346 +0,0 @@ -/** @file - Definitions of functions for Driver Binding Protocol and Block I/O Protocol, - and other internal definitions. - - Copyright (c) 2007 - 2010, Intel Corporation. All rights reserved.
- This program and the accompanying materials - are licensed and made available under the terms and conditions of the BSD License - which accompanies this distribution. The full text of the license may be found at - http://opensource.org/licenses/bsd-license.php - - THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, - WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. - -**/ - -#ifndef _EFI_BLOCK_MMIO_TO_BLOCK_IO_H_ -#define _EFI_BLOCK_MMIO_TO_BLOCK_IO_H_ - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#define BLOCK_MMIO_TO_BLOCK_IO_SIGNATURE SIGNATURE_32 ('B', 'M', 'I', 'O') - -#define PRIVATE_FROM_BLOCK_IO(a) \ - CR (a, BLOCK_MMIO_TO_BLOCK_IO_DEVICE, BlockIo, BLOCK_MMIO_TO_BLOCK_IO_SIGNATURE) - -extern EFI_COMPONENT_NAME_PROTOCOL gBlockMmioToBlockIoComponentName; -extern EFI_COMPONENT_NAME2_PROTOCOL gBlockMmioToBlockIoComponentName2; - -typedef struct { - UINT32 Signature; - EFI_HANDLE Controller; - BLOCK_MMIO_PROTOCOL *BlockMmio; - EFI_CPU_IO2_PROTOCOL *CpuIo; - EFI_DEVICE_PATH_PROTOCOL *DevicePath; - EFI_BLOCK_IO_PROTOCOL BlockIo; -} BLOCK_MMIO_TO_BLOCK_IO_DEVICE; - -// -// Functions for Driver Binding Protocol -// - -/** - Check whether the controller is a supported. - - @param This The driver binding protocol. - @param Controller The controller handle to check. - @param RemainingDevicePath The remaining device path. - - @retval EFI_SUCCESS The driver supports this controller. - @retval other This device isn't supported. - -**/ -EFI_STATUS -EFIAPI -BlockIoDriverBindingSupported ( - IN EFI_DRIVER_BINDING_PROTOCOL *This, - IN EFI_HANDLE Controller, - IN EFI_DEVICE_PATH_PROTOCOL *RemainingDevicePath - ); - -/** - Starts the BlockIo device with this driver. - - This function consumes Block MMIO Portocol and - installs Block I/O Protocol. - - @param This The driver binding protocol. - @param Controller The Block MMIO device to start on - @param RemainingDevicePath The remaining device path. - - @retval EFI_SUCCESS This driver supports this device. - @retval EFI_UNSUPPORTED This driver does not support this device. - @retval EFI_DEVICE_ERROR This driver cannot be started due to device Error. - @retval EFI_OUT_OF_RESOURCES Can't allocate memory resources. - @retval EFI_ALREADY_STARTED This driver has been started. - -**/ -EFI_STATUS -EFIAPI -BlockIoDriverBindingStart ( - IN EFI_DRIVER_BINDING_PROTOCOL *This, - IN EFI_HANDLE Controller, - IN EFI_DEVICE_PATH_PROTOCOL *RemainingDevicePath - ); - -/** - Stop controlling the device. - - @param This The driver binding - @param Controller The device controller controlled by the driver. - @param NumberOfChildren The number of children of this device - @param ChildHandleBuffer The buffer of children handle. - - @retval EFI_SUCCESS The driver stopped from controlling the device. - @retval EFI_DEVICE_ERROR The device could not be stopped due to a device error. - @retval EFI_UNSUPPORTED Block I/O Protocol is not installed on Controller. - @retval Others Failed to stop the driver - -**/ -EFI_STATUS -EFIAPI -BlockIoDriverBindingStop ( - IN EFI_DRIVER_BINDING_PROTOCOL *This, - IN EFI_HANDLE Controller, - IN UINTN NumberOfChildren, - IN EFI_HANDLE *ChildHandleBuffer - ); - -// -// Functions for Block I/O Protocol -// - -/** - Reset the block device. - - This function implements EFI_BLOCK_IO_PROTOCOL.Reset(). - It resets the block device hardware. - ExtendedVerification is ignored in this implementation. - - @param This Indicates a pointer to the calling context. - @param ExtendedVerification Indicates that the driver may perform a more exhaustive - verification operation of the device during reset. - - @retval EFI_SUCCESS The block device was reset. - @retval EFI_DEVICE_ERROR The block device is not functioning correctly and could not be reset. - -**/ -EFI_STATUS -EFIAPI -BlockIoReset ( - IN EFI_BLOCK_IO_PROTOCOL *This, - IN BOOLEAN ExtendedVerification - ); - -/** - Reads the requested number of blocks from the device. - - This function implements EFI_BLOCK_IO_PROTOCOL.ReadBlocks(). - It reads the requested number of blocks from the device. - All the blocks are read, or an error is returned. - - @param This Indicates a pointer to the calling context. - @param MediaId The media ID that the read request is for. - @param Lba The starting logical block address to read from on the device. - @param BufferSize The size of the Buffer in bytes. - This must be a multiple of the intrinsic block size of the device. - @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 attempting to perform the read operation. - @retval EFI_NO_MEDIA There is no media in the device. - @retval EFI_MEDIA_CHANGED The MediaId is not for the current media. - @retval EFI_BAD_BUFFER_SIZE The BufferSize parameter is not a multiple of the intrinsic 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 -EFIAPI -BlockIoReadBlocks ( - IN EFI_BLOCK_IO_PROTOCOL *This, - IN UINT32 MediaId, - IN EFI_LBA Lba, - IN UINTN BufferSize, - OUT VOID *Buffer - ); - -/** - Writes a specified number of blocks to the device. - - This function implements EFI_BLOCK_IO_PROTOCOL.WriteBlocks(). - It writes a specified number of blocks to the device. - All blocks are written, or an error is returned. - - @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. - @param BufferSize The size of the Buffer in bytes. - This must be a multiple of the intrinsic block size of the device. - @param Buffer Pointer to the source buffer for the data. - - @retval EFI_SUCCESS The data were written correctly to the device. - @retval EFI_WRITE_PROTECTED The device cannot be written to. - @retval EFI_NO_MEDIA There is no media in the device. - @retval EFI_MEDIA_CHANGED The MediaId is not for the current media. - @retval EFI_DEVICE_ERROR The device reported an error while attempting to perform the write operation. - @retval EFI_BAD_BUFFER_SIZE The BufferSize parameter is not a multiple of the intrinsic - 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 -BlockIoWriteBlocks ( - IN EFI_BLOCK_IO_PROTOCOL *This, - IN UINT32 MediaId, - IN EFI_LBA Lba, - IN UINTN BufferSize, - IN VOID *Buffer - ); - -/** - Flushes all modified data to a physical block device. - - @param This Indicates a pointer to the calling context. - - @retval EFI_SUCCESS All outstanding data were written correctly to the device. - @retval EFI_DEVICE_ERROR The device reported an error while attempting to write data. - @retval EFI_NO_MEDIA There is no media in the device. - -**/ -EFI_STATUS -EFIAPI -BlockIoFlushBlocks ( - IN EFI_BLOCK_IO_PROTOCOL *This - ); - -// -// EFI Component Name Functions -// - -/** - Retrieves a Unicode string that is the user readable name of the driver. - - This function retrieves the user readable name of a driver in the form of a - Unicode string. If the driver specified by This has a user readable name in - the language specified by Language, then a pointer to the driver name is - returned in DriverName, and EFI_SUCCESS is returned. If the driver specified - by This does not support the language specified by Language, - then EFI_UNSUPPORTED is returned. - - @param This A pointer to the EFI_COMPONENT_NAME2_PROTOCOL or - EFI_COMPONENT_NAME_PROTOCOL instance. - @param Language A pointer to a Null-terminated ASCII string - array indicating the language. This is the - language of the driver name that the caller is - requesting, and it must match one of the - languages specified in SupportedLanguages. The - number of languages supported by a driver is up - to the driver writer. Language is specified - in RFC 4646 or ISO 639-2 language code format. - @param DriverName A pointer to the Unicode string to return. - This Unicode string is the name of the - driver specified by This in the language - specified by Language. - - @retval EFI_SUCCESS The Unicode string for the Driver specified by - This and the language specified by Language was - returned in DriverName. - @retval EFI_INVALID_PARAMETER Language is NULL. - @retval EFI_INVALID_PARAMETER DriverName is NULL. - @retval EFI_UNSUPPORTED The driver specified by This does not support - the language specified by Language. - -**/ -EFI_STATUS -EFIAPI -BlockMmioToBlockIoGetDriverName ( - IN EFI_COMPONENT_NAME_PROTOCOL *This, - IN CHAR8 *Language, - OUT CHAR16 **DriverName - ); - - -/** - Retrieves a Unicode string that is the user readable name of the controller - that is being managed by a driver. - - This function retrieves the user readable name of the controller specified by - ControllerHandle and ChildHandle in the form of a Unicode string. If the - driver specified by This has a user readable name in the language specified by - Language, then a pointer to the controller name is returned in ControllerName, - and EFI_SUCCESS is returned. If the driver specified by This is not currently - managing the controller specified by ControllerHandle and ChildHandle, - then EFI_UNSUPPORTED is returned. If the driver specified by This does not - support the language specified by Language, then EFI_UNSUPPORTED is returned. - - @param This A pointer to the EFI_COMPONENT_NAME2_PROTOCOL or - EFI_COMPONENT_NAME_PROTOCOL instance. - @param ControllerHandle The handle of a controller that the driver - specified by This is managing. This handle - specifies the controller whose name is to be - returned. - @param ChildHandle The handle of the child controller to retrieve - the name of. This is an optional parameter that - may be NULL. It will be NULL for device - drivers. It will also be NULL for a bus drivers - that wish to retrieve the name of the bus - controller. It will not be NULL for a bus - driver that wishes to retrieve the name of a - child controller. - @param Language A pointer to a Null-terminated ASCII string - array indicating the language. This is the - language of the driver name that the caller is - requesting, and it must match one of the - languages specified in SupportedLanguages. The - number of languages supported by a driver is up - to the driver writer. Language is specified in - RFC 4646 or ISO 639-2 language code format. - @param ControllerName A pointer to the Unicode string to return. - This Unicode string is the name of the - controller specified by ControllerHandle and - ChildHandle in the language specified by - Language from the point of view of the driver - specified by This. - - @retval EFI_SUCCESS The Unicode string for the user readable name in - the language specified by Language for the - driver specified by This was returned in - DriverName. - @retval EFI_INVALID_PARAMETER ControllerHandle is not a valid EFI_HANDLE. - @retval EFI_INVALID_PARAMETER ChildHandle is not NULL and it is not a valid - EFI_HANDLE. - @retval EFI_INVALID_PARAMETER Language is NULL. - @retval EFI_INVALID_PARAMETER ControllerName is NULL. - @retval EFI_UNSUPPORTED The driver specified by This is not currently - managing the controller specified by - ControllerHandle and ChildHandle. - @retval EFI_UNSUPPORTED The driver specified by This does not support - the language specified by Language. - -**/ -EFI_STATUS -EFIAPI -BlockMmioToBlockIoGetControllerName ( - IN EFI_COMPONENT_NAME_PROTOCOL *This, - IN EFI_HANDLE ControllerHandle, - IN EFI_HANDLE ChildHandle OPTIONAL, - IN CHAR8 *Language, - OUT CHAR16 **ControllerName - ); - -#endif diff --git a/OvmfPkg/BlockMmioToBlockIoDxe/BlockIo.inf b/OvmfPkg/BlockMmioToBlockIoDxe/BlockIo.inf deleted file mode 100644 index d4e8a0ab2d..0000000000 --- a/OvmfPkg/BlockMmioToBlockIoDxe/BlockIo.inf +++ /dev/null @@ -1,55 +0,0 @@ -## @file -# The driver wrappers BlockMmio protocol instances to produce -# Block I/O Protocol instances. -# -# Copyright (c) 2006 - 2010, Intel Corporation. All rights reserved.
-# -# This program and the accompanying materials -# are licensed and made available under the terms and conditions of the BSD License -# which accompanies this distribution. The full text of the license may be found at -# http://opensource.org/licenses/bsd-license.php -# -# THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, -# WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. -# -# -## - -[Defines] - INF_VERSION = 0x00010005 - BASE_NAME = BlockMmioToBlockIoDxe - FILE_GUID = 33cb97af-6c33-4c42-986b-07581fa366d4 - MODULE_TYPE = UEFI_DRIVER - VERSION_STRING = 1.0 - ENTRY_POINT = BlockMmioToBlockIoEntryPoint - -# -# The following information is for reference only and not required by the build tools. -# -# VALID_ARCHITECTURES = IA32 X64 IPF EBC -# - -[Sources] - BlockIo.c - ComponentName.c - -[Packages] - MdePkg/MdePkg.dec - OvmfPkg/OvmfPkg.dec - -[LibraryClasses] - BaseLib - BaseMemoryLib - DebugLib - DevicePathLib - MemoryAllocationLib - UefiBootServicesTableLib - UefiDriverEntryPoint - UefiLib - -[Protocols] - gBlockMmioProtocolGuid ## TO_START - gEfiCpuIo2ProtocolGuid ## TO_START - gEfiDevicePathProtocolGuid ## TO_START - gEfiBlockIoProtocolGuid ## BY_START - diff --git a/OvmfPkg/BlockMmioToBlockIoDxe/ComponentName.c b/OvmfPkg/BlockMmioToBlockIoDxe/ComponentName.c deleted file mode 100644 index 1baa9489d5..0000000000 --- a/OvmfPkg/BlockMmioToBlockIoDxe/ComponentName.c +++ /dev/null @@ -1,162 +0,0 @@ -/** @file - UEFI Component Name(2) protocol implementation for Block MMIO to Block IO driver. - - Copyright (c) 2004 - 2007, Intel Corporation. All rights reserved.
- This program and the accompanying materials - are licensed and made available under the terms and conditions of the BSD License - which accompanies this distribution. The full text of the license may be found at - http://opensource.org/licenses/bsd-license.php - - THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, - WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. - -**/ - -#include "BlockIo.h" - -// -// EFI Component Name Protocol -// -GLOBAL_REMOVE_IF_UNREFERENCED EFI_COMPONENT_NAME_PROTOCOL gBlockMmioToBlockIoComponentName = { - BlockMmioToBlockIoGetDriverName, - BlockMmioToBlockIoGetControllerName, - "eng" -}; - -// -// EFI Component Name 2 Protocol -// -GLOBAL_REMOVE_IF_UNREFERENCED EFI_COMPONENT_NAME2_PROTOCOL gBlockMmioToBlockIoComponentName2 = { - (EFI_COMPONENT_NAME2_GET_DRIVER_NAME) BlockMmioToBlockIoGetDriverName, - (EFI_COMPONENT_NAME2_GET_CONTROLLER_NAME) BlockMmioToBlockIoGetControllerName, - "en" -}; - - -GLOBAL_REMOVE_IF_UNREFERENCED EFI_UNICODE_STRING_TABLE -mBlockMmioToBlockIoDriverNameTable[] = { - {"eng;en", L"Block MMIO to Block IO Driver"}, - {NULL, NULL} -}; - -/** - Retrieves a Unicode string that is the user readable name of the driver. - - This function retrieves the user readable name of a driver in the form of a - Unicode string. If the driver specified by This has a user readable name in - the language specified by Language, then a pointer to the driver name is - returned in DriverName, and EFI_SUCCESS is returned. If the driver specified - by This does not support the language specified by Language, - then EFI_UNSUPPORTED is returned. - - @param This A pointer to the EFI_COMPONENT_NAME2_PROTOCOL or - EFI_COMPONENT_NAME_PROTOCOL instance. - @param Language A pointer to a Null-terminated ASCII string - array indicating the language. This is the - language of the driver name that the caller is - requesting, and it must match one of the - languages specified in SupportedLanguages. The - number of languages supported by a driver is up - to the driver writer. Language is specified - in RFC 4646 or ISO 639-2 language code format. - @param DriverName A pointer to the Unicode string to return. - This Unicode string is the name of the - driver specified by This in the language - specified by Language. - - @retval EFI_SUCCESS The Unicode string for the Driver specified by - This and the language specified by Language was - returned in DriverName. - @retval EFI_INVALID_PARAMETER Language is NULL. - @retval EFI_INVALID_PARAMETER DriverName is NULL. - @retval EFI_UNSUPPORTED The driver specified by This does not support - the language specified by Language. - -**/ -EFI_STATUS -EFIAPI -BlockMmioToBlockIoGetDriverName ( - IN EFI_COMPONENT_NAME_PROTOCOL *This, - IN CHAR8 *Language, - OUT CHAR16 **DriverName - ) -{ - return LookupUnicodeString2 ( - Language, - This->SupportedLanguages, - mBlockMmioToBlockIoDriverNameTable, - DriverName, - (BOOLEAN)(This == &gBlockMmioToBlockIoComponentName) - ); -} - -/** - Retrieves a Unicode string that is the user readable name of the controller - that is being managed by a driver. - - This function retrieves the user readable name of the controller specified by - ControllerHandle and ChildHandle in the form of a Unicode string. If the - driver specified by This has a user readable name in the language specified by - Language, then a pointer to the controller name is returned in ControllerName, - and EFI_SUCCESS is returned. If the driver specified by This is not currently - managing the controller specified by ControllerHandle and ChildHandle, - then EFI_UNSUPPORTED is returned. If the driver specified by This does not - support the language specified by Language, then EFI_UNSUPPORTED is returned. - - @param This A pointer to the EFI_COMPONENT_NAME2_PROTOCOL or - EFI_COMPONENT_NAME_PROTOCOL instance. - @param ControllerHandle The handle of a controller that the driver - specified by This is managing. This handle - specifies the controller whose name is to be - returned. - @param ChildHandle The handle of the child controller to retrieve - the name of. This is an optional parameter that - may be NULL. It will be NULL for device - drivers. It will also be NULL for a bus drivers - that wish to retrieve the name of the bus - controller. It will not be NULL for a bus - driver that wishes to retrieve the name of a - child controller. - @param Language A pointer to a Null-terminated ASCII string - array indicating the language. This is the - language of the driver name that the caller is - requesting, and it must match one of the - languages specified in SupportedLanguages. The - number of languages supported by a driver is up - to the driver writer. Language is specified in - RFC 4646 or ISO 639-2 language code format. - @param ControllerName A pointer to the Unicode string to return. - This Unicode string is the name of the - controller specified by ControllerHandle and - ChildHandle in the language specified by - Language from the point of view of the driver - specified by This. - - @retval EFI_SUCCESS The Unicode string for the user readable name in - the language specified by Language for the - driver specified by This was returned in - DriverName. - @retval EFI_INVALID_PARAMETER ControllerHandle is not a valid EFI_HANDLE. - @retval EFI_INVALID_PARAMETER ChildHandle is not NULL and it is not a valid - EFI_HANDLE. - @retval EFI_INVALID_PARAMETER Language is NULL. - @retval EFI_INVALID_PARAMETER ControllerName is NULL. - @retval EFI_UNSUPPORTED The driver specified by This is not currently - managing the controller specified by - ControllerHandle and ChildHandle. - @retval EFI_UNSUPPORTED The driver specified by This does not support - the language specified by Language. - -**/ -EFI_STATUS -EFIAPI -BlockMmioToBlockIoGetControllerName ( - IN EFI_COMPONENT_NAME_PROTOCOL *This, - IN EFI_HANDLE ControllerHandle, - IN EFI_HANDLE ChildHandle OPTIONAL, - IN CHAR8 *Language, - OUT CHAR16 **ControllerName - ) -{ - return EFI_UNSUPPORTED; -} diff --git a/OvmfPkg/Contributions.txt b/OvmfPkg/Contributions.txt deleted file mode 100644 index f87cbd73c6..0000000000 --- a/OvmfPkg/Contributions.txt +++ /dev/null @@ -1,218 +0,0 @@ - -====================== -= Code Contributions = -====================== - -To make a contribution to a TianoCore project, follow these steps. -1. Create a change description in the format specified below to - use in the source control commit log. -2. Your commit message must include your "Signed-off-by" signature, - and "Contributed-under" message. -3. Your "Contributed-under" message explicitly states that the - contribution is made under the terms of the specified - contribution agreement. Your "Contributed-under" message - must include the name of contribution agreement and version. - For example: Contributed-under: TianoCore Contribution Agreement 1.0 - The "TianoCore Contribution Agreement" is included below in - this document. -4. Submit your code to the TianoCore project using the process - that the project documents on its web page. If the process is - not documented, then submit the code on development email list - for the project. -5. It is preferred that contributions are submitted using the same - copyright license as the base project. When that is not possible, - then contributions using the following licenses can be accepted: - * BSD (2-clause): http://opensource.org/licenses/BSD-2-Clause - * BSD (3-clause): http://opensource.org/licenses/BSD-3-Clause - * MIT: http://opensource.org/licenses/MIT - * Python-2.0: http://opensource.org/licenses/Python-2.0 - * Zlib: http://opensource.org/licenses/Zlib - - Contributions of code put into the public domain can also be - accepted. - - Contributions using other licenses might be accepted, but further - review will be required. - -===================================================== -= Change Description / Commit Message / Patch Email = -===================================================== - -Your change description should use the standard format for a -commit message, and must include your "Signed-off-by" signature -and the "Contributed-under" message. - -== Sample Change Description / Commit Message = - -=== Start of sample patch email message === - -From: Contributor Name -Subject: [PATCH] CodeModule: Brief-single-line-summary - -Full-commit-message - -Contributed-under: TianoCore Contribution Agreement 1.0 -Signed-off-by: Contributor Name ---- - -An extra message for the patch email which will not be considered part -of the commit message can be added here. - -Patch content inline or attached - -=== End of sample patch email message === - -=== Notes for sample patch email === - -* The first line of commit message is taken from the email's subject - line following [PATCH]. The remaining portion of the commit message - is the email's content until the '---' line. -* git format-patch is one way to create this format - -=== Definitions for sample patch email === - -* "CodeModule" is a short idenfier for the affected code. For - example MdePkg, or MdeModulePkg UsbBusDxe. -* "Brief-single-line-summary" is a short summary of the change. -* The entire first line should be less than ~70 characters. -* "Full-commit-message" a verbose multiple line comment describing - the change. Each line should be less than ~70 characters. -* "Contributed-under" explicitely states that the contribution is - made under the terms of the contribtion agreement. This - agreement is included below in this document. -* "Signed-off-by" is the contributor's signature identifying them - by their real/legal name and their email address. - -======================================== -= TianoCore Contribution Agreement 1.0 = -======================================== - -INTEL CORPORATION ("INTEL") MAKES AVAILABLE SOFTWARE, DOCUMENTATION, -INFORMATION AND/OR OTHER MATERIALS FOR USE IN THE TIANOCORE OPEN SOURCE -PROJECT (COLLECTIVELY "CONTENT"). USE OF THE CONTENT IS GOVERNED BY THE -TERMS AND CONDITIONS OF THIS AGREEMENT BETWEEN YOU AND INTEL AND/OR THE -TERMS AND CONDITIONS OF LICENSE AGREEMENTS OR NOTICES INDICATED OR -REFERENCED BELOW. BY USING THE CONTENT, YOU AGREE THAT YOUR USE OF THE -CONTENT IS GOVERNED BY THIS AGREEMENT AND/OR THE TERMS AND CONDITIONS -OF ANY APPLICABLE LICENSE AGREEMENTS OR NOTICES INDICATED OR REFERENCED -BELOW. IF YOU DO NOT AGREE TO THE TERMS AND CONDITIONS OF THIS -AGREEMENT AND THE TERMS AND CONDITIONS OF ANY APPLICABLE LICENSE -AGREEMENTS OR NOTICES INDICATED OR REFERENCED BELOW, THEN YOU MAY NOT -USE THE CONTENT. - -Unless otherwise indicated, all Content made available on the TianoCore -site is provided to you under the terms and conditions of the BSD -License ("BSD"). A copy of the BSD License is available at -http://opensource.org/licenses/bsd-license.php -or when applicable, in the associated License.txt file. - -Certain other content may be made available under other licenses as -indicated in or with such Content. (For example, in a License.txt file.) - -You accept and agree to the following terms and conditions for Your -present and future Contributions submitted to TianoCore site. Except -for the license granted to Intel hereunder, You reserve all right, -title, and interest in and to Your Contributions. - -== SECTION 1: Definitions == -* "You" or "Contributor" shall mean the copyright owner or legal - entity authorized by the copyright owner that is making a - Contribution hereunder. All other entities that control, are - controlled by, or are under common control with that entity are - considered to be a single Contributor. For the purposes of this - definition, "control" means (i) the power, direct or indirect, to - cause the direction or management of such entity, whether by - contract or otherwise, or (ii) ownership of fifty percent (50%) - or more of the outstanding shares, or (iii) beneficial ownership - of such entity. -* "Contribution" shall mean any original work of authorship, - including any modifications or additions to an existing work, - that is intentionally submitted by You to the TinaoCore site for - inclusion in, or documentation of, any of the Content. For the - purposes of this definition, "submitted" means any form of - electronic, verbal, or written communication sent to the - TianoCore site or its representatives, including but not limited - to communication on electronic mailing lists, source code - control systems, and issue tracking systems that are managed by, - or on behalf of, the TianoCore site for the purpose of - discussing and improving the Content, but excluding - communication that is conspicuously marked or otherwise - designated in writing by You as "Not a Contribution." - -== SECTION 2: License for Contributions == -* Contributor hereby agrees that redistribution and use of the - Contribution in source and binary forms, with or without - modification, are permitted provided that the following - conditions are met: -** Redistributions of source code must retain the Contributor's - copyright notice, this list of conditions and the following - disclaimer. -** Redistributions in binary form must reproduce the Contributor's - copyright notice, this list of conditions and the following - disclaimer in the documentation and/or other materials provided - with the distribution. -* Disclaimer. None of the names of Contributor, Intel, or the names - of their respective contributors may be used to endorse or - promote products derived from this software without specific - prior written permission. -* Contributor grants a license (with the right to sublicense) under - claims of Contributor's patents that Contributor can license that - are infringed by the Contribution (as delivered by Contributor) to - make, use, distribute, sell, offer for sale, and import the - Contribution and derivative works thereof solely to the minimum - extent necessary for licensee to exercise the granted copyright - license; this patent license applies solely to those portions of - the Contribution that are unmodified. No hardware per se is - licensed. -* EXCEPT AS EXPRESSLY SET FORTH IN SECTION 3 BELOW, THE - CONTRIBUTION IS PROVIDED BY THE CONTRIBUTOR "AS IS" AND ANY - EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, - THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A - PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE - CONTRIBUTOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, - SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT - NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; - LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN - CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR - OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THE - CONTRIBUTION, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH - DAMAGE. - -== SECTION 3: Representations == -* You represent that You are legally entitled to grant the above - license. If your employer(s) has rights to intellectual property - that You create that includes Your Contributions, You represent - that You have received permission to make Contributions on behalf - of that employer, that Your employer has waived such rights for - Your Contributions. -* You represent that each of Your Contributions is Your original - creation (see Section 4 for submissions on behalf of others). - You represent that Your Contribution submissions include complete - details of any third-party license or other restriction - (including, but not limited to, related patents and trademarks) - of which You are personally aware and which are associated with - any part of Your Contributions. - -== SECTION 4: Third Party Contributions == -* Should You wish to submit work that is not Your original creation, - You may submit it to TianoCore site separately from any - Contribution, identifying the complete details of its source - and of any license or other restriction (including, but not - limited to, related patents, trademarks, and license agreements) - of which You are personally aware, and conspicuously marking the - work as "Submitted on behalf of a third-party: [named here]". - -== SECTION 5: Miscellaneous == -* Applicable Laws. Any claims arising under or relating to this - Agreement shall be governed by the internal substantive laws of - the State of Delaware or federal courts located in Delaware, - without regard to principles of conflict of laws. -* Language. This Agreement is in the English language only, which - language shall be controlling in all respects, and all versions - of this Agreement in any other language shall be for accommodation - only and shall not be binding. All communications and notices made - or given pursuant to this Agreement, and all documentation and - support to be provided, unless otherwise noted, shall be in the - English language. - diff --git a/OvmfPkg/Csm/Csm16/Csm16.inf b/OvmfPkg/Csm/Csm16/Csm16.inf deleted file mode 100644 index 61f972b825..0000000000 --- a/OvmfPkg/Csm/Csm16/Csm16.inf +++ /dev/null @@ -1,23 +0,0 @@ -## @file -# CSM Binary -# -# Copyright (c) 2006 - 2011, Intel Corporation. All rights reserved.
-# This program and the accompanying materials -# are licensed and made available under the terms and conditions of the BSD License -# which accompanies this distribution. The full text of the license may be found at -# http://opensource.org/licenses/bsd-license.php -# -# THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, -# WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. -# -## - -[Defines] - INF_VERSION = 0x00010005 - BASE_NAME = Csm16 - FILE_GUID = 1547B4F3-3E8A-4FEF-81C8-328ED647AB1A - MODULE_TYPE = USER_DEFINED - VERSION_STRING = 1.0 - -[Binaries] - BIN|Csm16.bin|* \ No newline at end of file diff --git a/OvmfPkg/Csm/Csm16/ReadMe.txt b/OvmfPkg/Csm/Csm16/ReadMe.txt deleted file mode 100644 index 4d5d086bb4..0000000000 --- a/OvmfPkg/Csm/Csm16/ReadMe.txt +++ /dev/null @@ -1,12 +0,0 @@ -This module allows a CSM16 binary to be easily included -in the OVMF.fd output file. - -=== How to use Csm16.inf === - -1. Copy the CSM16 binary to OvmfPkg/Csm/Csm16/Csm16.bin -2. Build OVMF with CSM_ENABLE defined. - - For example: - * build -D CSM_ENABLE, or - * OvmfPkg/build.sh -D CSM_ENABLE - diff --git a/OvmfPkg/Csm/CsmSupportLib/CsmSupportLib.c b/OvmfPkg/Csm/CsmSupportLib/CsmSupportLib.c deleted file mode 100644 index c0b0252b9c..0000000000 --- a/OvmfPkg/Csm/CsmSupportLib/CsmSupportLib.c +++ /dev/null @@ -1,38 +0,0 @@ -/** @file - Platform CSM Support Library - - Copyright (c) 2008 - 2011, Intel Corporation. All rights reserved.
- - This program and the accompanying materials are - licensed and made available under the terms and conditions of the BSD License - which accompanies this distribution. The full text of the license may be found at - http://opensource.org/licenses/bsd-license.php - - THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, - WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. - -**/ - -#include "CsmSupportLib.h" - -/** - The constructor function for the platform CSM support library - - @retval EFI_SUCCESS The constructor always returns RETURN_SUCCESS. - -**/ -RETURN_STATUS -EFIAPI -CsmSupportLibConstructor ( - VOID - ) -{ - LegacyRegionInit (); - - LegacyInterruptInstall (); - - LegacyBiosPlatformInstall (); - - return EFI_SUCCESS; -} - diff --git a/OvmfPkg/Csm/CsmSupportLib/CsmSupportLib.h b/OvmfPkg/Csm/CsmSupportLib/CsmSupportLib.h deleted file mode 100644 index e3b6e8c628..0000000000 --- a/OvmfPkg/Csm/CsmSupportLib/CsmSupportLib.h +++ /dev/null @@ -1,55 +0,0 @@ -/** @file - Platform CSM Support Library - - Copyright (c) 2008 - 2011, Intel Corporation. All rights reserved.
- - This program and the accompanying materials are - licensed and made available under the terms and conditions of the BSD License - which accompanies this distribution. The full text of the license may be found at - http://opensource.org/licenses/bsd-license.php - - THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, - WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. - -**/ - -#ifndef _CSM_SUPPORT_LIB_H_ -#define _CSM_SUPPORT_LIB_H_ - -#include - -/** - Initialize Legacy Region support - - @retval EFI_SUCCESS Successfully initialized - -**/ -EFI_STATUS -LegacyRegionInit ( - VOID - ); - -/** - Initialize Legacy Interrupt support - - @retval EFI_SUCCESS Successfully initialized - -**/ -EFI_STATUS -LegacyInterruptInstall ( - VOID - ); - -/** - Initialize Legacy Platform support - - @retval EFI_SUCCESS Successfully initialized - -**/ -EFI_STATUS -LegacyBiosPlatformInstall ( - VOID - ); - -#endif - diff --git a/OvmfPkg/Csm/CsmSupportLib/CsmSupportLib.inf b/OvmfPkg/Csm/CsmSupportLib/CsmSupportLib.inf deleted file mode 100644 index fb2ec2039f..0000000000 --- a/OvmfPkg/Csm/CsmSupportLib/CsmSupportLib.inf +++ /dev/null @@ -1,58 +0,0 @@ -## @file -# Platform CSM Support Library -# -# Copyright (c) 2008 - 2011, Intel Corporation. All rights reserved.
-# This program and the accompanying materials -# are licensed and made available under the terms and conditions of the BSD License -# which accompanies this distribution. The full text of the license may be found at -# http://opensource.org/licenses/bsd-license.php -# -# THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, -# WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. -# -## - -[Defines] - INF_VERSION = 0x00010005 - BASE_NAME = CsmSupportLib - FILE_GUID = 04e03541-4663-417d-93f6-976378247d61 - MODULE_TYPE = BASE - VERSION_STRING = 1.0 - LIBRARY_CLASS = CsmSupportLib - - CONSTRUCTOR = CsmSupportLibConstructor - -# -# The following information is for reference only and not required by the build tools. -# -# VALID_ARCHITECTURES = IA32 X64 IPF EBC -# - -[Sources] - CsmSupportLib.c - LegacyInterrupt.c - LegacyRegion.c - LegacyPlatform.c - -[Packages] - MdePkg/MdePkg.dec - IntelFrameworkPkg/IntelFrameworkPkg.dec - OvmfPkg/OvmfPkg.dec - -[Pcd] - gUefiOvmfPkgTokenSpaceGuid.PcdOvmfHostBridgePciDevId - -[Protocols] - gEfiDevicePathProtocolGuid # PROTOCOL ALWAYS_CONSUMED - gEfiDiskInfoProtocolGuid # PROTOCOL ALWAYS_CONSUMED - gEfiLegacyBiosPlatformProtocolGuid # PROTOCOL ALWAYS_CONSUMED - gEfiLegacyBiosProtocolGuid # PROTOCOL ALWAYS_CONSUMED - gEfiLegacyInterruptProtocolGuid # PROTOCOL ALWAYS_PRODUCED - gEfiLegacyRegion2ProtocolGuid # PROTOCOL ALWAYS_PRODUCED - gEfiPciIoProtocolGuid # PROTOCOL ALWAYS_CONSUMED - -[LibraryClasses] - BaseLib - PciLib - IoLib - diff --git a/OvmfPkg/Csm/CsmSupportLib/LegacyInterrupt.c b/OvmfPkg/Csm/CsmSupportLib/LegacyInterrupt.c deleted file mode 100644 index 328a432b6c..0000000000 --- a/OvmfPkg/Csm/CsmSupportLib/LegacyInterrupt.c +++ /dev/null @@ -1,220 +0,0 @@ -/** @file - Legacy Interrupt Support - - Copyright (c) 2006 - 2011, Intel Corporation. All rights reserved.
- - This program and the accompanying materials are - licensed and made available under the terms and conditions of the BSD License - which accompanies this distribution. The full text of the license may be found at - http://opensource.org/licenses/bsd-license.php - - THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, - WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. - -**/ - -#include "LegacyInterrupt.h" - -// -// Handle for the Legacy Interrupt Protocol instance produced by this driver -// -STATIC EFI_HANDLE mLegacyInterruptHandle = NULL; - -// -// Legacy Interrupt Device number (0x01 on piix4, 0x1f on q35/mch) -// -STATIC UINT8 mLegacyInterruptDevice; - -// -// The Legacy Interrupt Protocol instance produced by this driver -// -STATIC EFI_LEGACY_INTERRUPT_PROTOCOL mLegacyInterrupt = { - GetNumberPirqs, - GetLocation, - ReadPirq, - WritePirq -}; - -STATIC UINT8 PirqReg[MAX_PIRQ_NUMBER] = { PIRQA, PIRQB, PIRQC, PIRQD, PIRQE, PIRQF, PIRQG, PIRQH }; - - -/** - Return the number of PIRQs supported by this chipset. - - @param[in] This Pointer to LegacyInterrupt Protocol - @param[out] NumberPirqs The pointer to return the max IRQ number supported - - @retval EFI_SUCCESS Max PIRQs successfully returned - -**/ -EFI_STATUS -EFIAPI -GetNumberPirqs ( - IN EFI_LEGACY_INTERRUPT_PROTOCOL *This, - OUT UINT8 *NumberPirqs - ) -{ - *NumberPirqs = MAX_PIRQ_NUMBER; - - return EFI_SUCCESS; -} - - -/** - Return PCI location of this device. - $PIR table requires this info. - - @param[in] This - Protocol instance pointer. - @param[out] Bus - PCI Bus - @param[out] Device - PCI Device - @param[out] Function - PCI Function - - @retval EFI_SUCCESS Bus/Device/Function returned - -**/ -EFI_STATUS -EFIAPI -GetLocation ( - IN EFI_LEGACY_INTERRUPT_PROTOCOL *This, - OUT UINT8 *Bus, - OUT UINT8 *Device, - OUT UINT8 *Function - ) -{ - *Bus = LEGACY_INT_BUS; - *Device = mLegacyInterruptDevice; - *Function = LEGACY_INT_FUNC; - - return EFI_SUCCESS; -} - - -/** - Builds the PCI configuration address for the register specified by PirqNumber - - @param[in] PirqNumber - The PIRQ number to build the PCI configuration address for - - @return The PCI Configuration address for the PIRQ -**/ -UINTN -GetAddress ( - UINT8 PirqNumber - ) -{ - return PCI_LIB_ADDRESS( - LEGACY_INT_BUS, - mLegacyInterruptDevice, - LEGACY_INT_FUNC, - PirqReg[PirqNumber] - ); -} - -/** - Read the given PIRQ register - - @param[in] This Protocol instance pointer - @param[in] PirqNumber The Pirq register 0 = A, 1 = B etc - @param[out] PirqData Value read - - @retval EFI_SUCCESS Decoding change affected. - @retval EFI_INVALID_PARAMETER Invalid PIRQ number - -**/ -EFI_STATUS -EFIAPI -ReadPirq ( - IN EFI_LEGACY_INTERRUPT_PROTOCOL *This, - IN UINT8 PirqNumber, - OUT UINT8 *PirqData - ) -{ - if (PirqNumber >= MAX_PIRQ_NUMBER) { - return EFI_INVALID_PARAMETER; - } - - *PirqData = PciRead8 (GetAddress (PirqNumber)); - *PirqData = (UINT8) (*PirqData & 0x7f); - - return EFI_SUCCESS; -} - - -/** - Write the given PIRQ register - - @param[in] This Protocol instance pointer - @param[in] PirqNumber The Pirq register 0 = A, 1 = B etc - @param[out] PirqData Value to write - - @retval EFI_SUCCESS Decoding change affected. - @retval EFI_INVALID_PARAMETER Invalid PIRQ number - -**/ -EFI_STATUS -EFIAPI -WritePirq ( - IN EFI_LEGACY_INTERRUPT_PROTOCOL *This, - IN UINT8 PirqNumber, - IN UINT8 PirqData - ) -{ - if (PirqNumber >= MAX_PIRQ_NUMBER) { - return EFI_INVALID_PARAMETER; - } - - PciWrite8 (GetAddress (PirqNumber), PirqData); - return EFI_SUCCESS; -} - - -/** - Initialize Legacy Interrupt support - - @retval EFI_SUCCESS Successfully initialized - -**/ -EFI_STATUS -LegacyInterruptInstall ( - VOID - ) -{ - UINT16 HostBridgeDevId; - EFI_STATUS Status; - - // - // Make sure the Legacy Interrupt Protocol is not already installed in the system - // - ASSERT_PROTOCOL_ALREADY_INSTALLED(NULL, &gEfiLegacyInterruptProtocolGuid); - - // - // Query Host Bridge DID to determine platform type, then set device number - // - HostBridgeDevId = PcdGet16 (PcdOvmfHostBridgePciDevId); - switch (HostBridgeDevId) { - case INTEL_82441_DEVICE_ID: - mLegacyInterruptDevice = LEGACY_INT_DEV_PIIX4; - break; - case INTEL_Q35_MCH_DEVICE_ID: - mLegacyInterruptDevice = LEGACY_INT_DEV_Q35; - break; - default: - DEBUG ((EFI_D_ERROR, "%a: Unknown Host Bridge Device ID: 0x%04x\n", - __FUNCTION__, HostBridgeDevId)); - ASSERT (FALSE); - return EFI_UNSUPPORTED; - } - - // - // Make a new handle and install the protocol - // - Status = gBS->InstallMultipleProtocolInterfaces ( - &mLegacyInterruptHandle, - &gEfiLegacyInterruptProtocolGuid, - &mLegacyInterrupt, - NULL - ); - ASSERT_EFI_ERROR(Status); - - return Status; -} - diff --git a/OvmfPkg/Csm/CsmSupportLib/LegacyInterrupt.h b/OvmfPkg/Csm/CsmSupportLib/LegacyInterrupt.h deleted file mode 100644 index eb1f583007..0000000000 --- a/OvmfPkg/Csm/CsmSupportLib/LegacyInterrupt.h +++ /dev/null @@ -1,123 +0,0 @@ -/** @file - Legacy Region Support - - Copyright (c) 2006 - 2011, Intel Corporation. All rights reserved.
- - This program and the accompanying materials are - licensed and made available under the terms and conditions of the BSD License - which accompanies this distribution. The full text of the license may be found at - http://opensource.org/licenses/bsd-license.php - - THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, - WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. - -**/ - -#ifndef _LEGACY_INTERRUPT_H_ -#define _LEGACY_INTERRUPT_H_ - -#include - -#include - -#include -#include -#include -#include -#include - - -#define LEGACY_INT_BUS 0 -#define LEGACY_INT_DEV_PIIX4 0x01 -#define LEGACY_INT_DEV_Q35 0x1f -#define LEGACY_INT_FUNC 0 - -#define PIRQN 0x00 // PIRQ Null -#define PIRQA 0x60 -#define PIRQB 0x61 -#define PIRQC 0x62 -#define PIRQD 0x63 -#define PIRQE 0x68 -#define PIRQF 0x69 -#define PIRQG 0x6A -#define PIRQH 0x6B - -#define MAX_PIRQ_NUMBER 8 - -/** - Return the number of PIRQs supported by this chipset. - - @param[in] This Pointer to LegacyInterrupt Protocol - @param[out] NumberPirqs The pointer to return the max IRQ number supported - - @retval EFI_SUCCESS Max PIRQs successfully returned - -**/ -EFI_STATUS -EFIAPI -GetNumberPirqs ( - IN EFI_LEGACY_INTERRUPT_PROTOCOL *This, - OUT UINT8 *NumberPirqs - ); - -/** - Return PCI location of this device. - $PIR table requires this info. - - @param[in] This - Protocol instance pointer. - @param[out] Bus - PCI Bus - @param[out] Device - PCI Device - @param[out] Function - PCI Function - - @retval EFI_SUCCESS Bus/Device/Function returned - -**/ -EFI_STATUS -EFIAPI -GetLocation ( - IN EFI_LEGACY_INTERRUPT_PROTOCOL *This, - OUT UINT8 *Bus, - OUT UINT8 *Device, - OUT UINT8 *Function - ); - -/** - Read the given PIRQ register - - @param[in] This Protocol instance pointer - @param[in] PirqNumber The Pirq register 0 = A, 1 = B etc - @param[out] PirqData Value read - - @retval EFI_SUCCESS Decoding change affected. - @retval EFI_INVALID_PARAMETER Invalid PIRQ number - -**/ -EFI_STATUS -EFIAPI -ReadPirq ( - IN EFI_LEGACY_INTERRUPT_PROTOCOL *This, - IN UINT8 PirqNumber, - OUT UINT8 *PirqData - ); - -/** - Write the given PIRQ register - - @param[in] This Protocol instance pointer - @param[in] PirqNumber The Pirq register 0 = A, 1 = B etc - @param[out] PirqData Value to write - - @retval EFI_SUCCESS Decoding change affected. - @retval EFI_INVALID_PARAMETER Invalid PIRQ number - -**/ -EFI_STATUS -EFIAPI -WritePirq ( - IN EFI_LEGACY_INTERRUPT_PROTOCOL *This, - IN UINT8 PirqNumber, - IN UINT8 PirqData - ); - -#endif - diff --git a/OvmfPkg/Csm/CsmSupportLib/LegacyPlatform.c b/OvmfPkg/Csm/CsmSupportLib/LegacyPlatform.c deleted file mode 100644 index dd75be00f6..0000000000 --- a/OvmfPkg/Csm/CsmSupportLib/LegacyPlatform.c +++ /dev/null @@ -1,1066 +0,0 @@ -/** @file - Legacy BIOS Platform support - - Copyright (c) 2006 - 2011, Intel Corporation. All rights reserved.
- - This program and the accompanying materials are - licensed and made available under the terms and conditions of the BSD License - which accompanies this distribution. The full text of the license may be found at - http://opensource.org/licenses/bsd-license.php - - THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, - WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. - -**/ - -#include "LegacyPlatform.h" - -EFI_SETUP_BBS_MAP mSetupBbsMap[] = { - { 1, 2, 1, 1 }, // ATA HardDrive - { 2, 3, 1, 1 }, // ATAPI CDROM - { 3, 0x80, 2, 0 }, // PXE - { 4, 1, 0, 6 }, // USB Floppy - { 4, 2, 0, 6 }, // USB HDD - { 4, 3, 0, 6 }, // USB CD - { 4, 1, 0, 0 }, // USB ZIP Bugbug since Class/SubClass code is uninitialized - { 4, 2, 0, 0 } // USB ZIP Bugbug since Class/SubClass code is uninitialized -}; - -// -// Global variables for System ROMs -// -#define SYSTEM_ROM_FILE_GUID \ -{ 0x1547B4F3, 0x3E8A, 0x4FEF, { 0x81, 0xC8, 0x32, 0x8E, 0xD6, 0x47, 0xAB, 0x1A } } - -#define NULL_ROM_FILE_GUID \ -{ 0x00000000, 0x0000, 0x0000, { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 } } - -SYSTEM_ROM_TABLE mSystemRomTable[] = { - { SYSTEM_ROM_FILE_GUID, 1 }, - { NULL_ROM_FILE_GUID, 0 } -}; - -EFI_HANDLE mVgaHandles[0x20]; -EFI_HANDLE mDiskHandles[0x20]; -EFI_HANDLE mIsaHandles[0x20]; - -EFI_LEGACY_IRQ_PRIORITY_TABLE_ENTRY IrqPriorityTable[MAX_IRQ_PRIORITY_ENTRIES] = { - {0x0B,0}, - {0x09,0}, - {0x0A,0}, - {0x05,0}, - {0x07,0}, - {0x00,0}, - {0x00,0} -}; - -// -// PIRQ Table -// - Slot numbering will be used to update the bus number and determine bridge -// to check to get bus number. The Slot number - 1 is an index into a decode -// table to get the bridge information. -// -EFI_LEGACY_PIRQ_TABLE PirqTableHead = { - { - EFI_LEGACY_PIRQ_TABLE_SIGNATURE, // UINT32 Signature - 0x00, // UINT8 MinorVersion - 0x01, // UINT8 MajorVersion - 0x0000, // UINT16 TableSize - 0x00, // UINT8 Bus - 0x08, // UINT8 DevFun - 0x0000, // UINT16 PciOnlyIrq - 0x8086, // UINT16 CompatibleVid - 0x122e, // UINT16 CompatibleDid - 0x00000000, // UINT32 Miniport - { // UINT8 Reserved[11] - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00 - }, - 0x00, // UINT8 Checksum - }, - { - // -- Pin 1 -- -- Pin 2 -- -- Pin 3 -- -- Pin 4 -- - // Bus Dev Reg Map Reg Map Reg Map Reg Map - // - {0x00,0x08,{{0x60,0xDEB8},{0x61,0xDEB8},{0x62,0xDEB8},{0x63,0xDEB8}},0x00,0x00}, - {0x00,0x10,{{0x61,0xDEB8},{0x62,0xDEB8},{0x63,0xDEB8},{0x60,0xDEB8}},0x01,0x00}, - {0x00,0x18,{{0x62,0xDEB8},{0x63,0xDEB8},{0x60,0xDEB8},{0x61,0xDEB8}},0x02,0x00}, - {0x00,0x20,{{0x63,0xDEB8},{0x60,0xDEB8},{0x61,0xDEB8},{0x62,0xDEB8}},0x03,0x00}, - {0x00,0x28,{{0x60,0xDEB8},{0x61,0xDEB8},{0x62,0xDEB8},{0x63,0xDEB8}},0x04,0x00}, - {0x00,0x30,{{0x61,0xDEB8},{0x62,0xDEB8},{0x63,0xDEB8},{0x60,0xDEB8}},0x05,0x00}, - } -}; - -LEGACY_BIOS_PLATFORM_INSTANCE mPrivateData; -EFI_HANDLE mImageHandle = NULL; - -/** - Return the handles and assorted information for the specified PCI Class code - - @param[in] PciClasses Array of PCI_CLASS_RECORD to find terminated with ClassCode 0xff - @param[in,out] DeviceTable Table to place handles etc in. - @param[in,out] DeviceIndex Number of devices found - @param[in] DeviceFlags FALSE if a valid legacy ROM is required, TRUE otherwise. - - @retval EFI_SUCCESS One or more devices found - @retval EFI_NOT_FOUND No device found - -**/ -EFI_STATUS -FindAllDeviceTypes ( - IN PCI_CLASS_RECORD *PciClasses, - IN OUT DEVICE_STRUCTURE *DeviceTable, - IN OUT UINT16 *DeviceIndex, - IN BOOLEAN DeviceFlags - ) -{ - UINTN HandleCount; - EFI_HANDLE *HandleBuffer; - UINTN Index; - UINTN StartIndex; - PCI_TYPE00 PciConfigHeader; - EFI_PCI_IO_PROTOCOL *PciIo; - EFI_LEGACY_BIOS_PROTOCOL *LegacyBios; - UINTN Flags; - EFI_STATUS Status; - UINTN Index2; - - // - // Get legacy BIOS protocol as it is required to deal with Option ROMs. - // - StartIndex = *DeviceIndex; - Status = gBS->LocateProtocol ( - &gEfiLegacyBiosProtocolGuid, - NULL, - (VOID**)&LegacyBios - ); - ASSERT_EFI_ERROR (Status); - - // - // Get all PCI handles and check them to generate a list of matching devices. - // - gBS->LocateHandleBuffer ( - ByProtocol, - &gEfiPciIoProtocolGuid, - NULL, - &HandleCount, - &HandleBuffer - ); - for (Index = 0; Index < HandleCount; Index++) { - gBS->HandleProtocol ( - HandleBuffer[Index], - &gEfiPciIoProtocolGuid, - (VOID**)&PciIo - ); - PciIo->Pci.Read ( - PciIo, - EfiPciIoWidthUint32, - 0, - sizeof (PciConfigHeader) / sizeof (UINT32), - &PciConfigHeader - ); - for (Index2 = 0; PciClasses[Index2].Class != 0xff; Index2++) { - if ((PciConfigHeader.Hdr.ClassCode[2] == PciClasses[Index2].Class) && - (PciConfigHeader.Hdr.ClassCode[1] == PciClasses[Index2].SubClass)) { - LegacyBios->CheckPciRom ( - LegacyBios, - HandleBuffer[Index], - NULL, - NULL, - &Flags - ); - - // - // Verify that results of OPROM check match request. - // The two valid requests are: - // DeviceFlags = 0 require a valid legacy ROM - // DeviceFlags = 1 require either no ROM or a valid legacy ROM - // - if ( - ((DeviceFlags != 0) && (Flags == NO_ROM)) || - ((Flags & (ROM_FOUND | VALID_LEGACY_ROM)) == (ROM_FOUND | VALID_LEGACY_ROM)) - ) { - DeviceTable->Handle = HandleBuffer[Index]; - DeviceTable->Vid = PciConfigHeader.Hdr.VendorId; - DeviceTable->Did = PciConfigHeader.Hdr.DeviceId; - DeviceTable->SvId = PciConfigHeader.Device.SubsystemVendorID; - DeviceTable->SysId = PciConfigHeader.Device.SubsystemID; - ++ *DeviceIndex; - DeviceTable++; - } - } - } - } - - // - // Free any allocated buffers - // - gBS->FreePool (HandleBuffer); - - if (*DeviceIndex != StartIndex) { - return EFI_SUCCESS; - } else { - return EFI_NOT_FOUND; - } -} - -/** - Load and initialize the Legacy BIOS SMM handler. - - @param This The protocol instance pointer. - @param EfiToLegacy16BootTable A pointer to Legacy16 boot table. - - @retval EFI_SUCCESS SMM code loaded. - @retval EFI_DEVICE_ERROR SMM code failed to load - -**/ -EFI_STATUS -EFIAPI -SmmInit ( - IN EFI_LEGACY_BIOS_PLATFORM_PROTOCOL *This, - IN VOID *EfiToLegacy16BootTable - ) -{ - return EFI_SUCCESS; -} - -/** - Finds the device path that should be used as the primary display adapter. - - @param VgaHandle - The handle of the video device - -**/ -VOID -GetSelectedVgaDeviceInfo ( - OUT EFI_HANDLE *VgaHandle - ) -{ - EFI_STATUS Status; - UINTN HandleCount; - EFI_HANDLE *HandleBuffer; - UINTN Index; - EFI_PCI_IO_PROTOCOL *PciIo; - PCI_TYPE00 Pci; - UINT8 MinBus; - UINT8 MaxBus; - UINTN Segment; - UINTN Bus; - UINTN Device; - UINTN Function; - UINTN SelectedAddress; - UINTN CurrentAddress; - - // - // Initialize return to 'not found' state - // - *VgaHandle = NULL; - - // - // Initialize variable states. This is important for selecting the VGA - // device if multiple devices exist behind a single bridge. - // - HandleCount = 0; - HandleBuffer = NULL; - SelectedAddress = PCI_LIB_ADDRESS(0xff, 0x1f, 0x7, 0); - - // - // The bus range to search for a VGA device in. - // - MinBus = MaxBus = 0; - - // - // Start to check all the pci io to find all possible VGA device - // - HandleCount = 0; - HandleBuffer = NULL; - Status = gBS->LocateHandleBuffer ( - ByProtocol, - &gEfiPciIoProtocolGuid, - NULL, - &HandleCount, - &HandleBuffer - ); - if (EFI_ERROR (Status)) { - return; - } - - for (Index = 0; Index < HandleCount; Index++) { - Status = gBS->HandleProtocol (HandleBuffer[Index], &gEfiPciIoProtocolGuid, (VOID**)&PciIo); - if (!EFI_ERROR (Status)) { - // - // Detemine if this is in the correct bus range. - // - Status = PciIo->GetLocation (PciIo, &Segment, &Bus, &Device, &Function); - if (EFI_ERROR(Status) || (Bus < MinBus || Bus > MaxBus)) { - continue; - } - - // - // Read device information. - // - Status = PciIo->Pci.Read ( - PciIo, - EfiPciIoWidthUint32, - 0, - sizeof (Pci) / sizeof (UINT32), - &Pci - ); - if (EFI_ERROR (Status)) { - continue; - } - - // - // Make sure the device is a VGA device. - // - if (!IS_PCI_VGA (&Pci)) { - continue; - } - DEBUG ((EFI_D_INFO, - "PCI VGA: 0x%04x:0x%04x\n", - Pci.Hdr.VendorId, - Pci.Hdr.DeviceId - )); - - // - // Currently we use the lowest numbered bus/device/function if multiple - // devices are found in the target bus range. - // - CurrentAddress = PCI_LIB_ADDRESS(Bus, Device, Function, 0); - if (CurrentAddress < SelectedAddress) { - SelectedAddress = CurrentAddress; - *VgaHandle = HandleBuffer[Index]; - } - } - } - - FreePool (HandleBuffer); -} - - -/** - Returns a buffer of handles for the requested subfunction. - - @param This The protocol instance pointer. - @param Mode Specifies what handle to return. See EFI_GET_PLATFORM_HANDLE_MODE enum. - @param Type Mode specific. See EFI_GET_PLATFORM_HANDLE_MODE enum. - @param HandleBuffer Mode specific. See EFI_GET_PLATFORM_HANDLE_MODE enum. - @param HandleCount Mode specific. See EFI_GET_PLATFORM_HANDLE_MODE enum. - @param AdditionalData Mode specific. See EFI_GET_PLATFORM_HANDLE_MODE enum. - - @retval EFI_SUCCESS Handle is valid. - @retval EFI_UNSUPPORTED Mode is not supported on the platform. - @retval EFI_NOT_FOUND Handle is not known. - -**/ -EFI_STATUS -EFIAPI -GetPlatformHandle ( - IN EFI_LEGACY_BIOS_PLATFORM_PROTOCOL *This, - IN EFI_GET_PLATFORM_HANDLE_MODE Mode, - IN UINT16 Type, - OUT EFI_HANDLE **HandleBuffer, - OUT UINTN *HandleCount, - OUT VOID **AdditionalData OPTIONAL - ) -{ - DEVICE_STRUCTURE LocalDevice[0x40]; - UINT32 LocalIndex; - UINT32 Index; - DEVICE_STRUCTURE TempDevice; - EFI_STATUS Status; - EFI_PCI_IO_PROTOCOL *PciIo; - UINTN Segment; - UINTN Bus; - UINTN Device; - UINTN Function; - HDD_INFO *HddInfo; - PCI_TYPE00 PciConfigHeader; - UINT32 HddIndex; - EFI_HANDLE IdeHandle; - EFI_LEGACY_BIOS_PROTOCOL *LegacyBios; - PCI_CLASS_RECORD ClassLists[10]; - UINTN PriorityIndex; - - static BOOLEAN bConnected = FALSE; - - LocalIndex = 0x00; - HddInfo = NULL; - HddIndex = 0; - - Status = gBS->LocateProtocol ( - &gEfiLegacyBiosProtocolGuid, - NULL, - (VOID**)&LegacyBios - ); - - // - // Process mode specific operations - // - switch (Mode) { - case EfiGetPlatformVgaHandle: - // - // Get the handle for the currently selected VGA device. - // - GetSelectedVgaDeviceInfo (&mVgaHandles[0]); - *HandleBuffer = &mVgaHandles[0]; - *HandleCount = (mVgaHandles[0] != NULL) ? 1 : 0; - return EFI_SUCCESS; - case EfiGetPlatformIdeHandle: - IdeHandle = NULL; - if (AdditionalData != NULL) { - HddInfo = (HDD_INFO *) *AdditionalData; - } - - // - // Locate all found block io devices - // - ClassLists[0].Class = PCI_CLASS_MASS_STORAGE; - ClassLists[0].SubClass = PCI_CLASS_MASS_STORAGE_SCSI; - ClassLists[1].Class = PCI_CLASS_MASS_STORAGE; - ClassLists[1].SubClass = PCI_CLASS_MASS_STORAGE_IDE; - ClassLists[2].Class = PCI_CLASS_MASS_STORAGE; - ClassLists[2].SubClass = PCI_CLASS_MASS_STORAGE_RAID; - ClassLists[3].Class = PCI_CLASS_MASS_STORAGE; - ClassLists[3].SubClass = PCI_CLASS_MASS_STORAGE_SATADPA; - ClassLists[4].Class = 0xff; - FindAllDeviceTypes (ClassLists, LocalDevice, (UINT16 *) &LocalIndex, TRUE); - if (LocalIndex == 0) { - return EFI_NOT_FOUND; - } - - // - // Make sure all IDE controllers are connected. This is necessary - // in NO_CONFIG_CHANGE boot path to ensure IDE controller is correctly - // initialized and all IDE drives are enumerated - // - if (!bConnected) { - for (Index = 0; Index < LocalIndex; Index++) { - gBS->ConnectController (LocalDevice[Index].Handle, NULL, NULL, TRUE); - } - } - - // - // Locate onboard controllers. - // - for (Index = 0; Index < LocalIndex; Index++) { - if (LocalDevice[Index].Vid == V_INTEL_VENDOR_ID) { - if (LocalDevice[Index].Did == V_PIIX4_IDE_DEVICE_ID) { - IdeHandle = LocalDevice[Index].Handle; - } - } - } - - // - // Set the IDE contorller as primary devices. - // - PriorityIndex = 0; - for (Index = 0; Index < LocalIndex; Index++) { - if (LocalDevice[Index].Handle == IdeHandle && PriorityIndex == 0) { - TempDevice = LocalDevice[PriorityIndex]; - LocalDevice[PriorityIndex] = LocalDevice[Index]; - LocalDevice[Index] = TempDevice; - PriorityIndex++; - break; - } - } - - // - // Copy over handles and update return values. - // - for (Index = 0; Index < LocalIndex; Index++) { - mDiskHandles[Index] = LocalDevice[Index].Handle; - } - *HandleBuffer = &mDiskHandles[0]; - *HandleCount = LocalIndex; - - // - // We have connected all IDE controllers once. No more needed - // - bConnected = TRUE; - - // - // Log all onboard controllers. - // - for (Index = 0; (Index < LocalIndex) && (AdditionalData != NULL); Index++) { - if ((LocalDevice[Index].Handle != NULL) && - (LocalDevice[Index].Handle == IdeHandle)) { - Status = gBS->HandleProtocol ( - LocalDevice[Index].Handle, - &gEfiPciIoProtocolGuid, - (VOID **) &PciIo - ); - PciIo->Pci.Read ( - PciIo, - EfiPciIoWidthUint32, - 0, - sizeof (PciConfigHeader) / sizeof (UINT32), - &PciConfigHeader - ); - if (!EFI_ERROR (Status)) { - PciIo->GetLocation ( - PciIo, - &Segment, - &Bus, - &Device, - &Function - ); - - // - // Be sure to only fill out correct information based on platform - // configureation. - // - HddInfo[HddIndex].Status |= HDD_PRIMARY; - HddInfo[HddIndex].Bus = (UINT32)Bus; - HddInfo[HddIndex].Device = (UINT32)Device; - HddInfo[HddIndex].Function = (UINT32)Function; - HddInfo[HddIndex + 1].Status |= HDD_SECONDARY; - HddInfo[HddIndex + 1].Bus = (UINT32)Bus; - HddInfo[HddIndex + 1].Device = (UINT32)Device; - HddInfo[HddIndex + 1].Function = (UINT32)Function; - - // - // Primary controller data - // - if ((PciConfigHeader.Hdr.ClassCode[0] & 0x01) != 0) { - HddInfo[HddIndex].CommandBaseAddress = - (UINT16)(PciConfigHeader.Device.Bar[0] & 0xfffc); - HddInfo[HddIndex].ControlBaseAddress = - (UINT16)((PciConfigHeader.Device.Bar[1] & 0xfffc)+2); - HddInfo[HddIndex].BusMasterAddress = - (UINT16)(PciConfigHeader.Device.Bar[4] & 0xfffc); - HddInfo[HddIndex].HddIrq = PciConfigHeader.Device.InterruptLine; - } else { - HddInfo[HddIndex].HddIrq = 14; - HddInfo[HddIndex].CommandBaseAddress = 0x1f0; - HddInfo[HddIndex].ControlBaseAddress = 0x3f6; - HddInfo[HddIndex].BusMasterAddress = 0; - } - HddIndex++; - - // - // Secondary controller data - // - if ((PciConfigHeader.Hdr.ClassCode[0] & 0x04) != 0) { - HddInfo[HddIndex].CommandBaseAddress = - (UINT16)(PciConfigHeader.Device.Bar[2] & 0xfffc); - HddInfo[HddIndex].ControlBaseAddress = - (UINT16)((PciConfigHeader.Device.Bar[3] & 0xfffc)+2); - HddInfo[HddIndex].BusMasterAddress = - (UINT16)(HddInfo[HddIndex].BusMasterAddress + 8); - HddInfo[HddIndex].HddIrq = PciConfigHeader.Device.InterruptLine; - } else { - HddInfo[HddIndex].HddIrq = 15; - HddInfo[HddIndex].CommandBaseAddress = 0x170; - HddInfo[HddIndex].ControlBaseAddress = 0x376; - HddInfo[HddIndex].BusMasterAddress = 0; - } - HddIndex++; - } - } - } - return EFI_SUCCESS; - case EfiGetPlatformIsaBusHandle: - ClassLists[0].Class = (UINT8) PCI_CLASS_BRIDGE; - ClassLists[0].SubClass = (UINT8) PCI_CLASS_BRIDGE_ISA_PDECODE; - ClassLists[1].Class = (UINT8) PCI_CLASS_BRIDGE; - ClassLists[1].SubClass = (UINT8) PCI_CLASS_BRIDGE_ISA; - ClassLists[2].Class = 0xff; - - // - // Locate all found block io devices - // - FindAllDeviceTypes (ClassLists, LocalDevice, (UINT16 *) (&LocalIndex), TRUE); - if (LocalIndex == 0) { - return EFI_NOT_FOUND; - } - - // - // Find our ISA bridge. - // - for (Index = 0; Index < LocalIndex; Index++) { - if (LocalDevice[Index].Vid == V_INTEL_VENDOR_ID) { - TempDevice = LocalDevice[0]; - LocalDevice[0] = LocalDevice[Index]; - LocalDevice[Index] = TempDevice; - } - } - - // - // Perform copy and update return values. - // - for (Index = 0; Index < LocalIndex; Index++) { - mIsaHandles[Index] = LocalDevice[Index].Handle; - } - *HandleBuffer = &mIsaHandles[0]; - *HandleCount = LocalIndex; - return EFI_SUCCESS; - case EfiGetPlatformUsbHandle: - default: - return EFI_UNSUPPORTED; - }; -} - -/** - Allows platform to perform any required action after a LegacyBios operation. - Invokes the specific sub function specified by Mode. - - @param This The protocol instance pointer. - @param Mode Specifies what handle to return. See EFI_GET_PLATFORM_HOOK_MODE enum. - @param Type Mode specific. See EFI_GET_PLATFORM_HOOK_MODE enum. - @param DeviceHandle Mode specific. See EFI_GET_PLATFORM_HOOK_MODE enum. - @param ShadowAddress Mode specific. See EFI_GET_PLATFORM_HOOK_MODE enum. - @param Compatibility16Table Mode specific. See EFI_GET_PLATFORM_HOOK_MODE enum. - @param AdditionalData Mode specific. See EFI_GET_PLATFORM_HOOK_MODE enum. - - @retval EFI_SUCCESS The operation performed successfully. Mode specific. - @retval EFI_UNSUPPORTED Mode is not supported on the platform. - -**/ -EFI_STATUS -EFIAPI -PlatformHooks ( - IN EFI_LEGACY_BIOS_PLATFORM_PROTOCOL *This, - IN EFI_GET_PLATFORM_HOOK_MODE Mode, - IN UINT16 Type, - OUT EFI_HANDLE DeviceHandle, OPTIONAL - IN OUT UINTN *Shadowaddress, OPTIONAL - IN EFI_COMPATIBILITY16_TABLE *Compatibility16Table, OPTIONAL - OUT VOID **AdditionalData OPTIONAL - ) -{ - EFI_IA32_REGISTER_SET Regs; - EFI_LEGACY_BIOS_PROTOCOL *LegacyBios; - EFI_STATUS Status; - - switch (Mode) { - case EfiPlatformHookPrepareToScanRom: - Status = gBS->LocateProtocol ( - &gEfiLegacyBiosProtocolGuid, - NULL, - (VOID**)&LegacyBios - ); - - // - // Set the 80x25 Text VGA Mode - // - Regs.H.AH = 0x00; - Regs.H.AL = 0x03; - Status = LegacyBios->Int86 (LegacyBios, 0x10, &Regs); - return Status; - case EfiPlatformHookShadowServiceRoms: - return EFI_SUCCESS; - case EfiPlatformHookAfterRomInit: - default: - return EFI_UNSUPPORTED; - }; -} - -/** - Returns information associated with PCI IRQ routing. - This function returns the following information associated with PCI IRQ routing: - * An IRQ routing table and number of entries in the table. - * The $PIR table and its size. - * A list of PCI IRQs and the priority order to assign them. - - @param This The protocol instance pointer. - @param RoutingTable The pointer to PCI IRQ Routing table. - This location is the $PIR table minus the header. - @param RoutingTableEntries The number of entries in table. - @param LocalPirqTable $PIR table. - @param PirqTableSize $PIR table size. - @param LocalIrqPriorityTable A list of interrupts in priority order to assign. - @param IrqPriorityTableEntries The number of entries in the priority table. - - @retval EFI_SUCCESS Data was successfully returned. - -**/ -EFI_STATUS -EFIAPI -GetRoutingTable ( - IN EFI_LEGACY_BIOS_PLATFORM_PROTOCOL *This, - OUT VOID **RoutingTable, - OUT UINTN *RoutingTableEntries, - OUT VOID **LocalPirqTable, OPTIONAL - OUT UINTN *PirqTableSize, OPTIONAL - OUT VOID **LocalIrqPriorityTable, OPTIONAL - OUT UINTN *IrqPriorityTableEntries OPTIONAL - ) -{ - UINT16 PTableSize; - UINT32 Index; - UINT8 Bus; - UINT8 Device; - UINT8 Function; - UINT8 Checksum; - UINT8 *Ptr; - EFI_STATUS Status; - EFI_LEGACY_INTERRUPT_PROTOCOL *LegacyInterrupt; - - Checksum = 0; - - if (LocalPirqTable != NULL) { - PTableSize = sizeof (EFI_LEGACY_PIRQ_TABLE_HEADER) + - sizeof (EFI_LEGACY_IRQ_ROUTING_ENTRY) * MAX_IRQ_ROUTING_ENTRIES; - - Status = gBS->LocateProtocol ( - &gEfiLegacyInterruptProtocolGuid, - NULL, - (VOID**)&LegacyInterrupt - ); - ASSERT_EFI_ERROR (Status); - LegacyInterrupt->GetLocation ( - LegacyInterrupt, - &Bus, - &Device, - &Function - ); - - // - // Update fields in $PIR table header - // - PirqTableHead.PirqTable.TableSize = PTableSize; - PirqTableHead.PirqTable.Bus = Bus; - PirqTableHead.PirqTable.DevFun = (UINT8) ((Device << 3) + Function); - Ptr = (UINT8 *) (&PirqTableHead); - - // - // Calculate checksum. - // - for (Index = 0; Index < PTableSize; Index++) { - Checksum = (UINT8) (Checksum + (UINT8) *Ptr); - Ptr += 1; - } - Checksum = (UINT8) (0x00 - Checksum); - PirqTableHead.PirqTable.Checksum = Checksum; - - // - // Update return values. - // - *LocalPirqTable = (VOID *) (&PirqTableHead); - *PirqTableSize = PTableSize; - } - - // - // More items to return. - // - *RoutingTable = PirqTableHead.IrqRoutingEntry; - *RoutingTableEntries = MAX_IRQ_ROUTING_ENTRIES; - if (LocalIrqPriorityTable != NULL) { - *LocalIrqPriorityTable = IrqPriorityTable; - *IrqPriorityTableEntries = MAX_IRQ_PRIORITY_ENTRIES; - } - - return EFI_SUCCESS; -} - -/** - Finds the binary data or other platform information. - - @param This The protocol instance pointer. - @param Mode Specifies what data to return. See See EFI_GET_PLATFORM_INFO_MODE enum. - @param Table Mode specific. See EFI_GET_PLATFORM_INFO_MODE enum. - @param TableSize Mode specific. See EFI_GET_PLATFORM_INFO_MODE enum. - @param Location Mode specific. See EFI_GET_PLATFORM_INFO_MODE enum. - @param Alignment Mode specific. See EFI_GET_PLATFORM_INFO_MODE enum. - @param LegacySegment Mode specific. See EFI_GET_PLATFORM_INFO_MODE enum. - @param LegacyOffset Mode specific. See EFI_GET_PLATFORM_INFO_MODE enum. - - @retval EFI_SUCCESS Data returned successfully. - @retval EFI_UNSUPPORTED Mode is not supported on the platform. - @retval EFI_NOT_FOUND Binary image or table not found. - -**/ -EFI_STATUS -EFIAPI -GetPlatformInfo ( - IN EFI_LEGACY_BIOS_PLATFORM_PROTOCOL *This, - IN EFI_GET_PLATFORM_INFO_MODE Mode, - OUT VOID **Table, - OUT UINTN *TableSize, - OUT UINTN *Location, - OUT UINTN *Alignment, - IN UINT16 LegacySegment, - IN UINT16 LegacyOffset - ) -{ - EFI_STATUS Status; - UINTN Index; - - switch (Mode) { - case EfiGetPlatformBinarySystemRom: - // - // Loop through table of System rom descriptions - // - for (Index = 0; mSystemRomTable[Index].Valid != 0; Index++) { - Status = GetSectionFromFv ( - &mSystemRomTable[Index].FileName, - EFI_SECTION_RAW, - 0, - Table, - (UINTN *) TableSize - ); - if (EFI_ERROR (Status)) { - continue; - } - return EFI_SUCCESS; - } - - return EFI_NOT_FOUND; - case EfiGetPlatformBinaryOem16Data: - case EfiGetPlatformBinaryMpTable: - case EfiGetPlatformBinaryOemIntData: - case EfiGetPlatformBinaryOem32Data: - case EfiGetPlatformBinaryTpmBinary: - case EfiGetPlatformPciExpressBase: - default: - return EFI_UNSUPPORTED; - }; -} - -/** - Translates the given PIRQ accounting for bridge. - This function translates the given PIRQ back through all buses, if required, - and returns the true PIRQ and associated IRQ. - - @param This The protocol instance pointer. - @param PciBus The PCI bus number for this device. - @param PciDevice The PCI device number for this device. - @param PciFunction The PCI function number for this device. - @param Pirq Input is PIRQ reported by device, and output is true PIRQ. - @param PciIrq The IRQ already assigned to the PIRQ, or the IRQ to be - assigned to the PIRQ. - - @retval EFI_SUCCESS The PIRQ was translated. - -**/ -EFI_STATUS -EFIAPI -TranslatePirq ( - IN EFI_LEGACY_BIOS_PLATFORM_PROTOCOL *This, - IN UINTN PciBus, - IN UINTN PciDevice, - IN UINTN PciFunction, - IN OUT UINT8 *Pirq, - OUT UINT8 *PciIrq - ) -{ - EFI_LEGACY_INTERRUPT_PROTOCOL *LegacyInterrupt; - EFI_STATUS Status; - UINTN Index; - UINTN Index1; - UINT8 LocalPirq; - UINT8 PirqData; - UINT8 MatchData; - - Status = gBS->LocateProtocol ( - &gEfiLegacyInterruptProtocolGuid, - NULL, - (VOID**)&LegacyInterrupt - ); - ASSERT_EFI_ERROR (Status); - LocalPirq = (UINT8) (*Pirq); - - for (Index = 0; Index < MAX_IRQ_ROUTING_ENTRIES; Index++) { - if ((PirqTableHead.IrqRoutingEntry[Index].Bus == PciBus) && - (PirqTableHead.IrqRoutingEntry[Index].Device == PciDevice)) { - LocalPirq = (UINT8) (PirqTableHead.IrqRoutingEntry[Index].PirqEntry[LocalPirq].Pirq & 0x0f); - if (LocalPirq > 4) { - LocalPirq -= 4; - } - - LegacyInterrupt->ReadPirq (LegacyInterrupt, LocalPirq, &PirqData); - MatchData = PCI_UNUSED; - while (PirqData == 0) { - for (Index1 = 0; Index1 < MAX_IRQ_PRIORITY_ENTRIES; Index1++) { - if ((IrqPriorityTable[Index1].Used == MatchData) && - (IrqPriorityTable[Index1].Irq != 0)) { - PirqData = IrqPriorityTable[Index1].Irq; - IrqPriorityTable[Index1].Used = 0xff; - LegacyInterrupt->WritePirq ( - LegacyInterrupt, - LocalPirq, - PirqData - ); - break; - } - } - - if (PirqData == 0) { - - // - // No unused interrpts, so start reusing them. - // - MatchData = (UINT8) (~MatchData); - } - } - - *PciIrq = PirqData; - *Pirq = LocalPirq; - } - } - - return EFI_SUCCESS; -} - - -/** - Attempt to legacy boot the BootOption. If the EFI contexted has been - compromised this function will not return. - - @param This The protocol instance pointer. - @param BbsDevicePath The EFI Device Path from BootXXXX variable. - @param BbsTable The Internal BBS table. - @param LoadOptionSize The size of LoadOption in size. - @param LoadOption The LoadOption from BootXXXX variable - @param EfiToLegacy16BootTable A pointer to BootTable structure - - @retval EFI_SUCCESS Ready to boot. - -**/ -EFI_STATUS -EFIAPI -PrepareToBoot ( - IN EFI_LEGACY_BIOS_PLATFORM_PROTOCOL *This, - IN BBS_BBS_DEVICE_PATH *BbsDevicePath, - IN VOID *BbsTable, - IN UINT32 LoadOptionsSize, - IN VOID *LoadOptions, - IN VOID *EfiToLegacy16BootTable - ) -{ - BBS_TABLE *LocalBbsTable; - EFI_TO_COMPATIBILITY16_BOOT_TABLE *Legacy16BootTable; - DEVICE_PRODUCER_DATA_HEADER *SioPtr; - UINT16 DevicePathType; - UINT16 Index; - UINT16 Priority; - - // - // Initialize values - // - Priority = 0; - Legacy16BootTable = (EFI_TO_COMPATIBILITY16_BOOT_TABLE*) EfiToLegacy16BootTable; - - // - // Set how Gate A20 is gated by hardware - // - SioPtr = &Legacy16BootTable->SioData; - SioPtr->Flags.A20Kybd = 1; - SioPtr->Flags.A20Port90 = 1; - SioPtr->MousePresent = 1; - - LocalBbsTable = BbsTable; - - // - // There are 2 cases that must be covered. - // Case 1: Booting to a legacy OS - BbsDevicePath is non-NULL. - // Case 2: Booting to an EFI aware OS - BbsDevicePath is NULL. - // We need to perform the PrepareToBoot function to assign - // drive numbers to HDD devices to allow the shell or EFI - // to access them. - // - if (BbsDevicePath != NULL) { - DevicePathType = BbsDevicePath->DeviceType; - } else { - DevicePathType = BBS_HARDDISK; - } - - // - // Skip the boot devices where priority is set by BDS and set the next one - // - for (Index = 0; Index < Legacy16BootTable->NumberBbsEntries; Index++) { - if ((LocalBbsTable[Index].BootPriority != BBS_UNPRIORITIZED_ENTRY) && - (LocalBbsTable[Index].BootPriority != BBS_IGNORE_ENTRY) && - (LocalBbsTable[Index].BootPriority != BBS_LOWEST_PRIORITY) && - (Priority <= LocalBbsTable[Index].BootPriority)) { - Priority = (UINT16) (LocalBbsTable[Index].BootPriority + 1); - } - } - - switch (DevicePathType) { - case BBS_FLOPPY: - case BBS_HARDDISK: - case BBS_CDROM: - case BBS_EMBED_NETWORK: - for (Index = 0; Index < Legacy16BootTable->NumberBbsEntries; Index++) { - if ((LocalBbsTable[Index].BootPriority == BBS_UNPRIORITIZED_ENTRY) && - (LocalBbsTable[Index].DeviceType == DevicePathType)) { - LocalBbsTable[Index].BootPriority = Priority; - ++Priority; - } - } - break; - case BBS_BEV_DEVICE: - for (Index = 0; Index < Legacy16BootTable->NumberBbsEntries; Index++) { - if ((LocalBbsTable[Index].BootPriority == BBS_UNPRIORITIZED_ENTRY) && - (LocalBbsTable[Index].Class == 01) && - (LocalBbsTable[Index].SubClass == 01)) { - LocalBbsTable[Index].BootPriority = Priority; - ++Priority; - } - } - break; - case BBS_USB: - case BBS_PCMCIA: - case BBS_UNKNOWN: - default: - break; - }; - - // - // Set priority for rest of devices - // - for (Index = 0; Index < Legacy16BootTable->NumberBbsEntries; Index++) { - if (LocalBbsTable[Index].BootPriority == BBS_UNPRIORITIZED_ENTRY) { - LocalBbsTable[Index].BootPriority = Priority; - ++Priority; - } - } - - return EFI_SUCCESS; -} - - -/** - Initialize Legacy Platform support - - @retval EFI_SUCCESS Successfully initialized - -**/ -EFI_STATUS -LegacyBiosPlatformInstall ( - VOID - ) -{ - EFI_STATUS Status; - LEGACY_BIOS_PLATFORM_INSTANCE *Private; - - mImageHandle = gImageHandle; - Private = &mPrivateData; - - // - // Grab a copy of all the protocols we depend on. - // - Private->Signature = LEGACY_BIOS_PLATFORM_INSTANCE_SIGNATURE; - Private->LegacyBiosPlatform.GetPlatformInfo = GetPlatformInfo; - Private->LegacyBiosPlatform.GetPlatformHandle = GetPlatformHandle; - Private->LegacyBiosPlatform.SmmInit = SmmInit; - Private->LegacyBiosPlatform.PlatformHooks = PlatformHooks; - Private->LegacyBiosPlatform.GetRoutingTable = GetRoutingTable; - Private->LegacyBiosPlatform.TranslatePirq = TranslatePirq; - Private->LegacyBiosPlatform.PrepareToBoot = PrepareToBoot; - Private->ImageHandle = gImageHandle; - - // - // Make a new handle and install the protocol - // - Private->Handle = NULL; - Status = gBS->InstallProtocolInterface ( - &Private->Handle, - &gEfiLegacyBiosPlatformProtocolGuid, - EFI_NATIVE_INTERFACE, - &Private->LegacyBiosPlatform - ); - return Status; -} - diff --git a/OvmfPkg/Csm/CsmSupportLib/LegacyPlatform.h b/OvmfPkg/Csm/CsmSupportLib/LegacyPlatform.h deleted file mode 100644 index a4654a446b..0000000000 --- a/OvmfPkg/Csm/CsmSupportLib/LegacyPlatform.h +++ /dev/null @@ -1,104 +0,0 @@ -/** @file - Legacy BIOS Platform support - - Copyright (c) 2006 - 2011, Intel Corporation. All rights reserved.
- - This program and the accompanying materials are - licensed and made available under the terms and conditions of the BSD License - which accompanies this distribution. The full text of the license may be found at - http://opensource.org/licenses/bsd-license.php - - THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, - WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. - -**/ - -#ifndef LEGACY_BIOS_PLATFORM_H_ -#define LEGACY_BIOS_PLATFORM_H_ - -#include - -#include -#include -#include -#include -#include -#include -#include -#include - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#include - -// -// PIRQ information constants. -// -#define MAX_IRQ_ROUTING_ENTRIES 6 -#define MAX_IRQ_PRIORITY_ENTRIES 7 - -#define V_INTEL_VENDOR_ID 0x8086 -#define V_PIIX4_IDE_DEVICE_ID 0x7010 - -// -// Type declarations -// -typedef struct { - UINT8 SetupValue; - UINT16 DeviceType; - UINT8 Class; - UINT8 SubClass; -} EFI_SETUP_BBS_MAP; - -typedef struct { - UINT8 Class; - UINT8 SubClass; -} PCI_CLASS_RECORD; - -typedef struct { - EFI_LEGACY_PIRQ_TABLE_HEADER PirqTable; - EFI_LEGACY_IRQ_ROUTING_ENTRY IrqRoutingEntry[MAX_IRQ_ROUTING_ENTRIES]; -} EFI_LEGACY_PIRQ_TABLE; - -typedef struct { - EFI_HANDLE Handle; - UINT16 Vid; - UINT16 Did; - UINT16 SvId; - UINT16 SysId; -} DEVICE_STRUCTURE; - -typedef struct { - EFI_GUID FileName; - UINTN Valid; -} SYSTEM_ROM_TABLE; - -typedef struct { - UINT32 Signature; - EFI_HANDLE Handle; - EFI_LEGACY_BIOS_PLATFORM_PROTOCOL LegacyBiosPlatform; - EFI_HANDLE ImageHandle; - EFI_PCI_ROOT_BRIDGE_IO_PROTOCOL *PciRootBridgeIo; -} LEGACY_BIOS_PLATFORM_INSTANCE; - -#define LEGACY_BIOS_PLATFORM_INSTANCE_SIGNATURE SIGNATURE_32('P','B','I','O') - -#define LEGACY_BIOS_PLATFORM_INSTANCE_FROM_THIS(this) \ - CR (this, \ - LEGACY_BIOS_PLATFORM_INSTANCE, \ - LegacyBiosPlatform, \ - LEGACY_BIOS_PLATFORM_INSTANCE_SIGNATURE \ - ) - -#endif - diff --git a/OvmfPkg/Csm/CsmSupportLib/LegacyRegion.c b/OvmfPkg/Csm/CsmSupportLib/LegacyRegion.c deleted file mode 100644 index 8d5d2e58a9..0000000000 --- a/OvmfPkg/Csm/CsmSupportLib/LegacyRegion.c +++ /dev/null @@ -1,504 +0,0 @@ -/** @file - Legacy Region Support - - Copyright (c) 2006 - 2016, Intel Corporation. All rights reserved.
- - This program and the accompanying materials are - licensed and made available under the terms and conditions of the BSD License - which accompanies this distribution. The full text of the license may be found at - http://opensource.org/licenses/bsd-license.php - - THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, - WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. - -**/ - -#include "LegacyRegion.h" - -// -// 440/Q35 PAM map. -// -// PAM Range Offset Bits Operation -// 440 Q35 -// =============== ==== ==== ==== =============================================================== -// 0xC0000-0xC3FFF 0x5a 0x91 1:0 00 = DRAM Disabled, 01= Read Only, 10 = Write Only, 11 = Normal -// 0xC4000-0xC7FFF 0x5a 0x91 5:4 00 = DRAM Disabled, 01= Read Only, 10 = Write Only, 11 = Normal -// 0xC8000-0xCBFFF 0x5b 0x92 1:0 00 = DRAM Disabled, 01= Read Only, 10 = Write Only, 11 = Normal -// 0xCC000-0xCFFFF 0x5b 0x92 5:4 00 = DRAM Disabled, 01= Read Only, 10 = Write Only, 11 = Normal -// 0xD0000-0xD3FFF 0x5c 0x93 1:0 00 = DRAM Disabled, 01= Read Only, 10 = Write Only, 11 = Normal -// 0xD4000-0xD7FFF 0x5c 0x93 5:4 00 = DRAM Disabled, 01= Read Only, 10 = Write Only, 11 = Normal -// 0xD8000-0xDBFFF 0x5d 0x94 1:0 00 = DRAM Disabled, 01= Read Only, 10 = Write Only, 11 = Normal -// 0xDC000-0xDFFFF 0x5d 0x94 5:4 00 = DRAM Disabled, 01= Read Only, 10 = Write Only, 11 = Normal -// 0xE0000-0xE3FFF 0x5e 0x95 1:0 00 = DRAM Disabled, 01= Read Only, 10 = Write Only, 11 = Normal -// 0xE4000-0xE7FFF 0x5e 0x95 5:4 00 = DRAM Disabled, 01= Read Only, 10 = Write Only, 11 = Normal -// 0xE8000-0xEBFFF 0x5f 0x96 1:0 00 = DRAM Disabled, 01= Read Only, 10 = Write Only, 11 = Normal -// 0xEC000-0xEFFFF 0x5f 0x96 5:4 00 = DRAM Disabled, 01= Read Only, 10 = Write Only, 11 = Normal -// 0xF0000-0xFFFFF 0x59 0x90 5:4 00 = DRAM Disabled, 01= Read Only, 10 = Write Only, 11 = Normal -// -STATIC LEGACY_MEMORY_SECTION_INFO mSectionArray[] = { - {0xC0000, SIZE_16KB, FALSE, FALSE}, - {0xC4000, SIZE_16KB, FALSE, FALSE}, - {0xC8000, SIZE_16KB, FALSE, FALSE}, - {0xCC000, SIZE_16KB, FALSE, FALSE}, - {0xD0000, SIZE_16KB, FALSE, FALSE}, - {0xD4000, SIZE_16KB, FALSE, FALSE}, - {0xD8000, SIZE_16KB, FALSE, FALSE}, - {0xDC000, SIZE_16KB, FALSE, FALSE}, - {0xE0000, SIZE_16KB, FALSE, FALSE}, - {0xE4000, SIZE_16KB, FALSE, FALSE}, - {0xE8000, SIZE_16KB, FALSE, FALSE}, - {0xEC000, SIZE_16KB, FALSE, FALSE}, - {0xF0000, SIZE_64KB, FALSE, FALSE} -}; - -STATIC PAM_REGISTER_VALUE mRegisterValues440[] = { - {REG_PAM1_OFFSET_440, 0x01, 0x02}, - {REG_PAM1_OFFSET_440, 0x10, 0x20}, - {REG_PAM2_OFFSET_440, 0x01, 0x02}, - {REG_PAM2_OFFSET_440, 0x10, 0x20}, - {REG_PAM3_OFFSET_440, 0x01, 0x02}, - {REG_PAM3_OFFSET_440, 0x10, 0x20}, - {REG_PAM4_OFFSET_440, 0x01, 0x02}, - {REG_PAM4_OFFSET_440, 0x10, 0x20}, - {REG_PAM5_OFFSET_440, 0x01, 0x02}, - {REG_PAM5_OFFSET_440, 0x10, 0x20}, - {REG_PAM6_OFFSET_440, 0x01, 0x02}, - {REG_PAM6_OFFSET_440, 0x10, 0x20}, - {REG_PAM0_OFFSET_440, 0x10, 0x20} -}; - -STATIC PAM_REGISTER_VALUE mRegisterValuesQ35[] = { - {REG_PAM1_OFFSET_Q35, 0x01, 0x02}, - {REG_PAM1_OFFSET_Q35, 0x10, 0x20}, - {REG_PAM2_OFFSET_Q35, 0x01, 0x02}, - {REG_PAM2_OFFSET_Q35, 0x10, 0x20}, - {REG_PAM3_OFFSET_Q35, 0x01, 0x02}, - {REG_PAM3_OFFSET_Q35, 0x10, 0x20}, - {REG_PAM4_OFFSET_Q35, 0x01, 0x02}, - {REG_PAM4_OFFSET_Q35, 0x10, 0x20}, - {REG_PAM5_OFFSET_Q35, 0x01, 0x02}, - {REG_PAM5_OFFSET_Q35, 0x10, 0x20}, - {REG_PAM6_OFFSET_Q35, 0x01, 0x02}, - {REG_PAM6_OFFSET_Q35, 0x10, 0x20}, - {REG_PAM0_OFFSET_Q35, 0x10, 0x20} -}; - -STATIC PAM_REGISTER_VALUE *mRegisterValues; - -// -// Handle used to install the Legacy Region Protocol -// -STATIC EFI_HANDLE mHandle = NULL; - -// -// Instance of the Legacy Region Protocol to install into the handle database -// -STATIC EFI_LEGACY_REGION2_PROTOCOL mLegacyRegion2 = { - LegacyRegion2Decode, - LegacyRegion2Lock, - LegacyRegion2BootLock, - LegacyRegion2Unlock, - LegacyRegionGetInfo -}; - -STATIC -EFI_STATUS -LegacyRegionManipulationInternal ( - IN UINT32 Start, - IN UINT32 Length, - IN BOOLEAN *ReadEnable, - IN BOOLEAN *WriteEnable, - OUT UINT32 *Granularity - ) -{ - UINT32 EndAddress; - UINTN Index; - UINTN StartIndex; - - // - // Validate input parameters. - // - if (Length == 0 || Granularity == NULL) { - return EFI_INVALID_PARAMETER; - } - EndAddress = Start + Length - 1; - if ((Start < PAM_BASE_ADDRESS) || EndAddress > PAM_LIMIT_ADDRESS) { - return EFI_INVALID_PARAMETER; - } - - // - // Loop to find the start PAM. - // - StartIndex = 0; - for (Index = 0; Index < ARRAY_SIZE (mSectionArray); Index++) { - if ((Start >= mSectionArray[Index].Start) && (Start < (mSectionArray[Index].Start + mSectionArray[Index].Length))) { - StartIndex = Index; - break; - } - } - ASSERT (Index < ARRAY_SIZE (mSectionArray)); - - // - // Program PAM until end PAM is encountered - // - for (Index = StartIndex; Index < ARRAY_SIZE (mSectionArray); Index++) { - if (ReadEnable != NULL) { - if (*ReadEnable) { - PciOr8 ( - PCI_LIB_ADDRESS(PAM_PCI_BUS, PAM_PCI_DEV, PAM_PCI_FUNC, mRegisterValues[Index].PAMRegOffset), - mRegisterValues[Index].ReadEnableData - ); - } else { - PciAnd8 ( - PCI_LIB_ADDRESS(PAM_PCI_BUS, PAM_PCI_DEV, PAM_PCI_FUNC, mRegisterValues[Index].PAMRegOffset), - (UINT8) (~mRegisterValues[Index].ReadEnableData) - ); - } - } - if (WriteEnable != NULL) { - if (*WriteEnable) { - PciOr8 ( - PCI_LIB_ADDRESS(PAM_PCI_BUS, PAM_PCI_DEV, PAM_PCI_FUNC, mRegisterValues[Index].PAMRegOffset), - mRegisterValues[Index].WriteEnableData - ); - } else { - PciAnd8 ( - PCI_LIB_ADDRESS(PAM_PCI_BUS, PAM_PCI_DEV, PAM_PCI_FUNC, mRegisterValues[Index].PAMRegOffset), - (UINT8) (~mRegisterValues[Index].WriteEnableData) - ); - } - } - - // - // If the end PAM is encountered, record its length as granularity and jump out. - // - if ((EndAddress >= mSectionArray[Index].Start) && (EndAddress < (mSectionArray[Index].Start + mSectionArray[Index].Length))) { - *Granularity = mSectionArray[Index].Length; - break; - } - } - ASSERT (Index < ARRAY_SIZE (mSectionArray)); - - return EFI_SUCCESS; -} - -STATIC -EFI_STATUS -LegacyRegionGetInfoInternal ( - OUT UINT32 *DescriptorCount, - OUT LEGACY_MEMORY_SECTION_INFO **Descriptor - ) -{ - UINTN Index; - UINT8 PamValue; - - // - // Check input parameters - // - if (DescriptorCount == NULL || Descriptor == NULL) { - return EFI_INVALID_PARAMETER; - } - - // - // Fill in current status of legacy region. - // - *DescriptorCount = sizeof(mSectionArray) / sizeof (mSectionArray[0]); - for (Index = 0; Index < *DescriptorCount; Index++) { - PamValue = PciRead8 (PCI_LIB_ADDRESS(PAM_PCI_BUS, PAM_PCI_DEV, PAM_PCI_FUNC, mRegisterValues[Index].PAMRegOffset)); - mSectionArray[Index].ReadEnabled = FALSE; - if ((PamValue & mRegisterValues[Index].ReadEnableData) != 0) { - mSectionArray[Index].ReadEnabled = TRUE; - } - mSectionArray[Index].WriteEnabled = FALSE; - if ((PamValue & mRegisterValues[Index].WriteEnableData) != 0) { - mSectionArray[Index].WriteEnabled = TRUE; - } - } - - *Descriptor = mSectionArray; - return EFI_SUCCESS; -} - -/** - Modify the hardware to allow (decode) or disallow (not decode) memory reads in a region. - - If the On parameter evaluates to TRUE, this function enables memory reads in the address range - Start to (Start + Length - 1). - If the On parameter evaluates to FALSE, this function disables memory reads in the address range - Start to (Start + Length - 1). - - @param This[in] Indicates the EFI_LEGACY_REGION_PROTOCOL instance. - @param Start[in] The beginning of the physical address of the region whose attributes - should be modified. - @param Length[in] The number of bytes of memory whose attributes should be modified. - The actual number of bytes modified may be greater than the number - specified. - @param Granularity[out] The number of bytes in the last region affected. This may be less - than the total number of bytes affected if the starting address - was not aligned to a region's starting address or if the length - was greater than the number of bytes in the first region. - @param On[in] Decode / Non-Decode flag. - - @retval EFI_SUCCESS The region's attributes were successfully modified. - @retval EFI_INVALID_PARAMETER If Start or Length describe an address not in the Legacy Region. - -**/ -EFI_STATUS -EFIAPI -LegacyRegion2Decode ( - IN EFI_LEGACY_REGION2_PROTOCOL *This, - IN UINT32 Start, - IN UINT32 Length, - OUT UINT32 *Granularity, - IN BOOLEAN *On - ) -{ - return LegacyRegionManipulationInternal (Start, Length, On, NULL, Granularity); -} - - -/** - Modify the hardware to disallow memory attribute changes in a region. - - This function makes the attributes of a region read only. Once a region is boot-locked with this - function, the read and write attributes of that region cannot be changed until a power cycle has - reset the boot-lock attribute. Calls to Decode(), Lock() and Unlock() will have no effect. - - @param This[in] Indicates the EFI_LEGACY_REGION_PROTOCOL instance. - @param Start[in] The beginning of the physical address of the region whose - attributes should be modified. - @param Length[in] The number of bytes of memory whose attributes should be modified. - The actual number of bytes modified may be greater than the number - specified. - @param Granularity[out] The number of bytes in the last region affected. This may be less - than the total number of bytes affected if the starting address was - not aligned to a region's starting address or if the length was - greater than the number of bytes in the first region. - - @retval EFI_SUCCESS The region's attributes were successfully modified. - @retval EFI_INVALID_PARAMETER If Start or Length describe an address not in the Legacy Region. - @retval EFI_UNSUPPORTED The chipset does not support locking the configuration registers in - a way that will not affect memory regions outside the legacy memory - region. - -**/ -EFI_STATUS -EFIAPI -LegacyRegion2BootLock ( - IN EFI_LEGACY_REGION2_PROTOCOL *This, - IN UINT32 Start, - IN UINT32 Length, - OUT UINT32 *Granularity - ) -{ - if ((Start < 0xC0000) || ((Start + Length - 1) > 0xFFFFF)) { - return EFI_INVALID_PARAMETER; - } - - return EFI_UNSUPPORTED; -} - - -/** - Modify the hardware to disallow memory writes in a region. - - This function changes the attributes of a memory range to not allow writes. - - @param This[in] Indicates the EFI_LEGACY_REGION_PROTOCOL instance. - @param Start[in] The beginning of the physical address of the region whose - attributes should be modified. - @param Length[in] The number of bytes of memory whose attributes should be modified. - The actual number of bytes modified may be greater than the number - specified. - @param Granularity[out] The number of bytes in the last region affected. This may be less - than the total number of bytes affected if the starting address was - not aligned to a region's starting address or if the length was - greater than the number of bytes in the first region. - - @retval EFI_SUCCESS The region's attributes were successfully modified. - @retval EFI_INVALID_PARAMETER If Start or Length describe an address not in the Legacy Region. - -**/ -EFI_STATUS -EFIAPI -LegacyRegion2Lock ( - IN EFI_LEGACY_REGION2_PROTOCOL *This, - IN UINT32 Start, - IN UINT32 Length, - OUT UINT32 *Granularity - ) -{ - BOOLEAN WriteEnable; - - WriteEnable = FALSE; - return LegacyRegionManipulationInternal (Start, Length, NULL, &WriteEnable, Granularity); -} - - -/** - Modify the hardware to allow memory writes in a region. - - This function changes the attributes of a memory range to allow writes. - - @param This[in] Indicates the EFI_LEGACY_REGION_PROTOCOL instance. - @param Start[in] The beginning of the physical address of the region whose - attributes should be modified. - @param Length[in] The number of bytes of memory whose attributes should be modified. - The actual number of bytes modified may be greater than the number - specified. - @param Granularity[out] The number of bytes in the last region affected. This may be less - than the total number of bytes affected if the starting address was - not aligned to a region's starting address or if the length was - greater than the number of bytes in the first region. - - @retval EFI_SUCCESS The region's attributes were successfully modified. - @retval EFI_INVALID_PARAMETER If Start or Length describe an address not in the Legacy Region. - -**/ -EFI_STATUS -EFIAPI -LegacyRegion2Unlock ( - IN EFI_LEGACY_REGION2_PROTOCOL *This, - IN UINT32 Start, - IN UINT32 Length, - OUT UINT32 *Granularity - ) -{ - BOOLEAN WriteEnable; - - WriteEnable = TRUE; - return LegacyRegionManipulationInternal (Start, Length, NULL, &WriteEnable, Granularity); -} - -/** - Get region information for the attributes of the Legacy Region. - - This function is used to discover the granularity of the attributes for the memory in the legacy - region. Each attribute may have a different granularity and the granularity may not be the same - for all memory ranges in the legacy region. - - @param This[in] Indicates the EFI_LEGACY_REGION_PROTOCOL instance. - @param DescriptorCount[out] The number of region descriptor entries returned in the Descriptor - buffer. - @param Descriptor[out] A pointer to a pointer used to return a buffer where the legacy - region information is deposited. This buffer will contain a list of - DescriptorCount number of region descriptors. This function will - provide the memory for the buffer. - - @retval EFI_SUCCESS The region's attributes were successfully modified. - @retval EFI_INVALID_PARAMETER If Start or Length describe an address not in the Legacy Region. - -**/ -EFI_STATUS -EFIAPI -LegacyRegionGetInfo ( - IN EFI_LEGACY_REGION2_PROTOCOL *This, - OUT UINT32 *DescriptorCount, - OUT EFI_LEGACY_REGION_DESCRIPTOR **Descriptor - ) -{ - LEGACY_MEMORY_SECTION_INFO *SectionInfo; - UINT32 SectionCount; - EFI_LEGACY_REGION_DESCRIPTOR *DescriptorArray; - UINTN Index; - UINTN DescriptorIndex; - - // - // Get section numbers and information - // - LegacyRegionGetInfoInternal (&SectionCount, &SectionInfo); - - // - // Each section has 3 descriptors, corresponding to readability, writeability, and lock status. - // - DescriptorArray = AllocatePool (sizeof (EFI_LEGACY_REGION_DESCRIPTOR) * SectionCount * 3); - if (DescriptorArray == NULL) { - return EFI_OUT_OF_RESOURCES; - } - - DescriptorIndex = 0; - for (Index = 0; Index < SectionCount; Index++) { - DescriptorArray[DescriptorIndex].Start = SectionInfo[Index].Start; - DescriptorArray[DescriptorIndex].Length = SectionInfo[Index].Length; - DescriptorArray[DescriptorIndex].Granularity = SectionInfo[Index].Length; - if (SectionInfo[Index].ReadEnabled) { - DescriptorArray[DescriptorIndex].Attribute = LegacyRegionDecoded; - } else { - DescriptorArray[DescriptorIndex].Attribute = LegacyRegionNotDecoded; - } - DescriptorIndex++; - - // - // Create descriptor for writeability, according to lock status - // - DescriptorArray[DescriptorIndex].Start = SectionInfo[Index].Start; - DescriptorArray[DescriptorIndex].Length = SectionInfo[Index].Length; - DescriptorArray[DescriptorIndex].Granularity = SectionInfo[Index].Length; - if (SectionInfo[Index].WriteEnabled) { - DescriptorArray[DescriptorIndex].Attribute = LegacyRegionWriteEnabled; - } else { - DescriptorArray[DescriptorIndex].Attribute = LegacyRegionWriteDisabled; - } - DescriptorIndex++; - - // - // Chipset does not support bootlock. - // - DescriptorArray[DescriptorIndex].Start = SectionInfo[Index].Start; - DescriptorArray[DescriptorIndex].Length = SectionInfo[Index].Length; - DescriptorArray[DescriptorIndex].Granularity = SectionInfo[Index].Length; - DescriptorArray[DescriptorIndex].Attribute = LegacyRegionNotLocked; - DescriptorIndex++; - } - - *DescriptorCount = (UINT32) DescriptorIndex; - *Descriptor = DescriptorArray; - - return EFI_SUCCESS; -} - -/** - Initialize Legacy Region support - - @retval EFI_SUCCESS Successfully initialized - -**/ -EFI_STATUS -LegacyRegionInit ( - VOID - ) -{ - EFI_STATUS Status; - UINT16 HostBridgeDevId; - - // - // Query Host Bridge DID to determine platform type - // - HostBridgeDevId = PcdGet16 (PcdOvmfHostBridgePciDevId); - switch (HostBridgeDevId) { - case INTEL_82441_DEVICE_ID: - mRegisterValues = mRegisterValues440; - break; - case INTEL_Q35_MCH_DEVICE_ID: - mRegisterValues = mRegisterValuesQ35; - break; - default: - DEBUG ((EFI_D_ERROR, "%a: Unknown Host Bridge Device ID: 0x%04x\n", - __FUNCTION__, HostBridgeDevId)); - ASSERT (FALSE); - return RETURN_UNSUPPORTED; - } - - // - // Install the Legacy Region Protocol on a new handle - // - Status = gBS->InstallMultipleProtocolInterfaces ( - &mHandle, - &gEfiLegacyRegion2ProtocolGuid, &mLegacyRegion2, - NULL - ); - ASSERT_EFI_ERROR (Status); - - return Status; -} - diff --git a/OvmfPkg/Csm/CsmSupportLib/LegacyRegion.h b/OvmfPkg/Csm/CsmSupportLib/LegacyRegion.h deleted file mode 100644 index f755a2a359..0000000000 --- a/OvmfPkg/Csm/CsmSupportLib/LegacyRegion.h +++ /dev/null @@ -1,229 +0,0 @@ -/** @file - Legacy Region Support - - Copyright (c) 2008 - 2016, Intel Corporation. All rights reserved.
- - This program and the accompanying materials are - licensed and made available under the terms and conditions of the BSD License - which accompanies this distribution. The full text of the license may be found at - http://opensource.org/licenses/bsd-license.php - - THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, - WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. - -**/ - -#ifndef _LEGACY_REGION_DXE_H_ -#define _LEGACY_REGION_DXE_H_ - -#include - -#include - -#include -#include -#include - -#include -#include -#include -#include -#include - -#define PAM_PCI_BUS 0 -#define PAM_PCI_DEV 0 -#define PAM_PCI_FUNC 0 - -#define REG_PAM0_OFFSET_440 0x59 // Programmable Attribute Map 0 -#define REG_PAM1_OFFSET_440 0x5a // Programmable Attribute Map 1 -#define REG_PAM2_OFFSET_440 0x5b // Programmable Attribute Map 2 -#define REG_PAM3_OFFSET_440 0x5c // Programmable Attribute Map 3 -#define REG_PAM4_OFFSET_440 0x5d // Programmable Attribute Map 4 -#define REG_PAM5_OFFSET_440 0x5e // Programmable Attribute Map 5 -#define REG_PAM6_OFFSET_440 0x5f // Programmable Attribute Map 6 - -#define REG_PAM0_OFFSET_Q35 0x90 // Programmable Attribute Map 0 -#define REG_PAM1_OFFSET_Q35 0x91 // Programmable Attribute Map 1 -#define REG_PAM2_OFFSET_Q35 0x92 // Programmable Attribute Map 2 -#define REG_PAM3_OFFSET_Q35 0x93 // Programmable Attribute Map 3 -#define REG_PAM4_OFFSET_Q35 0x94 // Programmable Attribute Map 4 -#define REG_PAM5_OFFSET_Q35 0x95 // Programmable Attribute Map 5 -#define REG_PAM6_OFFSET_Q35 0x96 // Programmable Attribute Map 6 - -#define PAM_BASE_ADDRESS 0xc0000 -#define PAM_LIMIT_ADDRESS BASE_1MB - -// -// Describes Legacy Region blocks and status. -// -typedef struct { - UINT32 Start; - UINT32 Length; - BOOLEAN ReadEnabled; - BOOLEAN WriteEnabled; -} LEGACY_MEMORY_SECTION_INFO; - -// -// Provides a map of the PAM registers and bits used to set Read/Write access. -// -typedef struct { - UINT8 PAMRegOffset; - UINT8 ReadEnableData; - UINT8 WriteEnableData; -} PAM_REGISTER_VALUE; - -/** - Modify the hardware to allow (decode) or disallow (not decode) memory reads in a region. - - If the On parameter evaluates to TRUE, this function enables memory reads in the address range - Start to (Start + Length - 1). - If the On parameter evaluates to FALSE, this function disables memory reads in the address range - Start to (Start + Length - 1). - - @param This[in] Indicates the EFI_LEGACY_REGION_PROTOCOL instance. - @param Start[in] The beginning of the physical address of the region whose attributes - should be modified. - @param Length[in] The number of bytes of memory whose attributes should be modified. - The actual number of bytes modified may be greater than the number - specified. - @param Granularity[out] The number of bytes in the last region affected. This may be less - than the total number of bytes affected if the starting address - was not aligned to a region's starting address or if the length - was greater than the number of bytes in the first region. - @param On[in] Decode / Non-Decode flag. - - @retval EFI_SUCCESS The region's attributes were successfully modified. - @retval EFI_INVALID_PARAMETER If Start or Length describe an address not in the Legacy Region. - -**/ -EFI_STATUS -EFIAPI -LegacyRegion2Decode ( - IN EFI_LEGACY_REGION2_PROTOCOL *This, - IN UINT32 Start, - IN UINT32 Length, - OUT UINT32 *Granularity, - IN BOOLEAN *On - ); - -/** - Modify the hardware to disallow memory writes in a region. - - This function changes the attributes of a memory range to not allow writes. - - @param This[in] Indicates the EFI_LEGACY_REGION_PROTOCOL instance. - @param Start[in] The beginning of the physical address of the region whose - attributes should be modified. - @param Length[in] The number of bytes of memory whose attributes should be modified. - The actual number of bytes modified may be greater than the number - specified. - @param Granularity[out] The number of bytes in the last region affected. This may be less - than the total number of bytes affected if the starting address was - not aligned to a region's starting address or if the length was - greater than the number of bytes in the first region. - - @retval EFI_SUCCESS The region's attributes were successfully modified. - @retval EFI_INVALID_PARAMETER If Start or Length describe an address not in the Legacy Region. - -**/ -EFI_STATUS -EFIAPI -LegacyRegion2Lock ( - IN EFI_LEGACY_REGION2_PROTOCOL *This, - IN UINT32 Start, - IN UINT32 Length, - OUT UINT32 *Granularity - ); - -/** - Modify the hardware to disallow memory attribute changes in a region. - - This function makes the attributes of a region read only. Once a region is boot-locked with this - function, the read and write attributes of that region cannot be changed until a power cycle has - reset the boot-lock attribute. Calls to Decode(), Lock() and Unlock() will have no effect. - - @param This[in] Indicates the EFI_LEGACY_REGION_PROTOCOL instance. - @param Start[in] The beginning of the physical address of the region whose - attributes should be modified. - @param Length[in] The number of bytes of memory whose attributes should be modified. - The actual number of bytes modified may be greater than the number - specified. - @param Granularity[out] The number of bytes in the last region affected. This may be less - than the total number of bytes affected if the starting address was - not aligned to a region's starting address or if the length was - greater than the number of bytes in the first region. - - @retval EFI_SUCCESS The region's attributes were successfully modified. - @retval EFI_INVALID_PARAMETER If Start or Length describe an address not in the Legacy Region. - @retval EFI_UNSUPPORTED The chipset does not support locking the configuration registers in - a way that will not affect memory regions outside the legacy memory - region. - -**/ -EFI_STATUS -EFIAPI -LegacyRegion2BootLock ( - IN EFI_LEGACY_REGION2_PROTOCOL *This, - IN UINT32 Start, - IN UINT32 Length, - OUT UINT32 *Granularity - ); - -/** - Modify the hardware to allow memory writes in a region. - - This function changes the attributes of a memory range to allow writes. - - @param This[in] Indicates the EFI_LEGACY_REGION_PROTOCOL instance. - @param Start[in] The beginning of the physical address of the region whose - attributes should be modified. - @param Length[in] The number of bytes of memory whose attributes should be modified. - The actual number of bytes modified may be greater than the number - specified. - @param Granularity[out] The number of bytes in the last region affected. This may be less - than the total number of bytes affected if the starting address was - not aligned to a region's starting address or if the length was - greater than the number of bytes in the first region. - - @retval EFI_SUCCESS The region's attributes were successfully modified. - @retval EFI_INVALID_PARAMETER If Start or Length describe an address not in the Legacy Region. - -**/ -EFI_STATUS -EFIAPI -LegacyRegion2Unlock ( - IN EFI_LEGACY_REGION2_PROTOCOL *This, - IN UINT32 Start, - IN UINT32 Length, - OUT UINT32 *Granularity - ); - -/** - Get region information for the attributes of the Legacy Region. - - This function is used to discover the granularity of the attributes for the memory in the legacy - region. Each attribute may have a different granularity and the granularity may not be the same - for all memory ranges in the legacy region. - - @param This[in] Indicates the EFI_LEGACY_REGION_PROTOCOL instance. - @param DescriptorCount[out] The number of region descriptor entries returned in the Descriptor - buffer. - @param Descriptor[out] A pointer to a pointer used to return a buffer where the legacy - region information is deposited. This buffer will contain a list of - DescriptorCount number of region descriptors. This function will - provide the memory for the buffer. - - @retval EFI_SUCCESS The region's attributes were successfully modified. - @retval EFI_INVALID_PARAMETER If Start or Length describe an address not in the Legacy Region. - -**/ -EFI_STATUS -EFIAPI -LegacyRegionGetInfo ( - IN EFI_LEGACY_REGION2_PROTOCOL *This, - OUT UINT32 *DescriptorCount, - OUT EFI_LEGACY_REGION_DESCRIPTOR **Descriptor - ); - -#endif - diff --git a/OvmfPkg/DecomprScratchEnd.fdf.inc b/OvmfPkg/DecomprScratchEnd.fdf.inc deleted file mode 100644 index eb5cd49470..0000000000 --- a/OvmfPkg/DecomprScratchEnd.fdf.inc +++ /dev/null @@ -1,72 +0,0 @@ -## @file -# This FDF include file computes the end of the scratch buffer used in -# DecompressMemFvs() [OvmfPkg/Sec/SecMain.c]. It is based on the decompressed -# (ie. original) size of the LZMA-compressed section of the one FFS file in -# the FVMAIN_COMPACT firmware volume. -# -# Copyright (C) 2015, 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. -## - -# The GUID EE4E5898-3914-4259-9D6E-DC7BD79403CF means "LzmaCustomDecompress". -# The decompressed output will have the following structure (see the file -# "9E21FD93-9C72-4c15-8C4B-E77F1DB2D792SEC1.guided.dummy" in the -# Build/Ovmf*/*/FV/Ffs/9E21FD93-9C72-4c15-8C4B-E77F1DB2D792/ directory): -# -# Size Contents -# ------------------- -------------------------------------------------------- -# 4 EFI_COMMON_SECTION_HEADER, stating size 124 (0x7C) and -# type 0x19 (EFI_SECTION_RAW). The purpose of this section -# is to pad the start of PEIFV to 128 bytes. -# 120 Zero bytes (padding). -# -# 4 EFI_COMMON_SECTION_HEADER, stating size -# (PcdOvmfPeiMemFvSize + 4), and type 0x17 -# (EFI_SECTION_FIRMWARE_VOLUME_IMAGE). -# PcdOvmfPeiMemFvSize PEIFV. Note that the above sizes pad the offset of this -# object to 128 bytes. See also the "guided.dummy.txt" -# file in the same directory. -# -# 4 EFI_COMMON_SECTION_HEADER, stating size 12 (0xC) and -# type 0x19 (EFI_SECTION_RAW). The purpose of this section -# is to pad the start of DXEFV to 16 bytes. -# 8 Zero bytes (padding). -# -# 4 EFI_COMMON_SECTION_HEADER, stating size -# (PcdOvmfDxeMemFvSize + 4), and type 0x17 -# (EFI_SECTION_FIRMWARE_VOLUME_IMAGE). -# PcdOvmfDxeMemFvSize DXEFV. Note that the above sizes pad the offset of this -# object to 16 bytes. See also the "guided.dummy.txt" file -# in the same directory. -# -# The total size after decompression is (128 + PcdOvmfPeiMemFvSize + 16 + -# PcdOvmfDxeMemFvSize). - -DEFINE OUTPUT_SIZE = (128 + gUefiOvmfPkgTokenSpaceGuid.PcdOvmfPeiMemFvSize + 16 + gUefiOvmfPkgTokenSpaceGuid.PcdOvmfDxeMemFvSize) - -# LzmaCustomDecompressLib uses a constant scratch buffer size of 64KB; see -# SCRATCH_BUFFER_REQUEST_SIZE in -# "MdeModulePkg/Library/LzmaCustomDecompressLib/LzmaDecompress.c". - -DEFINE DECOMP_SCRATCH_SIZE = 0x00010000 - -# Note: when we use PcdOvmfDxeMemFvBase in this context, BaseTools have not yet -# offset it with MEMFD's base address. For that reason we have to do it manually. -# -# The calculation below mirrors DecompressMemFvs() [OvmfPkg/Sec/SecMain.c]. - -DEFINE OUTPUT_BASE = ($(MEMFD_BASE_ADDRESS) + gUefiOvmfPkgTokenSpaceGuid.PcdOvmfDxeMemFvBase + 0x00100000) -DEFINE DECOMP_SCRATCH_BASE_UNALIGNED = ($(OUTPUT_BASE) + $(OUTPUT_SIZE)) -DEFINE DECOMP_SCRATCH_BASE_ALIGNMENT = 0x000FFFFF -DEFINE DECOMP_SCRATCH_BASE_MASK = 0xFFF00000 -DEFINE DECOMP_SCRATCH_BASE = (($(DECOMP_SCRATCH_BASE_UNALIGNED) + $(DECOMP_SCRATCH_BASE_ALIGNMENT)) & $(DECOMP_SCRATCH_BASE_MASK)) - -SET gUefiOvmfPkgTokenSpaceGuid.PcdOvmfDecompressionScratchEnd = $(DECOMP_SCRATCH_BASE) + $(DECOMP_SCRATCH_SIZE) diff --git a/OvmfPkg/EmuVariableFvbRuntimeDxe/Fvb.c b/OvmfPkg/EmuVariableFvbRuntimeDxe/Fvb.c deleted file mode 100644 index dec6d4af50..0000000000 --- a/OvmfPkg/EmuVariableFvbRuntimeDxe/Fvb.c +++ /dev/null @@ -1,923 +0,0 @@ -/** @file - Firmware Block Services to support emulating non-volatile variables - by pretending that a memory buffer is storage for the NV variables. - - Copyright (c) 2006 - 2013, Intel Corporation. All rights reserved.
- This program and the accompanying materials - are licensed and made available under the terms and conditions of the BSD License - which accompanies this distribution. The full text of the license may be found at - http://opensource.org/licenses/bsd-license.php - - THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, - WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. - -**/ - -#include "PiDxe.h" -#include -#include -#include - -#include -#include - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include "Fvb.h" - -#define EFI_AUTHENTICATED_VARIABLE_GUID \ -{ 0xaaf32c78, 0x947b, 0x439a, { 0xa1, 0x80, 0x2e, 0x14, 0x4e, 0xc3, 0x77, 0x92 } } - -// -// Virtual Address Change Event -// -// This is needed for runtime variable access. -// -EFI_EVENT mEmuVarsFvbAddrChangeEvent = NULL; - -// -// This is the single instance supported by this driver. It -// supports the FVB and Device Path protocols. -// -EFI_FW_VOL_BLOCK_DEVICE mEmuVarsFvb = { - FVB_DEVICE_SIGNATURE, - { // DevicePath - { - { - HARDWARE_DEVICE_PATH, - HW_MEMMAP_DP, - { - sizeof (MEMMAP_DEVICE_PATH), - 0 - } - }, - EfiMemoryMappedIO, - 0, - 0, - }, - { - END_DEVICE_PATH_TYPE, - END_ENTIRE_DEVICE_PATH_SUBTYPE, - { - sizeof (EFI_DEVICE_PATH_PROTOCOL), - 0 - } - } - }, - NULL, // BufferPtr - FixedPcdGet32 (PcdFlashNvStorageFtwSpareSize), // BlockSize - 2 * FixedPcdGet32 (PcdFlashNvStorageFtwSpareSize), // Size - { // FwVolBlockInstance - FvbProtocolGetAttributes, - FvbProtocolSetAttributes, - FvbProtocolGetPhysicalAddress, - FvbProtocolGetBlockSize, - FvbProtocolRead, - FvbProtocolWrite, - FvbProtocolEraseBlocks, - NULL - }, -}; - - -/** - Notification function of EVT_SIGNAL_VIRTUAL_ADDRESS_CHANGE. - - This is a notification function registered on EVT_SIGNAL_VIRTUAL_ADDRESS_CHANGE event. - It converts pointer to new virtual address. - - @param Event Event whose notification function is being invoked. - @param Context Pointer to the notification function's context. - -**/ -VOID -EFIAPI -FvbVirtualAddressChangeEvent ( - IN EFI_EVENT Event, - IN VOID *Context - ) -{ - EfiConvertPointer (0x0, &mEmuVarsFvb.BufferPtr); -} - - -// -// FVB protocol APIs -// - -/** - The GetPhysicalAddress() function retrieves the base address of - a memory-mapped firmware volume. This function should be called - only for memory-mapped firmware volumes. - - @param This Indicates the EFI_FIRMWARE_VOLUME_BLOCK2_PROTOCOL instance. - - @param Address Pointer to a caller-allocated - EFI_PHYSICAL_ADDRESS that, on successful - return from GetPhysicalAddress(), contains the - base address of the firmware volume. - - @retval EFI_SUCCESS The firmware volume base address is returned. - - @retval EFI_NOT_SUPPORTED The firmware volume is not memory mapped. - -**/ -EFI_STATUS -EFIAPI -FvbProtocolGetPhysicalAddress ( - IN CONST EFI_FIRMWARE_VOLUME_BLOCK2_PROTOCOL *This, - OUT EFI_PHYSICAL_ADDRESS *Address - ) -{ - EFI_FW_VOL_BLOCK_DEVICE *FvbDevice; - - FvbDevice = FVB_DEVICE_FROM_THIS (This); - - *Address = (EFI_PHYSICAL_ADDRESS)(UINTN) FvbDevice->BufferPtr; - - return EFI_SUCCESS; -} - - -/** - The GetBlockSize() function retrieves the size of the requested - block. It also returns the number of additional blocks with - the identical size. The GetBlockSize() function is used to - retrieve the block map (see EFI_FIRMWARE_VOLUME_HEADER). - - - @param This Indicates the EFI_FIRMWARE_VOLUME_BLOCK2_PROTOCOL instance. - - @param Lba Indicates the block for which to return the size. - - @param BlockSize Pointer to a caller-allocated UINTN in which - the size of the block is returned. - - @param NumberOfBlocks Pointer to a caller-allocated UINTN in - which the number of consecutive blocks, - starting with Lba, is returned. All - blocks in this range have a size of - BlockSize. - - - @retval EFI_SUCCESS The firmware volume base address is returned. - - @retval EFI_INVALID_PARAMETER The requested LBA is out of range. - -**/ -EFI_STATUS -EFIAPI -FvbProtocolGetBlockSize ( - IN CONST EFI_FIRMWARE_VOLUME_BLOCK2_PROTOCOL *This, - IN EFI_LBA Lba, - OUT UINTN *BlockSize, - OUT UINTN *NumberOfBlocks - ) -{ - EFI_FW_VOL_BLOCK_DEVICE *FvbDevice; - - if (Lba > 1) { - return EFI_INVALID_PARAMETER; - } - - FvbDevice = FVB_DEVICE_FROM_THIS (This); - - *BlockSize = FvbDevice->BlockSize; - *NumberOfBlocks = (UINTN) (2 - (UINTN) Lba); - - return EFI_SUCCESS; -} - - -/** - The GetAttributes() function retrieves the attributes and - current settings of the block. Status Codes Returned - - @param This Indicates the EFI_FIRMWARE_VOLUME_BLOCK2_PROTOCOL instance. - - @param Attributes Pointer to EFI_FVB_ATTRIBUTES_2 in which the - attributes and current settings are - returned. Type EFI_FVB_ATTRIBUTES_2 is defined - in EFI_FIRMWARE_VOLUME_HEADER. - - @retval EFI_SUCCESS The firmware volume attributes were - returned. - -**/ -EFI_STATUS -EFIAPI -FvbProtocolGetAttributes ( - IN CONST EFI_FIRMWARE_VOLUME_BLOCK2_PROTOCOL *This, - OUT EFI_FVB_ATTRIBUTES_2 *Attributes - ) -{ - *Attributes = - (EFI_FVB_ATTRIBUTES_2) ( - EFI_FVB2_READ_ENABLED_CAP | - EFI_FVB2_READ_STATUS | - EFI_FVB2_WRITE_ENABLED_CAP | - EFI_FVB2_WRITE_STATUS | - EFI_FVB2_ERASE_POLARITY - ); - - return EFI_SUCCESS; -} - - -/** - The SetAttributes() function sets configurable firmware volume - attributes and returns the new settings of the firmware volume. - - @param This Indicates the EFI_FIRMWARE_VOLUME_BLOCK2_PROTOCOL instance. - - @param Attributes On input, Attributes is a pointer to - EFI_FVB_ATTRIBUTES_2 that contains the - desired firmware volume settings. On - successful return, it contains the new - settings of the firmware volume. Type - EFI_FVB_ATTRIBUTES_2 is defined in - EFI_FIRMWARE_VOLUME_HEADER. - - @retval EFI_SUCCESS The firmware volume attributes were returned. - - @retval EFI_INVALID_PARAMETER The attributes requested are in - conflict with the capabilities - as declared in the firmware - volume header. - -**/ -EFI_STATUS -EFIAPI -FvbProtocolSetAttributes ( - IN CONST EFI_FIRMWARE_VOLUME_BLOCK2_PROTOCOL *This, - IN OUT EFI_FVB_ATTRIBUTES_2 *Attributes - ) -{ - return EFI_ACCESS_DENIED; -} - - -/** - Erases and initializes a firmware volume block. - - The EraseBlocks() function erases one or more blocks as denoted - by the variable argument list. The entire parameter list of - blocks must be verified before erasing any blocks. If a block is - requested that does not exist within the associated firmware - volume (it has a larger index than the last block of the - firmware volume), the EraseBlocks() function must return the - status code EFI_INVALID_PARAMETER without modifying the contents - of the firmware volume. Implementations should be mindful that - the firmware volume might be in the WriteDisabled state. If it - is in this state, the EraseBlocks() function must return the - status code EFI_ACCESS_DENIED without modifying the contents of - the firmware volume. All calls to EraseBlocks() must be fully - flushed to the hardware before the EraseBlocks() service - returns. - - @param This Indicates the EFI_FIRMWARE_VOLUME_BLOCK2_PROTOCOL - instance. - - @param ... The variable argument list is a list of tuples. - Each tuple describes a range of LBAs to erase - and consists of the following: - - An EFI_LBA that indicates the starting LBA - - A UINTN that indicates the number of blocks to - erase - - The list is terminated with an - EFI_LBA_LIST_TERMINATOR. For example, the - following indicates that two ranges of blocks - (5-7 and 10-11) are to be erased: EraseBlocks - (This, 5, 3, 10, 2, EFI_LBA_LIST_TERMINATOR); - - @retval EFI_SUCCESS The erase request was successfully - completed. - - @retval EFI_ACCESS_DENIED The firmware volume is in the - WriteDisabled state. - @retval EFI_DEVICE_ERROR The block device is not functioning - correctly and could not be written. - The firmware device may have been - partially erased. - @retval EFI_INVALID_PARAMETER One or more of the LBAs listed - in the variable argument list do - not exist in the firmware volume. - -**/ -EFI_STATUS -EFIAPI -FvbProtocolEraseBlocks ( - IN CONST EFI_FIRMWARE_VOLUME_BLOCK2_PROTOCOL *This, - ... - ) -{ - EFI_FW_VOL_BLOCK_DEVICE *FvbDevice; - VA_LIST args; - EFI_LBA StartingLba; - UINTN NumOfLba; - UINT8 Erase; - VOID *ErasePtr; - UINTN EraseSize; - - FvbDevice = FVB_DEVICE_FROM_THIS (This); - Erase = 0; - - VA_START (args, This); - - do { - StartingLba = VA_ARG (args, EFI_LBA); - if (StartingLba == EFI_LBA_LIST_TERMINATOR) { - break; - } - - NumOfLba = VA_ARG (args, UINT32); - - // - // Check input parameters - // - if ((NumOfLba == 0) || (StartingLba > 1) || ((StartingLba + NumOfLba) > 2)) { - VA_END (args); - return EFI_INVALID_PARAMETER; - } - - if (StartingLba == 0) { - Erase = (UINT8) (Erase | BIT0); - } - if ((StartingLba + NumOfLba) == 2) { - Erase = (UINT8) (Erase | BIT1); - } - - } while (1); - - VA_END (args); - - ErasePtr = (UINT8*) FvbDevice->BufferPtr; - EraseSize = 0; - - if ((Erase & BIT0) != 0) { - EraseSize = EraseSize + FvbDevice->BlockSize; - } else { - ErasePtr = (VOID*) ((UINT8*)ErasePtr + FvbDevice->BlockSize); - } - - if ((Erase & BIT1) != 0) { - EraseSize = EraseSize + FvbDevice->BlockSize; - } - - if (EraseSize != 0) { - SetMem ( - (VOID*) ErasePtr, - EraseSize, - ERASED_UINT8 - ); - VA_START (args, This); - PlatformFvbBlocksErased (This, args); - VA_END (args); - } - - return EFI_SUCCESS; -} - - -/** - Writes the specified number of bytes from the input buffer to the block. - - The Write() function writes the specified number of bytes from - the provided buffer to the specified block and offset. If the - firmware volume is sticky write, the caller must ensure that - all the bits of the specified range to write are in the - EFI_FVB_ERASE_POLARITY state before calling the Write() - function, or else the result will be unpredictable. This - unpredictability arises because, for a sticky-write firmware - volume, a write may negate a bit in the EFI_FVB_ERASE_POLARITY - state but cannot flip it back again. In general, before - calling the Write() function, the caller should call the - EraseBlocks() function first to erase the specified block to - write. A block erase cycle will transition bits from the - (NOT)EFI_FVB_ERASE_POLARITY state back to the - EFI_FVB_ERASE_POLARITY state. Implementations should be - mindful that the firmware volume might be in the WriteDisabled - state. If it is in this state, the Write() function must - return the status code EFI_ACCESS_DENIED without modifying the - contents of the firmware volume. The Write() function must - also prevent spanning block boundaries. If a write is - requested that spans a block boundary, the write must store up - to the boundary but not beyond. The output parameter NumBytes - must be set to correctly indicate the number of bytes actually - written. The caller must be aware that a write may be - partially completed. All writes, partial or otherwise, must be - fully flushed to the hardware before the Write() service - returns. - - @param This Indicates the EFI_FIRMWARE_VOLUME_BLOCK2_PROTOCOL instance. - - @param Lba The starting logical block index to write to. - - @param Offset Offset into the block at which to begin writing. - - @param NumBytes Pointer to a UINTN. At entry, *NumBytes - contains the total size of the buffer. At - exit, *NumBytes contains the total number of - bytes actually written. - - @param Buffer Pointer to a caller-allocated buffer that - contains the source for the write. - - @retval EFI_SUCCESS The firmware volume was written successfully. - - @retval EFI_BAD_BUFFER_SIZE The write was attempted across an - LBA boundary. On output, NumBytes - contains the total number of bytes - actually written. - - @retval EFI_ACCESS_DENIED The firmware volume is in the - WriteDisabled state. - - @retval EFI_DEVICE_ERROR The block device is malfunctioning - and could not be written. - - -**/ -EFI_STATUS -EFIAPI -FvbProtocolWrite ( - IN CONST EFI_FIRMWARE_VOLUME_BLOCK2_PROTOCOL *This, - IN EFI_LBA Lba, - IN UINTN Offset, - IN OUT UINTN *NumBytes, - IN UINT8 *Buffer - ) -{ - - EFI_FW_VOL_BLOCK_DEVICE *FvbDevice; - UINT8 *FvbDataPtr; - - FvbDevice = FVB_DEVICE_FROM_THIS (This); - - if ((Lba > 1) || (Offset > FvbDevice->BlockSize)) { - return EFI_INVALID_PARAMETER; - } - - if ((Offset + *NumBytes) > FvbDevice->BlockSize) { - *NumBytes = FvbDevice->BlockSize - Offset; - } - - FvbDataPtr = - (UINT8*) FvbDevice->BufferPtr + - MultU64x32 (Lba, (UINT32) FvbDevice->BlockSize) + - Offset; - - if (*NumBytes > 0) { - CopyMem (FvbDataPtr, Buffer, *NumBytes); - PlatformFvbDataWritten (This, Lba, Offset, *NumBytes, Buffer); - } - - return EFI_SUCCESS; -} - - -/** - Reads the specified number of bytes into a buffer from the specified block. - - The Read() function reads the requested number of bytes from the - requested block and stores them in the provided buffer. - Implementations should be mindful that the firmware volume - might be in the ReadDisabled state. If it is in this state, - the Read() function must return the status code - EFI_ACCESS_DENIED without modifying the contents of the - buffer. The Read() function must also prevent spanning block - boundaries. If a read is requested that would span a block - boundary, the read must read up to the boundary but not - beyond. The output parameter NumBytes must be set to correctly - indicate the number of bytes actually read. The caller must be - aware that a read may be partially completed. - - @param This Indicates the EFI_FIRMWARE_VOLUME_BLOCK2_PROTOCOL instance. - - @param Lba The starting logical block index - from which to read. - - @param Offset Offset into the block at which to begin reading. - - @param NumBytes Pointer to a UINTN. At entry, *NumBytes - contains the total size of the buffer. At - exit, *NumBytes contains the total number of - bytes read. - - @param Buffer Pointer to a caller-allocated buffer that will - be used to hold the data that is read. - - @retval EFI_SUCCESS The firmware volume was read successfully - and contents are in Buffer. - - @retval EFI_BAD_BUFFER_SIZE Read attempted across an LBA - boundary. On output, NumBytes - contains the total number of bytes - returned in Buffer. - - @retval EFI_ACCESS_DENIED The firmware volume is in the - ReadDisabled state. - - @retval EFI_DEVICE_ERROR The block device is not - functioning correctly and could - not be read. - -**/ -EFI_STATUS -EFIAPI -FvbProtocolRead ( - IN CONST EFI_FIRMWARE_VOLUME_BLOCK2_PROTOCOL *This, - IN EFI_LBA Lba, - IN UINTN Offset, - IN OUT UINTN *NumBytes, - IN OUT UINT8 *Buffer - ) -{ - EFI_FW_VOL_BLOCK_DEVICE *FvbDevice; - UINT8 *FvbDataPtr; - - FvbDevice = FVB_DEVICE_FROM_THIS (This); - - if ((Lba > 1) || (Offset > FvbDevice->BlockSize)) { - return EFI_INVALID_PARAMETER; - } - - if ((Offset + *NumBytes) > FvbDevice->BlockSize) { - *NumBytes = FvbDevice->BlockSize - Offset; - } - - FvbDataPtr = - (UINT8*) FvbDevice->BufferPtr + - MultU64x32 (Lba, (UINT32) FvbDevice->BlockSize) + - Offset; - - if (*NumBytes > 0) { - CopyMem (Buffer, FvbDataPtr, *NumBytes); - PlatformFvbDataRead (This, Lba, Offset, *NumBytes, Buffer); - } - - return EFI_SUCCESS; -} - - -/** - Check the integrity of firmware volume header. - - @param[in] FwVolHeader - A pointer to a firmware volume header - - @retval EFI_SUCCESS - The firmware volume is consistent - @retval EFI_NOT_FOUND - The firmware volume has been corrupted. - -**/ -EFI_STATUS -ValidateFvHeader ( - IN EFI_FIRMWARE_VOLUME_HEADER *FwVolHeader - ) -{ - UINT16 Checksum; - - // - // Verify the header revision, header signature, length - // Length of FvBlock cannot be 2**64-1 - // HeaderLength cannot be an odd number - // - if ((FwVolHeader->Revision != EFI_FVH_REVISION) || - (FwVolHeader->Signature != EFI_FVH_SIGNATURE) || - (FwVolHeader->FvLength != EMU_FVB_SIZE) || - (FwVolHeader->HeaderLength != EMU_FV_HEADER_LENGTH) - ) { - DEBUG ((EFI_D_INFO, "EMU Variable FVB: Basic FV headers were invalid\n")); - return EFI_NOT_FOUND; - } - // - // Verify the header checksum - // - Checksum = CalculateSum16((VOID*) FwVolHeader, FwVolHeader->HeaderLength); - - if (Checksum != 0) { - DEBUG ((EFI_D_INFO, "EMU Variable FVB: FV checksum was invalid\n")); - return EFI_NOT_FOUND; - } - - return EFI_SUCCESS; -} - - -/** - Initializes the FV Header and Variable Store Header - to support variable operations. - - @param[in] Ptr - Location to initialize the headers - -**/ -VOID -InitializeFvAndVariableStoreHeaders ( - IN VOID *Ptr - ) -{ - // - // Templates for standard (non-authenticated) variable FV header - // - STATIC FVB_FV_HDR_AND_VARS_TEMPLATE FvAndVarTemplate = { - { // EFI_FIRMWARE_VOLUME_HEADER FvHdr; - // UINT8 ZeroVector[16]; - { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }, - - // EFI_GUID FileSystemGuid; - EFI_SYSTEM_NV_DATA_FV_GUID, - - // UINT64 FvLength; - EMU_FVB_SIZE, - - // UINT32 Signature; - EFI_FVH_SIGNATURE, - - // EFI_FVB_ATTRIBUTES_2 Attributes; - 0x4feff, - - // UINT16 HeaderLength; - EMU_FV_HEADER_LENGTH, - - // UINT16 Checksum; - 0, - - // UINT16 ExtHeaderOffset; - 0, - - // UINT8 Reserved[1]; - {0}, - - // UINT8 Revision; - EFI_FVH_REVISION, - - // EFI_FV_BLOCK_MAP_ENTRY BlockMap[1]; - { - { - 2, // UINT32 NumBlocks; - EMU_FVB_BLOCK_SIZE // UINT32 Length; - } - } - }, - // EFI_FV_BLOCK_MAP_ENTRY EndBlockMap; - { 0, 0 }, // End of block map - { // VARIABLE_STORE_HEADER VarHdr; - // EFI_GUID Signature; - EFI_VARIABLE_GUID, - - // UINT32 Size; - ( - FixedPcdGet32 (PcdVariableStoreSize) - - OFFSET_OF (FVB_FV_HDR_AND_VARS_TEMPLATE, VarHdr) - ), - - // UINT8 Format; - VARIABLE_STORE_FORMATTED, - - // UINT8 State; - VARIABLE_STORE_HEALTHY, - - // UINT16 Reserved; - 0, - - // UINT32 Reserved1; - 0 - } - }; - - // - // Templates for authenticated variable FV header - // - STATIC FVB_FV_HDR_AND_VARS_TEMPLATE FvAndAuthenticatedVarTemplate = { - { // EFI_FIRMWARE_VOLUME_HEADER FvHdr; - // UINT8 ZeroVector[16]; - { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }, - - // EFI_GUID FileSystemGuid; - EFI_SYSTEM_NV_DATA_FV_GUID, - - // UINT64 FvLength; - EMU_FVB_SIZE, - - // UINT32 Signature; - EFI_FVH_SIGNATURE, - - // EFI_FVB_ATTRIBUTES_2 Attributes; - 0x4feff, - - // UINT16 HeaderLength; - EMU_FV_HEADER_LENGTH, - - // UINT16 Checksum; - 0, - - // UINT16 ExtHeaderOffset; - 0, - - // UINT8 Reserved[1]; - {0}, - - // UINT8 Revision; - EFI_FVH_REVISION, - - // EFI_FV_BLOCK_MAP_ENTRY BlockMap[1]; - { - { - 2, // UINT32 NumBlocks; - EMU_FVB_BLOCK_SIZE // UINT32 Length; - } - } - }, - // EFI_FV_BLOCK_MAP_ENTRY EndBlockMap; - { 0, 0 }, // End of block map - { // VARIABLE_STORE_HEADER VarHdr; - // EFI_GUID Signature; // need authenticated variables for secure boot - EFI_AUTHENTICATED_VARIABLE_GUID, - - // UINT32 Size; - ( - FixedPcdGet32 (PcdVariableStoreSize) - - OFFSET_OF (FVB_FV_HDR_AND_VARS_TEMPLATE, VarHdr) - ), - - // UINT8 Format; - VARIABLE_STORE_FORMATTED, - - // UINT8 State; - VARIABLE_STORE_HEALTHY, - - // UINT16 Reserved; - 0, - - // UINT32 Reserved1; - 0 - } - }; - - EFI_FIRMWARE_VOLUME_HEADER *Fv; - - // - // Copy the template structure into the location - // - if (FeaturePcdGet (PcdSecureBootEnable) == FALSE) { - CopyMem (Ptr, (VOID*)&FvAndVarTemplate, sizeof (FvAndVarTemplate)); - } else { - CopyMem (Ptr, (VOID*)&FvAndAuthenticatedVarTemplate, sizeof (FvAndAuthenticatedVarTemplate)); - } - - // - // Update the checksum for the FV header - // - Fv = (EFI_FIRMWARE_VOLUME_HEADER*) Ptr; - Fv->Checksum = CalculateCheckSum16 (Ptr, Fv->HeaderLength); -} - -/** - Main entry point. - - @param[in] ImageHandle The firmware allocated handle for the EFI image. - @param[in] SystemTable A pointer to the EFI System Table. - - @retval EFI_SUCCESS Successfully initialized. - -**/ -EFI_STATUS -EFIAPI -FvbInitialize ( - IN EFI_HANDLE ImageHandle, - IN EFI_SYSTEM_TABLE *SystemTable - ) -{ - EFI_STATUS Status; - VOID *Ptr; - VOID *SubPtr; - BOOLEAN Initialize; - EFI_HANDLE Handle; - EFI_PHYSICAL_ADDRESS Address; - RETURN_STATUS PcdStatus; - - DEBUG ((EFI_D_INFO, "EMU Variable FVB Started\n")); - - // - // Verify that the PCD's are set correctly. - // - if ( - (PcdGet32 (PcdVariableStoreSize) + - PcdGet32 (PcdFlashNvStorageFtwWorkingSize) - ) > - EMU_FVB_BLOCK_SIZE - ) { - DEBUG ((EFI_D_ERROR, "EMU Variable invalid PCD sizes\n")); - return EFI_INVALID_PARAMETER; - } - - if (PcdGet64 (PcdFlashNvStorageVariableBase64) != 0) { - DEBUG ((EFI_D_INFO, "Disabling EMU Variable FVB since " - "flash variables appear to be supported.\n")); - return EFI_ABORTED; - } - - // - // By default we will initialize the FV contents. But, if - // PcdEmuVariableNvStoreReserved is non-zero, then we will - // use this location for our buffer. - // - // If this location does not have a proper FV header, then - // we will initialize it. - // - Initialize = TRUE; - if (PcdGet64 (PcdEmuVariableNvStoreReserved) != 0) { - Ptr = (VOID*)(UINTN) PcdGet64 (PcdEmuVariableNvStoreReserved); - DEBUG (( - EFI_D_INFO, - "EMU Variable FVB: Using pre-reserved block at %p\n", - Ptr - )); - Status = ValidateFvHeader (Ptr); - if (!EFI_ERROR (Status)) { - DEBUG ((EFI_D_INFO, "EMU Variable FVB: Found valid pre-existing FV\n")); - Initialize = FALSE; - } - } else { - Ptr = AllocateAlignedRuntimePages ( - EFI_SIZE_TO_PAGES (EMU_FVB_SIZE), - SIZE_64KB - ); - } - - mEmuVarsFvb.BufferPtr = Ptr; - - // - // Initialize the main FV header and variable store header - // - if (Initialize) { - SetMem (Ptr, EMU_FVB_SIZE, ERASED_UINT8); - InitializeFvAndVariableStoreHeaders (Ptr); - } - PcdStatus = PcdSet64S (PcdFlashNvStorageVariableBase64, (UINT32)(UINTN) Ptr); - ASSERT_RETURN_ERROR (PcdStatus); - - // - // Initialize the Fault Tolerant Write data area - // - SubPtr = (VOID*) ((UINT8*) Ptr + PcdGet32 (PcdVariableStoreSize)); - PcdStatus = PcdSet32S (PcdFlashNvStorageFtwWorkingBase, - (UINT32)(UINTN) SubPtr); - ASSERT_RETURN_ERROR (PcdStatus); - - // - // Initialize the Fault Tolerant Write spare block - // - SubPtr = (VOID*) ((UINT8*) Ptr + EMU_FVB_BLOCK_SIZE); - PcdStatus = PcdSet32S (PcdFlashNvStorageFtwSpareBase, - (UINT32)(UINTN) SubPtr); - ASSERT_RETURN_ERROR (PcdStatus); - - // - // Setup FVB device path - // - Address = (EFI_PHYSICAL_ADDRESS)(UINTN) Ptr; - mEmuVarsFvb.DevicePath.MemMapDevPath.StartingAddress = Address; - mEmuVarsFvb.DevicePath.MemMapDevPath.EndingAddress = Address + EMU_FVB_SIZE - 1; - - // - // Install the protocols - // - DEBUG ((EFI_D_INFO, "Installing FVB for EMU Variable support\n")); - Handle = 0; - Status = gBS->InstallMultipleProtocolInterfaces ( - &Handle, - &gEfiFirmwareVolumeBlock2ProtocolGuid, - &mEmuVarsFvb.FwVolBlockInstance, - &gEfiDevicePathProtocolGuid, - &mEmuVarsFvb.DevicePath, - NULL - ); - ASSERT_EFI_ERROR (Status); - - // - // Register for the virtual address change event - // - Status = gBS->CreateEventEx ( - EVT_NOTIFY_SIGNAL, - TPL_NOTIFY, - FvbVirtualAddressChangeEvent, - NULL, - &gEfiEventVirtualAddressChangeGuid, - &mEmuVarsFvbAddrChangeEvent - ); - ASSERT_EFI_ERROR (Status); - - return EFI_SUCCESS; -} - - diff --git a/OvmfPkg/EmuVariableFvbRuntimeDxe/Fvb.h b/OvmfPkg/EmuVariableFvbRuntimeDxe/Fvb.h deleted file mode 100644 index f34fad2cdd..0000000000 --- a/OvmfPkg/EmuVariableFvbRuntimeDxe/Fvb.h +++ /dev/null @@ -1,140 +0,0 @@ -/*++ - -Copyright (c) 2006, Intel Corporation. All rights reserved.
-This program and the accompanying materials -are licensed and made available under the terms and conditions of the BSD License -which accompanies this distribution. The full text of the license may be found at -http://opensource.org/licenses/bsd-license.php - -THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, -WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. - -Module Name: - - FwBlockService.h - -Abstract: - - Firmware volume block driver for Intel Firmware Hub (FWH) device - ---*/ - -#ifndef _FW_BLOCK_SERVICE_H -#define _FW_BLOCK_SERVICE_H - -// -// Fvb Protocol instance data -// -#define FVB_DEVICE_FROM_THIS(a) CR (a, EFI_FW_VOL_BLOCK_DEVICE, FwVolBlockInstance, FVB_DEVICE_SIGNATURE) -#define FVB_DEVICE_SIGNATURE SIGNATURE_32 ('F', 'V', 'B', 'N') - -#pragma pack (1) - -typedef struct { - - EFI_FIRMWARE_VOLUME_HEADER FvHdr; - EFI_FV_BLOCK_MAP_ENTRY EndBlockMap; - VARIABLE_STORE_HEADER VarHdr; - -} FVB_FV_HDR_AND_VARS_TEMPLATE; - -typedef struct { - MEMMAP_DEVICE_PATH MemMapDevPath; - EFI_DEVICE_PATH_PROTOCOL EndDevPath; -} FV_DEVICE_PATH; - -#pragma pack () - -typedef struct { - UINTN Signature; - FV_DEVICE_PATH DevicePath; - VOID *BufferPtr; - UINTN BlockSize; - UINTN Size; - EFI_FIRMWARE_VOLUME_BLOCK_PROTOCOL FwVolBlockInstance; -} EFI_FW_VOL_BLOCK_DEVICE; - - -// -// Constants -// -#define EMU_FVB_BLOCK_SIZE (FixedPcdGet32 (PcdFlashNvStorageFtwSpareSize)) -#define EMU_FVB_SIZE (2 * FixedPcdGet32 (PcdFlashNvStorageFtwSpareSize)) -#define FTW_WRITE_QUEUE_SIZE \ - (FixedPcdGet32 (PcdFlashNvStorageFtwWorkingSize) - \ - sizeof (EFI_FAULT_TOLERANT_WORKING_BLOCK_HEADER)) -#define EMU_FV_HEADER_LENGTH OFFSET_OF (FVB_FV_HDR_AND_VARS_TEMPLATE, VarHdr) - -#define NOT_ERASED_BIT 0 -#define ERASED_BIT 1 -#define ERASED_UINT8 0xff -#define ERASED_UINT32 0xffffffff - -// -// Protocol APIs -// -EFI_STATUS -EFIAPI -FvbProtocolGetAttributes ( - IN CONST EFI_FIRMWARE_VOLUME_BLOCK_PROTOCOL *This, - OUT EFI_FVB_ATTRIBUTES_2 *Attributes - ) -; - -EFI_STATUS -EFIAPI -FvbProtocolSetAttributes ( - IN CONST EFI_FIRMWARE_VOLUME_BLOCK_PROTOCOL *This, - IN OUT EFI_FVB_ATTRIBUTES_2 *Attributes - ) -; - -EFI_STATUS -EFIAPI -FvbProtocolGetPhysicalAddress ( - IN CONST EFI_FIRMWARE_VOLUME_BLOCK_PROTOCOL *This, - OUT EFI_PHYSICAL_ADDRESS *Address - ) -; - -EFI_STATUS -EFIAPI -FvbProtocolGetBlockSize ( - IN CONST EFI_FIRMWARE_VOLUME_BLOCK_PROTOCOL *This, - IN EFI_LBA Lba, - OUT UINTN *BlockSize, - OUT UINTN *NumberOfBlocks - ) -; - -EFI_STATUS -EFIAPI -FvbProtocolRead ( - IN CONST EFI_FIRMWARE_VOLUME_BLOCK_PROTOCOL *This, - IN EFI_LBA Lba, - IN UINTN Offset, - IN OUT UINTN *NumBytes, - IN OUT UINT8 *Buffer - ) -; - -EFI_STATUS -EFIAPI -FvbProtocolWrite ( - IN CONST EFI_FIRMWARE_VOLUME_BLOCK_PROTOCOL *This, - IN EFI_LBA Lba, - IN UINTN Offset, - IN OUT UINTN *NumBytes, - IN UINT8 *Buffer - ) -; - -EFI_STATUS -EFIAPI -FvbProtocolEraseBlocks ( - IN CONST EFI_FIRMWARE_VOLUME_BLOCK_PROTOCOL *This, - ... - ) -; - -#endif diff --git a/OvmfPkg/EmuVariableFvbRuntimeDxe/Fvb.inf b/OvmfPkg/EmuVariableFvbRuntimeDxe/Fvb.inf deleted file mode 100644 index 4d4827decb..0000000000 --- a/OvmfPkg/EmuVariableFvbRuntimeDxe/Fvb.inf +++ /dev/null @@ -1,76 +0,0 @@ -## @file -# Firmware Block Services to support emulating non-volatile variables -# by pretending that a memory buffer is storage for the NV variables. -# -# Copyright (c) 2008 - 2011, Intel Corporation. All rights reserved.
-# -# This program and the accompanying materials -# are licensed and made available under the terms and conditions of the BSD License -# which accompanies this distribution. The full text of the license may be found at -# http://opensource.org/licenses/bsd-license.php -# THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, -# WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. -# -## - -[Defines] - INF_VERSION = 0x00010005 - BASE_NAME = EmuVariableFvbRuntimeDxe - FILE_GUID = 22dc2b60-fe40-42ac-b01f-3ab1fad9aad8 - MODULE_TYPE = DXE_RUNTIME_DRIVER - VERSION_STRING = 1.0 - ENTRY_POINT = FvbInitialize - -# -# The following information is for reference only and not required by the build tools. -# -# VALID_ARCHITECTURES = IA32 X64 IPF EBC -# - -[Sources] - Fvb.c - -[Packages] - MdePkg/MdePkg.dec - MdeModulePkg/MdeModulePkg.dec - OvmfPkg/OvmfPkg.dec - -[LibraryClasses] - BaseLib - BaseMemoryLib - DebugLib - DxeServicesTableLib - HobLib - MemoryAllocationLib - PcdLib - PlatformFvbLib - UefiBootServicesTableLib - UefiDriverEntryPoint - UefiLib - UefiRuntimeLib - -[Guids] - gEfiEventVirtualAddressChangeGuid # ALWAYS_CONSUMED Create Event: EVENT_GROUP_GUID - -[Protocols] - gEfiFirmwareVolumeBlock2ProtocolGuid # PROTOCOL ALWAYS_PRODUCED - gEfiDevicePathProtocolGuid # PROTOCOL ALWAYS_PRODUCED - -[FixedPcd] - gEfiMdeModulePkgTokenSpaceGuid.PcdVariableStoreSize - gEfiMdeModulePkgTokenSpaceGuid.PcdFlashNvStorageFtwWorkingSize - gEfiMdeModulePkgTokenSpaceGuid.PcdFlashNvStorageFtwSpareSize - -[Pcd] - gEfiMdeModulePkgTokenSpaceGuid.PcdFlashNvStorageVariableSize - gEfiMdeModulePkgTokenSpaceGuid.PcdFlashNvStorageVariableBase64 - gEfiMdeModulePkgTokenSpaceGuid.PcdFlashNvStorageFtwWorkingBase - gEfiMdeModulePkgTokenSpaceGuid.PcdFlashNvStorageFtwSpareBase - gEfiMdeModulePkgTokenSpaceGuid.PcdEmuVariableNvStoreReserved - -[FeaturePcd] - gUefiOvmfPkgTokenSpaceGuid.PcdSecureBootEnable - -[Depex] - TRUE - diff --git a/OvmfPkg/Include/Guid/OvmfPlatformConfig.h b/OvmfPkg/Include/Guid/OvmfPlatformConfig.h deleted file mode 100644 index ea3c26c43a..0000000000 --- a/OvmfPkg/Include/Guid/OvmfPlatformConfig.h +++ /dev/null @@ -1,24 +0,0 @@ -/** @file - GUID for UEFI variables that are specific to OVMF configuration. - - Copyright (C) 2014, Red Hat, Inc. - - This program and the accompanying materials are licensed and made available - under the terms and conditions of the BSD License that accompanies this - distribution. The full text of the license may be found at - http://opensource.org/licenses/bsd-license.php. - - THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, WITHOUT - WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. - -**/ - -#ifndef __OVMF_PLATFORM_CONFIG_H__ -#define __OVMF_PLATFORM_CONFIG_H__ - -#define OVMF_PLATFORM_CONFIG_GUID \ -{0x7235c51c, 0x0c80, 0x4cab, {0x87, 0xac, 0x3b, 0x08, 0x4a, 0x63, 0x04, 0xb1}} - -extern EFI_GUID gOvmfPlatformConfigGuid; - -#endif diff --git a/OvmfPkg/Include/Guid/RootBridgesConnectedEventGroup.h b/OvmfPkg/Include/Guid/RootBridgesConnectedEventGroup.h deleted file mode 100644 index b6803d4195..0000000000 --- a/OvmfPkg/Include/Guid/RootBridgesConnectedEventGroup.h +++ /dev/null @@ -1,33 +0,0 @@ -/** @file - An event group GUID with which BDS indicates that PCI root bridges have been - connected, and PciIo protocol instances have become available. - - Note that this differs from the PCI Enumeration Complete Protocol as defined - in the PI 1.1 specification. That protocol is installed by the PCI bus driver - after enumeration and resource allocation have been completed, but before - PciIo protocol instances are created. - - Copyright (C) 2016, 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 _ROOT_BRIDGES_CONNECTED_EVENT_GROUP_H_ -#define _ROOT_BRIDGES_CONNECTED_EVENT_GROUP_H_ - -#define ROOT_BRIDGES_CONNECTED_EVENT_GROUP_GUID \ - { 0x24a2d66f, \ - 0xeedd, \ - 0x4086, \ - { 0x90, 0x42, 0xf2, 0x6e, 0x47, 0x97, 0xee, 0x69 }, \ - } - -extern EFI_GUID gRootBridgesConnectedEventGroupGuid; - -#endif diff --git a/OvmfPkg/Include/Guid/VirtioMmioTransport.h b/OvmfPkg/Include/Guid/VirtioMmioTransport.h deleted file mode 100644 index f17d7b1b42..0000000000 --- a/OvmfPkg/Include/Guid/VirtioMmioTransport.h +++ /dev/null @@ -1,25 +0,0 @@ -/** @file - Recommended GUID to be used in the Vendor Hardware device path nodes that - identify virtio-mmio transports. - - Copyright (C) 2014, Red Hat, Inc. - - This program and the accompanying materials are licensed and made available - under the terms and conditions of the BSD License that accompanies this - distribution. The full text of the license may be found at - http://opensource.org/licenses/bsd-license.php. - - THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, WITHOUT - WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. - -**/ - -#ifndef __VIRTIO_MMIO_TRANSPORT_H__ -#define __VIRTIO_MMIO_TRANSPORT_H__ - -#define VIRTIO_MMIO_TRANSPORT_GUID \ -{0x837dca9e, 0xe874, 0x4d82, {0xb2, 0x9a, 0x23, 0xfe, 0x0e, 0x23, 0xd1, 0xe2}} - -extern EFI_GUID gVirtioMmioTransportGuid; - -#endif diff --git a/OvmfPkg/Include/Guid/XenBusRootDevice.h b/OvmfPkg/Include/Guid/XenBusRootDevice.h deleted file mode 100644 index 2b6e710180..0000000000 --- a/OvmfPkg/Include/Guid/XenBusRootDevice.h +++ /dev/null @@ -1,24 +0,0 @@ -/** @file - GUID to be used to identify the XenBus root node on non-PCI Xen guests - - Copyright (C) 2015, Linaro Ltd. - - This program and the accompanying materials are licensed and made available - under the terms and conditions of the BSD License that accompanies this - distribution. The full text of the license may be found at - http://opensource.org/licenses/bsd-license.php. - - THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, WITHOUT - WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. - -**/ - -#ifndef __XENBUS_ROOT_DEVICE_H__ -#define __XENBUS_ROOT_DEVICE_H__ - -#define XENBUS_ROOT_DEVICE_GUID \ -{0xa732241f, 0x383d, 0x4d9c, {0x8a, 0xe1, 0x8e, 0x09, 0x83, 0x75, 0x89, 0xd7}} - -extern EFI_GUID gXenBusRootDeviceGuid; - -#endif diff --git a/OvmfPkg/Include/Guid/XenInfo.h b/OvmfPkg/Include/Guid/XenInfo.h deleted file mode 100644 index d512b0b63f..0000000000 --- a/OvmfPkg/Include/Guid/XenInfo.h +++ /dev/null @@ -1,42 +0,0 @@ -/** @file - XenInfo HOB passed by PEI into DXE. - -Copyright (c) 2011, Andrei Warkentin -This program and the accompanying materials are licensed and made available under -the terms and conditions of the BSD License that accompanies this distribution. -The full text of the license may be found at -http://opensource.org/licenses/bsd-license.php. - -THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, -WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. - -**/ - -#ifndef __XEN_INFO_H__ -#define __XEN_INFO_H__ - -#define EFI_XEN_INFO_GUID \ - { 0xd3b46f3b, 0xd441, 0x1244, {0x9a, 0x12, 0x0, 0x12, 0x27, 0x3f, 0xc1, 0x4d } } - -typedef struct { - /// - /// Beginning of the hypercall page. - /// - VOID *HyperPages; - /// - /// Location of the hvm_info page. - /// - VOID *HvmInfo; - /// - /// Hypervisor major version. - /// - UINT16 VersionMajor; - /// - /// Hypervisor minor version. - /// - UINT16 VersionMinor; -} EFI_XEN_INFO; - -extern EFI_GUID gEfiXenInfoGuid; - -#endif diff --git a/OvmfPkg/Include/IndustryStandard/E820.h b/OvmfPkg/Include/IndustryStandard/E820.h deleted file mode 100644 index aeafd89f25..0000000000 --- a/OvmfPkg/Include/IndustryStandard/E820.h +++ /dev/null @@ -1,46 +0,0 @@ -/** @file - -Copyright (c) 2013, Citrix Systems UK Ltd. -Copyright (c) 2006 - 2013, Intel Corporation. All rights reserved.
- -This program and the accompanying materials -are licensed and made available under the terms and conditions -of the BSD License which accompanies this distribution. The -full text of the license may be found at -http://opensource.org/licenses/bsd-license.php - -THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, -WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. - -**/ - - -#ifndef __E820_H__ -#define __E820_H__ - -#pragma pack(1) - -typedef enum { - EfiAcpiAddressRangeMemory = 1, - EfiAcpiAddressRangeReserved = 2, - EfiAcpiAddressRangeACPI = 3, - EfiAcpiAddressRangeNVS = 4 -} EFI_ACPI_MEMORY_TYPE; - -typedef struct { - UINT64 BaseAddr; - UINT64 Length; - EFI_ACPI_MEMORY_TYPE Type; -} EFI_E820_ENTRY64; - -typedef struct { - UINT32 BassAddrLow; - UINT32 BaseAddrHigh; - UINT32 LengthLow; - UINT32 LengthHigh; - EFI_ACPI_MEMORY_TYPE Type; -} EFI_E820_ENTRY; - -#pragma pack() - -#endif /* __E820_H__ */ diff --git a/OvmfPkg/Include/IndustryStandard/I440FxPiix4.h b/OvmfPkg/Include/IndustryStandard/I440FxPiix4.h deleted file mode 100644 index baa4c063f1..0000000000 --- a/OvmfPkg/Include/IndustryStandard/I440FxPiix4.h +++ /dev/null @@ -1,42 +0,0 @@ -/** @file - Various register numbers and value bits based on the following publications: - - Intel(R) datasheet 290549-001 - - Intel(R) datasheet 290562-001 - - Intel(R) datasheet 297654-006 - - Intel(R) datasheet 297738-017 - - Copyright (C) 2015, Red Hat, Inc. - Copyright (c) 2014, Gabriel L. Somlo - - This program and the accompanying materials are licensed and made 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 __I440FX_PIIX4_H__ -#define __I440FX_PIIX4_H__ - -#include - -// -// Host Bridge Device ID (DID) value for I440FX -// -#define INTEL_82441_DEVICE_ID 0x1237 - -// -// B/D/F/Type: 0/1/3/PCI -// -#define POWER_MGMT_REGISTER_PIIX4(Offset) PCI_LIB_ADDRESS (0, 1, 3, (Offset)) - -#define PIIX4_PMBA 0x40 -#define PIIX4_PMBA_MASK (BIT15 | BIT14 | BIT13 | BIT12 | BIT11 | \ - BIT10 | BIT9 | BIT8 | BIT7 | BIT6) - -#define PIIX4_PMREGMISC 0x80 -#define PIIX4_PMREGMISC_PMIOSE BIT0 - -#endif diff --git a/OvmfPkg/Include/IndustryStandard/LegacyVgaBios.h b/OvmfPkg/Include/IndustryStandard/LegacyVgaBios.h deleted file mode 100644 index d55d1283f4..0000000000 --- a/OvmfPkg/Include/IndustryStandard/LegacyVgaBios.h +++ /dev/null @@ -1,97 +0,0 @@ -/** @file - Type definitions related to the VBE (VESA BIOS Extension, Int10h AH=4Fh) - services GET INFORMATION (AL=00h) and GET MODE INFORMATION (AL=01h). - - For reference, see Ralf Brown's Interrupt List: - - - - Copyright (C) 2014, 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 __LEGACY_VGA_BIOS_H__ -#define __LEGACY_VGA_BIOS_H__ - -#include - -#pragma pack (1) -typedef struct { - UINT8 Signature[4]; - UINT16 VesaVersion; - UINT32 OemNameAddress; - UINT32 Capabilities; - UINT32 ModeListAddress; - UINT16 VideoMem64K; - UINT16 OemSoftwareVersion; - UINT32 VendorNameAddress; - UINT32 ProductNameAddress; - UINT32 ProductRevAddress; -} VBE_INFO_BASE; - -typedef struct { - VBE_INFO_BASE Base; - UINT8 Buffer[256 - sizeof (VBE_INFO_BASE)]; -} VBE_INFO; - -typedef struct { - UINT16 ModeAttr; - UINT8 WindowAAttr; - UINT8 WindowBAttr; - UINT16 WindowGranularityKB; - UINT16 WindowSizeKB; - UINT16 WindowAStartSegment; - UINT16 WindowBStartSegment; - UINT32 WindowPositioningAddress; - UINT16 BytesPerScanLine; - - UINT16 Width; - UINT16 Height; - UINT8 CharCellWidth; - UINT8 CharCellHeight; - UINT8 NumPlanes; - UINT8 BitsPerPixel; - UINT8 NumBanks; - UINT8 MemoryModel; - UINT8 BankSizeKB; - UINT8 NumImagePagesLessOne; - UINT8 Vbe3; - - UINT8 RedMaskSize; - UINT8 RedMaskPos; - UINT8 GreenMaskSize; - UINT8 GreenMaskPos; - UINT8 BlueMaskSize; - UINT8 BlueMaskPos; - UINT8 ReservedMaskSize; - UINT8 ReservedMaskPos; - UINT8 DirectColorModeInfo; - - UINT32 LfbAddress; - UINT32 OffScreenAddress; - UINT16 OffScreenSizeKB; - - UINT16 BytesPerScanLineLinear; - UINT8 NumImagesLessOneBanked; - UINT8 NumImagesLessOneLinear; - UINT8 RedMaskSizeLinear; - UINT8 RedMaskPosLinear; - UINT8 GreenMaskSizeLinear; - UINT8 GreenMaskPosLinear; - UINT8 BlueMaskSizeLinear; - UINT8 BlueMaskPosLinear; - UINT8 ReservedMaskSizeLinear; - UINT8 ReservedMaskPosLinear; - UINT32 MaxPixelClockHz; - UINT8 Reserved[190]; -} VBE_MODE_INFO; -#pragma pack () - -#endif diff --git a/OvmfPkg/Include/IndustryStandard/LinuxBzimage.h b/OvmfPkg/Include/IndustryStandard/LinuxBzimage.h deleted file mode 100644 index a6d8999730..0000000000 --- a/OvmfPkg/Include/IndustryStandard/LinuxBzimage.h +++ /dev/null @@ -1,164 +0,0 @@ -/** @file - - Copyright (c) 2011 - 2013, Intel Corporation. All rights reserved.
- This program and the accompanying materials - are licensed and made available under the terms and conditions of the BSD License - which accompanies this distribution. The full text of the license may be found at - http://opensource.org/licenses/bsd-license.php - - THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, - WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. - -**/ - -#ifndef __LINUX_BZIMAGE_H__ -#define __LINUX_BZIMAGE_H__ - -#define BOOTSIG 0x1FE -#define SETUP_HDR 0x53726448 /* 0x53726448 == "HdrS" */ - -#define E820_RAM 1 -#define E820_RESERVED 2 -#define E820_ACPI 3 -#define E820_NVS 4 -#define E820_UNUSABLE 5 - -#pragma pack(1) - -struct setup_header { - UINT8 setup_secs; /* Sectors for setup code */ - UINT16 root_flags; - UINT32 sys_size; - UINT16 ram_size; - UINT16 video_mode; - UINT16 root_dev; - UINT16 signature; /* Boot signature */ - UINT16 jump; - UINT32 header; - UINT16 version; - UINT16 su_switch; - UINT16 setup_seg; - UINT16 start_sys; - UINT16 kernel_ver; - UINT8 loader_id; - UINT8 load_flags; - UINT16 movesize; - UINT32 code32_start; /* Start of code loaded high */ - UINT32 ramdisk_start; /* Start of initial ramdisk */ - UINT32 ramdisk_len; /* Length of initial ramdisk */ - UINT32 bootsect_kludge; - UINT16 heap_end; - UINT8 ext_loader_ver; /* Extended boot loader version */ - UINT8 ext_loader_type; /* Extended boot loader ID */ - UINT32 cmd_line_ptr; /* 32-bit pointer to the kernel command line */ - UINT32 ramdisk_max; /* Highest legal initrd address */ - UINT32 kernel_alignment; /* Physical addr alignment required for kernel */ - UINT8 relocatable_kernel; /* Whether kernel is relocatable or not */ - UINT8 min_alignment; - UINT16 xloadflags; - UINT32 cmdline_size; - UINT32 hardware_subarch; - UINT64 hardware_subarch_data; - UINT32 payload_offset; - UINT32 payload_length; - UINT64 setup_data; - UINT64 pref_address; - UINT32 init_size; - UINT32 handover_offset; -}; - -struct efi_info { - UINT32 efi_loader_signature; - UINT32 efi_systab; - UINT32 efi_memdesc_size; - UINT32 efi_memdesc_version; - UINT32 efi_memmap; - UINT32 efi_memmap_size; - UINT32 efi_systab_hi; - UINT32 efi_memmap_hi; -}; - -struct e820_entry { - UINT64 addr; /* start of memory segment */ - UINT64 size; /* size of memory segment */ - UINT32 type; /* type of memory segment */ -}; - -struct screen_info { - UINT8 orig_x; /* 0x00 */ - UINT8 orig_y; /* 0x01 */ - UINT16 ext_mem_k; /* 0x02 */ - UINT16 orig_video_page; /* 0x04 */ - UINT8 orig_video_mode; /* 0x06 */ - UINT8 orig_video_cols; /* 0x07 */ - UINT8 flags; /* 0x08 */ - UINT8 unused2; /* 0x09 */ - UINT16 orig_video_ega_bx;/* 0x0a */ - UINT16 unused3; /* 0x0c */ - UINT8 orig_video_lines; /* 0x0e */ - UINT8 orig_video_isVGA; /* 0x0f */ - UINT16 orig_video_points;/* 0x10 */ - - /* VESA graphic mode -- linear frame buffer */ - UINT16 lfb_width; /* 0x12 */ - UINT16 lfb_height; /* 0x14 */ - UINT16 lfb_depth; /* 0x16 */ - UINT32 lfb_base; /* 0x18 */ - UINT32 lfb_size; /* 0x1c */ - UINT16 cl_magic, cl_offset; /* 0x20 */ - UINT16 lfb_linelength; /* 0x24 */ - UINT8 red_size; /* 0x26 */ - UINT8 red_pos; /* 0x27 */ - UINT8 green_size; /* 0x28 */ - UINT8 green_pos; /* 0x29 */ - UINT8 blue_size; /* 0x2a */ - UINT8 blue_pos; /* 0x2b */ - UINT8 rsvd_size; /* 0x2c */ - UINT8 rsvd_pos; /* 0x2d */ - UINT16 vesapm_seg; /* 0x2e */ - UINT16 vesapm_off; /* 0x30 */ - UINT16 pages; /* 0x32 */ - UINT16 vesa_attributes; /* 0x34 */ - UINT32 capabilities; /* 0x36 */ - UINT8 _reserved[6]; /* 0x3a */ -}; - -struct boot_params { - struct screen_info screen_info; - UINT8 apm_bios_info[0x14]; - UINT8 _pad2[4]; - UINT64 tboot_addr; - UINT8 ist_info[0x10]; - UINT8 _pad3[16]; - UINT8 hd0_info[16]; - UINT8 hd1_info[16]; - UINT8 sys_desc_table[0x10]; - UINT8 olpc_ofw_header[0x10]; - UINT8 _pad4[128]; - UINT8 edid_info[0x80]; - struct efi_info efi_info; - UINT32 alt_mem_k; - UINT32 scratch; - UINT8 e820_entries; - UINT8 eddbuf_entries; - UINT8 edd_mbr_sig_buf_entries; - UINT8 _pad6[6]; - struct setup_header hdr; - UINT8 _pad7[0x290-0x1f1-sizeof(struct setup_header)]; - UINT32 edd_mbr_sig_buffer[16]; - struct e820_entry e820_map[128]; - UINT8 _pad8[48]; - UINT8 eddbuf[0x1ec]; - UINT8 _pad9[276]; -}; - -typedef struct { - UINT16 limit; - UINT64 *base; -} dt_addr_t; - -#pragma pack() - -extern EFI_STATUS setup_graphics(struct boot_params *buf); - -#endif /* __LINUX_BZIMAGE_H__ */ diff --git a/OvmfPkg/Include/IndustryStandard/Q35MchIch9.h b/OvmfPkg/Include/IndustryStandard/Q35MchIch9.h deleted file mode 100644 index f480455ae4..0000000000 --- a/OvmfPkg/Include/IndustryStandard/Q35MchIch9.h +++ /dev/null @@ -1,112 +0,0 @@ -/** @file - Various register numbers and value bits based on the following publications: - - Intel(R) datasheet 316966-002 - - Intel(R) datasheet 316972-004 - - Copyright (C) 2015, Red Hat, Inc. - Copyright (c) 2014, Gabriel L. Somlo - - This program and the accompanying materials are licensed and made 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 __Q35_MCH_ICH9_H__ -#define __Q35_MCH_ICH9_H__ - -#include -#include -#include -#include - -// -// Host Bridge Device ID (DID) value for Q35/MCH -// -#define INTEL_Q35_MCH_DEVICE_ID 0x29C0 - -// -// B/D/F/Type: 0/0/0/PCI -// -#define DRAMC_REGISTER_Q35(Offset) PCI_LIB_ADDRESS (0, 0, 0, (Offset)) - -#define MCH_GGC 0x52 -#define MCH_GGC_IVD BIT1 - -#define MCH_PCIEXBAR_LOW 0x60 -#define MCH_PCIEXBAR_LOWMASK 0x0FFFFFFF -#define MCH_PCIEXBAR_BUS_FF 0 -#define MCH_PCIEXBAR_EN BIT0 - -#define MCH_PCIEXBAR_HIGH 0x64 -#define MCH_PCIEXBAR_HIGHMASK 0xFFFFFFF0 - -#define MCH_SMRAM 0x9D -#define MCH_SMRAM_D_LCK BIT4 -#define MCH_SMRAM_G_SMRAME BIT3 - -#define MCH_ESMRAMC 0x9E -#define MCH_ESMRAMC_H_SMRAME BIT7 -#define MCH_ESMRAMC_E_SMERR BIT6 -#define MCH_ESMRAMC_SM_CACHE BIT5 -#define MCH_ESMRAMC_SM_L1 BIT4 -#define MCH_ESMRAMC_SM_L2 BIT3 -#define MCH_ESMRAMC_TSEG_8MB BIT2 -#define MCH_ESMRAMC_TSEG_2MB BIT1 -#define MCH_ESMRAMC_TSEG_1MB 0 -#define MCH_ESMRAMC_TSEG_MASK (BIT2 | BIT1) -#define MCH_ESMRAMC_T_EN BIT0 - -#define MCH_GBSM 0xA4 -#define MCH_GBSM_MB_SHIFT 20 - -#define MCH_BGSM 0xA8 -#define MCH_BGSM_MB_SHIFT 20 - -#define MCH_TSEGMB 0xAC -#define MCH_TSEGMB_MB_SHIFT 20 - -#define MCH_TOLUD 0xB0 -#define MCH_TOLUD_MB_SHIFT 4 - -// -// B/D/F/Type: 0/0x1f/0/PCI -// -#define POWER_MGMT_REGISTER_Q35(Offset) \ - PCI_LIB_ADDRESS (0, 0x1f, 0, (Offset)) - -#define POWER_MGMT_REGISTER_Q35_EFI_PCI_ADDRESS(Offset) \ - EFI_PCI_ADDRESS (0, 0x1f, 0, (Offset)) - -#define ICH9_PMBASE 0x40 -#define ICH9_PMBASE_MASK (BIT15 | BIT14 | BIT13 | BIT12 | BIT11 | \ - BIT10 | BIT9 | BIT8 | BIT7) - -#define ICH9_ACPI_CNTL 0x44 -#define ICH9_ACPI_CNTL_ACPI_EN BIT7 - -#define ICH9_GEN_PMCON_1 0xA0 -#define ICH9_GEN_PMCON_1_SMI_LOCK BIT4 - -#define ICH9_RCBA 0xF0 -#define ICH9_RCBA_EN BIT0 - -// -// IO ports -// -#define ICH9_APM_CNT 0xB2 -#define ICH9_APM_STS 0xB3 - -// -// IO ports relative to PMBASE -// -#define ICH9_PMBASE_OFS_SMI_EN 0x30 -#define ICH9_SMI_EN_APMC_EN BIT5 -#define ICH9_SMI_EN_GBL_SMI_EN BIT0 - -#define ICH9_ROOT_COMPLEX_BASE 0xFED1C000 - -#endif diff --git a/OvmfPkg/Include/IndustryStandard/QemuFwCfg.h b/OvmfPkg/Include/IndustryStandard/QemuFwCfg.h deleted file mode 100644 index 8c32f83e8e..0000000000 --- a/OvmfPkg/Include/IndustryStandard/QemuFwCfg.h +++ /dev/null @@ -1,104 +0,0 @@ -/** @file - Macro and type definitions corresponding to the QEMU fw_cfg interface. - - Refer to "docs/specs/fw_cfg.txt" in the QEMU source directory. - - Copyright (c) 2011 - 2013, Intel Corporation. All rights reserved.
- Copyright (C) 2013 - 2017, 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 __FW_CFG_H__ -#define __FW_CFG_H__ - -#include - -// -// The size, in bytes, of names of firmware configuration files, including at -// least one terminating NUL byte. -// -#define QEMU_FW_CFG_FNAME_SIZE 56 - -// -// If the following bit is set in the UINT32 fw_cfg revision / feature bitmap -// -- read from key 0x0001 with the basic IO Port or MMIO method --, then the -// DMA interface is available. -// -#define FW_CFG_F_DMA BIT1 - -// -// Macros for the FW_CFG_DMA_ACCESS.Control bitmap (in native encoding). -// -#define FW_CFG_DMA_CTL_ERROR BIT0 -#define FW_CFG_DMA_CTL_READ BIT1 -#define FW_CFG_DMA_CTL_SKIP BIT2 -#define FW_CFG_DMA_CTL_SELECT BIT3 -#define FW_CFG_DMA_CTL_WRITE BIT4 - -// -// The fw_cfg registers can be found at these IO Ports, on the IO-mapped -// platforms (Ia32 and X64). -// -#define FW_CFG_IO_SELECTOR 0x510 -#define FW_CFG_IO_DATA 0x511 -#define FW_CFG_IO_DMA_ADDRESS 0x514 - -// -// Numerically defined keys. -// -typedef enum { - QemuFwCfgItemSignature = 0x0000, - QemuFwCfgItemInterfaceVersion = 0x0001, - QemuFwCfgItemSystemUuid = 0x0002, - QemuFwCfgItemRamSize = 0x0003, - QemuFwCfgItemGraphicsEnabled = 0x0004, - QemuFwCfgItemSmpCpuCount = 0x0005, - QemuFwCfgItemMachineId = 0x0006, - QemuFwCfgItemKernelAddress = 0x0007, - QemuFwCfgItemKernelSize = 0x0008, - QemuFwCfgItemKernelCommandLine = 0x0009, - QemuFwCfgItemInitrdAddress = 0x000a, - QemuFwCfgItemInitrdSize = 0x000b, - QemuFwCfgItemBootDevice = 0x000c, - QemuFwCfgItemNumaData = 0x000d, - QemuFwCfgItemBootMenu = 0x000e, - QemuFwCfgItemMaximumCpuCount = 0x000f, - QemuFwCfgItemKernelEntry = 0x0010, - QemuFwCfgItemKernelData = 0x0011, - QemuFwCfgItemInitrdData = 0x0012, - QemuFwCfgItemCommandLineAddress = 0x0013, - QemuFwCfgItemCommandLineSize = 0x0014, - QemuFwCfgItemCommandLineData = 0x0015, - QemuFwCfgItemKernelSetupAddress = 0x0016, - QemuFwCfgItemKernelSetupSize = 0x0017, - QemuFwCfgItemKernelSetupData = 0x0018, - QemuFwCfgItemFileDir = 0x0019, - - QemuFwCfgItemX86AcpiTables = 0x8000, - QemuFwCfgItemX86SmbiosTables = 0x8001, - QemuFwCfgItemX86Irq0Override = 0x8002, - QemuFwCfgItemX86E820Table = 0x8003, - QemuFwCfgItemX86HpetData = 0x8004, - -} FIRMWARE_CONFIG_ITEM; - -// -// Communication structure for the DMA access method. All fields are encoded in -// big endian. -// -#pragma pack (1) -typedef struct { - UINT32 Control; - UINT32 Length; - UINT64 Address; -} FW_CFG_DMA_ACCESS; -#pragma pack () - -#endif diff --git a/OvmfPkg/Include/IndustryStandard/Virtio.h b/OvmfPkg/Include/IndustryStandard/Virtio.h deleted file mode 100644 index dddec38831..0000000000 --- a/OvmfPkg/Include/IndustryStandard/Virtio.h +++ /dev/null @@ -1,24 +0,0 @@ -/** @file - - Generic type and macro definitions corresponding to the virtio - specifications. - - Copyright (C) 2012-2016, Red Hat, Inc. - Portion of Copyright (C) 2013, ARM Ltd. - - This program and the accompanying materials are licensed and made available - under the terms and conditions of the BSD License which accompanies this - 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 - -#endif // _VIRTIO_H_ diff --git a/OvmfPkg/Include/IndustryStandard/Virtio095.h b/OvmfPkg/Include/IndustryStandard/Virtio095.h deleted file mode 100644 index 6bf77cb320..0000000000 --- a/OvmfPkg/Include/IndustryStandard/Virtio095.h +++ /dev/null @@ -1,175 +0,0 @@ -/** @file - - Generic type and macro definitions corresponding to the virtio-0.9.5 - specification. - - Copyright (C) 2012-2016, Red Hat, Inc. - Portion of Copyright (C) 2013, ARM Ltd. - - This program and the accompanying materials are licensed and made available - under the terms and conditions of the BSD License which accompanies this - 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_0_9_5_H_ -#define _VIRTIO_0_9_5_H_ - -#include - -// -// VirtIo Subsystem Device IDs -// -#define VIRTIO_SUBSYSTEM_NETWORK_CARD 1 -#define VIRTIO_SUBSYSTEM_BLOCK_DEVICE 2 -#define VIRTIO_SUBSYSTEM_CONSOLE 3 -#define VIRTIO_SUBSYSTEM_ENTROPY_SOURCE 4 -#define VIRTIO_SUBSYSTEM_MEMORY_BALLOONING 5 -#define VIRTIO_SUBSYSTEM_IO_MEMORY 6 -#define VIRTIO_SUBSYSTEM_RPMSG 7 -#define VIRTIO_SUBSYSTEM_SCSI_HOST 8 -#define VIRTIO_SUBSYSTEM_9P_TRANSPORT 9 -#define VIRTIO_SUBSYSTEM_MAC80211_WLAN 10 - -// -// Virtio IDs -// -#define VIRTIO_VENDOR_ID 0x1AF4 -#define VIRTIO_MMIO_MAGIC 0x74726976 // "virt" - - -// -// VirtIo Device Specific Configuration Offsets -// -#define VIRTIO_DEVICE_SPECIFIC_CONFIGURATION_OFFSET_PCI 20 -#define VIRTIO_DEVICE_SPECIFIC_CONFIGURATION_OFFSET_PCI_WITH_MSI_X 24 -#define VIRTIO_DEVICE_SPECIFIC_CONFIGURATION_OFFSET_MMIO 0x100 - -// -// PCI VirtIo Header Offsets -// -#define VIRTIO_PCI_OFFSET_DEVICE_FEATURES 0x00 -#define VIRTIO_PCI_OFFSET_GUEST_FEATURES 0x04 -#define VIRTIO_PCI_OFFSET_QUEUE_ADDRESS 0x08 -#define VIRTIO_PCI_OFFSET_QUEUE_SIZE 0x0C -#define VIRTIO_PCI_OFFSET_QUEUE_SELECT 0x0E -#define VIRTIO_PCI_OFFSET_QUEUE_NOTIFY 0x10 -#define VIRTIO_PCI_OFFSET_QUEUE_DEVICE_STATUS 0x12 -#define VIRTIO_PCI_OFFSET_QUEUE_DEVICE_ISR 0x13 - -// -// MMIO VirtIo Header Offsets -// -#define VIRTIO_MMIO_OFFSET_MAGIC 0x00 -#define VIRTIO_MMIO_OFFSET_VERSION 0x04 -#define VIRTIO_MMIO_OFFSET_DEVICE_ID 0x08 -#define VIRTIO_MMIO_OFFSET_VENDOR_ID 0x0C -#define VIRTIO_MMIO_OFFSET_HOST_FEATURES 0x10 -#define VIRTIO_MMIO_OFFSET_HOST_FEATURES_SEL 0x14 -#define VIRTIO_MMIO_OFFSET_GUEST_FEATURES 0x20 -#define VIRTIO_MMIO_OFFSET_GUEST_FEATURES_SEL 0x24 -#define VIRTIO_MMIO_OFFSET_GUEST_PAGE_SIZE 0x28 -#define VIRTIO_MMIO_OFFSET_QUEUE_SEL 0x30 -#define VIRTIO_MMIO_OFFSET_QUEUE_NUM_MAX 0x34 -#define VIRTIO_MMIO_OFFSET_QUEUE_NUM 0x38 -#define VIRTIO_MMIO_OFFSET_QUEUE_ALIGN 0x3C -#define VIRTIO_MMIO_OFFSET_QUEUE_PFN 0x40 -#define VIRTIO_MMIO_OFFSET_QUEUE_NOTIFY 0x50 -#define VIRTIO_MMIO_OFFSET_INTERRUPT_STATUS 0x60 -#define VIRTIO_MMIO_OFFSET_INTERRUPT_ACK 0x64 -#define VIRTIO_MMIO_OFFSET_STATUS 0x70 - -// -// Data in the communication area is defined as packed and accessed as -// volatile. -// -// 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.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_0_9_5_H_ diff --git a/OvmfPkg/Include/IndustryStandard/Virtio095Net.h b/OvmfPkg/Include/IndustryStandard/Virtio095Net.h deleted file mode 100644 index 819604289e..0000000000 --- a/OvmfPkg/Include/IndustryStandard/Virtio095Net.h +++ /dev/null @@ -1,97 +0,0 @@ -/** @file - Virtio Network Device specific type and macro definitions corresponding to - the virtio-0.9.5 specification. - - Copyright (C) 2013-2016, 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_0_9_5_NET_H_ -#define _VIRTIO_0_9_5_NET_H_ - -#include - -// -// virtio-0.9.5, Appendix C: Network Device -// -#pragma pack(1) -typedef struct { - UINT8 Mac[6]; - UINT16 LinkStatus; -} VIRTIO_NET_CONFIG; -#pragma pack() - -#define OFFSET_OF_VNET(Field) OFFSET_OF (VIRTIO_NET_CONFIG, Field) -#define SIZE_OF_VNET(Field) (sizeof ((VIRTIO_NET_CONFIG *) 0)->Field) - -// -// Queue Identifiers -// -#define VIRTIO_NET_Q_RX 0 -#define VIRTIO_NET_Q_TX 1 - -// -// Feature Bits -// -#define VIRTIO_NET_F_CSUM BIT0 // host to checksum outgoing packets -#define VIRTIO_NET_F_GUEST_CSUM BIT1 // guest to checksum incoming packets -#define VIRTIO_NET_F_MAC BIT5 // MAC available to guest -#define VIRTIO_NET_F_GSO BIT6 // deprecated -#define VIRTIO_NET_F_GUEST_TSO4 BIT7 // guest can receive TSOv4 -#define VIRTIO_NET_F_GUEST_TSO6 BIT8 // guest can receive TSOv6 -#define VIRTIO_NET_F_GUEST_ECN BIT9 // guest can receive TSO with ECN -#define VIRTIO_NET_F_GUEST_UFO BIT10 // guest can receive UFO -#define VIRTIO_NET_F_HOST_TSO4 BIT11 // host can receive TSOv4 -#define VIRTIO_NET_F_HOST_TSO6 BIT12 // host can receive TSOv6 -#define VIRTIO_NET_F_HOST_ECN BIT13 // host can receive TSO with ECN -#define VIRTIO_NET_F_HOST_UFO BIT14 // host can receive UFO -#define VIRTIO_NET_F_MRG_RXBUF BIT15 // guest can merge receive buffers -#define VIRTIO_NET_F_STATUS BIT16 // link status available to guest -#define VIRTIO_NET_F_CTRL_VQ BIT17 // control channel available -#define VIRTIO_NET_F_CTRL_RX BIT18 // control channel RX mode support -#define VIRTIO_NET_F_CTRL_VLAN BIT19 // control channel VLAN filtering -#define VIRTIO_NET_F_GUEST_ANNOUNCE BIT21 // guest can send gratuitous pkts - -// -// Packet Header -// -#pragma pack(1) -typedef struct { - UINT8 Flags; - UINT8 GsoType; - UINT16 HdrLen; - UINT16 GsoSize; - UINT16 CsumStart; - UINT16 CsumOffset; -} VIRTIO_NET_REQ; -#pragma pack() - -// -// Bits in VIRTIO_NET_REQ.Flags -// -#define VIRTIO_NET_HDR_F_NEEDS_CSUM BIT0 - -// -// Types/Bits for VIRTIO_NET_REQ.GsoType -// -#define VIRTIO_NET_HDR_GSO_NONE 0x00 -#define VIRTIO_NET_HDR_GSO_TCPV4 0x01 -#define VIRTIO_NET_HDR_GSO_UDP 0x03 -#define VIRTIO_NET_HDR_GSO_TCPV6 0x04 -#define VIRTIO_NET_HDR_GSO_ECN BIT7 - -// -// Link Status Bits in VIRTIO_NET_CONFIG.LinkStatus -// -#define VIRTIO_NET_S_LINK_UP BIT0 -#define VIRTIO_NET_S_ANNOUNCE BIT1 - -#endif // _VIRTIO_0_9_5_NET_H_ diff --git a/OvmfPkg/Include/IndustryStandard/Virtio10.h b/OvmfPkg/Include/IndustryStandard/Virtio10.h deleted file mode 100644 index 4c9b62a3cf..0000000000 --- a/OvmfPkg/Include/IndustryStandard/Virtio10.h +++ /dev/null @@ -1,86 +0,0 @@ -/** @file - Definitions from the VirtIo 1.0 specification (csprd05). - - Copyright (C) 2016, 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_1_0_H_ -#define _VIRTIO_1_0_H_ - -#include - -// -// Subsystem Device IDs (to be) introduced in VirtIo 1.0 -// -#define VIRTIO_SUBSYSTEM_GPU_DEVICE 16 - -// -// Structures for parsing the VirtIo 1.0 specific PCI capabilities from the -// config space -// -#pragma pack (1) -typedef struct { - UINT8 CapId; // Capability identifier (generic) - UINT8 CapNext; // Link to next capability (generic) -} VIRTIO_PCI_CAP_LINK; - -typedef struct { - UINT8 ConfigType; // Identifies the specific VirtIo 1.0 config structure - UINT8 Bar; // The BAR that contains the structure - UINT8 Padding[3]; - UINT32 Offset; // Offset within Bar until the start of the structure - UINT32 Length; // Length of the structure -} VIRTIO_PCI_CAP; -#pragma pack () - -// -// Values for the VIRTIO_PCI_CAP.ConfigType field -// -#define VIRTIO_PCI_CAP_COMMON_CFG 1 // Common configuration -#define VIRTIO_PCI_CAP_NOTIFY_CFG 2 // Notifications -#define VIRTIO_PCI_CAP_DEVICE_CFG 4 // Device specific configuration - -// -// Structure pointed-to by Bar and Offset in VIRTIO_PCI_CAP when ConfigType is -// VIRTIO_PCI_CAP_COMMON_CFG -// -#pragma pack (1) -typedef struct { - UINT32 DeviceFeatureSelect; - UINT32 DeviceFeature; - UINT32 DriverFeatureSelect; - UINT32 DriverFeature; - UINT16 MsixConfig; - UINT16 NumQueues; - UINT8 DeviceStatus; - UINT8 ConfigGeneration; - UINT16 QueueSelect; - UINT16 QueueSize; - UINT16 QueueMsixVector; - UINT16 QueueEnable; - UINT16 QueueNotifyOff; - UINT64 QueueDesc; - UINT64 QueueAvail; - UINT64 QueueUsed; -} VIRTIO_PCI_COMMON_CFG; -#pragma pack () - -// -// VirtIo 1.0 device status bits -// -#define VSTAT_FEATURES_OK BIT3 - -// -// VirtIo 1.0 reserved (device-independent) feature bits -// -#define VIRTIO_F_VERSION_1 BIT32 - -#endif // _VIRTIO_1_0_H_ diff --git a/OvmfPkg/Include/IndustryStandard/Virtio10Net.h b/OvmfPkg/Include/IndustryStandard/Virtio10Net.h deleted file mode 100644 index cfd25fc414..0000000000 --- a/OvmfPkg/Include/IndustryStandard/Virtio10Net.h +++ /dev/null @@ -1,32 +0,0 @@ -/** @file - Definitions from the VirtIo 1.0 specification (csprd05), specifically for the - network device. - - Copyright (C) 2016, 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_1_0_NET_H_ -#define _VIRTIO_1_0_NET_H_ - -#include -#include - -// -// VirtIo 1.0 packet header -// -#pragma pack (1) -typedef struct { - VIRTIO_NET_REQ V0_9_5; - UINT16 NumBuffers; -} VIRTIO_1_0_NET_REQ; -#pragma pack () - -#endif // _VIRTIO_1_0_NET_H_ diff --git a/OvmfPkg/Include/IndustryStandard/VirtioBlk.h b/OvmfPkg/Include/IndustryStandard/VirtioBlk.h deleted file mode 100644 index 2ce528a12e..0000000000 --- a/OvmfPkg/Include/IndustryStandard/VirtioBlk.h +++ /dev/null @@ -1,89 +0,0 @@ -/** @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 - - -// -// virtio-0.9.5, Appendix D: Block Device -// -#pragma pack(1) -typedef struct { - UINT8 PhysicalBlockExp; // # of logical blocks per physical block (log2) - UINT8 AlignmentOffset; // offset of first aligned logical block - UINT16 MinIoSize; // suggested minimum I/O size in blocks - UINT32 OptIoSize; // optimal (suggested maximum) I/O size in blocks -} VIRTIO_BLK_TOPOLOGY; - -typedef struct { - UINT64 Capacity; - UINT32 SizeMax; - UINT32 SegMax; - UINT16 Cylinders; - UINT8 Heads; - UINT8 Sectors; - UINT32 BlkSize; - VIRTIO_BLK_TOPOLOGY Topology; -} VIRTIO_BLK_CONFIG; -#pragma pack() - -#define OFFSET_OF_VBLK(Field) OFFSET_OF (VIRTIO_BLK_CONFIG, Field) -#define SIZE_OF_VBLK(Field) (sizeof ((VIRTIO_BLK_CONFIG *) 0)->Field) - -#define VIRTIO_BLK_F_BARRIER BIT0 -#define VIRTIO_BLK_F_SIZE_MAX BIT1 -#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, via - // VIRTIO_BLK_F_TOPOLOGY -#define VIRTIO_BLK_F_SCSI BIT7 -#define VIRTIO_BLK_F_FLUSH BIT9 // identical to "write cache enabled" -#define VIRTIO_BLK_F_TOPOLOGY BIT10 // information on optimal I/O alignment - -// -// 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/OvmfPkg/Include/IndustryStandard/VirtioGpu.h b/OvmfPkg/Include/IndustryStandard/VirtioGpu.h deleted file mode 100644 index 9c3516e71e..0000000000 --- a/OvmfPkg/Include/IndustryStandard/VirtioGpu.h +++ /dev/null @@ -1,216 +0,0 @@ -/** @file - - Virtio GPU Device specific type and macro definitions. - - At the time of this writing, the Virtio 1.0 specification has not - incorporated the GPU device yet. The following work-in-progress specification - is used as basis for the implementation: - - - https://lists.oasis-open.org/archives/virtio-dev/201605/msg00002.html - - https://www.kraxel.org/virtio/ - - This header file is minimal, and only defines the types and macros that are - necessary for the OvmfPkg implementation. - - Copyright (C) 2016, 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_GPU_H_ -#define _VIRTIO_GPU_H_ - -#include - -// -// Queue number for sending control commands. -// -#define VIRTIO_GPU_CONTROL_QUEUE 0 - -// -// Command and response types. -// -typedef enum { - // - // Commands related to mode setup: - // - // - create/release a host-side 2D resource, - // - VirtioGpuCmdResourceCreate2d = 0x0101, - VirtioGpuCmdResourceUnref = 0x0102, - // - // - attach/detach guest RAM to/from a host-side 2D resource, - // - VirtioGpuCmdResourceAttachBacking = 0x0106, - VirtioGpuCmdResourceDetachBacking = 0x0107, - // - // - assign/unassign a host-side 2D resource to/from a scanout ("head"). - // - VirtioGpuCmdSetScanout = 0x0103, - - // - // Commands related to drawing: - // - // - transfer a guest RAM update to the host-side 2D resource (does not imply - // host display refresh), - // - VirtioGpuCmdTransferToHost2d = 0x0105, - // - // - trigger a host display refresh from the 2D resource. - // - VirtioGpuCmdResourceFlush = 0x0104, - - // - // Success code for all of the above commands. - // - VirtioGpuRespOkNodata = 0x1100, -} VIRTIO_GPU_CONTROL_TYPE; - -// -// Common request/response header. -// -#define VIRTIO_GPU_FLAG_FENCE BIT0 - -#pragma pack (1) -typedef struct { - // - // The guest sets Type to VirtioGpuCmd* in the requests. The host sets Type - // to VirtioGpuResp* in the responses. - // - UINT32 Type; - - // - // Fencing forces the host to complete the command before producing a - // response. - // - UINT32 Flags; - UINT64 FenceId; - - // - // Unused. - // - UINT32 CtxId; - UINT32 Padding; -} VIRTIO_GPU_CONTROL_HEADER; -#pragma pack () - -// -// Rectangle structure used by several operations. -// -#pragma pack (1) -typedef struct { - UINT32 X; - UINT32 Y; - UINT32 Width; - UINT32 Height; -} VIRTIO_GPU_RECTANGLE; -#pragma pack () - -// -// Request structure for VirtioGpuCmdResourceCreate2d. -// -typedef enum { - // - // 32-bit depth, BGRX component order, X component ignored. - // - VirtioGpuFormatB8G8R8X8Unorm = 2, -} VIRTIO_GPU_FORMATS; - -#pragma pack (1) -typedef struct { - VIRTIO_GPU_CONTROL_HEADER Header; - UINT32 ResourceId; // note: 0 is invalid - UINT32 Format; // from VIRTIO_GPU_FORMATS - UINT32 Width; - UINT32 Height; -} VIRTIO_GPU_RESOURCE_CREATE_2D; -#pragma pack () - -// -// Request structure for VirtioGpuCmdResourceUnref. -// -#pragma pack (1) -typedef struct { - VIRTIO_GPU_CONTROL_HEADER Header; - UINT32 ResourceId; - UINT32 Padding; -} VIRTIO_GPU_RESOURCE_UNREF; -#pragma pack () - -// -// Request structure for VirtioGpuCmdResourceAttachBacking. -// -// The spec allows for a scatter-gather list, but for simplicity we hard-code a -// single guest buffer. -// -#pragma pack (1) -typedef struct { - UINT64 Addr; - UINT32 Length; - UINT32 Padding; -} VIRTIO_GPU_MEM_ENTRY; - -typedef struct { - VIRTIO_GPU_CONTROL_HEADER Header; - UINT32 ResourceId; - UINT32 NrEntries; // number of entries: constant 1 - VIRTIO_GPU_MEM_ENTRY Entry; -} VIRTIO_GPU_RESOURCE_ATTACH_BACKING; -#pragma pack () - -// -// Request structure for VirtioGpuCmdResourceDetachBacking. -// -#pragma pack (1) -typedef struct { - VIRTIO_GPU_CONTROL_HEADER Header; - UINT32 ResourceId; - UINT32 Padding; -} VIRTIO_GPU_RESOURCE_DETACH_BACKING; -#pragma pack () - -// -// Request structure for VirtioGpuCmdSetScanout. -// -#pragma pack (1) -typedef struct { - VIRTIO_GPU_CONTROL_HEADER Header; - VIRTIO_GPU_RECTANGLE Rectangle; - UINT32 ScanoutId; - UINT32 ResourceId; -} VIRTIO_GPU_SET_SCANOUT; -#pragma pack () - -// -// Request structure for VirtioGpuCmdTransferToHost2d. -// -#pragma pack (1) -typedef struct { - VIRTIO_GPU_CONTROL_HEADER Header; - VIRTIO_GPU_RECTANGLE Rectangle; - UINT64 Offset; - UINT32 ResourceId; - UINT32 Padding; -} VIRTIO_GPU_CMD_TRANSFER_TO_HOST_2D; -#pragma pack () - -// -// Request structure for VirtioGpuCmdResourceFlush. -// -#pragma pack (1) -typedef struct { - VIRTIO_GPU_CONTROL_HEADER Header; - VIRTIO_GPU_RECTANGLE Rectangle; - UINT32 ResourceId; - UINT32 Padding; -} VIRTIO_GPU_RESOURCE_FLUSH; -#pragma pack () - -#endif // _VIRTIO_GPU_H_ diff --git a/OvmfPkg/Include/IndustryStandard/VirtioNet.h b/OvmfPkg/Include/IndustryStandard/VirtioNet.h deleted file mode 100644 index 9b0bfdc585..0000000000 --- a/OvmfPkg/Include/IndustryStandard/VirtioNet.h +++ /dev/null @@ -1,22 +0,0 @@ -/** @file - Virtio Network Device specific type and macro definitions corresponding to - the virtio specifications. - - Copyright (C) 2013-2016, Red Hat, Inc. - - This program and the accompanying materials are licensed and made available - under the terms and conditions of the BSD License which accompanies this - distribution. The full text of the license may be found at - http://opensource.org/licenses/bsd-license.php - - THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, WITHOUT - WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. - -**/ - -#ifndef _VIRTIO_NET_H_ -#define _VIRTIO_NET_H_ - -#include - -#endif // _VIRTIO_NET_H_ diff --git a/OvmfPkg/Include/IndustryStandard/VirtioScsi.h b/OvmfPkg/Include/IndustryStandard/VirtioScsi.h deleted file mode 100644 index 0c9b520904..0000000000 --- a/OvmfPkg/Include/IndustryStandard/VirtioScsi.h +++ /dev/null @@ -1,99 +0,0 @@ -/** @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 - - -// -// virtio-0.9.5, Appendix I: SCSI Host Device -// -#pragma pack(1) -typedef struct { - UINT32 NumQueues; - UINT32 SegMax; - UINT32 MaxSectors; - UINT32 CmdPerLun; - UINT32 EventInfoSize; - UINT32 SenseSize; - UINT32 CdbSize; - UINT16 MaxChannel; - UINT16 MaxTarget; - UINT32 MaxLun; -} VIRTIO_SCSI_CONFIG; -#pragma pack() - -#define OFFSET_OF_VSCSI(Field) OFFSET_OF (VIRTIO_SCSI_CONFIG, Field) -#define SIZE_OF_VSCSI(Field) (sizeof ((VIRTIO_SCSI_CONFIG *) 0)->Field) - -#define VIRTIO_SCSI_F_INOUT BIT0 -#define VIRTIO_SCSI_F_HOTPLUG BIT1 - -// -// 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/OvmfPkg/Include/IndustryStandard/Xen/README b/OvmfPkg/Include/IndustryStandard/Xen/README deleted file mode 100644 index 8cb7f715b7..0000000000 --- a/OvmfPkg/Include/IndustryStandard/Xen/README +++ /dev/null @@ -1,37 +0,0 @@ -The headers in this directory have been imported from the Xen Project with few -modification that are described in this README. - -The modifications that needed to be done are: -- Use of ZeroMem() or SetMem() instead of memset(). -- If a struct is using a 64bit field, then a #pragma(4) might be needed - for IA32, like in io/blkif.h. -- Replace the types with the ones used in UEFI. - - -* Command to run to change types: -find OvmfPkg/Include/IndustryStandard/Xen -type f -name '*.h' -exec sed --regexp-extended --file=fix_type_in_xen_includes.sed --in-place {} \; - -$ cat fix_type_in_xen_includes.sed -# Avoid changing the 'long' that is not a type. -/as long as/b - -s/([^a-zA-Z0-9_]|^)uint8_t([^a-zA-Z0-9_]|$)/\1UINT8\2/g -s/([^a-zA-Z0-9_]|^)uint16_t([^a-zA-Z0-9_]|$)/\1UINT16\2/g -s/([^a-zA-Z0-9_]|^)uint32_t([^a-zA-Z0-9_]|$)/\1UINT32\2/g -s/([^a-zA-Z0-9_]|^)uint64_t([^a-zA-Z0-9_]|$)/\1UINT64\2/g - -s/([^a-zA-Z0-9_]|^)int8_t([^a-zA-Z0-9_]|$)/\1INT8\2/g -s/([^a-zA-Z0-9_]|^)int16_t([^a-zA-Z0-9_]|$)/\1INT16\2/g -s/([^a-zA-Z0-9_]|^)int32_t([^a-zA-Z0-9_]|$)/\1INT32\2/g -s/([^a-zA-Z0-9_]|^)int64_t([^a-zA-Z0-9_]|$)/\1INT64\2/g - -s/([^a-zA-Z0-9_]|^)void([^a-zA-Z0-9_]|$)/\1VOID\2/g -s/([^a-zA-Z0-9_]|^)unsigned int([^a-zA-Z0-9_]|$)/\1UINT32\2/g -s/([^a-zA-Z0-9_]|^)int([^a-zA-Z0-9_]|$)/\1INT32\2/g -s/([^a-zA-Z0-9_]|^)unsigned char([^a-zA-Z0-9_]|$)/\1UINT8\2/g -s/([^a-zA-Z0-9_]|^)char([^a-zA-Z0-9_]|$)/\1CHAR8\2/g -s/([^a-zA-Z0-9_]|^)unsigned long([^a-zA-Z0-9_]|$)/\1UINTN\2/g -s/([^a-zA-Z0-9_]|^)long([^a-zA-Z0-9_]|$)/\1INTN\2/g - -s/__i386__/MDE_CPU_IA32/g -s/__x86_64__/MDE_CPU_X64/g diff --git a/OvmfPkg/Include/IndustryStandard/Xen/arch-arm/xen.h b/OvmfPkg/Include/IndustryStandard/Xen/arch-arm/xen.h deleted file mode 100644 index 625a0fc994..0000000000 --- a/OvmfPkg/Include/IndustryStandard/Xen/arch-arm/xen.h +++ /dev/null @@ -1,436 +0,0 @@ -/****************************************************************************** - * arch-arm.h - * - * Guest OS interface to ARM Xen. - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to - * deal in the Software without restriction, including without limitation the - * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or - * sell copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING - * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER - * DEALINGS IN THE SOFTWARE. - * - * Copyright 2011 (C) Citrix Systems - */ - -#ifndef __XEN_PUBLIC_ARCH_ARM_H__ -#define __XEN_PUBLIC_ARCH_ARM_H__ - -/* - * `incontents 50 arm_abi Hypercall Calling Convention - * - * A hypercall is issued using the ARM HVC instruction. - * - * A hypercall can take up to 5 arguments. These are passed in - * registers, the first argument in x0/r0 (for arm64/arm32 guests - * respectively irrespective of whether the underlying hypervisor is - * 32- or 64-bit), the second argument in x1/r1, the third in x2/r2, - * the forth in x3/r3 and the fifth in x4/r4. - * - * The hypercall number is passed in r12 (arm) or x16 (arm64). In both - * cases the relevant ARM procedure calling convention specifies this - * is an inter-procedure-call scratch register (e.g. for use in linker - * stubs). This use does not conflict with use during a hypercall. - * - * The HVC ISS must contain a Xen specific TAG: XEN_HYPERCALL_TAG. - * - * The return value is in x0/r0. - * - * The hypercall will clobber x16/r12 and the argument registers used - * by that hypercall (except r0 which is the return value) i.e. in - * addition to x16/r12 a 2 argument hypercall will clobber x1/r1 and a - * 4 argument hypercall will clobber x1/r1, x2/r2 and x3/r3. - * - * Parameter structs passed to hypercalls are laid out according to - * the Procedure Call Standard for the ARM Architecture (AAPCS, AKA - * EABI) and Procedure Call Standard for the ARM 64-bit Architecture - * (AAPCS64). Where there is a conflict the 64-bit standard should be - * used regardless of guest type. Structures which are passed as - * hypercall arguments are always little endian. - * - * All memory which is shared with other entities in the system - * (including the hypervisor and other guests) must reside in memory - * which is mapped as Normal Inner-cacheable. This applies to: - * - hypercall arguments passed via a pointer to guest memory. - * - memory shared via the grant table mechanism (including PV I/O - * rings etc). - * - memory shared with the hypervisor (struct shared_info, struct - * vcpu_info, the grant table, etc). - * - * Any Inner cache allocation strategy (Write-Back, Write-Through etc) - * is acceptable. There is no restriction on the Outer-cacheability. - */ - -/* - * `incontents 55 arm_hcall Supported Hypercalls - * - * Xen on ARM makes extensive use of hardware facilities and therefore - * only a subset of the potential hypercalls are required. - * - * Since ARM uses second stage paging any machine/physical addresses - * passed to hypercalls are Guest Physical Addresses (Intermediate - * Physical Addresses) unless otherwise noted. - * - * The following hypercalls (and sub operations) are supported on the - * ARM platform. Other hypercalls should be considered - * unavailable/unsupported. - * - * HYPERVISOR_memory_op - * All generic sub-operations. - * - * In addition the following arch specific sub-ops: - * * XENMEM_add_to_physmap - * * XENMEM_add_to_physmap_batch - * - * HYPERVISOR_domctl - * All generic sub-operations, with the exception of: - * * XEN_DOMCTL_iomem_permission (not yet implemented) - * * XEN_DOMCTL_irq_permission (not yet implemented) - * - * HYPERVISOR_sched_op - * All generic sub-operations, with the exception of: - * * SCHEDOP_block -- prefer wfi hardware instruction - * - * HYPERVISOR_console_io - * All generic sub-operations - * - * HYPERVISOR_xen_version - * All generic sub-operations - * - * HYPERVISOR_event_channel_op - * All generic sub-operations - * - * HYPERVISOR_physdev_op - * No sub-operations are currenty supported - * - * HYPERVISOR_sysctl - * All generic sub-operations, with the exception of: - * * XEN_SYSCTL_page_offline_op - * * XEN_SYSCTL_get_pmstat - * * XEN_SYSCTL_pm_op - * - * HYPERVISOR_hvm_op - * Exactly these sub-operations are supported: - * * HVMOP_set_param - * * HVMOP_get_param - * - * HYPERVISOR_grant_table_op - * All generic sub-operations - * - * HYPERVISOR_vcpu_op - * Exactly these sub-operations are supported: - * * VCPUOP_register_vcpu_info - * * VCPUOP_register_runstate_memory_area - * - * - * Other notes on the ARM ABI: - * - * - struct start_info is not exported to ARM guests. - * - * - struct shared_info is mapped by ARM guests using the - * HYPERVISOR_memory_op sub-op XENMEM_add_to_physmap, passing - * XENMAPSPACE_shared_info as space parameter. - * - * - All the per-cpu struct vcpu_info are mapped by ARM guests using the - * HYPERVISOR_vcpu_op sub-op VCPUOP_register_vcpu_info, including cpu0 - * struct vcpu_info. - * - * - The grant table is mapped using the HYPERVISOR_memory_op sub-op - * XENMEM_add_to_physmap, passing XENMAPSPACE_grant_table as space - * parameter. The memory range specified under the Xen compatible - * hypervisor node on device tree can be used as target gpfn for the - * mapping. - * - * - Xenstore is initialized by using the two hvm_params - * HVM_PARAM_STORE_PFN and HVM_PARAM_STORE_EVTCHN. They can be read - * with the HYPERVISOR_hvm_op sub-op HVMOP_get_param. - * - * - The paravirtualized console is initialized by using the two - * hvm_params HVM_PARAM_CONSOLE_PFN and HVM_PARAM_CONSOLE_EVTCHN. They - * can be read with the HYPERVISOR_hvm_op sub-op HVMOP_get_param. - * - * - Event channel notifications are delivered using the percpu GIC - * interrupt specified under the Xen compatible hypervisor node on - * device tree. - * - * - The device tree Xen compatible node is fully described under Linux - * at Documentation/devicetree/bindings/arm/xen.txt. - */ - -#define XEN_HYPERCALL_TAG 0xEA1 - -#define uint64_aligned_t UINT64 __attribute__((aligned(8))) - -#ifndef __ASSEMBLY__ -#define ___DEFINE_XEN_GUEST_HANDLE(name, type) \ - typedef union { type *p; unsigned long q; } \ - __guest_handle_ ## name; \ - typedef union { type *p; uint64_aligned_t q; } \ - __guest_handle_64_ ## name; - -/* - * XEN_GUEST_HANDLE represents a guest pointer, when passed as a field - * in a struct in memory. On ARM is always 8 bytes sizes and 8 bytes - * aligned. - * XEN_GUEST_HANDLE_PARAM represent a guest pointer, when passed as an - * hypercall argument. It is 4 bytes on aarch and 8 bytes on aarch64. - */ -#define __DEFINE_XEN_GUEST_HANDLE(name, type) \ - ___DEFINE_XEN_GUEST_HANDLE(name, type); \ - ___DEFINE_XEN_GUEST_HANDLE(const_##name, const type) -#define DEFINE_XEN_GUEST_HANDLE(name) __DEFINE_XEN_GUEST_HANDLE(name, name) -#define __XEN_GUEST_HANDLE(name) __guest_handle_64_ ## name -#define XEN_GUEST_HANDLE(name) __XEN_GUEST_HANDLE(name) -/* this is going to be changed on 64 bit */ -#define XEN_GUEST_HANDLE_PARAM(name) __guest_handle_ ## name -#define set_xen_guest_handle_raw(hnd, val) \ - do { \ - typeof(&(hnd)) _sxghr_tmp = &(hnd); \ - _sxghr_tmp->q = 0; \ - _sxghr_tmp->p = val; \ - } while ( 0 ) -#ifdef __XEN_TOOLS__ -#define get_xen_guest_handle(val, hnd) do { val = (hnd).p; } while (0) -#endif -#define set_xen_guest_handle(hnd, val) set_xen_guest_handle_raw(hnd, val) - -#if defined(__GNUC__) && !defined(__STRICT_ANSI__) -/* Anonymous union includes both 32- and 64-bit names (e.g., r0/x0). */ -# define __DECL_REG(n64, n32) union { \ - UINT64 n64; \ - UINT32 n32; \ - } -#else -/* Non-gcc sources must always use the proper 64-bit name (e.g., x0). */ -#define __DECL_REG(n64, n32) UINT64 n64 -#endif - -struct vcpu_guest_core_regs -{ - /* Aarch64 Aarch32 */ - __DECL_REG(x0, r0_usr); - __DECL_REG(x1, r1_usr); - __DECL_REG(x2, r2_usr); - __DECL_REG(x3, r3_usr); - __DECL_REG(x4, r4_usr); - __DECL_REG(x5, r5_usr); - __DECL_REG(x6, r6_usr); - __DECL_REG(x7, r7_usr); - __DECL_REG(x8, r8_usr); - __DECL_REG(x9, r9_usr); - __DECL_REG(x10, r10_usr); - __DECL_REG(x11, r11_usr); - __DECL_REG(x12, r12_usr); - - __DECL_REG(x13, sp_usr); - __DECL_REG(x14, lr_usr); - - __DECL_REG(x15, __unused_sp_hyp); - - __DECL_REG(x16, lr_irq); - __DECL_REG(x17, sp_irq); - - __DECL_REG(x18, lr_svc); - __DECL_REG(x19, sp_svc); - - __DECL_REG(x20, lr_abt); - __DECL_REG(x21, sp_abt); - - __DECL_REG(x22, lr_und); - __DECL_REG(x23, sp_und); - - __DECL_REG(x24, r8_fiq); - __DECL_REG(x25, r9_fiq); - __DECL_REG(x26, r10_fiq); - __DECL_REG(x27, r11_fiq); - __DECL_REG(x28, r12_fiq); - - __DECL_REG(x29, sp_fiq); - __DECL_REG(x30, lr_fiq); - - /* Return address and mode */ - __DECL_REG(pc64, pc32); /* ELR_EL2 */ - UINT32 cpsr; /* SPSR_EL2 */ - - union { - UINT32 spsr_el1; /* AArch64 */ - UINT32 spsr_svc; /* AArch32 */ - }; - - /* AArch32 guests only */ - UINT32 spsr_fiq, spsr_irq, spsr_und, spsr_abt; - - /* AArch64 guests only */ - UINT64 sp_el0; - UINT64 sp_el1, elr_el1; -}; -typedef struct vcpu_guest_core_regs vcpu_guest_core_regs_t; -DEFINE_XEN_GUEST_HANDLE(vcpu_guest_core_regs_t); - -#undef __DECL_REG - -typedef UINT64 xen_pfn_t; -#define PRI_xen_pfn PRIx64 - -/* Maximum number of virtual CPUs in legacy multi-processor guests. */ -/* Only one. All other VCPUS must use VCPUOP_register_vcpu_info */ -#define XEN_LEGACY_MAX_VCPUS 1 - -typedef UINT64 xen_ulong_t; -#define PRI_xen_ulong PRIx64 - -#if defined(__XEN__) || defined(__XEN_TOOLS__) -struct vcpu_guest_context { -#define _VGCF_online 0 -#define VGCF_online (1<<_VGCF_online) - UINT32 flags; /* VGCF_* */ - - struct vcpu_guest_core_regs user_regs; /* Core CPU registers */ - - UINT32 sctlr; - UINT64 ttbcr, ttbr0, ttbr1; -}; -typedef struct vcpu_guest_context vcpu_guest_context_t; -DEFINE_XEN_GUEST_HANDLE(vcpu_guest_context_t); -#endif - -struct arch_vcpu_info { -}; -typedef struct arch_vcpu_info arch_vcpu_info_t; - -struct arch_shared_info { -}; -typedef struct arch_shared_info arch_shared_info_t; -typedef UINT64 xen_callback_t; - -#endif - -#if defined(__XEN__) || defined(__XEN_TOOLS__) - -/* PSR bits (CPSR, SPSR)*/ - -#define PSR_THUMB (1<<5) /* Thumb Mode enable */ -#define PSR_FIQ_MASK (1<<6) /* Fast Interrupt mask */ -#define PSR_IRQ_MASK (1<<7) /* Interrupt mask */ -#define PSR_ABT_MASK (1<<8) /* Asynchronous Abort mask */ -#define PSR_BIG_ENDIAN (1<<9) /* arm32: Big Endian Mode */ -#define PSR_DBG_MASK (1<<9) /* arm64: Debug Exception mask */ -#define PSR_IT_MASK (0x0600fc00) /* Thumb If-Then Mask */ -#define PSR_JAZELLE (1<<24) /* Jazelle Mode */ - -/* 32 bit modes */ -#define PSR_MODE_USR 0x10 -#define PSR_MODE_FIQ 0x11 -#define PSR_MODE_IRQ 0x12 -#define PSR_MODE_SVC 0x13 -#define PSR_MODE_MON 0x16 -#define PSR_MODE_ABT 0x17 -#define PSR_MODE_HYP 0x1a -#define PSR_MODE_UND 0x1b -#define PSR_MODE_SYS 0x1f - -/* 64 bit modes */ -#define PSR_MODE_BIT 0x10 /* Set iff AArch32 */ -#define PSR_MODE_EL3h 0x0d -#define PSR_MODE_EL3t 0x0c -#define PSR_MODE_EL2h 0x09 -#define PSR_MODE_EL2t 0x08 -#define PSR_MODE_EL1h 0x05 -#define PSR_MODE_EL1t 0x04 -#define PSR_MODE_EL0t 0x00 - -#define PSR_GUEST32_INIT (PSR_ABT_MASK|PSR_FIQ_MASK|PSR_IRQ_MASK|PSR_MODE_SVC) -#define PSR_GUEST64_INIT (PSR_ABT_MASK|PSR_FIQ_MASK|PSR_IRQ_MASK|PSR_MODE_EL1h) - -#define SCTLR_GUEST_INIT 0x00c50078 - -/* - * Virtual machine platform (memory layout, interrupts) - * - * These are defined for consistency between the tools and the - * hypervisor. Guests must not rely on these hardcoded values but - * should instead use the FDT. - */ - -/* Physical Address Space */ - -/* vGIC mappings: Only one set of mapping is used by the guest. - * Therefore they can overlap. - */ - -/* vGIC v2 mappings */ -#define GUEST_GICD_BASE 0x03001000ULL -#define GUEST_GICD_SIZE 0x00001000ULL -#define GUEST_GICC_BASE 0x03002000ULL -#define GUEST_GICC_SIZE 0x00000100ULL - -/* vGIC v3 mappings */ -#define GUEST_GICV3_GICD_BASE 0x03001000ULL -#define GUEST_GICV3_GICD_SIZE 0x00010000ULL - -#define GUEST_GICV3_RDIST_STRIDE 0x20000ULL -#define GUEST_GICV3_RDIST_REGIONS 1 - -#define GUEST_GICV3_GICR0_BASE 0x03020000ULL /* vCPU0 - vCPU7 */ -#define GUEST_GICV3_GICR0_SIZE 0x00100000ULL - -/* 16MB == 4096 pages reserved for guest to use as a region to map its - * grant table in. - */ -#define GUEST_GNTTAB_BASE 0x38000000ULL -#define GUEST_GNTTAB_SIZE 0x01000000ULL - -#define GUEST_MAGIC_BASE 0x39000000ULL -#define GUEST_MAGIC_SIZE 0x01000000ULL - -#define GUEST_RAM_BANKS 2 - -#define GUEST_RAM0_BASE 0x40000000ULL /* 3GB of low RAM @ 1GB */ -#define GUEST_RAM0_SIZE 0xc0000000ULL - -#define GUEST_RAM1_BASE 0x0200000000ULL /* 1016GB of RAM @ 8GB */ -#define GUEST_RAM1_SIZE 0xfe00000000ULL - -#define GUEST_RAM_BASE GUEST_RAM0_BASE /* Lowest RAM address */ -/* Largest amount of actual RAM, not including holes */ -#define GUEST_RAM_MAX (GUEST_RAM0_SIZE + GUEST_RAM1_SIZE) -/* Suitable for e.g. const uint64_t ramfoo[] = GUEST_RAM_BANK_FOOS; */ -#define GUEST_RAM_BANK_BASES { GUEST_RAM0_BASE, GUEST_RAM1_BASE } -#define GUEST_RAM_BANK_SIZES { GUEST_RAM0_SIZE, GUEST_RAM1_SIZE } - -/* Interrupts */ -#define GUEST_TIMER_VIRT_PPI 27 -#define GUEST_TIMER_PHYS_S_PPI 29 -#define GUEST_TIMER_PHYS_NS_PPI 30 -#define GUEST_EVTCHN_PPI 31 - -/* PSCI functions */ -#define PSCI_cpu_suspend 0 -#define PSCI_cpu_off 1 -#define PSCI_cpu_on 2 -#define PSCI_migrate 3 - -#endif - -#endif /* __XEN_PUBLIC_ARCH_ARM_H__ */ - -/* - * Local variables: - * mode: C - * c-file-style: "BSD" - * c-basic-offset: 4 - * tab-width: 4 - * indent-tabs-mode: nil - * End: - */ diff --git a/OvmfPkg/Include/IndustryStandard/Xen/arch-x86/xen-x86_32.h b/OvmfPkg/Include/IndustryStandard/Xen/arch-x86/xen-x86_32.h deleted file mode 100644 index 82f9e49f33..0000000000 --- a/OvmfPkg/Include/IndustryStandard/Xen/arch-x86/xen-x86_32.h +++ /dev/null @@ -1,59 +0,0 @@ -/****************************************************************************** - * xen-x86_32.h - * - * Guest OS interface to x86 32-bit Xen. - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to - * deal in the Software without restriction, including without limitation the - * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or - * sell copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING - * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER - * DEALINGS IN THE SOFTWARE. - * - * Copyright (c) 2004-2007, K A Fraser - */ - -#ifndef __XEN_PUBLIC_ARCH_X86_XEN_X86_32_H__ -#define __XEN_PUBLIC_ARCH_X86_XEN_X86_32_H__ - -/* - * Hypercall interface: - * Input: %ebx, %ecx, %edx, %esi, %edi, %ebp (arguments 1-6) - * Output: %eax - * Access is via hypercall page (set up by guest loader or via a Xen MSR): - * call hypercall_page + hypercall-number * 32 - * Clobbered: Argument registers (e.g., 2-arg hypercall clobbers %ebx,%ecx) - */ - -#ifndef __ASSEMBLY__ - -struct arch_vcpu_info { - UINTN cr2; - UINTN pad[5]; /* sizeof(vcpu_info_t) == 64 */ -}; -typedef struct arch_vcpu_info arch_vcpu_info_t; - -#endif /* !__ASSEMBLY__ */ - -#endif /* __XEN_PUBLIC_ARCH_X86_XEN_X86_32_H__ */ - -/* - * Local variables: - * mode: C - * c-file-style: "BSD" - * c-basic-offset: 4 - * tab-width: 4 - * indent-tabs-mode: nil - * End: - */ diff --git a/OvmfPkg/Include/IndustryStandard/Xen/arch-x86/xen-x86_64.h b/OvmfPkg/Include/IndustryStandard/Xen/arch-x86/xen-x86_64.h deleted file mode 100644 index ad2b6b0a4c..0000000000 --- a/OvmfPkg/Include/IndustryStandard/Xen/arch-x86/xen-x86_64.h +++ /dev/null @@ -1,59 +0,0 @@ -/****************************************************************************** - * xen-x86_64.h - * - * Guest OS interface to x86 64-bit Xen. - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to - * deal in the Software without restriction, including without limitation the - * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or - * sell copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING - * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER - * DEALINGS IN THE SOFTWARE. - * - * Copyright (c) 2004-2006, K A Fraser - */ - -#ifndef __XEN_PUBLIC_ARCH_X86_XEN_X86_64_H__ -#define __XEN_PUBLIC_ARCH_X86_XEN_X86_64_H__ - -/* - * Hypercall interface: - * Input: %rdi, %rsi, %rdx, %r10, %r8, %r9 (arguments 1-6) - * Output: %rax - * Access is via hypercall page (set up by guest loader or via a Xen MSR): - * call hypercall_page + hypercall-number * 32 - * Clobbered: argument registers (e.g., 2-arg hypercall clobbers %rdi,%rsi) - */ - -#ifndef __ASSEMBLY__ - -struct arch_vcpu_info { - UINTN cr2; - UINTN pad; /* sizeof(vcpu_info_t) == 64 */ -}; -typedef struct arch_vcpu_info arch_vcpu_info_t; - -#endif /* !__ASSEMBLY__ */ - -#endif /* __XEN_PUBLIC_ARCH_X86_XEN_X86_64_H__ */ - -/* - * Local variables: - * mode: C - * c-file-style: "BSD" - * c-basic-offset: 4 - * tab-width: 4 - * indent-tabs-mode: nil - * End: - */ diff --git a/OvmfPkg/Include/IndustryStandard/Xen/arch-x86/xen.h b/OvmfPkg/Include/IndustryStandard/Xen/arch-x86/xen.h deleted file mode 100644 index 684ca688c0..0000000000 --- a/OvmfPkg/Include/IndustryStandard/Xen/arch-x86/xen.h +++ /dev/null @@ -1,112 +0,0 @@ -/****************************************************************************** - * arch-x86/xen.h - * - * Guest OS interface to x86 Xen. - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to - * deal in the Software without restriction, including without limitation the - * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or - * sell copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING - * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER - * DEALINGS IN THE SOFTWARE. - * - * Copyright (c) 2004-2006, K A Fraser - */ - -#include "../xen.h" - -#ifndef __XEN_PUBLIC_ARCH_X86_XEN_H__ -#define __XEN_PUBLIC_ARCH_X86_XEN_H__ - -/* Structural guest handles introduced in 0x00030201. */ -#if __XEN_INTERFACE_VERSION__ >= 0x00030201 -#define ___DEFINE_XEN_GUEST_HANDLE(name, type) \ - typedef struct { type *p; } __guest_handle_ ## name -#else -#define ___DEFINE_XEN_GUEST_HANDLE(name, type) \ - typedef type * __guest_handle_ ## name -#endif - -/* - * XEN_GUEST_HANDLE represents a guest pointer, when passed as a field - * in a struct in memory. - * XEN_GUEST_HANDLE_PARAM represent a guest pointer, when passed as an - * hypercall argument. - * XEN_GUEST_HANDLE_PARAM and XEN_GUEST_HANDLE are the same on X86 but - * they might not be on other architectures. - */ -#define __DEFINE_XEN_GUEST_HANDLE(name, type) \ - ___DEFINE_XEN_GUEST_HANDLE(name, type); \ - ___DEFINE_XEN_GUEST_HANDLE(const_##name, const type) -#define DEFINE_XEN_GUEST_HANDLE(name) __DEFINE_XEN_GUEST_HANDLE(name, name) -#define __XEN_GUEST_HANDLE(name) __guest_handle_ ## name -#define XEN_GUEST_HANDLE(name) __XEN_GUEST_HANDLE(name) -#define XEN_GUEST_HANDLE_PARAM(name) XEN_GUEST_HANDLE(name) -#define set_xen_guest_handle_raw(hnd, val) do { (hnd).p = val; } while (0) -#ifdef __XEN_TOOLS__ -#define get_xen_guest_handle(val, hnd) do { val = (hnd).p; } while (0) -#endif -#define set_xen_guest_handle(hnd, val) set_xen_guest_handle_raw(hnd, val) - -#if defined(MDE_CPU_IA32) -#include "xen-x86_32.h" -#elif defined(MDE_CPU_X64) -#include "xen-x86_64.h" -#endif - -#ifndef __ASSEMBLY__ -typedef UINTN xen_pfn_t; -#define PRI_xen_pfn "lx" -#endif - -#define XEN_HAVE_PV_UPCALL_MASK 1 - -/* Maximum number of virtual CPUs in legacy multi-processor guests. */ -#define XEN_LEGACY_MAX_VCPUS 32 - -#ifndef __ASSEMBLY__ - -typedef UINTN xen_ulong_t; -#define PRI_xen_ulong "lx" - -typedef UINT64 tsc_timestamp_t; /* RDTSC timestamp */ - -#ifdef MDE_CPU_IA32 -#pragma pack(4) -#endif -struct arch_shared_info { - UINTN max_pfn; /* max pfn that appears in table */ - /* Frame containing list of mfns containing list of mfns containing p2m. */ - xen_pfn_t pfn_to_mfn_frame_list_list; - UINTN nmi_reason; - UINT64 pad[32]; -}; -typedef struct arch_shared_info arch_shared_info_t; -#ifdef MDE_CPU_IA32 -#pragma pack() -#endif - -#endif /* !__ASSEMBLY__ */ - -#endif /* __XEN_PUBLIC_ARCH_X86_XEN_H__ */ - -/* - * Local variables: - * mode: C - * c-file-style: "BSD" - * c-basic-offset: 4 - * tab-width: 4 - * indent-tabs-mode: nil - * End: - */ diff --git a/OvmfPkg/Include/IndustryStandard/Xen/event_channel.h b/OvmfPkg/Include/IndustryStandard/Xen/event_channel.h deleted file mode 100644 index 6377ce7b1a..0000000000 --- a/OvmfPkg/Include/IndustryStandard/Xen/event_channel.h +++ /dev/null @@ -1,118 +0,0 @@ -/****************************************************************************** - * event_channel.h - * - * Event channels between domains. - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to - * deal in the Software without restriction, including without limitation the - * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or - * sell copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING - * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER - * DEALINGS IN THE SOFTWARE. - * - * Copyright (c) 2003-2004, K A Fraser. - */ - -#ifndef __XEN_PUBLIC_EVENT_CHANNEL_H__ -#define __XEN_PUBLIC_EVENT_CHANNEL_H__ - -#include "xen.h" - -/* - * `incontents 150 evtchn Event Channels - * - * Event channels are the basic primitive provided by Xen for event - * notifications. An event is the Xen equivalent of a hardware - * interrupt. They essentially store one bit of information, the event - * of interest is signalled by transitioning this bit from 0 to 1. - * - * Notifications are received by a guest via an upcall from Xen, - * indicating when an event arrives (setting the bit). Further - * notifications are masked until the bit is cleared again (therefore, - * guests must check the value of the bit after re-enabling event - * delivery to ensure no missed notifications). - * - * Event notifications can be masked by setting a flag; this is - * equivalent to disabling interrupts and can be used to ensure - * atomicity of certain operations in the guest kernel. - * - * Event channels are represented by the evtchn_* fields in - * struct shared_info and struct vcpu_info. - */ - -/* - * ` enum neg_errnoval - * ` HYPERVISOR_event_channel_op(enum event_channel_op cmd, VOID *args) - * ` - * @cmd == EVTCHNOP_* (event-channel operation). - * @args == struct evtchn_* Operation-specific extra arguments (NULL if none). - */ - -/* ` enum event_channel_op { // EVTCHNOP_* => struct evtchn_* */ -#define EVTCHNOP_close 3 -#define EVTCHNOP_send 4 -#define EVTCHNOP_alloc_unbound 6 -/* ` } */ - -typedef UINT32 evtchn_port_t; -DEFINE_XEN_GUEST_HANDLE(evtchn_port_t); - -/* - * EVTCHNOP_alloc_unbound: Allocate a port in domain and mark as - * accepting interdomain bindings from domain . A fresh port - * is allocated in and returned as . - * NOTES: - * 1. If the caller is unprivileged then must be DOMID_SELF. - * 2. may be DOMID_SELF, allowing loopback connections. - */ -struct evtchn_alloc_unbound { - /* IN parameters */ - domid_t dom, remote_dom; - /* OUT parameters */ - evtchn_port_t port; -}; -typedef struct evtchn_alloc_unbound evtchn_alloc_unbound_t; - -/* - * EVTCHNOP_close: Close a local event channel . If the channel is - * interdomain then the remote end is placed in the unbound state - * (EVTCHNSTAT_unbound), awaiting a new connection. - */ -struct evtchn_close { - /* IN parameters. */ - evtchn_port_t port; -}; -typedef struct evtchn_close evtchn_close_t; - -/* - * EVTCHNOP_send: Send an event to the remote end of the channel whose local - * endpoint is . - */ -struct evtchn_send { - /* IN parameters. */ - evtchn_port_t port; -}; -typedef struct evtchn_send evtchn_send_t; - -#endif /* __XEN_PUBLIC_EVENT_CHANNEL_H__ */ - -/* - * Local variables: - * mode: C - * c-file-style: "BSD" - * c-basic-offset: 4 - * tab-width: 4 - * indent-tabs-mode: nil - * End: - */ diff --git a/OvmfPkg/Include/IndustryStandard/Xen/grant_table.h b/OvmfPkg/Include/IndustryStandard/Xen/grant_table.h deleted file mode 100644 index 029d049382..0000000000 --- a/OvmfPkg/Include/IndustryStandard/Xen/grant_table.h +++ /dev/null @@ -1,444 +0,0 @@ -/****************************************************************************** - * grant_table.h - * - * Interface for granting foreign access to page frames, and receiving - * page-ownership transfers. - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to - * deal in the Software without restriction, including without limitation the - * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or - * sell copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING - * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER - * DEALINGS IN THE SOFTWARE. - * - * Copyright (c) 2004, K A Fraser - */ - -#ifndef __XEN_PUBLIC_GRANT_TABLE_H__ -#define __XEN_PUBLIC_GRANT_TABLE_H__ - -#include "xen.h" - -/* - * `incontents 150 gnttab Grant Tables - * - * Xen's grant tables provide a generic mechanism to memory sharing - * between domains. This shared memory interface underpins the split - * device drivers for block and network IO. - * - * Each domain has its own grant table. This is a data structure that - * is shared with Xen; it allows the domain to tell Xen what kind of - * permissions other domains have on its pages. Entries in the grant - * table are identified by grant references. A grant reference is an - * integer, which indexes into the grant table. It acts as a - * capability which the grantee can use to perform operations on the - * granter's memory. - * - * This capability-based system allows shared-memory communications - * between unprivileged domains. A grant reference also encapsulates - * the details of a shared page, removing the need for a domain to - * know the real machine address of a page it is sharing. This makes - * it possible to share memory correctly with domains running in - * fully virtualised memory. - */ - -/*********************************** - * GRANT TABLE REPRESENTATION - */ - -/* Some rough guidelines on accessing and updating grant-table entries - * in a concurrency-safe manner. For more information, Linux contains a - * reference implementation for guest OSes (drivers/xen/grant_table.c, see - * http://git.kernel.org/?p=linux/kernel/git/torvalds/linux.git;a=blob;f=drivers/xen/grant-table.c;hb=HEAD - * - * NB. WMB is a no-op on current-generation x86 processors. However, a - * compiler barrier will still be required. - * - * Introducing a valid entry into the grant table: - * 1. Write ent->domid. - * 2. Write ent->frame: - * GTF_permit_access: Frame to which access is permitted. - * GTF_accept_transfer: Pseudo-phys frame slot being filled by new - * frame, or zero if none. - * 3. Write memory barrier (WMB). - * 4. Write ent->flags, inc. valid type. - * - * Invalidating an unused GTF_permit_access entry: - * 1. flags = ent->flags. - * 2. Observe that !(flags & (GTF_reading|GTF_writing)). - * 3. Check result of SMP-safe CMPXCHG(&ent->flags, flags, 0). - * NB. No need for WMB as reuse of entry is control-dependent on success of - * step 3, and all architectures guarantee ordering of ctrl-dep writes. - * - * Invalidating an in-use GTF_permit_access entry: - * This cannot be done directly. Request assistance from the domain controller - * which can set a timeout on the use of a grant entry and take necessary - * action. (NB. This is not yet implemented!). - * - * Invalidating an unused GTF_accept_transfer entry: - * 1. flags = ent->flags. - * 2. Observe that !(flags & GTF_transfer_committed). [*] - * 3. Check result of SMP-safe CMPXCHG(&ent->flags, flags, 0). - * NB. No need for WMB as reuse of entry is control-dependent on success of - * step 3, and all architectures guarantee ordering of ctrl-dep writes. - * [*] If GTF_transfer_committed is set then the grant entry is 'committed'. - * The guest must /not/ modify the grant entry until the address of the - * transferred frame is written. It is safe for the guest to spin waiting - * for this to occur (detect by observing GTF_transfer_completed in - * ent->flags). - * - * Invalidating a committed GTF_accept_transfer entry: - * 1. Wait for (ent->flags & GTF_transfer_completed). - * - * Changing a GTF_permit_access from writable to read-only: - * Use SMP-safe CMPXCHG to set GTF_readonly, while checking !GTF_writing. - * - * Changing a GTF_permit_access from read-only to writable: - * Use SMP-safe bit-setting instruction. - */ - -/* - * Reference to a grant entry in a specified domain's grant table. - */ -typedef UINT32 grant_ref_t; - -/* - * A grant table comprises a packed array of grant entries in one or more - * page frames shared between Xen and a guest. - * [XEN]: This field is written by Xen and read by the sharing guest. - * [GST]: This field is written by the guest and read by Xen. - */ - -/* - * Version 1 of the grant table entry structure is maintained purely - * for backwards compatibility. New guests should use version 2. - */ -#if __XEN_INTERFACE_VERSION__ < 0x0003020a -#define grant_entry_v1 grant_entry -#define grant_entry_v1_t grant_entry_t -#endif -struct grant_entry_v1 { - /* GTF_xxx: various type and flag information. [XEN,GST] */ - UINT16 flags; - /* The domain being granted foreign privileges. [GST] */ - domid_t domid; - /* - * GTF_permit_access: Frame that @domid is allowed to map and access. [GST] - * GTF_accept_transfer: Frame whose ownership transferred by @domid. [XEN] - */ - UINT32 frame; -}; -typedef struct grant_entry_v1 grant_entry_v1_t; - -/* The first few grant table entries will be preserved across grant table - * version changes and may be pre-populated at domain creation by tools. - */ -#define GNTTAB_NR_RESERVED_ENTRIES 8 -#define GNTTAB_RESERVED_CONSOLE 0 -#define GNTTAB_RESERVED_XENSTORE 1 - -/* - * Type of grant entry. - * GTF_invalid: This grant entry grants no privileges. - * GTF_permit_access: Allow @domid to map/access @frame. - * GTF_accept_transfer: Allow @domid to transfer ownership of one page frame - * to this guest. Xen writes the page number to @frame. - * GTF_transitive: Allow @domid to transitively access a subrange of - * @trans_grant in @trans_domid. No mappings are allowed. - */ -#define GTF_invalid (0U<<0) -#define GTF_permit_access (1U<<0) -#define GTF_accept_transfer (2U<<0) -#define GTF_transitive (3U<<0) -#define GTF_type_mask (3U<<0) - -/* - * Subflags for GTF_permit_access. - * GTF_readonly: Restrict @domid to read-only mappings and accesses. [GST] - * GTF_reading: Grant entry is currently mapped for reading by @domid. [XEN] - * GTF_writing: Grant entry is currently mapped for writing by @domid. [XEN] - * GTF_PAT, GTF_PWT, GTF_PCD: (x86) cache attribute flags for the grant [GST] - * GTF_sub_page: Grant access to only a subrange of the page. @domid - * will only be allowed to copy from the grant, and not - * map it. [GST] - */ -#define _GTF_readonly (2) -#define GTF_readonly (1U<<_GTF_readonly) -#define _GTF_reading (3) -#define GTF_reading (1U<<_GTF_reading) -#define _GTF_writing (4) -#define GTF_writing (1U<<_GTF_writing) -#define _GTF_PWT (5) -#define GTF_PWT (1U<<_GTF_PWT) -#define _GTF_PCD (6) -#define GTF_PCD (1U<<_GTF_PCD) -#define _GTF_PAT (7) -#define GTF_PAT (1U<<_GTF_PAT) -#define _GTF_sub_page (8) -#define GTF_sub_page (1U<<_GTF_sub_page) - -/* - * Subflags for GTF_accept_transfer: - * GTF_transfer_committed: Xen sets this flag to indicate that it is committed - * to transferring ownership of a page frame. When a guest sees this flag - * it must /not/ modify the grant entry until GTF_transfer_completed is - * set by Xen. - * GTF_transfer_completed: It is safe for the guest to spin-wait on this flag - * after reading GTF_transfer_committed. Xen will always write the frame - * address, followed by ORing this flag, in a timely manner. - */ -#define _GTF_transfer_committed (2) -#define GTF_transfer_committed (1U<<_GTF_transfer_committed) -#define _GTF_transfer_completed (3) -#define GTF_transfer_completed (1U<<_GTF_transfer_completed) - -/* - * Version 2 grant table entries. These fulfil the same role as - * version 1 entries, but can represent more complicated operations. - * Any given domain will have either a version 1 or a version 2 table, - * and every entry in the table will be the same version. - * - * The interface by which domains use grant references does not depend - * on the grant table version in use by the other domain. - */ -#if __XEN_INTERFACE_VERSION__ >= 0x0003020a -/* - * Version 1 and version 2 grant entries share a common prefix. The - * fields of the prefix are documented as part of struct - * grant_entry_v1. - */ -struct grant_entry_header { - UINT16 flags; - domid_t domid; -}; -typedef struct grant_entry_header grant_entry_header_t; - -/* - * Version 2 of the grant entry structure. - */ -union grant_entry_v2 { - grant_entry_header_t hdr; - - /* - * This member is used for V1-style full page grants, where either: - * - * -- hdr.type is GTF_accept_transfer, or - * -- hdr.type is GTF_permit_access and GTF_sub_page is not set. - * - * In that case, the frame field has the same semantics as the - * field of the same name in the V1 entry structure. - */ - struct { - grant_entry_header_t hdr; - UINT32 pad0; - UINT64 frame; - } full_page; - - /* - * If the grant type is GTF_grant_access and GTF_sub_page is set, - * @domid is allowed to access bytes [@page_off,@page_off+@length) - * in frame @frame. - */ - struct { - grant_entry_header_t hdr; - UINT16 page_off; - UINT16 length; - UINT64 frame; - } sub_page; - - /* - * If the grant is GTF_transitive, @domid is allowed to use the - * grant @gref in domain @trans_domid, as if it was the local - * domain. Obviously, the transitive access must be compatible - * with the original grant. - * - * The current version of Xen does not allow transitive grants - * to be mapped. - */ - struct { - grant_entry_header_t hdr; - domid_t trans_domid; - UINT16 pad0; - grant_ref_t gref; - } transitive; - - UINT32 __spacer[4]; /* Pad to a power of two */ -}; -typedef union grant_entry_v2 grant_entry_v2_t; - -typedef UINT16 grant_status_t; - -#endif /* __XEN_INTERFACE_VERSION__ */ - -/*********************************** - * GRANT TABLE QUERIES AND USES - */ - -/* ` enum neg_errnoval - * ` HYPERVISOR_grant_table_op(enum grant_table_op cmd, - * ` VOID *args, - * ` UINT32 count) - * ` - * - * @args points to an array of a per-command data structure. The array - * has @count members - */ - -/* ` enum grant_table_op { // GNTTABOP_* => struct gnttab_* */ -#define GNTTABOP_map_grant_ref 0 -#define GNTTABOP_unmap_grant_ref 1 -/* ` } */ - -/* - * Handle to track a mapping created via a grant reference. - */ -typedef UINT32 grant_handle_t; - -/* - * GNTTABOP_map_grant_ref: Map the grant entry (,) for access - * by devices and/or host CPUs. If successful, is a tracking number - * that must be presented later to destroy the mapping(s). On error, - * is a negative status code. - * NOTES: - * 1. If GNTMAP_device_map is specified then is the address - * via which I/O devices may access the granted frame. - * 2. If GNTMAP_host_map is specified then a mapping will be added at - * either a host virtual address in the current address space, or at - * a PTE at the specified machine address. The type of mapping to - * perform is selected through the GNTMAP_contains_pte flag, and the - * address is specified in . - * 3. Mappings should only be destroyed via GNTTABOP_unmap_grant_ref. If a - * host mapping is destroyed by other means then it is *NOT* guaranteed - * to be accounted to the correct grant reference! - */ -struct gnttab_map_grant_ref { - /* IN parameters. */ - UINT64 host_addr; - UINT32 flags; /* GNTMAP_* */ - grant_ref_t ref; - domid_t dom; - /* OUT parameters. */ - INT16 status; /* => enum grant_status */ - grant_handle_t handle; - UINT64 dev_bus_addr; -}; -typedef struct gnttab_map_grant_ref gnttab_map_grant_ref_t; -DEFINE_XEN_GUEST_HANDLE(gnttab_map_grant_ref_t); - -/* - * GNTTABOP_unmap_grant_ref: Destroy one or more grant-reference mappings - * tracked by . If or is zero, that - * field is ignored. If non-zero, they must refer to a device/host mapping - * that is tracked by - * NOTES: - * 1. The call may fail in an undefined manner if either mapping is not - * tracked by . - * 3. After executing a batch of unmaps, it is guaranteed that no stale - * mappings will remain in the device or host TLBs. - */ -struct gnttab_unmap_grant_ref { - /* IN parameters. */ - UINT64 host_addr; - UINT64 dev_bus_addr; - grant_handle_t handle; - /* OUT parameters. */ - INT16 status; /* => enum grant_status */ -}; -typedef struct gnttab_unmap_grant_ref gnttab_unmap_grant_ref_t; -DEFINE_XEN_GUEST_HANDLE(gnttab_unmap_grant_ref_t); - -/* - * Bitfield values for gnttab_map_grant_ref.flags. - */ - /* Map the grant entry for access by I/O devices. */ -#define _GNTMAP_device_map (0) -#define GNTMAP_device_map (1<<_GNTMAP_device_map) - /* Map the grant entry for access by host CPUs. */ -#define _GNTMAP_host_map (1) -#define GNTMAP_host_map (1<<_GNTMAP_host_map) - /* Accesses to the granted frame will be restricted to read-only access. */ -#define _GNTMAP_readonly (2) -#define GNTMAP_readonly (1<<_GNTMAP_readonly) - /* - * GNTMAP_host_map subflag: - * 0 => The host mapping is usable only by the guest OS. - * 1 => The host mapping is usable by guest OS + current application. - */ -#define _GNTMAP_application_map (3) -#define GNTMAP_application_map (1<<_GNTMAP_application_map) - - /* - * GNTMAP_contains_pte subflag: - * 0 => This map request contains a host virtual address. - * 1 => This map request contains the machine addess of the PTE to update. - */ -#define _GNTMAP_contains_pte (4) -#define GNTMAP_contains_pte (1<<_GNTMAP_contains_pte) - -#define _GNTMAP_can_fail (5) -#define GNTMAP_can_fail (1<<_GNTMAP_can_fail) - -/* - * Bits to be placed in guest kernel available PTE bits (architecture - * dependent; only supported when XENFEAT_gnttab_map_avail_bits is set). - */ -#define _GNTMAP_guest_avail0 (16) -#define GNTMAP_guest_avail_mask ((UINT32)~0 << _GNTMAP_guest_avail0) - -/* - * Values for error status returns. All errors are -ve. - */ -/* ` enum grant_status { */ -#define GNTST_okay (0) /* Normal return. */ -#define GNTST_general_error (-1) /* General undefined error. */ -#define GNTST_bad_domain (-2) /* Unrecognsed domain id. */ -#define GNTST_bad_gntref (-3) /* Unrecognised or inappropriate gntref. */ -#define GNTST_bad_handle (-4) /* Unrecognised or inappropriate handle. */ -#define GNTST_bad_virt_addr (-5) /* Inappropriate virtual address to map. */ -#define GNTST_bad_dev_addr (-6) /* Inappropriate device address to unmap.*/ -#define GNTST_no_device_space (-7) /* Out of space in I/O MMU. */ -#define GNTST_permission_denied (-8) /* Not enough privilege for operation. */ -#define GNTST_bad_page (-9) /* Specified page was invalid for op. */ -#define GNTST_bad_copy_arg (-10) /* copy arguments cross page boundary. */ -#define GNTST_address_too_big (-11) /* transfer page address too large. */ -#define GNTST_eagain (-12) /* Operation not done; try again. */ -/* ` } */ - -#define GNTTABOP_error_msgs { \ - "okay", \ - "undefined error", \ - "unrecognised domain id", \ - "invalid grant reference", \ - "invalid mapping handle", \ - "invalid virtual address", \ - "invalid device address", \ - "no spare translation slot in the I/O MMU", \ - "permission denied", \ - "bad page", \ - "copy arguments cross page boundary", \ - "page address size too large", \ - "operation not done; try again" \ -} - -#endif /* __XEN_PUBLIC_GRANT_TABLE_H__ */ - -/* - * Local variables: - * mode: C - * c-file-style: "BSD" - * c-basic-offset: 4 - * tab-width: 4 - * indent-tabs-mode: nil - * End: - */ diff --git a/OvmfPkg/Include/IndustryStandard/Xen/hvm/hvm_op.h b/OvmfPkg/Include/IndustryStandard/Xen/hvm/hvm_op.h deleted file mode 100644 index bd8d445c08..0000000000 --- a/OvmfPkg/Include/IndustryStandard/Xen/hvm/hvm_op.h +++ /dev/null @@ -1,37 +0,0 @@ -/* - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to - * deal in the Software without restriction, including without limitation the - * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or - * sell copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING - * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER - * DEALINGS IN THE SOFTWARE. - */ - -#ifndef __XEN_PUBLIC_HVM_HVM_OP_H__ -#define __XEN_PUBLIC_HVM_HVM_OP_H__ - -#include "../xen.h" - -/* Get/set subcommands: extra argument == pointer to xen_hvm_param struct. */ -#define HVMOP_set_param 0 -#define HVMOP_get_param 1 -struct xen_hvm_param { - domid_t domid; /* IN */ - UINT32 index; /* IN */ - UINT64 value; /* IN/OUT */ -}; -typedef struct xen_hvm_param xen_hvm_param_t; -DEFINE_XEN_GUEST_HANDLE(xen_hvm_param_t); - -#endif /* __XEN_PUBLIC_HVM_HVM_OP_H__ */ diff --git a/OvmfPkg/Include/IndustryStandard/Xen/hvm/params.h b/OvmfPkg/Include/IndustryStandard/Xen/hvm/params.h deleted file mode 100644 index cac33359ce..0000000000 --- a/OvmfPkg/Include/IndustryStandard/Xen/hvm/params.h +++ /dev/null @@ -1,150 +0,0 @@ -/* - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to - * deal in the Software without restriction, including without limitation the - * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or - * sell copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING - * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER - * DEALINGS IN THE SOFTWARE. - */ - -#ifndef __XEN_PUBLIC_HVM_PARAMS_H__ -#define __XEN_PUBLIC_HVM_PARAMS_H__ - -#include "hvm_op.h" - -/* - * Parameter space for HVMOP_{set,get}_param. - */ - -/* - * How should CPU0 event-channel notifications be delivered? - * val[63:56] == 0: val[55:0] is a delivery GSI (Global System Interrupt). - * val[63:56] == 1: val[55:0] is a delivery PCI INTx line, as follows: - * Domain = val[47:32], Bus = val[31:16], - * DevFn = val[15: 8], IntX = val[ 1: 0] - * val[63:56] == 2: val[7:0] is a vector number, check for - * XENFEAT_hvm_callback_vector to know if this delivery - * method is available. - * If val == 0 then CPU0 event-channel notifications are not delivered. - */ -#define HVM_PARAM_CALLBACK_IRQ 0 - -/* - * These are not used by Xen. They are here for convenience of HVM-guest - * xenbus implementations. - */ -#define HVM_PARAM_STORE_PFN 1 -#define HVM_PARAM_STORE_EVTCHN 2 - -#define HVM_PARAM_PAE_ENABLED 4 - -#define HVM_PARAM_IOREQ_PFN 5 - -#define HVM_PARAM_BUFIOREQ_PFN 6 -#define HVM_PARAM_BUFIOREQ_EVTCHN 26 - -#if defined(MDE_CPU_IA32) || defined(MDE_CPU_X64) - -/* Expose Viridian interfaces to this HVM guest? */ -#define HVM_PARAM_VIRIDIAN 9 - -#endif - -/* - * Set mode for virtual timers (currently x86 only): - * delay_for_missed_ticks (default): - * Do not advance a vcpu's time beyond the correct delivery time for - * interrupts that have been missed due to preemption. Deliver missed - * interrupts when the vcpu is rescheduled and advance the vcpu's virtual - * time stepwise for each one. - * no_delay_for_missed_ticks: - * As above, missed interrupts are delivered, but guest time always tracks - * wallclock (i.e., real) time while doing so. - * no_missed_ticks_pending: - * No missed interrupts are held pending. Instead, to ensure ticks are - * delivered at some non-zero rate, if we detect missed ticks then the - * internal tick alarm is not disabled if the VCPU is preempted during the - * next tick period. - * one_missed_tick_pending: - * Missed interrupts are collapsed together and delivered as one 'late tick'. - * Guest time always tracks wallclock (i.e., real) time. - */ -#define HVM_PARAM_TIMER_MODE 10 -#define HVMPTM_delay_for_missed_ticks 0 -#define HVMPTM_no_delay_for_missed_ticks 1 -#define HVMPTM_no_missed_ticks_pending 2 -#define HVMPTM_one_missed_tick_pending 3 - -/* Boolean: Enable virtual HPET (high-precision event timer)? (x86-only) */ -#define HVM_PARAM_HPET_ENABLED 11 - -/* Identity-map page directory used by Intel EPT when CR0.PG=0. */ -#define HVM_PARAM_IDENT_PT 12 - -/* Device Model domain, defaults to 0. */ -#define HVM_PARAM_DM_DOMAIN 13 - -/* ACPI S state: currently support S0 and S3 on x86. */ -#define HVM_PARAM_ACPI_S_STATE 14 - -/* TSS used on Intel when CR0.PE=0. */ -#define HVM_PARAM_VM86_TSS 15 - -/* Boolean: Enable aligning all periodic vpts to reduce interrupts */ -#define HVM_PARAM_VPT_ALIGN 16 - -/* Console debug shared memory ring and event channel */ -#define HVM_PARAM_CONSOLE_PFN 17 -#define HVM_PARAM_CONSOLE_EVTCHN 18 - -/* - * Select location of ACPI PM1a and TMR control blocks. Currently two locations - * are supported, specified by version 0 or 1 in this parameter: - * - 0: default, use the old addresses - * PM1A_EVT == 0x1f40; PM1A_CNT == 0x1f44; PM_TMR == 0x1f48 - * - 1: use the new default qemu addresses - * PM1A_EVT == 0xb000; PM1A_CNT == 0xb004; PM_TMR == 0xb008 - * You can find these address definitions in - */ -#define HVM_PARAM_ACPI_IOPORTS_LOCATION 19 - -/* Enable blocking memory events, async or sync (pause vcpu until response) - * onchangeonly indicates messages only on a change of value */ -#define HVM_PARAM_MEMORY_EVENT_CR0 20 -#define HVM_PARAM_MEMORY_EVENT_CR3 21 -#define HVM_PARAM_MEMORY_EVENT_CR4 22 -#define HVM_PARAM_MEMORY_EVENT_INT3 23 -#define HVM_PARAM_MEMORY_EVENT_SINGLE_STEP 25 -#define HVM_PARAM_MEMORY_EVENT_MSR 30 - -#define HVMPME_MODE_MASK (3 << 0) -#define HVMPME_mode_disabled 0 -#define HVMPME_mode_async 1 -#define HVMPME_mode_sync 2 -#define HVMPME_onchangeonly (1 << 2) - -/* Boolean: Enable nestedhvm (hvm only) */ -#define HVM_PARAM_NESTEDHVM 24 - -/* Params for the mem event rings */ -#define HVM_PARAM_PAGING_RING_PFN 27 -#define HVM_PARAM_ACCESS_RING_PFN 28 -#define HVM_PARAM_SHARING_RING_PFN 29 - -/* SHUTDOWN_* action in case of a triple fault */ -#define HVM_PARAM_TRIPLE_FAULT_REASON 31 - -#define HVM_NR_PARAMS 32 - -#endif /* __XEN_PUBLIC_HVM_PARAMS_H__ */ diff --git a/OvmfPkg/Include/IndustryStandard/Xen/io/blkif.h b/OvmfPkg/Include/IndustryStandard/Xen/io/blkif.h deleted file mode 100644 index 27774d6285..0000000000 --- a/OvmfPkg/Include/IndustryStandard/Xen/io/blkif.h +++ /dev/null @@ -1,619 +0,0 @@ -/****************************************************************************** - * blkif.h - * - * Unified block-device I/O interface for Xen guest OSes. - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to - * deal in the Software without restriction, including without limitation the - * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or - * sell copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING - * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER - * DEALINGS IN THE SOFTWARE. - * - * Copyright (c) 2003-2004, Keir Fraser - * Copyright (c) 2012, Spectra Logic Corporation - */ - -#ifndef __XEN_PUBLIC_IO_BLKIF_H__ -#define __XEN_PUBLIC_IO_BLKIF_H__ - -#include "ring.h" -#include "../grant_table.h" - -/* - * Front->back notifications: When enqueuing a new request, sending a - * notification can be made conditional on req_event (i.e., the generic - * hold-off mechanism provided by the ring macros). Backends must set - * req_event appropriately (e.g., using RING_FINAL_CHECK_FOR_REQUESTS()). - * - * Back->front notifications: When enqueuing a new response, sending a - * notification can be made conditional on rsp_event (i.e., the generic - * hold-off mechanism provided by the ring macros). Frontends must set - * rsp_event appropriately (e.g., using RING_FINAL_CHECK_FOR_RESPONSES()). - */ - -#ifndef blkif_vdev_t -#define blkif_vdev_t UINT16 -#endif -#define blkif_sector_t UINT64 - -/* - * Feature and Parameter Negotiation - * ================================= - * The two halves of a Xen block driver utilize nodes within the XenStore to - * communicate capabilities and to negotiate operating parameters. This - * section enumerates these nodes which reside in the respective front and - * backend portions of the XenStore, following the XenBus convention. - * - * All data in the XenStore is stored as strings. Nodes specifying numeric - * values are encoded in decimal. Integer value ranges listed below are - * expressed as fixed sized integer types capable of storing the conversion - * of a properly formatted node string, without loss of information. - * - * Any specified default value is in effect if the corresponding XenBus node - * is not present in the XenStore. - * - * XenStore nodes in sections marked "PRIVATE" are solely for use by the - * driver side whose XenBus tree contains them. - * - * XenStore nodes marked "DEPRECATED" in their notes section should only be - * used to provide interoperability with legacy implementations. - * - * See the XenBus state transition diagram below for details on when XenBus - * nodes must be published and when they can be queried. - * - ***************************************************************************** - * Backend XenBus Nodes - ***************************************************************************** - * - *------------------ Backend Device Identification (PRIVATE) ------------------ - * - * mode - * Values: "r" (read only), "w" (writable) - * - * The read or write access permissions to the backing store to be - * granted to the frontend. - * - * params - * Values: string - * - * A free formatted string providing sufficient information for the - * backend driver to open the backing device. (e.g. the path to the - * file or block device representing the backing store.) - * - * type - * Values: "file", "phy", "tap" - * - * The type of the backing device/object. - * - *--------------------------------- Features --------------------------------- - * - * feature-barrier - * Values: 0/1 (boolean) - * Default Value: 0 - * - * A value of "1" indicates that the backend can process requests - * containing the BLKIF_OP_WRITE_BARRIER request opcode. Requests - * of this type may still be returned at any time with the - * BLKIF_RSP_EOPNOTSUPP result code. - * - * feature-flush-cache - * Values: 0/1 (boolean) - * Default Value: 0 - * - * A value of "1" indicates that the backend can process requests - * containing the BLKIF_OP_FLUSH_DISKCACHE request opcode. Requests - * of this type may still be returned at any time with the - * BLKIF_RSP_EOPNOTSUPP result code. - * - * feature-discard - * Values: 0/1 (boolean) - * Default Value: 0 - * - * A value of "1" indicates that the backend can process requests - * containing the BLKIF_OP_DISCARD request opcode. Requests - * of this type may still be returned at any time with the - * BLKIF_RSP_EOPNOTSUPP result code. - * - * feature-persistent - * Values: 0/1 (boolean) - * Default Value: 0 - * Notes: 7 - * - * A value of "1" indicates that the backend can keep the grants used - * by the frontend driver mapped, so the same set of grants should be - * used in all transactions. The maximum number of grants the backend - * can map persistently depends on the implementation, but ideally it - * should be RING_SIZE * BLKIF_MAX_SEGMENTS_PER_REQUEST. Using this - * feature the backend doesn't need to unmap each grant, preventing - * costly TLB flushes. The backend driver should only map grants - * persistently if the frontend supports it. If a backend driver chooses - * to use the persistent protocol when the frontend doesn't support it, - * it will probably hit the maximum number of persistently mapped grants - * (due to the fact that the frontend won't be reusing the same grants), - * and fall back to non-persistent mode. Backend implementations may - * shrink or expand the number of persistently mapped grants without - * notifying the frontend depending on memory constraints (this might - * cause a performance degradation). - * - * If a backend driver wants to limit the maximum number of persistently - * mapped grants to a value less than RING_SIZE * - * BLKIF_MAX_SEGMENTS_PER_REQUEST a LRU strategy should be used to - * discard the grants that are less commonly used. Using a LRU in the - * backend driver paired with a LIFO queue in the frontend will - * allow us to have better performance in this scenario. - * - *----------------------- Request Transport Parameters ------------------------ - * - * max-ring-page-order - * Values: - * Default Value: 0 - * Notes: 1, 3 - * - * The maximum supported size of the request ring buffer in units of - * lb(machine pages). (e.g. 0 == 1 page, 1 = 2 pages, 2 == 4 pages, - * etc.). - * - * max-ring-pages - * Values: - * Default Value: 1 - * Notes: DEPRECATED, 2, 3 - * - * The maximum supported size of the request ring buffer in units of - * machine pages. The value must be a power of 2. - * - *------------------------- Backend Device Properties ------------------------- - * - * discard-alignment - * Values: - * Default Value: 0 - * Notes: 4, 5 - * - * The offset, in bytes from the beginning of the virtual block device, - * to the first, addressable, discard extent on the underlying device. - * - * discard-granularity - * Values: - * Default Value: <"sector-size"> - * Notes: 4 - * - * The size, in bytes, of the individually addressable discard extents - * of the underlying device. - * - * discard-secure - * Values: 0/1 (boolean) - * Default Value: 0 - * Notes: 10 - * - * A value of "1" indicates that the backend can process BLKIF_OP_DISCARD - * requests with the BLKIF_DISCARD_SECURE flag set. - * - * info - * Values: (bitmap) - * - * A collection of bit flags describing attributes of the backing - * device. The VDISK_* macros define the meaning of each bit - * location. - * - * sector-size - * Values: - * - * The logical sector size, in bytes, of the backend device. - * - * physical-sector-size - * Values: - * - * The physical sector size, in bytes, of the backend device. - * - * sectors - * Values: - * - * The size of the backend device, expressed in units of its logical - * sector size ("sector-size"). - * - ***************************************************************************** - * Frontend XenBus Nodes - ***************************************************************************** - * - *----------------------- Request Transport Parameters ----------------------- - * - * event-channel - * Values: - * - * The identifier of the Xen event channel used to signal activity - * in the ring buffer. - * - * ring-ref - * Values: - * Notes: 6 - * - * The Xen grant reference granting permission for the backend to map - * the sole page in a single page sized ring buffer. - * - * ring-ref%u - * Values: - * Notes: 6 - * - * For a frontend providing a multi-page ring, a "number of ring pages" - * sized list of nodes, each containing a Xen grant reference granting - * permission for the backend to map the page of the ring located - * at page index "%u". Page indexes are zero based. - * - * protocol - * Values: string (XEN_IO_PROTO_ABI_*) - * Default Value: XEN_IO_PROTO_ABI_NATIVE - * - * The machine ABI rules governing the format of all ring request and - * response structures. - * - * ring-page-order - * Values: - * Default Value: 0 - * Maximum Value: MAX(ffs(max-ring-pages) - 1, max-ring-page-order) - * Notes: 1, 3 - * - * The size of the frontend allocated request ring buffer in units - * of lb(machine pages). (e.g. 0 == 1 page, 1 = 2 pages, 2 == 4 pages, - * etc.). - * - * num-ring-pages - * Values: - * Default Value: 1 - * Maximum Value: MAX(max-ring-pages,(0x1 << max-ring-page-order)) - * Notes: DEPRECATED, 2, 3 - * - * The size of the frontend allocated request ring buffer in units of - * machine pages. The value must be a power of 2. - * - * feature-persistent - * Values: 0/1 (boolean) - * Default Value: 0 - * Notes: 7, 8, 9 - * - * A value of "1" indicates that the frontend will reuse the same grants - * for all transactions, allowing the backend to map them with write - * access (even when it should be read-only). If the frontend hits the - * maximum number of allowed persistently mapped grants, it can fallback - * to non persistent mode. This will cause a performance degradation, - * since the the backend driver will still try to map those grants - * persistently. Since the persistent grants protocol is compatible with - * the previous protocol, a frontend driver can choose to work in - * persistent mode even when the backend doesn't support it. - * - * It is recommended that the frontend driver stores the persistently - * mapped grants in a LIFO queue, so a subset of all persistently mapped - * grants gets used commonly. This is done in case the backend driver - * decides to limit the maximum number of persistently mapped grants - * to a value less than RING_SIZE * BLKIF_MAX_SEGMENTS_PER_REQUEST. - * - *------------------------- Virtual Device Properties ------------------------- - * - * device-type - * Values: "disk", "cdrom", "floppy", etc. - * - * virtual-device - * Values: - * - * A value indicating the physical device to virtualize within the - * frontend's domain. (e.g. "The first ATA disk", "The third SCSI - * disk", etc.) - * - * See docs/misc/vbd-interface.txt for details on the format of this - * value. - * - * Notes - * ----- - * (1) Multi-page ring buffer scheme first developed in the Citrix XenServer - * PV drivers. - * (2) Multi-page ring buffer scheme first used in some RedHat distributions - * including a distribution deployed on certain nodes of the Amazon - * EC2 cluster. - * (3) Support for multi-page ring buffers was implemented independently, - * in slightly different forms, by both Citrix and RedHat/Amazon. - * For full interoperability, block front and backends should publish - * identical ring parameters, adjusted for unit differences, to the - * XenStore nodes used in both schemes. - * (4) Devices that support discard functionality may internally allocate space - * (discardable extents) in units that are larger than the exported logical - * block size. If the backing device has such discardable extents the - * backend should provide both discard-granularity and discard-alignment. - * Providing just one of the two may be considered an error by the frontend. - * Backends supporting discard should include discard-granularity and - * discard-alignment even if it supports discarding individual sectors. - * Frontends should assume discard-alignment == 0 and discard-granularity - * == sector size if these keys are missing. - * (5) The discard-alignment parameter allows a physical device to be - * partitioned into virtual devices that do not necessarily begin or - * end on a discardable extent boundary. - * (6) When there is only a single page allocated to the request ring, - * 'ring-ref' is used to communicate the grant reference for this - * page to the backend. When using a multi-page ring, the 'ring-ref' - * node is not created. Instead 'ring-ref0' - 'ring-refN' are used. - * (7) When using persistent grants data has to be copied from/to the page - * where the grant is currently mapped. The overhead of doing this copy - * however doesn't suppress the speed improvement of not having to unmap - * the grants. - * (8) The frontend driver has to allow the backend driver to map all grants - * with write access, even when they should be mapped read-only, since - * further requests may reuse these grants and require write permissions. - * (9) Linux implementation doesn't have a limit on the maximum number of - * grants that can be persistently mapped in the frontend driver, but - * due to the frontent driver implementation it should never be bigger - * than RING_SIZE * BLKIF_MAX_SEGMENTS_PER_REQUEST. - *(10) The discard-secure property may be present and will be set to 1 if the - * backing device supports secure discard. - */ - -/* - * STATE DIAGRAMS - * - ***************************************************************************** - * Startup * - ***************************************************************************** - * - * Tool stack creates front and back nodes with state XenbusStateInitialising. - * - * Front Back - * ================================= ===================================== - * XenbusStateInitialising XenbusStateInitialising - * o Query virtual device o Query backend device identification - * properties. data. - * o Setup OS device instance. o Open and validate backend device. - * o Publish backend features and - * transport parameters. - * | - * | - * V - * XenbusStateInitWait - * - * o Query backend features and - * transport parameters. - * o Allocate and initialize the - * request ring. - * o Publish transport parameters - * that will be in effect during - * this connection. - * | - * | - * V - * XenbusStateInitialised - * - * o Query frontend transport parameters. - * o Connect to the request ring and - * event channel. - * o Publish backend device properties. - * | - * | - * V - * XenbusStateConnected - * - * o Query backend device properties. - * o Finalize OS virtual device - * instance. - * | - * | - * V - * XenbusStateConnected - * - * Note: Drivers that do not support any optional features, or the negotiation - * of transport parameters, can skip certain states in the state machine: - * - * o A frontend may transition to XenbusStateInitialised without - * waiting for the backend to enter XenbusStateInitWait. In this - * case, default transport parameters are in effect and any - * transport parameters published by the frontend must contain - * their default values. - * - * o A backend may transition to XenbusStateInitialised, bypassing - * XenbusStateInitWait, without waiting for the frontend to first - * enter the XenbusStateInitialised state. In this case, default - * transport parameters are in effect and any transport parameters - * published by the backend must contain their default values. - * - * Drivers that support optional features and/or transport parameter - * negotiation must tolerate these additional state transition paths. - * In general this means performing the work of any skipped state - * transition, if it has not already been performed, in addition to the - * work associated with entry into the current state. - */ - -/* - * REQUEST CODES. - */ -#define BLKIF_OP_READ 0 -#define BLKIF_OP_WRITE 1 -/* - * All writes issued prior to a request with the BLKIF_OP_WRITE_BARRIER - * operation code ("barrier request") must be completed prior to the - * execution of the barrier request. All writes issued after the barrier - * request must not execute until after the completion of the barrier request. - * - * Optional. See "feature-barrier" XenBus node documentation above. - */ -#define BLKIF_OP_WRITE_BARRIER 2 -/* - * Commit any uncommitted contents of the backing device's volatile cache - * to stable storage. - * - * Optional. See "feature-flush-cache" XenBus node documentation above. - */ -#define BLKIF_OP_FLUSH_DISKCACHE 3 -/* - * Used in SLES sources for device specific command packet - * contained within the request. Reserved for that purpose. - */ -#define BLKIF_OP_RESERVED_1 4 -/* - * Indicate to the backend device that a region of storage is no longer in - * use, and may be discarded at any time without impact to the client. If - * the BLKIF_DISCARD_SECURE flag is set on the request, all copies of the - * discarded region on the device must be rendered unrecoverable before the - * command returns. - * - * This operation is analogous to performing a trim (ATA) or unamp (SCSI), - * command on a native device. - * - * More information about trim/unmap operations can be found at: - * http://t13.org/Documents/UploadedDocuments/docs2008/ - * e07154r6-Data_Set_Management_Proposal_for_ATA-ACS2.doc - * http://www.seagate.com/staticfiles/support/disc/manuals/ - * Interface%20manuals/100293068c.pdf - * - * Optional. See "feature-discard", "discard-alignment", - * "discard-granularity", and "discard-secure" in the XenBus node - * documentation above. - */ -#define BLKIF_OP_DISCARD 5 - -/* - * Recognized if "feature-max-indirect-segments" in present in the backend - * xenbus info. The "feature-max-indirect-segments" node contains the maximum - * number of segments allowed by the backend per request. If the node is - * present, the frontend might use blkif_request_indirect structs in order to - * issue requests with more than BLKIF_MAX_SEGMENTS_PER_REQUEST (11). The - * maximum number of indirect segments is fixed by the backend, but the - * frontend can issue requests with any number of indirect segments as long as - * it's less than the number provided by the backend. The indirect_grefs field - * in blkif_request_indirect should be filled by the frontend with the - * grant references of the pages that are holding the indirect segments. - * These pages are filled with an array of blkif_request_segment that hold the - * information about the segments. The number of indirect pages to use is - * determined by the number of segments an indirect request contains. Every - * indirect page can contain a maximum of - * (PAGE_SIZE / sizeof(struct blkif_request_segment)) segments, so to - * calculate the number of indirect pages to use we have to do - * ceil(indirect_segments / (PAGE_SIZE / sizeof(struct blkif_request_segment))). - * - * If a backend does not recognize BLKIF_OP_INDIRECT, it should *not* - * create the "feature-max-indirect-segments" node! - */ -#define BLKIF_OP_INDIRECT 6 - -/* - * Maximum scatter/gather segments per request. - * This is carefully chosen so that sizeof(blkif_ring_t) <= PAGE_SIZE. - * NB. This could be 12 if the ring indexes weren't stored in the same page. - */ -#define BLKIF_MAX_SEGMENTS_PER_REQUEST 11 - -/* - * Maximum number of indirect pages to use per request. - */ -#define BLKIF_MAX_INDIRECT_PAGES_PER_REQUEST 8 - -/* - * NB. first_sect and last_sect in blkif_request_segment, as well as - * sector_number in blkif_request, are always expressed in 512-byte units. - * However they must be properly aligned to the real sector size of the - * physical disk, which is reported in the "physical-sector-size" node in - * the backend xenbus info. Also the xenbus "sectors" node is expressed in - * 512-byte units. - */ -struct blkif_request_segment { - grant_ref_t gref; /* reference to I/O buffer frame */ - /* @first_sect: first sector in frame to transfer (inclusive). */ - /* @last_sect: last sector in frame to transfer (inclusive). */ - UINT8 first_sect, last_sect; -}; - -/* - * Starting ring element for any I/O request. - */ -#if defined(MDE_CPU_IA32) -// -// pack(4) is necessary when these structs are compiled for Ia32. -// Without it, the struct will have a different alignment than the one -// a backend expect for a 32bit guest. -// -#pragma pack(4) -#endif -struct blkif_request { - UINT8 operation; /* BLKIF_OP_??? */ - UINT8 nr_segments; /* number of segments */ - blkif_vdev_t handle; /* only for read/write requests */ - UINT64 id; /* private guest value, echoed in resp */ - blkif_sector_t sector_number;/* start sector idx on disk (r/w only) */ - struct blkif_request_segment seg[BLKIF_MAX_SEGMENTS_PER_REQUEST]; -}; -typedef struct blkif_request blkif_request_t; - -/* - * Cast to this structure when blkif_request.operation == BLKIF_OP_DISCARD - * sizeof(struct blkif_request_discard) <= sizeof(struct blkif_request) - */ -struct blkif_request_discard { - UINT8 operation; /* BLKIF_OP_DISCARD */ - UINT8 flag; /* BLKIF_DISCARD_SECURE or zero */ -#define BLKIF_DISCARD_SECURE (1<<0) /* ignored if discard-secure=0 */ - blkif_vdev_t handle; /* same as for read/write requests */ - UINT64 id; /* private guest value, echoed in resp */ - blkif_sector_t sector_number;/* start sector idx on disk */ - UINT64 nr_sectors; /* number of contiguous sectors to discard*/ -}; -typedef struct blkif_request_discard blkif_request_discard_t; - -struct blkif_request_indirect { - UINT8 operation; /* BLKIF_OP_INDIRECT */ - UINT8 indirect_op; /* BLKIF_OP_{READ/WRITE} */ - UINT16 nr_segments; /* number of segments */ - UINT64 id; /* private guest value, echoed in resp */ - blkif_sector_t sector_number;/* start sector idx on disk (r/w only) */ - blkif_vdev_t handle; /* same as for read/write requests */ - grant_ref_t indirect_grefs[BLKIF_MAX_INDIRECT_PAGES_PER_REQUEST]; -#ifdef MDE_CPU_IA32 - UINT64 pad; /* Make it 64 byte aligned on i386 */ -#endif -}; -typedef struct blkif_request_indirect blkif_request_indirect_t; - -struct blkif_response { - UINT64 id; /* copied from request */ - UINT8 operation; /* copied from request */ - INT16 status; /* BLKIF_RSP_??? */ -}; -typedef struct blkif_response blkif_response_t; -#if defined(MDE_CPU_IA32) -#pragma pack() -#endif - -/* - * STATUS RETURN CODES. - */ - /* Operation not supported (only happens on barrier writes). */ -#define BLKIF_RSP_EOPNOTSUPP -2 - /* Operation failed for some unspecified reason (-EIO). */ -#define BLKIF_RSP_ERROR -1 - /* Operation completed successfully. */ -#define BLKIF_RSP_OKAY 0 - -/* - * Generate blkif ring structures and types. - */ -DEFINE_RING_TYPES(blkif, struct blkif_request, struct blkif_response); - -#define VDISK_CDROM 0x1 -#define VDISK_REMOVABLE 0x2 -#define VDISK_READONLY 0x4 - -#endif /* __XEN_PUBLIC_IO_BLKIF_H__ */ - -/* - * Local variables: - * mode: C - * c-file-style: "BSD" - * c-basic-offset: 4 - * tab-width: 4 - * indent-tabs-mode: nil - * End: - */ diff --git a/OvmfPkg/Include/IndustryStandard/Xen/io/console.h b/OvmfPkg/Include/IndustryStandard/Xen/io/console.h deleted file mode 100644 index f1caa9765b..0000000000 --- a/OvmfPkg/Include/IndustryStandard/Xen/io/console.h +++ /dev/null @@ -1,51 +0,0 @@ -/****************************************************************************** - * console.h - * - * Console I/O interface for Xen guest OSes. - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to - * deal in the Software without restriction, including without limitation the - * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or - * sell copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING - * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER - * DEALINGS IN THE SOFTWARE. - * - * Copyright (c) 2005, Keir Fraser - */ - -#ifndef __XEN_PUBLIC_IO_CONSOLE_H__ -#define __XEN_PUBLIC_IO_CONSOLE_H__ - -typedef UINT32 XENCONS_RING_IDX; - -#define MASK_XENCONS_IDX(idx, ring) ((idx) & (sizeof(ring)-1)) - -struct xencons_interface { - char in[1024]; - char out[2048]; - XENCONS_RING_IDX in_cons, in_prod; - XENCONS_RING_IDX out_cons, out_prod; -}; - -#endif /* __XEN_PUBLIC_IO_CONSOLE_H__ */ - -/* - * Local variables: - * mode: C - * c-file-style: "BSD" - * c-basic-offset: 4 - * tab-width: 4 - * indent-tabs-mode: nil - * End: - */ diff --git a/OvmfPkg/Include/IndustryStandard/Xen/io/protocols.h b/OvmfPkg/Include/IndustryStandard/Xen/io/protocols.h deleted file mode 100644 index e2cbd871aa..0000000000 --- a/OvmfPkg/Include/IndustryStandard/Xen/io/protocols.h +++ /dev/null @@ -1,40 +0,0 @@ -/****************************************************************************** - * protocols.h - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to - * deal in the Software without restriction, including without limitation the - * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or - * sell copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING - * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER - * DEALINGS IN THE SOFTWARE. - */ - -#ifndef __XEN_PROTOCOLS_H__ -#define __XEN_PROTOCOLS_H__ - -#define XEN_IO_PROTO_ABI_X86_32 "x86_32-abi" -#define XEN_IO_PROTO_ABI_X86_64 "x86_64-abi" -#define XEN_IO_PROTO_ABI_ARM "arm-abi" - -#if defined(MDE_CPU_IA32) -# define XEN_IO_PROTO_ABI_NATIVE XEN_IO_PROTO_ABI_X86_32 -#elif defined(MDE_CPU_X64) -# define XEN_IO_PROTO_ABI_NATIVE XEN_IO_PROTO_ABI_X86_64 -#elif defined(__arm__) || defined(__aarch64__) -# define XEN_IO_PROTO_ABI_NATIVE XEN_IO_PROTO_ABI_ARM -#else -# error arch fixup needed here -#endif - -#endif diff --git a/OvmfPkg/Include/IndustryStandard/Xen/io/ring.h b/OvmfPkg/Include/IndustryStandard/Xen/io/ring.h deleted file mode 100644 index 16313773cb..0000000000 --- a/OvmfPkg/Include/IndustryStandard/Xen/io/ring.h +++ /dev/null @@ -1,312 +0,0 @@ -/****************************************************************************** - * ring.h - * - * Shared producer-consumer ring macros. - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to - * deal in the Software without restriction, including without limitation the - * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or - * sell copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING - * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER - * DEALINGS IN THE SOFTWARE. - * - * Tim Deegan and Andrew Warfield November 2004. - */ - -#ifndef __XEN_PUBLIC_IO_RING_H__ -#define __XEN_PUBLIC_IO_RING_H__ - -#include "../xen-compat.h" - -#if __XEN_INTERFACE_VERSION__ < 0x00030208 -#define xen_mb() mb() -#define xen_rmb() rmb() -#define xen_wmb() wmb() -#endif - -typedef UINT32 RING_IDX; - -/* Round a 32-bit unsigned constant down to the nearest power of two. */ -#define __RD2(_x) (((_x) & 0x00000002) ? 0x2 : ((_x) & 0x1)) -#define __RD4(_x) (((_x) & 0x0000000c) ? __RD2((_x)>>2)<<2 : __RD2(_x)) -#define __RD8(_x) (((_x) & 0x000000f0) ? __RD4((_x)>>4)<<4 : __RD4(_x)) -#define __RD16(_x) (((_x) & 0x0000ff00) ? __RD8((_x)>>8)<<8 : __RD8(_x)) -#define __RD32(_x) (((_x) & 0xffff0000) ? __RD16((_x)>>16)<<16 : __RD16(_x)) - -/* - * Calculate size of a shared ring, given the total available space for the - * ring and indexes (_sz), and the name tag of the request/response structure. - * A ring contains as many entries as will fit, rounded down to the nearest - * power of two (so we can mask with (size-1) to loop around). - */ -#define __CONST_RING_SIZE(_s, _sz) \ - (__RD32(((_sz) - offsetof(struct _s##_sring, ring)) / \ - sizeof(((struct _s##_sring *)0)->ring[0]))) -/* - * The same for passing in an actual pointer instead of a name tag. - */ -#define __RING_SIZE(_s, _sz) \ - (__RD32(((_sz) - (INTN)(_s)->ring + (INTN)(_s)) / sizeof((_s)->ring[0]))) - -/* - * Macros to make the correct C datatypes for a new kind of ring. - * - * To make a new ring datatype, you need to have two message structures, - * let's say request_t, and response_t already defined. - * - * In a header where you want the ring datatype declared, you then do: - * - * DEFINE_RING_TYPES(mytag, request_t, response_t); - * - * These expand out to give you a set of types, as you can see below. - * The most important of these are: - * - * mytag_sring_t - The shared ring. - * mytag_front_ring_t - The 'front' half of the ring. - * mytag_back_ring_t - The 'back' half of the ring. - * - * To initialize a ring in your code you need to know the location and size - * of the shared memory area (PAGE_SIZE, for instance). To initialise - * the front half: - * - * mytag_front_ring_t front_ring; - * SHARED_RING_INIT((mytag_sring_t *)shared_page); - * FRONT_RING_INIT(&front_ring, (mytag_sring_t *)shared_page, PAGE_SIZE); - * - * Initializing the back follows similarly (note that only the front - * initializes the shared ring): - * - * mytag_back_ring_t back_ring; - * BACK_RING_INIT(&back_ring, (mytag_sring_t *)shared_page, PAGE_SIZE); - */ - -#define DEFINE_RING_TYPES(__name, __req_t, __rsp_t) \ - \ -/* Shared ring entry */ \ -union __name##_sring_entry { \ - __req_t req; \ - __rsp_t rsp; \ -}; \ - \ -/* Shared ring page */ \ -struct __name##_sring { \ - RING_IDX req_prod, req_event; \ - RING_IDX rsp_prod, rsp_event; \ - union { \ - struct { \ - UINT8 smartpoll_active; \ - } netif; \ - struct { \ - UINT8 msg; \ - } tapif_user; \ - UINT8 pvt_pad[4]; \ - } private; \ - UINT8 __pad[44]; \ - union __name##_sring_entry ring[1]; /* variable-length */ \ -}; \ - \ -/* "Front" end's private variables */ \ -struct __name##_front_ring { \ - RING_IDX req_prod_pvt; \ - RING_IDX rsp_cons; \ - UINT32 nr_ents; \ - struct __name##_sring *sring; \ -}; \ - \ -/* "Back" end's private variables */ \ -struct __name##_back_ring { \ - RING_IDX rsp_prod_pvt; \ - RING_IDX req_cons; \ - UINT32 nr_ents; \ - struct __name##_sring *sring; \ -}; \ - \ -/* Syntactic sugar */ \ -typedef struct __name##_sring __name##_sring_t; \ -typedef struct __name##_front_ring __name##_front_ring_t; \ -typedef struct __name##_back_ring __name##_back_ring_t - -/* - * Macros for manipulating rings. - * - * FRONT_RING_whatever works on the "front end" of a ring: here - * requests are pushed on to the ring and responses taken off it. - * - * BACK_RING_whatever works on the "back end" of a ring: here - * requests are taken off the ring and responses put on. - * - * N.B. these macros do NO INTERLOCKS OR FLOW CONTROL. - * This is OK in 1-for-1 request-response situations where the - * requestor (front end) never has more than RING_SIZE()-1 - * outstanding requests. - */ - -/* Initialising empty rings */ -#define SHARED_RING_INIT(_s) do { \ - (_s)->req_prod = (_s)->rsp_prod = 0; \ - (_s)->req_event = (_s)->rsp_event = 1; \ - (VOID)ZeroMem((_s)->private.pvt_pad, sizeof((_s)->private.pvt_pad)); \ - (VOID)ZeroMem((_s)->__pad, sizeof((_s)->__pad)); \ -} while(0) - -#define FRONT_RING_INIT(_r, _s, __size) do { \ - (_r)->req_prod_pvt = 0; \ - (_r)->rsp_cons = 0; \ - (_r)->nr_ents = __RING_SIZE(_s, __size); \ - (_r)->sring = (_s); \ -} while (0) - -#define BACK_RING_INIT(_r, _s, __size) do { \ - (_r)->rsp_prod_pvt = 0; \ - (_r)->req_cons = 0; \ - (_r)->nr_ents = __RING_SIZE(_s, __size); \ - (_r)->sring = (_s); \ -} while (0) - -/* How big is this ring? */ -#define RING_SIZE(_r) \ - ((_r)->nr_ents) - -/* Number of free requests (for use on front side only). */ -#define RING_FREE_REQUESTS(_r) \ - (RING_SIZE(_r) - ((_r)->req_prod_pvt - (_r)->rsp_cons)) - -/* Test if there is an empty slot available on the front ring. - * (This is only meaningful from the front. ) - */ -#define RING_FULL(_r) \ - (RING_FREE_REQUESTS(_r) == 0) - -/* Test if there are outstanding messages to be processed on a ring. */ -#define RING_HAS_UNCONSUMED_RESPONSES(_r) \ - ((_r)->sring->rsp_prod - (_r)->rsp_cons) - -#ifdef __GNUC__ -#define RING_HAS_UNCONSUMED_REQUESTS(_r) ({ \ - UINT32 req = (_r)->sring->req_prod - (_r)->req_cons; \ - UINT32 rsp = RING_SIZE(_r) - \ - ((_r)->req_cons - (_r)->rsp_prod_pvt); \ - req < rsp ? req : rsp; \ -}) -#else -/* Same as above, but without the nice GCC ({ ... }) syntax. */ -#define RING_HAS_UNCONSUMED_REQUESTS(_r) \ - ((((_r)->sring->req_prod - (_r)->req_cons) < \ - (RING_SIZE(_r) - ((_r)->req_cons - (_r)->rsp_prod_pvt))) ? \ - ((_r)->sring->req_prod - (_r)->req_cons) : \ - (RING_SIZE(_r) - ((_r)->req_cons - (_r)->rsp_prod_pvt))) -#endif - -/* Direct access to individual ring elements, by index. */ -#define RING_GET_REQUEST(_r, _idx) \ - (&((_r)->sring->ring[((_idx) & (RING_SIZE(_r) - 1))].req)) - -#define RING_GET_RESPONSE(_r, _idx) \ - (&((_r)->sring->ring[((_idx) & (RING_SIZE(_r) - 1))].rsp)) - -/* Loop termination condition: Would the specified index overflow the ring? */ -#define RING_REQUEST_CONS_OVERFLOW(_r, _cons) \ - (((_cons) - (_r)->rsp_prod_pvt) >= RING_SIZE(_r)) - -/* Ill-behaved frontend determination: Can there be this many requests? */ -#define RING_REQUEST_PROD_OVERFLOW(_r, _prod) \ - (((_prod) - (_r)->rsp_prod_pvt) > RING_SIZE(_r)) - -#define RING_PUSH_REQUESTS(_r) do { \ - xen_wmb(); /* back sees requests /before/ updated producer index */ \ - (_r)->sring->req_prod = (_r)->req_prod_pvt; \ -} while (0) - -#define RING_PUSH_RESPONSES(_r) do { \ - xen_wmb(); /* front sees resps /before/ updated producer index */ \ - (_r)->sring->rsp_prod = (_r)->rsp_prod_pvt; \ -} while (0) - -/* - * Notification hold-off (req_event and rsp_event): - * - * When queueing requests or responses on a shared ring, it may not always be - * necessary to notify the remote end. For example, if requests are in flight - * in a backend, the front may be able to queue further requests without - * notifying the back (if the back checks for new requests when it queues - * responses). - * - * When enqueuing requests or responses: - * - * Use RING_PUSH_{REQUESTS,RESPONSES}_AND_CHECK_NOTIFY(). The second argument - * is a boolean return value. True indicates that the receiver requires an - * asynchronous notification. - * - * After dequeuing requests or responses (before sleeping the connection): - * - * Use RING_FINAL_CHECK_FOR_REQUESTS() or RING_FINAL_CHECK_FOR_RESPONSES(). - * The second argument is a boolean return value. True indicates that there - * are pending messages on the ring (i.e., the connection should not be put - * to sleep). - * - * These macros will set the req_event/rsp_event field to trigger a - * notification on the very next message that is enqueued. If you want to - * create batches of work (i.e., only receive a notification after several - * messages have been enqueued) then you will need to create a customised - * version of the FINAL_CHECK macro in your own code, which sets the event - * field appropriately. - */ - -#define RING_PUSH_REQUESTS_AND_CHECK_NOTIFY(_r, _notify) do { \ - RING_IDX __old = (_r)->sring->req_prod; \ - RING_IDX __new = (_r)->req_prod_pvt; \ - xen_wmb(); /* back sees requests /before/ updated producer index */ \ - (_r)->sring->req_prod = __new; \ - xen_mb(); /* back sees new requests /before/ we check req_event */ \ - (_notify) = ((RING_IDX)(__new - (_r)->sring->req_event) < \ - (RING_IDX)(__new - __old)); \ -} while (0) - -#define RING_PUSH_RESPONSES_AND_CHECK_NOTIFY(_r, _notify) do { \ - RING_IDX __old = (_r)->sring->rsp_prod; \ - RING_IDX __new = (_r)->rsp_prod_pvt; \ - xen_wmb(); /* front sees resps /before/ updated producer index */ \ - (_r)->sring->rsp_prod = __new; \ - xen_mb(); /* front sees new resps /before/ we check rsp_event */ \ - (_notify) = ((RING_IDX)(__new - (_r)->sring->rsp_event) < \ - (RING_IDX)(__new - __old)); \ -} while (0) - -#define RING_FINAL_CHECK_FOR_REQUESTS(_r, _work_to_do) do { \ - (_work_to_do) = RING_HAS_UNCONSUMED_REQUESTS(_r); \ - if (_work_to_do) break; \ - (_r)->sring->req_event = (_r)->req_cons + 1; \ - xen_mb(); \ - (_work_to_do) = RING_HAS_UNCONSUMED_REQUESTS(_r); \ -} while (0) - -#define RING_FINAL_CHECK_FOR_RESPONSES(_r, _work_to_do) do { \ - (_work_to_do) = RING_HAS_UNCONSUMED_RESPONSES(_r); \ - if (_work_to_do) break; \ - (_r)->sring->rsp_event = (_r)->rsp_cons + 1; \ - xen_mb(); \ - (_work_to_do) = RING_HAS_UNCONSUMED_RESPONSES(_r); \ -} while (0) - -#endif /* __XEN_PUBLIC_IO_RING_H__ */ - -/* - * Local variables: - * mode: C - * c-file-style: "BSD" - * c-basic-offset: 4 - * tab-width: 4 - * indent-tabs-mode: nil - * End: - */ diff --git a/OvmfPkg/Include/IndustryStandard/Xen/io/xenbus.h b/OvmfPkg/Include/IndustryStandard/Xen/io/xenbus.h deleted file mode 100644 index 4c76b5ba0f..0000000000 --- a/OvmfPkg/Include/IndustryStandard/Xen/io/xenbus.h +++ /dev/null @@ -1,80 +0,0 @@ -/***************************************************************************** - * xenbus.h - * - * Xenbus protocol details. - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to - * deal in the Software without restriction, including without limitation the - * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or - * sell copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING - * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER - * DEALINGS IN THE SOFTWARE. - * - * Copyright (C) 2005 XenSource Ltd. - */ - -#ifndef _XEN_PUBLIC_IO_XENBUS_H -#define _XEN_PUBLIC_IO_XENBUS_H - -/* - * The state of either end of the Xenbus, i.e. the current communication - * status of initialisation across the bus. States here imply nothing about - * the state of the connection between the driver and the kernel's device - * layers. - */ -enum xenbus_state { - XenbusStateUnknown = 0, - - XenbusStateInitialising = 1, - - /* - * InitWait: Finished early initialisation but waiting for information - * from the peer or hotplug scripts. - */ - XenbusStateInitWait = 2, - - /* - * Initialised: Waiting for a connection from the peer. - */ - XenbusStateInitialised = 3, - - XenbusStateConnected = 4, - - /* - * Closing: The device is being closed due to an error or an unplug event. - */ - XenbusStateClosing = 5, - - XenbusStateClosed = 6, - - /* - * Reconfiguring: The device is being reconfigured. - */ - XenbusStateReconfiguring = 7, - - XenbusStateReconfigured = 8 -}; -typedef enum xenbus_state XenbusState; - -#endif /* _XEN_PUBLIC_IO_XENBUS_H */ - -/* - * Local variables: - * mode: C - * c-file-style: "BSD" - * c-basic-offset: 4 - * tab-width: 4 - * indent-tabs-mode: nil - * End: - */ diff --git a/OvmfPkg/Include/IndustryStandard/Xen/io/xs_wire.h b/OvmfPkg/Include/IndustryStandard/Xen/io/xs_wire.h deleted file mode 100644 index 6f302d1447..0000000000 --- a/OvmfPkg/Include/IndustryStandard/Xen/io/xs_wire.h +++ /dev/null @@ -1,149 +0,0 @@ -/* - * Details of the "wire" protocol between Xen Store Daemon and client - * library or guest kernel. - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to - * deal in the Software without restriction, including without limitation the - * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or - * sell copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING - * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER - * DEALINGS IN THE SOFTWARE. - * - * Copyright (C) 2005 Rusty Russell IBM Corporation - */ - -#ifndef _XS_WIRE_H -#define _XS_WIRE_H - -enum xsd_sockmsg_type -{ - XS_DEBUG, - XS_DIRECTORY, - XS_READ, - XS_GET_PERMS, - XS_WATCH, - XS_UNWATCH, - XS_TRANSACTION_START, - XS_TRANSACTION_END, - XS_INTRODUCE, - XS_RELEASE, - XS_GET_DOMAIN_PATH, - XS_WRITE, - XS_MKDIR, - XS_RM, - XS_SET_PERMS, - XS_WATCH_EVENT, - XS_ERROR, - XS_IS_DOMAIN_INTRODUCED, - XS_RESUME, - XS_SET_TARGET, - XS_RESTRICT, - XS_RESET_WATCHES, - - XS_INVALID = 0xffff /* Guaranteed to remain an invalid type */ -}; - -#define XS_WRITE_NONE "NONE" -#define XS_WRITE_CREATE "CREATE" -#define XS_WRITE_CREATE_EXCL "CREATE|EXCL" - -/* We hand errors as strings, for portability. */ -struct xsd_errors -{ - INT32 errnum; - const CHAR8 *errstring; -}; -#ifdef EINVAL -#define XSD_ERROR(x) { x, #x } -/* LINTED: static unused */ -static struct xsd_errors xsd_errors[] -#if defined(__GNUC__) -__attribute__((unused)) -#endif - = { - XSD_ERROR(EINVAL), - XSD_ERROR(EACCES), - XSD_ERROR(EEXIST), - XSD_ERROR(EISDIR), - XSD_ERROR(ENOENT), - XSD_ERROR(ENOMEM), - XSD_ERROR(ENOSPC), - XSD_ERROR(EIO), - XSD_ERROR(ENOTEMPTY), - XSD_ERROR(ENOSYS), - XSD_ERROR(EROFS), - XSD_ERROR(EBUSY), - XSD_ERROR(EAGAIN), - XSD_ERROR(EISCONN), - XSD_ERROR(E2BIG) -}; -#endif - -struct xsd_sockmsg -{ - UINT32 type; /* XS_??? */ - UINT32 req_id;/* Request identifier, echoed in daemon's response. */ - UINT32 tx_id; /* Transaction id (0 if not related to a transaction). */ - UINT32 len; /* Length of data following this. */ - - /* Generally followed by nul-terminated string(s). */ -}; - -enum xs_watch_type -{ - XS_WATCH_PATH = 0, - XS_WATCH_TOKEN -}; - -/* - * `incontents 150 xenstore_struct XenStore wire protocol. - * - * Inter-domain shared memory communications. */ -#define XENSTORE_RING_SIZE 1024 -typedef UINT32 XENSTORE_RING_IDX; -#define MASK_XENSTORE_IDX(idx) ((idx) & (XENSTORE_RING_SIZE-1)) -struct xenstore_domain_interface { - CHAR8 req[XENSTORE_RING_SIZE]; /* Requests to xenstore daemon. */ - CHAR8 rsp[XENSTORE_RING_SIZE]; /* Replies and async watch events. */ - XENSTORE_RING_IDX req_cons, req_prod; - XENSTORE_RING_IDX rsp_cons, rsp_prod; - UINT32 server_features; /* Bitmap of features supported by the server */ - UINT32 connection; -}; - -/* Violating this is very bad. See docs/misc/xenstore.txt. */ -#define XENSTORE_PAYLOAD_MAX 4096 - -/* Violating these just gets you an error back */ -#define XENSTORE_ABS_PATH_MAX 3072 -#define XENSTORE_REL_PATH_MAX 2048 - -/* The ability to reconnect a ring */ -#define XENSTORE_SERVER_FEATURE_RECONNECTION 1 - -/* Valid values for the connection field */ -#define XENSTORE_CONNECTED 0 /* the steady-state */ -#define XENSTORE_RECONNECT 1 /* guest has initiated a reconnect */ - -#endif /* _XS_WIRE_H */ - -/* - * Local variables: - * mode: C - * c-file-style: "BSD" - * c-basic-offset: 4 - * tab-width: 4 - * indent-tabs-mode: nil - * End: - */ diff --git a/OvmfPkg/Include/IndustryStandard/Xen/memory.h b/OvmfPkg/Include/IndustryStandard/Xen/memory.h deleted file mode 100644 index 020155962c..0000000000 --- a/OvmfPkg/Include/IndustryStandard/Xen/memory.h +++ /dev/null @@ -1,94 +0,0 @@ -/****************************************************************************** - * memory.h - * - * Memory reservation and information. - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to - * deal in the Software without restriction, including without limitation the - * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or - * sell copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING - * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER - * DEALINGS IN THE SOFTWARE. - * - * Copyright (c) 2005, Keir Fraser - */ - -#ifndef __XEN_PUBLIC_MEMORY_H__ -#define __XEN_PUBLIC_MEMORY_H__ - -#include "xen.h" - -/* Source mapping space. */ -/* ` enum phys_map_space { */ -#define XENMAPSPACE_shared_info 0 /* shared info page */ -#define XENMAPSPACE_grant_table 1 /* grant table page */ -#define XENMAPSPACE_gmfn 2 /* GMFN */ -#define XENMAPSPACE_gmfn_range 3 /* GMFN range, XENMEM_add_to_physmap only. */ -#define XENMAPSPACE_gmfn_foreign 4 /* GMFN from another dom, - * XENMEM_add_to_physmap_batch only. */ -/* ` } */ - -/* - * Sets the GPFN at which a particular page appears in the specified guest's - * pseudophysical address space. - * arg == addr of xen_add_to_physmap_t. - */ -#define XENMEM_add_to_physmap 7 -struct xen_add_to_physmap { - /* Which domain to change the mapping for. */ - domid_t domid; - - /* Number of pages to go through for gmfn_range */ - UINT16 size; - - UINT32 space; /* => enum phys_map_space */ - -#define XENMAPIDX_grant_table_status 0x80000000 - - /* Index into space being mapped. */ - xen_ulong_t idx; - - /* GPFN in domid where the source mapping page should appear. */ - xen_pfn_t gpfn; -}; -typedef struct xen_add_to_physmap xen_add_to_physmap_t; -DEFINE_XEN_GUEST_HANDLE(xen_add_to_physmap_t); - -/* - * Unmaps the page appearing at a particular GPFN from the specified guest's - * pseudophysical address space. - * arg == addr of xen_remove_from_physmap_t. - */ -#define XENMEM_remove_from_physmap 15 -struct xen_remove_from_physmap { - /* Which domain to change the mapping for. */ - domid_t domid; - - /* GPFN of the current mapping of the page. */ - xen_pfn_t gpfn; -}; -typedef struct xen_remove_from_physmap xen_remove_from_physmap_t; -DEFINE_XEN_GUEST_HANDLE(xen_remove_from_physmap_t); - -#endif /* __XEN_PUBLIC_MEMORY_H__ */ - -/* - * Local variables: - * mode: C - * c-file-style: "BSD" - * c-basic-offset: 4 - * tab-width: 4 - * indent-tabs-mode: nil - * End: - */ diff --git a/OvmfPkg/Include/IndustryStandard/Xen/xen-compat.h b/OvmfPkg/Include/IndustryStandard/Xen/xen-compat.h deleted file mode 100644 index 53b7a3c7f6..0000000000 --- a/OvmfPkg/Include/IndustryStandard/Xen/xen-compat.h +++ /dev/null @@ -1,44 +0,0 @@ -/****************************************************************************** - * xen-compat.h - * - * Guest OS interface to Xen. Compatibility layer. - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to - * deal in the Software without restriction, including without limitation the - * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or - * sell copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING - * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER - * DEALINGS IN THE SOFTWARE. - * - * Copyright (c) 2006, Christian Limpach - */ - -#ifndef __XEN_PUBLIC_XEN_COMPAT_H__ -#define __XEN_PUBLIC_XEN_COMPAT_H__ - -#define __XEN_LATEST_INTERFACE_VERSION__ 0x00040400 - -#if defined(__XEN__) || defined(__XEN_TOOLS__) -/* Xen is built with matching headers and implements the latest interface. */ -#define __XEN_INTERFACE_VERSION__ __XEN_LATEST_INTERFACE_VERSION__ -#elif !defined(__XEN_INTERFACE_VERSION__) -/* Guests which do not specify a version get the legacy interface. */ -#define __XEN_INTERFACE_VERSION__ 0x00000000 -#endif - -#if __XEN_INTERFACE_VERSION__ > __XEN_LATEST_INTERFACE_VERSION__ -#error "These header files do not support the requested interface version." -#endif - -#endif /* __XEN_PUBLIC_XEN_COMPAT_H__ */ diff --git a/OvmfPkg/Include/IndustryStandard/Xen/xen.h b/OvmfPkg/Include/IndustryStandard/Xen/xen.h deleted file mode 100644 index 8596ca1bd2..0000000000 --- a/OvmfPkg/Include/IndustryStandard/Xen/xen.h +++ /dev/null @@ -1,346 +0,0 @@ -/****************************************************************************** - * xen.h - * - * Guest OS interface to Xen. - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to - * deal in the Software without restriction, including without limitation the - * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or - * sell copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING - * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER - * DEALINGS IN THE SOFTWARE. - * - * Copyright (c) 2004, K A Fraser - */ - -#ifndef __XEN_PUBLIC_XEN_H__ -#define __XEN_PUBLIC_XEN_H__ - -// -// Xen interface version used by Tianocore -// -#define __XEN_INTERFACE_VERSION__ 0x00040400 - -#include "xen-compat.h" - -#if defined(MDE_CPU_IA32) || defined(MDE_CPU_X64) -#include "arch-x86/xen.h" -#elif defined(__arm__) || defined (__aarch64__) -#include "arch-arm/xen.h" -#else -#error "Unsupported architecture" -#endif - -#ifndef __ASSEMBLY__ -/* Guest handles for primitive C types. */ -DEFINE_XEN_GUEST_HANDLE(CHAR8); -__DEFINE_XEN_GUEST_HANDLE(uchar, UINT8); -DEFINE_XEN_GUEST_HANDLE(INT32); -__DEFINE_XEN_GUEST_HANDLE(uint, UINT32); -#if __XEN_INTERFACE_VERSION__ < 0x00040300 -DEFINE_XEN_GUEST_HANDLE(INTN); -__DEFINE_XEN_GUEST_HANDLE(ulong, UINTN); -#endif -DEFINE_XEN_GUEST_HANDLE(VOID); - -DEFINE_XEN_GUEST_HANDLE(UINT64); -DEFINE_XEN_GUEST_HANDLE(xen_pfn_t); -DEFINE_XEN_GUEST_HANDLE(xen_ulong_t); -#endif - -/* - * HYPERCALLS - */ - -/* `incontents 100 hcalls List of hypercalls - * ` enum hypercall_num { // __HYPERVISOR_* => HYPERVISOR_*() - */ - -#define __HYPERVISOR_set_trap_table 0 -#define __HYPERVISOR_mmu_update 1 -#define __HYPERVISOR_set_gdt 2 -#define __HYPERVISOR_stack_switch 3 -#define __HYPERVISOR_set_callbacks 4 -#define __HYPERVISOR_fpu_taskswitch 5 -#define __HYPERVISOR_sched_op_compat 6 /* compat since 0x00030101 */ -#define __HYPERVISOR_platform_op 7 -#define __HYPERVISOR_set_debugreg 8 -#define __HYPERVISOR_get_debugreg 9 -#define __HYPERVISOR_update_descriptor 10 -#define __HYPERVISOR_memory_op 12 -#define __HYPERVISOR_multicall 13 -#define __HYPERVISOR_update_va_mapping 14 -#define __HYPERVISOR_set_timer_op 15 -#define __HYPERVISOR_event_channel_op_compat 16 /* compat since 0x00030202 */ -#define __HYPERVISOR_xen_version 17 -#define __HYPERVISOR_console_io 18 -#define __HYPERVISOR_physdev_op_compat 19 /* compat since 0x00030202 */ -#define __HYPERVISOR_grant_table_op 20 -#define __HYPERVISOR_vm_assist 21 -#define __HYPERVISOR_update_va_mapping_otherdomain 22 -#define __HYPERVISOR_iret 23 /* x86 only */ -#define __HYPERVISOR_vcpu_op 24 -#define __HYPERVISOR_set_segment_base 25 /* x86/64 only */ -#define __HYPERVISOR_mmuext_op 26 -#define __HYPERVISOR_xsm_op 27 -#define __HYPERVISOR_nmi_op 28 -#define __HYPERVISOR_sched_op 29 -#define __HYPERVISOR_callback_op 30 -#define __HYPERVISOR_xenoprof_op 31 -#define __HYPERVISOR_event_channel_op 32 -#define __HYPERVISOR_physdev_op 33 -#define __HYPERVISOR_hvm_op 34 -#define __HYPERVISOR_sysctl 35 -#define __HYPERVISOR_domctl 36 -#define __HYPERVISOR_kexec_op 37 -#define __HYPERVISOR_tmem_op 38 -#define __HYPERVISOR_xc_reserved_op 39 /* reserved for XenClient */ - -/* Architecture-specific hypercall definitions. */ -#define __HYPERVISOR_arch_0 48 -#define __HYPERVISOR_arch_1 49 -#define __HYPERVISOR_arch_2 50 -#define __HYPERVISOR_arch_3 51 -#define __HYPERVISOR_arch_4 52 -#define __HYPERVISOR_arch_5 53 -#define __HYPERVISOR_arch_6 54 -#define __HYPERVISOR_arch_7 55 - -/* ` } */ - -/* - * HYPERCALL COMPATIBILITY. - */ - -/* New sched_op hypercall introduced in 0x00030101. */ -#if __XEN_INTERFACE_VERSION__ < 0x00030101 -#undef __HYPERVISOR_sched_op -#define __HYPERVISOR_sched_op __HYPERVISOR_sched_op_compat -#endif - -/* New event-channel and physdev hypercalls introduced in 0x00030202. */ -#if __XEN_INTERFACE_VERSION__ < 0x00030202 -#undef __HYPERVISOR_event_channel_op -#define __HYPERVISOR_event_channel_op __HYPERVISOR_event_channel_op_compat -#undef __HYPERVISOR_physdev_op -#define __HYPERVISOR_physdev_op __HYPERVISOR_physdev_op_compat -#endif - -/* New platform_op hypercall introduced in 0x00030204. */ -#if __XEN_INTERFACE_VERSION__ < 0x00030204 -#define __HYPERVISOR_dom0_op __HYPERVISOR_platform_op -#endif - -#ifndef __ASSEMBLY__ - -typedef UINT16 domid_t; - -/* Domain ids >= DOMID_FIRST_RESERVED cannot be used for ordinary domains. */ -#define DOMID_FIRST_RESERVED (0x7FF0U) - -/* DOMID_SELF is used in certain contexts to refer to oneself. */ -#define DOMID_SELF (0x7FF0U) - -/* - * DOMID_IO is used to restrict page-table updates to mapping I/O memory. - * Although no Foreign Domain need be specified to map I/O pages, DOMID_IO - * is useful to ensure that no mappings to the OS's own heap are accidentally - * installed. (e.g., in Linux this could cause havoc as reference counts - * aren't adjusted on the I/O-mapping code path). - * This only makes sense in MMUEXT_SET_FOREIGNDOM, but in that context can - * be specified by any calling domain. - */ -#define DOMID_IO (0x7FF1U) - -/* - * DOMID_XEN is used to allow privileged domains to map restricted parts of - * Xen's heap space (e.g., the machine_to_phys table). - * This only makes sense in MMUEXT_SET_FOREIGNDOM, and is only permitted if - * the caller is privileged. - */ -#define DOMID_XEN (0x7FF2U) - -/* - * DOMID_COW is used as the owner of sharable pages */ -#define DOMID_COW (0x7FF3U) - -/* DOMID_INVALID is used to identify pages with unknown owner. */ -#define DOMID_INVALID (0x7FF4U) - -/* Idle domain. */ -#define DOMID_IDLE (0x7FFFU) - -#if __XEN_INTERFACE_VERSION__ < 0x00040400 -/* - * Event channel endpoints per domain (when using the 2-level ABI): - * 1024 if a INTN is 32 bits; 4096 if a INTN is 64 bits. - */ -#define NR_EVENT_CHANNELS EVTCHN_2L_NR_CHANNELS -#endif - -struct vcpu_time_info { - /* - * Updates to the following values are preceded and followed by an - * increment of 'version'. The guest can therefore detect updates by - * looking for changes to 'version'. If the least-significant bit of - * the version number is set then an update is in progress and the guest - * must wait to read a consistent set of values. - * The correct way to interact with the version number is similar to - * Linux's seqlock: see the implementations of read_seqbegin/read_seqretry. - */ - UINT32 version; - UINT32 pad0; - UINT64 tsc_timestamp; /* TSC at last update of time vals. */ - UINT64 system_time; /* Time, in nanosecs, since boot. */ - /* - * Current system time: - * system_time + - * ((((tsc - tsc_timestamp) << tsc_shift) * tsc_to_system_mul) >> 32) - * CPU frequency (Hz): - * ((10^9 << 32) / tsc_to_system_mul) >> tsc_shift - */ - UINT32 tsc_to_system_mul; - INT8 tsc_shift; - INT8 pad1[3]; -}; /* 32 bytes */ -typedef struct vcpu_time_info vcpu_time_info_t; - -struct vcpu_info { - /* - * 'evtchn_upcall_pending' is written non-zero by Xen to indicate - * a pending notification for a particular VCPU. It is then cleared - * by the guest OS /before/ checking for pending work, thus avoiding - * a set-and-check race. Note that the mask is only accessed by Xen - * on the CPU that is currently hosting the VCPU. This means that the - * pending and mask flags can be updated by the guest without special - * synchronisation (i.e., no need for the x86 LOCK prefix). - * This may seem suboptimal because if the pending flag is set by - * a different CPU then an IPI may be scheduled even when the mask - * is set. However, note: - * 1. The task of 'interrupt holdoff' is covered by the per-event- - * channel mask bits. A 'noisy' event that is continually being - * triggered can be masked at source at this very precise - * granularity. - * 2. The main purpose of the per-VCPU mask is therefore to restrict - * reentrant execution: whether for concurrency control, or to - * prevent unbounded stack usage. Whatever the purpose, we expect - * that the mask will be asserted only for short periods at a time, - * and so the likelihood of a 'spurious' IPI is suitably small. - * The mask is read before making an event upcall to the guest: a - * non-zero mask therefore guarantees that the VCPU will not receive - * an upcall activation. The mask is cleared when the VCPU requests - * to block: this avoids wakeup-waiting races. - */ - UINT8 evtchn_upcall_pending; -#ifdef XEN_HAVE_PV_UPCALL_MASK - UINT8 evtchn_upcall_mask; -#else /* XEN_HAVE_PV_UPCALL_MASK */ - UINT8 pad0; -#endif /* XEN_HAVE_PV_UPCALL_MASK */ - xen_ulong_t evtchn_pending_sel; - struct arch_vcpu_info arch; - struct vcpu_time_info time; -}; /* 64 bytes (x86) */ -#ifndef __XEN__ -typedef struct vcpu_info vcpu_info_t; -#endif - -/* - * `incontents 200 startofday_shared Start-of-day shared data structure - * Xen/kernel shared data -- pointer provided in start_info. - * - * This structure is defined to be both smaller than a page, and the - * only data on the shared page, but may vary in actual size even within - * compatible Xen versions; guests should not rely on the size - * of this structure remaining constant. - */ -struct shared_info { - struct vcpu_info vcpu_info[XEN_LEGACY_MAX_VCPUS]; - - /* - * A domain can create "event channels" on which it can send and receive - * asynchronous event notifications. There are three classes of event that - * are delivered by this mechanism: - * 1. Bi-directional inter- and intra-domain connections. Domains must - * arrange out-of-band to set up a connection (usually by allocating - * an unbound 'listener' port and avertising that via a storage service - * such as xenstore). - * 2. Physical interrupts. A domain with suitable hardware-access - * privileges can bind an event-channel port to a physical interrupt - * source. - * 3. Virtual interrupts ('events'). A domain can bind an event-channel - * port to a virtual interrupt source, such as the virtual-timer - * device or the emergency console. - * - * Event channels are addressed by a "port index". Each channel is - * associated with two bits of information: - * 1. PENDING -- notifies the domain that there is a pending notification - * to be processed. This bit is cleared by the guest. - * 2. MASK -- if this bit is clear then a 0->1 transition of PENDING - * will cause an asynchronous upcall to be scheduled. This bit is only - * updated by the guest. It is read-only within Xen. If a channel - * becomes pending while the channel is masked then the 'edge' is lost - * (i.e., when the channel is unmasked, the guest must manually handle - * pending notifications as no upcall will be scheduled by Xen). - * - * To expedite scanning of pending notifications, any 0->1 pending - * transition on an unmasked channel causes a corresponding bit in a - * per-vcpu selector word to be set. Each bit in the selector covers a - * 'C INTN' in the PENDING bitfield array. - */ - xen_ulong_t evtchn_pending[sizeof(xen_ulong_t) * 8]; - xen_ulong_t evtchn_mask[sizeof(xen_ulong_t) * 8]; - - /* - * Wallclock time: updated only by control software. Guests should base - * their gettimeofday() syscall on this wallclock-base value. - */ - UINT32 wc_version; /* Version counter: see vcpu_time_info_t. */ - UINT32 wc_sec; /* Secs 00:00:00 UTC, Jan 1, 1970. */ - UINT32 wc_nsec; /* Nsecs 00:00:00 UTC, Jan 1, 1970. */ - - struct arch_shared_info arch; - -}; -#ifndef __XEN__ -typedef struct shared_info shared_info_t; -#endif - -/* Turn a plain number into a C UINTN constant. */ -#define __mk_unsigned_long(x) x ## UL -#define mk_unsigned_long(x) __mk_unsigned_long(x) - -__DEFINE_XEN_GUEST_HANDLE(uint8, UINT8); -__DEFINE_XEN_GUEST_HANDLE(uint16, UINT16); -__DEFINE_XEN_GUEST_HANDLE(uint32, UINT32); -__DEFINE_XEN_GUEST_HANDLE(uint64, UINT64); - -#else /* __ASSEMBLY__ */ - -/* In assembly code we cannot use C numeric constant suffixes. */ -#define mk_unsigned_long(x) x - -#endif /* !__ASSEMBLY__ */ - -#endif /* __XEN_PUBLIC_XEN_H__ */ - -/* - * Local variables: - * mode: C - * c-file-style: "BSD" - * c-basic-offset: 4 - * tab-width: 4 - * indent-tabs-mode: nil - * End: - */ diff --git a/OvmfPkg/Include/Library/LoadLinuxLib.h b/OvmfPkg/Include/Library/LoadLinuxLib.h deleted file mode 100644 index d33249903c..0000000000 --- a/OvmfPkg/Include/Library/LoadLinuxLib.h +++ /dev/null @@ -1,211 +0,0 @@ -/** @file - Load/boot UEFI Linux. - - Copyright (c) 2011 - 2013, Intel Corporation. All rights reserved.
- This program and the accompanying materials - are licensed and made available under the terms and conditions of the BSD License - which accompanies this distribution. The full text of the license may be found at - http://opensource.org/licenses/bsd-license.php - - THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, - WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. - -**/ - -#ifndef __LOAD_LINUX_LIB__ -#define __LOAD_LINUX_LIB__ - - -/** - Verifies that the kernel setup image is valid and supported. - The kernel setup image should be checked before using other library - routines which take the kernel setup as an input. - - @param[in] KernelSetup - The kernel setup image - @param[in] KernelSetupSize - The kernel setup size - - @retval EFI_SUCCESS - The Linux kernel setup is valid and supported - @retval EFI_INVALID_PARAMETER - KernelSetup was NULL - @retval EFI_UNSUPPORTED - The Linux kernel is not supported - -**/ -EFI_STATUS -EFIAPI -LoadLinuxCheckKernelSetup ( - IN VOID *KernelSetup, - IN UINTN KernelSetupSize - ); - - -/** - Gets the initial runtime size of the Linux kernel image by examining - the kernel setup image. - - @param[in] KernelSetup - The kernel setup image - @param[in] KernelSize - The kernel size on disk. - - @retval 0 An error occurred - @retval !0 The initial size required by the kernel to - begin execution. - -**/ -UINTN -EFIAPI -LoadLinuxGetKernelSize ( - IN VOID *KernelSetup, - IN UINTN KernelSize - ); - - -/** - Loads and boots UEFI Linux. - - Note: If successful, then this routine will not return - - @param[in] Kernel - The main kernel image - @param[in,out] KernelSetup - The kernel setup image - - @retval EFI_NOT_FOUND - The Linux kernel was not found - @retval EFI_INVALID_PARAMETER - Kernel or KernelSetup was NULL - @retval EFI_UNSUPPORTED - The Linux kernel version is not supported - -**/ -EFI_STATUS -EFIAPI -LoadLinux ( - IN VOID *Kernel, - IN OUT VOID *KernelSetup - ); - - -/** - Allocates pages for the kernel setup image. - - @param[in] Pages - The number of pages - - @retval NULL - Unable to allocate pages - @retval !NULL - The address of the pages allocated - -**/ -VOID* -EFIAPI -LoadLinuxAllocateKernelSetupPages ( - IN UINTN Pages - ); - - -/** - Clears the uninitialised space before and after the struct setup_header - in the kernel setup image. The kernel requires that these be zeroed - unless explicitly initialised, so this function should be called after - the setup_header has been copied in from a bzImage, before setting up - anything else. - - @param[in] KernelSetup - The kernel setup image - - @retval EFI_SUCCESS - The Linux kernel setup was successfully initialized - @retval EFI_INVALID_PARAMETER - KernelSetup was NULL - @retval EFI_UNSUPPORTED - The Linux kernel is not supported - -**/ -EFI_STATUS -EFIAPI -LoadLinuxInitializeKernelSetup ( - IN VOID *KernelSetup - ); - -/** - Allocates pages for the kernel. - - @param[in] KernelSetup - The kernel setup image - @param[in] Pages - The number of pages. (It is recommended to use the - size returned from LoadLinuxGetKernelSize.) - - @retval NULL - Unable to allocate pages - @retval !NULL - The address of the pages allocated - -**/ -VOID* -EFIAPI -LoadLinuxAllocateKernelPages ( - IN VOID *KernelSetup, - IN UINTN Pages - ); - - -/** - Allocates pages for the kernel command line. - - @param[in] Pages - The number of pages. - - @retval NULL - Unable to allocate pages - @retval !NULL - The address of the pages allocated - -**/ -VOID* -EFIAPI -LoadLinuxAllocateCommandLinePages ( - IN UINTN Pages - ); - - -/** - Allocates pages for the initrd image. - - @param[in,out] KernelSetup - The kernel setup image - @param[in] Pages - The number of pages. - - @retval NULL - Unable to allocate pages - @retval !NULL - The address of the pages allocated - -**/ -VOID* -EFIAPI -LoadLinuxAllocateInitrdPages ( - IN VOID *KernelSetup, - IN UINTN Pages - ); - - -/** - Sets the kernel command line parameter within the setup image. - - @param[in,out] KernelSetup - The kernel setup image - @param[in] CommandLine - The kernel command line - - @retval EFI_SUCCESS - The Linux kernel setup is valid and supported - @retval EFI_INVALID_PARAMETER - KernelSetup was NULL - @retval EFI_UNSUPPORTED - The Linux kernel is not supported - -**/ -EFI_STATUS -EFIAPI -LoadLinuxSetCommandLine ( - IN OUT VOID *KernelSetup, - IN CHAR8 *CommandLine - ); - - -/** - Sets the kernel initial ram disk pointer within the setup image. - - @param[in,out] KernelSetup - The kernel setup image - @param[in] Initrd - Pointer to the initial ram disk - @param[in] InitrdSize - The initial ram disk image size - - @retval EFI_SUCCESS - The Linux kernel setup is valid and supported - @retval EFI_INVALID_PARAMETER - KernelSetup was NULL - @retval EFI_UNSUPPORTED - The Linux kernel is not supported - -**/ -EFI_STATUS -EFIAPI -LoadLinuxSetInitrd ( - IN OUT VOID *KernelSetup, - IN VOID *Initrd, - IN UINTN InitrdSize - ); - - -#endif - diff --git a/OvmfPkg/Include/Library/NvVarsFileLib.h b/OvmfPkg/Include/Library/NvVarsFileLib.h deleted file mode 100644 index a9548678f3..0000000000 --- a/OvmfPkg/Include/Library/NvVarsFileLib.h +++ /dev/null @@ -1,51 +0,0 @@ -/** @file - Provides functions to save and restore NV variables in a file. - - Copyright (c) 2009, Intel Corporation. All rights reserved.
- This program and the accompanying materials - are licensed and made available under the terms and conditions of the BSD License - which accompanies this distribution. The full text of the license may be found at - http://opensource.org/licenses/bsd-license.php - - THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, - WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. - -**/ - -#ifndef __NV_VARS_FILE_LIB__ -#define __NV_VARS_FILE_LIB__ - -/** - Attempts to connect the NvVarsFileLib to the specified file system. - - @param[in] FsHandle - Handle for a gEfiSimpleFileSystemProtocolGuid instance - - @return The EFI_STATUS while attempting to connect the NvVarsFileLib - to the file system instance. - @retval EFI_SUCCESS - The given file system was connected successfully - -**/ -EFI_STATUS -EFIAPI -ConnectNvVarsToFileSystem ( - IN EFI_HANDLE FsHandle - ); - - -/** - Update non-volatile variables stored on the file system. - - @return The EFI_STATUS while attempting to update the variable on - the connected file system. - @retval EFI_SUCCESS - The non-volatile variables were saved to the disk - @retval EFI_NOT_STARTED - A file system has not been connected - -**/ -EFI_STATUS -EFIAPI -UpdateNvVarsOnFileSystem ( - ); - - -#endif - diff --git a/OvmfPkg/Include/Library/PlatformFvbLib.h b/OvmfPkg/Include/Library/PlatformFvbLib.h deleted file mode 100644 index d4d09b2ebd..0000000000 --- a/OvmfPkg/Include/Library/PlatformFvbLib.h +++ /dev/null @@ -1,87 +0,0 @@ -/** @file - Library to define platform customization functions for a - Firmare Volume Block driver. - - Copyright (c) 2009 - 2011, Intel Corporation. All rights reserved.
- This program and the accompanying materials - are licensed and made available under the terms and conditions of the BSD License - which accompanies this distribution. The full text of the license may be found at - http://opensource.org/licenses/bsd-license.php - - THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, - WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. - -**/ - -#ifndef __PLATFORM_FVB_LIB__ -#define __PLATFORM_FVB_LIB__ - -#include - -/** - This function will be called following a call to the - EFI_FIRMWARE_VOLUME_BLOCK2_PROTOCOL Read function. - - @param[in] This The EFI_FIRMWARE_VOLUME_BLOCK2_PROTOCOL instance. - @param[in] Lba The starting logical block index - from which to read. - @param[in] Offset Offset into the block at which to begin reading. - @param[in] NumBytes The number of bytes read. - @param[in] Buffer Pointer to the buffer that was read, and will be - returned to the caller. - -**/ -VOID -EFIAPI -PlatformFvbDataRead ( - IN CONST EFI_FIRMWARE_VOLUME_BLOCK2_PROTOCOL *This, - IN EFI_LBA Lba, - IN UINTN Offset, - IN UINTN NumBytes, - IN UINT8 *Buffer - ); - - -/** - This function will be called following a call to the - EFI_FIRMWARE_VOLUME_BLOCK2_PROTOCOL Write function. - - @param[in] This EFI_FIRMWARE_VOLUME_BLOCK2_PROTOCOL instance. - @param[in] Lba The starting logical block index to written to. - @param[in] Offset Offset into the block at which to begin writing. - @param[in] NumBytes The number of bytes written. - @param[in] Buffer Pointer to the buffer that was written. - -**/ -VOID -EFIAPI -PlatformFvbDataWritten ( - IN CONST EFI_FIRMWARE_VOLUME_BLOCK2_PROTOCOL *This, - IN EFI_LBA Lba, - IN UINTN Offset, - IN UINTN NumBytes, - IN UINT8 *Buffer - ); - - -/** - This function will be called following a call to the - EFI_FIRMWARE_VOLUME_BLOCK2_PROTOCOL Erase function. - - @param This Indicates the EFI_FIRMWARE_VOLUME_BLOCK2_PROTOCOL - instance. - @param List The variable argument list as documented for - the EFI_FIRMWARE_VOLUME_BLOCK2_PROTOCOL Erase - function. - -**/ -VOID -EFIAPI -PlatformFvbBlocksErased ( - IN CONST EFI_FIRMWARE_VOLUME_BLOCK2_PROTOCOL *This, - IN VA_LIST List - ); - - -#endif - diff --git a/OvmfPkg/Include/Library/QemuBootOrderLib.h b/OvmfPkg/Include/Library/QemuBootOrderLib.h deleted file mode 100644 index 743a717824..0000000000 --- a/OvmfPkg/Include/Library/QemuBootOrderLib.h +++ /dev/null @@ -1,68 +0,0 @@ -/** @file - Rewrite the BootOrder NvVar based on QEMU's "bootorder" fw_cfg file -- - include file. - - Copyright (C) 2012-2014, 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 __QEMU_BOOT_ORDER_LIB_H__ -#define __QEMU_BOOT_ORDER_LIB_H__ - -#include -#include - - -/** - - Set the boot order based on configuration retrieved from QEMU. - - Attempt to retrieve the "bootorder" fw_cfg file from QEMU. Translate the - OpenFirmware device paths therein to UEFI device path fragments. Match the - translated fragments against the current list of boot options, and rewrite - the BootOrder NvVar so that it corresponds to the order described in fw_cfg. - - Platform BDS should call this function after EfiBootManagerConnectAll () and - EfiBootManagerRefreshAllBootOption () return. - - @retval RETURN_SUCCESS BootOrder NvVar rewritten. - - @retval RETURN_UNSUPPORTED QEMU's fw_cfg is not supported. - - @retval RETURN_NOT_FOUND Empty or nonexistent "bootorder" fw_cfg - file, or no match found between the - "bootorder" fw_cfg file and BootOptionList. - - @retval RETURN_INVALID_PARAMETER Parse error in the "bootorder" fw_cfg file. - - @retval RETURN_OUT_OF_RESOURCES Memory allocation failed. - - @return Values returned by gBS->LocateProtocol () - or gRT->SetVariable (). - -**/ -RETURN_STATUS -SetBootOrderFromQemu ( - VOID - ); - - -/** - Calculate the number of seconds we should be showing the FrontPage progress - bar for. - - @return The TimeoutDefault argument for PlatformBdsEnterFrontPage(). -**/ -UINT16 -GetFrontPageTimeoutFromQemu ( - VOID - ); - -#endif diff --git a/OvmfPkg/Include/Library/QemuFwCfgLib.h b/OvmfPkg/Include/Library/QemuFwCfgLib.h deleted file mode 100644 index 596e3f25d5..0000000000 --- a/OvmfPkg/Include/Library/QemuFwCfgLib.h +++ /dev/null @@ -1,183 +0,0 @@ -/** @file - QEMU/KVM Firmware Configuration access - - Copyright (c) 2011 - 2013, Intel Corporation. All rights reserved.
- Copyright (C) 2013, Red Hat, Inc. - - This program and the accompanying materials - are licensed and made available under the terms and conditions of the BSD License - which accompanies this distribution. The full text of the license may be found at - http://opensource.org/licenses/bsd-license.php - - THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, - WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. - -**/ - -#ifndef __FW_CFG_LIB__ -#define __FW_CFG_LIB__ - -#include - -/** - Returns a boolean indicating if the firmware configuration interface - is available or not. - - This function may change fw_cfg state. - - @retval TRUE The interface is available - @retval FALSE The interface is not available - -**/ -BOOLEAN -EFIAPI -QemuFwCfgIsAvailable ( - VOID - ); - - -/** - Selects a firmware configuration item for reading. - - Following this call, any data read from this item will start from - the beginning of the configuration item's data. - - @param[in] QemuFwCfgItem - Firmware Configuration item to read - -**/ -VOID -EFIAPI -QemuFwCfgSelectItem ( - IN FIRMWARE_CONFIG_ITEM QemuFwCfgItem - ); - - -/** - Reads firmware configuration bytes into a buffer - - If called multiple times, then the data read will - continue at the offset of the firmware configuration - item where the previous read ended. - - @param[in] Size - Size in bytes to read - @param[in] Buffer - Buffer to store data into - -**/ -VOID -EFIAPI -QemuFwCfgReadBytes ( - IN UINTN Size, - IN VOID *Buffer OPTIONAL - ); - - -/** - Writes firmware configuration bytes from a buffer - - If called multiple times, then the data written will - continue at the offset of the firmware configuration - item where the previous write ended. - - @param[in] Size - Size in bytes to write - @param[in] Buffer - Buffer to read data from - -**/ -VOID -EFIAPI -QemuFwCfgWriteBytes ( - IN UINTN Size, - IN VOID *Buffer - ); - - -/** - Skip bytes in the firmware configuration item. - - Increase the offset of the firmware configuration item without transferring - bytes between the item and a caller-provided buffer. Subsequent read, write - or skip operations will commence at the increased offset. - - @param[in] Size Number of bytes to skip. -**/ -VOID -EFIAPI -QemuFwCfgSkipBytes ( - IN UINTN Size - ); - - -/** - Reads a UINT8 firmware configuration value - - @return Value of Firmware Configuration item read - -**/ -UINT8 -EFIAPI -QemuFwCfgRead8 ( - VOID - ); - - -/** - Reads a UINT16 firmware configuration value - - @return Value of Firmware Configuration item read - -**/ -UINT16 -EFIAPI -QemuFwCfgRead16 ( - VOID - ); - - -/** - Reads a UINT32 firmware configuration value - - @return Value of Firmware Configuration item read - -**/ -UINT32 -EFIAPI -QemuFwCfgRead32 ( - VOID - ); - - -/** - Reads a UINT64 firmware configuration value - - @return Value of Firmware Configuration item read - -**/ -UINT64 -EFIAPI -QemuFwCfgRead64 ( - VOID - ); - - -/** - Find the configuration item corresponding to the firmware configuration file. - - @param[in] Name - Name of file to look up. - @param[out] Item - Configuration item corresponding to the file, to be passed - to QemuFwCfgSelectItem (). - @param[out] Size - Number of bytes in the file. - - @return RETURN_SUCCESS If file is found. - RETURN_NOT_FOUND If file is not found. - RETURN_UNSUPPORTED If firmware configuration is unavailable. - -**/ -RETURN_STATUS -EFIAPI -QemuFwCfgFindFile ( - IN CONST CHAR8 *Name, - OUT FIRMWARE_CONFIG_ITEM *Item, - OUT UINTN *Size - ); - -#endif - diff --git a/OvmfPkg/Include/Library/QemuFwCfgS3Lib.h b/OvmfPkg/Include/Library/QemuFwCfgS3Lib.h deleted file mode 100644 index 432e3c906c..0000000000 --- a/OvmfPkg/Include/Library/QemuFwCfgS3Lib.h +++ /dev/null @@ -1,361 +0,0 @@ -/** @file - S3 support for QEMU fw_cfg - - This library class enables driver modules (a) to query whether S3 support was - enabled on the QEMU command line, (b) to produce fw_cfg DMA operations that - are to be replayed at S3 resume time. - - Copyright (C) 2017, 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 __FW_CFG_S3_LIB__ -#define __FW_CFG_S3_LIB__ - -#include - -/** - Determine if S3 support is explicitly enabled. - - @retval TRUE If S3 support is explicitly enabled. Other functions in this - library may be called (subject to their individual - restrictions). - - FALSE Otherwise. This includes unavailability of the firmware - configuration interface. No other function in this library - must be called. -**/ -BOOLEAN -EFIAPI -QemuFwCfgS3Enabled ( - VOID - ); - - -/** - Prototype for the callback function that the client module provides. - - In the callback function, the client module calls the - QemuFwCfgS3ScriptWriteBytes(), QemuFwCfgS3ScriptReadBytes(), - QemuFwCfgS3ScriptSkipBytes(), and QemuFwCfgS3ScriptCheckValue() functions. - Those functions produce ACPI S3 Boot Script opcodes that will perform fw_cfg - DMA operations, and will check any desired values that were read, during S3 - resume. - - The callback function is invoked when the production of ACPI S3 Boot Script - opcodes becomes possible. This may occur directly on the call stack of - QemuFwCfgS3CallWhenBootScriptReady() (see below), or after - QemuFwCfgS3CallWhenBootScriptReady() has successfully returned. - - The callback function must not return if it fails -- in the general case, - there is noone to propagate any errors to. Therefore, on error, an error - message should be logged, and CpuDeadLoop() must be called. - - @param[in,out] Context Carries information from the client module - itself (i.e., from the invocation of - QemuFwCfgS3CallWhenBootScriptReady()) to the - callback function. - - If Context points to dynamically allocated - storage, then the callback function must - release it. - - @param[in,out] ScratchBuffer Points to reserved memory, allocated by - QemuFwCfgS3CallWhenBootScriptReady() - internally. - - ScratchBuffer is typed and sized by the client - module when it calls - QemuFwCfgS3CallWhenBootScriptReady(). The - client module defines a union type of - structures for ScratchBuffer such that the - union can hold client data for any desired - fw_cfg DMA read and write operations, and value - checking. - - The callback function casts ScratchBuffer to - the union type described above. It passes union - member sizes as NumberOfBytes to - QemuFwCfgS3ScriptReadBytes() and - QemuFwCfgS3ScriptWriteBytes(). It passes field - addresses and sizes in structures in the union - as ScratchData and ValueSize to - QemuFwCfgS3ScriptCheckValue(). - - ScratchBuffer is aligned at 8 bytes. -**/ -typedef -VOID (EFIAPI FW_CFG_BOOT_SCRIPT_CALLBACK_FUNCTION) ( - IN OUT VOID *Context, OPTIONAL - IN OUT VOID *ScratchBuffer - ); - - -/** - Install the client module's FW_CFG_BOOT_SCRIPT_CALLBACK_FUNCTION callback for - when the production of ACPI S3 Boot Script opcodes becomes possible. - - Take ownership of the client-provided Context, and pass it to the callback - function, when the latter is invoked. - - Allocate scratch space for those ACPI S3 Boot Script opcodes to work upon - that the client will produce in the callback function. - - @param[in] Callback FW_CFG_BOOT_SCRIPT_CALLBACK_FUNCTION to invoke - when the production of ACPI S3 Boot Script - opcodes becomes possible. Callback() may be - called immediately from - QemuFwCfgS3CallWhenBootScriptReady(). - - @param[in,out] Context Client-provided data structure for the - Callback() callback function to consume. - - If Context points to dynamically allocated - memory, then Callback() must release it. - - If Context points to dynamically allocated - memory, and - QemuFwCfgS3CallWhenBootScriptReady() returns - successfully, then the caller of - QemuFwCfgS3CallWhenBootScriptReady() must - neither dereference nor even evaluate Context - any longer, as ownership of the referenced area - has been transferred to Callback(). - - @param[in] ScratchBufferSize The size of the scratch buffer that will hold, - in reserved memory, all client data read, - written, and checked by the ACPI S3 Boot Script - opcodes produced by Callback(). - - @retval RETURN_UNSUPPORTED The library instance does not support this - function. - - @retval RETURN_NOT_FOUND The fw_cfg DMA interface to QEMU is - unavailable. - - @retval RETURN_BAD_BUFFER_SIZE ScratchBufferSize is too large. - - @retval RETURN_OUT_OF_RESOURCES Memory allocation failed. - - @retval RETURN_SUCCESS Callback() has been installed, and the - ownership of Context has been transferred. - Reserved memory has been allocated for the - scratch buffer. - - A successful invocation of - QemuFwCfgS3CallWhenBootScriptReady() cannot - be rolled back. - - @return Error codes from underlying functions. -**/ -RETURN_STATUS -EFIAPI -QemuFwCfgS3CallWhenBootScriptReady ( - IN FW_CFG_BOOT_SCRIPT_CALLBACK_FUNCTION *Callback, - IN OUT VOID *Context, OPTIONAL - IN UINTN ScratchBufferSize - ); - - -/** - Produce ACPI S3 Boot Script opcodes that (optionally) select an fw_cfg item, - and transfer data to it. - - The opcodes produced by QemuFwCfgS3ScriptWriteBytes() will first restore - NumberOfBytes bytes in ScratchBuffer in-place, in reserved memory, then write - them to fw_cfg using DMA. - - If the operation fails during S3 resume, the boot script will hang. - - This function may only be called from the client module's - FW_CFG_BOOT_SCRIPT_CALLBACK_FUNCTION, which was passed to - QemuFwCfgS3CallWhenBootScriptReady() as Callback. - - @param[in] FirmwareConfigItem The UINT16 selector key of the firmware config - item to write, expressed as INT32. If - FirmwareConfigItem is -1, no selection is - made, the write will occur to the currently - selected item, at its currently selected - offset. Otherwise, the specified item will be - selected, and the write will occur at offset - 0. - - @param[in] NumberOfBytes Size of the data to restore in ScratchBuffer, - and to write from ScratchBuffer, during S3 - resume. NumberOfBytes must not exceed - ScratchBufferSize, which was passed to - QemuFwCfgS3CallWhenBootScriptReady(). - - @retval RETURN_SUCCESS The opcodes were appended to the ACPI S3 - Boot Script successfully. There is no way - to undo this action. - - @retval RETURN_INVALID_PARAMETER FirmwareConfigItem is invalid. - - @retval RETURN_BAD_BUFFER_SIZE NumberOfBytes is larger than - ScratchBufferSize. - - @return Error codes from underlying functions. -**/ -RETURN_STATUS -EFIAPI -QemuFwCfgS3ScriptWriteBytes ( - IN INT32 FirmwareConfigItem, - IN UINTN NumberOfBytes - ); - - -/** - Produce ACPI S3 Boot Script opcodes that (optionally) select an fw_cfg item, - and transfer data from it. - - The opcodes produced by QemuFwCfgS3ScriptReadBytes() will read NumberOfBytes - bytes from fw_cfg using DMA, storing the result in ScratchBuffer, in reserved - memory. - - If the operation fails during S3 resume, the boot script will hang. - - This function may only be called from the client module's - FW_CFG_BOOT_SCRIPT_CALLBACK_FUNCTION, which was passed to - QemuFwCfgS3CallWhenBootScriptReady() as Callback. - - @param[in] FirmwareConfigItem The UINT16 selector key of the firmware config - item to read, expressed as INT32. If - FirmwareConfigItem is -1, no selection is - made, the read will occur from the currently - selected item, from its currently selected - offset. Otherwise, the specified item will be - selected, and the read will occur from offset - 0. - - @param[in] NumberOfBytes Size of the data to read during S3 resume. - NumberOfBytes must not exceed - ScratchBufferSize, which was passed to - QemuFwCfgS3CallWhenBootScriptReady(). - - @retval RETURN_SUCCESS The opcodes were appended to the ACPI S3 - Boot Script successfully. There is no way - to undo this action. - - @retval RETURN_INVALID_PARAMETER FirmwareConfigItem is invalid. - - @retval RETURN_BAD_BUFFER_SIZE NumberOfBytes is larger than - ScratchBufferSize. - - @return Error codes from underlying functions. -**/ -RETURN_STATUS -EFIAPI -QemuFwCfgS3ScriptReadBytes ( - IN INT32 FirmwareConfigItem, - IN UINTN NumberOfBytes - ); - - -/** - Produce ACPI S3 Boot Script opcodes that (optionally) select an fw_cfg item, - and increase its offset. - - If the operation fails during S3 resume, the boot script will hang. - - This function may only be called from the client module's - FW_CFG_BOOT_SCRIPT_CALLBACK_FUNCTION, which was passed to - QemuFwCfgS3CallWhenBootScriptReady() as Callback. - - @param[in] FirmwareConfigItem The UINT16 selector key of the firmware config - item to advance the offset of, expressed as - INT32. If FirmwareConfigItem is -1, no - selection is made, and the offset for the - currently selected item is increased. - Otherwise, the specified item will be - selected, and the offset increment will occur - from offset 0. - - @param[in] NumberOfBytes The number of bytes to skip in the subject - fw_cfg item. - - @retval RETURN_SUCCESS The opcodes were appended to the ACPI S3 - Boot Script successfully. There is no way - to undo this action. - - @retval RETURN_INVALID_PARAMETER FirmwareConfigItem is invalid. - - @retval RETURN_BAD_BUFFER_SIZE NumberOfBytes is too large. - - @return Error codes from underlying functions. -**/ -RETURN_STATUS -EFIAPI -QemuFwCfgS3ScriptSkipBytes ( - IN INT32 FirmwareConfigItem, - IN UINTN NumberOfBytes - ); - - -/** - Produce ACPI S3 Boot Script opcodes that check a value in ScratchBuffer. - - If the check fails during S3 resume, the boot script will hang. - - This function may only be called from the client module's - FW_CFG_BOOT_SCRIPT_CALLBACK_FUNCTION, which was passed to - QemuFwCfgS3CallWhenBootScriptReady() as Callback. - - @param[in] ScratchData Pointer to the UINT8, UINT16, UINT32 or UINT64 field - in ScratchBuffer that should be checked. The caller - is responsible for populating the field during S3 - resume, by calling QemuFwCfgS3ScriptReadBytes() ahead - of QemuFwCfgS3ScriptCheckValue(). - - ScratchData must point into ScratchBuffer, which was - allocated, and passed to Callback(), by - QemuFwCfgS3CallWhenBootScriptReady(). - - ScratchData must be aligned at ValueSize bytes. - - @param[in] ValueSize One of 1, 2, 4 or 8, specifying the size of the field - to check. - - @param[in] ValueMask The value read from ScratchData is binarily AND-ed - with ValueMask, and the result is compared against - Value. If the masked data equals Value, the check - passes, and the boot script can proceed. Otherwise, - the check fails, and the boot script hangs. - - @param[in] Value Refer to ValueMask. - - @retval RETURN_SUCCESS The opcodes were appended to the ACPI S3 - Boot Script successfully. There is no way - to undo this action. - - @retval RETURN_INVALID_PARAMETER ValueSize is invalid. - - @retval RETURN_INVALID_PARAMETER ValueMask or Value cannot be represented in - ValueSize bytes. - - @retval RETURN_INVALID_PARAMETER ScratchData is not aligned at ValueSize - bytes. - - @retval RETURN_BAD_BUFFER_SIZE The ValueSize bytes at ScratchData aren't - wholly contained in the ScratchBufferSize - bytes at ScratchBuffer. - - @return Error codes from underlying functions. -**/ -RETURN_STATUS -EFIAPI -QemuFwCfgS3ScriptCheckValue ( - IN VOID *ScratchData, - IN UINT8 ValueSize, - IN UINT64 ValueMask, - IN UINT64 Value - ); - -#endif diff --git a/OvmfPkg/Include/Library/SerializeVariablesLib.h b/OvmfPkg/Include/Library/SerializeVariablesLib.h deleted file mode 100644 index c9feeb0515..0000000000 --- a/OvmfPkg/Include/Library/SerializeVariablesLib.h +++ /dev/null @@ -1,229 +0,0 @@ -/** @file - Serialize & Deserialize UEFI Variables - - Copyright (c) 2011, Intel Corporation. All rights reserved.
- This program and the accompanying materials - are licensed and made available under the terms and conditions of the BSD License - which accompanies this distribution. The full text of the license may be found at - http://opensource.org/licenses/bsd-license.php - - THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, - WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. - -**/ - -#ifndef __SERIALIZE_VARIABLES_LIB__ -#define __SERIALIZE_VARIABLES_LIB__ - - -/** - Callback function for each variable - - @param[in] Context - Context as sent to the iteration function - @param[in] VariableName - Refer to RuntimeServices GetNextVariableName - @param[in] VendorGuid - Refer to RuntimeServices GetNextVariableName - @param[in] Attributes - Refer to RuntimeServices GetVariable - @param[in] DataSize - Refer to RuntimeServices GetVariable - @param[in] Data - Refer to RuntimeServices GetVariable - - @retval RETURN_SUCCESS Continue iterating through the variables - @return Any RETURN_ERROR Stop iterating through the variables - -**/ -typedef -RETURN_STATUS -(EFIAPI *VARIABLE_SERIALIZATION_ITERATION_CALLBACK)( - IN VOID *Context, - IN CHAR16 *VariableName, - IN EFI_GUID *VendorGuid, - IN UINT32 Attributes, - IN UINTN DataSize, - IN VOID *Data - ); - - -/** - Creates a new variable serialization instance - - @param[out] Handle - Handle for a variable serialization instance - - @retval RETURN_SUCCESS - The variable serialization instance was - successfully created. - @retval RETURN_OUT_OF_RESOURCES - There we not enough resources to - create the variable serialization instance. - -**/ -RETURN_STATUS -EFIAPI -SerializeVariablesNewInstance ( - OUT EFI_HANDLE *Handle - ); - - -/** - Free memory associated with a variable serialization instance - - @param[in] Handle - Handle for a variable serialization instance - - @retval RETURN_SUCCESS - The variable serialization instance was - successfully freed. - @retval RETURN_INVALID_PARAMETER - Handle was not a valid - variable serialization instance. - -**/ -RETURN_STATUS -EFIAPI -SerializeVariablesFreeInstance ( - IN EFI_HANDLE Handle - ); - - -/** - Creates a new variable serialization instance using the given - binary representation of the variables to fill the new instance - - @param[out] Handle - Handle for a variable serialization instance - @param[in] Buffer - A buffer with the serialized representation - of the variables. Must be the same format as produced - by SerializeVariablesToBuffer. - @param[in] Size - This is the size of the binary representation - of the variables. - - @retval RETURN_SUCCESS - The binary representation was successfully - imported into a new variable serialization instance - @retval RETURN_OUT_OF_RESOURCES - There we not enough resources to - create the new variable serialization instance - -**/ -RETURN_STATUS -EFIAPI -SerializeVariablesNewInstanceFromBuffer ( - OUT EFI_HANDLE *Handle, - IN VOID *Buffer, - IN UINTN Size - ); - - -/** - Iterates all variables found with RuntimeServices GetNextVariableName - - @param[in] CallbackFunction - Function called for each variable instance - @param[in] Context - Passed to each call of CallbackFunction - - @retval RETURN_SUCCESS - All variables were iterated without the - CallbackFunction returning an error - @retval RETURN_OUT_OF_RESOURCES - There we not enough resources to - iterate through the variables - @return Any of RETURN_ERROR indicates an error reading the variable - or an error was returned from CallbackFunction - -**/ -RETURN_STATUS -EFIAPI -SerializeVariablesIterateSystemVariables ( - IN VARIABLE_SERIALIZATION_ITERATION_CALLBACK CallbackFunction, - IN VOID *Context - ); - - -/** - Iterates all variables found in the variable serialization instance - - @param[in] Handle - Handle for a variable serialization instance - @param[in] CallbackFunction - Function called for each variable instance - @param[in] Context - Passed to each call of CallbackFunction - - @retval RETURN_SUCCESS - All variables were iterated without the - CallbackFunction returning an error - @retval RETURN_OUT_OF_RESOURCES - There we not enough resources to - iterate through the variables - @return Any of RETURN_ERROR indicates an error reading the variable - or an error was returned from CallbackFunction - -**/ -RETURN_STATUS -EFIAPI -SerializeVariablesIterateInstanceVariables ( - IN EFI_HANDLE Handle, - IN VARIABLE_SERIALIZATION_ITERATION_CALLBACK CallbackFunction, - IN VOID *Context - ); - - -/** - Sets all variables found in the variable serialization instance - - @param[in] Handle - Handle for a variable serialization instance - - @retval RETURN_SUCCESS - All variables were set successfully - @retval RETURN_OUT_OF_RESOURCES - There we not enough resources to - set all the variables - @return Any of RETURN_ERROR indicates an error reading the variables - or in attempting to set a variable - -**/ -RETURN_STATUS -EFIAPI -SerializeVariablesSetSerializedVariables ( - IN EFI_HANDLE Handle - ); - - -/** - Adds a variable to the variable serialization instance - - @param[in] Handle - Handle for a variable serialization instance - @param[in] VariableName - Refer to RuntimeServices GetVariable - @param[in] VendorGuid - Refer to RuntimeServices GetVariable - @param[in] Attributes - Refer to RuntimeServices GetVariable - @param[in] DataSize - Refer to RuntimeServices GetVariable - @param[in] Data - Refer to RuntimeServices GetVariable - - @retval RETURN_SUCCESS - All variables were set successfully - @retval RETURN_OUT_OF_RESOURCES - There we not enough resources to - add the variable - -**/ -RETURN_STATUS -EFIAPI -SerializeVariablesAddVariable ( - IN EFI_HANDLE Handle, - IN CHAR16 *VariableName, - IN EFI_GUID *VendorGuid, - IN UINT32 Attributes, - IN UINTN DataSize, - IN VOID *Data - ); - - -/** - Serializes the variables known to this instance into the - provided buffer. - - @param[in] Handle - Handle for a variable serialization instance - @param[out] Buffer - A buffer to store the binary representation - of the variables. - @param[in,out] Size - On input this is the size of the buffer. - On output this is the size of the binary representation - of the variables. - - @retval RETURN_SUCCESS - The binary representation was successfully - completed and returned in the buffer. - @retval RETURN_OUT_OF_RESOURCES - There we not enough resources to - save the variables to the buffer. - @retval RETURN_INVALID_PARAMETER - Handle was not a valid - variable serialization instance or - Size or Buffer were NULL. - -**/ -RETURN_STATUS -EFIAPI -SerializeVariablesToBuffer ( - IN EFI_HANDLE Handle, - OUT VOID *Buffer, - IN OUT UINTN *Size - ); - - -#endif - diff --git a/OvmfPkg/Include/Library/VirtioLib.h b/OvmfPkg/Include/Library/VirtioLib.h deleted file mode 100644 index 5badfb3291..0000000000 --- a/OvmfPkg/Include/Library/VirtioLib.h +++ /dev/null @@ -1,238 +0,0 @@ -/** @file - - Declarations of utility functions used by virtio device drivers. - - Copyright (C) 2012-2016, 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 - -#include - - -/** - - 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 HeadDescIdx; - UINT16 NextDescIdx; -} 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 section from virtio-0.9.5: - - 2.4.1.1 Placing Buffers into the Descriptor Table - - 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. - - @param[in,out] Indices Indices->HeadDescIdx is not accessed. - On input, Indices->NextDescIdx identifies the next - descriptor to carry the buffer. On output, - Indices->NextDescIdx is incremented by one, modulo - 2^16. - -**/ -VOID -EFIAPI -VirtioAppendDesc ( - IN OUT VRING *Ring, - IN UINTN BufferPhysAddr, - IN UINT32 BufferSize, - IN UINT16 Flags, - IN OUT DESC_INDICES *Indices - ); - - -/** - - Notify the host about the descriptor chain just built, and wait until the - host processes it. - - @param[in] VirtIo The target virtio 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 Indices->NextDescIdx is not accessed. - Indices->HeadDescIdx identifies the head descriptor - of the descriptor chain. - - @param[out] UsedLen On success, the total number of bytes, consecutively - across the buffers linked by the descriptor chain, - that the host wrote. May be NULL if the caller - doesn't care, or can compute the same information - from device-specific request structures linked by the - descriptor chain. - - @return Error code from VirtIo->SetQueueNotify() if it fails. - - @retval EFI_SUCCESS Otherwise, the host processed all descriptors. - -**/ -EFI_STATUS -EFIAPI -VirtioFlush ( - IN VIRTIO_DEVICE_PROTOCOL *VirtIo, - IN UINT16 VirtQueueId, - IN OUT VRING *Ring, - IN DESC_INDICES *Indices, - OUT UINT32 *UsedLen OPTIONAL - ); - - -/** - - Report the feature bits to the VirtIo 1.0 device that the VirtIo 1.0 driver - understands. - - In VirtIo 1.0, a device can reject a self-inconsistent feature bitmap through - the new VSTAT_FEATURES_OK status bit. (For example if the driver requests a - higher level feature but clears a prerequisite feature.) This function is a - small wrapper around VIRTIO_DEVICE_PROTOCOL.SetGuestFeatures() that also - verifies if the VirtIo 1.0 device accepts the feature bitmap. - - @param[in] VirtIo Report feature bits to this device. - - @param[in] Features The set of feature bits that the driver wishes - to report. The caller is responsible to perform - any masking before calling this function; the - value is directly written with - VIRTIO_DEVICE_PROTOCOL.SetGuestFeatures(). - - @param[in,out] DeviceStatus On input, the status byte most recently written - to the device's status register. On output (even - on error), DeviceStatus will be updated so that - it is suitable for further status bit - manipulation and writing to the device's status - register. - - @retval EFI_SUCCESS The device accepted the configuration in Features. - - @return EFI_UNSUPPORTED The device rejected the configuration in Features. - - @retval EFI_UNSUPPORTED VirtIo->Revision is smaller than 1.0.0. - - @return Error codes from the SetGuestFeatures(), - SetDeviceStatus(), GetDeviceStatus() member - functions. - -**/ -EFI_STATUS -EFIAPI -Virtio10WriteFeatures ( - IN VIRTIO_DEVICE_PROTOCOL *VirtIo, - IN UINT64 Features, - IN OUT UINT8 *DeviceStatus - ); - -#endif // _VIRTIO_LIB_H_ diff --git a/OvmfPkg/Include/Library/VirtioMmioDeviceLib.h b/OvmfPkg/Include/Library/VirtioMmioDeviceLib.h deleted file mode 100644 index 3f63a650be..0000000000 --- a/OvmfPkg/Include/Library/VirtioMmioDeviceLib.h +++ /dev/null @@ -1,66 +0,0 @@ -/** @file - - Definitions for the VirtIo MMIO Device Library - - Copyright (C) 2013, ARM Ltd - - This program and the accompanying materials are licensed and made available - under the terms and conditions of the BSD License which accompanies this - distribution. The full text of the license may be found at - http://opensource.org/licenses/bsd-license.php - - THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, WITHOUT - WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. - -**/ - -#ifndef _VIRTIO_MMIO_DEVICE_LIB_H_ -#define _VIRTIO_MMIO_DEVICE_LIB_H_ - -/** - - Initialize VirtIo Device and Install VIRTIO_DEVICE_PROTOCOL protocol - - @param[in] BaseAddress Base Address of the VirtIo MMIO Device - - @param[in] Handle Handle of the device the driver should be attached - to. - - @retval EFI_SUCCESS The VirtIo Device has been installed - successfully. - - @retval EFI_OUT_OF_RESOURCES The function failed to allocate memory required - by the Virtio MMIO device initialization. - - @retval EFI_UNSUPPORTED BaseAddress does not point to a VirtIo MMIO - device. - - @return Status code returned by InstallProtocolInterface - Boot Service function. - -**/ -EFI_STATUS -VirtioMmioInstallDevice ( - IN PHYSICAL_ADDRESS BaseAddress, - IN EFI_HANDLE Handle - ); - -/** - - Uninstall the VirtIo Device - - @param[in] Handle Handle of the device where the VirtIo Device protocol - should have been installed. - - @retval EFI_SUCCESS The device has been un-initialized successfully. - - @return Status code returned by UninstallProtocolInterface - Boot Service function. - -**/ -EFI_STATUS -VirtioMmioUninstallDevice ( - IN EFI_HANDLE Handle - ); - -#endif // _VIRTIO_MMIO_DEVICE_LIB_H_ diff --git a/OvmfPkg/Include/Library/XenHypercallLib.h b/OvmfPkg/Include/Library/XenHypercallLib.h deleted file mode 100644 index 36e3344e2f..0000000000 --- a/OvmfPkg/Include/Library/XenHypercallLib.h +++ /dev/null @@ -1,98 +0,0 @@ -/** @file - Functions declarations to make Xen hypercalls. - - Copyright (C) 2014, Citrix Ltd. - - This program and the accompanying materials - are licensed and made available under the terms and conditions of the BSD License - which accompanies this distribution. The full text of the license may be found at - http://opensource.org/licenses/bsd-license.php - - THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, - WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. - -**/ - -#ifndef __XEN_HYPERCALL_LIB_H__ -#define __XEN_HYPERCALL_LIB_H__ - -/** - Check if the Xen Hypercall library is able to make calls to the Xen - hypervisor. - - Client code should call further functions in this library only if, and after, - this function returns TRUE. - - @retval TRUE Hypercalls are available. - @retval FALSE Hypercalls are not available. -**/ -BOOLEAN -EFIAPI -XenHypercallIsAvailable ( - VOID - ); - -/** - This function will put the two arguments in the right place (registers) and - invoke the hypercall identified by HypercallID. - - @param HypercallID The symbolic ID of the hypercall to be invoked - @param Arg1 First argument. - @param Arg2 Second argument. - - @return Return 0 if success otherwise it return an errno. -**/ -INTN -EFIAPI -XenHypercall2 ( - IN UINTN HypercallID, - IN OUT INTN Arg1, - IN OUT INTN Arg2 - ); - -/** - Return the value of the HVM parameter Index. - - @param Index The parameter to get, e.g. HVM_PARAM_STORE_EVTCHN. - - @return The value of the asked parameter or 0 in case of error. -**/ -UINT64 -EFIAPI -XenHypercallHvmGetParam ( - UINT32 Index - ); - -/** - Hypercall to do different operation on the memory. - - @param Operation The operation number, e.g. XENMEM_add_to_physmap. - @param Arguments The arguments associated to the operation. - - @return Return the return value from the hypercall, 0 in case of success - otherwise, an error code. -**/ -INTN -EFIAPI -XenHypercallMemoryOp ( - IN UINTN Operation, - IN OUT VOID *Arguments - ); - -/** - Do an operation on the event channels. - - @param Operation The operation number, e.g. EVTCHNOP_send. - @param Arguments The argument associated to the operation. - - @return Return the return value from the hypercall, 0 in case of success - otherwise, an error code. -**/ -INTN -EFIAPI -XenHypercallEventChannelOp ( - IN INTN Operation, - IN OUT VOID *Arguments - ); - -#endif diff --git a/OvmfPkg/Include/Library/XenIoMmioLib.h b/OvmfPkg/Include/Library/XenIoMmioLib.h deleted file mode 100644 index 3986c72c57..0000000000 --- a/OvmfPkg/Include/Library/XenIoMmioLib.h +++ /dev/null @@ -1,64 +0,0 @@ -/** @file -* Manage XenBus device path and I/O handles -* -* Copyright (c) 2015, Linaro Ltd. 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. -* -**/ - -#ifndef _XENIO_MMIO_DEVICE_LIB_H_ -#define _XENIO_MMIO_DEVICE_LIB_H_ - -/** - - Install the XENBUS_ROOT_DEVICE_PATH and XENIO_PROTOCOL protocols on - the handle pointed to by @Handle, or on a new handle if it points to - NULL - - @param Handle Pointer to the handle to install the protocols - on, may point to a NULL handle. - - @param GrantTableAddress The address of the Xen grant table - - @retval EFI_SUCCESS Protocols were installed successfully - - @retval EFI_OUT_OF_RESOURCES The function failed to allocate memory required - by the XenIo MMIO and device path protocols - - @return Status code returned by the boot service - InstallMultipleProtocolInterfaces () - -**/ -EFI_STATUS -XenIoMmioInstall ( - IN OUT EFI_HANDLE *Handle, - IN EFI_PHYSICAL_ADDRESS GrantTableAddress - ); - - -/** - - Uninstall the XENBUS_ROOT_DEVICE_PATH and XENIO_PROTOCOL protocols - - @param Handle Handle onto which the protocols have been installed - earlier by XenIoMmioInstall () - - @retval EFI_SUCCESS Protocols were uninstalled successfully - - @return Status code returned by the boot service - UninstallMultipleProtocolInterfaces () - -**/ -EFI_STATUS -XenIoMmioUninstall ( - IN EFI_HANDLE Handle - ); - -#endif diff --git a/OvmfPkg/Include/OvmfPlatforms.h b/OvmfPkg/Include/OvmfPlatforms.h deleted file mode 100644 index cc67f40a88..0000000000 --- a/OvmfPkg/Include/OvmfPlatforms.h +++ /dev/null @@ -1,46 +0,0 @@ -/** @file - OVMF Platform definitions - - Copyright (C) 2015, Red Hat, Inc. - Copyright (c) 2014, Gabriel L. Somlo - - This program and the accompanying materials are licensed and made - 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 __OVMF_PLATFORMS_H__ -#define __OVMF_PLATFORMS_H__ - -#include -#include -#include -#include - -// -// OVMF Host Bridge DID Address -// -#define OVMF_HOSTBRIDGE_DID \ - PCI_LIB_ADDRESS (0, 0, 0, PCI_DEVICE_ID_OFFSET) - -// -// Values we program into the PM base address registers -// -#define PIIX4_PMBA_VALUE 0xB000 -#define ICH9_PMBASE_VALUE 0x0600 - -// -// Common bits in same-purpose registers -// -#define PMBA_RTE BIT0 - -// -// Common IO ports relative to the Power Management Base Address -// -#define ACPI_TIMER_OFFSET 0x8 - -#endif diff --git a/OvmfPkg/Include/Protocol/BlockMmio.h b/OvmfPkg/Include/Protocol/BlockMmio.h deleted file mode 100644 index 6edd23ca1f..0000000000 --- a/OvmfPkg/Include/Protocol/BlockMmio.h +++ /dev/null @@ -1,50 +0,0 @@ -/** @file - Block IO (memory mapped) - - Copyright (c) 2006 - 2010, Intel Corporation. All rights reserved.
- This program and the accompanying materials - are licensed and made available under the terms and conditions of the BSD License - which accompanies this distribution. The full text of the license may be found at - http://opensource.org/licenses/bsd-license.php - - THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, - WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. - -**/ - -#ifndef __BLOCK_MMIO_H__ -#define __BLOCK_MMIO_H__ - -#include - -#define BLOCK_MMIO_PROTOCOL_GUID \ - { \ - 0x6b558ce3, 0x69e5, 0x4c67, {0xa6, 0x34, 0xf7, 0xfe, 0x72, 0xad, 0xbe, 0x84 } \ - } - -typedef struct _BLOCK_MMIO_PROTOCOL BLOCK_MMIO_PROTOCOL; - - -/// -/// This protocol provides control over block devices. -/// -struct _BLOCK_MMIO_PROTOCOL { - /// - /// The revision to which the block IO interface adheres. All future - /// revisions must be backwards compatible. If a future version is not - /// back wards compatible, it is not the same GUID. - /// - UINT64 Revision; - /// - /// Pointer to the EFI_BLOCK_IO_MEDIA data for this device. - /// - EFI_BLOCK_IO_MEDIA *Media; - - EFI_PHYSICAL_ADDRESS BaseAddress; - -}; - -extern EFI_GUID gBlockMmioProtocolGuid; - -#endif - diff --git a/OvmfPkg/Include/Protocol/VirtioDevice.h b/OvmfPkg/Include/Protocol/VirtioDevice.h deleted file mode 100644 index 910a4866e7..0000000000 --- a/OvmfPkg/Include/Protocol/VirtioDevice.h +++ /dev/null @@ -1,360 +0,0 @@ -/** @file - Virtio Device - - DISCLAIMER: the VIRTIO_DEVICE_PROTOCOL introduced here is a work in progress, - and should not be used outside of the EDK II tree. - - Copyright (c) 2013, ARM Ltd. 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. - -**/ - -#ifndef __VIRTIO_DEVICE_H__ -#define __VIRTIO_DEVICE_H__ - -#include - -// VirtIo Specification Revision: Major[31:24].Minor[23:16].Revision[15:0 -#define VIRTIO_SPEC_REVISION(major,minor,revision) \ - ((((major) & 0xFF) << 24) | (((minor) & 0xFF) << 16) | ((revision) & 0xFFFF)) - -#define VIRTIO_DEVICE_PROTOCOL_GUID { \ - 0xfa920010, 0x6785, 0x4941, {0xb6, 0xec, 0x49, 0x8c, 0x57, 0x9f, 0x16, 0x0a }\ - } - -typedef struct _VIRTIO_DEVICE_PROTOCOL VIRTIO_DEVICE_PROTOCOL; - -/** - - Read a word from the device-specific I/O region of the Virtio Header. - - @param[in] This This instance of VIRTIO_DEVICE_PROTOCOL - - @param[in] FieldOffset Source offset. - - @param[in] FieldSize Source field size in bytes, must be in {1, 2, 4, 8}. - - @param[in] BufferSize Number of bytes available in the target buffer. Must - equal FieldSize. - - @param[out] Buffer Target buffer. - - @retval EFI_SUCCESS The data was read successfully. - @retval EFI_UNSUPPORTED The underlying IO device doesn't support the - provided address offset and read size. - @retval EFI_OUT_OF_RESOURCES The request could not be completed due to a - lack of resources. - @retval EFI_INVALID_PARAMETER One or more parameters are invalid. - -**/ -typedef -EFI_STATUS -(EFIAPI *VIRTIO_DEVICE_READ) ( - IN VIRTIO_DEVICE_PROTOCOL *This, - IN UINTN FieldOffset, - IN UINTN FieldSize, - IN UINTN BufferSize, - OUT VOID *Buffer - ); - -/** - - Write a word to the device-specific I/O region of the Virtio Header. - - @param[in] This This instance of VIRTIO_DEVICE_PROTOCOL - - @param[in] FieldOffset Destination offset. - - @param[in] FieldSize Destination field size in bytes, - must be in {1, 2, 4, 8}. - - @param[out] Value Value to write. - - @retval EFI_SUCCESS The data was written successfully. - @retval EFI_UNSUPPORTED The underlying IO device doesn't support the - provided address offset and write size. - @retval EFI_OUT_OF_RESOURCES The request could not be completed due to a - lack of resources. - @retval EFI_INVALID_PARAMETER One or more parameters are invalid. - -**/ -typedef -EFI_STATUS -(EFIAPI *VIRTIO_DEVICE_WRITE) ( - IN VIRTIO_DEVICE_PROTOCOL *This, - IN UINTN FieldOffset, - IN UINTN FieldSize, - IN UINT64 Value - ); - -/** - Read the device features field from the Virtio Header. - - @param[in] This This instance of VIRTIO_DEVICE_PROTOCOL - - @param[out] DeviceFeatures The device features field. - - @retval EFI_SUCCESS The data was read successfully. - @retval EFI_UNSUPPORTED The underlying IO device doesn't support the - provided address offset and read size. - @retval EFI_INVALID_PARAMETER DeviceFeatures is NULL -**/ -typedef -EFI_STATUS -(EFIAPI *VIRTIO_GET_DEVICE_FEATURES) ( - IN VIRTIO_DEVICE_PROTOCOL *This, - OUT UINT64 *DeviceFeatures - ); - -/** - Write the guest features field in the Virtio Header. - - @param[in] This This instance of VIRTIO_DEVICE_PROTOCOL - - @param[in] Features The guest features field - -**/ -typedef -EFI_STATUS -(EFIAPI *VIRTIO_SET_GUEST_FEATURES) ( - IN VIRTIO_DEVICE_PROTOCOL *This, - IN UINT64 Features - ); - -/** - Write the queue address field(s) in the Virtio Header. - - @param[in] This This instance of VIRTIO_DEVICE_PROTOCOL - - @param[in] Ring The initialized VRING object to take the - addresses from. - - @retval EFI_SUCCESS The data was written successfully. - @retval EFI_UNSUPPORTED The underlying IO device doesn't support the - provided address offset and write size. -**/ -typedef -EFI_STATUS -(EFIAPI *VIRTIO_SET_QUEUE_ADDRESS) ( - IN VIRTIO_DEVICE_PROTOCOL *This, - IN VRING *Ring - ); - -/** - - Write the queue select field in the Virtio Header. - - Writing to the queue select field sets the index of the queue to which - operations such as SetQueueAlign and GetQueueNumMax apply. - - @param[in] This This instance of VIRTIO_DEVICE_PROTOCOL - - @param[in] Index The index of the queue to select - - @retval EFI_SUCCESS The data was written successfully. - @retval EFI_UNSUPPORTED The underlying IO device doesn't support the - provided address offset and write size. -**/ -typedef -EFI_STATUS -(EFIAPI *VIRTIO_SET_QUEUE_SEL) ( - IN VIRTIO_DEVICE_PROTOCOL *This, - IN UINT16 Index - ); - -/** - - Write the queue notify field in the Virtio Header. - - @param[in] This This instance of VIRTIO_DEVICE_PROTOCOL - - @param[in] Address The 32-bit Queue Notify field - - @retval EFI_SUCCESS The data was written successfully. - @retval EFI_UNSUPPORTED The underlying IO device doesn't support the - provided address offset and write size. -**/ -typedef -EFI_STATUS -(EFIAPI *VIRTIO_SET_QUEUE_NOTIFY) ( - IN VIRTIO_DEVICE_PROTOCOL *This, - IN UINT16 Index - ); - -/** - Write the queue alignment field in the Virtio Header. - - The queue to which the alignment applies is selected by the Queue Select - field. - - Note: This operation is not implemented by the VirtIo over PCI. The PCI - implementation of this protocol returns EFI_SUCCESS. - - @param[in] This This instance of VIRTIO_DEVICE_PROTOCOL - - @param[in] Alignment The alignment boundary of the Used Ring in bytes. - Must be a power of 2. - - @retval EFI_SUCCESS The data was written successfully. - @retval EFI_UNSUPPORTED The underlying IO device doesn't support the - provided address offset and write size. -**/ -typedef -EFI_STATUS -(EFIAPI *VIRTIO_SET_QUEUE_ALIGN) ( - IN VIRTIO_DEVICE_PROTOCOL *This, - IN UINT32 Alignment - ); - -/** - Write the guest page size. - - Note: This operation is not implemented by the VirtIo over PCI. The PCI - implementation of this protocol returns EFI_SUCCESS. - - @param[in] This This instance of VIRTIO_DEVICE_PROTOCOL - - @param[in] PageSize Size of the Guest page in bytes. - Must be a power of 2. - - @retval EFI_SUCCESS The data was written successfully. - @retval EFI_UNSUPPORTED The underlying IO device doesn't support the - provided address offset and write size. -**/ -typedef -EFI_STATUS -(EFIAPI *VIRTIO_SET_PAGE_SIZE) ( - IN VIRTIO_DEVICE_PROTOCOL *This, - IN UINT32 PageSize - ); - -/** - - Get the size of the virtqueue selected by the queue select field. - - See Virtio spec Section 2.3 - - @param[in] This This instance of VIRTIO_DEVICE_PROTOCOL - - @param[out] QueueNumMax The size of the virtqueue in bytes. - Always a power of 2. - - @retval EFI_SUCCESS The data was read successfully. - @retval EFI_UNSUPPORTED The underlying IO device doesn't support the - provided address offset and read size. - @retval EFI_INVALID_PARAMETER QueueNumMax is NULL -**/ -typedef -EFI_STATUS -(EFIAPI *VIRTIO_GET_QUEUE_NUM_MAX) ( - IN VIRTIO_DEVICE_PROTOCOL *This, - OUT UINT16 *QueueNumMax - ); - -/** - - Write to the QueueNum field in the Virtio Header. - - This function only applies to Virtio-MMIO and may be a stub for other - implementations. See Virtio Spec appendix X. - - @param[in] This This instance of VIRTIO_DEVICE_PROTOCOL - - @param[in] QueueSize The number of elements in the queue. - - @retval EFI_SUCCESS The data was written successfully. - @retval EFI_UNSUPPORTED The underlying IO device doesn't support the - provided address offset and write size. -**/ -typedef -EFI_STATUS -(EFIAPI *VIRTIO_SET_QUEUE_NUM) ( - IN VIRTIO_DEVICE_PROTOCOL *This, - IN UINT16 QueueSize - ); - -/** - - Get the DeviceStatus field from the Virtio Header. - - @param[in] This This instance of VIRTIO_DEVICE_PROTOCOL - - @param[out] DeviceStatus The 8-bit value for the Device status field - - @retval EFI_SUCCESS The data was read successfully. - @retval EFI_UNSUPPORTED The underlying IO device doesn't support the - provided address offset and read size. - @retval EFI_INVALID_PARAMETER DeviceStatus is NULL -**/ -typedef -EFI_STATUS -(EFIAPI *VIRTIO_GET_DEVICE_STATUS) ( - IN VIRTIO_DEVICE_PROTOCOL *This, - OUT UINT8 *DeviceStatus - ); - -/** - - Write the DeviceStatus field in the Virtio Header. - - @param[in] This This instance of VIRTIO_DEVICE_PROTOCOL - - @param[in] DeviceStatus The 8-bit value for the Device status field - - @retval EFI_SUCCESS The data was written successfully. - @retval EFI_UNSUPPORTED The underlying IO device doesn't support the - provided address offset and write size. -**/ -typedef -EFI_STATUS -(EFIAPI *VIRTIO_SET_DEVICE_STATUS) ( - IN VIRTIO_DEVICE_PROTOCOL *This, - IN UINT8 DeviceStatus - ); - - -/// -/// This protocol provides an abstraction over the VirtIo transport layer -/// -/// DISCLAIMER: this protocol is a work in progress, and should not be used -/// outside of the EDK II tree. -/// -struct _VIRTIO_DEVICE_PROTOCOL { - /// VirtIo Specification Revision encoded with VIRTIO_SPEC_REVISION() - UINT32 Revision; - /// From the Virtio Spec - INT32 SubSystemDeviceId; - - VIRTIO_GET_DEVICE_FEATURES GetDeviceFeatures; - VIRTIO_SET_GUEST_FEATURES SetGuestFeatures; - - VIRTIO_SET_QUEUE_ADDRESS SetQueueAddress; - - VIRTIO_SET_QUEUE_SEL SetQueueSel; - - VIRTIO_SET_QUEUE_NOTIFY SetQueueNotify; - - VIRTIO_SET_QUEUE_ALIGN SetQueueAlign; - VIRTIO_SET_PAGE_SIZE SetPageSize; - - VIRTIO_GET_QUEUE_NUM_MAX GetQueueNumMax; - VIRTIO_SET_QUEUE_NUM SetQueueNum; - - VIRTIO_GET_DEVICE_STATUS GetDeviceStatus; - VIRTIO_SET_DEVICE_STATUS SetDeviceStatus; - - // Functions to read/write Device Specific headers - VIRTIO_DEVICE_WRITE WriteDevice; - VIRTIO_DEVICE_READ ReadDevice; -}; - -extern EFI_GUID gVirtioDeviceProtocolGuid; - -#endif diff --git a/OvmfPkg/Include/Protocol/XenBus.h b/OvmfPkg/Include/Protocol/XenBus.h deleted file mode 100644 index f5b1cbc44b..0000000000 --- a/OvmfPkg/Include/Protocol/XenBus.h +++ /dev/null @@ -1,416 +0,0 @@ - -/** @file - XenBus protocol to be used between the XenBus bus driver and Xen PV devices. - - DISCLAIMER: the XENBUS_PROTOCOL introduced here is a work in progress, and - should not be used outside of the EDK II tree. - - This protocol provide the necessary for a Xen PV driver frontend to - communicate with the bus driver, and perform several task to - initialize/shutdown a PV device and perform IO with a PV backend. - - Copyright (C) 2014, Citrix Ltd. - - This program and the accompanying materials - are licensed and made available under the terms and conditions of the BSD License - which accompanies this distribution. The full text of the license may be found at - http://opensource.org/licenses/bsd-license.php - - THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, - WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. - -**/ - -#ifndef __PROTOCOL_XENBUS_H__ -#define __PROTOCOL_XENBUS_H__ - -#define XENBUS_PROTOCOL_GUID \ - {0x3d3ca290, 0xb9a5, 0x11e3, {0xb7, 0x5d, 0xb8, 0xac, 0x6f, 0x7d, 0x65, 0xe6}} - -/// -/// Forward declaration -/// -typedef struct _XENBUS_PROTOCOL XENBUS_PROTOCOL; - -typedef enum xenbus_state XenBusState; - -typedef struct -{ - UINT32 Id; -} XENSTORE_TRANSACTION; - -#define XST_NIL ((XENSTORE_TRANSACTION *) NULL) - -typedef enum { - XENSTORE_STATUS_SUCCESS = 0, - XENSTORE_STATUS_FAIL, - XENSTORE_STATUS_EINVAL, - XENSTORE_STATUS_EACCES, - XENSTORE_STATUS_EEXIST, - XENSTORE_STATUS_EISDIR, - XENSTORE_STATUS_ENOENT, - XENSTORE_STATUS_ENOMEM, - XENSTORE_STATUS_ENOSPC, - XENSTORE_STATUS_EIO, - XENSTORE_STATUS_ENOTEMPTY, - XENSTORE_STATUS_ENOSYS, - XENSTORE_STATUS_EROFS, - XENSTORE_STATUS_EBUSY, - XENSTORE_STATUS_EAGAIN, - XENSTORE_STATUS_EISCONN, - XENSTORE_STATUS_E2BIG -} XENSTORE_STATUS; - - -#include -#include - -/// -/// Function prototypes -/// - -/** - Get the contents of the node Node of the PV device. Returns the contents in - *Result which should be freed after use. - - @param This A pointer to XENBUS_PROTOCOL instance. - @param Transaction The XenStore transaction covering this request. - @param Node The basename of the file to read. - @param Result The returned contents from this file. - - @return On success, XENSTORE_STATUS_SUCCESS. Otherwise an errno value - indicating the type of failure. - - @note The results buffer is malloced and should be free'd by the - caller. -**/ -typedef -XENSTORE_STATUS -(EFIAPI *XENBUS_XS_READ)( - IN XENBUS_PROTOCOL *This, - IN CONST XENSTORE_TRANSACTION *Transaction, - IN CONST CHAR8 *Node, - OUT VOID **Result - ); - -/** - Get the contents of the node Node of the PV device's backend. Returns the - contents in *Result which should be freed after use. - - @param This A pointer to XENBUS_PROTOCOL instance. - @param Transaction The XenStore transaction covering this request. - @param Node The basename of the file to read. - @param Result The returned contents from this file. - - @return On success, XENSTORE_STATUS_SUCCESS. Otherwise an errno value - indicating the type of failure. - - @note The results buffer is malloced and should be free'd by the - caller. -**/ -typedef -XENSTORE_STATUS -(EFIAPI *XENBUS_XS_BACKEND_READ)( - IN XENBUS_PROTOCOL *This, - IN CONST XENSTORE_TRANSACTION *Transaction, - IN CONST CHAR8 *Node, - OUT VOID **Result - ); - -/** - Print formatted write to a XenStore node. - - @param This A pointer to XENBUS_PROTOCOL instance. - @param Transaction The XenStore transaction covering this request. - @param Directory The dirname of the path to read. - @param Node The basename of the path to read. - @param Format AsciiSPrint format string followed by a variable number - of arguments. - - @return On success, XENSTORE_STATUS_SUCCESS. Otherwise an errno value - indicating the type of write failure. -**/ -typedef -XENSTORE_STATUS -(EFIAPI *XENBUS_XS_PRINTF) ( - IN XENBUS_PROTOCOL *This, - IN CONST XENSTORE_TRANSACTION *Transaction, - IN CONST CHAR8 *Directory, - IN CONST CHAR8 *Node, - IN CONST CHAR8 *Format, - ... - ); - -/** - Remove a node or directory (directories must be empty) of the PV driver's - subdirectory. - - @param This A pointer to XENBUS_PROTOCOL instance. - @param Transaction The XenStore transaction covering this request. - @param Node The basename of the node to remove. - - @return On success, XENSTORE_STATUS_SUCCESS. Otherwise an errno value - indicating the type of failure. -**/ -typedef -XENSTORE_STATUS -(EFIAPI *XENBUS_XS_REMOVE) ( - IN XENBUS_PROTOCOL *This, - IN CONST XENSTORE_TRANSACTION *Transaction, - IN CONST CHAR8 *Node - ); - -/** - Start a transaction. - - Changes by others will not be seen during the lifetime of this - transaction, and changes will not be visible to others until it - is committed (XsTransactionEnd). - - @param This A pointer to XENBUS_PROTOCOL instance. - @param Transaction The returned transaction. - - @return On success, XENSTORE_STATUS_SUCCESS. Otherwise an errno value - indicating the type of failure. -**/ -typedef -XENSTORE_STATUS -(EFIAPI *XENBUS_XS_TRANSACTION_START)( - IN XENBUS_PROTOCOL *This, - OUT XENSTORE_TRANSACTION *Transaction - ); - -/** - End a transaction. - - @param This A pointer to XENBUS_PROTOCOL instance. - @param Transaction The transaction to end/commit. - @param Abort If TRUE, the transaction is discarded - instead of committed. - - @return On success, XENSTORE_STATUS_SUCCESS. Otherwise an errno value - indicating the type of failure. -**/ -typedef -XENSTORE_STATUS -(EFIAPI *XENBUS_XS_TRANSACTION_END) ( - IN XENBUS_PROTOCOL *This, - IN CONST XENSTORE_TRANSACTION *Transaction, - IN BOOLEAN Abort - ); - -/** - Set a new state for the frontend of the PV driver. - - @param This A pointer to XENBUS_PROTOCOL instance. - @param Transaction The transaction to end/commit. - @param State The new state to apply. - - @return On success, XENSTORE_STATUS_SUCCESS. Otherwise an errno value - indicating the type of failure. -**/ -typedef -XENSTORE_STATUS -(EFIAPI *XENBUS_SET_STATE)( - IN XENBUS_PROTOCOL *This, - IN CONST XENSTORE_TRANSACTION *Transaction, - IN XenBusState State - ); - -/** - Grant access to the page Frame to the domain DomainId. - - @param This A pointer to XENBUS_PROTOCOL instance. - @param DomainId ID of the domain to grant acces to. - @param Frame Frame Number of the page to grant access to. - @param ReadOnly Provide read-only or read-write access. - @param RefPtr Reference number of the grant will be written to this pointer. -**/ -typedef -EFI_STATUS -(EFIAPI *XENBUS_GRANT_ACCESS)( - IN XENBUS_PROTOCOL *This, - IN domid_t DomainId, - IN UINTN Frame, - IN BOOLEAN ReadOnly, - OUT grant_ref_t *refp - ); - -/** - End access to grant Ref, previously return by XenBusGrantAccess. - - @param This A pointer to XENBUS_PROTOCOL instance. - @param Ref Reference numeber of a grant previously returned by - XenBusGrantAccess. -**/ -typedef -EFI_STATUS -(EFIAPI *XENBUS_GRANT_END_ACCESS)( - IN XENBUS_PROTOCOL *This, - IN grant_ref_t Ref - ); - -/** - Allocate a port that can be bind from domain DomainId. - - @param This A pointer to the XENBUS_PROTOCOL. - @param DomainId The domain ID that can bind the newly allocated port. - @param Port A pointer to a evtchn_port_t that will contain the newly - allocated port. - - @retval UINT32 The return value from the hypercall, 0 if success. -**/ -typedef -UINT32 -(EFIAPI *XENBUS_EVENT_CHANNEL_ALLOCATE) ( - IN XENBUS_PROTOCOL *This, - IN domid_t DomainId, - OUT evtchn_port_t *Port - ); - -/** - Send an event to the remote end of the channel whose local endpoint is Port. - - @param This A pointer to the XENBUS_PROTOCOL. - @param Port Local port to the the event from. - - @retval UINT32 The return value from the hypercall, 0 if success. -**/ -typedef -UINT32 -(EFIAPI *XENBUS_EVENT_CHANNEL_NOTIFY) ( - IN XENBUS_PROTOCOL *This, - IN evtchn_port_t Port - ); - -/** - Close a local event channel Port. - - @param This A pointer to the XENBUS_PROTOCOL. - @param Port The event channel to close. - - @retval UINT32 The return value from the hypercall, 0 if success. -**/ -typedef -UINT32 -(EFIAPI *XENBUS_EVENT_CHANNEL_CLOSE) ( - IN XENBUS_PROTOCOL *This, - IN evtchn_port_t Port - ); - -/** - Register a XenStore watch. - - XenStore watches allow a client to wait for changes to an object in the - XenStore. - - @param This A pointer to the XENBUS_PROTOCOL. - @param Node The basename of the path to watch. - @param Token A token. - - @return On success, XENSTORE_STATUS_SUCCESS. Otherwise an errno value - indicating the type of write failure. EEXIST errors from the - XenStore are suppressed, allowing multiple, physically different, - xenbus_watch objects, to watch the same path in the XenStore. -**/ -typedef -XENSTORE_STATUS -(EFIAPI *XENBUS_REGISTER_WATCH) ( - IN XENBUS_PROTOCOL *This, - IN CONST CHAR8 *Node, - OUT VOID **Token - ); - -/** - Register a XenStore watch on a backend's node. - - XenStore watches allow a client to wait for changes to an object in the - XenStore. - - @param This A pointer to the XENBUS_PROTOCOL. - @param Node The basename of the path to watch. - @param Token A token. - - @return On success, XENSTORE_STATUS_SUCCESS. Otherwise an errno value - indicating the type of write failure. EEXIST errors from the - XenStore are suppressed, allowing multiple, physically different, - xenbus_watch objects, to watch the same path in the XenStore. -**/ -typedef -XENSTORE_STATUS -(EFIAPI *XENBUS_REGISTER_WATCH_BACKEND) ( - IN XENBUS_PROTOCOL *This, - IN CONST CHAR8 *Node, - OUT VOID **Token - ); - -/** - Unregister a XenStore watch. - - @param This A pointer to the XENBUS_PROTOCOL. - @param Token An token previously returned by a successful - call to RegisterWatch (). -**/ -typedef -VOID -(EFIAPI *XENBUS_UNREGISTER_WATCH) ( - IN XENBUS_PROTOCOL *This, - IN VOID *Token - ); - -/** - Block until the node watch by Token change. - - @param This A pointer to the XENBUS_PROTOCOL. - @param Token An token previously returned by a successful - call to RegisterWatch or RegisterWatchBackend. - - @return On success, XENSTORE_STATUS_SUCCESS. Otherwise an errno value - indicating the type of failure. -**/ -typedef -XENSTORE_STATUS -(EFIAPI *XENBUS_WAIT_FOR_WATCH) ( - IN XENBUS_PROTOCOL *This, - IN VOID *Token - ); - - -/// -/// Protocol structure -/// -/// DISCLAIMER: the XENBUS_PROTOCOL introduced here is a work in progress, and -/// should not be used outside of the EDK II tree. -/// -struct _XENBUS_PROTOCOL { - XENBUS_XS_READ XsRead; - XENBUS_XS_BACKEND_READ XsBackendRead; - XENBUS_XS_PRINTF XsPrintf; - XENBUS_XS_REMOVE XsRemove; - XENBUS_XS_TRANSACTION_START XsTransactionStart; - XENBUS_XS_TRANSACTION_END XsTransactionEnd; - XENBUS_SET_STATE SetState; - - XENBUS_GRANT_ACCESS GrantAccess; - XENBUS_GRANT_END_ACCESS GrantEndAccess; - - XENBUS_EVENT_CHANNEL_ALLOCATE EventChannelAllocate; - XENBUS_EVENT_CHANNEL_NOTIFY EventChannelNotify; - XENBUS_EVENT_CHANNEL_CLOSE EventChannelClose; - - XENBUS_REGISTER_WATCH RegisterWatch; - XENBUS_REGISTER_WATCH_BACKEND RegisterWatchBackend; - XENBUS_UNREGISTER_WATCH UnregisterWatch; - XENBUS_WAIT_FOR_WATCH WaitForWatch; - // - // Protocol data fields - // - CONST CHAR8 *Type; - UINT16 DeviceId; - CONST CHAR8 *Node; - CONST CHAR8 *Backend; -}; - -extern EFI_GUID gXenBusProtocolGuid; - -#endif diff --git a/OvmfPkg/Include/Protocol/XenIo.h b/OvmfPkg/Include/Protocol/XenIo.h deleted file mode 100644 index 510391f3b3..0000000000 --- a/OvmfPkg/Include/Protocol/XenIo.h +++ /dev/null @@ -1,48 +0,0 @@ -/** @file - XenIo protocol to abstract arch specific details - - The Xen implementations for the Intel and ARM archictures differ in the way - the base address of the grant table is communicated to the guest. The former - uses a virtual PCI device, while the latter uses a device tree node. - In order to allow the XenBusDxe UEFI driver to be reused for the non-PCI - Xen implementation, this abstract protocol can be installed on a handle - with the appropriate base address. - - Copyright (C) 2014, Linaro Ltd. - - This program and the accompanying materials - are licensed and made available under the terms and conditions of the BSD License - which accompanies this distribution. The full text of the license may be found at - http://opensource.org/licenses/bsd-license.php - - THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, - WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. - -**/ - -#ifndef __PROTOCOL_XENIO_H__ -#define __PROTOCOL_XENIO_H__ - -#include - -#define XENIO_PROTOCOL_GUID \ - {0x6efac84f, 0x0ab0, 0x4747, {0x81, 0xbe, 0x85, 0x55, 0x62, 0x59, 0x04, 0x49}} - -/// -/// Forward declaration -/// -typedef struct _XENIO_PROTOCOL XENIO_PROTOCOL; - -/// -/// Protocol structure -/// -struct _XENIO_PROTOCOL { - // - // Protocol data fields - // - EFI_PHYSICAL_ADDRESS GrantTableAddress; -}; - -extern EFI_GUID gXenIoProtocolGuid; - -#endif diff --git a/OvmfPkg/Include/Register/QemuSmramSaveStateMap.h b/OvmfPkg/Include/Register/QemuSmramSaveStateMap.h deleted file mode 100644 index 389428da11..0000000000 --- a/OvmfPkg/Include/Register/QemuSmramSaveStateMap.h +++ /dev/null @@ -1,184 +0,0 @@ -/** @file -SMRAM Save State Map Definitions. - -SMRAM Save State Map definitions based on contents of the -Intel(R) 64 and IA-32 Architectures Software Developer's Manual - Volume 3C, Section 34.4 SMRAM - Volume 3C, Section 34.5 SMI Handler Execution Environment - Volume 3C, Section 34.7 Managing Synchronous and Asynchronous SMIs - -and the AMD64 Architecture Programmer's Manual - Volume 2, Section 10.2 SMM Resources - -Copyright (c) 2015, Intel Corporation. All rights reserved.
-Copyright (c) 2015, 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 __QEMU_SMRAM_SAVE_STATE_MAP_H__ -#define __QEMU_SMRAM_SAVE_STATE_MAP_H__ - -#pragma pack (1) - -/// -/// 32-bit SMRAM Save State Map -/// -typedef struct { - UINT8 Reserved0[0x200]; // 7c00h - UINT8 Reserved1[0xf8]; // 7e00h - UINT32 SMBASE; // 7ef8h - UINT32 SMMRevId; // 7efch - UINT16 IORestart; // 7f00h - UINT16 AutoHALTRestart; // 7f02h - UINT8 Reserved2[0x9C]; // 7f08h - UINT32 IOMemAddr; // 7fa0h - UINT32 IOMisc; // 7fa4h - UINT32 _ES; // 7fa8h - UINT32 _CS; // 7fach - UINT32 _SS; // 7fb0h - UINT32 _DS; // 7fb4h - UINT32 _FS; // 7fb8h - UINT32 _GS; // 7fbch - UINT32 Reserved3; // 7fc0h - UINT32 _TR; // 7fc4h - UINT32 _DR7; // 7fc8h - UINT32 _DR6; // 7fcch - UINT32 _EAX; // 7fd0h - UINT32 _ECX; // 7fd4h - UINT32 _EDX; // 7fd8h - UINT32 _EBX; // 7fdch - UINT32 _ESP; // 7fe0h - UINT32 _EBP; // 7fe4h - UINT32 _ESI; // 7fe8h - UINT32 _EDI; // 7fech - UINT32 _EIP; // 7ff0h - UINT32 _EFLAGS; // 7ff4h - UINT32 _CR3; // 7ff8h - UINT32 _CR0; // 7ffch -} QEMU_SMRAM_SAVE_STATE_MAP32; - -/// -/// 64-bit SMRAM Save State Map -/// -typedef struct { - UINT8 Reserved0[0x200]; // 7c00h - - UINT16 _ES; // 7e00h - UINT16 _ESAccessRights; // 7e02h - UINT32 _ESLimit; // 7e04h - UINT64 _ESBase; // 7e08h - - UINT16 _CS; // 7e10h - UINT16 _CSAccessRights; // 7e12h - UINT32 _CSLimit; // 7e14h - UINT64 _CSBase; // 7e18h - - UINT16 _SS; // 7e20h - UINT16 _SSAccessRights; // 7e22h - UINT32 _SSLimit; // 7e24h - UINT64 _SSBase; // 7e28h - - UINT16 _DS; // 7e30h - UINT16 _DSAccessRights; // 7e32h - UINT32 _DSLimit; // 7e34h - UINT64 _DSBase; // 7e38h - - UINT16 _FS; // 7e40h - UINT16 _FSAccessRights; // 7e42h - UINT32 _FSLimit; // 7e44h - UINT64 _FSBase; // 7e48h - - UINT16 _GS; // 7e50h - UINT16 _GSAccessRights; // 7e52h - UINT32 _GSLimit; // 7e54h - UINT64 _GSBase; // 7e58h - - UINT32 _GDTRReserved1; // 7e60h - UINT16 _GDTRLimit; // 7e64h - UINT16 _GDTRReserved2; // 7e66h - UINT64 _GDTRBase; // 7e68h - - UINT16 _LDTR; // 7e70h - UINT16 _LDTRAccessRights; // 7e72h - UINT32 _LDTRLimit; // 7e74h - UINT64 _LDTRBase; // 7e78h - - UINT32 _IDTRReserved1; // 7e80h - UINT16 _IDTRLimit; // 7e84h - UINT16 _IDTRReserved2; // 7e86h - UINT64 _IDTRBase; // 7e88h - - UINT16 _TR; // 7e90h - UINT16 _TRAccessRights; // 7e92h - UINT32 _TRLimit; // 7e94h - UINT64 _TRBase; // 7e98h - - UINT64 IO_RIP; // 7ea0h - UINT64 IO_RCX; // 7ea8h - UINT64 IO_RSI; // 7eb0h - UINT64 IO_RDI; // 7eb8h - UINT32 IO_DWord; // 7ec0h - UINT8 Reserved1[0x04]; // 7ec4h - UINT8 IORestart; // 7ec8h - UINT8 AutoHALTRestart; // 7ec9h - UINT8 Reserved2[0x06]; // 7ecah - - UINT64 IA32_EFER; // 7ed0h - UINT64 SVM_Guest; // 7ed8h - UINT64 SVM_GuestVMCB; // 7ee0h - UINT64 SVM_GuestVIntr; // 7ee8h - UINT8 Reserved3[0x0c]; // 7ef0h - - UINT32 SMMRevId; // 7efch - UINT32 SMBASE; // 7f00h - - UINT8 Reserved4[0x1c]; // 7f04h - UINT64 SVM_GuestPAT; // 7f20h - UINT64 SVM_HostIA32_EFER; // 7f28h - UINT64 SVM_HostCR4; // 7f30h - UINT64 SVM_HostCR3; // 7f38h - UINT64 SVM_HostCR0; // 7f40h - - UINT64 _CR4; // 7f48h - UINT64 _CR3; // 7f50h - UINT64 _CR0; // 7f58h - UINT64 _DR7; // 7f60h - UINT64 _DR6; // 7f68h - UINT64 _RFLAGS; // 7f70h - UINT64 _RIP; // 7f78h - UINT64 _R15; // 7f80h - UINT64 _R14; // 7f88h - UINT64 _R13; // 7f90h - UINT64 _R12; // 7f98h - UINT64 _R11; // 7fa0h - UINT64 _R10; // 7fa8h - UINT64 _R9; // 7fb0h - UINT64 _R8; // 7fb8h - UINT64 _RDI; // 7fc0h - UINT64 _RSI; // 7fc8h - UINT64 _RBP; // 7fd0h - UINT64 _RSP; // 7fd8h - UINT64 _RBX; // 7fe0h - UINT64 _RDX; // 7fe8h - UINT64 _RCX; // 7ff0h - UINT64 _RAX; // 7ff8h -} QEMU_SMRAM_SAVE_STATE_MAP64; - -/// -/// Union of 32-bit and 64-bit SMRAM Save State Maps -/// -typedef union { - QEMU_SMRAM_SAVE_STATE_MAP32 x86; - QEMU_SMRAM_SAVE_STATE_MAP64 x64; -} QEMU_SMRAM_SAVE_STATE_MAP; - -#pragma pack () - -#endif diff --git a/OvmfPkg/IncompatiblePciDeviceSupportDxe/IncompatiblePciDeviceSupport.c b/OvmfPkg/IncompatiblePciDeviceSupportDxe/IncompatiblePciDeviceSupport.c deleted file mode 100644 index eff89978ee..0000000000 --- a/OvmfPkg/IncompatiblePciDeviceSupportDxe/IncompatiblePciDeviceSupport.c +++ /dev/null @@ -1,354 +0,0 @@ -/** @file - A simple DXE_DRIVER that causes the PCI Bus UEFI_DRIVER to allocate 64-bit - MMIO BARs above 4 GB, regardless of option ROM availability (as long as a CSM - is not present), conserving 32-bit MMIO aperture for 32-bit BARs. - - Copyright (C) 2016, Red Hat, Inc. - Copyright (c) 2017, Intel Corporation. All rights reserved.
- - This program and the accompanying materials are licensed and made available - under the terms and conditions of the BSD License which accompanies this - distribution. The full text of the license may be found at - http://opensource.org/licenses/bsd-license.php - - THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, WITHOUT - WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. -**/ - -#include -#include - -#include -#include -#include -#include - -#include -#include - -// -// The Legacy BIOS protocol has been located. -// -STATIC BOOLEAN mLegacyBiosInstalled; - -// -// The protocol interface this driver produces. -// -STATIC EFI_INCOMPATIBLE_PCI_DEVICE_SUPPORT_PROTOCOL - mIncompatiblePciDeviceSupport; - -// -// Configuration template for the CheckDevice() protocol member function. -// -// Refer to Table 20 "ACPI 2.0 & 3.0 QWORD Address Space Descriptor Usage" in -// the Platform Init 1.4a Spec, Volume 5. -// -// This structure is interpreted by the UpdatePciInfo() function in the edk2 -// PCI Bus UEFI_DRIVER. -// -#pragma pack (1) -typedef struct { - EFI_ACPI_ADDRESS_SPACE_DESCRIPTOR AddressSpaceDesc; - EFI_ACPI_END_TAG_DESCRIPTOR EndDesc; -} MMIO64_PREFERENCE; -#pragma pack () - -STATIC CONST MMIO64_PREFERENCE mConfiguration = { - // - // AddressSpaceDesc - // - { - ACPI_ADDRESS_SPACE_DESCRIPTOR, // Desc - (UINT16)( // Len - sizeof (EFI_ACPI_ADDRESS_SPACE_DESCRIPTOR) - - OFFSET_OF ( - EFI_ACPI_ADDRESS_SPACE_DESCRIPTOR, - ResType - ) - ), - ACPI_ADDRESS_SPACE_TYPE_MEM, // ResType - 0, // GenFlag - 0, // SpecificFlag - 64, // AddrSpaceGranularity: - // aperture selection hint - // for BAR allocation - 0, // AddrRangeMin - 0, // AddrRangeMax: - // no special alignment - // for affected BARs - MAX_UINT64, // AddrTranslationOffset: - // hint covers all - // eligible BARs - 0 // AddrLen: - // use probed BAR size - }, - // - // EndDesc - // - { - ACPI_END_TAG_DESCRIPTOR, // Desc - 0 // Checksum: to be ignored - } -}; - -// -// The CheckDevice() member function has been called. -// -STATIC BOOLEAN mCheckDeviceCalled; - - -/** - Notification callback for Legacy BIOS protocol installation. - - @param[in] Event Event whose notification function is being invoked. - - @param[in] Context The pointer to the notification function's context, which - is implementation-dependent. -**/ -STATIC -VOID -EFIAPI -LegacyBiosInstalled ( - IN EFI_EVENT Event, - IN VOID *Context - ) -{ - EFI_STATUS Status; - EFI_LEGACY_BIOS_PROTOCOL *LegacyBios; - - ASSERT (!mCheckDeviceCalled); - - Status = gBS->LocateProtocol (&gEfiLegacyBiosProtocolGuid, - NULL /* Registration */, (VOID **)&LegacyBios); - if (EFI_ERROR (Status)) { - return; - } - - mLegacyBiosInstalled = TRUE; - - // - // Close the event and deregister this callback. - // - Status = gBS->CloseEvent (Event); - ASSERT_EFI_ERROR (Status); -} - - -/** - Returns a list of ACPI resource descriptors that detail the special resource - configuration requirements for an incompatible PCI device. - - Prior to bus enumeration, the PCI bus driver will look for the presence of - the EFI_INCOMPATIBLE_PCI_DEVICE_SUPPORT_PROTOCOL. Only one instance of this - protocol can be present in the system. For each PCI device that the PCI bus - driver discovers, the PCI bus driver calls this function with the device's - vendor ID, device ID, revision ID, subsystem vendor ID, and subsystem device - ID. If the VendorId, DeviceId, RevisionId, SubsystemVendorId, or - SubsystemDeviceId value is set to (UINTN)-1, that field will be ignored. The - ID values that are not (UINTN)-1 will be used to identify the current device. - - This function will only return EFI_SUCCESS. However, if the device is an - incompatible PCI device, a list of ACPI resource descriptors will be returned - in Configuration. Otherwise, NULL will be returned in Configuration instead. - The PCI bus driver does not need to allocate memory for Configuration. - However, it is the PCI bus driver's responsibility to free it. The PCI bus - driver then can configure this device with the information that is derived - from this list of resource nodes, rather than the result of BAR probing. - - Only the following two resource descriptor types from the ACPI Specification - may be used to describe the incompatible PCI device resource requirements: - - QWORD Address Space Descriptor (ACPI 2.0, section 6.4.3.5.1; also ACPI 3.0) - - End Tag (ACPI 2.0, section 6.4.2.8; also ACPI 3.0) - - The QWORD Address Space Descriptor can describe memory, I/O, and bus number - ranges for dynamic or fixed resources. The configuration of a PCI root bridge - is described with one or more QWORD Address Space Descriptors, followed by an - End Tag. See the ACPI Specification for details on the field values. - - @param[in] This Pointer to the - EFI_INCOMPATIBLE_PCI_DEVICE_SUPPORT_PROTOCOL - instance. - - @param[in] VendorId A unique ID to identify the manufacturer of - the PCI device. See the Conventional PCI - Specification 3.0 for details. - - @param[in] DeviceId A unique ID to identify the particular PCI - device. See the Conventional PCI - Specification 3.0 for details. - - @param[in] RevisionId A PCI device-specific revision identifier. - See the Conventional PCI Specification 3.0 - for details. - - @param[in] SubsystemVendorId Specifies the subsystem vendor ID. See the - Conventional PCI Specification 3.0 for - details. - - @param[in] SubsystemDeviceId Specifies the subsystem device ID. See the - Conventional PCI Specification 3.0 for - details. - - @param[out] Configuration A list of ACPI resource descriptors that - detail the configuration requirement. - - @retval EFI_SUCCESS The function always returns EFI_SUCCESS. -**/ -STATIC -EFI_STATUS -EFIAPI -CheckDevice ( - IN EFI_INCOMPATIBLE_PCI_DEVICE_SUPPORT_PROTOCOL *This, - IN UINTN VendorId, - IN UINTN DeviceId, - IN UINTN RevisionId, - IN UINTN SubsystemVendorId, - IN UINTN SubsystemDeviceId, - OUT VOID **Configuration - ) -{ - mCheckDeviceCalled = TRUE; - - // - // Unlike the general description of this protocol member suggests, there is - // nothing incompatible about the PCI devices that we'll match here. We'll - // match all PCI devices, and generate exactly one QWORD Address Space - // Descriptor for each. That descriptor will instruct the PCI Bus UEFI_DRIVER - // not to degrade 64-bit MMIO BARs for the device, even if a PCI option ROM - // BAR is present on the device. - // - // The concern captured in the PCI Bus UEFI_DRIVER is that a legacy BIOS boot - // (via a CSM) could dispatch a legacy option ROM on the device, which might - // have trouble with MMIO BARs that have been allocated outside of the 32-bit - // address space. But, if we don't support legacy option ROMs at all, then - // this problem cannot arise. - // - if (mLegacyBiosInstalled) { - // - // Don't interfere with resource degradation. - // - *Configuration = NULL; - return EFI_SUCCESS; - } - - // - // This member function is mis-specified actually: it is supposed to allocate - // memory, but as specified, it could not return an error status. Thankfully, - // the edk2 PCI Bus UEFI_DRIVER actually handles error codes; see the - // UpdatePciInfo() function. - // - *Configuration = AllocateCopyPool (sizeof mConfiguration, &mConfiguration); - if (*Configuration == NULL) { - DEBUG ((EFI_D_WARN, - "%a: 64-bit MMIO BARs may be degraded for PCI 0x%04x:0x%04x (rev %d)\n", - __FUNCTION__, (UINT32)VendorId, (UINT32)DeviceId, (UINT8)RevisionId)); - return EFI_OUT_OF_RESOURCES; - } - return EFI_SUCCESS; -} - - -/** - Entry point for this driver. - - @param[in] ImageHandle Image handle of this driver. - @param[in] SystemTable Pointer to SystemTable. - - @retval EFI_SUCESS Driver has loaded successfully. - @retval EFI_UNSUPPORTED PCI resource allocation has been disabled. - @retval EFI_UNSUPPORTED There is no 64-bit PCI MMIO aperture. - @return Error codes from lower level functions. - -**/ -EFI_STATUS -EFIAPI -DriverInitialize ( - IN EFI_HANDLE ImageHandle, - IN EFI_SYSTEM_TABLE *SystemTable - ) -{ - EFI_STATUS Status; - EFI_EVENT Event; - VOID *Registration; - - // - // If the PCI Bus driver is not supposed to allocate resources, then it makes - // no sense to install a protocol that influences the resource allocation. - // - // Similarly, if there is no 64-bit PCI MMIO aperture, then 64-bit MMIO BARs - // have to be allocated under 4 GB unconditionally. - // - if (PcdGetBool (PcdPciDisableBusEnumeration) || - PcdGet64 (PcdPciMmio64Size) == 0) { - return EFI_UNSUPPORTED; - } - - // - // Otherwise, create a protocol notify to see if a CSM is present. (With the - // CSM absent, the PCI Bus driver won't have to worry about allocating 64-bit - // MMIO BARs in the 32-bit MMIO aperture, for the sake of a legacy BIOS.) - // - // If the Legacy BIOS Protocol is present at the time of this driver starting - // up, we can mark immediately that the PCI Bus driver should perform the - // usual 64-bit MMIO BAR degradation. - // - // Otherwise, if the Legacy BIOS Protocol is absent at startup, it may be - // installed later. However, if it doesn't show up until the first - // EFI_INCOMPATIBLE_PCI_DEVICE_SUPPORT_PROTOCOL.CheckDevice() call from the - // PCI Bus driver, then it never will: - // - // 1. The following drivers are dispatched in some unspecified order: - // - PCI Host Bridge DXE_DRIVER, - // - PCI Bus UEFI_DRIVER, - // - this DXE_DRIVER, - // - Legacy BIOS DXE_DRIVER. - // - // 2. The DXE_CORE enters BDS. - // - // 3. The platform BDS connects the PCI Root Bridge IO instances (produced by - // the PCI Host Bridge DXE_DRIVER). - // - // 4. The PCI Bus UEFI_DRIVER enumerates resources and calls into this - // DXE_DRIVER (CheckDevice()). - // - // 5. This driver remembers if EFI_LEGACY_BIOS_PROTOCOL has been installed - // sometime during step 1 (produced by the Legacy BIOS DXE_DRIVER). - // - // For breaking this order, the Legacy BIOS DXE_DRIVER would have to install - // its protocol after the firmware enters BDS, which cannot happen. - // - Status = gBS->CreateEvent (EVT_NOTIFY_SIGNAL, TPL_CALLBACK, - LegacyBiosInstalled, NULL /* Context */, &Event); - if (EFI_ERROR (Status)) { - return Status; - } - - Status = gBS->RegisterProtocolNotify (&gEfiLegacyBiosProtocolGuid, Event, - &Registration); - if (EFI_ERROR (Status)) { - goto CloseEvent; - } - - Status = gBS->SignalEvent (Event); - ASSERT_EFI_ERROR (Status); - - mIncompatiblePciDeviceSupport.CheckDevice = CheckDevice; - Status = gBS->InstallMultipleProtocolInterfaces (&ImageHandle, - &gEfiIncompatiblePciDeviceSupportProtocolGuid, - &mIncompatiblePciDeviceSupport, NULL); - if (EFI_ERROR (Status)) { - goto CloseEvent; - } - - return EFI_SUCCESS; - -CloseEvent: - if (!mLegacyBiosInstalled) { - EFI_STATUS CloseStatus; - - CloseStatus = gBS->CloseEvent (Event); - ASSERT_EFI_ERROR (CloseStatus); - } - - return Status; -} diff --git a/OvmfPkg/IncompatiblePciDeviceSupportDxe/IncompatiblePciDeviceSupport.inf b/OvmfPkg/IncompatiblePciDeviceSupportDxe/IncompatiblePciDeviceSupport.inf deleted file mode 100644 index 883e45c174..0000000000 --- a/OvmfPkg/IncompatiblePciDeviceSupportDxe/IncompatiblePciDeviceSupport.inf +++ /dev/null @@ -1,50 +0,0 @@ -## @file -# A simple DXE_DRIVER that causes the PCI Bus UEFI_DRIVER to allocate 64-bit -# MMIO BARs above 4 GB, regardless of option ROM availability (as long as a CSM -# is not present), conserving 32-bit MMIO aperture for 32-bit BARs. -# -# Copyright (C) 2016, 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 = IncompatiblePciDeviceSupportDxe - FILE_GUID = F6697AC4-A776-4EE1-B643-1FEFF2B615BB - MODULE_TYPE = DXE_DRIVER - VERSION_STRING = 1.0 - ENTRY_POINT = DriverInitialize - -[Sources] - IncompatiblePciDeviceSupport.c - -[Packages] - IntelFrameworkPkg/IntelFrameworkPkg.dec - MdeModulePkg/MdeModulePkg.dec - MdePkg/MdePkg.dec - OvmfPkg/OvmfPkg.dec - -[LibraryClasses] - DebugLib - MemoryAllocationLib - PcdLib - UefiBootServicesTableLib - UefiDriverEntryPoint - -[Protocols] - gEfiIncompatiblePciDeviceSupportProtocolGuid ## SOMETIMES_PRODUCES - gEfiLegacyBiosProtocolGuid ## NOTIFY - -[Pcd] - gEfiMdeModulePkgTokenSpaceGuid.PcdPciDisableBusEnumeration ## CONSUMES - gUefiOvmfPkgTokenSpaceGuid.PcdPciMmio64Size ## CONSUMES - -[Depex] - TRUE diff --git a/OvmfPkg/Library/AcpiTimerLib/AcpiTimerLib.c b/OvmfPkg/Library/AcpiTimerLib/AcpiTimerLib.c deleted file mode 100644 index 938b77cdc6..0000000000 --- a/OvmfPkg/Library/AcpiTimerLib/AcpiTimerLib.c +++ /dev/null @@ -1,216 +0,0 @@ -/** @file - ACPI Timer implements one instance of Timer Library. - - Copyright (c) 2008 - 2012, Intel Corporation. All rights reserved.
- Copyright (c) 2011, Andrei Warkentin - - This program and the accompanying materials are - licensed and made 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 -#include -#include - -#include "AcpiTimerLib.h" - -// -// The ACPI Time is a 24-bit counter -// -#define ACPI_TIMER_COUNT_SIZE BIT24 - -/** - Stalls the CPU for at least the given number of ticks. - - Stalls the CPU for at least the given number of ticks. It's invoked by - MicroSecondDelay() and NanoSecondDelay(). - - @param Delay A period of time to delay in ticks. - -**/ -VOID -InternalAcpiDelay ( - IN UINT32 Delay - ) -{ - UINT32 Ticks; - UINT32 Times; - - Times = Delay >> 22; - Delay &= BIT22 - 1; - do { - // - // The target timer count is calculated here - // - Ticks = InternalAcpiGetTimerTick () + Delay; - Delay = BIT22; - // - // Wait until time out - // Delay >= 2^23 could not be handled by this function - // Timer wrap-arounds are handled correctly by this function - // - while (((Ticks - InternalAcpiGetTimerTick ()) & BIT23) == 0) { - CpuPause (); - } - } while (Times-- > 0); -} - -/** - Stalls the CPU for at least the given number of microseconds. - - Stalls the CPU for the number of microseconds specified by MicroSeconds. - - @param MicroSeconds The minimum number of microseconds to delay. - - @return MicroSeconds - -**/ -UINTN -EFIAPI -MicroSecondDelay ( - IN UINTN MicroSeconds - ) -{ - InternalAcpiDelay ( - (UINT32)DivU64x32 ( - MultU64x32 ( - MicroSeconds, - ACPI_TIMER_FREQUENCY - ), - 1000000u - ) - ); - return MicroSeconds; -} - -/** - Stalls the CPU for at least the given number of nanoseconds. - - Stalls the CPU for the number of nanoseconds specified by NanoSeconds. - - @param NanoSeconds The minimum number of nanoseconds to delay. - - @return NanoSeconds - -**/ -UINTN -EFIAPI -NanoSecondDelay ( - IN UINTN NanoSeconds - ) -{ - InternalAcpiDelay ( - (UINT32)DivU64x32 ( - MultU64x32 ( - NanoSeconds, - ACPI_TIMER_FREQUENCY - ), - 1000000000u - ) - ); - return NanoSeconds; -} - -/** - Retrieves the current value of a 64-bit free running performance counter. - - Retrieves the current value of a 64-bit free running performance counter. The - counter can either count up by 1 or count down by 1. If the physical - performance counter counts by a larger increment, then the counter values - must be translated. The properties of the counter can be retrieved from - GetPerformanceCounterProperties(). - - @return The current value of the free running performance counter. - -**/ -UINT64 -EFIAPI -GetPerformanceCounter ( - VOID - ) -{ - return (UINT64)InternalAcpiGetTimerTick (); -} - -/** - Retrieves the 64-bit frequency in Hz and the range of performance counter - values. - - If StartValue is not NULL, then the value that the performance counter starts - with immediately after is it rolls over is returned in StartValue. If - EndValue is not NULL, then the value that the performance counter end with - immediately before it rolls over is returned in EndValue. The 64-bit - frequency of the performance counter in Hz is always returned. If StartValue - is less than EndValue, then the performance counter counts up. If StartValue - is greater than EndValue, then the performance counter counts down. For - example, a 64-bit free running counter that counts up would have a StartValue - of 0 and an EndValue of 0xFFFFFFFFFFFFFFFF. A 24-bit free running counter - that counts down would have a StartValue of 0xFFFFFF and an EndValue of 0. - - @param StartValue The value the performance counter starts with when it - rolls over. - @param EndValue The value that the performance counter ends with before - it rolls over. - - @return The frequency in Hz. - -**/ -UINT64 -EFIAPI -GetPerformanceCounterProperties ( - OUT UINT64 *StartValue, OPTIONAL - OUT UINT64 *EndValue OPTIONAL - ) -{ - if (StartValue != NULL) { - *StartValue = 0; - } - - if (EndValue != NULL) { - *EndValue = ACPI_TIMER_COUNT_SIZE - 1; - } - - return ACPI_TIMER_FREQUENCY; -} - -/** - Converts elapsed ticks of performance counter to time in nanoseconds. - - This function converts the elapsed ticks of running performance counter to - time value in unit of nanoseconds. - - @param Ticks The number of elapsed ticks of running performance counter. - - @return The elapsed time in nanoseconds. - -**/ -UINT64 -EFIAPI -GetTimeInNanoSecond ( - IN UINT64 Ticks - ) -{ - UINT64 NanoSeconds; - UINT32 Remainder; - - // - // Ticks - // Time = --------- x 1,000,000,000 - // Frequency - // - NanoSeconds = MultU64x32 (DivU64x32Remainder (Ticks, ACPI_TIMER_FREQUENCY, &Remainder), 1000000000u); - - // - // Frequency < 0x100000000, so Remainder < 0x100000000, then (Remainder * 1,000,000,000) - // will not overflow 64-bit. - // - NanoSeconds += DivU64x32 (MultU64x32 ((UINT64) Remainder, 1000000000u), ACPI_TIMER_FREQUENCY); - - return NanoSeconds; -} diff --git a/OvmfPkg/Library/AcpiTimerLib/AcpiTimerLib.h b/OvmfPkg/Library/AcpiTimerLib/AcpiTimerLib.h deleted file mode 100644 index 475da70ac8..0000000000 --- a/OvmfPkg/Library/AcpiTimerLib/AcpiTimerLib.h +++ /dev/null @@ -1,29 +0,0 @@ -/** @file - Internal definitions for ACPI Timer Library - - Copyright (C) 2014, Gabriel L. Somlo - - This program and the accompanying materials are licensed and made - 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 _ACPI_TIMER_LIB_INTERNAL_H_ -#define _ACPI_TIMER_LIB_INTERNAL_H_ - -/** - Internal function to read the current tick counter of ACPI. - - @return The tick counter read. - -**/ -UINT32 -InternalAcpiGetTimerTick ( - VOID - ); - -#endif // _ACPI_TIMER_LIB_INTERNAL_H_ diff --git a/OvmfPkg/Library/AcpiTimerLib/BaseAcpiTimerLib.c b/OvmfPkg/Library/AcpiTimerLib/BaseAcpiTimerLib.c deleted file mode 100644 index a839495e67..0000000000 --- a/OvmfPkg/Library/AcpiTimerLib/BaseAcpiTimerLib.c +++ /dev/null @@ -1,109 +0,0 @@ -/** @file - Provide constructor and GetTick for Base instance of ACPI Timer Library - - Copyright (C) 2014, Gabriel L. Somlo - - This program and the accompanying materials are licensed and made - 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 -#include -#include -#include - -// -// Cached ACPI Timer IO Address -// -STATIC UINT32 mAcpiTimerIoAddr; - -/** - The constructor function caches the ACPI tick counter address, and, - if necessary, enables ACPI IO space. - - @retval EFI_SUCCESS The constructor always returns RETURN_SUCCESS. - -**/ -RETURN_STATUS -EFIAPI -AcpiTimerLibConstructor ( - VOID - ) -{ - UINT16 HostBridgeDevId; - UINTN Pmba; - UINT32 PmbaAndVal; - UINT32 PmbaOrVal; - UINTN AcpiCtlReg; - UINT8 AcpiEnBit; - - // - // Query Host Bridge DID to determine platform type - // - HostBridgeDevId = PciRead16 (OVMF_HOSTBRIDGE_DID); - switch (HostBridgeDevId) { - case INTEL_82441_DEVICE_ID: - Pmba = POWER_MGMT_REGISTER_PIIX4 (PIIX4_PMBA); - PmbaAndVal = ~(UINT32)PIIX4_PMBA_MASK; - PmbaOrVal = PIIX4_PMBA_VALUE; - AcpiCtlReg = POWER_MGMT_REGISTER_PIIX4 (PIIX4_PMREGMISC); - AcpiEnBit = PIIX4_PMREGMISC_PMIOSE; - break; - case INTEL_Q35_MCH_DEVICE_ID: - Pmba = POWER_MGMT_REGISTER_Q35 (ICH9_PMBASE); - PmbaAndVal = ~(UINT32)ICH9_PMBASE_MASK; - PmbaOrVal = ICH9_PMBASE_VALUE; - AcpiCtlReg = POWER_MGMT_REGISTER_Q35 (ICH9_ACPI_CNTL); - AcpiEnBit = ICH9_ACPI_CNTL_ACPI_EN; - break; - default: - DEBUG ((EFI_D_ERROR, "%a: Unknown Host Bridge Device ID: 0x%04x\n", - __FUNCTION__, HostBridgeDevId)); - ASSERT (FALSE); - return RETURN_UNSUPPORTED; - } - - // - // Check to see if the Power Management Base Address is already enabled - // - if ((PciRead8 (AcpiCtlReg) & AcpiEnBit) == 0) { - // - // If the Power Management Base Address is not programmed, - // then program it now. - // - PciAndThenOr32 (Pmba, PmbaAndVal, PmbaOrVal); - - // - // Enable PMBA I/O port decodes - // - PciOr8 (AcpiCtlReg, AcpiEnBit); - } - - mAcpiTimerIoAddr = (PciRead32 (Pmba) & ~PMBA_RTE) + ACPI_TIMER_OFFSET; - return RETURN_SUCCESS; -} - -/** - Internal function to read the current tick counter of ACPI. - - Read the current ACPI tick counter using the counter address cached - by this instance's constructor. - - @return The tick counter read. - -**/ -UINT32 -InternalAcpiGetTimerTick ( - VOID - ) -{ - // - // Return the current ACPI timer value. - // - return IoRead32 (mAcpiTimerIoAddr); -} diff --git a/OvmfPkg/Library/AcpiTimerLib/BaseAcpiTimerLib.inf b/OvmfPkg/Library/AcpiTimerLib/BaseAcpiTimerLib.inf deleted file mode 100644 index 04df609220..0000000000 --- a/OvmfPkg/Library/AcpiTimerLib/BaseAcpiTimerLib.inf +++ /dev/null @@ -1,37 +0,0 @@ -## @file -# Base ACPI Timer Library Instance. -# -# Copyright (C) 2014, Gabriel L. Somlo -# Copyright (c) 2008 - 2010, Intel Corporation. All rights reserved. -# -# This program and the accompanying materials are licensed and made -# available under the terms and conditions of the BSD License which -# accompanies this distribution. The full text of the license may -# be found at http://opensource.org/licenses/bsd-license.php -# -# THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, -# WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. -# -## - -[Defines] - INF_VERSION = 0x00010005 - BASE_NAME = BaseAcpiTimerLib - FILE_GUID = FB648CF5-91BE-4737-9023-FD807AC6D96D - MODULE_TYPE = BASE - VERSION_STRING = 1.0 - LIBRARY_CLASS = TimerLib|PEI_CORE PEIM DXE_CORE - CONSTRUCTOR = AcpiTimerLibConstructor - -[Sources] - AcpiTimerLib.c - BaseAcpiTimerLib.c - -[Packages] - MdePkg/MdePkg.dec - OvmfPkg/OvmfPkg.dec - -[LibraryClasses] - BaseLib - PciLib - IoLib diff --git a/OvmfPkg/Library/AcpiTimerLib/BaseRomAcpiTimerLib.c b/OvmfPkg/Library/AcpiTimerLib/BaseRomAcpiTimerLib.c deleted file mode 100644 index dbbecc93c1..0000000000 --- a/OvmfPkg/Library/AcpiTimerLib/BaseRomAcpiTimerLib.c +++ /dev/null @@ -1,127 +0,0 @@ -/** @file - Provide constructor and GetTick for BaseRom instance of ACPI Timer Library - - Copyright (c) 2008 - 2012, Intel Corporation. All rights reserved. - Copyright (c) 2011, Andrei Warkentin - - This program and the accompanying materials are licensed and made - 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 -#include -#include -#include - -/** - The constructor function enables ACPI IO space. - - If ACPI I/O space not enabled, this function will enable it. - It will always return RETURN_SUCCESS. - - @retval EFI_SUCCESS The constructor always returns RETURN_SUCCESS. - -**/ -RETURN_STATUS -EFIAPI -AcpiTimerLibConstructor ( - VOID - ) -{ - UINT16 HostBridgeDevId; - UINTN Pmba; - UINT32 PmbaAndVal; - UINT32 PmbaOrVal; - UINTN AcpiCtlReg; - UINT8 AcpiEnBit; - - // - // Query Host Bridge DID to determine platform type - // - HostBridgeDevId = PciRead16 (OVMF_HOSTBRIDGE_DID); - switch (HostBridgeDevId) { - case INTEL_82441_DEVICE_ID: - Pmba = POWER_MGMT_REGISTER_PIIX4 (PIIX4_PMBA); - PmbaAndVal = ~(UINT32)PIIX4_PMBA_MASK; - PmbaOrVal = PIIX4_PMBA_VALUE; - AcpiCtlReg = POWER_MGMT_REGISTER_PIIX4 (PIIX4_PMREGMISC); - AcpiEnBit = PIIX4_PMREGMISC_PMIOSE; - break; - case INTEL_Q35_MCH_DEVICE_ID: - Pmba = POWER_MGMT_REGISTER_Q35 (ICH9_PMBASE); - PmbaAndVal = ~(UINT32)ICH9_PMBASE_MASK; - PmbaOrVal = ICH9_PMBASE_VALUE; - AcpiCtlReg = POWER_MGMT_REGISTER_Q35 (ICH9_ACPI_CNTL); - AcpiEnBit = ICH9_ACPI_CNTL_ACPI_EN; - break; - default: - DEBUG ((EFI_D_ERROR, "%a: Unknown Host Bridge Device ID: 0x%04x\n", - __FUNCTION__, HostBridgeDevId)); - ASSERT (FALSE); - return RETURN_UNSUPPORTED; - } - - // - // Check to see if the Power Management Base Address is already enabled - // - if ((PciRead8 (AcpiCtlReg) & AcpiEnBit) == 0) { - // - // If the Power Management Base Address is not programmed, - // then program it now. - // - PciAndThenOr32 (Pmba, PmbaAndVal, PmbaOrVal); - - // - // Enable PMBA I/O port decodes - // - PciOr8 (AcpiCtlReg, AcpiEnBit); - } - - return RETURN_SUCCESS; -} - -/** - Internal function to read the current tick counter of ACPI. - - Dynamically compute the address of the ACPI tick counter based on the - properties of the underlying platform, to avoid relying on global variables. - - @return The tick counter read. - -**/ -UINT32 -InternalAcpiGetTimerTick ( - VOID - ) -{ - UINT16 HostBridgeDevId; - UINTN Pmba; - - // - // Query Host Bridge DID to determine platform type - // - HostBridgeDevId = PciRead16 (OVMF_HOSTBRIDGE_DID); - switch (HostBridgeDevId) { - case INTEL_82441_DEVICE_ID: - Pmba = POWER_MGMT_REGISTER_PIIX4 (PIIX4_PMBA); - break; - case INTEL_Q35_MCH_DEVICE_ID: - Pmba = POWER_MGMT_REGISTER_Q35 (ICH9_PMBASE); - break; - default: - DEBUG ((EFI_D_ERROR, "%a: Unknown Host Bridge Device ID: 0x%04x\n", - __FUNCTION__, HostBridgeDevId)); - ASSERT (FALSE); - return 0; - } - - // - // Read PMBA to read and return the current ACPI timer value. - // - return IoRead32 ((PciRead32 (Pmba) & ~PMBA_RTE) + ACPI_TIMER_OFFSET); -} diff --git a/OvmfPkg/Library/AcpiTimerLib/BaseRomAcpiTimerLib.inf b/OvmfPkg/Library/AcpiTimerLib/BaseRomAcpiTimerLib.inf deleted file mode 100644 index 946292c181..0000000000 --- a/OvmfPkg/Library/AcpiTimerLib/BaseRomAcpiTimerLib.inf +++ /dev/null @@ -1,36 +0,0 @@ -## @file -# BaseRom ACPI Timer Library Instance. -# -# Copyright (c) 2008 - 2010, Intel Corporation. All rights reserved. -# -# This program and the accompanying materials are licensed and made -# available under the terms and conditions of the BSD License which -# accompanies this distribution. The full text of the license may -# be found at http://opensource.org/licenses/bsd-license.php -# -# THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, -# WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. -# -## - -[Defines] - INF_VERSION = 0x00010005 - BASE_NAME = BaseRomAcpiTimerLib - FILE_GUID = CDD9D74F-213E-4c28-98F7-8B4A167DB936 - MODULE_TYPE = BASE - VERSION_STRING = 1.0 - LIBRARY_CLASS = TimerLib|SEC - CONSTRUCTOR = AcpiTimerLibConstructor - -[Sources] - AcpiTimerLib.c - BaseRomAcpiTimerLib.c - -[Packages] - MdePkg/MdePkg.dec - OvmfPkg/OvmfPkg.dec - -[LibraryClasses] - BaseLib - PciLib - IoLib diff --git a/OvmfPkg/Library/AcpiTimerLib/DxeAcpiTimerLib.c b/OvmfPkg/Library/AcpiTimerLib/DxeAcpiTimerLib.c deleted file mode 100644 index e673434ae6..0000000000 --- a/OvmfPkg/Library/AcpiTimerLib/DxeAcpiTimerLib.c +++ /dev/null @@ -1,89 +0,0 @@ -/** @file - Provide constructor and GetTick for Dxe instance of ACPI Timer Library - - Copyright (C) 2014, Gabriel L. Somlo - - This program and the accompanying materials are licensed and made - 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 -#include -#include -#include -#include - -// -// Cached ACPI Timer IO Address -// -STATIC UINT32 mAcpiTimerIoAddr; - -/** - The constructor function caches the ACPI tick counter address - - At the time this constructor runs (DXE_CORE or later), ACPI IO space - has already been enabled by either PlatformPei or by the "Base" - instance of this library. - In order to avoid querying the underlying platform type during each - tick counter read operation, we cache the counter address during - initialization of this instance of the Timer Library. - - @retval EFI_SUCCESS The constructor always returns RETURN_SUCCESS. - -**/ -RETURN_STATUS -EFIAPI -AcpiTimerLibConstructor ( - VOID - ) -{ - UINT16 HostBridgeDevId; - UINTN Pmba; - - // - // Query Host Bridge DID to determine platform type - // - HostBridgeDevId = PcdGet16 (PcdOvmfHostBridgePciDevId); - switch (HostBridgeDevId) { - case INTEL_82441_DEVICE_ID: - Pmba = POWER_MGMT_REGISTER_PIIX4 (PIIX4_PMBA); - break; - case INTEL_Q35_MCH_DEVICE_ID: - Pmba = POWER_MGMT_REGISTER_Q35 (ICH9_PMBASE); - break; - default: - DEBUG ((EFI_D_ERROR, "%a: Unknown Host Bridge Device ID: 0x%04x\n", - __FUNCTION__, HostBridgeDevId)); - ASSERT (FALSE); - return RETURN_UNSUPPORTED; - } - - mAcpiTimerIoAddr = (PciRead32 (Pmba) & ~PMBA_RTE) + ACPI_TIMER_OFFSET; - - return RETURN_SUCCESS; -} - -/** - Internal function to read the current tick counter of ACPI. - - Read the current ACPI tick counter using the counter address cached - by this instance's constructor. - - @return The tick counter read. - -**/ -UINT32 -InternalAcpiGetTimerTick ( - VOID - ) -{ - // - // Return the current ACPI timer value. - // - return IoRead32 (mAcpiTimerIoAddr); -} diff --git a/OvmfPkg/Library/AcpiTimerLib/DxeAcpiTimerLib.inf b/OvmfPkg/Library/AcpiTimerLib/DxeAcpiTimerLib.inf deleted file mode 100644 index 25a9823d25..0000000000 --- a/OvmfPkg/Library/AcpiTimerLib/DxeAcpiTimerLib.inf +++ /dev/null @@ -1,40 +0,0 @@ -## @file -# DXE ACPI Timer Library Instance. -# -# Copyright (C) 2014, Gabriel L. Somlo -# Copyright (c) 2008 - 2010, Intel Corporation. All rights reserved. -# -# This program and the accompanying materials are licensed and made -# available under the terms and conditions of the BSD License which -# accompanies this distribution. The full text of the license may -# be found at http://opensource.org/licenses/bsd-license.php -# -# THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, -# WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. -# -## - -[Defines] - INF_VERSION = 0x00010005 - BASE_NAME = DxeAcpiTimerLib - FILE_GUID = 52DECA02-2EE8-4EAA-8EAD-1AB83F8A5955 - MODULE_TYPE = BASE - VERSION_STRING = 1.0 - LIBRARY_CLASS = TimerLib|DXE_DRIVER DXE_RUNTIME_DRIVER DXE_SMM_DRIVER UEFI_DRIVER UEFI_APPLICATION SMM_CORE - CONSTRUCTOR = AcpiTimerLibConstructor - -[Sources] - AcpiTimerLib.c - DxeAcpiTimerLib.c - -[Packages] - MdePkg/MdePkg.dec - OvmfPkg/OvmfPkg.dec - -[Pcd] - gUefiOvmfPkgTokenSpaceGuid.PcdOvmfHostBridgePciDevId - -[LibraryClasses] - BaseLib - PciLib - IoLib diff --git a/OvmfPkg/Library/DxePciLibI440FxQ35/DxePciLibI440FxQ35.inf b/OvmfPkg/Library/DxePciLibI440FxQ35/DxePciLibI440FxQ35.inf deleted file mode 100644 index 2bd10cc232..0000000000 --- a/OvmfPkg/Library/DxePciLibI440FxQ35/DxePciLibI440FxQ35.inf +++ /dev/null @@ -1,47 +0,0 @@ -## @file -# An instance of the PCI Library that is based on both the PCI CF8 Library and -# the PCI Express Library. -# -# This PciLib instance caches the OVMF platform type (I440FX vs. Q35) in -# its entry point function, then delegates function calls to one of the -# PciCf8Lib or PciExpressLib "backends" as appropriate. -# -# Copyright (C) 2016, Red Hat, Inc. -# -# Copyright (c) 2007 - 2014, Intel Corporation. All rights reserved.
-# -# This program and the accompanying materials are licensed and made available -# under the terms and conditions of the BSD License which accompanies this -# distribution. The full text of the license may be found at -# http://opensource.org/licenses/bsd-license.php. -# -# THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, -# WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR -# IMPLIED. -## - -[Defines] - INF_VERSION = 0x00010005 - BASE_NAME = DxePciLibI440FxQ35 - FILE_GUID = 5360bff6-3911-4495-ae3c-b02ff004b585 - MODULE_TYPE = BASE - VERSION_STRING = 1.0 - LIBRARY_CLASS = PciLib|DXE_DRIVER DXE_RUNTIME_DRIVER SMM_CORE DXE_SMM_DRIVER UEFI_DRIVER UEFI_APPLICATION - CONSTRUCTOR = InitializeConfigAccessMethod - -# VALID_ARCHITECTURES = IA32 X64 - -[Sources] - PciLib.c - -[Packages] - MdePkg/MdePkg.dec - OvmfPkg/OvmfPkg.dec - -[LibraryClasses] - PcdLib - PciCf8Lib - PciExpressLib - -[Pcd] - gUefiOvmfPkgTokenSpaceGuid.PcdOvmfHostBridgePciDevId diff --git a/OvmfPkg/Library/DxePciLibI440FxQ35/PciLib.c b/OvmfPkg/Library/DxePciLibI440FxQ35/PciLib.c deleted file mode 100644 index 6c1a272973..0000000000 --- a/OvmfPkg/Library/DxePciLibI440FxQ35/PciLib.c +++ /dev/null @@ -1,1229 +0,0 @@ -/** @file - PCI Library functions that use - (a) I/O ports 0xCF8 and 0xCFC to perform PCI Configuration cycles, layering - on top of one PCI CF8 Library instance; or - (b) PCI Library functions that use the 256 MB PCI Express MMIO window to - perform PCI Configuration cycles, layering on PCI Express Library. - - The decision is made in the entry point function, based on the OVMF platform - type, and then adhered to during the lifetime of the client module. - - Copyright (C) 2016, Red Hat, Inc. - - Copyright (c) 2006 - 2012, Intel Corporation. All rights reserved.
- This program and the accompanying materials - are licensed and made available under the terms and conditions of the BSD License - which accompanies this distribution. The full text of the license may be found at - http://opensource.org/licenses/bsd-license.php. - - THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, - WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. - -**/ - - -#include - -#include - -#include -#include -#include -#include - -STATIC BOOLEAN mRunningOnQ35; - -RETURN_STATUS -EFIAPI -InitializeConfigAccessMethod ( - VOID - ) -{ - mRunningOnQ35 = (PcdGet16 (PcdOvmfHostBridgePciDevId) == - INTEL_Q35_MCH_DEVICE_ID); - return RETURN_SUCCESS; -} - -/** - Registers a PCI device so PCI configuration registers may be accessed after - SetVirtualAddressMap(). - - Registers the PCI device specified by Address so all the PCI configuration registers - associated with that PCI device may be accessed after SetVirtualAddressMap() is called. - - If Address > 0x0FFFFFFF, then ASSERT(). - - @param Address The address that encodes the PCI Bus, Device, Function and - Register. - - @retval RETURN_SUCCESS The PCI device was registered for runtime access. - @retval RETURN_UNSUPPORTED An attempt was made to call this function - after ExitBootServices(). - @retval RETURN_UNSUPPORTED The resources required to access the PCI device - at runtime could not be mapped. - @retval RETURN_OUT_OF_RESOURCES There are not enough resources available to - complete the registration. - -**/ -RETURN_STATUS -EFIAPI -PciRegisterForRuntimeAccess ( - IN UINTN Address - ) -{ - return mRunningOnQ35 ? - PciExpressRegisterForRuntimeAccess (Address) : - PciCf8RegisterForRuntimeAccess (Address); -} - -/** - Reads an 8-bit PCI configuration register. - - Reads and returns the 8-bit PCI configuration register specified by Address. - This function must guarantee that all PCI read and write operations are - serialized. - - If Address > 0x0FFFFFFF, then ASSERT(). - - @param Address The address that encodes the PCI Bus, Device, Function and - Register. - - @return The read value from the PCI configuration register. - -**/ -UINT8 -EFIAPI -PciRead8 ( - IN UINTN Address - ) -{ - return mRunningOnQ35 ? - PciExpressRead8 (Address) : - PciCf8Read8 (Address); -} - -/** - Writes an 8-bit PCI configuration register. - - Writes the 8-bit PCI configuration register specified by Address with the - value specified by Value. Value is returned. This function must guarantee - that all PCI read and write operations are serialized. - - If Address > 0x0FFFFFFF, then ASSERT(). - - @param Address The address that encodes the PCI Bus, Device, Function and - Register. - @param Value The value to write. - - @return The value written to the PCI configuration register. - -**/ -UINT8 -EFIAPI -PciWrite8 ( - IN UINTN Address, - IN UINT8 Value - ) -{ - return mRunningOnQ35 ? - PciExpressWrite8 (Address, Value) : - PciCf8Write8 (Address, Value); -} - -/** - Performs a bitwise OR of an 8-bit PCI configuration register with - an 8-bit value. - - Reads the 8-bit PCI configuration register specified by Address, performs a - bitwise OR between the read result and the value specified by - OrData, and writes the result to the 8-bit PCI configuration register - specified by Address. The value written to the PCI configuration register is - returned. This function must guarantee that all PCI read and write operations - are serialized. - - If Address > 0x0FFFFFFF, then ASSERT(). - - @param Address The address that encodes the PCI Bus, Device, Function and - Register. - @param OrData The value to OR with the PCI configuration register. - - @return The value written back to the PCI configuration register. - -**/ -UINT8 -EFIAPI -PciOr8 ( - IN UINTN Address, - IN UINT8 OrData - ) -{ - return mRunningOnQ35 ? - PciExpressOr8 (Address, OrData) : - PciCf8Or8 (Address, OrData); -} - -/** - Performs a bitwise AND of an 8-bit PCI configuration register with an 8-bit - value. - - Reads the 8-bit PCI configuration register specified by Address, performs a - bitwise AND between the read result and the value specified by AndData, and - writes the result to the 8-bit PCI configuration register specified by - Address. The value written to the PCI configuration register is returned. - This function must guarantee that all PCI read and write operations are - serialized. - - If Address > 0x0FFFFFFF, then ASSERT(). - - @param Address The address that encodes the PCI Bus, Device, Function and - Register. - @param AndData The value to AND with the PCI configuration register. - - @return The value written back to the PCI configuration register. - -**/ -UINT8 -EFIAPI -PciAnd8 ( - IN UINTN Address, - IN UINT8 AndData - ) -{ - return mRunningOnQ35 ? - PciExpressAnd8 (Address, AndData) : - PciCf8And8 (Address, AndData); -} - -/** - Performs a bitwise AND of an 8-bit PCI configuration register with an 8-bit - value, followed a bitwise OR with another 8-bit value. - - Reads the 8-bit PCI configuration register specified by Address, performs a - bitwise AND between the read result and the value specified by AndData, - performs a bitwise OR between the result of the AND operation and - the value specified by OrData, and writes the result to the 8-bit PCI - configuration register specified by Address. The value written to the PCI - configuration register is returned. This function must guarantee that all PCI - read and write operations are serialized. - - If Address > 0x0FFFFFFF, then ASSERT(). - - @param Address The address that encodes the PCI Bus, Device, Function and - Register. - @param AndData The value to AND with the PCI configuration register. - @param OrData The value to OR with the result of the AND operation. - - @return The value written back to the PCI configuration register. - -**/ -UINT8 -EFIAPI -PciAndThenOr8 ( - IN UINTN Address, - IN UINT8 AndData, - IN UINT8 OrData - ) -{ - return mRunningOnQ35 ? - PciExpressAndThenOr8 (Address, AndData, OrData) : - PciCf8AndThenOr8 (Address, AndData, OrData); -} - -/** - Reads a bit field of a PCI configuration register. - - Reads the bit field in an 8-bit PCI configuration register. The bit field is - specified by the StartBit and the EndBit. The value of the bit field is - returned. - - If Address > 0x0FFFFFFF, then ASSERT(). - If StartBit is greater than 7, then ASSERT(). - If EndBit is greater than 7, then ASSERT(). - If EndBit is less than StartBit, then ASSERT(). - - @param Address The PCI configuration register to read. - @param StartBit The ordinal of the least significant bit in the bit field. - Range 0..7. - @param EndBit The ordinal of the most significant bit in the bit field. - Range 0..7. - - @return The value of the bit field read from the PCI configuration register. - -**/ -UINT8 -EFIAPI -PciBitFieldRead8 ( - IN UINTN Address, - IN UINTN StartBit, - IN UINTN EndBit - ) -{ - return mRunningOnQ35 ? - PciExpressBitFieldRead8 (Address, StartBit, EndBit) : - PciCf8BitFieldRead8 (Address, StartBit, EndBit); -} - -/** - Writes a bit field to a PCI configuration register. - - Writes Value to the bit field of the PCI configuration register. The bit - field is specified by the StartBit and the EndBit. All other bits in the - destination PCI configuration register are preserved. The new value of the - 8-bit register is returned. - - If Address > 0x0FFFFFFF, then ASSERT(). - If StartBit is greater than 7, then ASSERT(). - If EndBit is greater than 7, then ASSERT(). - If EndBit is less than StartBit, then ASSERT(). - If Value is larger than the bitmask value range specified by StartBit and EndBit, then ASSERT(). - - @param Address The PCI configuration register to write. - @param StartBit The ordinal of the least significant bit in the bit field. - Range 0..7. - @param EndBit The ordinal of the most significant bit in the bit field. - Range 0..7. - @param Value The new value of the bit field. - - @return The value written back to the PCI configuration register. - -**/ -UINT8 -EFIAPI -PciBitFieldWrite8 ( - IN UINTN Address, - IN UINTN StartBit, - IN UINTN EndBit, - IN UINT8 Value - ) -{ - return mRunningOnQ35 ? - PciExpressBitFieldWrite8 (Address, StartBit, EndBit, Value) : - PciCf8BitFieldWrite8 (Address, StartBit, EndBit, Value); -} - -/** - Reads a bit field in an 8-bit PCI configuration, performs a bitwise OR, and - writes the result back to the bit field in the 8-bit port. - - Reads the 8-bit PCI configuration register specified by Address, performs a - bitwise OR between the read result and the value specified by - OrData, and writes the result to the 8-bit PCI configuration register - specified by Address. The value written to the PCI configuration register is - returned. This function must guarantee that all PCI read and write operations - are serialized. Extra left bits in OrData are stripped. - - If Address > 0x0FFFFFFF, then ASSERT(). - If StartBit is greater than 7, then ASSERT(). - If EndBit is greater than 7, then ASSERT(). - If EndBit is less than StartBit, then ASSERT(). - If OrData is larger than the bitmask value range specified by StartBit and EndBit, then ASSERT(). - - @param Address The PCI configuration register to write. - @param StartBit The ordinal of the least significant bit in the bit field. - Range 0..7. - @param EndBit The ordinal of the most significant bit in the bit field. - Range 0..7. - @param OrData The value to OR with the PCI configuration register. - - @return The value written back to the PCI configuration register. - -**/ -UINT8 -EFIAPI -PciBitFieldOr8 ( - IN UINTN Address, - IN UINTN StartBit, - IN UINTN EndBit, - IN UINT8 OrData - ) -{ - return mRunningOnQ35 ? - PciExpressBitFieldOr8 (Address, StartBit, EndBit, OrData) : - PciCf8BitFieldOr8 (Address, StartBit, EndBit, OrData); -} - -/** - Reads a bit field in an 8-bit PCI configuration register, performs a bitwise - AND, and writes the result back to the bit field in the 8-bit register. - - Reads the 8-bit PCI configuration register specified by Address, performs a - bitwise AND between the read result and the value specified by AndData, and - writes the result to the 8-bit PCI configuration register specified by - Address. The value written to the PCI configuration register is returned. - This function must guarantee that all PCI read and write operations are - serialized. Extra left bits in AndData are stripped. - - If Address > 0x0FFFFFFF, then ASSERT(). - If StartBit is greater than 7, then ASSERT(). - If EndBit is greater than 7, then ASSERT(). - If EndBit is less than StartBit, then ASSERT(). - If AndData is larger than the bitmask value range specified by StartBit and EndBit, then ASSERT(). - - @param Address The PCI configuration register to write. - @param StartBit The ordinal of the least significant bit in the bit field. - Range 0..7. - @param EndBit The ordinal of the most significant bit in the bit field. - Range 0..7. - @param AndData The value to AND with the PCI configuration register. - - @return The value written back to the PCI configuration register. - -**/ -UINT8 -EFIAPI -PciBitFieldAnd8 ( - IN UINTN Address, - IN UINTN StartBit, - IN UINTN EndBit, - IN UINT8 AndData - ) -{ - return mRunningOnQ35 ? - PciExpressBitFieldAnd8 (Address, StartBit, EndBit, AndData) : - PciCf8BitFieldAnd8 (Address, StartBit, EndBit, AndData); -} - -/** - Reads a bit field in an 8-bit port, performs a bitwise AND followed by a - bitwise OR, and writes the result back to the bit field in the - 8-bit port. - - Reads the 8-bit PCI configuration register specified by Address, performs a - bitwise AND followed by a bitwise OR between the read result and - the value specified by AndData, and writes the result to the 8-bit PCI - configuration register specified by Address. The value written to the PCI - configuration register is returned. This function must guarantee that all PCI - read and write operations are serialized. Extra left bits in both AndData and - OrData are stripped. - - If Address > 0x0FFFFFFF, then ASSERT(). - If StartBit is greater than 7, then ASSERT(). - If EndBit is greater than 7, then ASSERT(). - If EndBit is less than StartBit, then ASSERT(). - If AndData is larger than the bitmask value range specified by StartBit and EndBit, then ASSERT(). - If OrData is larger than the bitmask value range specified by StartBit and EndBit, then ASSERT(). - - @param Address The PCI configuration register to write. - @param StartBit The ordinal of the least significant bit in the bit field. - Range 0..7. - @param EndBit The ordinal of the most significant bit in the bit field. - Range 0..7. - @param AndData The value to AND with the PCI configuration register. - @param OrData The value to OR with the result of the AND operation. - - @return The value written back to the PCI configuration register. - -**/ -UINT8 -EFIAPI -PciBitFieldAndThenOr8 ( - IN UINTN Address, - IN UINTN StartBit, - IN UINTN EndBit, - IN UINT8 AndData, - IN UINT8 OrData - ) -{ - return mRunningOnQ35 ? - PciExpressBitFieldAndThenOr8 (Address, StartBit, EndBit, AndData, OrData) : - PciCf8BitFieldAndThenOr8 (Address, StartBit, EndBit, AndData, OrData); -} - -/** - Reads a 16-bit PCI configuration register. - - Reads and returns the 16-bit PCI configuration register specified by Address. - This function must guarantee that all PCI read and write operations are - serialized. - - If Address > 0x0FFFFFFF, then ASSERT(). - If Address is not aligned on a 16-bit boundary, then ASSERT(). - - @param Address The address that encodes the PCI Bus, Device, Function and - Register. - - @return The read value from the PCI configuration register. - -**/ -UINT16 -EFIAPI -PciRead16 ( - IN UINTN Address - ) -{ - return mRunningOnQ35 ? - PciExpressRead16 (Address) : - PciCf8Read16 (Address); -} - -/** - Writes a 16-bit PCI configuration register. - - Writes the 16-bit PCI configuration register specified by Address with the - value specified by Value. Value is returned. This function must guarantee - that all PCI read and write operations are serialized. - - If Address > 0x0FFFFFFF, then ASSERT(). - If Address is not aligned on a 16-bit boundary, then ASSERT(). - - @param Address The address that encodes the PCI Bus, Device, Function and - Register. - @param Value The value to write. - - @return The value written to the PCI configuration register. - -**/ -UINT16 -EFIAPI -PciWrite16 ( - IN UINTN Address, - IN UINT16 Value - ) -{ - return mRunningOnQ35 ? - PciExpressWrite16 (Address, Value) : - PciCf8Write16 (Address, Value); -} - -/** - Performs a bitwise OR of a 16-bit PCI configuration register with - a 16-bit value. - - Reads the 16-bit PCI configuration register specified by Address, performs a - bitwise OR between the read result and the value specified by - OrData, and writes the result to the 16-bit PCI configuration register - specified by Address. The value written to the PCI configuration register is - returned. This function must guarantee that all PCI read and write operations - are serialized. - - If Address > 0x0FFFFFFF, then ASSERT(). - If Address is not aligned on a 16-bit boundary, then ASSERT(). - - @param Address The address that encodes the PCI Bus, Device, Function and - Register. - @param OrData The value to OR with the PCI configuration register. - - @return The value written back to the PCI configuration register. - -**/ -UINT16 -EFIAPI -PciOr16 ( - IN UINTN Address, - IN UINT16 OrData - ) -{ - return mRunningOnQ35 ? - PciExpressOr16 (Address, OrData) : - PciCf8Or16 (Address, OrData); -} - -/** - Performs a bitwise AND of a 16-bit PCI configuration register with a 16-bit - value. - - Reads the 16-bit PCI configuration register specified by Address, performs a - bitwise AND between the read result and the value specified by AndData, and - writes the result to the 16-bit PCI configuration register specified by - Address. The value written to the PCI configuration register is returned. - This function must guarantee that all PCI read and write operations are - serialized. - - If Address > 0x0FFFFFFF, then ASSERT(). - If Address is not aligned on a 16-bit boundary, then ASSERT(). - - @param Address The address that encodes the PCI Bus, Device, Function and - Register. - @param AndData The value to AND with the PCI configuration register. - - @return The value written back to the PCI configuration register. - -**/ -UINT16 -EFIAPI -PciAnd16 ( - IN UINTN Address, - IN UINT16 AndData - ) -{ - return mRunningOnQ35 ? - PciExpressAnd16 (Address, AndData) : - PciCf8And16 (Address, AndData); -} - -/** - Performs a bitwise AND of a 16-bit PCI configuration register with a 16-bit - value, followed a bitwise OR with another 16-bit value. - - Reads the 16-bit PCI configuration register specified by Address, performs a - bitwise AND between the read result and the value specified by AndData, - performs a bitwise OR between the result of the AND operation and - the value specified by OrData, and writes the result to the 16-bit PCI - configuration register specified by Address. The value written to the PCI - configuration register is returned. This function must guarantee that all PCI - read and write operations are serialized. - - If Address > 0x0FFFFFFF, then ASSERT(). - If Address is not aligned on a 16-bit boundary, then ASSERT(). - - @param Address The address that encodes the PCI Bus, Device, Function and - Register. - @param AndData The value to AND with the PCI configuration register. - @param OrData The value to OR with the result of the AND operation. - - @return The value written back to the PCI configuration register. - -**/ -UINT16 -EFIAPI -PciAndThenOr16 ( - IN UINTN Address, - IN UINT16 AndData, - IN UINT16 OrData - ) -{ - return mRunningOnQ35 ? - PciExpressAndThenOr16 (Address, AndData, OrData) : - PciCf8AndThenOr16 (Address, AndData, OrData); -} - -/** - Reads a bit field of a PCI configuration register. - - Reads the bit field in a 16-bit PCI configuration register. The bit field is - specified by the StartBit and the EndBit. The value of the bit field is - returned. - - If Address > 0x0FFFFFFF, then ASSERT(). - If Address is not aligned on a 16-bit boundary, then ASSERT(). - If StartBit is greater than 15, then ASSERT(). - If EndBit is greater than 15, then ASSERT(). - If EndBit is less than StartBit, then ASSERT(). - - @param Address The PCI configuration register to read. - @param StartBit The ordinal of the least significant bit in the bit field. - Range 0..15. - @param EndBit The ordinal of the most significant bit in the bit field. - Range 0..15. - - @return The value of the bit field read from the PCI configuration register. - -**/ -UINT16 -EFIAPI -PciBitFieldRead16 ( - IN UINTN Address, - IN UINTN StartBit, - IN UINTN EndBit - ) -{ - return mRunningOnQ35 ? - PciExpressBitFieldRead16 (Address, StartBit, EndBit) : - PciCf8BitFieldRead16 (Address, StartBit, EndBit); -} - -/** - Writes a bit field to a PCI configuration register. - - Writes Value to the bit field of the PCI configuration register. The bit - field is specified by the StartBit and the EndBit. All other bits in the - destination PCI configuration register are preserved. The new value of the - 16-bit register is returned. - - If Address > 0x0FFFFFFF, then ASSERT(). - If Address is not aligned on a 16-bit boundary, then ASSERT(). - If StartBit is greater than 15, then ASSERT(). - If EndBit is greater than 15, then ASSERT(). - If EndBit is less than StartBit, then ASSERT(). - If Value is larger than the bitmask value range specified by StartBit and EndBit, then ASSERT(). - - @param Address The PCI configuration register to write. - @param StartBit The ordinal of the least significant bit in the bit field. - Range 0..15. - @param EndBit The ordinal of the most significant bit in the bit field. - Range 0..15. - @param Value The new value of the bit field. - - @return The value written back to the PCI configuration register. - -**/ -UINT16 -EFIAPI -PciBitFieldWrite16 ( - IN UINTN Address, - IN UINTN StartBit, - IN UINTN EndBit, - IN UINT16 Value - ) -{ - return mRunningOnQ35 ? - PciExpressBitFieldWrite16 (Address, StartBit, EndBit, Value) : - PciCf8BitFieldWrite16 (Address, StartBit, EndBit, Value); -} - -/** - Reads a bit field in a 16-bit PCI configuration, performs a bitwise OR, and - writes the result back to the bit field in the 16-bit port. - - Reads the 16-bit PCI configuration register specified by Address, performs a - bitwise OR between the read result and the value specified by - OrData, and writes the result to the 16-bit PCI configuration register - specified by Address. The value written to the PCI configuration register is - returned. This function must guarantee that all PCI read and write operations - are serialized. Extra left bits in OrData are stripped. - - If Address > 0x0FFFFFFF, then ASSERT(). - If Address is not aligned on a 16-bit boundary, then ASSERT(). - If StartBit is greater than 15, then ASSERT(). - If EndBit is greater than 15, then ASSERT(). - If EndBit is less than StartBit, then ASSERT(). - If OrData is larger than the bitmask value range specified by StartBit and EndBit, then ASSERT(). - - @param Address The PCI configuration register to write. - @param StartBit The ordinal of the least significant bit in the bit field. - Range 0..15. - @param EndBit The ordinal of the most significant bit in the bit field. - Range 0..15. - @param OrData The value to OR with the PCI configuration register. - - @return The value written back to the PCI configuration register. - -**/ -UINT16 -EFIAPI -PciBitFieldOr16 ( - IN UINTN Address, - IN UINTN StartBit, - IN UINTN EndBit, - IN UINT16 OrData - ) -{ - return mRunningOnQ35 ? - PciExpressBitFieldOr16 (Address, StartBit, EndBit, OrData) : - PciCf8BitFieldOr16 (Address, StartBit, EndBit, OrData); -} - -/** - Reads a bit field in a 16-bit PCI configuration register, performs a bitwise - AND, and writes the result back to the bit field in the 16-bit register. - - Reads the 16-bit PCI configuration register specified by Address, performs a - bitwise AND between the read result and the value specified by AndData, and - writes the result to the 16-bit PCI configuration register specified by - Address. The value written to the PCI configuration register is returned. - This function must guarantee that all PCI read and write operations are - serialized. Extra left bits in AndData are stripped. - - If Address > 0x0FFFFFFF, then ASSERT(). - If Address is not aligned on a 16-bit boundary, then ASSERT(). - If StartBit is greater than 15, then ASSERT(). - If EndBit is greater than 15, then ASSERT(). - If EndBit is less than StartBit, then ASSERT(). - If AndData is larger than the bitmask value range specified by StartBit and EndBit, then ASSERT(). - - @param Address The PCI configuration register to write. - @param StartBit The ordinal of the least significant bit in the bit field. - Range 0..15. - @param EndBit The ordinal of the most significant bit in the bit field. - Range 0..15. - @param AndData The value to AND with the PCI configuration register. - - @return The value written back to the PCI configuration register. - -**/ -UINT16 -EFIAPI -PciBitFieldAnd16 ( - IN UINTN Address, - IN UINTN StartBit, - IN UINTN EndBit, - IN UINT16 AndData - ) -{ - return mRunningOnQ35 ? - PciExpressBitFieldAnd16 (Address, StartBit, EndBit, AndData) : - PciCf8BitFieldAnd16 (Address, StartBit, EndBit, AndData); -} - -/** - Reads a bit field in a 16-bit port, performs a bitwise AND followed by a - bitwise OR, and writes the result back to the bit field in the - 16-bit port. - - Reads the 16-bit PCI configuration register specified by Address, performs a - bitwise AND followed by a bitwise OR between the read result and - the value specified by AndData, and writes the result to the 16-bit PCI - configuration register specified by Address. The value written to the PCI - configuration register is returned. This function must guarantee that all PCI - read and write operations are serialized. Extra left bits in both AndData and - OrData are stripped. - - If Address > 0x0FFFFFFF, then ASSERT(). - If Address is not aligned on a 16-bit boundary, then ASSERT(). - If StartBit is greater than 15, then ASSERT(). - If EndBit is greater than 15, then ASSERT(). - If EndBit is less than StartBit, then ASSERT(). - If AndData is larger than the bitmask value range specified by StartBit and EndBit, then ASSERT(). - If OrData is larger than the bitmask value range specified by StartBit and EndBit, then ASSERT(). - - @param Address The PCI configuration register to write. - @param StartBit The ordinal of the least significant bit in the bit field. - Range 0..15. - @param EndBit The ordinal of the most significant bit in the bit field. - Range 0..15. - @param AndData The value to AND with the PCI configuration register. - @param OrData The value to OR with the result of the AND operation. - - @return The value written back to the PCI configuration register. - -**/ -UINT16 -EFIAPI -PciBitFieldAndThenOr16 ( - IN UINTN Address, - IN UINTN StartBit, - IN UINTN EndBit, - IN UINT16 AndData, - IN UINT16 OrData - ) -{ - return mRunningOnQ35 ? - PciExpressBitFieldAndThenOr16 (Address, StartBit, EndBit, AndData, OrData) : - PciCf8BitFieldAndThenOr16 (Address, StartBit, EndBit, AndData, OrData); -} - -/** - Reads a 32-bit PCI configuration register. - - Reads and returns the 32-bit PCI configuration register specified by Address. - This function must guarantee that all PCI read and write operations are - serialized. - - If Address > 0x0FFFFFFF, then ASSERT(). - If Address is not aligned on a 32-bit boundary, then ASSERT(). - - @param Address The address that encodes the PCI Bus, Device, Function and - Register. - - @return The read value from the PCI configuration register. - -**/ -UINT32 -EFIAPI -PciRead32 ( - IN UINTN Address - ) -{ - return mRunningOnQ35 ? - PciExpressRead32 (Address) : - PciCf8Read32 (Address); -} - -/** - Writes a 32-bit PCI configuration register. - - Writes the 32-bit PCI configuration register specified by Address with the - value specified by Value. Value is returned. This function must guarantee - that all PCI read and write operations are serialized. - - If Address > 0x0FFFFFFF, then ASSERT(). - If Address is not aligned on a 32-bit boundary, then ASSERT(). - - @param Address The address that encodes the PCI Bus, Device, Function and - Register. - @param Value The value to write. - - @return The value written to the PCI configuration register. - -**/ -UINT32 -EFIAPI -PciWrite32 ( - IN UINTN Address, - IN UINT32 Value - ) -{ - return mRunningOnQ35 ? - PciExpressWrite32 (Address, Value) : - PciCf8Write32 (Address, Value); -} - -/** - Performs a bitwise OR of a 32-bit PCI configuration register with - a 32-bit value. - - Reads the 32-bit PCI configuration register specified by Address, performs a - bitwise OR between the read result and the value specified by - OrData, and writes the result to the 32-bit PCI configuration register - specified by Address. The value written to the PCI configuration register is - returned. This function must guarantee that all PCI read and write operations - are serialized. - - If Address > 0x0FFFFFFF, then ASSERT(). - If Address is not aligned on a 32-bit boundary, then ASSERT(). - - @param Address The address that encodes the PCI Bus, Device, Function and - Register. - @param OrData The value to OR with the PCI configuration register. - - @return The value written back to the PCI configuration register. - -**/ -UINT32 -EFIAPI -PciOr32 ( - IN UINTN Address, - IN UINT32 OrData - ) -{ - return mRunningOnQ35 ? - PciExpressOr32 (Address, OrData) : - PciCf8Or32 (Address, OrData); -} - -/** - Performs a bitwise AND of a 32-bit PCI configuration register with a 32-bit - value. - - Reads the 32-bit PCI configuration register specified by Address, performs a - bitwise AND between the read result and the value specified by AndData, and - writes the result to the 32-bit PCI configuration register specified by - Address. The value written to the PCI configuration register is returned. - This function must guarantee that all PCI read and write operations are - serialized. - - If Address > 0x0FFFFFFF, then ASSERT(). - If Address is not aligned on a 32-bit boundary, then ASSERT(). - - @param Address The address that encodes the PCI Bus, Device, Function and - Register. - @param AndData The value to AND with the PCI configuration register. - - @return The value written back to the PCI configuration register. - -**/ -UINT32 -EFIAPI -PciAnd32 ( - IN UINTN Address, - IN UINT32 AndData - ) -{ - return mRunningOnQ35 ? - PciExpressAnd32 (Address, AndData) : - PciCf8And32 (Address, AndData); -} - -/** - Performs a bitwise AND of a 32-bit PCI configuration register with a 32-bit - value, followed a bitwise OR with another 32-bit value. - - Reads the 32-bit PCI configuration register specified by Address, performs a - bitwise AND between the read result and the value specified by AndData, - performs a bitwise OR between the result of the AND operation and - the value specified by OrData, and writes the result to the 32-bit PCI - configuration register specified by Address. The value written to the PCI - configuration register is returned. This function must guarantee that all PCI - read and write operations are serialized. - - If Address > 0x0FFFFFFF, then ASSERT(). - If Address is not aligned on a 32-bit boundary, then ASSERT(). - - @param Address The address that encodes the PCI Bus, Device, Function and - Register. - @param AndData The value to AND with the PCI configuration register. - @param OrData The value to OR with the result of the AND operation. - - @return The value written back to the PCI configuration register. - -**/ -UINT32 -EFIAPI -PciAndThenOr32 ( - IN UINTN Address, - IN UINT32 AndData, - IN UINT32 OrData - ) -{ - return mRunningOnQ35 ? - PciExpressAndThenOr32 (Address, AndData, OrData) : - PciCf8AndThenOr32 (Address, AndData, OrData); -} - -/** - Reads a bit field of a PCI configuration register. - - Reads the bit field in a 32-bit PCI configuration register. The bit field is - specified by the StartBit and the EndBit. The value of the bit field is - returned. - - If Address > 0x0FFFFFFF, then ASSERT(). - If Address is not aligned on a 32-bit boundary, then ASSERT(). - If StartBit is greater than 31, then ASSERT(). - If EndBit is greater than 31, then ASSERT(). - If EndBit is less than StartBit, then ASSERT(). - - @param Address The PCI configuration register to read. - @param StartBit The ordinal of the least significant bit in the bit field. - Range 0..31. - @param EndBit The ordinal of the most significant bit in the bit field. - Range 0..31. - - @return The value of the bit field read from the PCI configuration register. - -**/ -UINT32 -EFIAPI -PciBitFieldRead32 ( - IN UINTN Address, - IN UINTN StartBit, - IN UINTN EndBit - ) -{ - return mRunningOnQ35 ? - PciExpressBitFieldRead32 (Address, StartBit, EndBit) : - PciCf8BitFieldRead32 (Address, StartBit, EndBit); -} - -/** - Writes a bit field to a PCI configuration register. - - Writes Value to the bit field of the PCI configuration register. The bit - field is specified by the StartBit and the EndBit. All other bits in the - destination PCI configuration register are preserved. The new value of the - 32-bit register is returned. - - If Address > 0x0FFFFFFF, then ASSERT(). - If Address is not aligned on a 32-bit boundary, then ASSERT(). - If StartBit is greater than 31, then ASSERT(). - If EndBit is greater than 31, then ASSERT(). - If EndBit is less than StartBit, then ASSERT(). - If Value is larger than the bitmask value range specified by StartBit and EndBit, then ASSERT(). - - @param Address The PCI configuration register to write. - @param StartBit The ordinal of the least significant bit in the bit field. - Range 0..31. - @param EndBit The ordinal of the most significant bit in the bit field. - Range 0..31. - @param Value The new value of the bit field. - - @return The value written back to the PCI configuration register. - -**/ -UINT32 -EFIAPI -PciBitFieldWrite32 ( - IN UINTN Address, - IN UINTN StartBit, - IN UINTN EndBit, - IN UINT32 Value - ) -{ - return mRunningOnQ35 ? - PciExpressBitFieldWrite32 (Address, StartBit, EndBit, Value) : - PciCf8BitFieldWrite32 (Address, StartBit, EndBit, Value); -} - -/** - Reads a bit field in a 32-bit PCI configuration, performs a bitwise OR, and - writes the result back to the bit field in the 32-bit port. - - Reads the 32-bit PCI configuration register specified by Address, performs a - bitwise OR between the read result and the value specified by - OrData, and writes the result to the 32-bit PCI configuration register - specified by Address. The value written to the PCI configuration register is - returned. This function must guarantee that all PCI read and write operations - are serialized. Extra left bits in OrData are stripped. - - If Address > 0x0FFFFFFF, then ASSERT(). - If Address is not aligned on a 32-bit boundary, then ASSERT(). - If StartBit is greater than 31, then ASSERT(). - If EndBit is greater than 31, then ASSERT(). - If EndBit is less than StartBit, then ASSERT(). - If OrData is larger than the bitmask value range specified by StartBit and EndBit, then ASSERT(). - - @param Address The PCI configuration register to write. - @param StartBit The ordinal of the least significant bit in the bit field. - Range 0..31. - @param EndBit The ordinal of the most significant bit in the bit field. - Range 0..31. - @param OrData The value to OR with the PCI configuration register. - - @return The value written back to the PCI configuration register. - -**/ -UINT32 -EFIAPI -PciBitFieldOr32 ( - IN UINTN Address, - IN UINTN StartBit, - IN UINTN EndBit, - IN UINT32 OrData - ) -{ - return mRunningOnQ35 ? - PciExpressBitFieldOr32 (Address, StartBit, EndBit, OrData) : - PciCf8BitFieldOr32 (Address, StartBit, EndBit, OrData); -} - -/** - Reads a bit field in a 32-bit PCI configuration register, performs a bitwise - AND, and writes the result back to the bit field in the 32-bit register. - - Reads the 32-bit PCI configuration register specified by Address, performs a - bitwise AND between the read result and the value specified by AndData, and - writes the result to the 32-bit PCI configuration register specified by - Address. The value written to the PCI configuration register is returned. - This function must guarantee that all PCI read and write operations are - serialized. Extra left bits in AndData are stripped. - - If Address > 0x0FFFFFFF, then ASSERT(). - If Address is not aligned on a 32-bit boundary, then ASSERT(). - If StartBit is greater than 31, then ASSERT(). - If EndBit is greater than 31, then ASSERT(). - If EndBit is less than StartBit, then ASSERT(). - If AndData is larger than the bitmask value range specified by StartBit and EndBit, then ASSERT(). - - @param Address The PCI configuration register to write. - @param StartBit The ordinal of the least significant bit in the bit field. - Range 0..31. - @param EndBit The ordinal of the most significant bit in the bit field. - Range 0..31. - @param AndData The value to AND with the PCI configuration register. - - @return The value written back to the PCI configuration register. - -**/ -UINT32 -EFIAPI -PciBitFieldAnd32 ( - IN UINTN Address, - IN UINTN StartBit, - IN UINTN EndBit, - IN UINT32 AndData - ) -{ - return mRunningOnQ35 ? - PciExpressBitFieldAnd32 (Address, StartBit, EndBit, AndData) : - PciCf8BitFieldAnd32 (Address, StartBit, EndBit, AndData); -} - -/** - Reads a bit field in a 32-bit port, performs a bitwise AND followed by a - bitwise OR, and writes the result back to the bit field in the - 32-bit port. - - Reads the 32-bit PCI configuration register specified by Address, performs a - bitwise AND followed by a bitwise OR between the read result and - the value specified by AndData, and writes the result to the 32-bit PCI - configuration register specified by Address. The value written to the PCI - configuration register is returned. This function must guarantee that all PCI - read and write operations are serialized. Extra left bits in both AndData and - OrData are stripped. - - If Address > 0x0FFFFFFF, then ASSERT(). - If Address is not aligned on a 32-bit boundary, then ASSERT(). - If StartBit is greater than 31, then ASSERT(). - If EndBit is greater than 31, then ASSERT(). - If EndBit is less than StartBit, then ASSERT(). - If AndData is larger than the bitmask value range specified by StartBit and EndBit, then ASSERT(). - If OrData is larger than the bitmask value range specified by StartBit and EndBit, then ASSERT(). - - @param Address The PCI configuration register to write. - @param StartBit The ordinal of the least significant bit in the bit field. - Range 0..31. - @param EndBit The ordinal of the most significant bit in the bit field. - Range 0..31. - @param AndData The value to AND with the PCI configuration register. - @param OrData The value to OR with the result of the AND operation. - - @return The value written back to the PCI configuration register. - -**/ -UINT32 -EFIAPI -PciBitFieldAndThenOr32 ( - IN UINTN Address, - IN UINTN StartBit, - IN UINTN EndBit, - IN UINT32 AndData, - IN UINT32 OrData - ) -{ - return mRunningOnQ35 ? - PciExpressBitFieldAndThenOr32 (Address, StartBit, EndBit, AndData, OrData) : - PciCf8BitFieldAndThenOr32 (Address, StartBit, EndBit, AndData, OrData); -} - -/** - Reads a range of PCI configuration registers into a caller supplied buffer. - - Reads the range of PCI configuration registers specified by StartAddress and - Size into the buffer specified by Buffer. This function only allows the PCI - configuration registers from a single PCI function to be read. Size is - returned. When possible 32-bit PCI configuration read cycles are used to read - from StartAdress to StartAddress + Size. Due to alignment restrictions, 8-bit - and 16-bit PCI configuration read cycles may be used at the beginning and the - end of the range. - - If StartAddress > 0x0FFFFFFF, then ASSERT(). - If ((StartAddress & 0xFFF) + Size) > 0x1000, then ASSERT(). - If Size > 0 and Buffer is NULL, then ASSERT(). - - @param StartAddress The starting address that encodes the PCI Bus, Device, - Function and Register. - @param Size The size in bytes of the transfer. - @param Buffer The pointer to a buffer receiving the data read. - - @return Size - -**/ -UINTN -EFIAPI -PciReadBuffer ( - IN UINTN StartAddress, - IN UINTN Size, - OUT VOID *Buffer - ) -{ - return mRunningOnQ35 ? - PciExpressReadBuffer (StartAddress, Size, Buffer) : - PciCf8ReadBuffer (StartAddress, Size, Buffer); -} - -/** - Copies the data in a caller supplied buffer to a specified range of PCI - configuration space. - - Writes the range of PCI configuration registers specified by StartAddress and - Size from the buffer specified by Buffer. This function only allows the PCI - configuration registers from a single PCI function to be written. Size is - returned. When possible 32-bit PCI configuration write cycles are used to - write from StartAdress to StartAddress + Size. Due to alignment restrictions, - 8-bit and 16-bit PCI configuration write cycles may be used at the beginning - and the end of the range. - - If StartAddress > 0x0FFFFFFF, then ASSERT(). - If ((StartAddress & 0xFFF) + Size) > 0x1000, then ASSERT(). - If Size > 0 and Buffer is NULL, then ASSERT(). - - @param StartAddress The starting address that encodes the PCI Bus, Device, - Function and Register. - @param Size The size in bytes of the transfer. - @param Buffer The pointer to a buffer containing the data to write. - - @return Size written to StartAddress. - -**/ -UINTN -EFIAPI -PciWriteBuffer ( - IN UINTN StartAddress, - IN UINTN Size, - IN VOID *Buffer - ) -{ - return mRunningOnQ35 ? - PciExpressWriteBuffer (StartAddress, Size, Buffer) : - PciCf8WriteBuffer (StartAddress, Size, Buffer); -} diff --git a/OvmfPkg/Library/EmuVariableFvbLib/EmuVariableFvbLib.c b/OvmfPkg/Library/EmuVariableFvbLib/EmuVariableFvbLib.c deleted file mode 100644 index 9b449a6dec..0000000000 --- a/OvmfPkg/Library/EmuVariableFvbLib/EmuVariableFvbLib.c +++ /dev/null @@ -1,103 +0,0 @@ -/** @file - OVMF platform customization for EMU Variable FVB driver - - Copyright (c) 2009 - 2011, Intel Corporation. All rights reserved.
- This program and the accompanying materials - are licensed and made available under the terms and conditions of the BSD License - which accompanies this distribution. The full text of the license may be found at - http://opensource.org/licenses/bsd-license.php - - THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, - WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. - -**/ - -#include "PiDxe.h" -#include -#include -#include -#include -#include - - -/** - This function will be called following a call to the - EFI_FIRMWARE_VOLUME_BLOCK2_PROTOCOL Read function. - - @param[in] This The EFI_FIRMWARE_VOLUME_BLOCK2_PROTOCOL instance. - @param[in] Lba The starting logical block index - from which to read. - @param[in] Offset Offset into the block at which to begin reading. - @param[in] NumBytes The number of bytes read. - @param[in] Buffer Pointer to the buffer that was read, and will be - returned to the caller. - -**/ -VOID -EFIAPI -PlatformFvbDataRead ( - IN CONST EFI_FIRMWARE_VOLUME_BLOCK2_PROTOCOL *This, - IN EFI_LBA Lba, - IN UINTN Offset, - IN UINTN NumBytes, - IN UINT8 *Buffer - ) -{ -} - - -/** - This function will be called following a call to the - EFI_FIRMWARE_VOLUME_BLOCK2_PROTOCOL Write function. - - @param[in] This EFI_FIRMWARE_VOLUME_BLOCK2_PROTOCOL instance. - @param[in] Lba The starting logical block index to written to. - @param[in] Offset Offset into the block at which to begin writing. - @param[in] NumBytes The number of bytes written. - @param[in] Buffer Pointer to the buffer that was written. - -**/ -VOID -EFIAPI -PlatformFvbDataWritten ( - IN CONST EFI_FIRMWARE_VOLUME_BLOCK2_PROTOCOL *This, - IN EFI_LBA Lba, - IN UINTN Offset, - IN UINTN NumBytes, - IN UINT8 *Buffer - ) -{ - STATIC EFI_EVENT EventToSignal = NULL; - - if (!EfiAtRuntime ()) { - if (EventToSignal == NULL) { - EventToSignal = (EFI_EVENT)(UINTN) PcdGet64 (PcdEmuVariableEvent); - } - if (EventToSignal != NULL) { - gBS->SignalEvent (EventToSignal); - } - } -} - - -/** - This function will be called following a call to the - EFI_FIRMWARE_VOLUME_BLOCK2_PROTOCOL Erase function. - - @param This Indicates the EFI_FIRMWARE_VOLUME_BLOCK2_PROTOCOL - instance. - @param List The variable argument list as documented for - the EFI_FIRMWARE_VOLUME_BLOCK2_PROTOCOL Erase - function. - -**/ -VOID -EFIAPI -PlatformFvbBlocksErased ( - IN CONST EFI_FIRMWARE_VOLUME_BLOCK2_PROTOCOL *This, - IN VA_LIST List - ) -{ -} - - diff --git a/OvmfPkg/Library/EmuVariableFvbLib/EmuVariableFvbLib.inf b/OvmfPkg/Library/EmuVariableFvbLib/EmuVariableFvbLib.inf deleted file mode 100644 index ec6764d760..0000000000 --- a/OvmfPkg/Library/EmuVariableFvbLib/EmuVariableFvbLib.inf +++ /dev/null @@ -1,48 +0,0 @@ -## @file -# OVMF platform customization for EMU Variable FVB driver -# -# This library handles hooks for the EMU Variable FVB driver. -# -# Copyright (c) 2006 - 2010, Intel Corporation. All rights reserved.
-# -# This program and the accompanying materials -# are licensed and made available under the terms and conditions of the BSD License -# which accompanies this distribution. The full text of the license may be found at -# http://opensource.org/licenses/bsd-license.php -# THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, -# WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. -# -# -## - -[Defines] - INF_VERSION = 0x00010005 - BASE_NAME = EmuVariableFvbLib - FILE_GUID = 8a6062ed-7140-4a74-b4ea-fe900e79e24b - MODULE_TYPE = BASE - VERSION_STRING = 1.0 - LIBRARY_CLASS = PlatformFvbLib|DXE_RUNTIME_DRIVER - -# -# The following information is for reference only and not required by the build tools. -# -# VALID_ARCHITECTURES = IA32 X64 IPF EBC -# - -[Sources] - EmuVariableFvbLib.c - -[Packages] - MdePkg/MdePkg.dec - MdeModulePkg/MdeModulePkg.dec - OvmfPkg/OvmfPkg.dec - -[LibraryClasses] - BaseLib - BaseMemoryLib - DebugLib - MemoryAllocationLib - -[Pcd] - gUefiOvmfPkgTokenSpaceGuid.PcdEmuVariableEvent - diff --git a/OvmfPkg/Library/LoadLinuxLib/Ia32/JumpToKernel.nasm b/OvmfPkg/Library/LoadLinuxLib/Ia32/JumpToKernel.nasm deleted file mode 100644 index fcb686c644..0000000000 --- a/OvmfPkg/Library/LoadLinuxLib/Ia32/JumpToKernel.nasm +++ /dev/null @@ -1,49 +0,0 @@ -;------------------------------------------------------------------------------ -; -; Copyright (c) 2006 - 2013, Intel Corporation. All rights reserved.
-; -; This program and the accompanying materials -; are licensed and made available under the terms and conditions of the BSD License -; which accompanies this distribution. The full text of the license may be found at -; http://opensource.org/licenses/bsd-license.php. -; -; THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, -; WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. -; -;------------------------------------------------------------------------------ - - SECTION .text - -;------------------------------------------------------------------------------ -; VOID -; EFIAPI -; JumpToKernel ( -; VOID *KernelStart, -; VOID *KernelBootParams -; ); -;------------------------------------------------------------------------------ -global ASM_PFX(JumpToKernel) -ASM_PFX(JumpToKernel): - - mov esi, [esp + 8] - call DWORD [esp + 4] - ret - -;------------------------------------------------------------------------------ -; VOID -; EFIAPI -; JumpToUefiKernel ( -; EFI_HANDLE ImageHandle, -; EFI_SYSTEM_TABLE *SystemTable, -; VOID *KernelBootParams, -; VOID *KernelStart -; ); -;------------------------------------------------------------------------------ -global ASM_PFX(JumpToUefiKernel) -ASM_PFX(JumpToUefiKernel): - - mov eax, [esp + 12] - mov eax, [eax + 0x264] - add eax, [esp + 16] - jmp eax - diff --git a/OvmfPkg/Library/LoadLinuxLib/Linux.c b/OvmfPkg/Library/LoadLinuxLib/Linux.c deleted file mode 100644 index 68d15377bf..0000000000 --- a/OvmfPkg/Library/LoadLinuxLib/Linux.c +++ /dev/null @@ -1,670 +0,0 @@ -/** @file - - Copyright (c) 2011 - 2014, Intel Corporation. All rights reserved.
- - This program and the accompanying materials - are licensed and made available under the terms and conditions of the BSD License - which accompanies this distribution. The full text of the license may be found at - http://opensource.org/licenses/bsd-license.php - - THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, - WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. - -**/ - -#include "LoadLinuxLib.h" - - -/** - A simple check of the kernel setup image - - An assumption is made that the size of the data is at least the - size of struct boot_params. - - @param[in] KernelSetup - The kernel setup image - - @retval EFI_SUCCESS - The kernel setup looks valid and supported - @retval EFI_INVALID_PARAMETER - KernelSetup was NULL - @retval EFI_UNSUPPORTED - The kernel setup is not valid or supported - -**/ -STATIC -EFI_STATUS -EFIAPI -BasicKernelSetupCheck ( - IN VOID *KernelSetup - ) -{ - return LoadLinuxCheckKernelSetup(KernelSetup, sizeof (struct boot_params)); -} - - -EFI_STATUS -EFIAPI -LoadLinuxCheckKernelSetup ( - IN VOID *KernelSetup, - IN UINTN KernelSetupSize - ) -{ - struct boot_params *Bp; - - if (KernelSetup == NULL) { - return EFI_INVALID_PARAMETER; - } - - if (KernelSetupSize < sizeof (*Bp)) { - return EFI_UNSUPPORTED; - } - - Bp = (struct boot_params*) KernelSetup; - - if ((Bp->hdr.signature != 0xAA55) || // Check boot sector signature - (Bp->hdr.header != SETUP_HDR) || - (Bp->hdr.version < 0x205) || // We only support relocatable kernels - (!Bp->hdr.relocatable_kernel) - ) { - return EFI_UNSUPPORTED; - } else { - return EFI_SUCCESS; - } -} - - -UINTN -EFIAPI -LoadLinuxGetKernelSize ( - IN VOID *KernelSetup, - IN UINTN KernelSize - ) -{ - struct boot_params *Bp; - - if (EFI_ERROR (BasicKernelSetupCheck (KernelSetup))) { - return 0; - } - - Bp = (struct boot_params*) KernelSetup; - - if (Bp->hdr.version > 0x20a) { - return Bp->hdr.init_size; - } else { - // - // Add extra size for kernel decompression - // - return 3 * KernelSize; - } -} - - -VOID* -EFIAPI -LoadLinuxAllocateKernelSetupPages ( - IN UINTN Pages - ) -{ - EFI_STATUS Status; - EFI_PHYSICAL_ADDRESS Address; - - Address = BASE_1GB; - Status = gBS->AllocatePages ( - AllocateMaxAddress, - EfiLoaderData, - Pages, - &Address - ); - if (!EFI_ERROR (Status)) { - return (VOID*)(UINTN) Address; - } else { - return NULL; - } -} - -EFI_STATUS -EFIAPI -LoadLinuxInitializeKernelSetup ( - IN VOID *KernelSetup - ) -{ - EFI_STATUS Status; - UINTN SetupEnd; - struct boot_params *Bp; - - Status = BasicKernelSetupCheck (KernelSetup); - if (EFI_ERROR (Status)) { - return Status; - } - - Bp = (struct boot_params*) KernelSetup; - - SetupEnd = 0x202 + (Bp->hdr.jump & 0xff); - - // - // Clear all but the setup_header - // - ZeroMem (KernelSetup, 0x1f1); - ZeroMem (((UINT8 *)KernelSetup) + SetupEnd, 4096 - SetupEnd); - DEBUG ((EFI_D_INFO, "Cleared kernel setup 0-0x1f1, 0x%Lx-0x1000\n", - (UINT64)SetupEnd)); - - return EFI_SUCCESS; -} - -VOID* -EFIAPI -LoadLinuxAllocateKernelPages ( - IN VOID *KernelSetup, - IN UINTN Pages - ) -{ - EFI_STATUS Status; - EFI_PHYSICAL_ADDRESS KernelAddress; - UINT32 Loop; - struct boot_params *Bp; - - if (EFI_ERROR (BasicKernelSetupCheck (KernelSetup))) { - return NULL; - } - - Bp = (struct boot_params*) KernelSetup; - - for (Loop = 1; Loop < 512; Loop++) { - KernelAddress = MultU64x32 ( - 2 * Bp->hdr.kernel_alignment, - Loop - ); - Status = gBS->AllocatePages ( - AllocateAddress, - EfiLoaderData, - Pages, - &KernelAddress - ); - if (!EFI_ERROR (Status)) { - return (VOID*)(UINTN) KernelAddress; - } - } - - return NULL; -} - - -VOID* -EFIAPI -LoadLinuxAllocateCommandLinePages ( - IN UINTN Pages - ) -{ - EFI_STATUS Status; - EFI_PHYSICAL_ADDRESS Address; - - Address = 0xa0000; - Status = gBS->AllocatePages ( - AllocateMaxAddress, - EfiLoaderData, - Pages, - &Address - ); - if (!EFI_ERROR (Status)) { - return (VOID*)(UINTN) Address; - } else { - return NULL; - } -} - - -VOID* -EFIAPI -LoadLinuxAllocateInitrdPages ( - IN VOID *KernelSetup, - IN UINTN Pages - ) -{ - EFI_STATUS Status; - EFI_PHYSICAL_ADDRESS Address; - - struct boot_params *Bp; - - if (EFI_ERROR (BasicKernelSetupCheck (KernelSetup))) { - return NULL; - } - - Bp = (struct boot_params*) KernelSetup; - - Address = (EFI_PHYSICAL_ADDRESS)(UINTN) Bp->hdr.ramdisk_max; - Status = gBS->AllocatePages ( - AllocateMaxAddress, - EfiLoaderData, - Pages, - &Address - ); - if (!EFI_ERROR (Status)) { - return (VOID*)(UINTN) Address; - } else { - return NULL; - } -} - - -STATIC -VOID -SetupLinuxMemmap ( - IN OUT struct boot_params *Bp - ) -{ - EFI_STATUS Status; - UINT8 TmpMemoryMap[1]; - UINTN MapKey; - UINTN DescriptorSize; - UINT32 DescriptorVersion; - UINTN MemoryMapSize; - EFI_MEMORY_DESCRIPTOR *MemoryMap; - EFI_MEMORY_DESCRIPTOR *MemoryMapPtr; - UINTN Index; - struct efi_info *Efi; - struct e820_entry *LastE820; - struct e820_entry *E820; - UINTN E820EntryCount; - EFI_PHYSICAL_ADDRESS LastEndAddr; - - // - // Get System MemoryMapSize - // - MemoryMapSize = sizeof (TmpMemoryMap); - Status = gBS->GetMemoryMap ( - &MemoryMapSize, - (EFI_MEMORY_DESCRIPTOR *)TmpMemoryMap, - &MapKey, - &DescriptorSize, - &DescriptorVersion - ); - ASSERT (Status == EFI_BUFFER_TOO_SMALL); - // - // Enlarge space here, because we will allocate pool now. - // - MemoryMapSize += EFI_PAGE_SIZE; - Status = gBS->AllocatePool ( - EfiLoaderData, - MemoryMapSize, - (VOID **) &MemoryMap - ); - ASSERT_EFI_ERROR (Status); - - // - // Get System MemoryMap - // - Status = gBS->GetMemoryMap ( - &MemoryMapSize, - MemoryMap, - &MapKey, - &DescriptorSize, - &DescriptorVersion - ); - ASSERT_EFI_ERROR (Status); - - LastE820 = NULL; - E820 = &Bp->e820_map[0]; - E820EntryCount = 0; - LastEndAddr = 0; - MemoryMapPtr = MemoryMap; - for (Index = 0; Index < (MemoryMapSize / DescriptorSize); Index++) { - UINTN E820Type = 0; - - if (MemoryMap->NumberOfPages == 0) { - continue; - } - - switch(MemoryMap->Type) { - case EfiReservedMemoryType: - case EfiRuntimeServicesCode: - case EfiRuntimeServicesData: - case EfiMemoryMappedIO: - case EfiMemoryMappedIOPortSpace: - case EfiPalCode: - E820Type = E820_RESERVED; - break; - - case EfiUnusableMemory: - E820Type = E820_UNUSABLE; - break; - - case EfiACPIReclaimMemory: - E820Type = E820_ACPI; - break; - - case EfiLoaderCode: - case EfiLoaderData: - case EfiBootServicesCode: - case EfiBootServicesData: - case EfiConventionalMemory: - E820Type = E820_RAM; - break; - - case EfiACPIMemoryNVS: - E820Type = E820_NVS; - break; - - default: - DEBUG (( - EFI_D_ERROR, - "Invalid EFI memory descriptor type (0x%x)!\n", - MemoryMap->Type - )); - continue; - } - - if ((LastE820 != NULL) && - (LastE820->type == (UINT32) E820Type) && - (MemoryMap->PhysicalStart == LastEndAddr)) { - LastE820->size += EFI_PAGES_TO_SIZE ((UINTN) MemoryMap->NumberOfPages); - LastEndAddr += EFI_PAGES_TO_SIZE ((UINTN) MemoryMap->NumberOfPages); - } else { - if (E820EntryCount >= ARRAY_SIZE (Bp->e820_map)) { - break; - } - E820->type = (UINT32) E820Type; - E820->addr = MemoryMap->PhysicalStart; - E820->size = EFI_PAGES_TO_SIZE ((UINTN) MemoryMap->NumberOfPages); - LastE820 = E820; - LastEndAddr = E820->addr + E820->size; - E820++; - E820EntryCount++; - } - - // - // Get next item - // - MemoryMap = (EFI_MEMORY_DESCRIPTOR *)((UINTN)MemoryMap + DescriptorSize); - } - Bp->e820_entries = (UINT8) E820EntryCount; - - Efi = &Bp->efi_info; - Efi->efi_systab = (UINT32)(UINTN) gST; - Efi->efi_memdesc_size = (UINT32) DescriptorSize; - Efi->efi_memdesc_version = DescriptorVersion; - Efi->efi_memmap = (UINT32)(UINTN) MemoryMapPtr; - Efi->efi_memmap_size = (UINT32) MemoryMapSize; -#ifdef MDE_CPU_IA32 - Efi->efi_loader_signature = SIGNATURE_32 ('E', 'L', '3', '2'); -#else - Efi->efi_systab_hi = (UINT32) (((UINT64)(UINTN) gST) >> 32); - Efi->efi_memmap_hi = (UINT32) (((UINT64)(UINTN) MemoryMapPtr) >> 32); - Efi->efi_loader_signature = SIGNATURE_32 ('E', 'L', '6', '4'); -#endif - - gBS->ExitBootServices (gImageHandle, MapKey); -} - - -EFI_STATUS -EFIAPI -LoadLinuxSetCommandLine ( - IN OUT VOID *KernelSetup, - IN CHAR8 *CommandLine - ) -{ - EFI_STATUS Status; - struct boot_params *Bp; - - Status = BasicKernelSetupCheck (KernelSetup); - if (EFI_ERROR (Status)) { - return Status; - } - - Bp = (struct boot_params*) KernelSetup; - - Bp->hdr.cmd_line_ptr = (UINT32)(UINTN) CommandLine; - - return EFI_SUCCESS; -} - - -EFI_STATUS -EFIAPI -LoadLinuxSetInitrd ( - IN OUT VOID *KernelSetup, - IN VOID *Initrd, - IN UINTN InitrdSize - ) -{ - EFI_STATUS Status; - struct boot_params *Bp; - - Status = BasicKernelSetupCheck (KernelSetup); - if (EFI_ERROR (Status)) { - return Status; - } - - Bp = (struct boot_params*) KernelSetup; - - Bp->hdr.ramdisk_start = (UINT32)(UINTN) Initrd; - Bp->hdr.ramdisk_len = (UINT32) InitrdSize; - - return EFI_SUCCESS; -} - - -STATIC VOID -FindBits ( - unsigned long Mask, - UINT8 *Pos, - UINT8 *Size - ) -{ - UINT8 First, Len; - - First = 0; - Len = 0; - - if (Mask) { - while (!(Mask & 0x1)) { - Mask = Mask >> 1; - First++; - } - - while (Mask & 0x1) { - Mask = Mask >> 1; - Len++; - } - } - *Pos = First; - *Size = Len; -} - - -STATIC -EFI_STATUS -SetupGraphicsFromGop ( - struct screen_info *Si, - EFI_GRAPHICS_OUTPUT_PROTOCOL *Gop - ) -{ - EFI_GRAPHICS_OUTPUT_MODE_INFORMATION *Info; - EFI_STATUS Status; - UINTN Size; - - Status = Gop->QueryMode(Gop, Gop->Mode->Mode, &Size, &Info); - if (EFI_ERROR (Status)) { - return Status; - } - - /* We found a GOP */ - - /* EFI framebuffer */ - Si->orig_video_isVGA = 0x70; - - Si->orig_x = 0; - Si->orig_y = 0; - Si->orig_video_page = 0; - Si->orig_video_mode = 0; - Si->orig_video_cols = 0; - Si->orig_video_lines = 0; - Si->orig_video_ega_bx = 0; - Si->orig_video_points = 0; - - Si->lfb_base = (UINT32) Gop->Mode->FrameBufferBase; - Si->lfb_size = (UINT32) Gop->Mode->FrameBufferSize; - Si->lfb_width = (UINT16) Info->HorizontalResolution; - Si->lfb_height = (UINT16) Info->VerticalResolution; - Si->pages = 1; - Si->vesapm_seg = 0; - Si->vesapm_off = 0; - - if (Info->PixelFormat == PixelRedGreenBlueReserved8BitPerColor) { - Si->lfb_depth = 32; - Si->red_size = 8; - Si->red_pos = 0; - Si->green_size = 8; - Si->green_pos = 8; - Si->blue_size = 8; - Si->blue_pos = 16; - Si->rsvd_size = 8; - Si->rsvd_pos = 24; - Si->lfb_linelength = (UINT16) (Info->PixelsPerScanLine * 4); - - } else if (Info->PixelFormat == PixelBlueGreenRedReserved8BitPerColor) { - Si->lfb_depth = 32; - Si->red_size = 8; - Si->red_pos = 16; - Si->green_size = 8; - Si->green_pos = 8; - Si->blue_size = 8; - Si->blue_pos = 0; - Si->rsvd_size = 8; - Si->rsvd_pos = 24; - Si->lfb_linelength = (UINT16) (Info->PixelsPerScanLine * 4); - } else if (Info->PixelFormat == PixelBitMask) { - FindBits(Info->PixelInformation.RedMask, - &Si->red_pos, &Si->red_size); - FindBits(Info->PixelInformation.GreenMask, - &Si->green_pos, &Si->green_size); - FindBits(Info->PixelInformation.BlueMask, - &Si->blue_pos, &Si->blue_size); - FindBits(Info->PixelInformation.ReservedMask, - &Si->rsvd_pos, &Si->rsvd_size); - Si->lfb_depth = Si->red_size + Si->green_size + - Si->blue_size + Si->rsvd_size; - Si->lfb_linelength = (UINT16) ((Info->PixelsPerScanLine * Si->lfb_depth) / 8); - } else { - Si->lfb_depth = 4; - Si->red_size = 0; - Si->red_pos = 0; - Si->green_size = 0; - Si->green_pos = 0; - Si->blue_size = 0; - Si->blue_pos = 0; - Si->rsvd_size = 0; - Si->rsvd_pos = 0; - Si->lfb_linelength = Si->lfb_width / 2; - } - - return Status; -} - - -STATIC -EFI_STATUS -SetupGraphics ( - IN OUT struct boot_params *Bp - ) -{ - EFI_STATUS Status; - EFI_HANDLE *HandleBuffer; - UINTN HandleCount; - UINTN Index; - EFI_GRAPHICS_OUTPUT_PROTOCOL *Gop; - - ZeroMem ((VOID*)&Bp->screen_info, sizeof(Bp->screen_info)); - - Status = gBS->LocateHandleBuffer ( - ByProtocol, - &gEfiGraphicsOutputProtocolGuid, - NULL, - &HandleCount, - &HandleBuffer - ); - if (!EFI_ERROR (Status)) { - for (Index = 0; Index < HandleCount; Index++) { - Status = gBS->HandleProtocol ( - HandleBuffer[Index], - &gEfiGraphicsOutputProtocolGuid, - (VOID*) &Gop - ); - if (EFI_ERROR (Status)) { - continue; - } - - Status = SetupGraphicsFromGop (&Bp->screen_info, Gop); - if (!EFI_ERROR (Status)) { - FreePool (HandleBuffer); - return EFI_SUCCESS; - } - } - - FreePool (HandleBuffer); - } - - return EFI_NOT_FOUND; -} - - -STATIC -EFI_STATUS -SetupLinuxBootParams ( - IN OUT struct boot_params *Bp - ) -{ - SetupGraphics (Bp); - - SetupLinuxMemmap (Bp); - - return EFI_SUCCESS; -} - - -EFI_STATUS -EFIAPI -LoadLinux ( - IN VOID *Kernel, - IN OUT VOID *KernelSetup - ) -{ - EFI_STATUS Status; - struct boot_params *Bp; - - Status = BasicKernelSetupCheck (KernelSetup); - if (EFI_ERROR (Status)) { - return Status; - } - - Bp = (struct boot_params *) KernelSetup; - - if (Bp->hdr.version < 0x205 || !Bp->hdr.relocatable_kernel) { - // - // We only support relocatable kernels - // - return EFI_UNSUPPORTED; - } - - InitLinuxDescriptorTables (); - - Bp->hdr.code32_start = (UINT32)(UINTN) Kernel; - if (Bp->hdr.version >= 0x20c && Bp->hdr.handover_offset && - (Bp->hdr.xloadflags & (sizeof (UINTN) == 4 ? BIT2 : BIT3))) { - DEBUG ((EFI_D_INFO, "Jumping to kernel EFI handover point at ofs %x\n", Bp->hdr.handover_offset)); - - DisableInterrupts (); - JumpToUefiKernel ((VOID*) gImageHandle, (VOID*) gST, KernelSetup, Kernel); - } - - // - // Old kernels without EFI handover protocol - // - SetupLinuxBootParams (KernelSetup); - - DEBUG ((EFI_D_INFO, "Jumping to kernel\n")); - DisableInterrupts (); - SetLinuxDescriptorTables (); - JumpToKernel (Kernel, (VOID*) KernelSetup); - - return EFI_SUCCESS; -} - diff --git a/OvmfPkg/Library/LoadLinuxLib/LinuxGdt.c b/OvmfPkg/Library/LoadLinuxLib/LinuxGdt.c deleted file mode 100644 index 4e20436246..0000000000 --- a/OvmfPkg/Library/LoadLinuxLib/LinuxGdt.c +++ /dev/null @@ -1,181 +0,0 @@ -/** @file - Initialize GDT for Linux. - - Copyright (c) 2006 - 2012, Intel Corporation. All rights reserved.
- This program and the accompanying materials - are licensed and made available under the terms and conditions of the BSD License - which accompanies this distribution. The full text of the license may be found at - http://opensource.org/licenses/bsd-license.php - - THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, - WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. - -**/ - -#include "LoadLinuxLib.h" - - -// -// Local structure definitions -// - -#pragma pack (1) - -// -// Global Descriptor Entry structures -// - -typedef struct _GDT_ENTRY { - UINT16 Limit15_0; - UINT16 Base15_0; - UINT8 Base23_16; - UINT8 Type; - UINT8 Limit19_16_and_flags; - UINT8 Base31_24; -} GDT_ENTRY; - -typedef -struct _GDT_ENTRIES { - GDT_ENTRY Null; - GDT_ENTRY Null2; - GDT_ENTRY Linear; - GDT_ENTRY LinearCode; - GDT_ENTRY TaskSegment; - GDT_ENTRY Spare4; - GDT_ENTRY Spare5; -} GDT_ENTRIES; - -#pragma pack () - -STATIC GDT_ENTRIES *mGdt = NULL; - -// -// Global descriptor table (GDT) Template -// -STATIC GDT_ENTRIES GdtTemplate = { - // - // Null - // - { - 0x0, // limit 15:0 - 0x0, // base 15:0 - 0x0, // base 23:16 - 0x0, // type - 0x0, // limit 19:16, flags - 0x0, // base 31:24 - }, - // - // Null2 - // - { - 0x0, // limit 15:0 - 0x0, // base 15:0 - 0x0, // base 23:16 - 0x0, // type - 0x0, // limit 19:16, flags - 0x0, // base 31:24 - }, - // - // Linear - // - { - 0x0FFFF, // limit 0xFFFFF - 0x0, // base 0 - 0x0, - 0x09A, // present, ring 0, data, expand-up, writable - 0x0CF, // page-granular, 32-bit - 0x0, - }, - // - // LinearCode - // - { - 0x0FFFF, // limit 0xFFFFF - 0x0, // base 0 - 0x0, - 0x092, // present, ring 0, data, expand-up, writable - 0x0CF, // page-granular, 32-bit - 0x0, - }, - // - // TaskSegment - // - { - 0x0, // limit 0 - 0x0, // base 0 - 0x0, - 0x089, // ? - 0x080, // ? - 0x0, - }, - // - // Spare4 - // - { - 0x0, // limit 0 - 0x0, // base 0 - 0x0, - 0x0, // present, ring 0, data, expand-up, writable - 0x0, // page-granular, 32-bit - 0x0, - }, - // - // Spare5 - // - { - 0x0, // limit 0 - 0x0, // base 0 - 0x0, - 0x0, // present, ring 0, data, expand-up, writable - 0x0, // page-granular, 32-bit - 0x0, - }, -}; - -/** - Initialize Global Descriptor Table. - -**/ -VOID -InitLinuxDescriptorTables ( - VOID - ) -{ - // - // Allocate Runtime Data for the GDT - // - mGdt = AllocateRuntimePool (sizeof (GdtTemplate) + 8); - ASSERT (mGdt != NULL); - mGdt = ALIGN_POINTER (mGdt, 8); - - // - // Initialize all GDT entries - // - CopyMem (mGdt, &GdtTemplate, sizeof (GdtTemplate)); - -} - -/** - Initialize Global Descriptor Table. - -**/ -VOID -SetLinuxDescriptorTables ( - VOID - ) -{ - IA32_DESCRIPTOR GdtPtr; - IA32_DESCRIPTOR IdtPtr; - - // - // Write GDT register - // - GdtPtr.Base = (UINT32)(UINTN)(VOID*) mGdt; - GdtPtr.Limit = (UINT16) (sizeof (GdtTemplate) - 1); - AsmWriteGdtr (&GdtPtr); - - IdtPtr.Base = (UINT32) 0; - IdtPtr.Limit = (UINT16) 0; - AsmWriteIdtr (&IdtPtr); -} - diff --git a/OvmfPkg/Library/LoadLinuxLib/LoadLinuxLib.h b/OvmfPkg/Library/LoadLinuxLib/LoadLinuxLib.h deleted file mode 100644 index 045cbf9b2f..0000000000 --- a/OvmfPkg/Library/LoadLinuxLib/LoadLinuxLib.h +++ /dev/null @@ -1,59 +0,0 @@ -/** @file - Boot UEFI Linux. - - Copyright (c) 2008 - 2013, Intel Corporation. All rights reserved.
- - This program and the accompanying materials - are licensed and made available under the terms and conditions of the BSD License - which accompanies this distribution. The full text of the license may be found at - http://opensource.org/licenses/bsd-license.php - - THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, - WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. - -**/ - -#ifndef _LOAD_LINUX_LIB_INCLUDED_ -#define _LOAD_LINUX_LIB_INCLUDED_ - -#include -#include -#include -#include -#include -#include -#include -#include - -#include - -#include - -VOID -EFIAPI -JumpToKernel ( - VOID *KernelStart, - VOID *KernelBootParams - ); - -VOID -EFIAPI -JumpToUefiKernel ( - EFI_HANDLE ImageHandle, - EFI_SYSTEM_TABLE *SystemTable, - VOID *KernelBootParams, - VOID *KernelStart - ); - -VOID -InitLinuxDescriptorTables ( - VOID - ); - -VOID -SetLinuxDescriptorTables ( - VOID - ); - -#endif - diff --git a/OvmfPkg/Library/LoadLinuxLib/LoadLinuxLib.inf b/OvmfPkg/Library/LoadLinuxLib/LoadLinuxLib.inf deleted file mode 100644 index 12d2f4f084..0000000000 --- a/OvmfPkg/Library/LoadLinuxLib/LoadLinuxLib.inf +++ /dev/null @@ -1,48 +0,0 @@ -## @file -# -# Copyright (c) 2008 - 2012, Intel Corporation. All rights reserved.
-# -# This program and the accompanying materials -# are licensed and made available under the terms and conditions of the BSD License -# which accompanies this distribution. The full text of the license may be found at -# http://opensource.org/licenses/bsd-license.php -# -# THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, -# WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. -# -## - -[Defines] - INF_VERSION = 0x00010005 - BASE_NAME = LoadLinuxLib - FILE_GUID = eaec1915-65a0-43a9-bf0b-a76438da61db - MODULE_TYPE = BASE - VERSION_STRING = 1.0 - LIBRARY_CLASS = LoadLinuxLib - -# -# The following information is for reference only and not required by the build tools. -# -# VALID_ARCHITECTURES = IA32 X64 -# - -[Sources.common] - Linux.c - LinuxGdt.c - -[Sources.IA32] - Ia32/JumpToKernel.nasm - -[Sources.X64] - X64/JumpToKernel.nasm - -[Packages] - MdePkg/MdePkg.dec - OvmfPkg/OvmfPkg.dec - -[LibraryClasses] - BaseLib - DebugLib - MemoryAllocationLib - BaseMemoryLib - diff --git a/OvmfPkg/Library/LoadLinuxLib/X64/JumpToKernel.nasm b/OvmfPkg/Library/LoadLinuxLib/X64/JumpToKernel.nasm deleted file mode 100644 index 128dcef0f6..0000000000 --- a/OvmfPkg/Library/LoadLinuxLib/X64/JumpToKernel.nasm +++ /dev/null @@ -1,93 +0,0 @@ -;------------------------------------------------------------------------------ -; -; Copyright (c) 2006 - 2013, Intel Corporation. All rights reserved.
-; -; This program and the accompanying materials -; are licensed and made available under the terms and conditions of the BSD License -; which accompanies this distribution. The full text of the license may be found at -; http://opensource.org/licenses/bsd-license.php. -; -; THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, -; WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. -; -;------------------------------------------------------------------------------ - - DEFAULT REL - SECTION .text - -;------------------------------------------------------------------------------ -; VOID -; EFIAPI -; JumpToKernel ( -; VOID *KernelStart, // rcx -; VOID *KernelBootParams // rdx -; ); -;------------------------------------------------------------------------------ -global ASM_PFX(JumpToKernel) -ASM_PFX(JumpToKernel): - - ; Set up for executing kernel. BP in %esi, entry point on the stack - ; (64-bit when the 'ret' will use it as 32-bit, but we're little-endian) - mov rsi, rdx - push rcx - - ; Jump into the compatibility mode CS - push 0x10 - lea rax, [.0] - push rax - DB 0x48, 0xcb ; retfq - -.0: - ; Now in compatibility mode. - - DB 0xb8, 0x18, 0x0, 0x0, 0x0 ; movl $0x18, %eax - DB 0x8e, 0xd8 ; movl %eax, %ds - DB 0x8e, 0xc0 ; movl %eax, %es - DB 0x8e, 0xe0 ; movl %eax, %fs - DB 0x8e, 0xe8 ; movl %eax, %gs - DB 0x8e, 0xd0 ; movl %eax, %ss - - ; Disable paging - DB 0xf, 0x20, 0xc0 ; movl %cr0, %eax - DB 0xf, 0xba, 0xf8, 0x1f ; btcl $31, %eax - DB 0xf, 0x22, 0xc0 ; movl %eax, %cr0 - - ; Disable long mode in EFER - DB 0xb9, 0x80, 0x0, 0x0, 0xc0 ; movl $0x0c0000080, %ecx - DB 0xf, 0x32 ; rdmsr - DB 0xf, 0xba, 0xf8, 0x8 ; btcl $8, %eax - DB 0xf, 0x30 ; wrmsr - - ; Disable PAE - DB 0xf, 0x20, 0xe0 ; movl %cr4, %eax - DB 0xf, 0xba, 0xf8, 0x5 ; btcl $5, %eax - DB 0xf, 0x22, 0xe0 ; movl %eax, %cr4 - - DB 0x31, 0xed ; xor %ebp, %ebp - DB 0x31, 0xff ; xor %edi, %edi - DB 0x31, 0xdb ; xor %ebx, %ebx - DB 0xc3 ; ret - -;------------------------------------------------------------------------------ -; VOID -; EFIAPI -; JumpToUefiKernel ( -; EFI_HANDLE ImageHandle, // rcx -; EFI_SYSTEM_TABLE *SystemTable, // rdx -; VOID *KernelBootParams // r8 -; VOID *KernelStart, // r9 -; ); -;------------------------------------------------------------------------------ -global ASM_PFX(JumpToUefiKernel) -ASM_PFX(JumpToUefiKernel): - - mov rdi, rcx - mov rsi, rdx - mov rdx, r8 - xor rax, rax - mov eax, [r8 + 0x264] - add r9, rax - add r9, 0x200 - call r9 - ret - diff --git a/OvmfPkg/Library/LockBoxLib/LockBoxBase.c b/OvmfPkg/Library/LockBoxLib/LockBoxBase.c deleted file mode 100644 index 8f367701f3..0000000000 --- a/OvmfPkg/Library/LockBoxLib/LockBoxBase.c +++ /dev/null @@ -1,42 +0,0 @@ -/** @file - - Copyright (c) 2006 - 2014, Intel Corporation. All rights reserved.
- - This program and the accompanying materials - are licensed and made available under the terms and conditions of the BSD License - which accompanies this distribution. The full text of the license may be found at - http://opensource.org/licenses/bsd-license.php. - - THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, - WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. - -**/ - -#include - -#include -#include - -/** - Allocates a buffer of type EfiACPIMemoryNVS. - - Allocates the number bytes specified by AllocationSize of type - EfiACPIMemoryNVS and returns a pointer to the allocated buffer. - If AllocationSize is 0, then a valid buffer of 0 size is - returned. If there is not enough memory remaining to satisfy - the request, then NULL is returned. - - @param AllocationSize The number of bytes to allocate. - - @return A pointer to the allocated buffer or NULL if allocation fails. - -**/ -VOID * -EFIAPI -AllocateAcpiNvsPool ( - IN UINTN AllocationSize - ) -{ - ASSERT_EFI_ERROR (RETURN_UNSUPPORTED); - return NULL; -} diff --git a/OvmfPkg/Library/LockBoxLib/LockBoxBaseLib.inf b/OvmfPkg/Library/LockBoxLib/LockBoxBaseLib.inf deleted file mode 100644 index 81c893e4cb..0000000000 --- a/OvmfPkg/Library/LockBoxLib/LockBoxBaseLib.inf +++ /dev/null @@ -1,47 +0,0 @@ -## @file -# -# Library implementing the LockBox interface for OVMF -# -# Copyright (C) 2013, Red Hat, Inc. -# Copyright (c) 2014, Intel Corporation. All rights reserved.
-# -# This program and the accompanying materials are licensed and made available -# under the terms and conditions of the BSD License which accompanies this -# distribution. The full text of the license may be found at -# http://opensource.org/licenses/bsd-license.php -# -# THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, -# WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR -# IMPLIED. -# -## - -[Defines] - INF_VERSION = 0x00010005 - BASE_NAME = LockBoxBaseLib - FILE_GUID = 17CA9B37-5BAB-492C-A09C-7121FBE34CE6 - MODULE_TYPE = BASE - VERSION_STRING = 1.0 - LIBRARY_CLASS = LockBoxLib - - CONSTRUCTOR = LockBoxLibInitialize - -[Sources] - LockBoxBase.c - LockBoxLib.c - -[Packages] - MdePkg/MdePkg.dec - MdeModulePkg/MdeModulePkg.dec - OvmfPkg/OvmfPkg.dec - -[LibraryClasses] - BaseMemoryLib - DebugLib - -[Pcd] - gUefiOvmfPkgTokenSpaceGuid.PcdOvmfLockBoxStorageBase - gUefiOvmfPkgTokenSpaceGuid.PcdOvmfLockBoxStorageSize - -[FeaturePcd] - gUefiOvmfPkgTokenSpaceGuid.PcdSmmSmramRequire diff --git a/OvmfPkg/Library/LockBoxLib/LockBoxDxe.c b/OvmfPkg/Library/LockBoxLib/LockBoxDxe.c deleted file mode 100644 index 3da9cd21e5..0000000000 --- a/OvmfPkg/Library/LockBoxLib/LockBoxDxe.c +++ /dev/null @@ -1,147 +0,0 @@ -/** @file - - Copyright (c) 2006 - 2016, Intel Corporation. All rights reserved.
- - This program and the accompanying materials - are licensed and made available under the terms and conditions of the BSD License - which accompanies this distribution. The full text of the license may be found at - http://opensource.org/licenses/bsd-license.php. - - THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, - WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. - -**/ - -#include - -#include -#include -#include -#include -#include -#include -#include -#include - -/** - Allocate memory below 4G memory address. - - This function allocates memory below 4G memory address. - - @param MemoryType Memory type of memory to allocate. - @param Size Size of memory to allocate. - - @return Allocated address for output. - -**/ -STATIC -VOID * -AllocateMemoryBelow4G ( - IN EFI_MEMORY_TYPE MemoryType, - IN UINTN Size - ) -{ - UINTN Pages; - EFI_PHYSICAL_ADDRESS Address; - EFI_STATUS Status; - VOID* Buffer; - UINTN AllocRemaining; - - Pages = EFI_SIZE_TO_PAGES (Size); - Address = 0xffffffff; - - // - // Since we need to use gBS->AllocatePages to get a buffer below - // 4GB, there is a good chance that space will be wasted for very - // small allocation. We keep track of unused portions of the page - // allocations, and use these to allocate memory for small buffers. - // - ASSERT (mLockBoxGlobal->Signature == LOCK_BOX_GLOBAL_SIGNATURE); - if ((UINTN) mLockBoxGlobal->SubPageRemaining >= Size) { - Buffer = (VOID*)(UINTN) mLockBoxGlobal->SubPageBuffer; - mLockBoxGlobal->SubPageBuffer += (UINT32) Size; - mLockBoxGlobal->SubPageRemaining -= (UINT32) Size; - return Buffer; - } - - Status = gBS->AllocatePages ( - AllocateMaxAddress, - MemoryType, - Pages, - &Address - ); - if (EFI_ERROR (Status)) { - return NULL; - } - - Buffer = (VOID *) (UINTN) Address; - ZeroMem (Buffer, EFI_PAGES_TO_SIZE (Pages)); - - AllocRemaining = EFI_PAGES_TO_SIZE (Pages) - Size; - if (AllocRemaining > (UINTN) mLockBoxGlobal->SubPageRemaining) { - mLockBoxGlobal->SubPageBuffer = (UINT32) (Address + Size); - mLockBoxGlobal->SubPageRemaining = (UINT32) AllocRemaining; - } - - return Buffer; -} - - -/** - Allocates a buffer of type EfiACPIMemoryNVS. - - Allocates the number bytes specified by AllocationSize of type - EfiACPIMemoryNVS and returns a pointer to the allocated buffer. - If AllocationSize is 0, then a valid buffer of 0 size is - returned. If there is not enough memory remaining to satisfy - the request, then NULL is returned. - - @param AllocationSize The number of bytes to allocate. - - @return A pointer to the allocated buffer or NULL if allocation fails. - -**/ -VOID * -EFIAPI -AllocateAcpiNvsPool ( - IN UINTN AllocationSize - ) -{ - return AllocateMemoryBelow4G (EfiACPIMemoryNVS, AllocationSize); -} - - -EFI_STATUS -EFIAPI -LockBoxDxeLibInitialize ( - IN EFI_HANDLE ImageHandle, - IN EFI_SYSTEM_TABLE *SystemTable - ) -{ - EFI_STATUS Status; - VOID *Interface; - - Status = LockBoxLibInitialize (); - if (!EFI_ERROR (Status)) { - if (QemuFwCfgS3Enabled ()) { - // - // When S3 enabled, the first driver run with this library linked will - // have this library constructor to install LockBox protocol on the - // ImageHandle. As other drivers may have gEfiLockBoxProtocolGuid - // dependency, the first driver should run before them. - // - Status = gBS->LocateProtocol (&gEfiLockBoxProtocolGuid, NULL, &Interface); - if (EFI_ERROR (Status)) { - Status = gBS->InstallProtocolInterface ( - &ImageHandle, - &gEfiLockBoxProtocolGuid, - EFI_NATIVE_INTERFACE, - NULL - ); - ASSERT_EFI_ERROR (Status); - } - } - } - - return Status; -} diff --git a/OvmfPkg/Library/LockBoxLib/LockBoxDxeLib.inf b/OvmfPkg/Library/LockBoxLib/LockBoxDxeLib.inf deleted file mode 100644 index eb03f4f546..0000000000 --- a/OvmfPkg/Library/LockBoxLib/LockBoxDxeLib.inf +++ /dev/null @@ -1,53 +0,0 @@ -## @file -# -# Library implementing the LockBox interface for OVMF -# -# Copyright (C) 2013, Red Hat, Inc. -# Copyright (c) 2014 - 2016, Intel Corporation. All rights reserved.
-# -# This program and the accompanying materials are licensed and made available -# under the terms and conditions of the BSD License which accompanies this -# distribution. The full text of the license may be found at -# http://opensource.org/licenses/bsd-license.php -# -# THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, -# WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR -# IMPLIED. -# -## - -[Defines] - INF_VERSION = 0x00010005 - BASE_NAME = LockBoxDxeLib - FILE_GUID = f61c9a34-2e18-44ce-af2f-21a998e64fda - MODULE_TYPE = DXE_DRIVER - VERSION_STRING = 1.0 - LIBRARY_CLASS = LockBoxLib - - CONSTRUCTOR = LockBoxDxeLibInitialize - -[Sources] - LockBoxDxe.c - LockBoxLib.c - -[Packages] - MdePkg/MdePkg.dec - MdeModulePkg/MdeModulePkg.dec - OvmfPkg/OvmfPkg.dec - -[LibraryClasses] - BaseMemoryLib - DebugLib - UefiBootServicesTableLib - QemuFwCfgLib - QemuFwCfgS3Lib - -[Protocols] - gEfiLockBoxProtocolGuid ## SOMETIMES_PRODUCES - -[Pcd] - gUefiOvmfPkgTokenSpaceGuid.PcdOvmfLockBoxStorageBase - gUefiOvmfPkgTokenSpaceGuid.PcdOvmfLockBoxStorageSize - -[FeaturePcd] - gUefiOvmfPkgTokenSpaceGuid.PcdSmmSmramRequire diff --git a/OvmfPkg/Library/LockBoxLib/LockBoxLib.c b/OvmfPkg/Library/LockBoxLib/LockBoxLib.c deleted file mode 100644 index 45481b9230..0000000000 --- a/OvmfPkg/Library/LockBoxLib/LockBoxLib.c +++ /dev/null @@ -1,378 +0,0 @@ -/** @file - - Library implementing the LockBox interface for OVMF - - Copyright (C) 2013, Red Hat, Inc. - Copyright (c) 2010 - 2014, Intel Corporation. All rights reserved.
- - This program and the accompanying materials are licensed and made available - under the terms and conditions of the BSD License which accompanies this - distribution. The full text of the license may be found at - http://opensource.org/licenses/bsd-license.php - - THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, WITHOUT - WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. - -**/ - -#include -#include -#include -#include -#include -#include - -#pragma pack(1) -typedef struct { - EFI_GUID Guid; - EFI_PHYSICAL_ADDRESS OrigAddress; - EFI_PHYSICAL_ADDRESS CopyAddress; - UINT32 Size; - UINT64 Attributes; -} LOCK_BOX_ENTRY; -#pragma pack() - -LOCK_BOX_GLOBAL *mLockBoxGlobal = NULL; -STATIC LOCK_BOX_ENTRY *StartOfEntries = NULL; -STATIC LOCK_BOX_ENTRY *EndOfEntries = NULL; - -RETURN_STATUS -EFIAPI -LockBoxLibInitialize ( - VOID - ) -{ - UINTN NumEntries; - - ASSERT (!FeaturePcdGet (PcdSmmSmramRequire)); - - if (PcdGet32 (PcdOvmfLockBoxStorageSize) < sizeof (LOCK_BOX_GLOBAL)) { - return RETURN_UNSUPPORTED; - } - - mLockBoxGlobal = (LOCK_BOX_GLOBAL *)(UINTN) PcdGet32 (PcdOvmfLockBoxStorageBase); - StartOfEntries = ((LOCK_BOX_ENTRY *) (mLockBoxGlobal + 1)); - NumEntries = ((PcdGet32 (PcdOvmfLockBoxStorageSize) - sizeof (LOCK_BOX_GLOBAL)) / - sizeof (LOCK_BOX_ENTRY)); - EndOfEntries = StartOfEntries + NumEntries; - if (mLockBoxGlobal->Signature != LOCK_BOX_GLOBAL_SIGNATURE) { - // - // Note: This code depends on the lock box being cleared in early - // PEI before usage, so the SubPageBuffer and SubPageRemaining - // fields don't need to be set to 0. - // - mLockBoxGlobal->Signature = LOCK_BOX_GLOBAL_SIGNATURE; - } - return RETURN_SUCCESS; -} - - -/** - Find LockBox entry based on GUID. - - @param[in] Guid The GUID to search for. - - @return Address of the LOCK_BOX_ENTRY found. - - If NULL, then the item was not found, and there is no space - left to store a new item. - - If non-NULL and LOCK_BOX_ENTRY.Size == 0, then the item was not - found, but a new item can be inserted at the returned location. - - If non-NULL and LOCK_BOX_ENTRY.Size > 0, then the item was found. -**/ -STATIC -LOCK_BOX_ENTRY * -EFIAPI -FindHeaderByGuid ( - IN CONST EFI_GUID *Guid - ) -{ - LOCK_BOX_ENTRY *Header; - - for (Header = StartOfEntries; Header < EndOfEntries; Header++) { - if (Header->Size == 0 || CompareGuid (Guid, &Header->Guid)) { - return Header; - } - } - - return NULL; -} - - -/** - This function will save confidential information to lockbox. - - @param Guid the guid to identify the confidential information - @param Buffer the address of the confidential information - @param Length the length of the confidential information - - @retval RETURN_SUCCESS the information is saved successfully. - @retval RETURN_INVALID_PARAMETER the Guid is NULL, or Buffer is NULL, or - Length is 0 - @retval RETURN_ALREADY_STARTED the requested GUID already exist. - @retval RETURN_OUT_OF_RESOURCES no enough resource to save the information. - @retval RETURN_ACCESS_DENIED it is too late to invoke this interface - @retval RETURN_NOT_STARTED it is too early to invoke this interface - @retval RETURN_UNSUPPORTED the service is not supported by - implementaion. -**/ -RETURN_STATUS -EFIAPI -SaveLockBox ( - IN GUID *Guid, - IN VOID *Buffer, - IN UINTN Length - ) -{ - LOCK_BOX_ENTRY *Header; - VOID *CopyBuffer; - - DEBUG ((DEBUG_VERBOSE, "%a: Guid=%g Buffer=%p Length=0x%x\n", __FUNCTION__, - Guid, Buffer, (UINT32) Length)); - - if (Guid == NULL || Buffer == NULL || Length == 0) { - return RETURN_INVALID_PARAMETER; - } - - if (Length > 0xFFFFFFFF) { - return RETURN_OUT_OF_RESOURCES; - } - - Header = FindHeaderByGuid (Guid); - if (Header == NULL) { - return RETURN_OUT_OF_RESOURCES; - } - - if (Header->Size > 0) { - return RETURN_ALREADY_STARTED; - } - - CopyBuffer = AllocateAcpiNvsPool (Length); - if (CopyBuffer == NULL) { - return RETURN_OUT_OF_RESOURCES; - } - - // - // overwrite the current terminator header with new metadata - // - CopyGuid (&Header->Guid, Guid); - Header->OrigAddress = (UINTN) Buffer; - Header->CopyAddress = (UINTN) CopyBuffer; - Header->Size = (UINT32) Length; - Header->Attributes = 0; - - // - // copy contents - // - CopyMem (CopyBuffer, Buffer, Length); - - return RETURN_SUCCESS; -} - - -/** - This function will set lockbox attributes. - - @param Guid the guid to identify the confidential information - @param Attributes the attributes of the lockbox - - @retval RETURN_SUCCESS the information is saved successfully. - @retval RETURN_INVALID_PARAMETER attributes is invalid. - @retval RETURN_NOT_FOUND the requested GUID not found. - @retval RETURN_ACCESS_DENIED it is too late to invoke this interface - @retval RETURN_NOT_STARTED it is too early to invoke this interface - @retval RETURN_UNSUPPORTED the service is not supported by - implementaion. -**/ -RETURN_STATUS -EFIAPI -SetLockBoxAttributes ( - IN GUID *Guid, - IN UINT64 Attributes - ) -{ - LOCK_BOX_ENTRY *Header; - - DEBUG ((DEBUG_VERBOSE, "%a: Guid=%g Attributes=0x%Lx\n", __FUNCTION__, Guid, - Attributes)); - - if (Guid == NULL) { - return RETURN_INVALID_PARAMETER; - } - - Header = FindHeaderByGuid (Guid); - if (!Header || Header->Size == 0) { - return RETURN_NOT_FOUND; - } - Header->Attributes = Attributes; - - return RETURN_SUCCESS; -} - - -/** - This function will update confidential information to lockbox. - - @param Guid the guid to identify the original confidential information - @param Offset the offset of the original confidential information - @param Buffer the address of the updated confidential information - @param Length the length of the updated confidential information - - @retval RETURN_SUCCESS the information is saved successfully. - @retval RETURN_INVALID_PARAMETER the Guid is NULL, or Buffer is NULL, or - Length is 0. - @retval RETURN_NOT_FOUND the requested GUID not found. - @retval RETURN_BUFFER_TOO_SMALL the original buffer to too small to hold - new information. - @retval RETURN_ACCESS_DENIED it is too late to invoke this interface - @retval RETURN_NOT_STARTED it is too early to invoke this interface - @retval RETURN_UNSUPPORTED the service is not supported by - implementaion. -**/ -RETURN_STATUS -EFIAPI -UpdateLockBox ( - IN GUID *Guid, - IN UINTN Offset, - IN VOID *Buffer, - IN UINTN Length - ) -{ - LOCK_BOX_ENTRY *Header; - - DEBUG ((DEBUG_VERBOSE, "%a: Guid=%g Offset=0x%x Length=0x%x\n", __FUNCTION__, - Guid, (UINT32) Offset, (UINT32) Length)); - - if (Guid == NULL || Buffer == NULL || Length == 0) { - return RETURN_INVALID_PARAMETER; - } - - Header = FindHeaderByGuid (Guid); - if (!Header || Header->Size == 0) { - return RETURN_NOT_FOUND; - } - - if (Header->Size < Offset || - Length > Header->Size - Offset) { - return RETURN_BUFFER_TOO_SMALL; - } - - CopyMem ((UINT8 *)(UINTN) (Header->CopyAddress) + Offset, Buffer, Length); - - return RETURN_SUCCESS; -} - - -/** - This function will restore confidential information from lockbox. - - @param Guid the guid to identify the confidential information - @param Buffer the address of the restored confidential information - NULL means restored to original address, Length MUST be NULL at - same time. - @param Length the length of the restored confidential information - - @retval RETURN_SUCCESS the information is restored successfully. - @retval RETURN_INVALID_PARAMETER the Guid is NULL, or one of Buffer and - Length is NULL. - @retval RETURN_WRITE_PROTECTED Buffer and Length are NULL, but the LockBox - has no LOCK_BOX_ATTRIBUTE_RESTORE_IN_PLACE - attribute. - @retval RETURN_BUFFER_TOO_SMALL the Length is too small to hold the - confidential information. - @retval RETURN_NOT_FOUND the requested GUID not found. - @retval RETURN_NOT_STARTED it is too early to invoke this interface - @retval RETURN_ACCESS_DENIED not allow to restore to the address - @retval RETURN_UNSUPPORTED the service is not supported by - implementaion. -**/ -RETURN_STATUS -EFIAPI -RestoreLockBox ( - IN GUID *Guid, - IN VOID *Buffer, OPTIONAL - IN OUT UINTN *Length OPTIONAL - ) -{ - LOCK_BOX_ENTRY *Header; - - DEBUG ((DEBUG_VERBOSE, "%a: Guid=%g Buffer=%p\n", __FUNCTION__, Guid, - Buffer)); - - if ((Guid == NULL) || - ((Buffer == NULL) && (Length != NULL)) || - ((Buffer != NULL) && (Length == NULL))) { - return EFI_INVALID_PARAMETER; - } - - Header = FindHeaderByGuid (Guid); - if (!Header || Header->Size == 0) { - return RETURN_NOT_FOUND; - } - - if (Buffer == NULL) { - if (!(Header->Attributes & LOCK_BOX_ATTRIBUTE_RESTORE_IN_PLACE)) { - return RETURN_WRITE_PROTECTED; - } - if (Header->OrigAddress + (Header->Size - 1) > MAX_ADDRESS) { - return RETURN_UNSUPPORTED; - } - Buffer = (VOID *)(UINTN) Header->OrigAddress; - } - - // - // Set RestoreLength - // - if (Length != NULL) { - if (Header->Size > *Length) { - // - // Input buffer is too small to hold all data. - // - *Length = Header->Size; - return EFI_BUFFER_TOO_SMALL; - } - *Length = Header->Size; - } - - CopyMem (Buffer, (VOID*)(UINTN) Header->CopyAddress, Header->Size); - - return RETURN_SUCCESS; -} - - -/** - This function will restore confidential information from all lockbox which - have RestoreInPlace attribute. - - @retval RETURN_SUCCESS the information is restored successfully. - @retval RETURN_NOT_STARTED it is too early to invoke this interface - @retval RETURN_UNSUPPORTED the service is not supported by - implementaion. -**/ -RETURN_STATUS -EFIAPI -RestoreAllLockBoxInPlace ( - VOID - ) -{ - LOCK_BOX_ENTRY *Header; - - for (Header = StartOfEntries; - Header < EndOfEntries && Header->Size > 0; - Header++) { - if (Header->Attributes & LOCK_BOX_ATTRIBUTE_RESTORE_IN_PLACE) { - VOID *Buffer; - - if (Header->OrigAddress + (Header->Size - 1) > MAX_ADDRESS) { - return RETURN_UNSUPPORTED; - } - Buffer = (VOID *)(UINTN) Header->OrigAddress; - CopyMem (Buffer, (VOID*)(UINTN)Header->CopyAddress, Header->Size); - DEBUG ((DEBUG_VERBOSE, "%a: Guid=%g Buffer=%p\n", __FUNCTION__, - &Header->Guid, Buffer)); - } - } - return RETURN_SUCCESS; -} diff --git a/OvmfPkg/Library/LockBoxLib/LockBoxLib.h b/OvmfPkg/Library/LockBoxLib/LockBoxLib.h deleted file mode 100644 index 5adb65fef2..0000000000 --- a/OvmfPkg/Library/LockBoxLib/LockBoxLib.h +++ /dev/null @@ -1,60 +0,0 @@ -/** @file - - Copyright (c) 2006 - 2014, Intel Corporation. All rights reserved.
- - This program and the accompanying materials - are licensed and made available under the terms and conditions of the BSD License - which accompanies this distribution. The full text of the license may be found at - http://opensource.org/licenses/bsd-license.php - - THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, - WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. - -**/ - -#ifndef __LOCK_BOX_LIB_IMPL_H__ -#define __LOCK_BOX_LIB_IMPL_H__ - -#pragma pack(1) - -typedef struct { - UINT32 Signature; - UINT32 SubPageBuffer; - UINT32 SubPageRemaining; -} LOCK_BOX_GLOBAL; - -#define LOCK_BOX_GLOBAL_SIGNATURE SIGNATURE_32('L', 'B', 'G', 'S') - -extern LOCK_BOX_GLOBAL *mLockBoxGlobal; - -#pragma pack() - -/** - Allocates a buffer of type EfiACPIMemoryNVS. - - Allocates the number bytes specified by AllocationSize of type - EfiACPIMemoryNVS and returns a pointer to the allocated buffer. - If AllocationSize is 0, then a valid buffer of 0 size is - returned. If there is not enough memory remaining to satisfy - the request, then NULL is returned. - - @param AllocationSize The number of bytes to allocate. - - @return A pointer to the allocated buffer or NULL if allocation fails. - -**/ -VOID * -EFIAPI -AllocateAcpiNvsPool ( - IN UINTN AllocationSize - ); - - -RETURN_STATUS -EFIAPI -LockBoxLibInitialize ( - VOID - ); - - -#endif diff --git a/OvmfPkg/Library/NvVarsFileLib/FsAccess.c b/OvmfPkg/Library/NvVarsFileLib/FsAccess.c deleted file mode 100644 index cd0bfff2c4..0000000000 --- a/OvmfPkg/Library/NvVarsFileLib/FsAccess.c +++ /dev/null @@ -1,514 +0,0 @@ -/** @file - File System Access for NvVarsFileLib - - Copyright (c) 2004 - 2014, Intel Corporation. All rights reserved.
- This program and the accompanying materials - are licensed and made available under the terms and conditions of the BSD License - which accompanies this distribution. The full text of the license may be found at - http://opensource.org/licenses/bsd-license.php - - THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, - WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. - -**/ - -#include "NvVarsFileLib.h" - -#include -#include -#include - - -/** - Open the NvVars file for reading or writing - - @param[in] FsHandle - Handle for a gEfiSimpleFileSystemProtocolGuid instance - @param[in] ReadingFile - TRUE: open the file for reading. FALSE: writing - @param[out] NvVarsFile - If EFI_SUCCESS is returned, then this is updated - with the opened NvVars file. - - @return EFI_SUCCESS if the file was opened - -**/ -EFI_STATUS -GetNvVarsFile ( - IN EFI_HANDLE FsHandle, - IN BOOLEAN ReadingFile, - OUT EFI_FILE_HANDLE *NvVarsFile - ) -{ - EFI_STATUS Status; - EFI_SIMPLE_FILE_SYSTEM_PROTOCOL *Fs; - EFI_FILE_HANDLE Root; - - // - // Get the FileSystem protocol on that handle - // - Status = gBS->HandleProtocol ( - FsHandle, - &gEfiSimpleFileSystemProtocolGuid, - (VOID **)&Fs - ); - if (EFI_ERROR (Status)) { - return Status; - } - - // - // Get the volume (the root directory) - // - Status = Fs->OpenVolume (Fs, &Root); - if (EFI_ERROR (Status)) { - return Status; - } - - // - // Attempt to open the NvVars file in the root directory - // - Status = Root->Open ( - Root, - NvVarsFile, - L"NvVars", - ReadingFile ? - EFI_FILE_MODE_READ : - ( - EFI_FILE_MODE_CREATE | - EFI_FILE_MODE_READ | - EFI_FILE_MODE_WRITE - ), - 0 - ); - - return Status; -} - - -/** - Open the NvVars file for reading or writing - - @param[in] File - The file to inspect - @param[out] Exists - Returns whether the file exists - @param[out] Size - Returns the size of the file - (0 if the file does not exist) - -**/ -VOID -NvVarsFileReadCheckup ( - IN EFI_FILE_HANDLE File, - OUT BOOLEAN *Exists, - OUT UINTN *Size - ) -{ - EFI_FILE_INFO *FileInfo; - - *Exists = FALSE; - *Size = 0; - - FileInfo = FileHandleGetInfo (File); - if (FileInfo == NULL) { - return; - } - - if ((FileInfo->Attribute & EFI_FILE_DIRECTORY) != 0) { - FreePool (FileInfo); - return; - } - - *Exists = TRUE; - *Size = (UINTN) FileInfo->FileSize; - - FreePool (FileInfo); -} - - -/** - Open the NvVars file for reading or writing - - @param[in] File - The file to inspect - @param[out] Exists - Returns whether the file exists - @param[out] Size - Returns the size of the file - (0 if the file does not exist) - -**/ -EFI_STATUS -FileHandleEmpty ( - IN EFI_FILE_HANDLE File - ) -{ - EFI_STATUS Status; - EFI_FILE_INFO *FileInfo; - - // - // Retrieve the FileInfo structure - // - FileInfo = FileHandleGetInfo (File); - if (FileInfo == NULL) { - return EFI_INVALID_PARAMETER; - } - - // - // If the path is a directory, then return an error - // - if ((FileInfo->Attribute & EFI_FILE_DIRECTORY) != 0) { - FreePool (FileInfo); - return EFI_INVALID_PARAMETER; - } - - // - // If the file size is already 0, then it is empty, so - // we can return success. - // - if (FileInfo->FileSize == 0) { - FreePool (FileInfo); - return EFI_SUCCESS; - } - - // - // Set the file size to 0. - // - FileInfo->FileSize = 0; - Status = FileHandleSetInfo (File, FileInfo); - - FreePool (FileInfo); - - return Status; -} - - -/** - Reads a file to a newly allocated buffer - - @param[in] File - The file to read - @param[in] ReadSize - The size of data to read from the file - - @return Pointer to buffer allocated to hold the file - contents. NULL if an error occurred. - -**/ -VOID* -FileHandleReadToNewBuffer ( - IN EFI_FILE_HANDLE FileHandle, - IN UINTN ReadSize - ) -{ - EFI_STATUS Status; - UINTN ActualReadSize; - VOID *FileContents; - - ActualReadSize = ReadSize; - FileContents = AllocatePool (ReadSize); - if (FileContents != NULL) { - Status = FileHandleRead ( - FileHandle, - &ReadSize, - FileContents - ); - if (EFI_ERROR (Status) || (ActualReadSize != ReadSize)) { - FreePool (FileContents); - return NULL; - } - } - - return FileContents; -} - - -/** - Reads the contents of the NvVars file on the file system - - @param[in] FsHandle - Handle for a gEfiSimpleFileSystemProtocolGuid instance - - @return EFI_STATUS based on the success or failure of the file read - -**/ -EFI_STATUS -ReadNvVarsFile ( - IN EFI_HANDLE FsHandle - ) -{ - EFI_STATUS Status; - EFI_FILE_HANDLE File; - UINTN FileSize; - BOOLEAN FileExists; - VOID *FileContents; - EFI_HANDLE SerializedVariables; - - Status = GetNvVarsFile (FsHandle, TRUE, &File); - if (EFI_ERROR (Status)) { - DEBUG ((EFI_D_INFO, "FsAccess.c: Could not open NV Variables file on this file system\n")); - return Status; - } - - NvVarsFileReadCheckup (File, &FileExists, &FileSize); - if (FileSize == 0) { - FileHandleClose (File); - return EFI_UNSUPPORTED; - } - - FileContents = FileHandleReadToNewBuffer (File, FileSize); - if (FileContents == NULL) { - FileHandleClose (File); - return EFI_UNSUPPORTED; - } - - DEBUG (( - EFI_D_INFO, - "FsAccess.c: Read %Lu bytes from NV Variables file\n", - (UINT64)FileSize - )); - - Status = SerializeVariablesNewInstanceFromBuffer ( - &SerializedVariables, - FileContents, - FileSize - ); - if (!RETURN_ERROR (Status)) { - Status = SerializeVariablesSetSerializedVariables (SerializedVariables); - } - - FreePool (FileContents); - FileHandleClose (File); - - return Status; -} - - -/** - Writes a variable to indicate that the NV variables - have been loaded from the file system. - -**/ -STATIC -VOID -SetNvVarsVariable ( - VOID - ) -{ - BOOLEAN VarData; - UINTN Size; - - // - // Write a variable to indicate we've already loaded the - // variable data. If it is found, we skip the loading on - // subsequent attempts. - // - Size = sizeof (VarData); - VarData = TRUE; - gRT->SetVariable ( - L"NvVars", - &gEfiSimpleFileSystemProtocolGuid, - EFI_VARIABLE_NON_VOLATILE | - EFI_VARIABLE_BOOTSERVICE_ACCESS | - EFI_VARIABLE_RUNTIME_ACCESS, - Size, - (VOID*) &VarData - ); -} - - -/** - Loads the non-volatile variables from the NvVars file on the - given file system. - - @param[in] FsHandle - Handle for a gEfiSimpleFileSystemProtocolGuid instance - - @return EFI_STATUS based on the success or failure of load operation - -**/ -EFI_STATUS -LoadNvVarsFromFs ( - EFI_HANDLE FsHandle - ) -{ - EFI_STATUS Status; - BOOLEAN VarData; - UINTN Size; - - DEBUG ((EFI_D_INFO, "FsAccess.c: LoadNvVarsFromFs\n")); - - // - // We write a variable to indicate we've already loaded the - // variable data. If it is found, we skip the loading. - // - // This is relevant if the non-volatile variable have been - // able to survive a reboot operation. In that case, we don't - // want to re-load the file as it would overwrite newer changes - // made to the variables. - // - Size = sizeof (VarData); - VarData = TRUE; - Status = gRT->GetVariable ( - L"NvVars", - &gEfiSimpleFileSystemProtocolGuid, - NULL, - &Size, - (VOID*) &VarData - ); - if (Status == EFI_SUCCESS) { - DEBUG ((EFI_D_INFO, "NV Variables were already loaded\n")); - return EFI_ALREADY_STARTED; - } - - // - // Attempt to restore the variables from the NvVars file. - // - Status = ReadNvVarsFile (FsHandle); - if (EFI_ERROR (Status)) { - DEBUG ((EFI_D_INFO, "Error while restoring NV variable data\n")); - return Status; - } - - // - // Write a variable to indicate we've already loaded the - // variable data. If it is found, we skip the loading on - // subsequent attempts. - // - SetNvVarsVariable(); - - DEBUG (( - EFI_D_INFO, - "FsAccess.c: Read NV Variables file (size=%Lu)\n", - (UINT64)Size - )); - - return Status; -} - - -STATIC -RETURN_STATUS -EFIAPI -IterateVariablesCallbackAddAllNvVariables ( - IN VOID *Context, - IN CHAR16 *VariableName, - IN EFI_GUID *VendorGuid, - IN UINT32 Attributes, - IN UINTN DataSize, - IN VOID *Data - ) -{ - EFI_HANDLE Instance; - - Instance = (EFI_HANDLE) Context; - - // - // Only save non-volatile variables - // - if ((Attributes & EFI_VARIABLE_NON_VOLATILE) == 0) { - return RETURN_SUCCESS; - } - - return SerializeVariablesAddVariable ( - Instance, - VariableName, - VendorGuid, - Attributes, - DataSize, - Data - ); -} - - -/** - Saves the non-volatile variables into the NvVars file on the - given file system. - - @param[in] FsHandle - Handle for a gEfiSimpleFileSystemProtocolGuid instance - - @return EFI_STATUS based on the success or failure of load operation - -**/ -EFI_STATUS -SaveNvVarsToFs ( - EFI_HANDLE FsHandle - ) -{ - EFI_STATUS Status; - EFI_FILE_HANDLE File; - UINTN WriteSize; - UINTN VariableDataSize; - VOID *VariableData; - EFI_HANDLE SerializedVariables; - - SerializedVariables = NULL; - - Status = SerializeVariablesNewInstance (&SerializedVariables); - if (EFI_ERROR (Status)) { - return Status; - } - - Status = SerializeVariablesIterateSystemVariables ( - IterateVariablesCallbackAddAllNvVariables, - (VOID*) SerializedVariables - ); - if (EFI_ERROR (Status)) { - return Status; - } - - VariableData = NULL; - VariableDataSize = 0; - Status = SerializeVariablesToBuffer ( - SerializedVariables, - NULL, - &VariableDataSize - ); - if (Status == RETURN_BUFFER_TOO_SMALL) { - VariableData = AllocatePool (VariableDataSize); - if (VariableData == NULL) { - Status = EFI_OUT_OF_RESOURCES; - } else { - Status = SerializeVariablesToBuffer ( - SerializedVariables, - VariableData, - &VariableDataSize - ); - } - } - - SerializeVariablesFreeInstance (SerializedVariables); - - if (EFI_ERROR (Status)) { - return Status; - } - - // - // Open the NvVars file for writing. - // - Status = GetNvVarsFile (FsHandle, FALSE, &File); - if (EFI_ERROR (Status)) { - DEBUG ((EFI_D_INFO, "FsAccess.c: Unable to open file to saved NV Variables\n")); - return Status; - } - - // - // Empty the starting file contents. - // - Status = FileHandleEmpty (File); - if (EFI_ERROR (Status)) { - FileHandleClose (File); - return Status; - } - - WriteSize = VariableDataSize; - Status = FileHandleWrite (File, &WriteSize, VariableData); - if (EFI_ERROR (Status)) { - return Status; - } - - FileHandleClose (File); - - if (!EFI_ERROR (Status)) { - // - // Write a variable to indicate we've already loaded the - // variable data. If it is found, we skip the loading on - // subsequent attempts. - // - SetNvVarsVariable(); - - DEBUG ((EFI_D_INFO, "Saved NV Variables to NvVars file\n")); - } - - return Status; - -} - - diff --git a/OvmfPkg/Library/NvVarsFileLib/NvVarsFileLib.c b/OvmfPkg/Library/NvVarsFileLib/NvVarsFileLib.c deleted file mode 100644 index b597b30bed..0000000000 --- a/OvmfPkg/Library/NvVarsFileLib/NvVarsFileLib.c +++ /dev/null @@ -1,83 +0,0 @@ -/** @file - Save Non-Volatile Variables to a file system. - - Copyright (c) 2009, Intel Corporation. All rights reserved.
- This program and the accompanying materials - are licensed and made available under the terms and conditions of the BSD License - which accompanies this distribution. The full text of the license may be found at - http://opensource.org/licenses/bsd-license.php - - THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, - WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. - -**/ - -#include "NvVarsFileLib.h" -#include -#include - -EFI_HANDLE mNvVarsFileLibFsHandle = NULL; - - -/** - Attempts to connect the NvVarsFileLib to the specified file system. - - @param[in] FsHandle - Handle for a gEfiSimpleFileSystemProtocolGuid instance - - @return The EFI_STATUS while attempting to connect the NvVarsFileLib - to the file system instance. - @retval EFI_SUCCESS - The given file system was connected successfully - -**/ -EFI_STATUS -EFIAPI -ConnectNvVarsToFileSystem ( - IN EFI_HANDLE FsHandle - ) -{ - EFI_STATUS Status; - - // - // We might fail to load the variable, since the file system initially - // will not have the NvVars file. - // - LoadNvVarsFromFs (FsHandle); - - // - // We must be able to save the variables successfully to the file system - // to have connected successfully. - // - Status = SaveNvVarsToFs (FsHandle); - if (!EFI_ERROR (Status)) { - mNvVarsFileLibFsHandle = FsHandle; - } - - return Status; -} - - -/** - Update non-volatile variables stored on the file system. - - @return The EFI_STATUS while attempting to update the variable on - the connected file system. - @retval EFI_SUCCESS - The non-volatile variables were saved to the disk - @retval EFI_NOT_STARTED - A file system has not been connected - -**/ -EFI_STATUS -EFIAPI -UpdateNvVarsOnFileSystem ( - ) -{ - if (mNvVarsFileLibFsHandle == NULL) { - // - // A file system had not been connected to the library. - // - return EFI_NOT_STARTED; - } else { - return SaveNvVarsToFs (mNvVarsFileLibFsHandle); - } -} - - diff --git a/OvmfPkg/Library/NvVarsFileLib/NvVarsFileLib.h b/OvmfPkg/Library/NvVarsFileLib/NvVarsFileLib.h deleted file mode 100644 index f24f3d32bd..0000000000 --- a/OvmfPkg/Library/NvVarsFileLib/NvVarsFileLib.h +++ /dev/null @@ -1,61 +0,0 @@ -/** @file - Save Non-Volatile Variables to a file system. - - Copyright (c) 2009 - 2011, Intel Corporation. All rights reserved.
- This program and the accompanying materials - are licensed and made available under the terms and conditions of the BSD License - which accompanies this distribution. The full text of the license may be found at - http://opensource.org/licenses/bsd-license.php - - THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, - WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. - -**/ - -#ifndef __NV_VARS_FILE_LIB_INSTANCE__ -#define __NV_VARS_FILE_LIB_INSTANCE__ - -#include - -#include - -#include - -#include -#include -#include -#include -#include -#include - -/** - Loads the non-volatile variables from the NvVars file on the - given file system. - - @param[in] FsHandle - Handle for a gEfiSimpleFileSystemProtocolGuid instance - - @return EFI_STATUS based on the success or failure of load operation - -**/ -EFI_STATUS -LoadNvVarsFromFs ( - EFI_HANDLE FsHandle - ); - - -/** - Saves the non-volatile variables into the NvVars file on the - given file system. - - @param[in] FsHandle - Handle for a gEfiSimpleFileSystemProtocolGuid instance - - @return EFI_STATUS based on the success or failure of load operation - -**/ -EFI_STATUS -SaveNvVarsToFs ( - EFI_HANDLE FsHandle - ); - -#endif - diff --git a/OvmfPkg/Library/NvVarsFileLib/NvVarsFileLib.inf b/OvmfPkg/Library/NvVarsFileLib/NvVarsFileLib.inf deleted file mode 100644 index 76fbae0870..0000000000 --- a/OvmfPkg/Library/NvVarsFileLib/NvVarsFileLib.inf +++ /dev/null @@ -1,60 +0,0 @@ -## @file -# NvVarsFileLib -# -# This library saves and restores non-volatile variables in a -# file within a file system. -# -# Copyright (c) 2006 - 2011, Intel Corporation. All rights reserved.
-# -# This program and the accompanying materials -# are licensed and made available under the terms and conditions of the BSD License -# which accompanies this distribution. The full text of the license may be found at -# http://opensource.org/licenses/bsd-license.php -# THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, -# WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. -# -# -## - -[Defines] - INF_VERSION = 0x00010005 - BASE_NAME = NvVarsFileLib - FILE_GUID = 9172fe8b-9a36-40f8-bba5-5e57a44390bd - MODULE_TYPE = UEFI_DRIVER - VERSION_STRING = 1.0 - LIBRARY_CLASS = NvVarsFileLib|DXE_DRIVER DXE_RUNTIME_DRIVER DXE_SAL_DRIVER UEFI_DRIVER - -# -# The following information is for reference only and not required by the build tools. -# -# VALID_ARCHITECTURES = IA32 X64 IPF EBC -# - -[Sources] - FsAccess.c - NvVarsFileLib.c - -[Packages] - MdePkg/MdePkg.dec - MdeModulePkg/MdeModulePkg.dec - OvmfPkg/OvmfPkg.dec - ShellPkg/ShellPkg.dec - -[LibraryClasses] - BaseLib - BaseMemoryLib - DebugLib - FileHandleLib - MemoryAllocationLib - SerializeVariablesLib - -[Protocols] - gEfiSimpleFileSystemProtocolGuid ## CONSUMES - - -[Guids] - gEfiFileInfoGuid - -[Depex] - gEfiVariableWriteArchProtocolGuid - diff --git a/OvmfPkg/Library/PciHostBridgeLib/PciHostBridge.h b/OvmfPkg/Library/PciHostBridgeLib/PciHostBridge.h deleted file mode 100644 index c23d40c8ac..0000000000 --- a/OvmfPkg/Library/PciHostBridgeLib/PciHostBridge.h +++ /dev/null @@ -1,75 +0,0 @@ -/** @file - Header file of OVMF instance of PciHostBridgeLib. - - Copyright (c) 2016, Intel Corporation. All rights reserved.
- - This program and the accompanying materials are licensed and made available - under the terms and conditions of the BSD License which accompanies this - distribution. The full text of the license may be found at - http://opensource.org/licenses/bsd-license.php. - - THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, WITHOUT - WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. - -**/ - -PCI_ROOT_BRIDGE * -ScanForRootBridges ( - UINTN *NumberOfRootBridges -); - -/** - Initialize a PCI_ROOT_BRIDGE structure. - - @param[in] Supports Supported attributes. - - @param[in] Attributes Initial attributes. - - @param[in] AllocAttributes Allocation attributes. - - @param[in] RootBusNumber The bus number to store in RootBus. - - @param[in] MaxSubBusNumber The inclusive maximum bus number that can be - assigned to any subordinate bus found behind any - PCI bridge hanging off this root bus. - - The caller is repsonsible for ensuring that - RootBusNumber <= MaxSubBusNumber. If - RootBusNumber equals MaxSubBusNumber, then the - root bus has no room for subordinate buses. - - @param[in] Io IO aperture. - - @param[in] Mem MMIO aperture. - - @param[in] MemAbove4G MMIO aperture above 4G. - - @param[in] PMem Prefetchable MMIO aperture. - - @param[in] PMemAbove4G Prefetchable MMIO aperture above 4G. - - @param[out] RootBus The PCI_ROOT_BRIDGE structure (allocated by the - caller) that should be filled in by this - function. - - @retval EFI_SUCCESS Initialization successful. A device path - consisting of an ACPI device path node, with - UID = RootBusNumber, has been allocated and - linked into RootBus. - - @retval EFI_OUT_OF_RESOURCES Memory allocation failed. -**/ -EFI_STATUS -InitRootBridge ( - IN UINT64 Supports, - IN UINT64 Attributes, - IN UINT64 AllocAttributes, - IN UINT8 RootBusNumber, - IN UINT8 MaxSubBusNumber, - IN PCI_ROOT_BRIDGE_APERTURE *Io, - IN PCI_ROOT_BRIDGE_APERTURE *Mem, - IN PCI_ROOT_BRIDGE_APERTURE *MemAbove4G, - IN PCI_ROOT_BRIDGE_APERTURE *PMem, - IN PCI_ROOT_BRIDGE_APERTURE *PMemAbove4G, - OUT PCI_ROOT_BRIDGE *RootBus - ); diff --git a/OvmfPkg/Library/PciHostBridgeLib/PciHostBridgeLib.c b/OvmfPkg/Library/PciHostBridgeLib/PciHostBridgeLib.c deleted file mode 100644 index ff837035ca..0000000000 --- a/OvmfPkg/Library/PciHostBridgeLib/PciHostBridgeLib.c +++ /dev/null @@ -1,445 +0,0 @@ -/** @file - OVMF's instance of the PCI Host Bridge Library. - - Copyright (C) 2016, Red Hat, Inc. - Copyright (c) 2016, Intel Corporation. All rights reserved.
- - This program and the accompanying materials are licensed and made available - under the terms and conditions of the BSD License which accompanies this - distribution. The full text of the license may be found at - http://opensource.org/licenses/bsd-license.php. - - THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, WITHOUT - WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. - -**/ -#include - -#include -#include - -#include -#include - -#include -#include -#include -#include -#include -#include -#include -#include "PciHostBridge.h" - - -#pragma pack(1) -typedef struct { - ACPI_HID_DEVICE_PATH AcpiDevicePath; - EFI_DEVICE_PATH_PROTOCOL EndDevicePath; -} OVMF_PCI_ROOT_BRIDGE_DEVICE_PATH; -#pragma pack () - - -GLOBAL_REMOVE_IF_UNREFERENCED -CHAR16 *mPciHostBridgeLibAcpiAddressSpaceTypeStr[] = { - L"Mem", L"I/O", L"Bus" -}; - - -STATIC -CONST -OVMF_PCI_ROOT_BRIDGE_DEVICE_PATH mRootBridgeDevicePathTemplate = { - { - { - ACPI_DEVICE_PATH, - ACPI_DP, - { - (UINT8) (sizeof(ACPI_HID_DEVICE_PATH)), - (UINT8) ((sizeof(ACPI_HID_DEVICE_PATH)) >> 8) - } - }, - EISA_PNP_ID(0x0A03), // HID - 0 // UID - }, - - { - END_DEVICE_PATH_TYPE, - END_ENTIRE_DEVICE_PATH_SUBTYPE, - { - END_DEVICE_PATH_LENGTH, - 0 - } - } -}; - -STATIC PCI_ROOT_BRIDGE_APERTURE mNonExistAperture = { MAX_UINT64, 0 }; - -/** - Initialize a PCI_ROOT_BRIDGE structure. - - @param[in] Supports Supported attributes. - - @param[in] Attributes Initial attributes. - - @param[in] AllocAttributes Allocation attributes. - - @param[in] RootBusNumber The bus number to store in RootBus. - - @param[in] MaxSubBusNumber The inclusive maximum bus number that can be - assigned to any subordinate bus found behind any - PCI bridge hanging off this root bus. - - The caller is repsonsible for ensuring that - RootBusNumber <= MaxSubBusNumber. If - RootBusNumber equals MaxSubBusNumber, then the - root bus has no room for subordinate buses. - - @param[in] Io IO aperture. - - @param[in] Mem MMIO aperture. - - @param[in] MemAbove4G MMIO aperture above 4G. - - @param[in] PMem Prefetchable MMIO aperture. - - @param[in] PMemAbove4G Prefetchable MMIO aperture above 4G. - - @param[out] RootBus The PCI_ROOT_BRIDGE structure (allocated by the - caller) that should be filled in by this - function. - - @retval EFI_SUCCESS Initialization successful. A device path - consisting of an ACPI device path node, with - UID = RootBusNumber, has been allocated and - linked into RootBus. - - @retval EFI_OUT_OF_RESOURCES Memory allocation failed. -**/ -EFI_STATUS -InitRootBridge ( - IN UINT64 Supports, - IN UINT64 Attributes, - IN UINT64 AllocAttributes, - IN UINT8 RootBusNumber, - IN UINT8 MaxSubBusNumber, - IN PCI_ROOT_BRIDGE_APERTURE *Io, - IN PCI_ROOT_BRIDGE_APERTURE *Mem, - IN PCI_ROOT_BRIDGE_APERTURE *MemAbove4G, - IN PCI_ROOT_BRIDGE_APERTURE *PMem, - IN PCI_ROOT_BRIDGE_APERTURE *PMemAbove4G, - OUT PCI_ROOT_BRIDGE *RootBus - ) -{ - OVMF_PCI_ROOT_BRIDGE_DEVICE_PATH *DevicePath; - - // - // Be safe if other fields are added to PCI_ROOT_BRIDGE later. - // - ZeroMem (RootBus, sizeof *RootBus); - - RootBus->Segment = 0; - - RootBus->Supports = Supports; - RootBus->Attributes = Attributes; - - RootBus->DmaAbove4G = FALSE; - - RootBus->AllocationAttributes = AllocAttributes; - RootBus->Bus.Base = RootBusNumber; - RootBus->Bus.Limit = MaxSubBusNumber; - CopyMem (&RootBus->Io, Io, sizeof (*Io)); - CopyMem (&RootBus->Mem, Mem, sizeof (*Mem)); - CopyMem (&RootBus->MemAbove4G, MemAbove4G, sizeof (*MemAbove4G)); - CopyMem (&RootBus->PMem, PMem, sizeof (*PMem)); - CopyMem (&RootBus->PMemAbove4G, PMemAbove4G, sizeof (*PMemAbove4G)); - - RootBus->NoExtendedConfigSpace = (PcdGet16 (PcdOvmfHostBridgePciDevId) != - INTEL_Q35_MCH_DEVICE_ID); - - DevicePath = AllocateCopyPool (sizeof mRootBridgeDevicePathTemplate, - &mRootBridgeDevicePathTemplate); - if (DevicePath == NULL) { - DEBUG ((EFI_D_ERROR, "%a: %r\n", __FUNCTION__, EFI_OUT_OF_RESOURCES)); - return EFI_OUT_OF_RESOURCES; - } - DevicePath->AcpiDevicePath.UID = RootBusNumber; - RootBus->DevicePath = (EFI_DEVICE_PATH_PROTOCOL *)DevicePath; - - DEBUG ((EFI_D_INFO, - "%a: populated root bus %d, with room for %d subordinate bus(es)\n", - __FUNCTION__, RootBusNumber, MaxSubBusNumber - RootBusNumber)); - return EFI_SUCCESS; -} - - -/** - Uninitialize a PCI_ROOT_BRIDGE structure set up with InitRootBridge(). - - param[in] RootBus The PCI_ROOT_BRIDGE structure, allocated by the caller and - initialized with InitRootBridge(), that should be - uninitialized. This function doesn't free RootBus. -**/ -STATIC -VOID -UninitRootBridge ( - IN PCI_ROOT_BRIDGE *RootBus - ) -{ - FreePool (RootBus->DevicePath); -} - - -/** - Return all the root bridge instances in an array. - - @param Count Return the count of root bridge instances. - - @return All the root bridge instances in an array. - The array should be passed into PciHostBridgeFreeRootBridges() - when it's not used. -**/ -PCI_ROOT_BRIDGE * -EFIAPI -PciHostBridgeGetRootBridges ( - UINTN *Count - ) -{ - EFI_STATUS Status; - FIRMWARE_CONFIG_ITEM FwCfgItem; - UINTN FwCfgSize; - UINT64 ExtraRootBridges; - PCI_ROOT_BRIDGE *Bridges; - UINTN Initialized; - UINTN LastRootBridgeNumber; - UINTN RootBridgeNumber; - UINT64 Attributes; - UINT64 AllocationAttributes; - PCI_ROOT_BRIDGE_APERTURE Io; - PCI_ROOT_BRIDGE_APERTURE Mem; - PCI_ROOT_BRIDGE_APERTURE MemAbove4G; - - if (PcdGetBool (PcdPciDisableBusEnumeration)) { - return ScanForRootBridges (Count); - } - - Attributes = EFI_PCI_ATTRIBUTE_IDE_PRIMARY_IO | - EFI_PCI_ATTRIBUTE_IDE_SECONDARY_IO | - EFI_PCI_ATTRIBUTE_ISA_IO_16 | - EFI_PCI_ATTRIBUTE_ISA_MOTHERBOARD_IO | - EFI_PCI_ATTRIBUTE_VGA_MEMORY | - EFI_PCI_ATTRIBUTE_VGA_IO_16 | - EFI_PCI_ATTRIBUTE_VGA_PALETTE_IO_16; - - AllocationAttributes = EFI_PCI_HOST_BRIDGE_COMBINE_MEM_PMEM; - if (PcdGet64 (PcdPciMmio64Size) > 0) { - AllocationAttributes |= EFI_PCI_HOST_BRIDGE_MEM64_DECODE; - MemAbove4G.Base = PcdGet64 (PcdPciMmio64Base); - MemAbove4G.Limit = PcdGet64 (PcdPciMmio64Base) + - PcdGet64 (PcdPciMmio64Size) - 1; - } else { - CopyMem (&MemAbove4G, &mNonExistAperture, sizeof (mNonExistAperture)); - } - - Io.Base = PcdGet64 (PcdPciIoBase); - Io.Limit = PcdGet64 (PcdPciIoBase) + (PcdGet64 (PcdPciIoSize) - 1); - Mem.Base = PcdGet64 (PcdPciMmio32Base); - Mem.Limit = PcdGet64 (PcdPciMmio32Base) + (PcdGet64 (PcdPciMmio32Size) - 1); - - *Count = 0; - - // - // QEMU provides the number of extra root buses, shortening the exhaustive - // search below. If there is no hint, the feature is missing. - // - Status = QemuFwCfgFindFile ("etc/extra-pci-roots", &FwCfgItem, &FwCfgSize); - if (EFI_ERROR (Status) || FwCfgSize != sizeof ExtraRootBridges) { - ExtraRootBridges = 0; - } else { - QemuFwCfgSelectItem (FwCfgItem); - QemuFwCfgReadBytes (FwCfgSize, &ExtraRootBridges); - - if (ExtraRootBridges > PCI_MAX_BUS) { - DEBUG ((EFI_D_ERROR, "%a: invalid count of extra root buses (%Lu) " - "reported by QEMU\n", __FUNCTION__, ExtraRootBridges)); - return NULL; - } - DEBUG ((EFI_D_INFO, "%a: %Lu extra root buses reported by QEMU\n", - __FUNCTION__, ExtraRootBridges)); - } - - // - // Allocate the "main" root bridge, and any extra root bridges. - // - Bridges = AllocatePool ((1 + (UINTN)ExtraRootBridges) * sizeof *Bridges); - if (Bridges == NULL) { - DEBUG ((EFI_D_ERROR, "%a: %r\n", __FUNCTION__, EFI_OUT_OF_RESOURCES)); - return NULL; - } - Initialized = 0; - - // - // The "main" root bus is always there. - // - LastRootBridgeNumber = 0; - - // - // Scan all other root buses. If function 0 of any device on a bus returns a - // VendorId register value different from all-bits-one, then that bus is - // alive. - // - for (RootBridgeNumber = 1; - RootBridgeNumber <= PCI_MAX_BUS && Initialized < ExtraRootBridges; - ++RootBridgeNumber) { - UINTN Device; - - for (Device = 0; Device <= PCI_MAX_DEVICE; ++Device) { - if (PciRead16 (PCI_LIB_ADDRESS (RootBridgeNumber, Device, 0, - PCI_VENDOR_ID_OFFSET)) != MAX_UINT16) { - break; - } - } - if (Device <= PCI_MAX_DEVICE) { - // - // Found the next root bus. We can now install the *previous* one, - // because now we know how big a bus number range *that* one has, for any - // subordinate buses that might exist behind PCI bridges hanging off it. - // - Status = InitRootBridge ( - Attributes, - Attributes, - AllocationAttributes, - (UINT8) LastRootBridgeNumber, - (UINT8) (RootBridgeNumber - 1), - &Io, - &Mem, - &MemAbove4G, - &mNonExistAperture, - &mNonExistAperture, - &Bridges[Initialized] - ); - if (EFI_ERROR (Status)) { - goto FreeBridges; - } - ++Initialized; - LastRootBridgeNumber = RootBridgeNumber; - } - } - - // - // Install the last root bus (which might be the only, ie. main, root bus, if - // we've found no extra root buses). - // - Status = InitRootBridge ( - Attributes, - Attributes, - AllocationAttributes, - (UINT8) LastRootBridgeNumber, - PCI_MAX_BUS, - &Io, - &Mem, - &MemAbove4G, - &mNonExistAperture, - &mNonExistAperture, - &Bridges[Initialized] - ); - if (EFI_ERROR (Status)) { - goto FreeBridges; - } - ++Initialized; - - *Count = Initialized; - return Bridges; - -FreeBridges: - while (Initialized > 0) { - --Initialized; - UninitRootBridge (&Bridges[Initialized]); - } - - FreePool (Bridges); - return NULL; -} - - -/** - Free the root bridge instances array returned from - PciHostBridgeGetRootBridges(). - - @param The root bridge instances array. - @param The count of the array. -**/ -VOID -EFIAPI -PciHostBridgeFreeRootBridges ( - PCI_ROOT_BRIDGE *Bridges, - UINTN Count - ) -{ - if (Bridges == NULL && Count == 0) { - return; - } - ASSERT (Bridges != NULL && Count > 0); - - do { - --Count; - UninitRootBridge (&Bridges[Count]); - } while (Count > 0); - - FreePool (Bridges); -} - - -/** - Inform the platform that the resource conflict happens. - - @param HostBridgeHandle Handle of the Host Bridge. - @param Configuration Pointer to PCI I/O and PCI memory resource - descriptors. The Configuration contains the resources - for all the root bridges. The resource for each root - bridge is terminated with END descriptor and an - additional END is appended indicating the end of the - entire resources. The resource descriptor field - values follow the description in - EFI_PCI_HOST_BRIDGE_RESOURCE_ALLOCATION_PROTOCOL - .SubmitResources(). -**/ -VOID -EFIAPI -PciHostBridgeResourceConflict ( - EFI_HANDLE HostBridgeHandle, - VOID *Configuration - ) -{ - EFI_ACPI_ADDRESS_SPACE_DESCRIPTOR *Descriptor; - UINTN RootBridgeIndex; - DEBUG ((EFI_D_ERROR, "PciHostBridge: Resource conflict happens!\n")); - - RootBridgeIndex = 0; - Descriptor = (EFI_ACPI_ADDRESS_SPACE_DESCRIPTOR *) Configuration; - while (Descriptor->Desc == ACPI_ADDRESS_SPACE_DESCRIPTOR) { - DEBUG ((EFI_D_ERROR, "RootBridge[%d]:\n", RootBridgeIndex++)); - for (; Descriptor->Desc == ACPI_ADDRESS_SPACE_DESCRIPTOR; Descriptor++) { - ASSERT (Descriptor->ResType < - ARRAY_SIZE (mPciHostBridgeLibAcpiAddressSpaceTypeStr) - ); - DEBUG ((EFI_D_ERROR, " %s: Length/Alignment = 0x%lx / 0x%lx\n", - mPciHostBridgeLibAcpiAddressSpaceTypeStr[Descriptor->ResType], - Descriptor->AddrLen, Descriptor->AddrRangeMax - )); - if (Descriptor->ResType == ACPI_ADDRESS_SPACE_TYPE_MEM) { - DEBUG ((EFI_D_ERROR, " Granularity/SpecificFlag = %ld / %02x%s\n", - Descriptor->AddrSpaceGranularity, Descriptor->SpecificFlag, - ((Descriptor->SpecificFlag & - EFI_ACPI_MEMORY_RESOURCE_SPECIFIC_FLAG_CACHEABLE_PREFETCHABLE - ) != 0) ? L" (Prefetchable)" : L"" - )); - } - } - // - // Skip the END descriptor for root bridge - // - ASSERT (Descriptor->Desc == ACPI_END_TAG_DESCRIPTOR); - Descriptor = (EFI_ACPI_ADDRESS_SPACE_DESCRIPTOR *)( - (EFI_ACPI_END_TAG_DESCRIPTOR *)Descriptor + 1 - ); - } -} diff --git a/OvmfPkg/Library/PciHostBridgeLib/PciHostBridgeLib.inf b/OvmfPkg/Library/PciHostBridgeLib/PciHostBridgeLib.inf deleted file mode 100644 index 046ffbde8e..0000000000 --- a/OvmfPkg/Library/PciHostBridgeLib/PciHostBridgeLib.inf +++ /dev/null @@ -1,59 +0,0 @@ -## @file -# OVMF's instance of the PCI Host Bridge Library. -# -# Copyright (C) 2016, Red Hat, Inc. -# Copyright (c) 2016, Intel Corporation. All rights reserved.
-# -# This program and the accompanying materials are licensed and made available -# under the terms and conditions of the BSD License which accompanies this -# distribution. The full text of the license may be found at -# http://opensource.org/licenses/bsd-license.php -# THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, -# WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR -# IMPLIED. -# -# -## - -[Defines] - INF_VERSION = 0x00010005 - BASE_NAME = PciHostBridgeLib - FILE_GUID = 9F2BC05E-51EA-4AED-9A3E-7699641734E8 - MODULE_TYPE = DXE_DRIVER - VERSION_STRING = 1.0 - LIBRARY_CLASS = PciHostBridgeLib - -# -# The following information is for reference only and not required by the build -# tools. -# -# VALID_ARCHITECTURES = IA32 X64 IPF EBC -# - -[Sources] - PciHostBridgeLib.c - XenSupport.c - PciHostBridge.h - -[Packages] - MdeModulePkg/MdeModulePkg.dec - MdePkg/MdePkg.dec - OvmfPkg/OvmfPkg.dec - -[LibraryClasses] - BaseMemoryLib - DebugLib - DevicePathLib - MemoryAllocationLib - PciLib - QemuFwCfgLib - -[Pcd] - gUefiOvmfPkgTokenSpaceGuid.PcdPciIoBase - gUefiOvmfPkgTokenSpaceGuid.PcdPciIoSize - gUefiOvmfPkgTokenSpaceGuid.PcdPciMmio32Base - gUefiOvmfPkgTokenSpaceGuid.PcdPciMmio32Size - gUefiOvmfPkgTokenSpaceGuid.PcdPciMmio64Base - gUefiOvmfPkgTokenSpaceGuid.PcdPciMmio64Size - gUefiOvmfPkgTokenSpaceGuid.PcdOvmfHostBridgePciDevId - gEfiMdeModulePkgTokenSpaceGuid.PcdPciDisableBusEnumeration diff --git a/OvmfPkg/Library/PciHostBridgeLib/XenSupport.c b/OvmfPkg/Library/PciHostBridgeLib/XenSupport.c deleted file mode 100644 index 31c63ae19e..0000000000 --- a/OvmfPkg/Library/PciHostBridgeLib/XenSupport.c +++ /dev/null @@ -1,456 +0,0 @@ -/** @file - Scan the entire PCI bus for root bridges to support OVMF above Xen. - - Copyright (c) 2016, Intel Corporation. All rights reserved.
- - This program and the accompanying materials are licensed and made available - under the terms and conditions of the BSD License which accompanies this - distribution. The full text of the license may be found at - http://opensource.org/licenses/bsd-license.php. - - THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, WITHOUT - WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. - -**/ -#include - -#include -#include - -#include -#include - -#include -#include -#include -#include -#include -#include "PciHostBridge.h" - -STATIC -VOID -PcatPciRootBridgeBarExisted ( - IN UINTN Address, - OUT UINT32 *OriginalValue, - OUT UINT32 *Value - ) -{ - // - // Preserve the original value - // - *OriginalValue = PciRead32 (Address); - - // - // Disable timer interrupt while the BAR is probed - // - DisableInterrupts (); - - PciWrite32 (Address, 0xFFFFFFFF); - *Value = PciRead32 (Address); - PciWrite32 (Address, *OriginalValue); - - // - // Enable interrupt - // - EnableInterrupts (); -} - -STATIC -VOID -PcatPciRootBridgeParseBars ( - IN UINT16 Command, - IN UINTN Bus, - IN UINTN Device, - IN UINTN Function, - IN UINTN BarOffsetBase, - IN UINTN BarOffsetEnd, - IN PCI_ROOT_BRIDGE_APERTURE *Io, - IN PCI_ROOT_BRIDGE_APERTURE *Mem, - IN PCI_ROOT_BRIDGE_APERTURE *MemAbove4G, - IN PCI_ROOT_BRIDGE_APERTURE *PMem, - IN PCI_ROOT_BRIDGE_APERTURE *PMemAbove4G - -) -{ - UINT32 OriginalValue; - UINT32 Value; - UINT32 OriginalUpperValue; - UINT32 UpperValue; - UINT64 Mask; - UINTN Offset; - UINT64 Base; - UINT64 Length; - UINT64 Limit; - PCI_ROOT_BRIDGE_APERTURE *MemAperture; - - for (Offset = BarOffsetBase; Offset < BarOffsetEnd; Offset += sizeof (UINT32)) { - PcatPciRootBridgeBarExisted ( - PCI_LIB_ADDRESS (Bus, Device, Function, Offset), - &OriginalValue, &Value - ); - if (Value == 0) { - continue; - } - if ((Value & BIT0) == BIT0) { - // - // IO Bar - // - if (Command & EFI_PCI_COMMAND_IO_SPACE) { - Mask = 0xfffffffc; - Base = OriginalValue & Mask; - Length = ((~(Value & Mask)) & Mask) + 0x04; - if (!(Value & 0xFFFF0000)) { - Length &= 0x0000FFFF; - } - Limit = Base + Length - 1; - - if (Base < Limit) { - if (Io->Base > Base) { - Io->Base = Base; - } - if (Io->Limit < Limit) { - Io->Limit = Limit; - } - } - } - } else { - // - // Mem Bar - // - if (Command & EFI_PCI_COMMAND_MEMORY_SPACE) { - - Mask = 0xfffffff0; - Base = OriginalValue & Mask; - Length = Value & Mask; - - if ((Value & (BIT1 | BIT2)) == 0) { - // - // 32bit - // - Length = ((~Length) + 1) & 0xffffffff; - - if ((Value & BIT3) == BIT3) { - MemAperture = PMem; - } else { - MemAperture = Mem; - } - } else { - // - // 64bit - // - Offset += 4; - PcatPciRootBridgeBarExisted ( - PCI_LIB_ADDRESS (Bus, Device, Function, Offset), - &OriginalUpperValue, - &UpperValue - ); - - Base = Base | LShiftU64 ((UINT64) OriginalUpperValue, 32); - Length = Length | LShiftU64 ((UINT64) UpperValue, 32); - Length = (~Length) + 1; - - if ((Value & BIT3) == BIT3) { - MemAperture = PMemAbove4G; - } else { - MemAperture = MemAbove4G; - } - } - - Limit = Base + Length - 1; - if (Base < Limit) { - if (MemAperture->Base > Base) { - MemAperture->Base = Base; - } - if (MemAperture->Limit < Limit) { - MemAperture->Limit = Limit; - } - } - } - } - } -} - -PCI_ROOT_BRIDGE * -ScanForRootBridges ( - UINTN *NumberOfRootBridges - ) -{ - UINTN PrimaryBus; - UINTN SubBus; - UINT8 Device; - UINT8 Function; - UINTN NumberOfDevices; - UINTN Address; - PCI_TYPE01 Pci; - UINT64 Attributes; - UINT64 Base; - UINT64 Limit; - UINT64 Value; - PCI_ROOT_BRIDGE_APERTURE Io, Mem, MemAbove4G, PMem, PMemAbove4G, *MemAperture; - PCI_ROOT_BRIDGE *RootBridges; - UINTN BarOffsetEnd; - - - *NumberOfRootBridges = 0; - RootBridges = NULL; - - // - // After scanning all the PCI devices on the PCI root bridge's primary bus, - // update the Primary Bus Number for the next PCI root bridge to be this PCI - // root bridge's subordinate bus number + 1. - // - for (PrimaryBus = 0; PrimaryBus <= PCI_MAX_BUS; PrimaryBus = SubBus + 1) { - SubBus = PrimaryBus; - Attributes = 0; - Io.Base = Mem.Base = MemAbove4G.Base = PMem.Base = PMemAbove4G.Base = MAX_UINT64; - Io.Limit = Mem.Limit = MemAbove4G.Limit = PMem.Limit = PMemAbove4G.Limit = 0; - // - // Scan all the PCI devices on the primary bus of the PCI root bridge - // - for (Device = 0, NumberOfDevices = 0; Device <= PCI_MAX_DEVICE; Device++) { - - for (Function = 0; Function <= PCI_MAX_FUNC; Function++) { - - // - // Compute the PCI configuration address of the PCI device to probe - // - Address = PCI_LIB_ADDRESS (PrimaryBus, Device, Function, 0); - - // - // Read the Vendor ID from the PCI Configuration Header - // - if (PciRead16 (Address) == MAX_UINT16) { - if (Function == 0) { - // - // If the PCI Configuration Read fails, or a PCI device does not - // exist, then skip this entire PCI device - // - break; - } else { - // - // If PCI function != 0, VendorId == 0xFFFF, we continue to search - // PCI function. - // - continue; - } - } - - // - // Read the entire PCI Configuration Header - // - PciReadBuffer (Address, sizeof (Pci), &Pci); - - // - // Increment the number of PCI device found on the primary bus of the - // PCI root bridge - // - NumberOfDevices++; - - // - // Look for devices with the VGA Palette Snoop enabled in the COMMAND - // register of the PCI Config Header - // - if ((Pci.Hdr.Command & EFI_PCI_COMMAND_VGA_PALETTE_SNOOP) != 0) { - Attributes |= EFI_PCI_ATTRIBUTE_VGA_PALETTE_IO; - Attributes |= EFI_PCI_ATTRIBUTE_VGA_PALETTE_IO_16; - } - - BarOffsetEnd = 0; - - // - // PCI-PCI Bridge - // - if (IS_PCI_BRIDGE (&Pci)) { - // - // Get the Bus range that the PPB is decoding - // - if (Pci.Bridge.SubordinateBus > SubBus) { - // - // If the suborinate bus number of the PCI-PCI bridge is greater - // than the PCI root bridge's current subordinate bus number, - // then update the PCI root bridge's subordinate bus number - // - SubBus = Pci.Bridge.SubordinateBus; - } - - // - // Get the I/O range that the PPB is decoding - // - Value = Pci.Bridge.IoBase & 0x0f; - Base = ((UINT32) Pci.Bridge.IoBase & 0xf0) << 8; - Limit = (((UINT32) Pci.Bridge.IoLimit & 0xf0) << 8) | 0x0fff; - if (Value == BIT0) { - Base |= ((UINT32) Pci.Bridge.IoBaseUpper16 << 16); - Limit |= ((UINT32) Pci.Bridge.IoLimitUpper16 << 16); - } - if (Base < Limit) { - if (Io.Base > Base) { - Io.Base = Base; - } - if (Io.Limit < Limit) { - Io.Limit = Limit; - } - } - - // - // Get the Memory range that the PPB is decoding - // - Base = ((UINT32) Pci.Bridge.MemoryBase & 0xfff0) << 16; - Limit = (((UINT32) Pci.Bridge.MemoryLimit & 0xfff0) << 16) | 0xfffff; - if (Base < Limit) { - if (Mem.Base > Base) { - Mem.Base = Base; - } - if (Mem.Limit < Limit) { - Mem.Limit = Limit; - } - } - - // - // Get the Prefetchable Memory range that the PPB is decoding - // - Value = Pci.Bridge.PrefetchableMemoryBase & 0x0f; - Base = ((UINT32) Pci.Bridge.PrefetchableMemoryBase & 0xfff0) << 16; - Limit = (((UINT32) Pci.Bridge.PrefetchableMemoryLimit & 0xfff0) - << 16) | 0xfffff; - MemAperture = &PMem; - if (Value == BIT0) { - Base |= LShiftU64 (Pci.Bridge.PrefetchableBaseUpper32, 32); - Limit |= LShiftU64 (Pci.Bridge.PrefetchableLimitUpper32, 32); - MemAperture = &PMemAbove4G; - } - if (Base < Limit) { - if (MemAperture->Base > Base) { - MemAperture->Base = Base; - } - if (MemAperture->Limit < Limit) { - MemAperture->Limit = Limit; - } - } - - // - // Look at the PPB Configuration for legacy decoding attributes - // - if ((Pci.Bridge.BridgeControl & EFI_PCI_BRIDGE_CONTROL_ISA) - == EFI_PCI_BRIDGE_CONTROL_ISA) { - Attributes |= EFI_PCI_ATTRIBUTE_ISA_IO; - Attributes |= EFI_PCI_ATTRIBUTE_ISA_IO_16; - Attributes |= EFI_PCI_ATTRIBUTE_ISA_MOTHERBOARD_IO; - } - if ((Pci.Bridge.BridgeControl & EFI_PCI_BRIDGE_CONTROL_VGA) - == EFI_PCI_BRIDGE_CONTROL_VGA) { - Attributes |= EFI_PCI_ATTRIBUTE_VGA_PALETTE_IO; - Attributes |= EFI_PCI_ATTRIBUTE_VGA_MEMORY; - Attributes |= EFI_PCI_ATTRIBUTE_VGA_IO; - if ((Pci.Bridge.BridgeControl & EFI_PCI_BRIDGE_CONTROL_VGA_16) - != 0) { - Attributes |= EFI_PCI_ATTRIBUTE_VGA_PALETTE_IO_16; - Attributes |= EFI_PCI_ATTRIBUTE_VGA_IO_16; - } - } - - BarOffsetEnd = OFFSET_OF (PCI_TYPE01, Bridge.Bar[2]); - } else { - // - // Parse the BARs of the PCI device to get what I/O Ranges, Memory - // Ranges, and Prefetchable Memory Ranges the device is decoding - // - if ((Pci.Hdr.HeaderType & HEADER_LAYOUT_CODE) == HEADER_TYPE_DEVICE) { - BarOffsetEnd = OFFSET_OF (PCI_TYPE00, Device.Bar[6]); - } - } - - PcatPciRootBridgeParseBars ( - Pci.Hdr.Command, - PrimaryBus, - Device, - Function, - OFFSET_OF (PCI_TYPE00, Device.Bar), - BarOffsetEnd, - &Io, - &Mem, &MemAbove4G, - &PMem, &PMemAbove4G - ); - - // - // See if the PCI device is an IDE controller - // - if (IS_CLASS2 (&Pci, PCI_CLASS_MASS_STORAGE, - PCI_CLASS_MASS_STORAGE_IDE)) { - if (Pci.Hdr.ClassCode[0] & 0x80) { - Attributes |= EFI_PCI_ATTRIBUTE_IDE_PRIMARY_IO; - Attributes |= EFI_PCI_ATTRIBUTE_IDE_SECONDARY_IO; - } - if (Pci.Hdr.ClassCode[0] & 0x01) { - Attributes |= EFI_PCI_ATTRIBUTE_IDE_PRIMARY_IO; - } - if (Pci.Hdr.ClassCode[0] & 0x04) { - Attributes |= EFI_PCI_ATTRIBUTE_IDE_SECONDARY_IO; - } - } - - // - // See if the PCI device is a legacy VGA controller or - // a standard VGA controller - // - if (IS_CLASS2 (&Pci, PCI_CLASS_OLD, PCI_CLASS_OLD_VGA) || - IS_CLASS2 (&Pci, PCI_CLASS_DISPLAY, PCI_CLASS_DISPLAY_VGA) - ) { - Attributes |= EFI_PCI_ATTRIBUTE_VGA_PALETTE_IO; - Attributes |= EFI_PCI_ATTRIBUTE_VGA_PALETTE_IO_16; - Attributes |= EFI_PCI_ATTRIBUTE_VGA_MEMORY; - Attributes |= EFI_PCI_ATTRIBUTE_VGA_IO; - Attributes |= EFI_PCI_ATTRIBUTE_VGA_IO_16; - } - - // - // See if the PCI Device is a PCI - ISA or PCI - EISA - // or ISA_POSITIVIE_DECODE Bridge device - // - if (Pci.Hdr.ClassCode[2] == PCI_CLASS_BRIDGE) { - if (Pci.Hdr.ClassCode[1] == PCI_CLASS_BRIDGE_ISA || - Pci.Hdr.ClassCode[1] == PCI_CLASS_BRIDGE_EISA || - Pci.Hdr.ClassCode[1] == PCI_CLASS_BRIDGE_ISA_PDECODE) { - Attributes |= EFI_PCI_ATTRIBUTE_ISA_IO; - Attributes |= EFI_PCI_ATTRIBUTE_ISA_IO_16; - Attributes |= EFI_PCI_ATTRIBUTE_ISA_MOTHERBOARD_IO; - } - } - - // - // If this device is not a multi function device, then skip the rest - // of this PCI device - // - if (Function == 0 && !IS_PCI_MULTI_FUNC (&Pci)) { - break; - } - } - } - - // - // If at least one PCI device was found on the primary bus of this PCI - // root bridge, then the PCI root bridge exists. - // - if (NumberOfDevices > 0) { - RootBridges = ReallocatePool ( - (*NumberOfRootBridges) * sizeof (PCI_ROOT_BRIDGE), - (*NumberOfRootBridges + 1) * sizeof (PCI_ROOT_BRIDGE), - RootBridges - ); - ASSERT (RootBridges != NULL); - InitRootBridge ( - Attributes, Attributes, 0, - (UINT8) PrimaryBus, (UINT8) SubBus, - &Io, &Mem, &MemAbove4G, &PMem, &PMemAbove4G, - &RootBridges[*NumberOfRootBridges] - ); - RootBridges[*NumberOfRootBridges].ResourceAssigned = TRUE; - // - // Increment the index for the next PCI Root Bridge - // - (*NumberOfRootBridges)++; - } - } - - return RootBridges; -} diff --git a/OvmfPkg/Library/PlatformBootManagerLib/BdsPlatform.c b/OvmfPkg/Library/PlatformBootManagerLib/BdsPlatform.c deleted file mode 100644 index cc35630fcf..0000000000 --- a/OvmfPkg/Library/PlatformBootManagerLib/BdsPlatform.c +++ /dev/null @@ -1,1608 +0,0 @@ -/** @file - Platform BDS customizations. - - Copyright (c) 2004 - 2016, Intel Corporation. All rights reserved.
- This program and the accompanying materials - are licensed and made available under the terms and conditions of the BSD License - which accompanies this distribution. The full text of the license may be found at - http://opensource.org/licenses/bsd-license.php - - THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, - WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. - -**/ - -#include "BdsPlatform.h" -#include -#include -#include - - -// -// Global data -// - -VOID *mEfiDevPathNotifyReg; -EFI_EVENT mEfiDevPathEvent; -VOID *mEmuVariableEventReg; -EFI_EVENT mEmuVariableEvent; -BOOLEAN mDetectVgaOnly; -UINT16 mHostBridgeDevId; - -// -// Table of host IRQs matching PCI IRQs A-D -// (for configuring PCI Interrupt Line register) -// -CONST UINT8 PciHostIrqs[] = { - 0x0a, 0x0a, 0x0b, 0x0b -}; - -// -// Type definitions -// - -typedef -EFI_STATUS -(EFIAPI *PROTOCOL_INSTANCE_CALLBACK)( - IN EFI_HANDLE Handle, - IN VOID *Instance, - IN VOID *Context - ); - -/** - @param[in] Handle - Handle of PCI device instance - @param[in] PciIo - PCI IO protocol instance - @param[in] Pci - PCI Header register block -**/ -typedef -EFI_STATUS -(EFIAPI *VISIT_PCI_INSTANCE_CALLBACK)( - IN EFI_HANDLE Handle, - IN EFI_PCI_IO_PROTOCOL *PciIo, - IN PCI_TYPE00 *Pci - ); - - -// -// Function prototypes -// - -EFI_STATUS -VisitAllInstancesOfProtocol ( - IN EFI_GUID *Id, - IN PROTOCOL_INSTANCE_CALLBACK CallBackFunction, - IN VOID *Context - ); - -EFI_STATUS -VisitAllPciInstancesOfProtocol ( - IN VISIT_PCI_INSTANCE_CALLBACK CallBackFunction - ); - -VOID -InstallDevicePathCallback ( - VOID - ); - -VOID -PlatformRegisterFvBootOption ( - EFI_GUID *FileGuid, - CHAR16 *Description, - UINT32 Attributes - ) -{ - EFI_STATUS Status; - INTN OptionIndex; - EFI_BOOT_MANAGER_LOAD_OPTION NewOption; - EFI_BOOT_MANAGER_LOAD_OPTION *BootOptions; - UINTN BootOptionCount; - MEDIA_FW_VOL_FILEPATH_DEVICE_PATH FileNode; - EFI_LOADED_IMAGE_PROTOCOL *LoadedImage; - EFI_DEVICE_PATH_PROTOCOL *DevicePath; - - Status = gBS->HandleProtocol ( - gImageHandle, - &gEfiLoadedImageProtocolGuid, - (VOID **) &LoadedImage - ); - ASSERT_EFI_ERROR (Status); - - EfiInitializeFwVolDevicepathNode (&FileNode, FileGuid); - DevicePath = DevicePathFromHandle (LoadedImage->DeviceHandle); - ASSERT (DevicePath != NULL); - DevicePath = AppendDevicePathNode ( - DevicePath, - (EFI_DEVICE_PATH_PROTOCOL *) &FileNode - ); - ASSERT (DevicePath != NULL); - - Status = EfiBootManagerInitializeLoadOption ( - &NewOption, - LoadOptionNumberUnassigned, - LoadOptionTypeBoot, - Attributes, - Description, - DevicePath, - NULL, - 0 - ); - ASSERT_EFI_ERROR (Status); - FreePool (DevicePath); - - BootOptions = EfiBootManagerGetLoadOptions ( - &BootOptionCount, LoadOptionTypeBoot - ); - - OptionIndex = EfiBootManagerFindLoadOption ( - &NewOption, BootOptions, BootOptionCount - ); - - if (OptionIndex == -1) { - Status = EfiBootManagerAddLoadOptionVariable (&NewOption, MAX_UINTN); - ASSERT_EFI_ERROR (Status); - } - EfiBootManagerFreeLoadOption (&NewOption); - EfiBootManagerFreeLoadOptions (BootOptions, BootOptionCount); -} - -/** - Remove all MemoryMapped(...)/FvFile(...) and Fv(...)/FvFile(...) boot options - whose device paths do not resolve exactly to an FvFile in the system. - - This removes any boot options that point to binaries built into the firmware - and have become stale due to any of the following: - - DXEFV's base address or size changed (historical), - - DXEFV's FvNameGuid changed, - - the FILE_GUID of the pointed-to binary changed, - - the referenced binary is no longer built into the firmware. - - EfiBootManagerFindLoadOption() used in PlatformRegisterFvBootOption() only - avoids exact duplicates. -**/ -VOID -RemoveStaleFvFileOptions ( - VOID - ) -{ - EFI_BOOT_MANAGER_LOAD_OPTION *BootOptions; - UINTN BootOptionCount; - UINTN Index; - - BootOptions = EfiBootManagerGetLoadOptions (&BootOptionCount, - LoadOptionTypeBoot); - - for (Index = 0; Index < BootOptionCount; ++Index) { - EFI_DEVICE_PATH_PROTOCOL *Node1, *Node2, *SearchNode; - EFI_STATUS Status; - EFI_HANDLE FvHandle; - - // - // If the device path starts with neither MemoryMapped(...) nor Fv(...), - // then keep the boot option. - // - Node1 = BootOptions[Index].FilePath; - if (!(DevicePathType (Node1) == HARDWARE_DEVICE_PATH && - DevicePathSubType (Node1) == HW_MEMMAP_DP) && - !(DevicePathType (Node1) == MEDIA_DEVICE_PATH && - DevicePathSubType (Node1) == MEDIA_PIWG_FW_VOL_DP)) { - continue; - } - - // - // If the second device path node is not FvFile(...), then keep the boot - // option. - // - Node2 = NextDevicePathNode (Node1); - if (DevicePathType (Node2) != MEDIA_DEVICE_PATH || - DevicePathSubType (Node2) != MEDIA_PIWG_FW_FILE_DP) { - continue; - } - - // - // Locate the Firmware Volume2 protocol instance that is denoted by the - // boot option. If this lookup fails (i.e., the boot option references a - // firmware volume that doesn't exist), then we'll proceed to delete the - // boot option. - // - SearchNode = Node1; - Status = gBS->LocateDevicePath (&gEfiFirmwareVolume2ProtocolGuid, - &SearchNode, &FvHandle); - - if (!EFI_ERROR (Status)) { - // - // The firmware volume was found; now let's see if it contains the FvFile - // identified by GUID. - // - EFI_FIRMWARE_VOLUME2_PROTOCOL *FvProtocol; - MEDIA_FW_VOL_FILEPATH_DEVICE_PATH *FvFileNode; - UINTN BufferSize; - EFI_FV_FILETYPE FoundType; - EFI_FV_FILE_ATTRIBUTES FileAttributes; - UINT32 AuthenticationStatus; - - Status = gBS->HandleProtocol (FvHandle, &gEfiFirmwareVolume2ProtocolGuid, - (VOID **)&FvProtocol); - ASSERT_EFI_ERROR (Status); - - FvFileNode = (MEDIA_FW_VOL_FILEPATH_DEVICE_PATH *)Node2; - // - // Buffer==NULL means we request metadata only: BufferSize, FoundType, - // FileAttributes. - // - Status = FvProtocol->ReadFile ( - FvProtocol, - &FvFileNode->FvFileName, // NameGuid - NULL, // Buffer - &BufferSize, - &FoundType, - &FileAttributes, - &AuthenticationStatus - ); - if (!EFI_ERROR (Status)) { - // - // The FvFile was found. Keep the boot option. - // - continue; - } - } - - // - // Delete the boot option. - // - Status = EfiBootManagerDeleteLoadOptionVariable ( - BootOptions[Index].OptionNumber, LoadOptionTypeBoot); - DEBUG_CODE ( - CHAR16 *DevicePathString; - - DevicePathString = ConvertDevicePathToText(BootOptions[Index].FilePath, - FALSE, FALSE); - DEBUG (( - EFI_ERROR (Status) ? EFI_D_WARN : EFI_D_VERBOSE, - "%a: removing stale Boot#%04x %s: %r\n", - __FUNCTION__, - (UINT32)BootOptions[Index].OptionNumber, - DevicePathString == NULL ? L"" : DevicePathString, - Status - )); - if (DevicePathString != NULL) { - FreePool (DevicePathString); - } - ); - } - - EfiBootManagerFreeLoadOptions (BootOptions, BootOptionCount); -} - -VOID -PlatformRegisterOptionsAndKeys ( - VOID - ) -{ - EFI_STATUS Status; - EFI_INPUT_KEY Enter; - EFI_INPUT_KEY F2; - EFI_INPUT_KEY Esc; - EFI_BOOT_MANAGER_LOAD_OPTION BootOption; - - // - // Register ENTER as CONTINUE key - // - Enter.ScanCode = SCAN_NULL; - Enter.UnicodeChar = CHAR_CARRIAGE_RETURN; - Status = EfiBootManagerRegisterContinueKeyOption (0, &Enter, NULL); - ASSERT_EFI_ERROR (Status); - - // - // Map F2 to Boot Manager Menu - // - F2.ScanCode = SCAN_F2; - F2.UnicodeChar = CHAR_NULL; - Esc.ScanCode = SCAN_ESC; - Esc.UnicodeChar = CHAR_NULL; - Status = EfiBootManagerGetBootManagerMenu (&BootOption); - ASSERT_EFI_ERROR (Status); - Status = EfiBootManagerAddKeyOptionVariable ( - NULL, (UINT16) BootOption.OptionNumber, 0, &F2, NULL - ); - ASSERT (Status == EFI_SUCCESS || Status == EFI_ALREADY_STARTED); - Status = EfiBootManagerAddKeyOptionVariable ( - NULL, (UINT16) BootOption.OptionNumber, 0, &Esc, NULL - ); - ASSERT (Status == EFI_SUCCESS || Status == EFI_ALREADY_STARTED); -} - -EFI_STATUS -EFIAPI -ConnectRootBridge ( - IN EFI_HANDLE RootBridgeHandle, - IN VOID *Instance, - IN VOID *Context - ); - -STATIC -VOID -SaveS3BootScript ( - VOID - ); - -// -// BDS Platform Functions -// -VOID -EFIAPI -PlatformBootManagerBeforeConsole ( - VOID - ) -/*++ - -Routine Description: - - Platform Bds init. Include the platform firmware vendor, revision - and so crc check. - -Arguments: - -Returns: - - None. - ---*/ -{ - EFI_HANDLE Handle; - EFI_STATUS Status; - RETURN_STATUS PcdStatus; - - DEBUG ((EFI_D_INFO, "PlatformBootManagerBeforeConsole\n")); - InstallDevicePathCallback (); - - VisitAllInstancesOfProtocol (&gEfiPciRootBridgeIoProtocolGuid, - ConnectRootBridge, NULL); - - // - // Signal the ACPI platform driver that it can download QEMU ACPI tables. - // - EfiEventGroupSignal (&gRootBridgesConnectedEventGroupGuid); - - // - // We can't signal End-of-Dxe earlier than this. Namely, End-of-Dxe triggers - // the preparation of S3 system information. That logic has a hard dependency - // on the presence of the FACS ACPI table. Since our ACPI tables are only - // installed after PCI enumeration completes, we must not trigger the S3 save - // earlier, hence we can't signal End-of-Dxe earlier. - // - EfiEventGroupSignal (&gEfiEndOfDxeEventGroupGuid); - - if (QemuFwCfgS3Enabled ()) { - // - // Save the boot script too. Note that this will require us to emit the - // DxeSmmReadyToLock event just below, which in turn locks down SMM. - // - SaveS3BootScript (); - } - - // - // Prevent further changes to LockBoxes or SMRAM. - // - Handle = NULL; - Status = gBS->InstallProtocolInterface (&Handle, - &gEfiDxeSmmReadyToLockProtocolGuid, EFI_NATIVE_INTERFACE, - NULL); - ASSERT_EFI_ERROR (Status); - - // - // Dispatch deferred images after EndOfDxe event and ReadyToLock installation. - // - EfiBootManagerDispatchDeferredImages (); - - PlatformInitializeConsole (gPlatformConsole); - PcdStatus = PcdSet16S (PcdPlatformBootTimeOut, - GetFrontPageTimeoutFromQemu ()); - ASSERT_RETURN_ERROR (PcdStatus); - - PlatformRegisterOptionsAndKeys (); -} - - -EFI_STATUS -EFIAPI -ConnectRootBridge ( - IN EFI_HANDLE RootBridgeHandle, - IN VOID *Instance, - IN VOID *Context - ) -{ - EFI_STATUS Status; - - // - // Make the PCI bus driver connect the root bridge, non-recursively. This - // will produce a number of child handles with PciIo on them. - // - Status = gBS->ConnectController ( - RootBridgeHandle, // ControllerHandle - NULL, // DriverImageHandle - NULL, // RemainingDevicePath -- produce all - // children - FALSE // Recursive - ); - return Status; -} - - -EFI_STATUS -PrepareLpcBridgeDevicePath ( - IN EFI_HANDLE DeviceHandle - ) -/*++ - -Routine Description: - - Add IsaKeyboard to ConIn, - add IsaSerial to ConOut, ConIn, ErrOut. - LPC Bridge: 06 01 00 - -Arguments: - - DeviceHandle - Handle of PCIIO protocol. - -Returns: - - EFI_SUCCESS - LPC bridge is added to ConOut, ConIn, and ErrOut. - EFI_STATUS - No LPC bridge is added. - ---*/ -{ - EFI_STATUS Status; - EFI_DEVICE_PATH_PROTOCOL *DevicePath; - EFI_DEVICE_PATH_PROTOCOL *TempDevicePath; - CHAR16 *DevPathStr; - - DevicePath = NULL; - Status = gBS->HandleProtocol ( - DeviceHandle, - &gEfiDevicePathProtocolGuid, - (VOID*)&DevicePath - ); - if (EFI_ERROR (Status)) { - return Status; - } - TempDevicePath = DevicePath; - - // - // Register Keyboard - // - DevicePath = AppendDevicePathNode (DevicePath, (EFI_DEVICE_PATH_PROTOCOL *)&gPnpPs2KeyboardDeviceNode); - - EfiBootManagerUpdateConsoleVariable (ConIn, DevicePath, NULL); - - // - // Register COM1 - // - DevicePath = TempDevicePath; - gPnp16550ComPortDeviceNode.UID = 0; - - DevicePath = AppendDevicePathNode (DevicePath, (EFI_DEVICE_PATH_PROTOCOL *)&gPnp16550ComPortDeviceNode); - DevicePath = AppendDevicePathNode (DevicePath, (EFI_DEVICE_PATH_PROTOCOL *)&gUartDeviceNode); - DevicePath = AppendDevicePathNode (DevicePath, (EFI_DEVICE_PATH_PROTOCOL *)&gTerminalTypeDeviceNode); - - // - // Print Device Path - // - DevPathStr = ConvertDevicePathToText (DevicePath, FALSE, FALSE); - if (DevPathStr != NULL) { - DEBUG(( - EFI_D_INFO, - "BdsPlatform.c+%d: COM%d DevPath: %s\n", - __LINE__, - gPnp16550ComPortDeviceNode.UID + 1, - DevPathStr - )); - FreePool(DevPathStr); - } - - EfiBootManagerUpdateConsoleVariable (ConOut, DevicePath, NULL); - EfiBootManagerUpdateConsoleVariable (ConIn, DevicePath, NULL); - EfiBootManagerUpdateConsoleVariable (ErrOut, DevicePath, NULL); - - // - // Register COM2 - // - DevicePath = TempDevicePath; - gPnp16550ComPortDeviceNode.UID = 1; - - DevicePath = AppendDevicePathNode (DevicePath, (EFI_DEVICE_PATH_PROTOCOL *)&gPnp16550ComPortDeviceNode); - DevicePath = AppendDevicePathNode (DevicePath, (EFI_DEVICE_PATH_PROTOCOL *)&gUartDeviceNode); - DevicePath = AppendDevicePathNode (DevicePath, (EFI_DEVICE_PATH_PROTOCOL *)&gTerminalTypeDeviceNode); - - // - // Print Device Path - // - DevPathStr = ConvertDevicePathToText (DevicePath, FALSE, FALSE); - if (DevPathStr != NULL) { - DEBUG(( - EFI_D_INFO, - "BdsPlatform.c+%d: COM%d DevPath: %s\n", - __LINE__, - gPnp16550ComPortDeviceNode.UID + 1, - DevPathStr - )); - FreePool(DevPathStr); - } - - EfiBootManagerUpdateConsoleVariable (ConOut, DevicePath, NULL); - EfiBootManagerUpdateConsoleVariable (ConIn, DevicePath, NULL); - EfiBootManagerUpdateConsoleVariable (ErrOut, DevicePath, NULL); - - return EFI_SUCCESS; -} - -EFI_STATUS -GetGopDevicePath ( - IN EFI_DEVICE_PATH_PROTOCOL *PciDevicePath, - OUT EFI_DEVICE_PATH_PROTOCOL **GopDevicePath - ) -{ - UINTN Index; - EFI_STATUS Status; - EFI_HANDLE PciDeviceHandle; - EFI_DEVICE_PATH_PROTOCOL *TempDevicePath; - EFI_DEVICE_PATH_PROTOCOL *TempPciDevicePath; - UINTN GopHandleCount; - EFI_HANDLE *GopHandleBuffer; - - if (PciDevicePath == NULL || GopDevicePath == NULL) { - return EFI_INVALID_PARAMETER; - } - - // - // Initialize the GopDevicePath to be PciDevicePath - // - *GopDevicePath = PciDevicePath; - TempPciDevicePath = PciDevicePath; - - Status = gBS->LocateDevicePath ( - &gEfiDevicePathProtocolGuid, - &TempPciDevicePath, - &PciDeviceHandle - ); - if (EFI_ERROR (Status)) { - return Status; - } - - // - // Try to connect this handle, so that GOP driver could start on this - // device and create child handles with GraphicsOutput Protocol installed - // on them, then we get device paths of these child handles and select - // them as possible console device. - // - gBS->ConnectController (PciDeviceHandle, NULL, NULL, FALSE); - - Status = gBS->LocateHandleBuffer ( - ByProtocol, - &gEfiGraphicsOutputProtocolGuid, - NULL, - &GopHandleCount, - &GopHandleBuffer - ); - if (!EFI_ERROR (Status)) { - // - // Add all the child handles as possible Console Device - // - for (Index = 0; Index < GopHandleCount; Index++) { - Status = gBS->HandleProtocol (GopHandleBuffer[Index], &gEfiDevicePathProtocolGuid, (VOID*)&TempDevicePath); - if (EFI_ERROR (Status)) { - continue; - } - if (CompareMem ( - PciDevicePath, - TempDevicePath, - GetDevicePathSize (PciDevicePath) - END_DEVICE_PATH_LENGTH - ) == 0) { - // - // In current implementation, we only enable one of the child handles - // as console device, i.e. sotre one of the child handle's device - // path to variable "ConOut" - // In future, we could select all child handles to be console device - // - - *GopDevicePath = TempDevicePath; - - // - // Delete the PCI device's path that added by GetPlugInPciVgaDevicePath() - // Add the integrity GOP device path. - // - EfiBootManagerUpdateConsoleVariable (ConOutDev, NULL, PciDevicePath); - EfiBootManagerUpdateConsoleVariable (ConOutDev, TempDevicePath, NULL); - } - } - gBS->FreePool (GopHandleBuffer); - } - - return EFI_SUCCESS; -} - -EFI_STATUS -PreparePciDisplayDevicePath ( - IN EFI_HANDLE DeviceHandle - ) -/*++ - -Routine Description: - - Add PCI VGA to ConOut. - PCI VGA: 03 00 00 - -Arguments: - - DeviceHandle - Handle of PCIIO protocol. - -Returns: - - EFI_SUCCESS - PCI VGA is added to ConOut. - EFI_STATUS - No PCI VGA device is added. - ---*/ -{ - EFI_STATUS Status; - EFI_DEVICE_PATH_PROTOCOL *DevicePath; - EFI_DEVICE_PATH_PROTOCOL *GopDevicePath; - - DevicePath = NULL; - GopDevicePath = NULL; - Status = gBS->HandleProtocol ( - DeviceHandle, - &gEfiDevicePathProtocolGuid, - (VOID*)&DevicePath - ); - if (EFI_ERROR (Status)) { - return Status; - } - - GetGopDevicePath (DevicePath, &GopDevicePath); - DevicePath = GopDevicePath; - - EfiBootManagerUpdateConsoleVariable (ConOut, DevicePath, NULL); - - return EFI_SUCCESS; -} - -EFI_STATUS -PreparePciSerialDevicePath ( - IN EFI_HANDLE DeviceHandle - ) -/*++ - -Routine Description: - - Add PCI Serial to ConOut, ConIn, ErrOut. - PCI Serial: 07 00 02 - -Arguments: - - DeviceHandle - Handle of PCIIO protocol. - -Returns: - - EFI_SUCCESS - PCI Serial is added to ConOut, ConIn, and ErrOut. - EFI_STATUS - No PCI Serial device is added. - ---*/ -{ - EFI_STATUS Status; - EFI_DEVICE_PATH_PROTOCOL *DevicePath; - - DevicePath = NULL; - Status = gBS->HandleProtocol ( - DeviceHandle, - &gEfiDevicePathProtocolGuid, - (VOID*)&DevicePath - ); - if (EFI_ERROR (Status)) { - return Status; - } - - DevicePath = AppendDevicePathNode (DevicePath, (EFI_DEVICE_PATH_PROTOCOL *)&gUartDeviceNode); - DevicePath = AppendDevicePathNode (DevicePath, (EFI_DEVICE_PATH_PROTOCOL *)&gTerminalTypeDeviceNode); - - EfiBootManagerUpdateConsoleVariable (ConOut, DevicePath, NULL); - EfiBootManagerUpdateConsoleVariable (ConIn, DevicePath, NULL); - EfiBootManagerUpdateConsoleVariable (ErrOut, DevicePath, NULL); - - return EFI_SUCCESS; -} - -EFI_STATUS -VisitAllInstancesOfProtocol ( - IN EFI_GUID *Id, - IN PROTOCOL_INSTANCE_CALLBACK CallBackFunction, - IN VOID *Context - ) -{ - EFI_STATUS Status; - UINTN HandleCount; - EFI_HANDLE *HandleBuffer; - UINTN Index; - VOID *Instance; - - // - // Start to check all the PciIo to find all possible device - // - HandleCount = 0; - HandleBuffer = NULL; - Status = gBS->LocateHandleBuffer ( - ByProtocol, - Id, - NULL, - &HandleCount, - &HandleBuffer - ); - if (EFI_ERROR (Status)) { - return Status; - } - - for (Index = 0; Index < HandleCount; Index++) { - Status = gBS->HandleProtocol (HandleBuffer[Index], Id, &Instance); - if (EFI_ERROR (Status)) { - continue; - } - - Status = (*CallBackFunction) ( - HandleBuffer[Index], - Instance, - Context - ); - } - - gBS->FreePool (HandleBuffer); - - return EFI_SUCCESS; -} - - -EFI_STATUS -EFIAPI -VisitingAPciInstance ( - IN EFI_HANDLE Handle, - IN VOID *Instance, - IN VOID *Context - ) -{ - EFI_STATUS Status; - EFI_PCI_IO_PROTOCOL *PciIo; - PCI_TYPE00 Pci; - - PciIo = (EFI_PCI_IO_PROTOCOL*) Instance; - - // - // Check for all PCI device - // - Status = PciIo->Pci.Read ( - PciIo, - EfiPciIoWidthUint32, - 0, - sizeof (Pci) / sizeof (UINT32), - &Pci - ); - if (EFI_ERROR (Status)) { - return Status; - } - - return (*(VISIT_PCI_INSTANCE_CALLBACK)(UINTN) Context) ( - Handle, - PciIo, - &Pci - ); - -} - - - -EFI_STATUS -VisitAllPciInstances ( - IN VISIT_PCI_INSTANCE_CALLBACK CallBackFunction - ) -{ - return VisitAllInstancesOfProtocol ( - &gEfiPciIoProtocolGuid, - VisitingAPciInstance, - (VOID*)(UINTN) CallBackFunction - ); -} - - -/** - Do platform specific PCI Device check and add them to - ConOut, ConIn, ErrOut. - - @param[in] Handle - Handle of PCI device instance - @param[in] PciIo - PCI IO protocol instance - @param[in] Pci - PCI Header register block - - @retval EFI_SUCCESS - PCI Device check and Console variable update successfully. - @retval EFI_STATUS - PCI Device check or Console variable update fail. - -**/ -EFI_STATUS -EFIAPI -DetectAndPreparePlatformPciDevicePath ( - IN EFI_HANDLE Handle, - IN EFI_PCI_IO_PROTOCOL *PciIo, - IN PCI_TYPE00 *Pci - ) -{ - EFI_STATUS Status; - - Status = PciIo->Attributes ( - PciIo, - EfiPciIoAttributeOperationEnable, - EFI_PCI_DEVICE_ENABLE, - NULL - ); - ASSERT_EFI_ERROR (Status); - - if (!mDetectVgaOnly) { - // - // Here we decide whether it is LPC Bridge - // - if ((IS_PCI_LPC (Pci)) || - ((IS_PCI_ISA_PDECODE (Pci)) && - (Pci->Hdr.VendorId == 0x8086) && - (Pci->Hdr.DeviceId == 0x7000) - ) - ) { - // - // Add IsaKeyboard to ConIn, - // add IsaSerial to ConOut, ConIn, ErrOut - // - DEBUG ((EFI_D_INFO, "Found LPC Bridge device\n")); - PrepareLpcBridgeDevicePath (Handle); - return EFI_SUCCESS; - } - // - // Here we decide which Serial device to enable in PCI bus - // - if (IS_PCI_16550SERIAL (Pci)) { - // - // Add them to ConOut, ConIn, ErrOut. - // - DEBUG ((EFI_D_INFO, "Found PCI 16550 SERIAL device\n")); - PreparePciSerialDevicePath (Handle); - return EFI_SUCCESS; - } - } - - // - // Here we decide which display device to enable in PCI bus - // - if (IS_PCI_DISPLAY (Pci)) { - // - // Add them to ConOut. - // - DEBUG ((EFI_D_INFO, "Found PCI display device\n")); - PreparePciDisplayDevicePath (Handle); - return EFI_SUCCESS; - } - - return Status; -} - - -/** - Do platform specific PCI Device check and add them to ConOut, ConIn, ErrOut - - @param[in] DetectVgaOnly - Only detect VGA device if it's TRUE. - - @retval EFI_SUCCESS - PCI Device check and Console variable update successfully. - @retval EFI_STATUS - PCI Device check or Console variable update fail. - -**/ -EFI_STATUS -DetectAndPreparePlatformPciDevicePaths ( - BOOLEAN DetectVgaOnly - ) -{ - mDetectVgaOnly = DetectVgaOnly; - return VisitAllPciInstances (DetectAndPreparePlatformPciDevicePath); -} - - -VOID -PlatformInitializeConsole ( - IN PLATFORM_CONSOLE_CONNECT_ENTRY *PlatformConsole - ) -/*++ - -Routine Description: - - Connect the predefined platform default console device. Always try to find - and enable the vga device if have. - -Arguments: - - PlatformConsole - Predefined platform default console device array. ---*/ -{ - UINTN Index; - EFI_DEVICE_PATH_PROTOCOL *VarConout; - EFI_DEVICE_PATH_PROTOCOL *VarConin; - - // - // Connect RootBridge - // - GetEfiGlobalVariable2 (EFI_CON_OUT_VARIABLE_NAME, (VOID **) &VarConout, NULL); - GetEfiGlobalVariable2 (EFI_CON_IN_VARIABLE_NAME, (VOID **) &VarConin, NULL); - - if (VarConout == NULL || VarConin == NULL) { - // - // Do platform specific PCI Device check and add them to ConOut, ConIn, ErrOut - // - DetectAndPreparePlatformPciDevicePaths (FALSE); - - // - // Have chance to connect the platform default console, - // the platform default console is the minimum device group - // the platform should support - // - for (Index = 0; PlatformConsole[Index].DevicePath != NULL; ++Index) { - // - // Update the console variable with the connect type - // - if ((PlatformConsole[Index].ConnectType & CONSOLE_IN) == CONSOLE_IN) { - EfiBootManagerUpdateConsoleVariable (ConIn, PlatformConsole[Index].DevicePath, NULL); - } - if ((PlatformConsole[Index].ConnectType & CONSOLE_OUT) == CONSOLE_OUT) { - EfiBootManagerUpdateConsoleVariable (ConOut, PlatformConsole[Index].DevicePath, NULL); - } - if ((PlatformConsole[Index].ConnectType & STD_ERROR) == STD_ERROR) { - EfiBootManagerUpdateConsoleVariable (ErrOut, PlatformConsole[Index].DevicePath, NULL); - } - } - } else { - // - // Only detect VGA device and add them to ConOut - // - DetectAndPreparePlatformPciDevicePaths (TRUE); - } -} - - -/** - Configure PCI Interrupt Line register for applicable devices - Ported from SeaBIOS, src/fw/pciinit.c, *_pci_slot_get_irq() - - @param[in] Handle - Handle of PCI device instance - @param[in] PciIo - PCI IO protocol instance - @param[in] PciHdr - PCI Header register block - - @retval EFI_SUCCESS - PCI Interrupt Line register configured successfully. - -**/ -EFI_STATUS -EFIAPI -SetPciIntLine ( - IN EFI_HANDLE Handle, - IN EFI_PCI_IO_PROTOCOL *PciIo, - IN PCI_TYPE00 *PciHdr - ) -{ - EFI_DEVICE_PATH_PROTOCOL *DevPathNode; - EFI_DEVICE_PATH_PROTOCOL *DevPath; - UINTN RootSlot; - UINTN Idx; - UINT8 IrqLine; - EFI_STATUS Status; - UINT32 RootBusNumber; - - Status = EFI_SUCCESS; - - if (PciHdr->Device.InterruptPin != 0) { - - DevPathNode = DevicePathFromHandle (Handle); - ASSERT (DevPathNode != NULL); - DevPath = DevPathNode; - - RootBusNumber = 0; - if (DevicePathType (DevPathNode) == ACPI_DEVICE_PATH && - DevicePathSubType (DevPathNode) == ACPI_DP && - ((ACPI_HID_DEVICE_PATH *)DevPathNode)->HID == EISA_PNP_ID(0x0A03)) { - RootBusNumber = ((ACPI_HID_DEVICE_PATH *)DevPathNode)->UID; - } - - // - // Compute index into PciHostIrqs[] table by walking - // the device path and adding up all device numbers - // - Status = EFI_NOT_FOUND; - RootSlot = 0; - Idx = PciHdr->Device.InterruptPin - 1; - while (!IsDevicePathEnd (DevPathNode)) { - if (DevicePathType (DevPathNode) == HARDWARE_DEVICE_PATH && - DevicePathSubType (DevPathNode) == HW_PCI_DP) { - - Idx += ((PCI_DEVICE_PATH *)DevPathNode)->Device; - - // - // Unlike SeaBIOS, which starts climbing from the leaf device - // up toward the root, we traverse the device path starting at - // the root moving toward the leaf node. - // The slot number of the top-level parent bridge is needed for - // Q35 cases with more than 24 slots on the root bus. - // - if (Status != EFI_SUCCESS) { - Status = EFI_SUCCESS; - RootSlot = ((PCI_DEVICE_PATH *)DevPathNode)->Device; - } - } - - DevPathNode = NextDevicePathNode (DevPathNode); - } - if (EFI_ERROR (Status)) { - return Status; - } - if (RootBusNumber == 0 && RootSlot == 0) { - DEBUG(( - EFI_D_ERROR, - "%a: PCI host bridge (00:00.0) should have no interrupts!\n", - __FUNCTION__ - )); - ASSERT (FALSE); - } - - // - // Final PciHostIrqs[] index calculation depends on the platform - // and should match SeaBIOS src/fw/pciinit.c *_pci_slot_get_irq() - // - switch (mHostBridgeDevId) { - case INTEL_82441_DEVICE_ID: - Idx -= 1; - break; - case INTEL_Q35_MCH_DEVICE_ID: - // - // SeaBIOS contains the following comment: - // "Slots 0-24 rotate slot:pin mapping similar to piix above, but - // with a different starting index - see q35-acpi-dsdt.dsl. - // - // Slots 25-31 all use LNKA mapping (or LNKE, but A:D = E:H)" - // - if (RootSlot > 24) { - // - // in this case, subtract back out RootSlot from Idx - // (SeaBIOS never adds it to begin with, but that would make our - // device path traversal loop above too awkward) - // - Idx -= RootSlot; - } - break; - default: - ASSERT (FALSE); // should never get here - } - Idx %= ARRAY_SIZE (PciHostIrqs); - IrqLine = PciHostIrqs[Idx]; - - DEBUG_CODE_BEGIN (); - { - CHAR16 *DevPathString; - STATIC CHAR16 Fallback[] = L""; - UINTN Segment, Bus, Device, Function; - - DevPathString = ConvertDevicePathToText (DevPath, FALSE, FALSE); - if (DevPathString == NULL) { - DevPathString = Fallback; - } - Status = PciIo->GetLocation (PciIo, &Segment, &Bus, &Device, &Function); - ASSERT_EFI_ERROR (Status); - - DEBUG ((EFI_D_VERBOSE, "%a: [%02x:%02x.%x] %s -> 0x%02x\n", __FUNCTION__, - (UINT32)Bus, (UINT32)Device, (UINT32)Function, DevPathString, - IrqLine)); - - if (DevPathString != Fallback) { - FreePool (DevPathString); - } - } - DEBUG_CODE_END (); - - // - // Set PCI Interrupt Line register for this device to PciHostIrqs[Idx] - // - Status = PciIo->Pci.Write ( - PciIo, - EfiPciIoWidthUint8, - PCI_INT_LINE_OFFSET, - 1, - &IrqLine - ); - } - - return Status; -} - - -VOID -PciAcpiInitialization ( - ) -{ - UINTN Pmba; - - // - // Query Host Bridge DID to determine platform type - // - mHostBridgeDevId = PcdGet16 (PcdOvmfHostBridgePciDevId); - switch (mHostBridgeDevId) { - case INTEL_82441_DEVICE_ID: - Pmba = POWER_MGMT_REGISTER_PIIX4 (PIIX4_PMBA); - // - // 00:01.0 ISA Bridge (PIIX4) LNK routing targets - // - PciWrite8 (PCI_LIB_ADDRESS (0, 1, 0, 0x60), 0x0b); // A - PciWrite8 (PCI_LIB_ADDRESS (0, 1, 0, 0x61), 0x0b); // B - PciWrite8 (PCI_LIB_ADDRESS (0, 1, 0, 0x62), 0x0a); // C - PciWrite8 (PCI_LIB_ADDRESS (0, 1, 0, 0x63), 0x0a); // D - break; - case INTEL_Q35_MCH_DEVICE_ID: - Pmba = POWER_MGMT_REGISTER_Q35 (ICH9_PMBASE); - // - // 00:1f.0 LPC Bridge (Q35) LNK routing targets - // - PciWrite8 (PCI_LIB_ADDRESS (0, 0x1f, 0, 0x60), 0x0a); // A - PciWrite8 (PCI_LIB_ADDRESS (0, 0x1f, 0, 0x61), 0x0a); // B - PciWrite8 (PCI_LIB_ADDRESS (0, 0x1f, 0, 0x62), 0x0b); // C - PciWrite8 (PCI_LIB_ADDRESS (0, 0x1f, 0, 0x63), 0x0b); // D - PciWrite8 (PCI_LIB_ADDRESS (0, 0x1f, 0, 0x68), 0x0a); // E - PciWrite8 (PCI_LIB_ADDRESS (0, 0x1f, 0, 0x69), 0x0a); // F - PciWrite8 (PCI_LIB_ADDRESS (0, 0x1f, 0, 0x6a), 0x0b); // G - PciWrite8 (PCI_LIB_ADDRESS (0, 0x1f, 0, 0x6b), 0x0b); // H - break; - default: - DEBUG ((EFI_D_ERROR, "%a: Unknown Host Bridge Device ID: 0x%04x\n", - __FUNCTION__, mHostBridgeDevId)); - ASSERT (FALSE); - return; - } - - // - // Initialize PCI_INTERRUPT_LINE for applicable present PCI devices - // - VisitAllPciInstances (SetPciIntLine); - - // - // Set ACPI SCI_EN bit in PMCNTRL - // - IoOr16 ((PciRead32 (Pmba) & ~BIT0) + 4, BIT0); -} - -/** - This function detects if OVMF is running on Xen. - -**/ -STATIC -BOOLEAN -XenDetected ( - VOID - ) -{ - EFI_HOB_GUID_TYPE *GuidHob; - STATIC INTN FoundHob = -1; - - if (FoundHob == 0) { - return FALSE; - } else if (FoundHob == 1) { - return TRUE; - } - - // - // See if a XenInfo HOB is available - // - GuidHob = GetFirstGuidHob (&gEfiXenInfoGuid); - if (GuidHob == NULL) { - FoundHob = 0; - return FALSE; - } - - FoundHob = 1; - return TRUE; -} - -EFI_STATUS -EFIAPI -ConnectRecursivelyIfPciMassStorage ( - IN EFI_HANDLE Handle, - IN EFI_PCI_IO_PROTOCOL *Instance, - IN PCI_TYPE00 *PciHeader - ) -{ - EFI_STATUS Status; - EFI_DEVICE_PATH_PROTOCOL *DevicePath; - CHAR16 *DevPathStr; - - // - // Recognize PCI Mass Storage, and Xen PCI devices - // - if (IS_CLASS1 (PciHeader, PCI_CLASS_MASS_STORAGE) || - (XenDetected() && IS_CLASS2 (PciHeader, 0xFF, 0x80))) { - DevicePath = NULL; - Status = gBS->HandleProtocol ( - Handle, - &gEfiDevicePathProtocolGuid, - (VOID*)&DevicePath - ); - if (EFI_ERROR (Status)) { - return Status; - } - - // - // Print Device Path - // - DevPathStr = ConvertDevicePathToText (DevicePath, FALSE, FALSE); - if (DevPathStr != NULL) { - DEBUG(( - EFI_D_INFO, - "Found %s device: %s\n", - IS_CLASS1 (PciHeader, PCI_CLASS_MASS_STORAGE) ? L"Mass Storage" : L"Xen", - DevPathStr - )); - FreePool(DevPathStr); - } - - Status = gBS->ConnectController (Handle, NULL, NULL, TRUE); - if (EFI_ERROR (Status)) { - return Status; - } - - } - - return EFI_SUCCESS; -} - - -/** - This notification function is invoked when the - EMU Variable FVB has been changed. - - @param Event The event that occurred - @param Context For EFI compatibility. Not used. - -**/ -VOID -EFIAPI -EmuVariablesUpdatedCallback ( - IN EFI_EVENT Event, - IN VOID *Context - ) -{ - DEBUG ((EFI_D_INFO, "EmuVariablesUpdatedCallback\n")); - UpdateNvVarsOnFileSystem (); -} - - -EFI_STATUS -EFIAPI -VisitingFileSystemInstance ( - IN EFI_HANDLE Handle, - IN VOID *Instance, - IN VOID *Context - ) -{ - EFI_STATUS Status; - STATIC BOOLEAN ConnectedToFileSystem = FALSE; - RETURN_STATUS PcdStatus; - - if (ConnectedToFileSystem) { - return EFI_ALREADY_STARTED; - } - - Status = ConnectNvVarsToFileSystem (Handle); - if (EFI_ERROR (Status)) { - return Status; - } - - ConnectedToFileSystem = TRUE; - mEmuVariableEvent = - EfiCreateProtocolNotifyEvent ( - &gEfiDevicePathProtocolGuid, - TPL_CALLBACK, - EmuVariablesUpdatedCallback, - NULL, - &mEmuVariableEventReg - ); - PcdStatus = PcdSet64S (PcdEmuVariableEvent, - (UINT64)(UINTN) mEmuVariableEvent); - ASSERT_RETURN_ERROR (PcdStatus); - - return EFI_SUCCESS; -} - - -VOID -PlatformBdsRestoreNvVarsFromHardDisk ( - ) -{ - VisitAllPciInstances (ConnectRecursivelyIfPciMassStorage); - VisitAllInstancesOfProtocol ( - &gEfiSimpleFileSystemProtocolGuid, - VisitingFileSystemInstance, - NULL - ); - -} - -VOID -PlatformBdsConnectSequence ( - VOID - ) -/*++ - -Routine Description: - - Connect with predefined platform connect sequence, - the OEM/IBV can customize with their own connect sequence. - -Arguments: - - None. - -Returns: - - None. - ---*/ -{ - UINTN Index; - - DEBUG ((EFI_D_INFO, "PlatformBdsConnectSequence\n")); - - Index = 0; - - // - // Here we can get the customized platform connect sequence - // Notes: we can connect with new variable which record the - // last time boots connect device path sequence - // - while (gPlatformConnectSequence[Index] != NULL) { - // - // Build the platform boot option - // - EfiBootManagerConnectDevicePath (gPlatformConnectSequence[Index], NULL); - Index++; - } - - // - // Just use the simple policy to connect all devices - // - DEBUG ((EFI_D_INFO, "EfiBootManagerConnectAll\n")); - EfiBootManagerConnectAll (); - - PciAcpiInitialization (); -} - -/** - Save the S3 boot script. - - Note that DxeSmmReadyToLock must be signaled after this function returns; - otherwise the script wouldn't be saved actually. -**/ -STATIC -VOID -SaveS3BootScript ( - VOID - ) -{ - EFI_STATUS Status; - EFI_S3_SAVE_STATE_PROTOCOL *BootScript; - STATIC CONST UINT8 Info[] = { 0xDE, 0xAD, 0xBE, 0xEF }; - - Status = gBS->LocateProtocol (&gEfiS3SaveStateProtocolGuid, NULL, - (VOID **) &BootScript); - ASSERT_EFI_ERROR (Status); - - // - // Despite the opcode documentation in the PI spec, the protocol - // implementation embeds a deep copy of the info in the boot script, rather - // than storing just a pointer to runtime or NVS storage. - // - Status = BootScript->Write(BootScript, EFI_BOOT_SCRIPT_INFORMATION_OPCODE, - (UINT32) sizeof Info, - (EFI_PHYSICAL_ADDRESS)(UINTN) &Info); - ASSERT_EFI_ERROR (Status); -} - - -VOID -EFIAPI -PlatformBootManagerAfterConsole ( - VOID - ) -/*++ - -Routine Description: - - The function will execute with as the platform policy, current policy - is driven by boot mode. IBV/OEM can customize this code for their specific - policy action. - ---*/ -{ - EFI_BOOT_MODE BootMode; - - DEBUG ((EFI_D_INFO, "PlatformBootManagerAfterConsole\n")); - - if (PcdGetBool (PcdOvmfFlashVariablesEnable)) { - DEBUG ((EFI_D_INFO, "PlatformBdsPolicyBehavior: not restoring NvVars " - "from disk since flash variables appear to be supported.\n")); - } else { - // - // Try to restore variables from the hard disk early so - // they can be used for the other BDS connect operations. - // - PlatformBdsRestoreNvVarsFromHardDisk (); - } - - // - // Get current Boot Mode - // - BootMode = GetBootModeHob (); - DEBUG ((EFI_D_ERROR, "Boot Mode:%x\n", BootMode)); - - // - // Go the different platform policy with different boot mode - // Notes: this part code can be change with the table policy - // - ASSERT (BootMode == BOOT_WITH_FULL_CONFIGURATION); - - // - // Logo show - // - BootLogoEnableLogo (); - - // - // Perform some platform specific connect sequence - // - PlatformBdsConnectSequence (); - - // - // Process QEMU's -kernel command line option - // - TryRunningQemuKernel (); - - EfiBootManagerRefreshAllBootOption (); - - // - // Register UEFI Shell - // - PlatformRegisterFvBootOption ( - PcdGetPtr (PcdShellFile), L"EFI Internal Shell", LOAD_OPTION_ACTIVE - ); - - RemoveStaleFvFileOptions (); - SetBootOrderFromQemu (); -} - -/** - This notification function is invoked when an instance of the - EFI_DEVICE_PATH_PROTOCOL is produced. - - @param Event The event that occurred - @param Context For EFI compatibility. Not used. - -**/ -VOID -EFIAPI -NotifyDevPath ( - IN EFI_EVENT Event, - IN VOID *Context - ) -{ - EFI_HANDLE Handle; - EFI_STATUS Status; - UINTN BufferSize; - EFI_DEVICE_PATH_PROTOCOL *DevPathNode; - ATAPI_DEVICE_PATH *Atapi; - - // - // Examine all new handles - // - for (;;) { - // - // Get the next handle - // - BufferSize = sizeof (Handle); - Status = gBS->LocateHandle ( - ByRegisterNotify, - NULL, - mEfiDevPathNotifyReg, - &BufferSize, - &Handle - ); - - // - // If not found, we're done - // - if (EFI_NOT_FOUND == Status) { - break; - } - - if (EFI_ERROR (Status)) { - continue; - } - - // - // Get the DevicePath protocol on that handle - // - Status = gBS->HandleProtocol (Handle, &gEfiDevicePathProtocolGuid, (VOID **)&DevPathNode); - ASSERT_EFI_ERROR (Status); - - while (!IsDevicePathEnd (DevPathNode)) { - // - // Find the handler to dump this device path node - // - if ( - (DevicePathType(DevPathNode) == MESSAGING_DEVICE_PATH) && - (DevicePathSubType(DevPathNode) == MSG_ATAPI_DP) - ) { - Atapi = (ATAPI_DEVICE_PATH*) DevPathNode; - PciOr16 ( - PCI_LIB_ADDRESS ( - 0, - 1, - 1, - (Atapi->PrimarySecondary == 1) ? 0x42: 0x40 - ), - BIT15 - ); - } - - // - // Next device path node - // - DevPathNode = NextDevicePathNode (DevPathNode); - } - } - - return; -} - - -VOID -InstallDevicePathCallback ( - VOID - ) -{ - DEBUG ((EFI_D_INFO, "Registered NotifyDevPath Event\n")); - mEfiDevPathEvent = EfiCreateProtocolNotifyEvent ( - &gEfiDevicePathProtocolGuid, - TPL_CALLBACK, - NotifyDevPath, - NULL, - &mEfiDevPathNotifyReg - ); -} - -/** - This function is called each second during the boot manager waits the timeout. - - @param TimeoutRemain The remaining timeout. -**/ -VOID -EFIAPI -PlatformBootManagerWaitCallback ( - UINT16 TimeoutRemain - ) -{ - EFI_GRAPHICS_OUTPUT_BLT_PIXEL_UNION Black; - EFI_GRAPHICS_OUTPUT_BLT_PIXEL_UNION White; - UINT16 Timeout; - - Timeout = PcdGet16 (PcdPlatformBootTimeOut); - - Black.Raw = 0x00000000; - White.Raw = 0x00FFFFFF; - - BootLogoUpdateProgress ( - White.Pixel, - Black.Pixel, - L"Start boot option", - White.Pixel, - (Timeout - TimeoutRemain) * 100 / Timeout, - 0 - ); -} - diff --git a/OvmfPkg/Library/PlatformBootManagerLib/BdsPlatform.h b/OvmfPkg/Library/PlatformBootManagerLib/BdsPlatform.h deleted file mode 100644 index 97ffbb5148..0000000000 --- a/OvmfPkg/Library/PlatformBootManagerLib/BdsPlatform.h +++ /dev/null @@ -1,195 +0,0 @@ -/** @file - Platform BDS customizations include file. - - Copyright (c) 2006 - 2017, Intel Corporation. All rights reserved.
- This program and the accompanying materials - are licensed and made available under the terms and conditions of the BSD License - which accompanies this distribution. The full text of the license may be found at - http://opensource.org/licenses/bsd-license.php - - THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, - WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. - -Module Name: - - BdsPlatform.h - -Abstract: - - Head file for BDS Platform specific code - -**/ - -#ifndef _PLATFORM_SPECIFIC_BDS_PLATFORM_H_ -#define _PLATFORM_SPECIFIC_BDS_PLATFORM_H_ - - -#include - -#include -#include -#include -#include - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#include -#include -#include -#include -#include -#include -#include -#include - -#include -#include -#include -#include -#include -#include -#include - -#include - -extern EFI_DEVICE_PATH_PROTOCOL *gPlatformConnectSequence[]; -extern ACPI_HID_DEVICE_PATH gPnpPs2KeyboardDeviceNode; -extern ACPI_HID_DEVICE_PATH gPnp16550ComPortDeviceNode; -extern UART_DEVICE_PATH gUartDeviceNode; -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) \ - } \ - }, \ - (Func), \ - (Dev) \ - } - -#define PNPID_DEVICE_PATH_NODE(PnpId) \ - { \ - { \ - ACPI_DEVICE_PATH, \ - ACPI_DP, \ - { \ - (UINT8) (sizeof (ACPI_HID_DEVICE_PATH)), \ - (UINT8) ((sizeof (ACPI_HID_DEVICE_PATH)) >> 8) \ - }, \ - }, \ - EISA_PNP_ID((PnpId)), \ - 0 \ - } - -#define gPciIsaBridge \ - PCI_DEVICE_PATH_NODE(0, 0x1f) - -#define gP2PBridge \ - PCI_DEVICE_PATH_NODE(0, 0x1e) - -#define gPnpPs2Keyboard \ - PNPID_DEVICE_PATH_NODE(0x0303) - -#define gPnp16550ComPort \ - PNPID_DEVICE_PATH_NODE(0x0501) - -#define gUart \ - { \ - { \ - MESSAGING_DEVICE_PATH, \ - MSG_UART_DP, \ - { \ - (UINT8) (sizeof (UART_DEVICE_PATH)), \ - (UINT8) ((sizeof (UART_DEVICE_PATH)) >> 8) \ - } \ - }, \ - 0, \ - 115200, \ - 8, \ - 1, \ - 1 \ - } - -#define gPcAnsiTerminal \ - { \ - { \ - MESSAGING_DEVICE_PATH, \ - MSG_VENDOR_DP, \ - { \ - (UINT8) (sizeof (VENDOR_DEVICE_PATH)), \ - (UINT8) ((sizeof (VENDOR_DEVICE_PATH)) >> 8) \ - } \ - }, \ - DEVICE_PATH_MESSAGING_PC_ANSI \ - } - -#define gEndEntire \ - { \ - END_DEVICE_PATH_TYPE, \ - END_ENTIRE_DEVICE_PATH_SUBTYPE, \ - { \ - END_DEVICE_PATH_LENGTH, \ - 0 \ - } \ - } - -#define PCI_CLASS_SCC 0x07 -#define PCI_SUBCLASS_SERIAL 0x00 -#define PCI_IF_16550 0x02 -#define IS_PCI_16550SERIAL(_p) IS_CLASS3 (_p, PCI_CLASS_SCC, PCI_SUBCLASS_SERIAL, PCI_IF_16550) -#define IS_PCI_ISA_PDECODE(_p) IS_CLASS3 (_p, PCI_CLASS_BRIDGE, PCI_CLASS_BRIDGE_ISA_PDECODE, 0) - -typedef struct { - EFI_DEVICE_PATH_PROTOCOL *DevicePath; - UINTN ConnectType; -} PLATFORM_CONSOLE_CONNECT_ENTRY; - -#define CONSOLE_OUT BIT0 -#define CONSOLE_IN BIT1 -#define STD_ERROR BIT2 -extern PLATFORM_CONSOLE_CONNECT_ENTRY gPlatformConsole[]; - -// -// Platform BDS Functions -// - -VOID -PlatformInitializeConsole ( - IN PLATFORM_CONSOLE_CONNECT_ENTRY *PlatformConsole - ); - -/** - Loads and boots UEFI Linux via the FwCfg interface. - - @retval EFI_NOT_FOUND - The Linux kernel was not found - -**/ -EFI_STATUS -TryRunningQemuKernel ( - VOID - ); - -#endif // _PLATFORM_SPECIFIC_BDS_PLATFORM_H_ diff --git a/OvmfPkg/Library/PlatformBootManagerLib/PlatformBootManagerLib.inf b/OvmfPkg/Library/PlatformBootManagerLib/PlatformBootManagerLib.inf deleted file mode 100644 index 27789b7377..0000000000 --- a/OvmfPkg/Library/PlatformBootManagerLib/PlatformBootManagerLib.inf +++ /dev/null @@ -1,81 +0,0 @@ -## @file -# Platform BDS customizations library. -# -# Copyright (c) 2007 - 2017, Intel Corporation. All rights reserved.
-# This program and the accompanying materials -# are licensed and made available under the terms and conditions of the BSD License -# which accompanies this distribution. The full text of the license may be found at -# http://opensource.org/licenses/bsd-license.php -# -# THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, -# WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. -# -## - -[Defines] - INF_VERSION = 0x00010005 - BASE_NAME = PlatformBootManagerLib - FILE_GUID = FB65006C-AC9F-4992-AD80-184B2BDBBD83 - MODULE_TYPE = DXE_DRIVER - VERSION_STRING = 1.0 - LIBRARY_CLASS = PlatformBootManagerLib|DXE_DRIVER - -# -# The following information is for reference only and not required by the build tools. -# -# VALID_ARCHITECTURES = IA32 X64 IPF EBC -# - -[Sources] - BdsPlatform.c - PlatformData.c - QemuKernel.c - BdsPlatform.h - -[Packages] - MdePkg/MdePkg.dec - MdeModulePkg/MdeModulePkg.dec - IntelFrameworkModulePkg/IntelFrameworkModulePkg.dec - SourceLevelDebugPkg/SourceLevelDebugPkg.dec - OvmfPkg/OvmfPkg.dec - -[LibraryClasses] - BaseLib - MemoryAllocationLib - UefiBootServicesTableLib - BaseMemoryLib - DebugLib - PcdLib - UefiBootManagerLib - BootLogoLib - DevicePathLib - PciLib - NvVarsFileLib - QemuFwCfgLib - QemuFwCfgS3Lib - LoadLinuxLib - QemuBootOrderLib - UefiLib - -[Pcd] - gUefiOvmfPkgTokenSpaceGuid.PcdEmuVariableEvent - gUefiOvmfPkgTokenSpaceGuid.PcdOvmfFlashVariablesEnable - gUefiOvmfPkgTokenSpaceGuid.PcdOvmfHostBridgePciDevId - gEfiMdePkgTokenSpaceGuid.PcdPlatformBootTimeOut - gEfiIntelFrameworkModulePkgTokenSpaceGuid.PcdShellFile - -[Pcd.IA32, Pcd.X64] - gEfiMdePkgTokenSpaceGuid.PcdFSBClock - -[Protocols] - gEfiDecompressProtocolGuid - gEfiPciRootBridgeIoProtocolGuid - gEfiS3SaveStateProtocolGuid # PROTOCOL SOMETIMES_CONSUMED - gEfiDxeSmmReadyToLockProtocolGuid # PROTOCOL SOMETIMES_PRODUCED - gEfiLoadedImageProtocolGuid # PROTOCOL SOMETIMES_PRODUCED - gEfiFirmwareVolume2ProtocolGuid # PROTOCOL SOMETIMES_CONSUMED - -[Guids] - gEfiXenInfoGuid - gEfiEndOfDxeEventGroupGuid - gRootBridgesConnectedEventGroupGuid diff --git a/OvmfPkg/Library/PlatformBootManagerLib/PlatformData.c b/OvmfPkg/Library/PlatformBootManagerLib/PlatformData.c deleted file mode 100644 index 82f294577e..0000000000 --- a/OvmfPkg/Library/PlatformBootManagerLib/PlatformData.c +++ /dev/null @@ -1,93 +0,0 @@ -/** @file - Defined the platform specific device path which will be used by - platform Bbd to perform the platform policy connect. - - Copyright (c) 2004 - 2017, Intel Corporation. All rights reserved.
- This program and the accompanying materials - are licensed and made available under the terms and conditions of the BSD License - which accompanies this distribution. The full text of the license may be found at - http://opensource.org/licenses/bsd-license.php - - THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, - WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. - -**/ - -#include "BdsPlatform.h" - -// -// Debug Agent UART Device Path structure -// -#pragma pack(1) -typedef struct { - VENDOR_DEVICE_PATH VendorHardware; - UART_DEVICE_PATH Uart; - VENDOR_DEVICE_PATH TerminalType; - EFI_DEVICE_PATH_PROTOCOL End; -} VENDOR_UART_DEVICE_PATH; -#pragma pack() - -ACPI_HID_DEVICE_PATH gPnpPs2KeyboardDeviceNode = gPnpPs2Keyboard; -ACPI_HID_DEVICE_PATH gPnp16550ComPortDeviceNode = gPnp16550ComPort; -UART_DEVICE_PATH gUartDeviceNode = gUart; -VENDOR_DEVICE_PATH gTerminalTypeDeviceNode = gPcAnsiTerminal; - -// -// Platform specific keyboard device path -// - - -// -// Debug Agent UART Device Path -// -VENDOR_UART_DEVICE_PATH gDebugAgentUartDevicePath = { - { - { - HARDWARE_DEVICE_PATH, - HW_VENDOR_DP, - { - (UINT8) (sizeof (VENDOR_DEVICE_PATH)), - (UINT8) ((sizeof (VENDOR_DEVICE_PATH)) >> 8) - } - }, - EFI_DEBUG_AGENT_GUID, - }, - { - { - MESSAGING_DEVICE_PATH, - MSG_UART_DP, - { - (UINT8) (sizeof (UART_DEVICE_PATH)), - (UINT8) ((sizeof (UART_DEVICE_PATH)) >> 8) - } - }, - 0, // Reserved - 0, // BaudRate - Default - 0, // DataBits - Default - 0, // Parity - Default - 0, // StopBits - Default - }, - gPcAnsiTerminal, - gEndEntire -}; - - -// -// Predefined platform default console device path -// -PLATFORM_CONSOLE_CONNECT_ENTRY gPlatformConsole[] = { - { - (EFI_DEVICE_PATH_PROTOCOL *) &gDebugAgentUartDevicePath, - (CONSOLE_OUT | CONSOLE_IN | STD_ERROR) - }, - { - NULL, - 0 - } -}; - -// -// Predefined platform connect sequence -// -EFI_DEVICE_PATH_PROTOCOL *gPlatformConnectSequence[] = { NULL }; - diff --git a/OvmfPkg/Library/PlatformBootManagerLib/QemuKernel.c b/OvmfPkg/Library/PlatformBootManagerLib/QemuKernel.c deleted file mode 100644 index ef728dfdeb..0000000000 --- a/OvmfPkg/Library/PlatformBootManagerLib/QemuKernel.c +++ /dev/null @@ -1,170 +0,0 @@ -/** @file - - Copyright (c) 2006 - 2015, Intel Corporation. All rights reserved.
- This program and the accompanying materials - are licensed and made available under the terms and conditions of the BSD License - which accompanies this distribution. The full text of the license may be found at - http://opensource.org/licenses/bsd-license.php - - THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, - WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. - -**/ - -#include - -#include -#include -#include -#include -#include -#include -#include - - -EFI_STATUS -TryRunningQemuKernel ( - VOID - ) -{ - EFI_STATUS Status; - UINTN KernelSize; - UINTN KernelInitialSize; - VOID *KernelBuf; - UINTN SetupSize; - VOID *SetupBuf; - UINTN CommandLineSize; - CHAR8 *CommandLine; - UINTN InitrdSize; - VOID* InitrdData; - - SetupBuf = NULL; - SetupSize = 0; - KernelBuf = NULL; - KernelInitialSize = 0; - CommandLine = NULL; - CommandLineSize = 0; - InitrdData = NULL; - InitrdSize = 0; - - if (!QemuFwCfgIsAvailable ()) { - return EFI_NOT_FOUND; - } - - QemuFwCfgSelectItem (QemuFwCfgItemKernelSize); - KernelSize = (UINTN) QemuFwCfgRead64 (); - - QemuFwCfgSelectItem (QemuFwCfgItemKernelSetupSize); - SetupSize = (UINTN) QemuFwCfgRead64 (); - - if (KernelSize == 0 || SetupSize == 0) { - DEBUG ((EFI_D_INFO, "qemu -kernel was not used.\n")); - return EFI_NOT_FOUND; - } - - SetupBuf = LoadLinuxAllocateKernelSetupPages (EFI_SIZE_TO_PAGES (SetupSize)); - if (SetupBuf == NULL) { - DEBUG ((EFI_D_ERROR, "Unable to allocate memory for kernel setup!\n")); - return EFI_OUT_OF_RESOURCES; - } - - DEBUG ((EFI_D_INFO, "Setup size: 0x%x\n", (UINT32) SetupSize)); - DEBUG ((EFI_D_INFO, "Reading kernel setup image ...")); - QemuFwCfgSelectItem (QemuFwCfgItemKernelSetupData); - QemuFwCfgReadBytes (SetupSize, SetupBuf); - DEBUG ((EFI_D_INFO, " [done]\n")); - - Status = LoadLinuxCheckKernelSetup (SetupBuf, SetupSize); - if (EFI_ERROR (Status)) { - goto FreeAndReturn; - } - - Status = LoadLinuxInitializeKernelSetup (SetupBuf); - if (EFI_ERROR (Status)) { - goto FreeAndReturn; - } - - KernelInitialSize = LoadLinuxGetKernelSize (SetupBuf, KernelSize); - if (KernelInitialSize == 0) { - Status = EFI_UNSUPPORTED; - goto FreeAndReturn; - } - - KernelBuf = LoadLinuxAllocateKernelPages ( - SetupBuf, - EFI_SIZE_TO_PAGES (KernelInitialSize)); - if (KernelBuf == NULL) { - DEBUG ((EFI_D_ERROR, "Unable to allocate memory for kernel!\n")); - Status = EFI_OUT_OF_RESOURCES; - goto FreeAndReturn; - } - - DEBUG ((EFI_D_INFO, "Kernel size: 0x%x\n", (UINT32) KernelSize)); - DEBUG ((EFI_D_INFO, "Reading kernel image ...")); - QemuFwCfgSelectItem (QemuFwCfgItemKernelData); - QemuFwCfgReadBytes (KernelSize, KernelBuf); - DEBUG ((EFI_D_INFO, " [done]\n")); - - QemuFwCfgSelectItem (QemuFwCfgItemCommandLineSize); - CommandLineSize = (UINTN) QemuFwCfgRead64 (); - - if (CommandLineSize > 0) { - CommandLine = LoadLinuxAllocateCommandLinePages ( - EFI_SIZE_TO_PAGES (CommandLineSize)); - QemuFwCfgSelectItem (QemuFwCfgItemCommandLineData); - QemuFwCfgReadBytes (CommandLineSize, CommandLine); - } else { - CommandLine = NULL; - } - - Status = LoadLinuxSetCommandLine (SetupBuf, CommandLine); - if (EFI_ERROR (Status)) { - goto FreeAndReturn; - } - - QemuFwCfgSelectItem (QemuFwCfgItemInitrdSize); - InitrdSize = (UINTN) QemuFwCfgRead64 (); - - if (InitrdSize > 0) { - InitrdData = LoadLinuxAllocateInitrdPages ( - SetupBuf, - EFI_SIZE_TO_PAGES (InitrdSize) - ); - DEBUG ((EFI_D_INFO, "Initrd size: 0x%x\n", (UINT32) InitrdSize)); - DEBUG ((EFI_D_INFO, "Reading initrd image ...")); - QemuFwCfgSelectItem (QemuFwCfgItemInitrdData); - QemuFwCfgReadBytes (InitrdSize, InitrdData); - DEBUG ((EFI_D_INFO, " [done]\n")); - } else { - InitrdData = NULL; - } - - Status = LoadLinuxSetInitrd (SetupBuf, InitrdData, InitrdSize); - if (EFI_ERROR (Status)) { - goto FreeAndReturn; - } - - // - // Signal the EVT_SIGNAL_READY_TO_BOOT event - // - EfiSignalEventReadyToBoot(); - - Status = LoadLinux (KernelBuf, SetupBuf); - -FreeAndReturn: - if (SetupBuf != NULL) { - FreePages (SetupBuf, EFI_SIZE_TO_PAGES (SetupSize)); - } - if (KernelBuf != NULL) { - FreePages (KernelBuf, EFI_SIZE_TO_PAGES (KernelInitialSize)); - } - if (CommandLine != NULL) { - FreePages (CommandLine, EFI_SIZE_TO_PAGES (CommandLineSize)); - } - if (InitrdData != NULL) { - FreePages (InitrdData, EFI_SIZE_TO_PAGES (InitrdSize)); - } - - return Status; -} - diff --git a/OvmfPkg/Library/PlatformDebugLibIoPort/DebugLib.c b/OvmfPkg/Library/PlatformDebugLibIoPort/DebugLib.c deleted file mode 100644 index 44850a9dba..0000000000 --- a/OvmfPkg/Library/PlatformDebugLibIoPort/DebugLib.c +++ /dev/null @@ -1,287 +0,0 @@ -/** @file - Base Debug library instance for QEMU debug port. - It uses PrintLib to send debug messages to a fixed I/O port. - - Copyright (c) 2006 - 2015, Intel Corporation. All rights reserved.
- 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 -#include -#include -#include -#include -#include -#include -#include -#include - -// -// Define the maximum debug and assert message length that this library supports -// -#define MAX_DEBUG_MESSAGE_LENGTH 0x100 - -/** - This constructor function does not have to do anything. - - @retval EFI_SUCCESS The constructor always returns RETURN_SUCCESS. - -**/ -RETURN_STATUS -EFIAPI -PlatformDebugLibIoPortConstructor ( - VOID - ) -{ - return EFI_SUCCESS; -} - -/** - Prints a debug message to the debug output device if the specified error level is enabled. - - If any bit in ErrorLevel is also set in DebugPrintErrorLevelLib function - GetDebugPrintErrorLevel (), then print the message specified by Format and the - associated variable argument list to the debug output device. - - If Format is NULL, then ASSERT(). - - @param ErrorLevel The error level of the debug message. - @param Format Format string for the debug message to print. - @param ... Variable argument list whose contents are accessed - based on the format string specified by Format. - -**/ -VOID -EFIAPI -DebugPrint ( - IN UINTN ErrorLevel, - IN CONST CHAR8 *Format, - ... - ) -{ - CHAR8 Buffer[MAX_DEBUG_MESSAGE_LENGTH]; - VA_LIST Marker; - UINT8 *Ptr; - - // - // If Format is NULL, then ASSERT(). - // - ASSERT (Format != NULL); - - // - // Check driver debug mask value and global mask - // - if ((ErrorLevel & GetDebugPrintErrorLevel ()) == 0) { - return; - } - - // - // Convert the DEBUG() message to an ASCII String - // - VA_START (Marker, Format); - AsciiVSPrint (Buffer, sizeof (Buffer), Format, Marker); - VA_END (Marker); - - // - // Send the print string to the debug I/O port - // - for (Ptr = (UINT8 *) Buffer; *Ptr; Ptr++) { - IoWrite8 (PcdGet16(PcdDebugIoPort), *Ptr); - } -} - - -/** - Prints an assert message containing a filename, line number, and description. - This may be followed by a breakpoint or a dead loop. - - Print a message of the form "ASSERT (): \n" - to the debug output device. If DEBUG_PROPERTY_ASSERT_BREAKPOINT_ENABLED bit of - PcdDebugProperyMask is set then CpuBreakpoint() is called. Otherwise, if - DEBUG_PROPERTY_ASSERT_DEADLOOP_ENABLED bit of PcdDebugProperyMask is set then - CpuDeadLoop() is called. If neither of these bits are set, then this function - returns immediately after the message is printed to the debug output device. - DebugAssert() must actively prevent recursion. If DebugAssert() is called while - processing another DebugAssert(), then DebugAssert() must return immediately. - - If FileName is NULL, then a string of "(NULL) Filename" is printed. - If Description is NULL, then a string of "(NULL) Description" is printed. - - @param FileName The pointer to the name of the source file that generated the assert condition. - @param LineNumber The line number in the source file that generated the assert condition - @param Description The pointer to the description of the assert condition. - -**/ -VOID -EFIAPI -DebugAssert ( - IN CONST CHAR8 *FileName, - IN UINTN LineNumber, - IN CONST CHAR8 *Description - ) -{ - CHAR8 Buffer[MAX_DEBUG_MESSAGE_LENGTH]; - UINT8 *Ptr; - - // - // Generate the ASSERT() message in Ascii format - // - AsciiSPrint (Buffer, sizeof Buffer, "ASSERT %a(%Lu): %a\n", FileName, - (UINT64)LineNumber, Description); - - // - // Send the print string to the Console Output device - // - for (Ptr = (UINT8 *) Buffer; *Ptr; Ptr++) { - IoWrite8 (PcdGet16(PcdDebugIoPort), *Ptr); - } - - // - // Generate a Breakpoint, DeadLoop, or NOP based on PCD settings - // - if ((PcdGet8(PcdDebugPropertyMask) & DEBUG_PROPERTY_ASSERT_BREAKPOINT_ENABLED) != 0) { - CpuBreakpoint (); - } else if ((PcdGet8(PcdDebugPropertyMask) & DEBUG_PROPERTY_ASSERT_DEADLOOP_ENABLED) != 0) { - CpuDeadLoop (); - } -} - - -/** - Fills a target buffer with PcdDebugClearMemoryValue, and returns the target buffer. - - This function fills Length bytes of Buffer with the value specified by - PcdDebugClearMemoryValue, and returns Buffer. - - If Buffer is NULL, then ASSERT(). - If Length is greater than (MAX_ADDRESS - Buffer + 1), then ASSERT(). - - @param Buffer The pointer to the target buffer to be filled with PcdDebugClearMemoryValue. - @param Length The number of bytes in Buffer to fill with zeros PcdDebugClearMemoryValue. - - @return Buffer The pointer to the target buffer filled with PcdDebugClearMemoryValue. - -**/ -VOID * -EFIAPI -DebugClearMemory ( - OUT VOID *Buffer, - IN UINTN Length - ) -{ - // - // If Buffer is NULL, then ASSERT(). - // - ASSERT (Buffer != NULL); - - // - // SetMem() checks for the the ASSERT() condition on Length and returns Buffer - // - return SetMem (Buffer, Length, PcdGet8(PcdDebugClearMemoryValue)); -} - - -/** - Returns TRUE if ASSERT() macros are enabled. - - This function returns TRUE if the DEBUG_PROPERTY_DEBUG_ASSERT_ENABLED bit of - PcdDebugProperyMask is set. Otherwise FALSE is returned. - - @retval TRUE The DEBUG_PROPERTY_DEBUG_ASSERT_ENABLED bit of PcdDebugProperyMask is set. - @retval FALSE The DEBUG_PROPERTY_DEBUG_ASSERT_ENABLED bit of PcdDebugProperyMask is clear. - -**/ -BOOLEAN -EFIAPI -DebugAssertEnabled ( - VOID - ) -{ - return (BOOLEAN) ((PcdGet8(PcdDebugPropertyMask) & DEBUG_PROPERTY_DEBUG_ASSERT_ENABLED) != 0); -} - - -/** - Returns TRUE if DEBUG() macros are enabled. - - This function returns TRUE if the DEBUG_PROPERTY_DEBUG_PRINT_ENABLED bit of - PcdDebugProperyMask is set. Otherwise FALSE is returned. - - @retval TRUE The DEBUG_PROPERTY_DEBUG_PRINT_ENABLED bit of PcdDebugProperyMask is set. - @retval FALSE The DEBUG_PROPERTY_DEBUG_PRINT_ENABLED bit of PcdDebugProperyMask is clear. - -**/ -BOOLEAN -EFIAPI -DebugPrintEnabled ( - VOID - ) -{ - return (BOOLEAN) ((PcdGet8(PcdDebugPropertyMask) & DEBUG_PROPERTY_DEBUG_PRINT_ENABLED) != 0); -} - - -/** - Returns TRUE if DEBUG_CODE() macros are enabled. - - This function returns TRUE if the DEBUG_PROPERTY_DEBUG_CODE_ENABLED bit of - PcdDebugProperyMask is set. Otherwise FALSE is returned. - - @retval TRUE The DEBUG_PROPERTY_DEBUG_CODE_ENABLED bit of PcdDebugProperyMask is set. - @retval FALSE The DEBUG_PROPERTY_DEBUG_CODE_ENABLED bit of PcdDebugProperyMask is clear. - -**/ -BOOLEAN -EFIAPI -DebugCodeEnabled ( - VOID - ) -{ - return (BOOLEAN) ((PcdGet8(PcdDebugPropertyMask) & DEBUG_PROPERTY_DEBUG_CODE_ENABLED) != 0); -} - - -/** - Returns TRUE if DEBUG_CLEAR_MEMORY() macro is enabled. - - This function returns TRUE if the DEBUG_PROPERTY_CLEAR_MEMORY_ENABLED bit of - PcdDebugProperyMask is set. Otherwise FALSE is returned. - - @retval TRUE The DEBUG_PROPERTY_CLEAR_MEMORY_ENABLED bit of PcdDebugProperyMask is set. - @retval FALSE The DEBUG_PROPERTY_CLEAR_MEMORY_ENABLED bit of PcdDebugProperyMask is clear. - -**/ -BOOLEAN -EFIAPI -DebugClearMemoryEnabled ( - VOID - ) -{ - return (BOOLEAN) ((PcdGet8(PcdDebugPropertyMask) & DEBUG_PROPERTY_CLEAR_MEMORY_ENABLED) != 0); -} - -/** - Returns TRUE if any one of the bit is set both in ErrorLevel and PcdFixedDebugPrintErrorLevel. - - This function compares the bit mask of ErrorLevel and PcdFixedDebugPrintErrorLevel. - - @retval TRUE Current ErrorLevel is supported. - @retval FALSE Current ErrorLevel is not supported. - -**/ -BOOLEAN -EFIAPI -DebugPrintLevelEnabled ( - IN CONST UINTN ErrorLevel - ) -{ - return (BOOLEAN) ((ErrorLevel & PcdGet32(PcdFixedDebugPrintErrorLevel)) != 0); -} diff --git a/OvmfPkg/Library/PlatformDebugLibIoPort/PlatformDebugLibIoPort.inf b/OvmfPkg/Library/PlatformDebugLibIoPort/PlatformDebugLibIoPort.inf deleted file mode 100644 index 0e74fe94cb..0000000000 --- a/OvmfPkg/Library/PlatformDebugLibIoPort/PlatformDebugLibIoPort.inf +++ /dev/null @@ -1,51 +0,0 @@ -## @file -# Instance of Debug Library for the QEMU debug console port. -# It uses Print Library to produce formatted output strings. -# -# Copyright (c) 2006 - 2015, Intel Corporation. All rights reserved.
-# 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 = PlatformDebugLibIoPort - FILE_GUID = DF934DA3-CD31-49FE-AF50-B3C87C79325F - MODULE_TYPE = BASE - VERSION_STRING = 1.0 - LIBRARY_CLASS = DebugLib - CONSTRUCTOR = PlatformDebugLibIoPortConstructor - -# -# VALID_ARCHITECTURES = IA32 X64 IPF EBC -# - -[Sources] - DebugLib.c - -[Packages] - MdePkg/MdePkg.dec - OvmfPkg/OvmfPkg.dec - -[LibraryClasses] - BaseMemoryLib - IoLib - PcdLib - PrintLib - BaseLib - DebugPrintErrorLevelLib - -[Pcd] - gUefiOvmfPkgTokenSpaceGuid.PcdDebugIoPort ## CONSUMES - gEfiMdePkgTokenSpaceGuid.PcdDebugClearMemoryValue ## CONSUMES - gEfiMdePkgTokenSpaceGuid.PcdDebugPropertyMask ## CONSUMES - gEfiMdePkgTokenSpaceGuid.PcdFixedDebugPrintErrorLevel ## CONSUMES - diff --git a/OvmfPkg/Library/PlatformFvbLibNull/PlatformFvbLibNull.c b/OvmfPkg/Library/PlatformFvbLibNull/PlatformFvbLibNull.c deleted file mode 100644 index ea5da6e0d6..0000000000 --- a/OvmfPkg/Library/PlatformFvbLibNull/PlatformFvbLibNull.c +++ /dev/null @@ -1,89 +0,0 @@ -/** @file - NULL PlatformFvbLib library instance - - Copyright (c) 2009 - 2011, Intel Corporation. All rights reserved.
- This program and the accompanying materials - are licensed and made available under the terms and conditions of the BSD License - which accompanies this distribution. The full text of the license may be found at - http://opensource.org/licenses/bsd-license.php - - THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, - WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. - -**/ - -#include "PiDxe.h" -#include - - -/** - This function will be called following a call to the - EFI_FIRMWARE_VOLUME_BLOCK2_PROTOCOL Read function. - - @param[in] This The EFI_FIRMWARE_VOLUME_BLOCK2_PROTOCOL instance. - @param[in] Lba The starting logical block index - from which to read. - @param[in] Offset Offset into the block at which to begin reading. - @param[in] NumBytes The number of bytes read. - @param[in] Buffer Pointer to the buffer that was read, and will be - returned to the caller. - -**/ -VOID -EFIAPI -PlatformFvbDataRead ( - IN CONST EFI_FIRMWARE_VOLUME_BLOCK2_PROTOCOL *This, - IN EFI_LBA Lba, - IN UINTN Offset, - IN UINTN NumBytes, - IN UINT8 *Buffer - ) -{ -} - - -/** - This function will be called following a call to the - EFI_FIRMWARE_VOLUME_BLOCK_PROTOCOL Write function. - - @param[in] This EFI_FIRMWARE_VOLUME_BLOCK_PROTOCOL instance. - @param[in] Lba The starting logical block index to written to. - @param[in] Offset Offset into the block at which to begin writing. - @param[in] NumBytes The number of bytes written. - @param[in] Buffer Pointer to the buffer that was written. - -**/ -VOID -EFIAPI -PlatformFvbDataWritten ( - IN CONST EFI_FIRMWARE_VOLUME_BLOCK2_PROTOCOL *This, - IN EFI_LBA Lba, - IN UINTN Offset, - IN UINTN NumBytes, - IN UINT8 *Buffer - ) -{ -} - - -/** - This function will be called following a call to the - EFI_FIRMWARE_VOLUME_BLOCK2_PROTOCOL Erase function. - - @param This Indicates the EFI_FIRMWARE_VOLUME_BLOCK2_PROTOCOL - instance. - @param List The variable argument list as documented for - the EFI_FIRMWARE_VOLUME_BLOCK2_PROTOCOL Erase - function. - -**/ -VOID -EFIAPI -PlatformFvbBlocksErased ( - IN CONST EFI_FIRMWARE_VOLUME_BLOCK2_PROTOCOL *This, - IN VA_LIST List - ) -{ -} - - diff --git a/OvmfPkg/Library/PlatformFvbLibNull/PlatformFvbLibNull.inf b/OvmfPkg/Library/PlatformFvbLibNull/PlatformFvbLibNull.inf deleted file mode 100644 index 5f51391e82..0000000000 --- a/OvmfPkg/Library/PlatformFvbLibNull/PlatformFvbLibNull.inf +++ /dev/null @@ -1,39 +0,0 @@ -## @file -# NULL PlatformFvbLib library instance -# -# This library handles hooks for the EMU Variable FVB driver. -# -# Copyright (c) 2006 - 2010, Intel Corporation. All rights reserved.
-# -# This program and the accompanying materials -# are licensed and made available under the terms and conditions of the BSD License -# which accompanies this distribution. The full text of the license may be found at -# http://opensource.org/licenses/bsd-license.php -# THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, -# WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. -# -# -## - -[Defines] - INF_VERSION = 0x00010005 - BASE_NAME = PlatformFvbLibNull - FILE_GUID = 79263F9A-1701-4382-98C2-573F3558E6C8 - MODULE_TYPE = BASE - VERSION_STRING = 1.0 - LIBRARY_CLASS = PlatformFvbLib|DXE_RUNTIME_DRIVER - -# -# The following information is for reference only and not required by the build tools. -# -# VALID_ARCHITECTURES = IA32 X64 IPF EBC -# - -[Sources] - PlatformFvbLibNull.c - -[Packages] - MdePkg/MdePkg.dec - MdeModulePkg/MdeModulePkg.dec - OvmfPkg/OvmfPkg.dec - diff --git a/OvmfPkg/Library/PlatformSecureLib/PlatformSecureLib.c b/OvmfPkg/Library/PlatformSecureLib/PlatformSecureLib.c deleted file mode 100644 index de0e4fa938..0000000000 --- a/OvmfPkg/Library/PlatformSecureLib/PlatformSecureLib.c +++ /dev/null @@ -1,40 +0,0 @@ -/** @file - Provides a platform-specific method to enable Secure Boot Custom Mode setup. - - Copyright (c) 2006 - 2012, Intel Corporation. All rights reserved.
- This program and the accompanying materials - are licensed and made available under the terms and conditions of the BSD License - which accompanies this distribution. The full text of the license may be found at - http://opensource.org/licenses/bsd-license.php - - THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, - WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. - -**/ -#include - -/** - - This function provides a platform-specific method to detect whether the platform - is operating by a physically present user. - - Programmatic changing of platform security policy (such as disable Secure Boot, - or switch between Standard/Custom Secure Boot mode) MUST NOT be possible during - Boot Services or after exiting EFI Boot Services. Only a physically present user - is allowed to perform these operations. - - NOTE THAT: This function cannot depend on any EFI Variable Service since they are - not available when this function is called in AuthenticateVariable driver. - - @retval TRUE The platform is operated by a physically present user. - @retval FALSE The platform is NOT operated by a physically present user. - -**/ -BOOLEAN -EFIAPI -UserPhysicalPresent ( - VOID - ) -{ - return TRUE; -} diff --git a/OvmfPkg/Library/PlatformSecureLib/PlatformSecureLib.inf b/OvmfPkg/Library/PlatformSecureLib/PlatformSecureLib.inf deleted file mode 100644 index 267bc182b4..0000000000 --- a/OvmfPkg/Library/PlatformSecureLib/PlatformSecureLib.inf +++ /dev/null @@ -1,33 +0,0 @@ -## @file -# Provides a platform-specific method to enable Secure Boot Custom Mode setup. -# -# Copyright (c) 2008 - 2012, Intel Corporation. All rights reserved.
-# -# This program and the accompanying materials -# are licensed and made available under the terms and conditions of the BSD License -# which accompanies this distribution. The full text of the license may be found at -# http://opensource.org/licenses/bsd-license.php -# THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, -# WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. -# -## - -[Defines] - INF_VERSION = 0x00010005 - BASE_NAME = PlatformSecureLib - FILE_GUID = 4204D78D-EDBF-4cee-BE80-3881457CF344 - MODULE_TYPE = DXE_DRIVER - VERSION_STRING = 1.0 - LIBRARY_CLASS = PlatformSecureLib|DXE_RUNTIME_DRIVER DXE_SMM_DRIVER DXE_DRIVER - -# -# The following information is for reference only and not required by the build tools. -# -# VALID_ARCHITECTURES = IA32 X64 IPF EBC -# - -[Sources] - PlatformSecureLib.c - -[Packages] - MdePkg/MdePkg.dec diff --git a/OvmfPkg/Library/QemuBootOrderLib/ExtraRootBusMap.c b/OvmfPkg/Library/QemuBootOrderLib/ExtraRootBusMap.c deleted file mode 100644 index 70ba1619d1..0000000000 --- a/OvmfPkg/Library/QemuBootOrderLib/ExtraRootBusMap.c +++ /dev/null @@ -1,313 +0,0 @@ -/** @file - Map positions of extra PCI root buses to bus numbers. - - Copyright (C) 2015, 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 -#include -#include -#include -#include -#include -#include - -#include "ExtraRootBusMap.h" - -// -// The BusNumbers field is an array with Count elements. The elements increase -// strictry monotonically. Zero is not an element (because the zero bus number -// belongs to the "main" root bus, never to an extra root bus). Offset N in the -// array maps the extra root bus with position (N+1) to its bus number (because -// the root bus with position 0 is always the main root bus, therefore we don't -// store it). -// -// If there are no extra root buses in the system, then Count is 0, and -// BusNumbers is NULL. -// -struct EXTRA_ROOT_BUS_MAP_STRUCT { - UINT32 *BusNumbers; - UINTN Count; -}; - - -/** - An ORDERED_COLLECTION_USER_COMPARE function that compares root bridge - protocol device paths based on UID. - - @param[in] UserStruct1 Pointer to the first ACPI_HID_DEVICE_PATH. - - @param[in] UserStruct2 Pointer to the second ACPI_HID_DEVICE_PATH. - - @retval <0 If UserStruct1 compares less than UserStruct2. - - @retval 0 If UserStruct1 compares equal to UserStruct2. - - @retval >0 If UserStruct1 compares greater than UserStruct2. -**/ -STATIC -INTN -EFIAPI -RootBridgePathCompare ( - IN CONST VOID *UserStruct1, - IN CONST VOID *UserStruct2 - ) -{ - CONST ACPI_HID_DEVICE_PATH *Acpi1; - CONST ACPI_HID_DEVICE_PATH *Acpi2; - - Acpi1 = UserStruct1; - Acpi2 = UserStruct2; - - return Acpi1->UID < Acpi2->UID ? -1 : - Acpi1->UID > Acpi2->UID ? 1 : - 0; -} - - -/** - An ORDERED_COLLECTION_KEY_COMPARE function that compares a root bridge - protocol device path against a UID. - - @param[in] StandaloneKey Pointer to the bare UINT32 UID. - - @param[in] UserStruct Pointer to the ACPI_HID_DEVICE_PATH with the - embedded UINT32 UID. - - @retval <0 If StandaloneKey compares less than UserStruct's key. - - @retval 0 If StandaloneKey compares equal to UserStruct's key. - - @retval >0 If StandaloneKey compares greater than UserStruct's key. -**/ -STATIC -INTN -EFIAPI -RootBridgePathKeyCompare ( - IN CONST VOID *StandaloneKey, - IN CONST VOID *UserStruct - ) -{ - CONST UINT32 *Uid; - CONST ACPI_HID_DEVICE_PATH *Acpi; - - Uid = StandaloneKey; - Acpi = UserStruct; - - return *Uid < Acpi->UID ? -1 : - *Uid > Acpi->UID ? 1 : - 0; -} - - -/** - Create a structure that maps the relative positions of PCI root buses to bus - numbers. - - In the "bootorder" fw_cfg file, QEMU refers to extra PCI root buses by their - positions, in relative root bus number order, not by their actual PCI bus - numbers. The ACPI HID device path nodes however that are associated with - PciRootBridgeIo protocol instances in the system have their UID fields set to - the bus numbers. Create a map that gives, for each extra PCI root bus's - position (ie. "serial number") its actual PCI bus number. - - @param[out] ExtraRootBusMap The data structure implementing the map. - - @retval EFI_SUCCESS ExtraRootBusMap has been populated. - - @retval EFI_OUT_OF_RESOURCES Memory allocation failed. - - @retval EFI_ALREADY_STARTED A duplicate root bus number has been found in - the system. (This should never happen.) - - @return Error codes returned by - gBS->LocateHandleBuffer() and - gBS->HandleProtocol(). - -**/ -EFI_STATUS -CreateExtraRootBusMap ( - OUT EXTRA_ROOT_BUS_MAP **ExtraRootBusMap - ) -{ - EFI_STATUS Status; - UINTN NumHandles; - EFI_HANDLE *Handles; - ORDERED_COLLECTION *Collection; - EXTRA_ROOT_BUS_MAP *Map; - UINTN Idx; - ORDERED_COLLECTION_ENTRY *Entry, *Entry2; - - // - // Handles and Collection are temporary / helper variables, while in Map we - // build the return value. - // - - Status = gBS->LocateHandleBuffer (ByProtocol, - &gEfiPciRootBridgeIoProtocolGuid, NULL /* SearchKey */, - &NumHandles, &Handles); - if (EFI_ERROR (Status)) { - return Status; - } - - Collection = OrderedCollectionInit (RootBridgePathCompare, - RootBridgePathKeyCompare); - if (Collection == NULL) { - Status = EFI_OUT_OF_RESOURCES; - goto FreeHandles; - } - - Map = AllocateZeroPool (sizeof *Map); - if (Map == NULL) { - Status = EFI_OUT_OF_RESOURCES; - goto FreeCollection; - } - - // - // Collect the ACPI device path protocols of the root bridges. - // - for (Idx = 0; Idx < NumHandles; ++Idx) { - EFI_DEVICE_PATH_PROTOCOL *DevicePath; - - Status = gBS->HandleProtocol (Handles[Idx], &gEfiDevicePathProtocolGuid, - (VOID**)&DevicePath); - if (EFI_ERROR (Status)) { - goto FreeMap; - } - - // - // Examine if the device path is an ACPI HID one, and if so, if UID is - // nonzero (ie. the root bridge that the bus number belongs to is "extra", - // not the main one). In that case, link the device path into Collection. - // - if (DevicePathType (DevicePath) == ACPI_DEVICE_PATH && - DevicePathSubType (DevicePath) == ACPI_DP && - ((ACPI_HID_DEVICE_PATH *)DevicePath)->HID == EISA_PNP_ID(0x0A03) && - ((ACPI_HID_DEVICE_PATH *)DevicePath)->UID > 0) { - Status = OrderedCollectionInsert (Collection, NULL, DevicePath); - if (EFI_ERROR (Status)) { - goto FreeMap; - } - ++Map->Count; - } - } - - if (Map->Count > 0) { - // - // At least one extra PCI root bus exists. - // - Map->BusNumbers = AllocatePool (Map->Count * sizeof *Map->BusNumbers); - if (Map->BusNumbers == NULL) { - Status = EFI_OUT_OF_RESOURCES; - goto FreeMap; - } - } - - // - // Now collect the bus numbers of the extra PCI root buses into Map. - // - Idx = 0; - Entry = OrderedCollectionMin (Collection); - while (Idx < Map->Count) { - ACPI_HID_DEVICE_PATH *Acpi; - - ASSERT (Entry != NULL); - Acpi = OrderedCollectionUserStruct (Entry); - Map->BusNumbers[Idx] = Acpi->UID; - DEBUG ((EFI_D_VERBOSE, - "%a: extra bus position 0x%Lx maps to bus number (UID) 0x%x\n", - __FUNCTION__, (UINT64)(Idx + 1), Acpi->UID)); - ++Idx; - Entry = OrderedCollectionNext (Entry); - } - ASSERT (Entry == NULL); - - *ExtraRootBusMap = Map; - Status = EFI_SUCCESS; - - // - // Fall through in order to release temporaries. - // - -FreeMap: - if (EFI_ERROR (Status)) { - if (Map->BusNumbers != NULL) { - FreePool (Map->BusNumbers); - } - FreePool (Map); - } - -FreeCollection: - for (Entry = OrderedCollectionMin (Collection); Entry != NULL; - Entry = Entry2) { - Entry2 = OrderedCollectionNext (Entry); - OrderedCollectionDelete (Collection, Entry, NULL); - } - OrderedCollectionUninit (Collection); - -FreeHandles: - FreePool (Handles); - - return Status; -} - - -/** - Release a map created with CreateExtraRootBusMap(). - - @param[in] ExtraRootBusMap The map to release. -*/ -VOID -DestroyExtraRootBusMap ( - IN EXTRA_ROOT_BUS_MAP *ExtraRootBusMap - ) -{ - if (ExtraRootBusMap->BusNumbers != NULL) { - FreePool (ExtraRootBusMap->BusNumbers); - } - FreePool (ExtraRootBusMap); -} - -/** - Map the position (serial number) of an extra PCI root bus to its bus number. - - @param[in] ExtraRootBusMap The map created with CreateExtraRootBusMap(); - - @param[in] RootBusPos The extra PCI root bus position to map. - - @param[out] RootBusNr The bus number belonging to the extra PCI root - bus identified by RootBusPos. - - @retval EFI_INVALID_PARAMETER RootBusPos is zero. The zero position - identifies the main root bus, whose bus number - is always zero, and is therefore never - maintained in ExtraRootBusMap. - - @retval EFI_NOT_FOUND RootBusPos is not found in ExtraRootBusMap. - - @retval EFI_SUCCESS Mapping successful. -**/ -EFI_STATUS -MapRootBusPosToBusNr ( - IN CONST EXTRA_ROOT_BUS_MAP *ExtraRootBusMap, - IN UINT64 RootBusPos, - OUT UINT32 *RootBusNr - ) -{ - if (RootBusPos == 0) { - return EFI_INVALID_PARAMETER; - } - if (RootBusPos > ExtraRootBusMap->Count) { - return EFI_NOT_FOUND; - } - *RootBusNr = ExtraRootBusMap->BusNumbers[(UINTN)RootBusPos - 1]; - return EFI_SUCCESS; -} diff --git a/OvmfPkg/Library/QemuBootOrderLib/ExtraRootBusMap.h b/OvmfPkg/Library/QemuBootOrderLib/ExtraRootBusMap.h deleted file mode 100644 index e2dbc38ed8..0000000000 --- a/OvmfPkg/Library/QemuBootOrderLib/ExtraRootBusMap.h +++ /dev/null @@ -1,40 +0,0 @@ -/** @file - Map positions of extra PCI root buses to bus numbers. - - Copyright (C) 2015, 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 __EXTRA_ROOT_BUS_MAP_H__ -#define __EXTRA_ROOT_BUS_MAP_H__ - -/** - Incomplete ("opaque") data type implementing the map. -**/ -typedef struct EXTRA_ROOT_BUS_MAP_STRUCT EXTRA_ROOT_BUS_MAP; - -EFI_STATUS -CreateExtraRootBusMap ( - OUT EXTRA_ROOT_BUS_MAP **ExtraRootBusMap - ); - -VOID -DestroyExtraRootBusMap ( - IN EXTRA_ROOT_BUS_MAP *ExtraRootBusMap - ); - -EFI_STATUS -MapRootBusPosToBusNr ( - IN CONST EXTRA_ROOT_BUS_MAP *ExtraRootBusMap, - IN UINT64 RootBusPos, - OUT UINT32 *RootBusNr - ); - -#endif diff --git a/OvmfPkg/Library/QemuBootOrderLib/QemuBootOrderLib.c b/OvmfPkg/Library/QemuBootOrderLib/QemuBootOrderLib.c deleted file mode 100644 index 567f6f92f4..0000000000 --- a/OvmfPkg/Library/QemuBootOrderLib/QemuBootOrderLib.c +++ /dev/null @@ -1,1944 +0,0 @@ -/** @file - Rewrite the BootOrder NvVar based on QEMU's "bootorder" fw_cfg file. - - Copyright (C) 2012 - 2014, Red Hat, Inc. - Copyright (c) 2013 - 2016, Intel Corporation. All rights reserved.
- - This program and the accompanying materials are licensed and made available - under the terms and conditions of the BSD License which accompanies this - distribution. The full text of the license may be found at - http://opensource.org/licenses/bsd-license.php - - THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, WITHOUT - WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. -**/ - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#include "ExtraRootBusMap.h" - -/** - OpenFirmware to UEFI device path translation output buffer size in CHAR16's. -**/ -#define TRANSLATION_OUTPUT_SIZE 0x100 - -/** - Output buffer size for OpenFirmware to UEFI device path fragment translation, - in CHAR16's, for a sequence of PCI bridges. -**/ -#define BRIDGE_TRANSLATION_OUTPUT_SIZE 0x40 - -/** - Numbers of nodes in OpenFirmware device paths that are required and examined. -**/ -#define REQUIRED_PCI_OFW_NODES 2 -#define REQUIRED_MMIO_OFW_NODES 1 -#define EXAMINED_OFW_NODES 6 - - -/** - Simple character classification routines, corresponding to POSIX class names - and ASCII encoding. -**/ -STATIC -BOOLEAN -IsAlnum ( - IN CHAR8 Chr - ) -{ - return (('0' <= Chr && Chr <= '9') || - ('A' <= Chr && Chr <= 'Z') || - ('a' <= Chr && Chr <= 'z') - ); -} - - -STATIC -BOOLEAN -IsDriverNamePunct ( - IN CHAR8 Chr - ) -{ - return (Chr == ',' || Chr == '.' || Chr == '_' || - Chr == '+' || Chr == '-' - ); -} - - -STATIC -BOOLEAN -IsPrintNotDelim ( - IN CHAR8 Chr - ) -{ - return (32 <= Chr && Chr <= 126 && - Chr != '/' && Chr != '@' && Chr != ':'); -} - - -/** - Utility types and functions. -**/ -typedef struct { - CONST CHAR8 *Ptr; // not necessarily NUL-terminated - UINTN Len; // number of non-NUL characters -} SUBSTRING; - - -/** - - Check if Substring and String have identical contents. - - The function relies on the restriction that a SUBSTRING cannot have embedded - NULs either. - - @param[in] Substring The SUBSTRING input to the comparison. - - @param[in] String The ASCII string input to the comparison. - - - @return Whether the inputs have identical contents. - -**/ -STATIC -BOOLEAN -SubstringEq ( - IN SUBSTRING Substring, - IN CONST CHAR8 *String - ) -{ - UINTN Pos; - CONST CHAR8 *Chr; - - Pos = 0; - Chr = String; - - while (Pos < Substring.Len && Substring.Ptr[Pos] == *Chr) { - ++Pos; - ++Chr; - } - - return (BOOLEAN)(Pos == Substring.Len && *Chr == '\0'); -} - - -/** - - Parse a comma-separated list of hexadecimal integers into the elements of an - UINT64 array. - - Whitespace, "0x" prefixes, leading or trailing commas, sequences of commas, - or an empty string are not allowed; they are rejected. - - The function relies on ASCII encoding. - - @param[in] UnitAddress The substring to parse. - - @param[out] Result The array, allocated by the caller, to receive - the parsed values. This parameter may be NULL if - NumResults is zero on input. - - @param[in out] NumResults On input, the number of elements allocated for - Result. On output, the number of elements it has - taken (or would have taken) to parse the string - fully. - - - @retval RETURN_SUCCESS UnitAddress has been fully parsed. - NumResults is set to the number of parsed - values; the corresponding elements have - been set in Result. The rest of Result's - elements are unchanged. - - @retval RETURN_BUFFER_TOO_SMALL UnitAddress has been fully parsed. - NumResults is set to the number of parsed - values, but elements have been stored only - up to the input value of NumResults, which - is less than what has been parsed. - - @retval RETURN_INVALID_PARAMETER Parse error. The contents of Results is - indeterminate. NumResults has not been - changed. - -**/ -STATIC -RETURN_STATUS -ParseUnitAddressHexList ( - IN SUBSTRING UnitAddress, - OUT UINT64 *Result, - IN OUT UINTN *NumResults - ) -{ - UINTN Entry; // number of entry currently being parsed - UINT64 EntryVal; // value being constructed for current entry - CHAR8 PrevChr; // UnitAddress character previously checked - UINTN Pos; // current position within UnitAddress - RETURN_STATUS Status; - - Entry = 0; - EntryVal = 0; - PrevChr = ','; - - for (Pos = 0; Pos < UnitAddress.Len; ++Pos) { - CHAR8 Chr; - INT8 Val; - - Chr = UnitAddress.Ptr[Pos]; - Val = ('a' <= Chr && Chr <= 'f') ? (Chr - 'a' + 10) : - ('A' <= Chr && Chr <= 'F') ? (Chr - 'A' + 10) : - ('0' <= Chr && Chr <= '9') ? (Chr - '0' ) : - -1; - - if (Val >= 0) { - if (EntryVal > 0xFFFFFFFFFFFFFFFull) { - return RETURN_INVALID_PARAMETER; - } - EntryVal = LShiftU64 (EntryVal, 4) | Val; - } else if (Chr == ',') { - if (PrevChr == ',') { - return RETURN_INVALID_PARAMETER; - } - if (Entry < *NumResults) { - Result[Entry] = EntryVal; - } - ++Entry; - EntryVal = 0; - } else { - return RETURN_INVALID_PARAMETER; - } - - PrevChr = Chr; - } - - if (PrevChr == ',') { - return RETURN_INVALID_PARAMETER; - } - if (Entry < *NumResults) { - Result[Entry] = EntryVal; - Status = RETURN_SUCCESS; - } else { - Status = RETURN_BUFFER_TOO_SMALL; - } - ++Entry; - - *NumResults = Entry; - return Status; -} - - -/** - A simple array of Boot Option ID's. -**/ -typedef struct { - UINT16 *Data; - UINTN Allocated; - UINTN Produced; -} BOOT_ORDER; - - -/** - Array element tracking an enumerated boot option that has the - LOAD_OPTION_ACTIVE attribute. -**/ -typedef struct { - CONST EFI_BOOT_MANAGER_LOAD_OPTION *BootOption; // reference only, no - // ownership - BOOLEAN Appended; // has been added to a - // BOOT_ORDER? -} ACTIVE_OPTION; - - -/** - - Append an active boot option to BootOrder, reallocating the latter if needed. - - @param[in out] BootOrder The structure pointing to the array and holding - allocation and usage counters. - - @param[in] ActiveOption The active boot option whose ID should be - appended to the array. - - - @retval RETURN_SUCCESS ID of ActiveOption appended. - - @retval RETURN_OUT_OF_RESOURCES Memory reallocation failed. - -**/ -STATIC -RETURN_STATUS -BootOrderAppend ( - IN OUT BOOT_ORDER *BootOrder, - IN OUT ACTIVE_OPTION *ActiveOption - ) -{ - if (BootOrder->Produced == BootOrder->Allocated) { - UINTN AllocatedNew; - UINT16 *DataNew; - - ASSERT (BootOrder->Allocated > 0); - AllocatedNew = BootOrder->Allocated * 2; - DataNew = ReallocatePool ( - BootOrder->Allocated * sizeof (*BootOrder->Data), - AllocatedNew * sizeof (*DataNew), - BootOrder->Data - ); - if (DataNew == NULL) { - return RETURN_OUT_OF_RESOURCES; - } - BootOrder->Allocated = AllocatedNew; - BootOrder->Data = DataNew; - } - - BootOrder->Data[BootOrder->Produced++] = - (UINT16) ActiveOption->BootOption->OptionNumber; - ActiveOption->Appended = TRUE; - return RETURN_SUCCESS; -} - - -/** - - Create an array of ACTIVE_OPTION elements for a boot option array. - - @param[in] BootOptions A boot option array, created with - EfiBootManagerRefreshAllBootOption () and - EfiBootManagerGetLoadOptions (). - - @param[in] BootOptionCount The number of elements in BootOptions. - - @param[out] ActiveOption Pointer to the first element in the new array. - The caller is responsible for freeing the array - with FreePool() after use. - - @param[out] Count Number of elements in the new array. - - - @retval RETURN_SUCCESS The ActiveOption array has been created. - - @retval RETURN_NOT_FOUND No active entry has been found in - BootOptions. - - @retval RETURN_OUT_OF_RESOURCES Memory allocation failed. - -**/ -STATIC -RETURN_STATUS -CollectActiveOptions ( - IN CONST EFI_BOOT_MANAGER_LOAD_OPTION *BootOptions, - IN UINTN BootOptionCount, - OUT ACTIVE_OPTION **ActiveOption, - OUT UINTN *Count - ) -{ - UINTN Index; - UINTN ScanMode; - - *ActiveOption = NULL; - - // - // Scan the list twice: - // - count active entries, - // - store links to active entries. - // - for (ScanMode = 0; ScanMode < 2; ++ScanMode) { - *Count = 0; - for (Index = 0; Index < BootOptionCount; Index++) { - if ((BootOptions[Index].Attributes & LOAD_OPTION_ACTIVE) != 0) { - if (ScanMode == 1) { - (*ActiveOption)[*Count].BootOption = &BootOptions[Index]; - (*ActiveOption)[*Count].Appended = FALSE; - } - ++*Count; - } - } - - if (ScanMode == 0) { - if (*Count == 0) { - return RETURN_NOT_FOUND; - } - *ActiveOption = AllocatePool (*Count * sizeof **ActiveOption); - if (*ActiveOption == NULL) { - return RETURN_OUT_OF_RESOURCES; - } - } - } - return RETURN_SUCCESS; -} - - -/** - OpenFirmware device path node -**/ -typedef struct { - SUBSTRING DriverName; - SUBSTRING UnitAddress; - SUBSTRING DeviceArguments; -} OFW_NODE; - - -/** - - Parse an OpenFirmware device path node into the caller-allocated OFW_NODE - structure, and advance in the input string. - - The node format is mostly parsed after IEEE 1275-1994, 3.2.1.1 "Node names" - (a leading slash is expected and not returned): - - /driver-name@unit-address[:device-arguments][] - - A single trailing character is consumed but not returned. A trailing - or NUL character terminates the device path. - - The function relies on ASCII encoding. - - @param[in out] Ptr Address of the pointer pointing to the start of the - node string. After successful parsing *Ptr is set to - the byte immediately following the consumed - characters. On error it points to the byte that - caused the error. The input string is never modified. - - @param[out] OfwNode The members of this structure point into the input - string, designating components of the node. - Separators are never included. If "device-arguments" - is missing, then DeviceArguments.Ptr is set to NULL. - All components that are present have nonzero length. - - If the call doesn't succeed, the contents of this - structure is indeterminate. - - @param[out] IsFinal In case of successul parsing, this parameter signals - whether the node just parsed is the final node in the - device path. The call after a final node will attempt - to start parsing the next path. If the call doesn't - succeed, then this parameter is not changed. - - - @retval RETURN_SUCCESS Parsing successful. - - @retval RETURN_NOT_FOUND Parsing terminated. *Ptr was (and is) - pointing to an empty string. - - @retval RETURN_INVALID_PARAMETER Parse error. - -**/ -STATIC -RETURN_STATUS -ParseOfwNode ( - IN OUT CONST CHAR8 **Ptr, - OUT OFW_NODE *OfwNode, - OUT BOOLEAN *IsFinal - ) -{ - // - // A leading slash is expected. End of string is tolerated. - // - switch (**Ptr) { - case '\0': - return RETURN_NOT_FOUND; - - case '/': - ++*Ptr; - break; - - default: - return RETURN_INVALID_PARAMETER; - } - - // - // driver-name - // - OfwNode->DriverName.Ptr = *Ptr; - OfwNode->DriverName.Len = 0; - while (OfwNode->DriverName.Len < 32 && - (IsAlnum (**Ptr) || IsDriverNamePunct (**Ptr)) - ) { - ++*Ptr; - ++OfwNode->DriverName.Len; - } - - if (OfwNode->DriverName.Len == 0 || OfwNode->DriverName.Len == 32) { - return RETURN_INVALID_PARAMETER; - } - - - // - // unit-address - // - if (**Ptr != '@') { - return RETURN_INVALID_PARAMETER; - } - ++*Ptr; - - OfwNode->UnitAddress.Ptr = *Ptr; - OfwNode->UnitAddress.Len = 0; - while (IsPrintNotDelim (**Ptr)) { - ++*Ptr; - ++OfwNode->UnitAddress.Len; - } - - if (OfwNode->UnitAddress.Len == 0) { - return RETURN_INVALID_PARAMETER; - } - - - // - // device-arguments, may be omitted - // - OfwNode->DeviceArguments.Len = 0; - if (**Ptr == ':') { - ++*Ptr; - OfwNode->DeviceArguments.Ptr = *Ptr; - - while (IsPrintNotDelim (**Ptr)) { - ++*Ptr; - ++OfwNode->DeviceArguments.Len; - } - - if (OfwNode->DeviceArguments.Len == 0) { - return RETURN_INVALID_PARAMETER; - } - } - else { - OfwNode->DeviceArguments.Ptr = NULL; - } - - switch (**Ptr) { - case '\n': - ++*Ptr; - // - // fall through - // - - case '\0': - *IsFinal = TRUE; - break; - - case '/': - *IsFinal = FALSE; - break; - - default: - return RETURN_INVALID_PARAMETER; - } - - DEBUG (( - DEBUG_VERBOSE, - "%a: DriverName=\"%.*a\" UnitAddress=\"%.*a\" DeviceArguments=\"%.*a\"\n", - __FUNCTION__, - OfwNode->DriverName.Len, OfwNode->DriverName.Ptr, - OfwNode->UnitAddress.Len, OfwNode->UnitAddress.Ptr, - OfwNode->DeviceArguments.Len, - OfwNode->DeviceArguments.Ptr == NULL ? "" : OfwNode->DeviceArguments.Ptr - )); - return RETURN_SUCCESS; -} - - -/** - - Translate a PCI-like array of OpenFirmware device nodes to a UEFI device path - fragment. - - @param[in] OfwNode Array of OpenFirmware device nodes to - translate, constituting the beginning of an - OpenFirmware device path. - - @param[in] NumNodes Number of elements in OfwNode. - - @param[in] ExtraPciRoots An EXTRA_ROOT_BUS_MAP object created with - CreateExtraRootBusMap(), to be used for - translating positions of extra root buses to - bus numbers. - - @param[out] Translated Destination array receiving the UEFI path - fragment, allocated by the caller. If the - return value differs from RETURN_SUCCESS, its - contents is indeterminate. - - @param[in out] TranslatedSize On input, the number of CHAR16's in - Translated. On RETURN_SUCCESS this parameter - is assigned the number of non-NUL CHAR16's - written to Translated. In case of other return - values, TranslatedSize is indeterminate. - - - @retval RETURN_SUCCESS Translation successful. - - @retval RETURN_BUFFER_TOO_SMALL The translation does not fit into the number - of bytes provided. - - @retval RETURN_UNSUPPORTED The array of OpenFirmware device nodes can't - be translated in the current implementation. - - @retval RETURN_PROTOCOL_ERROR The initial OpenFirmware node refers to an - extra PCI root bus (by serial number) that - is invalid according to ExtraPciRoots. - -**/ -STATIC -RETURN_STATUS -TranslatePciOfwNodes ( - IN CONST OFW_NODE *OfwNode, - IN UINTN NumNodes, - IN CONST EXTRA_ROOT_BUS_MAP *ExtraPciRoots, - OUT CHAR16 *Translated, - IN OUT UINTN *TranslatedSize - ) -{ - UINT32 PciRoot; - CHAR8 *Comma; - UINTN FirstNonBridge; - CHAR16 Bridges[BRIDGE_TRANSLATION_OUTPUT_SIZE]; - UINTN BridgesLen; - UINT64 PciDevFun[2]; - UINTN NumEntries; - UINTN Written; - - // - // Resolve the PCI root bus number. - // - // The initial OFW node for the main root bus (ie. bus number 0) is: - // - // /pci@i0cf8 - // - // For extra root buses, the initial OFW node is - // - // /pci@i0cf8,4 - // ^ - // root bus serial number (not PCI bus number) - // - if (NumNodes < REQUIRED_PCI_OFW_NODES || - !SubstringEq (OfwNode[0].DriverName, "pci") - ) { - return RETURN_UNSUPPORTED; - } - - PciRoot = 0; - Comma = ScanMem8 (OfwNode[0].UnitAddress.Ptr, OfwNode[0].UnitAddress.Len, - ','); - if (Comma != NULL) { - SUBSTRING PciRootSerialSubString; - UINT64 PciRootSerial; - - // - // Parse the root bus serial number from the unit address after the comma. - // - PciRootSerialSubString.Ptr = Comma + 1; - PciRootSerialSubString.Len = OfwNode[0].UnitAddress.Len - - (PciRootSerialSubString.Ptr - - OfwNode[0].UnitAddress.Ptr); - NumEntries = 1; - if (RETURN_ERROR (ParseUnitAddressHexList (PciRootSerialSubString, - &PciRootSerial, &NumEntries))) { - return RETURN_UNSUPPORTED; - } - - // - // Map the extra root bus's serial number to its actual bus number. - // - if (EFI_ERROR (MapRootBusPosToBusNr (ExtraPciRoots, PciRootSerial, - &PciRoot))) { - return RETURN_PROTOCOL_ERROR; - } - } - - // - // Translate a sequence of PCI bridges. For each bridge, the OFW node is: - // - // pci-bridge@1e[,0] - // ^ ^ - // PCI slot & function on the parent, holding the bridge - // - // and the UEFI device path node is: - // - // Pci(0x1E,0x0) - // - FirstNonBridge = 1; - Bridges[0] = L'\0'; - BridgesLen = 0; - do { - UINT64 BridgeDevFun[2]; - UINTN BridgesFreeBytes; - - if (!SubstringEq (OfwNode[FirstNonBridge].DriverName, "pci-bridge")) { - break; - } - - BridgeDevFun[1] = 0; - NumEntries = sizeof BridgeDevFun / sizeof BridgeDevFun[0]; - if (ParseUnitAddressHexList (OfwNode[FirstNonBridge].UnitAddress, - BridgeDevFun, &NumEntries) != RETURN_SUCCESS) { - return RETURN_UNSUPPORTED; - } - - BridgesFreeBytes = sizeof Bridges - BridgesLen * sizeof Bridges[0]; - Written = UnicodeSPrintAsciiFormat (Bridges + BridgesLen, BridgesFreeBytes, - "/Pci(0x%Lx,0x%Lx)", BridgeDevFun[0], BridgeDevFun[1]); - BridgesLen += Written; - - // - // There's no way to differentiate between "completely used up without - // truncation" and "truncated", so treat the former as the latter. - // - if (BridgesLen + 1 == BRIDGE_TRANSLATION_OUTPUT_SIZE) { - return RETURN_UNSUPPORTED; - } - - ++FirstNonBridge; - } while (FirstNonBridge < NumNodes); - - if (FirstNonBridge == NumNodes) { - return RETURN_UNSUPPORTED; - } - - // - // Parse the OFW nodes starting with the first non-bridge node. - // - PciDevFun[1] = 0; - NumEntries = ARRAY_SIZE (PciDevFun); - if (ParseUnitAddressHexList ( - OfwNode[FirstNonBridge].UnitAddress, - PciDevFun, - &NumEntries - ) != RETURN_SUCCESS - ) { - return RETURN_UNSUPPORTED; - } - - if (NumNodes >= FirstNonBridge + 3 && - SubstringEq (OfwNode[FirstNonBridge + 0].DriverName, "ide") && - SubstringEq (OfwNode[FirstNonBridge + 1].DriverName, "drive") && - SubstringEq (OfwNode[FirstNonBridge + 2].DriverName, "disk") - ) { - // - // OpenFirmware device path (IDE disk, IDE CD-ROM): - // - // /pci@i0cf8/ide@1,1/drive@0/disk@0 - // ^ ^ ^ ^ ^ - // | | | | master or slave - // | | | primary or secondary - // | PCI slot & function holding IDE controller - // PCI root at system bus port, PIO - // - // UEFI device path: - // - // PciRoot(0x0)/Pci(0x1,0x1)/Ata(Primary,Master,0x0) - // ^ - // fixed LUN - // - UINT64 Secondary; - UINT64 Slave; - - NumEntries = 1; - if (ParseUnitAddressHexList ( - OfwNode[FirstNonBridge + 1].UnitAddress, - &Secondary, - &NumEntries - ) != RETURN_SUCCESS || - Secondary > 1 || - ParseUnitAddressHexList ( - OfwNode[FirstNonBridge + 2].UnitAddress, - &Slave, - &NumEntries // reuse after previous single-element call - ) != RETURN_SUCCESS || - Slave > 1 - ) { - return RETURN_UNSUPPORTED; - } - - Written = UnicodeSPrintAsciiFormat ( - Translated, - *TranslatedSize * sizeof (*Translated), // BufferSize in bytes - "PciRoot(0x%x)%s/Pci(0x%Lx,0x%Lx)/Ata(%a,%a,0x0)", - PciRoot, - Bridges, - PciDevFun[0], - PciDevFun[1], - Secondary ? "Secondary" : "Primary", - Slave ? "Slave" : "Master" - ); - } else if (NumNodes >= FirstNonBridge + 3 && - SubstringEq (OfwNode[FirstNonBridge + 0].DriverName, "pci8086,2922") && - SubstringEq (OfwNode[FirstNonBridge + 1].DriverName, "drive") && - SubstringEq (OfwNode[FirstNonBridge + 2].DriverName, "disk") - ) { - // - // OpenFirmware device path (Q35 SATA disk and CD-ROM): - // - // /pci@i0cf8/pci8086,2922@1f,2/drive@1/disk@0 - // ^ ^ ^ ^ ^ - // | | | | device number (fixed 0) - // | | | channel (port) number - // | PCI slot & function holding SATA HBA - // PCI root at system bus port, PIO - // - // UEFI device path: - // - // PciRoot(0x0)/Pci(0x1F,0x2)/Sata(0x1,0xFFFF,0x0) - // ^ ^ ^ - // | | LUN (always 0 on Q35) - // | port multiplier port number, - // | always 0xFFFF on Q35 - // channel (port) number - // - UINT64 Channel; - - NumEntries = 1; - if (RETURN_ERROR (ParseUnitAddressHexList ( - OfwNode[FirstNonBridge + 1].UnitAddress, &Channel, - &NumEntries))) { - return RETURN_UNSUPPORTED; - } - - Written = UnicodeSPrintAsciiFormat ( - Translated, - *TranslatedSize * sizeof (*Translated), // BufferSize in bytes - "PciRoot(0x%x)%s/Pci(0x%Lx,0x%Lx)/Sata(0x%Lx,0xFFFF,0x0)", - PciRoot, - Bridges, - PciDevFun[0], - PciDevFun[1], - Channel - ); - } else if (NumNodes >= FirstNonBridge + 3 && - SubstringEq (OfwNode[FirstNonBridge + 0].DriverName, "isa") && - SubstringEq (OfwNode[FirstNonBridge + 1].DriverName, "fdc") && - SubstringEq (OfwNode[FirstNonBridge + 2].DriverName, "floppy") - ) { - // - // OpenFirmware device path (floppy disk): - // - // /pci@i0cf8/isa@1/fdc@03f0/floppy@0 - // ^ ^ ^ ^ - // | | | A: or B: - // | | ISA controller io-port (hex) - // | PCI slot holding ISA controller - // PCI root at system bus port, PIO - // - // UEFI device path: - // - // PciRoot(0x0)/Pci(0x1,0x0)/Floppy(0x0) - // ^ - // ACPI UID - // - UINT64 AcpiUid; - - NumEntries = 1; - if (ParseUnitAddressHexList ( - OfwNode[FirstNonBridge + 2].UnitAddress, - &AcpiUid, - &NumEntries - ) != RETURN_SUCCESS || - AcpiUid > 1 - ) { - return RETURN_UNSUPPORTED; - } - - Written = UnicodeSPrintAsciiFormat ( - Translated, - *TranslatedSize * sizeof (*Translated), // BufferSize in bytes - "PciRoot(0x%x)%s/Pci(0x%Lx,0x%Lx)/Floppy(0x%Lx)", - PciRoot, - Bridges, - PciDevFun[0], - PciDevFun[1], - AcpiUid - ); - } else if (NumNodes >= FirstNonBridge + 2 && - SubstringEq (OfwNode[FirstNonBridge + 0].DriverName, "scsi") && - SubstringEq (OfwNode[FirstNonBridge + 1].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) -- if PCI function is 0 or absent - // PciRoot(0x0)/Pci(0x6,0x3) -- if PCI function is present and nonzero - // - Written = UnicodeSPrintAsciiFormat ( - Translated, - *TranslatedSize * sizeof (*Translated), // BufferSize in bytes - "PciRoot(0x%x)%s/Pci(0x%Lx,0x%Lx)", - PciRoot, - Bridges, - PciDevFun[0], - PciDevFun[1] - ); - } else if (NumNodes >= FirstNonBridge + 3 && - SubstringEq (OfwNode[FirstNonBridge + 0].DriverName, "scsi") && - SubstringEq (OfwNode[FirstNonBridge + 1].DriverName, "channel") && - SubstringEq (OfwNode[FirstNonBridge + 2].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 - // - UINT64 TargetLun[2]; - - TargetLun[1] = 0; - NumEntries = ARRAY_SIZE (TargetLun); - if (ParseUnitAddressHexList ( - OfwNode[FirstNonBridge + 2].UnitAddress, - TargetLun, - &NumEntries - ) != RETURN_SUCCESS - ) { - return RETURN_UNSUPPORTED; - } - - Written = UnicodeSPrintAsciiFormat ( - Translated, - *TranslatedSize * sizeof (*Translated), // BufferSize in bytes - "PciRoot(0x%x)%s/Pci(0x%Lx,0x%Lx)/Scsi(0x%Lx,0x%Lx)", - PciRoot, - Bridges, - PciDevFun[0], - PciDevFun[1], - TargetLun[0], - TargetLun[1] - ); - } else if (NumNodes >= FirstNonBridge + 2 && - SubstringEq (OfwNode[FirstNonBridge + 0].DriverName, "pci8086,5845") && - SubstringEq (OfwNode[FirstNonBridge + 1].DriverName, "namespace") - ) { - // - // OpenFirmware device path (NVMe device): - // - // /pci@i0cf8/pci8086,5845@6[,1]/namespace@1,0 - // ^ ^ ^ ^ ^ - // | | | | Extended Unique Identifier - // | | | | (EUI-64), big endian interp. - // | | | namespace ID - // | PCI slot & function holding NVMe controller - // PCI root at system bus port, PIO - // - // UEFI device path: - // - // PciRoot(0x0)/Pci(0x6,0x1)/NVMe(0x1,00-00-00-00-00-00-00-00) - // ^ ^ - // | octets of the EUI-64 - // | in address order - // namespace ID - // - UINT64 Namespace[2]; - UINTN RequiredEntries; - UINT8 *Eui64; - - RequiredEntries = ARRAY_SIZE (Namespace); - NumEntries = RequiredEntries; - if (ParseUnitAddressHexList ( - OfwNode[FirstNonBridge + 1].UnitAddress, - Namespace, - &NumEntries - ) != RETURN_SUCCESS || - NumEntries != RequiredEntries || - Namespace[0] == 0 || - Namespace[0] >= MAX_UINT32 - ) { - return RETURN_UNSUPPORTED; - } - - Eui64 = (UINT8 *)&Namespace[1]; - Written = UnicodeSPrintAsciiFormat ( - Translated, - *TranslatedSize * sizeof (*Translated), // BufferSize in bytes - "PciRoot(0x%x)%s/Pci(0x%Lx,0x%Lx)/" - "NVMe(0x%Lx,%02x-%02x-%02x-%02x-%02x-%02x-%02x-%02x)", - PciRoot, - Bridges, - PciDevFun[0], - PciDevFun[1], - Namespace[0], - Eui64[7], Eui64[6], Eui64[5], Eui64[4], - Eui64[3], Eui64[2], Eui64[1], Eui64[0] - ); - } else { - // - // Generic OpenFirmware device path for PCI devices: - // - // /pci@i0cf8/ethernet@3[,2] - // ^ ^ - // | PCI slot[, function] holding Ethernet card - // PCI root at system bus port, PIO - // - // UEFI device path prefix (dependent on presence of nonzero PCI function): - // - // PciRoot(0x0)/Pci(0x3,0x0) - // PciRoot(0x0)/Pci(0x3,0x2) - // - Written = UnicodeSPrintAsciiFormat ( - Translated, - *TranslatedSize * sizeof (*Translated), // BufferSize in bytes - "PciRoot(0x%x)%s/Pci(0x%Lx,0x%Lx)", - PciRoot, - Bridges, - PciDevFun[0], - PciDevFun[1] - ); - } - - // - // There's no way to differentiate between "completely used up without - // truncation" and "truncated", so treat the former as the latter, and return - // success only for "some room left unused". - // - if (Written + 1 < *TranslatedSize) { - *TranslatedSize = Written; - return RETURN_SUCCESS; - } - - return RETURN_BUFFER_TOO_SMALL; -} - - -// -// A type providing easy raw access to the base address of a virtio-mmio -// transport. -// -typedef union { - UINT64 Uint64; - UINT8 Raw[8]; -} VIRTIO_MMIO_BASE_ADDRESS; - - -/** - - Translate an MMIO-like array of OpenFirmware device nodes to a UEFI device - path fragment. - - @param[in] OfwNode Array of OpenFirmware device nodes to - translate, constituting the beginning of an - OpenFirmware device path. - - @param[in] NumNodes Number of elements in OfwNode. - - @param[out] Translated Destination array receiving the UEFI path - fragment, allocated by the caller. If the - return value differs from RETURN_SUCCESS, its - contents is indeterminate. - - @param[in out] TranslatedSize On input, the number of CHAR16's in - Translated. On RETURN_SUCCESS this parameter - is assigned the number of non-NUL CHAR16's - written to Translated. In case of other return - values, TranslatedSize is indeterminate. - - - @retval RETURN_SUCCESS Translation successful. - - @retval RETURN_BUFFER_TOO_SMALL The translation does not fit into the number - of bytes provided. - - @retval RETURN_UNSUPPORTED The array of OpenFirmware device nodes can't - be translated in the current implementation. - -**/ -STATIC -RETURN_STATUS -TranslateMmioOfwNodes ( - IN CONST OFW_NODE *OfwNode, - IN UINTN NumNodes, - OUT CHAR16 *Translated, - IN OUT UINTN *TranslatedSize - ) -{ - VIRTIO_MMIO_BASE_ADDRESS VirtioMmioBase; - CHAR16 VenHwString[60 + 1]; - UINTN NumEntries; - UINTN Written; - - // - // Get the base address of the virtio-mmio transport. - // - if (NumNodes < REQUIRED_MMIO_OFW_NODES || - !SubstringEq (OfwNode[0].DriverName, "virtio-mmio") - ) { - return RETURN_UNSUPPORTED; - } - NumEntries = 1; - if (ParseUnitAddressHexList ( - OfwNode[0].UnitAddress, - &VirtioMmioBase.Uint64, - &NumEntries - ) != RETURN_SUCCESS - ) { - return RETURN_UNSUPPORTED; - } - - UnicodeSPrintAsciiFormat (VenHwString, sizeof VenHwString, - "VenHw(%g,%02X%02X%02X%02X%02X%02X%02X%02X)", &gVirtioMmioTransportGuid, - VirtioMmioBase.Raw[0], VirtioMmioBase.Raw[1], VirtioMmioBase.Raw[2], - VirtioMmioBase.Raw[3], VirtioMmioBase.Raw[4], VirtioMmioBase.Raw[5], - VirtioMmioBase.Raw[6], VirtioMmioBase.Raw[7]); - - if (NumNodes >= 2 && - SubstringEq (OfwNode[1].DriverName, "disk")) { - // - // OpenFirmware device path (virtio-blk disk): - // - // /virtio-mmio@000000000a003c00/disk@0,0 - // ^ ^ ^ - // | fixed - // base address of virtio-mmio register block - // - // UEFI device path prefix: - // - // - // - Written = UnicodeSPrintAsciiFormat ( - Translated, - *TranslatedSize * sizeof (*Translated), // BufferSize in bytes - "%s", - VenHwString - ); - } else if (NumNodes >= 3 && - SubstringEq (OfwNode[1].DriverName, "channel") && - SubstringEq (OfwNode[2].DriverName, "disk")) { - // - // OpenFirmware device path (virtio-scsi disk): - // - // /virtio-mmio@000000000a003a00/channel@0/disk@2,3 - // ^ ^ ^ ^ - // | | | LUN - // | | target - // | channel (unused, fixed 0) - // base address of virtio-mmio register block - // - // UEFI device path prefix: - // - // /Scsi(0x2,0x3) - // - UINT64 TargetLun[2]; - - TargetLun[1] = 0; - NumEntries = ARRAY_SIZE (TargetLun); - if (ParseUnitAddressHexList ( - OfwNode[2].UnitAddress, - TargetLun, - &NumEntries - ) != RETURN_SUCCESS - ) { - return RETURN_UNSUPPORTED; - } - - Written = UnicodeSPrintAsciiFormat ( - Translated, - *TranslatedSize * sizeof (*Translated), // BufferSize in bytes - "%s/Scsi(0x%Lx,0x%Lx)", - VenHwString, - TargetLun[0], - TargetLun[1] - ); - } else if (NumNodes >= 2 && - SubstringEq (OfwNode[1].DriverName, "ethernet-phy")) { - // - // OpenFirmware device path (virtio-net NIC): - // - // /virtio-mmio@000000000a003e00/ethernet-phy@0 - // ^ ^ - // | fixed - // base address of virtio-mmio register block - // - // UEFI device path prefix (dependent on presence of nonzero PCI function): - // - // /MAC( - // - Written = UnicodeSPrintAsciiFormat ( - Translated, - *TranslatedSize * sizeof (*Translated), // BufferSize in bytes - "%s/MAC(", - VenHwString - ); - } else { - return RETURN_UNSUPPORTED; - } - - // - // There's no way to differentiate between "completely used up without - // truncation" and "truncated", so treat the former as the latter, and return - // success only for "some room left unused". - // - if (Written + 1 < *TranslatedSize) { - *TranslatedSize = Written; - return RETURN_SUCCESS; - } - - return RETURN_BUFFER_TOO_SMALL; -} - - -/** - - Translate an array of OpenFirmware device nodes to a UEFI device path - fragment. - - @param[in] OfwNode Array of OpenFirmware device nodes to - translate, constituting the beginning of an - OpenFirmware device path. - - @param[in] NumNodes Number of elements in OfwNode. - - @param[in] ExtraPciRoots An EXTRA_ROOT_BUS_MAP object created with - CreateExtraRootBusMap(), to be used for - translating positions of extra root buses to - bus numbers. - - @param[out] Translated Destination array receiving the UEFI path - fragment, allocated by the caller. If the - return value differs from RETURN_SUCCESS, its - contents is indeterminate. - - @param[in out] TranslatedSize On input, the number of CHAR16's in - Translated. On RETURN_SUCCESS this parameter - is assigned the number of non-NUL CHAR16's - written to Translated. In case of other return - values, TranslatedSize is indeterminate. - - - @retval RETURN_SUCCESS Translation successful. - - @retval RETURN_BUFFER_TOO_SMALL The translation does not fit into the number - of bytes provided. - - @retval RETURN_UNSUPPORTED The array of OpenFirmware device nodes can't - be translated in the current implementation. - - @retval RETURN_PROTOCOL_ERROR The array of OpenFirmware device nodes has - been (partially) recognized, but it contains - a logic error / doesn't match system state. - -**/ -STATIC -RETURN_STATUS -TranslateOfwNodes ( - IN CONST OFW_NODE *OfwNode, - IN UINTN NumNodes, - IN CONST EXTRA_ROOT_BUS_MAP *ExtraPciRoots, - OUT CHAR16 *Translated, - IN OUT UINTN *TranslatedSize - ) -{ - RETURN_STATUS Status; - - Status = RETURN_UNSUPPORTED; - - if (FeaturePcdGet (PcdQemuBootOrderPciTranslation)) { - Status = TranslatePciOfwNodes (OfwNode, NumNodes, ExtraPciRoots, - Translated, TranslatedSize); - } - if (Status == RETURN_UNSUPPORTED && - FeaturePcdGet (PcdQemuBootOrderMmioTranslation)) { - Status = TranslateMmioOfwNodes (OfwNode, NumNodes, Translated, - TranslatedSize); - } - return Status; -} - -/** - - Translate an OpenFirmware device path fragment to a UEFI device path - fragment, and advance in the input string. - - @param[in out] Ptr Address of the pointer pointing to the start - of the path string. After successful - translation (RETURN_SUCCESS) or at least - successful parsing (RETURN_UNSUPPORTED, - RETURN_BUFFER_TOO_SMALL), *Ptr is set to the - byte immediately following the consumed - characters. In other error cases, it points to - the byte that caused the error. - - @param[in] ExtraPciRoots An EXTRA_ROOT_BUS_MAP object created with - CreateExtraRootBusMap(), to be used for - translating positions of extra root buses to - bus numbers. - - @param[out] Translated Destination array receiving the UEFI path - fragment, allocated by the caller. If the - return value differs from RETURN_SUCCESS, its - contents is indeterminate. - - @param[in out] TranslatedSize On input, the number of CHAR16's in - Translated. On RETURN_SUCCESS this parameter - is assigned the number of non-NUL CHAR16's - written to Translated. In case of other return - values, TranslatedSize is indeterminate. - - - @retval RETURN_SUCCESS Translation successful. - - @retval RETURN_BUFFER_TOO_SMALL The OpenFirmware device path was parsed - successfully, but its translation did not - fit into the number of bytes provided. - Further calls to this function are - possible. - - @retval RETURN_UNSUPPORTED The OpenFirmware device path was parsed - successfully, but it can't be translated in - the current implementation. Further calls - to this function are possible. - - @retval RETURN_PROTOCOL_ERROR The OpenFirmware device path has been - (partially) recognized, but it contains a - logic error / doesn't match system state. - Further calls to this function are - possible. - - @retval RETURN_NOT_FOUND Translation terminated. On input, *Ptr was - pointing to the empty string or "HALT". On - output, *Ptr points to the empty string - (ie. "HALT" is consumed transparently when - present). - - @retval RETURN_INVALID_PARAMETER Parse error. This is a permanent error. - -**/ -STATIC -RETURN_STATUS -TranslateOfwPath ( - IN OUT CONST CHAR8 **Ptr, - IN CONST EXTRA_ROOT_BUS_MAP *ExtraPciRoots, - OUT CHAR16 *Translated, - IN OUT UINTN *TranslatedSize - ) -{ - UINTN NumNodes; - RETURN_STATUS Status; - OFW_NODE Node[EXAMINED_OFW_NODES]; - BOOLEAN IsFinal; - OFW_NODE Skip; - - IsFinal = FALSE; - NumNodes = 0; - if (AsciiStrCmp (*Ptr, "HALT") == 0) { - *Ptr += 4; - Status = RETURN_NOT_FOUND; - } else { - Status = ParseOfwNode (Ptr, &Node[NumNodes], &IsFinal); - } - - if (Status == RETURN_NOT_FOUND) { - DEBUG ((DEBUG_VERBOSE, "%a: no more nodes\n", __FUNCTION__)); - return RETURN_NOT_FOUND; - } - - while (Status == RETURN_SUCCESS && !IsFinal) { - ++NumNodes; - Status = ParseOfwNode ( - Ptr, - (NumNodes < EXAMINED_OFW_NODES) ? &Node[NumNodes] : &Skip, - &IsFinal - ); - } - - switch (Status) { - case RETURN_SUCCESS: - ++NumNodes; - break; - - case RETURN_INVALID_PARAMETER: - DEBUG ((DEBUG_VERBOSE, "%a: parse error\n", __FUNCTION__)); - return RETURN_INVALID_PARAMETER; - - default: - ASSERT (0); - } - - Status = TranslateOfwNodes ( - Node, - NumNodes < EXAMINED_OFW_NODES ? NumNodes : EXAMINED_OFW_NODES, - ExtraPciRoots, - Translated, - TranslatedSize); - switch (Status) { - case RETURN_SUCCESS: - DEBUG ((DEBUG_VERBOSE, "%a: success: \"%s\"\n", __FUNCTION__, Translated)); - break; - - case RETURN_BUFFER_TOO_SMALL: - DEBUG ((DEBUG_VERBOSE, "%a: buffer too small\n", __FUNCTION__)); - break; - - case RETURN_UNSUPPORTED: - DEBUG ((DEBUG_VERBOSE, "%a: unsupported\n", __FUNCTION__)); - break; - - case RETURN_PROTOCOL_ERROR: - DEBUG ((DEBUG_VERBOSE, "%a: logic error / system state mismatch\n", - __FUNCTION__)); - break; - - default: - ASSERT (0); - } - return Status; -} - - -/** - - Convert the UEFI DevicePath to full text representation with DevPathToText, - then match the UEFI device path fragment in Translated against it. - - @param[in] Translated UEFI device path fragment, translated from - OpenFirmware format, to search for. - - @param[in] TranslatedLength The length of Translated in CHAR16's. - - @param[in] DevicePath Boot option device path whose textual rendering - to search in. - - @param[in] DevPathToText Binary-to-text conversion protocol for DevicePath. - - - @retval TRUE If Translated was found at the beginning of DevicePath after - converting the latter to text. - - @retval FALSE If DevicePath was NULL, or it could not be converted, or there - was no match. - -**/ -STATIC -BOOLEAN -Match ( - IN CONST CHAR16 *Translated, - IN UINTN TranslatedLength, - IN EFI_DEVICE_PATH_PROTOCOL *DevicePath - ) -{ - CHAR16 *Converted; - BOOLEAN Result; - VOID *FileBuffer; - UINTN FileSize; - EFI_DEVICE_PATH_PROTOCOL *AbsDevicePath; - CHAR16 *AbsConverted; - BOOLEAN Shortform; - EFI_DEVICE_PATH_PROTOCOL *Node; - - Converted = ConvertDevicePathToText ( - DevicePath, - FALSE, // DisplayOnly - FALSE // AllowShortcuts - ); - if (Converted == NULL) { - return FALSE; - } - - Result = FALSE; - Shortform = FALSE; - // - // Expand the short-form device path to full device path - // - if ((DevicePathType (DevicePath) == MEDIA_DEVICE_PATH) && - (DevicePathSubType (DevicePath) == MEDIA_HARDDRIVE_DP)) { - // - // Harddrive shortform device path - // - Shortform = TRUE; - } else if ((DevicePathType (DevicePath) == MEDIA_DEVICE_PATH) && - (DevicePathSubType (DevicePath) == MEDIA_FILEPATH_DP)) { - // - // File-path shortform device path - // - Shortform = TRUE; - } else if ((DevicePathType (DevicePath) == MESSAGING_DEVICE_PATH) && - (DevicePathSubType (DevicePath) == MSG_URI_DP)) { - // - // URI shortform device path - // - Shortform = TRUE; - } else { - for ( Node = DevicePath - ; !IsDevicePathEnd (Node) - ; Node = NextDevicePathNode (Node) - ) { - if ((DevicePathType (Node) == MESSAGING_DEVICE_PATH) && - ((DevicePathSubType (Node) == MSG_USB_CLASS_DP) || - (DevicePathSubType (Node) == MSG_USB_WWID_DP))) { - Shortform = TRUE; - break; - } - } - } - - // - // Attempt to expand any relative UEFI device path to - // an absolute device path first. - // - if (Shortform) { - FileBuffer = EfiBootManagerGetLoadOptionBuffer ( - DevicePath, &AbsDevicePath, &FileSize - ); - if (FileBuffer == NULL) { - goto Exit; - } - FreePool (FileBuffer); - AbsConverted = ConvertDevicePathToText (AbsDevicePath, FALSE, FALSE); - FreePool (AbsDevicePath); - if (AbsConverted == NULL) { - goto Exit; - } - DEBUG ((DEBUG_VERBOSE, - "%a: expanded relative device path \"%s\" for prefix matching\n", - __FUNCTION__, Converted)); - FreePool (Converted); - Converted = AbsConverted; - } - - // - // Is Translated a prefix of Converted? - // - Result = (BOOLEAN)(StrnCmp (Converted, Translated, TranslatedLength) == 0); - DEBUG (( - DEBUG_VERBOSE, - "%a: against \"%s\": %a\n", - __FUNCTION__, - Converted, - Result ? "match" : "no match" - )); -Exit: - FreePool (Converted); - return Result; -} - - -/** - Append some of the unselected active boot options to the boot order. - - This function should accommodate any further policy changes in "boot option - survival". Currently we're adding back everything that starts with neither - PciRoot() nor HD() nor a virtio-mmio VenHw() node. - - @param[in,out] BootOrder The structure holding the boot order to - complete. The caller is responsible for - initializing (and potentially populating) it - before calling this function. - - @param[in,out] ActiveOption The array of active boot options to scan. - Entries marked as Appended will be skipped. - Those of the rest that satisfy the survival - policy will be added to BootOrder with - BootOrderAppend(). - - @param[in] ActiveCount Number of elements in ActiveOption. - - - @retval RETURN_SUCCESS BootOrder has been extended with any eligible boot - options. - - @return Error codes returned by BootOrderAppend(). -**/ -STATIC -RETURN_STATUS -BootOrderComplete ( - IN OUT BOOT_ORDER *BootOrder, - IN OUT ACTIVE_OPTION *ActiveOption, - IN UINTN ActiveCount - ) -{ - RETURN_STATUS Status; - UINTN Idx; - - Status = RETURN_SUCCESS; - Idx = 0; - while (!RETURN_ERROR (Status) && Idx < ActiveCount) { - if (!ActiveOption[Idx].Appended) { - CONST EFI_BOOT_MANAGER_LOAD_OPTION *Current; - CONST EFI_DEVICE_PATH_PROTOCOL *FirstNode; - - Current = ActiveOption[Idx].BootOption; - FirstNode = Current->FilePath; - if (FirstNode != NULL) { - CHAR16 *Converted; - STATIC CHAR16 ConvFallBack[] = L""; - BOOLEAN Keep; - - Converted = ConvertDevicePathToText (FirstNode, FALSE, FALSE); - if (Converted == NULL) { - Converted = ConvFallBack; - } - - Keep = TRUE; - if (DevicePathType(FirstNode) == MEDIA_DEVICE_PATH && - DevicePathSubType(FirstNode) == MEDIA_HARDDRIVE_DP) { - // - // drop HD() - // - Keep = FALSE; - } else if (DevicePathType(FirstNode) == ACPI_DEVICE_PATH && - DevicePathSubType(FirstNode) == ACPI_DP) { - ACPI_HID_DEVICE_PATH *Acpi; - - Acpi = (ACPI_HID_DEVICE_PATH *) FirstNode; - if ((Acpi->HID & PNP_EISA_ID_MASK) == PNP_EISA_ID_CONST && - EISA_ID_TO_NUM (Acpi->HID) == 0x0a03) { - // - // drop PciRoot() if we enabled the user to select PCI-like boot - // options, by providing translation for such OFW device path - // fragments - // - Keep = !FeaturePcdGet (PcdQemuBootOrderPciTranslation); - } - } else if (DevicePathType(FirstNode) == HARDWARE_DEVICE_PATH && - DevicePathSubType(FirstNode) == HW_VENDOR_DP) { - VENDOR_DEVICE_PATH *VenHw; - - VenHw = (VENDOR_DEVICE_PATH *)FirstNode; - if (CompareGuid (&VenHw->Guid, &gVirtioMmioTransportGuid)) { - // - // drop virtio-mmio if we enabled the user to select boot options - // referencing such device paths - // - Keep = !FeaturePcdGet (PcdQemuBootOrderMmioTranslation); - } - } - - if (Keep) { - Status = BootOrderAppend (BootOrder, &ActiveOption[Idx]); - if (!RETURN_ERROR (Status)) { - DEBUG ((DEBUG_VERBOSE, "%a: keeping \"%s\"\n", __FUNCTION__, - Converted)); - } - } else { - DEBUG ((DEBUG_VERBOSE, "%a: dropping \"%s\"\n", __FUNCTION__, - Converted)); - } - - if (Converted != ConvFallBack) { - FreePool (Converted); - } - } - } - ++Idx; - } - return Status; -} - - -/** - Delete Boot#### variables that stand for such active boot options that have - been dropped (ie. have not been selected by either matching or "survival - policy"). - - @param[in] ActiveOption The array of active boot options to scan. Each - entry not marked as appended will trigger the - deletion of the matching Boot#### variable. - - @param[in] ActiveCount Number of elements in ActiveOption. -**/ -STATIC -VOID -PruneBootVariables ( - IN CONST ACTIVE_OPTION *ActiveOption, - IN UINTN ActiveCount - ) -{ - UINTN Idx; - - for (Idx = 0; Idx < ActiveCount; ++Idx) { - if (!ActiveOption[Idx].Appended) { - CHAR16 VariableName[9]; - - UnicodeSPrintAsciiFormat (VariableName, sizeof VariableName, "Boot%04x", - ActiveOption[Idx].BootOption->OptionNumber); - - // - // "The space consumed by the deleted variable may not be available until - // the next power cycle", but that's good enough. - // - gRT->SetVariable (VariableName, &gEfiGlobalVariableGuid, - 0, // Attributes, 0 means deletion - 0, // DataSize, 0 means deletion - NULL // Data - ); - } - } -} - - -/** - - Set the boot order based on configuration retrieved from QEMU. - - Attempt to retrieve the "bootorder" fw_cfg file from QEMU. Translate the - OpenFirmware device paths therein to UEFI device path fragments. Match the - translated fragments against the current list of boot options, and rewrite - the BootOrder NvVar so that it corresponds to the order described in fw_cfg. - - Platform BDS should call this function after EfiBootManagerConnectAll () and - EfiBootManagerRefreshAllBootOption () return. - - @retval RETURN_SUCCESS BootOrder NvVar rewritten. - - @retval RETURN_UNSUPPORTED QEMU's fw_cfg is not supported. - - @retval RETURN_NOT_FOUND Empty or nonexistent "bootorder" fw_cfg - file, or no match found between the - "bootorder" fw_cfg file and BootOptionList. - - @retval RETURN_INVALID_PARAMETER Parse error in the "bootorder" fw_cfg file. - - @retval RETURN_OUT_OF_RESOURCES Memory allocation failed. - - @return Values returned by gBS->LocateProtocol () - or gRT->SetVariable (). - -**/ -RETURN_STATUS -SetBootOrderFromQemu ( - VOID - ) -{ - RETURN_STATUS Status; - FIRMWARE_CONFIG_ITEM FwCfgItem; - UINTN FwCfgSize; - CHAR8 *FwCfg; - CONST CHAR8 *FwCfgPtr; - - BOOT_ORDER BootOrder; - ACTIVE_OPTION *ActiveOption; - UINTN ActiveCount; - - EXTRA_ROOT_BUS_MAP *ExtraPciRoots; - - UINTN TranslatedSize; - CHAR16 Translated[TRANSLATION_OUTPUT_SIZE]; - EFI_BOOT_MANAGER_LOAD_OPTION *BootOptions; - UINTN BootOptionCount; - - Status = QemuFwCfgFindFile ("bootorder", &FwCfgItem, &FwCfgSize); - if (Status != RETURN_SUCCESS) { - return Status; - } - - if (FwCfgSize == 0) { - return RETURN_NOT_FOUND; - } - - FwCfg = AllocatePool (FwCfgSize); - if (FwCfg == NULL) { - return RETURN_OUT_OF_RESOURCES; - } - - QemuFwCfgSelectItem (FwCfgItem); - QemuFwCfgReadBytes (FwCfgSize, FwCfg); - if (FwCfg[FwCfgSize - 1] != '\0') { - Status = RETURN_INVALID_PARAMETER; - goto ErrorFreeFwCfg; - } - - DEBUG ((DEBUG_VERBOSE, "%a: FwCfg:\n", __FUNCTION__)); - DEBUG ((DEBUG_VERBOSE, "%a\n", FwCfg)); - DEBUG ((DEBUG_VERBOSE, "%a: FwCfg: \n", __FUNCTION__)); - FwCfgPtr = FwCfg; - - BootOrder.Produced = 0; - BootOrder.Allocated = 1; - BootOrder.Data = AllocatePool ( - BootOrder.Allocated * sizeof (*BootOrder.Data) - ); - if (BootOrder.Data == NULL) { - Status = RETURN_OUT_OF_RESOURCES; - goto ErrorFreeFwCfg; - } - - BootOptions = EfiBootManagerGetLoadOptions ( - &BootOptionCount, LoadOptionTypeBoot - ); - if (BootOptions == NULL) { - Status = RETURN_NOT_FOUND; - goto ErrorFreeBootOrder; - } - - Status = CollectActiveOptions ( - BootOptions, BootOptionCount, &ActiveOption, &ActiveCount - ); - if (RETURN_ERROR (Status)) { - goto ErrorFreeBootOptions; - } - - if (FeaturePcdGet (PcdQemuBootOrderPciTranslation)) { - Status = CreateExtraRootBusMap (&ExtraPciRoots); - if (EFI_ERROR (Status)) { - goto ErrorFreeActiveOption; - } - } else { - ExtraPciRoots = NULL; - } - - // - // translate each OpenFirmware path - // - TranslatedSize = ARRAY_SIZE (Translated); - Status = TranslateOfwPath (&FwCfgPtr, ExtraPciRoots, Translated, - &TranslatedSize); - while (Status == RETURN_SUCCESS || - Status == RETURN_UNSUPPORTED || - Status == RETURN_PROTOCOL_ERROR || - Status == RETURN_BUFFER_TOO_SMALL) { - if (Status == RETURN_SUCCESS) { - UINTN Idx; - - // - // match translated OpenFirmware path against all active boot options - // - for (Idx = 0; Idx < ActiveCount; ++Idx) { - if (Match ( - Translated, - TranslatedSize, // contains length, not size, in CHAR16's here - ActiveOption[Idx].BootOption->FilePath - ) - ) { - // - // match found, store ID and continue with next OpenFirmware path - // - Status = BootOrderAppend (&BootOrder, &ActiveOption[Idx]); - if (Status != RETURN_SUCCESS) { - goto ErrorFreeExtraPciRoots; - } - break; - } - } // scanned all active boot options - } // translation successful - - TranslatedSize = ARRAY_SIZE (Translated); - Status = TranslateOfwPath (&FwCfgPtr, ExtraPciRoots, Translated, - &TranslatedSize); - } // scanning of OpenFirmware paths done - - if (Status == RETURN_NOT_FOUND && BootOrder.Produced > 0) { - // - // No more OpenFirmware paths, some matches found: rewrite BootOrder NvVar. - // Some of the active boot options that have not been selected over fw_cfg - // should be preserved at the end of the boot order. - // - Status = BootOrderComplete (&BootOrder, ActiveOption, ActiveCount); - if (RETURN_ERROR (Status)) { - goto ErrorFreeExtraPciRoots; - } - - // - // See Table 10 in the UEFI Spec 2.3.1 with Errata C for the required - // attributes. - // - Status = gRT->SetVariable ( - L"BootOrder", - &gEfiGlobalVariableGuid, - EFI_VARIABLE_NON_VOLATILE | - EFI_VARIABLE_BOOTSERVICE_ACCESS | - EFI_VARIABLE_RUNTIME_ACCESS, - BootOrder.Produced * sizeof (*BootOrder.Data), - BootOrder.Data - ); - if (EFI_ERROR (Status)) { - DEBUG ((DEBUG_ERROR, "%a: setting BootOrder: %r\n", __FUNCTION__, Status)); - goto ErrorFreeExtraPciRoots; - } - - DEBUG ((DEBUG_INFO, "%a: setting BootOrder: success\n", __FUNCTION__)); - PruneBootVariables (ActiveOption, ActiveCount); - } - -ErrorFreeExtraPciRoots: - if (ExtraPciRoots != NULL) { - DestroyExtraRootBusMap (ExtraPciRoots); - } - -ErrorFreeActiveOption: - FreePool (ActiveOption); - -ErrorFreeBootOptions: - EfiBootManagerFreeLoadOptions (BootOptions, BootOptionCount); - -ErrorFreeBootOrder: - FreePool (BootOrder.Data); - -ErrorFreeFwCfg: - FreePool (FwCfg); - - return Status; -} - - -/** - Calculate the number of seconds we should be showing the FrontPage progress - bar for. - - @return The TimeoutDefault argument for PlatformBdsEnterFrontPage(). -**/ -UINT16 -GetFrontPageTimeoutFromQemu ( - VOID - ) -{ - FIRMWARE_CONFIG_ITEM BootMenuWaitItem; - UINTN BootMenuWaitSize; - - QemuFwCfgSelectItem (QemuFwCfgItemBootMenu); - if (QemuFwCfgRead16 () == 0) { - // - // The user specified "-boot menu=off", or didn't specify "-boot - // menu=(on|off)" at all. Return the platform default. - // - return PcdGet16 (PcdPlatformBootTimeOut); - } - - if (RETURN_ERROR (QemuFwCfgFindFile ("etc/boot-menu-wait", &BootMenuWaitItem, - &BootMenuWaitSize)) || - BootMenuWaitSize != sizeof (UINT16)) { - // - // "-boot menu=on" was specified without "splash-time=N". In this case, - // return three seconds if the platform default would cause us to skip the - // front page, and return the platform default otherwise. - // - UINT16 Timeout; - - Timeout = PcdGet16 (PcdPlatformBootTimeOut); - if (Timeout == 0) { - Timeout = 3; - } - return Timeout; - } - - // - // "-boot menu=on,splash-time=N" was specified, where N is in units of - // milliseconds. The Intel BDS Front Page progress bar only supports whole - // seconds, round N up. - // - QemuFwCfgSelectItem (BootMenuWaitItem); - return (UINT16)((QemuFwCfgRead16 () + 999) / 1000); -} diff --git a/OvmfPkg/Library/QemuBootOrderLib/QemuBootOrderLib.inf b/OvmfPkg/Library/QemuBootOrderLib/QemuBootOrderLib.inf deleted file mode 100644 index eec938f198..0000000000 --- a/OvmfPkg/Library/QemuBootOrderLib/QemuBootOrderLib.inf +++ /dev/null @@ -1,68 +0,0 @@ -## @file -# Rewrite the BootOrder NvVar based on QEMU's "bootorder" fw_cfg file. -# -# Copyright (C) 2012 - 2014, Red Hat, Inc. -# Copyright (c) 2007 - 2016, Intel Corporation. All rights reserved.
-# -# This program and the accompanying materials are licensed and made available -# under the terms and conditions of the BSD License which accompanies this -# distribution. The full text of the license may be found at -# http://opensource.org/licenses/bsd-license.php -# -# THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, -# WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR -# IMPLIED. -# -## - -[Defines] - INF_VERSION = 0x00010005 - BASE_NAME = QemuBootOrderLib - FILE_GUID = 1D677A58-C753-4AF1-B552-EFE142DF8F57 - MODULE_TYPE = DXE_DRIVER - VERSION_STRING = 1.0 - LIBRARY_CLASS = QemuBootOrderLib|DXE_DRIVER - -# -# The following information is for reference only and not required by the build -# tools. -# -# VALID_ARCHITECTURES = IA32 X64 IPF EBC ARM AARCH64 -# - -[Sources] - QemuBootOrderLib.c - ExtraRootBusMap.c - -[Packages] - MdePkg/MdePkg.dec - MdeModulePkg/MdeModulePkg.dec - OvmfPkg/OvmfPkg.dec - -[LibraryClasses] - QemuFwCfgLib - DebugLib - MemoryAllocationLib - UefiBootManagerLib - UefiBootServicesTableLib - UefiRuntimeServicesTableLib - BaseLib - PrintLib - DevicePathLib - BaseMemoryLib - OrderedCollectionLib - -[Guids] - gEfiGlobalVariableGuid - gVirtioMmioTransportGuid - -[FeaturePcd] - gUefiOvmfPkgTokenSpaceGuid.PcdQemuBootOrderPciTranslation - gUefiOvmfPkgTokenSpaceGuid.PcdQemuBootOrderMmioTranslation - -[Pcd] - gEfiMdePkgTokenSpaceGuid.PcdPlatformBootTimeOut - -[Protocols] - gEfiDevicePathProtocolGuid ## CONSUMES - gEfiPciRootBridgeIoProtocolGuid ## CONSUMES diff --git a/OvmfPkg/Library/QemuFwCfgLib/QemuFwCfgLib.c b/OvmfPkg/Library/QemuFwCfgLib/QemuFwCfgLib.c deleted file mode 100644 index 1bf725d8b7..0000000000 --- a/OvmfPkg/Library/QemuFwCfgLib/QemuFwCfgLib.c +++ /dev/null @@ -1,370 +0,0 @@ -/** @file - - Copyright (c) 2011 - 2013, Intel Corporation. All rights reserved.
- Copyright (C) 2013, Red Hat, Inc. - Copyright (c) 2017, AMD Incorporated. All rights reserved.
- - This program and the accompanying materials - are licensed and made available under the terms and conditions of the BSD License - which accompanies this distribution. The full text of the license may be found at - http://opensource.org/licenses/bsd-license.php - - THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, - WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. - -**/ - -#include "Uefi.h" -#include -#include -#include -#include -#include -#include -#include - -#include "QemuFwCfgLibInternal.h" - - -/** - Selects a firmware configuration item for reading. - - Following this call, any data read from this item will start from - the beginning of the configuration item's data. - - @param[in] QemuFwCfgItem - Firmware Configuration item to read - -**/ -VOID -EFIAPI -QemuFwCfgSelectItem ( - IN FIRMWARE_CONFIG_ITEM QemuFwCfgItem - ) -{ - DEBUG ((EFI_D_INFO, "Select Item: 0x%x\n", (UINT16)(UINTN) QemuFwCfgItem)); - IoWrite16 (FW_CFG_IO_SELECTOR, (UINT16)(UINTN) QemuFwCfgItem); -} - - -/** - Transfer an array of bytes, or skip a number of bytes, using the DMA - interface. - - @param[in] Size Size in bytes to transfer or skip. - - @param[in,out] Buffer Buffer to read data into or write data from. Ignored, - and may be NULL, if Size is zero, or Control is - FW_CFG_DMA_CTL_SKIP. - - @param[in] Control One of the following: - FW_CFG_DMA_CTL_WRITE - write to fw_cfg from Buffer. - FW_CFG_DMA_CTL_READ - read from fw_cfg into Buffer. - FW_CFG_DMA_CTL_SKIP - skip bytes in fw_cfg. -**/ -VOID -InternalQemuFwCfgDmaBytes ( - IN UINT32 Size, - IN OUT VOID *Buffer OPTIONAL, - IN UINT32 Control - ) -{ - volatile FW_CFG_DMA_ACCESS Access; - UINT32 AccessHigh, AccessLow; - UINT32 Status; - - ASSERT (Control == FW_CFG_DMA_CTL_WRITE || Control == FW_CFG_DMA_CTL_READ || - Control == FW_CFG_DMA_CTL_SKIP); - - if (Size == 0) { - return; - } - - Access.Control = SwapBytes32 (Control); - Access.Length = SwapBytes32 (Size); - Access.Address = SwapBytes64 ((UINTN)Buffer); - - // - // Delimit the transfer from (a) modifications to Access, (b) in case of a - // write, from writes to Buffer by the caller. - // - MemoryFence (); - - // - // Start the transfer. - // - AccessHigh = (UINT32)RShiftU64 ((UINTN)&Access, 32); - AccessLow = (UINT32)(UINTN)&Access; - IoWrite32 (FW_CFG_IO_DMA_ADDRESS, SwapBytes32 (AccessHigh)); - IoWrite32 (FW_CFG_IO_DMA_ADDRESS + 4, SwapBytes32 (AccessLow)); - - // - // Don't look at Access.Control before starting the transfer. - // - MemoryFence (); - - // - // Wait for the transfer to complete. - // - do { - Status = SwapBytes32 (Access.Control); - ASSERT ((Status & FW_CFG_DMA_CTL_ERROR) == 0); - } while (Status != 0); - - // - // After a read, the caller will want to use Buffer. - // - MemoryFence (); -} - - -/** - Reads firmware configuration bytes into a buffer - - @param[in] Size - Size in bytes to read - @param[in] Buffer - Buffer to store data into (OPTIONAL if Size is 0) - -**/ -VOID -EFIAPI -InternalQemuFwCfgReadBytes ( - IN UINTN Size, - IN VOID *Buffer OPTIONAL - ) -{ - if (InternalQemuFwCfgDmaIsAvailable () && Size <= MAX_UINT32) { - InternalQemuFwCfgDmaBytes ((UINT32)Size, Buffer, FW_CFG_DMA_CTL_READ); - return; - } - IoReadFifo8 (FW_CFG_IO_DATA, Size, Buffer); -} - - -/** - Reads firmware configuration bytes into a buffer - - If called multiple times, then the data read will - continue at the offset of the firmware configuration - item where the previous read ended. - - @param[in] Size - Size in bytes to read - @param[in] Buffer - Buffer to store data into - -**/ -VOID -EFIAPI -QemuFwCfgReadBytes ( - IN UINTN Size, - IN VOID *Buffer - ) -{ - if (InternalQemuFwCfgIsAvailable ()) { - InternalQemuFwCfgReadBytes (Size, Buffer); - } else { - ZeroMem (Buffer, Size); - } -} - -/** - Write firmware configuration bytes from a buffer - - If called multiple times, then the data written will - continue at the offset of the firmware configuration - item where the previous write ended. - - @param[in] Size - Size in bytes to write - @param[in] Buffer - Buffer to read data from - -**/ -VOID -EFIAPI -QemuFwCfgWriteBytes ( - IN UINTN Size, - IN VOID *Buffer - ) -{ - if (InternalQemuFwCfgIsAvailable ()) { - if (InternalQemuFwCfgDmaIsAvailable () && Size <= MAX_UINT32) { - InternalQemuFwCfgDmaBytes ((UINT32)Size, Buffer, FW_CFG_DMA_CTL_WRITE); - return; - } - IoWriteFifo8 (FW_CFG_IO_DATA, Size, Buffer); - } -} - - -/** - Skip bytes in the firmware configuration item. - - Increase the offset of the firmware configuration item without transferring - bytes between the item and a caller-provided buffer. Subsequent read, write - or skip operations will commence at the increased offset. - - @param[in] Size Number of bytes to skip. -**/ -VOID -EFIAPI -QemuFwCfgSkipBytes ( - IN UINTN Size - ) -{ - UINTN ChunkSize; - UINT8 SkipBuffer[256]; - - if (!InternalQemuFwCfgIsAvailable ()) { - return; - } - - if (InternalQemuFwCfgDmaIsAvailable () && Size <= MAX_UINT32) { - InternalQemuFwCfgDmaBytes ((UINT32)Size, NULL, FW_CFG_DMA_CTL_SKIP); - return; - } - - // - // Emulate the skip by reading data in chunks, and throwing it away. The - // implementation below is suitable even for phases where RAM or dynamic - // allocation is not available or appropriate. It also doesn't affect the - // static data footprint for client modules. Large skips are not expected, - // therefore this fallback is not performance critical. The size of - // SkipBuffer is thought not to exert a large pressure on the stack in any - // phase. - // - while (Size > 0) { - ChunkSize = MIN (Size, sizeof SkipBuffer); - IoReadFifo8 (FW_CFG_IO_DATA, ChunkSize, SkipBuffer); - Size -= ChunkSize; - } -} - - -/** - Reads a UINT8 firmware configuration value - - @return Value of Firmware Configuration item read - -**/ -UINT8 -EFIAPI -QemuFwCfgRead8 ( - VOID - ) -{ - UINT8 Result; - - QemuFwCfgReadBytes (sizeof (Result), &Result); - - return Result; -} - - -/** - Reads a UINT16 firmware configuration value - - @return Value of Firmware Configuration item read - -**/ -UINT16 -EFIAPI -QemuFwCfgRead16 ( - VOID - ) -{ - UINT16 Result; - - QemuFwCfgReadBytes (sizeof (Result), &Result); - - return Result; -} - - -/** - Reads a UINT32 firmware configuration value - - @return Value of Firmware Configuration item read - -**/ -UINT32 -EFIAPI -QemuFwCfgRead32 ( - VOID - ) -{ - UINT32 Result; - - QemuFwCfgReadBytes (sizeof (Result), &Result); - - return Result; -} - - -/** - Reads a UINT64 firmware configuration value - - @return Value of Firmware Configuration item read - -**/ -UINT64 -EFIAPI -QemuFwCfgRead64 ( - VOID - ) -{ - UINT64 Result; - - QemuFwCfgReadBytes (sizeof (Result), &Result); - - return Result; -} - - -/** - Find the configuration item corresponding to the firmware configuration file. - - @param[in] Name - Name of file to look up. - @param[out] Item - Configuration item corresponding to the file, to be passed - to QemuFwCfgSelectItem (). - @param[out] Size - Number of bytes in the file. - - @return RETURN_SUCCESS If file is found. - RETURN_NOT_FOUND If file is not found. - RETURN_UNSUPPORTED If firmware configuration is unavailable. - -**/ -RETURN_STATUS -EFIAPI -QemuFwCfgFindFile ( - IN CONST CHAR8 *Name, - OUT FIRMWARE_CONFIG_ITEM *Item, - OUT UINTN *Size - ) -{ - UINT32 Count; - UINT32 Idx; - - if (!InternalQemuFwCfgIsAvailable ()) { - return RETURN_UNSUPPORTED; - } - - QemuFwCfgSelectItem (QemuFwCfgItemFileDir); - Count = SwapBytes32 (QemuFwCfgRead32 ()); - - for (Idx = 0; Idx < Count; ++Idx) { - UINT32 FileSize; - UINT16 FileSelect; - UINT16 FileReserved; - CHAR8 FName[QEMU_FW_CFG_FNAME_SIZE]; - - FileSize = QemuFwCfgRead32 (); - FileSelect = QemuFwCfgRead16 (); - FileReserved = QemuFwCfgRead16 (); - (VOID) FileReserved; /* Force a do-nothing reference. */ - InternalQemuFwCfgReadBytes (sizeof (FName), FName); - - if (AsciiStrCmp (Name, FName) == 0) { - *Item = SwapBytes16 (FileSelect); - *Size = SwapBytes32 (FileSize); - return RETURN_SUCCESS; - } - } - - return RETURN_NOT_FOUND; -} diff --git a/OvmfPkg/Library/QemuFwCfgLib/QemuFwCfgLib.inf b/OvmfPkg/Library/QemuFwCfgLib/QemuFwCfgLib.inf deleted file mode 100644 index 689476032d..0000000000 --- a/OvmfPkg/Library/QemuFwCfgLib/QemuFwCfgLib.inf +++ /dev/null @@ -1,50 +0,0 @@ -## @file -# -# Stateful, implicitly initialized fw_cfg library. -# -# Copyright (C) 2013, Red Hat, Inc. -# Copyright (c) 2008 - 2012, Intel Corporation. All rights reserved.
-# Copyright (c) 2017, AMD Incorporated. 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. -# -## - -[Defines] - INF_VERSION = 0x00010005 - BASE_NAME = QemuFwCfgLib - FILE_GUID = fdd53716-31e1-4acc-9007-8bd5d877c96f - MODULE_TYPE = BASE - VERSION_STRING = 1.0 - LIBRARY_CLASS = QemuFwCfgLib|PEIM DXE_DRIVER DXE_RUNTIME_DRIVER DXE_SMM_DRIVER - - CONSTRUCTOR = QemuFwCfgInitialize - -# -# The following information is for reference only and not required by the build tools. -# -# VALID_ARCHITECTURES = IA32 X64 -# - -[Sources] - QemuFwCfgLibInternal.h - QemuFwCfgLib.c - QemuFwCfgPeiDxe.c - -[Packages] - MdePkg/MdePkg.dec - OvmfPkg/OvmfPkg.dec - -[LibraryClasses] - BaseLib - BaseMemoryLib - DebugLib - IoLib - MemoryAllocationLib - diff --git a/OvmfPkg/Library/QemuFwCfgLib/QemuFwCfgLibInternal.h b/OvmfPkg/Library/QemuFwCfgLib/QemuFwCfgLibInternal.h deleted file mode 100644 index 6e87c62510..0000000000 --- a/OvmfPkg/Library/QemuFwCfgLib/QemuFwCfgLibInternal.h +++ /dev/null @@ -1,46 +0,0 @@ -/** @file - Internal interfaces specific to the QemuFwCfgLib instances in OvmfPkg. - - Copyright (C) 2016, 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 __QEMU_FW_CFG_LIB_INTERNAL_H__ -#define __QEMU_FW_CFG_LIB_INTERNAL_H__ - -/** - Returns a boolean indicating if the firmware configuration interface is - available for library-internal purposes. - - This function never changes fw_cfg state. - - @retval TRUE The interface is available internally. - @retval FALSE The interface is not available internally. -**/ -BOOLEAN -InternalQemuFwCfgIsAvailable ( - VOID - ); - - -/** - Returns a boolean indicating whether QEMU provides the DMA-like access method - for fw_cfg. - - @retval TRUE The DMA-like access method is available. - @retval FALSE The DMA-like access method is unavailable. -**/ -BOOLEAN -InternalQemuFwCfgDmaIsAvailable ( - VOID - ); - -#endif diff --git a/OvmfPkg/Library/QemuFwCfgLib/QemuFwCfgPeiDxe.c b/OvmfPkg/Library/QemuFwCfgLib/QemuFwCfgPeiDxe.c deleted file mode 100644 index ac05f4c347..0000000000 --- a/OvmfPkg/Library/QemuFwCfgLib/QemuFwCfgPeiDxe.c +++ /dev/null @@ -1,116 +0,0 @@ -/** @file - - Stateful and implicitly initialized fw_cfg library implementation. - - Copyright (C) 2013, Red Hat, Inc. - Copyright (c) 2011 - 2013, Intel Corporation. All rights reserved.
- - This program and the accompanying materials are licensed and made available - under the terms and conditions of the BSD License which accompanies this - distribution. The full text of the license may be found at - http://opensource.org/licenses/bsd-license.php - - THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, WITHOUT - WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. -**/ - -#include -#include - -#include "QemuFwCfgLibInternal.h" - -STATIC BOOLEAN mQemuFwCfgSupported = FALSE; -STATIC BOOLEAN mQemuFwCfgDmaSupported; - - -/** - Returns a boolean indicating if the firmware configuration interface - is available or not. - - This function may change fw_cfg state. - - @retval TRUE The interface is available - @retval FALSE The interface is not available - -**/ -BOOLEAN -EFIAPI -QemuFwCfgIsAvailable ( - VOID - ) -{ - return InternalQemuFwCfgIsAvailable (); -} - - -RETURN_STATUS -EFIAPI -QemuFwCfgInitialize ( - VOID - ) -{ - UINT32 Signature; - UINT32 Revision; - - // - // Enable the access routines while probing to see if it is supported. - // For probing we always use the IO Port (IoReadFifo8()) access method. - // - mQemuFwCfgSupported = TRUE; - mQemuFwCfgDmaSupported = FALSE; - - QemuFwCfgSelectItem (QemuFwCfgItemSignature); - Signature = QemuFwCfgRead32 (); - DEBUG ((EFI_D_INFO, "FW CFG Signature: 0x%x\n", Signature)); - QemuFwCfgSelectItem (QemuFwCfgItemInterfaceVersion); - Revision = QemuFwCfgRead32 (); - DEBUG ((EFI_D_INFO, "FW CFG Revision: 0x%x\n", Revision)); - if ((Signature != SIGNATURE_32 ('Q', 'E', 'M', 'U')) || - (Revision < 1) - ) { - DEBUG ((EFI_D_INFO, "QemuFwCfg interface not supported.\n")); - mQemuFwCfgSupported = FALSE; - return RETURN_SUCCESS; - } - - if ((Revision & FW_CFG_F_DMA) == 0) { - DEBUG ((DEBUG_INFO, "QemuFwCfg interface (IO Port) is supported.\n")); - } else { - mQemuFwCfgDmaSupported = TRUE; - DEBUG ((DEBUG_INFO, "QemuFwCfg interface (DMA) is supported.\n")); - } - return RETURN_SUCCESS; -} - - -/** - Returns a boolean indicating if the firmware configuration interface is - available for library-internal purposes. - - This function never changes fw_cfg state. - - @retval TRUE The interface is available internally. - @retval FALSE The interface is not available internally. -**/ -BOOLEAN -InternalQemuFwCfgIsAvailable ( - VOID - ) -{ - return mQemuFwCfgSupported; -} - -/** - Returns a boolean indicating whether QEMU provides the DMA-like access method - for fw_cfg. - - @retval TRUE The DMA-like access method is available. - @retval FALSE The DMA-like access method is unavailable. -**/ -BOOLEAN -InternalQemuFwCfgDmaIsAvailable ( - VOID - ) -{ - return mQemuFwCfgDmaSupported; -} diff --git a/OvmfPkg/Library/QemuFwCfgLib/QemuFwCfgSec.c b/OvmfPkg/Library/QemuFwCfgLib/QemuFwCfgSec.c deleted file mode 100644 index 465ccbe90d..0000000000 --- a/OvmfPkg/Library/QemuFwCfgLib/QemuFwCfgSec.c +++ /dev/null @@ -1,96 +0,0 @@ -/** @file - - Stateless fw_cfg library implementation. - - Clients must call QemuFwCfgIsAvailable() first. - - Copyright (C) 2013, Red Hat, Inc. - Copyright (c) 2011 - 2013, Intel Corporation. All rights reserved.
- - This program and the accompanying materials are licensed and made available - under the terms and conditions of the BSD License which accompanies this - distribution. The full text of the license may be found at - http://opensource.org/licenses/bsd-license.php - - THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, WITHOUT - WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. -**/ - -#include -#include - -#include "QemuFwCfgLibInternal.h" - -/** - Returns a boolean indicating if the firmware configuration interface - is available or not. - - This function may change fw_cfg state. - - @retval TRUE The interface is available - @retval FALSE The interface is not available - -**/ -BOOLEAN -EFIAPI -QemuFwCfgIsAvailable ( - VOID - ) -{ - UINT32 Signature; - UINT32 Revision; - - QemuFwCfgSelectItem (QemuFwCfgItemSignature); - Signature = QemuFwCfgRead32 (); - DEBUG ((EFI_D_INFO, "FW CFG Signature: 0x%x\n", Signature)); - QemuFwCfgSelectItem (QemuFwCfgItemInterfaceVersion); - Revision = QemuFwCfgRead32 (); - DEBUG ((EFI_D_INFO, "FW CFG Revision: 0x%x\n", Revision)); - if ((Signature != SIGNATURE_32 ('Q', 'E', 'M', 'U')) || - (Revision < 1) - ) { - DEBUG ((EFI_D_INFO, "QemuFwCfg interface not supported.\n")); - return FALSE; - } - - DEBUG ((EFI_D_INFO, "QemuFwCfg interface is supported.\n")); - return TRUE; -} - - -/** - Returns a boolean indicating if the firmware configuration interface is - available for library-internal purposes. - - This function never changes fw_cfg state. - - @retval TRUE The interface is available internally. - @retval FALSE The interface is not available internally. -**/ -BOOLEAN -InternalQemuFwCfgIsAvailable ( - VOID - ) -{ - // - // We always return TRUE, because the consumer of this library ought to have - // called QemuFwCfgIsAvailable before making other calls which would hit this - // path. - // - return TRUE; -} - -/** - Returns a boolean indicating whether QEMU provides the DMA-like access method - for fw_cfg. - - @retval TRUE The DMA-like access method is available. - @retval FALSE The DMA-like access method is unavailable. -**/ -BOOLEAN -InternalQemuFwCfgDmaIsAvailable ( - VOID - ) -{ - return FALSE; -} diff --git a/OvmfPkg/Library/QemuFwCfgLib/QemuFwCfgSecLib.inf b/OvmfPkg/Library/QemuFwCfgLib/QemuFwCfgSecLib.inf deleted file mode 100644 index 7a96575d18..0000000000 --- a/OvmfPkg/Library/QemuFwCfgLib/QemuFwCfgSecLib.inf +++ /dev/null @@ -1,48 +0,0 @@ -## @file -# -# Stateless fw_cfg library that must be queried before use. -# -# Copyright (C) 2013, Red Hat, Inc. -# Copyright (c) 2008 - 2012, Intel Corporation. All rights reserved.
-# Copyright (c) 2017, AMD Incorporated. 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. -# -## - -[Defines] - INF_VERSION = 0x00010005 - BASE_NAME = QemuFwCfgSecLib - FILE_GUID = 60a910e5-7443-413d-9a30-97e57497cd1b - MODULE_TYPE = BASE - VERSION_STRING = 1.0 - LIBRARY_CLASS = QemuFwCfgLib|SEC - -# -# The following information is for reference only and not required by the build tools. -# -# VALID_ARCHITECTURES = IA32 X64 -# - -[Sources] - QemuFwCfgLibInternal.h - QemuFwCfgLib.c - QemuFwCfgSec.c - -[Packages] - MdePkg/MdePkg.dec - OvmfPkg/OvmfPkg.dec - -[LibraryClasses] - BaseLib - BaseMemoryLib - DebugLib - IoLib - MemoryAllocationLib - diff --git a/OvmfPkg/Library/QemuFwCfgS3Lib/BaseQemuFwCfgS3LibNull.inf b/OvmfPkg/Library/QemuFwCfgS3Lib/BaseQemuFwCfgS3LibNull.inf deleted file mode 100644 index 837fd70db6..0000000000 --- a/OvmfPkg/Library/QemuFwCfgS3Lib/BaseQemuFwCfgS3LibNull.inf +++ /dev/null @@ -1,43 +0,0 @@ -## @file -# Base Null library instance of the QemuFwCfgS3Lib class. -# -# This library instance returns constant FALSE from QemuFwCfgS3Enabled(), and -# all other library functions trigger assertion failures. It is suitable for -# QEMU targets and machine types that never enable S3. -# -# Copyright (C) 2017, 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 = 1.25 - BASE_NAME = BaseQemuFwCfgS3LibNull - FILE_GUID = EA7D2B69-D221-4950-9C2C-C38A65BCC96E - MODULE_TYPE = BASE - VERSION_STRING = 1.0 - LIBRARY_CLASS = QemuFwCfgS3Lib - -# -# The following information is for reference only and not required by the build -# tools. -# -# VALID_ARCHITECTURES = IA32 X64 ARM AARCH64 IPF EBC -# - -[Sources] - QemuFwCfgS3Base.c - QemuFwCfgS3BasePei.c - -[Packages] - MdePkg/MdePkg.dec - OvmfPkg/OvmfPkg.dec - -[LibraryClasses] - DebugLib diff --git a/OvmfPkg/Library/QemuFwCfgS3Lib/DxeQemuFwCfgS3LibFwCfg.inf b/OvmfPkg/Library/QemuFwCfgS3Lib/DxeQemuFwCfgS3LibFwCfg.inf deleted file mode 100644 index a0e4275cb8..0000000000 --- a/OvmfPkg/Library/QemuFwCfgS3Lib/DxeQemuFwCfgS3LibFwCfg.inf +++ /dev/null @@ -1,46 +0,0 @@ -## @file -# Full functionality QemuFwCfgS3Lib instance, for DXE phase modules. -# -# Copyright (C) 2017, 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 = 1.25 - BASE_NAME = DxeQemuFwCfgS3LibFwCfg - FILE_GUID = C5DE76EB-E8DE-4057-A487-C5A09AB039AB - MODULE_TYPE = DXE_DRIVER - VERSION_STRING = 1.0 - LIBRARY_CLASS = QemuFwCfgS3Lib|DXE_DRIVER DXE_RUNTIME_DRIVER - -# -# The following information is for reference only and not required by the build -# tools. -# -# VALID_ARCHITECTURES = IA32 X64 ARM AARCH64 IPF EBC -# - -[Sources] - QemuFwCfgS3Dxe.c - QemuFwCfgS3PeiDxe.c - -[Packages] - MdePkg/MdePkg.dec - OvmfPkg/OvmfPkg.dec - -[LibraryClasses] - BaseLib - DebugLib - MemoryAllocationLib - QemuFwCfgLib - UefiBootServicesTableLib - -[Protocols] - gEfiS3SaveStateProtocolGuid ## SOMETIMES_CONSUMES diff --git a/OvmfPkg/Library/QemuFwCfgS3Lib/PeiQemuFwCfgS3LibFwCfg.inf b/OvmfPkg/Library/QemuFwCfgS3Lib/PeiQemuFwCfgS3LibFwCfg.inf deleted file mode 100644 index 890862076e..0000000000 --- a/OvmfPkg/Library/QemuFwCfgS3Lib/PeiQemuFwCfgS3LibFwCfg.inf +++ /dev/null @@ -1,44 +0,0 @@ -## @file -# Limited functionality QemuFwCfgS3Lib instance, for PEI phase modules. -# -# QemuFwCfgS3Enabled() queries S3 enablement via fw_cfg. Other library APIs -# will report lack of support. -# -# Copyright (C) 2017, 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 = 1.25 - BASE_NAME = PeiQemuFwCfgS3LibFwCfg - FILE_GUID = DD8D28B4-C1DC-4CAF-BB93-074BE80DAE6D - MODULE_TYPE = PEIM - VERSION_STRING = 1.0 - LIBRARY_CLASS = QemuFwCfgS3Lib|PEIM - -# -# The following information is for reference only and not required by the build -# tools. -# -# VALID_ARCHITECTURES = IA32 X64 ARM AARCH64 IPF EBC -# - -[Sources] - QemuFwCfgS3BasePei.c - QemuFwCfgS3Pei.c - QemuFwCfgS3PeiDxe.c - -[Packages] - MdePkg/MdePkg.dec - OvmfPkg/OvmfPkg.dec - -[LibraryClasses] - DebugLib - QemuFwCfgLib diff --git a/OvmfPkg/Library/QemuFwCfgS3Lib/QemuFwCfgS3Base.c b/OvmfPkg/Library/QemuFwCfgS3Lib/QemuFwCfgS3Base.c deleted file mode 100644 index 7fa1200ee3..0000000000 --- a/OvmfPkg/Library/QemuFwCfgS3Lib/QemuFwCfgS3Base.c +++ /dev/null @@ -1,111 +0,0 @@ -/** @file - Base Null library instance of the QemuFwCfgS3Lib class. - - This library instance returns constant FALSE from QemuFwCfgS3Enabled(), and - all other library functions trigger assertion failures. It is suitable for - QEMU targets and machine types that never enable S3. - - Copyright (C) 2017, 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 -#include - -/** - Determine if S3 support is explicitly enabled. - - @retval TRUE If S3 support is explicitly enabled. Other functions in this - library may be called (subject to their individual - restrictions). - - FALSE Otherwise. This includes unavailability of the firmware - configuration interface. No other function in this library - must be called. -**/ -BOOLEAN -EFIAPI -QemuFwCfgS3Enabled ( - VOID - ) -{ - return FALSE; -} - - -/** - Install the client module's FW_CFG_BOOT_SCRIPT_CALLBACK_FUNCTION callback for - when the production of ACPI S3 Boot Script opcodes becomes possible. - - Take ownership of the client-provided Context, and pass it to the callback - function, when the latter is invoked. - - Allocate scratch space for those ACPI S3 Boot Script opcodes to work upon - that the client will produce in the callback function. - - @param[in] Callback FW_CFG_BOOT_SCRIPT_CALLBACK_FUNCTION to invoke - when the production of ACPI S3 Boot Script - opcodes becomes possible. Callback() may be - called immediately from - QemuFwCfgS3CallWhenBootScriptReady(). - - @param[in,out] Context Client-provided data structure for the - Callback() callback function to consume. - - If Context points to dynamically allocated - memory, then Callback() must release it. - - If Context points to dynamically allocated - memory, and - QemuFwCfgS3CallWhenBootScriptReady() returns - successfully, then the caller of - QemuFwCfgS3CallWhenBootScriptReady() must - neither dereference nor even evaluate Context - any longer, as ownership of the referenced area - has been transferred to Callback(). - - @param[in] ScratchBufferSize The size of the scratch buffer that will hold, - in reserved memory, all client data read, - written, and checked by the ACPI S3 Boot Script - opcodes produced by Callback(). - - @retval RETURN_UNSUPPORTED The library instance does not support this - function. - - @retval RETURN_NOT_FOUND The fw_cfg DMA interface to QEMU is - unavailable. - - @retval RETURN_BAD_BUFFER_SIZE ScratchBufferSize is too large. - - @retval RETURN_OUT_OF_RESOURCES Memory allocation failed. - - @retval RETURN_SUCCESS Callback() has been installed, and the - ownership of Context has been transferred. - Reserved memory has been allocated for the - scratch buffer. - - A successful invocation of - QemuFwCfgS3CallWhenBootScriptReady() cannot - be rolled back. - - @return Error codes from underlying functions. -**/ - -RETURN_STATUS -EFIAPI -QemuFwCfgS3CallWhenBootScriptReady ( - IN FW_CFG_BOOT_SCRIPT_CALLBACK_FUNCTION *Callback, - IN OUT VOID *Context, OPTIONAL - IN UINTN ScratchBufferSize - ) -{ - ASSERT (FALSE); - return RETURN_UNSUPPORTED; -} diff --git a/OvmfPkg/Library/QemuFwCfgS3Lib/QemuFwCfgS3BasePei.c b/OvmfPkg/Library/QemuFwCfgS3Lib/QemuFwCfgS3BasePei.c deleted file mode 100644 index bdad448016..0000000000 --- a/OvmfPkg/Library/QemuFwCfgS3Lib/QemuFwCfgS3BasePei.c +++ /dev/null @@ -1,227 +0,0 @@ -/** @file - Shared code for the Base Null and PEI fw_cfg instances of the QemuFwCfgS3Lib - class. - - Copyright (C) 2017, 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 -#include - -/** - Produce ACPI S3 Boot Script opcodes that (optionally) select an fw_cfg item, - and transfer data to it. - - The opcodes produced by QemuFwCfgS3ScriptWriteBytes() will first restore - NumberOfBytes bytes in ScratchBuffer in-place, in reserved memory, then write - them to fw_cfg using DMA. - - If the operation fails during S3 resume, the boot script will hang. - - This function may only be called from the client module's - FW_CFG_BOOT_SCRIPT_CALLBACK_FUNCTION, which was passed to - QemuFwCfgS3CallWhenBootScriptReady() as Callback. - - @param[in] FirmwareConfigItem The UINT16 selector key of the firmware config - item to write, expressed as INT32. If - FirmwareConfigItem is -1, no selection is - made, the write will occur to the currently - selected item, at its currently selected - offset. Otherwise, the specified item will be - selected, and the write will occur at offset - 0. - - @param[in] NumberOfBytes Size of the data to restore in ScratchBuffer, - and to write from ScratchBuffer, during S3 - resume. NumberOfBytes must not exceed - ScratchBufferSize, which was passed to - QemuFwCfgS3CallWhenBootScriptReady(). - - @retval RETURN_SUCCESS The opcodes were appended to the ACPI S3 - Boot Script successfully. There is no way - to undo this action. - - @retval RETURN_INVALID_PARAMETER FirmwareConfigItem is invalid. - - @retval RETURN_BAD_BUFFER_SIZE NumberOfBytes is larger than - ScratchBufferSize. - - @return Error codes from underlying functions. -**/ -RETURN_STATUS -EFIAPI -QemuFwCfgS3ScriptWriteBytes ( - IN INT32 FirmwareConfigItem, - IN UINTN NumberOfBytes - ) -{ - ASSERT (FALSE); - return RETURN_UNSUPPORTED; -} - - -/** - Produce ACPI S3 Boot Script opcodes that (optionally) select an fw_cfg item, - and transfer data from it. - - The opcodes produced by QemuFwCfgS3ScriptReadBytes() will read NumberOfBytes - bytes from fw_cfg using DMA, storing the result in ScratchBuffer, in reserved - memory. - - If the operation fails during S3 resume, the boot script will hang. - - This function may only be called from the client module's - FW_CFG_BOOT_SCRIPT_CALLBACK_FUNCTION, which was passed to - QemuFwCfgS3CallWhenBootScriptReady() as Callback. - - @param[in] FirmwareConfigItem The UINT16 selector key of the firmware config - item to read, expressed as INT32. If - FirmwareConfigItem is -1, no selection is - made, the read will occur from the currently - selected item, from its currently selected - offset. Otherwise, the specified item will be - selected, and the read will occur from offset - 0. - - @param[in] NumberOfBytes Size of the data to read during S3 resume. - NumberOfBytes must not exceed - ScratchBufferSize, which was passed to - QemuFwCfgS3CallWhenBootScriptReady(). - - @retval RETURN_SUCCESS The opcodes were appended to the ACPI S3 - Boot Script successfully. There is no way - to undo this action. - - @retval RETURN_INVALID_PARAMETER FirmwareConfigItem is invalid. - - @retval RETURN_BAD_BUFFER_SIZE NumberOfBytes is larger than - ScratchBufferSize. - - @return Error codes from underlying functions. -**/ -RETURN_STATUS -EFIAPI -QemuFwCfgS3ScriptReadBytes ( - IN INT32 FirmwareConfigItem, - IN UINTN NumberOfBytes - ) -{ - ASSERT (FALSE); - return RETURN_UNSUPPORTED; -} - - -/** - Produce ACPI S3 Boot Script opcodes that (optionally) select an fw_cfg item, - and increase its offset. - - If the operation fails during S3 resume, the boot script will hang. - - This function may only be called from the client module's - FW_CFG_BOOT_SCRIPT_CALLBACK_FUNCTION, which was passed to - QemuFwCfgS3CallWhenBootScriptReady() as Callback. - - @param[in] FirmwareConfigItem The UINT16 selector key of the firmware config - item to advance the offset of, expressed as - INT32. If FirmwareConfigItem is -1, no - selection is made, and the offset for the - currently selected item is increased. - Otherwise, the specified item will be - selected, and the offset increment will occur - from offset 0. - - @param[in] NumberOfBytes The number of bytes to skip in the subject - fw_cfg item. - - @retval RETURN_SUCCESS The opcodes were appended to the ACPI S3 - Boot Script successfully. There is no way - to undo this action. - - @retval RETURN_INVALID_PARAMETER FirmwareConfigItem is invalid. - - @retval RETURN_BAD_BUFFER_SIZE NumberOfBytes is too large. - - @return Error codes from underlying functions. -**/ -RETURN_STATUS -EFIAPI -QemuFwCfgS3ScriptSkipBytes ( - IN INT32 FirmwareConfigItem, - IN UINTN NumberOfBytes - ) -{ - ASSERT (FALSE); - return RETURN_UNSUPPORTED; -} - - -/** - Produce ACPI S3 Boot Script opcodes that check a value in ScratchBuffer. - - If the check fails during S3 resume, the boot script will hang. - - This function may only be called from the client module's - FW_CFG_BOOT_SCRIPT_CALLBACK_FUNCTION, which was passed to - QemuFwCfgS3CallWhenBootScriptReady() as Callback. - - @param[in] ScratchData Pointer to the UINT8, UINT16, UINT32 or UINT64 field - in ScratchBuffer that should be checked. The caller - is responsible for populating the field during S3 - resume, by calling QemuFwCfgS3ScriptReadBytes() ahead - of QemuFwCfgS3ScriptCheckValue(). - - ScratchData must point into ScratchBuffer, which was - allocated, and passed to Callback(), by - QemuFwCfgS3CallWhenBootScriptReady(). - - ScratchData must be aligned at ValueSize bytes. - - @param[in] ValueSize One of 1, 2, 4 or 8, specifying the size of the field - to check. - - @param[in] ValueMask The value read from ScratchData is binarily AND-ed - with ValueMask, and the result is compared against - Value. If the masked data equals Value, the check - passes, and the boot script can proceed. Otherwise, - the check fails, and the boot script hangs. - - @param[in] Value Refer to ValueMask. - - @retval RETURN_SUCCESS The opcodes were appended to the ACPI S3 - Boot Script successfully. There is no way - to undo this action. - - @retval RETURN_INVALID_PARAMETER ValueSize is invalid. - - @retval RETURN_INVALID_PARAMETER ValueMask or Value cannot be represented in - ValueSize bytes. - - @retval RETURN_INVALID_PARAMETER ScratchData is not aligned at ValueSize - bytes. - - @retval RETURN_BAD_BUFFER_SIZE The ValueSize bytes at ScratchData aren't - wholly contained in the ScratchBufferSize - bytes at ScratchBuffer. - - @return Error codes from underlying functions. -**/ -RETURN_STATUS -EFIAPI -QemuFwCfgS3ScriptCheckValue ( - IN VOID *ScratchData, - IN UINT8 ValueSize, - IN UINT64 ValueMask, - IN UINT64 Value - ) -{ - ASSERT (FALSE); - return RETURN_UNSUPPORTED; -} diff --git a/OvmfPkg/Library/QemuFwCfgS3Lib/QemuFwCfgS3Dxe.c b/OvmfPkg/Library/QemuFwCfgS3Lib/QemuFwCfgS3Dxe.c deleted file mode 100644 index 3fef2e3017..0000000000 --- a/OvmfPkg/Library/QemuFwCfgS3Lib/QemuFwCfgS3Dxe.c +++ /dev/null @@ -1,792 +0,0 @@ -/** @file - Full functionality QemuFwCfgS3Lib instance, for DXE phase modules. - - Copyright (C) 2017, 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 -#include -#include -#include -#include -#include -#include - - -// -// Event to signal when the S3SaveState protocol interface is installed. -// -STATIC EFI_EVENT mS3SaveStateInstalledEvent; - -// -// Reference to the S3SaveState protocol interface, after it is installed. -// -STATIC EFI_S3_SAVE_STATE_PROTOCOL *mS3SaveState; - -// -// The control structure is allocated in reserved memory, aligned at 8 bytes. -// The client-requested ScratchBuffer will be allocated adjacently, also -// aligned at 8 bytes. -// -#define RESERVED_MEM_ALIGNMENT 8 - -STATIC FW_CFG_DMA_ACCESS *mDmaAccess; -STATIC VOID *mScratchBuffer; -STATIC UINTN mScratchBufferSize; - -// -// Callback provided by the client, for appending ACPI S3 Boot Script opcodes. -// To be called from S3SaveStateInstalledNotify(). -// -STATIC FW_CFG_BOOT_SCRIPT_CALLBACK_FUNCTION *mCallback; - - -/** - Event notification function for mS3SaveStateInstalledEvent. -**/ -STATIC -VOID -EFIAPI -S3SaveStateInstalledNotify ( - IN EFI_EVENT Event, - IN VOID *Context - ) -{ - EFI_STATUS Status; - - ASSERT (Event == mS3SaveStateInstalledEvent); - - Status = gBS->LocateProtocol (&gEfiS3SaveStateProtocolGuid, - NULL /* Registration */, (VOID **)&mS3SaveState); - if (EFI_ERROR (Status)) { - return; - } - - ASSERT (mCallback != NULL); - - DEBUG ((DEBUG_INFO, "%a: %a: DmaAccess@0x%Lx ScratchBuffer@[0x%Lx+0x%Lx]\n", - gEfiCallerBaseName, __FUNCTION__, (UINT64)(UINTN)mDmaAccess, - (UINT64)(UINTN)mScratchBuffer, (UINT64)mScratchBufferSize)); - mCallback (Context, mScratchBuffer); - - gBS->CloseEvent (mS3SaveStateInstalledEvent); - mS3SaveStateInstalledEvent = NULL; -} - - -/** - Install the client module's FW_CFG_BOOT_SCRIPT_CALLBACK_FUNCTION callback for - when the production of ACPI S3 Boot Script opcodes becomes possible. - - Take ownership of the client-provided Context, and pass it to the callback - function, when the latter is invoked. - - Allocate scratch space for those ACPI S3 Boot Script opcodes to work upon - that the client will produce in the callback function. - - @param[in] Callback FW_CFG_BOOT_SCRIPT_CALLBACK_FUNCTION to invoke - when the production of ACPI S3 Boot Script - opcodes becomes possible. Callback() may be - called immediately from - QemuFwCfgS3CallWhenBootScriptReady(). - - @param[in,out] Context Client-provided data structure for the - Callback() callback function to consume. - - If Context points to dynamically allocated - memory, then Callback() must release it. - - If Context points to dynamically allocated - memory, and - QemuFwCfgS3CallWhenBootScriptReady() returns - successfully, then the caller of - QemuFwCfgS3CallWhenBootScriptReady() must - neither dereference nor even evaluate Context - any longer, as ownership of the referenced area - has been transferred to Callback(). - - @param[in] ScratchBufferSize The size of the scratch buffer that will hold, - in reserved memory, all client data read, - written, and checked by the ACPI S3 Boot Script - opcodes produced by Callback(). - - @retval RETURN_UNSUPPORTED The library instance does not support this - function. - - @retval RETURN_NOT_FOUND The fw_cfg DMA interface to QEMU is - unavailable. - - @retval RETURN_BAD_BUFFER_SIZE ScratchBufferSize is too large. - - @retval RETURN_OUT_OF_RESOURCES Memory allocation failed. - - @retval RETURN_SUCCESS Callback() has been installed, and the - ownership of Context has been transferred. - Reserved memory has been allocated for the - scratch buffer. - - A successful invocation of - QemuFwCfgS3CallWhenBootScriptReady() cannot - be rolled back. - - @return Error codes from underlying functions. -**/ -RETURN_STATUS -EFIAPI -QemuFwCfgS3CallWhenBootScriptReady ( - IN FW_CFG_BOOT_SCRIPT_CALLBACK_FUNCTION *Callback, - IN OUT VOID *Context, OPTIONAL - IN UINTN ScratchBufferSize - ) -{ - EFI_STATUS Status; - VOID *Registration; - - // - // Basic fw_cfg is certainly available, as we can only be here after a - // successful call to QemuFwCfgS3Enabled(). Check fw_cfg DMA availability. - // - ASSERT (QemuFwCfgIsAvailable ()); - QemuFwCfgSelectItem (QemuFwCfgItemInterfaceVersion); - if ((QemuFwCfgRead32 () & FW_CFG_F_DMA) == 0) { - DEBUG ((DEBUG_ERROR, "%a: %a: fw_cfg DMA unavailable\n", - gEfiCallerBaseName, __FUNCTION__)); - return RETURN_NOT_FOUND; - } - - // - // Allocate a reserved buffer for the DMA access control structure and the - // client data together. - // - if (ScratchBufferSize > - MAX_UINT32 - (RESERVED_MEM_ALIGNMENT - 1) - sizeof *mDmaAccess) { - DEBUG ((DEBUG_ERROR, "%a: %a: ScratchBufferSize too big: %Lu\n", - gEfiCallerBaseName, __FUNCTION__, (UINT64)ScratchBufferSize)); - return RETURN_BAD_BUFFER_SIZE; - } - mDmaAccess = AllocateReservedPool ((RESERVED_MEM_ALIGNMENT - 1) + - sizeof *mDmaAccess + ScratchBufferSize); - if (mDmaAccess == NULL) { - DEBUG ((DEBUG_ERROR, "%a: %a: AllocateReservedPool(): out of resources\n", - gEfiCallerBaseName, __FUNCTION__)); - return RETURN_OUT_OF_RESOURCES; - } - mDmaAccess = ALIGN_POINTER (mDmaAccess, RESERVED_MEM_ALIGNMENT); - - // - // Set up a protocol notify for EFI_S3_SAVE_STATE_PROTOCOL. Forward the - // client's Context to the callback. - // - Status = gBS->CreateEvent (EVT_NOTIFY_SIGNAL, TPL_CALLBACK, - S3SaveStateInstalledNotify, Context, - &mS3SaveStateInstalledEvent); - if (EFI_ERROR (Status)) { - DEBUG ((DEBUG_ERROR, "%a: %a: CreateEvent(): %r\n", gEfiCallerBaseName, - __FUNCTION__, Status)); - goto FreeDmaAccess; - } - Status = gBS->RegisterProtocolNotify (&gEfiS3SaveStateProtocolGuid, - mS3SaveStateInstalledEvent, &Registration); - if (EFI_ERROR (Status)) { - DEBUG ((DEBUG_ERROR, "%a: %a: RegisterProtocolNotify(): %r\n", - gEfiCallerBaseName, __FUNCTION__, Status)); - goto CloseEvent; - } - - // - // Set the remaining global variables. For the alignment guarantee on - // mScratchBuffer, we rely on the fact that *mDmaAccess has a size that is an - // integral multiple of RESERVED_MEM_ALIGNMENT. - // - ASSERT (sizeof *mDmaAccess % RESERVED_MEM_ALIGNMENT == 0); - mScratchBuffer = mDmaAccess + 1; - mScratchBufferSize = ScratchBufferSize; - mCallback = Callback; - - // - // Kick the event; EFI_S3_SAVE_STATE_PROTOCOL could be available already. - // - Status = gBS->SignalEvent (mS3SaveStateInstalledEvent); - if (EFI_ERROR (Status)) { - DEBUG ((DEBUG_ERROR, "%a: %a: SignalEvent(): %r\n", gEfiCallerBaseName, - __FUNCTION__, Status)); - goto NullGlobals; - } - - return RETURN_SUCCESS; - -NullGlobals: - mScratchBuffer = NULL; - mScratchBufferSize = 0; - mCallback = NULL; - -CloseEvent: - gBS->CloseEvent (mS3SaveStateInstalledEvent); - mS3SaveStateInstalledEvent = NULL; - -FreeDmaAccess: - FreePool (mDmaAccess); - mDmaAccess = NULL; - - return (RETURN_STATUS)Status; -} - - -/** - Produce ACPI S3 Boot Script opcodes that (optionally) select an fw_cfg item, - and transfer data to it. - - The opcodes produced by QemuFwCfgS3ScriptWriteBytes() will first restore - NumberOfBytes bytes in ScratchBuffer in-place, in reserved memory, then write - them to fw_cfg using DMA. - - If the operation fails during S3 resume, the boot script will hang. - - This function may only be called from the client module's - FW_CFG_BOOT_SCRIPT_CALLBACK_FUNCTION, which was passed to - QemuFwCfgS3CallWhenBootScriptReady() as Callback. - - @param[in] FirmwareConfigItem The UINT16 selector key of the firmware config - item to write, expressed as INT32. If - FirmwareConfigItem is -1, no selection is - made, the write will occur to the currently - selected item, at its currently selected - offset. Otherwise, the specified item will be - selected, and the write will occur at offset - 0. - - @param[in] NumberOfBytes Size of the data to restore in ScratchBuffer, - and to write from ScratchBuffer, during S3 - resume. NumberOfBytes must not exceed - ScratchBufferSize, which was passed to - QemuFwCfgS3CallWhenBootScriptReady(). - - @retval RETURN_SUCCESS The opcodes were appended to the ACPI S3 - Boot Script successfully. There is no way - to undo this action. - - @retval RETURN_INVALID_PARAMETER FirmwareConfigItem is invalid. - - @retval RETURN_BAD_BUFFER_SIZE NumberOfBytes is larger than - ScratchBufferSize. - - @return Error codes from underlying functions. -**/ -RETURN_STATUS -EFIAPI -QemuFwCfgS3ScriptWriteBytes ( - IN INT32 FirmwareConfigItem, - IN UINTN NumberOfBytes - ) -{ - UINTN Count; - EFI_STATUS Status; - UINT64 AccessAddress; - UINT32 ControlPollData; - UINT32 ControlPollMask; - - ASSERT (mDmaAccess != NULL); - ASSERT (mS3SaveState != NULL); - - if (FirmwareConfigItem < -1 || FirmwareConfigItem > MAX_UINT16) { - return RETURN_INVALID_PARAMETER; - } - if (NumberOfBytes > mScratchBufferSize) { - return RETURN_BAD_BUFFER_SIZE; - } - - // - // Set up a write[+select] fw_cfg DMA command. - // - mDmaAccess->Control = FW_CFG_DMA_CTL_WRITE; - if (FirmwareConfigItem != -1) { - mDmaAccess->Control |= FW_CFG_DMA_CTL_SELECT; - mDmaAccess->Control |= (UINT32)FirmwareConfigItem << 16; - } - mDmaAccess->Control = SwapBytes32 (mDmaAccess->Control); - - // - // We ensured the following constraint via mScratchBufferSize in - // QemuFwCfgS3CallWhenBootScriptReady(). - // - ASSERT (NumberOfBytes <= MAX_UINT32); - mDmaAccess->Length = SwapBytes32 ((UINT32)NumberOfBytes); - - mDmaAccess->Address = SwapBytes64 ((UINTN)mScratchBuffer); - - // - // Copy mDmaAccess and NumberOfBytes bytes from mScratchBuffer into the boot - // script. When executed at S3 resume, this opcode will restore all of them - // in-place. - // - Count = (UINTN)mScratchBuffer + NumberOfBytes - (UINTN)mDmaAccess; - Status = mS3SaveState->Write ( - mS3SaveState, // This - EFI_BOOT_SCRIPT_MEM_WRITE_OPCODE, // OpCode - EfiBootScriptWidthUint8, // Width - (UINT64)(UINTN)mDmaAccess, // Address - Count, // Count - (VOID *)mDmaAccess // Buffer - ); - if (EFI_ERROR (Status)) { - DEBUG ((DEBUG_ERROR, "%a: %a: EFI_BOOT_SCRIPT_MEM_WRITE_OPCODE: %r\n", - gEfiCallerBaseName, __FUNCTION__, Status)); - return (RETURN_STATUS)Status; - } - - // - // Append an opcode that will write the address of the fw_cfg DMA command to - // the fw_cfg DMA address register, which consists of two 32-bit IO ports. - // The second (highest address, least significant) write will start the - // transfer. - // - AccessAddress = SwapBytes64 ((UINTN)mDmaAccess); - Status = mS3SaveState->Write ( - mS3SaveState, // This - EFI_BOOT_SCRIPT_IO_WRITE_OPCODE, // OpCode - EfiBootScriptWidthUint32, // Width - (UINT64)FW_CFG_IO_DMA_ADDRESS, // Address - (UINTN)2, // Count - (VOID *)&AccessAddress // Buffer - ); - if (EFI_ERROR (Status)) { - DEBUG ((DEBUG_ERROR, "%a: %a: EFI_BOOT_SCRIPT_IO_WRITE_OPCODE: %r\n", - gEfiCallerBaseName, __FUNCTION__, Status)); - return (RETURN_STATUS)Status; - } - - // - // The following opcode will wait until the Control word reads as zero - // (transfer complete). As timeout we use MAX_UINT64 * 100ns, which is - // approximately 58494 years. - // - ControlPollData = 0; - ControlPollMask = MAX_UINT32; - Status = mS3SaveState->Write ( - mS3SaveState, // This - EFI_BOOT_SCRIPT_MEM_POLL_OPCODE, // OpCode - EfiBootScriptWidthUint32, // Width - (UINT64)(UINTN)&mDmaAccess->Control, // Address - (VOID *)&ControlPollData, // Data - (VOID *)&ControlPollMask, // DataMask - MAX_UINT64 // Delay - ); - if (EFI_ERROR (Status)) { - DEBUG ((DEBUG_ERROR, "%a: %a: EFI_BOOT_SCRIPT_MEM_POLL_OPCODE: %r\n", - gEfiCallerBaseName, __FUNCTION__, Status)); - return (RETURN_STATUS)Status; - } - - return RETURN_SUCCESS; -} - - -/** - Produce ACPI S3 Boot Script opcodes that (optionally) select an fw_cfg item, - and transfer data from it. - - The opcodes produced by QemuFwCfgS3ScriptReadBytes() will read NumberOfBytes - bytes from fw_cfg using DMA, storing the result in ScratchBuffer, in reserved - memory. - - If the operation fails during S3 resume, the boot script will hang. - - This function may only be called from the client module's - FW_CFG_BOOT_SCRIPT_CALLBACK_FUNCTION, which was passed to - QemuFwCfgS3CallWhenBootScriptReady() as Callback. - - @param[in] FirmwareConfigItem The UINT16 selector key of the firmware config - item to read, expressed as INT32. If - FirmwareConfigItem is -1, no selection is - made, the read will occur from the currently - selected item, from its currently selected - offset. Otherwise, the specified item will be - selected, and the read will occur from offset - 0. - - @param[in] NumberOfBytes Size of the data to read during S3 resume. - NumberOfBytes must not exceed - ScratchBufferSize, which was passed to - QemuFwCfgS3CallWhenBootScriptReady(). - - @retval RETURN_SUCCESS The opcodes were appended to the ACPI S3 - Boot Script successfully. There is no way - to undo this action. - - @retval RETURN_INVALID_PARAMETER FirmwareConfigItem is invalid. - - @retval RETURN_BAD_BUFFER_SIZE NumberOfBytes is larger than - ScratchBufferSize. - - @return Error codes from underlying functions. -**/ -RETURN_STATUS -EFIAPI -QemuFwCfgS3ScriptReadBytes ( - IN INT32 FirmwareConfigItem, - IN UINTN NumberOfBytes - ) -{ - EFI_STATUS Status; - UINT64 AccessAddress; - UINT32 ControlPollData; - UINT32 ControlPollMask; - - ASSERT (mDmaAccess != NULL); - ASSERT (mS3SaveState != NULL); - - if (FirmwareConfigItem < -1 || FirmwareConfigItem > MAX_UINT16) { - return RETURN_INVALID_PARAMETER; - } - if (NumberOfBytes > mScratchBufferSize) { - return RETURN_BAD_BUFFER_SIZE; - } - - // - // Set up a read[+select] fw_cfg DMA command. - // - mDmaAccess->Control = FW_CFG_DMA_CTL_READ; - if (FirmwareConfigItem != -1) { - mDmaAccess->Control |= FW_CFG_DMA_CTL_SELECT; - mDmaAccess->Control |= (UINT32)FirmwareConfigItem << 16; - } - mDmaAccess->Control = SwapBytes32 (mDmaAccess->Control); - - // - // We ensured the following constraint via mScratchBufferSize in - // QemuFwCfgS3CallWhenBootScriptReady(). - // - ASSERT (NumberOfBytes <= MAX_UINT32); - mDmaAccess->Length = SwapBytes32 ((UINT32)NumberOfBytes); - - mDmaAccess->Address = SwapBytes64 ((UINTN)mScratchBuffer); - - // - // Copy mDmaAccess into the boot script. When executed at S3 resume, this - // opcode will restore it in-place. - // - Status = mS3SaveState->Write ( - mS3SaveState, // This - EFI_BOOT_SCRIPT_MEM_WRITE_OPCODE, // OpCode - EfiBootScriptWidthUint8, // Width - (UINT64)(UINTN)mDmaAccess, // Address - sizeof *mDmaAccess, // Count - (VOID *)mDmaAccess // Buffer - ); - if (EFI_ERROR (Status)) { - DEBUG ((DEBUG_ERROR, "%a: %a: EFI_BOOT_SCRIPT_MEM_WRITE_OPCODE: %r\n", - gEfiCallerBaseName, __FUNCTION__, Status)); - return (RETURN_STATUS)Status; - } - - // - // Append an opcode that will write the address of the fw_cfg DMA command to - // the fw_cfg DMA address register, which consists of two 32-bit IO ports. - // The second (highest address, least significant) write will start the - // transfer. - // - AccessAddress = SwapBytes64 ((UINTN)mDmaAccess); - Status = mS3SaveState->Write ( - mS3SaveState, // This - EFI_BOOT_SCRIPT_IO_WRITE_OPCODE, // OpCode - EfiBootScriptWidthUint32, // Width - (UINT64)FW_CFG_IO_DMA_ADDRESS, // Address - (UINTN)2, // Count - (VOID *)&AccessAddress // Buffer - ); - if (EFI_ERROR (Status)) { - DEBUG ((DEBUG_ERROR, "%a: %a: EFI_BOOT_SCRIPT_IO_WRITE_OPCODE: %r\n", - gEfiCallerBaseName, __FUNCTION__, Status)); - return (RETURN_STATUS)Status; - } - - // - // The following opcode will wait until the Control word reads as zero - // (transfer complete). As timeout we use MAX_UINT64 * 100ns, which is - // approximately 58494 years. - // - ControlPollData = 0; - ControlPollMask = MAX_UINT32; - Status = mS3SaveState->Write ( - mS3SaveState, // This - EFI_BOOT_SCRIPT_MEM_POLL_OPCODE, // OpCode - EfiBootScriptWidthUint32, // Width - (UINT64)(UINTN)&mDmaAccess->Control, // Address - (VOID *)&ControlPollData, // Data - (VOID *)&ControlPollMask, // DataMask - MAX_UINT64 // Delay - ); - if (EFI_ERROR (Status)) { - DEBUG ((DEBUG_ERROR, "%a: %a: EFI_BOOT_SCRIPT_MEM_POLL_OPCODE: %r\n", - gEfiCallerBaseName, __FUNCTION__, Status)); - return (RETURN_STATUS)Status; - } - - return RETURN_SUCCESS; -} - - -/** - Produce ACPI S3 Boot Script opcodes that (optionally) select an fw_cfg item, - and increase its offset. - - If the operation fails during S3 resume, the boot script will hang. - - This function may only be called from the client module's - FW_CFG_BOOT_SCRIPT_CALLBACK_FUNCTION, which was passed to - QemuFwCfgS3CallWhenBootScriptReady() as Callback. - - @param[in] FirmwareConfigItem The UINT16 selector key of the firmware config - item to advance the offset of, expressed as - INT32. If FirmwareConfigItem is -1, no - selection is made, and the offset for the - currently selected item is increased. - Otherwise, the specified item will be - selected, and the offset increment will occur - from offset 0. - - @param[in] NumberOfBytes The number of bytes to skip in the subject - fw_cfg item. - - @retval RETURN_SUCCESS The opcodes were appended to the ACPI S3 - Boot Script successfully. There is no way - to undo this action. - - @retval RETURN_INVALID_PARAMETER FirmwareConfigItem is invalid. - - @retval RETURN_BAD_BUFFER_SIZE NumberOfBytes is too large. - - @return Error codes from underlying functions. -**/ -RETURN_STATUS -EFIAPI -QemuFwCfgS3ScriptSkipBytes ( - IN INT32 FirmwareConfigItem, - IN UINTN NumberOfBytes - ) -{ - EFI_STATUS Status; - UINT64 AccessAddress; - UINT32 ControlPollData; - UINT32 ControlPollMask; - - ASSERT (mDmaAccess != NULL); - ASSERT (mS3SaveState != NULL); - - if (FirmwareConfigItem < -1 || FirmwareConfigItem > MAX_UINT16) { - return RETURN_INVALID_PARAMETER; - } - if (NumberOfBytes > MAX_UINT32) { - return RETURN_BAD_BUFFER_SIZE; - } - - // - // Set up a skip[+select] fw_cfg DMA command. - // - mDmaAccess->Control = FW_CFG_DMA_CTL_SKIP; - if (FirmwareConfigItem != -1) { - mDmaAccess->Control |= FW_CFG_DMA_CTL_SELECT; - mDmaAccess->Control |= (UINT32)FirmwareConfigItem << 16; - } - mDmaAccess->Control = SwapBytes32 (mDmaAccess->Control); - - mDmaAccess->Length = SwapBytes32 ((UINT32)NumberOfBytes); - mDmaAccess->Address = 0; - - // - // Copy mDmaAccess into the boot script. When executed at S3 resume, this - // opcode will restore it in-place. - // - Status = mS3SaveState->Write ( - mS3SaveState, // This - EFI_BOOT_SCRIPT_MEM_WRITE_OPCODE, // OpCode - EfiBootScriptWidthUint8, // Width - (UINT64)(UINTN)mDmaAccess, // Address - sizeof *mDmaAccess, // Count - (VOID *)mDmaAccess // Buffer - ); - if (EFI_ERROR (Status)) { - DEBUG ((DEBUG_ERROR, "%a: %a: EFI_BOOT_SCRIPT_MEM_WRITE_OPCODE: %r\n", - gEfiCallerBaseName, __FUNCTION__, Status)); - return (RETURN_STATUS)Status; - } - - // - // Append an opcode that will write the address of the fw_cfg DMA command to - // the fw_cfg DMA address register, which consists of two 32-bit IO ports. - // The second (highest address, least significant) write will start the - // transfer. - // - AccessAddress = SwapBytes64 ((UINTN)mDmaAccess); - Status = mS3SaveState->Write ( - mS3SaveState, // This - EFI_BOOT_SCRIPT_IO_WRITE_OPCODE, // OpCode - EfiBootScriptWidthUint32, // Width - (UINT64)FW_CFG_IO_DMA_ADDRESS, // Address - (UINTN)2, // Count - (VOID *)&AccessAddress // Buffer - ); - if (EFI_ERROR (Status)) { - DEBUG ((DEBUG_ERROR, "%a: %a: EFI_BOOT_SCRIPT_IO_WRITE_OPCODE: %r\n", - gEfiCallerBaseName, __FUNCTION__, Status)); - return (RETURN_STATUS)Status; - } - - // - // The following opcode will wait until the Control word reads as zero - // (transfer complete). As timeout we use MAX_UINT64 * 100ns, which is - // approximately 58494 years. - // - ControlPollData = 0; - ControlPollMask = MAX_UINT32; - Status = mS3SaveState->Write ( - mS3SaveState, // This - EFI_BOOT_SCRIPT_MEM_POLL_OPCODE, // OpCode - EfiBootScriptWidthUint32, // Width - (UINT64)(UINTN)&mDmaAccess->Control, // Address - (VOID *)&ControlPollData, // Data - (VOID *)&ControlPollMask, // DataMask - MAX_UINT64 // Delay - ); - if (EFI_ERROR (Status)) { - DEBUG ((DEBUG_ERROR, "%a: %a: EFI_BOOT_SCRIPT_MEM_POLL_OPCODE: %r\n", - gEfiCallerBaseName, __FUNCTION__, Status)); - return (RETURN_STATUS)Status; - } - - return RETURN_SUCCESS; -} - - -/** - Produce ACPI S3 Boot Script opcodes that check a value in ScratchBuffer. - - If the check fails during S3 resume, the boot script will hang. - - This function may only be called from the client module's - FW_CFG_BOOT_SCRIPT_CALLBACK_FUNCTION, which was passed to - QemuFwCfgS3CallWhenBootScriptReady() as Callback. - - @param[in] ScratchData Pointer to the UINT8, UINT16, UINT32 or UINT64 field - in ScratchBuffer that should be checked. The caller - is responsible for populating the field during S3 - resume, by calling QemuFwCfgS3ScriptReadBytes() ahead - of QemuFwCfgS3ScriptCheckValue(). - - ScratchData must point into ScratchBuffer, which was - allocated, and passed to Callback(), by - QemuFwCfgS3CallWhenBootScriptReady(). - - ScratchData must be aligned at ValueSize bytes. - - @param[in] ValueSize One of 1, 2, 4 or 8, specifying the size of the field - to check. - - @param[in] ValueMask The value read from ScratchData is binarily AND-ed - with ValueMask, and the result is compared against - Value. If the masked data equals Value, the check - passes, and the boot script can proceed. Otherwise, - the check fails, and the boot script hangs. - - @param[in] Value Refer to ValueMask. - - @retval RETURN_SUCCESS The opcodes were appended to the ACPI S3 - Boot Script successfully. There is no way - to undo this action. - - @retval RETURN_INVALID_PARAMETER ValueSize is invalid. - - @retval RETURN_INVALID_PARAMETER ValueMask or Value cannot be represented in - ValueSize bytes. - - @retval RETURN_INVALID_PARAMETER ScratchData is not aligned at ValueSize - bytes. - - @retval RETURN_BAD_BUFFER_SIZE The ValueSize bytes at ScratchData aren't - wholly contained in the ScratchBufferSize - bytes at ScratchBuffer. - - @return Error codes from underlying functions. -**/ -RETURN_STATUS -EFIAPI -QemuFwCfgS3ScriptCheckValue ( - IN VOID *ScratchData, - IN UINT8 ValueSize, - IN UINT64 ValueMask, - IN UINT64 Value - ) -{ - EFI_BOOT_SCRIPT_WIDTH Width; - EFI_STATUS Status; - - ASSERT (mS3SaveState != NULL); - - switch (ValueSize) { - case 1: - Width = EfiBootScriptWidthUint8; - break; - - case 2: - Width = EfiBootScriptWidthUint16; - break; - - case 4: - Width = EfiBootScriptWidthUint32; - break; - - case 8: - Width = EfiBootScriptWidthUint64; - break; - - default: - return RETURN_INVALID_PARAMETER; - } - - if (ValueSize < 8 && - (RShiftU64 (ValueMask, ValueSize * 8) > 0 || - RShiftU64 (Value, ValueSize * 8) > 0)) { - return RETURN_INVALID_PARAMETER; - } - - if ((UINTN)ScratchData % ValueSize > 0) { - return RETURN_INVALID_PARAMETER; - } - - if (((UINTN)ScratchData < (UINTN)mScratchBuffer) || - ((UINTN)ScratchData > MAX_UINTN - ValueSize) || - ((UINTN)ScratchData + ValueSize > - (UINTN)mScratchBuffer + mScratchBufferSize)) { - return RETURN_BAD_BUFFER_SIZE; - } - - // - // The following opcode will wait "until" (*ScratchData & ValueMask) reads as - // Value, considering the least significant ValueSize bytes. As timeout we - // use MAX_UINT64 * 100ns, which is approximately 58494 years. - // - Status = mS3SaveState->Write ( - mS3SaveState, // This - EFI_BOOT_SCRIPT_MEM_POLL_OPCODE, // OpCode - Width, // Width - (UINT64)(UINTN)ScratchData, // Address - (VOID *)&Value, // Data - (VOID *)&ValueMask, // DataMask - MAX_UINT64 // Delay - ); - if (EFI_ERROR (Status)) { - DEBUG ((DEBUG_ERROR, "%a: %a: EFI_BOOT_SCRIPT_MEM_POLL_OPCODE: %r\n", - gEfiCallerBaseName, __FUNCTION__, Status)); - return (RETURN_STATUS)Status; - } - - return RETURN_SUCCESS; -} diff --git a/OvmfPkg/Library/QemuFwCfgS3Lib/QemuFwCfgS3Pei.c b/OvmfPkg/Library/QemuFwCfgS3Lib/QemuFwCfgS3Pei.c deleted file mode 100644 index 031e9f2f70..0000000000 --- a/OvmfPkg/Library/QemuFwCfgS3Lib/QemuFwCfgS3Pei.c +++ /dev/null @@ -1,86 +0,0 @@ -/** @file - Limited functionality QemuFwCfgS3Lib instance, for PEI phase modules. - - QemuFwCfgS3Enabled() queries S3 enablement via fw_cfg. Other library APIs - will report lack of support. - - Copyright (C) 2017, 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 - -/** - Install the client module's FW_CFG_BOOT_SCRIPT_CALLBACK_FUNCTION callback for - when the production of ACPI S3 Boot Script opcodes becomes possible. - - Take ownership of the client-provided Context, and pass it to the callback - function, when the latter is invoked. - - Allocate scratch space for those ACPI S3 Boot Script opcodes to work upon - that the client will produce in the callback function. - - @param[in] Callback FW_CFG_BOOT_SCRIPT_CALLBACK_FUNCTION to invoke - when the production of ACPI S3 Boot Script - opcodes becomes possible. Callback() may be - called immediately from - QemuFwCfgS3CallWhenBootScriptReady(). - - @param[in,out] Context Client-provided data structure for the - Callback() callback function to consume. - - If Context points to dynamically allocated - memory, then Callback() must release it. - - If Context points to dynamically allocated - memory, and - QemuFwCfgS3CallWhenBootScriptReady() returns - successfully, then the caller of - QemuFwCfgS3CallWhenBootScriptReady() must - neither dereference nor even evaluate Context - any longer, as ownership of the referenced area - has been transferred to Callback(). - - @param[in] ScratchBufferSize The size of the scratch buffer that will hold, - in reserved memory, all client data read, - written, and checked by the ACPI S3 Boot Script - opcodes produced by Callback(). - - @retval RETURN_UNSUPPORTED The library instance does not support this - function. - - @retval RETURN_NOT_FOUND The fw_cfg DMA interface to QEMU is - unavailable. - - @retval RETURN_BAD_BUFFER_SIZE ScratchBufferSize is too large. - - @retval RETURN_OUT_OF_RESOURCES Memory allocation failed. - - @retval RETURN_SUCCESS Callback() has been installed, and the - ownership of Context has been transferred. - Reserved memory has been allocated for the - scratch buffer. - - A successful invocation of - QemuFwCfgS3CallWhenBootScriptReady() cannot - be rolled back. - - @return Error codes from underlying functions. -**/ -RETURN_STATUS -EFIAPI -QemuFwCfgS3CallWhenBootScriptReady ( - IN FW_CFG_BOOT_SCRIPT_CALLBACK_FUNCTION *Callback, - IN OUT VOID *Context, OPTIONAL - IN UINTN ScratchBufferSize - ) -{ - return RETURN_UNSUPPORTED; -} diff --git a/OvmfPkg/Library/QemuFwCfgS3Lib/QemuFwCfgS3PeiDxe.c b/OvmfPkg/Library/QemuFwCfgS3Lib/QemuFwCfgS3PeiDxe.c deleted file mode 100644 index f87d6b8227..0000000000 --- a/OvmfPkg/Library/QemuFwCfgS3Lib/QemuFwCfgS3PeiDxe.c +++ /dev/null @@ -1,48 +0,0 @@ -/** @file - Shared code for the PEI fw_cfg and DXE fw_cfg instances of the QemuFwCfgS3Lib - class. - - Copyright (C) 2017, 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 -#include - -/** - Determine if S3 support is explicitly enabled. - - @retval TRUE If S3 support is explicitly enabled. Other functions in this - library may be called (subject to their individual - restrictions). - - FALSE Otherwise. This includes unavailability of the firmware - configuration interface. No other function in this library - must be called. -**/ -BOOLEAN -EFIAPI -QemuFwCfgS3Enabled ( - VOID - ) -{ - RETURN_STATUS Status; - FIRMWARE_CONFIG_ITEM FwCfgItem; - UINTN FwCfgSize; - UINT8 SystemStates[6]; - - Status = QemuFwCfgFindFile ("etc/system-states", &FwCfgItem, &FwCfgSize); - if (Status != RETURN_SUCCESS || FwCfgSize != sizeof SystemStates) { - return FALSE; - } - QemuFwCfgSelectItem (FwCfgItem); - QemuFwCfgReadBytes (sizeof SystemStates, SystemStates); - return (BOOLEAN) (SystemStates[3] & BIT7); -} diff --git a/OvmfPkg/Library/ResetSystemLib/ResetSystemLib.c b/OvmfPkg/Library/ResetSystemLib/ResetSystemLib.c deleted file mode 100644 index cc75d046a8..0000000000 --- a/OvmfPkg/Library/ResetSystemLib/ResetSystemLib.c +++ /dev/null @@ -1,148 +0,0 @@ -/** @file - Reset System Library functions for OVMF - - Copyright (c) 2006 - 2016, Intel Corporation. All rights reserved.
- This program and the accompanying materials - are licensed and made available under the terms and conditions of the BSD License - which accompanies this distribution. The full text of the license may be found at - http://opensource.org/licenses/bsd-license.php - - THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, - WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. - -**/ - -#include - -#include -#include -#include -#include -#include - -#include - -VOID -AcpiPmControl ( - UINTN SuspendType - ) -{ - UINT16 AcpiPmBaseAddress; - UINT16 HostBridgeDevId; - - ASSERT (SuspendType < 6); - - AcpiPmBaseAddress = 0; - HostBridgeDevId = PciRead16 (OVMF_HOSTBRIDGE_DID); - switch (HostBridgeDevId) { - case INTEL_82441_DEVICE_ID: - AcpiPmBaseAddress = PIIX4_PMBA_VALUE; - break; - case INTEL_Q35_MCH_DEVICE_ID: - AcpiPmBaseAddress = ICH9_PMBASE_VALUE; - break; - default: - ASSERT (FALSE); - CpuDeadLoop (); - } - - IoBitFieldWrite16 (AcpiPmBaseAddress + 4, 10, 13, (UINT16) SuspendType); - IoOr16 (AcpiPmBaseAddress + 4, BIT13); - CpuDeadLoop (); -} - -/** - Calling this function causes a system-wide reset. This sets - all circuitry within the system to its initial state. This type of reset - is asynchronous to system operation and operates without regard to - cycle boundaries. - - System reset should not return, if it returns, it means the system does - not support cold reset. -**/ -VOID -EFIAPI -ResetCold ( - VOID - ) -{ - IoWrite8 (0xCF9, BIT2 | BIT1); // 1st choice: PIIX3 RCR, RCPU|SRST - MicroSecondDelay (50); - - IoWrite8 (0x64, 0xfe); // 2nd choice: keyboard controller - CpuDeadLoop (); -} - -/** - Calling this function causes a system-wide initialization. The processors - are set to their initial state, and pending cycles are not corrupted. - - System reset should not return, if it returns, it means the system does - not support warm reset. -**/ -VOID -EFIAPI -ResetWarm ( - VOID - ) -{ - IoWrite8 (0x64, 0xfe); - CpuDeadLoop (); -} - -/** - Calling this function causes the system to enter a power state equivalent - to the ACPI G2/S5 or G3 states. - - System shutdown should not return, if it returns, it means the system does - not support shut down reset. -**/ -VOID -EFIAPI -ResetShutdown ( - VOID - ) -{ - AcpiPmControl (0); - ASSERT (FALSE); -} - - -/** - Calling this function causes the system to enter a power state for capsule - update. - - Reset update should not return, if it returns, it means the system does - not support capsule update. - -**/ -VOID -EFIAPI -EnterS3WithImmediateWake ( - VOID - ) -{ - AcpiPmControl (1); - ASSERT (FALSE); -} - -/** - This function causes a systemwide reset. The exact type of the reset is - defined by the EFI_GUID that follows the Null-terminated Unicode string passed - into ResetData. If the platform does not recognize the EFI_GUID in ResetData - the platform must pick a supported reset type to perform.The platform may - optionally log the parameters from any non-normal reset that occurs. - - @param[in] DataSize The size, in bytes, of ResetData. - @param[in] ResetData The data buffer starts with a Null-terminated string, - followed by the EFI_GUID. -**/ -VOID -EFIAPI -ResetPlatformSpecific ( - IN UINTN DataSize, - IN VOID *ResetData - ) -{ - ResetCold (); -} diff --git a/OvmfPkg/Library/ResetSystemLib/ResetSystemLib.inf b/OvmfPkg/Library/ResetSystemLib/ResetSystemLib.inf deleted file mode 100644 index ecd462ba7d..0000000000 --- a/OvmfPkg/Library/ResetSystemLib/ResetSystemLib.inf +++ /dev/null @@ -1,39 +0,0 @@ -## @file -# Library instance for ResetSystem library class for OVMF -# -# Copyright (c) 2006 - 2013, Intel Corporation. All rights reserved.
-# This program and the accompanying materials -# are licensed and made available under the terms and conditions of the BSD License -# which accompanies this distribution. The full text of the license may be found at -# http://opensource.org/licenses/bsd-license.php -# -# THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, -# WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. -# -## - -[Defines] - INF_VERSION = 0x00010005 - BASE_NAME = ResetSystemLib - FILE_GUID = 66564872-21d4-4d2a-a68b-1e844f980820 - MODULE_TYPE = BASE - VERSION_STRING = 1.0 - LIBRARY_CLASS = ResetSystemLib - -# -# The following information is for reference only and not required by the build tools. -# -# VALID_ARCHITECTURES = IA32 X64 IPF -# - -[Sources] - ResetSystemLib.c - -[Packages] - MdePkg/MdePkg.dec - OvmfPkg/OvmfPkg.dec - -[LibraryClasses] - DebugLib - IoLib - TimerLib diff --git a/OvmfPkg/Library/SerializeVariablesLib/SerializeVariablesLib.c b/OvmfPkg/Library/SerializeVariablesLib/SerializeVariablesLib.c deleted file mode 100644 index a1a3d188f2..0000000000 --- a/OvmfPkg/Library/SerializeVariablesLib/SerializeVariablesLib.c +++ /dev/null @@ -1,875 +0,0 @@ -/** @file - Serialize Variables Library implementation - - Copyright (c) 2004 - 2011, Intel Corporation. All rights reserved.
- This program and the accompanying materials - are licensed and made available under the terms and conditions of the BSD License - which accompanies this distribution. The full text of the license may be found at - http://opensource.org/licenses/bsd-license.php - - THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, - WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. - -**/ - -#include "SerializeVariablesLib.h" - -/** - Serialization format: - - The SerializeVariablesLib interface does not specify a format - for the serialization of the variable data. This library uses - a packed array of a non-uniformly sized data structure elements. - - Each variable is stored (packed) as: - UINT32 VendorNameSize; // Name size in bytes - CHAR16 VendorName[?]; // The variable unicode name including the - // null terminating character. - EFI_GUID VendorGuid; // The variable GUID - UINT32 DataSize; // The size of variable data in bytes - UINT8 Data[?]; // The variable data - -**/ - - -/** - Unpacks the next variable from the buffer - - @param[in] Buffer - Buffer pointing to the next variable instance - On subsequent calls, the pointer should be incremented - by the returned SizeUsed value. - @param[in] MaxSize - Max allowable size for the variable data - On subsequent calls, this should be decremented - by the returned SizeUsed value. - @param[out] Name - Variable name string (address in Buffer) - @param[out] NameSize - Size of Name in bytes - @param[out] Guid - GUID of variable (address in Buffer) - @param[out] Attributes - Attributes of variable - @param[out] Data - Buffer containing Data for variable (address in Buffer) - @param[out] DataSize - Size of Data in bytes - @param[out] SizeUsed - Total size used for this variable instance in Buffer - - @return EFI_STATUS based on the success or failure of the operation - -**/ -STATIC -EFI_STATUS -UnpackVariableFromBuffer ( - IN VOID *Buffer, - IN UINTN MaxSize, - OUT CHAR16 **Name, - OUT UINT32 *NameSize, - OUT EFI_GUID **Guid, - OUT UINT32 *Attributes, - OUT UINT32 *DataSize, - OUT VOID **Data, - OUT UINTN *SizeUsed - ) -{ - UINT8 *BytePtr; - UINTN Offset; - - BytePtr = (UINT8*)Buffer; - Offset = 0; - - *NameSize = *(UINT32*) (BytePtr + Offset); - Offset = Offset + sizeof (UINT32); - - if (Offset > MaxSize) { - return EFI_INVALID_PARAMETER; - } - - *Name = (CHAR16*) (BytePtr + Offset); - Offset = Offset + *(UINT32*)BytePtr; - if (Offset > MaxSize) { - return EFI_INVALID_PARAMETER; - } - - *Guid = (EFI_GUID*) (BytePtr + Offset); - Offset = Offset + sizeof (EFI_GUID); - if (Offset > MaxSize) { - return EFI_INVALID_PARAMETER; - } - - *Attributes = *(UINT32*) (BytePtr + Offset); - Offset = Offset + sizeof (UINT32); - if (Offset > MaxSize) { - return EFI_INVALID_PARAMETER; - } - - *DataSize = *(UINT32*) (BytePtr + Offset); - Offset = Offset + sizeof (UINT32); - if (Offset > MaxSize) { - return EFI_INVALID_PARAMETER; - } - - *Data = (VOID*) (BytePtr + Offset); - Offset = Offset + *DataSize; - if (Offset > MaxSize) { - return EFI_INVALID_PARAMETER; - } - - *SizeUsed = Offset; - - return EFI_SUCCESS; -} - - -/** - Iterates through the variables in the buffer, and calls a callback - function for each variable found. - - @param[in] CallbackFunction - Function called for each variable instance - @param[in] Context - Passed to each call of CallbackFunction - @param[in] Buffer - Buffer containing serialized variables - @param[in] MaxSize - Size of Buffer in bytes - - @return EFI_STATUS based on the success or failure of the operation - -**/ -STATIC -EFI_STATUS -IterateVariablesInBuffer ( - IN VARIABLE_SERIALIZATION_ITERATION_CALLBACK CallbackFunction, - IN VOID *CallbackContext, - IN VOID *Buffer, - IN UINTN MaxSize - ) -{ - RETURN_STATUS Status; - UINTN TotalSizeUsed; - UINTN SizeUsed; - - CHAR16 *Name; - UINT32 NameSize; - CHAR16 *AlignedName; - UINT32 AlignedNameMaxSize; - EFI_GUID *Guid; - UINT32 Attributes; - UINT32 DataSize; - VOID *Data; - - SizeUsed = 0; - AlignedName = NULL; - AlignedNameMaxSize = 0; - Name = NULL; - Guid = NULL; - Attributes = 0; - DataSize = 0; - Data = NULL; - - for ( - Status = EFI_SUCCESS, TotalSizeUsed = 0; - !EFI_ERROR (Status) && (TotalSizeUsed < MaxSize); - ) { - Status = UnpackVariableFromBuffer ( - (VOID*) ((UINT8*) Buffer + TotalSizeUsed), - (MaxSize - TotalSizeUsed), - &Name, - &NameSize, - &Guid, - &Attributes, - &DataSize, - &Data, - &SizeUsed - ); - if (EFI_ERROR (Status)) { - return Status; - } - - // - // We copy the name to a separately allocated buffer, - // to be sure it is 16-bit aligned. - // - if (NameSize > AlignedNameMaxSize) { - if (AlignedName != NULL) { - FreePool (AlignedName); - } - AlignedName = AllocatePool (NameSize); - } - if (AlignedName == NULL) { - return EFI_OUT_OF_RESOURCES; - } - CopyMem (AlignedName, Name, NameSize); - - TotalSizeUsed = TotalSizeUsed + SizeUsed; - - // - // Run the callback function - // - Status = (*CallbackFunction) ( - CallbackContext, - AlignedName, - Guid, - Attributes, - DataSize, - Data - ); - - } - - if (AlignedName != NULL) { - FreePool (AlignedName); - } - - // - // Make sure the entire buffer was used, or else return an error - // - if (TotalSizeUsed != MaxSize) { - DEBUG (( - EFI_D_ERROR, - "Deserialize variables error: TotalSizeUsed(%Lu) != MaxSize(%Lu)\n", - (UINT64)TotalSizeUsed, - (UINT64)MaxSize - )); - return EFI_INVALID_PARAMETER; - } - - return EFI_SUCCESS; -} - - -STATIC -RETURN_STATUS -EFIAPI -IterateVariablesCallbackNop ( - IN VOID *Context, - IN CHAR16 *VariableName, - IN EFI_GUID *VendorGuid, - IN UINT32 Attributes, - IN UINTN DataSize, - IN VOID *Data - ) -{ - return RETURN_SUCCESS; -} - - -STATIC -RETURN_STATUS -EFIAPI -IterateVariablesCallbackSetInInstance ( - IN VOID *Context, - IN CHAR16 *VariableName, - IN EFI_GUID *VendorGuid, - IN UINT32 Attributes, - IN UINTN DataSize, - IN VOID *Data - ) -{ - EFI_HANDLE Instance; - - Instance = (EFI_HANDLE) Context; - - return SerializeVariablesAddVariable ( - Instance, - VariableName, - VendorGuid, - Attributes, - DataSize, - Data - ); -} - - -STATIC -RETURN_STATUS -EFIAPI -IterateVariablesCallbackSetSystemVariable ( - IN VOID *Context, - IN CHAR16 *VariableName, - IN EFI_GUID *VendorGuid, - IN UINT32 Attributes, - IN UINTN DataSize, - IN VOID *Data - ) -{ - EFI_STATUS Status; - STATIC CONST UINT32 AuthMask = - EFI_VARIABLE_AUTHENTICATED_WRITE_ACCESS | - EFI_VARIABLE_TIME_BASED_AUTHENTICATED_WRITE_ACCESS; - - Status = gRT->SetVariable ( - VariableName, - VendorGuid, - Attributes, - DataSize, - Data - ); - - if (Status == EFI_SECURITY_VIOLATION && (Attributes & AuthMask) != 0) { - DEBUG ((DEBUG_WARN, "%a: setting authenticated variable \"%s\" " - "failed with EFI_SECURITY_VIOLATION, ignoring\n", __FUNCTION__, - VariableName)); - Status = EFI_SUCCESS; - } else if (Status == EFI_WRITE_PROTECTED) { - DEBUG ((DEBUG_WARN, "%a: setting ReadOnly variable \"%s\" " - "failed with EFI_WRITE_PROTECTED, ignoring\n", __FUNCTION__, - VariableName)); - Status = EFI_SUCCESS; - } - return Status; -} - - -STATIC -RETURN_STATUS -EnsureExtraBufferSpace ( - IN SV_INSTANCE *Instance, - IN UINTN Size - ) -{ - VOID *NewBuffer; - UINTN NewSize; - - NewSize = Instance->DataSize + Size; - if (NewSize <= Instance->BufferSize) { - return RETURN_SUCCESS; - } - - // - // Double the required size to lessen the need to re-allocate in the future - // - NewSize = 2 * NewSize; - - NewBuffer = AllocatePool (NewSize); - if (NewBuffer == NULL) { - return RETURN_OUT_OF_RESOURCES; - } - - if (Instance->BufferPtr != NULL) { - CopyMem (NewBuffer, Instance->BufferPtr, Instance->DataSize); - FreePool (Instance->BufferPtr); - } - - Instance->BufferPtr = NewBuffer; - Instance->BufferSize = NewSize; - - return RETURN_SUCCESS; -} - - -STATIC -VOID -AppendToBuffer ( - IN SV_INSTANCE *Instance, - IN VOID *Data, - IN UINTN Size - ) -{ - UINTN NewSize; - - ASSERT (Instance != NULL); - ASSERT (Data != NULL); - - NewSize = Instance->DataSize + Size; - ASSERT ((Instance->DataSize + Size) <= Instance->BufferSize); - - CopyMem ( - (VOID*) (((UINT8*) (Instance->BufferPtr)) + Instance->DataSize), - Data, - Size - ); - - Instance->DataSize = NewSize; -} - - -/** - Creates a new variable serialization instance - - @param[out] Handle - Handle for a variable serialization instance - - @retval RETURN_SUCCESS - The variable serialization instance was - successfully created. - @retval RETURN_OUT_OF_RESOURCES - There we not enough resources to - create the variable serialization instance. - -**/ -RETURN_STATUS -EFIAPI -SerializeVariablesNewInstance ( - OUT EFI_HANDLE *Handle - ) -{ - SV_INSTANCE *New; - - New = AllocateZeroPool (sizeof (*New)); - if (New == NULL) { - return RETURN_OUT_OF_RESOURCES; - } - - New->Signature = SV_SIGNATURE; - - *Handle = (EFI_HANDLE) New; - return RETURN_SUCCESS; -} - - -/** - Free memory associated with a variable serialization instance - - @param[in] Handle - Handle for a variable serialization instance - - @retval RETURN_SUCCESS - The variable serialization instance was - successfully freed. - @retval RETURN_INVALID_PARAMETER - Handle was not a valid - variable serialization instance. - -**/ -RETURN_STATUS -EFIAPI -SerializeVariablesFreeInstance ( - IN EFI_HANDLE Handle - ) -{ - SV_INSTANCE *Instance; - - Instance = SV_FROM_HANDLE (Handle); - - if (Instance->Signature != SV_SIGNATURE) { - return RETURN_INVALID_PARAMETER; - } - - Instance->Signature = 0; - - if (Instance->BufferPtr != NULL) { - FreePool (Instance->BufferPtr); - } - - FreePool (Instance); - - return RETURN_SUCCESS; -} - - -/** - Creates a new variable serialization instance using the given - binary representation of the variables to fill the new instance - - @param[out] Handle - Handle for a variable serialization instance - @param[in] Buffer - A buffer with the serialized representation - of the variables. Must be the same format as produced - by SerializeVariablesToBuffer. - @param[in] Size - This is the size of the binary representation - of the variables. - - @retval RETURN_SUCCESS - The binary representation was successfully - imported into a new variable serialization instance - @retval RETURN_OUT_OF_RESOURCES - There we not enough resources to - create the new variable serialization instance - -**/ -RETURN_STATUS -EFIAPI -SerializeVariablesNewInstanceFromBuffer ( - OUT EFI_HANDLE *Handle, - IN VOID *Buffer, - IN UINTN Size - ) -{ - RETURN_STATUS Status; - - Status = SerializeVariablesNewInstance (Handle); - if (RETURN_ERROR (Status)) { - return Status; - } - - Status = IterateVariablesInBuffer ( - IterateVariablesCallbackNop, - NULL, - Buffer, - Size - ); - if (RETURN_ERROR (Status)) { - SerializeVariablesFreeInstance (*Handle); - return Status; - } - - Status = IterateVariablesInBuffer ( - IterateVariablesCallbackSetInInstance, - (VOID*) *Handle, - Buffer, - Size - ); - if (RETURN_ERROR (Status)) { - SerializeVariablesFreeInstance (*Handle); - return Status; - } - - return Status; -} - - -/** - Iterates all variables found with RuntimeServices GetNextVariableName - - @param[in] CallbackFunction - Function called for each variable instance - @param[in] Context - Passed to each call of CallbackFunction - - @retval RETURN_SUCCESS - All variables were iterated without the - CallbackFunction returning an error - @retval RETURN_OUT_OF_RESOURCES - There we not enough resources to - iterate through the variables - @return Any of RETURN_ERROR indicates an error reading the variable - or an error was returned from CallbackFunction - -**/ -RETURN_STATUS -EFIAPI -SerializeVariablesIterateSystemVariables ( - IN VARIABLE_SERIALIZATION_ITERATION_CALLBACK CallbackFunction, - IN VOID *Context - ) -{ - RETURN_STATUS Status; - UINTN VariableNameBufferSize; - UINTN VariableNameSize; - CHAR16 *VariableName; - EFI_GUID VendorGuid; - UINTN VariableDataBufferSize; - UINTN VariableDataSize; - VOID *VariableData; - UINT32 VariableAttributes; - VOID *NewBuffer; - - // - // Initialize the variable name and data buffer variables. - // - VariableNameBufferSize = sizeof (CHAR16); - VariableName = AllocateZeroPool (VariableNameBufferSize); - - VariableDataBufferSize = 0; - VariableData = NULL; - - for (;;) { - // - // Get the next variable name and guid - // - VariableNameSize = VariableNameBufferSize; - Status = gRT->GetNextVariableName ( - &VariableNameSize, - VariableName, - &VendorGuid - ); - if (Status == EFI_BUFFER_TOO_SMALL) { - // - // The currently allocated VariableName buffer is too small, - // so we allocate a larger buffer, and copy the old buffer - // to it. - // - NewBuffer = AllocatePool (VariableNameSize); - if (NewBuffer == NULL) { - Status = EFI_OUT_OF_RESOURCES; - break; - } - CopyMem (NewBuffer, VariableName, VariableNameBufferSize); - if (VariableName != NULL) { - FreePool (VariableName); - } - VariableName = NewBuffer; - VariableNameBufferSize = VariableNameSize; - - // - // Try to get the next variable name again with the larger buffer. - // - Status = gRT->GetNextVariableName ( - &VariableNameSize, - VariableName, - &VendorGuid - ); - } - - if (EFI_ERROR (Status)) { - if (Status == EFI_NOT_FOUND) { - Status = EFI_SUCCESS; - } - break; - } - - // - // Get the variable data and attributes - // - VariableDataSize = VariableDataBufferSize; - Status = gRT->GetVariable ( - VariableName, - &VendorGuid, - &VariableAttributes, - &VariableDataSize, - VariableData - ); - if (Status == EFI_BUFFER_TOO_SMALL) { - // - // The currently allocated VariableData buffer is too small, - // so we allocate a larger buffer. - // - if (VariableDataBufferSize != 0) { - FreePool (VariableData); - VariableData = NULL; - VariableDataBufferSize = 0; - } - VariableData = AllocatePool (VariableDataSize); - if (VariableData == NULL) { - Status = EFI_OUT_OF_RESOURCES; - break; - } - VariableDataBufferSize = VariableDataSize; - - // - // Try to read the variable again with the larger buffer. - // - Status = gRT->GetVariable ( - VariableName, - &VendorGuid, - &VariableAttributes, - &VariableDataSize, - VariableData - ); - } - if (EFI_ERROR (Status)) { - break; - } - - // - // Run the callback function - // - Status = (*CallbackFunction) ( - Context, - VariableName, - &VendorGuid, - VariableAttributes, - VariableDataSize, - VariableData - ); - if (EFI_ERROR (Status)) { - break; - } - - } - - if (VariableName != NULL) { - FreePool (VariableName); - } - - if (VariableData != NULL) { - FreePool (VariableData); - } - - return Status; -} - - -/** - Iterates all variables found in the variable serialization instance - - @param[in] Handle - Handle for a variable serialization instance - @param[in] CallbackFunction - Function called for each variable instance - @param[in] Context - Passed to each call of CallbackFunction - - @retval RETURN_SUCCESS - All variables were iterated without the - CallbackFunction returning an error - @retval RETURN_OUT_OF_RESOURCES - There we not enough resources to - iterate through the variables - @return Any of RETURN_ERROR indicates an error reading the variable - or an error was returned from CallbackFunction - -**/ -RETURN_STATUS -EFIAPI -SerializeVariablesIterateInstanceVariables ( - IN EFI_HANDLE Handle, - IN VARIABLE_SERIALIZATION_ITERATION_CALLBACK CallbackFunction, - IN VOID *Context - ) -{ - SV_INSTANCE *Instance; - - Instance = SV_FROM_HANDLE (Handle); - - if ((Instance->BufferPtr != NULL) && (Instance->DataSize != 0)) { - return IterateVariablesInBuffer ( - CallbackFunction, - Context, - Instance->BufferPtr, - Instance->DataSize - ); - } else { - return RETURN_SUCCESS; - } -} - - -/** - Sets all variables found in the variable serialization instance - - @param[in] Handle - Handle for a variable serialization instance - - @retval RETURN_SUCCESS - All variables were set successfully - @retval RETURN_OUT_OF_RESOURCES - There we not enough resources to - set all the variables - @return Any of RETURN_ERROR indicates an error reading the variables - or in attempting to set a variable - -**/ -RETURN_STATUS -EFIAPI -SerializeVariablesSetSerializedVariables ( - IN EFI_HANDLE Handle - ) -{ - return SerializeVariablesIterateInstanceVariables ( - Handle, - IterateVariablesCallbackSetSystemVariable, - NULL - ); -} - - -/** - Adds a variable to the variable serialization instance - - @param[in] Handle - Handle for a variable serialization instance - @param[in] VariableName - Refer to RuntimeServices GetVariable - @param[in] VendorGuid - Refer to RuntimeServices GetVariable - @param[in] Attributes - Refer to RuntimeServices GetVariable - @param[in] DataSize - Refer to RuntimeServices GetVariable - @param[in] Data - Refer to RuntimeServices GetVariable - - @retval RETURN_SUCCESS - All variables were set successfully - @retval RETURN_OUT_OF_RESOURCES - There we not enough resources to - add the variable - @retval RETURN_INVALID_PARAMETER - Handle was not a valid - variable serialization instance or - VariableName, VariableGuid or Data are NULL. - -**/ -RETURN_STATUS -EFIAPI -SerializeVariablesAddVariable ( - IN EFI_HANDLE Handle, - IN CHAR16 *VariableName, - IN EFI_GUID *VendorGuid, - IN UINT32 Attributes, - IN UINTN DataSize, - IN VOID *Data - ) -{ - RETURN_STATUS Status; - SV_INSTANCE *Instance; - UINT32 SerializedNameSize; - UINT32 SerializedDataSize; - UINTN SerializedSize; - - Instance = SV_FROM_HANDLE (Handle); - - if ((Instance->Signature != SV_SIGNATURE) || - (VariableName == NULL) || (VendorGuid == NULL) || (Data == NULL)) { - } - - SerializedNameSize = (UINT32) StrSize (VariableName); - - SerializedSize = - sizeof (SerializedNameSize) + - SerializedNameSize + - sizeof (*VendorGuid) + - sizeof (Attributes) + - sizeof (SerializedDataSize) + - DataSize; - - Status = EnsureExtraBufferSpace ( - Instance, - SerializedSize - ); - if (RETURN_ERROR (Status)) { - return Status; - } - - // - // Add name size (UINT32) - // - AppendToBuffer (Instance, (VOID*) &SerializedNameSize, sizeof (SerializedNameSize)); - - // - // Add variable unicode name string - // - AppendToBuffer (Instance, (VOID*) VariableName, SerializedNameSize); - - // - // Add variable GUID - // - AppendToBuffer (Instance, (VOID*) VendorGuid, sizeof (*VendorGuid)); - - // - // Add variable attributes - // - AppendToBuffer (Instance, (VOID*) &Attributes, sizeof (Attributes)); - - // - // Add variable data size (UINT32) - // - SerializedDataSize = (UINT32) DataSize; - AppendToBuffer (Instance, (VOID*) &SerializedDataSize, sizeof (SerializedDataSize)); - - // - // Add variable data - // - AppendToBuffer (Instance, Data, DataSize); - - return RETURN_SUCCESS; -} - - -/** - Serializes the variables known to this instance into the - provided buffer. - - @param[in] Handle - Handle for a variable serialization instance - @param[out] Buffer - A buffer to store the binary representation - of the variables. - @param[in,out] Size - On input this is the size of the buffer. - On output this is the size of the binary representation - of the variables. - - @retval RETURN_SUCCESS - The binary representation was successfully - completed and returned in the buffer. - @retval RETURN_OUT_OF_RESOURCES - There we not enough resources to - save the variables to the buffer. - @retval RETURN_INVALID_PARAMETER - Handle was not a valid - variable serialization instance or - Size or Buffer were NULL. - @retval RETURN_BUFFER_TOO_SMALL - The Buffer size as indicated by - the Size parameter was too small for the serialized - variable data. Size is returned with the required size. - -**/ -RETURN_STATUS -EFIAPI -SerializeVariablesToBuffer ( - IN EFI_HANDLE Handle, - OUT VOID *Buffer, - IN OUT UINTN *Size - ) -{ - SV_INSTANCE *Instance; - - Instance = SV_FROM_HANDLE (Handle); - - if (Size == NULL) { - return RETURN_INVALID_PARAMETER; - } - - if (*Size < Instance->DataSize) { - *Size = Instance->DataSize; - return RETURN_BUFFER_TOO_SMALL; - } - - if (Buffer == NULL) { - return RETURN_INVALID_PARAMETER; - } - - *Size = Instance->DataSize; - CopyMem (Buffer, Instance->BufferPtr, Instance->DataSize); - - return RETURN_SUCCESS; -} - diff --git a/OvmfPkg/Library/SerializeVariablesLib/SerializeVariablesLib.h b/OvmfPkg/Library/SerializeVariablesLib/SerializeVariablesLib.h deleted file mode 100644 index 86aed03418..0000000000 --- a/OvmfPkg/Library/SerializeVariablesLib/SerializeVariablesLib.h +++ /dev/null @@ -1,39 +0,0 @@ -/** @file - Serialize Variables Library implementation - - Copyright (c) 2009 - 2011, Intel Corporation. All rights reserved.
- This program and the accompanying materials - are licensed and made available under the terms and conditions of the BSD License - which accompanies this distribution. The full text of the license may be found at - http://opensource.org/licenses/bsd-license.php - - THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, - WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. - -**/ - -#ifndef __SERIALIZE_VARIABLES_LIB_INSTANCE__ -#define __SERIALIZE_VARIABLES_LIB_INSTANCE__ - -#include - -#include -#include -#include -#include -#include -#include -#include - -#define SV_FROM_HANDLE(a) CR (a, SV_INSTANCE, Signature, SV_SIGNATURE) -#define SV_SIGNATURE SIGNATURE_32 ('S', 'V', 'A', 'R') - -typedef struct { - UINT32 Signature; - VOID *BufferPtr; - UINTN BufferSize; - UINTN DataSize; -} SV_INSTANCE; - -#endif - diff --git a/OvmfPkg/Library/SerializeVariablesLib/SerializeVariablesLib.inf b/OvmfPkg/Library/SerializeVariablesLib/SerializeVariablesLib.inf deleted file mode 100644 index b0c12b0ef6..0000000000 --- a/OvmfPkg/Library/SerializeVariablesLib/SerializeVariablesLib.inf +++ /dev/null @@ -1,41 +0,0 @@ -## @file -# Serialize Variables Library implementation -# -# This library serializes and deserializes UEFI variables -# -# Copyright (c) 2006 - 2011, Intel Corporation. All rights reserved.
-# -# This program and the accompanying materials -# are licensed and made available under the terms and conditions of the BSD License -# which accompanies this distribution. The full text of the license may be found at -# http://opensource.org/licenses/bsd-license.php -# THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, -# WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. -# -## - -[Defines] - INF_VERSION = 0x00010005 - BASE_NAME = DxeSerializeVariablesLib - FILE_GUID = 9515f92a-83ae-45fd-9d2e-e3dc15df52d0 - MODULE_TYPE = UEFI_DRIVER - VERSION_STRING = 1.0 - LIBRARY_CLASS = SerializeVariablesLib|DXE_DRIVER DXE_RUNTIME_DRIVER DXE_SAL_DRIVER UEFI_DRIVER - -[Sources] - SerializeVariablesLib.c - -[Packages] - MdePkg/MdePkg.dec - MdeModulePkg/MdeModulePkg.dec - OvmfPkg/OvmfPkg.dec - ShellPkg/ShellPkg.dec - -[LibraryClasses] - BaseLib - BaseMemoryLib - DebugLib - MemoryAllocationLib - UefiBootServicesTableLib - UefiRuntimeServicesTableLib - diff --git a/OvmfPkg/Library/SmbiosVersionLib/DetectSmbiosVersionLib.c b/OvmfPkg/Library/SmbiosVersionLib/DetectSmbiosVersionLib.c deleted file mode 100644 index 58180412bd..0000000000 --- a/OvmfPkg/Library/SmbiosVersionLib/DetectSmbiosVersionLib.c +++ /dev/null @@ -1,111 +0,0 @@ -/** @file - - A hook-in library for MdeModulePkg/Universal/SmbiosDxe, in order to set - gEfiMdeModulePkgTokenSpaceGuid.PcdSmbiosVersion (and possibly other PCDs) - just before SmbiosDxe consumes them. - - Copyright (C) 2013, 2015, Red Hat, Inc. - Copyright (c) 2008 - 2012, Intel Corporation. All rights reserved.
- - This program and the accompanying materials are licensed and made available - under the terms and conditions of the BSD License which accompanies this - distribution. The full text of the license may be found at - http://opensource.org/licenses/bsd-license.php - - THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, WITHOUT - WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. - -**/ - -#include - -#include -#include -#include -#include -#include - -typedef union { - SMBIOS_TABLE_ENTRY_POINT V2; - SMBIOS_TABLE_3_0_ENTRY_POINT V3; -} QEMU_SMBIOS_ANCHOR; - -RETURN_STATUS -EFIAPI -DetectSmbiosVersion ( - VOID - ) -{ - FIRMWARE_CONFIG_ITEM Anchor, Tables; - UINTN AnchorSize, TablesSize; - QEMU_SMBIOS_ANCHOR QemuAnchor; - UINT16 SmbiosVersion; - RETURN_STATUS PcdStatus; - - if (PcdGetBool (PcdQemuSmbiosValidated)) { - // - // Some other module, linked against this library, has already performed - // the task at hand. This should never happen, but it's easy to handle; - // just exit early. - // - return RETURN_SUCCESS; - } - - if (RETURN_ERROR (QemuFwCfgFindFile ( - "etc/smbios/smbios-anchor", &Anchor, &AnchorSize)) || - RETURN_ERROR (QemuFwCfgFindFile ( - "etc/smbios/smbios-tables", &Tables, &TablesSize)) || - TablesSize == 0) { - return RETURN_SUCCESS; - } - - QemuFwCfgSelectItem (Anchor); - - switch (AnchorSize) { - case sizeof QemuAnchor.V2: - QemuFwCfgReadBytes (AnchorSize, &QemuAnchor); - - if (QemuAnchor.V2.MajorVersion != 2 || - QemuAnchor.V2.TableLength != TablesSize || - CompareMem (QemuAnchor.V2.AnchorString, "_SM_", 4) != 0 || - CompareMem (QemuAnchor.V2.IntermediateAnchorString, "_DMI_", 5) != 0) { - return RETURN_SUCCESS; - } - SmbiosVersion = (UINT16)(QemuAnchor.V2.MajorVersion << 8 | - QemuAnchor.V2.MinorVersion); - break; - - case sizeof QemuAnchor.V3: - QemuFwCfgReadBytes (AnchorSize, &QemuAnchor); - - if (QemuAnchor.V3.MajorVersion != 3 || - QemuAnchor.V3.TableMaximumSize != TablesSize || - CompareMem (QemuAnchor.V3.AnchorString, "_SM3_", 5) != 0) { - return RETURN_SUCCESS; - } - SmbiosVersion = (UINT16)(QemuAnchor.V3.MajorVersion << 8 | - QemuAnchor.V3.MinorVersion); - - DEBUG ((EFI_D_INFO, "%a: SMBIOS 3.x DocRev from QEMU: 0x%02x\n", - __FUNCTION__, QemuAnchor.V3.DocRev)); - PcdStatus = PcdSet8S (PcdSmbiosDocRev, QemuAnchor.V3.DocRev); - ASSERT_RETURN_ERROR (PcdStatus); - break; - - default: - return RETURN_SUCCESS; - } - - DEBUG ((EFI_D_INFO, "%a: SMBIOS version from QEMU: 0x%04x\n", __FUNCTION__, - SmbiosVersion)); - PcdStatus = PcdSet16S (PcdSmbiosVersion, SmbiosVersion); - ASSERT_RETURN_ERROR (PcdStatus); - - // - // SMBIOS platform drivers can now fetch and install - // "etc/smbios/smbios-tables" from QEMU. - // - PcdStatus = PcdSetBoolS (PcdQemuSmbiosValidated, TRUE); - ASSERT_RETURN_ERROR (PcdStatus); - return RETURN_SUCCESS; -} diff --git a/OvmfPkg/Library/SmbiosVersionLib/DetectSmbiosVersionLib.inf b/OvmfPkg/Library/SmbiosVersionLib/DetectSmbiosVersionLib.inf deleted file mode 100644 index 45d953a015..0000000000 --- a/OvmfPkg/Library/SmbiosVersionLib/DetectSmbiosVersionLib.inf +++ /dev/null @@ -1,53 +0,0 @@ -## @file -# -# A hook-in library for MdeModulePkg/Universal/SmbiosDxe, in order to set -# gEfiMdeModulePkgTokenSpaceGuid.PcdSmbiosVersion (and possibly other PCDs) -# just before SmbiosDxe consumes them. -# -# Copyright (C) 2013, 2015, Red Hat, Inc. -# Copyright (c) 2008 - 2012, Intel Corporation. All rights reserved.
-# -# This program and the accompanying materials are licensed and made available -# under the terms and conditions of the BSD License which accompanies this -# distribution. The full text of the license may be found at -# http://opensource.org/licenses/bsd-license.php -# -# THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, WITHOUT -# WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. -# -## - -[Defines] - INF_VERSION = 0x00010005 - BASE_NAME = DetectSmbiosVersionLib - FILE_GUID = 6c633bb2-ae33-49ae-9f89-b5aa999fe3ae - MODULE_TYPE = BASE - VERSION_STRING = 1.0 - LIBRARY_CLASS = SmbiosVersionLib|DXE_DRIVER - CONSTRUCTOR = DetectSmbiosVersion - -# -# The following information is for reference only and not required by the build -# tools. -# -# VALID_ARCHITECTURES = IA32 X64 ARM AARCH64 -# - -[Sources] - DetectSmbiosVersionLib.c - -[Packages] - MdePkg/MdePkg.dec - MdeModulePkg/MdeModulePkg.dec - OvmfPkg/OvmfPkg.dec - -[LibraryClasses] - BaseMemoryLib - DebugLib - PcdLib - QemuFwCfgLib - -[Pcd] - gEfiMdeModulePkgTokenSpaceGuid.PcdSmbiosVersion - gEfiMdeModulePkgTokenSpaceGuid.PcdSmbiosDocRev - gUefiOvmfPkgTokenSpaceGuid.PcdQemuSmbiosValidated diff --git a/OvmfPkg/Library/SmmCpuFeaturesLib/SmmCpuFeaturesLib.c b/OvmfPkg/Library/SmmCpuFeaturesLib/SmmCpuFeaturesLib.c deleted file mode 100644 index a307f64c9c..0000000000 --- a/OvmfPkg/Library/SmmCpuFeaturesLib/SmmCpuFeaturesLib.c +++ /dev/null @@ -1,834 +0,0 @@ -/** @file -The CPU specific programming for PiSmmCpuDxeSmm module. - -Copyright (c) 2010 - 2015, Intel Corporation. All rights reserved.
-This program and the accompanying materials -are licensed and made available under the terms and conditions of the BSD License -which accompanies this distribution. The full text of the license may be found at -http://opensource.org/licenses/bsd-license.php - -THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, -WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. - -**/ - -#include -#include -#include -#include -#include -#include -#include -#include -#include - -// -// EFER register LMA bit -// -#define LMA BIT10 - -/** - The constructor function - - @param[in] ImageHandle The firmware allocated handle for the EFI image. - @param[in] SystemTable A pointer to the EFI System Table. - - @retval EFI_SUCCESS The constructor always returns EFI_SUCCESS. - -**/ -EFI_STATUS -EFIAPI -SmmCpuFeaturesLibConstructor ( - IN EFI_HANDLE ImageHandle, - IN EFI_SYSTEM_TABLE *SystemTable - ) -{ - // - // No need to program SMRRs on our virtual platform. - // - return EFI_SUCCESS; -} - -/** - Called during the very first SMI into System Management Mode to initialize - CPU features, including SMBASE, for the currently executing CPU. Since this - is the first SMI, the SMRAM Save State Map is at the default address of - SMM_DEFAULT_SMBASE + SMRAM_SAVE_STATE_MAP_OFFSET. The currently executing - CPU is specified by CpuIndex and CpuIndex can be used to access information - about the currently executing CPU in the ProcessorInfo array and the - HotPlugCpuData data structure. - - @param[in] CpuIndex The index of the CPU to initialize. The value - must be between 0 and the NumberOfCpus field in - the System Management System Table (SMST). - @param[in] IsMonarch TRUE if the CpuIndex is the index of the CPU that - was elected as monarch during System Management - Mode initialization. - FALSE if the CpuIndex is not the index of the CPU - that was elected as monarch during System - Management Mode initialization. - @param[in] ProcessorInfo Pointer to an array of EFI_PROCESSOR_INFORMATION - structures. ProcessorInfo[CpuIndex] contains the - information for the currently executing CPU. - @param[in] CpuHotPlugData Pointer to the CPU_HOT_PLUG_DATA structure that - contains the ApidId and SmBase arrays. -**/ -VOID -EFIAPI -SmmCpuFeaturesInitializeProcessor ( - IN UINTN CpuIndex, - IN BOOLEAN IsMonarch, - IN EFI_PROCESSOR_INFORMATION *ProcessorInfo, - IN CPU_HOT_PLUG_DATA *CpuHotPlugData - ) -{ - QEMU_SMRAM_SAVE_STATE_MAP *CpuState; - - // - // Configure SMBASE. - // - CpuState = (QEMU_SMRAM_SAVE_STATE_MAP *)(UINTN)(SMM_DEFAULT_SMBASE + SMRAM_SAVE_STATE_MAP_OFFSET); - if ((CpuState->x86.SMMRevId & 0xFFFF) == 0) { - CpuState->x86.SMBASE = (UINT32)CpuHotPlugData->SmBase[CpuIndex]; - } else { - CpuState->x64.SMBASE = (UINT32)CpuHotPlugData->SmBase[CpuIndex]; - } - - // - // No need to program SMRRs on our virtual platform. - // -} - -/** - This function updates the SMRAM save state on the currently executing CPU - to resume execution at a specific address after an RSM instruction. This - function must evaluate the SMRAM save state to determine the execution mode - the RSM instruction resumes and update the resume execution address with - either NewInstructionPointer32 or NewInstructionPoint. The auto HALT restart - flag in the SMRAM save state must always be cleared. This function returns - the value of the instruction pointer from the SMRAM save state that was - replaced. If this function returns 0, then the SMRAM save state was not - modified. - - This function is called during the very first SMI on each CPU after - SmmCpuFeaturesInitializeProcessor() to set a flag in normal execution mode - to signal that the SMBASE of each CPU has been updated before the default - SMBASE address is used for the first SMI to the next CPU. - - @param[in] CpuIndex The index of the CPU to hook. The value - must be between 0 and the NumberOfCpus - field in the System Management System Table - (SMST). - @param[in] CpuState Pointer to SMRAM Save State Map for the - currently executing CPU. - @param[in] NewInstructionPointer32 Instruction pointer to use if resuming to - 32-bit execution mode from 64-bit SMM. - @param[in] NewInstructionPointer Instruction pointer to use if resuming to - same execution mode as SMM. - - @retval 0 This function did modify the SMRAM save state. - @retval > 0 The original instruction pointer value from the SMRAM save state - before it was replaced. -**/ -UINT64 -EFIAPI -SmmCpuFeaturesHookReturnFromSmm ( - IN UINTN CpuIndex, - IN SMRAM_SAVE_STATE_MAP *CpuState, - IN UINT64 NewInstructionPointer32, - IN UINT64 NewInstructionPointer - ) -{ - UINT64 OriginalInstructionPointer; - QEMU_SMRAM_SAVE_STATE_MAP *CpuSaveState = (QEMU_SMRAM_SAVE_STATE_MAP *)CpuState; - - if ((CpuSaveState->x86.SMMRevId & 0xFFFF) == 0) { - OriginalInstructionPointer = (UINT64)CpuSaveState->x86._EIP; - CpuSaveState->x86._EIP = (UINT32)NewInstructionPointer; - // - // Clear the auto HALT restart flag so the RSM instruction returns - // program control to the instruction following the HLT instruction. - // - if ((CpuSaveState->x86.AutoHALTRestart & BIT0) != 0) { - CpuSaveState->x86.AutoHALTRestart &= ~BIT0; - } - } else { - OriginalInstructionPointer = CpuSaveState->x64._RIP; - if ((CpuSaveState->x64.IA32_EFER & LMA) == 0) { - CpuSaveState->x64._RIP = (UINT32)NewInstructionPointer32; - } else { - CpuSaveState->x64._RIP = (UINT32)NewInstructionPointer; - } - // - // Clear the auto HALT restart flag so the RSM instruction returns - // program control to the instruction following the HLT instruction. - // - if ((CpuSaveState->x64.AutoHALTRestart & BIT0) != 0) { - CpuSaveState->x64.AutoHALTRestart &= ~BIT0; - } - } - return OriginalInstructionPointer; -} - -/** - Hook point in normal execution mode that allows the one CPU that was elected - as monarch during System Management Mode initialization to perform additional - initialization actions immediately after all of the CPUs have processed their - first SMI and called SmmCpuFeaturesInitializeProcessor() relocating SMBASE - into a buffer in SMRAM and called SmmCpuFeaturesHookReturnFromSmm(). -**/ -VOID -EFIAPI -SmmCpuFeaturesSmmRelocationComplete ( - VOID - ) -{ -} - -/** - Return the size, in bytes, of a custom SMI Handler in bytes. If 0 is - returned, then a custom SMI handler is not provided by this library, - and the default SMI handler must be used. - - @retval 0 Use the default SMI handler. - @retval > 0 Use the SMI handler installed by SmmCpuFeaturesInstallSmiHandler() - The caller is required to allocate enough SMRAM for each CPU to - support the size of the custom SMI handler. -**/ -UINTN -EFIAPI -SmmCpuFeaturesGetSmiHandlerSize ( - VOID - ) -{ - return 0; -} - -/** - Install a custom SMI handler for the CPU specified by CpuIndex. This function - is only called if SmmCpuFeaturesGetSmiHandlerSize() returns a size is greater - than zero and is called by the CPU that was elected as monarch during System - Management Mode initialization. - - @param[in] CpuIndex The index of the CPU to install the custom SMI handler. - The value must be between 0 and the NumberOfCpus field - in the System Management System Table (SMST). - @param[in] SmBase The SMBASE address for the CPU specified by CpuIndex. - @param[in] SmiStack The stack to use when an SMI is processed by the - the CPU specified by CpuIndex. - @param[in] StackSize The size, in bytes, if the stack used when an SMI is - processed by the CPU specified by CpuIndex. - @param[in] GdtBase The base address of the GDT to use when an SMI is - processed by the CPU specified by CpuIndex. - @param[in] GdtSize The size, in bytes, of the GDT used when an SMI is - processed by the CPU specified by CpuIndex. - @param[in] IdtBase The base address of the IDT to use when an SMI is - processed by the CPU specified by CpuIndex. - @param[in] IdtSize The size, in bytes, of the IDT used when an SMI is - processed by the CPU specified by CpuIndex. - @param[in] Cr3 The base address of the page tables to use when an SMI - is processed by the CPU specified by CpuIndex. -**/ -VOID -EFIAPI -SmmCpuFeaturesInstallSmiHandler ( - IN UINTN CpuIndex, - IN UINT32 SmBase, - IN VOID *SmiStack, - IN UINTN StackSize, - IN UINTN GdtBase, - IN UINTN GdtSize, - IN UINTN IdtBase, - IN UINTN IdtSize, - IN UINT32 Cr3 - ) -{ -} - -/** - Determines if MTRR registers must be configured to set SMRAM cache-ability - when executing in System Management Mode. - - @retval TRUE MTRR registers must be configured to set SMRAM cache-ability. - @retval FALSE MTRR registers do not need to be configured to set SMRAM - cache-ability. -**/ -BOOLEAN -EFIAPI -SmmCpuFeaturesNeedConfigureMtrrs ( - VOID - ) -{ - return FALSE; -} - -/** - Disable SMRR register if SMRR is supported and SmmCpuFeaturesNeedConfigureMtrrs() - returns TRUE. -**/ -VOID -EFIAPI -SmmCpuFeaturesDisableSmrr ( - VOID - ) -{ - // - // No SMRR support, nothing to do - // -} - -/** - Enable SMRR register if SMRR is supported and SmmCpuFeaturesNeedConfigureMtrrs() - returns TRUE. -**/ -VOID -EFIAPI -SmmCpuFeaturesReenableSmrr ( - VOID - ) -{ - // - // No SMRR support, nothing to do - // -} - -/** - Processor specific hook point each time a CPU enters System Management Mode. - - @param[in] CpuIndex The index of the CPU that has entered SMM. The value - must be between 0 and the NumberOfCpus field in the - System Management System Table (SMST). -**/ -VOID -EFIAPI -SmmCpuFeaturesRendezvousEntry ( - IN UINTN CpuIndex - ) -{ - // - // No SMRR support, nothing to do - // -} - -/** - Processor specific hook point each time a CPU exits System Management Mode. - - @param[in] CpuIndex The index of the CPU that is exiting SMM. The value must - be between 0 and the NumberOfCpus field in the System - Management System Table (SMST). -**/ -VOID -EFIAPI -SmmCpuFeaturesRendezvousExit ( - IN UINTN CpuIndex - ) -{ -} - -/** - Check to see if an SMM register is supported by a specified CPU. - - @param[in] CpuIndex The index of the CPU to check for SMM register support. - The value must be between 0 and the NumberOfCpus field - in the System Management System Table (SMST). - @param[in] RegName Identifies the SMM register to check for support. - - @retval TRUE The SMM register specified by RegName is supported by the CPU - specified by CpuIndex. - @retval FALSE The SMM register specified by RegName is not supported by the - CPU specified by CpuIndex. -**/ -BOOLEAN -EFIAPI -SmmCpuFeaturesIsSmmRegisterSupported ( - IN UINTN CpuIndex, - IN SMM_REG_NAME RegName - ) -{ - ASSERT (RegName == SmmRegFeatureControl); - return FALSE; -} - -/** - Returns the current value of the SMM register for the specified CPU. - If the SMM register is not supported, then 0 is returned. - - @param[in] CpuIndex The index of the CPU to read the SMM register. The - value must be between 0 and the NumberOfCpus field in - the System Management System Table (SMST). - @param[in] RegName Identifies the SMM register to read. - - @return The value of the SMM register specified by RegName from the CPU - specified by CpuIndex. -**/ -UINT64 -EFIAPI -SmmCpuFeaturesGetSmmRegister ( - IN UINTN CpuIndex, - IN SMM_REG_NAME RegName - ) -{ - // - // This is called for SmmRegSmmDelayed, SmmRegSmmBlocked, SmmRegSmmEnable. - // The last of these should actually be SmmRegSmmDisable, so we can just - // return FALSE. - // - return 0; -} - -/** - Sets the value of an SMM register on a specified CPU. - If the SMM register is not supported, then no action is performed. - - @param[in] CpuIndex The index of the CPU to write the SMM register. The - value must be between 0 and the NumberOfCpus field in - the System Management System Table (SMST). - @param[in] RegName Identifies the SMM register to write. - registers are read-only. - @param[in] Value The value to write to the SMM register. -**/ -VOID -EFIAPI -SmmCpuFeaturesSetSmmRegister ( - IN UINTN CpuIndex, - IN SMM_REG_NAME RegName, - IN UINT64 Value - ) -{ - ASSERT (FALSE); -} - -/// -/// Macro used to simplify the lookup table entries of type CPU_SMM_SAVE_STATE_LOOKUP_ENTRY -/// -#define SMM_CPU_OFFSET(Field) OFFSET_OF (QEMU_SMRAM_SAVE_STATE_MAP, Field) - -/// -/// Macro used to simplify the lookup table entries of type CPU_SMM_SAVE_STATE_REGISTER_RANGE -/// -#define SMM_REGISTER_RANGE(Start, End) { Start, End, End - Start + 1 } - -/// -/// Structure used to describe a range of registers -/// -typedef struct { - EFI_SMM_SAVE_STATE_REGISTER Start; - EFI_SMM_SAVE_STATE_REGISTER End; - UINTN Length; -} CPU_SMM_SAVE_STATE_REGISTER_RANGE; - -/// -/// Structure used to build a lookup table to retrieve the widths and offsets -/// associated with each supported EFI_SMM_SAVE_STATE_REGISTER value -/// - -#define SMM_SAVE_STATE_REGISTER_FIRST_INDEX 1 - -typedef struct { - UINT8 Width32; - UINT8 Width64; - UINT16 Offset32; - UINT16 Offset64Lo; - UINT16 Offset64Hi; - BOOLEAN Writeable; -} CPU_SMM_SAVE_STATE_LOOKUP_ENTRY; - -/// -/// Table used by GetRegisterIndex() to convert an EFI_SMM_SAVE_STATE_REGISTER -/// value to an index into a table of type CPU_SMM_SAVE_STATE_LOOKUP_ENTRY -/// -static CONST CPU_SMM_SAVE_STATE_REGISTER_RANGE mSmmCpuRegisterRanges[] = { - SMM_REGISTER_RANGE (EFI_SMM_SAVE_STATE_REGISTER_GDTBASE, EFI_SMM_SAVE_STATE_REGISTER_LDTINFO), - SMM_REGISTER_RANGE (EFI_SMM_SAVE_STATE_REGISTER_ES, EFI_SMM_SAVE_STATE_REGISTER_RIP), - SMM_REGISTER_RANGE (EFI_SMM_SAVE_STATE_REGISTER_RFLAGS, EFI_SMM_SAVE_STATE_REGISTER_CR4), - { (EFI_SMM_SAVE_STATE_REGISTER)0, (EFI_SMM_SAVE_STATE_REGISTER)0, 0 } -}; - -/// -/// Lookup table used to retrieve the widths and offsets associated with each -/// supported EFI_SMM_SAVE_STATE_REGISTER value -/// -static CONST CPU_SMM_SAVE_STATE_LOOKUP_ENTRY mSmmCpuWidthOffset[] = { - {0, 0, 0, 0, 0, FALSE}, // Reserved - - // - // CPU Save State registers defined in PI SMM CPU Protocol. - // - {0, 8, 0 , SMM_CPU_OFFSET (x64._GDTRBase) , SMM_CPU_OFFSET (x64._GDTRBase) + 4, FALSE}, // EFI_SMM_SAVE_STATE_REGISTER_GDTBASE = 4 - {0, 8, 0 , SMM_CPU_OFFSET (x64._IDTRBase) , SMM_CPU_OFFSET (x64._IDTRBase) + 4, FALSE}, // EFI_SMM_SAVE_STATE_REGISTER_IDTBASE = 5 - {0, 8, 0 , SMM_CPU_OFFSET (x64._LDTRBase) , SMM_CPU_OFFSET (x64._LDTRBase) + 4, FALSE}, // EFI_SMM_SAVE_STATE_REGISTER_LDTBASE = 6 - {0, 0, 0 , SMM_CPU_OFFSET (x64._GDTRLimit), SMM_CPU_OFFSET (x64._GDTRLimit) + 4, FALSE}, // EFI_SMM_SAVE_STATE_REGISTER_GDTLIMIT = 7 - {0, 0, 0 , SMM_CPU_OFFSET (x64._IDTRLimit), SMM_CPU_OFFSET (x64._IDTRLimit) + 4, FALSE}, // EFI_SMM_SAVE_STATE_REGISTER_IDTLIMIT = 8 - {0, 0, 0 , SMM_CPU_OFFSET (x64._LDTRLimit), SMM_CPU_OFFSET (x64._LDTRLimit) + 4, FALSE}, // EFI_SMM_SAVE_STATE_REGISTER_LDTLIMIT = 9 - {0, 0, 0 , 0 , 0 + 4, FALSE}, // EFI_SMM_SAVE_STATE_REGISTER_LDTINFO = 10 - - {4, 4, SMM_CPU_OFFSET (x86._ES) , SMM_CPU_OFFSET (x64._ES) , 0 , FALSE}, // EFI_SMM_SAVE_STATE_REGISTER_ES = 20 - {4, 4, SMM_CPU_OFFSET (x86._CS) , SMM_CPU_OFFSET (x64._CS) , 0 , FALSE}, // EFI_SMM_SAVE_STATE_REGISTER_CS = 21 - {4, 4, SMM_CPU_OFFSET (x86._SS) , SMM_CPU_OFFSET (x64._SS) , 0 , FALSE}, // EFI_SMM_SAVE_STATE_REGISTER_SS = 22 - {4, 4, SMM_CPU_OFFSET (x86._DS) , SMM_CPU_OFFSET (x64._DS) , 0 , FALSE}, // EFI_SMM_SAVE_STATE_REGISTER_DS = 23 - {4, 4, SMM_CPU_OFFSET (x86._FS) , SMM_CPU_OFFSET (x64._FS) , 0 , FALSE}, // EFI_SMM_SAVE_STATE_REGISTER_FS = 24 - {4, 4, SMM_CPU_OFFSET (x86._GS) , SMM_CPU_OFFSET (x64._GS) , 0 , FALSE}, // EFI_SMM_SAVE_STATE_REGISTER_GS = 25 - {0, 4, 0 , SMM_CPU_OFFSET (x64._LDTR) , 0 , FALSE}, // EFI_SMM_SAVE_STATE_REGISTER_LDTR_SEL = 26 - {4, 4, SMM_CPU_OFFSET (x86._TR) , SMM_CPU_OFFSET (x64._TR) , 0 , FALSE}, // EFI_SMM_SAVE_STATE_REGISTER_TR_SEL = 27 - {4, 8, SMM_CPU_OFFSET (x86._DR7) , SMM_CPU_OFFSET (x64._DR7) , SMM_CPU_OFFSET (x64._DR7) + 4, FALSE}, // EFI_SMM_SAVE_STATE_REGISTER_DR7 = 28 - {4, 8, SMM_CPU_OFFSET (x86._DR6) , SMM_CPU_OFFSET (x64._DR6) , SMM_CPU_OFFSET (x64._DR6) + 4, FALSE}, // EFI_SMM_SAVE_STATE_REGISTER_DR6 = 29 - {0, 8, 0 , SMM_CPU_OFFSET (x64._R8) , SMM_CPU_OFFSET (x64._R8) + 4, TRUE }, // EFI_SMM_SAVE_STATE_REGISTER_R8 = 30 - {0, 8, 0 , SMM_CPU_OFFSET (x64._R9) , SMM_CPU_OFFSET (x64._R9) + 4, TRUE }, // EFI_SMM_SAVE_STATE_REGISTER_R9 = 31 - {0, 8, 0 , SMM_CPU_OFFSET (x64._R10) , SMM_CPU_OFFSET (x64._R10) + 4, TRUE }, // EFI_SMM_SAVE_STATE_REGISTER_R10 = 32 - {0, 8, 0 , SMM_CPU_OFFSET (x64._R11) , SMM_CPU_OFFSET (x64._R11) + 4, TRUE }, // EFI_SMM_SAVE_STATE_REGISTER_R11 = 33 - {0, 8, 0 , SMM_CPU_OFFSET (x64._R12) , SMM_CPU_OFFSET (x64._R12) + 4, TRUE }, // EFI_SMM_SAVE_STATE_REGISTER_R12 = 34 - {0, 8, 0 , SMM_CPU_OFFSET (x64._R13) , SMM_CPU_OFFSET (x64._R13) + 4, TRUE }, // EFI_SMM_SAVE_STATE_REGISTER_R13 = 35 - {0, 8, 0 , SMM_CPU_OFFSET (x64._R14) , SMM_CPU_OFFSET (x64._R14) + 4, TRUE }, // EFI_SMM_SAVE_STATE_REGISTER_R14 = 36 - {0, 8, 0 , SMM_CPU_OFFSET (x64._R15) , SMM_CPU_OFFSET (x64._R15) + 4, TRUE }, // EFI_SMM_SAVE_STATE_REGISTER_R15 = 37 - {4, 8, SMM_CPU_OFFSET (x86._EAX) , SMM_CPU_OFFSET (x64._RAX) , SMM_CPU_OFFSET (x64._RAX) + 4, TRUE }, // EFI_SMM_SAVE_STATE_REGISTER_RAX = 38 - {4, 8, SMM_CPU_OFFSET (x86._EBX) , SMM_CPU_OFFSET (x64._RBX) , SMM_CPU_OFFSET (x64._RBX) + 4, TRUE }, // EFI_SMM_SAVE_STATE_REGISTER_RBX = 39 - {4, 8, SMM_CPU_OFFSET (x86._ECX) , SMM_CPU_OFFSET (x64._RCX) , SMM_CPU_OFFSET (x64._RCX) + 4, TRUE }, // EFI_SMM_SAVE_STATE_REGISTER_RCX = 40 - {4, 8, SMM_CPU_OFFSET (x86._EDX) , SMM_CPU_OFFSET (x64._RDX) , SMM_CPU_OFFSET (x64._RDX) + 4, TRUE }, // EFI_SMM_SAVE_STATE_REGISTER_RDX = 41 - {4, 8, SMM_CPU_OFFSET (x86._ESP) , SMM_CPU_OFFSET (x64._RSP) , SMM_CPU_OFFSET (x64._RSP) + 4, TRUE }, // EFI_SMM_SAVE_STATE_REGISTER_RSP = 42 - {4, 8, SMM_CPU_OFFSET (x86._EBP) , SMM_CPU_OFFSET (x64._RBP) , SMM_CPU_OFFSET (x64._RBP) + 4, TRUE }, // EFI_SMM_SAVE_STATE_REGISTER_RBP = 43 - {4, 8, SMM_CPU_OFFSET (x86._ESI) , SMM_CPU_OFFSET (x64._RSI) , SMM_CPU_OFFSET (x64._RSI) + 4, TRUE }, // EFI_SMM_SAVE_STATE_REGISTER_RSI = 44 - {4, 8, SMM_CPU_OFFSET (x86._EDI) , SMM_CPU_OFFSET (x64._RDI) , SMM_CPU_OFFSET (x64._RDI) + 4, TRUE }, // EFI_SMM_SAVE_STATE_REGISTER_RDI = 45 - {4, 8, SMM_CPU_OFFSET (x86._EIP) , SMM_CPU_OFFSET (x64._RIP) , SMM_CPU_OFFSET (x64._RIP) + 4, TRUE }, // EFI_SMM_SAVE_STATE_REGISTER_RIP = 46 - - {4, 8, SMM_CPU_OFFSET (x86._EFLAGS) , SMM_CPU_OFFSET (x64._RFLAGS) , SMM_CPU_OFFSET (x64._RFLAGS) + 4, TRUE }, // EFI_SMM_SAVE_STATE_REGISTER_RFLAGS = 51 - {4, 8, SMM_CPU_OFFSET (x86._CR0) , SMM_CPU_OFFSET (x64._CR0) , SMM_CPU_OFFSET (x64._CR0) + 4, FALSE}, // EFI_SMM_SAVE_STATE_REGISTER_CR0 = 52 - {4, 8, SMM_CPU_OFFSET (x86._CR3) , SMM_CPU_OFFSET (x64._CR3) , SMM_CPU_OFFSET (x64._CR3) + 4, FALSE}, // EFI_SMM_SAVE_STATE_REGISTER_CR3 = 53 - {0, 4, 0 , SMM_CPU_OFFSET (x64._CR4) , SMM_CPU_OFFSET (x64._CR4) + 4, FALSE}, // EFI_SMM_SAVE_STATE_REGISTER_CR4 = 54 -}; - -// -// No support for I/O restart -// - -/** - Read information from the CPU save state. - - @param Register Specifies the CPU register to read form the save state. - - @retval 0 Register is not valid - @retval >0 Index into mSmmCpuWidthOffset[] associated with Register - -**/ -static UINTN -GetRegisterIndex ( - IN EFI_SMM_SAVE_STATE_REGISTER Register - ) -{ - UINTN Index; - UINTN Offset; - - for (Index = 0, Offset = SMM_SAVE_STATE_REGISTER_FIRST_INDEX; mSmmCpuRegisterRanges[Index].Length != 0; Index++) { - if (Register >= mSmmCpuRegisterRanges[Index].Start && Register <= mSmmCpuRegisterRanges[Index].End) { - return Register - mSmmCpuRegisterRanges[Index].Start + Offset; - } - Offset += mSmmCpuRegisterRanges[Index].Length; - } - return 0; -} - -/** - Read a CPU Save State register on the target processor. - - This function abstracts the differences that whether the CPU Save State register is in the - IA32 CPU Save State Map or X64 CPU Save State Map. - - This function supports reading a CPU Save State register in SMBase relocation handler. - - @param[in] CpuIndex Specifies the zero-based index of the CPU save state. - @param[in] RegisterIndex Index into mSmmCpuWidthOffset[] look up table. - @param[in] Width The number of bytes to read from the CPU save state. - @param[out] Buffer Upon return, this holds the CPU register value read from the save state. - - @retval EFI_SUCCESS The register was read from Save State. - @retval EFI_NOT_FOUND The register is not defined for the Save State of Processor. - @retval EFI_INVALID_PARAMTER This or Buffer is NULL. - -**/ -static EFI_STATUS -ReadSaveStateRegisterByIndex ( - IN UINTN CpuIndex, - IN UINTN RegisterIndex, - IN UINTN Width, - OUT VOID *Buffer - ) -{ - QEMU_SMRAM_SAVE_STATE_MAP *CpuSaveState; - - CpuSaveState = (QEMU_SMRAM_SAVE_STATE_MAP *)gSmst->CpuSaveState[CpuIndex]; - - if ((CpuSaveState->x86.SMMRevId & 0xFFFF) == 0) { - // - // If 32-bit mode width is zero, then the specified register can not be accessed - // - if (mSmmCpuWidthOffset[RegisterIndex].Width32 == 0) { - return EFI_NOT_FOUND; - } - - // - // If Width is bigger than the 32-bit mode width, then the specified register can not be accessed - // - if (Width > mSmmCpuWidthOffset[RegisterIndex].Width32) { - return EFI_INVALID_PARAMETER; - } - - // - // Write return buffer - // - ASSERT(CpuSaveState != NULL); - CopyMem(Buffer, (UINT8 *)CpuSaveState + mSmmCpuWidthOffset[RegisterIndex].Offset32, Width); - } else { - // - // If 64-bit mode width is zero, then the specified register can not be accessed - // - if (mSmmCpuWidthOffset[RegisterIndex].Width64 == 0) { - return EFI_NOT_FOUND; - } - - // - // If Width is bigger than the 64-bit mode width, then the specified register can not be accessed - // - if (Width > mSmmCpuWidthOffset[RegisterIndex].Width64) { - return EFI_INVALID_PARAMETER; - } - - // - // Write lower 32-bits of return buffer - // - CopyMem(Buffer, (UINT8 *)CpuSaveState + mSmmCpuWidthOffset[RegisterIndex].Offset64Lo, MIN(4, Width)); - if (Width >= 4) { - // - // Write upper 32-bits of return buffer - // - CopyMem((UINT8 *)Buffer + 4, (UINT8 *)CpuSaveState + mSmmCpuWidthOffset[RegisterIndex].Offset64Hi, Width - 4); - } - } - return EFI_SUCCESS; -} - -/** - Read an SMM Save State register on the target processor. If this function - returns EFI_UNSUPPORTED, then the caller is responsible for reading the - SMM Save Sate register. - - @param[in] CpuIndex The index of the CPU to read the SMM Save State. The - value must be between 0 and the NumberOfCpus field in - the System Management System Table (SMST). - @param[in] Register The SMM Save State register to read. - @param[in] Width The number of bytes to read from the CPU save state. - @param[out] Buffer Upon return, this holds the CPU register value read - from the save state. - - @retval EFI_SUCCESS The register was read from Save State. - @retval EFI_INVALID_PARAMTER Buffer is NULL. - @retval EFI_UNSUPPORTED This function does not support reading Register. - -**/ -EFI_STATUS -EFIAPI -SmmCpuFeaturesReadSaveStateRegister ( - IN UINTN CpuIndex, - IN EFI_SMM_SAVE_STATE_REGISTER Register, - IN UINTN Width, - OUT VOID *Buffer - ) -{ - UINTN RegisterIndex; - QEMU_SMRAM_SAVE_STATE_MAP *CpuSaveState; - - // - // Check for special EFI_SMM_SAVE_STATE_REGISTER_LMA - // - if (Register == EFI_SMM_SAVE_STATE_REGISTER_LMA) { - // - // Only byte access is supported for this register - // - if (Width != 1) { - return EFI_INVALID_PARAMETER; - } - - CpuSaveState = (QEMU_SMRAM_SAVE_STATE_MAP *)gSmst->CpuSaveState[CpuIndex]; - - // - // Check CPU mode - // - if ((CpuSaveState->x86.SMMRevId & 0xFFFF) == 0) { - *(UINT8 *)Buffer = 32; - } else { - *(UINT8 *)Buffer = 64; - } - - return EFI_SUCCESS; - } - - // - // Check for special EFI_SMM_SAVE_STATE_REGISTER_IO - // - if (Register == EFI_SMM_SAVE_STATE_REGISTER_IO) { - return EFI_NOT_FOUND; - } - - // - // Convert Register to a register lookup table index. Let - // PiSmmCpuDxeSmm implement other special registers (currently - // there is only EFI_SMM_SAVE_STATE_REGISTER_PROCESSOR_ID). - // - RegisterIndex = GetRegisterIndex (Register); - if (RegisterIndex == 0) { - return Register < EFI_SMM_SAVE_STATE_REGISTER_IO ? EFI_NOT_FOUND : EFI_UNSUPPORTED; - } - - return ReadSaveStateRegisterByIndex (CpuIndex, RegisterIndex, Width, Buffer); -} - -/** - Writes an SMM Save State register on the target processor. If this function - returns EFI_UNSUPPORTED, then the caller is responsible for writing the - SMM Save Sate register. - - @param[in] CpuIndex The index of the CPU to write the SMM Save State. The - value must be between 0 and the NumberOfCpus field in - the System Management System Table (SMST). - @param[in] Register The SMM Save State register to write. - @param[in] Width The number of bytes to write to the CPU save state. - @param[in] Buffer Upon entry, this holds the new CPU register value. - - @retval EFI_SUCCESS The register was written to Save State. - @retval EFI_INVALID_PARAMTER Buffer is NULL. - @retval EFI_UNSUPPORTED This function does not support writing Register. -**/ -EFI_STATUS -EFIAPI -SmmCpuFeaturesWriteSaveStateRegister ( - IN UINTN CpuIndex, - IN EFI_SMM_SAVE_STATE_REGISTER Register, - IN UINTN Width, - IN CONST VOID *Buffer - ) -{ - UINTN RegisterIndex; - QEMU_SMRAM_SAVE_STATE_MAP *CpuSaveState; - - // - // Writes to EFI_SMM_SAVE_STATE_REGISTER_LMA are ignored - // - if (Register == EFI_SMM_SAVE_STATE_REGISTER_LMA) { - return EFI_SUCCESS; - } - - // - // Writes to EFI_SMM_SAVE_STATE_REGISTER_IO are not supported - // - if (Register == EFI_SMM_SAVE_STATE_REGISTER_IO) { - return EFI_NOT_FOUND; - } - - // - // Convert Register to a register lookup table index. Let - // PiSmmCpuDxeSmm implement other special registers (currently - // there is only EFI_SMM_SAVE_STATE_REGISTER_PROCESSOR_ID). - // - RegisterIndex = GetRegisterIndex (Register); - if (RegisterIndex == 0) { - return Register < EFI_SMM_SAVE_STATE_REGISTER_IO ? EFI_NOT_FOUND : EFI_UNSUPPORTED; - } - - CpuSaveState = (QEMU_SMRAM_SAVE_STATE_MAP *)gSmst->CpuSaveState[CpuIndex]; - - // - // Do not write non-writable SaveState, because it will cause exception. - // - if (!mSmmCpuWidthOffset[RegisterIndex].Writeable) { - return EFI_UNSUPPORTED; - } - - // - // Check CPU mode - // - if ((CpuSaveState->x86.SMMRevId & 0xFFFF) == 0) { - // - // If 32-bit mode width is zero, then the specified register can not be accessed - // - if (mSmmCpuWidthOffset[RegisterIndex].Width32 == 0) { - return EFI_NOT_FOUND; - } - - // - // If Width is bigger than the 32-bit mode width, then the specified register can not be accessed - // - if (Width > mSmmCpuWidthOffset[RegisterIndex].Width32) { - return EFI_INVALID_PARAMETER; - } - // - // Write SMM State register - // - ASSERT (CpuSaveState != NULL); - CopyMem((UINT8 *)CpuSaveState + mSmmCpuWidthOffset[RegisterIndex].Offset32, Buffer, Width); - } else { - // - // If 64-bit mode width is zero, then the specified register can not be accessed - // - if (mSmmCpuWidthOffset[RegisterIndex].Width64 == 0) { - return EFI_NOT_FOUND; - } - - // - // If Width is bigger than the 64-bit mode width, then the specified register can not be accessed - // - if (Width > mSmmCpuWidthOffset[RegisterIndex].Width64) { - return EFI_INVALID_PARAMETER; - } - - // - // Write lower 32-bits of SMM State register - // - CopyMem((UINT8 *)CpuSaveState + mSmmCpuWidthOffset[RegisterIndex].Offset64Lo, Buffer, MIN (4, Width)); - if (Width >= 4) { - // - // Write upper 32-bits of SMM State register - // - CopyMem((UINT8 *)CpuSaveState + mSmmCpuWidthOffset[RegisterIndex].Offset64Hi, (UINT8 *)Buffer + 4, Width - 4); - } - } - return EFI_SUCCESS; -} - -/** - This function is hook point called after the gEfiSmmReadyToLockProtocolGuid - notification is completely processed. -**/ -VOID -EFIAPI -SmmCpuFeaturesCompleteSmmReadyToLock ( - VOID - ) -{ -} - -/** - This API provides a method for a CPU to allocate a specific region for storing page tables. - - This API can be called more once to allocate memory for page tables. - - Allocates the number of 4KB pages of type EfiRuntimeServicesData and returns a pointer to the - allocated buffer. The buffer returned is aligned on a 4KB boundary. If Pages is 0, then NULL - is returned. If there is not enough memory remaining to satisfy the request, then NULL is - returned. - - This function can also return NULL if there is no preference on where the page tables are allocated in SMRAM. - - @param Pages The number of 4 KB pages to allocate. - - @return A pointer to the allocated buffer for page tables. - @retval NULL Fail to allocate a specific region for storing page tables, - Or there is no preference on where the page tables are allocated in SMRAM. - -**/ -VOID * -EFIAPI -SmmCpuFeaturesAllocatePageTableMemory ( - IN UINTN Pages - ) -{ - return NULL; -} - diff --git a/OvmfPkg/Library/SmmCpuFeaturesLib/SmmCpuFeaturesLib.inf b/OvmfPkg/Library/SmmCpuFeaturesLib/SmmCpuFeaturesLib.inf deleted file mode 100644 index 31edf3a9c1..0000000000 --- a/OvmfPkg/Library/SmmCpuFeaturesLib/SmmCpuFeaturesLib.inf +++ /dev/null @@ -1,38 +0,0 @@ -## @file -# The CPU specific programming for PiSmmCpuDxeSmm module. -# -# Copyright (c) 2009 - 2015, Intel Corporation. All rights reserved.
-# This program and the accompanying materials -# are licensed and made available under the terms and conditions of the BSD License -# which accompanies this distribution. The full text of the license may be found at -# http://opensource.org/licenses/bsd-license.php -# -# THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, -# WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. -# -## - -[Defines] - INF_VERSION = 0x00010005 - BASE_NAME = SmmCpuFeaturesLib - MODULE_UNI_FILE = SmmCpuFeaturesLib.uni - FILE_GUID = AC9991BE-D77A-464C-A8DE-A873DB8A4836 - MODULE_TYPE = DXE_SMM_DRIVER - VERSION_STRING = 1.0 - LIBRARY_CLASS = SmmCpuFeaturesLib - CONSTRUCTOR = SmmCpuFeaturesLibConstructor - -[Sources] - SmmCpuFeaturesLib.c - -[Packages] - MdePkg/MdePkg.dec - OvmfPkg/OvmfPkg.dec - UefiCpuPkg/UefiCpuPkg.dec - -[LibraryClasses] - BaseLib - BaseMemoryLib - PcdLib - DebugLib - SmmServicesTableLib diff --git a/OvmfPkg/Library/VirtioLib/VirtioLib.c b/OvmfPkg/Library/VirtioLib/VirtioLib.c deleted file mode 100644 index 845f206369..0000000000 --- a/OvmfPkg/Library/VirtioLib/VirtioLib.c +++ /dev/null @@ -1,416 +0,0 @@ -/** @file - - Utility functions used by virtio device drivers. - - Copyright (C) 2012-2016, Red Hat, Inc. - Portion of Copyright (C) 2013, ARM Ltd. - - This program and the accompanying materials are licensed and made available - under the terms and conditions of the BSD License which accompanies this - 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 -#include -#include -#include -#include - -#include - - -/** - - 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. - // - // Since we support only one in-flight descriptor chain, we can always build - // that chain starting at entry #0 of the descriptor table. - // - Indices->HeadDescIdx = 0; - Indices->NextDescIdx = Indices->HeadDescIdx; -} - - -/** - - Append a contiguous buffer for transmission / reception via the virtio ring. - - This function implements the following section from virtio-0.9.5: - - 2.4.1.1 Placing Buffers into the Descriptor Table - - 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. - - @param[in,out] Indices Indices->HeadDescIdx is not accessed. - On input, Indices->NextDescIdx identifies the next - descriptor to carry the buffer. On output, - Indices->NextDescIdx is incremented by one, modulo - 2^16. - -**/ -VOID -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->NextDescIdx++ % Ring->QueueSize]; - Desc->Addr = BufferPhysAddr; - Desc->Len = BufferSize; - Desc->Flags = Flags; - Desc->Next = Indices->NextDescIdx % Ring->QueueSize; -} - - -/** - - Notify the host about the descriptor chain just built, and wait until the - host processes it. - - @param[in] VirtIo The target virtio 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 Indices->NextDescIdx is not accessed. - Indices->HeadDescIdx identifies the head descriptor - of the descriptor chain. - - @param[out] UsedLen On success, the total number of bytes, consecutively - across the buffers linked by the descriptor chain, - that the host wrote. May be NULL if the caller - doesn't care, or can compute the same information - from device-specific request structures linked by the - descriptor chain. - - @return Error code from VirtIo->SetQueueNotify() if it fails. - - @retval EFI_SUCCESS Otherwise, the host processed all descriptors. - -**/ -EFI_STATUS -EFIAPI -VirtioFlush ( - IN VIRTIO_DEVICE_PROTOCOL *VirtIo, - IN UINT16 VirtQueueId, - IN OUT VRING *Ring, - IN DESC_INDICES *Indices, - OUT UINT32 *UsedLen OPTIONAL - ) -{ - UINT16 NextAvailIdx; - UINT16 LastUsedIdx; - EFI_STATUS Status; - UINTN PollPeriodUsecs; - - // - // virtio-0.9.5, 2.4.1.2 Updating the Available Ring - // - // It is not exactly clear from the wording of the virtio-0.9.5 - // specification, but each entry in the Available Ring references only the - // head descriptor of any given descriptor chain. - // - NextAvailIdx = *Ring->Avail.Idx; - // - // (Due to our lock-step progress, this is where the host will produce the - // used element with the head descriptor's index in it.) - // - LastUsedIdx = NextAvailIdx; - Ring->Avail.Ring[NextAvailIdx++ % Ring->QueueSize] = - Indices->HeadDescIdx % Ring->QueueSize; - - // - // virtio-0.9.5, 2.4.1.3 Updating the Index Field - // - MemoryFence(); - *Ring->Avail.Idx = NextAvailIdx; - - // - // virtio-0.9.5, 2.4.1.4 Notifying the Device -- gratuitous notifications are - // OK. - // - MemoryFence(); - Status = VirtIo->SetQueueNotify (VirtIo, 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 != NextAvailIdx) { - gBS->Stall (PollPeriodUsecs); // calls AcpiTimerLib::MicroSecondDelay - - if (PollPeriodUsecs < 1024) { - PollPeriodUsecs *= 2; - } - MemoryFence(); - } - - MemoryFence(); - - if (UsedLen != NULL) { - volatile CONST VRING_USED_ELEM *UsedElem; - - UsedElem = &Ring->Used.UsedElem[LastUsedIdx % Ring->QueueSize]; - ASSERT (UsedElem->Id == Indices->HeadDescIdx); - *UsedLen = UsedElem->Len; - } - - return EFI_SUCCESS; -} - - -/** - - Report the feature bits to the VirtIo 1.0 device that the VirtIo 1.0 driver - understands. - - In VirtIo 1.0, a device can reject a self-inconsistent feature bitmap through - the new VSTAT_FEATURES_OK status bit. (For example if the driver requests a - higher level feature but clears a prerequisite feature.) This function is a - small wrapper around VIRTIO_DEVICE_PROTOCOL.SetGuestFeatures() that also - verifies if the VirtIo 1.0 device accepts the feature bitmap. - - @param[in] VirtIo Report feature bits to this device. - - @param[in] Features The set of feature bits that the driver wishes - to report. The caller is responsible to perform - any masking before calling this function; the - value is directly written with - VIRTIO_DEVICE_PROTOCOL.SetGuestFeatures(). - - @param[in,out] DeviceStatus On input, the status byte most recently written - to the device's status register. On output (even - on error), DeviceStatus will be updated so that - it is suitable for further status bit - manipulation and writing to the device's status - register. - - @retval EFI_SUCCESS The device accepted the configuration in Features. - - @return EFI_UNSUPPORTED The device rejected the configuration in Features. - - @retval EFI_UNSUPPORTED VirtIo->Revision is smaller than 1.0.0. - - @return Error codes from the SetGuestFeatures(), - SetDeviceStatus(), GetDeviceStatus() member - functions. - -**/ -EFI_STATUS -EFIAPI -Virtio10WriteFeatures ( - IN VIRTIO_DEVICE_PROTOCOL *VirtIo, - IN UINT64 Features, - IN OUT UINT8 *DeviceStatus - ) -{ - EFI_STATUS Status; - - if (VirtIo->Revision < VIRTIO_SPEC_REVISION (1, 0, 0)) { - return EFI_UNSUPPORTED; - } - - Status = VirtIo->SetGuestFeatures (VirtIo, Features); - if (EFI_ERROR (Status)) { - return Status; - } - - *DeviceStatus |= VSTAT_FEATURES_OK; - Status = VirtIo->SetDeviceStatus (VirtIo, *DeviceStatus); - if (EFI_ERROR (Status)) { - return Status; - } - - Status = VirtIo->GetDeviceStatus (VirtIo, DeviceStatus); - if (EFI_ERROR (Status)) { - return Status; - } - - if ((*DeviceStatus & VSTAT_FEATURES_OK) == 0) { - Status = EFI_UNSUPPORTED; - } - - return Status; -} diff --git a/OvmfPkg/Library/VirtioLib/VirtioLib.inf b/OvmfPkg/Library/VirtioLib/VirtioLib.inf deleted file mode 100644 index fb5897a88e..0000000000 --- a/OvmfPkg/Library/VirtioLib/VirtioLib.inf +++ /dev/null @@ -1,36 +0,0 @@ -## @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/OvmfPkg/Library/VirtioMmioDeviceLib/VirtioMmioDevice.c b/OvmfPkg/Library/VirtioMmioDeviceLib/VirtioMmioDevice.c deleted file mode 100644 index b1d443ea70..0000000000 --- a/OvmfPkg/Library/VirtioMmioDeviceLib/VirtioMmioDevice.c +++ /dev/null @@ -1,223 +0,0 @@ -/** @file - - This driver produces Virtio Device Protocol instances for Virtio Mmio devices. - - Copyright (C) 2013, ARM Ltd. - - This program and the accompanying materials are licensed and made available - under the terms and conditions of the BSD License which accompanies this - distribution. The full text of the license may be found at - http://opensource.org/licenses/bsd-license.php - - THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, WITHOUT - WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. - -**/ - -#include -#include -#include - -#include "VirtioMmioDevice.h" - -static VIRTIO_DEVICE_PROTOCOL mMmioDeviceProtocolTemplate = { - 0, // Revision - 0, // SubSystemDeviceId - VirtioMmioGetDeviceFeatures, // GetDeviceFeatures - VirtioMmioSetGuestFeatures, // SetGuestFeatures - VirtioMmioSetQueueAddress, // SetQueueAddress - VirtioMmioSetQueueSel, // SetQueueSel - VirtioMmioSetQueueNotify, // SetQueueNotify - VirtioMmioSetQueueAlignment, // SetQueueAlign - VirtioMmioSetPageSize, // SetPageSize - VirtioMmioGetQueueSize, // GetQueueNumMax - VirtioMmioSetQueueSize, // SetQueueNum - VirtioMmioGetDeviceStatus, // GetDeviceStatus - VirtioMmioSetDeviceStatus, // SetDeviceStatus - VirtioMmioDeviceWrite, // WriteDevice - VirtioMmioDeviceRead // ReadDevice -}; - -/** - - Initialize the VirtIo MMIO Device - - @param[in] BaseAddress Base Address of the VirtIo MMIO Device - - @param[in, out] Device The driver instance to configure. - - @retval EFI_SUCCESS Setup complete. - - @retval EFI_UNSUPPORTED The driver is not a VirtIo MMIO device. - -**/ -STATIC -EFI_STATUS -EFIAPI -VirtioMmioInit ( - IN PHYSICAL_ADDRESS BaseAddress, - IN OUT VIRTIO_MMIO_DEVICE *Device - ) -{ - UINT32 MagicValue; - UINT32 VendorId; - UINT32 Version; - - // - // Initialize VirtIo Mmio Device - // - CopyMem (&Device->VirtioDevice, &mMmioDeviceProtocolTemplate, - sizeof (VIRTIO_DEVICE_PROTOCOL)); - Device->BaseAddress = BaseAddress; - Device->VirtioDevice.Revision = VIRTIO_SPEC_REVISION (0, 9, 5); - Device->VirtioDevice.SubSystemDeviceId = - MmioRead32 (BaseAddress + VIRTIO_MMIO_OFFSET_DEVICE_ID); - - // - // Double-check MMIO-specific values - // - MagicValue = VIRTIO_CFG_READ (Device, VIRTIO_MMIO_OFFSET_MAGIC); - if (MagicValue != VIRTIO_MMIO_MAGIC) { - return EFI_UNSUPPORTED; - } - - Version = VIRTIO_CFG_READ (Device, VIRTIO_MMIO_OFFSET_VERSION); - if (Version != 1) { - return EFI_UNSUPPORTED; - } - - // - // Double-check MMIO-specific values - // - VendorId = VIRTIO_CFG_READ (Device, VIRTIO_MMIO_OFFSET_VENDOR_ID); - if (VendorId != VIRTIO_VENDOR_ID) { - // - // The ARM Base and Foundation Models do not report a valid VirtIo VendorId. - // They return a value of 0x0 for the VendorId. - // - DEBUG((EFI_D_WARN, "VirtioMmioInit: Warning: The VendorId (0x%X) does not " - "match the VirtIo VendorId (0x%X).\n", - VendorId, VIRTIO_VENDOR_ID)); - } - - return EFI_SUCCESS; -} - - -/** - - Uninitialize the internals of a virtio-mmio device that has been successfully - set up with VirtioMmioInit(). - - @param[in, out] Device The device to clean up. - -**/ - -STATIC -VOID -EFIAPI -VirtioMmioUninit ( - IN VIRTIO_MMIO_DEVICE *Device - ) -{ - // - // Note: This function mirrors VirtioMmioInit() that does not allocate any - // resources - there's nothing to free here. - // -} - -EFI_STATUS -VirtioMmioInstallDevice ( - IN PHYSICAL_ADDRESS BaseAddress, - IN EFI_HANDLE Handle - ) -{ - EFI_STATUS Status; - VIRTIO_MMIO_DEVICE *VirtIo; - - if (!BaseAddress) { - return EFI_INVALID_PARAMETER; - } - if (Handle == NULL) { - return EFI_INVALID_PARAMETER; - } - - // - // Allocate VIRTIO_MMIO_DEVICE - // - VirtIo = AllocateZeroPool (sizeof (VIRTIO_MMIO_DEVICE)); - if (VirtIo == NULL) { - return EFI_OUT_OF_RESOURCES; - } - - VirtIo->Signature = VIRTIO_MMIO_DEVICE_SIGNATURE; - - Status = VirtioMmioInit (BaseAddress, VirtIo); - if (EFI_ERROR (Status)) { - goto FreeVirtioMem; - } - - // - // Install VIRTIO_DEVICE_PROTOCOL to Handle - // - Status = gBS->InstallProtocolInterface (&Handle, - &gVirtioDeviceProtocolGuid, EFI_NATIVE_INTERFACE, - &VirtIo->VirtioDevice); - if (EFI_ERROR (Status)) { - goto UninitVirtio; - } - - return EFI_SUCCESS; - -UninitVirtio: - VirtioMmioUninit (VirtIo); - -FreeVirtioMem: - FreePool (VirtIo); - return Status; -} - -EFI_STATUS -VirtioMmioUninstallDevice ( - IN EFI_HANDLE DeviceHandle - ) -{ - VIRTIO_DEVICE_PROTOCOL *VirtioDevice; - VIRTIO_MMIO_DEVICE *MmioDevice; - EFI_STATUS Status; - - Status = gBS->OpenProtocol ( - DeviceHandle, // candidate device - &gVirtioDeviceProtocolGuid, // retrieve the VirtIo iface - (VOID **)&VirtioDevice, // target pointer - DeviceHandle, // requestor driver identity - DeviceHandle, // requesting lookup for dev. - EFI_OPEN_PROTOCOL_GET_PROTOCOL // lookup only, no ref. added - ); - if (EFI_ERROR (Status)) { - return Status; - } - - // - // Get the MMIO device from the VirtIo Device instance - // - MmioDevice = VIRTIO_MMIO_DEVICE_FROM_VIRTIO_DEVICE (VirtioDevice); - - // - // Uninstall the protocol interface - // - Status = gBS->UninstallProtocolInterface (DeviceHandle, - &gVirtioDeviceProtocolGuid, &MmioDevice->VirtioDevice - ); - if (EFI_ERROR (Status)) { - return Status; - } - - // - // Uninitialize the VirtIo Device - // - VirtioMmioUninit (MmioDevice); - FreePool (MmioDevice); - - return EFI_SUCCESS; -} diff --git a/OvmfPkg/Library/VirtioMmioDeviceLib/VirtioMmioDevice.h b/OvmfPkg/Library/VirtioMmioDeviceLib/VirtioMmioDevice.h deleted file mode 100644 index 4130dbc043..0000000000 --- a/OvmfPkg/Library/VirtioMmioDeviceLib/VirtioMmioDevice.h +++ /dev/null @@ -1,140 +0,0 @@ -/** @file - - Internal definitions for the VirtIo MMIO Device driver - - Copyright (C) 2013, ARM Ltd - - This program and the accompanying materials are licensed and made available - under the terms and conditions of the BSD License which accompanies this - distribution. The full text of the license may be found at - http://opensource.org/licenses/bsd-license.php - - THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, WITHOUT - WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. - -**/ - -#ifndef _VIRTIO_MMIO_DEVICE_INTERNAL_H_ -#define _VIRTIO_MMIO_DEVICE_INTERNAL_H_ - -#include - -#include - -#include -#include -#include -#include - -#define VIRTIO_MMIO_DEVICE_SIGNATURE SIGNATURE_32 ('V', 'M', 'I', 'O') - -typedef struct { - UINT32 Signature; - VIRTIO_DEVICE_PROTOCOL VirtioDevice; - PHYSICAL_ADDRESS BaseAddress; -} VIRTIO_MMIO_DEVICE; - -#define VIRTIO_MMIO_DEVICE_FROM_VIRTIO_DEVICE(Device) \ - CR (Device, VIRTIO_MMIO_DEVICE, VirtioDevice, VIRTIO_MMIO_DEVICE_SIGNATURE) - -#define VIRTIO_CFG_WRITE(Device, Offset, Val) \ - (MmioWrite32 (Device->BaseAddress + (Offset), Val)) -#define VIRTIO_CFG_READ(Device, Offset) \ - (MmioRead32 (Device->BaseAddress + (Offset))) - -EFI_STATUS -EFIAPI -VirtioMmioDeviceRead ( - IN VIRTIO_DEVICE_PROTOCOL *This, - IN UINTN FieldOFfset, - IN UINTN FieldSize, - IN UINTN BufferSize, - OUT VOID* Buffer - ); - -EFI_STATUS -EFIAPI -VirtioMmioDeviceWrite ( - IN VIRTIO_DEVICE_PROTOCOL *This, - IN UINTN FieldOffset, - IN UINTN FieldSize, - IN UINT64 Value - ); - -EFI_STATUS -EFIAPI -VirtioMmioGetDeviceFeatures ( - IN VIRTIO_DEVICE_PROTOCOL *This, - OUT UINT64 *DeviceFeatures - ); - -EFI_STATUS -EFIAPI -VirtioMmioGetQueueSize ( - IN VIRTIO_DEVICE_PROTOCOL *This, - OUT UINT16 *QueueNumMax - ); - -EFI_STATUS -EFIAPI -VirtioMmioGetDeviceStatus ( - IN VIRTIO_DEVICE_PROTOCOL *This, - OUT UINT8 *DeviceStatus - ); - -EFI_STATUS -EFIAPI -VirtioMmioSetQueueSize ( - VIRTIO_DEVICE_PROTOCOL *This, - UINT16 QueueSize - ); - -EFI_STATUS -EFIAPI -VirtioMmioSetDeviceStatus ( - VIRTIO_DEVICE_PROTOCOL *This, - UINT8 DeviceStatus - ); - -EFI_STATUS -EFIAPI -VirtioMmioSetQueueNotify ( - VIRTIO_DEVICE_PROTOCOL *This, - UINT16 QueueNotify - ); - -EFI_STATUS -EFIAPI -VirtioMmioSetQueueSel ( - VIRTIO_DEVICE_PROTOCOL *This, - UINT16 Sel - ); - -EFI_STATUS -VirtioMmioSetQueueAddress ( - IN VIRTIO_DEVICE_PROTOCOL *This, - IN VRING *Ring - ); - -EFI_STATUS -EFIAPI -VirtioMmioSetQueueAlignment ( - VIRTIO_DEVICE_PROTOCOL *This, - UINT32 Alignment - ); - -EFI_STATUS -EFIAPI -VirtioMmioSetPageSize ( - VIRTIO_DEVICE_PROTOCOL *This, - UINT32 PageSize - ); - -EFI_STATUS -EFIAPI -VirtioMmioSetGuestFeatures ( - VIRTIO_DEVICE_PROTOCOL *This, - UINT64 Features - ); - -#endif // _VIRTIO_MMIO_DEVICE_INTERNAL_H_ diff --git a/OvmfPkg/Library/VirtioMmioDeviceLib/VirtioMmioDeviceFunctions.c b/OvmfPkg/Library/VirtioMmioDeviceLib/VirtioMmioDeviceFunctions.c deleted file mode 100644 index 53c734f6b1..0000000000 --- a/OvmfPkg/Library/VirtioMmioDeviceLib/VirtioMmioDeviceFunctions.c +++ /dev/null @@ -1,295 +0,0 @@ -/** @file - - This driver produces Virtio Device Protocol instances for Virtio MMIO devices. - - Copyright (C) 2012, Red Hat, Inc. - Copyright (c) 2012, Intel Corporation. All rights reserved.
- Copyright (C) 2013, ARM Ltd. - - This program and the accompanying materials are licensed and made available - under the terms and conditions of the BSD License which accompanies this - distribution. The full text of the license may be found at - http://opensource.org/licenses/bsd-license.php - - THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, WITHOUT - WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. - -**/ - -#include "VirtioMmioDevice.h" - -EFI_STATUS -EFIAPI -VirtioMmioGetDeviceFeatures ( - IN VIRTIO_DEVICE_PROTOCOL *This, - OUT UINT64 *DeviceFeatures - ) -{ - VIRTIO_MMIO_DEVICE *Device; - - if (DeviceFeatures == NULL) { - return EFI_INVALID_PARAMETER; - } - - Device = VIRTIO_MMIO_DEVICE_FROM_VIRTIO_DEVICE (This); - - *DeviceFeatures = VIRTIO_CFG_READ (Device, VIRTIO_MMIO_OFFSET_HOST_FEATURES); - - return EFI_SUCCESS; -} - -EFI_STATUS -EFIAPI -VirtioMmioGetQueueSize ( - IN VIRTIO_DEVICE_PROTOCOL *This, - OUT UINT16 *QueueNumMax - ) -{ - VIRTIO_MMIO_DEVICE *Device; - - if (QueueNumMax == NULL) { - return EFI_INVALID_PARAMETER; - } - - Device = VIRTIO_MMIO_DEVICE_FROM_VIRTIO_DEVICE (This); - - *QueueNumMax = VIRTIO_CFG_READ (Device, VIRTIO_MMIO_OFFSET_QUEUE_NUM_MAX) & 0xFFFF; - - return EFI_SUCCESS; -} - -EFI_STATUS -EFIAPI -VirtioMmioGetDeviceStatus ( - IN VIRTIO_DEVICE_PROTOCOL *This, - OUT UINT8 *DeviceStatus - ) -{ - VIRTIO_MMIO_DEVICE *Device; - - if (DeviceStatus == NULL) { - return EFI_INVALID_PARAMETER; - } - - Device = VIRTIO_MMIO_DEVICE_FROM_VIRTIO_DEVICE (This); - - *DeviceStatus = VIRTIO_CFG_READ (Device, VIRTIO_MMIO_OFFSET_STATUS) & 0xFF; - - return EFI_SUCCESS; -} - -EFI_STATUS -EFIAPI -VirtioMmioSetQueueSize ( - VIRTIO_DEVICE_PROTOCOL *This, - UINT16 QueueSize - ) -{ - VIRTIO_MMIO_DEVICE *Device; - - Device = VIRTIO_MMIO_DEVICE_FROM_VIRTIO_DEVICE (This); - - VIRTIO_CFG_WRITE (Device, VIRTIO_MMIO_OFFSET_QUEUE_NUM, QueueSize); - - return EFI_SUCCESS; -} - -EFI_STATUS -EFIAPI -VirtioMmioSetDeviceStatus ( - VIRTIO_DEVICE_PROTOCOL *This, - UINT8 DeviceStatus - ) -{ - VIRTIO_MMIO_DEVICE *Device; - - Device = VIRTIO_MMIO_DEVICE_FROM_VIRTIO_DEVICE (This); - - VIRTIO_CFG_WRITE (Device, VIRTIO_MMIO_OFFSET_STATUS, DeviceStatus); - - return EFI_SUCCESS; -} - -EFI_STATUS -EFIAPI -VirtioMmioSetQueueNotify ( - VIRTIO_DEVICE_PROTOCOL *This, - UINT16 QueueNotify - ) -{ - VIRTIO_MMIO_DEVICE *Device; - - Device = VIRTIO_MMIO_DEVICE_FROM_VIRTIO_DEVICE (This); - - VIRTIO_CFG_WRITE (Device, VIRTIO_MMIO_OFFSET_QUEUE_NOTIFY, QueueNotify); - - return EFI_SUCCESS; -} - -EFI_STATUS -EFIAPI -VirtioMmioSetQueueAlignment ( - VIRTIO_DEVICE_PROTOCOL *This, - UINT32 Alignment - ) -{ - VIRTIO_MMIO_DEVICE *Device; - - Device = VIRTIO_MMIO_DEVICE_FROM_VIRTIO_DEVICE (This); - - VIRTIO_CFG_WRITE (Device, VIRTIO_MMIO_OFFSET_QUEUE_ALIGN, Alignment); - - return EFI_SUCCESS; -} - -EFI_STATUS -EFIAPI -VirtioMmioSetPageSize ( - VIRTIO_DEVICE_PROTOCOL *This, - UINT32 PageSize - ) -{ - VIRTIO_MMIO_DEVICE *Device; - - if (PageSize != EFI_PAGE_SIZE) { - return EFI_UNSUPPORTED; - } - - Device = VIRTIO_MMIO_DEVICE_FROM_VIRTIO_DEVICE (This); - - VIRTIO_CFG_WRITE (Device, VIRTIO_MMIO_OFFSET_GUEST_PAGE_SIZE, PageSize); - - return EFI_SUCCESS; -} - -EFI_STATUS -EFIAPI -VirtioMmioSetQueueSel ( - VIRTIO_DEVICE_PROTOCOL *This, - UINT16 Sel - ) -{ - VIRTIO_MMIO_DEVICE *Device; - - Device = VIRTIO_MMIO_DEVICE_FROM_VIRTIO_DEVICE (This); - - VIRTIO_CFG_WRITE (Device, VIRTIO_MMIO_OFFSET_QUEUE_SEL, Sel); - - return EFI_SUCCESS; -} - -EFI_STATUS -VirtioMmioSetQueueAddress ( - IN VIRTIO_DEVICE_PROTOCOL *This, - IN VRING *Ring - ) -{ - VIRTIO_MMIO_DEVICE *Device; - - Device = VIRTIO_MMIO_DEVICE_FROM_VIRTIO_DEVICE (This); - - VIRTIO_CFG_WRITE (Device, VIRTIO_MMIO_OFFSET_QUEUE_PFN, - (UINT32)((UINTN)Ring->Base >> EFI_PAGE_SHIFT)); - - return EFI_SUCCESS; -} - -EFI_STATUS -EFIAPI -VirtioMmioSetGuestFeatures ( - VIRTIO_DEVICE_PROTOCOL *This, - UINT64 Features - ) -{ - VIRTIO_MMIO_DEVICE *Device; - - Device = VIRTIO_MMIO_DEVICE_FROM_VIRTIO_DEVICE (This); - - if (Features > MAX_UINT32) { - return EFI_UNSUPPORTED; - } - VIRTIO_CFG_WRITE (Device, VIRTIO_MMIO_OFFSET_GUEST_FEATURES, - (UINT32)Features); - - return EFI_SUCCESS; -} - -EFI_STATUS -EFIAPI -VirtioMmioDeviceWrite ( - IN VIRTIO_DEVICE_PROTOCOL *This, - IN UINTN FieldOffset, - IN UINTN FieldSize, - IN UINT64 Value - ) -{ - UINTN DstBaseAddress; - VIRTIO_MMIO_DEVICE *Device; - - Device = VIRTIO_MMIO_DEVICE_FROM_VIRTIO_DEVICE (This); - - // - // Double-check fieldsize - // - if ((FieldSize != 1) && (FieldSize != 2) && - (FieldSize != 4) && (FieldSize != 8)) { - return EFI_INVALID_PARAMETER; - } - - // - // Compute base address - // - DstBaseAddress = Device->BaseAddress + - VIRTIO_DEVICE_SPECIFIC_CONFIGURATION_OFFSET_MMIO + FieldOffset; - - // - // The device-specific memory area of Virtio-MMIO can only be written in - // byte accesses. This is not currently in the Virtio spec. - // - MmioWriteBuffer8 (DstBaseAddress, FieldSize, (UINT8*)&Value); - - return EFI_SUCCESS; -} - -EFI_STATUS -EFIAPI -VirtioMmioDeviceRead ( - IN VIRTIO_DEVICE_PROTOCOL *This, - IN UINTN FieldOffset, - IN UINTN FieldSize, - IN UINTN BufferSize, - OUT VOID *Buffer - ) -{ - UINTN SrcBaseAddress; - VIRTIO_MMIO_DEVICE *Device; - - Device = VIRTIO_MMIO_DEVICE_FROM_VIRTIO_DEVICE (This); - - // - // Parameter validation - // - ASSERT (FieldSize == BufferSize); - - // - // Double-check fieldsize - // - if ((FieldSize != 1) && (FieldSize != 2) && - (FieldSize != 4) && (FieldSize != 8)) { - return EFI_INVALID_PARAMETER; - } - - // - // Compute base address - // - SrcBaseAddress = Device->BaseAddress + - VIRTIO_DEVICE_SPECIFIC_CONFIGURATION_OFFSET_MMIO + FieldOffset; - - // - // The device-specific memory area of Virtio-MMIO can only be read in - // byte reads. This is not currently in the Virtio spec. - // - MmioReadBuffer8 (SrcBaseAddress, BufferSize, Buffer); - - return EFI_SUCCESS; -} diff --git a/OvmfPkg/Library/VirtioMmioDeviceLib/VirtioMmioDeviceLib.inf b/OvmfPkg/Library/VirtioMmioDeviceLib/VirtioMmioDeviceLib.inf deleted file mode 100644 index 2e266a9d45..0000000000 --- a/OvmfPkg/Library/VirtioMmioDeviceLib/VirtioMmioDeviceLib.inf +++ /dev/null @@ -1,42 +0,0 @@ -## @file -# This driver produces the VirtIo Device Protocol instances for VirtIo Mmio -# Device -# -# Copyright (C) 2013, ARM Ltd -# -# This program and the accompanying materials are licensed and made available -# under the terms and conditions of the BSD License which accompanies this -# distribution. The full text of the license may be found at -# http://opensource.org/licenses/bsd-license.php -# -# THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, WITHOUT -# WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. -# -## - -[Defines] - INF_VERSION = 0x00010006 - BASE_NAME = VirtioMmioDeviceLib - FILE_GUID = 3b6ed966-b5d1-46a8-965b-867ff22d9c89 - MODULE_TYPE = UEFI_DRIVER - VERSION_STRING = 1.0 - LIBRARY_CLASS = VirtioMmioDeviceLib - -[Sources] - VirtioMmioDevice.c - VirtioMmioDeviceFunctions.c - -[Packages] - MdePkg/MdePkg.dec - OvmfPkg/OvmfPkg.dec - -[LibraryClasses] - BaseMemoryLib - DebugLib - IoLib - MemoryAllocationLib - UefiBootServicesTableLib - UefiLib - -[Protocols] - gVirtioDeviceProtocolGuid ## PRODUCES diff --git a/OvmfPkg/Library/XenConsoleSerialPortLib/XenConsoleSerialPortLib.c b/OvmfPkg/Library/XenConsoleSerialPortLib/XenConsoleSerialPortLib.c deleted file mode 100644 index 4a63b86047..0000000000 --- a/OvmfPkg/Library/XenConsoleSerialPortLib/XenConsoleSerialPortLib.c +++ /dev/null @@ -1,301 +0,0 @@ -/** @file - Xen console SerialPortLib instance - - Copyright (c) 2015, Linaro Ltd. All rights reserved.
- Copyright (c) 2015, Intel Corporation. All rights reserved.
- - This program and the accompanying materials - are licensed and made available under the terms and conditions of the BSD License - which accompanies this distribution. The full text of the license may be found at - http://opensource.org/licenses/bsd-license.php - - THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, - WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. - -**/ - -#include - -#include -#include -#include - -#include -#include -#include - -// -// We can't use DebugLib due to a constructor dependency cycle between DebugLib -// and ourselves. -// -#define ASSERT(Expression) \ - do { \ - if (!(Expression)) { \ - CpuDeadLoop (); \ - } \ - } while (FALSE) - -// -// The code below expects these global variables to be mutable, even in the case -// that we have been incorporated into SEC or PEIM phase modules (which is -// allowed by our INF description). While this is a dangerous assumption to make -// in general, it is actually fine for the Xen domU (guest) environment that -// this module is intended for, as UEFI always executes from DRAM in that case. -// -STATIC evtchn_send_t mXenConsoleEventChain; -STATIC struct xencons_interface *mXenConsoleInterface; - -/** - Initialize the serial device hardware. - - If no initialization is required, then return RETURN_SUCCESS. - If the serial device was successfully initialized, then return RETURN_SUCCESS. - If the serial device could not be initialized, then return RETURN_DEVICE_ERROR. - - @retval RETURN_SUCCESS The serial device was initialized. - @retval RETURN_DEVICE_ERROR The serial device could not be initialized. - -**/ -RETURN_STATUS -EFIAPI -SerialPortInitialize ( - VOID - ) -{ - if (! XenHypercallIsAvailable ()) { - return RETURN_DEVICE_ERROR; - } - - if (!mXenConsoleInterface) { - mXenConsoleEventChain.port = (UINT32)XenHypercallHvmGetParam (HVM_PARAM_CONSOLE_EVTCHN); - mXenConsoleInterface = (struct xencons_interface *)(UINTN) - (XenHypercallHvmGetParam (HVM_PARAM_CONSOLE_PFN) << EFI_PAGE_SHIFT); - - // - // No point in ASSERT'ing here as we won't be seeing the output - // - } - return RETURN_SUCCESS; -} - -/** - Write data from buffer to serial device. - - Writes NumberOfBytes data bytes from Buffer to the serial device. - The number of bytes actually written to the serial device is returned. - If the return value is less than NumberOfBytes, then the write operation failed. - If Buffer is NULL, then ASSERT(). - If NumberOfBytes is zero, then return 0. - - @param Buffer Pointer to the data buffer to be written. - @param NumberOfBytes Number of bytes to written to the serial device. - - @retval 0 NumberOfBytes is 0. - @retval >0 The number of bytes written to the serial device. - If this value is less than NumberOfBytes, then the write operation failed. - -**/ -UINTN -EFIAPI -SerialPortWrite ( - IN UINT8 *Buffer, - IN UINTN NumberOfBytes - ) -{ - XENCONS_RING_IDX Consumer, Producer; - UINTN Sent; - - ASSERT (Buffer != NULL); - - if (NumberOfBytes == 0) { - return 0; - } - - if (!mXenConsoleInterface) { - return 0; - } - - Sent = 0; - do { - Consumer = mXenConsoleInterface->out_cons; - Producer = mXenConsoleInterface->out_prod; - - MemoryFence (); - - while (Sent < NumberOfBytes && ((Producer - Consumer) < sizeof (mXenConsoleInterface->out))) - mXenConsoleInterface->out[MASK_XENCONS_IDX(Producer++, mXenConsoleInterface->out)] = Buffer[Sent++]; - - MemoryFence (); - - mXenConsoleInterface->out_prod = Producer; - - XenHypercallEventChannelOp (EVTCHNOP_send, &mXenConsoleEventChain); - - } while (Sent < NumberOfBytes); - - return Sent; -} - -/** - Read data from serial device and save the datas in buffer. - - Reads NumberOfBytes data bytes from a serial device into the buffer - specified by Buffer. The number of bytes actually read is returned. - If Buffer is NULL, then ASSERT(). - If NumberOfBytes is zero, then return 0. - - @param Buffer Pointer to the data buffer to store the data read from the serial device. - @param NumberOfBytes Number of bytes which will be read. - - @retval 0 Read data failed, no data is to be read. - @retval >0 Actual number of bytes read from serial device. - -**/ -UINTN -EFIAPI -SerialPortRead ( - OUT UINT8 *Buffer, - IN UINTN NumberOfBytes -) -{ - XENCONS_RING_IDX Consumer, Producer; - UINTN Received; - - ASSERT (Buffer != NULL); - - if (NumberOfBytes == 0) { - return 0; - } - - if (!mXenConsoleInterface) { - return 0; - } - - Consumer = mXenConsoleInterface->in_cons; - Producer = mXenConsoleInterface->in_prod; - - MemoryFence (); - - Received = 0; - while (Received < NumberOfBytes && Consumer < Producer) - Buffer[Received++] = mXenConsoleInterface->in[MASK_XENCONS_IDX(Consumer++, mXenConsoleInterface->in)]; - - MemoryFence (); - - mXenConsoleInterface->in_cons = Consumer; - - XenHypercallEventChannelOp (EVTCHNOP_send, &mXenConsoleEventChain); - - return Received; -} - -/** - Polls a serial device to see if there is any data waiting to be read. - - @retval TRUE Data is waiting to be read from the serial device. - @retval FALSE There is no data waiting to be read from the serial device. - -**/ -BOOLEAN -EFIAPI -SerialPortPoll ( - VOID - ) -{ - return mXenConsoleInterface && - mXenConsoleInterface->in_cons != mXenConsoleInterface->in_prod; -} - -/** - Sets the control bits on a serial device. - - @param Control Sets the bits of Control that are settable. - - @retval RETURN_SUCCESS The new control bits were set on the serial device. - @retval RETURN_UNSUPPORTED The serial device does not support this operation. - @retval RETURN_DEVICE_ERROR The serial device is not functioning correctly. - -**/ -RETURN_STATUS -EFIAPI -SerialPortSetControl ( - IN UINT32 Control - ) -{ - return RETURN_UNSUPPORTED; -} - -/** - Retrieve the status of the control bits on a serial device. - - @param Control A pointer to return the current control signals from the serial device. - - @retval RETURN_SUCCESS The control bits were read from the serial device. - @retval RETURN_UNSUPPORTED The serial device does not support this operation. - @retval RETURN_DEVICE_ERROR The serial device is not functioning correctly. - -**/ -RETURN_STATUS -EFIAPI -SerialPortGetControl ( - OUT UINT32 *Control - ) -{ - if (!mXenConsoleInterface) { - return RETURN_UNSUPPORTED; - } - - *Control = 0; - if (!SerialPortPoll ()) { - *Control = EFI_SERIAL_INPUT_BUFFER_EMPTY; - } - return RETURN_SUCCESS; -} - -/** - Sets the baud rate, receive FIFO depth, transmit/receice time out, parity, - data bits, and stop bits on a serial device. - - @param BaudRate The requested baud rate. A BaudRate value of 0 will use the - device's default interface speed. - On output, the value actually set. - @param ReveiveFifoDepth The requested depth of the FIFO on the receive side of the - serial interface. A ReceiveFifoDepth value of 0 will use - the device's default FIFO depth. - On output, the value actually set. - @param Timeout The requested time out for a single character in microseconds. - This timeout applies to both the transmit and receive side of the - interface. A Timeout value of 0 will use the device's default time - out value. - On output, the value actually set. - @param Parity The type of parity to use on this serial device. A Parity value of - DefaultParity will use the device's default parity value. - On output, the value actually set. - @param DataBits The number of data bits to use on the serial device. A DataBits - vaule of 0 will use the device's default data bit setting. - On output, the value actually set. - @param StopBits The number of stop bits to use on this serial device. A StopBits - value of DefaultStopBits will use the device's default number of - stop bits. - On output, the value actually set. - - @retval RETURN_SUCCESS The new attributes were set on the serial device. - @retval RETURN_UNSUPPORTED The serial device does not support this operation. - @retval RETURN_INVALID_PARAMETER One or more of the attributes has an unsupported value. - @retval RETURN_DEVICE_ERROR The serial device is not functioning correctly. - -**/ -RETURN_STATUS -EFIAPI -SerialPortSetAttributes ( - IN OUT UINT64 *BaudRate, - IN OUT UINT32 *ReceiveFifoDepth, - IN OUT UINT32 *Timeout, - IN OUT EFI_PARITY_TYPE *Parity, - IN OUT UINT8 *DataBits, - IN OUT EFI_STOP_BITS_TYPE *StopBits - ) -{ - return RETURN_UNSUPPORTED; -} - diff --git a/OvmfPkg/Library/XenConsoleSerialPortLib/XenConsoleSerialPortLib.inf b/OvmfPkg/Library/XenConsoleSerialPortLib/XenConsoleSerialPortLib.inf deleted file mode 100644 index 8a7411558f..0000000000 --- a/OvmfPkg/Library/XenConsoleSerialPortLib/XenConsoleSerialPortLib.inf +++ /dev/null @@ -1,35 +0,0 @@ -#/** @file -# -# Component description file for XenConsoleSerialPortLib module -# -# Copyright (c) 2015, Linaro Ltd. 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. -# -#**/ - -[Defines] - INF_VERSION = 0x00010005 - BASE_NAME = XenConsoleSerialPortLib - FILE_GUID = 401406DD-BCAC-4B91-9F4E-72A7FEBE4762 - MODULE_TYPE = BASE - VERSION_STRING = 1.0 - LIBRARY_CLASS = SerialPortLib - CONSTRUCTOR = SerialPortInitialize - -[Sources.common] - XenConsoleSerialPortLib.c - -[LibraryClasses] - BaseLib - XenHypercallLib - -[Packages] - MdePkg/MdePkg.dec - OvmfPkg/OvmfPkg.dec diff --git a/OvmfPkg/Library/XenHypercallLib/Aarch64/Hypercall.S b/OvmfPkg/Library/XenHypercallLib/Aarch64/Hypercall.S deleted file mode 100644 index b1b5d4cc3f..0000000000 --- a/OvmfPkg/Library/XenHypercallLib/Aarch64/Hypercall.S +++ /dev/null @@ -1,26 +0,0 @@ - -/** @file - AArch64 implementation of XenHypercall2 - - Copyright (C) 2014, Linaro Ltd. - - This program and the accompanying materials - are licensed and made available under the terms and conditions of the BSD License - which accompanies this distribution. The full text of the license may be found at - http://opensource.org/licenses/bsd-license.php - - THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, - WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. - -**/ - -#include - - .text - .global ASM_PFX(XenHypercall2) -ASM_PFX(XenHypercall2): - mov x16, x0 - mov x0, x1 - mov x1, x2 - hvc #XEN_HYPERCALL_TAG - ret diff --git a/OvmfPkg/Library/XenHypercallLib/Arm/Hypercall.S b/OvmfPkg/Library/XenHypercallLib/Arm/Hypercall.S deleted file mode 100644 index c12c8658b7..0000000000 --- a/OvmfPkg/Library/XenHypercallLib/Arm/Hypercall.S +++ /dev/null @@ -1,26 +0,0 @@ -/** @file - ARM (AArch32) implementation of XenHypercall2 - - Copyright (C) 2014, Linaro Ltd. - - This program and the accompanying materials - are licensed and made available under the terms and conditions of the BSD License - which accompanies this distribution. The full text of the license may be found at - http://opensource.org/licenses/bsd-license.php - - THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, - WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. - -**/ - -#include - - .text -GCC_ASM_EXPORT(XenHypercall2) - -ASM_PFX(XenHypercall2): - mov r12, r0 - mov r0, r1 - mov r1, r2 - hvc #XEN_HYPERCALL_TAG - bx lr diff --git a/OvmfPkg/Library/XenHypercallLib/ArmXenHypercall.c b/OvmfPkg/Library/XenHypercallLib/ArmXenHypercall.c deleted file mode 100644 index 58cd3ec76b..0000000000 --- a/OvmfPkg/Library/XenHypercallLib/ArmXenHypercall.c +++ /dev/null @@ -1,44 +0,0 @@ -/** @file - Xen Hypercall Library implementation for ARM architecture - - Copyright (C) 2015, Red Hat, Inc. - Copyright (c) 2014, Linaro Ltd. All rights reserved.
- - This program and the accompanying materials are licensed and made available - under the terms and conditions of the BSD License that accompanies this - distribution. The full text of the license may be found at - http://opensource.org/licenses/bsd-license.php. - - THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, WITHOUT - WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. -**/ - -#include - -/** - Check if the Xen Hypercall library is able to make calls to the Xen - hypervisor. - - Client code should call further functions in this library only if, and after, - this function returns TRUE. - - @retval TRUE Hypercalls are available. - @retval FALSE Hypercalls are not available. -**/ -BOOLEAN -EFIAPI -XenHypercallIsAvailable ( - VOID - ) -{ - return TRUE; -} - -RETURN_STATUS -EFIAPI -XenHypercallLibInit ( - VOID - ) -{ - return RETURN_SUCCESS; -} diff --git a/OvmfPkg/Library/XenHypercallLib/Ia32/hypercall.nasm b/OvmfPkg/Library/XenHypercallLib/Ia32/hypercall.nasm deleted file mode 100644 index e0fa71bb5b..0000000000 --- a/OvmfPkg/Library/XenHypercallLib/Ia32/hypercall.nasm +++ /dev/null @@ -1,25 +0,0 @@ -SECTION .text - -; INTN -; EFIAPI -; __XenHypercall2 ( -; IN VOID *HypercallAddr, -; IN OUT INTN Arg1, -; IN OUT INTN Arg2 -; ); -global ASM_PFX(__XenHypercall2) -ASM_PFX(__XenHypercall2): - ; Save only ebx, ecx is supposed to be a scratch register and needs to be - ; saved by the caller - push ebx - ; Copy HypercallAddr to eax - mov eax, [esp + 8] - ; Copy Arg1 to the register expected by Xen - mov ebx, [esp + 12] - ; Copy Arg2 to the register expected by Xen - mov ecx, [esp + 16] - ; Call HypercallAddr - call eax - pop ebx - ret - diff --git a/OvmfPkg/Library/XenHypercallLib/X64/hypercall.nasm b/OvmfPkg/Library/XenHypercallLib/X64/hypercall.nasm deleted file mode 100644 index 5e6a0c05c5..0000000000 --- a/OvmfPkg/Library/XenHypercallLib/X64/hypercall.nasm +++ /dev/null @@ -1,26 +0,0 @@ -DEFAULT REL -SECTION .text - -; INTN -; EFIAPI -; __XenHypercall2 ( -; IN VOID *HypercallAddr, -; IN OUT INTN Arg1, -; IN OUT INTN Arg2 -; ); -global ASM_PFX(__XenHypercall2) -ASM_PFX(__XenHypercall2): - push rdi - push rsi - ; Copy HypercallAddr to rax - mov rax, rcx - ; Copy Arg1 to the register expected by Xen - mov rdi, rdx - ; Copy Arg2 to the register expected by Xen - mov rsi, r8 - ; Call HypercallAddr - call rax - pop rsi - pop rdi - ret - diff --git a/OvmfPkg/Library/XenHypercallLib/X86XenHypercall.c b/OvmfPkg/Library/XenHypercallLib/X86XenHypercall.c deleted file mode 100644 index 7cb7f46c9b..0000000000 --- a/OvmfPkg/Library/XenHypercallLib/X86XenHypercall.c +++ /dev/null @@ -1,102 +0,0 @@ -/** @file - Xen Hypercall Library implementation for Intel architecture - -Copyright (c) 2014, Linaro Ltd. All rights reserved.
-This program and the accompanying materials are licensed and made available under -the terms and conditions of the BSD License that accompanies this distribution. -The full text of the license may be found at -http://opensource.org/licenses/bsd-license.php. - -THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, -WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. - -**/ - -#include -#include -#include -#include - -STATIC VOID *HyperPage; - -/** - Check if the Xen Hypercall library is able to make calls to the Xen - hypervisor. - - Client code should call further functions in this library only if, and after, - this function returns TRUE. - - @retval TRUE Hypercalls are available. - @retval FALSE Hypercalls are not available. -**/ -BOOLEAN -EFIAPI -XenHypercallIsAvailable ( - VOID - ) -{ - return HyperPage != NULL; -} - -// -// Interface exposed by the ASM implementation of the core hypercall -// -INTN -EFIAPI -__XenHypercall2 ( - IN VOID *HypercallAddr, - IN OUT INTN Arg1, - IN OUT INTN Arg2 - ); - -/** - Library constructor: retrieves the Hyperpage address - from the gEfiXenInfoGuid HOB -**/ - -RETURN_STATUS -EFIAPI -XenHypercallLibInit ( - VOID - ) -{ - EFI_HOB_GUID_TYPE *GuidHob; - EFI_XEN_INFO *XenInfo; - - GuidHob = GetFirstGuidHob (&gEfiXenInfoGuid); - if (GuidHob == NULL) { - // - // We don't fail library construction, since that has catastrophic - // consequences for client modules (whereas those modules may easily be - // running on a non-Xen platform). Instead, XenHypercallIsAvailable() above - // will return FALSE. - // - return RETURN_SUCCESS; - } - XenInfo = (EFI_XEN_INFO *) GET_GUID_HOB_DATA (GuidHob); - HyperPage = XenInfo->HyperPages; - return RETURN_SUCCESS; -} - -/** - This function will put the two arguments in the right place (registers) and - invoke the hypercall identified by HypercallID. - - @param HypercallID The symbolic ID of the hypercall to be invoked - @param Arg1 First argument. - @param Arg2 Second argument. - - @return Return 0 if success otherwise it return an errno. -**/ -INTN -EFIAPI -XenHypercall2 ( - IN UINTN HypercallID, - IN OUT INTN Arg1, - IN OUT INTN Arg2 - ) -{ - ASSERT (HyperPage != NULL); - - return __XenHypercall2 ((UINT8*)HyperPage + HypercallID * 32, Arg1, Arg2); -} diff --git a/OvmfPkg/Library/XenHypercallLib/XenHypercall.c b/OvmfPkg/Library/XenHypercallLib/XenHypercall.c deleted file mode 100644 index 5ea5c45818..0000000000 --- a/OvmfPkg/Library/XenHypercallLib/XenHypercall.c +++ /dev/null @@ -1,66 +0,0 @@ -/** @file - Functions to make Xen hypercalls. - - Copyright (C) 2014, Citrix Ltd. - - This program and the accompanying materials - are licensed and made available under the terms and conditions of the BSD License - which accompanies this distribution. The full text of the license may be found at - http://opensource.org/licenses/bsd-license.php - - THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, - WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. - -**/ - -#include - -#include -#include - -#include -#include - -UINT64 -EFIAPI -XenHypercallHvmGetParam ( - IN UINT32 Index - ) -{ - xen_hvm_param_t Parameter; - INTN Error; - - Parameter.domid = DOMID_SELF; - Parameter.index = Index; - Error = XenHypercall2 (__HYPERVISOR_hvm_op, - HVMOP_get_param, (INTN) &Parameter); - if (Error != 0) { - DEBUG ((EFI_D_ERROR, - "XenHypercall: Error %Ld trying to get HVM parameter %d\n", - (INT64)Error, Index)); - return 0; - } - return Parameter.value; -} - -INTN -EFIAPI -XenHypercallMemoryOp ( - IN UINTN Operation, - IN OUT VOID *Arguments - ) -{ - return XenHypercall2 (__HYPERVISOR_memory_op, - Operation, (INTN) Arguments); -} - -INTN -EFIAPI -XenHypercallEventChannelOp ( - IN INTN Operation, - IN OUT VOID *Arguments - ) -{ - return XenHypercall2 (__HYPERVISOR_event_channel_op, - Operation, (INTN) Arguments); -} diff --git a/OvmfPkg/Library/XenHypercallLib/XenHypercallLib.inf b/OvmfPkg/Library/XenHypercallLib/XenHypercallLib.inf deleted file mode 100644 index f4503a4b01..0000000000 --- a/OvmfPkg/Library/XenHypercallLib/XenHypercallLib.inf +++ /dev/null @@ -1,66 +0,0 @@ -## @file -# Xen Hypercall abstraction lib for Intel and ARM architectures -# -# Copyright (c) 2014, Linaro Ltd. 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. -# -## - -[Defines] - INF_VERSION = 0x00010005 - BASE_NAME = XenHypercallLib - FILE_GUID = B5EE9A32-CA5A-49A8-82E3-ADA4CCB77C7C - MODULE_TYPE = BASE - VERSION_STRING = 1.0 - CONSTRUCTOR = XenHypercallLibInit - -[Defines.IA32, Defines.X64] - LIBRARY_CLASS = XenHypercallLib|DXE_DRIVER UEFI_DRIVER - -[Defines.ARM, Defines.AARCH64] - LIBRARY_CLASS = XenHypercallLib - -# -# The following information is for reference only and not required by the build tools. -# -# VALID_ARCHITECTURES = IA32 X64 ARM AARCH64 -# - -[Sources.IA32, Sources.X64] - X86XenHypercall.c - -[Sources.IA32] - Ia32/hypercall.nasm - -[Sources.X64] - X64/hypercall.nasm - -[Sources.ARM, Sources.AARCH64] - ArmXenHypercall.c - -[Sources.ARM] - Arm/Hypercall.S - -[Sources.AARCH64] - Aarch64/Hypercall.S - -[Sources] - XenHypercall.c - -[Packages] - MdePkg/MdePkg.dec - OvmfPkg/OvmfPkg.dec - -[LibraryClasses.IA32, LibraryClasses.X64] - BaseLib - HobLib - DebugLib - -[Guids.IA32, Guids.X64] - gEfiXenInfoGuid diff --git a/OvmfPkg/Library/XenIoMmioLib/XenIoMmioLib.c b/OvmfPkg/Library/XenIoMmioLib/XenIoMmioLib.c deleted file mode 100644 index c710e85865..0000000000 --- a/OvmfPkg/Library/XenIoMmioLib/XenIoMmioLib.c +++ /dev/null @@ -1,166 +0,0 @@ -/** @file -* Manage XenBus device path and I/O handles -* -* Copyright (c) 2015, Linaro Ltd. All rights reserved.
-* -* This program and the accompanying materials are -* licensed and made available under the terms and conditions of the BSD License -* which accompanies this distribution. The full text of the license may be found at -* http://opensource.org/licenses/bsd-license.php -* -* THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, -* WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. -* -**/ - -#include -#include -#include -#include -#include -#include -#include -#include - -#include -#include - -#pragma pack (1) -typedef struct { - VENDOR_DEVICE_PATH Vendor; - EFI_PHYSICAL_ADDRESS GrantTableAddress; - EFI_DEVICE_PATH_PROTOCOL End; -} XENBUS_ROOT_DEVICE_PATH; -#pragma pack () - -STATIC CONST XENBUS_ROOT_DEVICE_PATH mXenBusRootDevicePathTemplate = { - { - { - HARDWARE_DEVICE_PATH, - HW_VENDOR_DP, - { sizeof (VENDOR_DEVICE_PATH) + sizeof (EFI_PHYSICAL_ADDRESS), 0 } - }, - XENBUS_ROOT_DEVICE_GUID, - }, - 0, - { - END_DEVICE_PATH_TYPE, - END_ENTIRE_DEVICE_PATH_SUBTYPE, - { sizeof (EFI_DEVICE_PATH_PROTOCOL), 0 } - } -}; - -/** - - Install the XENBUS_ROOT_DEVICE_PATH and XENIO_PROTOCOL protocols on - the handle pointed to by @Handle, or on a new handle if it points to - NULL - - @param Handle Pointer to the handle to install the protocols - on, may point to a NULL handle. - - @param GrantTableAddress The address of the Xen grant table - - @retval EFI_SUCCESS Protocols were installed successfully - - @retval EFI_OUT_OF_RESOURCES The function failed to allocate memory required - by the XenIo MMIO and device path protocols - - @return Status code returned by the boot service - InstallMultipleProtocolInterfaces () - -**/ -EFI_STATUS -XenIoMmioInstall ( - IN OUT EFI_HANDLE *Handle, - IN EFI_PHYSICAL_ADDRESS GrantTableAddress - ) -{ - EFI_STATUS Status; - XENIO_PROTOCOL *XenIo; - XENBUS_ROOT_DEVICE_PATH *XenBusDevicePath; - EFI_HANDLE OutHandle; - - ASSERT (Handle != NULL); - - OutHandle = *Handle; - - XenIo = AllocateZeroPool (sizeof *XenIo); - if (!XenIo) { - return EFI_OUT_OF_RESOURCES; - } - XenIo->GrantTableAddress = GrantTableAddress; - - XenBusDevicePath = AllocateCopyPool (sizeof *XenBusDevicePath, - &mXenBusRootDevicePathTemplate); - if (!XenBusDevicePath) { - DEBUG ((EFI_D_ERROR, "%a: Out of memory\n", __FUNCTION__)); - Status = EFI_OUT_OF_RESOURCES; - goto FreeXenIo; - } - XenBusDevicePath->GrantTableAddress = GrantTableAddress; - - Status = gBS->InstallMultipleProtocolInterfaces (&OutHandle, - &gEfiDevicePathProtocolGuid, XenBusDevicePath, - &gXenIoProtocolGuid, XenIo, - NULL); - if (!EFI_ERROR (Status)) { - *Handle = OutHandle; - return EFI_SUCCESS; - } - - DEBUG ((EFI_D_ERROR, "%a: Failed to install the EFI_DEVICE_PATH and " - "XENIO_PROTOCOL protocols on handle %p (Status == %r)\n", - __FUNCTION__, OutHandle, Status)); - - FreePool (XenBusDevicePath); - -FreeXenIo: - FreePool (XenIo); - return Status; -} - -/** - - Uninstall the XENBUS_ROOT_DEVICE_PATH and XENIO_PROTOCOL protocols - - @param Handle Handle onto which the protocols have been installed - earlier by XenIoMmioInstall () - - @retval EFI_SUCCESS Protocols were uninstalled successfully - - @return Status code returned by the boot service - UninstallMultipleProtocolInterfaces () - -**/ -EFI_STATUS -XenIoMmioUninstall ( - IN EFI_HANDLE Handle - ) -{ - EFI_STATUS Status; - VOID *XenIo; - VOID *XenBusDevicePath; - - XenBusDevicePath = NULL; - gBS->OpenProtocol (Handle, &gEfiDevicePathProtocolGuid, &XenBusDevicePath, - NULL, NULL, EFI_OPEN_PROTOCOL_GET_PROTOCOL); - - XenIo = NULL; - gBS->OpenProtocol (Handle, &gXenIoProtocolGuid, &XenIo, - NULL, NULL, EFI_OPEN_PROTOCOL_GET_PROTOCOL); - - Status = gBS->UninstallMultipleProtocolInterfaces (Handle, - &gEfiDevicePathProtocolGuid, XenBusDevicePath, - &gXenIoProtocolGuid, XenIo, - NULL); - - if (EFI_ERROR (Status)) { - return Status; - } - - FreePool (XenBusDevicePath); - FreePool (XenIo); - - return EFI_SUCCESS; -} diff --git a/OvmfPkg/Library/XenIoMmioLib/XenIoMmioLib.inf b/OvmfPkg/Library/XenIoMmioLib/XenIoMmioLib.inf deleted file mode 100644 index d02588f281..0000000000 --- a/OvmfPkg/Library/XenIoMmioLib/XenIoMmioLib.inf +++ /dev/null @@ -1,40 +0,0 @@ -## @file -# Manage XenBus device path and I/O handles -# -# Copyright (c) 2015, Linaro Ltd. 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. -# -# -## - -[Defines] - INF_VERSION = 0x00010005 - BASE_NAME = XenIoMmioLib - FILE_GUID = de9bdc19-8434-47bb-be3c-7f28f2101fd0 - MODULE_TYPE = DXE_DRIVER - VERSION_STRING = 1.0 - LIBRARY_CLASS = XenIoMmioLib - -[Sources] - XenIoMmioLib.c - -[Packages] - MdePkg/MdePkg.dec - OvmfPkg/OvmfPkg.dec - -[LibraryClasses] - BaseMemoryLib - MemoryAllocationLib - -[Guids] - gXenBusRootDeviceGuid - -[Protocols] - gEfiDevicePathProtocolGuid - gXenIoProtocolGuid diff --git a/OvmfPkg/License.txt b/OvmfPkg/License.txt deleted file mode 100644 index e2eff41571..0000000000 --- a/OvmfPkg/License.txt +++ /dev/null @@ -1,50 +0,0 @@ -Copyright (c) 2012, Intel Corporation. All rights reserved. - -Redistribution and use in source and binary forms, with or without -modification, are permitted provided that the following conditions -are met: - -* Redistributions of source code must retain the above copyright - notice, this list of conditions and the following disclaimer. -* Redistributions in binary form must reproduce the above copyright - notice, this list of conditions and the following disclaimer in - the documentation and/or other materials provided with the - distribution. - -THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS -FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE -COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, -INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, -BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; -LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER -CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT -LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN -ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE -POSSIBILITY OF SUCH DAMAGE. - - -Some files are subject to the following license, the MIT license. Those files -are located in: -- OvmfPkg/Include/IndustryStandard/Xen/ -- OvmfPkg/XenBusDxe/ -- OvmfPkg/XenPvBlkDxe/ - -Permission is hereby granted, free of charge, to any person obtaining a copy -of this software and associated documentation files (the "Software"), to deal -in the Software without restriction, including without limitation the rights -to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -copies of the Software, and to permit persons to whom the Software is -furnished to do so, subject to the following conditions: - -The above copyright notice and this permission notice shall be included in -all copies or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN -THE SOFTWARE. diff --git a/OvmfPkg/OvmfPkg.dec b/OvmfPkg/OvmfPkg.dec deleted file mode 100644 index 3490f7ca7c..0000000000 --- a/OvmfPkg/OvmfPkg.dec +++ /dev/null @@ -1,151 +0,0 @@ -## @file -# EFI/Framework Open Virtual Machine Firmware (OVMF) platform -# -# Copyright (c) 2006 - 2013, Intel Corporation. All rights reserved.
-# -# This program and the accompanying materials -# are licensed and made available under the terms and conditions of the BSD License -# which accompanies this distribution. The full text of the license may be found at -# http://opensource.org/licenses/bsd-license.php -# -# THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, -# WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. -# -## - -[Defines] - DEC_SPECIFICATION = 0x00010005 - PACKAGE_NAME = OvmfPkg - PACKAGE_GUID = 2daf5f34-50e5-4b9d-b8e3-5562334d87e5 - PACKAGE_VERSION = 0.1 - -[Includes] - Include - -[LibraryClasses] - ## @libraryclass Loads and boots a Linux kernel image - # - LoadLinuxLib|Include/Library/LoadLinuxLib.h - - ## @libraryclass Save and restore variables using a file - # - NvVarsFileLib|Include/Library/NvVarsFileLib.h - - ## @libraryclass Access QEMU's firmware configuration interface - # - QemuFwCfgLib|Include/Library/QemuFwCfgLib.h - - ## @libraryclass S3 support for QEMU fw_cfg - # - QemuFwCfgS3Lib|Include/Library/QemuFwCfgS3Lib.h - - ## @libraryclass Rewrite the BootOrder NvVar based on QEMU's "bootorder" - # fw_cfg file. - # - QemuBootOrderLib|Include/Library/QemuBootOrderLib.h - - ## @libraryclass Serialize (and deserialize) variables - # - SerializeVariablesLib|Include/Library/SerializeVariablesLib.h - - ## @libraryclass Invoke Xen hypercalls - # - XenHypercallLib|Include/Library/XenHypercallLib.h - - ## @libraryclass Manage XenBus device path and I/O handles - # - XenIoMmioLib|Include/Library/XenIoMmioLib.h - -[Guids] - gUefiOvmfPkgTokenSpaceGuid = {0x93bb96af, 0xb9f2, 0x4eb8, {0x94, 0x62, 0xe0, 0xba, 0x74, 0x56, 0x42, 0x36}} - gEfiXenInfoGuid = {0xd3b46f3b, 0xd441, 0x1244, {0x9a, 0x12, 0x0, 0x12, 0x27, 0x3f, 0xc1, 0x4d}} - gOvmfPlatformConfigGuid = {0x7235c51c, 0x0c80, 0x4cab, {0x87, 0xac, 0x3b, 0x08, 0x4a, 0x63, 0x04, 0xb1}} - gVirtioMmioTransportGuid = {0x837dca9e, 0xe874, 0x4d82, {0xb2, 0x9a, 0x23, 0xfe, 0x0e, 0x23, 0xd1, 0xe2}} - gXenBusRootDeviceGuid = {0xa732241f, 0x383d, 0x4d9c, {0x8a, 0xe1, 0x8e, 0x09, 0x83, 0x75, 0x89, 0xd7}} - gRootBridgesConnectedEventGroupGuid = {0x24a2d66f, 0xeedd, 0x4086, {0x90, 0x42, 0xf2, 0x6e, 0x47, 0x97, 0xee, 0x69}} - -[Protocols] - gVirtioDeviceProtocolGuid = {0xfa920010, 0x6785, 0x4941, {0xb6, 0xec, 0x49, 0x8c, 0x57, 0x9f, 0x16, 0x0a}} - gBlockMmioProtocolGuid = {0x6b558ce3, 0x69e5, 0x4c67, {0xa6, 0x34, 0xf7, 0xfe, 0x72, 0xad, 0xbe, 0x84}} - gXenBusProtocolGuid = {0x3d3ca290, 0xb9a5, 0x11e3, {0xb7, 0x5d, 0xb8, 0xac, 0x6f, 0x7d, 0x65, 0xe6}} - gXenIoProtocolGuid = {0x6efac84f, 0x0ab0, 0x4747, {0x81, 0xbe, 0x85, 0x55, 0x62, 0x59, 0x04, 0x49}} - -[PcdsFixedAtBuild] - gUefiOvmfPkgTokenSpaceGuid.PcdOvmfPeiMemFvBase|0x0|UINT32|0 - gUefiOvmfPkgTokenSpaceGuid.PcdOvmfPeiMemFvSize|0x0|UINT32|1 - gUefiOvmfPkgTokenSpaceGuid.PcdOvmfDxeMemFvBase|0x0|UINT32|0x15 - gUefiOvmfPkgTokenSpaceGuid.PcdOvmfDxeMemFvSize|0x0|UINT32|0x16 - - ## This flag is used to control the destination port for PlatformDebugLibIoPort - gUefiOvmfPkgTokenSpaceGuid.PcdDebugIoPort|0x402|UINT16|4 - - ## 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 - - ## The following setting controls how many megabytes we configure as TSEG on - # Q35, for SMRAM purposes. Permitted values are: 1, 2, 8. Other values cause - # undefined behavior. - # - # This PCD is only consulted if PcdSmmSmramRequire is TRUE (see below). - gUefiOvmfPkgTokenSpaceGuid.PcdQ35TsegMbytes|8|UINT8|0x20 - - gUefiOvmfPkgTokenSpaceGuid.PcdOvmfFlashNvStorageEventLogBase|0x0|UINT32|0x8 - gUefiOvmfPkgTokenSpaceGuid.PcdOvmfFlashNvStorageEventLogSize|0x0|UINT32|0x9 - gUefiOvmfPkgTokenSpaceGuid.PcdOvmfFirmwareFdSize|0x0|UINT32|0xa - gUefiOvmfPkgTokenSpaceGuid.PcdOvmfFirmwareBlockSize|0|UINT32|0xb - gUefiOvmfPkgTokenSpaceGuid.PcdOvmfFlashNvStorageVariableBase|0x0|UINT32|0xc - gUefiOvmfPkgTokenSpaceGuid.PcdOvmfFlashNvStorageFtwSpareBase|0x0|UINT32|0xd - gUefiOvmfPkgTokenSpaceGuid.PcdOvmfFlashNvStorageFtwWorkingBase|0x0|UINT32|0xe - gUefiOvmfPkgTokenSpaceGuid.PcdOvmfFdBaseAddress|0x0|UINT32|0xf - gUefiOvmfPkgTokenSpaceGuid.PcdOvmfSecPageTablesBase|0x0|UINT32|0x11 - gUefiOvmfPkgTokenSpaceGuid.PcdOvmfSecPageTablesSize|0x0|UINT32|0x12 - gUefiOvmfPkgTokenSpaceGuid.PcdOvmfSecPeiTempRamBase|0x0|UINT32|0x13 - gUefiOvmfPkgTokenSpaceGuid.PcdOvmfSecPeiTempRamSize|0x0|UINT32|0x14 - gUefiOvmfPkgTokenSpaceGuid.PcdOvmfLockBoxStorageBase|0x0|UINT32|0x18 - gUefiOvmfPkgTokenSpaceGuid.PcdOvmfLockBoxStorageSize|0x0|UINT32|0x19 - gUefiOvmfPkgTokenSpaceGuid.PcdGuidedExtractHandlerTableSize|0x0|UINT32|0x1a - gUefiOvmfPkgTokenSpaceGuid.PcdOvmfDecompressionScratchEnd|0x0|UINT32|0x1f - -[PcdsDynamic, PcdsDynamicEx] - gUefiOvmfPkgTokenSpaceGuid.PcdEmuVariableEvent|0|UINT64|2 - gUefiOvmfPkgTokenSpaceGuid.PcdOvmfFlashVariablesEnable|FALSE|BOOLEAN|0x10 - gUefiOvmfPkgTokenSpaceGuid.PcdOvmfHostBridgePciDevId|0|UINT16|0x1b - gUefiOvmfPkgTokenSpaceGuid.PcdQemuSmbiosValidated|FALSE|BOOLEAN|0x21 - - ## The IO port aperture shared by all PCI root bridges. - # - gUefiOvmfPkgTokenSpaceGuid.PcdPciIoBase|0x0|UINT64|0x22 - gUefiOvmfPkgTokenSpaceGuid.PcdPciIoSize|0x0|UINT64|0x23 - - ## The 32-bit MMIO aperture shared by all PCI root bridges. - # - gUefiOvmfPkgTokenSpaceGuid.PcdPciMmio32Base|0x0|UINT64|0x24 - gUefiOvmfPkgTokenSpaceGuid.PcdPciMmio32Size|0x0|UINT64|0x25 - - ## The 64-bit MMIO aperture shared by all PCI root bridges. - # - gUefiOvmfPkgTokenSpaceGuid.PcdPciMmio64Base|0x0|UINT64|0x26 - gUefiOvmfPkgTokenSpaceGuid.PcdPciMmio64Size|0x0|UINT64|0x27 - -[PcdsFeatureFlag] - gUefiOvmfPkgTokenSpaceGuid.PcdSecureBootEnable|FALSE|BOOLEAN|3 - gUefiOvmfPkgTokenSpaceGuid.PcdQemuBootOrderPciTranslation|TRUE|BOOLEAN|0x1c - gUefiOvmfPkgTokenSpaceGuid.PcdQemuBootOrderMmioTranslation|FALSE|BOOLEAN|0x1d - - ## This feature flag enables SMM/SMRAM support. Note that it also requires - # such support from the underlying QEMU instance; if that support is not - # present, the firmware will reject continuing after a certain point. - # - # The flag also acts as a general "security switch"; when TRUE, many - # components will change behavior, with the goal of preventing a malicious - # runtime OS from tampering with firmware structures (special memory ranges - # used by OVMF, the varstore pflash chip, LockBox etc). - gUefiOvmfPkgTokenSpaceGuid.PcdSmmSmramRequire|FALSE|BOOLEAN|0x1e diff --git a/OvmfPkg/OvmfPkg.fdf.inc b/OvmfPkg/OvmfPkg.fdf.inc deleted file mode 100644 index 9cc0578d64..0000000000 --- a/OvmfPkg/OvmfPkg.fdf.inc +++ /dev/null @@ -1,70 +0,0 @@ -## @file -# FDF include file that defines the main macros and sets the dependent PCDs. -# -# Copyright (C) 2014, Red Hat, Inc. -# Copyright (c) 2006 - 2013, Intel Corporation. All rights reserved.
-# -# This program and the accompanying materials are licensed and made available -# under the terms and conditions of the BSD License which accompanies this -# distribution. The full text of the license may be found at -# http://opensource.org/licenses/bsd-license.php -# -# THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, -# WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR -# IMPLIED. -# -## - -# -# Default flash size is 2MB. -# -# Defining FD_SIZE_1MB on the build command line can override this. -# - -DEFINE BLOCK_SIZE = 0x1000 -DEFINE VARS_SIZE = 0x20000 -DEFINE VARS_BLOCKS = 0x20 - -!ifdef $(FD_SIZE_1MB) - -DEFINE FW_BASE_ADDRESS = 0xFFF00000 -DEFINE FW_SIZE = 0x00100000 -DEFINE FW_BLOCKS = 0x100 -DEFINE CODE_BASE_ADDRESS = 0xFFF20000 -DEFINE CODE_SIZE = 0x000E0000 -DEFINE CODE_BLOCKS = 0xE0 -DEFINE FVMAIN_SIZE = 0x000CC000 -DEFINE SECFV_OFFSET = 0x000EC000 -DEFINE SECFV_SIZE = 0x14000 - -!else - -DEFINE FW_BASE_ADDRESS = 0xFFE00000 -DEFINE FW_SIZE = 0x00200000 -DEFINE FW_BLOCKS = 0x200 -DEFINE CODE_BASE_ADDRESS = 0xFFE20000 -DEFINE CODE_SIZE = 0x001E0000 -DEFINE CODE_BLOCKS = 0x1E0 -DEFINE FVMAIN_SIZE = 0x001AC000 -DEFINE SECFV_OFFSET = 0x001CC000 -DEFINE SECFV_SIZE = 0x34000 - -!endif - -SET gUefiOvmfPkgTokenSpaceGuid.PcdOvmfFdBaseAddress = $(FW_BASE_ADDRESS) -SET gUefiOvmfPkgTokenSpaceGuid.PcdOvmfFirmwareFdSize = $(FW_SIZE) -SET gUefiOvmfPkgTokenSpaceGuid.PcdOvmfFirmwareBlockSize = $(BLOCK_SIZE) - -SET gUefiOvmfPkgTokenSpaceGuid.PcdOvmfFlashNvStorageVariableBase = $(FW_BASE_ADDRESS) -SET gEfiMdeModulePkgTokenSpaceGuid.PcdFlashNvStorageVariableSize = 0xE000 - -SET gUefiOvmfPkgTokenSpaceGuid.PcdOvmfFlashNvStorageEventLogBase = gUefiOvmfPkgTokenSpaceGuid.PcdOvmfFlashNvStorageVariableBase + gEfiMdeModulePkgTokenSpaceGuid.PcdFlashNvStorageVariableSize -SET gUefiOvmfPkgTokenSpaceGuid.PcdOvmfFlashNvStorageEventLogSize = $(BLOCK_SIZE) - -SET gUefiOvmfPkgTokenSpaceGuid.PcdOvmfFlashNvStorageFtwWorkingBase = gUefiOvmfPkgTokenSpaceGuid.PcdOvmfFlashNvStorageEventLogBase + gUefiOvmfPkgTokenSpaceGuid.PcdOvmfFlashNvStorageEventLogSize -SET gEfiMdeModulePkgTokenSpaceGuid.PcdFlashNvStorageFtwWorkingSize = $(BLOCK_SIZE) - -SET gUefiOvmfPkgTokenSpaceGuid.PcdOvmfFlashNvStorageFtwSpareBase = gUefiOvmfPkgTokenSpaceGuid.PcdOvmfFlashNvStorageFtwWorkingBase + gEfiMdeModulePkgTokenSpaceGuid.PcdFlashNvStorageFtwWorkingSize -SET gEfiMdeModulePkgTokenSpaceGuid.PcdFlashNvStorageFtwSpareSize = 0x10000 - -DEFINE MEMFD_BASE_ADDRESS = 0x800000 diff --git a/OvmfPkg/OvmfPkgIa32.dsc b/OvmfPkg/OvmfPkgIa32.dsc deleted file mode 100644 index 0796b0db81..0000000000 --- a/OvmfPkg/OvmfPkgIa32.dsc +++ /dev/null @@ -1,848 +0,0 @@ -## @file -# EFI/Framework Open Virtual Machine Firmware (OVMF) platform -# -# Copyright (c) 2006 - 2017, Intel Corporation. All rights reserved.
-# (C) Copyright 2016 Hewlett Packard Enterprise Development LP
-# -# This program and the accompanying materials -# are licensed and made 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 Section - statements that will be processed to create a Makefile. -# -################################################################################ -[Defines] - PLATFORM_NAME = Ovmf - PLATFORM_GUID = 5a9e7754-d81b-49ea-85ad-69eaa7b1539b - PLATFORM_VERSION = 0.1 - DSC_SPECIFICATION = 0x00010005 - OUTPUT_DIRECTORY = Build/OvmfIa32 - SUPPORTED_ARCHITECTURES = IA32 - BUILD_TARGETS = NOOPT|DEBUG|RELEASE - SKUID_IDENTIFIER = DEFAULT - FLASH_DEFINITION = OvmfPkg/OvmfPkgIa32.fdf - - # - # Defines for default states. These can be changed on the command line. - # -D FLAG=VALUE - # - DEFINE SECURE_BOOT_ENABLE = FALSE - DEFINE NETWORK_IP6_ENABLE = FALSE - DEFINE HTTP_BOOT_ENABLE = FALSE - DEFINE SMM_REQUIRE = FALSE - DEFINE TLS_ENABLE = FALSE - -[BuildOptions] - GCC:*_UNIXGCC_*_CC_FLAGS = -DMDEPKG_NDEBUG - GCC:RELEASE_*_*_CC_FLAGS = -DMDEPKG_NDEBUG - INTEL:RELEASE_*_*_CC_FLAGS = /D MDEPKG_NDEBUG - MSFT:RELEASE_*_*_CC_FLAGS = /D MDEPKG_NDEBUG - GCC:*_*_*_CC_FLAGS = -mno-mmx -mno-sse - - # - # Disable deprecated APIs. - # - MSFT:*_*_*_CC_FLAGS = /D DISABLE_NEW_DEPRECATED_INTERFACES - INTEL:*_*_*_CC_FLAGS = /D DISABLE_NEW_DEPRECATED_INTERFACES - GCC:*_*_*_CC_FLAGS = -D DISABLE_NEW_DEPRECATED_INTERFACES - -[BuildOptions.common.EDKII.DXE_RUNTIME_DRIVER] - GCC:*_*_*_DLINK_FLAGS = -z common-page-size=0x1000 - -# Force PE/COFF sections to be aligned at 4KB boundaries to support page level -# protection of DXE_SMM_DRIVER/SMM_CORE modules -[BuildOptions.common.EDKII.DXE_SMM_DRIVER, BuildOptions.common.EDKII.SMM_CORE] - GCC:*_*_*_DLINK_FLAGS = -z common-page-size=0x1000 - -################################################################################ -# -# SKU Identification section - list of all SKU IDs supported by this Platform. -# -################################################################################ -[SkuIds] - 0|DEFAULT - -################################################################################ -# -# Library Class section - list of all Library Classes needed by this Platform. -# -################################################################################ -[LibraryClasses] - PcdLib|MdePkg/Library/BasePcdLibNull/BasePcdLibNull.inf - TimerLib|OvmfPkg/Library/AcpiTimerLib/BaseAcpiTimerLib.inf - PrintLib|MdePkg/Library/BasePrintLib/BasePrintLib.inf - BaseMemoryLib|MdePkg/Library/BaseMemoryLibRepStr/BaseMemoryLibRepStr.inf - BaseLib|MdePkg/Library/BaseLib/BaseLib.inf - SynchronizationLib|MdePkg/Library/BaseSynchronizationLib/BaseSynchronizationLib.inf - CpuLib|MdePkg/Library/BaseCpuLib/BaseCpuLib.inf - PerformanceLib|MdePkg/Library/BasePerformanceLibNull/BasePerformanceLibNull.inf - PeCoffLib|MdePkg/Library/BasePeCoffLib/BasePeCoffLib.inf - CacheMaintenanceLib|MdePkg/Library/BaseCacheMaintenanceLib/BaseCacheMaintenanceLib.inf - UefiDecompressLib|MdePkg/Library/BaseUefiDecompressLib/BaseUefiDecompressLib.inf - UefiHiiServicesLib|MdeModulePkg/Library/UefiHiiServicesLib/UefiHiiServicesLib.inf - HiiLib|MdeModulePkg/Library/UefiHiiLib/UefiHiiLib.inf - SortLib|MdeModulePkg/Library/UefiSortLib/UefiSortLib.inf - UefiBootManagerLib|MdeModulePkg/Library/UefiBootManagerLib/UefiBootManagerLib.inf - BootLogoLib|MdeModulePkg/Library/BootLogoLib/BootLogoLib.inf - FileExplorerLib|MdeModulePkg/Library/FileExplorerLib/FileExplorerLib.inf - CapsuleLib|MdeModulePkg/Library/DxeCapsuleLibNull/DxeCapsuleLibNull.inf - DxeServicesLib|MdePkg/Library/DxeServicesLib/DxeServicesLib.inf - DxeServicesTableLib|MdePkg/Library/DxeServicesTableLib/DxeServicesTableLib.inf - PeCoffGetEntryPointLib|MdePkg/Library/BasePeCoffGetEntryPointLib/BasePeCoffGetEntryPointLib.inf - PciCf8Lib|MdePkg/Library/BasePciCf8Lib/BasePciCf8Lib.inf - PciExpressLib|MdePkg/Library/BasePciExpressLib/BasePciExpressLib.inf - PciLib|MdePkg/Library/BasePciLibCf8/BasePciLibCf8.inf - PciSegmentLib|MdePkg/Library/BasePciSegmentLibPci/BasePciSegmentLibPci.inf - IoLib|MdePkg/Library/BaseIoLibIntrinsic/BaseIoLibIntrinsic.inf - OemHookStatusCodeLib|MdeModulePkg/Library/OemHookStatusCodeLibNull/OemHookStatusCodeLibNull.inf - SerialPortLib|PcAtChipsetPkg/Library/SerialIoLib/SerialIoLib.inf - MtrrLib|UefiCpuPkg/Library/MtrrLib/MtrrLib.inf - UefiLib|MdePkg/Library/UefiLib/UefiLib.inf - UefiBootServicesTableLib|MdePkg/Library/UefiBootServicesTableLib/UefiBootServicesTableLib.inf - UefiRuntimeServicesTableLib|MdePkg/Library/UefiRuntimeServicesTableLib/UefiRuntimeServicesTableLib.inf - UefiDriverEntryPoint|MdePkg/Library/UefiDriverEntryPoint/UefiDriverEntryPoint.inf - UefiApplicationEntryPoint|MdePkg/Library/UefiApplicationEntryPoint/UefiApplicationEntryPoint.inf - DevicePathLib|MdePkg/Library/UefiDevicePathLibDevicePathProtocol/UefiDevicePathLibDevicePathProtocol.inf - NvVarsFileLib|OvmfPkg/Library/NvVarsFileLib/NvVarsFileLib.inf - FileHandleLib|MdePkg/Library/UefiFileHandleLib/UefiFileHandleLib.inf - UefiCpuLib|UefiCpuPkg/Library/BaseUefiCpuLib/BaseUefiCpuLib.inf - SecurityManagementLib|MdeModulePkg/Library/DxeSecurityManagementLib/DxeSecurityManagementLib.inf - NetLib|MdeModulePkg/Library/DxeNetLib/DxeNetLib.inf - IpIoLib|MdeModulePkg/Library/DxeIpIoLib/DxeIpIoLib.inf - UdpIoLib|MdeModulePkg/Library/DxeUdpIoLib/DxeUdpIoLib.inf - DpcLib|MdeModulePkg/Library/DxeDpcLib/DxeDpcLib.inf - UefiUsbLib|MdePkg/Library/UefiUsbLib/UefiUsbLib.inf - SerializeVariablesLib|OvmfPkg/Library/SerializeVariablesLib/SerializeVariablesLib.inf - QemuFwCfgLib|OvmfPkg/Library/QemuFwCfgLib/QemuFwCfgLib.inf - VirtioLib|OvmfPkg/Library/VirtioLib/VirtioLib.inf - LoadLinuxLib|OvmfPkg/Library/LoadLinuxLib/LoadLinuxLib.inf -!if $(SMM_REQUIRE) == FALSE - LockBoxLib|OvmfPkg/Library/LockBoxLib/LockBoxBaseLib.inf -!endif - CustomizedDisplayLib|MdeModulePkg/Library/CustomizedDisplayLib/CustomizedDisplayLib.inf - FrameBufferBltLib|MdeModulePkg/Library/FrameBufferBltLib/FrameBufferBltLib.inf - -!ifdef $(SOURCE_DEBUG_ENABLE) - PeCoffExtraActionLib|SourceLevelDebugPkg/Library/PeCoffExtraActionLibDebug/PeCoffExtraActionLibDebug.inf - DebugCommunicationLib|SourceLevelDebugPkg/Library/DebugCommunicationLibSerialPort/DebugCommunicationLibSerialPort.inf -!else - PeCoffExtraActionLib|MdePkg/Library/BasePeCoffExtraActionLibNull/BasePeCoffExtraActionLibNull.inf - DebugAgentLib|MdeModulePkg/Library/DebugAgentLibNull/DebugAgentLibNull.inf -!endif - - ResetSystemLib|OvmfPkg/Library/ResetSystemLib/ResetSystemLib.inf - LocalApicLib|UefiCpuPkg/Library/BaseXApicX2ApicLib/BaseXApicX2ApicLib.inf - DebugPrintErrorLevelLib|MdePkg/Library/BaseDebugPrintErrorLevelLib/BaseDebugPrintErrorLevelLib.inf - - IntrinsicLib|CryptoPkg/Library/IntrinsicLib/IntrinsicLib.inf -!if $(TLS_ENABLE) == TRUE - OpensslLib|CryptoPkg/Library/OpensslLib/OpensslLib.inf -!else - OpensslLib|CryptoPkg/Library/OpensslLib/OpensslLibCrypto.inf -!endif - -!if $(SECURE_BOOT_ENABLE) == TRUE - PlatformSecureLib|OvmfPkg/Library/PlatformSecureLib/PlatformSecureLib.inf - TpmMeasurementLib|SecurityPkg/Library/DxeTpmMeasurementLib/DxeTpmMeasurementLib.inf - AuthVariableLib|SecurityPkg/Library/AuthVariableLib/AuthVariableLib.inf -!else - TpmMeasurementLib|MdeModulePkg/Library/TpmMeasurementLibNull/TpmMeasurementLibNull.inf - AuthVariableLib|MdeModulePkg/Library/AuthVariableLibNull/AuthVariableLibNull.inf -!endif - VarCheckLib|MdeModulePkg/Library/VarCheckLib/VarCheckLib.inf - -!if $(NETWORK_IP6_ENABLE) == TRUE - TcpIoLib|MdeModulePkg/Library/DxeTcpIoLib/DxeTcpIoLib.inf -!endif - -!if $(HTTP_BOOT_ENABLE) == TRUE - HttpLib|MdeModulePkg/Library/DxeHttpLib/DxeHttpLib.inf -!endif - -!if $(TLS_ENABLE) == TRUE - TlsLib|CryptoPkg/Library/TlsLib/TlsLib.inf -!endif - - S3BootScriptLib|MdeModulePkg/Library/PiDxeS3BootScriptLib/DxeS3BootScriptLib.inf - SmbusLib|MdePkg/Library/BaseSmbusLibNull/BaseSmbusLibNull.inf - OrderedCollectionLib|MdePkg/Library/BaseOrderedCollectionRedBlackTreeLib/BaseOrderedCollectionRedBlackTreeLib.inf - XenHypercallLib|OvmfPkg/Library/XenHypercallLib/XenHypercallLib.inf - -[LibraryClasses.common] - BaseCryptLib|CryptoPkg/Library/BaseCryptLib/BaseCryptLib.inf - -[LibraryClasses.common.SEC] - TimerLib|OvmfPkg/Library/AcpiTimerLib/BaseRomAcpiTimerLib.inf - QemuFwCfgLib|OvmfPkg/Library/QemuFwCfgLib/QemuFwCfgSecLib.inf -!ifdef $(DEBUG_ON_SERIAL_PORT) - DebugLib|MdePkg/Library/BaseDebugLibSerialPort/BaseDebugLibSerialPort.inf -!else - DebugLib|OvmfPkg/Library/PlatformDebugLibIoPort/PlatformDebugLibIoPort.inf -!endif - ReportStatusCodeLib|MdeModulePkg/Library/PeiReportStatusCodeLib/PeiReportStatusCodeLib.inf - ExtractGuidedSectionLib|MdePkg/Library/BaseExtractGuidedSectionLib/BaseExtractGuidedSectionLib.inf -!ifdef $(SOURCE_DEBUG_ENABLE) - DebugAgentLib|SourceLevelDebugPkg/Library/DebugAgent/SecPeiDebugAgentLib.inf -!endif - HobLib|MdePkg/Library/PeiHobLib/PeiHobLib.inf - PeiServicesLib|MdePkg/Library/PeiServicesLib/PeiServicesLib.inf - PeiServicesTablePointerLib|MdePkg/Library/PeiServicesTablePointerLibIdt/PeiServicesTablePointerLibIdt.inf - MemoryAllocationLib|MdePkg/Library/PeiMemoryAllocationLib/PeiMemoryAllocationLib.inf - CpuExceptionHandlerLib|UefiCpuPkg/Library/CpuExceptionHandlerLib/SecPeiCpuExceptionHandlerLib.inf - -[LibraryClasses.common.PEI_CORE] - HobLib|MdePkg/Library/PeiHobLib/PeiHobLib.inf - PeiServicesTablePointerLib|MdePkg/Library/PeiServicesTablePointerLibIdt/PeiServicesTablePointerLibIdt.inf - PeiServicesLib|MdePkg/Library/PeiServicesLib/PeiServicesLib.inf - MemoryAllocationLib|MdePkg/Library/PeiMemoryAllocationLib/PeiMemoryAllocationLib.inf - PeiCoreEntryPoint|MdePkg/Library/PeiCoreEntryPoint/PeiCoreEntryPoint.inf - ReportStatusCodeLib|MdeModulePkg/Library/PeiReportStatusCodeLib/PeiReportStatusCodeLib.inf - OemHookStatusCodeLib|MdeModulePkg/Library/OemHookStatusCodeLibNull/OemHookStatusCodeLibNull.inf - PeCoffGetEntryPointLib|MdePkg/Library/BasePeCoffGetEntryPointLib/BasePeCoffGetEntryPointLib.inf -!ifdef $(DEBUG_ON_SERIAL_PORT) - DebugLib|MdePkg/Library/BaseDebugLibSerialPort/BaseDebugLibSerialPort.inf -!else - DebugLib|OvmfPkg/Library/PlatformDebugLibIoPort/PlatformDebugLibIoPort.inf -!endif - PeCoffLib|MdePkg/Library/BasePeCoffLib/BasePeCoffLib.inf - -[LibraryClasses.common.PEIM] - HobLib|MdePkg/Library/PeiHobLib/PeiHobLib.inf - PeiServicesTablePointerLib|MdePkg/Library/PeiServicesTablePointerLibIdt/PeiServicesTablePointerLibIdt.inf - PeiServicesLib|MdePkg/Library/PeiServicesLib/PeiServicesLib.inf - MemoryAllocationLib|MdePkg/Library/PeiMemoryAllocationLib/PeiMemoryAllocationLib.inf - PeimEntryPoint|MdePkg/Library/PeimEntryPoint/PeimEntryPoint.inf - ReportStatusCodeLib|MdeModulePkg/Library/PeiReportStatusCodeLib/PeiReportStatusCodeLib.inf - OemHookStatusCodeLib|MdeModulePkg/Library/OemHookStatusCodeLibNull/OemHookStatusCodeLibNull.inf - PeCoffGetEntryPointLib|MdePkg/Library/BasePeCoffGetEntryPointLib/BasePeCoffGetEntryPointLib.inf -!ifdef $(DEBUG_ON_SERIAL_PORT) - DebugLib|MdePkg/Library/BaseDebugLibSerialPort/BaseDebugLibSerialPort.inf -!else - DebugLib|OvmfPkg/Library/PlatformDebugLibIoPort/PlatformDebugLibIoPort.inf -!endif - PeCoffLib|MdePkg/Library/BasePeCoffLib/BasePeCoffLib.inf - PeiResourcePublicationLib|MdePkg/Library/PeiResourcePublicationLib/PeiResourcePublicationLib.inf - ExtractGuidedSectionLib|MdePkg/Library/PeiExtractGuidedSectionLib/PeiExtractGuidedSectionLib.inf -!ifdef $(SOURCE_DEBUG_ENABLE) - DebugAgentLib|SourceLevelDebugPkg/Library/DebugAgent/SecPeiDebugAgentLib.inf -!endif - CpuExceptionHandlerLib|UefiCpuPkg/Library/CpuExceptionHandlerLib/PeiCpuExceptionHandlerLib.inf - MpInitLib|UefiCpuPkg/Library/MpInitLib/PeiMpInitLib.inf - QemuFwCfgS3Lib|OvmfPkg/Library/QemuFwCfgS3Lib/PeiQemuFwCfgS3LibFwCfg.inf - -[LibraryClasses.common.DXE_CORE] - HobLib|MdePkg/Library/DxeCoreHobLib/DxeCoreHobLib.inf - DxeCoreEntryPoint|MdePkg/Library/DxeCoreEntryPoint/DxeCoreEntryPoint.inf - MemoryAllocationLib|MdeModulePkg/Library/DxeCoreMemoryAllocationLib/DxeCoreMemoryAllocationLib.inf - ReportStatusCodeLib|MdeModulePkg/Library/DxeReportStatusCodeLib/DxeReportStatusCodeLib.inf -!ifdef $(DEBUG_ON_SERIAL_PORT) - DebugLib|MdePkg/Library/BaseDebugLibSerialPort/BaseDebugLibSerialPort.inf -!else - DebugLib|OvmfPkg/Library/PlatformDebugLibIoPort/PlatformDebugLibIoPort.inf -!endif - ExtractGuidedSectionLib|MdePkg/Library/DxeExtractGuidedSectionLib/DxeExtractGuidedSectionLib.inf -!ifdef $(SOURCE_DEBUG_ENABLE) - DebugAgentLib|SourceLevelDebugPkg/Library/DebugAgent/DxeDebugAgentLib.inf -!endif - CpuExceptionHandlerLib|UefiCpuPkg/Library/CpuExceptionHandlerLib/DxeCpuExceptionHandlerLib.inf - PcdLib|MdePkg/Library/DxePcdLib/DxePcdLib.inf - -[LibraryClasses.common.DXE_RUNTIME_DRIVER] - PcdLib|MdePkg/Library/DxePcdLib/DxePcdLib.inf - TimerLib|OvmfPkg/Library/AcpiTimerLib/DxeAcpiTimerLib.inf - HobLib|MdePkg/Library/DxeHobLib/DxeHobLib.inf - DxeCoreEntryPoint|MdePkg/Library/DxeCoreEntryPoint/DxeCoreEntryPoint.inf - MemoryAllocationLib|MdePkg/Library/UefiMemoryAllocationLib/UefiMemoryAllocationLib.inf - ReportStatusCodeLib|MdeModulePkg/Library/RuntimeDxeReportStatusCodeLib/RuntimeDxeReportStatusCodeLib.inf -!ifdef $(DEBUG_ON_SERIAL_PORT) - DebugLib|MdePkg/Library/BaseDebugLibSerialPort/BaseDebugLibSerialPort.inf -!else - DebugLib|OvmfPkg/Library/PlatformDebugLibIoPort/PlatformDebugLibIoPort.inf -!endif - UefiRuntimeLib|MdePkg/Library/UefiRuntimeLib/UefiRuntimeLib.inf - BaseCryptLib|CryptoPkg/Library/BaseCryptLib/RuntimeCryptLib.inf - PciLib|OvmfPkg/Library/DxePciLibI440FxQ35/DxePciLibI440FxQ35.inf - QemuFwCfgS3Lib|OvmfPkg/Library/QemuFwCfgS3Lib/DxeQemuFwCfgS3LibFwCfg.inf - -[LibraryClasses.common.UEFI_DRIVER] - PcdLib|MdePkg/Library/DxePcdLib/DxePcdLib.inf - TimerLib|OvmfPkg/Library/AcpiTimerLib/DxeAcpiTimerLib.inf - HobLib|MdePkg/Library/DxeHobLib/DxeHobLib.inf - DxeCoreEntryPoint|MdePkg/Library/DxeCoreEntryPoint/DxeCoreEntryPoint.inf - MemoryAllocationLib|MdePkg/Library/UefiMemoryAllocationLib/UefiMemoryAllocationLib.inf - ReportStatusCodeLib|MdeModulePkg/Library/DxeReportStatusCodeLib/DxeReportStatusCodeLib.inf -!ifdef $(DEBUG_ON_SERIAL_PORT) - DebugLib|MdePkg/Library/BaseDebugLibSerialPort/BaseDebugLibSerialPort.inf -!else - DebugLib|OvmfPkg/Library/PlatformDebugLibIoPort/PlatformDebugLibIoPort.inf -!endif - UefiScsiLib|MdePkg/Library/UefiScsiLib/UefiScsiLib.inf - PciLib|OvmfPkg/Library/DxePciLibI440FxQ35/DxePciLibI440FxQ35.inf - -[LibraryClasses.common.DXE_DRIVER] - PcdLib|MdePkg/Library/DxePcdLib/DxePcdLib.inf - TimerLib|OvmfPkg/Library/AcpiTimerLib/DxeAcpiTimerLib.inf - HobLib|MdePkg/Library/DxeHobLib/DxeHobLib.inf - MemoryAllocationLib|MdePkg/Library/UefiMemoryAllocationLib/UefiMemoryAllocationLib.inf - ReportStatusCodeLib|MdeModulePkg/Library/DxeReportStatusCodeLib/DxeReportStatusCodeLib.inf - UefiScsiLib|MdePkg/Library/UefiScsiLib/UefiScsiLib.inf -!ifdef $(DEBUG_ON_SERIAL_PORT) - DebugLib|MdePkg/Library/BaseDebugLibSerialPort/BaseDebugLibSerialPort.inf -!else - DebugLib|OvmfPkg/Library/PlatformDebugLibIoPort/PlatformDebugLibIoPort.inf -!endif - NetLib|MdeModulePkg/Library/DxeNetLib/DxeNetLib.inf - IpIoLib|MdeModulePkg/Library/DxeIpIoLib/DxeIpIoLib.inf - UdpIoLib|MdeModulePkg/Library/DxeUdpIoLib/DxeUdpIoLib.inf - DpcLib|MdeModulePkg/Library/DxeDpcLib/DxeDpcLib.inf - PlatformBootManagerLib|OvmfPkg/Library/PlatformBootManagerLib/PlatformBootManagerLib.inf - QemuBootOrderLib|OvmfPkg/Library/QemuBootOrderLib/QemuBootOrderLib.inf - CpuExceptionHandlerLib|UefiCpuPkg/Library/CpuExceptionHandlerLib/DxeCpuExceptionHandlerLib.inf -!if $(SMM_REQUIRE) == TRUE - LockBoxLib|MdeModulePkg/Library/SmmLockBoxLib/SmmLockBoxDxeLib.inf -!else - LockBoxLib|OvmfPkg/Library/LockBoxLib/LockBoxDxeLib.inf -!endif -!ifdef $(SOURCE_DEBUG_ENABLE) - DebugAgentLib|SourceLevelDebugPkg/Library/DebugAgent/DxeDebugAgentLib.inf -!endif - PciLib|OvmfPkg/Library/DxePciLibI440FxQ35/DxePciLibI440FxQ35.inf - MpInitLib|UefiCpuPkg/Library/MpInitLib/DxeMpInitLib.inf - QemuFwCfgS3Lib|OvmfPkg/Library/QemuFwCfgS3Lib/DxeQemuFwCfgS3LibFwCfg.inf - -[LibraryClasses.common.UEFI_APPLICATION] - PcdLib|MdePkg/Library/DxePcdLib/DxePcdLib.inf - TimerLib|OvmfPkg/Library/AcpiTimerLib/DxeAcpiTimerLib.inf - HobLib|MdePkg/Library/DxeHobLib/DxeHobLib.inf - MemoryAllocationLib|MdePkg/Library/UefiMemoryAllocationLib/UefiMemoryAllocationLib.inf - ReportStatusCodeLib|MdeModulePkg/Library/DxeReportStatusCodeLib/DxeReportStatusCodeLib.inf -!ifdef $(DEBUG_ON_SERIAL_PORT) - DebugLib|MdePkg/Library/BaseDebugLibSerialPort/BaseDebugLibSerialPort.inf -!else - DebugLib|OvmfPkg/Library/PlatformDebugLibIoPort/PlatformDebugLibIoPort.inf -!endif - PciLib|OvmfPkg/Library/DxePciLibI440FxQ35/DxePciLibI440FxQ35.inf - -[LibraryClasses.common.DXE_SMM_DRIVER] - PcdLib|MdePkg/Library/DxePcdLib/DxePcdLib.inf - TimerLib|OvmfPkg/Library/AcpiTimerLib/DxeAcpiTimerLib.inf - MemoryAllocationLib|MdePkg/Library/SmmMemoryAllocationLib/SmmMemoryAllocationLib.inf - ReportStatusCodeLib|MdeModulePkg/Library/DxeReportStatusCodeLib/DxeReportStatusCodeLib.inf - HobLib|MdePkg/Library/DxeHobLib/DxeHobLib.inf - SmmMemLib|MdePkg/Library/SmmMemLib/SmmMemLib.inf - SmmServicesTableLib|MdePkg/Library/SmmServicesTableLib/SmmServicesTableLib.inf -!ifdef $(DEBUG_ON_SERIAL_PORT) - DebugLib|MdePkg/Library/BaseDebugLibSerialPort/BaseDebugLibSerialPort.inf -!else - DebugLib|OvmfPkg/Library/PlatformDebugLibIoPort/PlatformDebugLibIoPort.inf -!endif - CpuExceptionHandlerLib|UefiCpuPkg/Library/CpuExceptionHandlerLib/SmmCpuExceptionHandlerLib.inf -!ifdef $(SOURCE_DEBUG_ENABLE) - DebugAgentLib|SourceLevelDebugPkg/Library/DebugAgent/SmmDebugAgentLib.inf -!endif - BaseCryptLib|CryptoPkg/Library/BaseCryptLib/SmmCryptLib.inf - PciLib|OvmfPkg/Library/DxePciLibI440FxQ35/DxePciLibI440FxQ35.inf - -[LibraryClasses.common.SMM_CORE] - PcdLib|MdePkg/Library/DxePcdLib/DxePcdLib.inf - TimerLib|OvmfPkg/Library/AcpiTimerLib/DxeAcpiTimerLib.inf - SmmCorePlatformHookLib|MdeModulePkg/Library/SmmCorePlatformHookLibNull/SmmCorePlatformHookLibNull.inf - MemoryAllocationLib|MdeModulePkg/Library/PiSmmCoreMemoryAllocationLib/PiSmmCoreMemoryAllocationLib.inf - ReportStatusCodeLib|MdeModulePkg/Library/DxeReportStatusCodeLib/DxeReportStatusCodeLib.inf - HobLib|MdePkg/Library/DxeHobLib/DxeHobLib.inf - SmmMemLib|MdePkg/Library/SmmMemLib/SmmMemLib.inf - SmmServicesTableLib|MdeModulePkg/Library/PiSmmCoreSmmServicesTableLib/PiSmmCoreSmmServicesTableLib.inf -!ifdef $(DEBUG_ON_SERIAL_PORT) - DebugLib|MdePkg/Library/BaseDebugLibSerialPort/BaseDebugLibSerialPort.inf -!else - DebugLib|OvmfPkg/Library/PlatformDebugLibIoPort/PlatformDebugLibIoPort.inf -!endif - PciLib|OvmfPkg/Library/DxePciLibI440FxQ35/DxePciLibI440FxQ35.inf - -################################################################################ -# -# Pcd Section - list of all EDK II PCD Entries defined by this Platform. -# -################################################################################ -[PcdsFeatureFlag] - gEfiMdeModulePkgTokenSpaceGuid.PcdHiiOsRuntimeSupport|FALSE - gEfiMdeModulePkgTokenSpaceGuid.PcdStatusCodeUseSerial|FALSE - gEfiMdeModulePkgTokenSpaceGuid.PcdStatusCodeUseMemory|TRUE - gEfiMdeModulePkgTokenSpaceGuid.PcdDxeIplSupportUefiDecompress|FALSE - gEfiMdeModulePkgTokenSpaceGuid.PcdDxeIplSwitchToLongMode|FALSE - gEfiMdeModulePkgTokenSpaceGuid.PcdConOutGopSupport|TRUE - gEfiMdeModulePkgTokenSpaceGuid.PcdConOutUgaSupport|FALSE - gEfiMdeModulePkgTokenSpaceGuid.PcdInstallAcpiSdtProtocol|TRUE -!if $(SECURE_BOOT_ENABLE) == TRUE - gUefiOvmfPkgTokenSpaceGuid.PcdSecureBootEnable|TRUE -!endif -!if $(SMM_REQUIRE) == TRUE - gUefiOvmfPkgTokenSpaceGuid.PcdSmmSmramRequire|TRUE - gUefiCpuPkgTokenSpaceGuid.PcdCpuSmmEnableBspElection|FALSE -!endif - -[PcdsFixedAtBuild] - gEfiMdeModulePkgTokenSpaceGuid.PcdStatusCodeMemorySize|1 - gEfiMdeModulePkgTokenSpaceGuid.PcdResetOnMemoryTypeInformationChange|FALSE - gEfiMdePkgTokenSpaceGuid.PcdMaximumGuidedExtractHandler|0x10 - gEfiMdeModulePkgTokenSpaceGuid.PcdPeiCoreMaxFvSupported|6 - gEfiMdeModulePkgTokenSpaceGuid.PcdPeiCoreMaxPeimPerFv|32 - gEfiMdeModulePkgTokenSpaceGuid.PcdMaxVariableSize|0x2000 - gEfiMdeModulePkgTokenSpaceGuid.PcdMaxAuthVariableSize|0x2800 - gEfiMdeModulePkgTokenSpaceGuid.PcdVariableStoreSize|0xe000 - - gEfiMdeModulePkgTokenSpaceGuid.PcdVpdBaseAddress|0x0 - - gEfiMdePkgTokenSpaceGuid.PcdReportStatusCodePropertyMask|0x07 - - # DEBUG_INIT 0x00000001 // Initialization - # DEBUG_WARN 0x00000002 // Warnings - # DEBUG_LOAD 0x00000004 // Load events - # DEBUG_FS 0x00000008 // EFI File system - # DEBUG_POOL 0x00000010 // Alloc & Free (pool) - # DEBUG_PAGE 0x00000020 // Alloc & Free (page) - # DEBUG_INFO 0x00000040 // Informational debug messages - # DEBUG_DISPATCH 0x00000080 // PEI/DXE/SMM Dispatchers - # DEBUG_VARIABLE 0x00000100 // Variable - # DEBUG_BM 0x00000400 // Boot Manager - # DEBUG_BLKIO 0x00001000 // BlkIo Driver - # DEBUG_NET 0x00004000 // SNP Driver - # DEBUG_UNDI 0x00010000 // UNDI Driver - # DEBUG_LOADFILE 0x00020000 // LoadFile - # DEBUG_EVENT 0x00080000 // Event messages - # DEBUG_GCD 0x00100000 // Global Coherency Database changes - # DEBUG_CACHE 0x00200000 // Memory range cachability changes - # DEBUG_VERBOSE 0x00400000 // Detailed debug messages that may - # // significantly impact boot performance - # DEBUG_ERROR 0x80000000 // Error - gEfiMdePkgTokenSpaceGuid.PcdDebugPrintErrorLevel|0x8000004F - -!ifdef $(SOURCE_DEBUG_ENABLE) - gEfiMdePkgTokenSpaceGuid.PcdDebugPropertyMask|0x17 -!else - gEfiMdePkgTokenSpaceGuid.PcdDebugPropertyMask|0x2F -!endif - - # This PCD is used to set the base address of the PCI express hierarchy. It - # is only consulted when OVMF runs on Q35. In that case it is programmed into - # the PCIEXBAR register. - # - # On Q35 machine types that QEMU intends to support in the long term, QEMU - # never lets the RAM below 4 GB exceed 2 GB. - gEfiMdePkgTokenSpaceGuid.PcdPciExpressBaseAddress|0x80000000 - -!ifdef $(SOURCE_DEBUG_ENABLE) - gEfiSourceLevelDebugPkgTokenSpaceGuid.PcdDebugLoadImageMethod|0x2 -!endif - -!if $(HTTP_BOOT_ENABLE) == TRUE - gEfiNetworkPkgTokenSpaceGuid.PcdAllowHttpConnections|TRUE -!endif - -!ifndef $(USE_OLD_SHELL) - gEfiIntelFrameworkModulePkgTokenSpaceGuid.PcdShellFile|{ 0x83, 0xA5, 0x04, 0x7C, 0x3E, 0x9E, 0x1C, 0x4F, 0xAD, 0x65, 0xE0, 0x52, 0x68, 0xD0, 0xB4, 0xD1 } -!endif - -!if $(SMM_REQUIRE) == TRUE - gUefiCpuPkgTokenSpaceGuid.PcdCpuSmmStackSize|0x4000 -!endif - -!if $(SECURE_BOOT_ENABLE) == TRUE - gEfiSecurityPkgTokenSpaceGuid.PcdOptionRomImageVerificationPolicy|0x00 -!endif - - # IRQs 5, 9, 10, 11 are level-triggered - gPcAtChipsetPkgTokenSpaceGuid.Pcd8259LegacyModeEdgeLevel|0x0E20 - - # Point to the MdeModulePkg/Application/UiApp/UiApp.inf - gEfiMdeModulePkgTokenSpaceGuid.PcdBootManagerMenuFile|{ 0x21, 0xaa, 0x2c, 0x46, 0x14, 0x76, 0x03, 0x45, 0x83, 0x6e, 0x8a, 0xb6, 0xf4, 0x66, 0x23, 0x31 } - -################################################################################ -# -# Pcd Dynamic Section - list of all EDK II PCD Entries defined by this Platform -# -################################################################################ - -[PcdsDynamicDefault] - gEfiMdeModulePkgTokenSpaceGuid.PcdEmuVariableNvStoreReserved|0 - gEfiMdeModulePkgTokenSpaceGuid.PcdFlashNvStorageVariableBase64|0 - gEfiMdeModulePkgTokenSpaceGuid.PcdFlashNvStorageFtwWorkingBase|0 - gEfiMdeModulePkgTokenSpaceGuid.PcdFlashNvStorageFtwSpareBase|0 - gEfiMdeModulePkgTokenSpaceGuid.PcdPciDisableBusEnumeration|FALSE - gEfiMdeModulePkgTokenSpaceGuid.PcdVideoHorizontalResolution|800 - gEfiMdeModulePkgTokenSpaceGuid.PcdVideoVerticalResolution|600 - gEfiMdeModulePkgTokenSpaceGuid.PcdAcpiS3Enable|FALSE - gUefiOvmfPkgTokenSpaceGuid.PcdOvmfHostBridgePciDevId|0 - gUefiOvmfPkgTokenSpaceGuid.PcdPciIoBase|0x0 - gUefiOvmfPkgTokenSpaceGuid.PcdPciIoSize|0x0 - gUefiOvmfPkgTokenSpaceGuid.PcdPciMmio32Base|0x0 - gUefiOvmfPkgTokenSpaceGuid.PcdPciMmio32Size|0x0 - - gEfiMdePkgTokenSpaceGuid.PcdPlatformBootTimeOut|0 - - # Set video resolution for text setup. - gEfiMdeModulePkgTokenSpaceGuid.PcdSetupVideoHorizontalResolution|640 - gEfiMdeModulePkgTokenSpaceGuid.PcdSetupVideoVerticalResolution|480 - - gEfiMdeModulePkgTokenSpaceGuid.PcdSmbiosVersion|0x0208 - gEfiMdeModulePkgTokenSpaceGuid.PcdSmbiosDocRev|0x0 - gUefiOvmfPkgTokenSpaceGuid.PcdQemuSmbiosValidated|FALSE - - # Noexec settings for DXE. - gEfiMdeModulePkgTokenSpaceGuid.PcdSetNxForStack|FALSE - gEfiMdeModulePkgTokenSpaceGuid.PcdPropertiesTableEnable|FALSE - - # UefiCpuPkg PCDs related to initial AP bringup and general AP management. - gUefiCpuPkgTokenSpaceGuid.PcdCpuMaxLogicalProcessorNumber|64 - gUefiCpuPkgTokenSpaceGuid.PcdCpuApInitTimeOutInMicroSeconds|50000 - -!if $(SMM_REQUIRE) == TRUE - gUefiCpuPkgTokenSpaceGuid.PcdCpuSmmSyncMode|0x01 - gUefiCpuPkgTokenSpaceGuid.PcdCpuSmmApSyncTimeout|100000 -!endif - -################################################################################ -# -# Components Section - list of all EDK II Modules needed by this Platform. -# -################################################################################ -[Components] - OvmfPkg/ResetVector/ResetVector.inf - - # - # SEC Phase modules - # - OvmfPkg/Sec/SecMain.inf { - - NULL|MdeModulePkg/Library/LzmaCustomDecompressLib/LzmaCustomDecompressLib.inf - } - - # - # PEI Phase modules - # - MdeModulePkg/Core/Pei/PeiMain.inf - MdeModulePkg/Universal/PCD/Pei/Pcd.inf { - - PcdLib|MdePkg/Library/BasePcdLibNull/BasePcdLibNull.inf - } - MdeModulePkg/Universal/ReportStatusCodeRouter/Pei/ReportStatusCodeRouterPei.inf - MdeModulePkg/Universal/StatusCodeHandler/Pei/StatusCodeHandlerPei.inf - MdeModulePkg/Core/DxeIplPeim/DxeIpl.inf { - - PcdLib|MdePkg/Library/PeiPcdLib/PeiPcdLib.inf - } - - OvmfPkg/PlatformPei/PlatformPei.inf { - - PcdLib|MdePkg/Library/PeiPcdLib/PeiPcdLib.inf - } - UefiCpuPkg/Universal/Acpi/S3Resume2Pei/S3Resume2Pei.inf { - - PcdLib|MdePkg/Library/PeiPcdLib/PeiPcdLib.inf -!if $(SMM_REQUIRE) == TRUE - LockBoxLib|MdeModulePkg/Library/SmmLockBoxLib/SmmLockBoxPeiLib.inf -!endif - } -!if $(SMM_REQUIRE) == TRUE - OvmfPkg/SmmAccess/SmmAccessPei.inf { - - PcdLib|MdePkg/Library/PeiPcdLib/PeiPcdLib.inf - } -!endif - UefiCpuPkg/CpuMpPei/CpuMpPei.inf { - - PcdLib|MdePkg/Library/PeiPcdLib/PeiPcdLib.inf - } - - # - # DXE Phase modules - # - MdeModulePkg/Core/Dxe/DxeMain.inf { - - NULL|MdeModulePkg/Library/LzmaCustomDecompressLib/LzmaCustomDecompressLib.inf - DevicePathLib|MdePkg/Library/UefiDevicePathLib/UefiDevicePathLib.inf - } - - MdeModulePkg/Universal/ReportStatusCodeRouter/RuntimeDxe/ReportStatusCodeRouterRuntimeDxe.inf - MdeModulePkg/Universal/StatusCodeHandler/RuntimeDxe/StatusCodeHandlerRuntimeDxe.inf - MdeModulePkg/Universal/PCD/Dxe/Pcd.inf { - - PcdLib|MdePkg/Library/BasePcdLibNull/BasePcdLibNull.inf - } - - MdeModulePkg/Core/RuntimeDxe/RuntimeDxe.inf - -!if $(SECURE_BOOT_ENABLE) == TRUE - MdeModulePkg/Universal/SecurityStubDxe/SecurityStubDxe.inf { - - NULL|SecurityPkg/Library/DxeImageVerificationLib/DxeImageVerificationLib.inf - } -!else - MdeModulePkg/Universal/SecurityStubDxe/SecurityStubDxe.inf -!endif - - MdeModulePkg/Universal/EbcDxe/EbcDxe.inf - PcAtChipsetPkg/8259InterruptControllerDxe/8259.inf - UefiCpuPkg/CpuIo2Dxe/CpuIo2Dxe.inf - UefiCpuPkg/CpuDxe/CpuDxe.inf - PcAtChipsetPkg/8254TimerDxe/8254Timer.inf - OvmfPkg/IncompatiblePciDeviceSupportDxe/IncompatiblePciDeviceSupport.inf - OvmfPkg/PciHotPlugInitDxe/PciHotPlugInit.inf - MdeModulePkg/Bus/Pci/PciHostBridgeDxe/PciHostBridgeDxe.inf { - - PciHostBridgeLib|OvmfPkg/Library/PciHostBridgeLib/PciHostBridgeLib.inf - } - MdeModulePkg/Bus/Pci/PciBusDxe/PciBusDxe.inf { - - PcdLib|MdePkg/Library/DxePcdLib/DxePcdLib.inf - } - MdeModulePkg/Universal/ResetSystemRuntimeDxe/ResetSystemRuntimeDxe.inf - MdeModulePkg/Universal/Metronome/Metronome.inf - PcAtChipsetPkg/PcatRealTimeClockRuntimeDxe/PcatRealTimeClockRuntimeDxe.inf - MdeModulePkg/Universal/DriverHealthManagerDxe/DriverHealthManagerDxe.inf - MdeModulePkg/Universal/BdsDxe/BdsDxe.inf { - -!ifdef $(CSM_ENABLE) - NULL|OvmfPkg/Csm/CsmSupportLib/CsmSupportLib.inf - NULL|IntelFrameworkModulePkg/Library/LegacyBootManagerLib/LegacyBootManagerLib.inf -!endif - } - MdeModulePkg/Logo/LogoDxe.inf - MdeModulePkg/Application/UiApp/UiApp.inf { - - NULL|MdeModulePkg/Library/DeviceManagerUiLib/DeviceManagerUiLib.inf - NULL|MdeModulePkg/Library/BootManagerUiLib/BootManagerUiLib.inf - NULL|MdeModulePkg/Library/BootMaintenanceManagerUiLib/BootMaintenanceManagerUiLib.inf -!ifdef $(CSM_ENABLE) - NULL|IntelFrameworkModulePkg/Library/LegacyBootManagerLib/LegacyBootManagerLib.inf - NULL|IntelFrameworkModulePkg/Library/LegacyBootMaintUiLib/LegacyBootMaintUiLib.inf -!endif - } - OvmfPkg/BlockMmioToBlockIoDxe/BlockIo.inf - OvmfPkg/VirtioPciDeviceDxe/VirtioPciDeviceDxe.inf - OvmfPkg/Virtio10Dxe/Virtio10.inf - OvmfPkg/VirtioBlkDxe/VirtioBlk.inf - OvmfPkg/VirtioScsiDxe/VirtioScsi.inf - OvmfPkg/VirtioRngDxe/VirtioRng.inf - OvmfPkg/XenIoPciDxe/XenIoPciDxe.inf - OvmfPkg/XenBusDxe/XenBusDxe.inf - OvmfPkg/XenPvBlkDxe/XenPvBlkDxe.inf - MdeModulePkg/Universal/WatchdogTimerDxe/WatchdogTimer.inf - MdeModulePkg/Universal/MonotonicCounterRuntimeDxe/MonotonicCounterRuntimeDxe.inf - MdeModulePkg/Universal/CapsuleRuntimeDxe/CapsuleRuntimeDxe.inf - MdeModulePkg/Universal/Console/ConPlatformDxe/ConPlatformDxe.inf - MdeModulePkg/Universal/Console/ConSplitterDxe/ConSplitterDxe.inf - MdeModulePkg/Universal/Console/GraphicsConsoleDxe/GraphicsConsoleDxe.inf { - - PcdLib|MdePkg/Library/DxePcdLib/DxePcdLib.inf - } - MdeModulePkg/Universal/Console/TerminalDxe/TerminalDxe.inf - MdeModulePkg/Universal/DevicePathDxe/DevicePathDxe.inf { - - DevicePathLib|MdePkg/Library/UefiDevicePathLib/UefiDevicePathLib.inf - PcdLib|MdePkg/Library/BasePcdLibNull/BasePcdLibNull.inf - } - MdeModulePkg/Universal/PrintDxe/PrintDxe.inf - MdeModulePkg/Universal/Disk/DiskIoDxe/DiskIoDxe.inf - MdeModulePkg/Universal/Disk/PartitionDxe/PartitionDxe.inf - MdeModulePkg/Universal/Disk/RamDiskDxe/RamDiskDxe.inf - MdeModulePkg/Universal/Disk/UnicodeCollation/EnglishDxe/EnglishDxe.inf - FatPkg/EnhancedFatDxe/Fat.inf - MdeModulePkg/Bus/Scsi/ScsiBusDxe/ScsiBusDxe.inf - MdeModulePkg/Bus/Scsi/ScsiDiskDxe/ScsiDiskDxe.inf - OvmfPkg/SataControllerDxe/SataControllerDxe.inf - MdeModulePkg/Bus/Ata/AtaAtapiPassThru/AtaAtapiPassThru.inf - MdeModulePkg/Bus/Ata/AtaBusDxe/AtaBusDxe.inf - MdeModulePkg/Bus/Pci/NvmExpressDxe/NvmExpressDxe.inf - MdeModulePkg/Universal/HiiDatabaseDxe/HiiDatabaseDxe.inf - MdeModulePkg/Universal/SetupBrowserDxe/SetupBrowserDxe.inf - MdeModulePkg/Universal/DisplayEngineDxe/DisplayEngineDxe.inf - MdeModulePkg/Universal/MemoryTest/NullMemoryTestDxe/NullMemoryTestDxe.inf - - OvmfPkg/QemuVideoDxe/QemuVideoDxe.inf - OvmfPkg/VirtioGpuDxe/VirtioGpu.inf - - # - # ISA Support - # - PcAtChipsetPkg/IsaAcpiDxe/IsaAcpi.inf - IntelFrameworkModulePkg/Bus/Isa/IsaBusDxe/IsaBusDxe.inf - IntelFrameworkModulePkg/Bus/Isa/IsaSerialDxe/IsaSerialDxe.inf - IntelFrameworkModulePkg/Bus/Isa/Ps2KeyboardDxe/Ps2keyboardDxe.inf - IntelFrameworkModulePkg/Bus/Isa/IsaFloppyDxe/IsaFloppyDxe.inf - - # - # SMBIOS Support - # - MdeModulePkg/Universal/SmbiosDxe/SmbiosDxe.inf { - - NULL|OvmfPkg/Library/SmbiosVersionLib/DetectSmbiosVersionLib.inf - } - OvmfPkg/SmbiosPlatformDxe/SmbiosPlatformDxe.inf - - # - # ACPI Support - # - MdeModulePkg/Universal/Acpi/AcpiTableDxe/AcpiTableDxe.inf - OvmfPkg/AcpiPlatformDxe/AcpiPlatformDxe.inf - OvmfPkg/AcpiTables/AcpiTables.inf - MdeModulePkg/Universal/Acpi/S3SaveStateDxe/S3SaveStateDxe.inf - MdeModulePkg/Universal/Acpi/BootScriptExecutorDxe/BootScriptExecutorDxe.inf - MdeModulePkg/Universal/Acpi/BootGraphicsResourceTableDxe/BootGraphicsResourceTableDxe.inf - - # - # Network Support - # - MdeModulePkg/Universal/Network/SnpDxe/SnpDxe.inf - MdeModulePkg/Universal/Network/DpcDxe/DpcDxe.inf - MdeModulePkg/Universal/Network/MnpDxe/MnpDxe.inf - MdeModulePkg/Universal/Network/VlanConfigDxe/VlanConfigDxe.inf - MdeModulePkg/Universal/Network/ArpDxe/ArpDxe.inf - MdeModulePkg/Universal/Network/Dhcp4Dxe/Dhcp4Dxe.inf - MdeModulePkg/Universal/Network/Ip4Dxe/Ip4Dxe.inf - MdeModulePkg/Universal/Network/Mtftp4Dxe/Mtftp4Dxe.inf - MdeModulePkg/Universal/Network/Udp4Dxe/Udp4Dxe.inf -!if $(NETWORK_IP6_ENABLE) == TRUE - NetworkPkg/Ip6Dxe/Ip6Dxe.inf - NetworkPkg/TcpDxe/TcpDxe.inf - NetworkPkg/Udp6Dxe/Udp6Dxe.inf - NetworkPkg/Dhcp6Dxe/Dhcp6Dxe.inf - NetworkPkg/Mtftp6Dxe/Mtftp6Dxe.inf - NetworkPkg/UefiPxeBcDxe/UefiPxeBcDxe.inf - NetworkPkg/IScsiDxe/IScsiDxe.inf -!else - MdeModulePkg/Universal/Network/Tcp4Dxe/Tcp4Dxe.inf - MdeModulePkg/Universal/Network/UefiPxeBcDxe/UefiPxeBcDxe.inf - MdeModulePkg/Universal/Network/IScsiDxe/IScsiDxe.inf -!endif -!if $(HTTP_BOOT_ENABLE) == TRUE - NetworkPkg/DnsDxe/DnsDxe.inf - NetworkPkg/HttpUtilitiesDxe/HttpUtilitiesDxe.inf - NetworkPkg/HttpDxe/HttpDxe.inf - NetworkPkg/HttpBootDxe/HttpBootDxe.inf -!endif -!if $(TLS_ENABLE) == TRUE - NetworkPkg/TlsDxe/TlsDxe.inf - NetworkPkg/TlsAuthConfigDxe/TlsAuthConfigDxe.inf -!endif - OvmfPkg/VirtioNetDxe/VirtioNet.inf - - # - # Usb Support - # - MdeModulePkg/Bus/Pci/UhciDxe/UhciDxe.inf - MdeModulePkg/Bus/Pci/EhciDxe/EhciDxe.inf - MdeModulePkg/Bus/Pci/XhciDxe/XhciDxe.inf - MdeModulePkg/Bus/Usb/UsbBusDxe/UsbBusDxe.inf - MdeModulePkg/Bus/Usb/UsbKbDxe/UsbKbDxe.inf - MdeModulePkg/Bus/Usb/UsbMassStorageDxe/UsbMassStorageDxe.inf - -!ifdef $(CSM_ENABLE) - IntelFrameworkModulePkg/Csm/BiosThunk/VideoDxe/VideoDxe.inf { - - PcdLib|MdePkg/Library/DxePcdLib/DxePcdLib.inf - } - IntelFrameworkModulePkg/Csm/LegacyBiosDxe/LegacyBiosDxe.inf - OvmfPkg/Csm/Csm16/Csm16.inf -!endif - -!ifndef $(USE_OLD_SHELL) - ShellPkg/Application/Shell/Shell.inf { - - ShellCommandLib|ShellPkg/Library/UefiShellCommandLib/UefiShellCommandLib.inf - NULL|ShellPkg/Library/UefiShellLevel2CommandsLib/UefiShellLevel2CommandsLib.inf - NULL|ShellPkg/Library/UefiShellLevel1CommandsLib/UefiShellLevel1CommandsLib.inf - NULL|ShellPkg/Library/UefiShellLevel3CommandsLib/UefiShellLevel3CommandsLib.inf - NULL|ShellPkg/Library/UefiShellDriver1CommandsLib/UefiShellDriver1CommandsLib.inf - NULL|ShellPkg/Library/UefiShellDebug1CommandsLib/UefiShellDebug1CommandsLib.inf - NULL|ShellPkg/Library/UefiShellInstall1CommandsLib/UefiShellInstall1CommandsLib.inf - NULL|ShellPkg/Library/UefiShellNetwork1CommandsLib/UefiShellNetwork1CommandsLib.inf -!if $(NETWORK_IP6_ENABLE) == TRUE - NULL|ShellPkg/Library/UefiShellNetwork2CommandsLib/UefiShellNetwork2CommandsLib.inf -!endif - NULL|ShellPkg/Library/UefiShellTftpCommandLib/UefiShellTftpCommandLib.inf - HandleParsingLib|ShellPkg/Library/UefiHandleParsingLib/UefiHandleParsingLib.inf - ShellLib|ShellPkg/Library/UefiShellLib/UefiShellLib.inf - FileHandleLib|MdePkg/Library/UefiFileHandleLib/UefiFileHandleLib.inf - PrintLib|MdePkg/Library/BasePrintLib/BasePrintLib.inf -# SafeBlockIoLib|ShellPkg/Library/SafeBlockIoLib/SafeBlockIoLib.inf -# SafeOpenProtocolLib|ShellPkg/Library/SafeOpenProtocolLib/SafeOpenProtocolLib.inf - BcfgCommandLib|ShellPkg/Library/UefiShellBcfgCommandLib/UefiShellBcfgCommandLib.inf - - - gEfiMdePkgTokenSpaceGuid.PcdDebugPropertyMask|0xFF - gEfiShellPkgTokenSpaceGuid.PcdShellLibAutoInitialize|FALSE - gEfiMdePkgTokenSpaceGuid.PcdUefiLibMaxPrintBufferSize|8000 - } -!endif - -!if $(SECURE_BOOT_ENABLE) == TRUE - SecurityPkg/VariableAuthenticated/SecureBootConfigDxe/SecureBootConfigDxe.inf -!endif - - OvmfPkg/PlatformDxe/Platform.inf - -!if $(SMM_REQUIRE) == TRUE - OvmfPkg/SmmAccess/SmmAccess2Dxe.inf - OvmfPkg/SmmControl2Dxe/SmmControl2Dxe.inf - UefiCpuPkg/CpuS3DataDxe/CpuS3DataDxe.inf - - # - # SMM Initial Program Load (a DXE_RUNTIME_DRIVER) - # - MdeModulePkg/Core/PiSmmCore/PiSmmIpl.inf - - # - # SMM_CORE - # - MdeModulePkg/Core/PiSmmCore/PiSmmCore.inf - - # - # Privileged drivers (DXE_SMM_DRIVER modules) - # - UefiCpuPkg/CpuIo2Smm/CpuIo2Smm.inf - MdeModulePkg/Universal/LockBox/SmmLockBox/SmmLockBox.inf { - - LockBoxLib|MdeModulePkg/Library/SmmLockBoxLib/SmmLockBoxSmmLib.inf - } - UefiCpuPkg/PiSmmCpuDxeSmm/PiSmmCpuDxeSmm.inf { - - SmmCpuPlatformHookLib|UefiCpuPkg/Library/SmmCpuPlatformHookLibNull/SmmCpuPlatformHookLibNull.inf - SmmCpuFeaturesLib|OvmfPkg/Library/SmmCpuFeaturesLib/SmmCpuFeaturesLib.inf - } - - # - # Variable driver stack (SMM) - # - OvmfPkg/QemuFlashFvbServicesRuntimeDxe/FvbServicesSmm.inf - MdeModulePkg/Universal/FaultTolerantWriteDxe/FaultTolerantWriteSmm.inf - MdeModulePkg/Universal/Variable/RuntimeDxe/VariableSmm.inf { - - NULL|MdeModulePkg/Library/VarCheckUefiLib/VarCheckUefiLib.inf - } - MdeModulePkg/Universal/Variable/RuntimeDxe/VariableSmmRuntimeDxe.inf - -!else - - # - # Variable driver stack (non-SMM) - # - OvmfPkg/QemuFlashFvbServicesRuntimeDxe/FvbServicesRuntimeDxe.inf - OvmfPkg/EmuVariableFvbRuntimeDxe/Fvb.inf { - - PlatformFvbLib|OvmfPkg/Library/EmuVariableFvbLib/EmuVariableFvbLib.inf - } - MdeModulePkg/Universal/FaultTolerantWriteDxe/FaultTolerantWriteDxe.inf - MdeModulePkg/Universal/Variable/RuntimeDxe/VariableRuntimeDxe.inf { - - NULL|MdeModulePkg/Library/VarCheckUefiLib/VarCheckUefiLib.inf - } -!endif diff --git a/OvmfPkg/OvmfPkgIa32.fdf b/OvmfPkg/OvmfPkgIa32.fdf deleted file mode 100644 index 09c165882c..0000000000 --- a/OvmfPkg/OvmfPkgIa32.fdf +++ /dev/null @@ -1,527 +0,0 @@ -## @file -# Open Virtual Machine Firmware: FDF -# -# Copyright (c) 2006 - 2016, Intel Corporation. All rights reserved.
-# (C) Copyright 2016 Hewlett Packard Enterprise Development LP
-# -# This program and the accompanying materials -# are licensed and made 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] -!include OvmfPkg.fdf.inc - -# -# Build the variable store and the firmware code as one unified flash device -# image. -# -[FD.OVMF] -BaseAddress = $(FW_BASE_ADDRESS) -Size = $(FW_SIZE) -ErasePolarity = 1 -BlockSize = $(BLOCK_SIZE) -NumBlocks = $(FW_BLOCKS) - -!include VarStore.fdf.inc - -$(VARS_SIZE)|$(FVMAIN_SIZE) -FV = FVMAIN_COMPACT - -$(SECFV_OFFSET)|$(SECFV_SIZE) -FV = SECFV - -# -# Build the variable store and the firmware code as separate flash device -# images. -# -[FD.OVMF_VARS] -BaseAddress = $(FW_BASE_ADDRESS) -Size = $(VARS_SIZE) -ErasePolarity = 1 -BlockSize = $(BLOCK_SIZE) -NumBlocks = $(VARS_BLOCKS) - -!include VarStore.fdf.inc - -[FD.OVMF_CODE] -BaseAddress = $(CODE_BASE_ADDRESS) -Size = $(CODE_SIZE) -ErasePolarity = 1 -BlockSize = $(BLOCK_SIZE) -NumBlocks = $(CODE_BLOCKS) - -0x00000000|$(FVMAIN_SIZE) -FV = FVMAIN_COMPACT - -$(FVMAIN_SIZE)|$(SECFV_SIZE) -FV = SECFV - -################################################################################ - -[FD.MEMFD] -BaseAddress = $(MEMFD_BASE_ADDRESS) -Size = 0xB00000 -ErasePolarity = 1 -BlockSize = 0x10000 -NumBlocks = 0xB0 - -0x000000|0x006000 -gUefiOvmfPkgTokenSpaceGuid.PcdOvmfSecPageTablesBase|gUefiOvmfPkgTokenSpaceGuid.PcdOvmfSecPageTablesSize - -0x006000|0x001000 -gUefiOvmfPkgTokenSpaceGuid.PcdOvmfLockBoxStorageBase|gUefiOvmfPkgTokenSpaceGuid.PcdOvmfLockBoxStorageSize - -0x007000|0x001000 -gEfiMdePkgTokenSpaceGuid.PcdGuidedExtractHandlerTableAddress|gUefiOvmfPkgTokenSpaceGuid.PcdGuidedExtractHandlerTableSize - -0x010000|0x008000 -gUefiOvmfPkgTokenSpaceGuid.PcdOvmfSecPeiTempRamBase|gUefiOvmfPkgTokenSpaceGuid.PcdOvmfSecPeiTempRamSize - -0x020000|0x0E0000 -gUefiOvmfPkgTokenSpaceGuid.PcdOvmfPeiMemFvBase|gUefiOvmfPkgTokenSpaceGuid.PcdOvmfPeiMemFvSize -FV = PEIFV - -0x100000|0xA00000 -gUefiOvmfPkgTokenSpaceGuid.PcdOvmfDxeMemFvBase|gUefiOvmfPkgTokenSpaceGuid.PcdOvmfDxeMemFvSize -FV = DXEFV - -################################################################################ - -[FV.SECFV] -FvNameGuid = 763BED0D-DE9F-48F5-81F1-3E90E1B1A015 -BlockSize = 0x1000 -FvAlignment = 16 -ERASE_POLARITY = 1 -MEMORY_MAPPED = TRUE -STICKY_WRITE = TRUE -LOCK_CAP = TRUE -LOCK_STATUS = TRUE -WRITE_DISABLED_CAP = TRUE -WRITE_ENABLED_CAP = TRUE -WRITE_STATUS = TRUE -WRITE_LOCK_CAP = TRUE -WRITE_LOCK_STATUS = TRUE -READ_DISABLED_CAP = TRUE -READ_ENABLED_CAP = TRUE -READ_STATUS = TRUE -READ_LOCK_CAP = TRUE -READ_LOCK_STATUS = TRUE - -# -# SEC Phase modules -# -# The code in this FV handles the initial firmware startup, and -# decompresses the PEI and DXE FVs which handles the rest of the boot sequence. -# -INF OvmfPkg/Sec/SecMain.inf - -INF RuleOverride=RESET_VECTOR OvmfPkg/ResetVector/ResetVector.inf - -################################################################################ -[FV.PEIFV] -FvNameGuid = 6938079B-B503-4E3D-9D24-B28337A25806 -BlockSize = 0x10000 -FvAlignment = 16 -ERASE_POLARITY = 1 -MEMORY_MAPPED = TRUE -STICKY_WRITE = TRUE -LOCK_CAP = TRUE -LOCK_STATUS = TRUE -WRITE_DISABLED_CAP = TRUE -WRITE_ENABLED_CAP = TRUE -WRITE_STATUS = TRUE -WRITE_LOCK_CAP = TRUE -WRITE_LOCK_STATUS = TRUE -READ_DISABLED_CAP = TRUE -READ_ENABLED_CAP = TRUE -READ_STATUS = TRUE -READ_LOCK_CAP = TRUE -READ_LOCK_STATUS = TRUE - -APRIORI PEI { - INF MdeModulePkg/Universal/PCD/Pei/Pcd.inf -} - -# -# PEI Phase modules -# -INF MdeModulePkg/Core/Pei/PeiMain.inf -INF MdeModulePkg/Universal/PCD/Pei/Pcd.inf -INF MdeModulePkg/Universal/ReportStatusCodeRouter/Pei/ReportStatusCodeRouterPei.inf -INF MdeModulePkg/Universal/StatusCodeHandler/Pei/StatusCodeHandlerPei.inf -INF OvmfPkg/PlatformPei/PlatformPei.inf -INF MdeModulePkg/Core/DxeIplPeim/DxeIpl.inf -INF UefiCpuPkg/Universal/Acpi/S3Resume2Pei/S3Resume2Pei.inf -!if $(SMM_REQUIRE) == TRUE -INF OvmfPkg/SmmAccess/SmmAccessPei.inf -!endif -INF UefiCpuPkg/CpuMpPei/CpuMpPei.inf - -################################################################################ - -[FV.DXEFV] -FvNameGuid = 7CB8BDC9-F8EB-4F34-AAEA-3EE4AF6516A1 -BlockSize = 0x10000 -FvAlignment = 16 -ERASE_POLARITY = 1 -MEMORY_MAPPED = TRUE -STICKY_WRITE = TRUE -LOCK_CAP = TRUE -LOCK_STATUS = TRUE -WRITE_DISABLED_CAP = TRUE -WRITE_ENABLED_CAP = TRUE -WRITE_STATUS = TRUE -WRITE_LOCK_CAP = TRUE -WRITE_LOCK_STATUS = TRUE -READ_DISABLED_CAP = TRUE -READ_ENABLED_CAP = TRUE -READ_STATUS = TRUE -READ_LOCK_CAP = TRUE -READ_LOCK_STATUS = TRUE - -APRIORI DXE { - INF MdeModulePkg/Universal/DevicePathDxe/DevicePathDxe.inf - INF MdeModulePkg/Universal/PCD/Dxe/Pcd.inf -!if $(SMM_REQUIRE) == FALSE - INF OvmfPkg/QemuFlashFvbServicesRuntimeDxe/FvbServicesRuntimeDxe.inf -!endif -} - -# -# DXE Phase modules -# -INF MdeModulePkg/Core/Dxe/DxeMain.inf - -INF MdeModulePkg/Universal/ReportStatusCodeRouter/RuntimeDxe/ReportStatusCodeRouterRuntimeDxe.inf -INF MdeModulePkg/Universal/StatusCodeHandler/RuntimeDxe/StatusCodeHandlerRuntimeDxe.inf -INF MdeModulePkg/Universal/PCD/Dxe/Pcd.inf - -INF MdeModulePkg/Core/RuntimeDxe/RuntimeDxe.inf -INF MdeModulePkg/Universal/SecurityStubDxe/SecurityStubDxe.inf -INF MdeModulePkg/Universal/EbcDxe/EbcDxe.inf -INF PcAtChipsetPkg/8259InterruptControllerDxe/8259.inf -INF UefiCpuPkg/CpuIo2Dxe/CpuIo2Dxe.inf -INF UefiCpuPkg/CpuDxe/CpuDxe.inf -INF PcAtChipsetPkg/8254TimerDxe/8254Timer.inf -INF OvmfPkg/IncompatiblePciDeviceSupportDxe/IncompatiblePciDeviceSupport.inf -INF OvmfPkg/PciHotPlugInitDxe/PciHotPlugInit.inf -INF MdeModulePkg/Bus/Pci/PciHostBridgeDxe/PciHostBridgeDxe.inf -INF MdeModulePkg/Bus/Pci/PciBusDxe/PciBusDxe.inf -INF MdeModulePkg/Universal/ResetSystemRuntimeDxe/ResetSystemRuntimeDxe.inf -INF MdeModulePkg/Universal/Metronome/Metronome.inf -INF PcAtChipsetPkg/PcatRealTimeClockRuntimeDxe/PcatRealTimeClockRuntimeDxe.inf - -INF OvmfPkg/BlockMmioToBlockIoDxe/BlockIo.inf -INF OvmfPkg/VirtioPciDeviceDxe/VirtioPciDeviceDxe.inf -INF OvmfPkg/Virtio10Dxe/Virtio10.inf -INF OvmfPkg/VirtioBlkDxe/VirtioBlk.inf -INF OvmfPkg/VirtioScsiDxe/VirtioScsi.inf -INF OvmfPkg/VirtioRngDxe/VirtioRng.inf -INF OvmfPkg/XenIoPciDxe/XenIoPciDxe.inf -INF OvmfPkg/XenBusDxe/XenBusDxe.inf -INF OvmfPkg/XenPvBlkDxe/XenPvBlkDxe.inf - -!if $(SECURE_BOOT_ENABLE) == TRUE - INF SecurityPkg/VariableAuthenticated/SecureBootConfigDxe/SecureBootConfigDxe.inf -!endif - -INF MdeModulePkg/Universal/WatchdogTimerDxe/WatchdogTimer.inf -INF MdeModulePkg/Universal/MonotonicCounterRuntimeDxe/MonotonicCounterRuntimeDxe.inf -INF MdeModulePkg/Universal/CapsuleRuntimeDxe/CapsuleRuntimeDxe.inf -INF MdeModulePkg/Universal/Console/ConPlatformDxe/ConPlatformDxe.inf -INF MdeModulePkg/Universal/Console/ConSplitterDxe/ConSplitterDxe.inf -INF MdeModulePkg/Universal/Console/GraphicsConsoleDxe/GraphicsConsoleDxe.inf -INF MdeModulePkg/Universal/Console/TerminalDxe/TerminalDxe.inf -INF MdeModulePkg/Universal/DriverHealthManagerDxe/DriverHealthManagerDxe.inf -INF MdeModulePkg/Universal/BdsDxe/BdsDxe.inf -INF MdeModulePkg/Application/UiApp/UiApp.inf -INF MdeModulePkg/Universal/DevicePathDxe/DevicePathDxe.inf -INF MdeModulePkg/Universal/PrintDxe/PrintDxe.inf -INF MdeModulePkg/Universal/Disk/DiskIoDxe/DiskIoDxe.inf -INF MdeModulePkg/Universal/Disk/PartitionDxe/PartitionDxe.inf -INF MdeModulePkg/Universal/Disk/RamDiskDxe/RamDiskDxe.inf -INF MdeModulePkg/Universal/Disk/UnicodeCollation/EnglishDxe/EnglishDxe.inf -INF MdeModulePkg/Bus/Scsi/ScsiBusDxe/ScsiBusDxe.inf -INF MdeModulePkg/Bus/Scsi/ScsiDiskDxe/ScsiDiskDxe.inf -INF OvmfPkg/SataControllerDxe/SataControllerDxe.inf -INF MdeModulePkg/Bus/Ata/AtaAtapiPassThru/AtaAtapiPassThru.inf -INF MdeModulePkg/Bus/Ata/AtaBusDxe/AtaBusDxe.inf -INF MdeModulePkg/Bus/Pci/NvmExpressDxe/NvmExpressDxe.inf -INF MdeModulePkg/Universal/HiiDatabaseDxe/HiiDatabaseDxe.inf -INF MdeModulePkg/Universal/SetupBrowserDxe/SetupBrowserDxe.inf -INF MdeModulePkg/Universal/DisplayEngineDxe/DisplayEngineDxe.inf -INF MdeModulePkg/Universal/MemoryTest/NullMemoryTestDxe/NullMemoryTestDxe.inf - -INF PcAtChipsetPkg/IsaAcpiDxe/IsaAcpi.inf -INF IntelFrameworkModulePkg/Bus/Isa/IsaBusDxe/IsaBusDxe.inf - -!ifndef $(SOURCE_DEBUG_ENABLE) -INF IntelFrameworkModulePkg/Bus/Isa/IsaSerialDxe/IsaSerialDxe.inf -!endif - -INF IntelFrameworkModulePkg/Bus/Isa/Ps2KeyboardDxe/Ps2keyboardDxe.inf -INF IntelFrameworkModulePkg/Bus/Isa/IsaFloppyDxe/IsaFloppyDxe.inf - -INF MdeModulePkg/Universal/SmbiosDxe/SmbiosDxe.inf -INF OvmfPkg/SmbiosPlatformDxe/SmbiosPlatformDxe.inf - -INF MdeModulePkg/Universal/Acpi/AcpiTableDxe/AcpiTableDxe.inf -INF OvmfPkg/AcpiPlatformDxe/AcpiPlatformDxe.inf -INF RuleOverride=ACPITABLE OvmfPkg/AcpiTables/AcpiTables.inf -INF MdeModulePkg/Universal/Acpi/S3SaveStateDxe/S3SaveStateDxe.inf -INF MdeModulePkg/Universal/Acpi/BootScriptExecutorDxe/BootScriptExecutorDxe.inf -INF MdeModulePkg/Universal/Acpi/BootGraphicsResourceTableDxe/BootGraphicsResourceTableDxe.inf - -INF FatPkg/EnhancedFatDxe/Fat.inf - -!ifndef $(USE_OLD_SHELL) -INF ShellPkg/Application/Shell/Shell.inf -!else -INF RuleOverride = BINARY EdkShellBinPkg/FullShell/FullShell.inf -!endif - -INF MdeModulePkg/Logo/LogoDxe.inf - -# -# Network modules -# -!if $(E1000_ENABLE) - FILE DRIVER = 5D695E11-9B3F-4b83-B25F-4A8D5D69BE07 { - SECTION PE32 = Intel3.5/EFI32/E3507E2.EFI - } -!endif - INF MdeModulePkg/Universal/Network/SnpDxe/SnpDxe.inf - INF MdeModulePkg/Universal/Network/DpcDxe/DpcDxe.inf - INF MdeModulePkg/Universal/Network/MnpDxe/MnpDxe.inf - INF MdeModulePkg/Universal/Network/VlanConfigDxe/VlanConfigDxe.inf - INF MdeModulePkg/Universal/Network/ArpDxe/ArpDxe.inf - INF MdeModulePkg/Universal/Network/Dhcp4Dxe/Dhcp4Dxe.inf - INF MdeModulePkg/Universal/Network/Ip4Dxe/Ip4Dxe.inf - INF MdeModulePkg/Universal/Network/Mtftp4Dxe/Mtftp4Dxe.inf - INF MdeModulePkg/Universal/Network/Udp4Dxe/Udp4Dxe.inf -!if $(NETWORK_IP6_ENABLE) == TRUE - INF NetworkPkg/Ip6Dxe/Ip6Dxe.inf - INF NetworkPkg/TcpDxe/TcpDxe.inf - INF NetworkPkg/Udp6Dxe/Udp6Dxe.inf - INF NetworkPkg/Dhcp6Dxe/Dhcp6Dxe.inf - INF NetworkPkg/Mtftp6Dxe/Mtftp6Dxe.inf - INF NetworkPkg/UefiPxeBcDxe/UefiPxeBcDxe.inf - INF NetworkPkg/IScsiDxe/IScsiDxe.inf -!else - INF MdeModulePkg/Universal/Network/Tcp4Dxe/Tcp4Dxe.inf - INF MdeModulePkg/Universal/Network/UefiPxeBcDxe/UefiPxeBcDxe.inf - INF MdeModulePkg/Universal/Network/IScsiDxe/IScsiDxe.inf -!endif -!if $(HTTP_BOOT_ENABLE) == TRUE - INF NetworkPkg/DnsDxe/DnsDxe.inf - INF NetworkPkg/HttpUtilitiesDxe/HttpUtilitiesDxe.inf - INF NetworkPkg/HttpDxe/HttpDxe.inf - INF NetworkPkg/HttpBootDxe/HttpBootDxe.inf -!endif -!if $(TLS_ENABLE) == TRUE - INF NetworkPkg/TlsDxe/TlsDxe.inf - INF NetworkPkg/TlsAuthConfigDxe/TlsAuthConfigDxe.inf -!endif - INF OvmfPkg/VirtioNetDxe/VirtioNet.inf - -# -# Usb Support -# -INF MdeModulePkg/Bus/Pci/UhciDxe/UhciDxe.inf -INF MdeModulePkg/Bus/Pci/EhciDxe/EhciDxe.inf -INF MdeModulePkg/Bus/Pci/XhciDxe/XhciDxe.inf -INF MdeModulePkg/Bus/Usb/UsbBusDxe/UsbBusDxe.inf -INF MdeModulePkg/Bus/Usb/UsbKbDxe/UsbKbDxe.inf -INF MdeModulePkg/Bus/Usb/UsbMassStorageDxe/UsbMassStorageDxe.inf - -!ifdef $(CSM_ENABLE) -INF IntelFrameworkModulePkg/Csm/BiosThunk/VideoDxe/VideoDxe.inf -INF IntelFrameworkModulePkg/Csm/LegacyBiosDxe/LegacyBiosDxe.inf -INF RuleOverride=CSM OvmfPkg/Csm/Csm16/Csm16.inf -!endif - -INF OvmfPkg/QemuVideoDxe/QemuVideoDxe.inf -INF OvmfPkg/VirtioGpuDxe/VirtioGpu.inf -INF OvmfPkg/PlatformDxe/Platform.inf - -!if $(SMM_REQUIRE) == TRUE -INF OvmfPkg/SmmAccess/SmmAccess2Dxe.inf -INF OvmfPkg/SmmControl2Dxe/SmmControl2Dxe.inf -INF UefiCpuPkg/CpuS3DataDxe/CpuS3DataDxe.inf -INF MdeModulePkg/Core/PiSmmCore/PiSmmIpl.inf -INF MdeModulePkg/Core/PiSmmCore/PiSmmCore.inf -INF UefiCpuPkg/CpuIo2Smm/CpuIo2Smm.inf -INF MdeModulePkg/Universal/LockBox/SmmLockBox/SmmLockBox.inf -INF UefiCpuPkg/PiSmmCpuDxeSmm/PiSmmCpuDxeSmm.inf - -# -# Variable driver stack (SMM) -# -INF OvmfPkg/QemuFlashFvbServicesRuntimeDxe/FvbServicesSmm.inf -INF MdeModulePkg/Universal/FaultTolerantWriteDxe/FaultTolerantWriteSmm.inf -INF MdeModulePkg/Universal/Variable/RuntimeDxe/VariableSmm.inf -INF MdeModulePkg/Universal/Variable/RuntimeDxe/VariableSmmRuntimeDxe.inf - -!else - -# -# Variable driver stack (non-SMM) -# -INF OvmfPkg/QemuFlashFvbServicesRuntimeDxe/FvbServicesRuntimeDxe.inf -INF OvmfPkg/EmuVariableFvbRuntimeDxe/Fvb.inf -INF MdeModulePkg/Universal/FaultTolerantWriteDxe/FaultTolerantWriteDxe.inf -INF MdeModulePkg/Universal/Variable/RuntimeDxe/VariableRuntimeDxe.inf -!endif - -################################################################################ - -[FV.FVMAIN_COMPACT] -FvNameGuid = 48DB5E17-707C-472D-91CD-1613E7EF51B0 -FvAlignment = 16 -ERASE_POLARITY = 1 -MEMORY_MAPPED = TRUE -STICKY_WRITE = TRUE -LOCK_CAP = TRUE -LOCK_STATUS = TRUE -WRITE_DISABLED_CAP = TRUE -WRITE_ENABLED_CAP = TRUE -WRITE_STATUS = TRUE -WRITE_LOCK_CAP = TRUE -WRITE_LOCK_STATUS = TRUE -READ_DISABLED_CAP = TRUE -READ_ENABLED_CAP = TRUE -READ_STATUS = TRUE -READ_LOCK_CAP = TRUE -READ_LOCK_STATUS = TRUE - -FILE FV_IMAGE = 9E21FD93-9C72-4c15-8C4B-E77F1DB2D792 { - SECTION GUIDED EE4E5898-3914-4259-9D6E-DC7BD79403CF PROCESSING_REQUIRED = TRUE { - # - # These firmware volumes will have files placed in them uncompressed, - # and then both firmware volumes will be compressed in a single - # compression operation in order to achieve better overall compression. - # - SECTION FV_IMAGE = PEIFV - SECTION FV_IMAGE = DXEFV - } - } - -!include DecomprScratchEnd.fdf.inc - -################################################################################ - -[Rule.Common.SEC] - FILE SEC = $(NAMED_GUID) { - PE32 PE32 $(INF_OUTPUT)/$(MODULE_NAME).efi - UI STRING ="$(MODULE_NAME)" Optional - VERSION STRING ="$(INF_VERSION)" Optional BUILD_NUM=$(BUILD_NUMBER) - } - -[Rule.Common.PEI_CORE] - FILE PEI_CORE = $(NAMED_GUID) { - PE32 PE32 Align=Auto $(INF_OUTPUT)/$(MODULE_NAME).efi - UI STRING ="$(MODULE_NAME)" Optional - VERSION STRING ="$(INF_VERSION)" Optional BUILD_NUM=$(BUILD_NUMBER) - } - -[Rule.Common.PEIM] - FILE PEIM = $(NAMED_GUID) { - PEI_DEPEX PEI_DEPEX Optional $(INF_OUTPUT)/$(MODULE_NAME).depex - PE32 PE32 Align=Auto $(INF_OUTPUT)/$(MODULE_NAME).efi - UI STRING="$(MODULE_NAME)" Optional - VERSION STRING="$(INF_VERSION)" Optional BUILD_NUM=$(BUILD_NUMBER) - } - -[Rule.Common.DXE_CORE] - FILE DXE_CORE = $(NAMED_GUID) { - PE32 PE32 $(INF_OUTPUT)/$(MODULE_NAME).efi - UI STRING="$(MODULE_NAME)" Optional - VERSION STRING="$(INF_VERSION)" Optional BUILD_NUM=$(BUILD_NUMBER) - } - -[Rule.Common.DXE_DRIVER] - FILE DRIVER = $(NAMED_GUID) { - DXE_DEPEX DXE_DEPEX Optional $(INF_OUTPUT)/$(MODULE_NAME).depex - PE32 PE32 $(INF_OUTPUT)/$(MODULE_NAME).efi - UI STRING="$(MODULE_NAME)" Optional - VERSION STRING="$(INF_VERSION)" Optional BUILD_NUM=$(BUILD_NUMBER) - RAW ACPI Optional |.acpi - RAW ASL Optional |.aml - } - -[Rule.Common.DXE_RUNTIME_DRIVER] - FILE DRIVER = $(NAMED_GUID) { - DXE_DEPEX DXE_DEPEX Optional $(INF_OUTPUT)/$(MODULE_NAME).depex - PE32 PE32 $(INF_OUTPUT)/$(MODULE_NAME).efi - UI STRING="$(MODULE_NAME)" Optional - VERSION STRING="$(INF_VERSION)" Optional BUILD_NUM=$(BUILD_NUMBER) - } - -[Rule.Common.UEFI_DRIVER] - FILE DRIVER = $(NAMED_GUID) { - DXE_DEPEX DXE_DEPEX Optional $(INF_OUTPUT)/$(MODULE_NAME).depex - PE32 PE32 $(INF_OUTPUT)/$(MODULE_NAME).efi - UI STRING="$(MODULE_NAME)" Optional - VERSION STRING="$(INF_VERSION)" Optional BUILD_NUM=$(BUILD_NUMBER) - } - -[Rule.Common.UEFI_DRIVER.BINARY] - FILE DRIVER = $(NAMED_GUID) { - DXE_DEPEX DXE_DEPEX Optional |.depex - PE32 PE32 |.efi - UI STRING="$(MODULE_NAME)" Optional - VERSION STRING="$(INF_VERSION)" Optional BUILD_NUM=$(BUILD_NUMBER) - } - -[Rule.Common.UEFI_APPLICATION] - FILE APPLICATION = $(NAMED_GUID) { - PE32 PE32 $(INF_OUTPUT)/$(MODULE_NAME).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) - } - -[Rule.Common.USER_DEFINED.ACPITABLE] - FILE FREEFORM = $(NAMED_GUID) { - RAW ACPI |.acpi - RAW ASL |.aml - } - -[Rule.Common.USER_DEFINED.CSM] - FILE FREEFORM = $(NAMED_GUID) { - RAW BIN |.bin - } - -[Rule.Common.SEC.RESET_VECTOR] - FILE RAW = $(NAMED_GUID) { - RAW BIN Align = 16 |.bin - } - -[Rule.Common.SMM_CORE] - FILE SMM_CORE = $(NAMED_GUID) { - PE32 PE32 $(INF_OUTPUT)/$(MODULE_NAME).efi - UI STRING="$(MODULE_NAME)" Optional - VERSION STRING="$(INF_VERSION)" Optional BUILD_NUM=$(BUILD_NUMBER) - } - -[Rule.Common.DXE_SMM_DRIVER] - FILE SMM = $(NAMED_GUID) { - SMM_DEPEX SMM_DEPEX Optional $(INF_OUTPUT)/$(MODULE_NAME).depex - PE32 PE32 $(INF_OUTPUT)/$(MODULE_NAME).efi - UI STRING="$(MODULE_NAME)" Optional - VERSION STRING="$(INF_VERSION)" Optional BUILD_NUM=$(BUILD_NUMBER) - } diff --git a/OvmfPkg/OvmfPkgIa32X64.dsc b/OvmfPkg/OvmfPkgIa32X64.dsc deleted file mode 100644 index 71ac62f023..0000000000 --- a/OvmfPkg/OvmfPkgIa32X64.dsc +++ /dev/null @@ -1,857 +0,0 @@ -## @file -# EFI/Framework Open Virtual Machine Firmware (OVMF) platform -# -# Copyright (c) 2006 - 2017, Intel Corporation. All rights reserved.
-# (C) Copyright 2016 Hewlett Packard Enterprise Development LP
-# -# This program and the accompanying materials -# are licensed and made 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 Section - statements that will be processed to create a Makefile. -# -################################################################################ -[Defines] - PLATFORM_NAME = Ovmf - PLATFORM_GUID = 5a9e7754-d81b-49ea-85ad-69eaa7b1539b - PLATFORM_VERSION = 0.1 - DSC_SPECIFICATION = 0x00010005 - OUTPUT_DIRECTORY = Build/Ovmf3264 - SUPPORTED_ARCHITECTURES = IA32|X64 - BUILD_TARGETS = NOOPT|DEBUG|RELEASE - SKUID_IDENTIFIER = DEFAULT - FLASH_DEFINITION = OvmfPkg/OvmfPkgIa32X64.fdf - - # - # Defines for default states. These can be changed on the command line. - # -D FLAG=VALUE - # - DEFINE SECURE_BOOT_ENABLE = FALSE - DEFINE NETWORK_IP6_ENABLE = FALSE - DEFINE HTTP_BOOT_ENABLE = FALSE - DEFINE SMM_REQUIRE = FALSE - DEFINE TLS_ENABLE = FALSE - -[BuildOptions] - GCC:*_UNIXGCC_*_CC_FLAGS = -DMDEPKG_NDEBUG - GCC:RELEASE_*_*_CC_FLAGS = -DMDEPKG_NDEBUG - 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 - - # - # Disable deprecated APIs. - # - MSFT:*_*_*_CC_FLAGS = /D DISABLE_NEW_DEPRECATED_INTERFACES - INTEL:*_*_*_CC_FLAGS = /D DISABLE_NEW_DEPRECATED_INTERFACES - GCC:*_*_*_CC_FLAGS = -D DISABLE_NEW_DEPRECATED_INTERFACES - -[BuildOptions.common.EDKII.DXE_RUNTIME_DRIVER] - GCC:*_*_*_DLINK_FLAGS = -z common-page-size=0x1000 - -# Force PE/COFF sections to be aligned at 4KB boundaries to support page level -# protection of DXE_SMM_DRIVER/SMM_CORE modules -[BuildOptions.common.EDKII.DXE_SMM_DRIVER, BuildOptions.common.EDKII.SMM_CORE] - GCC:*_*_*_DLINK_FLAGS = -z common-page-size=0x1000 - -################################################################################ -# -# SKU Identification section - list of all SKU IDs supported by this Platform. -# -################################################################################ -[SkuIds] - 0|DEFAULT - -################################################################################ -# -# Library Class section - list of all Library Classes needed by this Platform. -# -################################################################################ -[LibraryClasses] - PcdLib|MdePkg/Library/BasePcdLibNull/BasePcdLibNull.inf - TimerLib|OvmfPkg/Library/AcpiTimerLib/BaseAcpiTimerLib.inf - PrintLib|MdePkg/Library/BasePrintLib/BasePrintLib.inf - BaseMemoryLib|MdePkg/Library/BaseMemoryLibRepStr/BaseMemoryLibRepStr.inf - BaseLib|MdePkg/Library/BaseLib/BaseLib.inf - SynchronizationLib|MdePkg/Library/BaseSynchronizationLib/BaseSynchronizationLib.inf - CpuLib|MdePkg/Library/BaseCpuLib/BaseCpuLib.inf - PerformanceLib|MdePkg/Library/BasePerformanceLibNull/BasePerformanceLibNull.inf - PeCoffLib|MdePkg/Library/BasePeCoffLib/BasePeCoffLib.inf - CacheMaintenanceLib|MdePkg/Library/BaseCacheMaintenanceLib/BaseCacheMaintenanceLib.inf - UefiDecompressLib|MdePkg/Library/BaseUefiDecompressLib/BaseUefiDecompressLib.inf - UefiHiiServicesLib|MdeModulePkg/Library/UefiHiiServicesLib/UefiHiiServicesLib.inf - HiiLib|MdeModulePkg/Library/UefiHiiLib/UefiHiiLib.inf - SortLib|MdeModulePkg/Library/UefiSortLib/UefiSortLib.inf - UefiBootManagerLib|MdeModulePkg/Library/UefiBootManagerLib/UefiBootManagerLib.inf - BootLogoLib|MdeModulePkg/Library/BootLogoLib/BootLogoLib.inf - FileExplorerLib|MdeModulePkg/Library/FileExplorerLib/FileExplorerLib.inf - CapsuleLib|MdeModulePkg/Library/DxeCapsuleLibNull/DxeCapsuleLibNull.inf - DxeServicesLib|MdePkg/Library/DxeServicesLib/DxeServicesLib.inf - DxeServicesTableLib|MdePkg/Library/DxeServicesTableLib/DxeServicesTableLib.inf - PeCoffGetEntryPointLib|MdePkg/Library/BasePeCoffGetEntryPointLib/BasePeCoffGetEntryPointLib.inf - PciCf8Lib|MdePkg/Library/BasePciCf8Lib/BasePciCf8Lib.inf - PciExpressLib|MdePkg/Library/BasePciExpressLib/BasePciExpressLib.inf - PciLib|MdePkg/Library/BasePciLibCf8/BasePciLibCf8.inf - PciSegmentLib|MdePkg/Library/BasePciSegmentLibPci/BasePciSegmentLibPci.inf - IoLib|MdePkg/Library/BaseIoLibIntrinsic/BaseIoLibIntrinsic.inf - OemHookStatusCodeLib|MdeModulePkg/Library/OemHookStatusCodeLibNull/OemHookStatusCodeLibNull.inf - SerialPortLib|PcAtChipsetPkg/Library/SerialIoLib/SerialIoLib.inf - MtrrLib|UefiCpuPkg/Library/MtrrLib/MtrrLib.inf - UefiLib|MdePkg/Library/UefiLib/UefiLib.inf - UefiBootServicesTableLib|MdePkg/Library/UefiBootServicesTableLib/UefiBootServicesTableLib.inf - UefiRuntimeServicesTableLib|MdePkg/Library/UefiRuntimeServicesTableLib/UefiRuntimeServicesTableLib.inf - UefiDriverEntryPoint|MdePkg/Library/UefiDriverEntryPoint/UefiDriverEntryPoint.inf - UefiApplicationEntryPoint|MdePkg/Library/UefiApplicationEntryPoint/UefiApplicationEntryPoint.inf - DevicePathLib|MdePkg/Library/UefiDevicePathLibDevicePathProtocol/UefiDevicePathLibDevicePathProtocol.inf - NvVarsFileLib|OvmfPkg/Library/NvVarsFileLib/NvVarsFileLib.inf - FileHandleLib|MdePkg/Library/UefiFileHandleLib/UefiFileHandleLib.inf - UefiCpuLib|UefiCpuPkg/Library/BaseUefiCpuLib/BaseUefiCpuLib.inf - SecurityManagementLib|MdeModulePkg/Library/DxeSecurityManagementLib/DxeSecurityManagementLib.inf - NetLib|MdeModulePkg/Library/DxeNetLib/DxeNetLib.inf - IpIoLib|MdeModulePkg/Library/DxeIpIoLib/DxeIpIoLib.inf - UdpIoLib|MdeModulePkg/Library/DxeUdpIoLib/DxeUdpIoLib.inf - DpcLib|MdeModulePkg/Library/DxeDpcLib/DxeDpcLib.inf - UefiUsbLib|MdePkg/Library/UefiUsbLib/UefiUsbLib.inf - SerializeVariablesLib|OvmfPkg/Library/SerializeVariablesLib/SerializeVariablesLib.inf - QemuFwCfgLib|OvmfPkg/Library/QemuFwCfgLib/QemuFwCfgLib.inf - VirtioLib|OvmfPkg/Library/VirtioLib/VirtioLib.inf - LoadLinuxLib|OvmfPkg/Library/LoadLinuxLib/LoadLinuxLib.inf -!if $(SMM_REQUIRE) == FALSE - LockBoxLib|OvmfPkg/Library/LockBoxLib/LockBoxBaseLib.inf -!endif - CustomizedDisplayLib|MdeModulePkg/Library/CustomizedDisplayLib/CustomizedDisplayLib.inf - FrameBufferBltLib|MdeModulePkg/Library/FrameBufferBltLib/FrameBufferBltLib.inf - -!ifdef $(SOURCE_DEBUG_ENABLE) - PeCoffExtraActionLib|SourceLevelDebugPkg/Library/PeCoffExtraActionLibDebug/PeCoffExtraActionLibDebug.inf - DebugCommunicationLib|SourceLevelDebugPkg/Library/DebugCommunicationLibSerialPort/DebugCommunicationLibSerialPort.inf -!else - PeCoffExtraActionLib|MdePkg/Library/BasePeCoffExtraActionLibNull/BasePeCoffExtraActionLibNull.inf - DebugAgentLib|MdeModulePkg/Library/DebugAgentLibNull/DebugAgentLibNull.inf -!endif - - ResetSystemLib|OvmfPkg/Library/ResetSystemLib/ResetSystemLib.inf - LocalApicLib|UefiCpuPkg/Library/BaseXApicX2ApicLib/BaseXApicX2ApicLib.inf - DebugPrintErrorLevelLib|MdePkg/Library/BaseDebugPrintErrorLevelLib/BaseDebugPrintErrorLevelLib.inf - - IntrinsicLib|CryptoPkg/Library/IntrinsicLib/IntrinsicLib.inf -!if $(TLS_ENABLE) == TRUE - OpensslLib|CryptoPkg/Library/OpensslLib/OpensslLib.inf -!else - OpensslLib|CryptoPkg/Library/OpensslLib/OpensslLibCrypto.inf -!endif - -!if $(SECURE_BOOT_ENABLE) == TRUE - PlatformSecureLib|OvmfPkg/Library/PlatformSecureLib/PlatformSecureLib.inf - TpmMeasurementLib|SecurityPkg/Library/DxeTpmMeasurementLib/DxeTpmMeasurementLib.inf - AuthVariableLib|SecurityPkg/Library/AuthVariableLib/AuthVariableLib.inf -!else - TpmMeasurementLib|MdeModulePkg/Library/TpmMeasurementLibNull/TpmMeasurementLibNull.inf - AuthVariableLib|MdeModulePkg/Library/AuthVariableLibNull/AuthVariableLibNull.inf -!endif - VarCheckLib|MdeModulePkg/Library/VarCheckLib/VarCheckLib.inf - -!if $(NETWORK_IP6_ENABLE) == TRUE - TcpIoLib|MdeModulePkg/Library/DxeTcpIoLib/DxeTcpIoLib.inf -!endif - -!if $(HTTP_BOOT_ENABLE) == TRUE - HttpLib|MdeModulePkg/Library/DxeHttpLib/DxeHttpLib.inf -!endif - -!if $(TLS_ENABLE) == TRUE - TlsLib|CryptoPkg/Library/TlsLib/TlsLib.inf -!endif - - S3BootScriptLib|MdeModulePkg/Library/PiDxeS3BootScriptLib/DxeS3BootScriptLib.inf - SmbusLib|MdePkg/Library/BaseSmbusLibNull/BaseSmbusLibNull.inf - OrderedCollectionLib|MdePkg/Library/BaseOrderedCollectionRedBlackTreeLib/BaseOrderedCollectionRedBlackTreeLib.inf - XenHypercallLib|OvmfPkg/Library/XenHypercallLib/XenHypercallLib.inf - -[LibraryClasses.common] - BaseCryptLib|CryptoPkg/Library/BaseCryptLib/BaseCryptLib.inf - -[LibraryClasses.common.SEC] - TimerLib|OvmfPkg/Library/AcpiTimerLib/BaseRomAcpiTimerLib.inf - QemuFwCfgLib|OvmfPkg/Library/QemuFwCfgLib/QemuFwCfgSecLib.inf -!ifdef $(DEBUG_ON_SERIAL_PORT) - DebugLib|MdePkg/Library/BaseDebugLibSerialPort/BaseDebugLibSerialPort.inf -!else - DebugLib|OvmfPkg/Library/PlatformDebugLibIoPort/PlatformDebugLibIoPort.inf -!endif - ReportStatusCodeLib|MdeModulePkg/Library/PeiReportStatusCodeLib/PeiReportStatusCodeLib.inf - ExtractGuidedSectionLib|MdePkg/Library/BaseExtractGuidedSectionLib/BaseExtractGuidedSectionLib.inf -!ifdef $(SOURCE_DEBUG_ENABLE) - DebugAgentLib|SourceLevelDebugPkg/Library/DebugAgent/SecPeiDebugAgentLib.inf -!endif - HobLib|MdePkg/Library/PeiHobLib/PeiHobLib.inf - PeiServicesLib|MdePkg/Library/PeiServicesLib/PeiServicesLib.inf - PeiServicesTablePointerLib|MdePkg/Library/PeiServicesTablePointerLibIdt/PeiServicesTablePointerLibIdt.inf - MemoryAllocationLib|MdePkg/Library/PeiMemoryAllocationLib/PeiMemoryAllocationLib.inf - CpuExceptionHandlerLib|UefiCpuPkg/Library/CpuExceptionHandlerLib/SecPeiCpuExceptionHandlerLib.inf - -[LibraryClasses.common.PEI_CORE] - HobLib|MdePkg/Library/PeiHobLib/PeiHobLib.inf - PeiServicesTablePointerLib|MdePkg/Library/PeiServicesTablePointerLibIdt/PeiServicesTablePointerLibIdt.inf - PeiServicesLib|MdePkg/Library/PeiServicesLib/PeiServicesLib.inf - MemoryAllocationLib|MdePkg/Library/PeiMemoryAllocationLib/PeiMemoryAllocationLib.inf - PeiCoreEntryPoint|MdePkg/Library/PeiCoreEntryPoint/PeiCoreEntryPoint.inf - ReportStatusCodeLib|MdeModulePkg/Library/PeiReportStatusCodeLib/PeiReportStatusCodeLib.inf - OemHookStatusCodeLib|MdeModulePkg/Library/OemHookStatusCodeLibNull/OemHookStatusCodeLibNull.inf - PeCoffGetEntryPointLib|MdePkg/Library/BasePeCoffGetEntryPointLib/BasePeCoffGetEntryPointLib.inf -!ifdef $(DEBUG_ON_SERIAL_PORT) - DebugLib|MdePkg/Library/BaseDebugLibSerialPort/BaseDebugLibSerialPort.inf -!else - DebugLib|OvmfPkg/Library/PlatformDebugLibIoPort/PlatformDebugLibIoPort.inf -!endif - PeCoffLib|MdePkg/Library/BasePeCoffLib/BasePeCoffLib.inf - -[LibraryClasses.common.PEIM] - HobLib|MdePkg/Library/PeiHobLib/PeiHobLib.inf - PeiServicesTablePointerLib|MdePkg/Library/PeiServicesTablePointerLibIdt/PeiServicesTablePointerLibIdt.inf - PeiServicesLib|MdePkg/Library/PeiServicesLib/PeiServicesLib.inf - MemoryAllocationLib|MdePkg/Library/PeiMemoryAllocationLib/PeiMemoryAllocationLib.inf - PeimEntryPoint|MdePkg/Library/PeimEntryPoint/PeimEntryPoint.inf - ReportStatusCodeLib|MdeModulePkg/Library/PeiReportStatusCodeLib/PeiReportStatusCodeLib.inf - OemHookStatusCodeLib|MdeModulePkg/Library/OemHookStatusCodeLibNull/OemHookStatusCodeLibNull.inf - PeCoffGetEntryPointLib|MdePkg/Library/BasePeCoffGetEntryPointLib/BasePeCoffGetEntryPointLib.inf -!ifdef $(DEBUG_ON_SERIAL_PORT) - DebugLib|MdePkg/Library/BaseDebugLibSerialPort/BaseDebugLibSerialPort.inf -!else - DebugLib|OvmfPkg/Library/PlatformDebugLibIoPort/PlatformDebugLibIoPort.inf -!endif - PeCoffLib|MdePkg/Library/BasePeCoffLib/BasePeCoffLib.inf - PeiResourcePublicationLib|MdePkg/Library/PeiResourcePublicationLib/PeiResourcePublicationLib.inf - ExtractGuidedSectionLib|MdePkg/Library/PeiExtractGuidedSectionLib/PeiExtractGuidedSectionLib.inf -!ifdef $(SOURCE_DEBUG_ENABLE) - DebugAgentLib|SourceLevelDebugPkg/Library/DebugAgent/SecPeiDebugAgentLib.inf -!endif - CpuExceptionHandlerLib|UefiCpuPkg/Library/CpuExceptionHandlerLib/PeiCpuExceptionHandlerLib.inf - MpInitLib|UefiCpuPkg/Library/MpInitLib/PeiMpInitLib.inf - QemuFwCfgS3Lib|OvmfPkg/Library/QemuFwCfgS3Lib/PeiQemuFwCfgS3LibFwCfg.inf - -[LibraryClasses.common.DXE_CORE] - HobLib|MdePkg/Library/DxeCoreHobLib/DxeCoreHobLib.inf - DxeCoreEntryPoint|MdePkg/Library/DxeCoreEntryPoint/DxeCoreEntryPoint.inf - MemoryAllocationLib|MdeModulePkg/Library/DxeCoreMemoryAllocationLib/DxeCoreMemoryAllocationLib.inf - ReportStatusCodeLib|MdeModulePkg/Library/DxeReportStatusCodeLib/DxeReportStatusCodeLib.inf -!ifdef $(DEBUG_ON_SERIAL_PORT) - DebugLib|MdePkg/Library/BaseDebugLibSerialPort/BaseDebugLibSerialPort.inf -!else - DebugLib|OvmfPkg/Library/PlatformDebugLibIoPort/PlatformDebugLibIoPort.inf -!endif - ExtractGuidedSectionLib|MdePkg/Library/DxeExtractGuidedSectionLib/DxeExtractGuidedSectionLib.inf -!ifdef $(SOURCE_DEBUG_ENABLE) - DebugAgentLib|SourceLevelDebugPkg/Library/DebugAgent/DxeDebugAgentLib.inf -!endif - CpuExceptionHandlerLib|UefiCpuPkg/Library/CpuExceptionHandlerLib/DxeCpuExceptionHandlerLib.inf - PcdLib|MdePkg/Library/DxePcdLib/DxePcdLib.inf - -[LibraryClasses.common.DXE_RUNTIME_DRIVER] - PcdLib|MdePkg/Library/DxePcdLib/DxePcdLib.inf - TimerLib|OvmfPkg/Library/AcpiTimerLib/DxeAcpiTimerLib.inf - HobLib|MdePkg/Library/DxeHobLib/DxeHobLib.inf - DxeCoreEntryPoint|MdePkg/Library/DxeCoreEntryPoint/DxeCoreEntryPoint.inf - MemoryAllocationLib|MdePkg/Library/UefiMemoryAllocationLib/UefiMemoryAllocationLib.inf - ReportStatusCodeLib|MdeModulePkg/Library/RuntimeDxeReportStatusCodeLib/RuntimeDxeReportStatusCodeLib.inf -!ifdef $(DEBUG_ON_SERIAL_PORT) - DebugLib|MdePkg/Library/BaseDebugLibSerialPort/BaseDebugLibSerialPort.inf -!else - DebugLib|OvmfPkg/Library/PlatformDebugLibIoPort/PlatformDebugLibIoPort.inf -!endif - UefiRuntimeLib|MdePkg/Library/UefiRuntimeLib/UefiRuntimeLib.inf - BaseCryptLib|CryptoPkg/Library/BaseCryptLib/RuntimeCryptLib.inf - PciLib|OvmfPkg/Library/DxePciLibI440FxQ35/DxePciLibI440FxQ35.inf - QemuFwCfgS3Lib|OvmfPkg/Library/QemuFwCfgS3Lib/DxeQemuFwCfgS3LibFwCfg.inf - -[LibraryClasses.common.UEFI_DRIVER] - PcdLib|MdePkg/Library/DxePcdLib/DxePcdLib.inf - TimerLib|OvmfPkg/Library/AcpiTimerLib/DxeAcpiTimerLib.inf - HobLib|MdePkg/Library/DxeHobLib/DxeHobLib.inf - DxeCoreEntryPoint|MdePkg/Library/DxeCoreEntryPoint/DxeCoreEntryPoint.inf - MemoryAllocationLib|MdePkg/Library/UefiMemoryAllocationLib/UefiMemoryAllocationLib.inf - ReportStatusCodeLib|MdeModulePkg/Library/DxeReportStatusCodeLib/DxeReportStatusCodeLib.inf -!ifdef $(DEBUG_ON_SERIAL_PORT) - DebugLib|MdePkg/Library/BaseDebugLibSerialPort/BaseDebugLibSerialPort.inf -!else - DebugLib|OvmfPkg/Library/PlatformDebugLibIoPort/PlatformDebugLibIoPort.inf -!endif - UefiScsiLib|MdePkg/Library/UefiScsiLib/UefiScsiLib.inf - PciLib|OvmfPkg/Library/DxePciLibI440FxQ35/DxePciLibI440FxQ35.inf - -[LibraryClasses.common.DXE_DRIVER] - PcdLib|MdePkg/Library/DxePcdLib/DxePcdLib.inf - TimerLib|OvmfPkg/Library/AcpiTimerLib/DxeAcpiTimerLib.inf - HobLib|MdePkg/Library/DxeHobLib/DxeHobLib.inf - MemoryAllocationLib|MdePkg/Library/UefiMemoryAllocationLib/UefiMemoryAllocationLib.inf - ReportStatusCodeLib|MdeModulePkg/Library/DxeReportStatusCodeLib/DxeReportStatusCodeLib.inf - UefiScsiLib|MdePkg/Library/UefiScsiLib/UefiScsiLib.inf -!ifdef $(DEBUG_ON_SERIAL_PORT) - DebugLib|MdePkg/Library/BaseDebugLibSerialPort/BaseDebugLibSerialPort.inf -!else - DebugLib|OvmfPkg/Library/PlatformDebugLibIoPort/PlatformDebugLibIoPort.inf -!endif - NetLib|MdeModulePkg/Library/DxeNetLib/DxeNetLib.inf - IpIoLib|MdeModulePkg/Library/DxeIpIoLib/DxeIpIoLib.inf - UdpIoLib|MdeModulePkg/Library/DxeUdpIoLib/DxeUdpIoLib.inf - DpcLib|MdeModulePkg/Library/DxeDpcLib/DxeDpcLib.inf - PlatformBootManagerLib|OvmfPkg/Library/PlatformBootManagerLib/PlatformBootManagerLib.inf - QemuBootOrderLib|OvmfPkg/Library/QemuBootOrderLib/QemuBootOrderLib.inf - CpuExceptionHandlerLib|UefiCpuPkg/Library/CpuExceptionHandlerLib/DxeCpuExceptionHandlerLib.inf -!if $(SMM_REQUIRE) == TRUE - LockBoxLib|MdeModulePkg/Library/SmmLockBoxLib/SmmLockBoxDxeLib.inf -!else - LockBoxLib|OvmfPkg/Library/LockBoxLib/LockBoxDxeLib.inf -!endif -!ifdef $(SOURCE_DEBUG_ENABLE) - DebugAgentLib|SourceLevelDebugPkg/Library/DebugAgent/DxeDebugAgentLib.inf -!endif - PciLib|OvmfPkg/Library/DxePciLibI440FxQ35/DxePciLibI440FxQ35.inf - MpInitLib|UefiCpuPkg/Library/MpInitLib/DxeMpInitLib.inf - QemuFwCfgS3Lib|OvmfPkg/Library/QemuFwCfgS3Lib/DxeQemuFwCfgS3LibFwCfg.inf - -[LibraryClasses.common.UEFI_APPLICATION] - PcdLib|MdePkg/Library/DxePcdLib/DxePcdLib.inf - TimerLib|OvmfPkg/Library/AcpiTimerLib/DxeAcpiTimerLib.inf - HobLib|MdePkg/Library/DxeHobLib/DxeHobLib.inf - MemoryAllocationLib|MdePkg/Library/UefiMemoryAllocationLib/UefiMemoryAllocationLib.inf - ReportStatusCodeLib|MdeModulePkg/Library/DxeReportStatusCodeLib/DxeReportStatusCodeLib.inf -!ifdef $(DEBUG_ON_SERIAL_PORT) - DebugLib|MdePkg/Library/BaseDebugLibSerialPort/BaseDebugLibSerialPort.inf -!else - DebugLib|OvmfPkg/Library/PlatformDebugLibIoPort/PlatformDebugLibIoPort.inf -!endif - PciLib|OvmfPkg/Library/DxePciLibI440FxQ35/DxePciLibI440FxQ35.inf - -[LibraryClasses.common.DXE_SMM_DRIVER] - PcdLib|MdePkg/Library/DxePcdLib/DxePcdLib.inf - TimerLib|OvmfPkg/Library/AcpiTimerLib/DxeAcpiTimerLib.inf - MemoryAllocationLib|MdePkg/Library/SmmMemoryAllocationLib/SmmMemoryAllocationLib.inf - ReportStatusCodeLib|MdeModulePkg/Library/DxeReportStatusCodeLib/DxeReportStatusCodeLib.inf - HobLib|MdePkg/Library/DxeHobLib/DxeHobLib.inf - SmmMemLib|MdePkg/Library/SmmMemLib/SmmMemLib.inf - SmmServicesTableLib|MdePkg/Library/SmmServicesTableLib/SmmServicesTableLib.inf -!ifdef $(DEBUG_ON_SERIAL_PORT) - DebugLib|MdePkg/Library/BaseDebugLibSerialPort/BaseDebugLibSerialPort.inf -!else - DebugLib|OvmfPkg/Library/PlatformDebugLibIoPort/PlatformDebugLibIoPort.inf -!endif - CpuExceptionHandlerLib|UefiCpuPkg/Library/CpuExceptionHandlerLib/SmmCpuExceptionHandlerLib.inf -!ifdef $(SOURCE_DEBUG_ENABLE) - DebugAgentLib|SourceLevelDebugPkg/Library/DebugAgent/SmmDebugAgentLib.inf -!endif - BaseCryptLib|CryptoPkg/Library/BaseCryptLib/SmmCryptLib.inf - PciLib|OvmfPkg/Library/DxePciLibI440FxQ35/DxePciLibI440FxQ35.inf - -[LibraryClasses.common.SMM_CORE] - PcdLib|MdePkg/Library/DxePcdLib/DxePcdLib.inf - TimerLib|OvmfPkg/Library/AcpiTimerLib/DxeAcpiTimerLib.inf - SmmCorePlatformHookLib|MdeModulePkg/Library/SmmCorePlatformHookLibNull/SmmCorePlatformHookLibNull.inf - MemoryAllocationLib|MdeModulePkg/Library/PiSmmCoreMemoryAllocationLib/PiSmmCoreMemoryAllocationLib.inf - ReportStatusCodeLib|MdeModulePkg/Library/DxeReportStatusCodeLib/DxeReportStatusCodeLib.inf - HobLib|MdePkg/Library/DxeHobLib/DxeHobLib.inf - SmmMemLib|MdePkg/Library/SmmMemLib/SmmMemLib.inf - SmmServicesTableLib|MdeModulePkg/Library/PiSmmCoreSmmServicesTableLib/PiSmmCoreSmmServicesTableLib.inf -!ifdef $(DEBUG_ON_SERIAL_PORT) - DebugLib|MdePkg/Library/BaseDebugLibSerialPort/BaseDebugLibSerialPort.inf -!else - DebugLib|OvmfPkg/Library/PlatformDebugLibIoPort/PlatformDebugLibIoPort.inf -!endif - PciLib|OvmfPkg/Library/DxePciLibI440FxQ35/DxePciLibI440FxQ35.inf - -################################################################################ -# -# Pcd Section - list of all EDK II PCD Entries defined by this Platform. -# -################################################################################ -[PcdsFeatureFlag] - gEfiMdeModulePkgTokenSpaceGuid.PcdHiiOsRuntimeSupport|FALSE - gEfiMdeModulePkgTokenSpaceGuid.PcdStatusCodeUseSerial|FALSE - gEfiMdeModulePkgTokenSpaceGuid.PcdStatusCodeUseMemory|TRUE - gEfiMdeModulePkgTokenSpaceGuid.PcdDxeIplSupportUefiDecompress|FALSE - gEfiMdeModulePkgTokenSpaceGuid.PcdDxeIplSwitchToLongMode|TRUE - gEfiMdeModulePkgTokenSpaceGuid.PcdConOutGopSupport|TRUE - gEfiMdeModulePkgTokenSpaceGuid.PcdConOutUgaSupport|FALSE - gEfiMdeModulePkgTokenSpaceGuid.PcdInstallAcpiSdtProtocol|TRUE -!if $(SECURE_BOOT_ENABLE) == TRUE - gUefiOvmfPkgTokenSpaceGuid.PcdSecureBootEnable|TRUE -!endif -!if $(SMM_REQUIRE) == TRUE - gUefiOvmfPkgTokenSpaceGuid.PcdSmmSmramRequire|TRUE - gUefiCpuPkgTokenSpaceGuid.PcdCpuSmmEnableBspElection|FALSE -!endif - -[PcdsFixedAtBuild] - gEfiMdeModulePkgTokenSpaceGuid.PcdStatusCodeMemorySize|1 - gEfiMdeModulePkgTokenSpaceGuid.PcdResetOnMemoryTypeInformationChange|FALSE - gEfiMdePkgTokenSpaceGuid.PcdMaximumGuidedExtractHandler|0x10 - gEfiMdeModulePkgTokenSpaceGuid.PcdPeiCoreMaxFvSupported|6 - gEfiMdeModulePkgTokenSpaceGuid.PcdPeiCoreMaxPeimPerFv|32 - gEfiMdeModulePkgTokenSpaceGuid.PcdMaxVariableSize|0x2000 - gEfiMdeModulePkgTokenSpaceGuid.PcdMaxAuthVariableSize|0x2800 - gEfiMdeModulePkgTokenSpaceGuid.PcdVariableStoreSize|0xe000 - - gEfiMdeModulePkgTokenSpaceGuid.PcdVpdBaseAddress|0x0 - - gEfiMdePkgTokenSpaceGuid.PcdReportStatusCodePropertyMask|0x07 - - # DEBUG_INIT 0x00000001 // Initialization - # DEBUG_WARN 0x00000002 // Warnings - # DEBUG_LOAD 0x00000004 // Load events - # DEBUG_FS 0x00000008 // EFI File system - # DEBUG_POOL 0x00000010 // Alloc & Free (pool) - # DEBUG_PAGE 0x00000020 // Alloc & Free (page) - # DEBUG_INFO 0x00000040 // Informational debug messages - # DEBUG_DISPATCH 0x00000080 // PEI/DXE/SMM Dispatchers - # DEBUG_VARIABLE 0x00000100 // Variable - # DEBUG_BM 0x00000400 // Boot Manager - # DEBUG_BLKIO 0x00001000 // BlkIo Driver - # DEBUG_NET 0x00004000 // SNP Driver - # DEBUG_UNDI 0x00010000 // UNDI Driver - # DEBUG_LOADFILE 0x00020000 // LoadFile - # DEBUG_EVENT 0x00080000 // Event messages - # DEBUG_GCD 0x00100000 // Global Coherency Database changes - # DEBUG_CACHE 0x00200000 // Memory range cachability changes - # DEBUG_VERBOSE 0x00400000 // Detailed debug messages that may - # // significantly impact boot performance - # DEBUG_ERROR 0x80000000 // Error - gEfiMdePkgTokenSpaceGuid.PcdDebugPrintErrorLevel|0x8000004F - -!ifdef $(SOURCE_DEBUG_ENABLE) - gEfiMdePkgTokenSpaceGuid.PcdDebugPropertyMask|0x17 -!else - gEfiMdePkgTokenSpaceGuid.PcdDebugPropertyMask|0x2F -!endif - - # This PCD is used to set the base address of the PCI express hierarchy. It - # is only consulted when OVMF runs on Q35. In that case it is programmed into - # the PCIEXBAR register. - # - # On Q35 machine types that QEMU intends to support in the long term, QEMU - # never lets the RAM below 4 GB exceed 2 GB. - gEfiMdePkgTokenSpaceGuid.PcdPciExpressBaseAddress|0x80000000 - -!ifdef $(SOURCE_DEBUG_ENABLE) - gEfiSourceLevelDebugPkgTokenSpaceGuid.PcdDebugLoadImageMethod|0x2 -!endif - -[PcdsFixedAtBuild.X64] -!if $(HTTP_BOOT_ENABLE) == TRUE - gEfiNetworkPkgTokenSpaceGuid.PcdAllowHttpConnections|TRUE -!endif - -!ifndef $(USE_OLD_SHELL) - gEfiIntelFrameworkModulePkgTokenSpaceGuid.PcdShellFile|{ 0x83, 0xA5, 0x04, 0x7C, 0x3E, 0x9E, 0x1C, 0x4F, 0xAD, 0x65, 0xE0, 0x52, 0x68, 0xD0, 0xB4, 0xD1 } -!endif - -!if $(SMM_REQUIRE) == TRUE - gUefiCpuPkgTokenSpaceGuid.PcdCpuSmmStackSize|0x4000 -!endif - -!if $(SECURE_BOOT_ENABLE) == TRUE - gEfiSecurityPkgTokenSpaceGuid.PcdOptionRomImageVerificationPolicy|0x00 -!endif - - # IRQs 5, 9, 10, 11 are level-triggered - gPcAtChipsetPkgTokenSpaceGuid.Pcd8259LegacyModeEdgeLevel|0x0E20 - - # Point to the MdeModulePkg/Application/UiApp/UiApp.inf - gEfiMdeModulePkgTokenSpaceGuid.PcdBootManagerMenuFile|{ 0x21, 0xaa, 0x2c, 0x46, 0x14, 0x76, 0x03, 0x45, 0x83, 0x6e, 0x8a, 0xb6, 0xf4, 0x66, 0x23, 0x31 } - -################################################################################ -# -# Pcd Dynamic Section - list of all EDK II PCD Entries defined by this Platform -# -################################################################################ - -[PcdsDynamicDefault] - gEfiMdeModulePkgTokenSpaceGuid.PcdEmuVariableNvStoreReserved|0 - gEfiMdeModulePkgTokenSpaceGuid.PcdFlashNvStorageVariableBase64|0 - gEfiMdeModulePkgTokenSpaceGuid.PcdFlashNvStorageFtwWorkingBase|0 - gEfiMdeModulePkgTokenSpaceGuid.PcdFlashNvStorageFtwSpareBase|0 - gEfiMdeModulePkgTokenSpaceGuid.PcdPciDisableBusEnumeration|FALSE - gEfiMdeModulePkgTokenSpaceGuid.PcdVideoHorizontalResolution|800 - gEfiMdeModulePkgTokenSpaceGuid.PcdVideoVerticalResolution|600 - gEfiMdeModulePkgTokenSpaceGuid.PcdAcpiS3Enable|FALSE - gUefiOvmfPkgTokenSpaceGuid.PcdOvmfHostBridgePciDevId|0 - gUefiOvmfPkgTokenSpaceGuid.PcdPciIoBase|0x0 - gUefiOvmfPkgTokenSpaceGuid.PcdPciIoSize|0x0 - gUefiOvmfPkgTokenSpaceGuid.PcdPciMmio32Base|0x0 - gUefiOvmfPkgTokenSpaceGuid.PcdPciMmio32Size|0x0 - gUefiOvmfPkgTokenSpaceGuid.PcdPciMmio64Base|0x0 - gUefiOvmfPkgTokenSpaceGuid.PcdPciMmio64Size|0x800000000 - - gEfiMdePkgTokenSpaceGuid.PcdPlatformBootTimeOut|0 - - # Set video resolution for text setup. - gEfiMdeModulePkgTokenSpaceGuid.PcdSetupVideoHorizontalResolution|640 - gEfiMdeModulePkgTokenSpaceGuid.PcdSetupVideoVerticalResolution|480 - - gEfiMdeModulePkgTokenSpaceGuid.PcdSmbiosVersion|0x0208 - gEfiMdeModulePkgTokenSpaceGuid.PcdSmbiosDocRev|0x0 - gUefiOvmfPkgTokenSpaceGuid.PcdQemuSmbiosValidated|FALSE - - # Noexec settings for DXE. - gEfiMdeModulePkgTokenSpaceGuid.PcdSetNxForStack|FALSE - gEfiMdeModulePkgTokenSpaceGuid.PcdPropertiesTableEnable|FALSE - - # UefiCpuPkg PCDs related to initial AP bringup and general AP management. - gUefiCpuPkgTokenSpaceGuid.PcdCpuMaxLogicalProcessorNumber|64 - gUefiCpuPkgTokenSpaceGuid.PcdCpuApInitTimeOutInMicroSeconds|50000 - -!if $(SMM_REQUIRE) == TRUE - gUefiCpuPkgTokenSpaceGuid.PcdCpuSmmSyncMode|0x01 - gUefiCpuPkgTokenSpaceGuid.PcdCpuSmmApSyncTimeout|100000 -!endif - -################################################################################ -# -# Components Section - list of all EDK II Modules needed by this Platform. -# -################################################################################ -[Components.IA32] - OvmfPkg/ResetVector/ResetVector.inf - - # - # SEC Phase modules - # - OvmfPkg/Sec/SecMain.inf { - - NULL|MdeModulePkg/Library/LzmaCustomDecompressLib/LzmaCustomDecompressLib.inf - } - - # - # PEI Phase modules - # - MdeModulePkg/Core/Pei/PeiMain.inf - MdeModulePkg/Universal/PCD/Pei/Pcd.inf { - - PcdLib|MdePkg/Library/BasePcdLibNull/BasePcdLibNull.inf - } - MdeModulePkg/Universal/ReportStatusCodeRouter/Pei/ReportStatusCodeRouterPei.inf - MdeModulePkg/Universal/StatusCodeHandler/Pei/StatusCodeHandlerPei.inf - MdeModulePkg/Core/DxeIplPeim/DxeIpl.inf { - - PcdLib|MdePkg/Library/PeiPcdLib/PeiPcdLib.inf - } - - OvmfPkg/PlatformPei/PlatformPei.inf { - - PcdLib|MdePkg/Library/PeiPcdLib/PeiPcdLib.inf - } - UefiCpuPkg/Universal/Acpi/S3Resume2Pei/S3Resume2Pei.inf { - - PcdLib|MdePkg/Library/PeiPcdLib/PeiPcdLib.inf -!if $(SMM_REQUIRE) == TRUE - LockBoxLib|MdeModulePkg/Library/SmmLockBoxLib/SmmLockBoxPeiLib.inf -!endif - } -!if $(SMM_REQUIRE) == TRUE - OvmfPkg/SmmAccess/SmmAccessPei.inf { - - PcdLib|MdePkg/Library/PeiPcdLib/PeiPcdLib.inf - } -!endif - UefiCpuPkg/CpuMpPei/CpuMpPei.inf { - - PcdLib|MdePkg/Library/PeiPcdLib/PeiPcdLib.inf - } - -[Components.X64] - # - # DXE Phase modules - # - MdeModulePkg/Core/Dxe/DxeMain.inf { - - NULL|MdeModulePkg/Library/LzmaCustomDecompressLib/LzmaCustomDecompressLib.inf - DevicePathLib|MdePkg/Library/UefiDevicePathLib/UefiDevicePathLib.inf - } - - MdeModulePkg/Universal/ReportStatusCodeRouter/RuntimeDxe/ReportStatusCodeRouterRuntimeDxe.inf - MdeModulePkg/Universal/StatusCodeHandler/RuntimeDxe/StatusCodeHandlerRuntimeDxe.inf - MdeModulePkg/Universal/PCD/Dxe/Pcd.inf { - - PcdLib|MdePkg/Library/BasePcdLibNull/BasePcdLibNull.inf - } - - MdeModulePkg/Core/RuntimeDxe/RuntimeDxe.inf - -!if $(SECURE_BOOT_ENABLE) == TRUE - MdeModulePkg/Universal/SecurityStubDxe/SecurityStubDxe.inf { - - NULL|SecurityPkg/Library/DxeImageVerificationLib/DxeImageVerificationLib.inf - } -!else - MdeModulePkg/Universal/SecurityStubDxe/SecurityStubDxe.inf -!endif - - MdeModulePkg/Universal/EbcDxe/EbcDxe.inf - PcAtChipsetPkg/8259InterruptControllerDxe/8259.inf - UefiCpuPkg/CpuIo2Dxe/CpuIo2Dxe.inf - UefiCpuPkg/CpuDxe/CpuDxe.inf - PcAtChipsetPkg/8254TimerDxe/8254Timer.inf - OvmfPkg/IncompatiblePciDeviceSupportDxe/IncompatiblePciDeviceSupport.inf - OvmfPkg/PciHotPlugInitDxe/PciHotPlugInit.inf - MdeModulePkg/Bus/Pci/PciHostBridgeDxe/PciHostBridgeDxe.inf { - - PciHostBridgeLib|OvmfPkg/Library/PciHostBridgeLib/PciHostBridgeLib.inf - } - MdeModulePkg/Bus/Pci/PciBusDxe/PciBusDxe.inf { - - PcdLib|MdePkg/Library/DxePcdLib/DxePcdLib.inf - } - MdeModulePkg/Universal/ResetSystemRuntimeDxe/ResetSystemRuntimeDxe.inf - MdeModulePkg/Universal/Metronome/Metronome.inf - PcAtChipsetPkg/PcatRealTimeClockRuntimeDxe/PcatRealTimeClockRuntimeDxe.inf - MdeModulePkg/Universal/DriverHealthManagerDxe/DriverHealthManagerDxe.inf - MdeModulePkg/Universal/BdsDxe/BdsDxe.inf { - -!ifdef $(CSM_ENABLE) - NULL|OvmfPkg/Csm/CsmSupportLib/CsmSupportLib.inf - NULL|IntelFrameworkModulePkg/Library/LegacyBootManagerLib/LegacyBootManagerLib.inf -!endif - } - MdeModulePkg/Logo/LogoDxe.inf - MdeModulePkg/Application/UiApp/UiApp.inf { - - NULL|MdeModulePkg/Library/DeviceManagerUiLib/DeviceManagerUiLib.inf - NULL|MdeModulePkg/Library/BootManagerUiLib/BootManagerUiLib.inf - NULL|MdeModulePkg/Library/BootMaintenanceManagerUiLib/BootMaintenanceManagerUiLib.inf -!ifdef $(CSM_ENABLE) - NULL|IntelFrameworkModulePkg/Library/LegacyBootManagerLib/LegacyBootManagerLib.inf - NULL|IntelFrameworkModulePkg/Library/LegacyBootMaintUiLib/LegacyBootMaintUiLib.inf -!endif - } - OvmfPkg/BlockMmioToBlockIoDxe/BlockIo.inf - OvmfPkg/VirtioPciDeviceDxe/VirtioPciDeviceDxe.inf - OvmfPkg/Virtio10Dxe/Virtio10.inf - OvmfPkg/VirtioBlkDxe/VirtioBlk.inf - OvmfPkg/VirtioScsiDxe/VirtioScsi.inf - OvmfPkg/VirtioRngDxe/VirtioRng.inf - OvmfPkg/XenIoPciDxe/XenIoPciDxe.inf - OvmfPkg/XenBusDxe/XenBusDxe.inf - OvmfPkg/XenPvBlkDxe/XenPvBlkDxe.inf - MdeModulePkg/Universal/WatchdogTimerDxe/WatchdogTimer.inf - MdeModulePkg/Universal/MonotonicCounterRuntimeDxe/MonotonicCounterRuntimeDxe.inf - MdeModulePkg/Universal/CapsuleRuntimeDxe/CapsuleRuntimeDxe.inf - MdeModulePkg/Universal/Console/ConPlatformDxe/ConPlatformDxe.inf - MdeModulePkg/Universal/Console/ConSplitterDxe/ConSplitterDxe.inf - MdeModulePkg/Universal/Console/GraphicsConsoleDxe/GraphicsConsoleDxe.inf { - - PcdLib|MdePkg/Library/DxePcdLib/DxePcdLib.inf - } - MdeModulePkg/Universal/Console/TerminalDxe/TerminalDxe.inf - MdeModulePkg/Universal/DevicePathDxe/DevicePathDxe.inf { - - DevicePathLib|MdePkg/Library/UefiDevicePathLib/UefiDevicePathLib.inf - PcdLib|MdePkg/Library/BasePcdLibNull/BasePcdLibNull.inf - } - MdeModulePkg/Universal/PrintDxe/PrintDxe.inf - MdeModulePkg/Universal/Disk/DiskIoDxe/DiskIoDxe.inf - MdeModulePkg/Universal/Disk/PartitionDxe/PartitionDxe.inf - MdeModulePkg/Universal/Disk/RamDiskDxe/RamDiskDxe.inf - MdeModulePkg/Universal/Disk/UnicodeCollation/EnglishDxe/EnglishDxe.inf - FatPkg/EnhancedFatDxe/Fat.inf - MdeModulePkg/Bus/Scsi/ScsiBusDxe/ScsiBusDxe.inf - MdeModulePkg/Bus/Scsi/ScsiDiskDxe/ScsiDiskDxe.inf - OvmfPkg/SataControllerDxe/SataControllerDxe.inf - MdeModulePkg/Bus/Ata/AtaAtapiPassThru/AtaAtapiPassThru.inf - MdeModulePkg/Bus/Ata/AtaBusDxe/AtaBusDxe.inf - MdeModulePkg/Bus/Pci/NvmExpressDxe/NvmExpressDxe.inf - MdeModulePkg/Universal/HiiDatabaseDxe/HiiDatabaseDxe.inf - MdeModulePkg/Universal/SetupBrowserDxe/SetupBrowserDxe.inf - MdeModulePkg/Universal/DisplayEngineDxe/DisplayEngineDxe.inf - MdeModulePkg/Universal/MemoryTest/NullMemoryTestDxe/NullMemoryTestDxe.inf - - OvmfPkg/QemuVideoDxe/QemuVideoDxe.inf - OvmfPkg/VirtioGpuDxe/VirtioGpu.inf - - # - # ISA Support - # - PcAtChipsetPkg/IsaAcpiDxe/IsaAcpi.inf - IntelFrameworkModulePkg/Bus/Isa/IsaBusDxe/IsaBusDxe.inf - IntelFrameworkModulePkg/Bus/Isa/IsaSerialDxe/IsaSerialDxe.inf - IntelFrameworkModulePkg/Bus/Isa/Ps2KeyboardDxe/Ps2keyboardDxe.inf - IntelFrameworkModulePkg/Bus/Isa/IsaFloppyDxe/IsaFloppyDxe.inf - - # - # SMBIOS Support - # - MdeModulePkg/Universal/SmbiosDxe/SmbiosDxe.inf { - - NULL|OvmfPkg/Library/SmbiosVersionLib/DetectSmbiosVersionLib.inf - } - OvmfPkg/SmbiosPlatformDxe/SmbiosPlatformDxe.inf - - # - # ACPI Support - # - MdeModulePkg/Universal/Acpi/AcpiTableDxe/AcpiTableDxe.inf - OvmfPkg/AcpiPlatformDxe/AcpiPlatformDxe.inf - OvmfPkg/AcpiTables/AcpiTables.inf - MdeModulePkg/Universal/Acpi/S3SaveStateDxe/S3SaveStateDxe.inf - MdeModulePkg/Universal/Acpi/BootScriptExecutorDxe/BootScriptExecutorDxe.inf - MdeModulePkg/Universal/Acpi/BootGraphicsResourceTableDxe/BootGraphicsResourceTableDxe.inf - - # - # Network Support - # - MdeModulePkg/Universal/Network/SnpDxe/SnpDxe.inf - MdeModulePkg/Universal/Network/DpcDxe/DpcDxe.inf - MdeModulePkg/Universal/Network/MnpDxe/MnpDxe.inf - MdeModulePkg/Universal/Network/VlanConfigDxe/VlanConfigDxe.inf - MdeModulePkg/Universal/Network/ArpDxe/ArpDxe.inf - MdeModulePkg/Universal/Network/Dhcp4Dxe/Dhcp4Dxe.inf - MdeModulePkg/Universal/Network/Ip4Dxe/Ip4Dxe.inf - MdeModulePkg/Universal/Network/Mtftp4Dxe/Mtftp4Dxe.inf - MdeModulePkg/Universal/Network/Udp4Dxe/Udp4Dxe.inf -!if $(NETWORK_IP6_ENABLE) == TRUE - NetworkPkg/Ip6Dxe/Ip6Dxe.inf - NetworkPkg/TcpDxe/TcpDxe.inf - NetworkPkg/Udp6Dxe/Udp6Dxe.inf - NetworkPkg/Dhcp6Dxe/Dhcp6Dxe.inf - NetworkPkg/Mtftp6Dxe/Mtftp6Dxe.inf - NetworkPkg/UefiPxeBcDxe/UefiPxeBcDxe.inf - NetworkPkg/IScsiDxe/IScsiDxe.inf -!else - MdeModulePkg/Universal/Network/Tcp4Dxe/Tcp4Dxe.inf - MdeModulePkg/Universal/Network/UefiPxeBcDxe/UefiPxeBcDxe.inf - MdeModulePkg/Universal/Network/IScsiDxe/IScsiDxe.inf -!endif -!if $(HTTP_BOOT_ENABLE) == TRUE - NetworkPkg/DnsDxe/DnsDxe.inf - NetworkPkg/HttpUtilitiesDxe/HttpUtilitiesDxe.inf - NetworkPkg/HttpDxe/HttpDxe.inf - NetworkPkg/HttpBootDxe/HttpBootDxe.inf -!endif -!if $(TLS_ENABLE) == TRUE - NetworkPkg/TlsDxe/TlsDxe.inf - NetworkPkg/TlsAuthConfigDxe/TlsAuthConfigDxe.inf -!endif - OvmfPkg/VirtioNetDxe/VirtioNet.inf - - # - # Usb Support - # - MdeModulePkg/Bus/Pci/UhciDxe/UhciDxe.inf - MdeModulePkg/Bus/Pci/EhciDxe/EhciDxe.inf - MdeModulePkg/Bus/Pci/XhciDxe/XhciDxe.inf - MdeModulePkg/Bus/Usb/UsbBusDxe/UsbBusDxe.inf - MdeModulePkg/Bus/Usb/UsbKbDxe/UsbKbDxe.inf - MdeModulePkg/Bus/Usb/UsbMassStorageDxe/UsbMassStorageDxe.inf - -!ifdef $(CSM_ENABLE) - IntelFrameworkModulePkg/Csm/BiosThunk/VideoDxe/VideoDxe.inf { - - PcdLib|MdePkg/Library/DxePcdLib/DxePcdLib.inf - } - IntelFrameworkModulePkg/Csm/LegacyBiosDxe/LegacyBiosDxe.inf - OvmfPkg/Csm/Csm16/Csm16.inf -!endif - -!ifndef $(USE_OLD_SHELL) - ShellPkg/Application/Shell/Shell.inf { - - ShellCommandLib|ShellPkg/Library/UefiShellCommandLib/UefiShellCommandLib.inf - NULL|ShellPkg/Library/UefiShellLevel2CommandsLib/UefiShellLevel2CommandsLib.inf - NULL|ShellPkg/Library/UefiShellLevel1CommandsLib/UefiShellLevel1CommandsLib.inf - NULL|ShellPkg/Library/UefiShellLevel3CommandsLib/UefiShellLevel3CommandsLib.inf - NULL|ShellPkg/Library/UefiShellDriver1CommandsLib/UefiShellDriver1CommandsLib.inf - NULL|ShellPkg/Library/UefiShellDebug1CommandsLib/UefiShellDebug1CommandsLib.inf - NULL|ShellPkg/Library/UefiShellInstall1CommandsLib/UefiShellInstall1CommandsLib.inf - NULL|ShellPkg/Library/UefiShellNetwork1CommandsLib/UefiShellNetwork1CommandsLib.inf -!if $(NETWORK_IP6_ENABLE) == TRUE - NULL|ShellPkg/Library/UefiShellNetwork2CommandsLib/UefiShellNetwork2CommandsLib.inf -!endif - NULL|ShellPkg/Library/UefiShellTftpCommandLib/UefiShellTftpCommandLib.inf - HandleParsingLib|ShellPkg/Library/UefiHandleParsingLib/UefiHandleParsingLib.inf - ShellLib|ShellPkg/Library/UefiShellLib/UefiShellLib.inf - FileHandleLib|MdePkg/Library/UefiFileHandleLib/UefiFileHandleLib.inf - PrintLib|MdePkg/Library/BasePrintLib/BasePrintLib.inf -# SafeBlockIoLib|ShellPkg/Library/SafeBlockIoLib/SafeBlockIoLib.inf -# SafeOpenProtocolLib|ShellPkg/Library/SafeOpenProtocolLib/SafeOpenProtocolLib.inf - BcfgCommandLib|ShellPkg/Library/UefiShellBcfgCommandLib/UefiShellBcfgCommandLib.inf - - - gEfiMdePkgTokenSpaceGuid.PcdDebugPropertyMask|0xFF - gEfiShellPkgTokenSpaceGuid.PcdShellLibAutoInitialize|FALSE - gEfiMdePkgTokenSpaceGuid.PcdUefiLibMaxPrintBufferSize|8000 - } -!endif - -!if $(SECURE_BOOT_ENABLE) == TRUE - SecurityPkg/VariableAuthenticated/SecureBootConfigDxe/SecureBootConfigDxe.inf -!endif - - OvmfPkg/PlatformDxe/Platform.inf - -!if $(SMM_REQUIRE) == TRUE - OvmfPkg/SmmAccess/SmmAccess2Dxe.inf - OvmfPkg/SmmControl2Dxe/SmmControl2Dxe.inf - UefiCpuPkg/CpuS3DataDxe/CpuS3DataDxe.inf - - # - # SMM Initial Program Load (a DXE_RUNTIME_DRIVER) - # - MdeModulePkg/Core/PiSmmCore/PiSmmIpl.inf - - # - # SMM_CORE - # - MdeModulePkg/Core/PiSmmCore/PiSmmCore.inf - - # - # Privileged drivers (DXE_SMM_DRIVER modules) - # - UefiCpuPkg/CpuIo2Smm/CpuIo2Smm.inf - MdeModulePkg/Universal/LockBox/SmmLockBox/SmmLockBox.inf { - - LockBoxLib|MdeModulePkg/Library/SmmLockBoxLib/SmmLockBoxSmmLib.inf - } - UefiCpuPkg/PiSmmCpuDxeSmm/PiSmmCpuDxeSmm.inf { - - SmmCpuPlatformHookLib|UefiCpuPkg/Library/SmmCpuPlatformHookLibNull/SmmCpuPlatformHookLibNull.inf - SmmCpuFeaturesLib|OvmfPkg/Library/SmmCpuFeaturesLib/SmmCpuFeaturesLib.inf - } - - # - # Variable driver stack (SMM) - # - OvmfPkg/QemuFlashFvbServicesRuntimeDxe/FvbServicesSmm.inf - MdeModulePkg/Universal/FaultTolerantWriteDxe/FaultTolerantWriteSmm.inf - MdeModulePkg/Universal/Variable/RuntimeDxe/VariableSmm.inf { - - NULL|MdeModulePkg/Library/VarCheckUefiLib/VarCheckUefiLib.inf - } - MdeModulePkg/Universal/Variable/RuntimeDxe/VariableSmmRuntimeDxe.inf - -!else - - # - # Variable driver stack (non-SMM) - # - OvmfPkg/QemuFlashFvbServicesRuntimeDxe/FvbServicesRuntimeDxe.inf - OvmfPkg/EmuVariableFvbRuntimeDxe/Fvb.inf { - - PlatformFvbLib|OvmfPkg/Library/EmuVariableFvbLib/EmuVariableFvbLib.inf - } - MdeModulePkg/Universal/FaultTolerantWriteDxe/FaultTolerantWriteDxe.inf - MdeModulePkg/Universal/Variable/RuntimeDxe/VariableRuntimeDxe.inf { - - NULL|MdeModulePkg/Library/VarCheckUefiLib/VarCheckUefiLib.inf - } -!endif diff --git a/OvmfPkg/OvmfPkgIa32X64.fdf b/OvmfPkg/OvmfPkgIa32X64.fdf deleted file mode 100644 index 5233314139..0000000000 --- a/OvmfPkg/OvmfPkgIa32X64.fdf +++ /dev/null @@ -1,527 +0,0 @@ -## @file -# Open Virtual Machine Firmware: FDF -# -# Copyright (c) 2006 - 2016, Intel Corporation. All rights reserved.
-# (C) Copyright 2016 Hewlett Packard Enterprise Development LP
-# -# This program and the accompanying materials -# are licensed and made 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] -!include OvmfPkg.fdf.inc - -# -# Build the variable store and the firmware code as one unified flash device -# image. -# -[FD.OVMF] -BaseAddress = $(FW_BASE_ADDRESS) -Size = $(FW_SIZE) -ErasePolarity = 1 -BlockSize = $(BLOCK_SIZE) -NumBlocks = $(FW_BLOCKS) - -!include VarStore.fdf.inc - -$(VARS_SIZE)|$(FVMAIN_SIZE) -FV = FVMAIN_COMPACT - -$(SECFV_OFFSET)|$(SECFV_SIZE) -FV = SECFV - -# -# Build the variable store and the firmware code as separate flash device -# images. -# -[FD.OVMF_VARS] -BaseAddress = $(FW_BASE_ADDRESS) -Size = $(VARS_SIZE) -ErasePolarity = 1 -BlockSize = $(BLOCK_SIZE) -NumBlocks = $(VARS_BLOCKS) - -!include VarStore.fdf.inc - -[FD.OVMF_CODE] -BaseAddress = $(CODE_BASE_ADDRESS) -Size = $(CODE_SIZE) -ErasePolarity = 1 -BlockSize = $(BLOCK_SIZE) -NumBlocks = $(CODE_BLOCKS) - -0x00000000|$(FVMAIN_SIZE) -FV = FVMAIN_COMPACT - -$(FVMAIN_SIZE)|$(SECFV_SIZE) -FV = SECFV - -################################################################################ - -[FD.MEMFD] -BaseAddress = $(MEMFD_BASE_ADDRESS) -Size = 0xB00000 -ErasePolarity = 1 -BlockSize = 0x10000 -NumBlocks = 0xB0 - -0x000000|0x006000 -gUefiOvmfPkgTokenSpaceGuid.PcdOvmfSecPageTablesBase|gUefiOvmfPkgTokenSpaceGuid.PcdOvmfSecPageTablesSize - -0x006000|0x001000 -gUefiOvmfPkgTokenSpaceGuid.PcdOvmfLockBoxStorageBase|gUefiOvmfPkgTokenSpaceGuid.PcdOvmfLockBoxStorageSize - -0x007000|0x001000 -gEfiMdePkgTokenSpaceGuid.PcdGuidedExtractHandlerTableAddress|gUefiOvmfPkgTokenSpaceGuid.PcdGuidedExtractHandlerTableSize - -0x010000|0x008000 -gUefiOvmfPkgTokenSpaceGuid.PcdOvmfSecPeiTempRamBase|gUefiOvmfPkgTokenSpaceGuid.PcdOvmfSecPeiTempRamSize - -0x020000|0x0E0000 -gUefiOvmfPkgTokenSpaceGuid.PcdOvmfPeiMemFvBase|gUefiOvmfPkgTokenSpaceGuid.PcdOvmfPeiMemFvSize -FV = PEIFV - -0x100000|0xA00000 -gUefiOvmfPkgTokenSpaceGuid.PcdOvmfDxeMemFvBase|gUefiOvmfPkgTokenSpaceGuid.PcdOvmfDxeMemFvSize -FV = DXEFV - -################################################################################ - -[FV.SECFV] -FvNameGuid = 763BED0D-DE9F-48F5-81F1-3E90E1B1A015 -BlockSize = 0x1000 -FvAlignment = 16 -ERASE_POLARITY = 1 -MEMORY_MAPPED = TRUE -STICKY_WRITE = TRUE -LOCK_CAP = TRUE -LOCK_STATUS = TRUE -WRITE_DISABLED_CAP = TRUE -WRITE_ENABLED_CAP = TRUE -WRITE_STATUS = TRUE -WRITE_LOCK_CAP = TRUE -WRITE_LOCK_STATUS = TRUE -READ_DISABLED_CAP = TRUE -READ_ENABLED_CAP = TRUE -READ_STATUS = TRUE -READ_LOCK_CAP = TRUE -READ_LOCK_STATUS = TRUE - -# -# SEC Phase modules -# -# The code in this FV handles the initial firmware startup, and -# decompresses the PEI and DXE FVs which handles the rest of the boot sequence. -# -INF OvmfPkg/Sec/SecMain.inf - -INF RuleOverride=RESET_VECTOR OvmfPkg/ResetVector/ResetVector.inf - -################################################################################ -[FV.PEIFV] -FvNameGuid = 6938079B-B503-4E3D-9D24-B28337A25806 -BlockSize = 0x10000 -FvAlignment = 16 -ERASE_POLARITY = 1 -MEMORY_MAPPED = TRUE -STICKY_WRITE = TRUE -LOCK_CAP = TRUE -LOCK_STATUS = TRUE -WRITE_DISABLED_CAP = TRUE -WRITE_ENABLED_CAP = TRUE -WRITE_STATUS = TRUE -WRITE_LOCK_CAP = TRUE -WRITE_LOCK_STATUS = TRUE -READ_DISABLED_CAP = TRUE -READ_ENABLED_CAP = TRUE -READ_STATUS = TRUE -READ_LOCK_CAP = TRUE -READ_LOCK_STATUS = TRUE - -APRIORI PEI { - INF MdeModulePkg/Universal/PCD/Pei/Pcd.inf -} - -# -# PEI Phase modules -# -INF MdeModulePkg/Core/Pei/PeiMain.inf -INF MdeModulePkg/Universal/PCD/Pei/Pcd.inf -INF MdeModulePkg/Universal/ReportStatusCodeRouter/Pei/ReportStatusCodeRouterPei.inf -INF MdeModulePkg/Universal/StatusCodeHandler/Pei/StatusCodeHandlerPei.inf -INF OvmfPkg/PlatformPei/PlatformPei.inf -INF MdeModulePkg/Core/DxeIplPeim/DxeIpl.inf -INF UefiCpuPkg/Universal/Acpi/S3Resume2Pei/S3Resume2Pei.inf -!if $(SMM_REQUIRE) == TRUE -INF OvmfPkg/SmmAccess/SmmAccessPei.inf -!endif -INF UefiCpuPkg/CpuMpPei/CpuMpPei.inf - -################################################################################ - -[FV.DXEFV] -FvNameGuid = 7CB8BDC9-F8EB-4F34-AAEA-3EE4AF6516A1 -BlockSize = 0x10000 -FvAlignment = 16 -ERASE_POLARITY = 1 -MEMORY_MAPPED = TRUE -STICKY_WRITE = TRUE -LOCK_CAP = TRUE -LOCK_STATUS = TRUE -WRITE_DISABLED_CAP = TRUE -WRITE_ENABLED_CAP = TRUE -WRITE_STATUS = TRUE -WRITE_LOCK_CAP = TRUE -WRITE_LOCK_STATUS = TRUE -READ_DISABLED_CAP = TRUE -READ_ENABLED_CAP = TRUE -READ_STATUS = TRUE -READ_LOCK_CAP = TRUE -READ_LOCK_STATUS = TRUE - -APRIORI DXE { - INF MdeModulePkg/Universal/DevicePathDxe/DevicePathDxe.inf - INF MdeModulePkg/Universal/PCD/Dxe/Pcd.inf -!if $(SMM_REQUIRE) == FALSE - INF OvmfPkg/QemuFlashFvbServicesRuntimeDxe/FvbServicesRuntimeDxe.inf -!endif -} - -# -# DXE Phase modules -# -INF MdeModulePkg/Core/Dxe/DxeMain.inf - -INF MdeModulePkg/Universal/ReportStatusCodeRouter/RuntimeDxe/ReportStatusCodeRouterRuntimeDxe.inf -INF MdeModulePkg/Universal/StatusCodeHandler/RuntimeDxe/StatusCodeHandlerRuntimeDxe.inf -INF MdeModulePkg/Universal/PCD/Dxe/Pcd.inf - -INF MdeModulePkg/Core/RuntimeDxe/RuntimeDxe.inf -INF MdeModulePkg/Universal/SecurityStubDxe/SecurityStubDxe.inf -INF MdeModulePkg/Universal/EbcDxe/EbcDxe.inf -INF PcAtChipsetPkg/8259InterruptControllerDxe/8259.inf -INF UefiCpuPkg/CpuIo2Dxe/CpuIo2Dxe.inf -INF UefiCpuPkg/CpuDxe/CpuDxe.inf -INF PcAtChipsetPkg/8254TimerDxe/8254Timer.inf -INF OvmfPkg/IncompatiblePciDeviceSupportDxe/IncompatiblePciDeviceSupport.inf -INF OvmfPkg/PciHotPlugInitDxe/PciHotPlugInit.inf -INF MdeModulePkg/Bus/Pci/PciHostBridgeDxe/PciHostBridgeDxe.inf -INF MdeModulePkg/Bus/Pci/PciBusDxe/PciBusDxe.inf -INF MdeModulePkg/Universal/ResetSystemRuntimeDxe/ResetSystemRuntimeDxe.inf -INF MdeModulePkg/Universal/Metronome/Metronome.inf -INF PcAtChipsetPkg/PcatRealTimeClockRuntimeDxe/PcatRealTimeClockRuntimeDxe.inf - -INF OvmfPkg/BlockMmioToBlockIoDxe/BlockIo.inf -INF OvmfPkg/VirtioPciDeviceDxe/VirtioPciDeviceDxe.inf -INF OvmfPkg/Virtio10Dxe/Virtio10.inf -INF OvmfPkg/VirtioBlkDxe/VirtioBlk.inf -INF OvmfPkg/VirtioScsiDxe/VirtioScsi.inf -INF OvmfPkg/VirtioRngDxe/VirtioRng.inf -INF OvmfPkg/XenIoPciDxe/XenIoPciDxe.inf -INF OvmfPkg/XenBusDxe/XenBusDxe.inf -INF OvmfPkg/XenPvBlkDxe/XenPvBlkDxe.inf - -!if $(SECURE_BOOT_ENABLE) == TRUE - INF SecurityPkg/VariableAuthenticated/SecureBootConfigDxe/SecureBootConfigDxe.inf -!endif - -INF MdeModulePkg/Universal/WatchdogTimerDxe/WatchdogTimer.inf -INF MdeModulePkg/Universal/MonotonicCounterRuntimeDxe/MonotonicCounterRuntimeDxe.inf -INF MdeModulePkg/Universal/CapsuleRuntimeDxe/CapsuleRuntimeDxe.inf -INF MdeModulePkg/Universal/Console/ConPlatformDxe/ConPlatformDxe.inf -INF MdeModulePkg/Universal/Console/ConSplitterDxe/ConSplitterDxe.inf -INF MdeModulePkg/Universal/Console/GraphicsConsoleDxe/GraphicsConsoleDxe.inf -INF MdeModulePkg/Universal/Console/TerminalDxe/TerminalDxe.inf -INF MdeModulePkg/Universal/DriverHealthManagerDxe/DriverHealthManagerDxe.inf -INF MdeModulePkg/Universal/BdsDxe/BdsDxe.inf -INF MdeModulePkg/Application/UiApp/UiApp.inf -INF MdeModulePkg/Universal/DevicePathDxe/DevicePathDxe.inf -INF MdeModulePkg/Universal/PrintDxe/PrintDxe.inf -INF MdeModulePkg/Universal/Disk/DiskIoDxe/DiskIoDxe.inf -INF MdeModulePkg/Universal/Disk/PartitionDxe/PartitionDxe.inf -INF MdeModulePkg/Universal/Disk/RamDiskDxe/RamDiskDxe.inf -INF MdeModulePkg/Universal/Disk/UnicodeCollation/EnglishDxe/EnglishDxe.inf -INF MdeModulePkg/Bus/Scsi/ScsiBusDxe/ScsiBusDxe.inf -INF MdeModulePkg/Bus/Scsi/ScsiDiskDxe/ScsiDiskDxe.inf -INF OvmfPkg/SataControllerDxe/SataControllerDxe.inf -INF MdeModulePkg/Bus/Ata/AtaAtapiPassThru/AtaAtapiPassThru.inf -INF MdeModulePkg/Bus/Ata/AtaBusDxe/AtaBusDxe.inf -INF MdeModulePkg/Bus/Pci/NvmExpressDxe/NvmExpressDxe.inf -INF MdeModulePkg/Universal/HiiDatabaseDxe/HiiDatabaseDxe.inf -INF MdeModulePkg/Universal/SetupBrowserDxe/SetupBrowserDxe.inf -INF MdeModulePkg/Universal/DisplayEngineDxe/DisplayEngineDxe.inf -INF MdeModulePkg/Universal/MemoryTest/NullMemoryTestDxe/NullMemoryTestDxe.inf - -INF PcAtChipsetPkg/IsaAcpiDxe/IsaAcpi.inf -INF IntelFrameworkModulePkg/Bus/Isa/IsaBusDxe/IsaBusDxe.inf - -!ifndef $(SOURCE_DEBUG_ENABLE) -INF IntelFrameworkModulePkg/Bus/Isa/IsaSerialDxe/IsaSerialDxe.inf -!endif - -INF IntelFrameworkModulePkg/Bus/Isa/Ps2KeyboardDxe/Ps2keyboardDxe.inf -INF IntelFrameworkModulePkg/Bus/Isa/IsaFloppyDxe/IsaFloppyDxe.inf - -INF MdeModulePkg/Universal/SmbiosDxe/SmbiosDxe.inf -INF OvmfPkg/SmbiosPlatformDxe/SmbiosPlatformDxe.inf - -INF MdeModulePkg/Universal/Acpi/AcpiTableDxe/AcpiTableDxe.inf -INF OvmfPkg/AcpiPlatformDxe/AcpiPlatformDxe.inf -INF RuleOverride=ACPITABLE OvmfPkg/AcpiTables/AcpiTables.inf -INF MdeModulePkg/Universal/Acpi/S3SaveStateDxe/S3SaveStateDxe.inf -INF MdeModulePkg/Universal/Acpi/BootScriptExecutorDxe/BootScriptExecutorDxe.inf -INF MdeModulePkg/Universal/Acpi/BootGraphicsResourceTableDxe/BootGraphicsResourceTableDxe.inf - -INF FatPkg/EnhancedFatDxe/Fat.inf - -!ifndef $(USE_OLD_SHELL) -INF ShellPkg/Application/Shell/Shell.inf -!else -INF RuleOverride = BINARY USE = X64 EdkShellBinPkg/FullShell/FullShell.inf -!endif - -INF MdeModulePkg/Logo/LogoDxe.inf - -# -# Network modules -# -!if $(E1000_ENABLE) - FILE DRIVER = 5D695E11-9B3F-4b83-B25F-4A8D5D69BE07 { - SECTION PE32 = Intel3.5/EFIX64/E3507X2.EFI - } -!endif - INF MdeModulePkg/Universal/Network/SnpDxe/SnpDxe.inf - INF MdeModulePkg/Universal/Network/DpcDxe/DpcDxe.inf - INF MdeModulePkg/Universal/Network/MnpDxe/MnpDxe.inf - INF MdeModulePkg/Universal/Network/VlanConfigDxe/VlanConfigDxe.inf - INF MdeModulePkg/Universal/Network/ArpDxe/ArpDxe.inf - INF MdeModulePkg/Universal/Network/Dhcp4Dxe/Dhcp4Dxe.inf - INF MdeModulePkg/Universal/Network/Ip4Dxe/Ip4Dxe.inf - INF MdeModulePkg/Universal/Network/Mtftp4Dxe/Mtftp4Dxe.inf - INF MdeModulePkg/Universal/Network/Udp4Dxe/Udp4Dxe.inf -!if $(NETWORK_IP6_ENABLE) == TRUE - INF NetworkPkg/Ip6Dxe/Ip6Dxe.inf - INF NetworkPkg/TcpDxe/TcpDxe.inf - INF NetworkPkg/Udp6Dxe/Udp6Dxe.inf - INF NetworkPkg/Dhcp6Dxe/Dhcp6Dxe.inf - INF NetworkPkg/Mtftp6Dxe/Mtftp6Dxe.inf - INF NetworkPkg/UefiPxeBcDxe/UefiPxeBcDxe.inf - INF NetworkPkg/IScsiDxe/IScsiDxe.inf -!else - INF MdeModulePkg/Universal/Network/Tcp4Dxe/Tcp4Dxe.inf - INF MdeModulePkg/Universal/Network/UefiPxeBcDxe/UefiPxeBcDxe.inf - INF MdeModulePkg/Universal/Network/IScsiDxe/IScsiDxe.inf -!endif -!if $(HTTP_BOOT_ENABLE) == TRUE - INF NetworkPkg/DnsDxe/DnsDxe.inf - INF NetworkPkg/HttpUtilitiesDxe/HttpUtilitiesDxe.inf - INF NetworkPkg/HttpDxe/HttpDxe.inf - INF NetworkPkg/HttpBootDxe/HttpBootDxe.inf -!endif -!if $(TLS_ENABLE) == TRUE - INF NetworkPkg/TlsDxe/TlsDxe.inf - INF NetworkPkg/TlsAuthConfigDxe/TlsAuthConfigDxe.inf -!endif - INF OvmfPkg/VirtioNetDxe/VirtioNet.inf - -# -# Usb Support -# -INF MdeModulePkg/Bus/Pci/UhciDxe/UhciDxe.inf -INF MdeModulePkg/Bus/Pci/EhciDxe/EhciDxe.inf -INF MdeModulePkg/Bus/Pci/XhciDxe/XhciDxe.inf -INF MdeModulePkg/Bus/Usb/UsbBusDxe/UsbBusDxe.inf -INF MdeModulePkg/Bus/Usb/UsbKbDxe/UsbKbDxe.inf -INF MdeModulePkg/Bus/Usb/UsbMassStorageDxe/UsbMassStorageDxe.inf - -!ifdef $(CSM_ENABLE) -INF IntelFrameworkModulePkg/Csm/BiosThunk/VideoDxe/VideoDxe.inf -INF IntelFrameworkModulePkg/Csm/LegacyBiosDxe/LegacyBiosDxe.inf -INF RuleOverride=CSM OvmfPkg/Csm/Csm16/Csm16.inf -!endif - -INF OvmfPkg/QemuVideoDxe/QemuVideoDxe.inf -INF OvmfPkg/VirtioGpuDxe/VirtioGpu.inf -INF OvmfPkg/PlatformDxe/Platform.inf - -!if $(SMM_REQUIRE) == TRUE -INF OvmfPkg/SmmAccess/SmmAccess2Dxe.inf -INF OvmfPkg/SmmControl2Dxe/SmmControl2Dxe.inf -INF UefiCpuPkg/CpuS3DataDxe/CpuS3DataDxe.inf -INF MdeModulePkg/Core/PiSmmCore/PiSmmIpl.inf -INF MdeModulePkg/Core/PiSmmCore/PiSmmCore.inf -INF UefiCpuPkg/CpuIo2Smm/CpuIo2Smm.inf -INF MdeModulePkg/Universal/LockBox/SmmLockBox/SmmLockBox.inf -INF UefiCpuPkg/PiSmmCpuDxeSmm/PiSmmCpuDxeSmm.inf - -# -# Variable driver stack (SMM) -# -INF OvmfPkg/QemuFlashFvbServicesRuntimeDxe/FvbServicesSmm.inf -INF MdeModulePkg/Universal/FaultTolerantWriteDxe/FaultTolerantWriteSmm.inf -INF MdeModulePkg/Universal/Variable/RuntimeDxe/VariableSmm.inf -INF MdeModulePkg/Universal/Variable/RuntimeDxe/VariableSmmRuntimeDxe.inf - -!else - -# -# Variable driver stack (non-SMM) -# -INF OvmfPkg/QemuFlashFvbServicesRuntimeDxe/FvbServicesRuntimeDxe.inf -INF OvmfPkg/EmuVariableFvbRuntimeDxe/Fvb.inf -INF MdeModulePkg/Universal/FaultTolerantWriteDxe/FaultTolerantWriteDxe.inf -INF MdeModulePkg/Universal/Variable/RuntimeDxe/VariableRuntimeDxe.inf -!endif - -################################################################################ - -[FV.FVMAIN_COMPACT] -FvNameGuid = 48DB5E17-707C-472D-91CD-1613E7EF51B0 -FvAlignment = 16 -ERASE_POLARITY = 1 -MEMORY_MAPPED = TRUE -STICKY_WRITE = TRUE -LOCK_CAP = TRUE -LOCK_STATUS = TRUE -WRITE_DISABLED_CAP = TRUE -WRITE_ENABLED_CAP = TRUE -WRITE_STATUS = TRUE -WRITE_LOCK_CAP = TRUE -WRITE_LOCK_STATUS = TRUE -READ_DISABLED_CAP = TRUE -READ_ENABLED_CAP = TRUE -READ_STATUS = TRUE -READ_LOCK_CAP = TRUE -READ_LOCK_STATUS = TRUE - -FILE FV_IMAGE = 9E21FD93-9C72-4c15-8C4B-E77F1DB2D792 { - SECTION GUIDED EE4E5898-3914-4259-9D6E-DC7BD79403CF PROCESSING_REQUIRED = TRUE { - # - # These firmware volumes will have files placed in them uncompressed, - # and then both firmware volumes will be compressed in a single - # compression operation in order to achieve better overall compression. - # - SECTION FV_IMAGE = PEIFV - SECTION FV_IMAGE = DXEFV - } - } - -!include DecomprScratchEnd.fdf.inc - -################################################################################ - -[Rule.Common.SEC] - FILE SEC = $(NAMED_GUID) { - PE32 PE32 $(INF_OUTPUT)/$(MODULE_NAME).efi - UI STRING ="$(MODULE_NAME)" Optional - VERSION STRING ="$(INF_VERSION)" Optional BUILD_NUM=$(BUILD_NUMBER) - } - -[Rule.Common.PEI_CORE] - FILE PEI_CORE = $(NAMED_GUID) { - PE32 PE32 Align=Auto $(INF_OUTPUT)/$(MODULE_NAME).efi - UI STRING ="$(MODULE_NAME)" Optional - VERSION STRING ="$(INF_VERSION)" Optional BUILD_NUM=$(BUILD_NUMBER) - } - -[Rule.Common.PEIM] - FILE PEIM = $(NAMED_GUID) { - PEI_DEPEX PEI_DEPEX Optional $(INF_OUTPUT)/$(MODULE_NAME).depex - PE32 PE32 Align=Auto $(INF_OUTPUT)/$(MODULE_NAME).efi - UI STRING="$(MODULE_NAME)" Optional - VERSION STRING="$(INF_VERSION)" Optional BUILD_NUM=$(BUILD_NUMBER) - } - -[Rule.Common.DXE_CORE] - FILE DXE_CORE = $(NAMED_GUID) { - PE32 PE32 $(INF_OUTPUT)/$(MODULE_NAME).efi - UI STRING="$(MODULE_NAME)" Optional - VERSION STRING="$(INF_VERSION)" Optional BUILD_NUM=$(BUILD_NUMBER) - } - -[Rule.Common.DXE_DRIVER] - FILE DRIVER = $(NAMED_GUID) { - DXE_DEPEX DXE_DEPEX Optional $(INF_OUTPUT)/$(MODULE_NAME).depex - PE32 PE32 $(INF_OUTPUT)/$(MODULE_NAME).efi - UI STRING="$(MODULE_NAME)" Optional - VERSION STRING="$(INF_VERSION)" Optional BUILD_NUM=$(BUILD_NUMBER) - RAW ACPI Optional |.acpi - RAW ASL Optional |.aml - } - -[Rule.Common.DXE_RUNTIME_DRIVER] - FILE DRIVER = $(NAMED_GUID) { - DXE_DEPEX DXE_DEPEX Optional $(INF_OUTPUT)/$(MODULE_NAME).depex - PE32 PE32 $(INF_OUTPUT)/$(MODULE_NAME).efi - UI STRING="$(MODULE_NAME)" Optional - VERSION STRING="$(INF_VERSION)" Optional BUILD_NUM=$(BUILD_NUMBER) - } - -[Rule.Common.UEFI_DRIVER] - FILE DRIVER = $(NAMED_GUID) { - DXE_DEPEX DXE_DEPEX Optional $(INF_OUTPUT)/$(MODULE_NAME).depex - PE32 PE32 $(INF_OUTPUT)/$(MODULE_NAME).efi - UI STRING="$(MODULE_NAME)" Optional - VERSION STRING="$(INF_VERSION)" Optional BUILD_NUM=$(BUILD_NUMBER) - } - -[Rule.Common.UEFI_DRIVER.BINARY] - FILE DRIVER = $(NAMED_GUID) { - DXE_DEPEX DXE_DEPEX Optional |.depex - PE32 PE32 |.efi - UI STRING="$(MODULE_NAME)" Optional - VERSION STRING="$(INF_VERSION)" Optional BUILD_NUM=$(BUILD_NUMBER) - } - -[Rule.Common.UEFI_APPLICATION] - FILE APPLICATION = $(NAMED_GUID) { - PE32 PE32 $(INF_OUTPUT)/$(MODULE_NAME).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) - } - -[Rule.Common.USER_DEFINED.ACPITABLE] - FILE FREEFORM = $(NAMED_GUID) { - RAW ACPI |.acpi - RAW ASL |.aml - } - -[Rule.Common.USER_DEFINED.CSM] - FILE FREEFORM = $(NAMED_GUID) { - RAW BIN |.bin - } - -[Rule.Common.SEC.RESET_VECTOR] - FILE RAW = $(NAMED_GUID) { - RAW BIN Align = 16 |.bin - } - -[Rule.Common.SMM_CORE] - FILE SMM_CORE = $(NAMED_GUID) { - PE32 PE32 $(INF_OUTPUT)/$(MODULE_NAME).efi - UI STRING="$(MODULE_NAME)" Optional - VERSION STRING="$(INF_VERSION)" Optional BUILD_NUM=$(BUILD_NUMBER) - } - -[Rule.Common.DXE_SMM_DRIVER] - FILE SMM = $(NAMED_GUID) { - SMM_DEPEX SMM_DEPEX Optional $(INF_OUTPUT)/$(MODULE_NAME).depex - PE32 PE32 $(INF_OUTPUT)/$(MODULE_NAME).efi - UI STRING="$(MODULE_NAME)" Optional - VERSION STRING="$(INF_VERSION)" Optional BUILD_NUM=$(BUILD_NUMBER) - } diff --git a/OvmfPkg/OvmfPkgX64.dsc b/OvmfPkg/OvmfPkgX64.dsc deleted file mode 100644 index 2ceb31d7ff..0000000000 --- a/OvmfPkg/OvmfPkgX64.dsc +++ /dev/null @@ -1,855 +0,0 @@ -## @file -# EFI/Framework Open Virtual Machine Firmware (OVMF) platform -# -# Copyright (c) 2006 - 2017, Intel Corporation. All rights reserved.
-# (C) Copyright 2016 Hewlett Packard Enterprise Development LP
-# -# This program and the accompanying materials -# are licensed and made 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 Section - statements that will be processed to create a Makefile. -# -################################################################################ -[Defines] - PLATFORM_NAME = Ovmf - PLATFORM_GUID = 5a9e7754-d81b-49ea-85ad-69eaa7b1539b - PLATFORM_VERSION = 0.1 - DSC_SPECIFICATION = 0x00010005 - OUTPUT_DIRECTORY = Build/OvmfX64 - SUPPORTED_ARCHITECTURES = X64 - BUILD_TARGETS = NOOPT|DEBUG|RELEASE - SKUID_IDENTIFIER = DEFAULT - FLASH_DEFINITION = OvmfPkg/OvmfPkgX64.fdf - - # - # Defines for default states. These can be changed on the command line. - # -D FLAG=VALUE - # - DEFINE SECURE_BOOT_ENABLE = FALSE - DEFINE NETWORK_IP6_ENABLE = FALSE - DEFINE HTTP_BOOT_ENABLE = FALSE - DEFINE SMM_REQUIRE = FALSE - DEFINE TLS_ENABLE = FALSE - -[BuildOptions] - GCC:*_UNIXGCC_*_CC_FLAGS = -DMDEPKG_NDEBUG - GCC:RELEASE_*_*_CC_FLAGS = -DMDEPKG_NDEBUG - 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 - - # - # Disable deprecated APIs. - # - MSFT:*_*_*_CC_FLAGS = /D DISABLE_NEW_DEPRECATED_INTERFACES - INTEL:*_*_*_CC_FLAGS = /D DISABLE_NEW_DEPRECATED_INTERFACES - GCC:*_*_*_CC_FLAGS = -D DISABLE_NEW_DEPRECATED_INTERFACES - -[BuildOptions.common.EDKII.DXE_RUNTIME_DRIVER] - GCC:*_*_*_DLINK_FLAGS = -z common-page-size=0x1000 - -# Force PE/COFF sections to be aligned at 4KB boundaries to support page level -# protection of DXE_SMM_DRIVER/SMM_CORE modules -[BuildOptions.common.EDKII.DXE_SMM_DRIVER, BuildOptions.common.EDKII.SMM_CORE] - GCC:*_*_*_DLINK_FLAGS = -z common-page-size=0x1000 - -################################################################################ -# -# SKU Identification section - list of all SKU IDs supported by this Platform. -# -################################################################################ -[SkuIds] - 0|DEFAULT - -################################################################################ -# -# Library Class section - list of all Library Classes needed by this Platform. -# -################################################################################ -[LibraryClasses] - PcdLib|MdePkg/Library/BasePcdLibNull/BasePcdLibNull.inf - TimerLib|OvmfPkg/Library/AcpiTimerLib/BaseAcpiTimerLib.inf - PrintLib|MdePkg/Library/BasePrintLib/BasePrintLib.inf - BaseMemoryLib|MdePkg/Library/BaseMemoryLibRepStr/BaseMemoryLibRepStr.inf - BaseLib|MdePkg/Library/BaseLib/BaseLib.inf - SynchronizationLib|MdePkg/Library/BaseSynchronizationLib/BaseSynchronizationLib.inf - CpuLib|MdePkg/Library/BaseCpuLib/BaseCpuLib.inf - PerformanceLib|MdePkg/Library/BasePerformanceLibNull/BasePerformanceLibNull.inf - PeCoffLib|MdePkg/Library/BasePeCoffLib/BasePeCoffLib.inf - CacheMaintenanceLib|MdePkg/Library/BaseCacheMaintenanceLib/BaseCacheMaintenanceLib.inf - UefiDecompressLib|MdePkg/Library/BaseUefiDecompressLib/BaseUefiDecompressLib.inf - UefiHiiServicesLib|MdeModulePkg/Library/UefiHiiServicesLib/UefiHiiServicesLib.inf - HiiLib|MdeModulePkg/Library/UefiHiiLib/UefiHiiLib.inf - SortLib|MdeModulePkg/Library/UefiSortLib/UefiSortLib.inf - UefiBootManagerLib|MdeModulePkg/Library/UefiBootManagerLib/UefiBootManagerLib.inf - BootLogoLib|MdeModulePkg/Library/BootLogoLib/BootLogoLib.inf - FileExplorerLib|MdeModulePkg/Library/FileExplorerLib/FileExplorerLib.inf - CapsuleLib|MdeModulePkg/Library/DxeCapsuleLibNull/DxeCapsuleLibNull.inf - DxeServicesLib|MdePkg/Library/DxeServicesLib/DxeServicesLib.inf - DxeServicesTableLib|MdePkg/Library/DxeServicesTableLib/DxeServicesTableLib.inf - PeCoffGetEntryPointLib|MdePkg/Library/BasePeCoffGetEntryPointLib/BasePeCoffGetEntryPointLib.inf - PciCf8Lib|MdePkg/Library/BasePciCf8Lib/BasePciCf8Lib.inf - PciExpressLib|MdePkg/Library/BasePciExpressLib/BasePciExpressLib.inf - PciLib|MdePkg/Library/BasePciLibCf8/BasePciLibCf8.inf - PciSegmentLib|MdePkg/Library/BasePciSegmentLibPci/BasePciSegmentLibPci.inf - IoLib|MdePkg/Library/BaseIoLibIntrinsic/BaseIoLibIntrinsic.inf - OemHookStatusCodeLib|MdeModulePkg/Library/OemHookStatusCodeLibNull/OemHookStatusCodeLibNull.inf - SerialPortLib|PcAtChipsetPkg/Library/SerialIoLib/SerialIoLib.inf - MtrrLib|UefiCpuPkg/Library/MtrrLib/MtrrLib.inf - UefiLib|MdePkg/Library/UefiLib/UefiLib.inf - UefiBootServicesTableLib|MdePkg/Library/UefiBootServicesTableLib/UefiBootServicesTableLib.inf - UefiRuntimeServicesTableLib|MdePkg/Library/UefiRuntimeServicesTableLib/UefiRuntimeServicesTableLib.inf - UefiDriverEntryPoint|MdePkg/Library/UefiDriverEntryPoint/UefiDriverEntryPoint.inf - UefiApplicationEntryPoint|MdePkg/Library/UefiApplicationEntryPoint/UefiApplicationEntryPoint.inf - DevicePathLib|MdePkg/Library/UefiDevicePathLibDevicePathProtocol/UefiDevicePathLibDevicePathProtocol.inf - NvVarsFileLib|OvmfPkg/Library/NvVarsFileLib/NvVarsFileLib.inf - FileHandleLib|MdePkg/Library/UefiFileHandleLib/UefiFileHandleLib.inf - UefiCpuLib|UefiCpuPkg/Library/BaseUefiCpuLib/BaseUefiCpuLib.inf - SecurityManagementLib|MdeModulePkg/Library/DxeSecurityManagementLib/DxeSecurityManagementLib.inf - NetLib|MdeModulePkg/Library/DxeNetLib/DxeNetLib.inf - IpIoLib|MdeModulePkg/Library/DxeIpIoLib/DxeIpIoLib.inf - UdpIoLib|MdeModulePkg/Library/DxeUdpIoLib/DxeUdpIoLib.inf - DpcLib|MdeModulePkg/Library/DxeDpcLib/DxeDpcLib.inf - UefiUsbLib|MdePkg/Library/UefiUsbLib/UefiUsbLib.inf - SerializeVariablesLib|OvmfPkg/Library/SerializeVariablesLib/SerializeVariablesLib.inf - QemuFwCfgLib|OvmfPkg/Library/QemuFwCfgLib/QemuFwCfgLib.inf - VirtioLib|OvmfPkg/Library/VirtioLib/VirtioLib.inf - LoadLinuxLib|OvmfPkg/Library/LoadLinuxLib/LoadLinuxLib.inf -!if $(SMM_REQUIRE) == FALSE - LockBoxLib|OvmfPkg/Library/LockBoxLib/LockBoxBaseLib.inf -!endif - CustomizedDisplayLib|MdeModulePkg/Library/CustomizedDisplayLib/CustomizedDisplayLib.inf - FrameBufferBltLib|MdeModulePkg/Library/FrameBufferBltLib/FrameBufferBltLib.inf - -!ifdef $(SOURCE_DEBUG_ENABLE) - PeCoffExtraActionLib|SourceLevelDebugPkg/Library/PeCoffExtraActionLibDebug/PeCoffExtraActionLibDebug.inf - DebugCommunicationLib|SourceLevelDebugPkg/Library/DebugCommunicationLibSerialPort/DebugCommunicationLibSerialPort.inf -!else - PeCoffExtraActionLib|MdePkg/Library/BasePeCoffExtraActionLibNull/BasePeCoffExtraActionLibNull.inf - DebugAgentLib|MdeModulePkg/Library/DebugAgentLibNull/DebugAgentLibNull.inf -!endif - - ResetSystemLib|OvmfPkg/Library/ResetSystemLib/ResetSystemLib.inf - LocalApicLib|UefiCpuPkg/Library/BaseXApicX2ApicLib/BaseXApicX2ApicLib.inf - DebugPrintErrorLevelLib|MdePkg/Library/BaseDebugPrintErrorLevelLib/BaseDebugPrintErrorLevelLib.inf - - IntrinsicLib|CryptoPkg/Library/IntrinsicLib/IntrinsicLib.inf -!if $(TLS_ENABLE) == TRUE - OpensslLib|CryptoPkg/Library/OpensslLib/OpensslLib.inf -!else - OpensslLib|CryptoPkg/Library/OpensslLib/OpensslLibCrypto.inf -!endif - -!if $(SECURE_BOOT_ENABLE) == TRUE - PlatformSecureLib|OvmfPkg/Library/PlatformSecureLib/PlatformSecureLib.inf - TpmMeasurementLib|SecurityPkg/Library/DxeTpmMeasurementLib/DxeTpmMeasurementLib.inf - AuthVariableLib|SecurityPkg/Library/AuthVariableLib/AuthVariableLib.inf -!else - TpmMeasurementLib|MdeModulePkg/Library/TpmMeasurementLibNull/TpmMeasurementLibNull.inf - AuthVariableLib|MdeModulePkg/Library/AuthVariableLibNull/AuthVariableLibNull.inf -!endif - VarCheckLib|MdeModulePkg/Library/VarCheckLib/VarCheckLib.inf - -!if $(NETWORK_IP6_ENABLE) == TRUE - TcpIoLib|MdeModulePkg/Library/DxeTcpIoLib/DxeTcpIoLib.inf -!endif - -!if $(HTTP_BOOT_ENABLE) == TRUE - HttpLib|MdeModulePkg/Library/DxeHttpLib/DxeHttpLib.inf -!endif - -!if $(TLS_ENABLE) == TRUE - TlsLib|CryptoPkg/Library/TlsLib/TlsLib.inf -!endif - - S3BootScriptLib|MdeModulePkg/Library/PiDxeS3BootScriptLib/DxeS3BootScriptLib.inf - SmbusLib|MdePkg/Library/BaseSmbusLibNull/BaseSmbusLibNull.inf - OrderedCollectionLib|MdePkg/Library/BaseOrderedCollectionRedBlackTreeLib/BaseOrderedCollectionRedBlackTreeLib.inf - XenHypercallLib|OvmfPkg/Library/XenHypercallLib/XenHypercallLib.inf - -[LibraryClasses.common] - BaseCryptLib|CryptoPkg/Library/BaseCryptLib/BaseCryptLib.inf - -[LibraryClasses.common.SEC] - TimerLib|OvmfPkg/Library/AcpiTimerLib/BaseRomAcpiTimerLib.inf - QemuFwCfgLib|OvmfPkg/Library/QemuFwCfgLib/QemuFwCfgSecLib.inf -!ifdef $(DEBUG_ON_SERIAL_PORT) - DebugLib|MdePkg/Library/BaseDebugLibSerialPort/BaseDebugLibSerialPort.inf -!else - DebugLib|OvmfPkg/Library/PlatformDebugLibIoPort/PlatformDebugLibIoPort.inf -!endif - ReportStatusCodeLib|MdeModulePkg/Library/PeiReportStatusCodeLib/PeiReportStatusCodeLib.inf - ExtractGuidedSectionLib|MdePkg/Library/BaseExtractGuidedSectionLib/BaseExtractGuidedSectionLib.inf -!ifdef $(SOURCE_DEBUG_ENABLE) - DebugAgentLib|SourceLevelDebugPkg/Library/DebugAgent/SecPeiDebugAgentLib.inf -!endif - HobLib|MdePkg/Library/PeiHobLib/PeiHobLib.inf - PeiServicesLib|MdePkg/Library/PeiServicesLib/PeiServicesLib.inf - PeiServicesTablePointerLib|MdePkg/Library/PeiServicesTablePointerLibIdt/PeiServicesTablePointerLibIdt.inf - MemoryAllocationLib|MdePkg/Library/PeiMemoryAllocationLib/PeiMemoryAllocationLib.inf - CpuExceptionHandlerLib|UefiCpuPkg/Library/CpuExceptionHandlerLib/SecPeiCpuExceptionHandlerLib.inf - -[LibraryClasses.common.PEI_CORE] - HobLib|MdePkg/Library/PeiHobLib/PeiHobLib.inf - PeiServicesTablePointerLib|MdePkg/Library/PeiServicesTablePointerLibIdt/PeiServicesTablePointerLibIdt.inf - PeiServicesLib|MdePkg/Library/PeiServicesLib/PeiServicesLib.inf - MemoryAllocationLib|MdePkg/Library/PeiMemoryAllocationLib/PeiMemoryAllocationLib.inf - PeiCoreEntryPoint|MdePkg/Library/PeiCoreEntryPoint/PeiCoreEntryPoint.inf - ReportStatusCodeLib|MdeModulePkg/Library/PeiReportStatusCodeLib/PeiReportStatusCodeLib.inf - OemHookStatusCodeLib|MdeModulePkg/Library/OemHookStatusCodeLibNull/OemHookStatusCodeLibNull.inf - PeCoffGetEntryPointLib|MdePkg/Library/BasePeCoffGetEntryPointLib/BasePeCoffGetEntryPointLib.inf -!ifdef $(DEBUG_ON_SERIAL_PORT) - DebugLib|MdePkg/Library/BaseDebugLibSerialPort/BaseDebugLibSerialPort.inf -!else - DebugLib|OvmfPkg/Library/PlatformDebugLibIoPort/PlatformDebugLibIoPort.inf -!endif - PeCoffLib|MdePkg/Library/BasePeCoffLib/BasePeCoffLib.inf - -[LibraryClasses.common.PEIM] - HobLib|MdePkg/Library/PeiHobLib/PeiHobLib.inf - PeiServicesTablePointerLib|MdePkg/Library/PeiServicesTablePointerLibIdt/PeiServicesTablePointerLibIdt.inf - PeiServicesLib|MdePkg/Library/PeiServicesLib/PeiServicesLib.inf - MemoryAllocationLib|MdePkg/Library/PeiMemoryAllocationLib/PeiMemoryAllocationLib.inf - PeimEntryPoint|MdePkg/Library/PeimEntryPoint/PeimEntryPoint.inf - ReportStatusCodeLib|MdeModulePkg/Library/PeiReportStatusCodeLib/PeiReportStatusCodeLib.inf - OemHookStatusCodeLib|MdeModulePkg/Library/OemHookStatusCodeLibNull/OemHookStatusCodeLibNull.inf - PeCoffGetEntryPointLib|MdePkg/Library/BasePeCoffGetEntryPointLib/BasePeCoffGetEntryPointLib.inf -!ifdef $(DEBUG_ON_SERIAL_PORT) - DebugLib|MdePkg/Library/BaseDebugLibSerialPort/BaseDebugLibSerialPort.inf -!else - DebugLib|OvmfPkg/Library/PlatformDebugLibIoPort/PlatformDebugLibIoPort.inf -!endif - PeCoffLib|MdePkg/Library/BasePeCoffLib/BasePeCoffLib.inf - PeiResourcePublicationLib|MdePkg/Library/PeiResourcePublicationLib/PeiResourcePublicationLib.inf - ExtractGuidedSectionLib|MdePkg/Library/PeiExtractGuidedSectionLib/PeiExtractGuidedSectionLib.inf -!ifdef $(SOURCE_DEBUG_ENABLE) - DebugAgentLib|SourceLevelDebugPkg/Library/DebugAgent/SecPeiDebugAgentLib.inf -!endif - CpuExceptionHandlerLib|UefiCpuPkg/Library/CpuExceptionHandlerLib/PeiCpuExceptionHandlerLib.inf - MpInitLib|UefiCpuPkg/Library/MpInitLib/PeiMpInitLib.inf - QemuFwCfgS3Lib|OvmfPkg/Library/QemuFwCfgS3Lib/PeiQemuFwCfgS3LibFwCfg.inf - -[LibraryClasses.common.DXE_CORE] - HobLib|MdePkg/Library/DxeCoreHobLib/DxeCoreHobLib.inf - DxeCoreEntryPoint|MdePkg/Library/DxeCoreEntryPoint/DxeCoreEntryPoint.inf - MemoryAllocationLib|MdeModulePkg/Library/DxeCoreMemoryAllocationLib/DxeCoreMemoryAllocationLib.inf - ReportStatusCodeLib|MdeModulePkg/Library/DxeReportStatusCodeLib/DxeReportStatusCodeLib.inf -!ifdef $(DEBUG_ON_SERIAL_PORT) - DebugLib|MdePkg/Library/BaseDebugLibSerialPort/BaseDebugLibSerialPort.inf -!else - DebugLib|OvmfPkg/Library/PlatformDebugLibIoPort/PlatformDebugLibIoPort.inf -!endif - ExtractGuidedSectionLib|MdePkg/Library/DxeExtractGuidedSectionLib/DxeExtractGuidedSectionLib.inf -!ifdef $(SOURCE_DEBUG_ENABLE) - DebugAgentLib|SourceLevelDebugPkg/Library/DebugAgent/DxeDebugAgentLib.inf -!endif - CpuExceptionHandlerLib|UefiCpuPkg/Library/CpuExceptionHandlerLib/DxeCpuExceptionHandlerLib.inf - PcdLib|MdePkg/Library/DxePcdLib/DxePcdLib.inf - -[LibraryClasses.common.DXE_RUNTIME_DRIVER] - PcdLib|MdePkg/Library/DxePcdLib/DxePcdLib.inf - TimerLib|OvmfPkg/Library/AcpiTimerLib/DxeAcpiTimerLib.inf - HobLib|MdePkg/Library/DxeHobLib/DxeHobLib.inf - DxeCoreEntryPoint|MdePkg/Library/DxeCoreEntryPoint/DxeCoreEntryPoint.inf - MemoryAllocationLib|MdePkg/Library/UefiMemoryAllocationLib/UefiMemoryAllocationLib.inf - ReportStatusCodeLib|MdeModulePkg/Library/RuntimeDxeReportStatusCodeLib/RuntimeDxeReportStatusCodeLib.inf -!ifdef $(DEBUG_ON_SERIAL_PORT) - DebugLib|MdePkg/Library/BaseDebugLibSerialPort/BaseDebugLibSerialPort.inf -!else - DebugLib|OvmfPkg/Library/PlatformDebugLibIoPort/PlatformDebugLibIoPort.inf -!endif - UefiRuntimeLib|MdePkg/Library/UefiRuntimeLib/UefiRuntimeLib.inf - BaseCryptLib|CryptoPkg/Library/BaseCryptLib/RuntimeCryptLib.inf - PciLib|OvmfPkg/Library/DxePciLibI440FxQ35/DxePciLibI440FxQ35.inf - QemuFwCfgS3Lib|OvmfPkg/Library/QemuFwCfgS3Lib/DxeQemuFwCfgS3LibFwCfg.inf - -[LibraryClasses.common.UEFI_DRIVER] - PcdLib|MdePkg/Library/DxePcdLib/DxePcdLib.inf - TimerLib|OvmfPkg/Library/AcpiTimerLib/DxeAcpiTimerLib.inf - HobLib|MdePkg/Library/DxeHobLib/DxeHobLib.inf - DxeCoreEntryPoint|MdePkg/Library/DxeCoreEntryPoint/DxeCoreEntryPoint.inf - MemoryAllocationLib|MdePkg/Library/UefiMemoryAllocationLib/UefiMemoryAllocationLib.inf - ReportStatusCodeLib|MdeModulePkg/Library/DxeReportStatusCodeLib/DxeReportStatusCodeLib.inf -!ifdef $(DEBUG_ON_SERIAL_PORT) - DebugLib|MdePkg/Library/BaseDebugLibSerialPort/BaseDebugLibSerialPort.inf -!else - DebugLib|OvmfPkg/Library/PlatformDebugLibIoPort/PlatformDebugLibIoPort.inf -!endif - UefiScsiLib|MdePkg/Library/UefiScsiLib/UefiScsiLib.inf - PciLib|OvmfPkg/Library/DxePciLibI440FxQ35/DxePciLibI440FxQ35.inf - -[LibraryClasses.common.DXE_DRIVER] - PcdLib|MdePkg/Library/DxePcdLib/DxePcdLib.inf - TimerLib|OvmfPkg/Library/AcpiTimerLib/DxeAcpiTimerLib.inf - HobLib|MdePkg/Library/DxeHobLib/DxeHobLib.inf - MemoryAllocationLib|MdePkg/Library/UefiMemoryAllocationLib/UefiMemoryAllocationLib.inf - ReportStatusCodeLib|MdeModulePkg/Library/DxeReportStatusCodeLib/DxeReportStatusCodeLib.inf - UefiScsiLib|MdePkg/Library/UefiScsiLib/UefiScsiLib.inf -!ifdef $(DEBUG_ON_SERIAL_PORT) - DebugLib|MdePkg/Library/BaseDebugLibSerialPort/BaseDebugLibSerialPort.inf -!else - DebugLib|OvmfPkg/Library/PlatformDebugLibIoPort/PlatformDebugLibIoPort.inf -!endif - NetLib|MdeModulePkg/Library/DxeNetLib/DxeNetLib.inf - IpIoLib|MdeModulePkg/Library/DxeIpIoLib/DxeIpIoLib.inf - UdpIoLib|MdeModulePkg/Library/DxeUdpIoLib/DxeUdpIoLib.inf - DpcLib|MdeModulePkg/Library/DxeDpcLib/DxeDpcLib.inf - PlatformBootManagerLib|OvmfPkg/Library/PlatformBootManagerLib/PlatformBootManagerLib.inf - QemuBootOrderLib|OvmfPkg/Library/QemuBootOrderLib/QemuBootOrderLib.inf - CpuExceptionHandlerLib|UefiCpuPkg/Library/CpuExceptionHandlerLib/DxeCpuExceptionHandlerLib.inf -!if $(SMM_REQUIRE) == TRUE - LockBoxLib|MdeModulePkg/Library/SmmLockBoxLib/SmmLockBoxDxeLib.inf -!else - LockBoxLib|OvmfPkg/Library/LockBoxLib/LockBoxDxeLib.inf -!endif -!ifdef $(SOURCE_DEBUG_ENABLE) - DebugAgentLib|SourceLevelDebugPkg/Library/DebugAgent/DxeDebugAgentLib.inf -!endif - PciLib|OvmfPkg/Library/DxePciLibI440FxQ35/DxePciLibI440FxQ35.inf - MpInitLib|UefiCpuPkg/Library/MpInitLib/DxeMpInitLib.inf - QemuFwCfgS3Lib|OvmfPkg/Library/QemuFwCfgS3Lib/DxeQemuFwCfgS3LibFwCfg.inf - -[LibraryClasses.common.UEFI_APPLICATION] - PcdLib|MdePkg/Library/DxePcdLib/DxePcdLib.inf - TimerLib|OvmfPkg/Library/AcpiTimerLib/DxeAcpiTimerLib.inf - HobLib|MdePkg/Library/DxeHobLib/DxeHobLib.inf - MemoryAllocationLib|MdePkg/Library/UefiMemoryAllocationLib/UefiMemoryAllocationLib.inf - ReportStatusCodeLib|MdeModulePkg/Library/DxeReportStatusCodeLib/DxeReportStatusCodeLib.inf -!ifdef $(DEBUG_ON_SERIAL_PORT) - DebugLib|MdePkg/Library/BaseDebugLibSerialPort/BaseDebugLibSerialPort.inf -!else - DebugLib|OvmfPkg/Library/PlatformDebugLibIoPort/PlatformDebugLibIoPort.inf -!endif - PciLib|OvmfPkg/Library/DxePciLibI440FxQ35/DxePciLibI440FxQ35.inf - -[LibraryClasses.common.DXE_SMM_DRIVER] - PcdLib|MdePkg/Library/DxePcdLib/DxePcdLib.inf - TimerLib|OvmfPkg/Library/AcpiTimerLib/DxeAcpiTimerLib.inf - MemoryAllocationLib|MdePkg/Library/SmmMemoryAllocationLib/SmmMemoryAllocationLib.inf - ReportStatusCodeLib|MdeModulePkg/Library/DxeReportStatusCodeLib/DxeReportStatusCodeLib.inf - HobLib|MdePkg/Library/DxeHobLib/DxeHobLib.inf - SmmMemLib|MdePkg/Library/SmmMemLib/SmmMemLib.inf - SmmServicesTableLib|MdePkg/Library/SmmServicesTableLib/SmmServicesTableLib.inf -!ifdef $(DEBUG_ON_SERIAL_PORT) - DebugLib|MdePkg/Library/BaseDebugLibSerialPort/BaseDebugLibSerialPort.inf -!else - DebugLib|OvmfPkg/Library/PlatformDebugLibIoPort/PlatformDebugLibIoPort.inf -!endif - CpuExceptionHandlerLib|UefiCpuPkg/Library/CpuExceptionHandlerLib/SmmCpuExceptionHandlerLib.inf -!ifdef $(SOURCE_DEBUG_ENABLE) - DebugAgentLib|SourceLevelDebugPkg/Library/DebugAgent/SmmDebugAgentLib.inf -!endif - BaseCryptLib|CryptoPkg/Library/BaseCryptLib/SmmCryptLib.inf - PciLib|OvmfPkg/Library/DxePciLibI440FxQ35/DxePciLibI440FxQ35.inf - -[LibraryClasses.common.SMM_CORE] - PcdLib|MdePkg/Library/DxePcdLib/DxePcdLib.inf - TimerLib|OvmfPkg/Library/AcpiTimerLib/DxeAcpiTimerLib.inf - SmmCorePlatformHookLib|MdeModulePkg/Library/SmmCorePlatformHookLibNull/SmmCorePlatformHookLibNull.inf - MemoryAllocationLib|MdeModulePkg/Library/PiSmmCoreMemoryAllocationLib/PiSmmCoreMemoryAllocationLib.inf - ReportStatusCodeLib|MdeModulePkg/Library/DxeReportStatusCodeLib/DxeReportStatusCodeLib.inf - HobLib|MdePkg/Library/DxeHobLib/DxeHobLib.inf - SmmMemLib|MdePkg/Library/SmmMemLib/SmmMemLib.inf - SmmServicesTableLib|MdeModulePkg/Library/PiSmmCoreSmmServicesTableLib/PiSmmCoreSmmServicesTableLib.inf -!ifdef $(DEBUG_ON_SERIAL_PORT) - DebugLib|MdePkg/Library/BaseDebugLibSerialPort/BaseDebugLibSerialPort.inf -!else - DebugLib|OvmfPkg/Library/PlatformDebugLibIoPort/PlatformDebugLibIoPort.inf -!endif - PciLib|OvmfPkg/Library/DxePciLibI440FxQ35/DxePciLibI440FxQ35.inf - -################################################################################ -# -# Pcd Section - list of all EDK II PCD Entries defined by this Platform. -# -################################################################################ -[PcdsFeatureFlag] - gEfiMdeModulePkgTokenSpaceGuid.PcdHiiOsRuntimeSupport|FALSE - gEfiMdeModulePkgTokenSpaceGuid.PcdStatusCodeUseSerial|FALSE - gEfiMdeModulePkgTokenSpaceGuid.PcdStatusCodeUseMemory|TRUE - gEfiMdeModulePkgTokenSpaceGuid.PcdDxeIplSupportUefiDecompress|FALSE - gEfiMdeModulePkgTokenSpaceGuid.PcdDxeIplSwitchToLongMode|FALSE - gEfiMdeModulePkgTokenSpaceGuid.PcdConOutGopSupport|TRUE - gEfiMdeModulePkgTokenSpaceGuid.PcdConOutUgaSupport|FALSE - gEfiMdeModulePkgTokenSpaceGuid.PcdInstallAcpiSdtProtocol|TRUE -!if $(SECURE_BOOT_ENABLE) == TRUE - gUefiOvmfPkgTokenSpaceGuid.PcdSecureBootEnable|TRUE -!endif -!if $(SMM_REQUIRE) == TRUE - gUefiOvmfPkgTokenSpaceGuid.PcdSmmSmramRequire|TRUE - gUefiCpuPkgTokenSpaceGuid.PcdCpuSmmEnableBspElection|FALSE -!endif - -[PcdsFixedAtBuild] - gEfiMdeModulePkgTokenSpaceGuid.PcdStatusCodeMemorySize|1 - gEfiMdeModulePkgTokenSpaceGuid.PcdResetOnMemoryTypeInformationChange|FALSE - gEfiMdePkgTokenSpaceGuid.PcdMaximumGuidedExtractHandler|0x10 - gEfiMdeModulePkgTokenSpaceGuid.PcdPeiCoreMaxFvSupported|6 - gEfiMdeModulePkgTokenSpaceGuid.PcdPeiCoreMaxPeimPerFv|32 - gEfiMdeModulePkgTokenSpaceGuid.PcdMaxVariableSize|0x2000 - gEfiMdeModulePkgTokenSpaceGuid.PcdMaxAuthVariableSize|0x2800 - gEfiMdeModulePkgTokenSpaceGuid.PcdVariableStoreSize|0xe000 - - gEfiMdeModulePkgTokenSpaceGuid.PcdVpdBaseAddress|0x0 - - gEfiMdePkgTokenSpaceGuid.PcdReportStatusCodePropertyMask|0x07 - - # DEBUG_INIT 0x00000001 // Initialization - # DEBUG_WARN 0x00000002 // Warnings - # DEBUG_LOAD 0x00000004 // Load events - # DEBUG_FS 0x00000008 // EFI File system - # DEBUG_POOL 0x00000010 // Alloc & Free (pool) - # DEBUG_PAGE 0x00000020 // Alloc & Free (page) - # DEBUG_INFO 0x00000040 // Informational debug messages - # DEBUG_DISPATCH 0x00000080 // PEI/DXE/SMM Dispatchers - # DEBUG_VARIABLE 0x00000100 // Variable - # DEBUG_BM 0x00000400 // Boot Manager - # DEBUG_BLKIO 0x00001000 // BlkIo Driver - # DEBUG_NET 0x00004000 // SNP Driver - # DEBUG_UNDI 0x00010000 // UNDI Driver - # DEBUG_LOADFILE 0x00020000 // LoadFile - # DEBUG_EVENT 0x00080000 // Event messages - # DEBUG_GCD 0x00100000 // Global Coherency Database changes - # DEBUG_CACHE 0x00200000 // Memory range cachability changes - # DEBUG_VERBOSE 0x00400000 // Detailed debug messages that may - # // significantly impact boot performance - # DEBUG_ERROR 0x80000000 // Error - gEfiMdePkgTokenSpaceGuid.PcdDebugPrintErrorLevel|0x8000004F - -!ifdef $(SOURCE_DEBUG_ENABLE) - gEfiMdePkgTokenSpaceGuid.PcdDebugPropertyMask|0x17 -!else - gEfiMdePkgTokenSpaceGuid.PcdDebugPropertyMask|0x2F -!endif - - # This PCD is used to set the base address of the PCI express hierarchy. It - # is only consulted when OVMF runs on Q35. In that case it is programmed into - # the PCIEXBAR register. - # - # On Q35 machine types that QEMU intends to support in the long term, QEMU - # never lets the RAM below 4 GB exceed 2 GB. - gEfiMdePkgTokenSpaceGuid.PcdPciExpressBaseAddress|0x80000000 - -!ifdef $(SOURCE_DEBUG_ENABLE) - gEfiSourceLevelDebugPkgTokenSpaceGuid.PcdDebugLoadImageMethod|0x2 -!endif - -!if $(HTTP_BOOT_ENABLE) == TRUE - gEfiNetworkPkgTokenSpaceGuid.PcdAllowHttpConnections|TRUE -!endif - -!ifndef $(USE_OLD_SHELL) - gEfiIntelFrameworkModulePkgTokenSpaceGuid.PcdShellFile|{ 0x83, 0xA5, 0x04, 0x7C, 0x3E, 0x9E, 0x1C, 0x4F, 0xAD, 0x65, 0xE0, 0x52, 0x68, 0xD0, 0xB4, 0xD1 } -!endif - -!if $(SMM_REQUIRE) == TRUE - gUefiCpuPkgTokenSpaceGuid.PcdCpuSmmStackSize|0x4000 -!endif - -!if $(SECURE_BOOT_ENABLE) == TRUE - gEfiSecurityPkgTokenSpaceGuid.PcdOptionRomImageVerificationPolicy|0x00 -!endif - - # IRQs 5, 9, 10, 11 are level-triggered - gPcAtChipsetPkgTokenSpaceGuid.Pcd8259LegacyModeEdgeLevel|0x0E20 - - # Point to the MdeModulePkg/Application/UiApp/UiApp.inf - gEfiMdeModulePkgTokenSpaceGuid.PcdBootManagerMenuFile|{ 0x21, 0xaa, 0x2c, 0x46, 0x14, 0x76, 0x03, 0x45, 0x83, 0x6e, 0x8a, 0xb6, 0xf4, 0x66, 0x23, 0x31 } - -################################################################################ -# -# Pcd Dynamic Section - list of all EDK II PCD Entries defined by this Platform -# -################################################################################ - -[PcdsDynamicDefault] - gEfiMdeModulePkgTokenSpaceGuid.PcdEmuVariableNvStoreReserved|0 - gEfiMdeModulePkgTokenSpaceGuid.PcdFlashNvStorageVariableBase64|0 - gEfiMdeModulePkgTokenSpaceGuid.PcdFlashNvStorageFtwWorkingBase|0 - gEfiMdeModulePkgTokenSpaceGuid.PcdFlashNvStorageFtwSpareBase|0 - gEfiMdeModulePkgTokenSpaceGuid.PcdPciDisableBusEnumeration|FALSE - gEfiMdeModulePkgTokenSpaceGuid.PcdVideoHorizontalResolution|800 - gEfiMdeModulePkgTokenSpaceGuid.PcdVideoVerticalResolution|600 - gEfiMdeModulePkgTokenSpaceGuid.PcdAcpiS3Enable|FALSE - gUefiOvmfPkgTokenSpaceGuid.PcdOvmfHostBridgePciDevId|0 - gUefiOvmfPkgTokenSpaceGuid.PcdPciIoBase|0x0 - gUefiOvmfPkgTokenSpaceGuid.PcdPciIoSize|0x0 - gUefiOvmfPkgTokenSpaceGuid.PcdPciMmio32Base|0x0 - gUefiOvmfPkgTokenSpaceGuid.PcdPciMmio32Size|0x0 - gUefiOvmfPkgTokenSpaceGuid.PcdPciMmio64Base|0x0 - gUefiOvmfPkgTokenSpaceGuid.PcdPciMmio64Size|0x800000000 - - gEfiMdePkgTokenSpaceGuid.PcdPlatformBootTimeOut|0 - - # Set video resolution for text setup. - gEfiMdeModulePkgTokenSpaceGuid.PcdSetupVideoHorizontalResolution|640 - gEfiMdeModulePkgTokenSpaceGuid.PcdSetupVideoVerticalResolution|480 - - gEfiMdeModulePkgTokenSpaceGuid.PcdSmbiosVersion|0x0208 - gEfiMdeModulePkgTokenSpaceGuid.PcdSmbiosDocRev|0x0 - gUefiOvmfPkgTokenSpaceGuid.PcdQemuSmbiosValidated|FALSE - - # Noexec settings for DXE. - gEfiMdeModulePkgTokenSpaceGuid.PcdSetNxForStack|FALSE - gEfiMdeModulePkgTokenSpaceGuid.PcdPropertiesTableEnable|FALSE - - # UefiCpuPkg PCDs related to initial AP bringup and general AP management. - gUefiCpuPkgTokenSpaceGuid.PcdCpuMaxLogicalProcessorNumber|64 - gUefiCpuPkgTokenSpaceGuid.PcdCpuApInitTimeOutInMicroSeconds|50000 - -!if $(SMM_REQUIRE) == TRUE - gUefiCpuPkgTokenSpaceGuid.PcdCpuSmmSyncMode|0x01 - gUefiCpuPkgTokenSpaceGuid.PcdCpuSmmApSyncTimeout|100000 -!endif - -################################################################################ -# -# Components Section - list of all EDK II Modules needed by this Platform. -# -################################################################################ -[Components] - OvmfPkg/ResetVector/ResetVector.inf - - # - # SEC Phase modules - # - OvmfPkg/Sec/SecMain.inf { - - NULL|MdeModulePkg/Library/LzmaCustomDecompressLib/LzmaCustomDecompressLib.inf - } - - # - # PEI Phase modules - # - MdeModulePkg/Core/Pei/PeiMain.inf - MdeModulePkg/Universal/PCD/Pei/Pcd.inf { - - PcdLib|MdePkg/Library/BasePcdLibNull/BasePcdLibNull.inf - } - MdeModulePkg/Universal/ReportStatusCodeRouter/Pei/ReportStatusCodeRouterPei.inf - MdeModulePkg/Universal/StatusCodeHandler/Pei/StatusCodeHandlerPei.inf - MdeModulePkg/Core/DxeIplPeim/DxeIpl.inf { - - PcdLib|MdePkg/Library/PeiPcdLib/PeiPcdLib.inf - } - - OvmfPkg/PlatformPei/PlatformPei.inf { - - PcdLib|MdePkg/Library/PeiPcdLib/PeiPcdLib.inf - } - UefiCpuPkg/Universal/Acpi/S3Resume2Pei/S3Resume2Pei.inf { - - PcdLib|MdePkg/Library/PeiPcdLib/PeiPcdLib.inf -!if $(SMM_REQUIRE) == TRUE - LockBoxLib|MdeModulePkg/Library/SmmLockBoxLib/SmmLockBoxPeiLib.inf -!endif - } -!if $(SMM_REQUIRE) == TRUE - OvmfPkg/SmmAccess/SmmAccessPei.inf { - - PcdLib|MdePkg/Library/PeiPcdLib/PeiPcdLib.inf - } -!endif - UefiCpuPkg/CpuMpPei/CpuMpPei.inf { - - PcdLib|MdePkg/Library/PeiPcdLib/PeiPcdLib.inf - } - - # - # DXE Phase modules - # - MdeModulePkg/Core/Dxe/DxeMain.inf { - - NULL|MdeModulePkg/Library/LzmaCustomDecompressLib/LzmaCustomDecompressLib.inf - DevicePathLib|MdePkg/Library/UefiDevicePathLib/UefiDevicePathLib.inf - } - - MdeModulePkg/Universal/ReportStatusCodeRouter/RuntimeDxe/ReportStatusCodeRouterRuntimeDxe.inf - MdeModulePkg/Universal/StatusCodeHandler/RuntimeDxe/StatusCodeHandlerRuntimeDxe.inf - MdeModulePkg/Universal/PCD/Dxe/Pcd.inf { - - PcdLib|MdePkg/Library/BasePcdLibNull/BasePcdLibNull.inf - } - - MdeModulePkg/Core/RuntimeDxe/RuntimeDxe.inf - -!if $(SECURE_BOOT_ENABLE) == TRUE - MdeModulePkg/Universal/SecurityStubDxe/SecurityStubDxe.inf { - - NULL|SecurityPkg/Library/DxeImageVerificationLib/DxeImageVerificationLib.inf - } -!else - MdeModulePkg/Universal/SecurityStubDxe/SecurityStubDxe.inf -!endif - - MdeModulePkg/Universal/EbcDxe/EbcDxe.inf - PcAtChipsetPkg/8259InterruptControllerDxe/8259.inf - UefiCpuPkg/CpuIo2Dxe/CpuIo2Dxe.inf - UefiCpuPkg/CpuDxe/CpuDxe.inf - PcAtChipsetPkg/8254TimerDxe/8254Timer.inf - OvmfPkg/IncompatiblePciDeviceSupportDxe/IncompatiblePciDeviceSupport.inf - OvmfPkg/PciHotPlugInitDxe/PciHotPlugInit.inf - MdeModulePkg/Bus/Pci/PciHostBridgeDxe/PciHostBridgeDxe.inf { - - PciHostBridgeLib|OvmfPkg/Library/PciHostBridgeLib/PciHostBridgeLib.inf - } - MdeModulePkg/Bus/Pci/PciBusDxe/PciBusDxe.inf { - - PcdLib|MdePkg/Library/DxePcdLib/DxePcdLib.inf - } - MdeModulePkg/Universal/ResetSystemRuntimeDxe/ResetSystemRuntimeDxe.inf - MdeModulePkg/Universal/Metronome/Metronome.inf - PcAtChipsetPkg/PcatRealTimeClockRuntimeDxe/PcatRealTimeClockRuntimeDxe.inf - MdeModulePkg/Universal/DriverHealthManagerDxe/DriverHealthManagerDxe.inf - MdeModulePkg/Universal/BdsDxe/BdsDxe.inf { - -!ifdef $(CSM_ENABLE) - NULL|OvmfPkg/Csm/CsmSupportLib/CsmSupportLib.inf - NULL|IntelFrameworkModulePkg/Library/LegacyBootManagerLib/LegacyBootManagerLib.inf -!endif - } - MdeModulePkg/Logo/LogoDxe.inf - MdeModulePkg/Application/UiApp/UiApp.inf { - - NULL|MdeModulePkg/Library/DeviceManagerUiLib/DeviceManagerUiLib.inf - NULL|MdeModulePkg/Library/BootManagerUiLib/BootManagerUiLib.inf - NULL|MdeModulePkg/Library/BootMaintenanceManagerUiLib/BootMaintenanceManagerUiLib.inf -!ifdef $(CSM_ENABLE) - NULL|IntelFrameworkModulePkg/Library/LegacyBootManagerLib/LegacyBootManagerLib.inf - NULL|IntelFrameworkModulePkg/Library/LegacyBootMaintUiLib/LegacyBootMaintUiLib.inf -!endif - } - OvmfPkg/BlockMmioToBlockIoDxe/BlockIo.inf - OvmfPkg/VirtioPciDeviceDxe/VirtioPciDeviceDxe.inf - OvmfPkg/Virtio10Dxe/Virtio10.inf - OvmfPkg/VirtioBlkDxe/VirtioBlk.inf - OvmfPkg/VirtioScsiDxe/VirtioScsi.inf - OvmfPkg/VirtioRngDxe/VirtioRng.inf - OvmfPkg/XenIoPciDxe/XenIoPciDxe.inf - OvmfPkg/XenBusDxe/XenBusDxe.inf - OvmfPkg/XenPvBlkDxe/XenPvBlkDxe.inf - MdeModulePkg/Universal/WatchdogTimerDxe/WatchdogTimer.inf - MdeModulePkg/Universal/MonotonicCounterRuntimeDxe/MonotonicCounterRuntimeDxe.inf - MdeModulePkg/Universal/CapsuleRuntimeDxe/CapsuleRuntimeDxe.inf - MdeModulePkg/Universal/Console/ConPlatformDxe/ConPlatformDxe.inf - MdeModulePkg/Universal/Console/ConSplitterDxe/ConSplitterDxe.inf - MdeModulePkg/Universal/Console/GraphicsConsoleDxe/GraphicsConsoleDxe.inf { - - PcdLib|MdePkg/Library/DxePcdLib/DxePcdLib.inf - } - MdeModulePkg/Universal/Console/TerminalDxe/TerminalDxe.inf - MdeModulePkg/Universal/DevicePathDxe/DevicePathDxe.inf { - - DevicePathLib|MdePkg/Library/UefiDevicePathLib/UefiDevicePathLib.inf - PcdLib|MdePkg/Library/BasePcdLibNull/BasePcdLibNull.inf - } - MdeModulePkg/Universal/PrintDxe/PrintDxe.inf - MdeModulePkg/Universal/Disk/DiskIoDxe/DiskIoDxe.inf - MdeModulePkg/Universal/Disk/PartitionDxe/PartitionDxe.inf - MdeModulePkg/Universal/Disk/RamDiskDxe/RamDiskDxe.inf - MdeModulePkg/Universal/Disk/UnicodeCollation/EnglishDxe/EnglishDxe.inf - FatPkg/EnhancedFatDxe/Fat.inf - MdeModulePkg/Bus/Scsi/ScsiBusDxe/ScsiBusDxe.inf - MdeModulePkg/Bus/Scsi/ScsiDiskDxe/ScsiDiskDxe.inf - OvmfPkg/SataControllerDxe/SataControllerDxe.inf - MdeModulePkg/Bus/Ata/AtaAtapiPassThru/AtaAtapiPassThru.inf - MdeModulePkg/Bus/Ata/AtaBusDxe/AtaBusDxe.inf - MdeModulePkg/Bus/Pci/NvmExpressDxe/NvmExpressDxe.inf - MdeModulePkg/Universal/HiiDatabaseDxe/HiiDatabaseDxe.inf - MdeModulePkg/Universal/SetupBrowserDxe/SetupBrowserDxe.inf - MdeModulePkg/Universal/DisplayEngineDxe/DisplayEngineDxe.inf - MdeModulePkg/Universal/MemoryTest/NullMemoryTestDxe/NullMemoryTestDxe.inf - - OvmfPkg/QemuVideoDxe/QemuVideoDxe.inf - OvmfPkg/VirtioGpuDxe/VirtioGpu.inf - - # - # ISA Support - # - PcAtChipsetPkg/IsaAcpiDxe/IsaAcpi.inf - IntelFrameworkModulePkg/Bus/Isa/IsaBusDxe/IsaBusDxe.inf - IntelFrameworkModulePkg/Bus/Isa/IsaSerialDxe/IsaSerialDxe.inf - IntelFrameworkModulePkg/Bus/Isa/Ps2KeyboardDxe/Ps2keyboardDxe.inf - IntelFrameworkModulePkg/Bus/Isa/IsaFloppyDxe/IsaFloppyDxe.inf - - # - # SMBIOS Support - # - MdeModulePkg/Universal/SmbiosDxe/SmbiosDxe.inf { - - NULL|OvmfPkg/Library/SmbiosVersionLib/DetectSmbiosVersionLib.inf - } - OvmfPkg/SmbiosPlatformDxe/SmbiosPlatformDxe.inf - - # - # ACPI Support - # - MdeModulePkg/Universal/Acpi/AcpiTableDxe/AcpiTableDxe.inf - OvmfPkg/AcpiPlatformDxe/AcpiPlatformDxe.inf - OvmfPkg/AcpiTables/AcpiTables.inf - MdeModulePkg/Universal/Acpi/S3SaveStateDxe/S3SaveStateDxe.inf - MdeModulePkg/Universal/Acpi/BootScriptExecutorDxe/BootScriptExecutorDxe.inf - MdeModulePkg/Universal/Acpi/BootGraphicsResourceTableDxe/BootGraphicsResourceTableDxe.inf - - # - # Network Support - # - MdeModulePkg/Universal/Network/SnpDxe/SnpDxe.inf - MdeModulePkg/Universal/Network/DpcDxe/DpcDxe.inf - MdeModulePkg/Universal/Network/MnpDxe/MnpDxe.inf - MdeModulePkg/Universal/Network/VlanConfigDxe/VlanConfigDxe.inf - MdeModulePkg/Universal/Network/ArpDxe/ArpDxe.inf - MdeModulePkg/Universal/Network/Dhcp4Dxe/Dhcp4Dxe.inf - MdeModulePkg/Universal/Network/Ip4Dxe/Ip4Dxe.inf - MdeModulePkg/Universal/Network/Mtftp4Dxe/Mtftp4Dxe.inf - MdeModulePkg/Universal/Network/Udp4Dxe/Udp4Dxe.inf -!if $(NETWORK_IP6_ENABLE) == TRUE - NetworkPkg/Ip6Dxe/Ip6Dxe.inf - NetworkPkg/TcpDxe/TcpDxe.inf - NetworkPkg/Udp6Dxe/Udp6Dxe.inf - NetworkPkg/Dhcp6Dxe/Dhcp6Dxe.inf - NetworkPkg/Mtftp6Dxe/Mtftp6Dxe.inf - NetworkPkg/UefiPxeBcDxe/UefiPxeBcDxe.inf - NetworkPkg/IScsiDxe/IScsiDxe.inf -!else - MdeModulePkg/Universal/Network/Tcp4Dxe/Tcp4Dxe.inf - MdeModulePkg/Universal/Network/UefiPxeBcDxe/UefiPxeBcDxe.inf - MdeModulePkg/Universal/Network/IScsiDxe/IScsiDxe.inf -!endif -!if $(HTTP_BOOT_ENABLE) == TRUE - NetworkPkg/DnsDxe/DnsDxe.inf - NetworkPkg/HttpUtilitiesDxe/HttpUtilitiesDxe.inf - NetworkPkg/HttpDxe/HttpDxe.inf - NetworkPkg/HttpBootDxe/HttpBootDxe.inf -!endif -!if $(TLS_ENABLE) == TRUE - NetworkPkg/TlsDxe/TlsDxe.inf - NetworkPkg/TlsAuthConfigDxe/TlsAuthConfigDxe.inf -!endif - OvmfPkg/VirtioNetDxe/VirtioNet.inf - - # - # Usb Support - # - MdeModulePkg/Bus/Pci/UhciDxe/UhciDxe.inf - MdeModulePkg/Bus/Pci/EhciDxe/EhciDxe.inf - MdeModulePkg/Bus/Pci/XhciDxe/XhciDxe.inf - MdeModulePkg/Bus/Usb/UsbBusDxe/UsbBusDxe.inf - MdeModulePkg/Bus/Usb/UsbKbDxe/UsbKbDxe.inf - MdeModulePkg/Bus/Usb/UsbMassStorageDxe/UsbMassStorageDxe.inf - -!ifdef $(CSM_ENABLE) - IntelFrameworkModulePkg/Csm/BiosThunk/VideoDxe/VideoDxe.inf { - - PcdLib|MdePkg/Library/DxePcdLib/DxePcdLib.inf - } - IntelFrameworkModulePkg/Csm/LegacyBiosDxe/LegacyBiosDxe.inf - OvmfPkg/Csm/Csm16/Csm16.inf -!endif - -!ifndef $(USE_OLD_SHELL) - ShellPkg/Application/Shell/Shell.inf { - - ShellCommandLib|ShellPkg/Library/UefiShellCommandLib/UefiShellCommandLib.inf - NULL|ShellPkg/Library/UefiShellLevel2CommandsLib/UefiShellLevel2CommandsLib.inf - NULL|ShellPkg/Library/UefiShellLevel1CommandsLib/UefiShellLevel1CommandsLib.inf - NULL|ShellPkg/Library/UefiShellLevel3CommandsLib/UefiShellLevel3CommandsLib.inf - NULL|ShellPkg/Library/UefiShellDriver1CommandsLib/UefiShellDriver1CommandsLib.inf - NULL|ShellPkg/Library/UefiShellDebug1CommandsLib/UefiShellDebug1CommandsLib.inf - NULL|ShellPkg/Library/UefiShellInstall1CommandsLib/UefiShellInstall1CommandsLib.inf - NULL|ShellPkg/Library/UefiShellNetwork1CommandsLib/UefiShellNetwork1CommandsLib.inf -!if $(NETWORK_IP6_ENABLE) == TRUE - NULL|ShellPkg/Library/UefiShellNetwork2CommandsLib/UefiShellNetwork2CommandsLib.inf -!endif - NULL|ShellPkg/Library/UefiShellTftpCommandLib/UefiShellTftpCommandLib.inf - HandleParsingLib|ShellPkg/Library/UefiHandleParsingLib/UefiHandleParsingLib.inf - ShellLib|ShellPkg/Library/UefiShellLib/UefiShellLib.inf - FileHandleLib|MdePkg/Library/UefiFileHandleLib/UefiFileHandleLib.inf - PrintLib|MdePkg/Library/BasePrintLib/BasePrintLib.inf -# SafeBlockIoLib|ShellPkg/Library/SafeBlockIoLib/SafeBlockIoLib.inf -# SafeOpenProtocolLib|ShellPkg/Library/SafeOpenProtocolLib/SafeOpenProtocolLib.inf - BcfgCommandLib|ShellPkg/Library/UefiShellBcfgCommandLib/UefiShellBcfgCommandLib.inf - - - gEfiMdePkgTokenSpaceGuid.PcdDebugPropertyMask|0xFF - gEfiShellPkgTokenSpaceGuid.PcdShellLibAutoInitialize|FALSE - gEfiMdePkgTokenSpaceGuid.PcdUefiLibMaxPrintBufferSize|8000 - } -!endif - -!if $(SECURE_BOOT_ENABLE) == TRUE - SecurityPkg/VariableAuthenticated/SecureBootConfigDxe/SecureBootConfigDxe.inf -!endif - - OvmfPkg/PlatformDxe/Platform.inf - -!if $(SMM_REQUIRE) == TRUE - OvmfPkg/SmmAccess/SmmAccess2Dxe.inf - OvmfPkg/SmmControl2Dxe/SmmControl2Dxe.inf - UefiCpuPkg/CpuS3DataDxe/CpuS3DataDxe.inf - - # - # SMM Initial Program Load (a DXE_RUNTIME_DRIVER) - # - MdeModulePkg/Core/PiSmmCore/PiSmmIpl.inf - - # - # SMM_CORE - # - MdeModulePkg/Core/PiSmmCore/PiSmmCore.inf - - # - # Privileged drivers (DXE_SMM_DRIVER modules) - # - UefiCpuPkg/CpuIo2Smm/CpuIo2Smm.inf - MdeModulePkg/Universal/LockBox/SmmLockBox/SmmLockBox.inf { - - LockBoxLib|MdeModulePkg/Library/SmmLockBoxLib/SmmLockBoxSmmLib.inf - } - UefiCpuPkg/PiSmmCpuDxeSmm/PiSmmCpuDxeSmm.inf { - - SmmCpuPlatformHookLib|UefiCpuPkg/Library/SmmCpuPlatformHookLibNull/SmmCpuPlatformHookLibNull.inf - SmmCpuFeaturesLib|OvmfPkg/Library/SmmCpuFeaturesLib/SmmCpuFeaturesLib.inf - } - - # - # Variable driver stack (SMM) - # - OvmfPkg/QemuFlashFvbServicesRuntimeDxe/FvbServicesSmm.inf - MdeModulePkg/Universal/FaultTolerantWriteDxe/FaultTolerantWriteSmm.inf - MdeModulePkg/Universal/Variable/RuntimeDxe/VariableSmm.inf { - - NULL|MdeModulePkg/Library/VarCheckUefiLib/VarCheckUefiLib.inf - } - MdeModulePkg/Universal/Variable/RuntimeDxe/VariableSmmRuntimeDxe.inf - -!else - - # - # Variable driver stack (non-SMM) - # - OvmfPkg/QemuFlashFvbServicesRuntimeDxe/FvbServicesRuntimeDxe.inf - OvmfPkg/EmuVariableFvbRuntimeDxe/Fvb.inf { - - PlatformFvbLib|OvmfPkg/Library/EmuVariableFvbLib/EmuVariableFvbLib.inf - } - MdeModulePkg/Universal/FaultTolerantWriteDxe/FaultTolerantWriteDxe.inf - MdeModulePkg/Universal/Variable/RuntimeDxe/VariableRuntimeDxe.inf { - - NULL|MdeModulePkg/Library/VarCheckUefiLib/VarCheckUefiLib.inf - } -!endif diff --git a/OvmfPkg/OvmfPkgX64.fdf b/OvmfPkg/OvmfPkgX64.fdf deleted file mode 100644 index 36150101e7..0000000000 --- a/OvmfPkg/OvmfPkgX64.fdf +++ /dev/null @@ -1,527 +0,0 @@ -## @file -# Open Virtual Machine Firmware: FDF -# -# Copyright (c) 2006 - 2016, Intel Corporation. All rights reserved.
-# (C) Copyright 2016 Hewlett Packard Enterprise Development LP
-# -# This program and the accompanying materials -# are licensed and made 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] -!include OvmfPkg.fdf.inc - -# -# Build the variable store and the firmware code as one unified flash device -# image. -# -[FD.OVMF] -BaseAddress = $(FW_BASE_ADDRESS) -Size = $(FW_SIZE) -ErasePolarity = 1 -BlockSize = $(BLOCK_SIZE) -NumBlocks = $(FW_BLOCKS) - -!include VarStore.fdf.inc - -$(VARS_SIZE)|$(FVMAIN_SIZE) -FV = FVMAIN_COMPACT - -$(SECFV_OFFSET)|$(SECFV_SIZE) -FV = SECFV - -# -# Build the variable store and the firmware code as separate flash device -# images. -# -[FD.OVMF_VARS] -BaseAddress = $(FW_BASE_ADDRESS) -Size = $(VARS_SIZE) -ErasePolarity = 1 -BlockSize = $(BLOCK_SIZE) -NumBlocks = $(VARS_BLOCKS) - -!include VarStore.fdf.inc - -[FD.OVMF_CODE] -BaseAddress = $(CODE_BASE_ADDRESS) -Size = $(CODE_SIZE) -ErasePolarity = 1 -BlockSize = $(BLOCK_SIZE) -NumBlocks = $(CODE_BLOCKS) - -0x00000000|$(FVMAIN_SIZE) -FV = FVMAIN_COMPACT - -$(FVMAIN_SIZE)|$(SECFV_SIZE) -FV = SECFV - -################################################################################ - -[FD.MEMFD] -BaseAddress = $(MEMFD_BASE_ADDRESS) -Size = 0xB00000 -ErasePolarity = 1 -BlockSize = 0x10000 -NumBlocks = 0xB0 - -0x000000|0x006000 -gUefiOvmfPkgTokenSpaceGuid.PcdOvmfSecPageTablesBase|gUefiOvmfPkgTokenSpaceGuid.PcdOvmfSecPageTablesSize - -0x006000|0x001000 -gUefiOvmfPkgTokenSpaceGuid.PcdOvmfLockBoxStorageBase|gUefiOvmfPkgTokenSpaceGuid.PcdOvmfLockBoxStorageSize - -0x007000|0x001000 -gEfiMdePkgTokenSpaceGuid.PcdGuidedExtractHandlerTableAddress|gUefiOvmfPkgTokenSpaceGuid.PcdGuidedExtractHandlerTableSize - -0x010000|0x008000 -gUefiOvmfPkgTokenSpaceGuid.PcdOvmfSecPeiTempRamBase|gUefiOvmfPkgTokenSpaceGuid.PcdOvmfSecPeiTempRamSize - -0x020000|0x0E0000 -gUefiOvmfPkgTokenSpaceGuid.PcdOvmfPeiMemFvBase|gUefiOvmfPkgTokenSpaceGuid.PcdOvmfPeiMemFvSize -FV = PEIFV - -0x100000|0xA00000 -gUefiOvmfPkgTokenSpaceGuid.PcdOvmfDxeMemFvBase|gUefiOvmfPkgTokenSpaceGuid.PcdOvmfDxeMemFvSize -FV = DXEFV - -################################################################################ - -[FV.SECFV] -FvNameGuid = 763BED0D-DE9F-48F5-81F1-3E90E1B1A015 -BlockSize = 0x1000 -FvAlignment = 16 -ERASE_POLARITY = 1 -MEMORY_MAPPED = TRUE -STICKY_WRITE = TRUE -LOCK_CAP = TRUE -LOCK_STATUS = TRUE -WRITE_DISABLED_CAP = TRUE -WRITE_ENABLED_CAP = TRUE -WRITE_STATUS = TRUE -WRITE_LOCK_CAP = TRUE -WRITE_LOCK_STATUS = TRUE -READ_DISABLED_CAP = TRUE -READ_ENABLED_CAP = TRUE -READ_STATUS = TRUE -READ_LOCK_CAP = TRUE -READ_LOCK_STATUS = TRUE - -# -# SEC Phase modules -# -# The code in this FV handles the initial firmware startup, and -# decompresses the PEI and DXE FVs which handles the rest of the boot sequence. -# -INF OvmfPkg/Sec/SecMain.inf - -INF RuleOverride=RESET_VECTOR OvmfPkg/ResetVector/ResetVector.inf - -################################################################################ -[FV.PEIFV] -FvNameGuid = 6938079B-B503-4E3D-9D24-B28337A25806 -BlockSize = 0x10000 -FvAlignment = 16 -ERASE_POLARITY = 1 -MEMORY_MAPPED = TRUE -STICKY_WRITE = TRUE -LOCK_CAP = TRUE -LOCK_STATUS = TRUE -WRITE_DISABLED_CAP = TRUE -WRITE_ENABLED_CAP = TRUE -WRITE_STATUS = TRUE -WRITE_LOCK_CAP = TRUE -WRITE_LOCK_STATUS = TRUE -READ_DISABLED_CAP = TRUE -READ_ENABLED_CAP = TRUE -READ_STATUS = TRUE -READ_LOCK_CAP = TRUE -READ_LOCK_STATUS = TRUE - -APRIORI PEI { - INF MdeModulePkg/Universal/PCD/Pei/Pcd.inf -} - -# -# PEI Phase modules -# -INF MdeModulePkg/Core/Pei/PeiMain.inf -INF MdeModulePkg/Universal/PCD/Pei/Pcd.inf -INF MdeModulePkg/Universal/ReportStatusCodeRouter/Pei/ReportStatusCodeRouterPei.inf -INF MdeModulePkg/Universal/StatusCodeHandler/Pei/StatusCodeHandlerPei.inf -INF OvmfPkg/PlatformPei/PlatformPei.inf -INF MdeModulePkg/Core/DxeIplPeim/DxeIpl.inf -INF UefiCpuPkg/Universal/Acpi/S3Resume2Pei/S3Resume2Pei.inf -!if $(SMM_REQUIRE) == TRUE -INF OvmfPkg/SmmAccess/SmmAccessPei.inf -!endif -INF UefiCpuPkg/CpuMpPei/CpuMpPei.inf - -################################################################################ - -[FV.DXEFV] -FvNameGuid = 7CB8BDC9-F8EB-4F34-AAEA-3EE4AF6516A1 -BlockSize = 0x10000 -FvAlignment = 16 -ERASE_POLARITY = 1 -MEMORY_MAPPED = TRUE -STICKY_WRITE = TRUE -LOCK_CAP = TRUE -LOCK_STATUS = TRUE -WRITE_DISABLED_CAP = TRUE -WRITE_ENABLED_CAP = TRUE -WRITE_STATUS = TRUE -WRITE_LOCK_CAP = TRUE -WRITE_LOCK_STATUS = TRUE -READ_DISABLED_CAP = TRUE -READ_ENABLED_CAP = TRUE -READ_STATUS = TRUE -READ_LOCK_CAP = TRUE -READ_LOCK_STATUS = TRUE - -APRIORI DXE { - INF MdeModulePkg/Universal/DevicePathDxe/DevicePathDxe.inf - INF MdeModulePkg/Universal/PCD/Dxe/Pcd.inf -!if $(SMM_REQUIRE) == FALSE - INF OvmfPkg/QemuFlashFvbServicesRuntimeDxe/FvbServicesRuntimeDxe.inf -!endif -} - -# -# DXE Phase modules -# -INF MdeModulePkg/Core/Dxe/DxeMain.inf - -INF MdeModulePkg/Universal/ReportStatusCodeRouter/RuntimeDxe/ReportStatusCodeRouterRuntimeDxe.inf -INF MdeModulePkg/Universal/StatusCodeHandler/RuntimeDxe/StatusCodeHandlerRuntimeDxe.inf -INF MdeModulePkg/Universal/PCD/Dxe/Pcd.inf - -INF MdeModulePkg/Core/RuntimeDxe/RuntimeDxe.inf -INF MdeModulePkg/Universal/SecurityStubDxe/SecurityStubDxe.inf -INF MdeModulePkg/Universal/EbcDxe/EbcDxe.inf -INF PcAtChipsetPkg/8259InterruptControllerDxe/8259.inf -INF UefiCpuPkg/CpuIo2Dxe/CpuIo2Dxe.inf -INF UefiCpuPkg/CpuDxe/CpuDxe.inf -INF PcAtChipsetPkg/8254TimerDxe/8254Timer.inf -INF OvmfPkg/IncompatiblePciDeviceSupportDxe/IncompatiblePciDeviceSupport.inf -INF OvmfPkg/PciHotPlugInitDxe/PciHotPlugInit.inf -INF MdeModulePkg/Bus/Pci/PciHostBridgeDxe/PciHostBridgeDxe.inf -INF MdeModulePkg/Bus/Pci/PciBusDxe/PciBusDxe.inf -INF MdeModulePkg/Universal/ResetSystemRuntimeDxe/ResetSystemRuntimeDxe.inf -INF MdeModulePkg/Universal/Metronome/Metronome.inf -INF PcAtChipsetPkg/PcatRealTimeClockRuntimeDxe/PcatRealTimeClockRuntimeDxe.inf - -INF OvmfPkg/BlockMmioToBlockIoDxe/BlockIo.inf -INF OvmfPkg/VirtioPciDeviceDxe/VirtioPciDeviceDxe.inf -INF OvmfPkg/Virtio10Dxe/Virtio10.inf -INF OvmfPkg/VirtioBlkDxe/VirtioBlk.inf -INF OvmfPkg/VirtioScsiDxe/VirtioScsi.inf -INF OvmfPkg/VirtioRngDxe/VirtioRng.inf -INF OvmfPkg/XenIoPciDxe/XenIoPciDxe.inf -INF OvmfPkg/XenBusDxe/XenBusDxe.inf -INF OvmfPkg/XenPvBlkDxe/XenPvBlkDxe.inf - -!if $(SECURE_BOOT_ENABLE) == TRUE - INF SecurityPkg/VariableAuthenticated/SecureBootConfigDxe/SecureBootConfigDxe.inf -!endif - -INF MdeModulePkg/Universal/WatchdogTimerDxe/WatchdogTimer.inf -INF MdeModulePkg/Universal/MonotonicCounterRuntimeDxe/MonotonicCounterRuntimeDxe.inf -INF MdeModulePkg/Universal/CapsuleRuntimeDxe/CapsuleRuntimeDxe.inf -INF MdeModulePkg/Universal/Console/ConPlatformDxe/ConPlatformDxe.inf -INF MdeModulePkg/Universal/Console/ConSplitterDxe/ConSplitterDxe.inf -INF MdeModulePkg/Universal/Console/GraphicsConsoleDxe/GraphicsConsoleDxe.inf -INF MdeModulePkg/Universal/Console/TerminalDxe/TerminalDxe.inf -INF MdeModulePkg/Universal/DriverHealthManagerDxe/DriverHealthManagerDxe.inf -INF MdeModulePkg/Universal/BdsDxe/BdsDxe.inf -INF MdeModulePkg/Application/UiApp/UiApp.inf -INF MdeModulePkg/Universal/DevicePathDxe/DevicePathDxe.inf -INF MdeModulePkg/Universal/PrintDxe/PrintDxe.inf -INF MdeModulePkg/Universal/Disk/DiskIoDxe/DiskIoDxe.inf -INF MdeModulePkg/Universal/Disk/PartitionDxe/PartitionDxe.inf -INF MdeModulePkg/Universal/Disk/RamDiskDxe/RamDiskDxe.inf -INF MdeModulePkg/Universal/Disk/UnicodeCollation/EnglishDxe/EnglishDxe.inf -INF MdeModulePkg/Bus/Scsi/ScsiBusDxe/ScsiBusDxe.inf -INF MdeModulePkg/Bus/Scsi/ScsiDiskDxe/ScsiDiskDxe.inf -INF OvmfPkg/SataControllerDxe/SataControllerDxe.inf -INF MdeModulePkg/Bus/Ata/AtaAtapiPassThru/AtaAtapiPassThru.inf -INF MdeModulePkg/Bus/Ata/AtaBusDxe/AtaBusDxe.inf -INF MdeModulePkg/Bus/Pci/NvmExpressDxe/NvmExpressDxe.inf -INF MdeModulePkg/Universal/HiiDatabaseDxe/HiiDatabaseDxe.inf -INF MdeModulePkg/Universal/SetupBrowserDxe/SetupBrowserDxe.inf -INF MdeModulePkg/Universal/DisplayEngineDxe/DisplayEngineDxe.inf -INF MdeModulePkg/Universal/MemoryTest/NullMemoryTestDxe/NullMemoryTestDxe.inf - -INF PcAtChipsetPkg/IsaAcpiDxe/IsaAcpi.inf -INF IntelFrameworkModulePkg/Bus/Isa/IsaBusDxe/IsaBusDxe.inf - -!ifndef $(SOURCE_DEBUG_ENABLE) -INF IntelFrameworkModulePkg/Bus/Isa/IsaSerialDxe/IsaSerialDxe.inf -!endif - -INF IntelFrameworkModulePkg/Bus/Isa/Ps2KeyboardDxe/Ps2keyboardDxe.inf -INF IntelFrameworkModulePkg/Bus/Isa/IsaFloppyDxe/IsaFloppyDxe.inf - -INF MdeModulePkg/Universal/SmbiosDxe/SmbiosDxe.inf -INF OvmfPkg/SmbiosPlatformDxe/SmbiosPlatformDxe.inf - -INF MdeModulePkg/Universal/Acpi/AcpiTableDxe/AcpiTableDxe.inf -INF OvmfPkg/AcpiPlatformDxe/AcpiPlatformDxe.inf -INF RuleOverride=ACPITABLE OvmfPkg/AcpiTables/AcpiTables.inf -INF MdeModulePkg/Universal/Acpi/S3SaveStateDxe/S3SaveStateDxe.inf -INF MdeModulePkg/Universal/Acpi/BootScriptExecutorDxe/BootScriptExecutorDxe.inf -INF MdeModulePkg/Universal/Acpi/BootGraphicsResourceTableDxe/BootGraphicsResourceTableDxe.inf - -INF FatPkg/EnhancedFatDxe/Fat.inf - -!ifndef $(USE_OLD_SHELL) -INF ShellPkg/Application/Shell/Shell.inf -!else -INF RuleOverride = BINARY EdkShellBinPkg/FullShell/FullShell.inf -!endif - -INF MdeModulePkg/Logo/LogoDxe.inf - -# -# Network modules -# -!if $(E1000_ENABLE) - FILE DRIVER = 5D695E11-9B3F-4b83-B25F-4A8D5D69BE07 { - SECTION PE32 = Intel3.5/EFIX64/E3507X2.EFI - } -!endif - INF MdeModulePkg/Universal/Network/SnpDxe/SnpDxe.inf - INF MdeModulePkg/Universal/Network/DpcDxe/DpcDxe.inf - INF MdeModulePkg/Universal/Network/MnpDxe/MnpDxe.inf - INF MdeModulePkg/Universal/Network/VlanConfigDxe/VlanConfigDxe.inf - INF MdeModulePkg/Universal/Network/ArpDxe/ArpDxe.inf - INF MdeModulePkg/Universal/Network/Dhcp4Dxe/Dhcp4Dxe.inf - INF MdeModulePkg/Universal/Network/Ip4Dxe/Ip4Dxe.inf - INF MdeModulePkg/Universal/Network/Mtftp4Dxe/Mtftp4Dxe.inf - INF MdeModulePkg/Universal/Network/Udp4Dxe/Udp4Dxe.inf -!if $(NETWORK_IP6_ENABLE) == TRUE - INF NetworkPkg/Ip6Dxe/Ip6Dxe.inf - INF NetworkPkg/TcpDxe/TcpDxe.inf - INF NetworkPkg/Udp6Dxe/Udp6Dxe.inf - INF NetworkPkg/Dhcp6Dxe/Dhcp6Dxe.inf - INF NetworkPkg/Mtftp6Dxe/Mtftp6Dxe.inf - INF NetworkPkg/UefiPxeBcDxe/UefiPxeBcDxe.inf - INF NetworkPkg/IScsiDxe/IScsiDxe.inf -!else - INF MdeModulePkg/Universal/Network/Tcp4Dxe/Tcp4Dxe.inf - INF MdeModulePkg/Universal/Network/UefiPxeBcDxe/UefiPxeBcDxe.inf - INF MdeModulePkg/Universal/Network/IScsiDxe/IScsiDxe.inf -!endif -!if $(HTTP_BOOT_ENABLE) == TRUE - INF NetworkPkg/DnsDxe/DnsDxe.inf - INF NetworkPkg/HttpUtilitiesDxe/HttpUtilitiesDxe.inf - INF NetworkPkg/HttpDxe/HttpDxe.inf - INF NetworkPkg/HttpBootDxe/HttpBootDxe.inf -!endif -!if $(TLS_ENABLE) == TRUE - INF NetworkPkg/TlsDxe/TlsDxe.inf - INF NetworkPkg/TlsAuthConfigDxe/TlsAuthConfigDxe.inf -!endif - INF OvmfPkg/VirtioNetDxe/VirtioNet.inf - -# -# Usb Support -# -INF MdeModulePkg/Bus/Pci/UhciDxe/UhciDxe.inf -INF MdeModulePkg/Bus/Pci/EhciDxe/EhciDxe.inf -INF MdeModulePkg/Bus/Pci/XhciDxe/XhciDxe.inf -INF MdeModulePkg/Bus/Usb/UsbBusDxe/UsbBusDxe.inf -INF MdeModulePkg/Bus/Usb/UsbKbDxe/UsbKbDxe.inf -INF MdeModulePkg/Bus/Usb/UsbMassStorageDxe/UsbMassStorageDxe.inf - -!ifdef $(CSM_ENABLE) -INF IntelFrameworkModulePkg/Csm/BiosThunk/VideoDxe/VideoDxe.inf -INF IntelFrameworkModulePkg/Csm/LegacyBiosDxe/LegacyBiosDxe.inf -INF RuleOverride=CSM OvmfPkg/Csm/Csm16/Csm16.inf -!endif - -INF OvmfPkg/QemuVideoDxe/QemuVideoDxe.inf -INF OvmfPkg/VirtioGpuDxe/VirtioGpu.inf -INF OvmfPkg/PlatformDxe/Platform.inf - -!if $(SMM_REQUIRE) == TRUE -INF OvmfPkg/SmmAccess/SmmAccess2Dxe.inf -INF OvmfPkg/SmmControl2Dxe/SmmControl2Dxe.inf -INF UefiCpuPkg/CpuS3DataDxe/CpuS3DataDxe.inf -INF MdeModulePkg/Core/PiSmmCore/PiSmmIpl.inf -INF MdeModulePkg/Core/PiSmmCore/PiSmmCore.inf -INF UefiCpuPkg/CpuIo2Smm/CpuIo2Smm.inf -INF MdeModulePkg/Universal/LockBox/SmmLockBox/SmmLockBox.inf -INF UefiCpuPkg/PiSmmCpuDxeSmm/PiSmmCpuDxeSmm.inf - -# -# Variable driver stack (SMM) -# -INF OvmfPkg/QemuFlashFvbServicesRuntimeDxe/FvbServicesSmm.inf -INF MdeModulePkg/Universal/FaultTolerantWriteDxe/FaultTolerantWriteSmm.inf -INF MdeModulePkg/Universal/Variable/RuntimeDxe/VariableSmm.inf -INF MdeModulePkg/Universal/Variable/RuntimeDxe/VariableSmmRuntimeDxe.inf - -!else - -# -# Variable driver stack (non-SMM) -# -INF OvmfPkg/QemuFlashFvbServicesRuntimeDxe/FvbServicesRuntimeDxe.inf -INF OvmfPkg/EmuVariableFvbRuntimeDxe/Fvb.inf -INF MdeModulePkg/Universal/FaultTolerantWriteDxe/FaultTolerantWriteDxe.inf -INF MdeModulePkg/Universal/Variable/RuntimeDxe/VariableRuntimeDxe.inf -!endif - -################################################################################ - -[FV.FVMAIN_COMPACT] -FvNameGuid = 48DB5E17-707C-472D-91CD-1613E7EF51B0 -FvAlignment = 16 -ERASE_POLARITY = 1 -MEMORY_MAPPED = TRUE -STICKY_WRITE = TRUE -LOCK_CAP = TRUE -LOCK_STATUS = TRUE -WRITE_DISABLED_CAP = TRUE -WRITE_ENABLED_CAP = TRUE -WRITE_STATUS = TRUE -WRITE_LOCK_CAP = TRUE -WRITE_LOCK_STATUS = TRUE -READ_DISABLED_CAP = TRUE -READ_ENABLED_CAP = TRUE -READ_STATUS = TRUE -READ_LOCK_CAP = TRUE -READ_LOCK_STATUS = TRUE - -FILE FV_IMAGE = 9E21FD93-9C72-4c15-8C4B-E77F1DB2D792 { - SECTION GUIDED EE4E5898-3914-4259-9D6E-DC7BD79403CF PROCESSING_REQUIRED = TRUE { - # - # These firmware volumes will have files placed in them uncompressed, - # and then both firmware volumes will be compressed in a single - # compression operation in order to achieve better overall compression. - # - SECTION FV_IMAGE = PEIFV - SECTION FV_IMAGE = DXEFV - } - } - -!include DecomprScratchEnd.fdf.inc - -################################################################################ - -[Rule.Common.SEC] - FILE SEC = $(NAMED_GUID) { - PE32 PE32 $(INF_OUTPUT)/$(MODULE_NAME).efi - UI STRING ="$(MODULE_NAME)" Optional - VERSION STRING ="$(INF_VERSION)" Optional BUILD_NUM=$(BUILD_NUMBER) - } - -[Rule.Common.PEI_CORE] - FILE PEI_CORE = $(NAMED_GUID) { - PE32 PE32 Align=Auto $(INF_OUTPUT)/$(MODULE_NAME).efi - UI STRING ="$(MODULE_NAME)" Optional - VERSION STRING ="$(INF_VERSION)" Optional BUILD_NUM=$(BUILD_NUMBER) - } - -[Rule.Common.PEIM] - FILE PEIM = $(NAMED_GUID) { - PEI_DEPEX PEI_DEPEX Optional $(INF_OUTPUT)/$(MODULE_NAME).depex - PE32 PE32 Align=Auto $(INF_OUTPUT)/$(MODULE_NAME).efi - UI STRING="$(MODULE_NAME)" Optional - VERSION STRING="$(INF_VERSION)" Optional BUILD_NUM=$(BUILD_NUMBER) - } - -[Rule.Common.DXE_CORE] - FILE DXE_CORE = $(NAMED_GUID) { - PE32 PE32 $(INF_OUTPUT)/$(MODULE_NAME).efi - UI STRING="$(MODULE_NAME)" Optional - VERSION STRING="$(INF_VERSION)" Optional BUILD_NUM=$(BUILD_NUMBER) - } - -[Rule.Common.DXE_DRIVER] - FILE DRIVER = $(NAMED_GUID) { - DXE_DEPEX DXE_DEPEX Optional $(INF_OUTPUT)/$(MODULE_NAME).depex - PE32 PE32 $(INF_OUTPUT)/$(MODULE_NAME).efi - UI STRING="$(MODULE_NAME)" Optional - VERSION STRING="$(INF_VERSION)" Optional BUILD_NUM=$(BUILD_NUMBER) - RAW ACPI Optional |.acpi - RAW ASL Optional |.aml - } - -[Rule.Common.DXE_RUNTIME_DRIVER] - FILE DRIVER = $(NAMED_GUID) { - DXE_DEPEX DXE_DEPEX Optional $(INF_OUTPUT)/$(MODULE_NAME).depex - PE32 PE32 $(INF_OUTPUT)/$(MODULE_NAME).efi - UI STRING="$(MODULE_NAME)" Optional - VERSION STRING="$(INF_VERSION)" Optional BUILD_NUM=$(BUILD_NUMBER) - } - -[Rule.Common.UEFI_DRIVER] - FILE DRIVER = $(NAMED_GUID) { - DXE_DEPEX DXE_DEPEX Optional $(INF_OUTPUT)/$(MODULE_NAME).depex - PE32 PE32 $(INF_OUTPUT)/$(MODULE_NAME).efi - UI STRING="$(MODULE_NAME)" Optional - VERSION STRING="$(INF_VERSION)" Optional BUILD_NUM=$(BUILD_NUMBER) - } - -[Rule.Common.UEFI_DRIVER.BINARY] - FILE DRIVER = $(NAMED_GUID) { - DXE_DEPEX DXE_DEPEX Optional |.depex - PE32 PE32 |.efi - UI STRING="$(MODULE_NAME)" Optional - VERSION STRING="$(INF_VERSION)" Optional BUILD_NUM=$(BUILD_NUMBER) - } - -[Rule.Common.UEFI_APPLICATION] - FILE APPLICATION = $(NAMED_GUID) { - PE32 PE32 $(INF_OUTPUT)/$(MODULE_NAME).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) - } - -[Rule.Common.USER_DEFINED.ACPITABLE] - FILE FREEFORM = $(NAMED_GUID) { - RAW ACPI |.acpi - RAW ASL |.aml - } - -[Rule.Common.USER_DEFINED.CSM] - FILE FREEFORM = $(NAMED_GUID) { - RAW BIN |.bin - } - -[Rule.Common.SEC.RESET_VECTOR] - FILE RAW = $(NAMED_GUID) { - RAW BIN Align = 16 |.bin - } - -[Rule.Common.SMM_CORE] - FILE SMM_CORE = $(NAMED_GUID) { - PE32 PE32 $(INF_OUTPUT)/$(MODULE_NAME).efi - UI STRING="$(MODULE_NAME)" Optional - VERSION STRING="$(INF_VERSION)" Optional BUILD_NUM=$(BUILD_NUMBER) - } - -[Rule.Common.DXE_SMM_DRIVER] - FILE SMM = $(NAMED_GUID) { - SMM_DEPEX SMM_DEPEX Optional $(INF_OUTPUT)/$(MODULE_NAME).depex - PE32 PE32 $(INF_OUTPUT)/$(MODULE_NAME).efi - UI STRING="$(MODULE_NAME)" Optional - VERSION STRING="$(INF_VERSION)" Optional BUILD_NUM=$(BUILD_NUMBER) - } diff --git a/OvmfPkg/PciHotPlugInitDxe/PciHotPlugInit.c b/OvmfPkg/PciHotPlugInitDxe/PciHotPlugInit.c deleted file mode 100644 index 2265b8c7e1..0000000000 --- a/OvmfPkg/PciHotPlugInitDxe/PciHotPlugInit.c +++ /dev/null @@ -1,342 +0,0 @@ -/** @file - This driver implements EFI_PCI_HOT_PLUG_INIT_PROTOCOL, providing the PCI bus - driver with resource padding information, for PCIe hotplug purposes. - - Copyright (C) 2016, 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 - -#include -#include -#include -#include - -#include -#include - -// -// The protocol interface this driver produces. -// -// Refer to 12.6 "PCI Hot Plug PCI Initialization Protocol" in the Platform -// Init 1.4a Spec, Volume 5. -// -STATIC EFI_PCI_HOT_PLUG_INIT_PROTOCOL mPciHotPlugInit; - - -// -// Resource padding template for the GetResourcePadding() protocol member -// function. -// -// Refer to Table 8 "ACPI 2.0 & 3.0 QWORD Address Space Descriptor Usage" in -// the Platform Init 1.4a Spec, Volume 5. -// -// This structure is interpreted by the ApplyResourcePadding() function in the -// edk2 PCI Bus UEFI_DRIVER. -// -#pragma pack (1) -typedef struct { - EFI_ACPI_ADDRESS_SPACE_DESCRIPTOR MmioPadding; - EFI_ACPI_ADDRESS_SPACE_DESCRIPTOR IoPadding; - EFI_ACPI_END_TAG_DESCRIPTOR EndDesc; -} RESOURCE_PADDING; -#pragma pack () - -STATIC CONST RESOURCE_PADDING mPadding = { - // - // MmioPadding - // - { - ACPI_ADDRESS_SPACE_DESCRIPTOR, // Desc - (UINT16)( // Len - sizeof (EFI_ACPI_ADDRESS_SPACE_DESCRIPTOR) - - OFFSET_OF ( - EFI_ACPI_ADDRESS_SPACE_DESCRIPTOR, - ResType - ) - ), - ACPI_ADDRESS_SPACE_TYPE_MEM, // ResType - 0, // GenFlag: - // ignored - 0, // SpecificFlag: - // non-prefetchable - 64, // AddrSpaceGranularity: - // reserve 64-bit aperture - 0, // AddrRangeMin: - // ignored - SIZE_2MB - 1, // AddrRangeMax: - // align at 2MB - 0, // AddrTranslationOffset: - // ignored - SIZE_2MB // AddrLen: - // 2MB padding - }, - - // - // IoPadding - // - { - ACPI_ADDRESS_SPACE_DESCRIPTOR, // Desc - (UINT16)( // Len - sizeof (EFI_ACPI_ADDRESS_SPACE_DESCRIPTOR) - - OFFSET_OF ( - EFI_ACPI_ADDRESS_SPACE_DESCRIPTOR, - ResType - ) - ), - ACPI_ADDRESS_SPACE_TYPE_IO,// ResType - 0, // GenFlag: - // ignored - 0, // SpecificFlag: - // ignored - 0, // AddrSpaceGranularity: - // ignored - 0, // AddrRangeMin: - // ignored - 512 - 1, // AddrRangeMax: - // align at 512 IO ports - 0, // AddrTranslationOffset: - // ignored - 512 // AddrLen: - // 512 IO ports - }, - - // - // EndDesc - // - { - ACPI_END_TAG_DESCRIPTOR, // Desc - 0 // Checksum: to be ignored - } -}; - - -/** - Returns a list of root Hot Plug Controllers (HPCs) that require - initialization during the boot process. - - This procedure returns a list of root HPCs. The PCI bus driver must - initialize these controllers during the boot process. The PCI bus driver may - or may not be able to detect these HPCs. If the platform includes a - PCI-to-CardBus bridge, it can be included in this list if it requires - initialization. The HpcList must be self consistent. An HPC cannot control - any of its parent buses. Only one HPC can control a PCI bus. Because this - list includes only root HPCs, no HPC in the list can be a child of another - HPC. This policy must be enforced by the EFI_PCI_HOT_PLUG_INIT_PROTOCOL. - The PCI bus driver may not check for such invalid conditions. The callee - allocates the buffer HpcList - - @param[in] This Pointer to the EFI_PCI_HOT_PLUG_INIT_PROTOCOL - instance. - @param[out] HpcCount The number of root HPCs that were returned. - @param[out] HpcList The list of root HPCs. HpcCount defines the number of - elements in this list. - - @retval EFI_SUCCESS HpcList was returned. - @retval EFI_OUT_OF_RESOURCES HpcList was not returned due to insufficient - resources. - @retval EFI_INVALID_PARAMETER HpcCount is NULL or HpcList is NULL. -**/ -STATIC -EFI_STATUS -EFIAPI -GetRootHpcList ( - IN EFI_PCI_HOT_PLUG_INIT_PROTOCOL *This, - OUT UINTN *HpcCount, - OUT EFI_HPC_LOCATION **HpcList - ) -{ - if (HpcCount == NULL || HpcList == NULL) { - return EFI_INVALID_PARAMETER; - } - - // - // There are no top-level (i.e., un-enumerable) hot-plug controllers in QEMU - // that would require special initialization. - // - *HpcCount = 0; - *HpcList = NULL; - return EFI_SUCCESS; -} - - -/** - Initializes one root Hot Plug Controller (HPC). This process may causes - initialization of its subordinate buses. - - This function initializes the specified HPC. At the end of initialization, - the hot-plug slots or sockets (controlled by this HPC) are powered and are - connected to the bus. All the necessary registers in the HPC are set up. For - a Standard (PCI) Hot Plug Controller (SHPC), the registers that must be set - up are defined in the PCI Standard Hot Plug Controller and Subsystem - Specification. - - @param[in] This Pointer to the EFI_PCI_HOT_PLUG_INIT_PROTOCOL - instance. - @param[in] HpcDevicePath The device path to the HPC that is being - initialized. - @param[in] HpcPciAddress The address of the HPC function on the PCI bus. - @param[in] Event The event that should be signaled when the HPC - initialization is complete. Set to NULL if the - caller wants to wait until the entire - initialization process is complete. - @param[out] HpcState The state of the HPC hardware. The state is - EFI_HPC_STATE_INITIALIZED or - EFI_HPC_STATE_ENABLED. - - @retval EFI_SUCCESS If Event is NULL, the specific HPC was - successfully initialized. If Event is not - NULL, Event will be signaled at a later time - when initialization is complete. - @retval EFI_UNSUPPORTED This instance of - EFI_PCI_HOT_PLUG_INIT_PROTOCOL does not - support the specified HPC. - @retval EFI_OUT_OF_RESOURCES Initialization failed due to insufficient - resources. - @retval EFI_INVALID_PARAMETER HpcState is NULL. -**/ -STATIC -EFI_STATUS -EFIAPI -InitializeRootHpc ( - IN EFI_PCI_HOT_PLUG_INIT_PROTOCOL *This, - IN EFI_DEVICE_PATH_PROTOCOL *HpcDevicePath, - IN UINT64 HpcPciAddress, - IN EFI_EVENT Event, OPTIONAL - OUT EFI_HPC_STATE *HpcState - ) -{ - // - // This function should never be called, due to the information returned by - // GetRootHpcList(). - // - ASSERT (FALSE); - - if (HpcState == NULL) { - return EFI_INVALID_PARAMETER; - } - return EFI_UNSUPPORTED; -} - - -/** - Returns the resource padding that is required by the PCI bus that is - controlled by the specified Hot Plug Controller (HPC). - - This function returns the resource padding that is required by the PCI bus - that is controlled by the specified HPC. This member function is called for - all the root HPCs and nonroot HPCs that are detected by the PCI bus - enumerator. This function will be called before PCI resource allocation is - completed. This function must be called after all the root HPCs, with the - possible exception of a PCI-to-CardBus bridge, have completed - initialization. - - @param[in] This Pointer to the EFI_PCI_HOT_PLUG_INIT_PROTOCOL - instance. - @param[in] HpcDevicePath The device path to the HPC. - @param[in] HpcPciAddress The address of the HPC function on the PCI bus. - @param[in] HpcState The state of the HPC hardware. - @param[out] Padding The amount of resource padding that is required - by the PCI bus under the control of the specified - HPC. - @param[out] Attributes Describes how padding is accounted for. The - padding is returned in the form of ACPI 2.0 - resource descriptors. - - @retval EFI_SUCCESS The resource padding was successfully - returned. - @retval EFI_UNSUPPORTED This instance of the - EFI_PCI_HOT_PLUG_INIT_PROTOCOL does not - support the specified HPC. - @retval EFI_NOT_READY This function was called before HPC - initialization is complete. - @retval EFI_INVALID_PARAMETER HpcState or Padding or Attributes is NULL. - @retval EFI_OUT_OF_RESOURCES ACPI 2.0 resource descriptors for Padding - cannot be allocated due to insufficient - resources. -**/ -STATIC -EFI_STATUS -EFIAPI -GetResourcePadding ( - IN EFI_PCI_HOT_PLUG_INIT_PROTOCOL *This, - IN EFI_DEVICE_PATH_PROTOCOL *HpcDevicePath, - IN UINT64 HpcPciAddress, - OUT EFI_HPC_STATE *HpcState, - OUT VOID **Padding, - OUT EFI_HPC_PADDING_ATTRIBUTES *Attributes - ) -{ - DEBUG_CODE ( - EFI_PCI_ROOT_BRIDGE_IO_PROTOCOL_PCI_ADDRESS *Address; - CHAR16 *DevicePathString; - - Address = (EFI_PCI_ROOT_BRIDGE_IO_PROTOCOL_PCI_ADDRESS *)&HpcPciAddress; - DevicePathString = ConvertDevicePathToText (HpcDevicePath, FALSE, FALSE); - - DEBUG ((EFI_D_VERBOSE, "%a: Address=%02x:%02x.%x DevicePath=%s\n", - __FUNCTION__, Address->Bus, Address->Device, Address->Function, - (DevicePathString == NULL) ? L"" : DevicePathString)); - - if (DevicePathString != NULL) { - FreePool (DevicePathString); - } - ); - - if (HpcState == NULL || Padding == NULL || Attributes == NULL) { - return EFI_INVALID_PARAMETER; - } - - *Padding = AllocateCopyPool (sizeof mPadding, &mPadding); - if (*Padding == NULL) { - return EFI_OUT_OF_RESOURCES; - } - - // - // Resource padding is required. - // - *HpcState = EFI_HPC_STATE_INITIALIZED | EFI_HPC_STATE_ENABLED; - - // - // The padding should be applied at PCI bus level, and considered by upstream - // bridges, recursively. - // - *Attributes = EfiPaddingPciBus; - return EFI_SUCCESS; -} - - -/** - Entry point for this driver. - - @param[in] ImageHandle Image handle of this driver. - @param[in] SystemTable Pointer to SystemTable. - - @retval EFI_SUCESS Driver has loaded successfully. - @return Error codes from lower level functions. - -**/ -EFI_STATUS -EFIAPI -DriverInitialize ( - IN EFI_HANDLE ImageHandle, - IN EFI_SYSTEM_TABLE *SystemTable - ) -{ - EFI_STATUS Status; - - mPciHotPlugInit.GetRootHpcList = GetRootHpcList; - mPciHotPlugInit.InitializeRootHpc = InitializeRootHpc; - mPciHotPlugInit.GetResourcePadding = GetResourcePadding; - Status = gBS->InstallMultipleProtocolInterfaces (&ImageHandle, - &gEfiPciHotPlugInitProtocolGuid, &mPciHotPlugInit, NULL); - return Status; -} diff --git a/OvmfPkg/PciHotPlugInitDxe/PciHotPlugInit.inf b/OvmfPkg/PciHotPlugInitDxe/PciHotPlugInit.inf deleted file mode 100644 index 641ee2cad9..0000000000 --- a/OvmfPkg/PciHotPlugInitDxe/PciHotPlugInit.inf +++ /dev/null @@ -1,42 +0,0 @@ -## @file -# This driver implements EFI_PCI_HOT_PLUG_INIT_PROTOCOL, providing the PCI bus -# driver with resource padding information, for PCIe hotplug purposes. -# -# Copyright (C) 2016, 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 = PciHotPlugInitDxe - FILE_GUID = 11A6EDF6-A9BE-426D-A6CC-B22FE51D9224 - MODULE_TYPE = DXE_DRIVER - VERSION_STRING = 1.0 - ENTRY_POINT = DriverInitialize - -[Sources] - PciHotPlugInit.c - -[Packages] - MdeModulePkg/MdeModulePkg.dec - MdePkg/MdePkg.dec - -[LibraryClasses] - DebugLib - DevicePathLib - MemoryAllocationLib - UefiBootServicesTableLib - UefiDriverEntryPoint - -[Protocols] - gEfiPciHotPlugInitProtocolGuid ## SOMETIMES_PRODUCES - -[Depex] - TRUE diff --git a/OvmfPkg/PlatformDxe/Platform.c b/OvmfPkg/PlatformDxe/Platform.c deleted file mode 100644 index 126d8e7382..0000000000 --- a/OvmfPkg/PlatformDxe/Platform.c +++ /dev/null @@ -1,875 +0,0 @@ -/** @file - This driver effectuates OVMF's platform configuration settings and exposes - them via HII. - - Copyright (C) 2014, Red Hat, Inc. - Copyright (c) 2009 - 2014, Intel Corporation. All rights reserved.
- - This program and the accompanying materials are licensed and made available - under the terms and conditions of the BSD License which accompanies this - distribution. The full text of the license may be found at - http://opensource.org/licenses/bsd-license.php - - THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, WITHOUT - WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. -**/ - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#include "Platform.h" -#include "PlatformConfig.h" - -// -// The HiiAddPackages() library function requires that any controller (or -// image) handle, to be associated with the HII packages under installation, be -// "decorated" with a device path. The tradition seems to be a vendor device -// path. -// -// We'd like to associate our HII packages with the driver's image handle. The -// first idea is to use the driver image's device path. Unfortunately, loaded -// images only come with an EFI_LOADED_IMAGE_DEVICE_PATH_PROTOCOL (not the -// usual EFI_DEVICE_PATH_PROTOCOL), ie. a different GUID. In addition, even the -// EFI_LOADED_IMAGE_DEVICE_PATH_PROTOCOL interface may be NULL, if the image -// has been loaded from an "unnamed" memory source buffer. -// -// Hence let's just stick with the tradition -- use a dedicated vendor device -// path, with the driver's FILE_GUID. -// -#pragma pack(1) -typedef struct { - VENDOR_DEVICE_PATH VendorDevicePath; - EFI_DEVICE_PATH_PROTOCOL End; -} PKG_DEVICE_PATH; -#pragma pack() - -STATIC PKG_DEVICE_PATH mPkgDevicePath = { - { - { - HARDWARE_DEVICE_PATH, - HW_VENDOR_DP, - { - (UINT8) (sizeof (VENDOR_DEVICE_PATH) ), - (UINT8) (sizeof (VENDOR_DEVICE_PATH) >> 8) - } - }, - EFI_CALLER_ID_GUID - }, - { - END_DEVICE_PATH_TYPE, - END_ENTIRE_DEVICE_PATH_SUBTYPE, - { - (UINT8) (END_DEVICE_PATH_LENGTH ), - (UINT8) (END_DEVICE_PATH_LENGTH >> 8) - } - } -}; - -// -// The configuration interface between the HII engine (form display etc) and -// this driver. -// -STATIC EFI_HII_CONFIG_ACCESS_PROTOCOL mConfigAccess; - -// -// The handle representing our list of packages after installation. -// -STATIC EFI_HII_HANDLE mInstalledPackages; - -// -// The arrays below constitute our HII package list. They are auto-generated by -// the VFR compiler and linked into the driver image during the build. -// -// - The strings package receives its C identifier from the driver's BASE_NAME, -// plus "Strings". -// -// - The forms package receives its C identifier from the VFR file's basename, -// plus "Bin". -// -// -extern UINT8 PlatformDxeStrings[]; -extern UINT8 PlatformFormsBin[]; - -// -// We want to be notified about GOP installations until we find one GOP -// interface that lets us populate the form. -// -STATIC EFI_EVENT mGopEvent; - -// -// The registration record underneath this pointer allows us to iterate through -// the GOP instances one by one. -// -STATIC VOID *mGopTracker; - -// -// Cache the resolutions we get from the GOP. -// -typedef struct { - UINT32 X; - UINT32 Y; -} GOP_MODE; - -STATIC UINTN mNumGopModes; -STATIC GOP_MODE *mGopModes; - - -/** - Load the persistent platform configuration and translate it to binary form - state. - - If the platform configuration is missing, then the function fills in a - default state. - - @param[out] MainFormState Binary form/widget state after translation. - - @retval EFI_SUCCESS Form/widget state ready. - @return Error codes from underlying functions. -**/ -STATIC -EFI_STATUS -EFIAPI -PlatformConfigToFormState ( - OUT MAIN_FORM_STATE *MainFormState - ) -{ - EFI_STATUS Status; - PLATFORM_CONFIG PlatformConfig; - UINT64 OptionalElements; - UINTN ModeNumber; - - ZeroMem (MainFormState, sizeof *MainFormState); - - Status = PlatformConfigLoad (&PlatformConfig, &OptionalElements); - switch (Status) { - case EFI_SUCCESS: - if (OptionalElements & PLATFORM_CONFIG_F_GRAPHICS_RESOLUTION) { - // - // Format the preferred resolution as text. - // - UnicodeSPrintAsciiFormat ( - (CHAR16 *) MainFormState->CurrentPreferredResolution, - sizeof MainFormState->CurrentPreferredResolution, - "%Ldx%Ld", - (INT64) PlatformConfig.HorizontalResolution, - (INT64) PlatformConfig.VerticalResolution); - - // - // Try to locate it in the drop-down list too. This may not succeed, but - // that's fine. - // - for (ModeNumber = 0; ModeNumber < mNumGopModes; ++ModeNumber) { - if (mGopModes[ModeNumber].X == PlatformConfig.HorizontalResolution && - mGopModes[ModeNumber].Y == PlatformConfig.VerticalResolution) { - MainFormState->NextPreferredResolution = (UINT32) ModeNumber; - break; - } - } - - break; - } - // - // fall through otherwise - // - - case EFI_NOT_FOUND: - UnicodeSPrintAsciiFormat ( - (CHAR16 *) MainFormState->CurrentPreferredResolution, - sizeof MainFormState->CurrentPreferredResolution, - "Unset"); - break; - - default: - return Status; - } - - return EFI_SUCCESS; -} - - -/** - This function is called by the HII machinery when it fetches the form state. - - See the precise documentation in the UEFI spec. - - @param[in] This The Config Access Protocol instance. - - @param[in] Request A format UCS-2 string describing the - query. - - @param[out] Progress A pointer into Request on output, identifying the query - element where processing failed. - - @param[out] Results A format UCS-2 string that has - all values filled in for the names in the Request - string. - - @retval EFI_SUCCESS Extraction of form state in - encoding successful. - @return Status codes from underlying functions. - -**/ -STATIC -EFI_STATUS -EFIAPI -ExtractConfig ( - IN CONST EFI_HII_CONFIG_ACCESS_PROTOCOL *This, - IN CONST EFI_STRING Request, - OUT EFI_STRING *Progress, - OUT EFI_STRING *Results -) -{ - MAIN_FORM_STATE MainFormState; - EFI_STATUS Status; - - DEBUG ((EFI_D_VERBOSE, "%a: Request=\"%s\"\n", __FUNCTION__, Request)); - - Status = PlatformConfigToFormState (&MainFormState); - if (EFI_ERROR (Status)) { - *Progress = Request; - return Status; - } - - // - // Answer the textual request keying off the binary form state. - // - Status = gHiiConfigRouting->BlockToConfig (gHiiConfigRouting, Request, - (VOID *) &MainFormState, sizeof MainFormState, - Results, Progress); - if (EFI_ERROR (Status)) { - DEBUG ((EFI_D_ERROR, "%a: BlockToConfig(): %r, Progress=\"%s\"\n", - __FUNCTION__, Status, (Status == EFI_DEVICE_ERROR) ? NULL : *Progress)); - } else { - DEBUG ((EFI_D_VERBOSE, "%a: Results=\"%s\"\n", __FUNCTION__, *Results)); - } - return Status; -} - - -/** - Interpret the binary form state and save it as persistent platform - configuration. - - @param[in] MainFormState Binary form/widget state to verify and save. - - @retval EFI_SUCCESS Platform configuration saved. - @return Error codes from underlying functions. -**/ -STATIC -EFI_STATUS -EFIAPI -FormStateToPlatformConfig ( - IN CONST MAIN_FORM_STATE *MainFormState - ) -{ - EFI_STATUS Status; - PLATFORM_CONFIG PlatformConfig; - CONST GOP_MODE *GopMode; - - // - // There's nothing to do with the textual CurrentPreferredResolution field. - // We verify and translate the selection in the drop-down list. - // - if (MainFormState->NextPreferredResolution >= mNumGopModes) { - return EFI_INVALID_PARAMETER; - } - GopMode = mGopModes + MainFormState->NextPreferredResolution; - - ZeroMem (&PlatformConfig, sizeof PlatformConfig); - PlatformConfig.HorizontalResolution = GopMode->X; - PlatformConfig.VerticalResolution = GopMode->Y; - - Status = PlatformConfigSave (&PlatformConfig); - return Status; -} - - -/** - This function is called by the HII machinery when it wants the driver to - interpret and persist the form state. - - See the precise documentation in the UEFI spec. - - @param[in] This The Config Access Protocol instance. - - @param[in] Configuration A format UCS-2 string describing the - form state. - - @param[out] Progress A pointer into Configuration on output, - identifying the element where processing failed. - - @retval EFI_SUCCESS Configuration verified, state permanent. - - @return Status codes from underlying functions. -**/ -STATIC -EFI_STATUS -EFIAPI -RouteConfig ( - IN CONST EFI_HII_CONFIG_ACCESS_PROTOCOL *This, - IN CONST EFI_STRING Configuration, - OUT EFI_STRING *Progress -) -{ - MAIN_FORM_STATE MainFormState; - UINTN BlockSize; - EFI_STATUS Status; - - DEBUG ((EFI_D_VERBOSE, "%a: Configuration=\"%s\"\n", __FUNCTION__, - Configuration)); - - // - // the "read" step in RMW - // - Status = PlatformConfigToFormState (&MainFormState); - if (EFI_ERROR (Status)) { - *Progress = Configuration; - return Status; - } - - // - // the "modify" step in RMW - // - // (Update the binary form state. This update may be partial, which is why in - // general we must pre-load the form state from the platform config.) - // - BlockSize = sizeof MainFormState; - Status = gHiiConfigRouting->ConfigToBlock (gHiiConfigRouting, Configuration, - (VOID *) &MainFormState, &BlockSize, Progress); - if (EFI_ERROR (Status)) { - DEBUG ((EFI_D_ERROR, "%a: ConfigToBlock(): %r, Progress=\"%s\"\n", - __FUNCTION__, Status, - (Status == EFI_BUFFER_TOO_SMALL) ? NULL : *Progress)); - return Status; - } - - // - // the "write" step in RMW - // - Status = FormStateToPlatformConfig (&MainFormState); - if (EFI_ERROR (Status)) { - *Progress = Configuration; - } - return Status; -} - - -STATIC -EFI_STATUS -EFIAPI -Callback ( - IN CONST EFI_HII_CONFIG_ACCESS_PROTOCOL *This, - IN EFI_BROWSER_ACTION Action, - IN EFI_QUESTION_ID QuestionId, - IN UINT8 Type, - IN OUT EFI_IFR_TYPE_VALUE *Value, - OUT EFI_BROWSER_ACTION_REQUEST *ActionRequest - ) -{ - DEBUG ((EFI_D_VERBOSE, "%a: Action=0x%Lx QuestionId=%d Type=%d\n", - __FUNCTION__, (UINT64) Action, QuestionId, Type)); - - if (Action != EFI_BROWSER_ACTION_CHANGED) { - return EFI_UNSUPPORTED; - } - - switch (QuestionId) { - case QUESTION_SAVE_EXIT: - *ActionRequest = EFI_BROWSER_ACTION_REQUEST_FORM_SUBMIT_EXIT; - break; - - case QUESTION_DISCARD_EXIT: - *ActionRequest = EFI_BROWSER_ACTION_REQUEST_FORM_DISCARD_EXIT; - break; - - default: - break; - } - - return EFI_SUCCESS; -} - - -/** - Query and save all resolutions supported by the GOP. - - @param[in] Gop The Graphics Output Protocol instance to query. - - @param[out] NumGopModes The number of modes supported by the GOP. On output, - this parameter will be positive. - - @param[out] GopModes On output, a dynamically allocated array containing - the resolutions returned by the GOP. The caller is - responsible for freeing the array after use. - - @retval EFI_UNSUPPORTED No modes found. - @retval EFI_OUT_OF_RESOURCES Failed to allocate GopModes. - @return Error codes from Gop->QueryMode(). - -**/ -STATIC -EFI_STATUS -EFIAPI -QueryGopModes ( - IN EFI_GRAPHICS_OUTPUT_PROTOCOL *Gop, - OUT UINTN *NumGopModes, - OUT GOP_MODE **GopModes - ) -{ - EFI_STATUS Status; - UINT32 ModeNumber; - - if (Gop->Mode->MaxMode == 0) { - return EFI_UNSUPPORTED; - } - *NumGopModes = Gop->Mode->MaxMode; - - *GopModes = AllocatePool (Gop->Mode->MaxMode * sizeof **GopModes); - if (*GopModes == NULL) { - return EFI_OUT_OF_RESOURCES; - } - - for (ModeNumber = 0; ModeNumber < Gop->Mode->MaxMode; ++ModeNumber) { - EFI_GRAPHICS_OUTPUT_MODE_INFORMATION *Info; - UINTN SizeOfInfo; - - Status = Gop->QueryMode (Gop, ModeNumber, &SizeOfInfo, &Info); - if (EFI_ERROR (Status)) { - goto FreeGopModes; - } - - (*GopModes)[ModeNumber].X = Info->HorizontalResolution; - (*GopModes)[ModeNumber].Y = Info->VerticalResolution; - FreePool (Info); - } - - return EFI_SUCCESS; - -FreeGopModes: - FreePool (*GopModes); - - return Status; -} - - -/** - Create a set of "one-of-many" (ie. "drop down list") option IFR opcodes, - based on available GOP resolutions, to be placed under a "one-of-many" (ie. - "drop down list") opcode. - - @param[in] PackageList The package list with the formset and form for - which the drop down options are produced. Option - names are added as new strings to PackageList. - - @param[out] OpCodeBuffer On output, a dynamically allocated opcode buffer - with drop down list options corresponding to GOP - resolutions. The caller is responsible for freeing - OpCodeBuffer with HiiFreeOpCodeHandle() after use. - - @param[in] NumGopModes Number of entries in GopModes. - - @param[in] GopModes Array of resolutions retrieved from the GOP. - - @retval EFI_SUCESS Opcodes have been successfully produced. - - @return Status codes from underlying functions. PackageList may - have been extended with new strings. OpCodeBuffer is - unchanged. -**/ -STATIC -EFI_STATUS -EFIAPI -CreateResolutionOptions ( - IN EFI_HII_HANDLE *PackageList, - OUT VOID **OpCodeBuffer, - IN UINTN NumGopModes, - IN GOP_MODE *GopModes - ) -{ - EFI_STATUS Status; - VOID *OutputBuffer; - UINTN ModeNumber; - - OutputBuffer = HiiAllocateOpCodeHandle (); - if (OutputBuffer == NULL) { - return EFI_OUT_OF_RESOURCES; - } - - for (ModeNumber = 0; ModeNumber < NumGopModes; ++ModeNumber) { - CHAR16 Desc[MAXSIZE_RES_CUR]; - EFI_STRING_ID NewString; - VOID *OpCode; - - UnicodeSPrintAsciiFormat (Desc, sizeof Desc, "%Ldx%Ld", - (INT64) GopModes[ModeNumber].X, (INT64) GopModes[ModeNumber].Y); - NewString = HiiSetString (PackageList, 0 /* new string */, Desc, - NULL /* for all languages */); - if (NewString == 0) { - Status = EFI_OUT_OF_RESOURCES; - goto FreeOutputBuffer; - } - OpCode = HiiCreateOneOfOptionOpCode (OutputBuffer, NewString, - 0 /* Flags */, EFI_IFR_NUMERIC_SIZE_4, ModeNumber); - if (OpCode == NULL) { - Status = EFI_OUT_OF_RESOURCES; - goto FreeOutputBuffer; - } - } - - *OpCodeBuffer = OutputBuffer; - return EFI_SUCCESS; - -FreeOutputBuffer: - HiiFreeOpCodeHandle (OutputBuffer); - - return Status; -} - - -/** - Populate the form identified by the (PackageList, FormSetGuid, FormId) - triplet. - - The drop down list of video resolutions is generated from (NumGopModes, - GopModes). - - @retval EFI_SUCESS Form successfully updated. - @return Status codes from underlying functions. - -**/ -STATIC -EFI_STATUS -EFIAPI -PopulateForm ( - IN EFI_HII_HANDLE *PackageList, - IN EFI_GUID *FormSetGuid, - IN EFI_FORM_ID FormId, - IN UINTN NumGopModes, - IN GOP_MODE *GopModes - ) -{ - EFI_STATUS Status; - VOID *OpCodeBuffer; - VOID *OpCode; - EFI_IFR_GUID_LABEL *Anchor; - VOID *OpCodeBuffer2; - - OpCodeBuffer2 = NULL; - - // - // 1. Allocate an empty opcode buffer. - // - OpCodeBuffer = HiiAllocateOpCodeHandle (); - if (OpCodeBuffer == NULL) { - return EFI_OUT_OF_RESOURCES; - } - - // - // 2. Create a label opcode (which is a Tiano extension) inside the buffer. - // The label's number must match the "anchor" label in the form. - // - OpCode = HiiCreateGuidOpCode (OpCodeBuffer, &gEfiIfrTianoGuid, - NULL /* optional copy origin */, sizeof *Anchor); - if (OpCode == NULL) { - Status = EFI_OUT_OF_RESOURCES; - goto FreeOpCodeBuffer; - } - Anchor = OpCode; - Anchor->ExtendOpCode = EFI_IFR_EXTEND_OP_LABEL; - Anchor->Number = LABEL_RES_NEXT; - - // - // 3. Create the opcodes inside the buffer that are to be inserted into the - // form. - // - // 3.1. Get a list of resolutions. - // - Status = CreateResolutionOptions (PackageList, &OpCodeBuffer2, - NumGopModes, GopModes); - if (EFI_ERROR (Status)) { - goto FreeOpCodeBuffer; - } - - // - // 3.2. Create a one-of-many question with the above options. - // - OpCode = HiiCreateOneOfOpCode ( - OpCodeBuffer, // create opcode inside this - // opcode buffer, - QUESTION_RES_NEXT, // ID of question, - FORMSTATEID_MAIN_FORM, // identifies form state - // storage, - (UINT16) OFFSET_OF (MAIN_FORM_STATE, // value of question stored - NextPreferredResolution), // at this offset, - STRING_TOKEN (STR_RES_NEXT), // Prompt, - STRING_TOKEN (STR_RES_NEXT_HELP), // Help, - 0, // QuestionFlags, - EFI_IFR_NUMERIC_SIZE_4, // see sizeof - // NextPreferredResolution, - OpCodeBuffer2, // buffer with possible - // choices, - NULL // DEFAULT opcodes - ); - if (OpCode == NULL) { - Status = EFI_OUT_OF_RESOURCES; - goto FreeOpCodeBuffer2; - } - - // - // 4. Update the form with the opcode buffer. - // - Status = HiiUpdateForm (PackageList, FormSetGuid, FormId, - OpCodeBuffer, // buffer with head anchor, and new contents to be - // inserted at it - NULL // buffer with tail anchor, for deleting old - // contents up to it - ); - -FreeOpCodeBuffer2: - HiiFreeOpCodeHandle (OpCodeBuffer2); - -FreeOpCodeBuffer: - HiiFreeOpCodeHandle (OpCodeBuffer); - - return Status; -} - - -/** - Load and execute the platform configuration. - - @retval EFI_SUCCESS Configuration loaded and executed. - @return Status codes from PlatformConfigLoad(). -**/ -STATIC -EFI_STATUS -EFIAPI -ExecutePlatformConfig ( - VOID - ) -{ - EFI_STATUS Status; - PLATFORM_CONFIG PlatformConfig; - UINT64 OptionalElements; - RETURN_STATUS PcdStatus; - - Status = PlatformConfigLoad (&PlatformConfig, &OptionalElements); - if (EFI_ERROR (Status)) { - DEBUG (((Status == EFI_NOT_FOUND) ? EFI_D_VERBOSE : EFI_D_ERROR, - "%a: failed to load platform config: %r\n", __FUNCTION__, Status)); - return Status; - } - - if (OptionalElements & PLATFORM_CONFIG_F_GRAPHICS_RESOLUTION) { - // - // Pass the preferred resolution to GraphicsConsoleDxe via dynamic PCDs. - // - PcdStatus = PcdSet32S (PcdVideoHorizontalResolution, - PlatformConfig.HorizontalResolution); - ASSERT_RETURN_ERROR (PcdStatus); - - PcdStatus = PcdSet32S (PcdVideoVerticalResolution, - PlatformConfig.VerticalResolution); - ASSERT_RETURN_ERROR (PcdStatus); - } - - return EFI_SUCCESS; -} - - -/** - Notification callback for GOP interface installation. - - @param[in] Event Event whose notification function is being invoked. - - @param[in] Context The pointer to the notification function's context, which - is implementation-dependent. -**/ -STATIC -VOID -EFIAPI -GopInstalled ( - IN EFI_EVENT Event, - IN VOID *Context - ) -{ - EFI_STATUS Status; - EFI_GRAPHICS_OUTPUT_PROTOCOL *Gop; - - ASSERT (Event == mGopEvent); - - // - // Check further GOPs. - // - for (;;) { - mNumGopModes = 0; - mGopModes = NULL; - - Status = gBS->LocateProtocol (&gEfiGraphicsOutputProtocolGuid, mGopTracker, - (VOID **) &Gop); - if (EFI_ERROR (Status)) { - return; - } - - Status = QueryGopModes (Gop, &mNumGopModes, &mGopModes); - if (EFI_ERROR (Status)) { - continue; - } - - Status = PopulateForm (mInstalledPackages, &gOvmfPlatformConfigGuid, - FORMID_MAIN_FORM, mNumGopModes, mGopModes); - if (EFI_ERROR (Status)) { - FreePool (mGopModes); - continue; - } - - break; - } - - // - // Success -- so uninstall this callback. Closing the event removes all - // pending notifications and all protocol registrations. - // - Status = gBS->CloseEvent (mGopEvent); - ASSERT_EFI_ERROR (Status); - mGopEvent = NULL; - mGopTracker = NULL; -} - - -/** - Entry point for this driver. - - @param[in] ImageHandle Image handle of this driver. - @param[in] SystemTable Pointer to SystemTable. - - @retval EFI_SUCESS Driver has loaded successfully. - @retval EFI_OUT_OF_RESOURCES Failed to install HII packages. - @return Error codes from lower level functions. - -**/ -EFI_STATUS -EFIAPI -PlatformInit ( - IN EFI_HANDLE ImageHandle, - IN EFI_SYSTEM_TABLE *SystemTable - ) -{ - EFI_STATUS Status; - - ExecutePlatformConfig (); - - mConfigAccess.ExtractConfig = &ExtractConfig; - mConfigAccess.RouteConfig = &RouteConfig; - mConfigAccess.Callback = &Callback; - - // - // Declare ourselves suitable for HII communication. - // - Status = gBS->InstallMultipleProtocolInterfaces (&ImageHandle, - &gEfiDevicePathProtocolGuid, &mPkgDevicePath, - &gEfiHiiConfigAccessProtocolGuid, &mConfigAccess, - NULL); - if (EFI_ERROR (Status)) { - return Status; - } - - // - // Publish the HII package list to HII Database. - // - mInstalledPackages = HiiAddPackages ( - &gEfiCallerIdGuid, // PackageListGuid - ImageHandle, // associated DeviceHandle - PlatformDxeStrings, // 1st package - PlatformFormsBin, // 2nd package - NULL // terminator - ); - if (mInstalledPackages == NULL) { - Status = EFI_OUT_OF_RESOURCES; - goto UninstallProtocols; - } - - Status = gBS->CreateEvent (EVT_NOTIFY_SIGNAL, TPL_CALLBACK, &GopInstalled, - NULL /* Context */, &mGopEvent); - if (EFI_ERROR (Status)) { - goto RemovePackages; - } - - Status = gBS->RegisterProtocolNotify (&gEfiGraphicsOutputProtocolGuid, - mGopEvent, &mGopTracker); - if (EFI_ERROR (Status)) { - goto CloseGopEvent; - } - - // - // Check already installed GOPs. - // - Status = gBS->SignalEvent (mGopEvent); - ASSERT_EFI_ERROR (Status); - - return EFI_SUCCESS; - -CloseGopEvent: - gBS->CloseEvent (mGopEvent); - -RemovePackages: - HiiRemovePackages (mInstalledPackages); - -UninstallProtocols: - gBS->UninstallMultipleProtocolInterfaces (ImageHandle, - &gEfiDevicePathProtocolGuid, &mPkgDevicePath, - &gEfiHiiConfigAccessProtocolGuid, &mConfigAccess, - NULL); - return Status; -} - -/** - Unload the driver. - - @param[in] ImageHandle Handle that identifies the image to evict. - - @retval EFI_SUCCESS The image has been unloaded. -**/ -EFI_STATUS -EFIAPI -PlatformUnload ( - IN EFI_HANDLE ImageHandle - ) -{ - if (mGopEvent == NULL) { - // - // The GOP callback ran successfully and unregistered itself. Release the - // resources allocated there. - // - ASSERT (mGopModes != NULL); - FreePool (mGopModes); - } else { - // - // Otherwise we need to unregister the callback. - // - ASSERT (mGopModes == NULL); - gBS->CloseEvent (mGopEvent); - } - - // - // Release resources allocated by the entry point. - // - HiiRemovePackages (mInstalledPackages); - gBS->UninstallMultipleProtocolInterfaces (ImageHandle, - &gEfiDevicePathProtocolGuid, &mPkgDevicePath, - &gEfiHiiConfigAccessProtocolGuid, &mConfigAccess, - NULL); - return EFI_SUCCESS; -} diff --git a/OvmfPkg/PlatformDxe/Platform.h b/OvmfPkg/PlatformDxe/Platform.h deleted file mode 100644 index 432eb5bc23..0000000000 --- a/OvmfPkg/PlatformDxe/Platform.h +++ /dev/null @@ -1,43 +0,0 @@ -/** @file - This driver effectuates OVMF's platform configuration settings and exposes - them via HII. - - Copyright (C) 2014, 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 _PLATFORM_H_ -#define _PLATFORM_H_ - -// -// Macro and type definitions that connect the form with the HII driver code. -// -#define FORMSTATEID_MAIN_FORM 1 -#define FORMID_MAIN_FORM 1 - -#define QUESTION_RES_CUR 1 -#define MAXSIZE_RES_CUR 16 - -#define LABEL_RES_NEXT 1 -#define QUESTION_RES_NEXT 2 - -#define QUESTION_SAVE_EXIT 3 -#define QUESTION_DISCARD_EXIT 4 - -// -// This structure describes the form state. Its fields relate strictly to the -// visual widgets on the form. -// -typedef struct { - UINT16 CurrentPreferredResolution[MAXSIZE_RES_CUR]; - UINT32 NextPreferredResolution; -} MAIN_FORM_STATE; - -#endif // _PLATFORM_H_ diff --git a/OvmfPkg/PlatformDxe/Platform.inf b/OvmfPkg/PlatformDxe/Platform.inf deleted file mode 100644 index 16cd9ab753..0000000000 --- a/OvmfPkg/PlatformDxe/Platform.inf +++ /dev/null @@ -1,69 +0,0 @@ -## @file -# This driver effectuates OVMF's platform configuration settings and exposes -# them via HII. -# -# Copyright (C) 2014, Red Hat, Inc. -# Copyright (c) 2009 - 2010, Intel Corporation. All rights reserved.
-# -# This program and the accompanying materials are licensed and made available -# under the terms and conditions of the BSD License which accompanies this -# distribution. The full text of the license may be found at -# http://opensource.org/licenses/bsd-license.php -# -# THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, -# WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR -# IMPLIED. -## - -[Defines] - INF_VERSION = 0x00010005 - BASE_NAME = PlatformDxe - FILE_GUID = D9DCC5DF-4007-435E-9098-8970935504B2 - MODULE_TYPE = DXE_DRIVER - VERSION_STRING = 1.0 - ENTRY_POINT = PlatformInit - UNLOAD_IMAGE = PlatformUnload - -[Sources] - Platform.c - Platform.uni - PlatformConfig.c - PlatformForms.vfr - -[Packages] - MdePkg/MdePkg.dec - MdeModulePkg/MdeModulePkg.dec - OvmfPkg/OvmfPkg.dec - -[LibraryClasses] - BaseLib - BaseMemoryLib - DebugLib - DevicePathLib - HiiLib - MemoryAllocationLib - PrintLib - UefiBootServicesTableLib - UefiHiiServicesLib - UefiLib - UefiRuntimeServicesTableLib - UefiDriverEntryPoint - -[Pcd] - gEfiMdeModulePkgTokenSpaceGuid.PcdVideoHorizontalResolution - gEfiMdeModulePkgTokenSpaceGuid.PcdVideoVerticalResolution - -[Protocols] - gEfiDevicePathProtocolGuid ## PRODUCES - gEfiGraphicsOutputProtocolGuid ## CONSUMES - gEfiHiiConfigAccessProtocolGuid ## PRODUCES - -[Guids] - gEfiIfrTianoGuid - gOvmfPlatformConfigGuid - -[Depex] - gEfiHiiConfigRoutingProtocolGuid AND - gEfiHiiDatabaseProtocolGuid AND - gEfiVariableArchProtocolGuid AND - gEfiVariableWriteArchProtocolGuid diff --git a/OvmfPkg/PlatformDxe/Platform.uni b/OvmfPkg/PlatformDxe/Platform.uni deleted file mode 100644 index 6df865519f..0000000000 --- a/OvmfPkg/PlatformDxe/Platform.uni +++ /dev/null @@ -1,38 +0,0 @@ -// *++ -// -// Copyright (C) 2014, Red Hat, Inc. -// Copyright (c) 2009, Intel Corporation. All rights reserved.
-// -// This program and the accompanying materials are licensed and made available -// under the terms and conditions of the BSD License which accompanies this -// distribution. The full text of the license may be found at -// http://opensource.org/licenses/bsd-license.php -// -// THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, -// WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR -// IMPLIED. -// -// Module Name: -// -// Platform.uni -// -// Abstract: -// -// String definitions for PlatformForms.vfr -// -// --*/ - -/=# - -#langdef en-US "English" - -#string STR_FORMSET_TITLE #language en-US "OVMF Platform Configuration" -#string STR_FORMSET_HELP #language en-US "Change various OVMF platform settings." -#string STR_MAIN_FORM_TITLE #language en-US "OVMF Settings" -#string STR_RES_CUR #language en-US "Preferred Resolution at Next Boot" -#string STR_RES_CUR_HELP #language en-US "The preferred resolution of the Graphics Console at next boot. It might be unset, or even invalid (hence ignored) wrt. the video RAM size." -#string STR_RES_NEXT #language en-US "Change Preferred Resolution for Next Boot" -#string STR_RES_NEXT_HELP #language en-US "You can specify a new preference for the Graphics Console here. The list is filtered against the video RAM size." -#string STR_SAVE_EXIT #language en-US "Commit Changes and Exit" -#string STR_DISCARD_EXIT #language en-US "Discard Changes and Exit" - diff --git a/OvmfPkg/PlatformDxe/PlatformConfig.c b/OvmfPkg/PlatformDxe/PlatformConfig.c deleted file mode 100644 index 3468f88150..0000000000 --- a/OvmfPkg/PlatformDxe/PlatformConfig.c +++ /dev/null @@ -1,131 +0,0 @@ -/** @file - - Utility functions for serializing (persistently storing) and deserializing - OVMF's platform configuration. - - Copyright (C) 2014, 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 -#include -#include -#include -#include -#include - -#include "PlatformConfig.h" - -// -// Name of the UEFI variable that we use for persistent storage. -// -STATIC CHAR16 mVariableName[] = L"PlatformConfig"; - - -/** - Serialize and persistently save platform configuration. - - @param[in] PlatformConfig The platform configuration to serialize and save. - - @return Status codes returned by gRT->SetVariable(). -**/ -EFI_STATUS -EFIAPI -PlatformConfigSave ( - IN PLATFORM_CONFIG *PlatformConfig - ) -{ - EFI_STATUS Status; - - // - // We could implement any kind of translation here, as part of serialization. - // For example, we could expose the platform configuration in separate - // variables with human-readable contents, allowing other tools to access - // them more easily. For now, just save a binary dump. - // - Status = gRT->SetVariable (mVariableName, &gOvmfPlatformConfigGuid, - EFI_VARIABLE_NON_VOLATILE | EFI_VARIABLE_BOOTSERVICE_ACCESS | - EFI_VARIABLE_RUNTIME_ACCESS, - sizeof *PlatformConfig, PlatformConfig); - return Status; -} - - -/** - Load and deserialize platform configuration. - - When the function fails, output parameters are indeterminate. - - @param[out] PlatformConfig The platform configuration to receive the - loaded data. - - @param[out] OptionalElements This bitmap describes the presence of optional - configuration elements that have been loaded. - PLATFORM_CONFIG_F_DOWNGRADE means that some - unknown elements, present in the wire format, - have been ignored. - - @retval EFI_SUCCESS Loading & deserialization successful. - @return Error codes returned by GetVariable2(). -**/ -EFI_STATUS -EFIAPI -PlatformConfigLoad ( - OUT PLATFORM_CONFIG *PlatformConfig, - OUT UINT64 *OptionalElements - ) -{ - VOID *Data; - UINTN DataSize; - EFI_STATUS Status; - - // - // Any translation done in PlatformConfigSave() would have to be mirrored - // here. For now, just load the binary dump. - // - // Versioning of the binary wire format is implemented based on size - // (only incremental changes, ie. new fields), and on GUID. - // (Incompatible changes require a GUID change.) - // - Status = GetVariable2 (mVariableName, &gOvmfPlatformConfigGuid, &Data, - &DataSize); - if (EFI_ERROR (Status)) { - return Status; - } - - *OptionalElements = 0; - if (DataSize > sizeof *PlatformConfig) { - // - // Handle firmware downgrade -- keep only leading part. - // - CopyMem (PlatformConfig, Data, sizeof *PlatformConfig); - *OptionalElements |= PLATFORM_CONFIG_F_DOWNGRADE; - } else { - CopyMem (PlatformConfig, Data, DataSize); - - // - // Handle firmware upgrade -- zero out missing fields. - // - ZeroMem ((UINT8 *)PlatformConfig + DataSize, - sizeof *PlatformConfig - DataSize); - } - - // - // Based on DataSize, report the optional features that we recognize. - // - if (DataSize >= (OFFSET_OF (PLATFORM_CONFIG, VerticalResolution) + - sizeof PlatformConfig->VerticalResolution)) { - *OptionalElements |= PLATFORM_CONFIG_F_GRAPHICS_RESOLUTION; - } - - FreePool (Data); - return EFI_SUCCESS; -} diff --git a/OvmfPkg/PlatformDxe/PlatformConfig.h b/OvmfPkg/PlatformDxe/PlatformConfig.h deleted file mode 100644 index 3fd6982566..0000000000 --- a/OvmfPkg/PlatformDxe/PlatformConfig.h +++ /dev/null @@ -1,59 +0,0 @@ -/** @file - - Utility functions for serializing (persistently storing) and deserializing - OVMF's platform configuration. - - Copyright (C) 2014, 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 _PLATFORM_CONFIG_H_ -#define _PLATFORM_CONFIG_H_ - -#include - -// -// This structure participates in driver configuration. It does not -// (necessarily) reflect the wire format in the persistent store. -// -#pragma pack(1) -typedef struct { - // - // preferred graphics console resolution when booting - // - UINT32 HorizontalResolution; - UINT32 VerticalResolution; -} PLATFORM_CONFIG; -#pragma pack() - -// -// Please see the API documentation near the function definitions. -// -EFI_STATUS -EFIAPI -PlatformConfigSave ( - IN PLATFORM_CONFIG *PlatformConfig - ); - -EFI_STATUS -EFIAPI -PlatformConfigLoad ( - OUT PLATFORM_CONFIG *PlatformConfig, - OUT UINT64 *OptionalElements - ); - -// -// Feature flags for OptionalElements. -// -#define PLATFORM_CONFIG_F_GRAPHICS_RESOLUTION BIT0 -#define PLATFORM_CONFIG_F_DOWNGRADE BIT63 - -#endif // _PLATFORM_CONFIG_H_ diff --git a/OvmfPkg/PlatformDxe/PlatformForms.vfr b/OvmfPkg/PlatformDxe/PlatformForms.vfr deleted file mode 100644 index a254572baf..0000000000 --- a/OvmfPkg/PlatformDxe/PlatformForms.vfr +++ /dev/null @@ -1,74 +0,0 @@ -// *++ -// -// Copyright (C) 2014, Red Hat, Inc. -// Copyright (c) 2009 - 2011, Intel Corporation. All rights reserved.
-// -// This program and the accompanying materials are licensed and made available -// under the terms and conditions of the BSD License which accompanies this -// distribution. The full text of the license may be found at -// http://opensource.org/licenses/bsd-license.php -// -// THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, -// WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR -// IMPLIED. -// -// Module Name: -// -// PlatformForms.vfr -// -// Abstract: -// -// Form definitions for exposing some of OVMF's platform knobs via HII. -// -// --*/ - -#include -#include "Platform.h" - -formset - guid = OVMF_PLATFORM_CONFIG_GUID, - title = STRING_TOKEN(STR_FORMSET_TITLE), - help = STRING_TOKEN(STR_FORMSET_HELP), - - varstore MAIN_FORM_STATE, - varid = FORMSTATEID_MAIN_FORM, - name = MainFormState, - guid = OVMF_PLATFORM_CONFIG_GUID; - - form - formid = FORMID_MAIN_FORM, - title = STRING_TOKEN(STR_MAIN_FORM_TITLE); - - // - // Display the current preference in a read-only string field. - // - string - varid = MainFormState.CurrentPreferredResolution, - questionid = QUESTION_RES_CUR, - prompt = STRING_TOKEN(STR_RES_CUR), - help = STRING_TOKEN(STR_RES_CUR_HELP), - flags = READ_ONLY, - minsize = 0, - maxsize = MAXSIZE_RES_CUR, - endstring; - - // - // We'll dynamically generate a one-of-many selection at this label. - // - label LABEL_RES_NEXT; - - text - help = STRING_TOKEN(STR_SAVE_EXIT), - text = STRING_TOKEN(STR_SAVE_EXIT), - flags = INTERACTIVE, - key = QUESTION_SAVE_EXIT; - - text - help = STRING_TOKEN(STR_DISCARD_EXIT), - text = STRING_TOKEN(STR_DISCARD_EXIT), - flags = INTERACTIVE, - key = QUESTION_DISCARD_EXIT; - - endform; - -endformset; diff --git a/OvmfPkg/PlatformPei/Cmos.c b/OvmfPkg/PlatformPei/Cmos.c deleted file mode 100644 index 48ed2cb8f4..0000000000 --- a/OvmfPkg/PlatformPei/Cmos.c +++ /dev/null @@ -1,64 +0,0 @@ -/** @file - PC/AT CMOS access routines - - Copyright (c) 2006 - 2009, Intel Corporation. All rights reserved.
- This program and the accompanying materials - are licensed and made available under the terms and conditions of the BSD License - which accompanies this distribution. The full text of the license may be found at - http://opensource.org/licenses/bsd-license.php - - THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, - WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. - -**/ - - -#include "Cmos.h" -#include "Library/IoLib.h" - -/** - Reads 8-bits of CMOS data. - - Reads the 8-bits of CMOS data at the location specified by Index. - The 8-bit read value is returned. - - @param Index The CMOS location to read. - - @return The value read. - -**/ -UINT8 -EFIAPI -CmosRead8 ( - IN UINTN Index - ) -{ - IoWrite8 (0x70, (UINT8) Index); - return IoRead8 (0x71); -} - - -/** - Writes 8-bits of CMOS data. - - Writes 8-bits of CMOS data to the location specified by Index - with the value specified by Value and returns Value. - - @param Index The CMOS location to write. - @param Value The value to write to CMOS. - - @return The value written to CMOS. - -**/ -UINT8 -EFIAPI -CmosWrite8 ( - IN UINTN Index, - IN UINT8 Value - ) -{ - IoWrite8 (0x70, (UINT8) Index); - IoWrite8 (0x71, Value); - return Value; -} - diff --git a/OvmfPkg/PlatformPei/Cmos.h b/OvmfPkg/PlatformPei/Cmos.h deleted file mode 100644 index 949f884c2c..0000000000 --- a/OvmfPkg/PlatformPei/Cmos.h +++ /dev/null @@ -1,56 +0,0 @@ -/** @file - PC/AT CMOS access routines - - Copyright (c) 2006 - 2009, Intel Corporation. All rights reserved.
- This program and the accompanying materials - are licensed and made available under the terms and conditions of the BSD License - which accompanies this distribution. The full text of the license may be found at - http://opensource.org/licenses/bsd-license.php - - THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, - WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. - -**/ - -#ifndef __CMOS_H__ -#define __CMOS_H__ - -/** - Reads 8-bits of CMOS data. - - Reads the 8-bits of CMOS data at the location specified by Index. - The 8-bit read value is returned. - - @param Index The CMOS location to read. - - @return The value read. - -**/ -UINT8 -EFIAPI -CmosRead8 ( - IN UINTN Index - ); - -/** - Writes 8-bits of CMOS data. - - Writes 8-bits of CMOS data to the location specified by Index - with the value specified by Value and returns Value. - - @param Index The CMOS location to write. - @param Value The value to write to CMOS. - - @return The value written to CMOS. - -**/ -UINT8 -EFIAPI -CmosWrite8 ( - IN UINTN Index, - IN UINT8 Value - ); - - -#endif - diff --git a/OvmfPkg/PlatformPei/FeatureControl.c b/OvmfPkg/PlatformPei/FeatureControl.c deleted file mode 100644 index b91d9888a9..0000000000 --- a/OvmfPkg/PlatformPei/FeatureControl.c +++ /dev/null @@ -1,134 +0,0 @@ -/**@file - Install a callback when necessary for setting the Feature Control MSR on all - processors. - - Copyright (C) 2016, 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 -#include -#include -#include -#include - -#include "Platform.h" - -// -// The value to be written to the Feature Control MSR, retrieved from fw_cfg. -// -STATIC UINT64 mFeatureControlValue; - -/** - Write the Feature Control MSR on an Application Processor or the Boot - Processor. - - All APs execute this function in parallel. The BSP executes the function - separately. - - @param[in,out] WorkSpace Pointer to the input/output argument workspace - shared by all processors. -**/ -STATIC -VOID -EFIAPI -WriteFeatureControl ( - IN OUT VOID *WorkSpace - ) -{ - AsmWriteMsr64 (MSR_CORE2_FEATURE_CONTROL, mFeatureControlValue); -} - -/** - Notification function called when EFI_PEI_MP_SERVICES_PPI becomes available. - - @param[in] PeiServices Indirect reference to the PEI Services Table. - @param[in] NotifyDescriptor Address of the notification descriptor data - structure. - @param[in] Ppi Address of the PPI that was installed. - - @return Status of the notification. The status code returned from this - function is ignored. -**/ -STATIC -EFI_STATUS -EFIAPI -OnMpServicesAvailable ( - IN EFI_PEI_SERVICES **PeiServices, - IN EFI_PEI_NOTIFY_DESCRIPTOR *NotifyDescriptor, - IN VOID *Ppi - ) -{ - EFI_PEI_MP_SERVICES_PPI *MpServices; - EFI_STATUS Status; - - DEBUG ((EFI_D_VERBOSE, "%a: %a\n", gEfiCallerBaseName, __FUNCTION__)); - - // - // Write the MSR on all the APs in parallel. - // - MpServices = Ppi; - Status = MpServices->StartupAllAPs ( - (CONST EFI_PEI_SERVICES **)PeiServices, - MpServices, - WriteFeatureControl, // Procedure - FALSE, // SingleThread - 0, // TimeoutInMicroSeconds: inf. - NULL // ProcedureArgument - ); - if (EFI_ERROR (Status) && Status != EFI_NOT_STARTED) { - DEBUG ((EFI_D_ERROR, "%a: StartupAllAps(): %r\n", __FUNCTION__, Status)); - return Status; - } - - // - // Now write the MSR on the BSP too. - // - WriteFeatureControl (NULL); - return EFI_SUCCESS; -} - -// -// Notification object for registering the callback, for when -// EFI_PEI_MP_SERVICES_PPI becomes available. -// -STATIC CONST EFI_PEI_NOTIFY_DESCRIPTOR mMpServicesNotify = { - EFI_PEI_PPI_DESCRIPTOR_NOTIFY_CALLBACK | // Flags - EFI_PEI_PPI_DESCRIPTOR_TERMINATE_LIST, - &gEfiPeiMpServicesPpiGuid, // Guid - OnMpServicesAvailable // Notify -}; - -VOID -InstallFeatureControlCallback ( - VOID - ) -{ - EFI_STATUS Status; - FIRMWARE_CONFIG_ITEM FwCfgItem; - UINTN FwCfgSize; - - Status = QemuFwCfgFindFile ("etc/msr_feature_control", &FwCfgItem, - &FwCfgSize); - if (EFI_ERROR (Status) || FwCfgSize != sizeof mFeatureControlValue) { - // - // Nothing to do. - // - return; - } - QemuFwCfgSelectItem (FwCfgItem); - QemuFwCfgReadBytes (sizeof mFeatureControlValue, &mFeatureControlValue); - - Status = PeiServicesNotifyPpi (&mMpServicesNotify); - if (EFI_ERROR (Status)) { - DEBUG ((EFI_D_ERROR, "%a: failed to set up MP Services callback: %r\n", - __FUNCTION__, Status)); - } -} diff --git a/OvmfPkg/PlatformPei/Fv.c b/OvmfPkg/PlatformPei/Fv.c deleted file mode 100644 index 248c585085..0000000000 --- a/OvmfPkg/PlatformPei/Fv.c +++ /dev/null @@ -1,100 +0,0 @@ -/** @file - Build FV related hobs for platform. - - Copyright (c) 2006 - 2013, Intel Corporation. All rights reserved.
- This program and the accompanying materials - are licensed and made available under the terms and conditions of the BSD License - which accompanies this distribution. The full text of the license may be found at - http://opensource.org/licenses/bsd-license.php - - THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, - WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. - -**/ - -#include "PiPei.h" -#include "Platform.h" -#include -#include -#include -#include - - -/** - Publish PEI & DXE (Decompressed) Memory based FVs to let PEI - and DXE know about them. - - @retval EFI_SUCCESS Platform PEI FVs were initialized successfully. - -**/ -EFI_STATUS -PeiFvInitialization ( - VOID - ) -{ - BOOLEAN SecureS3Needed; - - DEBUG ((EFI_D_INFO, "Platform PEI Firmware Volume Initialization\n")); - - // - // Create a memory allocation HOB for the PEI FV. - // - // Allocate as ACPI NVS is S3 is supported - // - BuildMemoryAllocationHob ( - PcdGet32 (PcdOvmfPeiMemFvBase), - PcdGet32 (PcdOvmfPeiMemFvSize), - mS3Supported ? EfiACPIMemoryNVS : EfiBootServicesData - ); - - // - // Let DXE know about the DXE FV - // - BuildFvHob (PcdGet32 (PcdOvmfDxeMemFvBase), PcdGet32 (PcdOvmfDxeMemFvSize)); - - SecureS3Needed = mS3Supported && FeaturePcdGet (PcdSmmSmramRequire); - - // - // Create a memory allocation HOB for the DXE FV. - // - // If "secure" S3 is needed, then SEC will decompress both PEI and DXE - // firmware volumes at S3 resume too, hence we need to keep away the OS from - // DXEFV as well. Otherwise we only need to keep away DXE itself from the - // DXEFV area. - // - BuildMemoryAllocationHob ( - PcdGet32 (PcdOvmfDxeMemFvBase), - PcdGet32 (PcdOvmfDxeMemFvSize), - SecureS3Needed ? EfiACPIMemoryNVS : EfiBootServicesData - ); - - // - // Additionally, said decompression will use temporary memory above the end - // of DXEFV, so let's keep away the OS from there too. - // - if (SecureS3Needed) { - UINT32 DxeMemFvEnd; - - DxeMemFvEnd = PcdGet32 (PcdOvmfDxeMemFvBase) + - PcdGet32 (PcdOvmfDxeMemFvSize); - BuildMemoryAllocationHob ( - DxeMemFvEnd, - PcdGet32 (PcdOvmfDecompressionScratchEnd) - DxeMemFvEnd, - EfiACPIMemoryNVS - ); - } - - // - // Let PEI know about the DXE FV so it can find the DXE Core - // - PeiServicesInstallFvInfoPpi ( - NULL, - (VOID *)(UINTN) PcdGet32 (PcdOvmfDxeMemFvBase), - PcdGet32 (PcdOvmfDxeMemFvSize), - NULL, - NULL - ); - - return EFI_SUCCESS; -} - diff --git a/OvmfPkg/PlatformPei/MemDetect.c b/OvmfPkg/PlatformPei/MemDetect.c deleted file mode 100644 index af96a04d19..0000000000 --- a/OvmfPkg/PlatformPei/MemDetect.c +++ /dev/null @@ -1,616 +0,0 @@ -/**@file - Memory Detection for Virtual Machines. - - Copyright (c) 2006 - 2016, Intel Corporation. All rights reserved.
- This program and the accompanying materials - are licensed and made available under the terms and conditions of the BSD License - which accompanies this distribution. The full text of the license may be found at - http://opensource.org/licenses/bsd-license.php - - THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, - WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. - -Module Name: - - MemDetect.c - -**/ - -// -// The package level header files this module uses -// -#include - -// -// The Library classes this module consumes -// -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#include "Platform.h" -#include "Cmos.h" - -UINT8 mPhysMemAddressWidth; - -STATIC UINT32 mS3AcpiReservedMemoryBase; -STATIC UINT32 mS3AcpiReservedMemorySize; - -UINT32 -GetSystemMemorySizeBelow4gb ( - VOID - ) -{ - UINT8 Cmos0x34; - UINT8 Cmos0x35; - - // - // CMOS 0x34/0x35 specifies the system memory above 16 MB. - // * CMOS(0x35) is the high byte - // * CMOS(0x34) is the low byte - // * The size is specified in 64kb chunks - // * Since this is memory above 16MB, the 16MB must be added - // into the calculation to get the total memory size. - // - - Cmos0x34 = (UINT8) CmosRead8 (0x34); - Cmos0x35 = (UINT8) CmosRead8 (0x35); - - return (UINT32) (((UINTN)((Cmos0x35 << 8) + Cmos0x34) << 16) + SIZE_16MB); -} - - -STATIC -UINT64 -GetSystemMemorySizeAbove4gb ( - ) -{ - UINT32 Size; - UINTN CmosIndex; - - // - // CMOS 0x5b-0x5d specifies the system memory above 4GB MB. - // * CMOS(0x5d) is the most significant size byte - // * CMOS(0x5c) is the middle size byte - // * CMOS(0x5b) is the least significant size byte - // * The size is specified in 64kb chunks - // - - Size = 0; - for (CmosIndex = 0x5d; CmosIndex >= 0x5b; CmosIndex--) { - Size = (UINT32) (Size << 8) + (UINT32) CmosRead8 (CmosIndex); - } - - return LShiftU64 (Size, 16); -} - - -/** - Return the highest address that DXE could possibly use, plus one. -**/ -STATIC -UINT64 -GetFirstNonAddress ( - VOID - ) -{ - UINT64 FirstNonAddress; - UINT64 Pci64Base, Pci64Size; - CHAR8 MbString[7 + 1]; - EFI_STATUS Status; - FIRMWARE_CONFIG_ITEM FwCfgItem; - UINTN FwCfgSize; - UINT64 HotPlugMemoryEnd; - RETURN_STATUS PcdStatus; - - FirstNonAddress = BASE_4GB + GetSystemMemorySizeAbove4gb (); - - // - // If DXE is 32-bit, then we're done; PciBusDxe will degrade 64-bit MMIO - // resources to 32-bit anyway. See DegradeResource() in - // "PciResourceSupport.c". - // -#ifdef MDE_CPU_IA32 - if (!FeaturePcdGet (PcdDxeIplSwitchToLongMode)) { - return FirstNonAddress; - } -#endif - - // - // Otherwise, in order to calculate the highest address plus one, we must - // consider the 64-bit PCI host aperture too. Fetch the default size. - // - Pci64Size = PcdGet64 (PcdPciMmio64Size); - - // - // See if the user specified the number of megabytes for the 64-bit PCI host - // aperture. The number of non-NUL characters in MbString allows for - // 9,999,999 MB, which is approximately 10 TB. - // - // As signaled by the "X-" prefix, this knob is experimental, and might go - // away at any time. - // - Status = QemuFwCfgFindFile ("opt/ovmf/X-PciMmio64Mb", &FwCfgItem, - &FwCfgSize); - if (!EFI_ERROR (Status)) { - if (FwCfgSize >= sizeof MbString) { - DEBUG ((EFI_D_WARN, - "%a: ignoring malformed 64-bit PCI host aperture size from fw_cfg\n", - __FUNCTION__)); - } else { - QemuFwCfgSelectItem (FwCfgItem); - QemuFwCfgReadBytes (FwCfgSize, MbString); - MbString[FwCfgSize] = '\0'; - Pci64Size = LShiftU64 (AsciiStrDecimalToUint64 (MbString), 20); - } - } - - if (Pci64Size == 0) { - if (mBootMode != BOOT_ON_S3_RESUME) { - DEBUG ((EFI_D_INFO, "%a: disabling 64-bit PCI host aperture\n", - __FUNCTION__)); - PcdStatus = PcdSet64S (PcdPciMmio64Size, 0); - ASSERT_RETURN_ERROR (PcdStatus); - } - - // - // There's nothing more to do; the amount of memory above 4GB fully - // determines the highest address plus one. The memory hotplug area (see - // below) plays no role for the firmware in this case. - // - return FirstNonAddress; - } - - // - // The "etc/reserved-memory-end" fw_cfg file, when present, contains an - // absolute, exclusive end address for the memory hotplug area. This area - // starts right at the end of the memory above 4GB. The 64-bit PCI host - // aperture must be placed above it. - // - Status = QemuFwCfgFindFile ("etc/reserved-memory-end", &FwCfgItem, - &FwCfgSize); - if (!EFI_ERROR (Status) && FwCfgSize == sizeof HotPlugMemoryEnd) { - QemuFwCfgSelectItem (FwCfgItem); - QemuFwCfgReadBytes (FwCfgSize, &HotPlugMemoryEnd); - - ASSERT (HotPlugMemoryEnd >= FirstNonAddress); - FirstNonAddress = HotPlugMemoryEnd; - } - - // - // SeaBIOS aligns both boundaries of the 64-bit PCI host aperture to 1GB, so - // that the host can map it with 1GB hugepages. Follow suit. - // - Pci64Base = ALIGN_VALUE (FirstNonAddress, (UINT64)SIZE_1GB); - Pci64Size = ALIGN_VALUE (Pci64Size, (UINT64)SIZE_1GB); - - // - // The 64-bit PCI host aperture should also be "naturally" aligned. The - // alignment is determined by rounding the size of the aperture down to the - // next smaller or equal power of two. That is, align the aperture by the - // largest BAR size that can fit into it. - // - Pci64Base = ALIGN_VALUE (Pci64Base, GetPowerOfTwo64 (Pci64Size)); - - if (mBootMode != BOOT_ON_S3_RESUME) { - // - // The core PciHostBridgeDxe driver will automatically add this range to - // the GCD memory space map through our PciHostBridgeLib instance; here we - // only need to set the PCDs. - // - PcdStatus = PcdSet64S (PcdPciMmio64Base, Pci64Base); - ASSERT_RETURN_ERROR (PcdStatus); - PcdStatus = PcdSet64S (PcdPciMmio64Size, Pci64Size); - ASSERT_RETURN_ERROR (PcdStatus); - - DEBUG ((EFI_D_INFO, "%a: Pci64Base=0x%Lx Pci64Size=0x%Lx\n", - __FUNCTION__, Pci64Base, Pci64Size)); - } - - // - // The useful address space ends with the 64-bit PCI host aperture. - // - FirstNonAddress = Pci64Base + Pci64Size; - return FirstNonAddress; -} - - -/** - Initialize the mPhysMemAddressWidth variable, based on guest RAM size. -**/ -VOID -AddressWidthInitialization ( - VOID - ) -{ - UINT64 FirstNonAddress; - - // - // As guest-physical memory size grows, the permanent PEI RAM requirements - // are dominated by the identity-mapping page tables built by the DXE IPL. - // The DXL IPL keys off of the physical address bits advertized in the CPU - // HOB. To conserve memory, we calculate the minimum address width here. - // - FirstNonAddress = GetFirstNonAddress (); - mPhysMemAddressWidth = (UINT8)HighBitSet64 (FirstNonAddress); - - // - // If FirstNonAddress is not an integral power of two, then we need an - // additional bit. - // - if ((FirstNonAddress & (FirstNonAddress - 1)) != 0) { - ++mPhysMemAddressWidth; - } - - // - // The minimum address width is 36 (covers up to and excluding 64 GB, which - // is the maximum for Ia32 + PAE). The theoretical architecture maximum for - // X64 long mode is 52 bits, but the DXE IPL clamps that down to 48 bits. We - // can simply assert that here, since 48 bits are good enough for 256 TB. - // - if (mPhysMemAddressWidth <= 36) { - mPhysMemAddressWidth = 36; - } - ASSERT (mPhysMemAddressWidth <= 48); -} - - -/** - Calculate the cap for the permanent PEI memory. -**/ -STATIC -UINT32 -GetPeiMemoryCap ( - VOID - ) -{ - BOOLEAN Page1GSupport; - UINT32 RegEax; - UINT32 RegEdx; - UINT32 Pml4Entries; - UINT32 PdpEntries; - UINTN TotalPages; - - // - // If DXE is 32-bit, then just return the traditional 64 MB cap. - // -#ifdef MDE_CPU_IA32 - if (!FeaturePcdGet (PcdDxeIplSwitchToLongMode)) { - return SIZE_64MB; - } -#endif - - // - // Dependent on physical address width, PEI memory allocations can be - // dominated by the page tables built for 64-bit DXE. So we key the cap off - // of those. The code below is based on CreateIdentityMappingPageTables() in - // "MdeModulePkg/Core/DxeIplPeim/X64/VirtualMemory.c". - // - Page1GSupport = FALSE; - if (PcdGetBool (PcdUse1GPageTable)) { - AsmCpuid (0x80000000, &RegEax, NULL, NULL, NULL); - if (RegEax >= 0x80000001) { - AsmCpuid (0x80000001, NULL, NULL, NULL, &RegEdx); - if ((RegEdx & BIT26) != 0) { - Page1GSupport = TRUE; - } - } - } - - if (mPhysMemAddressWidth <= 39) { - Pml4Entries = 1; - PdpEntries = 1 << (mPhysMemAddressWidth - 30); - ASSERT (PdpEntries <= 0x200); - } else { - Pml4Entries = 1 << (mPhysMemAddressWidth - 39); - ASSERT (Pml4Entries <= 0x200); - PdpEntries = 512; - } - - TotalPages = Page1GSupport ? Pml4Entries + 1 : - (PdpEntries + 1) * Pml4Entries + 1; - ASSERT (TotalPages <= 0x40201); - - // - // Add 64 MB for miscellaneous allocations. Note that for - // mPhysMemAddressWidth values close to 36, the cap will actually be - // dominated by this increment. - // - return (UINT32)(EFI_PAGES_TO_SIZE (TotalPages) + SIZE_64MB); -} - - -/** - Publish PEI core memory - - @return EFI_SUCCESS The PEIM initialized successfully. - -**/ -EFI_STATUS -PublishPeiMemory ( - VOID - ) -{ - EFI_STATUS Status; - EFI_PHYSICAL_ADDRESS MemoryBase; - UINT64 MemorySize; - UINT32 LowerMemorySize; - UINT32 PeiMemoryCap; - - LowerMemorySize = GetSystemMemorySizeBelow4gb (); - if (FeaturePcdGet (PcdSmmSmramRequire)) { - // - // TSEG is chipped from the end of low RAM - // - LowerMemorySize -= FixedPcdGet8 (PcdQ35TsegMbytes) * SIZE_1MB; - } - - // - // If S3 is supported, then the S3 permanent PEI memory is placed next, - // downwards. Its size is primarily dictated by CpuMpPei. The formula below - // is an approximation. - // - if (mS3Supported) { - mS3AcpiReservedMemorySize = SIZE_512KB + - mMaxCpuCount * - PcdGet32 (PcdCpuApStackSize); - mS3AcpiReservedMemoryBase = LowerMemorySize - mS3AcpiReservedMemorySize; - LowerMemorySize = mS3AcpiReservedMemoryBase; - } - - if (mBootMode == BOOT_ON_S3_RESUME) { - MemoryBase = mS3AcpiReservedMemoryBase; - MemorySize = mS3AcpiReservedMemorySize; - } else { - PeiMemoryCap = GetPeiMemoryCap (); - DEBUG ((EFI_D_INFO, "%a: mPhysMemAddressWidth=%d PeiMemoryCap=%u KB\n", - __FUNCTION__, mPhysMemAddressWidth, PeiMemoryCap >> 10)); - - // - // Determine the range of memory to use during PEI - // - // Technically we could lay the permanent PEI RAM over SEC's temporary - // decompression and scratch buffer even if "secure S3" is needed, since - // their lifetimes don't overlap. However, PeiFvInitialization() will cover - // RAM up to PcdOvmfDecompressionScratchEnd with an EfiACPIMemoryNVS memory - // allocation HOB, and other allocations served from the permanent PEI RAM - // shouldn't overlap with that HOB. - // - MemoryBase = mS3Supported && FeaturePcdGet (PcdSmmSmramRequire) ? - PcdGet32 (PcdOvmfDecompressionScratchEnd) : - PcdGet32 (PcdOvmfDxeMemFvBase) + PcdGet32 (PcdOvmfDxeMemFvSize); - MemorySize = LowerMemorySize - MemoryBase; - if (MemorySize > PeiMemoryCap) { - MemoryBase = LowerMemorySize - PeiMemoryCap; - MemorySize = PeiMemoryCap; - } - } - - // - // Publish this memory to the PEI Core - // - Status = PublishSystemMemory(MemoryBase, MemorySize); - ASSERT_EFI_ERROR (Status); - - return Status; -} - - -/** - Peform Memory Detection for QEMU / KVM - -**/ -STATIC -VOID -QemuInitializeRam ( - VOID - ) -{ - UINT64 LowerMemorySize; - UINT64 UpperMemorySize; - MTRR_SETTINGS MtrrSettings; - EFI_STATUS Status; - - DEBUG ((EFI_D_INFO, "%a called\n", __FUNCTION__)); - - // - // Determine total memory size available - // - LowerMemorySize = GetSystemMemorySizeBelow4gb (); - UpperMemorySize = GetSystemMemorySizeAbove4gb (); - - if (mBootMode == BOOT_ON_S3_RESUME) { - // - // Create the following memory HOB as an exception on the S3 boot path. - // - // Normally we'd create memory HOBs only on the normal boot path. However, - // CpuMpPei specifically needs such a low-memory HOB on the S3 path as - // well, for "borrowing" a subset of it temporarily, for the AP startup - // vector. - // - // CpuMpPei saves the original contents of the borrowed area in permanent - // PEI RAM, in a backup buffer allocated with the normal PEI services. - // CpuMpPei restores the original contents ("returns" the borrowed area) at - // End-of-PEI. End-of-PEI in turn is emitted by S3Resume2Pei before - // transferring control to the OS's wakeup vector in the FACS. - // - // We expect any other PEIMs that "borrow" memory similarly to CpuMpPei to - // restore the original contents. Furthermore, we expect all such PEIMs - // (CpuMpPei included) to claim the borrowed areas by producing memory - // allocation HOBs, and to honor preexistent memory allocation HOBs when - // looking for an area to borrow. - // - AddMemoryRangeHob (0, BASE_512KB + BASE_128KB); - } else { - // - // Create memory HOBs - // - AddMemoryRangeHob (0, BASE_512KB + BASE_128KB); - - if (FeaturePcdGet (PcdSmmSmramRequire)) { - UINT32 TsegSize; - - TsegSize = FixedPcdGet8 (PcdQ35TsegMbytes) * SIZE_1MB; - AddMemoryRangeHob (BASE_1MB, LowerMemorySize - TsegSize); - AddReservedMemoryBaseSizeHob (LowerMemorySize - TsegSize, TsegSize, - TRUE); - } else { - AddMemoryRangeHob (BASE_1MB, LowerMemorySize); - } - - if (UpperMemorySize != 0) { - AddMemoryBaseSizeHob (BASE_4GB, UpperMemorySize); - } - } - - // - // We'd like to keep the following ranges uncached: - // - [640 KB, 1 MB) - // - [LowerMemorySize, 4 GB) - // - // Everything else should be WB. Unfortunately, programming the inverse (ie. - // keeping the default UC, and configuring the complement set of the above as - // WB) is not reliable in general, because the end of the upper RAM can have - // practically any alignment, and we may not have enough variable MTRRs to - // cover it exactly. - // - if (IsMtrrSupported ()) { - MtrrGetAllMtrrs (&MtrrSettings); - - // - // MTRRs disabled, fixed MTRRs disabled, default type is uncached - // - ASSERT ((MtrrSettings.MtrrDefType & BIT11) == 0); - ASSERT ((MtrrSettings.MtrrDefType & BIT10) == 0); - ASSERT ((MtrrSettings.MtrrDefType & 0xFF) == 0); - - // - // flip default type to writeback - // - SetMem (&MtrrSettings.Fixed, sizeof MtrrSettings.Fixed, 0x06); - ZeroMem (&MtrrSettings.Variables, sizeof MtrrSettings.Variables); - MtrrSettings.MtrrDefType |= BIT11 | BIT10 | 6; - MtrrSetAllMtrrs (&MtrrSettings); - - // - // Set memory range from 640KB to 1MB to uncacheable - // - Status = MtrrSetMemoryAttribute (BASE_512KB + BASE_128KB, - BASE_1MB - (BASE_512KB + BASE_128KB), CacheUncacheable); - ASSERT_EFI_ERROR (Status); - - // - // Set memory range from the "top of lower RAM" (RAM below 4GB) to 4GB as - // uncacheable - // - Status = MtrrSetMemoryAttribute (LowerMemorySize, - SIZE_4GB - LowerMemorySize, CacheUncacheable); - ASSERT_EFI_ERROR (Status); - } -} - -/** - Publish system RAM and reserve memory regions - -**/ -VOID -InitializeRamRegions ( - VOID - ) -{ - if (!mXen) { - QemuInitializeRam (); - } else { - XenPublishRamRegions (); - } - - if (mS3Supported && mBootMode != BOOT_ON_S3_RESUME) { - // - // This is the memory range that will be used for PEI on S3 resume - // - BuildMemoryAllocationHob ( - mS3AcpiReservedMemoryBase, - mS3AcpiReservedMemorySize, - EfiACPIMemoryNVS - ); - - // - // Cover the initial RAM area used as stack and temporary PEI heap. - // - // This is reserved as ACPI NVS so it can be used on S3 resume. - // - BuildMemoryAllocationHob ( - PcdGet32 (PcdOvmfSecPeiTempRamBase), - PcdGet32 (PcdOvmfSecPeiTempRamSize), - EfiACPIMemoryNVS - ); - - // - // SEC stores its table of GUIDed section handlers here. - // - BuildMemoryAllocationHob ( - PcdGet64 (PcdGuidedExtractHandlerTableAddress), - PcdGet32 (PcdGuidedExtractHandlerTableSize), - EfiACPIMemoryNVS - ); - -#ifdef MDE_CPU_X64 - // - // Reserve the initial page tables built by the reset vector code. - // - // Since this memory range will be used by the Reset Vector on S3 - // resume, it must be reserved as ACPI NVS. - // - BuildMemoryAllocationHob ( - (EFI_PHYSICAL_ADDRESS)(UINTN) PcdGet32 (PcdOvmfSecPageTablesBase), - (UINT64)(UINTN) PcdGet32 (PcdOvmfSecPageTablesSize), - EfiACPIMemoryNVS - ); -#endif - } - - if (mBootMode != BOOT_ON_S3_RESUME) { - if (!FeaturePcdGet (PcdSmmSmramRequire)) { - // - // Reserve the lock box storage area - // - // Since this memory range will be used on S3 resume, it must be - // reserved as ACPI NVS. - // - // If S3 is unsupported, then various drivers might still write to the - // LockBox area. We ought to prevent DXE from serving allocation requests - // such that they would overlap the LockBox storage. - // - ZeroMem ( - (VOID*)(UINTN) PcdGet32 (PcdOvmfLockBoxStorageBase), - (UINTN) PcdGet32 (PcdOvmfLockBoxStorageSize) - ); - BuildMemoryAllocationHob ( - (EFI_PHYSICAL_ADDRESS)(UINTN) PcdGet32 (PcdOvmfLockBoxStorageBase), - (UINT64)(UINTN) PcdGet32 (PcdOvmfLockBoxStorageSize), - mS3Supported ? EfiACPIMemoryNVS : EfiBootServicesData - ); - } - - if (FeaturePcdGet (PcdSmmSmramRequire)) { - UINT32 TsegSize; - - // - // Make sure the TSEG area that we reported as a reserved memory resource - // cannot be used for reserved memory allocations. - // - TsegSize = FixedPcdGet8 (PcdQ35TsegMbytes) * SIZE_1MB; - BuildMemoryAllocationHob ( - GetSystemMemorySizeBelow4gb() - TsegSize, - TsegSize, - EfiReservedMemoryType - ); - } - } -} diff --git a/OvmfPkg/PlatformPei/Platform.c b/OvmfPkg/PlatformPei/Platform.c deleted file mode 100644 index 77a8a16c15..0000000000 --- a/OvmfPkg/PlatformPei/Platform.c +++ /dev/null @@ -1,674 +0,0 @@ -/**@file - Platform PEI driver - - Copyright (c) 2006 - 2016, Intel Corporation. All rights reserved.
- Copyright (c) 2011, Andrei Warkentin - - This program and the accompanying materials - are licensed and made 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. - -**/ - -// -// The package level header files this module uses -// -#include - -// -// The Library classes this module consumes -// -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#include "Platform.h" -#include "Cmos.h" - -EFI_MEMORY_TYPE_INFORMATION mDefaultMemoryTypeInformation[] = { - { EfiACPIMemoryNVS, 0x004 }, - { EfiACPIReclaimMemory, 0x008 }, - { EfiReservedMemoryType, 0x004 }, - { EfiRuntimeServicesData, 0x024 }, - { EfiRuntimeServicesCode, 0x030 }, - { EfiBootServicesCode, 0x180 }, - { EfiBootServicesData, 0xF00 }, - { EfiMaxMemoryType, 0x000 } -}; - - -EFI_PEI_PPI_DESCRIPTOR mPpiBootMode[] = { - { - EFI_PEI_PPI_DESCRIPTOR_PPI | EFI_PEI_PPI_DESCRIPTOR_TERMINATE_LIST, - &gEfiPeiMasterBootModePpiGuid, - NULL - } -}; - - -UINT16 mHostBridgeDevId; - -EFI_BOOT_MODE mBootMode = BOOT_WITH_FULL_CONFIGURATION; - -BOOLEAN mS3Supported = FALSE; - -UINT32 mMaxCpuCount; - -VOID -AddIoMemoryBaseSizeHob ( - EFI_PHYSICAL_ADDRESS MemoryBase, - UINT64 MemorySize - ) -{ - BuildResourceDescriptorHob ( - EFI_RESOURCE_MEMORY_MAPPED_IO, - EFI_RESOURCE_ATTRIBUTE_PRESENT | - EFI_RESOURCE_ATTRIBUTE_INITIALIZED | - EFI_RESOURCE_ATTRIBUTE_UNCACHEABLE | - EFI_RESOURCE_ATTRIBUTE_TESTED, - MemoryBase, - MemorySize - ); -} - -VOID -AddReservedMemoryBaseSizeHob ( - EFI_PHYSICAL_ADDRESS MemoryBase, - UINT64 MemorySize, - BOOLEAN Cacheable - ) -{ - BuildResourceDescriptorHob ( - EFI_RESOURCE_MEMORY_RESERVED, - EFI_RESOURCE_ATTRIBUTE_PRESENT | - EFI_RESOURCE_ATTRIBUTE_INITIALIZED | - EFI_RESOURCE_ATTRIBUTE_UNCACHEABLE | - (Cacheable ? - EFI_RESOURCE_ATTRIBUTE_WRITE_COMBINEABLE | - EFI_RESOURCE_ATTRIBUTE_WRITE_THROUGH_CACHEABLE | - EFI_RESOURCE_ATTRIBUTE_WRITE_BACK_CACHEABLE : - 0 - ) | - EFI_RESOURCE_ATTRIBUTE_TESTED, - MemoryBase, - MemorySize - ); -} - -VOID -AddIoMemoryRangeHob ( - EFI_PHYSICAL_ADDRESS MemoryBase, - EFI_PHYSICAL_ADDRESS MemoryLimit - ) -{ - AddIoMemoryBaseSizeHob (MemoryBase, (UINT64)(MemoryLimit - MemoryBase)); -} - - -VOID -AddMemoryBaseSizeHob ( - EFI_PHYSICAL_ADDRESS MemoryBase, - UINT64 MemorySize - ) -{ - BuildResourceDescriptorHob ( - EFI_RESOURCE_SYSTEM_MEMORY, - EFI_RESOURCE_ATTRIBUTE_PRESENT | - EFI_RESOURCE_ATTRIBUTE_INITIALIZED | - EFI_RESOURCE_ATTRIBUTE_UNCACHEABLE | - EFI_RESOURCE_ATTRIBUTE_WRITE_COMBINEABLE | - EFI_RESOURCE_ATTRIBUTE_WRITE_THROUGH_CACHEABLE | - EFI_RESOURCE_ATTRIBUTE_WRITE_BACK_CACHEABLE | - EFI_RESOURCE_ATTRIBUTE_TESTED, - MemoryBase, - MemorySize - ); -} - - -VOID -AddMemoryRangeHob ( - EFI_PHYSICAL_ADDRESS MemoryBase, - EFI_PHYSICAL_ADDRESS MemoryLimit - ) -{ - AddMemoryBaseSizeHob (MemoryBase, (UINT64)(MemoryLimit - MemoryBase)); -} - - -VOID -MemMapInitialization ( - VOID - ) -{ - UINT64 PciIoBase; - UINT64 PciIoSize; - RETURN_STATUS PcdStatus; - - PciIoBase = 0xC000; - PciIoSize = 0x4000; - - // - // Create Memory Type Information HOB - // - BuildGuidDataHob ( - &gEfiMemoryTypeInformationGuid, - mDefaultMemoryTypeInformation, - sizeof(mDefaultMemoryTypeInformation) - ); - - // - // Video memory + Legacy BIOS region - // - AddIoMemoryRangeHob (0x0A0000, BASE_1MB); - - if (!mXen) { - UINT32 TopOfLowRam; - UINT64 PciExBarBase; - UINT32 PciBase; - UINT32 PciSize; - - TopOfLowRam = GetSystemMemorySizeBelow4gb (); - PciExBarBase = 0; - if (mHostBridgeDevId == INTEL_Q35_MCH_DEVICE_ID) { - // - // The MMCONFIG area is expected to fall between the top of low RAM and - // the base of the 32-bit PCI host aperture. - // - PciExBarBase = FixedPcdGet64 (PcdPciExpressBaseAddress); - ASSERT (TopOfLowRam <= PciExBarBase); - ASSERT (PciExBarBase <= MAX_UINT32 - SIZE_256MB); - PciBase = (UINT32)(PciExBarBase + SIZE_256MB); - } else { - PciBase = (TopOfLowRam < BASE_2GB) ? BASE_2GB : TopOfLowRam; - } - - // - // address purpose size - // ------------ -------- ------------------------- - // max(top, 2g) PCI MMIO 0xFC000000 - max(top, 2g) - // 0xFC000000 gap 44 MB - // 0xFEC00000 IO-APIC 4 KB - // 0xFEC01000 gap 1020 KB - // 0xFED00000 HPET 1 KB - // 0xFED00400 gap 111 KB - // 0xFED1C000 gap (PIIX4) / RCRB (ICH9) 16 KB - // 0xFED20000 gap 896 KB - // 0xFEE00000 LAPIC 1 MB - // - PciSize = 0xFC000000 - PciBase; - AddIoMemoryBaseSizeHob (PciBase, PciSize); - PcdStatus = PcdSet64S (PcdPciMmio32Base, PciBase); - ASSERT_RETURN_ERROR (PcdStatus); - PcdStatus = PcdSet64S (PcdPciMmio32Size, PciSize); - ASSERT_RETURN_ERROR (PcdStatus); - - AddIoMemoryBaseSizeHob (0xFEC00000, SIZE_4KB); - AddIoMemoryBaseSizeHob (0xFED00000, SIZE_1KB); - if (mHostBridgeDevId == INTEL_Q35_MCH_DEVICE_ID) { - AddIoMemoryBaseSizeHob (ICH9_ROOT_COMPLEX_BASE, SIZE_16KB); - // - // Note: there should be an - // - // AddIoMemoryBaseSizeHob (PciExBarBase, SIZE_256MB); - // - // call below, just like the one above for RCBA. However, Linux insists - // that the MMCONFIG area be marked in the E820 or UEFI memory map as - // "reserved memory" -- Linux does not content itself with a simple gap - // in the memory map wherever the MCFG ACPI table points to. - // - // This appears to be a safety measure. The PCI Firmware Specification - // (rev 3.1) says in 4.1.2. "MCFG Table Description": "The resources can - // *optionally* be returned in [...] EFIGetMemoryMap as reserved memory - // [...]". (Emphasis added here.) - // - // Normally we add memory resource descriptor HOBs in - // QemuInitializeRam(), and pre-allocate from those with memory - // allocation HOBs in InitializeRamRegions(). However, the MMCONFIG area - // is most definitely not RAM; so, as an exception, cover it with - // uncacheable reserved memory right here. - // - AddReservedMemoryBaseSizeHob (PciExBarBase, SIZE_256MB, FALSE); - BuildMemoryAllocationHob (PciExBarBase, SIZE_256MB, - EfiReservedMemoryType); - } - AddIoMemoryBaseSizeHob (PcdGet32(PcdCpuLocalApicBaseAddress), SIZE_1MB); - - // - // On Q35, the IO Port space is available for PCI resource allocations from - // 0x6000 up. - // - if (mHostBridgeDevId == INTEL_Q35_MCH_DEVICE_ID) { - PciIoBase = 0x6000; - PciIoSize = 0xA000; - ASSERT ((ICH9_PMBASE_VALUE & 0xF000) < PciIoBase); - } - } - - // - // Add PCI IO Port space available for PCI resource allocations. - // - BuildResourceDescriptorHob ( - EFI_RESOURCE_IO, - EFI_RESOURCE_ATTRIBUTE_PRESENT | - EFI_RESOURCE_ATTRIBUTE_INITIALIZED, - PciIoBase, - PciIoSize - ); - PcdStatus = PcdSet64S (PcdPciIoBase, PciIoBase); - ASSERT_RETURN_ERROR (PcdStatus); - PcdStatus = PcdSet64S (PcdPciIoSize, PciIoSize); - ASSERT_RETURN_ERROR (PcdStatus); -} - -EFI_STATUS -GetNamedFwCfgBoolean ( - IN CHAR8 *FwCfgFileName, - OUT BOOLEAN *Setting - ) -{ - EFI_STATUS Status; - FIRMWARE_CONFIG_ITEM FwCfgItem; - UINTN FwCfgSize; - UINT8 Value[3]; - - Status = QemuFwCfgFindFile (FwCfgFileName, &FwCfgItem, &FwCfgSize); - if (EFI_ERROR (Status)) { - return Status; - } - if (FwCfgSize > sizeof Value) { - return EFI_BAD_BUFFER_SIZE; - } - QemuFwCfgSelectItem (FwCfgItem); - QemuFwCfgReadBytes (FwCfgSize, Value); - - if ((FwCfgSize == 1) || - (FwCfgSize == 2 && Value[1] == '\n') || - (FwCfgSize == 3 && Value[1] == '\r' && Value[2] == '\n')) { - switch (Value[0]) { - case '0': - case 'n': - case 'N': - *Setting = FALSE; - return EFI_SUCCESS; - - case '1': - case 'y': - case 'Y': - *Setting = TRUE; - return EFI_SUCCESS; - - default: - break; - } - } - return EFI_PROTOCOL_ERROR; -} - -#define UPDATE_BOOLEAN_PCD_FROM_FW_CFG(TokenName) \ - do { \ - BOOLEAN Setting; \ - RETURN_STATUS PcdStatus; \ - \ - if (!EFI_ERROR (GetNamedFwCfgBoolean ( \ - "opt/ovmf/" #TokenName, &Setting))) { \ - PcdStatus = PcdSetBoolS (TokenName, Setting); \ - ASSERT_RETURN_ERROR (PcdStatus); \ - } \ - } while (0) - -VOID -NoexecDxeInitialization ( - VOID - ) -{ - UPDATE_BOOLEAN_PCD_FROM_FW_CFG (PcdPropertiesTableEnable); - UPDATE_BOOLEAN_PCD_FROM_FW_CFG (PcdSetNxForStack); -} - -VOID -PciExBarInitialization ( - VOID - ) -{ - union { - UINT64 Uint64; - UINT32 Uint32[2]; - } PciExBarBase; - - // - // We only support the 256MB size for the MMCONFIG area: - // 256 buses * 32 devices * 8 functions * 4096 bytes config space. - // - // The masks used below enforce the Q35 requirements that the MMCONFIG area - // be (a) correctly aligned -- here at 256 MB --, (b) located under 64 GB. - // - // Note that (b) also ensures that the minimum address width we have - // determined in AddressWidthInitialization(), i.e., 36 bits, will suffice - // for DXE's page tables to cover the MMCONFIG area. - // - PciExBarBase.Uint64 = FixedPcdGet64 (PcdPciExpressBaseAddress); - ASSERT ((PciExBarBase.Uint32[1] & MCH_PCIEXBAR_HIGHMASK) == 0); - ASSERT ((PciExBarBase.Uint32[0] & MCH_PCIEXBAR_LOWMASK) == 0); - - // - // Clear the PCIEXBAREN bit first, before programming the high register. - // - PciWrite32 (DRAMC_REGISTER_Q35 (MCH_PCIEXBAR_LOW), 0); - - // - // Program the high register. Then program the low register, setting the - // MMCONFIG area size and enabling decoding at once. - // - PciWrite32 (DRAMC_REGISTER_Q35 (MCH_PCIEXBAR_HIGH), PciExBarBase.Uint32[1]); - PciWrite32 ( - DRAMC_REGISTER_Q35 (MCH_PCIEXBAR_LOW), - PciExBarBase.Uint32[0] | MCH_PCIEXBAR_BUS_FF | MCH_PCIEXBAR_EN - ); -} - -VOID -MiscInitialization ( - VOID - ) -{ - UINTN PmCmd; - UINTN Pmba; - UINT32 PmbaAndVal; - UINT32 PmbaOrVal; - UINTN AcpiCtlReg; - UINT8 AcpiEnBit; - RETURN_STATUS PcdStatus; - - // - // Disable A20 Mask - // - IoOr8 (0x92, BIT1); - - // - // Build the CPU HOB with guest RAM size dependent address width and 16-bits - // of IO space. (Side note: unlike other HOBs, the CPU HOB is needed during - // S3 resume as well, so we build it unconditionally.) - // - BuildCpuHob (mPhysMemAddressWidth, 16); - - // - // Determine platform type and save Host Bridge DID to PCD - // - switch (mHostBridgeDevId) { - case INTEL_82441_DEVICE_ID: - PmCmd = POWER_MGMT_REGISTER_PIIX4 (PCI_COMMAND_OFFSET); - Pmba = POWER_MGMT_REGISTER_PIIX4 (PIIX4_PMBA); - PmbaAndVal = ~(UINT32)PIIX4_PMBA_MASK; - PmbaOrVal = PIIX4_PMBA_VALUE; - AcpiCtlReg = POWER_MGMT_REGISTER_PIIX4 (PIIX4_PMREGMISC); - AcpiEnBit = PIIX4_PMREGMISC_PMIOSE; - break; - case INTEL_Q35_MCH_DEVICE_ID: - PmCmd = POWER_MGMT_REGISTER_Q35 (PCI_COMMAND_OFFSET); - Pmba = POWER_MGMT_REGISTER_Q35 (ICH9_PMBASE); - PmbaAndVal = ~(UINT32)ICH9_PMBASE_MASK; - PmbaOrVal = ICH9_PMBASE_VALUE; - AcpiCtlReg = POWER_MGMT_REGISTER_Q35 (ICH9_ACPI_CNTL); - AcpiEnBit = ICH9_ACPI_CNTL_ACPI_EN; - break; - default: - DEBUG ((EFI_D_ERROR, "%a: Unknown Host Bridge Device ID: 0x%04x\n", - __FUNCTION__, mHostBridgeDevId)); - ASSERT (FALSE); - return; - } - PcdStatus = PcdSet16S (PcdOvmfHostBridgePciDevId, mHostBridgeDevId); - ASSERT_RETURN_ERROR (PcdStatus); - - // - // If the appropriate IOspace enable bit is set, assume the ACPI PMBA - // has been configured (e.g., by Xen) and skip the setup here. - // This matches the logic in AcpiTimerLibConstructor (). - // - if ((PciRead8 (AcpiCtlReg) & AcpiEnBit) == 0) { - // - // The PEI phase should be exited with fully accessibe ACPI PM IO space: - // 1. set PMBA - // - PciAndThenOr32 (Pmba, PmbaAndVal, PmbaOrVal); - - // - // 2. set PCICMD/IOSE - // - PciOr8 (PmCmd, EFI_PCI_COMMAND_IO_SPACE); - - // - // 3. set ACPI PM IO enable bit (PMREGMISC:PMIOSE or ACPI_CNTL:ACPI_EN) - // - PciOr8 (AcpiCtlReg, AcpiEnBit); - } - - if (mHostBridgeDevId == INTEL_Q35_MCH_DEVICE_ID) { - // - // Set Root Complex Register Block BAR - // - PciWrite32 ( - POWER_MGMT_REGISTER_Q35 (ICH9_RCBA), - ICH9_ROOT_COMPLEX_BASE | ICH9_RCBA_EN - ); - - // - // Set PCI Express Register Range Base Address - // - PciExBarInitialization (); - } -} - - -VOID -BootModeInitialization ( - VOID - ) -{ - EFI_STATUS Status; - - if (CmosRead8 (0xF) == 0xFE) { - mBootMode = BOOT_ON_S3_RESUME; - } - CmosWrite8 (0xF, 0x00); - - Status = PeiServicesSetBootMode (mBootMode); - ASSERT_EFI_ERROR (Status); - - Status = PeiServicesInstallPpi (mPpiBootMode); - ASSERT_EFI_ERROR (Status); -} - - -VOID -ReserveEmuVariableNvStore ( - ) -{ - EFI_PHYSICAL_ADDRESS VariableStore; - RETURN_STATUS PcdStatus; - - // - // Allocate storage for NV variables early on so it will be - // at a consistent address. Since VM memory is preserved - // across reboots, this allows the NV variable storage to survive - // a VM reboot. - // - VariableStore = - (EFI_PHYSICAL_ADDRESS)(UINTN) - AllocateAlignedRuntimePages ( - EFI_SIZE_TO_PAGES (2 * PcdGet32 (PcdFlashNvStorageFtwSpareSize)), - PcdGet32 (PcdFlashNvStorageFtwSpareSize) - ); - DEBUG ((EFI_D_INFO, - "Reserved variable store memory: 0x%lX; size: %dkb\n", - VariableStore, - (2 * PcdGet32 (PcdFlashNvStorageFtwSpareSize)) / 1024 - )); - PcdStatus = PcdSet64S (PcdEmuVariableNvStoreReserved, VariableStore); - ASSERT_RETURN_ERROR (PcdStatus); -} - - -VOID -DebugDumpCmos ( - VOID - ) -{ - UINT32 Loop; - - DEBUG ((EFI_D_INFO, "CMOS:\n")); - - for (Loop = 0; Loop < 0x80; Loop++) { - if ((Loop % 0x10) == 0) { - DEBUG ((EFI_D_INFO, "%02x:", Loop)); - } - DEBUG ((EFI_D_INFO, " %02x", CmosRead8 (Loop))); - if ((Loop % 0x10) == 0xf) { - DEBUG ((EFI_D_INFO, "\n")); - } - } -} - - -VOID -S3Verification ( - VOID - ) -{ -#if defined (MDE_CPU_X64) - if (FeaturePcdGet (PcdSmmSmramRequire) && mS3Supported) { - DEBUG ((EFI_D_ERROR, - "%a: S3Resume2Pei doesn't support X64 PEI + SMM yet.\n", __FUNCTION__)); - DEBUG ((EFI_D_ERROR, - "%a: Please disable S3 on the QEMU command line (see the README),\n", - __FUNCTION__)); - DEBUG ((EFI_D_ERROR, - "%a: or build OVMF with \"OvmfPkgIa32X64.dsc\".\n", __FUNCTION__)); - ASSERT (FALSE); - CpuDeadLoop (); - } -#endif -} - - -/** - Fetch the number of boot CPUs from QEMU and expose it to UefiCpuPkg modules. - Set the mMaxCpuCount variable. -**/ -VOID -MaxCpuCountInitialization ( - VOID - ) -{ - UINT16 ProcessorCount; - RETURN_STATUS PcdStatus; - - QemuFwCfgSelectItem (QemuFwCfgItemSmpCpuCount); - ProcessorCount = QemuFwCfgRead16 (); - // - // If the fw_cfg key or fw_cfg entirely is unavailable, load mMaxCpuCount - // from the PCD default. No change to PCDs. - // - if (ProcessorCount == 0) { - mMaxCpuCount = PcdGet32 (PcdCpuMaxLogicalProcessorNumber); - return; - } - // - // Otherwise, set mMaxCpuCount to the value reported by QEMU. - // - mMaxCpuCount = ProcessorCount; - // - // Additionally, tell UefiCpuPkg modules (a) the exact number of VCPUs, (b) - // to wait, in the initial AP bringup, exactly as long as it takes for all of - // the APs to report in. For this, we set the longest representable timeout - // (approx. 71 minutes). - // - PcdStatus = PcdSet32S (PcdCpuMaxLogicalProcessorNumber, ProcessorCount); - ASSERT_RETURN_ERROR (PcdStatus); - PcdStatus = PcdSet32S (PcdCpuApInitTimeOutInMicroSeconds, MAX_UINT32); - ASSERT_RETURN_ERROR (PcdStatus); - DEBUG ((DEBUG_INFO, "%a: QEMU reports %d processor(s)\n", __FUNCTION__, - ProcessorCount)); -} - - -/** - Perform Platform PEI initialization. - - @param FileHandle Handle of the file being invoked. - @param PeiServices Describes the list of possible PEI Services. - - @return EFI_SUCCESS The PEIM initialized successfully. - -**/ -EFI_STATUS -EFIAPI -InitializePlatform ( - IN EFI_PEI_FILE_HANDLE FileHandle, - IN CONST EFI_PEI_SERVICES **PeiServices - ) -{ - EFI_STATUS Status; - - DEBUG ((EFI_D_ERROR, "Platform PEIM Loaded\n")); - - DebugDumpCmos (); - - XenDetect (); - - if (QemuFwCfgS3Enabled ()) { - DEBUG ((EFI_D_INFO, "S3 support was detected on QEMU\n")); - mS3Supported = TRUE; - Status = PcdSetBoolS (PcdAcpiS3Enable, TRUE); - ASSERT_EFI_ERROR (Status); - } - - S3Verification (); - BootModeInitialization (); - AddressWidthInitialization (); - MaxCpuCountInitialization (); - - PublishPeiMemory (); - - InitializeRamRegions (); - - if (mXen) { - DEBUG ((EFI_D_INFO, "Xen was detected\n")); - InitializeXen (); - } - - // - // Query Host Bridge DID - // - mHostBridgeDevId = PciRead16 (OVMF_HOSTBRIDGE_DID); - - if (mBootMode != BOOT_ON_S3_RESUME) { - ReserveEmuVariableNvStore (); - PeiFvInitialization (); - MemMapInitialization (); - NoexecDxeInitialization (); - } - - MiscInitialization (); - InstallFeatureControlCallback (); - - return EFI_SUCCESS; -} diff --git a/OvmfPkg/PlatformPei/Platform.h b/OvmfPkg/PlatformPei/Platform.h deleted file mode 100644 index 18f42c3f0e..0000000000 --- a/OvmfPkg/PlatformPei/Platform.h +++ /dev/null @@ -1,106 +0,0 @@ -/** @file - Platform PEI module include file. - - Copyright (c) 2006 - 2016, Intel Corporation. All rights reserved.
- This program and the accompanying materials - are licensed and made available under the terms and conditions of the BSD License - which accompanies this distribution. The full text of the license may be found at - http://opensource.org/licenses/bsd-license.php - - THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, - WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. - -**/ - -#ifndef _PLATFORM_PEI_H_INCLUDED_ -#define _PLATFORM_PEI_H_INCLUDED_ - -#include - -VOID -AddIoMemoryBaseSizeHob ( - EFI_PHYSICAL_ADDRESS MemoryBase, - UINT64 MemorySize - ); - -VOID -AddIoMemoryRangeHob ( - EFI_PHYSICAL_ADDRESS MemoryBase, - EFI_PHYSICAL_ADDRESS MemoryLimit - ); - -VOID -AddMemoryBaseSizeHob ( - EFI_PHYSICAL_ADDRESS MemoryBase, - UINT64 MemorySize - ); - -VOID -AddMemoryRangeHob ( - EFI_PHYSICAL_ADDRESS MemoryBase, - EFI_PHYSICAL_ADDRESS MemoryLimit - ); - -VOID -AddReservedMemoryBaseSizeHob ( - EFI_PHYSICAL_ADDRESS MemoryBase, - UINT64 MemorySize, - BOOLEAN Cacheable - ); - -VOID -AddressWidthInitialization ( - VOID - ); - -EFI_STATUS -PublishPeiMemory ( - VOID - ); - -UINT32 -GetSystemMemorySizeBelow4gb ( - VOID - ); - -VOID -InitializeRamRegions ( - VOID - ); - -EFI_STATUS -PeiFvInitialization ( - VOID - ); - -VOID -InstallFeatureControlCallback ( - VOID - ); - -EFI_STATUS -InitializeXen ( - VOID - ); - -BOOLEAN -XenDetect ( - VOID - ); - -extern BOOLEAN mXen; - -VOID -XenPublishRamRegions ( - VOID - ); - -extern EFI_BOOT_MODE mBootMode; - -extern BOOLEAN mS3Supported; - -extern UINT8 mPhysMemAddressWidth; - -extern UINT32 mMaxCpuCount; - -#endif // _PLATFORM_PEI_H_INCLUDED_ diff --git a/OvmfPkg/PlatformPei/PlatformPei.inf b/OvmfPkg/PlatformPei/PlatformPei.inf deleted file mode 100644 index 53c6dd445a..0000000000 --- a/OvmfPkg/PlatformPei/PlatformPei.inf +++ /dev/null @@ -1,114 +0,0 @@ -## @file -# Platform PEI driver -# -# This module provides platform specific function to detect boot mode. -# Copyright (c) 2006 - 2016, Intel Corporation. All rights reserved.
-# -# This program and the accompanying materials -# are licensed and made available under the terms and conditions of the BSD License -# which accompanies this distribution. The full text of the license may be found at -# http://opensource.org/licenses/bsd-license.php -# -# THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, -# WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. -# -## - -[Defines] - INF_VERSION = 0x00010005 - BASE_NAME = PlatformPei - FILE_GUID = 222c386d-5abc-4fb4-b124-fbb82488acf4 - MODULE_TYPE = PEIM - VERSION_STRING = 1.0 - ENTRY_POINT = InitializePlatform - -# -# The following information is for reference only and not required by the build tools. -# -# VALID_ARCHITECTURES = IA32 X64 IPF EBC -# - -[Sources] - Cmos.c - FeatureControl.c - Fv.c - MemDetect.c - Platform.c - Xen.c - -[Packages] - IntelFrameworkModulePkg/IntelFrameworkModulePkg.dec - MdePkg/MdePkg.dec - MdeModulePkg/MdeModulePkg.dec - UefiCpuPkg/UefiCpuPkg.dec - OvmfPkg/OvmfPkg.dec - -[Guids] - gEfiMemoryTypeInformationGuid - gEfiXenInfoGuid - -[LibraryClasses] - BaseLib - DebugLib - HobLib - IoLib - PciLib - PeiResourcePublicationLib - PeiServicesLib - PeiServicesTablePointerLib - PeimEntryPoint - QemuFwCfgLib - QemuFwCfgS3Lib - MtrrLib - PcdLib - -[Pcd] - gUefiOvmfPkgTokenSpaceGuid.PcdOvmfPeiMemFvBase - gUefiOvmfPkgTokenSpaceGuid.PcdOvmfPeiMemFvSize - gUefiOvmfPkgTokenSpaceGuid.PcdOvmfDxeMemFvBase - gUefiOvmfPkgTokenSpaceGuid.PcdOvmfDxeMemFvSize - gUefiOvmfPkgTokenSpaceGuid.PcdOvmfSecPeiTempRamBase - gUefiOvmfPkgTokenSpaceGuid.PcdOvmfSecPeiTempRamSize - gUefiOvmfPkgTokenSpaceGuid.PcdOvmfSecPageTablesBase - gUefiOvmfPkgTokenSpaceGuid.PcdOvmfSecPageTablesSize - gUefiOvmfPkgTokenSpaceGuid.PcdOvmfLockBoxStorageBase - gUefiOvmfPkgTokenSpaceGuid.PcdOvmfLockBoxStorageSize - gUefiOvmfPkgTokenSpaceGuid.PcdGuidedExtractHandlerTableSize - gUefiOvmfPkgTokenSpaceGuid.PcdOvmfHostBridgePciDevId - gUefiOvmfPkgTokenSpaceGuid.PcdPciIoBase - gUefiOvmfPkgTokenSpaceGuid.PcdPciIoSize - gUefiOvmfPkgTokenSpaceGuid.PcdPciMmio32Base - gUefiOvmfPkgTokenSpaceGuid.PcdPciMmio32Size - gUefiOvmfPkgTokenSpaceGuid.PcdPciMmio64Base - gUefiOvmfPkgTokenSpaceGuid.PcdPciMmio64Size - gUefiOvmfPkgTokenSpaceGuid.PcdOvmfDecompressionScratchEnd - gUefiOvmfPkgTokenSpaceGuid.PcdQ35TsegMbytes - gEfiMdePkgTokenSpaceGuid.PcdGuidedExtractHandlerTableAddress - gEfiMdeModulePkgTokenSpaceGuid.PcdVariableStoreSize - gEfiMdeModulePkgTokenSpaceGuid.PcdFlashNvStorageFtwSpareSize - gEfiMdeModulePkgTokenSpaceGuid.PcdFlashNvStorageVariableSize - gEfiMdeModulePkgTokenSpaceGuid.PcdEmuVariableNvStoreReserved - gEfiMdeModulePkgTokenSpaceGuid.PcdPciDisableBusEnumeration - gEfiMdeModulePkgTokenSpaceGuid.PcdDxeIplSwitchToLongMode - gEfiMdeModulePkgTokenSpaceGuid.PcdUse1GPageTable - gEfiMdeModulePkgTokenSpaceGuid.PcdSetNxForStack - gEfiMdeModulePkgTokenSpaceGuid.PcdPropertiesTableEnable - gEfiMdeModulePkgTokenSpaceGuid.PcdAcpiS3Enable - gUefiCpuPkgTokenSpaceGuid.PcdCpuLocalApicBaseAddress - gUefiCpuPkgTokenSpaceGuid.PcdCpuMaxLogicalProcessorNumber - gUefiCpuPkgTokenSpaceGuid.PcdCpuApInitTimeOutInMicroSeconds - gUefiCpuPkgTokenSpaceGuid.PcdCpuApStackSize - -[FixedPcd] - gEfiMdePkgTokenSpaceGuid.PcdPciExpressBaseAddress - -[FeaturePcd] - gUefiOvmfPkgTokenSpaceGuid.PcdSmmSmramRequire - -[Ppis] - gEfiPeiMasterBootModePpiGuid - gEfiPeiMpServicesPpiGuid - -[Depex] - TRUE - diff --git a/OvmfPkg/PlatformPei/Xen.c b/OvmfPkg/PlatformPei/Xen.c deleted file mode 100644 index ab38f97a67..0000000000 --- a/OvmfPkg/PlatformPei/Xen.c +++ /dev/null @@ -1,231 +0,0 @@ -/**@file - Xen Platform PEI support - - Copyright (c) 2006 - 2016, Intel Corporation. All rights reserved.
- Copyright (c) 2011, Andrei Warkentin - - This program and the accompanying materials - are licensed and made 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. - -**/ - -// -// The package level header files this module uses -// -#include - -// -// The Library classes this module consumes -// -#include -#include -#include -#include -#include -#include -#include -#include - -#include "Platform.h" -#include "Xen.h" - -BOOLEAN mXen = FALSE; - -STATIC UINT32 mXenLeaf = 0; - -EFI_XEN_INFO mXenInfo; - -/** - Returns E820 map provided by Xen - - @param Entries Pointer to E820 map - @param Count Number of entries - - @return EFI_STATUS -**/ -EFI_STATUS -XenGetE820Map ( - EFI_E820_ENTRY64 **Entries, - UINT32 *Count - ) -{ - EFI_XEN_OVMF_INFO *Info = - (EFI_XEN_OVMF_INFO *)(UINTN) OVMF_INFO_PHYSICAL_ADDRESS; - - if (AsciiStrCmp ((CHAR8 *) Info->Signature, "XenHVMOVMF")) { - return EFI_NOT_FOUND; - } - - ASSERT (Info->E820 < MAX_ADDRESS); - *Entries = (EFI_E820_ENTRY64 *)(UINTN) Info->E820; - *Count = Info->E820EntriesCount; - - return EFI_SUCCESS; -} - -/** - Connects to the Hypervisor. - - @param XenLeaf CPUID index used to connect. - - @return EFI_STATUS - -**/ -EFI_STATUS -XenConnect ( - UINT32 XenLeaf - ) -{ - UINT32 Index; - UINT32 TransferReg; - UINT32 TransferPages; - UINT32 XenVersion; - - AsmCpuid (XenLeaf + 2, &TransferPages, &TransferReg, NULL, NULL); - mXenInfo.HyperPages = AllocatePages (TransferPages); - if (!mXenInfo.HyperPages) { - return EFI_OUT_OF_RESOURCES; - } - - for (Index = 0; Index < TransferPages; Index++) { - AsmWriteMsr64 (TransferReg, - (UINTN) mXenInfo.HyperPages + - (Index << EFI_PAGE_SHIFT) + Index); - } - - AsmCpuid (XenLeaf + 1, &XenVersion, NULL, NULL, NULL); - DEBUG ((EFI_D_ERROR, "Detected Xen version %d.%d\n", - XenVersion >> 16, XenVersion & 0xFFFF)); - mXenInfo.VersionMajor = (UINT16)(XenVersion >> 16); - mXenInfo.VersionMinor = (UINT16)(XenVersion & 0xFFFF); - - /* TBD: Locate hvm_info and reserve it away. */ - mXenInfo.HvmInfo = NULL; - - BuildGuidDataHob ( - &gEfiXenInfoGuid, - &mXenInfo, - sizeof(mXenInfo) - ); - - return EFI_SUCCESS; -} - -/** - Figures out if we are running inside Xen HVM. - - @retval TRUE Xen was detected - @retval FALSE Xen was not detected - -**/ -BOOLEAN -XenDetect ( - VOID - ) -{ - UINT8 Signature[13]; - - if (mXenLeaf != 0) { - return TRUE; - } - - Signature[12] = '\0'; - for (mXenLeaf = 0x40000000; mXenLeaf < 0x40010000; mXenLeaf += 0x100) { - AsmCpuid (mXenLeaf, - NULL, - (UINT32 *) &Signature[0], - (UINT32 *) &Signature[4], - (UINT32 *) &Signature[8]); - - if (!AsciiStrCmp ((CHAR8 *) Signature, "XenVMMXenVMM")) { - mXen = TRUE; - return TRUE; - } - } - - mXenLeaf = 0; - return FALSE; -} - - -VOID -XenPublishRamRegions ( - VOID - ) -{ - EFI_E820_ENTRY64 *E820Map; - UINT32 E820EntriesCount; - EFI_STATUS Status; - - if (!mXen) { - return; - } - - DEBUG ((EFI_D_INFO, "Using memory map provided by Xen\n")); - - // - // Parse RAM in E820 map - // - E820EntriesCount = 0; - Status = XenGetE820Map (&E820Map, &E820EntriesCount); - - ASSERT_EFI_ERROR (Status); - - if (E820EntriesCount > 0) { - EFI_E820_ENTRY64 *Entry; - UINT32 Loop; - - for (Loop = 0; Loop < E820EntriesCount; Loop++) { - Entry = E820Map + Loop; - - // - // Only care about RAM - // - if (Entry->Type != EfiAcpiAddressRangeMemory) { - continue; - } - - AddMemoryBaseSizeHob (Entry->BaseAddr, Entry->Length); - - MtrrSetMemoryAttribute (Entry->BaseAddr, Entry->Length, CacheWriteBack); - } - } -} - - -/** - Perform Xen PEI initialization. - - @return EFI_SUCCESS Xen initialized successfully - @return EFI_NOT_FOUND Not running under Xen - -**/ -EFI_STATUS -InitializeXen ( - VOID - ) -{ - RETURN_STATUS PcdStatus; - - if (mXenLeaf == 0) { - return EFI_NOT_FOUND; - } - - XenConnect (mXenLeaf); - - // - // Reserve away HVMLOADER reserved memory [0xFC000000,0xFD000000). - // This needs to match HVMLOADER RESERVED_MEMBASE/RESERVED_MEMSIZE. - // - AddReservedMemoryBaseSizeHob (0xFC000000, 0x1000000, FALSE); - - PcdStatus = PcdSetBoolS (PcdPciDisableBusEnumeration, TRUE); - ASSERT_RETURN_ERROR (PcdStatus); - - return EFI_SUCCESS; -} diff --git a/OvmfPkg/PlatformPei/Xen.h b/OvmfPkg/PlatformPei/Xen.h deleted file mode 100644 index 2a8a32be6b..0000000000 --- a/OvmfPkg/PlatformPei/Xen.h +++ /dev/null @@ -1,45 +0,0 @@ -/** @file - Ovmf info structure passed by Xen - -Copyright (c) 2013, Citrix Systems UK Ltd.
- -This program and the accompanying materials are licensed and made available under -the terms and conditions of the BSD License that accompanies this distribution. -The full text of the license may be found at -http://opensource.org/licenses/bsd-license.php. - -THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, -WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. - -**/ - -#ifndef __XEN_H__ -#define __XEN_H__ - -#include - -// Physical address of OVMF info -#define OVMF_INFO_PHYSICAL_ADDRESS 0x00001000 - -// This structure must match the definition on Xen side -#pragma pack(1) -typedef struct { - CHAR8 Signature[14]; // XenHVMOVMF\0 - UINT8 Length; // Length of this structure - UINT8 Checksum; // Set such that the sum over bytes 0..length == 0 - // - // Physical address of an array of TablesCount elements. - // - // Each element contains the physical address of a BIOS table. - // - EFI_PHYSICAL_ADDRESS Tables; - UINT32 TablesCount; - // - // Physical address of the E820 table, contains E820EntriesCount entries. - // - EFI_PHYSICAL_ADDRESS E820; - UINT32 E820EntriesCount; -} EFI_XEN_OVMF_INFO; -#pragma pack() - -#endif /* __XEN_H__ */ diff --git a/OvmfPkg/QemuFlashFvbServicesRuntimeDxe/FvbInfo.c b/OvmfPkg/QemuFlashFvbServicesRuntimeDxe/FvbInfo.c deleted file mode 100644 index 6edbeed82f..0000000000 --- a/OvmfPkg/QemuFlashFvbServicesRuntimeDxe/FvbInfo.c +++ /dev/null @@ -1,135 +0,0 @@ -/**@file - - Copyright (c) 2006, Intel Corporation. All rights reserved.
- - This program and the accompanying materials are licensed and made available - under the terms and conditions of the BSD License which accompanies this - distribution. The full text of the license may be found at - http://opensource.org/licenses/bsd-license.php - - THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, - WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. - - Module Name: - - FvbInfo.c - - Abstract: - - Defines data structure that is the volume header found.These data is intent - to decouple FVB driver with FV header. - -**/ - -// -// The package level header files this module uses -// -#include - -// -// The protocols, PPI and GUID defintions for this module -// -#include -// -// The Library classes this module consumes -// -#include -#include - -typedef struct { - UINT64 FvLength; - EFI_FIRMWARE_VOLUME_HEADER FvbInfo; - // - // EFI_FV_BLOCK_MAP_ENTRY ExtraBlockMap[n];//n=0 - // - EFI_FV_BLOCK_MAP_ENTRY End[1]; -} EFI_FVB_MEDIA_INFO; - -EFI_FVB_MEDIA_INFO mPlatformFvbMediaInfo[] = { - // - // Systen NvStorage FVB - // - { - FixedPcdGet32 (PcdFlashNvStorageVariableSize) + - FixedPcdGet32 (PcdFlashNvStorageFtwWorkingSize) + - FixedPcdGet32 (PcdFlashNvStorageFtwSpareSize) + - FixedPcdGet32 (PcdOvmfFlashNvStorageEventLogSize), - { - { - 0, - }, // ZeroVector[16] - EFI_SYSTEM_NV_DATA_FV_GUID, - FixedPcdGet32 (PcdFlashNvStorageVariableSize) + - FixedPcdGet32 (PcdFlashNvStorageFtwWorkingSize) + - FixedPcdGet32 (PcdFlashNvStorageFtwSpareSize) + - FixedPcdGet32 (PcdOvmfFlashNvStorageEventLogSize), - EFI_FVH_SIGNATURE, - EFI_FVB2_MEMORY_MAPPED | - EFI_FVB2_READ_ENABLED_CAP | - EFI_FVB2_READ_STATUS | - EFI_FVB2_WRITE_ENABLED_CAP | - EFI_FVB2_WRITE_STATUS | - EFI_FVB2_ERASE_POLARITY | - EFI_FVB2_ALIGNMENT_16, - sizeof (EFI_FIRMWARE_VOLUME_HEADER) + sizeof (EFI_FV_BLOCK_MAP_ENTRY), - 0, // CheckSum - 0, // ExtHeaderOffset - { - 0, - }, // Reserved[1] - 2, // Revision - { - { - (FixedPcdGet32 (PcdFlashNvStorageVariableSize) + - FixedPcdGet32 (PcdFlashNvStorageFtwWorkingSize) + - FixedPcdGet32 (PcdFlashNvStorageFtwSpareSize) + - FixedPcdGet32 (PcdOvmfFlashNvStorageEventLogSize)) / - FixedPcdGet32 (PcdOvmfFirmwareBlockSize), - FixedPcdGet32 (PcdOvmfFirmwareBlockSize), - } - } // BlockMap[1] - }, - { - { - 0, - 0 - } - } // End[1] - } -}; - -EFI_STATUS -GetFvbInfo ( - IN UINT64 FvLength, - OUT EFI_FIRMWARE_VOLUME_HEADER **FvbInfo - ) -{ - STATIC BOOLEAN Checksummed = FALSE; - UINTN Index; - - if (!Checksummed) { - for (Index = 0; - Index < sizeof (mPlatformFvbMediaInfo) / sizeof (EFI_FVB_MEDIA_INFO); - Index += 1) { - UINT16 Checksum; - mPlatformFvbMediaInfo[Index].FvbInfo.Checksum = 0; - Checksum = CalculateCheckSum16 ( - (UINT16*) &mPlatformFvbMediaInfo[Index].FvbInfo, - mPlatformFvbMediaInfo[Index].FvbInfo.HeaderLength - ); - mPlatformFvbMediaInfo[Index].FvbInfo.Checksum = Checksum; - } - Checksummed = TRUE; - } - - for (Index = 0; - Index < sizeof (mPlatformFvbMediaInfo) / sizeof (EFI_FVB_MEDIA_INFO); - Index += 1) { - if (mPlatformFvbMediaInfo[Index].FvLength == FvLength) { - *FvbInfo = &mPlatformFvbMediaInfo[Index].FvbInfo; - return EFI_SUCCESS; - } - } - - return EFI_NOT_FOUND; -} diff --git a/OvmfPkg/QemuFlashFvbServicesRuntimeDxe/FvbServicesRuntimeDxe.inf b/OvmfPkg/QemuFlashFvbServicesRuntimeDxe/FvbServicesRuntimeDxe.inf deleted file mode 100644 index c0dda75bf7..0000000000 --- a/OvmfPkg/QemuFlashFvbServicesRuntimeDxe/FvbServicesRuntimeDxe.inf +++ /dev/null @@ -1,92 +0,0 @@ -## @file -# Component description file for QEMU Flash Fimware Volume Block DXE driver -# module. -# -# This DXE runtime driver implements and produces the Fimware Volue Block -# Protocol for a QEMU flash device. -# -# Copyright (c) 2006 - 2013, Intel Corporation. All rights reserved.
-# -# This program and the accompanying materials are licensed and made available -# under the terms and conditions of the BSD License which accompanies this -# distribution. The full text of the license may be found at -# http://opensource.org/licenses/bsd-license.php -# -# THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, -# WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR -# IMPLIED. -# -## - -[Defines] - INF_VERSION = 0x00010005 - BASE_NAME = FvbServicesRuntimeDxe - FILE_GUID = 733cbac2-b23f-4b92-bc8e-fb01ce5907b7 - MODULE_TYPE = DXE_RUNTIME_DRIVER - VERSION_STRING = 1.0 - ENTRY_POINT = FvbInitialize - -# -# The following information is for reference only and not required by the build -# tools. -# -# VALID_ARCHITECTURES = IA32 X64 -# - -[Sources] - FvbInfo.c - FwBlockService.c - FwBlockServiceDxe.c - QemuFlash.c - QemuFlashDxe.c - -[Packages] - MdePkg/MdePkg.dec - MdeModulePkg/MdeModulePkg.dec - OvmfPkg/OvmfPkg.dec - -[LibraryClasses] - BaseLib - BaseMemoryLib - DebugLib - DevicePathLib - DxeServicesTableLib - MemoryAllocationLib - PcdLib - UefiBootServicesTableLib - UefiDriverEntryPoint - UefiRuntimeLib - -[Guids] - gEfiEventVirtualAddressChangeGuid # ALWAYS_CONSUMED - # gEfiEventVirtualAddressChangeGuid # Create Event: EVENT_GROUP_GUID - -[Protocols] - gEfiFirmwareVolumeBlockProtocolGuid # PROTOCOL SOMETIMES_PRODUCED - gEfiDevicePathProtocolGuid # PROTOCOL SOMETIMES_PRODUCED - -[FixedPcd] - gEfiMdeModulePkgTokenSpaceGuid.PcdFlashNvStorageVariableSize - gEfiMdeModulePkgTokenSpaceGuid.PcdFlashNvStorageFtwWorkingSize - gEfiMdeModulePkgTokenSpaceGuid.PcdFlashNvStorageFtwSpareSize - gUefiOvmfPkgTokenSpaceGuid.PcdOvmfFlashNvStorageVariableBase - gUefiOvmfPkgTokenSpaceGuid.PcdOvmfFlashNvStorageFtwWorkingBase - gUefiOvmfPkgTokenSpaceGuid.PcdOvmfFlashNvStorageFtwSpareBase - gUefiOvmfPkgTokenSpaceGuid.PcdOvmfFlashNvStorageEventLogSize - gUefiOvmfPkgTokenSpaceGuid.PcdOvmfFdBaseAddress - gUefiOvmfPkgTokenSpaceGuid.PcdOvmfFirmwareFdSize - gUefiOvmfPkgTokenSpaceGuid.PcdOvmfFirmwareBlockSize - -[Pcd] - gEfiMdeModulePkgTokenSpaceGuid.PcdFlashNvStorageFtwWorkingBase - gEfiMdeModulePkgTokenSpaceGuid.PcdFlashNvStorageFtwSpareBase - gEfiMdeModulePkgTokenSpaceGuid.PcdFlashNvStorageVariableBase - gUefiOvmfPkgTokenSpaceGuid.PcdOvmfFlashNvStorageEventLogBase - gEfiMdeModulePkgTokenSpaceGuid.PcdFlashNvStorageVariableBase64 - gUefiOvmfPkgTokenSpaceGuid.PcdOvmfFlashVariablesEnable - -[FeaturePcd] - gUefiOvmfPkgTokenSpaceGuid.PcdSmmSmramRequire - -[Depex] - TRUE diff --git a/OvmfPkg/QemuFlashFvbServicesRuntimeDxe/FvbServicesSmm.inf b/OvmfPkg/QemuFlashFvbServicesRuntimeDxe/FvbServicesSmm.inf deleted file mode 100644 index ba2d3679a4..0000000000 --- a/OvmfPkg/QemuFlashFvbServicesRuntimeDxe/FvbServicesSmm.inf +++ /dev/null @@ -1,91 +0,0 @@ -## @file -# Component description file for QEMU Flash Fimware Volume Block SMM driver -# module. -# -# This SMM driver implements and produces the SMM Fimware Volue Block Protocol -# for a QEMU flash device. -# -# Copyright (C) 2015, Red Hat, Inc. -# Copyright (c) 2006 - 2013, Intel Corporation. All rights reserved.
-# -# This program and the accompanying materials are licensed and made available -# under the terms and conditions of the BSD License which accompanies this -# distribution. The full text of the license may be found at -# http://opensource.org/licenses/bsd-license.php -# -# THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, -# WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR -# IMPLIED. -# -## - -[Defines] - INF_VERSION = 0x00010005 - BASE_NAME = FvbServicesSmm - FILE_GUID = 2E7DB7A7-608E-4041-B45F-00359E0766C6 - MODULE_TYPE = DXE_SMM_DRIVER - VERSION_STRING = 1.0 - PI_SPECIFICATION_VERSION = 0x0001000A - ENTRY_POINT = FvbInitialize - -# -# The following information is for reference only and not required by the build -# tools. -# -# VALID_ARCHITECTURES = IA32 X64 -# - -[Sources] - FvbInfo.c - FwBlockService.c - FwBlockServiceSmm.c - QemuFlash.c - -[Packages] - MdePkg/MdePkg.dec - MdeModulePkg/MdeModulePkg.dec - OvmfPkg/OvmfPkg.dec - -[LibraryClasses] - BaseLib - BaseMemoryLib - DebugLib - DevicePathLib - DxeServicesTableLib - MemoryAllocationLib - PcdLib - SmmServicesTableLib - UefiBootServicesTableLib - UefiDriverEntryPoint - -[Guids] - -[Protocols] - gEfiSmmFirmwareVolumeBlockProtocolGuid # PROTOCOL ALWAYS_PRODUCED - gEfiDevicePathProtocolGuid # PROTOCOL ALWAYS_PRODUCED - -[FixedPcd] - gEfiMdeModulePkgTokenSpaceGuid.PcdFlashNvStorageVariableSize - gEfiMdeModulePkgTokenSpaceGuid.PcdFlashNvStorageFtwWorkingSize - gEfiMdeModulePkgTokenSpaceGuid.PcdFlashNvStorageFtwSpareSize - gUefiOvmfPkgTokenSpaceGuid.PcdOvmfFlashNvStorageVariableBase - gUefiOvmfPkgTokenSpaceGuid.PcdOvmfFlashNvStorageFtwWorkingBase - gUefiOvmfPkgTokenSpaceGuid.PcdOvmfFlashNvStorageFtwSpareBase - gUefiOvmfPkgTokenSpaceGuid.PcdOvmfFlashNvStorageEventLogSize - gUefiOvmfPkgTokenSpaceGuid.PcdOvmfFdBaseAddress - gUefiOvmfPkgTokenSpaceGuid.PcdOvmfFirmwareFdSize - gUefiOvmfPkgTokenSpaceGuid.PcdOvmfFirmwareBlockSize - -[Pcd] - gEfiMdeModulePkgTokenSpaceGuid.PcdFlashNvStorageFtwWorkingBase - gEfiMdeModulePkgTokenSpaceGuid.PcdFlashNvStorageFtwSpareBase - gEfiMdeModulePkgTokenSpaceGuid.PcdFlashNvStorageVariableBase - gUefiOvmfPkgTokenSpaceGuid.PcdOvmfFlashNvStorageEventLogBase - gEfiMdeModulePkgTokenSpaceGuid.PcdFlashNvStorageVariableBase64 - gUefiOvmfPkgTokenSpaceGuid.PcdOvmfFlashVariablesEnable - -[FeaturePcd] - gUefiOvmfPkgTokenSpaceGuid.PcdSmmSmramRequire - -[Depex] - TRUE diff --git a/OvmfPkg/QemuFlashFvbServicesRuntimeDxe/FwBlockService.c b/OvmfPkg/QemuFlashFvbServicesRuntimeDxe/FwBlockService.c deleted file mode 100644 index ff27c1100c..0000000000 --- a/OvmfPkg/QemuFlashFvbServicesRuntimeDxe/FwBlockService.c +++ /dev/null @@ -1,1129 +0,0 @@ -/**@file - - Copyright (c) 2006 - 2014, Intel Corporation. All rights reserved.
- - This program and the accompanying materials are licensed and made available - under the terms and conditions of the BSD License which accompanies this - distribution. The full text of the license may be found at - http://opensource.org/licenses/bsd-license.php - - THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, - WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. - - Module Name: - - FWBlockService.c - - Abstract: - - Revision History - -**/ - -// -// The protocols, PPI and GUID defintions for this module -// -#include -#include - -// -// The Library classes this module consumes -// -#include -#include -#include -#include -#include -#include -#include - -#include "FwBlockService.h" -#include "QemuFlash.h" - -#define EFI_FVB2_STATUS \ - (EFI_FVB2_READ_STATUS | EFI_FVB2_WRITE_STATUS | EFI_FVB2_LOCK_STATUS) - -ESAL_FWB_GLOBAL *mFvbModuleGlobal; - -FV_MEMMAP_DEVICE_PATH mFvMemmapDevicePathTemplate = { - { - { - HARDWARE_DEVICE_PATH, - HW_MEMMAP_DP, - { - (UINT8)(sizeof (MEMMAP_DEVICE_PATH)), - (UINT8)(sizeof (MEMMAP_DEVICE_PATH) >> 8) - } - }, - EfiMemoryMappedIO, - (EFI_PHYSICAL_ADDRESS) 0, - (EFI_PHYSICAL_ADDRESS) 0, - }, - { - END_DEVICE_PATH_TYPE, - END_ENTIRE_DEVICE_PATH_SUBTYPE, - { - END_DEVICE_PATH_LENGTH, - 0 - } - } -}; - -FV_PIWG_DEVICE_PATH mFvPIWGDevicePathTemplate = { - { - { - MEDIA_DEVICE_PATH, - MEDIA_PIWG_FW_VOL_DP, - { - (UINT8)(sizeof (MEDIA_FW_VOL_DEVICE_PATH)), - (UINT8)(sizeof (MEDIA_FW_VOL_DEVICE_PATH) >> 8) - } - }, - { 0 } - }, - { - END_DEVICE_PATH_TYPE, - END_ENTIRE_DEVICE_PATH_SUBTYPE, - { - END_DEVICE_PATH_LENGTH, - 0 - } - } -}; - -EFI_FW_VOL_BLOCK_DEVICE mFvbDeviceTemplate = { - FVB_DEVICE_SIGNATURE, - NULL, - 0, - { - FvbProtocolGetAttributes, - FvbProtocolSetAttributes, - FvbProtocolGetPhysicalAddress, - FvbProtocolGetBlockSize, - FvbProtocolRead, - FvbProtocolWrite, - FvbProtocolEraseBlocks, - NULL - } -}; - - -EFI_STATUS -GetFvbInstance ( - IN UINTN Instance, - IN ESAL_FWB_GLOBAL *Global, - OUT EFI_FW_VOL_INSTANCE **FwhInstance - ) -/*++ - - Routine Description: - Retrieves the physical address of a memory mapped FV - - Arguments: - Instance - The FV instance whose base address is going to be - returned - Global - Pointer to ESAL_FWB_GLOBAL that contains all - instance data - FwhInstance - The EFI_FW_VOL_INSTANCE fimrware instance structure - - Returns: - EFI_SUCCESS - Successfully returns - EFI_INVALID_PARAMETER - Instance not found - ---*/ -{ - EFI_FW_VOL_INSTANCE *FwhRecord; - - *FwhInstance = NULL; - if (Instance >= Global->NumFv) { - return EFI_INVALID_PARAMETER; - } - // - // Find the right instance of the FVB private data - // - FwhRecord = Global->FvInstance; - while (Instance > 0) { - FwhRecord = (EFI_FW_VOL_INSTANCE *) - ( - (UINTN) ((UINT8 *) FwhRecord) + FwhRecord->VolumeHeader.HeaderLength + - (sizeof (EFI_FW_VOL_INSTANCE) - sizeof (EFI_FIRMWARE_VOLUME_HEADER)) - ); - Instance--; - } - - *FwhInstance = FwhRecord; - - return EFI_SUCCESS; -} - -EFI_STATUS -FvbGetPhysicalAddress ( - IN UINTN Instance, - OUT EFI_PHYSICAL_ADDRESS *Address, - IN ESAL_FWB_GLOBAL *Global - ) -/*++ - - Routine Description: - Retrieves the physical address of a memory mapped FV - - Arguments: - Instance - The FV instance whose base address is going to be - returned - Address - Pointer to a caller allocated EFI_PHYSICAL_ADDRESS - that on successful return, contains the base - address of the firmware volume. - Global - Pointer to ESAL_FWB_GLOBAL that contains all - instance data - - Returns: - EFI_SUCCESS - Successfully returns - EFI_INVALID_PARAMETER - Instance not found - ---*/ -{ - EFI_FW_VOL_INSTANCE *FwhInstance; - EFI_STATUS Status; - - // - // Find the right instance of the FVB private data - // - Status = GetFvbInstance (Instance, Global, &FwhInstance); - ASSERT_EFI_ERROR (Status); - *Address = FwhInstance->FvBase; - - return EFI_SUCCESS; -} - -EFI_STATUS -FvbGetVolumeAttributes ( - IN UINTN Instance, - OUT EFI_FVB_ATTRIBUTES_2 *Attributes, - IN ESAL_FWB_GLOBAL *Global - ) -/*++ - - Routine Description: - Retrieves attributes, insures positive polarity of attribute bits, returns - resulting attributes in output parameter - - Arguments: - Instance - The FV instance whose attributes is going to be - returned - Attributes - Output buffer which contains attributes - Global - Pointer to ESAL_FWB_GLOBAL that contains all - instance data - - Returns: - EFI_SUCCESS - Successfully returns - EFI_INVALID_PARAMETER - Instance not found - ---*/ -{ - EFI_FW_VOL_INSTANCE *FwhInstance; - EFI_STATUS Status; - - // - // Find the right instance of the FVB private data - // - Status = GetFvbInstance (Instance, Global, &FwhInstance); - ASSERT_EFI_ERROR (Status); - *Attributes = FwhInstance->VolumeHeader.Attributes; - - return EFI_SUCCESS; -} - -EFI_STATUS -FvbGetLbaAddress ( - IN UINTN Instance, - IN EFI_LBA Lba, - OUT UINTN *LbaAddress, - OUT UINTN *LbaLength, - OUT UINTN *NumOfBlocks, - IN ESAL_FWB_GLOBAL *Global - ) -/*++ - - Routine Description: - Retrieves the starting address of an LBA in an FV - - Arguments: - Instance - The FV instance which the Lba belongs to - Lba - The logical block address - LbaAddress - On output, contains the physical starting address - of the Lba - LbaLength - On output, contains the length of the block - NumOfBlocks - A pointer to a caller allocated UINTN in which the - number of consecutive blocks starting with Lba is - returned. All blocks in this range have a size of - BlockSize - Global - Pointer to ESAL_FWB_GLOBAL that contains all - instance data - - Returns: - EFI_SUCCESS - Successfully returns - EFI_INVALID_PARAMETER - Instance not found - ---*/ -{ - UINT32 NumBlocks; - UINT32 BlockLength; - UINTN Offset; - EFI_LBA StartLba; - EFI_LBA NextLba; - EFI_FW_VOL_INSTANCE *FwhInstance; - EFI_FV_BLOCK_MAP_ENTRY *BlockMap; - EFI_STATUS Status; - - // - // Find the right instance of the FVB private data - // - Status = GetFvbInstance (Instance, Global, &FwhInstance); - ASSERT_EFI_ERROR (Status); - - StartLba = 0; - Offset = 0; - BlockMap = &(FwhInstance->VolumeHeader.BlockMap[0]); - - // - // Parse the blockmap of the FV to find which map entry the Lba belongs to - // - while (TRUE) { - NumBlocks = BlockMap->NumBlocks; - BlockLength = BlockMap->Length; - - if (NumBlocks == 0 || BlockLength == 0) { - return EFI_INVALID_PARAMETER; - } - - NextLba = StartLba + NumBlocks; - - // - // The map entry found - // - if (Lba >= StartLba && Lba < NextLba) { - Offset = Offset + (UINTN) MultU64x32 ((Lba - StartLba), BlockLength); - if (LbaAddress != NULL) { - *LbaAddress = FwhInstance->FvBase + Offset; - } - - if (LbaLength != NULL) { - *LbaLength = BlockLength; - } - - if (NumOfBlocks != NULL) { - *NumOfBlocks = (UINTN) (NextLba - Lba); - } - - return EFI_SUCCESS; - } - - StartLba = NextLba; - Offset = Offset + NumBlocks * BlockLength; - BlockMap++; - } -} - -EFI_STATUS -FvbSetVolumeAttributes ( - IN UINTN Instance, - IN OUT EFI_FVB_ATTRIBUTES_2 *Attributes, - IN ESAL_FWB_GLOBAL *Global - ) -/*++ - - Routine Description: - Modifies the current settings of the firmware volume according to the - input parameter, and returns the new setting of the volume - - Arguments: - Instance - The FV instance whose attributes is going to be - modified - Attributes - On input, it is a pointer to EFI_FVB_ATTRIBUTES_2 - containing the desired firmware volume settings. - On successful return, it contains the new settings - of the firmware volume - Global - Pointer to ESAL_FWB_GLOBAL that contains all - instance data - - Returns: - EFI_SUCCESS - Successfully returns - EFI_ACCESS_DENIED - The volume setting is locked and cannot be modified - EFI_INVALID_PARAMETER - Instance not found, or The attributes requested are - in conflict with the capabilities as declared in - the firmware volume header - ---*/ -{ - EFI_FW_VOL_INSTANCE *FwhInstance; - EFI_FVB_ATTRIBUTES_2 OldAttributes; - EFI_FVB_ATTRIBUTES_2 *AttribPtr; - UINT32 Capabilities; - UINT32 OldStatus; - UINT32 NewStatus; - EFI_STATUS Status; - EFI_FVB_ATTRIBUTES_2 UnchangedAttributes; - - // - // Find the right instance of the FVB private data - // - Status = GetFvbInstance (Instance, Global, &FwhInstance); - ASSERT_EFI_ERROR (Status); - - AttribPtr = - (EFI_FVB_ATTRIBUTES_2 *) &(FwhInstance->VolumeHeader.Attributes); - OldAttributes = *AttribPtr; - Capabilities = OldAttributes & (EFI_FVB2_READ_DISABLED_CAP | \ - EFI_FVB2_READ_ENABLED_CAP | \ - EFI_FVB2_WRITE_DISABLED_CAP | \ - EFI_FVB2_WRITE_ENABLED_CAP | \ - EFI_FVB2_LOCK_CAP \ - ); - OldStatus = OldAttributes & EFI_FVB2_STATUS; - NewStatus = *Attributes & EFI_FVB2_STATUS; - - UnchangedAttributes = EFI_FVB2_READ_DISABLED_CAP | \ - EFI_FVB2_READ_ENABLED_CAP | \ - EFI_FVB2_WRITE_DISABLED_CAP | \ - EFI_FVB2_WRITE_ENABLED_CAP | \ - EFI_FVB2_LOCK_CAP | \ - EFI_FVB2_STICKY_WRITE | \ - EFI_FVB2_MEMORY_MAPPED | \ - EFI_FVB2_ERASE_POLARITY | \ - EFI_FVB2_READ_LOCK_CAP | \ - EFI_FVB2_WRITE_LOCK_CAP | \ - EFI_FVB2_ALIGNMENT; - - // - // Some attributes of FV is read only can *not* be set - // - if ((OldAttributes & UnchangedAttributes) ^ - (*Attributes & UnchangedAttributes)) { - return EFI_INVALID_PARAMETER; - } - // - // If firmware volume is locked, no status bit can be updated - // - if (OldAttributes & EFI_FVB2_LOCK_STATUS) { - if (OldStatus ^ NewStatus) { - return EFI_ACCESS_DENIED; - } - } - // - // Test read disable - // - if ((Capabilities & EFI_FVB2_READ_DISABLED_CAP) == 0) { - if ((NewStatus & EFI_FVB2_READ_STATUS) == 0) { - return EFI_INVALID_PARAMETER; - } - } - // - // Test read enable - // - if ((Capabilities & EFI_FVB2_READ_ENABLED_CAP) == 0) { - if (NewStatus & EFI_FVB2_READ_STATUS) { - return EFI_INVALID_PARAMETER; - } - } - // - // Test write disable - // - if ((Capabilities & EFI_FVB2_WRITE_DISABLED_CAP) == 0) { - if ((NewStatus & EFI_FVB2_WRITE_STATUS) == 0) { - return EFI_INVALID_PARAMETER; - } - } - // - // Test write enable - // - if ((Capabilities & EFI_FVB2_WRITE_ENABLED_CAP) == 0) { - if (NewStatus & EFI_FVB2_WRITE_STATUS) { - return EFI_INVALID_PARAMETER; - } - } - // - // Test lock - // - if ((Capabilities & EFI_FVB2_LOCK_CAP) == 0) { - if (NewStatus & EFI_FVB2_LOCK_STATUS) { - return EFI_INVALID_PARAMETER; - } - } - - *AttribPtr = (*AttribPtr) & (0xFFFFFFFF & (~EFI_FVB2_STATUS)); - *AttribPtr = (*AttribPtr) | NewStatus; - *Attributes = *AttribPtr; - - return EFI_SUCCESS; -} - -// -// FVB protocol APIs -// -EFI_STATUS -EFIAPI -FvbProtocolGetPhysicalAddress ( - IN CONST EFI_FIRMWARE_VOLUME_BLOCK_PROTOCOL *This, - OUT EFI_PHYSICAL_ADDRESS *Address - ) -/*++ - - Routine Description: - - Retrieves the physical address of the device. - - Arguments: - - This - Calling context - Address - Output buffer containing the address. - - Returns: - EFI_SUCCESS - Successfully returns - ---*/ -{ - EFI_FW_VOL_BLOCK_DEVICE *FvbDevice; - - FvbDevice = FVB_DEVICE_FROM_THIS (This); - - return FvbGetPhysicalAddress (FvbDevice->Instance, Address, - mFvbModuleGlobal); -} - -EFI_STATUS -EFIAPI -FvbProtocolGetBlockSize ( - IN CONST EFI_FIRMWARE_VOLUME_BLOCK_PROTOCOL *This, - IN CONST EFI_LBA Lba, - OUT UINTN *BlockSize, - OUT UINTN *NumOfBlocks - ) -/*++ - - Routine Description: - Retrieve the size of a logical block - - Arguments: - This - Calling context - Lba - Indicates which block to return the size for. - BlockSize - A pointer to a caller allocated UINTN in which - the size of the block is returned - NumOfBlocks - a pointer to a caller allocated UINTN in which the - number of consecutive blocks starting with Lba is - returned. All blocks in this range have a size of - BlockSize - - Returns: - EFI_SUCCESS - The firmware volume was read successfully and - contents are in Buffer - ---*/ -{ - EFI_FW_VOL_BLOCK_DEVICE *FvbDevice; - - FvbDevice = FVB_DEVICE_FROM_THIS (This); - - return FvbGetLbaAddress ( - FvbDevice->Instance, - Lba, - NULL, - BlockSize, - NumOfBlocks, - mFvbModuleGlobal - ); -} - -EFI_STATUS -EFIAPI -FvbProtocolGetAttributes ( - IN CONST EFI_FIRMWARE_VOLUME_BLOCK_PROTOCOL *This, - OUT EFI_FVB_ATTRIBUTES_2 *Attributes - ) -/*++ - - Routine Description: - Retrieves Volume attributes. No polarity translations are done. - - Arguments: - This - Calling context - Attributes - output buffer which contains attributes - - Returns: - EFI_SUCCESS - Successfully returns - ---*/ -{ - EFI_FW_VOL_BLOCK_DEVICE *FvbDevice; - - FvbDevice = FVB_DEVICE_FROM_THIS (This); - - return FvbGetVolumeAttributes (FvbDevice->Instance, Attributes, - mFvbModuleGlobal); -} - -EFI_STATUS -EFIAPI -FvbProtocolSetAttributes ( - IN CONST EFI_FIRMWARE_VOLUME_BLOCK_PROTOCOL *This, - IN OUT EFI_FVB_ATTRIBUTES_2 *Attributes - ) -/*++ - - Routine Description: - Sets Volume attributes. No polarity translations are done. - - Arguments: - This - Calling context - Attributes - output buffer which contains attributes - - Returns: - EFI_SUCCESS - Successfully returns - ---*/ -{ - EFI_FW_VOL_BLOCK_DEVICE *FvbDevice; - - FvbDevice = FVB_DEVICE_FROM_THIS (This); - - return FvbSetVolumeAttributes (FvbDevice->Instance, Attributes, - mFvbModuleGlobal); -} - -EFI_STATUS -EFIAPI -FvbProtocolEraseBlocks ( - IN CONST EFI_FIRMWARE_VOLUME_BLOCK_PROTOCOL *This, - ... - ) -/*++ - - Routine Description: - - The EraseBlock() function erases one or more blocks as denoted by the - variable argument list. The entire parameter list of blocks must be - verified prior to erasing any blocks. If a block is requested that does - not exist within the associated firmware volume (it has a larger index than - the last block of the firmware volume), the EraseBlock() function must - return EFI_INVALID_PARAMETER without modifying the contents of the firmware - volume. - - Arguments: - This - Calling context - ... - Starting LBA followed by Number of Lba to erase. - a -1 to terminate the list. - - Returns: - EFI_SUCCESS - The erase request was successfully completed - EFI_ACCESS_DENIED - The firmware volume is in the WriteDisabled state - EFI_DEVICE_ERROR - The block device is not functioning correctly and - could not be written. Firmware device may have been - partially erased - ---*/ -{ - EFI_FW_VOL_BLOCK_DEVICE *FvbDevice; - EFI_FW_VOL_INSTANCE *FwhInstance; - UINTN NumOfBlocks; - VA_LIST args; - EFI_LBA StartingLba; - UINTN NumOfLba; - EFI_STATUS Status; - - FvbDevice = FVB_DEVICE_FROM_THIS (This); - - Status = GetFvbInstance (FvbDevice->Instance, mFvbModuleGlobal, - &FwhInstance); - ASSERT_EFI_ERROR (Status); - - NumOfBlocks = FwhInstance->NumOfBlocks; - - VA_START (args, This); - - do { - StartingLba = VA_ARG (args, EFI_LBA); - if (StartingLba == EFI_LBA_LIST_TERMINATOR) { - break; - } - - NumOfLba = VA_ARG (args, UINT32); - - // - // Check input parameters - // - if ((NumOfLba == 0) || ((StartingLba + NumOfLba) > NumOfBlocks)) { - VA_END (args); - return EFI_INVALID_PARAMETER; - } - } while (1); - - VA_END (args); - - VA_START (args, This); - do { - StartingLba = VA_ARG (args, EFI_LBA); - if (StartingLba == EFI_LBA_LIST_TERMINATOR) { - break; - } - - NumOfLba = VA_ARG (args, UINT32); - - while (NumOfLba > 0) { - Status = QemuFlashEraseBlock (StartingLba); - if (EFI_ERROR (Status)) { - VA_END (args); - return Status; - } - - StartingLba++; - NumOfLba--; - } - - } while (1); - - VA_END (args); - - return EFI_SUCCESS; -} - -EFI_STATUS -EFIAPI -FvbProtocolWrite ( - IN CONST EFI_FIRMWARE_VOLUME_BLOCK_PROTOCOL *This, - IN EFI_LBA Lba, - IN UINTN Offset, - IN OUT UINTN *NumBytes, - IN UINT8 *Buffer - ) -/*++ - - Routine Description: - - Writes data beginning at Lba:Offset from FV. The write terminates either - when *NumBytes of data have been written, or when a block boundary is - reached. *NumBytes is updated to reflect the actual number of bytes - written. The write opertion does not include erase. This routine will - attempt to write only the specified bytes. If the writes do not stick, - it will return an error. - - Arguments: - This - Calling context - Lba - Block in which to begin write - Offset - Offset in the block at which to begin write - NumBytes - On input, indicates the requested write size. On - output, indicates the actual number of bytes - written - Buffer - Buffer containing source data for the write. - - Returns: - EFI_SUCCESS - The firmware volume was written successfully - EFI_BAD_BUFFER_SIZE - Write attempted across a LBA boundary. On output, - NumBytes contains the total number of bytes - actually written - EFI_ACCESS_DENIED - The firmware volume is in the WriteDisabled state - EFI_DEVICE_ERROR - The block device is not functioning correctly and - could not be written - EFI_INVALID_PARAMETER - NumBytes or Buffer are NULL - ---*/ -{ - return QemuFlashWrite ((EFI_LBA)Lba, (UINTN)Offset, NumBytes, - (UINT8 *)Buffer); -} - -EFI_STATUS -EFIAPI -FvbProtocolRead ( - IN CONST EFI_FIRMWARE_VOLUME_BLOCK_PROTOCOL *This, - IN CONST EFI_LBA Lba, - IN CONST UINTN Offset, - IN OUT UINTN *NumBytes, - IN UINT8 *Buffer - ) -/*++ - - Routine Description: - - Reads data beginning at Lba:Offset from FV. The Read terminates either - when *NumBytes of data have been read, or when a block boundary is - reached. *NumBytes is updated to reflect the actual number of bytes - written. The write opertion does not include erase. This routine will - attempt to write only the specified bytes. If the writes do not stick, - it will return an error. - - Arguments: - This - Calling context - Lba - Block in which to begin Read - Offset - Offset in the block at which to begin Read - NumBytes - On input, indicates the requested write size. On - output, indicates the actual number of bytes Read - Buffer - Buffer containing source data for the Read. - - Returns: - EFI_SUCCESS - The firmware volume was read successfully and - contents are in Buffer - EFI_BAD_BUFFER_SIZE - Read attempted across a LBA boundary. On output, - NumBytes contains the total number of bytes - returned in Buffer - EFI_ACCESS_DENIED - The firmware volume is in the ReadDisabled state - EFI_DEVICE_ERROR - The block device is not functioning correctly and - could not be read - EFI_INVALID_PARAMETER - NumBytes or Buffer are NULL - ---*/ -{ - return QemuFlashRead ((EFI_LBA)Lba, (UINTN)Offset, NumBytes, - (UINT8 *)Buffer); -} - -EFI_STATUS -ValidateFvHeader ( - EFI_FIRMWARE_VOLUME_HEADER *FwVolHeader - ) -/*++ - - Routine Description: - Check the integrity of firmware volume header - - Arguments: - FwVolHeader - A pointer to a firmware volume header - - Returns: - EFI_SUCCESS - The firmware volume is consistent - EFI_NOT_FOUND - The firmware volume has corrupted. So it is not an - FV - ---*/ -{ - UINT16 Checksum; - - // - // Verify the header revision, header signature, length - // Length of FvBlock cannot be 2**64-1 - // HeaderLength cannot be an odd number - // - if ((FwVolHeader->Revision != EFI_FVH_REVISION) || - (FwVolHeader->Signature != EFI_FVH_SIGNATURE) || - (FwVolHeader->FvLength == ((UINTN) -1)) || - ((FwVolHeader->HeaderLength & 0x01) != 0) - ) { - return EFI_NOT_FOUND; - } - - // - // Verify the header checksum - // - - Checksum = CalculateSum16 ((UINT16 *) FwVolHeader, - FwVolHeader->HeaderLength); - if (Checksum != 0) { - UINT16 Expected; - - Expected = - (UINT16) (((UINTN) FwVolHeader->Checksum + 0x10000 - Checksum) & 0xffff); - - DEBUG ((EFI_D_INFO, "FV@%p Checksum is 0x%x, expected 0x%x\n", - FwVolHeader, FwVolHeader->Checksum, Expected)); - return EFI_NOT_FOUND; - } - - return EFI_SUCCESS; -} - -STATIC -EFI_STATUS -MarkMemoryRangeForRuntimeAccess ( - EFI_PHYSICAL_ADDRESS BaseAddress, - UINTN Length - ) -{ - EFI_STATUS Status; - - // - // Mark flash region as runtime memory - // - Status = gDS->RemoveMemorySpace ( - BaseAddress, - Length - ); - - Status = gDS->AddMemorySpace ( - EfiGcdMemoryTypeSystemMemory, - BaseAddress, - Length, - EFI_MEMORY_UC | EFI_MEMORY_RUNTIME - ); - ASSERT_EFI_ERROR (Status); - - Status = gBS->AllocatePages ( - AllocateAddress, - EfiRuntimeServicesData, - EFI_SIZE_TO_PAGES (Length), - &BaseAddress - ); - ASSERT_EFI_ERROR (Status); - - return Status; -} - -STATIC -EFI_STATUS -InitializeVariableFvHeader ( - VOID - ) -{ - EFI_STATUS Status; - EFI_FIRMWARE_VOLUME_HEADER *GoodFwVolHeader; - EFI_FIRMWARE_VOLUME_HEADER *FwVolHeader; - UINTN Length; - UINTN WriteLength; - UINTN BlockSize; - - FwVolHeader = - (EFI_FIRMWARE_VOLUME_HEADER *) (UINTN) - PcdGet32 (PcdOvmfFlashNvStorageVariableBase); - - Length = - (FixedPcdGet32 (PcdFlashNvStorageVariableSize) + - FixedPcdGet32 (PcdFlashNvStorageFtwWorkingSize) + - FixedPcdGet32 (PcdFlashNvStorageFtwSpareSize) + - FixedPcdGet32 (PcdOvmfFlashNvStorageEventLogSize)); - - BlockSize = PcdGet32 (PcdOvmfFirmwareBlockSize); - - Status = ValidateFvHeader (FwVolHeader); - if (!EFI_ERROR (Status)) { - if (FwVolHeader->FvLength != Length || - FwVolHeader->BlockMap[0].Length != BlockSize) { - Status = EFI_VOLUME_CORRUPTED; - } - } - if (EFI_ERROR (Status)) { - UINTN Offset; - UINTN Start; - - DEBUG ((EFI_D_INFO, - "Variable FV header is not valid. It will be reinitialized.\n")); - - // - // Get FvbInfo to provide in FwhInstance. - // - Status = GetFvbInfo (Length, &GoodFwVolHeader); - ASSERT (!EFI_ERROR (Status)); - - Start = (UINTN)(UINT8*) FwVolHeader - PcdGet32 (PcdOvmfFdBaseAddress); - ASSERT (Start % BlockSize == 0 && Length % BlockSize == 0); - ASSERT (GoodFwVolHeader->HeaderLength <= BlockSize); - - // - // Erase all the blocks - // - for (Offset = Start; Offset < Start + Length; Offset += BlockSize) { - Status = QemuFlashEraseBlock (Offset / BlockSize); - ASSERT_EFI_ERROR (Status); - } - - // - // Write good FV header - // - WriteLength = GoodFwVolHeader->HeaderLength; - Status = QemuFlashWrite ( - Start / BlockSize, - 0, - &WriteLength, - (UINT8 *) GoodFwVolHeader); - ASSERT_EFI_ERROR (Status); - ASSERT (WriteLength == GoodFwVolHeader->HeaderLength); - } - - return Status; -} - -EFI_STATUS -EFIAPI -FvbInitialize ( - IN EFI_HANDLE ImageHandle, - IN EFI_SYSTEM_TABLE *SystemTable - ) -/*++ - - Routine Description: - This function does common initialization for FVB services - - Arguments: - - Returns: - ---*/ -{ - EFI_STATUS Status; - EFI_FW_VOL_INSTANCE *FwhInstance; - EFI_FIRMWARE_VOLUME_HEADER *FwVolHeader; - UINT32 BufferSize; - EFI_FV_BLOCK_MAP_ENTRY *PtrBlockMapEntry; - EFI_FW_VOL_BLOCK_DEVICE *FvbDevice; - UINT32 MaxLbaSize; - EFI_PHYSICAL_ADDRESS BaseAddress; - UINTN Length; - UINTN NumOfBlocks; - RETURN_STATUS PcdStatus; - - if (EFI_ERROR (QemuFlashInitialize ())) { - // - // Return an error so image will be unloaded - // - DEBUG ((EFI_D_INFO, - "QEMU flash was not detected. Writable FVB is not being installed.\n")); - return EFI_WRITE_PROTECTED; - } - - // - // Allocate runtime services data for global variable, which contains - // the private data of all firmware volume block instances - // - mFvbModuleGlobal = AllocateRuntimePool (sizeof (ESAL_FWB_GLOBAL)); - ASSERT (mFvbModuleGlobal != NULL); - - BaseAddress = (UINTN) PcdGet32 (PcdOvmfFdBaseAddress); - Length = PcdGet32 (PcdOvmfFirmwareFdSize); - - Status = InitializeVariableFvHeader (); - if (EFI_ERROR (Status)) { - DEBUG ((EFI_D_INFO, - "QEMU Flash: Unable to initialize variable FV header\n")); - return EFI_WRITE_PROTECTED; - } - - FwVolHeader = (EFI_FIRMWARE_VOLUME_HEADER *) (UINTN) BaseAddress; - Status = ValidateFvHeader (FwVolHeader); - if (EFI_ERROR (Status)) { - // - // Get FvbInfo - // - Status = GetFvbInfo (Length, &FwVolHeader); - if (EFI_ERROR (Status)) { - DEBUG ((EFI_D_INFO, "EFI_ERROR (GetFvbInfo (Length, &FwVolHeader))\n")); - return EFI_WRITE_PROTECTED; - } - } - - BufferSize = (sizeof (EFI_FW_VOL_INSTANCE) + - FwVolHeader->HeaderLength - - sizeof (EFI_FIRMWARE_VOLUME_HEADER) - ); - mFvbModuleGlobal->FvInstance = AllocateRuntimePool (BufferSize); - ASSERT (mFvbModuleGlobal->FvInstance != NULL); - - FwhInstance = mFvbModuleGlobal->FvInstance; - - mFvbModuleGlobal->NumFv = 0; - MaxLbaSize = 0; - - FwVolHeader = - (EFI_FIRMWARE_VOLUME_HEADER *) (UINTN) - PcdGet32 (PcdOvmfFlashNvStorageVariableBase); - - FwhInstance->FvBase = (UINTN) BaseAddress; - - CopyMem ((UINTN *) &(FwhInstance->VolumeHeader), (UINTN *) FwVolHeader, - FwVolHeader->HeaderLength); - FwVolHeader = &(FwhInstance->VolumeHeader); - - NumOfBlocks = 0; - - for (PtrBlockMapEntry = FwVolHeader->BlockMap; - PtrBlockMapEntry->NumBlocks != 0; - PtrBlockMapEntry++) { - // - // Get the maximum size of a block. - // - if (MaxLbaSize < PtrBlockMapEntry->Length) { - MaxLbaSize = PtrBlockMapEntry->Length; - } - - NumOfBlocks = NumOfBlocks + PtrBlockMapEntry->NumBlocks; - } - - // - // The total number of blocks in the FV. - // - FwhInstance->NumOfBlocks = NumOfBlocks; - - // - // Add a FVB Protocol Instance - // - FvbDevice = AllocateRuntimePool (sizeof (EFI_FW_VOL_BLOCK_DEVICE)); - ASSERT (FvbDevice != NULL); - - CopyMem (FvbDevice, &mFvbDeviceTemplate, sizeof (EFI_FW_VOL_BLOCK_DEVICE)); - - FvbDevice->Instance = mFvbModuleGlobal->NumFv; - mFvbModuleGlobal->NumFv++; - - // - // Set up the devicepath - // - if (FwVolHeader->ExtHeaderOffset == 0) { - FV_MEMMAP_DEVICE_PATH *FvMemmapDevicePath; - - // - // FV does not contains extension header, then produce MEMMAP_DEVICE_PATH - // - FvMemmapDevicePath = AllocateCopyPool (sizeof (FV_MEMMAP_DEVICE_PATH), - &mFvMemmapDevicePathTemplate); - FvMemmapDevicePath->MemMapDevPath.StartingAddress = BaseAddress; - FvMemmapDevicePath->MemMapDevPath.EndingAddress = - BaseAddress + FwVolHeader->FvLength - 1; - FvbDevice->DevicePath = (EFI_DEVICE_PATH_PROTOCOL *)FvMemmapDevicePath; - } else { - FV_PIWG_DEVICE_PATH *FvPiwgDevicePath; - - FvPiwgDevicePath = AllocateCopyPool (sizeof (FV_PIWG_DEVICE_PATH), - &mFvPIWGDevicePathTemplate); - CopyGuid ( - &FvPiwgDevicePath->FvDevPath.FvName, - (GUID *)(UINTN)(BaseAddress + FwVolHeader->ExtHeaderOffset) - ); - FvbDevice->DevicePath = (EFI_DEVICE_PATH_PROTOCOL *)FvPiwgDevicePath; - } - - // - // Module type specific hook. - // - InstallProtocolInterfaces (FvbDevice); - - MarkMemoryRangeForRuntimeAccess (BaseAddress, Length); - - // - // Set several PCD values to point to flash - // - PcdStatus = PcdSet64S ( - PcdFlashNvStorageVariableBase64, - (UINTN) PcdGet32 (PcdOvmfFlashNvStorageVariableBase) - ); - ASSERT_RETURN_ERROR (PcdStatus); - PcdStatus = PcdSet32S ( - PcdFlashNvStorageFtwWorkingBase, - PcdGet32 (PcdOvmfFlashNvStorageFtwWorkingBase) - ); - ASSERT_RETURN_ERROR (PcdStatus); - PcdStatus = PcdSet32S ( - PcdFlashNvStorageFtwSpareBase, - PcdGet32 (PcdOvmfFlashNvStorageFtwSpareBase) - ); - ASSERT_RETURN_ERROR (PcdStatus); - - FwhInstance = (EFI_FW_VOL_INSTANCE *) - ( - (UINTN) ((UINT8 *) FwhInstance) + FwVolHeader->HeaderLength + - (sizeof (EFI_FW_VOL_INSTANCE) - sizeof (EFI_FIRMWARE_VOLUME_HEADER)) - ); - - // - // Module type specific hook. - // - InstallVirtualAddressChangeHandler (); - - PcdStatus = PcdSetBoolS (PcdOvmfFlashVariablesEnable, TRUE); - ASSERT_RETURN_ERROR (PcdStatus); - return EFI_SUCCESS; -} diff --git a/OvmfPkg/QemuFlashFvbServicesRuntimeDxe/FwBlockService.h b/OvmfPkg/QemuFlashFvbServicesRuntimeDxe/FwBlockService.h deleted file mode 100644 index 1f9287b087..0000000000 --- a/OvmfPkg/QemuFlashFvbServicesRuntimeDxe/FwBlockService.h +++ /dev/null @@ -1,192 +0,0 @@ -/**@file - - Copyright (c) 2006, Intel Corporation. All rights reserved.
- - This program and the accompanying materials are licensed and made available - under the terms and conditions of the BSD License which accompanies this - distribution. The full text of the license may be found at - http://opensource.org/licenses/bsd-license.php - - THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, - WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. - - Module Name: - - FwBlockService.h - - Abstract: - - Firmware volume block driver for Intel Firmware Hub (FWH) device - -**/ - -#ifndef _FW_BLOCK_SERVICE_H -#define _FW_BLOCK_SERVICE_H - -typedef struct { - UINTN FvBase; - UINTN NumOfBlocks; - EFI_FIRMWARE_VOLUME_HEADER VolumeHeader; -} EFI_FW_VOL_INSTANCE; - -typedef struct { - UINT32 NumFv; - EFI_FW_VOL_INSTANCE *FvInstance; -} ESAL_FWB_GLOBAL; - -extern ESAL_FWB_GLOBAL *mFvbModuleGlobal; - -// -// Fvb Protocol instance data -// -#define FVB_DEVICE_FROM_THIS(a) CR (a, EFI_FW_VOL_BLOCK_DEVICE, \ - FwVolBlockInstance, FVB_DEVICE_SIGNATURE) - -#define FVB_EXTEND_DEVICE_FROM_THIS(a) CR (a, EFI_FW_VOL_BLOCK_DEVICE, \ - FvbExtension, FVB_DEVICE_SIGNATURE) - -#define FVB_DEVICE_SIGNATURE SIGNATURE_32 ('F', 'V', 'B', 'N') - -typedef struct { - MEDIA_FW_VOL_DEVICE_PATH FvDevPath; - EFI_DEVICE_PATH_PROTOCOL EndDevPath; -} FV_PIWG_DEVICE_PATH; - -typedef struct { - MEMMAP_DEVICE_PATH MemMapDevPath; - EFI_DEVICE_PATH_PROTOCOL EndDevPath; -} FV_MEMMAP_DEVICE_PATH; - -typedef struct { - UINTN Signature; - EFI_DEVICE_PATH_PROTOCOL *DevicePath; - UINTN Instance; - EFI_FIRMWARE_VOLUME_BLOCK_PROTOCOL FwVolBlockInstance; -} EFI_FW_VOL_BLOCK_DEVICE; - -EFI_STATUS -GetFvbInfo ( - IN UINT64 FvLength, - OUT EFI_FIRMWARE_VOLUME_HEADER **FvbInfo - ); - -EFI_STATUS -FvbSetVolumeAttributes ( - IN UINTN Instance, - IN OUT EFI_FVB_ATTRIBUTES_2 *Attributes, - IN ESAL_FWB_GLOBAL *Global - ); - -EFI_STATUS -FvbGetVolumeAttributes ( - IN UINTN Instance, - OUT EFI_FVB_ATTRIBUTES_2 *Attributes, - IN ESAL_FWB_GLOBAL *Global - ); - -EFI_STATUS -FvbGetPhysicalAddress ( - IN UINTN Instance, - OUT EFI_PHYSICAL_ADDRESS *Address, - IN ESAL_FWB_GLOBAL *Global - ); - -EFI_STATUS -EFIAPI -FvbInitialize ( - IN EFI_HANDLE ImageHandle, - IN EFI_SYSTEM_TABLE *SystemTable - ); - - -VOID -EFIAPI -FvbClassAddressChangeEvent ( - IN EFI_EVENT Event, - IN VOID *Context - ); - -EFI_STATUS -FvbGetLbaAddress ( - IN UINTN Instance, - IN EFI_LBA Lba, - OUT UINTN *LbaAddress, - OUT UINTN *LbaLength, - OUT UINTN *NumOfBlocks, - IN ESAL_FWB_GLOBAL *Global - ); - -// -// Protocol APIs -// -EFI_STATUS -EFIAPI -FvbProtocolGetAttributes ( - IN CONST EFI_FIRMWARE_VOLUME_BLOCK_PROTOCOL *This, - OUT EFI_FVB_ATTRIBUTES_2 *Attributes - ); - -EFI_STATUS -EFIAPI -FvbProtocolSetAttributes ( - IN CONST EFI_FIRMWARE_VOLUME_BLOCK_PROTOCOL *This, - IN OUT EFI_FVB_ATTRIBUTES_2 *Attributes - ); - -EFI_STATUS -EFIAPI -FvbProtocolGetPhysicalAddress ( - IN CONST EFI_FIRMWARE_VOLUME_BLOCK_PROTOCOL *This, - OUT EFI_PHYSICAL_ADDRESS *Address - ); - -EFI_STATUS -EFIAPI -FvbProtocolGetBlockSize ( - IN CONST EFI_FIRMWARE_VOLUME_BLOCK_PROTOCOL *This, - IN CONST EFI_LBA Lba, - OUT UINTN *BlockSize, - OUT UINTN *NumOfBlocks - ); - -EFI_STATUS -EFIAPI -FvbProtocolRead ( - IN CONST EFI_FIRMWARE_VOLUME_BLOCK_PROTOCOL *This, - IN CONST EFI_LBA Lba, - IN CONST UINTN Offset, - IN OUT UINTN *NumBytes, - IN UINT8 *Buffer - ); - -EFI_STATUS -EFIAPI -FvbProtocolWrite ( - IN CONST EFI_FIRMWARE_VOLUME_BLOCK_PROTOCOL *This, - IN EFI_LBA Lba, - IN UINTN Offset, - IN OUT UINTN *NumBytes, - IN UINT8 *Buffer - ); - -EFI_STATUS -EFIAPI -FvbProtocolEraseBlocks ( - IN CONST EFI_FIRMWARE_VOLUME_BLOCK_PROTOCOL *This, - ... - ); - -// -// The following functions have different implementations dependent on the -// module type chosen for building this driver. -// -VOID -InstallProtocolInterfaces ( - IN EFI_FW_VOL_BLOCK_DEVICE *FvbDevice - ); - -VOID -InstallVirtualAddressChangeHandler ( - VOID - ); -#endif diff --git a/OvmfPkg/QemuFlashFvbServicesRuntimeDxe/FwBlockServiceDxe.c b/OvmfPkg/QemuFlashFvbServicesRuntimeDxe/FwBlockServiceDxe.c deleted file mode 100644 index 63b308658e..0000000000 --- a/OvmfPkg/QemuFlashFvbServicesRuntimeDxe/FwBlockServiceDxe.c +++ /dev/null @@ -1,157 +0,0 @@ -/**@file - Functions related to the Firmware Volume Block service whose - implementation is specific to the runtime DXE driver build. - - Copyright (C) 2015, Red Hat, Inc. - Copyright (c) 2006 - 2014, Intel Corporation. All rights reserved.
- - This program and the accompanying materials are licensed and made available - under the terms and conditions of the BSD License which accompanies this - distribution. The full text of the license may be found at - http://opensource.org/licenses/bsd-license.php - - THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, - WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. -**/ - -#include -#include -#include -#include -#include -#include -#include -#include - -#include "FwBlockService.h" -#include "QemuFlash.h" - -VOID -InstallProtocolInterfaces ( - IN EFI_FW_VOL_BLOCK_DEVICE *FvbDevice - ) -{ - EFI_STATUS Status; - EFI_HANDLE FwbHandle; - EFI_FIRMWARE_VOLUME_BLOCK_PROTOCOL *OldFwbInterface; - - ASSERT (!FeaturePcdGet (PcdSmmSmramRequire)); - - // - // Find a handle with a matching device path that has supports FW Block - // protocol - // - Status = gBS->LocateDevicePath (&gEfiFirmwareVolumeBlockProtocolGuid, - &FvbDevice->DevicePath, &FwbHandle); - if (EFI_ERROR (Status)) { - // - // LocateDevicePath fails so install a new interface and device path - // - FwbHandle = NULL; - DEBUG ((EFI_D_INFO, "Installing QEMU flash FVB\n")); - Status = gBS->InstallMultipleProtocolInterfaces ( - &FwbHandle, - &gEfiFirmwareVolumeBlockProtocolGuid, - &FvbDevice->FwVolBlockInstance, - &gEfiDevicePathProtocolGuid, - FvbDevice->DevicePath, - NULL - ); - ASSERT_EFI_ERROR (Status); - } else if (IsDevicePathEnd (FvbDevice->DevicePath)) { - // - // Device already exists, so reinstall the FVB protocol - // - Status = gBS->HandleProtocol ( - FwbHandle, - &gEfiFirmwareVolumeBlockProtocolGuid, - (VOID**)&OldFwbInterface - ); - ASSERT_EFI_ERROR (Status); - - DEBUG ((EFI_D_INFO, "Reinstalling FVB for QEMU flash region\n")); - Status = gBS->ReinstallProtocolInterface ( - FwbHandle, - &gEfiFirmwareVolumeBlockProtocolGuid, - OldFwbInterface, - &FvbDevice->FwVolBlockInstance - ); - ASSERT_EFI_ERROR (Status); - } else { - // - // There was a FVB protocol on an End Device Path node - // - ASSERT (FALSE); - } -} - - -STATIC -VOID -EFIAPI -FvbVirtualAddressChangeEvent ( - IN EFI_EVENT Event, - IN VOID *Context - ) -/*++ - - Routine Description: - - Fixup internal data so that EFI and SAL can be call in virtual mode. - Call the passed in Child Notify event and convert the mFvbModuleGlobal - date items to there virtual address. - - Arguments: - - (Standard EFI notify event - EFI_EVENT_NOTIFY) - - Returns: - - None - ---*/ -{ - EFI_FW_VOL_INSTANCE *FwhInstance; - UINTN Index; - - FwhInstance = mFvbModuleGlobal->FvInstance; - EfiConvertPointer (0x0, (VOID **) &mFvbModuleGlobal->FvInstance); - - // - // Convert the base address of all the instances - // - Index = 0; - while (Index < mFvbModuleGlobal->NumFv) { - EfiConvertPointer (0x0, (VOID **) &FwhInstance->FvBase); - FwhInstance = (EFI_FW_VOL_INSTANCE *) - ( - (UINTN) ((UINT8 *) FwhInstance) + - FwhInstance->VolumeHeader.HeaderLength + - (sizeof (EFI_FW_VOL_INSTANCE) - sizeof (EFI_FIRMWARE_VOLUME_HEADER)) - ); - Index++; - } - - EfiConvertPointer (0x0, (VOID **) &mFvbModuleGlobal); - QemuFlashConvertPointers (); -} - - -VOID -InstallVirtualAddressChangeHandler ( - VOID - ) -{ - EFI_STATUS Status; - EFI_EVENT VirtualAddressChangeEvent; - - Status = gBS->CreateEventEx ( - EVT_NOTIFY_SIGNAL, - TPL_NOTIFY, - FvbVirtualAddressChangeEvent, - NULL, - &gEfiEventVirtualAddressChangeGuid, - &VirtualAddressChangeEvent - ); - ASSERT_EFI_ERROR (Status); -} diff --git a/OvmfPkg/QemuFlashFvbServicesRuntimeDxe/FwBlockServiceSmm.c b/OvmfPkg/QemuFlashFvbServicesRuntimeDxe/FwBlockServiceSmm.c deleted file mode 100644 index e0617f2503..0000000000 --- a/OvmfPkg/QemuFlashFvbServicesRuntimeDxe/FwBlockServiceSmm.c +++ /dev/null @@ -1,69 +0,0 @@ -/**@file - Functions related to the Firmware Volume Block service whose - implementation is specific to the SMM driver build. - - Copyright (C) 2015, Red Hat, Inc. - Copyright (c) 2006 - 2014, Intel Corporation. All rights reserved.
- - This program and the accompanying materials are licensed and made available - under the terms and conditions of the BSD License which accompanies this - distribution. The full text of the license may be found at - http://opensource.org/licenses/bsd-license.php - - THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, - WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. -**/ - -#include -#include -#include -#include -#include - -#include "FwBlockService.h" - -VOID -InstallProtocolInterfaces ( - IN EFI_FW_VOL_BLOCK_DEVICE *FvbDevice - ) -{ - EFI_HANDLE FvbHandle; - EFI_STATUS Status; - - ASSERT (FeaturePcdGet (PcdSmmSmramRequire)); - - // - // There is no SMM service that can install multiple protocols in the SMM - // protocol database in one go. - // - // The SMM Firmware Volume Block protocol structure is the same as the - // Firmware Volume Block protocol structure. - // - FvbHandle = NULL; - DEBUG ((EFI_D_INFO, "Installing QEMU flash SMM FVB\n")); - Status = gSmst->SmmInstallProtocolInterface ( - &FvbHandle, - &gEfiSmmFirmwareVolumeBlockProtocolGuid, - EFI_NATIVE_INTERFACE, - &FvbDevice->FwVolBlockInstance - ); - ASSERT_EFI_ERROR (Status); - - Status = gSmst->SmmInstallProtocolInterface ( - &FvbHandle, - &gEfiDevicePathProtocolGuid, - EFI_NATIVE_INTERFACE, - FvbDevice->DevicePath - ); - ASSERT_EFI_ERROR (Status); -} - -VOID -InstallVirtualAddressChangeHandler ( - VOID - ) -{ - // - // Nothing. - // -} diff --git a/OvmfPkg/QemuFlashFvbServicesRuntimeDxe/QemuFlash.c b/OvmfPkg/QemuFlashFvbServicesRuntimeDxe/QemuFlash.c deleted file mode 100644 index 5677b5ee11..0000000000 --- a/OvmfPkg/QemuFlashFvbServicesRuntimeDxe/QemuFlash.c +++ /dev/null @@ -1,254 +0,0 @@ -/** @file - OVMF support for QEMU system firmware flash device - - Copyright (c) 2009 - 2013, Intel Corporation. All rights reserved.
- - This program and the accompanying materials are licensed and made available - under the terms and conditions of the BSD License which accompanies this - distribution. The full text of the license may be found at - http://opensource.org/licenses/bsd-license.php - - THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, - WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. - -**/ - -#include -#include -#include - -#include "QemuFlash.h" - -#define WRITE_BYTE_CMD 0x10 -#define BLOCK_ERASE_CMD 0x20 -#define CLEAR_STATUS_CMD 0x50 -#define READ_STATUS_CMD 0x70 -#define READ_DEVID_CMD 0x90 -#define BLOCK_ERASE_CONFIRM_CMD 0xd0 -#define READ_ARRAY_CMD 0xff - -#define CLEARED_ARRAY_STATUS 0x00 - - -UINT8 *mFlashBase; - -STATIC UINTN mFdBlockSize = 0; -STATIC UINTN mFdBlockCount = 0; - -STATIC -volatile UINT8* -QemuFlashPtr ( - IN EFI_LBA Lba, - IN UINTN Offset - ) -{ - return mFlashBase + ((UINTN)Lba * mFdBlockSize) + Offset; -} - - -/** - Determines if the QEMU flash memory device is present. - - @retval FALSE The QEMU flash device is not present. - @retval TRUE The QEMU flash device is present. - -**/ -STATIC -BOOLEAN -QemuFlashDetected ( - VOID - ) -{ - BOOLEAN FlashDetected; - volatile UINT8 *Ptr; - - UINTN Offset; - UINT8 OriginalUint8; - UINT8 ProbeUint8; - - FlashDetected = FALSE; - Ptr = QemuFlashPtr (0, 0); - - for (Offset = 0; Offset < mFdBlockSize; Offset++) { - Ptr = QemuFlashPtr (0, Offset); - ProbeUint8 = *Ptr; - if (ProbeUint8 != CLEAR_STATUS_CMD && - ProbeUint8 != READ_STATUS_CMD && - ProbeUint8 != CLEARED_ARRAY_STATUS) { - break; - } - } - - if (Offset >= mFdBlockSize) { - DEBUG ((EFI_D_INFO, "QEMU Flash: Failed to find probe location\n")); - return FALSE; - } - - DEBUG ((EFI_D_INFO, "QEMU Flash: Attempting flash detection at %p\n", Ptr)); - - OriginalUint8 = *Ptr; - *Ptr = CLEAR_STATUS_CMD; - ProbeUint8 = *Ptr; - if (OriginalUint8 != CLEAR_STATUS_CMD && - ProbeUint8 == CLEAR_STATUS_CMD) { - DEBUG ((EFI_D_INFO, "QemuFlashDetected => FD behaves as RAM\n")); - *Ptr = OriginalUint8; - } else { - *Ptr = READ_STATUS_CMD; - ProbeUint8 = *Ptr; - if (ProbeUint8 == OriginalUint8) { - DEBUG ((EFI_D_INFO, "QemuFlashDetected => FD behaves as ROM\n")); - } else if (ProbeUint8 == READ_STATUS_CMD) { - DEBUG ((EFI_D_INFO, "QemuFlashDetected => FD behaves as RAM\n")); - *Ptr = OriginalUint8; - } else if (ProbeUint8 == CLEARED_ARRAY_STATUS) { - DEBUG ((EFI_D_INFO, "QemuFlashDetected => FD behaves as FLASH\n")); - FlashDetected = TRUE; - *Ptr = READ_ARRAY_CMD; - } - } - - DEBUG ((EFI_D_INFO, "QemuFlashDetected => %a\n", - FlashDetected ? "Yes" : "No")); - return FlashDetected; -} - - -/** - Read from QEMU Flash - - @param[in] Lba The starting logical block index to read from. - @param[in] Offset Offset into the block at which to begin reading. - @param[in] NumBytes On input, indicates the requested read size. On - output, indicates the actual number of bytes read - @param[in] Buffer Pointer to the buffer to read into. - -**/ -EFI_STATUS -QemuFlashRead ( - IN EFI_LBA Lba, - IN UINTN Offset, - IN UINTN *NumBytes, - IN UINT8 *Buffer - ) -{ - UINT8 *Ptr; - - // - // Only write to the first 64k. We don't bother saving the FTW Spare - // block into the flash memory. - // - if (Lba >= mFdBlockCount) { - return EFI_INVALID_PARAMETER; - } - - // - // Get flash address - // - Ptr = (UINT8*) QemuFlashPtr (Lba, Offset); - - CopyMem (Buffer, Ptr, *NumBytes); - - return EFI_SUCCESS; -} - - -/** - Write to QEMU Flash - - @param[in] Lba The starting logical block index to write to. - @param[in] Offset Offset into the block at which to begin writing. - @param[in] NumBytes On input, indicates the requested write size. On - output, indicates the actual number of bytes written - @param[in] Buffer Pointer to the data to write. - -**/ -EFI_STATUS -QemuFlashWrite ( - IN EFI_LBA Lba, - IN UINTN Offset, - IN UINTN *NumBytes, - IN UINT8 *Buffer - ) -{ - volatile UINT8 *Ptr; - UINTN Loop; - - // - // Only write to the first 64k. We don't bother saving the FTW Spare - // block into the flash memory. - // - if (Lba >= mFdBlockCount) { - return EFI_INVALID_PARAMETER; - } - - // - // Program flash - // - Ptr = QemuFlashPtr (Lba, Offset); - for (Loop = 0; Loop < *NumBytes; Loop++) { - *Ptr = WRITE_BYTE_CMD; - *Ptr = Buffer[Loop]; - Ptr++; - } - - // - // Restore flash to read mode - // - if (*NumBytes > 0) { - *(Ptr - 1) = READ_ARRAY_CMD; - } - - return EFI_SUCCESS; -} - - -/** - Erase a QEMU Flash block - - @param Lba The logical block index to erase. - -**/ -EFI_STATUS -QemuFlashEraseBlock ( - IN EFI_LBA Lba - ) -{ - volatile UINT8 *Ptr; - - if (Lba >= mFdBlockCount) { - return EFI_INVALID_PARAMETER; - } - - Ptr = QemuFlashPtr (Lba, 0); - *Ptr = BLOCK_ERASE_CMD; - *Ptr = BLOCK_ERASE_CONFIRM_CMD; - return EFI_SUCCESS; -} - - -/** - Initializes QEMU flash memory support - - @retval EFI_WRITE_PROTECTED The QEMU flash device is not present. - @retval EFI_SUCCESS The QEMU flash device is supported. - -**/ -EFI_STATUS -QemuFlashInitialize ( - VOID - ) -{ - mFlashBase = (UINT8*)(UINTN) PcdGet32 (PcdOvmfFdBaseAddress); - mFdBlockSize = PcdGet32 (PcdOvmfFirmwareBlockSize); - ASSERT(PcdGet32 (PcdOvmfFirmwareFdSize) % mFdBlockSize == 0); - mFdBlockCount = PcdGet32 (PcdOvmfFirmwareFdSize) / mFdBlockSize; - - if (!QemuFlashDetected ()) { - ASSERT (!FeaturePcdGet (PcdSmmSmramRequire)); - return EFI_WRITE_PROTECTED; - } - - return EFI_SUCCESS; -} - diff --git a/OvmfPkg/QemuFlashFvbServicesRuntimeDxe/QemuFlash.h b/OvmfPkg/QemuFlashFvbServicesRuntimeDxe/QemuFlash.h deleted file mode 100644 index 8d83dca7a5..0000000000 --- a/OvmfPkg/QemuFlashFvbServicesRuntimeDxe/QemuFlash.h +++ /dev/null @@ -1,92 +0,0 @@ -/** @file - OVMF support for QEMU system firmware flash device - - Copyright (c) 2009 - 2013, Intel Corporation. All rights reserved.
- - This program and the accompanying materials are licensed and made available - under the terms and conditions of the BSD License which accompanies this - distribution. The full text of the license may be found at - http://opensource.org/licenses/bsd-license.php - - THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, - WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. - -**/ - -#ifndef __QEMU_FLASH_H__ -#define __QEMU_FLASH_H__ - -#include - -extern UINT8 *mFlashBase; - -/** - Read from QEMU Flash - - @param[in] Lba The starting logical block index to read from. - @param[in] Offset Offset into the block at which to begin reading. - @param[in] NumBytes On input, indicates the requested read size. On - output, indicates the actual number of bytes read - @param[in] Buffer Pointer to the buffer to read into. - -**/ -EFI_STATUS -QemuFlashRead ( - IN EFI_LBA Lba, - IN UINTN Offset, - IN UINTN *NumBytes, - IN UINT8 *Buffer - ); - - -/** - Write to QEMU Flash - - @param[in] Lba The starting logical block index to write to. - @param[in] Offset Offset into the block at which to begin writing. - @param[in] NumBytes On input, indicates the requested write size. On - output, indicates the actual number of bytes written - @param[in] Buffer Pointer to the data to write. - -**/ -EFI_STATUS -QemuFlashWrite ( - IN EFI_LBA Lba, - IN UINTN Offset, - IN UINTN *NumBytes, - IN UINT8 *Buffer - ); - - -/** - Erase a QEMU Flash block - - @param Lba The logical block index to erase. - -**/ -EFI_STATUS -QemuFlashEraseBlock ( - IN EFI_LBA Lba - ); - - -/** - Initializes QEMU flash memory support - - @retval EFI_WRITE_PROTECTED The QEMU flash device is not present. - @retval EFI_SUCCESS The QEMU flash device is supported. - -**/ -EFI_STATUS -QemuFlashInitialize ( - VOID - ); - - -VOID -QemuFlashConvertPointers ( - VOID - ); - -#endif - diff --git a/OvmfPkg/QemuFlashFvbServicesRuntimeDxe/QemuFlashDxe.c b/OvmfPkg/QemuFlashFvbServicesRuntimeDxe/QemuFlashDxe.c deleted file mode 100644 index 08ece2beae..0000000000 --- a/OvmfPkg/QemuFlashFvbServicesRuntimeDxe/QemuFlashDxe.c +++ /dev/null @@ -1,28 +0,0 @@ -/** @file - OVMF support for QEMU system firmware flash device: functions specific to the - runtime DXE driver build. - - Copyright (C) 2015, Red Hat, Inc. - Copyright (c) 2009 - 2013, Intel Corporation. All rights reserved.
- - This program and the accompanying materials are licensed and made available - under the terms and conditions of the BSD License which accompanies this - distribution. The full text of the license may be found at - http://opensource.org/licenses/bsd-license.php - - THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, - WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. - -**/ - -#include - -#include "QemuFlash.h" - -VOID -QemuFlashConvertPointers ( - VOID - ) -{ - EfiConvertPointer (0x0, (VOID **) &mFlashBase); -} diff --git a/OvmfPkg/QemuVideoDxe/ComponentName.c b/OvmfPkg/QemuVideoDxe/ComponentName.c deleted file mode 100644 index de1fe76aa7..0000000000 --- a/OvmfPkg/QemuVideoDxe/ComponentName.c +++ /dev/null @@ -1,212 +0,0 @@ -/** @file - Component name for the QEMU video controller. - - Copyright (c) 2006 - 2010, Intel Corporation. All rights reserved.
- - This program and the accompanying materials - are licensed and made available under the terms and conditions of the BSD License - which accompanies this distribution. The full text of the license may be found at - http://opensource.org/licenses/bsd-license.php - - THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, - WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. - -**/ - -#include "Qemu.h" - -// -// EFI Component Name Protocol -// -GLOBAL_REMOVE_IF_UNREFERENCED EFI_COMPONENT_NAME_PROTOCOL gQemuVideoComponentName = { - QemuVideoComponentNameGetDriverName, - QemuVideoComponentNameGetControllerName, - "eng" -}; - -// -// EFI Component Name 2 Protocol -// -GLOBAL_REMOVE_IF_UNREFERENCED EFI_COMPONENT_NAME2_PROTOCOL gQemuVideoComponentName2 = { - (EFI_COMPONENT_NAME2_GET_DRIVER_NAME) QemuVideoComponentNameGetDriverName, - (EFI_COMPONENT_NAME2_GET_CONTROLLER_NAME) QemuVideoComponentNameGetControllerName, - "en" -}; - - -GLOBAL_REMOVE_IF_UNREFERENCED EFI_UNICODE_STRING_TABLE mQemuVideoDriverNameTable[] = { - { "eng;en", L"QEMU Video Driver" }, - { NULL , NULL } -}; - -GLOBAL_REMOVE_IF_UNREFERENCED EFI_UNICODE_STRING_TABLE mQemuVideoControllerNameTable[] = { - { "eng;en", L"QEMU Video PCI Adapter" }, - { NULL , NULL } -}; - -/** - Retrieves a Unicode string that is the user readable name of the driver. - - This function retrieves the user readable name of a driver in the form of a - Unicode string. If the driver specified by This has a user readable name in - the language specified by Language, then a pointer to the driver name is - returned in DriverName, and EFI_SUCCESS is returned. If the driver specified - by This does not support the language specified by Language, - then EFI_UNSUPPORTED is returned. - - @param This[in] A pointer to the EFI_COMPONENT_NAME2_PROTOCOL or - EFI_COMPONENT_NAME_PROTOCOL instance. - - @param Language[in] A pointer to a Null-terminated ASCII string - array indicating the language. This is the - language of the driver name that the caller is - requesting, and it must match one of the - languages specified in SupportedLanguages. The - number of languages supported by a driver is up - to the driver writer. Language is specified - in RFC 4646 or ISO 639-2 language code format. - - @param DriverName[out] A pointer to the Unicode string to return. - This Unicode string is the name of the - driver specified by This in the language - specified by Language. - - @retval EFI_SUCCESS The Unicode string for the Driver specified by - This and the language specified by Language was - returned in DriverName. - - @retval EFI_INVALID_PARAMETER Language is NULL. - - @retval EFI_INVALID_PARAMETER DriverName is NULL. - - @retval EFI_UNSUPPORTED The driver specified by This does not support - the language specified by Language. - -**/ -EFI_STATUS -EFIAPI -QemuVideoComponentNameGetDriverName ( - IN EFI_COMPONENT_NAME_PROTOCOL *This, - IN CHAR8 *Language, - OUT CHAR16 **DriverName - ) -{ - return LookupUnicodeString2 ( - Language, - This->SupportedLanguages, - mQemuVideoDriverNameTable, - DriverName, - (BOOLEAN)(This == &gQemuVideoComponentName) - ); -} - -/** - Retrieves a Unicode string that is the user readable name of the controller - that is being managed by a driver. - - This function retrieves the user readable name of the controller specified by - ControllerHandle and ChildHandle in the form of a Unicode string. If the - driver specified by This has a user readable name in the language specified by - Language, then a pointer to the controller name is returned in ControllerName, - and EFI_SUCCESS is returned. If the driver specified by This is not currently - managing the controller specified by ControllerHandle and ChildHandle, - then EFI_UNSUPPORTED is returned. If the driver specified by This does not - support the language specified by Language, then EFI_UNSUPPORTED is returned. - - @param This[in] A pointer to the EFI_COMPONENT_NAME2_PROTOCOL or - EFI_COMPONENT_NAME_PROTOCOL instance. - - @param ControllerHandle[in] The handle of a controller that the driver - specified by This is managing. This handle - specifies the controller whose name is to be - returned. - - @param ChildHandle[in] The handle of the child controller to retrieve - the name of. This is an optional parameter that - may be NULL. It will be NULL for device - drivers. It will also be NULL for a bus drivers - that wish to retrieve the name of the bus - controller. It will not be NULL for a bus - driver that wishes to retrieve the name of a - child controller. - - @param Language[in] A pointer to a Null-terminated ASCII string - array indicating the language. This is the - language of the driver name that the caller is - requesting, and it must match one of the - languages specified in SupportedLanguages. The - number of languages supported by a driver is up - to the driver writer. Language is specified in - RFC 4646 or ISO 639-2 language code format. - - @param ControllerName[out] A pointer to the Unicode string to return. - This Unicode string is the name of the - controller specified by ControllerHandle and - ChildHandle in the language specified by - Language from the point of view of the driver - specified by This. - - @retval EFI_SUCCESS The Unicode string for the user readable name in - the language specified by Language for the - driver specified by This was returned in - DriverName. - - @retval EFI_INVALID_PARAMETER ControllerHandle is not a valid EFI_HANDLE. - - @retval EFI_INVALID_PARAMETER ChildHandle is not NULL and it is not a valid - EFI_HANDLE. - - @retval EFI_INVALID_PARAMETER Language is NULL. - - @retval EFI_INVALID_PARAMETER ControllerName is NULL. - - @retval EFI_UNSUPPORTED The driver specified by This is not currently - managing the controller specified by - ControllerHandle and ChildHandle. - - @retval EFI_UNSUPPORTED The driver specified by This does not support - the language specified by Language. - -**/ -EFI_STATUS -EFIAPI -QemuVideoComponentNameGetControllerName ( - IN EFI_COMPONENT_NAME_PROTOCOL *This, - IN EFI_HANDLE ControllerHandle, - IN EFI_HANDLE ChildHandle OPTIONAL, - IN CHAR8 *Language, - OUT CHAR16 **ControllerName - ) -{ - EFI_STATUS Status; - - // - // This is a device driver, so ChildHandle must be NULL. - // - if (ChildHandle != NULL) { - return EFI_UNSUPPORTED; - } - - // - // Make sure this driver is currently managing ControllHandle - // - Status = EfiTestManagedDevice ( - ControllerHandle, - gQemuVideoDriverBinding.DriverBindingHandle, - &gEfiPciIoProtocolGuid - ); - if (EFI_ERROR (Status)) { - return Status; - } - - // - // Get the QEMU Video's Device structure - // - return LookupUnicodeString2 ( - Language, - This->SupportedLanguages, - mQemuVideoControllerNameTable, - ControllerName, - (BOOLEAN)(This == &gQemuVideoComponentName) - ); -} diff --git a/OvmfPkg/QemuVideoDxe/Driver.c b/OvmfPkg/QemuVideoDxe/Driver.c deleted file mode 100644 index fc8025ec46..0000000000 --- a/OvmfPkg/QemuVideoDxe/Driver.c +++ /dev/null @@ -1,977 +0,0 @@ -/** @file - This driver is a sample implementation of the Graphics Output Protocol for - the QEMU (Cirrus Logic 5446) video controller. - - Copyright (c) 2006 - 2010, Intel Corporation. All rights reserved.
- - This program and the accompanying materials - are licensed and made available under the terms and conditions of the BSD License - which accompanies this distribution. The full text of the license may be found at - http://opensource.org/licenses/bsd-license.php - - THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, - WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. - -**/ - -#include "Qemu.h" -#include - -EFI_DRIVER_BINDING_PROTOCOL gQemuVideoDriverBinding = { - QemuVideoControllerDriverSupported, - QemuVideoControllerDriverStart, - QemuVideoControllerDriverStop, - 0x10, - NULL, - NULL -}; - -QEMU_VIDEO_CARD gQemuVideoCardList[] = { - { - CIRRUS_LOGIC_VENDOR_ID, - CIRRUS_LOGIC_5430_DEVICE_ID, - QEMU_VIDEO_CIRRUS_5430, - L"Cirrus 5430" - },{ - CIRRUS_LOGIC_VENDOR_ID, - CIRRUS_LOGIC_5430_ALTERNATE_DEVICE_ID, - QEMU_VIDEO_CIRRUS_5430, - L"Cirrus 5430" - },{ - CIRRUS_LOGIC_VENDOR_ID, - CIRRUS_LOGIC_5446_DEVICE_ID, - QEMU_VIDEO_CIRRUS_5446, - L"Cirrus 5446" - },{ - 0x1234, - 0x1111, - QEMU_VIDEO_BOCHS_MMIO, - L"QEMU Standard VGA" - },{ - 0x1b36, - 0x0100, - QEMU_VIDEO_BOCHS, - L"QEMU QXL VGA" - },{ - 0x1af4, - 0x1050, - QEMU_VIDEO_BOCHS_MMIO, - L"QEMU VirtIO VGA" - },{ - 0 /* end of list */ - } -}; - -static QEMU_VIDEO_CARD* -QemuVideoDetect( - IN UINT16 VendorId, - IN UINT16 DeviceId - ) -{ - UINTN Index = 0; - - while (gQemuVideoCardList[Index].VendorId != 0) { - if (gQemuVideoCardList[Index].VendorId == VendorId && - gQemuVideoCardList[Index].DeviceId == DeviceId) { - return gQemuVideoCardList + Index; - } - Index++; - } - return NULL; -} - -/** - Check if this device is supported. - - @param This The driver binding protocol. - @param Controller The controller handle to check. - @param RemainingDevicePath The remaining device path. - - @retval EFI_SUCCESS The bus supports this controller. - @retval EFI_UNSUPPORTED This device isn't supported. - -**/ -EFI_STATUS -EFIAPI -QemuVideoControllerDriverSupported ( - IN EFI_DRIVER_BINDING_PROTOCOL *This, - IN EFI_HANDLE Controller, - IN EFI_DEVICE_PATH_PROTOCOL *RemainingDevicePath - ) -{ - EFI_STATUS Status; - EFI_PCI_IO_PROTOCOL *PciIo; - PCI_TYPE00 Pci; - QEMU_VIDEO_CARD *Card; - - // - // Open the PCI I/O Protocol - // - Status = gBS->OpenProtocol ( - Controller, - &gEfiPciIoProtocolGuid, - (VOID **) &PciIo, - This->DriverBindingHandle, - Controller, - EFI_OPEN_PROTOCOL_BY_DRIVER - ); - if (EFI_ERROR (Status)) { - return Status; - } - - // - // Read the PCI Configuration Header from the PCI Device - // - Status = PciIo->Pci.Read ( - PciIo, - EfiPciIoWidthUint32, - 0, - sizeof (Pci) / sizeof (UINT32), - &Pci - ); - if (EFI_ERROR (Status)) { - goto Done; - } - - Status = EFI_UNSUPPORTED; - if (!IS_PCI_VGA (&Pci)) { - goto Done; - } - Card = QemuVideoDetect(Pci.Hdr.VendorId, Pci.Hdr.DeviceId); - if (Card != NULL) { - DEBUG ((EFI_D_INFO, "QemuVideo: %s detected\n", Card->Name)); - Status = EFI_SUCCESS; - } - -Done: - // - // Close the PCI I/O Protocol - // - gBS->CloseProtocol ( - Controller, - &gEfiPciIoProtocolGuid, - This->DriverBindingHandle, - Controller - ); - - return Status; -} - -/** - Start to process the controller. - - @param This The USB bus driver binding instance. - @param Controller The controller to check. - @param RemainingDevicePath The remaining device patch. - - @retval EFI_SUCCESS The controller is controlled by the usb bus. - @retval EFI_ALREADY_STARTED The controller is already controlled by the usb - bus. - @retval EFI_OUT_OF_RESOURCES Failed to allocate resources. - -**/ -EFI_STATUS -EFIAPI -QemuVideoControllerDriverStart ( - IN EFI_DRIVER_BINDING_PROTOCOL *This, - IN EFI_HANDLE Controller, - IN EFI_DEVICE_PATH_PROTOCOL *RemainingDevicePath - ) -{ - EFI_TPL OldTpl; - EFI_STATUS Status; - QEMU_VIDEO_PRIVATE_DATA *Private; - BOOLEAN IsQxl; - EFI_DEVICE_PATH_PROTOCOL *ParentDevicePath; - ACPI_ADR_DEVICE_PATH AcpiDeviceNode; - PCI_TYPE00 Pci; - QEMU_VIDEO_CARD *Card; - EFI_PCI_IO_PROTOCOL *ChildPciIo; - - OldTpl = gBS->RaiseTPL (TPL_CALLBACK); - - // - // Allocate Private context data for GOP inteface. - // - Private = AllocateZeroPool (sizeof (QEMU_VIDEO_PRIVATE_DATA)); - if (Private == NULL) { - Status = EFI_OUT_OF_RESOURCES; - goto RestoreTpl; - } - - // - // Set up context record - // - Private->Signature = QEMU_VIDEO_PRIVATE_DATA_SIGNATURE; - - // - // Open PCI I/O Protocol - // - Status = gBS->OpenProtocol ( - Controller, - &gEfiPciIoProtocolGuid, - (VOID **) &Private->PciIo, - This->DriverBindingHandle, - Controller, - EFI_OPEN_PROTOCOL_BY_DRIVER - ); - if (EFI_ERROR (Status)) { - goto FreePrivate; - } - - // - // Read the PCI Configuration Header from the PCI Device - // - Status = Private->PciIo->Pci.Read ( - Private->PciIo, - EfiPciIoWidthUint32, - 0, - sizeof (Pci) / sizeof (UINT32), - &Pci - ); - if (EFI_ERROR (Status)) { - goto ClosePciIo; - } - - // - // Determine card variant. - // - Card = QemuVideoDetect(Pci.Hdr.VendorId, Pci.Hdr.DeviceId); - if (Card == NULL) { - Status = EFI_DEVICE_ERROR; - goto ClosePciIo; - } - Private->Variant = Card->Variant; - - // - // IsQxl is based on the detected Card->Variant, which at a later point might - // not match Private->Variant. - // - IsQxl = (BOOLEAN)(Card->Variant == QEMU_VIDEO_BOCHS); - - // - // Save original PCI attributes - // - Status = Private->PciIo->Attributes ( - Private->PciIo, - EfiPciIoAttributeOperationGet, - 0, - &Private->OriginalPciAttributes - ); - - if (EFI_ERROR (Status)) { - goto ClosePciIo; - } - - // - // Set new PCI attributes - // - Status = Private->PciIo->Attributes ( - Private->PciIo, - EfiPciIoAttributeOperationEnable, - EFI_PCI_DEVICE_ENABLE | EFI_PCI_IO_ATTRIBUTE_VGA_MEMORY | EFI_PCI_IO_ATTRIBUTE_VGA_IO, - NULL - ); - if (EFI_ERROR (Status)) { - goto ClosePciIo; - } - - // - // Check whenever the qemu stdvga mmio bar is present (qemu 1.3+). - // - if (Private->Variant == QEMU_VIDEO_BOCHS_MMIO) { - EFI_ACPI_ADDRESS_SPACE_DESCRIPTOR *MmioDesc; - - Status = Private->PciIo->GetBarAttributes ( - Private->PciIo, - PCI_BAR_IDX2, - NULL, - (VOID**) &MmioDesc - ); - if (EFI_ERROR (Status) || - MmioDesc->ResType != ACPI_ADDRESS_SPACE_TYPE_MEM) { - DEBUG ((EFI_D_INFO, "QemuVideo: No mmio bar, fallback to port io\n")); - Private->Variant = QEMU_VIDEO_BOCHS; - } else { - DEBUG ((EFI_D_INFO, "QemuVideo: Using mmio bar @ 0x%lx\n", - MmioDesc->AddrRangeMin)); - } - - if (!EFI_ERROR (Status)) { - FreePool (MmioDesc); - } - } - - // - // Check if accessing the bochs interface works. - // - if (Private->Variant == QEMU_VIDEO_BOCHS_MMIO || - Private->Variant == QEMU_VIDEO_BOCHS) { - UINT16 BochsId; - BochsId = BochsRead(Private, VBE_DISPI_INDEX_ID); - if ((BochsId & 0xFFF0) != VBE_DISPI_ID0) { - DEBUG ((EFI_D_INFO, "QemuVideo: BochsID mismatch (got 0x%x)\n", BochsId)); - Status = EFI_DEVICE_ERROR; - goto RestoreAttributes; - } - } - - // - // Get ParentDevicePath - // - Status = gBS->HandleProtocol ( - Controller, - &gEfiDevicePathProtocolGuid, - (VOID **) &ParentDevicePath - ); - if (EFI_ERROR (Status)) { - goto RestoreAttributes; - } - - // - // Set Gop Device Path - // - ZeroMem (&AcpiDeviceNode, sizeof (ACPI_ADR_DEVICE_PATH)); - AcpiDeviceNode.Header.Type = ACPI_DEVICE_PATH; - AcpiDeviceNode.Header.SubType = ACPI_ADR_DP; - AcpiDeviceNode.ADR = ACPI_DISPLAY_ADR (1, 0, 0, 1, 0, ACPI_ADR_DISPLAY_TYPE_VGA, 0, 0); - SetDevicePathNodeLength (&AcpiDeviceNode.Header, sizeof (ACPI_ADR_DEVICE_PATH)); - - Private->GopDevicePath = AppendDevicePathNode ( - ParentDevicePath, - (EFI_DEVICE_PATH_PROTOCOL *) &AcpiDeviceNode - ); - if (Private->GopDevicePath == NULL) { - Status = EFI_OUT_OF_RESOURCES; - goto RestoreAttributes; - } - - // - // Create new child handle and install the device path protocol on it. - // - Status = gBS->InstallMultipleProtocolInterfaces ( - &Private->Handle, - &gEfiDevicePathProtocolGuid, - Private->GopDevicePath, - NULL - ); - if (EFI_ERROR (Status)) { - goto FreeGopDevicePath; - } - - // - // Construct video mode buffer - // - switch (Private->Variant) { - case QEMU_VIDEO_CIRRUS_5430: - case QEMU_VIDEO_CIRRUS_5446: - Status = QemuVideoCirrusModeSetup (Private); - break; - case QEMU_VIDEO_BOCHS_MMIO: - case QEMU_VIDEO_BOCHS: - Status = QemuVideoBochsModeSetup (Private, IsQxl); - break; - default: - ASSERT (FALSE); - Status = EFI_DEVICE_ERROR; - break; - } - if (EFI_ERROR (Status)) { - goto UninstallGopDevicePath; - } - - // - // Start the GOP software stack. - // - Status = QemuVideoGraphicsOutputConstructor (Private); - if (EFI_ERROR (Status)) { - goto FreeModeData; - } - - Status = gBS->InstallMultipleProtocolInterfaces ( - &Private->Handle, - &gEfiGraphicsOutputProtocolGuid, - &Private->GraphicsOutput, - NULL - ); - if (EFI_ERROR (Status)) { - goto DestructQemuVideoGraphics; - } - - // - // Reference parent handle from child handle. - // - Status = gBS->OpenProtocol ( - Controller, - &gEfiPciIoProtocolGuid, - (VOID **) &ChildPciIo, - This->DriverBindingHandle, - Private->Handle, - EFI_OPEN_PROTOCOL_BY_CHILD_CONTROLLER - ); - if (EFI_ERROR (Status)) { - goto UninstallGop; - } - -#if defined MDE_CPU_IA32 || defined MDE_CPU_X64 - if (Private->Variant == QEMU_VIDEO_BOCHS_MMIO || - Private->Variant == QEMU_VIDEO_BOCHS) { - InstallVbeShim (Card->Name, Private->GraphicsOutput.Mode->FrameBufferBase); - } -#endif - - gBS->RestoreTPL (OldTpl); - return EFI_SUCCESS; - -UninstallGop: - gBS->UninstallProtocolInterface (Private->Handle, - &gEfiGraphicsOutputProtocolGuid, &Private->GraphicsOutput); - -DestructQemuVideoGraphics: - QemuVideoGraphicsOutputDestructor (Private); - -FreeModeData: - FreePool (Private->ModeData); - -UninstallGopDevicePath: - gBS->UninstallProtocolInterface (Private->Handle, - &gEfiDevicePathProtocolGuid, Private->GopDevicePath); - -FreeGopDevicePath: - FreePool (Private->GopDevicePath); - -RestoreAttributes: - Private->PciIo->Attributes (Private->PciIo, EfiPciIoAttributeOperationSet, - Private->OriginalPciAttributes, NULL); - -ClosePciIo: - gBS->CloseProtocol (Controller, &gEfiPciIoProtocolGuid, - This->DriverBindingHandle, Controller); - -FreePrivate: - FreePool (Private); - -RestoreTpl: - gBS->RestoreTPL (OldTpl); - - return Status; -} - -/** - Stop this device - - @param This The USB bus driver binding protocol. - @param Controller The controller to release. - @param NumberOfChildren The number of children of this device that - opened the controller BY_CHILD. - @param ChildHandleBuffer The array of child handle. - - @retval EFI_SUCCESS The controller or children are stopped. - @retval EFI_DEVICE_ERROR Failed to stop the driver. - -**/ -EFI_STATUS -EFIAPI -QemuVideoControllerDriverStop ( - IN EFI_DRIVER_BINDING_PROTOCOL *This, - IN EFI_HANDLE Controller, - IN UINTN NumberOfChildren, - IN EFI_HANDLE *ChildHandleBuffer - ) -{ - EFI_GRAPHICS_OUTPUT_PROTOCOL *GraphicsOutput; - - EFI_STATUS Status; - QEMU_VIDEO_PRIVATE_DATA *Private; - - if (NumberOfChildren == 0) { - // - // Close the PCI I/O Protocol - // - gBS->CloseProtocol ( - Controller, - &gEfiPciIoProtocolGuid, - This->DriverBindingHandle, - Controller - ); - return EFI_SUCCESS; - } - - // - // free all resources for whose access we need the child handle, because the - // child handle is going away - // - ASSERT (NumberOfChildren == 1); - Status = gBS->OpenProtocol ( - ChildHandleBuffer[0], - &gEfiGraphicsOutputProtocolGuid, - (VOID **) &GraphicsOutput, - This->DriverBindingHandle, - Controller, - EFI_OPEN_PROTOCOL_GET_PROTOCOL - ); - if (EFI_ERROR (Status)) { - return Status; - } - - // - // Get our private context information - // - Private = QEMU_VIDEO_PRIVATE_DATA_FROM_GRAPHICS_OUTPUT_THIS (GraphicsOutput); - ASSERT (Private->Handle == ChildHandleBuffer[0]); - - QemuVideoGraphicsOutputDestructor (Private); - // - // Remove the GOP protocol interface from the system - // - Status = gBS->UninstallMultipleProtocolInterfaces ( - Private->Handle, - &gEfiGraphicsOutputProtocolGuid, - &Private->GraphicsOutput, - NULL - ); - - if (EFI_ERROR (Status)) { - return Status; - } - - // - // Restore original PCI attributes - // - Private->PciIo->Attributes ( - Private->PciIo, - EfiPciIoAttributeOperationSet, - Private->OriginalPciAttributes, - NULL - ); - - gBS->CloseProtocol ( - Controller, - &gEfiPciIoProtocolGuid, - This->DriverBindingHandle, - Private->Handle - ); - - FreePool (Private->ModeData); - gBS->UninstallProtocolInterface (Private->Handle, - &gEfiDevicePathProtocolGuid, Private->GopDevicePath); - FreePool (Private->GopDevicePath); - - // - // Free our instance data - // - gBS->FreePool (Private); - - return EFI_SUCCESS; -} - -/** - TODO: Add function description - - @param Private TODO: add argument description - @param Address TODO: add argument description - @param Data TODO: add argument description - - TODO: add return values - -**/ -VOID -outb ( - QEMU_VIDEO_PRIVATE_DATA *Private, - UINTN Address, - UINT8 Data - ) -{ - Private->PciIo->Io.Write ( - Private->PciIo, - EfiPciIoWidthUint8, - EFI_PCI_IO_PASS_THROUGH_BAR, - Address, - 1, - &Data - ); -} - -/** - TODO: Add function description - - @param Private TODO: add argument description - @param Address TODO: add argument description - @param Data TODO: add argument description - - TODO: add return values - -**/ -VOID -outw ( - QEMU_VIDEO_PRIVATE_DATA *Private, - UINTN Address, - UINT16 Data - ) -{ - Private->PciIo->Io.Write ( - Private->PciIo, - EfiPciIoWidthUint16, - EFI_PCI_IO_PASS_THROUGH_BAR, - Address, - 1, - &Data - ); -} - -/** - TODO: Add function description - - @param Private TODO: add argument description - @param Address TODO: add argument description - - TODO: add return values - -**/ -UINT8 -inb ( - QEMU_VIDEO_PRIVATE_DATA *Private, - UINTN Address - ) -{ - UINT8 Data; - - Private->PciIo->Io.Read ( - Private->PciIo, - EfiPciIoWidthUint8, - EFI_PCI_IO_PASS_THROUGH_BAR, - Address, - 1, - &Data - ); - return Data; -} - -/** - TODO: Add function description - - @param Private TODO: add argument description - @param Address TODO: add argument description - - TODO: add return values - -**/ -UINT16 -inw ( - QEMU_VIDEO_PRIVATE_DATA *Private, - UINTN Address - ) -{ - UINT16 Data; - - Private->PciIo->Io.Read ( - Private->PciIo, - EfiPciIoWidthUint16, - EFI_PCI_IO_PASS_THROUGH_BAR, - Address, - 1, - &Data - ); - return Data; -} - -/** - TODO: Add function description - - @param Private TODO: add argument description - @param Index TODO: add argument description - @param Red TODO: add argument description - @param Green TODO: add argument description - @param Blue TODO: add argument description - - TODO: add return values - -**/ -VOID -SetPaletteColor ( - QEMU_VIDEO_PRIVATE_DATA *Private, - UINTN Index, - UINT8 Red, - UINT8 Green, - UINT8 Blue - ) -{ - VgaOutb (Private, PALETTE_INDEX_REGISTER, (UINT8) Index); - VgaOutb (Private, PALETTE_DATA_REGISTER, (UINT8) (Red >> 2)); - VgaOutb (Private, PALETTE_DATA_REGISTER, (UINT8) (Green >> 2)); - VgaOutb (Private, PALETTE_DATA_REGISTER, (UINT8) (Blue >> 2)); -} - -/** - TODO: Add function description - - @param Private TODO: add argument description - - TODO: add return values - -**/ -VOID -SetDefaultPalette ( - QEMU_VIDEO_PRIVATE_DATA *Private - ) -{ - UINTN Index; - UINTN RedIndex; - UINTN GreenIndex; - UINTN BlueIndex; - - Index = 0; - for (RedIndex = 0; RedIndex < 8; RedIndex++) { - for (GreenIndex = 0; GreenIndex < 8; GreenIndex++) { - for (BlueIndex = 0; BlueIndex < 4; BlueIndex++) { - SetPaletteColor (Private, Index, (UINT8) (RedIndex << 5), (UINT8) (GreenIndex << 5), (UINT8) (BlueIndex << 6)); - Index++; - } - } - } -} - -/** - TODO: Add function description - - @param Private TODO: add argument description - - TODO: add return values - -**/ -VOID -ClearScreen ( - QEMU_VIDEO_PRIVATE_DATA *Private - ) -{ - UINT32 Color; - - Color = 0; - Private->PciIo->Mem.Write ( - Private->PciIo, - EfiPciIoWidthFillUint32, - 0, - 0, - 0x400000 >> 2, - &Color - ); -} - -/** - TODO: Add function description - - @param Private TODO: add argument description - - TODO: add return values - -**/ -VOID -DrawLogo ( - QEMU_VIDEO_PRIVATE_DATA *Private, - UINTN ScreenWidth, - UINTN ScreenHeight - ) -{ -} - -/** - TODO: Add function description - - @param Private TODO: add argument description - @param ModeData TODO: add argument description - - TODO: add return values - -**/ -VOID -InitializeCirrusGraphicsMode ( - QEMU_VIDEO_PRIVATE_DATA *Private, - QEMU_VIDEO_CIRRUS_MODES *ModeData - ) -{ - UINT8 Byte; - UINTN Index; - - outw (Private, SEQ_ADDRESS_REGISTER, 0x1206); - outw (Private, SEQ_ADDRESS_REGISTER, 0x0012); - - for (Index = 0; Index < 15; Index++) { - outw (Private, SEQ_ADDRESS_REGISTER, ModeData->SeqSettings[Index]); - } - - if (Private->Variant == QEMU_VIDEO_CIRRUS_5430) { - outb (Private, SEQ_ADDRESS_REGISTER, 0x0f); - Byte = (UINT8) ((inb (Private, SEQ_DATA_REGISTER) & 0xc7) ^ 0x30); - outb (Private, SEQ_DATA_REGISTER, Byte); - } - - outb (Private, MISC_OUTPUT_REGISTER, ModeData->MiscSetting); - outw (Private, GRAPH_ADDRESS_REGISTER, 0x0506); - outw (Private, SEQ_ADDRESS_REGISTER, 0x0300); - outw (Private, CRTC_ADDRESS_REGISTER, 0x2011); - - for (Index = 0; Index < 28; Index++) { - outw (Private, CRTC_ADDRESS_REGISTER, (UINT16) ((ModeData->CrtcSettings[Index] << 8) | Index)); - } - - for (Index = 0; Index < 9; Index++) { - outw (Private, GRAPH_ADDRESS_REGISTER, (UINT16) ((GraphicsController[Index] << 8) | Index)); - } - - inb (Private, INPUT_STATUS_1_REGISTER); - - for (Index = 0; Index < 21; Index++) { - outb (Private, ATT_ADDRESS_REGISTER, (UINT8) Index); - outb (Private, ATT_ADDRESS_REGISTER, AttributeController[Index]); - } - - outb (Private, ATT_ADDRESS_REGISTER, 0x20); - - outw (Private, GRAPH_ADDRESS_REGISTER, 0x0009); - outw (Private, GRAPH_ADDRESS_REGISTER, 0x000a); - outw (Private, GRAPH_ADDRESS_REGISTER, 0x000b); - outb (Private, DAC_PIXEL_MASK_REGISTER, 0xff); - - SetDefaultPalette (Private); - ClearScreen (Private); -} - -VOID -BochsWrite ( - QEMU_VIDEO_PRIVATE_DATA *Private, - UINT16 Reg, - UINT16 Data - ) -{ - EFI_STATUS Status; - - if (Private->Variant == QEMU_VIDEO_BOCHS_MMIO) { - Status = Private->PciIo->Mem.Write ( - Private->PciIo, - EfiPciIoWidthUint16, - PCI_BAR_IDX2, - 0x500 + (Reg << 1), - 1, - &Data - ); - ASSERT_EFI_ERROR (Status); - } else { - outw (Private, VBE_DISPI_IOPORT_INDEX, Reg); - outw (Private, VBE_DISPI_IOPORT_DATA, Data); - } -} - -UINT16 -BochsRead ( - QEMU_VIDEO_PRIVATE_DATA *Private, - UINT16 Reg - ) -{ - EFI_STATUS Status; - UINT16 Data; - - if (Private->Variant == QEMU_VIDEO_BOCHS_MMIO) { - Status = Private->PciIo->Mem.Read ( - Private->PciIo, - EfiPciIoWidthUint16, - PCI_BAR_IDX2, - 0x500 + (Reg << 1), - 1, - &Data - ); - ASSERT_EFI_ERROR (Status); - } else { - outw (Private, VBE_DISPI_IOPORT_INDEX, Reg); - Data = inw (Private, VBE_DISPI_IOPORT_DATA); - } - return Data; -} - -VOID -VgaOutb ( - QEMU_VIDEO_PRIVATE_DATA *Private, - UINTN Reg, - UINT8 Data - ) -{ - EFI_STATUS Status; - - if (Private->Variant == QEMU_VIDEO_BOCHS_MMIO) { - Status = Private->PciIo->Mem.Write ( - Private->PciIo, - EfiPciIoWidthUint8, - PCI_BAR_IDX2, - 0x400 - 0x3c0 + Reg, - 1, - &Data - ); - ASSERT_EFI_ERROR (Status); - } else { - outb (Private, Reg, Data); - } -} - -VOID -InitializeBochsGraphicsMode ( - QEMU_VIDEO_PRIVATE_DATA *Private, - QEMU_VIDEO_BOCHS_MODES *ModeData - ) -{ - DEBUG ((EFI_D_INFO, "InitializeBochsGraphicsMode: %dx%d @ %d\n", - ModeData->Width, ModeData->Height, ModeData->ColorDepth)); - - /* unblank */ - VgaOutb (Private, ATT_ADDRESS_REGISTER, 0x20); - - BochsWrite (Private, VBE_DISPI_INDEX_ENABLE, 0); - BochsWrite (Private, VBE_DISPI_INDEX_BANK, 0); - BochsWrite (Private, VBE_DISPI_INDEX_X_OFFSET, 0); - BochsWrite (Private, VBE_DISPI_INDEX_Y_OFFSET, 0); - - BochsWrite (Private, VBE_DISPI_INDEX_BPP, (UINT16) ModeData->ColorDepth); - BochsWrite (Private, VBE_DISPI_INDEX_XRES, (UINT16) ModeData->Width); - BochsWrite (Private, VBE_DISPI_INDEX_VIRT_WIDTH, (UINT16) ModeData->Width); - BochsWrite (Private, VBE_DISPI_INDEX_YRES, (UINT16) ModeData->Height); - BochsWrite (Private, VBE_DISPI_INDEX_VIRT_HEIGHT, (UINT16) ModeData->Height); - - BochsWrite (Private, VBE_DISPI_INDEX_ENABLE, - VBE_DISPI_ENABLED | VBE_DISPI_LFB_ENABLED); - - SetDefaultPalette (Private); - ClearScreen (Private); -} - -EFI_STATUS -EFIAPI -InitializeQemuVideo ( - IN EFI_HANDLE ImageHandle, - IN EFI_SYSTEM_TABLE *SystemTable - ) -{ - EFI_STATUS Status; - - Status = EfiLibInstallDriverBindingComponentName2 ( - ImageHandle, - SystemTable, - &gQemuVideoDriverBinding, - ImageHandle, - &gQemuVideoComponentName, - &gQemuVideoComponentName2 - ); - ASSERT_EFI_ERROR (Status); - - // - // Install EFI Driver Supported EFI Version Protocol required for - // EFI drivers that are on PCI and other plug in cards. - // - gQemuVideoDriverSupportedEfiVersion.FirmwareVersion = PcdGet32 (PcdDriverSupportedEfiVersion); - Status = gBS->InstallMultipleProtocolInterfaces ( - &ImageHandle, - &gEfiDriverSupportedEfiVersionProtocolGuid, - &gQemuVideoDriverSupportedEfiVersion, - NULL - ); - ASSERT_EFI_ERROR (Status); - - return Status; -} diff --git a/OvmfPkg/QemuVideoDxe/DriverSupportedEfiVersion.c b/OvmfPkg/QemuVideoDxe/DriverSupportedEfiVersion.c deleted file mode 100644 index 5691e410ed..0000000000 --- a/OvmfPkg/QemuVideoDxe/DriverSupportedEfiVersion.c +++ /dev/null @@ -1,21 +0,0 @@ -/** @file - Driver supported version protocol for the QEMU video driver. - - Copyright (c) 2007 - 2010, Intel Corporation. All rights reserved.
- - This program and the accompanying materials - are licensed and made available under the terms and conditions of the BSD License - which accompanies this distribution. The full text of the license may be found at - http://opensource.org/licenses/bsd-license.php - - THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, - WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. - -**/ -#include "Qemu.h" - -EFI_DRIVER_SUPPORTED_EFI_VERSION_PROTOCOL gQemuVideoDriverSupportedEfiVersion = { - sizeof (EFI_DRIVER_SUPPORTED_EFI_VERSION_PROTOCOL), // Size of Protocol structure. - 0 // Version number to be filled at start up. -}; - diff --git a/OvmfPkg/QemuVideoDxe/Gop.c b/OvmfPkg/QemuVideoDxe/Gop.c deleted file mode 100644 index 359e9217d3..0000000000 --- a/OvmfPkg/QemuVideoDxe/Gop.c +++ /dev/null @@ -1,405 +0,0 @@ -/** @file - Graphics Output Protocol functions for the QEMU video controller. - - Copyright (c) 2007 - 2017, Intel Corporation. All rights reserved.
- - This program and the accompanying materials - are licensed and made available under the terms and conditions of the BSD License - which accompanies this distribution. The full text of the license may be found at - http://opensource.org/licenses/bsd-license.php - - THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, - WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. - -**/ - -#include "Qemu.h" - -STATIC -VOID -QemuVideoCompleteModeInfo ( - IN QEMU_VIDEO_MODE_DATA *ModeData, - OUT EFI_GRAPHICS_OUTPUT_MODE_INFORMATION *Info - ) -{ - Info->Version = 0; - if (ModeData->ColorDepth == 8) { - Info->PixelFormat = PixelBitMask; - Info->PixelInformation.RedMask = PIXEL_RED_MASK; - Info->PixelInformation.GreenMask = PIXEL_GREEN_MASK; - Info->PixelInformation.BlueMask = PIXEL_BLUE_MASK; - Info->PixelInformation.ReservedMask = 0; - } else if (ModeData->ColorDepth == 24) { - Info->PixelFormat = PixelBitMask; - Info->PixelInformation.RedMask = PIXEL24_RED_MASK; - Info->PixelInformation.GreenMask = PIXEL24_GREEN_MASK; - Info->PixelInformation.BlueMask = PIXEL24_BLUE_MASK; - Info->PixelInformation.ReservedMask = 0; - } else if (ModeData->ColorDepth == 32) { - DEBUG ((EFI_D_INFO, "PixelBlueGreenRedReserved8BitPerColor\n")); - Info->PixelFormat = PixelBlueGreenRedReserved8BitPerColor; - } - Info->PixelsPerScanLine = Info->HorizontalResolution; -} - - -STATIC -EFI_STATUS -QemuVideoCompleteModeData ( - IN QEMU_VIDEO_PRIVATE_DATA *Private, - OUT EFI_GRAPHICS_OUTPUT_PROTOCOL_MODE *Mode - ) -{ - EFI_GRAPHICS_OUTPUT_MODE_INFORMATION *Info; - EFI_ACPI_ADDRESS_SPACE_DESCRIPTOR *FrameBufDesc; - QEMU_VIDEO_MODE_DATA *ModeData; - - ModeData = &Private->ModeData[Mode->Mode]; - Info = Mode->Info; - QemuVideoCompleteModeInfo (ModeData, Info); - - Private->PciIo->GetBarAttributes ( - Private->PciIo, - 0, - NULL, - (VOID**) &FrameBufDesc - ); - - Mode->FrameBufferBase = FrameBufDesc->AddrRangeMin; - Mode->FrameBufferSize = Info->HorizontalResolution * Info->VerticalResolution; - Mode->FrameBufferSize = Mode->FrameBufferSize * ((ModeData->ColorDepth + 7) / 8); - DEBUG ((EFI_D_INFO, "FrameBufferBase: 0x%Lx, FrameBufferSize: 0x%Lx\n", - Mode->FrameBufferBase, (UINT64)Mode->FrameBufferSize)); - - FreePool (FrameBufDesc); - return EFI_SUCCESS; -} - - -// -// Graphics Output Protocol Member Functions -// -EFI_STATUS -EFIAPI -QemuVideoGraphicsOutputQueryMode ( - IN EFI_GRAPHICS_OUTPUT_PROTOCOL *This, - IN UINT32 ModeNumber, - OUT UINTN *SizeOfInfo, - OUT EFI_GRAPHICS_OUTPUT_MODE_INFORMATION **Info - ) -/*++ - -Routine Description: - - Graphics Output protocol interface to query video mode - - Arguments: - This - Protocol instance pointer. - ModeNumber - The mode number to return information on. - Info - Caller allocated buffer that returns information about ModeNumber. - SizeOfInfo - A pointer to the size, in bytes, of the Info buffer. - - Returns: - EFI_SUCCESS - Mode information returned. - EFI_BUFFER_TOO_SMALL - The Info buffer was too small. - EFI_DEVICE_ERROR - A hardware error occurred trying to retrieve the video mode. - EFI_NOT_STARTED - Video display is not initialized. Call SetMode () - EFI_INVALID_PARAMETER - One of the input args was NULL. - ---*/ -{ - QEMU_VIDEO_PRIVATE_DATA *Private; - QEMU_VIDEO_MODE_DATA *ModeData; - - Private = QEMU_VIDEO_PRIVATE_DATA_FROM_GRAPHICS_OUTPUT_THIS (This); - - if (Info == NULL || SizeOfInfo == NULL || ModeNumber >= This->Mode->MaxMode) { - return EFI_INVALID_PARAMETER; - } - - *Info = AllocatePool (sizeof (EFI_GRAPHICS_OUTPUT_MODE_INFORMATION)); - if (*Info == NULL) { - return EFI_OUT_OF_RESOURCES; - } - - *SizeOfInfo = sizeof (EFI_GRAPHICS_OUTPUT_MODE_INFORMATION); - - ModeData = &Private->ModeData[ModeNumber]; - (*Info)->HorizontalResolution = ModeData->HorizontalResolution; - (*Info)->VerticalResolution = ModeData->VerticalResolution; - QemuVideoCompleteModeInfo (ModeData, *Info); - - return EFI_SUCCESS; -} - -EFI_STATUS -EFIAPI -QemuVideoGraphicsOutputSetMode ( - IN EFI_GRAPHICS_OUTPUT_PROTOCOL *This, - IN UINT32 ModeNumber - ) -/*++ - -Routine Description: - - Graphics Output protocol interface to set video mode - - Arguments: - This - Protocol instance pointer. - ModeNumber - The mode number to be set. - - Returns: - EFI_SUCCESS - Graphics mode was changed. - EFI_DEVICE_ERROR - The device had an error and could not complete the request. - EFI_UNSUPPORTED - ModeNumber is not supported by this device. - ---*/ -{ - QEMU_VIDEO_PRIVATE_DATA *Private; - QEMU_VIDEO_MODE_DATA *ModeData; - RETURN_STATUS Status; - - Private = QEMU_VIDEO_PRIVATE_DATA_FROM_GRAPHICS_OUTPUT_THIS (This); - - if (ModeNumber >= This->Mode->MaxMode) { - return EFI_UNSUPPORTED; - } - - ModeData = &Private->ModeData[ModeNumber]; - - switch (Private->Variant) { - case QEMU_VIDEO_CIRRUS_5430: - case QEMU_VIDEO_CIRRUS_5446: - InitializeCirrusGraphicsMode (Private, &QemuVideoCirrusModes[ModeData->InternalModeIndex]); - break; - case QEMU_VIDEO_BOCHS_MMIO: - case QEMU_VIDEO_BOCHS: - InitializeBochsGraphicsMode (Private, &QemuVideoBochsModes[ModeData->InternalModeIndex]); - break; - default: - ASSERT (FALSE); - return EFI_DEVICE_ERROR; - } - - This->Mode->Mode = ModeNumber; - This->Mode->Info->HorizontalResolution = ModeData->HorizontalResolution; - This->Mode->Info->VerticalResolution = ModeData->VerticalResolution; - This->Mode->SizeOfInfo = sizeof(EFI_GRAPHICS_OUTPUT_MODE_INFORMATION); - - QemuVideoCompleteModeData (Private, This->Mode); - - // - // Re-initialize the frame buffer configure when mode changes. - // - Status = FrameBufferBltConfigure ( - (VOID*) (UINTN) This->Mode->FrameBufferBase, - This->Mode->Info, - Private->FrameBufferBltConfigure, - &Private->FrameBufferBltConfigureSize - ); - if (Status == RETURN_BUFFER_TOO_SMALL) { - // - // Frame buffer configure may be larger in new mode. - // - if (Private->FrameBufferBltConfigure != NULL) { - FreePool (Private->FrameBufferBltConfigure); - } - Private->FrameBufferBltConfigure = - AllocatePool (Private->FrameBufferBltConfigureSize); - ASSERT (Private->FrameBufferBltConfigure != NULL); - - // - // Create the configuration for FrameBufferBltLib - // - Status = FrameBufferBltConfigure ( - (VOID*) (UINTN) This->Mode->FrameBufferBase, - This->Mode->Info, - Private->FrameBufferBltConfigure, - &Private->FrameBufferBltConfigureSize - ); - } - ASSERT (Status == RETURN_SUCCESS); - - return EFI_SUCCESS; -} - -EFI_STATUS -EFIAPI -QemuVideoGraphicsOutputBlt ( - IN EFI_GRAPHICS_OUTPUT_PROTOCOL *This, - IN EFI_GRAPHICS_OUTPUT_BLT_PIXEL *BltBuffer, OPTIONAL - IN EFI_GRAPHICS_OUTPUT_BLT_OPERATION BltOperation, - IN UINTN SourceX, - IN UINTN SourceY, - IN UINTN DestinationX, - IN UINTN DestinationY, - IN UINTN Width, - IN UINTN Height, - IN UINTN Delta - ) -/*++ - -Routine Description: - - Graphics Output protocol instance to block transfer for CirrusLogic device - -Arguments: - - This - Pointer to Graphics Output protocol instance - BltBuffer - The data to transfer to screen - BltOperation - The operation to perform - SourceX - The X coordinate of the source for BltOperation - SourceY - The Y coordinate of the source for BltOperation - DestinationX - The X coordinate of the destination for BltOperation - DestinationY - The Y coordinate of the destination for BltOperation - Width - The width of a rectangle in the blt rectangle in pixels - Height - The height of a rectangle in the blt rectangle in pixels - Delta - Not used for EfiBltVideoFill and EfiBltVideoToVideo operation. - If a Delta of 0 is used, the entire BltBuffer will be operated on. - If a subrectangle of the BltBuffer is used, then Delta represents - the number of bytes in a row of the BltBuffer. - -Returns: - - EFI_INVALID_PARAMETER - Invalid parameter passed in - EFI_SUCCESS - Blt operation success - ---*/ -{ - EFI_STATUS Status; - EFI_TPL OriginalTPL; - QEMU_VIDEO_PRIVATE_DATA *Private; - - Private = QEMU_VIDEO_PRIVATE_DATA_FROM_GRAPHICS_OUTPUT_THIS (This); - // - // We have to raise to TPL Notify, so we make an atomic write the frame buffer. - // We would not want a timer based event (Cursor, ...) to come in while we are - // doing this operation. - // - OriginalTPL = gBS->RaiseTPL (TPL_NOTIFY); - - switch (BltOperation) { - case EfiBltVideoToBltBuffer: - case EfiBltBufferToVideo: - case EfiBltVideoFill: - case EfiBltVideoToVideo: - Status = FrameBufferBlt ( - Private->FrameBufferBltConfigure, - BltBuffer, - BltOperation, - SourceX, - SourceY, - DestinationX, - DestinationY, - Width, - Height, - Delta - ); - break; - - default: - Status = EFI_INVALID_PARAMETER; - ASSERT (FALSE); - } - - gBS->RestoreTPL (OriginalTPL); - - return Status; -} - -EFI_STATUS -QemuVideoGraphicsOutputConstructor ( - QEMU_VIDEO_PRIVATE_DATA *Private - ) -{ - EFI_STATUS Status; - EFI_GRAPHICS_OUTPUT_PROTOCOL *GraphicsOutput; - - - GraphicsOutput = &Private->GraphicsOutput; - GraphicsOutput->QueryMode = QemuVideoGraphicsOutputQueryMode; - GraphicsOutput->SetMode = QemuVideoGraphicsOutputSetMode; - GraphicsOutput->Blt = QemuVideoGraphicsOutputBlt; - - // - // Initialize the private data - // - Status = gBS->AllocatePool ( - EfiBootServicesData, - sizeof (EFI_GRAPHICS_OUTPUT_PROTOCOL_MODE), - (VOID **) &Private->GraphicsOutput.Mode - ); - if (EFI_ERROR (Status)) { - return Status; - } - - Status = gBS->AllocatePool ( - EfiBootServicesData, - sizeof (EFI_GRAPHICS_OUTPUT_MODE_INFORMATION), - (VOID **) &Private->GraphicsOutput.Mode->Info - ); - if (EFI_ERROR (Status)) { - goto FreeMode; - } - Private->GraphicsOutput.Mode->MaxMode = (UINT32) Private->MaxMode; - Private->GraphicsOutput.Mode->Mode = GRAPHICS_OUTPUT_INVALIDE_MODE_NUMBER; - Private->FrameBufferBltConfigure = NULL; - Private->FrameBufferBltConfigureSize = 0; - - // - // Initialize the hardware - // - Status = GraphicsOutput->SetMode (GraphicsOutput, 0); - if (EFI_ERROR (Status)) { - goto FreeInfo; - } - - DrawLogo ( - Private, - Private->ModeData[Private->GraphicsOutput.Mode->Mode].HorizontalResolution, - Private->ModeData[Private->GraphicsOutput.Mode->Mode].VerticalResolution - ); - - return EFI_SUCCESS; - -FreeInfo: - FreePool (Private->GraphicsOutput.Mode->Info); - -FreeMode: - FreePool (Private->GraphicsOutput.Mode); - Private->GraphicsOutput.Mode = NULL; - - return Status; -} - -EFI_STATUS -QemuVideoGraphicsOutputDestructor ( - QEMU_VIDEO_PRIVATE_DATA *Private - ) -/*++ - -Routine Description: - -Arguments: - -Returns: - - None - ---*/ -{ - if (Private->FrameBufferBltConfigure != NULL) { - FreePool (Private->FrameBufferBltConfigure); - } - - if (Private->GraphicsOutput.Mode != NULL) { - if (Private->GraphicsOutput.Mode->Info != NULL) { - gBS->FreePool (Private->GraphicsOutput.Mode->Info); - } - gBS->FreePool (Private->GraphicsOutput.Mode); - } - - return EFI_SUCCESS; -} - - diff --git a/OvmfPkg/QemuVideoDxe/Initialize.c b/OvmfPkg/QemuVideoDxe/Initialize.c deleted file mode 100644 index d5d8cfef96..0000000000 --- a/OvmfPkg/QemuVideoDxe/Initialize.c +++ /dev/null @@ -1,348 +0,0 @@ -/** @file - Graphics Output Protocol functions for the QEMU video controller. - - Copyright (c) 2007 - 2010, Intel Corporation. All rights reserved.
- - This program and the accompanying materials - are licensed and made available under the terms and conditions of the BSD License - which accompanies this distribution. The full text of the license may be found at - http://opensource.org/licenses/bsd-license.php - - THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, - WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. - -**/ - -#include "Qemu.h" - - -/// -/// Generic Attribute Controller Register Settings -/// -UINT8 AttributeController[21] = { - 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, - 0x08, 0x09, 0x0A, 0x0B, 0x0C, 0x0D, 0x0E, 0x0F, - 0x41, 0x00, 0x0F, 0x00, 0x00 -}; - -/// -/// Generic Graphics Controller Register Settings -/// -UINT8 GraphicsController[9] = { - 0x00, 0x00, 0x00, 0x00, 0x00, 0x40, 0x05, 0x0F, 0xFF -}; - -// -// 640 x 480 x 256 color @ 60 Hertz -// -UINT8 Crtc_640_480_256_60[28] = { - 0x5d, 0x4f, 0x50, 0x82, 0x53, 0x9f, 0x00, 0x3e, - 0x00, 0x40, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0xe1, 0x83, 0xdf, 0x50, 0x00, 0xe7, 0x04, 0xe3, - 0xff, 0x00, 0x00, 0x22 -}; - -UINT8 Crtc_640_480_32bpp_60[28] = { - 0x5d, 0x4f, 0x50, 0x82, 0x53, 0x9f, 0x00, 0x3e, - 0x00, 0x40, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0xe1, 0x83, 0xdf, 0x40, 0x00, 0xe7, 0x04, 0xe3, - 0xff, 0x00, 0x00, 0x32 -}; - -UINT16 Seq_640_480_256_60[15] = { - 0x0100, 0x0101, 0x0f02, 0x0003, 0x0e04, 0x1107, 0x0008, 0x4a0b, - 0x5b0c, 0x450d, 0x7e0e, 0x2b1b, 0x2f1c, 0x301d, 0x331e -}; - -UINT16 Seq_640_480_32bpp_60[15] = { - 0x0100, 0x0101, 0x0f02, 0x0003, 0x0e04, 0x1907, 0x0008, 0x4a0b, - 0x5b0c, 0x450d, 0x7e0e, 0x2b1b, 0x2f1c, 0x301d, 0x331e -}; - -// -// 800 x 600 x 256 color @ 60 Hertz -// -UINT8 Crtc_800_600_256_60[28] = { - 0x7F, 0x63, 0x64, 0x80, 0x6B, 0x1B, 0x72, 0xF0, - 0x00, 0x60, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x58, 0x8C, 0x57, 0x64, 0x00, 0x5F, 0x91, 0xE3, - 0xFF, 0x00, 0x00, 0x22 -}; - -UINT8 Crtc_800_600_32bpp_60[28] = { - 0x7F, 0x63, 0x64, 0x80, 0x6B, 0x1B, 0x72, 0xF0, - 0x00, 0x60, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x58, 0x8C, 0x57, 0x90, 0x00, 0x5F, 0x91, 0xE3, - 0xFF, 0x00, 0x00, 0x32 -}; - -UINT16 Seq_800_600_256_60[15] = { - 0x0100, 0x0101, 0x0f02, 0x0003, 0x0e04, 0x1107, 0x0008, 0x4a0b, - 0x5b0c, 0x450d, 0x510e, 0x2b1b, 0x2f1c, 0x301d, 0x3a1e -}; - -UINT16 Seq_800_600_32bpp_60[15] = { - 0x0100, 0x0101, 0x0f02, 0x0003, 0x0e04, 0x1907, 0x0008, 0x4a0b, - 0x5b0c, 0x450d, 0x510e, 0x2b1b, 0x2f1c, 0x301d, 0x3a1e -}; - -UINT8 Crtc_960_720_32bpp_60[28] = { - 0xA3, 0x77, 0x80, 0x86, 0x85, 0x96, 0x24, 0xFD, - 0x00, 0x60, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x02, 0x88, 0xCF, 0xe0, 0x00, 0x00, 0x64, 0xE3, - 0xFF, 0x4A, 0x00, 0x32 -}; - -UINT16 Seq_960_720_32bpp_60[15] = { - 0x0100, 0x0101, 0x0f02, 0x0003, 0x0e04, 0x1907, 0x0008, 0x4a0b, - 0x5b0c, 0x450d, 0x760e, 0x2b1b, 0x2f1c, 0x301d, 0x341e -}; - -// -// 1024 x 768 x 256 color @ 60 Hertz -// -UINT8 Crtc_1024_768_256_60[28] = { - 0xA3, 0x7F, 0x80, 0x86, 0x85, 0x96, 0x24, 0xFD, - 0x00, 0x60, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x02, 0x88, 0xFF, 0x80, 0x00, 0x00, 0x24, 0xE3, - 0xFF, 0x4A, 0x00, 0x22 -}; - -UINT16 Seq_1024_768_256_60[15] = { - 0x0100, 0x0101, 0x0f02, 0x0003, 0x0e04, 0x1107, 0x0008, 0x4a0b, - 0x5b0c, 0x450d, 0x760e, 0x2b1b, 0x2f1c, 0x301d, 0x341e -}; - -// -// 1024 x 768 x 24-bit color @ 60 Hertz -// -UINT8 Crtc_1024_768_24bpp_60[28] = { - 0xA3, 0x7F, 0x80, 0x86, 0x85, 0x96, 0x24, 0xFD, - 0x00, 0x60, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x02, 0x88, 0xFF, 0x80, 0x00, 0x00, 0x24, 0xE3, - 0xFF, 0x4A, 0x00, 0x32 -}; - -UINT16 Seq_1024_768_24bpp_60[15] = { - 0x0100, 0x0101, 0x0f02, 0x0003, 0x0e04, 0x1507, 0x0008, 0x4a0b, - 0x5b0c, 0x450d, 0x760e, 0x2b1b, 0x2f1c, 0x301d, 0x341e -}; - -UINT8 Crtc_1024_768_32bpp_60[28] = { - 0xA3, 0x7F, 0x80, 0x86, 0x85, 0x96, 0x24, 0xFD, - 0x00, 0x60, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x02, 0x88, 0xFF, 0xe0, 0x00, 0x00, 0x64, 0xE3, - 0xFF, 0x4A, 0x00, 0x32 -}; - -UINT16 Seq_1024_768_32bpp_60[15] = { - 0x0100, 0x0101, 0x0f02, 0x0003, 0x0e04, 0x1907, 0x0008, 0x4a0b, - 0x5b0c, 0x450d, 0x760e, 0x2b1b, 0x2f1c, 0x301d, 0x341e -}; - -/// -/// Table of supported video modes -/// -QEMU_VIDEO_CIRRUS_MODES QemuVideoCirrusModes[] = { -// { 640, 480, 8, Crtc_640_480_256_60, Seq_640_480_256_60, 0xe3 }, -// { 800, 600, 8, Crtc_800_600_256_60, Seq_800_600_256_60, 0xef }, - { 640, 480, 32, Crtc_640_480_32bpp_60, Seq_640_480_32bpp_60, 0xef }, - { 800, 600, 32, Crtc_800_600_32bpp_60, Seq_800_600_32bpp_60, 0xef }, -// { 1024, 768, 8, Crtc_1024_768_256_60, Seq_1024_768_256_60, 0xef } - { 1024, 768, 24, Crtc_1024_768_24bpp_60, Seq_1024_768_24bpp_60, 0xef } -// { 1024, 768, 32, Crtc_1024_768_32bpp_60, Seq_1024_768_32bpp_60, 0xef } -// { 960, 720, 32, Crtc_960_720_32bpp_60, Seq_1024_768_32bpp_60, 0xef } -}; - -#define QEMU_VIDEO_CIRRUS_MODE_COUNT \ - (ARRAY_SIZE (QemuVideoCirrusModes)) - -/** - Construct the valid video modes for QemuVideo. - -**/ -EFI_STATUS -QemuVideoCirrusModeSetup ( - QEMU_VIDEO_PRIVATE_DATA *Private - ) -{ - UINT32 Index; - QEMU_VIDEO_MODE_DATA *ModeData; - QEMU_VIDEO_CIRRUS_MODES *VideoMode; - - // - // Setup Video Modes - // - Private->ModeData = AllocatePool ( - sizeof (Private->ModeData[0]) * QEMU_VIDEO_CIRRUS_MODE_COUNT - ); - if (Private->ModeData == NULL) { - return EFI_OUT_OF_RESOURCES; - } - ModeData = Private->ModeData; - VideoMode = &QemuVideoCirrusModes[0]; - for (Index = 0; Index < QEMU_VIDEO_CIRRUS_MODE_COUNT; Index ++) { - ModeData->InternalModeIndex = Index; - ModeData->HorizontalResolution = VideoMode->Width; - ModeData->VerticalResolution = VideoMode->Height; - ModeData->ColorDepth = VideoMode->ColorDepth; - DEBUG ((EFI_D_INFO, - "Adding Mode %d as Cirrus Internal Mode %d: %dx%d, %d-bit\n", - (INT32) (ModeData - Private->ModeData), - ModeData->InternalModeIndex, - ModeData->HorizontalResolution, - ModeData->VerticalResolution, - ModeData->ColorDepth - )); - - ModeData ++ ; - VideoMode ++; - } - Private->MaxMode = ModeData - Private->ModeData; - - return EFI_SUCCESS; -} - -/// -/// Table of supported video modes -/// -QEMU_VIDEO_BOCHS_MODES QemuVideoBochsModes[] = { - { 640, 480, 32 }, - { 800, 480, 32 }, - { 800, 600, 32 }, - { 832, 624, 32 }, - { 960, 640, 32 }, - { 1024, 600, 32 }, - { 1024, 768, 32 }, - { 1152, 864, 32 }, - { 1152, 870, 32 }, - { 1280, 720, 32 }, - { 1280, 760, 32 }, - { 1280, 768, 32 }, - { 1280, 800, 32 }, - { 1280, 960, 32 }, - { 1280, 1024, 32 }, - { 1360, 768, 32 }, - { 1366, 768, 32 }, - { 1400, 1050, 32 }, - { 1440, 900, 32 }, - { 1600, 900, 32 }, - { 1600, 1200, 32 }, - { 1680, 1050, 32 }, - { 1920, 1080, 32 }, - { 1920, 1200, 32 }, - { 1920, 1440, 32 }, - { 2000, 2000, 32 }, - { 2048, 1536, 32 }, - { 2048, 2048, 32 }, - { 2560, 1440, 32 }, - { 2560, 1600, 32 }, - { 2560, 2048, 32 }, - { 2800, 2100, 32 }, - { 3200, 2400, 32 }, - { 3840, 2160, 32 }, - { 4096, 2160, 32 }, - { 7680, 4320, 32 }, - { 8192, 4320, 32 } -}; - -#define QEMU_VIDEO_BOCHS_MODE_COUNT \ - (ARRAY_SIZE (QemuVideoBochsModes)) - -EFI_STATUS -QemuVideoBochsModeSetup ( - QEMU_VIDEO_PRIVATE_DATA *Private, - BOOLEAN IsQxl - ) -{ - UINT32 AvailableFbSize; - UINT32 Index; - QEMU_VIDEO_MODE_DATA *ModeData; - QEMU_VIDEO_BOCHS_MODES *VideoMode; - - // - // Fetch the available framebuffer size. - // - // VBE_DISPI_INDEX_VIDEO_MEMORY_64K is expected to return the size of the - // drawable framebuffer. Up to and including qemu-2.1 however it used to - // return the size of PCI BAR 0 (ie. the full video RAM size). - // - // On stdvga the two concepts coincide with each other; the full memory size - // is usable for drawing. - // - // On QXL however, only a leading segment, "surface 0", can be used for - // drawing; the rest of the video memory is used for the QXL guest-host - // protocol. VBE_DISPI_INDEX_VIDEO_MEMORY_64K should report the size of - // "surface 0", but since it doesn't (up to and including qemu-2.1), we - // retrieve the size of the drawable portion from a field in the QXL ROM BAR, - // where it is also available. - // - if (IsQxl) { - UINT32 Signature; - UINT32 DrawStart; - - Signature = 0; - DrawStart = 0xFFFFFFFF; - AvailableFbSize = 0; - if (EFI_ERROR ( - Private->PciIo->Mem.Read (Private->PciIo, EfiPciIoWidthUint32, - PCI_BAR_IDX2, 0, 1, &Signature)) || - Signature != SIGNATURE_32 ('Q', 'X', 'R', 'O') || - EFI_ERROR ( - Private->PciIo->Mem.Read (Private->PciIo, EfiPciIoWidthUint32, - PCI_BAR_IDX2, 36, 1, &DrawStart)) || - DrawStart != 0 || - EFI_ERROR ( - Private->PciIo->Mem.Read (Private->PciIo, EfiPciIoWidthUint32, - PCI_BAR_IDX2, 40, 1, &AvailableFbSize))) { - DEBUG ((EFI_D_ERROR, "%a: can't read size of drawable buffer from QXL " - "ROM\n", __FUNCTION__)); - return EFI_NOT_FOUND; - } - } else { - AvailableFbSize = BochsRead (Private, VBE_DISPI_INDEX_VIDEO_MEMORY_64K); - AvailableFbSize *= SIZE_64KB; - } - DEBUG ((EFI_D_INFO, "%a: AvailableFbSize=0x%x\n", __FUNCTION__, - AvailableFbSize)); - - // - // Setup Video Modes - // - Private->ModeData = AllocatePool ( - sizeof (Private->ModeData[0]) * QEMU_VIDEO_BOCHS_MODE_COUNT - ); - if (Private->ModeData == NULL) { - return EFI_OUT_OF_RESOURCES; - } - ModeData = Private->ModeData; - VideoMode = &QemuVideoBochsModes[0]; - for (Index = 0; Index < QEMU_VIDEO_BOCHS_MODE_COUNT; Index ++) { - UINTN RequiredFbSize; - - ASSERT (VideoMode->ColorDepth % 8 == 0); - RequiredFbSize = (UINTN) VideoMode->Width * VideoMode->Height * - (VideoMode->ColorDepth / 8); - if (RequiredFbSize <= AvailableFbSize) { - ModeData->InternalModeIndex = Index; - ModeData->HorizontalResolution = VideoMode->Width; - ModeData->VerticalResolution = VideoMode->Height; - ModeData->ColorDepth = VideoMode->ColorDepth; - DEBUG ((EFI_D_INFO, - "Adding Mode %d as Bochs Internal Mode %d: %dx%d, %d-bit\n", - (INT32) (ModeData - Private->ModeData), - ModeData->InternalModeIndex, - ModeData->HorizontalResolution, - ModeData->VerticalResolution, - ModeData->ColorDepth - )); - - ModeData ++ ; - } - VideoMode ++; - } - Private->MaxMode = ModeData - Private->ModeData; - - return EFI_SUCCESS; -} - diff --git a/OvmfPkg/QemuVideoDxe/Qemu.h b/OvmfPkg/QemuVideoDxe/Qemu.h deleted file mode 100644 index 2ce37defc5..0000000000 --- a/OvmfPkg/QemuVideoDxe/Qemu.h +++ /dev/null @@ -1,510 +0,0 @@ -/** @file - QEMU Video Controller Driver - - Copyright (c) 2006 - 2016, Intel Corporation. All rights reserved.
- This program and the accompanying materials - are licensed and made available under the terms and conditions of the BSD License - which accompanies this distribution. The full text of the license may be found at - http://opensource.org/licenses/bsd-license.php - - THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, - WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. - -**/ - -// -// QEMU Video Controller Driver -// - -#ifndef _QEMU_H_ -#define _QEMU_H_ - - -#include -#include -#include -#include -#include - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#include -#include - -// -// QEMU Video PCI Configuration Header values -// -#define CIRRUS_LOGIC_VENDOR_ID 0x1013 -#define CIRRUS_LOGIC_5430_DEVICE_ID 0x00a8 -#define CIRRUS_LOGIC_5430_ALTERNATE_DEVICE_ID 0x00a0 -#define CIRRUS_LOGIC_5446_DEVICE_ID 0x00b8 - -// -// QEMU Vide Graphical Mode Data -// -typedef struct { - UINT32 InternalModeIndex; // points into card-specific mode table - UINT32 HorizontalResolution; - UINT32 VerticalResolution; - UINT32 ColorDepth; -} QEMU_VIDEO_MODE_DATA; - -#define PIXEL_RED_SHIFT 0 -#define PIXEL_GREEN_SHIFT 3 -#define PIXEL_BLUE_SHIFT 6 - -#define PIXEL_RED_MASK (BIT7 | BIT6 | BIT5) -#define PIXEL_GREEN_MASK (BIT4 | BIT3 | BIT2) -#define PIXEL_BLUE_MASK (BIT1 | BIT0) - -#define PIXEL_TO_COLOR_BYTE(pixel, mask, shift) ((UINT8) ((pixel & mask) << shift)) -#define PIXEL_TO_RED_BYTE(pixel) PIXEL_TO_COLOR_BYTE(pixel, PIXEL_RED_MASK, PIXEL_RED_SHIFT) -#define PIXEL_TO_GREEN_BYTE(pixel) PIXEL_TO_COLOR_BYTE(pixel, PIXEL_GREEN_MASK, PIXEL_GREEN_SHIFT) -#define PIXEL_TO_BLUE_BYTE(pixel) PIXEL_TO_COLOR_BYTE(pixel, PIXEL_BLUE_MASK, PIXEL_BLUE_SHIFT) - -#define RGB_BYTES_TO_PIXEL(Red, Green, Blue) \ - (UINT8) ( (((Red) >> PIXEL_RED_SHIFT) & PIXEL_RED_MASK) | \ - (((Green) >> PIXEL_GREEN_SHIFT) & PIXEL_GREEN_MASK) | \ - (((Blue) >> PIXEL_BLUE_SHIFT) & PIXEL_BLUE_MASK) ) - -#define PIXEL24_RED_MASK 0x00ff0000 -#define PIXEL24_GREEN_MASK 0x0000ff00 -#define PIXEL24_BLUE_MASK 0x000000ff - -#define GRAPHICS_OUTPUT_INVALIDE_MODE_NUMBER 0xffff - -// -// QEMU Video Private Data Structure -// -#define QEMU_VIDEO_PRIVATE_DATA_SIGNATURE SIGNATURE_32 ('Q', 'V', 'I', 'D') - -typedef enum { - QEMU_VIDEO_CIRRUS_5430 = 1, - QEMU_VIDEO_CIRRUS_5446, - QEMU_VIDEO_BOCHS, - QEMU_VIDEO_BOCHS_MMIO, -} QEMU_VIDEO_VARIANT; - -typedef struct { - UINT16 VendorId; - UINT16 DeviceId; - QEMU_VIDEO_VARIANT Variant; - CHAR16 *Name; -} QEMU_VIDEO_CARD; - -typedef struct { - UINT64 Signature; - EFI_HANDLE Handle; - EFI_PCI_IO_PROTOCOL *PciIo; - UINT64 OriginalPciAttributes; - EFI_GRAPHICS_OUTPUT_PROTOCOL GraphicsOutput; - EFI_DEVICE_PATH_PROTOCOL *GopDevicePath; - - // - // The next two fields match the client-visible - // EFI_GRAPHICS_OUTPUT_PROTOCOL_MODE.MaxMode field. - // - UINTN MaxMode; - QEMU_VIDEO_MODE_DATA *ModeData; - - QEMU_VIDEO_VARIANT Variant; - FRAME_BUFFER_CONFIGURE *FrameBufferBltConfigure; - UINTN FrameBufferBltConfigureSize; -} QEMU_VIDEO_PRIVATE_DATA; - -/// -/// Card-specific Video Mode structures -/// -typedef struct { - UINT32 Width; - UINT32 Height; - UINT32 ColorDepth; - UINT8 *CrtcSettings; - UINT16 *SeqSettings; - UINT8 MiscSetting; -} QEMU_VIDEO_CIRRUS_MODES; - -typedef struct { - UINT32 Width; - UINT32 Height; - UINT32 ColorDepth; -} QEMU_VIDEO_BOCHS_MODES; - -#define QEMU_VIDEO_PRIVATE_DATA_FROM_GRAPHICS_OUTPUT_THIS(a) \ - CR(a, QEMU_VIDEO_PRIVATE_DATA, GraphicsOutput, QEMU_VIDEO_PRIVATE_DATA_SIGNATURE) - - -// -// Global Variables -// -extern UINT8 AttributeController[]; -extern UINT8 GraphicsController[]; -extern UINT8 Crtc_640_480_256_60[]; -extern UINT16 Seq_640_480_256_60[]; -extern UINT8 Crtc_800_600_256_60[]; -extern UINT16 Seq_800_600_256_60[]; -extern UINT8 Crtc_1024_768_256_60[]; -extern UINT16 Seq_1024_768_256_60[]; -extern QEMU_VIDEO_CIRRUS_MODES QemuVideoCirrusModes[]; -extern QEMU_VIDEO_BOCHS_MODES QemuVideoBochsModes[]; -extern EFI_DRIVER_BINDING_PROTOCOL gQemuVideoDriverBinding; -extern EFI_COMPONENT_NAME_PROTOCOL gQemuVideoComponentName; -extern EFI_COMPONENT_NAME2_PROTOCOL gQemuVideoComponentName2; -extern EFI_DRIVER_SUPPORTED_EFI_VERSION_PROTOCOL gQemuVideoDriverSupportedEfiVersion; - -// -// Io Registers defined by VGA -// -#define CRTC_ADDRESS_REGISTER 0x3d4 -#define CRTC_DATA_REGISTER 0x3d5 -#define SEQ_ADDRESS_REGISTER 0x3c4 -#define SEQ_DATA_REGISTER 0x3c5 -#define GRAPH_ADDRESS_REGISTER 0x3ce -#define GRAPH_DATA_REGISTER 0x3cf -#define ATT_ADDRESS_REGISTER 0x3c0 -#define MISC_OUTPUT_REGISTER 0x3c2 -#define INPUT_STATUS_1_REGISTER 0x3da -#define DAC_PIXEL_MASK_REGISTER 0x3c6 -#define PALETTE_INDEX_REGISTER 0x3c8 -#define PALETTE_DATA_REGISTER 0x3c9 - -#define VBE_DISPI_IOPORT_INDEX 0x01CE -#define VBE_DISPI_IOPORT_DATA 0x01D0 - -#define VBE_DISPI_INDEX_ID 0x0 -#define VBE_DISPI_INDEX_XRES 0x1 -#define VBE_DISPI_INDEX_YRES 0x2 -#define VBE_DISPI_INDEX_BPP 0x3 -#define VBE_DISPI_INDEX_ENABLE 0x4 -#define VBE_DISPI_INDEX_BANK 0x5 -#define VBE_DISPI_INDEX_VIRT_WIDTH 0x6 -#define VBE_DISPI_INDEX_VIRT_HEIGHT 0x7 -#define VBE_DISPI_INDEX_X_OFFSET 0x8 -#define VBE_DISPI_INDEX_Y_OFFSET 0x9 -#define VBE_DISPI_INDEX_VIDEO_MEMORY_64K 0xa - -#define VBE_DISPI_ID0 0xB0C0 -#define VBE_DISPI_ID1 0xB0C1 -#define VBE_DISPI_ID2 0xB0C2 -#define VBE_DISPI_ID3 0xB0C3 -#define VBE_DISPI_ID4 0xB0C4 -#define VBE_DISPI_ID5 0xB0C5 - -#define VBE_DISPI_DISABLED 0x00 -#define VBE_DISPI_ENABLED 0x01 -#define VBE_DISPI_GETCAPS 0x02 -#define VBE_DISPI_8BIT_DAC 0x20 -#define VBE_DISPI_LFB_ENABLED 0x40 -#define VBE_DISPI_NOCLEARMEM 0x80 - -// -// Graphics Output Hardware abstraction internal worker functions -// -EFI_STATUS -QemuVideoGraphicsOutputConstructor ( - QEMU_VIDEO_PRIVATE_DATA *Private - ); - -EFI_STATUS -QemuVideoGraphicsOutputDestructor ( - QEMU_VIDEO_PRIVATE_DATA *Private - ); - - -// -// EFI_DRIVER_BINDING_PROTOCOL Protocol Interface -// -/** - TODO: Add function description - - @param This TODO: add argument description - @param Controller TODO: add argument description - @param RemainingDevicePath TODO: add argument description - - TODO: add return values - -**/ -EFI_STATUS -EFIAPI -QemuVideoControllerDriverSupported ( - IN EFI_DRIVER_BINDING_PROTOCOL *This, - IN EFI_HANDLE Controller, - IN EFI_DEVICE_PATH_PROTOCOL *RemainingDevicePath - ); - -/** - TODO: Add function description - - @param This TODO: add argument description - @param Controller TODO: add argument description - @param RemainingDevicePath TODO: add argument description - - TODO: add return values - -**/ -EFI_STATUS -EFIAPI -QemuVideoControllerDriverStart ( - IN EFI_DRIVER_BINDING_PROTOCOL *This, - IN EFI_HANDLE Controller, - IN EFI_DEVICE_PATH_PROTOCOL *RemainingDevicePath - ); - -/** - TODO: Add function description - - @param This TODO: add argument description - @param Controller TODO: add argument description - @param NumberOfChildren TODO: add argument description - @param ChildHandleBuffer TODO: add argument description - - TODO: add return values - -**/ -EFI_STATUS -EFIAPI -QemuVideoControllerDriverStop ( - IN EFI_DRIVER_BINDING_PROTOCOL *This, - IN EFI_HANDLE Controller, - IN UINTN NumberOfChildren, - IN EFI_HANDLE *ChildHandleBuffer - ); - -// -// EFI Component Name Functions -// -/** - Retrieves a Unicode string that is the user readable name of the driver. - - This function retrieves the user readable name of a driver in the form of a - Unicode string. If the driver specified by This has a user readable name in - the language specified by Language, then a pointer to the driver name is - returned in DriverName, and EFI_SUCCESS is returned. If the driver specified - by This does not support the language specified by Language, - then EFI_UNSUPPORTED is returned. - - @param This[in] A pointer to the EFI_COMPONENT_NAME2_PROTOCOL or - EFI_COMPONENT_NAME_PROTOCOL instance. - - @param Language[in] A pointer to a Null-terminated ASCII string - array indicating the language. This is the - language of the driver name that the caller is - requesting, and it must match one of the - languages specified in SupportedLanguages. The - number of languages supported by a driver is up - to the driver writer. Language is specified - in RFC 4646 or ISO 639-2 language code format. - - @param DriverName[out] A pointer to the Unicode string to return. - This Unicode string is the name of the - driver specified by This in the language - specified by Language. - - @retval EFI_SUCCESS The Unicode string for the Driver specified by - This and the language specified by Language was - returned in DriverName. - - @retval EFI_INVALID_PARAMETER Language is NULL. - - @retval EFI_INVALID_PARAMETER DriverName is NULL. - - @retval EFI_UNSUPPORTED The driver specified by This does not support - the language specified by Language. - -**/ -EFI_STATUS -EFIAPI -QemuVideoComponentNameGetDriverName ( - IN EFI_COMPONENT_NAME_PROTOCOL *This, - IN CHAR8 *Language, - OUT CHAR16 **DriverName - ); - - -/** - Retrieves a Unicode string that is the user readable name of the controller - that is being managed by a driver. - - This function retrieves the user readable name of the controller specified by - ControllerHandle and ChildHandle in the form of a Unicode string. If the - driver specified by This has a user readable name in the language specified by - Language, then a pointer to the controller name is returned in ControllerName, - and EFI_SUCCESS is returned. If the driver specified by This is not currently - managing the controller specified by ControllerHandle and ChildHandle, - then EFI_UNSUPPORTED is returned. If the driver specified by This does not - support the language specified by Language, then EFI_UNSUPPORTED is returned. - - @param This[in] A pointer to the EFI_COMPONENT_NAME2_PROTOCOL or - EFI_COMPONENT_NAME_PROTOCOL instance. - - @param ControllerHandle[in] The handle of a controller that the driver - specified by This is managing. This handle - specifies the controller whose name is to be - returned. - - @param ChildHandle[in] The handle of the child controller to retrieve - the name of. This is an optional parameter that - may be NULL. It will be NULL for device - drivers. It will also be NULL for a bus drivers - that wish to retrieve the name of the bus - controller. It will not be NULL for a bus - driver that wishes to retrieve the name of a - child controller. - - @param Language[in] A pointer to a Null-terminated ASCII string - array indicating the language. This is the - language of the driver name that the caller is - requesting, and it must match one of the - languages specified in SupportedLanguages. The - number of languages supported by a driver is up - to the driver writer. Language is specified in - RFC 4646 or ISO 639-2 language code format. - - @param ControllerName[out] A pointer to the Unicode string to return. - This Unicode string is the name of the - controller specified by ControllerHandle and - ChildHandle in the language specified by - Language from the point of view of the driver - specified by This. - - @retval EFI_SUCCESS The Unicode string for the user readable name in - the language specified by Language for the - driver specified by This was returned in - DriverName. - - @retval EFI_INVALID_PARAMETER ControllerHandle is not a valid EFI_HANDLE. - - @retval EFI_INVALID_PARAMETER ChildHandle is not NULL and it is not a valid - EFI_HANDLE. - - @retval EFI_INVALID_PARAMETER Language is NULL. - - @retval EFI_INVALID_PARAMETER ControllerName is NULL. - - @retval EFI_UNSUPPORTED The driver specified by This is not currently - managing the controller specified by - ControllerHandle and ChildHandle. - - @retval EFI_UNSUPPORTED The driver specified by This does not support - the language specified by Language. - -**/ -EFI_STATUS -EFIAPI -QemuVideoComponentNameGetControllerName ( - IN EFI_COMPONENT_NAME_PROTOCOL *This, - IN EFI_HANDLE ControllerHandle, - IN EFI_HANDLE ChildHandle OPTIONAL, - IN CHAR8 *Language, - OUT CHAR16 **ControllerName - ); - - -// -// Local Function Prototypes -// -VOID -InitializeCirrusGraphicsMode ( - QEMU_VIDEO_PRIVATE_DATA *Private, - QEMU_VIDEO_CIRRUS_MODES *ModeData - ); - -VOID -InitializeBochsGraphicsMode ( - QEMU_VIDEO_PRIVATE_DATA *Private, - QEMU_VIDEO_BOCHS_MODES *ModeData - ); - -VOID -SetPaletteColor ( - QEMU_VIDEO_PRIVATE_DATA *Private, - UINTN Index, - UINT8 Red, - UINT8 Green, - UINT8 Blue - ); - -VOID -SetDefaultPalette ( - QEMU_VIDEO_PRIVATE_DATA *Private - ); - -VOID -DrawLogo ( - QEMU_VIDEO_PRIVATE_DATA *Private, - UINTN ScreenWidth, - UINTN ScreenHeight - ); - -VOID -outb ( - QEMU_VIDEO_PRIVATE_DATA *Private, - UINTN Address, - UINT8 Data - ); - -VOID -outw ( - QEMU_VIDEO_PRIVATE_DATA *Private, - UINTN Address, - UINT16 Data - ); - -UINT8 -inb ( - QEMU_VIDEO_PRIVATE_DATA *Private, - UINTN Address - ); - -UINT16 -inw ( - QEMU_VIDEO_PRIVATE_DATA *Private, - UINTN Address - ); - -VOID -BochsWrite ( - QEMU_VIDEO_PRIVATE_DATA *Private, - UINT16 Reg, - UINT16 Data - ); - -UINT16 -BochsRead ( - QEMU_VIDEO_PRIVATE_DATA *Private, - UINT16 Reg - ); - -VOID -VgaOutb ( - QEMU_VIDEO_PRIVATE_DATA *Private, - UINTN Reg, - UINT8 Data - ); - -EFI_STATUS -QemuVideoCirrusModeSetup ( - QEMU_VIDEO_PRIVATE_DATA *Private - ); - -EFI_STATUS -QemuVideoBochsModeSetup ( - QEMU_VIDEO_PRIVATE_DATA *Private, - BOOLEAN IsQxl - ); - -VOID -InstallVbeShim ( - IN CONST CHAR16 *CardName, - IN EFI_PHYSICAL_ADDRESS FrameBufferBase - ); -#endif diff --git a/OvmfPkg/QemuVideoDxe/QemuVideoDxe.inf b/OvmfPkg/QemuVideoDxe/QemuVideoDxe.inf deleted file mode 100644 index affb6ffd88..0000000000 --- a/OvmfPkg/QemuVideoDxe/QemuVideoDxe.inf +++ /dev/null @@ -1,72 +0,0 @@ -## @file -# This driver is a sample implementation of the Graphics Output Protocol for -# the QEMU (Cirrus Logic 5446) video controller. -# -# Copyright (c) 2006 - 2016, Intel Corporation. All rights reserved.
-# -# This program and the accompanying materials -# are licensed and made available under the terms and conditions of the BSD License -# which accompanies this distribution. The full text of the license may be found at -# http://opensource.org/licenses/bsd-license.php -# -# THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, -# WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. -# -## - -[Defines] - INF_VERSION = 0x00010005 - BASE_NAME = QemuVideoDxe - FILE_GUID = e3752948-b9a1-4770-90c4-df41c38986be - MODULE_TYPE = UEFI_DRIVER - VERSION_STRING = 1.0 - - ENTRY_POINT = InitializeQemuVideo - -# -# The following information is for reference only and not required by the build tools. -# -# VALID_ARCHITECTURES = IA32 X64 IPF EBC ARM AARCH64 -# -# DRIVER_BINDING = gQemuVideoDriverBinding -# COMPONENT_NAME = gQemuVideoComponentName -# - -[Sources.common] - ComponentName.c - Driver.c - DriverSupportedEfiVersion.c - Gop.c - Initialize.c - -[Sources.Ia32, Sources.X64] - VbeShim.c - -[Packages] - MdePkg/MdePkg.dec - MdeModulePkg/MdeModulePkg.dec - OptionRomPkg/OptionRomPkg.dec - OvmfPkg/OvmfPkg.dec - -[LibraryClasses] - BaseMemoryLib - FrameBufferBltLib - DebugLib - DevicePathLib - MemoryAllocationLib - PciLib - PrintLib - TimerLib - UefiBootServicesTableLib - UefiDriverEntryPoint - UefiLib - -[Protocols] - gEfiDriverSupportedEfiVersionProtocolGuid # PROTOCOL ALWAYS_PRODUCED - gEfiGraphicsOutputProtocolGuid # PROTOCOL BY_START - gEfiDevicePathProtocolGuid # PROTOCOL BY_START - gEfiPciIoProtocolGuid # PROTOCOL TO_START - -[Pcd] - gOptionRomPkgTokenSpaceGuid.PcdDriverSupportedEfiVersion - diff --git a/OvmfPkg/QemuVideoDxe/VbeShim.asm b/OvmfPkg/QemuVideoDxe/VbeShim.asm deleted file mode 100644 index 18fa9209d4..0000000000 --- a/OvmfPkg/QemuVideoDxe/VbeShim.asm +++ /dev/null @@ -1,287 +0,0 @@ -;------------------------------------------------------------------------------ -; @file -; A minimal Int10h stub that allows the Windows 2008 R2 SP1 UEFI guest's buggy, -; default VGA driver to switch to 1024x768x32, on the stdvga and QXL video -; cards of QEMU. -; -; Copyright (C) 2014, Red Hat, Inc. -; Copyright (c) 2013 - 2014, Intel Corporation. All rights reserved.
-; -; This program and the accompanying materials are licensed and made available -; under the terms and conditions of the BSD License which accompanies this -; distribution. The full text of the license may be found at -; http://opensource.org/licenses/bsd-license.php -; -; THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, WITHOUT -; WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. -; -;------------------------------------------------------------------------------ - -; enable this macro for debug messages -;%define DEBUG - -%macro DebugLog 1 -%ifdef DEBUG - push si - mov si, %1 - call PrintStringSi - pop si -%endif -%endmacro - - -BITS 16 -ORG 0 - -VbeInfo: -TIMES 256 nop - -VbeModeInfo: -TIMES 256 nop - - -Handler: - cmp ax, 0x4f00 - je GetInfo - cmp ax, 0x4f01 - je GetModeInfo - cmp ax, 0x4f02 - je SetMode - cmp ax, 0x4f03 - je GetMode - cmp ax, 0x4f10 - je GetPmCapabilities - cmp ax, 0x4f15 - je ReadEdid - cmp ah, 0x00 - je SetModeLegacy - DebugLog StrUnkownFunction -Hang: - jmp Hang - - -GetInfo: - push es - push di - push ds - push si - push cx - - DebugLog StrEnterGetInfo - - ; target (es:di) set on input - push cs - pop ds - mov si, VbeInfo - ; source (ds:si) set now - - mov cx, 256 - cld - rep movsb - - pop cx - pop si - pop ds - pop di - pop es - jmp Success - - -GetModeInfo: - push es - push di - push ds - push si - push cx - - DebugLog StrEnterGetModeInfo - - and cx, ~0x4000 ; clear potentially set LFB bit in mode number - cmp cx, 0x00f1 - je KnownMode1 - DebugLog StrUnkownMode - jmp Hang -KnownMode1: - ; target (es:di) set on input - push cs - pop ds - mov si, VbeModeInfo - ; source (ds:si) set now - - mov cx, 256 - cld - rep movsb - - pop cx - pop si - pop ds - pop di - pop es - jmp Success - - -%define ATT_ADDRESS_REGISTER 0x03c0 -%define VBE_DISPI_IOPORT_INDEX 0x01ce -%define VBE_DISPI_IOPORT_DATA 0x01d0 - -%define VBE_DISPI_INDEX_XRES 0x1 -%define VBE_DISPI_INDEX_YRES 0x2 -%define VBE_DISPI_INDEX_BPP 0x3 -%define VBE_DISPI_INDEX_ENABLE 0x4 -%define VBE_DISPI_INDEX_BANK 0x5 -%define VBE_DISPI_INDEX_VIRT_WIDTH 0x6 -%define VBE_DISPI_INDEX_VIRT_HEIGHT 0x7 -%define VBE_DISPI_INDEX_X_OFFSET 0x8 -%define VBE_DISPI_INDEX_Y_OFFSET 0x9 - -%define VBE_DISPI_ENABLED 0x01 -%define VBE_DISPI_LFB_ENABLED 0x40 - -%macro BochsWrite 2 - push dx - push ax - - mov dx, VBE_DISPI_IOPORT_INDEX - mov ax, %1 - out dx, ax - - mov dx, VBE_DISPI_IOPORT_DATA - mov ax, %2 - out dx, ax - - pop ax - pop dx -%endmacro - -SetMode: - push dx - push ax - - DebugLog StrEnterSetMode - - cmp bx, 0x40f1 - je KnownMode2 - DebugLog StrUnkownMode - jmp Hang -KnownMode2: - - ; unblank - mov dx, ATT_ADDRESS_REGISTER - mov al, 0x20 - out dx, al - - BochsWrite VBE_DISPI_INDEX_ENABLE, 0 - BochsWrite VBE_DISPI_INDEX_BANK, 0 - BochsWrite VBE_DISPI_INDEX_X_OFFSET, 0 - BochsWrite VBE_DISPI_INDEX_Y_OFFSET, 0 - BochsWrite VBE_DISPI_INDEX_BPP, 32 - BochsWrite VBE_DISPI_INDEX_XRES, 1024 - BochsWrite VBE_DISPI_INDEX_VIRT_WIDTH, 1024 - BochsWrite VBE_DISPI_INDEX_YRES, 768 - BochsWrite VBE_DISPI_INDEX_VIRT_HEIGHT, 768 - BochsWrite VBE_DISPI_INDEX_ENABLE, VBE_DISPI_ENABLED | VBE_DISPI_LFB_ENABLED - - pop ax - pop dx - jmp Success - - -GetMode: - DebugLog StrEnterGetMode - mov bx, 0x40f1 - jmp Success - - -GetPmCapabilities: - DebugLog StrGetPmCapabilities - jmp Unsupported - - -ReadEdid: - DebugLog StrReadEdid - jmp Unsupported - - -SetModeLegacy: - DebugLog StrEnterSetModeLegacy - - cmp al, 0x03 - je KnownMode3 - cmp al, 0x12 - je KnownMode4 - DebugLog StrUnkownMode - jmp Hang -KnownMode3: - mov al, 0x30 - jmp SetModeLegacyDone -KnownMode4: - mov al, 0x20 -SetModeLegacyDone: - DebugLog StrExitSuccess - iret - - -Success: - DebugLog StrExitSuccess - mov ax, 0x004f - iret - - -Unsupported: - DebugLog StrExitUnsupported - mov ax, 0x014f - iret - - -%ifdef DEBUG -PrintStringSi: - pusha - push ds ; save original - push cs - pop ds - mov dx, 0x0402 -PrintStringSiLoop: - lodsb - cmp al, 0 - je PrintStringSiDone - out dx, al - jmp PrintStringSiLoop -PrintStringSiDone: - pop ds ; restore original - popa - ret - - -StrExitSuccess: - db 'Exit', 0x0a, 0 - -StrExitUnsupported: - db 'Unsupported', 0x0a, 0 - -StrUnkownFunction: - db 'Unknown Function', 0x0a, 0 - -StrEnterGetInfo: - db 'GetInfo', 0x0a, 0 - -StrEnterGetModeInfo: - db 'GetModeInfo', 0x0a, 0 - -StrEnterGetMode: - db 'GetMode', 0x0a, 0 - -StrEnterSetMode: - db 'SetMode', 0x0a, 0 - -StrEnterSetModeLegacy: - db 'SetModeLegacy', 0x0a, 0 - -StrUnkownMode: - db 'Unkown Mode', 0x0a, 0 - -StrGetPmCapabilities: - db 'GetPmCapabilities', 0x0a, 0 - -StrReadEdid: - db 'ReadEdid', 0x0a, 0 -%endif diff --git a/OvmfPkg/QemuVideoDxe/VbeShim.c b/OvmfPkg/QemuVideoDxe/VbeShim.c deleted file mode 100644 index 4c4517e9da..0000000000 --- a/OvmfPkg/QemuVideoDxe/VbeShim.c +++ /dev/null @@ -1,275 +0,0 @@ -/** @file - Install a fake VGABIOS service handler (real mode Int10h) for the buggy - Windows 2008 R2 SP1 UEFI guest. - - The handler is never meant to be directly executed by a VCPU; it's there for - the internal real mode emulator of Windows 2008 R2 SP1. - - The code is based on Ralf Brown's Interrupt List: - - - - Copyright (C) 2014, Red Hat, Inc. - Copyright (c) 2013 - 2014, Intel Corporation. All rights reserved.
- - This program and the accompanying materials are licensed and made available - under the terms and conditions of the BSD License which accompanies this - distribution. The full text of the license may be found at - http://opensource.org/licenses/bsd-license.php - - THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, WITHOUT - WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. -**/ - -#include -#include -#include -#include - -#include "Qemu.h" -#include "VbeShim.h" - -#pragma pack (1) -typedef struct { - UINT16 Offset; - UINT16 Segment; -} IVT_ENTRY; -#pragma pack () - -// -// This string is displayed by Windows 2008 R2 SP1 in the Screen Resolution, -// Advanced Settings dialog. It should be short. -// -STATIC CONST CHAR8 mProductRevision[] = "OVMF Int10h (fake)"; - -/** - Install the VBE Info and VBE Mode Info structures, and the VBE service - handler routine in the C segment. Point the real-mode Int10h interrupt vector - to the handler. The only advertised mode is 1024x768x32. - - @param[in] CardName Name of the video card to be exposed in the - Product Name field of the VBE Info structure. The - parameter must originate from a - QEMU_VIDEO_CARD.Name field. - @param[in] FrameBufferBase Guest-physical base address of the video card's - frame buffer. -**/ -VOID -InstallVbeShim ( - IN CONST CHAR16 *CardName, - IN EFI_PHYSICAL_ADDRESS FrameBufferBase - ) -{ - EFI_PHYSICAL_ADDRESS Segment0, SegmentC, SegmentF; - UINTN Segment0Pages; - IVT_ENTRY *Int0x10; - EFI_STATUS Status; - UINTN Pam1Address; - UINT8 Pam1; - UINTN SegmentCPages; - VBE_INFO *VbeInfoFull; - VBE_INFO_BASE *VbeInfo; - UINT8 *Ptr; - UINTN Printed; - VBE_MODE_INFO *VbeModeInfo; - - Segment0 = 0x00000; - SegmentC = 0xC0000; - SegmentF = 0xF0000; - - // - // Attempt to cover the real mode IVT with an allocation. This is a UEFI - // driver, hence the arch protocols have been installed previously. Among - // those, the CPU arch protocol has configured the IDT, so we can overwrite - // the IVT used in real mode. - // - // The allocation request may fail, eg. if LegacyBiosDxe has already run. - // - Segment0Pages = 1; - Int0x10 = (IVT_ENTRY *)(UINTN)Segment0 + 0x10; - Status = gBS->AllocatePages (AllocateAddress, EfiBootServicesCode, - Segment0Pages, &Segment0); - - if (EFI_ERROR (Status)) { - EFI_PHYSICAL_ADDRESS Handler; - - // - // Check if a video BIOS handler has been installed previously -- we - // shouldn't override a real video BIOS with our shim, nor our own shim if - // it's already present. - // - Handler = (Int0x10->Segment << 4) + Int0x10->Offset; - if (Handler >= SegmentC && Handler < SegmentF) { - DEBUG ((EFI_D_INFO, "%a: Video BIOS handler found at %04x:%04x\n", - __FUNCTION__, Int0x10->Segment, Int0x10->Offset)); - return; - } - - // - // Otherwise we'll overwrite the Int10h vector, even though we may not own - // the page at zero. - // - DEBUG ((EFI_D_INFO, "%a: failed to allocate page at zero: %r\n", - __FUNCTION__, Status)); - } else { - // - // We managed to allocate the page at zero. SVN r14218 guarantees that it - // is NUL-filled. - // - ASSERT (Int0x10->Segment == 0x0000); - ASSERT (Int0x10->Offset == 0x0000); - } - - // - // Put the shim in place first. - // - Pam1Address = PCI_LIB_ADDRESS (0, 0, 0, 0x5A); - // - // low nibble covers 0xC0000 to 0xC3FFF - // high nibble covers 0xC4000 to 0xC7FFF - // bit1 in each nibble is Write Enable - // bit0 in each nibble is Read Enable - // - Pam1 = PciRead8 (Pam1Address); - PciWrite8 (Pam1Address, Pam1 | (BIT1 | BIT0)); - - // - // We never added memory space during PEI or DXE for the C segment, so we - // don't need to (and can't) allocate from there. Also, guest operating - // systems will see a hole in the UEFI memory map there. - // - SegmentCPages = 4; - - ASSERT (sizeof mVbeShim <= EFI_PAGES_TO_SIZE (SegmentCPages)); - CopyMem ((VOID *)(UINTN)SegmentC, mVbeShim, sizeof mVbeShim); - - // - // Fill in the VBE INFO structure. - // - VbeInfoFull = (VBE_INFO *)(UINTN)SegmentC; - VbeInfo = &VbeInfoFull->Base; - Ptr = VbeInfoFull->Buffer; - - CopyMem (VbeInfo->Signature, "VESA", 4); - VbeInfo->VesaVersion = 0x0300; - - VbeInfo->OemNameAddress = (UINT32)SegmentC << 12 | (UINT16)(UINTN)Ptr; - CopyMem (Ptr, "QEMU", 5); - Ptr += 5; - - VbeInfo->Capabilities = BIT0; // DAC can be switched into 8-bit mode - - VbeInfo->ModeListAddress = (UINT32)SegmentC << 12 | (UINT16)(UINTN)Ptr; - *(UINT16*)Ptr = 0x00f1; // mode number - Ptr += 2; - *(UINT16*)Ptr = 0xFFFF; // mode list terminator - Ptr += 2; - - VbeInfo->VideoMem64K = (UINT16)((1024 * 768 * 4 + 65535) / 65536); - VbeInfo->OemSoftwareVersion = 0x0000; - - VbeInfo->VendorNameAddress = (UINT32)SegmentC << 12 | (UINT16)(UINTN)Ptr; - CopyMem (Ptr, "OVMF", 5); - Ptr += 5; - - VbeInfo->ProductNameAddress = (UINT32)SegmentC << 12 | (UINT16)(UINTN)Ptr; - Printed = AsciiSPrint ((CHAR8 *)Ptr, - sizeof VbeInfoFull->Buffer - (Ptr - VbeInfoFull->Buffer), "%s", - CardName); - Ptr += Printed + 1; - - VbeInfo->ProductRevAddress = (UINT32)SegmentC << 12 | (UINT16)(UINTN)Ptr; - CopyMem (Ptr, mProductRevision, sizeof mProductRevision); - Ptr += sizeof mProductRevision; - - ASSERT (sizeof VbeInfoFull->Buffer >= Ptr - VbeInfoFull->Buffer); - ZeroMem (Ptr, sizeof VbeInfoFull->Buffer - (Ptr - VbeInfoFull->Buffer)); - - // - // Fil in the VBE MODE INFO structure. - // - VbeModeInfo = (VBE_MODE_INFO *)(VbeInfoFull + 1); - - // - // bit0: mode supported by present hardware configuration - // bit1: optional information available (must be =1 for VBE v1.2+) - // bit3: set if color, clear if monochrome - // bit4: set if graphics mode, clear if text mode - // bit5: mode is not VGA-compatible - // bit7: linear framebuffer mode supported - // - VbeModeInfo->ModeAttr = BIT7 | BIT5 | BIT4 | BIT3 | BIT1 | BIT0; - - // - // bit0: exists - // bit1: bit1: readable - // bit2: writeable - // - VbeModeInfo->WindowAAttr = BIT2 | BIT1 | BIT0; - - VbeModeInfo->WindowBAttr = 0x00; - VbeModeInfo->WindowGranularityKB = 0x0040; - VbeModeInfo->WindowSizeKB = 0x0040; - VbeModeInfo->WindowAStartSegment = 0xA000; - VbeModeInfo->WindowBStartSegment = 0x0000; - VbeModeInfo->WindowPositioningAddress = 0x0000; - VbeModeInfo->BytesPerScanLine = 1024 * 4; - - VbeModeInfo->Width = 1024; - VbeModeInfo->Height = 768; - VbeModeInfo->CharCellWidth = 8; - VbeModeInfo->CharCellHeight = 16; - VbeModeInfo->NumPlanes = 1; - VbeModeInfo->BitsPerPixel = 32; - VbeModeInfo->NumBanks = 1; - VbeModeInfo->MemoryModel = 6; // direct color - VbeModeInfo->BankSizeKB = 0; - VbeModeInfo->NumImagePagesLessOne = 0; - VbeModeInfo->Vbe3 = 0x01; - - VbeModeInfo->RedMaskSize = 8; - VbeModeInfo->RedMaskPos = 16; - VbeModeInfo->GreenMaskSize = 8; - VbeModeInfo->GreenMaskPos = 8; - VbeModeInfo->BlueMaskSize = 8; - VbeModeInfo->BlueMaskPos = 0; - VbeModeInfo->ReservedMaskSize = 8; - VbeModeInfo->ReservedMaskPos = 24; - - // - // bit1: Bytes in reserved field may be used by application - // - VbeModeInfo->DirectColorModeInfo = BIT1; - - VbeModeInfo->LfbAddress = (UINT32)FrameBufferBase; - VbeModeInfo->OffScreenAddress = 0; - VbeModeInfo->OffScreenSizeKB = 0; - - VbeModeInfo->BytesPerScanLineLinear = 1024 * 4; - VbeModeInfo->NumImagesLessOneBanked = 0; - VbeModeInfo->NumImagesLessOneLinear = 0; - VbeModeInfo->RedMaskSizeLinear = 8; - VbeModeInfo->RedMaskPosLinear = 16; - VbeModeInfo->GreenMaskSizeLinear = 8; - VbeModeInfo->GreenMaskPosLinear = 8; - VbeModeInfo->BlueMaskSizeLinear = 8; - VbeModeInfo->BlueMaskPosLinear = 0; - VbeModeInfo->ReservedMaskSizeLinear = 8; - VbeModeInfo->ReservedMaskPosLinear = 24; - VbeModeInfo->MaxPixelClockHz = 0; - - ZeroMem (VbeModeInfo->Reserved, sizeof VbeModeInfo->Reserved); - - // - // Clear Write Enable (bit1), keep Read Enable (bit0) set - // - PciWrite8 (Pam1Address, (Pam1 & ~BIT1) | BIT0); - - // - // Second, point the Int10h vector at the shim. - // - Int0x10->Segment = (UINT16) ((UINT32)SegmentC >> 4); - Int0x10->Offset = (UINT16) ((UINTN) (VbeModeInfo + 1) - SegmentC); - - DEBUG ((EFI_D_INFO, "%a: VBE shim installed\n", __FUNCTION__)); -} diff --git a/OvmfPkg/QemuVideoDxe/VbeShim.h b/OvmfPkg/QemuVideoDxe/VbeShim.h deleted file mode 100644 index cc9b6e14cd..0000000000 --- a/OvmfPkg/QemuVideoDxe/VbeShim.h +++ /dev/null @@ -1,701 +0,0 @@ -// -// THIS FILE WAS GENERATED BY "VbeShim.sh". DO NOT EDIT. -// -#ifndef _VBE_SHIM_H_ -#define _VBE_SHIM_H_ -STATIC CONST UINT8 mVbeShim[] = { - /* 00000000 nop */ 0x90, - /* 00000001 nop */ 0x90, - /* 00000002 nop */ 0x90, - /* 00000003 nop */ 0x90, - /* 00000004 nop */ 0x90, - /* 00000005 nop */ 0x90, - /* 00000006 nop */ 0x90, - /* 00000007 nop */ 0x90, - /* 00000008 nop */ 0x90, - /* 00000009 nop */ 0x90, - /* 0000000A nop */ 0x90, - /* 0000000B nop */ 0x90, - /* 0000000C nop */ 0x90, - /* 0000000D nop */ 0x90, - /* 0000000E nop */ 0x90, - /* 0000000F nop */ 0x90, - /* 00000010 nop */ 0x90, - /* 00000011 nop */ 0x90, - /* 00000012 nop */ 0x90, - /* 00000013 nop */ 0x90, - /* 00000014 nop */ 0x90, - /* 00000015 nop */ 0x90, - /* 00000016 nop */ 0x90, - /* 00000017 nop */ 0x90, - /* 00000018 nop */ 0x90, - /* 00000019 nop */ 0x90, - /* 0000001A nop */ 0x90, - /* 0000001B nop */ 0x90, - /* 0000001C nop */ 0x90, - /* 0000001D nop */ 0x90, - /* 0000001E nop */ 0x90, - /* 0000001F nop */ 0x90, - /* 00000020 nop */ 0x90, - /* 00000021 nop */ 0x90, - /* 00000022 nop */ 0x90, - /* 00000023 nop */ 0x90, - /* 00000024 nop */ 0x90, - /* 00000025 nop */ 0x90, - /* 00000026 nop */ 0x90, - /* 00000027 nop */ 0x90, - /* 00000028 nop */ 0x90, - /* 00000029 nop */ 0x90, - /* 0000002A nop */ 0x90, - /* 0000002B nop */ 0x90, - /* 0000002C nop */ 0x90, - /* 0000002D nop */ 0x90, - /* 0000002E nop */ 0x90, - /* 0000002F nop */ 0x90, - /* 00000030 nop */ 0x90, - /* 00000031 nop */ 0x90, - /* 00000032 nop */ 0x90, - /* 00000033 nop */ 0x90, - /* 00000034 nop */ 0x90, - /* 00000035 nop */ 0x90, - /* 00000036 nop */ 0x90, - /* 00000037 nop */ 0x90, - /* 00000038 nop */ 0x90, - /* 00000039 nop */ 0x90, - /* 0000003A nop */ 0x90, - /* 0000003B nop */ 0x90, - /* 0000003C nop */ 0x90, - /* 0000003D nop */ 0x90, - /* 0000003E nop */ 0x90, - /* 0000003F nop */ 0x90, - /* 00000040 nop */ 0x90, - /* 00000041 nop */ 0x90, - /* 00000042 nop */ 0x90, - /* 00000043 nop */ 0x90, - /* 00000044 nop */ 0x90, - /* 00000045 nop */ 0x90, - /* 00000046 nop */ 0x90, - /* 00000047 nop */ 0x90, - /* 00000048 nop */ 0x90, - /* 00000049 nop */ 0x90, - /* 0000004A nop */ 0x90, - /* 0000004B nop */ 0x90, - /* 0000004C nop */ 0x90, - /* 0000004D nop */ 0x90, - /* 0000004E nop */ 0x90, - /* 0000004F nop */ 0x90, - /* 00000050 nop */ 0x90, - /* 00000051 nop */ 0x90, - /* 00000052 nop */ 0x90, - /* 00000053 nop */ 0x90, - /* 00000054 nop */ 0x90, - /* 00000055 nop */ 0x90, - /* 00000056 nop */ 0x90, - /* 00000057 nop */ 0x90, - /* 00000058 nop */ 0x90, - /* 00000059 nop */ 0x90, - /* 0000005A nop */ 0x90, - /* 0000005B nop */ 0x90, - /* 0000005C nop */ 0x90, - /* 0000005D nop */ 0x90, - /* 0000005E nop */ 0x90, - /* 0000005F nop */ 0x90, - /* 00000060 nop */ 0x90, - /* 00000061 nop */ 0x90, - /* 00000062 nop */ 0x90, - /* 00000063 nop */ 0x90, - /* 00000064 nop */ 0x90, - /* 00000065 nop */ 0x90, - /* 00000066 nop */ 0x90, - /* 00000067 nop */ 0x90, - /* 00000068 nop */ 0x90, - /* 00000069 nop */ 0x90, - /* 0000006A nop */ 0x90, - /* 0000006B nop */ 0x90, - /* 0000006C nop */ 0x90, - /* 0000006D nop */ 0x90, - /* 0000006E nop */ 0x90, - /* 0000006F nop */ 0x90, - /* 00000070 nop */ 0x90, - /* 00000071 nop */ 0x90, - /* 00000072 nop */ 0x90, - /* 00000073 nop */ 0x90, - /* 00000074 nop */ 0x90, - /* 00000075 nop */ 0x90, - /* 00000076 nop */ 0x90, - /* 00000077 nop */ 0x90, - /* 00000078 nop */ 0x90, - /* 00000079 nop */ 0x90, - /* 0000007A nop */ 0x90, - /* 0000007B nop */ 0x90, - /* 0000007C nop */ 0x90, - /* 0000007D nop */ 0x90, - /* 0000007E nop */ 0x90, - /* 0000007F nop */ 0x90, - /* 00000080 nop */ 0x90, - /* 00000081 nop */ 0x90, - /* 00000082 nop */ 0x90, - /* 00000083 nop */ 0x90, - /* 00000084 nop */ 0x90, - /* 00000085 nop */ 0x90, - /* 00000086 nop */ 0x90, - /* 00000087 nop */ 0x90, - /* 00000088 nop */ 0x90, - /* 00000089 nop */ 0x90, - /* 0000008A nop */ 0x90, - /* 0000008B nop */ 0x90, - /* 0000008C nop */ 0x90, - /* 0000008D nop */ 0x90, - /* 0000008E nop */ 0x90, - /* 0000008F nop */ 0x90, - /* 00000090 nop */ 0x90, - /* 00000091 nop */ 0x90, - /* 00000092 nop */ 0x90, - /* 00000093 nop */ 0x90, - /* 00000094 nop */ 0x90, - /* 00000095 nop */ 0x90, - /* 00000096 nop */ 0x90, - /* 00000097 nop */ 0x90, - /* 00000098 nop */ 0x90, - /* 00000099 nop */ 0x90, - /* 0000009A nop */ 0x90, - /* 0000009B nop */ 0x90, - /* 0000009C nop */ 0x90, - /* 0000009D nop */ 0x90, - /* 0000009E nop */ 0x90, - /* 0000009F nop */ 0x90, - /* 000000A0 nop */ 0x90, - /* 000000A1 nop */ 0x90, - /* 000000A2 nop */ 0x90, - /* 000000A3 nop */ 0x90, - /* 000000A4 nop */ 0x90, - /* 000000A5 nop */ 0x90, - /* 000000A6 nop */ 0x90, - /* 000000A7 nop */ 0x90, - /* 000000A8 nop */ 0x90, - /* 000000A9 nop */ 0x90, - /* 000000AA nop */ 0x90, - /* 000000AB nop */ 0x90, - /* 000000AC nop */ 0x90, - /* 000000AD nop */ 0x90, - /* 000000AE nop */ 0x90, - /* 000000AF nop */ 0x90, - /* 000000B0 nop */ 0x90, - /* 000000B1 nop */ 0x90, - /* 000000B2 nop */ 0x90, - /* 000000B3 nop */ 0x90, - /* 000000B4 nop */ 0x90, - /* 000000B5 nop */ 0x90, - /* 000000B6 nop */ 0x90, - /* 000000B7 nop */ 0x90, - /* 000000B8 nop */ 0x90, - /* 000000B9 nop */ 0x90, - /* 000000BA nop */ 0x90, - /* 000000BB nop */ 0x90, - /* 000000BC nop */ 0x90, - /* 000000BD nop */ 0x90, - /* 000000BE nop */ 0x90, - /* 000000BF nop */ 0x90, - /* 000000C0 nop */ 0x90, - /* 000000C1 nop */ 0x90, - /* 000000C2 nop */ 0x90, - /* 000000C3 nop */ 0x90, - /* 000000C4 nop */ 0x90, - /* 000000C5 nop */ 0x90, - /* 000000C6 nop */ 0x90, - /* 000000C7 nop */ 0x90, - /* 000000C8 nop */ 0x90, - /* 000000C9 nop */ 0x90, - /* 000000CA nop */ 0x90, - /* 000000CB nop */ 0x90, - /* 000000CC nop */ 0x90, - /* 000000CD nop */ 0x90, - /* 000000CE nop */ 0x90, - /* 000000CF nop */ 0x90, - /* 000000D0 nop */ 0x90, - /* 000000D1 nop */ 0x90, - /* 000000D2 nop */ 0x90, - /* 000000D3 nop */ 0x90, - /* 000000D4 nop */ 0x90, - /* 000000D5 nop */ 0x90, - /* 000000D6 nop */ 0x90, - /* 000000D7 nop */ 0x90, - /* 000000D8 nop */ 0x90, - /* 000000D9 nop */ 0x90, - /* 000000DA nop */ 0x90, - /* 000000DB nop */ 0x90, - /* 000000DC nop */ 0x90, - /* 000000DD nop */ 0x90, - /* 000000DE nop */ 0x90, - /* 000000DF nop */ 0x90, - /* 000000E0 nop */ 0x90, - /* 000000E1 nop */ 0x90, - /* 000000E2 nop */ 0x90, - /* 000000E3 nop */ 0x90, - /* 000000E4 nop */ 0x90, - /* 000000E5 nop */ 0x90, - /* 000000E6 nop */ 0x90, - /* 000000E7 nop */ 0x90, - /* 000000E8 nop */ 0x90, - /* 000000E9 nop */ 0x90, - /* 000000EA nop */ 0x90, - /* 000000EB nop */ 0x90, - /* 000000EC nop */ 0x90, - /* 000000ED nop */ 0x90, - /* 000000EE nop */ 0x90, - /* 000000EF nop */ 0x90, - /* 000000F0 nop */ 0x90, - /* 000000F1 nop */ 0x90, - /* 000000F2 nop */ 0x90, - /* 000000F3 nop */ 0x90, - /* 000000F4 nop */ 0x90, - /* 000000F5 nop */ 0x90, - /* 000000F6 nop */ 0x90, - /* 000000F7 nop */ 0x90, - /* 000000F8 nop */ 0x90, - /* 000000F9 nop */ 0x90, - /* 000000FA nop */ 0x90, - /* 000000FB nop */ 0x90, - /* 000000FC nop */ 0x90, - /* 000000FD nop */ 0x90, - /* 000000FE nop */ 0x90, - /* 000000FF nop */ 0x90, - /* 00000100 nop */ 0x90, - /* 00000101 nop */ 0x90, - /* 00000102 nop */ 0x90, - /* 00000103 nop */ 0x90, - /* 00000104 nop */ 0x90, - /* 00000105 nop */ 0x90, - /* 00000106 nop */ 0x90, - /* 00000107 nop */ 0x90, - /* 00000108 nop */ 0x90, - /* 00000109 nop */ 0x90, - /* 0000010A nop */ 0x90, - /* 0000010B nop */ 0x90, - /* 0000010C nop */ 0x90, - /* 0000010D nop */ 0x90, - /* 0000010E nop */ 0x90, - /* 0000010F nop */ 0x90, - /* 00000110 nop */ 0x90, - /* 00000111 nop */ 0x90, - /* 00000112 nop */ 0x90, - /* 00000113 nop */ 0x90, - /* 00000114 nop */ 0x90, - /* 00000115 nop */ 0x90, - /* 00000116 nop */ 0x90, - /* 00000117 nop */ 0x90, - /* 00000118 nop */ 0x90, - /* 00000119 nop */ 0x90, - /* 0000011A nop */ 0x90, - /* 0000011B nop */ 0x90, - /* 0000011C nop */ 0x90, - /* 0000011D nop */ 0x90, - /* 0000011E nop */ 0x90, - /* 0000011F nop */ 0x90, - /* 00000120 nop */ 0x90, - /* 00000121 nop */ 0x90, - /* 00000122 nop */ 0x90, - /* 00000123 nop */ 0x90, - /* 00000124 nop */ 0x90, - /* 00000125 nop */ 0x90, - /* 00000126 nop */ 0x90, - /* 00000127 nop */ 0x90, - /* 00000128 nop */ 0x90, - /* 00000129 nop */ 0x90, - /* 0000012A nop */ 0x90, - /* 0000012B nop */ 0x90, - /* 0000012C nop */ 0x90, - /* 0000012D nop */ 0x90, - /* 0000012E nop */ 0x90, - /* 0000012F nop */ 0x90, - /* 00000130 nop */ 0x90, - /* 00000131 nop */ 0x90, - /* 00000132 nop */ 0x90, - /* 00000133 nop */ 0x90, - /* 00000134 nop */ 0x90, - /* 00000135 nop */ 0x90, - /* 00000136 nop */ 0x90, - /* 00000137 nop */ 0x90, - /* 00000138 nop */ 0x90, - /* 00000139 nop */ 0x90, - /* 0000013A nop */ 0x90, - /* 0000013B nop */ 0x90, - /* 0000013C nop */ 0x90, - /* 0000013D nop */ 0x90, - /* 0000013E nop */ 0x90, - /* 0000013F nop */ 0x90, - /* 00000140 nop */ 0x90, - /* 00000141 nop */ 0x90, - /* 00000142 nop */ 0x90, - /* 00000143 nop */ 0x90, - /* 00000144 nop */ 0x90, - /* 00000145 nop */ 0x90, - /* 00000146 nop */ 0x90, - /* 00000147 nop */ 0x90, - /* 00000148 nop */ 0x90, - /* 00000149 nop */ 0x90, - /* 0000014A nop */ 0x90, - /* 0000014B nop */ 0x90, - /* 0000014C nop */ 0x90, - /* 0000014D nop */ 0x90, - /* 0000014E nop */ 0x90, - /* 0000014F nop */ 0x90, - /* 00000150 nop */ 0x90, - /* 00000151 nop */ 0x90, - /* 00000152 nop */ 0x90, - /* 00000153 nop */ 0x90, - /* 00000154 nop */ 0x90, - /* 00000155 nop */ 0x90, - /* 00000156 nop */ 0x90, - /* 00000157 nop */ 0x90, - /* 00000158 nop */ 0x90, - /* 00000159 nop */ 0x90, - /* 0000015A nop */ 0x90, - /* 0000015B nop */ 0x90, - /* 0000015C nop */ 0x90, - /* 0000015D nop */ 0x90, - /* 0000015E nop */ 0x90, - /* 0000015F nop */ 0x90, - /* 00000160 nop */ 0x90, - /* 00000161 nop */ 0x90, - /* 00000162 nop */ 0x90, - /* 00000163 nop */ 0x90, - /* 00000164 nop */ 0x90, - /* 00000165 nop */ 0x90, - /* 00000166 nop */ 0x90, - /* 00000167 nop */ 0x90, - /* 00000168 nop */ 0x90, - /* 00000169 nop */ 0x90, - /* 0000016A nop */ 0x90, - /* 0000016B nop */ 0x90, - /* 0000016C nop */ 0x90, - /* 0000016D nop */ 0x90, - /* 0000016E nop */ 0x90, - /* 0000016F nop */ 0x90, - /* 00000170 nop */ 0x90, - /* 00000171 nop */ 0x90, - /* 00000172 nop */ 0x90, - /* 00000173 nop */ 0x90, - /* 00000174 nop */ 0x90, - /* 00000175 nop */ 0x90, - /* 00000176 nop */ 0x90, - /* 00000177 nop */ 0x90, - /* 00000178 nop */ 0x90, - /* 00000179 nop */ 0x90, - /* 0000017A nop */ 0x90, - /* 0000017B nop */ 0x90, - /* 0000017C nop */ 0x90, - /* 0000017D nop */ 0x90, - /* 0000017E nop */ 0x90, - /* 0000017F nop */ 0x90, - /* 00000180 nop */ 0x90, - /* 00000181 nop */ 0x90, - /* 00000182 nop */ 0x90, - /* 00000183 nop */ 0x90, - /* 00000184 nop */ 0x90, - /* 00000185 nop */ 0x90, - /* 00000186 nop */ 0x90, - /* 00000187 nop */ 0x90, - /* 00000188 nop */ 0x90, - /* 00000189 nop */ 0x90, - /* 0000018A nop */ 0x90, - /* 0000018B nop */ 0x90, - /* 0000018C nop */ 0x90, - /* 0000018D nop */ 0x90, - /* 0000018E nop */ 0x90, - /* 0000018F nop */ 0x90, - /* 00000190 nop */ 0x90, - /* 00000191 nop */ 0x90, - /* 00000192 nop */ 0x90, - /* 00000193 nop */ 0x90, - /* 00000194 nop */ 0x90, - /* 00000195 nop */ 0x90, - /* 00000196 nop */ 0x90, - /* 00000197 nop */ 0x90, - /* 00000198 nop */ 0x90, - /* 00000199 nop */ 0x90, - /* 0000019A nop */ 0x90, - /* 0000019B nop */ 0x90, - /* 0000019C nop */ 0x90, - /* 0000019D nop */ 0x90, - /* 0000019E nop */ 0x90, - /* 0000019F nop */ 0x90, - /* 000001A0 nop */ 0x90, - /* 000001A1 nop */ 0x90, - /* 000001A2 nop */ 0x90, - /* 000001A3 nop */ 0x90, - /* 000001A4 nop */ 0x90, - /* 000001A5 nop */ 0x90, - /* 000001A6 nop */ 0x90, - /* 000001A7 nop */ 0x90, - /* 000001A8 nop */ 0x90, - /* 000001A9 nop */ 0x90, - /* 000001AA nop */ 0x90, - /* 000001AB nop */ 0x90, - /* 000001AC nop */ 0x90, - /* 000001AD nop */ 0x90, - /* 000001AE nop */ 0x90, - /* 000001AF nop */ 0x90, - /* 000001B0 nop */ 0x90, - /* 000001B1 nop */ 0x90, - /* 000001B2 nop */ 0x90, - /* 000001B3 nop */ 0x90, - /* 000001B4 nop */ 0x90, - /* 000001B5 nop */ 0x90, - /* 000001B6 nop */ 0x90, - /* 000001B7 nop */ 0x90, - /* 000001B8 nop */ 0x90, - /* 000001B9 nop */ 0x90, - /* 000001BA nop */ 0x90, - /* 000001BB nop */ 0x90, - /* 000001BC nop */ 0x90, - /* 000001BD nop */ 0x90, - /* 000001BE nop */ 0x90, - /* 000001BF nop */ 0x90, - /* 000001C0 nop */ 0x90, - /* 000001C1 nop */ 0x90, - /* 000001C2 nop */ 0x90, - /* 000001C3 nop */ 0x90, - /* 000001C4 nop */ 0x90, - /* 000001C5 nop */ 0x90, - /* 000001C6 nop */ 0x90, - /* 000001C7 nop */ 0x90, - /* 000001C8 nop */ 0x90, - /* 000001C9 nop */ 0x90, - /* 000001CA nop */ 0x90, - /* 000001CB nop */ 0x90, - /* 000001CC nop */ 0x90, - /* 000001CD nop */ 0x90, - /* 000001CE nop */ 0x90, - /* 000001CF nop */ 0x90, - /* 000001D0 nop */ 0x90, - /* 000001D1 nop */ 0x90, - /* 000001D2 nop */ 0x90, - /* 000001D3 nop */ 0x90, - /* 000001D4 nop */ 0x90, - /* 000001D5 nop */ 0x90, - /* 000001D6 nop */ 0x90, - /* 000001D7 nop */ 0x90, - /* 000001D8 nop */ 0x90, - /* 000001D9 nop */ 0x90, - /* 000001DA nop */ 0x90, - /* 000001DB nop */ 0x90, - /* 000001DC nop */ 0x90, - /* 000001DD nop */ 0x90, - /* 000001DE nop */ 0x90, - /* 000001DF nop */ 0x90, - /* 000001E0 nop */ 0x90, - /* 000001E1 nop */ 0x90, - /* 000001E2 nop */ 0x90, - /* 000001E3 nop */ 0x90, - /* 000001E4 nop */ 0x90, - /* 000001E5 nop */ 0x90, - /* 000001E6 nop */ 0x90, - /* 000001E7 nop */ 0x90, - /* 000001E8 nop */ 0x90, - /* 000001E9 nop */ 0x90, - /* 000001EA nop */ 0x90, - /* 000001EB nop */ 0x90, - /* 000001EC nop */ 0x90, - /* 000001ED nop */ 0x90, - /* 000001EE nop */ 0x90, - /* 000001EF nop */ 0x90, - /* 000001F0 nop */ 0x90, - /* 000001F1 nop */ 0x90, - /* 000001F2 nop */ 0x90, - /* 000001F3 nop */ 0x90, - /* 000001F4 nop */ 0x90, - /* 000001F5 nop */ 0x90, - /* 000001F6 nop */ 0x90, - /* 000001F7 nop */ 0x90, - /* 000001F8 nop */ 0x90, - /* 000001F9 nop */ 0x90, - /* 000001FA nop */ 0x90, - /* 000001FB nop */ 0x90, - /* 000001FC nop */ 0x90, - /* 000001FD nop */ 0x90, - /* 000001FE nop */ 0x90, - /* 000001FF nop */ 0x90, - /* 00000200 cmp ax,0x4f00 */ 0x3D, 0x00, 0x4F, - /* 00000203 jz 0x22d */ 0x74, 0x28, - /* 00000205 cmp ax,0x4f01 */ 0x3D, 0x01, 0x4F, - /* 00000208 jz 0x245 */ 0x74, 0x3B, - /* 0000020A cmp ax,0x4f02 */ 0x3D, 0x02, 0x4F, - /* 0000020D jz 0x269 */ 0x74, 0x5A, - /* 0000020F cmp ax,0x4f03 */ 0x3D, 0x03, 0x4F, - /* 00000212 jz word 0x331 */ 0x0F, 0x84, 0x1B, 0x01, - /* 00000216 cmp ax,0x4f10 */ 0x3D, 0x10, 0x4F, - /* 00000219 jz word 0x336 */ 0x0F, 0x84, 0x19, 0x01, - /* 0000021D cmp ax,0x4f15 */ 0x3D, 0x15, 0x4F, - /* 00000220 jz word 0x338 */ 0x0F, 0x84, 0x14, 0x01, - /* 00000224 cmp ah,0x0 */ 0x80, 0xFC, 0x00, - /* 00000227 jz word 0x33a */ 0x0F, 0x84, 0x0F, 0x01, - /* 0000022B jmp short 0x22b */ 0xEB, 0xFE, - /* 0000022D push es */ 0x06, - /* 0000022E push di */ 0x57, - /* 0000022F push ds */ 0x1E, - /* 00000230 push si */ 0x56, - /* 00000231 push cx */ 0x51, - /* 00000232 push cs */ 0x0E, - /* 00000233 pop ds */ 0x1F, - /* 00000234 mov si,0x0 */ 0xBE, 0x00, 0x00, - /* 00000237 mov cx,0x100 */ 0xB9, 0x00, 0x01, - /* 0000023A cld */ 0xFC, - /* 0000023B rep movsb */ 0xF3, 0xA4, - /* 0000023D pop cx */ 0x59, - /* 0000023E pop si */ 0x5E, - /* 0000023F pop ds */ 0x1F, - /* 00000240 pop di */ 0x5F, - /* 00000241 pop es */ 0x07, - /* 00000242 jmp word 0x34c */ 0xE9, 0x07, 0x01, - /* 00000245 push es */ 0x06, - /* 00000246 push di */ 0x57, - /* 00000247 push ds */ 0x1E, - /* 00000248 push si */ 0x56, - /* 00000249 push cx */ 0x51, - /* 0000024A and cx,0xbfff */ 0x81, 0xE1, 0xFF, 0xBF, - /* 0000024E cmp cx,0xf1 */ 0x81, 0xF9, 0xF1, 0x00, - /* 00000252 jz 0x256 */ 0x74, 0x02, - /* 00000254 jmp short 0x22b */ 0xEB, 0xD5, - /* 00000256 push cs */ 0x0E, - /* 00000257 pop ds */ 0x1F, - /* 00000258 mov si,0x100 */ 0xBE, 0x00, 0x01, - /* 0000025B mov cx,0x100 */ 0xB9, 0x00, 0x01, - /* 0000025E cld */ 0xFC, - /* 0000025F rep movsb */ 0xF3, 0xA4, - /* 00000261 pop cx */ 0x59, - /* 00000262 pop si */ 0x5E, - /* 00000263 pop ds */ 0x1F, - /* 00000264 pop di */ 0x5F, - /* 00000265 pop es */ 0x07, - /* 00000266 jmp word 0x34c */ 0xE9, 0xE3, 0x00, - /* 00000269 push dx */ 0x52, - /* 0000026A push ax */ 0x50, - /* 0000026B cmp bx,0x40f1 */ 0x81, 0xFB, 0xF1, 0x40, - /* 0000026F jz 0x273 */ 0x74, 0x02, - /* 00000271 jmp short 0x22b */ 0xEB, 0xB8, - /* 00000273 mov dx,0x3c0 */ 0xBA, 0xC0, 0x03, - /* 00000276 mov al,0x20 */ 0xB0, 0x20, - /* 00000278 out dx,al */ 0xEE, - /* 00000279 push dx */ 0x52, - /* 0000027A push ax */ 0x50, - /* 0000027B mov dx,0x1ce */ 0xBA, 0xCE, 0x01, - /* 0000027E mov ax,0x4 */ 0xB8, 0x04, 0x00, - /* 00000281 out dx,ax */ 0xEF, - /* 00000282 mov dx,0x1d0 */ 0xBA, 0xD0, 0x01, - /* 00000285 mov ax,0x0 */ 0xB8, 0x00, 0x00, - /* 00000288 out dx,ax */ 0xEF, - /* 00000289 pop ax */ 0x58, - /* 0000028A pop dx */ 0x5A, - /* 0000028B push dx */ 0x52, - /* 0000028C push ax */ 0x50, - /* 0000028D mov dx,0x1ce */ 0xBA, 0xCE, 0x01, - /* 00000290 mov ax,0x5 */ 0xB8, 0x05, 0x00, - /* 00000293 out dx,ax */ 0xEF, - /* 00000294 mov dx,0x1d0 */ 0xBA, 0xD0, 0x01, - /* 00000297 mov ax,0x0 */ 0xB8, 0x00, 0x00, - /* 0000029A out dx,ax */ 0xEF, - /* 0000029B pop ax */ 0x58, - /* 0000029C pop dx */ 0x5A, - /* 0000029D push dx */ 0x52, - /* 0000029E push ax */ 0x50, - /* 0000029F mov dx,0x1ce */ 0xBA, 0xCE, 0x01, - /* 000002A2 mov ax,0x8 */ 0xB8, 0x08, 0x00, - /* 000002A5 out dx,ax */ 0xEF, - /* 000002A6 mov dx,0x1d0 */ 0xBA, 0xD0, 0x01, - /* 000002A9 mov ax,0x0 */ 0xB8, 0x00, 0x00, - /* 000002AC out dx,ax */ 0xEF, - /* 000002AD pop ax */ 0x58, - /* 000002AE pop dx */ 0x5A, - /* 000002AF push dx */ 0x52, - /* 000002B0 push ax */ 0x50, - /* 000002B1 mov dx,0x1ce */ 0xBA, 0xCE, 0x01, - /* 000002B4 mov ax,0x9 */ 0xB8, 0x09, 0x00, - /* 000002B7 out dx,ax */ 0xEF, - /* 000002B8 mov dx,0x1d0 */ 0xBA, 0xD0, 0x01, - /* 000002BB mov ax,0x0 */ 0xB8, 0x00, 0x00, - /* 000002BE out dx,ax */ 0xEF, - /* 000002BF pop ax */ 0x58, - /* 000002C0 pop dx */ 0x5A, - /* 000002C1 push dx */ 0x52, - /* 000002C2 push ax */ 0x50, - /* 000002C3 mov dx,0x1ce */ 0xBA, 0xCE, 0x01, - /* 000002C6 mov ax,0x3 */ 0xB8, 0x03, 0x00, - /* 000002C9 out dx,ax */ 0xEF, - /* 000002CA mov dx,0x1d0 */ 0xBA, 0xD0, 0x01, - /* 000002CD mov ax,0x20 */ 0xB8, 0x20, 0x00, - /* 000002D0 out dx,ax */ 0xEF, - /* 000002D1 pop ax */ 0x58, - /* 000002D2 pop dx */ 0x5A, - /* 000002D3 push dx */ 0x52, - /* 000002D4 push ax */ 0x50, - /* 000002D5 mov dx,0x1ce */ 0xBA, 0xCE, 0x01, - /* 000002D8 mov ax,0x1 */ 0xB8, 0x01, 0x00, - /* 000002DB out dx,ax */ 0xEF, - /* 000002DC mov dx,0x1d0 */ 0xBA, 0xD0, 0x01, - /* 000002DF mov ax,0x400 */ 0xB8, 0x00, 0x04, - /* 000002E2 out dx,ax */ 0xEF, - /* 000002E3 pop ax */ 0x58, - /* 000002E4 pop dx */ 0x5A, - /* 000002E5 push dx */ 0x52, - /* 000002E6 push ax */ 0x50, - /* 000002E7 mov dx,0x1ce */ 0xBA, 0xCE, 0x01, - /* 000002EA mov ax,0x6 */ 0xB8, 0x06, 0x00, - /* 000002ED out dx,ax */ 0xEF, - /* 000002EE mov dx,0x1d0 */ 0xBA, 0xD0, 0x01, - /* 000002F1 mov ax,0x400 */ 0xB8, 0x00, 0x04, - /* 000002F4 out dx,ax */ 0xEF, - /* 000002F5 pop ax */ 0x58, - /* 000002F6 pop dx */ 0x5A, - /* 000002F7 push dx */ 0x52, - /* 000002F8 push ax */ 0x50, - /* 000002F9 mov dx,0x1ce */ 0xBA, 0xCE, 0x01, - /* 000002FC mov ax,0x2 */ 0xB8, 0x02, 0x00, - /* 000002FF out dx,ax */ 0xEF, - /* 00000300 mov dx,0x1d0 */ 0xBA, 0xD0, 0x01, - /* 00000303 mov ax,0x300 */ 0xB8, 0x00, 0x03, - /* 00000306 out dx,ax */ 0xEF, - /* 00000307 pop ax */ 0x58, - /* 00000308 pop dx */ 0x5A, - /* 00000309 push dx */ 0x52, - /* 0000030A push ax */ 0x50, - /* 0000030B mov dx,0x1ce */ 0xBA, 0xCE, 0x01, - /* 0000030E mov ax,0x7 */ 0xB8, 0x07, 0x00, - /* 00000311 out dx,ax */ 0xEF, - /* 00000312 mov dx,0x1d0 */ 0xBA, 0xD0, 0x01, - /* 00000315 mov ax,0x300 */ 0xB8, 0x00, 0x03, - /* 00000318 out dx,ax */ 0xEF, - /* 00000319 pop ax */ 0x58, - /* 0000031A pop dx */ 0x5A, - /* 0000031B push dx */ 0x52, - /* 0000031C push ax */ 0x50, - /* 0000031D mov dx,0x1ce */ 0xBA, 0xCE, 0x01, - /* 00000320 mov ax,0x4 */ 0xB8, 0x04, 0x00, - /* 00000323 out dx,ax */ 0xEF, - /* 00000324 mov dx,0x1d0 */ 0xBA, 0xD0, 0x01, - /* 00000327 mov ax,0x41 */ 0xB8, 0x41, 0x00, - /* 0000032A out dx,ax */ 0xEF, - /* 0000032B pop ax */ 0x58, - /* 0000032C pop dx */ 0x5A, - /* 0000032D pop ax */ 0x58, - /* 0000032E pop dx */ 0x5A, - /* 0000032F jmp short 0x34c */ 0xEB, 0x1B, - /* 00000331 mov bx,0x40f1 */ 0xBB, 0xF1, 0x40, - /* 00000334 jmp short 0x34c */ 0xEB, 0x16, - /* 00000336 jmp short 0x350 */ 0xEB, 0x18, - /* 00000338 jmp short 0x350 */ 0xEB, 0x16, - /* 0000033A cmp al,0x3 */ 0x3C, 0x03, - /* 0000033C jz 0x345 */ 0x74, 0x07, - /* 0000033E cmp al,0x12 */ 0x3C, 0x12, - /* 00000340 jz 0x349 */ 0x74, 0x07, - /* 00000342 jmp word 0x22b */ 0xE9, 0xE6, 0xFE, - /* 00000345 mov al,0x30 */ 0xB0, 0x30, - /* 00000347 jmp short 0x34b */ 0xEB, 0x02, - /* 00000349 mov al,0x20 */ 0xB0, 0x20, - /* 0000034B iretw */ 0xCF, - /* 0000034C mov ax,0x4f */ 0xB8, 0x4F, 0x00, - /* 0000034F iretw */ 0xCF, - /* 00000350 mov ax,0x14f */ 0xB8, 0x4F, 0x01, - /* 00000353 iretw */ 0xCF, -}; -#endif diff --git a/OvmfPkg/QemuVideoDxe/VbeShim.sh b/OvmfPkg/QemuVideoDxe/VbeShim.sh deleted file mode 100755 index 7a6eba63a5..0000000000 --- a/OvmfPkg/QemuVideoDxe/VbeShim.sh +++ /dev/null @@ -1,85 +0,0 @@ -#!/bin/sh -### -# @file -# Shell script to assemble and dump the fake Int10h handler from NASM source to -# a C array. -# -# Copyright (C) 2014, Red Hat, Inc. -# Copyright (c) 2013 - 2014, Intel Corporation. All rights reserved.
-# -# This program and the accompanying materials are licensed and made available -# under the terms and conditions of the BSD License which accompanies this -# distribution. The full text of the license may be found at -# http://opensource.org/licenses/bsd-license.php -# -# THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, WITHOUT -# WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. -# -### - -set -e -u - -STEM=$(dirname -- "$0")/$(basename -- "$0" .sh) - -# -# Install exit handler -- remove temporary files. -# -exit_handler() -{ - rm -f -- "$STEM".bin "$STEM".disasm "$STEM".offsets "$STEM".insns \ - "$STEM".bytes -} -trap exit_handler EXIT - -# -# Assemble the source file. -# -nasm -o "$STEM".bin -- "$STEM".asm - -# -# Disassemble it, in order to get a binary dump associated with the source. -# (ndisasm doesn't recognize the "--" end-of-options delimiter.) -# -ndisasm "$STEM".bin >"$STEM".disasm - -# -# Create three files, each with one column of the disassembly. -# -# The first column contains the offsets, and it starts the comment. -# -cut -c 1-8 -- "$STEM".disasm \ -| sed -e 's,^, /* ,' >"$STEM".offsets - -# -# The second column contains the assembly-language instructions, and it closes -# the comment. We first pad it to 30 characters. -# -cut -c 29- -- "$STEM".disasm \ -| sed -e 's,$, ,' \ - -e 's,^\(.\{30\}\).*$,\1 */,' >"$STEM".insns - -# -# The third column contains the bytes corresponding to the instruction, -# represented as C integer constants. First strip trailing whitespace from the -# middle column of the input disassembly, then process pairs of nibbles. -# -cut -c 11-28 -- "$STEM".disasm \ -| sed -e 's, \+$,,' -e 's/\(..\)/ 0x\1,/g' >"$STEM".bytes - -# -# Write the output file, recombining the columns. The output should have CRLF -# line endings. -# -{ - printf '//\n' - printf '// THIS FILE WAS GENERATED BY "%s". DO NOT EDIT.\n' \ - "$(basename -- "$0")" - printf '//\n' - printf '#ifndef _VBE_SHIM_H_\n' - printf '#define _VBE_SHIM_H_\n' - printf 'STATIC CONST UINT8 mVbeShim[] = {\n' - paste -d ' ' -- "$STEM".offsets "$STEM".insns "$STEM".bytes - printf '};\n' - printf '#endif\n' -} \ -| unix2dos >"$STEM".h diff --git a/OvmfPkg/README b/OvmfPkg/README deleted file mode 100644 index 304e69fbe5..0000000000 --- a/OvmfPkg/README +++ /dev/null @@ -1,311 +0,0 @@ - -=== OVMF OVERVIEW === - -The Open Virtual Machine Firmware (OVMF) project aims -to support firmware for Virtual Machines using the edk2 -code base. More information can be found at: - -http://www.tianocore.org/ovmf/ - -=== STATUS === - -Current capabilities: -* IA32 and X64 architectures -* QEMU (0.10.0 or later) - - Video, keyboard, IDE, CD-ROM, serial - - Runs UEFI shell - - Optional NIC support. Requires QEMU (0.12.2 or later) -* UEFI Linux boots -* UEFI Windows 8 boots -* UEFI Windows 7 & Windows 2008 Server boot (see important notes below!) - -=== FUTURE PLANS === - -* Test/Stabilize UEFI Self-Certification Tests (SCT) results - -=== BUILDING OVMF === - -Pre-requisites: -* Build environment capable of build the edk2 MdeModulePkg. -* A properly configured ASL compiler: - - Intel ASL compiler: Available from http://www.acpica.org - - Microsoft ASL compiler: Available from http://www.acpi.info -* NASM: http://www.nasm.us/ - -Update Conf/target.txt ACTIVE_PLATFORM for OVMF: - PEI arch DXE arch UEFI interfaces -* OvmfPkg/OvmfPkgIa32.dsc IA32 IA32 IA32 -* OvmfPkg/OvmfPkgIa32X64.dsc IA32 X64 X64 -* OvmfPkg/OvmfPkgX64.dsc X64 X64 X64 - -Update Conf/target.txt TARGET_ARCH based on the .dsc file: - TARGET_ARCH -* OvmfPkg/OvmfPkgIa32.dsc IA32 -* OvmfPkg/OvmfPkgIa32X64.dsc IA32 X64 -* OvmfPkg/OvmfPkgX64.dsc X64 - -Following the edk2 build process, you will find the OVMF binaries -under the $WORKSPACE/Build/*/*/FV directory. The actual path will -depend on how your build is configured. You can expect to find -these binary outputs: -* OVMF.FD - - Please note! This filename has changed. Older releases used OVMF.Fv. -* OvmfVideo.rom - - This file is not built separately any longer, starting with svn r13520. - -More information on building OVMF can be found at: - -https://github.com/tianocore/tianocore.github.io/wiki/How%20to%20build%20OVMF - -=== RUNNING OVMF on QEMU === - -* QEMU 0.12.2 or later is required. -* Be sure to use qemu-system-x86_64, if you are using and X64 firmware. - (qemu-system-x86_64 works for the IA32 firmware as well, of course.) -* Use OVMF for QEMU firmware (3 options available) - - Option 1: QEMU 1.6 or newer; Use QEMU -pflash parameter - * QEMU/OVMF will use emulated flash, and fully support UEFI variables - * Run qemu with: -pflash path/to/OVMF.fd - * Note that this option is required for running SecureBoot-enabled builds - (-D SECURE_BOOT_ENABLE). - - Option 2: Use QEMU -bios parameter - * Note that UEFI variables will be partially emulated, and non-volatile - variables may lose their contents after a reboot - * Run qemu with: -bios path/to/OVMF.fd - - Option 3: Use QEMU -L parameter - * Note that UEFI variables will be partially emulated, and non-volatile - variables may lose their contents after a reboot - * Either copy, rename or symlink OVMF.fd => bios.bin - * Use the QEMU -L parameter to specify the directory where the bios.bin - file is located. -* The EFI shell is built into OVMF builds at this time, so it should - run automatically if a UEFI boot application is not found on the - removable media. -* On Linux, newer version of QEMU may enable KVM feature, and this might - cause OVMF to fail to boot. The QEMU '-no-kvm' may allow OVMF to boot. -* Capturing OVMF debug messages on qemu: - - The default OVMF build writes debug messages to IO port 0x402. The - following qemu command line options save them in the file called - debug.log: '-debugcon file:debug.log -global isa-debugcon.iobase=0x402'. - - It is possible to revert to the original behavior, when debug messages were - written to the emulated serial port (potentially intermixing OVMF debug - output with UEFI serial console output). For this the - '-D DEBUG_ON_SERIAL_PORT' option has to be passed to the build command (see - the next section), and in order to capture the serial output qemu needs to - be started with eg. '-serial file:serial.log'. - - Debug messages fall into several categories. Logged vs. suppressed - categories are controlled at OVMF build time by the - 'gEfiMdePkgTokenSpaceGuid.PcdDebugPrintErrorLevel' bitmask (an UINT32 - value) in the selected .dsc file. Individual bits of this bitmask are - defined in . One non-default bit (with - some performance impact) that is frequently set for debugging is 0x00400000 - (DEBUG_VERBOSE). - - The RELEASE build target ('-b RELEASE' build option, see below) disables - all debug messages. The default build target is DEBUG. - -=== Build Scripts === - -On systems with the bash shell you can use OvmfPkg/build.sh to simplify -building and running OVMF. - -So, for example, to build + run OVMF X64: -$ OvmfPkg/build.sh -a X64 -$ OvmfPkg/build.sh -a X64 qemu - -And to run a 64-bit UEFI bootable ISO image: -$ OvmfPkg/build.sh -a X64 qemu -cdrom /path/to/disk-image.iso - -To build a 32-bit OVMF without debug messages using GCC 4.5: -$ OvmfPkg/build.sh -a IA32 -b RELEASE -t GCC45 - -=== SMM support === - -Requirements: -* SMM support requires QEMU 2.5. -* The minimum required QEMU machine type is "pc-q35-2.5". -* SMM with KVM requires Linux 4.4 (host). - -OVMF is capable of utilizing SMM if the underlying QEMU or KVM hypervisor -emulates SMM. SMM is put to use in the S3 suspend and resume infrastructure, -and in the UEFI variable driver stack. The purpose is (virtual) hardware -separation between the runtime guest OS and the firmware (OVMF), with the -intent to make Secure Boot actually secure, by preventing the runtime guest OS -from tampering with the variable store and S3 areas. - -For SMM support, OVMF must be built with the "-D SMM_REQUIRE" option. The -resultant firmware binary will check if QEMU actually provides SMM emulation; -if it doesn't, then OVMF will log an error and trigger an assertion failure -during boot (even in RELEASE builds). Both the naming of the flag (SMM_REQUIRE, -instead of SMM_ENABLE), and this behavior are consistent with the goal -described above: this is supposed to be a security feature, and fallbacks are -not allowed. Similarly, a pflash-backed variable store is a requirement. - -QEMU should be started with the options listed below (in addition to any other -guest-specific flags). The command line should be gradually composed from the -hints below. '\' is used to extend the command line to multiple lines, and '^' -can be used on Windows. - -* QEMU binary and options specific to 32-bit guests: - - $ qemu-system-i386 -cpu coreduo,-nx \ - - or - - $ qemu-system-x86_64 -cpu ,-lm,-nx \ - -* QEMU binary for running 64-bit guests (no particular options): - - $ qemu-system-x86_64 \ - -* Flags common to all SMM scenarios (only the Q35 machine type is supported): - - -machine q35,smm=on,accel=(tcg|kvm) \ - -m ... \ - -smp ... \ - -global driver=cfi.pflash01,property=secure,value=on \ - -drive if=pflash,format=raw,unit=0,file=OVMF_CODE.fd,readonly=on \ - -drive if=pflash,format=raw,unit=1,file=copy_of_OVMF_VARS.fd \ - -* In order to disable S3, add: - - -global ICH9-LPC.disable_s3=1 \ - -=== Network Support === - -OVMF provides a UEFI network stack by default. Its lowest level driver is the -NIC driver, higher levels are generic. In order to make DHCP, PXE Boot, and eg. -socket test utilities from the StdLib edk2 package work, (1) qemu has to be -configured to emulate a NIC, (2) a matching UEFI NIC driver must be available -when OVMF boots. - -(If a NIC is configured for the virtual machine, and -- dependent on boot order --- PXE booting is attempted, but no DHCP server responds to OVMF's DHCP -DISCOVER message at startup, the boot process may take approx. 3 seconds -longer.) - -* For each NIC emulated by qemu, a GPLv2 licensed UEFI driver is available from - the iPXE project. The qemu source distribution, starting with version 1.5, - contains prebuilt binaries of these drivers (and of course allows one to - rebuild them from source as well). This is the recommended set of drivers. - -* Use the qemu -netdev and -device options, or the legacy -net option, to - enable NIC support: . - -* For a qemu >= 1.5 binary running *without* any "-M machine" option where - "machine" would identify a < qemu-1.5 configuration (for example: "-M - pc-i440fx-1.4" or "-M pc-0.13"), the iPXE drivers are automatically available - to and configured for OVMF in the default qemu installation. - -* For a qemu binary in [0.13, 1.5), or a qemu >= 1.5 binary with an "-M - machine" option where "machine" selects a < qemu-1.5 configuration: - - - download a >= 1.5.0-rc1 source tarball from , - - - extract the following iPXE driver files from the tarball and install them - in a location that is accessible to qemu processes (this may depend on your - SELinux configuration, for example): - - qemu-VERSION/pc-bios/efi-e1000.rom - qemu-VERSION/pc-bios/efi-ne2k_pci.rom - qemu-VERSION/pc-bios/efi-pcnet.rom - qemu-VERSION/pc-bios/efi-rtl8139.rom - qemu-VERSION/pc-bios/efi-virtio.rom - - - extend the NIC's -device option on the qemu command line with a matching - "romfile=" optarg: - - -device e1000,...,romfile=/full/path/to/efi-e1000.rom - -device ne2k_pci,...,romfile=/full/path/to/efi-ne2k_pci.rom - -device pcnet,...,romfile=/full/path/to/efi-pcnet.rom - -device rtl8139,...,romfile=/full/path/to/efi-rtl8139.rom - -device virtio-net-pci,...,romfile=/full/path/to/efi-virtio.rom - -* Independently of the iPXE NIC drivers, the default OVMF build provides a - basic virtio-net driver, located in OvmfPkg/VirtioNetDxe. - -* Also independently of the iPXE NIC drivers, Intel's proprietary E1000 NIC - driver (PROEFI) can be embedded in the OVMF image at build time: - - - Download UEFI drivers for the e1000 NIC - - http://downloadcenter.intel.com/Detail_Desc.aspx?agr=Y&DwnldID=17515&lang=eng - - Install the drivers into a directory called Intel3.5 in your WORKSPACE. - - - Include the driver in OVMF during the build: - - Add "-D E1000_ENABLE" to your build command, - - For example: "build -D E1000_ENABLE". - -* When a matching iPXE driver is configured for a NIC as described above, it - takes priority over other drivers that could possibly drive the card too: - - | e1000 ne2k_pci pcnet rtl8139 virtio-net-pci - -------------+------------------------------------------------ - iPXE | x x x x x - VirtioNetDxe | x - Intel PROEFI | x - -=== OVMF Flash Layout === - -Like all current IA32/X64 system designs, OVMF's firmware -device (rom/flash) appears in QEMU's physical address space -just below 4GB (0x100000000). - -The layout of the firmware device in memory looks like: - -+--------------------------------------- 4GB (0x100000000) -| VTF0 (16-bit reset code) and OVMF SEC -| (SECFV) -+--------------------------------------- varies based on flash size -| -| Compressed main firmware image -| (FVMAIN_COMPACT) -| -+--------------------------------------- base + 0x20000 -| Fault-tolerant write (FTW) -| Spare blocks (64KB/0x10000) -+--------------------------------------- base + 0x10000 -| FTW Work block (4KB/0x1000) -+--------------------------------------- base + 0x0f000 -| Event log area (4KB/0x1000) -+--------------------------------------- base + 0x0e000 -| Non-volatile variable storage -| area (56KB/0xe000) -+--------------------------------------- base address - -OVMF supports building a 1MB or a 2MB flash image. The base address for -a 1MB image in QEMU physical memory is 0xfff00000. The base address for -a 2MB image is 0xffe00000. - -The code in SECFV locates FVMAIN_COMPACT, and decompresses the -main firmware (MAINFV) into RAM memory at address 0x800000. The -remaining OVMF firmware then uses this decompressed firmware -volume image. - -=== UNIXGCC Debug === - -If you build with the UNIXGCC toolchain, then debugging will be disabled -due to larger image sizes being produced by the UNIXGCC toolchain. The -first choice recommendation is to use GCC44 or newer instead. - -If you must use UNIXGCC, then you can override the build options for -particular libraries and modules in the .dsc to re-enable debugging -selectively. For example: - [Components] - OvmfPkg/Library/PlatformBootManagerLib/PlatformBootManagerLib.inf { - - GCC:*_*_*_CC_FLAGS = -UMDEPKG_NDEBUG - } - MdeModulePkg/Universal/BdsDxe/BdsDxe.inf { - - GCC:*_*_*_CC_FLAGS = -UMDEPKG_NDEBUG - } - -=== UEFI Windows 7 & Windows 2008 Server === - -* One of the '-vga std' and '-vga qxl' QEMU options should be used. -* Only one video mode, 1024x768x32, is supported at OS runtime. -* The '-vga qxl' QEMU option is recommended. After booting the installed - guest OS, select the video card in Device Manager, and upgrade its driver - to the QXL XDDM one. Download location: - , Guest | Windows binaries. - This enables further resolutions at OS runtime, and provides S3 - (suspend/resume) capability. diff --git a/OvmfPkg/ResetVector/Ia32/PageTables64.asm b/OvmfPkg/ResetVector/Ia32/PageTables64.asm deleted file mode 100644 index 6201cad1f5..0000000000 --- a/OvmfPkg/ResetVector/Ia32/PageTables64.asm +++ /dev/null @@ -1,94 +0,0 @@ -;------------------------------------------------------------------------------ -; @file -; Sets the CR3 register for 64-bit paging -; -; Copyright (c) 2008 - 2013, Intel Corporation. All rights reserved.
-; This program and the accompanying materials -; are licensed and made available under the terms and conditions of the BSD License -; which accompanies this distribution. The full text of the license may be found at -; http://opensource.org/licenses/bsd-license.php -; -; THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, -; WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. -; -;------------------------------------------------------------------------------ - -BITS 32 - -%define PAGE_PRESENT 0x01 -%define PAGE_READ_WRITE 0x02 -%define PAGE_USER_SUPERVISOR 0x04 -%define PAGE_WRITE_THROUGH 0x08 -%define PAGE_CACHE_DISABLE 0x010 -%define PAGE_ACCESSED 0x020 -%define PAGE_DIRTY 0x040 -%define PAGE_PAT 0x080 -%define PAGE_GLOBAL 0x0100 -%define PAGE_2M_MBO 0x080 -%define PAGE_2M_PAT 0x01000 - -%define PAGE_2M_PDE_ATTR (PAGE_2M_MBO + \ - PAGE_ACCESSED + \ - PAGE_DIRTY + \ - PAGE_READ_WRITE + \ - PAGE_PRESENT) - -%define PAGE_PDP_ATTR (PAGE_ACCESSED + \ - PAGE_READ_WRITE + \ - PAGE_PRESENT) - - -; -; Modified: EAX, ECX -; -SetCr3ForPageTables64: - - ; - ; For OVMF, build some initial page tables at - ; PcdOvmfSecPageTablesBase - (PcdOvmfSecPageTablesBase + 0x6000). - ; - ; This range should match with PcdOvmfSecPageTablesSize which is - ; declared in the FDF files. - ; - ; At the end of PEI, the pages tables will be rebuilt into a - ; more permanent location by DxeIpl. - ; - - mov ecx, 6 * 0x1000 / 4 - xor eax, eax -clearPageTablesMemoryLoop: - mov dword[ecx * 4 + PT_ADDR (0) - 4], eax - loop clearPageTablesMemoryLoop - - ; - ; Top level Page Directory Pointers (1 * 512GB entry) - ; - mov dword[PT_ADDR (0)], PT_ADDR (0x1000) + PAGE_PDP_ATTR - - ; - ; Next level Page Directory Pointers (4 * 1GB entries => 4GB) - ; - mov dword[PT_ADDR (0x1000)], PT_ADDR (0x2000) + PAGE_PDP_ATTR - mov dword[PT_ADDR (0x1008)], PT_ADDR (0x3000) + PAGE_PDP_ATTR - mov dword[PT_ADDR (0x1010)], PT_ADDR (0x4000) + PAGE_PDP_ATTR - mov dword[PT_ADDR (0x1018)], PT_ADDR (0x5000) + PAGE_PDP_ATTR - - ; - ; Page Table Entries (2048 * 2MB entries => 4GB) - ; - mov ecx, 0x800 -pageTableEntriesLoop: - mov eax, ecx - dec eax - shl eax, 21 - add eax, PAGE_2M_PDE_ATTR - mov [ecx * 8 + PT_ADDR (0x2000 - 8)], eax - loop pageTableEntriesLoop - - ; - ; Set CR3 now that the paging structures are available - ; - mov eax, PT_ADDR (0) - mov cr3, eax - - OneTimeCallRet SetCr3ForPageTables64 diff --git a/OvmfPkg/ResetVector/ResetVector.inf b/OvmfPkg/ResetVector/ResetVector.inf deleted file mode 100644 index d1e5d4d9bd..0000000000 --- a/OvmfPkg/ResetVector/ResetVector.inf +++ /dev/null @@ -1,42 +0,0 @@ -## @file -# Reset Vector -# -# Copyright (c) 2006 - 2014, Intel Corporation. All rights reserved.
-# -# This program and the accompanying materials -# are licensed and made available under the terms and conditions of the BSD License -# which accompanies this distribution. The full text of the license may be found at -# http://opensource.org/licenses/bsd-license.php -# THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, -# WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. -# -## - -[Defines] - INF_VERSION = 0x00010005 - BASE_NAME = ResetVector - FILE_GUID = 1BA0062E-C779-4582-8566-336AE8F78F09 - MODULE_TYPE = SEC - VERSION_STRING = 1.1 - -# -# The following information is for reference only and not required by the build tools. -# -# VALID_ARCHITECTURES = IA32 X64 -# - -[Sources] - ResetVector.nasmb - -[Packages] - OvmfPkg/OvmfPkg.dec - MdePkg/MdePkg.dec - UefiCpuPkg/UefiCpuPkg.dec - -[BuildOptions] - *_*_IA32_NASMB_FLAGS = -I$(WORKSPACE)/UefiCpuPkg/ResetVector/Vtf0/ - *_*_X64_NASMB_FLAGS = -I$(WORKSPACE)/UefiCpuPkg/ResetVector/Vtf0/ - -[Pcd] - gUefiOvmfPkgTokenSpaceGuid.PcdOvmfSecPageTablesBase - gUefiOvmfPkgTokenSpaceGuid.PcdOvmfSecPageTablesSize diff --git a/OvmfPkg/ResetVector/ResetVector.nasmb b/OvmfPkg/ResetVector/ResetVector.nasmb deleted file mode 100644 index 29cbad3677..0000000000 --- a/OvmfPkg/ResetVector/ResetVector.nasmb +++ /dev/null @@ -1,73 +0,0 @@ -;------------------------------------------------------------------------------ -; @file -; This file includes all other code files to assemble the reset vector code -; -; Copyright (c) 2008 - 2013, Intel Corporation. All rights reserved.
-; This program and the accompanying materials -; are licensed and made available under the terms and conditions of the BSD License -; which accompanies this distribution. The full text of the license may be found at -; http://opensource.org/licenses/bsd-license.php -; -; THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, -; WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. -; -;------------------------------------------------------------------------------ - -; -; If neither ARCH_IA32 nor ARCH_X64 are defined, then try to include -; Base.h to use the C pre-processor to determine the architecture. -; -%ifndef ARCH_IA32 - %ifndef ARCH_X64 - #include - #if defined (MDE_CPU_IA32) - %define ARCH_IA32 - #elif defined (MDE_CPU_X64) - %define ARCH_X64 - #endif - %endif -%endif - -%ifdef ARCH_IA32 - %ifdef ARCH_X64 - %error "Only one of ARCH_IA32 or ARCH_X64 can be defined." - %endif -%elifdef ARCH_X64 -%else - %error "Either ARCH_IA32 or ARCH_X64 must be defined." -%endif - -%include "CommonMacros.inc" - -%include "PostCodes.inc" - -%ifdef DEBUG_PORT80 - %include "Port80Debug.asm" -%elifdef DEBUG_SERIAL - %include "SerialDebug.asm" -%else - %include "DebugDisabled.asm" -%endif - -%include "Ia32/SearchForBfvBase.asm" -%include "Ia32/SearchForSecEntry.asm" - -%ifdef ARCH_X64 - #include - - %if (FixedPcdGet32 (PcdOvmfSecPageTablesSize) != 0x6000) - %error "This implementation inherently depends on PcdOvmfSecPageTablesSize" - %endif - - %define PT_ADDR(Offset) (FixedPcdGet32 (PcdOvmfSecPageTablesBase) + (Offset)) -%include "Ia32/Flat32ToFlat64.asm" -%include "Ia32/PageTables64.asm" -%endif - -%include "Ia16/Real16ToFlat32.asm" -%include "Ia16/Init16.asm" - -%include "Main.asm" - -%include "Ia16/ResetVectorVtf0.asm" - diff --git a/OvmfPkg/SataControllerDxe/ComponentName.c b/OvmfPkg/SataControllerDxe/ComponentName.c deleted file mode 100644 index 57cd3c88d3..0000000000 --- a/OvmfPkg/SataControllerDxe/ComponentName.c +++ /dev/null @@ -1,176 +0,0 @@ -/** @file - UEFI Component Name(2) protocol implementation for Sata Controller driver. - - Copyright (c) 2011, Intel Corporation. All rights reserved.
- This program and the accompanying materials - are licensed and made available under the terms and conditions of the BSD License - which accompanies this distribution. The full text of the license may be found at - http://opensource.org/licenses/bsd-license.php. - - THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, - WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. - -**/ - -#include "SataController.h" - -// -/// EFI Component Name Protocol -/// -GLOBAL_REMOVE_IF_UNREFERENCED EFI_COMPONENT_NAME_PROTOCOL gSataControllerComponentName = { - SataControllerComponentNameGetDriverName, - SataControllerComponentNameGetControllerName, - "eng" -}; - -// -/// EFI Component Name 2 Protocol -/// -GLOBAL_REMOVE_IF_UNREFERENCED EFI_COMPONENT_NAME2_PROTOCOL gSataControllerComponentName2 = { - (EFI_COMPONENT_NAME2_GET_DRIVER_NAME) SataControllerComponentNameGetDriverName, - (EFI_COMPONENT_NAME2_GET_CONTROLLER_NAME) SataControllerComponentNameGetControllerName, - "en" -}; - -// -/// Driver Name Strings -/// -GLOBAL_REMOVE_IF_UNREFERENCED EFI_UNICODE_STRING_TABLE mSataControllerDriverNameTable[] = { - { - "eng;en", - (CHAR16 *)L"Sata Controller Init Driver" - }, - { - NULL, - NULL - } -}; - -/// -/// Controller Name Strings -/// -GLOBAL_REMOVE_IF_UNREFERENCED EFI_UNICODE_STRING_TABLE mSataControllerControllerNameTable[] = { - { - "eng;en", - (CHAR16 *)L"Sata Controller" - }, - { - NULL, - NULL - } -}; - -/** - Retrieves a Unicode string that is the user readable name of the UEFI Driver. - - @param This A pointer to the EFI_COMPONENT_NAME_PROTOCOL instance. - @param Language A pointer to a three character ISO 639-2 language identifier. - This is the language of the driver name that that the caller - is requesting, and it must match one of the languages specified - in SupportedLanguages. The number of languages supported by a - driver is up to the driver writer. - @param DriverName A pointer to the Unicode string to return. This Unicode string - is the name of the driver specified by This in the language - specified by Language. - - @retval EFI_SUCCESS The Unicode string for the Driver specified by This - and the language specified by Language was returned - in DriverName. - @retval EFI_INVALID_PARAMETER Language is NULL. - @retval EFI_INVALID_PARAMETER DriverName is NULL. - @retval EFI_UNSUPPORTED The driver specified by This does not support the - language specified by Language. -**/ -EFI_STATUS -EFIAPI -SataControllerComponentNameGetDriverName ( - IN EFI_COMPONENT_NAME_PROTOCOL *This, - IN CHAR8 *Language, - OUT CHAR16 **DriverName - ) -{ - return LookupUnicodeString2 ( - Language, - This->SupportedLanguages, - mSataControllerDriverNameTable, - DriverName, - (BOOLEAN)(This == &gSataControllerComponentName) - ); -} - -/** - Retrieves a Unicode string that is the user readable name of the controller - that is being managed by an UEFI Driver. - - @param This A pointer to the EFI_COMPONENT_NAME_PROTOCOL instance. - @param ControllerHandle The handle of a controller that the driver specified by - This is managing. This handle specifies the controller - whose name is to be returned. - @param ChildHandle OPTIONAL The handle of the child controller to retrieve the name - of. This is an optional parameter that may be NULL. It - will be NULL for device drivers. It will also be NULL - for a bus drivers that wish to retrieve the name of the - bus controller. It will not be NULL for a bus driver - that wishes to retrieve the name of a child controller. - @param Language A pointer to a three character ISO 639-2 language - identifier. This is the language of the controller name - that that the caller is requesting, and it must match one - of the languages specified in SupportedLanguages. The - number of languages supported by a driver is up to the - driver writer. - @param ControllerName A pointer to the Unicode string to return. This Unicode - string is the name of the controller specified by - ControllerHandle and ChildHandle in the language - specified by Language from the point of view of the - driver specified by This. - - @retval EFI_SUCCESS The Unicode string for the user readable name in the - language specified by Language for the driver - specified by This was returned in DriverName. - @retval EFI_INVALID_PARAMETER ControllerHandle is not a valid EFI_HANDLE. - @retval EFI_INVALID_PARAMETER ChildHandle is not NULL and it is not a valid - EFI_HANDLE. - @retval EFI_INVALID_PARAMETER Language is NULL. - @retval EFI_INVALID_PARAMETER ControllerName is NULL. - @retval EFI_UNSUPPORTED The driver specified by This is not currently - managing the controller specified by - ControllerHandle and ChildHandle. - @retval EFI_UNSUPPORTED The driver specified by This does not support the - language specified by Language. -**/ -EFI_STATUS -EFIAPI -SataControllerComponentNameGetControllerName ( - IN EFI_COMPONENT_NAME_PROTOCOL *This, - IN EFI_HANDLE ControllerHandle, - IN EFI_HANDLE ChildHandle OPTIONAL, - IN CHAR8 *Language, - OUT CHAR16 **ControllerName - ) -{ - EFI_STATUS Status; - - // - // Make sure this driver is currently managing ControllHandle - // - Status = EfiTestManagedDevice ( - ControllerHandle, - gSataControllerDriverBinding.DriverBindingHandle, - &gEfiPciIoProtocolGuid - ); - if (EFI_ERROR (Status)) { - return Status; - } - - if (ChildHandle != NULL) { - return EFI_UNSUPPORTED; - } - - return LookupUnicodeString2 ( - Language, - This->SupportedLanguages, - mSataControllerControllerNameTable, - ControllerName, - (BOOLEAN)(This == &gSataControllerComponentName) - ); -} diff --git a/OvmfPkg/SataControllerDxe/SataController.c b/OvmfPkg/SataControllerDxe/SataController.c deleted file mode 100644 index 1f84ad034e..0000000000 --- a/OvmfPkg/SataControllerDxe/SataController.c +++ /dev/null @@ -1,1088 +0,0 @@ -/** @file - This driver module produces IDE_CONTROLLER_INIT protocol for Sata Controllers. - - Copyright (c) 2011, Intel Corporation. All rights reserved.
- This program and the accompanying materials - are licensed and made available under the terms and conditions of the BSD License - which accompanies this distribution. The full text of the license may be found at - http://opensource.org/licenses/bsd-license.php - - THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, - WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. - -**/ - -#include "SataController.h" - -/// -/// EFI_DRIVER_BINDING_PROTOCOL instance -/// -EFI_DRIVER_BINDING_PROTOCOL gSataControllerDriverBinding = { - SataControllerSupported, - SataControllerStart, - SataControllerStop, - 0xa, - NULL, - NULL -}; - -/** - Read AHCI Operation register. - - @param PciIo The PCI IO protocol instance. - @param Offset The operation register offset. - - @return The register content read. - -**/ -UINT32 -EFIAPI -AhciReadReg ( - IN EFI_PCI_IO_PROTOCOL *PciIo, - IN UINT32 Offset - ) -{ - UINT32 Data; - - ASSERT (PciIo != NULL); - - Data = 0; - - PciIo->Mem.Read ( - PciIo, - EfiPciIoWidthUint32, - AHCI_BAR_INDEX, - (UINT64) Offset, - 1, - &Data - ); - - return Data; -} - -/** - Write AHCI Operation register. - - @param PciIo The PCI IO protocol instance. - @param Offset The operation register offset. - @param Data The data used to write down. - -**/ -VOID -EFIAPI -AhciWriteReg ( - IN EFI_PCI_IO_PROTOCOL *PciIo, - IN UINT32 Offset, - IN UINT32 Data - ) -{ - ASSERT (PciIo != NULL); - - PciIo->Mem.Write ( - PciIo, - EfiPciIoWidthUint32, - AHCI_BAR_INDEX, - (UINT64) Offset, - 1, - &Data - ); - - return; -} - -/** - This function is used to calculate the best PIO mode supported by specific IDE device - - @param IdentifyData The identify data of specific IDE device. - @param DisPioMode Disqualified PIO modes collection. - @param SelectedMode Available PIO modes collection. - - @retval EFI_SUCCESS Best PIO modes are returned. - @retval EFI_UNSUPPORTED The device doesn't support PIO mode, - or all supported modes have been disqualified. -**/ -EFI_STATUS -CalculateBestPioMode ( - IN EFI_IDENTIFY_DATA *IdentifyData, - IN UINT16 *DisPioMode OPTIONAL, - OUT UINT16 *SelectedMode - ) -{ - UINT16 PioMode; - UINT16 AdvancedPioMode; - UINT16 Temp; - UINT16 Index; - UINT16 MinimumPioCycleTime; - - Temp = 0xff; - - PioMode = (UINT8) (((ATA5_IDENTIFY_DATA *) (&(IdentifyData->AtaData)))->pio_cycle_timing >> 8); - - // - // See whether Identify Data word 64 - 70 are valid - // - if ((IdentifyData->AtaData.field_validity & 0x02) == 0x02) { - - AdvancedPioMode = IdentifyData->AtaData.advanced_pio_modes; - DEBUG ((EFI_D_INFO, "CalculateBestPioMode: AdvancedPioMode = %x\n", AdvancedPioMode)); - - for (Index = 0; Index < 8; Index++) { - if ((AdvancedPioMode & 0x01) != 0) { - Temp = Index; - } - - AdvancedPioMode >>= 1; - } - - // - // If Temp is modified, mean the advanced_pio_modes is not zero; - // if Temp is not modified, mean there is no advanced PIO mode supported, - // the best PIO Mode is the value in pio_cycle_timing. - // - if (Temp != 0xff) { - AdvancedPioMode = (UINT16) (Temp + 3); - } else { - AdvancedPioMode = PioMode; - } - - // - // Limit the PIO mode to at most PIO4. - // - PioMode = (UINT16) MIN (AdvancedPioMode, 4); - - MinimumPioCycleTime = IdentifyData->AtaData.min_pio_cycle_time_with_flow_control; - - if (MinimumPioCycleTime <= 120) { - PioMode = (UINT16) MIN (4, PioMode); - } else if (MinimumPioCycleTime <= 180) { - PioMode = (UINT16) MIN (3, PioMode); - } else if (MinimumPioCycleTime <= 240) { - PioMode = (UINT16) MIN (2, PioMode); - } else { - PioMode = 0; - } - - // - // Degrade the PIO mode if the mode has been disqualified - // - if (DisPioMode != NULL) { - if (*DisPioMode < 2) { - return EFI_UNSUPPORTED; // no mode below ATA_PIO_MODE_BELOW_2 - } - - if (PioMode >= *DisPioMode) { - PioMode = (UINT16) (*DisPioMode - 1); - } - } - - if (PioMode < 2) { - *SelectedMode = 1; // ATA_PIO_MODE_BELOW_2; - } else { - *SelectedMode = PioMode; // ATA_PIO_MODE_2 to ATA_PIO_MODE_4; - } - - } else { - // - // Identify Data word 64 - 70 are not valid - // Degrade the PIO mode if the mode has been disqualified - // - if (DisPioMode != NULL) { - if (*DisPioMode < 2) { - return EFI_UNSUPPORTED; // no mode below ATA_PIO_MODE_BELOW_2 - } - - if (PioMode == *DisPioMode) { - PioMode--; - } - } - - if (PioMode < 2) { - *SelectedMode = 1; // ATA_PIO_MODE_BELOW_2; - } else { - *SelectedMode = 2; // ATA_PIO_MODE_2; - } - - } - - return EFI_SUCCESS; -} - -/** - This function is used to calculate the best UDMA mode supported by specific IDE device - - @param IdentifyData The identify data of specific IDE device. - @param DisUDmaMode Disqualified UDMA modes collection. - @param SelectedMode Available UDMA modes collection. - - @retval EFI_SUCCESS Best UDMA modes are returned. - @retval EFI_UNSUPPORTED The device doesn't support UDMA mode, - or all supported modes have been disqualified. -**/ -EFI_STATUS -CalculateBestUdmaMode ( - IN EFI_IDENTIFY_DATA *IdentifyData, - IN UINT16 *DisUDmaMode OPTIONAL, - OUT UINT16 *SelectedMode - ) -{ - UINT16 TempMode; - UINT16 DeviceUDmaMode; - - DeviceUDmaMode = 0; - - // - // Check whether the WORD 88 (supported UltraDMA by drive) is valid - // - if ((IdentifyData->AtaData.field_validity & 0x04) == 0x00) { - return EFI_UNSUPPORTED; - } - - DeviceUDmaMode = IdentifyData->AtaData.ultra_dma_mode; - DEBUG ((EFI_D_INFO, "CalculateBestUdmaMode: DeviceUDmaMode = %x\n", DeviceUDmaMode)); - DeviceUDmaMode &= 0x3f; - TempMode = 0; // initialize it to UDMA-0 - - while ((DeviceUDmaMode >>= 1) != 0) { - TempMode++; - } - - // - // Degrade the UDMA mode if the mode has been disqualified - // - if (DisUDmaMode != NULL) { - if (*DisUDmaMode == 0) { - *SelectedMode = 0; - return EFI_UNSUPPORTED; // no mode below ATA_UDMA_MODE_0 - } - - if (TempMode >= *DisUDmaMode) { - TempMode = (UINT16) (*DisUDmaMode - 1); - } - } - - // - // Possible returned mode is between ATA_UDMA_MODE_0 and ATA_UDMA_MODE_5 - // - *SelectedMode = TempMode; - - return EFI_SUCCESS; -} - -/** - The Entry Point of module. It follows the standard UEFI driver model. - - @param[in] ImageHandle The firmware allocated handle for the EFI image. - @param[in] SystemTable A pointer to the EFI System Table. - - @retval EFI_SUCCESS The entry point is executed successfully. - @retval other Some error occurs when executing this entry point. - -**/ -EFI_STATUS -EFIAPI -InitializeSataControllerDriver ( - IN EFI_HANDLE ImageHandle, - IN EFI_SYSTEM_TABLE *SystemTable - ) -{ - EFI_STATUS Status; - - // - // Install driver model protocol(s). - // - Status = EfiLibInstallDriverBindingComponentName2 ( - ImageHandle, - SystemTable, - &gSataControllerDriverBinding, - ImageHandle, - &gSataControllerComponentName, - &gSataControllerComponentName2 - ); - ASSERT_EFI_ERROR (Status); - - return Status; -} - -/** - Supported function of Driver Binding protocol for this driver. - Test to see if this driver supports ControllerHandle. - - @param This Protocol instance pointer. - @param Controller Handle of device to test. - @param RemainingDevicePath A pointer to the device path. - it should be ignored by device driver. - - @retval EFI_SUCCESS This driver supports this device. - @retval EFI_ALREADY_STARTED This driver is already running on this device. - @retval other This driver does not support this device. - -**/ -EFI_STATUS -EFIAPI -SataControllerSupported ( - IN EFI_DRIVER_BINDING_PROTOCOL *This, - IN EFI_HANDLE Controller, - IN EFI_DEVICE_PATH_PROTOCOL *RemainingDevicePath - ) -{ - EFI_STATUS Status; - EFI_PCI_IO_PROTOCOL *PciIo; - PCI_TYPE00 PciData; - - // - // Attempt to open PCI I/O Protocol - // - Status = gBS->OpenProtocol ( - Controller, - &gEfiPciIoProtocolGuid, - (VOID **) &PciIo, - This->DriverBindingHandle, - Controller, - EFI_OPEN_PROTOCOL_GET_PROTOCOL - ); - if (EFI_ERROR (Status)) { - return Status; - } - - // - // Now further check the PCI header: Base Class (offset 0x0B) and - // Sub Class (offset 0x0A). This controller should be an SATA controller - // - Status = PciIo->Pci.Read ( - PciIo, - EfiPciIoWidthUint8, - PCI_CLASSCODE_OFFSET, - sizeof (PciData.Hdr.ClassCode), - PciData.Hdr.ClassCode - ); - if (EFI_ERROR (Status)) { - return EFI_UNSUPPORTED; - } - - if (IS_PCI_IDE (&PciData) || IS_PCI_SATADPA (&PciData)) { - return EFI_SUCCESS; - } - - return EFI_UNSUPPORTED; -} - -/** - This routine is called right after the .Supported() called and - Start this driver on ControllerHandle. - - @param This Protocol instance pointer. - @param Controller Handle of device to bind driver to. - @param RemainingDevicePath A pointer to the device path. - it should be ignored by device driver. - - @retval EFI_SUCCESS This driver is added to this device. - @retval EFI_ALREADY_STARTED This driver is already running on this device. - @retval other Some error occurs when binding this driver to this device. - -**/ -EFI_STATUS -EFIAPI -SataControllerStart ( - IN EFI_DRIVER_BINDING_PROTOCOL *This, - IN EFI_HANDLE Controller, - IN EFI_DEVICE_PATH_PROTOCOL *RemainingDevicePath - ) -{ - EFI_STATUS Status; - EFI_PCI_IO_PROTOCOL *PciIo; - UINT64 OriginalPciAttributes; - PCI_TYPE00 PciData; - EFI_SATA_CONTROLLER_PRIVATE_DATA *SataPrivateData; - UINT32 Data32; - UINTN ChannelDeviceCount; - - DEBUG ((EFI_D_INFO, "SataControllerStart START\n")); - - SataPrivateData = NULL; - - // - // Now test and open PCI I/O Protocol - // - Status = gBS->OpenProtocol ( - Controller, - &gEfiPciIoProtocolGuid, - (VOID **) &PciIo, - This->DriverBindingHandle, - Controller, - EFI_OPEN_PROTOCOL_BY_DRIVER - ); - if (EFI_ERROR (Status)) { - goto Bail; - } - - // - // Save original PCI attributes, and enable IO space access, memory space - // access, and Bus Master (DMA). - // - Status = PciIo->Attributes (PciIo, EfiPciIoAttributeOperationGet, 0, - &OriginalPciAttributes); - if (EFI_ERROR (Status)) { - goto ClosePciIo; - } - Status = PciIo->Attributes (PciIo, EfiPciIoAttributeOperationEnable, - EFI_PCI_DEVICE_ENABLE, NULL); - if (EFI_ERROR (Status)) { - goto ClosePciIo; - } - - // - // Allocate Sata Private Data structure - // - SataPrivateData = AllocateZeroPool (sizeof (EFI_SATA_CONTROLLER_PRIVATE_DATA)); - if (SataPrivateData == NULL) { - Status = EFI_OUT_OF_RESOURCES; - goto RestorePciAttributes; - } - - // - // Initialize Sata Private Data - // - SataPrivateData->Signature = SATA_CONTROLLER_SIGNATURE; - SataPrivateData->PciIo = PciIo; - SataPrivateData->OriginalPciAttributes = OriginalPciAttributes; - SataPrivateData->IdeInit.GetChannelInfo = IdeInitGetChannelInfo; - SataPrivateData->IdeInit.NotifyPhase = IdeInitNotifyPhase; - SataPrivateData->IdeInit.SubmitData = IdeInitSubmitData; - SataPrivateData->IdeInit.DisqualifyMode = IdeInitDisqualifyMode; - SataPrivateData->IdeInit.CalculateMode = IdeInitCalculateMode; - SataPrivateData->IdeInit.SetTiming = IdeInitSetTiming; - SataPrivateData->IdeInit.EnumAll = SATA_ENUMER_ALL; - - Status = PciIo->Pci.Read ( - PciIo, - EfiPciIoWidthUint8, - PCI_CLASSCODE_OFFSET, - sizeof (PciData.Hdr.ClassCode), - PciData.Hdr.ClassCode - ); - if (EFI_ERROR (Status)) { - goto FreeSataPrivateData; - } - - if (IS_PCI_IDE (&PciData)) { - SataPrivateData->IdeInit.ChannelCount = IDE_MAX_CHANNEL; - SataPrivateData->DeviceCount = IDE_MAX_DEVICES; - } else if (IS_PCI_SATADPA (&PciData)) { - // - // Read Host Capability Register(CAP) to get Number of Ports(NPS) and Supports Port Multiplier(SPM) - // NPS is 0's based value indicating the maximum number of ports supported by the HBA silicon. - // A maximum of 32 ports can be supported. A value of '0h', indicating one port, is the minimum requirement. - // - Data32 = AhciReadReg (PciIo, R_AHCI_CAP); - SataPrivateData->IdeInit.ChannelCount = (UINT8) ((Data32 & B_AHCI_CAP_NPS) + 1); - SataPrivateData->DeviceCount = AHCI_MAX_DEVICES; - if ((Data32 & B_AHCI_CAP_SPM) == B_AHCI_CAP_SPM) { - SataPrivateData->DeviceCount = AHCI_MULTI_MAX_DEVICES; - } - } - - ChannelDeviceCount = (UINTN) (SataPrivateData->IdeInit.ChannelCount) * (UINTN) (SataPrivateData->DeviceCount); - SataPrivateData->DisqualifiedModes = AllocateZeroPool ((sizeof (EFI_ATA_COLLECTIVE_MODE)) * ChannelDeviceCount); - if (SataPrivateData->DisqualifiedModes == NULL) { - Status = EFI_OUT_OF_RESOURCES; - goto FreeSataPrivateData; - } - - SataPrivateData->IdentifyData = AllocateZeroPool ((sizeof (EFI_IDENTIFY_DATA)) * ChannelDeviceCount); - if (SataPrivateData->IdentifyData == NULL) { - Status = EFI_OUT_OF_RESOURCES; - goto FreeDisqualifiedModes; - } - - SataPrivateData->IdentifyValid = AllocateZeroPool ((sizeof (BOOLEAN)) * ChannelDeviceCount); - if (SataPrivateData->IdentifyValid == NULL) { - Status = EFI_OUT_OF_RESOURCES; - goto FreeIdentifyData; - } - - // - // Install IDE Controller Init Protocol to this instance - // - Status = gBS->InstallMultipleProtocolInterfaces ( - &Controller, - &gEfiIdeControllerInitProtocolGuid, - &(SataPrivateData->IdeInit), - NULL - ); - - if (EFI_ERROR (Status)) { - goto FreeIdentifyValid; - } - - DEBUG ((EFI_D_INFO, "SataControllerStart END status = %r\n", Status)); - return Status; - -FreeIdentifyValid: - FreePool (SataPrivateData->IdentifyValid); - -FreeIdentifyData: - FreePool (SataPrivateData->IdentifyData); - -FreeDisqualifiedModes: - FreePool (SataPrivateData->DisqualifiedModes); - -FreeSataPrivateData: - FreePool (SataPrivateData); - -RestorePciAttributes: - PciIo->Attributes (PciIo, EfiPciIoAttributeOperationSet, - OriginalPciAttributes, NULL); - -ClosePciIo: - gBS->CloseProtocol ( - Controller, - &gEfiPciIoProtocolGuid, - This->DriverBindingHandle, - Controller - ); - -Bail: - DEBUG ((EFI_D_ERROR, "SataControllerStart error return status = %r\n", Status)); - return Status; -} - -/** - Stop this driver on ControllerHandle. - - @param This Protocol instance pointer. - @param Controller Handle of device to stop driver on. - @param NumberOfChildren Not used. - @param ChildHandleBuffer Not used. - - @retval EFI_SUCCESS This driver is removed from this device. - @retval other Some error occurs when removing this driver from this device. - -**/ -EFI_STATUS -EFIAPI -SataControllerStop ( - IN EFI_DRIVER_BINDING_PROTOCOL *This, - IN EFI_HANDLE Controller, - IN UINTN NumberOfChildren, - IN EFI_HANDLE *ChildHandleBuffer - ) -{ - EFI_STATUS Status; - EFI_IDE_CONTROLLER_INIT_PROTOCOL *IdeInit; - EFI_SATA_CONTROLLER_PRIVATE_DATA *SataPrivateData; - EFI_PCI_IO_PROTOCOL *PciIo; - UINT64 OriginalPciAttributes; - - // - // Open the produced protocol - // - Status = gBS->OpenProtocol ( - Controller, - &gEfiIdeControllerInitProtocolGuid, - (VOID **) &IdeInit, - This->DriverBindingHandle, - Controller, - EFI_OPEN_PROTOCOL_GET_PROTOCOL - ); - if (EFI_ERROR (Status)) { - return EFI_UNSUPPORTED; - } - - SataPrivateData = SATA_CONTROLLER_PRIVATE_DATA_FROM_THIS (IdeInit); - ASSERT (SataPrivateData != NULL); - - PciIo = SataPrivateData->PciIo; - OriginalPciAttributes = SataPrivateData->OriginalPciAttributes; - - // - // Uninstall the IDE Controller Init Protocol from this instance - // - Status = gBS->UninstallMultipleProtocolInterfaces ( - Controller, - &gEfiIdeControllerInitProtocolGuid, - &(SataPrivateData->IdeInit), - NULL - ); - if (EFI_ERROR (Status)) { - return Status; - } - - if (SataPrivateData->DisqualifiedModes != NULL) { - FreePool (SataPrivateData->DisqualifiedModes); - } - if (SataPrivateData->IdentifyData != NULL) { - FreePool (SataPrivateData->IdentifyData); - } - if (SataPrivateData->IdentifyValid != NULL) { - FreePool (SataPrivateData->IdentifyValid); - } - FreePool (SataPrivateData); - - // - // Restore original PCI attributes - // - PciIo->Attributes ( - PciIo, - EfiPciIoAttributeOperationSet, - OriginalPciAttributes, - NULL - ); - - // - // Close protocols opened by Sata Controller driver - // - return gBS->CloseProtocol ( - Controller, - &gEfiPciIoProtocolGuid, - This->DriverBindingHandle, - Controller - ); -} - -/** - Calculate the flat array subscript of a (Channel, Device) pair. - - @param[in] SataPrivateData The private data structure corresponding to the - SATA controller that attaches the device for - which the flat array subscript is being - calculated. - - @param[in] Channel The channel (ie. port) number on the SATA - controller that the device is attached to. - - @param[in] Device The device number on the channel. - - @return The flat array subscript suitable for indexing DisqualifiedModes, - IdentifyData, and IdentifyValid. -**/ -STATIC -UINTN -FlatDeviceIndex ( - IN CONST EFI_SATA_CONTROLLER_PRIVATE_DATA *SataPrivateData, - IN UINTN Channel, - IN UINTN Device - ) -{ - ASSERT (SataPrivateData != NULL); - ASSERT (Channel < SataPrivateData->IdeInit.ChannelCount); - ASSERT (Device < SataPrivateData->DeviceCount); - - return Channel * SataPrivateData->DeviceCount + Device; -} - -// -// Interface functions of IDE_CONTROLLER_INIT protocol -// -/** - Returns the information about the specified IDE channel. - - This function can be used to obtain information about a particular IDE channel. - The driver entity uses this information during the enumeration process. - - If Enabled is set to FALSE, the driver entity will not scan the channel. Note - that it will not prevent an operating system driver from scanning the channel. - - For most of today's controllers, MaxDevices will either be 1 or 2. For SATA - controllers, this value will always be 1. SATA configurations can contain SATA - port multipliers. SATA port multipliers behave like SATA bridges and can support - up to 16 devices on the other side. If a SATA port out of the IDE controller - is connected to a port multiplier, MaxDevices will be set to the number of SATA - devices that the port multiplier supports. Because today's port multipliers - support up to fifteen SATA devices, this number can be as large as fifteen. The IDE - bus driver is required to scan for the presence of port multipliers behind an SATA - controller and enumerate up to MaxDevices number of devices behind the port - multiplier. - - In this context, the devices behind a port multiplier constitute a channel. - - @param[in] This The pointer to the EFI_IDE_CONTROLLER_INIT_PROTOCOL instance. - @param[in] Channel Zero-based channel number. - @param[out] Enabled TRUE if this channel is enabled. Disabled channels - are not scanned to see if any devices are present. - @param[out] MaxDevices The maximum number of IDE devices that the bus driver - can expect on this channel. For the ATA/ATAPI - specification, version 6, this number will either be - one or two. For Serial ATA (SATA) configurations with a - port multiplier, this number can be as large as fifteen. - - @retval EFI_SUCCESS Information was returned without any errors. - @retval EFI_INVALID_PARAMETER Channel is invalid (Channel >= ChannelCount). - -**/ -EFI_STATUS -EFIAPI -IdeInitGetChannelInfo ( - IN EFI_IDE_CONTROLLER_INIT_PROTOCOL *This, - IN UINT8 Channel, - OUT BOOLEAN *Enabled, - OUT UINT8 *MaxDevices - ) -{ - EFI_SATA_CONTROLLER_PRIVATE_DATA *SataPrivateData; - SataPrivateData = SATA_CONTROLLER_PRIVATE_DATA_FROM_THIS (This); - ASSERT (SataPrivateData != NULL); - - if (Channel < This->ChannelCount) { - *Enabled = TRUE; - *MaxDevices = SataPrivateData->DeviceCount; - return EFI_SUCCESS; - } - - *Enabled = FALSE; - return EFI_INVALID_PARAMETER; -} - -/** - The notifications from the driver entity that it is about to enter a certain - phase of the IDE channel enumeration process. - - This function can be used to notify the IDE controller driver to perform - specific actions, including any chipset-specific initialization, so that the - chipset is ready to enter the next phase. Seven notification points are defined - at this time. - - More synchronization points may be added as required in the future. - - @param[in] This The pointer to the EFI_IDE_CONTROLLER_INIT_PROTOCOL instance. - @param[in] Phase The phase during enumeration. - @param[in] Channel Zero-based channel number. - - @retval EFI_SUCCESS The notification was accepted without any errors. - @retval EFI_UNSUPPORTED Phase is not supported. - @retval EFI_INVALID_PARAMETER Channel is invalid (Channel >= ChannelCount). - @retval EFI_NOT_READY This phase cannot be entered at this time; for - example, an attempt was made to enter a Phase - without having entered one or more previous - Phase. - -**/ -EFI_STATUS -EFIAPI -IdeInitNotifyPhase ( - IN EFI_IDE_CONTROLLER_INIT_PROTOCOL *This, - IN EFI_IDE_CONTROLLER_ENUM_PHASE Phase, - IN UINT8 Channel - ) -{ - return EFI_SUCCESS; -} - -/** - Submits the device information to the IDE controller driver. - - This function is used by the driver entity to pass detailed information about - a particular device to the IDE controller driver. The driver entity obtains - this information by issuing an ATA or ATAPI IDENTIFY_DEVICE command. IdentifyData - is the pointer to the response data buffer. The IdentifyData buffer is owned - by the driver entity, and the IDE controller driver must make a local copy - of the entire buffer or parts of the buffer as needed. The original IdentifyData - buffer pointer may not be valid when - - - EFI_IDE_CONTROLLER_INIT_PROTOCOL.CalculateMode() or - - EFI_IDE_CONTROLLER_INIT_PROTOCOL.DisqualifyMode() is called at a later point. - - The IDE controller driver may consult various fields of EFI_IDENTIFY_DATA to - compute the optimum mode for the device. These fields are not limited to the - timing information. For example, an implementation of the IDE controller driver - may examine the vendor and type/mode field to match known bad drives. - - The driver entity may submit drive information in any order, as long as it - submits information for all the devices belonging to the enumeration group - before EFI_IDE_CONTROLLER_INIT_PROTOCOL.CalculateMode() is called for any device - in that enumeration group. If a device is absent, EFI_IDE_CONTROLLER_INIT_PROTOCOL.SubmitData() - should be called with IdentifyData set to NULL. The IDE controller driver may - not have any other mechanism to know whether a device is present or not. Therefore, - setting IdentifyData to NULL does not constitute an error condition. - EFI_IDE_CONTROLLER_INIT_PROTOCOL.SubmitData() can be called only once for a - given (Channel, Device) pair. - - @param[in] This A pointer to the EFI_IDE_CONTROLLER_INIT_PROTOCOL instance. - @param[in] Channel Zero-based channel number. - @param[in] Device Zero-based device number on the Channel. - @param[in] IdentifyData The device's response to the ATA IDENTIFY_DEVICE command. - - @retval EFI_SUCCESS The information was accepted without any errors. - @retval EFI_INVALID_PARAMETER Channel is invalid (Channel >= ChannelCount). - @retval EFI_INVALID_PARAMETER Device is invalid. - -**/ -EFI_STATUS -EFIAPI -IdeInitSubmitData ( - IN EFI_IDE_CONTROLLER_INIT_PROTOCOL *This, - IN UINT8 Channel, - IN UINT8 Device, - IN EFI_IDENTIFY_DATA *IdentifyData - ) -{ - EFI_SATA_CONTROLLER_PRIVATE_DATA *SataPrivateData; - UINTN DeviceIndex; - - SataPrivateData = SATA_CONTROLLER_PRIVATE_DATA_FROM_THIS (This); - ASSERT (SataPrivateData != NULL); - - if ((Channel >= This->ChannelCount) || (Device >= SataPrivateData->DeviceCount)) { - return EFI_INVALID_PARAMETER; - } - - DeviceIndex = FlatDeviceIndex (SataPrivateData, Channel, Device); - - // - // Make a local copy of device's IdentifyData and mark the valid flag - // - if (IdentifyData != NULL) { - CopyMem ( - &(SataPrivateData->IdentifyData[DeviceIndex]), - IdentifyData, - sizeof (EFI_IDENTIFY_DATA) - ); - - SataPrivateData->IdentifyValid[DeviceIndex] = TRUE; - } else { - SataPrivateData->IdentifyValid[DeviceIndex] = FALSE; - } - - return EFI_SUCCESS; -} - -/** - Disqualifies specific modes for an IDE device. - - This function allows the driver entity or other drivers (such as platform - drivers) to reject certain timing modes and request the IDE controller driver - to recalculate modes. This function allows the driver entity and the IDE - controller driver to negotiate the timings on a per-device basis. This function - is useful in the case of drives that lie about their capabilities. An example - is when the IDE device fails to accept the timing modes that are calculated - by the IDE controller driver based on the response to the Identify Drive command. - - If the driver entity does not want to limit the ATA timing modes and leave that - decision to the IDE controller driver, it can either not call this function for - the given device or call this function and set the Valid flag to FALSE for all - modes that are listed in EFI_ATA_COLLECTIVE_MODE. - - The driver entity may disqualify modes for a device in any order and any number - of times. - - This function can be called multiple times to invalidate multiple modes of the - same type (e.g., Programmed Input/Output [PIO] modes 3 and 4). See the ATA/ATAPI - specification for more information on PIO modes. - - For Serial ATA (SATA) controllers, this member function can be used to disqualify - a higher transfer rate mode on a given channel. For example, a platform driver - may inform the IDE controller driver to not use second-generation (Gen2) speeds - for a certain SATA drive. - - @param[in] This The pointer to the EFI_IDE_CONTROLLER_INIT_PROTOCOL instance. - @param[in] Channel The zero-based channel number. - @param[in] Device The zero-based device number on the Channel. - @param[in] BadModes The modes that the device does not support and that - should be disqualified. - - @retval EFI_SUCCESS The modes were accepted without any errors. - @retval EFI_INVALID_PARAMETER Channel is invalid (Channel >= ChannelCount). - @retval EFI_INVALID_PARAMETER Device is invalid. - @retval EFI_INVALID_PARAMETER IdentifyData is NULL. - -**/ -EFI_STATUS -EFIAPI -IdeInitDisqualifyMode ( - IN EFI_IDE_CONTROLLER_INIT_PROTOCOL *This, - IN UINT8 Channel, - IN UINT8 Device, - IN EFI_ATA_COLLECTIVE_MODE *BadModes - ) -{ - EFI_SATA_CONTROLLER_PRIVATE_DATA *SataPrivateData; - UINTN DeviceIndex; - - SataPrivateData = SATA_CONTROLLER_PRIVATE_DATA_FROM_THIS (This); - ASSERT (SataPrivateData != NULL); - - if ((Channel >= This->ChannelCount) || (BadModes == NULL) || (Device >= SataPrivateData->DeviceCount)) { - return EFI_INVALID_PARAMETER; - } - - DeviceIndex = FlatDeviceIndex (SataPrivateData, Channel, Device); - - // - // Record the disqualified modes per channel per device. From ATA/ATAPI spec, - // if a mode is not supported, the modes higher than it is also not supported. - // - CopyMem ( - &(SataPrivateData->DisqualifiedModes[DeviceIndex]), - BadModes, - sizeof (EFI_ATA_COLLECTIVE_MODE) - ); - - return EFI_SUCCESS; -} - -/** - Returns the information about the optimum modes for the specified IDE device. - - This function is used by the driver entity to obtain the optimum ATA modes for - a specific device. The IDE controller driver takes into account the following - while calculating the mode: - - The IdentifyData inputs to EFI_IDE_CONTROLLER_INIT_PROTOCOL.SubmitData() - - The BadModes inputs to EFI_IDE_CONTROLLER_INIT_PROTOCOL.DisqualifyMode() - - The driver entity is required to call EFI_IDE_CONTROLLER_INIT_PROTOCOL.SubmitData() - for all the devices that belong to an enumeration group before calling - EFI_IDE_CONTROLLER_INIT_PROTOCOL.CalculateMode() for any device in the same group. - - The IDE controller driver will use controller- and possibly platform-specific - algorithms to arrive at SupportedModes. The IDE controller may base its - decision on user preferences and other considerations as well. This function - may be called multiple times because the driver entity may renegotiate the mode - with the IDE controller driver using EFI_IDE_CONTROLLER_INIT_PROTOCOL.DisqualifyMode(). - - The driver entity may collect timing information for various devices in any - order. The driver entity is responsible for making sure that all the dependencies - are satisfied. For example, the SupportedModes information for device A that - was previously returned may become stale after a call to - EFI_IDE_CONTROLLER_INIT_PROTOCOL.DisqualifyMode() for device B. - - The buffer SupportedModes is allocated by the callee because the caller does - not necessarily know the size of the buffer. The type EFI_ATA_COLLECTIVE_MODE - is defined in a way that allows for future extensibility and can be of variable - length. This memory pool should be deallocated by the caller when it is no - longer necessary. - - The IDE controller driver for a Serial ATA (SATA) controller can use this - member function to force a lower speed (first-generation [Gen1] speeds on a - second-generation [Gen2]-capable hardware). The IDE controller driver can - also allow the driver entity to stay with the speed that has been negotiated - by the physical layer. - - @param[in] This The pointer to the EFI_IDE_CONTROLLER_INIT_PROTOCOL instance. - @param[in] Channel A zero-based channel number. - @param[in] Device A zero-based device number on the Channel. - @param[out] SupportedModes The optimum modes for the device. - - @retval EFI_SUCCESS SupportedModes was returned. - @retval EFI_INVALID_PARAMETER Channel is invalid (Channel >= ChannelCount). - @retval EFI_INVALID_PARAMETER Device is invalid. - @retval EFI_INVALID_PARAMETER SupportedModes is NULL. - @retval EFI_NOT_READY Modes cannot be calculated due to a lack of - data. This error may happen if - EFI_IDE_CONTROLLER_INIT_PROTOCOL.SubmitData() - and EFI_IDE_CONTROLLER_INIT_PROTOCOL.DisqualifyData() - were not called for at least one drive in the - same enumeration group. - -**/ -EFI_STATUS -EFIAPI -IdeInitCalculateMode ( - IN EFI_IDE_CONTROLLER_INIT_PROTOCOL *This, - IN UINT8 Channel, - IN UINT8 Device, - OUT EFI_ATA_COLLECTIVE_MODE **SupportedModes - ) -{ - EFI_SATA_CONTROLLER_PRIVATE_DATA *SataPrivateData; - EFI_IDENTIFY_DATA *IdentifyData; - BOOLEAN IdentifyValid; - EFI_ATA_COLLECTIVE_MODE *DisqualifiedModes; - UINT16 SelectedMode; - EFI_STATUS Status; - UINTN DeviceIndex; - - SataPrivateData = SATA_CONTROLLER_PRIVATE_DATA_FROM_THIS (This); - ASSERT (SataPrivateData != NULL); - - if ((Channel >= This->ChannelCount) || (SupportedModes == NULL) || (Device >= SataPrivateData->DeviceCount)) { - return EFI_INVALID_PARAMETER; - } - - *SupportedModes = AllocateZeroPool (sizeof (EFI_ATA_COLLECTIVE_MODE)); - if (*SupportedModes == NULL) { - ASSERT (*SupportedModes != NULL); - return EFI_OUT_OF_RESOURCES; - } - - DeviceIndex = FlatDeviceIndex (SataPrivateData, Channel, Device); - - IdentifyData = &(SataPrivateData->IdentifyData[DeviceIndex]); - IdentifyValid = SataPrivateData->IdentifyValid[DeviceIndex]; - DisqualifiedModes = &(SataPrivateData->DisqualifiedModes[DeviceIndex]); - - // - // Make sure we've got the valid identify data of the device from SubmitData() - // - if (!IdentifyValid) { - FreePool (*SupportedModes); - return EFI_NOT_READY; - } - - Status = CalculateBestPioMode ( - IdentifyData, - (DisqualifiedModes->PioMode.Valid ? ((UINT16 *) &(DisqualifiedModes->PioMode.Mode)) : NULL), - &SelectedMode - ); - if (!EFI_ERROR (Status)) { - (*SupportedModes)->PioMode.Valid = TRUE; - (*SupportedModes)->PioMode.Mode = SelectedMode; - - } else { - (*SupportedModes)->PioMode.Valid = FALSE; - } - DEBUG ((EFI_D_INFO, "IdeInitCalculateMode: PioMode = %x\n", (*SupportedModes)->PioMode.Mode)); - - Status = CalculateBestUdmaMode ( - IdentifyData, - (DisqualifiedModes->UdmaMode.Valid ? ((UINT16 *) &(DisqualifiedModes->UdmaMode.Mode)) : NULL), - &SelectedMode - ); - - if (!EFI_ERROR (Status)) { - (*SupportedModes)->UdmaMode.Valid = TRUE; - (*SupportedModes)->UdmaMode.Mode = SelectedMode; - - } else { - (*SupportedModes)->UdmaMode.Valid = FALSE; - } - DEBUG ((EFI_D_INFO, "IdeInitCalculateMode: UdmaMode = %x\n", (*SupportedModes)->UdmaMode.Mode)); - - // - // The modes other than PIO and UDMA are not supported - // - return EFI_SUCCESS; -} - -/** - Commands the IDE controller driver to program the IDE controller hardware - so that the specified device can operate at the specified mode. - - This function is used by the driver entity to instruct the IDE controller - driver to program the IDE controller hardware to the specified modes. This - function can be called only once for a particular device. For a Serial ATA - (SATA) Advanced Host Controller Interface (AHCI) controller, no controller- - specific programming may be required. - - @param[in] This Pointer to the EFI_IDE_CONTROLLER_INIT_PROTOCOL instance. - @param[in] Channel Zero-based channel number. - @param[in] Device Zero-based device number on the Channel. - @param[in] Modes The modes to set. - - @retval EFI_SUCCESS The command was accepted without any errors. - @retval EFI_INVALID_PARAMETER Channel is invalid (Channel >= ChannelCount). - @retval EFI_INVALID_PARAMETER Device is invalid. - @retval EFI_NOT_READY Modes cannot be set at this time due to lack of data. - @retval EFI_DEVICE_ERROR Modes cannot be set due to hardware failure. - The driver entity should not use this device. - -**/ -EFI_STATUS -EFIAPI -IdeInitSetTiming ( - IN EFI_IDE_CONTROLLER_INIT_PROTOCOL *This, - IN UINT8 Channel, - IN UINT8 Device, - IN EFI_ATA_COLLECTIVE_MODE *Modes - ) -{ - return EFI_SUCCESS; -} diff --git a/OvmfPkg/SataControllerDxe/SataController.h b/OvmfPkg/SataControllerDxe/SataController.h deleted file mode 100644 index e5b719e76d..0000000000 --- a/OvmfPkg/SataControllerDxe/SataController.h +++ /dev/null @@ -1,547 +0,0 @@ -/** @file - Header file for Sata Controller driver. - - Copyright (c) 2011, Intel Corporation. All rights reserved.
- This program and the accompanying materials - are licensed and made available under the terms and conditions of the BSD License - which accompanies this distribution. The full text of the license may be found at - http://opensource.org/licenses/bsd-license.php - - THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, - WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. - -**/ - -#ifndef _SATA_CONTROLLER_H_ -#define _SATA_CONTROLLER_H_ - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -// -// Global Variables definitions -// -extern EFI_DRIVER_BINDING_PROTOCOL gSataControllerDriverBinding; -extern EFI_COMPONENT_NAME_PROTOCOL gSataControllerComponentName; -extern EFI_COMPONENT_NAME2_PROTOCOL gSataControllerComponentName2; - -#define AHCI_BAR_INDEX 0x05 -#define R_AHCI_CAP 0x0 -#define B_AHCI_CAP_NPS (BIT4 | BIT3 | BIT2 | BIT1 | BIT0) // Number of Ports -#define B_AHCI_CAP_SPM BIT17 // Supports Port Multiplier - -/// -/// AHCI each channel can have up to 1 device -/// -#define AHCI_MAX_DEVICES 0x01 - -/// -/// AHCI each channel can have 15 devices in the presence of a multiplier -/// -#define AHCI_MULTI_MAX_DEVICES 0x0F - -/// -/// IDE supports 2 channel max -/// -#define IDE_MAX_CHANNEL 0x02 - -/// -/// IDE supports 2 devices max -/// -#define IDE_MAX_DEVICES 0x02 - -#define SATA_ENUMER_ALL FALSE - -// -// Sata Controller driver private data structure -// - -#define SATA_CONTROLLER_SIGNATURE SIGNATURE_32('S','A','T','A') - -typedef struct _EFI_SATA_CONTROLLER_PRIVATE_DATA { - // - // Standard signature used to identify Sata Controller private data - // - UINT32 Signature; - - // - // Protocol instance of IDE_CONTROLLER_INIT produced by this driver - // - EFI_IDE_CONTROLLER_INIT_PROTOCOL IdeInit; - - // - // Copy of protocol pointers used by this driver - // - EFI_PCI_IO_PROTOCOL *PciIo; - - // - // Original PCI attributes - // - UINT64 OriginalPciAttributes; - - // - // The number of devices that are supported by this channel - // - UINT8 DeviceCount; - - // - // The highest disqulified mode for each attached device, - // From ATA/ATAPI spec, if a mode is not supported, - // the modes higher than it is also not supported - // - EFI_ATA_COLLECTIVE_MODE *DisqualifiedModes; - - // - // A copy of EFI_IDENTIFY_DATA data for each attached SATA device and its flag - // - EFI_IDENTIFY_DATA *IdentifyData; - BOOLEAN *IdentifyValid; -} EFI_SATA_CONTROLLER_PRIVATE_DATA; - -#define SATA_CONTROLLER_PRIVATE_DATA_FROM_THIS(a) CR(a, EFI_SATA_CONTROLLER_PRIVATE_DATA, IdeInit, SATA_CONTROLLER_SIGNATURE) - -// -// Driver binding functions declaration -// -/** - Supported function of Driver Binding protocol for this driver. - Test to see if this driver supports ControllerHandle. - - @param This Protocol instance pointer. - @param Controller Handle of device to test. - @param RemainingDevicePath A pointer to the device path. Should be ignored by - device driver. - - @retval EFI_SUCCESS This driver supports this device. - @retval EFI_ALREADY_STARTED This driver is already running on this device. - @retval other This driver does not support this device. - -**/ -EFI_STATUS -EFIAPI -SataControllerSupported ( - IN EFI_DRIVER_BINDING_PROTOCOL *This, - IN EFI_HANDLE Controller, - IN EFI_DEVICE_PATH_PROTOCOL *RemainingDevicePath - ) -; - -/** - This routine is called right after the .Supported() called and - Start this driver on ControllerHandle. - - @param This Protocol instance pointer. - @param Controller Handle of device to bind driver to. - @param RemainingDevicePath A pointer to the device path. Should be ignored by - device driver. - - @retval EFI_SUCCESS This driver is added to this device. - @retval EFI_ALREADY_STARTED This driver is already running on this device. - @retval other Some error occurs when binding this driver to this device. - -**/ -EFI_STATUS -EFIAPI -SataControllerStart ( - IN EFI_DRIVER_BINDING_PROTOCOL *This, - IN EFI_HANDLE Controller, - IN EFI_DEVICE_PATH_PROTOCOL *RemainingDevicePath - ) -; - -/** - Stop this driver on ControllerHandle. - - @param This Protocol instance pointer. - @param Controller Handle of device to stop driver on. - @param NumberOfChildren Not used. - @param ChildHandleBuffer Not used. - - @retval EFI_SUCCESS This driver is removed from this device. - @retval other Some error occurs when removing this driver from this device. - -**/ -EFI_STATUS -EFIAPI -SataControllerStop ( - IN EFI_DRIVER_BINDING_PROTOCOL *This, - IN EFI_HANDLE Controller, - IN UINTN NumberOfChildren, - IN EFI_HANDLE *ChildHandleBuffer - ) -; - -// -// IDE controller init functions declaration -// -/** - Returns the information about the specified IDE channel. - - This function can be used to obtain information about a particular IDE channel. - The driver entity uses this information during the enumeration process. - - If Enabled is set to FALSE, the driver entity will not scan the channel. Note - that it will not prevent an operating system driver from scanning the channel. - - For most of today's controllers, MaxDevices will either be 1 or 2. For SATA - controllers, this value will always be 1. SATA configurations can contain SATA - port multipliers. SATA port multipliers behave like SATA bridges and can support - up to 16 devices on the other side. If a SATA port out of the IDE controller - is connected to a port multiplier, MaxDevices will be set to the number of SATA - devices that the port multiplier supports. Because today's port multipliers - support up to fifteen SATA devices, this number can be as large as fifteen. The IDE - bus driver is required to scan for the presence of port multipliers behind an SATA - controller and enumerate up to MaxDevices number of devices behind the port - multiplier. - - In this context, the devices behind a port multiplier constitute a channel. - - @param[in] This The pointer to the EFI_IDE_CONTROLLER_INIT_PROTOCOL instance. - @param[in] Channel Zero-based channel number. - @param[out] Enabled TRUE if this channel is enabled. Disabled channels - are not scanned to see if any devices are present. - @param[out] MaxDevices The maximum number of IDE devices that the bus driver - can expect on this channel. For the ATA/ATAPI - specification, version 6, this number will either be - one or two. For Serial ATA (SATA) configurations with a - port multiplier, this number can be as large as fifteen. - - @retval EFI_SUCCESS Information was returned without any errors. - @retval EFI_INVALID_PARAMETER Channel is invalid (Channel >= ChannelCount). - -**/ -EFI_STATUS -EFIAPI -IdeInitGetChannelInfo ( - IN EFI_IDE_CONTROLLER_INIT_PROTOCOL *This, - IN UINT8 Channel, - OUT BOOLEAN *Enabled, - OUT UINT8 *MaxDevices - ) -; - -/** - The notifications from the driver entity that it is about to enter a certain - phase of the IDE channel enumeration process. - - This function can be used to notify the IDE controller driver to perform - specific actions, including any chipset-specific initialization, so that the - chipset is ready to enter the next phase. Seven notification points are defined - at this time. - - More synchronization points may be added as required in the future. - - @param[in] This The pointer to the EFI_IDE_CONTROLLER_INIT_PROTOCOL instance. - @param[in] Phase The phase during enumeration. - @param[in] Channel Zero-based channel number. - - @retval EFI_SUCCESS The notification was accepted without any errors. - @retval EFI_UNSUPPORTED Phase is not supported. - @retval EFI_INVALID_PARAMETER Channel is invalid (Channel >= ChannelCount). - @retval EFI_NOT_READY This phase cannot be entered at this time; for - example, an attempt was made to enter a Phase - without having entered one or more previous - Phase. - -**/ -EFI_STATUS -EFIAPI -IdeInitNotifyPhase ( - IN EFI_IDE_CONTROLLER_INIT_PROTOCOL *This, - IN EFI_IDE_CONTROLLER_ENUM_PHASE Phase, - IN UINT8 Channel - ) -; - -/** - Submits the device information to the IDE controller driver. - - This function is used by the driver entity to pass detailed information about - a particular device to the IDE controller driver. The driver entity obtains - this information by issuing an ATA or ATAPI IDENTIFY_DEVICE command. IdentifyData - is the pointer to the response data buffer. The IdentifyData buffer is owned - by the driver entity, and the IDE controller driver must make a local copy - of the entire buffer or parts of the buffer as needed. The original IdentifyData - buffer pointer may not be valid when - - - EFI_IDE_CONTROLLER_INIT_PROTOCOL.CalculateMode() or - - EFI_IDE_CONTROLLER_INIT_PROTOCOL.DisqualifyMode() is called at a later point. - - The IDE controller driver may consult various fields of EFI_IDENTIFY_DATA to - compute the optimum mode for the device. These fields are not limited to the - timing information. For example, an implementation of the IDE controller driver - may examine the vendor and type/mode field to match known bad drives. - - The driver entity may submit drive information in any order, as long as it - submits information for all the devices belonging to the enumeration group - before EFI_IDE_CONTROLLER_INIT_PROTOCOL.CalculateMode() is called for any device - in that enumeration group. If a device is absent, EFI_IDE_CONTROLLER_INIT_PROTOCOL.SubmitData() - should be called with IdentifyData set to NULL. The IDE controller driver may - not have any other mechanism to know whether a device is present or not. Therefore, - setting IdentifyData to NULL does not constitute an error condition. - EFI_IDE_CONTROLLER_INIT_PROTOCOL.SubmitData() can be called only once for a - given (Channel, Device) pair. - - @param[in] This A pointer to the EFI_IDE_CONTROLLER_INIT_PROTOCOL instance. - @param[in] Channel Zero-based channel number. - @param[in] Device Zero-based device number on the Channel. - @param[in] IdentifyData The device's response to the ATA IDENTIFY_DEVICE command. - - @retval EFI_SUCCESS The information was accepted without any errors. - @retval EFI_INVALID_PARAMETER Channel is invalid (Channel >= ChannelCount). - @retval EFI_INVALID_PARAMETER Device is invalid. - -**/ -EFI_STATUS -EFIAPI -IdeInitSubmitData ( - IN EFI_IDE_CONTROLLER_INIT_PROTOCOL *This, - IN UINT8 Channel, - IN UINT8 Device, - IN EFI_IDENTIFY_DATA *IdentifyData - ) -; - -/** - Disqualifies specific modes for an IDE device. - - This function allows the driver entity or other drivers (such as platform - drivers) to reject certain timing modes and request the IDE controller driver - to recalculate modes. This function allows the driver entity and the IDE - controller driver to negotiate the timings on a per-device basis. This function - is useful in the case of drives that lie about their capabilities. An example - is when the IDE device fails to accept the timing modes that are calculated - by the IDE controller driver based on the response to the Identify Drive command. - - If the driver entity does not want to limit the ATA timing modes and leave that - decision to the IDE controller driver, it can either not call this function for - the given device or call this function and set the Valid flag to FALSE for all - modes that are listed in EFI_ATA_COLLECTIVE_MODE. - - The driver entity may disqualify modes for a device in any order and any number - of times. - - This function can be called multiple times to invalidate multiple modes of the - same type (e.g., Programmed Input/Output [PIO] modes 3 and 4). See the ATA/ATAPI - specification for more information on PIO modes. - - For Serial ATA (SATA) controllers, this member function can be used to disqualify - a higher transfer rate mode on a given channel. For example, a platform driver - may inform the IDE controller driver to not use second-generation (Gen2) speeds - for a certain SATA drive. - - @param[in] This The pointer to the EFI_IDE_CONTROLLER_INIT_PROTOCOL instance. - @param[in] Channel The zero-based channel number. - @param[in] Device The zero-based device number on the Channel. - @param[in] BadModes The modes that the device does not support and that - should be disqualified. - - @retval EFI_SUCCESS The modes were accepted without any errors. - @retval EFI_INVALID_PARAMETER Channel is invalid (Channel >= ChannelCount). - @retval EFI_INVALID_PARAMETER Device is invalid. - @retval EFI_INVALID_PARAMETER IdentifyData is NULL. - -**/ -EFI_STATUS -EFIAPI -IdeInitDisqualifyMode ( - IN EFI_IDE_CONTROLLER_INIT_PROTOCOL *This, - IN UINT8 Channel, - IN UINT8 Device, - IN EFI_ATA_COLLECTIVE_MODE *BadModes - ) -; - -/** - Returns the information about the optimum modes for the specified IDE device. - - This function is used by the driver entity to obtain the optimum ATA modes for - a specific device. The IDE controller driver takes into account the following - while calculating the mode: - - The IdentifyData inputs to EFI_IDE_CONTROLLER_INIT_PROTOCOL.SubmitData() - - The BadModes inputs to EFI_IDE_CONTROLLER_INIT_PROTOCOL.DisqualifyMode() - - The driver entity is required to call EFI_IDE_CONTROLLER_INIT_PROTOCOL.SubmitData() - for all the devices that belong to an enumeration group before calling - EFI_IDE_CONTROLLER_INIT_PROTOCOL.CalculateMode() for any device in the same group. - - The IDE controller driver will use controller- and possibly platform-specific - algorithms to arrive at SupportedModes. The IDE controller may base its - decision on user preferences and other considerations as well. This function - may be called multiple times because the driver entity may renegotiate the mode - with the IDE controller driver using EFI_IDE_CONTROLLER_INIT_PROTOCOL.DisqualifyMode(). - - The driver entity may collect timing information for various devices in any - order. The driver entity is responsible for making sure that all the dependencies - are satisfied. For example, the SupportedModes information for device A that - was previously returned may become stale after a call to - EFI_IDE_CONTROLLER_INIT_PROTOCOL.DisqualifyMode() for device B. - - The buffer SupportedModes is allocated by the callee because the caller does - not necessarily know the size of the buffer. The type EFI_ATA_COLLECTIVE_MODE - is defined in a way that allows for future extensibility and can be of variable - length. This memory pool should be deallocated by the caller when it is no - longer necessary. - - The IDE controller driver for a Serial ATA (SATA) controller can use this - member function to force a lower speed (first-generation [Gen1] speeds on a - second-generation [Gen2]-capable hardware). The IDE controller driver can - also allow the driver entity to stay with the speed that has been negotiated - by the physical layer. - - @param[in] This The pointer to the EFI_IDE_CONTROLLER_INIT_PROTOCOL instance. - @param[in] Channel A zero-based channel number. - @param[in] Device A zero-based device number on the Channel. - @param[out] SupportedModes The optimum modes for the device. - - @retval EFI_SUCCESS SupportedModes was returned. - @retval EFI_INVALID_PARAMETER Channel is invalid (Channel >= ChannelCount). - @retval EFI_INVALID_PARAMETER Device is invalid. - @retval EFI_INVALID_PARAMETER SupportedModes is NULL. - @retval EFI_NOT_READY Modes cannot be calculated due to a lack of - data. This error may happen if - EFI_IDE_CONTROLLER_INIT_PROTOCOL.SubmitData() - and EFI_IDE_CONTROLLER_INIT_PROTOCOL.DisqualifyData() - were not called for at least one drive in the - same enumeration group. - -**/ -EFI_STATUS -EFIAPI -IdeInitCalculateMode ( - IN EFI_IDE_CONTROLLER_INIT_PROTOCOL *This, - IN UINT8 Channel, - IN UINT8 Device, - OUT EFI_ATA_COLLECTIVE_MODE **SupportedModes - ) -; - -/** - Commands the IDE controller driver to program the IDE controller hardware - so that the specified device can operate at the specified mode. - - This function is used by the driver entity to instruct the IDE controller - driver to program the IDE controller hardware to the specified modes. This - function can be called only once for a particular device. For a Serial ATA - (SATA) Advanced Host Controller Interface (AHCI) controller, no controller- - specific programming may be required. - - @param[in] This Pointer to the EFI_IDE_CONTROLLER_INIT_PROTOCOL instance. - @param[in] Channel Zero-based channel number. - @param[in] Device Zero-based device number on the Channel. - @param[in] Modes The modes to set. - - @retval EFI_SUCCESS The command was accepted without any errors. - @retval EFI_INVALID_PARAMETER Channel is invalid (Channel >= ChannelCount). - @retval EFI_INVALID_PARAMETER Device is invalid. - @retval EFI_NOT_READY Modes cannot be set at this time due to lack of data. - @retval EFI_DEVICE_ERROR Modes cannot be set due to hardware failure. - The driver entity should not use this device. - -**/ -EFI_STATUS -EFIAPI -IdeInitSetTiming ( - IN EFI_IDE_CONTROLLER_INIT_PROTOCOL *This, - IN UINT8 Channel, - IN UINT8 Device, - IN EFI_ATA_COLLECTIVE_MODE *Modes - ) -; - -// -// Forward reference declaration -// -/** - Retrieves a Unicode string that is the user readable name of the UEFI Driver. - - @param This A pointer to the EFI_COMPONENT_NAME_PROTOCOL instance. - @param Language A pointer to a three character ISO 639-2 language identifier. - This is the language of the driver name that that the caller - is requesting, and it must match one of the languages specified - in SupportedLanguages. The number of languages supported by a - driver is up to the driver writer. - @param DriverName A pointer to the Unicode string to return. This Unicode string - is the name of the driver specified by This in the language - specified by Language. - - @retval EFI_SUCCESS The Unicode string for the Driver specified by This - and the language specified by Language was returned - in DriverName. - @retval EFI_INVALID_PARAMETER Language is NULL. - @retval EFI_INVALID_PARAMETER DriverName is NULL. - @retval EFI_UNSUPPORTED The driver specified by This does not support the - language specified by Language. -**/ -EFI_STATUS -EFIAPI -SataControllerComponentNameGetDriverName ( - IN EFI_COMPONENT_NAME_PROTOCOL *This, - IN CHAR8 *Language, - OUT CHAR16 **DriverName - ) -; - -/** - Retrieves a Unicode string that is the user readable name of the controller - that is being managed by an UEFI Driver. - - @param This A pointer to the EFI_COMPONENT_NAME_PROTOCOL instance. - @param ControllerHandle The handle of a controller that the driver specified by - This is managing. This handle specifies the controller - whose name is to be returned. - @param OPTIONAL ChildHandle The handle of the child controller to retrieve the name - of. This is an optional parameter that may be NULL. It - will be NULL for device drivers. It will also be NULL - for a bus drivers that wish to retrieve the name of the - bus controller. It will not be NULL for a bus driver - that wishes to retrieve the name of a child controller. - @param Language A pointer to a three character ISO 639-2 language - identifier. This is the language of the controller name - that that the caller is requesting, and it must match one - of the languages specified in SupportedLanguages. The - number of languages supported by a driver is up to the - driver writer. - @param ControllerName A pointer to the Unicode string to return. This Unicode - string is the name of the controller specified by - ControllerHandle and ChildHandle in the language - specified by Language from the point of view of the - driver specified by This. - - @retval EFI_SUCCESS The Unicode string for the user readable name in the - language specified by Language for the driver - specified by This was returned in DriverName. - @retval EFI_INVALID_PARAMETER ControllerHandle is not a valid EFI_HANDLE. - @retval EFI_INVALID_PARAMETER ChildHandle is not NULL and it is not a valid - EFI_HANDLE. - @retval EFI_INVALID_PARAMETER Language is NULL. - @retval EFI_INVALID_PARAMETER ControllerName is NULL. - @retval EFI_UNSUPPORTED The driver specified by This is not currently - managing the controller specified by - ControllerHandle and ChildHandle. - @retval EFI_UNSUPPORTED The driver specified by This does not support the - language specified by Language. -**/ -EFI_STATUS -EFIAPI -SataControllerComponentNameGetControllerName ( - IN EFI_COMPONENT_NAME_PROTOCOL *This, - IN EFI_HANDLE ControllerHandle, - IN EFI_HANDLE ChildHandle OPTIONAL, - IN CHAR8 *Language, - OUT CHAR16 **ControllerName - ) -; - -#endif diff --git a/OvmfPkg/SataControllerDxe/SataControllerDxe.inf b/OvmfPkg/SataControllerDxe/SataControllerDxe.inf deleted file mode 100644 index 42312062d7..0000000000 --- a/OvmfPkg/SataControllerDxe/SataControllerDxe.inf +++ /dev/null @@ -1,49 +0,0 @@ -## @file -# -# Component description file for the Sata Controller driver. -# -# Copyright (c) 2011, Intel Corporation. All rights reserved.
-# This program and the accompanying materials -# are licensed and made available under the terms and conditions of the BSD License -# which accompanies this distribution. The full text of the license may be found at -# http://opensource.org/licenses/bsd-license.php -# -# THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, -# WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. -# -## - -[Defines] - INF_VERSION = 0x00010005 - BASE_NAME = SataController - FILE_GUID = 021722D8-522B-4079-852A-FE44C2C13F49 - MODULE_TYPE = UEFI_DRIVER - VERSION_STRING = 1.0 - ENTRY_POINT = InitializeSataControllerDriver - -# -# The following information is for reference only and not required by the build tools. -# -# VALID_ARCHITECTURES = IA32 X64 IPF EBC -# - -[Sources] - ComponentName.c - SataController.c - SataController.h - -[Packages] - MdePkg/MdePkg.dec - -[LibraryClasses] - UefiDriverEntryPoint - DebugLib - UefiLib - BaseLib - BaseMemoryLib - MemoryAllocationLib - UefiBootServicesTableLib - -[Protocols] - gEfiPciIoProtocolGuid - gEfiIdeControllerInitProtocolGuid diff --git a/OvmfPkg/Sec/Ia32/SecEntry.nasm b/OvmfPkg/Sec/Ia32/SecEntry.nasm deleted file mode 100644 index 7fee1c2b2e..0000000000 --- a/OvmfPkg/Sec/Ia32/SecEntry.nasm +++ /dev/null @@ -1,56 +0,0 @@ -;------------------------------------------------------------------------------ -;* -;* Copyright (c) 2006 - 2013, Intel Corporation. All rights reserved.
-;* This program and the accompanying materials -;* are licensed and made available under the terms and conditions of the BSD License -;* which accompanies this distribution. The full text of the license may be found at -;* http://opensource.org/licenses/bsd-license.php -;* -;* THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, -;* WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. -;* -;* CpuAsm.asm -;* -;* Abstract: -;* -;------------------------------------------------------------------------------ - -#include - - SECTION .text - -extern ASM_PFX(SecCoreStartupWithStack) - -; -; SecCore Entry Point -; -; Processor is in flat protected mode -; -; @param[in] EAX Initial value of the EAX register (BIST: Built-in Self Test) -; @param[in] DI 'BP': boot-strap processor, or 'AP': application processor -; @param[in] EBP Pointer to the start of the Boot Firmware Volume -; -; @return None This routine does not return -; -global ASM_PFX(_ModuleEntryPoint) -ASM_PFX(_ModuleEntryPoint): - - ; - ; Load temporary RAM stack based on PCDs - ; - %define SEC_TOP_OF_STACK (FixedPcdGet32 (PcdOvmfSecPeiTempRamBase) + \ - FixedPcdGet32 (PcdOvmfSecPeiTempRamSize)) - mov eax, SEC_TOP_OF_STACK - mov esp, eax - nop - - ; - ; Setup parameters and call SecCoreStartupWithStack - ; [esp] return address for call - ; [esp+4] BootFirmwareVolumePtr - ; [esp+8] TopOfCurrentStack - ; - push eax - push ebp - call ASM_PFX(SecCoreStartupWithStack) - diff --git a/OvmfPkg/Sec/SecMain.c b/OvmfPkg/Sec/SecMain.c deleted file mode 100644 index e1993ec347..0000000000 --- a/OvmfPkg/Sec/SecMain.c +++ /dev/null @@ -1,945 +0,0 @@ -/** @file - Main SEC phase code. Transitions to PEI. - - Copyright (c) 2008 - 2015, Intel Corporation. All rights reserved.
- (C) Copyright 2016 Hewlett Packard Enterprise Development LP
- - This program and the accompanying materials - are licensed and made 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 - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#include - -#define SEC_IDT_ENTRY_COUNT 34 - -typedef struct _SEC_IDT_TABLE { - EFI_PEI_SERVICES *PeiService; - IA32_IDT_GATE_DESCRIPTOR IdtTable[SEC_IDT_ENTRY_COUNT]; -} SEC_IDT_TABLE; - -VOID -EFIAPI -SecStartupPhase2 ( - IN VOID *Context - ); - -EFI_STATUS -EFIAPI -TemporaryRamMigration ( - IN CONST EFI_PEI_SERVICES **PeiServices, - IN EFI_PHYSICAL_ADDRESS TemporaryMemoryBase, - IN EFI_PHYSICAL_ADDRESS PermanentMemoryBase, - IN UINTN CopySize - ); - -// -// -// -EFI_PEI_TEMPORARY_RAM_SUPPORT_PPI mTemporaryRamSupportPpi = { - TemporaryRamMigration -}; - -EFI_PEI_PPI_DESCRIPTOR mPrivateDispatchTable[] = { - { - (EFI_PEI_PPI_DESCRIPTOR_PPI | EFI_PEI_PPI_DESCRIPTOR_TERMINATE_LIST), - &gEfiTemporaryRamSupportPpiGuid, - &mTemporaryRamSupportPpi - }, -}; - -// -// Template of an IDT entry pointing to 10:FFFFFFE4h. -// -IA32_IDT_GATE_DESCRIPTOR mIdtEntryTemplate = { - { // Bits - 0xffe4, // OffsetLow - 0x10, // Selector - 0x0, // Reserved_0 - IA32_IDT_GATE_TYPE_INTERRUPT_32, // GateType - 0xffff // OffsetHigh - } -}; - -/** - Locates the main boot firmware volume. - - @param[in,out] BootFv On input, the base of the BootFv - On output, the decompressed main firmware volume - - @retval EFI_SUCCESS The main firmware volume was located and decompressed - @retval EFI_NOT_FOUND The main firmware volume was not found - -**/ -EFI_STATUS -FindMainFv ( - IN OUT EFI_FIRMWARE_VOLUME_HEADER **BootFv - ) -{ - EFI_FIRMWARE_VOLUME_HEADER *Fv; - UINTN Distance; - - ASSERT (((UINTN) *BootFv & EFI_PAGE_MASK) == 0); - - Fv = *BootFv; - Distance = (UINTN) (*BootFv)->FvLength; - do { - Fv = (EFI_FIRMWARE_VOLUME_HEADER*) ((UINT8*) Fv - EFI_PAGE_SIZE); - Distance += EFI_PAGE_SIZE; - if (Distance > SIZE_32MB) { - return EFI_NOT_FOUND; - } - - if (Fv->Signature != EFI_FVH_SIGNATURE) { - continue; - } - - if ((UINTN) Fv->FvLength > Distance) { - continue; - } - - *BootFv = Fv; - return EFI_SUCCESS; - - } while (TRUE); -} - -/** - Locates a section within a series of sections - with the specified section type. - - The Instance parameter indicates which instance of the section - type to return. (0 is first instance, 1 is second...) - - @param[in] Sections The sections to search - @param[in] SizeOfSections Total size of all sections - @param[in] SectionType The section type to locate - @param[in] Instance The section instance number - @param[out] FoundSection The FFS section if found - - @retval EFI_SUCCESS The file and section was found - @retval EFI_NOT_FOUND The file and section was not found - @retval EFI_VOLUME_CORRUPTED The firmware volume was corrupted - -**/ -EFI_STATUS -FindFfsSectionInstance ( - IN VOID *Sections, - IN UINTN SizeOfSections, - IN EFI_SECTION_TYPE SectionType, - IN UINTN Instance, - OUT EFI_COMMON_SECTION_HEADER **FoundSection - ) -{ - EFI_PHYSICAL_ADDRESS CurrentAddress; - UINT32 Size; - EFI_PHYSICAL_ADDRESS EndOfSections; - EFI_COMMON_SECTION_HEADER *Section; - EFI_PHYSICAL_ADDRESS EndOfSection; - - // - // Loop through the FFS file sections within the PEI Core FFS file - // - EndOfSection = (EFI_PHYSICAL_ADDRESS)(UINTN) Sections; - EndOfSections = EndOfSection + SizeOfSections; - for (;;) { - if (EndOfSection == EndOfSections) { - break; - } - CurrentAddress = (EndOfSection + 3) & ~(3ULL); - if (CurrentAddress >= EndOfSections) { - return EFI_VOLUME_CORRUPTED; - } - - Section = (EFI_COMMON_SECTION_HEADER*)(UINTN) CurrentAddress; - - Size = SECTION_SIZE (Section); - if (Size < sizeof (*Section)) { - return EFI_VOLUME_CORRUPTED; - } - - EndOfSection = CurrentAddress + Size; - if (EndOfSection > EndOfSections) { - return EFI_VOLUME_CORRUPTED; - } - - // - // Look for the requested section type - // - if (Section->Type == SectionType) { - if (Instance == 0) { - *FoundSection = Section; - return EFI_SUCCESS; - } else { - Instance--; - } - } - } - - return EFI_NOT_FOUND; -} - -/** - Locates a section within a series of sections - with the specified section type. - - @param[in] Sections The sections to search - @param[in] SizeOfSections Total size of all sections - @param[in] SectionType The section type to locate - @param[out] FoundSection The FFS section if found - - @retval EFI_SUCCESS The file and section was found - @retval EFI_NOT_FOUND The file and section was not found - @retval EFI_VOLUME_CORRUPTED The firmware volume was corrupted - -**/ -EFI_STATUS -FindFfsSectionInSections ( - IN VOID *Sections, - IN UINTN SizeOfSections, - IN EFI_SECTION_TYPE SectionType, - OUT EFI_COMMON_SECTION_HEADER **FoundSection - ) -{ - return FindFfsSectionInstance ( - Sections, - SizeOfSections, - SectionType, - 0, - FoundSection - ); -} - -/** - Locates a FFS file with the specified file type and a section - within that file with the specified section type. - - @param[in] Fv The firmware volume to search - @param[in] FileType The file type to locate - @param[in] SectionType The section type to locate - @param[out] FoundSection The FFS section if found - - @retval EFI_SUCCESS The file and section was found - @retval EFI_NOT_FOUND The file and section was not found - @retval EFI_VOLUME_CORRUPTED The firmware volume was corrupted - -**/ -EFI_STATUS -FindFfsFileAndSection ( - IN EFI_FIRMWARE_VOLUME_HEADER *Fv, - IN EFI_FV_FILETYPE FileType, - IN EFI_SECTION_TYPE SectionType, - OUT EFI_COMMON_SECTION_HEADER **FoundSection - ) -{ - EFI_STATUS Status; - EFI_PHYSICAL_ADDRESS CurrentAddress; - EFI_PHYSICAL_ADDRESS EndOfFirmwareVolume; - EFI_FFS_FILE_HEADER *File; - UINT32 Size; - EFI_PHYSICAL_ADDRESS EndOfFile; - - if (Fv->Signature != EFI_FVH_SIGNATURE) { - DEBUG ((EFI_D_ERROR, "FV at %p does not have FV header signature\n", Fv)); - return EFI_VOLUME_CORRUPTED; - } - - CurrentAddress = (EFI_PHYSICAL_ADDRESS)(UINTN) Fv; - EndOfFirmwareVolume = CurrentAddress + Fv->FvLength; - - // - // Loop through the FFS files in the Boot Firmware Volume - // - for (EndOfFile = CurrentAddress + Fv->HeaderLength; ; ) { - - CurrentAddress = (EndOfFile + 7) & ~(7ULL); - if (CurrentAddress > EndOfFirmwareVolume) { - return EFI_VOLUME_CORRUPTED; - } - - File = (EFI_FFS_FILE_HEADER*)(UINTN) CurrentAddress; - Size = *(UINT32*) File->Size & 0xffffff; - if (Size < (sizeof (*File) + sizeof (EFI_COMMON_SECTION_HEADER))) { - return EFI_VOLUME_CORRUPTED; - } - - EndOfFile = CurrentAddress + Size; - if (EndOfFile > EndOfFirmwareVolume) { - return EFI_VOLUME_CORRUPTED; - } - - // - // Look for the request file type - // - if (File->Type != FileType) { - continue; - } - - Status = FindFfsSectionInSections ( - (VOID*) (File + 1), - (UINTN) EndOfFile - (UINTN) (File + 1), - SectionType, - FoundSection - ); - if (!EFI_ERROR (Status) || (Status == EFI_VOLUME_CORRUPTED)) { - return Status; - } - } -} - -/** - Locates the compressed main firmware volume and decompresses it. - - @param[in,out] Fv On input, the firmware volume to search - On output, the decompressed BOOT/PEI FV - - @retval EFI_SUCCESS The file and section was found - @retval EFI_NOT_FOUND The file and section was not found - @retval EFI_VOLUME_CORRUPTED The firmware volume was corrupted - -**/ -EFI_STATUS -DecompressMemFvs ( - IN OUT EFI_FIRMWARE_VOLUME_HEADER **Fv - ) -{ - EFI_STATUS Status; - EFI_GUID_DEFINED_SECTION *Section; - UINT32 OutputBufferSize; - UINT32 ScratchBufferSize; - UINT16 SectionAttribute; - UINT32 AuthenticationStatus; - VOID *OutputBuffer; - VOID *ScratchBuffer; - EFI_COMMON_SECTION_HEADER *FvSection; - EFI_FIRMWARE_VOLUME_HEADER *PeiMemFv; - EFI_FIRMWARE_VOLUME_HEADER *DxeMemFv; - UINT32 FvHeaderSize; - UINT32 FvSectionSize; - - FvSection = (EFI_COMMON_SECTION_HEADER*) NULL; - - Status = FindFfsFileAndSection ( - *Fv, - EFI_FV_FILETYPE_FIRMWARE_VOLUME_IMAGE, - EFI_SECTION_GUID_DEFINED, - (EFI_COMMON_SECTION_HEADER**) &Section - ); - if (EFI_ERROR (Status)) { - DEBUG ((EFI_D_ERROR, "Unable to find GUID defined section\n")); - return Status; - } - - Status = ExtractGuidedSectionGetInfo ( - Section, - &OutputBufferSize, - &ScratchBufferSize, - &SectionAttribute - ); - if (EFI_ERROR (Status)) { - DEBUG ((EFI_D_ERROR, "Unable to GetInfo for GUIDed section\n")); - return Status; - } - - OutputBuffer = (VOID*) ((UINT8*)(UINTN) PcdGet32 (PcdOvmfDxeMemFvBase) + SIZE_1MB); - ScratchBuffer = ALIGN_POINTER ((UINT8*) OutputBuffer + OutputBufferSize, SIZE_1MB); - - DEBUG ((EFI_D_VERBOSE, "%a: OutputBuffer@%p+0x%x ScratchBuffer@%p+0x%x " - "PcdOvmfDecompressionScratchEnd=0x%x\n", __FUNCTION__, OutputBuffer, - OutputBufferSize, ScratchBuffer, ScratchBufferSize, - PcdGet32 (PcdOvmfDecompressionScratchEnd))); - ASSERT ((UINTN)ScratchBuffer + ScratchBufferSize == - PcdGet32 (PcdOvmfDecompressionScratchEnd)); - - Status = ExtractGuidedSectionDecode ( - Section, - &OutputBuffer, - ScratchBuffer, - &AuthenticationStatus - ); - if (EFI_ERROR (Status)) { - DEBUG ((EFI_D_ERROR, "Error during GUID section decode\n")); - return Status; - } - - Status = FindFfsSectionInstance ( - OutputBuffer, - OutputBufferSize, - EFI_SECTION_FIRMWARE_VOLUME_IMAGE, - 0, - &FvSection - ); - if (EFI_ERROR (Status)) { - DEBUG ((EFI_D_ERROR, "Unable to find PEI FV section\n")); - return Status; - } - - ASSERT (SECTION_SIZE (FvSection) == - (PcdGet32 (PcdOvmfPeiMemFvSize) + sizeof (*FvSection))); - ASSERT (FvSection->Type == EFI_SECTION_FIRMWARE_VOLUME_IMAGE); - - PeiMemFv = (EFI_FIRMWARE_VOLUME_HEADER*)(UINTN) PcdGet32 (PcdOvmfPeiMemFvBase); - CopyMem (PeiMemFv, (VOID*) (FvSection + 1), PcdGet32 (PcdOvmfPeiMemFvSize)); - - if (PeiMemFv->Signature != EFI_FVH_SIGNATURE) { - DEBUG ((EFI_D_ERROR, "Extracted FV at %p does not have FV header signature\n", PeiMemFv)); - CpuDeadLoop (); - return EFI_VOLUME_CORRUPTED; - } - - Status = FindFfsSectionInstance ( - OutputBuffer, - OutputBufferSize, - EFI_SECTION_FIRMWARE_VOLUME_IMAGE, - 1, - &FvSection - ); - if (EFI_ERROR (Status)) { - DEBUG ((EFI_D_ERROR, "Unable to find DXE FV section\n")); - return Status; - } - - ASSERT (FvSection->Type == EFI_SECTION_FIRMWARE_VOLUME_IMAGE); - - if (IS_SECTION2 (FvSection)) { - FvSectionSize = SECTION2_SIZE (FvSection); - FvHeaderSize = sizeof (EFI_COMMON_SECTION_HEADER2); - } else { - FvSectionSize = SECTION_SIZE (FvSection); - FvHeaderSize = sizeof (EFI_COMMON_SECTION_HEADER); - } - - ASSERT (FvSectionSize == (PcdGet32 (PcdOvmfDxeMemFvSize) + FvHeaderSize)); - - DxeMemFv = (EFI_FIRMWARE_VOLUME_HEADER*)(UINTN) PcdGet32 (PcdOvmfDxeMemFvBase); - CopyMem (DxeMemFv, (VOID*) ((UINTN)FvSection + FvHeaderSize), PcdGet32 (PcdOvmfDxeMemFvSize)); - - if (DxeMemFv->Signature != EFI_FVH_SIGNATURE) { - DEBUG ((EFI_D_ERROR, "Extracted FV at %p does not have FV header signature\n", DxeMemFv)); - CpuDeadLoop (); - return EFI_VOLUME_CORRUPTED; - } - - *Fv = PeiMemFv; - return EFI_SUCCESS; -} - -/** - Locates the PEI Core entry point address - - @param[in] Fv The firmware volume to search - @param[out] PeiCoreEntryPoint The entry point of the PEI Core image - - @retval EFI_SUCCESS The file and section was found - @retval EFI_NOT_FOUND The file and section was not found - @retval EFI_VOLUME_CORRUPTED The firmware volume was corrupted - -**/ -EFI_STATUS -FindPeiCoreImageBaseInFv ( - IN EFI_FIRMWARE_VOLUME_HEADER *Fv, - OUT EFI_PHYSICAL_ADDRESS *PeiCoreImageBase - ) -{ - EFI_STATUS Status; - EFI_COMMON_SECTION_HEADER *Section; - - Status = FindFfsFileAndSection ( - Fv, - EFI_FV_FILETYPE_PEI_CORE, - EFI_SECTION_PE32, - &Section - ); - if (EFI_ERROR (Status)) { - Status = FindFfsFileAndSection ( - Fv, - EFI_FV_FILETYPE_PEI_CORE, - EFI_SECTION_TE, - &Section - ); - if (EFI_ERROR (Status)) { - DEBUG ((EFI_D_ERROR, "Unable to find PEI Core image\n")); - return Status; - } - } - - *PeiCoreImageBase = (EFI_PHYSICAL_ADDRESS)(UINTN)(Section + 1); - return EFI_SUCCESS; -} - - -/** - Reads 8-bits of CMOS data. - - Reads the 8-bits of CMOS data at the location specified by Index. - The 8-bit read value is returned. - - @param Index The CMOS location to read. - - @return The value read. - -**/ -STATIC -UINT8 -CmosRead8 ( - IN UINTN Index - ) -{ - IoWrite8 (0x70, (UINT8) Index); - return IoRead8 (0x71); -} - - -STATIC -BOOLEAN -IsS3Resume ( - VOID - ) -{ - return (CmosRead8 (0xF) == 0xFE); -} - - -STATIC -EFI_STATUS -GetS3ResumePeiFv ( - IN OUT EFI_FIRMWARE_VOLUME_HEADER **PeiFv - ) -{ - *PeiFv = (EFI_FIRMWARE_VOLUME_HEADER*)(UINTN) PcdGet32 (PcdOvmfPeiMemFvBase); - return EFI_SUCCESS; -} - - -/** - Locates the PEI Core entry point address - - @param[in,out] Fv The firmware volume to search - @param[out] PeiCoreEntryPoint The entry point of the PEI Core image - - @retval EFI_SUCCESS The file and section was found - @retval EFI_NOT_FOUND The file and section was not found - @retval EFI_VOLUME_CORRUPTED The firmware volume was corrupted - -**/ -VOID -FindPeiCoreImageBase ( - IN OUT EFI_FIRMWARE_VOLUME_HEADER **BootFv, - OUT EFI_PHYSICAL_ADDRESS *PeiCoreImageBase - ) -{ - BOOLEAN S3Resume; - - *PeiCoreImageBase = 0; - - S3Resume = IsS3Resume (); - if (S3Resume && !FeaturePcdGet (PcdSmmSmramRequire)) { - // - // A malicious runtime OS may have injected something into our previously - // decoded PEI FV, but we don't care about that unless SMM/SMRAM is required. - // - DEBUG ((EFI_D_VERBOSE, "SEC: S3 resume\n")); - GetS3ResumePeiFv (BootFv); - } else { - // - // We're either not resuming, or resuming "securely" -- we'll decompress - // both PEI FV and DXE FV from pristine flash. - // - DEBUG ((EFI_D_VERBOSE, "SEC: %a\n", - S3Resume ? "S3 resume (with PEI decompression)" : "Normal boot")); - FindMainFv (BootFv); - - DecompressMemFvs (BootFv); - } - - FindPeiCoreImageBaseInFv (*BootFv, PeiCoreImageBase); -} - -/** - Find core image base. - -**/ -EFI_STATUS -FindImageBase ( - IN EFI_FIRMWARE_VOLUME_HEADER *BootFirmwareVolumePtr, - OUT EFI_PHYSICAL_ADDRESS *SecCoreImageBase - ) -{ - EFI_PHYSICAL_ADDRESS CurrentAddress; - EFI_PHYSICAL_ADDRESS EndOfFirmwareVolume; - EFI_FFS_FILE_HEADER *File; - UINT32 Size; - EFI_PHYSICAL_ADDRESS EndOfFile; - EFI_COMMON_SECTION_HEADER *Section; - EFI_PHYSICAL_ADDRESS EndOfSection; - - *SecCoreImageBase = 0; - - CurrentAddress = (EFI_PHYSICAL_ADDRESS)(UINTN) BootFirmwareVolumePtr; - EndOfFirmwareVolume = CurrentAddress + BootFirmwareVolumePtr->FvLength; - - // - // Loop through the FFS files in the Boot Firmware Volume - // - for (EndOfFile = CurrentAddress + BootFirmwareVolumePtr->HeaderLength; ; ) { - - CurrentAddress = (EndOfFile + 7) & 0xfffffffffffffff8ULL; - if (CurrentAddress > EndOfFirmwareVolume) { - return EFI_NOT_FOUND; - } - - File = (EFI_FFS_FILE_HEADER*)(UINTN) CurrentAddress; - Size = *(UINT32*) File->Size & 0xffffff; - if (Size < sizeof (*File)) { - return EFI_NOT_FOUND; - } - - EndOfFile = CurrentAddress + Size; - if (EndOfFile > EndOfFirmwareVolume) { - return EFI_NOT_FOUND; - } - - // - // Look for SEC Core - // - if (File->Type != EFI_FV_FILETYPE_SECURITY_CORE) { - continue; - } - - // - // Loop through the FFS file sections within the FFS file - // - EndOfSection = (EFI_PHYSICAL_ADDRESS)(UINTN) (File + 1); - for (;;) { - CurrentAddress = (EndOfSection + 3) & 0xfffffffffffffffcULL; - Section = (EFI_COMMON_SECTION_HEADER*)(UINTN) CurrentAddress; - - Size = *(UINT32*) Section->Size & 0xffffff; - if (Size < sizeof (*Section)) { - return EFI_NOT_FOUND; - } - - EndOfSection = CurrentAddress + Size; - if (EndOfSection > EndOfFile) { - return EFI_NOT_FOUND; - } - - // - // Look for executable sections - // - if (Section->Type == EFI_SECTION_PE32 || Section->Type == EFI_SECTION_TE) { - if (File->Type == EFI_FV_FILETYPE_SECURITY_CORE) { - *SecCoreImageBase = (PHYSICAL_ADDRESS) (UINTN) (Section + 1); - } - break; - } - } - - // - // SEC Core image found - // - if (*SecCoreImageBase != 0) { - return EFI_SUCCESS; - } - } -} - -/* - Find and return Pei Core entry point. - - It also find SEC and PEI Core file debug information. It will report them if - remote debug is enabled. - -**/ -VOID -FindAndReportEntryPoints ( - IN EFI_FIRMWARE_VOLUME_HEADER **BootFirmwareVolumePtr, - OUT EFI_PEI_CORE_ENTRY_POINT *PeiCoreEntryPoint - ) -{ - EFI_STATUS Status; - EFI_PHYSICAL_ADDRESS SecCoreImageBase; - EFI_PHYSICAL_ADDRESS PeiCoreImageBase; - PE_COFF_LOADER_IMAGE_CONTEXT ImageContext; - - // - // Find SEC Core and PEI Core image base - // - Status = FindImageBase (*BootFirmwareVolumePtr, &SecCoreImageBase); - ASSERT_EFI_ERROR (Status); - - FindPeiCoreImageBase (BootFirmwareVolumePtr, &PeiCoreImageBase); - - ZeroMem ((VOID *) &ImageContext, sizeof (PE_COFF_LOADER_IMAGE_CONTEXT)); - // - // Report SEC Core debug information when remote debug is enabled - // - ImageContext.ImageAddress = SecCoreImageBase; - ImageContext.PdbPointer = PeCoffLoaderGetPdbPointer ((VOID*) (UINTN) ImageContext.ImageAddress); - PeCoffLoaderRelocateImageExtraAction (&ImageContext); - - // - // Report PEI Core debug information when remote debug is enabled - // - ImageContext.ImageAddress = (EFI_PHYSICAL_ADDRESS)(UINTN)PeiCoreImageBase; - ImageContext.PdbPointer = PeCoffLoaderGetPdbPointer ((VOID*) (UINTN) ImageContext.ImageAddress); - PeCoffLoaderRelocateImageExtraAction (&ImageContext); - - // - // Find PEI Core entry point - // - Status = PeCoffLoaderGetEntryPoint ((VOID *) (UINTN) PeiCoreImageBase, (VOID**) PeiCoreEntryPoint); - if (EFI_ERROR (Status)) { - *PeiCoreEntryPoint = 0; - } - - return; -} - -VOID -EFIAPI -SecCoreStartupWithStack ( - IN EFI_FIRMWARE_VOLUME_HEADER *BootFv, - IN VOID *TopOfCurrentStack - ) -{ - EFI_SEC_PEI_HAND_OFF SecCoreData; - SEC_IDT_TABLE IdtTableInStack; - IA32_DESCRIPTOR IdtDescriptor; - UINT32 Index; - volatile UINT8 *Table; - - // - // To ensure SMM can't be compromised on S3 resume, we must force re-init of - // the BaseExtractGuidedSectionLib. Since this is before library contructors - // are called, we must use a loop rather than SetMem. - // - Table = (UINT8*)(UINTN)FixedPcdGet64 (PcdGuidedExtractHandlerTableAddress); - for (Index = 0; - Index < FixedPcdGet32 (PcdGuidedExtractHandlerTableSize); - ++Index) { - Table[Index] = 0; - } - - ProcessLibraryConstructorList (NULL, NULL); - - DEBUG ((EFI_D_INFO, - "SecCoreStartupWithStack(0x%x, 0x%x)\n", - (UINT32)(UINTN)BootFv, - (UINT32)(UINTN)TopOfCurrentStack - )); - - // - // Initialize floating point operating environment - // to be compliant with UEFI spec. - // - InitializeFloatingPointUnits (); - - // - // Initialize IDT - // - IdtTableInStack.PeiService = NULL; - for (Index = 0; Index < SEC_IDT_ENTRY_COUNT; Index ++) { - CopyMem (&IdtTableInStack.IdtTable[Index], &mIdtEntryTemplate, sizeof (mIdtEntryTemplate)); - } - - IdtDescriptor.Base = (UINTN)&IdtTableInStack.IdtTable; - IdtDescriptor.Limit = (UINT16)(sizeof (IdtTableInStack.IdtTable) - 1); - - AsmWriteIdtr (&IdtDescriptor); - -#if defined (MDE_CPU_X64) - // - // ASSERT that the Page Tables were set by the reset vector code to - // the address we expect. - // - ASSERT (AsmReadCr3 () == (UINTN) PcdGet32 (PcdOvmfSecPageTablesBase)); -#endif - - // - // |-------------| <-- TopOfCurrentStack - // | Stack | 32k - // |-------------| - // | Heap | 32k - // |-------------| <-- SecCoreData.TemporaryRamBase - // - - ASSERT ((UINTN) (PcdGet32 (PcdOvmfSecPeiTempRamBase) + - PcdGet32 (PcdOvmfSecPeiTempRamSize)) == - (UINTN) TopOfCurrentStack); - - // - // Initialize SEC hand-off state - // - SecCoreData.DataSize = sizeof(EFI_SEC_PEI_HAND_OFF); - - SecCoreData.TemporaryRamSize = (UINTN) PcdGet32 (PcdOvmfSecPeiTempRamSize); - SecCoreData.TemporaryRamBase = (VOID*)((UINT8 *)TopOfCurrentStack - SecCoreData.TemporaryRamSize); - - SecCoreData.PeiTemporaryRamBase = SecCoreData.TemporaryRamBase; - SecCoreData.PeiTemporaryRamSize = SecCoreData.TemporaryRamSize >> 1; - - SecCoreData.StackBase = (UINT8 *)SecCoreData.TemporaryRamBase + SecCoreData.PeiTemporaryRamSize; - SecCoreData.StackSize = SecCoreData.TemporaryRamSize >> 1; - - SecCoreData.BootFirmwareVolumeBase = BootFv; - SecCoreData.BootFirmwareVolumeSize = (UINTN) BootFv->FvLength; - - // - // Make sure the 8259 is masked before initializing the Debug Agent and the debug timer is enabled - // - IoWrite8 (0x21, 0xff); - IoWrite8 (0xA1, 0xff); - - // - // Initialize Local APIC Timer hardware and disable Local APIC Timer - // interrupts before initializing the Debug Agent and the debug timer is - // enabled. - // - InitializeApicTimer (0, MAX_UINT32, TRUE, 5); - DisableApicTimerInterrupt (); - - // - // Initialize Debug Agent to support source level debug in SEC/PEI phases before memory ready. - // - InitializeDebugAgent (DEBUG_AGENT_INIT_PREMEM_SEC, &SecCoreData, SecStartupPhase2); -} - -/** - Caller provided function to be invoked at the end of InitializeDebugAgent(). - - Entry point to the C language phase of SEC. After the SEC assembly - code has initialized some temporary memory and set up the stack, - the control is transferred to this function. - - @param[in] Context The first input parameter of InitializeDebugAgent(). - -**/ -VOID -EFIAPI -SecStartupPhase2( - IN VOID *Context - ) -{ - EFI_SEC_PEI_HAND_OFF *SecCoreData; - EFI_FIRMWARE_VOLUME_HEADER *BootFv; - EFI_PEI_CORE_ENTRY_POINT PeiCoreEntryPoint; - - SecCoreData = (EFI_SEC_PEI_HAND_OFF *) Context; - - // - // Find PEI Core entry point. It will report SEC and Pei Core debug information if remote debug - // is enabled. - // - BootFv = (EFI_FIRMWARE_VOLUME_HEADER *)SecCoreData->BootFirmwareVolumeBase; - FindAndReportEntryPoints (&BootFv, &PeiCoreEntryPoint); - SecCoreData->BootFirmwareVolumeBase = BootFv; - SecCoreData->BootFirmwareVolumeSize = (UINTN) BootFv->FvLength; - - // - // Transfer the control to the PEI core - // - (*PeiCoreEntryPoint) (SecCoreData, (EFI_PEI_PPI_DESCRIPTOR *)&mPrivateDispatchTable); - - // - // If we get here then the PEI Core returned, which is not recoverable. - // - ASSERT (FALSE); - CpuDeadLoop (); -} - -EFI_STATUS -EFIAPI -TemporaryRamMigration ( - IN CONST EFI_PEI_SERVICES **PeiServices, - IN EFI_PHYSICAL_ADDRESS TemporaryMemoryBase, - IN EFI_PHYSICAL_ADDRESS PermanentMemoryBase, - IN UINTN CopySize - ) -{ - IA32_DESCRIPTOR IdtDescriptor; - VOID *OldHeap; - VOID *NewHeap; - VOID *OldStack; - VOID *NewStack; - DEBUG_AGENT_CONTEXT_POSTMEM_SEC DebugAgentContext; - BOOLEAN OldStatus; - BASE_LIBRARY_JUMP_BUFFER JumpBuffer; - - DEBUG ((EFI_D_INFO, - "TemporaryRamMigration(0x%Lx, 0x%Lx, 0x%Lx)\n", - TemporaryMemoryBase, - PermanentMemoryBase, - (UINT64)CopySize - )); - - OldHeap = (VOID*)(UINTN)TemporaryMemoryBase; - NewHeap = (VOID*)((UINTN)PermanentMemoryBase + (CopySize >> 1)); - - OldStack = (VOID*)((UINTN)TemporaryMemoryBase + (CopySize >> 1)); - NewStack = (VOID*)(UINTN)PermanentMemoryBase; - - DebugAgentContext.HeapMigrateOffset = (UINTN)NewHeap - (UINTN)OldHeap; - DebugAgentContext.StackMigrateOffset = (UINTN)NewStack - (UINTN)OldStack; - - OldStatus = SaveAndSetDebugTimerInterrupt (FALSE); - InitializeDebugAgent (DEBUG_AGENT_INIT_POSTMEM_SEC, (VOID *) &DebugAgentContext, NULL); - - // - // Migrate Heap - // - CopyMem (NewHeap, OldHeap, CopySize >> 1); - - // - // Migrate Stack - // - CopyMem (NewStack, OldStack, CopySize >> 1); - - // - // Rebase IDT table in permanent memory - // - AsmReadIdtr (&IdtDescriptor); - IdtDescriptor.Base = IdtDescriptor.Base - (UINTN)OldStack + (UINTN)NewStack; - - AsmWriteIdtr (&IdtDescriptor); - - // - // Use SetJump()/LongJump() to switch to a new stack. - // - if (SetJump (&JumpBuffer) == 0) { -#if defined (MDE_CPU_IA32) - JumpBuffer.Esp = JumpBuffer.Esp + DebugAgentContext.StackMigrateOffset; -#endif -#if defined (MDE_CPU_X64) - JumpBuffer.Rsp = JumpBuffer.Rsp + DebugAgentContext.StackMigrateOffset; -#endif - LongJump (&JumpBuffer, (UINTN)-1); - } - - SaveAndSetDebugTimerInterrupt (OldStatus); - - return EFI_SUCCESS; -} - diff --git a/OvmfPkg/Sec/SecMain.inf b/OvmfPkg/Sec/SecMain.inf deleted file mode 100644 index 711b595309..0000000000 --- a/OvmfPkg/Sec/SecMain.inf +++ /dev/null @@ -1,76 +0,0 @@ -## @file -# SEC Driver -# -# Copyright (c) 2008 - 2015, Intel Corporation. All rights reserved.
-# -# This program and the accompanying materials -# are licensed and made available under the terms and conditions of the BSD License -# which accompanies this distribution. The full text of the license may be found at -# http://opensource.org/licenses/bsd-license.php -# -# THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, -# WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. -# -## - -[Defines] - INF_VERSION = 0x00010005 - BASE_NAME = SecMain - FILE_GUID = df1ccef6-f301-4a63-9661-fc6030dcc880 - MODULE_TYPE = SEC - VERSION_STRING = 1.0 - ENTRY_POINT = SecMain - -# -# The following information is for reference only and not required by the build tools. -# -# VALID_ARCHITECTURES = IA32 X64 IPF EBC -# - -[Sources] - SecMain.c - -[Sources.IA32] - Ia32/SecEntry.nasm - -[Sources.X64] - X64/SecEntry.nasm - -[Packages] - MdePkg/MdePkg.dec - MdeModulePkg/MdeModulePkg.dec - UefiCpuPkg/UefiCpuPkg.dec - OvmfPkg/OvmfPkg.dec - -[LibraryClasses] - BaseLib - DebugLib - BaseMemoryLib - PeiServicesLib - PcdLib - UefiCpuLib - DebugAgentLib - IoLib - PeCoffLib - PeCoffGetEntryPointLib - PeCoffExtraActionLib - ExtractGuidedSectionLib - LocalApicLib - -[Ppis] - gEfiTemporaryRamSupportPpiGuid # PPI ALWAYS_PRODUCED - -[Pcd] - gUefiOvmfPkgTokenSpaceGuid.PcdOvmfPeiMemFvBase - gUefiOvmfPkgTokenSpaceGuid.PcdOvmfPeiMemFvSize - gUefiOvmfPkgTokenSpaceGuid.PcdOvmfDxeMemFvBase - gUefiOvmfPkgTokenSpaceGuid.PcdOvmfDxeMemFvSize - gUefiOvmfPkgTokenSpaceGuid.PcdOvmfSecPageTablesBase - gUefiOvmfPkgTokenSpaceGuid.PcdOvmfSecPeiTempRamBase - gUefiOvmfPkgTokenSpaceGuid.PcdOvmfSecPeiTempRamSize - gEfiMdePkgTokenSpaceGuid.PcdGuidedExtractHandlerTableAddress - gUefiOvmfPkgTokenSpaceGuid.PcdGuidedExtractHandlerTableSize - gUefiOvmfPkgTokenSpaceGuid.PcdOvmfDecompressionScratchEnd - -[FeaturePcd] - gUefiOvmfPkgTokenSpaceGuid.PcdSmmSmramRequire diff --git a/OvmfPkg/Sec/X64/SecEntry.nasm b/OvmfPkg/Sec/X64/SecEntry.nasm deleted file mode 100644 index f40427aa8e..0000000000 --- a/OvmfPkg/Sec/X64/SecEntry.nasm +++ /dev/null @@ -1,56 +0,0 @@ -;------------------------------------------------------------------------------ -;* -;* Copyright (c) 2006 - 2013, Intel Corporation. All rights reserved.
-;* This program and the accompanying materials -;* are licensed and made available under the terms and conditions of the BSD License -;* which accompanies this distribution. The full text of the license may be found at -;* http://opensource.org/licenses/bsd-license.php -;* -;* THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, -;* WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. -;* -;* CpuAsm.asm -;* -;* Abstract: -;* -;------------------------------------------------------------------------------ - -#include - -DEFAULT REL -SECTION .text - -extern ASM_PFX(SecCoreStartupWithStack) - -; -; SecCore Entry Point -; -; Processor is in flat protected mode -; -; @param[in] RAX Initial value of the EAX register (BIST: Built-in Self Test) -; @param[in] DI 'BP': boot-strap processor, or 'AP': application processor -; @param[in] RBP Pointer to the start of the Boot Firmware Volume -; -; @return None This routine does not return -; -global ASM_PFX(_ModuleEntryPoint) -ASM_PFX(_ModuleEntryPoint): - - ; - ; Load temporary RAM stack based on PCDs - ; - %define SEC_TOP_OF_STACK (FixedPcdGet32 (PcdOvmfSecPeiTempRamBase) + \ - FixedPcdGet32 (PcdOvmfSecPeiTempRamSize)) - mov rsp, SEC_TOP_OF_STACK - nop - - ; - ; Setup parameters and call SecCoreStartupWithStack - ; rcx: BootFirmwareVolumePtr - ; rdx: TopOfCurrentStack - ; - mov rcx, rbp - mov rdx, rsp - sub rsp, 0x20 - call ASM_PFX(SecCoreStartupWithStack) - diff --git a/OvmfPkg/SmbiosPlatformDxe/ArmXen.c b/OvmfPkg/SmbiosPlatformDxe/ArmXen.c deleted file mode 100644 index 538cbc26f0..0000000000 --- a/OvmfPkg/SmbiosPlatformDxe/ArmXen.c +++ /dev/null @@ -1,34 +0,0 @@ -/** @file - Detect Xen SMBIOS data on ARM / AARCH64. - - Copyright (C) 2015, Red Hat, Inc. - Copyright (c) 2011, Bei Guan - Copyright (c) 2011, Intel Corporation. All rights reserved.
- - This program and the accompanying materials are licensed and made available - under the terms and conditions of the BSD License which accompanies this - distribution. The full text of the license may be found at - http://opensource.org/licenses/bsd-license.php - - THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, WITHOUT - WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. -**/ - -#include "SmbiosPlatformDxe.h" - -/** - Locates the Xen SMBIOS data if it exists - - @return SMBIOS_TABLE_ENTRY_POINT Address of Xen SMBIOS data - -**/ -SMBIOS_TABLE_ENTRY_POINT * -GetXenSmbiosTables ( - VOID - ) -{ - // - // Not implemented yet. - // - return NULL; -} diff --git a/OvmfPkg/SmbiosPlatformDxe/Qemu.c b/OvmfPkg/SmbiosPlatformDxe/Qemu.c deleted file mode 100644 index 9466b950fc..0000000000 --- a/OvmfPkg/SmbiosPlatformDxe/Qemu.c +++ /dev/null @@ -1,54 +0,0 @@ -/** @file - Find and extract QEMU SMBIOS data from fw_cfg. - - Copyright (C) 2014, Gabriel L. Somlo - - This program and the accompanying materials are licensed and made - 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 "SmbiosPlatformDxe.h" -#include -#include -#include - -/** - Locates and extracts the QEMU SMBIOS data if present in fw_cfg - - @return Address of extracted QEMU SMBIOS data - -**/ -UINT8 * -GetQemuSmbiosTables ( - VOID - ) -{ - EFI_STATUS Status; - FIRMWARE_CONFIG_ITEM Tables; - UINTN TablesSize; - UINT8 *QemuTables; - - if (!PcdGetBool (PcdQemuSmbiosValidated)) { - return NULL; - } - - Status = QemuFwCfgFindFile ("etc/smbios/smbios-tables", &Tables, - &TablesSize); - ASSERT_EFI_ERROR (Status); - ASSERT (TablesSize > 0); - - QemuTables = AllocatePool (TablesSize); - if (QemuTables == NULL) { - return NULL; - } - - QemuFwCfgSelectItem (Tables); - QemuFwCfgReadBytes (TablesSize, QemuTables); - - return QemuTables; -} diff --git a/OvmfPkg/SmbiosPlatformDxe/SmbiosPlatformDxe.c b/OvmfPkg/SmbiosPlatformDxe/SmbiosPlatformDxe.c deleted file mode 100644 index 29948a4b42..0000000000 --- a/OvmfPkg/SmbiosPlatformDxe/SmbiosPlatformDxe.c +++ /dev/null @@ -1,217 +0,0 @@ -/** @file - This driver installs SMBIOS information for OVMF - - Copyright (c) 2011, Bei Guan - Copyright (c) 2011 - 2015, Intel Corporation. All rights reserved.
- - This program and the accompanying materials - are licensed and made available under the terms and conditions of the BSD License - which accompanies this distribution. The full text of the license may be found at - http://opensource.org/licenses/bsd-license.php - - THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, - WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. - -**/ - -#include "SmbiosPlatformDxe.h" - -#define TYPE0_STRINGS \ - "EFI Development Kit II / OVMF\0" /* Vendor */ \ - "0.0.0\0" /* BiosVersion */ \ - "02/06/2015\0" /* BiosReleaseDate */ -// -// Type definition and contents of the default Type 0 SMBIOS table. -// -#pragma pack(1) -typedef struct { - SMBIOS_TABLE_TYPE0 Base; - UINT8 Strings[sizeof(TYPE0_STRINGS)]; -} OVMF_TYPE0; -#pragma pack() - -STATIC CONST OVMF_TYPE0 mOvmfDefaultType0 = { - { - // SMBIOS_STRUCTURE Hdr - { - EFI_SMBIOS_TYPE_BIOS_INFORMATION, // UINT8 Type - sizeof (SMBIOS_TABLE_TYPE0), // UINT8 Length - }, - 1, // SMBIOS_TABLE_STRING Vendor - 2, // SMBIOS_TABLE_STRING BiosVersion - 0xE800,// UINT16 BiosSegment - 3, // SMBIOS_TABLE_STRING BiosReleaseDate - 0, // UINT8 BiosSize - { // MISC_BIOS_CHARACTERISTICS BiosCharacteristics - 0, // Reserved :2 - 0, // Unknown :1 - 1, // BiosCharacteristicsNotSupported :1 - // Remaining BiosCharacteristics bits left unset :60 - }, - { // BIOSCharacteristicsExtensionBytes[2] - 0, // BiosReserved - 0x1C // SystemReserved = VirtualMachineSupported | - // UefiSpecificationSupported | - // TargetContentDistributionEnabled - }, - 0, // UINT8 SystemBiosMajorRelease - 0, // UINT8 SystemBiosMinorRelease - 0xFF, // UINT8 EmbeddedControllerFirmwareMajorRelease - 0xFF // UINT8 EmbeddedControllerFirmwareMinorRelease - }, - // Text strings (unformatted area) - TYPE0_STRINGS -}; - - -/** - Get SMBIOS record length. - - @param SmbiosTable SMBIOS pointer. - -**/ -UINTN -SmbiosTableLength ( - IN SMBIOS_STRUCTURE_POINTER SmbiosTable - ) -{ - CHAR8 *AChar; - UINTN Length; - - AChar = (CHAR8 *)(SmbiosTable.Raw + SmbiosTable.Hdr->Length); - - // - // Each structure shall be terminated by a double-null (SMBIOS spec.7.1) - // - while ((*AChar != 0) || (*(AChar + 1) != 0)) { - AChar ++; - } - Length = ((UINTN)AChar - (UINTN)SmbiosTable.Raw + 2); - - return Length; -} - - -/** - Install all structures from the given SMBIOS structures block - - @param Smbios SMBIOS protocol - @param TableAddress SMBIOS tables starting address - -**/ -EFI_STATUS -InstallAllStructures ( - IN EFI_SMBIOS_PROTOCOL *Smbios, - IN UINT8 *TableAddress - ) -{ - EFI_STATUS Status; - SMBIOS_STRUCTURE_POINTER SmbiosTable; - EFI_SMBIOS_HANDLE SmbiosHandle; - BOOLEAN NeedSmbiosType0; - - SmbiosTable.Raw = TableAddress; - if (SmbiosTable.Raw == NULL) { - return EFI_INVALID_PARAMETER; - } - - NeedSmbiosType0 = TRUE; - - while (SmbiosTable.Hdr->Type != 127) { - // - // Log the SMBIOS data for this structure - // - SmbiosHandle = SmbiosTable.Hdr->Handle; - Status = Smbios->Add ( - Smbios, - NULL, - &SmbiosHandle, - (EFI_SMBIOS_TABLE_HEADER*) SmbiosTable.Raw - ); - ASSERT_EFI_ERROR (Status); - - if (SmbiosTable.Hdr->Type == 0) { - NeedSmbiosType0 = FALSE; - } - - // - // Get the next structure address - // - SmbiosTable.Raw = (UINT8 *)(SmbiosTable.Raw + SmbiosTableLength (SmbiosTable)); - } - - if (NeedSmbiosType0) { - // - // Add OVMF default Type 0 (BIOS Information) table - // - SmbiosHandle = SMBIOS_HANDLE_PI_RESERVED; - Status = Smbios->Add ( - Smbios, - NULL, - &SmbiosHandle, - (EFI_SMBIOS_TABLE_HEADER*) &mOvmfDefaultType0 - ); - ASSERT_EFI_ERROR (Status); - } - - return EFI_SUCCESS; -} - - -/** - Installs SMBIOS information for OVMF - - @param ImageHandle Module's image handle - @param SystemTable Pointer of EFI_SYSTEM_TABLE - - @retval EFI_SUCCESS Smbios data successfully installed - @retval Other Smbios data was not installed - -**/ -EFI_STATUS -EFIAPI -SmbiosTablePublishEntry ( - IN EFI_HANDLE ImageHandle, - IN EFI_SYSTEM_TABLE *SystemTable - ) -{ - EFI_STATUS Status; - EFI_SMBIOS_PROTOCOL *Smbios; - SMBIOS_TABLE_ENTRY_POINT *EntryPointStructure; - UINT8 *SmbiosTables; - - // - // Find the SMBIOS protocol - // - Status = gBS->LocateProtocol ( - &gEfiSmbiosProtocolGuid, - NULL, - (VOID**)&Smbios - ); - if (EFI_ERROR (Status)) { - return Status; - } - - // - // Add Xen or QEMU SMBIOS data if found - // - EntryPointStructure = GetXenSmbiosTables (); - if (EntryPointStructure != NULL) { - SmbiosTables = (UINT8*)(UINTN)EntryPointStructure->TableAddress; - } else { - SmbiosTables = GetQemuSmbiosTables (); - } - - if (SmbiosTables != NULL) { - Status = InstallAllStructures (Smbios, SmbiosTables); - - // - // Free SmbiosTables if allocated by Qemu (i.e., NOT by Xen): - // - if (EntryPointStructure == NULL) { - FreePool (SmbiosTables); - } - } - - return Status; -} diff --git a/OvmfPkg/SmbiosPlatformDxe/SmbiosPlatformDxe.h b/OvmfPkg/SmbiosPlatformDxe/SmbiosPlatformDxe.h deleted file mode 100644 index 6210a56f75..0000000000 --- a/OvmfPkg/SmbiosPlatformDxe/SmbiosPlatformDxe.h +++ /dev/null @@ -1,54 +0,0 @@ -/** @file - This driver installs SMBIOS information for OVMF - - Copyright (c) 2011, Bei Guan - Copyright (c) 2011, Intel Corporation. All rights reserved.
- - This program and the accompanying materials - are licensed and made available under the terms and conditions of the BSD License - which accompanies this distribution. The full text of the license may be found at - http://opensource.org/licenses/bsd-license.php - - THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, - WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. - -**/ - -#ifndef _SMBIOS_PLATFORM_DXE_H_ -#define _SMBIOS_PLATFORM_DXE_H_ - -#include - -#include -#include -#include -#include -#include -#include -#include - - -/** - Locates the Xen SMBIOS data if it exists - - @return SMBIOS_TABLE_ENTRY_POINT Address of Xen SMBIOS data - -**/ -SMBIOS_TABLE_ENTRY_POINT * -GetXenSmbiosTables ( - VOID - ); - - -/** - Locates and extracts the QEMU SMBIOS table data if present in fw_cfg - - @return Address of extracted QEMU SMBIOS data - -**/ -UINT8 * -GetQemuSmbiosTables ( - VOID - ); - -#endif diff --git a/OvmfPkg/SmbiosPlatformDxe/SmbiosPlatformDxe.inf b/OvmfPkg/SmbiosPlatformDxe/SmbiosPlatformDxe.inf deleted file mode 100644 index 91815ecd6f..0000000000 --- a/OvmfPkg/SmbiosPlatformDxe/SmbiosPlatformDxe.inf +++ /dev/null @@ -1,69 +0,0 @@ -## @file -# This driver installs SMBIOS information for OVMF -# -# Copyright (c) 2011, Bei Guan -# Copyright (c) 2011, Intel Corporation. All rights reserved.
-# -# This program and the accompanying materials -# are licensed and made available under the terms and conditions of the BSD License -# which accompanies this distribution. The full text of the license may be found at -# http://opensource.org/licenses/bsd-license.php -# THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, -# WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. -# -## - -[Defines] - INF_VERSION = 0x00010005 - BASE_NAME = SmbiosPlatformDxe - FILE_GUID = 4110465d-5ff3-4f4b-b580-24ed0d06747a - MODULE_TYPE = DXE_DRIVER - VERSION_STRING = 1.0 - - ENTRY_POINT = SmbiosTablePublishEntry - -# -# The following information is for reference only and not required by the build tools. -# -# VALID_ARCHITECTURES = IA32 X64 IPF EBC ARM AARCH64 -# - -[Sources] - SmbiosPlatformDxe.h - SmbiosPlatformDxe.c - Qemu.c - -[Sources.IA32, Sources.X64] - X86Xen.c - -[Sources.ARM, Sources.AARCH64] - ArmXen.c - -[Packages] - MdePkg/MdePkg.dec - MdeModulePkg/MdeModulePkg.dec - OvmfPkg/OvmfPkg.dec - -[LibraryClasses] - UefiBootServicesTableLib - BaseMemoryLib - BaseLib - UefiDriverEntryPoint - DebugLib - HobLib - QemuFwCfgLib - MemoryAllocationLib - PcdLib - -[Pcd] - gUefiOvmfPkgTokenSpaceGuid.PcdQemuSmbiosValidated - -[Protocols] - gEfiSmbiosProtocolGuid # PROTOCOL ALWAYS_CONSUMED - -[Guids] - gEfiXenInfoGuid - -[Depex] - gEfiSmbiosProtocolGuid - diff --git a/OvmfPkg/SmbiosPlatformDxe/X86Xen.c b/OvmfPkg/SmbiosPlatformDxe/X86Xen.c deleted file mode 100644 index 3d2abcea7c..0000000000 --- a/OvmfPkg/SmbiosPlatformDxe/X86Xen.c +++ /dev/null @@ -1,98 +0,0 @@ -/** @file - Detect Xen hvmloader SMBIOS data for usage by OVMF. - - Copyright (c) 2011, Bei Guan - Copyright (c) 2011, Intel Corporation. All rights reserved.
- - This program and the accompanying materials - are licensed and made available under the terms and conditions of the BSD License - which accompanies this distribution. The full text of the license may be found at - http://opensource.org/licenses/bsd-license.php - - THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, - WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. - -**/ - -#include "SmbiosPlatformDxe.h" -#include -#include - -#define XEN_SMBIOS_PHYSICAL_ADDRESS 0x000EB000 -#define XEN_SMBIOS_PHYSICAL_END 0x000F0000 - -/** - Validates the SMBIOS entry point structure - - @param EntryPointStructure SMBIOS entry point structure - - @retval TRUE The entry point structure is valid - @retval FALSE The entry point structure is not valid - -**/ -STATIC -BOOLEAN -IsEntryPointStructureValid ( - IN SMBIOS_TABLE_ENTRY_POINT *EntryPointStructure - ) -{ - UINTN Index; - UINT8 Length; - UINT8 Checksum; - UINT8 *BytePtr; - - BytePtr = (UINT8*) EntryPointStructure; - Length = EntryPointStructure->EntryPointLength; - Checksum = 0; - - for (Index = 0; Index < Length; Index++) { - Checksum = Checksum + (UINT8) BytePtr[Index]; - } - - if (Checksum != 0) { - return FALSE; - } else { - return TRUE; - } -} - -/** - Locates the Xen SMBIOS data if it exists - - @return SMBIOS_TABLE_ENTRY_POINT Address of Xen SMBIOS data - -**/ -SMBIOS_TABLE_ENTRY_POINT * -GetXenSmbiosTables ( - VOID - ) -{ - UINT8 *XenSmbiosPtr; - SMBIOS_TABLE_ENTRY_POINT *XenSmbiosEntryPointStructure; - EFI_HOB_GUID_TYPE *GuidHob; - - // - // See if a XenInfo HOB is available - // - GuidHob = GetFirstGuidHob (&gEfiXenInfoGuid); - if (GuidHob == NULL) { - return NULL; - } - - for (XenSmbiosPtr = (UINT8*)(UINTN) XEN_SMBIOS_PHYSICAL_ADDRESS; - XenSmbiosPtr < (UINT8*)(UINTN) XEN_SMBIOS_PHYSICAL_END; - XenSmbiosPtr += 0x10) { - - XenSmbiosEntryPointStructure = (SMBIOS_TABLE_ENTRY_POINT *) XenSmbiosPtr; - - if (!AsciiStrnCmp ((CHAR8 *) XenSmbiosEntryPointStructure->AnchorString, "_SM_", 4) && - !AsciiStrnCmp ((CHAR8 *) XenSmbiosEntryPointStructure->IntermediateAnchorString, "_DMI_", 5) && - IsEntryPointStructureValid (XenSmbiosEntryPointStructure)) { - - return XenSmbiosEntryPointStructure; - - } - } - - return NULL; -} diff --git a/OvmfPkg/SmmAccess/SmmAccess2Dxe.c b/OvmfPkg/SmmAccess/SmmAccess2Dxe.c deleted file mode 100644 index d5130399b0..0000000000 --- a/OvmfPkg/SmmAccess/SmmAccess2Dxe.c +++ /dev/null @@ -1,156 +0,0 @@ -/** @file - - A DXE_DRIVER providing SMRAM access by producing EFI_SMM_ACCESS2_PROTOCOL. - - Q35 TSEG is expected to have been verified and set up by the SmmAccessPei - driver. - - Copyright (C) 2013, 2015, Red Hat, Inc.
- Copyright (c) 2009 - 2010, Intel Corporation. All rights reserved.
- - This program and the accompanying materials are licensed and made available - under the terms and conditions of the BSD License which accompanies this - distribution. The full text of the license may be found at - http://opensource.org/licenses/bsd-license.php - - THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, WITHOUT - WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. - -**/ - -#include -#include -#include -#include - -#include "SmramInternal.h" - -/** - Opens the SMRAM area to be accessible by a boot-service driver. - - This function "opens" SMRAM so that it is visible while not inside of SMM. - The function should return EFI_UNSUPPORTED if the hardware does not support - hiding of SMRAM. The function should return EFI_DEVICE_ERROR if the SMRAM - configuration is locked. - - @param[in] This The EFI_SMM_ACCESS2_PROTOCOL instance. - - @retval EFI_SUCCESS The operation was successful. - @retval EFI_UNSUPPORTED The system does not support opening and closing of - SMRAM. - @retval EFI_DEVICE_ERROR SMRAM cannot be opened, perhaps because it is - locked. -**/ -STATIC -EFI_STATUS -EFIAPI -SmmAccess2DxeOpen ( - IN EFI_SMM_ACCESS2_PROTOCOL *This - ) -{ - return SmramAccessOpen (&This->LockState, &This->OpenState); -} - -/** - Inhibits access to the SMRAM. - - This function "closes" SMRAM so that it is not visible while outside of SMM. - The function should return EFI_UNSUPPORTED if the hardware does not support - hiding of SMRAM. - - @param[in] This The EFI_SMM_ACCESS2_PROTOCOL instance. - - @retval EFI_SUCCESS The operation was successful. - @retval EFI_UNSUPPORTED The system does not support opening and closing of - SMRAM. - @retval EFI_DEVICE_ERROR SMRAM cannot be closed. -**/ -STATIC -EFI_STATUS -EFIAPI -SmmAccess2DxeClose ( - IN EFI_SMM_ACCESS2_PROTOCOL *This - ) -{ - return SmramAccessClose (&This->LockState, &This->OpenState); -} - -/** - Inhibits access to the SMRAM. - - This function prohibits access to the SMRAM region. This function is usually - implemented such that it is a write-once operation. - - @param[in] This The EFI_SMM_ACCESS2_PROTOCOL instance. - - @retval EFI_SUCCESS The device was successfully locked. - @retval EFI_UNSUPPORTED The system does not support locking of SMRAM. -**/ -STATIC -EFI_STATUS -EFIAPI -SmmAccess2DxeLock ( - IN EFI_SMM_ACCESS2_PROTOCOL *This - ) -{ - return SmramAccessLock (&This->LockState, &This->OpenState); -} - -/** - Queries the memory controller for the possible regions that will support - SMRAM. - - @param[in] This The EFI_SMM_ACCESS2_PROTOCOL instance. - @param[in,out] SmramMapSize A pointer to the size, in bytes, of the - SmramMemoryMap buffer. - @param[in,out] SmramMap A pointer to the buffer in which firmware - places the current memory map. - - @retval EFI_SUCCESS The chipset supported the given resource. - @retval EFI_BUFFER_TOO_SMALL The SmramMap parameter was too small. The - current buffer size needed to hold the memory - map is returned in SmramMapSize. -**/ -STATIC -EFI_STATUS -EFIAPI -SmmAccess2DxeGetCapabilities ( - IN CONST EFI_SMM_ACCESS2_PROTOCOL *This, - IN OUT UINTN *SmramMapSize, - IN OUT EFI_SMRAM_DESCRIPTOR *SmramMap - ) -{ - return SmramAccessGetCapabilities (This->LockState, This->OpenState, - SmramMapSize, SmramMap); -} - -// -// LockState and OpenState will be filled in by the entry point. -// -STATIC EFI_SMM_ACCESS2_PROTOCOL mAccess2 = { - &SmmAccess2DxeOpen, - &SmmAccess2DxeClose, - &SmmAccess2DxeLock, - &SmmAccess2DxeGetCapabilities -}; - -// -// Entry point of this driver. -// -EFI_STATUS -EFIAPI -SmmAccess2DxeEntryPoint ( - IN EFI_HANDLE ImageHandle, - IN EFI_SYSTEM_TABLE *SystemTable - ) -{ - // - // This module should only be included if SMRAM support is required. - // - ASSERT (FeaturePcdGet (PcdSmmSmramRequire)); - - GetStates (&mAccess2.LockState, &mAccess2.OpenState); - return gBS->InstallMultipleProtocolInterfaces (&ImageHandle, - &gEfiSmmAccess2ProtocolGuid, &mAccess2, - NULL); -} diff --git a/OvmfPkg/SmmAccess/SmmAccess2Dxe.inf b/OvmfPkg/SmmAccess/SmmAccess2Dxe.inf deleted file mode 100644 index 31e4dfa029..0000000000 --- a/OvmfPkg/SmmAccess/SmmAccess2Dxe.inf +++ /dev/null @@ -1,58 +0,0 @@ -## @file -# A DXE_DRIVER providing SMRAM access by producing EFI_SMM_ACCESS2_PROTOCOL. -# -# Q35 TSEG is expected to have been verified and set up by the SmmAccessPei -# driver. -# -# Copyright (C) 2013, 2015, 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 = SmmAccess2Dxe - FILE_GUID = AC95AD3D-4366-44BF-9A62-E4B29D7A2206 - MODULE_TYPE = DXE_DRIVER - VERSION_STRING = 1.0 - PI_SPECIFICATION_VERSION = 0x00010400 - ENTRY_POINT = SmmAccess2DxeEntryPoint - -# -# The following information is for reference only and not required by the build tools. -# -# VALID_ARCHITECTURES = IA32 X64 -# - -[Sources] - SmmAccess2Dxe.c - SmramInternal.c - SmramInternal.h - -[Packages] - MdeModulePkg/MdeModulePkg.dec - MdePkg/MdePkg.dec - OvmfPkg/OvmfPkg.dec - -[LibraryClasses] - DebugLib - PcdLib - PciLib - UefiBootServicesTableLib - UefiDriverEntryPoint - -[Protocols] - gEfiSmmAccess2ProtocolGuid ## PRODUCES - -[FeaturePcd] - gUefiOvmfPkgTokenSpaceGuid.PcdSmmSmramRequire - -[Depex] - TRUE diff --git a/OvmfPkg/SmmAccess/SmmAccessPei.c b/OvmfPkg/SmmAccess/SmmAccessPei.c deleted file mode 100644 index a4ce610a46..0000000000 --- a/OvmfPkg/SmmAccess/SmmAccessPei.c +++ /dev/null @@ -1,393 +0,0 @@ -/** @file - - A PEIM with the following responsibilities: - - - verify & configure the Q35 TSEG in the entry point, - - provide SMRAM access by producing PEI_SMM_ACCESS_PPI, - - set aside the SMM_S3_RESUME_STATE object at the bottom of TSEG, and expose - it via the gEfiAcpiVariableGuid GUID HOB. - - This PEIM runs from RAM, so we can write to variables with static storage - duration. - - Copyright (C) 2013, 2015, Red Hat, Inc.
- Copyright (c) 2010, Intel Corporation. All rights reserved.
- - This program and the accompanying materials are licensed and made available - under the terms and conditions of the BSD License which accompanies this - distribution. The full text of the license may be found at - http://opensource.org/licenses/bsd-license.php - - THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, WITHOUT - WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. - -**/ - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#include - -#include "SmramInternal.h" - -// -// PEI_SMM_ACCESS_PPI implementation. -// - -/** - Opens the SMRAM area to be accessible by a PEIM driver. - - This function "opens" SMRAM so that it is visible while not inside of SMM. - The function should return EFI_UNSUPPORTED if the hardware does not support - hiding of SMRAM. The function should return EFI_DEVICE_ERROR if the SMRAM - configuration is locked. - - @param PeiServices General purpose services available to every - PEIM. - @param This The pointer to the SMM Access Interface. - @param DescriptorIndex The region of SMRAM to Open. - - @retval EFI_SUCCESS The region was successfully opened. - @retval EFI_DEVICE_ERROR The region could not be opened because locked - by chipset. - @retval EFI_INVALID_PARAMETER The descriptor index was out of bounds. - -**/ -STATIC -EFI_STATUS -EFIAPI -SmmAccessPeiOpen ( - IN EFI_PEI_SERVICES **PeiServices, - IN PEI_SMM_ACCESS_PPI *This, - IN UINTN DescriptorIndex - ) -{ - if (DescriptorIndex >= DescIdxCount) { - return EFI_INVALID_PARAMETER; - } - - // - // According to current practice, DescriptorIndex is not considered at all, - // beyond validating it. - // - return SmramAccessOpen (&This->LockState, &This->OpenState); -} - -/** - Inhibits access to the SMRAM. - - This function "closes" SMRAM so that it is not visible while outside of SMM. - The function should return EFI_UNSUPPORTED if the hardware does not support - hiding of SMRAM. - - @param PeiServices General purpose services available to every - PEIM. - @param This The pointer to the SMM Access Interface. - @param DescriptorIndex The region of SMRAM to Close. - - @retval EFI_SUCCESS The region was successfully closed. - @retval EFI_DEVICE_ERROR The region could not be closed because - locked by chipset. - @retval EFI_INVALID_PARAMETER The descriptor index was out of bounds. - -**/ -STATIC -EFI_STATUS -EFIAPI -SmmAccessPeiClose ( - IN EFI_PEI_SERVICES **PeiServices, - IN PEI_SMM_ACCESS_PPI *This, - IN UINTN DescriptorIndex - ) -{ - if (DescriptorIndex >= DescIdxCount) { - return EFI_INVALID_PARAMETER; - } - - // - // According to current practice, DescriptorIndex is not considered at all, - // beyond validating it. - // - return SmramAccessClose (&This->LockState, &This->OpenState); -} - -/** - Inhibits access to the SMRAM. - - This function prohibits access to the SMRAM region. This function is usually - implemented such that it is a write-once operation. - - @param PeiServices General purpose services available to every - PEIM. - @param This The pointer to the SMM Access Interface. - @param DescriptorIndex The region of SMRAM to Close. - - @retval EFI_SUCCESS The region was successfully locked. - @retval EFI_DEVICE_ERROR The region could not be locked because at - least one range is still open. - @retval EFI_INVALID_PARAMETER The descriptor index was out of bounds. - -**/ -STATIC -EFI_STATUS -EFIAPI -SmmAccessPeiLock ( - IN EFI_PEI_SERVICES **PeiServices, - IN PEI_SMM_ACCESS_PPI *This, - IN UINTN DescriptorIndex - ) -{ - if (DescriptorIndex >= DescIdxCount) { - return EFI_INVALID_PARAMETER; - } - - // - // According to current practice, DescriptorIndex is not considered at all, - // beyond validating it. - // - return SmramAccessLock (&This->LockState, &This->OpenState); -} - -/** - Queries the memory controller for the possible regions that will support - SMRAM. - - @param PeiServices General purpose services available to every - PEIM. - @param This The pointer to the SmmAccessPpi Interface. - @param SmramMapSize The pointer to the variable containing size of - the buffer to contain the description - information. - @param SmramMap The buffer containing the data describing the - Smram region descriptors. - - @retval EFI_BUFFER_TOO_SMALL The user did not provide a sufficient buffer. - @retval EFI_SUCCESS The user provided a sufficiently-sized buffer. - -**/ -STATIC -EFI_STATUS -EFIAPI -SmmAccessPeiGetCapabilities ( - IN EFI_PEI_SERVICES **PeiServices, - IN PEI_SMM_ACCESS_PPI *This, - IN OUT UINTN *SmramMapSize, - IN OUT EFI_SMRAM_DESCRIPTOR *SmramMap - ) -{ - return SmramAccessGetCapabilities (This->LockState, This->OpenState, - SmramMapSize, SmramMap); -} - -// -// LockState and OpenState will be filled in by the entry point. -// -STATIC PEI_SMM_ACCESS_PPI mAccess = { - &SmmAccessPeiOpen, - &SmmAccessPeiClose, - &SmmAccessPeiLock, - &SmmAccessPeiGetCapabilities -}; - - -STATIC EFI_PEI_PPI_DESCRIPTOR mPpiList[] = { - { - EFI_PEI_PPI_DESCRIPTOR_PPI | EFI_PEI_PPI_DESCRIPTOR_TERMINATE_LIST, - &gPeiSmmAccessPpiGuid, &mAccess - } -}; - - -// -// Utility functions. -// -STATIC -UINT8 -CmosRead8 ( - IN UINT8 Index - ) -{ - IoWrite8 (0x70, Index); - return IoRead8 (0x71); -} - -STATIC -UINT32 -GetSystemMemorySizeBelow4gb ( - VOID - ) -{ - UINT32 Cmos0x34; - UINT32 Cmos0x35; - - Cmos0x34 = CmosRead8 (0x34); - Cmos0x35 = CmosRead8 (0x35); - - return ((Cmos0x35 << 8 | Cmos0x34) << 16) + SIZE_16MB; -} - - -// -// Entry point of this driver. -// -EFI_STATUS -EFIAPI -SmmAccessPeiEntryPoint ( - IN EFI_PEI_FILE_HANDLE FileHandle, - IN CONST EFI_PEI_SERVICES **PeiServices - ) -{ - UINT16 HostBridgeDevId; - UINT8 EsmramcVal; - UINT8 RegMask8; - UINT32 TopOfLowRam, TopOfLowRamMb; - EFI_STATUS Status; - UINTN SmramMapSize; - EFI_SMRAM_DESCRIPTOR SmramMap[DescIdxCount]; - VOID *GuidHob; - - // - // This module should only be included if SMRAM support is required. - // - ASSERT (FeaturePcdGet (PcdSmmSmramRequire)); - - // - // Verify if we're running on a Q35 machine type. - // - HostBridgeDevId = PciRead16 (OVMF_HOSTBRIDGE_DID); - if (HostBridgeDevId != INTEL_Q35_MCH_DEVICE_ID) { - DEBUG ((EFI_D_ERROR, "%a: no SMRAM with host bridge DID=0x%04x; only " - "DID=0x%04x (Q35) is supported\n", __FUNCTION__, HostBridgeDevId, - INTEL_Q35_MCH_DEVICE_ID)); - goto WrongConfig; - } - - // - // Confirm if QEMU supports SMRAM. - // - // With no support for it, the ESMRAMC (Extended System Management RAM - // Control) register reads as zero. If there is support, the cache-enable - // bits are hard-coded as 1 by QEMU. - // - EsmramcVal = PciRead8 (DRAMC_REGISTER_Q35 (MCH_ESMRAMC)); - RegMask8 = MCH_ESMRAMC_SM_CACHE | MCH_ESMRAMC_SM_L1 | MCH_ESMRAMC_SM_L2; - if ((EsmramcVal & RegMask8) != RegMask8) { - DEBUG ((EFI_D_ERROR, "%a: this Q35 implementation lacks SMRAM\n", - __FUNCTION__)); - goto WrongConfig; - } - - TopOfLowRam = GetSystemMemorySizeBelow4gb (); - ASSERT ((TopOfLowRam & (SIZE_1MB - 1)) == 0); - TopOfLowRamMb = TopOfLowRam >> 20; - - // - // Some of the following registers are no-ops for QEMU at the moment, but it - // is recommended to set them correctly, since the ESMRAMC that we ultimately - // care about is in the same set of registers. - // - // First, we disable the integrated VGA, and set both the GTT Graphics Memory - // Size and the Graphics Mode Select memory pre-allocation fields to zero. - // This takes just one write to the Graphics Control Register. - // - PciWrite16 (DRAMC_REGISTER_Q35 (MCH_GGC), MCH_GGC_IVD); - - // - // Set Top of Low Usable DRAM. - // - PciWrite16 (DRAMC_REGISTER_Q35 (MCH_TOLUD), - (UINT16)(TopOfLowRamMb << MCH_TOLUD_MB_SHIFT)); - - // - // Given the zero graphics memory sizes configured above, set the - // graphics-related stolen memory bases to the same as TOLUD. - // - PciWrite32 (DRAMC_REGISTER_Q35 (MCH_GBSM), - TopOfLowRamMb << MCH_GBSM_MB_SHIFT); - PciWrite32 (DRAMC_REGISTER_Q35 (MCH_BGSM), - TopOfLowRamMb << MCH_BGSM_MB_SHIFT); - - // - // Set TSEG Memory Base. - // - PciWrite32 (DRAMC_REGISTER_Q35 (MCH_TSEGMB), - (TopOfLowRamMb - FixedPcdGet8 (PcdQ35TsegMbytes)) << MCH_TSEGMB_MB_SHIFT); - - // - // Set TSEG size, and disable TSEG visibility outside of SMM. Note that the - // T_EN bit has inverse meaning; when T_EN is set, then TSEG visibility is - // *restricted* to SMM. - // - EsmramcVal &= ~(UINT32)MCH_ESMRAMC_TSEG_MASK; - EsmramcVal |= FixedPcdGet8 (PcdQ35TsegMbytes) == 8 ? MCH_ESMRAMC_TSEG_8MB : - FixedPcdGet8 (PcdQ35TsegMbytes) == 2 ? MCH_ESMRAMC_TSEG_2MB : - MCH_ESMRAMC_TSEG_1MB; - EsmramcVal |= MCH_ESMRAMC_T_EN; - PciWrite8 (DRAMC_REGISTER_Q35 (MCH_ESMRAMC), EsmramcVal); - - // - // TSEG should be closed (see above), but unlocked, initially. Set G_SMRAME - // (Global SMRAM Enable) too, as both D_LCK and T_EN depend on it. - // - PciAndThenOr8 (DRAMC_REGISTER_Q35 (MCH_SMRAM), - (UINT8)((~(UINT32)MCH_SMRAM_D_LCK) & 0xff), MCH_SMRAM_G_SMRAME); - - // - // Create the GUID HOB and point it to the first SMRAM range. - // - GetStates (&mAccess.LockState, &mAccess.OpenState); - SmramMapSize = sizeof SmramMap; - Status = SmramAccessGetCapabilities (mAccess.LockState, mAccess.OpenState, - &SmramMapSize, SmramMap); - ASSERT_EFI_ERROR (Status); - - DEBUG_CODE_BEGIN (); - { - UINTN Count; - UINTN Idx; - - Count = SmramMapSize / sizeof SmramMap[0]; - DEBUG ((EFI_D_VERBOSE, "%a: SMRAM map follows, %d entries\n", __FUNCTION__, - (INT32)Count)); - DEBUG ((EFI_D_VERBOSE, "% 20a % 20a % 20a % 20a\n", "PhysicalStart(0x)", - "PhysicalSize(0x)", "CpuStart(0x)", "RegionState(0x)")); - for (Idx = 0; Idx < Count; ++Idx) { - DEBUG ((EFI_D_VERBOSE, "% 20Lx % 20Lx % 20Lx % 20Lx\n", - SmramMap[Idx].PhysicalStart, SmramMap[Idx].PhysicalSize, - SmramMap[Idx].CpuStart, SmramMap[Idx].RegionState)); - } - } - DEBUG_CODE_END (); - - GuidHob = BuildGuidHob (&gEfiAcpiVariableGuid, - sizeof SmramMap[DescIdxSmmS3ResumeState]); - if (GuidHob == NULL) { - return EFI_OUT_OF_RESOURCES; - } - - CopyMem (GuidHob, &SmramMap[DescIdxSmmS3ResumeState], - sizeof SmramMap[DescIdxSmmS3ResumeState]); - - // - // We're done. The next step should succeed, but even if it fails, we can't - // roll back the above BuildGuidHob() allocation, because PEI doesn't support - // releasing memory. - // - return PeiServicesInstallPpi (mPpiList); - -WrongConfig: - // - // We really don't want to continue in this case. - // - ASSERT (FALSE); - CpuDeadLoop (); - return EFI_UNSUPPORTED; -} diff --git a/OvmfPkg/SmmAccess/SmmAccessPei.inf b/OvmfPkg/SmmAccess/SmmAccessPei.inf deleted file mode 100644 index 3908b085da..0000000000 --- a/OvmfPkg/SmmAccess/SmmAccessPei.inf +++ /dev/null @@ -1,69 +0,0 @@ -## @file -# A PEIM with the following responsibilities: -# -# - provide SMRAM access by producing PEI_SMM_ACCESS_PPI, -# - verify & configure the Q35 TSEG in the entry point, -# - set aside the SMM_S3_RESUME_STATE object at the bottom of TSEG, and expose -# it via the gEfiAcpiVariableGuid GUIDed HOB. -# -# Copyright (C) 2013, 2015, 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 = SmmAccessPei - FILE_GUID = 6C0E75B4-B0B9-44D1-8210-3377D7B4E066 - MODULE_TYPE = PEIM - VERSION_STRING = 1.0 - ENTRY_POINT = SmmAccessPeiEntryPoint - -# -# The following information is for reference only and not required by the build tools. -# -# VALID_ARCHITECTURES = IA32 X64 -# - -[Sources] - SmmAccessPei.c - SmramInternal.c - SmramInternal.h - -[Packages] - MdeModulePkg/MdeModulePkg.dec - MdePkg/MdePkg.dec - OvmfPkg/OvmfPkg.dec - -[Guids] - gEfiAcpiVariableGuid - -[LibraryClasses] - BaseLib - BaseMemoryLib - DebugLib - HobLib - IoLib - PcdLib - PciLib - PeiServicesLib - PeimEntryPoint - -[FeaturePcd] - gUefiOvmfPkgTokenSpaceGuid.PcdSmmSmramRequire - -[FixedPcd] - gUefiOvmfPkgTokenSpaceGuid.PcdQ35TsegMbytes - -[Ppis] - gPeiSmmAccessPpiGuid ## PRODUCES - -[Depex] - TRUE diff --git a/OvmfPkg/SmmAccess/SmramInternal.c b/OvmfPkg/SmmAccess/SmramInternal.c deleted file mode 100644 index c3267ca940..0000000000 --- a/OvmfPkg/SmmAccess/SmramInternal.c +++ /dev/null @@ -1,188 +0,0 @@ -/** @file - - Functions and types shared by the SMM accessor PEI and DXE modules. - - Copyright (C) 2015, 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 -#include -#include -#include - -#include "SmramInternal.h" - -/** - Read the MCH_SMRAM and ESMRAMC registers, and update the LockState and - OpenState fields in the PEI_SMM_ACCESS_PPI / EFI_SMM_ACCESS2_PROTOCOL object, - from the D_LCK and T_EN bits. - - PEI_SMM_ACCESS_PPI and EFI_SMM_ACCESS2_PROTOCOL member functions can rely on - the LockState and OpenState fields being up-to-date on entry, and they need - to restore the same invariant on exit, if they touch the bits in question. - - @param[out] LockState Reflects the D_LCK bit on output; TRUE iff SMRAM is - locked. - @param[out] OpenState Reflects the inverse of the T_EN bit on output; TRUE - iff SMRAM is open. -**/ -VOID -GetStates ( - OUT BOOLEAN *LockState, - OUT BOOLEAN *OpenState -) -{ - UINT8 SmramVal, EsmramcVal; - - SmramVal = PciRead8 (DRAMC_REGISTER_Q35 (MCH_SMRAM)); - EsmramcVal = PciRead8 (DRAMC_REGISTER_Q35 (MCH_ESMRAMC)); - - *LockState = !!(SmramVal & MCH_SMRAM_D_LCK); - *OpenState = !(EsmramcVal & MCH_ESMRAMC_T_EN); -} - -// -// The functions below follow the PEI_SMM_ACCESS_PPI and -// EFI_SMM_ACCESS2_PROTOCOL member declarations. The PeiServices and This -// pointers are removed (TSEG doesn't depend on them), and so is the -// DescriptorIndex parameter (TSEG doesn't support range-wise locking). -// -// The LockState and OpenState members that are common to both -// PEI_SMM_ACCESS_PPI and EFI_SMM_ACCESS2_PROTOCOL are taken and updated in -// isolation from the rest of the (non-shared) members. -// - -EFI_STATUS -SmramAccessOpen ( - OUT BOOLEAN *LockState, - OUT BOOLEAN *OpenState - ) -{ - // - // Open TSEG by clearing T_EN. - // - PciAnd8 (DRAMC_REGISTER_Q35 (MCH_ESMRAMC), - (UINT8)((~(UINT32)MCH_ESMRAMC_T_EN) & 0xff)); - - GetStates (LockState, OpenState); - if (!*OpenState) { - return EFI_DEVICE_ERROR; - } - return EFI_SUCCESS; -} - -EFI_STATUS -SmramAccessClose ( - OUT BOOLEAN *LockState, - OUT BOOLEAN *OpenState - ) -{ - // - // Close TSEG by setting T_EN. - // - PciOr8 (DRAMC_REGISTER_Q35 (MCH_ESMRAMC), MCH_ESMRAMC_T_EN); - - GetStates (LockState, OpenState); - if (*OpenState) { - return EFI_DEVICE_ERROR; - } - return EFI_SUCCESS; -} - -EFI_STATUS -SmramAccessLock ( - OUT BOOLEAN *LockState, - IN OUT BOOLEAN *OpenState - ) -{ - if (*OpenState) { - return EFI_DEVICE_ERROR; - } - - // - // Close & lock TSEG by setting T_EN and D_LCK. - // - PciOr8 (DRAMC_REGISTER_Q35 (MCH_ESMRAMC), MCH_ESMRAMC_T_EN); - PciOr8 (DRAMC_REGISTER_Q35 (MCH_SMRAM), MCH_SMRAM_D_LCK); - - GetStates (LockState, OpenState); - if (*OpenState || !*LockState) { - return EFI_DEVICE_ERROR; - } - return EFI_SUCCESS; -} - -EFI_STATUS -SmramAccessGetCapabilities ( - IN BOOLEAN LockState, - IN BOOLEAN OpenState, - IN OUT UINTN *SmramMapSize, - IN OUT EFI_SMRAM_DESCRIPTOR *SmramMap - ) -{ - UINTN OriginalSize; - UINT32 TsegMemoryBaseMb, TsegMemoryBase; - UINT64 CommonRegionState; - UINT8 TsegSizeBits; - - OriginalSize = *SmramMapSize; - *SmramMapSize = DescIdxCount * sizeof *SmramMap; - if (OriginalSize < *SmramMapSize) { - return EFI_BUFFER_TOO_SMALL; - } - - // - // Read the TSEG Memory Base register. - // - TsegMemoryBaseMb = PciRead32 (DRAMC_REGISTER_Q35 (MCH_TSEGMB)); - TsegMemoryBase = (TsegMemoryBaseMb >> MCH_TSEGMB_MB_SHIFT) << 20; - - // - // Precompute the region state bits that will be set for all regions. - // - CommonRegionState = (OpenState ? EFI_SMRAM_OPEN : EFI_SMRAM_CLOSED) | - (LockState ? EFI_SMRAM_LOCKED : 0) | - EFI_CACHEABLE; - - // - // The first region hosts an SMM_S3_RESUME_STATE object. It is located at the - // start of TSEG. We round up the size to whole pages, and we report it as - // EFI_ALLOCATED, so that the SMM_CORE stays away from it. - // - SmramMap[DescIdxSmmS3ResumeState].PhysicalStart = TsegMemoryBase; - SmramMap[DescIdxSmmS3ResumeState].CpuStart = TsegMemoryBase; - SmramMap[DescIdxSmmS3ResumeState].PhysicalSize = - EFI_PAGES_TO_SIZE (EFI_SIZE_TO_PAGES (sizeof (SMM_S3_RESUME_STATE))); - SmramMap[DescIdxSmmS3ResumeState].RegionState = - CommonRegionState | EFI_ALLOCATED; - - // - // Get the TSEG size bits from the ESMRAMC register. - // - TsegSizeBits = PciRead8 (DRAMC_REGISTER_Q35 (MCH_ESMRAMC)) & - MCH_ESMRAMC_TSEG_MASK; - - // - // The second region is the main one, following the first. - // - SmramMap[DescIdxMain].PhysicalStart = - SmramMap[DescIdxSmmS3ResumeState].PhysicalStart + - SmramMap[DescIdxSmmS3ResumeState].PhysicalSize; - SmramMap[DescIdxMain].CpuStart = SmramMap[DescIdxMain].PhysicalStart; - SmramMap[DescIdxMain].PhysicalSize = - (TsegSizeBits == MCH_ESMRAMC_TSEG_8MB ? SIZE_8MB : - TsegSizeBits == MCH_ESMRAMC_TSEG_2MB ? SIZE_2MB : - SIZE_1MB) - SmramMap[DescIdxSmmS3ResumeState].PhysicalSize; - SmramMap[DescIdxMain].RegionState = CommonRegionState; - - return EFI_SUCCESS; -} diff --git a/OvmfPkg/SmmAccess/SmramInternal.h b/OvmfPkg/SmmAccess/SmramInternal.h deleted file mode 100644 index 4e9ac05fad..0000000000 --- a/OvmfPkg/SmmAccess/SmramInternal.h +++ /dev/null @@ -1,89 +0,0 @@ -/** @file - - Functions and types shared by the SMM accessor PEI and DXE modules. - - Copyright (C) 2015, 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 - -// -// We'll have two SMRAM ranges. -// -// The first is a tiny one that hosts an SMM_S3_RESUME_STATE object, to be -// filled in by the CPU SMM driver during normal boot, for the PEI instance of -// the LockBox library (which will rely on the object during S3 resume). -// -// The other SMRAM range is the main one, for the SMM core and the SMM drivers. -// -typedef enum { - DescIdxSmmS3ResumeState = 0, - DescIdxMain = 1, - DescIdxCount = 2 -} DESCRIPTOR_INDEX; - -/** - Read the MCH_SMRAM and ESMRAMC registers, and update the LockState and - OpenState fields in the PEI_SMM_ACCESS_PPI / EFI_SMM_ACCESS2_PROTOCOL object, - from the D_LCK and T_EN bits. - - PEI_SMM_ACCESS_PPI and EFI_SMM_ACCESS2_PROTOCOL member functions can rely on - the LockState and OpenState fields being up-to-date on entry, and they need - to restore the same invariant on exit, if they touch the bits in question. - - @param[out] LockState Reflects the D_LCK bit on output; TRUE iff SMRAM is - locked. - @param[out] OpenState Reflects the inverse of the T_EN bit on output; TRUE - iff SMRAM is open. -**/ -VOID -GetStates ( - OUT BOOLEAN *LockState, - OUT BOOLEAN *OpenState - ); - -// -// The functions below follow the PEI_SMM_ACCESS_PPI and -// EFI_SMM_ACCESS2_PROTOCOL member declarations. The PeiServices and This -// pointers are removed (TSEG doesn't depend on them), and so is the -// DescriptorIndex parameter (TSEG doesn't support range-wise locking). -// -// The LockState and OpenState members that are common to both -// PEI_SMM_ACCESS_PPI and EFI_SMM_ACCESS2_PROTOCOL are taken and updated in -// isolation from the rest of the (non-shared) members. -// - -EFI_STATUS -SmramAccessOpen ( - OUT BOOLEAN *LockState, - OUT BOOLEAN *OpenState - ); - -EFI_STATUS -SmramAccessClose ( - OUT BOOLEAN *LockState, - OUT BOOLEAN *OpenState - ); - -EFI_STATUS -SmramAccessLock ( - OUT BOOLEAN *LockState, - IN OUT BOOLEAN *OpenState - ); - -EFI_STATUS -SmramAccessGetCapabilities ( - IN BOOLEAN LockState, - IN BOOLEAN OpenState, - IN OUT UINTN *SmramMapSize, - IN OUT EFI_SMRAM_DESCRIPTOR *SmramMap - ); diff --git a/OvmfPkg/SmmControl2Dxe/SmiFeatures.c b/OvmfPkg/SmmControl2Dxe/SmiFeatures.c deleted file mode 100644 index 7c2cbd86ee..0000000000 --- a/OvmfPkg/SmmControl2Dxe/SmiFeatures.c +++ /dev/null @@ -1,246 +0,0 @@ -/**@file - Negotiate SMI features with QEMU, and configure UefiCpuPkg/PiSmmCpuDxeSmm - accordingly. - - Copyright (C) 2016-2017, 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 -#include -#include -#include -#include -#include - -#include "SmiFeatures.h" - -// -// The following bit value stands for "broadcast SMI" in the -// "etc/smi/supported-features" and "etc/smi/requested-features" fw_cfg files. -// -#define ICH9_LPC_SMI_F_BROADCAST BIT0 - -// -// Provides a scratch buffer (allocated in EfiReservedMemoryType type memory) -// for the S3 boot script fragment to write to and read from. -// -#pragma pack (1) -typedef union { - UINT64 Features; - UINT8 FeaturesOk; -} SCRATCH_BUFFER; -#pragma pack () - -// -// These carry the selector keys of the "etc/smi/requested-features" and -// "etc/smi/features-ok" fw_cfg files from NegotiateSmiFeatures() to -// AppendFwCfgBootScript(). -// -STATIC FIRMWARE_CONFIG_ITEM mRequestedFeaturesItem; -STATIC FIRMWARE_CONFIG_ITEM mFeaturesOkItem; - -// -// Carries the negotiated SMI features from NegotiateSmiFeatures() to -// AppendFwCfgBootScript(). -// -STATIC UINT64 mSmiFeatures; - -/** - Negotiate SMI features with QEMU. - - @retval FALSE If SMI feature negotiation is not supported by QEMU. This is - not an error, it just means that SaveSmiFeatures() should not - be called. - - @retval TRUE SMI feature negotiation is supported, and it has completed - successfully as well. (Failure to negotiate is a fatal error - and the function never returns in that case.) -**/ -BOOLEAN -NegotiateSmiFeatures ( - VOID - ) -{ - FIRMWARE_CONFIG_ITEM SupportedFeaturesItem; - UINTN SupportedFeaturesSize; - UINTN RequestedFeaturesSize; - UINTN FeaturesOkSize; - - // - // Look up the fw_cfg files used for feature negotiation. The selector keys - // of "etc/smi/requested-features" and "etc/smi/features-ok" are saved - // statically. If the files are missing, then QEMU doesn't support SMI - // feature negotiation. - // - if (RETURN_ERROR (QemuFwCfgFindFile ("etc/smi/supported-features", - &SupportedFeaturesItem, &SupportedFeaturesSize)) || - RETURN_ERROR (QemuFwCfgFindFile ("etc/smi/requested-features", - &mRequestedFeaturesItem, &RequestedFeaturesSize)) || - RETURN_ERROR (QemuFwCfgFindFile ("etc/smi/features-ok", - &mFeaturesOkItem, &FeaturesOkSize))) { - DEBUG ((DEBUG_INFO, "%a: SMI feature negotiation unavailable\n", - __FUNCTION__)); - return FALSE; - } - - // - // If the files are present but their sizes disagree with us, that's a fatal - // error (we can't trust the behavior of SMIs either way). - // - if (SupportedFeaturesSize != sizeof mSmiFeatures || - RequestedFeaturesSize != sizeof mSmiFeatures || - FeaturesOkSize != sizeof (UINT8)) { - DEBUG ((DEBUG_ERROR, "%a: size mismatch in feature negotiation\n", - __FUNCTION__)); - goto FatalError; - } - - // - // Get the features supported by the host. - // - QemuFwCfgSelectItem (SupportedFeaturesItem); - QemuFwCfgReadBytes (sizeof mSmiFeatures, &mSmiFeatures); - - // - // We want broadcast SMI and nothing else. - // - mSmiFeatures &= ICH9_LPC_SMI_F_BROADCAST; - QemuFwCfgSelectItem (mRequestedFeaturesItem); - QemuFwCfgWriteBytes (sizeof mSmiFeatures, &mSmiFeatures); - - // - // Invoke feature validation in QEMU. If the selection is accepted, the - // features will be locked down. If the selection is rejected, feature - // negotiation remains open; however we don't know what to do in that case, - // so that's a fatal error. - // - QemuFwCfgSelectItem (mFeaturesOkItem); - if (QemuFwCfgRead8 () != 1) { - DEBUG ((DEBUG_ERROR, "%a: negotiation failed for feature bitmap 0x%Lx\n", - __FUNCTION__, mSmiFeatures)); - goto FatalError; - } - - if ((mSmiFeatures & ICH9_LPC_SMI_F_BROADCAST) == 0) { - // - // If we can't get broadcast SMIs from QEMU, that's acceptable too, - // although not optimal. - // - DEBUG ((DEBUG_INFO, "%a: SMI broadcast unavailable\n", __FUNCTION__)); - } else { - // - // Configure the traditional AP sync / SMI delivery mode for - // PiSmmCpuDxeSmm. Effectively, restore the UefiCpuPkg defaults, from which - // the original QEMU behavior (i.e., unicast SMI) used to differ. - // - if (RETURN_ERROR (PcdSet64S (PcdCpuSmmApSyncTimeout, 1000000)) || - RETURN_ERROR (PcdSet8S (PcdCpuSmmSyncMode, 0x00))) { - DEBUG ((DEBUG_ERROR, "%a: PiSmmCpuDxeSmm PCD configuration failed\n", - __FUNCTION__)); - goto FatalError; - } - DEBUG ((DEBUG_INFO, "%a: using SMI broadcast\n", __FUNCTION__)); - } - - // - // Negotiation successful (although we may not have gotten the optimal - // feature set). - // - return TRUE; - -FatalError: - ASSERT (FALSE); - CpuDeadLoop (); - // - // Keep the compiler happy. - // - return FALSE; -} - -/** - FW_CFG_BOOT_SCRIPT_CALLBACK_FUNCTION provided to QemuFwCfgS3Lib. -**/ -STATIC -VOID -EFIAPI -AppendFwCfgBootScript ( - IN OUT VOID *Context, OPTIONAL - IN OUT VOID *ExternalScratchBuffer - ) -{ - SCRATCH_BUFFER *ScratchBuffer; - RETURN_STATUS Status; - - ScratchBuffer = ExternalScratchBuffer; - - // - // Write the negotiated feature bitmap into "etc/smi/requested-features". - // - ScratchBuffer->Features = mSmiFeatures; - Status = QemuFwCfgS3ScriptWriteBytes (mRequestedFeaturesItem, - sizeof ScratchBuffer->Features); - if (RETURN_ERROR (Status)) { - goto FatalError; - } - - // - // Read back "etc/smi/features-ok". This invokes the feature validation & - // lockdown. (The validation succeeded at first boot.) - // - Status = QemuFwCfgS3ScriptReadBytes (mFeaturesOkItem, - sizeof ScratchBuffer->FeaturesOk); - if (RETURN_ERROR (Status)) { - goto FatalError; - } - - // - // If "etc/smi/features-ok" read as 1, we're good. Otherwise, hang the S3 - // resume process. - // - Status = QemuFwCfgS3ScriptCheckValue (&ScratchBuffer->FeaturesOk, - sizeof ScratchBuffer->FeaturesOk, MAX_UINT8, 1); - if (RETURN_ERROR (Status)) { - goto FatalError; - } - - DEBUG ((DEBUG_VERBOSE, "%a: SMI feature negotiation boot script saved\n", - __FUNCTION__)); - return; - -FatalError: - ASSERT (FALSE); - CpuDeadLoop (); -} - - -/** - Append a boot script fragment that will re-select the previously negotiated - SMI features during S3 resume. -**/ -VOID -SaveSmiFeatures ( - VOID - ) -{ - RETURN_STATUS Status; - - // - // We are already running at TPL_CALLBACK, on the stack of - // OnS3SaveStateInstalled(). But that's okay, we can easily queue more - // notification functions while executing a notification function. - // - Status = QemuFwCfgS3CallWhenBootScriptReady (AppendFwCfgBootScript, NULL, - sizeof (SCRATCH_BUFFER)); - if (RETURN_ERROR (Status)) { - ASSERT (FALSE); - CpuDeadLoop (); - } -} diff --git a/OvmfPkg/SmmControl2Dxe/SmiFeatures.h b/OvmfPkg/SmmControl2Dxe/SmiFeatures.h deleted file mode 100644 index 3f3a5d3ea9..0000000000 --- a/OvmfPkg/SmmControl2Dxe/SmiFeatures.h +++ /dev/null @@ -1,46 +0,0 @@ -/**@file - Negotiate SMI features with QEMU, and configure UefiCpuPkg/PiSmmCpuDxeSmm - accordingly. - - Copyright (C) 2016-2017, 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 __SMI_FEATURES_H__ -#define __SMI_FEATURES_H__ - -#include - -/** - Negotiate SMI features with QEMU. - - @retval FALSE If SMI feature negotiation is not supported by QEMU. This is - not an error, it just means that SaveSmiFeatures() should not - be called. - - @retval TRUE SMI feature negotiation is supported, and it has completed - successfully as well. (Failure to negotiate is a fatal error - and the function never returns in that case.) -**/ -BOOLEAN -NegotiateSmiFeatures ( - VOID - ); - -/** - Append a boot script fragment that will re-select the previously negotiated - SMI features during S3 resume. -**/ -VOID -SaveSmiFeatures ( - VOID - ); - -#endif diff --git a/OvmfPkg/SmmControl2Dxe/SmmControl2Dxe.c b/OvmfPkg/SmmControl2Dxe/SmmControl2Dxe.c deleted file mode 100644 index e1cd3d02ac..0000000000 --- a/OvmfPkg/SmmControl2Dxe/SmmControl2Dxe.c +++ /dev/null @@ -1,392 +0,0 @@ -/** @file - - A DXE_RUNTIME_DRIVER providing synchronous SMI activations via the - EFI_SMM_CONTROL2_PROTOCOL. - - We expect the PEI phase to have covered the following: - - ensure that the underlying QEMU machine type be Q35 - (responsible: OvmfPkg/SmmAccess/SmmAccessPei.inf) - - ensure that the ACPI PM IO space be configured - (responsible: OvmfPkg/PlatformPei/PlatformPei.inf) - - Our own entry point is responsible for confirming the SMI feature and for - configuring it. - - Copyright (C) 2013, 2015, Red Hat, Inc.
- Copyright (c) 2009 - 2010, Intel Corporation. All rights reserved.
- - This program and the accompanying materials are licensed and made available - under the terms and conditions of the BSD License which accompanies this - distribution. The full text of the license may be found at - http://opensource.org/licenses/bsd-license.php - - THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, WITHOUT - WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. - -**/ - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#include "SmiFeatures.h" - -// -// Forward declaration. -// -STATIC -VOID -EFIAPI -OnS3SaveStateInstalled ( - IN EFI_EVENT Event, - IN VOID *Context - ); - -// -// The absolute IO port address of the SMI Control and Enable Register. It is -// only used to carry information from the entry point function to the -// S3SaveState protocol installation callback, strictly before the runtime -// phase. -// -STATIC UINTN mSmiEnable; - -// -// Captures whether SMI feature negotiation is supported. The variable is only -// used to carry this information from the entry point function to the -// S3SaveState protocol installation callback. -// -STATIC BOOLEAN mSmiFeatureNegotiation; - -// -// Event signaled when an S3SaveState protocol interface is installed. -// -STATIC EFI_EVENT mS3SaveStateInstalled; - -/** - Invokes SMI activation from either the preboot or runtime environment. - - This function generates an SMI. - - @param[in] This The EFI_SMM_CONTROL2_PROTOCOL instance. - @param[in,out] CommandPort The value written to the command port. - @param[in,out] DataPort The value written to the data port. - @param[in] Periodic Optional mechanism to engender a periodic - stream. - @param[in] ActivationInterval Optional parameter to repeat at this - period one time or, if the Periodic - Boolean is set, periodically. - - @retval EFI_SUCCESS The SMI/PMI has been engendered. - @retval EFI_DEVICE_ERROR The timing is unsupported. - @retval EFI_INVALID_PARAMETER The activation period is unsupported. - @retval EFI_INVALID_PARAMETER The last periodic activation has not been - cleared. - @retval EFI_NOT_STARTED The SMM base service has not been initialized. -**/ -STATIC -EFI_STATUS -EFIAPI -SmmControl2DxeTrigger ( - IN CONST EFI_SMM_CONTROL2_PROTOCOL *This, - IN OUT UINT8 *CommandPort OPTIONAL, - IN OUT UINT8 *DataPort OPTIONAL, - IN BOOLEAN Periodic OPTIONAL, - IN UINTN ActivationInterval OPTIONAL - ) -{ - // - // No support for queued or periodic activation. - // - if (Periodic || ActivationInterval > 0) { - return EFI_DEVICE_ERROR; - } - - // - // The so-called "Advanced Power Management Status Port Register" is in fact - // a generic data passing register, between the caller and the SMI - // dispatcher. The ICH9 spec calls it "scratchpad register" -- calling it - // "status" elsewhere seems quite the misnomer. Status registers usually - // report about hardware status, while this register is fully governed by - // software. - // - // Write to the status register first, as this won't trigger the SMI just - // yet. Then write to the control register. - // - IoWrite8 (ICH9_APM_STS, DataPort == NULL ? 0 : *DataPort); - IoWrite8 (ICH9_APM_CNT, CommandPort == NULL ? 0 : *CommandPort); - return EFI_SUCCESS; -} - -/** - Clears any system state that was created in response to the Trigger() call. - - This function acknowledges and causes the deassertion of the SMI activation - source. - - @param[in] This The EFI_SMM_CONTROL2_PROTOCOL instance. - @param[in] Periodic Optional parameter to repeat at this period - one time - - @retval EFI_SUCCESS The SMI/PMI has been engendered. - @retval EFI_DEVICE_ERROR The source could not be cleared. - @retval EFI_INVALID_PARAMETER The service did not support the Periodic input - argument. -**/ -STATIC -EFI_STATUS -EFIAPI -SmmControl2DxeClear ( - IN CONST EFI_SMM_CONTROL2_PROTOCOL *This, - IN BOOLEAN Periodic OPTIONAL - ) -{ - if (Periodic) { - return EFI_INVALID_PARAMETER; - } - - // - // The PI spec v1.4 explains that Clear() is only supposed to clear software - // status; it is not in fact responsible for deasserting the SMI. It gives - // two reasons for this: (a) many boards clear the SMI automatically when - // entering SMM, (b) if Clear() actually deasserted the SMI, then it could - // incorrectly suppress an SMI that was asynchronously asserted between the - // last return of the SMI handler and the call made to Clear(). - // - // In fact QEMU automatically deasserts CPU_INTERRUPT_SMI in: - // - x86_cpu_exec_interrupt() [target-i386/seg_helper.c], and - // - kvm_arch_pre_run() [target-i386/kvm.c]. - // - // So, nothing to do here. - // - return EFI_SUCCESS; -} - -STATIC EFI_SMM_CONTROL2_PROTOCOL mControl2 = { - &SmmControl2DxeTrigger, - &SmmControl2DxeClear, - MAX_UINTN // MinimumTriggerPeriod -- we don't support periodic SMIs -}; - -// -// Entry point of this driver. -// -EFI_STATUS -EFIAPI -SmmControl2DxeEntryPoint ( - IN EFI_HANDLE ImageHandle, - IN EFI_SYSTEM_TABLE *SystemTable - ) -{ - UINT32 PmBase; - UINT32 SmiEnableVal; - EFI_STATUS Status; - - // - // This module should only be included if SMRAM support is required. - // - ASSERT (FeaturePcdGet (PcdSmmSmramRequire)); - - // - // Calculate the absolute IO port address of the SMI Control and Enable - // Register. (As noted at the top, the PEI phase has left us with a working - // ACPI PM IO space.) - // - PmBase = PciRead32 (POWER_MGMT_REGISTER_Q35 (ICH9_PMBASE)) & - ICH9_PMBASE_MASK; - mSmiEnable = PmBase + ICH9_PMBASE_OFS_SMI_EN; - - // - // If APMC_EN is pre-set in SMI_EN, that's QEMU's way to tell us that SMI - // support is not available. (For example due to KVM lacking it.) Otherwise, - // this bit is clear after each reset. - // - SmiEnableVal = IoRead32 (mSmiEnable); - if ((SmiEnableVal & ICH9_SMI_EN_APMC_EN) != 0) { - DEBUG ((EFI_D_ERROR, "%a: this Q35 implementation lacks SMI\n", - __FUNCTION__)); - goto FatalError; - } - - // - // Otherwise, configure the board to inject an SMI when ICH9_APM_CNT is - // written to. (See the Trigger() method above.) - // - SmiEnableVal |= ICH9_SMI_EN_APMC_EN | ICH9_SMI_EN_GBL_SMI_EN; - IoWrite32 (mSmiEnable, SmiEnableVal); - - // - // Prevent software from undoing the above (until platform reset). - // - PciOr16 (POWER_MGMT_REGISTER_Q35 (ICH9_GEN_PMCON_1), - ICH9_GEN_PMCON_1_SMI_LOCK); - - // - // If we can clear GBL_SMI_EN now, that means QEMU's SMI support is not - // appropriate. - // - IoWrite32 (mSmiEnable, SmiEnableVal & ~(UINT32)ICH9_SMI_EN_GBL_SMI_EN); - if (IoRead32 (mSmiEnable) != SmiEnableVal) { - DEBUG ((EFI_D_ERROR, "%a: failed to lock down GBL_SMI_EN\n", - __FUNCTION__)); - goto FatalError; - } - - // - // QEMU can inject SMIs in different ways, negotiate our preferences. - // - mSmiFeatureNegotiation = NegotiateSmiFeatures (); - - if (QemuFwCfgS3Enabled ()) { - VOID *Registration; - - // - // On S3 resume the above register settings have to be repeated. Register a - // protocol notify callback that, when boot script saving becomes - // available, saves operations equivalent to the above to the boot script. - // - Status = gBS->CreateEvent (EVT_NOTIFY_SIGNAL, TPL_CALLBACK, - OnS3SaveStateInstalled, NULL /* Context */, - &mS3SaveStateInstalled); - if (EFI_ERROR (Status)) { - DEBUG ((EFI_D_ERROR, "%a: CreateEvent: %r\n", __FUNCTION__, Status)); - goto FatalError; - } - - Status = gBS->RegisterProtocolNotify (&gEfiS3SaveStateProtocolGuid, - mS3SaveStateInstalled, &Registration); - if (EFI_ERROR (Status)) { - DEBUG ((EFI_D_ERROR, "%a: RegisterProtocolNotify: %r\n", __FUNCTION__, - Status)); - goto ReleaseEvent; - } - - // - // Kick the event right now -- maybe the boot script is already saveable. - // - Status = gBS->SignalEvent (mS3SaveStateInstalled); - if (EFI_ERROR (Status)) { - DEBUG ((EFI_D_ERROR, "%a: SignalEvent: %r\n", __FUNCTION__, Status)); - goto ReleaseEvent; - } - } - - // - // We have no pointers to convert to virtual addresses. The handle itself - // doesn't matter, as protocol services are not accessible at runtime. - // - Status = gBS->InstallMultipleProtocolInterfaces (&ImageHandle, - &gEfiSmmControl2ProtocolGuid, &mControl2, - NULL); - if (EFI_ERROR (Status)) { - DEBUG ((EFI_D_ERROR, "%a: InstallMultipleProtocolInterfaces: %r\n", - __FUNCTION__, Status)); - goto ReleaseEvent; - } - - return EFI_SUCCESS; - -ReleaseEvent: - if (mS3SaveStateInstalled != NULL) { - gBS->CloseEvent (mS3SaveStateInstalled); - } - -FatalError: - // - // We really don't want to continue in this case. - // - ASSERT (FALSE); - CpuDeadLoop (); - return EFI_UNSUPPORTED; -} - -/** - Notification callback for S3SaveState installation. - - @param[in] Event Event whose notification function is being invoked. - - @param[in] Context The pointer to the notification function's context, which - is implementation-dependent. -**/ -STATIC -VOID -EFIAPI -OnS3SaveStateInstalled ( - IN EFI_EVENT Event, - IN VOID *Context - ) -{ - EFI_STATUS Status; - EFI_S3_SAVE_STATE_PROTOCOL *S3SaveState; - UINT32 SmiEnOrMask, SmiEnAndMask; - UINT64 GenPmCon1Address; - UINT16 GenPmCon1OrMask, GenPmCon1AndMask; - - ASSERT (Event == mS3SaveStateInstalled); - - Status = gBS->LocateProtocol (&gEfiS3SaveStateProtocolGuid, - NULL /* Registration */, (VOID **)&S3SaveState); - if (EFI_ERROR (Status)) { - return; - } - - // - // These operations were originally done, verified and explained in the entry - // point function of the driver. - // - SmiEnOrMask = ICH9_SMI_EN_APMC_EN | ICH9_SMI_EN_GBL_SMI_EN; - SmiEnAndMask = MAX_UINT32; - Status = S3SaveState->Write ( - S3SaveState, - EFI_BOOT_SCRIPT_IO_READ_WRITE_OPCODE, - EfiBootScriptWidthUint32, - (UINT64)mSmiEnable, - &SmiEnOrMask, - &SmiEnAndMask - ); - if (EFI_ERROR (Status)) { - DEBUG ((EFI_D_ERROR, "%a: EFI_BOOT_SCRIPT_IO_READ_WRITE_OPCODE: %r\n", - __FUNCTION__, Status)); - ASSERT (FALSE); - CpuDeadLoop (); - } - - GenPmCon1Address = POWER_MGMT_REGISTER_Q35_EFI_PCI_ADDRESS ( - ICH9_GEN_PMCON_1); - GenPmCon1OrMask = ICH9_GEN_PMCON_1_SMI_LOCK; - GenPmCon1AndMask = MAX_UINT16; - Status = S3SaveState->Write ( - S3SaveState, - EFI_BOOT_SCRIPT_PCI_CONFIG_READ_WRITE_OPCODE, - EfiBootScriptWidthUint16, - GenPmCon1Address, - &GenPmCon1OrMask, - &GenPmCon1AndMask - ); - if (EFI_ERROR (Status)) { - DEBUG ((EFI_D_ERROR, - "%a: EFI_BOOT_SCRIPT_PCI_CONFIG_READ_WRITE_OPCODE: %r\n", __FUNCTION__, - Status)); - ASSERT (FALSE); - CpuDeadLoop (); - } - - DEBUG ((DEBUG_VERBOSE, "%a: chipset boot script saved\n", __FUNCTION__)); - - // - // Append a boot script fragment that re-selects the negotiated SMI features. - // - if (mSmiFeatureNegotiation) { - SaveSmiFeatures (); - } - - gBS->CloseEvent (Event); - mS3SaveStateInstalled = NULL; -} diff --git a/OvmfPkg/SmmControl2Dxe/SmmControl2Dxe.inf b/OvmfPkg/SmmControl2Dxe/SmmControl2Dxe.inf deleted file mode 100644 index 04b1ed0e4e..0000000000 --- a/OvmfPkg/SmmControl2Dxe/SmmControl2Dxe.inf +++ /dev/null @@ -1,75 +0,0 @@ -## @file -# A DXE_RUNTIME_DRIVER providing synchronous SMI activations via the -# EFI_SMM_CONTROL2_PROTOCOL. -# -# We expect the PEI phase to have covered the following: -# - ensure that the underlying QEMU machine type be Q35 -# (responsible: OvmfPkg/SmmAccess/SmmAccessPei.inf) -# - ensure that the ACPI PM IO space be configured -# (responsible: OvmfPkg/PlatformPei/PlatformPei.inf) -# -# Our own entry point is responsible for confirming the SMI feature and for -# configuring it. -# -# Copyright (C) 2013, 2015, 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 = SmmControl2Dxe - FILE_GUID = 1206F7CA-A475-4624-A83E-E6FC9BB38E49 - MODULE_TYPE = DXE_RUNTIME_DRIVER - VERSION_STRING = 1.0 - PI_SPECIFICATION_VERSION = 0x00010400 - ENTRY_POINT = SmmControl2DxeEntryPoint - -# -# The following information is for reference only and not required by the build tools. -# -# VALID_ARCHITECTURES = IA32 X64 -# - -[Sources] - SmiFeatures.h - SmiFeatures.c - SmmControl2Dxe.c - -[Packages] - MdePkg/MdePkg.dec - OvmfPkg/OvmfPkg.dec - UefiCpuPkg/UefiCpuPkg.dec - -[LibraryClasses] - BaseLib - DebugLib - IoLib - MemoryAllocationLib - PcdLib - PciLib - QemuFwCfgLib - QemuFwCfgS3Lib - UefiBootServicesTableLib - UefiDriverEntryPoint - -[Protocols] - gEfiS3SaveStateProtocolGuid ## SOMETIMES_CONSUMES - gEfiSmmControl2ProtocolGuid ## PRODUCES - -[Pcd] - gUefiCpuPkgTokenSpaceGuid.PcdCpuSmmApSyncTimeout ## SOMETIMES_PRODUCES - gUefiCpuPkgTokenSpaceGuid.PcdCpuSmmSyncMode ## SOMETIMES_PRODUCES - -[FeaturePcd] - gUefiOvmfPkgTokenSpaceGuid.PcdSmmSmramRequire - -[Depex] - TRUE diff --git a/OvmfPkg/VarStore.fdf.inc b/OvmfPkg/VarStore.fdf.inc deleted file mode 100644 index ce901c0109..0000000000 --- a/OvmfPkg/VarStore.fdf.inc +++ /dev/null @@ -1,72 +0,0 @@ -## @file -# FDF include file with Layout Regions that define an empty variable store. -# -# Copyright (C) 2014, Red Hat, Inc. -# Copyright (c) 2006 - 2013, Intel Corporation. All rights reserved.
-# -# This program and the accompanying materials are licensed and made available -# under the terms and conditions of the BSD License which accompanies this -# distribution. The full text of the license may be found at -# http://opensource.org/licenses/bsd-license.php -# -# THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, -# WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR -# IMPLIED. -# -## - -0x00000000|0x0000e000 -#NV_VARIABLE_STORE -DATA = { - ## This is the EFI_FIRMWARE_VOLUME_HEADER - # ZeroVector [] - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - # FileSystemGuid: gEfiSystemNvDataFvGuid = - # { 0xFFF12B8D, 0x7696, 0x4C8B, - # { 0xA9, 0x85, 0x27, 0x47, 0x07, 0x5B, 0x4F, 0x50 }} - 0x8D, 0x2B, 0xF1, 0xFF, 0x96, 0x76, 0x8B, 0x4C, - 0xA9, 0x85, 0x27, 0x47, 0x07, 0x5B, 0x4F, 0x50, - # FvLength: 0x20000 - 0x00, 0x00, 0x02, 0x00, 0x00, 0x00, 0x00, 0x00, - # Signature "_FVH" # Attributes - 0x5f, 0x46, 0x56, 0x48, 0xff, 0xfe, 0x04, 0x00, - # HeaderLength # CheckSum # ExtHeaderOffset #Reserved #Revision - 0x48, 0x00, 0x19, 0xF9, 0x00, 0x00, 0x00, 0x02, - # Blockmap[0]: 0x20 Blocks * 0x1000 Bytes / Block - 0x20, 0x00, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, - # Blockmap[1]: End - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - ## This is the VARIABLE_STORE_HEADER - # It is compatible with SECURE_BOOT_ENABLE == FALSE as well. - # Signature: gEfiAuthenticatedVariableGuid = - # { 0xaaf32c78, 0x947b, 0x439a, - # { 0xa1, 0x80, 0x2e, 0x14, 0x4e, 0xc3, 0x77, 0x92 }} - 0x78, 0x2c, 0xf3, 0xaa, 0x7b, 0x94, 0x9a, 0x43, - 0xa1, 0x80, 0x2e, 0x14, 0x4e, 0xc3, 0x77, 0x92, - # Size: 0xe000 (gEfiMdeModulePkgTokenSpaceGuid.PcdFlashNvStorageVariableSize) - - # 0x48 (size of EFI_FIRMWARE_VOLUME_HEADER) = 0xdfb8 - # This can speed up the Variable Dispatch a bit. - 0xB8, 0xDF, 0x00, 0x00, - # FORMATTED: 0x5A #HEALTHY: 0xFE #Reserved: UINT16 #Reserved1: UINT32 - 0x5A, 0xFE, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 -} - -0x0000e000|0x00001000 -#NV_EVENT_LOG - -0x0000f000|0x00001000 -#NV_FTW_WORKING -DATA = { - # EFI_FAULT_TOLERANT_WORKING_BLOCK_HEADER->Signature = gEdkiiWorkingBlockSignatureGuid = - # { 0x9e58292b, 0x7c68, 0x497d, { 0xa0, 0xce, 0x65, 0x0, 0xfd, 0x9f, 0x1b, 0x95 }} - 0x2b, 0x29, 0x58, 0x9e, 0x68, 0x7c, 0x7d, 0x49, - 0xa0, 0xce, 0x65, 0x0, 0xfd, 0x9f, 0x1b, 0x95, - # Crc:UINT32 #WorkingBlockValid:1, WorkingBlockInvalid:1, Reserved - 0x2c, 0xaf, 0x2c, 0x64, 0xFE, 0xFF, 0xFF, 0xFF, - # WriteQueueSize: UINT64 - 0xE0, 0x0F, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 -} - -0x00010000|0x00010000 -#NV_FTW_SPARE diff --git a/OvmfPkg/Virtio10Dxe/Virtio10.c b/OvmfPkg/Virtio10Dxe/Virtio10.c deleted file mode 100644 index a8a6a58c3f..0000000000 --- a/OvmfPkg/Virtio10Dxe/Virtio10.c +++ /dev/null @@ -1,1073 +0,0 @@ -/** @file - A non-transitional driver for VirtIo 1.0 PCI devices. - - Copyright (C) 2016, 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 -#include -#include -#include -#include -#include -#include -#include -#include - -#include "Virtio10.h" - - -// -// Utility functions -// - -/** - Transfer data between the caller and a register in a virtio-1.0 register - block. - - @param[in] PciIo The EFI_PCI_IO_PROTOCOL instance that represents - the device. - - @param[in] Config The "fat pointer" structure that identifies the - register block to access. - - @param[in] Write TRUE if the register should be written, FALSE if - the register should be read. - - @param[in] FieldOffset The offset of the register within the register - block. - - @param[in] FieldSize The size of the register within the register - block. Can be one of 1, 2, 4 and 8. Accesses to - 8-byte registers are broken up into two 4-byte - accesses. - - @param[in,out] Buffer When Write is TRUE, the register is written with - data from Buffer. When Write is FALSE, the caller - receives the register value into Buffer. - - @retval EFI_SUCCESS Register access successful. - - @retval EFI_INVALID_PARAMETER The register block pointed-to by Config - doesn't exist; or FieldOffset and FieldSize - would overflow the register block; or - FieldSize is invalid. - - @return Error codes from - EFI_PCI_IO_PROTOCOL.(Io|Mem).(Read|Write) - member functions. -**/ -STATIC -EFI_STATUS -Virtio10Transfer ( - IN EFI_PCI_IO_PROTOCOL *PciIo, - IN VIRTIO_1_0_CONFIG *Config, - IN BOOLEAN Write, - IN UINTN FieldOffset, - IN UINTN FieldSize, - IN OUT VOID *Buffer - ) -{ - UINTN Count; - EFI_PCI_IO_PROTOCOL_WIDTH Width; - EFI_PCI_IO_PROTOCOL_ACCESS *BarType; - EFI_PCI_IO_PROTOCOL_IO_MEM Access; - - if (!Config->Exists || - FieldSize > Config->Length || - FieldOffset > Config->Length - FieldSize) { - return EFI_INVALID_PARAMETER; - } - - 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: - return EFI_INVALID_PARAMETER; - } - - BarType = (Config->BarType == Virtio10BarTypeMem) ? &PciIo->Mem : &PciIo->Io; - Access = Write ? BarType->Write : BarType->Read; - - return Access (PciIo, Width, Config->Bar, Config->Offset + FieldOffset, - Count, Buffer); -} - - -/** - Determine if a PCI BAR is IO or MMIO. - - @param[in] PciIo The EFI_PCI_IO_PROTOCOL instance that represents the - device. - - @param[in] BarIndex The number of the BAR whose type the caller is - interested in. - - @param[out] BarType On output, a VIRTIO_1_0_BAR_TYPE value that gives the - type of the BAR. - - @retval EFI_SUCCESS The BAR type has been recognized and stored in - BarType. - - @retval EFI_UNSUPPORTED The BAR type couldn't be identified. - - @return Error codes from - EFI_PCI_IO_PROTOCOL.GetBarAttributes(). -**/ -STATIC -EFI_STATUS -GetBarType ( - IN EFI_PCI_IO_PROTOCOL *PciIo, - IN UINT8 BarIndex, - OUT VIRTIO_1_0_BAR_TYPE *BarType - ) -{ - EFI_STATUS Status; - VOID *Resources; - - Status = PciIo->GetBarAttributes (PciIo, BarIndex, NULL, &Resources); - if (EFI_ERROR (Status)) { - return Status; - } - - Status = EFI_UNSUPPORTED; - - if (*(UINT8 *)Resources == ACPI_QWORD_ADDRESS_SPACE_DESCRIPTOR) { - EFI_ACPI_QWORD_ADDRESS_SPACE_DESCRIPTOR *Descriptor; - - Descriptor = Resources; - switch (Descriptor->ResType) { - case ACPI_ADDRESS_SPACE_TYPE_MEM: - *BarType = Virtio10BarTypeMem; - Status = EFI_SUCCESS; - break; - - case ACPI_ADDRESS_SPACE_TYPE_IO: - *BarType = Virtio10BarTypeIo; - Status = EFI_SUCCESS; - break; - - default: - break; - } - } - - FreePool (Resources); - return Status; -} - - -/** - Read a slice from PCI config space at the given offset, then advance the - offset. - - @param [in] PciIo The EFI_PCI_IO_PROTOCOL instance that represents the - device. - - @param [in,out] Offset On input, the offset in PCI config space to start - reading from. On output, the offset of the first byte - that was not read. On error, Offset is not modified. - - @param [in] Size The number of bytes to read. - - @param [out] Buffer On output, the bytes read from PCI config space are - stored in this object. - - @retval EFI_SUCCESS Size bytes have been transferred from PCI config space - (from Offset) to Buffer, and Offset has been incremented - by Size. - - @return Error codes from PciIo->Pci.Read(). -**/ -STATIC -EFI_STATUS -ReadConfigSpace ( - IN EFI_PCI_IO_PROTOCOL *PciIo, - IN OUT UINT32 *Offset, - IN UINTN Size, - OUT VOID *Buffer - ) -{ - EFI_STATUS Status; - - Status = PciIo->Pci.Read (PciIo, EfiPciIoWidthUint8, *Offset, Size, Buffer); - if (EFI_ERROR (Status)) { - return Status; - } - *Offset += (UINT32)Size; - return EFI_SUCCESS; -} - - -/* - Traverse the PCI capabilities list of a virtio-1.0 device, and capture the - locations of the interesting virtio-1.0 register blocks. - - @param[in,out] Device The VIRTIO_1_0_DEV structure that identifies - the device. On input, the caller is responsible - that the Device->PciIo member be live, and that - the CommonConfig, NotifyConfig, - NotifyOffsetMultiplier and SpecificConfig - members be zeroed. On output, said members - will have been updated from the PCI - capabilities found. - - @param[in] CapabilityPtr The offset of the first capability in PCI - config space, taken from the standard PCI - device header. - - @retval EFI_SUCCESS Traversal successful. - - @return Error codes from the ReadConfigSpace() and GetBarType() - helper functions. -*/ -STATIC -EFI_STATUS -ParseCapabilities ( - IN OUT VIRTIO_1_0_DEV *Device, - IN UINT8 CapabilityPtr - ) -{ - UINT32 Offset; - VIRTIO_PCI_CAP_LINK CapLink; - - for (Offset = CapabilityPtr & 0xFC; - Offset > 0; - Offset = CapLink.CapNext & 0xFC - ) { - EFI_STATUS Status; - UINT8 CapLen; - VIRTIO_PCI_CAP VirtIoCap; - VIRTIO_1_0_CONFIG *ParsedConfig; - - // - // Read capability identifier and link to next capability. - // - Status = ReadConfigSpace (Device->PciIo, &Offset, sizeof CapLink, - &CapLink); - if (EFI_ERROR (Status)) { - return Status; - } - if (CapLink.CapId != 0x09) { - // - // Not a vendor-specific capability, move to the next one. - // - continue; - } - - // - // Big enough to accommodate a VIRTIO_PCI_CAP structure? - // - Status = ReadConfigSpace (Device->PciIo, &Offset, sizeof CapLen, &CapLen); - if (EFI_ERROR (Status)) { - return Status; - } - if (CapLen < sizeof CapLink + sizeof CapLen + sizeof VirtIoCap) { - // - // Too small, move to next. - // - continue; - } - - // - // Read interesting part of capability. - // - Status = ReadConfigSpace (Device->PciIo, &Offset, sizeof VirtIoCap, - &VirtIoCap); - if (EFI_ERROR (Status)) { - return Status; - } - switch (VirtIoCap.ConfigType) { - case VIRTIO_PCI_CAP_COMMON_CFG: - ParsedConfig = &Device->CommonConfig; - break; - case VIRTIO_PCI_CAP_NOTIFY_CFG: - ParsedConfig = &Device->NotifyConfig; - break; - case VIRTIO_PCI_CAP_DEVICE_CFG: - ParsedConfig = &Device->SpecificConfig; - break; - default: - // - // Capability is not interesting. - // - continue; - } - - // - // Save the location of the register block into ParsedConfig. - // - Status = GetBarType (Device->PciIo, VirtIoCap.Bar, &ParsedConfig->BarType); - if (EFI_ERROR (Status)) { - return Status; - } - ParsedConfig->Bar = VirtIoCap.Bar; - ParsedConfig->Offset = VirtIoCap.Offset; - ParsedConfig->Length = VirtIoCap.Length; - - if (VirtIoCap.ConfigType == VIRTIO_PCI_CAP_NOTIFY_CFG) { - // - // This capability has an additional field called NotifyOffsetMultiplier; - // parse it too. - // - if (CapLen < sizeof CapLink + sizeof CapLen + sizeof VirtIoCap + - sizeof Device->NotifyOffsetMultiplier) { - // - // Too small, move to next. - // - continue; - } - - Status = ReadConfigSpace (Device->PciIo, &Offset, - sizeof Device->NotifyOffsetMultiplier, - &Device->NotifyOffsetMultiplier); - if (EFI_ERROR (Status)) { - return Status; - } - } - - // - // Capability parsed successfully. - // - ParsedConfig->Exists = TRUE; - } - - return EFI_SUCCESS; -} - - -/** - Accumulate the BAR type of a virtio-1.0 register block into a UINT64 - attribute map, such that the latter is suitable for enabling IO / MMIO - decoding with EFI_PCI_IO_PROTOCOL.Attributes(). - - @param[in] Config The "fat pointer" structure that identifies the - register block. It is allowed for the register - block not to exist. - - @param[in,out] Attributes On output, if the register block exists, - EFI_PCI_IO_ATTRIBUTE_MEMORY or - EFI_PCI_IO_ATTRIBUTE_IO is OR-ed into Attributes, - according to the register block's BAR type. -**/ -STATIC -VOID -UpdateAttributes ( - IN VIRTIO_1_0_CONFIG *Config, - IN OUT UINT64 *Attributes - ) -{ - if (Config->Exists) { - *Attributes |= (Config->BarType == Virtio10BarTypeMem) ? - EFI_PCI_IO_ATTRIBUTE_MEMORY: - EFI_PCI_IO_ATTRIBUTE_IO; - } -} - - -// -// VIRTIO_DEVICE_PROTOCOL member functions -// - -STATIC -EFI_STATUS -EFIAPI -Virtio10GetDeviceFeatures ( - IN VIRTIO_DEVICE_PROTOCOL *This, - OUT UINT64 *DeviceFeatures - ) -{ - VIRTIO_1_0_DEV *Dev; - UINT32 Selector; - UINT32 Features32[2]; - - Dev = VIRTIO_1_0_FROM_VIRTIO_DEVICE (This); - - for (Selector = 0; Selector < 2; ++Selector) { - EFI_STATUS Status; - - // - // Select the low or high half of the features. - // - Status = Virtio10Transfer (Dev->PciIo, &Dev->CommonConfig, TRUE, - OFFSET_OF (VIRTIO_PCI_COMMON_CFG, DeviceFeatureSelect), - sizeof Selector, &Selector); - if (EFI_ERROR (Status)) { - return Status; - } - - // - // Fetch that half. - // - Status = Virtio10Transfer (Dev->PciIo, &Dev->CommonConfig, FALSE, - OFFSET_OF (VIRTIO_PCI_COMMON_CFG, DeviceFeature), - sizeof Features32[Selector], &Features32[Selector]); - if (EFI_ERROR (Status)) { - return Status; - } - } - - *DeviceFeatures = LShiftU64 (Features32[1], 32) | Features32[0]; - return EFI_SUCCESS; -} - - -STATIC -EFI_STATUS -EFIAPI -Virtio10SetGuestFeatures ( - IN VIRTIO_DEVICE_PROTOCOL *This, - IN UINT64 Features - ) -{ - VIRTIO_1_0_DEV *Dev; - UINT32 Selector; - UINT32 Features32[2]; - - Dev = VIRTIO_1_0_FROM_VIRTIO_DEVICE (This); - - Features32[0] = (UINT32)Features; - Features32[1] = (UINT32)RShiftU64 (Features, 32); - - for (Selector = 0; Selector < 2; ++Selector) { - EFI_STATUS Status; - - // - // Select the low or high half of the features. - // - Status = Virtio10Transfer (Dev->PciIo, &Dev->CommonConfig, TRUE, - OFFSET_OF (VIRTIO_PCI_COMMON_CFG, DriverFeatureSelect), - sizeof Selector, &Selector); - if (EFI_ERROR (Status)) { - return Status; - } - - // - // Write that half. - // - Status = Virtio10Transfer (Dev->PciIo, &Dev->CommonConfig, TRUE, - OFFSET_OF (VIRTIO_PCI_COMMON_CFG, DriverFeature), - sizeof Features32[Selector], &Features32[Selector]); - if (EFI_ERROR (Status)) { - return Status; - } - } - - return EFI_SUCCESS; -} - - -STATIC -EFI_STATUS -EFIAPI -Virtio10SetQueueAddress ( - IN VIRTIO_DEVICE_PROTOCOL *This, - IN VRING *Ring - ) -{ - VIRTIO_1_0_DEV *Dev; - EFI_STATUS Status; - UINT64 Address; - UINT16 Enable; - - Dev = VIRTIO_1_0_FROM_VIRTIO_DEVICE (This); - - Address = (UINTN)Ring->Desc; - Status = Virtio10Transfer (Dev->PciIo, &Dev->CommonConfig, TRUE, - OFFSET_OF (VIRTIO_PCI_COMMON_CFG, QueueDesc), - sizeof Address, &Address); - if (EFI_ERROR (Status)) { - return Status; - } - - Address = (UINTN)Ring->Avail.Flags; - Status = Virtio10Transfer (Dev->PciIo, &Dev->CommonConfig, TRUE, - OFFSET_OF (VIRTIO_PCI_COMMON_CFG, QueueAvail), - sizeof Address, &Address); - if (EFI_ERROR (Status)) { - return Status; - } - - Address = (UINTN)Ring->Used.Flags; - Status = Virtio10Transfer (Dev->PciIo, &Dev->CommonConfig, TRUE, - OFFSET_OF (VIRTIO_PCI_COMMON_CFG, QueueUsed), - sizeof Address, &Address); - if (EFI_ERROR (Status)) { - return Status; - } - - Enable = 1; - Status = Virtio10Transfer (Dev->PciIo, &Dev->CommonConfig, TRUE, - OFFSET_OF (VIRTIO_PCI_COMMON_CFG, QueueEnable), - sizeof Enable, &Enable); - return Status; -} - - -STATIC -EFI_STATUS -EFIAPI -Virtio10SetQueueSel ( - IN VIRTIO_DEVICE_PROTOCOL *This, - IN UINT16 Index - ) -{ - VIRTIO_1_0_DEV *Dev; - EFI_STATUS Status; - - Dev = VIRTIO_1_0_FROM_VIRTIO_DEVICE (This); - - Status = Virtio10Transfer (Dev->PciIo, &Dev->CommonConfig, TRUE, - OFFSET_OF (VIRTIO_PCI_COMMON_CFG, QueueSelect), - sizeof Index, &Index); - return Status; -} - - -STATIC -EFI_STATUS -EFIAPI -Virtio10SetQueueNotify ( - IN VIRTIO_DEVICE_PROTOCOL *This, - IN UINT16 Index - ) -{ - VIRTIO_1_0_DEV *Dev; - EFI_STATUS Status; - UINT16 SavedQueueSelect; - UINT16 NotifyOffset; - - Dev = VIRTIO_1_0_FROM_VIRTIO_DEVICE (This); - - // - // Read NotifyOffset first. NotifyOffset is queue specific, so we have - // to stash & restore the current queue selector around it. - // - // So, start with saving the current queue selector. - // - Status = Virtio10Transfer (Dev->PciIo, &Dev->CommonConfig, FALSE, - OFFSET_OF (VIRTIO_PCI_COMMON_CFG, QueueSelect), - sizeof SavedQueueSelect, &SavedQueueSelect); - if (EFI_ERROR (Status)) { - return Status; - } - - // - // Select the requested queue. - // - Status = Virtio10Transfer (Dev->PciIo, &Dev->CommonConfig, TRUE, - OFFSET_OF (VIRTIO_PCI_COMMON_CFG, QueueSelect), - sizeof Index, &Index); - if (EFI_ERROR (Status)) { - return Status; - } - - // - // Read the QueueNotifyOff field. - // - Status = Virtio10Transfer (Dev->PciIo, &Dev->CommonConfig, FALSE, - OFFSET_OF (VIRTIO_PCI_COMMON_CFG, QueueNotifyOff), - sizeof NotifyOffset, &NotifyOffset); - if (EFI_ERROR (Status)) { - return Status; - } - - // - // Re-select the original queue. - // - Status = Virtio10Transfer (Dev->PciIo, &Dev->CommonConfig, TRUE, - OFFSET_OF (VIRTIO_PCI_COMMON_CFG, QueueSelect), - sizeof SavedQueueSelect, &SavedQueueSelect); - if (EFI_ERROR (Status)) { - return Status; - } - - // - // We can now kick the queue. - // - Status = Virtio10Transfer (Dev->PciIo, &Dev->NotifyConfig, TRUE, - NotifyOffset * Dev->NotifyOffsetMultiplier, - sizeof Index, &Index); - return Status; -} - - -STATIC -EFI_STATUS -EFIAPI -Virtio10SetQueueAlign ( - IN VIRTIO_DEVICE_PROTOCOL *This, - IN UINT32 Alignment - ) -{ - return (Alignment == EFI_PAGE_SIZE) ? EFI_SUCCESS : EFI_UNSUPPORTED; -} - - -STATIC -EFI_STATUS -EFIAPI -Virtio10SetPageSize ( - IN VIRTIO_DEVICE_PROTOCOL *This, - IN UINT32 PageSize - ) -{ - return (PageSize == EFI_PAGE_SIZE) ? EFI_SUCCESS : EFI_UNSUPPORTED; -} - - -STATIC -EFI_STATUS -EFIAPI -Virtio10GetQueueNumMax ( - IN VIRTIO_DEVICE_PROTOCOL *This, - OUT UINT16 *QueueNumMax - ) -{ - VIRTIO_1_0_DEV *Dev; - EFI_STATUS Status; - - Dev = VIRTIO_1_0_FROM_VIRTIO_DEVICE (This); - - Status = Virtio10Transfer (Dev->PciIo, &Dev->CommonConfig, FALSE, - OFFSET_OF (VIRTIO_PCI_COMMON_CFG, QueueSize), - sizeof *QueueNumMax, QueueNumMax); - return Status; -} - - -STATIC -EFI_STATUS -EFIAPI -Virtio10SetQueueNum ( - IN VIRTIO_DEVICE_PROTOCOL *This, - IN UINT16 QueueSize - ) -{ - EFI_STATUS Status; - UINT16 CurrentSize; - - // - // This member function is required for VirtIo MMIO, and a no-op in - // VirtIo PCI 0.9.5. In VirtIo 1.0, drivers can theoretically use this - // member to reduce memory consumption, but none of our drivers do. So - // just check that they set the size that is already in effect. - // - Status = Virtio10GetQueueNumMax (This, &CurrentSize); - if (EFI_ERROR (Status)) { - return Status; - } - return (CurrentSize == QueueSize) ? EFI_SUCCESS : EFI_UNSUPPORTED; -} - - -STATIC -EFI_STATUS -EFIAPI -Virtio10GetDeviceStatus ( - IN VIRTIO_DEVICE_PROTOCOL *This, - OUT UINT8 *DeviceStatus - ) -{ - VIRTIO_1_0_DEV *Dev; - EFI_STATUS Status; - - Dev = VIRTIO_1_0_FROM_VIRTIO_DEVICE (This); - - Status = Virtio10Transfer (Dev->PciIo, &Dev->CommonConfig, FALSE, - OFFSET_OF (VIRTIO_PCI_COMMON_CFG, DeviceStatus), - sizeof *DeviceStatus, DeviceStatus); - return Status; -} - - -STATIC -EFI_STATUS -EFIAPI -Virtio10SetDeviceStatus ( - IN VIRTIO_DEVICE_PROTOCOL *This, - IN UINT8 DeviceStatus - ) -{ - VIRTIO_1_0_DEV *Dev; - EFI_STATUS Status; - - Dev = VIRTIO_1_0_FROM_VIRTIO_DEVICE (This); - - Status = Virtio10Transfer (Dev->PciIo, &Dev->CommonConfig, TRUE, - OFFSET_OF (VIRTIO_PCI_COMMON_CFG, DeviceStatus), - sizeof DeviceStatus, &DeviceStatus); - return Status; -} - - -STATIC -EFI_STATUS -EFIAPI -Virtio10WriteDevice ( - IN VIRTIO_DEVICE_PROTOCOL *This, - IN UINTN FieldOffset, - IN UINTN FieldSize, - IN UINT64 Value - ) -{ - VIRTIO_1_0_DEV *Dev; - EFI_STATUS Status; - - Dev = VIRTIO_1_0_FROM_VIRTIO_DEVICE (This); - - Status = Virtio10Transfer (Dev->PciIo, &Dev->SpecificConfig, TRUE, - FieldOffset, FieldSize, &Value); - return Status; -} - - -STATIC -EFI_STATUS -EFIAPI -Virtio10ReadDevice ( - IN VIRTIO_DEVICE_PROTOCOL *This, - IN UINTN FieldOffset, - IN UINTN FieldSize, - IN UINTN BufferSize, - OUT VOID *Buffer - ) -{ - VIRTIO_1_0_DEV *Dev; - EFI_STATUS Status; - - if (FieldSize != BufferSize) { - return EFI_INVALID_PARAMETER; - } - - Dev = VIRTIO_1_0_FROM_VIRTIO_DEVICE (This); - - Status = Virtio10Transfer (Dev->PciIo, &Dev->SpecificConfig, FALSE, - FieldOffset, FieldSize, Buffer); - return Status; -} - - -STATIC CONST VIRTIO_DEVICE_PROTOCOL mVirtIoTemplate = { - VIRTIO_SPEC_REVISION (1, 0, 0), - 0, // SubSystemDeviceId, filled in dynamically - Virtio10GetDeviceFeatures, - Virtio10SetGuestFeatures, - Virtio10SetQueueAddress, - Virtio10SetQueueSel, - Virtio10SetQueueNotify, - Virtio10SetQueueAlign, - Virtio10SetPageSize, - Virtio10GetQueueNumMax, - Virtio10SetQueueNum, - Virtio10GetDeviceStatus, - Virtio10SetDeviceStatus, - Virtio10WriteDevice, - Virtio10ReadDevice -}; - - -// -// EFI_DRIVER_BINDING_PROTOCOL member functions -// - -STATIC -EFI_STATUS -EFIAPI -Virtio10BindingSupported ( - 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; - - Status = gBS->OpenProtocol (DeviceHandle, &gEfiPciIoProtocolGuid, - (VOID **)&PciIo, This->DriverBindingHandle, - DeviceHandle, EFI_OPEN_PROTOCOL_BY_DRIVER); - if (EFI_ERROR (Status)) { - return Status; - } - - Status = PciIo->Pci.Read (PciIo, EfiPciIoWidthUint32, 0, - sizeof Pci / sizeof (UINT32), &Pci); - if (EFI_ERROR (Status)) { - goto CloseProtocol; - } - - Status = EFI_UNSUPPORTED; - // - // Recognize non-transitional modern devices. Also, we'll have to parse the - // PCI capability list, so make sure the CapabilityPtr field will be valid. - // - if (Pci.Hdr.VendorId == VIRTIO_VENDOR_ID && - Pci.Hdr.DeviceId >= 0x1040 && - Pci.Hdr.DeviceId <= 0x107F && - Pci.Hdr.RevisionID >= 0x01 && - Pci.Device.SubsystemID >= 0x40 && - (Pci.Hdr.Status & EFI_PCI_STATUS_CAPABILITY) != 0) { - // - // The virtio-vga device is special. It can be driven both as a VGA device - // with a linear framebuffer, and through its underlying, modern, - // virtio-gpu-pci device, which has no linear framebuffer itself. For - // compatibility with guest OSes that insist on inheriting a linear - // framebuffer from the firmware, we should leave virtio-vga to - // QemuVideoDxe, and support only virtio-gpu-pci here. - // - // Both virtio-vga and virtio-gpu-pci have DeviceId 0x1050, but only the - // former has device class PCI_CLASS_DISPLAY_VGA. - // - if (Pci.Hdr.DeviceId != 0x1050 || !IS_PCI_VGA (&Pci)) { - Status = EFI_SUCCESS; - } - } - -CloseProtocol: - gBS->CloseProtocol (DeviceHandle, &gEfiPciIoProtocolGuid, - This->DriverBindingHandle, DeviceHandle); - - return Status; -} - - -STATIC -EFI_STATUS -EFIAPI -Virtio10BindingStart ( - IN EFI_DRIVER_BINDING_PROTOCOL *This, - IN EFI_HANDLE DeviceHandle, - IN EFI_DEVICE_PATH_PROTOCOL *RemainingDevicePath - ) -{ - VIRTIO_1_0_DEV *Device; - EFI_STATUS Status; - PCI_TYPE00 Pci; - UINT64 SetAttributes; - - Device = AllocateZeroPool (sizeof *Device); - if (Device == NULL) { - return EFI_OUT_OF_RESOURCES; - } - - Device->Signature = VIRTIO_1_0_SIGNATURE; - CopyMem (&Device->VirtIo, &mVirtIoTemplate, sizeof mVirtIoTemplate); - - Status = gBS->OpenProtocol (DeviceHandle, &gEfiPciIoProtocolGuid, - (VOID **)&Device->PciIo, This->DriverBindingHandle, - DeviceHandle, EFI_OPEN_PROTOCOL_BY_DRIVER); - if (EFI_ERROR (Status)) { - goto FreeDevice; - } - - Status = Device->PciIo->Pci.Read (Device->PciIo, EfiPciIoWidthUint32, 0, - sizeof Pci / sizeof (UINT32), &Pci); - if (EFI_ERROR (Status)) { - goto ClosePciIo; - } - - Device->VirtIo.SubSystemDeviceId = Pci.Hdr.DeviceId - 0x1040; - - Status = ParseCapabilities (Device, Pci.Device.CapabilityPtr); - if (EFI_ERROR (Status)) { - goto ClosePciIo; - } - - Status = Device->PciIo->Attributes (Device->PciIo, - EfiPciIoAttributeOperationGet, 0, - &Device->OriginalPciAttributes); - if (EFI_ERROR (Status)) { - goto ClosePciIo; - } - - SetAttributes = 0; - UpdateAttributes (&Device->CommonConfig, &SetAttributes); - UpdateAttributes (&Device->NotifyConfig, &SetAttributes); - UpdateAttributes (&Device->SpecificConfig, &SetAttributes); - Status = Device->PciIo->Attributes (Device->PciIo, - EfiPciIoAttributeOperationEnable, SetAttributes, - NULL); - if (EFI_ERROR (Status)) { - goto ClosePciIo; - } - - Status = gBS->InstallProtocolInterface (&DeviceHandle, - &gVirtioDeviceProtocolGuid, EFI_NATIVE_INTERFACE, - &Device->VirtIo); - if (EFI_ERROR (Status)) { - goto RestorePciAttributes; - } - - return EFI_SUCCESS; - -RestorePciAttributes: - Device->PciIo->Attributes (Device->PciIo, EfiPciIoAttributeOperationSet, - Device->OriginalPciAttributes, NULL); - -ClosePciIo: - gBS->CloseProtocol (DeviceHandle, &gEfiPciIoProtocolGuid, - This->DriverBindingHandle, DeviceHandle); - -FreeDevice: - FreePool (Device); - - return Status; -} - - -STATIC -EFI_STATUS -EFIAPI -Virtio10BindingStop ( - IN EFI_DRIVER_BINDING_PROTOCOL *This, - IN EFI_HANDLE DeviceHandle, - IN UINTN NumberOfChildren, - IN EFI_HANDLE *ChildHandleBuffer - ) -{ - EFI_STATUS Status; - VIRTIO_DEVICE_PROTOCOL *VirtIo; - VIRTIO_1_0_DEV *Device; - - Status = gBS->OpenProtocol (DeviceHandle, &gVirtioDeviceProtocolGuid, - (VOID **)&VirtIo, This->DriverBindingHandle, - DeviceHandle, EFI_OPEN_PROTOCOL_GET_PROTOCOL); - if (EFI_ERROR (Status)) { - return Status; - } - - Device = VIRTIO_1_0_FROM_VIRTIO_DEVICE (VirtIo); - - Status = gBS->UninstallProtocolInterface (DeviceHandle, - &gVirtioDeviceProtocolGuid, &Device->VirtIo); - if (EFI_ERROR (Status)) { - return Status; - } - - Device->PciIo->Attributes (Device->PciIo, EfiPciIoAttributeOperationSet, - Device->OriginalPciAttributes, NULL); - gBS->CloseProtocol (DeviceHandle, &gEfiPciIoProtocolGuid, - This->DriverBindingHandle, DeviceHandle); - FreePool (Device); - - return EFI_SUCCESS; -} - - -STATIC EFI_DRIVER_BINDING_PROTOCOL mDriverBinding = { - &Virtio10BindingSupported, - &Virtio10BindingStart, - &Virtio10BindingStop, - 0x10, // Version - NULL, // ImageHandle, to be overwritten - NULL // DriverBindingHandle, to be overwritten -}; - - -// -// EFI_COMPONENT_NAME_PROTOCOL and EFI_COMPONENT_NAME2_PROTOCOL -// implementations -// - -STATIC -EFI_UNICODE_STRING_TABLE mDriverNameTable[] = { - { "eng;en", L"Virtio 1.0 PCI Driver" }, - { NULL, NULL } -}; - -STATIC -EFI_COMPONENT_NAME_PROTOCOL mComponentName; - -STATIC -EFI_STATUS -EFIAPI -Virtio10GetDriverName ( - IN EFI_COMPONENT_NAME_PROTOCOL *This, - IN CHAR8 *Language, - OUT CHAR16 **DriverName - ) -{ - return LookupUnicodeString2 ( - Language, - This->SupportedLanguages, - mDriverNameTable, - DriverName, - (BOOLEAN)(This == &mComponentName) // Iso639Language - ); -} - -STATIC -EFI_STATUS -EFIAPI -Virtio10GetDeviceName ( - 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 mComponentName = { - &Virtio10GetDriverName, - &Virtio10GetDeviceName, - "eng" -}; - -STATIC -EFI_COMPONENT_NAME2_PROTOCOL mComponentName2 = { - (EFI_COMPONENT_NAME2_GET_DRIVER_NAME) &Virtio10GetDriverName, - (EFI_COMPONENT_NAME2_GET_CONTROLLER_NAME) &Virtio10GetDeviceName, - "en" -}; - - -// -// Entry point of this driver -// - -EFI_STATUS -EFIAPI -Virtio10EntryPoint ( - IN EFI_HANDLE ImageHandle, - IN EFI_SYSTEM_TABLE *SystemTable - ) -{ - return EfiLibInstallDriverBindingComponentName2 ( - ImageHandle, - SystemTable, - &mDriverBinding, - ImageHandle, - &mComponentName, - &mComponentName2 - ); -} diff --git a/OvmfPkg/Virtio10Dxe/Virtio10.h b/OvmfPkg/Virtio10Dxe/Virtio10.h deleted file mode 100644 index 2fbe27f1cf..0000000000 --- a/OvmfPkg/Virtio10Dxe/Virtio10.h +++ /dev/null @@ -1,56 +0,0 @@ -/** @file - Private definitions of the VirtIo 1.0 driver. - - Copyright (C) 2016, 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_1_0_DXE_H_ -#define _VIRTIO_1_0_DXE_H_ - -#include -#include - -#define VIRTIO_1_0_SIGNATURE SIGNATURE_32 ('V', 'I', 'O', '1') - -// -// Type of the PCI BAR that contains a VirtIo 1.0 config structure. -// -typedef enum { - Virtio10BarTypeMem, - Virtio10BarTypeIo -} VIRTIO_1_0_BAR_TYPE; - -// -// The type below defines the access to a VirtIo 1.0 config structure. -// -typedef struct { - BOOLEAN Exists; // The device exposes this structure - VIRTIO_1_0_BAR_TYPE BarType; - UINT8 Bar; - UINT32 Offset; // Offset into BAR where structure starts - UINT32 Length; // Length of structure in BAR. -} VIRTIO_1_0_CONFIG; - -typedef struct { - UINT32 Signature; - VIRTIO_DEVICE_PROTOCOL VirtIo; - EFI_PCI_IO_PROTOCOL *PciIo; - UINT64 OriginalPciAttributes; - VIRTIO_1_0_CONFIG CommonConfig; // Common settings - VIRTIO_1_0_CONFIG NotifyConfig; // Notifications - UINT32 NotifyOffsetMultiplier; - VIRTIO_1_0_CONFIG SpecificConfig; // Device specific settings -} VIRTIO_1_0_DEV; - -#define VIRTIO_1_0_FROM_VIRTIO_DEVICE(Device) \ - CR (Device, VIRTIO_1_0_DEV, VirtIo, VIRTIO_1_0_SIGNATURE) - -#endif // _VIRTIO_1_0_DXE_H_ diff --git a/OvmfPkg/Virtio10Dxe/Virtio10.inf b/OvmfPkg/Virtio10Dxe/Virtio10.inf deleted file mode 100644 index f868d1cfc4..0000000000 --- a/OvmfPkg/Virtio10Dxe/Virtio10.inf +++ /dev/null @@ -1,40 +0,0 @@ -## @file -# A non-transitional driver for VirtIo 1.0 PCI devices. -# -# Copyright (C) 2016, 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 = Virtio10 - FILE_GUID = 0170F60C-1D40-4651-956D-F0BD9879D527 - MODULE_TYPE = UEFI_DRIVER - VERSION_STRING = 1.0 - ENTRY_POINT = Virtio10EntryPoint - -[Sources] - Virtio10.c - -[Packages] - MdePkg/MdePkg.dec - OvmfPkg/OvmfPkg.dec - -[LibraryClasses] - BaseMemoryLib - DebugLib - MemoryAllocationLib - UefiBootServicesTableLib - UefiDriverEntryPoint - UefiLib - -[Protocols] - gEfiPciIoProtocolGuid ## TO_START - gVirtioDeviceProtocolGuid ## BY_START diff --git a/OvmfPkg/VirtioBlkDxe/VirtioBlk.c b/OvmfPkg/VirtioBlkDxe/VirtioBlk.c deleted file mode 100644 index 3ce72281c2..0000000000 --- a/OvmfPkg/VirtioBlkDxe/VirtioBlk.c +++ /dev/null @@ -1,1158 +0,0 @@ -/** @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 - 2016, Intel Corporation. All rights reserved.
- - This program and the accompanying materials are licensed and made available - under the terms and conditions of the BSD License which accompanies this - distribution. The full text of the license may be found at - http://opensource.org/licenses/bsd-license.php - - THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, WITHOUT - WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. - -**/ - -#include -#include -#include -#include -#include -#include -#include - -#include "VirtioBlk.h" - -/** - - Convenience macros to read and write region 0 IO space elements of the - virtio-blk device, for configuration purposes. - - The following macros make it possible to specify only the "core parameters" - for such accesses and to derive the rest. By the time VIRTIO_CFG_WRITE() - returns, the transaction will have been completed. - - @param[in] Dev Pointer to the VBLK_DEV structure whose VirtIo space - we're accessing. Dev->VirtIo must be valid. - - @param[in] Field A field name from VBLK_HDR, identifying the virtio-blk - configuration item to access. - - @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 Virtio->WriteDevice() / - Virtio->ReadDevice(). - -**/ - -#define VIRTIO_CFG_WRITE(Dev, Field, Value) ((Dev)->VirtIo->WriteDevice ( \ - (Dev)->VirtIo, \ - OFFSET_OF_VBLK (Field), \ - SIZE_OF_VBLK (Field), \ - (Value) \ - )) - -#define VIRTIO_CFG_READ(Dev, Field, Pointer) ((Dev)->VirtIo->ReadDevice ( \ - (Dev)->VirtIo, \ - 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 VirtIo 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->VirtIo, 0, &Dev->Ring, &Indices, - NULL) == 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 - - @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 discovery, we do not support - the device. - - @return Error codes from the OpenProtocol() boot service or - the VirtIo protocol. - -**/ - -EFI_STATUS -EFIAPI -VirtioBlkDriverBindingSupported ( - IN EFI_DRIVER_BINDING_PROTOCOL *This, - IN EFI_HANDLE DeviceHandle, - IN EFI_DEVICE_PATH_PROTOCOL *RemainingDevicePath - ) -{ - EFI_STATUS Status; - VIRTIO_DEVICE_PROTOCOL *VirtIo; - - // - // Attempt to open the device with the VirtIo set of interfaces. On success, - // the protocol is "instantiated" for the VirtIo device. Covers duplicate - // open attempts (EFI_ALREADY_STARTED). - // - Status = gBS->OpenProtocol ( - DeviceHandle, // candidate device - &gVirtioDeviceProtocolGuid, // for generic VirtIo access - (VOID **)&VirtIo, // handle to instantiate - This->DriverBindingHandle, // requestor driver identity - DeviceHandle, // ControllerHandle, according to - // the UEFI Driver Model - EFI_OPEN_PROTOCOL_BY_DRIVER // get exclusive VirtIo access to - // the device; to be released - ); - if (EFI_ERROR (Status)) { - return Status; - } - - if (VirtIo->SubSystemDeviceId != VIRTIO_SUBSYSTEM_BLOCK_DEVICE) { - Status = EFI_UNSUPPORTED; - } - - // - // We needed VirtIo access only transitorily, to see whether we support the - // device or not. - // - gBS->CloseProtocol (DeviceHandle, &gVirtioDeviceProtocolGuid, - 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->VirtIo's validity (ie. working IO - access to the underlying virtio-blk 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; - - UINT64 Features; - UINT64 NumSectors; - UINT32 BlockSize; - UINT8 PhysicalBlockExp; - UINT8 AlignmentOffset; - UINT32 OptIoSize; - UINT16 QueueSize; - - PhysicalBlockExp = 0; - AlignmentOffset = 0; - OptIoSize = 0; - - // - // Execute virtio-0.9.5, 2.2.1 Device Initialization Sequence. - // - NextDevStat = 0; // step 1 -- reset device - Status = Dev->VirtIo->SetDeviceStatus (Dev->VirtIo, NextDevStat); - if (EFI_ERROR (Status)) { - goto Failed; - } - - NextDevStat |= VSTAT_ACK; // step 2 -- acknowledge device presence - Status = Dev->VirtIo->SetDeviceStatus (Dev->VirtIo, NextDevStat); - if (EFI_ERROR (Status)) { - goto Failed; - } - - NextDevStat |= VSTAT_DRIVER; // step 3 -- we know how to drive it - Status = Dev->VirtIo->SetDeviceStatus (Dev->VirtIo, NextDevStat); - if (EFI_ERROR (Status)) { - goto Failed; - } - - // - // Set Page Size - MMIO VirtIo Specific - // - Status = Dev->VirtIo->SetPageSize (Dev->VirtIo, EFI_PAGE_SIZE); - if (EFI_ERROR (Status)) { - goto Failed; - } - - // - // step 4a -- retrieve and validate features - // - Status = Dev->VirtIo->GetDeviceFeatures (Dev->VirtIo, &Features); - if (EFI_ERROR (Status)) { - goto Failed; - } - - Status = VIRTIO_CFG_READ (Dev, Capacity, &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, BlkSize, &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; - } - - if (Features & VIRTIO_BLK_F_TOPOLOGY) { - Status = VIRTIO_CFG_READ (Dev, Topology.PhysicalBlockExp, - &PhysicalBlockExp); - if (EFI_ERROR (Status)) { - goto Failed; - } - if (PhysicalBlockExp >= 32) { - Status = EFI_UNSUPPORTED; - goto Failed; - } - - Status = VIRTIO_CFG_READ (Dev, Topology.AlignmentOffset, &AlignmentOffset); - if (EFI_ERROR (Status)) { - goto Failed; - } - - Status = VIRTIO_CFG_READ (Dev, Topology.OptIoSize, &OptIoSize); - if (EFI_ERROR (Status)) { - goto Failed; - } - } - - Features &= VIRTIO_BLK_F_BLK_SIZE | VIRTIO_BLK_F_TOPOLOGY | VIRTIO_BLK_F_RO | - VIRTIO_BLK_F_FLUSH | VIRTIO_F_VERSION_1; - - // - // In virtio-1.0, feature negotiation is expected to complete before queue - // discovery, and the device can also reject the selected set of features. - // - if (Dev->VirtIo->Revision >= VIRTIO_SPEC_REVISION (1, 0, 0)) { - Status = Virtio10WriteFeatures (Dev->VirtIo, Features, &NextDevStat); - if (EFI_ERROR (Status)) { - goto Failed; - } - } - - // - // step 4b -- allocate virtqueue - // - Status = Dev->VirtIo->SetQueueSel (Dev->VirtIo, 0); - if (EFI_ERROR (Status)) { - goto Failed; - } - Status = Dev->VirtIo->GetQueueNumMax (Dev->VirtIo, &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; - } - - // - // Additional steps for MMIO: align the queue appropriately, and set the - // size. If anything fails from here on, we must release the ring resources. - // - Status = Dev->VirtIo->SetQueueNum (Dev->VirtIo, QueueSize); - if (EFI_ERROR (Status)) { - goto ReleaseQueue; - } - - Status = Dev->VirtIo->SetQueueAlign (Dev->VirtIo, EFI_PAGE_SIZE); - if (EFI_ERROR (Status)) { - goto ReleaseQueue; - } - - // - // step 4c -- Report GPFN (guest-physical frame number) of queue. - // - Status = Dev->VirtIo->SetQueueAddress (Dev->VirtIo, &Dev->Ring); - if (EFI_ERROR (Status)) { - goto ReleaseQueue; - } - - - // - // step 5 -- Report understood features. - // - if (Dev->VirtIo->Revision < VIRTIO_SPEC_REVISION (1, 0, 0)) { - Features &= ~(UINT64)VIRTIO_F_VERSION_1; - Status = Dev->VirtIo->SetGuestFeatures (Dev->VirtIo, Features); - if (EFI_ERROR (Status)) { - goto ReleaseQueue; - } - } - - // - // step 6 -- initialization complete - // - NextDevStat |= VSTAT_DRIVER_OK; - Status = Dev->VirtIo->SetDeviceStatus (Dev->VirtIo, NextDevStat); - if (EFI_ERROR (Status)) { - goto ReleaseQueue; - } - - // - // Populate the exported interface's attributes; see UEFI spec v2.4, 12.9 EFI - // Block I/O Protocol. - // - 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 = (BOOLEAN) ((Features & VIRTIO_BLK_F_RO) != 0); - Dev->BlockIoMedia.WriteCaching = (BOOLEAN) ((Features & VIRTIO_BLK_F_FLUSH) != 0); - Dev->BlockIoMedia.BlockSize = BlockSize; - Dev->BlockIoMedia.IoAlign = 0; - Dev->BlockIoMedia.LastBlock = DivU64x32 (NumSectors, - BlockSize / 512) - 1; - - DEBUG ((DEBUG_INFO, "%a: LbaSize=0x%x[B] NumBlocks=0x%Lx[Lba]\n", - __FUNCTION__, Dev->BlockIoMedia.BlockSize, - Dev->BlockIoMedia.LastBlock + 1)); - - if (Features & VIRTIO_BLK_F_TOPOLOGY) { - Dev->BlockIo.Revision = EFI_BLOCK_IO_PROTOCOL_REVISION3; - - Dev->BlockIoMedia.LowestAlignedLba = AlignmentOffset; - Dev->BlockIoMedia.LogicalBlocksPerPhysicalBlock = 1u << PhysicalBlockExp; - Dev->BlockIoMedia.OptimalTransferLengthGranularity = OptIoSize; - - DEBUG ((DEBUG_INFO, "%a: FirstAligned=0x%Lx[Lba] PhysBlkSize=0x%x[Lba]\n", - __FUNCTION__, Dev->BlockIoMedia.LowestAlignedLba, - Dev->BlockIoMedia.LogicalBlocksPerPhysicalBlock)); - DEBUG ((DEBUG_INFO, "%a: OptimalTransferLengthGranularity=0x%x[Lba]\n", - __FUNCTION__, Dev->BlockIoMedia.OptimalTransferLengthGranularity)); - } - 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. VirtIo access failure here should not mask the original error. - // - NextDevStat |= VSTAT_FAILED; - Dev->VirtIo->SetDeviceStatus (Dev->VirtIo, 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. - // - Dev->VirtIo->SetDeviceStatus (Dev->VirtIo, 0); - - VirtioRingUninit (&Dev->Ring); - - SetMem (&Dev->BlockIo, sizeof Dev->BlockIo, 0x00); - SetMem (&Dev->BlockIoMedia, sizeof Dev->BlockIoMedia, 0x00); -} - - -/** - - Event notification function enqueued by ExitBootServices(). - - @param[in] Event Event whose notification function is being invoked. - - @param[in] Context Pointer to the VBLK_DEV structure. - -**/ - -STATIC -VOID -EFIAPI -VirtioBlkExitBoot ( - IN EFI_EVENT Event, - IN VOID *Context - ) -{ - VBLK_DEV *Dev; - - // - // Reset the device. This causes the hypervisor to forget about the virtio - // ring. - // - // We allocated said ring in EfiBootServicesData type memory, and code - // executing after ExitBootServices() is permitted to overwrite it. - // - Dev = Context; - Dev->VirtIo->SetDeviceStatus (Dev->VirtIo, 0); -} - -/** - - After we've pronounced support for a specific device in - DriverBindingSupported(), we start managing said device (passed in by the - Driver Execution 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 device, it - is now accessible via EFI_BLOCK_IO_PROTOCOL. - - @retval EFI_OUT_OF_RESOURCES Memory allocation failed. - - @return Error codes from the OpenProtocol() boot - service, the VirtIo 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, &gVirtioDeviceProtocolGuid, - (VOID **)&Dev->VirtIo, This->DriverBindingHandle, - DeviceHandle, EFI_OPEN_PROTOCOL_BY_DRIVER); - if (EFI_ERROR (Status)) { - goto FreeVirtioBlk; - } - - // - // VirtIo access granted, configure virtio-blk device. - // - Status = VirtioBlkInit (Dev); - if (EFI_ERROR (Status)) { - goto CloseVirtIo; - } - - Status = gBS->CreateEvent (EVT_SIGNAL_EXIT_BOOT_SERVICES, TPL_CALLBACK, - &VirtioBlkExitBoot, Dev, &Dev->ExitBoot); - if (EFI_ERROR (Status)) { - goto UninitDev; - } - - // - // 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 CloseExitBoot; - } - - return EFI_SUCCESS; - -CloseExitBoot: - gBS->CloseEvent (Dev->ExitBoot); - -UninitDev: - VirtioBlkUninit (Dev); - -CloseVirtIo: - gBS->CloseProtocol (DeviceHandle, &gVirtioDeviceProtocolGuid, - 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; - } - - gBS->CloseEvent (Dev->ExitBoot); - - VirtioBlkUninit (Dev); - - gBS->CloseProtocol (DeviceHandle, &gVirtioDeviceProtocolGuid, - 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/OvmfPkg/VirtioBlkDxe/VirtioBlk.h b/OvmfPkg/VirtioBlkDxe/VirtioBlk.h deleted file mode 100644 index 6c402ca88e..0000000000 --- a/OvmfPkg/VirtioBlkDxe/VirtioBlk.h +++ /dev/null @@ -1,291 +0,0 @@ -/** @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 -#include -#include - -#include - - -#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 - VIRTIO_DEVICE_PROTOCOL *VirtIo; // DriverBindingStart 0 - EFI_EVENT ExitBoot; // 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 - - @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 discovery, we do not support - the device. - - @return Error codes from the OpenProtocol() boot service. - -**/ - -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 Execution 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 device, it - is now accessible via EFI_BLOCK_IO_PROTOCOL. - - @retval EFI_OUT_OF_RESOURCES Memory allocation failed. - - @return Error codes from the OpenProtocol() boot - service, 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/OvmfPkg/VirtioBlkDxe/VirtioBlk.inf b/OvmfPkg/VirtioBlkDxe/VirtioBlk.inf deleted file mode 100644 index d5975b74eb..0000000000 --- a/OvmfPkg/VirtioBlkDxe/VirtioBlk.inf +++ /dev/null @@ -1,42 +0,0 @@ -## @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 - gVirtioDeviceProtocolGuid ## TO_START diff --git a/OvmfPkg/VirtioGpuDxe/Commands.c b/OvmfPkg/VirtioGpuDxe/Commands.c deleted file mode 100644 index 962087cfec..0000000000 --- a/OvmfPkg/VirtioGpuDxe/Commands.c +++ /dev/null @@ -1,560 +0,0 @@ -/** @file - - VirtIo GPU initialization, and commands (primitives) for the GPU device. - - Copyright (C) 2016, 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 - -#include "VirtioGpu.h" - -/** - Configure the VirtIo GPU device that underlies VgpuDev. - - @param[in,out] VgpuDev The VGPU_DEV object to set up VirtIo messaging for. - On input, the caller is responsible for having - initialized VgpuDev->VirtIo. On output, VgpuDev->Ring - has been initialized, and synchronous VirtIo GPU - commands (primitives) can be submitted to the device. - - @retval EFI_SUCCESS VirtIo GPU configuration successful. - - @retval EFI_UNSUPPORTED The host-side configuration of the VirtIo GPU is not - supported by this driver. - - @retval Error codes from underlying functions. -**/ -EFI_STATUS -VirtioGpuInit ( - IN OUT VGPU_DEV *VgpuDev - ) -{ - UINT8 NextDevStat; - EFI_STATUS Status; - UINT64 Features; - UINT16 QueueSize; - - // - // Execute virtio-v1.0-cs04, 3.1.1 Driver Requirements: Device - // Initialization. - // - // 1. Reset the device. - // - NextDevStat = 0; - Status = VgpuDev->VirtIo->SetDeviceStatus (VgpuDev->VirtIo, NextDevStat); - if (EFI_ERROR (Status)) { - goto Failed; - } - - // - // 2. Set the ACKNOWLEDGE status bit [...] - // - NextDevStat |= VSTAT_ACK; - Status = VgpuDev->VirtIo->SetDeviceStatus (VgpuDev->VirtIo, NextDevStat); - if (EFI_ERROR (Status)) { - goto Failed; - } - - // - // 3. Set the DRIVER status bit [...] - // - NextDevStat |= VSTAT_DRIVER; - Status = VgpuDev->VirtIo->SetDeviceStatus (VgpuDev->VirtIo, NextDevStat); - if (EFI_ERROR (Status)) { - goto Failed; - } - - // - // 4. Read device feature bits... - // - Status = VgpuDev->VirtIo->GetDeviceFeatures (VgpuDev->VirtIo, &Features); - if (EFI_ERROR (Status)) { - goto Failed; - } - if ((Features & VIRTIO_F_VERSION_1) == 0) { - Status = EFI_UNSUPPORTED; - goto Failed; - } - // - // We only want the most basic 2D features. - // - Features &= VIRTIO_F_VERSION_1; - - // - // ... and write the subset of feature bits understood by the [...] driver to - // the device. [...] - // 5. Set the FEATURES_OK status bit. - // 6. Re-read device status to ensure the FEATURES_OK bit is still set [...] - // - Status = Virtio10WriteFeatures (VgpuDev->VirtIo, Features, &NextDevStat); - if (EFI_ERROR (Status)) { - goto Failed; - } - - // - // 7. Perform device-specific setup, including discovery of virtqueues for - // the device [...] - // - Status = VgpuDev->VirtIo->SetQueueSel (VgpuDev->VirtIo, - VIRTIO_GPU_CONTROL_QUEUE); - if (EFI_ERROR (Status)) { - goto Failed; - } - Status = VgpuDev->VirtIo->GetQueueNumMax (VgpuDev->VirtIo, &QueueSize); - if (EFI_ERROR (Status)) { - goto Failed; - } - - // - // We implement each VirtIo GPU command that we use with two descriptors: - // request, response. - // - if (QueueSize < 2) { - Status = EFI_UNSUPPORTED; - goto Failed; - } - - // - // [...] population of virtqueues [...] - // - Status = VirtioRingInit (QueueSize, &VgpuDev->Ring); - if (EFI_ERROR (Status)) { - goto Failed; - } - Status = VgpuDev->VirtIo->SetQueueAddress (VgpuDev->VirtIo, &VgpuDev->Ring); - if (EFI_ERROR (Status)) { - goto ReleaseQueue; - } - - // - // 8. Set the DRIVER_OK status bit. - // - NextDevStat |= VSTAT_DRIVER_OK; - Status = VgpuDev->VirtIo->SetDeviceStatus (VgpuDev->VirtIo, NextDevStat); - if (EFI_ERROR (Status)) { - goto ReleaseQueue; - } - - return EFI_SUCCESS; - -ReleaseQueue: - VirtioRingUninit (&VgpuDev->Ring); - -Failed: - // - // If any of these steps go irrecoverably wrong, the driver SHOULD set the - // FAILED status bit to indicate that it has given up on the device (it can - // reset the device later to restart if desired). [...] - // - // VirtIo access failure here should not mask the original error. - // - NextDevStat |= VSTAT_FAILED; - VgpuDev->VirtIo->SetDeviceStatus (VgpuDev->VirtIo, NextDevStat); - - return Status; -} - -/** - De-configure the VirtIo GPU device that underlies VgpuDev. - - @param[in,out] VgpuDev The VGPU_DEV object to tear down VirtIo messaging - for. On input, the caller is responsible for having - called VirtioGpuInit(). On output, VgpuDev->Ring has - been uninitialized; VirtIo GPU commands (primitives) - can no longer be submitted to the device. -**/ -VOID -VirtioGpuUninit ( - IN OUT VGPU_DEV *VgpuDev - ) -{ - // - // Resetting the VirtIo device makes it release its resources and forget its - // configuration. - // - VgpuDev->VirtIo->SetDeviceStatus (VgpuDev->VirtIo, 0); - VirtioRingUninit (&VgpuDev->Ring); -} - -/** - EFI_EVENT_NOTIFY function for the VGPU_DEV.ExitBoot event. It resets the - VirtIo device, causing it to release its resources and to forget its - configuration. - - This function may only be called (that is, VGPU_DEV.ExitBoot may only be - signaled) after VirtioGpuInit() returns and before VirtioGpuUninit() is - called. - - @param[in] Event Event whose notification function is being invoked. - - @param[in] Context Pointer to the associated VGPU_DEV object. -**/ -VOID -EFIAPI -VirtioGpuExitBoot ( - IN EFI_EVENT Event, - IN VOID *Context - ) -{ - VGPU_DEV *VgpuDev; - - VgpuDev = Context; - VgpuDev->VirtIo->SetDeviceStatus (VgpuDev->VirtIo, 0); -} - -/** - Internal utility function that sends a request to the VirtIo GPU device - model, awaits the answer from the host, and returns a status. - - @param[in,out] VgpuDev The VGPU_DEV object that represents the VirtIo GPU - device. The caller is responsible to have - successfully invoked VirtioGpuInit() on VgpuDev - previously, while VirtioGpuUninit() must not have - been called on VgpuDev. - - @param[in] RequestType The type of the request. The caller is responsible - for providing a VirtioGpuCmd* RequestType which, on - success, elicits a VirtioGpuRespOkNodata response - from the host. - - @param[in] Fence Whether to enable fencing for this request. Fencing - forces the host to complete the command before - producing a response. If Fence is TRUE, then - VgpuDev->FenceId is consumed, and incremented. - - @param[in,out] Header Pointer to the caller-allocated request object. The - request must start with VIRTIO_GPU_CONTROL_HEADER. - This function overwrites all fields of Header before - submitting the request to the host: - - - it sets Type from RequestType, - - - it sets Flags and FenceId based on Fence, - - - it zeroes CtxId and Padding. - - @param[in] RequestSize Size of the entire caller-allocated request object, - including the leading VIRTIO_GPU_CONTROL_HEADER. - - @retval EFI_SUCCESS Operation successful. - - @retval EFI_DEVICE_ERROR The host rejected the request. The host error - code has been logged on the EFI_D_ERROR level. - - @return Codes for unexpected errors in VirtIo - messaging. -**/ -STATIC -EFI_STATUS -VirtioGpuSendCommand ( - IN OUT VGPU_DEV *VgpuDev, - IN VIRTIO_GPU_CONTROL_TYPE RequestType, - IN BOOLEAN Fence, - IN OUT volatile VIRTIO_GPU_CONTROL_HEADER *Header, - IN UINTN RequestSize - ) -{ - DESC_INDICES Indices; - volatile VIRTIO_GPU_CONTROL_HEADER Response; - EFI_STATUS Status; - UINT32 ResponseSize; - - // - // Initialize Header. - // - Header->Type = RequestType; - if (Fence) { - Header->Flags = VIRTIO_GPU_FLAG_FENCE; - Header->FenceId = VgpuDev->FenceId++; - } else { - Header->Flags = 0; - Header->FenceId = 0; - } - Header->CtxId = 0; - Header->Padding = 0; - - ASSERT (RequestSize >= sizeof *Header); - ASSERT (RequestSize <= MAX_UINT32); - - // - // Compose the descriptor chain. - // - VirtioPrepare (&VgpuDev->Ring, &Indices); - VirtioAppendDesc (&VgpuDev->Ring, (UINTN)Header, (UINT32)RequestSize, - VRING_DESC_F_NEXT, &Indices); - VirtioAppendDesc (&VgpuDev->Ring, (UINTN)&Response, sizeof Response, - VRING_DESC_F_WRITE, &Indices); - - // - // Send the command. - // - Status = VirtioFlush (VgpuDev->VirtIo, VIRTIO_GPU_CONTROL_QUEUE, - &VgpuDev->Ring, &Indices, &ResponseSize); - if (EFI_ERROR (Status)) { - return Status; - } - - // - // Parse the response. - // - if (ResponseSize != sizeof Response) { - DEBUG ((EFI_D_ERROR, "%a: malformed response to Request=0x%x\n", - __FUNCTION__, (UINT32)RequestType)); - return EFI_PROTOCOL_ERROR; - } - - if (Response.Type == VirtioGpuRespOkNodata) { - return EFI_SUCCESS; - } - - DEBUG ((EFI_D_ERROR, "%a: Request=0x%x Response=0x%x\n", __FUNCTION__, - (UINT32)RequestType, Response.Type)); - return EFI_DEVICE_ERROR; -} - -/** - The following functions send requests to the VirtIo GPU device model, await - the answer from the host, and return a status. They share the following - interface details: - - @param[in,out] VgpuDev The VGPU_DEV object that represents the VirtIo GPU - device. The caller is responsible to have - successfully invoked VirtioGpuInit() on VgpuDev - previously, while VirtioGpuUninit() must not have - been called on VgpuDev. - - @retval EFI_INVALID_PARAMETER Invalid command-specific parameters were - detected by this driver. - - @retval EFI_SUCCESS Operation successful. - - @retval EFI_DEVICE_ERROR The host rejected the request. The host error - code has been logged on the EFI_D_ERROR level. - - @return Codes for unexpected errors in VirtIo - messaging. - - For the command-specific parameters, please consult the GPU Device section of - the VirtIo 1.0 specification (see references in - "OvmfPkg/Include/IndustryStandard/VirtioGpu.h"). -**/ -EFI_STATUS -VirtioGpuResourceCreate2d ( - IN OUT VGPU_DEV *VgpuDev, - IN UINT32 ResourceId, - IN VIRTIO_GPU_FORMATS Format, - IN UINT32 Width, - IN UINT32 Height - ) -{ - volatile VIRTIO_GPU_RESOURCE_CREATE_2D Request; - - if (ResourceId == 0) { - return EFI_INVALID_PARAMETER; - } - - Request.ResourceId = ResourceId; - Request.Format = (UINT32)Format; - Request.Width = Width; - Request.Height = Height; - - return VirtioGpuSendCommand ( - VgpuDev, - VirtioGpuCmdResourceCreate2d, - FALSE, // Fence - &Request.Header, - sizeof Request - ); -} - -EFI_STATUS -VirtioGpuResourceUnref ( - IN OUT VGPU_DEV *VgpuDev, - IN UINT32 ResourceId - ) -{ - volatile VIRTIO_GPU_RESOURCE_UNREF Request; - - if (ResourceId == 0) { - return EFI_INVALID_PARAMETER; - } - - Request.ResourceId = ResourceId; - Request.Padding = 0; - - return VirtioGpuSendCommand ( - VgpuDev, - VirtioGpuCmdResourceUnref, - FALSE, // Fence - &Request.Header, - sizeof Request - ); -} - -EFI_STATUS -VirtioGpuResourceAttachBacking ( - IN OUT VGPU_DEV *VgpuDev, - IN UINT32 ResourceId, - IN VOID *FirstBackingPage, - IN UINTN NumberOfPages - ) -{ - volatile VIRTIO_GPU_RESOURCE_ATTACH_BACKING Request; - - if (ResourceId == 0) { - return EFI_INVALID_PARAMETER; - } - - Request.ResourceId = ResourceId; - Request.NrEntries = 1; - Request.Entry.Addr = (UINTN)FirstBackingPage; - Request.Entry.Length = (UINT32)EFI_PAGES_TO_SIZE (NumberOfPages); - Request.Entry.Padding = 0; - - return VirtioGpuSendCommand ( - VgpuDev, - VirtioGpuCmdResourceAttachBacking, - FALSE, // Fence - &Request.Header, - sizeof Request - ); -} - -EFI_STATUS -VirtioGpuResourceDetachBacking ( - IN OUT VGPU_DEV *VgpuDev, - IN UINT32 ResourceId - ) -{ - volatile VIRTIO_GPU_RESOURCE_DETACH_BACKING Request; - - if (ResourceId == 0) { - return EFI_INVALID_PARAMETER; - } - - Request.ResourceId = ResourceId; - Request.Padding = 0; - - // - // In this case, we set Fence to TRUE, because after this function returns, - // the caller might reasonably want to repurpose the backing pages - // immediately. Thus we should ensure that the host releases all references - // to the backing pages before we return. - // - return VirtioGpuSendCommand ( - VgpuDev, - VirtioGpuCmdResourceDetachBacking, - TRUE, // Fence - &Request.Header, - sizeof Request - ); -} - -EFI_STATUS -VirtioGpuSetScanout ( - IN OUT VGPU_DEV *VgpuDev, - IN UINT32 X, - IN UINT32 Y, - IN UINT32 Width, - IN UINT32 Height, - IN UINT32 ScanoutId, - IN UINT32 ResourceId - ) -{ - volatile VIRTIO_GPU_SET_SCANOUT Request; - - // - // Unlike for most other commands, ResourceId=0 is valid; it - // is used to disable a scanout. - // - Request.Rectangle.X = X; - Request.Rectangle.Y = Y; - Request.Rectangle.Width = Width; - Request.Rectangle.Height = Height; - Request.ScanoutId = ScanoutId; - Request.ResourceId = ResourceId; - - return VirtioGpuSendCommand ( - VgpuDev, - VirtioGpuCmdSetScanout, - FALSE, // Fence - &Request.Header, - sizeof Request - ); -} - -EFI_STATUS -VirtioGpuTransferToHost2d ( - IN OUT VGPU_DEV *VgpuDev, - IN UINT32 X, - IN UINT32 Y, - IN UINT32 Width, - IN UINT32 Height, - IN UINT64 Offset, - IN UINT32 ResourceId - ) -{ - volatile VIRTIO_GPU_CMD_TRANSFER_TO_HOST_2D Request; - - if (ResourceId == 0) { - return EFI_INVALID_PARAMETER; - } - - Request.Rectangle.X = X; - Request.Rectangle.Y = Y; - Request.Rectangle.Width = Width; - Request.Rectangle.Height = Height; - Request.Offset = Offset; - Request.ResourceId = ResourceId; - Request.Padding = 0; - - return VirtioGpuSendCommand ( - VgpuDev, - VirtioGpuCmdTransferToHost2d, - FALSE, // Fence - &Request.Header, - sizeof Request - ); -} - -EFI_STATUS -VirtioGpuResourceFlush ( - IN OUT VGPU_DEV *VgpuDev, - IN UINT32 X, - IN UINT32 Y, - IN UINT32 Width, - IN UINT32 Height, - IN UINT32 ResourceId - ) -{ - volatile VIRTIO_GPU_RESOURCE_FLUSH Request; - - if (ResourceId == 0) { - return EFI_INVALID_PARAMETER; - } - - Request.Rectangle.X = X; - Request.Rectangle.Y = Y; - Request.Rectangle.Width = Width; - Request.Rectangle.Height = Height; - Request.ResourceId = ResourceId; - Request.Padding = 0; - - return VirtioGpuSendCommand ( - VgpuDev, - VirtioGpuCmdResourceFlush, - FALSE, // Fence - &Request.Header, - sizeof Request - ); -} diff --git a/OvmfPkg/VirtioGpuDxe/DriverBinding.c b/OvmfPkg/VirtioGpuDxe/DriverBinding.c deleted file mode 100644 index 33c1ad3b31..0000000000 --- a/OvmfPkg/VirtioGpuDxe/DriverBinding.c +++ /dev/null @@ -1,844 +0,0 @@ -/** @file - - Implement the Driver Binding Protocol and the Component Name 2 Protocol for - the Virtio GPU hybrid driver. - - Copyright (C) 2016, 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 -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#include "VirtioGpu.h" - -// -// The device path node that describes the Video Output Device Attributes for -// the single head (UEFI child handle) that we support. -// -// The ACPI_DISPLAY_ADR() macro corresponds to Table B-2, section "B.4.2 _DOD" -// in the ACPI 3.0b spec, or more recently, to Table B-379, section "B.3.2 -// _DOD" in the ACPI 6.0 spec. -// -STATIC CONST ACPI_ADR_DEVICE_PATH mAcpiAdr = { - { // Header - ACPI_DEVICE_PATH, // Type - ACPI_ADR_DP, // SubType - { sizeof mAcpiAdr, 0 }, // Length - }, - ACPI_DISPLAY_ADR ( // ADR - 1, // DeviceIdScheme: use the ACPI - // bit-field definitions - 0, // HeadId - 0, // NonVgaOutput - 1, // BiosCanDetect - 0, // VendorInfo - ACPI_ADR_DISPLAY_TYPE_EXTERNAL_DIGITAL, // Type - 0, // Port - 0 // Index - ) -}; - -// -// Component Name 2 Protocol implementation. -// -STATIC CONST EFI_UNICODE_STRING_TABLE mDriverNameTable[] = { - { "en", L"Virtio GPU Driver" }, - { NULL, NULL } -}; - -STATIC -EFI_STATUS -EFIAPI -VirtioGpuGetDriverName ( - IN EFI_COMPONENT_NAME2_PROTOCOL *This, - IN CHAR8 *Language, - OUT CHAR16 **DriverName - ) -{ - return LookupUnicodeString2 (Language, This->SupportedLanguages, - mDriverNameTable, DriverName, FALSE /* Iso639Language */); -} - -STATIC -EFI_STATUS -EFIAPI -VirtioGpuGetControllerName ( - IN EFI_COMPONENT_NAME2_PROTOCOL *This, - IN EFI_HANDLE ControllerHandle, - IN EFI_HANDLE ChildHandle OPTIONAL, - IN CHAR8 *Language, - OUT CHAR16 **ControllerName - ) -{ - EFI_STATUS Status; - VGPU_DEV *VgpuDev; - - // - // Look up the VGPU_DEV "protocol interface" on ControllerHandle. - // - Status = gBS->OpenProtocol (ControllerHandle, &gEfiCallerIdGuid, - (VOID **)&VgpuDev, gImageHandle, ControllerHandle, - EFI_OPEN_PROTOCOL_GET_PROTOCOL); - if (EFI_ERROR (Status)) { - return Status; - } - // - // Sanity check: if we found gEfiCallerIdGuid on ControllerHandle, then we - // keep its Virtio Device Protocol interface open BY_DRIVER. - // - ASSERT_EFI_ERROR (EfiTestManagedDevice (ControllerHandle, gImageHandle, - &gVirtioDeviceProtocolGuid)); - - if (ChildHandle == NULL) { - // - // The caller is querying the name of the VGPU_DEV controller. - // - return LookupUnicodeString2 (Language, This->SupportedLanguages, - VgpuDev->BusName, ControllerName, FALSE /* Iso639Language */); - } - - // - // Otherwise, the caller is looking for the name of the GOP child controller. - // Check if it is asking about the GOP child controller that we manage. (The - // condition below covers the case when we haven't produced the GOP child - // controller yet, or we've destroyed it since.) - // - if (VgpuDev->Child == NULL || ChildHandle != VgpuDev->Child->GopHandle) { - return EFI_UNSUPPORTED; - } - // - // Sanity check: our GOP child controller keeps the VGPU_DEV controller's - // Virtio Device Protocol interface open BY_CHILD_CONTROLLER. - // - ASSERT_EFI_ERROR (EfiTestChildHandle (ControllerHandle, ChildHandle, - &gVirtioDeviceProtocolGuid)); - - return LookupUnicodeString2 (Language, This->SupportedLanguages, - VgpuDev->Child->GopName, ControllerName, - FALSE /* Iso639Language */); -} - -STATIC CONST EFI_COMPONENT_NAME2_PROTOCOL mComponentName2 = { - VirtioGpuGetDriverName, - VirtioGpuGetControllerName, - "en" // SupportedLanguages (RFC 4646) -}; - -// -// Helper functions for the Driver Binding Protocol Implementation. -// -/** - Format the VGPU_DEV controller name, to be looked up and returned by - VirtioGpuGetControllerName(). - - @param[in] ControllerHandle The handle that identifies the VGPU_DEV - controller. - - @param[in] AgentHandle The handle of the agent that will attempt to - temporarily open the PciIo protocol. This is the - DriverBindingHandle member of the - EFI_DRIVER_BINDING_PROTOCOL whose Start() - function is calling this function. - - @param[in] DevicePath The device path that is installed on - ControllerHandle. - - @param[out] ControllerName A dynamically allocated unicode string that - unconditionally says "Virtio GPU Device", with a - PCI Segment:Bus:Device.Function location - optionally appended. The latter part is only - produced if DevicePath contains at least one - PciIo node; in that case, the most specific such - node is used for retrieving the location info. - The caller is responsible for freeing - ControllerName after use. - - @retval EFI_SUCCESS ControllerName has been formatted. - - @retval EFI_OUT_OF_RESOURCES Failed to allocate memory for ControllerName. -**/ -STATIC -EFI_STATUS -FormatVgpuDevName ( - IN EFI_HANDLE ControllerHandle, - IN EFI_HANDLE AgentHandle, - IN EFI_DEVICE_PATH_PROTOCOL *DevicePath, - OUT CHAR16 **ControllerName - ) -{ - EFI_HANDLE PciIoHandle; - EFI_PCI_IO_PROTOCOL *PciIo; - UINTN Segment, Bus, Device, Function; - STATIC CONST CHAR16 ControllerNameStem[] = L"Virtio GPU Device"; - UINTN ControllerNameSize; - - if (EFI_ERROR (gBS->LocateDevicePath (&gEfiPciIoProtocolGuid, &DevicePath, - &PciIoHandle)) || - EFI_ERROR (gBS->OpenProtocol (PciIoHandle, &gEfiPciIoProtocolGuid, - (VOID **)&PciIo, AgentHandle, ControllerHandle, - EFI_OPEN_PROTOCOL_GET_PROTOCOL)) || - EFI_ERROR (PciIo->GetLocation (PciIo, &Segment, &Bus, &Device, - &Function))) { - // - // Failed to retrieve location info, return verbatim copy of static string. - // - *ControllerName = AllocateCopyPool (sizeof ControllerNameStem, - ControllerNameStem); - return (*ControllerName == NULL) ? EFI_OUT_OF_RESOURCES : EFI_SUCCESS; - } - // - // Location info available, format ControllerName dynamically. - // - ControllerNameSize = sizeof ControllerNameStem + // includes L'\0' - sizeof (CHAR16) * (1 + 4 + // Segment - 1 + 2 + // Bus - 1 + 2 + // Device - 1 + 1 // Function - ); - *ControllerName = AllocatePool (ControllerNameSize); - if (*ControllerName == NULL) { - return EFI_OUT_OF_RESOURCES; - } - - UnicodeSPrintAsciiFormat (*ControllerName, ControllerNameSize, - "%s %04x:%02x:%02x.%x", ControllerNameStem, (UINT32)Segment, (UINT32)Bus, - (UINT32)Device, (UINT32)Function); - return EFI_SUCCESS; -} - -/** - Dynamically allocate and initialize the VGPU_GOP child object within an - otherwise configured parent VGPU_DEV object. - - This function adds a BY_CHILD_CONTROLLER reference to ParentBusController's - VIRTIO_DEVICE_PROTOCOL interface. - - @param[in,out] ParentBus The pre-initialized VGPU_DEV object that the - newly created VGPU_GOP object will be the - child of. - - @param[in] ParentDevicePath The device path protocol instance that is - installed on ParentBusController. - - @param[in] ParentBusController The UEFI controller handle on which the - ParentBus VGPU_DEV object and the - ParentDevicePath device path protocol are - installed. - - @param[in] DriverBindingHandle The DriverBindingHandle member of - EFI_DRIVER_BINDING_PROTOCOL whose Start() - function is calling this function. It is - passed as AgentHandle to gBS->OpenProtocol() - when creating the BY_CHILD_CONTROLLER - reference. - - @retval EFI_SUCCESS ParentBus->Child has been created and - populated, and ParentBus->Child->GopHandle now - references ParentBusController->VirtIo - BY_CHILD_CONTROLLER. - - @retval EFI_OUT_OF_RESOURCES Memory allocation failed. - - @return Error codes from underlying functions. -**/ -STATIC -EFI_STATUS -InitVgpuGop ( - IN OUT VGPU_DEV *ParentBus, - IN EFI_DEVICE_PATH_PROTOCOL *ParentDevicePath, - IN EFI_HANDLE ParentBusController, - IN EFI_HANDLE DriverBindingHandle - ) -{ - VGPU_GOP *VgpuGop; - EFI_STATUS Status; - CHAR16 *ParentBusName; - STATIC CONST CHAR16 NameSuffix[] = L" Head #0"; - UINTN NameSize; - CHAR16 *Name; - EFI_TPL OldTpl; - VOID *ParentVirtIo; - - VgpuGop = AllocateZeroPool (sizeof *VgpuGop); - if (VgpuGop == NULL) { - return EFI_OUT_OF_RESOURCES; - } - - VgpuGop->Signature = VGPU_GOP_SIG; - VgpuGop->ParentBus = ParentBus; - - // - // Format a human-readable controller name for VGPU_GOP, and stash it for - // VirtioGpuGetControllerName() to look up. We simply append NameSuffix to - // ParentBus->BusName. - // - Status = LookupUnicodeString2 ("en", mComponentName2.SupportedLanguages, - ParentBus->BusName, &ParentBusName, FALSE /* Iso639Language */); - ASSERT_EFI_ERROR (Status); - NameSize = StrSize (ParentBusName) - sizeof (CHAR16) + sizeof NameSuffix; - Name = AllocatePool (NameSize); - if (Name == NULL) { - Status = EFI_OUT_OF_RESOURCES; - goto FreeVgpuGop; - } - UnicodeSPrintAsciiFormat (Name, NameSize, "%s%s", ParentBusName, NameSuffix); - Status = AddUnicodeString2 ("en", mComponentName2.SupportedLanguages, - &VgpuGop->GopName, Name, FALSE /* Iso639Language */); - FreePool (Name); - if (EFI_ERROR (Status)) { - goto FreeVgpuGop; - } - - // - // Create the child device path. - // - VgpuGop->GopDevicePath = AppendDevicePathNode (ParentDevicePath, - &mAcpiAdr.Header); - if (VgpuGop->GopDevicePath == NULL) { - Status = EFI_OUT_OF_RESOURCES; - goto FreeVgpuGopName; - } - - // - // Mask protocol notify callbacks until we're done. - // - OldTpl = gBS->RaiseTPL (TPL_CALLBACK); - - // - // Create the child handle with the child device path. - // - Status = gBS->InstallProtocolInterface (&VgpuGop->GopHandle, - &gEfiDevicePathProtocolGuid, EFI_NATIVE_INTERFACE, - VgpuGop->GopDevicePath); - if (EFI_ERROR (Status)) { - goto FreeDevicePath; - } - - // - // The child handle must present a reference to the parent handle's Virtio - // Device Protocol interface. - // - Status = gBS->OpenProtocol (ParentBusController, &gVirtioDeviceProtocolGuid, - &ParentVirtIo, DriverBindingHandle, VgpuGop->GopHandle, - EFI_OPEN_PROTOCOL_BY_CHILD_CONTROLLER); - if (EFI_ERROR (Status)) { - goto UninstallDevicePath; - } - ASSERT (ParentVirtIo == ParentBus->VirtIo); - - // - // Initialize our Graphics Output Protocol. - // - // Fill in the function members of VgpuGop->Gop from the template, then set - // up the rest of the GOP infrastructure by calling SetMode() right now. - // - CopyMem (&VgpuGop->Gop, &mGopTemplate, sizeof mGopTemplate); - Status = VgpuGop->Gop.SetMode (&VgpuGop->Gop, 0); - if (EFI_ERROR (Status)) { - goto CloseVirtIoByChild; - } - - // - // Install the Graphics Output Protocol on the child handle. - // - Status = gBS->InstallProtocolInterface (&VgpuGop->GopHandle, - &gEfiGraphicsOutputProtocolGuid, EFI_NATIVE_INTERFACE, - &VgpuGop->Gop); - if (EFI_ERROR (Status)) { - goto UninitGop; - } - - // - // We're done. - // - gBS->RestoreTPL (OldTpl); - ParentBus->Child = VgpuGop; - return EFI_SUCCESS; - -UninitGop: - ReleaseGopResources (VgpuGop, TRUE /* DisableHead */); - -CloseVirtIoByChild: - gBS->CloseProtocol (ParentBusController, &gVirtioDeviceProtocolGuid, - DriverBindingHandle, VgpuGop->GopHandle); - -UninstallDevicePath: - gBS->UninstallProtocolInterface (VgpuGop->GopHandle, - &gEfiDevicePathProtocolGuid, VgpuGop->GopDevicePath); - -FreeDevicePath: - gBS->RestoreTPL (OldTpl); - FreePool (VgpuGop->GopDevicePath); - -FreeVgpuGopName: - FreeUnicodeStringTable (VgpuGop->GopName); - -FreeVgpuGop: - FreePool (VgpuGop); - - return Status; -} - -/** - Tear down and release the VGPU_GOP child object within the VGPU_DEV parent - object. - - This function removes the BY_CHILD_CONTROLLER reference from - ParentBusController's VIRTIO_DEVICE_PROTOCOL interface. - - @param[in,out] ParentBus The VGPU_DEV object that the VGPU_GOP child - object will be removed from. - - @param[in] ParentBusController The UEFI controller handle on which the - ParentBus VGPU_DEV object is installed. - - @param[in] DriverBindingHandle The DriverBindingHandle member of - EFI_DRIVER_BINDING_PROTOCOL whose Stop() - function is calling this function. It is - passed as AgentHandle to gBS->CloseProtocol() - when removing the BY_CHILD_CONTROLLER - reference. -**/ -STATIC -VOID -UninitVgpuGop ( - IN OUT VGPU_DEV *ParentBus, - IN EFI_HANDLE ParentBusController, - IN EFI_HANDLE DriverBindingHandle - ) -{ - VGPU_GOP *VgpuGop; - EFI_STATUS Status; - - VgpuGop = ParentBus->Child; - Status = gBS->UninstallProtocolInterface (VgpuGop->GopHandle, - &gEfiGraphicsOutputProtocolGuid, &VgpuGop->Gop); - ASSERT_EFI_ERROR (Status); - - // - // Uninitialize VgpuGop->Gop. - // - ReleaseGopResources (VgpuGop, TRUE /* DisableHead */); - - Status = gBS->CloseProtocol (ParentBusController, &gVirtioDeviceProtocolGuid, - DriverBindingHandle, VgpuGop->GopHandle); - ASSERT_EFI_ERROR (Status); - - Status = gBS->UninstallProtocolInterface (VgpuGop->GopHandle, - &gEfiDevicePathProtocolGuid, VgpuGop->GopDevicePath); - ASSERT_EFI_ERROR (Status); - - FreePool (VgpuGop->GopDevicePath); - FreeUnicodeStringTable (VgpuGop->GopName); - FreePool (VgpuGop); - - ParentBus->Child = NULL; -} - -// -// Driver Binding Protocol Implementation. -// -STATIC -EFI_STATUS -EFIAPI -VirtioGpuDriverBindingSupported ( - IN EFI_DRIVER_BINDING_PROTOCOL *This, - IN EFI_HANDLE ControllerHandle, - IN EFI_DEVICE_PATH_PROTOCOL *RemainingDevicePath OPTIONAL - ) -{ - EFI_STATUS Status; - VIRTIO_DEVICE_PROTOCOL *VirtIo; - - // - // - If RemainingDevicePath is NULL: the caller is interested in creating all - // child handles. - // - If RemainingDevicePath points to an end node: the caller is not - // interested in creating any child handle. - // - Otherwise, the caller would like to create the one child handle - // specified in RemainingDevicePath. In this case we have to see if the - // requested device path is supportable. - // - if (RemainingDevicePath != NULL && - !IsDevicePathEnd (RemainingDevicePath) && - (DevicePathNodeLength (RemainingDevicePath) != sizeof mAcpiAdr || - CompareMem (RemainingDevicePath, &mAcpiAdr, sizeof mAcpiAdr) != 0)) { - return EFI_UNSUPPORTED; - } - - // - // Open the Virtio Device Protocol interface on the controller, BY_DRIVER. - // - Status = gBS->OpenProtocol (ControllerHandle, &gVirtioDeviceProtocolGuid, - (VOID **)&VirtIo, This->DriverBindingHandle, - ControllerHandle, EFI_OPEN_PROTOCOL_BY_DRIVER); - if (EFI_ERROR (Status)) { - // - // If this fails, then by default we cannot support ControllerHandle. There - // is one exception: we've already bound the device, have not produced any - // GOP child controller, and now the caller wants us to produce the child - // controller (either specifically or as part of "all children"). That's - // allowed. - // - if (Status == EFI_ALREADY_STARTED) { - EFI_STATUS Status2; - VGPU_DEV *VgpuDev; - - Status2 = gBS->OpenProtocol (ControllerHandle, &gEfiCallerIdGuid, - (VOID **)&VgpuDev, This->DriverBindingHandle, - ControllerHandle, EFI_OPEN_PROTOCOL_GET_PROTOCOL); - ASSERT_EFI_ERROR (Status2); - - if (VgpuDev->Child == NULL && - (RemainingDevicePath == NULL || - !IsDevicePathEnd (RemainingDevicePath))) { - Status = EFI_SUCCESS; - } - } - - return Status; - } - - // - // First BY_DRIVER open; check the VirtIo revision and subsystem. - // - if (VirtIo->Revision < VIRTIO_SPEC_REVISION (1, 0, 0) || - VirtIo->SubSystemDeviceId != VIRTIO_SUBSYSTEM_GPU_DEVICE) { - Status = EFI_UNSUPPORTED; - goto CloseVirtIo; - } - - // - // We'll need the device path of the VirtIo device both for formatting - // VGPU_DEV.BusName and for populating VGPU_GOP.GopDevicePath. - // - Status = gBS->OpenProtocol (ControllerHandle, &gEfiDevicePathProtocolGuid, - NULL, This->DriverBindingHandle, ControllerHandle, - EFI_OPEN_PROTOCOL_TEST_PROTOCOL); - -CloseVirtIo: - gBS->CloseProtocol (ControllerHandle, &gVirtioDeviceProtocolGuid, - This->DriverBindingHandle, ControllerHandle); - - return Status; -} - -STATIC -EFI_STATUS -EFIAPI -VirtioGpuDriverBindingStart ( - IN EFI_DRIVER_BINDING_PROTOCOL *This, - IN EFI_HANDLE ControllerHandle, - IN EFI_DEVICE_PATH_PROTOCOL *RemainingDevicePath OPTIONAL - ) -{ - EFI_STATUS Status; - VIRTIO_DEVICE_PROTOCOL *VirtIo; - BOOLEAN VirtIoBoundJustNow; - VGPU_DEV *VgpuDev; - EFI_DEVICE_PATH_PROTOCOL *DevicePath; - - // - // Open the Virtio Device Protocol. - // - // The result of this operation, combined with the checks in - // VirtioGpuDriverBindingSupported(), uniquely tells us whether we are - // binding the VirtIo controller on this call (with or without creating child - // controllers), or else we're *only* creating child controllers. - // - Status = gBS->OpenProtocol (ControllerHandle, &gVirtioDeviceProtocolGuid, - (VOID **)&VirtIo, This->DriverBindingHandle, - ControllerHandle, EFI_OPEN_PROTOCOL_BY_DRIVER); - if (EFI_ERROR (Status)) { - // - // The assertions below are based on the success of - // VirtioGpuDriverBindingSupported(): we bound ControllerHandle earlier, - // without producing child handles, and now we're producing the GOP child - // handle only. - // - ASSERT (Status == EFI_ALREADY_STARTED); - - Status = gBS->OpenProtocol (ControllerHandle, &gEfiCallerIdGuid, - (VOID **)&VgpuDev, This->DriverBindingHandle, - ControllerHandle, EFI_OPEN_PROTOCOL_GET_PROTOCOL); - ASSERT_EFI_ERROR (Status); - - ASSERT (VgpuDev->Child == NULL); - ASSERT ( - RemainingDevicePath == NULL || !IsDevicePathEnd (RemainingDevicePath)); - - VirtIoBoundJustNow = FALSE; - } else { - VirtIoBoundJustNow = TRUE; - - // - // Allocate the private structure. - // - VgpuDev = AllocateZeroPool (sizeof *VgpuDev); - if (VgpuDev == NULL) { - Status = EFI_OUT_OF_RESOURCES; - goto CloseVirtIo; - } - VgpuDev->VirtIo = VirtIo; - } - - // - // Grab the VirtIo controller's device path. This is necessary regardless of - // VirtIoBoundJustNow. - // - Status = gBS->OpenProtocol (ControllerHandle, &gEfiDevicePathProtocolGuid, - (VOID **)&DevicePath, This->DriverBindingHandle, - ControllerHandle, EFI_OPEN_PROTOCOL_GET_PROTOCOL); - if (EFI_ERROR (Status)) { - goto FreeVgpuDev; - } - - // - // Create VGPU_DEV if we've bound the VirtIo controller right now (that is, - // if we aren't *only* creating child handles). - // - if (VirtIoBoundJustNow) { - CHAR16 *VgpuDevName; - - // - // Format a human-readable controller name for VGPU_DEV, and stash it for - // VirtioGpuGetControllerName() to look up. - // - Status = FormatVgpuDevName (ControllerHandle, This->DriverBindingHandle, - DevicePath, &VgpuDevName); - if (EFI_ERROR (Status)) { - goto FreeVgpuDev; - } - Status = AddUnicodeString2 ("en", mComponentName2.SupportedLanguages, - &VgpuDev->BusName, VgpuDevName, FALSE /* Iso639Language */); - FreePool (VgpuDevName); - if (EFI_ERROR (Status)) { - goto FreeVgpuDev; - } - - Status = VirtioGpuInit (VgpuDev); - if (EFI_ERROR (Status)) { - goto FreeVgpuDevBusName; - } - - Status = gBS->CreateEvent (EVT_SIGNAL_EXIT_BOOT_SERVICES, TPL_CALLBACK, - VirtioGpuExitBoot, VgpuDev /* NotifyContext */, - &VgpuDev->ExitBoot); - if (EFI_ERROR (Status)) { - goto UninitGpu; - } - - // - // Install the VGPU_DEV "protocol interface" on ControllerHandle. - // - Status = gBS->InstallProtocolInterface (&ControllerHandle, - &gEfiCallerIdGuid, EFI_NATIVE_INTERFACE, VgpuDev); - if (EFI_ERROR (Status)) { - goto CloseExitBoot; - } - - if (RemainingDevicePath != NULL && IsDevicePathEnd (RemainingDevicePath)) { - // - // No child handle should be produced; we're done. - // - DEBUG ((EFI_D_INFO, "%a: bound VirtIo=%p without producing GOP\n", - __FUNCTION__, (VOID *)VgpuDev->VirtIo)); - return EFI_SUCCESS; - } - } - - // - // Below we'll produce our single child handle: the caller requested it - // either specifically, or as part of all child handles. - // - ASSERT (VgpuDev->Child == NULL); - ASSERT ( - RemainingDevicePath == NULL || !IsDevicePathEnd (RemainingDevicePath)); - - Status = InitVgpuGop (VgpuDev, DevicePath, ControllerHandle, - This->DriverBindingHandle); - if (EFI_ERROR (Status)) { - goto UninstallVgpuDev; - } - - // - // We're done. - // - DEBUG ((EFI_D_INFO, "%a: produced GOP %a VirtIo=%p\n", __FUNCTION__, - VirtIoBoundJustNow ? "while binding" : "for pre-bound", - (VOID *)VgpuDev->VirtIo)); - return EFI_SUCCESS; - -UninstallVgpuDev: - if (VirtIoBoundJustNow) { - gBS->UninstallProtocolInterface (ControllerHandle, &gEfiCallerIdGuid, - VgpuDev); - } - -CloseExitBoot: - if (VirtIoBoundJustNow) { - gBS->CloseEvent (VgpuDev->ExitBoot); - } - -UninitGpu: - if (VirtIoBoundJustNow) { - VirtioGpuUninit (VgpuDev); - } - -FreeVgpuDevBusName: - if (VirtIoBoundJustNow) { - FreeUnicodeStringTable (VgpuDev->BusName); - } - -FreeVgpuDev: - if (VirtIoBoundJustNow) { - FreePool (VgpuDev); - } - -CloseVirtIo: - if (VirtIoBoundJustNow) { - gBS->CloseProtocol (ControllerHandle, &gVirtioDeviceProtocolGuid, - This->DriverBindingHandle, ControllerHandle); - } - - return Status; -} - -STATIC -EFI_STATUS -EFIAPI -VirtioGpuDriverBindingStop ( - IN EFI_DRIVER_BINDING_PROTOCOL *This, - IN EFI_HANDLE ControllerHandle, - IN UINTN NumberOfChildren, - IN EFI_HANDLE *ChildHandleBuffer OPTIONAL - ) -{ - EFI_STATUS Status; - VGPU_DEV *VgpuDev; - - // - // Look up the VGPU_DEV "protocol interface" on ControllerHandle. - // - Status = gBS->OpenProtocol (ControllerHandle, &gEfiCallerIdGuid, - (VOID **)&VgpuDev, This->DriverBindingHandle, - ControllerHandle, EFI_OPEN_PROTOCOL_GET_PROTOCOL); - if (EFI_ERROR (Status)) { - return Status; - } - // - // Sanity check: if we found gEfiCallerIdGuid on ControllerHandle, then we - // keep its Virtio Device Protocol interface open BY_DRIVER. - // - ASSERT_EFI_ERROR (EfiTestManagedDevice (ControllerHandle, - This->DriverBindingHandle, &gVirtioDeviceProtocolGuid)); - - switch (NumberOfChildren) { - case 0: - // - // The caller wants us to unbind the VirtIo controller. - // - if (VgpuDev->Child != NULL) { - // - // We still have the GOP child. - // - Status = EFI_DEVICE_ERROR; - break; - } - - DEBUG ((EFI_D_INFO, "%a: unbinding GOP-less VirtIo=%p\n", __FUNCTION__, - (VOID *)VgpuDev->VirtIo)); - - Status = gBS->UninstallProtocolInterface (ControllerHandle, - &gEfiCallerIdGuid, VgpuDev); - ASSERT_EFI_ERROR (Status); - - Status = gBS->CloseEvent (VgpuDev->ExitBoot); - ASSERT_EFI_ERROR (Status); - - VirtioGpuUninit (VgpuDev); - FreeUnicodeStringTable (VgpuDev->BusName); - FreePool (VgpuDev); - - Status = gBS->CloseProtocol (ControllerHandle, &gVirtioDeviceProtocolGuid, - This->DriverBindingHandle, ControllerHandle); - ASSERT_EFI_ERROR (Status); - break; - - case 1: - // - // The caller wants us to destroy our child GOP controller. - // - if (VgpuDev->Child == NULL || - ChildHandleBuffer[0] != VgpuDev->Child->GopHandle) { - // - // We have no child controller at the moment, or it differs from the one - // the caller wants us to destroy. I.e., we don't own the child - // controller passed in. - // - Status = EFI_DEVICE_ERROR; - break; - } - // - // Sanity check: our GOP child controller keeps the VGPU_DEV controller's - // Virtio Device Protocol interface open BY_CHILD_CONTROLLER. - // - ASSERT_EFI_ERROR (EfiTestChildHandle (ControllerHandle, - VgpuDev->Child->GopHandle, - &gVirtioDeviceProtocolGuid)); - - DEBUG ((EFI_D_INFO, "%a: destroying GOP under VirtIo=%p\n", __FUNCTION__, - (VOID *)VgpuDev->VirtIo)); - UninitVgpuGop (VgpuDev, ControllerHandle, This->DriverBindingHandle); - break; - - default: - // - // Impossible, we never produced more than one child. - // - Status = EFI_DEVICE_ERROR; - break; - } - return Status; -} - -STATIC EFI_DRIVER_BINDING_PROTOCOL mDriverBinding = { - VirtioGpuDriverBindingSupported, - VirtioGpuDriverBindingStart, - VirtioGpuDriverBindingStop, - 0x10, // Version - NULL, // ImageHandle, overwritten in entry point - NULL // DriverBindingHandle, ditto -}; - -// -// Entry point of the driver. -// -EFI_STATUS -EFIAPI -VirtioGpuEntryPoint ( - IN EFI_HANDLE ImageHandle, - IN EFI_SYSTEM_TABLE *SystemTable - ) -{ - return EfiLibInstallDriverBindingComponentName2 (ImageHandle, SystemTable, - &mDriverBinding, ImageHandle, NULL /* ComponentName */, - &mComponentName2); -} diff --git a/OvmfPkg/VirtioGpuDxe/Gop.c b/OvmfPkg/VirtioGpuDxe/Gop.c deleted file mode 100644 index 3438bd0322..0000000000 --- a/OvmfPkg/VirtioGpuDxe/Gop.c +++ /dev/null @@ -1,646 +0,0 @@ -/** @file - - EFI_GRAPHICS_OUTPUT_PROTOCOL member functions for the VirtIo GPU driver. - - Copyright (C) 2016, 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 -#include - -#include "VirtioGpu.h" - -/** - Release guest-side and host-side resources that are related to an initialized - VGPU_GOP.Gop. - - param[in,out] VgpuGop The VGPU_GOP object to release resources for. - - On input, the caller is responsible for having called - VgpuGop->Gop.SetMode() at least once successfully. - (This is equivalent to the requirement that - VgpuGop->BackingStore be non-NULL. It is also - equivalent to the requirement that VgpuGop->ResourceId - be nonzero.) - - On output, resources will be released, and - VgpuGop->BackingStore and VgpuGop->ResourceId will be - nulled. - - param[in] DisableHead Whether this head (scanout) currently references the - resource identified by VgpuGop->ResourceId. Only pass - FALSE when VgpuGop->Gop.SetMode() calls this function - while switching between modes, and set it to TRUE - every other time. -**/ -VOID -ReleaseGopResources ( - IN OUT VGPU_GOP *VgpuGop, - IN BOOLEAN DisableHead - ) -{ - EFI_STATUS Status; - - ASSERT (VgpuGop->ResourceId != 0); - ASSERT (VgpuGop->BackingStore != NULL); - - // - // If any of the following host-side destruction steps fail, we can't get out - // of an inconsistent state, so we'll hang. In general errors in object - // destruction can hardly be recovered from. - // - if (DisableHead) { - // - // Dissociate head (scanout) #0 from the currently used 2D host resource, - // by setting ResourceId=0 for it. - // - Status = VirtioGpuSetScanout ( - VgpuGop->ParentBus, // VgpuDev - 0, 0, 0, 0, // X, Y, Width, Height - 0, // ScanoutId - 0 // ResourceId - ); - // - // HACK BEGINS HERE - // - // According to the GPU Device section of the VirtIo specification, the - // above operation is valid: - // - // "The driver can use resource_id = 0 to disable a scanout." - // - // However, in practice QEMU does not allow us to disable head (scanout) #0 - // -- it rejects the command with response code 0x1202 - // (VIRTIO_GPU_RESP_ERR_INVALID_SCANOUT_ID). Looking at the QEMU source - // code, function virtio_gpu_set_scanout() in "hw/display/virtio-gpu.c", - // this appears fully intentional, despite not being documented in the - // spec. - // - // Surprisingly, ignoring the error here, and proceeding to release - // host-side resources that presumably underlie head (scanout) #0, work - // without any problems -- the driver survives repeated "disconnect" / - // "connect -r" commands in the UEFI shell. - // - // So, for now, let's just suppress the error. - // - Status = EFI_SUCCESS; - // - // HACK ENDS HERE - // - - ASSERT_EFI_ERROR (Status); - if (EFI_ERROR (Status)) { - CpuDeadLoop (); - } - } - - // - // Detach backing pages from the currently used 2D host resource. - // - Status = VirtioGpuResourceDetachBacking ( - VgpuGop->ParentBus, // VgpuDev - VgpuGop->ResourceId // ResourceId - ); - ASSERT_EFI_ERROR (Status); - if (EFI_ERROR (Status)) { - CpuDeadLoop (); - } - - // - // Release backing pages. - // - FreePages (VgpuGop->BackingStore, VgpuGop->NumberOfPages); - VgpuGop->BackingStore = NULL; - VgpuGop->NumberOfPages = 0; - - // - // Destroy the currently used 2D host resource. - // - Status = VirtioGpuResourceUnref ( - VgpuGop->ParentBus, // VgpuDev - VgpuGop->ResourceId // ResourceId - ); - ASSERT_EFI_ERROR (Status); - if (EFI_ERROR (Status)) { - CpuDeadLoop (); - } - VgpuGop->ResourceId = 0; -} - -// -// The resolutions supported by this driver. -// -typedef struct { - UINT32 Width; - UINT32 Height; -} GOP_RESOLUTION; - -STATIC CONST GOP_RESOLUTION mGopResolutions[] = { - { 640, 480 }, - { 800, 480 }, - { 800, 600 }, - { 832, 624 }, - { 960, 640 }, - { 1024, 600 }, - { 1024, 768 }, - { 1152, 864 }, - { 1152, 870 }, - { 1280, 720 }, - { 1280, 760 }, - { 1280, 768 }, - { 1280, 800 }, - { 1280, 960 }, - { 1280, 1024 }, - { 1360, 768 }, - { 1366, 768 }, - { 1400, 1050 }, - { 1440, 900 }, - { 1600, 900 }, - { 1600, 1200 }, - { 1680, 1050 }, - { 1920, 1080 }, - { 1920, 1200 }, - { 1920, 1440 }, - { 2000, 2000 }, - { 2048, 1536 }, - { 2048, 2048 }, - { 2560, 1440 }, - { 2560, 1600 }, - { 2560, 2048 }, - { 2800, 2100 }, - { 3200, 2400 }, - { 3840, 2160 }, - { 4096, 2160 }, - { 7680, 4320 }, - { 8192, 4320 }, -}; - -// -// Macro for casting VGPU_GOP.Gop to VGPU_GOP. -// -#define VGPU_GOP_FROM_GOP(GopPointer) \ - CR (GopPointer, VGPU_GOP, Gop, VGPU_GOP_SIG) - -// -// EFI_GRAPHICS_OUTPUT_PROTOCOL member functions. -// -STATIC -EFI_STATUS -EFIAPI -GopQueryMode ( - IN EFI_GRAPHICS_OUTPUT_PROTOCOL *This, - IN UINT32 ModeNumber, - OUT UINTN *SizeOfInfo, - OUT EFI_GRAPHICS_OUTPUT_MODE_INFORMATION **Info - ) -{ - EFI_GRAPHICS_OUTPUT_MODE_INFORMATION *GopModeInfo; - - if (ModeNumber >= ARRAY_SIZE (mGopResolutions)) { - return EFI_INVALID_PARAMETER; - } - - GopModeInfo = AllocateZeroPool (sizeof *GopModeInfo); - if (GopModeInfo == NULL) { - return EFI_OUT_OF_RESOURCES; - } - - GopModeInfo->HorizontalResolution = mGopResolutions[ModeNumber].Width; - GopModeInfo->VerticalResolution = mGopResolutions[ModeNumber].Height; - GopModeInfo->PixelFormat = PixelBltOnly; - GopModeInfo->PixelsPerScanLine = mGopResolutions[ModeNumber].Width; - - *SizeOfInfo = sizeof *GopModeInfo; - *Info = GopModeInfo; - return EFI_SUCCESS; -} - -STATIC -EFI_STATUS -EFIAPI -GopSetMode ( - IN EFI_GRAPHICS_OUTPUT_PROTOCOL *This, - IN UINT32 ModeNumber - ) -{ - VGPU_GOP *VgpuGop; - UINT32 NewResourceId; - UINTN NewNumberOfBytes; - UINTN NewNumberOfPages; - VOID *NewBackingStore; - EFI_STATUS Status; - EFI_STATUS Status2; - - if (ModeNumber >= ARRAY_SIZE (mGopResolutions)) { - return EFI_UNSUPPORTED; - } - - VgpuGop = VGPU_GOP_FROM_GOP (This); - - // - // Distinguish the first (internal) call from the other (protocol consumer) - // calls. - // - if (VgpuGop->ResourceId == 0) { - // - // Set up the Gop -> GopMode -> GopModeInfo pointer chain, and the other - // (nonzero) constant fields. - // - // No direct framebuffer access is supported, only Blt() is. - // - VgpuGop->Gop.Mode = &VgpuGop->GopMode; - - VgpuGop->GopMode.MaxMode = (UINT32)(ARRAY_SIZE (mGopResolutions)); - VgpuGop->GopMode.Info = &VgpuGop->GopModeInfo; - VgpuGop->GopMode.SizeOfInfo = sizeof VgpuGop->GopModeInfo; - - VgpuGop->GopModeInfo.PixelFormat = PixelBltOnly; - - // - // This is the first time we create a host side resource. - // - NewResourceId = 1; - } else { - // - // We already have an active host side resource. Create the new one without - // interfering with the current one, so that we can cleanly bail out on - // error, without disturbing the current graphics mode. - // - // The formula below will alternate between IDs 1 and 2. - // - NewResourceId = 3 - VgpuGop->ResourceId; - } - - // - // Create the 2D host resource. - // - Status = VirtioGpuResourceCreate2d ( - VgpuGop->ParentBus, // VgpuDev - NewResourceId, // ResourceId - VirtioGpuFormatB8G8R8X8Unorm, // Format - mGopResolutions[ModeNumber].Width, // Width - mGopResolutions[ModeNumber].Height // Height - ); - if (EFI_ERROR (Status)) { - return Status; - } - - // - // Allocate guest backing store. - // - NewNumberOfBytes = mGopResolutions[ModeNumber].Width * - mGopResolutions[ModeNumber].Height * sizeof (UINT32); - NewNumberOfPages = EFI_SIZE_TO_PAGES (NewNumberOfBytes); - NewBackingStore = AllocatePages (NewNumberOfPages); - if (NewBackingStore == NULL) { - Status = EFI_OUT_OF_RESOURCES; - goto DestroyHostResource; - } - // - // Fill visible part of backing store with black. - // - ZeroMem (NewBackingStore, NewNumberOfBytes); - - // - // Attach backing store to the host resource. - // - Status = VirtioGpuResourceAttachBacking ( - VgpuGop->ParentBus, // VgpuDev - NewResourceId, // ResourceId - NewBackingStore, // FirstBackingPage - NewNumberOfPages // NumberOfPages - ); - if (EFI_ERROR (Status)) { - goto FreeBackingStore; - } - - // - // Point head (scanout) #0 to the host resource. - // - Status = VirtioGpuSetScanout ( - VgpuGop->ParentBus, // VgpuDev - 0, // X - 0, // Y - mGopResolutions[ModeNumber].Width, // Width - mGopResolutions[ModeNumber].Height, // Height - 0, // ScanoutId - NewResourceId // ResourceId - ); - if (EFI_ERROR (Status)) { - goto DetachBackingStore; - } - - // - // If this is not the first (i.e., internal) call, then we have to (a) flush - // the new resource to head (scanout) #0, after having flipped the latter to - // the former above, plus (b) release the old resources. - // - if (VgpuGop->ResourceId != 0) { - Status = VirtioGpuResourceFlush ( - VgpuGop->ParentBus, // VgpuDev - 0, // X - 0, // Y - mGopResolutions[ModeNumber].Width, // Width - mGopResolutions[ModeNumber].Height, // Height - NewResourceId // ResourceId - ); - if (EFI_ERROR (Status)) { - // - // Flip head (scanout) #0 back to the current resource. If this fails, we - // cannot continue, as this error occurs on the error path and is - // therefore non-recoverable. - // - Status2 = VirtioGpuSetScanout ( - VgpuGop->ParentBus, // VgpuDev - 0, // X - 0, // Y - mGopResolutions[This->Mode->Mode].Width, // Width - mGopResolutions[This->Mode->Mode].Height, // Height - 0, // ScanoutId - VgpuGop->ResourceId // ResourceId - ); - ASSERT_EFI_ERROR (Status2); - if (EFI_ERROR (Status2)) { - CpuDeadLoop (); - } - goto DetachBackingStore; - } - - // - // Flush successful; release the old resources (without disabling head - // (scanout) #0). - // - ReleaseGopResources (VgpuGop, FALSE /* DisableHead */); - } - - // - // This is either the first (internal) call when we have no old resources - // yet, or we've changed the mode successfully and released the old - // resources. - // - ASSERT (VgpuGop->ResourceId == 0); - ASSERT (VgpuGop->BackingStore == NULL); - - VgpuGop->ResourceId = NewResourceId; - VgpuGop->BackingStore = NewBackingStore; - VgpuGop->NumberOfPages = NewNumberOfPages; - - // - // Populate Mode and ModeInfo (mutable fields only). - // - VgpuGop->GopMode.Mode = ModeNumber; - VgpuGop->GopModeInfo.HorizontalResolution = - mGopResolutions[ModeNumber].Width; - VgpuGop->GopModeInfo.VerticalResolution = mGopResolutions[ModeNumber].Height; - VgpuGop->GopModeInfo.PixelsPerScanLine = mGopResolutions[ModeNumber].Width; - return EFI_SUCCESS; - -DetachBackingStore: - Status2 = VirtioGpuResourceDetachBacking (VgpuGop->ParentBus, NewResourceId); - ASSERT_EFI_ERROR (Status2); - if (EFI_ERROR (Status2)) { - CpuDeadLoop (); - } - -FreeBackingStore: - FreePages (NewBackingStore, NewNumberOfPages); - -DestroyHostResource: - Status2 = VirtioGpuResourceUnref (VgpuGop->ParentBus, NewResourceId); - ASSERT_EFI_ERROR (Status2); - if (EFI_ERROR (Status2)) { - CpuDeadLoop (); - } - - return Status; -} - -STATIC -EFI_STATUS -EFIAPI -GopBlt ( - IN EFI_GRAPHICS_OUTPUT_PROTOCOL *This, - IN EFI_GRAPHICS_OUTPUT_BLT_PIXEL *BltBuffer, OPTIONAL - IN EFI_GRAPHICS_OUTPUT_BLT_OPERATION BltOperation, - IN UINTN SourceX, - IN UINTN SourceY, - IN UINTN DestinationX, - IN UINTN DestinationY, - IN UINTN Width, - IN UINTN Height, - IN UINTN Delta OPTIONAL - ) -{ - VGPU_GOP *VgpuGop; - UINT32 CurrentHorizontal; - UINT32 CurrentVertical; - UINTN SegmentSize; - UINTN Y; - UINTN ResourceOffset; - EFI_STATUS Status; - - VgpuGop = VGPU_GOP_FROM_GOP (This); - CurrentHorizontal = VgpuGop->GopModeInfo.HorizontalResolution; - CurrentVertical = VgpuGop->GopModeInfo.VerticalResolution; - - // - // We can avoid pixel format conversion in the guest because the internal - // representation of EFI_GRAPHICS_OUTPUT_BLT_PIXEL and that of - // VirtioGpuFormatB8G8R8X8Unorm are identical. - // - SegmentSize = Width * sizeof (UINT32); - - // - // Delta is relevant for operations that read a rectangle from, or write a - // rectangle to, BltBuffer. - // - // In these cases, Delta is the stride of BltBuffer, in bytes. If Delta is - // zero, then Width is the entire width of BltBuffer, and the stride is - // supposed to be calculated from Width. - // - if (BltOperation == EfiBltVideoToBltBuffer || - BltOperation == EfiBltBufferToVideo) { - if (Delta == 0) { - Delta = SegmentSize; - } - } - - // - // For operations that write to the display, check if the destination fits - // onto the display. - // - if (BltOperation == EfiBltVideoFill || - BltOperation == EfiBltBufferToVideo || - BltOperation == EfiBltVideoToVideo) { - if (DestinationX > CurrentHorizontal || - Width > CurrentHorizontal - DestinationX || - DestinationY > CurrentVertical || - Height > CurrentVertical - DestinationY) { - return EFI_INVALID_PARAMETER; - } - } - - // - // For operations that read from the display, check if the source fits onto - // the display. - // - if (BltOperation == EfiBltVideoToBltBuffer || - BltOperation == EfiBltVideoToVideo) { - if (SourceX > CurrentHorizontal || - Width > CurrentHorizontal - SourceX || - SourceY > CurrentVertical || - Height > CurrentVertical - SourceY) { - return EFI_INVALID_PARAMETER; - } - } - - // - // Render the request. For requests that do not modify the display, there - // won't be further steps. - // - switch (BltOperation) { - case EfiBltVideoFill: - // - // Write data from the BltBuffer pixel (0, 0) directly to every pixel of - // the video display rectangle (DestinationX, DestinationY) (DestinationX + - // Width, DestinationY + Height). Only one pixel will be used from the - // BltBuffer. Delta is NOT used. - // - for (Y = 0; Y < Height; ++Y) { - SetMem32 ( - VgpuGop->BackingStore + - (DestinationY + Y) * CurrentHorizontal + DestinationX, - SegmentSize, - *(UINT32 *)BltBuffer - ); - } - break; - - case EfiBltVideoToBltBuffer: - // - // Read data from the video display rectangle (SourceX, SourceY) (SourceX + - // Width, SourceY + Height) and place it in the BltBuffer rectangle - // (DestinationX, DestinationY ) (DestinationX + Width, DestinationY + - // Height). If DestinationX or DestinationY is not zero then Delta must be - // set to the length in bytes of a row in the BltBuffer. - // - for (Y = 0; Y < Height; ++Y) { - CopyMem ( - (UINT8 *)BltBuffer + - (DestinationY + Y) * Delta + DestinationX * sizeof *BltBuffer, - VgpuGop->BackingStore + - (SourceY + Y) * CurrentHorizontal + SourceX, - SegmentSize - ); - } - return EFI_SUCCESS; - - case EfiBltBufferToVideo: - // - // Write data from the BltBuffer rectangle (SourceX, SourceY) (SourceX + - // Width, SourceY + Height) directly to the video display rectangle - // (DestinationX, DestinationY) (DestinationX + Width, DestinationY + - // Height). If SourceX or SourceY is not zero then Delta must be set to the - // length in bytes of a row in the BltBuffer. - // - for (Y = 0; Y < Height; ++Y) { - CopyMem ( - VgpuGop->BackingStore + - (DestinationY + Y) * CurrentHorizontal + DestinationX, - (UINT8 *)BltBuffer + - (SourceY + Y) * Delta + SourceX * sizeof *BltBuffer, - SegmentSize - ); - } - break; - - case EfiBltVideoToVideo: - // - // Copy from the video display rectangle (SourceX, SourceY) (SourceX + - // Width, SourceY + Height) to the video display rectangle (DestinationX, - // DestinationY) (DestinationX + Width, DestinationY + Height). The - // BltBuffer and Delta are not used in this mode. - // - // A single invocation of CopyMem() handles overlap between source and - // destination (that is, within a single line), but for multiple - // invocations, we must handle overlaps. - // - if (SourceY < DestinationY) { - Y = Height; - while (Y > 0) { - --Y; - CopyMem ( - VgpuGop->BackingStore + - (DestinationY + Y) * CurrentHorizontal + DestinationX, - VgpuGop->BackingStore + - (SourceY + Y) * CurrentHorizontal + SourceX, - SegmentSize - ); - } - } else { - for (Y = 0; Y < Height; ++Y) { - CopyMem ( - VgpuGop->BackingStore + - (DestinationY + Y) * CurrentHorizontal + DestinationX, - VgpuGop->BackingStore + - (SourceY + Y) * CurrentHorizontal + SourceX, - SegmentSize - ); - } - } - break; - - default: - return EFI_INVALID_PARAMETER; - } - - // - // For operations that wrote to the display, submit the updated area to the - // host -- update the host resource from guest memory. - // - ResourceOffset = sizeof (UINT32) * (DestinationY * CurrentHorizontal + - DestinationX); - Status = VirtioGpuTransferToHost2d ( - VgpuGop->ParentBus, // VgpuDev - (UINT32)DestinationX, // X - (UINT32)DestinationY, // Y - (UINT32)Width, // Width - (UINT32)Height, // Height - ResourceOffset, // Offset - VgpuGop->ResourceId // ResourceId - ); - if (EFI_ERROR (Status)) { - return Status; - } - - // - // Flush the updated resource to the display. - // - Status = VirtioGpuResourceFlush ( - VgpuGop->ParentBus, // VgpuDev - (UINT32)DestinationX, // X - (UINT32)DestinationY, // Y - (UINT32)Width, // Width - (UINT32)Height, // Height - VgpuGop->ResourceId // ResourceId - ); - return Status; -} - -// -// Template for initializing VGPU_GOP.Gop. -// -CONST EFI_GRAPHICS_OUTPUT_PROTOCOL mGopTemplate = { - GopQueryMode, - GopSetMode, - GopBlt, - NULL // Mode, to be overwritten in the actual protocol instance -}; diff --git a/OvmfPkg/VirtioGpuDxe/VirtioGpu.h b/OvmfPkg/VirtioGpuDxe/VirtioGpu.h deleted file mode 100644 index 078b7d44d8..0000000000 --- a/OvmfPkg/VirtioGpuDxe/VirtioGpu.h +++ /dev/null @@ -1,327 +0,0 @@ -/** @file - - Internal type and macro definitions for the Virtio GPU hybrid driver. - - Copyright (C) 2016, 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_GPU_DXE_H_ -#define _VIRTIO_GPU_DXE_H_ - -#include -#include -#include -#include -#include - -// -// Forward declaration of VGPU_GOP. -// -typedef struct VGPU_GOP_STRUCT VGPU_GOP; - -// -// The abstraction that directly corresponds to a Virtio GPU device. -// -// This structure will be installed on the handle that has the VirtIo Device -// Protocol interface, with GUID gEfiCallerIdGuid. A similar trick is employed -// in TerminalDxe, and it is necessary so that we can look up VGPU_DEV just -// from the VirtIo Device Protocol handle in the Component Name 2 Protocol -// implementation. -// -typedef struct { - // - // VirtIo represents access to the Virtio GPU device. Never NULL. - // - VIRTIO_DEVICE_PROTOCOL *VirtIo; - - // - // BusName carries a customized name for - // EFI_COMPONENT_NAME2_PROTOCOL.GetControllerName(). It is expressed in table - // form because it can theoretically support several languages. Never NULL. - // - EFI_UNICODE_STRING_TABLE *BusName; - - // - // VirtIo ring used for VirtIo communication. - // - VRING Ring; - - // - // Event to be signaled at ExitBootServices(). - // - EFI_EVENT ExitBoot; - - // - // Common running counter for all VirtIo GPU requests that ask for fencing. - // - UINT64 FenceId; - - // - // The Child field references the GOP wrapper structure. If this pointer is - // NULL, then the hybrid driver has bound (i.e., started) the - // VIRTIO_DEVICE_PROTOCOL controller without producing the child GOP - // controller (that is, after Start() was called with RemainingDevicePath - // pointing to and End of Device Path node). Child can be created and - // destroyed, even repeatedly, independently of VGPU_DEV. - // - // In practice, this field represents the single head (scanout) that we - // support. - // - VGPU_GOP *Child; -} VGPU_DEV; - -// -// The Graphics Output Protocol wrapper structure. -// -#define VGPU_GOP_SIG SIGNATURE_64 ('V', 'G', 'P', 'U', '_', 'G', 'O', 'P') - -struct VGPU_GOP_STRUCT { - UINT64 Signature; - - // - // ParentBus points to the parent VGPU_DEV object. Never NULL. - // - VGPU_DEV *ParentBus; - - // - // GopName carries a customized name for - // EFI_COMPONENT_NAME2_PROTOCOL.GetControllerName(). It is expressed in table - // form because it can theoretically support several languages. Never NULL. - // - EFI_UNICODE_STRING_TABLE *GopName; - - // - // GopHandle is the UEFI child handle that carries the device path ending - // with the ACPI ADR node, and the Graphics Output Protocol. Never NULL. - // - EFI_HANDLE GopHandle; - - // - // The GopDevicePath field is the device path installed on GopHandle, - // ending with an ACPI ADR node. Never NULL. - // - EFI_DEVICE_PATH_PROTOCOL *GopDevicePath; - - // - // The Gop field is installed on the child handle as Graphics Output Protocol - // interface. - // - EFI_GRAPHICS_OUTPUT_PROTOCOL Gop; - - // - // Referenced by Gop.Mode, GopMode provides a summary about the supported - // graphics modes, and the current mode. - // - EFI_GRAPHICS_OUTPUT_PROTOCOL_MODE GopMode; - - // - // Referenced by GopMode.Info, GopModeInfo provides detailed information - // about the current mode. - // - EFI_GRAPHICS_OUTPUT_MODE_INFORMATION GopModeInfo; - - // - // Identifier of the 2D host resource that is in use by this head (scanout) - // of the VirtIo GPU device. Zero until the first successful -- internal -- - // Gop.SetMode() call, never zero afterwards. - // - UINT32 ResourceId; - - // - // A number of whole pages providing the backing store for the 2D host - // resource identified by ResourceId above. NULL until the first successful - // -- internal -- Gop.SetMode() call, never NULL afterwards. - // - UINT32 *BackingStore; - UINTN NumberOfPages; -}; - -// -// VirtIo GPU initialization, and commands (primitives) for the GPU device. -// -/** - Configure the VirtIo GPU device that underlies VgpuDev. - - @param[in,out] VgpuDev The VGPU_DEV object to set up VirtIo messaging for. - On input, the caller is responsible for having - initialized VgpuDev->VirtIo. On output, VgpuDev->Ring - has been initialized, and synchronous VirtIo GPU - commands (primitives) can be submitted to the device. - - @retval EFI_SUCCESS VirtIo GPU configuration successful. - - @retval EFI_UNSUPPORTED The host-side configuration of the VirtIo GPU is not - supported by this driver. - - @retval Error codes from underlying functions. -**/ -EFI_STATUS -VirtioGpuInit ( - IN OUT VGPU_DEV *VgpuDev - ); - -/** - De-configure the VirtIo GPU device that underlies VgpuDev. - - @param[in,out] VgpuDev The VGPU_DEV object to tear down VirtIo messaging - for. On input, the caller is responsible for having - called VirtioGpuInit(). On output, VgpuDev->Ring has - been uninitialized; VirtIo GPU commands (primitives) - can no longer be submitted to the device. -**/ -VOID -VirtioGpuUninit ( - IN OUT VGPU_DEV *VgpuDev - ); - -/** - EFI_EVENT_NOTIFY function for the VGPU_DEV.ExitBoot event. It resets the - VirtIo device, causing it to release its resources and to forget its - configuration. - - This function may only be called (that is, VGPU_DEV.ExitBoot may only be - signaled) after VirtioGpuInit() returns and before VirtioGpuUninit() is - called. - - @param[in] Event Event whose notification function is being invoked. - - @param[in] Context Pointer to the associated VGPU_DEV object. -**/ -VOID -EFIAPI -VirtioGpuExitBoot ( - IN EFI_EVENT Event, - IN VOID *Context - ); - -/** - The following functions send requests to the VirtIo GPU device model, await - the answer from the host, and return a status. They share the following - interface details: - - @param[in,out] VgpuDev The VGPU_DEV object that represents the VirtIo GPU - device. The caller is responsible to have - successfully invoked VirtioGpuInit() on VgpuDev - previously, while VirtioGpuUninit() must not have - been called on VgpuDev. - - @retval EFI_INVALID_PARAMETER Invalid command-specific parameters were - detected by this driver. - - @retval EFI_SUCCESS Operation successful. - - @retval EFI_DEVICE_ERROR The host rejected the request. The host error - code has been logged on the EFI_D_ERROR level. - - @return Codes for unexpected errors in VirtIo - messaging. - - For the command-specific parameters, please consult the GPU Device section of - the VirtIo 1.0 specification (see references in - "OvmfPkg/Include/IndustryStandard/VirtioGpu.h"). -**/ -EFI_STATUS -VirtioGpuResourceCreate2d ( - IN OUT VGPU_DEV *VgpuDev, - IN UINT32 ResourceId, - IN VIRTIO_GPU_FORMATS Format, - IN UINT32 Width, - IN UINT32 Height - ); - -EFI_STATUS -VirtioGpuResourceUnref ( - IN OUT VGPU_DEV *VgpuDev, - IN UINT32 ResourceId - ); - -EFI_STATUS -VirtioGpuResourceAttachBacking ( - IN OUT VGPU_DEV *VgpuDev, - IN UINT32 ResourceId, - IN VOID *FirstBackingPage, - IN UINTN NumberOfPages - ); - -EFI_STATUS -VirtioGpuResourceDetachBacking ( - IN OUT VGPU_DEV *VgpuDev, - IN UINT32 ResourceId - ); - -EFI_STATUS -VirtioGpuSetScanout ( - IN OUT VGPU_DEV *VgpuDev, - IN UINT32 X, - IN UINT32 Y, - IN UINT32 Width, - IN UINT32 Height, - IN UINT32 ScanoutId, - IN UINT32 ResourceId - ); - -EFI_STATUS -VirtioGpuTransferToHost2d ( - IN OUT VGPU_DEV *VgpuDev, - IN UINT32 X, - IN UINT32 Y, - IN UINT32 Width, - IN UINT32 Height, - IN UINT64 Offset, - IN UINT32 ResourceId - ); - -EFI_STATUS -VirtioGpuResourceFlush ( - IN OUT VGPU_DEV *VgpuDev, - IN UINT32 X, - IN UINT32 Y, - IN UINT32 Width, - IN UINT32 Height, - IN UINT32 ResourceId - ); - -/** - Release guest-side and host-side resources that are related to an initialized - VGPU_GOP.Gop. - - param[in,out] VgpuGop The VGPU_GOP object to release resources for. - - On input, the caller is responsible for having called - VgpuGop->Gop.SetMode() at least once successfully. - (This is equivalent to the requirement that - VgpuGop->BackingStore be non-NULL. It is also - equivalent to the requirement that VgpuGop->ResourceId - be nonzero.) - - On output, resources will be released, and - VgpuGop->BackingStore and VgpuGop->ResourceId will be - nulled. - - param[in] DisableHead Whether this head (scanout) currently references the - resource identified by VgpuGop->ResourceId. Only pass - FALSE when VgpuGop->Gop.SetMode() calls this function - while switching between modes, and set it to TRUE - every other time. -**/ -VOID -ReleaseGopResources ( - IN OUT VGPU_GOP *VgpuGop, - IN BOOLEAN DisableHead - ); - -// -// Template for initializing VGPU_GOP.Gop. -// -extern CONST EFI_GRAPHICS_OUTPUT_PROTOCOL mGopTemplate; - -#endif // _VIRTIO_GPU_DXE_H_ diff --git a/OvmfPkg/VirtioGpuDxe/VirtioGpu.inf b/OvmfPkg/VirtioGpuDxe/VirtioGpu.inf deleted file mode 100644 index 04bc2964c2..0000000000 --- a/OvmfPkg/VirtioGpuDxe/VirtioGpu.inf +++ /dev/null @@ -1,51 +0,0 @@ -## @file -# -# This hybrid driver produces the Graphics Output Protocol for the Virtio GPU -# device (head #0, only and unconditionally). -# -# Copyright (C) 2016, 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 = VirtioGpuDxe - FILE_GUID = D6099B94-CD97-4CC5-8714-7F6312701A8A - MODULE_TYPE = UEFI_DRIVER - VERSION_STRING = 1.0 - ENTRY_POINT = VirtioGpuEntryPoint - -[Sources] - Commands.c - DriverBinding.c - Gop.c - VirtioGpu.h - -[Packages] - MdePkg/MdePkg.dec - OvmfPkg/OvmfPkg.dec - -[LibraryClasses] - BaseMemoryLib - DebugLib - DevicePathLib - MemoryAllocationLib - PrintLib - UefiBootServicesTableLib - UefiDriverEntryPoint - UefiLib - VirtioLib - -[Protocols] - gEfiDevicePathProtocolGuid ## TO_START ## BY_START - gEfiGraphicsOutputProtocolGuid ## BY_START - gEfiPciIoProtocolGuid ## TO_START - gVirtioDeviceProtocolGuid ## TO_START diff --git a/OvmfPkg/VirtioNetDxe/ComponentName.c b/OvmfPkg/VirtioNetDxe/ComponentName.c deleted file mode 100644 index 2c96adbcbd..0000000000 --- a/OvmfPkg/VirtioNetDxe/ComponentName.c +++ /dev/null @@ -1,177 +0,0 @@ -/** @file - - Component Name code for the virtio-net driver. - - Copyright (C) 2013, Red Hat, Inc. - Copyright (c) 2006 - 2011, Intel Corporation. All rights reserved.
- - This program and the accompanying materials are licensed and made available - under the terms and conditions of the BSD License which accompanies this - distribution. The full text of the license may be found at - http://opensource.org/licenses/bsd-license.php - - THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, WITHOUT - WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. - -**/ - -#include - -#include "VirtioNet.h" - -STATIC -EFI_UNICODE_STRING_TABLE mVirtioNetDriverNameTable[] = { - { "eng;en", L"Virtio Network Driver" }, - { NULL, NULL } -}; - -STATIC -EFI_UNICODE_STRING_TABLE mVirtioNetControllerNameTable[] = { - { "eng;en", L"Virtio Network Device" }, - { NULL, NULL } -}; - -/** - Retrieves a Unicode string that is the user-readable name of the EFI Driver. - - @param This A pointer to the EFI_COMPONENT_NAME_PROTOCOL instance. - @param Language A pointer to a three-character ISO 639-2 language - identifier. This is the language of the driver name that - that the caller is requesting, and it must match one of - the languages specified in SupportedLanguages. The number - of languages supported by a driver is up to the driver - writer. - @param DriverName A pointer to the Unicode string to return. This Unicode - string is the name of the driver specified by This in the - language specified by Language. - - @retval EFI_SUCCESS The Unicode string for the Driver specified by - This and the language specified by Language was - returned in DriverName. - @retval EFI_INVALID_PARAMETER Language is NULL. - @retval EFI_INVALID_PARAMETER DriverName is NULL. - @retval EFI_UNSUPPORTED The driver specified by This does not support - the language specified by Language. - -**/ - -STATIC -EFI_STATUS -EFIAPI -VirtioNetGetDriverName ( - IN EFI_COMPONENT_NAME_PROTOCOL *This, - IN CHAR8 *Language, - OUT CHAR16 **DriverName - ) -{ - return (Language == NULL || DriverName == NULL) ? - EFI_INVALID_PARAMETER : - LookupUnicodeString2 ( - Language, - This->SupportedLanguages, - mVirtioNetDriverNameTable, - DriverName, - (BOOLEAN) (This == &gVirtioNetComponentName) // Iso639Language - ); -} - - -/** - Retrieves a Unicode string that is the user readable name of the controller - that is being managed by an EFI Driver. - - @param This A pointer to the EFI_COMPONENT_NAME_PROTOCOL - instance. - @param ControllerHandle The handle of a controller that the driver specified - by This is managing. This handle specifies the - controller whose name is to be returned. - @param ChildHandle The handle of the child controller to retrieve the - name of. This is an optional parameter that may be - NULL. It will be NULL for device drivers. It will - also be NULL for a bus drivers that wish to retrieve - the name of the bus controller. It will not be NULL - for a bus driver that wishes to retrieve the name of - a child controller. - @param Language A pointer to a three character ISO 639-2 language - identifier. This is the language of the controller - name that the caller is requesting, and it must - match one of the languages specified in - SupportedLanguages. The number of languages - supported by a driver is up to the driver writer. - @param ControllerName A pointer to the Unicode string to return. This - Unicode string is the name of the controller - specified by ControllerHandle and ChildHandle in the - language specified by Language, from the point of - view of the driver specified by This. - - @retval EFI_SUCCESS The Unicode string for the user-readable name - in the language specified by Language for the - driver specified by This was returned in - DriverName. - @retval EFI_INVALID_PARAMETER ControllerHandle is NULL. - @retval EFI_INVALID_PARAMETER ChildHandle is not NULL and it is not a valid - EFI_HANDLE. - @retval EFI_INVALID_PARAMETER Language is NULL. - @retval EFI_INVALID_PARAMETER ControllerName is NULL. - @retval EFI_UNSUPPORTED The driver specified by This is not currently - managing the controller specified by - ControllerHandle and ChildHandle. - @retval EFI_UNSUPPORTED The driver specified by This does not support - the language specified by Language. - -**/ - -STATIC -EFI_STATUS -EFIAPI -VirtioNetGetControllerName ( - IN EFI_COMPONENT_NAME_PROTOCOL *This, - IN EFI_HANDLE ControllerHandle, - IN EFI_HANDLE ChildHandle, - IN CHAR8 *Language, - OUT CHAR16 **ControllerName - ) -{ - EFI_STATUS Status; - - if (ControllerHandle == NULL || Language == NULL || ControllerName == NULL) { - return EFI_INVALID_PARAMETER; - } - - // - // confirm that the device is managed by this driver, using the VirtIo - // Protocol - // - Status = EfiTestManagedDevice ( - ControllerHandle, - gVirtioNetDriverBinding.DriverBindingHandle, - &gVirtioDeviceProtocolGuid - ); - if (EFI_ERROR (Status)) { - return Status; - } - - // - // we don't give different names to the bus (= parent) handle and the - // child (= MAC) handle - // - return LookupUnicodeString2 ( - Language, - This->SupportedLanguages, - mVirtioNetControllerNameTable, - ControllerName, - (BOOLEAN) (This == &gVirtioNetComponentName) // Iso639Language - ); -} - -EFI_COMPONENT_NAME_PROTOCOL gVirtioNetComponentName = { - &VirtioNetGetDriverName, - &VirtioNetGetControllerName, - "eng" // SupportedLanguages, ISO 639-2 language codes -}; - -EFI_COMPONENT_NAME2_PROTOCOL gVirtioNetComponentName2 = { - (EFI_COMPONENT_NAME2_GET_DRIVER_NAME) &VirtioNetGetDriverName, - (EFI_COMPONENT_NAME2_GET_CONTROLLER_NAME) &VirtioNetGetControllerName, - "en" // SupportedLanguages, RFC 4646 language codes -}; diff --git a/OvmfPkg/VirtioNetDxe/DriverBinding.c b/OvmfPkg/VirtioNetDxe/DriverBinding.c deleted file mode 100644 index bcf9ebbdad..0000000000 --- a/OvmfPkg/VirtioNetDxe/DriverBinding.c +++ /dev/null @@ -1,653 +0,0 @@ -/** @file - - Driver Binding code and its private helpers for the virtio-net driver. - - Copyright (C) 2013, Red Hat, Inc. - Copyright (c) 2006 - 2014, Intel Corporation. All rights reserved.
- - This program and the accompanying materials are licensed and made available - under the terms and conditions of the BSD License which accompanies this - distribution. The full text of the license may be found at - http://opensource.org/licenses/bsd-license.php - - THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, WITHOUT - WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. - -**/ - -#include -#include -#include -#include - -#include "VirtioNet.h" - -#define RECEIVE_FILTERS_NO_MCAST ((UINT32) ( \ - EFI_SIMPLE_NETWORK_RECEIVE_UNICAST | \ - EFI_SIMPLE_NETWORK_RECEIVE_BROADCAST | \ - EFI_SIMPLE_NETWORK_RECEIVE_PROMISCUOUS \ - )) - -/* - Temporarily enable then reset the virtio-net device in order to retrieve - configuration values needed by Simple Network Protocol and Simple Network - Mode fields. - - Only VirtioNetSnpPopulate() may call this function. - - If the function fails for any reason, the virtio-net device is moved to - VSTAT_FAILED instead of being reset. This serves only informative purposes - for the host side. - - param[in,out] Dev The VNET_DEV structure being created for - the virtio-net device. - param[out] MacAddress MAC address configured by the host. - param[out] MediaPresentSupported Link status is made available by the host. - param[out] MediaPresent If link status is made available by the - host, the current link status is stored in - *MediaPresent. Otherwise MediaPresent is - unused. - - @retval EFI_UNSUPPORTED The host doesn't supply a MAC address. - @return Status codes from VirtIo protocol members. - @retval EFI_SUCCESS Configuration values retrieved. -*/ -STATIC -EFI_STATUS -EFIAPI -VirtioNetGetFeatures ( - IN OUT VNET_DEV *Dev, - OUT EFI_MAC_ADDRESS *MacAddress, - OUT BOOLEAN *MediaPresentSupported, - OUT BOOLEAN *MediaPresent - ) -{ - EFI_STATUS Status; - UINT8 NextDevStat; - UINT64 Features; - UINTN MacIdx; - UINT16 LinkStatus; - - // - // Interrogate the device for features (virtio-0.9.5, 2.2.1 Device - // Initialization Sequence), but don't complete setting it up. - // - NextDevStat = 0; // step 1 -- reset device - Status = Dev->VirtIo->SetDeviceStatus (Dev->VirtIo, NextDevStat); - if (EFI_ERROR (Status)) { - return Status; - } - - NextDevStat |= VSTAT_ACK; // step 2 -- acknowledge device presence - Status = Dev->VirtIo->SetDeviceStatus (Dev->VirtIo, NextDevStat); - if (EFI_ERROR (Status)) { - goto YieldDevice; - } - - NextDevStat |= VSTAT_DRIVER; // step 3 -- we know how to drive it - Status = Dev->VirtIo->SetDeviceStatus (Dev->VirtIo, NextDevStat); - if (EFI_ERROR (Status)) { - goto YieldDevice; - } - - // - // step 4a -- retrieve and validate features - // - Status = Dev->VirtIo->GetDeviceFeatures (Dev->VirtIo, &Features); - if (EFI_ERROR (Status)) { - goto YieldDevice; - } - - // - // get MAC address byte-wise - // - if ((Features & VIRTIO_NET_F_MAC) == 0) { - Status = EFI_UNSUPPORTED; - goto YieldDevice; - } - for (MacIdx = 0; MacIdx < SIZE_OF_VNET (Mac); ++MacIdx) { - Status = Dev->VirtIo->ReadDevice (Dev->VirtIo, - OFFSET_OF_VNET (Mac) + MacIdx, // Offset - 1, // FieldSize - 1, // BufferSize - &MacAddress->Addr[MacIdx] // Buffer - ); - if (EFI_ERROR (Status)) { - goto YieldDevice; - } - } - - // - // check if link status is reported, and if so, what the link status is - // - if ((Features & VIRTIO_NET_F_STATUS) == 0) { - *MediaPresentSupported = FALSE; - } - else { - *MediaPresentSupported = TRUE; - Status = VIRTIO_CFG_READ (Dev, LinkStatus, &LinkStatus); - if (EFI_ERROR (Status)) { - goto YieldDevice; - } - *MediaPresent = (BOOLEAN) ((LinkStatus & VIRTIO_NET_S_LINK_UP) != 0); - } - -YieldDevice: - Dev->VirtIo->SetDeviceStatus (Dev->VirtIo, - EFI_ERROR (Status) ? VSTAT_FAILED : 0); - - return Status; -} - - -/** - Set up the Simple Network Protocol fields, the Simple Network Mode fields, - and the Exit Boot Services Event of the virtio-net driver instance. - - This function may only be called by VirtioNetDriverBindingStart(). - - @param[in,out] Dev The VNET_DEV driver instance being created for the - virtio-net device. - - @return Status codes from the CreateEvent() boot service or the - VirtioNetGetFeatures() function. - @retval EFI_SUCCESS Configuration successful. -*/ -STATIC -EFI_STATUS -EFIAPI -VirtioNetSnpPopulate ( - IN OUT VNET_DEV *Dev - ) -{ - EFI_STATUS Status; - - // - // We set up a function here that is asynchronously callable by an - // external application to check if there are any packets available for - // reception. The least urgent task priority level we can specify for such a - // "software interrupt" is TPL_CALLBACK. - // - // TPL_CALLBACK is also the maximum TPL an SNP implementation is allowed to - // run at (see 6.1 Event, Timer, and Task Priority Services in the UEFI - // Specification 2.3.1+errC). - // - // Since we raise our TPL to TPL_CALLBACK in every single function that - // accesses the device, and the external application also queues its interest - // for received packets at the same TPL_CALLBACK, in effect the - // VirtioNetIsPacketAvailable() function will never interrupt any - // device-accessing driver function, it will be scheduled in isolation. - // - // TPL_CALLBACK (which basically this entire driver runs at) is allowed - // for "[l]ong term operations (such as file system operations and disk - // I/O)". Because none of our functions block, we'd satisfy an even stronger - // requirement. - // - Status = gBS->CreateEvent (EVT_NOTIFY_WAIT, TPL_CALLBACK, - &VirtioNetIsPacketAvailable, Dev, &Dev->Snp.WaitForPacket); - if (EFI_ERROR (Status)) { - return Status; - } - - Dev->Snp.Revision = EFI_SIMPLE_NETWORK_PROTOCOL_REVISION; - Dev->Snp.Start = &VirtioNetStart; - Dev->Snp.Stop = &VirtioNetStop; - Dev->Snp.Initialize = &VirtioNetInitialize; - Dev->Snp.Reset = &VirtioNetReset; - Dev->Snp.Shutdown = &VirtioNetShutdown; - Dev->Snp.ReceiveFilters = &VirtioNetReceiveFilters; - Dev->Snp.StationAddress = &VirtioNetStationAddress; - Dev->Snp.Statistics = &VirtioNetStatistics; - Dev->Snp.MCastIpToMac = &VirtioNetMcastIpToMac; - Dev->Snp.NvData = &VirtioNetNvData; - Dev->Snp.GetStatus = &VirtioNetGetStatus; - Dev->Snp.Transmit = &VirtioNetTransmit; - Dev->Snp.Receive = &VirtioNetReceive; - Dev->Snp.Mode = &Dev->Snm; - - Dev->Snm.State = EfiSimpleNetworkStopped; - Dev->Snm.HwAddressSize = SIZE_OF_VNET (Mac); - Dev->Snm.MediaHeaderSize = SIZE_OF_VNET (Mac) + // dst MAC - SIZE_OF_VNET (Mac) + // src MAC - 2; // Ethertype - Dev->Snm.MaxPacketSize = 1500; - Dev->Snm.NvRamSize = 0; - Dev->Snm.NvRamAccessSize = 0; - Dev->Snm.ReceiveFilterMask = RECEIVE_FILTERS_NO_MCAST; - Dev->Snm.ReceiveFilterSetting = RECEIVE_FILTERS_NO_MCAST; - Dev->Snm.MaxMCastFilterCount = 0; - Dev->Snm.MCastFilterCount = 0; - Dev->Snm.IfType = 1; // ethernet - Dev->Snm.MacAddressChangeable = FALSE; - Dev->Snm.MultipleTxSupported = TRUE; - - ASSERT (SIZE_OF_VNET (Mac) <= sizeof (EFI_MAC_ADDRESS)); - - Status = VirtioNetGetFeatures (Dev, &Dev->Snm.CurrentAddress, - &Dev->Snm.MediaPresentSupported, &Dev->Snm.MediaPresent); - if (EFI_ERROR (Status)) { - goto CloseWaitForPacket; - } - CopyMem (&Dev->Snm.PermanentAddress, &Dev->Snm.CurrentAddress, - SIZE_OF_VNET (Mac)); - SetMem (&Dev->Snm.BroadcastAddress, SIZE_OF_VNET (Mac), 0xFF); - - // - // VirtioNetExitBoot() is queued by ExitBootServices(); its purpose is to - // cancel any pending virtio requests. The TPL_CALLBACK reasoning is - // identical to the one above. There's one difference: this kind of - // event is "globally visible", which means it can be signalled as soon as - // we create it. We haven't raised our TPL here, hence VirtioNetExitBoot() - // could be entered immediately. VirtioNetExitBoot() checks Dev->Snm.State, - // so we're safe. - // - Status = gBS->CreateEvent (EVT_SIGNAL_EXIT_BOOT_SERVICES, TPL_CALLBACK, - &VirtioNetExitBoot, Dev, &Dev->ExitBoot); - if (EFI_ERROR (Status)) { - goto CloseWaitForPacket; - } - - return EFI_SUCCESS; - -CloseWaitForPacket: - gBS->CloseEvent (Dev->Snp.WaitForPacket); - return Status; -} - - -/** - Release any resources allocated by VirtioNetSnpPopulate(). - - This function may only be called by VirtioNetDriverBindingStart(), when - rolling back a partial, failed driver instance creation, and by - VirtioNetDriverBindingStop(), when disconnecting a virtio-net device from the - driver. - - @param[in,out] Dev The VNET_DEV driver instance being destroyed. -*/ -STATIC -VOID -EFIAPI -VirtioNetSnpEvacuate ( - IN OUT VNET_DEV *Dev - ) -{ - // - // This function runs either at TPL_CALLBACK already (from - // VirtioNetDriverBindingStop()), or it is part of a teardown following - // a partial, failed construction in VirtioNetDriverBindingStart(), when - // WaitForPacket was never accessible to the world. - // - gBS->CloseEvent (Dev->ExitBoot); - gBS->CloseEvent (Dev->Snp.WaitForPacket); -} - - -/** - Tests to see if this driver supports a given controller. If a child device is - provided, it further tests to see if this driver supports creating a handle - for the specified child device. - - This function checks to see if the driver specified by This supports the - device specified by ControllerHandle. Drivers will typically use the device - path attached to ControllerHandle and/or the services from the bus I/O - abstraction attached to ControllerHandle to determine if the driver supports - ControllerHandle. This function may be called many times during platform - initialization. In order to reduce boot times, the tests performed by this - function must be very small, and take as little time as possible to execute. - This function must not change the state of any hardware devices, and this - function must be aware that the device specified by ControllerHandle may - already be managed by the same driver or a different driver. This function - must match its calls to AllocatePages() with FreePages(), AllocatePool() with - FreePool(), and OpenProtocol() with CloseProtocol(). Because ControllerHandle - may have been previously started by the same driver, if a protocol is already - in the opened state, then it must not be closed with CloseProtocol(). This is - required to guarantee the state of ControllerHandle is not modified by this - function. - - @param[in] This A pointer to the EFI_DRIVER_BINDING_PROTOCOL - instance. - @param[in] ControllerHandle The handle of the controller to test. This - handle must support a protocol interface - that supplies an I/O abstraction to the - driver. - @param[in] RemainingDevicePath A pointer to the remaining portion of a - device path. This parameter is ignored by - device drivers, and is optional for bus - drivers. For bus drivers, if this parameter - is not NULL, then the bus driver must - determine if the bus controller specified by - ControllerHandle and the child controller - specified by RemainingDevicePath are both - supported by this bus driver. - - @retval EFI_SUCCESS The device specified by ControllerHandle and - RemainingDevicePath is supported by the - driver specified by This. - @retval EFI_ALREADY_STARTED The device specified by ControllerHandle and - RemainingDevicePath is already being managed - by the driver specified by This. - @retval EFI_ACCESS_DENIED The device specified by ControllerHandle and - RemainingDevicePath is already being managed - by a different driver or an application that - requires exclusive access. Currently not - implemented. - @retval EFI_UNSUPPORTED The device specified by ControllerHandle and - RemainingDevicePath is not supported by the - driver specified by This. -**/ - -STATIC -EFI_STATUS -EFIAPI -VirtioNetDriverBindingSupported ( - IN EFI_DRIVER_BINDING_PROTOCOL *This, - IN EFI_HANDLE DeviceHandle, - IN EFI_DEVICE_PATH_PROTOCOL *RemainingDevicePath - ) -{ - EFI_STATUS Status; - VIRTIO_DEVICE_PROTOCOL *VirtIo; - - // - // Attempt to open the device with the VirtIo set of interfaces. On success, - // the protocol is "instantiated" for the VirtIo device. Covers duplicate open - // attempts (EFI_ALREADY_STARTED). - // - Status = gBS->OpenProtocol ( - DeviceHandle, // candidate device - &gVirtioDeviceProtocolGuid, // for generic VirtIo access - (VOID **)&VirtIo, // handle to instantiate - This->DriverBindingHandle, // requestor driver identity - DeviceHandle, // ControllerHandle, according to - // the UEFI Driver Model - EFI_OPEN_PROTOCOL_BY_DRIVER // get exclusive VirtIo access to - // the device; to be released - ); - if (EFI_ERROR (Status)) { - return Status; - } - - if (VirtIo->SubSystemDeviceId != VIRTIO_SUBSYSTEM_NETWORK_CARD) { - Status = EFI_UNSUPPORTED; - } - - // - // We needed VirtIo access only transitorily, to see whether we support the - // device or not. - // - gBS->CloseProtocol (DeviceHandle, &gVirtioDeviceProtocolGuid, - This->DriverBindingHandle, DeviceHandle); - return Status; -} - - -/** - Starts a device controller or a bus controller. - - The Start() function is designed to be invoked from the EFI boot service - ConnectController(). As a result, much of the error checking on the - parameters to Start() has been moved into this common boot service. It is - legal to call Start() from other locations, but the following calling - restrictions must be followed, or the system behavior will not be - deterministic. - 1. ControllerHandle must be a valid EFI_HANDLE. - 2. If RemainingDevicePath is not NULL, then it must be a pointer to a - naturally aligned EFI_DEVICE_PATH_PROTOCOL. - 3. Prior to calling Start(), the Supported() function for the driver - specified by This must have been called with the same calling parameters, - and Supported() must have returned EFI_SUCCESS. - - @param[in] This A pointer to the EFI_DRIVER_BINDING_PROTOCOL - instance. - @param[in] ControllerHandle The handle of the controller to start. This - handle must support a protocol interface - that supplies an I/O abstraction to the - driver. - @param[in] RemainingDevicePath A pointer to the remaining portion of a - device path. This parameter is ignored by - device drivers, and is optional for bus - drivers. For a bus driver, if this parameter - is NULL, then handles for all the children - of Controller are created by this driver. - If this parameter is not NULL and the first - Device Path Node is not the End of Device - Path Node, then only the handle for the - child device specified by the first Device - Path Node of RemainingDevicePath is created - by this driver. If the first Device Path - Node of RemainingDevicePath is the End of - Device Path Node, no child handle is created - by this driver. - - @retval EFI_SUCCESS The device was started. - @retval EFI_DEVICE_ERROR The device could not be started due to a - device error.Currently not implemented. - @retval EFI_OUT_OF_RESOURCES The request could not be completed due to a - lack of resources. - @retval Others The driver failded to start the device. - -**/ - -STATIC -EFI_STATUS -EFIAPI -VirtioNetDriverBindingStart ( - IN EFI_DRIVER_BINDING_PROTOCOL *This, - IN EFI_HANDLE DeviceHandle, - IN EFI_DEVICE_PATH_PROTOCOL *RemainingDevicePath - ) -{ - EFI_STATUS Status; - VNET_DEV *Dev; - EFI_DEVICE_PATH_PROTOCOL *DevicePath; - MAC_ADDR_DEVICE_PATH MacNode; - VOID *ChildVirtIo; - - // - // allocate space for the driver instance - // - Dev = (VNET_DEV *) AllocateZeroPool (sizeof *Dev); - if (Dev == NULL) { - return EFI_OUT_OF_RESOURCES; - } - Dev->Signature = VNET_SIG; - - Status = gBS->OpenProtocol (DeviceHandle, &gVirtioDeviceProtocolGuid, - (VOID **)&Dev->VirtIo, This->DriverBindingHandle, - DeviceHandle, EFI_OPEN_PROTOCOL_BY_DRIVER); - if (EFI_ERROR (Status)) { - goto FreeVirtioNet; - } - - // - // now we can run a basic one-shot virtio-net initialization required to - // retrieve the MAC address - // - Status = VirtioNetSnpPopulate (Dev); - if (EFI_ERROR (Status)) { - goto CloseVirtIo; - } - - // - // get the device path of the virtio-net device -- one-shot open - // - Status = gBS->OpenProtocol (DeviceHandle, &gEfiDevicePathProtocolGuid, - (VOID **)&DevicePath, This->DriverBindingHandle, - DeviceHandle, EFI_OPEN_PROTOCOL_GET_PROTOCOL); - if (EFI_ERROR (Status)) { - goto Evacuate; - } - - // - // create another device path that has the MAC address appended - // - MacNode.Header.Type = MESSAGING_DEVICE_PATH; - MacNode.Header.SubType = MSG_MAC_ADDR_DP; - SetDevicePathNodeLength (&MacNode, sizeof MacNode); - CopyMem (&MacNode.MacAddress, &Dev->Snm.CurrentAddress, - sizeof (EFI_MAC_ADDRESS)); - MacNode.IfType = Dev->Snm.IfType; - - Dev->MacDevicePath = AppendDevicePathNode (DevicePath, &MacNode.Header); - if (Dev->MacDevicePath == NULL) { - Status = EFI_OUT_OF_RESOURCES; - goto Evacuate; - } - - // - // create a child handle with the Simple Network Protocol and the new - // device path installed on it - // - Status = gBS->InstallMultipleProtocolInterfaces (&Dev->MacHandle, - &gEfiSimpleNetworkProtocolGuid, &Dev->Snp, - &gEfiDevicePathProtocolGuid, Dev->MacDevicePath, - NULL); - if (EFI_ERROR (Status)) { - goto FreeMacDevicePath; - } - - // - // make a note that we keep this device open with VirtIo for the sake of this - // child - // - Status = gBS->OpenProtocol (DeviceHandle, &gVirtioDeviceProtocolGuid, - &ChildVirtIo, This->DriverBindingHandle, - Dev->MacHandle, EFI_OPEN_PROTOCOL_BY_CHILD_CONTROLLER); - if (EFI_ERROR (Status)) { - goto UninstallMultiple; - } - - return EFI_SUCCESS; - -UninstallMultiple: - gBS->UninstallMultipleProtocolInterfaces (Dev->MacHandle, - &gEfiDevicePathProtocolGuid, Dev->MacDevicePath, - &gEfiSimpleNetworkProtocolGuid, &Dev->Snp, - NULL); - -FreeMacDevicePath: - FreePool (Dev->MacDevicePath); - -Evacuate: - VirtioNetSnpEvacuate (Dev); - -CloseVirtIo: - gBS->CloseProtocol (DeviceHandle, &gVirtioDeviceProtocolGuid, - This->DriverBindingHandle, DeviceHandle); - -FreeVirtioNet: - FreePool (Dev); - - return Status; -} - - -/** - Stops a device controller or a bus controller. - - The Stop() function is designed to be invoked from the EFI boot service - DisconnectController(). As a result, much of the error checking on the - parameters to Stop() has been moved into this common boot service. It is - legal to call Stop() from other locations, but the following calling - restrictions must be followed, or the system behavior will not be - deterministic. - 1. ControllerHandle must be a valid EFI_HANDLE that was used on a previous - call to this same driver's Start() function. - 2. The first NumberOfChildren handles of ChildHandleBuffer must all be a - valid EFI_HANDLE. In addition, all of these handles must have been created - in this driver's Start() function, and the Start() function must have - called OpenProtocol() on ControllerHandle with an Attribute of - EFI_OPEN_PROTOCOL_BY_CHILD_CONTROLLER. - - @param[in] This A pointer to the EFI_DRIVER_BINDING_PROTOCOL - instance. - @param[in] ControllerHandle A handle to the device being stopped. The - handle must support a bus specific I/O - protocol for the driver to use to stop the - device. - @param[in] NumberOfChildren The number of child device handles in - ChildHandleBuffer. - @param[in] ChildHandleBuffer An array of child handles to be freed. May be - NULL if NumberOfChildren is 0. - - @retval EFI_SUCCESS The device was stopped. - @retval EFI_DEVICE_ERROR The device could not be stopped due to a device - error. - -**/ -STATIC -EFI_STATUS -EFIAPI -VirtioNetDriverBindingStop ( - IN EFI_DRIVER_BINDING_PROTOCOL *This, - IN EFI_HANDLE DeviceHandle, - IN UINTN NumberOfChildren, - IN EFI_HANDLE *ChildHandleBuffer - ) -{ - if (NumberOfChildren > 0) { - // - // free all resources for whose access we need the child handle, because - // the child handle is going away - // - EFI_STATUS Status; - EFI_SIMPLE_NETWORK_PROTOCOL *Snp; - VNET_DEV *Dev; - EFI_TPL OldTpl; - - ASSERT (NumberOfChildren == 1); - - Status = gBS->OpenProtocol (ChildHandleBuffer[0], - &gEfiSimpleNetworkProtocolGuid, (VOID **)&Snp, - This->DriverBindingHandle, DeviceHandle, - EFI_OPEN_PROTOCOL_GET_PROTOCOL); - ASSERT_EFI_ERROR (Status); - Dev = VIRTIO_NET_FROM_SNP (Snp); - - // - // prevent any interference with WaitForPacket - // - OldTpl = gBS->RaiseTPL (TPL_CALLBACK); - - ASSERT (Dev->MacHandle == ChildHandleBuffer[0]); - if (Dev->Snm.State != EfiSimpleNetworkStopped) { - // - // device in use, cannot stop driver instance - // - Status = EFI_DEVICE_ERROR; - } - else { - gBS->CloseProtocol (DeviceHandle, &gVirtioDeviceProtocolGuid, - This->DriverBindingHandle, Dev->MacHandle); - gBS->UninstallMultipleProtocolInterfaces (Dev->MacHandle, - &gEfiDevicePathProtocolGuid, Dev->MacDevicePath, - &gEfiSimpleNetworkProtocolGuid, &Dev->Snp, - NULL); - FreePool (Dev->MacDevicePath); - VirtioNetSnpEvacuate (Dev); - FreePool (Dev); - } - - gBS->RestoreTPL (OldTpl); - return Status; - } - - // - // release remaining resources, tied directly to the parent handle - // - gBS->CloseProtocol (DeviceHandle, &gVirtioDeviceProtocolGuid, - This->DriverBindingHandle, DeviceHandle); - - return EFI_SUCCESS; -} - - -EFI_DRIVER_BINDING_PROTOCOL gVirtioNetDriverBinding = { - &VirtioNetDriverBindingSupported, - &VirtioNetDriverBindingStart, - &VirtioNetDriverBindingStop, - 0x10, - NULL, - NULL -}; diff --git a/OvmfPkg/VirtioNetDxe/EntryPoint.c b/OvmfPkg/VirtioNetDxe/EntryPoint.c deleted file mode 100644 index bbf6d8f1a0..0000000000 --- a/OvmfPkg/VirtioNetDxe/EntryPoint.c +++ /dev/null @@ -1,50 +0,0 @@ -/** @file - - This file implements the entry point of the virtio-net driver. - - Copyright (C) 2013, Red Hat, Inc. - Copyright (c) 2006 - 2012, Intel Corporation. All rights reserved.
- - This program and the accompanying materials are licensed and made available - under the terms and conditions of the BSD License which accompanies this - distribution. The full text of the license may be found at - http://opensource.org/licenses/bsd-license.php - - THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, WITHOUT - WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. - -**/ - -#include - -#include "VirtioNet.h" - -/** - This is the declaration of an EFI image entry point. This entry point is the - same for UEFI Applications, UEFI OS Loaders, and UEFI Drivers including both - device drivers and bus drivers. - - @param ImageHandle The firmware allocated handle for the UEFI - image. - @param SystemTable A pointer to the EFI System Table. - - @retval EFI_SUCCESS The operation completed successfully. - @retval Others An unexpected error occurred. -**/ - -EFI_STATUS -EFIAPI -VirtioNetEntryPoint ( - IN EFI_HANDLE ImageHandle, - IN EFI_SYSTEM_TABLE *SystemTable - ) -{ - return EfiLibInstallDriverBindingComponentName2 ( - ImageHandle, - SystemTable, - &gVirtioNetDriverBinding, - ImageHandle, - &gVirtioNetComponentName, - &gVirtioNetComponentName2 - ); -} diff --git a/OvmfPkg/VirtioNetDxe/Events.c b/OvmfPkg/VirtioNetDxe/Events.c deleted file mode 100644 index 5be1af6ffb..0000000000 --- a/OvmfPkg/VirtioNetDxe/Events.c +++ /dev/null @@ -1,91 +0,0 @@ -/** @file - - Implements - - the SNM.WaitForPacket EVT_NOTIFY_WAIT event, - - the EVT_SIGNAL_EXIT_BOOT_SERVICES event - for the virtio-net driver. - - Copyright (C) 2013, Red Hat, Inc. - Copyright (c) 2006 - 2012, Intel Corporation. All rights reserved.
- - This program and the accompanying materials are licensed and made available - under the terms and conditions of the BSD License which accompanies this - distribution. The full text of the license may be found at - http://opensource.org/licenses/bsd-license.php - - THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, WITHOUT - WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. - -**/ - -#include -#include - -#include "VirtioNet.h" - -/** - Invoke a notification event - - @param Event Event whose notification function is being - invoked. - @param Context The pointer to the notification function's - context, which is implementation-dependent. - -**/ - -VOID -EFIAPI -VirtioNetIsPacketAvailable ( - IN EFI_EVENT Event, - IN VOID *Context - ) -{ - // - // This callback has been enqueued by an external application and is - // running at TPL_CALLBACK already. - // - // The WaitForPacket logic is similar to that of WaitForKey. The former has - // almost no documentation in either the UEFI-2.3.1+errC spec or the - // DWG-2.3.1, but WaitForKey does have some. - // - VNET_DEV *Dev; - UINT16 RxCurUsed; - - Dev = Context; - if (Dev->Snm.State != EfiSimpleNetworkInitialized) { - return; - } - - // - // virtio-0.9.5, 2.4.2 Receiving Used Buffers From the Device - // - MemoryFence (); - RxCurUsed = *Dev->RxRing.Used.Idx; - MemoryFence (); - - if (Dev->RxLastUsed != RxCurUsed) { - gBS->SignalEvent (&Dev->Snp.WaitForPacket); - } -} - -VOID -EFIAPI -VirtioNetExitBoot ( - IN EFI_EVENT Event, - IN VOID *Context - ) -{ - // - // This callback has been enqueued by ExitBootServices() and is running at - // TPL_CALLBACK already. - // - // Shut down pending transfers according to DWG-2.3.1, "25.5.1 Exit Boot - // Services Event". - // - VNET_DEV *Dev; - - Dev = Context; - if (Dev->Snm.State == EfiSimpleNetworkInitialized) { - Dev->VirtIo->SetDeviceStatus (Dev->VirtIo, 0); - } -} diff --git a/OvmfPkg/VirtioNetDxe/SnpGetStatus.c b/OvmfPkg/VirtioNetDxe/SnpGetStatus.c deleted file mode 100644 index 694940ea1d..0000000000 --- a/OvmfPkg/VirtioNetDxe/SnpGetStatus.c +++ /dev/null @@ -1,160 +0,0 @@ -/** @file - - Implementation of the SNP.GetStatus() function and its private helpers if - any. - - Copyright (C) 2013, Red Hat, Inc. - Copyright (c) 2006 - 2014, Intel Corporation. All rights reserved.
- - This program and the accompanying materials are licensed and made available - under the terms and conditions of the BSD License which accompanies this - distribution. The full text of the license may be found at - http://opensource.org/licenses/bsd-license.php - - THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, WITHOUT - WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. - -**/ - -#include -#include - -#include "VirtioNet.h" - -/** - Reads the current interrupt status and recycled transmit buffer status from - a network interface. - - @param This The protocol instance pointer. - @param InterruptStatus A pointer to the bit mask of the currently active - interrupts If this is NULL, the interrupt status will - not be read from the device. If this is not NULL, the - interrupt status will be read from the device. When - the interrupt status is read, it will also be - cleared. Clearing the transmit interrupt does not - empty the recycled transmit buffer array. - @param TxBuf Recycled transmit buffer address. The network - interface will not transmit if its internal recycled - transmit buffer array is full. Reading the transmit - buffer does not clear the transmit interrupt. If this - is NULL, then the transmit buffer status will not be - read. If there are no transmit buffers to recycle and - TxBuf is not NULL, * TxBuf will be set to NULL. - - @retval EFI_SUCCESS The status of the network interface was - retrieved. - @retval EFI_NOT_STARTED The network interface has not been started. - @retval EFI_INVALID_PARAMETER One or more of the parameters has an - unsupported value. - @retval EFI_DEVICE_ERROR The command could not be sent to the network - interface. - @retval EFI_UNSUPPORTED This function is not supported by the network - interface. - -**/ - -EFI_STATUS -EFIAPI -VirtioNetGetStatus ( - IN EFI_SIMPLE_NETWORK_PROTOCOL *This, - OUT UINT32 *InterruptStatus OPTIONAL, - OUT VOID **TxBuf OPTIONAL - ) -{ - VNET_DEV *Dev; - EFI_TPL OldTpl; - EFI_STATUS Status; - UINT16 RxCurUsed; - UINT16 TxCurUsed; - - if (This == NULL) { - return EFI_INVALID_PARAMETER; - } - - Dev = VIRTIO_NET_FROM_SNP (This); - OldTpl = gBS->RaiseTPL (TPL_CALLBACK); - switch (Dev->Snm.State) { - case EfiSimpleNetworkStopped: - Status = EFI_NOT_STARTED; - goto Exit; - case EfiSimpleNetworkStarted: - Status = EFI_DEVICE_ERROR; - goto Exit; - default: - break; - } - - // - // update link status - // - if (Dev->Snm.MediaPresentSupported) { - UINT16 LinkStatus; - - Status = VIRTIO_CFG_READ (Dev, LinkStatus, &LinkStatus); - if (EFI_ERROR (Status)) { - goto Exit; - } - Dev->Snm.MediaPresent = - (BOOLEAN) ((LinkStatus & VIRTIO_NET_S_LINK_UP) != 0); - } - - // - // virtio-0.9.5, 2.4.2 Receiving Used Buffers From the Device - // - MemoryFence (); - RxCurUsed = *Dev->RxRing.Used.Idx; - TxCurUsed = *Dev->TxRing.Used.Idx; - MemoryFence (); - - if (InterruptStatus != NULL) { - // - // report the receive interrupt if there is data available for reception, - // report the transmit interrupt if we have transmitted at least one buffer - // - *InterruptStatus = 0; - if (Dev->RxLastUsed != RxCurUsed) { - *InterruptStatus |= EFI_SIMPLE_NETWORK_RECEIVE_INTERRUPT; - } - if (Dev->TxLastUsed != TxCurUsed) { - ASSERT (Dev->TxCurPending > 0); - *InterruptStatus |= EFI_SIMPLE_NETWORK_TRANSMIT_INTERRUPT; - } - } - - if (TxBuf != NULL) { - if (Dev->TxLastUsed == TxCurUsed) { - *TxBuf = NULL; - } - else { - UINT16 UsedElemIdx; - UINT32 DescIdx; - - // - // fetch the first descriptor among those that the hypervisor reports - // completed - // - ASSERT (Dev->TxCurPending > 0); - ASSERT (Dev->TxCurPending <= Dev->TxMaxPending); - - UsedElemIdx = Dev->TxLastUsed++ % Dev->TxRing.QueueSize; - DescIdx = Dev->TxRing.Used.UsedElem[UsedElemIdx].Id; - ASSERT (DescIdx < (UINT32) (2 * Dev->TxMaxPending - 1)); - - // - // report buffer address to caller that has been enqueued by caller - // - *TxBuf = (VOID *)(UINTN) Dev->TxRing.Desc[DescIdx + 1].Addr; - - // - // now this descriptor can be used again to enqueue a transmit buffer - // - Dev->TxFreeStack[--Dev->TxCurPending] = (UINT16) DescIdx; - } - } - - Status = EFI_SUCCESS; - -Exit: - gBS->RestoreTPL (OldTpl); - return Status; -} diff --git a/OvmfPkg/VirtioNetDxe/SnpInitialize.c b/OvmfPkg/VirtioNetDxe/SnpInitialize.c deleted file mode 100644 index 430670a980..0000000000 --- a/OvmfPkg/VirtioNetDxe/SnpInitialize.c +++ /dev/null @@ -1,526 +0,0 @@ -/** @file - - Implementation of the SNP.Initialize() function and its private helpers if - any. - - Copyright (C) 2013, Red Hat, Inc. - Copyright (c) 2006 - 2010, Intel Corporation. All rights reserved.
- - This program and the accompanying materials are licensed and made available - under the terms and conditions of the BSD License which accompanies this - distribution. The full text of the license may be found at - http://opensource.org/licenses/bsd-license.php - - THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, WITHOUT - WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. - -**/ - -#include -#include -#include - -#include "VirtioNet.h" - -/** - Initialize a virtio ring for a specific transfer direction of the virtio-net - device. - - This function may only be called by VirtioNetInitialize(). - - @param[in,out] Dev The VNET_DEV driver instance about to enter the - EfiSimpleNetworkInitialized state. - @param[in] Selector Identifies the transfer direction (virtio queue) of - the network device. - @param[out] Ring The virtio-ring inside the VNET_DEV structure, - corresponding to Selector. - - @retval EFI_UNSUPPORTED The queue size reported by the virtio-net device is - too small. - @return Status codes from VIRTIO_CFG_WRITE(), - VIRTIO_CFG_READ() and VirtioRingInit(). - @retval EFI_SUCCESS Ring initialized. -*/ - -STATIC -EFI_STATUS -EFIAPI -VirtioNetInitRing ( - IN OUT VNET_DEV *Dev, - IN UINT16 Selector, - OUT VRING *Ring - ) -{ - EFI_STATUS Status; - UINT16 QueueSize; - - // - // step 4b -- allocate selected queue - // - Status = Dev->VirtIo->SetQueueSel (Dev->VirtIo, Selector); - if (EFI_ERROR (Status)) { - return Status; - } - Status = Dev->VirtIo->GetQueueNumMax (Dev->VirtIo, &QueueSize); - if (EFI_ERROR (Status)) { - return Status; - } - - // - // For each packet (RX and TX alike), we need two descriptors: - // one for the virtio-net request header, and another one for the data - // - if (QueueSize < 2) { - return EFI_UNSUPPORTED; - } - Status = VirtioRingInit (QueueSize, Ring); - if (EFI_ERROR (Status)) { - return Status; - } - - // - // Additional steps for MMIO: align the queue appropriately, and set the - // size. If anything fails from here on, we must release the ring resources. - // - Status = Dev->VirtIo->SetQueueNum (Dev->VirtIo, QueueSize); - if (EFI_ERROR (Status)) { - goto ReleaseQueue; - } - - Status = Dev->VirtIo->SetQueueAlign (Dev->VirtIo, EFI_PAGE_SIZE); - if (EFI_ERROR (Status)) { - goto ReleaseQueue; - } - - // - // step 4c -- report GPFN (guest-physical frame number) of queue - // - Status = Dev->VirtIo->SetQueueAddress (Dev->VirtIo, Ring); - if (EFI_ERROR (Status)) { - goto ReleaseQueue; - } - - return EFI_SUCCESS; - -ReleaseQueue: - VirtioRingUninit (Ring); - - return Status; -} - - -/** - Set up static scaffolding for the VirtioNetTransmit() and - VirtioNetGetStatus() SNP methods. - - This function may only be called by VirtioNetInitialize(). - - The structures laid out and resources configured include: - - fully populate the TX queue with a static pattern of virtio descriptor - chains, - - tracking of heads of free descriptor chains from the above, - - one common virtio-net request header (never modified by the host) for all - pending TX packets, - - select polling over TX interrupt. - - @param[in,out] Dev The VNET_DEV driver instance about to enter the - EfiSimpleNetworkInitialized state. - - @retval EFI_OUT_OF_RESOURCES Failed to allocate the stack to track the heads - of free descriptor chains. - @retval EFI_SUCCESS TX setup successful. -*/ - -STATIC -EFI_STATUS -EFIAPI -VirtioNetInitTx ( - IN OUT VNET_DEV *Dev - ) -{ - UINTN TxSharedReqSize; - UINTN PktIdx; - - Dev->TxMaxPending = (UINT16) MIN (Dev->TxRing.QueueSize / 2, - VNET_MAX_PENDING); - Dev->TxCurPending = 0; - Dev->TxFreeStack = AllocatePool (Dev->TxMaxPending * - sizeof *Dev->TxFreeStack); - if (Dev->TxFreeStack == NULL) { - return EFI_OUT_OF_RESOURCES; - } - - // - // In VirtIo 1.0, the NumBuffers field is mandatory. In 0.9.5, it depends on - // VIRTIO_NET_F_MRG_RXBUF, which we never negotiate. - // - TxSharedReqSize = (Dev->VirtIo->Revision < VIRTIO_SPEC_REVISION (1, 0, 0)) ? - sizeof Dev->TxSharedReq.V0_9_5 : - sizeof Dev->TxSharedReq; - - for (PktIdx = 0; PktIdx < Dev->TxMaxPending; ++PktIdx) { - UINT16 DescIdx; - - DescIdx = (UINT16) (2 * PktIdx); - Dev->TxFreeStack[PktIdx] = DescIdx; - - // - // For each possibly pending packet, lay out the descriptor for the common - // (unmodified by the host) virtio-net request header. - // - Dev->TxRing.Desc[DescIdx].Addr = (UINTN) &Dev->TxSharedReq; - Dev->TxRing.Desc[DescIdx].Len = (UINT32) TxSharedReqSize; - Dev->TxRing.Desc[DescIdx].Flags = VRING_DESC_F_NEXT; - Dev->TxRing.Desc[DescIdx].Next = (UINT16) (DescIdx + 1); - - // - // The second descriptor of each pending TX packet is updated on the fly, - // but it always terminates the descriptor chain of the packet. - // - Dev->TxRing.Desc[DescIdx + 1].Flags = 0; - } - - // - // virtio-0.9.5, Appendix C, Packet Transmission - // - Dev->TxSharedReq.V0_9_5.Flags = 0; - Dev->TxSharedReq.V0_9_5.GsoType = VIRTIO_NET_HDR_GSO_NONE; - - // - // For VirtIo 1.0 only -- the field exists, but it is unused - // - Dev->TxSharedReq.NumBuffers = 0; - - // - // virtio-0.9.5, 2.4.2 Receiving Used Buffers From the Device - // - MemoryFence (); - Dev->TxLastUsed = *Dev->TxRing.Used.Idx; - ASSERT (Dev->TxLastUsed == 0); - - // - // want no interrupt when a transmit completes - // - *Dev->TxRing.Avail.Flags = (UINT16) VRING_AVAIL_F_NO_INTERRUPT; - - return EFI_SUCCESS; -} - - -/** - Set up static scaffolding for the VirtioNetReceive() SNP method and enable - live device operation. - - This function may only be called as VirtioNetInitialize()'s final step. - - The structures laid out and resources configured include: - - destination area for the host to write virtio-net request headers and - packet data into, - - select polling over RX interrupt, - - fully populate the RX queue with a static pattern of virtio descriptor - chains. - - @param[in,out] Dev The VNET_DEV driver instance about to enter the - EfiSimpleNetworkInitialized state. - - @retval EFI_OUT_OF_RESOURCES Failed to allocate RX destination area. - @return Status codes from VIRTIO_CFG_WRITE(). - @retval EFI_SUCCESS RX setup successful. The device is live and may - already be writing to the receive area. -*/ - -STATIC -EFI_STATUS -EFIAPI -VirtioNetInitRx ( - IN OUT VNET_DEV *Dev - ) -{ - EFI_STATUS Status; - UINTN VirtioNetReqSize; - UINTN RxBufSize; - UINT16 RxAlwaysPending; - UINTN PktIdx; - UINT16 DescIdx; - UINT8 *RxPtr; - - // - // In VirtIo 1.0, the NumBuffers field is mandatory. In 0.9.5, it depends on - // VIRTIO_NET_F_MRG_RXBUF, which we never negotiate. - // - VirtioNetReqSize = (Dev->VirtIo->Revision < VIRTIO_SPEC_REVISION (1, 0, 0)) ? - sizeof (VIRTIO_NET_REQ) : - sizeof (VIRTIO_1_0_NET_REQ); - - // - // For each incoming packet we must supply two descriptors: - // - the recipient for the virtio-net request header, plus - // - the recipient for the network data (which consists of Ethernet header - // and Ethernet payload). - // - RxBufSize = VirtioNetReqSize + - (Dev->Snm.MediaHeaderSize + Dev->Snm.MaxPacketSize); - - // - // Limit the number of pending RX packets if the queue is big. The division - // by two is due to the above "two descriptors per packet" trait. - // - RxAlwaysPending = (UINT16) MIN (Dev->RxRing.QueueSize / 2, VNET_MAX_PENDING); - - Dev->RxBuf = AllocatePool (RxAlwaysPending * RxBufSize); - if (Dev->RxBuf == NULL) { - return EFI_OUT_OF_RESOURCES; - } - - // - // virtio-0.9.5, 2.4.2 Receiving Used Buffers From the Device - // - MemoryFence (); - Dev->RxLastUsed = *Dev->RxRing.Used.Idx; - ASSERT (Dev->RxLastUsed == 0); - - // - // virtio-0.9.5, 2.4.2 Receiving Used Buffers From the Device: - // the host should not send interrupts, we'll poll in VirtioNetReceive() - // and VirtioNetIsPacketAvailable(). - // - *Dev->RxRing.Avail.Flags = (UINT16) VRING_AVAIL_F_NO_INTERRUPT; - - // - // now set up a separate, two-part descriptor chain for each RX packet, and - // link each chain into (from) the available ring as well - // - DescIdx = 0; - RxPtr = Dev->RxBuf; - for (PktIdx = 0; PktIdx < RxAlwaysPending; ++PktIdx) { - // - // virtio-0.9.5, 2.4.1.2 Updating the Available Ring - // invisible to the host until we update the Index Field - // - Dev->RxRing.Avail.Ring[PktIdx] = DescIdx; - - // - // virtio-0.9.5, 2.4.1.1 Placing Buffers into the Descriptor Table - // - Dev->RxRing.Desc[DescIdx].Addr = (UINTN) RxPtr; - Dev->RxRing.Desc[DescIdx].Len = (UINT32) VirtioNetReqSize; - Dev->RxRing.Desc[DescIdx].Flags = VRING_DESC_F_WRITE | VRING_DESC_F_NEXT; - Dev->RxRing.Desc[DescIdx].Next = (UINT16) (DescIdx + 1); - RxPtr += Dev->RxRing.Desc[DescIdx++].Len; - - Dev->RxRing.Desc[DescIdx].Addr = (UINTN) RxPtr; - Dev->RxRing.Desc[DescIdx].Len = (UINT32) (RxBufSize - VirtioNetReqSize); - Dev->RxRing.Desc[DescIdx].Flags = VRING_DESC_F_WRITE; - RxPtr += Dev->RxRing.Desc[DescIdx++].Len; - } - - // - // virtio-0.9.5, 2.4.1.3 Updating the Index Field - // - MemoryFence (); - *Dev->RxRing.Avail.Idx = RxAlwaysPending; - - // - // At this point reception may already be running. In order to make it sure, - // kick the hypervisor. If we fail to kick it, we must first abort reception - // before tearing down anything, because reception may have been already - // running even without the kick. - // - // virtio-0.9.5, 2.4.1.4 Notifying the Device - // - MemoryFence (); - Status = Dev->VirtIo->SetQueueNotify (Dev->VirtIo, VIRTIO_NET_Q_RX); - if (EFI_ERROR (Status)) { - Dev->VirtIo->SetDeviceStatus (Dev->VirtIo, 0); - FreePool (Dev->RxBuf); - } - - return Status; -} - - -/** - Resets a network adapter and allocates the transmit and receive buffers - required by the network interface; optionally, also requests allocation of - additional transmit and receive buffers. - - @param This The protocol instance pointer. - @param ExtraRxBufferSize The size, in bytes, of the extra receive buffer - space that the driver should allocate for the - network interface. Some network interfaces will not - be able to use the extra buffer, and the caller - will not know if it is actually being used. - @param ExtraTxBufferSize The size, in bytes, of the extra transmit buffer - space that the driver should allocate for the - network interface. Some network interfaces will not - be able to use the extra buffer, and the caller - will not know if it is actually being used. - - @retval EFI_SUCCESS The network interface was initialized. - @retval EFI_NOT_STARTED The network interface has not been started. - @retval EFI_OUT_OF_RESOURCES There was not enough memory for the transmit - and receive buffers. - @retval EFI_INVALID_PARAMETER One or more of the parameters has an - unsupported value. - @retval EFI_DEVICE_ERROR The command could not be sent to the network - interface. - @retval EFI_UNSUPPORTED This function is not supported by the network - interface. - -**/ - -EFI_STATUS -EFIAPI -VirtioNetInitialize ( - IN EFI_SIMPLE_NETWORK_PROTOCOL *This, - IN UINTN ExtraRxBufferSize OPTIONAL, - IN UINTN ExtraTxBufferSize OPTIONAL - ) -{ - VNET_DEV *Dev; - EFI_TPL OldTpl; - EFI_STATUS Status; - UINT8 NextDevStat; - UINT64 Features; - - if (This == NULL) { - return EFI_INVALID_PARAMETER; - } - if (ExtraRxBufferSize > 0 || ExtraTxBufferSize > 0) { - return EFI_UNSUPPORTED; - } - - Dev = VIRTIO_NET_FROM_SNP (This); - OldTpl = gBS->RaiseTPL (TPL_CALLBACK); - if (Dev->Snm.State != EfiSimpleNetworkStarted) { - Status = EFI_NOT_STARTED; - goto InitFailed; - } - - // - // In the EfiSimpleNetworkStarted state the virtio-net device has status - // value 0 (= reset) -- see the state diagram, the full call chain to - // the end of VirtioNetGetFeatures() (considering we're here now), - // the DeviceFailed label below, and VirtioNetShutdown(). - // - // Accordingly, the below is a subsequence of the steps found in the - // virtio-0.9.5 spec, 2.2.1 Device Initialization Sequence. - // - NextDevStat = VSTAT_ACK; // step 2 -- acknowledge device presence - Status = Dev->VirtIo->SetDeviceStatus (Dev->VirtIo, NextDevStat); - if (EFI_ERROR (Status)) { - goto InitFailed; - } - - NextDevStat |= VSTAT_DRIVER; // step 3 -- we know how to drive it - Status = Dev->VirtIo->SetDeviceStatus (Dev->VirtIo, NextDevStat); - if (EFI_ERROR (Status)) { - goto DeviceFailed; - } - - // - // Set Page Size - MMIO VirtIo Specific - // - Status = Dev->VirtIo->SetPageSize (Dev->VirtIo, EFI_PAGE_SIZE); - if (EFI_ERROR (Status)) { - goto DeviceFailed; - } - - // - // step 4a -- retrieve features. Note that we're past validating required - // features in VirtioNetGetFeatures(). - // - Status = Dev->VirtIo->GetDeviceFeatures (Dev->VirtIo, &Features); - if (EFI_ERROR (Status)) { - goto DeviceFailed; - } - - ASSERT (Features & VIRTIO_NET_F_MAC); - ASSERT (Dev->Snm.MediaPresentSupported == - !!(Features & VIRTIO_NET_F_STATUS)); - - Features &= VIRTIO_NET_F_MAC | VIRTIO_NET_F_STATUS | VIRTIO_F_VERSION_1; - - // - // In virtio-1.0, feature negotiation is expected to complete before queue - // discovery, and the device can also reject the selected set of features. - // - if (Dev->VirtIo->Revision >= VIRTIO_SPEC_REVISION (1, 0, 0)) { - Status = Virtio10WriteFeatures (Dev->VirtIo, Features, &NextDevStat); - if (EFI_ERROR (Status)) { - goto DeviceFailed; - } - } - - // - // step 4b, 4c -- allocate and report virtqueues - // - Status = VirtioNetInitRing (Dev, VIRTIO_NET_Q_RX, &Dev->RxRing); - if (EFI_ERROR (Status)) { - goto DeviceFailed; - } - - Status = VirtioNetInitRing (Dev, VIRTIO_NET_Q_TX, &Dev->TxRing); - if (EFI_ERROR (Status)) { - goto ReleaseRxRing; - } - - // - // step 5 -- keep only the features we want - // - if (Dev->VirtIo->Revision < VIRTIO_SPEC_REVISION (1, 0, 0)) { - Features &= ~(UINT64)VIRTIO_F_VERSION_1; - Status = Dev->VirtIo->SetGuestFeatures (Dev->VirtIo, Features); - if (EFI_ERROR (Status)) { - goto ReleaseTxRing; - } - } - - // - // step 6 -- virtio-net initialization complete - // - NextDevStat |= VSTAT_DRIVER_OK; - Status = Dev->VirtIo->SetDeviceStatus (Dev->VirtIo, NextDevStat); - if (EFI_ERROR (Status)) { - goto ReleaseTxRing; - } - - Status = VirtioNetInitTx (Dev); - if (EFI_ERROR (Status)) { - goto AbortDevice; - } - - // - // start receiving - // - Status = VirtioNetInitRx (Dev); - if (EFI_ERROR (Status)) { - goto ReleaseTxAux; - } - - Dev->Snm.State = EfiSimpleNetworkInitialized; - gBS->RestoreTPL (OldTpl); - return EFI_SUCCESS; - -ReleaseTxAux: - VirtioNetShutdownTx (Dev); - -AbortDevice: - Dev->VirtIo->SetDeviceStatus (Dev->VirtIo, 0); - -ReleaseTxRing: - VirtioRingUninit (&Dev->TxRing); - -ReleaseRxRing: - VirtioRingUninit (&Dev->RxRing); - -DeviceFailed: - // - // restore device status invariant for the EfiSimpleNetworkStarted state - // - Dev->VirtIo->SetDeviceStatus (Dev->VirtIo, 0); - -InitFailed: - gBS->RestoreTPL (OldTpl); - return Status; -} diff --git a/OvmfPkg/VirtioNetDxe/SnpMcastIpToMac.c b/OvmfPkg/VirtioNetDxe/SnpMcastIpToMac.c deleted file mode 100644 index 686fd0db4e..0000000000 --- a/OvmfPkg/VirtioNetDxe/SnpMcastIpToMac.c +++ /dev/null @@ -1,108 +0,0 @@ -/** @file - - Implementation of the SNP.McastIpToMac() function and its private helpers if - any. - - Copyright (C) 2013, Red Hat, Inc. - Copyright (c) 2006 - 2010, Intel Corporation. All rights reserved.
- - This program and the accompanying materials are licensed and made available - under the terms and conditions of the BSD License which accompanies this - distribution. The full text of the license may be found at - http://opensource.org/licenses/bsd-license.php - - THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, WITHOUT - WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. - -**/ - -#include - -#include "VirtioNet.h" - -/** - Converts a multicast IP address to a multicast HW MAC address. - - @param This The protocol instance pointer. - @param IPv6 Set to TRUE if the multicast IP address is IPv6 [RFC 2460]. Set - to FALSE if the multicast IP address is IPv4 [RFC 791]. - @param IP The multicast IP address that is to be converted to a multicast - HW MAC address. - @param MAC The multicast HW MAC address that is to be generated from IP. - - @retval EFI_SUCCESS The multicast IP address was mapped to the - multicast HW MAC address. - @retval EFI_NOT_STARTED The network interface has not been started. - @retval EFI_BUFFER_TOO_SMALL The Statistics buffer was too small. The - current buffer size needed to hold the - statistics is returned in StatisticsSize. - @retval EFI_INVALID_PARAMETER One or more of the parameters has an - unsupported value. - @retval EFI_DEVICE_ERROR The command could not be sent to the network - interface. - @retval EFI_UNSUPPORTED This function is not supported by the network - interface. - -**/ - -EFI_STATUS -EFIAPI -VirtioNetMcastIpToMac ( - IN EFI_SIMPLE_NETWORK_PROTOCOL *This, - IN BOOLEAN IPv6, - IN EFI_IP_ADDRESS *Ip, - OUT EFI_MAC_ADDRESS *Mac - ) -{ - VNET_DEV *Dev; - EFI_TPL OldTpl; - EFI_STATUS Status; - - // - // http://en.wikipedia.org/wiki/Multicast_address - // - if (This == NULL || Ip == NULL || Mac == NULL || - ( IPv6 && (Ip->v6.Addr[0] ) != 0xFF) || // invalid IPv6 mcast addr - (!IPv6 && (Ip->v4.Addr[0] & 0xF0) != 0xE0) // invalid IPv4 mcast addr - ) { - return EFI_INVALID_PARAMETER; - } - - Dev = VIRTIO_NET_FROM_SNP (This); - OldTpl = gBS->RaiseTPL (TPL_CALLBACK); - switch (Dev->Snm.State) { - case EfiSimpleNetworkStopped: - Status = EFI_NOT_STARTED; - goto Exit; - case EfiSimpleNetworkStarted: - Status = EFI_DEVICE_ERROR; - goto Exit; - default: - break; - } - - // - // http://en.wikipedia.org/wiki/IP_multicast#Layer_2_delivery - // - if (IPv6) { - Mac->Addr[0] = 0x33; - Mac->Addr[1] = 0x33; - Mac->Addr[2] = Ip->v6.Addr[12]; - Mac->Addr[3] = Ip->v6.Addr[13]; - Mac->Addr[4] = Ip->v6.Addr[14]; - Mac->Addr[5] = Ip->v6.Addr[15]; - } - else { - Mac->Addr[0] = 0x01; - Mac->Addr[1] = 0x00; - Mac->Addr[2] = 0x5E; - Mac->Addr[3] = Ip->v4.Addr[1] & 0x7F; - Mac->Addr[4] = Ip->v4.Addr[2]; - Mac->Addr[5] = Ip->v4.Addr[3]; - } - Status = EFI_SUCCESS; - -Exit: - gBS->RestoreTPL (OldTpl); - return Status; -} diff --git a/OvmfPkg/VirtioNetDxe/SnpReceive.c b/OvmfPkg/VirtioNetDxe/SnpReceive.c deleted file mode 100644 index 99abd7ebe4..0000000000 --- a/OvmfPkg/VirtioNetDxe/SnpReceive.c +++ /dev/null @@ -1,188 +0,0 @@ -/** @file - - Implementation of the SNP.Receive() function and its private helpers if any. - - Copyright (C) 2013, Red Hat, Inc. - Copyright (c) 2006 - 2013, Intel Corporation. All rights reserved.
- - This program and the accompanying materials are licensed and made available - under the terms and conditions of the BSD License which accompanies this - distribution. The full text of the license may be found at - http://opensource.org/licenses/bsd-license.php - - THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, WITHOUT - WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. - -**/ - -#include -#include -#include - -#include "VirtioNet.h" - -/** - Receives a packet from a network interface. - - @param This The protocol instance pointer. - @param HeaderSize The size, in bytes, of the media header received on the - network interface. If this parameter is NULL, then the - media header size will not be returned. - @param BufferSize On entry, the size, in bytes, of Buffer. On exit, the - size, in bytes, of the packet that was received on the - network interface. - @param Buffer A pointer to the data buffer to receive both the media - header and the data. - @param SrcAddr The source HW MAC address. If this parameter is NULL, the - HW MAC source address will not be extracted from the media - header. - @param DestAddr The destination HW MAC address. If this parameter is NULL, - the HW MAC destination address will not be extracted from - the media header. - @param Protocol The media header type. If this parameter is NULL, then the - protocol will not be extracted from the media header. See - RFC 1700 section "Ether Types" for examples. - - @retval EFI_SUCCESS The received data was stored in Buffer, and - BufferSize has been updated to the number of - bytes received. - @retval EFI_NOT_STARTED The network interface has not been started. - @retval EFI_NOT_READY The network interface is too busy to accept - this transmit request. - @retval EFI_BUFFER_TOO_SMALL The BufferSize parameter is too small. - @retval EFI_INVALID_PARAMETER One or more of the parameters has an - unsupported value. - @retval EFI_DEVICE_ERROR The command could not be sent to the network - interface. - @retval EFI_UNSUPPORTED This function is not supported by the network - interface. - -**/ - -EFI_STATUS -EFIAPI -VirtioNetReceive ( - IN EFI_SIMPLE_NETWORK_PROTOCOL *This, - OUT UINTN *HeaderSize OPTIONAL, - IN OUT UINTN *BufferSize, - OUT VOID *Buffer, - OUT EFI_MAC_ADDRESS *SrcAddr OPTIONAL, - OUT EFI_MAC_ADDRESS *DestAddr OPTIONAL, - OUT UINT16 *Protocol OPTIONAL - ) -{ - VNET_DEV *Dev; - EFI_TPL OldTpl; - EFI_STATUS Status; - UINT16 RxCurUsed; - UINT16 UsedElemIdx; - UINT32 DescIdx; - UINT32 RxLen; - UINTN OrigBufferSize; - UINT8 *RxPtr; - UINT16 AvailIdx; - EFI_STATUS NotifyStatus; - - if (This == NULL || BufferSize == NULL || Buffer == NULL) { - return EFI_INVALID_PARAMETER; - } - - Dev = VIRTIO_NET_FROM_SNP (This); - OldTpl = gBS->RaiseTPL (TPL_CALLBACK); - switch (Dev->Snm.State) { - case EfiSimpleNetworkStopped: - Status = EFI_NOT_STARTED; - goto Exit; - case EfiSimpleNetworkStarted: - Status = EFI_DEVICE_ERROR; - goto Exit; - default: - break; - } - - // - // virtio-0.9.5, 2.4.2 Receiving Used Buffers From the Device - // - MemoryFence (); - RxCurUsed = *Dev->RxRing.Used.Idx; - MemoryFence (); - - if (Dev->RxLastUsed == RxCurUsed) { - Status = EFI_NOT_READY; - goto Exit; - } - - UsedElemIdx = Dev->RxLastUsed % Dev->RxRing.QueueSize; - DescIdx = Dev->RxRing.Used.UsedElem[UsedElemIdx].Id; - RxLen = Dev->RxRing.Used.UsedElem[UsedElemIdx].Len; - - // - // the virtio-net request header must be complete; we skip it - // - ASSERT (RxLen >= Dev->RxRing.Desc[DescIdx].Len); - RxLen -= Dev->RxRing.Desc[DescIdx].Len; - // - // the host must not have filled in more data than requested - // - ASSERT (RxLen <= Dev->RxRing.Desc[DescIdx + 1].Len); - - OrigBufferSize = *BufferSize; - *BufferSize = RxLen; - - if (OrigBufferSize < RxLen) { - Status = EFI_BUFFER_TOO_SMALL; - goto Exit; // keep the packet - } - - if (RxLen < Dev->Snm.MediaHeaderSize) { - Status = EFI_DEVICE_ERROR; - goto RecycleDesc; // drop useless short packet - } - - if (HeaderSize != NULL) { - *HeaderSize = Dev->Snm.MediaHeaderSize; - } - - RxPtr = (UINT8 *)(UINTN) Dev->RxRing.Desc[DescIdx + 1].Addr; - CopyMem (Buffer, RxPtr, RxLen); - - if (DestAddr != NULL) { - CopyMem (DestAddr, RxPtr, SIZE_OF_VNET (Mac)); - } - RxPtr += SIZE_OF_VNET (Mac); - - if (SrcAddr != NULL) { - CopyMem (SrcAddr, RxPtr, SIZE_OF_VNET (Mac)); - } - RxPtr += SIZE_OF_VNET (Mac); - - if (Protocol != NULL) { - *Protocol = (UINT16) ((RxPtr[0] << 8) | RxPtr[1]); - } - RxPtr += sizeof (UINT16); - - Status = EFI_SUCCESS; - -RecycleDesc: - ++Dev->RxLastUsed; - - // - // virtio-0.9.5, 2.4.1 Supplying Buffers to The Device - // - AvailIdx = *Dev->RxRing.Avail.Idx; - Dev->RxRing.Avail.Ring[AvailIdx++ % Dev->RxRing.QueueSize] = - (UINT16) DescIdx; - - MemoryFence (); - *Dev->RxRing.Avail.Idx = AvailIdx; - - MemoryFence (); - NotifyStatus = Dev->VirtIo->SetQueueNotify (Dev->VirtIo, VIRTIO_NET_Q_RX); - if (!EFI_ERROR (Status)) { // earlier error takes precedence - Status = NotifyStatus; - } - -Exit: - gBS->RestoreTPL (OldTpl); - return Status; -} diff --git a/OvmfPkg/VirtioNetDxe/SnpReceiveFilters.c b/OvmfPkg/VirtioNetDxe/SnpReceiveFilters.c deleted file mode 100644 index 43e554fba2..0000000000 --- a/OvmfPkg/VirtioNetDxe/SnpReceiveFilters.c +++ /dev/null @@ -1,105 +0,0 @@ -/** @file - - Implementation of the SNP.ReceiveFilters() function and its private helpers - if any. - - Copyright (C) 2013, Red Hat, Inc. - Copyright (c) 2006 - 2010, Intel Corporation. All rights reserved.
- - This program and the accompanying materials are licensed and made available - under the terms and conditions of the BSD License which accompanies this - distribution. The full text of the license may be found at - http://opensource.org/licenses/bsd-license.php - - THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, WITHOUT - WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. - -**/ - -#include - -#include "VirtioNet.h" - -/** - Manages the multicast receive filters of a network interface. - - @param This The protocol instance pointer. - @param Enable A bit mask of receive filters to enable on the - network interface. - @param Disable A bit mask of receive filters to disable on the - network interface. - @param ResetMCastFilter Set to TRUE to reset the contents of the multicast - receive filters on the network interface to their - default values. - @param McastFilterCnt Number of multicast HW MAC addresses in the new - MCastFilter list. This value must be less than or - equal to the MCastFilterCnt field of - EFI_SIMPLE_NETWORK_MODE. This field is optional if - ResetMCastFilter is TRUE. - @param MCastFilter A pointer to a list of new multicast receive filter - HW MAC addresses. This list will replace any - existing multicast HW MAC address list. This field - is optional if ResetMCastFilter is TRUE. - - @retval EFI_SUCCESS The multicast receive filter list was updated. - @retval EFI_NOT_STARTED The network interface has not been started. - @retval EFI_INVALID_PARAMETER One or more of the parameters has an - unsupported value. - @retval EFI_DEVICE_ERROR The command could not be sent to the network - interface. - @retval EFI_UNSUPPORTED This function is not supported by the network - interface. - -**/ - -EFI_STATUS -EFIAPI -VirtioNetReceiveFilters ( - IN EFI_SIMPLE_NETWORK_PROTOCOL *This, - IN UINT32 Enable, - IN UINT32 Disable, - IN BOOLEAN ResetMCastFilter, - IN UINTN MCastFilterCnt OPTIONAL, - IN EFI_MAC_ADDRESS *MCastFilter OPTIONAL - ) -{ - VNET_DEV *Dev; - EFI_TPL OldTpl; - EFI_STATUS Status; - - if (This == NULL) { - return EFI_INVALID_PARAMETER; - } - - Dev = VIRTIO_NET_FROM_SNP (This); - OldTpl = gBS->RaiseTPL (TPL_CALLBACK); - switch (Dev->Snm.State) { - case EfiSimpleNetworkStopped: - Status = EFI_NOT_STARTED; - goto Exit; - case EfiSimpleNetworkStarted: - Status = EFI_DEVICE_ERROR; - goto Exit; - default: - break; - } - - // - // MNP apparently fails to initialize on top of us if we simply return - // EFI_UNSUPPORTED in this function. - // - // Hence we openly refuse multicast functionality, and fake the rest by - // selecting a no stricter filter setting than whatever is requested. The - // UEFI-2.3.1+errC spec allows this. In practice we don't change our current - // (default) filter. Additionally, receiving software is responsible for - // discarding any packets getting through the filter. - // - Status = ( - ((Enable | Disable) & ~Dev->Snm.ReceiveFilterMask) != 0 || - (!ResetMCastFilter && MCastFilterCnt > Dev->Snm.MaxMCastFilterCount) - ) ? EFI_INVALID_PARAMETER : EFI_SUCCESS; - -Exit: - gBS->RestoreTPL (OldTpl); - return Status; -} diff --git a/OvmfPkg/VirtioNetDxe/SnpSharedHelpers.c b/OvmfPkg/VirtioNetDxe/SnpSharedHelpers.c deleted file mode 100644 index 9fedb72fdb..0000000000 --- a/OvmfPkg/VirtioNetDxe/SnpSharedHelpers.c +++ /dev/null @@ -1,53 +0,0 @@ -/** @file - - Helper functions used by at least two Simple Network Protocol methods. - - Copyright (C) 2013, Red Hat, Inc. - - This program and the accompanying materials are licensed and made available - under the terms and conditions of the BSD License which accompanies this - distribution. The full text of the license may be found at - http://opensource.org/licenses/bsd-license.php - - THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, WITHOUT - WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. - -**/ - -#include - -#include "VirtioNet.h" - -/** - Release RX and TX resources on the boundary of the - EfiSimpleNetworkInitialized state. - - These functions contribute to rolling back a partial, failed initialization - of the virtio-net SNP driver instance, or to shutting down a fully - initialized, running instance. - - They are only callable by the VirtioNetInitialize() and the - VirtioNetShutdown() SNP methods. See the state diagram in "VirtioNet.h". - - @param[in,out] Dev The VNET_DEV driver instance being shut down, or whose - partial, failed initialization is being rolled back. -*/ - -VOID -EFIAPI -VirtioNetShutdownRx ( - IN OUT VNET_DEV *Dev - ) -{ - FreePool (Dev->RxBuf); -} - - -VOID -EFIAPI -VirtioNetShutdownTx ( - IN OUT VNET_DEV *Dev - ) -{ - FreePool (Dev->TxFreeStack); -} diff --git a/OvmfPkg/VirtioNetDxe/SnpShutdown.c b/OvmfPkg/VirtioNetDxe/SnpShutdown.c deleted file mode 100644 index 01409c0ce7..0000000000 --- a/OvmfPkg/VirtioNetDxe/SnpShutdown.c +++ /dev/null @@ -1,78 +0,0 @@ -/** @file - - Implementation of the SNP.Shutdown() function and its private helpers if any. - - Copyright (C) 2013, Red Hat, Inc. - Copyright (c) 2006 - 2010, Intel Corporation. All rights reserved.
- - This program and the accompanying materials are licensed and made available - under the terms and conditions of the BSD License which accompanies this - distribution. The full text of the license may be found at - http://opensource.org/licenses/bsd-license.php - - THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, WITHOUT - WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. - -**/ - -#include - -#include "VirtioNet.h" - -/** - Resets a network adapter and leaves it in a state that is safe for another - driver to initialize. - - @param This Protocol instance pointer. - - @retval EFI_SUCCESS The network interface was shutdown. - @retval EFI_NOT_STARTED The network interface has not been started. - @retval EFI_INVALID_PARAMETER One or more of the parameters has an - unsupported value. - @retval EFI_DEVICE_ERROR The command could not be sent to the network - interface. - @retval EFI_UNSUPPORTED This function is not supported by the network - interface. - -**/ - -EFI_STATUS -EFIAPI -VirtioNetShutdown ( - IN EFI_SIMPLE_NETWORK_PROTOCOL *This - ) -{ - VNET_DEV *Dev; - EFI_TPL OldTpl; - EFI_STATUS Status; - - if (This == NULL) { - return EFI_INVALID_PARAMETER; - } - - Dev = VIRTIO_NET_FROM_SNP (This); - OldTpl = gBS->RaiseTPL (TPL_CALLBACK); - switch (Dev->Snm.State) { - case EfiSimpleNetworkStopped: - Status = EFI_NOT_STARTED; - goto Exit; - case EfiSimpleNetworkStarted: - Status = EFI_DEVICE_ERROR; - goto Exit; - default: - break; - } - - Dev->VirtIo->SetDeviceStatus (Dev->VirtIo, 0); - VirtioNetShutdownRx (Dev); - VirtioNetShutdownTx (Dev); - VirtioRingUninit (&Dev->TxRing); - VirtioRingUninit (&Dev->RxRing); - - Dev->Snm.State = EfiSimpleNetworkStarted; - Status = EFI_SUCCESS; - -Exit: - gBS->RestoreTPL (OldTpl); - return Status; -} diff --git a/OvmfPkg/VirtioNetDxe/SnpStart.c b/OvmfPkg/VirtioNetDxe/SnpStart.c deleted file mode 100644 index 4ded4d6db4..0000000000 --- a/OvmfPkg/VirtioNetDxe/SnpStart.c +++ /dev/null @@ -1,64 +0,0 @@ -/** @file - - Implementation of the SNP.Start() function and its private helpers if any. - - Copyright (C) 2013, Red Hat, Inc. - Copyright (c) 2006 - 2010, Intel Corporation. All rights reserved.
- - This program and the accompanying materials are licensed and made available - under the terms and conditions of the BSD License which accompanies this - distribution. The full text of the license may be found at - http://opensource.org/licenses/bsd-license.php - - THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, WITHOUT - WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. - -**/ - -#include - -#include "VirtioNet.h" - -/** - Changes the state of a network interface from "stopped" to "started". - - @param This Protocol instance pointer. - - @retval EFI_SUCCESS The network interface was started. - @retval EFI_ALREADY_STARTED The network interface is already in the started - state. - @retval EFI_INVALID_PARAMETER One or more of the parameters has an - unsupported value. - @retval EFI_DEVICE_ERROR The command could not be sent to the network - interface. - @retval EFI_UNSUPPORTED This function is not supported by the network - interface. -**/ - -EFI_STATUS -EFIAPI -VirtioNetStart ( - IN EFI_SIMPLE_NETWORK_PROTOCOL *This - ) -{ - VNET_DEV *Dev; - EFI_TPL OldTpl; - EFI_STATUS Status; - - if (This == NULL) { - return EFI_INVALID_PARAMETER; - } - - Dev = VIRTIO_NET_FROM_SNP (This); - OldTpl = gBS->RaiseTPL (TPL_CALLBACK); - if (Dev->Snm.State != EfiSimpleNetworkStopped) { - Status = EFI_ALREADY_STARTED; - } - else { - Dev->Snm.State = EfiSimpleNetworkStarted; - Status = EFI_SUCCESS; - } - - gBS->RestoreTPL (OldTpl); - return Status; -} diff --git a/OvmfPkg/VirtioNetDxe/SnpStop.c b/OvmfPkg/VirtioNetDxe/SnpStop.c deleted file mode 100644 index 86c501930b..0000000000 --- a/OvmfPkg/VirtioNetDxe/SnpStop.c +++ /dev/null @@ -1,65 +0,0 @@ -/** @file - - Implementation of the SNP.Stop() function and its private helpers if any. - - Copyright (C) 2013, Red Hat, Inc. - Copyright (c) 2006 - 2010, Intel Corporation. All rights reserved.
- - This program and the accompanying materials are licensed and made available - under the terms and conditions of the BSD License which accompanies this - distribution. The full text of the license may be found at - http://opensource.org/licenses/bsd-license.php - - THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, WITHOUT - WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. - -**/ - -#include - -#include "VirtioNet.h" - -/** - Changes the state of a network interface from "started" to "stopped". - - @param This Protocol instance pointer. - - @retval EFI_SUCCESS The network interface was stopped. - @retval EFI_ALREADY_STARTED The network interface is already in the stopped - state. - @retval EFI_INVALID_PARAMETER One or more of the parameters has an - unsupported value. - @retval EFI_DEVICE_ERROR The command could not be sent to the network - interface. - @retval EFI_UNSUPPORTED This function is not supported by the network - interface. - -**/ - -EFI_STATUS -EFIAPI -VirtioNetStop ( - IN EFI_SIMPLE_NETWORK_PROTOCOL *This - ) -{ - VNET_DEV *Dev; - EFI_TPL OldTpl; - EFI_STATUS Status; - - if (This == NULL) { - return EFI_INVALID_PARAMETER; - } - - Dev = VIRTIO_NET_FROM_SNP (This); - OldTpl = gBS->RaiseTPL (TPL_CALLBACK); - if (Dev->Snm.State != EfiSimpleNetworkStarted) { - Status = EFI_NOT_STARTED; - } - else { - Dev->Snm.State = EfiSimpleNetworkStopped; - Status = EFI_SUCCESS; - } - - gBS->RestoreTPL (OldTpl); - return Status; -} diff --git a/OvmfPkg/VirtioNetDxe/SnpTransmit.c b/OvmfPkg/VirtioNetDxe/SnpTransmit.c deleted file mode 100644 index 7ca40d5d06..0000000000 --- a/OvmfPkg/VirtioNetDxe/SnpTransmit.c +++ /dev/null @@ -1,169 +0,0 @@ -/** @file - - Implementation of the SNP.Transmit() function and its private helpers if any. - - Copyright (C) 2013, Red Hat, Inc. - Copyright (c) 2006 - 2013, Intel Corporation. All rights reserved.
- - This program and the accompanying materials are licensed and made available - under the terms and conditions of the BSD License which accompanies this - distribution. The full text of the license may be found at - http://opensource.org/licenses/bsd-license.php - - THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, WITHOUT - WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. - -**/ - -#include -#include -#include - -#include "VirtioNet.h" - -/** - Places a packet in the transmit queue of a network interface. - - @param This The protocol instance pointer. - @param HeaderSize The size, in bytes, of the media header to be filled in by - the Transmit() function. If HeaderSize is non-zero, then - it must be equal to This->Mode->MediaHeaderSize and the - DestAddr and Protocol parameters must not be NULL. - @param BufferSize The size, in bytes, of the entire packet (media header and - data) to be transmitted through the network interface. - @param Buffer A pointer to the packet (media header followed by data) to - be transmitted. This parameter cannot be NULL. If - HeaderSize is zero, then the media header in Buffer must - already be filled in by the caller. If HeaderSize is - non-zero, then the media header will be filled in by the - Transmit() function. - @param SrcAddr The source HW MAC address. If HeaderSize is zero, then - this parameter is ignored. If HeaderSize is non-zero and - SrcAddr is NULL, then This->Mode->CurrentAddress is used - for the source HW MAC address. - @param DestAddr The destination HW MAC address. If HeaderSize is zero, - then this parameter is ignored. - @param Protocol The type of header to build. If HeaderSize is zero, then - this parameter is ignored. See RFC 1700, section "Ether - Types", for examples. - - @retval EFI_SUCCESS The packet was placed on the transmit queue. - @retval EFI_NOT_STARTED The network interface has not been started. - @retval EFI_NOT_READY The network interface is too busy to accept - this transmit request. - @retval EFI_BUFFER_TOO_SMALL The BufferSize parameter is too small. - @retval EFI_INVALID_PARAMETER One or more of the parameters has an - unsupported value. - @retval EFI_DEVICE_ERROR The command could not be sent to the network - interface. - @retval EFI_UNSUPPORTED This function is not supported by the network - interface. - -**/ - -EFI_STATUS -EFIAPI -VirtioNetTransmit ( - IN EFI_SIMPLE_NETWORK_PROTOCOL *This, - IN UINTN HeaderSize, - IN UINTN BufferSize, - IN /* +OUT! */ VOID *Buffer, - IN EFI_MAC_ADDRESS *SrcAddr OPTIONAL, - IN EFI_MAC_ADDRESS *DestAddr OPTIONAL, - IN UINT16 *Protocol OPTIONAL - ) -{ - VNET_DEV *Dev; - EFI_TPL OldTpl; - EFI_STATUS Status; - UINT16 DescIdx; - UINT16 AvailIdx; - - if (This == NULL || BufferSize == 0 || Buffer == NULL) { - return EFI_INVALID_PARAMETER; - } - - Dev = VIRTIO_NET_FROM_SNP (This); - OldTpl = gBS->RaiseTPL (TPL_CALLBACK); - switch (Dev->Snm.State) { - case EfiSimpleNetworkStopped: - Status = EFI_NOT_STARTED; - goto Exit; - case EfiSimpleNetworkStarted: - Status = EFI_DEVICE_ERROR; - goto Exit; - default: - break; - } - - if (BufferSize < Dev->Snm.MediaHeaderSize) { - Status = EFI_BUFFER_TOO_SMALL; - goto Exit; - } - if (BufferSize > Dev->Snm.MediaHeaderSize + Dev->Snm.MaxPacketSize) { - Status = EFI_INVALID_PARAMETER; - goto Exit; - } - - // - // check if we have room for transmission - // - ASSERT (Dev->TxCurPending <= Dev->TxMaxPending); - if (Dev->TxCurPending == Dev->TxMaxPending) { - Status = EFI_NOT_READY; - goto Exit; - } - - // - // the caller may want us to fill in the media header: - // dst MAC, src MAC, Ethertype - // - if (HeaderSize != 0) { - UINT8 *Ptr; - - if (HeaderSize != Dev->Snm.MediaHeaderSize || - DestAddr == NULL || Protocol == NULL) { - Status = EFI_INVALID_PARAMETER; - goto Exit; - } - Ptr = Buffer; - ASSERT (SIZE_OF_VNET (Mac) <= sizeof (EFI_MAC_ADDRESS)); - - CopyMem (Ptr, DestAddr, SIZE_OF_VNET (Mac)); - Ptr += SIZE_OF_VNET (Mac); - - CopyMem (Ptr, - (SrcAddr == NULL) ? &Dev->Snm.CurrentAddress : SrcAddr, - SIZE_OF_VNET (Mac)); - Ptr += SIZE_OF_VNET (Mac); - - *Ptr++ = (UINT8) (*Protocol >> 8); - *Ptr++ = (UINT8) *Protocol; - - ASSERT ((UINTN) (Ptr - (UINT8 *) Buffer) == Dev->Snm.MediaHeaderSize); - } - - // - // virtio-0.9.5, 2.4.1 Supplying Buffers to The Device - // - DescIdx = Dev->TxFreeStack[Dev->TxCurPending++]; - Dev->TxRing.Desc[DescIdx + 1].Addr = (UINTN) Buffer; - Dev->TxRing.Desc[DescIdx + 1].Len = (UINT32) BufferSize; - - // - // the available index is never written by the host, we can read it back - // without a barrier - // - AvailIdx = *Dev->TxRing.Avail.Idx; - Dev->TxRing.Avail.Ring[AvailIdx++ % Dev->TxRing.QueueSize] = DescIdx; - - MemoryFence (); - *Dev->TxRing.Avail.Idx = AvailIdx; - - MemoryFence (); - Status = Dev->VirtIo->SetQueueNotify (Dev->VirtIo, VIRTIO_NET_Q_TX); - -Exit: - gBS->RestoreTPL (OldTpl); - return Status; -} diff --git a/OvmfPkg/VirtioNetDxe/SnpUnsupported.c b/OvmfPkg/VirtioNetDxe/SnpUnsupported.c deleted file mode 100644 index e9f3825fa2..0000000000 --- a/OvmfPkg/VirtioNetDxe/SnpUnsupported.c +++ /dev/null @@ -1,160 +0,0 @@ -/** @file - - Empty implementation of the SNP methods that dependent protocols don't - absolutely need and the UEFI-2.3.1+errC specification allows us not to - support. - - Copyright (C) 2013, Red Hat, Inc. - Copyright (c) 2006 - 2010, Intel Corporation. All rights reserved.
- - This program and the accompanying materials are licensed and made available - under the terms and conditions of the BSD License which accompanies this - distribution. The full text of the license may be found at - http://opensource.org/licenses/bsd-license.php - - THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, WITHOUT - WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. - -**/ - -#include "VirtioNet.h" - -/** - Resets a network adapter and re-initializes it with the parameters that were - provided in the previous call to Initialize(). - - @param This The protocol instance pointer. - @param ExtendedVerification Indicates that the driver may perform a more - exhaustive verification operation of the device - during reset. - - @retval EFI_SUCCESS The network interface was reset. - @retval EFI_NOT_STARTED The network interface has not been started. - @retval EFI_INVALID_PARAMETER One or more of the parameters has an - unsupported value. - @retval EFI_DEVICE_ERROR The command could not be sent to the network - interface. - @retval EFI_UNSUPPORTED This function is not supported by the network - interface. - -**/ - -EFI_STATUS -EFIAPI -VirtioNetReset ( - IN EFI_SIMPLE_NETWORK_PROTOCOL *This, - IN BOOLEAN ExtendedVerification - ) -{ - return EFI_UNSUPPORTED; -} - - -/** - Modifies or resets the current station address, if supported. - - @param This The protocol instance pointer. - @param Reset Flag used to reset the station address to the network - interfaces permanent address. - @param New The new station address to be used for the network interface. - - @retval EFI_SUCCESS The network interfaces station address was - updated. - @retval EFI_NOT_STARTED The network interface has not been started. - @retval EFI_INVALID_PARAMETER One or more of the parameters has an - unsupported value. - @retval EFI_DEVICE_ERROR The command could not be sent to the network - interface. - @retval EFI_UNSUPPORTED This function is not supported by the network - interface. - -**/ - -EFI_STATUS -EFIAPI -VirtioNetStationAddress ( - IN EFI_SIMPLE_NETWORK_PROTOCOL *This, - IN BOOLEAN Reset, - IN EFI_MAC_ADDRESS *New OPTIONAL - ) -{ - return EFI_UNSUPPORTED; -} - - -/** - Resets or collects the statistics on a network interface. - - @param This Protocol instance pointer. - @param Reset Set to TRUE to reset the statistics for the network - interface. - @param StatisticsSize On input the size, in bytes, of StatisticsTable. On - output the size, in bytes, of the resulting table of - statistics. - @param StatisticsTable A pointer to the EFI_NETWORK_STATISTICS structure - that contains the statistics. - - @retval EFI_SUCCESS The statistics were collected from the network - interface. - @retval EFI_NOT_STARTED The network interface has not been started. - @retval EFI_BUFFER_TOO_SMALL The Statistics buffer was too small. The - current buffer size needed to hold the - statistics is returned in StatisticsSize. - @retval EFI_INVALID_PARAMETER One or more of the parameters has an - unsupported value. - @retval EFI_DEVICE_ERROR The command could not be sent to the network - interface. - @retval EFI_UNSUPPORTED This function is not supported by the network - interface. - -**/ - -EFI_STATUS -EFIAPI -VirtioNetStatistics ( - IN EFI_SIMPLE_NETWORK_PROTOCOL *This, - IN BOOLEAN Reset, - IN OUT UINTN *StatisticsSize OPTIONAL, - OUT EFI_NETWORK_STATISTICS *StatisticsTable OPTIONAL - ) -{ - return EFI_UNSUPPORTED; -} - - -/** - Performs read and write operations on the NVRAM device attached to a network - interface. - - @param This The protocol instance pointer. - @param ReadWrite TRUE for read operations, FALSE for write operations. - @param Offset Byte offset in the NVRAM device at which to start the read - or write operation. This must be a multiple of - NvRamAccessSize and less than NvRamSize. - @param BufferSize The number of bytes to read or write from the NVRAM - device. This must also be a multiple of NvramAccessSize. - @param Buffer A pointer to the data buffer. - - @retval EFI_SUCCESS The NVRAM access was performed. - @retval EFI_NOT_STARTED The network interface has not been started. - @retval EFI_INVALID_PARAMETER One or more of the parameters has an - unsupported value. - @retval EFI_DEVICE_ERROR The command could not be sent to the network - interface. - @retval EFI_UNSUPPORTED This function is not supported by the network - interface. - -**/ - -EFI_STATUS -EFIAPI -VirtioNetNvData ( - IN EFI_SIMPLE_NETWORK_PROTOCOL *This, - IN BOOLEAN ReadWrite, - IN UINTN Offset, - IN UINTN BufferSize, - IN OUT VOID *Buffer - ) -{ - return EFI_UNSUPPORTED; -} diff --git a/OvmfPkg/VirtioNetDxe/TechNotes.txt b/OvmfPkg/VirtioNetDxe/TechNotes.txt deleted file mode 100644 index 9c1dfe6a77..0000000000 --- a/OvmfPkg/VirtioNetDxe/TechNotes.txt +++ /dev/null @@ -1,355 +0,0 @@ -## @file -# -# Technical notes for the virtio-net driver. -# -# Copyright (C) 2013, Red Hat, Inc. -# -# This program and the accompanying materials are licensed and made available -# under the terms and conditions of the BSD License which accompanies this -# distribution. The full text of the license may be found at -# http://opensource.org/licenses/bsd-license.php -# -# THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, WITHOUT -# WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. -# -## - -Disclaimer ----------- - -All statements concerning standards and specifications are informative and not -normative. They are made in good faith. Corrections are most welcome on the -edk2-devel mailing list. - -The following documents have been perused while writing the driver and this -document: -- Unified Extensible Firmware Interface Specification, Version 2.3.1, Errata C; - June 27, 2012 -- Driver Writer's Guide for UEFI 2.3.1, 03/08/2012, Version 1.01; -- Virtio PCI Card Specification, v0.9.5 DRAFT, 2012 May 7. - - -Summary -------- - -The VirtioNetDxe UEFI_DRIVER implements the Simple Network Protocol for -virtio-net devices. Higher level protocols are automatically installed on top -of it by the DXE Core / the ConnectController() boot service, enabling for -virtio-net devices eg. DHCP configuration, TCP transfers with edk2 StdLib -applications, and PXE booting in OVMF. - - -UEFI driver structure ---------------------- - -A driver instance, belonging to a given virtio-net device, can be in one of -four states at any time. The states stack up as follows below. The state -transitions are labeled with the primary function (and its important callees -faithfully indented) that implement the transition. - - | ^ - | | - [DriverBinding.c] | | [DriverBinding.c] - VirtioNetDriverBindingStart | | VirtioNetDriverBindingStop - VirtioNetSnpPopulate | | VirtioNetSnpEvacuate - VirtioNetGetFeatures | | - v | - +-------------------------+ - | EfiSimpleNetworkStopped | - +-------------------------+ - | ^ - [SnpStart.c] | | [SnpStop.c] - VirtioNetStart | | VirtioNetStop - | | - v | - +-------------------------+ - | EfiSimpleNetworkStarted | - +-------------------------+ - | ^ - [SnpInitialize.c] | | [SnpShutdown.c] - VirtioNetInitialize | | VirtioNetShutdown - VirtioNetInitRing {Rx, Tx} | | VirtioNetShutdownRx [SnpSharedHelpers.c] - VirtioRingInit | | VirtioNetShutdownTx [SnpSharedHelpers.c] - VirtioNetInitTx | | VirtioRingUninit {Tx, Rx} - VirtioNetInitRx | | - v | - +-----------------------------+ - | EfiSimpleNetworkInitialized | - +-----------------------------+ - -The state at the top means "nonexistent" and is hence unnamed on the diagram -- -a driver instance actually doesn't exist at that point. The transition -functions out of and into that state implement the Driver Binding Protocol. - -The lower three states characterize an existent driver instance and are all -states defined by the Simple Network Protocol. The transition functions between -them are member functions of the Simple Network Protocol. - -Each transition function validates its expected source state and its -parameters. For example, VirtioNetDriverBindingStop will refuse to disconnect -from the controller unless it's in EfiSimpleNetworkStopped. - - -Driver instance states (Simple Network Protocol) ------------------------------------------------- - -In the EfiSimpleNetworkStopped state, the virtio-net device is (has been) -re-set. No resources are allocated for networking / traffic purposes. The MAC -address and other device attributes have been retrieved from the device (this -is necessary for completing the VirtioNetDriverBindingStart transition). - -The EfiSimpleNetworkStarted is completely identical to the -EfiSimpleNetworkStopped state for virtio-net, in the functional and -resource-usage sense. This state is mandated / provided by the Simple Network -Protocol for flexibility that the virtio-net driver doesn't exploit. - -In particular, the EfiSimpleNetworkStarted state is the target of the Shutdown -SNP member function, and must therefore correspond to a hardware configuration -where "[it] is safe for another driver to initialize". (Clearly another UEFI -driver could not do that due to the exclusivity of the driver binding that -VirtioNetDriverBindingStart() installs, but a later OS driver might qualify.) - -The EfiSimpleNetworkInitialized state is the live state of the virtio NIC / the -driver instance. Virtio and other resources required for network traffic have -been allocated, and the following SNP member functions are available (in -addition to VirtioNetShutdown which leaves the state): - -- VirtioNetReceive [SnpReceive.c]: poll the virtio NIC for an Rx packet that - may have arrived asynchronously; - -- VirtioNetTransmit [SnpTransmit.c]: queue a Tx packet for asynchronous - transmission (meant to be used together with VirtioNetGetStatus); - -- VirtioNetGetStatus [SnpGetStatus.c]: query link status and status of pending - Tx packets; - -- VirtioNetMcastIpToMac [SnpMcastIpToMac.c]: transform a multicast IPv4/IPv6 - address into a multicast MAC address; - -- VirtioNetReceiveFilters [SnpReceiveFilters.c]: emulate unicast / multicast / - broadcast filter configuration (not their actual effect -- a more liberal - filter setting than requested is allowed by the UEFI specification). - -The following SNP member functions are not supported [SnpUnsupported.c]: - -- VirtioNetReset: reinitialize the virtio NIC without shutting it down (a loop - from/to EfiSimpleNetworkInitialized); - -- VirtioNetStationAddress: assign a new MAC address to the virtio NIC, - -- VirtioNetStatistics: collect statistics, - -- VirtioNetNvData: access non-volatile data on the virtio NIC. - -Missing support for these functions is allowed by the UEFI specification and -doesn't seem to trip up higher level protocols. - - -Events and task priority levels -------------------------------- - -The UEFI specification defines a sophisticated mechanism for asynchronous -events / callbacks (see "6.1 Event, Timer, and Task Priority Services" for -details). Such callbacks work like software interrupts, and some notion of -locking / masking is important to implement critical sections (atomic or -exclusive access to data or a device). This notion is defined as Task Priority -Levels. - -The virtio-net driver for OVMF must concern itself with events for two reasons: - -- The Simple Network Protocol provides its clients with a (non-optional) WAIT - type event called WaitForPacket: it allows them to check or wait for Rx - packets by polling or blocking on this event. (This functionality overlaps - with the Receive member function.) The event is available to clients starting - with EfiSimpleNetworkStopped (inclusive). - - The virtio-net driver is informed about such client polling or blockage by - receiving an asynchronous callback (a software interrupt). In the callback - function the driver must interrogate the driver instance state, and if it is - EfiSimpleNetworkInitialized, access the Rx queue and see if any packets are - available for consumption. If so, it must signal the WaitForPacket WAIT type - event, waking the client. - - For simplicity and safety, all parts of the virtio-net driver that access any - bit of the driver instance (data or device) run at the TPL_CALLBACK level. - This is the highest level allowed for an SNP implementation, and all code - protected in this manner satisfies even stricter non-blocking requirements - than what's documented for TPL_CALLBACK. - - The task priority level for the WaitForPacket callback too is set by the - driver, the choice is TPL_CALLBACK again. This in effect serializes the - WaitForPacket callback (VirtioNetIsPacketAvailable [Events.c]) with "normal" - parts of the driver. - -- According to the Driver Writer's Guide, a network driver should install a - callback function for the global EXIT_BOOT_SERVICES event (a special NOTIFY - type event). When the ExitBootServices() boot service has cleaned up internal - firmware state and is about to pass control to the OS, any network driver has - to stop any in-flight DMA transfers, lest it corrupts OS memory. For this - reason EXIT_BOOT_SERVICES is emitted and the network driver must abort - in-flight DMA transfers. - - This callback (VirtioNetExitBoot) is synchronized with the rest of the driver - code just the same as explained for WaitForPacket. In - EfiSimpleNetworkInitialized state it resets the virtio NIC, halting all data - transfer. After the callback returns, no further driver code is expected to - be scheduled. - - -Virtio internals -- Rx ----------------------- - -Requests (Rx and Tx alike) are always submitted by the guest and processed by -the host. For Tx, processing means transmission. For Rx, processing means -filling in the request with an incoming packet. Submitted requests exist on the -"Available Ring", and answered (processed) requests show up on the "Used Ring". - -Packet data includes the media (Ethernet) header: destination MAC, source MAC, -and Ethertype (14 bytes total). - -The following structures implement packet reception. Most of them are defined -in the Virtio specification, the only driver-specific trait here is the static -pre-configuration of the two-part descriptor chains, in VirtioNetInitRx. The -diagram is simplified. - - Available Index Available Index - last processed incremented - by the host by the guest - v -------> v -Available +-------+-------+-------+-------+-------+ -Ring |DescIdx|DescIdx|DescIdx|DescIdx|DescIdx| - +-------+-------+-------+-------+-------+ - =D6 =D2 - - D2 D3 D4 D5 D6 D7 -Descr. +----------+----------++----------+----------++----------+----------+ -Table |Adr:Len:Nx|Adr:Len:Nx||Adr:Len:Nx|Adr:Len:Nx||Adr:Len:Nx|Adr:Len:Nx| - +----------+----------++----------+----------++----------+----------+ - =A2 =D3 =A3 =A4 =D5 =A5 =A6 =D7 =A7 - - - A2 A3 A4 A5 A6 A7 -Receive +---------------+---------------+---------------+ -Destination |vnet hdr:packet|vnet hdr:packet|vnet hdr:packet| -Area +---------------+---------------+---------------+ - - Used Index Used Index incremented - last processed by the guest by the host - v -------> v -Used +-----------+-----------+-----------+-----------+-----------+ -Ring |DescIdx:Len|DescIdx:Len|DescIdx:Len|DescIdx:Len|DescIdx:Len| - +-----------+-----------+-----------+-----------+-----------+ - =D4 - -In VirtioNetInitRx, the guest allocates the fixed size Receive Destination -Area, which accommodates all packets delivered asynchronously by the host. To -each packet, a slice of this area is dedicated; each slice is further -subdivided into virtio-net request header and network packet data. The -(guest-physical) addresses of these sub-slices are denoted with A2, A3, A4 and -so on. Importantly, an even-subscript "A" always belongs to a virtio-net -request header, while an odd-subscript "A" always belongs to a packet -sub-slice. - -Furthermore, the guest lays out a static pattern in the Descriptor Table. For -each packet that can be in-flight or already arrived from the host, -VirtioNetInitRx sets up a separate, two-part descriptor chain. For packet N, -the Nth descriptor chain is set up as follows: - -- the first (=head) descriptor, with even index, points to the fixed-size - sub-slice receiving the virtio-net request header, - -- the second descriptor (with odd index) points to the fixed (1514 byte) size - sub-slice receiving the packet data, - -- a link from the first (head) descriptor in the chain is established to the - second (tail) descriptor in the chain. - -Finally, the guest populates the Available Ring with the indices of the head -descriptors. All descriptor indices on both the Available Ring and the Used -Ring are even. - -Packet reception occurs as follows: - -- The host consumes a descriptor index off the Available Ring. This index is - even (=2*N), and fingers the head descriptor of the chain belonging to packet - N. - -- The host reads the descriptors D(2*N) and -- following the Next link there - --- D(2*N+1), and stores the virtio-net request header at A(2*N), and the - packet data at A(2*N+1). - -- The host places the index of the head descriptor, 2*N, onto the Used Ring, - and sets the Len field in the same Used Ring Element to the total number of - bytes transferred for the entire descriptor chain. This enables the guest to - identify the length of Rx packets. - -- VirtioNetReceive polls the Used Ring. If a new Used Ring Element shows up, it - copies the data out to the caller, and recycles the index of the head - descriptor (ie. 2*N) to the Available Ring. - -- Because the host can process (answer) Rx requests in any order theoretically, - the order of head descriptor indices on each of the Available Ring and the - Used Ring is virtually random. (Except right after the initial population in - VirtioNetInitRx, when the Available Ring is full and increasing, and the Used - Ring is empty.) - -- If the Available Ring is empty, the host is forced to drop packets. If the - Used Ring is empty, VirtioNetReceive returns EFI_NOT_READY (no packet - available). - - -Virtio internals -- Tx ----------------------- - -The transmission structure erected by VirtioNetInitTx is similar, it differs -in the following: - -- There is no Receive Destination Area. - -- Each head descriptor, D(2*N), points to a read-only virtio-net request header - that is shared by all of the head descriptors. This virtio-net request header - is never modified by the host. - -- Each tail descriptor is re-pointed to the caller-supplied packet buffer - whenever VirtioNetTransmit places the corresponding head descriptor on the - Available Ring. The caller is responsible to hang on to the unmodified buffer - until it is reported transmitted by VirtioNetGetStatus. - -Steps of packet transmission: - -- Client code calls VirtioNetTransmit. VirtioNetTransmit tracks free descriptor - chains by keeping the indices of their head descriptors in a stack that is - private to the driver instance. All elements of the stack are even. - -- If the stack is empty (that is, each descriptor chain, in isolation, is - either pending transmission, or has been processed by the host but not - yet recycled by a VirtioNetGetStatus call), then VirtioNetTransmit returns - EFI_NOT_READY. - -- Otherwise the index of a free chain's head descriptor is popped from the - stack. The linked tail descriptor is re-pointed as discussed above. The head - descriptor's index is pushed on the Available Ring. - -- The host moves the head descriptor index from the Available Ring to the Used - Ring when it transmits the packet. - -- Client code calls VirtioNetGetStatus. In case the Used Ring is empty, the - function reports no Tx completion. Otherwise, a head descriptor's index is - consumed from the Used Ring and recycled to the private stack. The client - code's original packet buffer address is fetched from the tail descriptor - (where it has been stored at VirtioNetTransmit time) and returned to the - caller. - -- The Len field of the Used Ring Element is not checked. The host is assumed to - have transmitted the entire packet -- VirtioNetTransmit had forced it below - 1514 bytes (inclusive). The Virtio specification suggests this packet size is - always accepted (and a lower MTU could be encountered on any later hop as - well). Additionally, there's no good way to report a short transmit via - VirtioNetGetStatus; EFI_DEVICE_ERROR seems too serious from the specification - and higher level protocols could interpret it as a fatal condition. - -- The host can theoretically reorder head descriptor indices when moving them - from the Available Ring to the Used Ring (out of order transmission). Because - of this (and the choice of a stack over a list for free descriptor chain - tracking) the order of head descriptor indices on either Ring is - unpredictable. diff --git a/OvmfPkg/VirtioNetDxe/VirtioNet.h b/OvmfPkg/VirtioNetDxe/VirtioNet.h deleted file mode 100644 index 710859bc61..0000000000 --- a/OvmfPkg/VirtioNetDxe/VirtioNet.h +++ /dev/null @@ -1,283 +0,0 @@ -/** @file - - Internal definitions for the virtio-net driver, which produces Simple Network - Protocol instances for virtio-net devices. - - Copyright (C) 2013, Red Hat, Inc. - - This program and the accompanying materials are licensed and made available - under the terms and conditions of the BSD License which accompanies this - distribution. The full text of the license may be found at - http://opensource.org/licenses/bsd-license.php - - THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, WITHOUT - WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. -**/ - -#ifndef _VIRTIO_NET_DXE_H_ -#define _VIRTIO_NET_DXE_H_ - -#include -#include -#include -#include -#include -#include -#include -#include - -#define VNET_SIG SIGNATURE_32 ('V', 'N', 'E', 'T') - -// -// maximum number of pending packets, separately for each direction -// -#define VNET_MAX_PENDING 64 - -// -// State diagram: -// -// | ^ -// | | -// BindingStart BindingStop -// +SnpPopulate | -// ++GetFeatures | -// | | -// v | -// +---------+ virtio-net device is reset, no resources are -// | stopped | allocated for traffic, but MAC address has -// +---------+ been retrieved -// | ^ -// | | -// SNP.Start SNP.Stop -// | | -// v | -// +---------+ -// | started | functionally identical to stopped -// +---------+ -// | ^ -// | | -// SNP.Initialize SNP.Shutdown -// | | -// v | -// +-------------+ Virtio-net setup complete, including DRIVER_OK -// | initialized | bit. The receive queue is populated with -// +-------------+ requests; McastIpToMac, GetStatus, Transmit, -// Receive are callable. -// - -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 - // ------------------ ------------------------------ - UINT32 Signature; // VirtioNetDriverBindingStart - VIRTIO_DEVICE_PROTOCOL *VirtIo; // VirtioNetDriverBindingStart - EFI_SIMPLE_NETWORK_PROTOCOL Snp; // VirtioNetSnpPopulate - EFI_SIMPLE_NETWORK_MODE Snm; // VirtioNetSnpPopulate - EFI_EVENT ExitBoot; // VirtioNetSnpPopulate - EFI_DEVICE_PATH_PROTOCOL *MacDevicePath; // VirtioNetDriverBindingStart - EFI_HANDLE MacHandle; // VirtioNetDriverBindingStart - - VRING RxRing; // VirtioNetInitRing - UINT8 *RxBuf; // VirtioNetInitRx - UINT16 RxLastUsed; // VirtioNetInitRx - - VRING TxRing; // VirtioNetInitRing - UINT16 TxMaxPending; // VirtioNetInitTx - UINT16 TxCurPending; // VirtioNetInitTx - UINT16 *TxFreeStack; // VirtioNetInitTx - VIRTIO_1_0_NET_REQ TxSharedReq; // VirtioNetInitTx - UINT16 TxLastUsed; // VirtioNetInitTx -} VNET_DEV; - - -// -// In order to avoid duplication of interface documentation, please find all -// leading comments near the respective function / variable definitions (not -// the declarations here), which is where your code editor of choice takes you -// anyway when jumping to a function. -// - -// -// utility macros -// -#define VIRTIO_NET_FROM_SNP(SnpPointer) \ - CR (SnpPointer, VNET_DEV, Snp, VNET_SIG) - -#define VIRTIO_CFG_WRITE(Dev, Field, Value) ((Dev)->VirtIo->WriteDevice ( \ - (Dev)->VirtIo, \ - OFFSET_OF_VNET (Field), \ - SIZE_OF_VNET (Field), \ - (Value) \ - )) - -#define VIRTIO_CFG_READ(Dev, Field, Pointer) ((Dev)->VirtIo->ReadDevice ( \ - (Dev)->VirtIo, \ - OFFSET_OF_VNET (Field), \ - SIZE_OF_VNET (Field), \ - sizeof *(Pointer), \ - (Pointer) \ - )) - -// -// component naming -// -extern EFI_COMPONENT_NAME_PROTOCOL gVirtioNetComponentName; -extern EFI_COMPONENT_NAME2_PROTOCOL gVirtioNetComponentName2; - -// -// driver binding -// -extern EFI_DRIVER_BINDING_PROTOCOL gVirtioNetDriverBinding; - -// -// member functions implementing the Simple Network Protocol -// -EFI_STATUS -EFIAPI -VirtioNetStart ( - IN EFI_SIMPLE_NETWORK_PROTOCOL *This - ); - -EFI_STATUS -EFIAPI -VirtioNetStop ( - IN EFI_SIMPLE_NETWORK_PROTOCOL *This - ); - -EFI_STATUS -EFIAPI -VirtioNetInitialize ( - IN EFI_SIMPLE_NETWORK_PROTOCOL *This, - IN UINTN ExtraRxBufferSize OPTIONAL, - IN UINTN ExtraTxBufferSize OPTIONAL - ); - -EFI_STATUS -EFIAPI -VirtioNetReset ( - IN EFI_SIMPLE_NETWORK_PROTOCOL *This, - IN BOOLEAN ExtendedVerification - ); - -EFI_STATUS -EFIAPI -VirtioNetShutdown ( - IN EFI_SIMPLE_NETWORK_PROTOCOL *This - ); - -EFI_STATUS -EFIAPI -VirtioNetReceiveFilters ( - IN EFI_SIMPLE_NETWORK_PROTOCOL *This, - IN UINT32 Enable, - IN UINT32 Disable, - IN BOOLEAN ResetMCastFilter, - IN UINTN MCastFilterCnt OPTIONAL, - IN EFI_MAC_ADDRESS *MCastFilter OPTIONAL - ); - -EFI_STATUS -EFIAPI -VirtioNetStationAddress ( - IN EFI_SIMPLE_NETWORK_PROTOCOL *This, - IN BOOLEAN Reset, - IN EFI_MAC_ADDRESS *New OPTIONAL - ); - -EFI_STATUS -EFIAPI -VirtioNetStatistics ( - IN EFI_SIMPLE_NETWORK_PROTOCOL *This, - IN BOOLEAN Reset, - IN OUT UINTN *StatisticsSize OPTIONAL, - OUT EFI_NETWORK_STATISTICS *StatisticsTable OPTIONAL - ); - -EFI_STATUS -EFIAPI -VirtioNetMcastIpToMac ( - IN EFI_SIMPLE_NETWORK_PROTOCOL *This, - IN BOOLEAN IPv6, - IN EFI_IP_ADDRESS *Ip, - OUT EFI_MAC_ADDRESS *Mac - ); - -EFI_STATUS -EFIAPI -VirtioNetNvData ( - IN EFI_SIMPLE_NETWORK_PROTOCOL *This, - IN BOOLEAN ReadWrite, - IN UINTN Offset, - IN UINTN BufferSize, - IN OUT VOID *Buffer - ); - -EFI_STATUS -EFIAPI -VirtioNetGetStatus ( - IN EFI_SIMPLE_NETWORK_PROTOCOL *This, - OUT UINT32 *InterruptStatus OPTIONAL, - OUT VOID **TxBuf OPTIONAL - ); - -EFI_STATUS -EFIAPI -VirtioNetTransmit ( - IN EFI_SIMPLE_NETWORK_PROTOCOL *This, - IN UINTN HeaderSize, - IN UINTN BufferSize, - IN /* +OUT! */ VOID *Buffer, - IN EFI_MAC_ADDRESS *SrcAddr OPTIONAL, - IN EFI_MAC_ADDRESS *DestAddr OPTIONAL, - IN UINT16 *Protocol OPTIONAL - ); - -EFI_STATUS -EFIAPI -VirtioNetReceive ( - IN EFI_SIMPLE_NETWORK_PROTOCOL *This, - OUT UINTN *HeaderSize OPTIONAL, - IN OUT UINTN *BufferSize, - OUT VOID *Buffer, - OUT EFI_MAC_ADDRESS *SrcAddr OPTIONAL, - OUT EFI_MAC_ADDRESS *DestAddr OPTIONAL, - OUT UINT16 *Protocol OPTIONAL - ); - -// -// utility functions shared by various SNP member functions -// -VOID -EFIAPI -VirtioNetShutdownRx ( - IN OUT VNET_DEV *Dev - ); - -VOID -EFIAPI -VirtioNetShutdownTx ( - IN OUT VNET_DEV *Dev - ); - -// -// event callbacks -// -VOID -EFIAPI -VirtioNetIsPacketAvailable ( - IN EFI_EVENT Event, - IN VOID *Context - ); - -VOID -EFIAPI -VirtioNetExitBoot ( - IN EFI_EVENT Event, - IN VOID *Context - ); - -#endif // _VIRTIO_NET_DXE_H_ diff --git a/OvmfPkg/VirtioNetDxe/VirtioNet.inf b/OvmfPkg/VirtioNetDxe/VirtioNet.inf deleted file mode 100644 index a855ad4ac1..0000000000 --- a/OvmfPkg/VirtioNetDxe/VirtioNet.inf +++ /dev/null @@ -1,60 +0,0 @@ -## @file -# -# This driver produces Simple Network Protocol instances for virtio-net -# devices. -# -# Copyright (C) 2013, Red Hat, Inc. -# -# This program and the accompanying materials are licensed and made available -# under the terms and conditions of the BSD License which accompanies this -# distribution. The full text of the license may be found at -# http://opensource.org/licenses/bsd-license.php -# -# THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, WITHOUT -# WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. -# -## - -[Defines] - INF_VERSION = 0x00010005 - BASE_NAME = VirtioNetDxe - FILE_GUID = A92CDB4B-82F1-4E0B-A516-8A655D371524 - MODULE_TYPE = UEFI_DRIVER - VERSION_STRING = 1.0 - ENTRY_POINT = VirtioNetEntryPoint - -[Sources] - ComponentName.c - DriverBinding.c - EntryPoint.c - Events.c - SnpGetStatus.c - SnpInitialize.c - SnpMcastIpToMac.c - SnpReceive.c - SnpReceiveFilters.c - SnpSharedHelpers.c - SnpShutdown.c - SnpStart.c - SnpStop.c - SnpTransmit.c - SnpUnsupported.c - -[Packages] - MdePkg/MdePkg.dec - OvmfPkg/OvmfPkg.dec - -[LibraryClasses] - BaseMemoryLib - DebugLib - DevicePathLib - MemoryAllocationLib - UefiBootServicesTableLib - UefiDriverEntryPoint - UefiLib - VirtioLib - -[Protocols] - gEfiSimpleNetworkProtocolGuid ## BY_START - gEfiDevicePathProtocolGuid ## BY_START - gVirtioDeviceProtocolGuid ## TO_START diff --git a/OvmfPkg/VirtioPciDeviceDxe/VirtioPciDevice.c b/OvmfPkg/VirtioPciDeviceDxe/VirtioPciDevice.c deleted file mode 100644 index bc4f6fe8bf..0000000000 --- a/OvmfPkg/VirtioPciDeviceDxe/VirtioPciDevice.c +++ /dev/null @@ -1,679 +0,0 @@ -/** @file - - This driver produces Virtio Device Protocol instances for Virtio PCI devices. - - Copyright (C) 2012, Red Hat, Inc. - Copyright (c) 2012 - 2016, Intel Corporation. All rights reserved.
- Copyright (C) 2013, ARM Ltd. - - This program and the accompanying materials are licensed and made available - under the terms and conditions of the BSD License which accompanies this - distribution. The full text of the license may be found at - http://opensource.org/licenses/bsd-license.php - - THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, WITHOUT - WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. - -**/ - -#include -#include -#include -#include -#include -#include - -#include "VirtioPciDevice.h" - -STATIC VIRTIO_DEVICE_PROTOCOL mDeviceProtocolTemplate = { - 0, // Revision - 0, // SubSystemDeviceId - VirtioPciGetDeviceFeatures, // GetDeviceFeatures - VirtioPciSetGuestFeatures, // SetGuestFeatures - VirtioPciSetQueueAddress, // SetQueueAddress - VirtioPciSetQueueSel, // SetQueueSel - VirtioPciSetQueueNotify, // SetQueueNotify - VirtioPciSetQueueAlignment, // SetQueueAlignment - VirtioPciSetPageSize, // SetPageSize - VirtioPciGetQueueSize, // GetQueueNumMax - VirtioPciSetQueueSize, // SetQueueNum - VirtioPciGetDeviceStatus, // GetDeviceStatus - VirtioPciSetDeviceStatus, // SetDeviceStatus - VirtioPciDeviceWrite, // WriteDevice - VirtioPciDeviceRead // ReadDevice -}; - -/** - - Read a word from Region 0 of the device specified by PciIo. - - Region 0 must be an iomem region. This is an internal function for the PCI - implementation of the protocol. - - @param[in] Dev Virtio PCI device. - - @param[in] FieldOffset Source offset. - - @param[in] FieldSize Source field size, must be in { 1, 2, 4, 8 }. - - @param[in] BufferSize Number of bytes available in the target buffer. Must - equal FieldSize. - - @param[out] Buffer Target buffer. - - - @return Status code returned by PciIo->Io.Read(). - -**/ -EFI_STATUS -EFIAPI -VirtioPciIoRead ( - IN VIRTIO_PCI_DEVICE *Dev, - IN UINTN FieldOffset, - IN UINTN FieldSize, - IN UINTN BufferSize, - OUT VOID *Buffer - ) -{ - UINTN Count; - EFI_PCI_IO_PROTOCOL_WIDTH Width; - EFI_PCI_IO_PROTOCOL *PciIo; - - ASSERT (FieldSize == BufferSize); - - PciIo = Dev->PciIo; - Count = 1; - - switch (FieldSize) { - case 1: - Width = EfiPciIoWidthUint8; - break; - - case 2: - Width = EfiPciIoWidthUint16; - break; - - case 8: - // - // The 64bit PCI I/O is broken down into two 32bit reads to prevent - // any alignment or width issues. - // The UEFI spec says under EFI_PCI_IO_PROTOCOL.Io.Write(): - // - // The I/O operations are carried out exactly as requested. The caller - // is responsible for any alignment and I/O width issues which the - // bus, device, platform, or type of I/O might require. For example on - // some platforms, width requests of EfiPciIoWidthUint64 do not work. - // - Count = 2; - - // - // fall through - // - case 4: - Width = EfiPciIoWidthUint32; - break; - - default: - ASSERT (FALSE); - return EFI_INVALID_PARAMETER; - } - - return PciIo->Io.Read ( - PciIo, - Width, - PCI_BAR_IDX0, - FieldOffset, - Count, - Buffer - ); -} - -/** - - Write a word into Region 0 of the device specified by PciIo. - - Region 0 must be an iomem region. This is an internal function for the PCI - implementation of the protocol. - - @param[in] Dev Virtio PCI device. - - @param[in] FieldOffset Destination offset. - - @param[in] FieldSize Destination field size, must be in { 1, 2, 4, 8 }. - - @param[in] Value Little endian value to write, converted to UINT64. - The least significant FieldSize bytes will be used. - - - @return Status code returned by PciIo->Io.Write(). - -**/ -EFI_STATUS -EFIAPI -VirtioPciIoWrite ( - IN VIRTIO_PCI_DEVICE *Dev, - IN UINTN FieldOffset, - IN UINTN FieldSize, - IN UINT64 Value - ) -{ - UINTN Count; - EFI_PCI_IO_PROTOCOL_WIDTH Width; - EFI_PCI_IO_PROTOCOL *PciIo; - - PciIo = Dev->PciIo; - Count = 1; - - switch (FieldSize) { - case 1: - Width = EfiPciIoWidthUint8; - break; - - case 2: - Width = EfiPciIoWidthUint16; - break; - - case 8: - // - // The 64bit PCI I/O is broken down into two 32bit writes to prevent - // any alignment or width issues. - // The UEFI spec says under EFI_PCI_IO_PROTOCOL.Io.Write(): - // - // The I/O operations are carried out exactly as requested. The caller - // is responsible for any alignment and I/O width issues which the - // bus, device, platform, or type of I/O might require. For example on - // some platforms, width requests of EfiPciIoWidthUint64 do not work - // - Count = Count * 2; - - // - // fall through - // - case 4: - Width = EfiPciIoWidthUint32; - break; - - default: - ASSERT (FALSE); - return EFI_INVALID_PARAMETER; - } - - return PciIo->Io.Write ( - PciIo, - Width, - PCI_BAR_IDX0, - FieldOffset, - Count, - &Value - ); -} - -/** - - Device probe function for this driver. - - The DXE core calls this function for any given device in order to see if the - driver can drive the device. - - @param[in] This The EFI_DRIVER_BINDING_PROTOCOL object - incorporating this driver (independently of - any device). - - @param[in] DeviceHandle The device to probe. - - @param[in] RemainingDevicePath Relevant only for bus drivers, ignored. - - - @retval EFI_SUCCESS The driver supports the device being probed. - - @retval EFI_UNSUPPORTED Based on virtio-pci discovery, we do not support - the device. - - @return Error codes from the OpenProtocol() boot service or - the PciIo protocol. - -**/ -STATIC -EFI_STATUS -EFIAPI -VirtioPciDeviceBindingSupported ( - IN EFI_DRIVER_BINDING_PROTOCOL *This, - IN EFI_HANDLE DeviceHandle, - IN EFI_DEVICE_PATH_PROTOCOL *RemainingDevicePath - ) -{ - EFI_STATUS Status; - EFI_PCI_IO_PROTOCOL *PciIo; - PCI_TYPE00 Pci; - - // - // Attempt to open the device with the PciIo set of interfaces. On success, - // the protocol is "instantiated" for the PCI device. Covers duplicate open - // attempts (EFI_ALREADY_STARTED). - // - Status = gBS->OpenProtocol ( - DeviceHandle, // candidate device - &gEfiPciIoProtocolGuid, // for generic PCI access - (VOID **)&PciIo, // handle to instantiate - This->DriverBindingHandle, // requestor driver identity - DeviceHandle, // ControllerHandle, according to - // the UEFI Driver Model - EFI_OPEN_PROTOCOL_BY_DRIVER // get exclusive PciIo access to - // the device; to be released - ); - if (EFI_ERROR (Status)) { - return Status; - } - - // - // Read entire PCI configuration header for more extensive check ahead. - // - Status = PciIo->Pci.Read ( - PciIo, // (protocol, device) - // handle - EfiPciIoWidthUint32, // access width & copy - // mode - 0, // Offset - sizeof Pci / sizeof (UINT32), // Count - &Pci // target buffer - ); - - if (Status == EFI_SUCCESS) { - // - // virtio-0.9.5, 2.1 PCI Discovery - // - if ((Pci.Hdr.VendorId == VIRTIO_VENDOR_ID) && - (Pci.Hdr.DeviceId >= 0x1000) && - (Pci.Hdr.DeviceId <= 0x103F) && - (Pci.Hdr.RevisionID == 0x00)) { - Status = EFI_SUCCESS; - } else { - Status = EFI_UNSUPPORTED; - } - } - - // - // We needed PCI IO access only transitorily, to see whether we support the - // device or not. - // - gBS->CloseProtocol (DeviceHandle, &gEfiPciIoProtocolGuid, - This->DriverBindingHandle, DeviceHandle); - - return Status; -} - -/** - - Initialize the VirtIo PCI Device - - @param[in, out] Dev The driver instance to configure. The caller is - responsible for Device->PciIo's validity (ie. working IO - access to the underlying virtio-pci device). - - @retval EFI_SUCCESS Setup complete. - - @retval EFI_UNSUPPORTED The underlying IO device doesn't support the - provided address offset and read size. - - @return Error codes from PciIo->Pci.Read(). - -**/ -STATIC -EFI_STATUS -EFIAPI -VirtioPciInit ( - IN OUT VIRTIO_PCI_DEVICE *Device - ) -{ - EFI_STATUS Status; - EFI_PCI_IO_PROTOCOL *PciIo; - PCI_TYPE00 Pci; - - ASSERT (Device != NULL); - PciIo = Device->PciIo; - ASSERT (PciIo != NULL); - ASSERT (PciIo->Pci.Read != NULL); - - Status = PciIo->Pci.Read ( - PciIo, // (protocol, device) - // handle - EfiPciIoWidthUint32, // access width & copy - // mode - 0, // Offset - sizeof (Pci) / sizeof (UINT32), // Count - &Pci // target buffer - ); - if (EFI_ERROR (Status)) { - return Status; - } - - // - // Copy protocol template - // - CopyMem (&Device->VirtioDevice, &mDeviceProtocolTemplate, - sizeof (VIRTIO_DEVICE_PROTOCOL)); - - // - // Initialize the protocol interface attributes - // - Device->VirtioDevice.Revision = VIRTIO_SPEC_REVISION (0, 9, 5); - Device->VirtioDevice.SubSystemDeviceId = Pci.Device.SubsystemID; - - // - // Note: We don't support the MSI-X capability. If we did, - // the offset would become 24 after enabling MSI-X. - // - Device->DeviceSpecificConfigurationOffset = - VIRTIO_DEVICE_SPECIFIC_CONFIGURATION_OFFSET_PCI; - - return EFI_SUCCESS; -} - -/** - - Uninitialize the internals of a virtio-pci device that has been successfully - set up with VirtioPciInit(). - - @param[in, out] Dev The device to clean up. - -**/ - -STATIC -VOID -EFIAPI -VirtioPciUninit ( - IN OUT VIRTIO_PCI_DEVICE *Device - ) -{ - // Note: This function mirrors VirtioPciInit() that does not allocate any - // resources - there's nothing to free here. -} - -/** - - After we've pronounced support for a specific device in - DriverBindingSupported(), we start managing said device (passed in by the - Driver Execution Environment) with the following service. - - See DriverBindingSupported() for specification references. - - @param[in] This The EFI_DRIVER_BINDING_PROTOCOL object - incorporating this driver (independently of - any device). - - @param[in] DeviceHandle The supported device to drive. - - @param[in] RemainingDevicePath Relevant only for bus drivers, ignored. - - - @retval EFI_SUCCESS Driver instance has been created and - initialized for the virtio-pci device, it - is now accessible via VIRTIO_DEVICE_PROTOCOL. - - @retval EFI_OUT_OF_RESOURCES Memory allocation failed. - - @return Error codes from the OpenProtocol() boot - service, the PciIo protocol, VirtioPciInit(), - or the InstallProtocolInterface() boot service. - -**/ -STATIC -EFI_STATUS -EFIAPI -VirtioPciDeviceBindingStart ( - IN EFI_DRIVER_BINDING_PROTOCOL *This, - IN EFI_HANDLE DeviceHandle, - IN EFI_DEVICE_PATH_PROTOCOL *RemainingDevicePath - ) -{ - VIRTIO_PCI_DEVICE *Device; - EFI_STATUS Status; - - Device = (VIRTIO_PCI_DEVICE *) AllocateZeroPool (sizeof *Device); - if (Device == NULL) { - return EFI_OUT_OF_RESOURCES; - } - - Status = gBS->OpenProtocol (DeviceHandle, &gEfiPciIoProtocolGuid, - (VOID **)&Device->PciIo, This->DriverBindingHandle, - DeviceHandle, EFI_OPEN_PROTOCOL_BY_DRIVER); - if (EFI_ERROR (Status)) { - goto FreeVirtioPci; - } - - // - // We must retain and ultimately restore the original PCI attributes of the - // device. See Driver Writer's Guide for UEFI 2.3.1 v1.01, 18.3 PCI drivers / - // 18.3.2 Start() and Stop(). - // - // The third parameter ("Attributes", input) is ignored by the Get operation. - // The fourth parameter ("Result", output) is ignored by the Enable and Set - // operations. - // - // For virtio-pci we only need IO space access. - // - Status = Device->PciIo->Attributes (Device->PciIo, - EfiPciIoAttributeOperationGet, 0, &Device->OriginalPciAttributes); - if (EFI_ERROR (Status)) { - goto ClosePciIo; - } - - Status = Device->PciIo->Attributes (Device->PciIo, - EfiPciIoAttributeOperationEnable, - EFI_PCI_IO_ATTRIBUTE_IO, NULL); - if (EFI_ERROR (Status)) { - goto ClosePciIo; - } - - // - // PCI IO access granted, configure protocol instance - // - - Status = VirtioPciInit (Device); - if (EFI_ERROR (Status)) { - goto RestorePciAttributes; - } - - // - // Setup complete, attempt to export the driver instance's VirtioDevice - // interface. - // - Device->Signature = VIRTIO_PCI_DEVICE_SIGNATURE; - Status = gBS->InstallProtocolInterface (&DeviceHandle, - &gVirtioDeviceProtocolGuid, EFI_NATIVE_INTERFACE, - &Device->VirtioDevice); - if (EFI_ERROR (Status)) { - goto UninitDev; - } - - return EFI_SUCCESS; - -UninitDev: - VirtioPciUninit (Device); - -RestorePciAttributes: - Device->PciIo->Attributes (Device->PciIo, EfiPciIoAttributeOperationSet, - Device->OriginalPciAttributes, NULL); - -ClosePciIo: - gBS->CloseProtocol (DeviceHandle, &gEfiPciIoProtocolGuid, - This->DriverBindingHandle, DeviceHandle); - -FreeVirtioPci: - FreePool (Device); - - return Status; -} - -/** - - Stop driving the Virtio PCI device - - @param[in] This The EFI_DRIVER_BINDING_PROTOCOL object - incorporating this driver (independently of any - device). - - @param[in] DeviceHandle Stop driving this device. - - @param[in] NumberOfChildren Since this function belongs to a device driver - only (as opposed to a bus driver), the caller - environment sets NumberOfChildren to zero, and - we ignore it. - - @param[in] ChildHandleBuffer Ignored (corresponding to NumberOfChildren). - - @retval EFI_SUCCESS Driver instance has been stopped and the PCI - configuration attributes have been restored. - - @return Error codes from the OpenProtocol() or - CloseProtocol(), UninstallProtocolInterface() - boot services. - -**/ -STATIC -EFI_STATUS -EFIAPI -VirtioPciDeviceBindingStop ( - IN EFI_DRIVER_BINDING_PROTOCOL *This, - IN EFI_HANDLE DeviceHandle, - IN UINTN NumberOfChildren, - IN EFI_HANDLE *ChildHandleBuffer - ) -{ - EFI_STATUS Status; - VIRTIO_DEVICE_PROTOCOL *VirtioDevice; - VIRTIO_PCI_DEVICE *Device; - - Status = gBS->OpenProtocol ( - DeviceHandle, // candidate device - &gVirtioDeviceProtocolGuid, // retrieve the VirtIo iface - (VOID **)&VirtioDevice, // target pointer - This->DriverBindingHandle, // requestor driver identity - DeviceHandle, // requesting lookup for dev. - EFI_OPEN_PROTOCOL_GET_PROTOCOL // lookup only, no ref. added - ); - if (EFI_ERROR (Status)) { - return Status; - } - - Device = VIRTIO_PCI_DEVICE_FROM_VIRTIO_DEVICE (VirtioDevice); - - // - // Handle Stop() requests for in-use driver instances gracefully. - // - Status = gBS->UninstallProtocolInterface (DeviceHandle, - &gVirtioDeviceProtocolGuid, &Device->VirtioDevice); - if (EFI_ERROR (Status)) { - return Status; - } - - VirtioPciUninit (Device); - - Device->PciIo->Attributes (Device->PciIo, EfiPciIoAttributeOperationSet, - Device->OriginalPciAttributes, NULL); - - Status = gBS->CloseProtocol (DeviceHandle, &gEfiPciIoProtocolGuid, - This->DriverBindingHandle, DeviceHandle); - - FreePool (Device); - - return Status; -} - - -// -// The static object that groups the Supported() (ie. probe), Start() and -// Stop() functions of the driver together. Refer to UEFI Spec 2.3.1 + Errata -// C, 10.1 EFI Driver Binding Protocol. -// -STATIC EFI_DRIVER_BINDING_PROTOCOL gDriverBinding = { - &VirtioPciDeviceBindingSupported, - &VirtioPciDeviceBindingStart, - &VirtioPciDeviceBindingStop, - 0x10, // Version, must be in [0x10 .. 0xFFFFFFEF] for IHV-developed drivers - NULL, // ImageHandle, to be overwritten by - // EfiLibInstallDriverBindingComponentName2() in VirtioPciEntryPoint() - NULL // DriverBindingHandle, ditto -}; - - -// -// The purpose of the following scaffolding (EFI_COMPONENT_NAME_PROTOCOL and -// EFI_COMPONENT_NAME2_PROTOCOL implementation) is to format the driver's name -// in English, for display on standard console devices. This is recommended for -// UEFI drivers that follow the UEFI Driver Model. Refer to the Driver Writer's -// Guide for UEFI 2.3.1 v1.01, 11 UEFI Driver and Controller Names. -// -STATIC -EFI_UNICODE_STRING_TABLE mDriverNameTable[] = { - { "eng;en", L"Virtio PCI Driver" }, - { NULL, NULL } -}; - -STATIC -EFI_COMPONENT_NAME_PROTOCOL gComponentName; - -EFI_STATUS -EFIAPI -VirtioPciGetDriverName ( - IN EFI_COMPONENT_NAME_PROTOCOL *This, - IN CHAR8 *Language, - OUT CHAR16 **DriverName - ) -{ - return LookupUnicodeString2 ( - Language, - This->SupportedLanguages, - mDriverNameTable, - DriverName, - (BOOLEAN)(This == &gComponentName) // Iso639Language - ); -} - -EFI_STATUS -EFIAPI -VirtioPciGetDeviceName ( - IN EFI_COMPONENT_NAME_PROTOCOL *This, - IN EFI_HANDLE DeviceHandle, - IN EFI_HANDLE ChildHandle, - IN CHAR8 *Language, - OUT CHAR16 **ControllerName - ) -{ - return EFI_UNSUPPORTED; -} - -STATIC -EFI_COMPONENT_NAME_PROTOCOL gComponentName = { - &VirtioPciGetDriverName, - &VirtioPciGetDeviceName, - "eng" // SupportedLanguages, ISO 639-2 language codes -}; - -STATIC -EFI_COMPONENT_NAME2_PROTOCOL gComponentName2 = { - (EFI_COMPONENT_NAME2_GET_DRIVER_NAME) &VirtioPciGetDriverName, - (EFI_COMPONENT_NAME2_GET_CONTROLLER_NAME) &VirtioPciGetDeviceName, - "en" // SupportedLanguages, RFC 4646 language codes -}; - - -// -// Entry point of this driver. -// -EFI_STATUS -EFIAPI -VirtioPciDeviceEntryPoint ( - IN EFI_HANDLE ImageHandle, - IN EFI_SYSTEM_TABLE *SystemTable - ) -{ - return EfiLibInstallDriverBindingComponentName2 ( - ImageHandle, - SystemTable, - &gDriverBinding, - ImageHandle, - &gComponentName, - &gComponentName2 - ); -} diff --git a/OvmfPkg/VirtioPciDeviceDxe/VirtioPciDevice.h b/OvmfPkg/VirtioPciDeviceDxe/VirtioPciDevice.h deleted file mode 100644 index 8f17a16c88..0000000000 --- a/OvmfPkg/VirtioPciDeviceDxe/VirtioPciDevice.h +++ /dev/null @@ -1,159 +0,0 @@ -/** @file - - Internal definitions for the VirtIo PCI Device driver - - Copyright (C) 2013, ARM Ltd - - This program and the accompanying materials are licensed and made available - under the terms and conditions of the BSD License which accompanies this - distribution. The full text of the license may be found at - http://opensource.org/licenses/bsd-license.php - - THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, WITHOUT - WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. - -**/ - -#ifndef _VIRTIO_PCI_DEVICE_DXE_H_ -#define _VIRTIO_PCI_DEVICE_DXE_H_ - -#include -#include -#include -#include - -#include - -#define VIRTIO_PCI_DEVICE_SIGNATURE SIGNATURE_32 ('V', 'P', 'C', 'I') - -typedef struct { - UINT32 Signature; - VIRTIO_DEVICE_PROTOCOL VirtioDevice; - EFI_PCI_IO_PROTOCOL *PciIo; - UINT64 OriginalPciAttributes; - UINT32 DeviceSpecificConfigurationOffset; -} VIRTIO_PCI_DEVICE; - -#define VIRTIO_PCI_DEVICE_FROM_VIRTIO_DEVICE(Device) \ - CR (Device, VIRTIO_PCI_DEVICE, VirtioDevice, VIRTIO_PCI_DEVICE_SIGNATURE) - - -EFI_STATUS -EFIAPI -VirtioPciIoRead ( - IN VIRTIO_PCI_DEVICE *Dev, - IN UINTN FieldOffset, - IN UINTN FieldSize, - IN UINTN BufferSize, - OUT VOID *Buffer - ); - -EFI_STATUS -EFIAPI -VirtioPciIoWrite ( - IN VIRTIO_PCI_DEVICE *Dev, - IN UINTN FieldOffset, - IN UINTN FieldSize, - IN UINT64 Value - ); - -/******************************************** - * PCI Functions for VIRTIO_DEVICE_PROTOCOL - *******************************************/ -EFI_STATUS -EFIAPI -VirtioPciDeviceRead ( - IN VIRTIO_DEVICE_PROTOCOL *This, - IN UINTN FieldOffset, - IN UINTN FieldSize, - IN UINTN BufferSize, - OUT VOID *Buffer - ); - -EFI_STATUS -EFIAPI -VirtioPciDeviceWrite ( - IN VIRTIO_DEVICE_PROTOCOL *This, - IN UINTN FieldOffset, - IN UINTN FieldSize, - IN UINT64 Value - ); - -EFI_STATUS -EFIAPI -VirtioPciGetDeviceFeatures ( - IN VIRTIO_DEVICE_PROTOCOL *This, - OUT UINT64 *DeviceFeatures - ); - -EFI_STATUS -EFIAPI -VirtioPciGetQueueSize ( - IN VIRTIO_DEVICE_PROTOCOL *This, - OUT UINT16 *QueueNumMax - ); - -EFI_STATUS -EFIAPI -VirtioPciSetQueueAlignment ( - VIRTIO_DEVICE_PROTOCOL *This, - UINT32 Alignment - ); - -EFI_STATUS -EFIAPI -VirtioPciSetPageSize ( - VIRTIO_DEVICE_PROTOCOL *This, - UINT32 PageSize - ); - -EFI_STATUS -EFIAPI -VirtioPciGetDeviceStatus ( - IN VIRTIO_DEVICE_PROTOCOL *This, - OUT UINT8 *DeviceStatus - ); - -EFI_STATUS -EFIAPI -VirtioPciSetGuestFeatures ( - IN VIRTIO_DEVICE_PROTOCOL *This, - IN UINT64 Features - ); - -EFI_STATUS -EFIAPI -VirtioPciSetQueueAddress ( - IN VIRTIO_DEVICE_PROTOCOL *This, - IN VRING *Ring - ); - -EFI_STATUS -EFIAPI -VirtioPciSetQueueSel ( - VIRTIO_DEVICE_PROTOCOL *This, - UINT16 Sel - ); - -EFI_STATUS -EFIAPI -VirtioPciSetQueueNotify ( - VIRTIO_DEVICE_PROTOCOL *This, - UINT16 Index - ); - -EFI_STATUS -EFIAPI -VirtioPciSetQueueSize ( - VIRTIO_DEVICE_PROTOCOL *This, - UINT16 Size - ); - -EFI_STATUS -EFIAPI -VirtioPciSetDeviceStatus ( - VIRTIO_DEVICE_PROTOCOL *This, - UINT8 DeviceStatus - ); - -#endif // _VIRTIO_PCI_DEVICE_DXE_H_ diff --git a/OvmfPkg/VirtioPciDeviceDxe/VirtioPciDeviceDxe.inf b/OvmfPkg/VirtioPciDeviceDxe/VirtioPciDeviceDxe.inf deleted file mode 100644 index 4b5d1a493e..0000000000 --- a/OvmfPkg/VirtioPciDeviceDxe/VirtioPciDeviceDxe.inf +++ /dev/null @@ -1,43 +0,0 @@ -## @file -# This driver produces the VirtIo Device Protocol instances for VirtIo PCI -# Device -# -# Copyright (C) 2013, ARM Ltd -# -# This program and the accompanying materials are licensed and made available -# under the terms and conditions of the BSD License which accompanies this -# distribution. The full text of the license may be found at -# http://opensource.org/licenses/bsd-license.php -# -# THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, WITHOUT -# WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. -# -## - -[Defines] - INF_VERSION = 0x00010006 - BASE_NAME = VirtioPciDeviceDxe - FILE_GUID = 83dd3b39-7caf-4fac-a542-e050b767e3a7 - MODULE_TYPE = UEFI_DRIVER - VERSION_STRING = 1.0 - ENTRY_POINT = VirtioPciDeviceEntryPoint - -[Sources] - VirtioPciDevice.c - VirtioPciFunctions.c - -[Packages] - MdePkg/MdePkg.dec - OvmfPkg/OvmfPkg.dec - -[LibraryClasses] - BaseMemoryLib - DebugLib - MemoryAllocationLib - UefiBootServicesTableLib - UefiDriverEntryPoint - UefiLib - -[Protocols] - gEfiPciIoProtocolGuid ## TO_START - gVirtioDeviceProtocolGuid ## BY_START diff --git a/OvmfPkg/VirtioPciDeviceDxe/VirtioPciFunctions.c b/OvmfPkg/VirtioPciDeviceDxe/VirtioPciFunctions.c deleted file mode 100644 index 243aa14c24..0000000000 --- a/OvmfPkg/VirtioPciDeviceDxe/VirtioPciFunctions.c +++ /dev/null @@ -1,273 +0,0 @@ -/** @file - - This driver produces Virtio Device Protocol instances for Virtio PCI devices. - - Copyright (C) 2012, Red Hat, Inc. - Copyright (c) 2012, Intel Corporation. All rights reserved.
- Copyright (C) 2013, ARM Ltd. - - This program and the accompanying materials are licensed and made available - under the terms and conditions of the BSD License which accompanies this - distribution. The full text of the license may be found at - http://opensource.org/licenses/bsd-license.php - - THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, WITHOUT - WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. - -**/ -#include -#include -#include -#include -#include -#include "VirtioPciDevice.h" - -/** - - Read a word from Region 0 of the device specified by VirtIo Device protocol. - - The function implements the ReadDevice protocol member of - VIRTIO_DEVICE_PROTOCOL. - - @param[in] This VirtIo Device protocol. - - @param[in] FieldOffset Source offset. - - @param[in] FieldSize Source field size, must be in { 1, 2, 4, 8 }. - - @param[in] BufferSize Number of bytes available in the target buffer. Must - equal FieldSize. - - @param[out] Buffer Target buffer. - - - @return Status code returned by PciIo->Io.Read(). - -**/ -EFI_STATUS -EFIAPI -VirtioPciDeviceRead ( - IN VIRTIO_DEVICE_PROTOCOL *This, - IN UINTN FieldOffset, - IN UINTN FieldSize, - IN UINTN BufferSize, - OUT VOID *Buffer - ) -{ - VIRTIO_PCI_DEVICE *Dev; - - Dev = VIRTIO_PCI_DEVICE_FROM_VIRTIO_DEVICE (This); - - return VirtioPciIoRead (Dev, - Dev->DeviceSpecificConfigurationOffset + FieldOffset, - FieldSize, BufferSize, Buffer); -} - -/** - - Write a word into Region 0 of the device specified by VirtIo Device protocol. - - @param[in] This VirtIo Device protocol. - - @param[in] FieldOffset Destination offset. - - @param[in] FieldSize Destination field size, must be in { 1, 2, 4, 8 }. - - @param[in] Value Little endian value to write, converted to UINT64. - The least significant FieldSize bytes will be used. - - - @return Status code returned by PciIo->Io.Write(). - -**/ -EFI_STATUS -EFIAPI -VirtioPciDeviceWrite ( - IN VIRTIO_DEVICE_PROTOCOL *This, - IN UINTN FieldOffset, - IN UINTN FieldSize, - IN UINT64 Value - ) -{ - VIRTIO_PCI_DEVICE *Dev; - - Dev = VIRTIO_PCI_DEVICE_FROM_VIRTIO_DEVICE (This); - - return VirtioPciIoWrite (Dev, - Dev->DeviceSpecificConfigurationOffset + FieldOffset, FieldSize, Value); -} - -EFI_STATUS -EFIAPI -VirtioPciGetDeviceFeatures ( - IN VIRTIO_DEVICE_PROTOCOL *This, - OUT UINT64 *DeviceFeatures - ) -{ - VIRTIO_PCI_DEVICE *Dev; - EFI_STATUS Status; - UINT32 Features32; - - if (DeviceFeatures == NULL) { - return EFI_INVALID_PARAMETER; - } - - Dev = VIRTIO_PCI_DEVICE_FROM_VIRTIO_DEVICE (This); - - Status = VirtioPciIoRead (Dev, VIRTIO_PCI_OFFSET_DEVICE_FEATURES, - sizeof (UINT32), sizeof (UINT32), &Features32); - if (!EFI_ERROR (Status)) { - *DeviceFeatures = Features32; - } - return Status; -} - -EFI_STATUS -EFIAPI -VirtioPciGetQueueSize ( - IN VIRTIO_DEVICE_PROTOCOL *This, - OUT UINT16 *QueueNumMax - ) -{ - VIRTIO_PCI_DEVICE *Dev; - - if (QueueNumMax == NULL) { - return EFI_INVALID_PARAMETER; - } - - Dev = VIRTIO_PCI_DEVICE_FROM_VIRTIO_DEVICE (This); - - return VirtioPciIoRead (Dev, VIRTIO_PCI_OFFSET_QUEUE_SIZE, sizeof (UINT16), - sizeof (UINT16), QueueNumMax); -} - -EFI_STATUS -EFIAPI -VirtioPciGetDeviceStatus ( - IN VIRTIO_DEVICE_PROTOCOL *This, - OUT UINT8 *DeviceStatus - ) -{ - VIRTIO_PCI_DEVICE *Dev; - - if (DeviceStatus == NULL) { - return EFI_INVALID_PARAMETER; - } - - Dev = VIRTIO_PCI_DEVICE_FROM_VIRTIO_DEVICE (This); - - return VirtioPciIoRead (Dev, VIRTIO_PCI_OFFSET_QUEUE_DEVICE_STATUS, - sizeof (UINT8), sizeof (UINT8), DeviceStatus); -} - -EFI_STATUS -EFIAPI -VirtioPciSetGuestFeatures ( - IN VIRTIO_DEVICE_PROTOCOL *This, - IN UINT64 Features - ) -{ - VIRTIO_PCI_DEVICE *Dev; - - Dev = VIRTIO_PCI_DEVICE_FROM_VIRTIO_DEVICE (This); - - if (Features > MAX_UINT32) { - return EFI_UNSUPPORTED; - } - return VirtioPciIoWrite (Dev, VIRTIO_PCI_OFFSET_GUEST_FEATURES, - sizeof (UINT32), Features); -} - -EFI_STATUS -EFIAPI -VirtioPciSetQueueAddress ( - IN VIRTIO_DEVICE_PROTOCOL *This, - IN VRING *Ring - ) -{ - VIRTIO_PCI_DEVICE *Dev; - - Dev = VIRTIO_PCI_DEVICE_FROM_VIRTIO_DEVICE (This); - - return VirtioPciIoWrite (Dev, VIRTIO_PCI_OFFSET_QUEUE_ADDRESS, sizeof (UINT32), - (UINT32)((UINTN)Ring->Base >> EFI_PAGE_SHIFT)); -} - -EFI_STATUS -EFIAPI -VirtioPciSetQueueSel ( - VIRTIO_DEVICE_PROTOCOL *This, - UINT16 Sel - ) -{ - VIRTIO_PCI_DEVICE *Dev; - - Dev = VIRTIO_PCI_DEVICE_FROM_VIRTIO_DEVICE (This); - - return VirtioPciIoWrite (Dev, VIRTIO_PCI_OFFSET_QUEUE_SELECT, sizeof (UINT16), - Sel); -} - -EFI_STATUS -EFIAPI -VirtioPciSetQueueAlignment ( - VIRTIO_DEVICE_PROTOCOL *This, - UINT32 Alignment - ) -{ - return EFI_SUCCESS; -} - -EFI_STATUS -EFIAPI -VirtioPciSetPageSize ( - VIRTIO_DEVICE_PROTOCOL *This, - UINT32 PageSize - ) -{ - return (PageSize == EFI_PAGE_SIZE) ? EFI_SUCCESS : EFI_UNSUPPORTED; -} - -EFI_STATUS -EFIAPI -VirtioPciSetQueueNotify ( - VIRTIO_DEVICE_PROTOCOL *This, - UINT16 Index - ) -{ - VIRTIO_PCI_DEVICE *Dev; - - Dev = VIRTIO_PCI_DEVICE_FROM_VIRTIO_DEVICE (This); - - return VirtioPciIoWrite (Dev, VIRTIO_PCI_OFFSET_QUEUE_NOTIFY, sizeof (UINT16), - Index); -} - -EFI_STATUS -EFIAPI -VirtioPciSetQueueSize ( - VIRTIO_DEVICE_PROTOCOL *This, - UINT16 Size - ) -{ - // - // This function is only applicable in Virtio-MMIO. - // (The QueueSize field is read-only in Virtio proper (PCI)) - // - return EFI_SUCCESS; -} - -EFI_STATUS -EFIAPI -VirtioPciSetDeviceStatus ( - VIRTIO_DEVICE_PROTOCOL *This, - UINT8 DeviceStatus - ) -{ - VIRTIO_PCI_DEVICE *Dev; - - Dev = VIRTIO_PCI_DEVICE_FROM_VIRTIO_DEVICE (This); - - return VirtioPciIoWrite (Dev, VIRTIO_PCI_OFFSET_QUEUE_DEVICE_STATUS, - sizeof (UINT8), DeviceStatus); -} diff --git a/OvmfPkg/VirtioRngDxe/VirtioRng.c b/OvmfPkg/VirtioRngDxe/VirtioRng.c deleted file mode 100644 index 1a186d0408..0000000000 --- a/OvmfPkg/VirtioRngDxe/VirtioRng.c +++ /dev/null @@ -1,666 +0,0 @@ -/** @file - - This driver produces EFI_RNG_PROTOCOL instances for virtio-rng devices. - - The implementation is based on OvmfPkg/VirtioScsiDxe/VirtioScsi.c - - Copyright (C) 2012, Red Hat, Inc. - Copyright (c) 2012 - 2014, Intel Corporation. All rights reserved.
- - This driver: - - Copyright (C) 2016, Linaro Ltd. - - This program and the accompanying materials are licensed and made available - under the terms and conditions of the BSD License which accompanies this - distribution. The full text of the license may be found at - http://opensource.org/licenses/bsd-license.php - - THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, WITHOUT - WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. - -**/ - -#include -#include -#include -#include -#include -#include - -#include "VirtioRng.h" - -/** - Returns information about the random number generation implementation. - - @param[in] This A pointer to the EFI_RNG_PROTOCOL - instance. - @param[in,out] RNGAlgorithmListSize On input, the size in bytes of - RNGAlgorithmList. - On output with a return code of - EFI_SUCCESS, the size in bytes of the - data returned in RNGAlgorithmList. On - output with a return code of - EFI_BUFFER_TOO_SMALL, the size of - RNGAlgorithmList required to obtain the - list. - @param[out] RNGAlgorithmList A caller-allocated memory buffer filled - by the driver with one EFI_RNG_ALGORITHM - element for each supported RNG algorithm. - The list must not change across multiple - calls to the same driver. The first - algorithm in the list is the default - algorithm for the driver. - - @retval EFI_SUCCESS The RNG algorithm list was returned - successfully. - @retval EFI_UNSUPPORTED The services is not supported by this - driver. - @retval EFI_DEVICE_ERROR The list of algorithms could not be - retrieved due to a hardware or firmware - error. - @retval EFI_INVALID_PARAMETER One or more of the parameters are - incorrect. - @retval EFI_BUFFER_TOO_SMALL The buffer RNGAlgorithmList is too small - to hold the result. - -**/ -STATIC -EFI_STATUS -EFIAPI -VirtioRngGetInfo ( - IN EFI_RNG_PROTOCOL *This, - IN OUT UINTN *RNGAlgorithmListSize, - OUT EFI_RNG_ALGORITHM *RNGAlgorithmList - ) -{ - if (This == NULL || RNGAlgorithmListSize == NULL) { - return EFI_INVALID_PARAMETER; - } - - if (*RNGAlgorithmListSize < sizeof (EFI_RNG_ALGORITHM)) { - *RNGAlgorithmListSize = sizeof (EFI_RNG_ALGORITHM); - return EFI_BUFFER_TOO_SMALL; - } - - if (RNGAlgorithmList == NULL) { - return EFI_INVALID_PARAMETER; - } - - *RNGAlgorithmListSize = sizeof (EFI_RNG_ALGORITHM); - CopyGuid (RNGAlgorithmList, &gEfiRngAlgorithmRaw); - - return EFI_SUCCESS; -} - -/** - Produces and returns an RNG value using either the default or specified RNG - algorithm. - - @param[in] This A pointer to the EFI_RNG_PROTOCOL - instance. - @param[in] RNGAlgorithm A pointer to the EFI_RNG_ALGORITHM that - identifies the RNG algorithm to use. May - be NULL in which case the function will - use its default RNG algorithm. - @param[in] RNGValueLength The length in bytes of the memory buffer - pointed to by RNGValue. The driver shall - return exactly this numbers of bytes. - @param[out] RNGValue A caller-allocated memory buffer filled - by the driver with the resulting RNG - value. - - @retval EFI_SUCCESS The RNG value was returned successfully. - @retval EFI_UNSUPPORTED The algorithm specified by RNGAlgorithm - is not supported by this driver. - @retval EFI_DEVICE_ERROR An RNG value could not be retrieved due - to a hardware or firmware error. - @retval EFI_NOT_READY There is not enough random data available - to satisfy the length requested by - RNGValueLength. - @retval EFI_INVALID_PARAMETER RNGValue is NULL or RNGValueLength is - zero. - -**/ -STATIC -EFI_STATUS -EFIAPI -VirtioRngGetRNG ( - IN EFI_RNG_PROTOCOL *This, - IN EFI_RNG_ALGORITHM *RNGAlgorithm, OPTIONAL - IN UINTN RNGValueLength, - OUT UINT8 *RNGValue - ) -{ - VIRTIO_RNG_DEV *Dev; - DESC_INDICES Indices; - volatile UINT8 *Buffer; - UINTN Index; - UINT32 Len; - UINT32 BufferSize; - EFI_STATUS Status; - - if (This == NULL || RNGValueLength == 0 || RNGValue == NULL) { - return EFI_INVALID_PARAMETER; - } - - // - // We only support the raw algorithm, so reject requests for anything else - // - if (RNGAlgorithm != NULL && - !CompareGuid (RNGAlgorithm, &gEfiRngAlgorithmRaw)) { - return EFI_UNSUPPORTED; - } - - Buffer = (volatile UINT8 *)AllocatePool (RNGValueLength); - if (Buffer == NULL) { - return EFI_DEVICE_ERROR; - } - - Dev = VIRTIO_ENTROPY_SOURCE_FROM_RNG (This); - - // - // The Virtio RNG device may return less data than we asked it to, and can - // only return MAX_UINT32 bytes per invocation. So loop as long as needed to - // get all the entropy we were asked for. - // - for (Index = 0; Index < RNGValueLength; Index += Len) { - BufferSize = (UINT32)MIN (RNGValueLength - Index, (UINTN)MAX_UINT32); - - VirtioPrepare (&Dev->Ring, &Indices); - VirtioAppendDesc (&Dev->Ring, - (UINTN)Buffer + Index, - BufferSize, - VRING_DESC_F_WRITE, - &Indices); - - if (VirtioFlush (Dev->VirtIo, 0, &Dev->Ring, &Indices, &Len) != - EFI_SUCCESS) { - Status = EFI_DEVICE_ERROR; - goto FreeBuffer; - } - ASSERT (Len > 0); - ASSERT (Len <= BufferSize); - } - - for (Index = 0; Index < RNGValueLength; Index++) { - RNGValue[Index] = Buffer[Index]; - } - Status = EFI_SUCCESS; - -FreeBuffer: - FreePool ((VOID *)Buffer); - return Status; -} - -STATIC -EFI_STATUS -EFIAPI -VirtioRngInit ( - IN OUT VIRTIO_RNG_DEV *Dev - ) -{ - UINT8 NextDevStat; - EFI_STATUS Status; - UINT16 QueueSize; - UINT64 Features; - - // - // Execute virtio-0.9.5, 2.2.1 Device Initialization Sequence. - // - NextDevStat = 0; // step 1 -- reset device - Status = Dev->VirtIo->SetDeviceStatus (Dev->VirtIo, NextDevStat); - if (EFI_ERROR (Status)) { - goto Failed; - } - - NextDevStat |= VSTAT_ACK; // step 2 -- acknowledge device presence - Status = Dev->VirtIo->SetDeviceStatus (Dev->VirtIo, NextDevStat); - if (EFI_ERROR (Status)) { - goto Failed; - } - - NextDevStat |= VSTAT_DRIVER; // step 3 -- we know how to drive it - Status = Dev->VirtIo->SetDeviceStatus (Dev->VirtIo, NextDevStat); - if (EFI_ERROR (Status)) { - goto Failed; - } - - // - // Set Page Size - MMIO VirtIo Specific - // - Status = Dev->VirtIo->SetPageSize (Dev->VirtIo, EFI_PAGE_SIZE); - if (EFI_ERROR (Status)) { - goto Failed; - } - - // - // step 4a -- retrieve and validate features - // - Status = Dev->VirtIo->GetDeviceFeatures (Dev->VirtIo, &Features); - if (EFI_ERROR (Status)) { - goto Failed; - } - - Features &= VIRTIO_F_VERSION_1; - - // - // In virtio-1.0, feature negotiation is expected to complete before queue - // discovery, and the device can also reject the selected set of features. - // - if (Dev->VirtIo->Revision >= VIRTIO_SPEC_REVISION (1, 0, 0)) { - Status = Virtio10WriteFeatures (Dev->VirtIo, Features, &NextDevStat); - if (EFI_ERROR (Status)) { - goto Failed; - } - } - - // - // step 4b -- allocate request virtqueue, just use #0 - // - Status = Dev->VirtIo->SetQueueSel (Dev->VirtIo, 0); - if (EFI_ERROR (Status)) { - goto Failed; - } - Status = Dev->VirtIo->GetQueueNumMax (Dev->VirtIo, &QueueSize); - if (EFI_ERROR (Status)) { - goto Failed; - } - - // - // VirtioRngGetRNG() uses one descriptor - // - if (QueueSize < 1) { - Status = EFI_UNSUPPORTED; - goto Failed; - } - - Status = VirtioRingInit (QueueSize, &Dev->Ring); - if (EFI_ERROR (Status)) { - goto Failed; - } - - // - // Additional steps for MMIO: align the queue appropriately, and set the - // size. If anything fails from here on, we must release the ring resources. - // - Status = Dev->VirtIo->SetQueueNum (Dev->VirtIo, QueueSize); - if (EFI_ERROR (Status)) { - goto ReleaseQueue; - } - - Status = Dev->VirtIo->SetQueueAlign (Dev->VirtIo, EFI_PAGE_SIZE); - if (EFI_ERROR (Status)) { - goto ReleaseQueue; - } - - // - // step 4c -- Report GPFN (guest-physical frame number) of queue. - // - Status = Dev->VirtIo->SetQueueAddress (Dev->VirtIo, &Dev->Ring); - if (EFI_ERROR (Status)) { - goto ReleaseQueue; - } - - // - // step 5 -- Report understood features and guest-tuneables. - // - if (Dev->VirtIo->Revision < VIRTIO_SPEC_REVISION (1, 0, 0)) { - Features &= ~(UINT64)VIRTIO_F_VERSION_1; - Status = Dev->VirtIo->SetGuestFeatures (Dev->VirtIo, Features); - if (EFI_ERROR (Status)) { - goto ReleaseQueue; - } - } - - // - // step 6 -- initialization complete - // - NextDevStat |= VSTAT_DRIVER_OK; - Status = Dev->VirtIo->SetDeviceStatus (Dev->VirtIo, NextDevStat); - if (EFI_ERROR (Status)) { - goto ReleaseQueue; - } - - // - // populate the exported interface's attributes - // - Dev->Rng.GetInfo = VirtioRngGetInfo; - Dev->Rng.GetRNG = VirtioRngGetRNG; - - 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. VirtIo access failure here should not mask the original error. - // - NextDevStat |= VSTAT_FAILED; - Dev->VirtIo->SetDeviceStatus (Dev->VirtIo, NextDevStat); - - return Status; // reached only via Failed above -} - - -STATIC -VOID -EFIAPI -VirtioRngUninit ( - IN OUT VIRTIO_RNG_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. - // - Dev->VirtIo->SetDeviceStatus (Dev->VirtIo, 0); - VirtioRingUninit (&Dev->Ring); -} - -// -// Event notification function enqueued by ExitBootServices(). -// - -STATIC -VOID -EFIAPI -VirtioRngExitBoot ( - IN EFI_EVENT Event, - IN VOID *Context - ) -{ - VIRTIO_RNG_DEV *Dev; - - // - // Reset the device. This causes the hypervisor to forget about the virtio - // ring. - // - // We allocated said ring in EfiBootServicesData type memory, and code - // executing after ExitBootServices() is permitted to overwrite it. - // - Dev = Context; - Dev->VirtIo->SetDeviceStatus (Dev->VirtIo, 0); -} - - -// -// 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() -// - UEFI Spec 2.3.1 + Errata C -// - 6.3 Protocol Handler Services -// - -STATIC -EFI_STATUS -EFIAPI -VirtioRngDriverBindingSupported ( - IN EFI_DRIVER_BINDING_PROTOCOL *This, - IN EFI_HANDLE DeviceHandle, - IN EFI_DEVICE_PATH_PROTOCOL *RemainingDevicePath - ) -{ - EFI_STATUS Status; - VIRTIO_DEVICE_PROTOCOL *VirtIo; - - // - // Attempt to open the device with the VirtIo set of interfaces. On success, - // the protocol is "instantiated" for the VirtIo device. Covers duplicate - // open attempts (EFI_ALREADY_STARTED). - // - Status = gBS->OpenProtocol ( - DeviceHandle, // candidate device - &gVirtioDeviceProtocolGuid, // for generic VirtIo access - (VOID **)&VirtIo, // handle to instantiate - This->DriverBindingHandle, // requestor driver identity - DeviceHandle, // ControllerHandle, according to - // the UEFI Driver Model - EFI_OPEN_PROTOCOL_BY_DRIVER // get exclusive VirtIo access to - // the device; to be released - ); - if (EFI_ERROR (Status)) { - return Status; - } - - if (VirtIo->SubSystemDeviceId != VIRTIO_SUBSYSTEM_ENTROPY_SOURCE) { - Status = EFI_UNSUPPORTED; - } - - // - // We needed VirtIo access only transitorily, to see whether we support the - // device or not. - // - gBS->CloseProtocol (DeviceHandle, &gVirtioDeviceProtocolGuid, - This->DriverBindingHandle, DeviceHandle); - return Status; -} - -STATIC -EFI_STATUS -EFIAPI -VirtioRngDriverBindingStart ( - IN EFI_DRIVER_BINDING_PROTOCOL *This, - IN EFI_HANDLE DeviceHandle, - IN EFI_DEVICE_PATH_PROTOCOL *RemainingDevicePath - ) -{ - VIRTIO_RNG_DEV *Dev; - EFI_STATUS Status; - - Dev = (VIRTIO_RNG_DEV *) AllocateZeroPool (sizeof *Dev); - if (Dev == NULL) { - return EFI_OUT_OF_RESOURCES; - } - - Status = gBS->OpenProtocol (DeviceHandle, &gVirtioDeviceProtocolGuid, - (VOID **)&Dev->VirtIo, This->DriverBindingHandle, - DeviceHandle, EFI_OPEN_PROTOCOL_BY_DRIVER); - if (EFI_ERROR (Status)) { - goto FreeVirtioRng; - } - - // - // VirtIo access granted, configure virtio-rng device. - // - Status = VirtioRngInit (Dev); - if (EFI_ERROR (Status)) { - goto CloseVirtIo; - } - - Status = gBS->CreateEvent (EVT_SIGNAL_EXIT_BOOT_SERVICES, TPL_CALLBACK, - &VirtioRngExitBoot, Dev, &Dev->ExitBoot); - if (EFI_ERROR (Status)) { - goto UninitDev; - } - - // - // Setup complete, attempt to export the driver instance's EFI_RNG_PROTOCOL - // interface. - // - Dev->Signature = VIRTIO_RNG_SIG; - Status = gBS->InstallProtocolInterface (&DeviceHandle, - &gEfiRngProtocolGuid, EFI_NATIVE_INTERFACE, - &Dev->Rng); - if (EFI_ERROR (Status)) { - goto CloseExitBoot; - } - - return EFI_SUCCESS; - -CloseExitBoot: - gBS->CloseEvent (Dev->ExitBoot); - -UninitDev: - VirtioRngUninit (Dev); - -CloseVirtIo: - gBS->CloseProtocol (DeviceHandle, &gVirtioDeviceProtocolGuid, - This->DriverBindingHandle, DeviceHandle); - -FreeVirtioRng: - FreePool (Dev); - - return Status; -} - - -STATIC -EFI_STATUS -EFIAPI -VirtioRngDriverBindingStop ( - IN EFI_DRIVER_BINDING_PROTOCOL *This, - IN EFI_HANDLE DeviceHandle, - IN UINTN NumberOfChildren, - IN EFI_HANDLE *ChildHandleBuffer - ) -{ - EFI_STATUS Status; - EFI_RNG_PROTOCOL *Rng; - VIRTIO_RNG_DEV *Dev; - - Status = gBS->OpenProtocol ( - DeviceHandle, // candidate device - &gEfiRngProtocolGuid, // retrieve the RNG iface - (VOID **)&Rng, // 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_ENTROPY_SOURCE_FROM_RNG (Rng); - - // - // Handle Stop() requests for in-use driver instances gracefully. - // - Status = gBS->UninstallProtocolInterface (DeviceHandle, - &gEfiRngProtocolGuid, &Dev->Rng); - if (EFI_ERROR (Status)) { - return Status; - } - - gBS->CloseEvent (Dev->ExitBoot); - - VirtioRngUninit (Dev); - - gBS->CloseProtocol (DeviceHandle, &gVirtioDeviceProtocolGuid, - 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 = { - &VirtioRngDriverBindingSupported, - &VirtioRngDriverBindingStart, - &VirtioRngDriverBindingStop, - 0x10, // Version, must be in [0x10 .. 0xFFFFFFEF] for IHV-developed drivers - NULL, // ImageHandle, to be overwritten by - // EfiLibInstallDriverBindingComponentName2() in VirtioRngEntryPoint() - NULL // DriverBindingHandle, ditto -}; - - -// -// The purpose of the following scaffolding (EFI_COMPONENT_NAME_PROTOCOL and -// EFI_COMPONENT_NAME2_PROTOCOL implementation) is to format the driver's name -// in English, for display on standard console devices. This is recommended for -// UEFI drivers that follow the UEFI Driver Model. Refer to the Driver Writer's -// Guide for UEFI 2.3.1 v1.01, 11 UEFI Driver and Controller Names. -// - -STATIC -EFI_UNICODE_STRING_TABLE mDriverNameTable[] = { - { "eng;en", L"Virtio Random Number Generator Driver" }, - { NULL, NULL } -}; - -STATIC -EFI_COMPONENT_NAME_PROTOCOL gComponentName; - -STATIC -EFI_STATUS -EFIAPI -VirtioRngGetDriverName ( - IN EFI_COMPONENT_NAME_PROTOCOL *This, - IN CHAR8 *Language, - OUT CHAR16 **DriverName - ) -{ - return LookupUnicodeString2 ( - Language, - This->SupportedLanguages, - mDriverNameTable, - DriverName, - (BOOLEAN)(This == &gComponentName) // Iso639Language - ); -} - -STATIC -EFI_STATUS -EFIAPI -VirtioRngGetDeviceName ( - 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 = { - &VirtioRngGetDriverName, - &VirtioRngGetDeviceName, - "eng" // SupportedLanguages, ISO 639-2 language codes -}; - -STATIC -EFI_COMPONENT_NAME2_PROTOCOL gComponentName2 = { - (EFI_COMPONENT_NAME2_GET_DRIVER_NAME) &VirtioRngGetDriverName, - (EFI_COMPONENT_NAME2_GET_CONTROLLER_NAME) &VirtioRngGetDeviceName, - "en" // SupportedLanguages, RFC 4646 language codes -}; - - -// -// Entry point of this driver. -// -EFI_STATUS -EFIAPI -VirtioRngEntryPoint ( - IN EFI_HANDLE ImageHandle, - IN EFI_SYSTEM_TABLE *SystemTable - ) -{ - return EfiLibInstallDriverBindingComponentName2 ( - ImageHandle, - SystemTable, - &gDriverBinding, - ImageHandle, - &gComponentName, - &gComponentName2 - ); -} diff --git a/OvmfPkg/VirtioRngDxe/VirtioRng.h b/OvmfPkg/VirtioRngDxe/VirtioRng.h deleted file mode 100644 index 998f9fae48..0000000000 --- a/OvmfPkg/VirtioRngDxe/VirtioRng.h +++ /dev/null @@ -1,46 +0,0 @@ -/** @file - - Private definitions of the VirtioRng RNG driver - - Copyright (C) 2016, Linaro Ltd. - - This program and the accompanying materials are licensed and made available - under the terms and conditions of the BSD License which accompanies this - distribution. The full text of the license may be found at - http://opensource.org/licenses/bsd-license.php - - THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, WITHOUT - WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. - -**/ - -#ifndef _VIRTIO_RNG_DXE_H_ -#define _VIRTIO_RNG_DXE_H_ - -#include -#include -#include - -#include - -#define VIRTIO_RNG_SIG SIGNATURE_32 ('V', 'R', 'N', 'G') - -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 - VIRTIO_DEVICE_PROTOCOL *VirtIo; // DriverBindingStart 0 - EFI_EVENT ExitBoot; // DriverBindingStart 0 - VRING Ring; // VirtioRingInit 2 - EFI_RNG_PROTOCOL Rng; // VirtioRngInit 1 -} VIRTIO_RNG_DEV; - -#define VIRTIO_ENTROPY_SOURCE_FROM_RNG(RngPointer) \ - CR (RngPointer, VIRTIO_RNG_DEV, Rng, VIRTIO_RNG_SIG) - -#endif diff --git a/OvmfPkg/VirtioRngDxe/VirtioRng.inf b/OvmfPkg/VirtioRngDxe/VirtioRng.inf deleted file mode 100644 index 471beb37bc..0000000000 --- a/OvmfPkg/VirtioRngDxe/VirtioRng.inf +++ /dev/null @@ -1,45 +0,0 @@ -## @file -# This driver produces EFI_RNG_PROTOCOL instances for virtio-rng devices. -# -# Copyright (C) 2016, Linaro Ltd. -# -# This program and the accompanying materials are licensed and made available -# under the terms and conditions of the BSD License which accompanies this -# distribution. The full text of the license may be found at -# http://opensource.org/licenses/bsd-license.php -# -# THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, WITHOUT -# WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. -# -## - -[Defines] - INF_VERSION = 0x00010005 - BASE_NAME = VirtioRngDxe - FILE_GUID = 58E26F0D-CBAC-4BBA-B70F-18221415665A - MODULE_TYPE = UEFI_DRIVER - VERSION_STRING = 1.0 - ENTRY_POINT = VirtioRngEntryPoint - -[Sources] - VirtioRng.c - -[Packages] - MdePkg/MdePkg.dec - OvmfPkg/OvmfPkg.dec - -[LibraryClasses] - BaseMemoryLib - DebugLib - MemoryAllocationLib - UefiBootServicesTableLib - UefiDriverEntryPoint - UefiLib - VirtioLib - -[Protocols] - gEfiRngProtocolGuid ## BY_START - gVirtioDeviceProtocolGuid ## TO_START - -[Guids] - gEfiRngAlgorithmRaw diff --git a/OvmfPkg/VirtioScsiDxe/VirtioScsi.c b/OvmfPkg/VirtioScsiDxe/VirtioScsi.c deleted file mode 100644 index c080404330..0000000000 --- a/OvmfPkg/VirtioScsiDxe/VirtioScsi.c +++ /dev/null @@ -1,1276 +0,0 @@ -/** @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 - 2014, Intel Corporation. All rights reserved.
- - This program and the accompanying materials are licensed and made available - under the terms and conditions of the BSD License which accompanies this - distribution. The full text of the license may be found at - http://opensource.org/licenses/bsd-license.php - - THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, WITHOUT - WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. - -**/ - -#include -#include -#include -#include -#include -#include -#include - -#include "VirtioScsi.h" - -/** - - Convenience macros to read and write configuration elements of the - virtio-scsi VirtIo device. - - 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. - - @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 Virtio->WriteDevice() / Virtio->ReadDevice(). - -**/ - -#define VIRTIO_CFG_WRITE(Dev, Field, Value) ((Dev)->VirtIo->WriteDevice ( \ - (Dev)->VirtIo, \ - OFFSET_OF_VSCSI (Field), \ - SIZE_OF_VSCSI (Field), \ - (Value) \ - )) - -#define VIRTIO_CFG_READ(Dev, Field, Pointer) ((Dev)->VirtIo->ReadDevice ( \ - (Dev)->VirtIo, \ - 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) (((UINT32)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; - - ZeroMem ((VOID*) &Request, sizeof (Request)); - ZeroMem ((VOID*) &Response, sizeof (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->VirtIo, VIRTIO_SCSI_REQUEST_QUEUE, &Dev->Ring, - &Indices, NULL) != 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; - - UINT64 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 = Dev->VirtIo->SetDeviceStatus (Dev->VirtIo, NextDevStat); - if (EFI_ERROR (Status)) { - goto Failed; - } - - NextDevStat |= VSTAT_ACK; // step 2 -- acknowledge device presence - Status = Dev->VirtIo->SetDeviceStatus (Dev->VirtIo, NextDevStat); - if (EFI_ERROR (Status)) { - goto Failed; - } - - NextDevStat |= VSTAT_DRIVER; // step 3 -- we know how to drive it - Status = Dev->VirtIo->SetDeviceStatus (Dev->VirtIo, NextDevStat); - if (EFI_ERROR (Status)) { - goto Failed; - } - - // - // Set Page Size - MMIO VirtIo Specific - // - Status = Dev->VirtIo->SetPageSize (Dev->VirtIo, EFI_PAGE_SIZE); - if (EFI_ERROR (Status)) { - goto Failed; - } - - // - // step 4a -- retrieve and validate features - // - Status = Dev->VirtIo->GetDeviceFeatures (Dev->VirtIo, &Features); - if (EFI_ERROR (Status)) { - goto Failed; - } - Dev->InOutSupported = (BOOLEAN) ((Features & VIRTIO_SCSI_F_INOUT) != 0); - - Status = VIRTIO_CFG_READ (Dev, MaxChannel, &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, NumQueues, &NumQueues); - if (EFI_ERROR (Status)) { - goto Failed; - } - if (NumQueues < 1) { - Status = EFI_UNSUPPORTED; - goto Failed; - } - - Status = VIRTIO_CFG_READ (Dev, MaxTarget, &Dev->MaxTarget); - if (EFI_ERROR (Status)) { - goto Failed; - } - if (Dev->MaxTarget > PcdGet16 (PcdVirtioScsiMaxTargetLimit)) { - Dev->MaxTarget = PcdGet16 (PcdVirtioScsiMaxTargetLimit); - } - - Status = VIRTIO_CFG_READ (Dev, MaxLun, &Dev->MaxLun); - if (EFI_ERROR (Status)) { - goto Failed; - } - if (Dev->MaxLun > PcdGet32 (PcdVirtioScsiMaxLunLimit)) { - Dev->MaxLun = PcdGet32 (PcdVirtioScsiMaxLunLimit); - } - - Status = VIRTIO_CFG_READ (Dev, MaxSectors, &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; - } - - Features &= VIRTIO_SCSI_F_INOUT | VIRTIO_F_VERSION_1; - - // - // In virtio-1.0, feature negotiation is expected to complete before queue - // discovery, and the device can also reject the selected set of features. - // - if (Dev->VirtIo->Revision >= VIRTIO_SPEC_REVISION (1, 0, 0)) { - Status = Virtio10WriteFeatures (Dev->VirtIo, Features, &NextDevStat); - if (EFI_ERROR (Status)) { - goto Failed; - } - } - - // - // step 4b -- allocate request virtqueue - // - Status = Dev->VirtIo->SetQueueSel (Dev->VirtIo, VIRTIO_SCSI_REQUEST_QUEUE); - if (EFI_ERROR (Status)) { - goto Failed; - } - Status = Dev->VirtIo->GetQueueNumMax (Dev->VirtIo, &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; - } - - // - // Additional steps for MMIO: align the queue appropriately, and set the - // size. If anything fails from here on, we must release the ring resources. - // - Status = Dev->VirtIo->SetQueueNum (Dev->VirtIo, QueueSize); - if (EFI_ERROR (Status)) { - goto ReleaseQueue; - } - - Status = Dev->VirtIo->SetQueueAlign (Dev->VirtIo, EFI_PAGE_SIZE); - if (EFI_ERROR (Status)) { - goto ReleaseQueue; - } - - // - // step 4c -- Report GPFN (guest-physical frame number) of queue. - // - Status = Dev->VirtIo->SetQueueAddress (Dev->VirtIo, &Dev->Ring); - if (EFI_ERROR (Status)) { - goto ReleaseQueue; - } - - // - // step 5 -- Report understood features and guest-tuneables. - // - if (Dev->VirtIo->Revision < VIRTIO_SPEC_REVISION (1, 0, 0)) { - Features &= ~(UINT64)VIRTIO_F_VERSION_1; - Status = Dev->VirtIo->SetGuestFeatures (Dev->VirtIo, Features); - 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, CdbSize, VIRTIO_SCSI_CDB_SIZE); - if (EFI_ERROR (Status)) { - goto ReleaseQueue; - } - Status = VIRTIO_CFG_WRITE (Dev, SenseSize, VIRTIO_SCSI_SENSE_SIZE); - if (EFI_ERROR (Status)) { - goto ReleaseQueue; - } - - // - // step 6 -- initialization complete - // - NextDevStat |= VSTAT_DRIVER_OK; - Status = Dev->VirtIo->SetDeviceStatus (Dev->VirtIo, 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. VirtIo access failure here should not mask the original error. - // - NextDevStat |= VSTAT_FAILED; - Dev->VirtIo->SetDeviceStatus (Dev->VirtIo, 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. - // - Dev->VirtIo->SetDeviceStatus (Dev->VirtIo, 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); -} - - -// -// Event notification function enqueued by ExitBootServices(). -// - -STATIC -VOID -EFIAPI -VirtioScsiExitBoot ( - IN EFI_EVENT Event, - IN VOID *Context - ) -{ - VSCSI_DEV *Dev; - - // - // Reset the device. This causes the hypervisor to forget about the virtio - // ring. - // - // We allocated said ring in EfiBootServicesData type memory, and code - // executing after ExitBootServices() is permitted to overwrite it. - // - Dev = Context; - Dev->VirtIo->SetDeviceStatus (Dev->VirtIo, 0); -} - - -// -// 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() -// - UEFI Spec 2.3.1 + Errata C -// - 6.3 Protocol Handler Services -// - -EFI_STATUS -EFIAPI -VirtioScsiDriverBindingSupported ( - IN EFI_DRIVER_BINDING_PROTOCOL *This, - IN EFI_HANDLE DeviceHandle, - IN EFI_DEVICE_PATH_PROTOCOL *RemainingDevicePath - ) -{ - EFI_STATUS Status; - VIRTIO_DEVICE_PROTOCOL *VirtIo; - - // - // Attempt to open the device with the VirtIo set of interfaces. On success, - // the protocol is "instantiated" for the VirtIo device. Covers duplicate open - // attempts (EFI_ALREADY_STARTED). - // - Status = gBS->OpenProtocol ( - DeviceHandle, // candidate device - &gVirtioDeviceProtocolGuid, // for generic VirtIo access - (VOID **)&VirtIo, // handle to instantiate - This->DriverBindingHandle, // requestor driver identity - DeviceHandle, // ControllerHandle, according to - // the UEFI Driver Model - EFI_OPEN_PROTOCOL_BY_DRIVER // get exclusive VirtIo access to - // the device; to be released - ); - if (EFI_ERROR (Status)) { - return Status; - } - - if (VirtIo->SubSystemDeviceId != VIRTIO_SUBSYSTEM_SCSI_HOST) { - Status = EFI_UNSUPPORTED; - } - - // - // We needed VirtIo access only transitorily, to see whether we support the - // device or not. - // - gBS->CloseProtocol (DeviceHandle, &gVirtioDeviceProtocolGuid, - 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, &gVirtioDeviceProtocolGuid, - (VOID **)&Dev->VirtIo, This->DriverBindingHandle, - DeviceHandle, EFI_OPEN_PROTOCOL_BY_DRIVER); - if (EFI_ERROR (Status)) { - goto FreeVirtioScsi; - } - - // - // VirtIo access granted, configure virtio-scsi device. - // - Status = VirtioScsiInit (Dev); - if (EFI_ERROR (Status)) { - goto CloseVirtIo; - } - - Status = gBS->CreateEvent (EVT_SIGNAL_EXIT_BOOT_SERVICES, TPL_CALLBACK, - &VirtioScsiExitBoot, Dev, &Dev->ExitBoot); - if (EFI_ERROR (Status)) { - goto UninitDev; - } - - // - // 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 CloseExitBoot; - } - - return EFI_SUCCESS; - -CloseExitBoot: - gBS->CloseEvent (Dev->ExitBoot); - -UninitDev: - VirtioScsiUninit (Dev); - -CloseVirtIo: - gBS->CloseProtocol (DeviceHandle, &gVirtioDeviceProtocolGuid, - 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; - } - - gBS->CloseEvent (Dev->ExitBoot); - - VirtioScsiUninit (Dev); - - gBS->CloseProtocol (DeviceHandle, &gVirtioDeviceProtocolGuid, - 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/OvmfPkg/VirtioScsiDxe/VirtioScsi.h b/OvmfPkg/VirtioScsiDxe/VirtioScsi.h deleted file mode 100644 index 6d00567e8c..0000000000 --- a/OvmfPkg/VirtioScsiDxe/VirtioScsi.h +++ /dev/null @@ -1,208 +0,0 @@ -/** @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 -#include -#include - -#include - - -// -// 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 accommodate 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 - VIRTIO_DEVICE_PROTOCOL *VirtIo; // DriverBindingStart 0 - EFI_EVENT ExitBoot; // 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/OvmfPkg/VirtioScsiDxe/VirtioScsi.inf b/OvmfPkg/VirtioScsiDxe/VirtioScsi.inf deleted file mode 100644 index 7558112393..0000000000 --- a/OvmfPkg/VirtioScsiDxe/VirtioScsi.inf +++ /dev/null @@ -1,47 +0,0 @@ -## @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 - gVirtioDeviceProtocolGuid ## TO_START - -[Pcd] - gUefiOvmfPkgTokenSpaceGuid.PcdVirtioScsiMaxTargetLimit ## CONSUMES - gUefiOvmfPkgTokenSpaceGuid.PcdVirtioScsiMaxLunLimit ## CONSUMES diff --git a/OvmfPkg/XenBusDxe/ComponentName.c b/OvmfPkg/XenBusDxe/ComponentName.c deleted file mode 100644 index 3f2dd406c7..0000000000 --- a/OvmfPkg/XenBusDxe/ComponentName.c +++ /dev/null @@ -1,174 +0,0 @@ -/** @file - Component Name functions implementation for XenBus Bus driver. - - Copyright (C) 2014, Citrix Ltd. - - This program and the accompanying materials - are licensed and made available under the terms and conditions of the BSD License - which accompanies this distribution. The full text of the license may be found at - http://opensource.org/licenses/bsd-license.php - - THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, - WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. - -**/ - -#include "XenBusDxe.h" - -/// -/// Component Name Protocol instance -/// -GLOBAL_REMOVE_IF_UNREFERENCED -EFI_COMPONENT_NAME_PROTOCOL gXenBusDxeComponentName = { - (EFI_COMPONENT_NAME_GET_DRIVER_NAME) XenBusDxeComponentNameGetDriverName, - (EFI_COMPONENT_NAME_GET_CONTROLLER_NAME)XenBusDxeComponentNameGetControllerName, - "eng" -}; - -/// -/// Component Name 2 Protocol instance -/// -GLOBAL_REMOVE_IF_UNREFERENCED -EFI_COMPONENT_NAME2_PROTOCOL gXenBusDxeComponentName2 = { - XenBusDxeComponentNameGetDriverName, - XenBusDxeComponentNameGetControllerName, - "en" -}; - -/// -/// Table of driver names -/// -GLOBAL_REMOVE_IF_UNREFERENCED -EFI_UNICODE_STRING_TABLE mXenBusDxeDriverNameTable[] = { - { "eng;en", (CHAR16 *)L"XenBus Bus Driver" }, - { NULL, NULL } -}; - -/// -/// Table of controller names -/// -GLOBAL_REMOVE_IF_UNREFERENCED -EFI_UNICODE_STRING_TABLE mXenBusDxeControllerNameTable[] = { - { "eng;en", (CHAR16 *)L"XenBus Controller" }, - { NULL, NULL } -}; - -/** - Retrieves a Unicode string that is the user-readable name of the EFI Driver. - - @param This A pointer to the EFI_COMPONENT_NAME_PROTOCOL instance. - @param Language A pointer to a three-character ISO 639-2 language identifier. - This is the language of the driver name that that the caller - is requesting, and it must match one of the languages specified - in SupportedLanguages. The number of languages supported by a - driver is up to the driver writer. - @param DriverName A pointer to the Unicode string to return. This Unicode string - is the name of the driver specified by This in the language - specified by Language. - - @retval EFI_SUCCESS The Unicode string for the Driver specified by This - and the language specified by Language was returned - in DriverName. - @retval EFI_INVALID_PARAMETER Language is NULL. - @retval EFI_INVALID_PARAMETER DriverName is NULL. - @retval EFI_UNSUPPORTED The driver specified by This does not support the - language specified by Language. - -**/ -EFI_STATUS -EFIAPI -XenBusDxeComponentNameGetDriverName ( - IN EFI_COMPONENT_NAME2_PROTOCOL *This, - IN CHAR8 *Language, - OUT CHAR16 **DriverName - ) -{ - return LookupUnicodeString2 ( - Language, - This->SupportedLanguages, - mXenBusDxeDriverNameTable, - DriverName, - (BOOLEAN)(This != &gXenBusDxeComponentName2) - ); -} - -/** - Retrieves a Unicode string that is the user readable name of the controller - that is being managed by an EFI Driver. - - @param This A pointer to the EFI_COMPONENT_NAME_PROTOCOL instance. - @param ControllerHandle The handle of a controller that the driver specified by - This is managing. This handle specifies the controller - whose name is to be returned. - @param ChildHandle The handle of the child controller to retrieve the name - of. This is an optional parameter that may be NULL. It - will be NULL for device drivers. It will also be NULL - for a bus drivers that wish to retrieve the name of the - bus controller. It will not be NULL for a bus driver - that wishes to retrieve the name of a child controller. - @param Language A pointer to a three character ISO 639-2 language - identifier. This is the language of the controller name - that the caller is requesting, and it must match one - of the languages specified in SupportedLanguages. The - number of languages supported by a driver is up to the - driver writer. - @param ControllerName A pointer to the Unicode string to return. This Unicode - string is the name of the controller specified by - ControllerHandle and ChildHandle in the language specified - by Language, from the point of view of the driver specified - by This. - - @retval EFI_SUCCESS The Unicode string for the user-readable name in the - language specified by Language for the driver - specified by This was returned in DriverName. - @retval EFI_INVALID_PARAMETER ControllerHandle is NULL. - @retval EFI_INVALID_PARAMETER ChildHandle is not NULL and it is not a valid EFI_HANDLE. - @retval EFI_INVALID_PARAMETER Language is NULL. - @retval EFI_INVALID_PARAMETER ControllerName is NULL. - @retval EFI_UNSUPPORTED The driver specified by This is not currently managing - the controller specified by ControllerHandle and - ChildHandle. - @retval EFI_UNSUPPORTED The driver specified by This does not support the - language specified by Language. - -**/ -EFI_STATUS -EFIAPI -XenBusDxeComponentNameGetControllerName ( - IN EFI_COMPONENT_NAME2_PROTOCOL *This, - IN EFI_HANDLE ControllerHandle, - IN EFI_HANDLE ChildHandle OPTIONAL, - IN CHAR8 *Language, - OUT CHAR16 **ControllerName - ) -{ - EFI_STATUS Status; - - if (ChildHandle != NULL) { - // TODO Get controller name for a child. - return EFI_UNSUPPORTED; - } - - // - // Make sure this driver is currently managing ControllerHandle - // - Status = EfiTestManagedDevice ( - ControllerHandle, - gXenBusDxeDriverBinding.DriverBindingHandle, - &gXenIoProtocolGuid - ); - if (EFI_ERROR (Status)) { - return Status; - } - - // - // Lookup name of controller specified by ControllerHandle - // - return LookupUnicodeString2 ( - Language, - This->SupportedLanguages, - mXenBusDxeControllerNameTable, - ControllerName, - (BOOLEAN)(This != &gXenBusDxeComponentName2) - ); -} diff --git a/OvmfPkg/XenBusDxe/ComponentName.h b/OvmfPkg/XenBusDxe/ComponentName.h deleted file mode 100644 index 42c5b57ebb..0000000000 --- a/OvmfPkg/XenBusDxe/ComponentName.h +++ /dev/null @@ -1,94 +0,0 @@ -/** @file - Component Name functions declaration for XenBus Bus driver. - - Copyright (C) 2014, Citrix Ltd. - - This program and the accompanying materials - are licensed and made available under the terms and conditions of the BSD License - which accompanies this distribution. The full text of the license may be found at - http://opensource.org/licenses/bsd-license.php - - THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, - WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. - -**/ - -/** - Retrieves a Unicode string that is the user-readable name of the EFI Driver. - - @param This A pointer to the EFI_COMPONENT_NAME_PROTOCOL instance. - @param Language A pointer to a three-character ISO 639-2 language identifier. - This is the language of the driver name that that the caller - is requesting, and it must match one of the languages specified - in SupportedLanguages. The number of languages supported by a - driver is up to the driver writer. - @param DriverName A pointer to the Unicode string to return. This Unicode string - is the name of the driver specified by This in the language - specified by Language. - - @retval EFI_SUCCESS The Unicode string for the Driver specified by This - and the language specified by Language was returned - in DriverName. - @retval EFI_INVALID_PARAMETER Language is NULL. - @retval EFI_INVALID_PARAMETER DriverName is NULL. - @retval EFI_UNSUPPORTED The driver specified by This does not support the - language specified by Language. - -**/ -EFI_STATUS -EFIAPI -XenBusDxeComponentNameGetDriverName ( - IN EFI_COMPONENT_NAME2_PROTOCOL *This, - IN CHAR8 *Language, - OUT CHAR16 **DriverName - ); - -/** - Retrieves a Unicode string that is the user readable name of the controller - that is being managed by an EFI Driver. - - @param This A pointer to the EFI_COMPONENT_NAME_PROTOCOL instance. - @param ControllerHandle The handle of a controller that the driver specified by - This is managing. This handle specifies the controller - whose name is to be returned. - @param ChildHandle The handle of the child controller to retrieve the name - of. This is an optional parameter that may be NULL. It - will be NULL for device drivers. It will also be NULL - for a bus drivers that wish to retrieve the name of the - bus controller. It will not be NULL for a bus driver - that wishes to retrieve the name of a child controller. - @param Language A pointer to a three character ISO 639-2 language - identifier. This is the language of the controller name - that the caller is requesting, and it must match one - of the languages specified in SupportedLanguages. The - number of languages supported by a driver is up to the - driver writer. - @param ControllerName A pointer to the Unicode string to return. This Unicode - string is the name of the controller specified by - ControllerHandle and ChildHandle in the language specified - by Language, from the point of view of the driver specified - by This. - - @retval EFI_SUCCESS The Unicode string for the user-readable name in the - language specified by Language for the driver - specified by This was returned in DriverName. - @retval EFI_INVALID_PARAMETER ControllerHandle is NULL. - @retval EFI_INVALID_PARAMETER ChildHandle is not NULL and it is not a valid EFI_HANDLE. - @retval EFI_INVALID_PARAMETER Language is NULL. - @retval EFI_INVALID_PARAMETER ControllerName is NULL. - @retval EFI_UNSUPPORTED The driver specified by This is not currently managing - the controller specified by ControllerHandle and - ChildHandle. - @retval EFI_UNSUPPORTED The driver specified by This does not support the - language specified by Language. - -**/ -EFI_STATUS -EFIAPI -XenBusDxeComponentNameGetControllerName ( - IN EFI_COMPONENT_NAME2_PROTOCOL *This, - IN EFI_HANDLE ControllerHandle, - IN EFI_HANDLE ChildHandle OPTIONAL, - IN CHAR8 *Language, - OUT CHAR16 **ControllerName - ); diff --git a/OvmfPkg/XenBusDxe/DriverBinding.h b/OvmfPkg/XenBusDxe/DriverBinding.h deleted file mode 100644 index 693b5c0f50..0000000000 --- a/OvmfPkg/XenBusDxe/DriverBinding.h +++ /dev/null @@ -1,128 +0,0 @@ -/** @file - Driver Binding functions declaration for XenBus Bus driver. - - Copyright (C) 2014, Citrix Ltd. - - This program and the accompanying materials - are licensed and made available under the terms and conditions of the BSD License - which accompanies this distribution. The full text of the license may be found at - http://opensource.org/licenses/bsd-license.php - - THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, - WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. - -**/ - -/** - Tests to see if this driver supports a given controller. If a child device is provided, - it further tests to see if this driver supports creating a handle for the specified child device. - - @param[in] This A pointer to the EFI_DRIVER_BINDING_PROTOCOL instance. - @param[in] ControllerHandle The handle of the controller to test. This handle - must support a protocol interface that supplies - an I/O abstraction to the driver. - @param[in] RemainingDevicePath A pointer to the remaining portion of a device path. This - parameter is ignored by device drivers, and is optional for bus - drivers. For bus drivers, if this parameter is not NULL, then - the bus driver must determine if the bus controller specified - by ControllerHandle and the child controller specified - by RemainingDevicePath are both supported by this - bus driver. - - @retval EFI_SUCCESS The device specified by ControllerHandle and - RemainingDevicePath is supported by the driver specified by This. - @retval EFI_ALREADY_STARTED The device specified by ControllerHandle and - RemainingDevicePath is already being managed by the driver - specified by This. - @retval EFI_ACCESS_DENIED The device specified by ControllerHandle and - RemainingDevicePath is already being managed by a different - driver or an application that requires exclusive access. - Currently not implemented. - @retval EFI_UNSUPPORTED The device specified by ControllerHandle and - RemainingDevicePath is not supported by the driver specified by This. -**/ -EFI_STATUS -EFIAPI -XenBusDxeDriverBindingSupported ( - IN EFI_DRIVER_BINDING_PROTOCOL *This, - IN EFI_HANDLE ControllerHandle, - IN EFI_DEVICE_PATH_PROTOCOL *RemainingDevicePath OPTIONAL - ); - -/** - Starts a device controller or a bus controller. - - The Start() function is designed to be invoked from the EFI boot service ConnectController(). - As a result, much of the error checking on the parameters to Start() has been moved into this - common boot service. It is legal to call Start() from other locations, - but the following calling restrictions must be followed, or the system behavior will not be deterministic. - 1. ControllerHandle must be a valid EFI_HANDLE. - 2. If RemainingDevicePath is not NULL, then it must be a pointer to a naturally aligned - EFI_DEVICE_PATH_PROTOCOL. - 3. Prior to calling Start(), the Supported() function for the driver specified by This must - have been called with the same calling parameters, and Supported() must have returned EFI_SUCCESS. - - @param[in] This A pointer to the EFI_DRIVER_BINDING_PROTOCOL instance. - @param[in] ControllerHandle The handle of the controller to start. This handle - must support a protocol interface that supplies - an I/O abstraction to the driver. - @param[in] RemainingDevicePath A pointer to the remaining portion of a device path. This - parameter is ignored by device drivers, and is optional for bus - drivers. For a bus driver, if this parameter is NULL, then handles - for all the children of Controller are created by this driver. - If this parameter is not NULL and the first Device Path Node is - not the End of Device Path Node, then only the handle for the - child device specified by the first Device Path Node of - RemainingDevicePath is created by this driver. - If the first Device Path Node of RemainingDevicePath is - the End of Device Path Node, no child handle is created by this - driver. - - @retval EFI_SUCCESS The device was started. - @retval EFI_DEVICE_ERROR The device could not be started due to a device error.Currently not implemented. - @retval EFI_OUT_OF_RESOURCES The request could not be completed due to a lack of resources. - @retval Others The driver failded to start the device. - -**/ -EFI_STATUS -EFIAPI -XenBusDxeDriverBindingStart ( - IN EFI_DRIVER_BINDING_PROTOCOL *This, - IN EFI_HANDLE ControllerHandle, - IN EFI_DEVICE_PATH_PROTOCOL *RemainingDevicePath OPTIONAL - ); - -/** - Stops a device controller or a bus controller. - - The Stop() function is designed to be invoked from the EFI boot service DisconnectController(). - As a result, much of the error checking on the parameters to Stop() has been moved - into this common boot service. It is legal to call Stop() from other locations, - but the following calling restrictions must be followed, or the system behavior will not be deterministic. - 1. ControllerHandle must be a valid EFI_HANDLE that was used on a previous call to this - same driver's Start() function. - 2. The first NumberOfChildren handles of ChildHandleBuffer must all be a valid - EFI_HANDLE. In addition, all of these handles must have been created in this driver's - Start() function, and the Start() function must have called OpenProtocol() on - ControllerHandle with an Attribute of EFI_OPEN_PROTOCOL_BY_CHILD_CONTROLLER. - - @param[in] This A pointer to the EFI_DRIVER_BINDING_PROTOCOL instance. - @param[in] ControllerHandle A handle to the device being stopped. The handle must - support a bus specific I/O protocol for the driver - to use to stop the device. - @param[in] NumberOfChildren The number of child device handles in ChildHandleBuffer. - @param[in] ChildHandleBuffer An array of child handles to be freed. May be NULL - if NumberOfChildren is 0. - - @retval EFI_SUCCESS The device was stopped. - @retval EFI_DEVICE_ERROR The device could not be stopped due to a device error. - -**/ -EFI_STATUS -EFIAPI -XenBusDxeDriverBindingStop ( - IN EFI_DRIVER_BINDING_PROTOCOL *This, - IN EFI_HANDLE ControllerHandle, - IN UINTN NumberOfChildren, - IN EFI_HANDLE *ChildHandleBuffer OPTIONAL - ); diff --git a/OvmfPkg/XenBusDxe/EventChannel.c b/OvmfPkg/XenBusDxe/EventChannel.c deleted file mode 100644 index 490ca58cb4..0000000000 --- a/OvmfPkg/XenBusDxe/EventChannel.c +++ /dev/null @@ -1,84 +0,0 @@ -/** @file - Event Channel function implementation. - - Event channel are use to notify of an event that happened in a shared - structure for example. - - Copyright (C) 2014, Citrix Ltd. - - This program and the accompanying materials - are licensed and made available under the terms and conditions of the BSD License - which accompanies this distribution. The full text of the license may be found at - http://opensource.org/licenses/bsd-license.php - - THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, - WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. - -**/ -#include "EventChannel.h" - -#include - -UINT32 -XenEventChannelNotify ( - IN XENBUS_DEVICE *Dev, - IN evtchn_port_t Port - ) -{ - INTN ReturnCode; - evtchn_send_t Send; - - Send.port = Port; - ReturnCode = XenHypercallEventChannelOp (EVTCHNOP_send, &Send); - return (UINT32)ReturnCode; -} - -UINT32 -EFIAPI -XenBusEventChannelAllocate ( - IN XENBUS_PROTOCOL *This, - IN domid_t DomainId, - OUT evtchn_port_t *Port - ) -{ - evtchn_alloc_unbound_t Parameter; - UINT32 ReturnCode; - - Parameter.dom = DOMID_SELF; - Parameter.remote_dom = DomainId; - ReturnCode = (UINT32)XenHypercallEventChannelOp ( - EVTCHNOP_alloc_unbound, - &Parameter); - if (ReturnCode != 0) { - DEBUG ((EFI_D_ERROR, "ERROR: alloc_unbound failed with rc=%d", ReturnCode)); - return ReturnCode; - } - *Port = Parameter.port; - return ReturnCode; -} - -UINT32 -EFIAPI -XenBusEventChannelNotify ( - IN XENBUS_PROTOCOL *This, - IN evtchn_port_t Port - ) -{ - XENBUS_PRIVATE_DATA *Private; - - Private = XENBUS_PRIVATE_DATA_FROM_THIS(This); - return XenEventChannelNotify (Private->Dev, Port); -} - -UINT32 -EFIAPI -XenBusEventChannelClose ( - IN XENBUS_PROTOCOL *This, - IN evtchn_port_t Port - ) -{ - evtchn_close_t Close; - - Close.port = Port; - return (UINT32)XenHypercallEventChannelOp (EVTCHNOP_close, &Close); -} diff --git a/OvmfPkg/XenBusDxe/EventChannel.h b/OvmfPkg/XenBusDxe/EventChannel.h deleted file mode 100644 index 4dcc20f73b..0000000000 --- a/OvmfPkg/XenBusDxe/EventChannel.h +++ /dev/null @@ -1,88 +0,0 @@ -/** @file - Event Channel function declaration. - - Copyright (C) 2014, Citrix Ltd. - - This program and the accompanying materials - are licensed and made available under the terms and conditions of the BSD License - which accompanies this distribution. The full text of the license may be found at - http://opensource.org/licenses/bsd-license.php - - THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, - WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. - -**/ -#ifndef __XENBUS_EVENT_CHANNEL_H -#define __XENBUS_EVENT_CHANNEL_H - -#include "XenBusDxe.h" - -#include - -/** - Send an event to the remote end of the channel whose local endpoint is Port. - - @param Dev A pointer to XENBUS_DEVICE. - @param Port The port to notify. - - @return Return 0 on success, or return the errno code from the hypercall. -**/ -UINT32 -XenEventChannelNotify ( - IN XENBUS_DEVICE *Dev, - IN evtchn_port_t Port - ); - -/* - * XenBus protocol - */ - -/** - Allocate a port that can be bind from domain DomainId. - - @param This A pointer to the XENBUS_PROTOCOL. - @param DomainId The domain ID that can bind the newly allocated port. - @param Port A pointer to a evtchn_port_t that will contain the newly - allocated port. - - @retval UINT32 The return value from the hypercall, 0 if success. -**/ -UINT32 -EFIAPI -XenBusEventChannelAllocate ( - IN XENBUS_PROTOCOL *This, - IN domid_t DomainId, - OUT evtchn_port_t *Port - ); - -/** - Send an event to the remote end of the channel whose local endpoint is Port. - - @param This A pointer to the XENBUS_PROTOCOL. - @param Port Local port to the the event from. - - @retval UINT32 The return value from the hypercall, 0 if success. -**/ -UINT32 -EFIAPI -XenBusEventChannelNotify ( - IN XENBUS_PROTOCOL *This, - IN evtchn_port_t Port - ); - -/** - Close a local event channel Port. - - @param This A pointer to the XENBUS_PROTOCOL. - @param Port The event channel to close. - - @retval UINT32 The return value from the hypercall, 0 if success. -**/ -UINT32 -EFIAPI -XenBusEventChannelClose ( - IN XENBUS_PROTOCOL *This, - IN evtchn_port_t Port - ); - -#endif diff --git a/OvmfPkg/XenBusDxe/GrantTable.c b/OvmfPkg/XenBusDxe/GrantTable.c deleted file mode 100644 index 90dec26ab0..0000000000 --- a/OvmfPkg/XenBusDxe/GrantTable.c +++ /dev/null @@ -1,221 +0,0 @@ -/** @file - Grant Table function implementation. - - Grant Table are used to grant access to certain page of the current - VM to an other VM. - - Author: Steven Smith (sos22@cam.ac.uk) - Changes: Grzegorz Milos (gm281@cam.ac.uk) - Copyright (C) 2006, Cambridge University - Copyright (C) 2014, Citrix Ltd. - - Redistribution and use in source and binary forms, with or without - modification, are permitted provided that the following conditions - are met: - 1. Redistributions of source code must retain the above copyright - notice, this list of conditions and the following disclaimer. - 2. Redistributions in binary form must reproduce the above copyright - notice, this list of conditions and the following disclaimer in the - documentation and/or other materials provided with the distribution. - - THIS SOFTWARE IS PROVIDED BY AUTHOR AND CONTRIBUTORS ``AS IS'' AND - ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - ARE DISCLAIMED. IN NO EVENT SHALL AUTHOR OR CONTRIBUTORS BE LIABLE - FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - SUCH DAMAGE. -**/ -#include "XenBusDxe.h" - -#include - -#include -#include - -#include "GrantTable.h" - -#define NR_RESERVED_ENTRIES 8 - -/* NR_GRANT_FRAMES must be less than or equal to that configured in Xen */ -#define NR_GRANT_FRAMES 4 -#define NR_GRANT_ENTRIES (NR_GRANT_FRAMES * EFI_PAGE_SIZE / sizeof(grant_entry_v1_t)) - -STATIC grant_entry_v1_t *GrantTable = NULL; -STATIC grant_ref_t GrantList[NR_GRANT_ENTRIES]; -STATIC EFI_LOCK mGrantListLock; -#ifdef GNT_DEBUG -STATIC BOOLEAN GrantInUseList[NR_GRANT_ENTRIES]; -#endif - -STATIC -VOID -XenGrantTablePutFreeEntry ( - grant_ref_t Ref - ) -{ - EfiAcquireLock (&mGrantListLock); -#ifdef GNT_DEBUG - ASSERT (GrantInUseList[Ref]); - GrantInUseList[Ref] = FALSE; -#endif - GrantList[Ref] = GrantList[0]; - GrantList[0] = Ref; - EfiReleaseLock (&mGrantListLock); -} - -STATIC -grant_ref_t -XenGrantTableGetFreeEntry ( - VOID - ) -{ - grant_ref_t Ref; - - EfiAcquireLock (&mGrantListLock); - Ref = GrantList[0]; - ASSERT (Ref >= NR_RESERVED_ENTRIES && Ref < NR_GRANT_ENTRIES); - GrantList[0] = GrantList[Ref]; -#ifdef GNT_DEBUG - ASSERT (!GrantInUseList[Ref]); - GrantInUseList[Ref] = TRUE; -#endif - EfiReleaseLock (&mGrantListLock); - return Ref; -} - -STATIC -grant_ref_t -XenGrantTableGrantAccess ( - IN domid_t DomainId, - IN UINTN Frame, - IN BOOLEAN ReadOnly - ) -{ - grant_ref_t Ref; - UINT16 Flags; - - ASSERT (GrantTable != NULL); - Ref = XenGrantTableGetFreeEntry (); - GrantTable[Ref].frame = (UINT32)Frame; - GrantTable[Ref].domid = DomainId; - MemoryFence (); - Flags = GTF_permit_access; - if (ReadOnly) { - Flags |= GTF_readonly; - } - GrantTable[Ref].flags = Flags; - - return Ref; -} - -STATIC -EFI_STATUS -XenGrantTableEndAccess ( - grant_ref_t Ref - ) -{ - UINT16 Flags, OldFlags; - - ASSERT (GrantTable != NULL); - ASSERT (Ref >= NR_RESERVED_ENTRIES && Ref < NR_GRANT_ENTRIES); - - OldFlags = GrantTable[Ref].flags; - do { - if ((Flags = OldFlags) & (GTF_reading | GTF_writing)) { - DEBUG ((EFI_D_WARN, "WARNING: g.e. still in use! (%x)\n", Flags)); - return EFI_NOT_READY; - } - OldFlags = InterlockedCompareExchange16 (&GrantTable[Ref].flags, Flags, 0); - } while (OldFlags != Flags); - - XenGrantTablePutFreeEntry (Ref); - return EFI_SUCCESS; -} - -VOID -XenGrantTableInit ( - IN XENBUS_DEVICE *Dev - ) -{ - xen_add_to_physmap_t Parameters; - INTN Index; - INTN ReturnCode; - -#ifdef GNT_DEBUG - SetMem(GrantInUseList, sizeof (GrantInUseList), 1); -#endif - EfiInitializeLock (&mGrantListLock, TPL_NOTIFY); - for (Index = NR_RESERVED_ENTRIES; Index < NR_GRANT_ENTRIES; Index++) { - XenGrantTablePutFreeEntry ((grant_ref_t)Index); - } - - GrantTable = (VOID*)(UINTN) Dev->XenIo->GrantTableAddress; - for (Index = 0; Index < NR_GRANT_FRAMES; Index++) { - Parameters.domid = DOMID_SELF; - Parameters.idx = Index; - Parameters.space = XENMAPSPACE_grant_table; - Parameters.gpfn = (xen_pfn_t) ((UINTN) GrantTable >> EFI_PAGE_SHIFT) + Index; - ReturnCode = XenHypercallMemoryOp (XENMEM_add_to_physmap, &Parameters); - if (ReturnCode != 0) { - DEBUG ((EFI_D_ERROR, - "Xen GrantTable, add_to_physmap hypercall error: %Ld\n", - (INT64)ReturnCode)); - } - } -} - -VOID -XenGrantTableDeinit ( - XENBUS_DEVICE *Dev - ) -{ - INTN ReturnCode, Index; - xen_remove_from_physmap_t Parameters; - - if (GrantTable == NULL) { - return; - } - - for (Index = NR_GRANT_FRAMES - 1; Index >= 0; Index--) { - Parameters.domid = DOMID_SELF; - Parameters.gpfn = (xen_pfn_t) ((UINTN) GrantTable >> EFI_PAGE_SHIFT) + Index; - DEBUG ((EFI_D_INFO, "Xen GrantTable, removing %Lx\n", - (UINT64)Parameters.gpfn)); - ReturnCode = XenHypercallMemoryOp (XENMEM_remove_from_physmap, &Parameters); - if (ReturnCode != 0) { - DEBUG ((EFI_D_ERROR, - "Xen GrantTable, remove_from_physmap hypercall error: %Ld\n", - (INT64)ReturnCode)); - } - } - GrantTable = NULL; -} - -EFI_STATUS -EFIAPI -XenBusGrantAccess ( - IN XENBUS_PROTOCOL *This, - IN domid_t DomainId, - IN UINTN Frame, // MFN - IN BOOLEAN ReadOnly, - OUT grant_ref_t *RefPtr - ) -{ - *RefPtr = XenGrantTableGrantAccess (DomainId, Frame, ReadOnly); - return EFI_SUCCESS; -} - -EFI_STATUS -EFIAPI -XenBusGrantEndAccess ( - IN XENBUS_PROTOCOL *This, - IN grant_ref_t Ref - ) -{ - return XenGrantTableEndAccess (Ref); -} diff --git a/OvmfPkg/XenBusDxe/GrantTable.h b/OvmfPkg/XenBusDxe/GrantTable.h deleted file mode 100644 index 28195b6e59..0000000000 --- a/OvmfPkg/XenBusDxe/GrantTable.h +++ /dev/null @@ -1,76 +0,0 @@ -/** @file - Grant Table function declaration. - - Grant Table are used to grant access to certain page of the current - VM to an other VM. - - Copyright (C) 2014, Citrix Ltd. - - This program and the accompanying materials - are licensed and made available under the terms and conditions of the BSD License - which accompanies this distribution. The full text of the license may be found at - http://opensource.org/licenses/bsd-license.php - - THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, - WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. - -**/ -#ifndef __GNTTAB_H__ -#define __GNTTAB_H__ - -#include - -/** - Initialize the Grant Table at the address MmioAddr. - - @param Dev A pointer to XENBUS_DEVICE. - @param MmioAddr An address where the grant table can be mapped into - the guest. -**/ -VOID -XenGrantTableInit ( - IN XENBUS_DEVICE *Dev - ); - -/** - Desinitilize the Grant Table. -**/ -VOID -XenGrantTableDeinit ( - IN XENBUS_DEVICE *Dev - ); - -/** - Grant access to the page Frame to the domain DomainId. - - @param This A pointer to XENBUS_PROTOCOL instance. - @param DomainId ID of the domain to grant acces to. - @param Frame Frame Number of the page to grant access to. - @param ReadOnly Provide read-only or read-write access. - @param RefPtr Reference number of the grant will be written to this pointer. -**/ -EFI_STATUS -EFIAPI -XenBusGrantAccess ( - IN XENBUS_PROTOCOL *This, - IN domid_t DomainId, - IN UINTN Frame, // MFN - IN BOOLEAN ReadOnly, - OUT grant_ref_t *RefPtr - ); - -/** - End access to grant Ref, previously return by XenBusGrantAccess. - - @param This A pointer to XENBUS_PROTOCOL instance. - @param Ref Reference numeber of a grant previously returned by - XenBusGrantAccess. -**/ -EFI_STATUS -EFIAPI -XenBusGrantEndAccess ( - IN XENBUS_PROTOCOL *This, - IN grant_ref_t Ref - ); - -#endif /* !__GNTTAB_H__ */ diff --git a/OvmfPkg/XenBusDxe/Helpers.c b/OvmfPkg/XenBusDxe/Helpers.c deleted file mode 100644 index b22f9c5b0d..0000000000 --- a/OvmfPkg/XenBusDxe/Helpers.c +++ /dev/null @@ -1,9 +0,0 @@ -#include "XenBusDxe.h" - -CHAR8* -AsciiStrDup ( - IN CONST CHAR8* Str - ) -{ - return AllocateCopyPool (AsciiStrSize (Str), Str); -} diff --git a/OvmfPkg/XenBusDxe/TestAndClearBit.c b/OvmfPkg/XenBusDxe/TestAndClearBit.c deleted file mode 100644 index ac01b3ce50..0000000000 --- a/OvmfPkg/XenBusDxe/TestAndClearBit.c +++ /dev/null @@ -1,46 +0,0 @@ -/** @file - Implementation of TestAndClearBit using compare-exchange primitive - - Copyright (C) 2015, Linaro Ltd. - Copyright (c) 2015, Intel Corporation. All rights reserved.
- - This program and the accompanying materials - are licensed and made available under the terms and conditions of the BSD License - which accompanies this distribution. The full text of the license may be found at - http://opensource.org/licenses/bsd-license.php - - THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, - WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. - -**/ - -#include -#include - -INT32 -EFIAPI -TestAndClearBit ( - IN INT32 Bit, - IN VOID *Address - ) -{ - UINT16 Word, Read; - UINT16 Mask; - - // - // Calculate the effective address relative to 'Address' based on the - // higher order bits of 'Bit'. Use signed shift instead of division to - // ensure we round towards -Inf, and end up with a positive shift in - // 'Bit', even if 'Bit' itself is negative. - // - Address = (VOID*)((UINT8*) Address + ((Bit >> 4) * sizeof(UINT16))); - Mask = 1U << (Bit & 15); - - for (Word = *(UINT16 *) Address; Word & Mask; Word = Read) { - Read = InterlockedCompareExchange16 (Address, Word, Word & ~Mask); - if (Read == Word) { - return 1; - } - } - return 0; -} diff --git a/OvmfPkg/XenBusDxe/XenBus.c b/OvmfPkg/XenBusDxe/XenBus.c deleted file mode 100644 index ee9526c332..0000000000 --- a/OvmfPkg/XenBusDxe/XenBus.c +++ /dev/null @@ -1,386 +0,0 @@ -/** @file - XenBus Bus driver implemtation. - - This file implement the necessary to discover and enumerate Xen PV devices - through XenStore. - - Copyright (C) 2010 Spectra Logic Corporation - Copyright (C) 2008 Doug Rabson - Copyright (C) 2005 Rusty Russell, IBM Corporation - Copyright (C) 2005 Mike Wray, Hewlett-Packard - Copyright (C) 2005 XenSource Ltd - Copyright (C) 2014, Citrix Ltd. - - This file may be distributed separately from the Linux kernel, or - incorporated into other software packages, subject to the following license: - - Permission is hereby granted, free of charge, to any person obtaining a copy - of this source file (the "Software"), to deal in the Software without - restriction, including without limitation the rights to use, copy, modify, - merge, publish, distribute, sublicense, and/or sell copies of the Software, - and to permit persons to whom the Software is furnished to do so, subject to - the following conditions: - - The above copyright notice and this permission notice shall be included in - all copies or substantial portions of the Software. - - THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING - FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS - IN THE SOFTWARE. -**/ - -#include - -#include "XenBus.h" -#include "GrantTable.h" -#include "XenStore.h" -#include "EventChannel.h" - -#include - -STATIC XENBUS_PRIVATE_DATA gXenBusPrivateData; - -STATIC XENBUS_DEVICE_PATH gXenBusDevicePathTemplate = { - { // Vendor - { // Vendor.Header - HARDWARE_DEVICE_PATH, // Vendor.Header.Type - HW_VENDOR_DP, // Vendor.Header.SubType - { - (UINT8) (sizeof (XENBUS_DEVICE_PATH)), // Vendor.Header.Length[0] - (UINT8) (sizeof (XENBUS_DEVICE_PATH) >> 8), // Vendor.Header.Length[1] - } - }, - XENBUS_PROTOCOL_GUID, // Vendor.Guid - }, - 0, // Type - 0 // DeviceId -}; - - -/** - Search our internal record of configured devices (not the XenStore) to - determine if the XenBus device indicated by Node is known to the system. - - @param Dev The XENBUS_DEVICE instance to search for device children. - @param Node The XenStore node path for the device to find. - - @return The XENBUS_PRIVATE_DATA of the found device if any, or NULL. - */ -STATIC -XENBUS_PRIVATE_DATA * -XenBusDeviceInitialized ( - IN XENBUS_DEVICE *Dev, - IN CONST CHAR8 *Node - ) -{ - LIST_ENTRY *Entry; - XENBUS_PRIVATE_DATA *Child; - XENBUS_PRIVATE_DATA *Result; - - if (IsListEmpty (&Dev->ChildList)) { - return NULL; - } - - Result = NULL; - for (Entry = GetFirstNode (&Dev->ChildList); - !IsNodeAtEnd (&Dev->ChildList, Entry); - Entry = GetNextNode (&Dev->ChildList, Entry)) { - Child = XENBUS_PRIVATE_DATA_FROM_LINK (Entry); - if (!AsciiStrCmp (Child->XenBusIo.Node, Node)) { - Result = Child; - break; - } - } - - return (Result); -} - -STATIC -XenbusState -XenBusReadDriverState ( - IN CONST CHAR8 *Path - ) -{ - XenbusState State; - CHAR8 *Ptr = NULL; - XENSTORE_STATUS Status; - - Status = XenStoreRead (XST_NIL, Path, "state", NULL, (VOID **)&Ptr); - if (Status != XENSTORE_STATUS_SUCCESS) { - State = XenbusStateClosed; - } else { - State = AsciiStrDecimalToUintn (Ptr); - } - - if (Ptr != NULL) { - FreePool (Ptr); - } - - return State; -} - -// -// Callers should ensure that they are only one calling XenBusAddDevice. -// -STATIC -EFI_STATUS -XenBusAddDevice ( - XENBUS_DEVICE *Dev, - CONST CHAR8 *Type, - CONST CHAR8 *Id) -{ - CHAR8 DevicePath[XENSTORE_ABS_PATH_MAX]; - XENSTORE_STATUS StatusXenStore; - XENBUS_PRIVATE_DATA *Private; - EFI_STATUS Status; - XENBUS_DEVICE_PATH *TempXenBusPath; - VOID *ChildXenIo; - - AsciiSPrint (DevicePath, sizeof (DevicePath), - "device/%a/%a", Type, Id); - - if (XenStorePathExists (XST_NIL, DevicePath, "")) { - XENBUS_PRIVATE_DATA *Child; - enum xenbus_state State; - CHAR8 *BackendPath; - - Child = XenBusDeviceInitialized (Dev, DevicePath); - if (Child != NULL) { - /* - * We are already tracking this node - */ - Status = EFI_SUCCESS; - goto out; - } - - State = XenBusReadDriverState (DevicePath); - if (State != XenbusStateInitialising) { - /* - * Device is not new, so ignore it. This can - * happen if a device is going away after - * switching to Closed. - */ - DEBUG ((EFI_D_INFO, "XenBus: Device %a ignored. " - "State %d\n", DevicePath, State)); - Status = EFI_SUCCESS; - goto out; - } - - StatusXenStore = XenStoreRead (XST_NIL, DevicePath, "backend", - NULL, (VOID **) &BackendPath); - if (StatusXenStore != XENSTORE_STATUS_SUCCESS) { - DEBUG ((EFI_D_ERROR, "xenbus: %a no backend path.\n", DevicePath)); - Status = EFI_NOT_FOUND; - goto out; - } - - Private = AllocateCopyPool (sizeof (*Private), &gXenBusPrivateData); - Private->XenBusIo.Type = AsciiStrDup (Type); - Private->XenBusIo.Node = AsciiStrDup (DevicePath); - Private->XenBusIo.Backend = BackendPath; - Private->XenBusIo.DeviceId = (UINT16)AsciiStrDecimalToUintn (Id); - Private->Dev = Dev; - - TempXenBusPath = AllocateCopyPool (sizeof (XENBUS_DEVICE_PATH), - &gXenBusDevicePathTemplate); - if (!AsciiStrCmp (Private->XenBusIo.Type, "vbd")) { - TempXenBusPath->Type = XENBUS_DEVICE_PATH_TYPE_VBD; - } - TempXenBusPath->DeviceId = Private->XenBusIo.DeviceId; - Private->DevicePath = (XENBUS_DEVICE_PATH *)AppendDevicePathNode ( - Dev->DevicePath, - &TempXenBusPath->Vendor.Header); - FreePool (TempXenBusPath); - - InsertTailList (&Dev->ChildList, &Private->Link); - - Status = gBS->InstallMultipleProtocolInterfaces ( - &Private->Handle, - &gEfiDevicePathProtocolGuid, Private->DevicePath, - &gXenBusProtocolGuid, &Private->XenBusIo, - NULL); - if (EFI_ERROR (Status)) { - goto ErrorInstallProtocol; - } - - Status = gBS->OpenProtocol (Dev->ControllerHandle, - &gXenIoProtocolGuid, - &ChildXenIo, Dev->This->DriverBindingHandle, - Private->Handle, - EFI_OPEN_PROTOCOL_BY_CHILD_CONTROLLER); - if (EFI_ERROR (Status)) { - DEBUG ((EFI_D_ERROR, "open by child controller fail (%r)\n", - Status)); - goto ErrorOpenProtocolByChild; - } - } else { - DEBUG ((EFI_D_ERROR, "XenBus: does not exist: %a\n", DevicePath)); - Status = EFI_NOT_FOUND; - } - - return Status; - -ErrorOpenProtocolByChild: - gBS->UninstallMultipleProtocolInterfaces ( - &Private->Handle, - &gEfiDevicePathProtocolGuid, Private->DevicePath, - &gXenBusProtocolGuid, &Private->XenBusIo, - NULL); -ErrorInstallProtocol: - RemoveEntryList (&Private->Link); - FreePool (Private->DevicePath); - FreePool ((VOID *) Private->XenBusIo.Backend); - FreePool ((VOID *) Private->XenBusIo.Node); - FreePool ((VOID *) Private->XenBusIo.Type); - FreePool (Private); -out: - return Status; -} - -/** - Enumerate all devices of the given type on this bus. - - @param Dev A XENBUS_DEVICE instance. - @param Type String indicating the device sub-tree (e.g. "vfb", "vif") - to enumerate. - - Devices that are found are been initialize via XenBusAddDevice (). - XenBusAddDevice () ignores duplicate detects and ignores duplicate devices, - so it can be called unconditionally for any device found in the XenStore. - */ -STATIC -VOID -XenBusEnumerateDeviceType ( - XENBUS_DEVICE *Dev, - CONST CHAR8 *Type - ) -{ - CONST CHAR8 **Directory; - UINTN Index; - UINT32 Count; - XENSTORE_STATUS Status; - - Status = XenStoreListDirectory (XST_NIL, - "device", Type, - &Count, &Directory); - if (Status != XENSTORE_STATUS_SUCCESS) { - return; - } - for (Index = 0; Index < Count; Index++) { - XenBusAddDevice (Dev, Type, Directory[Index]); - } - - FreePool ((VOID*)Directory); -} - - -/** - Enumerate the devices on a XenBus bus and install a XenBus Protocol instance. - - Caller should ensure that it is the only one to call this function. This - function cannot be called concurrently. - - @param Dev A XENBUS_DEVICE instance. - - @return On success, XENSTORE_STATUS_SUCCESS. Otherwise an errno value - indicating the type of failure. - */ -XENSTORE_STATUS -XenBusEnumerateBus ( - XENBUS_DEVICE *Dev - ) -{ - CONST CHAR8 **Types; - UINTN Index; - UINT32 Count; - XENSTORE_STATUS Status; - - Status = XenStoreListDirectory (XST_NIL, - "device", "", - &Count, &Types); - if (Status != XENSTORE_STATUS_SUCCESS) { - return Status; - } - - for (Index = 0; Index < Count; Index++) { - XenBusEnumerateDeviceType (Dev, Types[Index]); - } - - FreePool ((VOID*)Types); - - return XENSTORE_STATUS_SUCCESS; -} - -STATIC -XENSTORE_STATUS -EFIAPI -XenBusSetState ( - IN XENBUS_PROTOCOL *This, - IN CONST XENSTORE_TRANSACTION *Transaction, - IN enum xenbus_state NewState - ) -{ - enum xenbus_state CurrentState; - XENSTORE_STATUS Status; - CHAR8 *Temp; - - DEBUG ((EFI_D_INFO, "XenBus: Set state to %d\n", NewState)); - - Status = XenStoreRead (Transaction, This->Node, "state", NULL, (VOID **)&Temp); - if (Status != XENSTORE_STATUS_SUCCESS) { - goto Out; - } - CurrentState = AsciiStrDecimalToUintn (Temp); - FreePool (Temp); - if (CurrentState == NewState) { - goto Out; - } - - do { - Status = XenStoreSPrint (Transaction, This->Node, "state", "%d", NewState); - } while (Status == XENSTORE_STATUS_EAGAIN); - if (Status != XENSTORE_STATUS_SUCCESS) { - DEBUG ((EFI_D_ERROR, "XenBus: failed to write new state\n")); - goto Out; - } - DEBUG ((EFI_D_INFO, "XenBus: Set state to %d, done\n", NewState)); - -Out: - return Status; -} - -STATIC XENBUS_PRIVATE_DATA gXenBusPrivateData = { - XENBUS_PRIVATE_DATA_SIGNATURE, // Signature - { NULL, NULL }, // Link - NULL, // Handle - { // XenBusIo - XenBusXenStoreRead, // XenBusIo.XsRead - XenBusXenStoreBackendRead, // XenBusIo.XsBackendRead - XenBusXenStoreSPrint, // XenBusIo.XsPrintf - XenBusXenStoreRemove, // XenBusIo.XsRemove - XenBusXenStoreTransactionStart, // XenBusIo.XsTransactionStart - XenBusXenStoreTransactionEnd, // XenBusIo.XsTransactionEnd - XenBusSetState, // XenBusIo.SetState - XenBusGrantAccess, // XenBusIo.GrantAccess - XenBusGrantEndAccess, // XenBusIo.GrantEndAccess - XenBusEventChannelAllocate, // XenBusIo.EventChannelAllocate - XenBusEventChannelNotify, // XenBusIo.EventChannelNotify - XenBusEventChannelClose, // XenBusIo.EventChannelClose - XenBusRegisterWatch, // XenBusIo.RegisterWatch - XenBusRegisterWatchBackend, // XenBusIo.RegisterWatchBackend - XenBusUnregisterWatch, // XenBusIo.UnregisterWatch - XenBusWaitForWatch, // XenBusIo.WaitForWatch - - NULL, // XenBusIo.Type - 0, // XenBusIo.DeviceId - NULL, // XenBusIo.Node - NULL, // XenBusIo.Backend - }, - - NULL, // Dev - NULL // DevicePath -}; diff --git a/OvmfPkg/XenBusDxe/XenBus.h b/OvmfPkg/XenBusDxe/XenBus.h deleted file mode 100644 index e96439ab7b..0000000000 --- a/OvmfPkg/XenBusDxe/XenBus.h +++ /dev/null @@ -1,44 +0,0 @@ -/** @file - XenBus Bus driver declarations. - - Copyright (C) 2014, Citrix Ltd. - - This program and the accompanying materials - are licensed and made available under the terms and conditions of the BSD License - which accompanies this distribution. The full text of the license may be found at - http://opensource.org/licenses/bsd-license.php - - THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, - WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. - -**/ -#ifndef _XEN_XENBUS_XENBUSB_H -#define _XEN_XENBUS_XENBUSB_H - -#include "XenBusDxe.h" - -#define XENBUS_DEVICE_PATH_TYPE_VBD 0x1 -struct _XENBUS_DEVICE_PATH { - VENDOR_DEVICE_PATH Vendor; - UINT8 Type; - UINT16 DeviceId; -}; - - -/** - Perform XenBus bus enumeration and install protocol for children. - - Caller should ensure that it is the only one to call this function. This - function cannot be called concurrently. - - @param Dev A XENBUS_DEVICE instance. - - @return On success, XENSTORE_STATUS_SUCCESS. Otherwise an errno value - indicating the type of failure. -**/ -XENSTORE_STATUS -XenBusEnumerateBus ( - XENBUS_DEVICE *Dev - ); - -#endif /* _XEN_XENBUS_XENBUSB_H */ diff --git a/OvmfPkg/XenBusDxe/XenBusDxe.c b/OvmfPkg/XenBusDxe/XenBusDxe.c deleted file mode 100644 index 439b060ddc..0000000000 --- a/OvmfPkg/XenBusDxe/XenBusDxe.c +++ /dev/null @@ -1,492 +0,0 @@ -/** @file - This driver produces XenBus Protocol instances for each Xen PV devices. - - This XenBus bus driver will first initialize differente services in order to - enumerate the ParaVirtualized devices available. - - Those services are: - - HyperCall - - Event Channel - - Grant Table - - XenStore - - XenBus - - Copyright (C) 2014, Citrix Ltd. - - This program and the accompanying materials - are licensed and made available under the terms and conditions of the BSD License - which accompanies this distribution. The full text of the license may be found at - http://opensource.org/licenses/bsd-license.php - - THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, - WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. - -**/ - -#include -#include - -#include "XenBusDxe.h" - -#include "GrantTable.h" -#include "XenStore.h" -#include "XenBus.h" - -#include -#include - -/// -/// Driver Binding Protocol instance -/// -EFI_DRIVER_BINDING_PROTOCOL gXenBusDxeDriverBinding = { - XenBusDxeDriverBindingSupported, - XenBusDxeDriverBindingStart, - XenBusDxeDriverBindingStop, - XENBUS_DXE_VERSION, - NULL, - NULL -}; - - -STATIC EFI_LOCK mMyDeviceLock = EFI_INITIALIZE_LOCK_VARIABLE (TPL_CALLBACK); -STATIC XENBUS_DEVICE *mMyDevice = NULL; - -/** - Map the shared_info_t page into memory. - - @param Dev A XENBUS_DEVICE instance. - - @retval EFI_SUCCESS Dev->SharedInfo whill contain a pointer to - the shared info page - @retval EFI_LOAD_ERROR The shared info page could not be mapped. The - hypercall returned an error. -**/ -STATIC -EFI_STATUS -XenGetSharedInfoPage ( - IN OUT XENBUS_DEVICE *Dev - ) -{ - xen_add_to_physmap_t Parameter; - - ASSERT (Dev->SharedInfo == NULL); - - Parameter.domid = DOMID_SELF; - Parameter.space = XENMAPSPACE_shared_info; - Parameter.idx = 0; - - // - // using reserved page because the page is not released when Linux is - // starting because of the add_to_physmap. QEMU might try to access the - // page, and fail because it have no right to do so (segv). - // - Dev->SharedInfo = AllocateReservedPages (1); - Parameter.gpfn = (UINTN) Dev->SharedInfo >> EFI_PAGE_SHIFT; - if (XenHypercallMemoryOp (XENMEM_add_to_physmap, &Parameter) != 0) { - FreePages (Dev->SharedInfo, 1); - Dev->SharedInfo = NULL; - return EFI_LOAD_ERROR; - } - - return EFI_SUCCESS; -} - -/** - Unloads an image. - - @param ImageHandle Handle that identifies the image to be unloaded. - - @retval EFI_SUCCESS The image has been unloaded. - @retval EFI_INVALID_PARAMETER ImageHandle is not a valid image handle. - -**/ -EFI_STATUS -EFIAPI -XenBusDxeUnload ( - IN EFI_HANDLE ImageHandle - ) -{ - EFI_STATUS Status; - - EFI_HANDLE *HandleBuffer; - UINTN HandleCount; - UINTN Index; - - // - // Retrieve array of all handles in the handle database - // - Status = gBS->LocateHandleBuffer ( - AllHandles, - NULL, - NULL, - &HandleCount, - &HandleBuffer - ); - if (EFI_ERROR (Status)) { - return Status; - } - - // - // Disconnect the current driver from handles in the handle database - // - for (Index = 0; Index < HandleCount; Index++) { - gBS->DisconnectController (HandleBuffer[Index], gImageHandle, NULL); - } - - // - // Free the array of handles - // - FreePool (HandleBuffer); - - - // - // Uninstall protocols installed in the driver entry point - // - Status = gBS->UninstallMultipleProtocolInterfaces ( - ImageHandle, - &gEfiDriverBindingProtocolGuid, &gXenBusDxeDriverBinding, - &gEfiComponentNameProtocolGuid, &gXenBusDxeComponentName, - &gEfiComponentName2ProtocolGuid, &gXenBusDxeComponentName2, - NULL - ); - if (EFI_ERROR (Status)) { - return Status; - } - - return EFI_SUCCESS; -} - -/** - This is the declaration of an EFI image entry point. This entry point is - the same for UEFI Applications, UEFI OS Loaders, and UEFI Drivers including - both device drivers and bus drivers. - - @param ImageHandle The firmware allocated handle for the UEFI image. - @param SystemTable A pointer to the EFI System Table. - - @retval EFI_SUCCESS The operation completed successfully. - @retval EFI_ABORTED Xen hypercalls are not available. - @retval Others An unexpected error occurred. -**/ -EFI_STATUS -EFIAPI -XenBusDxeDriverEntryPoint ( - IN EFI_HANDLE ImageHandle, - IN EFI_SYSTEM_TABLE *SystemTable - ) -{ - EFI_STATUS Status; - - if (! XenHypercallIsAvailable ()) { - return EFI_ABORTED; - } - - // - // Install UEFI Driver Model protocol(s). - // - Status = EfiLibInstallDriverBindingComponentName2 ( - ImageHandle, - SystemTable, - &gXenBusDxeDriverBinding, - ImageHandle, - &gXenBusDxeComponentName, - &gXenBusDxeComponentName2 - ); - ASSERT_EFI_ERROR (Status); - - - return Status; -} - - -/** - Tests to see if this driver supports a given controller. If a child device is provided, - it further tests to see if this driver supports creating a handle for the specified child device. - - @param[in] This A pointer to the EFI_DRIVER_BINDING_PROTOCOL instance. - @param[in] ControllerHandle The handle of the controller to test. This handle - must support a protocol interface that supplies - an I/O abstraction to the driver. - @param[in] RemainingDevicePath A pointer to the remaining portion of a device path. This - parameter is ignored by device drivers, and is optional for bus - drivers. For bus drivers, if this parameter is not NULL, then - the bus driver must determine if the bus controller specified - by ControllerHandle and the child controller specified - by RemainingDevicePath are both supported by this - bus driver. - - @retval EFI_SUCCESS The device specified by ControllerHandle and - RemainingDevicePath is supported by the driver specified by This. - @retval EFI_ALREADY_STARTED The device specified by ControllerHandle and - RemainingDevicePath is already being managed by the driver - specified by This. - @retval EFI_ACCESS_DENIED The device specified by ControllerHandle and - RemainingDevicePath is already being managed by a different - driver or an application that requires exclusive access. - Currently not implemented. - @retval EFI_UNSUPPORTED The device specified by ControllerHandle and - RemainingDevicePath is not supported by the driver specified by This. -**/ -EFI_STATUS -EFIAPI -XenBusDxeDriverBindingSupported ( - IN EFI_DRIVER_BINDING_PROTOCOL *This, - IN EFI_HANDLE ControllerHandle, - IN EFI_DEVICE_PATH_PROTOCOL *RemainingDevicePath OPTIONAL - ) -{ - EFI_STATUS Status; - XENIO_PROTOCOL *XenIo; - - Status = gBS->OpenProtocol ( - ControllerHandle, - &gXenIoProtocolGuid, - (VOID **)&XenIo, - This->DriverBindingHandle, - ControllerHandle, - EFI_OPEN_PROTOCOL_BY_DRIVER - ); - - if (EFI_ERROR (Status)) { - return Status; - } - - gBS->CloseProtocol (ControllerHandle, &gXenIoProtocolGuid, - This->DriverBindingHandle, ControllerHandle); - - return Status; -} - -VOID -EFIAPI -NotifyExitBoot ( - IN EFI_EVENT Event, - IN VOID *Context - ) -{ - XENBUS_DEVICE *Dev = Context; - - gBS->DisconnectController(Dev->ControllerHandle, - Dev->This->DriverBindingHandle, NULL); -} - -/** - Starts a bus controller. - - The Start() function is designed to be invoked from the EFI boot service ConnectController(). - As a result, much of the error checking on the parameters to Start() has been moved into this - common boot service. It is legal to call Start() from other locations, - but the following calling restrictions must be followed, or the system behavior will not be deterministic. - 1. ControllerHandle must be a valid EFI_HANDLE. - 2. If RemainingDevicePath is not NULL, then it must be a pointer to a naturally aligned - EFI_DEVICE_PATH_PROTOCOL. - 3. Prior to calling Start(), the Supported() function for the driver specified by This must - have been called with the same calling parameters, and Supported() must have returned EFI_SUCCESS. - - @param[in] This A pointer to the EFI_DRIVER_BINDING_PROTOCOL instance. - @param[in] ControllerHandle The handle of the controller to start. This handle - must support a protocol interface that supplies - an I/O abstraction to the driver. - @param[in] RemainingDevicePath A pointer to the remaining portion of a device path. This - parameter is ignored by device drivers, and is optional for bus - drivers. For a bus driver, if this parameter is NULL, then handles - for all the children of Controller are created by this driver. - If this parameter is not NULL and the first Device Path Node is - not the End of Device Path Node, then only the handle for the - child device specified by the first Device Path Node of - RemainingDevicePath is created by this driver. - If the first Device Path Node of RemainingDevicePath is - the End of Device Path Node, no child handle is created by this - driver. - - @retval EFI_SUCCESS The device was started. - @retval EFI_DEVICE_ERROR The device could not be started due to a device error.Currently not implemented. - @retval EFI_OUT_OF_RESOURCES The request could not be completed due to a lack of resources. - @retval EFI_UNSUPPORTED Something is missing on the system that - prevent to start the edvice. - @retval Others The driver failded to start the device. - -**/ -EFI_STATUS -EFIAPI -XenBusDxeDriverBindingStart ( - IN EFI_DRIVER_BINDING_PROTOCOL *This, - IN EFI_HANDLE ControllerHandle, - IN EFI_DEVICE_PATH_PROTOCOL *RemainingDevicePath OPTIONAL - ) -{ - EFI_STATUS Status; - XENBUS_DEVICE *Dev; - XENIO_PROTOCOL *XenIo; - EFI_DEVICE_PATH_PROTOCOL *DevicePath; - - Status = gBS->OpenProtocol ( - ControllerHandle, - &gXenIoProtocolGuid, - (VOID**)&XenIo, - This->DriverBindingHandle, - ControllerHandle, - EFI_OPEN_PROTOCOL_BY_DRIVER - ); - - if (EFI_ERROR (Status)) { - return Status; - } - - Status = gBS->OpenProtocol ( - ControllerHandle, - &gEfiDevicePathProtocolGuid, - (VOID **) &DevicePath, - This->DriverBindingHandle, - ControllerHandle, - EFI_OPEN_PROTOCOL_BY_DRIVER - ); - - if (EFI_ERROR (Status)) { - goto ErrorOpenningProtocol; - } - - Dev = AllocateZeroPool (sizeof (*Dev)); - Dev->Signature = XENBUS_DEVICE_SIGNATURE; - Dev->This = This; - Dev->ControllerHandle = ControllerHandle; - Dev->XenIo = XenIo; - Dev->DevicePath = DevicePath; - InitializeListHead (&Dev->ChildList); - - EfiAcquireLock (&mMyDeviceLock); - if (mMyDevice != NULL) { - EfiReleaseLock (&mMyDeviceLock); - // - // There is already a XenBus running, only one can be used at a time. - // - Status = EFI_ALREADY_STARTED; - goto ErrorAllocated; - } - mMyDevice = Dev; - EfiReleaseLock (&mMyDeviceLock); - - Status = XenGetSharedInfoPage (Dev); - if (EFI_ERROR (Status)) { - DEBUG ((EFI_D_ERROR, "XenBus: Unable to get the shared info page.\n")); - Status = EFI_UNSUPPORTED; - goto ErrorAllocated; - } - - XenGrantTableInit (Dev); - - Status = XenStoreInit (Dev); - ASSERT_EFI_ERROR (Status); - - XenBusEnumerateBus (Dev); - - Status = gBS->CreateEvent (EVT_SIGNAL_EXIT_BOOT_SERVICES, TPL_CALLBACK, - NotifyExitBoot, - (VOID*) Dev, - &Dev->ExitBootEvent); - ASSERT_EFI_ERROR (Status); - - return EFI_SUCCESS; - -ErrorAllocated: - FreePool (Dev); - gBS->CloseProtocol (ControllerHandle, &gEfiDevicePathProtocolGuid, - This->DriverBindingHandle, ControllerHandle); -ErrorOpenningProtocol: - gBS->CloseProtocol (ControllerHandle, &gXenIoProtocolGuid, - This->DriverBindingHandle, ControllerHandle); - return Status; -} - -/** - Stops a bus controller. - - The Stop() function is designed to be invoked from the EFI boot service DisconnectController(). - As a result, much of the error checking on the parameters to Stop() has been moved - into this common boot service. It is legal to call Stop() from other locations, - but the following calling restrictions must be followed, or the system behavior will not be deterministic. - 1. ControllerHandle must be a valid EFI_HANDLE that was used on a previous call to this - same driver's Start() function. - 2. The first NumberOfChildren handles of ChildHandleBuffer must all be a valid - EFI_HANDLE. In addition, all of these handles must have been created in this driver's - Start() function, and the Start() function must have called OpenProtocol() on - ControllerHandle with an Attribute of EFI_OPEN_PROTOCOL_BY_CHILD_CONTROLLER. - - @param[in] This A pointer to the EFI_DRIVER_BINDING_PROTOCOL instance. - @param[in] ControllerHandle A handle to the device being stopped. The handle must - support a bus specific I/O protocol for the driver - to use to stop the device. - @param[in] NumberOfChildren The number of child device handles in ChildHandleBuffer. - @param[in] ChildHandleBuffer An array of child handles to be freed. May be NULL - if NumberOfChildren is 0. - - @retval EFI_SUCCESS The device was stopped. - @retval EFI_DEVICE_ERROR The device could not be stopped due to a device error. - -**/ -EFI_STATUS -EFIAPI -XenBusDxeDriverBindingStop ( - IN EFI_DRIVER_BINDING_PROTOCOL *This, - IN EFI_HANDLE ControllerHandle, - IN UINTN NumberOfChildren, - IN EFI_HANDLE *ChildHandleBuffer OPTIONAL - ) -{ - UINTN Index; - XENBUS_PROTOCOL *XenBusIo; - XENBUS_PRIVATE_DATA *ChildData; - EFI_STATUS Status; - XENBUS_DEVICE *Dev = mMyDevice; - - for (Index = 0; Index < NumberOfChildren; Index++) { - Status = gBS->OpenProtocol ( - ChildHandleBuffer[Index], - &gXenBusProtocolGuid, - (VOID **) &XenBusIo, - This->DriverBindingHandle, - ControllerHandle, - EFI_OPEN_PROTOCOL_GET_PROTOCOL); - if (EFI_ERROR (Status)) { - DEBUG ((EFI_D_ERROR, "XenBusDxe: get children protocol failed: %r\n", Status)); - continue; - } - ChildData = XENBUS_PRIVATE_DATA_FROM_THIS (XenBusIo); - Status = gBS->DisconnectController (ChildData->Handle, NULL, NULL); - if (EFI_ERROR (Status)) { - DEBUG ((EFI_D_ERROR, "XenBusDxe: error disconnecting child: %r\n", - Status)); - continue; - } - - Status = gBS->UninstallMultipleProtocolInterfaces ( - ChildData->Handle, - &gEfiDevicePathProtocolGuid, ChildData->DevicePath, - &gXenBusProtocolGuid, &ChildData->XenBusIo, - NULL); - ASSERT_EFI_ERROR (Status); - - FreePool ((VOID*)ChildData->XenBusIo.Type); - FreePool ((VOID*)ChildData->XenBusIo.Node); - FreePool ((VOID*)ChildData->XenBusIo.Backend); - FreePool (ChildData->DevicePath); - RemoveEntryList (&ChildData->Link); - FreePool (ChildData); - } - if (NumberOfChildren > 0) { - return EFI_SUCCESS; - } - - gBS->CloseEvent (Dev->ExitBootEvent); - XenStoreDeinit (Dev); - XenGrantTableDeinit (Dev); - - gBS->CloseProtocol (ControllerHandle, &gEfiDevicePathProtocolGuid, - This->DriverBindingHandle, ControllerHandle); - gBS->CloseProtocol (ControllerHandle, &gXenIoProtocolGuid, - This->DriverBindingHandle, ControllerHandle); - - mMyDevice = NULL; - FreePool (Dev); - return EFI_SUCCESS; -} diff --git a/OvmfPkg/XenBusDxe/XenBusDxe.h b/OvmfPkg/XenBusDxe/XenBusDxe.h deleted file mode 100644 index 953e4b72e8..0000000000 --- a/OvmfPkg/XenBusDxe/XenBusDxe.h +++ /dev/null @@ -1,133 +0,0 @@ -/** @file - Function declaration and internal data for XenBusDxe. - - Copyright (C) 2014, Citrix Ltd. - - This program and the accompanying materials - are licensed and made available under the terms and conditions of the BSD License - which accompanies this distribution. The full text of the license may be found at - http://opensource.org/licenses/bsd-license.php - - THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, - WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. - -**/ - -#ifndef __EFI_XENBUS_DXE_H__ -#define __EFI_XENBUS_DXE_H__ - -#include - -// -// Libraries -// -#include -#include -#include -#include -#include -#include -#include - - -// -// UEFI Driver Model Protocols -// -#include - - -// -// Consumed Protocols -// -#include - - -// -// Produced Protocols -// -#include - - -// -// Driver Version -// -#define XENBUS_DXE_VERSION 0x00000010 - - -// -// Protocol instances -// -extern EFI_DRIVER_BINDING_PROTOCOL gXenBusDxeDriverBinding; -extern EFI_COMPONENT_NAME2_PROTOCOL gXenBusDxeComponentName2; -extern EFI_COMPONENT_NAME_PROTOCOL gXenBusDxeComponentName; - - -// -// Include files with function prototypes -// -#include "DriverBinding.h" -#include "ComponentName.h" - -// -// Other stuff -// -#include - -typedef struct _XENBUS_DEVICE_PATH XENBUS_DEVICE_PATH; -typedef struct _XENBUS_DEVICE XENBUS_DEVICE; - -// Have the state of the driver. -#define XENBUS_DEVICE_SIGNATURE SIGNATURE_32 ('X','B','s','t') -struct _XENBUS_DEVICE { - UINT32 Signature; - EFI_DRIVER_BINDING_PROTOCOL *This; - EFI_HANDLE ControllerHandle; - XENIO_PROTOCOL *XenIo; - EFI_EVENT ExitBootEvent; - EFI_DEVICE_PATH_PROTOCOL *DevicePath; - LIST_ENTRY ChildList; - - shared_info_t *SharedInfo; -}; - -// There is one of this struct allocated for every child. -#define XENBUS_PRIVATE_DATA_SIGNATURE SIGNATURE_32 ('X', 'B', 'p', 'd') -typedef struct { - UINTN Signature; - LIST_ENTRY Link; - EFI_HANDLE Handle; - XENBUS_PROTOCOL XenBusIo; - XENBUS_DEVICE *Dev; - XENBUS_DEVICE_PATH *DevicePath; -} XENBUS_PRIVATE_DATA; - -#define XENBUS_PRIVATE_DATA_FROM_THIS(a) \ - CR (a, XENBUS_PRIVATE_DATA, XenBusIo, XENBUS_PRIVATE_DATA_SIGNATURE) -#define XENBUS_PRIVATE_DATA_FROM_LINK(a) \ - CR (a, XENBUS_PRIVATE_DATA, Link, XENBUS_PRIVATE_DATA_SIGNATURE) - -/* - * Helpers - */ - -/** - Atomically test and clear a bit. - - @param Bit Bit index to test in *Address - @param Address The Address to the buffer that contain the bit to test. - - @return Value of the Bit before it was cleared. -**/ -INT32 -EFIAPI -TestAndClearBit ( - IN INT32 Bit, - IN VOID *Address - ); - -CHAR8* -AsciiStrDup ( - IN CONST CHAR8* Str - ); - -#endif diff --git a/OvmfPkg/XenBusDxe/XenBusDxe.inf b/OvmfPkg/XenBusDxe/XenBusDxe.inf deleted file mode 100644 index 5ff1cd0484..0000000000 --- a/OvmfPkg/XenBusDxe/XenBusDxe.inf +++ /dev/null @@ -1,67 +0,0 @@ -## @file -# This driver produces a XenBus protocol for every Xen PV devices found. -# -# Copyright (C) 2014, Citrix Ltd. -# -# This program and the accompanying materials -# are licensed and made available under the terms and conditions of the BSD License -# which accompanies this distribution. The full text of the license may be found at -# http://opensource.org/licenses/bsd-license.php -# -# THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, -# WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. -# -## - -[Defines] - INF_VERSION = 0x00010005 - BASE_NAME = XenBusDxe - FILE_GUID = 565ec8ba-a484-11e3-802b-b8ac6f7d65e6 - MODULE_TYPE = UEFI_DRIVER - - VERSION_STRING = 1.0 - ENTRY_POINT = XenBusDxeDriverEntryPoint - UNLOAD_IMAGE = XenBusDxeUnload - - -[Packages] - MdePkg/MdePkg.dec - OvmfPkg/OvmfPkg.dec - -[Sources] - XenBusDxe.h - XenBusDxe.c - DriverBinding.h - ComponentName.c - ComponentName.h - GrantTable.c - GrantTable.h - EventChannel.c - EventChannel.h - XenStore.c - XenStore.h - XenBus.c - XenBus.h - Helpers.c - TestAndClearBit.c - -[LibraryClasses] - UefiDriverEntryPoint - UefiBootServicesTableLib - MemoryAllocationLib - BaseMemoryLib - BaseLib - UefiLib - DevicePathLib - DebugLib - XenHypercallLib - SynchronizationLib - PrintLib - -[Protocols] - gEfiDriverBindingProtocolGuid - gEfiComponentName2ProtocolGuid - gEfiComponentNameProtocolGuid - gXenBusProtocolGuid - gXenIoProtocolGuid - diff --git a/OvmfPkg/XenBusDxe/XenStore.c b/OvmfPkg/XenBusDxe/XenStore.c deleted file mode 100644 index 6812e1078c..0000000000 --- a/OvmfPkg/XenBusDxe/XenStore.c +++ /dev/null @@ -1,1554 +0,0 @@ -/** @file - Low-level kernel interface to the XenStore. - - The XenStore interface is a simple storage system that is a means of - communicating state and configuration data between the Xen Domain 0 - and the various guest domains. All configuration data other than - a small amount of essential information required during the early - boot process of launching a Xen aware guest, is managed using the - XenStore. - - The XenStore is ASCII string based, and has a structure and semantics - similar to a filesystem. There are files and directories, the directories - able to contain files or other directories. The depth of the hierarchy - is only limited by the XenStore's maximum path length. - - The communication channel between the XenStore service and other - domains is via two, guest specific, ring buffers in a shared memory - area. One ring buffer is used for communicating in each direction. - The grant table references for this shared memory are given to the - guest either via the xen_start_info structure for a fully para- - virtualized guest, or via HVM hypercalls for a hardware virtualized - guest. - - The XenStore communication relies on an event channel and thus - interrupts. But under OVMF this XenStore client will pull the - state of the event channel. - - Several Xen services depend on the XenStore, most notably the - XenBus used to discover and manage Xen devices. - - Copyright (C) 2005 Rusty Russell, IBM Corporation - Copyright (C) 2009,2010 Spectra Logic Corporation - Copyright (C) 2014, Citrix Ltd. - - This file may be distributed separately from the Linux kernel, or - incorporated into other software packages, subject to the following license: - - Permission is hereby granted, free of charge, to any person obtaining a copy - of this source file (the "Software"), to deal in the Software without - restriction, including without limitation the rights to use, copy, modify, - merge, publish, distribute, sublicense, and/or sell copies of the Software, - and to permit persons to whom the Software is furnished to do so, subject to - the following conditions: - - The above copyright notice and this permission notice shall be included in - all copies or substantial portions of the Software. - - THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING - FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS - IN THE SOFTWARE. -**/ - -#include "XenStore.h" - -#include - -#include - -#include "EventChannel.h" -#include - -// -// Private Data Structures -// - -typedef struct { - CONST VOID *Data; - UINT32 Len; -} WRITE_REQUEST; - -/* Register callback to watch subtree (node) in the XenStore. */ -#define XENSTORE_WATCH_SIGNATURE SIGNATURE_32 ('X','S','w','a') -struct _XENSTORE_WATCH -{ - UINT32 Signature; - LIST_ENTRY Link; - - /* Path being watched. */ - CHAR8 *Node; -}; - -#define XENSTORE_WATCH_FROM_LINK(l) \ - CR (l, XENSTORE_WATCH, Link, XENSTORE_WATCH_SIGNATURE) - - -/** - * Structure capturing messages received from the XenStore service. - */ -#define XENSTORE_MESSAGE_SIGNATURE SIGNATURE_32 ('X', 'S', 's', 'm') -typedef struct { - UINT32 Signature; - LIST_ENTRY Link; - - struct xsd_sockmsg Header; - - union { - /* Queued replies. */ - struct { - CHAR8 *Body; - } Reply; - - /* Queued watch events. */ - struct { - XENSTORE_WATCH *Handle; - CONST CHAR8 **Vector; - UINT32 VectorSize; - } Watch; - } u; -} XENSTORE_MESSAGE; -#define XENSTORE_MESSAGE_FROM_LINK(r) \ - CR (r, XENSTORE_MESSAGE, Link, XENSTORE_MESSAGE_SIGNATURE) - -/** - * Container for all XenStore related state. - */ -typedef struct { - /** - * Pointer to shared memory communication structures allowing us - * to communicate with the XenStore service. - */ - struct xenstore_domain_interface *XenStore; - - XENBUS_DEVICE *Dev; - - /** - * A list of replies to our requests. - * - * The reply list is filled by xs_rcv_thread(). It - * is consumed by the context that issued the request - * to which a reply is made. The requester blocks in - * XenStoreReadReply (). - * - * /note Only one requesting context can be active at a time. - */ - LIST_ENTRY ReplyList; - - /** Lock protecting the reply list. */ - EFI_LOCK ReplyLock; - - /** - * List of registered watches. - */ - LIST_ENTRY RegisteredWatches; - - /** Lock protecting the registered watches list. */ - EFI_LOCK RegisteredWatchesLock; - - /** - * List of pending watch callback events. - */ - LIST_ENTRY WatchEvents; - - /** Lock protecting the watch calback list. */ - EFI_LOCK WatchEventsLock; - - /** - * The event channel for communicating with the - * XenStore service. - */ - evtchn_port_t EventChannel; - - /** Handle for XenStore events. */ - EFI_EVENT EventChannelEvent; -} XENSTORE_PRIVATE; - -// -// Global Data -// -static XENSTORE_PRIVATE xs; - - -// -// Private Utility Functions -// - -/** - Count and optionally record pointers to a number of NUL terminated - strings in a buffer. - - @param Strings A pointer to a contiguous buffer of NUL terminated strings. - @param Len The length of the buffer pointed to by strings. - @param Dst An array to store pointers to each string found in strings. - - @return A count of the number of strings found. -**/ -STATIC -UINT32 -ExtractStrings ( - IN CONST CHAR8 *Strings, - IN UINTN Len, - OUT CONST CHAR8 **Dst OPTIONAL - ) -{ - UINT32 Num = 0; - CONST CHAR8 *Ptr; - - for (Ptr = Strings; Ptr < Strings + Len; Ptr += AsciiStrSize (Ptr)) { - if (Dst != NULL) { - *Dst++ = Ptr; - } - Num++; - } - - return Num; -} - -/** - Convert a contiguous buffer containing a series of NUL terminated - strings into an array of pointers to strings. - - The returned pointer references the array of string pointers which - is followed by the storage for the string data. It is the client's - responsibility to free this storage. - - The storage addressed by Strings is free'd prior to Split returning. - - @param Strings A pointer to a contiguous buffer of NUL terminated strings. - @param Len The length of the buffer pointed to by strings. - @param NumPtr The number of strings found and returned in the strings - array. - - @return An array of pointers to the strings found in the input buffer. -**/ -STATIC -CONST CHAR8 ** -Split ( - IN CHAR8 *Strings, - IN UINTN Len, - OUT UINT32 *NumPtr - ) -{ - CONST CHAR8 **Dst; - - ASSERT(NumPtr != NULL); - ASSERT(Strings != NULL); - - /* Protect against unterminated buffers. */ - if (Len > 0) { - Strings[Len - 1] = '\0'; - } - - /* Count the Strings. */ - *NumPtr = ExtractStrings (Strings, Len, NULL); - - /* Transfer to one big alloc for easy freeing by the caller. */ - Dst = AllocatePool (*NumPtr * sizeof (CHAR8 *) + Len); - CopyMem ((VOID*)&Dst[*NumPtr], Strings, Len); - FreePool (Strings); - - /* Extract pointers to newly allocated array. */ - Strings = (CHAR8 *) &Dst[*NumPtr]; - ExtractStrings (Strings, Len, Dst); - - return (Dst); -} - -/** - Convert from watch token (unique identifier) to the associated - internal tracking structure for this watch. - - @param Tocken The unique identifier for the watch to find. - - @return A pointer to the found watch structure or NULL. -**/ -STATIC -XENSTORE_WATCH * -XenStoreFindWatch ( - IN CONST CHAR8 *Token - ) -{ - XENSTORE_WATCH *Watch, *WantedWatch; - LIST_ENTRY *Entry; - - WantedWatch = (VOID *) AsciiStrHexToUintn (Token); - - if (IsListEmpty (&xs.RegisteredWatches)) { - return NULL; - } - for (Entry = GetFirstNode (&xs.RegisteredWatches); - !IsNull (&xs.RegisteredWatches, Entry); - Entry = GetNextNode (&xs.RegisteredWatches, Entry)) { - Watch = XENSTORE_WATCH_FROM_LINK (Entry); - if (Watch == WantedWatch) - return Watch; - } - - return NULL; -} - -// -// Public Utility Functions -// API comments for these methods can be found in XenStore.h -// - -CHAR8 * -XenStoreJoin ( - IN CONST CHAR8 *DirectoryPath, - IN CONST CHAR8 *Node - ) -{ - CHAR8 *Buf; - UINTN BufSize; - - /* +1 for '/' and +1 for '\0' */ - BufSize = AsciiStrLen (DirectoryPath) + AsciiStrLen (Node) + 2; - Buf = AllocatePool (BufSize); - ASSERT (Buf != NULL); - - if (Node[0] == '\0') { - AsciiSPrint (Buf, BufSize, "%a", DirectoryPath); - } else { - AsciiSPrint (Buf, BufSize, "%a/%a", DirectoryPath, Node); - } - - return Buf; -} - -// -// Low Level Communication Management -// - -/** - Verify that the indexes for a ring are valid. - - The difference between the producer and consumer cannot - exceed the size of the ring. - - @param Cons The consumer index for the ring to test. - @param Prod The producer index for the ring to test. - - @retval TRUE If indexes are in range. - @retval FALSE If the indexes are out of range. -**/ -STATIC -BOOLEAN -XenStoreCheckIndexes ( - XENSTORE_RING_IDX Cons, - XENSTORE_RING_IDX Prod - ) -{ - return ((Prod - Cons) <= XENSTORE_RING_SIZE); -} - -/** - Return a pointer to, and the length of, the contiguous - free region available for output in a ring buffer. - - @param Cons The consumer index for the ring. - @param Prod The producer index for the ring. - @param Buffer The base address of the ring's storage. - @param LenPtr The amount of contiguous storage available. - - @return A pointer to the start location of the free region. -**/ -STATIC -VOID * -XenStoreGetOutputChunk ( - IN XENSTORE_RING_IDX Cons, - IN XENSTORE_RING_IDX Prod, - IN CHAR8 *Buffer, - OUT UINT32 *LenPtr - ) -{ - UINT32 Len; - Len = XENSTORE_RING_SIZE - MASK_XENSTORE_IDX (Prod); - if ((XENSTORE_RING_SIZE - (Prod - Cons)) < Len) { - Len = XENSTORE_RING_SIZE - (Prod - Cons); - } - *LenPtr = Len; - return (Buffer + MASK_XENSTORE_IDX (Prod)); -} - -/** - Return a pointer to, and the length of, the contiguous - data available to read from a ring buffer. - - @param Cons The consumer index for the ring. - @param Prod The producer index for the ring. - @param Buffer The base address of the ring's storage. - @param LenPtr The amount of contiguous data available to read. - - @return A pointer to the start location of the available data. -**/ -STATIC -CONST VOID * -XenStoreGetInputChunk ( - IN XENSTORE_RING_IDX Cons, - IN XENSTORE_RING_IDX Prod, - IN CONST CHAR8 *Buffer, - OUT UINT32 *LenPtr - ) -{ - UINT32 Len; - - Len = XENSTORE_RING_SIZE - MASK_XENSTORE_IDX (Cons); - if ((Prod - Cons) < Len) { - Len = Prod - Cons; - } - *LenPtr = Len; - return (Buffer + MASK_XENSTORE_IDX (Cons)); -} - -/** - Wait for an event or timeout. - - @param Event Event to wait for. - @param Timeout A timeout value in 100ns units. - - @retval EFI_SUCCESS Event have been triggered or the current TPL is not - TPL_APPLICATION. - @retval EFI_TIMEOUT Timeout have expired. -**/ -STATIC -EFI_STATUS -XenStoreWaitForEvent ( - IN EFI_EVENT Event, - IN UINT64 Timeout - ) -{ - UINTN Index; - EFI_STATUS Status; - EFI_EVENT TimerEvent; - EFI_EVENT WaitList[2]; - - gBS->CreateEvent (EVT_TIMER, 0, NULL, NULL, &TimerEvent); - gBS->SetTimer (TimerEvent, TimerRelative, Timeout); - - WaitList[0] = xs.EventChannelEvent; - WaitList[1] = TimerEvent; - Status = gBS->WaitForEvent (2, WaitList, &Index); - ASSERT (Status != EFI_INVALID_PARAMETER); - gBS->CloseEvent (TimerEvent); - if (Status == EFI_UNSUPPORTED) { - return EFI_SUCCESS; - } - if (Index == 1) { - return EFI_TIMEOUT; - } else { - return EFI_SUCCESS; - } -} - -/** - Transmit data to the XenStore service. - - The buffer pointed to by DataPtr is at least Len bytes in length. - - @param DataPtr A pointer to the contiguous data to send. - @param Len The amount of data to send. - - @return On success 0, otherwise an errno value indicating the - cause of failure. -**/ -STATIC -XENSTORE_STATUS -XenStoreWriteStore ( - IN CONST VOID *DataPtr, - IN UINT32 Len - ) -{ - XENSTORE_RING_IDX Cons, Prod; - CONST CHAR8 *Data = (CONST CHAR8 *)DataPtr; - - while (Len != 0) { - void *Dest; - UINT32 Available; - - Cons = xs.XenStore->req_cons; - Prod = xs.XenStore->req_prod; - if ((Prod - Cons) == XENSTORE_RING_SIZE) { - /* - * Output ring is full. Wait for a ring event. - * - * Note that the events from both queues are combined, so being woken - * does not guarantee that data exist in the read ring. - */ - EFI_STATUS Status; - - Status = XenStoreWaitForEvent (xs.EventChannelEvent, - EFI_TIMER_PERIOD_SECONDS (1)); - if (Status == EFI_TIMEOUT) { - DEBUG ((EFI_D_WARN, "XenStore Write, waiting for a ring event.\n")); - } - continue; - } - - /* Verify queue sanity. */ - if (!XenStoreCheckIndexes (Cons, Prod)) { - xs.XenStore->req_cons = xs.XenStore->req_prod = 0; - return XENSTORE_STATUS_EIO; - } - - Dest = XenStoreGetOutputChunk (Cons, Prod, xs.XenStore->req, &Available); - if (Available > Len) { - Available = Len; - } - - CopyMem (Dest, Data, Available); - Data += Available; - Len -= Available; - - /* - * The store to the producer index, which indicates - * to the other side that new data has arrived, must - * be visible only after our copy of the data into the - * ring has completed. - */ - MemoryFence (); - xs.XenStore->req_prod += Available; - - /* - * The other side will see the change to req_prod at the time of the - * interrupt. - */ - MemoryFence (); - XenEventChannelNotify (xs.Dev, xs.EventChannel); - } - - return XENSTORE_STATUS_SUCCESS; -} - -/** - Receive data from the XenStore service. - - The buffer pointed to by DataPtr is at least Len bytes in length. - - @param DataPtr A pointer to the contiguous buffer to receive the data. - @param Len The amount of data to receive. - - @return On success 0, otherwise an errno value indicating the - cause of failure. -**/ -STATIC -XENSTORE_STATUS -XenStoreReadStore ( - OUT VOID *DataPtr, - IN UINT32 Len - ) -{ - XENSTORE_RING_IDX Cons, Prod; - CHAR8 *Data = (CHAR8 *) DataPtr; - - while (Len != 0) { - UINT32 Available; - CONST CHAR8 *Src; - - Cons = xs.XenStore->rsp_cons; - Prod = xs.XenStore->rsp_prod; - if (Cons == Prod) { - /* - * Nothing to read. Wait for a ring event. - * - * Note that the events from both queues are combined, so being woken - * does not guarantee that data exist in the read ring. - */ - EFI_STATUS Status; - - Status = XenStoreWaitForEvent (xs.EventChannelEvent, - EFI_TIMER_PERIOD_SECONDS (1)); - if (Status == EFI_TIMEOUT) { - DEBUG ((EFI_D_WARN, "XenStore Read, waiting for a ring event.\n")); - } - continue; - } - - /* Verify queue sanity. */ - if (!XenStoreCheckIndexes (Cons, Prod)) { - xs.XenStore->rsp_cons = xs.XenStore->rsp_prod = 0; - return XENSTORE_STATUS_EIO; - } - - Src = XenStoreGetInputChunk (Cons, Prod, xs.XenStore->rsp, &Available); - if (Available > Len) { - Available = Len; - } - - /* - * Insure the data we read is related to the indexes - * we read above. - */ - MemoryFence (); - - CopyMem (Data, Src, Available); - Data += Available; - Len -= Available; - - /* - * Insure that the producer of this ring does not see - * the ring space as free until after we have copied it - * out. - */ - MemoryFence (); - xs.XenStore->rsp_cons += Available; - - /* - * The producer will see the updated consumer index when the event is - * delivered. - */ - MemoryFence (); - XenEventChannelNotify (xs.Dev, xs.EventChannel); - } - - return XENSTORE_STATUS_SUCCESS; -} - -// -// Received Message Processing -// - -/** - Block reading the next message from the XenStore service and - process the result. - - @return XENSTORE_STATUS_SUCCESS on success. Otherwise an errno value - indicating the type of failure encountered. -**/ -STATIC -XENSTORE_STATUS -XenStoreProcessMessage ( - VOID - ) -{ - XENSTORE_MESSAGE *Message; - CHAR8 *Body; - XENSTORE_STATUS Status; - - Message = AllocateZeroPool (sizeof (XENSTORE_MESSAGE)); - Message->Signature = XENSTORE_MESSAGE_SIGNATURE; - Status = XenStoreReadStore (&Message->Header, sizeof (Message->Header)); - if (Status != XENSTORE_STATUS_SUCCESS) { - FreePool (Message); - DEBUG ((EFI_D_ERROR, "XenStore: Error read store (%d)\n", Status)); - return Status; - } - - Body = AllocatePool (Message->Header.len + 1); - Status = XenStoreReadStore (Body, Message->Header.len); - if (Status != XENSTORE_STATUS_SUCCESS) { - FreePool (Body); - FreePool (Message); - DEBUG ((EFI_D_ERROR, "XenStore: Error read store (%d)\n", Status)); - return Status; - } - Body[Message->Header.len] = '\0'; - - if (Message->Header.type == XS_WATCH_EVENT) { - Message->u.Watch.Vector = Split(Body, Message->Header.len, - &Message->u.Watch.VectorSize); - - EfiAcquireLock (&xs.RegisteredWatchesLock); - Message->u.Watch.Handle = - XenStoreFindWatch (Message->u.Watch.Vector[XS_WATCH_TOKEN]); - DEBUG ((EFI_D_INFO, "XenStore: Watch event %a\n", - Message->u.Watch.Vector[XS_WATCH_TOKEN])); - if (Message->u.Watch.Handle != NULL) { - EfiAcquireLock (&xs.WatchEventsLock); - InsertHeadList (&xs.WatchEvents, &Message->Link); - EfiReleaseLock (&xs.WatchEventsLock); - } else { - DEBUG ((EFI_D_WARN, "XenStore: Watch handle %a not found\n", - Message->u.Watch.Vector[XS_WATCH_TOKEN])); - FreePool((VOID*)Message->u.Watch.Vector); - FreePool(Message); - } - EfiReleaseLock (&xs.RegisteredWatchesLock); - } else { - Message->u.Reply.Body = Body; - EfiAcquireLock (&xs.ReplyLock); - InsertTailList (&xs.ReplyList, &Message->Link); - EfiReleaseLock (&xs.ReplyLock); - } - - return XENSTORE_STATUS_SUCCESS; -} - -// -// XenStore Message Request/Reply Processing -// - -/** - Convert a XenStore error string into an errno number. - - Unknown error strings are converted to EINVAL. - - @param errorstring The error string to convert. - - @return The errno best matching the input string. - -**/ -typedef struct { - XENSTORE_STATUS Status; - CONST CHAR8 *ErrorStr; -} XenStoreErrors; - -static XenStoreErrors gXenStoreErrors[] = { - { XENSTORE_STATUS_EINVAL, "EINVAL" }, - { XENSTORE_STATUS_EACCES, "EACCES" }, - { XENSTORE_STATUS_EEXIST, "EEXIST" }, - { XENSTORE_STATUS_EISDIR, "EISDIR" }, - { XENSTORE_STATUS_ENOENT, "ENOENT" }, - { XENSTORE_STATUS_ENOMEM, "ENOMEM" }, - { XENSTORE_STATUS_ENOSPC, "ENOSPC" }, - { XENSTORE_STATUS_EIO, "EIO" }, - { XENSTORE_STATUS_ENOTEMPTY, "ENOTEMPTY" }, - { XENSTORE_STATUS_ENOSYS, "ENOSYS" }, - { XENSTORE_STATUS_EROFS, "EROFS" }, - { XENSTORE_STATUS_EBUSY, "EBUSY" }, - { XENSTORE_STATUS_EAGAIN, "EAGAIN" }, - { XENSTORE_STATUS_EISCONN, "EISCONN" }, - { XENSTORE_STATUS_E2BIG, "E2BIG" } -}; - -STATIC -XENSTORE_STATUS -XenStoreGetError ( - CONST CHAR8 *ErrorStr - ) -{ - UINT32 Index; - - for (Index = 0; Index < ARRAY_SIZE(gXenStoreErrors); Index++) { - if (!AsciiStrCmp (ErrorStr, gXenStoreErrors[Index].ErrorStr)) { - return gXenStoreErrors[Index].Status; - } - } - DEBUG ((EFI_D_WARN, "XenStore gave unknown error %a\n", ErrorStr)); - return XENSTORE_STATUS_EINVAL; -} - -/** - Block waiting for a reply to a message request. - - @param TypePtr The returned type of the reply. - @param LenPtr The returned body length of the reply. - @param Result The returned body of the reply. -**/ -STATIC -XENSTORE_STATUS -XenStoreReadReply ( - OUT enum xsd_sockmsg_type *TypePtr, - OUT UINT32 *LenPtr OPTIONAL, - OUT VOID **Result - ) -{ - XENSTORE_MESSAGE *Message; - LIST_ENTRY *Entry; - CHAR8 *Body; - - while (IsListEmpty (&xs.ReplyList)) { - XENSTORE_STATUS Status; - Status = XenStoreProcessMessage (); - if (Status != XENSTORE_STATUS_SUCCESS && Status != XENSTORE_STATUS_EAGAIN) { - DEBUG ((EFI_D_ERROR, "XenStore, error while reading the ring (%d).", - Status)); - return Status; - } - } - EfiAcquireLock (&xs.ReplyLock); - Entry = GetFirstNode (&xs.ReplyList); - Message = XENSTORE_MESSAGE_FROM_LINK (Entry); - RemoveEntryList (Entry); - EfiReleaseLock (&xs.ReplyLock); - - *TypePtr = Message->Header.type; - if (LenPtr != NULL) { - *LenPtr = Message->Header.len; - } - Body = Message->u.Reply.Body; - - FreePool (Message); - *Result = Body; - return XENSTORE_STATUS_SUCCESS; -} - -/** - Send a message with an optionally muti-part body to the XenStore service. - - @param Transaction The transaction to use for this request. - @param RequestType The type of message to send. - @param WriteRequest Pointers to the body sections of the request. - @param NumRequests The number of body sections in the request. - @param LenPtr The returned length of the reply. - @param ResultPtr The returned body of the reply. - - @return XENSTORE_STATUS_SUCCESS on success. Otherwise an errno indicating - the cause of failure. -**/ -STATIC -XENSTORE_STATUS -XenStoreTalkv ( - IN CONST XENSTORE_TRANSACTION *Transaction, - IN enum xsd_sockmsg_type RequestType, - IN CONST WRITE_REQUEST *WriteRequest, - IN UINT32 NumRequests, - OUT UINT32 *LenPtr OPTIONAL, - OUT VOID **ResultPtr OPTIONAL - ) -{ - struct xsd_sockmsg Message; - void *Return = NULL; - UINT32 Index; - XENSTORE_STATUS Status; - - if (Transaction == XST_NIL) { - Message.tx_id = 0; - } else { - Message.tx_id = Transaction->Id; - } - Message.req_id = 0; - Message.type = RequestType; - Message.len = 0; - for (Index = 0; Index < NumRequests; Index++) { - Message.len += WriteRequest[Index].Len; - } - - Status = XenStoreWriteStore (&Message, sizeof (Message)); - if (Status != XENSTORE_STATUS_SUCCESS) { - DEBUG ((EFI_D_ERROR, "XenStoreTalkv failed %d\n", Status)); - goto Error; - } - - for (Index = 0; Index < NumRequests; Index++) { - Status = XenStoreWriteStore (WriteRequest[Index].Data, WriteRequest[Index].Len); - if (Status != XENSTORE_STATUS_SUCCESS) { - DEBUG ((EFI_D_ERROR, "XenStoreTalkv failed %d\n", Status)); - goto Error; - } - } - - Status = XenStoreReadReply ((enum xsd_sockmsg_type *)&Message.type, LenPtr, &Return); - -Error: - if (Status != XENSTORE_STATUS_SUCCESS) { - return Status; - } - - if (Message.type == XS_ERROR) { - Status = XenStoreGetError (Return); - FreePool (Return); - return Status; - } - - /* Reply is either error or an echo of our request message type. */ - ASSERT ((enum xsd_sockmsg_type)Message.type == RequestType); - - if (ResultPtr) { - *ResultPtr = Return; - } else { - FreePool (Return); - } - - return XENSTORE_STATUS_SUCCESS; -} - -/** - Wrapper for XenStoreTalkv allowing easy transmission of a message with - a single, contiguous, message body. - - The returned result is provided in malloced storage and thus must be free'd - by the caller. - - @param Transaction The transaction to use for this request. - @param RequestType The type of message to send. - @param Body The body of the request. - @param LenPtr The returned length of the reply. - @param Result The returned body of the reply. - - @return 0 on success. Otherwise an errno indicating - the cause of failure. -**/ -STATIC -XENSTORE_STATUS -XenStoreSingle ( - IN CONST XENSTORE_TRANSACTION *Transaction, - IN enum xsd_sockmsg_type RequestType, - IN CONST CHAR8 *Body, - OUT UINT32 *LenPtr OPTIONAL, - OUT VOID **Result OPTIONAL - ) -{ - WRITE_REQUEST WriteRequest; - - WriteRequest.Data = (VOID *) Body; - WriteRequest.Len = (UINT32)AsciiStrSize (Body); - - return XenStoreTalkv (Transaction, RequestType, &WriteRequest, 1, - LenPtr, Result); -} - -// -// XenStore Watch Support -// - -/** - Transmit a watch request to the XenStore service. - - @param Path The path in the XenStore to watch. - @param Tocken A unique identifier for this watch. - - @return XENSTORE_STATUS_SUCCESS on success. Otherwise an errno indicating the - cause of failure. -**/ -STATIC -XENSTORE_STATUS -XenStoreWatch ( - CONST CHAR8 *Path, - CONST CHAR8 *Token - ) -{ - WRITE_REQUEST WriteRequest[2]; - - WriteRequest[0].Data = (VOID *) Path; - WriteRequest[0].Len = (UINT32)AsciiStrSize (Path); - WriteRequest[1].Data = (VOID *) Token; - WriteRequest[1].Len = (UINT32)AsciiStrSize (Token); - - return XenStoreTalkv (XST_NIL, XS_WATCH, WriteRequest, 2, NULL, NULL); -} - -/** - Transmit an uwatch request to the XenStore service. - - @param Path The path in the XenStore to watch. - @param Tocken A unique identifier for this watch. - - @return XENSTORE_STATUS_SUCCESS on success. Otherwise an errno indicating - the cause of failure. -**/ -STATIC -XENSTORE_STATUS -XenStoreUnwatch ( - CONST CHAR8 *Path, - CONST CHAR8 *Token - ) -{ - WRITE_REQUEST WriteRequest[2]; - - WriteRequest[0].Data = (VOID *) Path; - WriteRequest[0].Len = (UINT32)AsciiStrSize (Path); - WriteRequest[1].Data = (VOID *) Token; - WriteRequest[1].Len = (UINT32)AsciiStrSize (Token); - - return XenStoreTalkv (XST_NIL, XS_UNWATCH, WriteRequest, 2, NULL, NULL); -} - -STATIC -XENSTORE_STATUS -XenStoreWaitWatch ( - VOID *Token - ) -{ - XENSTORE_MESSAGE *Message; - LIST_ENTRY *Entry = NULL; - LIST_ENTRY *Last = NULL; - XENSTORE_STATUS Status; - - while (TRUE) { - EfiAcquireLock (&xs.WatchEventsLock); - if (IsListEmpty (&xs.WatchEvents) || - Last == GetFirstNode (&xs.WatchEvents)) { - EfiReleaseLock (&xs.WatchEventsLock); - Status = XenStoreProcessMessage (); - if (Status != XENSTORE_STATUS_SUCCESS && Status != XENSTORE_STATUS_EAGAIN) { - return Status; - } - continue; - } - - for (Entry = GetFirstNode (&xs.WatchEvents); - Entry != Last && !IsNull (&xs.WatchEvents, Entry); - Entry = GetNextNode (&xs.WatchEvents, Entry)) { - Message = XENSTORE_MESSAGE_FROM_LINK (Entry); - if (Message->u.Watch.Handle == Token) { - RemoveEntryList (Entry); - EfiReleaseLock (&xs.WatchEventsLock); - FreePool((VOID*)Message->u.Watch.Vector); - FreePool(Message); - return XENSTORE_STATUS_SUCCESS; - } - } - Last = GetFirstNode (&xs.WatchEvents); - EfiReleaseLock (&xs.WatchEventsLock); - } -} - -VOID -EFIAPI -NotifyEventChannelCheckForEvent ( - IN EFI_EVENT Event, - IN VOID *Context - ) -{ - XENSTORE_PRIVATE *xsp; - xsp = (XENSTORE_PRIVATE *)Context; - if (TestAndClearBit (xsp->EventChannel, xsp->Dev->SharedInfo->evtchn_pending)) { - gBS->SignalEvent (Event); - } -} - -/** - Setup communication channels with the XenStore service. - - @retval EFI_SUCCESS if everything went well. -**/ -STATIC -EFI_STATUS -XenStoreInitComms ( - XENSTORE_PRIVATE *xsp - ) -{ - EFI_STATUS Status; - EFI_EVENT TimerEvent; - struct xenstore_domain_interface *XenStore = xsp->XenStore; - - Status = gBS->CreateEvent (EVT_TIMER, 0, NULL, NULL, &TimerEvent); - Status = gBS->SetTimer (TimerEvent, TimerRelative, - EFI_TIMER_PERIOD_SECONDS (5)); - while (XenStore->rsp_prod != XenStore->rsp_cons) { - Status = gBS->CheckEvent (TimerEvent); - if (!EFI_ERROR (Status)) { - DEBUG ((EFI_D_WARN, "XENSTORE response ring is not quiescent " - "(%08x:%08x): fixing up\n", - XenStore->rsp_cons, XenStore->rsp_prod)); - XenStore->rsp_cons = XenStore->rsp_prod; - } - } - gBS->CloseEvent (TimerEvent); - - Status = gBS->CreateEvent (EVT_NOTIFY_WAIT, TPL_NOTIFY, - NotifyEventChannelCheckForEvent, xsp, - &xsp->EventChannelEvent); - ASSERT_EFI_ERROR (Status); - - return Status; -} - -/** - Initialize XenStore. - - @param Dev A XENBUS_DEVICE instance. - - @retval EFI_SUCCESS if everything went well. -**/ -EFI_STATUS -XenStoreInit ( - XENBUS_DEVICE *Dev - ) -{ - EFI_STATUS Status; - /** - * The HVM guest pseudo-physical frame number. This is Xen's mapping - * of the true machine frame number into our "physical address space". - */ - UINTN XenStoreGpfn; - - xs.Dev = Dev; - - xs.EventChannel = (evtchn_port_t)XenHypercallHvmGetParam (HVM_PARAM_STORE_EVTCHN); - XenStoreGpfn = (UINTN)XenHypercallHvmGetParam (HVM_PARAM_STORE_PFN); - xs.XenStore = (VOID *) (XenStoreGpfn << EFI_PAGE_SHIFT); - DEBUG ((EFI_D_INFO, "XenBusInit: XenBus rings @%p, event channel %x\n", - xs.XenStore, xs.EventChannel)); - - InitializeListHead (&xs.ReplyList); - InitializeListHead (&xs.WatchEvents); - InitializeListHead (&xs.RegisteredWatches); - - EfiInitializeLock (&xs.ReplyLock, TPL_NOTIFY); - EfiInitializeLock (&xs.RegisteredWatchesLock, TPL_NOTIFY); - EfiInitializeLock (&xs.WatchEventsLock, TPL_NOTIFY); - - /* Initialize the shared memory rings to talk to xenstored */ - Status = XenStoreInitComms (&xs); - - return Status; -} - -VOID -XenStoreDeinit ( - IN XENBUS_DEVICE *Dev - ) -{ - // - // Emptying the list RegisteredWatches, but this list should already be - // empty. Every driver that is using Watches should unregister them when - // it is stopped. - // - if (!IsListEmpty (&xs.RegisteredWatches)) { - XENSTORE_WATCH *Watch; - LIST_ENTRY *Entry; - DEBUG ((EFI_D_WARN, "XenStore: RegisteredWatches is not empty, cleaning up...")); - Entry = GetFirstNode (&xs.RegisteredWatches); - while (!IsNull (&xs.RegisteredWatches, Entry)) { - Watch = XENSTORE_WATCH_FROM_LINK (Entry); - Entry = GetNextNode (&xs.RegisteredWatches, Entry); - - XenStoreUnregisterWatch (Watch); - } - } - - // - // Emptying the list WatchEvents, but this list should already be empty after - // having cleanup the list RegisteredWatches. - // - if (!IsListEmpty (&xs.WatchEvents)) { - LIST_ENTRY *Entry; - DEBUG ((EFI_D_WARN, "XenStore: WatchEvents is not empty, cleaning up...")); - Entry = GetFirstNode (&xs.WatchEvents); - while (!IsNull (&xs.WatchEvents, Entry)) { - XENSTORE_MESSAGE *Message = XENSTORE_MESSAGE_FROM_LINK (Entry); - Entry = GetNextNode (&xs.WatchEvents, Entry); - RemoveEntryList (&Message->Link); - FreePool ((VOID*)Message->u.Watch.Vector); - FreePool (Message); - } - } - - if (!IsListEmpty (&xs.ReplyList)) { - XENSTORE_MESSAGE *Message; - LIST_ENTRY *Entry; - Entry = GetFirstNode (&xs.ReplyList); - while (!IsNull (&xs.ReplyList, Entry)) { - Message = XENSTORE_MESSAGE_FROM_LINK (Entry); - Entry = GetNextNode (&xs.ReplyList, Entry); - RemoveEntryList (&Message->Link); - FreePool (Message->u.Reply.Body); - FreePool (Message); - } - } - - gBS->CloseEvent (xs.EventChannelEvent); - - if (xs.XenStore->server_features & XENSTORE_SERVER_FEATURE_RECONNECTION) { - xs.XenStore->connection = XENSTORE_RECONNECT; - XenEventChannelNotify (xs.Dev, xs.EventChannel); - while (*(volatile UINT32*)&xs.XenStore->connection == XENSTORE_RECONNECT) { - XenStoreWaitForEvent (xs.EventChannelEvent, EFI_TIMER_PERIOD_MILLISECONDS (100)); - } - } else { - /* If the backend reads the state while we're erasing it then the - * ring state will become corrupted, preventing guest frontends from - * connecting. This is rare. To help diagnose the failure, we fill - * the ring with XS_INVALID packets. */ - SetMem (xs.XenStore->req, XENSTORE_RING_SIZE, 0xff); - SetMem (xs.XenStore->rsp, XENSTORE_RING_SIZE, 0xff); - xs.XenStore->req_cons = xs.XenStore->req_prod = 0; - xs.XenStore->rsp_cons = xs.XenStore->rsp_prod = 0; - } - xs.XenStore = NULL; -} - -// -// Public API -// API comments for these methods can be found in XenStore.h -// - -XENSTORE_STATUS -XenStoreListDirectory ( - IN CONST XENSTORE_TRANSACTION *Transaction, - IN CONST CHAR8 *DirectoryPath, - IN CONST CHAR8 *Node, - OUT UINT32 *DirectoryCountPtr, - OUT CONST CHAR8 ***DirectoryListPtr - ) -{ - CHAR8 *Path; - CHAR8 *TempStr; - UINT32 Len = 0; - XENSTORE_STATUS Status; - - Path = XenStoreJoin (DirectoryPath, Node); - Status = XenStoreSingle (Transaction, XS_DIRECTORY, Path, &Len, - (VOID **) &TempStr); - FreePool (Path); - if (Status != XENSTORE_STATUS_SUCCESS) { - return Status; - } - - *DirectoryListPtr = Split (TempStr, Len, DirectoryCountPtr); - - return XENSTORE_STATUS_SUCCESS; -} - -BOOLEAN -XenStorePathExists ( - IN CONST XENSTORE_TRANSACTION *Transaction, - IN CONST CHAR8 *Directory, - IN CONST CHAR8 *Node - ) -{ - CONST CHAR8 **TempStr; - XENSTORE_STATUS Status; - UINT32 TempNum; - - Status = XenStoreListDirectory (Transaction, Directory, Node, - &TempNum, &TempStr); - if (Status != XENSTORE_STATUS_SUCCESS) { - return FALSE; - } - FreePool ((VOID*)TempStr); - return TRUE; -} - -XENSTORE_STATUS -XenStoreRead ( - IN CONST XENSTORE_TRANSACTION *Transaction, - IN CONST CHAR8 *DirectoryPath, - IN CONST CHAR8 *Node, - OUT UINT32 *LenPtr OPTIONAL, - OUT VOID **Result - ) -{ - CHAR8 *Path; - VOID *Value; - XENSTORE_STATUS Status; - - Path = XenStoreJoin (DirectoryPath, Node); - Status = XenStoreSingle (Transaction, XS_READ, Path, LenPtr, &Value); - FreePool (Path); - if (Status != XENSTORE_STATUS_SUCCESS) { - return Status; - } - - *Result = Value; - return XENSTORE_STATUS_SUCCESS; -} - -XENSTORE_STATUS -XenStoreWrite ( - IN CONST XENSTORE_TRANSACTION *Transaction, - IN CONST CHAR8 *DirectoryPath, - IN CONST CHAR8 *Node, - IN CONST CHAR8 *Str - ) -{ - CHAR8 *Path; - WRITE_REQUEST WriteRequest[2]; - XENSTORE_STATUS Status; - - Path = XenStoreJoin (DirectoryPath, Node); - - WriteRequest[0].Data = (VOID *) Path; - WriteRequest[0].Len = (UINT32)AsciiStrSize (Path); - WriteRequest[1].Data = (VOID *) Str; - WriteRequest[1].Len = (UINT32)AsciiStrLen (Str); - - Status = XenStoreTalkv (Transaction, XS_WRITE, WriteRequest, 2, NULL, NULL); - FreePool (Path); - - return Status; -} - -XENSTORE_STATUS -XenStoreRemove ( - IN CONST XENSTORE_TRANSACTION *Transaction, - IN CONST CHAR8 *DirectoryPath, - IN CONST CHAR8 *Node - ) -{ - CHAR8 *Path; - XENSTORE_STATUS Status; - - Path = XenStoreJoin (DirectoryPath, Node); - Status = XenStoreSingle (Transaction, XS_RM, Path, NULL, NULL); - FreePool (Path); - - return Status; -} - -XENSTORE_STATUS -XenStoreTransactionStart ( - OUT XENSTORE_TRANSACTION *Transaction - ) -{ - CHAR8 *IdStr; - XENSTORE_STATUS Status; - - Status = XenStoreSingle (XST_NIL, XS_TRANSACTION_START, "", NULL, - (VOID **) &IdStr); - if (Status == XENSTORE_STATUS_SUCCESS) { - Transaction->Id = (UINT32)AsciiStrDecimalToUintn (IdStr); - FreePool (IdStr); - } - - return Status; -} - -XENSTORE_STATUS -XenStoreTransactionEnd ( - IN CONST XENSTORE_TRANSACTION *Transaction, - IN BOOLEAN Abort - ) -{ - CHAR8 AbortStr[2]; - - AbortStr[0] = Abort ? 'F' : 'T'; - AbortStr[1] = '\0'; - - return XenStoreSingle (Transaction, XS_TRANSACTION_END, AbortStr, NULL, NULL); -} - -XENSTORE_STATUS -EFIAPI -XenStoreVSPrint ( - IN CONST XENSTORE_TRANSACTION *Transaction, - IN CONST CHAR8 *DirectoryPath, - IN CONST CHAR8 *Node, - IN CONST CHAR8 *FormatString, - IN VA_LIST Marker - ) -{ - CHAR8 *Buf; - XENSTORE_STATUS Status; - UINTN BufSize; - VA_LIST Marker2; - - VA_COPY (Marker2, Marker); - BufSize = SPrintLengthAsciiFormat (FormatString, Marker2) + 1; - VA_END (Marker2); - Buf = AllocateZeroPool (BufSize); - AsciiVSPrint (Buf, BufSize, FormatString, Marker); - Status = XenStoreWrite (Transaction, DirectoryPath, Node, Buf); - FreePool (Buf); - - return Status; -} - -XENSTORE_STATUS -EFIAPI -XenStoreSPrint ( - IN CONST XENSTORE_TRANSACTION *Transaction, - IN CONST CHAR8 *DirectoryPath, - IN CONST CHAR8 *Node, - IN CONST CHAR8 *FormatString, - ... - ) -{ - VA_LIST Marker; - XENSTORE_STATUS Status; - - VA_START (Marker, FormatString); - Status = XenStoreVSPrint (Transaction, DirectoryPath, Node, FormatString, Marker); - VA_END (Marker); - - return Status; -} - -XENSTORE_STATUS -XenStoreRegisterWatch ( - IN CONST CHAR8 *DirectoryPath, - IN CONST CHAR8 *Node, - OUT XENSTORE_WATCH **WatchPtr - ) -{ - /* Pointer in ascii is the token. */ - CHAR8 Token[sizeof (XENSTORE_WATCH) * 2 + 1]; - XENSTORE_STATUS Status; - XENSTORE_WATCH *Watch; - - Watch = AllocateZeroPool (sizeof (XENSTORE_WATCH)); - Watch->Signature = XENSTORE_WATCH_SIGNATURE; - Watch->Node = XenStoreJoin (DirectoryPath, Node); - - EfiAcquireLock (&xs.RegisteredWatchesLock); - InsertTailList (&xs.RegisteredWatches, &Watch->Link); - EfiReleaseLock (&xs.RegisteredWatchesLock); - - AsciiSPrint (Token, sizeof (Token), "%p", (VOID*) Watch); - Status = XenStoreWatch (Watch->Node, Token); - - /* Ignore errors due to multiple registration. */ - if (Status == XENSTORE_STATUS_EEXIST) { - Status = XENSTORE_STATUS_SUCCESS; - } - - if (Status == XENSTORE_STATUS_SUCCESS) { - *WatchPtr = Watch; - } else { - EfiAcquireLock (&xs.RegisteredWatchesLock); - RemoveEntryList (&Watch->Link); - EfiReleaseLock (&xs.RegisteredWatchesLock); - FreePool (Watch->Node); - FreePool (Watch); - } - - return Status; -} - -VOID -XenStoreUnregisterWatch ( - IN XENSTORE_WATCH *Watch - ) -{ - CHAR8 Token[sizeof (Watch) * 2 + 1]; - LIST_ENTRY *Entry; - - ASSERT (Watch->Signature == XENSTORE_WATCH_SIGNATURE); - - AsciiSPrint (Token, sizeof (Token), "%p", (VOID *) Watch); - if (XenStoreFindWatch (Token) == NULL) { - return; - } - - EfiAcquireLock (&xs.RegisteredWatchesLock); - RemoveEntryList (&Watch->Link); - EfiReleaseLock (&xs.RegisteredWatchesLock); - - XenStoreUnwatch (Watch->Node, Token); - - /* Cancel pending watch events. */ - EfiAcquireLock (&xs.WatchEventsLock); - Entry = GetFirstNode (&xs.WatchEvents); - while (!IsNull (&xs.WatchEvents, Entry)) { - XENSTORE_MESSAGE *Message = XENSTORE_MESSAGE_FROM_LINK (Entry); - Entry = GetNextNode (&xs.WatchEvents, Entry); - if (Message->u.Watch.Handle == Watch) { - RemoveEntryList (&Message->Link); - FreePool ((VOID*)Message->u.Watch.Vector); - FreePool (Message); - } - } - EfiReleaseLock (&xs.WatchEventsLock); - - FreePool (Watch->Node); - FreePool (Watch); -} - - -// -// XENBUS protocol -// - -XENSTORE_STATUS -EFIAPI -XenBusWaitForWatch ( - IN XENBUS_PROTOCOL *This, - IN VOID *Token - ) -{ - return XenStoreWaitWatch (Token); -} - -XENSTORE_STATUS -EFIAPI -XenBusXenStoreRead ( - IN XENBUS_PROTOCOL *This, - IN CONST XENSTORE_TRANSACTION *Transaction, - IN CONST CHAR8 *Node, - OUT VOID **Value - ) -{ - return XenStoreRead (Transaction, This->Node, Node, NULL, Value); -} - -XENSTORE_STATUS -EFIAPI -XenBusXenStoreBackendRead ( - IN XENBUS_PROTOCOL *This, - IN CONST XENSTORE_TRANSACTION *Transaction, - IN CONST CHAR8 *Node, - OUT VOID **Value - ) -{ - return XenStoreRead (Transaction, This->Backend, Node, NULL, Value); -} - -XENSTORE_STATUS -EFIAPI -XenBusXenStoreRemove ( - IN XENBUS_PROTOCOL *This, - IN CONST XENSTORE_TRANSACTION *Transaction, - IN const char *Node - ) -{ - return XenStoreRemove (Transaction, This->Node, Node); -} - -XENSTORE_STATUS -EFIAPI -XenBusXenStoreTransactionStart ( - IN XENBUS_PROTOCOL *This, - OUT XENSTORE_TRANSACTION *Transaction - ) -{ - return XenStoreTransactionStart (Transaction); -} - -XENSTORE_STATUS -EFIAPI -XenBusXenStoreTransactionEnd ( - IN XENBUS_PROTOCOL *This, - IN CONST XENSTORE_TRANSACTION *Transaction, - IN BOOLEAN Abort - ) -{ - return XenStoreTransactionEnd (Transaction, Abort); -} - -XENSTORE_STATUS -EFIAPI -XenBusXenStoreSPrint ( - IN XENBUS_PROTOCOL *This, - IN CONST XENSTORE_TRANSACTION *Transaction, - IN CONST CHAR8 *DirectoryPath, - IN CONST CHAR8 *Node, - IN CONST CHAR8 *FormatString, - ... - ) -{ - VA_LIST Marker; - XENSTORE_STATUS Status; - - VA_START (Marker, FormatString); - Status = XenStoreVSPrint (Transaction, DirectoryPath, Node, FormatString, Marker); - VA_END (Marker); - - return Status; -} - -XENSTORE_STATUS -EFIAPI -XenBusRegisterWatch ( - IN XENBUS_PROTOCOL *This, - IN CONST CHAR8 *Node, - OUT VOID **Token - ) -{ - return XenStoreRegisterWatch (This->Node, Node, (XENSTORE_WATCH **) Token); -} - -XENSTORE_STATUS -EFIAPI -XenBusRegisterWatchBackend ( - IN XENBUS_PROTOCOL *This, - IN CONST CHAR8 *Node, - OUT VOID **Token - ) -{ - return XenStoreRegisterWatch (This->Backend, Node, (XENSTORE_WATCH **) Token); -} - -VOID -EFIAPI -XenBusUnregisterWatch ( - IN XENBUS_PROTOCOL *This, - IN VOID *Token - ) -{ - XenStoreUnregisterWatch ((XENSTORE_WATCH *) Token); -} diff --git a/OvmfPkg/XenBusDxe/XenStore.h b/OvmfPkg/XenBusDxe/XenStore.h deleted file mode 100644 index 33bb647f66..0000000000 --- a/OvmfPkg/XenBusDxe/XenStore.h +++ /dev/null @@ -1,380 +0,0 @@ -/** @file - Method declarations and structures for accessing the XenStore - - Copyright (C) 2005 Rusty Russell, IBM Corporation - Copyright (C) 2005 XenSource Ltd. - Copyright (C) 2009,2010 Spectra Logic Corporation - Copyright (C) 2014, Citrix Ltd. - - This file may be distributed separately from the Linux kernel, or - incorporated into other software packages, subject to the following license: - - Permission is hereby granted, free of charge, to any person obtaining a copy - of this source file (the "Software"), to deal in the Software without - restriction, including without limitation the rights to use, copy, modify, - merge, publish, distribute, sublicense, and/or sell copies of the Software, - and to permit persons to whom the Software is furnished to do so, subject to - the following conditions: - - The above copyright notice and this permission notice shall be included in - all copies or substantial portions of the Software. - - THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING - FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS - IN THE SOFTWARE. -**/ - -#ifndef _XEN_XENSTORE_XENSTOREVAR_H -#define _XEN_XENSTORE_XENSTOREVAR_H - -#include "XenBusDxe.h" - -#include - -typedef struct _XENSTORE_WATCH XENSTORE_WATCH; - -/** - Fetch the contents of a directory in the XenStore. - - @param Transaction The XenStore transaction covering this request. - @param DirectoryPath The dirname of the path to read. - @param Node The basename of the path to read. - @param DirectoryCountPtr The returned number of directory entries. - @param DirectoryListPtr An array of directory entry strings. - - @return On success, XENSTORE_STATUS_SUCCESS. Otherwise an errno value - indicating the type of failure. - - @note The results buffer is alloced and should be free'd by the - caller. -**/ -XENSTORE_STATUS -XenStoreListDirectory ( - IN CONST XENSTORE_TRANSACTION *Transaction, - IN CONST CHAR8 *DirectoryPath, - IN CONST CHAR8 *Node, - OUT UINT32 *DirectoryCountPtr, - OUT CONST CHAR8 ***DirectoryListPtr - ); - -/** - Determine if a path exists in the XenStore. - - @param Transaction The XenStore transaction covering this request. - @param Directory The dirname of the path to read. - @param Node The basename of the path to read. - - @retval TRUE The path exists. - @retval FALSE The path does not exist or an error occurred attempting - to make that determination. -**/ -BOOLEAN -XenStorePathExists ( - IN CONST XENSTORE_TRANSACTION *Transaction, - IN CONST CHAR8 *Directory, - IN CONST CHAR8 *Node - ); - -/** - Get the contents of a single "file". Returns the contents in *Result which - should be freed after use. The length of the value in bytes is returned in - *LenPtr. - - @param Transaction The XenStore transaction covering this request. - @param DirectoryPath The dirname of the file to read. - @param Node The basename of the file to read. - @param LenPtr The amount of data read. - @param Result The returned contents from this file. - - @return On success, XENSTORE_STATUS_SUCCESS. Otherwise an errno value - indicating the type of failure. - - @note The results buffer is malloced and should be free'd by the - caller. -**/ -XENSTORE_STATUS -XenStoreRead ( - IN CONST XENSTORE_TRANSACTION *Transaction, - IN CONST CHAR8 *DirectoryPath, - IN CONST CHAR8 *Node, - OUT UINT32 *LenPtr OPTIONAL, - OUT VOID **Result - ); - -/** - Write to a single file. - - @param Transaction The XenStore transaction covering this request. - @param DirectoryPath The dirname of the file to write. - @param Node The basename of the file to write. - @param Str The NUL terminated string of data to write. - - @return On success, XENSTORE_STATUS_SUCCESS. Otherwise an errno value - indicating the type of failure. -**/ -XENSTORE_STATUS -XenStoreWrite ( - IN CONST XENSTORE_TRANSACTION *Transaction, - IN CONST CHAR8 *DirectoryPath, - IN CONST CHAR8 *Node, - IN CONST CHAR8 *Str - ); - -/** - Remove a file or directory (directories must be empty). - - @param Transaction The XenStore transaction covering this request. - @param DirectoryPath The dirname of the directory to remove. - @param Node The basename of the directory to remove. - - @return On success, XENSTORE_STATUS_SUCCESS. Otherwise an errno value - indicating the type of failure. -**/ -XENSTORE_STATUS -XenStoreRemove ( - IN CONST XENSTORE_TRANSACTION *Transaction, - IN CONST CHAR8 *DirectoryPath, - IN CONST CHAR8 *Node - ); - -/** - Start a transaction. - - Changes by others will not be seen during the lifetime of this - transaction, and changes will not be visible to others until it - is committed (XenStoreTransactionEnd). - - @param Transaction The returned transaction. - - @return On success, XENSTORE_STATUS_SUCCESS. Otherwise an errno value - indicating the type of failure. -**/ -XENSTORE_STATUS -XenStoreTransactionStart ( - OUT XENSTORE_TRANSACTION *Transaction - ); - -/** - End a transaction. - - @param Transaction The transaction to end/commit. - @param Abort If TRUE, the transaction is discarded - instead of committed. - - @return On success, XENSTORE_STATUS_SUCCESS. Otherwise an errno value - indicating the type of failure. -**/ -XENSTORE_STATUS -XenStoreTransactionEnd ( - IN CONST XENSTORE_TRANSACTION *Transaction, - IN BOOLEAN Abort - ); - -/** - Printf formatted write to a XenStore file. - - @param Transaction The XenStore transaction covering this request. - @param DirectoryPath The dirname of the path to read. - @param Node The basename of the path to read. - @param FormatString AsciiSPrint format string followed by a variable number - of arguments. - - @return On success, XENSTORE_STATUS_SUCCESS. Otherwise an errno value - indicating the type of write failure. -**/ -XENSTORE_STATUS -EFIAPI -XenStoreSPrint ( - IN CONST XENSTORE_TRANSACTION *Transaction, - IN CONST CHAR8 *DirectoryPath, - IN CONST CHAR8 *Node, - IN CONST CHAR8 *FormatString, - ... - ); - -/** - VA_LIST version of XenStoreSPrint(). - - @param Transaction The XenStore transaction covering this request. - @param DirectoryPath The dirname of the path to read. - @param Node The basename of the path to read. - @param FormatString Printf format string. - @param Marker VA_LIST of printf arguments. - - @return On success, XENSTORE_STATUS_SUCCESS. Otherwise an errno value - indicating the type of write failure. -**/ -XENSTORE_STATUS -EFIAPI -XenStoreVSPrint ( - IN CONST XENSTORE_TRANSACTION *Transaction, - IN CONST CHAR8 *DirectoryPath, - IN CONST CHAR8 *Node, - IN CONST CHAR8 *FormatString, - IN VA_LIST Marker - ); - -/** - Register a XenStore watch. - - XenStore watches allow a client to be notified via a callback (embedded - within the watch object) of changes to an object in the XenStore. - - @param DirectoryPath The dirname of the path to watch. - @param Node The basename of the path to watch. - @param WatchPtr A returned XENSTORE_WATCH pointer. - - @return On success, XENSTORE_STATUS_SUCCESS. Otherwise an errno value - indicating the type of write failure. EEXIST errors from the - XenStore are suppressed, allowing multiple, physically different, - xenbus_watch objects, to watch the same path in the XenStore. -**/ -XENSTORE_STATUS -XenStoreRegisterWatch ( - IN CONST CHAR8 *DirectoryPath, - IN CONST CHAR8 *Node, - OUT XENSTORE_WATCH **WatchPtr - ); - -/** - Unregister a XenStore watch. - - @param Watch An XENSTORE_WATCH object previously returned by a successful - call to XenStoreRegisterWatch (). -**/ -VOID -XenStoreUnregisterWatch ( - IN XENSTORE_WATCH *Watch - ); - -/** - Allocate and return the XenStore path string /. If name - is the NUL string, the returned value contains the path string - . - - @param DirectoryPath The NUL terminated directory prefix for new path. - @param Node The NUL terminated basename for the new path. - - @return A buffer containing the joined path. - */ -CHAR8 * -XenStoreJoin ( - IN CONST CHAR8 *DirectoryPath, - IN CONST CHAR8 *Node - ); - - -/** - Initialize the XenStore states and rings. - - @param Dev A pointer to a XENBUS_DEVICE instance. - - @return EFI_SUCCESS if everything went smoothly. -**/ -EFI_STATUS -XenStoreInit ( - XENBUS_DEVICE *Dev - ); - -/** - Deinitialize the XenStore states and rings. - - @param Dev A pointer to a XENBUS_DEVICE instance. -**/ -VOID -XenStoreDeinit ( - IN XENBUS_DEVICE *Dev - ); - - -// -// XENBUS protocol -// - -XENSTORE_STATUS -EFIAPI -XenBusWaitForWatch ( - IN XENBUS_PROTOCOL *This, - IN VOID *Token - ); - -XENSTORE_STATUS -EFIAPI -XenBusXenStoreRead ( - IN XENBUS_PROTOCOL *This, - IN CONST XENSTORE_TRANSACTION *Transaction, - IN CONST CHAR8 *Node, - OUT VOID **Value - ); - -XENSTORE_STATUS -EFIAPI -XenBusXenStoreBackendRead ( - IN XENBUS_PROTOCOL *This, - IN CONST XENSTORE_TRANSACTION *Transaction, - IN CONST CHAR8 *Node, - OUT VOID **Value - ); - -XENSTORE_STATUS -EFIAPI -XenBusXenStoreRemove ( - IN XENBUS_PROTOCOL *This, - IN CONST XENSTORE_TRANSACTION *Transaction, - IN CONST CHAR8 *Node - ); - -XENSTORE_STATUS -EFIAPI -XenBusXenStoreTransactionStart ( - IN XENBUS_PROTOCOL *This, - OUT XENSTORE_TRANSACTION *Transaction - ); - -XENSTORE_STATUS -EFIAPI -XenBusXenStoreTransactionEnd ( - IN XENBUS_PROTOCOL *This, - IN CONST XENSTORE_TRANSACTION *Transaction, - IN BOOLEAN Abort - ); - -XENSTORE_STATUS -EFIAPI -XenBusXenStoreSPrint ( - IN XENBUS_PROTOCOL *This, - IN CONST XENSTORE_TRANSACTION *Transaction, - IN CONST CHAR8 *DirectoryPath, - IN CONST CHAR8 *Node, - IN CONST CHAR8 *FormatString, - ... - ); - -XENSTORE_STATUS -EFIAPI -XenBusRegisterWatch ( - IN XENBUS_PROTOCOL *This, - IN CONST CHAR8 *Node, - OUT VOID **Token - ); - -XENSTORE_STATUS -EFIAPI -XenBusRegisterWatchBackend ( - IN XENBUS_PROTOCOL *This, - IN CONST CHAR8 *Node, - OUT VOID **Token - ); - -VOID -EFIAPI -XenBusUnregisterWatch ( - IN XENBUS_PROTOCOL *This, - IN VOID *Token - ); - -#endif /* _XEN_XENSTORE_XENSTOREVAR_H */ diff --git a/OvmfPkg/XenIoPciDxe/XenIoPciDxe.c b/OvmfPkg/XenIoPciDxe/XenIoPciDxe.c deleted file mode 100644 index 15803eb847..0000000000 --- a/OvmfPkg/XenIoPciDxe/XenIoPciDxe.c +++ /dev/null @@ -1,367 +0,0 @@ -/** @file - - Driver for the virtual Xen PCI device - - Copyright (C) 2012, Red Hat, Inc. - Copyright (c) 2012 - 2016, Intel Corporation. All rights reserved.
- Copyright (C) 2013, ARM Ltd. - Copyright (C) 2015, Linaro Ltd. - - This program and the accompanying materials are licensed and made available - under the terms and conditions of the BSD License which accompanies this - distribution. The full text of the license may be found at - http://opensource.org/licenses/bsd-license.php - - THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, WITHOUT - WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. - -**/ - -#include -#include -#include -#include -#include -#include -#include - -#include -#include - -#define PCI_VENDOR_ID_XEN 0x5853 -#define PCI_DEVICE_ID_XEN_PLATFORM 0x0001 - -/** - - Device probe function for this driver. - - The DXE core calls this function for any given device in order to see if the - driver can drive the device. - - @param[in] This The EFI_DRIVER_BINDING_PROTOCOL object - incorporating this driver (independently of - any device). - - @param[in] DeviceHandle The device to probe. - - @param[in] RemainingDevicePath Relevant only for bus drivers, ignored. - - - @retval EFI_SUCCESS The driver supports the device being probed. - - @retval EFI_UNSUPPORTED The driver does not support the device being probed. - - @return Error codes from the OpenProtocol() boot service or - the PciIo protocol. - -**/ -STATIC -EFI_STATUS -EFIAPI -XenIoPciDeviceBindingSupported ( - 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) { - if ((Pci.Hdr.VendorId == PCI_VENDOR_ID_XEN) && - (Pci.Hdr.DeviceId == PCI_DEVICE_ID_XEN_PLATFORM)) { - Status = EFI_SUCCESS; - } else { - Status = EFI_UNSUPPORTED; - } - } - - // - // We needed PCI IO access only transitorily, to see whether we support the - // device or not. - // - gBS->CloseProtocol (DeviceHandle, &gEfiPciIoProtocolGuid, - This->DriverBindingHandle, DeviceHandle); - - return Status; -} - -/** - - After we've pronounced support for a specific device in - DriverBindingSupported(), we start managing said device (passed in by the - Driver Execution 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 The device was started. - - @retval EFI_OUT_OF_RESOURCES Memory allocation failed. - - @return Error codes from the OpenProtocol() boot - service, the PciIo protocol or the - InstallProtocolInterface() boot service. - -**/ -STATIC -EFI_STATUS -EFIAPI -XenIoPciDeviceBindingStart ( - IN EFI_DRIVER_BINDING_PROTOCOL *This, - IN EFI_HANDLE DeviceHandle, - IN EFI_DEVICE_PATH_PROTOCOL *RemainingDevicePath - ) -{ - EFI_STATUS Status; - XENIO_PROTOCOL *XenIo; - EFI_PCI_IO_PROTOCOL *PciIo; - EFI_ACPI_ADDRESS_SPACE_DESCRIPTOR *BarDesc; - - XenIo = (XENIO_PROTOCOL *) AllocateZeroPool (sizeof *XenIo); - if (XenIo == NULL) { - return EFI_OUT_OF_RESOURCES; - } - - Status = gBS->OpenProtocol (DeviceHandle, &gEfiPciIoProtocolGuid, - (VOID **)&PciIo, This->DriverBindingHandle, - DeviceHandle, EFI_OPEN_PROTOCOL_BY_DRIVER); - if (EFI_ERROR (Status)) { - goto FreeXenIo; - } - - // - // The BAR1 of this PCI device is used for shared memory and is supposed to - // look like MMIO. The address space of the BAR1 will be used to map the - // Grant Table. - // - Status = PciIo->GetBarAttributes (PciIo, PCI_BAR_IDX1, NULL, (VOID**) &BarDesc); - ASSERT_EFI_ERROR (Status); - ASSERT (BarDesc->ResType == ACPI_ADDRESS_SPACE_TYPE_MEM); - - /* Get a Memory address for mapping the Grant Table. */ - DEBUG ((EFI_D_INFO, "XenIoPci: BAR at %LX\n", BarDesc->AddrRangeMin)); - XenIo->GrantTableAddress = BarDesc->AddrRangeMin; - FreePool (BarDesc); - - Status = gBS->InstallProtocolInterface (&DeviceHandle, - &gXenIoProtocolGuid, EFI_NATIVE_INTERFACE, XenIo); - - if (!EFI_ERROR (Status)) { - return EFI_SUCCESS; - } - - gBS->CloseProtocol (DeviceHandle, &gEfiPciIoProtocolGuid, - This->DriverBindingHandle, DeviceHandle); - -FreeXenIo: - FreePool (XenIo); - - return Status; -} - -/** - - Stop driving the XenIo PCI device - - @param[in] This The EFI_DRIVER_BINDING_PROTOCOL object - incorporating this driver (independently of any - device). - - @param[in] DeviceHandle Stop driving this device. - - @param[in] NumberOfChildren Since this function belongs to a device driver - only (as opposed to a bus driver), the caller - environment sets NumberOfChildren to zero, and - we ignore it. - - @param[in] ChildHandleBuffer Ignored (corresponding to NumberOfChildren). - - @retval EFI_SUCCESS Driver instance has been stopped and the PCI - configuration attributes have been restored. - - @return Error codes from the OpenProtocol() or - CloseProtocol(), UninstallProtocolInterface() - boot services. - -**/ -STATIC -EFI_STATUS -EFIAPI -XenIoPciDeviceBindingStop ( - IN EFI_DRIVER_BINDING_PROTOCOL *This, - IN EFI_HANDLE DeviceHandle, - IN UINTN NumberOfChildren, - IN EFI_HANDLE *ChildHandleBuffer - ) -{ - EFI_STATUS Status; - XENIO_PROTOCOL *XenIo; - - Status = gBS->OpenProtocol ( - DeviceHandle, // candidate device - &gXenIoProtocolGuid, // retrieve the XenIo iface - (VOID **)&XenIo, // 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; - } - - // - // Handle Stop() requests for in-use driver instances gracefully. - // - Status = gBS->UninstallProtocolInterface (DeviceHandle, - &gXenIoProtocolGuid, XenIo); - if (EFI_ERROR (Status)) { - return Status; - } - - Status = gBS->CloseProtocol (DeviceHandle, &gEfiPciIoProtocolGuid, - This->DriverBindingHandle, DeviceHandle); - - FreePool (XenIo); - - return Status; -} - - -// -// The static object that groups the Supported() (ie. probe), Start() and -// Stop() functions of the driver together. Refer to UEFI Spec 2.3.1 + Errata -// C, 10.1 EFI Driver Binding Protocol. -// -STATIC EFI_DRIVER_BINDING_PROTOCOL gDriverBinding = { - &XenIoPciDeviceBindingSupported, - &XenIoPciDeviceBindingStart, - &XenIoPciDeviceBindingStop, - 0x10, // Version, must be in [0x10 .. 0xFFFFFFEF] for IHV-developed drivers - NULL, // ImageHandle, to be overwritten by - // EfiLibInstallDriverBindingComponentName2() in XenIoPciDeviceEntryPoint() - NULL // DriverBindingHandle, ditto -}; - - -// -// The purpose of the following scaffolding (EFI_COMPONENT_NAME_PROTOCOL and -// EFI_COMPONENT_NAME2_PROTOCOL implementation) is to format the driver's name -// in English, for display on standard console devices. This is recommended for -// UEFI drivers that follow the UEFI Driver Model. Refer to the Driver Writer's -// Guide for UEFI 2.3.1 v1.01, 11 UEFI Driver and Controller Names. -// -STATIC -EFI_UNICODE_STRING_TABLE mDriverNameTable[] = { - { "eng;en", L"XenIo PCI Driver" }, - { NULL, NULL } -}; - -STATIC -EFI_COMPONENT_NAME_PROTOCOL gComponentName; - -EFI_STATUS -EFIAPI -XenIoPciGetDriverName ( - 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 -XenIoPciGetDeviceName ( - 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 = { - &XenIoPciGetDriverName, - &XenIoPciGetDeviceName, - "eng" // SupportedLanguages, ISO 639-2 language codes -}; - -STATIC -EFI_COMPONENT_NAME2_PROTOCOL gComponentName2 = { - (EFI_COMPONENT_NAME2_GET_DRIVER_NAME) &XenIoPciGetDriverName, - (EFI_COMPONENT_NAME2_GET_CONTROLLER_NAME) &XenIoPciGetDeviceName, - "en" // SupportedLanguages, RFC 4646 language codes -}; - - -// -// Entry point of this driver. -// -EFI_STATUS -EFIAPI -XenIoPciDeviceEntryPoint ( - IN EFI_HANDLE ImageHandle, - IN EFI_SYSTEM_TABLE *SystemTable - ) -{ - return EfiLibInstallDriverBindingComponentName2 ( - ImageHandle, - SystemTable, - &gDriverBinding, - ImageHandle, - &gComponentName, - &gComponentName2 - ); -} diff --git a/OvmfPkg/XenIoPciDxe/XenIoPciDxe.inf b/OvmfPkg/XenIoPciDxe/XenIoPciDxe.inf deleted file mode 100644 index b32075a381..0000000000 --- a/OvmfPkg/XenIoPciDxe/XenIoPciDxe.inf +++ /dev/null @@ -1,45 +0,0 @@ -## @file -# Driver for the virtual Xen PCI device -# -# Copyright (C) 2015, Linaro Ltd. -# -# This program and the accompanying materials -# are licensed and made available under the terms and conditions of the BSD License -# which accompanies this distribution. The full text of the license may be found at -# http://opensource.org/licenses/bsd-license.php -# -# THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, -# WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. -# -## - -[Defines] - INF_VERSION = 0x00010005 - BASE_NAME = XenIoPciDxe - FILE_GUID = cf569f50-de44-4f54-b4d7-f4ae25cda599 - MODULE_TYPE = UEFI_DRIVER - VERSION_STRING = 1.0 - ENTRY_POINT = XenIoPciDeviceEntryPoint - -[Packages] - MdePkg/MdePkg.dec - OvmfPkg/OvmfPkg.dec - -[Sources] - XenIoPciDxe.c - -[LibraryClasses] - UefiDriverEntryPoint - UefiBootServicesTableLib - MemoryAllocationLib - BaseMemoryLib - BaseLib - UefiLib - DebugLib - -[Protocols] - gEfiDriverBindingProtocolGuid - gEfiPciIoProtocolGuid - gEfiComponentName2ProtocolGuid - gEfiComponentNameProtocolGuid - gXenIoProtocolGuid diff --git a/OvmfPkg/XenPvBlkDxe/BlockFront.c b/OvmfPkg/XenPvBlkDxe/BlockFront.c deleted file mode 100644 index d07e980990..0000000000 --- a/OvmfPkg/XenPvBlkDxe/BlockFront.c +++ /dev/null @@ -1,658 +0,0 @@ -/** @file - Minimal block driver for Mini-OS. - - Copyright (c) 2007-2008 Samuel Thibault. - Copyright (C) 2014, Citrix Ltd. - Copyright (c) 2014, Intel Corporation. All rights reserved.
- - Redistribution and use in source and binary forms, with or without - modification, are permitted provided that the following conditions - are met: - 1. Redistributions of source code must retain the above copyright - notice, this list of conditions and the following disclaimer. - 2. Redistributions in binary form must reproduce the above copyright - notice, this list of conditions and the following disclaimer in the - documentation and/or other materials provided with the distribution. - - THIS SOFTWARE IS PROVIDED BY AUTHOR AND CONTRIBUTORS ``AS IS'' AND - ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - ARE DISCLAIMED. IN NO EVENT SHALL AUTHOR OR CONTRIBUTORS BE LIABLE - FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - SUCH DAMAGE. -**/ - -#include -#include - -#include "BlockFront.h" - -#include -#include - -/** - Helper to read an integer from XenStore. - - If the number overflows according to the range defined by UINT64, - then ASSERT(). - - @param This A pointer to a XENBUS_PROTOCOL instance. - @param Node The XenStore node to read from. - @param FromBackend Read frontend or backend value. - @param ValuePtr Where to put the value. - - @retval XENSTORE_STATUS_SUCCESS If succefull, will update ValuePtr. - @return Any other return value indicate the error, - ValuePtr is not updated in this case. -**/ -STATIC -XENSTORE_STATUS -XenBusReadUint64 ( - IN XENBUS_PROTOCOL *This, - IN CONST CHAR8 *Node, - IN BOOLEAN FromBackend, - OUT UINT64 *ValuePtr - ) -{ - XENSTORE_STATUS Status; - CHAR8 *Ptr; - - if (!FromBackend) { - Status = This->XsRead (This, XST_NIL, Node, (VOID**)&Ptr); - } else { - Status = This->XsBackendRead (This, XST_NIL, Node, (VOID**)&Ptr); - } - if (Status != XENSTORE_STATUS_SUCCESS) { - return Status; - } - // AsciiStrDecimalToUint64 will ASSERT if Ptr overflow UINT64. - *ValuePtr = AsciiStrDecimalToUint64 (Ptr); - FreePool (Ptr); - return Status; -} - -/** - Free an instance of XEN_BLOCK_FRONT_DEVICE. - - @param Dev The instance to free. -**/ -STATIC -VOID -XenPvBlockFree ( - IN XEN_BLOCK_FRONT_DEVICE *Dev - ) -{ - XENBUS_PROTOCOL *XenBusIo = Dev->XenBusIo; - - if (Dev->RingRef != 0) { - XenBusIo->GrantEndAccess (XenBusIo, Dev->RingRef); - } - if (Dev->Ring.sring != NULL) { - FreePages (Dev->Ring.sring, 1); - } - if (Dev->EventChannel != 0) { - XenBusIo->EventChannelClose (XenBusIo, Dev->EventChannel); - } - FreePool (Dev); -} - -/** - Wait until until the backend has reached the ExpectedState. - - @param Dev A XEN_BLOCK_FRONT_DEVICE instance. - @param ExpectedState The backend state expected. - @param LastStatePtr An optional pointer where to right the final state. - - @return Return XENSTORE_STATUS_SUCCESS if the new backend state is ExpectedState - or return an error otherwise. -**/ -STATIC -XENSTORE_STATUS -XenPvBlkWaitForBackendState ( - IN XEN_BLOCK_FRONT_DEVICE *Dev, - IN XenbusState ExpectedState, - OUT XenbusState *LastStatePtr OPTIONAL - ) -{ - XENBUS_PROTOCOL *XenBusIo = Dev->XenBusIo; - XenbusState State; - UINT64 Value; - XENSTORE_STATUS Status = XENSTORE_STATUS_SUCCESS; - - while (TRUE) { - Status = XenBusReadUint64 (XenBusIo, "state", TRUE, &Value); - if (Status != XENSTORE_STATUS_SUCCESS) { - return Status; - } - if (Value > XenbusStateReconfigured) { - // - // Value is not a State value. - // - return XENSTORE_STATUS_EIO; - } - State = Value; - if (State == ExpectedState) { - break; - } else if (State > ExpectedState) { - Status = XENSTORE_STATUS_FAIL; - break; - } - DEBUG ((EFI_D_INFO, - "XenPvBlk: waiting backend state %d, current: %d\n", - ExpectedState, State)); - XenBusIo->WaitForWatch (XenBusIo, Dev->StateWatchToken); - } - - if (LastStatePtr != NULL) { - *LastStatePtr = State; - } - - return Status; -} - -EFI_STATUS -XenPvBlockFrontInitialization ( - IN XENBUS_PROTOCOL *XenBusIo, - IN CONST CHAR8 *NodeName, - OUT XEN_BLOCK_FRONT_DEVICE **DevPtr - ) -{ - XENSTORE_TRANSACTION Transaction; - CHAR8 *DeviceType; - blkif_sring_t *SharedRing; - XENSTORE_STATUS Status; - XEN_BLOCK_FRONT_DEVICE *Dev; - XenbusState State; - UINT64 Value; - CHAR8 *Params; - - ASSERT (NodeName != NULL); - - Dev = AllocateZeroPool (sizeof (XEN_BLOCK_FRONT_DEVICE)); - Dev->Signature = XEN_BLOCK_FRONT_SIGNATURE; - Dev->NodeName = NodeName; - Dev->XenBusIo = XenBusIo; - Dev->DeviceId = XenBusIo->DeviceId; - - XenBusIo->XsRead (XenBusIo, XST_NIL, "device-type", (VOID**)&DeviceType); - if (AsciiStrCmp (DeviceType, "cdrom") == 0) { - Dev->MediaInfo.CdRom = TRUE; - } else { - Dev->MediaInfo.CdRom = FALSE; - } - FreePool (DeviceType); - - if (Dev->MediaInfo.CdRom) { - Status = XenBusIo->XsBackendRead (XenBusIo, XST_NIL, "params", (VOID**)&Params); - if (Status != XENSTORE_STATUS_SUCCESS) { - DEBUG ((EFI_D_ERROR, "%a: Failed to read params (%d)\n", __FUNCTION__, Status)); - goto Error; - } - if (AsciiStrLen (Params) == 0 || AsciiStrCmp (Params, "aio:") == 0) { - FreePool (Params); - DEBUG ((EFI_D_INFO, "%a: Empty cdrom\n", __FUNCTION__)); - goto Error; - } - FreePool (Params); - } - - Status = XenBusReadUint64 (XenBusIo, "backend-id", FALSE, &Value); - if (Status != XENSTORE_STATUS_SUCCESS || Value > MAX_UINT16) { - DEBUG ((EFI_D_ERROR, "XenPvBlk: Failed to get backend-id (%d)\n", - Status)); - goto Error; - } - Dev->DomainId = (domid_t)Value; - XenBusIo->EventChannelAllocate (XenBusIo, Dev->DomainId, &Dev->EventChannel); - - SharedRing = (blkif_sring_t*) AllocatePages (1); - SHARED_RING_INIT (SharedRing); - FRONT_RING_INIT (&Dev->Ring, SharedRing, EFI_PAGE_SIZE); - XenBusIo->GrantAccess (XenBusIo, - Dev->DomainId, - (INTN) SharedRing >> EFI_PAGE_SHIFT, - FALSE, - &Dev->RingRef); - -Again: - Status = XenBusIo->XsTransactionStart (XenBusIo, &Transaction); - if (Status != XENSTORE_STATUS_SUCCESS) { - DEBUG ((EFI_D_WARN, "XenPvBlk: Failed to start transaction, %d\n", Status)); - goto Error; - } - - Status = XenBusIo->XsPrintf (XenBusIo, &Transaction, NodeName, "ring-ref", "%d", - Dev->RingRef); - if (Status != XENSTORE_STATUS_SUCCESS) { - DEBUG ((EFI_D_ERROR, "XenPvBlk: Failed to write ring-ref.\n")); - goto AbortTransaction; - } - Status = XenBusIo->XsPrintf (XenBusIo, &Transaction, NodeName, - "event-channel", "%d", Dev->EventChannel); - if (Status != XENSTORE_STATUS_SUCCESS) { - DEBUG ((EFI_D_ERROR, "XenPvBlk: Failed to write event-channel.\n")); - goto AbortTransaction; - } - Status = XenBusIo->XsPrintf (XenBusIo, &Transaction, NodeName, - "protocol", "%a", XEN_IO_PROTO_ABI_NATIVE); - if (Status != XENSTORE_STATUS_SUCCESS) { - DEBUG ((EFI_D_ERROR, "XenPvBlk: Failed to write protocol.\n")); - goto AbortTransaction; - } - - Status = XenBusIo->SetState (XenBusIo, &Transaction, XenbusStateConnected); - if (Status != XENSTORE_STATUS_SUCCESS) { - DEBUG ((EFI_D_ERROR, "XenPvBlk: Failed to switch state.\n")); - goto AbortTransaction; - } - - Status = XenBusIo->XsTransactionEnd (XenBusIo, &Transaction, FALSE); - if (Status == XENSTORE_STATUS_EAGAIN) { - goto Again; - } - - XenBusIo->RegisterWatchBackend (XenBusIo, "state", &Dev->StateWatchToken); - - // - // Waiting for backend - // - Status = XenPvBlkWaitForBackendState (Dev, XenbusStateConnected, &State); - if (Status != XENSTORE_STATUS_SUCCESS) { - DEBUG ((EFI_D_ERROR, - "XenPvBlk: backend for %a/%d not available, rc=%d state=%d\n", - XenBusIo->Type, XenBusIo->DeviceId, Status, State)); - goto Error2; - } - - Status = XenBusReadUint64 (XenBusIo, "info", TRUE, &Value); - if (Status != XENSTORE_STATUS_SUCCESS || Value > MAX_UINT32) { - goto Error2; - } - Dev->MediaInfo.VDiskInfo = (UINT32)Value; - if (Dev->MediaInfo.VDiskInfo & VDISK_READONLY) { - Dev->MediaInfo.ReadWrite = FALSE; - } else { - Dev->MediaInfo.ReadWrite = TRUE; - } - - Status = XenBusReadUint64 (XenBusIo, "sectors", TRUE, &Dev->MediaInfo.Sectors); - if (Status != XENSTORE_STATUS_SUCCESS) { - goto Error2; - } - - Status = XenBusReadUint64 (XenBusIo, "sector-size", TRUE, &Value); - if (Status != XENSTORE_STATUS_SUCCESS || Value > MAX_UINT32) { - goto Error2; - } - if ((UINT32)Value % 512 != 0) { - // - // This is not supported by the driver. - // - DEBUG ((EFI_D_ERROR, "XenPvBlk: Unsupported sector-size value %Lu, " - "it must be a multiple of 512\n", Value)); - goto Error2; - } - Dev->MediaInfo.SectorSize = (UINT32)Value; - - // Default value - Value = 0; - XenBusReadUint64 (XenBusIo, "feature-barrier", TRUE, &Value); - if (Value == 1) { - Dev->MediaInfo.FeatureBarrier = TRUE; - } else { - Dev->MediaInfo.FeatureBarrier = FALSE; - } - - // Default value - Value = 0; - XenBusReadUint64 (XenBusIo, "feature-flush-cache", TRUE, &Value); - if (Value == 1) { - Dev->MediaInfo.FeatureFlushCache = TRUE; - } else { - Dev->MediaInfo.FeatureFlushCache = FALSE; - } - - DEBUG ((EFI_D_INFO, "XenPvBlk: New disk with %ld sectors of %d bytes\n", - Dev->MediaInfo.Sectors, Dev->MediaInfo.SectorSize)); - - *DevPtr = Dev; - return EFI_SUCCESS; - -Error2: - XenBusIo->UnregisterWatch (XenBusIo, Dev->StateWatchToken); - XenBusIo->XsRemove (XenBusIo, XST_NIL, "ring-ref"); - XenBusIo->XsRemove (XenBusIo, XST_NIL, "event-channel"); - XenBusIo->XsRemove (XenBusIo, XST_NIL, "protocol"); - goto Error; -AbortTransaction: - XenBusIo->XsTransactionEnd (XenBusIo, &Transaction, TRUE); -Error: - XenPvBlockFree (Dev); - return EFI_DEVICE_ERROR; -} - -VOID -XenPvBlockFrontShutdown ( - IN XEN_BLOCK_FRONT_DEVICE *Dev - ) -{ - XENBUS_PROTOCOL *XenBusIo = Dev->XenBusIo; - XENSTORE_STATUS Status; - UINT64 Value; - - XenPvBlockSync (Dev); - - Status = XenBusIo->SetState (XenBusIo, XST_NIL, XenbusStateClosing); - if (Status != XENSTORE_STATUS_SUCCESS) { - DEBUG ((EFI_D_ERROR, - "XenPvBlk: error while changing state to Closing: %d\n", - Status)); - goto Close; - } - - Status = XenPvBlkWaitForBackendState (Dev, XenbusStateClosing, NULL); - if (Status != XENSTORE_STATUS_SUCCESS) { - DEBUG ((EFI_D_ERROR, - "XenPvBlk: error while waiting for closing backend state: %d\n", - Status)); - goto Close; - } - - Status = XenBusIo->SetState (XenBusIo, XST_NIL, XenbusStateClosed); - if (Status != XENSTORE_STATUS_SUCCESS) { - DEBUG ((EFI_D_ERROR, - "XenPvBlk: error while changing state to Closed: %d\n", - Status)); - goto Close; - } - - Status = XenPvBlkWaitForBackendState (Dev, XenbusStateClosed, NULL); - if (Status != XENSTORE_STATUS_SUCCESS) { - DEBUG ((EFI_D_ERROR, - "XenPvBlk: error while waiting for closed backend state: %d\n", - Status)); - goto Close; - } - - Status = XenBusIo->SetState (XenBusIo, XST_NIL, XenbusStateInitialising); - if (Status != XENSTORE_STATUS_SUCCESS) { - DEBUG ((EFI_D_ERROR, - "XenPvBlk: error while changing state to initialising: %d\n", - Status)); - goto Close; - } - - while (TRUE) { - Status = XenBusReadUint64 (XenBusIo, "state", TRUE, &Value); - if (Status != XENSTORE_STATUS_SUCCESS) { - DEBUG ((EFI_D_ERROR, - "XenPvBlk: error while waiting for new backend state: %d\n", - Status)); - goto Close; - } - if (Value <= XenbusStateInitWait || Value >= XenbusStateClosed) { - break; - } - DEBUG ((EFI_D_INFO, - "XenPvBlk: waiting backend state %d, current: %Lu\n", - XenbusStateInitWait, Value)); - XenBusIo->WaitForWatch (XenBusIo, Dev->StateWatchToken); - } - -Close: - XenBusIo->UnregisterWatch (XenBusIo, Dev->StateWatchToken); - XenBusIo->XsRemove (XenBusIo, XST_NIL, "ring-ref"); - XenBusIo->XsRemove (XenBusIo, XST_NIL, "event-channel"); - XenBusIo->XsRemove (XenBusIo, XST_NIL, "protocol"); - - XenPvBlockFree (Dev); -} - -STATIC -VOID -XenPvBlockWaitSlot ( - IN XEN_BLOCK_FRONT_DEVICE *Dev - ) -{ - /* Wait for a slot */ - if (RING_FULL (&Dev->Ring)) { - while (TRUE) { - XenPvBlockAsyncIoPoll (Dev); - if (!RING_FULL (&Dev->Ring)) { - break; - } - /* Really no slot, could wait for an event on Dev->EventChannel. */ - } - } -} - -VOID -XenPvBlockAsyncIo ( - IN OUT XEN_BLOCK_FRONT_IO *IoData, - IN BOOLEAN IsWrite - ) -{ - XEN_BLOCK_FRONT_DEVICE *Dev = IoData->Dev; - XENBUS_PROTOCOL *XenBusIo = Dev->XenBusIo; - blkif_request_t *Request; - RING_IDX RingIndex; - BOOLEAN Notify; - INT32 NumSegments, Index; - UINTN Start, End; - - // Can't io at non-sector-aligned location - ASSERT(!(IoData->Sector & ((Dev->MediaInfo.SectorSize / 512) - 1))); - // Can't io non-sector-sized amounts - ASSERT(!(IoData->Size & (Dev->MediaInfo.SectorSize - 1))); - // Can't io non-sector-aligned buffer - ASSERT(!((UINTN) IoData->Buffer & (Dev->MediaInfo.SectorSize - 1))); - - Start = (UINTN) IoData->Buffer & ~EFI_PAGE_MASK; - End = ((UINTN) IoData->Buffer + IoData->Size + EFI_PAGE_SIZE - 1) & ~EFI_PAGE_MASK; - IoData->NumRef = NumSegments = (INT32)((End - Start) / EFI_PAGE_SIZE); - - ASSERT (NumSegments <= BLKIF_MAX_SEGMENTS_PER_REQUEST); - - XenPvBlockWaitSlot (Dev); - RingIndex = Dev->Ring.req_prod_pvt; - Request = RING_GET_REQUEST (&Dev->Ring, RingIndex); - - Request->operation = IsWrite ? BLKIF_OP_WRITE : BLKIF_OP_READ; - Request->nr_segments = (UINT8)NumSegments; - Request->handle = Dev->DeviceId; - Request->id = (UINTN) IoData; - Request->sector_number = IoData->Sector; - - for (Index = 0; Index < NumSegments; Index++) { - Request->seg[Index].first_sect = 0; - Request->seg[Index].last_sect = EFI_PAGE_SIZE / 512 - 1; - } - Request->seg[0].first_sect = (UINT8)(((UINTN) IoData->Buffer & EFI_PAGE_MASK) / 512); - Request->seg[NumSegments - 1].last_sect = - (UINT8)((((UINTN) IoData->Buffer + IoData->Size - 1) & EFI_PAGE_MASK) / 512); - for (Index = 0; Index < NumSegments; Index++) { - UINTN Data = Start + Index * EFI_PAGE_SIZE; - XenBusIo->GrantAccess (XenBusIo, Dev->DomainId, - Data >> EFI_PAGE_SHIFT, IsWrite, - &Request->seg[Index].gref); - IoData->GrantRef[Index] = Request->seg[Index].gref; - } - - Dev->Ring.req_prod_pvt = RingIndex + 1; - - MemoryFence (); - RING_PUSH_REQUESTS_AND_CHECK_NOTIFY (&Dev->Ring, Notify); - - if (Notify) { - UINT32 ReturnCode; - ReturnCode = XenBusIo->EventChannelNotify (XenBusIo, Dev->EventChannel); - if (ReturnCode != 0) { - DEBUG ((EFI_D_ERROR, - "XenPvBlk: Unexpected return value from EventChannelNotify: %d\n", - ReturnCode)); - } - } -} - -EFI_STATUS -XenPvBlockIo ( - IN OUT XEN_BLOCK_FRONT_IO *IoData, - IN BOOLEAN IsWrite - ) -{ - // - // Status value that correspond to an IO in progress. - // - IoData->Status = EFI_ALREADY_STARTED; - XenPvBlockAsyncIo (IoData, IsWrite); - - while (IoData->Status == EFI_ALREADY_STARTED) { - XenPvBlockAsyncIoPoll (IoData->Dev); - } - - return IoData->Status; -} - -STATIC -VOID -XenPvBlockPushOperation ( - IN XEN_BLOCK_FRONT_DEVICE *Dev, - IN UINT8 Operation, - IN UINT64 Id - ) -{ - INT32 Index; - blkif_request_t *Request; - BOOLEAN Notify; - - XenPvBlockWaitSlot (Dev); - Index = Dev->Ring.req_prod_pvt; - Request = RING_GET_REQUEST(&Dev->Ring, Index); - Request->operation = Operation; - Request->nr_segments = 0; - Request->handle = Dev->DeviceId; - Request->id = Id; - /* Not needed anyway, but the backend will check it */ - Request->sector_number = 0; - Dev->Ring.req_prod_pvt = Index + 1; - MemoryFence (); - RING_PUSH_REQUESTS_AND_CHECK_NOTIFY (&Dev->Ring, Notify); - if (Notify) { - XENBUS_PROTOCOL *XenBusIo = Dev->XenBusIo; - UINT32 ReturnCode; - ReturnCode = XenBusIo->EventChannelNotify (XenBusIo, Dev->EventChannel); - if (ReturnCode != 0) { - DEBUG ((EFI_D_ERROR, - "XenPvBlk: Unexpected return value from EventChannelNotify: %d\n", - ReturnCode)); - } - } -} - -VOID -XenPvBlockSync ( - IN XEN_BLOCK_FRONT_DEVICE *Dev - ) -{ - if (Dev->MediaInfo.ReadWrite) { - if (Dev->MediaInfo.FeatureBarrier) { - XenPvBlockPushOperation (Dev, BLKIF_OP_WRITE_BARRIER, 0); - } - - if (Dev->MediaInfo.FeatureFlushCache) { - XenPvBlockPushOperation (Dev, BLKIF_OP_FLUSH_DISKCACHE, 0); - } - } - - /* Note: This won't finish if another thread enqueues requests. */ - while (TRUE) { - XenPvBlockAsyncIoPoll (Dev); - if (RING_FREE_REQUESTS (&Dev->Ring) == RING_SIZE (&Dev->Ring)) { - break; - } - } -} - -VOID -XenPvBlockAsyncIoPoll ( - IN XEN_BLOCK_FRONT_DEVICE *Dev - ) -{ - RING_IDX ProducerIndex, ConsumerIndex; - blkif_response_t *Response; - INT32 More; - - do { - ProducerIndex = Dev->Ring.sring->rsp_prod; - /* Ensure we see queued responses up to 'ProducerIndex'. */ - MemoryFence (); - ConsumerIndex = Dev->Ring.rsp_cons; - - while (ConsumerIndex != ProducerIndex) { - XEN_BLOCK_FRONT_IO *IoData = NULL; - INT16 Status; - - Response = RING_GET_RESPONSE (&Dev->Ring, ConsumerIndex); - - IoData = (VOID *) (UINTN) Response->id; - Status = Response->status; - - switch (Response->operation) { - case BLKIF_OP_READ: - case BLKIF_OP_WRITE: - { - INT32 Index; - - if (Status != BLKIF_RSP_OKAY) { - DEBUG ((EFI_D_ERROR, - "XenPvBlk: " - "%a error %d on %a at sector %Lx, num bytes %Lx\n", - Response->operation == BLKIF_OP_READ ? "read" : "write", - Status, IoData->Dev->NodeName, - (UINT64)IoData->Sector, - (UINT64)IoData->Size)); - } - - for (Index = 0; Index < IoData->NumRef; Index++) { - Dev->XenBusIo->GrantEndAccess (Dev->XenBusIo, IoData->GrantRef[Index]); - } - - break; - } - - case BLKIF_OP_WRITE_BARRIER: - if (Status != BLKIF_RSP_OKAY) { - DEBUG ((EFI_D_ERROR, "XenPvBlk: write barrier error %d\n", Status)); - } - break; - case BLKIF_OP_FLUSH_DISKCACHE: - if (Status != BLKIF_RSP_OKAY) { - DEBUG ((EFI_D_ERROR, "XenPvBlk: flush error %d\n", Status)); - } - break; - - default: - DEBUG ((EFI_D_ERROR, - "XenPvBlk: unrecognized block operation %d response (status %d)\n", - Response->operation, Status)); - break; - } - - Dev->Ring.rsp_cons = ++ConsumerIndex; - if (IoData != NULL) { - IoData->Status = Status ? EFI_DEVICE_ERROR : EFI_SUCCESS; - } - if (Dev->Ring.rsp_cons != ConsumerIndex) { - /* We reentered, we must not continue here */ - break; - } - } - - RING_FINAL_CHECK_FOR_RESPONSES (&Dev->Ring, More); - } while (More != 0); -} diff --git a/OvmfPkg/XenPvBlkDxe/BlockFront.h b/OvmfPkg/XenPvBlkDxe/BlockFront.h deleted file mode 100644 index 867b39f044..0000000000 --- a/OvmfPkg/XenPvBlkDxe/BlockFront.h +++ /dev/null @@ -1,101 +0,0 @@ -/** @file - BlockFront functions and types declarations. - - Copyright (C) 2014, Citrix Ltd. - - This program and the accompanying materials - are licensed and made available under the terms and conditions of the BSD License - which accompanies this distribution. The full text of the license may be found at - http://opensource.org/licenses/bsd-license.php - - THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, - WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. - -**/ -#include "XenPvBlkDxe.h" - -#include -#include - -typedef struct _XEN_BLOCK_FRONT_DEVICE XEN_BLOCK_FRONT_DEVICE; -typedef struct _XEN_BLOCK_FRONT_IO XEN_BLOCK_FRONT_IO; - -struct _XEN_BLOCK_FRONT_IO -{ - XEN_BLOCK_FRONT_DEVICE *Dev; - UINT8 *Buffer; - UINTN Size; - UINTN Sector; ///< 512 bytes sector. - - grant_ref_t GrantRef[BLKIF_MAX_SEGMENTS_PER_REQUEST]; - INT32 NumRef; - - EFI_STATUS Status; -}; - -typedef struct -{ - UINT64 Sectors; - UINT32 SectorSize; - UINT32 VDiskInfo; - BOOLEAN ReadWrite; - BOOLEAN CdRom; - BOOLEAN FeatureBarrier; - BOOLEAN FeatureFlushCache; -} XEN_BLOCK_FRONT_MEDIA_INFO; - -#define XEN_BLOCK_FRONT_SIGNATURE SIGNATURE_32 ('X', 'p', 'v', 'B') -struct _XEN_BLOCK_FRONT_DEVICE { - UINT32 Signature; - EFI_BLOCK_IO_PROTOCOL BlockIo; - domid_t DomainId; - - blkif_front_ring_t Ring; - grant_ref_t RingRef; - evtchn_port_t EventChannel; - blkif_vdev_t DeviceId; - - CONST CHAR8 *NodeName; - XEN_BLOCK_FRONT_MEDIA_INFO MediaInfo; - - VOID *StateWatchToken; - - XENBUS_PROTOCOL *XenBusIo; -}; - -#define XEN_BLOCK_FRONT_FROM_BLOCK_IO(b) \ - CR (b, XEN_BLOCK_FRONT_DEVICE, BlockIo, XEN_BLOCK_FRONT_SIGNATURE) - -EFI_STATUS -XenPvBlockFrontInitialization ( - IN XENBUS_PROTOCOL *XenBusIo, - IN CONST CHAR8 *NodeName, - OUT XEN_BLOCK_FRONT_DEVICE **DevPtr - ); - -VOID -XenPvBlockFrontShutdown ( - IN XEN_BLOCK_FRONT_DEVICE *Dev - ); - -VOID -XenPvBlockAsyncIo ( - IN OUT XEN_BLOCK_FRONT_IO *IoData, - IN BOOLEAN IsWrite - ); - -EFI_STATUS -XenPvBlockIo ( - IN OUT XEN_BLOCK_FRONT_IO *IoData, - IN BOOLEAN IsWrite - ); - -VOID -XenPvBlockAsyncIoPoll ( - IN XEN_BLOCK_FRONT_DEVICE *Dev - ); - -VOID -XenPvBlockSync ( - IN XEN_BLOCK_FRONT_DEVICE *Dev - ); diff --git a/OvmfPkg/XenPvBlkDxe/BlockIo.c b/OvmfPkg/XenPvBlkDxe/BlockIo.c deleted file mode 100644 index 70bf32cab0..0000000000 --- a/OvmfPkg/XenPvBlkDxe/BlockIo.c +++ /dev/null @@ -1,276 +0,0 @@ -/** @file - BlockIo implementation for Xen PV Block driver. - - This file is implementing the interface between the actual driver in - BlockFront.c to the BlockIo protocol. - - Copyright (C) 2014, Citrix Ltd. - - This program and the accompanying materials - are licensed and made available under the terms and conditions of the BSD License - which accompanies this distribution. The full text of the license may be found at - http://opensource.org/licenses/bsd-license.php - - THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, - WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. - -**/ - -#include "XenPvBlkDxe.h" - -#include "BlockFront.h" - -/// -/// Block I/O Media structure -/// -GLOBAL_REMOVE_IF_UNREFERENCED -EFI_BLOCK_IO_MEDIA gXenPvBlkDxeBlockIoMedia = { - 0, // MediaId - FALSE, // RemovableMedia - FALSE, // MediaPresent - FALSE, // LogicalPartition - TRUE, // ReadOnly - FALSE, // WriteCaching - 512, // BlockSize - 512, // IoAlign, BlockFront does not support less than 512 bits-aligned. - 0, // LastBlock - 0, // LowestAlignedLba - 0, // LogicalBlocksPerPhysicalBlock - 0 // OptimalTransferLengthGranularity -}; - -/// -/// Block I/O Protocol instance -/// -GLOBAL_REMOVE_IF_UNREFERENCED -EFI_BLOCK_IO_PROTOCOL gXenPvBlkDxeBlockIo = { - EFI_BLOCK_IO_PROTOCOL_REVISION3, // Revision - &gXenPvBlkDxeBlockIoMedia, // Media - XenPvBlkDxeBlockIoReset, // Reset - XenPvBlkDxeBlockIoReadBlocks, // ReadBlocks - XenPvBlkDxeBlockIoWriteBlocks, // WriteBlocks - XenPvBlkDxeBlockIoFlushBlocks // FlushBlocks -}; - - - - -/** - Read/Write BufferSize bytes from Lba into Buffer. - - This function is commun to XenPvBlkDxeBlockIoReadBlocks and - XenPvBlkDxeBlockIoWriteBlocks. - - @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/write to. - @param BufferSize Size of Buffer, must be a multiple of device block size. - @param Buffer A pointer to the destination/source buffer for the data. - @param IsWrite Indicate if the operation is write or read. - - @return See description of XenPvBlkDxeBlockIoReadBlocks and - XenPvBlkDxeBlockIoWriteBlocks. -**/ -STATIC -EFI_STATUS -XenPvBlkDxeBlockIoReadWriteBlocks ( - IN EFI_BLOCK_IO_PROTOCOL *This, - IN UINT32 MediaId, - IN EFI_LBA Lba, - IN UINTN BufferSize, - IN OUT VOID *Buffer, - IN BOOLEAN IsWrite - ) -{ - XEN_BLOCK_FRONT_IO IoData; - EFI_BLOCK_IO_MEDIA *Media = This->Media; - UINTN Sector; - EFI_STATUS Status; - - if (Buffer == NULL) { - return EFI_INVALID_PARAMETER; - } - if (BufferSize == 0) { - return EFI_SUCCESS; - } - - if (BufferSize % Media->BlockSize != 0) { - DEBUG ((EFI_D_ERROR, "XenPvBlkDxe: Bad buffer size: 0x%Lx\n", - (UINT64)BufferSize)); - return EFI_BAD_BUFFER_SIZE; - } - - if (Lba > Media->LastBlock || - (BufferSize / Media->BlockSize) - 1 > Media->LastBlock - Lba) { - DEBUG ((EFI_D_ERROR, - "XenPvBlkDxe: %a with invalid LBA: 0x%Lx, size: 0x%Lx\n", - IsWrite ? "Write" : "Read", Lba, (UINT64)BufferSize)); - return EFI_INVALID_PARAMETER; - } - - if (IsWrite && Media->ReadOnly) { - return EFI_WRITE_PROTECTED; - } - - if ((Media->IoAlign > 1) && (UINTN)Buffer & (Media->IoAlign - 1)) { - // - // Grub2 does not appear to respect IoAlign of 512, so reallocate the - // buffer here. - // - VOID *NewBuffer; - - // - // Try again with a properly aligned buffer. - // - NewBuffer = AllocateAlignedPages((BufferSize + EFI_PAGE_SIZE) / EFI_PAGE_SIZE, - Media->IoAlign); - if (!IsWrite) { - Status = XenPvBlkDxeBlockIoReadBlocks (This, MediaId, - Lba, BufferSize, NewBuffer); - CopyMem (Buffer, NewBuffer, BufferSize); - } else { - CopyMem (NewBuffer, Buffer, BufferSize); - Status = XenPvBlkDxeBlockIoWriteBlocks (This, MediaId, - Lba, BufferSize, NewBuffer); - } - FreeAlignedPages (NewBuffer, (BufferSize + EFI_PAGE_SIZE) / EFI_PAGE_SIZE); - return Status; - } - - IoData.Dev = XEN_BLOCK_FRONT_FROM_BLOCK_IO (This); - Sector = (UINTN)MultU64x32 (Lba, Media->BlockSize / 512); - - while (BufferSize > 0) { - if (((UINTN)Buffer & EFI_PAGE_MASK) == 0) { - IoData.Size = MIN (BLKIF_MAX_SEGMENTS_PER_REQUEST * EFI_PAGE_SIZE, - BufferSize); - } else { - IoData.Size = MIN ((BLKIF_MAX_SEGMENTS_PER_REQUEST - 1) * EFI_PAGE_SIZE, - BufferSize); - } - - IoData.Buffer = Buffer; - IoData.Sector = Sector; - BufferSize -= IoData.Size; - Buffer = (VOID*) ((UINTN) Buffer + IoData.Size); - Sector += IoData.Size / 512; - Status = XenPvBlockIo (&IoData, IsWrite); - if (EFI_ERROR (Status)) { - DEBUG ((EFI_D_ERROR, "XenPvBlkDxe: Error during %a operation.\n", - IsWrite ? "write" : "read")); - return Status; - } - } - 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 -EFIAPI -XenPvBlkDxeBlockIoReadBlocks ( - IN EFI_BLOCK_IO_PROTOCOL *This, - IN UINT32 MediaId, - IN EFI_LBA Lba, - IN UINTN BufferSize, - OUT VOID *Buffer - ) -{ - return XenPvBlkDxeBlockIoReadWriteBlocks (This, - MediaId, Lba, BufferSize, Buffer, FALSE); -} - -/** - 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 -XenPvBlkDxeBlockIoWriteBlocks ( - IN EFI_BLOCK_IO_PROTOCOL *This, - IN UINT32 MediaId, - IN EFI_LBA Lba, - IN UINTN BufferSize, - IN VOID *Buffer - ) -{ - return XenPvBlkDxeBlockIoReadWriteBlocks (This, - MediaId, Lba, BufferSize, Buffer, TRUE); -} - -/** - 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 -XenPvBlkDxeBlockIoFlushBlocks ( - IN EFI_BLOCK_IO_PROTOCOL *This - ) -{ - XenPvBlockSync (XEN_BLOCK_FRONT_FROM_BLOCK_IO (This)); - return EFI_SUCCESS; -} - -/** - Reset the block device hardware. - - @param[in] This Indicates a pointer to the calling context. - @param[in] ExtendedVerification Not used. - - @retval EFI_SUCCESS The device was reset. - -**/ -EFI_STATUS -EFIAPI -XenPvBlkDxeBlockIoReset ( - IN EFI_BLOCK_IO_PROTOCOL *This, - IN BOOLEAN ExtendedVerification - ) -{ - // - // Since the initialization of the devices is done, then the device is - // working correctly. - // - return EFI_SUCCESS; -} diff --git a/OvmfPkg/XenPvBlkDxe/BlockIo.h b/OvmfPkg/XenPvBlkDxe/BlockIo.h deleted file mode 100644 index a05f27c813..0000000000 --- a/OvmfPkg/XenPvBlkDxe/BlockIo.h +++ /dev/null @@ -1,108 +0,0 @@ -/** @file - BlockIo function declaration for Xen PV block driver. - - Copyright (C) 2014, Citrix Ltd. - - This program and the accompanying materials - are licensed and made available under the terms and conditions of the BSD License - which accompanies this distribution. The full text of the license may be found at - http://opensource.org/licenses/bsd-license.php - - THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, - WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. - -**/ - -/** - 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 -EFIAPI -XenPvBlkDxeBlockIoReadBlocks ( - IN EFI_BLOCK_IO_PROTOCOL *This, - IN UINT32 MediaId, - IN EFI_LBA Lba, - IN UINTN BufferSize, - OUT VOID *Buffer - ); - -/** - 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 -XenPvBlkDxeBlockIoWriteBlocks ( - IN EFI_BLOCK_IO_PROTOCOL *This, - IN UINT32 MediaId, - IN EFI_LBA Lba, - IN UINTN BufferSize, - IN VOID *Buffer - ); - -/** - 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 -XenPvBlkDxeBlockIoFlushBlocks ( - IN EFI_BLOCK_IO_PROTOCOL *This - ); - -/** - Reset the block device hardware. - - @param[in] This Indicates a pointer to the calling context. - @param[in] ExtendedVerification Not used. - - @retval EFI_SUCCESS The device was reset. - -**/ -EFI_STATUS -EFIAPI -XenPvBlkDxeBlockIoReset ( - IN EFI_BLOCK_IO_PROTOCOL *This, - IN BOOLEAN ExtendedVerification - ); - -extern EFI_BLOCK_IO_MEDIA gXenPvBlkDxeBlockIoMedia; -extern EFI_BLOCK_IO_PROTOCOL gXenPvBlkDxeBlockIo; diff --git a/OvmfPkg/XenPvBlkDxe/ComponentName.c b/OvmfPkg/XenPvBlkDxe/ComponentName.c deleted file mode 100644 index 752aaf6233..0000000000 --- a/OvmfPkg/XenPvBlkDxe/ComponentName.c +++ /dev/null @@ -1,176 +0,0 @@ -/** @file - Component Name functions implementation for XenPvBlk driver. - - Copyright (C) 2014, Citrix Ltd. - - This program and the accompanying materials - are licensed and made available under the terms and conditions of the BSD License - which accompanies this distribution. The full text of the license may be found at - http://opensource.org/licenses/bsd-license.php - - THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, - WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. - -**/ - -#include "XenPvBlkDxe.h" - -/// -/// Component Name Protocol instance -/// -GLOBAL_REMOVE_IF_UNREFERENCED -EFI_COMPONENT_NAME_PROTOCOL gXenPvBlkDxeComponentName = { - (EFI_COMPONENT_NAME_GET_DRIVER_NAME) XenPvBlkDxeComponentNameGetDriverName, - (EFI_COMPONENT_NAME_GET_CONTROLLER_NAME)XenPvBlkDxeComponentNameGetControllerName, - "eng" -}; - -/// -/// Component Name 2 Protocol instance -/// -GLOBAL_REMOVE_IF_UNREFERENCED -EFI_COMPONENT_NAME2_PROTOCOL gXenPvBlkDxeComponentName2 = { - XenPvBlkDxeComponentNameGetDriverName, - XenPvBlkDxeComponentNameGetControllerName, - "en" -}; - -/// -/// Table of driver names -/// -GLOBAL_REMOVE_IF_UNREFERENCED -EFI_UNICODE_STRING_TABLE mXenPvBlkDxeDriverNameTable[] = { - { "eng;en", (CHAR16 *)L"Xen PV Block Driver" }, - { NULL, NULL } -}; - -/// -/// Table of controller names -/// -GLOBAL_REMOVE_IF_UNREFERENCED -EFI_UNICODE_STRING_TABLE mXenPvBlkDxeControllerNameTable[] = { - { "eng;en", (CHAR16 *)L"Xen PV Block Device" }, - { NULL, NULL } -}; - -/** - Retrieves a Unicode string that is the user-readable name of the EFI Driver. - - @param This A pointer to the EFI_COMPONENT_NAME_PROTOCOL instance. - @param Language A pointer to a three-character ISO 639-2 language identifier. - This is the language of the driver name that that the caller - is requesting, and it must match one of the languages specified - in SupportedLanguages. The number of languages supported by a - driver is up to the driver writer. - @param DriverName A pointer to the Unicode string to return. This Unicode string - is the name of the driver specified by This in the language - specified by Language. - - @retval EFI_SUCCESS The Unicode string for the Driver specified by This - and the language specified by Language was returned - in DriverName. - @retval EFI_INVALID_PARAMETER Language is NULL. - @retval EFI_INVALID_PARAMETER DriverName is NULL. - @retval EFI_UNSUPPORTED The driver specified by This does not support the - language specified by Language. - -**/ -EFI_STATUS -EFIAPI -XenPvBlkDxeComponentNameGetDriverName ( - IN EFI_COMPONENT_NAME2_PROTOCOL *This, - IN CHAR8 *Language, - OUT CHAR16 **DriverName - ) -{ - return LookupUnicodeString2 ( - Language, - This->SupportedLanguages, - mXenPvBlkDxeDriverNameTable, - DriverName, - (BOOLEAN)(This != &gXenPvBlkDxeComponentName2) - ); -} - -/** - Retrieves a Unicode string that is the user readable name of the controller - that is being managed by an EFI Driver. - - @param This A pointer to the EFI_COMPONENT_NAME_PROTOCOL instance. - @param ControllerHandle The handle of a controller that the driver specified by - This is managing. This handle specifies the controller - whose name is to be returned. - @param ChildHandle The handle of the child controller to retrieve the name - of. This is an optional parameter that may be NULL. It - will be NULL for device drivers. It will also be NULL - for a bus drivers that wish to retrieve the name of the - bus controller. It will not be NULL for a bus driver - that wishes to retrieve the name of a child controller. - @param Language A pointer to a three character ISO 639-2 language - identifier. This is the language of the controller name - that the caller is requesting, and it must match one - of the languages specified in SupportedLanguages. The - number of languages supported by a driver is up to the - driver writer. - @param ControllerName A pointer to the Unicode string to return. This Unicode - string is the name of the controller specified by - ControllerHandle and ChildHandle in the language specified - by Language, from the point of view of the driver specified - by This. - - @retval EFI_SUCCESS The Unicode string for the user-readable name in the - language specified by Language for the driver - specified by This was returned in DriverName. - @retval EFI_INVALID_PARAMETER ControllerHandle is NULL. - @retval EFI_INVALID_PARAMETER ChildHandle is not NULL and it is not a valid EFI_HANDLE. - @retval EFI_INVALID_PARAMETER Language is NULL. - @retval EFI_INVALID_PARAMETER ControllerName is NULL. - @retval EFI_UNSUPPORTED The driver specified by This is not currently managing - the controller specified by ControllerHandle and - ChildHandle. - @retval EFI_UNSUPPORTED The driver specified by This does not support the - language specified by Language. - -**/ -EFI_STATUS -EFIAPI -XenPvBlkDxeComponentNameGetControllerName ( - IN EFI_COMPONENT_NAME2_PROTOCOL *This, - IN EFI_HANDLE ControllerHandle, - IN EFI_HANDLE ChildHandle OPTIONAL, - IN CHAR8 *Language, - OUT CHAR16 **ControllerName - ) -{ - EFI_STATUS Status; - - // - // ChildHandle must be NULL for a Device Driver - // - if (ChildHandle != NULL) { - return EFI_UNSUPPORTED; - } - - // - // Make sure this driver is currently managing ControllerHandle - // - Status = EfiTestManagedDevice ( - ControllerHandle, - gXenPvBlkDxeDriverBinding.DriverBindingHandle, - &gXenBusProtocolGuid - ); - if (EFI_ERROR (Status)) { - return Status; - } - - // - // Lookup name of controller specified by ControllerHandle - // - return LookupUnicodeString2 ( - Language, - This->SupportedLanguages, - mXenPvBlkDxeControllerNameTable, - ControllerName, - (BOOLEAN)(This != &gXenPvBlkDxeComponentName2) - ); -} diff --git a/OvmfPkg/XenPvBlkDxe/ComponentName.h b/OvmfPkg/XenPvBlkDxe/ComponentName.h deleted file mode 100644 index 03724c5430..0000000000 --- a/OvmfPkg/XenPvBlkDxe/ComponentName.h +++ /dev/null @@ -1,94 +0,0 @@ -/** @file - Component Name functions declaration for XenPvBlk driver. - - Copyright (C) 2014, Citrix Ltd. - - This program and the accompanying materials - are licensed and made available under the terms and conditions of the BSD License - which accompanies this distribution. The full text of the license may be found at - http://opensource.org/licenses/bsd-license.php - - THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, - WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. - -**/ - -/** - Retrieves a Unicode string that is the user-readable name of the EFI Driver. - - @param This A pointer to the EFI_COMPONENT_NAME_PROTOCOL instance. - @param Language A pointer to a three-character ISO 639-2 language identifier. - This is the language of the driver name that that the caller - is requesting, and it must match one of the languages specified - in SupportedLanguages. The number of languages supported by a - driver is up to the driver writer. - @param DriverName A pointer to the Unicode string to return. This Unicode string - is the name of the driver specified by This in the language - specified by Language. - - @retval EFI_SUCCESS The Unicode string for the Driver specified by This - and the language specified by Language was returned - in DriverName. - @retval EFI_INVALID_PARAMETER Language is NULL. - @retval EFI_INVALID_PARAMETER DriverName is NULL. - @retval EFI_UNSUPPORTED The driver specified by This does not support the - language specified by Language. - -**/ -EFI_STATUS -EFIAPI -XenPvBlkDxeComponentNameGetDriverName ( - IN EFI_COMPONENT_NAME2_PROTOCOL *This, - IN CHAR8 *Language, - OUT CHAR16 **DriverName - ); - -/** - Retrieves a Unicode string that is the user readable name of the controller - that is being managed by an EFI Driver. - - @param This A pointer to the EFI_COMPONENT_NAME_PROTOCOL instance. - @param ControllerHandle The handle of a controller that the driver specified by - This is managing. This handle specifies the controller - whose name is to be returned. - @param ChildHandle The handle of the child controller to retrieve the name - of. This is an optional parameter that may be NULL. It - will be NULL for device drivers. It will also be NULL - for a bus drivers that wish to retrieve the name of the - bus controller. It will not be NULL for a bus driver - that wishes to retrieve the name of a child controller. - @param Language A pointer to a three character ISO 639-2 language - identifier. This is the language of the controller name - that the caller is requesting, and it must match one - of the languages specified in SupportedLanguages. The - number of languages supported by a driver is up to the - driver writer. - @param ControllerName A pointer to the Unicode string to return. This Unicode - string is the name of the controller specified by - ControllerHandle and ChildHandle in the language specified - by Language, from the point of view of the driver specified - by This. - - @retval EFI_SUCCESS The Unicode string for the user-readable name in the - language specified by Language for the driver - specified by This was returned in DriverName. - @retval EFI_INVALID_PARAMETER ControllerHandle is NULL. - @retval EFI_INVALID_PARAMETER ChildHandle is not NULL and it is not a valid EFI_HANDLE. - @retval EFI_INVALID_PARAMETER Language is NULL. - @retval EFI_INVALID_PARAMETER ControllerName is NULL. - @retval EFI_UNSUPPORTED The driver specified by This is not currently managing - the controller specified by ControllerHandle and - ChildHandle. - @retval EFI_UNSUPPORTED The driver specified by This does not support the - language specified by Language. - -**/ -EFI_STATUS -EFIAPI -XenPvBlkDxeComponentNameGetControllerName ( - IN EFI_COMPONENT_NAME2_PROTOCOL *This, - IN EFI_HANDLE ControllerHandle, - IN EFI_HANDLE ChildHandle OPTIONAL, - IN CHAR8 *Language, - OUT CHAR16 **ControllerName - ); diff --git a/OvmfPkg/XenPvBlkDxe/DriverBinding.h b/OvmfPkg/XenPvBlkDxe/DriverBinding.h deleted file mode 100644 index 0d60561004..0000000000 --- a/OvmfPkg/XenPvBlkDxe/DriverBinding.h +++ /dev/null @@ -1,143 +0,0 @@ - -/** @file - Driver Binding functions declaration for XenPvBlk driver. - - Copyright (C) 2014, Citrix Ltd. - - This program and the accompanying materials - are licensed and made available under the terms and conditions of the BSD License - which accompanies this distribution. The full text of the license may be found at - http://opensource.org/licenses/bsd-license.php - - THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, - WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. - -**/ - -/** - Tests to see if this driver supports a given controller. If a child device is provided, - it further tests to see if this driver supports creating a handle for the specified child device. - - This function checks to see if the driver specified by This supports the device specified by - ControllerHandle. Drivers will typically use the device path attached to - ControllerHandle and/or the services from the bus I/O abstraction attached to - ControllerHandle to determine if the driver supports ControllerHandle. This function - may be called many times during platform initialization. In order to reduce boot times, the tests - performed by this function must be very small, and take as little time as possible to execute. This - function must not change the state of any hardware devices, and this function must be aware that the - device specified by ControllerHandle may already be managed by the same driver or a - different driver. This function must match its calls to AllocatePages() with FreePages(), - AllocatePool() with FreePool(), and OpenProtocol() with CloseProtocol(). - Because ControllerHandle may have been previously started by the same driver, if a protocol is - already in the opened state, then it must not be closed with CloseProtocol(). This is required - to guarantee the state of ControllerHandle is not modified by this function. - - @param[in] This A pointer to the EFI_DRIVER_BINDING_PROTOCOL instance. - @param[in] ControllerHandle The handle of the controller to test. This handle - must support a protocol interface that supplies - an I/O abstraction to the driver. - @param[in] RemainingDevicePath A pointer to the remaining portion of a device path. This - parameter is ignored by device drivers, and is optional for bus - drivers. For bus drivers, if this parameter is not NULL, then - the bus driver must determine if the bus controller specified - by ControllerHandle and the child controller specified - by RemainingDevicePath are both supported by this - bus driver. - - @retval EFI_SUCCESS The device specified by ControllerHandle and - RemainingDevicePath is supported by the driver specified by This. - @retval EFI_ALREADY_STARTED The device specified by ControllerHandle and - RemainingDevicePath is already being managed by the driver - specified by This. - @retval EFI_ACCESS_DENIED The device specified by ControllerHandle and - RemainingDevicePath is already being managed by a different - driver or an application that requires exclusive access. - Currently not implemented. - @retval EFI_UNSUPPORTED The device specified by ControllerHandle and - RemainingDevicePath is not supported by the driver specified by This. -**/ -EFI_STATUS -EFIAPI -XenPvBlkDxeDriverBindingSupported ( - IN EFI_DRIVER_BINDING_PROTOCOL *This, - IN EFI_HANDLE ControllerHandle, - IN EFI_DEVICE_PATH_PROTOCOL *RemainingDevicePath OPTIONAL - ); - -/** - Starts a device controller or a bus controller. - - The Start() function is designed to be invoked from the EFI boot service ConnectController(). - As a result, much of the error checking on the parameters to Start() has been moved into this - common boot service. It is legal to call Start() from other locations, - but the following calling restrictions must be followed, or the system behavior will not be deterministic. - 1. ControllerHandle must be a valid EFI_HANDLE. - 2. If RemainingDevicePath is not NULL, then it must be a pointer to a naturally aligned - EFI_DEVICE_PATH_PROTOCOL. - 3. Prior to calling Start(), the Supported() function for the driver specified by This must - have been called with the same calling parameters, and Supported() must have returned EFI_SUCCESS. - - @param[in] This A pointer to the EFI_DRIVER_BINDING_PROTOCOL instance. - @param[in] ControllerHandle The handle of the controller to start. This handle - must support a protocol interface that supplies - an I/O abstraction to the driver. - @param[in] RemainingDevicePath A pointer to the remaining portion of a device path. This - parameter is ignored by device drivers, and is optional for bus - drivers. For a bus driver, if this parameter is NULL, then handles - for all the children of Controller are created by this driver. - If this parameter is not NULL and the first Device Path Node is - not the End of Device Path Node, then only the handle for the - child device specified by the first Device Path Node of - RemainingDevicePath is created by this driver. - If the first Device Path Node of RemainingDevicePath is - the End of Device Path Node, no child handle is created by this - driver. - - @retval EFI_SUCCESS The device was started. - @retval EFI_DEVICE_ERROR The device could not be started due to a device error.Currently not implemented. - @retval EFI_OUT_OF_RESOURCES The request could not be completed due to a lack of resources. - @retval Others The driver failded to start the device. - -**/ -EFI_STATUS -EFIAPI -XenPvBlkDxeDriverBindingStart ( - IN EFI_DRIVER_BINDING_PROTOCOL *This, - IN EFI_HANDLE ControllerHandle, - IN EFI_DEVICE_PATH_PROTOCOL *RemainingDevicePath OPTIONAL - ); - -/** - Stops a device controller or a bus controller. - - The Stop() function is designed to be invoked from the EFI boot service DisconnectController(). - As a result, much of the error checking on the parameters to Stop() has been moved - into this common boot service. It is legal to call Stop() from other locations, - but the following calling restrictions must be followed, or the system behavior will not be deterministic. - 1. ControllerHandle must be a valid EFI_HANDLE that was used on a previous call to this - same driver's Start() function. - 2. The first NumberOfChildren handles of ChildHandleBuffer must all be a valid - EFI_HANDLE. In addition, all of these handles must have been created in this driver's - Start() function, and the Start() function must have called OpenProtocol() on - ControllerHandle with an Attribute of EFI_OPEN_PROTOCOL_BY_CHILD_CONTROLLER. - - @param[in] This A pointer to the EFI_DRIVER_BINDING_PROTOCOL instance. - @param[in] ControllerHandle A handle to the device being stopped. The handle must - support a bus specific I/O protocol for the driver - to use to stop the device. - @param[in] NumberOfChildren The number of child device handles in ChildHandleBuffer. - @param[in] ChildHandleBuffer An array of child handles to be freed. May be NULL - if NumberOfChildren is 0. - - @retval EFI_SUCCESS The device was stopped. - @retval EFI_DEVICE_ERROR The device could not be stopped due to a device error. - -**/ -EFI_STATUS -EFIAPI -XenPvBlkDxeDriverBindingStop ( - IN EFI_DRIVER_BINDING_PROTOCOL *This, - IN EFI_HANDLE ControllerHandle, - IN UINTN NumberOfChildren, - IN EFI_HANDLE *ChildHandleBuffer OPTIONAL - ); diff --git a/OvmfPkg/XenPvBlkDxe/XenPvBlkDxe.c b/OvmfPkg/XenPvBlkDxe/XenPvBlkDxe.c deleted file mode 100644 index caaa9b4ff4..0000000000 --- a/OvmfPkg/XenPvBlkDxe/XenPvBlkDxe.c +++ /dev/null @@ -1,394 +0,0 @@ -/** @file - This driver produce a BlockIo protocol instance for a Xen PV block device. - - This driver support XenBus protocol of type 'vbd'. Every function that - comsume XenBus protocol are in BlockFront, which the implementation to access - a Xen PV device. The BlockIo implementation is in it's one file and will call - BlockFront functions. - - Copyright (C) 2014, Citrix Ltd. - - This program and the accompanying materials - are licensed and made available under the terms and conditions of the BSD License - which accompanies this distribution. The full text of the license may be found at - http://opensource.org/licenses/bsd-license.php - - THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, - WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. - -**/ - -#include "XenPvBlkDxe.h" - -#include "BlockFront.h" - - -/// -/// Driver Binding Protocol instance -/// -EFI_DRIVER_BINDING_PROTOCOL gXenPvBlkDxeDriverBinding = { - XenPvBlkDxeDriverBindingSupported, - XenPvBlkDxeDriverBindingStart, - XenPvBlkDxeDriverBindingStop, - XEN_PV_BLK_DXE_VERSION, - NULL, - NULL -}; - - -/** - Unloads an image. - - @param ImageHandle Handle that identifies the image to be unloaded. - - @retval EFI_SUCCESS The image has been unloaded. - @retval EFI_INVALID_PARAMETER ImageHandle is not a valid image handle. - -**/ -EFI_STATUS -EFIAPI -XenPvBlkDxeUnload ( - IN EFI_HANDLE ImageHandle - ) -{ - EFI_STATUS Status; - - EFI_HANDLE *HandleBuffer; - UINTN HandleCount; - UINTN Index; - - - // - // Retrieve array of all handles in the handle database - // - Status = gBS->LocateHandleBuffer ( - AllHandles, - NULL, - NULL, - &HandleCount, - &HandleBuffer - ); - if (EFI_ERROR (Status)) { - return Status; - } - - // - // Disconnect the current driver from handles in the handle database - // - for (Index = 0; Index < HandleCount; Index++) { - gBS->DisconnectController (HandleBuffer[Index], gImageHandle, NULL); - } - - // - // Free the array of handles - // - FreePool (HandleBuffer); - - - // - // Uninstall protocols installed in the driver entry point - // - Status = gBS->UninstallMultipleProtocolInterfaces ( - ImageHandle, - &gEfiDriverBindingProtocolGuid, &gXenPvBlkDxeDriverBinding, - &gEfiComponentNameProtocolGuid, &gXenPvBlkDxeComponentName, - &gEfiComponentName2ProtocolGuid, &gXenPvBlkDxeComponentName2, - NULL - ); - if (EFI_ERROR (Status)) { - return Status; - } - - return EFI_SUCCESS; -} - -/** - This is the declaration of an EFI image entry point. This entry point is - the same for UEFI Applications, UEFI OS Loaders, and UEFI Drivers including - both device drivers and bus drivers. - - @param ImageHandle The firmware allocated handle for the UEFI image. - @param SystemTable A pointer to the EFI System Table. - - @retval EFI_SUCCESS The operation completed successfully. - @retval Others An unexpected error occurred. -**/ -EFI_STATUS -EFIAPI -XenPvBlkDxeDriverEntryPoint ( - IN EFI_HANDLE ImageHandle, - IN EFI_SYSTEM_TABLE *SystemTable - ) -{ - EFI_STATUS Status; - - // - // Install UEFI Driver Model protocol(s). - // - Status = EfiLibInstallDriverBindingComponentName2 ( - ImageHandle, - SystemTable, - &gXenPvBlkDxeDriverBinding, - ImageHandle, - &gXenPvBlkDxeComponentName, - &gXenPvBlkDxeComponentName2 - ); - ASSERT_EFI_ERROR (Status); - - return Status; -} - - -/** - Tests to see if this driver supports a given controller. If a child device is provided, - it further tests to see if this driver supports creating a handle for the specified child device. - - This function checks to see if the driver specified by This supports the device specified by - ControllerHandle. Drivers will typically use the device path attached to - ControllerHandle and/or the services from the bus I/O abstraction attached to - ControllerHandle to determine if the driver supports ControllerHandle. This function - may be called many times during platform initialization. In order to reduce boot times, the tests - performed by this function must be very small, and take as little time as possible to execute. This - function must not change the state of any hardware devices, and this function must be aware that the - device specified by ControllerHandle may already be managed by the same driver or a - different driver. This function must match its calls to AllocatePages() with FreePages(), - AllocatePool() with FreePool(), and OpenProtocol() with CloseProtocol(). - Because ControllerHandle may have been previously started by the same driver, if a protocol is - already in the opened state, then it must not be closed with CloseProtocol(). This is required - to guarantee the state of ControllerHandle is not modified by this function. - - @param[in] This A pointer to the EFI_DRIVER_BINDING_PROTOCOL instance. - @param[in] ControllerHandle The handle of the controller to test. This handle - must support a protocol interface that supplies - an I/O abstraction to the driver. - @param[in] RemainingDevicePath A pointer to the remaining portion of a device path. This - parameter is ignored by device drivers, and is optional for bus - drivers. For bus drivers, if this parameter is not NULL, then - the bus driver must determine if the bus controller specified - by ControllerHandle and the child controller specified - by RemainingDevicePath are both supported by this - bus driver. - - @retval EFI_SUCCESS The device specified by ControllerHandle and - RemainingDevicePath is supported by the driver specified by This. - @retval EFI_ALREADY_STARTED The device specified by ControllerHandle and - RemainingDevicePath is already being managed by the driver - specified by This. - @retval EFI_ACCESS_DENIED The device specified by ControllerHandle and - RemainingDevicePath is already being managed by a different - driver or an application that requires exclusive access. - Currently not implemented. - @retval EFI_UNSUPPORTED The device specified by ControllerHandle and - RemainingDevicePath is not supported by the driver specified by This. -**/ -EFI_STATUS -EFIAPI -XenPvBlkDxeDriverBindingSupported ( - IN EFI_DRIVER_BINDING_PROTOCOL *This, - IN EFI_HANDLE ControllerHandle, - IN EFI_DEVICE_PATH_PROTOCOL *RemainingDevicePath OPTIONAL - ) -{ - EFI_STATUS Status; - XENBUS_PROTOCOL *XenBusIo; - - Status = gBS->OpenProtocol ( - ControllerHandle, - &gXenBusProtocolGuid, - (VOID **)&XenBusIo, - This->DriverBindingHandle, - ControllerHandle, - EFI_OPEN_PROTOCOL_BY_DRIVER - ); - if (EFI_ERROR (Status)) { - return Status; - } - if (AsciiStrCmp (XenBusIo->Type, "vbd") == 0) { - Status = EFI_SUCCESS; - } else { - Status = EFI_UNSUPPORTED; - } - - gBS->CloseProtocol (ControllerHandle, &gXenBusProtocolGuid, - This->DriverBindingHandle, ControllerHandle); - - return Status; -} - -/** - Starts a device controller. - - The Start() function is designed to be invoked from the EFI boot service ConnectController(). - As a result, much of the error checking on the parameters to Start() has been moved into this - common boot service. It is legal to call Start() from other locations, - but the following calling restrictions must be followed, or the system behavior will not be deterministic. - 1. ControllerHandle must be a valid EFI_HANDLE. - 2. If RemainingDevicePath is not NULL, then it must be a pointer to a naturally aligned - EFI_DEVICE_PATH_PROTOCOL. - 3. Prior to calling Start(), the Supported() function for the driver specified by This must - have been called with the same calling parameters, and Supported() must have returned EFI_SUCCESS. - - @param[in] This A pointer to the EFI_DRIVER_BINDING_PROTOCOL instance. - @param[in] ControllerHandle The handle of the controller to start. This handle - must support a protocol interface that supplies - an I/O abstraction to the driver. - @param[in] RemainingDevicePath A pointer to the remaining portion of a device path. This - parameter is ignored by device drivers, and is optional for bus - drivers. For a bus driver, if this parameter is NULL, then handles - for all the children of Controller are created by this driver. - If this parameter is not NULL and the first Device Path Node is - not the End of Device Path Node, then only the handle for the - child device specified by the first Device Path Node of - RemainingDevicePath is created by this driver. - If the first Device Path Node of RemainingDevicePath is - the End of Device Path Node, no child handle is created by this - driver. - - @retval EFI_SUCCESS The device was started. - @retval EFI_DEVICE_ERROR The device could not be started due to a device error.Currently not implemented. - @retval EFI_OUT_OF_RESOURCES The request could not be completed due to a lack of resources. - @retval Others The driver failded to start the device. - -**/ -EFI_STATUS -EFIAPI -XenPvBlkDxeDriverBindingStart ( - IN EFI_DRIVER_BINDING_PROTOCOL *This, - IN EFI_HANDLE ControllerHandle, - IN EFI_DEVICE_PATH_PROTOCOL *RemainingDevicePath OPTIONAL - ) -{ - EFI_STATUS Status; - XENBUS_PROTOCOL *XenBusIo; - XEN_BLOCK_FRONT_DEVICE *Dev; - EFI_BLOCK_IO_MEDIA *Media; - - Status = gBS->OpenProtocol ( - ControllerHandle, - &gXenBusProtocolGuid, - (VOID **)&XenBusIo, - This->DriverBindingHandle, - ControllerHandle, - EFI_OPEN_PROTOCOL_BY_DRIVER - ); - if (EFI_ERROR (Status)) { - return Status; - } - - Status = XenPvBlockFrontInitialization (XenBusIo, XenBusIo->Node, &Dev); - if (EFI_ERROR (Status)) { - goto CloseProtocol; - } - - CopyMem (&Dev->BlockIo, &gXenPvBlkDxeBlockIo, sizeof (EFI_BLOCK_IO_PROTOCOL)); - Media = AllocateCopyPool (sizeof (EFI_BLOCK_IO_MEDIA), - &gXenPvBlkDxeBlockIoMedia); - if (Dev->MediaInfo.VDiskInfo & VDISK_REMOVABLE) { - Media->RemovableMedia = TRUE; - } - Media->MediaPresent = TRUE; - Media->ReadOnly = !Dev->MediaInfo.ReadWrite; - if (Dev->MediaInfo.CdRom) { - // - // If it's a cdrom, the blocksize value need to be 2048 for OVMF to - // recognize it as a cdrom: - // MdeModulePkg/Universal/Disk/PartitionDxe/ElTorito.c - // - Media->BlockSize = 2048; - Media->LastBlock = DivU64x32 (Dev->MediaInfo.Sectors, - Media->BlockSize / Dev->MediaInfo.SectorSize) - 1; - } else { - Media->BlockSize = Dev->MediaInfo.SectorSize; - Media->LastBlock = Dev->MediaInfo.Sectors - 1; - } - ASSERT (Media->BlockSize % 512 == 0); - Dev->BlockIo.Media = Media; - - Status = gBS->InstallMultipleProtocolInterfaces ( - &ControllerHandle, - &gEfiBlockIoProtocolGuid, &Dev->BlockIo, - NULL - ); - if (EFI_ERROR (Status)) { - DEBUG ((EFI_D_ERROR, "XenPvBlk: install protocol fail: %r\n", Status)); - goto UninitBlockFront; - } - - return EFI_SUCCESS; - -UninitBlockFront: - FreePool (Media); - XenPvBlockFrontShutdown (Dev); -CloseProtocol: - gBS->CloseProtocol (ControllerHandle, &gXenBusProtocolGuid, - This->DriverBindingHandle, ControllerHandle); - return Status; -} - -/** - Stops a device controller. - - The Stop() function is designed to be invoked from the EFI boot service DisconnectController(). - As a result, much of the error checking on the parameters to Stop() has been moved - into this common boot service. It is legal to call Stop() from other locations, - but the following calling restrictions must be followed, or the system behavior will not be deterministic. - 1. ControllerHandle must be a valid EFI_HANDLE that was used on a previous call to this - same driver's Start() function. - 2. The first NumberOfChildren handles of ChildHandleBuffer must all be a valid - EFI_HANDLE. In addition, all of these handles must have been created in this driver's - Start() function, and the Start() function must have called OpenProtocol() on - ControllerHandle with an Attribute of EFI_OPEN_PROTOCOL_BY_CHILD_CONTROLLER. - - @param[in] This A pointer to the EFI_DRIVER_BINDING_PROTOCOL instance. - @param[in] ControllerHandle A handle to the device being stopped. The handle must - support a bus specific I/O protocol for the driver - to use to stop the device. - @param[in] NumberOfChildren The number of child device handles in ChildHandleBuffer. - @param[in] ChildHandleBuffer An array of child handles to be freed. May be NULL - if NumberOfChildren is 0. - - @retval EFI_SUCCESS The device was stopped. - @retval EFI_DEVICE_ERROR The device could not be stopped due to a device error. - -**/ -EFI_STATUS -EFIAPI -XenPvBlkDxeDriverBindingStop ( - IN EFI_DRIVER_BINDING_PROTOCOL *This, - IN EFI_HANDLE ControllerHandle, - IN UINTN NumberOfChildren, - IN EFI_HANDLE *ChildHandleBuffer OPTIONAL - ) -{ - EFI_BLOCK_IO_PROTOCOL *BlockIo; - XEN_BLOCK_FRONT_DEVICE *Dev; - EFI_BLOCK_IO_MEDIA *Media; - EFI_STATUS Status; - - Status = gBS->OpenProtocol ( - ControllerHandle, &gEfiBlockIoProtocolGuid, - (VOID **)&BlockIo, - This->DriverBindingHandle, ControllerHandle, - EFI_OPEN_PROTOCOL_GET_PROTOCOL - ); - if (EFI_ERROR (Status)) { - return Status; - } - - Status = gBS->UninstallProtocolInterface (ControllerHandle, - &gEfiBlockIoProtocolGuid, BlockIo); - if (EFI_ERROR (Status)) { - return Status; - } - - Media = BlockIo->Media; - Dev = XEN_BLOCK_FRONT_FROM_BLOCK_IO (BlockIo); - XenPvBlockFrontShutdown (Dev); - - FreePool (Media); - - gBS->CloseProtocol (ControllerHandle, &gXenBusProtocolGuid, - This->DriverBindingHandle, ControllerHandle); - - return EFI_SUCCESS; -} diff --git a/OvmfPkg/XenPvBlkDxe/XenPvBlkDxe.h b/OvmfPkg/XenPvBlkDxe/XenPvBlkDxe.h deleted file mode 100644 index c0b62c4f38..0000000000 --- a/OvmfPkg/XenPvBlkDxe/XenPvBlkDxe.h +++ /dev/null @@ -1,79 +0,0 @@ -/** @file - Main header for XenPvBlkDxe - - Copyright (C) 2014, Citrix Ltd. - - This program and the accompanying materials - are licensed and made available under the terms and conditions of the BSD License - which accompanies this distribution. The full text of the license may be found at - http://opensource.org/licenses/bsd-license.php - - THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, - WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. - -**/ - -#ifndef __EFI_XEN_PV_BLK_DXE_H__ -#define __EFI_XEN_PV_BLK_DXE_H__ - -#include - -#define xen_mb() MemoryFence() -#define xen_rmb() MemoryFence() -#define xen_wmb() MemoryFence() - -// -// Libraries -// -#include -#include -#include -#include -#include -#include -#include - - -// -// UEFI Driver Model Protocols -// -#include -#include -#include - - -// -// Consumed Protocols -// -#include - - -// -// Produced Protocols -// -#include - - -// -// Driver Version -// -#define XEN_PV_BLK_DXE_VERSION 0x00000010 - - -// -// Protocol instances -// -extern EFI_DRIVER_BINDING_PROTOCOL gXenPvBlkDxeDriverBinding; -extern EFI_COMPONENT_NAME2_PROTOCOL gXenPvBlkDxeComponentName2; -extern EFI_COMPONENT_NAME_PROTOCOL gXenPvBlkDxeComponentName; - - -// -// Include files with function prototypes -// -#include "DriverBinding.h" -#include "ComponentName.h" -#include "BlockIo.h" - - -#endif diff --git a/OvmfPkg/XenPvBlkDxe/XenPvBlkDxe.inf b/OvmfPkg/XenPvBlkDxe/XenPvBlkDxe.inf deleted file mode 100644 index c9ac155861..0000000000 --- a/OvmfPkg/XenPvBlkDxe/XenPvBlkDxe.inf +++ /dev/null @@ -1,63 +0,0 @@ -## @file -# This driver produces a Block I/O protocol for a Xen PV block device. -# -# Copyright (C) 2014, Citrix Ltd. -# -# This program and the accompanying materials -# are licensed and made available under the terms and conditions of the BSD License -# which accompanies this distribution. The full text of the license may be found at -# http://opensource.org/licenses/bsd-license.php -# -# THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, -# WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. -# -## - -[Defines] - INF_VERSION = 0x00010005 - BASE_NAME = XenPvBlkDxe - FILE_GUID = 8c2487ea-9af3-11e3-b966-b8ac6f7d65e6 - MODULE_TYPE = UEFI_DRIVER - - VERSION_STRING = 1.0 - ENTRY_POINT = XenPvBlkDxeDriverEntryPoint - UNLOAD_IMAGE = XenPvBlkDxeUnload - - -[Packages] - MdePkg/MdePkg.dec - OvmfPkg/OvmfPkg.dec - -[Sources] - XenPvBlkDxe.h - XenPvBlkDxe.c - ComponentName.c - ComponentName.h - BlockFront.c - BlockFront.h - BlockIo.c - BlockIo.h - - -[LibraryClasses] - UefiDriverEntryPoint - UefiBootServicesTableLib - MemoryAllocationLib - BaseMemoryLib - BaseLib - UefiLib - DevicePathLib - DebugLib - - -[Protocols] - gEfiDriverBindingProtocolGuid - gEfiBlockIoProtocolGuid - gEfiComponentName2ProtocolGuid - gEfiComponentNameProtocolGuid - gXenBusProtocolGuid - gEfiDevicePathProtocolGuid ## TO_START - - -[Guids] - diff --git a/OvmfPkg/build.sh b/OvmfPkg/build.sh deleted file mode 100755 index 6821552025..0000000000 --- a/OvmfPkg/build.sh +++ /dev/null @@ -1,302 +0,0 @@ -#!/usr/bin/env bash -# -# Copyright (c) 2008 - 2009, Apple Inc. All rights reserved.
-# Copyright (c) 2010 - 2017, Intel Corporation. All rights reserved.
-# -# This program and the accompanying materials -# are licensed and made available under the terms and conditions of the BSD License -# which accompanies this distribution. The full text of the license may be found at -# http://opensource.org/licenses/bsd-license.php -# -# THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, -# WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. -# - -set -e -shopt -s nocasematch - - -# -# Setup workspace if it is not set -# -if [ -z "$WORKSPACE" ] -then - echo Initializing workspace - if [ ! -e `pwd`/edksetup.sh ] - then - cd .. - fi -# This version is for the tools in the BaseTools project. -# this assumes svn pulls have the same root dir -# export EDK_TOOLS_PATH=`pwd`/../BaseTools -# This version is for the tools source in edk2 - export EDK_TOOLS_PATH=`pwd`/BaseTools - echo $EDK_TOOLS_PATH - source edksetup.sh BaseTools -else - echo Building from: $WORKSPACE -fi - -# -# Configure defaults for various options -# - -ARCH_IA32=no -ARCH_X64=no -BUILDTARGET=DEBUG -BUILD_OPTIONS= -PLATFORMFILE= -THREADNUMBER=1 -LAST_ARG= -RUN_QEMU=no -ENABLE_FLASH=no - -# -# Pick a default tool type for a given OS -# -TARGET_TOOLS=MYTOOLS -case `uname` in - CYGWIN*) - echo Cygwin not fully supported yet. - ;; - Darwin*) - Major=$(uname -r | cut -f 1 -d '.') - # Major is Darwin version, not OS X version. - # OS X Yosemite 10.10.2 returns 14. - case $Major in - [156789]) - echo OvmfPkg requires OS X Snow Leopard 10.6 or newer OS - exit 1 - ;; - 10) - TARGET_TOOLS=XCODE32 - ;; - 1[12]) - TARGET_TOOLS=XCLANG - ;; - *) - # Mavericks and future assume XCODE5 (clang + lldb) - TARGET_TOOLS=XCODE5 - ;; - esac - ;; - Linux*) - gcc_version=$(gcc -v 2>&1 | tail -1 | awk '{print $3}') - case $gcc_version in - [1-3].*|4.[0-3].*) - echo OvmfPkg requires GCC4.4 or later - exit 1 - ;; - 4.4.*) - TARGET_TOOLS=GCC44 - ;; - 4.5.*) - TARGET_TOOLS=GCC45 - ;; - 4.6.*) - TARGET_TOOLS=GCC46 - ;; - 4.7.*) - TARGET_TOOLS=GCC47 - ;; - 4.8.*) - TARGET_TOOLS=GCC48 - ;; - 4.9.*|6.[0-2].*) - TARGET_TOOLS=GCC49 - ;; - *) - TARGET_TOOLS=GCC5 - ;; - esac -esac - -# -# Scan command line to override defaults -# - -for arg in "$@" -do - if [ -z "$LAST_ARG" ]; then - case $arg in - -a|-b|-t|-p|-n) - LAST_ARG=$arg - ;; - qemu) - RUN_QEMU=yes - shift - break - ;; - --enable-flash) - ENABLE_FLASH=yes - ;; - *) - BUILD_OPTIONS="$BUILD_OPTIONS $arg" - ;; - esac - else - case $LAST_ARG in - -a) - if [[ x"$arg" != x"IA32" && x"$arg" != x"X64" ]]; then - echo Unsupported processor architecture: $arg - echo Only IA32 or X64 is supported - exit 1 - fi - eval ARCH_$arg=yes - ;; - -b) - BUILDTARGET=$arg - ;; - -p) - PLATFORMFILE=$arg - ;; - -t) - TARGET_TOOLS=$arg - ;; - -n) - THREADNUMBER=$arg - ;; - *) - BUILD_OPTIONS="$BUILD_OPTIONS $arg" - ;; - esac - LAST_ARG= - fi - shift -done - -if [[ "$ARCH_IA32" == "yes" && "$ARCH_X64" == "yes" ]]; then - PROCESSOR=IA32X64 - Processor=Ia32X64 - BUILD_OPTIONS="$BUILD_OPTIONS -a IA32 -a X64" - PLATFORM_BUILD_DIR=Ovmf3264 - BUILD_ROOT_ARCH=X64 -elif [[ "$ARCH_IA32" == "yes" && "$ARCH_X64" == "no" ]]; then - PROCESSOR=IA32 - Processor=Ia32 - BUILD_OPTIONS="$BUILD_OPTIONS -a IA32" - PLATFORM_BUILD_DIR=Ovmf$Processor - BUILD_ROOT_ARCH=$PROCESSOR -else - PROCESSOR=X64 - Processor=X64 - BUILD_OPTIONS="$BUILD_OPTIONS -a X64" - PLATFORM_BUILD_DIR=Ovmf$Processor - BUILD_ROOT_ARCH=X64 -fi - -case $PROCESSOR in - IA32) - if [ -n "$QEMU_COMMAND" ]; then - # - # The user set the QEMU_COMMAND variable. We'll use it to run QEMU. - # - : - elif [ -x `which qemu-system-i386` ]; then - QEMU_COMMAND=qemu-system-i386 - elif [ -x `which qemu-system-x86_64` ]; then - QEMU_COMMAND=qemu-system-x86_64 - elif [ -x `which qemu` ]; then - QEMU_COMMAND=qemu - else - echo Unable to find QEMU for IA32 architecture! - exit 1 - fi - ;; - X64|IA32X64) - if [ -z "$QEMU_COMMAND" ]; then - # - # The user didn't set the QEMU_COMMAND variable. - # - QEMU_COMMAND=qemu-system-x86_64 - fi - ;; - *) - echo Unsupported processor architecture: $PROCESSOR - echo Only IA32 or X64 is supported - exit 1 - ;; -esac - -if [ -z "$PLATFORMFILE" ]; then - PLATFORMFILE=$WORKSPACE/OvmfPkg/OvmfPkg$Processor.dsc -fi - -if [[ "$RUN_QEMU" == "yes" ]]; then - qemu_version=$($QEMU_COMMAND -version 2>&1 | \ - grep -o -E 'version [0-9]+\.[0-9]+\.[0-9]+' | \ - awk '{print $2}') - case $qemu_version in - 1.[6-9].*|1.[1-9][0-9].*|2.*.*) - ENABLE_FLASH=yes - ;; - esac - - ADD_QEMU_HDA=yes - for arg in "$@" - do - case $arg in - -hd[a-d]|-fd[ab]|-cdrom) - ADD_QEMU_HDA=no - break - ;; - esac - done -fi - -# -# Uncomment this block for parameter parsing debug -# -#echo RUN_QEMU=$RUN_QEMU -#echo BUILD_OPTIONS=$BUILD_OPTIONS -#echo BUILDTARGET=$BUILDTARGET -#echo TARGET_TOOLS=$TARGET_TOOLS -#echo PROCESSOR=$PROCESSOR -#echo Remaining for qemu: $* -#exit 1 - -BUILD_ROOT=$WORKSPACE/Build/$PLATFORM_BUILD_DIR/"$BUILDTARGET"_"$TARGET_TOOLS" -FV_DIR=$BUILD_ROOT/FV -BUILD_ROOT_ARCH=$BUILD_ROOT/$BUILD_ROOT_ARCH -QEMU_FIRMWARE_DIR=$BUILD_ROOT/QEMU - -if [[ ! -f `which build` || ! -f `which GenFv` ]]; -then - # build the tools if they don't yet exist. Bin scheme - echo Building tools as they are not in the path - make -C $WORKSPACE/BaseTools -elif [[ ( -f `which build` || -f `which GenFv` ) && ! -d $EDK_TOOLS_PATH/Source/C/bin ]]; -then - # build the tools if they don't yet exist. BinWrapper scheme - echo Building tools no $EDK_TOOLS_PATH/Source/C/bin directory - make -C $WORKSPACE/BaseTools -else - echo using prebuilt tools -fi - - -if [[ "$RUN_QEMU" == "yes" ]]; then - if [[ ! -d $QEMU_FIRMWARE_DIR ]]; then - mkdir $QEMU_FIRMWARE_DIR - fi - ln -sf $FV_DIR/OVMF.fd $QEMU_FIRMWARE_DIR/bios.bin - if [[ "$ENABLE_FLASH" == "yes" ]]; then - QEMU_COMMAND="$QEMU_COMMAND -pflash $QEMU_FIRMWARE_DIR/bios.bin" - else - QEMU_COMMAND="$QEMU_COMMAND -L $QEMU_FIRMWARE_DIR" - fi - if [[ "$ADD_QEMU_HDA" == "yes" ]]; then - QEMU_COMMAND="$QEMU_COMMAND -hda fat:$BUILD_ROOT_ARCH" - fi - echo Running: $QEMU_COMMAND "$@" - $QEMU_COMMAND "$@" - exit $? -fi - -# -# Build the edk2 OvmfPkg -# -echo Running edk2 build for OvmfPkg$Processor -build -p $PLATFORMFILE $BUILD_OPTIONS -b $BUILDTARGET -t $TARGET_TOOLS -n $THREADNUMBER -exit $? - diff --git a/OvmfPkg/create-release.py b/OvmfPkg/create-release.py deleted file mode 100755 index 82d8e7b0a2..0000000000 --- a/OvmfPkg/create-release.py +++ /dev/null @@ -1,208 +0,0 @@ -#!/usr/bin/python -# -# Copyright (c) 2010 - 2013, Intel Corporation. All rights reserved.
-# -# This program and the accompanying materials -# are licensed and made available under the terms and conditions of the BSD License -# which accompanies this distribution. The full text of the license may be found at -# http://opensource.org/licenses/bsd-license.php -# -# THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, -# WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. -# - -import os -import re -import StringIO -import subprocess -import sys -import zipfile - -is_unix = not sys.platform.startswith('win') - -if not is_unix: - print "This script currently only supports unix-like systems" - sys.exit(-1) - -if os.path.exists('OvmfPkgX64.dsc'): - os.chdir('..') - -if not os.path.exists(os.path.join('OvmfPkg', 'OvmfPkgX64.dsc')): - print "OvmfPkg/OvmfPkgX64.dsc doesn't exist" - sys.exit(-1) - -def run_and_capture_output(args, checkExitCode = True): - p = subprocess.Popen(args=args, stdout=subprocess.PIPE) - stdout = p.stdout.read() - ret_code = p.wait() - if checkExitCode: - assert ret_code == 0 - return stdout - -gcc_version = run_and_capture_output(args=('gcc', '--version')) -gcc_re = re.compile(r'\s*\S+\s+\([^\)]+?\)\s+(\d+(?:\.\d+)*)(?:\s+.*)?') -mo = gcc_re.match(gcc_version) -if not mo: - print "Unable to find GCC version" - sys.exit(-1) -gcc_version = map(lambda n: int(n), mo.group(1).split('.')) - -if 'TOOLCHAIN' in os.environ: - TOOLCHAIN = os.environ['TOOLCHAIN'] -else: - assert(gcc_version[0] == 4) - minor = max(4, min(7, gcc_version[1])) - TOOLCHAIN = 'GCC4' + str(minor) - -def git_based_version(): - dir = os.getcwd() - if not os.path.exists('.git'): - os.chdir('OvmfPkg') - stdout = run_and_capture_output(args=('git', 'log', - '-n', '1', - '--abbrev-commit')) - regex = re.compile(r'^\s*git-svn-id:\s+\S+@(\d+)\s+[0-9a-f\-]+$', - re.MULTILINE) - mo = regex.search(stdout) - if mo: - version = 'r' + mo.group(1) - else: - version = stdout.split(None, 3)[1] - os.chdir(dir) - return version - -def svn_info(): - dir = os.getcwd() - os.chdir('OvmfPkg') - stdout = run_and_capture_output(args=('svn', 'info')) - os.chdir(dir) - return stdout - -def svn_based_version(): - buf = svn_info() - revision_re = re.compile('^Revision\:\s*([\da-f]+)$', re.MULTILINE) - mo = revision_re.search(buf) - assert(mo is not None) - return 'r' + mo.group(1) - -def get_revision(): - if os.path.exists(os.path.join('OvmfPkg', '.svn')): - return svn_based_version() - else: - return git_based_version() - -revision = get_revision() - -newline_re = re.compile(r'(\n|\r\n|\r(?!\n))', re.MULTILINE) -def to_dos_text(str): - return newline_re.sub('\r\n', str) - -def gen_build_info(): - distro = run_and_capture_output(args=('lsb_release', '-sd')).strip() - - machine = run_and_capture_output(args=('uname', '-m')).strip() - - gcc_version_str = '.'.join(map(lambda v: str(v), gcc_version)) - - ld_version = run_and_capture_output(args=('ld', '--version')) - ld_version = ld_version.split('\n')[0].split()[-1] - - iasl_version = run_and_capture_output(args=('iasl'), checkExitCode=False) - iasl_version = filter(lambda s: s.find(' version ') >= 0, iasl_version.split('\n'))[0] - iasl_version = iasl_version.split(' version ')[1].strip() - - sb = StringIO.StringIO() - print >> sb, 'edk2: ', revision - print >> sb, 'compiler: GCC', gcc_version_str, '(' + TOOLCHAIN + ')' - print >> sb, 'binutils:', ld_version - print >> sb, 'iasl: ', iasl_version - print >> sb, 'system: ', distro, machine.replace('_', '-') - return to_dos_text(sb.getvalue()) - -def read_file(filename): - f = open(filename) - d = f.read() - f.close() - return d - -LICENSE = to_dos_text( -'''This OVMF binary release is built from source code licensed under -the BSD open source license. The BSD license is documented at -http://opensource.org/licenses/bsd-license.php, and a copy is -shown below. - -One sub-component of the OVMF project is a FAT filesystem driver. The FAT -filesystem driver code is also BSD licensed, but the code license contains -one additional term. This license can be found at -https://github.com/tianocore/tianocore.github.io/wiki/Edk2-fat-driver -and a copy is shown below (following the normal BSD license). - -=== BSD license: START === - -''') - -LICENSE += read_file(os.path.join('MdePkg', 'License.txt')) - -LICENSE += to_dos_text( -''' -=== BSD license: END === - -=== FAT filesystem driver license: START === - -''') - -LICENSE += read_file(os.path.join('FatBinPkg', 'License.txt')) - -LICENSE += to_dos_text( -''' -=== FAT filesystem driver license: END === -''') - -def build(arch): - args = ( - 'OvmfPkg/build.sh', - '-t', TOOLCHAIN, - '-a', arch, - '-b', 'RELEASE' - ) - logname = 'build-%s.log' % arch - build_log = open(logname, 'w') - print 'Building OVMF for', arch, '(%s)' % logname, '...', - sys.stdout.flush() - p = subprocess.Popen(args=args, stdout=build_log, stderr=build_log) - ret_code = p.wait() - if ret_code == 0: - print '[done]' - else: - print '[error 0x%x]' % ret_code - return ret_code - -def create_zip(arch): - global build_info - filename = 'OVMF-%s-%s.zip' % (arch, revision) - print 'Creating', filename, '...', - sys.stdout.flush() - if os.path.exists(filename): - os.remove(filename) - zipf = zipfile.ZipFile(filename, 'w', zipfile.ZIP_DEFLATED) - - zipf.writestr('BUILD_INFO', build_info) - zipf.writestr('LICENSE', LICENSE) - zipf.write(os.path.join('OvmfPkg', 'README'), 'README') - FV_DIR = os.path.join( - 'Build', - 'Ovmf' + arch.title(), - 'RELEASE_' + TOOLCHAIN, - 'FV' - ) - zipf.write(os.path.join(FV_DIR, 'OVMF.fd'), 'OVMF.fd') - zipf.close() - print '[done]' - -build_info = gen_build_info() -build('IA32') -build('X64') -create_zip('IA32') -create_zip('X64') - - -- cgit v1.2.3