summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--OvmfPkg/AcpiPlatformDxe/AcpiPlatform.c261
-rw-r--r--OvmfPkg/AcpiPlatformDxe/AcpiPlatform.h77
-rw-r--r--OvmfPkg/AcpiPlatformDxe/AcpiPlatformDxe.inf73
-rw-r--r--OvmfPkg/AcpiPlatformDxe/EntryPoint.c116
-rw-r--r--OvmfPkg/AcpiPlatformDxe/Qemu.c518
-rw-r--r--OvmfPkg/AcpiPlatformDxe/QemuFwCfgAcpi.c685
-rw-r--r--OvmfPkg/AcpiPlatformDxe/QemuFwCfgAcpiPlatform.c39
-rw-r--r--OvmfPkg/AcpiPlatformDxe/QemuFwCfgAcpiPlatformDxe.inf56
-rw-r--r--OvmfPkg/AcpiPlatformDxe/QemuLoader.h86
-rw-r--r--OvmfPkg/AcpiPlatformDxe/Xen.c318
-rw-r--r--OvmfPkg/AcpiS3SaveDxe/AcpiS3Save.c558
-rw-r--r--OvmfPkg/AcpiS3SaveDxe/AcpiS3SaveDxe.inf76
-rw-r--r--OvmfPkg/AcpiTables/AcpiTables.inf40
-rw-r--r--OvmfPkg/AcpiTables/Dsdt.asl698
-rw-r--r--OvmfPkg/AcpiTables/Facp.aslc95
-rw-r--r--OvmfPkg/AcpiTables/Facs.aslc84
-rw-r--r--OvmfPkg/AcpiTables/Madt.aslc159
-rw-r--r--OvmfPkg/AcpiTables/Platform.h74
-rw-r--r--OvmfPkg/AcpiTables/Ssdt.asl19
-rw-r--r--OvmfPkg/BlockMmioToBlockIoDxe/BlockIo.c528
-rw-r--r--OvmfPkg/BlockMmioToBlockIoDxe/BlockIo.h346
-rw-r--r--OvmfPkg/BlockMmioToBlockIoDxe/BlockIo.inf55
-rw-r--r--OvmfPkg/BlockMmioToBlockIoDxe/ComponentName.c162
-rw-r--r--OvmfPkg/Contributions.txt218
-rw-r--r--OvmfPkg/Csm/Csm16/Csm16.inf23
-rw-r--r--OvmfPkg/Csm/Csm16/ReadMe.txt12
-rw-r--r--OvmfPkg/Csm/CsmSupportLib/CsmSupportLib.c38
-rw-r--r--OvmfPkg/Csm/CsmSupportLib/CsmSupportLib.h55
-rw-r--r--OvmfPkg/Csm/CsmSupportLib/CsmSupportLib.inf58
-rw-r--r--OvmfPkg/Csm/CsmSupportLib/LegacyInterrupt.c220
-rw-r--r--OvmfPkg/Csm/CsmSupportLib/LegacyInterrupt.h123
-rw-r--r--OvmfPkg/Csm/CsmSupportLib/LegacyPlatform.c1066
-rw-r--r--OvmfPkg/Csm/CsmSupportLib/LegacyPlatform.h104
-rw-r--r--OvmfPkg/Csm/CsmSupportLib/LegacyRegion.c466
-rw-r--r--OvmfPkg/Csm/CsmSupportLib/LegacyRegion.h219
-rw-r--r--OvmfPkg/EmuVariableFvbRuntimeDxe/Fvb.c917
-rw-r--r--OvmfPkg/EmuVariableFvbRuntimeDxe/Fvb.h140
-rw-r--r--OvmfPkg/EmuVariableFvbRuntimeDxe/Fvb.inf76
-rw-r--r--OvmfPkg/Include/Guid/OvmfPlatformConfig.h24
-rw-r--r--OvmfPkg/Include/Guid/VirtioMmioTransport.h25
-rw-r--r--OvmfPkg/Include/Guid/XenBusRootDevice.h24
-rw-r--r--OvmfPkg/Include/Guid/XenInfo.h42
-rw-r--r--OvmfPkg/Include/IndustryStandard/E820.h46
-rw-r--r--OvmfPkg/Include/IndustryStandard/I440FxPiix4.h40
-rw-r--r--OvmfPkg/Include/IndustryStandard/LegacyVgaBios.h97
-rw-r--r--OvmfPkg/Include/IndustryStandard/LinuxBzimage.h164
-rw-r--r--OvmfPkg/Include/IndustryStandard/Q35MchIch9.h98
-rw-r--r--OvmfPkg/Include/IndustryStandard/Virtio.h175
-rw-r--r--OvmfPkg/Include/IndustryStandard/VirtioBlk.h89
-rw-r--r--OvmfPkg/Include/IndustryStandard/VirtioNet.h97
-rw-r--r--OvmfPkg/Include/IndustryStandard/VirtioScsi.h99
-rw-r--r--OvmfPkg/Include/IndustryStandard/Xen/README37
-rw-r--r--OvmfPkg/Include/IndustryStandard/Xen/arch-arm/xen.h436
-rw-r--r--OvmfPkg/Include/IndustryStandard/Xen/arch-x86/xen-x86_32.h59
-rw-r--r--OvmfPkg/Include/IndustryStandard/Xen/arch-x86/xen-x86_64.h59
-rw-r--r--OvmfPkg/Include/IndustryStandard/Xen/arch-x86/xen.h112
-rw-r--r--OvmfPkg/Include/IndustryStandard/Xen/event_channel.h118
-rw-r--r--OvmfPkg/Include/IndustryStandard/Xen/grant_table.h444
-rw-r--r--OvmfPkg/Include/IndustryStandard/Xen/hvm/hvm_op.h37
-rw-r--r--OvmfPkg/Include/IndustryStandard/Xen/hvm/params.h150
-rw-r--r--OvmfPkg/Include/IndustryStandard/Xen/io/blkif.h619
-rw-r--r--OvmfPkg/Include/IndustryStandard/Xen/io/console.h51
-rw-r--r--OvmfPkg/Include/IndustryStandard/Xen/io/protocols.h40
-rw-r--r--OvmfPkg/Include/IndustryStandard/Xen/io/ring.h312
-rw-r--r--OvmfPkg/Include/IndustryStandard/Xen/io/xenbus.h80
-rw-r--r--OvmfPkg/Include/IndustryStandard/Xen/io/xs_wire.h149
-rw-r--r--OvmfPkg/Include/IndustryStandard/Xen/memory.h94
-rw-r--r--OvmfPkg/Include/IndustryStandard/Xen/xen-compat.h44
-rw-r--r--OvmfPkg/Include/IndustryStandard/Xen/xen.h346
-rw-r--r--OvmfPkg/Include/Library/LoadLinuxLib.h211
-rw-r--r--OvmfPkg/Include/Library/NvVarsFileLib.h51
-rw-r--r--OvmfPkg/Include/Library/PlatformFvbLib.h87
-rw-r--r--OvmfPkg/Include/Library/QemuBootOrderLib.h69
-rw-r--r--OvmfPkg/Include/Library/QemuFwCfgLib.h238
-rw-r--r--OvmfPkg/Include/Library/SerializeVariablesLib.h229
-rw-r--r--OvmfPkg/Include/Library/VirtioLib.h185
-rw-r--r--OvmfPkg/Include/Library/VirtioMmioDeviceLib.h66
-rw-r--r--OvmfPkg/Include/Library/XenHypercallLib.h95
-rw-r--r--OvmfPkg/Include/Library/XenIoMmioLib.h64
-rw-r--r--OvmfPkg/Include/OvmfPlatforms.h40
-rw-r--r--OvmfPkg/Include/Protocol/BlockMmio.h50
-rw-r--r--OvmfPkg/Include/Protocol/VirtioDevice.h382
-rw-r--r--OvmfPkg/Include/Protocol/XenBus.h416
-rw-r--r--OvmfPkg/Include/Protocol/XenIo.h48
-rw-r--r--OvmfPkg/Library/AcpiTimerLib/AcpiTimerLib.c216
-rw-r--r--OvmfPkg/Library/AcpiTimerLib/AcpiTimerLib.h29
-rw-r--r--OvmfPkg/Library/AcpiTimerLib/BaseAcpiTimerLib.c105
-rw-r--r--OvmfPkg/Library/AcpiTimerLib/BaseAcpiTimerLib.inf40
-rw-r--r--OvmfPkg/Library/AcpiTimerLib/BaseRomAcpiTimerLib.c122
-rw-r--r--OvmfPkg/Library/AcpiTimerLib/BaseRomAcpiTimerLib.inf39
-rw-r--r--OvmfPkg/Library/AcpiTimerLib/DxeAcpiTimerLib.c89
-rw-r--r--OvmfPkg/Library/AcpiTimerLib/DxeAcpiTimerLib.inf40
-rw-r--r--OvmfPkg/Library/EmuVariableFvbLib/EmuVariableFvbLib.c103
-rw-r--r--OvmfPkg/Library/EmuVariableFvbLib/EmuVariableFvbLib.inf48
-rw-r--r--OvmfPkg/Library/LoadLinuxLib/Ia32/JumpToKernel.nasm49
-rw-r--r--OvmfPkg/Library/LoadLinuxLib/Linux.c670
-rw-r--r--OvmfPkg/Library/LoadLinuxLib/LinuxGdt.c181
-rw-r--r--OvmfPkg/Library/LoadLinuxLib/LoadLinuxLib.h59
-rw-r--r--OvmfPkg/Library/LoadLinuxLib/LoadLinuxLib.inf48
-rw-r--r--OvmfPkg/Library/LoadLinuxLib/X64/JumpToKernel.nasm93
-rw-r--r--OvmfPkg/Library/LockBoxLib/LockBoxBase.c42
-rw-r--r--OvmfPkg/Library/LockBoxLib/LockBoxBaseLib.inf44
-rw-r--r--OvmfPkg/Library/LockBoxLib/LockBoxDxe.c119
-rw-r--r--OvmfPkg/Library/LockBoxLib/LockBoxDxeLib.inf45
-rw-r--r--OvmfPkg/Library/LockBoxLib/LockBoxLib.c376
-rw-r--r--OvmfPkg/Library/LockBoxLib/LockBoxLib.h60
-rw-r--r--OvmfPkg/Library/NvVarsFileLib/FsAccess.c517
-rw-r--r--OvmfPkg/Library/NvVarsFileLib/NvVarsFileLib.c83
-rw-r--r--OvmfPkg/Library/NvVarsFileLib/NvVarsFileLib.h61
-rw-r--r--OvmfPkg/Library/NvVarsFileLib/NvVarsFileLib.inf60
-rw-r--r--OvmfPkg/Library/PlatformBdsLib/BdsPlatform.c1597
-rw-r--r--OvmfPkg/Library/PlatformBdsLib/BdsPlatform.h292
-rw-r--r--OvmfPkg/Library/PlatformBdsLib/PlatformBdsLib.inf72
-rw-r--r--OvmfPkg/Library/PlatformBdsLib/PlatformData.c51
-rw-r--r--OvmfPkg/Library/PlatformBdsLib/QemuKernel.c170
-rw-r--r--OvmfPkg/Library/PlatformDebugLibIoPort/DebugLib.c287
-rw-r--r--OvmfPkg/Library/PlatformDebugLibIoPort/PlatformDebugLibIoPort.inf51
-rw-r--r--OvmfPkg/Library/PlatformFvbLibNull/PlatformFvbLibNull.c89
-rw-r--r--OvmfPkg/Library/PlatformFvbLibNull/PlatformFvbLibNull.inf39
-rw-r--r--OvmfPkg/Library/PlatformSecureLib/PlatformSecureLib.c40
-rw-r--r--OvmfPkg/Library/PlatformSecureLib/PlatformSecureLib.inf33
-rw-r--r--OvmfPkg/Library/QemuBootOrderLib/ExtraRootBusMap.c313
-rw-r--r--OvmfPkg/Library/QemuBootOrderLib/ExtraRootBusMap.h40
-rw-r--r--OvmfPkg/Library/QemuBootOrderLib/QemuBootOrderLib.c1793
-rw-r--r--OvmfPkg/Library/QemuBootOrderLib/QemuBootOrderLib.inf68
-rw-r--r--OvmfPkg/Library/QemuFwCfgLib/Ia32/IoLibExAsm.nasm55
-rw-r--r--OvmfPkg/Library/QemuFwCfgLib/QemuFwCfgLib.c325
-rw-r--r--OvmfPkg/Library/QemuFwCfgLib/QemuFwCfgLib.inf54
-rw-r--r--OvmfPkg/Library/QemuFwCfgLib/QemuFwCfgPeiDxe.c92
-rw-r--r--OvmfPkg/Library/QemuFwCfgLib/QemuFwCfgSec.c81
-rw-r--r--OvmfPkg/Library/QemuFwCfgLib/QemuFwCfgSecLib.inf52
-rw-r--r--OvmfPkg/Library/QemuFwCfgLib/X64/IoLibExAsm.nasm52
-rw-r--r--OvmfPkg/Library/ResetSystemLib/ResetSystemLib.c108
-rw-r--r--OvmfPkg/Library/ResetSystemLib/ResetSystemLib.inf42
-rw-r--r--OvmfPkg/Library/SerializeVariablesLib/SerializeVariablesLib.c870
-rw-r--r--OvmfPkg/Library/SerializeVariablesLib/SerializeVariablesLib.h39
-rw-r--r--OvmfPkg/Library/SerializeVariablesLib/SerializeVariablesLib.inf41
-rw-r--r--OvmfPkg/Library/SmbiosVersionLib/DetectSmbiosVersionLib.c107
-rw-r--r--OvmfPkg/Library/SmbiosVersionLib/DetectSmbiosVersionLib.inf53
-rw-r--r--OvmfPkg/Library/VirtioLib/VirtioLib.c319
-rw-r--r--OvmfPkg/Library/VirtioLib/VirtioLib.inf36
-rw-r--r--OvmfPkg/Library/VirtioMmioDeviceLib/VirtioMmioDevice.c224
-rw-r--r--OvmfPkg/Library/VirtioMmioDeviceLib/VirtioMmioDevice.h147
-rw-r--r--OvmfPkg/Library/VirtioMmioDeviceLib/VirtioMmioDeviceFunctions.c310
-rw-r--r--OvmfPkg/Library/VirtioMmioDeviceLib/VirtioMmioDeviceLib.inf42
-rw-r--r--OvmfPkg/Library/XenConsoleSerialPortLib/XenConsoleSerialPortLib.c302
-rw-r--r--OvmfPkg/Library/XenConsoleSerialPortLib/XenConsoleSerialPortLib.inf35
-rw-r--r--OvmfPkg/Library/XenHypercallLib/Aarch64/Hypercall.S26
-rw-r--r--OvmfPkg/Library/XenHypercallLib/Arm/Hypercall.S25
-rw-r--r--OvmfPkg/Library/XenHypercallLib/ArmXenHypercall.c44
-rw-r--r--OvmfPkg/Library/XenHypercallLib/Ia32/hypercall.nasm25
-rw-r--r--OvmfPkg/Library/XenHypercallLib/X64/hypercall.nasm26
-rw-r--r--OvmfPkg/Library/XenHypercallLib/X86XenHypercall.c102
-rw-r--r--OvmfPkg/Library/XenHypercallLib/XenHypercall.c63
-rw-r--r--OvmfPkg/Library/XenHypercallLib/XenHypercallLib.inf66
-rw-r--r--OvmfPkg/Library/XenIoMmioLib/XenIoMmioLib.c166
-rw-r--r--OvmfPkg/Library/XenIoMmioLib/XenIoMmioLib.inf39
-rw-r--r--OvmfPkg/License.txt50
-rw-r--r--OvmfPkg/OvmfPkg.dec119
-rw-r--r--OvmfPkg/OvmfPkg.fdf.inc62
-rw-r--r--OvmfPkg/OvmfPkgIa32.dsc620
-rw-r--r--OvmfPkg/OvmfPkgIa32.fdf476
-rw-r--r--OvmfPkg/OvmfPkgIa32X64.dsc627
-rw-r--r--OvmfPkg/OvmfPkgIa32X64.fdf476
-rw-r--r--OvmfPkg/OvmfPkgX64.dsc625
-rw-r--r--OvmfPkg/OvmfPkgX64.fdf476
-rw-r--r--OvmfPkg/PciHostBridgeDxe/Ia32/IoFifo.S134
-rw-r--r--OvmfPkg/PciHostBridgeDxe/Ia32/IoFifo.asm140
-rw-r--r--OvmfPkg/PciHostBridgeDxe/IoFifo.h176
-rw-r--r--OvmfPkg/PciHostBridgeDxe/PciHostBridge.c1551
-rw-r--r--OvmfPkg/PciHostBridgeDxe/PciHostBridge.h651
-rw-r--r--OvmfPkg/PciHostBridgeDxe/PciHostBridgeDxe.inf66
-rw-r--r--OvmfPkg/PciHostBridgeDxe/PciRootBridgeIo.c2628
-rw-r--r--OvmfPkg/PciHostBridgeDxe/X64/IoFifo.S122
-rw-r--r--OvmfPkg/PciHostBridgeDxe/X64/IoFifo.asm126
-rw-r--r--OvmfPkg/PlatformDxe/Platform.c871
-rw-r--r--OvmfPkg/PlatformDxe/Platform.h43
-rw-r--r--OvmfPkg/PlatformDxe/Platform.inf69
-rw-r--r--OvmfPkg/PlatformDxe/Platform.uni38
-rw-r--r--OvmfPkg/PlatformDxe/PlatformConfig.c131
-rw-r--r--OvmfPkg/PlatformDxe/PlatformConfig.h59
-rw-r--r--OvmfPkg/PlatformDxe/PlatformForms.vfr74
-rw-r--r--OvmfPkg/PlatformPei/Cmos.c64
-rw-r--r--OvmfPkg/PlatformPei/Cmos.h56
-rw-r--r--OvmfPkg/PlatformPei/Fv.c75
-rw-r--r--OvmfPkg/PlatformPei/MemDetect.c404
-rw-r--r--OvmfPkg/PlatformPei/Platform.c437
-rw-r--r--OvmfPkg/PlatformPei/Platform.h110
-rw-r--r--OvmfPkg/PlatformPei/PlatformPei.inf93
-rw-r--r--OvmfPkg/PlatformPei/Xen.c231
-rw-r--r--OvmfPkg/PlatformPei/Xen.h45
-rw-r--r--OvmfPkg/QemuFlashFvbServicesRuntimeDxe/FvbInfo.c141
-rw-r--r--OvmfPkg/QemuFlashFvbServicesRuntimeDxe/FvbServicesRuntimeDxe.inf84
-rw-r--r--OvmfPkg/QemuFlashFvbServicesRuntimeDxe/FwBlockService.c1229
-rw-r--r--OvmfPkg/QemuFlashFvbServicesRuntimeDxe/FwBlockService.h184
-rw-r--r--OvmfPkg/QemuFlashFvbServicesRuntimeDxe/QemuFlash.c265
-rw-r--r--OvmfPkg/QemuFlashFvbServicesRuntimeDxe/QemuFlash.h89
-rw-r--r--OvmfPkg/QemuVideoDxe/ComponentName.c212
-rw-r--r--OvmfPkg/QemuVideoDxe/Driver.c974
-rw-r--r--OvmfPkg/QemuVideoDxe/DriverSupportedEfiVersion.c21
-rw-r--r--OvmfPkg/QemuVideoDxe/Gop.c387
-rw-r--r--OvmfPkg/QemuVideoDxe/Initialize.c352
-rw-r--r--OvmfPkg/QemuVideoDxe/Qemu.h511
-rw-r--r--OvmfPkg/QemuVideoDxe/QemuVideoDxe.inf71
-rw-r--r--OvmfPkg/QemuVideoDxe/VbeShim.asm287
-rw-r--r--OvmfPkg/QemuVideoDxe/VbeShim.c275
-rw-r--r--OvmfPkg/QemuVideoDxe/VbeShim.h701
-rwxr-xr-xOvmfPkg/QemuVideoDxe/VbeShim.sh85
-rw-r--r--OvmfPkg/README259
-rw-r--r--OvmfPkg/ResetVector/Ia32/PageTables64.asm93
-rw-r--r--OvmfPkg/ResetVector/ResetVector.inf37
-rw-r--r--OvmfPkg/ResetVector/ResetVector.nasmb66
-rw-r--r--OvmfPkg/ResetVector/ResetVectorCode.asm53
-rw-r--r--OvmfPkg/Sec/Ia32/SecEntry.nasm56
-rw-r--r--OvmfPkg/Sec/SecMain.c892
-rw-r--r--OvmfPkg/Sec/SecMain.inf69
-rw-r--r--OvmfPkg/Sec/X64/SecEntry.nasm56
-rw-r--r--OvmfPkg/SmbiosPlatformDxe/ArmXen.c34
-rw-r--r--OvmfPkg/SmbiosPlatformDxe/Qemu.c54
-rw-r--r--OvmfPkg/SmbiosPlatformDxe/SmbiosPlatformDxe.c217
-rw-r--r--OvmfPkg/SmbiosPlatformDxe/SmbiosPlatformDxe.h54
-rw-r--r--OvmfPkg/SmbiosPlatformDxe/SmbiosPlatformDxe.inf69
-rw-r--r--OvmfPkg/SmbiosPlatformDxe/X86Xen.c98
-rw-r--r--OvmfPkg/VarStore.fdf.inc79
-rw-r--r--OvmfPkg/VirtioBlkDxe/VirtioBlk.c1102
-rw-r--r--OvmfPkg/VirtioBlkDxe/VirtioBlk.h290
-rw-r--r--OvmfPkg/VirtioBlkDxe/VirtioBlk.inf42
-rw-r--r--OvmfPkg/VirtioNetDxe/ComponentName.c177
-rw-r--r--OvmfPkg/VirtioNetDxe/DriverBinding.c653
-rw-r--r--OvmfPkg/VirtioNetDxe/EntryPoint.c50
-rw-r--r--OvmfPkg/VirtioNetDxe/Events.c91
-rw-r--r--OvmfPkg/VirtioNetDxe/SnpGetStatus.c160
-rw-r--r--OvmfPkg/VirtioNetDxe/SnpInitialize.c490
-rw-r--r--OvmfPkg/VirtioNetDxe/SnpMcastIpToMac.c108
-rw-r--r--OvmfPkg/VirtioNetDxe/SnpReceive.c188
-rw-r--r--OvmfPkg/VirtioNetDxe/SnpReceiveFilters.c105
-rw-r--r--OvmfPkg/VirtioNetDxe/SnpSharedHelpers.c53
-rw-r--r--OvmfPkg/VirtioNetDxe/SnpShutdown.c78
-rw-r--r--OvmfPkg/VirtioNetDxe/SnpStart.c64
-rw-r--r--OvmfPkg/VirtioNetDxe/SnpStop.c65
-rw-r--r--OvmfPkg/VirtioNetDxe/SnpTransmit.c169
-rw-r--r--OvmfPkg/VirtioNetDxe/SnpUnsupported.c160
-rw-r--r--OvmfPkg/VirtioNetDxe/TechNotes.txt355
-rw-r--r--OvmfPkg/VirtioNetDxe/VirtioNet.h283
-rw-r--r--OvmfPkg/VirtioNetDxe/VirtioNet.inf60
-rw-r--r--OvmfPkg/VirtioPciDeviceDxe/VirtioPciDevice.c680
-rw-r--r--OvmfPkg/VirtioPciDeviceDxe/VirtioPciDevice.h166
-rw-r--r--OvmfPkg/VirtioPciDeviceDxe/VirtioPciDeviceDxe.inf43
-rw-r--r--OvmfPkg/VirtioPciDeviceDxe/VirtioPciFunctions.c283
-rw-r--r--OvmfPkg/VirtioScsiDxe/VirtioScsi.c1228
-rw-r--r--OvmfPkg/VirtioScsiDxe/VirtioScsi.h207
-rw-r--r--OvmfPkg/VirtioScsiDxe/VirtioScsi.inf47
-rw-r--r--OvmfPkg/XenBusDxe/ComponentName.c174
-rw-r--r--OvmfPkg/XenBusDxe/ComponentName.h94
-rw-r--r--OvmfPkg/XenBusDxe/DriverBinding.h128
-rw-r--r--OvmfPkg/XenBusDxe/EventChannel.c84
-rw-r--r--OvmfPkg/XenBusDxe/EventChannel.h88
-rw-r--r--OvmfPkg/XenBusDxe/GrantTable.c221
-rw-r--r--OvmfPkg/XenBusDxe/GrantTable.h76
-rw-r--r--OvmfPkg/XenBusDxe/Helpers.c9
-rw-r--r--OvmfPkg/XenBusDxe/TestAndClearBit.c46
-rw-r--r--OvmfPkg/XenBusDxe/XenBus.c386
-rw-r--r--OvmfPkg/XenBusDxe/XenBus.h44
-rw-r--r--OvmfPkg/XenBusDxe/XenBusDxe.c492
-rw-r--r--OvmfPkg/XenBusDxe/XenBusDxe.h133
-rw-r--r--OvmfPkg/XenBusDxe/XenBusDxe.inf66
-rw-r--r--OvmfPkg/XenBusDxe/XenStore.c1554
-rw-r--r--OvmfPkg/XenBusDxe/XenStore.h379
-rw-r--r--OvmfPkg/XenIoPciDxe/XenIoPciDxe.c367
-rw-r--r--OvmfPkg/XenIoPciDxe/XenIoPciDxe.inf45
-rw-r--r--OvmfPkg/XenPvBlkDxe/BlockFront.c643
-rw-r--r--OvmfPkg/XenPvBlkDxe/BlockFront.h101
-rw-r--r--OvmfPkg/XenPvBlkDxe/BlockIo.c276
-rw-r--r--OvmfPkg/XenPvBlkDxe/BlockIo.h108
-rw-r--r--OvmfPkg/XenPvBlkDxe/ComponentName.c176
-rw-r--r--OvmfPkg/XenPvBlkDxe/ComponentName.h94
-rw-r--r--OvmfPkg/XenPvBlkDxe/DriverBinding.h143
-rw-r--r--OvmfPkg/XenPvBlkDxe/XenPvBlkDxe.c394
-rw-r--r--OvmfPkg/XenPvBlkDxe/XenPvBlkDxe.h79
-rw-r--r--OvmfPkg/XenPvBlkDxe/XenPvBlkDxe.inf63
-rwxr-xr-xOvmfPkg/build.sh293
-rwxr-xr-xOvmfPkg/create-release.py208
282 files changed, 0 insertions, 61877 deletions
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.<BR>
- This program and the accompanying materials
- are licensed and made available under the terms and conditions of the BSD License
- which accompanies this distribution. The full text of the license may be found at
- http://opensource.org/licenses/bsd-license.php
-
- 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 55b380b285..0000000000
--- a/OvmfPkg/AcpiPlatformDxe/AcpiPlatform.h
+++ /dev/null
@@ -1,77 +0,0 @@
-/** @file
- Sample ACPI Platform Driver
-
- Copyright (c) 2008 - 2012, Intel Corporation. All rights reserved.<BR>
- This program and the accompanying materials
- are licensed and made available under the terms and conditions of the BSD License
- which accompanies this distribution. The full text of the license may be found at
- http://opensource.org/licenses/bsd-license.php
-
- 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 <PiDxe.h>
-
-#include <Protocol/AcpiTable.h>
-#include <Protocol/FirmwareVolume2.h>
-
-#include <Library/BaseLib.h>
-#include <Library/UefiBootServicesTableLib.h>
-#include <Library/DebugLib.h>
-#include <Library/PcdLib.h>
-
-#include <IndustryStandard/Acpi.h>
-
-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
- );
-
-#endif
-
diff --git a/OvmfPkg/AcpiPlatformDxe/AcpiPlatformDxe.inf b/OvmfPkg/AcpiPlatformDxe/AcpiPlatformDxe.inf
deleted file mode 100644
index 055f3ad0ee..0000000000
--- a/OvmfPkg/AcpiPlatformDxe/AcpiPlatformDxe.inf
+++ /dev/null
@@ -1,73 +0,0 @@
-## @file
-# OVMF ACPI Platform Driver
-#
-# Copyright (c) 2008 - 2012, Intel Corporation. All rights reserved.<BR>
-# This program and the accompanying materials
-# are licensed and made available under the terms and conditions of the BSD License
-# which accompanies this distribution. The full text of the license may be found at
-# http://opensource.org/licenses/bsd-license.php
-#
-# 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
-
-[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
- MemoryAllocationLib
- BaseLib
- DxeServicesTableLib
- OrderedCollectionLib
-
-[Protocols]
- gEfiAcpiTableProtocolGuid # PROTOCOL ALWAYS_CONSUMED
- gEfiPciEnumerationCompleteProtocolGuid # PROTOCOL SOMETIMES_CONSUMED
-
-[Guids]
- gEfiXenInfoGuid
-
-[Pcd]
- gEfiMdeModulePkgTokenSpaceGuid.PcdAcpiTableStorageFile
- gEfiMdeModulePkgTokenSpaceGuid.PcdPciDisableBusEnumeration
- gUefiCpuPkgTokenSpaceGuid.PcdCpuLocalApicBaseAddress
- gPcAtChipsetPkgTokenSpaceGuid.Pcd8259LegacyModeEdgeLevel
- gUefiOvmfPkgTokenSpaceGuid.PcdOvmfFdBaseAddress
-
-[Depex]
- gEfiAcpiTableProtocolGuid
diff --git a/OvmfPkg/AcpiPlatformDxe/EntryPoint.c b/OvmfPkg/AcpiPlatformDxe/EntryPoint.c
deleted file mode 100644
index d713b0d44b..0000000000
--- a/OvmfPkg/AcpiPlatformDxe/EntryPoint.c
+++ /dev/null
@@ -1,116 +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.<BR>
-
- This program and the accompanying materials are licensed and made available
- under the terms and conditions of the BSD License which accompanies this
- distribution. The full text of the license may be found at
- http://opensource.org/licenses/bsd-license.php
-
- 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 <Protocol/PciEnumerationComplete.h>
-#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
-OnPciEnumerated (
- IN EFI_EVENT Event,
- IN VOID *Context
- )
-{
- EFI_STATUS Status;
-
- DEBUG ((EFI_D_INFO, "%a: PCI enumeration complete, 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;
- VOID *Interface;
- EFI_EVENT PciEnumerated;
- VOID *Registration;
-
- //
- // 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 ());
- }
-
- //
- // Similarly, if PCI enumeration has already completed, install the tables
- // immediately.
- //
- Status = gBS->LocateProtocol (&gEfiPciEnumerationCompleteProtocolGuid,
- NULL /* Registration */, &Interface);
- if (!EFI_ERROR (Status)) {
- DEBUG ((EFI_D_INFO, "%a: PCI enumeration already complete, "
- "installing ACPI tables\n", __FUNCTION__));
- return InstallAcpiTables (FindAcpiTableProtocol ());
- }
- ASSERT (Status == EFI_NOT_FOUND);
-
- //
- // Otherwise, delay installing the ACPI tables until PCI enumeration
- // completes. The entry point's return status will only reflect the callback
- // setup.
- //
- Status = gBS->CreateEvent (EVT_NOTIFY_SIGNAL, TPL_CALLBACK, OnPciEnumerated,
- NULL /* Context */, &PciEnumerated);
- if (EFI_ERROR (Status)) {
- return Status;
- }
-
- Status = gBS->RegisterProtocolNotify (
- &gEfiPciEnumerationCompleteProtocolGuid, PciEnumerated,
- &Registration);
- if (EFI_ERROR (Status)) {
- gBS->CloseEvent (PciEnumerated);
- } else {
- DEBUG ((EFI_D_INFO, "%a: PCI enumeration pending, registered callback\n",
- __FUNCTION__));
- }
-
- return Status;
-}
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.<BR>
-
- 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 <Library/BaseMemoryLib.h>
-#include <Library/MemoryAllocationLib.h>
-#include <Library/QemuFwCfgLib.h>
-#include <Library/DxeServicesTableLib.h>
-#include <Library/PcdLib.h>
-#include <Library/OrderedCollectionLib.h>
-#include <IndustryStandard/Acpi.h>
-
-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 81620448a0..0000000000
--- a/OvmfPkg/AcpiPlatformDxe/QemuFwCfgAcpi.c
+++ /dev/null
@@ -1,685 +0,0 @@
-/** @file
- OVMF ACPI support using QEMU's fw-cfg interface
-
- Copyright (c) 2008 - 2014, Intel Corporation. All rights reserved.<BR>
- 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 <Library/BaseMemoryLib.h>
-#include <Library/MemoryAllocationLib.h>
-#include <Library/QemuFwCfgLib.h>
-#include <Library/DxeServicesTableLib.h>
-#include <Library/PcdLib.h>
-#include <Library/OrderedCollectionLib.h>
-#include <IndustryStandard/Acpi.h>
-
-
-//
-// 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);
-}
-
-
-/**
- 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 (RShiftU64 (
- RShiftU64 (PointerValue, AddPointer->PointerSize * 8 - 1), 1) != 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;
-}
-
-
-//
-// 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 successfuly 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.
-
- @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 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
- )
-{
- CONST ORDERED_COLLECTION_ENTRY *TrackerEntry;
- CONST ORDERED_COLLECTION_ENTRY *TrackerEntry2;
- 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);
-
- 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));
- return EFI_OUT_OF_RESOURCES;
- }
-
- Status = AcpiProtocol->InstallAcpiTable (AcpiProtocol,
- (VOID *)(UINTN)PointerValue, TableSize,
- &InstalledKey[*NumInstalled]);
- if (EFI_ERROR (Status)) {
- DEBUG ((EFI_D_ERROR, "%a: InstallAcpiTable(): %r\n", __FUNCTION__,
- Status));
- return Status;
- }
- ++*NumInstalled;
- return EFI_SUCCESS;
-}
-
-
-/**
- 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;
- ORDERED_COLLECTION *Tracker;
- UINTN *InstalledKey;
- INT32 Installed;
- ORDERED_COLLECTION_ENTRY *TrackerEntry, *TrackerEntry2;
-
- 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;
- }
- QemuFwCfgSelectItem (FwCfgItem);
- QemuFwCfgReadBytes (FwCfgSize, LoaderStart);
- LoaderEnd = LoaderStart + FwCfgSize / sizeof *LoaderEntry;
-
- Tracker = OrderedCollectionInit (BlobCompare, BlobKeyCompare);
- if (Tracker == NULL) {
- Status = EFI_OUT_OF_RESOURCES;
- goto FreeLoader;
- }
-
- //
- // first pass: process the commands
- //
- 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;
-
- default:
- DEBUG ((EFI_D_VERBOSE, "%a: unknown loader command: 0x%x\n",
- __FUNCTION__, LoaderEntry->Type));
- break;
- }
-
- if (EFI_ERROR (Status)) {
- goto FreeTracker;
- }
- }
-
- InstalledKey = AllocatePool (INSTALLED_TABLES_MAX * sizeof *InstalledKey);
- if (InstalledKey == NULL) {
- Status = EFI_OUT_OF_RESOURCES;
- goto FreeTracker;
- }
-
- //
- // 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);
- if (EFI_ERROR (Status)) {
- break;
- }
- }
- }
-
- 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));
- }
-
- FreePool (InstalledKey);
-
-FreeTracker:
- //
- // 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);
-
-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.<BR>
-
- This program and the accompanying materials are licensed and made available
- under the terms and conditions of the BSD License which accompanies this
- distribution. The full text of the license may be found at
- http://opensource.org/licenses/bsd-license.php
-
- 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 22ce165852..0000000000
--- a/OvmfPkg/AcpiPlatformDxe/QemuFwCfgAcpiPlatformDxe.inf
+++ /dev/null
@@ -1,56 +0,0 @@
-## @file
-# OVMF ACPI Platform Driver using QEMU's fw-cfg interface
-#
-# Copyright (c) 2008 - 2014, Intel Corporation. All rights reserved.<BR>
-# This program and the accompanying materials
-# are licensed and made available under the terms and conditions of the BSD License
-# which accompanies this distribution. The full text of the license may be found at
-# http://opensource.org/licenses/bsd-license.php
-#
-# 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
-
-[Packages]
- MdePkg/MdePkg.dec
- MdeModulePkg/MdeModulePkg.dec
- OvmfPkg/OvmfPkg.dec
-
-[LibraryClasses]
- BaseLib
- DebugLib
- MemoryAllocationLib
- OrderedCollectionLib
- QemuFwCfgLib
- UefiBootServicesTableLib
- UefiDriverEntryPoint
-
-[Protocols]
- gEfiAcpiTableProtocolGuid # PROTOCOL ALWAYS_CONSUMED
- gEfiPciEnumerationCompleteProtocolGuid # PROTOCOL SOMETIMES_CONSUMED
-
-[Pcd]
- gEfiMdeModulePkgTokenSpaceGuid.PcdPciDisableBusEnumeration
-
-[Depex]
- gEfiAcpiTableProtocolGuid
diff --git a/OvmfPkg/AcpiPlatformDxe/QemuLoader.h b/OvmfPkg/AcpiPlatformDxe/QemuLoader.h
deleted file mode 100644
index 84dec06422..0000000000
--- a/OvmfPkg/AcpiPlatformDxe/QemuLoader.h
+++ /dev/null
@@ -1,86 +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/Base.h>
-#include <Library/QemuFwCfgLib.h>
-
-//
-// 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
-} 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;
-
-typedef struct {
- UINT32 Type; // QEMU_LOADER_COMMAND_TYPE values
- union {
- QEMU_LOADER_ALLOCATE Allocate;
- QEMU_LOADER_ADD_POINTER AddPointer;
- QEMU_LOADER_ADD_CHECKSUM AddChecksum;
- 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.<BR>
- Copyright (c) 2012, Bei Guan <gbtju85@gmail.com>
-
- This program and the accompanying materials
- are licensed and made available under the terms and conditions of the BSD License
- which accompanies this distribution. The full text of the license may be found at
- http://opensource.org/licenses/bsd-license.php
-
- 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 <Library/HobLib.h>
-#include <Guid/XenInfo.h>
-#include <Library/BaseLib.h>
-
-#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/AcpiS3SaveDxe/AcpiS3Save.c b/OvmfPkg/AcpiS3SaveDxe/AcpiS3Save.c
deleted file mode 100644
index f20560f8fe..0000000000
--- a/OvmfPkg/AcpiS3SaveDxe/AcpiS3Save.c
+++ /dev/null
@@ -1,558 +0,0 @@
-/** @file
- This is a replacement for the ACPI S3 Save protocol.
-
- The ACPI S3 Save protocol used to be defined in the S3 boot path
- specification 0.9. Instead, the same functionality is now hooked to the
- End-of-Dxe event.
-
-Copyright (c) 2014-2015, Red Hat, Inc.<BR>
-Copyright (c) 2006 - 2013, Intel Corporation. All rights reserved.<BR>
-
-This program and the accompanying materials
-are licensed and made available under the terms and conditions
-of the BSD License which accompanies this distribution. The
-full text of the license may be found at
-http://opensource.org/licenses/bsd-license.php
-
-THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
-WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
-
-**/
-
-#include <PiDxe.h>
-#include <Library/BaseLib.h>
-#include <Library/BaseMemoryLib.h>
-#include <Library/UefiBootServicesTableLib.h>
-#include <Library/UefiRuntimeServicesTableLib.h>
-#include <Library/HobLib.h>
-#include <Library/LockBoxLib.h>
-#include <Library/PcdLib.h>
-#include <Library/DebugLib.h>
-#include <Library/QemuFwCfgLib.h>
-#include <Guid/AcpiVariableCompatibility.h>
-#include <Guid/AcpiS3Context.h>
-#include <Guid/Acpi.h>
-#include <Guid/EventGroup.h>
-#include <Protocol/LockBox.h>
-#include <IndustryStandard/Acpi.h>
-
-EFI_GUID mAcpiS3IdtrProfileGuid = {
- 0xdea652b0, 0xd587, 0x4c54, { 0xb5, 0xb4, 0xc6, 0x82, 0xe7, 0xa0, 0xaa, 0x3d }
-};
-
-/**
- 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.
-
-**/
-VOID*
-AllocateMemoryBelow4G (
- IN EFI_MEMORY_TYPE MemoryType,
- IN UINTN Size
- )
-{
- UINTN Pages;
- EFI_PHYSICAL_ADDRESS Address;
- EFI_STATUS Status;
- VOID* Buffer;
-
- Pages = EFI_SIZE_TO_PAGES (Size);
- Address = 0xffffffff;
-
- Status = gBS->AllocatePages (
- AllocateMaxAddress,
- MemoryType,
- Pages,
- &Address
- );
- ASSERT_EFI_ERROR (Status);
-
- Buffer = (VOID *) (UINTN) Address;
- ZeroMem (Buffer, Size);
-
- return Buffer;
-}
-
-/**
-
- This function scan ACPI table in RSDT.
-
- @param Rsdt ACPI RSDT
- @param Signature ACPI table signature
-
- @return ACPI table
-
-**/
-VOID *
-ScanTableInRSDT (
- IN EFI_ACPI_DESCRIPTION_HEADER *Rsdt,
- IN UINT32 Signature
- )
-{
- UINTN Index;
- UINT32 EntryCount;
- UINT32 *EntryPtr;
- EFI_ACPI_DESCRIPTION_HEADER *Table;
-
- if (Rsdt == NULL) {
- return NULL;
- }
-
- EntryCount = (Rsdt->Length - sizeof (EFI_ACPI_DESCRIPTION_HEADER)) / sizeof(UINT32);
-
- EntryPtr = (UINT32 *)(Rsdt + 1);
- for (Index = 0; Index < EntryCount; Index ++, EntryPtr ++) {
- Table = (EFI_ACPI_DESCRIPTION_HEADER *)((UINTN)(*EntryPtr));
- if (Table->Signature == Signature) {
- return Table;
- }
- }
-
- return NULL;
-}
-
-/**
-
- This function scan ACPI table in XSDT.
-
- @param Xsdt ACPI XSDT
- @param Signature ACPI table signature
-
- @return ACPI table
-
-**/
-VOID *
-ScanTableInXSDT (
- IN EFI_ACPI_DESCRIPTION_HEADER *Xsdt,
- IN UINT32 Signature
- )
-{
- UINTN Index;
- UINT32 EntryCount;
- UINT64 EntryPtr;
- UINTN BasePtr;
- EFI_ACPI_DESCRIPTION_HEADER *Table;
-
- if (Xsdt == NULL) {
- return NULL;
- }
-
- EntryCount = (Xsdt->Length - sizeof (EFI_ACPI_DESCRIPTION_HEADER)) / sizeof(UINT64);
-
- BasePtr = (UINTN)(Xsdt + 1);
- for (Index = 0; Index < EntryCount; Index ++) {
- CopyMem (&EntryPtr, (VOID *)(BasePtr + Index * sizeof(UINT64)), sizeof(UINT64));
- Table = (EFI_ACPI_DESCRIPTION_HEADER *)((UINTN)(EntryPtr));
- if (Table->Signature == Signature) {
- return Table;
- }
- }
-
- return NULL;
-}
-
-/**
- To find Facs in FADT.
-
- @param Fadt FADT table pointer
-
- @return Facs table pointer.
-**/
-EFI_ACPI_2_0_FIRMWARE_ACPI_CONTROL_STRUCTURE *
-FindAcpiFacsFromFadt (
- IN EFI_ACPI_2_0_FIXED_ACPI_DESCRIPTION_TABLE *Fadt
- )
-{
- EFI_ACPI_2_0_FIRMWARE_ACPI_CONTROL_STRUCTURE *Facs;
- UINT64 Data64;
-
- if (Fadt == NULL) {
- return NULL;
- }
-
- if (Fadt->Header.Revision < EFI_ACPI_2_0_FIXED_ACPI_DESCRIPTION_TABLE_REVISION) {
- Facs = (EFI_ACPI_2_0_FIRMWARE_ACPI_CONTROL_STRUCTURE *)(UINTN)Fadt->FirmwareCtrl;
- } else {
- if (Fadt->FirmwareCtrl != 0) {
- Facs = (EFI_ACPI_2_0_FIRMWARE_ACPI_CONTROL_STRUCTURE *)(UINTN)Fadt->FirmwareCtrl;
- } else {
- CopyMem (&Data64, &Fadt->XFirmwareCtrl, sizeof(UINT64));
- Facs = (EFI_ACPI_2_0_FIRMWARE_ACPI_CONTROL_STRUCTURE *)(UINTN)Data64;
- }
- }
- return Facs;
-}
-
-/**
- To find Facs in Acpi tables.
-
- To find Firmware ACPI control strutcure in Acpi Tables since the S3 waking vector is stored
- in the table.
-
- @param AcpiTableGuid The guid used to find ACPI table in UEFI ConfigurationTable.
-
- @return Facs table pointer.
-**/
-EFI_ACPI_2_0_FIRMWARE_ACPI_CONTROL_STRUCTURE *
-FindAcpiFacsTableByAcpiGuid (
- IN EFI_GUID *AcpiTableGuid
- )
-{
- EFI_ACPI_2_0_ROOT_SYSTEM_DESCRIPTION_POINTER *Rsdp;
- EFI_ACPI_DESCRIPTION_HEADER *Rsdt;
- EFI_ACPI_DESCRIPTION_HEADER *Xsdt;
- EFI_ACPI_2_0_FIXED_ACPI_DESCRIPTION_TABLE *Fadt;
- EFI_ACPI_2_0_FIRMWARE_ACPI_CONTROL_STRUCTURE *Facs;
- UINTN Index;
-
- Rsdp = NULL;
- //
- // found ACPI table RSD_PTR from system table
- //
- for (Index = 0; Index < gST->NumberOfTableEntries; Index++) {
- if (CompareGuid (&(gST->ConfigurationTable[Index].VendorGuid), AcpiTableGuid)) {
- //
- // A match was found.
- //
- Rsdp = gST->ConfigurationTable[Index].VendorTable;
- break;
- }
- }
-
- if (Rsdp == NULL) {
- return NULL;
- }
-
- //
- // Search XSDT
- //
- if (Rsdp->Revision >= EFI_ACPI_2_0_ROOT_SYSTEM_DESCRIPTION_POINTER_REVISION) {
- Xsdt = (EFI_ACPI_DESCRIPTION_HEADER *)(UINTN) Rsdp->XsdtAddress;
- Fadt = ScanTableInXSDT (Xsdt, EFI_ACPI_2_0_FIXED_ACPI_DESCRIPTION_TABLE_SIGNATURE);
- if (Fadt != NULL) {
- Facs = FindAcpiFacsFromFadt (Fadt);
- if (Facs != NULL) {
- return Facs;
- }
- }
- }
-
- //
- // Search RSDT
- //
- Rsdt = (EFI_ACPI_DESCRIPTION_HEADER *)(UINTN) Rsdp->RsdtAddress;
- Fadt = ScanTableInRSDT (Rsdt, EFI_ACPI_2_0_FIXED_ACPI_DESCRIPTION_TABLE_SIGNATURE);
- if (Fadt != NULL) {
- Facs = FindAcpiFacsFromFadt (Fadt);
- if (Facs != NULL) {
- return Facs;
- }
- }
-
- return NULL;
-}
-
-/**
- To find Facs in Acpi tables.
-
- To find Firmware ACPI control strutcure in Acpi Tables since the S3 waking vector is stored
- in the table.
-
- @return Facs table pointer.
-**/
-EFI_ACPI_2_0_FIRMWARE_ACPI_CONTROL_STRUCTURE *
-FindAcpiFacsTable (
- VOID
- )
-{
- EFI_ACPI_2_0_FIRMWARE_ACPI_CONTROL_STRUCTURE *Facs;
-
- Facs = FindAcpiFacsTableByAcpiGuid (&gEfiAcpi20TableGuid);
- if (Facs != NULL) {
- return Facs;
- }
-
- return FindAcpiFacsTableByAcpiGuid (&gEfiAcpi10TableGuid);
-}
-
-/**
- Allocates and fills in the Page Directory and Page Table Entries to
- establish a 1:1 Virtual to Physical mapping.
- If BootScriptExector driver will run in 64-bit mode, this function will establish the 1:1
- virtual to physical mapping page table.
- If BootScriptExector driver will not run in 64-bit mode, this function will do nothing.
-
- @return the 1:1 Virtual to Physical identity mapping page table base address.
-
-**/
-EFI_PHYSICAL_ADDRESS
-S3CreateIdentityMappingPageTables (
- VOID
- )
-{
- if (FeaturePcdGet (PcdDxeIplSwitchToLongMode)) {
- UINT32 RegEax;
- UINT32 RegEdx;
- UINT8 PhysicalAddressBits;
- UINT32 NumberOfPml4EntriesNeeded;
- UINT32 NumberOfPdpEntriesNeeded;
- EFI_PHYSICAL_ADDRESS S3NvsPageTableAddress;
- UINTN TotalPageTableSize;
- VOID *Hob;
- BOOLEAN Page1GSupport;
-
- 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;
- }
- }
- }
-
- //
- // Get physical address bits supported.
- //
- Hob = GetFirstHob (EFI_HOB_TYPE_CPU);
- if (Hob != NULL) {
- PhysicalAddressBits = ((EFI_HOB_CPU *) Hob)->SizeOfMemorySpace;
- } else {
- AsmCpuid (0x80000000, &RegEax, NULL, NULL, NULL);
- if (RegEax >= 0x80000008) {
- AsmCpuid (0x80000008, &RegEax, NULL, NULL, NULL);
- PhysicalAddressBits = (UINT8) RegEax;
- } else {
- PhysicalAddressBits = 36;
- }
- }
-
- //
- // IA-32e paging translates 48-bit linear addresses to 52-bit physical addresses.
- //
- ASSERT (PhysicalAddressBits <= 52);
- if (PhysicalAddressBits > 48) {
- PhysicalAddressBits = 48;
- }
-
- //
- // Calculate the table entries needed.
- //
- if (PhysicalAddressBits <= 39 ) {
- NumberOfPml4EntriesNeeded = 1;
- NumberOfPdpEntriesNeeded = (UINT32)LShiftU64 (1, (PhysicalAddressBits - 30));
- } else {
- NumberOfPml4EntriesNeeded = (UINT32)LShiftU64 (1, (PhysicalAddressBits - 39));
- NumberOfPdpEntriesNeeded = 512;
- }
-
- //
- // We need calculate whole page size then allocate once, because S3 restore page table does not know each page in Nvs.
- //
- if (!Page1GSupport) {
- TotalPageTableSize = (UINTN)(1 + NumberOfPml4EntriesNeeded + NumberOfPml4EntriesNeeded * NumberOfPdpEntriesNeeded);
- } else {
- TotalPageTableSize = (UINTN)(1 + NumberOfPml4EntriesNeeded);
- }
- DEBUG ((EFI_D_ERROR, "TotalPageTableSize - %Lx pages\n",
- (UINT64)TotalPageTableSize));
-
- //
- // By architecture only one PageMapLevel4 exists - so lets allocate storage for it.
- //
- S3NvsPageTableAddress = (EFI_PHYSICAL_ADDRESS)(UINTN)AllocateMemoryBelow4G (EfiReservedMemoryType, EFI_PAGES_TO_SIZE(TotalPageTableSize));
- ASSERT (S3NvsPageTableAddress != 0);
- return S3NvsPageTableAddress;
- } else {
- //
- // If DXE is running 32-bit mode, no need to establish page table.
- //
- return (EFI_PHYSICAL_ADDRESS) 0;
- }
-}
-
-/**
- Prepares all information that is needed in the S3 resume boot path.
-
- Allocate the resources or prepare informations and save in ACPI variable set for S3 resume boot path
-
- @retval EFI_SUCCESS All information was saved successfully.
-**/
-STATIC
-EFI_STATUS
-EFIAPI
-S3Ready (
- VOID
- )
-{
- EFI_STATUS Status;
- EFI_PHYSICAL_ADDRESS AcpiS3ContextBuffer;
- ACPI_S3_CONTEXT *AcpiS3Context;
- STATIC BOOLEAN AlreadyEntered;
- IA32_DESCRIPTOR *Idtr;
- IA32_IDT_GATE_DESCRIPTOR *IdtGate;
-
- DEBUG ((EFI_D_INFO, "S3Ready!\n"));
-
- ASSERT (!AlreadyEntered);
- if (AlreadyEntered) {
- return EFI_SUCCESS;
- }
- AlreadyEntered = TRUE;
-
- AcpiS3Context = AllocateMemoryBelow4G (EfiReservedMemoryType, sizeof(*AcpiS3Context));
- ASSERT (AcpiS3Context != NULL);
- AcpiS3ContextBuffer = (EFI_PHYSICAL_ADDRESS)(UINTN)AcpiS3Context;
-
- //
- // Get ACPI Table because we will save its position to variable
- //
- AcpiS3Context->AcpiFacsTable = (EFI_PHYSICAL_ADDRESS)(UINTN)FindAcpiFacsTable ();
- ASSERT (AcpiS3Context->AcpiFacsTable != 0);
-
- IdtGate = AllocateMemoryBelow4G (EfiReservedMemoryType, sizeof(IA32_IDT_GATE_DESCRIPTOR) * 0x100 + sizeof(IA32_DESCRIPTOR));
- Idtr = (IA32_DESCRIPTOR *)(IdtGate + 0x100);
- Idtr->Base = (UINTN)IdtGate;
- Idtr->Limit = (UINT16)(sizeof(IA32_IDT_GATE_DESCRIPTOR) * 0x100 - 1);
- AcpiS3Context->IdtrProfile = (EFI_PHYSICAL_ADDRESS)(UINTN)Idtr;
-
- Status = SaveLockBox (
- &mAcpiS3IdtrProfileGuid,
- (VOID *)(UINTN)Idtr,
- (UINTN)sizeof(IA32_DESCRIPTOR)
- );
- ASSERT_EFI_ERROR (Status);
-
- Status = SetLockBoxAttributes (&mAcpiS3IdtrProfileGuid, LOCK_BOX_ATTRIBUTE_RESTORE_IN_PLACE);
- ASSERT_EFI_ERROR (Status);
-
- //
- // Allocate page table
- //
- AcpiS3Context->S3NvsPageTableAddress = S3CreateIdentityMappingPageTables ();
-
- //
- // Allocate stack
- //
- AcpiS3Context->BootScriptStackSize = PcdGet32 (PcdS3BootScriptStackSize);
- AcpiS3Context->BootScriptStackBase = (EFI_PHYSICAL_ADDRESS)(UINTN)AllocateMemoryBelow4G (EfiReservedMemoryType, PcdGet32 (PcdS3BootScriptStackSize));
- ASSERT (AcpiS3Context->BootScriptStackBase != 0);
-
- //
- // Allocate a code buffer < 4G for S3 debug to load external code, set invalid code instructions in it.
- //
- AcpiS3Context->S3DebugBufferAddress = (EFI_PHYSICAL_ADDRESS)(UINTN)AllocateMemoryBelow4G (EfiReservedMemoryType, EFI_PAGE_SIZE);
- SetMem ((VOID *)(UINTN)AcpiS3Context->S3DebugBufferAddress, EFI_PAGE_SIZE, 0xff);
-
- DEBUG ((EFI_D_INFO, "AcpiS3Context: AcpiFacsTable is 0x%8Lx\n",
- AcpiS3Context->AcpiFacsTable));
- DEBUG ((EFI_D_INFO, "AcpiS3Context: IdtrProfile is 0x%8Lx\n",
- AcpiS3Context->IdtrProfile));
- DEBUG ((EFI_D_INFO, "AcpiS3Context: S3NvsPageTableAddress is 0x%8Lx\n",
- AcpiS3Context->S3NvsPageTableAddress));
- DEBUG ((EFI_D_INFO, "AcpiS3Context: S3DebugBufferAddress is 0x%8Lx\n",
- AcpiS3Context->S3DebugBufferAddress));
-
- Status = SaveLockBox (
- &gEfiAcpiVariableGuid,
- &AcpiS3ContextBuffer,
- sizeof(AcpiS3ContextBuffer)
- );
- ASSERT_EFI_ERROR (Status);
-
- Status = SaveLockBox (
- &gEfiAcpiS3ContextGuid,
- (VOID *)(UINTN)AcpiS3Context,
- (UINTN)sizeof(*AcpiS3Context)
- );
- ASSERT_EFI_ERROR (Status);
-
- Status = SetLockBoxAttributes (&gEfiAcpiS3ContextGuid, LOCK_BOX_ATTRIBUTE_RESTORE_IN_PLACE);
- ASSERT_EFI_ERROR (Status);
-
- return EFI_SUCCESS;
-}
-
-/**
- Callback function executed when the EndOfDxe event group is signaled.
-
- @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.
-**/
-VOID
-EFIAPI
-OnEndOfDxe (
- IN EFI_EVENT Event,
- IN VOID *Context
- )
-{
- EFI_STATUS Status;
-
- //
- // Our S3Ready() function always succeeds.
- //
- Status = S3Ready ();
- ASSERT_EFI_ERROR (Status);
-
- //
- // Close the event, deregistering the callback and freeing resources.
- //
- Status = gBS->CloseEvent (Event);
- ASSERT_EFI_ERROR (Status);
-}
-
-
-/**
- The Driver Entry Point.
-
- The function is the driver Entry point that will register the End-of-Dxe
- callback.
-
- @param ImageHandle A handle for the image that is initializing this driver
- @param SystemTable A pointer to the EFI system table
-
- @retval EFI_SUCCESS: Driver initialized successfully
- @retval EFI_LOAD_ERROR: Failed to Initialize or has been loaded
- @retval EFI_OUT_OF_RESOURCES Could not allocate needed resources
-
-**/
-EFI_STATUS
-EFIAPI
-InstallEndOfDxeCallback (
- IN EFI_HANDLE ImageHandle,
- IN EFI_SYSTEM_TABLE *SystemTable
- )
-{
- EFI_STATUS Status;
- EFI_EVENT EndOfDxeEvent;
-
- if (!QemuFwCfgS3Enabled()) {
- return EFI_LOAD_ERROR;
- }
-
- Status = gBS->InstallMultipleProtocolInterfaces (
- &ImageHandle,
- &gEfiLockBoxProtocolGuid, NULL,
- NULL
- );
- ASSERT_EFI_ERROR (Status);
-
- Status = gBS->CreateEventEx (
- EVT_NOTIFY_SIGNAL,
- TPL_CALLBACK,
- OnEndOfDxe,
- NULL, /* NotifyContext */
- &gEfiEndOfDxeEventGroupGuid,
- &EndOfDxeEvent
- );
- ASSERT_EFI_ERROR (Status);
- return Status;
-}
diff --git a/OvmfPkg/AcpiS3SaveDxe/AcpiS3SaveDxe.inf b/OvmfPkg/AcpiS3SaveDxe/AcpiS3SaveDxe.inf
deleted file mode 100644
index 4cc0713d1a..0000000000
--- a/OvmfPkg/AcpiS3SaveDxe/AcpiS3SaveDxe.inf
+++ /dev/null
@@ -1,76 +0,0 @@
-## @file
-# AcpiS3Save module installs EndOfDxe callback to prepare S3 boot data.
-#
-# Copyright (c) 2006 - 2011, Intel Corporation. All rights reserved.<BR>
-#
-# This program and the accompanying materials are
-# licensed and made available under the terms and conditions of the BSD License
-# which accompanies this distribution. The full text of the license may be found at
-# http://opensource.org/licenses/bsd-license.php
-#
-# THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
-# WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
-#
-##
-
-[Defines]
- INF_VERSION = 0x00010005
- BASE_NAME = AcpiS3SaveDxe
- FILE_GUID = 6B79BBC0-26B9-4FE9-B631-551D8AB078C6
- MODULE_TYPE = DXE_DRIVER
- VERSION_STRING = 1.0
-
- ENTRY_POINT = InstallEndOfDxeCallback
-
-#
-# The following information is for reference only and not required by the build tools.
-#
-# VALID_ARCHITECTURES = IA32 X64
-#
-
-[Sources]
- AcpiS3Save.c
-
-[Packages]
- MdePkg/MdePkg.dec
- MdeModulePkg/MdeModulePkg.dec
- IntelFrameworkPkg/IntelFrameworkPkg.dec
- IntelFrameworkModulePkg/IntelFrameworkModulePkg.dec
- OvmfPkg/OvmfPkg.dec
-
-[LibraryClasses]
- PcdLib
- UefiRuntimeServicesTableLib
- UefiBootServicesTableLib
- UefiDriverEntryPoint
- BaseMemoryLib
- HobLib
- UefiLib
- LockBoxLib
- DebugLib
- DxeServicesLib
- QemuFwCfgLib
-
-[Guids]
- gEfiAcpiVariableGuid # ALWAYS_CONSUMED
- gEfiAcpiS3ContextGuid # ALWAYS_CONSUMED
- gEfiAcpi20TableGuid # ALWAYS_CONSUMED System Table
- gEfiAcpi10TableGuid # ALWAYS_CONSUMED System Table
- gEfiEndOfDxeEventGroupGuid ## CONSUMES ## Event
-
-[Protocols]
- gEfiLockBoxProtocolGuid # PROTOCOL ALWAYS_PRODUCED
- gEfiLegacyBiosProtocolGuid # PROTOCOL ALWAYS_CONSUMED
- gEfiLegacyRegion2ProtocolGuid # PROTOCOL SOMETIMES_CONSUMED
- gFrameworkEfiMpServiceProtocolGuid # PROTOCOL SOMETIMES_CONSUMED
-
-[FeaturePcd]
- gEfiMdeModulePkgTokenSpaceGuid.PcdDxeIplSwitchToLongMode
-
-[Pcd]
- gEfiIntelFrameworkModulePkgTokenSpaceGuid.PcdS3AcpiReservedMemorySize ## CONSUMES
- gEfiIntelFrameworkModulePkgTokenSpaceGuid.PcdS3BootScriptStackSize ## CONSUMES
- gEfiMdeModulePkgTokenSpaceGuid.PcdUse1GPageTable
-
-[Depex]
- gEfiVariableArchProtocolGuid AND gEfiVariableWriteArchProtocolGuid
diff --git a/OvmfPkg/AcpiTables/AcpiTables.inf b/OvmfPkg/AcpiTables/AcpiTables.inf
deleted file mode 100644
index 1187a145e5..0000000000
--- a/OvmfPkg/AcpiTables/AcpiTables.inf
+++ /dev/null
@@ -1,40 +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.<BR>
-# This program and the accompanying materials
-# are licensed and made available under the terms and conditions of the BSD License
-# which accompanies this distribution. The full text of the license may be found at
-# http://opensource.org/licenses/bsd-license.php
-#
-# 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
-
diff --git a/OvmfPkg/AcpiTables/Dsdt.asl b/OvmfPkg/AcpiTables/Dsdt.asl
deleted file mode 100644
index 519a31250a..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.<BR>
- This program and the accompanying materials are
- licensed and made available under the terms and conditions of the BSD License
- which accompanies this distribution. The full text of the license may be found at
- http://opensource.org/licenses/bsd-license.php
-
- 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) {
- //
- // 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, NotSerialized) {
- //
- // 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, 0x402, 0x402, 0x00, 0x01) // QEMU debug console, should use FixedPcdGet16 (PcdDebugIoPort)
- 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.<BR>
- This program and the accompanying materials are
- licensed and made available under the terms and conditions of the BSD License
- which accompanies this distribution. The full text of the license may be found at
- http://opensource.org/licenses/bsd-license.php
-
- 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.<BR>
- This program and the accompanying materials are
- licensed and made available under the terms and conditions of the BSD License
- which accompanies this distribution. The full text of the license may be found at
- http://opensource.org/licenses/bsd-license.php
-
- THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
- WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
-
-**/
-
-#include <IndustryStandard/Acpi.h>
-
-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.<BR>
- This program and the accompanying materials are
- licensed and made available under the terms and conditions of the BSD License
- which accompanies this distribution. The full text of the license may be found at
- http://opensource.org/licenses/bsd-license.php
-
- THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
- WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
-
-**/
-
-#include <IndustryStandard/Acpi.h>
-#include <Platform.h>
-
-//
-// 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.<BR>
- This program and the accompanying materials are
- licensed and made available under the terms and conditions of the BSD License
- which accompanies this distribution. The full text of the license may be found at
- http://opensource.org/licenses/bsd-license.php
-
- 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 <PiDxe.h>
-#include <IndustryStandard/Acpi.h>
-
-//
-// 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.<BR>
- This program and the accompanying materials
- are licensed and made available under the terms and conditions of the BSD License
- which accompanies this distribution. The full text of the license may be found at
- http://opensource.org/licenses/bsd-license.php
-
- 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.<BR>
- This program and the accompanying materials
- are licensed and made available under the terms and conditions of the BSD License
- which accompanies this distribution. The full text of the license may be found at
- http://opensource.org/licenses/bsd-license.php
-
- 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 <Uefi.h>
-#include <Protocol/BlockMmio.h>
-#include <Protocol/ComponentName.h>
-#include <Protocol/ComponentName2.h>
-#include <Protocol/CpuIo2.h>
-#include <Protocol/DevicePath.h>
-#include <Protocol/DriverBinding.h>
-#include <Library/BaseLib.h>
-#include <Library/DebugLib.h>
-#include <Library/MemoryAllocationLib.h>
-#include <Library/UefiBootServicesTableLib.h>
-#include <Library/UefiLib.h>
-
-#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.<BR>
-#
-# This program and the accompanying materials
-# are licensed and made available under the terms and conditions of the BSD License
-# which accompanies this distribution. The full text of the license may be found at
-# http://opensource.org/licenses/bsd-license.php
-#
-# 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.<BR>
- This program and the accompanying materials
- are licensed and made available under the terms and conditions of the BSD License
- which accompanies this distribution. The full text of the license may be found at
- http://opensource.org/licenses/bsd-license.php
-
- 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 <contributor@example.com>
-Subject: [PATCH] CodeModule: Brief-single-line-summary
-
-Full-commit-message
-
-Contributed-under: TianoCore Contribution Agreement 1.0
-Signed-off-by: Contributor Name <contributor@example.com>
----
-
-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.<BR>
-# This program and the accompanying materials
-# are licensed and made available under the terms and conditions of the BSD License
-# which accompanies this distribution. The full text of the license may be found at
-# http://opensource.org/licenses/bsd-license.php
-#
-# 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.<BR>
-
- This program and the accompanying materials are
- licensed and made available under the terms and conditions of the BSD License
- which accompanies this distribution. The full text of the license may be found at
- http://opensource.org/licenses/bsd-license.php
-
- 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.<BR>
-
- This program and the accompanying materials are
- licensed and made available under the terms and conditions of the BSD License
- which accompanies this distribution. The full text of the license may be found at
- http://opensource.org/licenses/bsd-license.php
-
- 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 <Uefi.h>
-
-/**
- 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.<BR>
-# This program and the accompanying materials
-# are licensed and made available under the terms and conditions of the BSD License
-# which accompanies this distribution. The full text of the license may be found at
-# http://opensource.org/licenses/bsd-license.php
-#
-# 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.<BR>
-
- This program and the accompanying materials are
- licensed and made available under the terms and conditions of the BSD License
- which accompanies this distribution. The full text of the license may be found at
- http://opensource.org/licenses/bsd-license.php
-
- 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.<BR>
-
- This program and the accompanying materials are
- licensed and made available under the terms and conditions of the BSD License
- which accompanies this distribution. The full text of the license may be found at
- http://opensource.org/licenses/bsd-license.php
-
- 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 <PiDxe.h>
-
-#include <Protocol/LegacyInterrupt.h>
-
-#include <Library/PcdLib.h>
-#include <Library/PciLib.h>
-#include <Library/DebugLib.h>
-#include <Library/UefiBootServicesTableLib.h>
-#include <OvmfPlatforms.h>
-
-
-#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 0ccfa97585..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.<BR>
-
- This program and the accompanying materials are
- licensed and made available under the terms and conditions of the BSD License
- which accompanies this distribution. The full text of the license may be found at
- http://opensource.org/licenses/bsd-license.php
-
- 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. Ths 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.<BR>
-
- This program and the accompanying materials are
- licensed and made available under the terms and conditions of the BSD License
- which accompanies this distribution. The full text of the license may be found at
- http://opensource.org/licenses/bsd-license.php
-
- 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 <FrameworkDxe.h>
-
-#include <Protocol/PciIo.h>
-#include <Protocol/PciRootBridgeIo.h>
-#include <Protocol/DevicePath.h>
-#include <Protocol/LegacyInterrupt.h>
-#include <Protocol/LegacyRegion2.h>
-#include <Protocol/LegacyBiosPlatform.h>
-#include <Protocol/FirmwareVolume.h>
-#include <Protocol/DiskInfo.h>
-
-#include <Library/UefiDriverEntryPoint.h>
-#include <Library/UefiBootServicesTableLib.h>
-#include <Library/UefiRuntimeServicesTableLib.h>
-#include <Library/DebugLib.h>
-#include <Library/BaseMemoryLib.h>
-#include <Library/MemoryAllocationLib.h>
-#include <Library/IoLib.h>
-#include <Library/PciLib.h>
-#include <Library/PcdLib.h>
-#include <Library/DxeServicesLib.h>
-#include <Library/DevicePathLib.h>
-
-#include <IndustryStandard/Pci.h>
-
-//
-// 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 44d340be68..0000000000
--- a/OvmfPkg/Csm/CsmSupportLib/LegacyRegion.c
+++ /dev/null
@@ -1,466 +0,0 @@
-/** @file
- Legacy Region Support
-
- Copyright (c) 2006 - 2011, Intel Corporation. All rights reserved.<BR>
-
- This program and the accompanying materials are
- licensed and made available under the terms and conditions of the BSD License
- which accompanies this distribution. The full text of the license may be found at
- http://opensource.org/licenses/bsd-license.php
-
- THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
- WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
-
-**/
-
-#include "LegacyRegion.h"
-
-//
-// 440 PAM map.
-//
-// PAM Range Offset Bits Operation
-// =============== ====== ==== ===============================================================
-// 0xC0000-0xC3FFF 0x5a 1:0 00 = DRAM Disabled, 01= Read Only, 10 = Write Only, 11 = Normal
-// 0xC4000-0xC7FFF 0x5a 5:4 00 = DRAM Disabled, 01= Read Only, 10 = Write Only, 11 = Normal
-// 0xC8000-0xCBFFF 0x5b 1:0 00 = DRAM Disabled, 01= Read Only, 10 = Write Only, 11 = Normal
-// 0xCC000-0xCFFFF 0x5b 5:4 00 = DRAM Disabled, 01= Read Only, 10 = Write Only, 11 = Normal
-// 0xD0000-0xD3FFF 0x5c 1:0 00 = DRAM Disabled, 01= Read Only, 10 = Write Only, 11 = Normal
-// 0xD4000-0xD7FFF 0x5c 5:4 00 = DRAM Disabled, 01= Read Only, 10 = Write Only, 11 = Normal
-// 0xD8000-0xDBFFF 0x5d 1:0 00 = DRAM Disabled, 01= Read Only, 10 = Write Only, 11 = Normal
-// 0xDC000-0xDFFFF 0x5d 5:4 00 = DRAM Disabled, 01= Read Only, 10 = Write Only, 11 = Normal
-// 0xE0000-0xE3FFF 0x5e 1:0 00 = DRAM Disabled, 01= Read Only, 10 = Write Only, 11 = Normal
-// 0xE4000-0xE7FFF 0x5e 5:4 00 = DRAM Disabled, 01= Read Only, 10 = Write Only, 11 = Normal
-// 0xE8000-0xEBFFF 0x5f 1:0 00 = DRAM Disabled, 01= Read Only, 10 = Write Only, 11 = Normal
-// 0xEC000-0xEFFFF 0x5f 5:4 00 = DRAM Disabled, 01= Read Only, 10 = Write Only, 11 = Normal
-// 0xF0000-0xFFFFF 0x59 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 mRegisterValues[] = {
- {REG_PAM1_OFFSET, 0x01, 0x02},
- {REG_PAM1_OFFSET, 0x10, 0x20},
- {REG_PAM2_OFFSET, 0x01, 0x02},
- {REG_PAM2_OFFSET, 0x10, 0x20},
- {REG_PAM3_OFFSET, 0x01, 0x02},
- {REG_PAM3_OFFSET, 0x10, 0x20},
- {REG_PAM4_OFFSET, 0x01, 0x02},
- {REG_PAM4_OFFSET, 0x10, 0x20},
- {REG_PAM5_OFFSET, 0x01, 0x02},
- {REG_PAM5_OFFSET, 0x10, 0x20},
- {REG_PAM6_OFFSET, 0x01, 0x02},
- {REG_PAM6_OFFSET, 0x10, 0x20},
- {REG_PAM0_OFFSET, 0x10, 0x20}
-};
-
-//
-// 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 < (sizeof(mSectionArray) / sizeof (mSectionArray[0])); Index++) {
- if ((Start >= mSectionArray[Index].Start) && (Start < (mSectionArray[Index].Start + mSectionArray[Index].Length))) {
- StartIndex = Index;
- break;
- }
- }
- ASSERT (Index < (sizeof(mSectionArray) / sizeof (mSectionArray[0])));
-
- //
- // Program PAM until end PAM is encountered
- //
- for (Index = StartIndex; Index < (sizeof(mSectionArray) / sizeof (mSectionArray[0])); 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 < (sizeof(mSectionArray) / sizeof (mSectionArray[0])));
-
- 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;
-
- //
- // 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 805df8656f..0000000000
--- a/OvmfPkg/Csm/CsmSupportLib/LegacyRegion.h
+++ /dev/null
@@ -1,219 +0,0 @@
-/** @file
- Legacy Region Support
-
- Copyright (c) 2008 - 2011, Intel Corporation. All rights reserved.<BR>
-
- This program and the accompanying materials are
- licensed and made available under the terms and conditions of the BSD License
- which accompanies this distribution. The full text of the license may be found at
- http://opensource.org/licenses/bsd-license.php
-
- 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 <PiDxe.h>
-
-#include <Protocol/LegacyRegion2.h>
-
-#include <IndustryStandard/Pci.h>
-
-#include <Library/PciLib.h>
-#include <Library/PcdLib.h>
-#include <Library/DebugLib.h>
-#include <Library/MemoryAllocationLib.h>
-#include <Library/UefiBootServicesTableLib.h>
-
-#define PAM_PCI_BUS 0
-#define PAM_PCI_DEV 0
-#define PAM_PCI_FUNC 0
-
-#define REG_PAM0_OFFSET 0x59 // Programmable Attribute Map 0
-#define REG_PAM1_OFFSET 0x5a // Programmable Attribute Map 1
-#define REG_PAM2_OFFSET 0x5b // Programmable Attribute Map 2
-#define REG_PAM3_OFFSET 0x5c // Programmable Attribute Map 3
-#define REG_PAM4_OFFSET 0x5d // Programmable Attribute Map 4
-#define REG_PAM5_OFFSET 0x5e // Programmable Attribute Map 5
-#define REG_PAM6_OFFSET 0x5f // 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/EmuVariableFvbRuntimeDxe/Fvb.c b/OvmfPkg/EmuVariableFvbRuntimeDxe/Fvb.c
deleted file mode 100644
index 7a8beb3354..0000000000
--- a/OvmfPkg/EmuVariableFvbRuntimeDxe/Fvb.c
+++ /dev/null
@@ -1,917 +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.<BR>
- This program and the accompanying materials
- are licensed and made available under the terms and conditions of the BSD License
- which accompanies this distribution. The full text of the license may be found at
- http://opensource.org/licenses/bsd-license.php
-
- THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
- WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
-
-**/
-
-#include "PiDxe.h"
-#include <Guid/EventGroup.h>
-#include <Guid/SystemNvDataGuid.h>
-#include <Guid/VariableFormat.h>
-
-#include <Protocol/FirmwareVolumeBlock.h>
-#include <Protocol/DevicePath.h>
-
-#include <Library/UefiLib.h>
-#include <Library/UefiDriverEntryPoint.h>
-#include <Library/BaseLib.h>
-#include <Library/UefiRuntimeLib.h>
-#include <Library/DebugLib.h>
-#include <Library/BaseMemoryLib.h>
-#include <Library/MemoryAllocationLib.h>
-#include <Library/UefiBootServicesTableLib.h>
-#include <Library/DevicePathLib.h>
-#include <Library/PcdLib.h>
-#include <Library/PlatformFvbLib.h>
-#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;
-
- 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);
- }
- PcdSet64 (PcdFlashNvStorageVariableBase64, (UINT32)(UINTN) Ptr);
-
- //
- // Initialize the Fault Tolerant Write data area
- //
- SubPtr = (VOID*) ((UINT8*) Ptr + PcdGet32 (PcdVariableStoreSize));
- PcdSet32 (PcdFlashNvStorageFtwWorkingBase, (UINT32)(UINTN) SubPtr);
-
- //
- // Initialize the Fault Tolerant Write spare block
- //
- SubPtr = (VOID*) ((UINT8*) Ptr + EMU_FVB_BLOCK_SIZE);
- PcdSet32 (PcdFlashNvStorageFtwSpareBase, (UINT32)(UINTN) SubPtr);
-
- //
- // 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.<BR>
-This program and the accompanying materials
-are licensed and made available under the terms and conditions of the BSD License
-which accompanies this distribution. The full text of the license may be found at
-http://opensource.org/licenses/bsd-license.php
-
-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.<BR>
-#
-# This program and the accompanying materials
-# are licensed and made available under the terms and conditions of the BSD License
-# which accompanies this distribution. The full text of the license may be found at
-# http://opensource.org/licenses/bsd-license.php
-# 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/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 <andreiw@motorola.com>
-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.<BR>
-
-This program and the accompanying materials
-are licensed and made available under the terms and conditions
-of the BSD License which accompanies this distribution. The
-full text of the license may be found at
-http://opensource.org/licenses/bsd-license.php
-
-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 8cbd685ab5..0000000000
--- a/OvmfPkg/Include/IndustryStandard/I440FxPiix4.h
+++ /dev/null
@@ -1,40 +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 <somlo@cmu.edu>
-
- This program and the accompanying materials are licensed and made available
- under the terms and conditions of the BSD License which accompanies this
- distribution. The full text of the license may be found at
- http://opensource.org/licenses/bsd-license.php
-
- 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 <Library/PciLib.h>
-
-//
-// 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_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:
- <http://www.cs.cmu.edu/~ralf/files.html>
- <http://www.ctyme.com/rbrown.htm>
-
- 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 <Base.h>
-
-#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 b83b7916a0..0000000000
--- a/OvmfPkg/Include/IndustryStandard/LinuxBzimage.h
+++ /dev/null
@@ -1,164 +0,0 @@
-/** @file
-
- Copyright (c) 2011 - 2013, Intel Corporation. All rights reserved.<BR>
- This program and the accompanying materials
- are licensed and made available under the terms and conditions of the BSD License
- which accompanies this distribution. The full text of the license may be found at
- http://opensource.org/licenses/bsd-license.php
-
- 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; /* Lenght 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 18b34a3d4f..0000000000
--- a/OvmfPkg/Include/IndustryStandard/Q35MchIch9.h
+++ /dev/null
@@ -1,98 +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 <somlo@cmu.edu>
-
- This program and the accompanying materials are licensed and made available
- under the terms and conditions of the BSD License which accompanies this
- distribution. The full text of the license may be found at
- http://opensource.org/licenses/bsd-license.php
-
- 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 <Library/PciLib.h>
-
-//
-// 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_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 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/Virtio.h b/OvmfPkg/Include/IndustryStandard/Virtio.h
deleted file mode 100644
index fcf7b67431..0000000000
--- a/OvmfPkg/Include/IndustryStandard/Virtio.h
+++ /dev/null
@@ -1,175 +0,0 @@
-/** @file
-
- Generic type and macro definitions corresponding to the virtio-0.9.5
- specification.
-
- Copyright (C) 2012, Red Hat, Inc.
- Portion of Copyright (C) 2013, ARM Ltd.
-
- This program and the accompanying materials are licensed and made available
- under the terms and conditions of the BSD License which accompanies this
- distribution. The full text of the license may be found at
- http://opensource.org/licenses/bsd-license.php
-
- THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, WITHOUT
- WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
-
-**/
-
-#ifndef _VIRTIO_H_
-#define _VIRTIO_H_
-
-#include <Base.h>
-
-//
-// 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_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 <IndustryStandard/Virtio.h>
-
-
-//
-// 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/VirtioNet.h b/OvmfPkg/Include/IndustryStandard/VirtioNet.h
deleted file mode 100644
index 34bf15a588..0000000000
--- a/OvmfPkg/Include/IndustryStandard/VirtioNet.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, Red Hat, Inc.
-
- This program and the accompanying materials are licensed and made available
- under the terms and conditions of the BSD License which accompanies this
- distribution. The full text of the license may be found at
- http://opensource.org/licenses/bsd-license.php
-
- THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, WITHOUT
- WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
-
-**/
-
-#ifndef _VIRTIO_NET_H_
-#define _VIRTIO_NET_H_
-
-#include <IndustryStandard/Virtio.h>
-
-//
-// virtio-0.9.5, Appendix C: Network Device
-//
-#pragma pack(1)
-typedef struct {
- UINT8 Mac[6];
- UINT16 LinkStatus;
-} VIRTIO_NET_CONFIG;
-#pragma pack()
-
-#define OFFSET_OF_VNET(Field) OFFSET_OF (VIRTIO_NET_CONFIG, Field)
-#define SIZE_OF_VNET(Field) (sizeof ((VIRTIO_NET_CONFIG *) 0)->Field)
-
-//
-// Queue Identifiers
-//
-#define VIRTIO_NET_Q_RX 0
-#define VIRTIO_NET_Q_TX 1
-
-//
-// Feature Bits
-//
-#define VIRTIO_NET_F_CSUM BIT0 // host to checksum outgoing packets
-#define VIRTIO_NET_F_GUEST_CSUM BIT1 // guest to checksum incoming packets
-#define VIRTIO_NET_F_MAC BIT5 // MAC available to guest
-#define VIRTIO_NET_F_GSO BIT6 // deprecated
-#define VIRTIO_NET_F_GUEST_TSO4 BIT7 // guest can receive TSOv4
-#define VIRTIO_NET_F_GUEST_TSO6 BIT8 // guest can receive TSOv6
-#define VIRTIO_NET_F_GUEST_ECN BIT9 // guest can receive TSO with ECN
-#define VIRTIO_NET_F_GUEST_UFO BIT10 // guest can receive UFO
-#define VIRTIO_NET_F_HOST_TSO4 BIT11 // host can receive TSOv4
-#define VIRTIO_NET_F_HOST_TSO6 BIT12 // host can receive TSOv6
-#define VIRTIO_NET_F_HOST_ECN BIT13 // host can receive TSO with ECN
-#define VIRTIO_NET_F_HOST_UFO BIT14 // host can receive UFO
-#define VIRTIO_NET_F_MRG_RXBUF BIT15 // guest can merge receive buffers
-#define VIRTIO_NET_F_STATUS BIT16 // link status available to guest
-#define VIRTIO_NET_F_CTRL_VQ BIT17 // control channel available
-#define VIRTIO_NET_F_CTRL_RX BIT18 // control channel RX mode support
-#define VIRTIO_NET_F_CTRL_VLAN BIT19 // control channel VLAN filtering
-#define VIRTIO_NET_F_GUEST_ANNOUNCE BIT21 // guest can send gratuitous pkts
-
-//
-// Packet Header
-//
-#pragma pack(1)
-typedef struct {
- UINT8 Flags;
- UINT8 GsoType;
- UINT16 HdrLen;
- UINT16 GsoSize;
- UINT16 CsumStart;
- UINT16 CsumOffset;
-} VIRTIO_NET_REQ;
-#pragma pack()
-
-//
-// Bits in VIRTIO_NET_REQ.Flags
-//
-#define VIRTIO_NET_HDR_F_NEEDS_CSUM BIT0
-
-//
-// Types/Bits for VIRTIO_NET_REQ.GsoType
-//
-#define VIRTIO_NET_HDR_GSO_NONE 0x00
-#define VIRTIO_NET_HDR_GSO_TCPV4 0x01
-#define VIRTIO_NET_HDR_GSO_UDP 0x03
-#define VIRTIO_NET_HDR_GSO_TCPV6 0x04
-#define VIRTIO_NET_HDR_GSO_ECN BIT7
-
-//
-// Link Status Bits in VIRTIO_NET_CONFIG.LinkStatus
-//
-#define VIRTIO_NET_S_LINK_UP BIT0
-#define VIRTIO_NET_S_ANNOUNCE BIT1
-
-#endif // _VIRTIO_NET_H_
diff --git a/OvmfPkg/Include/IndustryStandard/VirtioScsi.h b/OvmfPkg/Include/IndustryStandard/VirtioScsi.h
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 <IndustryStandard/Virtio.h>
-
-
-//
-// 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 <dom> and mark as
- * accepting interdomain bindings from domain <remote_dom>. A fresh port
- * is allocated in <dom> and returned as <port>.
- * NOTES:
- * 1. If the caller is unprivileged then <dom> must be DOMID_SELF.
- * 2. <rdom> 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 <port>. 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 <port>.
- */
-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 9083a35775..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 (<dom>,<ref>) for access
- * by devices and/or host CPUs. If successful, <handle> is a tracking number
- * that must be presented later to destroy the mapping(s). On error, <handle>
- * is a negative status code.
- * NOTES:
- * 1. If GNTMAP_device_map is specified then <dev_bus_addr> 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 <host_addr>.
- * 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 <handle>. If <host_addr> or <dev_bus_addr> is zero, that
- * field is ignored. If non-zero, they must refer to a device/host mapping
- * that is tracked by <handle>
- * NOTES:
- * 1. The call may fail in an undefined manner if either mapping is not
- * tracked by <handle>.
- * 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 <hvm/ioreq.h>
- */
-#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 ebed5799bc..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 formated 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: <UINT32>
- * 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: <UINT32>
- * 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: <UINT32>
- * 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: <UINT32>
- * 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: <UINT32> (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: <UINT32>
- *
- * The logical sector size, in bytes, of the backend device.
- *
- * physical-sector-size
- * Values: <UINT32>
- *
- * The physical sector size, in bytes, of the backend device.
- *
- * sectors
- * Values: <UINT64>
- *
- * 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: <UINT32>
- *
- * The identifier of the Xen event channel used to signal activity
- * in the ring buffer.
- *
- * ring-ref
- * Values: <UINT32>
- * 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: <UINT32>
- * 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: <UINT32>
- * 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: <UINT32>
- * 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: <UINT32>
- *
- * 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 <keir@xensource.com>
- */
-
-#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 36ee352e5e..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.<BR>
- This program and the accompanying materials
- are licensed and made available under the terms and conditions of the BSD License
- which accompanies this distribution. The full text of the license may be found at
- http://opensource.org/licenses/bsd-license.php
-
- 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 occured
- @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.<BR>
- This program and the accompanying materials
- are licensed and made available under the terms and conditions of the BSD License
- which accompanies this distribution. The full text of the license may be found at
- http://opensource.org/licenses/bsd-license.php
-
- 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.<BR>
- This program and the accompanying materials
- are licensed and made available under the terms and conditions of the BSD License
- which accompanies this distribution. The full text of the license may be found at
- http://opensource.org/licenses/bsd-license.php
-
- 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 <Protocol/FirmwareVolumeBlock.h>
-
-/**
- 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 80d02c80c2..0000000000
--- a/OvmfPkg/Include/Library/QemuBootOrderLib.h
+++ /dev/null
@@ -1,69 +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 <Uefi/UefiBaseType.h>
-#include <Base.h>
-
-
-/**
-
- 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 BootOptionList, and rewrite the BootOrder NvVar
- so that it corresponds to the order described in fw_cfg.
-
- @param[in] BootOptionList A boot option list, created with
- BdsLibEnumerateAllBootOption ().
-
-
- @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 (
- IN CONST LIST_ENTRY *BootOptionList
- );
-
-
-/**
- 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 baaa257d61..0000000000
--- a/OvmfPkg/Include/Library/QemuFwCfgLib.h
+++ /dev/null
@@ -1,238 +0,0 @@
-/** @file
- QEMU/KVM Firmware Configuration access
-
- Copyright (c) 2011 - 2013, Intel Corporation. All rights reserved.<BR>
- 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__
-
-//
-// The size, in bytes, of names of firmware configuration files, including at
-// least one terminating NUL byte.
-//
-#define QEMU_FW_CFG_FNAME_SIZE 56
-
-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;
-
-
-/**
- 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
- );
-
-
-/**
- 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
- );
-
-
-/**
- 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
-EFIAPI
-InternalQemuFwCfgIsAvailable (
- VOID
- );
-
-
-/**
- Determine if S3 support is explicitly enabled.
-
- @retval TRUE if S3 support is explicitly enabled.
- FALSE otherwise. This includes unavailability of the firmware
- configuration interface.
-**/
-BOOLEAN
-EFIAPI
-QemuFwCfgS3Enabled (
- VOID
- );
-
-#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.<BR>
- This program and the accompanying materials
- are licensed and made available under the terms and conditions of the BSD License
- which accompanies this distribution. The full text of the license may be found at
- http://opensource.org/licenses/bsd-license.php
-
- 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 36527a523f..0000000000
--- a/OvmfPkg/Include/Library/VirtioLib.h
+++ /dev/null
@@ -1,185 +0,0 @@
-/** @file
-
- Declarations of utility functions used by virtio device drivers.
-
- Copyright (C) 2012, Red Hat, Inc.
-
- This program and the accompanying materials are licensed and made available
- under the terms and conditions of the BSD License which accompanies this
- distribution. The full text of the license may be found at
- http://opensource.org/licenses/bsd-license.php
-
- THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, WITHOUT
- WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
-
-**/
-
-#ifndef _VIRTIO_LIB_H_
-#define _VIRTIO_LIB_H_
-
-#include <Protocol/VirtioDevice.h>
-
-#include <IndustryStandard/Virtio.h>
-
-
-/**
-
- 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.
-
-
- @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
- );
-
-#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 509855d302..0000000000
--- a/OvmfPkg/Include/Library/XenHypercallLib.h
+++ /dev/null
@@ -1,95 +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
-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
-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
-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.<BR>
-*
-* This program and the accompanying materials are
-* licensed and made available under the terms and conditions of the BSD License
-* which accompanies this distribution. The full text of the license may be found at
-* http://opensource.org/licenses/bsd-license.php
-*
-* 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 43ab01d57c..0000000000
--- a/OvmfPkg/Include/OvmfPlatforms.h
+++ /dev/null
@@ -1,40 +0,0 @@
-/** @file
- OVMF Platform definitions
-
- Copyright (C) 2015, Red Hat, Inc.
- Copyright (c) 2014, Gabriel L. Somlo <somlo@cmu.edu>
-
- This program and the accompanying materials are licensed and made
- available under the terms and conditions of the BSD License which
- accompanies this distribution. The full text of the license may
- be found at http://opensource.org/licenses/bsd-license.php
-
- 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 <Library/PciLib.h>
-#include <IndustryStandard/Pci22.h>
-#include <IndustryStandard/Q35MchIch9.h>
-#include <IndustryStandard/I440FxPiix4.h>
-
-//
-// OVMF Host Bridge DID Address
-//
-#define OVMF_HOSTBRIDGE_DID \
- PCI_LIB_ADDRESS (0, 0, 0, PCI_DEVICE_ID_OFFSET)
-
-//
-// 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.<BR>
- This program and the accompanying materials
- are licensed and made available under the terms and conditions of the BSD License
- which accompanies this distribution. The full text of the license may be found at
- http://opensource.org/licenses/bsd-license.php
-
- 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 <Protocol/BlockIo.h>
-
-#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 48fca2e14c..0000000000
--- a/OvmfPkg/Include/Protocol/VirtioDevice.h
+++ /dev/null
@@ -1,382 +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.<BR>
-
- This program and the accompanying materials are licensed and made available
- under the terms and conditions of the BSD License which accompanies this
- distribution. The full text of the license may be found at
- http://opensource.org/licenses/bsd-license.php
-
- THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, WITHOUT
- WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
-
-**/
-
-#ifndef __VIRTIO_DEVICE_H__
-#define __VIRTIO_DEVICE_H__
-
-// VirtIo Specification Revision: Major[31:24].Minor[23:16].Revision[15:0
-#define VIRTIO_SPEC_REVISION(major,minor,revision) \
- ((((major) & 0xFF) << 24) | (((minor) & 0xFF) << 16) | ((revision) & 0xFFFF))
-
-#define VIRTIO_DEVICE_PROTOCOL_GUID { \
- 0xfa920010, 0x6785, 0x4941, {0xb6, 0xec, 0x49, 0x8c, 0x57, 0x9f, 0x16, 0x0a }\
- }
-
-typedef struct _VIRTIO_DEVICE_PROTOCOL VIRTIO_DEVICE_PROTOCOL;
-
-/**
-
- Read a word from the device-specific I/O region of the Virtio Header.
-
- @param[in] This This instance of VIRTIO_DEVICE_PROTOCOL
-
- @param[in] FieldOffset Source offset.
-
- @param[in] FieldSize Source field size in bytes, must be in {1, 2, 4, 8}.
-
- @param[in] BufferSize Number of bytes available in the target buffer. Must
- equal FieldSize.
-
- @param[out] Buffer Target buffer.
-
- @retval EFI_SUCCESS The data was read successfully.
- @retval EFI_UNSUPPORTED The underlying IO device doesn't support the
- provided address offset and read size.
- @retval EFI_OUT_OF_RESOURCES The request could not be completed due to a
- lack of resources.
- @retval EFI_INVALID_PARAMETER One or more parameters are invalid.
-
-**/
-typedef
-EFI_STATUS
-(EFIAPI *VIRTIO_DEVICE_READ) (
- IN VIRTIO_DEVICE_PROTOCOL *This,
- IN UINTN FieldOffset,
- IN UINTN FieldSize,
- IN UINTN BufferSize,
- OUT VOID *Buffer
- );
-
-/**
-
- Write a word to the device-specific I/O region of the Virtio Header.
-
- @param[in] This This instance of VIRTIO_DEVICE_PROTOCOL
-
- @param[in] FieldOffset Destination offset.
-
- @param[in] FieldSize Destination field size in bytes,
- must be in {1, 2, 4, 8}.
-
- @param[out] Value Value to write.
-
- @retval EFI_SUCCESS The data was written successfully.
- @retval EFI_UNSUPPORTED The underlying IO device doesn't support the
- provided address offset and write size.
- @retval EFI_OUT_OF_RESOURCES The request could not be completed due to a
- lack of resources.
- @retval EFI_INVALID_PARAMETER One or more parameters are invalid.
-
-**/
-typedef
-EFI_STATUS
-(EFIAPI *VIRTIO_DEVICE_WRITE) (
- IN VIRTIO_DEVICE_PROTOCOL *This,
- IN UINTN FieldOffset,
- IN UINTN FieldSize,
- IN UINT64 Value
- );
-
-/**
- Read the device features field from the Virtio Header.
-
- @param[in] This This instance of VIRTIO_DEVICE_PROTOCOL
-
- @param[out] DeviceFeatures The 32-bit device features field.
-
- @retval EFI_SUCCESS The data was read successfully.
- @retval EFI_UNSUPPORTED The underlying IO device doesn't support the
- provided address offset and read size.
- @retval EFI_INVALID_PARAMETER DeviceFeatures is NULL
-**/
-typedef
-EFI_STATUS
-(EFIAPI *VIRTIO_GET_DEVICE_FEATURES) (
- IN VIRTIO_DEVICE_PROTOCOL *This,
- OUT UINT32 *DeviceFeatures
- );
-
-/**
- Write the guest features field in the Virtio Header.
-
- @param[in] This This instance of VIRTIO_DEVICE_PROTOCOL
-
- @param[in] Features The 32-bit guest guest features field
-
-**/
-typedef
-EFI_STATUS
-(EFIAPI *VIRTIO_SET_GUEST_FEATURES) (
- IN VIRTIO_DEVICE_PROTOCOL *This,
- IN UINT32 Features
- );
-
-/**
- Read the queue address field from the Virtio Header.
-
- QueueAddress is the address of the virtqueue divided by 4096.
-
- @param[in] This This instance of VIRTIO_DEVICE_PROTOCOL
-
- @param[out] QueueAddress The 32-bit queue address field.
-
- @retval EFI_SUCCESS The data was read successfully.
- @retval EFI_UNSUPPORTED The underlying IO device doesn't support the
- provided address offset and read size.
- @retval EFI_INVALID_PARAMETER QueueAddress is NULL
-**/
-typedef
-EFI_STATUS
-(EFIAPI *VIRTIO_GET_QUEUE_ADDRESS) (
- IN VIRTIO_DEVICE_PROTOCOL *This,
- OUT UINT32 *QueueAddress
- );
-
-/**
- Write the queue address field in the Virtio Header.
-
- The parameter Address must be the base address of the virtqueue divided
- by 4096.
-
- @param[in] This This instance of VIRTIO_DEVICE_PROTOCOL
-
- @param[in] Address The 32-bit Queue Address field
-
- @retval EFI_SUCCESS The data was written successfully.
- @retval EFI_UNSUPPORTED The underlying IO device doesn't support the
- provided address offset and write size.
-**/
-typedef
-EFI_STATUS
-(EFIAPI *VIRTIO_SET_QUEUE_ADDRESS) (
- IN VIRTIO_DEVICE_PROTOCOL *This,
- IN UINT32 Address
- );
-
-/**
-
- Write the queue select field in the Virtio Header.
-
- Writing to the queue select field sets the index of the queue to which
- operations such as SetQueueAlign and GetQueueNumMax apply.
-
- @param[in] This This instance of VIRTIO_DEVICE_PROTOCOL
-
- @param[in] Index The index of the queue to select
-
- @retval EFI_SUCCESS The data was written successfully.
- @retval EFI_UNSUPPORTED The underlying IO device doesn't support the
- provided address offset and write size.
-**/
-typedef
-EFI_STATUS
-(EFIAPI *VIRTIO_SET_QUEUE_SEL) (
- IN VIRTIO_DEVICE_PROTOCOL *This,
- IN UINT16 Index
- );
-
-/**
-
- Write the queue notify field in the Virtio Header.
-
- @param[in] This This instance of VIRTIO_DEVICE_PROTOCOL
-
- @param[in] Address The 32-bit Queue Notify field
-
- @retval EFI_SUCCESS The data was written successfully.
- @retval EFI_UNSUPPORTED The underlying IO device doesn't support the
- provided address offset and write size.
-**/
-typedef
-EFI_STATUS
-(EFIAPI *VIRTIO_SET_QUEUE_NOTIFY) (
- IN VIRTIO_DEVICE_PROTOCOL *This,
- IN UINT16 Index
- );
-
-/**
- Write the queue alignment field in the Virtio Header.
-
- The queue to which the alignment applies is selected by the Queue Select
- field.
-
- Note: This operation is not implemented by the VirtIo over PCI. The PCI
- implementation of this protocol returns EFI_SUCCESS.
-
- @param[in] This This instance of VIRTIO_DEVICE_PROTOCOL
-
- @param[in] Alignment The alignment boundary of the Used Ring in bytes.
- Must be a power of 2.
-
- @retval EFI_SUCCESS The data was written successfully.
- @retval EFI_UNSUPPORTED The underlying IO device doesn't support the
- provided address offset and write size.
-**/
-typedef
-EFI_STATUS
-(EFIAPI *VIRTIO_SET_QUEUE_ALIGN) (
- IN VIRTIO_DEVICE_PROTOCOL *This,
- IN UINT32 Alignment
- );
-
-/**
- Write the guest page size.
-
- Note: This operation is not implemented by the VirtIo over PCI. The PCI
- implementation of this protocol returns EFI_SUCCESS.
-
- @param[in] This This instance of VIRTIO_DEVICE_PROTOCOL
-
- @param[in] PageSize Size of the Guest page in bytes.
- Must be a power of 2.
-
- @retval EFI_SUCCESS The data was written successfully.
- @retval EFI_UNSUPPORTED The underlying IO device doesn't support the
- provided address offset and write size.
-**/
-typedef
-EFI_STATUS
-(EFIAPI *VIRTIO_SET_PAGE_SIZE) (
- IN VIRTIO_DEVICE_PROTOCOL *This,
- IN UINT32 PageSize
- );
-
-/**
-
- Get the size of the virtqueue selected by the queue select field.
-
- See Virtio spec Section 2.3
-
- @param[in] This This instance of VIRTIO_DEVICE_PROTOCOL
-
- @param[out] QueueNumMax The size of the virtqueue in bytes.
- Always a power of 2.
-
- @retval EFI_SUCCESS The data was read successfully.
- @retval EFI_UNSUPPORTED The underlying IO device doesn't support the
- provided address offset and read size.
- @retval EFI_INVALID_PARAMETER QueueNumMax is NULL
-**/
-typedef
-EFI_STATUS
-(EFIAPI *VIRTIO_GET_QUEUE_NUM_MAX) (
- IN VIRTIO_DEVICE_PROTOCOL *This,
- OUT UINT16 *QueueNumMax
- );
-
-/**
-
- Write to the QueueNum field in the Virtio Header.
-
- This function only applies to Virtio-MMIO and may be a stub for other
- implementations. See Virtio Spec appendix X.
-
- @param[in] This This instance of VIRTIO_DEVICE_PROTOCOL
-
- @param[in] QueueSize The number of elements in the queue.
-
- @retval EFI_SUCCESS The data was written successfully.
- @retval EFI_UNSUPPORTED The underlying IO device doesn't support the
- provided address offset and write size.
-**/
-typedef
-EFI_STATUS
-(EFIAPI *VIRTIO_SET_QUEUE_NUM) (
- IN VIRTIO_DEVICE_PROTOCOL *This,
- IN UINT16 QueueSize
- );
-
-/**
-
- Get the DeviceStatus field from the Virtio Header.
-
- @param[in] This This instance of VIRTIO_DEVICE_PROTOCOL
-
- @param[out] DeviceStatus The 8-bit value for the Device status field
-
- @retval EFI_SUCCESS The data was read successfully.
- @retval EFI_UNSUPPORTED The underlying IO device doesn't support the
- provided address offset and read size.
- @retval EFI_INVALID_PARAMETER DeviceStatus is NULL
-**/
-typedef
-EFI_STATUS
-(EFIAPI *VIRTIO_GET_DEVICE_STATUS) (
- IN VIRTIO_DEVICE_PROTOCOL *This,
- OUT UINT8 *DeviceStatus
- );
-
-/**
-
- Write the DeviceStatus field in the Virtio Header.
-
- @param[in] This This instance of VIRTIO_DEVICE_PROTOCOL
-
- @param[in] DeviceStatus The 8-bit value for the Device status field
-
- @retval EFI_SUCCESS The data was written successfully.
- @retval EFI_UNSUPPORTED The underlying IO device doesn't support the
- provided address offset and write size.
-**/
-typedef
-EFI_STATUS
-(EFIAPI *VIRTIO_SET_DEVICE_STATUS) (
- IN VIRTIO_DEVICE_PROTOCOL *This,
- IN UINT8 DeviceStatus
- );
-
-
-///
-/// This protocol provides an abstraction over the VirtIo transport layer
-///
-/// 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_GET_QUEUE_ADDRESS GetQueueAddress;
- VIRTIO_SET_QUEUE_ADDRESS SetQueueAddress;
-
- VIRTIO_SET_QUEUE_SEL SetQueueSel;
-
- VIRTIO_SET_QUEUE_NOTIFY SetQueueNotify;
-
- VIRTIO_SET_QUEUE_ALIGN SetQueueAlign;
- VIRTIO_SET_PAGE_SIZE SetPageSize;
-
- VIRTIO_GET_QUEUE_NUM_MAX GetQueueNumMax;
- VIRTIO_SET_QUEUE_NUM SetQueueNum;
-
- VIRTIO_GET_DEVICE_STATUS GetDeviceStatus;
- VIRTIO_SET_DEVICE_STATUS SetDeviceStatus;
-
- // Functions to read/write Device Specific headers
- VIRTIO_DEVICE_WRITE WriteDevice;
- VIRTIO_DEVICE_READ ReadDevice;
-};
-
-extern EFI_GUID gVirtioDeviceProtocolGuid;
-
-#endif
diff --git a/OvmfPkg/Include/Protocol/XenBus.h b/OvmfPkg/Include/Protocol/XenBus.h
deleted file mode 100644
index 3509691e03..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 <IndustryStandard/Xen/grant_table.h>
-#include <IndustryStandard/Xen/event_channel.h>
-
-///
-/// 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 writen 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 supressed, 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 supressed, 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 <IndustryStandard/Xen/xen.h>
-
-#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/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.<BR>
- Copyright (c) 2011, Andrei Warkentin <andreiw@motorola.com>
-
- This program and the accompanying materials are
- licensed and made available under the terms and conditions of the BSD License
- which accompanies this distribution. The full text of the license may be found at
- http://opensource.org/licenses/bsd-license.php
-
- THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
- WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
-
-**/
-
-#include <Library/DebugLib.h>
-#include <Library/BaseLib.h>
-#include <IndustryStandard/Acpi.h>
-
-#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 <somlo@cmu.edu>
-
- This program and the accompanying materials are licensed and made
- available under the terms and conditions of the BSD License which
- accompanies this distribution. The full text of the license may
- be found at http://opensource.org/licenses/bsd-license.php
-
- 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 c3c50c05d3..0000000000
--- a/OvmfPkg/Library/AcpiTimerLib/BaseAcpiTimerLib.c
+++ /dev/null
@@ -1,105 +0,0 @@
-/** @file
- Provide constructor and GetTick for Base instance of ACPI Timer Library
-
- Copyright (C) 2014, Gabriel L. Somlo <somlo@cmu.edu>
-
- This program and the accompanying materials are licensed and made
- available under the terms and conditions of the BSD License which
- accompanies this distribution. The full text of the license may
- be found at http://opensource.org/licenses/bsd-license.php
-
- THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
- WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
-**/
-
-#include <Library/DebugLib.h>
-#include <Library/IoLib.h>
-#include <Library/PciLib.h>
-#include <Library/PcdLib.h>
-#include <OvmfPlatforms.h>
-
-//
-// 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;
- 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);
- 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);
- 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;
- }
-
- mAcpiTimerIoAddr = (PciRead32 (Pmba) & ~PMBA_RTE) + ACPI_TIMER_OFFSET;
-
- //
- // 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 the Power Management Base Address from a PCD.
- //
- PciAndThenOr32 (Pmba, (UINT32) ~0xFFC0, PcdGet16 (PcdAcpiPmBaseAddress));
-
- //
- // Enable PMBA I/O port decodes
- //
- PciOr8 (AcpiCtlReg, AcpiEnBit);
- }
-
- 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 4c0e615955..0000000000
--- a/OvmfPkg/Library/AcpiTimerLib/BaseAcpiTimerLib.inf
+++ /dev/null
@@ -1,40 +0,0 @@
-## @file
-# Base ACPI Timer Library Instance.
-#
-# Copyright (C) 2014, Gabriel L. Somlo <somlo@cmu.edu>
-# 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
-
-[Pcd]
- gUefiOvmfPkgTokenSpaceGuid.PcdAcpiPmBaseAddress
-
-[LibraryClasses]
- BaseLib
- PciLib
- IoLib
diff --git a/OvmfPkg/Library/AcpiTimerLib/BaseRomAcpiTimerLib.c b/OvmfPkg/Library/AcpiTimerLib/BaseRomAcpiTimerLib.c
deleted file mode 100644
index 5164769f60..0000000000
--- a/OvmfPkg/Library/AcpiTimerLib/BaseRomAcpiTimerLib.c
+++ /dev/null
@@ -1,122 +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 <andreiw@motorola.com>
-
- This program and the accompanying materials are licensed and made
- available under the terms and conditions of the BSD License which
- accompanies this distribution. The full text of the license may
- be found at http://opensource.org/licenses/bsd-license.php
-
- THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
- WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
-**/
-
-#include <Library/DebugLib.h>
-#include <Library/IoLib.h>
-#include <Library/PciLib.h>
-#include <Library/PcdLib.h>
-#include <OvmfPlatforms.h>
-
-/**
- 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;
- 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);
- 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);
- 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 the Power Management Base Address from a PCD.
- //
- PciAndThenOr32 (Pmba, (UINT32) ~0xFFC0, PcdGet16 (PcdAcpiPmBaseAddress));
-
- //
- // 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 d5e50aef61..0000000000
--- a/OvmfPkg/Library/AcpiTimerLib/BaseRomAcpiTimerLib.inf
+++ /dev/null
@@ -1,39 +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
-
-[Pcd]
- gUefiOvmfPkgTokenSpaceGuid.PcdAcpiPmBaseAddress
-
-[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 <somlo@cmu.edu>
-
- This program and the accompanying materials are licensed and made
- available under the terms and conditions of the BSD License which
- accompanies this distribution. The full text of the license may
- be found at http://opensource.org/licenses/bsd-license.php
-
- THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
- WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
-**/
-
-#include <Library/DebugLib.h>
-#include <Library/IoLib.h>
-#include <Library/PcdLib.h>
-#include <Library/PciLib.h>
-#include <OvmfPlatforms.h>
-
-//
-// 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 <somlo@cmu.edu>
-# 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/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.<BR>
- This program and the accompanying materials
- are licensed and made available under the terms and conditions of the BSD License
- which accompanies this distribution. The full text of the license may be found at
- http://opensource.org/licenses/bsd-license.php
-
- THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
- WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
-
-**/
-
-#include "PiDxe.h"
-#include <Library/DebugLib.h>
-#include <Library/PcdLib.h>
-#include <Library/PlatformFvbLib.h>
-#include <Library/UefiBootServicesTableLib.h>
-#include <Library/UefiRuntimeLib.h>
-
-
-/**
- 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.<BR>
-#
-# This program and the accompanying materials
-# are licensed and made available under the terms and conditions of the BSD License
-# which accompanies this distribution. The full text of the license may be found at
-# http://opensource.org/licenses/bsd-license.php
-# 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.<BR>
-;
-; This program and the accompanying materials
-; are licensed and made available under the terms and conditions of the BSD License
-; which accompanies this distribution. The full text of the license may be found at
-; http://opensource.org/licenses/bsd-license.php.
-;
-; 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 9c996adfbb..0000000000
--- a/OvmfPkg/Library/LoadLinuxLib/Linux.c
+++ /dev/null
@@ -1,670 +0,0 @@
-/** @file
-
- Copyright (c) 2011 - 2014, Intel Corporation. All rights reserved.<BR>
-
- This program and the accompanying materials
- are licensed and made available under the terms and conditions of the BSD License
- which accompanies this distribution. The full text of the license may be found at
- http://opensource.org/licenses/bsd-license.php
-
- 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 >= (sizeof (Bp->e820_map) / sizeof (Bp->e820_map[0]))) {
- 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.<BR>
- This program and the accompanying materials
- are licensed and made available under the terms and conditions of the BSD License
- which accompanies this distribution. The full text of the license may be found at
- http://opensource.org/licenses/bsd-license.php
-
- 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.<BR>
-
- This program and the accompanying materials
- are licensed and made available under the terms and conditions of the BSD License
- which accompanies this distribution. The full text of the license may be found at
- http://opensource.org/licenses/bsd-license.php
-
- 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 <Uefi.h>
-#include <Library/LoadLinuxLib.h>
-#include <Library/BaseLib.h>
-#include <Library/BaseMemoryLib.h>
-#include <Library/DebugLib.h>
-#include <Library/MemoryAllocationLib.h>
-#include <Library/UefiBootServicesTableLib.h>
-#include <Library/UefiRuntimeServicesTableLib.h>
-
-#include <IndustryStandard/LinuxBzimage.h>
-
-#include <Protocol/GraphicsOutput.h>
-
-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.<BR>
-#
-# This program and the accompanying materials
-# are licensed and made available under the terms and conditions of the BSD License
-# which accompanies this distribution. The full text of the license may be found at
-# http://opensource.org/licenses/bsd-license.php
-#
-# 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.<BR>
-;
-; This program and the accompanying materials
-; are licensed and made available under the terms and conditions of the BSD License
-; which accompanies this distribution. The full text of the license may be found at
-; http://opensource.org/licenses/bsd-license.php.
-;
-; 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.<BR>
-
- This program and the accompanying materials
- are licensed and made available under the terms and conditions of the BSD License
- which accompanies this distribution. The full text of the license may be found at
- http://opensource.org/licenses/bsd-license.php.
-
- THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
- WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
-
-**/
-
-#include <Uefi.h>
-
-#include <Library/DebugLib.h>
-#include <LockBoxLib.h>
-
-/**
- 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 7203d0777d..0000000000
--- a/OvmfPkg/Library/LockBoxLib/LockBoxBaseLib.inf
+++ /dev/null
@@ -1,44 +0,0 @@
-## @file
-#
-# Library implementing the LockBox interface for OVMF
-#
-# Copyright (C) 2013, Red Hat, Inc.
-# Copyright (c) 2014, Intel Corporation. All rights reserved.<BR>
-#
-# This program and the accompanying materials are licensed and made available
-# under the terms and conditions of the BSD License which accompanies this
-# distribution. The full text of the license may be found at
-# http://opensource.org/licenses/bsd-license.php
-#
-# 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
diff --git a/OvmfPkg/Library/LockBoxLib/LockBoxDxe.c b/OvmfPkg/Library/LockBoxLib/LockBoxDxe.c
deleted file mode 100644
index c8f2ec8a4e..0000000000
--- a/OvmfPkg/Library/LockBoxLib/LockBoxDxe.c
+++ /dev/null
@@ -1,119 +0,0 @@
-/** @file
-
- Copyright (c) 2006 - 2014, Intel Corporation. All rights reserved.<BR>
-
- This program and the accompanying materials
- are licensed and made available under the terms and conditions of the BSD License
- which accompanies this distribution. The full text of the license may be found at
- http://opensource.org/licenses/bsd-license.php.
-
- THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
- WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
-
-**/
-
-#include <Uefi.h>
-
-#include <Library/MemoryAllocationLib.h>
-#include <Library/UefiBootServicesTableLib.h>
-#include <Library/BaseMemoryLib.h>
-#include <Library/DebugLib.h>
-#include <LockBoxLib.h>
-
-/**
- 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
- )
-{
- return LockBoxLibInitialize ();
-}
diff --git a/OvmfPkg/Library/LockBoxLib/LockBoxDxeLib.inf b/OvmfPkg/Library/LockBoxLib/LockBoxDxeLib.inf
deleted file mode 100644
index a4d27a598d..0000000000
--- a/OvmfPkg/Library/LockBoxLib/LockBoxDxeLib.inf
+++ /dev/null
@@ -1,45 +0,0 @@
-## @file
-#
-# Library implementing the LockBox interface for OVMF
-#
-# Copyright (C) 2013, Red Hat, Inc.
-# Copyright (c) 2014, Intel Corporation. All rights reserved.<BR>
-#
-# This program and the accompanying materials are licensed and made available
-# under the terms and conditions of the BSD License which accompanies this
-# distribution. The full text of the license may be found at
-# http://opensource.org/licenses/bsd-license.php
-#
-# 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
-
-[Pcd]
- gUefiOvmfPkgTokenSpaceGuid.PcdOvmfLockBoxStorageBase
- gUefiOvmfPkgTokenSpaceGuid.PcdOvmfLockBoxStorageSize
diff --git a/OvmfPkg/Library/LockBoxLib/LockBoxLib.c b/OvmfPkg/Library/LockBoxLib/LockBoxLib.c
deleted file mode 100644
index 89050ac87c..0000000000
--- a/OvmfPkg/Library/LockBoxLib/LockBoxLib.c
+++ /dev/null
@@ -1,376 +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.<BR>
-
- This program and the accompanying materials are licensed and made available
- under the terms and conditions of the BSD License which accompanies this
- distribution. The full text of the license may be found at
- http://opensource.org/licenses/bsd-license.php
-
- THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, WITHOUT
- WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
-
-**/
-
-#include <Uefi.h>
-#include <Library/BaseMemoryLib.h>
-#include <Library/DebugLib.h>
-#include <Library/LockBoxLib.h>
-#include <Library/PcdLib.h>
-#include <LockBoxLib.h>
-
-#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;
-
- 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.<BR>
-
- This program and the accompanying materials
- are licensed and made available under the terms and conditions of the BSD License
- which accompanies this distribution. The full text of the license may be found at
- http://opensource.org/licenses/bsd-license.php
-
- 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 5df8de4985..0000000000
--- a/OvmfPkg/Library/NvVarsFileLib/FsAccess.c
+++ /dev/null
@@ -1,517 +0,0 @@
-/** @file
- File System Access for NvVarsFileLib
-
- Copyright (c) 2004 - 2014, Intel Corporation. All rights reserved.<BR>
- This program and the accompanying materials
- are licensed and made available under the terms and conditions of the BSD License
- which accompanies this distribution. The full text of the license may be found at
- http://opensource.org/licenses/bsd-license.php
-
- 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 <Library/BaseMemoryLib.h>
-#include <Library/DebugLib.h>
-#include <Library/MemoryAllocationLib.h>
-
-
-/**
- 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
- );
- if (EFI_ERROR (Status)) {
- return Status;
- }
-
- 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 occured.
-
-**/
-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 relevent 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 c89bb4af7d..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.<BR>
- This program and the accompanying materials
- are licensed and made available under the terms and conditions of the BSD License
- which accompanies this distribution. The full text of the license may be found at
- http://opensource.org/licenses/bsd-license.php
-
- 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 <Library/DebugLib.h>
-#include <Library/NvVarsFileLib.h>
-
-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 ac3a3d6363..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.<BR>
- This program and the accompanying materials
- are licensed and made available under the terms and conditions of the BSD License
- which accompanies this distribution. The full text of the license may be found at
- http://opensource.org/licenses/bsd-license.php
-
- 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 <Uefi.h>
-
-#include <Guid/FileInfo.h>
-
-#include <Protocol/SimpleFileSystem.h>
-
-#include <Library/BaseLib.h>
-#include <Library/FileHandleLib.h>
-#include <Library/SerializeVariablesLib.h>
-#include <Library/UefiBootServicesTableLib.h>
-#include <Library/UefiRuntimeServicesTableLib.h>
-#include <Library/UefiLib.h>
-
-/**
- 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.<BR>
-#
-# This program and the accompanying materials
-# are licensed and made available under the terms and conditions of the BSD License
-# which accompanies this distribution. The full text of the license may be found at
-# http://opensource.org/licenses/bsd-license.php
-# 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/PlatformBdsLib/BdsPlatform.c b/OvmfPkg/Library/PlatformBdsLib/BdsPlatform.c
deleted file mode 100644
index 0abba98dfe..0000000000
--- a/OvmfPkg/Library/PlatformBdsLib/BdsPlatform.c
+++ /dev/null
@@ -1,1597 +0,0 @@
-/** @file
- Platform BDS customizations.
-
- Copyright (c) 2004 - 2014, Intel Corporation. All rights reserved.<BR>
- This program and the accompanying materials
- are licensed and made available under the terms and conditions of the BSD License
- which accompanies this distribution. The full text of the license may be found at
- http://opensource.org/licenses/bsd-license.php
-
- 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 <Library/QemuBootOrderLib.h>
-
-
-//
-// 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
-};
-
-//
-// Array Size macro
-//
-#define ARRAY_SIZE(array) (sizeof (array) / sizeof (array[0]))
-
-//
-// 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
- );
-
-//
-// BDS Platform Functions
-//
-VOID
-EFIAPI
-PlatformBdsInit (
- VOID
- )
-/*++
-
-Routine Description:
-
- Platform Bds init. Incude the platform firmware vendor, revision
- and so crc check.
-
-Arguments:
-
-Returns:
-
- None.
-
---*/
-{
- DEBUG ((EFI_D_INFO, "PlatformBdsInit\n"));
- InstallDevicePathCallback ();
-}
-
-
-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);
-
- BdsLibUpdateConsoleVariable (VarConsoleInp, 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 = DevicePathToStr(DevicePath);
- if (DevPathStr != NULL) {
- DEBUG((
- EFI_D_INFO,
- "BdsPlatform.c+%d: COM%d DevPath: %s\n",
- __LINE__,
- gPnp16550ComPortDeviceNode.UID + 1,
- DevPathStr
- ));
- FreePool(DevPathStr);
- }
-
- BdsLibUpdateConsoleVariable (VarConsoleOut, DevicePath, NULL);
- BdsLibUpdateConsoleVariable (VarConsoleInp, DevicePath, NULL);
- BdsLibUpdateConsoleVariable (VarErrorOut, 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 = DevicePathToStr(DevicePath);
- if (DevPathStr != NULL) {
- DEBUG((
- EFI_D_INFO,
- "BdsPlatform.c+%d: COM%d DevPath: %s\n",
- __LINE__,
- gPnp16550ComPortDeviceNode.UID + 1,
- DevPathStr
- ));
- FreePool(DevPathStr);
- }
-
- BdsLibUpdateConsoleVariable (VarConsoleOut, DevicePath, NULL);
- BdsLibUpdateConsoleVariable (VarConsoleInp, DevicePath, NULL);
- BdsLibUpdateConsoleVariable (VarErrorOut, 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 dirver 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 futhure, 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.
- //
- BdsLibUpdateConsoleVariable (VarConsoleOutDev, NULL, PciDevicePath);
- BdsLibUpdateConsoleVariable (VarConsoleOutDev, TempDevicePath, NULL);
- }
- }
- gBS->FreePool (GopHandleBuffer);
- }
-
- return EFI_SUCCESS;
-}
-
-EFI_STATUS
-PreparePciVgaDevicePath (
- 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;
-
- BdsLibUpdateConsoleVariable (VarConsoleOut, 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);
-
- BdsLibUpdateConsoleVariable (VarConsoleOut, DevicePath, NULL);
- BdsLibUpdateConsoleVariable (VarConsoleInp, DevicePath, NULL);
- BdsLibUpdateConsoleVariable (VarErrorOut, 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 VGA device to enable in PCI bus
- //
- if (IS_PCI_VGA (Pci)) {
- //
- // Add them to ConOut.
- //
- DEBUG ((EFI_D_INFO, "Found PCI VGA device\n"));
- PreparePciVgaDevicePath (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);
-}
-
-
-EFI_STATUS
-PlatformBdsConnectConsole (
- IN BDS_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 - Predfined platform default console device array.
-
-Returns:
-
- EFI_SUCCESS - Success connect at least one ConIn and ConOut
- device, there must have one ConOut device is
- active vga device.
-
- EFI_STATUS - Return the status of
- BdsLibConnectAllDefaultConsoles ()
-
---*/
-{
- EFI_STATUS Status;
- UINTN Index;
- EFI_DEVICE_PATH_PROTOCOL *VarConout;
- EFI_DEVICE_PATH_PROTOCOL *VarConin;
- UINTN DevicePathSize;
-
- //
- // Connect RootBridge
- //
- VarConout = BdsLibGetVariableAndSize (
- VarConsoleOut,
- &gEfiGlobalVariableGuid,
- &DevicePathSize
- );
- VarConin = BdsLibGetVariableAndSize (
- VarConsoleInp,
- &gEfiGlobalVariableGuid,
- &DevicePathSize
- );
-
- 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 minimue 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) {
- BdsLibUpdateConsoleVariable (VarConsoleInp, PlatformConsole[Index].DevicePath, NULL);
- }
- if ((PlatformConsole[Index].ConnectType & CONSOLE_OUT) == CONSOLE_OUT) {
- BdsLibUpdateConsoleVariable (VarConsoleOut, PlatformConsole[Index].DevicePath, NULL);
- }
- if ((PlatformConsole[Index].ConnectType & STD_ERROR) == STD_ERROR) {
- BdsLibUpdateConsoleVariable (VarErrorOut, PlatformConsole[Index].DevicePath, NULL);
- }
- }
- } else {
- //
- // Only detect VGA device and add them to ConOut
- //
- DetectAndPreparePlatformPciDevicePaths (TRUE);
- }
-
- //
- // Connect the all the default console with current cosole variable
- //
- Status = BdsLibConnectAllDefaultConsoles ();
- if (EFI_ERROR (Status)) {
- return Status;
- }
-
- return EFI_SUCCESS;
-}
-
-
-/**
- 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"<failed to convert>";
- 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);
-}
-
-
-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;
-
- if (IS_CLASS1 (PciHeader, PCI_CLASS_MASS_STORAGE)) {
- DevicePath = NULL;
- Status = gBS->HandleProtocol (
- Handle,
- &gEfiDevicePathProtocolGuid,
- (VOID*)&DevicePath
- );
- if (EFI_ERROR (Status)) {
- return Status;
- }
-
- //
- // Print Device Path
- //
- DevPathStr = DevicePathToStr (DevicePath);
- if (DevPathStr != NULL) {
- DEBUG((
- EFI_D_INFO,
- "Found Mass Storage device: %s\n",
- 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 occured
- @param Context For EFI compatiblity. 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;
-
- 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
- );
- PcdSet64 (PcdEmuVariableEvent, (UINT64)(UINTN) mEmuVariableEvent);
-
- return EFI_SUCCESS;
-}
-
-
-VOID
-PlatformBdsRestoreNvVarsFromHardDisk (
- )
-{
- VisitAllPciInstances (ConnectRecursivelyIfPciMassStorage);
- VisitAllInstancesOfProtocol (
- &gEfiSimpleFileSystemProtocolGuid,
- VisitingFileSystemInstance,
- NULL
- );
-
-}
-
-
-VOID
-PlatformBdsConnectSequence (
- VOID
- )
-/*++
-
-Routine Description:
-
- Connect with predeined 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
- //
- BdsLibConnectDevicePath (gPlatformConnectSequence[Index]);
- Index++;
- }
-
- //
- // Just use the simple policy to connect all devices
- //
- BdsLibConnectAll ();
-
- PciAcpiInitialization ();
-
- //
- // Clear the logo after all devices are connected.
- //
- gST->ConOut->ClearScreen (gST->ConOut);
-}
-
-VOID
-PlatformBdsGetDriverOption (
- IN OUT LIST_ENTRY *BdsDriverLists
- )
-/*++
-
-Routine Description:
-
- Load the predefined driver option, OEM/IBV can customize this
- to load their own drivers
-
-Arguments:
-
- BdsDriverLists - The header of the driver option link list.
-
-Returns:
-
- None.
-
---*/
-{
- DEBUG ((EFI_D_INFO, "PlatformBdsGetDriverOption\n"));
- return;
-}
-
-VOID
-PlatformBdsDiagnostics (
- IN EXTENDMEM_COVERAGE_LEVEL MemoryTestLevel,
- IN BOOLEAN QuietBoot,
- IN BASEM_MEMORY_TEST BaseMemoryTest
- )
-/*++
-
-Routine Description:
-
- Perform the platform diagnostic, such like test memory. OEM/IBV also
- can customize this fuction to support specific platform diagnostic.
-
-Arguments:
-
- MemoryTestLevel - The memory test intensive level
-
- QuietBoot - Indicate if need to enable the quiet boot
-
- BaseMemoryTest - A pointer to BaseMemoryTest()
-
-Returns:
-
- None.
-
---*/
-{
- EFI_STATUS Status;
-
- DEBUG ((EFI_D_INFO, "PlatformBdsDiagnostics\n"));
-
- //
- // Here we can decide if we need to show
- // the diagnostics screen
- // Notes: this quiet boot code should be remove
- // from the graphic lib
- //
- if (QuietBoot) {
- EnableQuietBoot (PcdGetPtr(PcdLogoFile));
- //
- // Perform system diagnostic
- //
- Status = BaseMemoryTest (MemoryTestLevel);
- if (EFI_ERROR (Status)) {
- DisableQuietBoot ();
- }
-
- return ;
- }
- //
- // Perform system diagnostic
- //
- Status = BaseMemoryTest (MemoryTestLevel);
-}
-
-
-/**
- Empty callback function executed when the EndOfDxe event group is signaled.
-
- We only need this function because we'd like to signal EndOfDxe, and for that
- we need to create an event, with a callback function.
-
- @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
-OnEndOfDxe (
- IN EFI_EVENT Event,
- IN VOID *Context
- )
-{
-}
-
-
-/**
- Save the S3 boot script.
-
- Note that we trigger DxeSmmReadyToLock here -- otherwise the script wouldn't
- be saved actually. Triggering this protocol installation event in turn locks
- down SMM, so no further changes to LockBoxes or SMRAM are possible
- afterwards.
-**/
-STATIC
-VOID
-SaveS3BootScript (
- VOID
- )
-{
- EFI_STATUS Status;
- EFI_S3_SAVE_STATE_PROTOCOL *BootScript;
- EFI_HANDLE Handle;
- 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);
-
- Handle = NULL;
- Status = gBS->InstallProtocolInterface (&Handle,
- &gEfiDxeSmmReadyToLockProtocolGuid, EFI_NATIVE_INTERFACE,
- NULL);
- ASSERT_EFI_ERROR (Status);
-}
-
-
-VOID
-EFIAPI
-PlatformBdsPolicyBehavior (
- IN OUT LIST_ENTRY *DriverOptionList,
- IN OUT LIST_ENTRY *BootOptionList,
- IN PROCESS_CAPSULES ProcessCapsules,
- IN BASEM_MEMORY_TEST BaseMemoryTest
- )
-/*++
-
-Routine Description:
-
- The function will excute with as the platform policy, current policy
- is driven by boot mode. IBV/OEM can customize this code for their specific
- policy action.
-
-Arguments:
-
- DriverOptionList - The header of the driver option link list
-
- BootOptionList - The header of the boot option link list
-
- ProcessCapsules - A pointer to ProcessCapsules()
-
- BaseMemoryTest - A pointer to BaseMemoryTest()
-
-Returns:
-
- None.
-
---*/
-{
- EFI_STATUS Status;
- EFI_BOOT_MODE BootMode;
- EFI_EVENT EndOfDxeEvent;
-
- DEBUG ((EFI_D_INFO, "PlatformBdsPolicyBehavior\n"));
-
- VisitAllInstancesOfProtocol (&gEfiPciRootBridgeIoProtocolGuid,
- ConnectRootBridge, NULL);
-
- //
- // 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.
- //
- Status = gBS->CreateEventEx (EVT_NOTIFY_SIGNAL, TPL_CALLBACK, OnEndOfDxe,
- NULL /* NotifyContext */, &gEfiEndOfDxeEventGroupGuid,
- &EndOfDxeEvent);
- if (!EFI_ERROR (Status)) {
- gBS->SignalEvent (EndOfDxeEvent);
- gBS->CloseEvent (EndOfDxeEvent);
- }
-
- if (QemuFwCfgS3Enabled ()) {
- //
- // Save the boot script too. Note that this requires/includes emitting the
- // DxeSmmReadyToLock event, which in turn locks down SMM.
- //
- SaveS3BootScript ();
- }
-
- 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 ();
- }
-
- //
- // Load the driver option as the driver option list
- //
- PlatformBdsGetDriverOption (DriverOptionList);
-
- //
- // Get current Boot Mode
- //
- Status = BdsLibGetBootMode (&BootMode);
- 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);
- //
- // Connect platform console
- //
- Status = PlatformBdsConnectConsole (gPlatformConsole);
- if (EFI_ERROR (Status)) {
- //
- // Here OEM/IBV can customize with defined action
- //
- PlatformBdsNoConsoleAction ();
- }
-
- //
- // Memory test and Logo show
- //
- PlatformBdsDiagnostics (IGNORE, TRUE, BaseMemoryTest);
-
- //
- // Perform some platform specific connect sequence
- //
- PlatformBdsConnectSequence ();
-
- //
- // Process QEMU's -kernel command line option
- //
- TryRunningQemuKernel ();
-
- DEBUG ((EFI_D_INFO, "BdsLibConnectAll\n"));
- BdsLibConnectAll ();
- BdsLibEnumerateAllBootOption (BootOptionList);
-
- SetBootOrderFromQemu (BootOptionList);
- //
- // The BootOrder variable may have changed, reload the in-memory list with
- // it.
- //
- BdsLibBuildOptionFromVar (BootOptionList, L"BootOrder");
-
- PlatformBdsEnterFrontPage (GetFrontPageTimeoutFromQemu(), TRUE);
-}
-
-VOID
-EFIAPI
-PlatformBdsBootSuccess (
- IN BDS_COMMON_OPTION *Option
- )
-/*++
-
-Routine Description:
-
- Hook point after a boot attempt succeeds. We don't expect a boot option to
- return, so the EFI 1.0 specification defines that you will default to an
- interactive mode and stop processing the BootOrder list in this case. This
- is alos a platform implementation and can be customized by IBV/OEM.
-
-Arguments:
-
- Option - Pointer to Boot Option that succeeded to boot.
-
-Returns:
-
- None.
-
---*/
-{
- CHAR16 *TmpStr;
-
- DEBUG ((EFI_D_INFO, "PlatformBdsBootSuccess\n"));
- //
- // If Boot returned with EFI_SUCCESS and there is not in the boot device
- // select loop then we need to pop up a UI and wait for user input.
- //
- TmpStr = Option->StatusString;
- if (TmpStr != NULL) {
- BdsLibOutputStrings (gST->ConOut, TmpStr, Option->Description, L"\n\r", NULL);
- FreePool (TmpStr);
- }
-}
-
-VOID
-EFIAPI
-PlatformBdsBootFail (
- IN BDS_COMMON_OPTION *Option,
- IN EFI_STATUS Status,
- IN CHAR16 *ExitData,
- IN UINTN ExitDataSize
- )
-/*++
-
-Routine Description:
-
- Hook point after a boot attempt fails.
-
-Arguments:
-
- Option - Pointer to Boot Option that failed to boot.
-
- Status - Status returned from failed boot.
-
- ExitData - Exit data returned from failed boot.
-
- ExitDataSize - Exit data size returned from failed boot.
-
-Returns:
-
- None.
-
---*/
-{
- CHAR16 *TmpStr;
-
- DEBUG ((EFI_D_INFO, "PlatformBdsBootFail\n"));
-
- //
- // If Boot returned with failed status then we need to pop up a UI and wait
- // for user input.
- //
- TmpStr = Option->StatusString;
- if (TmpStr != NULL) {
- BdsLibOutputStrings (gST->ConOut, TmpStr, Option->Description, L"\n\r", NULL);
- FreePool (TmpStr);
- }
-}
-
-EFI_STATUS
-PlatformBdsNoConsoleAction (
- VOID
- )
-/*++
-
-Routine Description:
-
- This function is remained for IBV/OEM to do some platform action,
- if there no console device can be connected.
-
-Arguments:
-
- None.
-
-Returns:
-
- EFI_SUCCESS - Direct return success now.
-
---*/
-{
- DEBUG ((EFI_D_INFO, "PlatformBdsNoConsoleAction\n"));
- return EFI_SUCCESS;
-}
-
-VOID
-EFIAPI
-PlatformBdsLockNonUpdatableFlash (
- VOID
- )
-{
- DEBUG ((EFI_D_INFO, "PlatformBdsLockNonUpdatableFlash\n"));
- return;
-}
-
-
-/**
- This notification function is invoked when an instance of the
- EFI_DEVICE_PATH_PROTOCOL is produced.
-
- @param Event The event that occured
- @param Context For EFI compatiblity. 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
- );
-}
-
-/**
- Lock the ConsoleIn device in system table. All key
- presses will be ignored until the Password is typed in. The only way to
- disable the password is to type it in to a ConIn device.
-
- @param Password Password used to lock ConIn device.
-
- @retval EFI_SUCCESS lock the Console In Spliter virtual handle successfully.
- @retval EFI_UNSUPPORTED Password not found
-
-**/
-EFI_STATUS
-EFIAPI
-LockKeyboards (
- IN CHAR16 *Password
- )
-{
- return EFI_UNSUPPORTED;
-}
-
diff --git a/OvmfPkg/Library/PlatformBdsLib/BdsPlatform.h b/OvmfPkg/Library/PlatformBdsLib/BdsPlatform.h
deleted file mode 100644
index 6ba0d48e80..0000000000
--- a/OvmfPkg/Library/PlatformBdsLib/BdsPlatform.h
+++ /dev/null
@@ -1,292 +0,0 @@
-/** @file
- Platform BDS customizations include file.
-
- Copyright (c) 2006 - 2007, Intel Corporation. All rights reserved.<BR>
- This program and the accompanying materials
- are licensed and made available under the terms and conditions of the BSD License
- which accompanies this distribution. The full text of the license may be found at
- http://opensource.org/licenses/bsd-license.php
-
- 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 <PiDxe.h>
-
-#include <IndustryStandard/Pci.h>
-#include <IndustryStandard/Acpi.h>
-#include <IndustryStandard/SmBios.h>
-#include <IndustryStandard/PeImage.h>
-
-#include <Library/DebugLib.h>
-#include <Library/BaseMemoryLib.h>
-#include <Library/UefiBootServicesTableLib.h>
-#include <Library/UefiRuntimeServicesTableLib.h>
-#include <Library/MemoryAllocationLib.h>
-#include <Library/BaseLib.h>
-#include <Library/PcdLib.h>
-#include <Library/PciLib.h>
-#include <Library/GenericBdsLib.h>
-#include <Library/PlatformBdsLib.h>
-#include <Library/HobLib.h>
-#include <Library/UefiLib.h>
-#include <Library/DxeServicesTableLib.h>
-#include <Library/DevicePathLib.h>
-#include <Library/IoLib.h>
-#include <Library/NvVarsFileLib.h>
-#include <Library/QemuFwCfgLib.h>
-
-#include <Protocol/Decompress.h>
-#include <Protocol/PciIo.h>
-#include <Protocol/FirmwareVolume2.h>
-#include <Protocol/SimpleFileSystem.h>
-#include <Protocol/PciRootBridgeIo.h>
-#include <Protocol/S3SaveState.h>
-#include <Protocol/DxeSmmReadyToLock.h>
-
-#include <Guid/Acpi.h>
-#include <Guid/SmBios.h>
-#include <Guid/Mps.h>
-#include <Guid/HobList.h>
-#include <Guid/GlobalVariable.h>
-#include <Guid/EventGroup.h>
-
-#include <OvmfPlatforms.h>
-
-extern BDS_CONSOLE_CONNECT_ENTRY gPlatformConsole[];
-extern EFI_DEVICE_PATH_PROTOCOL *gPlatformConnectSequence[];
-extern EFI_DEVICE_PATH_PROTOCOL *gPlatformDriverOption[];
-extern ACPI_HID_DEVICE_PATH gPnpPs2KeyboardDeviceNode;
-extern ACPI_HID_DEVICE_PATH gPnp16550ComPortDeviceNode;
-extern UART_DEVICE_PATH gUartDeviceNode;
-extern VENDOR_DEVICE_PATH gTerminalTypeDeviceNode;
-//
-//
-//
-#define VarConsoleInpDev L"ConInDev"
-#define VarConsoleInp L"ConIn"
-#define VarConsoleOutDev L"ConOutDev"
-#define VarConsoleOut L"ConOut"
-#define VarErrorOutDev L"ErrOutDev"
-#define VarErrorOut L"ErrOut"
-
-#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 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 EFI_SYSTEM_TABLE_MAX_ADDRESS 0xFFFFFFFF
-#define SYS_TABLE_PAD(ptr) (((~ptr) +1) & 0x07 )
-
-#define IS_PCI_ISA_PDECODE(_p) IS_CLASS3 (_p, PCI_CLASS_BRIDGE, PCI_CLASS_BRIDGE_ISA_PDECODE, 0)
-
-typedef struct {
- ACPI_HID_DEVICE_PATH PciRootBridge;
- PCI_DEVICE_PATH IsaBridge;
- ACPI_HID_DEVICE_PATH Keyboard;
- EFI_DEVICE_PATH_PROTOCOL End;
-} PLATFORM_DUMMY_ISA_KEYBOARD_DEVICE_PATH;
-
-typedef struct {
- ACPI_HID_DEVICE_PATH PciRootBridge;
- PCI_DEVICE_PATH IsaBridge;
- ACPI_HID_DEVICE_PATH IsaSerial;
- UART_DEVICE_PATH Uart;
- VENDOR_DEVICE_PATH TerminalType;
- EFI_DEVICE_PATH_PROTOCOL End;
-} PLATFORM_DUMMY_ISA_SERIAL_DEVICE_PATH;
-
-typedef struct {
- ACPI_HID_DEVICE_PATH PciRootBridge;
- PCI_DEVICE_PATH VgaDevice;
- EFI_DEVICE_PATH_PROTOCOL End;
-} PLATFORM_DUMMY_PCI_VGA_DEVICE_PATH;
-
-typedef struct {
- ACPI_HID_DEVICE_PATH PciRootBridge;
- PCI_DEVICE_PATH PciBridge;
- PCI_DEVICE_PATH SerialDevice;
- UART_DEVICE_PATH Uart;
- VENDOR_DEVICE_PATH TerminalType;
- EFI_DEVICE_PATH_PROTOCOL End;
-} PLATFORM_DUMMY_PCI_SERIAL_DEVICE_PATH;
-
-//
-// the short form device path for Usb keyboard
-//
-#define CLASS_HID 3
-#define SUBCLASS_BOOT 1
-#define PROTOCOL_KEYBOARD 1
-
-typedef struct {
- USB_CLASS_DEVICE_PATH UsbClass;
- EFI_DEVICE_PATH_PROTOCOL End;
-} USB_CLASS_FORMAT_DEVICE_PATH;
-
-//
-// Platform BDS Functions
-//
-
-VOID
-PlatformBdsGetDriverOption (
- IN LIST_ENTRY *BdsDriverLists
- );
-
-EFI_STATUS
-BdsMemoryTest (
- EXTENDMEM_COVERAGE_LEVEL Level
- );
-
-EFI_STATUS
-PlatformBdsShowProgress (
- EFI_GRAPHICS_OUTPUT_BLT_PIXEL TitleForeground,
- EFI_GRAPHICS_OUTPUT_BLT_PIXEL TitleBackground,
- CHAR16 *Title,
- EFI_GRAPHICS_OUTPUT_BLT_PIXEL ProgressColor,
- UINTN Progress,
- UINTN PreviousValue
- );
-
-VOID
-PlatformBdsConnectSequence (
- VOID
- );
-
-EFI_STATUS
-ProcessCapsules (
- EFI_BOOT_MODE BootMode
- );
-
-EFI_STATUS
-PlatformBdsConnectConsole (
- IN BDS_CONSOLE_CONNECT_ENTRY *PlatformConsole
- );
-
-EFI_STATUS
-PlatformBdsNoConsoleAction (
- VOID
- );
-
-EFI_STATUS
-ConvertMpsTable (
- IN OUT VOID **Table
- );
-
-EFI_STATUS
-ConvertSmbiosTable (
- IN OUT VOID **Table
- );
-
-EFI_STATUS
-ConvertAcpiTable (
- IN UINTN TableLen,
- IN OUT VOID **Table
- );
-
-EFI_STATUS
-ConvertSystemTable (
- IN EFI_GUID *TableGuid,
- IN OUT VOID **Table
- );
-
-VOID
-PlatformBdsEnterFrontPage (
- IN UINT16 TimeoutDefault,
- IN BOOLEAN ConnectAllHappened
- );
-
-/**
- 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/PlatformBdsLib/PlatformBdsLib.inf b/OvmfPkg/Library/PlatformBdsLib/PlatformBdsLib.inf
deleted file mode 100644
index ab5468368d..0000000000
--- a/OvmfPkg/Library/PlatformBdsLib/PlatformBdsLib.inf
+++ /dev/null
@@ -1,72 +0,0 @@
-## @file
-# Platform BDS customizations library.
-#
-# Copyright (c) 2007 - 2015, Intel Corporation. All rights reserved.<BR>
-# This program and the accompanying materials
-# are licensed and made available under the terms and conditions of the BSD License
-# which accompanies this distribution. The full text of the license may be found at
-# http://opensource.org/licenses/bsd-license.php
-#
-# 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 = PlatformBdsLib
- FILE_GUID = F844172E-9985-44f2-BADE-0DD783462E95
- MODULE_TYPE = DXE_DRIVER
- VERSION_STRING = 1.0
- LIBRARY_CLASS = PlatformBdsLib|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
- OvmfPkg/OvmfPkg.dec
-
-[LibraryClasses]
- BaseLib
- MemoryAllocationLib
- UefiBootServicesTableLib
- BaseMemoryLib
- DebugLib
- PcdLib
- GenericBdsLib
- PciLib
- NvVarsFileLib
- QemuFwCfgLib
- LoadLinuxLib
- QemuBootOrderLib
- UefiLib
-
-[Pcd]
- gEfiIntelFrameworkModulePkgTokenSpaceGuid.PcdLogoFile
- gUefiOvmfPkgTokenSpaceGuid.PcdEmuVariableEvent
- gUefiOvmfPkgTokenSpaceGuid.PcdOvmfFlashVariablesEnable
- gUefiOvmfPkgTokenSpaceGuid.PcdOvmfHostBridgePciDevId
-
-[Pcd.IA32, Pcd.X64]
- gEfiMdePkgTokenSpaceGuid.PcdFSBClock
-
-[Protocols]
- gEfiDecompressProtocolGuid
- gEfiPciRootBridgeIoProtocolGuid
- gEfiS3SaveStateProtocolGuid # PROTOCOL SOMETIMES_CONSUMED
- gEfiDxeSmmReadyToLockProtocolGuid # PROTOCOL SOMETIMES_PRODUCED
-
-[Guids]
- gEfiEndOfDxeEventGroupGuid
diff --git a/OvmfPkg/Library/PlatformBdsLib/PlatformData.c b/OvmfPkg/Library/PlatformBdsLib/PlatformData.c
deleted file mode 100644
index f69c1a8714..0000000000
--- a/OvmfPkg/Library/PlatformBdsLib/PlatformData.c
+++ /dev/null
@@ -1,51 +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 - 2008, Intel Corporation. All rights reserved.<BR>
- This program and the accompanying materials
- are licensed and made available under the terms and conditions of the BSD License
- which accompanies this distribution. The full text of the license may be found at
- http://opensource.org/licenses/bsd-license.php
-
- THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
- WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
-
-**/
-
-#include "BdsPlatform.h"
-
-//
-// Predefined platform default time out value
-//
-UINT16 gPlatformBootTimeOutDefault = 5;
-
-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
-//
-
-//
-// Predefined platform default console device path
-//
-BDS_CONSOLE_CONNECT_ENTRY gPlatformConsole[] = {
- {
- NULL,
- 0
- }
-};
-
-//
-// Predefined platform specific driver option
-//
-EFI_DEVICE_PATH_PROTOCOL *gPlatformDriverOption[] = { NULL };
-
-//
-// Predefined platform connect sequence
-//
-EFI_DEVICE_PATH_PROTOCOL *gPlatformConnectSequence[] = { NULL };
-
diff --git a/OvmfPkg/Library/PlatformBdsLib/QemuKernel.c b/OvmfPkg/Library/PlatformBdsLib/QemuKernel.c
deleted file mode 100644
index ef728dfdeb..0000000000
--- a/OvmfPkg/Library/PlatformBdsLib/QemuKernel.c
+++ /dev/null
@@ -1,170 +0,0 @@
-/** @file
-
- Copyright (c) 2006 - 2015, Intel Corporation. All rights reserved.<BR>
- This program and the accompanying materials
- are licensed and made available under the terms and conditions of the BSD License
- which accompanies this distribution. The full text of the license may be found at
- http://opensource.org/licenses/bsd-license.php
-
- THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
- WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
-
-**/
-
-#include <Uefi.h>
-
-#include <Library/BaseLib.h>
-#include <Library/DebugLib.h>
-#include <Library/LoadLinuxLib.h>
-#include <Library/MemoryAllocationLib.h>
-#include <Library/QemuFwCfgLib.h>
-#include <Library/UefiBootServicesTableLib.h>
-#include <Library/UefiLib.h>
-
-
-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.<BR>
- Copyright (c) 2012, Red Hat, Inc.<BR>
- This program and the accompanying materials
- are licensed and made available under the terms and conditions of the BSD License
- which accompanies this distribution. The full text of the license may be found at
- http://opensource.org/licenses/bsd-license.php.
-
- 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 <Base.h>
-#include <Uefi.h>
-#include <Library/DebugLib.h>
-#include <Library/BaseLib.h>
-#include <Library/IoLib.h>
-#include <Library/PrintLib.h>
-#include <Library/PcdLib.h>
-#include <Library/BaseMemoryLib.h>
-#include <Library/DebugPrintErrorLevelLib.h>
-
-//
-// 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 <FileName>(<LineNumber>): <Description>\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 <FileName> string of "(NULL) Filename" is printed.
- If Description is NULL, then a <Description> 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.<BR>
-# Copyright (c) 2012, Red Hat, Inc.<BR>
-#
-# This program and the accompanying materials
-# are licensed and made available under the terms and conditions of the BSD License
-# which accompanies this distribution. The full text of the license may be found at
-# http://opensource.org/licenses/bsd-license.php.
-# 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.<BR>
- This program and the accompanying materials
- are licensed and made available under the terms and conditions of the BSD License
- which accompanies this distribution. The full text of the license may be found at
- http://opensource.org/licenses/bsd-license.php
-
- THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
- WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
-
-**/
-
-#include "PiDxe.h"
-#include <Library/PlatformFvbLib.h>
-
-
-/**
- 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.<BR>
-#
-# This program and the accompanying materials
-# are licensed and made available under the terms and conditions of the BSD License
-# which accompanies this distribution. The full text of the license may be found at
-# http://opensource.org/licenses/bsd-license.php
-# 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.<BR>
- This program and the accompanying materials
- are licensed and made available under the terms and conditions of the BSD License
- which accompanies this distribution. The full text of the license may be found at
- http://opensource.org/licenses/bsd-license.php
-
- THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
- WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
-
-**/
-#include <Library/PcdLib.h>
-
-/**
-
- 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.<BR>
-#
-# This program and the accompanying materials
-# are licensed and made available under the terms and conditions of the BSD License
-# which accompanies this distribution. The full text of the license may be found at
-# http://opensource.org/licenses/bsd-license.php
-# 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 ec422145c4..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 <Library/DebugLib.h>
-#include <Library/DevicePathLib.h>
-#include <Library/MemoryAllocationLib.h>
-#include <Library/OrderedCollectionLib.h>
-#include <Library/UefiBootServicesTableLib.h>
-#include <Protocol/DevicePath.h>
-#include <Protocol/PciRootBridgeIo.h>
-
-#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[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 2e9634359d..0000000000
--- a/OvmfPkg/Library/QemuBootOrderLib/QemuBootOrderLib.c
+++ /dev/null
@@ -1,1793 +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, Intel Corporation. All rights reserved.<BR>
-
- This program and the accompanying materials are licensed and made available
- under the terms and conditions of the BSD License which accompanies this
- distribution. The full text of the license may be found at
- http://opensource.org/licenses/bsd-license.php
-
- THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, WITHOUT
- WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
-**/
-
-#include <Library/QemuFwCfgLib.h>
-#include <Library/DebugLib.h>
-#include <Library/MemoryAllocationLib.h>
-#include <Library/GenericBdsLib.h>
-#include <Library/UefiBootServicesTableLib.h>
-#include <Library/UefiRuntimeServicesTableLib.h>
-#include <Library/BaseLib.h>
-#include <Library/PrintLib.h>
-#include <Library/DevicePathLib.h>
-#include <Library/QemuBootOrderLib.h>
-#include <Library/BaseMemoryLib.h>
-#include <Guid/GlobalVariable.h>
-#include <Guid/VirtioMmioTransport.h>
-
-#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 BDS_COMMON_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++] =
- ActiveOption->BootOption->BootCurrent;
- ActiveOption->Appended = TRUE;
- return RETURN_SUCCESS;
-}
-
-
-/**
-
- Create an array of ACTIVE_OPTION elements for a boot option list.
-
- @param[in] BootOptionList A boot option list, created with
- BdsLibEnumerateAllBootOption().
-
- @param[out] ActiveOption Pointer to the first element in the new array.
- The caller is responsible for freeing the array
- with FreePool() after use.
-
- @param[out] Count Number of elements in the new array.
-
-
- @retval RETURN_SUCCESS The ActiveOption array has been created.
-
- @retval RETURN_NOT_FOUND No active entry has been found in
- BootOptionList.
-
- @retval RETURN_OUT_OF_RESOURCES Memory allocation failed.
-
-**/
-STATIC
-RETURN_STATUS
-CollectActiveOptions (
- IN CONST LIST_ENTRY *BootOptionList,
- OUT ACTIVE_OPTION **ActiveOption,
- OUT UINTN *Count
- )
-{
- UINTN ScanMode;
-
- *ActiveOption = NULL;
-
- //
- // Scan the list twice:
- // - count active entries,
- // - store links to active entries.
- //
- for (ScanMode = 0; ScanMode < 2; ++ScanMode) {
- CONST LIST_ENTRY *Link;
-
- Link = BootOptionList->ForwardLink;
- *Count = 0;
- while (Link != BootOptionList) {
- CONST BDS_COMMON_OPTION *Current;
-
- Current = CR (Link, BDS_COMMON_OPTION, Link, BDS_LOAD_OPTION_SIGNATURE);
- if (IS_LOAD_OPTION_TYPE (Current->Attribute, LOAD_OPTION_ACTIVE)) {
- if (ScanMode == 1) {
- (*ActiveOption)[*Count].BootOption = Current;
- (*ActiveOption)[*Count].Appended = FALSE;
- }
- ++*Count;
- }
- Link = Link->ForwardLink;
- }
-
- if (ScanMode == 0) {
- if (*Count == 0) {
- return RETURN_NOT_FOUND;
- }
- *ActiveOption = AllocatePool (*Count * sizeof **ActiveOption);
- if (*ActiveOption == NULL) {
- return RETURN_OUT_OF_RESOURCES;
- }
- }
- }
- return RETURN_SUCCESS;
-}
-
-
-/**
- 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][<LF>]
-
- A single trailing <LF> character is consumed but not returned. A trailing
- <LF> 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 = sizeof (PciDevFun) / sizeof (PciDevFun[0]);
- 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, "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)/HD( -- if PCI function is 0 or absent
- // PciRoot(0x0)/Pci(0x6,0x3)/HD( -- if PCI function is present and nonzero
- //
- Written = UnicodeSPrintAsciiFormat (
- Translated,
- *TranslatedSize * sizeof (*Translated), // BufferSize in bytes
- "PciRoot(0x%x)%s/Pci(0x%Lx,0x%Lx)/HD(",
- 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 = sizeof (TargetLun) / sizeof (TargetLun[0]);
- 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 {
- //
- // 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:
- //
- // <VenHwString>/HD(
- //
- Written = UnicodeSPrintAsciiFormat (
- Translated,
- *TranslatedSize * sizeof (*Translated), // BufferSize in bytes
- "%s/HD(",
- 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:
- //
- // <VenHwString>/Scsi(0x2,0x3)
- //
- UINT64 TargetLun[2];
-
- TargetLun[1] = 0;
- NumEntries = sizeof (TargetLun) / sizeof (TargetLun[0]);
- 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):
- //
- // <VenHwString>/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 CONST EFI_DEVICE_PATH_PROTOCOL *DevicePath
- )
-{
- CHAR16 *Converted;
- BOOLEAN Result;
-
- Converted = ConvertDevicePathToText (
- DevicePath,
- FALSE, // DisplayOnly
- FALSE // AllowShortcuts
- );
- if (Converted == NULL) {
- return FALSE;
- }
-
- //
- // Attempt to expand any relative UEFI device path starting with HD() to an
- // absolute device path first. The logic imitates BdsLibBootViaBootOption().
- // We don't have to free the absolute device path,
- // BdsExpandPartitionPartialDevicePathToFull() has internal caching.
- //
- Result = FALSE;
- if (DevicePathType (DevicePath) == MEDIA_DEVICE_PATH &&
- DevicePathSubType (DevicePath) == MEDIA_HARDDRIVE_DP) {
- EFI_DEVICE_PATH_PROTOCOL *AbsDevicePath;
- CHAR16 *AbsConverted;
-
- AbsDevicePath = BdsExpandPartitionPartialDevicePathToFull (
- (HARDDRIVE_DEVICE_PATH *) DevicePath);
- if (AbsDevicePath == NULL) {
- goto Exit;
- }
- AbsConverted = ConvertDevicePathToText (AbsDevicePath, FALSE, FALSE);
- if (AbsConverted == NULL) {
- goto Exit;
- }
- DEBUG ((DEBUG_VERBOSE,
- "%a: expanded relative device path \"%s\" for prefix matching\n",
- __FUNCTION__, Converted));
- FreePool (Converted);
- Converted = AbsConverted;
- }
-
- //
- // Is Translated a prefix of Converted?
- //
- Result = (BOOLEAN)(StrnCmp (Converted, Translated, TranslatedLength) == 0);
- 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 BDS_COMMON_OPTION *Current;
- CONST EFI_DEVICE_PATH_PROTOCOL *FirstNode;
-
- Current = ActiveOption[Idx].BootOption;
- FirstNode = Current->DevicePath;
- if (FirstNode != NULL) {
- CHAR16 *Converted;
- STATIC CHAR16 ConvFallBack[] = L"<unable to convert>";
- BOOLEAN Keep;
-
- Converted = ConvertDevicePathToText (FirstNode, FALSE, FALSE);
- if (Converted == NULL) {
- Converted = ConvFallBack;
- }
-
- Keep = TRUE;
- if (DevicePathType(FirstNode) == MEDIA_DEVICE_PATH &&
- DevicePathSubType(FirstNode) == MEDIA_HARDDRIVE_DP) {
- //
- // drop HD()
- //
- Keep = FALSE;
- } else if (DevicePathType(FirstNode) == ACPI_DEVICE_PATH &&
- DevicePathSubType(FirstNode) == ACPI_DP) {
- ACPI_HID_DEVICE_PATH *Acpi;
-
- Acpi = (ACPI_HID_DEVICE_PATH *) FirstNode;
- if ((Acpi->HID & PNP_EISA_ID_MASK) == PNP_EISA_ID_CONST &&
- EISA_ID_TO_NUM (Acpi->HID) == 0x0a03) {
- //
- // drop PciRoot() 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->BootCurrent);
-
- //
- // "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 BootOptionList, and rewrite the BootOrder NvVar
- so that it corresponds to the order described in fw_cfg.
-
- @param[in] BootOptionList A boot option list, created with
- BdsLibEnumerateAllBootOption ().
-
-
- @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 (
- IN CONST LIST_ENTRY *BootOptionList
- )
-{
- 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];
-
- 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: <end>\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;
- }
-
- Status = CollectActiveOptions (BootOptionList, &ActiveOption, &ActiveCount);
- if (RETURN_ERROR (Status)) {
- goto ErrorFreeBootOrder;
- }
-
- if (FeaturePcdGet (PcdQemuBootOrderPciTranslation)) {
- Status = CreateExtraRootBusMap (&ExtraPciRoots);
- if (EFI_ERROR (Status)) {
- goto ErrorFreeActiveOption;
- }
- } else {
- ExtraPciRoots = NULL;
- }
-
- //
- // translate each OpenFirmware path
- //
- TranslatedSize = sizeof (Translated) / sizeof (Translated[0]);
- 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->DevicePath
- )
- ) {
- //
- // 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 = sizeof (Translated) / sizeof (Translated[0]);
- 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);
-
-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 102432848b..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 - 2015, Intel Corporation. All rights reserved.<BR>
-#
-# This program and the accompanying materials are licensed and made available
-# under the terms and conditions of the BSD License which accompanies this
-# distribution. The full text of the license may be found at
-# http://opensource.org/licenses/bsd-license.php
-#
-# 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 = 4FFFA9E1-103D-4CF2-9C06-563BDD03050E
- 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
- IntelFrameworkModulePkg/IntelFrameworkModulePkg.dec
- OvmfPkg/OvmfPkg.dec
-
-[LibraryClasses]
- QemuFwCfgLib
- DebugLib
- MemoryAllocationLib
- GenericBdsLib
- 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/Ia32/IoLibExAsm.nasm b/OvmfPkg/Library/QemuFwCfgLib/Ia32/IoLibExAsm.nasm
deleted file mode 100644
index faa22e97d4..0000000000
--- a/OvmfPkg/Library/QemuFwCfgLib/Ia32/IoLibExAsm.nasm
+++ /dev/null
@@ -1,55 +0,0 @@
-;------------------------------------------------------------------------------
-;
-; Copyright (c) 2006 - 2013, Intel Corporation. All rights reserved.<BR>
-; This program and the accompanying materials
-; are licensed and made available under the terms and conditions of the BSD License
-; which accompanies this distribution. The full text of the license may be found at
-; http://opensource.org/licenses/bsd-license.php.
-;
-; THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
-; WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
-;
-;------------------------------------------------------------------------------
-
- SECTION .text
-
-;------------------------------------------------------------------------------
-; VOID
-; EFIAPI
-; IoReadFifo8 (
-; IN UINTN Port,
-; IN UINTN Size,
-; IN VOID *Buffer
-; );
-;------------------------------------------------------------------------------
-global ASM_PFX(IoReadFifo8)
-ASM_PFX(IoReadFifo8):
-
- mov dx, [esp + 4]
- mov ecx, [esp + 8]
- push edi
- mov edi, [esp + 16]
-rep insb
- pop edi
- ret
-
-;------------------------------------------------------------------------------
-; VOID
-; EFIAPI
-; IoWriteFifo8 (
-; IN UINTN Port,
-; IN UINTN Size,
-; IN VOID *Buffer
-; );
-;------------------------------------------------------------------------------
-global ASM_PFX(IoWriteFifo8)
-ASM_PFX(IoWriteFifo8):
-
- mov dx, [esp + 4]
- mov ecx, [esp + 8]
- push esi
- mov esi, [esp + 16]
-rep outsb
- pop esi
- ret
-
diff --git a/OvmfPkg/Library/QemuFwCfgLib/QemuFwCfgLib.c b/OvmfPkg/Library/QemuFwCfgLib/QemuFwCfgLib.c
deleted file mode 100644
index 5c96d2af25..0000000000
--- a/OvmfPkg/Library/QemuFwCfgLib/QemuFwCfgLib.c
+++ /dev/null
@@ -1,325 +0,0 @@
-/** @file
-
- Copyright (c) 2011 - 2013, Intel Corporation. All rights reserved.<BR>
- 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 "Uefi.h"
-#include <Library/BaseLib.h>
-#include <Library/BaseMemoryLib.h>
-#include <Library/DebugLib.h>
-#include <Library/IoLib.h>
-#include <Library/QemuFwCfgLib.h>
-#include <Library/MemoryAllocationLib.h>
-#include <Library/UefiBootServicesTableLib.h>
-
-
-/**
- Reads an 8-bit I/O port fifo into a block of memory.
-
- Reads the 8-bit I/O fifo port specified by Port.
-
- The port is read Count times, and the read data is
- stored in the provided Buffer.
-
- This function must guarantee that all I/O read and write operations are
- serialized.
-
- If 8-bit I/O port operations are not supported, then ASSERT().
-
- @param Port The I/O port to read.
- @param Count The number of times to read I/O port.
- @param Buffer The buffer to store the read data into.
-
-**/
-VOID
-EFIAPI
-IoReadFifo8 (
- IN UINTN Port,
- IN UINTN Count,
- OUT VOID *Buffer
- );
-
-/**
- Writes an 8-bit I/O port fifo from a block of memory.
-
- Writes the 8-bit I/O fifo port specified by Port.
-
- The port is written Count times, and the data are obtained
- from the provided Buffer.
-
- This function must guarantee that all I/O read and write operations are
- serialized.
-
- If 8-bit I/O port operations are not supported, then ASSERT().
-
- @param Port The I/O port to read.
- @param Count The number of times to read I/O port.
- @param Buffer The buffer to store the read data into.
-
-**/
-VOID
-EFIAPI
-IoWriteFifo8 (
- IN UINTN Port,
- IN UINTN Count,
- OUT VOID *Buffer
- );
-
-
-/**
- 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 (0x510, (UINT16)(UINTN) QemuFwCfgItem);
-}
-
-
-/**
- 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
- )
-{
- IoReadFifo8 (0x511, 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 ()) {
- IoWriteFifo8 (0x511, Size, Buffer);
- }
-}
-
-
-/**
- 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;
-}
-
-
-/**
- Determine if S3 support is explicitly enabled.
-
- @retval TRUE if S3 support is explicitly enabled.
- FALSE otherwise. This includes unavailability of the firmware
- configuration interface.
-**/
-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/QemuFwCfgLib/QemuFwCfgLib.inf b/OvmfPkg/Library/QemuFwCfgLib/QemuFwCfgLib.inf
deleted file mode 100644
index a95e1e730c..0000000000
--- a/OvmfPkg/Library/QemuFwCfgLib/QemuFwCfgLib.inf
+++ /dev/null
@@ -1,54 +0,0 @@
-## @file
-#
-# Stateful, implicitly initialized fw_cfg library.
-#
-# Copyright (C) 2013, Red Hat, Inc.
-# Copyright (c) 2008 - 2012, Intel Corporation. All rights reserved.<BR>
-#
-# This program and the accompanying materials
-# are licensed and made available under the terms and conditions of the BSD License
-# which accompanies this distribution. The full text of the license may be found at
-# http://opensource.org/licenses/bsd-license.php
-#
-# 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]
- QemuFwCfgLib.c
- QemuFwCfgPeiDxe.c
-
-[Sources.IA32]
- Ia32/IoLibExAsm.nasm
-
-[Sources.X64]
- X64/IoLibExAsm.nasm
-
-[Packages]
- MdePkg/MdePkg.dec
- OvmfPkg/OvmfPkg.dec
-
-[LibraryClasses]
- BaseLib
- BaseMemoryLib
- DebugLib
- IoLib
- MemoryAllocationLib
-
diff --git a/OvmfPkg/Library/QemuFwCfgLib/QemuFwCfgPeiDxe.c b/OvmfPkg/Library/QemuFwCfgLib/QemuFwCfgPeiDxe.c
deleted file mode 100644
index f693cff29e..0000000000
--- a/OvmfPkg/Library/QemuFwCfgLib/QemuFwCfgPeiDxe.c
+++ /dev/null
@@ -1,92 +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.<BR>
-
- This program and the accompanying materials are licensed and made available
- under the terms and conditions of the BSD License which accompanies this
- distribution. The full text of the license may be found at
- http://opensource.org/licenses/bsd-license.php
-
- THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, WITHOUT
- WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
-**/
-
-#include <Library/DebugLib.h>
-#include <Library/QemuFwCfgLib.h>
-
-STATIC BOOLEAN mQemuFwCfgSupported = FALSE;
-
-
-/**
- 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.
- //
- mQemuFwCfgSupported = TRUE;
-
- 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;
- }
-
- DEBUG ((EFI_D_INFO, "QemuFwCfg interface 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
-EFIAPI
-InternalQemuFwCfgIsAvailable (
- VOID
- )
-{
- return mQemuFwCfgSupported;
-}
diff --git a/OvmfPkg/Library/QemuFwCfgLib/QemuFwCfgSec.c b/OvmfPkg/Library/QemuFwCfgLib/QemuFwCfgSec.c
deleted file mode 100644
index 88c32ce89a..0000000000
--- a/OvmfPkg/Library/QemuFwCfgLib/QemuFwCfgSec.c
+++ /dev/null
@@ -1,81 +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.<BR>
-
- This program and the accompanying materials are licensed and made available
- under the terms and conditions of the BSD License which accompanies this
- distribution. The full text of the license may be found at
- http://opensource.org/licenses/bsd-license.php
-
- THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, WITHOUT
- WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
-**/
-
-#include <Library/DebugLib.h>
-#include <Library/QemuFwCfgLib.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
-EFIAPI
-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;
-}
diff --git a/OvmfPkg/Library/QemuFwCfgLib/QemuFwCfgSecLib.inf b/OvmfPkg/Library/QemuFwCfgLib/QemuFwCfgSecLib.inf
deleted file mode 100644
index 03a659c9b0..0000000000
--- a/OvmfPkg/Library/QemuFwCfgLib/QemuFwCfgSecLib.inf
+++ /dev/null
@@ -1,52 +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.<BR>
-#
-# This program and the accompanying materials
-# are licensed and made available under the terms and conditions of the BSD License
-# which accompanies this distribution. The full text of the license may be found at
-# http://opensource.org/licenses/bsd-license.php
-#
-# 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]
- QemuFwCfgLib.c
- QemuFwCfgSec.c
-
-[Sources.IA32]
- Ia32/IoLibExAsm.nasm
-
-[Sources.X64]
- X64/IoLibExAsm.nasm
-
-[Packages]
- MdePkg/MdePkg.dec
- OvmfPkg/OvmfPkg.dec
-
-[LibraryClasses]
- BaseLib
- BaseMemoryLib
- DebugLib
- IoLib
- MemoryAllocationLib
-
diff --git a/OvmfPkg/Library/QemuFwCfgLib/X64/IoLibExAsm.nasm b/OvmfPkg/Library/QemuFwCfgLib/X64/IoLibExAsm.nasm
deleted file mode 100644
index f1078f2088..0000000000
--- a/OvmfPkg/Library/QemuFwCfgLib/X64/IoLibExAsm.nasm
+++ /dev/null
@@ -1,52 +0,0 @@
-;------------------------------------------------------------------------------
-;
-; Copyright (c) 2006 - 2013, Intel Corporation. All rights reserved.<BR>
-; This program and the accompanying materials
-; are licensed and made available under the terms and conditions of the BSD License
-; which accompanies this distribution. The full text of the license may be found at
-; http://opensource.org/licenses/bsd-license.php.
-;
-; THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
-; WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
-;
-;------------------------------------------------------------------------------
-
- DEFAULT REL
- SECTION .text
-
-;------------------------------------------------------------------------------
-; VOID
-; EFIAPI
-; IoReadFifo8 (
-; IN UINTN Port, // rcx
-; IN UINTN Size, // rdx
-; IN VOID *Buffer // r8
-; );
-;------------------------------------------------------------------------------
-global ASM_PFX(IoReadFifo8)
-ASM_PFX(IoReadFifo8):
-
- xchg rcx, rdx
- xchg rdi, r8 ; rdi: buffer address; r8: save rdi
-rep insb
- mov rdi, r8 ; restore rdi
- ret
-
-;------------------------------------------------------------------------------
-; VOID
-; EFIAPI
-; IoWriteFifo8 (
-; IN UINTN Port, // rcx
-; IN UINTN Size, // rdx
-; IN VOID *Buffer // r8
-; );
-;------------------------------------------------------------------------------
-global ASM_PFX(IoWriteFifo8)
-ASM_PFX(IoWriteFifo8):
-
- xchg rcx, rdx
- xchg rsi, r8 ; rdi: buffer address; r8: save rdi
-rep outsb
- mov rsi, r8 ; restore rdi
- ret
-
diff --git a/OvmfPkg/Library/ResetSystemLib/ResetSystemLib.c b/OvmfPkg/Library/ResetSystemLib/ResetSystemLib.c
deleted file mode 100644
index 6d149e84c2..0000000000
--- a/OvmfPkg/Library/ResetSystemLib/ResetSystemLib.c
+++ /dev/null
@@ -1,108 +0,0 @@
-/** @file
- Reset System Library functions for OVMF
-
- Copyright (c) 2006 - 2013, Intel Corporation. All rights reserved.<BR>
- This program and the accompanying materials
- are licensed and made available under the terms and conditions of the BSD License
- which accompanies this distribution. The full text of the license may be found at
- http://opensource.org/licenses/bsd-license.php
-
- THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
- WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
-
-**/
-
-#include <Base.h>
-
-#include <Library/BaseLib.h>
-#include <Library/DebugLib.h>
-#include <Library/IoLib.h>
-#include <Library/PcdLib.h>
-#include <Library/TimerLib.h>
-
-VOID
-AcpiPmControl (
- UINTN SuspendType
- )
-{
- ASSERT (SuspendType < 6);
-
- IoBitFieldWrite16 (PcdGet16 (PcdAcpiPmBaseAddress) + 4, 10, 13, (UINT16) SuspendType);
- IoOr16 (PcdGet16 (PcdAcpiPmBaseAddress) + 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);
-}
diff --git a/OvmfPkg/Library/ResetSystemLib/ResetSystemLib.inf b/OvmfPkg/Library/ResetSystemLib/ResetSystemLib.inf
deleted file mode 100644
index b6a3ffe772..0000000000
--- a/OvmfPkg/Library/ResetSystemLib/ResetSystemLib.inf
+++ /dev/null
@@ -1,42 +0,0 @@
-## @file
-# Library instance for ResetSystem library class for OVMF
-#
-# Copyright (c) 2006 - 2013, Intel Corporation. All rights reserved.<BR>
-# This program and the accompanying materials
-# are licensed and made available under the terms and conditions of the BSD License
-# which accompanies this distribution. The full text of the license may be found at
-# http://opensource.org/licenses/bsd-license.php
-#
-# THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
-# WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
-#
-##
-
-[Defines]
- INF_VERSION = 0x00010005
- BASE_NAME = 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
-
-[Pcd]
- gUefiOvmfPkgTokenSpaceGuid.PcdAcpiPmBaseAddress \ No newline at end of file
diff --git a/OvmfPkg/Library/SerializeVariablesLib/SerializeVariablesLib.c b/OvmfPkg/Library/SerializeVariablesLib/SerializeVariablesLib.c
deleted file mode 100644
index 6822c5c725..0000000000
--- a/OvmfPkg/Library/SerializeVariablesLib/SerializeVariablesLib.c
+++ /dev/null
@@ -1,870 +0,0 @@
-/** @file
- Serialize Variables Library implementation
-
- Copyright (c) 2004 - 2011, Intel Corporation. All rights reserved.<BR>
- This program and the accompanying materials
- are licensed and made available under the terms and conditions of the BSD License
- which accompanies this distribution. The full text of the license may be found at
- http://opensource.org/licenses/bsd-license.php
-
- THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
- WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
-
-**/
-
-#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;
- }
- 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 4d01fd6e7c..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.<BR>
- This program and the accompanying materials
- are licensed and made available under the terms and conditions of the BSD License
- which accompanies this distribution. The full text of the license may be found at
- http://opensource.org/licenses/bsd-license.php
-
- 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 <Uefi.h>
-
-#include <Library/BaseLib.h>
-#include <Library/BaseMemoryLib.h>
-#include <Library/DebugLib.h>
-#include <Library/MemoryAllocationLib.h>
-#include <Library/SerializeVariablesLib.h>
-#include <Library/UefiBootServicesTableLib.h>
-#include <Library/UefiRuntimeServicesTableLib.h>
-
-#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.<BR>
-#
-# This program and the accompanying materials
-# are licensed and made available under the terms and conditions of the BSD License
-# which accompanies this distribution. The full text of the license may be found at
-# http://opensource.org/licenses/bsd-license.php
-# 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 950c3f7e0a..0000000000
--- a/OvmfPkg/Library/SmbiosVersionLib/DetectSmbiosVersionLib.c
+++ /dev/null
@@ -1,107 +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.<BR>
-
- This program and the accompanying materials are licensed and made available
- under the terms and conditions of the BSD License which accompanies this
- distribution. The full text of the license may be found at
- http://opensource.org/licenses/bsd-license.php
-
- THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, WITHOUT
- WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
-
-**/
-
-#include <IndustryStandard/SmBios.h>
-
-#include <Base.h>
-#include <Library/BaseMemoryLib.h>
-#include <Library/DebugLib.h>
-#include <Library/PcdLib.h>
-#include <Library/QemuFwCfgLib.h>
-
-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;
-
- 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));
- PcdSet8 (PcdSmbiosDocRev, QemuAnchor.V3.DocRev);
- break;
-
- default:
- return RETURN_SUCCESS;
- }
-
- DEBUG ((EFI_D_INFO, "%a: SMBIOS version from QEMU: 0x%04x\n", __FUNCTION__,
- SmbiosVersion));
- PcdSet16 (PcdSmbiosVersion, SmbiosVersion);
-
- //
- // SMBIOS platform drivers can now fetch and install
- // "etc/smbios/smbios-tables" from QEMU.
- //
- PcdSetBool (PcdQemuSmbiosValidated, TRUE);
- 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.<BR>
-#
-# This program and the accompanying materials are licensed and made available
-# under the terms and conditions of the BSD License which accompanies this
-# distribution. The full text of the license may be found at
-# http://opensource.org/licenses/bsd-license.php
-#
-# 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/VirtioLib/VirtioLib.c b/OvmfPkg/Library/VirtioLib/VirtioLib.c
deleted file mode 100644
index 54cf225c98..0000000000
--- a/OvmfPkg/Library/VirtioLib/VirtioLib.c
+++ /dev/null
@@ -1,319 +0,0 @@
-/** @file
-
- Utility functions used by virtio device drivers.
-
- Copyright (C) 2012, Red Hat, Inc.
- Portion of Copyright (C) 2013, ARM Ltd.
-
- This program and the accompanying materials are licensed and made available
- under the terms and conditions of the BSD License which accompanies this
- distribution. The full text of the license may be found at
- http://opensource.org/licenses/bsd-license.php
-
- THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, WITHOUT
- WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
-
-**/
-
-#include <Library/BaseLib.h>
-#include <Library/BaseMemoryLib.h>
-#include <Library/DebugLib.h>
-#include <Library/MemoryAllocationLib.h>
-#include <Library/UefiBootServicesTableLib.h>
-
-#include <Library/VirtioLib.h>
-
-
-/**
-
- 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.
-
-
- @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
- )
-{
- UINT16 NextAvailIdx;
- EFI_STATUS Status;
- UINTN PollPeriodUsecs;
-
- //
- // virtio-0.9.5, 2.4.1.2 Updating the Available Ring
- //
- // It is not exactly clear from the wording of the virtio-0.9.5
- // specification, but each entry in the Available Ring references only the
- // head descriptor of any given descriptor chain.
- //
- NextAvailIdx = *Ring->Avail.Idx;
- Ring->Avail.Ring[NextAvailIdx++ % Ring->QueueSize] =
- Indices->HeadDescIdx % Ring->QueueSize;
-
- //
- // virtio-0.9.5, 2.4.1.3 Updating the Index Field
- //
- MemoryFence();
- *Ring->Avail.Idx = 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();
- return EFI_SUCCESS;
-}
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 4af9dd0ac2..0000000000
--- a/OvmfPkg/Library/VirtioMmioDeviceLib/VirtioMmioDevice.c
+++ /dev/null
@@ -1,224 +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 <Library/BaseMemoryLib.h>
-#include <Library/MemoryAllocationLib.h>
-#include <Library/UefiBootServicesTableLib.h>
-
-#include "VirtioMmioDevice.h"
-
-static VIRTIO_DEVICE_PROTOCOL mMmioDeviceProtocolTemplate = {
- 0, // Revision
- 0, // SubSystemDeviceId
- VirtioMmioGetDeviceFeatures, // GetDeviceFeatures
- VirtioMmioSetGuestFeatures, // SetGuestFeatures
- VirtioMmioGetQueueAddress, // GetQueueAddress
- VirtioMmioSetQueueAddress, // SetQueueAddress
- VirtioMmioSetQueueSel, // SetQueueSel
- VirtioMmioSetQueueNotify, // SetQueueNotify
- VirtioMmioSetQueueAlignment, // SetQueueAlign
- VirtioMmioSetPageSize, // SetPageSize
- VirtioMmioGetQueueSize, // GetQueueNumMax
- VirtioMmioSetQueueSize, // SetQueueNum
- VirtioMmioGetDeviceStatus, // GetDeviceStatus
- VirtioMmioSetDeviceStatus, // SetDeviceStatus
- VirtioMmioDeviceWrite, // WriteDevice
- VirtioMmioDeviceRead // ReadDevice
-};
-
-/**
-
- Initialize the VirtIo MMIO Device
-
- @param[in] BaseAddress Base Address of the VirtIo MMIO Device
-
- @param[in, out] Device The driver instance to configure.
-
- @retval EFI_SUCCESS Setup complete.
-
- @retval EFI_UNSUPPORTED The driver is not a VirtIo MMIO device.
-
-**/
-STATIC
-EFI_STATUS
-EFIAPI
-VirtioMmioInit (
- IN PHYSICAL_ADDRESS BaseAddress,
- IN OUT VIRTIO_MMIO_DEVICE *Device
- )
-{
- UINT32 MagicValue;
- UINT32 VendorId;
- UINT32 Version;
-
- //
- // Initialize VirtIo Mmio Device
- //
- CopyMem (&Device->VirtioDevice, &mMmioDeviceProtocolTemplate,
- sizeof (VIRTIO_DEVICE_PROTOCOL));
- Device->BaseAddress = BaseAddress;
- Device->VirtioDevice.Revision = VIRTIO_SPEC_REVISION (0, 9, 5);
- Device->VirtioDevice.SubSystemDeviceId =
- MmioRead32 (BaseAddress + VIRTIO_MMIO_OFFSET_DEVICE_ID);
-
- //
- // Double-check MMIO-specific values
- //
- MagicValue = VIRTIO_CFG_READ (Device, VIRTIO_MMIO_OFFSET_MAGIC);
- if (MagicValue != VIRTIO_MMIO_MAGIC) {
- return EFI_UNSUPPORTED;
- }
-
- Version = VIRTIO_CFG_READ (Device, VIRTIO_MMIO_OFFSET_VERSION);
- if (Version != 1) {
- return EFI_UNSUPPORTED;
- }
-
- //
- // Double-check MMIO-specific values
- //
- VendorId = VIRTIO_CFG_READ (Device, VIRTIO_MMIO_OFFSET_VENDOR_ID);
- if (VendorId != VIRTIO_VENDOR_ID) {
- //
- // The ARM Base and Foundation Models do not report a valid VirtIo VendorId.
- // They return a value of 0x0 for the VendorId.
- //
- DEBUG((EFI_D_WARN, "VirtioMmioInit: Warning: The VendorId (0x%X) does not "
- "match the VirtIo VendorId (0x%X).\n",
- VendorId, VIRTIO_VENDOR_ID));
- }
-
- return EFI_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 3e4e5606cc..0000000000
--- a/OvmfPkg/Library/VirtioMmioDeviceLib/VirtioMmioDevice.h
+++ /dev/null
@@ -1,147 +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 <Protocol/VirtioDevice.h>
-
-#include <IndustryStandard/Virtio.h>
-
-#include <Library/DebugLib.h>
-#include <Library/IoLib.h>
-#include <Library/UefiLib.h>
-#include <Library/VirtioMmioDeviceLib.h>
-
-#define VIRTIO_MMIO_DEVICE_SIGNATURE SIGNATURE_32 ('V', 'M', 'I', 'O')
-
-typedef struct {
- UINT32 Signature;
- VIRTIO_DEVICE_PROTOCOL VirtioDevice;
- PHYSICAL_ADDRESS BaseAddress;
-} VIRTIO_MMIO_DEVICE;
-
-#define VIRTIO_MMIO_DEVICE_FROM_VIRTIO_DEVICE(Device) \
- CR (Device, VIRTIO_MMIO_DEVICE, VirtioDevice, VIRTIO_MMIO_DEVICE_SIGNATURE)
-
-#define VIRTIO_CFG_WRITE(Device, Offset, Val) \
- (MmioWrite32 (Device->BaseAddress + (Offset), Val))
-#define VIRTIO_CFG_READ(Device, Offset) \
- (MmioRead32 (Device->BaseAddress + (Offset)))
-
-EFI_STATUS
-EFIAPI
-VirtioMmioDeviceRead (
- IN VIRTIO_DEVICE_PROTOCOL *This,
- IN UINTN FieldOFfset,
- IN UINTN FieldSize,
- IN UINTN BufferSize,
- OUT VOID* Buffer
- );
-
-EFI_STATUS
-EFIAPI
-VirtioMmioDeviceWrite (
- IN VIRTIO_DEVICE_PROTOCOL *This,
- IN UINTN FieldOffset,
- IN UINTN FieldSize,
- IN UINT64 Value
- );
-
-EFI_STATUS
-EFIAPI
-VirtioMmioGetDeviceFeatures (
- IN VIRTIO_DEVICE_PROTOCOL *This,
- OUT UINT32 *DeviceFeatures
- );
-
-EFI_STATUS
-EFIAPI
-VirtioMmioGetQueueAddress (
- IN VIRTIO_DEVICE_PROTOCOL *This,
- OUT UINT32 *QueueAddress
- );
-
-EFI_STATUS
-EFIAPI
-VirtioMmioGetQueueSize (
- IN VIRTIO_DEVICE_PROTOCOL *This,
- OUT UINT16 *QueueNumMax
- );
-
-EFI_STATUS
-EFIAPI
-VirtioMmioGetDeviceStatus (
- IN VIRTIO_DEVICE_PROTOCOL *This,
- OUT UINT8 *DeviceStatus
- );
-
-EFI_STATUS
-EFIAPI
-VirtioMmioSetQueueSize (
- VIRTIO_DEVICE_PROTOCOL *This,
- UINT16 QueueSize
- );
-
-EFI_STATUS
-EFIAPI
-VirtioMmioSetDeviceStatus (
- VIRTIO_DEVICE_PROTOCOL *This,
- UINT8 DeviceStatus
- );
-
-EFI_STATUS
-EFIAPI
-VirtioMmioSetQueueNotify (
- VIRTIO_DEVICE_PROTOCOL *This,
- UINT16 QueueNotify
- );
-
-EFI_STATUS
-EFIAPI
-VirtioMmioSetQueueSel (
- VIRTIO_DEVICE_PROTOCOL *This,
- UINT16 Sel
- );
-
-EFI_STATUS
-VirtioMmioSetQueueAddress (
- VIRTIO_DEVICE_PROTOCOL *This,
- UINT32 Address
- );
-
-EFI_STATUS
-EFIAPI
-VirtioMmioSetQueueAlignment (
- VIRTIO_DEVICE_PROTOCOL *This,
- UINT32 Alignment
- );
-
-EFI_STATUS
-EFIAPI
-VirtioMmioSetPageSize (
- VIRTIO_DEVICE_PROTOCOL *This,
- UINT32 PageSize
- );
-
-EFI_STATUS
-EFIAPI
-VirtioMmioSetGuestFeatures (
- VIRTIO_DEVICE_PROTOCOL *This,
- UINT32 Features
- );
-
-#endif // _VIRTIO_MMIO_DEVICE_INTERNAL_H_
diff --git a/OvmfPkg/Library/VirtioMmioDeviceLib/VirtioMmioDeviceFunctions.c b/OvmfPkg/Library/VirtioMmioDeviceLib/VirtioMmioDeviceFunctions.c
deleted file mode 100644
index 3950c07f7f..0000000000
--- a/OvmfPkg/Library/VirtioMmioDeviceLib/VirtioMmioDeviceFunctions.c
+++ /dev/null
@@ -1,310 +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.<BR>
- Copyright (C) 2013, ARM Ltd.
-
- This program and the accompanying materials are licensed and made available
- under the terms and conditions of the BSD License which accompanies this
- distribution. The full text of the license may be found at
- http://opensource.org/licenses/bsd-license.php
-
- THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, WITHOUT
- WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
-
-**/
-
-#include "VirtioMmioDevice.h"
-
-EFI_STATUS
-EFIAPI
-VirtioMmioGetDeviceFeatures (
- IN VIRTIO_DEVICE_PROTOCOL *This,
- OUT UINT32 *DeviceFeatures
- )
-{
- VIRTIO_MMIO_DEVICE *Device;
-
- if (DeviceFeatures == NULL) {
- return EFI_INVALID_PARAMETER;
- }
-
- Device = VIRTIO_MMIO_DEVICE_FROM_VIRTIO_DEVICE (This);
-
- *DeviceFeatures = VIRTIO_CFG_READ (Device, VIRTIO_MMIO_OFFSET_HOST_FEATURES);
-
- return EFI_SUCCESS;
-}
-
-EFI_STATUS
-EFIAPI
-VirtioMmioGetQueueAddress (
- IN VIRTIO_DEVICE_PROTOCOL *This,
- OUT UINT32 *QueueAddress
- )
-{
- VIRTIO_MMIO_DEVICE *Device;
-
- if (QueueAddress == NULL) {
- return EFI_INVALID_PARAMETER;
- }
-
- Device = VIRTIO_MMIO_DEVICE_FROM_VIRTIO_DEVICE (This);
-
- *QueueAddress = VIRTIO_CFG_READ (Device, VIRTIO_MMIO_OFFSET_QUEUE_PFN);
-
- return EFI_SUCCESS;
-}
-
-EFI_STATUS
-EFIAPI
-VirtioMmioGetQueueSize (
- IN VIRTIO_DEVICE_PROTOCOL *This,
- OUT UINT16 *QueueNumMax
- )
-{
- VIRTIO_MMIO_DEVICE *Device;
-
- if (QueueNumMax == NULL) {
- return EFI_INVALID_PARAMETER;
- }
-
- Device = VIRTIO_MMIO_DEVICE_FROM_VIRTIO_DEVICE (This);
-
- *QueueNumMax = VIRTIO_CFG_READ (Device, VIRTIO_MMIO_OFFSET_QUEUE_NUM_MAX) & 0xFFFF;
-
- return EFI_SUCCESS;
-}
-
-EFI_STATUS
-EFIAPI
-VirtioMmioGetDeviceStatus (
- IN VIRTIO_DEVICE_PROTOCOL *This,
- OUT UINT8 *DeviceStatus
- )
-{
- VIRTIO_MMIO_DEVICE *Device;
-
- if (DeviceStatus == NULL) {
- return EFI_INVALID_PARAMETER;
- }
-
- Device = VIRTIO_MMIO_DEVICE_FROM_VIRTIO_DEVICE (This);
-
- *DeviceStatus = VIRTIO_CFG_READ (Device, VIRTIO_MMIO_OFFSET_STATUS) & 0xFF;
-
- return EFI_SUCCESS;
-}
-
-EFI_STATUS
-EFIAPI
-VirtioMmioSetQueueSize (
- VIRTIO_DEVICE_PROTOCOL *This,
- UINT16 QueueSize
- )
-{
- VIRTIO_MMIO_DEVICE *Device;
-
- Device = VIRTIO_MMIO_DEVICE_FROM_VIRTIO_DEVICE (This);
-
- 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 (
- VIRTIO_DEVICE_PROTOCOL *This,
- UINT32 Address
- )
-{
- VIRTIO_MMIO_DEVICE *Device;
-
- Device = VIRTIO_MMIO_DEVICE_FROM_VIRTIO_DEVICE (This);
-
- VIRTIO_CFG_WRITE (Device, VIRTIO_MMIO_OFFSET_QUEUE_PFN, Address);
-
- return EFI_SUCCESS;
-}
-
-EFI_STATUS
-EFIAPI
-VirtioMmioSetGuestFeatures (
- VIRTIO_DEVICE_PROTOCOL *This,
- UINT32 Features
- )
-{
- VIRTIO_MMIO_DEVICE *Device;
-
- Device = VIRTIO_MMIO_DEVICE_FROM_VIRTIO_DEVICE (This);
-
- VIRTIO_CFG_WRITE (Device, VIRTIO_MMIO_OFFSET_GUEST_FEATURES, Features);
-
- return EFI_SUCCESS;
-}
-
-EFI_STATUS
-EFIAPI
-VirtioMmioDeviceWrite (
- IN VIRTIO_DEVICE_PROTOCOL *This,
- IN UINTN FieldOffset,
- IN UINTN FieldSize,
- IN UINT64 Value
- )
-{
- UINTN DstBaseAddress;
- VIRTIO_MMIO_DEVICE *Device;
-
- Device = VIRTIO_MMIO_DEVICE_FROM_VIRTIO_DEVICE (This);
-
- //
- // Double-check fieldsize
- //
- if ((FieldSize != 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 2956963124..0000000000
--- a/OvmfPkg/Library/XenConsoleSerialPortLib/XenConsoleSerialPortLib.c
+++ /dev/null
@@ -1,302 +0,0 @@
-/** @file
- Xen console SerialPortLib instance
-
- Copyright (c) 2015, Linaro Ltd. All rights reserved.<BR>
- Copyright (c) 2015, Intel Corporation. All rights reserved.<BR>
-
- This program and the accompanying materials
- are licensed and made available under the terms and conditions of the BSD License
- which accompanies this distribution. The full text of the license may be found at
- http://opensource.org/licenses/bsd-license.php
-
- 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 <Base.h>
-#include <Uefi/UefiBaseType.h>
-
-#include <Library/BaseLib.h>
-#include <Library/SerialPortLib.h>
-#include <Library/XenHypercallLib.h>
-
-#include <IndustryStandard/Xen/io/console.h>
-#include <IndustryStandard/Xen/hvm/params.h>
-#include <IndustryStandard/Xen/event_channel.h>
-
-//
-// 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.<BR>
-#
-# This program and the accompanying materials
-# are licensed and made available under the terms and conditions of the BSD License
-# which accompanies this distribution. The full text of the license may be found at
-# http://opensource.org/licenses/bsd-license.php
-#
-# 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 <IndustryStandard/Xen/arch-arm/xen.h>
-
- .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 b38e1a8f18..0000000000
--- a/OvmfPkg/Library/XenHypercallLib/Arm/Hypercall.S
+++ /dev/null
@@ -1,25 +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 <IndustryStandard/Xen/arch-arm/xen.h>
-
- .text
- .global ASM_PFX(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.<BR>
-
- This program and the accompanying materials are licensed and made available
- under the terms and conditions of the BSD License that accompanies this
- distribution. The full text of the license may be found at
- http://opensource.org/licenses/bsd-license.php.
-
- THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, WITHOUT
- WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
-**/
-
-#include <Base.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
- )
-{
- 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.<BR>
-This program and the accompanying materials are licensed and made available under
-the terms and conditions of the BSD License that accompanies this distribution.
-The full text of the license may be found at
-http://opensource.org/licenses/bsd-license.php.
-
-THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
-WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
-
-**/
-
-#include <PiDxe.h>
-#include <Library/HobLib.h>
-#include <Library/DebugLib.h>
-#include <Guid/XenInfo.h>
-
-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 82cdbd9bdb..0000000000
--- a/OvmfPkg/Library/XenHypercallLib/XenHypercall.c
+++ /dev/null
@@ -1,63 +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 <PiDxe.h>
-
-#include <IndustryStandard/Xen/hvm/params.h>
-#include <IndustryStandard/Xen/memory.h>
-
-#include <Library/DebugLib.h>
-#include <Library/XenHypercallLib.h>
-
-UINT64
-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
-XenHypercallMemoryOp (
- IN UINTN Operation,
- IN OUT VOID *Arguments
- )
-{
- return XenHypercall2 (__HYPERVISOR_memory_op,
- Operation, (INTN) Arguments);
-}
-
-INTN
-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.<BR>
-# This program and the accompanying materials
-# are licensed and made available under the terms and conditions of the BSD License
-# which accompanies this distribution. The full text of the license may be found at
-# http://opensource.org/licenses/bsd-license.php
-#
-# 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.<BR>
-*
-* This program and the accompanying materials are
-* licensed and made available under the terms and conditions of the BSD License
-* which accompanies this distribution. The full text of the license may be found at
-* http://opensource.org/licenses/bsd-license.php
-*
-* THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
-* WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
-*
-**/
-
-#include <Library/BaseLib.h>
-#include <Library/UefiBootServicesTableLib.h>
-#include <Library/DebugLib.h>
-#include <Library/UefiLib.h>
-#include <Library/BaseMemoryLib.h>
-#include <Library/MemoryAllocationLib.h>
-#include <Library/DevicePathLib.h>
-#include <Library/XenIoMmioLib.h>
-
-#include <Protocol/XenIo.h>
-#include <Guid/XenBusRootDevice.h>
-
-#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 16cc453035..0000000000
--- a/OvmfPkg/Library/XenIoMmioLib/XenIoMmioLib.inf
+++ /dev/null
@@ -1,39 +0,0 @@
-## @file
-# Manage XenBus device path and I/O handles
-#
-# Copyright (c) 2015, Linaro Ltd. All rights reserved.<BR>
-#
-# This program and the accompanying materials
-# are licensed and made available under the terms and conditions of the BSD License
-# which accompanies this distribution. The full text of the license may be found at
-# http://opensource.org/licenses/bsd-license.php.
-# THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
-# WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
-#
-#
-##
-
-[Defines]
- INF_VERSION = 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
-
-[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 049f6edd05..0000000000
--- a/OvmfPkg/OvmfPkg.dec
+++ /dev/null
@@ -1,119 +0,0 @@
-## @file
-# EFI/Framework Open Virtual Machine Firmware (OVMF) platform
-#
-# Copyright (c) 2006 - 2013, Intel Corporation. All rights reserved.<BR>
-#
-# This program and the accompanying materials
-# are licensed and made available under the terms and conditions of the BSD License
-# which accompanies this distribution. The full text of the license may be found at
-# http://opensource.org/licenses/bsd-license.php
-#
-# THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
-# WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
-#
-##
-
-[Defines]
- 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 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}}
-
-[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
-
- ## This flag determines the Power Management Base Address of choice, written
- # to PIIX4 function 3 offset 0x40-0x43 bits [15:6].
- gUefiOvmfPkgTokenSpaceGuid.PcdAcpiPmBaseAddress|0xB000|UINT16|5
-
- ## When VirtioScsiDxe is instantiated for a HBA, the numbers of targets and
- # LUNs are retrieved from the host during virtio-scsi setup.
- # MdeModulePkg/Bus/Scsi/ScsiBusDxe then scans all MaxTarget * MaxLun
- # possible devices. This can take extremely long, for example with
- # MaxTarget=255 and MaxLun=16383. The *inclusive* constants below limit
- # MaxTarget and MaxLun, independently, should the host report higher values,
- # so that scanning the number of devices given by their product is still
- # acceptably fast.
- gUefiOvmfPkgTokenSpaceGuid.PcdVirtioScsiMaxTargetLimit|31|UINT16|6
- gUefiOvmfPkgTokenSpaceGuid.PcdVirtioScsiMaxLunLimit|7|UINT32|7
-
-[PcdsFixedAtBuild]
- 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.PcdS3AcpiReservedMemoryBase|0x0|UINT32|0x17
- gUefiOvmfPkgTokenSpaceGuid.PcdOvmfLockBoxStorageBase|0x0|UINT32|0x18
- gUefiOvmfPkgTokenSpaceGuid.PcdOvmfLockBoxStorageSize|0x0|UINT32|0x19
- gUefiOvmfPkgTokenSpaceGuid.PcdGuidedExtractHandlerTableSize|0x0|UINT32|0x1a
-
-[PcdsDynamic, PcdsDynamicEx]
- gUefiOvmfPkgTokenSpaceGuid.PcdEmuVariableEvent|0|UINT64|2
- gUefiOvmfPkgTokenSpaceGuid.PcdOvmfFlashVariablesEnable|FALSE|BOOLEAN|0x10
- gUefiOvmfPkgTokenSpaceGuid.PcdOvmfHostBridgePciDevId|0|UINT16|0x1b
- gUefiOvmfPkgTokenSpaceGuid.PcdQemuSmbiosValidated|FALSE|BOOLEAN|0x21
-
-[PcdsFeatureFlag]
- gUefiOvmfPkgTokenSpaceGuid.PcdSecureBootEnable|FALSE|BOOLEAN|3
- gUefiOvmfPkgTokenSpaceGuid.PcdQemuBootOrderPciTranslation|TRUE|BOOLEAN|0x1c
- gUefiOvmfPkgTokenSpaceGuid.PcdQemuBootOrderMmioTranslation|FALSE|BOOLEAN|0x1d
diff --git a/OvmfPkg/OvmfPkg.fdf.inc b/OvmfPkg/OvmfPkg.fdf.inc
deleted file mode 100644
index 486bbc61ea..0000000000
--- a/OvmfPkg/OvmfPkg.fdf.inc
+++ /dev/null
@@ -1,62 +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.<BR>
-#
-# This program and the accompanying materials are licensed and made available
-# under the terms and conditions of the BSD License which accompanies this
-# distribution. The full text of the license may be found at
-# http://opensource.org/licenses/bsd-license.php
-#
-# THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
-# WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR
-# IMPLIED.
-#
-##
-
-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
diff --git a/OvmfPkg/OvmfPkgIa32.dsc b/OvmfPkg/OvmfPkgIa32.dsc
deleted file mode 100644
index 5741eac330..0000000000
--- a/OvmfPkg/OvmfPkgIa32.dsc
+++ /dev/null
@@ -1,620 +0,0 @@
-## @file
-# EFI/Framework Open Virtual Machine Firmware (OVMF) platform
-#
-# Copyright (c) 2006 - 2015, Intel Corporation. All rights reserved.<BR>
-#
-# This program and the accompanying materials
-# are licensed and made available under the terms and conditions of the BSD License
-# which accompanies this distribution. The full text of the license may be found at
-# http://opensource.org/licenses/bsd-license.php
-#
-# 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 = 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
-
-[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
-
-################################################################################
-#
-# 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
- GenericBdsLib|IntelFrameworkModulePkg/Library/GenericBdsLib/GenericBdsLib.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
- PciLib|MdePkg/Library/BasePciLibCf8/BasePciLibCf8.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
- LockBoxLib|OvmfPkg/Library/LockBoxLib/LockBoxBaseLib.inf
- CustomizedDisplayLib|MdeModulePkg/Library/CustomizedDisplayLib/CustomizedDisplayLib.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/BaseXApicLib/BaseXApicLib.inf
- DebugPrintErrorLevelLib|MdePkg/Library/BaseDebugPrintErrorLevelLib/BaseDebugPrintErrorLevelLib.inf
-
-!if $(SECURE_BOOT_ENABLE) == TRUE
- PlatformSecureLib|OvmfPkg/Library/PlatformSecureLib/PlatformSecureLib.inf
- IntrinsicLib|CryptoPkg/Library/IntrinsicLib/IntrinsicLib.inf
- OpensslLib|CryptoPkg/Library/OpensslLib/OpensslLib.inf
- TpmMeasurementLib|SecurityPkg/Library/DxeTpmMeasurementLib/DxeTpmMeasurementLib.inf
- AuthVariableLib|SecurityPkg/Library/AuthVariableLib/AuthVariableLib.inf
-!if $(NETWORK_IP6_ENABLE) == TRUE
- TcpIoLib|MdeModulePkg/Library/DxeTcpIoLib/DxeTcpIoLib.inf
-!endif
-!else
- TpmMeasurementLib|MdeModulePkg/Library/TpmMeasurementLibNull/TpmMeasurementLibNull.inf
- AuthVariableLib|MdeModulePkg/Library/AuthVariableLibNull/AuthVariableLibNull.inf
-!endif
- VarCheckLib|MdeModulePkg/Library/VarCheckLib/VarCheckLib.inf
-
-!if $(HTTP_BOOT_ENABLE) == TRUE
- HttpLib|MdeModulePkg/Library/DxeHttpLib/DxeHttpLib.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]
-!if $(SECURE_BOOT_ENABLE) == TRUE
- BaseCryptLib|CryptoPkg/Library/BaseCryptLib/BaseCryptLib.inf
-!endif
-
-[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
-
-[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
-
-[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
-!if $(SECURE_BOOT_ENABLE) == TRUE
- BaseCryptLib|CryptoPkg/Library/BaseCryptLib/RuntimeCryptLib.inf
-!endif
-
-[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
-
-[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
- PlatformBdsLib|OvmfPkg/Library/PlatformBdsLib/PlatformBdsLib.inf
- CpuExceptionHandlerLib|UefiCpuPkg/Library/CpuExceptionHandlerLib/DxeCpuExceptionHandlerLib.inf
- LockBoxLib|OvmfPkg/Library/LockBoxLib/LockBoxDxeLib.inf
-!ifdef $(SOURCE_DEBUG_ENABLE)
- DebugAgentLib|SourceLevelDebugPkg/Library/DebugAgent/DxeDebugAgentLib.inf
-!endif
- QemuBootOrderLib|OvmfPkg/Library/QemuBootOrderLib/QemuBootOrderLib.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
-!ifdef $(DEBUG_ON_SERIAL_PORT)
- DebugLib|MdePkg/Library/BaseDebugLibSerialPort/BaseDebugLibSerialPort.inf
-!else
- DebugLib|OvmfPkg/Library/PlatformDebugLibIoPort/PlatformDebugLibIoPort.inf
-!endif
-
-[LibraryClasses.common.DXE_SMM_DRIVER]
- PcdLib|MdePkg/Library/DxePcdLib/DxePcdLib.inf
- TimerLib|OvmfPkg/Library/AcpiTimerLib/DxeAcpiTimerLib.inf
-
-[LibraryClasses.common.SMM_CORE]
- PcdLib|MdePkg/Library/DxePcdLib/DxePcdLib.inf
- TimerLib|OvmfPkg/Library/AcpiTimerLib/DxeAcpiTimerLib.inf
-
-################################################################################
-#
-# Pcd Section - list of all EDK II PCD Entries defined by this Platform.
-#
-################################################################################
-[PcdsFeatureFlag]
- gEfiMdeModulePkgTokenSpaceGuid.PcdStatusCodeUseSerial|FALSE
- gEfiMdeModulePkgTokenSpaceGuid.PcdStatusCodeUseMemory|TRUE
- gEfiMdeModulePkgTokenSpaceGuid.PcdDxeIplSupportUefiDecompress|FALSE
- gEfiMdeModulePkgTokenSpaceGuid.PcdDxeIplSwitchToLongMode|FALSE
- gEfiMdeModulePkgTokenSpaceGuid.PcdConOutGopSupport|TRUE
- gEfiMdeModulePkgTokenSpaceGuid.PcdConOutUgaSupport|FALSE
-!if $(SECURE_BOOT_ENABLE) == TRUE
- gUefiOvmfPkgTokenSpaceGuid.PcdSecureBootEnable|TRUE
-!endif
-
-[PcdsFixedAtBuild]
- gEfiMdeModulePkgTokenSpaceGuid.PcdStatusCodeMemorySize|1
- gEfiMdeModulePkgTokenSpaceGuid.PcdResetOnMemoryTypeInformationChange|FALSE
- gEfiMdePkgTokenSpaceGuid.PcdMaximumGuidedExtractHandler|0x10
- gEfiMdeModulePkgTokenSpaceGuid.PcdPeiCoreMaxFvSupported|6
- gEfiMdeModulePkgTokenSpaceGuid.PcdPeiCoreMaxPeimPerFv|32
- gEfiMdeModulePkgTokenSpaceGuid.PcdMaxVariableSize|0x2000
- gEfiMdeModulePkgTokenSpaceGuid.PcdMaxHardwareErrorVariableSize|0x8000
- gEfiMdeModulePkgTokenSpaceGuid.PcdVariableStoreSize|0xe000
-
- gEfiMdeModulePkgTokenSpaceGuid.PcdVpdBaseAddress|0x0
-
- gEfiMdePkgTokenSpaceGuid.PcdReportStatusCodePropertyMask|0x07
- gEfiMdePkgTokenSpaceGuid.PcdDebugPrintErrorLevel|0x8000004F
-!ifdef $(SOURCE_DEBUG_ENABLE)
- gEfiMdePkgTokenSpaceGuid.PcdDebugPropertyMask|0x17
-!else
- gEfiMdePkgTokenSpaceGuid.PcdDebugPropertyMask|0x2F
-!endif
-
-!ifdef $(SOURCE_DEBUG_ENABLE)
- gEfiSourceLevelDebugPkgTokenSpaceGuid.PcdDebugLoadImageMethod|0x2
-!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 $(SECURE_BOOT_ENABLE) == TRUE
- # override the default values from SecurityPkg to ensure images from all sources are verified in secure boot
- gEfiSecurityPkgTokenSpaceGuid.PcdOptionRomImageVerificationPolicy|0x04
- gEfiSecurityPkgTokenSpaceGuid.PcdFixedMediaImageVerificationPolicy|0x04
- gEfiSecurityPkgTokenSpaceGuid.PcdRemovableMediaImageVerificationPolicy|0x04
-!endif
-
- # IRQs 5, 9, 10, 11 are level-triggered
- gPcAtChipsetPkgTokenSpaceGuid.Pcd8259LegacyModeEdgeLevel|0x0E20
-
-################################################################################
-#
-# 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
- gUefiOvmfPkgTokenSpaceGuid.PcdOvmfHostBridgePciDevId|0
-
- gEfiMdePkgTokenSpaceGuid.PcdPlatformBootTimeOut|0
-
- # Set video resolution for text setup.
- gEfiMdeModulePkgTokenSpaceGuid.PcdSetupVideoHorizontalResolution|640
- gEfiMdeModulePkgTokenSpaceGuid.PcdSetupVideoVerticalResolution|480
-
- gEfiMdeModulePkgTokenSpaceGuid.PcdSmbiosVersion|0x0208
- gEfiMdeModulePkgTokenSpaceGuid.PcdSmbiosDocRev|0x0
- gUefiOvmfPkgTokenSpaceGuid.PcdQemuSmbiosValidated|FALSE
-
-################################################################################
-#
-# Components Section - list of all EDK II Modules needed by this Platform.
-#
-################################################################################
-[Components]
- OvmfPkg/ResetVector/ResetVector.inf
-
- #
- # SEC Phase modules
- #
- OvmfPkg/Sec/SecMain.inf {
- <LibraryClasses>
- NULL|IntelFrameworkModulePkg/Library/LzmaCustomDecompressLib/LzmaCustomDecompressLib.inf
- }
-
- #
- # PEI Phase modules
- #
- MdeModulePkg/Core/Pei/PeiMain.inf
- MdeModulePkg/Universal/PCD/Pei/Pcd.inf {
- <LibraryClasses>
- PcdLib|MdePkg/Library/BasePcdLibNull/BasePcdLibNull.inf
- }
- IntelFrameworkModulePkg/Universal/StatusCode/Pei/StatusCodePei.inf
- MdeModulePkg/Core/DxeIplPeim/DxeIpl.inf
-
- OvmfPkg/PlatformPei/PlatformPei.inf {
- <LibraryClasses>
- PcdLib|MdePkg/Library/PeiPcdLib/PeiPcdLib.inf
- }
- UefiCpuPkg/Universal/Acpi/S3Resume2Pei/S3Resume2Pei.inf {
- <LibraryClasses>
- PcdLib|MdePkg/Library/PeiPcdLib/PeiPcdLib.inf
- }
-
- #
- # DXE Phase modules
- #
- MdeModulePkg/Core/Dxe/DxeMain.inf {
- <LibraryClasses>
- NULL|IntelFrameworkModulePkg/Library/LzmaCustomDecompressLib/LzmaCustomDecompressLib.inf
- DevicePathLib|MdePkg/Library/UefiDevicePathLib/UefiDevicePathLib.inf
- }
-
- IntelFrameworkModulePkg/Universal/StatusCode/RuntimeDxe/StatusCodeRuntimeDxe.inf
- MdeModulePkg/Universal/PCD/Dxe/Pcd.inf {
- <LibraryClasses>
- PcdLib|MdePkg/Library/BasePcdLibNull/BasePcdLibNull.inf
- }
-
- MdeModulePkg/Core/RuntimeDxe/RuntimeDxe.inf
-
-!if $(SECURE_BOOT_ENABLE) == TRUE
- MdeModulePkg/Universal/SecurityStubDxe/SecurityStubDxe.inf {
- <LibraryClasses>
- 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/PciHostBridgeDxe/PciHostBridgeDxe.inf
- MdeModulePkg/Bus/Pci/PciBusDxe/PciBusDxe.inf {
- <LibraryClasses>
- PcdLib|MdePkg/Library/DxePcdLib/DxePcdLib.inf
- }
- PcAtChipsetPkg/KbcResetDxe/Reset.inf
- MdeModulePkg/Universal/Metronome/Metronome.inf
- PcAtChipsetPkg/PcatRealTimeClockRuntimeDxe/PcatRealTimeClockRuntimeDxe.inf
- IntelFrameworkModulePkg/Universal/BdsDxe/BdsDxe.inf {
- <LibraryClasses>
-!ifdef $(CSM_ENABLE)
- NULL|OvmfPkg/Csm/CsmSupportLib/CsmSupportLib.inf
-!endif
- }
-
- OvmfPkg/BlockMmioToBlockIoDxe/BlockIo.inf
- OvmfPkg/VirtioPciDeviceDxe/VirtioPciDeviceDxe.inf
- OvmfPkg/VirtioBlkDxe/VirtioBlk.inf
- OvmfPkg/VirtioScsiDxe/VirtioScsi.inf
- OvmfPkg/QemuFlashFvbServicesRuntimeDxe/FvbServicesRuntimeDxe.inf
- OvmfPkg/XenIoPciDxe/XenIoPciDxe.inf
- OvmfPkg/XenBusDxe/XenBusDxe.inf
- OvmfPkg/XenPvBlkDxe/XenPvBlkDxe.inf
- OvmfPkg/EmuVariableFvbRuntimeDxe/Fvb.inf {
- <LibraryClasses>
- PlatformFvbLib|OvmfPkg/Library/EmuVariableFvbLib/EmuVariableFvbLib.inf
- }
- MdeModulePkg/Universal/FaultTolerantWriteDxe/FaultTolerantWriteDxe.inf
- MdeModulePkg/Universal/Variable/RuntimeDxe/VariableRuntimeDxe.inf {
- <LibraryClasses>
- NULL|MdeModulePkg/Library/VarCheckUefiLib/VarCheckUefiLib.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 {
- <LibraryClasses>
- PcdLib|MdePkg/Library/DxePcdLib/DxePcdLib.inf
- }
- MdeModulePkg/Universal/Console/TerminalDxe/TerminalDxe.inf
- MdeModulePkg/Universal/DevicePathDxe/DevicePathDxe.inf {
- <LibraryClasses>
- 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/UnicodeCollation/EnglishDxe/EnglishDxe.inf
- MdeModulePkg/Bus/Scsi/ScsiBusDxe/ScsiBusDxe.inf
- MdeModulePkg/Bus/Scsi/ScsiDiskDxe/ScsiDiskDxe.inf
- IntelFrameworkModulePkg/Bus/Pci/IdeBusDxe/IdeBusDxe.inf
- PcAtChipsetPkg/Bus/Pci/IdeControllerDxe/IdeControllerDxe.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 {
- <LibraryClasses>
- BltLib|OptionRomPkg/Library/FrameBufferBltLib/FrameBufferBltLib.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 {
- <LibraryClasses>
- 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
- OvmfPkg/AcpiS3SaveDxe/AcpiS3SaveDxe.inf
- MdeModulePkg/Universal/Acpi/S3SaveStateDxe/S3SaveStateDxe.inf
- MdeModulePkg/Universal/Acpi/BootScriptExecutorDxe/BootScriptExecutorDxe.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
-!if $(SECURE_BOOT_ENABLE) == TRUE
- NetworkPkg/IScsiDxe/IScsiDxe.inf
-!else
- MdeModulePkg/Universal/Network/IScsiDxe/IScsiDxe.inf
-!endif
-!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/HttpDxe/HttpDxe.inf
- NetworkPkg/HttpBootDxe/HttpBootDxe.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 {
- <LibraryClasses>
- 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 {
- <LibraryClasses>
- 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
- HandleParsingLib|ShellPkg/Library/UefiHandleParsingLib/UefiHandleParsingLib.inf
- ShellLib|ShellPkg/Library/UefiShellLib/UefiShellLib.inf
- FileHandleLib|MdePkg/Library/UefiFileHandleLib/UefiFileHandleLib.inf
- SortLib|MdeModulePkg/Library/UefiSortLib/UefiSortLib.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
-
- <PcdsFixedAtBuild>
- 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
diff --git a/OvmfPkg/OvmfPkgIa32.fdf b/OvmfPkg/OvmfPkgIa32.fdf
deleted file mode 100644
index 0e4ee49602..0000000000
--- a/OvmfPkg/OvmfPkgIa32.fdf
+++ /dev/null
@@ -1,476 +0,0 @@
-## @file
-# Open Virtual Machine Firmware: FDF
-#
-# Copyright (c) 2006 - 2015, Intel Corporation. All rights reserved.<BR>
-#
-# This program and the accompanying materials
-# are licensed and made available under the terms and conditions of the BSD License
-# which accompanies this distribution. The full text of the license may be found at
-# http://opensource.org/licenses/bsd-license.php
-#
-# 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 for DEBUG build is 2MB. For RELEASE it is 1MB.
-#
-# Defining FD_SIZE_1MB or FD_SIZE_2MB on the build command line can
-# override this.
-#
-[Defines]
-!if $(TARGET) == RELEASE
-!ifndef $(FD_SIZE_2MB)
-DEFINE FD_SIZE_1MB=
-!endif
-!endif
-
-!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 = 0x800000
-Size = 0x900000
-ErasePolarity = 1
-BlockSize = 0x10000
-NumBlocks = 0x90
-
-0x000000|0x006000
-gUefiOvmfPkgTokenSpaceGuid.PcdOvmfSecPageTablesBase|gUefiOvmfPkgTokenSpaceGuid.PcdOvmfSecPageTablesSize
-
-0x006000|0x001000
-gUefiOvmfPkgTokenSpaceGuid.PcdOvmfLockBoxStorageBase|gUefiOvmfPkgTokenSpaceGuid.PcdOvmfLockBoxStorageSize
-
-0x007000|0x001000
-gEfiMdePkgTokenSpaceGuid.PcdGuidedExtractHandlerTableAddress|gUefiOvmfPkgTokenSpaceGuid.PcdGuidedExtractHandlerTableSize
-
-0x010000|0x008000
-gUefiOvmfPkgTokenSpaceGuid.PcdOvmfSecPeiTempRamBase|gUefiOvmfPkgTokenSpaceGuid.PcdOvmfSecPeiTempRamSize
-
-0x018000|0x008000
-gUefiOvmfPkgTokenSpaceGuid.PcdS3AcpiReservedMemoryBase|gEfiIntelFrameworkModulePkgTokenSpaceGuid.PcdS3AcpiReservedMemorySize
-
-0x020000|0x0E0000
-gUefiOvmfPkgTokenSpaceGuid.PcdOvmfPeiMemFvBase|gUefiOvmfPkgTokenSpaceGuid.PcdOvmfPeiMemFvSize
-FV = PEIFV
-
-0x100000|0x800000
-gUefiOvmfPkgTokenSpaceGuid.PcdOvmfDxeMemFvBase|gUefiOvmfPkgTokenSpaceGuid.PcdOvmfDxeMemFvSize
-FV = DXEFV
-
-################################################################################
-
-[FV.SECFV]
-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]
-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 IntelFrameworkModulePkg/Universal/StatusCode/Pei/StatusCodePei.inf
-INF OvmfPkg/PlatformPei/PlatformPei.inf
-INF MdeModulePkg/Core/DxeIplPeim/DxeIpl.inf
-INF UefiCpuPkg/Universal/Acpi/S3Resume2Pei/S3Resume2Pei.inf
-
-################################################################################
-
-[FV.DXEFV]
-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
- INF OvmfPkg/QemuFlashFvbServicesRuntimeDxe/FvbServicesRuntimeDxe.inf
-}
-
-#
-# DXE Phase modules
-#
-INF MdeModulePkg/Core/Dxe/DxeMain.inf
-
-INF IntelFrameworkModulePkg/Universal/StatusCode/RuntimeDxe/StatusCodeRuntimeDxe.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/PciHostBridgeDxe/PciHostBridgeDxe.inf
-INF MdeModulePkg/Bus/Pci/PciBusDxe/PciBusDxe.inf
-INF PcAtChipsetPkg/KbcResetDxe/Reset.inf
-INF MdeModulePkg/Universal/Metronome/Metronome.inf
-INF PcAtChipsetPkg/PcatRealTimeClockRuntimeDxe/PcatRealTimeClockRuntimeDxe.inf
-
-INF OvmfPkg/BlockMmioToBlockIoDxe/BlockIo.inf
-INF OvmfPkg/VirtioPciDeviceDxe/VirtioPciDeviceDxe.inf
-INF OvmfPkg/VirtioBlkDxe/VirtioBlk.inf
-INF OvmfPkg/VirtioScsiDxe/VirtioScsi.inf
-INF OvmfPkg/QemuFlashFvbServicesRuntimeDxe/FvbServicesRuntimeDxe.inf
-INF OvmfPkg/EmuVariableFvbRuntimeDxe/Fvb.inf
-INF MdeModulePkg/Universal/FaultTolerantWriteDxe/FaultTolerantWriteDxe.inf
-INF OvmfPkg/XenIoPciDxe/XenIoPciDxe.inf
-INF OvmfPkg/XenBusDxe/XenBusDxe.inf
-INF OvmfPkg/XenPvBlkDxe/XenPvBlkDxe.inf
-
-INF MdeModulePkg/Universal/Variable/RuntimeDxe/VariableRuntimeDxe.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 IntelFrameworkModulePkg/Universal/BdsDxe/BdsDxe.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/UnicodeCollation/EnglishDxe/EnglishDxe.inf
-INF MdeModulePkg/Bus/Scsi/ScsiBusDxe/ScsiBusDxe.inf
-INF MdeModulePkg/Bus/Scsi/ScsiDiskDxe/ScsiDiskDxe.inf
-INF IntelFrameworkModulePkg/Bus/Pci/IdeBusDxe/IdeBusDxe.inf
-INF PcAtChipsetPkg/Bus/Pci/IdeControllerDxe/IdeControllerDxe.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 OvmfPkg/AcpiS3SaveDxe/AcpiS3SaveDxe.inf
-INF MdeModulePkg/Universal/Acpi/S3SaveStateDxe/S3SaveStateDxe.inf
-INF MdeModulePkg/Universal/Acpi/BootScriptExecutorDxe/BootScriptExecutorDxe.inf
-
-INF RuleOverride = BINARY FatBinPkg/EnhancedFatDxe/Fat.inf
-
-!ifndef $(USE_OLD_SHELL)
-INF ShellPkg/Application/Shell/Shell.inf
-!else
-INF RuleOverride = BINARY EdkShellBinPkg/FullShell/FullShell.inf
-!endif
-
-FILE FREEFORM = PCD(gEfiIntelFrameworkModulePkgTokenSpaceGuid.PcdLogoFile) {
- SECTION RAW = MdeModulePkg/Logo/Logo.bmp
-}
-
-#
-# 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
-!if $(SECURE_BOOT_ENABLE) == TRUE
- INF NetworkPkg/IScsiDxe/IScsiDxe.inf
-!else
- INF MdeModulePkg/Universal/Network/IScsiDxe/IScsiDxe.inf
-!endif
-!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/HttpDxe/HttpDxe.inf
- INF NetworkPkg/HttpBootDxe/HttpBootDxe.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/PlatformDxe/Platform.inf
-
-################################################################################
-
-[FV.FVMAIN_COMPACT]
-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
- }
- }
-
-################################################################################
-
-[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)
- }
-
-[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
- }
diff --git a/OvmfPkg/OvmfPkgIa32X64.dsc b/OvmfPkg/OvmfPkgIa32X64.dsc
deleted file mode 100644
index 753ab27779..0000000000
--- a/OvmfPkg/OvmfPkgIa32X64.dsc
+++ /dev/null
@@ -1,627 +0,0 @@
-## @file
-# EFI/Framework Open Virtual Machine Firmware (OVMF) platform
-#
-# Copyright (c) 2006 - 2015, Intel Corporation. All rights reserved.<BR>
-#
-# This program and the accompanying materials
-# are licensed and made available under the terms and conditions of the BSD License
-# which accompanies this distribution. The full text of the license may be found at
-# http://opensource.org/licenses/bsd-license.php
-#
-# 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 = 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
-
-[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
-
-################################################################################
-#
-# 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
- GenericBdsLib|IntelFrameworkModulePkg/Library/GenericBdsLib/GenericBdsLib.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
- PciLib|MdePkg/Library/BasePciLibCf8/BasePciLibCf8.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
- LockBoxLib|OvmfPkg/Library/LockBoxLib/LockBoxBaseLib.inf
- CustomizedDisplayLib|MdeModulePkg/Library/CustomizedDisplayLib/CustomizedDisplayLib.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/BaseXApicLib/BaseXApicLib.inf
- DebugPrintErrorLevelLib|MdePkg/Library/BaseDebugPrintErrorLevelLib/BaseDebugPrintErrorLevelLib.inf
-
-!if $(SECURE_BOOT_ENABLE) == TRUE
- PlatformSecureLib|OvmfPkg/Library/PlatformSecureLib/PlatformSecureLib.inf
- IntrinsicLib|CryptoPkg/Library/IntrinsicLib/IntrinsicLib.inf
- OpensslLib|CryptoPkg/Library/OpensslLib/OpensslLib.inf
- TpmMeasurementLib|SecurityPkg/Library/DxeTpmMeasurementLib/DxeTpmMeasurementLib.inf
- AuthVariableLib|SecurityPkg/Library/AuthVariableLib/AuthVariableLib.inf
-!if $(NETWORK_IP6_ENABLE) == TRUE
- TcpIoLib|MdeModulePkg/Library/DxeTcpIoLib/DxeTcpIoLib.inf
-!endif
-!else
- TpmMeasurementLib|MdeModulePkg/Library/TpmMeasurementLibNull/TpmMeasurementLibNull.inf
- AuthVariableLib|MdeModulePkg/Library/AuthVariableLibNull/AuthVariableLibNull.inf
-!endif
- VarCheckLib|MdeModulePkg/Library/VarCheckLib/VarCheckLib.inf
-
-!if $(HTTP_BOOT_ENABLE) == TRUE
- HttpLib|MdeModulePkg/Library/DxeHttpLib/DxeHttpLib.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]
-!if $(SECURE_BOOT_ENABLE) == TRUE
- BaseCryptLib|CryptoPkg/Library/BaseCryptLib/BaseCryptLib.inf
-!endif
-
-[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
-
-[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
-
-[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
-!if $(SECURE_BOOT_ENABLE) == TRUE
- BaseCryptLib|CryptoPkg/Library/BaseCryptLib/RuntimeCryptLib.inf
-!endif
-
-[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
-
-[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
- PlatformBdsLib|OvmfPkg/Library/PlatformBdsLib/PlatformBdsLib.inf
- CpuExceptionHandlerLib|UefiCpuPkg/Library/CpuExceptionHandlerLib/DxeCpuExceptionHandlerLib.inf
- LockBoxLib|OvmfPkg/Library/LockBoxLib/LockBoxDxeLib.inf
-!ifdef $(SOURCE_DEBUG_ENABLE)
- DebugAgentLib|SourceLevelDebugPkg/Library/DebugAgent/DxeDebugAgentLib.inf
-!endif
- QemuBootOrderLib|OvmfPkg/Library/QemuBootOrderLib/QemuBootOrderLib.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
-!ifdef $(DEBUG_ON_SERIAL_PORT)
- DebugLib|MdePkg/Library/BaseDebugLibSerialPort/BaseDebugLibSerialPort.inf
-!else
- DebugLib|OvmfPkg/Library/PlatformDebugLibIoPort/PlatformDebugLibIoPort.inf
-!endif
-
-[LibraryClasses.common.DXE_SMM_DRIVER]
- PcdLib|MdePkg/Library/DxePcdLib/DxePcdLib.inf
- TimerLib|OvmfPkg/Library/AcpiTimerLib/DxeAcpiTimerLib.inf
-
-[LibraryClasses.common.SMM_CORE]
- PcdLib|MdePkg/Library/DxePcdLib/DxePcdLib.inf
- TimerLib|OvmfPkg/Library/AcpiTimerLib/DxeAcpiTimerLib.inf
-
-################################################################################
-#
-# Pcd Section - list of all EDK II PCD Entries defined by this Platform.
-#
-################################################################################
-[PcdsFeatureFlag]
- gEfiMdeModulePkgTokenSpaceGuid.PcdStatusCodeUseSerial|FALSE
- gEfiMdeModulePkgTokenSpaceGuid.PcdStatusCodeUseMemory|TRUE
- gEfiMdeModulePkgTokenSpaceGuid.PcdDxeIplSupportUefiDecompress|FALSE
- gEfiMdeModulePkgTokenSpaceGuid.PcdDxeIplSwitchToLongMode|TRUE
- gEfiMdeModulePkgTokenSpaceGuid.PcdConOutGopSupport|TRUE
- gEfiMdeModulePkgTokenSpaceGuid.PcdConOutUgaSupport|FALSE
-!if $(SECURE_BOOT_ENABLE) == TRUE
- gUefiOvmfPkgTokenSpaceGuid.PcdSecureBootEnable|TRUE
-!endif
-
-[PcdsFixedAtBuild]
- gEfiMdeModulePkgTokenSpaceGuid.PcdStatusCodeMemorySize|1
- gEfiMdeModulePkgTokenSpaceGuid.PcdResetOnMemoryTypeInformationChange|FALSE
- gEfiMdePkgTokenSpaceGuid.PcdMaximumGuidedExtractHandler|0x10
- gEfiMdeModulePkgTokenSpaceGuid.PcdPeiCoreMaxFvSupported|6
- gEfiMdeModulePkgTokenSpaceGuid.PcdPeiCoreMaxPeimPerFv|32
- gEfiMdeModulePkgTokenSpaceGuid.PcdMaxVariableSize|0x2000
- gEfiMdeModulePkgTokenSpaceGuid.PcdMaxHardwareErrorVariableSize|0x8000
- gEfiMdeModulePkgTokenSpaceGuid.PcdVariableStoreSize|0xe000
-
- gEfiMdeModulePkgTokenSpaceGuid.PcdVpdBaseAddress|0x0
-
- gEfiMdePkgTokenSpaceGuid.PcdReportStatusCodePropertyMask|0x07
- gEfiMdePkgTokenSpaceGuid.PcdDebugPrintErrorLevel|0x8000004F
-!ifdef $(SOURCE_DEBUG_ENABLE)
- gEfiMdePkgTokenSpaceGuid.PcdDebugPropertyMask|0x17
-!else
- gEfiMdePkgTokenSpaceGuid.PcdDebugPropertyMask|0x2F
-!endif
-
-!ifdef $(SOURCE_DEBUG_ENABLE)
- gEfiSourceLevelDebugPkgTokenSpaceGuid.PcdDebugLoadImageMethod|0x2
-!endif
-
-!ifndef $(USE_OLD_SHELL)
- gEfiIntelFrameworkModulePkgTokenSpaceGuid.PcdShellFile|{ 0x83, 0xA5, 0x04, 0x7C, 0x3E, 0x9E, 0x1C, 0x4F, 0xAD, 0x65, 0xE0, 0x52, 0x68, 0xD0, 0xB4, 0xD1 }
-!endif
-
-[PcdsFixedAtBuild.X64]
-!if $(SECURE_BOOT_ENABLE) == TRUE
- # override the default values from SecurityPkg to ensure images from all sources are verified in secure boot
- gEfiSecurityPkgTokenSpaceGuid.PcdOptionRomImageVerificationPolicy|0x04
- gEfiSecurityPkgTokenSpaceGuid.PcdFixedMediaImageVerificationPolicy|0x04
- gEfiSecurityPkgTokenSpaceGuid.PcdRemovableMediaImageVerificationPolicy|0x04
-!endif
-
- # IRQs 5, 9, 10, 11 are level-triggered
- gPcAtChipsetPkgTokenSpaceGuid.Pcd8259LegacyModeEdgeLevel|0x0E20
-
-################################################################################
-#
-# 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
- gUefiOvmfPkgTokenSpaceGuid.PcdOvmfHostBridgePciDevId|0
-
- gEfiMdePkgTokenSpaceGuid.PcdPlatformBootTimeOut|0
-
- # Set video resolution for text setup.
- gEfiMdeModulePkgTokenSpaceGuid.PcdSetupVideoHorizontalResolution|640
- gEfiMdeModulePkgTokenSpaceGuid.PcdSetupVideoVerticalResolution|480
-
- gEfiMdeModulePkgTokenSpaceGuid.PcdSmbiosVersion|0x0208
- gEfiMdeModulePkgTokenSpaceGuid.PcdSmbiosDocRev|0x0
- gUefiOvmfPkgTokenSpaceGuid.PcdQemuSmbiosValidated|FALSE
-
-################################################################################
-#
-# 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 {
- <LibraryClasses>
- NULL|IntelFrameworkModulePkg/Library/LzmaCustomDecompressLib/LzmaCustomDecompressLib.inf
- }
-
- #
- # PEI Phase modules
- #
- MdeModulePkg/Core/Pei/PeiMain.inf
- MdeModulePkg/Universal/PCD/Pei/Pcd.inf {
- <LibraryClasses>
- PcdLib|MdePkg/Library/BasePcdLibNull/BasePcdLibNull.inf
- }
- IntelFrameworkModulePkg/Universal/StatusCode/Pei/StatusCodePei.inf
- MdeModulePkg/Core/DxeIplPeim/DxeIpl.inf
-
- OvmfPkg/PlatformPei/PlatformPei.inf {
- <LibraryClasses>
- PcdLib|MdePkg/Library/PeiPcdLib/PeiPcdLib.inf
- }
- UefiCpuPkg/Universal/Acpi/S3Resume2Pei/S3Resume2Pei.inf {
- <LibraryClasses>
- PcdLib|MdePkg/Library/PeiPcdLib/PeiPcdLib.inf
- }
-
-[Components.X64]
- #
- # DXE Phase modules
- #
- MdeModulePkg/Core/Dxe/DxeMain.inf {
- <LibraryClasses>
- NULL|IntelFrameworkModulePkg/Library/LzmaCustomDecompressLib/LzmaCustomDecompressLib.inf
- DevicePathLib|MdePkg/Library/UefiDevicePathLib/UefiDevicePathLib.inf
- }
-
- IntelFrameworkModulePkg/Universal/StatusCode/RuntimeDxe/StatusCodeRuntimeDxe.inf
- MdeModulePkg/Universal/PCD/Dxe/Pcd.inf {
- <LibraryClasses>
- PcdLib|MdePkg/Library/BasePcdLibNull/BasePcdLibNull.inf
- }
-
- MdeModulePkg/Core/RuntimeDxe/RuntimeDxe.inf
-
-!if $(SECURE_BOOT_ENABLE) == TRUE
- MdeModulePkg/Universal/SecurityStubDxe/SecurityStubDxe.inf {
- <LibraryClasses>
- 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/PciHostBridgeDxe/PciHostBridgeDxe.inf
- MdeModulePkg/Bus/Pci/PciBusDxe/PciBusDxe.inf {
- <LibraryClasses>
- PcdLib|MdePkg/Library/DxePcdLib/DxePcdLib.inf
- }
- PcAtChipsetPkg/KbcResetDxe/Reset.inf
- MdeModulePkg/Universal/Metronome/Metronome.inf
- PcAtChipsetPkg/PcatRealTimeClockRuntimeDxe/PcatRealTimeClockRuntimeDxe.inf
- IntelFrameworkModulePkg/Universal/BdsDxe/BdsDxe.inf {
- <LibraryClasses>
-!ifdef $(CSM_ENABLE)
- NULL|OvmfPkg/Csm/CsmSupportLib/CsmSupportLib.inf
-!endif
- }
-
- OvmfPkg/BlockMmioToBlockIoDxe/BlockIo.inf
- OvmfPkg/VirtioPciDeviceDxe/VirtioPciDeviceDxe.inf
- OvmfPkg/VirtioBlkDxe/VirtioBlk.inf
- OvmfPkg/VirtioScsiDxe/VirtioScsi.inf
- OvmfPkg/QemuFlashFvbServicesRuntimeDxe/FvbServicesRuntimeDxe.inf
- OvmfPkg/XenIoPciDxe/XenIoPciDxe.inf
- OvmfPkg/XenBusDxe/XenBusDxe.inf
- OvmfPkg/XenPvBlkDxe/XenPvBlkDxe.inf
- OvmfPkg/EmuVariableFvbRuntimeDxe/Fvb.inf {
- <LibraryClasses>
- PlatformFvbLib|OvmfPkg/Library/EmuVariableFvbLib/EmuVariableFvbLib.inf
- }
- MdeModulePkg/Universal/FaultTolerantWriteDxe/FaultTolerantWriteDxe.inf
- MdeModulePkg/Universal/Variable/RuntimeDxe/VariableRuntimeDxe.inf {
- <LibraryClasses>
- NULL|MdeModulePkg/Library/VarCheckUefiLib/VarCheckUefiLib.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 {
- <LibraryClasses>
- PcdLib|MdePkg/Library/DxePcdLib/DxePcdLib.inf
- }
- MdeModulePkg/Universal/Console/TerminalDxe/TerminalDxe.inf
- MdeModulePkg/Universal/DevicePathDxe/DevicePathDxe.inf {
- <LibraryClasses>
- 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/UnicodeCollation/EnglishDxe/EnglishDxe.inf
- MdeModulePkg/Bus/Scsi/ScsiBusDxe/ScsiBusDxe.inf
- MdeModulePkg/Bus/Scsi/ScsiDiskDxe/ScsiDiskDxe.inf
- IntelFrameworkModulePkg/Bus/Pci/IdeBusDxe/IdeBusDxe.inf
- PcAtChipsetPkg/Bus/Pci/IdeControllerDxe/IdeControllerDxe.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 {
- <LibraryClasses>
- BltLib|OptionRomPkg/Library/FrameBufferBltLib/FrameBufferBltLib.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 {
- <LibraryClasses>
- 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
- OvmfPkg/AcpiS3SaveDxe/AcpiS3SaveDxe.inf
- MdeModulePkg/Universal/Acpi/S3SaveStateDxe/S3SaveStateDxe.inf
- MdeModulePkg/Universal/Acpi/BootScriptExecutorDxe/BootScriptExecutorDxe.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
-!if $(SECURE_BOOT_ENABLE) == TRUE
- NetworkPkg/IScsiDxe/IScsiDxe.inf
-!else
- MdeModulePkg/Universal/Network/IScsiDxe/IScsiDxe.inf
-!endif
-!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/HttpDxe/HttpDxe.inf
- NetworkPkg/HttpBootDxe/HttpBootDxe.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 {
- <LibraryClasses>
- 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 {
- <LibraryClasses>
- 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
- HandleParsingLib|ShellPkg/Library/UefiHandleParsingLib/UefiHandleParsingLib.inf
- ShellLib|ShellPkg/Library/UefiShellLib/UefiShellLib.inf
- FileHandleLib|MdePkg/Library/UefiFileHandleLib/UefiFileHandleLib.inf
- SortLib|MdeModulePkg/Library/UefiSortLib/UefiSortLib.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
-
- <PcdsFixedAtBuild>
- 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
diff --git a/OvmfPkg/OvmfPkgIa32X64.fdf b/OvmfPkg/OvmfPkgIa32X64.fdf
deleted file mode 100644
index 74412d4640..0000000000
--- a/OvmfPkg/OvmfPkgIa32X64.fdf
+++ /dev/null
@@ -1,476 +0,0 @@
-## @file
-# Open Virtual Machine Firmware: FDF
-#
-# Copyright (c) 2006 - 2015, Intel Corporation. All rights reserved.<BR>
-#
-# This program and the accompanying materials
-# are licensed and made available under the terms and conditions of the BSD License
-# which accompanies this distribution. The full text of the license may be found at
-# http://opensource.org/licenses/bsd-license.php
-#
-# 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 for DEBUG build is 2MB. For RELEASE it is 1MB.
-#
-# Defining FD_SIZE_1MB or FD_SIZE_2MB on the build command line can
-# override this.
-#
-[Defines]
-!if $(TARGET) == RELEASE
-!ifndef $(FD_SIZE_2MB)
-DEFINE FD_SIZE_1MB=
-!endif
-!endif
-
-!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 = 0x800000
-Size = 0x900000
-ErasePolarity = 1
-BlockSize = 0x10000
-NumBlocks = 0x90
-
-0x000000|0x006000
-gUefiOvmfPkgTokenSpaceGuid.PcdOvmfSecPageTablesBase|gUefiOvmfPkgTokenSpaceGuid.PcdOvmfSecPageTablesSize
-
-0x006000|0x001000
-gUefiOvmfPkgTokenSpaceGuid.PcdOvmfLockBoxStorageBase|gUefiOvmfPkgTokenSpaceGuid.PcdOvmfLockBoxStorageSize
-
-0x007000|0x001000
-gEfiMdePkgTokenSpaceGuid.PcdGuidedExtractHandlerTableAddress|gUefiOvmfPkgTokenSpaceGuid.PcdGuidedExtractHandlerTableSize
-
-0x010000|0x008000
-gUefiOvmfPkgTokenSpaceGuid.PcdOvmfSecPeiTempRamBase|gUefiOvmfPkgTokenSpaceGuid.PcdOvmfSecPeiTempRamSize
-
-0x018000|0x008000
-gUefiOvmfPkgTokenSpaceGuid.PcdS3AcpiReservedMemoryBase|gEfiIntelFrameworkModulePkgTokenSpaceGuid.PcdS3AcpiReservedMemorySize
-
-0x020000|0x0E0000
-gUefiOvmfPkgTokenSpaceGuid.PcdOvmfPeiMemFvBase|gUefiOvmfPkgTokenSpaceGuid.PcdOvmfPeiMemFvSize
-FV = PEIFV
-
-0x100000|0x800000
-gUefiOvmfPkgTokenSpaceGuid.PcdOvmfDxeMemFvBase|gUefiOvmfPkgTokenSpaceGuid.PcdOvmfDxeMemFvSize
-FV = DXEFV
-
-################################################################################
-
-[FV.SECFV]
-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]
-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 IntelFrameworkModulePkg/Universal/StatusCode/Pei/StatusCodePei.inf
-INF OvmfPkg/PlatformPei/PlatformPei.inf
-INF MdeModulePkg/Core/DxeIplPeim/DxeIpl.inf
-INF UefiCpuPkg/Universal/Acpi/S3Resume2Pei/S3Resume2Pei.inf
-
-################################################################################
-
-[FV.DXEFV]
-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
- INF OvmfPkg/QemuFlashFvbServicesRuntimeDxe/FvbServicesRuntimeDxe.inf
-}
-
-#
-# DXE Phase modules
-#
-INF MdeModulePkg/Core/Dxe/DxeMain.inf
-
-INF IntelFrameworkModulePkg/Universal/StatusCode/RuntimeDxe/StatusCodeRuntimeDxe.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/PciHostBridgeDxe/PciHostBridgeDxe.inf
-INF MdeModulePkg/Bus/Pci/PciBusDxe/PciBusDxe.inf
-INF PcAtChipsetPkg/KbcResetDxe/Reset.inf
-INF MdeModulePkg/Universal/Metronome/Metronome.inf
-INF PcAtChipsetPkg/PcatRealTimeClockRuntimeDxe/PcatRealTimeClockRuntimeDxe.inf
-
-INF OvmfPkg/BlockMmioToBlockIoDxe/BlockIo.inf
-INF OvmfPkg/VirtioPciDeviceDxe/VirtioPciDeviceDxe.inf
-INF OvmfPkg/VirtioBlkDxe/VirtioBlk.inf
-INF OvmfPkg/VirtioScsiDxe/VirtioScsi.inf
-INF OvmfPkg/QemuFlashFvbServicesRuntimeDxe/FvbServicesRuntimeDxe.inf
-INF OvmfPkg/EmuVariableFvbRuntimeDxe/Fvb.inf
-INF MdeModulePkg/Universal/FaultTolerantWriteDxe/FaultTolerantWriteDxe.inf
-INF OvmfPkg/XenIoPciDxe/XenIoPciDxe.inf
-INF OvmfPkg/XenBusDxe/XenBusDxe.inf
-INF OvmfPkg/XenPvBlkDxe/XenPvBlkDxe.inf
-
-INF MdeModulePkg/Universal/Variable/RuntimeDxe/VariableRuntimeDxe.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 IntelFrameworkModulePkg/Universal/BdsDxe/BdsDxe.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/UnicodeCollation/EnglishDxe/EnglishDxe.inf
-INF MdeModulePkg/Bus/Scsi/ScsiBusDxe/ScsiBusDxe.inf
-INF MdeModulePkg/Bus/Scsi/ScsiDiskDxe/ScsiDiskDxe.inf
-INF IntelFrameworkModulePkg/Bus/Pci/IdeBusDxe/IdeBusDxe.inf
-INF PcAtChipsetPkg/Bus/Pci/IdeControllerDxe/IdeControllerDxe.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 OvmfPkg/AcpiS3SaveDxe/AcpiS3SaveDxe.inf
-INF MdeModulePkg/Universal/Acpi/S3SaveStateDxe/S3SaveStateDxe.inf
-INF MdeModulePkg/Universal/Acpi/BootScriptExecutorDxe/BootScriptExecutorDxe.inf
-
-INF RuleOverride = BINARY USE = X64 FatBinPkg/EnhancedFatDxe/Fat.inf
-
-!ifndef $(USE_OLD_SHELL)
-INF ShellPkg/Application/Shell/Shell.inf
-!else
-INF RuleOverride = BINARY USE = X64 EdkShellBinPkg/FullShell/FullShell.inf
-!endif
-
-FILE FREEFORM = PCD(gEfiIntelFrameworkModulePkgTokenSpaceGuid.PcdLogoFile) {
- SECTION RAW = MdeModulePkg/Logo/Logo.bmp
-}
-
-#
-# 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
-!if $(SECURE_BOOT_ENABLE) == TRUE
- INF NetworkPkg/IScsiDxe/IScsiDxe.inf
-!else
- INF MdeModulePkg/Universal/Network/IScsiDxe/IScsiDxe.inf
-!endif
-!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/HttpDxe/HttpDxe.inf
- INF NetworkPkg/HttpBootDxe/HttpBootDxe.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/PlatformDxe/Platform.inf
-
-################################################################################
-
-[FV.FVMAIN_COMPACT]
-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
- }
- }
-
-################################################################################
-
-[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)
- }
-
-[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
- }
diff --git a/OvmfPkg/OvmfPkgX64.dsc b/OvmfPkg/OvmfPkgX64.dsc
deleted file mode 100644
index 540333d896..0000000000
--- a/OvmfPkg/OvmfPkgX64.dsc
+++ /dev/null
@@ -1,625 +0,0 @@
-## @file
-# EFI/Framework Open Virtual Machine Firmware (OVMF) platform
-#
-# Copyright (c) 2006 - 2015, Intel Corporation. All rights reserved.<BR>
-#
-# This program and the accompanying materials
-# are licensed and made available under the terms and conditions of the BSD License
-# which accompanies this distribution. The full text of the license may be found at
-# http://opensource.org/licenses/bsd-license.php
-#
-# 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 = 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
-
-[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
-
-################################################################################
-#
-# 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
- GenericBdsLib|IntelFrameworkModulePkg/Library/GenericBdsLib/GenericBdsLib.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
- PciLib|MdePkg/Library/BasePciLibCf8/BasePciLibCf8.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
- LockBoxLib|OvmfPkg/Library/LockBoxLib/LockBoxBaseLib.inf
- CustomizedDisplayLib|MdeModulePkg/Library/CustomizedDisplayLib/CustomizedDisplayLib.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/BaseXApicLib/BaseXApicLib.inf
- DebugPrintErrorLevelLib|MdePkg/Library/BaseDebugPrintErrorLevelLib/BaseDebugPrintErrorLevelLib.inf
-
-!if $(SECURE_BOOT_ENABLE) == TRUE
- PlatformSecureLib|OvmfPkg/Library/PlatformSecureLib/PlatformSecureLib.inf
- IntrinsicLib|CryptoPkg/Library/IntrinsicLib/IntrinsicLib.inf
- OpensslLib|CryptoPkg/Library/OpensslLib/OpensslLib.inf
- TpmMeasurementLib|SecurityPkg/Library/DxeTpmMeasurementLib/DxeTpmMeasurementLib.inf
- AuthVariableLib|SecurityPkg/Library/AuthVariableLib/AuthVariableLib.inf
-!if $(NETWORK_IP6_ENABLE) == TRUE
- TcpIoLib|MdeModulePkg/Library/DxeTcpIoLib/DxeTcpIoLib.inf
-!endif
-!else
- TpmMeasurementLib|MdeModulePkg/Library/TpmMeasurementLibNull/TpmMeasurementLibNull.inf
- AuthVariableLib|MdeModulePkg/Library/AuthVariableLibNull/AuthVariableLibNull.inf
-!endif
- VarCheckLib|MdeModulePkg/Library/VarCheckLib/VarCheckLib.inf
-
-!if $(HTTP_BOOT_ENABLE) == TRUE
- HttpLib|MdeModulePkg/Library/DxeHttpLib/DxeHttpLib.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]
-!if $(SECURE_BOOT_ENABLE) == TRUE
- BaseCryptLib|CryptoPkg/Library/BaseCryptLib/BaseCryptLib.inf
-!endif
-
-[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
-
-[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
-
-[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
-!if $(SECURE_BOOT_ENABLE) == TRUE
- BaseCryptLib|CryptoPkg/Library/BaseCryptLib/RuntimeCryptLib.inf
-!endif
-
-[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
-
-[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
- PlatformBdsLib|OvmfPkg/Library/PlatformBdsLib/PlatformBdsLib.inf
- CpuExceptionHandlerLib|UefiCpuPkg/Library/CpuExceptionHandlerLib/DxeCpuExceptionHandlerLib.inf
- LockBoxLib|OvmfPkg/Library/LockBoxLib/LockBoxDxeLib.inf
-!ifdef $(SOURCE_DEBUG_ENABLE)
- DebugAgentLib|SourceLevelDebugPkg/Library/DebugAgent/DxeDebugAgentLib.inf
-!endif
- QemuBootOrderLib|OvmfPkg/Library/QemuBootOrderLib/QemuBootOrderLib.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
-!ifdef $(DEBUG_ON_SERIAL_PORT)
- DebugLib|MdePkg/Library/BaseDebugLibSerialPort/BaseDebugLibSerialPort.inf
-!else
- DebugLib|OvmfPkg/Library/PlatformDebugLibIoPort/PlatformDebugLibIoPort.inf
-!endif
-
-[LibraryClasses.common.DXE_SMM_DRIVER]
- PcdLib|MdePkg/Library/DxePcdLib/DxePcdLib.inf
- TimerLib|OvmfPkg/Library/AcpiTimerLib/DxeAcpiTimerLib.inf
-
-[LibraryClasses.common.SMM_CORE]
- PcdLib|MdePkg/Library/DxePcdLib/DxePcdLib.inf
- TimerLib|OvmfPkg/Library/AcpiTimerLib/DxeAcpiTimerLib.inf
-
-################################################################################
-#
-# Pcd Section - list of all EDK II PCD Entries defined by this Platform.
-#
-################################################################################
-[PcdsFeatureFlag]
- gEfiMdeModulePkgTokenSpaceGuid.PcdStatusCodeUseSerial|FALSE
- gEfiMdeModulePkgTokenSpaceGuid.PcdStatusCodeUseMemory|TRUE
- gEfiMdeModulePkgTokenSpaceGuid.PcdDxeIplSupportUefiDecompress|FALSE
- gEfiMdeModulePkgTokenSpaceGuid.PcdDxeIplSwitchToLongMode|FALSE
- gEfiMdeModulePkgTokenSpaceGuid.PcdConOutGopSupport|TRUE
- gEfiMdeModulePkgTokenSpaceGuid.PcdConOutUgaSupport|FALSE
-!if $(SECURE_BOOT_ENABLE) == TRUE
- gUefiOvmfPkgTokenSpaceGuid.PcdSecureBootEnable|TRUE
-!endif
-
-[PcdsFixedAtBuild]
- gEfiMdeModulePkgTokenSpaceGuid.PcdStatusCodeMemorySize|1
- gEfiMdeModulePkgTokenSpaceGuid.PcdResetOnMemoryTypeInformationChange|FALSE
- gEfiMdePkgTokenSpaceGuid.PcdMaximumGuidedExtractHandler|0x10
- gEfiMdeModulePkgTokenSpaceGuid.PcdPeiCoreMaxFvSupported|6
- gEfiMdeModulePkgTokenSpaceGuid.PcdPeiCoreMaxPeimPerFv|32
- gEfiMdeModulePkgTokenSpaceGuid.PcdMaxVariableSize|0x2000
- gEfiMdeModulePkgTokenSpaceGuid.PcdMaxHardwareErrorVariableSize|0x8000
- gEfiMdeModulePkgTokenSpaceGuid.PcdVariableStoreSize|0xe000
-
- gEfiMdeModulePkgTokenSpaceGuid.PcdVpdBaseAddress|0x0
-
- gEfiMdePkgTokenSpaceGuid.PcdReportStatusCodePropertyMask|0x07
- gEfiMdePkgTokenSpaceGuid.PcdDebugPrintErrorLevel|0x8000004F
-!ifdef $(SOURCE_DEBUG_ENABLE)
- gEfiMdePkgTokenSpaceGuid.PcdDebugPropertyMask|0x17
-!else
- gEfiMdePkgTokenSpaceGuid.PcdDebugPropertyMask|0x2F
-!endif
-
-!ifdef $(SOURCE_DEBUG_ENABLE)
- gEfiSourceLevelDebugPkgTokenSpaceGuid.PcdDebugLoadImageMethod|0x2
-!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 $(SECURE_BOOT_ENABLE) == TRUE
- # override the default values from SecurityPkg to ensure images from all sources are verified in secure boot
- gEfiSecurityPkgTokenSpaceGuid.PcdOptionRomImageVerificationPolicy|0x04
- gEfiSecurityPkgTokenSpaceGuid.PcdFixedMediaImageVerificationPolicy|0x04
- gEfiSecurityPkgTokenSpaceGuid.PcdRemovableMediaImageVerificationPolicy|0x04
-!endif
-
- # IRQs 5, 9, 10, 11 are level-triggered
- gPcAtChipsetPkgTokenSpaceGuid.Pcd8259LegacyModeEdgeLevel|0x0E20
-
-################################################################################
-#
-# 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
- gUefiOvmfPkgTokenSpaceGuid.PcdOvmfHostBridgePciDevId|0
-
- gEfiMdePkgTokenSpaceGuid.PcdPlatformBootTimeOut|0
-
- # Set video resolution for text setup.
- gEfiMdeModulePkgTokenSpaceGuid.PcdSetupVideoHorizontalResolution|640
- gEfiMdeModulePkgTokenSpaceGuid.PcdSetupVideoVerticalResolution|480
-
- gEfiMdeModulePkgTokenSpaceGuid.PcdSmbiosVersion|0x0208
- gEfiMdeModulePkgTokenSpaceGuid.PcdSmbiosDocRev|0x0
- gUefiOvmfPkgTokenSpaceGuid.PcdQemuSmbiosValidated|FALSE
-
-################################################################################
-#
-# Components Section - list of all EDK II Modules needed by this Platform.
-#
-################################################################################
-[Components]
- OvmfPkg/ResetVector/ResetVector.inf
-
- #
- # SEC Phase modules
- #
- OvmfPkg/Sec/SecMain.inf {
- <LibraryClasses>
- NULL|IntelFrameworkModulePkg/Library/LzmaCustomDecompressLib/LzmaCustomDecompressLib.inf
- }
-
- #
- # PEI Phase modules
- #
- MdeModulePkg/Core/Pei/PeiMain.inf
- MdeModulePkg/Universal/PCD/Pei/Pcd.inf {
- <LibraryClasses>
- PcdLib|MdePkg/Library/BasePcdLibNull/BasePcdLibNull.inf
- }
- IntelFrameworkModulePkg/Universal/StatusCode/Pei/StatusCodePei.inf
- MdeModulePkg/Core/DxeIplPeim/DxeIpl.inf
-
- OvmfPkg/PlatformPei/PlatformPei.inf {
- <LibraryClasses>
- PcdLib|MdePkg/Library/PeiPcdLib/PeiPcdLib.inf
- }
- UefiCpuPkg/Universal/Acpi/S3Resume2Pei/S3Resume2Pei.inf {
- <LibraryClasses>
- PcdLib|MdePkg/Library/PeiPcdLib/PeiPcdLib.inf
- }
-
- #
- # DXE Phase modules
- #
- MdeModulePkg/Core/Dxe/DxeMain.inf {
- <LibraryClasses>
- NULL|IntelFrameworkModulePkg/Library/LzmaCustomDecompressLib/LzmaCustomDecompressLib.inf
- DevicePathLib|MdePkg/Library/UefiDevicePathLib/UefiDevicePathLib.inf
- }
-
- IntelFrameworkModulePkg/Universal/StatusCode/RuntimeDxe/StatusCodeRuntimeDxe.inf
- MdeModulePkg/Universal/PCD/Dxe/Pcd.inf {
- <LibraryClasses>
- PcdLib|MdePkg/Library/BasePcdLibNull/BasePcdLibNull.inf
- }
-
- MdeModulePkg/Core/RuntimeDxe/RuntimeDxe.inf
-
-!if $(SECURE_BOOT_ENABLE) == TRUE
- MdeModulePkg/Universal/SecurityStubDxe/SecurityStubDxe.inf {
- <LibraryClasses>
- 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/PciHostBridgeDxe/PciHostBridgeDxe.inf
- MdeModulePkg/Bus/Pci/PciBusDxe/PciBusDxe.inf {
- <LibraryClasses>
- PcdLib|MdePkg/Library/DxePcdLib/DxePcdLib.inf
- }
- PcAtChipsetPkg/KbcResetDxe/Reset.inf
- MdeModulePkg/Universal/Metronome/Metronome.inf
- PcAtChipsetPkg/PcatRealTimeClockRuntimeDxe/PcatRealTimeClockRuntimeDxe.inf
- IntelFrameworkModulePkg/Universal/BdsDxe/BdsDxe.inf {
- <LibraryClasses>
-!ifdef $(CSM_ENABLE)
- NULL|OvmfPkg/Csm/CsmSupportLib/CsmSupportLib.inf
-!endif
- }
-
- OvmfPkg/BlockMmioToBlockIoDxe/BlockIo.inf
- OvmfPkg/VirtioPciDeviceDxe/VirtioPciDeviceDxe.inf
- OvmfPkg/VirtioBlkDxe/VirtioBlk.inf
- OvmfPkg/VirtioScsiDxe/VirtioScsi.inf
- OvmfPkg/QemuFlashFvbServicesRuntimeDxe/FvbServicesRuntimeDxe.inf
- OvmfPkg/XenIoPciDxe/XenIoPciDxe.inf
- OvmfPkg/XenBusDxe/XenBusDxe.inf
- OvmfPkg/XenPvBlkDxe/XenPvBlkDxe.inf
- OvmfPkg/EmuVariableFvbRuntimeDxe/Fvb.inf {
- <LibraryClasses>
- PlatformFvbLib|OvmfPkg/Library/EmuVariableFvbLib/EmuVariableFvbLib.inf
- }
- MdeModulePkg/Universal/FaultTolerantWriteDxe/FaultTolerantWriteDxe.inf
- MdeModulePkg/Universal/Variable/RuntimeDxe/VariableRuntimeDxe.inf {
- <LibraryClasses>
- NULL|MdeModulePkg/Library/VarCheckUefiLib/VarCheckUefiLib.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 {
- <LibraryClasses>
- PcdLib|MdePkg/Library/DxePcdLib/DxePcdLib.inf
- }
- MdeModulePkg/Universal/Console/TerminalDxe/TerminalDxe.inf
- MdeModulePkg/Universal/DevicePathDxe/DevicePathDxe.inf {
- <LibraryClasses>
- 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/UnicodeCollation/EnglishDxe/EnglishDxe.inf
- MdeModulePkg/Bus/Scsi/ScsiBusDxe/ScsiBusDxe.inf
- MdeModulePkg/Bus/Scsi/ScsiDiskDxe/ScsiDiskDxe.inf
- IntelFrameworkModulePkg/Bus/Pci/IdeBusDxe/IdeBusDxe.inf
- PcAtChipsetPkg/Bus/Pci/IdeControllerDxe/IdeControllerDxe.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 {
- <LibraryClasses>
- BltLib|OptionRomPkg/Library/FrameBufferBltLib/FrameBufferBltLib.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 {
- <LibraryClasses>
- 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
- OvmfPkg/AcpiS3SaveDxe/AcpiS3SaveDxe.inf
- MdeModulePkg/Universal/Acpi/S3SaveStateDxe/S3SaveStateDxe.inf
- MdeModulePkg/Universal/Acpi/BootScriptExecutorDxe/BootScriptExecutorDxe.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
-!if $(SECURE_BOOT_ENABLE) == TRUE
- NetworkPkg/IScsiDxe/IScsiDxe.inf
-!else
- MdeModulePkg/Universal/Network/IScsiDxe/IScsiDxe.inf
-!endif
-!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/HttpDxe/HttpDxe.inf
- NetworkPkg/HttpBootDxe/HttpBootDxe.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 {
- <LibraryClasses>
- 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 {
- <LibraryClasses>
- 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
- HandleParsingLib|ShellPkg/Library/UefiHandleParsingLib/UefiHandleParsingLib.inf
- ShellLib|ShellPkg/Library/UefiShellLib/UefiShellLib.inf
- FileHandleLib|MdePkg/Library/UefiFileHandleLib/UefiFileHandleLib.inf
- SortLib|MdeModulePkg/Library/UefiSortLib/UefiSortLib.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
-
- <PcdsFixedAtBuild>
- 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
diff --git a/OvmfPkg/OvmfPkgX64.fdf b/OvmfPkg/OvmfPkgX64.fdf
deleted file mode 100644
index e9ba97b9ea..0000000000
--- a/OvmfPkg/OvmfPkgX64.fdf
+++ /dev/null
@@ -1,476 +0,0 @@
-## @file
-# Open Virtual Machine Firmware: FDF
-#
-# Copyright (c) 2006 - 2015, Intel Corporation. All rights reserved.<BR>
-#
-# This program and the accompanying materials
-# are licensed and made available under the terms and conditions of the BSD License
-# which accompanies this distribution. The full text of the license may be found at
-# http://opensource.org/licenses/bsd-license.php
-#
-# 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 for DEBUG build is 2MB. For RELEASE it is 1MB.
-#
-# Defining FD_SIZE_1MB or FD_SIZE_2MB on the build command line can
-# override this.
-#
-[Defines]
-!if $(TARGET) == RELEASE
-!ifndef $(FD_SIZE_2MB)
-DEFINE FD_SIZE_1MB=
-!endif
-!endif
-
-!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 = 0x800000
-Size = 0x900000
-ErasePolarity = 1
-BlockSize = 0x10000
-NumBlocks = 0x90
-
-0x000000|0x006000
-gUefiOvmfPkgTokenSpaceGuid.PcdOvmfSecPageTablesBase|gUefiOvmfPkgTokenSpaceGuid.PcdOvmfSecPageTablesSize
-
-0x006000|0x001000
-gUefiOvmfPkgTokenSpaceGuid.PcdOvmfLockBoxStorageBase|gUefiOvmfPkgTokenSpaceGuid.PcdOvmfLockBoxStorageSize
-
-0x007000|0x001000
-gEfiMdePkgTokenSpaceGuid.PcdGuidedExtractHandlerTableAddress|gUefiOvmfPkgTokenSpaceGuid.PcdGuidedExtractHandlerTableSize
-
-0x010000|0x008000
-gUefiOvmfPkgTokenSpaceGuid.PcdOvmfSecPeiTempRamBase|gUefiOvmfPkgTokenSpaceGuid.PcdOvmfSecPeiTempRamSize
-
-0x018000|0x008000
-gUefiOvmfPkgTokenSpaceGuid.PcdS3AcpiReservedMemoryBase|gEfiIntelFrameworkModulePkgTokenSpaceGuid.PcdS3AcpiReservedMemorySize
-
-0x020000|0x0E0000
-gUefiOvmfPkgTokenSpaceGuid.PcdOvmfPeiMemFvBase|gUefiOvmfPkgTokenSpaceGuid.PcdOvmfPeiMemFvSize
-FV = PEIFV
-
-0x100000|0x800000
-gUefiOvmfPkgTokenSpaceGuid.PcdOvmfDxeMemFvBase|gUefiOvmfPkgTokenSpaceGuid.PcdOvmfDxeMemFvSize
-FV = DXEFV
-
-################################################################################
-
-[FV.SECFV]
-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]
-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 IntelFrameworkModulePkg/Universal/StatusCode/Pei/StatusCodePei.inf
-INF OvmfPkg/PlatformPei/PlatformPei.inf
-INF MdeModulePkg/Core/DxeIplPeim/DxeIpl.inf
-INF UefiCpuPkg/Universal/Acpi/S3Resume2Pei/S3Resume2Pei.inf
-
-################################################################################
-
-[FV.DXEFV]
-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
- INF OvmfPkg/QemuFlashFvbServicesRuntimeDxe/FvbServicesRuntimeDxe.inf
-}
-
-#
-# DXE Phase modules
-#
-INF MdeModulePkg/Core/Dxe/DxeMain.inf
-
-INF IntelFrameworkModulePkg/Universal/StatusCode/RuntimeDxe/StatusCodeRuntimeDxe.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/PciHostBridgeDxe/PciHostBridgeDxe.inf
-INF MdeModulePkg/Bus/Pci/PciBusDxe/PciBusDxe.inf
-INF PcAtChipsetPkg/KbcResetDxe/Reset.inf
-INF MdeModulePkg/Universal/Metronome/Metronome.inf
-INF PcAtChipsetPkg/PcatRealTimeClockRuntimeDxe/PcatRealTimeClockRuntimeDxe.inf
-
-INF OvmfPkg/BlockMmioToBlockIoDxe/BlockIo.inf
-INF OvmfPkg/VirtioPciDeviceDxe/VirtioPciDeviceDxe.inf
-INF OvmfPkg/VirtioBlkDxe/VirtioBlk.inf
-INF OvmfPkg/VirtioScsiDxe/VirtioScsi.inf
-INF OvmfPkg/QemuFlashFvbServicesRuntimeDxe/FvbServicesRuntimeDxe.inf
-INF OvmfPkg/EmuVariableFvbRuntimeDxe/Fvb.inf
-INF MdeModulePkg/Universal/FaultTolerantWriteDxe/FaultTolerantWriteDxe.inf
-INF OvmfPkg/XenIoPciDxe/XenIoPciDxe.inf
-INF OvmfPkg/XenBusDxe/XenBusDxe.inf
-INF OvmfPkg/XenPvBlkDxe/XenPvBlkDxe.inf
-
-INF MdeModulePkg/Universal/Variable/RuntimeDxe/VariableRuntimeDxe.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 IntelFrameworkModulePkg/Universal/BdsDxe/BdsDxe.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/UnicodeCollation/EnglishDxe/EnglishDxe.inf
-INF MdeModulePkg/Bus/Scsi/ScsiBusDxe/ScsiBusDxe.inf
-INF MdeModulePkg/Bus/Scsi/ScsiDiskDxe/ScsiDiskDxe.inf
-INF IntelFrameworkModulePkg/Bus/Pci/IdeBusDxe/IdeBusDxe.inf
-INF PcAtChipsetPkg/Bus/Pci/IdeControllerDxe/IdeControllerDxe.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 OvmfPkg/AcpiS3SaveDxe/AcpiS3SaveDxe.inf
-INF MdeModulePkg/Universal/Acpi/S3SaveStateDxe/S3SaveStateDxe.inf
-INF MdeModulePkg/Universal/Acpi/BootScriptExecutorDxe/BootScriptExecutorDxe.inf
-
-INF RuleOverride = BINARY FatBinPkg/EnhancedFatDxe/Fat.inf
-
-!ifndef $(USE_OLD_SHELL)
-INF ShellPkg/Application/Shell/Shell.inf
-!else
-INF RuleOverride = BINARY EdkShellBinPkg/FullShell/FullShell.inf
-!endif
-
-FILE FREEFORM = PCD(gEfiIntelFrameworkModulePkgTokenSpaceGuid.PcdLogoFile) {
- SECTION RAW = MdeModulePkg/Logo/Logo.bmp
-}
-
-#
-# 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
-!if $(SECURE_BOOT_ENABLE) == TRUE
- INF NetworkPkg/IScsiDxe/IScsiDxe.inf
-!else
- INF MdeModulePkg/Universal/Network/IScsiDxe/IScsiDxe.inf
-!endif
-!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/HttpDxe/HttpDxe.inf
- INF NetworkPkg/HttpBootDxe/HttpBootDxe.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/PlatformDxe/Platform.inf
-
-################################################################################
-
-[FV.FVMAIN_COMPACT]
-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
- }
- }
-
-################################################################################
-
-[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)
- }
-
-[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
- }
diff --git a/OvmfPkg/PciHostBridgeDxe/Ia32/IoFifo.S b/OvmfPkg/PciHostBridgeDxe/Ia32/IoFifo.S
deleted file mode 100644
index 03a014de0c..0000000000
--- a/OvmfPkg/PciHostBridgeDxe/Ia32/IoFifo.S
+++ /dev/null
@@ -1,134 +0,0 @@
-#------------------------------------------------------------------------------
-#
-# Copyright (c) 2006 - 2012, Intel Corporation. All rights reserved.<BR>
-#
-# This program and the accompanying materials are licensed and made available
-# under the terms and conditions of the BSD License which accompanies this
-# distribution. The full text of the license may be found at
-# http://opensource.org/licenses/bsd-license.php.
-#
-# THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
-# WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
-#
-#------------------------------------------------------------------------------
-
-#------------------------------------------------------------------------------
-# VOID
-# EFIAPI
-# IoReadFifo8 (
-# IN UINTN Port,
-# IN UINTN Count,
-# IN VOID *Buffer
-# );
-#------------------------------------------------------------------------------
-ASM_GLOBAL ASM_PFX(IoReadFifo8)
-ASM_PFX(IoReadFifo8):
- push %edi
- cld
- movw 8(%esp), %dx
- mov 12(%esp), %ecx
- mov 16(%esp), %edi
-rep insb
- pop %edi
- ret
-
-#------------------------------------------------------------------------------
-# VOID
-# EFIAPI
-# IoReadFifo16 (
-# IN UINTN Port,
-# IN UINTN Count,
-# IN VOID *Buffer
-# );
-#------------------------------------------------------------------------------
-ASM_GLOBAL ASM_PFX(IoReadFifo16)
-ASM_PFX(IoReadFifo16):
- push %edi
- cld
- movw 8(%esp), %dx
- mov 12(%esp), %ecx
- mov 16(%esp), %edi
-rep insw
- pop %edi
- ret
-
-#------------------------------------------------------------------------------
-# VOID
-# EFIAPI
-# IoReadFifo32 (
-# IN UINTN Port,
-# IN UINTN Count,
-# IN VOID *Buffer
-# );
-#------------------------------------------------------------------------------
-ASM_GLOBAL ASM_PFX(IoReadFifo32)
-ASM_PFX(IoReadFifo32):
- push %edi
- cld
- movw 8(%esp), %dx
- mov 12(%esp), %ecx
- mov 16(%esp), %edi
-rep insl
- pop %edi
- ret
-
-#------------------------------------------------------------------------------
-# VOID
-# EFIAPI
-# IoWriteFifo8 (
-# IN UINTN Port,
-# IN UINTN Count,
-# IN VOID *Buffer
-# );
-#------------------------------------------------------------------------------
-ASM_GLOBAL ASM_PFX(IoWriteFifo8)
-ASM_PFX(IoWriteFifo8):
- push %esi
- cld
- movw 8(%esp), %dx
- mov 12(%esp), %ecx
- mov 16(%esp), %esi
-rep outsb
- pop %esi
- ret
-
-#------------------------------------------------------------------------------
-# VOID
-# EFIAPI
-# IoWriteFifo16 (
-# IN UINTN Port,
-# IN UINTN Count,
-# IN VOID *Buffer
-# );
-#------------------------------------------------------------------------------
-ASM_GLOBAL ASM_PFX(IoWriteFifo16)
-ASM_PFX(IoWriteFifo16):
- push %esi
- cld
- movw 8(%esp), %dx
- mov 12(%esp), %ecx
- mov 16(%esp), %esi
-rep outsw
- pop %esi
- ret
-
-#------------------------------------------------------------------------------
-# VOID
-# EFIAPI
-# IoWriteFifo32 (
-# IN UINTN Port,
-# IN UINTN Count,
-# IN VOID *Buffer
-# );
-#------------------------------------------------------------------------------
-ASM_GLOBAL ASM_PFX(IoWriteFifo32)
-ASM_PFX(IoWriteFifo32):
- push %esi
- cld
- movw 8(%esp), %dx
- mov 12(%esp), %ecx
- mov 16(%esp), %esi
-rep outsl
- pop %esi
- ret
-
diff --git a/OvmfPkg/PciHostBridgeDxe/Ia32/IoFifo.asm b/OvmfPkg/PciHostBridgeDxe/Ia32/IoFifo.asm
deleted file mode 100644
index b1cc25eeb6..0000000000
--- a/OvmfPkg/PciHostBridgeDxe/Ia32/IoFifo.asm
+++ /dev/null
@@ -1,140 +0,0 @@
-;------------------------------------------------------------------------------
-;
-; Copyright (c) 2006 - 2012, Intel Corporation. All rights reserved.<BR>
-;
-; This program and the accompanying materials are licensed and made available
-; under the terms and conditions of the BSD License which accompanies this
-; distribution. The full text of the license may be found at
-; http://opensource.org/licenses/bsd-license.php.
-;
-; THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
-; WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
-;
-;------------------------------------------------------------------------------
-
- .586P
- .model flat,C
- .code
-
-;------------------------------------------------------------------------------
-; VOID
-; EFIAPI
-; IoReadFifo8 (
-; IN UINTN Port,
-; IN UINTN Size,
-; IN VOID *Buffer
-; );
-;------------------------------------------------------------------------------
-IoReadFifo8 PROC
- push edi
- cld
- mov dx, [esp + 8]
- mov ecx, [esp + 12]
- mov edi, [esp + 16]
-rep insb
- pop edi
- ret
-IoReadFifo8 ENDP
-
-;------------------------------------------------------------------------------
-; VOID
-; EFIAPI
-; IoReadFifo16 (
-; IN UINTN Port,
-; IN UINTN Size,
-; IN VOID *Buffer
-; );
-;------------------------------------------------------------------------------
-IoReadFifo16 PROC
- push edi
- cld
- mov dx, [esp + 8]
- mov ecx, [esp + 12]
- mov edi, [esp + 16]
-rep insw
- pop edi
- ret
-IoReadFifo16 ENDP
-
-;------------------------------------------------------------------------------
-; VOID
-; EFIAPI
-; IoReadFifo32 (
-; IN UINTN Port,
-; IN UINTN Size,
-; IN VOID *Buffer
-; );
-;------------------------------------------------------------------------------
-IoReadFifo32 PROC
- push edi
- cld
- mov dx, [esp + 8]
- mov ecx, [esp + 12]
- mov edi, [esp + 16]
-rep insd
- pop edi
- ret
-IoReadFifo32 ENDP
-
-;------------------------------------------------------------------------------
-; VOID
-; EFIAPI
-; IoWriteFifo8 (
-; IN UINTN Port,
-; IN UINTN Size,
-; IN VOID *Buffer
-; );
-;------------------------------------------------------------------------------
-IoWriteFifo8 PROC
- push esi
- cld
- mov dx, [esp + 8]
- mov ecx, [esp + 12]
- mov esi, [esp + 16]
-rep outsb
- pop esi
- ret
-IoWriteFifo8 ENDP
-
-;------------------------------------------------------------------------------
-; VOID
-; EFIAPI
-; IoWriteFifo16 (
-; IN UINTN Port,
-; IN UINTN Size,
-; IN VOID *Buffer
-; );
-;------------------------------------------------------------------------------
-IoWriteFifo16 PROC
- push esi
- cld
- mov dx, [esp + 8]
- mov ecx, [esp + 12]
- mov esi, [esp + 16]
-rep outsw
- pop esi
- ret
-IoWriteFifo16 ENDP
-
-;------------------------------------------------------------------------------
-; VOID
-; EFIAPI
-; IoWriteFifo32 (
-; IN UINTN Port,
-; IN UINTN Size,
-; IN VOID *Buffer
-; );
-;------------------------------------------------------------------------------
-IoWriteFifo32 PROC
- push esi
- cld
- mov dx, [esp + 8]
- mov ecx, [esp + 12]
- mov esi, [esp + 16]
-rep outsd
- pop esi
- ret
-IoWriteFifo32 ENDP
-
- END
-
diff --git a/OvmfPkg/PciHostBridgeDxe/IoFifo.h b/OvmfPkg/PciHostBridgeDxe/IoFifo.h
deleted file mode 100644
index 9978f8bfc3..0000000000
--- a/OvmfPkg/PciHostBridgeDxe/IoFifo.h
+++ /dev/null
@@ -1,176 +0,0 @@
-/** @file
- I/O FIFO routines
-
- Copyright (c) 2008 - 2012, Intel Corporation. All rights reserved.<BR>
-
- This program and the accompanying materials are licensed and made available
- under the terms and conditions of the BSD License which accompanies this
- distribution. The full text of the license may be found at
- http://opensource.org/licenses/bsd-license.php
-
- 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 _IO_FIFO_H_INCLUDED_
-#define _IO_FIFO_H_INCLUDED_
-
-/**
- Reads an 8-bit I/O port fifo into a block of memory.
-
- Reads the 8-bit I/O fifo port specified by Port.
-
- The port is read Count times, and the read data is
- stored in the provided Buffer.
-
- This function must guarantee that all I/O read and write operations are
- serialized.
-
- If 8-bit I/O port operations are not supported, then ASSERT().
-
- @param Port The I/O port to read.
- @param Count The number of times to read I/O port.
- @param Buffer The buffer to store the read data into.
-
-**/
-VOID
-EFIAPI
-IoReadFifo8 (
- IN UINTN Port,
- IN UINTN Count,
- OUT VOID *Buffer
- );
-
-/**
- Reads a 16-bit I/O port fifo into a block of memory.
-
- Reads the 16-bit I/O fifo port specified by Port.
-
- The port is read Count times, and the read data is
- stored in the provided Buffer.
-
- This function must guarantee that all I/O read and write operations are
- serialized.
-
- If 16-bit I/O port operations are not supported, then ASSERT().
-
- @param Port The I/O port to read.
- @param Count The number of times to read I/O port.
- @param Buffer The buffer to store the read data into.
-
-**/
-VOID
-EFIAPI
-IoReadFifo16 (
- IN UINTN Port,
- IN UINTN Count,
- OUT VOID *Buffer
- );
-
-/**
- Reads a 32-bit I/O port fifo into a block of memory.
-
- Reads the 32-bit I/O fifo port specified by Port.
-
- The port is read Count times, and the read data is
- stored in the provided Buffer.
-
- This function must guarantee that all I/O read and write operations are
- serialized.
-
- If 32-bit I/O port operations are not supported, then ASSERT().
-
- @param Port The I/O port to read.
- @param Count The number of times to read I/O port.
- @param Buffer The buffer to store the read data into.
-
-**/
-VOID
-EFIAPI
-IoReadFifo32 (
- IN UINTN Port,
- IN UINTN Count,
- OUT VOID *Buffer
- );
-
-/**
- Writes a block of memory into an 8-bit I/O port fifo.
-
- Writes the 8-bit I/O fifo port specified by Port.
-
- The port is written Count times, and the write data is
- retrieved from the provided Buffer.
-
- This function must guarantee that all I/O write and write operations are
- serialized.
-
- If 8-bit I/O port operations are not supported, then ASSERT().
-
- @param Port The I/O port to write.
- @param Count The number of times to write I/O port.
- @param Buffer The buffer to store the write data into.
-
-**/
-VOID
-EFIAPI
-IoWriteFifo8 (
- IN UINTN Port,
- IN UINTN Count,
- OUT VOID *Buffer
- );
-
-/**
- Writes a block of memory into a 16-bit I/O port fifo.
-
- Writes the 16-bit I/O fifo port specified by Port.
-
- The port is written Count times, and the write data is
- retrieved from the provided Buffer.
-
- This function must guarantee that all I/O write and write operations are
- serialized.
-
- If 16-bit I/O port operations are not supported, then ASSERT().
-
- @param Port The I/O port to write.
- @param Count The number of times to write I/O port.
- @param Buffer The buffer to store the write data into.
-
-**/
-VOID
-EFIAPI
-IoWriteFifo16 (
- IN UINTN Port,
- IN UINTN Count,
- OUT VOID *Buffer
- );
-
-/**
- Writes a block of memory into a 32-bit I/O port fifo.
-
- Writes the 32-bit I/O fifo port specified by Port.
-
- The port is written Count times, and the write data is
- retrieved from the provided Buffer.
-
- This function must guarantee that all I/O write and write operations are
- serialized.
-
- If 32-bit I/O port operations are not supported, then ASSERT().
-
- @param Port The I/O port to write.
- @param Count The number of times to write I/O port.
- @param Buffer The buffer to store the write data into.
-
-**/
-VOID
-EFIAPI
-IoWriteFifo32 (
- IN UINTN Port,
- IN UINTN Count,
- OUT VOID *Buffer
- );
-
-#endif
-
diff --git a/OvmfPkg/PciHostBridgeDxe/PciHostBridge.c b/OvmfPkg/PciHostBridgeDxe/PciHostBridge.c
deleted file mode 100644
index efef2ed79e..0000000000
--- a/OvmfPkg/PciHostBridgeDxe/PciHostBridge.c
+++ /dev/null
@@ -1,1551 +0,0 @@
-/** @file
- Provides the basic interfaces to abstract a PCI Host Bridge Resource
- Allocation
-
- Copyright (C) 2015, Red Hat, Inc.
- Copyright (c) 2008 - 2013, Intel Corporation. All rights reserved.<BR>
-
- This program and the accompanying materials are licensed and made available
- under the terms and conditions of the BSD License which accompanies this
- distribution. The full text of the license may be found at
- http://opensource.org/licenses/bsd-license.php
-
- THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
- WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
-
-**/
-
-#include <Library/QemuFwCfgLib.h>
-
-#include "PciHostBridge.h"
-
-STATIC
-CONST
-EFI_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
- }
- }
-};
-
-EFI_HANDLE mDriverImageHandle;
-
-PCI_HOST_BRIDGE_INSTANCE mPciHostBridgeInstanceTemplate = {
- PCI_HOST_BRIDGE_SIGNATURE, // Signature
- NULL, // HostBridgeHandle
- {NULL, NULL}, // Head
- FALSE, // ResourceSubiteed
- TRUE, // CanRestarted
- {
- NotifyPhase,
- GetNextRootBridge,
- GetAttributes,
- StartBusEnumeration,
- SetBusNumbers,
- SubmitResources,
- GetProposedResources,
- PreprocessController
- }
-};
-
-//
-// Implementation
-//
-
-/**
- Allocate and initialize a root bridge.
-
- param[in] RootBusNumber The bus number of the root bus (root bridge) to
- create.
-
- 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] HostBridgeHandle The EFI_HANDLE corresponding to the host bridge
- that is the parent of the root bridge to create.
- HostBridgeHandle is expected to have
- EFI_PCI_HOST_BRIDGE_RESOURCE_ALLOCATION_PROTOCOL
- installed on it.
-
- param[out] RootBus The private PCI_ROOT_BRIDGE_INSTANCE that has
- been created as the result of the function call.
-
- @retval EFI_SUCCESS Initialization successful. A new
- EFI_PCI_ROOT_BRIDGE_IO_PROTOCOL has been
- created as the child of HostBridgeHandle. A
- device path consisting of an ACPI device path
- node, with UID = RootBusNumber, has been
- installed on the same new handle.
-
- @retval EFI_OUT_OF_RESOURCES Memory allocation failed.
-
- @return Error codes from
- gBS->InstallMultipleProtocolInterfaces().
-**/
-STATIC
-EFI_STATUS
-InitRootBridge (
- IN UINT8 RootBusNumber,
- IN UINT8 MaxSubBusNumber,
- IN EFI_HANDLE HostBridgeHandle,
- OUT PCI_ROOT_BRIDGE_INSTANCE **RootBus
- )
-{
- PCI_ROOT_BRIDGE_INSTANCE *PrivateData;
- PCI_ROOT_BRIDGE_RESOURCE_APERTURE ResAperture;
- EFI_STATUS Status;
-
- ASSERT (RootBusNumber <= MaxSubBusNumber);
-
- PrivateData = AllocateZeroPool (sizeof *PrivateData);
- if (PrivateData == NULL) {
- return EFI_OUT_OF_RESOURCES;
- }
-
- PrivateData->Signature = PCI_ROOT_BRIDGE_SIGNATURE;
-
- CopyMem (&PrivateData->DevicePath, &mRootBridgeDevicePathTemplate,
- sizeof mRootBridgeDevicePathTemplate);
- PrivateData->DevicePath.AcpiDevicePath.UID = RootBusNumber;
-
- ResAperture.BusBase = RootBusNumber;
- ResAperture.BusLimit = MaxSubBusNumber;
- ResAperture.MemBase = BASE_2GB;
- ResAperture.MemLimit = BASE_4GB - 1;
- ResAperture.IoBase = 0;
- ResAperture.IoLimit = MAX_UINT16;
- //
- // The function call below allocates no resources and performs no actions
- // that have to be rolled back on later failure. It always succeeds.
- //
- Status = RootBridgeConstructor (&PrivateData->Io, HostBridgeHandle,
- EFI_PCI_HOST_BRIDGE_COMBINE_MEM_PMEM, &ResAperture);
- ASSERT_EFI_ERROR (Status);
-
- Status = gBS->InstallMultipleProtocolInterfaces (&PrivateData->Handle,
- &gEfiDevicePathProtocolGuid, &PrivateData->DevicePath,
- &gEfiPciRootBridgeIoProtocolGuid, &PrivateData->Io,
- NULL);
- if (EFI_ERROR (Status)) {
- goto FreePrivateData;
- }
-
- DEBUG ((EFI_D_INFO,
- "%a: installed root bus %d, with room for %d subordinate bus(es)\n",
- __FUNCTION__, RootBusNumber, MaxSubBusNumber - RootBusNumber));
- *RootBus = PrivateData;
- return EFI_SUCCESS;
-
-FreePrivateData:
- FreePool (PrivateData);
- return Status;
-}
-
-
-/**
- Uninitialize and free a root bridge set up with InitRootBridge().
-
- On return, the EFI_PCI_ROOT_BRIDGE_IO_PROTOCOL instance and the device path
- will have been released, freeing RootBus->Handle as well.
-
- param[in] RootBus The private PCI_ROOT_BRIDGE_INSTANCE that has been created
- with InitRootBridge(), and should be released.
-**/
-STATIC
-VOID
-UninitRootBridge (
- IN PCI_ROOT_BRIDGE_INSTANCE *RootBus
- )
-{
- EFI_STATUS Status;
-
- Status = gBS->UninstallMultipleProtocolInterfaces (RootBus->Handle,
- &gEfiDevicePathProtocolGuid, &RootBus->DevicePath,
- &gEfiPciRootBridgeIoProtocolGuid, &RootBus->Io,
- NULL);
- ASSERT_EFI_ERROR (Status);
- FreePool (RootBus);
-}
-
-
-/**
- Entry point of this driver
-
- @param ImageHandle Handle of driver image
- @param SystemTable Point to EFI_SYSTEM_TABLE
-
- @retval EFI_OUT_OF_RESOURCES Can not allocate memory resource
- @retval EFI_DEVICE_ERROR Can not install the protocol instance
- @retval EFI_SUCCESS Success to initialize the Pci host bridge.
-**/
-EFI_STATUS
-EFIAPI
-InitializePciHostBridge (
- IN EFI_HANDLE ImageHandle,
- IN EFI_SYSTEM_TABLE *SystemTable
- )
-{
- EFI_STATUS Status;
- FIRMWARE_CONFIG_ITEM FwCfgItem;
- UINTN FwCfgSize;
- UINT64 ExtraRootBridgesLeft;
- UINTN LastRootBridgeNumber;
- UINTN RootBridgeNumber;
- PCI_HOST_BRIDGE_INSTANCE *HostBridge;
- PCI_ROOT_BRIDGE_INSTANCE *RootBus;
- EFI_STATUS UninstallStatus;
-
- mDriverImageHandle = ImageHandle;
-
- //
- // Create Host Bridge Device Handle
- //
- HostBridge = AllocateCopyPool (sizeof(PCI_HOST_BRIDGE_INSTANCE),
- &mPciHostBridgeInstanceTemplate);
- if (HostBridge == NULL) {
- return EFI_OUT_OF_RESOURCES;
- }
-
- InitializeListHead (&HostBridge->Head);
-
- Status = gBS->InstallMultipleProtocolInterfaces (
- &HostBridge->HostBridgeHandle,
- &gEfiPciHostBridgeResourceAllocationProtocolGuid,
- &HostBridge->ResAlloc,
- NULL
- );
- if (EFI_ERROR (Status)) {
- goto FreeHostBridge;
- }
-
- //
- // 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 ExtraRootBridgesLeft) {
- ExtraRootBridgesLeft = 0;
- } else {
- QemuFwCfgSelectItem (FwCfgItem);
- QemuFwCfgReadBytes (FwCfgSize, &ExtraRootBridgesLeft);
- DEBUG ((EFI_D_INFO, "%a: %Lu extra root buses reported by QEMU\n",
- __FUNCTION__, ExtraRootBridgesLeft));
- }
-
- //
- // 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 < 256 && ExtraRootBridgesLeft > 0;
- ++RootBridgeNumber) {
- UINTN Device;
-
- for (Device = 0; Device <= MAX_PCI_DEVICE_NUMBER; ++Device) {
- if (PciRead16 (PCI_LIB_ADDRESS (RootBridgeNumber, Device, 0,
- PCI_VENDOR_ID_OFFSET)) != MAX_UINT16) {
- break;
- }
- }
- if (Device <= MAX_PCI_DEVICE_NUMBER) {
- //
- // 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 ((UINT8)LastRootBridgeNumber,
- (UINT8)(RootBridgeNumber - 1), HostBridge->HostBridgeHandle,
- &RootBus);
- if (EFI_ERROR (Status)) {
- goto RollbackProtocols;
- }
- InsertTailList (&HostBridge->Head, &RootBus->Link);
- LastRootBridgeNumber = RootBridgeNumber;
- --ExtraRootBridgesLeft;
- }
- }
-
- //
- // Install the last root bus (which might be the only, ie. main, root bus, if
- // we've found no extra root buses).
- //
- Status = InitRootBridge ((UINT8)LastRootBridgeNumber, 255,
- HostBridge->HostBridgeHandle, &RootBus);
- if (EFI_ERROR (Status)) {
- goto RollbackProtocols;
- }
- InsertTailList (&HostBridge->Head, &RootBus->Link);
-
- return EFI_SUCCESS;
-
-RollbackProtocols:
- while (!IsListEmpty (&HostBridge->Head)) {
- LIST_ENTRY *Entry;
-
- Entry = GetFirstNode (&HostBridge->Head);
- RemoveEntryList (Entry);
- RootBus = DRIVER_INSTANCE_FROM_LIST_ENTRY (Entry);
- UninitRootBridge (RootBus);
- }
- UninstallStatus = gBS->UninstallMultipleProtocolInterfaces (
- HostBridge->HostBridgeHandle,
- &gEfiPciHostBridgeResourceAllocationProtocolGuid,
- &HostBridge->ResAlloc,
- NULL
- );
- ASSERT_EFI_ERROR (UninstallStatus);
-
-FreeHostBridge:
- FreePool (HostBridge);
-
- return Status;
-}
-
-
-/**
- These are the notifications from the PCI bus driver that it is about to enter
- a certain phase of the PCI enumeration process.
-
- This member function can be used to notify the host bridge driver to perform
- specific actions, including any chipset-specific initialization, so that the
- chipset is ready to enter the next phase. Eight notification points are
- defined at this time. See belows:
-
- EfiPciHostBridgeBeginEnumeration Resets the host bridge PCI apertures
- and internal data structures. The PCI
- enumerator should issue this
- notification before starting a fresh
- enumeration process. Enumeration
- cannot be restarted after sending any
- other notification such as
- EfiPciHostBridgeBeginBusAllocation.
-
- EfiPciHostBridgeBeginBusAllocation The bus allocation phase is about to
- begin. No specific action is required
- here. This notification can be used to
- perform any chipset-specific
- programming.
-
- EfiPciHostBridgeEndBusAllocation The bus allocation and bus programming
- phase is complete. No specific action
- is required here. This notification
- can be used to perform any
- chipset-specific programming.
-
- EfiPciHostBridgeBeginResourceAllocation
- The resource allocation phase is about
- to begin. No specific action is
- required here. This notification can
- be used to perform any
- chipset-specific programming.
-
- EfiPciHostBridgeAllocateResources Allocates resources per previously
- submitted requests for all the PCI
- root bridges. These resource settings
- are returned on the next call to
- GetProposedResources(). Before calling
- NotifyPhase() with a Phase of
- EfiPciHostBridgeAllocateResource, the
- PCI bus enumerator is responsible for
- gathering I/O and memory requests for
- all the PCI root bridges and
- submitting these requests using
- SubmitResources(). This function pads
- the resource amount to suit the root
- bridge hardware, takes care of
- dependencies between the PCI root
- bridges, and calls the Global
- Coherency Domain (GCD) with the
- allocation request. In the case of
- padding, the allocated range could be
- bigger than what was requested.
-
- EfiPciHostBridgeSetResources Programs the host bridge hardware to
- decode previously allocated resources
- (proposed resources) for all the PCI
- root bridges. After the hardware is
- programmed, reassigning resources will
- not be supported. The bus settings are
- not affected.
-
- EfiPciHostBridgeFreeResources Deallocates resources that were
- previously allocated for all the PCI
- root bridges and resets the I/O and
- memory apertures to their initial
- state. The bus settings are not
- affected. If the request to allocate
- resources fails, the PCI enumerator
- can use this notification to
- deallocate previous resources, adjust
- the requests, and retry allocation.
-
- EfiPciHostBridgeEndResourceAllocation The resource allocation phase is
- completed. No specific action is
- required here. This notification can
- be used to perform any chipsetspecific
- programming.
-
- @param[in] This The instance pointer of
- EFI_PCI_HOST_BRIDGE_RESOURCE_ALLOCATION_PROTOCOL
-
- @param[in] Phase The phase during enumeration
-
- @retval EFI_NOT_READY This phase cannot be entered at this time. For
- example, this error is valid for a Phase of
- EfiPciHostBridgeAllocateResources if
- SubmitResources() has not been called for one
- or more PCI root bridges before this call
-
- @retval EFI_DEVICE_ERROR Programming failed due to a hardware error.
- This error is valid for a Phase of
- EfiPciHostBridgeSetResources.
-
- @retval EFI_INVALID_PARAMETER Invalid phase parameter
-
- @retval EFI_OUT_OF_RESOURCES The request could not be completed due to a
- lack of resources. This error is valid for a
- Phase of EfiPciHostBridgeAllocateResources if
- the previously submitted resource requests
- cannot be fulfilled or were only partially
- fulfilled.
-
- @retval EFI_SUCCESS The notification was accepted without any
- errors.
-**/
-EFI_STATUS
-EFIAPI
-NotifyPhase(
- IN EFI_PCI_HOST_BRIDGE_RESOURCE_ALLOCATION_PROTOCOL *This,
- IN EFI_PCI_HOST_BRIDGE_RESOURCE_ALLOCATION_PHASE Phase
- )
-{
- PCI_HOST_BRIDGE_INSTANCE *HostBridgeInstance;
- PCI_ROOT_BRIDGE_INSTANCE *RootBridgeInstance;
- PCI_RESOURCE_TYPE Index;
- LIST_ENTRY *List;
- EFI_PHYSICAL_ADDRESS BaseAddress;
- UINT64 AddrLen;
- UINTN BitsOfAlignment;
- EFI_STATUS Status;
- EFI_STATUS ReturnStatus;
-
- HostBridgeInstance = INSTANCE_FROM_RESOURCE_ALLOCATION_THIS (This);
-
- switch (Phase) {
-
- case EfiPciHostBridgeBeginEnumeration:
- if (HostBridgeInstance->CanRestarted) {
- //
- // Reset the Each Root Bridge
- //
- List = HostBridgeInstance->Head.ForwardLink;
-
- while (List != &HostBridgeInstance->Head) {
- RootBridgeInstance = DRIVER_INSTANCE_FROM_LIST_ENTRY (List);
- for (Index = TypeIo; Index < TypeMax; Index++) {
- RootBridgeInstance->ResAllocNode[Index].Type = Index;
- RootBridgeInstance->ResAllocNode[Index].Base = 0;
- RootBridgeInstance->ResAllocNode[Index].Length = 0;
- RootBridgeInstance->ResAllocNode[Index].Status = ResNone;
- }
-
- List = List->ForwardLink;
- }
-
- HostBridgeInstance->ResourceSubmited = FALSE;
- HostBridgeInstance->CanRestarted = TRUE;
- } else {
- //
- // Can not restart
- //
- return EFI_NOT_READY;
- }
- break;
-
- case EfiPciHostBridgeEndEnumeration:
- break;
-
- case EfiPciHostBridgeBeginBusAllocation:
- //
- // No specific action is required here, can perform any chipset specific
- // programing
- //
- HostBridgeInstance->CanRestarted = FALSE;
- break;
-
- case EfiPciHostBridgeEndBusAllocation:
- //
- // No specific action is required here, can perform any chipset specific
- // programing
- //
- //HostBridgeInstance->CanRestarted = FALSE;
- break;
-
- case EfiPciHostBridgeBeginResourceAllocation:
- //
- // No specific action is required here, can perform any chipset specific
- // programing
- //
- //HostBridgeInstance->CanRestarted = FALSE;
- break;
-
- case EfiPciHostBridgeAllocateResources:
- ReturnStatus = EFI_SUCCESS;
- if (HostBridgeInstance->ResourceSubmited) {
- //
- // Take care of the resource dependencies between the root bridges
- //
- List = HostBridgeInstance->Head.ForwardLink;
-
- while (List != &HostBridgeInstance->Head) {
- RootBridgeInstance = DRIVER_INSTANCE_FROM_LIST_ENTRY (List);
- for (Index = TypeIo; Index < TypeBus; Index++) {
- if (RootBridgeInstance->ResAllocNode[Index].Status != ResNone) {
-
- AddrLen = RootBridgeInstance->ResAllocNode[Index].Length;
-
- //
- // Get the number of '1' in Alignment.
- //
- BitsOfAlignment =
- (UINTN)(HighBitSet64 (
- RootBridgeInstance->ResAllocNode[Index].Alignment
- ) + 1);
-
- switch (Index) {
-
- case TypeIo:
- //
- // It is impossible for this chipset to align 0xFFFF for IO16
- // So clear it
- //
- if (BitsOfAlignment >= 16) {
- BitsOfAlignment = 0;
- }
-
- Status = gDS->AllocateIoSpace (
- EfiGcdAllocateAnySearchBottomUp,
- EfiGcdIoTypeIo,
- BitsOfAlignment,
- AddrLen,
- &BaseAddress,
- mDriverImageHandle,
- NULL
- );
-
- if (!EFI_ERROR (Status)) {
- RootBridgeInstance->ResAllocNode[Index].Base =
- (UINTN)BaseAddress;
- RootBridgeInstance->ResAllocNode[Index].Status =
- ResAllocated;
- } else {
- ReturnStatus = Status;
- if (Status != EFI_OUT_OF_RESOURCES) {
- RootBridgeInstance->ResAllocNode[Index].Length = 0;
- }
- }
-
- break;
-
-
- case TypeMem32:
- //
- // It is impossible for this chipset to align 0xFFFFFFFF for
- // Mem32
- // So clear it
- //
-
- if (BitsOfAlignment >= 32) {
- BitsOfAlignment = 0;
- }
-
- Status = gDS->AllocateMemorySpace (
- EfiGcdAllocateAnySearchBottomUp,
- EfiGcdMemoryTypeMemoryMappedIo,
- BitsOfAlignment,
- AddrLen,
- &BaseAddress,
- mDriverImageHandle,
- NULL
- );
-
- if (!EFI_ERROR (Status)) {
- // We were able to allocate the PCI memory
- RootBridgeInstance->ResAllocNode[Index].Base =
- (UINTN)BaseAddress;
- RootBridgeInstance->ResAllocNode[Index].Status =
- ResAllocated;
-
- } else {
- // Not able to allocate enough PCI memory
- ReturnStatus = Status;
-
- if (Status != EFI_OUT_OF_RESOURCES) {
- RootBridgeInstance->ResAllocNode[Index].Length = 0;
- }
- ASSERT (FALSE);
- }
- break;
-
- case TypePMem32:
- case TypeMem64:
- case TypePMem64:
- ReturnStatus = EFI_ABORTED;
- break;
- default:
- ASSERT (FALSE);
- break;
- }; //end switch
- }
- }
-
- List = List->ForwardLink;
- }
-
- return ReturnStatus;
-
- } else {
- return EFI_NOT_READY;
- }
- break;
-
- case EfiPciHostBridgeSetResources:
- break;
-
- case EfiPciHostBridgeFreeResources:
- ReturnStatus = EFI_SUCCESS;
- List = HostBridgeInstance->Head.ForwardLink;
- while (List != &HostBridgeInstance->Head) {
- RootBridgeInstance = DRIVER_INSTANCE_FROM_LIST_ENTRY (List);
- for (Index = TypeIo; Index < TypeBus; Index++) {
- if (RootBridgeInstance->ResAllocNode[Index].Status == ResAllocated) {
- AddrLen = RootBridgeInstance->ResAllocNode[Index].Length;
- BaseAddress = RootBridgeInstance->ResAllocNode[Index].Base;
- switch (Index) {
-
- case TypeIo:
- Status = gDS->FreeIoSpace (BaseAddress, AddrLen);
- if (EFI_ERROR (Status)) {
- ReturnStatus = Status;
- }
- break;
-
- case TypeMem32:
- Status = gDS->FreeMemorySpace (BaseAddress, AddrLen);
- if (EFI_ERROR (Status)) {
- ReturnStatus = Status;
- }
- break;
-
- case TypePMem32:
- break;
-
- case TypeMem64:
- break;
-
- case TypePMem64:
- break;
-
- default:
- ASSERT (FALSE);
- break;
-
- }; //end switch
- RootBridgeInstance->ResAllocNode[Index].Type = Index;
- RootBridgeInstance->ResAllocNode[Index].Base = 0;
- RootBridgeInstance->ResAllocNode[Index].Length = 0;
- RootBridgeInstance->ResAllocNode[Index].Status = ResNone;
- }
- }
-
- List = List->ForwardLink;
- }
-
- HostBridgeInstance->ResourceSubmited = FALSE;
- HostBridgeInstance->CanRestarted = TRUE;
- return ReturnStatus;
-
- case EfiPciHostBridgeEndResourceAllocation:
- HostBridgeInstance->CanRestarted = FALSE;
- break;
-
- default:
- return EFI_INVALID_PARAMETER;
- }
-
- return EFI_SUCCESS;
-}
-
-/**
- Return the device handle of the next PCI root bridge that is associated with
- this Host Bridge.
-
- This function is called multiple times to retrieve the device handles of all
- the PCI root bridges that are associated with this PCI host bridge. Each PCI
- host bridge is associated with one or more PCI root bridges. On each call,
- the handle that was returned by the previous call is passed into the
- interface, and on output the interface returns the device handle of the next
- PCI root bridge. The caller can use the handle to obtain the instance of the
- EFI_PCI_ROOT_BRIDGE_IO_PROTOCOL for that root bridge. When there are no more
- PCI root bridges to report, the interface returns EFI_NOT_FOUND. A PCI
- enumerator must enumerate the PCI root bridges in the order that they are
- returned by this function.
-
- For D945 implementation, there is only one root bridge in PCI host bridge.
-
- @param[in] This The instance pointer of
- EFI_PCI_HOST_BRIDGE_RESOURCE_ALLOCATION_PROTOCOL
-
- @param[in, out] RootBridgeHandle Returns the device handle of the next PCI
- root bridge.
-
- @retval EFI_SUCCESS If parameter RootBridgeHandle = NULL, then
- return the first Rootbridge handle of the
- specific Host bridge and return EFI_SUCCESS.
-
- @retval EFI_NOT_FOUND Can not find the any more root bridge in
- specific host bridge.
-
- @retval EFI_INVALID_PARAMETER RootBridgeHandle is not an EFI_HANDLE that was
- returned on a previous call to
- GetNextRootBridge().
-**/
-EFI_STATUS
-EFIAPI
-GetNextRootBridge(
- IN EFI_PCI_HOST_BRIDGE_RESOURCE_ALLOCATION_PROTOCOL *This,
- IN OUT EFI_HANDLE *RootBridgeHandle
- )
-{
- BOOLEAN NoRootBridge;
- LIST_ENTRY *List;
- PCI_HOST_BRIDGE_INSTANCE *HostBridgeInstance;
- PCI_ROOT_BRIDGE_INSTANCE *RootBridgeInstance;
-
- NoRootBridge = TRUE;
- HostBridgeInstance = INSTANCE_FROM_RESOURCE_ALLOCATION_THIS (This);
- List = HostBridgeInstance->Head.ForwardLink;
-
-
- while (List != &HostBridgeInstance->Head) {
- NoRootBridge = FALSE;
- RootBridgeInstance = DRIVER_INSTANCE_FROM_LIST_ENTRY (List);
- if (*RootBridgeHandle == NULL) {
- //
- // Return the first Root Bridge Handle of the Host Bridge
- //
- *RootBridgeHandle = RootBridgeInstance->Handle;
- return EFI_SUCCESS;
- } else {
- if (*RootBridgeHandle == RootBridgeInstance->Handle) {
- //
- // Get next if have
- //
- List = List->ForwardLink;
- if (List!=&HostBridgeInstance->Head) {
- RootBridgeInstance = DRIVER_INSTANCE_FROM_LIST_ENTRY (List);
- *RootBridgeHandle = RootBridgeInstance->Handle;
- return EFI_SUCCESS;
- } else {
- return EFI_NOT_FOUND;
- }
- }
- }
-
- List = List->ForwardLink;
- } //end while
-
- if (NoRootBridge) {
- return EFI_NOT_FOUND;
- } else {
- return EFI_INVALID_PARAMETER;
- }
-}
-
-/**
- Returns the allocation attributes of a PCI root bridge.
-
- The function returns the allocation attributes of a specific PCI root bridge.
- The attributes can vary from one PCI root bridge to another. These attributes
- are different from the decode-related attributes that are returned by the
- EFI_PCI_ROOT_BRIDGE_IO_PROTOCOL.GetAttributes() member function. The
- RootBridgeHandle parameter is used to specify the instance of the PCI root
- bridge. The device handles of all the root bridges that are associated with
- this host bridge must be obtained by calling GetNextRootBridge(). The
- attributes are static in the sense that they do not change during or after
- the enumeration process. The hardware may provide mechanisms to change the
- attributes on the fly, but such changes must be completed before
- EFI_PCI_HOST_BRIDGE_RESOURCE_ALLOCATION_PROTOCOL is installed. The permitted
- values of EFI_PCI_HOST_BRIDGE_RESOURCE_ALLOCATION_ATTRIBUTES are defined in
- "Related Definitions" below. The caller uses these attributes to combine
- multiple resource requests.
-
- For example, if the flag EFI_PCI_HOST_BRIDGE_COMBINE_MEM_PMEM is set, the PCI
- bus enumerator needs to include requests for the prefetchable memory in the
- nonprefetchable memory pool and not request any prefetchable memory.
-
- Attribute Description
- ------------------------------------ ---------------------------------------
- EFI_PCI_HOST_BRIDGE_COMBINE_MEM_PMEM If this bit is set, then the PCI root
- bridge does not support separate
- windows for nonprefetchable and
- prefetchable memory. A PCI bus driver
- needs to include requests for
- prefetchable memory in the
- nonprefetchable memory pool.
-
- EFI_PCI_HOST_BRIDGE_MEM64_DECODE If this bit is set, then the PCI root
- bridge supports 64-bit memory windows.
- If this bit is not set, the PCI bus
- driver needs to include requests for a
- 64-bit memory address in the
- corresponding 32-bit memory pool.
-
- @param[in] This The instance pointer of
- EFI_PCI_HOST_BRIDGE_RESOURCE_ALLOCATION_PROTOCOL
-
- @param[in] RootBridgeHandle The device handle of the PCI root bridge in
- which the caller is interested. Type
- EFI_HANDLE is defined in
- InstallProtocolInterface() in the UEFI 2.0
- Specification.
-
- @param[out] Attributes The pointer to attribte of root bridge, it is
- output parameter
-
- @retval EFI_INVALID_PARAMETER Attribute pointer is NULL
-
- @retval EFI_INVALID_PARAMETER RootBridgehandle is invalid.
-
- @retval EFI_SUCCESS Success to get attribute of interested root
- bridge.
-**/
-EFI_STATUS
-EFIAPI
-GetAttributes(
- IN EFI_PCI_HOST_BRIDGE_RESOURCE_ALLOCATION_PROTOCOL *This,
- IN EFI_HANDLE RootBridgeHandle,
- OUT UINT64 *Attributes
- )
-{
- LIST_ENTRY *List;
- PCI_HOST_BRIDGE_INSTANCE *HostBridgeInstance;
- PCI_ROOT_BRIDGE_INSTANCE *RootBridgeInstance;
-
- if (Attributes == NULL) {
- return EFI_INVALID_PARAMETER;
- }
-
- HostBridgeInstance = INSTANCE_FROM_RESOURCE_ALLOCATION_THIS (This);
- List = HostBridgeInstance->Head.ForwardLink;
-
- while (List != &HostBridgeInstance->Head) {
- RootBridgeInstance = DRIVER_INSTANCE_FROM_LIST_ENTRY (List);
- if (RootBridgeHandle == RootBridgeInstance->Handle) {
- *Attributes = RootBridgeInstance->RootBridgeAttrib;
- return EFI_SUCCESS;
- }
- List = List->ForwardLink;
- }
-
- //
- // RootBridgeHandle is not an EFI_HANDLE
- // that was returned on a previous call to GetNextRootBridge()
- //
- return EFI_INVALID_PARAMETER;
-}
-
-/**
- Sets up the specified PCI root bridge for the bus enumeration process.
-
- This member function sets up the root bridge for bus enumeration and returns
- the PCI bus range over which the search should be performed in ACPI 2.0
- resource descriptor format.
-
- @param[in] This The
- EFI_PCI_HOST_BRIDGE_RESOURCE_ALLOCATION_PROTOCOL
- instance.
-
- @param[in] RootBridgeHandle The PCI Root Bridge to be set up.
-
- @param[out] Configuration Pointer to the pointer to the PCI bus resource
- descriptor.
-
- @retval EFI_INVALID_PARAMETER Invalid Root bridge's handle
-
- @retval EFI_OUT_OF_RESOURCES Fail to allocate ACPI resource descriptor tag.
-
- @retval EFI_SUCCESS Sucess to allocate ACPI resource descriptor.
-**/
-EFI_STATUS
-EFIAPI
-StartBusEnumeration(
- IN EFI_PCI_HOST_BRIDGE_RESOURCE_ALLOCATION_PROTOCOL *This,
- IN EFI_HANDLE RootBridgeHandle,
- OUT VOID **Configuration
- )
-{
- LIST_ENTRY *List;
- PCI_HOST_BRIDGE_INSTANCE *HostBridgeInstance;
- PCI_ROOT_BRIDGE_INSTANCE *RootBridgeInstance;
- VOID *Buffer;
- UINT8 *Temp;
- UINT64 BusStart;
- UINT64 BusEnd;
-
- HostBridgeInstance = INSTANCE_FROM_RESOURCE_ALLOCATION_THIS (This);
- List = HostBridgeInstance->Head.ForwardLink;
-
- while (List != &HostBridgeInstance->Head) {
- RootBridgeInstance = DRIVER_INSTANCE_FROM_LIST_ENTRY (List);
- if (RootBridgeHandle == RootBridgeInstance->Handle) {
- //
- // Set up the Root Bridge for Bus Enumeration
- //
- BusStart = RootBridgeInstance->BusBase;
- BusEnd = RootBridgeInstance->BusLimit;
- //
- // Program the Hardware(if needed) if error return EFI_DEVICE_ERROR
- //
-
- Buffer = AllocatePool (
- sizeof(EFI_ACPI_ADDRESS_SPACE_DESCRIPTOR) +
- sizeof(EFI_ACPI_END_TAG_DESCRIPTOR)
- );
- if (Buffer == NULL) {
- return EFI_OUT_OF_RESOURCES;
- }
-
- Temp = (UINT8 *)Buffer;
-
- ((EFI_ACPI_ADDRESS_SPACE_DESCRIPTOR *)Temp)->Desc = 0x8A;
- ((EFI_ACPI_ADDRESS_SPACE_DESCRIPTOR *)Temp)->Len = 0x2B;
- ((EFI_ACPI_ADDRESS_SPACE_DESCRIPTOR *)Temp)->ResType = 2;
- ((EFI_ACPI_ADDRESS_SPACE_DESCRIPTOR *)Temp)->GenFlag = 0;
- ((EFI_ACPI_ADDRESS_SPACE_DESCRIPTOR *)Temp)->SpecificFlag = 0;
- ((EFI_ACPI_ADDRESS_SPACE_DESCRIPTOR *)Temp)->AddrSpaceGranularity = 0;
- ((EFI_ACPI_ADDRESS_SPACE_DESCRIPTOR *)Temp)->AddrRangeMin = BusStart;
- ((EFI_ACPI_ADDRESS_SPACE_DESCRIPTOR *)Temp)->AddrRangeMax = 0;
- ((EFI_ACPI_ADDRESS_SPACE_DESCRIPTOR *)Temp)->AddrTranslationOffset = 0;
- ((EFI_ACPI_ADDRESS_SPACE_DESCRIPTOR *)Temp)->AddrLen =
- BusEnd - BusStart + 1;
-
- Temp = Temp + sizeof(EFI_ACPI_ADDRESS_SPACE_DESCRIPTOR);
- ((EFI_ACPI_END_TAG_DESCRIPTOR *)Temp)->Desc = 0x79;
- ((EFI_ACPI_END_TAG_DESCRIPTOR *)Temp)->Checksum = 0x0;
-
- *Configuration = Buffer;
- return EFI_SUCCESS;
- }
- List = List->ForwardLink;
- }
-
- return EFI_INVALID_PARAMETER;
-}
-
-/**
- Programs the PCI root bridge hardware so that it decodes the specified PCI
- bus range.
-
- This member function programs the specified PCI root bridge to decode the bus
- range that is specified by the input parameter Configuration.
- The bus range information is specified in terms of the ACPI 2.0 resource
- descriptor format.
-
- @param[in] This The
- EFI_PCI_HOST_BRIDGE_RESOURCE_ALLOCATION_PROTOCOL
- instance
-
- @param[in] RootBridgeHandle The PCI Root Bridge whose bus range is to be
- programmed
-
- @param[in] Configuration The pointer to the PCI bus resource descriptor
-
- @retval EFI_INVALID_PARAMETER RootBridgeHandle is not a valid root bridge
- handle.
-
- @retval EFI_INVALID_PARAMETER Configuration is NULL.
-
- @retval EFI_INVALID_PARAMETER Configuration does not point to a valid ACPI
- 2.0 resource descriptor.
-
- @retval EFI_INVALID_PARAMETER Configuration does not include a valid ACPI
- 2.0 bus resource descriptor.
-
- @retval EFI_INVALID_PARAMETER Configuration includes valid ACPI 2.0 resource
- descriptors other than bus descriptors.
-
- @retval EFI_INVALID_PARAMETER Configuration contains one or more invalid
- ACPI resource descriptors.
-
- @retval EFI_INVALID_PARAMETER "Address Range Minimum" is invalid for this
- root bridge.
-
- @retval EFI_INVALID_PARAMETER "Address Range Length" is invalid for this
- root bridge.
-
- @retval EFI_DEVICE_ERROR Programming failed due to a hardware error.
-
- @retval EFI_SUCCESS The bus range for the PCI root bridge was
- programmed.
-**/
-EFI_STATUS
-EFIAPI
-SetBusNumbers(
- IN EFI_PCI_HOST_BRIDGE_RESOURCE_ALLOCATION_PROTOCOL *This,
- IN EFI_HANDLE RootBridgeHandle,
- IN VOID *Configuration
- )
-{
- LIST_ENTRY *List;
- PCI_HOST_BRIDGE_INSTANCE *HostBridgeInstance;
- PCI_ROOT_BRIDGE_INSTANCE *RootBridgeInstance;
- UINT8 *Ptr;
- UINTN BusStart;
- UINTN BusEnd;
- UINTN BusLen;
-
- if (Configuration == NULL) {
- return EFI_INVALID_PARAMETER;
- }
-
- Ptr = Configuration;
-
- //
- // Check the Configuration is valid
- //
- if(*Ptr != ACPI_ADDRESS_SPACE_DESCRIPTOR) {
- return EFI_INVALID_PARAMETER;
- }
-
- if (((EFI_ACPI_ADDRESS_SPACE_DESCRIPTOR *)Ptr)->ResType != 2) {
- return EFI_INVALID_PARAMETER;
- }
-
- Ptr += sizeof(EFI_ACPI_ADDRESS_SPACE_DESCRIPTOR);
- if (*Ptr != ACPI_END_TAG_DESCRIPTOR) {
- return EFI_INVALID_PARAMETER;
- }
-
- HostBridgeInstance = INSTANCE_FROM_RESOURCE_ALLOCATION_THIS (This);
- List = HostBridgeInstance->Head.ForwardLink;
-
- Ptr = Configuration;
-
- while (List != &HostBridgeInstance->Head) {
- RootBridgeInstance = DRIVER_INSTANCE_FROM_LIST_ENTRY (List);
- if (RootBridgeHandle == RootBridgeInstance->Handle) {
- EFI_ACPI_ADDRESS_SPACE_DESCRIPTOR *Desc;
-
- Desc = (EFI_ACPI_ADDRESS_SPACE_DESCRIPTOR *)Ptr;
- BusStart = (UINTN)Desc->AddrRangeMin;
- BusLen = (UINTN)Desc->AddrLen;
- BusEnd = BusStart + BusLen - 1;
-
- if (BusStart > BusEnd) {
- return EFI_INVALID_PARAMETER;
- }
-
- if ((BusStart < RootBridgeInstance->BusBase) ||
- (BusEnd > RootBridgeInstance->BusLimit)) {
- return EFI_INVALID_PARAMETER;
- }
-
- //
- // Update the Bus Range
- //
- RootBridgeInstance->ResAllocNode[TypeBus].Base = BusStart;
- RootBridgeInstance->ResAllocNode[TypeBus].Length = BusLen;
- RootBridgeInstance->ResAllocNode[TypeBus].Status = ResAllocated;
-
- //
- // Program the Root Bridge Hardware
- //
-
- return EFI_SUCCESS;
- }
-
- List = List->ForwardLink;
- }
-
- return EFI_INVALID_PARAMETER;
-}
-
-
-/**
- Submits the I/O and memory resource requirements for the specified PCI root
- bridge.
-
- This function is used to submit all the I/O and memory resources that are
- required by the specified PCI root bridge. The input parameter Configuration
- is used to specify the following:
- - The various types of resources that are required
- - The associated lengths in terms of ACPI 2.0 resource descriptor format
-
- @param[in] This Pointer to the
- EFI_PCI_HOST_BRIDGE_RESOURCE_ALLOCATION_PROTOCOL
- instance.
-
- @param[in] RootBridgeHandle The PCI root bridge whose I/O and memory
- resource requirements are being submitted.
-
- @param[in] Configuration The pointer to the PCI I/O and PCI memory
- resource descriptor.
-
- @retval EFI_SUCCESS The I/O and memory resource requests for a PCI
- root bridge were accepted.
-
- @retval EFI_INVALID_PARAMETER RootBridgeHandle is not a valid root bridge
- handle.
-
- @retval EFI_INVALID_PARAMETER Configuration is NULL.
-
- @retval EFI_INVALID_PARAMETER Configuration does not point to a valid ACPI
- 2.0 resource descriptor.
-
- @retval EFI_INVALID_PARAMETER Configuration includes requests for one or
- more resource types that are not supported by
- this PCI root bridge. This error will happen
- if the caller did not combine resources
- according to Attributes that were returned by
- GetAllocAttributes().
-
- @retval EFI_INVALID_PARAMETER Address Range Maximum" is invalid.
-
- @retval EFI_INVALID_PARAMETER "Address Range Length" is invalid for this PCI
- root bridge.
-
- @retval EFI_INVALID_PARAMETER "Address Space Granularity" is invalid for
- this PCI root bridge.
-**/
-EFI_STATUS
-EFIAPI
-SubmitResources(
- IN EFI_PCI_HOST_BRIDGE_RESOURCE_ALLOCATION_PROTOCOL *This,
- IN EFI_HANDLE RootBridgeHandle,
- IN VOID *Configuration
- )
-{
- LIST_ENTRY *List;
- PCI_HOST_BRIDGE_INSTANCE *HostBridgeInstance;
- PCI_ROOT_BRIDGE_INSTANCE *RootBridgeInstance;
- UINT8 *Temp;
- EFI_ACPI_ADDRESS_SPACE_DESCRIPTOR *Ptr;
- UINT64 AddrLen;
- UINT64 Alignment;
-
- //
- // Check the input parameter: Configuration
- //
- if (Configuration == NULL) {
- return EFI_INVALID_PARAMETER;
- }
-
- HostBridgeInstance = INSTANCE_FROM_RESOURCE_ALLOCATION_THIS (This);
- List = HostBridgeInstance->Head.ForwardLink;
-
- Temp = (UINT8 *)Configuration;
- while ( *Temp == 0x8A) {
- Temp += sizeof (EFI_ACPI_ADDRESS_SPACE_DESCRIPTOR) ;
- }
- if (*Temp != 0x79) {
- return EFI_INVALID_PARAMETER;
- }
-
- Temp = (UINT8 *)Configuration;
- while (List != &HostBridgeInstance->Head) {
- RootBridgeInstance = DRIVER_INSTANCE_FROM_LIST_ENTRY (List);
- if (RootBridgeHandle == RootBridgeInstance->Handle) {
- while ( *Temp == 0x8A) {
- Ptr = (EFI_ACPI_ADDRESS_SPACE_DESCRIPTOR *) Temp ;
-
- //
- // Check Address Length
- //
- if (Ptr->AddrLen > 0xffffffff) {
- return EFI_INVALID_PARAMETER;
- }
-
- //
- // Check address range alignment
- //
- if (Ptr->AddrRangeMax >= 0xffffffff ||
- Ptr->AddrRangeMax != (GetPowerOfTwo64 (
- Ptr->AddrRangeMax + 1) - 1)) {
- return EFI_INVALID_PARAMETER;
- }
-
- switch (Ptr->ResType) {
-
- case 0:
-
- //
- // Check invalid Address Sapce Granularity
- //
- if (Ptr->AddrSpaceGranularity != 32) {
- return EFI_INVALID_PARAMETER;
- }
-
- //
- // check the memory resource request is supported by PCI root bridge
- //
- if (RootBridgeInstance->RootBridgeAttrib ==
- EFI_PCI_HOST_BRIDGE_COMBINE_MEM_PMEM &&
- Ptr->SpecificFlag == 0x06) {
- return EFI_INVALID_PARAMETER;
- }
-
- AddrLen = Ptr->AddrLen;
- Alignment = Ptr->AddrRangeMax;
- if (Ptr->AddrSpaceGranularity == 32) {
- if (Ptr->SpecificFlag == 0x06) {
- //
- // Apply from GCD
- //
- RootBridgeInstance->ResAllocNode[TypePMem32].Status =
- ResSubmitted;
- } else {
- RootBridgeInstance->ResAllocNode[TypeMem32].Length = AddrLen;
- RootBridgeInstance->ResAllocNode[TypeMem32].Alignment =
- Alignment;
- RootBridgeInstance->ResAllocNode[TypeMem32].Status =
- ResRequested;
- HostBridgeInstance->ResourceSubmited = TRUE;
- }
- }
-
- if (Ptr->AddrSpaceGranularity == 64) {
- if (Ptr->SpecificFlag == 0x06) {
- RootBridgeInstance->ResAllocNode[TypePMem64].Status =
- ResSubmitted;
- } else {
- RootBridgeInstance->ResAllocNode[TypeMem64].Status =
- ResSubmitted;
- }
- }
- break;
-
- case 1:
- AddrLen = (UINTN) Ptr->AddrLen;
- Alignment = (UINTN) Ptr->AddrRangeMax;
- RootBridgeInstance->ResAllocNode[TypeIo].Length = AddrLen;
- RootBridgeInstance->ResAllocNode[TypeIo].Alignment = Alignment;
- RootBridgeInstance->ResAllocNode[TypeIo].Status = ResRequested;
- HostBridgeInstance->ResourceSubmited = TRUE;
- break;
-
- default:
- break;
- };
-
- Temp += sizeof (EFI_ACPI_ADDRESS_SPACE_DESCRIPTOR) ;
- }
-
- return EFI_SUCCESS;
- }
-
- List = List->ForwardLink;
- }
-
- return EFI_INVALID_PARAMETER;
-}
-
-/**
- Returns the proposed resource settings for the specified PCI root bridge.
-
- This member function returns the proposed resource settings for the
- specified PCI root bridge. The proposed resource settings are prepared when
- NotifyPhase() is called with a Phase of EfiPciHostBridgeAllocateResources.
- The output parameter Configuration specifies the following:
- - The various types of resources, excluding bus resources, that are
- allocated
- - The associated lengths in terms of ACPI 2.0 resource descriptor format
-
- @param[in] This Pointer to the
- EFI_PCI_HOST_BRIDGE_RESOURCE_ALLOCATION_PROTOCOL
- instance.
-
- @param[in] RootBridgeHandle The PCI root bridge handle. Type EFI_HANDLE is
- defined in InstallProtocolInterface() in the
- UEFI 2.0 Specification.
-
- @param[out] Configuration The pointer to the pointer to the PCI I/O and
- memory resource descriptor.
-
- @retval EFI_SUCCESS The requested parameters were returned.
-
- @retval EFI_INVALID_PARAMETER RootBridgeHandle is not a valid root bridge
- handle.
-
- @retval EFI_DEVICE_ERROR Programming failed due to a hardware error.
-
- @retval EFI_OUT_OF_RESOURCES The request could not be completed due to a
- lack of resources.
-**/
-EFI_STATUS
-EFIAPI
-GetProposedResources(
- IN EFI_PCI_HOST_BRIDGE_RESOURCE_ALLOCATION_PROTOCOL *This,
- IN EFI_HANDLE RootBridgeHandle,
- OUT VOID **Configuration
- )
-{
- LIST_ENTRY *List;
- PCI_HOST_BRIDGE_INSTANCE *HostBridgeInstance;
- PCI_ROOT_BRIDGE_INSTANCE *RootBridgeInstance;
- UINTN Index;
- UINTN Number;
- VOID *Buffer;
- UINT8 *Temp;
- EFI_ACPI_ADDRESS_SPACE_DESCRIPTOR *Ptr;
- UINT64 ResStatus;
-
- Buffer = NULL;
- Number = 0;
- //
- // Get the Host Bridge Instance from the resource allocation protocol
- //
- HostBridgeInstance = INSTANCE_FROM_RESOURCE_ALLOCATION_THIS (This);
- List = HostBridgeInstance->Head.ForwardLink;
-
- //
- // Enumerate the root bridges in this host bridge
- //
- while (List != &HostBridgeInstance->Head) {
- RootBridgeInstance = DRIVER_INSTANCE_FROM_LIST_ENTRY (List);
- if (RootBridgeHandle == RootBridgeInstance->Handle) {
- for (Index = 0; Index < TypeBus; Index ++) {
- if (RootBridgeInstance->ResAllocNode[Index].Status != ResNone) {
- Number ++;
- }
- }
-
- if (Number == 0) {
- return EFI_INVALID_PARAMETER;
- }
-
- Buffer = AllocateZeroPool (
- Number * sizeof(EFI_ACPI_ADDRESS_SPACE_DESCRIPTOR) +
- sizeof(EFI_ACPI_END_TAG_DESCRIPTOR)
- );
- if (Buffer == NULL) {
- return EFI_OUT_OF_RESOURCES;
- }
-
- Temp = Buffer;
- for (Index = 0; Index < TypeBus; Index ++) {
- if (RootBridgeInstance->ResAllocNode[Index].Status != ResNone) {
- Ptr = (EFI_ACPI_ADDRESS_SPACE_DESCRIPTOR *) Temp ;
- ResStatus = RootBridgeInstance->ResAllocNode[Index].Status;
-
- switch (Index) {
-
- case TypeIo:
- //
- // Io
- //
- Ptr->Desc = 0x8A;
- Ptr->Len = 0x2B;
- Ptr->ResType = 1;
- Ptr->GenFlag = 0;
- Ptr->SpecificFlag = 0;
- Ptr->AddrRangeMin = RootBridgeInstance->ResAllocNode[Index].Base;
- Ptr->AddrRangeMax = 0;
- Ptr->AddrTranslationOffset = (ResStatus == ResAllocated) ?
- EFI_RESOURCE_SATISFIED :
- EFI_RESOURCE_LESS;
- Ptr->AddrLen = RootBridgeInstance->ResAllocNode[Index].Length;
- break;
-
- case TypeMem32:
- //
- // Memory 32
- //
- Ptr->Desc = 0x8A;
- Ptr->Len = 0x2B;
- Ptr->ResType = 0;
- Ptr->GenFlag = 0;
- Ptr->SpecificFlag = 0;
- Ptr->AddrSpaceGranularity = 32;
- Ptr->AddrRangeMin = RootBridgeInstance->ResAllocNode[Index].Base;
- Ptr->AddrRangeMax = 0;
- Ptr->AddrTranslationOffset = (ResStatus == ResAllocated) ?
- EFI_RESOURCE_SATISFIED :
- EFI_RESOURCE_LESS;
- Ptr->AddrLen = RootBridgeInstance->ResAllocNode[Index].Length;
- break;
-
- case TypePMem32:
- //
- // Prefetch memory 32
- //
- Ptr->Desc = 0x8A;
- Ptr->Len = 0x2B;
- Ptr->ResType = 0;
- Ptr->GenFlag = 0;
- Ptr->SpecificFlag = 6;
- Ptr->AddrSpaceGranularity = 32;
- Ptr->AddrRangeMin = 0;
- Ptr->AddrRangeMax = 0;
- Ptr->AddrTranslationOffset = EFI_RESOURCE_NONEXISTENT;
- Ptr->AddrLen = 0;
- break;
-
- case TypeMem64:
- //
- // Memory 64
- //
- Ptr->Desc = 0x8A;
- Ptr->Len = 0x2B;
- Ptr->ResType = 0;
- Ptr->GenFlag = 0;
- Ptr->SpecificFlag = 0;
- Ptr->AddrSpaceGranularity = 64;
- Ptr->AddrRangeMin = 0;
- Ptr->AddrRangeMax = 0;
- Ptr->AddrTranslationOffset = EFI_RESOURCE_NONEXISTENT;
- Ptr->AddrLen = 0;
- break;
-
- case TypePMem64:
- //
- // Prefetch memory 64
- //
- Ptr->Desc = 0x8A;
- Ptr->Len = 0x2B;
- Ptr->ResType = 0;
- Ptr->GenFlag = 0;
- Ptr->SpecificFlag = 6;
- Ptr->AddrSpaceGranularity = 64;
- Ptr->AddrRangeMin = 0;
- Ptr->AddrRangeMax = 0;
- Ptr->AddrTranslationOffset = EFI_RESOURCE_NONEXISTENT;
- Ptr->AddrLen = 0;
- break;
- };
-
- Temp += sizeof (EFI_ACPI_ADDRESS_SPACE_DESCRIPTOR);
- }
- }
-
- ((EFI_ACPI_END_TAG_DESCRIPTOR *)Temp)->Desc = 0x79;
- ((EFI_ACPI_END_TAG_DESCRIPTOR *)Temp)->Checksum = 0x0;
-
- *Configuration = Buffer;
-
- return EFI_SUCCESS;
- }
-
- List = List->ForwardLink;
- }
-
- return EFI_INVALID_PARAMETER;
-}
-
-/**
- Provides the hooks from the PCI bus driver to every PCI controller
- (device/function) at various stages of the PCI enumeration process that allow
- the host bridge driver to preinitialize individual PCI controllers before
- enumeration.
-
- This function is called during the PCI enumeration process. No specific
- action is expected from this member function. It allows the host bridge
- driver to preinitialize individual PCI controllers before enumeration.
-
- @param This Pointer to the
- EFI_PCI_HOST_BRIDGE_RESOURCE_ALLOCATION_PROTOCOL
- instance.
-
- @param RootBridgeHandle The associated PCI root bridge handle. Type
- EFI_HANDLE is defined in InstallProtocolInterface()
- in the UEFI 2.0 Specification.
-
- @param PciAddress The address of the PCI device on the PCI bus. This
- address can be passed to the
- EFI_PCI_ROOT_BRIDGE_IO_PROTOCOL member functions to
- access the PCI configuration space of the device.
- See Table 12-1 in the UEFI 2.0 Specification for the
- definition of
- EFI_PCI_ROOT_BRIDGE_IO_PROTOCOL_PCI_ADDRESS.
-
- @param Phase The phase of the PCI device enumeration.
-
- @retval EFI_SUCCESS The requested parameters were returned.
-
- @retval EFI_INVALID_PARAMETER RootBridgeHandle is not a valid root bridge
- handle.
-
- @retval EFI_INVALID_PARAMETER Phase is not a valid phase that is defined
- in
- EFI_PCI_CONTROLLER_RESOURCE_ALLOCATION_PHASE.
-
- @retval EFI_DEVICE_ERROR Programming failed due to a hardware error.
- The PCI enumerator should not enumerate this
- device, including its child devices if it is
- a PCI-to-PCI bridge.
-**/
-EFI_STATUS
-EFIAPI
-PreprocessController (
- IN EFI_PCI_HOST_BRIDGE_RESOURCE_ALLOCATION_PROTOCOL *This,
- IN EFI_HANDLE RootBridgeHandle,
- IN EFI_PCI_ROOT_BRIDGE_IO_PROTOCOL_PCI_ADDRESS PciAddress,
- IN EFI_PCI_CONTROLLER_RESOURCE_ALLOCATION_PHASE Phase
- )
-{
- PCI_HOST_BRIDGE_INSTANCE *HostBridgeInstance;
- PCI_ROOT_BRIDGE_INSTANCE *RootBridgeInstance;
- LIST_ENTRY *List;
-
- HostBridgeInstance = INSTANCE_FROM_RESOURCE_ALLOCATION_THIS (This);
- List = HostBridgeInstance->Head.ForwardLink;
-
- //
- // Enumerate the root bridges in this host bridge
- //
- while (List != &HostBridgeInstance->Head) {
- RootBridgeInstance = DRIVER_INSTANCE_FROM_LIST_ENTRY (List);
- if (RootBridgeHandle == RootBridgeInstance->Handle) {
- break;
- }
- List = List->ForwardLink;
- }
- if (List == &HostBridgeInstance->Head) {
- return EFI_INVALID_PARAMETER;
- }
-
- if ((UINT32)Phase > EfiPciBeforeResourceCollection) {
- return EFI_INVALID_PARAMETER;
- }
-
- return EFI_SUCCESS;
-}
diff --git a/OvmfPkg/PciHostBridgeDxe/PciHostBridge.h b/OvmfPkg/PciHostBridgeDxe/PciHostBridge.h
deleted file mode 100644
index 617c68e318..0000000000
--- a/OvmfPkg/PciHostBridgeDxe/PciHostBridge.h
+++ /dev/null
@@ -1,651 +0,0 @@
-/** @file
- The Header file of the Pci Host Bridge Driver
-
- Copyright (C) 2015, Red Hat, Inc.
- Copyright (c) 2008 - 2010, Intel Corporation. All rights reserved.<BR>
-
- This program and the accompanying materials are licensed and made available
- under the terms and conditions of the BSD License which accompanies this
- distribution. The full text of the license may be found at
- http://opensource.org/licenses/bsd-license.php
-
- THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
- WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
-**/
-
-#ifndef _PCI_HOST_BRIDGE_H_
-#define _PCI_HOST_BRIDGE_H_
-
-#include <PiDxe.h>
-
-#include <IndustryStandard/Pci.h>
-#include <IndustryStandard/Acpi.h>
-
-#include <Protocol/PciHostBridgeResourceAllocation.h>
-#include <Protocol/PciRootBridgeIo.h>
-#include <Protocol/Metronome.h>
-#include <Protocol/DevicePath.h>
-
-
-#include <Library/BaseLib.h>
-#include <Library/DebugLib.h>
-#include <Library/BaseMemoryLib.h>
-#include <Library/MemoryAllocationLib.h>
-#include <Library/UefiLib.h>
-#include <Library/UefiBootServicesTableLib.h>
-#include <Library/DxeServicesTableLib.h>
-#include <Library/DevicePathLib.h>
-#include <Library/IoLib.h>
-#include <Library/PciLib.h>
-
-#define MAX_PCI_DEVICE_NUMBER 31
-#define MAX_PCI_FUNCTION_NUMBER 7
-#define MAX_PCI_REG_ADDRESS 0xFF
-
-typedef enum {
- IoOperation,
- MemOperation,
- PciOperation
-} OPERATION_TYPE;
-
-#define PCI_HOST_BRIDGE_SIGNATURE SIGNATURE_32('e', 'h', 's', 't')
-typedef struct {
- UINTN Signature;
- EFI_HANDLE HostBridgeHandle;
- LIST_ENTRY Head;
- BOOLEAN ResourceSubmited;
- BOOLEAN CanRestarted;
- EFI_PCI_HOST_BRIDGE_RESOURCE_ALLOCATION_PROTOCOL ResAlloc;
-} PCI_HOST_BRIDGE_INSTANCE;
-
-#define INSTANCE_FROM_RESOURCE_ALLOCATION_THIS(a) \
- CR(a, PCI_HOST_BRIDGE_INSTANCE, ResAlloc, PCI_HOST_BRIDGE_SIGNATURE)
-
-//
-// HostBridge Resource Allocation interface
-//
-
-/**
- These are the notifications from the PCI bus driver that it is about to enter
- a certain phase of the PCI enumeration process.
-
- This member function can be used to notify the host bridge driver to perform
- specific actions, including any chipset-specific initialization, so that the
- chipset is ready to enter the next phase. Eight notification points are
- defined at this time. See belows:
-
- EfiPciHostBridgeBeginEnumeration Resets the host bridge PCI apertures
- and internal data structures. The PCI
- enumerator should issue this
- notification before starting a fresh
- enumeration process. Enumeration
- cannot be restarted after sending any
- other notification such as
- EfiPciHostBridgeBeginBusAllocation.
-
- EfiPciHostBridgeBeginBusAllocation The bus allocation phase is about to
- begin. No specific action is required
- here. This notification can be used to
- perform any chipset-specific
- programming.
-
- EfiPciHostBridgeEndBusAllocation The bus allocation and bus programming
- phase is complete. No specific action
- is required here. This notification
- can be used to perform any
- chipset-specific programming.
-
- EfiPciHostBridgeBeginResourceAllocation
- The resource allocation phase is about
- to begin. No specific action is
- required here. This notification can
- be used to perform any
- chipset-specific programming.
-
- EfiPciHostBridgeAllocateResources Allocates resources per previously
- submitted requests for all the PCI
- root bridges. These resource settings
- are returned on the next call to
- GetProposedResources(). Before calling
- NotifyPhase() with a Phase of
- EfiPciHostBridgeAllocateResource, the
- PCI bus enumerator is responsible for
- gathering I/O and memory requests for
- all the PCI root bridges and
- submitting these requests using
- SubmitResources(). This function pads
- the resource amount to suit the root
- bridge hardware, takes care of
- dependencies between the PCI root
- bridges, and calls the Global
- Coherency Domain (GCD) with the
- allocation request. In the case of
- padding, the allocated range could be
- bigger than what was requested.
-
- EfiPciHostBridgeSetResources Programs the host bridge hardware to
- decode previously allocated resources
- (proposed resources) for all the PCI
- root bridges. After the hardware is
- programmed, reassigning resources will
- not be supported. The bus settings are
- not affected.
-
- EfiPciHostBridgeFreeResources Deallocates resources that were
- previously allocated for all the PCI
- root bridges and resets the I/O and
- memory apertures to their initial
- state. The bus settings are not
- affected. If the request to allocate
- resources fails, the PCI enumerator
- can use this notification to
- deallocate previous resources, adjust
- the requests, and retry allocation.
-
- EfiPciHostBridgeEndResourceAllocation The resource allocation phase is
- completed. No specific action is
- required here. This notification can
- be used to perform any chipsetspecific
- programming.
-
- @param[in] This The instance pointer of
- EFI_PCI_HOST_BRIDGE_RESOURCE_ALLOCATION_PROTOCOL
-
- @param[in] Phase The phase during enumeration
-
- @retval EFI_NOT_READY This phase cannot be entered at this time. For
- example, this error is valid for a Phase of
- EfiPciHostBridgeAllocateResources if
- SubmitResources() has not been called for one
- or more PCI root bridges before this call
-
- @retval EFI_DEVICE_ERROR Programming failed due to a hardware error.
- This error is valid for a Phase of
- EfiPciHostBridgeSetResources.
-
- @retval EFI_INVALID_PARAMETER Invalid phase parameter
-
- @retval EFI_OUT_OF_RESOURCES The request could not be completed due to a
- lack of resources. This error is valid for a
- Phase of EfiPciHostBridgeAllocateResources if
- the previously submitted resource requests
- cannot be fulfilled or were only partially
- fulfilled.
-
- @retval EFI_SUCCESS The notification was accepted without any
- errors.
-**/
-EFI_STATUS
-EFIAPI
-NotifyPhase(
- IN EFI_PCI_HOST_BRIDGE_RESOURCE_ALLOCATION_PROTOCOL *This,
- IN EFI_PCI_HOST_BRIDGE_RESOURCE_ALLOCATION_PHASE Phase
- );
-
-/**
- Return the device handle of the next PCI root bridge that is associated with
- this Host Bridge.
-
- This function is called multiple times to retrieve the device handles of all
- the PCI root bridges that are associated with this PCI host bridge. Each PCI
- host bridge is associated with one or more PCI root bridges. On each call,
- the handle that was returned by the previous call is passed into the
- interface, and on output the interface returns the device handle of the next
- PCI root bridge. The caller can use the handle to obtain the instance of the
- EFI_PCI_ROOT_BRIDGE_IO_PROTOCOL for that root bridge. When there are no more
- PCI root bridges to report, the interface returns EFI_NOT_FOUND. A PCI
- enumerator must enumerate the PCI root bridges in the order that they are
- returned by this function.
-
- For D945 implementation, there is only one root bridge in PCI host bridge.
-
- @param[in] This The instance pointer of
- EFI_PCI_HOST_BRIDGE_RESOURCE_ALLOCATION_PROTOCOL
-
- @param[in, out] RootBridgeHandle Returns the device handle of the next PCI
- root bridge.
-
- @retval EFI_SUCCESS If parameter RootBridgeHandle = NULL, then
- return the first Rootbridge handle of the
- specific Host bridge and return EFI_SUCCESS.
-
- @retval EFI_NOT_FOUND Can not find the any more root bridge in
- specific host bridge.
-
- @retval EFI_INVALID_PARAMETER RootBridgeHandle is not an EFI_HANDLE that was
- returned on a previous call to
- GetNextRootBridge().
-**/
-EFI_STATUS
-EFIAPI
-GetNextRootBridge(
- IN EFI_PCI_HOST_BRIDGE_RESOURCE_ALLOCATION_PROTOCOL *This,
- IN OUT EFI_HANDLE *RootBridgeHandle
- );
-
-/**
- Returns the allocation attributes of a PCI root bridge.
-
- The function returns the allocation attributes of a specific PCI root bridge.
- The attributes can vary from one PCI root bridge to another. These attributes
- are different from the decode-related attributes that are returned by the
- EFI_PCI_ROOT_BRIDGE_IO_PROTOCOL.GetAttributes() member function. The
- RootBridgeHandle parameter is used to specify the instance of the PCI root
- bridge. The device handles of all the root bridges that are associated with
- this host bridge must be obtained by calling GetNextRootBridge(). The
- attributes are static in the sense that they do not change during or after
- the enumeration process. The hardware may provide mechanisms to change the
- attributes on the fly, but such changes must be completed before
- EFI_PCI_HOST_BRIDGE_RESOURCE_ALLOCATION_PROTOCOL is installed. The permitted
- values of EFI_PCI_HOST_BRIDGE_RESOURCE_ALLOCATION_ATTRIBUTES are defined in
- "Related Definitions" below. The caller uses these attributes to combine
- multiple resource requests.
-
- For example, if the flag EFI_PCI_HOST_BRIDGE_COMBINE_MEM_PMEM is set, the PCI
- bus enumerator needs to include requests for the prefetchable memory in the
- nonprefetchable memory pool and not request any prefetchable memory.
-
- Attribute Description
- ------------------------------------ ---------------------------------------
- EFI_PCI_HOST_BRIDGE_COMBINE_MEM_PMEM If this bit is set, then the PCI root
- bridge does not support separate
- windows for nonprefetchable and
- prefetchable memory. A PCI bus driver
- needs to include requests for
- prefetchable memory in the
- nonprefetchable memory pool.
-
- EFI_PCI_HOST_BRIDGE_MEM64_DECODE If this bit is set, then the PCI root
- bridge supports 64-bit memory windows.
- If this bit is not set, the PCI bus
- driver needs to include requests for a
- 64-bit memory address in the
- corresponding 32-bit memory pool.
-
- @param[in] This The instance pointer of
- EFI_PCI_HOST_BRIDGE_RESOURCE_ALLOCATION_PROTOCOL
-
- @param[in] RootBridgeHandle The device handle of the PCI root bridge in
- which the caller is interested. Type
- EFI_HANDLE is defined in
- InstallProtocolInterface() in the UEFI 2.0
- Specification.
-
- @param[out] Attributes The pointer to attribte of root bridge, it is
- output parameter
-
- @retval EFI_INVALID_PARAMETER Attribute pointer is NULL
-
- @retval EFI_INVALID_PARAMETER RootBridgehandle is invalid.
-
- @retval EFI_SUCCESS Success to get attribute of interested root
- bridge.
-**/
-EFI_STATUS
-EFIAPI
-GetAttributes(
- IN EFI_PCI_HOST_BRIDGE_RESOURCE_ALLOCATION_PROTOCOL *This,
- IN EFI_HANDLE RootBridgeHandle,
- OUT UINT64 *Attributes
- );
-
-/**
- Sets up the specified PCI root bridge for the bus enumeration process.
-
- This member function sets up the root bridge for bus enumeration and returns
- the PCI bus range over which the search should be performed in ACPI 2.0
- resource descriptor format.
-
- @param[in] This The
- EFI_PCI_HOST_BRIDGE_RESOURCE_ALLOCATION_PROTOCOL
- instance.
-
- @param[in] RootBridgeHandle The PCI Root Bridge to be set up.
-
- @param[out] Configuration Pointer to the pointer to the PCI bus resource
- descriptor.
-
- @retval EFI_INVALID_PARAMETER Invalid Root bridge's handle
-
- @retval EFI_OUT_OF_RESOURCES Fail to allocate ACPI resource descriptor tag.
-
- @retval EFI_SUCCESS Sucess to allocate ACPI resource descriptor.
-**/
-EFI_STATUS
-EFIAPI
-StartBusEnumeration(
- IN EFI_PCI_HOST_BRIDGE_RESOURCE_ALLOCATION_PROTOCOL *This,
- IN EFI_HANDLE RootBridgeHandle,
- OUT VOID **Configuration
- );
-
-/**
- Programs the PCI root bridge hardware so that it decodes the specified PCI
- bus range.
-
- This member function programs the specified PCI root bridge to decode the bus
- range that is specified by the input parameter Configuration.
- The bus range information is specified in terms of the ACPI 2.0 resource
- descriptor format.
-
- @param[in] This The
- EFI_PCI_HOST_BRIDGE_RESOURCE_ALLOCATION_PROTOCOL
- instance
-
- @param[in] RootBridgeHandle The PCI Root Bridge whose bus range is to be
- programmed
-
- @param[in] Configuration The pointer to the PCI bus resource descriptor
-
- @retval EFI_INVALID_PARAMETER RootBridgeHandle is not a valid root bridge
- handle.
-
- @retval EFI_INVALID_PARAMETER Configuration is NULL.
-
- @retval EFI_INVALID_PARAMETER Configuration does not point to a valid ACPI
- 2.0 resource descriptor.
-
- @retval EFI_INVALID_PARAMETER Configuration does not include a valid ACPI
- 2.0 bus resource descriptor.
-
- @retval EFI_INVALID_PARAMETER Configuration includes valid ACPI 2.0 resource
- descriptors other than bus descriptors.
-
- @retval EFI_INVALID_PARAMETER Configuration contains one or more invalid
- ACPI resource descriptors.
-
- @retval EFI_INVALID_PARAMETER "Address Range Minimum" is invalid for this
- root bridge.
-
- @retval EFI_INVALID_PARAMETER "Address Range Length" is invalid for this
- root bridge.
-
- @retval EFI_DEVICE_ERROR Programming failed due to a hardware error.
-
- @retval EFI_SUCCESS The bus range for the PCI root bridge was
- programmed.
-**/
-EFI_STATUS
-EFIAPI
-SetBusNumbers(
- IN EFI_PCI_HOST_BRIDGE_RESOURCE_ALLOCATION_PROTOCOL *This,
- IN EFI_HANDLE RootBridgeHandle,
- IN VOID *Configuration
- );
-
-/**
- Submits the I/O and memory resource requirements for the specified PCI root
- bridge.
-
- This function is used to submit all the I/O and memory resources that are
- required by the specified PCI root bridge. The input parameter Configuration
- is used to specify the following:
- - The various types of resources that are required
- - The associated lengths in terms of ACPI 2.0 resource descriptor format
-
- @param[in] This Pointer to the
- EFI_PCI_HOST_BRIDGE_RESOURCE_ALLOCATION_PROTOCOL
- instance.
-
- @param[in] RootBridgeHandle The PCI root bridge whose I/O and memory
- resource requirements are being submitted.
-
- @param[in] Configuration The pointer to the PCI I/O and PCI memory
- resource descriptor.
-
- @retval EFI_SUCCESS The I/O and memory resource requests for a PCI
- root bridge were accepted.
-
- @retval EFI_INVALID_PARAMETER RootBridgeHandle is not a valid root bridge
- handle.
-
- @retval EFI_INVALID_PARAMETER Configuration is NULL.
-
- @retval EFI_INVALID_PARAMETER Configuration does not point to a valid ACPI
- 2.0 resource descriptor.
-
- @retval EFI_INVALID_PARAMETER Configuration includes requests for one or
- more resource types that are not supported by
- this PCI root bridge. This error will happen
- if the caller did not combine resources
- according to Attributes that were returned by
- GetAllocAttributes().
-
- @retval EFI_INVALID_PARAMETER Address Range Maximum" is invalid.
-
- @retval EFI_INVALID_PARAMETER "Address Range Length" is invalid for this PCI
- root bridge.
-
- @retval EFI_INVALID_PARAMETER "Address Space Granularity" is invalid for
- this PCI root bridge.
-**/
-EFI_STATUS
-EFIAPI
-SubmitResources(
- IN EFI_PCI_HOST_BRIDGE_RESOURCE_ALLOCATION_PROTOCOL *This,
- IN EFI_HANDLE RootBridgeHandle,
- IN VOID *Configuration
- );
-
-/**
- Returns the proposed resource settings for the specified PCI root bridge.
-
- This member function returns the proposed resource settings for the
- specified PCI root bridge. The proposed resource settings are prepared when
- NotifyPhase() is called with a Phase of EfiPciHostBridgeAllocateResources.
- The output parameter Configuration specifies the following:
- - The various types of resources, excluding bus resources, that are
- allocated
- - The associated lengths in terms of ACPI 2.0 resource descriptor format
-
- @param[in] This Pointer to the
- EFI_PCI_HOST_BRIDGE_RESOURCE_ALLOCATION_PROTOCOL
- instance.
-
- @param[in] RootBridgeHandle The PCI root bridge handle. Type EFI_HANDLE is
- defined in InstallProtocolInterface() in the
- UEFI 2.0 Specification.
-
- @param[out] Configuration The pointer to the pointer to the PCI I/O and
- memory resource descriptor.
-
- @retval EFI_SUCCESS The requested parameters were returned.
-
- @retval EFI_INVALID_PARAMETER RootBridgeHandle is not a valid root bridge
- handle.
-
- @retval EFI_DEVICE_ERROR Programming failed due to a hardware error.
-
- @retval EFI_OUT_OF_RESOURCES The request could not be completed due to a
- lack of resources.
-**/
-EFI_STATUS
-EFIAPI
-GetProposedResources(
- IN EFI_PCI_HOST_BRIDGE_RESOURCE_ALLOCATION_PROTOCOL *This,
- IN EFI_HANDLE RootBridgeHandle,
- OUT VOID **Configuration
- );
-
-/**
- Provides the hooks from the PCI bus driver to every PCI controller
- (device/function) at various stages of the PCI enumeration process that allow
- the host bridge driver to preinitialize individual PCI controllers before
- enumeration.
-
- This function is called during the PCI enumeration process. No specific
- action is expected from this member function. It allows the host bridge
- driver to preinitialize individual PCI controllers before enumeration.
-
- @param This Pointer to the
- EFI_PCI_HOST_BRIDGE_RESOURCE_ALLOCATION_PROTOCOL
- instance.
-
- @param RootBridgeHandle The associated PCI root bridge handle. Type
- EFI_HANDLE is defined in InstallProtocolInterface()
- in the UEFI 2.0 Specification.
-
- @param PciAddress The address of the PCI device on the PCI bus. This
- address can be passed to the
- EFI_PCI_ROOT_BRIDGE_IO_PROTOCOL member functions to
- access the PCI configuration space of the device.
- See Table 12-1 in the UEFI 2.0 Specification for the
- definition of
- EFI_PCI_ROOT_BRIDGE_IO_PROTOCOL_PCI_ADDRESS.
-
- @param Phase The phase of the PCI device enumeration.
-
- @retval EFI_SUCCESS The requested parameters were returned.
-
- @retval EFI_INVALID_PARAMETER RootBridgeHandle is not a valid root bridge
- handle.
-
- @retval EFI_INVALID_PARAMETER Phase is not a valid phase that is defined
- in
- EFI_PCI_CONTROLLER_RESOURCE_ALLOCATION_PHASE.
-
- @retval EFI_DEVICE_ERROR Programming failed due to a hardware error.
- The PCI enumerator should not enumerate this
- device, including its child devices if it is
- a PCI-to-PCI bridge.
-**/
-EFI_STATUS
-EFIAPI
-PreprocessController (
- IN EFI_PCI_HOST_BRIDGE_RESOURCE_ALLOCATION_PROTOCOL *This,
- IN EFI_HANDLE RootBridgeHandle,
- IN EFI_PCI_ROOT_BRIDGE_IO_PROTOCOL_PCI_ADDRESS PciAddress,
- IN EFI_PCI_CONTROLLER_RESOURCE_ALLOCATION_PHASE Phase
- );
-
-
-//
-// Define resource status constant
-//
-#define EFI_RESOURCE_NONEXISTENT 0xFFFFFFFFFFFFFFFFULL
-#define EFI_RESOURCE_LESS 0xFFFFFFFFFFFFFFFEULL
-
-
-//
-// Driver Instance Data Prototypes
-//
-
-typedef struct {
- EFI_PCI_ROOT_BRIDGE_IO_PROTOCOL_OPERATION Operation;
- UINTN NumberOfBytes;
- UINTN NumberOfPages;
- EFI_PHYSICAL_ADDRESS HostAddress;
- EFI_PHYSICAL_ADDRESS MappedHostAddress;
-} MAP_INFO;
-
-typedef struct {
- ACPI_HID_DEVICE_PATH AcpiDevicePath;
- EFI_DEVICE_PATH_PROTOCOL EndDevicePath;
-} EFI_PCI_ROOT_BRIDGE_DEVICE_PATH;
-
-typedef struct {
- UINT64 BusBase;
- UINT64 BusLimit;
-
- UINT64 MemBase;
- UINT64 MemLimit;
-
- UINT64 IoBase;
- UINT64 IoLimit;
-} PCI_ROOT_BRIDGE_RESOURCE_APERTURE;
-
-typedef enum {
- TypeIo = 0,
- TypeMem32,
- TypePMem32,
- TypeMem64,
- TypePMem64,
- TypeBus,
- TypeMax
-} PCI_RESOURCE_TYPE;
-
-typedef enum {
- ResNone = 0,
- ResSubmitted,
- ResRequested,
- ResAllocated,
- ResStatusMax
-} RES_STATUS;
-
-typedef struct {
- PCI_RESOURCE_TYPE Type;
- UINT64 Base;
- UINT64 Length;
- UINT64 Alignment;
- RES_STATUS Status;
-} PCI_RES_NODE;
-
-#pragma pack(1)
-typedef struct {
- EFI_ACPI_ADDRESS_SPACE_DESCRIPTOR SpaceDesc[TypeMax];
- EFI_ACPI_END_TAG_DESCRIPTOR EndDesc;
-} RESOURCE_CONFIGURATION;
-#pragma pack()
-
-#define PCI_ROOT_BRIDGE_SIGNATURE SIGNATURE_32('e', '2', 'p', 'b')
-
-typedef struct {
- UINT32 Signature;
- LIST_ENTRY Link;
- EFI_HANDLE Handle;
- UINT64 RootBridgeAttrib;
- UINT64 Attributes;
- UINT64 Supports;
-
- //
- // Specific for this memory controller: Bus, I/O, Mem
- //
- PCI_RES_NODE ResAllocNode[6];
-
- //
- // Addressing for Memory and I/O and Bus arrange
- //
- UINT64 BusBase;
- UINT64 MemBase;
- UINT64 IoBase;
- UINT64 BusLimit;
- UINT64 MemLimit;
- UINT64 IoLimit;
-
- EFI_PCI_ROOT_BRIDGE_DEVICE_PATH DevicePath;
- EFI_PCI_ROOT_BRIDGE_IO_PROTOCOL Io;
-
- RESOURCE_CONFIGURATION ConfigBuffer;
-} PCI_ROOT_BRIDGE_INSTANCE;
-
-
-//
-// Driver Instance Data Macros
-//
-#define DRIVER_INSTANCE_FROM_PCI_ROOT_BRIDGE_IO_THIS(a) \
- CR(a, PCI_ROOT_BRIDGE_INSTANCE, Io, PCI_ROOT_BRIDGE_SIGNATURE)
-
-
-#define DRIVER_INSTANCE_FROM_LIST_ENTRY(a) \
- CR(a, PCI_ROOT_BRIDGE_INSTANCE, Link, PCI_ROOT_BRIDGE_SIGNATURE)
-
-/**
-
- Construct the Pci Root Bridge Io protocol
-
- @param Protocol Point to protocol instance
- @param HostBridgeHandle Handle of host bridge
- @param Attri Attribute of host bridge
- @param ResAperture ResourceAperture for host bridge
-
- @retval EFI_SUCCESS Success to initialize the Pci Root Bridge.
-**/
-EFI_STATUS
-RootBridgeConstructor (
- IN EFI_PCI_ROOT_BRIDGE_IO_PROTOCOL *Protocol,
- IN EFI_HANDLE HostBridgeHandle,
- IN UINT64 Attri,
- IN PCI_ROOT_BRIDGE_RESOURCE_APERTURE *ResAperture
- );
-
-#endif
diff --git a/OvmfPkg/PciHostBridgeDxe/PciHostBridgeDxe.inf b/OvmfPkg/PciHostBridgeDxe/PciHostBridgeDxe.inf
deleted file mode 100644
index ca760b5497..0000000000
--- a/OvmfPkg/PciHostBridgeDxe/PciHostBridgeDxe.inf
+++ /dev/null
@@ -1,66 +0,0 @@
-## @file
-# The basic interfaces implementation to a single segment PCI Host Bridge
-# driver.
-#
-# Copyright (c) 2008 - 2014, Intel Corporation. All rights reserved.<BR>
-#
-# This program and the accompanying materials are licensed and made available
-# under the terms and conditions of the BSD License which accompanies this
-# distribution. The full text of the license may be found at
-# http://opensource.org/licenses/bsd-license.php
-#
-# 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 = PciHostBridge
- FILE_GUID = 311161C5-BFD9-4504-8016-213F2DAEDAF3
- MODULE_TYPE = DXE_DRIVER
- VERSION_STRING = 1.0
-
- ENTRY_POINT = InitializePciHostBridge
-
-[Packages]
- MdePkg/MdePkg.dec
- OvmfPkg/OvmfPkg.dec
-
-[LibraryClasses]
- UefiDriverEntryPoint
- UefiBootServicesTableLib
- DxeServicesTableLib
- UefiLib
- MemoryAllocationLib
- BaseMemoryLib
- BaseLib
- DebugLib
- DevicePathLib
- IoLib
- PciLib
- QemuFwCfgLib
-
-[Sources]
- PciHostBridge.c
- PciRootBridgeIo.c
- PciHostBridge.h
- IoFifo.h
-
-[Sources.IA32]
- Ia32/IoFifo.asm
- Ia32/IoFifo.S
-
-[Sources.X64]
- X64/IoFifo.asm
- X64/IoFifo.S
-
-[Protocols]
- gEfiPciHostBridgeResourceAllocationProtocolGuid ## PRODUCES
- gEfiPciRootBridgeIoProtocolGuid ## PRODUCES
- gEfiMetronomeArchProtocolGuid ## CONSUMES
- gEfiDevicePathProtocolGuid ## PRODUCES
-
-[depex]
- gEfiMetronomeArchProtocolGuid
diff --git a/OvmfPkg/PciHostBridgeDxe/PciRootBridgeIo.c b/OvmfPkg/PciHostBridgeDxe/PciRootBridgeIo.c
deleted file mode 100644
index c61fd1d7db..0000000000
--- a/OvmfPkg/PciHostBridgeDxe/PciRootBridgeIo.c
+++ /dev/null
@@ -1,2628 +0,0 @@
-/** @file
- PCI Root Bridge Io Protocol implementation
-
- Copyright (C) 2015, Red Hat, Inc.
- Copyright (c) 2008 - 2012, Intel Corporation. All rights reserved.<BR>
-
- This program and the accompanying materials are licensed and made available
- under the terms and conditions of the BSD License which accompanies this
- distribution. The full text of the license may be found at
- http://opensource.org/licenses/bsd-license.php
-
- 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 "PciHostBridge.h"
-#include "IoFifo.h"
-
-STATIC
-CONST
-RESOURCE_CONFIGURATION mConfigurationTemplate = {
- {
- { 0x8A, 0x2B, 1, 0, 0, 0, 0, 0, 0, 0 }, // SpaceDesc[TypeIo]
- { 0x8A, 0x2B, 0, 0, 0, 32, 0, 0, 0, 0 }, // SpaceDesc[TypeMem32]
- { 0x8A, 0x2B, 0, 0, 6, 32, 0, 0, 0, 0 }, // SpaceDesc[TypePMem32]
- { 0x8A, 0x2B, 0, 0, 0, 64, 0, 0, 0, 0 }, // SpaceDesc[TypeMem64]
- { 0x8A, 0x2B, 0, 0, 6, 64, 0, 0, 0, 0 }, // SpaceDesc[TypePMem64]
- { 0x8A, 0x2B, 2, 0, 0, 0, 0, 0, 0, 0 } // SpaceDesc[TypeBus]
- },
- { 0x79, 0 } // EndDesc
-};
-
-//
-// Protocol Member Function Prototypes
-//
-
-/**
- Polls an address in memory mapped I/O space until an exit condition is met,
- or a timeout occurs.
-
- This function provides a standard way to poll a PCI memory location. A PCI
- memory read operation is performed at the PCI memory address specified by
- Address for the width specified by Width. The result of this PCI memory read
- operation is stored in Result. This PCI memory read operation is repeated
- until either a timeout of Delay 100 ns units has expired, or (Result & Mask)
- is equal to Value.
-
- @param[in] This A pointer to the EFI_PCI_ROOT_BRIDGE_IO_PROTOCOL.
-
- @param[in] Width Signifies the width of the memory operations.
-
- @param[in] Address The base address of the memory operations. The caller
- is responsible for aligning Address if required.
-
- @param[in] Mask Mask used for the polling criteria. Bytes above Width
- in Mask are ignored. The bits in the bytes below Width
- which are zero in Mask are ignored when polling the
- memory address.
-
- @param[in] Value The comparison value used for the polling exit
- criteria.
-
- @param[in] Delay The number of 100 ns units to poll. Note that timer
- available may be of poorer granularity.
-
- @param[out] Result Pointer to the last value read from the memory
- location.
-
- @retval EFI_SUCCESS The last data returned from the access matched
- the poll exit criteria.
-
- @retval EFI_INVALID_PARAMETER Width is invalid.
-
- @retval EFI_INVALID_PARAMETER Result is NULL.
-
- @retval EFI_TIMEOUT Delay expired before a match occurred.
-
- @retval EFI_OUT_OF_RESOURCES The request could not be completed due to a
- lack of resources.
-**/
-EFI_STATUS
-EFIAPI
-RootBridgeIoPollMem (
- IN EFI_PCI_ROOT_BRIDGE_IO_PROTOCOL *This,
- IN EFI_PCI_ROOT_BRIDGE_IO_PROTOCOL_WIDTH Width,
- IN UINT64 Address,
- IN UINT64 Mask,
- IN UINT64 Value,
- IN UINT64 Delay,
- OUT UINT64 *Result
- );
-
-/**
- Reads from the I/O space of a PCI Root Bridge. Returns when either the
- polling exit criteria is satisfied or after a defined duration.
-
- This function provides a standard way to poll a PCI I/O location. A PCI I/O
- read operation is performed at the PCI I/O address specified by Address for
- the width specified by Width. The result of this PCI I/O read operation is
- stored in Result. This PCI I/O read operation is repeated until either a
- timeout of Delay 100 ns units has expired, or (Result & Mask) is equal to
- Value.
-
- @param[in] This A pointer to the EFI_PCI_ROOT_BRIDGE_IO_PROTOCOL.
-
- @param[in] Width Signifies the width of the I/O operations.
-
- @param[in] Address The base address of the I/O operations. The caller is
- responsible for aligning Address if required.
-
- @param[in] Mask Mask used for the polling criteria. Bytes above Width in
- Mask are ignored. The bits in the bytes below Width
- which are zero in Mask are ignored when polling the I/O
- address.
-
- @param[in] Value The comparison value used for the polling exit criteria.
-
-
- @param[in] Delay The number of 100 ns units to poll. Note that timer
- available may be of poorer granularity.
-
- @param[out] Result Pointer to the last value read from the memory location.
-
- @retval EFI_SUCCESS The last data returned from the access matched
- the poll exit criteria.
-
- @retval EFI_INVALID_PARAMETER Width is invalid.
-
- @retval EFI_INVALID_PARAMETER Result is NULL.
-
- @retval EFI_TIMEOUT Delay expired before a match occurred.
-
- @retval EFI_OUT_OF_RESOURCES The request could not be completed due to a
- lack of resources.
-**/
-EFI_STATUS
-EFIAPI
-RootBridgeIoPollIo (
- IN EFI_PCI_ROOT_BRIDGE_IO_PROTOCOL *This,
- IN EFI_PCI_ROOT_BRIDGE_IO_PROTOCOL_WIDTH Width,
- IN UINT64 Address,
- IN UINT64 Mask,
- IN UINT64 Value,
- IN UINT64 Delay,
- OUT UINT64 *Result
- );
-
-/**
- Enables a PCI driver to access PCI controller registers in the PCI root
- bridge memory space.
-
- The Mem.Read(), and Mem.Write() functions enable a driver to access PCI
- controller registers in the PCI root bridge memory space.
- The memory operations are carried out exactly as requested. The caller is
- responsible for satisfying any alignment and memory width restrictions that a
- PCI Root Bridge on a platform might require.
-
- @param[in] This A pointer to the EFI_PCI_ROOT_BRIDGE_IO_PROTOCOL.
-
- @param[in] Width Signifies the width of the memory operation.
-
- @param[in] Address The base address of the memory operation. The caller
- is responsible for aligning the Address if required.
-
- @param[in] Count The number of memory operations to perform. Bytes
- moved is Width size * Count, starting at Address.
-
- @param[out] Buffer For read operations, the destination buffer to store
- the results. For write operations, the source buffer
- to write data from.
-
- @retval EFI_SUCCESS The data was read from or written to the PCI
- root bridge.
-
- @retval EFI_INVALID_PARAMETER Width is invalid for this PCI root bridge.
-
- @retval EFI_INVALID_PARAMETER Buffer is NULL.
-
- @retval EFI_OUT_OF_RESOURCES The request could not be completed due to a
- lack of resources.
-**/
-EFI_STATUS
-EFIAPI
-RootBridgeIoMemRead (
- IN EFI_PCI_ROOT_BRIDGE_IO_PROTOCOL *This,
- IN EFI_PCI_ROOT_BRIDGE_IO_PROTOCOL_WIDTH Width,
- IN UINT64 Address,
- IN UINTN Count,
- OUT VOID *Buffer
- );
-
-/**
- Enables a PCI driver to access PCI controller registers in the PCI root
- bridge memory space.
-
- The Mem.Read(), and Mem.Write() functions enable a driver to access PCI
- controller registers in the PCI root bridge memory space.
- The memory operations are carried out exactly as requested. The caller is
- responsible for satisfying any alignment and memory width restrictions that a
- PCI Root Bridge on a platform might require.
-
- @param[in] This A pointer to the EFI_PCI_ROOT_BRIDGE_IO_PROTOCOL.
-
- @param[in] Width Signifies the width of the memory operation.
-
- @param[in] Address The base address of the memory operation. The caller
- is responsible for aligning the Address if required.
-
- @param[in] Count The number of memory operations to perform. Bytes
- moved is Width size * Count, starting at Address.
-
- @param[in] Buffer For read operations, the destination buffer to store
- the results. For write operations, the source buffer
- to write data from.
-
- @retval EFI_SUCCESS The data was read from or written to the PCI
- root bridge.
-
- @retval EFI_INVALID_PARAMETER Width is invalid for this PCI root bridge.
-
- @retval EFI_INVALID_PARAMETER Buffer is NULL.
-
- @retval EFI_OUT_OF_RESOURCES The request could not be completed due to a
- lack of resources.
-**/
-EFI_STATUS
-EFIAPI
-RootBridgeIoMemWrite (
- IN EFI_PCI_ROOT_BRIDGE_IO_PROTOCOL *This,
- IN EFI_PCI_ROOT_BRIDGE_IO_PROTOCOL_WIDTH Width,
- IN UINT64 Address,
- IN UINTN Count,
- IN VOID *Buffer
- );
-
-/**
- Enables a PCI driver to access PCI controller registers in the PCI root
- bridge I/O space.
-
- @param[in] This A pointer to the EFI_PCI_ROOT_BRIDGE_IO_PROTOCOL.
-
- @param[in] Width Signifies the width of the memory operations.
-
- @param[in] UserAddress The base address of the I/O operation. The caller is
- responsible for aligning the Address if required.
-
- @param[in] Count The number of I/O operations to perform. Bytes moved
- is Width size * Count, starting at Address.
-
- @param[out] UserBuffer For read operations, the destination buffer to store
- the results. For write operations, the source buffer
- to write data from.
-
-
- @retval EFI_SUCCESS The data was read from or written to the PCI
- root bridge.
-
- @retval EFI_INVALID_PARAMETER Width is invalid for this PCI root bridge.
-
- @retval EFI_INVALID_PARAMETER Buffer is NULL.
-
- @retval EFI_OUT_OF_RESOURCES The request could not be completed due to a
- lack of resources.
-**/
-EFI_STATUS
-EFIAPI
-RootBridgeIoIoRead (
- IN EFI_PCI_ROOT_BRIDGE_IO_PROTOCOL *This,
- IN EFI_PCI_ROOT_BRIDGE_IO_PROTOCOL_WIDTH Width,
- IN UINT64 UserAddress,
- IN UINTN Count,
- OUT VOID *UserBuffer
- );
-
-/**
- Enables a PCI driver to access PCI controller registers in the PCI root
- bridge I/O space.
-
- @param[in] This A pointer to the EFI_PCI_ROOT_BRIDGE_IO_PROTOCOL.
-
- @param[in] Width Signifies the width of the memory operations.
-
- @param[in] UserAddress The base address of the I/O operation. The caller is
- responsible for aligning the Address if required.
-
- @param[in] Count The number of I/O operations to perform. Bytes moved
- is Width size * Count, starting at Address.
-
- @param[in] UserBuffer For read operations, the destination buffer to store
- the results. For write operations, the source buffer
- to write data from.
-
-
- @retval EFI_SUCCESS The data was read from or written to the PCI
- root bridge.
-
- @retval EFI_INVALID_PARAMETER Width is invalid for this PCI root bridge.
-
- @retval EFI_INVALID_PARAMETER Buffer is NULL.
-
- @retval EFI_OUT_OF_RESOURCES The request could not be completed due to a
- lack of resources.
-**/
-EFI_STATUS
-EFIAPI
-RootBridgeIoIoWrite (
- IN EFI_PCI_ROOT_BRIDGE_IO_PROTOCOL *This,
- IN EFI_PCI_ROOT_BRIDGE_IO_PROTOCOL_WIDTH Width,
- IN UINT64 UserAddress,
- IN UINTN Count,
- IN VOID *UserBuffer
- );
-
-/**
- Enables a PCI driver to copy one region of PCI root bridge memory space to
- another region of PCI root bridge memory space.
-
- The CopyMem() function enables a PCI driver to copy one region of PCI root
- bridge memory space to another region of PCI root bridge memory space. This
- is especially useful for video scroll operation on a memory mapped video
- buffer.
- The memory operations are carried out exactly as requested. The caller is
- responsible for satisfying any alignment and memory width restrictions that a
- PCI root bridge on a platform might require.
-
- @param[in] This A pointer to the EFI_PCI_ROOT_BRIDGE_IO_PROTOCOL
- instance.
-
- @param[in] Width Signifies the width of the memory operations.
-
- @param[in] DestAddress The destination address of the memory operation. The
- caller is responsible for aligning the DestAddress if
- required.
-
- @param[in] SrcAddress The source address of the memory operation. The caller
- is responsible for aligning the SrcAddress if
- required.
-
- @param[in] Count The number of memory operations to perform. Bytes
- moved is Width size * Count, starting at DestAddress
- and SrcAddress.
-
-
- @retval EFI_SUCCESS The data was copied from one memory region
- to another memory region.
-
- @retval EFI_INVALID_PARAMETER Width is invalid for this PCI root bridge.
-
- @retval EFI_OUT_OF_RESOURCES The request could not be completed due to a
- lack of resources.
-**/
-EFI_STATUS
-EFIAPI
-RootBridgeIoCopyMem (
- IN EFI_PCI_ROOT_BRIDGE_IO_PROTOCOL *This,
- IN EFI_PCI_ROOT_BRIDGE_IO_PROTOCOL_WIDTH Width,
- IN UINT64 DestAddress,
- IN UINT64 SrcAddress,
- IN UINTN Count
- );
-
-/**
- Enables a PCI driver to access PCI controller registers in a PCI root
- bridge's configuration space.
-
- The Pci.Read() and Pci.Write() functions enable a driver to access PCI
- configuration registers for a PCI controller.
- The PCI Configuration operations are carried out exactly as requested. The
- caller is responsible for any alignment and PCI configuration width issues
- that a PCI Root Bridge on a platform might require.
-
- @param[in] This A pointer to the EFI_PCI_ROOT_BRIDGE_IO_PROTOCOL.
-
- @param[in] Width Signifies the width of the memory operations.
-
- @param[in] Address The address within the PCI configuration space for the
- PCI controller.
-
- @param[in] Count The number of PCI configuration operations to perform.
- Bytes moved is Width size * Count, starting at
- Address.
-
- @param[out] Buffer For read operations, the destination buffer to store
- the results. For write operations, the source buffer
- to write data from.
-
-
- @retval EFI_SUCCESS The data was read from or written to the PCI
- root bridge.
-
- @retval EFI_INVALID_PARAMETER Width is invalid for this PCI root bridge.
-
- @retval EFI_INVALID_PARAMETER Buffer is NULL.
-
- @retval EFI_OUT_OF_RESOURCES The request could not be completed due to a
- lack of resources.
-**/
-EFI_STATUS
-EFIAPI
-RootBridgeIoPciRead (
- IN EFI_PCI_ROOT_BRIDGE_IO_PROTOCOL *This,
- IN EFI_PCI_ROOT_BRIDGE_IO_PROTOCOL_WIDTH Width,
- IN UINT64 Address,
- IN UINTN Count,
- OUT VOID *Buffer
- );
-
-/**
- Enables a PCI driver to access PCI controller registers in a PCI root
- bridge's configuration space.
-
- The Pci.Read() and Pci.Write() functions enable a driver to access PCI
- configuration registers for a PCI controller.
- The PCI Configuration operations are carried out exactly as requested. The
- caller is responsible for any alignment and PCI configuration width issues
- that a PCI Root Bridge on a platform might require.
-
- @param[in] This A pointer to the EFI_PCI_ROOT_BRIDGE_IO_PROTOCOL.
-
- @param[in] Width Signifies the width of the memory operations.
-
- @param[in] Address The address within the PCI configuration space for the
- PCI controller.
-
- @param[in] Count The number of PCI configuration operations to perform.
- Bytes moved is Width size * Count, starting at
- Address.
-
- @param[in] Buffer For read operations, the destination buffer to store
- the results. For write operations, the source buffer
- to write data from.
-
-
- @retval EFI_SUCCESS The data was read from or written to the PCI
- root bridge.
-
- @retval EFI_INVALID_PARAMETER Width is invalid for this PCI root bridge.
-
- @retval EFI_INVALID_PARAMETER Buffer is NULL.
-
- @retval EFI_OUT_OF_RESOURCES The request could not be completed due to a
- lack of resources.
-**/
-EFI_STATUS
-EFIAPI
-RootBridgeIoPciWrite (
- IN EFI_PCI_ROOT_BRIDGE_IO_PROTOCOL *This,
- IN EFI_PCI_ROOT_BRIDGE_IO_PROTOCOL_WIDTH Width,
- IN UINT64 Address,
- IN UINTN Count,
- IN VOID *Buffer
- );
-
-/**
- Provides the PCI controller-specific addresses required to access system
- memory from a DMA bus master.
-
- The Map() function provides the PCI controller specific addresses needed to
- access system memory. This function is used to map system memory for PCI bus
- master DMA accesses.
-
- @param[in] This A pointer to the
- EFI_PCI_ROOT_BRIDGE_IO_PROTOCOL.
-
- @param[in] Operation Indicates if the bus master is going to read
- or write to system memory.
-
- @param[in] HostAddress The system memory address to map to the PCI
- controller.
-
- @param[in, out] NumberOfBytes On input the number of bytes to map. On
- output the number of bytes that were mapped.
-
- @param[out] DeviceAddress The resulting map address for the bus master
- PCI controller to use to access the system
- memory's HostAddress.
-
- @param[out] Mapping The value to pass to Unmap() when the bus
- master DMA operation is complete.
-
- @retval EFI_SUCCESS The range was mapped for the returned
- NumberOfBytes.
-
- @retval EFI_INVALID_PARAMETER Operation is invalid.
-
- @retval EFI_INVALID_PARAMETER HostAddress is NULL.
-
- @retval EFI_INVALID_PARAMETER NumberOfBytes is NULL.
-
- @retval EFI_INVALID_PARAMETER DeviceAddress is NULL.
-
- @retval EFI_INVALID_PARAMETER Mapping is NULL.
-
- @retval EFI_UNSUPPORTED The HostAddress cannot be mapped as a common
- buffer.
-
- @retval EFI_DEVICE_ERROR The system hardware could not map the
- requested address.
-
- @retval EFI_OUT_OF_RESOURCES The request could not be completed due to a
- lack of resources.
-**/
-EFI_STATUS
-EFIAPI
-RootBridgeIoMap (
- IN EFI_PCI_ROOT_BRIDGE_IO_PROTOCOL *This,
- IN EFI_PCI_ROOT_BRIDGE_IO_PROTOCOL_OPERATION Operation,
- IN VOID *HostAddress,
- IN OUT UINTN *NumberOfBytes,
- OUT EFI_PHYSICAL_ADDRESS *DeviceAddress,
- OUT VOID **Mapping
- );
-
-/**
- Completes the Map() operation and releases any corresponding resources.
-
- The Unmap() function completes the Map() operation and releases any
- corresponding resources.
- If the operation was an EfiPciOperationBusMasterWrite or
- EfiPciOperationBusMasterWrite64, the data is committed to the target system
- memory.
- Any resources used for the mapping are freed.
-
- @param[in] This A pointer to the EFI_PCI_ROOT_BRIDGE_IO_PROTOCOL.
-
- @param[in] Mapping The mapping value returned from Map().
-
- @retval EFI_SUCCESS The range was unmapped.
-
- @retval EFI_INVALID_PARAMETER Mapping is not a value that was returned by
- Map().
-
- @retval EFI_DEVICE_ERROR The data was not committed to the target
- system memory.
-**/
-EFI_STATUS
-EFIAPI
-RootBridgeIoUnmap (
- IN EFI_PCI_ROOT_BRIDGE_IO_PROTOCOL *This,
- IN VOID *Mapping
- );
-
-/**
- Allocates pages that are suitable for an EfiPciOperationBusMasterCommonBuffer
- or EfiPciOperationBusMasterCommonBuffer64 mapping.
-
- @param This A pointer to the EFI_PCI_ROOT_BRIDGE_IO_PROTOCOL.
-
- @param Type This parameter is not used and must be ignored.
-
- @param MemoryType The type of memory to allocate, EfiBootServicesData or
- EfiRuntimeServicesData.
-
- @param Pages The number of pages to allocate.
-
- @param HostAddress A pointer to store the base system memory address of the
- allocated range.
-
- @param Attributes The requested bit mask of attributes for the allocated
- range. Only the attributes
- EFI_PCI_ATTRIBUTE_MEMORY_WRITE_COMBINE,
- EFI_PCI_ATTRIBUTE_MEMORY_CACHED, and
- EFI_PCI_ATTRIBUTE_DUAL_ADDRESS_CYCLE may be used with this
- function.
-
- @retval EFI_SUCCESS The requested memory pages were allocated.
-
- @retval EFI_INVALID_PARAMETER MemoryType is invalid.
-
- @retval EFI_INVALID_PARAMETER HostAddress is NULL.
-
- @retval EFI_UNSUPPORTED Attributes is unsupported. The only legal
- attribute bits are MEMORY_WRITE_COMBINE,
- MEMORY_CACHED, and DUAL_ADDRESS_CYCLE.
-
- @retval EFI_OUT_OF_RESOURCES The memory pages could not be allocated.
-**/
-EFI_STATUS
-EFIAPI
-RootBridgeIoAllocateBuffer (
- IN EFI_PCI_ROOT_BRIDGE_IO_PROTOCOL *This,
- IN EFI_ALLOCATE_TYPE Type,
- IN EFI_MEMORY_TYPE MemoryType,
- IN UINTN Pages,
- OUT VOID **HostAddress,
- IN UINT64 Attributes
- );
-
-/**
- Frees memory that was allocated with AllocateBuffer().
-
- The FreeBuffer() function frees memory that was allocated with
- AllocateBuffer().
-
- @param This A pointer to the EFI_PCI_ROOT_BRIDGE_IO_PROTOCOL.
-
- @param Pages The number of pages to free.
-
- @param HostAddress The base system memory address of the allocated range.
-
- @retval EFI_SUCCESS The requested memory pages were freed.
-
- @retval EFI_INVALID_PARAMETER The memory range specified by HostAddress and
- Pages was not allocated with AllocateBuffer().
-**/
-EFI_STATUS
-EFIAPI
-RootBridgeIoFreeBuffer (
- IN EFI_PCI_ROOT_BRIDGE_IO_PROTOCOL *This,
- IN UINTN Pages,
- OUT VOID *HostAddress
- );
-
-/**
- Flushes all PCI posted write transactions from a PCI host bridge to system
- memory.
-
- The Flush() function flushes any PCI posted write transactions from a PCI
- host bridge to system memory. Posted write transactions are generated by PCI
- bus masters when they perform write transactions to target addresses in
- system memory.
- This function does not flush posted write transactions from any PCI bridges.
- A PCI controller specific action must be taken to guarantee that the posted
- write transactions have been flushed from the PCI controller and from all the
- PCI bridges into the PCI host bridge. This is typically done with a PCI read
- transaction from the PCI controller prior to calling Flush().
-
- @param This A pointer to the EFI_PCI_ROOT_BRIDGE_IO_PROTOCOL.
-
- @retval EFI_SUCCESS The PCI posted write transactions were flushed
- from the PCI host bridge to system memory.
-
- @retval EFI_DEVICE_ERROR The PCI posted write transactions were not flushed
- from the PCI host bridge due to a hardware error.
-**/
-EFI_STATUS
-EFIAPI
-RootBridgeIoFlush (
- IN EFI_PCI_ROOT_BRIDGE_IO_PROTOCOL *This
- );
-
-/**
- Gets the attributes that a PCI root bridge supports setting with
- SetAttributes(), and the attributes that a PCI root bridge is currently
- using.
-
- The GetAttributes() function returns the mask of attributes that this PCI
- root bridge supports and the mask of attributes that the PCI root bridge is
- currently using.
-
- @param This A pointer to the EFI_PCI_ROOT_BRIDGE_IO_PROTOCOL.
-
- @param Supported A pointer to the mask of attributes that this PCI root
- bridge supports setting with SetAttributes().
-
- @param Attributes A pointer to the mask of attributes that this PCI root
- bridge is currently using.
-
-
- @retval EFI_SUCCESS If Supports is not NULL, then the attributes
- that the PCI root bridge supports is returned
- in Supports. If Attributes is not NULL, then
- the attributes that the PCI root bridge is
- currently using is returned in Attributes.
-
- @retval EFI_INVALID_PARAMETER Both Supports and Attributes are NULL.
-**/
-EFI_STATUS
-EFIAPI
-RootBridgeIoGetAttributes (
- IN EFI_PCI_ROOT_BRIDGE_IO_PROTOCOL *This,
- OUT UINT64 *Supported,
- OUT UINT64 *Attributes
- );
-
-/**
- Sets attributes for a resource range on a PCI root bridge.
-
- The SetAttributes() function sets the attributes specified in Attributes for
- the PCI root bridge on the resource range specified by ResourceBase and
- ResourceLength. Since the granularity of setting these attributes may vary
- from resource type to resource type, and from platform to platform, the
- actual resource range and the one passed in by the caller may differ. As a
- result, this function may set the attributes specified by Attributes on a
- larger resource range than the caller requested. The actual range is returned
- in ResourceBase and ResourceLength. The caller is responsible for verifying
- that the actual range for which the attributes were set is acceptable.
-
- @param[in] This A pointer to the
- EFI_PCI_ROOT_BRIDGE_IO_PROTOCOL.
-
- @param[in] Attributes The mask of attributes to set. If the
- attribute bit MEMORY_WRITE_COMBINE,
- MEMORY_CACHED, or MEMORY_DISABLE is set,
- then the resource range is specified by
- ResourceBase and ResourceLength. If
- MEMORY_WRITE_COMBINE, MEMORY_CACHED, and
- MEMORY_DISABLE are not set, then
- ResourceBase and ResourceLength are ignored,
- and may be NULL.
-
- @param[in, out] ResourceBase A pointer to the base address of the
- resource range to be modified by the
- attributes specified by Attributes.
-
- @param[in, out] ResourceLength A pointer to the length of the resource
- range to be modified by the attributes
- specified by Attributes.
-
- @retval EFI_SUCCESS The current configuration of this PCI root bridge
- was returned in Resources.
-
- @retval EFI_UNSUPPORTED The current configuration of this PCI root bridge
- could not be retrieved.
-
- @retval EFI_INVALID_PARAMETER Invalid pointer of
- EFI_PCI_ROOT_BRIDGE_IO_PROTOCOL
-
-**/
-EFI_STATUS
-EFIAPI
-RootBridgeIoSetAttributes (
- IN EFI_PCI_ROOT_BRIDGE_IO_PROTOCOL *This,
- IN UINT64 Attributes,
- IN OUT UINT64 *ResourceBase,
- IN OUT UINT64 *ResourceLength
- );
-
-/**
- Retrieves the current resource settings of this PCI root bridge in the form
- of a set of ACPI 2.0 resource descriptors.
-
- There are only two resource descriptor types from the ACPI Specification that
- may be used to describe the current resources allocated to a PCI root bridge.
- These are the QWORD Address Space Descriptor (ACPI 2.0 Section 6.4.3.5.1),
- and the End Tag (ACPI 2.0 Section 6.4.2.8). 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.
-
- @param[in] This A pointer to the EFI_PCI_ROOT_BRIDGE_IO_PROTOCOL.
-
- @param[out] Resources A pointer to the ACPI 2.0 resource descriptors that
- describe the current configuration of this PCI root
- bridge. The storage for the ACPI 2.0 resource
- descriptors is allocated by this function. The
- caller must treat the return buffer as read-only
- data, and the buffer must not be freed by the
- caller.
-
- @retval EFI_SUCCESS The current configuration of this PCI root bridge
- was returned in Resources.
-
- @retval EFI_UNSUPPORTED The current configuration of this PCI root bridge
- could not be retrieved.
-
- @retval EFI_INVALID_PARAMETER Invalid pointer of
- EFI_PCI_ROOT_BRIDGE_IO_PROTOCOL
-**/
-EFI_STATUS
-EFIAPI
-RootBridgeIoConfiguration (
- IN EFI_PCI_ROOT_BRIDGE_IO_PROTOCOL *This,
- OUT VOID **Resources
- );
-
-//
-// Memory Controller Pci Root Bridge Io Module Variables
-//
-EFI_METRONOME_ARCH_PROTOCOL *mMetronome;
-
-//
-// Lookup table for increment values based on transfer widths
-//
-UINT8 mInStride[] = {
- 1, // EfiPciWidthUint8
- 2, // EfiPciWidthUint16
- 4, // EfiPciWidthUint32
- 8, // EfiPciWidthUint64
- 0, // EfiPciWidthFifoUint8
- 0, // EfiPciWidthFifoUint16
- 0, // EfiPciWidthFifoUint32
- 0, // EfiPciWidthFifoUint64
- 1, // EfiPciWidthFillUint8
- 2, // EfiPciWidthFillUint16
- 4, // EfiPciWidthFillUint32
- 8 // EfiPciWidthFillUint64
-};
-
-//
-// Lookup table for increment values based on transfer widths
-//
-UINT8 mOutStride[] = {
- 1, // EfiPciWidthUint8
- 2, // EfiPciWidthUint16
- 4, // EfiPciWidthUint32
- 8, // EfiPciWidthUint64
- 1, // EfiPciWidthFifoUint8
- 2, // EfiPciWidthFifoUint16
- 4, // EfiPciWidthFifoUint32
- 8, // EfiPciWidthFifoUint64
- 0, // EfiPciWidthFillUint8
- 0, // EfiPciWidthFillUint16
- 0, // EfiPciWidthFillUint32
- 0 // EfiPciWidthFillUint64
-};
-
-/**
- Construct the Pci Root Bridge Io protocol
-
- @param Protocol Point to protocol instance
-
- @param HostBridgeHandle Handle of host bridge
-
- @param Attri Attribute of host bridge
-
- @param ResAperture ResourceAperture for host bridge
-
- @retval EFI_SUCCESS Success to initialize the Pci Root Bridge.
-**/
-EFI_STATUS
-RootBridgeConstructor (
- IN EFI_PCI_ROOT_BRIDGE_IO_PROTOCOL *Protocol,
- IN EFI_HANDLE HostBridgeHandle,
- IN UINT64 Attri,
- IN PCI_ROOT_BRIDGE_RESOURCE_APERTURE *ResAperture
- )
-{
- EFI_STATUS Status;
- PCI_ROOT_BRIDGE_INSTANCE *PrivateData;
- PCI_RESOURCE_TYPE Index;
-
- PrivateData = DRIVER_INSTANCE_FROM_PCI_ROOT_BRIDGE_IO_THIS (Protocol);
-
- //
- // The host to pci bridge, the host memory and io addresses are
- // direct mapped to pci addresses, so no need translate, set bases to 0.
- //
- PrivateData->MemBase = ResAperture->MemBase;
- PrivateData->IoBase = ResAperture->IoBase;
-
- //
- // The host bridge only supports 32bit addressing for memory
- // and standard IA32 16bit io
- //
- PrivateData->MemLimit = ResAperture->MemLimit;
- PrivateData->IoLimit = ResAperture->IoLimit;
-
- //
- // Bus Aperture for this Root Bridge (Possible Range)
- //
- PrivateData->BusBase = ResAperture->BusBase;
- PrivateData->BusLimit = ResAperture->BusLimit;
-
- //
- // Specific for this chipset
- //
- for (Index = TypeIo; Index < TypeMax; Index++) {
- PrivateData->ResAllocNode[Index].Type = Index;
- PrivateData->ResAllocNode[Index].Base = 0;
- PrivateData->ResAllocNode[Index].Length = 0;
- PrivateData->ResAllocNode[Index].Status = ResNone;
- }
-
- PrivateData->RootBridgeAttrib = Attri;
-
- PrivateData->Supports = 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;
- PrivateData->Attributes = PrivateData->Supports;
-
- Protocol->ParentHandle = HostBridgeHandle;
-
- Protocol->PollMem = RootBridgeIoPollMem;
- Protocol->PollIo = RootBridgeIoPollIo;
-
- Protocol->Mem.Read = RootBridgeIoMemRead;
- Protocol->Mem.Write = RootBridgeIoMemWrite;
-
- Protocol->Io.Read = RootBridgeIoIoRead;
- Protocol->Io.Write = RootBridgeIoIoWrite;
-
- Protocol->CopyMem = RootBridgeIoCopyMem;
-
- Protocol->Pci.Read = RootBridgeIoPciRead;
- Protocol->Pci.Write = RootBridgeIoPciWrite;
-
- Protocol->Map = RootBridgeIoMap;
- Protocol->Unmap = RootBridgeIoUnmap;
-
- Protocol->AllocateBuffer = RootBridgeIoAllocateBuffer;
- Protocol->FreeBuffer = RootBridgeIoFreeBuffer;
-
- Protocol->Flush = RootBridgeIoFlush;
-
- Protocol->GetAttributes = RootBridgeIoGetAttributes;
- Protocol->SetAttributes = RootBridgeIoSetAttributes;
-
- Protocol->Configuration = RootBridgeIoConfiguration;
-
- Protocol->SegmentNumber = 0;
-
- Status = gBS->LocateProtocol (&gEfiMetronomeArchProtocolGuid, NULL,
- (VOID **)&mMetronome);
- ASSERT_EFI_ERROR (Status);
-
- return EFI_SUCCESS;
-}
-
-/**
- Check parameters for IO,MMIO,PCI read/write services of PCI Root Bridge IO.
-
- The I/O operations are carried out exactly as requested. The caller is
- responsible for satisfying any alignment and I/O width restrictions that a PI
- System on a platform might require. For example on some platforms, width
- requests of EfiCpuIoWidthUint64 do not work. Misaligned buffers, on the other
- hand, will be handled by the driver.
-
- @param[in] This A pointer to the EFI_PCI_ROOT_BRIDGE_IO_PROTOCOL.
-
- @param[in] OperationType I/O operation type: IO/MMIO/PCI.
-
- @param[in] Width Signifies the width of the I/O or Memory operation.
-
- @param[in] Address The base address of the I/O operation.
-
- @param[in] Count The number of I/O operations to perform. The number
- of bytes moved is Width size * Count, starting at
- Address.
-
- @param[in] Buffer For read operations, the destination buffer to
- store the results. For write operations, the source
- buffer from which to write data.
-
- @retval EFI_SUCCESS The parameters for this request pass the
- checks.
-
- @retval EFI_INVALID_PARAMETER Width is invalid for this PI system.
-
- @retval EFI_INVALID_PARAMETER Buffer is NULL.
-
- @retval EFI_UNSUPPORTED The Buffer is not aligned for the given Width.
-
- @retval EFI_UNSUPPORTED The address range specified by Address, Width,
- and Count is not valid for this PI system.
-**/
-EFI_STATUS
-RootBridgeIoCheckParameter (
- IN EFI_PCI_ROOT_BRIDGE_IO_PROTOCOL *This,
- IN OPERATION_TYPE OperationType,
- IN EFI_PCI_ROOT_BRIDGE_IO_PROTOCOL_WIDTH Width,
- IN UINT64 Address,
- IN UINTN Count,
- IN VOID *Buffer
- )
-{
- PCI_ROOT_BRIDGE_INSTANCE *PrivateData;
- EFI_PCI_ROOT_BRIDGE_IO_PROTOCOL_PCI_ADDRESS *PciRbAddr;
- UINT64 MaxCount;
- UINT64 Base;
- UINT64 Limit;
-
- //
- // Check to see if Buffer is NULL
- //
- if (Buffer == NULL) {
- return EFI_INVALID_PARAMETER;
- }
-
- //
- // Check to see if Width is in the valid range
- //
- if ((UINT32)Width >= EfiPciWidthMaximum) {
- return EFI_INVALID_PARAMETER;
- }
-
- //
- // For FIFO type, the target address won't increase during the access,
- // so treat Count as 1
- //
- if (Width >= EfiPciWidthFifoUint8 && Width <= EfiPciWidthFifoUint64) {
- Count = 1;
- }
-
- //
- // Check to see if Width is in the valid range for I/O Port operations
- //
- Width = (EFI_PCI_ROOT_BRIDGE_IO_PROTOCOL_WIDTH) (Width & 0x03);
- if ((OperationType != MemOperation) && (Width == EfiPciWidthUint64)) {
- ASSERT (FALSE);
- return EFI_INVALID_PARAMETER;
- }
-
- //
- // Check to see if Address is aligned
- //
- if ((Address & (UINT64)(mInStride[Width] - 1)) != 0) {
- return EFI_UNSUPPORTED;
- }
-
- PrivateData = DRIVER_INSTANCE_FROM_PCI_ROOT_BRIDGE_IO_THIS (This);
-
- //
- // Check to see if any address associated with this transfer exceeds the
- // maximum allowed address. The maximum address implied by the parameters
- // passed in is Address + Size * Count. If the following condition is met,
- // then the transfer is not supported.
- //
- // Address + Size * Count > Limit + 1
- //
- // Since Limit can be the maximum integer value supported by the CPU and
- // Count can also be the maximum integer value supported by the CPU, this
- // range check must be adjusted to avoid all oveflow conditions.
- //
- // The following form of the range check is equivalent but assumes that
- // Limit is of the form (2^n - 1).
- //
- if (OperationType == IoOperation) {
- Base = PrivateData->IoBase;
- Limit = PrivateData->IoLimit;
- } else if (OperationType == MemOperation) {
- Base = PrivateData->MemBase;
- Limit = PrivateData->MemLimit;
- } else {
- PciRbAddr = (EFI_PCI_ROOT_BRIDGE_IO_PROTOCOL_PCI_ADDRESS*) &Address;
- if (PciRbAddr->Bus < PrivateData->BusBase ||
- PciRbAddr->Bus > PrivateData->BusLimit) {
- return EFI_INVALID_PARAMETER;
- }
-
- if (PciRbAddr->Device > MAX_PCI_DEVICE_NUMBER ||
- PciRbAddr->Function > MAX_PCI_FUNCTION_NUMBER) {
- return EFI_INVALID_PARAMETER;
- }
-
- if (PciRbAddr->ExtendedRegister != 0) {
- Address = PciRbAddr->ExtendedRegister;
- } else {
- Address = PciRbAddr->Register;
- }
- Base = 0;
- Limit = MAX_PCI_REG_ADDRESS;
- }
-
- if (Address < Base) {
- return EFI_INVALID_PARAMETER;
- }
-
- if (Count == 0) {
- if (Address > Limit) {
- return EFI_UNSUPPORTED;
- }
- } else {
- MaxCount = RShiftU64 (Limit, Width);
- if (MaxCount < (Count - 1)) {
- return EFI_UNSUPPORTED;
- }
- if (Address > LShiftU64 (MaxCount - Count + 1, Width)) {
- return EFI_UNSUPPORTED;
- }
- }
-
- return EFI_SUCCESS;
-}
-
-/**
- Internal help function for read and write memory space.
-
- @param[in] This A pointer to the EFI_PCI_ROOT_BRIDGE_IO_PROTOCOL.
-
- @param[in] Write Switch value for Read or Write.
-
- @param[in] Width Signifies the width of the memory operations.
-
- @param[in] UserAddress The address within the PCI configuration space for
- the PCI controller.
-
- @param[in] Count The number of PCI configuration operations to
- perform. Bytes moved is Width size * Count,
- starting at Address.
-
- @param[in, out] UserBuffer For read operations, the destination buffer to
- store the results. For write operations, the
- source buffer to write data from.
-
- @retval EFI_SUCCESS The data was read from or written to the PCI
- root bridge.
-
- @retval EFI_INVALID_PARAMETER Width is invalid for this PCI root bridge.
-
- @retval EFI_INVALID_PARAMETER Buffer is NULL.
-
- @retval EFI_OUT_OF_RESOURCES The request could not be completed due to a
- lack of resources.
-**/
-EFI_STATUS
-RootBridgeIoMemRW (
- IN EFI_PCI_ROOT_BRIDGE_IO_PROTOCOL *This,
- IN BOOLEAN Write,
- IN EFI_PCI_ROOT_BRIDGE_IO_PROTOCOL_WIDTH Width,
- IN UINT64 Address,
- IN UINTN Count,
- IN OUT VOID *Buffer
- )
-{
- EFI_STATUS Status;
- UINT8 InStride;
- UINT8 OutStride;
- EFI_PCI_ROOT_BRIDGE_IO_PROTOCOL_WIDTH OperationWidth;
- UINT8 *Uint8Buffer;
-
- Status = RootBridgeIoCheckParameter (This, MemOperation, Width, Address,
- Count, Buffer);
- if (EFI_ERROR (Status)) {
- return Status;
- }
-
- InStride = mInStride[Width];
- OutStride = mOutStride[Width];
- OperationWidth = (EFI_PCI_ROOT_BRIDGE_IO_PROTOCOL_WIDTH) (Width & 0x03);
- for (Uint8Buffer = Buffer;
- Count > 0;
- Address += InStride, Uint8Buffer += OutStride, Count--) {
- if (Write) {
- switch (OperationWidth) {
- case EfiPciWidthUint8:
- MmioWrite8 ((UINTN)Address, *Uint8Buffer);
- break;
- case EfiPciWidthUint16:
- MmioWrite16 ((UINTN)Address, *((UINT16 *)Uint8Buffer));
- break;
- case EfiPciWidthUint32:
- MmioWrite32 ((UINTN)Address, *((UINT32 *)Uint8Buffer));
- break;
- case EfiPciWidthUint64:
- MmioWrite64 ((UINTN)Address, *((UINT64 *)Uint8Buffer));
- break;
- default:
- //
- // The RootBridgeIoCheckParameter call above will ensure that this
- // path is not taken.
- //
- ASSERT (FALSE);
- break;
- }
- } else {
- switch (OperationWidth) {
- case EfiPciWidthUint8:
- *Uint8Buffer = MmioRead8 ((UINTN)Address);
- break;
- case EfiPciWidthUint16:
- *((UINT16 *)Uint8Buffer) = MmioRead16 ((UINTN)Address);
- break;
- case EfiPciWidthUint32:
- *((UINT32 *)Uint8Buffer) = MmioRead32 ((UINTN)Address);
- break;
- case EfiPciWidthUint64:
- *((UINT64 *)Uint8Buffer) = MmioRead64 ((UINTN)Address);
- break;
- default:
- //
- // The RootBridgeIoCheckParameter call above will ensure that this
- // path is not taken.
- //
- ASSERT (FALSE);
- break;
- }
- }
- }
- return EFI_SUCCESS;
-}
-
-/**
- Internal help function for read and write IO space.
-
- @param[in] This A pointer to the EFI_PCI_ROOT_BRIDGE_IO_PROTOCOL.
-
- @param[in] Write Switch value for Read or Write.
-
- @param[in] Width Signifies the width of the memory operations.
-
- @param[in] UserAddress The address within the PCI configuration space for
- the PCI controller.
-
- @param[in] Count The number of PCI configuration operations to
- perform. Bytes moved is Width size * Count,
- starting at Address.
-
- @param[in, out] UserBuffer For read operations, the destination buffer to
- store the results. For write operations, the
- source buffer to write data from.
-
-
- @retval EFI_SUCCESS The data was read from or written to the PCI
- root bridge.
-
- @retval EFI_INVALID_PARAMETER Width is invalid for this PCI root bridge.
-
- @retval EFI_INVALID_PARAMETER Buffer is NULL.
-
- @retval EFI_OUT_OF_RESOURCES The request could not be completed due to a
- lack of resources.
-**/
-EFI_STATUS
-RootBridgeIoIoRW (
- IN EFI_PCI_ROOT_BRIDGE_IO_PROTOCOL *This,
- IN BOOLEAN Write,
- IN EFI_PCI_ROOT_BRIDGE_IO_PROTOCOL_WIDTH Width,
- IN UINT64 Address,
- IN UINTN Count,
- IN OUT VOID *Buffer
- )
-{
- EFI_STATUS Status;
- UINT8 InStride;
- UINT8 OutStride;
- EFI_PCI_ROOT_BRIDGE_IO_PROTOCOL_WIDTH OperationWidth;
- UINT8 *Uint8Buffer;
-
- Status = RootBridgeIoCheckParameter (This, IoOperation, Width, Address,
- Count, Buffer);
- if (EFI_ERROR (Status)) {
- return Status;
- }
-
- InStride = mInStride[Width];
- OutStride = mOutStride[Width];
- OperationWidth = (EFI_PCI_ROOT_BRIDGE_IO_PROTOCOL_WIDTH) (Width & 0x03);
-
-#if defined (MDE_CPU_IA32) || defined (MDE_CPU_X64)
- if (InStride == 0) {
- if (Write) {
- switch (OperationWidth) {
- case EfiPciWidthUint8:
- IoWriteFifo8 ((UINTN) Address, Count, Buffer);
- return EFI_SUCCESS;
- case EfiPciWidthUint16:
- IoWriteFifo16 ((UINTN) Address, Count, Buffer);
- return EFI_SUCCESS;
- case EfiPciWidthUint32:
- IoWriteFifo32 ((UINTN) Address, Count, Buffer);
- return EFI_SUCCESS;
- default:
- //
- // The RootBridgeIoCheckParameter call above will ensure that this
- // path is not taken.
- //
- ASSERT (FALSE);
- break;
- }
- } else {
- switch (OperationWidth) {
- case EfiPciWidthUint8:
- IoReadFifo8 ((UINTN) Address, Count, Buffer);
- return EFI_SUCCESS;
- case EfiPciWidthUint16:
- IoReadFifo16 ((UINTN) Address, Count, Buffer);
- return EFI_SUCCESS;
- case EfiPciWidthUint32:
- IoReadFifo32 ((UINTN) Address, Count, Buffer);
- return EFI_SUCCESS;
- default:
- //
- // The RootBridgeIoCheckParameter call above will ensure that this
- // path is not taken.
- //
- ASSERT (FALSE);
- break;
- }
- }
- }
-#endif
-
- for (Uint8Buffer = Buffer;
- Count > 0;
- Address += InStride, Uint8Buffer += OutStride, Count--) {
- if (Write) {
- switch (OperationWidth) {
- case EfiPciWidthUint8:
- IoWrite8 ((UINTN)Address, *Uint8Buffer);
- break;
- case EfiPciWidthUint16:
- IoWrite16 ((UINTN)Address, *((UINT16 *)Uint8Buffer));
- break;
- case EfiPciWidthUint32:
- IoWrite32 ((UINTN)Address, *((UINT32 *)Uint8Buffer));
- break;
- default:
- //
- // The RootBridgeIoCheckParameter call above will ensure that this
- // path is not taken.
- //
- ASSERT (FALSE);
- break;
- }
- } else {
- switch (OperationWidth) {
- case EfiPciWidthUint8:
- *Uint8Buffer = IoRead8 ((UINTN)Address);
- break;
- case EfiPciWidthUint16:
- *((UINT16 *)Uint8Buffer) = IoRead16 ((UINTN)Address);
- break;
- case EfiPciWidthUint32:
- *((UINT32 *)Uint8Buffer) = IoRead32 ((UINTN)Address);
- break;
- default:
- //
- // The RootBridgeIoCheckParameter call above will ensure that this
- // path is not taken.
- //
- ASSERT (FALSE);
- break;
- }
- }
- }
- return EFI_SUCCESS;
-}
-
-/**
- Internal help function for read and write PCI configuration space.
-
- @param[in] This A pointer to the EFI_PCI_ROOT_BRIDGE_IO_PROTOCOL.
-
- @param[in] Write Switch value for Read or Write.
-
- @param[in] Width Signifies the width of the memory operations.
-
- @param[in] UserAddress The address within the PCI configuration space for
- the PCI controller.
-
- @param[in] Count The number of PCI configuration operations to
- perform. Bytes moved is Width size * Count,
- starting at Address.
-
- @param[in, out] UserBuffer For read operations, the destination buffer to
- store the results. For write operations, the
- source buffer to write data from.
-
-
- @retval EFI_SUCCESS The data was read from or written to the PCI
- root bridge.
-
- @retval EFI_INVALID_PARAMETER Width is invalid for this PCI root bridge.
-
- @retval EFI_INVALID_PARAMETER Buffer is NULL.
-
- @retval EFI_OUT_OF_RESOURCES The request could not be completed due to a
- lack of resources.
-**/
-EFI_STATUS
-RootBridgeIoPciRW (
- IN EFI_PCI_ROOT_BRIDGE_IO_PROTOCOL *This,
- IN BOOLEAN Write,
- IN EFI_PCI_ROOT_BRIDGE_IO_PROTOCOL_WIDTH Width,
- IN UINT64 Address,
- IN UINTN Count,
- IN OUT VOID *Buffer
- )
-{
- EFI_STATUS Status;
- UINT8 InStride;
- UINT8 OutStride;
- EFI_PCI_ROOT_BRIDGE_IO_PROTOCOL_WIDTH OperationWidth;
- UINT8 *Uint8Buffer;
- EFI_PCI_ROOT_BRIDGE_IO_PROTOCOL_PCI_ADDRESS *PciRbAddr;
- UINTN PcieRegAddr;
-
- Status = RootBridgeIoCheckParameter (This, PciOperation, Width, Address,
- Count, Buffer);
- if (EFI_ERROR (Status)) {
- return Status;
- }
-
- PciRbAddr = (EFI_PCI_ROOT_BRIDGE_IO_PROTOCOL_PCI_ADDRESS*) &Address;
-
- PcieRegAddr = (UINTN) PCI_LIB_ADDRESS (
- PciRbAddr->Bus,
- PciRbAddr->Device,
- PciRbAddr->Function,
- (PciRbAddr->ExtendedRegister != 0) ? \
- PciRbAddr->ExtendedRegister :
- PciRbAddr->Register
- );
-
- InStride = mInStride[Width];
- OutStride = mOutStride[Width];
- OperationWidth = (EFI_PCI_ROOT_BRIDGE_IO_PROTOCOL_WIDTH) (Width & 0x03);
- for (Uint8Buffer = Buffer;
- Count > 0;
- PcieRegAddr += InStride, Uint8Buffer += OutStride, Count--) {
- if (Write) {
- switch (OperationWidth) {
- case EfiPciWidthUint8:
- PciWrite8 (PcieRegAddr, *Uint8Buffer);
- break;
- case EfiPciWidthUint16:
- PciWrite16 (PcieRegAddr, *((UINT16 *)Uint8Buffer));
- break;
- case EfiPciWidthUint32:
- PciWrite32 (PcieRegAddr, *((UINT32 *)Uint8Buffer));
- break;
- default:
- //
- // The RootBridgeIoCheckParameter call above will ensure that this
- // path is not taken.
- //
- ASSERT (FALSE);
- break;
- }
- } else {
- switch (OperationWidth) {
- case EfiPciWidthUint8:
- *Uint8Buffer = PciRead8 (PcieRegAddr);
- break;
- case EfiPciWidthUint16:
- *((UINT16 *)Uint8Buffer) = PciRead16 (PcieRegAddr);
- break;
- case EfiPciWidthUint32:
- *((UINT32 *)Uint8Buffer) = PciRead32 (PcieRegAddr);
- break;
- default:
- //
- // The RootBridgeIoCheckParameter call above will ensure that this
- // path is not taken.
- //
- ASSERT (FALSE);
- break;
- }
- }
- }
-
- return EFI_SUCCESS;
-}
-
-/**
- Polls an address in memory mapped I/O space until an exit condition is met,
- or a timeout occurs.
-
- This function provides a standard way to poll a PCI memory location. A PCI
- memory read operation is performed at the PCI memory address specified by
- Address for the width specified by Width. The result of this PCI memory read
- operation is stored in Result. This PCI memory read operation is repeated
- until either a timeout of Delay 100 ns units has expired, or (Result & Mask)
- is equal to Value.
-
- @param[in] This A pointer to the EFI_PCI_ROOT_BRIDGE_IO_PROTOCOL.
-
- @param[in] Width Signifies the width of the memory operations.
-
- @param[in] Address The base address of the memory operations. The caller
- is responsible for aligning Address if required.
-
- @param[in] Mask Mask used for the polling criteria. Bytes above Width
- in Mask are ignored. The bits in the bytes below Width
- which are zero in Mask are ignored when polling the
- memory address.
-
- @param[in] Value The comparison value used for the polling exit
- criteria.
-
- @param[in] Delay The number of 100 ns units to poll. Note that timer
- available may be of poorer granularity.
-
- @param[out] Result Pointer to the last value read from the memory
- location.
-
- @retval EFI_SUCCESS The last data returned from the access matched
- the poll exit criteria.
-
- @retval EFI_INVALID_PARAMETER Width is invalid.
-
- @retval EFI_INVALID_PARAMETER Result is NULL.
-
- @retval EFI_TIMEOUT Delay expired before a match occurred.
-
- @retval EFI_OUT_OF_RESOURCES The request could not be completed due to a
- lack of resources.
-**/
-EFI_STATUS
-EFIAPI
-RootBridgeIoPollMem (
- IN EFI_PCI_ROOT_BRIDGE_IO_PROTOCOL *This,
- IN EFI_PCI_ROOT_BRIDGE_IO_PROTOCOL_WIDTH Width,
- IN UINT64 Address,
- IN UINT64 Mask,
- IN UINT64 Value,
- IN UINT64 Delay,
- OUT UINT64 *Result
- )
-{
- EFI_STATUS Status;
- UINT64 NumberOfTicks;
- UINT32 Remainder;
-
- if (Result == NULL) {
- return EFI_INVALID_PARAMETER;
- }
-
- if ((UINT32)Width > EfiPciWidthUint64) {
- return EFI_INVALID_PARAMETER;
- }
-
- //
- // No matter what, always do a single poll.
- //
- Status = This->Mem.Read (This, Width, Address, 1, Result);
- if (EFI_ERROR (Status)) {
- return Status;
- }
- if ((*Result & Mask) == Value) {
- return EFI_SUCCESS;
- }
-
- if (Delay == 0) {
- return EFI_SUCCESS;
-
- } else {
-
- //
- // Determine the proper # of metronome ticks to wait for polling the
- // location. The nuber of ticks is Roundup (Delay /
- // mMetronome->TickPeriod)+1
- // The "+1" to account for the possibility of the first tick being short
- // because we started in the middle of a tick.
- //
- // BugBug: overriding mMetronome->TickPeriod with UINT32 until Metronome
- // protocol definition is updated.
- //
- NumberOfTicks = DivU64x32Remainder (Delay, (UINT32) mMetronome->TickPeriod,
- &Remainder);
- if (Remainder != 0) {
- NumberOfTicks += 1;
- }
- NumberOfTicks += 1;
-
- while (NumberOfTicks != 0) {
-
- mMetronome->WaitForTick (mMetronome, 1);
-
- Status = This->Mem.Read (This, Width, Address, 1, Result);
- if (EFI_ERROR (Status)) {
- return Status;
- }
-
- if ((*Result & Mask) == Value) {
- return EFI_SUCCESS;
- }
-
- NumberOfTicks -= 1;
- }
- }
- return EFI_TIMEOUT;
-}
-
-/**
- Reads from the I/O space of a PCI Root Bridge. Returns when either the
- polling exit criteria is satisfied or after a defined duration.
-
- This function provides a standard way to poll a PCI I/O location. A PCI I/O
- read operation is performed at the PCI I/O address specified by Address for
- the width specified by Width.
- The result of this PCI I/O read operation is stored in Result. This PCI I/O
- read operation is repeated until either a timeout of Delay 100 ns units has
- expired, or (Result & Mask) is equal to Value.
-
- @param[in] This A pointer to the EFI_PCI_ROOT_BRIDGE_IO_PROTOCOL.
-
- @param[in] Width Signifies the width of the I/O operations.
-
- @param[in] Address The base address of the I/O operations. The caller is
- responsible for aligning Address if required.
-
- @param[in] Mask Mask used for the polling criteria. Bytes above Width in
- Mask are ignored. The bits in the bytes below Width
- which are zero in Mask are ignored when polling the I/O
- address.
-
- @param[in] Value The comparison value used for the polling exit criteria.
-
- @param[in] Delay The number of 100 ns units to poll. Note that timer
- available may be of poorer granularity.
-
- @param[out] Result Pointer to the last value read from the memory location.
-
- @retval EFI_SUCCESS The last data returned from the access matched
- the poll exit criteria.
-
- @retval EFI_INVALID_PARAMETER Width is invalid.
-
- @retval EFI_INVALID_PARAMETER Result is NULL.
-
- @retval EFI_TIMEOUT Delay expired before a match occurred.
-
- @retval EFI_OUT_OF_RESOURCES The request could not be completed due to a
- lack of resources.
-**/
-EFI_STATUS
-EFIAPI
-RootBridgeIoPollIo (
- IN EFI_PCI_ROOT_BRIDGE_IO_PROTOCOL *This,
- IN EFI_PCI_ROOT_BRIDGE_IO_PROTOCOL_WIDTH Width,
- IN UINT64 Address,
- IN UINT64 Mask,
- IN UINT64 Value,
- IN UINT64 Delay,
- OUT UINT64 *Result
- )
-{
- EFI_STATUS Status;
- UINT64 NumberOfTicks;
- UINT32 Remainder;
-
- //
- // No matter what, always do a single poll.
- //
-
- if (Result == NULL) {
- return EFI_INVALID_PARAMETER;
- }
-
- if ((UINT32)Width > EfiPciWidthUint64) {
- return EFI_INVALID_PARAMETER;
- }
-
- Status = This->Io.Read (This, Width, Address, 1, Result);
- if (EFI_ERROR (Status)) {
- return Status;
- }
- if ((*Result & Mask) == Value) {
- return EFI_SUCCESS;
- }
-
- if (Delay == 0) {
- return EFI_SUCCESS;
-
- } else {
-
- //
- // Determine the proper # of metronome ticks to wait for polling the
- // location. The number of ticks is Roundup (Delay /
- // mMetronome->TickPeriod)+1
- // The "+1" to account for the possibility of the first tick being short
- // because we started in the middle of a tick.
- //
- NumberOfTicks = DivU64x32Remainder (Delay, (UINT32)mMetronome->TickPeriod,
- &Remainder);
- if (Remainder != 0) {
- NumberOfTicks += 1;
- }
- NumberOfTicks += 1;
-
- while (NumberOfTicks != 0) {
-
- mMetronome->WaitForTick (mMetronome, 1);
-
- Status = This->Io.Read (This, Width, Address, 1, Result);
- if (EFI_ERROR (Status)) {
- return Status;
- }
-
- if ((*Result & Mask) == Value) {
- return EFI_SUCCESS;
- }
-
- NumberOfTicks -= 1;
- }
- }
- return EFI_TIMEOUT;
-}
-
-/**
- Enables a PCI driver to access PCI controller registers in the PCI root
- bridge memory space.
-
- The Mem.Read(), and Mem.Write() functions enable a driver to access PCI
- controller registers in the PCI root bridge memory space.
- The memory operations are carried out exactly as requested. The caller is
- responsible for satisfying any alignment and memory width restrictions that a
- PCI Root Bridge on a platform might require.
-
- @param[in] This A pointer to the EFI_PCI_ROOT_BRIDGE_IO_PROTOCOL.
-
- @param[in] Width Signifies the width of the memory operation.
-
- @param[in] Address The base address of the memory operation. The caller
- is responsible for aligning the Address if required.
-
- @param[in] Count The number of memory operations to perform. Bytes
- moved is Width size * Count, starting at Address.
-
- @param[out] Buffer For read operations, the destination buffer to store
- the results. For write operations, the source buffer
- to write data from.
-
- @retval EFI_SUCCESS The data was read from or written to the PCI
- root bridge.
-
- @retval EFI_INVALID_PARAMETER Width is invalid for this PCI root bridge.
-
- @retval EFI_INVALID_PARAMETER Buffer is NULL.
-
- @retval EFI_OUT_OF_RESOURCES The request could not be completed due to a
- lack of resources.
-**/
-EFI_STATUS
-EFIAPI
-RootBridgeIoMemRead (
- IN EFI_PCI_ROOT_BRIDGE_IO_PROTOCOL *This,
- IN EFI_PCI_ROOT_BRIDGE_IO_PROTOCOL_WIDTH Width,
- IN UINT64 Address,
- IN UINTN Count,
- OUT VOID *Buffer
- )
-{
- return RootBridgeIoMemRW (This, FALSE, Width, Address, Count, Buffer);
-}
-
-/**
- Enables a PCI driver to access PCI controller registers in the PCI root
- bridge memory space.
-
- The Mem.Read(), and Mem.Write() functions enable a driver to access PCI
- controller registers in the PCI root bridge memory space.
- The memory operations are carried out exactly as requested. The caller is
- responsible for satisfying any alignment and memory width restrictions that a
- PCI Root Bridge on a platform might require.
-
- @param[in] This A pointer to the EFI_PCI_ROOT_BRIDGE_IO_PROTOCOL.
-
- @param[in] Width Signifies the width of the memory operation.
-
- @param[in] Address The base address of the memory operation. The caller
- is responsible for aligning the Address if required.
-
- @param[in] Count The number of memory operations to perform. Bytes
- moved is Width size * Count, starting at Address.
-
- @param[in] Buffer For read operations, the destination buffer to store
- the results. For write operations, the source buffer
- to write data from.
-
- @retval EFI_SUCCESS The data was read from or written to the PCI
- root bridge.
-
- @retval EFI_INVALID_PARAMETER Width is invalid for this PCI root bridge.
-
- @retval EFI_INVALID_PARAMETER Buffer is NULL.
-
- @retval EFI_OUT_OF_RESOURCES The request could not be completed due to a
- lack of resources.
-**/
-EFI_STATUS
-EFIAPI
-RootBridgeIoMemWrite (
- IN EFI_PCI_ROOT_BRIDGE_IO_PROTOCOL *This,
- IN EFI_PCI_ROOT_BRIDGE_IO_PROTOCOL_WIDTH Width,
- IN UINT64 Address,
- IN UINTN Count,
- IN VOID *Buffer
- )
-{
- return RootBridgeIoMemRW (This, TRUE, Width, Address, Count, Buffer);
-}
-
-/**
- Enables a PCI driver to access PCI controller registers in the PCI root
- bridge I/O space.
-
- @param[in] This A pointer to the EFI_PCI_ROOT_BRIDGE_IO_PROTOCOL.
-
- @param[in] Width Signifies the width of the memory operations.
-
- @param[in] Address The base address of the I/O operation. The caller is
- responsible for aligning the Address if required.
-
- @param[in] Count The number of I/O operations to perform. Bytes moved
- is Width size * Count, starting at Address.
-
- @param[out] Buffer For read operations, the destination buffer to store
- the results. For write operations, the source buffer
- to write data from.
-
-
- @retval EFI_SUCCESS The data was read from or written to the PCI
- root bridge.
-
- @retval EFI_INVALID_PARAMETER Width is invalid for this PCI root bridge.
-
- @retval EFI_INVALID_PARAMETER Buffer is NULL.
-
- @retval EFI_OUT_OF_RESOURCES The request could not be completed due to a
- lack of resources.
-**/
-EFI_STATUS
-EFIAPI
-RootBridgeIoIoRead (
- IN EFI_PCI_ROOT_BRIDGE_IO_PROTOCOL *This,
- IN EFI_PCI_ROOT_BRIDGE_IO_PROTOCOL_WIDTH Width,
- IN UINT64 Address,
- IN UINTN Count,
- OUT VOID *Buffer
- )
-{
- return RootBridgeIoIoRW (This, FALSE, Width, Address, Count, Buffer);
-}
-
-/**
- Enables a PCI driver to access PCI controller registers in the PCI root
- bridge I/O space.
-
- @param[in] This A pointer to the EFI_PCI_ROOT_BRIDGE_IO_PROTOCOL.
-
- @param[in] Width Signifies the width of the memory operations.
-
- @param[in] Address The base address of the I/O operation. The caller is
- responsible for aligning the Address if required.
-
- @param[in] Count The number of I/O operations to perform. Bytes moved
- is Width size * Count, starting at Address.
-
- @param[in] Buffer For read operations, the destination buffer to store
- the results. For write operations, the source buffer
- to write data from.
-
- @retval EFI_SUCCESS The data was read from or written to the PCI
- root bridge.
-
- @retval EFI_INVALID_PARAMETER Width is invalid for this PCI root bridge.
-
- @retval EFI_INVALID_PARAMETER Buffer is NULL.
-
- @retval EFI_OUT_OF_RESOURCES The request could not be completed due to a
- lack of resources.
-**/
-EFI_STATUS
-EFIAPI
-RootBridgeIoIoWrite (
- IN EFI_PCI_ROOT_BRIDGE_IO_PROTOCOL *This,
- IN EFI_PCI_ROOT_BRIDGE_IO_PROTOCOL_WIDTH Width,
- IN UINT64 Address,
- IN UINTN Count,
- IN VOID *Buffer
- )
-{
- return RootBridgeIoIoRW (This, TRUE, Width, Address, Count, Buffer);
-}
-
-/**
- Enables a PCI driver to copy one region of PCI root bridge memory space to
- another region of PCI root bridge memory space.
-
- The CopyMem() function enables a PCI driver to copy one region of PCI root
- bridge memory space to another region of PCI root bridge memory space. This
- is especially useful for video scroll operation on a memory mapped video
- buffer.
- The memory operations are carried out exactly as requested. The caller is
- responsible for satisfying any alignment and memory width restrictions that a
- PCI root bridge on a platform might require.
-
- @param[in] This A pointer to the EFI_PCI_ROOT_BRIDGE_IO_PROTOCOL
- instance.
-
- @param[in] Width Signifies the width of the memory operations.
-
- @param[in] DestAddress The destination address of the memory operation. The
- caller is responsible for aligning the DestAddress if
- required.
-
- @param[in] SrcAddress The source address of the memory operation. The caller
- is responsible for aligning the SrcAddress if
- required.
-
- @param[in] Count The number of memory operations to perform. Bytes
- moved is Width size * Count, starting at DestAddress
- and SrcAddress.
-
- @retval EFI_SUCCESS The data was copied from one memory region
- to another memory region.
-
- @retval EFI_INVALID_PARAMETER Width is invalid for this PCI root bridge.
-
- @retval EFI_OUT_OF_RESOURCES The request could not be completed due to a
- lack of resources.
-**/
-EFI_STATUS
-EFIAPI
-RootBridgeIoCopyMem (
- IN EFI_PCI_ROOT_BRIDGE_IO_PROTOCOL *This,
- IN EFI_PCI_ROOT_BRIDGE_IO_PROTOCOL_WIDTH Width,
- IN UINT64 DestAddress,
- IN UINT64 SrcAddress,
- IN UINTN Count
- )
-{
- EFI_STATUS Status;
- BOOLEAN Direction;
- UINTN Stride;
- UINTN Index;
- UINT64 Result;
-
- if ((UINT32)Width > EfiPciWidthUint64) {
- return EFI_INVALID_PARAMETER;
- }
-
- if (DestAddress == SrcAddress) {
- return EFI_SUCCESS;
- }
-
- Stride = (UINTN)(1 << Width);
-
- Direction = TRUE;
- if ((DestAddress > SrcAddress) &&
- (DestAddress < (SrcAddress + Count * Stride))) {
- Direction = FALSE;
- SrcAddress = SrcAddress + (Count-1) * Stride;
- DestAddress = DestAddress + (Count-1) * Stride;
- }
-
- for (Index = 0;Index < Count;Index++) {
- Status = RootBridgeIoMemRead (
- This,
- Width,
- SrcAddress,
- 1,
- &Result
- );
- if (EFI_ERROR (Status)) {
- return Status;
- }
- Status = RootBridgeIoMemWrite (
- This,
- Width,
- DestAddress,
- 1,
- &Result
- );
- if (EFI_ERROR (Status)) {
- return Status;
- }
- if (Direction) {
- SrcAddress += Stride;
- DestAddress += Stride;
- } else {
- SrcAddress -= Stride;
- DestAddress -= Stride;
- }
- }
- return EFI_SUCCESS;
-}
-
-/**
- Enables a PCI driver to access PCI controller registers in a PCI root
- bridge's configuration space.
-
- The Pci.Read() and Pci.Write() functions enable a driver to access PCI
- configuration registers for a PCI controller.
- The PCI Configuration operations are carried out exactly as requested. The
- caller is responsible for any alignment and PCI configuration width issues
- that a PCI Root Bridge on a platform might require.
-
- @param[in] This A pointer to the EFI_PCI_ROOT_BRIDGE_IO_PROTOCOL.
-
- @param[in] Width Signifies the width of the memory operations.
-
- @param[in] Address The address within the PCI configuration space for the
- PCI controller.
-
- @param[in] Count The number of PCI configuration operations to perform.
- Bytes moved is Width size * Count, starting at
- Address.
-
- @param[out] Buffer For read operations, the destination buffer to store
- the results. For write operations, the source buffer
- to write data from.
-
- @retval EFI_SUCCESS The data was read from or written to the PCI
- root bridge.
-
- @retval EFI_INVALID_PARAMETER Width is invalid for this PCI root bridge.
-
- @retval EFI_INVALID_PARAMETER Buffer is NULL.
-
- @retval EFI_OUT_OF_RESOURCES The request could not be completed due to a
- lack of resources.
-**/
-EFI_STATUS
-EFIAPI
-RootBridgeIoPciRead (
- IN EFI_PCI_ROOT_BRIDGE_IO_PROTOCOL *This,
- IN EFI_PCI_ROOT_BRIDGE_IO_PROTOCOL_WIDTH Width,
- IN UINT64 Address,
- IN UINTN Count,
- OUT VOID *Buffer
- )
-{
- return RootBridgeIoPciRW (This, FALSE, Width, Address, Count, Buffer);
-}
-
-/**
- Enables a PCI driver to access PCI controller registers in a PCI root
- bridge's configuration space.
-
- The Pci.Read() and Pci.Write() functions enable a driver to access PCI
- configuration registers for a PCI controller.
- The PCI Configuration operations are carried out exactly as requested. The
- caller is responsible for any alignment and PCI configuration width issues
- that a PCI Root Bridge on a platform might require.
-
- @param[in] This A pointer to the EFI_PCI_ROOT_BRIDGE_IO_PROTOCOL.
-
- @param[in] Width Signifies the width of the memory operations.
-
- @param[in] Address The address within the PCI configuration space for the
- PCI controller.
-
- @param[in] Count The number of PCI configuration operations to perform.
- Bytes moved is Width size * Count, starting at
- Address.
-
- @param[in] Buffer For read operations, the destination buffer to store
- the results. For write operations, the source buffer
- to write data from.
-
- @retval EFI_SUCCESS The data was read from or written to the PCI
- root bridge.
-
- @retval EFI_INVALID_PARAMETER Width is invalid for this PCI root bridge.
-
- @retval EFI_INVALID_PARAMETER Buffer is NULL.
-
- @retval EFI_OUT_OF_RESOURCES The request could not be completed due to a
- lack of resources.
-**/
-EFI_STATUS
-EFIAPI
-RootBridgeIoPciWrite (
- IN EFI_PCI_ROOT_BRIDGE_IO_PROTOCOL *This,
- IN EFI_PCI_ROOT_BRIDGE_IO_PROTOCOL_WIDTH Width,
- IN UINT64 Address,
- IN UINTN Count,
- IN VOID *Buffer
- )
-{
- return RootBridgeIoPciRW (This, TRUE, Width, Address, Count, Buffer);
-}
-
-/**
- Provides the PCI controller-specific addresses required to access system
- memory from a DMA bus master.
-
- The Map() function provides the PCI controller specific addresses needed to
- access system memory. This function is used to map system memory for PCI bus
- master DMA accesses.
-
- @param[in] This A pointer to the
- EFI_PCI_ROOT_BRIDGE_IO_PROTOCOL.
-
- @param[in] Operation Indicates if the bus master is going to read
- or write to system memory.
-
- @param[in] HostAddress The system memory address to map to the PCI
- controller.
-
- @param[in, out] NumberOfBytes On input the number of bytes to map. On
- output the number of bytes that were mapped.
-
- @param[out] DeviceAddress The resulting map address for the bus master
- PCI controller to use to access the system
- memory's HostAddress.
-
- @param[out] Mapping The value to pass to Unmap() when the bus
- master DMA operation is complete.
-
- @retval EFI_SUCCESS The range was mapped for the returned
- NumberOfBytes.
-
- @retval EFI_INVALID_PARAMETER Operation is invalid.
-
- @retval EFI_INVALID_PARAMETER HostAddress is NULL.
-
- @retval EFI_INVALID_PARAMETER NumberOfBytes is NULL.
-
- @retval EFI_INVALID_PARAMETER DeviceAddress is NULL.
-
- @retval EFI_INVALID_PARAMETER Mapping is NULL.
-
- @retval EFI_UNSUPPORTED The HostAddress cannot be mapped as a common
- buffer.
-
- @retval EFI_DEVICE_ERROR The system hardware could not map the
- requested address.
-
- @retval EFI_OUT_OF_RESOURCES The request could not be completed due to a
- lack of resources.
-**/
-EFI_STATUS
-EFIAPI
-RootBridgeIoMap (
- IN EFI_PCI_ROOT_BRIDGE_IO_PROTOCOL *This,
- IN EFI_PCI_ROOT_BRIDGE_IO_PROTOCOL_OPERATION Operation,
- IN VOID *HostAddress,
- IN OUT UINTN *NumberOfBytes,
- OUT EFI_PHYSICAL_ADDRESS *DeviceAddress,
- OUT VOID **Mapping
- )
-{
- EFI_STATUS Status;
- EFI_PHYSICAL_ADDRESS PhysicalAddress;
- MAP_INFO *MapInfo;
-
- if (HostAddress == NULL || NumberOfBytes == NULL || DeviceAddress == NULL ||
- Mapping == NULL) {
- return EFI_INVALID_PARAMETER;
- }
-
- //
- // Initialize the return values to their defaults
- //
- *Mapping = NULL;
-
- //
- // Make sure that Operation is valid
- //
- if ((UINT32)Operation >= EfiPciOperationMaximum) {
- return EFI_INVALID_PARAMETER;
- }
-
- //
- // Most PCAT like chipsets can not handle performing DMA above 4GB.
- // If any part of the DMA transfer being mapped is above 4GB, then
- // map the DMA transfer to a buffer below 4GB.
- //
- PhysicalAddress = (EFI_PHYSICAL_ADDRESS) (UINTN) HostAddress;
- if ((PhysicalAddress + *NumberOfBytes) > 0x100000000ULL) {
-
- //
- // Common Buffer operations can not be remapped. If the common buffer
- // if above 4GB, then it is not possible to generate a mapping, so return
- // an error.
- //
- if (Operation == EfiPciOperationBusMasterCommonBuffer ||
- Operation == EfiPciOperationBusMasterCommonBuffer64) {
- return EFI_UNSUPPORTED;
- }
-
- //
- // Allocate a MAP_INFO structure to remember the mapping when Unmap() is
- // called later.
- //
- Status = gBS->AllocatePool (
- EfiBootServicesData,
- sizeof(MAP_INFO),
- (VOID **)&MapInfo
- );
- if (EFI_ERROR (Status)) {
- *NumberOfBytes = 0;
- return Status;
- }
-
- //
- // Return a pointer to the MAP_INFO structure in Mapping
- //
- *Mapping = MapInfo;
-
- //
- // Initialize the MAP_INFO structure
- //
- MapInfo->Operation = Operation;
- MapInfo->NumberOfBytes = *NumberOfBytes;
- MapInfo->NumberOfPages = EFI_SIZE_TO_PAGES(*NumberOfBytes);
- MapInfo->HostAddress = PhysicalAddress;
- MapInfo->MappedHostAddress = 0x00000000ffffffff;
-
- //
- // Allocate a buffer below 4GB to map the transfer to.
- //
- Status = gBS->AllocatePages (
- AllocateMaxAddress,
- EfiBootServicesData,
- MapInfo->NumberOfPages,
- &MapInfo->MappedHostAddress
- );
- if (EFI_ERROR (Status)) {
- gBS->FreePool (MapInfo);
- *NumberOfBytes = 0;
- return Status;
- }
-
- //
- // If this is a read operation from the Bus Master's point of view,
- // then copy the contents of the real buffer into the mapped buffer
- // so the Bus Master can read the contents of the real buffer.
- //
- if (Operation == EfiPciOperationBusMasterRead ||
- Operation == EfiPciOperationBusMasterRead64) {
- CopyMem (
- (VOID *)(UINTN)MapInfo->MappedHostAddress,
- (VOID *)(UINTN)MapInfo->HostAddress,
- MapInfo->NumberOfBytes
- );
- }
-
- //
- // The DeviceAddress is the address of the maped buffer below 4GB
- //
- *DeviceAddress = MapInfo->MappedHostAddress;
- } else {
- //
- // The transfer is below 4GB, so the DeviceAddress is simply the
- // HostAddress
- //
- *DeviceAddress = PhysicalAddress;
- }
-
- return EFI_SUCCESS;
-}
-
-/**
- Completes the Map() operation and releases any corresponding resources.
-
- The Unmap() function completes the Map() operation and releases any
- corresponding resources.
- If the operation was an EfiPciOperationBusMasterWrite or
- EfiPciOperationBusMasterWrite64, the data is committed to the target system
- memory.
- Any resources used for the mapping are freed.
-
- @param[in] This A pointer to the EFI_PCI_ROOT_BRIDGE_IO_PROTOCOL.
-
- @param[in] Mapping The mapping value returned from Map().
-
- @retval EFI_SUCCESS The range was unmapped.
-
- @retval EFI_INVALID_PARAMETER Mapping is not a value that was returned by
- Map().
-
- @retval EFI_DEVICE_ERROR The data was not committed to the target
- system memory.
-**/
-EFI_STATUS
-EFIAPI
-RootBridgeIoUnmap (
- IN EFI_PCI_ROOT_BRIDGE_IO_PROTOCOL *This,
- IN VOID *Mapping
- )
-{
- MAP_INFO *MapInfo;
-
- //
- // See if the Map() operation associated with this Unmap() required a mapping
- // buffer. If a mapping buffer was not required, then this function simply
- // returns EFI_SUCCESS.
- //
- if (Mapping != NULL) {
- //
- // Get the MAP_INFO structure from Mapping
- //
- MapInfo = (MAP_INFO *)Mapping;
-
- //
- // If this is a write operation from the Bus Master's point of view,
- // then copy the contents of the mapped buffer into the real buffer
- // so the processor can read the contents of the real buffer.
- //
- if (MapInfo->Operation == EfiPciOperationBusMasterWrite ||
- MapInfo->Operation == EfiPciOperationBusMasterWrite64) {
- CopyMem (
- (VOID *)(UINTN)MapInfo->HostAddress,
- (VOID *)(UINTN)MapInfo->MappedHostAddress,
- MapInfo->NumberOfBytes
- );
- }
-
- //
- // Free the mapped buffer and the MAP_INFO structure.
- //
- gBS->FreePages (MapInfo->MappedHostAddress, MapInfo->NumberOfPages);
- gBS->FreePool (Mapping);
- }
- return EFI_SUCCESS;
-}
-
-/**
- Allocates pages that are suitable for an EfiPciOperationBusMasterCommonBuffer
- or EfiPciOperationBusMasterCommonBuffer64 mapping.
-
- @param This A pointer to the EFI_PCI_ROOT_BRIDGE_IO_PROTOCOL.
-
- @param Type This parameter is not used and must be ignored.
-
- @param MemoryType The type of memory to allocate, EfiBootServicesData or
- EfiRuntimeServicesData.
-
- @param Pages The number of pages to allocate.
-
- @param HostAddress A pointer to store the base system memory address of the
- allocated range.
-
- @param Attributes The requested bit mask of attributes for the allocated
- range. Only the attributes
- EFI_PCI_ATTRIBUTE_MEMORY_WRITE_COMBINE,
- EFI_PCI_ATTRIBUTE_MEMORY_CACHED, and
- EFI_PCI_ATTRIBUTE_DUAL_ADDRESS_CYCLE may be used with this
- function.
-
- @retval EFI_SUCCESS The requested memory pages were allocated.
-
- @retval EFI_INVALID_PARAMETER MemoryType is invalid.
-
- @retval EFI_INVALID_PARAMETER HostAddress is NULL.
-
- @retval EFI_UNSUPPORTED Attributes is unsupported. The only legal
- attribute bits are MEMORY_WRITE_COMBINE,
- MEMORY_CACHED, and DUAL_ADDRESS_CYCLE.
-
- @retval EFI_OUT_OF_RESOURCES The memory pages could not be allocated.
-**/
-EFI_STATUS
-EFIAPI
-RootBridgeIoAllocateBuffer (
- IN EFI_PCI_ROOT_BRIDGE_IO_PROTOCOL *This,
- IN EFI_ALLOCATE_TYPE Type,
- IN EFI_MEMORY_TYPE MemoryType,
- IN UINTN Pages,
- OUT VOID **HostAddress,
- IN UINT64 Attributes
- )
-{
- EFI_STATUS Status;
- EFI_PHYSICAL_ADDRESS PhysicalAddress;
-
- //
- // Validate Attributes
- //
- if ((Attributes & EFI_PCI_ATTRIBUTE_INVALID_FOR_ALLOCATE_BUFFER) != 0) {
- return EFI_UNSUPPORTED;
- }
-
- //
- // Check for invalid inputs
- //
- if (HostAddress == NULL) {
- return EFI_INVALID_PARAMETER;
- }
-
- //
- // The only valid memory types are EfiBootServicesData and
- // EfiRuntimeServicesData
- //
- if (MemoryType != EfiBootServicesData &&
- MemoryType != EfiRuntimeServicesData) {
- return EFI_INVALID_PARAMETER;
- }
-
- //
- // Limit allocations to memory below 4GB
- //
- PhysicalAddress = (EFI_PHYSICAL_ADDRESS)(0xffffffff);
-
- Status = gBS->AllocatePages (AllocateMaxAddress, MemoryType, Pages,
- &PhysicalAddress);
- if (EFI_ERROR (Status)) {
- return Status;
- }
-
- *HostAddress = (VOID *)(UINTN)PhysicalAddress;
-
- return EFI_SUCCESS;
-}
-
-/**
- Frees memory that was allocated with AllocateBuffer().
-
- The FreeBuffer() function frees memory that was allocated with
- AllocateBuffer().
-
- @param This A pointer to the EFI_PCI_ROOT_BRIDGE_IO_PROTOCOL.
-
- @param Pages The number of pages to free.
-
- @param HostAddress The base system memory address of the allocated range.
-
- @retval EFI_SUCCESS The requested memory pages were freed.
-
- @retval EFI_INVALID_PARAMETER The memory range specified by HostAddress and
- Pages was not allocated with AllocateBuffer().
-**/
-EFI_STATUS
-EFIAPI
-RootBridgeIoFreeBuffer (
- IN EFI_PCI_ROOT_BRIDGE_IO_PROTOCOL *This,
- IN UINTN Pages,
- OUT VOID *HostAddress
- )
-{
- return gBS->FreePages ((EFI_PHYSICAL_ADDRESS) (UINTN) HostAddress, Pages);
-}
-
-/**
- Flushes all PCI posted write transactions from a PCI host bridge to system
- memory.
-
- The Flush() function flushes any PCI posted write transactions from a PCI
- host bridge to system memory. Posted write transactions are generated by PCI
- bus masters when they perform write transactions to target addresses in
- system memory.
- This function does not flush posted write transactions from any PCI bridges.
- A PCI controller specific action must be taken to guarantee that the posted
- write transactions have been flushed from the PCI controller and from all the
- PCI bridges into the PCI host bridge. This is typically done with a PCI read
- transaction from the PCI controller prior to calling Flush().
-
- @param This A pointer to the EFI_PCI_ROOT_BRIDGE_IO_PROTOCOL.
-
- @retval EFI_SUCCESS The PCI posted write transactions were flushed
- from the PCI host bridge to system memory.
-
- @retval EFI_DEVICE_ERROR The PCI posted write transactions were not flushed
- from the PCI host bridge due to a hardware error.
-**/
-EFI_STATUS
-EFIAPI
-RootBridgeIoFlush (
- IN EFI_PCI_ROOT_BRIDGE_IO_PROTOCOL *This
- )
-{
- //
- // not supported yet
- //
- return EFI_SUCCESS;
-}
-
-/**
- Gets the attributes that a PCI root bridge supports setting with
- SetAttributes(), and the attributes that a PCI root bridge is currently
- using.
-
- The GetAttributes() function returns the mask of attributes that this PCI
- root bridge supports and the mask of attributes that the PCI root bridge is
- currently using.
-
- @param This A pointer to the EFI_PCI_ROOT_BRIDGE_IO_PROTOCOL.
-
- @param Supported A pointer to the mask of attributes that this PCI root
- bridge supports setting with SetAttributes().
-
- @param Attributes A pointer to the mask of attributes that this PCI root
- bridge is currently using.
-
- @retval EFI_SUCCESS If Supports is not NULL, then the attributes
- that the PCI root bridge supports is returned
- in Supports. If Attributes is not NULL, then
- the attributes that the PCI root bridge is
- currently using is returned in Attributes.
-
- @retval EFI_INVALID_PARAMETER Both Supports and Attributes are NULL.
-**/
-EFI_STATUS
-EFIAPI
-RootBridgeIoGetAttributes (
- IN EFI_PCI_ROOT_BRIDGE_IO_PROTOCOL *This,
- OUT UINT64 *Supported,
- OUT UINT64 *Attributes
- )
-{
- PCI_ROOT_BRIDGE_INSTANCE *PrivateData;
-
- PrivateData = DRIVER_INSTANCE_FROM_PCI_ROOT_BRIDGE_IO_THIS(This);
-
- if (Attributes == NULL && Supported == NULL) {
- return EFI_INVALID_PARAMETER;
- }
-
- //
- // Set the return value for Supported and Attributes
- //
- if (Supported != NULL) {
- *Supported = PrivateData->Supports;
- }
-
- if (Attributes != NULL) {
- *Attributes = PrivateData->Attributes;
- }
-
- return EFI_SUCCESS;
-}
-
-/**
- Sets attributes for a resource range on a PCI root bridge.
-
- The SetAttributes() function sets the attributes specified in Attributes for
- the PCI root bridge on the resource range specified by ResourceBase and
- ResourceLength. Since the granularity of setting these attributes may vary
- from resource type to resource type, and from platform to platform, the
- actual resource range and the one passed in by the caller may differ. As a
- result, this function may set the attributes specified by Attributes on a
- larger resource range than the caller requested. The actual range is returned
- in ResourceBase and ResourceLength. The caller is responsible for verifying
- that the actual range for which the attributes were set is acceptable.
-
- @param[in] This A pointer to the
- EFI_PCI_ROOT_BRIDGE_IO_PROTOCOL.
-
- @param[in] Attributes The mask of attributes to set. If the
- attribute bit MEMORY_WRITE_COMBINE,
- MEMORY_CACHED, or MEMORY_DISABLE is set,
- then the resource range is specified by
- ResourceBase and ResourceLength. If
- MEMORY_WRITE_COMBINE, MEMORY_CACHED, and
- MEMORY_DISABLE are not set, then
- ResourceBase and ResourceLength are ignored,
- and may be NULL.
-
- @param[in, out] ResourceBase A pointer to the base address of the
- resource range to be modified by the
- attributes specified by Attributes.
-
- @param[in, out] ResourceLength A pointer to the length of the resource
- range to be modified by the attributes
- specified by Attributes.
-
- @retval EFI_SUCCESS The current configuration of this PCI root bridge
- was returned in Resources.
-
- @retval EFI_UNSUPPORTED The current configuration of this PCI root bridge
- could not be retrieved.
-
- @retval EFI_INVALID_PARAMETER Invalid pointer of
- EFI_PCI_ROOT_BRIDGE_IO_PROTOCOL
-**/
-EFI_STATUS
-EFIAPI
-RootBridgeIoSetAttributes (
- IN EFI_PCI_ROOT_BRIDGE_IO_PROTOCOL *This,
- IN UINT64 Attributes,
- IN OUT UINT64 *ResourceBase,
- IN OUT UINT64 *ResourceLength
- )
-{
- PCI_ROOT_BRIDGE_INSTANCE *PrivateData;
-
- PrivateData = DRIVER_INSTANCE_FROM_PCI_ROOT_BRIDGE_IO_THIS(This);
-
- if (Attributes != 0) {
- if ((Attributes & (~(PrivateData->Supports))) != 0) {
- return EFI_UNSUPPORTED;
- }
- }
-
- //
- // This is a generic driver for a PC-AT class system. It does not have any
- // chipset specific knowlegde, so none of the attributes can be set or
- // cleared. Any attempt to set attribute that are already set will succeed,
- // and any attempt to set an attribute that is not supported will fail.
- //
- if (Attributes & (~PrivateData->Attributes)) {
- return EFI_UNSUPPORTED;
- }
-
- return EFI_SUCCESS;
-}
-
-/**
- Retrieves the current resource settings of this PCI root bridge in the form
- of a set of ACPI 2.0 resource descriptors.
-
- There are only two resource descriptor types from the ACPI Specification that
- may be used to describe the current resources allocated to a PCI root bridge.
- These are the QWORD Address Space Descriptor (ACPI 2.0 Section 6.4.3.5.1),
- and the End Tag (ACPI 2.0 Section 6.4.2.8). 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.
-
- @param[in] This A pointer to the EFI_PCI_ROOT_BRIDGE_IO_PROTOCOL.
-
- @param[out] Resources A pointer to the ACPI 2.0 resource descriptors that
- describe the current configuration of this PCI root
- bridge. The storage for the ACPI 2.0 resource
- descriptors is allocated by this function. The
- caller must treat the return buffer as read-only
- data, and the buffer must not be freed by the
- caller.
-
- @retval EFI_SUCCESS The current configuration of this PCI root bridge
- was returned in Resources.
-
- @retval EFI_UNSUPPORTED The current configuration of this PCI root bridge
- could not be retrieved.
-
- @retval EFI_INVALID_PARAMETER Invalid pointer of
- EFI_PCI_ROOT_BRIDGE_IO_PROTOCOL
-**/
-EFI_STATUS
-EFIAPI
-RootBridgeIoConfiguration (
- IN EFI_PCI_ROOT_BRIDGE_IO_PROTOCOL *This,
- OUT VOID **Resources
- )
-{
- PCI_ROOT_BRIDGE_INSTANCE *PrivateData;
- UINTN Index;
-
- PrivateData = DRIVER_INSTANCE_FROM_PCI_ROOT_BRIDGE_IO_THIS (This);
- CopyMem (&PrivateData->ConfigBuffer, &mConfigurationTemplate,
- sizeof mConfigurationTemplate);
-
- for (Index = 0; Index < TypeMax; Index++) {
- if (PrivateData->ResAllocNode[Index].Status == ResAllocated) {
- EFI_ACPI_ADDRESS_SPACE_DESCRIPTOR *Desc;
-
- Desc = &PrivateData->ConfigBuffer.SpaceDesc[Index];
- Desc->AddrRangeMin = PrivateData->ResAllocNode[Index].Base;
- Desc->AddrRangeMax = PrivateData->ResAllocNode[Index].Base +
- PrivateData->ResAllocNode[Index].Length - 1;
- Desc->AddrLen = PrivateData->ResAllocNode[Index].Length;
- }
- }
-
- *Resources = &PrivateData->ConfigBuffer;
- return EFI_SUCCESS;
-}
-
diff --git a/OvmfPkg/PciHostBridgeDxe/X64/IoFifo.S b/OvmfPkg/PciHostBridgeDxe/X64/IoFifo.S
deleted file mode 100644
index decb382028..0000000000
--- a/OvmfPkg/PciHostBridgeDxe/X64/IoFifo.S
+++ /dev/null
@@ -1,122 +0,0 @@
-#------------------------------------------------------------------------------
-#
-# Copyright (c) 2006 - 2012, Intel Corporation. All rights reserved.<BR>
-#
-# This program and the accompanying materials are licensed and made available
-# under the terms and conditions of the BSD License which accompanies this
-# distribution. The full text of the license may be found at
-# http://opensource.org/licenses/bsd-license.php.
-#
-# THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
-# WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
-#
-#------------------------------------------------------------------------------
-
-#------------------------------------------------------------------------------
-# VOID
-# EFIAPI
-# IoReadFifo8 (
-# IN UINTN Port, // rcx
-# IN UINTN Count, // rdx
-# IN VOID *Buffer // r8
-# );
-#------------------------------------------------------------------------------
-ASM_GLOBAL ASM_PFX(IoReadFifo8)
-ASM_PFX(IoReadFifo8):
- cld
- xchg %rcx, %rdx
- xchg %r8, %rdi # rdi: buffer address; r8: save register
-rep insb
- mov %r8, %rdi # restore rdi
- ret
-
-#------------------------------------------------------------------------------
-# VOID
-# EFIAPI
-# IoReadFifo16 (
-# IN UINTN Port, // rcx
-# IN UINTN Count, // rdx
-# IN VOID *Buffer // r8
-# );
-#------------------------------------------------------------------------------
-ASM_GLOBAL ASM_PFX(IoReadFifo16)
-ASM_PFX(IoReadFifo16):
- cld
- xchg %rcx, %rdx
- xchg %r8, %rdi # rdi: buffer address; r8: save register
-rep insw
- mov %r8, %rdi # restore rdi
- ret
-
-#------------------------------------------------------------------------------
-# VOID
-# EFIAPI
-# IoReadFifo32 (
-# IN UINTN Port, // rcx
-# IN UINTN Count, // rdx
-# IN VOID *Buffer // r8
-# );
-#------------------------------------------------------------------------------
-ASM_GLOBAL ASM_PFX(IoReadFifo32)
-ASM_PFX(IoReadFifo32):
- cld
- xchg %rcx, %rdx
- xchg %r8, %rdi # rdi: buffer address; r8: save register
-rep insl
- mov %r8, %rdi # restore rdi
- ret
-
-#------------------------------------------------------------------------------
-# VOID
-# EFIAPI
-# IoWriteFifo8 (
-# IN UINTN Port, // rcx
-# IN UINTN Count, // rdx
-# IN VOID *Buffer // r8
-# );
-#------------------------------------------------------------------------------
-ASM_GLOBAL ASM_PFX(IoWriteFifo8)
-ASM_PFX(IoWriteFifo8):
- cld
- xchg %rcx, %rdx
- xchg %r8, %rsi # rsi: buffer address; r8: save register
-rep outsb
- mov %r8, %rsi # restore rsi
- ret
-
-#------------------------------------------------------------------------------
-# VOID
-# EFIAPI
-# IoWriteFifo16 (
-# IN UINTN Port, // rcx
-# IN UINTN Count, // rdx
-# IN VOID *Buffer // r8
-# );
-#------------------------------------------------------------------------------
-ASM_GLOBAL ASM_PFX(IoWriteFifo16)
-ASM_PFX(IoWriteFifo16):
- cld
- xchg %rcx, %rdx
- xchg %r8, %rsi # rsi: buffer address; r8: save register
-rep outsw
- mov %r8, %rsi # restore rsi
- ret
-
-#------------------------------------------------------------------------------
-# VOID
-# EFIAPI
-# IoWriteFifo32 (
-# IN UINTN Port, // rcx
-# IN UINTN Count, // rdx
-# IN VOID *Buffer // r8
-# );
-#------------------------------------------------------------------------------
-ASM_GLOBAL ASM_PFX(IoWriteFifo32)
-ASM_PFX(IoWriteFifo32):
- cld
- xchg %rcx, %rdx
- xchg %r8, %rsi # rsi: buffer address; r8: save register
-rep outsl
- mov %r8, %rsi # restore rsi
- ret
-
diff --git a/OvmfPkg/PciHostBridgeDxe/X64/IoFifo.asm b/OvmfPkg/PciHostBridgeDxe/X64/IoFifo.asm
deleted file mode 100644
index 1a3f0ef2ca..0000000000
--- a/OvmfPkg/PciHostBridgeDxe/X64/IoFifo.asm
+++ /dev/null
@@ -1,126 +0,0 @@
-;------------------------------------------------------------------------------
-;
-; Copyright (c) 2006 - 2012, Intel Corporation. All rights reserved.<BR>
-;
-; This program and the accompanying materials are licensed and made available
-; under the terms and conditions of the BSD License which accompanies this
-; distribution. The full text of the license may be found at
-; http://opensource.org/licenses/bsd-license.php.
-;
-; THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
-; WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
-;
-;------------------------------------------------------------------------------
-
- .code
-
-;------------------------------------------------------------------------------
-; VOID
-; EFIAPI
-; IoReadFifo8 (
-; IN UINTN Port, // rcx
-; IN UINTN Size, // rdx
-; IN VOID *Buffer // r8
-; );
-;------------------------------------------------------------------------------
-IoReadFifo8 PROC
- cld
- xchg rcx, rdx
- xchg rdi, r8 ; rdi: buffer address; r8: save rdi
-rep insb
- mov rdi, r8 ; restore rdi
- ret
-IoReadFifo8 ENDP
-
-;------------------------------------------------------------------------------
-; VOID
-; EFIAPI
-; IoReadFifo16 (
-; IN UINTN Port, // rcx
-; IN UINTN Size, // rdx
-; IN VOID *Buffer // r8
-; );
-;------------------------------------------------------------------------------
-IoReadFifo16 PROC
- cld
- xchg rcx, rdx
- xchg rdi, r8 ; rdi: buffer address; r8: save rdi
-rep insw
- mov rdi, r8 ; restore rdi
- ret
-IoReadFifo16 ENDP
-
-;------------------------------------------------------------------------------
-; VOID
-; EFIAPI
-; IoReadFifo32 (
-; IN UINTN Port, // rcx
-; IN UINTN Size, // rdx
-; IN VOID *Buffer // r8
-; );
-;------------------------------------------------------------------------------
-IoReadFifo32 PROC
- cld
- xchg rcx, rdx
- xchg rdi, r8 ; rdi: buffer address; r8: save rdi
-rep insd
- mov rdi, r8 ; restore rdi
- ret
-IoReadFifo32 ENDP
-
-;------------------------------------------------------------------------------
-; VOID
-; EFIAPI
-; IoWriteFifo8 (
-; IN UINTN Port, // rcx
-; IN UINTN Size, // rdx
-; IN VOID *Buffer // r8
-; );
-;------------------------------------------------------------------------------
-IoWriteFifo8 PROC
- cld
- xchg rcx, rdx
- xchg rsi, r8 ; rsi: buffer address; r8: save rsi
-rep outsb
- mov rsi, r8 ; restore rsi
- ret
-IoWriteFifo8 ENDP
-
-;------------------------------------------------------------------------------
-; VOID
-; EFIAPI
-; IoWriteFifo16 (
-; IN UINTN Port, // rcx
-; IN UINTN Size, // rdx
-; IN VOID *Buffer // r8
-; );
-;------------------------------------------------------------------------------
-IoWriteFifo16 PROC
- cld
- xchg rcx, rdx
- xchg rsi, r8 ; rsi: buffer address; r8: save rsi
-rep outsw
- mov rsi, r8 ; restore rsi
- ret
-IoWriteFifo16 ENDP
-
-;------------------------------------------------------------------------------
-; VOID
-; EFIAPI
-; IoWriteFifo32 (
-; IN UINTN Port, // rcx
-; IN UINTN Size, // rdx
-; IN VOID *Buffer // r8
-; );
-;------------------------------------------------------------------------------
-IoWriteFifo32 PROC
- cld
- xchg rcx, rdx
- xchg rsi, r8 ; rsi: buffer address; r8: save rsi
-rep outsd
- mov rsi, r8 ; restore rsi
- ret
-IoWriteFifo32 ENDP
-
- END
-
diff --git a/OvmfPkg/PlatformDxe/Platform.c b/OvmfPkg/PlatformDxe/Platform.c
deleted file mode 100644
index 4ec327e763..0000000000
--- a/OvmfPkg/PlatformDxe/Platform.c
+++ /dev/null
@@ -1,871 +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.<BR>
-
- This program and the accompanying materials are licensed and made available
- under the terms and conditions of the BSD License which accompanies this
- distribution. The full text of the license may be found at
- http://opensource.org/licenses/bsd-license.php
-
- THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, WITHOUT
- WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
-**/
-
-#include <Library/BaseLib.h>
-#include <Library/BaseMemoryLib.h>
-#include <Library/DebugLib.h>
-#include <Library/DevicePathLib.h>
-#include <Library/HiiLib.h>
-#include <Library/MemoryAllocationLib.h>
-#include <Library/PrintLib.h>
-#include <Library/UefiBootServicesTableLib.h>
-#include <Library/UefiHiiServicesLib.h>
-#include <Protocol/DevicePath.h>
-#include <Protocol/GraphicsOutput.h>
-#include <Protocol/HiiConfigAccess.h>
-#include <Guid/MdeModuleHii.h>
-#include <Guid/OvmfPlatformConfig.h>
-
-#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 <ConfigRequest> 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 <MultiConfigAltResp> 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 <MultiConfigAltResp>
- 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 <ConfigResp> 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;
-
- 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.
- //
- PcdSet32 (PcdVideoHorizontalResolution,
- PlatformConfig.HorizontalResolution);
- PcdSet32 (PcdVideoVerticalResolution,
- PlatformConfig.VerticalResolution);
- }
-
- 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.<BR>
-#
-# This program and the accompanying materials are licensed and made available
-# under the terms and conditions of the BSD License which accompanies this
-# distribution. The full text of the license may be found at
-# http://opensource.org/licenses/bsd-license.php
-#
-# 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.<BR>
-//
-// This program and the accompanying materials are licensed and made available
-// under the terms and conditions of the BSD License which accompanies this
-// distribution. The full text of the license may be found at
-// http://opensource.org/licenses/bsd-license.php
-//
-// 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 <Library/BaseMemoryLib.h>
-#include <Library/DebugLib.h>
-#include <Library/MemoryAllocationLib.h>
-#include <Library/UefiLib.h>
-#include <Library/UefiRuntimeServicesTableLib.h>
-#include <Guid/OvmfPlatformConfig.h>
-
-#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 <Base.h>
-
-//
-// 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.<BR>
-//
-// This program and the accompanying materials are licensed and made available
-// under the terms and conditions of the BSD License which accompanies this
-// distribution. The full text of the license may be found at
-// http://opensource.org/licenses/bsd-license.php
-//
-// 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 <Guid/OvmfPlatformConfig.h>
-#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.<BR>
- This program and the accompanying materials
- are licensed and made available under the terms and conditions of the BSD License
- which accompanies this distribution. The full text of the license may be found at
- http://opensource.org/licenses/bsd-license.php
-
- 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.<BR>
- This program and the accompanying materials
- are licensed and made available under the terms and conditions of the BSD License
- which accompanies this distribution. The full text of the license may be found at
- http://opensource.org/licenses/bsd-license.php
-
- 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/Fv.c b/OvmfPkg/PlatformPei/Fv.c
deleted file mode 100644
index 3ed775c850..0000000000
--- a/OvmfPkg/PlatformPei/Fv.c
+++ /dev/null
@@ -1,75 +0,0 @@
-/** @file
- Build FV related hobs for platform.
-
- Copyright (c) 2006 - 2013, Intel Corporation. All rights reserved.<BR>
- This program and the accompanying materials
- are licensed and made available under the terms and conditions of the BSD License
- which accompanies this distribution. The full text of the license may be found at
- http://opensource.org/licenses/bsd-license.php
-
- THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
- WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
-
-**/
-
-#include "PiPei.h"
-#include "Platform.h"
-#include <Library/DebugLib.h>
-#include <Library/HobLib.h>
-#include <Library/PeiServicesLib.h>
-#include <Library/PcdLib.h>
-
-
-/**
- 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
- )
-{
- 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));
-
- //
- // Create a memory allocation HOB for the DXE FV.
- //
- BuildMemoryAllocationHob (
- PcdGet32 (PcdOvmfDxeMemFvBase),
- PcdGet32 (PcdOvmfDxeMemFvSize),
- EfiBootServicesData
- );
-
- //
- // 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 612bb4a3ef..0000000000
--- a/OvmfPkg/PlatformPei/MemDetect.c
+++ /dev/null
@@ -1,404 +0,0 @@
-/**@file
- Memory Detection for Virtual Machines.
-
- Copyright (c) 2006 - 2014, Intel Corporation. All rights reserved.<BR>
- This program and the accompanying materials
- are licensed and made available under the terms and conditions of the BSD License
- which accompanies this distribution. The full text of the license may be found at
- http://opensource.org/licenses/bsd-license.php
-
- 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 <PiPei.h>
-
-//
-// The Library classes this module consumes
-//
-#include <Library/BaseMemoryLib.h>
-#include <Library/DebugLib.h>
-#include <Library/HobLib.h>
-#include <Library/IoLib.h>
-#include <Library/PcdLib.h>
-#include <Library/PeimEntryPoint.h>
-#include <Library/ResourcePublicationLib.h>
-#include <Library/MtrrLib.h>
-
-#include "Platform.h"
-#include "Cmos.h"
-
-UINT8 mPhysMemAddressWidth;
-
-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);
-}
-
-
-/**
- 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 = BASE_4GB + GetSystemMemorySizeAbove4gb ();
- 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;
- UINT64 LowerMemorySize;
- UINT32 PeiMemoryCap;
-
- if (mBootMode == BOOT_ON_S3_RESUME) {
- MemoryBase = PcdGet32 (PcdS3AcpiReservedMemoryBase);
- MemorySize = PcdGet32 (PcdS3AcpiReservedMemorySize);
- } else {
- LowerMemorySize = GetSystemMemorySizeBelow4gb ();
-
- 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
- //
- MemoryBase = 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 memory HOBs
- //
- AddMemoryRangeHob (0, BASE_512KB + BASE_128KB);
- AddMemoryRangeHob (BASE_1MB, LowerMemorySize);
- if (UpperMemorySize != 0) {
- AddUntestedMemoryBaseSizeHob (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 (
- (EFI_PHYSICAL_ADDRESS)(UINTN) PcdGet32 (PcdS3AcpiReservedMemoryBase),
- (UINT64)(UINTN) PcdGet32 (PcdS3AcpiReservedMemorySize),
- 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) {
- //
- // 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
- );
- }
-}
diff --git a/OvmfPkg/PlatformPei/Platform.c b/OvmfPkg/PlatformPei/Platform.c
deleted file mode 100644
index 9970d1479e..0000000000
--- a/OvmfPkg/PlatformPei/Platform.c
+++ /dev/null
@@ -1,437 +0,0 @@
-/**@file
- Platform PEI driver
-
- Copyright (c) 2006 - 2014, Intel Corporation. All rights reserved.<BR>
- Copyright (c) 2011, Andrei Warkentin <andreiw@motorola.com>
-
- This program and the accompanying materials
- are licensed and made available under the terms and conditions of the BSD License
- which accompanies this distribution. The full text of the license may be found at
- http://opensource.org/licenses/bsd-license.php
-
- 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 <PiPei.h>
-
-//
-// The Library classes this module consumes
-//
-#include <Library/DebugLib.h>
-#include <Library/HobLib.h>
-#include <Library/IoLib.h>
-#include <Library/MemoryAllocationLib.h>
-#include <Library/PcdLib.h>
-#include <Library/PciLib.h>
-#include <Library/PeimEntryPoint.h>
-#include <Library/PeiServicesLib.h>
-#include <Library/QemuFwCfgLib.h>
-#include <Library/ResourcePublicationLib.h>
-#include <Guid/MemoryTypeInformation.h>
-#include <Ppi/MasterBootMode.h>
-#include <IndustryStandard/Pci22.h>
-#include <OvmfPlatforms.h>
-
-#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;
-
-
-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
- )
-{
- BuildResourceDescriptorHob (
- EFI_RESOURCE_MEMORY_RESERVED,
- EFI_RESOURCE_ATTRIBUTE_PRESENT |
- EFI_RESOURCE_ATTRIBUTE_INITIALIZED |
- EFI_RESOURCE_ATTRIBUTE_UNCACHEABLE |
- 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
-AddUntestedMemoryBaseSizeHob (
- 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,
- MemoryBase,
- MemorySize
- );
-}
-
-
-VOID
-AddUntestedMemoryRangeHob (
- EFI_PHYSICAL_ADDRESS MemoryBase,
- EFI_PHYSICAL_ADDRESS MemoryLimit
- )
-{
- AddUntestedMemoryBaseSizeHob (MemoryBase, (UINT64)(MemoryLimit - MemoryBase));
-}
-
-VOID
-MemMapInitialization (
- VOID
- )
-{
- //
- // Create Memory Type Information HOB
- //
- BuildGuidDataHob (
- &gEfiMemoryTypeInformationGuid,
- mDefaultMemoryTypeInformation,
- sizeof(mDefaultMemoryTypeInformation)
- );
-
- //
- // Add PCI IO Port space available for PCI resource allocations.
- //
- BuildResourceDescriptorHob (
- EFI_RESOURCE_IO,
- EFI_RESOURCE_ATTRIBUTE_PRESENT |
- EFI_RESOURCE_ATTRIBUTE_INITIALIZED,
- 0xC000,
- 0x4000
- );
-
- //
- // Video memory + Legacy BIOS region
- //
- AddIoMemoryRangeHob (0x0A0000, BASE_1MB);
-
- if (!mXen) {
- UINT32 TopOfLowRam;
- TopOfLowRam = GetSystemMemorySizeBelow4gb ();
-
- //
- // 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
- //
- AddIoMemoryRangeHob (TopOfLowRam < BASE_2GB ?
- BASE_2GB : TopOfLowRam, 0xFC000000);
- AddIoMemoryBaseSizeHob (0xFEC00000, SIZE_4KB);
- AddIoMemoryBaseSizeHob (0xFED00000, SIZE_1KB);
- if (mHostBridgeDevId == INTEL_Q35_MCH_DEVICE_ID) {
- AddIoMemoryBaseSizeHob (ICH9_ROOT_COMPLEX_BASE, SIZE_16KB);
- }
- AddIoMemoryBaseSizeHob (PcdGet32(PcdCpuLocalApicBaseAddress), SIZE_1MB);
- }
-}
-
-
-VOID
-MiscInitialization (
- VOID
- )
-{
- UINTN PmCmd;
- UINTN Pmba;
- UINTN AcpiCtlReg;
- UINT8 AcpiEnBit;
-
- //
- // 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);
- 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);
- 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;
- }
- PcdSet16 (PcdOvmfHostBridgePciDevId, mHostBridgeDevId);
-
- //
- // 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, (UINT32) ~0xFFC0, PcdGet16 (PcdAcpiPmBaseAddress));
-
- //
- // 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
- );
- }
-}
-
-
-VOID
-BootModeInitialization (
- VOID
- )
-{
- EFI_STATUS Status;
-
- if (CmosRead8 (0xF) == 0xFE) {
- mBootMode = BOOT_ON_S3_RESUME;
- }
-
- Status = PeiServicesSetBootMode (mBootMode);
- ASSERT_EFI_ERROR (Status);
-
- Status = PeiServicesInstallPpi (mPpiBootMode);
- ASSERT_EFI_ERROR (Status);
-}
-
-
-VOID
-ReserveEmuVariableNvStore (
- )
-{
- EFI_PHYSICAL_ADDRESS VariableStore;
-
- //
- // 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
- ));
- PcdSet64 (PcdEmuVariableNvStoreReserved, VariableStore);
-}
-
-
-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"));
- }
- }
-}
-
-
-/**
- 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
- )
-{
- 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;
- }
-
- BootModeInitialization ();
- AddressWidthInitialization ();
-
- 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 ();
- }
-
- MiscInitialization ();
-
- return EFI_SUCCESS;
-}
diff --git a/OvmfPkg/PlatformPei/Platform.h b/OvmfPkg/PlatformPei/Platform.h
deleted file mode 100644
index 8b6a9760eb..0000000000
--- a/OvmfPkg/PlatformPei/Platform.h
+++ /dev/null
@@ -1,110 +0,0 @@
-/** @file
- Platform PEI module include file.
-
- Copyright (c) 2006 - 2014, Intel Corporation. All rights reserved.<BR>
- This program and the accompanying materials
- are licensed and made available under the terms and conditions of the BSD License
- which accompanies this distribution. The full text of the license may be found at
- http://opensource.org/licenses/bsd-license.php
-
- 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 <IndustryStandard/E820.h>
-
-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
-AddUntestedMemoryBaseSizeHob (
- EFI_PHYSICAL_ADDRESS MemoryBase,
- UINT64 MemorySize
- );
-
-VOID
-AddReservedMemoryBaseSizeHob (
- EFI_PHYSICAL_ADDRESS MemoryBase,
- UINT64 MemorySize
- );
-
-VOID
-AddUntestedMemoryRangeHob (
- EFI_PHYSICAL_ADDRESS MemoryBase,
- EFI_PHYSICAL_ADDRESS MemoryLimit
- );
-
-VOID
-AddressWidthInitialization (
- VOID
- );
-
-EFI_STATUS
-PublishPeiMemory (
- VOID
- );
-
-UINT32
-GetSystemMemorySizeBelow4gb (
- VOID
- );
-
-VOID
-InitializeRamRegions (
- VOID
- );
-
-EFI_STATUS
-PeiFvInitialization (
- 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;
-
-#endif // _PLATFORM_PEI_H_INCLUDED_
diff --git a/OvmfPkg/PlatformPei/PlatformPei.inf b/OvmfPkg/PlatformPei/PlatformPei.inf
deleted file mode 100644
index 81335a964f..0000000000
--- a/OvmfPkg/PlatformPei/PlatformPei.inf
+++ /dev/null
@@ -1,93 +0,0 @@
-## @file
-# Platform PEI driver
-#
-# This module provides platform specific function to detect boot mode.
-# Copyright (c) 2006 - 2014, Intel Corporation. All rights reserved.<BR>
-#
-# This program and the accompanying materials
-# are licensed and made available under the terms and conditions of the BSD License
-# which accompanies this distribution. The full text of the license may be found at
-# http://opensource.org/licenses/bsd-license.php
-#
-# 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
- 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]
- DebugLib
- HobLib
- IoLib
- PciLib
- PeiResourcePublicationLib
- PeiServicesLib
- PeiServicesTablePointerLib
- PeimEntryPoint
- QemuFwCfgLib
- MtrrLib
- PcdLib
-
-[Pcd]
- gUefiOvmfPkgTokenSpaceGuid.PcdOvmfPeiMemFvBase
- gUefiOvmfPkgTokenSpaceGuid.PcdOvmfPeiMemFvSize
- gUefiOvmfPkgTokenSpaceGuid.PcdOvmfDxeMemFvBase
- gUefiOvmfPkgTokenSpaceGuid.PcdOvmfDxeMemFvSize
- gUefiOvmfPkgTokenSpaceGuid.PcdAcpiPmBaseAddress
- gUefiOvmfPkgTokenSpaceGuid.PcdS3AcpiReservedMemoryBase
- gUefiOvmfPkgTokenSpaceGuid.PcdOvmfSecPeiTempRamBase
- gUefiOvmfPkgTokenSpaceGuid.PcdOvmfSecPeiTempRamSize
- gUefiOvmfPkgTokenSpaceGuid.PcdOvmfSecPageTablesBase
- gUefiOvmfPkgTokenSpaceGuid.PcdOvmfSecPageTablesSize
- gUefiOvmfPkgTokenSpaceGuid.PcdOvmfLockBoxStorageBase
- gUefiOvmfPkgTokenSpaceGuid.PcdOvmfLockBoxStorageSize
- gUefiOvmfPkgTokenSpaceGuid.PcdGuidedExtractHandlerTableSize
- gUefiOvmfPkgTokenSpaceGuid.PcdOvmfHostBridgePciDevId
- gEfiIntelFrameworkModulePkgTokenSpaceGuid.PcdS3AcpiReservedMemorySize
- gEfiMdePkgTokenSpaceGuid.PcdGuidedExtractHandlerTableAddress
- gEfiMdeModulePkgTokenSpaceGuid.PcdVariableStoreSize
- gEfiMdeModulePkgTokenSpaceGuid.PcdFlashNvStorageFtwSpareSize
- gEfiMdeModulePkgTokenSpaceGuid.PcdFlashNvStorageVariableSize
- gEfiMdeModulePkgTokenSpaceGuid.PcdEmuVariableNvStoreReserved
- gEfiMdeModulePkgTokenSpaceGuid.PcdPciDisableBusEnumeration
- gEfiMdeModulePkgTokenSpaceGuid.PcdDxeIplSwitchToLongMode
- gEfiMdeModulePkgTokenSpaceGuid.PcdUse1GPageTable
- gUefiCpuPkgTokenSpaceGuid.PcdCpuLocalApicBaseAddress
-
-[Ppis]
- gEfiPeiMasterBootModePpiGuid
-
-[Depex]
- TRUE
-
diff --git a/OvmfPkg/PlatformPei/Xen.c b/OvmfPkg/PlatformPei/Xen.c
deleted file mode 100644
index 1886326f20..0000000000
--- a/OvmfPkg/PlatformPei/Xen.c
+++ /dev/null
@@ -1,231 +0,0 @@
-/**@file
- Xen Platform PEI support
-
- Copyright (c) 2006 - 2014, Intel Corporation. All rights reserved.<BR>
- Copyright (c) 2011, Andrei Warkentin <andreiw@motorola.com>
-
- This program and the accompanying materials
- are licensed and made available under the terms and conditions of the BSD License
- which accompanies this distribution. The full text of the license may be found at
- http://opensource.org/licenses/bsd-license.php
-
- 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 <PiPei.h>
-
-//
-// The Library classes this module consumes
-//
-#include <Library/DebugLib.h>
-#include <Library/HobLib.h>
-#include <Library/MemoryAllocationLib.h>
-#include <Library/PcdLib.h>
-#include <Guid/XenInfo.h>
-#include <IndustryStandard/E820.h>
-#include <Library/ResourcePublicationLib.h>
-#include <Library/MtrrLib.h>
-
-#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
- //
- 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;
- }
-
- if (Entry->BaseAddr >= BASE_4GB) {
- AddUntestedMemoryBaseSizeHob (Entry->BaseAddr, Entry->Length);
- } else {
- 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
- )
-{
- 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);
-
- PcdSetBool (PcdPciDisableBusEnumeration, TRUE);
-
- 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.<BR>
-
-This program and the accompanying materials are licensed and made available under
-the terms and conditions of the BSD License that accompanies this distribution.
-The full text of the license may be found at
-http://opensource.org/licenses/bsd-license.php.
-
-THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
-WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
-
-**/
-
-#ifndef __XEN_H__
-#define __XEN_H__
-
-#include <PiPei.h>
-
-// 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 62f9158773..0000000000
--- a/OvmfPkg/QemuFlashFvbServicesRuntimeDxe/FvbInfo.c
+++ /dev/null
@@ -1,141 +0,0 @@
-/**@file
-
-Copyright (c) 2006, Intel Corporation. All rights reserved.<BR>
-This program and the accompanying materials
-are licensed and made available under the terms and conditions of the BSD License
-which accompanies this distribution. The full text of the license may be found at
-http://opensource.org/licenses/bsd-license.php
-
-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 <PiDxe.h>
-//
-// The protocols, PPI and GUID defintions for this module
-//
-#include <Guid/EventGroup.h>
-#include <Guid/FirmwareFileSystem2.h>
-#include <Guid/SystemNvDataGuid.h>
-#include <Protocol/FirmwareVolumeBlock.h>
-#include <Protocol/DevicePath.h>
-//
-// The Library classes this module consumes
-//
-#include <Library/UefiLib.h>
-#include <Library/UefiDriverEntryPoint.h>
-#include <Library/BaseLib.h>
-#include <Library/DxeServicesTableLib.h>
-#include <Library/UefiRuntimeLib.h>
-#include <Library/DebugLib.h>
-#include <Library/HobLib.h>
-#include <Library/BaseMemoryLib.h>
-#include <Library/MemoryAllocationLib.h>
-#include <Library/UefiBootServicesTableLib.h>
-#include <Library/PcdLib.h>
-
-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 e3e7176a41..0000000000
--- a/OvmfPkg/QemuFlashFvbServicesRuntimeDxe/FvbServicesRuntimeDxe.inf
+++ /dev/null
@@ -1,84 +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.<BR>
-#
-# This program and the accompanying materials
-# are licensed and made available under the terms and conditions of the BSD License
-# which accompanies this distribution. The full text of the license may be found at
-# http://opensource.org/licenses/bsd-license.php
-# 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
-#
-
-[Sources]
- FvbInfo.c
- FwBlockService.c
- QemuFlash.c
-
-[Packages]
- MdePkg/MdePkg.dec
- MdeModulePkg/MdeModulePkg.dec
- OvmfPkg/OvmfPkg.dec
-
-[LibraryClasses]
- UefiBootServicesTableLib
- MemoryAllocationLib
- BaseMemoryLib
- HobLib
- DebugLib
- UefiRuntimeLib
- DxeServicesTableLib
- BaseLib
- UefiDriverEntryPoint
- UefiLib
- PcdLib
-
-[Guids]
- gEfiEventVirtualAddressChangeGuid # ALWAYS_CONSUMED 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
-
-
-[Depex]
- TRUE
diff --git a/OvmfPkg/QemuFlashFvbServicesRuntimeDxe/FwBlockService.c b/OvmfPkg/QemuFlashFvbServicesRuntimeDxe/FwBlockService.c
deleted file mode 100644
index 9160bb885b..0000000000
--- a/OvmfPkg/QemuFlashFvbServicesRuntimeDxe/FwBlockService.c
+++ /dev/null
@@ -1,1229 +0,0 @@
-/**@file
-
-Copyright (c) 2006 - 2014, Intel Corporation. All rights reserved.<BR>
-This program and the accompanying materials
-are licensed and made available under the terms and conditions of the BSD License
-which accompanies this distribution. The full text of the license may be found at
-http://opensource.org/licenses/bsd-license.php
-
-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 package level header files this module uses
-//
-#include <PiDxe.h>
-
-//
-// The protocols, PPI and GUID defintions for this module
-//
-#include <Guid/EventGroup.h>
-#include <Protocol/FirmwareVolumeBlock.h>
-#include <Protocol/DevicePath.h>
-
-//
-// The Library classes this module consumes
-//
-#include <Library/UefiLib.h>
-#include <Library/UefiDriverEntryPoint.h>
-#include <Library/BaseLib.h>
-#include <Library/DxeServicesTableLib.h>
-#include <Library/UefiRuntimeLib.h>
-#include <Library/DebugLib.h>
-#include <Library/BaseMemoryLib.h>
-#include <Library/MemoryAllocationLib.h>
-#include <Library/UefiBootServicesTableLib.h>
-#include <Library/DevicePathLib.h>
-
-#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
- }
-};
-
-
-
-VOID
-EFIAPI
-FvbVirtualddressChangeEvent (
- 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.
-
- mFvbModuleGlobal->FvInstance[FVB_PHYSICAL] - Physical copy of instance data
- mFvbModuleGlobal->FvInstance[FVB_VIRTUAL] - Virtual pointer to common
- instance data.
-
-Arguments:
-
- (Standard EFI notify event - EFI_EVENT_NOTIFY)
-
-Returns:
-
- None
-
---*/
-{
- EFI_FW_VOL_INSTANCE *FwhInstance;
- UINTN Index;
-
- EfiConvertPointer (0x0, (VOID **) &mFvbModuleGlobal->FvInstance[FVB_VIRTUAL]);
-
- //
- // Convert the base address of all the instances
- //
- Index = 0;
- FwhInstance = mFvbModuleGlobal->FvInstance[FVB_PHYSICAL];
- while (Index < mFvbModuleGlobal->NumFv) {
- EfiConvertPointer (0x0, (VOID **) &FwhInstance->FvBase[FVB_VIRTUAL]);
- 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->FvbScratchSpace[FVB_VIRTUAL]);
- EfiConvertPointer (0x0, (VOID **) &mFvbModuleGlobal);
- QemuFlashConvertPointers ();
-}
-
-EFI_STATUS
-GetFvbInstance (
- IN UINTN Instance,
- IN ESAL_FWB_GLOBAL *Global,
- OUT EFI_FW_VOL_INSTANCE **FwhInstance,
- IN BOOLEAN Virtual
- )
-/*++
-
-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
- Virtual - Whether CPU is in virtual or physical mode
-
-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[Virtual];
- 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,
- IN BOOLEAN Virtual
- )
-/*++
-
-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
- Virtual - Whether CPU is in virtual or physical mode
-
-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, Virtual);
- ASSERT_EFI_ERROR (Status);
- *Address = FwhInstance->FvBase[Virtual];
-
- return EFI_SUCCESS;
-}
-
-EFI_STATUS
-FvbGetVolumeAttributes (
- IN UINTN Instance,
- OUT EFI_FVB_ATTRIBUTES_2 *Attributes,
- IN ESAL_FWB_GLOBAL *Global,
- IN BOOLEAN Virtual
- )
-/*++
-
-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
- Virtual - Whether CPU is in virtual or physical mode
-
-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, Virtual);
- 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,
- IN BOOLEAN Virtual
- )
-/*++
-
-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
- Virtual - Whether CPU is in virtual or physical mode
-
-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, Virtual);
- 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[Virtual] + 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,
- IN BOOLEAN Virtual
- )
-/*++
-
-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
- Virtual - Whether CPU is in virtual or physical mode
-
-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, Virtual);
- 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:
-
-Returns:
- EFI_SUCCESS - Successfully returns
-
---*/
-{
- EFI_FW_VOL_BLOCK_DEVICE *FvbDevice;
-
- FvbDevice = FVB_DEVICE_FROM_THIS (This);
-
- return FvbGetPhysicalAddress (FvbDevice->Instance, Address, mFvbModuleGlobal, EfiGoneVirtual ());
-}
-
-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,
- EfiGoneVirtual ()
- );
-}
-
-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, EfiGoneVirtual ());
-}
-
-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, EfiGoneVirtual ());
-}
-
-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, EfiGoneVirtual ());
- 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_HANDLE FwbHandle;
- EFI_FW_VOL_BLOCK_DEVICE *FvbDevice;
- EFI_FIRMWARE_VOLUME_BLOCK_PROTOCOL *OldFwbInterface;
- UINT32 MaxLbaSize;
- EFI_PHYSICAL_ADDRESS BaseAddress;
- UINTN Length;
- UINTN NumOfBlocks;
- EFI_EVENT VirtualAddressChangeEvent;
-
- 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));
-
- //
- // Only need to allocate once. There is only one copy of physical memory for
- // the private data of each FV instance. But in virtual mode or in physical
- // mode, the address of the the physical memory may be different.
- //
- mFvbModuleGlobal->FvInstance[FVB_PHYSICAL] = AllocateRuntimePool (BufferSize);
- ASSERT (mFvbModuleGlobal->FvInstance[FVB_PHYSICAL] != NULL);
-
- //
- // Make a virtual copy of the FvInstance pointer.
- //
- FwhInstance = mFvbModuleGlobal->FvInstance[FVB_PHYSICAL];
- mFvbModuleGlobal->FvInstance[FVB_VIRTUAL] = FwhInstance;
-
- mFvbModuleGlobal->NumFv = 0;
- MaxLbaSize = 0;
-
- FwVolHeader =
- (EFI_FIRMWARE_VOLUME_HEADER *) (UINTN)
- PcdGet32 (PcdOvmfFlashNvStorageVariableBase);
-
- FwhInstance->FvBase[FVB_PHYSICAL] = (UINTN) BaseAddress;
- FwhInstance->FvBase[FVB_VIRTUAL] = (UINTN) BaseAddress;
-
- CopyMem ((UINTN *) &(FwhInstance->VolumeHeader), (UINTN *) FwVolHeader, FwVolHeader->HeaderLength);
- FwVolHeader = &(FwhInstance->VolumeHeader);
- EfiInitializeLock (&(FwhInstance->FvbDevLock), TPL_HIGH_LEVEL);
-
- 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 does not contains extension header, then produce MEMMAP_DEVICE_PATH
- //
- FvbDevice->DevicePath = (EFI_DEVICE_PATH_PROTOCOL *) AllocateCopyPool (sizeof (FV_MEMMAP_DEVICE_PATH), &mFvMemmapDevicePathTemplate);
- ((FV_MEMMAP_DEVICE_PATH *) FvbDevice->DevicePath)->MemMapDevPath.StartingAddress = BaseAddress;
- ((FV_MEMMAP_DEVICE_PATH *) FvbDevice->DevicePath)->MemMapDevPath.EndingAddress = BaseAddress + FwVolHeader->FvLength - 1;
- } else {
- FvbDevice->DevicePath = (EFI_DEVICE_PATH_PROTOCOL *) AllocateCopyPool (sizeof (FV_PIWG_DEVICE_PATH), &mFvPIWGDevicePathTemplate);
- CopyGuid (
- &((FV_PIWG_DEVICE_PATH *)FvbDevice->DevicePath)->FvDevPath.FvName,
- (GUID *)(UINTN)(BaseAddress + FwVolHeader->ExtHeaderOffset)
- );
- }
-
- //
- // 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);
- }
-
- MarkMemoryRangeForRuntimeAccess (BaseAddress, Length);
-
- //
- // Set several PCD values to point to flash
- //
- PcdSet64 (
- PcdFlashNvStorageVariableBase64,
- (UINTN) PcdGet32 (PcdOvmfFlashNvStorageVariableBase)
- );
- PcdSet32 (
- PcdFlashNvStorageFtwWorkingBase,
- PcdGet32 (PcdOvmfFlashNvStorageFtwWorkingBase)
- );
- PcdSet32 (
- PcdFlashNvStorageFtwSpareBase,
- PcdGet32 (PcdOvmfFlashNvStorageFtwSpareBase)
- );
-
- FwhInstance = (EFI_FW_VOL_INSTANCE *)
- (
- (UINTN) ((UINT8 *) FwhInstance) + FwVolHeader->HeaderLength +
- (sizeof (EFI_FW_VOL_INSTANCE) - sizeof (EFI_FIRMWARE_VOLUME_HEADER))
- );
-
- VirtualAddressChangeEvent = NULL;
- Status = gBS->CreateEventEx (
- EVT_NOTIFY_SIGNAL,
- TPL_NOTIFY,
- FvbVirtualddressChangeEvent,
- NULL,
- &gEfiEventVirtualAddressChangeGuid,
- &VirtualAddressChangeEvent
- );
- ASSERT_EFI_ERROR (Status);
-
- PcdSetBool (PcdOvmfFlashVariablesEnable, TRUE);
- return EFI_SUCCESS;
-}
diff --git a/OvmfPkg/QemuFlashFvbServicesRuntimeDxe/FwBlockService.h b/OvmfPkg/QemuFlashFvbServicesRuntimeDxe/FwBlockService.h
deleted file mode 100644
index 06a092d900..0000000000
--- a/OvmfPkg/QemuFlashFvbServicesRuntimeDxe/FwBlockService.h
+++ /dev/null
@@ -1,184 +0,0 @@
-/**@file
-
-Copyright (c) 2006, Intel Corporation. All rights reserved.<BR>
-This program and the accompanying materials
-are licensed and made available under the terms and conditions of the BSD License
-which accompanies this distribution. The full text of the license may be found at
-http://opensource.org/licenses/bsd-license.php
-
-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
-
-//
-// BugBug: Add documentation here for data structure!!!!
-//
-#define FVB_PHYSICAL 0
-#define FVB_VIRTUAL 1
-
-typedef struct {
- EFI_LOCK FvbDevLock;
- UINTN FvBase[2];
- UINTN NumOfBlocks;
- EFI_FIRMWARE_VOLUME_HEADER VolumeHeader;
-} EFI_FW_VOL_INSTANCE;
-
-typedef struct {
- UINT32 NumFv;
- EFI_FW_VOL_INSTANCE *FvInstance[2];
- UINT8 *FvbScratchSpace[2];
-} ESAL_FWB_GLOBAL;
-
-//
-// 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,
- IN BOOLEAN Virtual
- );
-
-EFI_STATUS
-FvbGetVolumeAttributes (
- IN UINTN Instance,
- OUT EFI_FVB_ATTRIBUTES_2 *Attributes,
- IN ESAL_FWB_GLOBAL *Global,
- IN BOOLEAN Virtual
- );
-
-EFI_STATUS
-FvbGetPhysicalAddress (
- IN UINTN Instance,
- OUT EFI_PHYSICAL_ADDRESS *Address,
- IN ESAL_FWB_GLOBAL *Global,
- IN BOOLEAN Virtual
- );
-
-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,
- IN BOOLEAN Virtual
- );
-
-//
-// 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,
- ...
- );
-
-#endif
diff --git a/OvmfPkg/QemuFlashFvbServicesRuntimeDxe/QemuFlash.c b/OvmfPkg/QemuFlashFvbServicesRuntimeDxe/QemuFlash.c
deleted file mode 100644
index a96e0e5275..0000000000
--- a/OvmfPkg/QemuFlashFvbServicesRuntimeDxe/QemuFlash.c
+++ /dev/null
@@ -1,265 +0,0 @@
-/** @file
- OVMF support for QEMU system firmware flash device
-
- Copyright (c) 2009 - 2013, Intel Corporation. All rights reserved.<BR>
- This program and the accompanying materials
- are licensed and made available under the terms and conditions of the BSD License
- which accompanies this distribution. The full text of the license may be found at
- http://opensource.org/licenses/bsd-license.php
-
- THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
- WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
-
-**/
-
-#include "PiDxe.h"
-#include <Library/DebugLib.h>
-#include <Library/BaseMemoryLib.h>
-#include <Library/PcdLib.h>
-#include <Library/UefiBootServicesTableLib.h>
-#include <Library/UefiRuntimeLib.h>
-#include <Guid/EventGroup.h>
-
-#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
-
-
-STATIC UINT8 *mFlashBase = NULL;
-STATIC UINTN mFdBlockSize = 0;
-STATIC UINTN mFdBlockCount = 0;
-
-
-VOID
-QemuFlashConvertPointers (
- VOID
- )
-{
- EfiConvertPointer (0x0, (VOID **) &mFlashBase);
-}
-
-
-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 ()) {
- return EFI_WRITE_PROTECTED;
- }
-
- return EFI_SUCCESS;
-}
-
diff --git a/OvmfPkg/QemuFlashFvbServicesRuntimeDxe/QemuFlash.h b/OvmfPkg/QemuFlashFvbServicesRuntimeDxe/QemuFlash.h
deleted file mode 100644
index f77e880783..0000000000
--- a/OvmfPkg/QemuFlashFvbServicesRuntimeDxe/QemuFlash.h
+++ /dev/null
@@ -1,89 +0,0 @@
-/** @file
- OVMF support for QEMU system firmware flash device
-
- Copyright (c) 2009 - 2013, Intel Corporation. All rights reserved.<BR>
- This program and the accompanying materials
- are licensed and made available under the terms and conditions of the BSD License
- which accompanies this distribution. The full text of the license may be found at
- http://opensource.org/licenses/bsd-license.php
-
- THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
- WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
-
-**/
-
-#ifndef __QEMU_FLASH_H__
-#define __QEMU_FLASH_H__
-
-#include <Protocol/FirmwareVolumeBlock.h>
-
-/**
- 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/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.<BR>
-
- This program and the accompanying materials
- are licensed and made available under the terms and conditions of the BSD License
- which accompanies this distribution. The full text of the license may be found at
- http://opensource.org/licenses/bsd-license.php
-
- 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 8d962b4438..0000000000
--- a/OvmfPkg/QemuVideoDxe/Driver.c
+++ /dev/null
@@ -1,974 +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.<BR>
-
- This program and the accompanying materials
- are licensed and made available under the terms and conditions of the BSD License
- which accompanies this distribution. The full text of the license may be found at
- http://opensource.org/licenses/bsd-license.php
-
- 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 <IndustryStandard/Acpi.h>
-
-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;
- 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.<BR>
-
- This program and the accompanying materials
- are licensed and made available under the terms and conditions of the BSD License
- which accompanies this distribution. The full text of the license may be found at
- http://opensource.org/licenses/bsd-license.php
-
- 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 18d0779896..0000000000
--- a/OvmfPkg/QemuVideoDxe/Gop.c
+++ /dev/null
@@ -1,387 +0,0 @@
-/** @file
- Graphics Output Protocol functions for the QEMU video controller.
-
- Copyright (c) 2007 - 2010, Intel Corporation. All rights reserved.<BR>
-
- This program and the accompanying materials
- are licensed and made available under the terms and conditions of the BSD License
- which accompanies this distribution. The full text of the license may be found at
- http://opensource.org/licenses/bsd-license.php
-
- 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 <IndustryStandard/Acpi.h>
-#include <Library/BltLib.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;
-// UINTN Count;
-
- Private = QEMU_VIDEO_PRIVATE_DATA_FROM_GRAPHICS_OUTPUT_THIS (This);
-
- if (ModeNumber >= This->Mode->MaxMode) {
- return EFI_UNSUPPORTED;
- }
-
- ModeData = &Private->ModeData[ModeNumber];
-
- if (Private->LineBuffer) {
- gBS->FreePool (Private->LineBuffer);
- }
-
- Private->LineBuffer = AllocatePool (4 * ModeData->HorizontalResolution);
- if (Private->LineBuffer == NULL) {
- return EFI_OUT_OF_RESOURCES;
- }
-
- 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);
- gBS->FreePool (Private->LineBuffer);
- Private->LineBuffer = NULL;
- 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);
-
- BltLibConfigure (
- (VOID*)(UINTN) This->Mode->FrameBufferBase,
- This->Mode->Info
- );
-
- 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;
-
- //
- // 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 = BltLibGopBlt (
- 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->LineBuffer = NULL;
-
- //
- // 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->LineBuffer != NULL) {
- FreePool (Private->LineBuffer);
- }
-
- 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 9e0c3aa09f..0000000000
--- a/OvmfPkg/QemuVideoDxe/Initialize.c
+++ /dev/null
@@ -1,352 +0,0 @@
-/** @file
- Graphics Output Protocol functions for the QEMU video controller.
-
- Copyright (c) 2007 - 2010, Intel Corporation. All rights reserved.<BR>
-
- This program and the accompanying materials
- are licensed and made available under the terms and conditions of the BSD License
- which accompanies this distribution. The full text of the license may be found at
- http://opensource.org/licenses/bsd-license.php
-
- 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, 60, Crtc_640_480_256_60, Seq_640_480_256_60, 0xe3 },
-// { 800, 600, 8, 60, Crtc_800_600_256_60, Seq_800_600_256_60, 0xef },
- { 640, 480, 32, 60, Crtc_640_480_32bpp_60, Seq_640_480_32bpp_60, 0xef },
- { 800, 600, 32, 60, Crtc_800_600_32bpp_60, Seq_800_600_32bpp_60, 0xef },
-// { 1024, 768, 8, 60, Crtc_1024_768_256_60, Seq_1024_768_256_60, 0xef }
- { 1024, 768, 24, 60, Crtc_1024_768_24bpp_60, Seq_1024_768_24bpp_60, 0xef }
-// { 1024, 768, 32, 60, Crtc_1024_768_32bpp_60, Seq_1024_768_32bpp_60, 0xef }
-// { 960, 720, 32, 60, Crtc_960_720_32bpp_60, Seq_1024_768_32bpp_60, 0xef }
-};
-
-#define QEMU_VIDEO_CIRRUS_MODE_COUNT \
- (sizeof (QemuVideoCirrusModes) / sizeof (QemuVideoCirrusModes[0]))
-
-/**
- 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;
- ModeData->RefreshRate = VideoMode->RefreshRate;
- DEBUG ((EFI_D_INFO,
- "Adding Mode %d as Cirrus Internal Mode %d: %dx%d, %d-bit, %d Hz\n",
- (INT32) (ModeData - Private->ModeData),
- ModeData->InternalModeIndex,
- ModeData->HorizontalResolution,
- ModeData->VerticalResolution,
- ModeData->ColorDepth,
- ModeData->RefreshRate
- ));
-
- 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 \
- (sizeof (QemuVideoBochsModes) / sizeof (QemuVideoBochsModes[0]))
-
-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_VERBOSE, "%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;
- ModeData->RefreshRate = 60;
- DEBUG ((EFI_D_INFO,
- "Adding Mode %d as Bochs Internal Mode %d: %dx%d, %d-bit, %d Hz\n",
- (INT32) (ModeData - Private->ModeData),
- ModeData->InternalModeIndex,
- ModeData->HorizontalResolution,
- ModeData->VerticalResolution,
- ModeData->ColorDepth,
- ModeData->RefreshRate
- ));
-
- 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 52ee20d8ba..0000000000
--- a/OvmfPkg/QemuVideoDxe/Qemu.h
+++ /dev/null
@@ -1,511 +0,0 @@
-/** @file
- QEMU Video Controller Driver
-
- Copyright (c) 2006 - 2010, Intel Corporation. All rights reserved.<BR>
- This program and the accompanying materials
- are licensed and made available under the terms and conditions of the BSD License
- which accompanies this distribution. The full text of the license may be found at
- http://opensource.org/licenses/bsd-license.php
-
- 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 <Uefi.h>
-#include <Protocol/GraphicsOutput.h>
-#include <Protocol/PciIo.h>
-#include <Protocol/DriverSupportedEfiVersion.h>
-#include <Protocol/DevicePath.h>
-
-#include <Library/DebugLib.h>
-#include <Library/UefiDriverEntryPoint.h>
-#include <Library/UefiLib.h>
-#include <Library/PcdLib.h>
-#include <Library/MemoryAllocationLib.h>
-#include <Library/UefiBootServicesTableLib.h>
-#include <Library/BaseMemoryLib.h>
-#include <Library/DevicePathLib.h>
-#include <Library/TimerLib.h>
-
-#include <IndustryStandard/Pci.h>
-
-//
-// 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;
- UINT32 RefreshRate;
-} 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 three fields match the client-visible
- // EFI_GRAPHICS_OUTPUT_PROTOCOL_MODE.Mode and
- // EFI_GRAPHICS_OUTPUT_PROTOCOL_MODE.MaxMode fields.
- //
- UINTN CurrentMode;
- UINTN MaxMode;
- QEMU_VIDEO_MODE_DATA *ModeData;
-
- UINT8 *LineBuffer;
- QEMU_VIDEO_VARIANT Variant;
-} QEMU_VIDEO_PRIVATE_DATA;
-
-///
-/// Card-specific Video Mode structures
-///
-typedef struct {
- UINT32 Width;
- UINT32 Height;
- UINT32 ColorDepth;
- UINT32 RefreshRate;
- 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 ce1ff93d83..0000000000
--- a/OvmfPkg/QemuVideoDxe/QemuVideoDxe.inf
+++ /dev/null
@@ -1,71 +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 - 2011, Intel Corporation. All rights reserved.<BR>
-#
-# This program and the accompanying materials
-# are licensed and made available under the terms and conditions of the BSD License
-# which accompanies this distribution. The full text of the license may be found at
-# http://opensource.org/licenses/bsd-license.php
-#
-# THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
-# WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
-#
-##
-
-[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
- OptionRomPkg/OptionRomPkg.dec
- OvmfPkg/OvmfPkg.dec
-
-[LibraryClasses]
- BaseMemoryLib
- BltLib
- 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.<BR>
-;
-; This program and the accompanying materials are licensed and made available
-; under the terms and conditions of the BSD License which accompanies this
-; distribution. The full text of the license may be found at
-; http://opensource.org/licenses/bsd-license.php
-;
-; 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 6bb175bfd4..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:
- <http://www.cs.cmu.edu/~ralf/files.html>
- <http://www.ctyme.com/rbrown.htm>
-
- Copyright (C) 2014, Red Hat, Inc.
- Copyright (c) 2013 - 2014, Intel Corporation. All rights reserved.<BR>
-
- This program and the accompanying materials are licensed and made available
- under the terms and conditions of the BSD License which accompanies this
- distribution. The full text of the license may be found at
- http://opensource.org/licenses/bsd-license.php
-
- THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, WITHOUT
- WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
-**/
-
-#include <IndustryStandard/LegacyVgaBios.h>
-#include <Library/DebugLib.h>
-#include <Library/PciLib.h>
-#include <Library/PrintLib.h>
-
-#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_VERBOSE, "%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_VERBOSE, "%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 durig 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.<BR>
-#
-# This program and the accompanying materials are licensed and made available
-# under the terms and conditions of the BSD License which accompanies this
-# distribution. The full text of the license may be found at
-# http://opensource.org/licenses/bsd-license.php
-#
-# 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 147e6e0ebf..0000000000
--- a/OvmfPkg/README
+++ /dev/null
@@ -1,259 +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 <MdePkg/Include/Library/DebugLib.h>. One non-default bit (with
- some performance impact) that is frequently set for debugging is 0x00400000
- (DEBUG_VERBOSE).
- - The RELEASE build target ('-b RELEASE' build option, see below) disables
- all debug messages. The default build target is DEBUG.
-
-=== Build Scripts ===
-
-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
-
-=== 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: <http://wiki.qemu.org/Documentation/Networking>.
-
-* For a qemu >= 1.5 binary running *without* any "-M machine" option where
- "machine" would identify a < qemu-1.5 configuration (for example: "-M
- pc-i440fx-1.4" or "-M pc-0.13"), the 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 <http://wiki.qemu.org/Download>,
-
- - 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 -D FD_SIZE_2MB" to your build command,
- - For example: "build -D E1000_ENABLE -D FD_SIZE_2MB".
-
-* 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/PlatformBdsLib/PlatformBdsLib.inf {
- <BuildOptions>
- GCC:*_*_*_CC_FLAGS = -UMDEPKG_NDEBUG
- }
- IntelFrameworkModulePkg/Universal/BdsDxe/BdsDxe.inf {
- <BuildOptions>
- 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:
- <http://www.spice-space.org/download.html>, 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 b5a4cf8d71..0000000000
--- a/OvmfPkg/ResetVector/Ia32/PageTables64.asm
+++ /dev/null
@@ -1,93 +0,0 @@
-;------------------------------------------------------------------------------
-; @file
-; Sets the CR3 register for 64-bit paging
-;
-; Copyright (c) 2008 - 2013, Intel Corporation. All rights reserved.<BR>
-; This program and the accompanying materials
-; are licensed and made available under the terms and conditions of the BSD License
-; which accompanies this distribution. The full text of the license may be found at
-; http://opensource.org/licenses/bsd-license.php
-;
-; THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
-; WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
-;
-;------------------------------------------------------------------------------
-
-BITS 32
-
-%define PAGE_PRESENT 0x01
-%define PAGE_READ_WRITE 0x02
-%define PAGE_USER_SUPERVISOR 0x04
-%define PAGE_WRITE_THROUGH 0x08
-%define PAGE_CACHE_DISABLE 0x010
-%define PAGE_ACCESSED 0x020
-%define PAGE_DIRTY 0x040
-%define PAGE_PAT 0x080
-%define PAGE_GLOBAL 0x0100
-%define PAGE_2M_MBO 0x080
-%define PAGE_2M_PAT 0x01000
-
-%define PAGE_2M_PDE_ATTR (PAGE_2M_MBO + \
- PAGE_ACCESSED + \
- PAGE_DIRTY + \
- PAGE_READ_WRITE + \
- PAGE_PRESENT)
-
-%define PAGE_PDP_ATTR (PAGE_ACCESSED + \
- PAGE_READ_WRITE + \
- PAGE_PRESENT)
-
-
-;
-; Modified: EAX, ECX
-;
-SetCr3ForPageTables64:
-
- ;
- ; For OVMF, build some initial page tables at 0x800000-0x806000.
- ;
- ; This range should match with PcdOvmfSecPageTablesBase and
- ; PcdOvmfSecPageTablesSize which are 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 + 0x800000 - 4], eax
- loop clearPageTablesMemoryLoop
-
- ;
- ; Top level Page Directory Pointers (1 * 512GB entry)
- ;
- mov dword[0x800000], 0x801000 + PAGE_PDP_ATTR
-
- ;
- ; Next level Page Directory Pointers (4 * 1GB entries => 4GB)
- ;
- mov dword[0x801000], 0x802000 + PAGE_PDP_ATTR
- mov dword[0x801008], 0x803000 + PAGE_PDP_ATTR
- mov dword[0x801010], 0x804000 + PAGE_PDP_ATTR
- mov dword[0x801018], 0x805000 + 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 + 0x802000 - 8], eax
- loop pageTableEntriesLoop
-
- ;
- ; Set CR3 now that the paging structures are available
- ;
- mov eax, 0x800000
- mov cr3, eax
-
- OneTimeCallRet SetCr3ForPageTables64
diff --git a/OvmfPkg/ResetVector/ResetVector.inf b/OvmfPkg/ResetVector/ResetVector.inf
deleted file mode 100644
index 46610d243e..0000000000
--- a/OvmfPkg/ResetVector/ResetVector.inf
+++ /dev/null
@@ -1,37 +0,0 @@
-## @file
-# Reset Vector
-#
-# Copyright (c) 2006 - 2014, Intel Corporation. All rights reserved.<BR>
-#
-# This program and the accompanying materials
-# are licensed and made available under the terms and conditions of the BSD License
-# which accompanies this distribution. The full text of the license may be found at
-# http://opensource.org/licenses/bsd-license.php
-# 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]
- MdePkg/MdePkg.dec
- UefiCpuPkg/UefiCpuPkg.dec
-
-[BuildOptions]
- *_*_IA32_NASMB_FLAGS = -I$(WORKSPACE)/UefiCpuPkg/ResetVector/Vtf0/
- *_*_X64_NASMB_FLAGS = -I$(WORKSPACE)/UefiCpuPkg/ResetVector/Vtf0/
diff --git a/OvmfPkg/ResetVector/ResetVector.nasmb b/OvmfPkg/ResetVector/ResetVector.nasmb
deleted file mode 100644
index 31ac06ae4a..0000000000
--- a/OvmfPkg/ResetVector/ResetVector.nasmb
+++ /dev/null
@@ -1,66 +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.<BR>
-; This program and the accompanying materials
-; are licensed and made available under the terms and conditions of the BSD License
-; which accompanies this distribution. The full text of the license may be found at
-; http://opensource.org/licenses/bsd-license.php
-;
-; 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 <Base.h>
- #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 "Ia32/Flat32ToFlat64.asm"
-%include "Ia32/PageTables64.asm"
-%endif
-
-%include "Ia16/Real16ToFlat32.asm"
-%include "Ia16/Init16.asm"
-
-%include "Main.asm"
-
-%include "Ia16/ResetVectorVtf0.asm"
-
diff --git a/OvmfPkg/ResetVector/ResetVectorCode.asm b/OvmfPkg/ResetVector/ResetVectorCode.asm
deleted file mode 100644
index 052c821f21..0000000000
--- a/OvmfPkg/ResetVector/ResetVectorCode.asm
+++ /dev/null
@@ -1,53 +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.<BR>
-; This program and the accompanying materials
-; are licensed and made available under the terms and conditions of the BSD License
-; which accompanies this distribution. The full text of the license may be found at
-; http://opensource.org/licenses/bsd-license.php
-;
-; THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
-; WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
-;
-;------------------------------------------------------------------------------
-
-%ifdef ARCH_IA32
- %ifdef ARCH_X64
- %error "Only one of ARCH_IA32 or ARCH_X64 can be defined."
- %endif
-%elifdef ARCH_X64
-%else
- %error "Either ARCH_IA32 or ARCH_X64 must be defined."
-%endif
-
-%include "CommonMacros.inc"
-
-%include "PostCodes.inc"
-
-%ifdef DEBUG_NONE
- %include "DebugDisabled.asm"
-%elifdef DEBUG_PORT80
- %include "Port80Debug.asm"
-%elifdef DEBUG_SERIAL
- %include "SerialDebug.asm"
-%else
- %error "No debug type was specified."
-%endif
-
-%include "Ia32/SearchForBfvBase.asm"
-%include "Ia32/SearchForSecEntry.asm"
-
-%ifdef ARCH_X64
-%include "Ia32/Flat32ToFlat64.asm"
-%include "Ia32/PageTables64.asm"
-%endif
-
-%include "Ia16/Real16ToFlat32.asm"
-%include "Ia16/Init16.asm"
-
-%include "Main.asm"
-
-%include "Ia16/ResetVectorVtf0.asm"
-
diff --git a/OvmfPkg/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.<BR>
-;* This program and the accompanying materials
-;* are licensed and made available under the terms and conditions of the BSD License
-;* which accompanies this distribution. The full text of the license may be found at
-;* http://opensource.org/licenses/bsd-license.php
-;*
-;* 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 <Base.h>
-
- 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 b7df549f31..0000000000
--- a/OvmfPkg/Sec/SecMain.c
+++ /dev/null
@@ -1,892 +0,0 @@
-/** @file
- Main SEC phase code. Transitions to PEI.
-
- Copyright (c) 2008 - 2013, Intel Corporation. All rights reserved.<BR>
-
- This program and the accompanying materials
- are licensed and made available under the terms and conditions of the BSD License
- which accompanies this distribution. The full text of the license may be found at
- http://opensource.org/licenses/bsd-license.php
-
- THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
- WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
-
-**/
-
-#include <PiPei.h>
-
-#include <Library/PeimEntryPoint.h>
-#include <Library/BaseLib.h>
-#include <Library/DebugLib.h>
-#include <Library/BaseMemoryLib.h>
-#include <Library/PeiServicesLib.h>
-#include <Library/PcdLib.h>
-#include <Library/UefiCpuLib.h>
-#include <Library/DebugAgentLib.h>
-#include <Library/IoLib.h>
-#include <Library/PeCoffLib.h>
-#include <Library/PeCoffGetEntryPointLib.h>
-#include <Library/PeCoffExtraActionLib.h>
-#include <Library/ExtractGuidedSectionLib.h>
-
-#include <Ppi/TemporaryRamSupport.h>
-
-#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_FIRMWARE_VOLUME_IMAGE_SECTION *FvSection;
- EFI_FIRMWARE_VOLUME_HEADER *PeiMemFv;
- EFI_FIRMWARE_VOLUME_HEADER *DxeMemFv;
-
- FvSection = (EFI_FIRMWARE_VOLUME_IMAGE_SECTION*) 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);
- 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,
- (EFI_COMMON_SECTION_HEADER**) &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,
- (EFI_COMMON_SECTION_HEADER**) &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);
- ASSERT (SECTION_SIZE (FvSection) ==
- (PcdGet32 (PcdOvmfDxeMemFvSize) + sizeof (*FvSection)));
-
- DxeMemFv = (EFI_FIRMWARE_VOLUME_HEADER*)(UINTN) PcdGet32 (PcdOvmfDxeMemFvBase);
- CopyMem (DxeMemFv, (VOID*) (FvSection + 1), 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
- )
-{
- *PeiCoreImageBase = 0;
-
- if (IsS3Resume ()) {
- DEBUG ((EFI_D_VERBOSE, "SEC: S3 resume\n"));
- GetS3ResumePeiFv (BootFv);
- } else {
- DEBUG ((EFI_D_VERBOSE, "SEC: Normal boot\n"));
- 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 inforamtion. 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;
-
- 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 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 fce99fb74c..0000000000
--- a/OvmfPkg/Sec/SecMain.inf
+++ /dev/null
@@ -1,69 +0,0 @@
-## @file
-# SEC Driver
-#
-# Copyright (c) 2008 - 2013, Intel Corporation. All rights reserved.<BR>
-#
-# This program and the accompanying materials
-# are licensed and made available under the terms and conditions of the BSD License
-# which accompanies this distribution. The full text of the license may be found at
-# http://opensource.org/licenses/bsd-license.php
-#
-# THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
-# WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
-#
-##
-
-[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
-
-[Ppis]
- gEfiTemporaryRamSupportPpiGuid # PPI ALWAYS_PRODUCED
-
-[Pcd]
- gUefiOvmfPkgTokenSpaceGuid.PcdOvmfPeiMemFvBase
- gUefiOvmfPkgTokenSpaceGuid.PcdOvmfPeiMemFvSize
- gUefiOvmfPkgTokenSpaceGuid.PcdOvmfDxeMemFvBase
- gUefiOvmfPkgTokenSpaceGuid.PcdOvmfDxeMemFvSize
- gUefiOvmfPkgTokenSpaceGuid.PcdOvmfSecPageTablesBase
- gUefiOvmfPkgTokenSpaceGuid.PcdOvmfSecPeiTempRamBase
- gUefiOvmfPkgTokenSpaceGuid.PcdOvmfSecPeiTempRamSize
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.<BR>
-;* This program and the accompanying materials
-;* are licensed and made available under the terms and conditions of the BSD License
-;* which accompanies this distribution. The full text of the license may be found at
-;* http://opensource.org/licenses/bsd-license.php
-;*
-;* 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 <Base.h>
-
-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 <gbtju85@gmail.com>
- Copyright (c) 2011, Intel Corporation. All rights reserved.<BR>
-
- This program and the accompanying materials are licensed and made available
- under the terms and conditions of the BSD License which accompanies this
- distribution. The full text of the license may be found at
- http://opensource.org/licenses/bsd-license.php
-
- THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, WITHOUT
- WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
-**/
-
-#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 <somlo@cmu.edu>
-
- This program and the accompanying materials are licensed and made
- available under the terms and conditions of the BSD License which
- accompanies this distribution. The full text of the license may
- be found at http://opensource.org/licenses/bsd-license.php
-
- 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 <Library/QemuFwCfgLib.h>
-#include <Library/MemoryAllocationLib.h>
-#include <Library/PcdLib.h>
-
-/**
- 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 <gbtju85@gmail.com>
- Copyright (c) 2011 - 2015, Intel Corporation. All rights reserved.<BR>
-
- This program and the accompanying materials
- are licensed and made available under the terms and conditions of the BSD License
- which accompanies this distribution. The full text of the license may be found at
- http://opensource.org/licenses/bsd-license.php
-
- 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 <gbtju85@gmail.com>
- Copyright (c) 2011, Intel Corporation. All rights reserved.<BR>
-
- This program and the accompanying materials
- are licensed and made available under the terms and conditions of the BSD License
- which accompanies this distribution. The full text of the license may be found at
- http://opensource.org/licenses/bsd-license.php
-
- THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
- WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
-
-**/
-
-#ifndef _SMBIOS_PLATFORM_DXE_H_
-#define _SMBIOS_PLATFORM_DXE_H_
-
-#include <PiDxe.h>
-
-#include <Protocol/Smbios.h>
-#include <IndustryStandard/SmBios.h>
-#include <Library/DebugLib.h>
-#include <Library/BaseLib.h>
-#include <Library/BaseMemoryLib.h>
-#include <Library/UefiBootServicesTableLib.h>
-#include <Library/MemoryAllocationLib.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
- );
-
-
-/**
- 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 <gbtju85@gmail.com>
-# Copyright (c) 2011, Intel Corporation. All rights reserved.<BR>
-#
-# This program and the accompanying materials
-# are licensed and made available under the terms and conditions of the BSD License
-# which accompanies this distribution. The full text of the license may be found at
-# http://opensource.org/licenses/bsd-license.php
-# THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
-# WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
-#
-##
-
-[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 3f018d6f5c..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 <gbtju85@gmail.com>
- Copyright (c) 2011, Intel Corporation. All rights reserved.<BR>
-
- This program and the accompanying materials
- are licensed and made available under the terms and conditions of the BSD License
- which accompanies this distribution. The full text of the license may be found at
- http://opensource.org/licenses/bsd-license.php
-
- THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
- WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
-
-**/
-
-#include "SmbiosPlatformDxe.h"
-#include <Library/HobLib.h>
-#include <Guid/XenInfo.h>
-
-#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/VarStore.fdf.inc b/OvmfPkg/VarStore.fdf.inc
deleted file mode 100644
index 8f91e39591..0000000000
--- a/OvmfPkg/VarStore.fdf.inc
+++ /dev/null
@@ -1,79 +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.<BR>
-#
-# This program and the accompanying materials are licensed and made available
-# under the terms and conditions of the BSD License which accompanies this
-# distribution. The full text of the license may be found at
-# http://opensource.org/licenses/bsd-license.php
-#
-# 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
-!if $(SECURE_BOOT_ENABLE) == TRUE
- # 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,
-!else
- # Signature: gEfiVariableGuid =
- # { 0xddcf3616, 0x3275, 0x4164,
- # { 0x98, 0xb6, 0xfe, 0x85, 0x70, 0x7f, 0xfe, 0x7d }}
- 0x16, 0x36, 0xcf, 0xdd, 0x75, 0x32, 0x64, 0x41,
- 0x98, 0xb6, 0xfe, 0x85, 0x70, 0x7f, 0xfe, 0x7d,
-!endif
- # 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/VirtioBlkDxe/VirtioBlk.c b/OvmfPkg/VirtioBlkDxe/VirtioBlk.c
deleted file mode 100644
index 862957ce04..0000000000
--- a/OvmfPkg/VirtioBlkDxe/VirtioBlk.c
+++ /dev/null
@@ -1,1102 +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 - 2014, Intel Corporation. All rights reserved.<BR>
-
- This program and the accompanying materials are licensed and made available
- under the terms and conditions of the BSD License which accompanies this
- distribution. The full text of the license may be found at
- http://opensource.org/licenses/bsd-license.php
-
- THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, WITHOUT
- WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
-
-**/
-
-#include <IndustryStandard/VirtioBlk.h>
-#include <Library/BaseMemoryLib.h>
-#include <Library/DebugLib.h>
-#include <Library/MemoryAllocationLib.h>
-#include <Library/UefiBootServicesTableLib.h>
-#include <Library/UefiLib.h>
-#include <Library/VirtioLib.h>
-
-#include "VirtioBlk.h"
-
-/**
-
- Convenience macros to read and write region 0 IO space elements of the
- virtio-blk 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) == 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;
-
- UINT32 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;
- }
- }
-
- //
- // 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,
- (UINT32) ((UINTN) Dev->Ring.Base >> EFI_PAGE_SHIFT));
- if (EFI_ERROR (Status)) {
- goto ReleaseQueue;
- }
-
-
- //
- // step 5 -- Report understood features. There are no virtio-blk specific
- // features to negotiate in virtio-0.9.5, plus we do not want any of the
- // device-independent (known or unknown) VIRTIO_F_* capabilities (see
- // Appendix B).
- //
- Status = Dev->VirtIo->SetGuestFeatures (Dev->VirtIo, 0);
- 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);
-}
-
-
-/**
-
- After we've pronounced support for a specific device in
- DriverBindingSupported(), we start managing said device (passed in by the
- Driver Exeuction Environment) with the following service.
-
- See DriverBindingSupported() for specification references.
-
- @param[in] This The EFI_DRIVER_BINDING_PROTOCOL object
- incorporating this driver (independently of
- any device).
-
- @param[in] DeviceHandle The supported device to drive.
-
- @param[in] RemainingDevicePath Relevant only for bus drivers, ignored.
-
-
- @retval EFI_SUCCESS Driver instance has been created and
- initialized for the virtio-blk device, it
- is now accessibla via EFI_BLOCK_IO_PROTOCOL.
-
- @retval EFI_OUT_OF_RESOURCES Memory allocation failed.
-
- @return Error codes from the OpenProtocol() boot
- service, the 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;
- }
-
- //
- // Setup complete, attempt to export the driver instance's BlockIo interface.
- //
- Dev->Signature = VBLK_SIG;
- Status = gBS->InstallProtocolInterface (&DeviceHandle,
- &gEfiBlockIoProtocolGuid, EFI_NATIVE_INTERFACE,
- &Dev->BlockIo);
- if (EFI_ERROR (Status)) {
- goto UninitDev;
- }
-
- return EFI_SUCCESS;
-
-UninitDev:
- VirtioBlkUninit (Dev);
-
-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;
- }
-
- 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 789caf9a37..0000000000
--- a/OvmfPkg/VirtioBlkDxe/VirtioBlk.h
+++ /dev/null
@@ -1,290 +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 <Protocol/BlockIo.h>
-#include <Protocol/ComponentName.h>
-#include <Protocol/DriverBinding.h>
-
-#include <IndustryStandard/Virtio.h>
-
-
-#define VBLK_SIG SIGNATURE_32 ('V', 'B', 'L', 'K')
-
-typedef struct {
- //
- // Parts of this structure are initialized / torn down in various functions
- // at various call depths. The table to the right should make it easier to
- // track them.
- //
- // field init function init dpth
- // --------------------- ------------------ ---------
- UINT32 Signature; // DriverBindingStart 0
- VIRTIO_DEVICE_PROTOCOL *VirtIo; // DriverBindingStart 0
- VRING Ring; // VirtioRingInit 2
- EFI_BLOCK_IO_PROTOCOL BlockIo; // VirtioBlkInit 1
- EFI_BLOCK_IO_MEDIA BlockIoMedia; // VirtioBlkInit 1
-} VBLK_DEV;
-
-#define VIRTIO_BLK_FROM_BLOCK_IO(BlockIoPointer) \
- 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 Exeuction Environment) with the following service.
-
- See DriverBindingSupported() for specification references.
-
- @param[in] This The EFI_DRIVER_BINDING_PROTOCOL object
- incorporating this driver (independently of
- any device).
-
- @param[in] DeviceHandle The supported device to drive.
-
- @param[in] RemainingDevicePath Relevant only for bus drivers, ignored.
-
-
- @retval EFI_SUCCESS Driver instance has been created and
- initialized for the virtio-blk device, it
- is now accessibla via EFI_BLOCK_IO_PROTOCOL.
-
- @retval EFI_OUT_OF_RESOURCES Memory allocation failed.
-
- @return Error codes from the OpenProtocol() boot
- service, 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/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.<BR>
-
- This program and the accompanying materials are licensed and made available
- under the terms and conditions of the BSD License which accompanies this
- distribution. The full text of the license may be found at
- http://opensource.org/licenses/bsd-license.php
-
- THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, WITHOUT
- WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
-
-**/
-
-#include <Library/UefiLib.h>
-
-#include "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 0ad39cf972..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.<BR>
-
- This program and the accompanying materials are licensed and made available
- under the terms and conditions of the BSD License which accompanies this
- distribution. The full text of the license may be found at
- http://opensource.org/licenses/bsd-license.php
-
- THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, WITHOUT
- WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
-
-**/
-
-#include <Library/BaseMemoryLib.h>
-#include <Library/DevicePathLib.h>
-#include <Library/MemoryAllocationLib.h>
-#include <Library/UefiBootServicesTableLib.h>
-
-#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;
- UINT32 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.<BR>
-
- This program and the accompanying materials are licensed and made available
- under the terms and conditions of the BSD License which accompanies this
- distribution. The full text of the license may be found at
- http://opensource.org/licenses/bsd-license.php
-
- THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, WITHOUT
- WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
-
-**/
-
-#include <Library/UefiLib.h>
-
-#include "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.<BR>
-
- This program and the accompanying materials are licensed and made available
- under the terms and conditions of the BSD License which accompanies this
- distribution. The full text of the license may be found at
- http://opensource.org/licenses/bsd-license.php
-
- THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, WITHOUT
- WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
-
-**/
-
-#include <Library/BaseLib.h>
-#include <Library/UefiBootServicesTableLib.h>
-
-#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.<BR>
-
- This program and the accompanying materials are licensed and made available
- under the terms and conditions of the BSD License which accompanies this
- distribution. The full text of the license may be found at
- http://opensource.org/licenses/bsd-license.php
-
- THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, WITHOUT
- WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
-
-**/
-
-#include <Library/BaseLib.h>
-#include <Library/UefiBootServicesTableLib.h>
-
-#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 223030af9e..0000000000
--- a/OvmfPkg/VirtioNetDxe/SnpInitialize.c
+++ /dev/null
@@ -1,490 +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.<BR>
-
- This program and the accompanying materials are licensed and made available
- under the terms and conditions of the BSD License which accompanies this
- distribution. The full text of the license may be found at
- http://opensource.org/licenses/bsd-license.php
-
- THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, WITHOUT
- WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
-
-**/
-
-#include <Library/BaseLib.h>
-#include <Library/MemoryAllocationLib.h>
-#include <Library/UefiBootServicesTableLib.h>
-
-#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,
- (UINT32) ((UINTN) Ring->Base >> EFI_PAGE_SHIFT));
- 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 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;
- }
-
- 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 = sizeof Dev->TxSharedReq;
- 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.Flags = 0;
- Dev->TxSharedReq.GsoType = VIRTIO_NET_HDR_GSO_NONE;
-
- //
- // 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 RxBufSize;
- UINT16 RxAlwaysPending;
- UINTN PktIdx;
- UINT16 DescIdx;
- UINT8 *RxPtr;
-
- //
- // 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 = sizeof (VIRTIO_NET_REQ) +
- (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 = sizeof (VIRTIO_NET_REQ);
- 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 -
- sizeof (VIRTIO_NET_REQ));
- 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;
- UINT32 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));
-
- //
- // 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
- //
- Features &= VIRTIO_NET_F_MAC | VIRTIO_NET_F_STATUS;
- 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.<BR>
-
- This program and the accompanying materials are licensed and made available
- under the terms and conditions of the BSD License which accompanies this
- distribution. The full text of the license may be found at
- http://opensource.org/licenses/bsd-license.php
-
- THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, WITHOUT
- WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
-
-**/
-
-#include <Library/UefiBootServicesTableLib.h>
-
-#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.<BR>
-
- This program and the accompanying materials are licensed and made available
- under the terms and conditions of the BSD License which accompanies this
- distribution. The full text of the license may be found at
- http://opensource.org/licenses/bsd-license.php
-
- THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, WITHOUT
- WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
-
-**/
-
-#include <Library/BaseLib.h>
-#include <Library/BaseMemoryLib.h>
-#include <Library/UefiBootServicesTableLib.h>
-
-#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.<BR>
-
- This program and the accompanying materials are licensed and made available
- under the terms and conditions of the BSD License which accompanies this
- distribution. The full text of the license may be found at
- http://opensource.org/licenses/bsd-license.php
-
- THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, WITHOUT
- WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
-
-**/
-
-#include <Library/UefiBootServicesTableLib.h>
-
-#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 <Library/MemoryAllocationLib.h>
-
-#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.<BR>
-
- This program and the accompanying materials are licensed and made available
- under the terms and conditions of the BSD License which accompanies this
- distribution. The full text of the license may be found at
- http://opensource.org/licenses/bsd-license.php
-
- THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, WITHOUT
- WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
-
-**/
-
-#include <Library/UefiBootServicesTableLib.h>
-
-#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.<BR>
-
- This program and the accompanying materials are licensed and made available
- under the terms and conditions of the BSD License which accompanies this
- distribution. The full text of the license may be found at
- http://opensource.org/licenses/bsd-license.php
-
- THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, WITHOUT
- WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
-
-**/
-
-#include <Library/UefiBootServicesTableLib.h>
-
-#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.<BR>
-
- This program and the accompanying materials are licensed and made available
- under the terms and conditions of the BSD License which accompanies this
- distribution. The full text of the license may be found at
- http://opensource.org/licenses/bsd-license.php
-
- THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, WITHOUT
- WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
-
-**/
-
-#include <Library/UefiBootServicesTableLib.h>
-
-#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.<BR>
-
- This program and the accompanying materials are licensed and made available
- under the terms and conditions of the BSD License which accompanies this
- distribution. The full text of the license may be found at
- http://opensource.org/licenses/bsd-license.php
-
- THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, WITHOUT
- WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
-
-**/
-
-#include <Library/BaseLib.h>
-#include <Library/BaseMemoryLib.h>
-#include <Library/UefiBootServicesTableLib.h>
-
-#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.<BR>
-
- This program and the accompanying materials are licensed and made available
- under the terms and conditions of the BSD License which accompanies this
- distribution. The full text of the license may be found at
- http://opensource.org/licenses/bsd-license.php
-
- 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 2d3f3d87eb..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 <IndustryStandard/VirtioNet.h>
-#include <Library/DebugLib.h>
-#include <Library/VirtioLib.h>
-#include <Protocol/ComponentName.h>
-#include <Protocol/ComponentName2.h>
-#include <Protocol/DevicePath.h>
-#include <Protocol/DriverBinding.h>
-#include <Protocol/SimpleNetwork.h>
-
-#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_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 2647bd3918..0000000000
--- a/OvmfPkg/VirtioPciDeviceDxe/VirtioPciDevice.c
+++ /dev/null
@@ -1,680 +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.<BR>
- Copyright (C) 2013, ARM Ltd.
-
- This program and the accompanying materials are licensed and made available
- under the terms and conditions of the BSD License which accompanies this
- distribution. The full text of the license may be found at
- http://opensource.org/licenses/bsd-license.php
-
- THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, WITHOUT
- WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
-
-**/
-
-#include <IndustryStandard/Pci.h>
-#include <Library/BaseMemoryLib.h>
-#include <Library/DebugLib.h>
-#include <Library/MemoryAllocationLib.h>
-#include <Library/UefiBootServicesTableLib.h>
-#include <Library/UefiLib.h>
-
-#include "VirtioPciDevice.h"
-
-STATIC VIRTIO_DEVICE_PROTOCOL mDeviceProtocolTemplate = {
- 0, // Revision
- 0, // SubSystemDeviceId
- VirtioPciGetDeviceFeatures, // GetDeviceFeatures
- VirtioPciSetGuestFeatures, // SetGuestFeatures
- VirtioPciGetQueueAddress, // GetQueueAddress
- VirtioPciSetQueueAddress, // SetQueueAddress
- VirtioPciSetQueueSel, // SetQueueSel
- VirtioPciSetQueueNotify, // SetQueueNotify
- VirtioPciSetQueueAlignment, // SetQueueAlignment
- VirtioPciSetPageSize, // SetPageSize
- VirtioPciGetQueueSize, // GetQueueNumMax
- VirtioPciSetQueueSize, // SetQueueNum
- VirtioPciGetDeviceStatus, // GetDeviceStatus
- VirtioPciSetDeviceStatus, // SetDeviceStatus
- VirtioPciDeviceWrite, // WriteDevice
- VirtioPciDeviceRead // ReadDevice
-};
-
-/**
-
- Read a word from Region 0 of the device specified by PciIo.
-
- Region 0 must be an iomem region. This is an internal function for the PCI
- implementation of the protocol.
-
- @param[in] Dev Virtio PCI device.
-
- @param[in] FieldOffset Source offset.
-
- @param[in] FieldSize Source field size, must be in { 1, 2, 4, 8 }.
-
- @param[in] BufferSize Number of bytes available in the target buffer. Must
- equal FieldSize.
-
- @param[out] Buffer Target buffer.
-
-
- @return Status code returned by PciIo->Io.Read().
-
-**/
-EFI_STATUS
-EFIAPI
-VirtioPciIoRead (
- IN VIRTIO_PCI_DEVICE *Dev,
- IN UINTN FieldOffset,
- IN UINTN FieldSize,
- IN UINTN BufferSize,
- OUT VOID *Buffer
- )
-{
- UINTN Count;
- EFI_PCI_IO_PROTOCOL_WIDTH Width;
- EFI_PCI_IO_PROTOCOL *PciIo;
-
- 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 Exeuction Environment) with the following service.
-
- See DriverBindingSupported() for specification references.
-
- @param[in] This The EFI_DRIVER_BINDING_PROTOCOL object
- incorporating this driver (independently of
- any device).
-
- @param[in] DeviceHandle The supported device to drive.
-
- @param[in] RemainingDevicePath Relevant only for bus drivers, ignored.
-
-
- @retval EFI_SUCCESS Driver instance has been created and
- initialized for the virtio-pci device, it
- is now accessible via VIRTIO_DEVICE_PROTOCOL.
-
- @retval EFI_OUT_OF_RESOURCES Memory allocation failed.
-
- @return Error codes from the OpenProtocol() boot
- service, the PciIo protocol, VirtioPciInit(),
- or the InstallProtocolInterface() boot service.
-
-**/
-STATIC
-EFI_STATUS
-EFIAPI
-VirtioPciDeviceBindingStart (
- IN EFI_DRIVER_BINDING_PROTOCOL *This,
- IN EFI_HANDLE DeviceHandle,
- IN EFI_DEVICE_PATH_PROTOCOL *RemainingDevicePath
- )
-{
- VIRTIO_PCI_DEVICE *Device;
- EFI_STATUS Status;
-
- Device = (VIRTIO_PCI_DEVICE *) AllocateZeroPool (sizeof *Device);
- if (Device == NULL) {
- return EFI_OUT_OF_RESOURCES;
- }
-
- Status = gBS->OpenProtocol (DeviceHandle, &gEfiPciIoProtocolGuid,
- (VOID **)&Device->PciIo, This->DriverBindingHandle,
- DeviceHandle, EFI_OPEN_PROTOCOL_BY_DRIVER);
- if (EFI_ERROR (Status)) {
- goto FreeVirtioPci;
- }
-
- //
- // We must retain and ultimately restore the original PCI attributes of the
- // device. See Driver Writer's Guide for UEFI 2.3.1 v1.01, 18.3 PCI drivers /
- // 18.3.2 Start() and Stop().
- //
- // The third parameter ("Attributes", input) is ignored by the Get operation.
- // The fourth parameter ("Result", output) is ignored by the Enable and Set
- // operations.
- //
- // For virtio-pci we only need IO space access.
- //
- Status = Device->PciIo->Attributes (Device->PciIo,
- EfiPciIoAttributeOperationGet, 0, &Device->OriginalPciAttributes);
- if (EFI_ERROR (Status)) {
- goto ClosePciIo;
- }
-
- Status = Device->PciIo->Attributes (Device->PciIo,
- EfiPciIoAttributeOperationEnable,
- EFI_PCI_IO_ATTRIBUTE_IO, NULL);
- if (EFI_ERROR (Status)) {
- goto ClosePciIo;
- }
-
- //
- // PCI IO access granted, configure protocol instance
- //
-
- Status = VirtioPciInit (Device);
- if (EFI_ERROR (Status)) {
- goto RestorePciAttributes;
- }
-
- //
- // Setup complete, attempt to export the driver instance's VirtioDevice
- // interface.
- //
- Device->Signature = VIRTIO_PCI_DEVICE_SIGNATURE;
- Status = gBS->InstallProtocolInterface (&DeviceHandle,
- &gVirtioDeviceProtocolGuid, EFI_NATIVE_INTERFACE,
- &Device->VirtioDevice);
- if (EFI_ERROR (Status)) {
- goto UninitDev;
- }
-
- return EFI_SUCCESS;
-
-UninitDev:
- VirtioPciUninit (Device);
-
-RestorePciAttributes:
- Device->PciIo->Attributes (Device->PciIo, EfiPciIoAttributeOperationSet,
- Device->OriginalPciAttributes, NULL);
-
-ClosePciIo:
- gBS->CloseProtocol (DeviceHandle, &gEfiPciIoProtocolGuid,
- This->DriverBindingHandle, DeviceHandle);
-
-FreeVirtioPci:
- FreePool (Device);
-
- return Status;
-}
-
-/**
-
- Stop driving the Virtio PCI device
-
- @param[in] This The EFI_DRIVER_BINDING_PROTOCOL object
- incorporating this driver (independently of any
- device).
-
- @param[in] DeviceHandle Stop driving this device.
-
- @param[in] NumberOfChildren Since this function belongs to a device driver
- only (as opposed to a bus driver), the caller
- environment sets NumberOfChildren to zero, and
- we ignore it.
-
- @param[in] ChildHandleBuffer Ignored (corresponding to NumberOfChildren).
-
- @retval EFI_SUCCESS Driver instance has been stopped and the PCI
- configuration attributes have been restored.
-
- @return Error codes from the OpenProtocol() or
- CloseProtocol(), UninstallProtocolInterface()
- boot services.
-
-**/
-STATIC
-EFI_STATUS
-EFIAPI
-VirtioPciDeviceBindingStop (
- IN EFI_DRIVER_BINDING_PROTOCOL *This,
- IN EFI_HANDLE DeviceHandle,
- IN UINTN NumberOfChildren,
- IN EFI_HANDLE *ChildHandleBuffer
- )
-{
- EFI_STATUS Status;
- VIRTIO_DEVICE_PROTOCOL *VirtioDevice;
- VIRTIO_PCI_DEVICE *Device;
-
- Status = gBS->OpenProtocol (
- DeviceHandle, // candidate device
- &gVirtioDeviceProtocolGuid, // retrieve the VirtIo iface
- (VOID **)&VirtioDevice, // target pointer
- This->DriverBindingHandle, // requestor driver identity
- DeviceHandle, // requesting lookup for dev.
- EFI_OPEN_PROTOCOL_GET_PROTOCOL // lookup only, no ref. added
- );
- if (EFI_ERROR (Status)) {
- return Status;
- }
-
- Device = VIRTIO_PCI_DEVICE_FROM_VIRTIO_DEVICE (VirtioDevice);
-
- //
- // Handle Stop() requests for in-use driver instances gracefully.
- //
- Status = gBS->UninstallProtocolInterface (DeviceHandle,
- &gVirtioDeviceProtocolGuid, &Device->VirtioDevice);
- if (EFI_ERROR (Status)) {
- return Status;
- }
-
- VirtioPciUninit (Device);
-
- Device->PciIo->Attributes (Device->PciIo, EfiPciIoAttributeOperationSet,
- Device->OriginalPciAttributes, NULL);
-
- Status = gBS->CloseProtocol (DeviceHandle, &gEfiPciIoProtocolGuid,
- This->DriverBindingHandle, DeviceHandle);
-
- FreePool (Device);
-
- return Status;
-}
-
-
-//
-// The static object that groups the Supported() (ie. probe), Start() and
-// Stop() functions of the driver together. Refer to UEFI Spec 2.3.1 + Errata
-// C, 10.1 EFI Driver Binding Protocol.
-//
-STATIC EFI_DRIVER_BINDING_PROTOCOL gDriverBinding = {
- &VirtioPciDeviceBindingSupported,
- &VirtioPciDeviceBindingStart,
- &VirtioPciDeviceBindingStop,
- 0x10, // Version, must be in [0x10 .. 0xFFFFFFEF] for IHV-developed drivers
- NULL, // ImageHandle, to be overwritten by
- // EfiLibInstallDriverBindingComponentName2() in VirtioPciEntryPoint()
- NULL // DriverBindingHandle, ditto
-};
-
-
-//
-// The purpose of the following scaffolding (EFI_COMPONENT_NAME_PROTOCOL and
-// EFI_COMPONENT_NAME2_PROTOCOL implementation) is to format the driver's name
-// in English, for display on standard console devices. This is recommended for
-// UEFI drivers that follow the UEFI Driver Model. Refer to the Driver Writer's
-// Guide for UEFI 2.3.1 v1.01, 11 UEFI Driver and Controller Names.
-//
-STATIC
-EFI_UNICODE_STRING_TABLE mDriverNameTable[] = {
- { "eng;en", L"Virtio PCI Driver" },
- { NULL, NULL }
-};
-
-STATIC
-EFI_COMPONENT_NAME_PROTOCOL gComponentName;
-
-EFI_STATUS
-EFIAPI
-VirtioPciGetDriverName (
- IN EFI_COMPONENT_NAME_PROTOCOL *This,
- IN CHAR8 *Language,
- OUT CHAR16 **DriverName
- )
-{
- return LookupUnicodeString2 (
- Language,
- This->SupportedLanguages,
- mDriverNameTable,
- DriverName,
- (BOOLEAN)(This == &gComponentName) // Iso639Language
- );
-}
-
-EFI_STATUS
-EFIAPI
-VirtioPciGetDeviceName (
- IN EFI_COMPONENT_NAME_PROTOCOL *This,
- IN EFI_HANDLE DeviceHandle,
- IN EFI_HANDLE ChildHandle,
- IN CHAR8 *Language,
- OUT CHAR16 **ControllerName
- )
-{
- return EFI_UNSUPPORTED;
-}
-
-STATIC
-EFI_COMPONENT_NAME_PROTOCOL gComponentName = {
- &VirtioPciGetDriverName,
- &VirtioPciGetDeviceName,
- "eng" // SupportedLanguages, ISO 639-2 language codes
-};
-
-STATIC
-EFI_COMPONENT_NAME2_PROTOCOL gComponentName2 = {
- (EFI_COMPONENT_NAME2_GET_DRIVER_NAME) &VirtioPciGetDriverName,
- (EFI_COMPONENT_NAME2_GET_CONTROLLER_NAME) &VirtioPciGetDeviceName,
- "en" // SupportedLanguages, RFC 4646 language codes
-};
-
-
-//
-// Entry point of this driver.
-//
-EFI_STATUS
-EFIAPI
-VirtioPciDeviceEntryPoint (
- IN EFI_HANDLE ImageHandle,
- IN EFI_SYSTEM_TABLE *SystemTable
- )
-{
- return EfiLibInstallDriverBindingComponentName2 (
- ImageHandle,
- SystemTable,
- &gDriverBinding,
- ImageHandle,
- &gComponentName,
- &gComponentName2
- );
-}
diff --git a/OvmfPkg/VirtioPciDeviceDxe/VirtioPciDevice.h b/OvmfPkg/VirtioPciDeviceDxe/VirtioPciDevice.h
deleted file mode 100644
index 6311ae849d..0000000000
--- a/OvmfPkg/VirtioPciDeviceDxe/VirtioPciDevice.h
+++ /dev/null
@@ -1,166 +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 <Protocol/ComponentName.h>
-#include <Protocol/DriverBinding.h>
-#include <Protocol/PciIo.h>
-#include <Protocol/VirtioDevice.h>
-
-#include <IndustryStandard/Virtio.h>
-
-#define VIRTIO_PCI_DEVICE_SIGNATURE SIGNATURE_32 ('V', 'P', 'C', 'I')
-
-typedef struct {
- UINT32 Signature;
- VIRTIO_DEVICE_PROTOCOL VirtioDevice;
- EFI_PCI_IO_PROTOCOL *PciIo;
- UINT64 OriginalPciAttributes;
- UINT32 DeviceSpecificConfigurationOffset;
-} VIRTIO_PCI_DEVICE;
-
-#define VIRTIO_PCI_DEVICE_FROM_VIRTIO_DEVICE(Device) \
- CR (Device, VIRTIO_PCI_DEVICE, VirtioDevice, VIRTIO_PCI_DEVICE_SIGNATURE)
-
-
-EFI_STATUS
-EFIAPI
-VirtioPciIoRead (
- IN VIRTIO_PCI_DEVICE *Dev,
- IN UINTN FieldOffset,
- IN UINTN FieldSize,
- IN UINTN BufferSize,
- OUT VOID *Buffer
- );
-
-EFI_STATUS
-EFIAPI
-VirtioPciIoWrite (
- IN VIRTIO_PCI_DEVICE *Dev,
- IN UINTN FieldOffset,
- IN UINTN FieldSize,
- IN UINT64 Value
- );
-
-/********************************************
- * PCI Functions for VIRTIO_DEVICE_PROTOCOL
- *******************************************/
-EFI_STATUS
-EFIAPI
-VirtioPciDeviceRead (
- IN VIRTIO_DEVICE_PROTOCOL *This,
- IN UINTN FieldOffset,
- IN UINTN FieldSize,
- IN UINTN BufferSize,
- OUT VOID *Buffer
- );
-
-EFI_STATUS
-EFIAPI
-VirtioPciDeviceWrite (
- IN VIRTIO_DEVICE_PROTOCOL *This,
- IN UINTN FieldOffset,
- IN UINTN FieldSize,
- IN UINT64 Value
- );
-
-EFI_STATUS
-EFIAPI
-VirtioPciGetDeviceFeatures (
- IN VIRTIO_DEVICE_PROTOCOL *This,
- OUT UINT32 *DeviceFeatures
- );
-
-EFI_STATUS
-EFIAPI
-VirtioPciGetQueueAddress (
- IN VIRTIO_DEVICE_PROTOCOL *This,
- OUT UINT32 *QueueAddress
- );
-
-EFI_STATUS
-EFIAPI
-VirtioPciGetQueueSize (
- IN VIRTIO_DEVICE_PROTOCOL *This,
- OUT UINT16 *QueueNumMax
- );
-
-EFI_STATUS
-EFIAPI
-VirtioPciSetQueueAlignment (
- VIRTIO_DEVICE_PROTOCOL *This,
- UINT32 Alignment
- );
-
-EFI_STATUS
-EFIAPI
-VirtioPciSetPageSize (
- VIRTIO_DEVICE_PROTOCOL *This,
- UINT32 PageSize
- );
-
-EFI_STATUS
-EFIAPI
-VirtioPciGetDeviceStatus (
- IN VIRTIO_DEVICE_PROTOCOL *This,
- OUT UINT8 *DeviceStatus
- );
-
-EFI_STATUS
-EFIAPI
-VirtioPciSetGuestFeatures (
- IN VIRTIO_DEVICE_PROTOCOL *This,
- IN UINT32 Features
- );
-
-EFI_STATUS
-EFIAPI
-VirtioPciSetQueueAddress (
- VIRTIO_DEVICE_PROTOCOL *This,
- UINT32 Address
- );
-
-EFI_STATUS
-EFIAPI
-VirtioPciSetQueueSel (
- VIRTIO_DEVICE_PROTOCOL *This,
- UINT16 Sel
- );
-
-EFI_STATUS
-EFIAPI
-VirtioPciSetQueueNotify (
- VIRTIO_DEVICE_PROTOCOL *This,
- UINT16 Index
- );
-
-EFI_STATUS
-EFIAPI
-VirtioPciSetQueueSize (
- VIRTIO_DEVICE_PROTOCOL *This,
- UINT16 Size
- );
-
-EFI_STATUS
-EFIAPI
-VirtioPciSetDeviceStatus (
- VIRTIO_DEVICE_PROTOCOL *This,
- UINT8 DeviceStatus
- );
-
-#endif // _VIRTIO_PCI_DEVICE_DXE_H_
diff --git a/OvmfPkg/VirtioPciDeviceDxe/VirtioPciDeviceDxe.inf b/OvmfPkg/VirtioPciDeviceDxe/VirtioPciDeviceDxe.inf
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 9c40fd94a6..0000000000
--- a/OvmfPkg/VirtioPciDeviceDxe/VirtioPciFunctions.c
+++ /dev/null
@@ -1,283 +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.<BR>
- Copyright (C) 2013, ARM Ltd.
-
- This program and the accompanying materials are licensed and made available
- under the terms and conditions of the BSD License which accompanies this
- distribution. The full text of the license may be found at
- http://opensource.org/licenses/bsd-license.php
-
- THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, WITHOUT
- WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
-
-**/
-#include <Library/BaseMemoryLib.h>
-#include <Library/DebugLib.h>
-#include <Library/MemoryAllocationLib.h>
-#include <Library/UefiBootServicesTableLib.h>
-#include <Library/UefiLib.h>
-#include "VirtioPciDevice.h"
-
-/**
-
- Read a word from Region 0 of the device specified by 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 UINT32 *DeviceFeatures
- )
-{
- VIRTIO_PCI_DEVICE *Dev;
-
- if (DeviceFeatures == NULL) {
- return EFI_INVALID_PARAMETER;
- }
-
- Dev = VIRTIO_PCI_DEVICE_FROM_VIRTIO_DEVICE (This);
-
- return VirtioPciIoRead (Dev, VIRTIO_PCI_OFFSET_DEVICE_FEATURES, sizeof (UINT32),
- sizeof (UINT32), DeviceFeatures);
-}
-
-EFI_STATUS
-EFIAPI
-VirtioPciGetQueueAddress (
- IN VIRTIO_DEVICE_PROTOCOL *This,
- OUT UINT32 *QueueAddress
- )
-{
- VIRTIO_PCI_DEVICE *Dev;
-
- if (QueueAddress == NULL) {
- return EFI_INVALID_PARAMETER;
- }
-
- Dev = VIRTIO_PCI_DEVICE_FROM_VIRTIO_DEVICE (This);
-
- return VirtioPciIoRead (Dev, VIRTIO_PCI_OFFSET_QUEUE_ADDRESS, sizeof (UINT32),
- sizeof (UINT32), QueueAddress);
-}
-
-EFI_STATUS
-EFIAPI
-VirtioPciGetQueueSize (
- IN VIRTIO_DEVICE_PROTOCOL *This,
- OUT UINT16 *QueueNumMax
- )
-{
- VIRTIO_PCI_DEVICE *Dev;
-
- if (QueueNumMax == NULL) {
- return EFI_INVALID_PARAMETER;
- }
-
- Dev = VIRTIO_PCI_DEVICE_FROM_VIRTIO_DEVICE (This);
-
- return VirtioPciIoRead (Dev, VIRTIO_PCI_OFFSET_QUEUE_SIZE, sizeof (UINT16),
- sizeof (UINT16), QueueNumMax);
-}
-
-EFI_STATUS
-EFIAPI
-VirtioPciGetDeviceStatus (
- IN VIRTIO_DEVICE_PROTOCOL *This,
- OUT UINT8 *DeviceStatus
- )
-{
- VIRTIO_PCI_DEVICE *Dev;
-
- if (DeviceStatus == NULL) {
- return EFI_INVALID_PARAMETER;
- }
-
- Dev = VIRTIO_PCI_DEVICE_FROM_VIRTIO_DEVICE (This);
-
- return VirtioPciIoRead (Dev, VIRTIO_PCI_OFFSET_QUEUE_DEVICE_STATUS,
- sizeof (UINT8), sizeof (UINT8), DeviceStatus);
-}
-
-EFI_STATUS
-EFIAPI
-VirtioPciSetGuestFeatures (
- IN VIRTIO_DEVICE_PROTOCOL *This,
- IN UINT32 Features
- )
-{
- VIRTIO_PCI_DEVICE *Dev;
-
- Dev = VIRTIO_PCI_DEVICE_FROM_VIRTIO_DEVICE (This);
-
- return VirtioPciIoWrite (Dev, VIRTIO_PCI_OFFSET_GUEST_FEATURES,
- sizeof (UINT32), Features);
-}
-
-EFI_STATUS
-EFIAPI
-VirtioPciSetQueueAddress (
- VIRTIO_DEVICE_PROTOCOL *This,
- UINT32 Address
- )
-{
- VIRTIO_PCI_DEVICE *Dev;
-
- Dev = VIRTIO_PCI_DEVICE_FROM_VIRTIO_DEVICE (This);
-
- return VirtioPciIoWrite (Dev, VIRTIO_PCI_OFFSET_QUEUE_ADDRESS, sizeof (UINT32),
- Address);
-}
-
-EFI_STATUS
-EFIAPI
-VirtioPciSetQueueSel (
- VIRTIO_DEVICE_PROTOCOL *This,
- UINT16 Sel
- )
-{
- VIRTIO_PCI_DEVICE *Dev;
-
- Dev = VIRTIO_PCI_DEVICE_FROM_VIRTIO_DEVICE (This);
-
- return VirtioPciIoWrite (Dev, VIRTIO_PCI_OFFSET_QUEUE_SELECT, sizeof (UINT16),
- Sel);
-}
-
-EFI_STATUS
-EFIAPI
-VirtioPciSetQueueAlignment (
- VIRTIO_DEVICE_PROTOCOL *This,
- UINT32 Alignment
- )
-{
- return EFI_SUCCESS;
-}
-
-EFI_STATUS
-EFIAPI
-VirtioPciSetPageSize (
- VIRTIO_DEVICE_PROTOCOL *This,
- UINT32 PageSize
- )
-{
- 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/VirtioScsiDxe/VirtioScsi.c b/OvmfPkg/VirtioScsiDxe/VirtioScsi.c
deleted file mode 100644
index 2cb3f43bb0..0000000000
--- a/OvmfPkg/VirtioScsiDxe/VirtioScsi.c
+++ /dev/null
@@ -1,1228 +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.<BR>
-
- This program and the accompanying materials are licensed and made available
- under the terms and conditions of the BSD License which accompanies this
- distribution. The full text of the license may be found at
- http://opensource.org/licenses/bsd-license.php
-
- THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, WITHOUT
- WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
-
-**/
-
-#include <IndustryStandard/VirtioScsi.h>
-#include <Library/BaseMemoryLib.h>
-#include <Library/DebugLib.h>
-#include <Library/MemoryAllocationLib.h>
-#include <Library/UefiBootServicesTableLib.h>
-#include <Library/UefiLib.h>
-#include <Library/VirtioLib.h>
-
-#include "VirtioScsi.h"
-
-/**
-
- Convenience macros to read and write 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) != EFI_SUCCESS) {
- Packet->InTransferLength = 0;
- Packet->OutTransferLength = 0;
- Packet->HostAdapterStatus = EFI_EXT_SCSI_STATUS_HOST_ADAPTER_OTHER;
- Packet->TargetStatus = EFI_EXT_SCSI_STATUS_TARGET_GOOD;
- Packet->SenseDataLength = 0;
- return EFI_DEVICE_ERROR;
- }
-
- return ParseResponse (Packet, &Response);
-}
-
-
-EFI_STATUS
-EFIAPI
-VirtioScsiGetNextTargetLun (
- IN EFI_EXT_SCSI_PASS_THRU_PROTOCOL *This,
- IN OUT UINT8 **TargetPointer,
- IN OUT UINT64 *Lun
- )
-{
- UINT8 *Target;
- UINTN Idx;
- UINT16 LastTarget;
- VSCSI_DEV *Dev;
-
- //
- // the TargetPointer input parameter is unnecessarily a pointer-to-pointer
- //
- Target = *TargetPointer;
-
- //
- // Search for first non-0xFF byte. If not found, return first target & LUN.
- //
- for (Idx = 0; Idx < TARGET_MAX_BYTES && Target[Idx] == 0xFF; ++Idx)
- ;
- if (Idx == TARGET_MAX_BYTES) {
- SetMem (Target, TARGET_MAX_BYTES, 0x00);
- *Lun = 0;
- return EFI_SUCCESS;
- }
-
- //
- // see the TARGET_MAX_BYTES check in "VirtioScsi.h"
- //
- CopyMem (&LastTarget, Target, sizeof LastTarget);
-
- //
- // increment (target, LUN) pair if valid on input
- //
- Dev = VIRTIO_SCSI_FROM_PASS_THRU (This);
- if (LastTarget > Dev->MaxTarget || *Lun > Dev->MaxLun) {
- return EFI_INVALID_PARAMETER;
- }
-
- if (*Lun < Dev->MaxLun) {
- ++*Lun;
- return EFI_SUCCESS;
- }
-
- if (LastTarget < Dev->MaxTarget) {
- *Lun = 0;
- ++LastTarget;
- CopyMem (Target, &LastTarget, sizeof LastTarget);
- return EFI_SUCCESS;
- }
-
- return EFI_NOT_FOUND;
-}
-
-
-EFI_STATUS
-EFIAPI
-VirtioScsiBuildDevicePath (
- IN EFI_EXT_SCSI_PASS_THRU_PROTOCOL *This,
- IN UINT8 *Target,
- IN UINT64 Lun,
- IN OUT EFI_DEVICE_PATH_PROTOCOL **DevicePath
- )
-{
- UINT16 TargetValue;
- VSCSI_DEV *Dev;
- SCSI_DEVICE_PATH *ScsiDevicePath;
-
- if (DevicePath == NULL) {
- return EFI_INVALID_PARAMETER;
- }
-
- CopyMem (&TargetValue, Target, sizeof TargetValue);
- Dev = VIRTIO_SCSI_FROM_PASS_THRU (This);
- if (TargetValue > Dev->MaxTarget || Lun > Dev->MaxLun || Lun > 0xFFFF) {
- return EFI_NOT_FOUND;
- }
-
- ScsiDevicePath = AllocatePool (sizeof *ScsiDevicePath);
- if (ScsiDevicePath == NULL) {
- return EFI_OUT_OF_RESOURCES;
- }
-
- ScsiDevicePath->Header.Type = MESSAGING_DEVICE_PATH;
- ScsiDevicePath->Header.SubType = MSG_SCSI_DP;
- ScsiDevicePath->Header.Length[0] = (UINT8) sizeof *ScsiDevicePath;
- ScsiDevicePath->Header.Length[1] = (UINT8) (sizeof *ScsiDevicePath >> 8);
- ScsiDevicePath->Pun = TargetValue;
- ScsiDevicePath->Lun = (UINT16) Lun;
-
- *DevicePath = &ScsiDevicePath->Header;
- return EFI_SUCCESS;
-}
-
-
-EFI_STATUS
-EFIAPI
-VirtioScsiGetTargetLun (
- IN EFI_EXT_SCSI_PASS_THRU_PROTOCOL *This,
- IN EFI_DEVICE_PATH_PROTOCOL *DevicePath,
- OUT UINT8 **TargetPointer,
- OUT UINT64 *Lun
- )
-{
- SCSI_DEVICE_PATH *ScsiDevicePath;
- VSCSI_DEV *Dev;
- UINT8 *Target;
-
- if (DevicePath == NULL || TargetPointer == NULL || *TargetPointer == NULL ||
- Lun == NULL) {
- return EFI_INVALID_PARAMETER;
- }
-
- if (DevicePath->Type != MESSAGING_DEVICE_PATH ||
- DevicePath->SubType != MSG_SCSI_DP) {
- return EFI_UNSUPPORTED;
- }
-
- ScsiDevicePath = (SCSI_DEVICE_PATH *) DevicePath;
- Dev = VIRTIO_SCSI_FROM_PASS_THRU (This);
- if (ScsiDevicePath->Pun > Dev->MaxTarget ||
- ScsiDevicePath->Lun > Dev->MaxLun) {
- return EFI_NOT_FOUND;
- }
-
- //
- // a) the TargetPointer input parameter is unnecessarily a pointer-to-pointer
- // b) see the TARGET_MAX_BYTES check in "VirtioScsi.h"
- // c) ScsiDevicePath->Pun is an UINT16
- //
- Target = *TargetPointer;
- CopyMem (Target, &ScsiDevicePath->Pun, 2);
- SetMem (Target + 2, TARGET_MAX_BYTES - 2, 0x00);
-
- *Lun = ScsiDevicePath->Lun;
- return EFI_SUCCESS;
-}
-
-
-EFI_STATUS
-EFIAPI
-VirtioScsiResetChannel (
- IN EFI_EXT_SCSI_PASS_THRU_PROTOCOL *This
- )
-{
- return EFI_UNSUPPORTED;
-}
-
-
-EFI_STATUS
-EFIAPI
-VirtioScsiResetTargetLun (
- IN EFI_EXT_SCSI_PASS_THRU_PROTOCOL *This,
- IN UINT8 *Target,
- IN UINT64 Lun
- )
-{
- return EFI_UNSUPPORTED;
-}
-
-
-EFI_STATUS
-EFIAPI
-VirtioScsiGetNextTarget (
- IN EFI_EXT_SCSI_PASS_THRU_PROTOCOL *This,
- IN OUT UINT8 **TargetPointer
- )
-{
- UINT8 *Target;
- UINTN Idx;
- UINT16 LastTarget;
- VSCSI_DEV *Dev;
-
- //
- // the TargetPointer input parameter is unnecessarily a pointer-to-pointer
- //
- Target = *TargetPointer;
-
- //
- // Search for first non-0xFF byte. If not found, return first target.
- //
- for (Idx = 0; Idx < TARGET_MAX_BYTES && Target[Idx] == 0xFF; ++Idx)
- ;
- if (Idx == TARGET_MAX_BYTES) {
- SetMem (Target, TARGET_MAX_BYTES, 0x00);
- return EFI_SUCCESS;
- }
-
- //
- // see the TARGET_MAX_BYTES check in "VirtioScsi.h"
- //
- CopyMem (&LastTarget, Target, sizeof LastTarget);
-
- //
- // increment target if valid on input
- //
- Dev = VIRTIO_SCSI_FROM_PASS_THRU (This);
- if (LastTarget > Dev->MaxTarget) {
- return EFI_INVALID_PARAMETER;
- }
-
- if (LastTarget < Dev->MaxTarget) {
- ++LastTarget;
- CopyMem (Target, &LastTarget, sizeof LastTarget);
- return EFI_SUCCESS;
- }
-
- return EFI_NOT_FOUND;
-}
-
-
-STATIC
-EFI_STATUS
-EFIAPI
-VirtioScsiInit (
- IN OUT VSCSI_DEV *Dev
- )
-{
- UINT8 NextDevStat;
- EFI_STATUS Status;
-
- UINT32 Features;
- UINT16 MaxChannel; // for validation only
- UINT32 NumQueues; // for validation only
- UINT16 QueueSize;
-
- //
- // Execute virtio-0.9.5, 2.2.1 Device Initialization Sequence.
- //
- NextDevStat = 0; // step 1 -- reset device
- Status = 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;
- }
-
- //
- // 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,
- (UINT32) ((UINTN) Dev->Ring.Base >> EFI_PAGE_SHIFT));
- if (EFI_ERROR (Status)) {
- goto ReleaseQueue;
- }
-
- //
- // step 5 -- Report understood features and guest-tuneables. We want none of
- // the known (or unknown) VIRTIO_SCSI_F_* or VIRTIO_F_* capabilities (see
- // virtio-0.9.5, Appendices B and I), except bidirectional transfers.
- //
- Status = Dev->VirtIo->SetGuestFeatures (Dev->VirtIo,
- Features & VIRTIO_SCSI_F_INOUT);
- if (EFI_ERROR (Status)) {
- goto ReleaseQueue;
- }
-
- //
- // We expect these maximum sizes from the host. Since they are
- // guest-negotiable, ask for them rather than just checking them.
- //
- Status = VIRTIO_CFG_WRITE (Dev, 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);
-}
-
-
-//
-// 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;
- }
-
- //
- // Setup complete, attempt to export the driver instance's PassThru
- // interface.
- //
- Dev->Signature = VSCSI_SIG;
- Status = gBS->InstallProtocolInterface (&DeviceHandle,
- &gEfiExtScsiPassThruProtocolGuid, EFI_NATIVE_INTERFACE,
- &Dev->PassThru);
- if (EFI_ERROR (Status)) {
- goto UninitDev;
- }
-
- return EFI_SUCCESS;
-
-UninitDev:
- VirtioScsiUninit (Dev);
-
-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;
- }
-
- 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 0d3181d140..0000000000
--- a/OvmfPkg/VirtioScsiDxe/VirtioScsi.h
+++ /dev/null
@@ -1,207 +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 <Protocol/ComponentName.h>
-#include <Protocol/DriverBinding.h>
-#include <Protocol/ScsiPassThruExt.h>
-
-#include <IndustryStandard/Virtio.h>
-
-
-//
-// This driver supports 2-byte target identifiers and 4-byte LUN identifiers.
-//
-// EFI_EXT_SCSI_PASS_THRU_PROTOCOL provides TARGET_MAX_BYTES bytes for target
-// identification, and 8 bytes for LUN identification.
-//
-// EFI_EXT_SCSI_PASS_THRU_MODE.AdapterId is also a target identifier,
-// consisting of 4 bytes. Make sure TARGET_MAX_BYTES can accomodate both
-// AdapterId and our target identifiers.
-//
-#if TARGET_MAX_BYTES < 4
-# error "virtio-scsi requires TARGET_MAX_BYTES >= 4"
-#endif
-
-
-#define VSCSI_SIG SIGNATURE_32 ('V', 'S', 'C', 'S')
-
-typedef struct {
- //
- // Parts of this structure are initialized / torn down in various functions
- // at various call depths. The table to the right should make it easier to
- // track them.
- //
- // field init function init depth
- // ---------------- ------------------ ----------
- UINT32 Signature; // DriverBindingStart 0
- VIRTIO_DEVICE_PROTOCOL *VirtIo; // DriverBindingStart 0
- BOOLEAN InOutSupported; // VirtioScsiInit 1
- UINT16 MaxTarget; // VirtioScsiInit 1
- UINT32 MaxLun; // VirtioScsiInit 1
- UINT32 MaxSectors; // VirtioScsiInit 1
- VRING Ring; // VirtioRingInit 2
- EFI_EXT_SCSI_PASS_THRU_PROTOCOL PassThru; // VirtioScsiInit 1
- EFI_EXT_SCSI_PASS_THRU_MODE PassThruMode; // VirtioScsiInit 1
-} VSCSI_DEV;
-
-#define VIRTIO_SCSI_FROM_PASS_THRU(PassThruPointer) \
- 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 6a36dca299..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 happend 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 <Library/XenHypercallLib.h>
-
-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 <IndustryStandard/Xen/event_channel.h>
-
-/**
- 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 <IndustryStandard/Xen/memory.h>
-
-#include <Library/XenHypercallLib.h>
-#include <Library/SynchronizationLib.h>
-
-#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 194275ba7e..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 <IndustryStandard/Xen/grant_table.h>
-
-/**
- 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 writen 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.<BR>
-
- This program and the accompanying materials
- are licensed and made available under the terms and conditions of the BSD License
- which accompanies this distribution. The full text of the license may be found at
- http://opensource.org/licenses/bsd-license.php
-
- 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 <Base.h>
-#include <Library/SynchronizationLib.h>
-
-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 <Library/PrintLib.h>
-
-#include "XenBus.h"
-#include "GrantTable.h"
-#include "XenStore.h"
-#include "EventChannel.h"
-
-#include <IndustryStandard/Xen/io/xenbus.h>
-
-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 <Library/DebugLib.h>
-#include <Library/XenHypercallLib.h>
-
-#include "XenBusDxe.h"
-
-#include "GrantTable.h"
-#include "XenStore.h"
-#include "XenBus.h"
-
-#include <IndustryStandard/Xen/hvm/params.h>
-#include <IndustryStandard/Xen/memory.h>
-
-///
-/// 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 <Uefi.h>
-
-//
-// Libraries
-//
-#include <Library/UefiBootServicesTableLib.h>
-#include <Library/MemoryAllocationLib.h>
-#include <Library/BaseMemoryLib.h>
-#include <Library/BaseLib.h>
-#include <Library/UefiLib.h>
-#include <Library/DevicePathLib.h>
-#include <Library/DebugLib.h>
-
-
-//
-// UEFI Driver Model Protocols
-//
-#include <Protocol/DriverBinding.h>
-
-
-//
-// Consumed Protocols
-//
-#include <Protocol/XenIo.h>
-
-
-//
-// Produced Protocols
-//
-#include <Protocol/XenBus.h>
-
-
-//
-// 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 <IndustryStandard/Xen/xen.h>
-
-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 f0c5db98b1..0000000000
--- a/OvmfPkg/XenBusDxe/XenBusDxe.inf
+++ /dev/null
@@ -1,66 +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
-
-[Protocols]
- gEfiDriverBindingProtocolGuid
- gEfiComponentName2ProtocolGuid
- gEfiComponentNameProtocolGuid
- gXenBusProtocolGuid
- gXenIoProtocolGuid
-
diff --git a/OvmfPkg/XenBusDxe/XenStore.c b/OvmfPkg/XenBusDxe/XenStore.c
deleted file mode 100644
index 61976f91f1..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 hierachy
- 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 <Library/PrintLib.h>
-
-#include <IndustryStandard/Xen/hvm/params.h>
-
-#include "EventChannel.h"
-#include <Library/XenHypercallLib.h>
-
-//
-// 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;
-
- /* +1 for '/' and +1 for '\0' */
- Buf = AllocateZeroPool (
- AsciiStrLen (DirectoryPath) + AsciiStrLen (Node) + 2);
- AsciiStrCat (Buf, DirectoryPath);
- if (Node[0] != '\0') {
- AsciiStrCat (Buf, "/");
- AsciiStrCat (Buf, 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" }
-};
-#define ARRAY_SIZE(x) (sizeof(x) / sizeof(x[0]))
-
-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);
- if (EFI_ERROR (Status)) {
- return Status;
- }
-
- 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];
-
- if (Abort) {
- AsciiStrCpy (AbortStr, "F");
- } else {
- AsciiStrCpy (AbortStr, "T");
- }
-
- return XenStoreSingle (Transaction, XS_TRANSACTION_END, AbortStr, NULL, NULL);
-}
-
-XENSTORE_STATUS
-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;
-
- BufSize = SPrintLengthAsciiFormat (FormatString, Marker) + 1;
- 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 de5690119e..0000000000
--- a/OvmfPkg/XenBusDxe/XenStore.h
+++ /dev/null
@@ -1,379 +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 <IndustryStandard/Xen/io/xs_wire.h>
-
-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
-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 supressed, 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 <DirectoryPath>/<Node>. If name
- is the NUL string, the returned value contains the path string
- <DirectoryPath>.
-
- @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 c205cf74db..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, Intel Corporation. All rights reserved.<BR>
- 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 <IndustryStandard/Acpi.h>
-#include <IndustryStandard/Pci.h>
-#include <Library/BaseMemoryLib.h>
-#include <Library/DebugLib.h>
-#include <Library/MemoryAllocationLib.h>
-#include <Library/UefiBootServicesTableLib.h>
-#include <Library/UefiLib.h>
-
-#include <Protocol/PciIo.h>
-#include <Protocol/XenIo.h>
-
-#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 Exeuction Environment) with the following service.
-
- See DriverBindingSupported() for specification references.
-
- @param[in] This The EFI_DRIVER_BINDING_PROTOCOL object
- incorporating this driver (independently of
- any device).
-
- @param[in] DeviceHandle The supported device to drive.
-
- @param[in] RemainingDevicePath Relevant only for bus drivers, ignored.
-
-
- @retval EFI_SUCCESS 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 256ac55f25..0000000000
--- a/OvmfPkg/XenPvBlkDxe/BlockFront.c
+++ /dev/null
@@ -1,643 +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.<BR>
-
- 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 <Library/PrintLib.h>
-#include <Library/DebugLib.h>
-
-#include "BlockFront.h"
-
-#include <IndustryStandard/Xen/io/protocols.h>
-#include <IndustryStandard/Xen/io/xenbus.h>
-
-/**
- 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;
-
- 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);
-
- 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 <IndustryStandard/Xen/event_channel.h>
-#include <IndustryStandard/Xen/io/blkif.h>
-
-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 ae6aa62ac0..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 durring %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 <Uefi.h>
-
-#define xen_mb() MemoryFence()
-#define xen_rmb() MemoryFence()
-#define xen_wmb() MemoryFence()
-
-//
-// Libraries
-//
-#include <Library/UefiBootServicesTableLib.h>
-#include <Library/MemoryAllocationLib.h>
-#include <Library/BaseMemoryLib.h>
-#include <Library/BaseLib.h>
-#include <Library/UefiLib.h>
-#include <Library/DevicePathLib.h>
-#include <Library/DebugLib.h>
-
-
-//
-// UEFI Driver Model Protocols
-//
-#include <Protocol/DriverBinding.h>
-#include <Protocol/ComponentName2.h>
-#include <Protocol/ComponentName.h>
-
-
-//
-// Consumed Protocols
-//
-#include <Protocol/XenBus.h>
-
-
-//
-// Produced Protocols
-//
-#include <Protocol/BlockIo.h>
-
-
-//
-// 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 8be7baacf3..0000000000
--- a/OvmfPkg/build.sh
+++ /dev/null
@@ -1,293 +0,0 @@
-#!/usr/bin/env bash
-#
-# Copyright (c) 2008 - 2009, Apple Inc. All rights reserved.<BR>
-# Copyright (c) 2010 - 2015, Intel Corporation. All rights reserved.<BR>
-#
-# This program and the accompanying materials
-# are licensed and made available under the terms and conditions of the BSD License
-# which accompanies this distribution. The full text of the license may be found at
-# http://opensource.org/licenses/bsd-license.php
-#
-# 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
- 4.5.*)
- TARGET_TOOLS=GCC45
- ;;
- 4.6.*)
- TARGET_TOOLS=GCC46
- ;;
- 4.7.*)
- TARGET_TOOLS=GCC47
- ;;
- 4.8.*)
- TARGET_TOOLS=GCC48
- ;;
- 4.9.*|4.1[0-9].*)
- TARGET_TOOLS=GCC49
- ;;
- *)
- TARGET_TOOLS=GCC44
- ;;
- 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 | tail -1 | awk '{print $4}')
- 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.<BR>
-#
-# This program and the accompanying materials
-# are licensed and made available under the terms and conditions of the BSD License
-# which accompanies this distribution. The full text of the license may be found at
-# http://opensource.org/licenses/bsd-license.php
-#
-# 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')
-
-