From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail-wm1-f48.google.com (mail-wm1-f48.google.com [209.85.128.48]) by mx.groups.io with SMTP id smtpd.web12.44005.1661558547720123791 for ; Fri, 26 Aug 2022 17:02:28 -0700 Authentication-Results: mx.groups.io; dkim=pass header.i=@gmail.com header.s=20210112 header.b=ApuQhE8u; spf=pass (domain: gmail.com, ip: 209.85.128.48, mailfrom: theojehl76@gmail.com) Received: by mail-wm1-f48.google.com with SMTP id i188-20020a1c3bc5000000b003a7b6ae4eb2so184493wma.4 for ; Fri, 26 Aug 2022 17:02:27 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc; bh=jm6NwVNjwQse1Su8QvL1LrrY0XAz8yP+2vNYnisnx2o=; b=ApuQhE8uHdjkHNpkHTWA56OMS8LDX4+HXPfL8Gw0YK0BQABCzAS7BhVz4aj02oWG3u N8MrG1r46KrBJMdukiauZYtqJ9NkcuHgAZWLdCN3uT6tpYxt0onmgDeqwHIlMEvgMnvk sBbX0448ctN52cewhizpw3U3W5LHh0MIswa76LsjSUz/bJv0WEou1x4Wo7M/tTuyhxBa WXfXqGyiwSZDuT3F87WOEKK82H+V+k/da2Gxduj7AGYmblR4wGA3b8TkElScHbXq4jMN eu8xj1B9W5YaWodr6cEfjO3eDDuuDyAMVAkkqFVed7aghmU1iPhtEXKkRFLkU/itzntS 4ESA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc; bh=jm6NwVNjwQse1Su8QvL1LrrY0XAz8yP+2vNYnisnx2o=; b=UyqPdOYQuw/fIFRkcx48i06oAuoFzBRi50Ze9L8wDtkYYSkNTnWyZ5Nll3YO0pDKT4 naTvQh+/PbrF+n20j1UDB7PF8EuHhFTSUdNxVuIs4avy8TdB5RrwIM5/n7IdeCb9ygvG LC1jAqsNQvLMgm7kTh+A0TjshyBRYER+3G8ZddVyS2NASaYXKUG/G54viVB8wbx2iVpo VTC8l4y+kf9+Wna29j/kCfHhrNxMiAzVkdMT3ytRDQoBPLkFjF/7E6EpYcdrW6FDSDDx vo+0LNHg89WU8Ggu38wtK5eK0CEApNEqP/gGer3qyCCR/SGvAMf4Zr4cdZ6HfihXWv3z 8tig== X-Gm-Message-State: ACgBeo1NfAvOzKF3NViPuXk6zkIPDmfV9zNhX5o1YBKcYch17MkU8NWB uwgl6dmr/QyqhqrajqDQXUufmDVmtKY5P0DI X-Google-Smtp-Source: AA6agR7oxUx7Yu9r4dbqsajrCDYzdlmXYaBdVk8t98ypiQES9lOtVhza52VKyUmPz7MW1U07N+Q6tA== X-Received: by 2002:a05:600c:19d3:b0:3a8:3b06:655a with SMTP id u19-20020a05600c19d300b003a83b06655amr241017wmq.182.1661558545321; Fri, 26 Aug 2022 17:02:25 -0700 (PDT) Return-Path: Received: from localhost.localdomain ([2a01:e0a:865:1370:e1d0:f0a4:99df:be44]) by smtp.gmail.com with ESMTPSA id a3-20020a05600c224300b003a6a3595edasm1043797wmm.27.2022.08.26.17.02.23 (version=TLS1_3 cipher=TLS_CHACHA20_POLY1305_SHA256 bits=256/256); Fri, 26 Aug 2022 17:02:24 -0700 (PDT) From: =?UTF-8?B?VGjDqW8gSmVobA==?= To: devel@edk2.groups.io Cc: Leif Lindholm , Michael D Kinney , Isaac Oram , Pedro Falcato , Gerd Hoffmann , Stefan Hajnoczi Subject: [edk2-platforms][PATCH v1 01/02] QemuOpenBoardPkg: Add QemuOpenBoardPkg Date: Sat, 27 Aug 2022 02:02:00 +0200 Message-Id: <20220827000201.22235-2-theojehl76@gmail.com> X-Mailer: git-send-email 2.32.1 (Apple Git-133) In-Reply-To: <20220827000201.22235-1-theojehl76@gmail.com> References: <20220827000201.22235-1-theojehl76@gmail.com> MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable From: Th=C3=A9o Jehl QemuOpenBoardPkg adds a MinPlatform port to Qemu x86_64 It can boots UEFI Linux and Windows, and works on PIIX4 and Q35 This board port provides a simple starting place for investigating edk2 and MinPlatform Arch. Currently we implement up to stage 4 of the MinPlatform spec and can boot Windows/Linux. Cc: Leif Lindholm Cc: Michael D Kinney Cc: Isaac Oram Cc: Pedro Falcato Cc: Gerd Hoffmann Cc: Stefan Hajnoczi Signed-off-by: Th=C3=A9o Jehl --- Platform/Qemu/QemuOpenBoardPkg/QemuOpenBoardPkg.dec = | 32 + Platform/Qemu/QemuOpenBoardPkg/Include/Dsc/Stage1.dsc.inc = | 55 ++ Platform/Qemu/QemuOpenBoardPkg/Include/Dsc/Stage2.dsc.inc = | 31 + Platform/Qemu/QemuOpenBoardPkg/Include/Dsc/Stage3.dsc.inc = | 100 +++ Platform/Qemu/QemuOpenBoardPkg/Include/Dsc/Stage4.dsc.inc = | 56 ++ Platform/Qemu/QemuOpenBoardPkg/QemuOpenBoardPkg.dsc = | 144 +++++ Platform/Qemu/QemuOpenBoardPkg/QemuOpenBoardPkg.fdf = | 313 ++++++++++ Platform/Qemu/QemuOpenBoardPkg/Library/BoardBootManagerLib/BoardBootManage= rLib.inf | 39 ++ Platform/Qemu/QemuOpenBoardPkg/Library/BoardInitLib/BoardInitLib.inf = | 29 + Platform/Qemu/QemuOpenBoardPkg/Library/OpenQemuFwCfgLib/OpenQemuFwCfgLib.i= nf | 23 + Platform/Qemu/QemuOpenBoardPkg/Library/PeiReportFvLib/PeiReportFvLib.inf = | 63 ++ Platform/Qemu/QemuOpenBoardPkg/Library/PlatformSecLib/PlatformSecLib.inf = | 49 ++ Platform/Qemu/QemuOpenBoardPkg/PlatformInitPei/PlatformInitPei.inf = | 59 ++ Platform/Qemu/QemuOpenBoardPkg/Include/Library/OpenQemuFwCfgLib.h = | 102 +++ Platform/Qemu/QemuOpenBoardPkg/PlatformInitPei/PlatformInit.h = | 59 ++ Platform/Qemu/QemuOpenBoardPkg/Library/BoardBootManagerLib/BoardBootManage= r.c | 105 ++++ Platform/Qemu/QemuOpenBoardPkg/Library/BoardInitLib/BoardInitLib.c = | 222 +++++++ Platform/Qemu/QemuOpenBoardPkg/Library/OpenQemuFwCfgLib/OpenQemuFwCfgLib.c= | 130 ++++ Platform/Qemu/QemuOpenBoardPkg/Library/PeiReportFvLib/PeiReportFvLib.c = | 285 +++++++++ Platform/Qemu/QemuOpenBoardPkg/Library/PlatformSecLib/PlatformSecLib.c = | 140 +++++ Platform/Qemu/QemuOpenBoardPkg/PlatformInitPei/Cpu.c = | 56 ++ Platform/Qemu/QemuOpenBoardPkg/PlatformInitPei/Memory.c = | 244 ++++++++ Platform/Qemu/QemuOpenBoardPkg/PlatformInitPei/Pci.c = | 59 ++ Platform/Qemu/QemuOpenBoardPkg/PlatformInitPei/Pcie.c = | 91 +++ Platform/Qemu/QemuOpenBoardPkg/PlatformInitPei/PlatformInit.c = | 67 ++ Platform/Qemu/QemuOpenBoardPkg/Include/Fdf/FlashMap.fdf.inc = | 85 +++ Platform/Qemu/QemuOpenBoardPkg/Library/PlatformSecLib/Ia32/SecEntry.nasm = | 117 ++++ Platform/Qemu/QemuOpenBoardPkg/README.md = | 53 ++ 28 files changed, 2808 insertions(+) diff --git a/Platform/Qemu/QemuOpenBoardPkg/QemuOpenBoardPkg.dec b/Platform= /Qemu/QemuOpenBoardPkg/QemuOpenBoardPkg.dec new file mode 100644 index 000000000000..3b5300a0c309 --- /dev/null +++ b/Platform/Qemu/QemuOpenBoardPkg/QemuOpenBoardPkg.dec @@ -0,0 +1,32 @@ +## @file QemuOpenBoardPkg.dec=0D +# Declaration file for QemuOpenBoardPkg.=0D +#=0D +# This package supports a simple QEMU port implemented per the MinPlatfor= m=0D +# Arch specification.=0D +#=0D +# Copyright (c) 2022 Th=C3=A9o Jehl=0D +# SPDX-License-Identifier: BSD-2-Clause-Patent=0D +#=0D +# @par Specification Reference:=0D +# -https://tianocore-docs.github.io/edk2-MinimumPlatformSpecification/dr= aft/ 0.7=0D +##=0D +=0D +[Defines]=0D + DEC_SPECIFICATION =3D 0x00010005=0D + PACKAGE_NAME =3D QemuOpenBoardPkg=0D + PACKAGE_GUID =3D 3487DE0A-6770-48A2-9833-FB426A42D7B2= =0D + PACKAGE_VERSION =3D 0.1=0D +=0D +[LibraryClasses]=0D + OpenQemuFwCfgLib|Include/Library/OpenQemuFwCfgLib.h=0D +=0D +[Includes]=0D + Include=0D +=0D +[Guids]=0D + gQemuOpenBoardPkgTokenSpaceGuid =3D { 0x221b20c4, 0x= a3dc, 0x4b8f, { 0xb6, 0x94, 0x03, 0xc7, 0xf4, 0x76, 0x51, 0x2b } }=0D +=0D +[PcdsFixedAtBuild]=0D + gQemuOpenBoardPkgTokenSpaceGuid.PcdTemporaryRamBase|0|UINT32|0x00000001= =0D + gQemuOpenBoardPkgTokenSpaceGuid.PcdTemporaryRamSize|0|UINT32|0x00000002= =0D + gQemuOpenBoardPkgTokenSpaceGuid.PcdDebugIoPort|0|UINT16|0x00000003=0D diff --git a/Platform/Qemu/QemuOpenBoardPkg/Include/Dsc/Stage1.dsc.inc b/Pl= atform/Qemu/QemuOpenBoardPkg/Include/Dsc/Stage1.dsc.inc new file mode 100644 index 000000000000..114c4e8193b2 --- /dev/null +++ b/Platform/Qemu/QemuOpenBoardPkg/Include/Dsc/Stage1.dsc.inc @@ -0,0 +1,55 @@ +## @file=0D +# Common DSC content to begin Stage 1 enabling=0D +#=0D +# @copyright=0D +# Copyright (C) 2022 Intel Corporation=0D +#=0D +# SPDX-License-Identifier: BSD-2-Clause-Patent=0D +##=0D +=0D +##########################################################################= ######=0D +#=0D +# Library Class section - list of all Library Classes needed by this Platf= orm.=0D +#=0D +##########################################################################= ######=0D +=0D +[LibraryClasses]=0D + PciSegmentInfoLib | MinPlatformPkg/Pci/Library/PciSegmentInfoLibSi= mple/PciSegmentInfoLibSimple.inf=0D + BoardInitLib | QemuOpenBoardPkg/Library/BoardInitLib/BoardIni= tLib.inf=0D + SetCacheMtrrLib | MinPlatformPkg/Library/SetCacheMtrrLib/SetCach= eMtrrLib.inf=0D + ReportCpuHobLib | MinPlatformPkg/PlatformInit/Library/ReportCpuH= obLib/ReportCpuHobLib.inf=0D + SiliconPolicyInitLib | MinPlatformPkg/PlatformInit/Library/SiliconPol= icyInitLibNull/SiliconPolicyInitLibNull.inf=0D + SiliconPolicyUpdateLib | MinPlatformPkg/PlatformInit/Library/SiliconPol= icyUpdateLibNull/SiliconPolicyUpdateLibNull.inf=0D + ReportFvLib | QemuOpenBoardPkg/Library/PeiReportFvLib/PeiRep= ortFvLib.inf=0D + PciLib | MdePkg/Library/BasePciLibCf8/BasePciLibCf8.inf= =0D +=0D +[LibraryClasses.Common.SEC]=0D + TestPointCheckLib | MinPlatformPkg/Test/Library/TestPointCheckLib/= SecTestPointCheckLib.inf=0D + TimerLib | MdePkg/Library/BaseTimerLibNullTemplate/BaseTi= merLibNullTemplate.inf=0D +=0D +[LibraryClasses.Common.PEI_CORE, LibraryClasses.Common.PEIM]=0D + TestPointCheckLib | MinPlatformPkg/Test/Library/TestPointCheckLib/= PeiTestPointCheckLib.inf=0D + TestPointLib | MinPlatformPkg/Test/Library/TestPointLib/PeiTe= stPointLib.inf=0D + TimerLib | MdePkg/Library/BaseTimerLibNullTemplate/BaseTi= merLibNullTemplate.inf=0D +=0D +[Components.$(PEI_ARCH)]=0D + UefiCpuPkg/SecCore/SecCore.inf=0D + MdeModulePkg/Core/Pei/PeiMain.inf=0D + MdeModulePkg/Universal/Variable/Pei/VariablePei.inf=0D + UefiCpuPkg/CpuIoPei/CpuIoPei.inf=0D + MdeModulePkg/Universal/PcatSingleSegmentPciCfg2Pei/PcatSingleSegmentPciC= fg2Pei.inf=0D + MdeModulePkg/Universal/FaultTolerantWritePei/FaultTolerantWritePei.inf=0D + MdeModulePkg/Universal/PCD/Pei/Pcd.inf {=0D + =0D + PcdLib | MdePkg/Library/BasePcdLibNull/BasePcdLibNull.inf=0D + }=0D + MdeModulePkg/Universal/ReportStatusCodeRouter/Pei/ReportStatusCodeRouter= Pei.inf=0D + MdeModulePkg/Universal/StatusCodeHandler/Pei/StatusCodeHandlerPei.inf=0D + MinPlatformPkg/PlatformInit/PlatformInitPei/PlatformInitPreMem.inf=0D + MinPlatformPkg/PlatformInit/ReportFv/ReportFvPei.inf=0D + MinPlatformPkg/PlatformInit/SiliconPolicyPei/SiliconPolicyPeiPreMem.inf= =0D + MdeModulePkg/Core/DxeIplPeim/DxeIpl.inf=0D + QemuOpenBoardPkg/PlatformInitPei/PlatformInitPei.inf=0D + !if $(SMM_REQUIRED) =3D=3D TRUE=0D + OvmfPkg/SmmAccess/SmmAccessPei.inf=0D + !endif=0D diff --git a/Platform/Qemu/QemuOpenBoardPkg/Include/Dsc/Stage2.dsc.inc b/Pl= atform/Qemu/QemuOpenBoardPkg/Include/Dsc/Stage2.dsc.inc new file mode 100644 index 000000000000..4b331c4ed1fc --- /dev/null +++ b/Platform/Qemu/QemuOpenBoardPkg/Include/Dsc/Stage2.dsc.inc @@ -0,0 +1,31 @@ +## @file=0D +# Common DSC content to begin Stage 2 enabling=0D +#=0D +# @copyright=0D +# Copyright (C) 2022 Jehl Th=C3=A9o=0D +#=0D +# SPDX-License-Identifier: BSD-2-Clause-Patent=0D +##=0D +=0D +[LibraryClasses.Common]=0D + ResetSystemLib | OvmfPkg/Library/ResetSystemLib/BaseResetSystem= Lib.inf=0D + PciHostBridgeLib | OvmfPkg/Library/PciHostBridgeLib/PciHostBridge= Lib.inf=0D + PciHostBridgeUtilityLib | OvmfPkg/Library/PciHostBridgeUtilityLib/PciHos= tBridgeUtilityLib.inf=0D + DxeHardwareInfoLib | OvmfPkg/Library/HardwareInfoLib/DxeHardwareInf= oLib.inf=0D +=0D +[LibraryClasses.Common.PEIM]=0D + MpInitLib | UefiCpuPkg/Library/MpInitLib/PeiMpInitLib.inf= =0D + TimerLib | OvmfPkg/Library/AcpiTimerLib/BaseAcpiTimerLib.= inf=0D +=0D +[LibraryClasses.Common.DXE_DRIVER, LibraryClasses.Common.DXE_RUNTIME_DRIVE= R, LibraryClasses.Common.DXE_SMM_DRIVER, LibraryClasses.Common.UEFI_DRIVER,= LibraryClasses.Common.UEFI_APPLICATION, LibraryClasses.Common.SMM_CORE]=0D + PciLib | OvmfPkg/Library/DxePciLibI440FxQ35/DxePciLibI4= 40FxQ35.inf=0D +=0D +[Components.$(PEI_ARCH)]=0D + UefiCpuPkg/CpuMpPei/CpuMpPei.inf=0D + MinPlatformPkg/PlatformInit/SiliconPolicyPei/SiliconPolicyPeiPostMem.inf= =0D + MinPlatformPkg/PlatformInit/PlatformInitPei/PlatformInitPostMem.inf=0D + MdeModulePkg/Core/DxeIplPeim/DxeIpl.inf=0D +=0D +[Components.$(DXE_ARCH)]=0D + MdeModulePkg/Universal/ResetSystemRuntimeDxe/ResetSystemRuntimeDxe.inf=0D + MdeModulePkg/Bus/Pci/PciHostBridgeDxe/PciHostBridgeDxe.inf=0D diff --git a/Platform/Qemu/QemuOpenBoardPkg/Include/Dsc/Stage3.dsc.inc b/Pl= atform/Qemu/QemuOpenBoardPkg/Include/Dsc/Stage3.dsc.inc new file mode 100644 index 000000000000..0435fb2da81d --- /dev/null +++ b/Platform/Qemu/QemuOpenBoardPkg/Include/Dsc/Stage3.dsc.inc @@ -0,0 +1,100 @@ +## @file=0D +# Common DSC content to begin Stage 3 enabling=0D +#=0D +# @copyright=0D +# Copyright (C) 2022 Jehl Th=C3=A9o=0D +#=0D +# SPDX-License-Identifier: BSD-2-Clause-Patent=0D +##=0D +=0D +[LibraryClasses.Common]=0D + PlatformBootManagerLib | OvmfPkg/Library/PlatformBootManagerLib/Platfor= mBootManagerLib.inf=0D + BootLogoLib | MdeModulePkg/Library/BootLogoLib/BootLogoLib.i= nf=0D + NvVarsFileLib | OvmfPkg/Library/NvVarsFileLib/NvVarsFileLib.in= f=0D + QemuFwCfgS3Lib | OvmfPkg/Library/QemuFwCfgS3Lib/DxeQemuFwCfgS3L= ibFwCfg.inf=0D + QemuLoadImageLib | OvmfPkg/Library/X86QemuLoadImageLib/X86QemuLoa= dImageLib.inf=0D + QemuBootOrderLib | OvmfPkg/Library/QemuBootOrderLib/QemuBootOrder= Lib.inf=0D + PlatformBmPrintScLib | OvmfPkg/Library/PlatformBmPrintScLib/PlatformB= mPrintScLib.inf=0D + XenPlatformLib | OvmfPkg/Library/XenPlatformLib/XenPlatformLib.= inf=0D + LoadLinuxLib | OvmfPkg/Library/LoadLinuxLib/LoadLinuxLib.inf= =0D + SerializeVariablesLib | OvmfPkg/Library/SerializeVariablesLib/Serializ= eVariablesLib.inf=0D + BoardBootManagerLib | QemuOpenBoardPkg/Library/BoardBootManagerLib/B= oardBootManagerLib.inf=0D + LocalApicLib | UefiCpuPkg/Library/BaseXApicX2ApicLib/BaseXApi= cX2ApicLib.inf=0D + IoLib | MdePkg/Library/BaseIoLibIntrinsic/BaseIoLibInt= rinsic.inf=0D + PciExpressLib | MdePkg/Library/BasePciExpressLib/BasePciExpres= sLib.inf=0D + PcdLib | MdePkg/Library/DxePcdLib/DxePcdLib.inf=0D + PciLib | MdePkg/Library/BasePciLibCf8/BasePciLibCf8.inf= =0D + DebugLib | MdePkg/Library/BaseDebugLibSerialPort/BaseDebu= gLibSerialPort.inf=0D + SerialPortLib | PcAtChipsetPkg/Library/SerialIoLib/SerialIoLib= .inf=0D +=0D +[Components.$(DXE_ARCH)]=0D + MdeModulePkg/Core/Dxe/DxeMain.inf {=0D + =0D + NULL|MdeModulePkg/Library/LzmaCustomDecompressLib/LzmaCustomDecompre= ssLib.inf=0D + }=0D + MdeModulePkg/Universal/PCD/Dxe/Pcd.inf {=0D + =0D + PcdLib | MdePkg/Library/BasePcdLibNull/BasePcdLibNull.inf=0D + }=0D + MdeModulePkg/Universal/ReportStatusCodeRouter/RuntimeDxe/ReportStatusCod= eRouterRuntimeDxe.inf=0D + MdeModulePkg/Universal/StatusCodeHandler/RuntimeDxe/StatusCodeHandlerRun= timeDxe.inf=0D + MdeModulePkg/Universal/Metronome/Metronome.inf=0D + MdeModulePkg/Universal/WatchdogTimerDxe/WatchdogTimer.inf=0D + PcAtChipsetPkg/PcatRealTimeClockRuntimeDxe/PcatRealTimeClockRuntimeDxe.i= nf=0D + MdeModulePkg/Core/RuntimeDxe/RuntimeDxe.inf=0D + MdeModulePkg/Universal/Variable/RuntimeDxe/VariableRuntimeDxe.inf=0D + MdeModulePkg/Universal/MonotonicCounterRuntimeDxe/MonotonicCounterRuntim= eDxe.inf=0D + MdeModulePkg/Universal/BdsDxe/BdsDxe.inf=0D + MdeModulePkg/Universal/Console/TerminalDxe/TerminalDxe.inf=0D + MdeModulePkg/Universal/SecurityStubDxe/SecurityStubDxe.inf=0D + MdeModulePkg/Universal/CapsuleRuntimeDxe/CapsuleRuntimeDxe.inf=0D + UefiCpuPkg/CpuDxe/CpuDxe.inf=0D + PcAtChipsetPkg/HpetTimerDxe/HpetTimerDxe.inf=0D + MdeModulePkg/Bus/Pci/PciBusDxe/PciBusDxe.inf=0D + MdeModulePkg/Universal/Disk/UnicodeCollation/EnglishDxe/EnglishDxe.inf=0D + MdeModulePkg/Universal/Console/GraphicsOutputDxe/GraphicsOutputDxe.inf=0D + MdeModulePkg/Universal/Console/GraphicsConsoleDxe/GraphicsConsoleDxe.inf= =0D + MdeModulePkg/Universal/Console/ConSplitterDxe/ConSplitterDxe.inf=0D + MdeModulePkg/Universal/Console/ConPlatformDxe/ConPlatformDxe.inf=0D + MdeModulePkg/Universal/DevicePathDxe/DevicePathDxe.inf=0D + MdeModulePkg/Universal/HiiDatabaseDxe/HiiDatabaseDxe.inf=0D + UefiCpuPkg/CpuIo2Dxe/CpuIo2Dxe.inf=0D + OvmfPkg/QemuVideoDxe/QemuVideoDxe.inf=0D + MdeModulePkg/Universal/SerialDxe/SerialDxe.inf=0D + MdeModulePkg/Universal/DisplayEngineDxe/DisplayEngineDxe.inf=0D + MdeModulePkg/Bus/Isa/IsaBusDxe/IsaBusDxe.inf=0D + MdeModulePkg/Bus/Isa/Ps2KeyboardDxe/Ps2KeyboardDxe.inf=0D + MdeModulePkg/Universal/DevicePathDxe/DevicePathDxe.inf=0D + MdeModulePkg/Universal/Disk/DiskIoDxe/DiskIoDxe.inf=0D + PcAtChipsetPkg/Bus/Pci/IdeControllerDxe/IdeControllerDxe.inf=0D + MdeModulePkg/Universal/Disk/PartitionDxe/PartitionDxe.inf=0D + FatPkg/EnhancedFatDxe/Fat.inf=0D + OvmfPkg/QemuRamfbDxe/QemuRamfbDxe.inf=0D +=0D + ShellPkg/Application/Shell/Shell.inf {=0D + =0D + ShellCommandLib | ShellPkg/Library/UefiShellCommandLib/UefiShellComm= andLib.inf=0D + NULL | ShellPkg/Library/UefiShellLevel2CommandsLib/UefiShellLevel2Co= mmandsLib.inf=0D + NULL | ShellPkg/Library/UefiShellLevel1CommandsLib/UefiShellLevel1Co= mmandsLib.inf=0D + NULL | ShellPkg/Library/UefiShellLevel3CommandsLib/UefiShellLevel3Co= mmandsLib.inf=0D + NULL | ShellPkg/Library/UefiShellDriver1CommandsLib/UefiShellDriver1= CommandsLib.inf=0D + NULL | ShellPkg/Library/UefiShellDebug1CommandsLib/UefiShellDebug1Co= mmandsLib.inf=0D + NULL | ShellPkg/Library/UefiShellInstall1CommandsLib/UefiShellInstal= l1CommandsLib.inf=0D + NULL | ShellPkg/Library/UefiShellNetwork1CommandsLib/UefiShellNetwor= k1CommandsLib.inf=0D + HandleParsingLib | ShellPkg/Library/UefiHandleParsingLib/UefiHandleP= arsingLib.inf=0D + PrintLib | MdePkg/Library/BasePrintLib/BasePrintLib.inf=0D + BcfgCommandLib | ShellPkg/Library/UefiShellBcfgCommandLib/UefiShellB= cfgCommandLib.inf=0D + =0D + gEfiMdePkgTokenSpaceGuid.PcdDebugPropertyMask | 0xFF=0D + gEfiShellPkgTokenSpaceGuid.PcdShellLibAutoInitialize | FALSE=0D + gEfiMdePkgTokenSpaceGuid.PcdUefiLibMaxPrintBufferSize | 8000=0D + }=0D +=0D + MdeModulePkg/Universal/SetupBrowserDxe/SetupBrowserDxe.inf=0D + OvmfPkg/PlatformDxe/Platform.inf=0D + MdeModulePkg/Application/BootManagerMenuApp/BootManagerMenuApp.inf=0D + MdeModulePkg/Application/UiApp/UiApp.inf=0D + OvmfPkg/IoMmuDxe/IoMmuDxe.inf=0D + MdeModulePkg/Universal/Acpi/S3SaveStateDxe/S3SaveStateDxe.inf=0D + OvmfPkg/SioBusDxe/SioBusDxe.inf=0D + MdeModulePkg/Bus/Pci/PciSioSerialDxe/PciSioSerialDxe.inf=0D diff --git a/Platform/Qemu/QemuOpenBoardPkg/Include/Dsc/Stage4.dsc.inc b/Pl= atform/Qemu/QemuOpenBoardPkg/Include/Dsc/Stage4.dsc.inc new file mode 100644 index 000000000000..4a1f9c7d0124 --- /dev/null +++ b/Platform/Qemu/QemuOpenBoardPkg/Include/Dsc/Stage4.dsc.inc @@ -0,0 +1,56 @@ +## @file=0D +# Common DSC content to begin Stage 4 enabling=0D +#=0D +# @copyright=0D +# Copyright (C) 2022 Jehl Th=C3=A9o=0D +#=0D +# SPDX-License-Identifier: BSD-2-Clause-Patent=0D +##=0D +=0D +=0D +[LibraryClasses]=0D + !if $(SMM_REQUIRED) =3D=3D TRUE=0D + SpiFlashCommonLib | IntelSiliconPkg/Library/SmmSpiFlashCommonLib/S= mmSpiFlashCommonLib.inf=0D + !endif=0D +=0D +[LibraryClasses.Common.DXE_SMM_DRIVER]=0D + LockBoxLib | MdeModulePkg/Library/SmmLockBoxLib/SmmLockBoxS= mmLib.inf=0D + SmmCpuPlatformHookLib | OvmfPkg/Library/SmmCpuPlatformHookLibQemu/SmmC= puPlatformHookLibQemu.inf=0D + SmmCpuFeaturesLib | OvmfPkg/Library/SmmCpuFeaturesLib/SmmCpuFeatur= esLib.inf=0D +=0D +[Components.$(DXE_ARCH)]=0D + OvmfPkg/AcpiPlatformDxe/AcpiPlatformDxe.inf=0D + MdeModulePkg/Universal/Acpi/AcpiTableDxe/AcpiTableDxe.inf=0D + OvmfPkg/SataControllerDxe/SataControllerDxe.inf=0D + MdeModulePkg/Bus/Ata/AtaAtapiPassThru/AtaAtapiPassThru.inf=0D + MdeModulePkg/Bus/Ata/AtaBusDxe/AtaBusDxe.inf=0D + MdeModulePkg/Bus/Pci/UhciDxe/UhciDxe.inf=0D + MdeModulePkg/Bus/Pci/EhciDxe/EhciDxe.inf=0D + MdeModulePkg/Bus/Pci/XhciDxe/XhciDxe.inf=0D + MdeModulePkg/Bus/Usb/UsbBusDxe/UsbBusDxe.inf=0D + MdeModulePkg/Bus/Usb/UsbKbDxe/UsbKbDxe.inf=0D +=0D + !if $(SMM_REQUIRED) =3D=3D TRUE=0D + OvmfPkg/SmmAccess/SmmAccess2Dxe.inf=0D + OvmfPkg/SmmControl2Dxe/SmmControl2Dxe.inf=0D + MdeModulePkg/Core/PiSmmCore/PiSmmIpl.inf=0D + MdeModulePkg/Core/PiSmmCore/PiSmmCore.inf=0D +=0D + MdeModulePkg/Universal/LockBox/SmmLockBox/SmmLockBox.inf=0D + UefiCpuPkg/PiSmmCpuDxeSmm/PiSmmCpuDxeSmm.inf=0D +=0D + MdeModulePkg/Universal/ReportStatusCodeRouter/Smm/ReportStatusCodeRout= erSmm.inf=0D + MdeModulePkg/Universal/StatusCodeHandler/Smm/StatusCodeHandlerSmm.inf= =0D + UefiCpuPkg/CpuIo2Smm/CpuIo2Smm.inf=0D + MdeModulePkg/Universal/FaultTolerantWriteDxe/FaultTolerantWriteSmm.inf= =0D + IntelSiliconPkg/Feature/Flash/SpiFvbService/SpiFvbServiceSmm.inf=0D + !endif=0D +=0D + #=0D + # SMBIOS Support=0D + #=0D + MdeModulePkg/Universal/SmbiosDxe/SmbiosDxe.inf {=0D + =0D + NULL | OvmfPkg/Library/SmbiosVersionLib/DetectSmbiosVersionLib.inf=0D + }=0D + OvmfPkg/SmbiosPlatformDxe/SmbiosPlatformDxe.inf=0D diff --git a/Platform/Qemu/QemuOpenBoardPkg/QemuOpenBoardPkg.dsc b/Platform= /Qemu/QemuOpenBoardPkg/QemuOpenBoardPkg.dsc new file mode 100644 index 000000000000..958d6b9537c9 --- /dev/null +++ b/Platform/Qemu/QemuOpenBoardPkg/QemuOpenBoardPkg.dsc @@ -0,0 +1,144 @@ +## @file=0D +# QemuOpenBoardPkg.dsc=0D +#=0D +# Description file for QemuOpenBoardPkg=0D +#=0D +# Copyright (c) 2022 Th=C3=A9o Jehl=0D +# SPDX-License-Identifier: BSD-2-Clause-Patent=0D +##=0D +=0D +[Defines]=0D + DSC_SPECIFICATION =3D 0x0001001C=0D + PLATFORM_GUID =3D 94797875-D562-40CF-8D55-ADD623C8D46C=0D + PLATFORM_NAME =3D QemuOpenBoardPkg=0D + PLATFORM_VERSION =3D 0.1=0D + SUPPORTED_ARCHITECTURES =3D IA32 | X64=0D + FLASH_DEFINITION =3D $(PLATFORM_NAME)/$(PLATFORM_NAME).fdf=0D + OUTPUT_DIRECTORY =3D Build/$(PLATFORM_NAME)=0D + BUILD_TARGETS =3D DEBUG | RELEASE | NOOPT=0D + SKUID_IDENTIFIER =3D ALL=0D + SMM_REQUIRED =3D FALSE=0D +=0D +!ifndef $(PEI_ARCH)=0D + !error "PEI_ARCH must be specified to build this feature!"=0D +!endif=0D +!ifndef $(DXE_ARCH)=0D + !error "DXE_ARCH must be specified to build this feature!"=0D +!endif=0D +=0D +[SkuIds]=0D + 0 | DEFAULT=0D +=0D +[Packages]=0D + MdePkg/MdePkg.dec=0D + MdeModulePkg/MdeModulePkg.dec=0D + MinPlatformPkg/MinPlatformPkg.dec=0D + QemuOpenBoardPkg/QemuOpenBoardPkg.dec=0D + UefiCpuPkg/UefiCpuPkg.dec=0D +=0D +[PcdsFixedAtBuild]=0D + gMinPlatformPkgTokenSpaceGuid.PcdBootStage | 4=0D +=0D + gEfiMdePkgTokenSpaceGuid.PcdDebugPrintErrorLevel | 0x802A00C7=0D + gEfiMdePkgTokenSpaceGuid.PcdFixedDebugPrintErrorLevel | 0x802A00C7=0D + gEfiMdePkgTokenSpaceGuid.PcdDebugPropertyMask | 0x17=0D +=0D + # QEMU "memory" is functional even in SEC. For simplicity, we just use = that=0D + # "memory" for the temporary RAM=0D + gQemuOpenBoardPkgTokenSpaceGuid.PcdTemporaryRamBase | 0x1000000=0D + gQemuOpenBoardPkgTokenSpaceGuid.PcdTemporaryRamSize | 0x010000=0D +=0D + gQemuOpenBoardPkgTokenSpaceGuid.PcdDebugIoPort | 0x402=0D + gEfiMdePkgTokenSpaceGuid.PcdFSBClock | 100000000=0D + gEfiMdePkgTokenSpaceGuid.PcdPciExpressBaseAddress | 0xB0000000=0D +=0D + gEfiMdeModulePkgTokenSpaceGuid.PcdEmuVariableNvModeEnable | = TRUE=0D + gEfiMdeModulePkgTokenSpaceGuid.PcdResetOnMemoryTypeInformationChange | = FALSE=0D +=0D + gMinPlatformPkgTokenSpaceGuid.PcdFlashFvFspMBase | 0x00000000 # Will be = updated by build=0D +=0D +[PcdsFeatureFlag]=0D + gMinPlatformPkgTokenSpaceGuid.PcdSmiHandlerProfileEnable | TRUE=0D + gMinPlatformPkgTokenSpaceGuid.PcdUefiSecureBootEnable | FALSE=0D + gMinPlatformPkgTokenSpaceGuid.PcdPerformanceEnable | FALSE=0D + gEfiMdeModulePkgTokenSpaceGuid.PcdDxeIplSupportUefiDecompress|TRUE=0D +=0D + !if $(DXE_ARCH) =3D=3D X64=0D + gEfiMdeModulePkgTokenSpaceGuid.PcdDxeIplSwitchToLongMode | TRUE=0D + !else=0D + gEfiMdeModulePkgTokenSpaceGuid.PcdDxeIplSwitchToLongMode | FALSE=0D + !endif=0D +=0D + gMinPlatformPkgTokenSpaceGuid.PcdBootToShellOnly | TRUE=0D + gMinPlatformPkgTokenSpaceGuid.PcdSerialTerminalEnable | TRUE=0D + gMinPlatformPkgTokenSpaceGuid.PcdTpm2Enable | FALSE=0D +=0D + !if $(SMM_REQUIRED) =3D=3D TRUE=0D + gUefiOvmfPkgTokenSpaceGuid.PcdSmmSmramRequire | TRUE=0D + gUefiCpuPkgTokenSpaceGuid.PcdCpuHotPlugSupport | FALSE= =0D + gEfiMdeModulePkgTokenSpaceGuid.PcdEnableVariableRuntimeCache | FALSE= =0D + !endif=0D +=0D +[PcdsDynamicDefault]=0D + gUefiOvmfPkgTokenSpaceGuid.PcdOvmfHostBridgePciDevId | 0=0D +=0D + # Video setup=0D + gEfiMdeModulePkgTokenSpaceGuid.PcdSetupVideoHorizontalResolution | 640= =0D + gEfiMdeModulePkgTokenSpaceGuid.PcdSetupVideoVerticalResolution | 480= =0D +=0D + gEfiMdeModulePkgTokenSpaceGuid.PcdSmbiosVersion | 0x0208=0D + gEfiMdeModulePkgTokenSpaceGuid.PcdSmbiosDocRev | 0x0=0D +=0D + gEfiMdePkgTokenSpaceGuid.PcdPlatformBootTimeOut | 3=0D +=0D + gUefiCpuPkgTokenSpaceGuid.PcdCpuMaxLogicalProcessorNumber | 0=0D + gUefiCpuPkgTokenSpaceGuid.PcdCpuBootLogicalProcessorNumber | 0=0D +=0D + !if $(SMM_REQUIRED) =3D=3D TRUE=0D + gUefiOvmfPkgTokenSpaceGuid.PcdQ35TsegMbytes | 8=0D + gUefiOvmfPkgTokenSpaceGuid.PcdQ35SmramAtDefaultSmbase | FALSE=0D + gUefiCpuPkgTokenSpaceGuid.PcdCpuSmmSyncMode | 0x01=0D + gUefiCpuPkgTokenSpaceGuid.PcdCpuSmmApSyncTimeout | 100000=0D + !endif=0D +=0D +# Include Common libraries and then stage specific libraries and component= s=0D +!include MinPlatformPkg/Include/Dsc/CoreCommonLib.dsc=0D +!include MinPlatformPkg/Include/Dsc/CorePeiLib.dsc=0D +!include MinPlatformPkg/Include/Dsc/CoreDxeLib.dsc=0D +!include QemuOpenBoardPkg/Include/Dsc/Stage1.dsc.inc=0D +!include QemuOpenBoardPkg/Include/Dsc/Stage2.dsc.inc=0D +!include QemuOpenBoardPkg/Include/Dsc/Stage3.dsc.inc=0D +!include QemuOpenBoardPkg/Include/Dsc/Stage4.dsc.inc=0D +=0D +[LibraryClasses.Common]=0D + OpenQemuFwCfgLib | QemuOpenBoardPkg/Library/OpenQemuFwCfgLib/Open= QemuFwCfgLib.inf=0D + PlatformHookLib | MdeModulePkg/Library/BasePlatformHookLibNull/B= asePlatformHookLibNull.inf=0D + PlatformSecLib | QemuOpenBoardPkg/Library/PlatformSecLib/Platfo= rmSecLib.inf=0D + DebugLib | MdePkg/Library/BaseDebugLibSerialPort/BaseDebu= gLibSerialPort.inf=0D + PciCf8Lib | MdePkg/Library/BasePciCf8Lib/BasePciCf8Lib.inf= =0D + TimerLib | OvmfPkg/Library/AcpiTimerLib/BaseAcpiTimerLib.= inf=0D +=0D +[LibraryClasses.Common.DXE_CORE]=0D + TimerLib | OvmfPkg/Library/AcpiTimerLib/BaseAcpiTimerLib.= inf=0D +=0D +[LibraryClasses.Common.DXE_DRIVER, LibraryClasses.Common.DXE_RUNTIME_DRIVE= R, LibraryClasses.Common.DXE_SMM_DRIVER, LibraryClasses.Common.UEFI_DRIVER,= LibraryClasses.Common.UEFI_APPLICATION, LibraryClasses.Common.SMM_CORE]=0D + TimerLib | OvmfPkg/Library/AcpiTimerLib/DxeAcpiTimerLib.i= nf=0D + QemuFwCfgLib | OvmfPkg/Library/QemuFwCfgLib/QemuFwCfgDxeLib.i= nf=0D + MemEncryptSevLib | OvmfPkg/Library/BaseMemEncryptSevLib/DxeMemEnc= ryptSevLib.inf=0D + MemEncryptTdxLib | OvmfPkg/Library/BaseMemEncryptTdxLib/BaseMemEn= cryptTdxLibNull.inf=0D + Tcg2PhysicalPresenceLib | OvmfPkg/Library/Tcg2PhysicalPresenceLibNull/Dx= eTcg2PhysicalPresenceLib.inf=0D + ResetSystemLib | OvmfPkg/Library/ResetSystemLib/DxeResetSystemL= ib.inf=0D +=0D +[LibraryClasses.Common.SEC]=0D + DebugLib | OvmfPkg/Library/PlatformDebugLibIoPort/PlatformRomDebugLibIoP= ort.inf=0D +=0D +[Components.$(DXE_ARCH)]=0D + MdeModulePkg/Bus/Scsi/ScsiBusDxe/ScsiBusDxe.inf=0D + MdeModulePkg/Bus/Scsi/ScsiDiskDxe/ScsiDiskDxe.inf=0D + OvmfPkg/SataControllerDxe/SataControllerDxe.inf=0D + MdeModulePkg/Bus/Ata/AtaAtapiPassThru/AtaAtapiPassThru.inf=0D + MdeModulePkg/Bus/Ata/AtaBusDxe/AtaBusDxe.inf=0D + MdeModulePkg/Bus/Pci/NvmExpressDxe/NvmExpressDxe.inf=0D + MdeModulePkg/Universal/DevicePathDxe/DevicePathDxe.inf=0D + MdeModulePkg/Universal/Disk/DiskIoDxe/DiskIoDxe.inf=0D + MdeModulePkg/Universal/Disk/PartitionDxe/PartitionDxe.inf=0D diff --git a/Platform/Qemu/QemuOpenBoardPkg/QemuOpenBoardPkg.fdf b/Platform= /Qemu/QemuOpenBoardPkg/QemuOpenBoardPkg.fdf new file mode 100644 index 000000000000..2f39ce3860f6 --- /dev/null +++ b/Platform/Qemu/QemuOpenBoardPkg/QemuOpenBoardPkg.fdf @@ -0,0 +1,313 @@ +## @file=0D +# QemuOpenBoardPkg.fdf=0D +#=0D +# Copyright (c) 2022 Th=C3=A9o Jehl=0D +# SPDX-License-Identifier: BSD-2-Clause-Patent=0D +=0D +SET gMinPlatformPkgTokenSpaceGuid.PcdFlashAreaBaseAddress =3D 0xFF800= 000=0D +SET gMinPlatformPkgTokenSpaceGuid.PcdFlashAreaSize =3D 0x80000= 0=0D +=0D +!include QemuOpenBoardPkg/Include/Fdf/FlashMap.fdf.inc=0D +=0D +[FD.QemuOpenBoardPkg]=0D + BaseAddress =3D 0xFF800000=0D + Size =3D 0x800000=0D + ErasePolarity =3D 1=0D + BlockSize =3D 0x1000=0D + NumBlocks =3D 0x800=0D +=0D + #=0D + # Do not modify this block=0D + # These three areas are tightly coupled and should be modified with utmo= st care.=0D + # The total size must match the size in the EFI_FIRMWARE_VOLUME_HEADER i= n NvStorage512K.fdf.=0D + # The NvStorageVariableSize must also match the VARIABLE_STORE_HEADER si= ze in NvStorage512K.fdf.=0D + # The EFI_FAULT_TOLERANT_WORKING_BLOCK_HEADER in CommonNvStorageFtwWorki= ng.fdf doesn't have size info.=0D + #=0D + gMinPlatformPkgTokenSpaceGuid.PcdFlashNvStorageVariableOffset | gEfiMdeM= odulePkgTokenSpaceGuid.PcdFlashNvStorageVariableSize=0D + !include WhitleyOpenBoardPkg/Include/Fdf/NvStorage512K.fdf=0D + gMinPlatformPkgTokenSpaceGuid.PcdFlashNvStorageFtwWorkingOffset | gEfiMd= eModulePkgTokenSpaceGuid.PcdFlashNvStorageFtwWorkingSize=0D + !include WhitleyOpenBoardPkg/Include/Fdf/CommonNvStorageFtwWorking.fdf=0D + gMinPlatformPkgTokenSpaceGuid.PcdFlashNvStorageFtwSpareOffset | gEfiMdeM= odulePkgTokenSpaceGuid.PcdFlashNvStorageFtwSpareSize=0D + DATA =3D { 0xFF } # Hack to ensure build doesn't treat the next PCD as B= ase/Size to be written=0D +=0D + gMinPlatformPkgTokenSpaceGuid.PcdFlashFvAdvancedOffset | gMinPlatformPkg= TokenSpaceGuid.PcdFlashFvAdvancedSize=0D + FV =3D FvAdvanced=0D +=0D + gMinPlatformPkgTokenSpaceGuid.PcdFlashFvSecurityOffset | gMinPlatformPkg= TokenSpaceGuid.PcdFlashFvSecuritySize=0D + FV =3D FvSecurity=0D +=0D + gMinPlatformPkgTokenSpaceGuid.PcdFlashFvOsBootOffset | gMinPlatformPkgTo= kenSpaceGuid.PcdFlashFvOsBootSize=0D + FV =3D FvOsBoot=0D +=0D + gMinPlatformPkgTokenSpaceGuid.PcdFlashFvUefiBootOffset | gMinPlatformPkg= TokenSpaceGuid.PcdFlashFvUefiBootSize=0D + FV =3D FvUefiBoot=0D +=0D + gMinPlatformPkgTokenSpaceGuid.PcdFlashFvBspOffset | gMinPlatformPkgToken= SpaceGuid.PcdFlashFvBspSize=0D + FV =3D FvBsp=0D +=0D + gMinPlatformPkgTokenSpaceGuid.PcdFlashFvPostMemoryOffset | gMinPlatformP= kgTokenSpaceGuid.PcdFlashFvPostMemorySize=0D + FV =3D FvPostMemory=0D +=0D + gMinPlatformPkgTokenSpaceGuid.PcdFlashFvFspSOffset | gMinPlatformPkgToke= nSpaceGuid.PcdFlashFvFspSSize=0D + FV =3D FvFspS=0D +=0D + gMinPlatformPkgTokenSpaceGuid.PcdFlashFvFspMOffset | gMinPlatformPkgToke= nSpaceGuid.PcdFlashFvFspMSize=0D + FV =3D FvFspM=0D +=0D + gMinPlatformPkgTokenSpaceGuid.PcdFlashFvFspTOffset | gMinPlatformPkgToke= nSpaceGuid.PcdFlashFvFspTSize=0D + FV =3D FvFspT=0D +=0D + gMinPlatformPkgTokenSpaceGuid.PcdFlashFvBspPreMemoryOffset | gMinPlatfor= mPkgTokenSpaceGuid.PcdFlashFvBspPreMemorySize=0D + FV =3D FvBspPreMemory=0D +=0D + gMinPlatformPkgTokenSpaceGuid.PcdFlashFvPreMemoryOffset | gMinPlatformPk= gTokenSpaceGuid.PcdFlashFvPreMemorySize=0D + FV =3D FvPreMemory=0D +=0D +###########################=0D +#=0D +# Stage 1 Firmware Volumes=0D +#=0D +###########################=0D +=0D +[FV.FvPreMemory]=0D + !include MinPlatformPkg/Include/Fdf/CommonSpiFvHeaderInfo.fdf=0D + FvNameGuid =3D BD479C6B-2EFF-401F-A7F1-566347B41D07=0D +=0D + FILE FV_IMAGE =3D 618FBA00-2231-41F6-9931-25A89DF501D3 {=0D + SECTION FV_IMAGE =3D FvSecurityPreMemory=0D + }=0D +=0D + INF MdeModulePkg/Universal/PCD/Pei/Pcd.inf=0D +=0D + INF MdeModulePkg/Universal/ReportStatusCodeRouter/Pei/ReportStatusCodeRo= uterPei.inf=0D + INF MinPlatformPkg/PlatformInit/ReportFv/ReportFvPei.inf=0D +=0D + INF MdeModulePkg/Universal/FaultTolerantWritePei/FaultTolerantWritePei.i= nf=0D + INF MdeModulePkg/Universal/Variable/Pei/VariablePei.inf=0D +=0D + INF UefiCpuPkg/SecCore/SecCore.inf=0D +=0D +[FV.FvSecurityPreMemory]=0D + !include MinPlatformPkg/Include/Fdf/CommonSpiFvHeaderInfo.fdf=0D + FvNameGuid =3D F626B0FB-D759-44A8-B131-42408BB3533D=0D +=0D +[FV.FvBspPreMemory]=0D + !include MinPlatformPkg/Include/Fdf/CommonSpiFvHeaderInfo.fdf=0D + FvNameGuid =3D 5CF9C072-385F-44FC-B21B-002074251C08=0D +=0D + INF MdeModulePkg/Universal/StatusCodeHandler/Pei/StatusCodeHandlerPei.in= f=0D + INF MinPlatformPkg/PlatformInit/PlatformInitPei/PlatformInitPreMem.inf=0D + INF QemuOpenBoardPkg/PlatformInitPei/PlatformInitPei.inf=0D +=0D + FILE FV_IMAGE =3D 90B948EA-FF73-4689-B90A-A54F86C1FC01 {=0D + SECTION FV_IMAGE =3D FvAdvancedPreMemory=0D + }=0D +=0D +[FV.FvAdvancedPreMemory]=0D + !include MinPlatformPkg/Include/Fdf/CommonSpiFvHeaderInfo.fdf=0D + FvNameGuid =3D 43528CE0-812B-4074-B77E-C49E7A2F4FE1=0D +=0D +[FV.FvFspT]=0D + !include MinPlatformPkg/Include/Fdf/CommonSpiFvHeaderInfo.fdf=0D + FvNameGuid =3D 958CAF39-0B6C-40F1-B190-EC91C536CFF9=0D +=0D +[FV.FvFspM]=0D + !include MinPlatformPkg/Include/Fdf/CommonSpiFvHeaderInfo.fdf=0D + FvNameGuid =3D 03982cf7-246a-4356-b6ba-436a2251595c=0D +=0D + INF MdeModulePkg/Core/Pei/PeiMain.inf=0D +=0D + FILE FV_IMAGE =3D 83B39C64-BFB9-42EC-A7A3-527854A5C4C3 {=0D + SECTION FV_IMAGE =3D FvPreMemorySilicon=0D + }=0D +=0D +[FV.FvPreMemorySilicon]=0D + !include MinPlatformPkg/Include/Fdf/CommonSpiFvHeaderInfo.fdf=0D + FvNameGuid =3D F0205C0E-0AD1-499C-A5F9-96BAF98248A0=0D +=0D + INF MinPlatformPkg/PlatformInit/SiliconPolicyPei/SiliconPolicyPeiPreMem.= inf=0D +=0D + !if $(SMM_REQUIRED) =3D=3D TRUE=0D + INF OvmfPkg/SmmAccess/SmmAccessPei.inf=0D + !endif=0D +=0D +[FV.FvFspS]=0D + !include MinPlatformPkg/Include/Fdf/CommonSpiFvHeaderInfo.fdf=0D + FvNameGuid =3D C6786443-AFCA-471B-A8FC-E8C330708F99=0D +=0D +[FV.FvPostMemorySilicon]=0D + !include MinPlatformPkg/Include/Fdf/CommonSpiFvHeaderInfo.fdf=0D + FvNameGuid =3D EF76DFDC-2B7D-423D-BFE4-8FD4BB22E770=0D +=0D +###########################=0D +#=0D +# Stage 2 Firmware Volumes=0D +#=0D +###########################=0D +[FV.FvPostMemory]=0D + !include MinPlatformPkg/Include/Fdf/CommonSpiFvHeaderInfo.fdf=0D + FvNameGuid =3D 5A1D6978-BABE-42F9-A629-F7B3B6A1E1BD=0D +=0D + INF UefiCpuPkg/CpuMpPei/CpuMpPei.inf=0D +=0D + INF MinPlatformPkg/PlatformInit/SiliconPolicyPei/SiliconPolicyPeiPostMem= .inf=0D + INF MinPlatformPkg/PlatformInit/PlatformInitPei/PlatformInitPostMem.inf= =0D +=0D + INF MdeModulePkg/Core/DxeIplPeim/DxeIpl.inf=0D +=0D + INF MdeModulePkg/Universal/ResetSystemRuntimeDxe/ResetSystemRuntimeDxe.i= nf=0D + INF MdeModulePkg/Bus/Pci/PciHostBridgeDxe/PciHostBridgeDxe.inf=0D +=0D +[FV.FvBsp]=0D + !include MinPlatformPkg/Include/Fdf/CommonSpiFvHeaderInfo.fdf=0D + FvNameGuid =3D FCA0BC4A-994D-4EF9-BD56-A8C45872C2A8=0D +=0D +###########################=0D +#=0D +# Stage 3 Firmware Volumes=0D +#=0D +###########################=0D +=0D +[FV.FvUefiBootUnCompressed]=0D + !include MinPlatformPkg/Include/Fdf/CommonSpiFvHeaderInfo.fdf=0D + FvNameGuid =3D D2F110DB-2388-4963-BEFD-5889EEE01569=0D +=0D + INF MdeModulePkg/Universal/PCD/Dxe/Pcd.inf=0D +=0D + INF MdeModulePkg/Universal/ReportStatusCodeRouter/RuntimeDxe/ReportStatu= sCodeRouterRuntimeDxe.inf=0D + INF MdeModulePkg/Universal/StatusCodeHandler/RuntimeDxe/StatusCodeHandle= rRuntimeDxe.inf=0D +=0D + INF MdeModulePkg/Universal/Metronome/Metronome.inf=0D + INF PcAtChipsetPkg/HpetTimerDxe/HpetTimerDxe.inf=0D + INF UefiCpuPkg/CpuIo2Dxe/CpuIo2Dxe.inf=0D + INF UefiCpuPkg/CpuDxe/CpuDxe.inf=0D + INF MdeModulePkg/Universal/WatchdogTimerDxe/WatchdogTimer.inf=0D + INF PcAtChipsetPkg/PcatRealTimeClockRuntimeDxe/PcatRealTimeClockRuntimeD= xe.inf=0D + INF MdeModulePkg/Core/RuntimeDxe/RuntimeDxe.inf=0D + INF MdeModulePkg/Universal/Variable/RuntimeDxe/VariableRuntimeDxe.inf=0D + INF MdeModulePkg/Universal/MonotonicCounterRuntimeDxe/MonotonicCounterRu= ntimeDxe.inf=0D + INF MdeModulePkg/Universal/Console/TerminalDxe/TerminalDxe.inf=0D + INF MdeModulePkg/Universal/SecurityStubDxe/SecurityStubDxe.inf=0D + INF MdeModulePkg/Universal/CapsuleRuntimeDxe/CapsuleRuntimeDxe.inf=0D + INF MdeModulePkg/Universal/Acpi/S3SaveStateDxe/S3SaveStateDxe.inf=0D + INF MdeModulePkg/Universal/BdsDxe/BdsDxe.inf=0D +=0D + INF OvmfPkg/IoMmuDxe/IoMmuDxe.inf=0D + INF OvmfPkg/PlatformDxe/Platform.inf=0D +=0D + INF MdeModulePkg/Bus/Pci/PciBusDxe/PciBusDxe.inf=0D + INF MdeModulePkg/Universal/Disk/UnicodeCollation/EnglishDxe/EnglishDxe.i= nf=0D + INF MdeModulePkg/Universal/Console/GraphicsOutputDxe/GraphicsOutputDxe.i= nf=0D + INF MdeModulePkg/Universal/Console/GraphicsConsoleDxe/GraphicsConsoleDxe= .inf=0D + INF MdeModulePkg/Universal/Console/ConSplitterDxe/ConSplitterDxe.inf=0D + INF MdeModulePkg/Universal/Console/ConPlatformDxe/ConPlatformDxe.inf=0D + INF MdeModulePkg/Universal/HiiDatabaseDxe/HiiDatabaseDxe.inf=0D + INF MdeModulePkg/Universal/DevicePathDxe/DevicePathDxe.inf=0D +=0D + INF MdeModulePkg/Application/BootManagerMenuApp/BootManagerMenuApp.inf=0D + INF MdeModulePkg/Universal/SetupBrowserDxe/SetupBrowserDxe.inf=0D + INF ShellPkg/Application/Shell/Shell.inf=0D +=0D + INF OvmfPkg/SioBusDxe/SioBusDxe.inf=0D + INF MdeModulePkg/Universal/SerialDxe/SerialDxe.inf=0D + INF MdeModulePkg/Bus/Pci/PciSioSerialDxe/PciSioSerialDxe.inf=0D +=0D +=0D +[FV.FvUefiBoot]=0D + !include MinPlatformPkg/Include/Fdf/CommonSpiFvHeaderInfo.fdf=0D + FvNameGuid =3D D0C15ADB-FE38-4331-841C-0E96C1B0FBFA=0D +=0D + INF MdeModulePkg/Core/Dxe/DxeMain.inf=0D +=0D + FILE FV_IMAGE =3D D2F110DB-2388-4963-BEFD-5889EEE01569 {=0D + SECTION GUIDED EE4E5898-3914-4259-9D6E-DC7BD79403CF PROCESSING_REQUIRE= D =3D TRUE {=0D + SECTION FV_IMAGE =3D FvUefiBootUncompressed=0D + }=0D + }=0D +=0D +=0D +###########################=0D +#=0D +# Stage 4 Firmware Volumes=0D +#=0D +###########################=0D +[FV.FvOsBoot]=0D + !include MinPlatformPkg/Include/Fdf/CommonSpiFvHeaderInfo.fdf=0D + FvNameGuid =3D AE8F0EA0-1614-422D-ABC1-C518596F1678=0D +=0D + INF OvmfPkg/QemuVideoDxe/QemuVideoDxe.inf=0D +=0D + INF PcAtChipsetPkg/Bus/Pci/IdeControllerDxe/IdeControllerDxe.inf=0D + INF MdeModulePkg/Universal/Disk/DiskIoDxe/DiskIoDxe.inf=0D + INF MdeModulePkg/Universal/Disk/PartitionDxe/PartitionDxe.inf=0D + INF FatPkg/EnhancedFatDxe/Fat.inf=0D +=0D + INF MdeModulePkg/Bus/Isa/IsaBusDxe/IsaBusDxe.inf=0D + INF MdeModulePkg/Bus/Isa/Ps2KeyboardDxe/Ps2KeyboardDxe.inf=0D +=0D + # ACPI=0D + INF MdeModulePkg/Universal/Acpi/AcpiTableDxe/AcpiTableDxe.inf=0D + INF OvmfPkg/AcpiPlatformDxe/AcpiPlatformDxe.inf=0D +=0D + # Buses=0D +=0D + INF MdeModulePkg/Bus/Pci/UhciDxe/UhciDxe.inf=0D + INF MdeModulePkg/Bus/Pci/EhciDxe/EhciDxe.inf=0D + INF MdeModulePkg/Bus/Pci/XhciDxe/XhciDxe.inf=0D + INF MdeModulePkg/Bus/Usb/UsbBusDxe/UsbBusDxe.inf=0D + INF MdeModulePkg/Bus/Usb/UsbKbDxe/UsbKbDxe.inf=0D +=0D + INF MdeModulePkg/Bus/Scsi/ScsiBusDxe/ScsiBusDxe.inf=0D + INF MdeModulePkg/Bus/Scsi/ScsiDiskDxe/ScsiDiskDxe.inf=0D +=0D + INF OvmfPkg/SataControllerDxe/SataControllerDxe.inf=0D +=0D + INF MdeModulePkg/Bus/Ata/AtaAtapiPassThru/AtaAtapiPassThru.inf=0D + INF MdeModulePkg/Bus/Ata/AtaBusDxe/AtaBusDxe.inf=0D +=0D + INF MdeModulePkg/Bus/Pci/NvmExpressDxe/NvmExpressDxe.inf=0D +=0D + !if $(SMM_REQUIRED) =3D=3D TRUE=0D + INF OvmfPkg/SmmAccess/SmmAccess2Dxe.inf=0D + INF OvmfPkg/SmmControl2Dxe/SmmControl2Dxe.inf=0D + INF MdeModulePkg/Core/PiSmmCore/PiSmmIpl.inf=0D + INF MdeModulePkg/Core/PiSmmCore/PiSmmCore.inf=0D + INF MdeModulePkg/Universal/LockBox/SmmLockBox/SmmLockBox.inf=0D + INF MdeModulePkg/Universal/ReportStatusCodeRouter/Smm/ReportStatusCo= deRouterSmm.inf=0D + INF MdeModulePkg/Universal/StatusCodeHandler/Smm/StatusCodeHandlerSm= m.inf=0D + INF UefiCpuPkg/PiSmmCpuDxeSmm/PiSmmCpuDxeSmm.inf=0D + INF UefiCpuPkg/CpuIo2Smm/CpuIo2Smm.inf=0D + INF MdeModulePkg/Universal/FaultTolerantWriteDxe/FaultTolerantWriteS= mm.inf=0D + INF IntelSiliconPkg/Feature/Flash/SpiFvbService/SpiFvbServiceSmm.inf= =0D + !endif=0D + INF MdeModulePkg/Universal/SmbiosDxe/SmbiosDxe.inf=0D + INF OvmfPkg/SmbiosPlatformDxe/SmbiosPlatformDxe.inf=0D +=0D +=0D +###########################=0D +#=0D +# Stage 5 Firmware Volumes=0D +#=0D +###########################=0D +[FV.FvSecurity]=0D + !include MinPlatformPkg/Include/Fdf/CommonSpiFvHeaderInfo.fdf=0D + FvNameGuid =3D 1AE6AB90-9431-425B-9A92-ED2708A4E982=0D + !include MinPlatformPkg/Include/Fdf/CoreSecurityLateInclude.fdf=0D + !include MinPlatformPkg/Include/Fdf/CoreSecurityPreMemoryInclude.fdf=0D +=0D +=0D +###########################=0D +#=0D +# Stage 6 Firmware Volumes=0D +#=0D +###########################=0D +[FV.FvAdvanced]=0D + !include MinPlatformPkg/Include/Fdf/CommonSpiFvHeaderInfo.fdf=0D + FvNameGuid =3D 936D6D65-CB6C-4B87-A51C-70D56511CB55=0D +=0D +###########################=0D +#=0D +# File Construction Rules=0D +#=0D +###########################=0D +!include MinPlatformPkg/Include/Fdf/RuleInclude.fdf=0D diff --git a/Platform/Qemu/QemuOpenBoardPkg/Library/BoardBootManagerLib/Boa= rdBootManagerLib.inf b/Platform/Qemu/QemuOpenBoardPkg/Library/BoardBootMana= gerLib/BoardBootManagerLib.inf new file mode 100644 index 000000000000..37425d711010 --- /dev/null +++ b/Platform/Qemu/QemuOpenBoardPkg/Library/BoardBootManagerLib/BoardBootM= anagerLib.inf @@ -0,0 +1,39 @@ +## @file=0D +# The module definition file for BoardBootManagerLib.=0D +#=0D +# Copyright (c) 2019, Intel Corporation. All rights reserved.
=0D +# SPDX-License-Identifier: BSD-2-Clause-Patent=0D +#=0D +##=0D +=0D +[Defines]=0D + INF_VERSION =3D 0x00010005=0D + BASE_NAME =3D BoardBootManagerLib=0D + FILE_GUID =3D 3fe4b589-8bd9-46df-9322-d06fa2c278d6= =0D + MODULE_TYPE =3D DXE_DRIVER=0D + VERSION_STRING =3D 1.0=0D + LIBRARY_CLASS =3D BoardBootManagerLib|DXE_DRIVER=0D +=0D +=0D +#=0D +# The following information is for reference only and not required by the = build tools.=0D +#=0D +# VALID_ARCHITECTURES =3D IA32 X64 EBC=0D +#=0D +=0D +[Sources]=0D + BoardBootManager.c=0D +=0D +[LibraryClasses]=0D + BaseLib=0D + UefiBootServicesTableLib=0D + DebugLib=0D + UefiLib=0D + HobLib=0D + UefiBootManagerLib=0D + TimerLib=0D +=0D +[Packages]=0D + MdePkg/MdePkg.dec=0D + MdeModulePkg/MdeModulePkg.dec=0D + MinPlatformPkg/MinPlatformPkg.dec=0D diff --git a/Platform/Qemu/QemuOpenBoardPkg/Library/BoardInitLib/BoardInitL= ib.inf b/Platform/Qemu/QemuOpenBoardPkg/Library/BoardInitLib/BoardInitLib.i= nf new file mode 100644 index 000000000000..8f75d1277070 --- /dev/null +++ b/Platform/Qemu/QemuOpenBoardPkg/Library/BoardInitLib/BoardInitLib.inf @@ -0,0 +1,29 @@ +## @file=0D +# QemuOpenBoardPkg BoardInitLib instance=0D +#=0D +# Copyright (c) 2019, Intel Corporation. All rights reserved.
=0D +# SPDX-License-Identifier: BSD-2-Clause-Patent=0D +#=0D +##=0D +[Defines]=0D + INF_VERSION =3D 0x00010005=0D + BASE_NAME =3D BoardInitLib=0D + FILE_GUID =3D 70EE7BD9-08FF-4D0E-AA7B-4320844F939A= =0D + MODULE_TYPE =3D BASE=0D + VERSION_STRING =3D 1.0=0D + LIBRARY_CLASS =3D BoardInitLib=0D +=0D +[Sources]=0D + BoardInitLib.c=0D +=0D +[Packages]=0D + QemuOpenBoardPkg/QemuOpenBoardPkg.dec=0D + MdePkg/MdePkg.dec=0D + MinPlatformPkg/MinPlatformPkg.dec=0D + OvmfPkg/OvmfPkg.dec=0D +=0D +[LibraryClasses]=0D + DebugLib=0D + PcdLib=0D + IoLib=0D + PciCf8Lib=0D diff --git a/Platform/Qemu/QemuOpenBoardPkg/Library/OpenQemuFwCfgLib/OpenQe= muFwCfgLib.inf b/Platform/Qemu/QemuOpenBoardPkg/Library/OpenQemuFwCfgLib/Op= enQemuFwCfgLib.inf new file mode 100644 index 000000000000..cfabf412d5bb --- /dev/null +++ b/Platform/Qemu/QemuOpenBoardPkg/Library/OpenQemuFwCfgLib/OpenQemuFwCfg= Lib.inf @@ -0,0 +1,23 @@ +## @file=0D +# OpenQemuFwCfgLib.inf=0D +#=0D +# Simple implementation of the QemuFwCfgLib that reads data from the QEMU= =0D +# FW_CFG device=0D +#=0D +# Copyright (c) 2022 Th=C3=A9o Jehl=0D +# SPDX-License-Identifier: BSD-2-Clause-Patent=0D +##=0D +=0D +[Defines]=0D + INF_VERSION =3D 0x00010005=0D + BASE_NAME =3D QemuFwCfgLib=0D + FILE_GUID =3D 70EE7BD9-08FF-4D0E-AA7B-4320844F939A= =0D + MODULE_TYPE =3D BASE=0D + VERSION_STRING =3D 1.0=0D + LIBRARY_CLASS =3D OpenQemuFwCfgLib=0D +=0D +[Sources]=0D + OpenQemuFwCfgLib.c=0D +=0D +[LibraryClasses]=0D + IoLib=0D diff --git a/Platform/Qemu/QemuOpenBoardPkg/Library/PeiReportFvLib/PeiRepor= tFvLib.inf b/Platform/Qemu/QemuOpenBoardPkg/Library/PeiReportFvLib/PeiRepor= tFvLib.inf new file mode 100644 index 000000000000..d416f1c64061 --- /dev/null +++ b/Platform/Qemu/QemuOpenBoardPkg/Library/PeiReportFvLib/PeiReportFvLib.= inf @@ -0,0 +1,63 @@ +### @file=0D +# Component information file for the Report Firmware Volume (FV) library.= =0D +#=0D +# Copyright (c) 2018 - 2021, Intel Corporation. All rights reserved.
=0D +#=0D +# SPDX-License-Identifier: BSD-2-Clause-Patent=0D +#=0D +###=0D +=0D +[Defines]=0D + INF_VERSION =3D 0x00010017=0D + BASE_NAME =3D PeiReportFvLib=0D + FILE_GUID =3D 44328FA5-E4DD-4A15-ABDF-C6584AC363D9= =0D + VERSION_STRING =3D 1.0=0D + MODULE_TYPE =3D PEIM=0D + LIBRARY_CLASS =3D ReportFvLib=0D +=0D +[LibraryClasses]=0D + BaseMemoryLib=0D + DebugLib=0D + HobLib=0D + PeiServicesLib=0D +=0D +[Packages]=0D + MdePkg/MdePkg.dec=0D + MdeModulePkg/MdeModulePkg.dec=0D + MinPlatformPkg/MinPlatformPkg.dec=0D + QemuOpenBoardPkg/QemuOpenBoardPkg.dec=0D +=0D +[Sources]=0D + PeiReportFvLib.c=0D +=0D +[Pcd]=0D + gMinPlatformPkgTokenSpaceGuid.PcdBootStage ## CONSU= MES=0D + gMinPlatformPkgTokenSpaceGuid.PcdFspWrapperBootMode ## CONSU= MES=0D + gMinPlatformPkgTokenSpaceGuid.PcdFlashAreaBaseAddress ## CONSU= MES=0D + gMinPlatformPkgTokenSpaceGuid.PcdFlashAreaSize ## CONSU= MES=0D + gMinPlatformPkgTokenSpaceGuid.PcdFlashFvPreMemoryBase ## CONSU= MES=0D + gMinPlatformPkgTokenSpaceGuid.PcdFlashFvPreMemorySize ## CONSU= MES=0D + gMinPlatformPkgTokenSpaceGuid.PcdFlashFvFspTBase ## CONSU= MES=0D + gMinPlatformPkgTokenSpaceGuid.PcdFlashFvFspTSize ## CONSU= MES=0D + gMinPlatformPkgTokenSpaceGuid.PcdFlashFvFspMBase ## CONSU= MES=0D + gMinPlatformPkgTokenSpaceGuid.PcdFlashFvFspMSize ## CONSU= MES=0D + gMinPlatformPkgTokenSpaceGuid.PcdFlashFvFspSBase ## CONSU= MES=0D + gMinPlatformPkgTokenSpaceGuid.PcdFlashFvFspSSize ## CONSU= MES=0D + gMinPlatformPkgTokenSpaceGuid.PcdFlashFvPostMemoryBase ## CONSU= MES=0D + gMinPlatformPkgTokenSpaceGuid.PcdFlashFvPostMemorySize ## CONSU= MES=0D + gMinPlatformPkgTokenSpaceGuid.PcdFlashFvUefiBootBase ## CONSU= MES=0D + gMinPlatformPkgTokenSpaceGuid.PcdFlashFvUefiBootSize ## CONSU= MES=0D + gMinPlatformPkgTokenSpaceGuid.PcdFlashFvOsBootBase ## CONSU= MES=0D + gMinPlatformPkgTokenSpaceGuid.PcdFlashFvOsBootSize ## CONSU= MES=0D + gMinPlatformPkgTokenSpaceGuid.PcdFlashFvSecurityBase ## CONSU= MES=0D + gMinPlatformPkgTokenSpaceGuid.PcdFlashFvSecuritySize ## CONSU= MES=0D + gMinPlatformPkgTokenSpaceGuid.PcdFlashFvAdvancedPreMemoryBase ## CONSU= MES=0D + gMinPlatformPkgTokenSpaceGuid.PcdFlashFvAdvancedPreMemorySize ## CONSU= MES=0D + gMinPlatformPkgTokenSpaceGuid.PcdFlashFvAdvancedBase ## CONSU= MES=0D + gMinPlatformPkgTokenSpaceGuid.PcdFlashFvAdvancedSize ## CONSU= MES=0D + gMinPlatformPkgTokenSpaceGuid.PcdFlashFvBspPreMemorySize ## CONSU= MES=0D + gMinPlatformPkgTokenSpaceGuid.PcdFlashFvBspPreMemoryBase ## CONSU= MES=0D + gMinPlatformPkgTokenSpaceGuid.PcdFlashFvBspPreMemoryOffset ## CONSU= MES=0D + gMinPlatformPkgTokenSpaceGuid.PcdFlashFvBspSize ## CONSU= MES=0D + gMinPlatformPkgTokenSpaceGuid.PcdFlashFvBspBase ## CONSU= MES=0D + gMinPlatformPkgTokenSpaceGuid.PcdFlashFvBspOffset ## CONSU= MES=0D diff --git a/Platform/Qemu/QemuOpenBoardPkg/Library/PlatformSecLib/Platform= SecLib.inf b/Platform/Qemu/QemuOpenBoardPkg/Library/PlatformSecLib/Platform= SecLib.inf new file mode 100644 index 000000000000..a4c793af05cd --- /dev/null +++ b/Platform/Qemu/QemuOpenBoardPkg/Library/PlatformSecLib/PlatformSecLib.= inf @@ -0,0 +1,49 @@ +## @file=0D +# PlatformSecLib for QEMU OpenBoardPkg=0D +#=0D +# Copyright (c) 2022 Th=C3=A9o Jehl=0D +# SPDX-License-Identifier: BSD-2-Clause-Patent=0D +=0D +[Defines]=0D + INF_VERSION =3D 0x00010005=0D + BASE_NAME =3D PlatformSecLib=0D + FILE_GUID =3D 37b1bddc-5a53-4f2a-af7d-b78d5e80dcbd= =0D + MODULE_TYPE =3D SEC=0D + VERSION_STRING =3D 1.0=0D + LIBRARY_CLASS =3D PlatformSecLib=0D +=0D +#=0D +# The following information is for reference only and not required by the = build tools.=0D +#=0D +# VALID_ARCHITECTURES =3D IA32=0D +#=0D +=0D +[Sources.IA32]=0D + Ia32/SecEntry.nasm=0D +=0D +[Sources]=0D + PlatformSecLib.c=0D +=0D +[LibraryClasses]=0D + DebugLib=0D + BaseLib=0D + BaseMemoryLib=0D + PciLib=0D + PcdLib=0D + HobLib=0D + MtrrLib=0D +=0D +[Packages]=0D + MdePkg/MdePkg.dec=0D + UefiCpuPkg/UefiCpuPkg.dec=0D + QemuOpenBoardPkg/QemuOpenBoardPkg.dec=0D + IntelFsp2WrapperPkg/IntelFsp2WrapperPkg.dec=0D + MinPlatformPkg/MinPlatformPkg.dec=0D +=0D +[Ppis]=0D + gTopOfTemporaryRamPpiGuid=0D +=0D +[Pcd]=0D + gQemuOpenBoardPkgTokenSpaceGuid.PcdTemporaryRamBase=0D + gQemuOpenBoardPkgTokenSpaceGuid.PcdTemporaryRamSize=0D + gMinPlatformPkgTokenSpaceGuid.PcdFlashFvFspMBase=0D diff --git a/Platform/Qemu/QemuOpenBoardPkg/PlatformInitPei/PlatformInitPei= .inf b/Platform/Qemu/QemuOpenBoardPkg/PlatformInitPei/PlatformInitPei.inf new file mode 100644 index 000000000000..c800d14a02b5 --- /dev/null +++ b/Platform/Qemu/QemuOpenBoardPkg/PlatformInitPei/PlatformInitPei.inf @@ -0,0 +1,59 @@ +## @file=0D +# PlatformInitPei=0D +#=0D +# Simple PEIM for QEMU PIIX4/Q35 Memory, SMP and PCI/PCI Express initiali= zation=0D +#=0D +# Copyright (c) 2022 Th=C3=A9o Jehl=0D +# SPDX-License-Identifier: BSD-2-Clause-Patent=0D +=0D +[Defines]=0D + INF_VERSION =3D 0x00010005=0D + BASE_NAME =3D PlatformInitPei=0D + FILE_GUID =3D 82d851fe-3106-4175-8b6c-87fda1f2d0ac= =0D + MODULE_TYPE =3D PEIM=0D + VERSION_STRING =3D 1.0=0D + ENTRY_POINT =3D PlatformInit=0D +=0D +[Packages]=0D + OvmfPkg/OvmfPkg.dec=0D + MdePkg/MdePkg.dec=0D + QemuOpenBoardPkg/QemuOpenBoardPkg.dec=0D + UefiCpuPkg/UefiCpuPkg.dec=0D +=0D +[Sources]=0D + PlatformInit.h=0D + PlatformInit.c=0D + Memory.c=0D + Pcie.c=0D + Pci.c=0D + Cpu.c=0D +=0D +[LibraryClasses]=0D + PeimEntryPoint=0D + OpenQemuFwCfgLib=0D + HobLib=0D + PcdLib=0D + PciLib=0D +=0D +[Guids]=0D + gUefiOvmfPkgPlatformInfoGuid=0D +=0D +[Pcd]=0D + gUefiOvmfPkgTokenSpaceGuid.PcdOvmfHostBridgePciDevId=0D + gEfiMdePkgTokenSpaceGuid.PcdPciExpressBaseAddress=0D + gUefiCpuPkgTokenSpaceGuid.PcdCpuMaxLogicalProcessorNumber=0D + gUefiCpuPkgTokenSpaceGuid.PcdCpuBootLogicalProcessorNumber=0D + gUefiOvmfPkgTokenSpaceGuid.PcdPciIoBase=0D + gUefiOvmfPkgTokenSpaceGuid.PcdPciIoSize=0D + gUefiOvmfPkgTokenSpaceGuid.PcdPciMmio32Base=0D + gUefiOvmfPkgTokenSpaceGuid.PcdPciMmio32Size=0D + gUefiOvmfPkgTokenSpaceGuid.PcdPciMmio64Base=0D + gUefiOvmfPkgTokenSpaceGuid.PcdPciMmio64Size=0D + gEfiMdePkgTokenSpaceGuid.PcdPciExpressBaseAddress=0D + gUefiOvmfPkgTokenSpaceGuid.PcdQ35TsegMbytes=0D +=0D +[FeaturePcd]=0D + gUefiOvmfPkgTokenSpaceGuid.PcdSmmSmramRequire=0D +=0D +[Depex]=0D + TRUE=0D diff --git a/Platform/Qemu/QemuOpenBoardPkg/Include/Library/OpenQemuFwCfgLi= b.h b/Platform/Qemu/QemuOpenBoardPkg/Include/Library/OpenQemuFwCfgLib.h new file mode 100644 index 000000000000..ec82cc9c89f0 --- /dev/null +++ b/Platform/Qemu/QemuOpenBoardPkg/Include/Library/OpenQemuFwCfgLib.h @@ -0,0 +1,102 @@ +/** @file OpenQemuFwCfgLib.h=0D + OpenQemuFwCfgLib Headers=0D +=0D + Implements a minimal library to interact with Qemu FW CFG device=0D +=0D + Copyright (c) 2022 Th=C3=A9o Jehl All rights reserved.=0D + SPDX-License-Identifier: BSD-2-Clause-Patent=0D +**/=0D +=0D +=0D +#ifndef QEMU_OPEN_BOARD_PKG_QEMU_FW_CFG_LIB_H_=0D +#define QEMU_OPEN_BOARD_PKG_QEMU_FW_CFG_LIB_H_=0D +=0D +#include =0D +#include =0D +=0D +// QEMU fw_cfg registers=0D +#define FW_CFG_PORT_SEL 0x510=0D +#define FW_CFG_PORT_DATA 0x511=0D +#define FW_CFG_PORT_DMA 0x514=0D +=0D +// QEMU Selectors=0D +#define FW_CFG_SIGNATURE 0x0000=0D +#define FW_CFG_ID 0x0001=0D +#define FW_CFG_FILE_DIR 0x0019=0D +=0D +#define FW_CFG_QEMU_SIGNATURE SIGNATURE_32('Q', 'E', 'M', 'U')=0D +=0D +typedef struct {=0D + UINT32 Size;=0D + UINT16 Select;=0D + UINT16 Reserved;=0D + CHAR8 Name[56];=0D +} QEMU_FW_CFG_FILE;=0D +=0D +/**=0D + Checks for Qemu fw_cfg device by reading "QEMU" using the signature sele= ctor=0D +=0D + @return EFI_SUCCESS - The fw_cfg device is present=0D + @return EFI_UNSUPPORTED - The device is absent=0D + */=0D +EFI_STATUS=0D +EFIAPI=0D +QemuFwCfgIsPresent (=0D + VOID=0D + );=0D +=0D +/**=0D + Sets the selector register to the specified value=0D +=0D + @param[in] Selector=0D +=0D + @return EFI_SUCCESS=0D + @return EFI_UNSUPPORTED=0D + */=0D +EFI_STATUS=0D +EFIAPI=0D +QemuFwCfgSelectItem (=0D + IN UINT16 Selector=0D + );=0D +=0D +/**=0D + Reads 8 bits from the data register=0D +=0D + @return UINT8=0D + */=0D +UINT8=0D +EFIAPI=0D +QemuFwCfgRead8 (=0D + VOID=0D + );=0D +=0D +/**=0D + Reads N bytes from the data register=0D +=0D + @param Size=0D + @param Buffer=0D + */=0D +VOID=0D +EFIAPI=0D +QemuFwCfgReadBytes (=0D + IN UINTN Size,=0D + OUT VOID *Buffer=0D + );=0D +=0D +/**=0D + Finds a file in fw_cfg by its name=0D +=0D + @param[in] String Pointer to an ASCII string to match in the database=0D + @param[out] FWConfigFile Buffer for the config file=0D +=0D + @return EFI_STATUS - Entry was found, FWConfigFile is populated=0D + @return EFI_ERROR - Entry was not found=0D + */=0D +EFI_STATUS=0D +EFIAPI=0D +QemuFwCfgFindFile (=0D + IN CHAR8 *String,=0D + OUT QEMU_FW_CFG_FILE *FWConfigFile=0D + );=0D +=0D +#endif // QEMU_OPEN_BOARD_PKG_QEMU_FW_CFG_LIB_H_=0D diff --git a/Platform/Qemu/QemuOpenBoardPkg/PlatformInitPei/PlatformInit.h = b/Platform/Qemu/QemuOpenBoardPkg/PlatformInitPei/PlatformInit.h new file mode 100644 index 000000000000..7f84e5d9724b --- /dev/null +++ b/Platform/Qemu/QemuOpenBoardPkg/PlatformInitPei/PlatformInit.h @@ -0,0 +1,59 @@ +/** @file PlatformInit.h=0D + Headers for PlatformInitPei PEIM=0D +=0D + Copyright (c) 2022 Th=C3=A9o Jehl All rights reserved.=0D + SPDX-License-Identifier: BSD-2-Clause-Patent=0D +**/=0D +=0D +#ifndef QEMU_OPEN_BOARD_PKG_PLATFORM_INIT_H_=0D +#define QEMU_OPEN_BOARD_PKG_PLATFORM_INIT_H_=0D +=0D +#include =0D +#include =0D +=0D +#define PIIX4_PCI_IO_BASE 0xC000=0D +#define PIIX4_PCI_IO_SIZE 0x4000=0D +=0D +#define Q35_PCI_IO_BASE 0x6000=0D +#define Q35_PCI_IO_SIZE 0xA000=0D +=0D +#define PCI_MMIO_TOP_ADDRESS 0xFC000000=0D +=0D +EFI_STATUS=0D +EFIAPI=0D +PlatformInit (=0D + IN EFI_PEI_FILE_HANDLE FileHandle,=0D + IN CONST EFI_PEI_SERVICES **PeiServices=0D + );=0D +=0D +UINT32=0D +EFIAPI=0D +GetMemoryBelow4Gb (=0D + VOID=0D + );=0D +=0D +EFI_STATUS=0D +EFIAPI=0D +InstallMemory (=0D + IN CONST EFI_PEI_SERVICES **PeiServices=0D + );=0D +=0D +EFI_STATUS=0D +EFIAPI=0D +InitializePcie (=0D + VOID=0D + );=0D +=0D +EFI_STATUS=0D +EFIAPI=0D +InitializePciPIIX4 (=0D + VOID=0D + );=0D +=0D +EFI_STATUS=0D +EFIAPI=0D +MaxCpuInit (=0D + VOID=0D + );=0D +=0D +#endif //QEMU_OPEN_BOARD_PKG_PLATFORM_INIT_H_=0D diff --git a/Platform/Qemu/QemuOpenBoardPkg/Library/BoardBootManagerLib/Boa= rdBootManager.c b/Platform/Qemu/QemuOpenBoardPkg/Library/BoardBootManagerLi= b/BoardBootManager.c new file mode 100644 index 000000000000..9fad6bc56dfd --- /dev/null +++ b/Platform/Qemu/QemuOpenBoardPkg/Library/BoardBootManagerLib/BoardBootM= anager.c @@ -0,0 +1,105 @@ +/** @file=0D + This file include board specific boot manager callbacks=0D +=0D + Copyright (c) 2019, Intel Corporation. All rights reserved.
=0D + SPDX-License-Identifier: BSD-2-Clause-Patent=0D +**/=0D +=0D +#include =0D +#include =0D +#include =0D +#include =0D +#include =0D +#include =0D +#include =0D +#include =0D +=0D +BOOLEAN mHotKeypressed =3D FALSE;=0D +EFI_EVENT HotKeyEvent =3D NULL;=0D +UINTN mBootMenuOptionNumber;=0D +=0D +/**=0D + This function is called each second during the boot manager waits timeou= t.=0D +=0D + @param TimeoutRemain The remaining timeout.=0D +**/=0D +VOID=0D +EFIAPI=0D +BoardBootManagerWaitCallback (=0D + UINT16 TimeoutRemain=0D + )=0D +{=0D + EFI_STATUS Status;=0D + EFI_SIMPLE_TEXT_INPUT_EX_PROTOCOL *TxtInEx;=0D + EFI_KEY_DATA KeyData;=0D + BOOLEAN PausePressed;=0D +=0D + //=0D + // Pause on PAUSE key=0D + //=0D + Status =3D gBS->HandleProtocol (gST->ConsoleInHandle, &gEfiSimpleTextInp= utExProtocolGuid, (VOID **)&TxtInEx);=0D + ASSERT_EFI_ERROR (Status);=0D +=0D + PausePressed =3D FALSE;=0D +=0D + while (TRUE) {=0D + Status =3D TxtInEx->ReadKeyStrokeEx (TxtInEx, &KeyData);=0D + if (EFI_ERROR (Status)) {=0D + break;=0D + }=0D +=0D + if (KeyData.Key.ScanCode =3D=3D SCAN_PAUSE) {=0D + PausePressed =3D TRUE;=0D + break;=0D + }=0D + }=0D +=0D + //=0D + // Loop until non-PAUSE key pressed=0D + //=0D + while (PausePressed) {=0D + Status =3D TxtInEx->ReadKeyStrokeEx (TxtInEx, &KeyData);=0D + if (!EFI_ERROR (Status)) {=0D + DEBUG (=0D + (=0D + DEBUG_INFO, "[PauseCallback] %x/%x %x/%x\n",=0D + KeyData.Key.ScanCode, KeyData.Key.UnicodeChar,=0D + KeyData.KeyState.KeyShiftState, KeyData.KeyState.KeyToggleSt= ate=0D + )=0D + );=0D + PausePressed =3D (BOOLEAN)(KeyData.Key.ScanCode =3D=3D SCAN_PAUSE);= =0D + }=0D + }=0D +}=0D +=0D +/**=0D + The function is called when no boot option could be launched,=0D + including platform recovery options and options pointing to applications= =0D + built into firmware volumes.=0D +=0D + If this function returns, BDS attempts to enter an infinite loop.=0D +**/=0D +VOID=0D +EFIAPI=0D +BoardBootManagerUnableToBoot (=0D + VOID=0D + )=0D +{=0D + EFI_STATUS Status;=0D + EFI_BOOT_MANAGER_LOAD_OPTION BootDeviceList;=0D + CHAR16 OptionName[sizeof ("Boot####")];=0D +=0D + if (mBootMenuOptionNumber =3D=3D LoadOptionNumberUnassigned) {=0D + return;=0D + }=0D +=0D + UnicodeSPrint (OptionName, sizeof (OptionName), L"Boot%04x", mBootMenuOp= tionNumber);=0D + Status =3D EfiBootManagerVariableToLoadOption (OptionName, &BootDeviceLi= st);=0D + if (EFI_ERROR (Status)) {=0D + return;=0D + }=0D +=0D + for ( ;;) {=0D + EfiBootManagerBoot (&BootDeviceList);=0D + }=0D +}=0D diff --git a/Platform/Qemu/QemuOpenBoardPkg/Library/BoardInitLib/BoardInitL= ib.c b/Platform/Qemu/QemuOpenBoardPkg/Library/BoardInitLib/BoardInitLib.c new file mode 100644 index 000000000000..ae7c77915b5e --- /dev/null +++ b/Platform/Qemu/QemuOpenBoardPkg/Library/BoardInitLib/BoardInitLib.c @@ -0,0 +1,222 @@ +/** @file=0D + Board initialization library=0D +=0D + Copyright (c) 2022 Th=C3=A9o Jehl All rights reserved.=0D + SPDX-License-Identifier: BSD-2-Clause-Patent=0D +**/=0D +=0D +#include =0D +#include =0D +#include =0D +#include =0D +#include =0D +#include =0D +#include =0D +#include =0D +#include =0D +#include =0D +=0D +#define QEMU_IO_DEBUG_MAGIC 0xE9=0D +=0D +/**=0D + This board service detects the board type.=0D +=0D + @retval EFI_SUCCESS The board was detected successfully.=0D + @retval EFI_NOT_FOUND The board could not be detected.=0D +**/=0D +EFI_STATUS=0D +EFIAPI=0D +BoardDetect (=0D + VOID=0D + )=0D +{=0D + UINT16 DeviceID, VendorID;=0D +=0D + DEBUG ((DEBUG_INFO, "BoardDetect()\n"));=0D +=0D + DeviceID =3D PciCf8Read16 (PCI_CF8_LIB_ADDRESS (0, 0, 0, PCI_DEVICE_ID_O= FFSET));=0D + VendorID =3D PciCf8Read16 (PCI_CF8_LIB_ADDRESS (0, 0, 0, PCI_VENDOR_ID_O= FFSET));=0D +=0D + switch (DeviceID) {=0D + case INTEL_82441_DEVICE_ID:=0D + DEBUG ((DEBUG_INFO, "PIIX4\n"));=0D + return EFI_SUCCESS;=0D +=0D + case INTEL_Q35_MCH_DEVICE_ID:=0D + DEBUG ((DEBUG_INFO, "ICH9\n"));=0D + return EFI_SUCCESS;=0D +=0D + default:=0D + DEBUG ((DEBUG_ERROR, "Unable to detect board (Device id %u Vendor ID= %u)\n", DeviceID, VendorID));=0D + return EFI_NOT_FOUND;=0D + }=0D +}=0D +=0D +/**=0D + This board service initializes board-specific debug devices.=0D +=0D + @retval EFI_SUCCESS Board-specific debug initialization was successful= .=0D + @retval EFI_NOT_READY The board has not been detected yet.=0D +**/=0D +EFI_STATUS=0D +EFIAPI=0D +BoardDebugInit (=0D + VOID=0D + )=0D +{=0D + return EFI_SUCCESS;=0D +}=0D +=0D +EFI_BOOT_MODE=0D +EFIAPI=0D +BoardBootModeDetect (=0D + VOID=0D + )=0D +{=0D + DEBUG ((DEBUG_INFO, "BoardBootModeDetect()\n"));=0D + return BOOT_WITH_FULL_CONFIGURATION;=0D +}=0D +=0D +/**=0D + A hook for board-specific initialization prior to memory initialization.= =0D +=0D + @retval EFI_SUCCESS The board initialization was successful.=0D + @retval EFI_NOT_READY The board has not been detected yet.=0D +**/=0D +EFI_STATUS=0D +EFIAPI=0D +BoardInitBeforeMemoryInit (=0D + VOID=0D + )=0D +{=0D + DEBUG ((DEBUG_INFO, "BoardInitBeforeMemoryInit()\n"));=0D + return EFI_SUCCESS;=0D +}=0D +=0D +/**=0D + A hook for board-specific initialization after memory initialization.=0D +=0D + @retval EFI_SUCCESS The board initialization was successful.=0D + @retval EFI_NOT_READY The board has not been detected yet.=0D +**/=0D +EFI_STATUS=0D +EFIAPI=0D +BoardInitAfterMemoryInit (=0D + VOID=0D + )=0D +{=0D + DEBUG ((DEBUG_INFO, "BoardInitAfterMemoryInit()\n"));=0D + return EFI_SUCCESS;=0D +}=0D +=0D +/**=0D + A hook for board-specific initialization prior to disabling temporary RA= M.=0D +=0D + @retval EFI_SUCCESS The board initialization was successful.=0D + @retval EFI_NOT_READY The board has not been detected yet.=0D +**/=0D +EFI_STATUS=0D +EFIAPI=0D +BoardInitBeforeTempRamExit (=0D + VOID=0D + )=0D +{=0D + DEBUG ((DEBUG_INFO, "BoardInitBeforeTempRamExit()\n"));=0D + return EFI_SUCCESS;=0D +}=0D +=0D +/**=0D + A hook for board-specific initialization after disabling temporary RAM.= =0D +=0D + @retval EFI_SUCCESS The board initialization was successful.=0D + @retval EFI_NOT_READY The board has not been detected yet.=0D +**/=0D +EFI_STATUS=0D +EFIAPI=0D +BoardInitAfterTempRamExit (=0D + VOID=0D + )=0D +{=0D + DEBUG ((DEBUG_INFO, "BoardInitAfterTempRamExit()\n"));=0D + return EFI_SUCCESS;=0D +}=0D +=0D +/**=0D + A hook for board-specific initialization prior to silicon initialization= .=0D +=0D + @retval EFI_SUCCESS The board initialization was successful.=0D + @retval EFI_NOT_READY The board has not been detected yet.=0D +**/=0D +EFI_STATUS=0D +EFIAPI=0D +BoardInitBeforeSiliconInit (=0D + VOID=0D + )=0D +{=0D + DEBUG ((DEBUG_INFO, "BoardInitBeforeSiliconInit()\n"));=0D + return EFI_SUCCESS;=0D +}=0D +=0D +/**=0D + A hook for board-specific initialization after silicon initialization.=0D +=0D + @retval EFI_SUCCESS The board initialization was successful.=0D + @retval EFI_NOT_READY The board has not been detected yet.=0D +**/=0D +EFI_STATUS=0D +EFIAPI=0D +BoardInitAfterSiliconInit (=0D + VOID=0D + )=0D +{=0D + DEBUG ((DEBUG_INFO, "BoardInitAfterSiliconInit()\n"));=0D + return EFI_SUCCESS;=0D +}=0D +=0D +/**=0D + A hook for board-specific initialization after PCI enumeration.=0D +=0D + @retval EFI_SUCCESS The board initialization was successful.=0D + @retval EFI_NOT_READY The board has not been detected yet.=0D +**/=0D +EFI_STATUS=0D +EFIAPI=0D +BoardInitAfterPciEnumeration (=0D + VOID=0D + )=0D +{=0D + DEBUG ((DEBUG_INFO, "BoardInitAfterPciEnumeration()\n"));=0D + return EFI_SUCCESS;=0D +}=0D +=0D +/**=0D + A hook for board-specific functionality for the ReadyToBoot event.=0D +=0D + @retval EFI_SUCCESS The board initialization was successful.=0D + @retval EFI_NOT_READY The board has not been detected yet.=0D +**/=0D +EFI_STATUS=0D +EFIAPI=0D +BoardInitReadyToBoot (=0D + VOID=0D + )=0D +{=0D + DEBUG ((DEBUG_INFO, "BoardInitReadyToBoot()\n"));=0D + return EFI_SUCCESS;=0D +}=0D +=0D +/**=0D + A hook for board-specific functionality for the ExitBootServices event.= =0D +=0D + @retval EFI_SUCCESS The board initialization was successful.=0D + @retval EFI_NOT_READY The board has not been detected yet.=0D +**/=0D +EFI_STATUS=0D +EFIAPI=0D +BoardInitEndOfFirmware (=0D + VOID=0D + )=0D +{=0D + DEBUG ((DEBUG_INFO, "BoardInitEndOfFirmware()\n"));=0D + return EFI_SUCCESS;=0D +}=0D diff --git a/Platform/Qemu/QemuOpenBoardPkg/Library/OpenQemuFwCfgLib/OpenQe= muFwCfgLib.c b/Platform/Qemu/QemuOpenBoardPkg/Library/OpenQemuFwCfgLib/Open= QemuFwCfgLib.c new file mode 100644 index 000000000000..c02c263f03b3 --- /dev/null +++ b/Platform/Qemu/QemuOpenBoardPkg/Library/OpenQemuFwCfgLib/OpenQemuFwCfg= Lib.c @@ -0,0 +1,130 @@ +/** @file=0D + Qemu FW CFG device library=0D +=0D + Copyright (c) 2022 Th=C3=A9o Jehl All rights reserved.=0D + SPDX-License-Identifier: BSD-2-Clause-Patent=0D +**/=0D +=0D +#include =0D +#include =0D +#include =0D +=0D +/**=0D + Reads 8 bits from the data register=0D +=0D + @retval UINT8=0D +**/=0D +UINT8=0D +EFIAPI=0D +QemuFwCfgRead8 (=0D + VOID=0D + )=0D +{=0D + return IoRead8 (FW_CFG_PORT_DATA);=0D +}=0D +=0D +/**=0D + Sets the selector register to the specified value=0D +=0D + @param Selector=0D +=0D + @retval EFI_SUCCESS=0D + @retval EFI_UNSUPPORTED=0D +**/=0D +EFI_STATUS=0D +EFIAPI=0D +QemuFwCfgSelectItem (=0D + IN UINT16 Selector=0D + )=0D +{=0D + UINT16 WritenSelector;=0D +=0D + WritenSelector =3D IoWrite16 (FW_CFG_PORT_SEL, Selector);=0D +=0D + if (WritenSelector !=3D Selector) {=0D + return EFI_UNSUPPORTED;=0D + }=0D +=0D + return EFI_SUCCESS;=0D +}=0D +=0D +/**=0D + Reads N bytes from the data register=0D +=0D + @param Size=0D + @param Buffer=0D +**/=0D +VOID=0D +EFIAPI=0D +QemuFwCfgReadBytes (=0D + IN UINTN Size,=0D + OUT VOID *Buffer=0D + )=0D +{=0D + IoReadFifo8 (FW_CFG_PORT_DATA, Size, Buffer);=0D +}=0D +=0D +/**=0D + Checks for Qemu fw_cfg device by reading "QEMU" using the signature sele= ctor=0D +=0D + @retval EFI_SUCCESS - The fw_cfg device is present=0D + @retval EFI_UNSUPPORTED - The device is absent=0D +**/=0D +EFI_STATUS=0D +EFIAPI=0D +QemuFwCfgIsPresent (=0D + )=0D +{=0D + EFI_STATUS Status;=0D + UINT32 Control;=0D +=0D + Status =3D QemuFwCfgSelectItem (FW_CFG_SIGNATURE);=0D + if (EFI_ERROR (Status)) {=0D + return Status;=0D + }=0D +=0D + QemuFwCfgReadBytes (4, &Control);=0D + if (Control !=3D FW_CFG_QEMU_SIGNATURE) {=0D + ASSERT (Control =3D=3D FW_CFG_QEMU_SIGNATURE);=0D + return EFI_UNSUPPORTED;=0D + }=0D +=0D + return EFI_SUCCESS;=0D +}=0D +=0D +/**=0D + Finds a file in fw_cfg by its name=0D +=0D + @param String Pointer to an ASCII string to match in the database=0D + @param FWConfigFile Buffer for the config file=0D + @retval EFI_STATUS - Entry was found, FWConfigFile is populated=0D + @retval EFI_ERROR - Entry was not found=0D +**/=0D +EFI_STATUS=0D +EFIAPI=0D +QemuFwCfgFindFile (=0D + IN CHAR8 *String,=0D + OUT QEMU_FW_CFG_FILE *FWConfigFile=0D + )=0D +{=0D + QEMU_FW_CFG_FILE FirmwareConfigFile;=0D + UINT32 FilesCount;=0D + UINT32 Idx;=0D +=0D + QemuFwCfgSelectItem (FW_CFG_FILE_DIR);=0D + QemuFwCfgReadBytes (sizeof (UINT32), &FilesCount);=0D +=0D + FilesCount =3D SwapBytes32 (FilesCount);=0D +=0D + for (Idx =3D 0; Idx < FilesCount; Idx++) {=0D + QemuFwCfgReadBytes (sizeof (QEMU_FW_CFG_FILE), &FirmwareConfigFile);=0D + if (AsciiStrCmp ((CHAR8 *)&(FirmwareConfigFile.Name), String) =3D=3D 0= ) {=0D + FirmwareConfigFile.Select =3D SwapBytes16 (FirmwareConfigFile.Select= );=0D + FirmwareConfigFile.Size =3D SwapBytes32 (FirmwareConfigFile.Size);= =0D + CopyMem (FWConfigFile, &FirmwareConfigFile, sizeof (QEMU_FW_CFG_FILE= ));=0D + return EFI_SUCCESS;=0D + }=0D + }=0D +=0D + return EFI_UNSUPPORTED;=0D +}=0D diff --git a/Platform/Qemu/QemuOpenBoardPkg/Library/PeiReportFvLib/PeiRepor= tFvLib.c b/Platform/Qemu/QemuOpenBoardPkg/Library/PeiReportFvLib/PeiReportF= vLib.c new file mode 100644 index 000000000000..809e69ce4381 --- /dev/null +++ b/Platform/Qemu/QemuOpenBoardPkg/Library/PeiReportFvLib/PeiReportFvLib.c @@ -0,0 +1,285 @@ +/** @file PeiReportFvLib.c=0D + Source code file for Report Firmware Volume (FV) library=0D +=0D + Copyright (c) 2018 - 2021, Intel Corporation. All rights reserved.
=0D +=0D + SPDX-License-Identifier: BSD-2-Clause-Patent=0D +**/=0D +=0D +#include =0D +#include =0D +#include =0D +#include =0D +#include =0D +#include =0D +#include =0D +#include =0D +=0D +// Use a FV pointer PCD to get a pointer to the FileSystemGuid in the FV h= eader=0D +#define PCD_TO_FV_HEADER_FILE_SYSTEM_GUID(Pcd) (&((EFI_FIRMWARE_VOLUME_H= EADER *)(UINTN) PcdGet32 (Pcd))->FileSystemGuid)=0D +=0D +/**=0D + Reports FVs necessary for MinPlarform pre-memory initialization=0D + */=0D +VOID=0D +ReportPreMemFv (=0D + VOID=0D + )=0D +{=0D + UINTN Index =3D 0;=0D + EFI_PEI_PPI_DESCRIPTOR *Descriptor =3D NULL;=0D + EFI_PEI_FIRMWARE_VOLUME_INFO2_PPI *Ppi =3D NULL;=0D + EFI_STATUS Status =3D EFI_SUCCESS;=0D + EFI_FIRMWARE_VOLUME_HEADER *FvHeader =3D NULL;=0D + EFI_BOOT_MODE BootMode =3D BOOT_WITH_FULL_CONFIG= URATION;=0D +=0D + Status =3D PeiServicesGetBootMode (&BootMode);=0D + ASSERT_EFI_ERROR (Status);=0D +=0D + DEBUG_CODE (=0D + for (Index =3D 0; Status =3D=3D EFI_SUCCESS; Index++) {=0D + Status =3D PeiServicesLocatePpi (&gEfiPeiFirmwareVolumeInfo2PpiGuid,= Index, &Descriptor, (VOID**) &Ppi);=0D + if (!EFI_ERROR (Status)) {=0D + FvHeader =3D (EFI_FIRMWARE_VOLUME_HEADER*) Ppi->FvInfo;=0D + DEBUG ((DEBUG_INFO, "Found FV at 0x%x, size 0x%x\n", FvHeader, FvH= eader->FvLength));=0D + }=0D + }=0D + );=0D +=0D + //=0D + // FvBspPreMemory and FvPreMemory are required for all stages.=0D + //=0D +=0D + DEBUG ((DEBUG_INFO, "Install FlashFvBspPreMemory - 0x%x, 0x%x\n", PcdGet= 32 (PcdFlashFvBspPreMemoryBase), PcdGet32 (PcdFlashFvBspPreMemorySize)));=0D + PeiServicesInstallFvInfo2Ppi (=0D + PCD_TO_FV_HEADER_FILE_SYSTEM_GUID (PcdFlas= hFvBspPreMemoryBase),=0D + (VOID *)(UINTN)PcdGet32 (PcdFlashFvBspPreM= emoryBase),=0D + PcdGet32 (PcdFlashFvBspPreMemorySize),=0D + NULL,=0D + NULL,=0D + 0=0D + );=0D +=0D + DEBUG ((DEBUG_INFO, "Install FlashFvPreMemory - 0x%x, 0x%x\n", PcdGet32 = (PcdFlashFvPreMemoryBase), PcdGet32 (PcdFlashFvPreMemorySize)));=0D + PeiServicesInstallFvInfo2Ppi (=0D + PCD_TO_FV_HEADER_FILE_SYSTEM_GUID (PcdFlas= hFvPreMemoryBase),=0D + (VOID *)(UINTN)PcdGet32 (PcdFlashFvPreMemo= ryBase),=0D + PcdGet32 (PcdFlashFvPreMemorySize),=0D + NULL,=0D + NULL,=0D + 0=0D + );=0D +=0D + //=0D + // In API mode, do not publish FSP FV.=0D + //=0D + if (!PcdGetBool (PcdFspWrapperBootMode)) {=0D + //=0D + // FvFspT may be required for all stages=0D + //=0D + DEBUG ((DEBUG_INFO, "Install FlashFvFspT - 0x%x, 0x%x\n", PcdGet32 (Pc= dFlashFvFspTBase), PcdGet32 (PcdFlashFvFspTSize)));=0D + PeiServicesInstallFvInfo2Ppi (=0D + PCD_TO_FV_HEADER_FILE_SYSTEM_GUID (PcdFl= ashFvFspTBase),=0D + (VOID *)(UINTN)PcdGet32 (PcdFlashFvFspTB= ase),=0D + PcdGet32 (PcdFlashFvFspTSize),=0D + NULL,=0D + NULL,=0D + 0=0D + );=0D +=0D + //=0D + // FvFspM required for stage 2 and above=0D + //=0D + if (PcdGet8 (PcdBootStage) >=3D 2) {=0D + DEBUG ((DEBUG_INFO, "Install FlashFvFspM - 0x%x, 0x%x\n", PcdGet32 (= PcdFlashFvFspMBase), PcdGet32 (PcdFlashFvFspMSize)));=0D + PeiServicesInstallFvInfo2Ppi (=0D + PCD_TO_FV_HEADER_FILE_SYSTEM_GUID (Pcd= FlashFvFspMBase),=0D + (VOID *)(UINTN)PcdGet32 (PcdFlashFvFsp= MBase),=0D + PcdGet32 (PcdFlashFvFspMSize),=0D + NULL,=0D + NULL,=0D + 0=0D + );=0D + }=0D + }=0D +=0D + //=0D + // FvAdvanced not needed until stage 6=0D + //=0D + if (PcdGet8 (PcdBootStage) >=3D 6) {=0D + DEBUG ((DEBUG_INFO, "Install FlashFvAdvancedPreMemory - 0x%x, 0x%x\n",= PcdGet32 (PcdFlashFvAdvancedPreMemoryBase), PcdGet32 (PcdFlashFvAdvancedPr= eMemorySize)));=0D + PeiServicesInstallFvInfo2Ppi (=0D + PCD_TO_FV_HEADER_FILE_SYSTEM_GUID (PcdFl= ashFvAdvancedPreMemoryBase),=0D + (VOID *)(UINTN)PcdGet32 (PcdFlashFvAdvan= cedPreMemoryBase),=0D + PcdGet32 (PcdFlashFvAdvancedPreMemorySiz= e),=0D + NULL,=0D + NULL,=0D + 0=0D + );=0D + }=0D +}=0D +/**=0D + Reports FVs for MinPlarform post-memory initialization=0D + This function also publish FV HOBs to ensure DXE phase is aware of those= FVs=0D + */=0D +VOID=0D +ReportPostMemFv (=0D + VOID=0D + )=0D +{=0D + UINTN Index =3D 0;=0D + EFI_PEI_PPI_DESCRIPTOR *Descriptor =3D NULL;=0D + EFI_PEI_FIRMWARE_VOLUME_INFO2_PPI *Ppi =3D NULL;=0D + EFI_STATUS Status =3D EFI_SUCCESS;=0D + EFI_FIRMWARE_VOLUME_HEADER *FvHeader =3D NULL;=0D +=0D + DEBUG_CODE (=0D + for (Index =3D 0; Status =3D=3D EFI_SUCCESS; Index++) {=0D + Status =3D PeiServicesLocatePpi (&gEfiPeiFirmwareVolumeInfo2PpiGuid,= Index, &Descriptor, (VOID**) &Ppi);=0D + if (!EFI_ERROR (Status)) {=0D + FvHeader =3D (EFI_FIRMWARE_VOLUME_HEADER*) Ppi->FvInfo;=0D + DEBUG ((DEBUG_INFO, "Found FV at 0x%x, size 0x%x\n", FvHeader, FvH= eader->FvLength));=0D + }=0D + }=0D + );=0D +=0D + //=0D + // FvFspS, FvPostMemory, and FvBsp may be required for completing stage = 2=0D + //=0D + if (PcdGet8 (PcdBootStage) >=3D 2) {=0D + //=0D + // In API mode, do not publish FSP FV.=0D + //=0D + if (!PcdGetBool (PcdFspWrapperBootMode)) {=0D + DEBUG ((DEBUG_INFO, "Install FlashFvFspS - 0x%x, 0x%x\n", PcdGet32 (= PcdFlashFvFspSBase), PcdGet32 (PcdFlashFvFspSSize)));=0D + PeiServicesInstallFvInfo2Ppi (=0D + PCD_TO_FV_HEADER_FILE_SYSTEM_GUID (Pcd= FlashFvFspSBase),=0D + (VOID *)(UINTN)PcdGet32 (PcdFlashFvFsp= SBase),=0D + PcdGet32 (PcdFlashFvFspSSize),=0D + NULL,=0D + NULL,=0D + 0=0D + );=0D + }=0D +=0D + DEBUG ((DEBUG_INFO, "Install FlashFvPostMemory - 0x%x, 0x%x\n", PcdGet= 32 (PcdFlashFvPostMemoryBase), PcdGet32 (PcdFlashFvPostMemorySize)));=0D + PeiServicesInstallFvInfo2Ppi (=0D + PCD_TO_FV_HEADER_FILE_SYSTEM_GUID (PcdFl= ashFvPostMemoryBase),=0D + (VOID *)(UINTN)PcdGet32 (PcdFlashFvPostM= emoryBase),=0D + PcdGet32 (PcdFlashFvPostMemorySize),=0D + NULL,=0D + NULL,=0D + 0=0D + );=0D +=0D + DEBUG ((DEBUG_INFO, "%Build FlashFvPostMemory FV Hob at %Lx \n", (EFI_= PHYSICAL_ADDRESS)PcdGet32 (PcdFlashFvPostMemoryBase)));=0D +=0D + BuildFvHob (=0D + (EFI_PHYSICAL_ADDRESS)PcdGet32 (PcdFlashFvPostMemoryBase),= =0D + PcdGet32 (PcdFlashFvPostMemorySize)=0D + );=0D +=0D + DEBUG ((DEBUG_INFO, "Install FlashFvBsp - 0x%x, 0x%x\n", PcdGet32 (Pcd= FlashFvBspBase), PcdGet32 (PcdFlashFvBspSize)));=0D + PeiServicesInstallFvInfo2Ppi (=0D + PCD_TO_FV_HEADER_FILE_SYSTEM_GUID (PcdFl= ashFvBspBase),=0D + (VOID *)(UINTN)PcdGet32 (PcdFlashFvBspBa= se),=0D + PcdGet32 (PcdFlashFvBspSize),=0D + NULL,=0D + NULL,=0D + 0=0D + );=0D + }=0D +=0D + //=0D + // FvUefiBoot required for completing stage 3=0D + //=0D + if (PcdGet8 (PcdBootStage) >=3D 3) {=0D + DEBUG ((DEBUG_INFO, "Install FlashFvUefiBoot - 0x%x, 0x%x\n", PcdGet32= (PcdFlashFvUefiBootBase), PcdGet32 (PcdFlashFvUefiBootSize)));=0D + PeiServicesInstallFvInfo2Ppi (=0D + PCD_TO_FV_HEADER_FILE_SYSTEM_GUID (PcdFl= ashFvUefiBootBase),=0D + (VOID *)(UINTN)PcdGet32 (PcdFlashFvUefiB= ootBase),=0D + PcdGet32 (PcdFlashFvUefiBootSize),=0D + NULL,=0D + NULL,=0D + 0=0D + );=0D +=0D + DEBUG ((DEBUG_INFO, "%Build FlashFvUefiBoot FV Hob at %Lx \n", (EFI_PH= YSICAL_ADDRESS)PcdGet32 (PcdFlashFvUefiBootBase)));=0D +=0D + BuildFvHob (=0D + (EFI_PHYSICAL_ADDRESS)PcdGet32 (PcdFlashFvUefiBootBase),=0D + PcdGet32 (PcdFlashFvUefiBootSize)=0D + );=0D + }=0D +=0D + //=0D + // FvOsBoot required for completing stage 4=0D + //=0D + if (PcdGet8 (PcdBootStage) >=3D 4) {=0D + DEBUG ((DEBUG_INFO, "Install FlashFvOsBoot - 0x%x, 0x%x\n", PcdGet32 (= PcdFlashFvOsBootBase), PcdGet32 (PcdFlashFvOsBootSize)));=0D + PeiServicesInstallFvInfo2Ppi (=0D + PCD_TO_FV_HEADER_FILE_SYSTEM_GUID (PcdFl= ashFvOsBootBase),=0D + (VOID *)(UINTN)PcdGet32 (PcdFlashFvOsBoo= tBase),=0D + PcdGet32 (PcdFlashFvOsBootSize),=0D + NULL,=0D + NULL,=0D + 0=0D + );=0D +=0D + DEBUG ((DEBUG_INFO, "%Build FlashFvOsBoot FV Hob at %Lx \n", (EFI_PHYS= ICAL_ADDRESS)PcdGet32 (PcdFlashFvUefiBootBase)));=0D +=0D + BuildFvHob (=0D + (EFI_PHYSICAL_ADDRESS)PcdGet32 (PcdFlashFvOsBootBase),=0D + PcdGet32 (PcdFlashFvOsBootSize)=0D + );=0D + }=0D +=0D + //=0D + // FvSecurity required for completing stage 5=0D + //=0D + if (PcdGet8 (PcdBootStage) >=3D 5) {=0D + DEBUG ((DEBUG_INFO, "Install FlashFvSecurity - 0x%x, 0x%x\n", PcdGet32= (PcdFlashFvSecurityBase), PcdGet32 (PcdFlashFvSecuritySize)));=0D + PeiServicesInstallFvInfo2Ppi (=0D + PCD_TO_FV_HEADER_FILE_SYSTEM_GUID (PcdFl= ashFvSecurityBase),=0D + (VOID *)(UINTN)PcdGet32 (PcdFlashFvSecur= ityBase),=0D + PcdGet32 (PcdFlashFvSecuritySize),=0D + NULL,=0D + NULL,=0D + 0=0D + );=0D + }=0D +=0D + //=0D + // FvAdvanced required for completing stage 6=0D + //=0D + if (PcdGet8 (PcdBootStage) >=3D 6) {=0D + DEBUG ((DEBUG_INFO, "Install FlashFvAdvanced - 0x%x, 0x%x\n", PcdGet32= (PcdFlashFvAdvancedBase), PcdGet32 (PcdFlashFvAdvancedSize)));=0D + PeiServicesInstallFvInfo2Ppi (=0D + PCD_TO_FV_HEADER_FILE_SYSTEM_GUID (PcdFl= ashFvAdvancedBase),=0D + (VOID *)(UINTN)PcdGet32 (PcdFlashFvAdvan= cedBase),=0D + PcdGet32 (PcdFlashFvAdvancedSize),=0D + NULL,=0D + NULL,=0D + 0=0D + );=0D + }=0D +=0D + //=0D + // Report resource related HOB for flash FV to reserve space in GCD and = memory map=0D + //=0D +=0D + BuildResourceDescriptorHob (=0D + EFI_RESOURCE_MEMORY_MAPPED_IO,=0D + (EFI_RESOURCE_ATTRIBUTE_PRESENT |=0D + EFI_RESOURCE_ATTRIBUTE_INITIALIZED |=0D + EFI_RESOURCE_ATTRIBUTE_UNCACHEABLE),=0D + (UINTN)PcdGet32 (PcdFlashAreaBaseAddress),=0D + (UINTN)PcdGet32 (PcdFlashAreaSize)=0D + );=0D +=0D + BuildMemoryAllocationHob (=0D + (UINTN)PcdGet32 (PcdFlashAreaBaseAddress),=0D + (UINTN)PcdGet32 (PcdFlashAreaSize),=0D + EfiMemoryMappedIO=0D + );=0D +}=0D diff --git a/Platform/Qemu/QemuOpenBoardPkg/Library/PlatformSecLib/Platform= SecLib.c b/Platform/Qemu/QemuOpenBoardPkg/Library/PlatformSecLib/PlatformSe= cLib.c new file mode 100644 index 000000000000..ff632494c4a3 --- /dev/null +++ b/Platform/Qemu/QemuOpenBoardPkg/Library/PlatformSecLib/PlatformSecLib.c @@ -0,0 +1,140 @@ +/** @file=0D + PlatformSecLib library functions=0D +=0D + Copyright (c) 2022 Th=C3=A9o Jehl All rights reserved.=0D + SPDX-License-Identifier: BSD-2-Clause-Patent=0D +**/=0D +=0D +#include =0D +#include =0D +#include =0D +#include =0D +#include =0D +#include =0D +#include =0D +#include =0D +#include =0D +#include =0D +#include =0D +#include =0D +#include =0D +=0D +#include =0D +=0D +EFI_PEI_CORE_FV_LOCATION_PPI gEfiPeiCoreFvLocationPpi =3D {=0D + (VOID *)FixedPcdGet32 (PcdFlashFvFspMBase)=0D +};=0D +=0D +STATIC EFI_PEI_PPI_DESCRIPTOR mPeiSecPlatformPpi[] =3D {=0D + //=0D + // This must be the second PPI in the list because it will be patched in= SecPlatformMain ();=0D + //=0D + {=0D + EFI_PEI_PPI_DESCRIPTOR_PPI | EFI_PEI_PPI_DESCRIPTOR_TERMINATE_LIST,=0D + &gTopOfTemporaryRamPpiGuid,=0D + NULL=0D + }=0D +};=0D +=0D +EFI_PEI_PPI_DESCRIPTOR gEfiPeiCoreFvLocationDescriptor =3D {=0D + EFI_PEI_PPI_DESCRIPTOR_PPI,=0D + &gEfiPeiCoreFvLocationPpiGuid,=0D + &gEfiPeiCoreFvLocationPpi=0D +};=0D +=0D +EFI_PEI_PPI_DESCRIPTOR *=0D +EFIAPI=0D +SecPlatformMain (=0D + IN OUT EFI_SEC_PEI_HAND_OFF *SecCoreData=0D + )=0D +{=0D + // Use half of available heap size for PpiList=0D + EFI_PEI_PPI_DESCRIPTOR *PpiList;=0D +=0D + PpiList =3D (VOID *)((UINTN)SecCoreData->PeiTemporaryRamBase + (UINTN)Se= cCoreData->PeiTemporaryRamSize / 2);=0D +=0D + CopyMem (PpiList, &gEfiPeiCoreFvLocationDescriptor, sizeof (EFI_PEI_PPI_= DESCRIPTOR));=0D +=0D + CopyMem (&PpiList[1], &mPeiSecPlatformPpi, sizeof (EFI_PEI_PPI_DESCRIPTO= R));=0D +=0D + // Patch the top of RAM PPI=0D + PpiList[1].Ppi =3D (VOID *)((UINTN)SecCoreData->TemporaryRamBase + SecCo= reData->TemporaryRamSize);=0D + DEBUG ((DEBUG_INFO, "SecPlatformMain(): Top of memory %p\n", PpiList[1].= Ppi));=0D +=0D + return PpiList;=0D +}=0D +=0D +/**=0D + This interface conveys state information out of the Security (SEC) phase= into PEI.=0D +=0D + @param PeiServices Pointer to the PEI Services Table.=0D + @param StructureSize Pointer to the variable describing siz= e of the input buffer.=0D + @param PlatformInformationRecord Pointer to the EFI_SEC_PLATFORM_INFORM= ATION_RECORD.=0D +=0D + @retval EFI_SUCCESS The data was successfully returned.=0D + @retval EFI_BUFFER_TOO_SMALL The buffer was too small.=0D +=0D +**/=0D +EFI_STATUS=0D +EFIAPI=0D +SecPlatformInformation (=0D + IN CONST EFI_PEI_SERVICES **PeiServices,=0D + IN OUT UINT64 *StructureSize,=0D + OUT EFI_SEC_PLATFORM_INFORMATION_RECORD *PlatformInformationRecord=0D + )=0D +{=0D + UINT32 TopOfTemporaryRam;=0D + VOID *TopOfRamPpi;=0D + EFI_STATUS Status;=0D + UINT32 Count;=0D + UINT32 *BistStart;=0D + UINT32 Length;=0D +=0D + Status =3D (*PeiServices)->LocatePpi (PeiServices, &gTopOfTemporaryRamPp= iGuid, 0, NULL, &TopOfRamPpi);=0D + if (EFI_ERROR (Status)) {=0D + return Status;=0D + }=0D +=0D + TopOfTemporaryRam =3D (UINT32)TopOfRamPpi;=0D +=0D + DEBUG ((DEBUG_INFO, "SecPlatformInformation: Top of memory is %p\n", Top= OfRamPpi));=0D +=0D + Count =3D *(UINT32 *)(TopOfTemporaryRam - sizeof (UINT32));=0D + Length =3D Count * sizeof (UINT32);=0D +=0D + BistStart =3D (UINT32 *)(TopOfTemporaryRam - sizeof (UINT32) - Length);= =0D +=0D + DEBUG ((DEBUG_INFO, "SecPlatformInformation: Found %u processors with BI= STs starting at %p\n", Count, BistStart));=0D +=0D + if (*StructureSize < Length) {=0D + *StructureSize =3D Length;=0D + return EFI_BUFFER_TOO_SMALL;=0D + }=0D +=0D + CopyMem (PlatformInformationRecord, BistStart, Length);=0D + *StructureSize =3D Length;=0D +=0D + // Mask the PIC to avoid any interruption down the line=0D + IoWrite8 (0x21, 0xff);=0D + IoWrite8 (0xA1, 0xff);=0D +=0D + DEBUG ((DEBUG_INFO, "Initialize APIC Timer \n"));=0D + InitializeApicTimer (0, MAX_UINT32, TRUE, 5);=0D +=0D + DEBUG ((DEBUG_INFO, "Disable APIC Timer interrupt\n"));=0D + DisableApicTimerInterrupt ();=0D +=0D + return EFI_SUCCESS;=0D +}=0D +=0D +/**=0D + This interface disables temporary memory in SEC Phase.=0D +**/=0D +VOID=0D +EFIAPI=0D +SecPlatformDisableTemporaryMemory (=0D + VOID=0D + )=0D +{=0D + return;=0D +}=0D diff --git a/Platform/Qemu/QemuOpenBoardPkg/PlatformInitPei/Cpu.c b/Platfor= m/Qemu/QemuOpenBoardPkg/PlatformInitPei/Cpu.c new file mode 100644 index 000000000000..ff3e008aa96b --- /dev/null +++ b/Platform/Qemu/QemuOpenBoardPkg/PlatformInitPei/Cpu.c @@ -0,0 +1,56 @@ +/** @file Cpu.c=0D + CPU Count initialization=0D +=0D + Copyright (c) 2022 Th=C3=A9o Jehl All rights reserved.=0D + SPDX-License-Identifier: BSD-2-Clause-Patent=0D +**/=0D +=0D +#include "PlatformInit.h"=0D +#include =0D +#include =0D +#include =0D +#include =0D +#include =0D +#include =0D +#include =0D +#include =0D +#include =0D +#include =0D +=0D +/**=0D + Probe Qemu FW CFG device for current CPU count and report to MpInitLib=0D +=0D + @return EFI_SUCCESS Detection was successful=0D + @retval EFI_UNSUPPORTED Qemu FW CFG device is not present=0D + */=0D +EFI_STATUS=0D +EFIAPI=0D +MaxCpuInit (=0D + VOID=0D + )=0D +{=0D + UINT16 BootCpuCount;=0D + EFI_STATUS Status;=0D +=0D + Status =3D QemuFwCfgIsPresent ();=0D +=0D + if (EFI_ERROR (Status)) {=0D + DEBUG ((DEBUG_ERROR, "QemuFwCfg not present, unable to detect CPU coun= t \n"));=0D + ASSERT_EFI_ERROR (Status);=0D + return EFI_UNSUPPORTED;=0D + }=0D +=0D + Status =3D QemuFwCfgSelectItem (QemuFwCfgItemSmpCpuCount);=0D +=0D + if (EFI_ERROR (Status)) {=0D + return Status;=0D + }=0D +=0D + QemuFwCfgReadBytes (sizeof (BootCpuCount), &BootCpuCount);=0D +=0D + PcdSet32S (PcdCpuBootLogicalProcessorNumber, BootCpuCount);=0D +=0D + PcdSet32S (PcdCpuMaxLogicalProcessorNumber, 64);=0D +=0D + return EFI_SUCCESS;=0D +}=0D diff --git a/Platform/Qemu/QemuOpenBoardPkg/PlatformInitPei/Memory.c b/Plat= form/Qemu/QemuOpenBoardPkg/PlatformInitPei/Memory.c new file mode 100644 index 000000000000..8e378c17d851 --- /dev/null +++ b/Platform/Qemu/QemuOpenBoardPkg/PlatformInitPei/Memory.c @@ -0,0 +1,244 @@ +/** @file Memory.c=0D + Memory probing and installation=0D +=0D + Copyright (c) 2022 Th=C3=A9o Jehl All rights reserved.=0D + SPDX-License-Identifier: BSD-2-Clause-Patent=0D +**/=0D +=0D +#include =0D +#include =0D +#include =0D +#include =0D +#include =0D +#include =0D +#include =0D +#include =0D +=0D +/**=0D + Return the memory size below 4GB.=0D +=0D + @return UINT32=0D +**/=0D +UINT32=0D +EFIAPI=0D +GetMemoryBelow4Gb (=0D + VOID=0D + )=0D +{=0D + EFI_E820_ENTRY64 E820Entry;=0D + QEMU_FW_CFG_FILE FwCfgFile;=0D + UINT32 Processed;=0D + UINT64 Size;=0D + EFI_STATUS Status;=0D +=0D + Status =3D QemuFwCfgIsPresent ();=0D + if (EFI_ERROR (Status)) {=0D + return Status;=0D + }=0D +=0D + Status =3D QemuFwCfgFindFile ("etc/e820", &FwCfgFile);=0D + if (EFI_ERROR (Status)) {=0D + return Status;=0D + }=0D +=0D + Size =3D 0;=0D + QemuFwCfgSelectItem (FwCfgFile.Select);=0D + for (Processed =3D 0; Processed < FwCfgFile.Size / sizeof (EFI_E820_ENTR= Y); Processed++) {=0D + QemuFwCfgReadBytes (sizeof (EFI_E820_ENTRY), &E820Entry);=0D + if (E820Entry.Type !=3D EfiAcpiAddressRangeMemory) {=0D + continue;=0D + }=0D +=0D + if (E820Entry.BaseAddr + E820Entry.Length < SIZE_4GB) {=0D + Size +=3D E820Entry.Length;=0D + } else {=0D + return Size;=0D + }=0D + }=0D +=0D + return Size;=0D +}=0D +=0D +/**=0D + Reserve an MMIO region=0D +=0D + @param Start=0D + @param Length=0D +**/=0D +STATIC=0D +VOID=0D +ReserveMmioRegion (=0D + EFI_PHYSICAL_ADDRESS Start,=0D + UINT64 Length=0D + )=0D +{=0D + EFI_RESOURCE_TYPE ResourceType;=0D + EFI_RESOURCE_ATTRIBUTE_TYPE ResourceAttributes;=0D +=0D + ResourceAttributes =3D EFI_RESOURCE_ATTRIBUTE_PRESENT | EFI_RESOURCE_ATT= RIBUTE_UNCACHEABLE | EFI_RESOURCE_ATTRIBUTE_TESTED;=0D + ResourceType =3D EFI_RESOURCE_MEMORY_MAPPED_IO;=0D +=0D + BuildResourceDescriptorHob (=0D + ResourceType,=0D + ResourceAttributes,=0D + Start,=0D + Length=0D + );=0D +}=0D +=0D +/**=0D + Install EFI memory by probing Qemu FW CFG devices for valid E820 entries= =0D + It also reserve space for MMIO regions such as VGA, BIOS and APIC=0D +=0D + @param PeiServices=0D + @retval EFI_SUCCESS Memory initialization succeded=0D + @retval EFI_UNSUPPORTED Installation failed (etc/e820 file was not found= )=0D + @retval EFI_NOT_FOUND Qemu FW CFG device is not present=0D +**/=0D +EFI_STATUS=0D +EFIAPI=0D +InstallMemory (=0D + IN CONST EFI_PEI_SERVICES **PeiServices=0D + )=0D +{=0D + EFI_STATUS Status;=0D + CONST EFI_PEI_SERVICES **PeiServicesTable;=0D + EFI_E820_ENTRY64 E820Entry;=0D + EFI_E820_ENTRY64 LargestE820Entry;=0D + QEMU_FW_CFG_FILE FwCfgFile;=0D + UINT32 Processed;=0D + BOOLEAN ValidMemory;=0D + EFI_RESOURCE_TYPE ResourceType;=0D + EFI_RESOURCE_ATTRIBUTE_TYPE ResourceAttributes;=0D + UINT32 MemoryBelow4G;=0D + UINT32 RequiredBySmm;=0D +=0D + Status =3D QemuFwCfgIsPresent ();=0D + if (EFI_ERROR (Status)) {=0D + DEBUG ((DEBUG_INFO, "QEMU fw_cfg device is not present\n"));=0D + return EFI_NOT_FOUND;=0D + } else {=0D + DEBUG ((DEBUG_INFO, "QEMU fw_cfg device is present\n"));=0D + }=0D +=0D + Status =3D QemuFwCfgFindFile ("etc/e820", &FwCfgFile);=0D + if (EFI_ERROR (Status)) {=0D + DEBUG ((DEBUG_ERROR, "etc/e820 was not found \n"));=0D + return EFI_UNSUPPORTED;=0D + }=0D +=0D + MemoryBelow4G =3D GetMemoryBelow4Gb ();=0D +=0D + LargestE820Entry.Length =3D 0;=0D + QemuFwCfgSelectItem (FwCfgFile.Select);=0D + for (Processed =3D 0; Processed < FwCfgFile.Size / sizeof (EFI_E820_ENTR= Y); Processed++) {=0D + QemuFwCfgReadBytes (sizeof (EFI_E820_ENTRY), &E820Entry);=0D +=0D + ValidMemory =3D E820Entry.Type =3D=3D EfiAcpiAddressRangeMemory= ;=0D + ResourceType =3D EFI_RESOURCE_MEMORY_RESERVED;=0D + ResourceAttributes =3D EFI_RESOURCE_ATTRIBUTE_PRESENT | EFI_RESOURCE_A= TTRIBUTE_UNCACHEABLE | EFI_RESOURCE_ATTRIBUTE_TESTED;=0D +=0D + if (ValidMemory) {=0D + if (FeaturePcdGet (PcdSmmSmramRequire) && (E820Entry.BaseAddr + E820= Entry.Length =3D=3D MemoryBelow4G)) {=0D + RequiredBySmm =3D PcdGet16 (PcdQ35TsegMbytes) * SIZE_1MB;=0D + if (E820Entry.Length < RequiredBySmm) {=0D + DEBUG ((=0D + DEBUG_ERROR,=0D + "Error: There's not enough memory below TOLUD for SMM (%lx < %= x)\n",=0D + E820Entry.Length,=0D + RequiredBySmm=0D + ));=0D + }=0D +=0D + E820Entry.Length -=3D RequiredBySmm;=0D + DEBUG ((=0D + DEBUG_INFO,=0D + "SMM is enabled! Stealing [%lx, %lx](%u MiB) for SMRAM...\n",=0D + E820Entry.BaseAddr + E820Entry.Length,=0D + E820Entry.BaseAddr + E820Entry.Length + RequiredBySmm - 1,=0D + PcdGet16 (PcdQ35TsegMbytes)=0D + ));=0D + }=0D +=0D + ResourceType =3D EFI_RESOURCE_SYSTEM_MEMORY;=0D + ResourceAttributes =3D EFI_RESOURCE_ATTRIBUTE_PRESENT |=0D + EFI_RESOURCE_ATTRIBUTE_INITIALIZED |=0D + EFI_RESOURCE_ATTRIBUTE_UNCACHEABLE |=0D + EFI_RESOURCE_ATTRIBUTE_WRITE_COMBINEABLE |=0D + EFI_RESOURCE_ATTRIBUTE_WRITE_THROUGH_CACHEABLE = |=0D + EFI_RESOURCE_ATTRIBUTE_WRITE_BACK_CACHEABLE |=0D + EFI_RESOURCE_ATTRIBUTE_TESTED;=0D +=0D + //=0D + // Lets handle the lower 1MB in a special way=0D + //=0D +=0D + if (E820Entry.BaseAddr =3D=3D 0) {=0D + //=0D + // 0 - 0xa0000 is system memory, everything above that up to 1MB i= s not=0D + // Note that we check if we actually have 1MB=0D + //=0D +=0D + BuildResourceDescriptorHob (=0D + ResourceType,=0D + ResourceAttributes,=0D + 0,=0D + MIN (0xa0000, E820Entry.Length)=0D + );=0D +=0D + E820Entry.BaseAddr +=3D BASE_1MB;=0D + E820Entry.Length -=3D MIN (BASE_1MB, E820Entry.Length);=0D + }=0D +=0D + //=0D + // Note that we can only check if this is the largest entry after re= serving everything we have to reserve=0D + //=0D +=0D + if ((E820Entry.Length > LargestE820Entry.Length) && (E820Entry.BaseA= ddr + E820Entry.Length <=3D SIZE_4GB)) {=0D + CopyMem (&LargestE820Entry, &E820Entry, sizeof (EFI_E820_ENTRY64))= ;=0D + DEBUG ((=0D + DEBUG_INFO,=0D + "New largest entry for PEI: BaseAddress %lx, Size %lx\n",=0D + LargestE820Entry.BaseAddr,=0D + LargestE820Entry.Length=0D + ));=0D + }=0D + }=0D +=0D + BuildResourceDescriptorHob (=0D + ResourceType,=0D + ResourceAttributes,=0D + E820Entry.BaseAddr,=0D + E820Entry.Length=0D + );=0D +=0D + DEBUG ((=0D + DEBUG_INFO,=0D + "Processed E820 entry [%lx, %lx] with type %x\n",=0D + E820Entry.BaseAddr,=0D + E820Entry.BaseAddr + E820Entry.Length - 1,=0D + E820Entry.Type=0D + ));=0D + }=0D +=0D + ASSERT (LargestE820Entry.Length !=3D 0);=0D + DEBUG ((=0D + DEBUG_INFO,=0D + "Largest memory chunk found: [%lx, %lx]\n",=0D + LargestE820Entry.BaseAddr,=0D + LargestE820Entry.BaseAddr + LargestE820Entry.Length - 1=0D + ));=0D +=0D + PeiServicesTable =3D GetPeiServicesTablePointer ();=0D +=0D + Status =3D (*PeiServices)->InstallPeiMemory (PeiServicesTable, LargestE8= 20Entry.BaseAddr, LargestE820Entry.Length);=0D +=0D + ASSERT_EFI_ERROR (Status);=0D +=0D + // Reserve architectural PC MMIO regions=0D + // VGA space + BIOS shadow mapping=0D + ReserveMmioRegion (0xa0000, 0x100000 - 0xa0000);=0D + // IO APIC and LAPIC space=0D + ReserveMmioRegion (0xfec00000, 0xff000000 - 0xfec00000);=0D + return Status;=0D +}=0D diff --git a/Platform/Qemu/QemuOpenBoardPkg/PlatformInitPei/Pci.c b/Platfor= m/Qemu/QemuOpenBoardPkg/PlatformInitPei/Pci.c new file mode 100644 index 000000000000..a66cbf6005fb --- /dev/null +++ b/Platform/Qemu/QemuOpenBoardPkg/PlatformInitPei/Pci.c @@ -0,0 +1,59 @@ +/** @file Pci.c=0D + PCI Initialization for PIIX4 QEMU=0D +=0D + Copyright (c) 2022 Th=C3=A9o Jehl All rights reserved.=0D + SPDX-License-Identifier: BSD-2-Clause-Patent=0D +**/=0D +=0D +#include "PlatformInit.h"=0D +#include =0D +#include =0D +#include =0D +#include =0D +#include =0D +#include =0D +#include =0D +#include =0D +#include =0D +=0D +/**=0D + Initialize PCI support for QEMU PIIX4 machine=0D +=0D + It also publishes PCI MMIO and IO ranges PCDs for OVMF PciHostBridgeLib= =0D +=0D + @retval EFI_SUCCESS Initialization was a success=0D + @retval EFI_UNSUPPORTED Initialization failed (Memory below 4Gb probing = failed)=0D +**/=0D +EFI_STATUS=0D +EFIAPI=0D +InitializePciPIIX4 (=0D + VOID=0D + )=0D +{=0D + UINTN PciIoBase;=0D + UINTN PciIoSize;=0D + UINTN PciMmio32Base;=0D + UINTN PciMmio32Size;=0D +=0D + PciIoBase =3D PIIX4_PCI_IO_BASE;=0D + PciIoSize =3D PIIX4_PCI_IO_SIZE;=0D +=0D + PcdSet64S (PcdPciIoBase, PciIoBase);=0D + PcdSet64S (PcdPciIoSize, PciIoSize);=0D +=0D + PciMmio32Base =3D (UINTN) GetMemoryBelow4Gb ();=0D +=0D + if (PciMmio32Base =3D=3D 0) {=0D + DEBUG ((DEBUG_ERROR, "Unable to detect memory below 4Gb\n"));=0D + ASSERT (PciMmio32Base !=3D 0);=0D + return EFI_UNSUPPORTED;=0D + }=0D +=0D + DEBUG ((DEBUG_ERROR, "Memory below 4Gb: %x \n", PciMmio32Base));=0D + PciMmio32Size =3D PCI_MMIO_TOP_ADDRESS - PciMmio32Base;=0D +=0D + PcdSet64S (PcdPciMmio32Base, PciMmio32Base);=0D + PcdSet64S (PcdPciMmio32Size, PciMmio32Size);=0D +=0D + return EFI_SUCCESS;=0D +}=0D diff --git a/Platform/Qemu/QemuOpenBoardPkg/PlatformInitPei/Pcie.c b/Platfo= rm/Qemu/QemuOpenBoardPkg/PlatformInitPei/Pcie.c new file mode 100644 index 000000000000..a61fd6447e91 --- /dev/null +++ b/Platform/Qemu/QemuOpenBoardPkg/PlatformInitPei/Pcie.c @@ -0,0 +1,91 @@ +/** @file Pcie.c=0D + PCI Express initialization for QEMU Q35=0D +=0D + Copyright (c) 2022 Th=C3=A9o Jehl All rights reserved.=0D + SPDX-License-Identifier: BSD-2-Clause-Patent=0D +**/=0D +=0D +#include "PlatformInit.h"=0D +#include =0D +#include =0D +#include =0D +#include =0D +#include =0D +#include =0D +#include =0D +#include =0D +#include =0D +#include =0D +#include =0D +=0D +/**=0D + Initialize PCI Express support for QEMU Q35 system=0D + It also publishes PCI MMIO and IO ranges PCDs for OVMF PciHostBridgeLib= =0D + @retval EFI_SUCCESS Initialization was successful=0D +**/=0D +EFI_STATUS=0D +EFIAPI=0D +InitializePcie (=0D + VOID=0D + )=0D +{=0D + UINTN PciBase;=0D + UINTN PciSize;=0D + UINTN PciIoBase;=0D + UINTN PciIoSize;=0D +=0D + union {=0D + UINT64 Uint64;=0D + UINT32 Uint32[2];=0D + } PciExBarBase;=0D +=0D + PciExBarBase.Uint64 =3D FixedPcdGet64 (PcdPciExpressBaseAddress);=0D +=0D + // Build a reserved memory space for PCIE MMIO=0D + BuildResourceDescriptorHob (=0D + EFI_RESOURCE_MEMORY_RESERVED,=0D + EFI_RESOURCE_ATTRIBUTE_PRESENT |=0D + EFI_RESOURCE_ATTRIBUTE_INITIALIZED |=0D + EFI_RESOURCE_ATTRIBUTE_UNCACHEABLE |=0D + EFI_RESOURCE_ATTRIBUTE_TESTED,=0D + PciExBarBase.Uint64,=0D + SIZE_256MB=0D + );=0D +=0D + BuildMemoryAllocationHob (=0D + PciExBarBase.Uint64,=0D + SIZE_256MB,=0D + EfiReservedMemoryType=0D + );=0D +=0D + // Clear lower 32 bits of register=0D + PciWrite32 (DRAMC_REGISTER_Q35 (MCH_PCIEXBAR_LOW), 0);=0D +=0D + // Program PCIE MMIO Base address in MCH PCIEXBAR register=0D + PciWrite32 (DRAMC_REGISTER_Q35 (MCH_PCIEXBAR_HIGH), PciExBarBase.Uint32[= 1]);=0D +=0D + // Enable 256Mb MMIO space=0D + PciWrite32 (=0D + DRAMC_REGISTER_Q35 (MCH_PCIEXBAR_LOW),=0D + PciExBarBase.Uint32[0] | MCH_PCIEXBAR_BUS_FF | MCH_PCIEXBAR_EN=0D + );=0D +=0D + // Disable Pci MMIO above 4Gb=0D + PcdSet64S (PcdPciMmio64Size, 0);=0D +=0D + // Set Pci MMIO space below 4GB=0D + PciBase =3D (UINTN) (PcdGet64 (PcdPciExpressBaseAddress) + SIZE_256MB);= =0D + PciSize =3D PCI_MMIO_TOP_ADDRESS - PciBase;=0D +=0D + PcdSet64S (PcdPciMmio32Base, PciBase);=0D + PcdSet64S (PcdPciMmio32Size, PciSize);=0D +=0D + // Set Pci IO port range=0D + PciIoBase =3D Q35_PCI_IO_BASE;=0D + PciIoSize =3D Q35_PCI_IO_SIZE;=0D +=0D + PcdSet64S (PcdPciIoBase, PciIoBase);=0D + PcdSet64S (PcdPciIoSize, PciIoSize);=0D +=0D + return EFI_SUCCESS;=0D +}=0D diff --git a/Platform/Qemu/QemuOpenBoardPkg/PlatformInitPei/PlatformInit.c = b/Platform/Qemu/QemuOpenBoardPkg/PlatformInitPei/PlatformInit.c new file mode 100644 index 000000000000..f69518301cd2 --- /dev/null +++ b/Platform/Qemu/QemuOpenBoardPkg/PlatformInitPei/PlatformInit.c @@ -0,0 +1,67 @@ +/** @file PlarformInit.c=0D + Platform initialization PEIM for QEMU=0D +=0D + Copyright (c) 2022 Th=C3=A9o Jehl All rights reserved.=0D + SPDX-License-Identifier: BSD-2-Clause-Patent=0D +**/=0D +=0D +#include "PlatformInit.h"=0D +#include =0D +#include =0D +#include "Library/DebugLib.h"=0D +#include =0D +#include =0D +#include =0D +#include =0D +#include =0D +#include =0D +#include =0D +=0D +EFI_STATUS=0D +EFIAPI=0D +PlatformInit (=0D + IN EFI_PEI_FILE_HANDLE FileHandle,=0D + IN CONST EFI_PEI_SERVICES **PeiServices=0D + )=0D +{=0D + EFI_STATUS Status;=0D + UINT16 DeviceId;=0D + EFI_HOB_PLATFORM_INFO *EfiPlatformInfo;=0D +=0D + // Install permanent memory=0D + Status =3D InstallMemory (PeiServices);=0D +=0D + if (EFI_ERROR (Status)) {=0D + DEBUG ((DEBUG_ERROR, "Memory installation failed\n"));=0D + return Status;=0D + } else {=0D + DEBUG ((DEBUG_INFO, "Memory installation success\n"));=0D + }=0D +=0D + // Report CPU core count to MPInitLib=0D + MaxCpuInit ();=0D +=0D + EfiPlatformInfo =3D AllocateZeroPool (sizeof (EFI_HOB_PLATFORM_INFO));=0D + if (EfiPlatformInfo =3D=3D NULL) {=0D + DEBUG ((DEBUG_ERROR, "Failed to allocate pool for EFI_HOB_PLATFORM_INF= O\n"));=0D + return EFI_UNSUPPORTED;=0D + }=0D +=0D + // Report gUefiOvmfPkgPlatformInfo HOB with only the necessary data for = OVMF=0D + DeviceId =3D PciCf8Read16 (PCI_CF8_LIB_ADDRESS (0, 0, 0, PCI_DEVICE_ID_O= FFSET));=0D + DEBUG ((DEBUG_INFO, "Building gUefiOvmfPkgPlatformInfoGuid with Host bri= dge dev ID %x \n", DeviceId));=0D + (*EfiPlatformInfo).HostBridgeDevId =3D DeviceId;=0D +=0D + BuildGuidDataHob (&gUefiOvmfPkgPlatformInfoGuid, EfiPlatformInfo, sizeof= (EFI_HOB_PLATFORM_INFO));=0D +=0D + PcdSet16S (PcdOvmfHostBridgePciDevId, DeviceId);=0D +=0D + // Initialize PCI or PCIe based on current emulated system=0D + if (DeviceId =3D=3D INTEL_Q35_MCH_DEVICE_ID) {=0D + DEBUG ((DEBUG_INFO, "Q35: Initialize PCIe\n"));=0D + return InitializePcie ();=0D + } else {=0D + DEBUG ((DEBUG_INFO, "PIIX4: Initialize PCI\n"));=0D + return InitializePciPIIX4 ();=0D + }=0D +}=0D diff --git a/Platform/Qemu/QemuOpenBoardPkg/Include/Fdf/FlashMap.fdf.inc b/= Platform/Qemu/QemuOpenBoardPkg/Include/Fdf/FlashMap.fdf.inc new file mode 100644 index 000000000000..29f49f914171 --- /dev/null +++ b/Platform/Qemu/QemuOpenBoardPkg/Include/Fdf/FlashMap.fdf.inc @@ -0,0 +1,85 @@ +## @file=0D +# Flashmap and variable definitions for QemuOpenBoardPkg FVs and FD=0D +#=0D +# @copyright=0D +# Copyright (C) 2022 Jehl Th=C3=A9o=0D +#=0D +# SPDX-License-Identifier: BSD-2-Clause-Patent=0D +##=0D +=0D +#=0D +# These three items are tightly coupled.=0D +# The spare area size must be >=3D the first two areas.=0D +# The total size must match the size in the EFI_FIRMWARE_VOLUME_HEADER.=0D +# The NvStorageVariableSize must also match the VARIABLE_STORE_HEADER size= .=0D +# The EFI_FAULT_TOLERANT_WORKING_BLOCK_HEADER doesn't have size info.=0D +#=0D +# There isn't really a benefit to a larger spare area unless the FLASH dev= ice=0D +# block size is larger than the size specified.=0D +#=0D +SET gEfiMdeModulePkgTokenSpaceGuid.PcdFlashNvStorageVariableSize =3D 0x= 0003C000=0D +SET gEfiMdeModulePkgTokenSpaceGuid.PcdFlashNvStorageFtwWorkingSize =3D 0x= 00004000=0D +SET gEfiMdeModulePkgTokenSpaceGuid.PcdFlashNvStorageFtwSpareSize =3D gE= fiMdeModulePkgTokenSpaceGuid.PcdFlashNvStorageVariableSize + gEfiMdeModuleP= kgTokenSpaceGuid.PcdFlashNvStorageFtwWorkingSize=0D +=0D +#=0D +# Early FV=0D +#=0D +SET gMinPlatformPkgTokenSpaceGuid.PcdFlashFvPreMemorySize =3D 0x= 00081000=0D +SET gMinPlatformPkgTokenSpaceGuid.PcdFlashFvBspPreMemorySize =3D 0x= 00040000=0D +SET gMinPlatformPkgTokenSpaceGuid.PcdFlashFvFspTSize =3D 0x= 00010000=0D +SET gMinPlatformPkgTokenSpaceGuid.PcdFlashFvFspMSize =3D 0x= 00040000=0D +SET gMinPlatformPkgTokenSpaceGuid.PcdFlashFvFspSSize =3D 0x= 00020000=0D +SET gMinPlatformPkgTokenSpaceGuid.PcdFlashFvPostMemorySize =3D 0x= 00080000=0D +SET gMinPlatformPkgTokenSpaceGuid.PcdFlashFvBspSize =3D 0x= 00020000=0D +=0D +#=0D +# Later FV=0D +#=0D +SET gMinPlatformPkgTokenSpaceGuid.PcdFlashFvUefiBootSize =3D 0x= 00400000=0D +SET gMinPlatformPkgTokenSpaceGuid.PcdFlashFvOsBootSize =3D 0x= 00100000=0D +SET gMinPlatformPkgTokenSpaceGuid.PcdFlashFvSecuritySize =3D 0x= 00080000=0D +SET gMinPlatformPkgTokenSpaceGuid.PcdFlashFvAdvancedSize =3D gM= inPlatformPkgTokenSpaceGuid.PcdFlashAreaSize - gEfiMdeModulePkgTokenSpaceGu= id.PcdFlashNvStorageVariableSize - gEfiMdeModulePkgTokenSpaceGuid.PcdFlashN= vStorageFtwWorkingSize - gEfiMdeModulePkgTokenSpaceGuid.PcdFlashNvStorageFt= wSpareSize - gMinPlatformPkgTokenSpaceGuid.PcdFlashFvPreMemorySize - gMinPl= atformPkgTokenSpaceGuid.PcdFlashFvBspSize - gMinPlatformPkgTokenSpaceGuid.P= cdFlashFvPostMemorySize - gMinPlatformPkgTokenSpaceGuid.PcdFlashFvFspSSize = - gMinPlatformPkgTokenSpaceGuid.PcdFlashFvFspMSize - gMinPlatformPkgTokenSp= aceGuid.PcdFlashFvFspTSize - gMinPlatformPkgTokenSpaceGuid.PcdFlashFvBspPre= MemorySize - gMinPlatformPkgTokenSpaceGuid.PcdFlashFvUefiBootSize - gMinPla= tformPkgTokenSpaceGuid.PcdFlashFvOsBootSize - gMinPlatformPkgTokenSpaceGuid= .PcdFlashFvSecuritySize=0D +=0D +#=0D +# Calculate Offsets Once (Do not modify)=0D +# This layout is specified by the EDK II Minimum Platform Archicture speci= fication.=0D +# Each offset is the prior region's offset plus the prior region's size.=0D +#=0D +=0D +SET gMinPlatformPkgTokenSpaceGuid.PcdFlashNvStorageVariableOffset =3D 0x= 00000000=0D +SET gMinPlatformPkgTokenSpaceGuid.PcdFlashNvStorageFtwWorkingOffset =3D gM= inPlatformPkgTokenSpaceGuid.PcdFlashNvStorageVariableOffset + gEfiMdeModu= lePkgTokenSpaceGuid.PcdFlashNvStorageVariableSize=0D +SET gMinPlatformPkgTokenSpaceGuid.PcdFlashNvStorageFtwSpareOffset =3D gM= inPlatformPkgTokenSpaceGuid.PcdFlashNvStorageFtwWorkingOffset + gEfiMdeModu= lePkgTokenSpaceGuid.PcdFlashNvStorageFtwWorkingSize=0D +=0D +SET gMinPlatformPkgTokenSpaceGuid.PcdFlashFvAdvancedOffset =3D gM= inPlatformPkgTokenSpaceGuid.PcdFlashNvStorageFtwSpareOffset + gEfiMdeModu= lePkgTokenSpaceGuid.PcdFlashNvStorageFtwSpareSize=0D +SET gMinPlatformPkgTokenSpaceGuid.PcdFlashFvSecurityOffset =3D gM= inPlatformPkgTokenSpaceGuid.PcdFlashFvAdvancedOffset + gMinPlatfor= mPkgTokenSpaceGuid.PcdFlashFvAdvancedSize=0D +SET gMinPlatformPkgTokenSpaceGuid.PcdFlashFvOsBootOffset =3D gM= inPlatformPkgTokenSpaceGuid.PcdFlashFvSecurityOffset + gMinPlatfor= mPkgTokenSpaceGuid.PcdFlashFvSecuritySize=0D +SET gMinPlatformPkgTokenSpaceGuid.PcdFlashFvUefiBootOffset =3D gM= inPlatformPkgTokenSpaceGuid.PcdFlashFvOsBootOffset + gMinPlatfor= mPkgTokenSpaceGuid.PcdFlashFvOsBootSize=0D +=0D +SET gMinPlatformPkgTokenSpaceGuid.PcdFlashFvBspOffset =3D gM= inPlatformPkgTokenSpaceGuid.PcdFlashFvUefiBootOffset + gMinPlatfor= mPkgTokenSpaceGuid.PcdFlashFvUefiBootSize=0D +SET gMinPlatformPkgTokenSpaceGuid.PcdFlashFvPostMemoryOffset =3D gM= inPlatformPkgTokenSpaceGuid.PcdFlashFvBspOffset + gMinPlatfor= mPkgTokenSpaceGuid.PcdFlashFvBspSize=0D +SET gMinPlatformPkgTokenSpaceGuid.PcdFlashFvFspSOffset =3D gM= inPlatformPkgTokenSpaceGuid.PcdFlashFvPostMemoryOffset + gMinPlatfor= mPkgTokenSpaceGuid.PcdFlashFvPostMemorySize=0D +SET gMinPlatformPkgTokenSpaceGuid.PcdFlashFvFspMOffset =3D gM= inPlatformPkgTokenSpaceGuid.PcdFlashFvFspSOffset + gMinPlatfor= mPkgTokenSpaceGuid.PcdFlashFvFspSSize=0D +SET gMinPlatformPkgTokenSpaceGuid.PcdFlashFvFspTOffset =3D gM= inPlatformPkgTokenSpaceGuid.PcdFlashFvFspMOffset + gMinPlatfor= mPkgTokenSpaceGuid.PcdFlashFvFspMSize=0D +SET gMinPlatformPkgTokenSpaceGuid.PcdFlashFvBspPreMemoryOffset =3D gM= inPlatformPkgTokenSpaceGuid.PcdFlashFvFspTOffset + gMinPlatfor= mPkgTokenSpaceGuid.PcdFlashFvFspTSize=0D +SET gMinPlatformPkgTokenSpaceGuid.PcdFlashFvPreMemoryOffset =3D gM= inPlatformPkgTokenSpaceGuid.PcdFlashFvBspPreMemoryOffset + gMinPlatfor= mPkgTokenSpaceGuid.PcdFlashFvBspPreMemorySize=0D +=0D +#=0D +# Calculate base addresses=0D +#=0D +=0D +SET gEfiMdeModulePkgTokenSpaceGuid.PcdFlashNvStorageFtwSpareBase =3D gM= inPlatformPkgTokenSpaceGuid.PcdFlashAreaBaseAddress=0D +SET gEfiMdeModulePkgTokenSpaceGuid.PcdFlashNvStorageFtwWorkingBase =3D gE= fiMdeModulePkgTokenSpaceGuid.PcdFlashNvStorageFtwSpareBase + gEfiMdeModu= lePkgTokenSpaceGuid.PcdFlashNvStorageFtwSpareSize=0D +SET gEfiMdeModulePkgTokenSpaceGuid.PcdFlashNvStorageVariableBase =3D gE= fiMdeModulePkgTokenSpaceGuid.PcdFlashNvStorageFtwWorkingBase + gEfiMdeModu= lePkgTokenSpaceGuid.PcdFlashNvStorageFtwWorkingSize=0D +=0D +SET gMinPlatformPkgTokenSpaceGuid.PcdFlashFvAdvancedBase =3D gM= inPlatformPkgTokenSpaceGuid.PcdFlashAreaBaseAddress + gMinPlatfor= mPkgTokenSpaceGuid.PcdFlashFvAdvancedOffset=0D +SET gMinPlatformPkgTokenSpaceGuid.PcdFlashFvSecurityBase =3D gM= inPlatformPkgTokenSpaceGuid.PcdFlashFvAdvancedBase + gMinPlatfor= mPkgTokenSpaceGuid.PcdFlashFvAdvancedSize=0D +SET gMinPlatformPkgTokenSpaceGuid.PcdFlashFvOsBootBase =3D gM= inPlatformPkgTokenSpaceGuid.PcdFlashFvSecurityBase + gMinPlatfor= mPkgTokenSpaceGuid.PcdFlashFvSecuritySize=0D +SET gMinPlatformPkgTokenSpaceGuid.PcdFlashFvUefiBootBase =3D gM= inPlatformPkgTokenSpaceGuid.PcdFlashFvOsBootBase + gMinPlatfor= mPkgTokenSpaceGuid.PcdFlashFvOsBootSize=0D +=0D +SET gMinPlatformPkgTokenSpaceGuid.PcdFlashFvBspBase =3D gM= inPlatformPkgTokenSpaceGuid.PcdFlashFvUefiBootBase + gMinPlatfor= mPkgTokenSpaceGuid.PcdFlashFvUefiBootSize=0D +SET gMinPlatformPkgTokenSpaceGuid.PcdFlashFvPostMemoryBase =3D gM= inPlatformPkgTokenSpaceGuid.PcdFlashFvBspBase + gMinPlatfor= mPkgTokenSpaceGuid.PcdFlashFvBspSize=0D +SET gMinPlatformPkgTokenSpaceGuid.PcdFlashFvFspSBase =3D gM= inPlatformPkgTokenSpaceGuid.PcdFlashFvPostMemoryBase + gMinPlatfor= mPkgTokenSpaceGuid.PcdFlashFvPostMemorySize=0D +SET gMinPlatformPkgTokenSpaceGuid.PcdFlashFvFspMBase =3D gM= inPlatformPkgTokenSpaceGuid.PcdFlashFvFspSBase + gMinPlatfor= mPkgTokenSpaceGuid.PcdFlashFvFspSSize=0D +SET gMinPlatformPkgTokenSpaceGuid.PcdFlashFvFspTBase =3D gM= inPlatformPkgTokenSpaceGuid.PcdFlashFvFspMBase + gMinPlatfor= mPkgTokenSpaceGuid.PcdFlashFvFspMSize=0D +SET gMinPlatformPkgTokenSpaceGuid.PcdFlashFvBspPreMemoryBase =3D gM= inPlatformPkgTokenSpaceGuid.PcdFlashFvFspTBase + gMinPlatfor= mPkgTokenSpaceGuid.PcdFlashFvFspTSize=0D +SET gMinPlatformPkgTokenSpaceGuid.PcdFlashFvPreMemoryBase =3D gM= inPlatformPkgTokenSpaceGuid.PcdFlashFvBspPreMemoryBase + gMinPlatfor= mPkgTokenSpaceGuid.PcdFlashFvBspPreMemorySize=0D diff --git a/Platform/Qemu/QemuOpenBoardPkg/Library/PlatformSecLib/Ia32/Sec= Entry.nasm b/Platform/Qemu/QemuOpenBoardPkg/Library/PlatformSecLib/Ia32/Sec= Entry.nasm new file mode 100644 index 000000000000..bd90a466f790 --- /dev/null +++ b/Platform/Qemu/QemuOpenBoardPkg/Library/PlatformSecLib/Ia32/SecEntry.n= asm @@ -0,0 +1,117 @@ +;-------------------------------------------------------------------------= -----=0D +; @file SecEntry=0D +; Sec entry implementation=0D +;=0D +; Copyright (c) 2022 Th=C3=A9o Jehl=0D +; SPDX-License-Identifier: BSD-2-Clause-Patent=0D +;=0D +;-------------------------------------------------------------------------= -----=0D +=0D +CODE_SEG equ CodeSegDescriptor - GDT_START=0D +DATA_SEG equ DataSegDescriptor - GDT_START=0D +=0D +extern ASM_PFX(SecStartup)=0D +=0D +extern ASM_PFX(PcdGet32 (PcdTemporaryRamBase))=0D +extern ASM_PFX(PcdGet32 (PcdTemporaryRamSize))=0D +=0D +SECTION .text=0D +=0D +BITS 16=0D +align 4=0D +global ASM_PFX(_ModuleEntryPoint)=0D +ASM_PFX(_ModuleEntryPoint):=0D + cli=0D + ; Save the BIST in mm0=0D + movd mm0, eax=0D + mov esi, GDT_Descriptor=0D + db 66h=0D + lgdt [cs:si]=0D +=0D + mov eax, cr0=0D + or eax, 1=0D + mov cr0, eax=0D +=0D + mov ax, DATA_SEG=0D + mov ds, ax=0D + mov es, ax=0D + mov fs, ax=0D + mov gs, ax=0D + mov ss, ax=0D +=0D + mov esi, ProtectedModeEntryLinearAddress=0D +=0D + jmp dword far [cs:si]=0D +=0D +BITS 32=0D +align 4=0D +ProtectedModeEntry:=0D + PROTECTED_MODE equ $=0D +=0D + mov ecx, DWORD [ASM_PFX(PcdGet32 (PcdTemporaryRamBase))]=0D + mov edx, DWORD [ASM_PFX(PcdGet32 (PcdTemporaryRamSize))]=0D +=0D + ;Initialize the stack at the end of base + size=0D + mov esp, ecx=0D + add esp, edx=0D +=0D + ; TODO: Multiprocessor support=0D + push 1=0D + ; For now, we push the BIST once=0D + movd eax, mm0=0D + push eax=0D + ; Code in PlatformSecLib will look up this information we've just pushed= =0D + ; =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D TOP OF MEMORY =3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=0D + ; Count of BISTs=0D + ; BISTs[1..n]=0D + ; =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D REST OF MEMORY = =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=0D + ; Each BIST is always a DWORD in size=0D +=0D + mov edi, 0xFFFFFFFC ;BFV=0D +=0D + push DWORD [edi] ;Passes BFV=0D +=0D + push ecx ;Passes RAM size=0D +=0D + push edx ;Passes RAM base=0D +=0D + call ASM_PFX(SecStartup)=0D +=0D +align 8=0D +NULL_SEGMENT equ $ - GDT_START=0D +GDT_START:=0D +=0D +NullSegDescriptor:=0D + dd 0x0=0D + dd 0x0=0D +=0D + CODE_SEL equ $ - GDT_START=0D +=0D +CodeSegDescriptor:=0D + dw 0xFFFF=0D + dw 0x0=0D + db 0x0=0D + db 0x9B=0D + db 0xCF=0D + db 0x0=0D +=0D + DATA_SEL equ $ - GDT_START=0D +=0D +DataSegDescriptor:=0D + dw 0xFFFF=0D + dw 0x0=0D + db 0x0=0D + db 0x93=0D + db 0xCF=0D + db 0x0=0D +=0D +GDT_END:=0D +=0D +GDT_Descriptor:=0D + dw GDT_END - GDT_START - 1=0D + dd GDT_START=0D +=0D +ProtectedModeEntryLinearAddress:=0D +ProtectedModeEntryLinear:=0D + DD ProtectedModeEntry ; Offset of our 32 bit code=0D + DW CODE_SEL=0D diff --git a/Platform/Qemu/QemuOpenBoardPkg/README.md b/Platform/Qemu/QemuO= penBoardPkg/README.md new file mode 100644 index 000000000000..e1238c1f4e3e --- /dev/null +++ b/Platform/Qemu/QemuOpenBoardPkg/README.md @@ -0,0 +1,53 @@ +# QemuOpenBoardPkg=0D +=0D +This project brings UEFI support to QEMU x86_64 following the MinPlatform = specification.=0D +=0D +## Capabilities=0D +=0D +- Supports IA-32 and hybrid X64 (IA32 PEI Core and X64 DXE Core)=0D +- Modern QEMU (Tested on 7.0.0)=0D + - PIIX4 and Q35 machines=0D +- Boot UEFI Linux=0D +- Boot UEFI Windows=0D +=0D +## How to build=0D +=0D +### Pre-requesites=0D +=0D +- EDK2=0D + - How to setup a local tree: https://github.com/tianocore/tianocore.gith= ub.io/wiki/Getting-Started-with-EDK-II=0D +=0D +- EDK2 Platforms=0D + - https://github.com/tianocore/edk2-platforms=0D +=0D +- Environnements variables:=0D + - WORKSPACE set to your current workspace=0D + - PACKAGES_PATH should contain path to:=0D + - edk2=0D + - edk2-platforms=0D + - edk2-platforms/Platform/Intel=0D + - edk2-platforms/Platform/Qemu=0D + - edk2-platforms/Silicon/Intel=0D +=0D +Currently QemuOpenBoardPkg's PEI Core is 32 bits only, DXE supports either= 32 bits or 64 bits=0D +=0D +QemuOpenBoardPkg (IA32 PEI - IA32 DXE)=0D +=0D +```build -a IA32 -D PEI_ARCH=3DIA32 -D DXE_ARCH=3DIA32```=0D +=0D +QemuOpenBoardPkg (IA32 PEI - X64 DXE)=0D +=0D +```build -a IA32 -a X64 -D PEI_ARCH=3DIA32 -D DXE_ARCH=3DX64```=0D +=0D +## How to use=0D +=0D +Using qemu-system-x86_64, use=0D +=0D +```-bios ```=0D +=0D +To redirect serial output to the console=0D +=0D +```-serial stdio```=0D +=0D +## Important notes=0D +- Secure boot is not yet available due to QemuOpenBoardPkg NVRAM storage n= ot being persistent yet.=0D --=20 2.32.1 (Apple Git-133)