public inbox for devel@edk2.groups.io
 help / color / mirror / Atom feed
From: "Théo Jehl" <theojehl76@gmail.com>
To: devel@edk2.groups.io
Cc: Leif Lindholm <quic_llindhol@quicinc.com>,
	Michael D Kinney <michael.d.kinney@intel.com>,
	Isaac Oram <isaac.w.oram@intel.com>,
	Pedro Falcato <pedro.falcato@gmail.com>,
	Gerd Hoffmann <kraxel@redhat.com>,
	Stefan Hajnoczi <stefanha@gmail.com>
Subject: [[edk2-platforms] Patch V2 4/4] QemuOpenBoardPkg: Enable stage 4
Date: Fri,  9 Sep 2022 13:15:04 +0200	[thread overview]
Message-ID: <20220909111504.1661-5-theojehl76@gmail.com> (raw)
In-Reply-To: <20220909111504.1661-1-theojehl76@gmail.com>

Enable MinPlatform stage 4 (OS boot) functionality.
It adds ACPI, SMBIOS and SMM drivers required for stage 4.
This should boot Windows and Linux with PIIX4 or Q35 configurations.
In the current state, SMM only works on Qemu Q35 system if you set
SMM_REQUIRED = TRUE in QemuOpenBoardPkg.dsc or via command-line.

Cc: Leif Lindholm <quic_llindhol@quicinc.com>
Cc: Michael D Kinney <michael.d.kinney@intel.com>
Cc: Isaac Oram <isaac.w.oram@intel.com>
Cc: Pedro Falcato <pedro.falcato@gmail.com>
Cc: Gerd Hoffmann <kraxel@redhat.com>
Cc: Stefan Hajnoczi <stefanha@gmail.com>

Signed-off-by: Théo Jehl <theojehl76@gmail.com>
---
 Platform/Qemu/QemuOpenBoardPkg/Include/Dsc/Stage4.dsc.inc         | 56 ++++++++
 Platform/Qemu/QemuOpenBoardPkg/QemuOpenBoardPkg.dsc               | 14 +-
 Platform/Qemu/QemuOpenBoardPkg/QemuOpenBoardPkg.fdf               | 66 ++++++++++
 Platform/Qemu/QemuOpenBoardPkg/Include/Library/QemuOpenFwCfgLib.h | 10 +-
 4 files changed, 139 insertions(+), 7 deletions(-)

diff --git a/Platform/Qemu/QemuOpenBoardPkg/Include/Dsc/Stage4.dsc.inc b/Platform/Qemu/QemuOpenBoardPkg/Include/Dsc/Stage4.dsc.inc
new file mode 100644
index 000000000000..369416db72b6
--- /dev/null
+++ b/Platform/Qemu/QemuOpenBoardPkg/Include/Dsc/Stage4.dsc.inc
@@ -0,0 +1,56 @@
+## @file
+# Common DSC content to begin Stage 4 enabling
+#
+# @copyright
+# Copyright (C) 2022 Théo Jehl
+#
+# SPDX-License-Identifier: BSD-2-Clause-Patent
+##
+
+
+[LibraryClasses]
+  !if $(SMM_REQUIRED) == TRUE
+    SpiFlashCommonLib     | IntelSiliconPkg/Library/SmmSpiFlashCommonLib/SmmSpiFlashCommonLib.inf
+  !endif
+
+[LibraryClasses.Common.DXE_SMM_DRIVER]
+  LockBoxLib              | MdeModulePkg/Library/SmmLockBoxLib/SmmLockBoxSmmLib.inf
+  SmmCpuPlatformHookLib   | OvmfPkg/Library/SmmCpuPlatformHookLibQemu/SmmCpuPlatformHookLibQemu.inf
+  SmmCpuFeaturesLib       | OvmfPkg/Library/SmmCpuFeaturesLib/SmmCpuFeaturesLib.inf
+
+[Components.$(DXE_ARCH)]
+  OvmfPkg/AcpiPlatformDxe/AcpiPlatformDxe.inf
+  MdeModulePkg/Universal/Acpi/AcpiTableDxe/AcpiTableDxe.inf
+  OvmfPkg/SataControllerDxe/SataControllerDxe.inf
+  MdeModulePkg/Bus/Ata/AtaAtapiPassThru/AtaAtapiPassThru.inf
+  MdeModulePkg/Bus/Ata/AtaBusDxe/AtaBusDxe.inf
+  MdeModulePkg/Bus/Pci/UhciDxe/UhciDxe.inf
+  MdeModulePkg/Bus/Pci/EhciDxe/EhciDxe.inf
+  MdeModulePkg/Bus/Pci/XhciDxe/XhciDxe.inf
+  MdeModulePkg/Bus/Usb/UsbBusDxe/UsbBusDxe.inf
+  MdeModulePkg/Bus/Usb/UsbKbDxe/UsbKbDxe.inf
+
+  !if $(SMM_REQUIRED) == TRUE
+    OvmfPkg/SmmAccess/SmmAccess2Dxe.inf
+    OvmfPkg/SmmControl2Dxe/SmmControl2Dxe.inf
+    MdeModulePkg/Core/PiSmmCore/PiSmmIpl.inf
+    MdeModulePkg/Core/PiSmmCore/PiSmmCore.inf
+
+    MdeModulePkg/Universal/LockBox/SmmLockBox/SmmLockBox.inf
+    UefiCpuPkg/PiSmmCpuDxeSmm/PiSmmCpuDxeSmm.inf
+
+    MdeModulePkg/Universal/ReportStatusCodeRouter/Smm/ReportStatusCodeRouterSmm.inf
+    MdeModulePkg/Universal/StatusCodeHandler/Smm/StatusCodeHandlerSmm.inf
+    UefiCpuPkg/CpuIo2Smm/CpuIo2Smm.inf
+    MdeModulePkg/Universal/FaultTolerantWriteDxe/FaultTolerantWriteSmm.inf
+    IntelSiliconPkg/Feature/Flash/SpiFvbService/SpiFvbServiceSmm.inf
+  !endif
+
+  #
+  # SMBIOS Support
+  #
+  MdeModulePkg/Universal/SmbiosDxe/SmbiosDxe.inf {
+    <LibraryClasses>
+      NULL | OvmfPkg/Library/SmbiosVersionLib/DetectSmbiosVersionLib.inf
+  }
+  OvmfPkg/SmbiosPlatformDxe/SmbiosPlatformDxe.inf
diff --git a/Platform/Qemu/QemuOpenBoardPkg/QemuOpenBoardPkg.dsc b/Platform/Qemu/QemuOpenBoardPkg/QemuOpenBoardPkg.dsc
index 55c7c3e3cc00..13eeaac0cc05 100644
--- a/Platform/Qemu/QemuOpenBoardPkg/QemuOpenBoardPkg.dsc
+++ b/Platform/Qemu/QemuOpenBoardPkg/QemuOpenBoardPkg.dsc
@@ -38,7 +38,7 @@
   OvmfPkg/OvmfPkg.dec
 
 [PcdsFixedAtBuild]
-  gMinPlatformPkgTokenSpaceGuid.PcdBootStage                            | 3
+  gMinPlatformPkgTokenSpaceGuid.PcdBootStage                            | 4
 
   gEfiMdePkgTokenSpaceGuid.PcdDebugPrintErrorLevel                      | 0x802A00C7
   gEfiMdePkgTokenSpaceGuid.PcdFixedDebugPrintErrorLevel                 | 0x802A00C7
@@ -95,7 +95,7 @@
   gMinPlatformPkgTokenSpaceGuid.PcdTpm2Enable                           | FALSE
 
   !if $(SMM_REQUIRED) == TRUE
-    gUefiOvmfPkgTokenSpaceGuid.PcdSmmSmramRequire                       | FALSE
+    gUefiOvmfPkgTokenSpaceGuid.PcdSmmSmramRequire                       | TRUE
     gUefiCpuPkgTokenSpaceGuid.PcdCpuHotPlugSupport                      | FALSE
     gEfiMdeModulePkgTokenSpaceGuid.PcdEnableVariableRuntimeCache        | FALSE
   !endif
@@ -129,6 +129,7 @@
 !include QemuOpenBoardPkg/Include/Dsc/Stage1.dsc.inc
 !include QemuOpenBoardPkg/Include/Dsc/Stage2.dsc.inc
 !include QemuOpenBoardPkg/Include/Dsc/Stage3.dsc.inc
+!include QemuOpenBoardPkg/Include/Dsc/Stage4.dsc.inc
 
 [LibraryClasses.Common]
   QemuOpenFwCfgLib        | QemuOpenBoardPkg/Library/QemuOpenFwCfgLib/QemuOpenFwCfgLib.inf
@@ -153,3 +154,12 @@
   DebugLib                | OvmfPkg/Library/PlatformDebugLibIoPort/PlatformRomDebugLibIoPort.inf
 
 [Components.$(DXE_ARCH)]
+  MdeModulePkg/Bus/Scsi/ScsiBusDxe/ScsiBusDxe.inf
+  MdeModulePkg/Bus/Scsi/ScsiDiskDxe/ScsiDiskDxe.inf
+  OvmfPkg/SataControllerDxe/SataControllerDxe.inf
+  MdeModulePkg/Bus/Ata/AtaAtapiPassThru/AtaAtapiPassThru.inf
+  MdeModulePkg/Bus/Ata/AtaBusDxe/AtaBusDxe.inf
+  MdeModulePkg/Bus/Pci/NvmExpressDxe/NvmExpressDxe.inf
+  MdeModulePkg/Universal/DevicePathDxe/DevicePathDxe.inf
+  MdeModulePkg/Universal/Disk/DiskIoDxe/DiskIoDxe.inf
+  MdeModulePkg/Universal/Disk/PartitionDxe/PartitionDxe.inf
diff --git a/Platform/Qemu/QemuOpenBoardPkg/QemuOpenBoardPkg.fdf b/Platform/Qemu/QemuOpenBoardPkg/QemuOpenBoardPkg.fdf
index 8f14ad71c1f8..ea1547df32aa 100644
--- a/Platform/Qemu/QemuOpenBoardPkg/QemuOpenBoardPkg.fdf
+++ b/Platform/Qemu/QemuOpenBoardPkg/QemuOpenBoardPkg.fdf
@@ -220,6 +220,8 @@ SET gMinPlatformPkgTokenSpaceGuid.PcdFlashAreaSize             = 0x800000
   INF MdeModulePkg/Universal/SerialDxe/SerialDxe.inf
   INF MdeModulePkg/Bus/Pci/PciSioSerialDxe/PciSioSerialDxe.inf
 
+
+
 [FV.FvUefiBoot]
   !include MinPlatformPkg/Include/Fdf/CommonSpiFvHeaderInfo.fdf
   FvNameGuid    = D0C15ADB-FE38-4331-841C-0E96C1B0FBFA
@@ -232,15 +234,76 @@ SET gMinPlatformPkgTokenSpaceGuid.PcdFlashAreaSize             = 0x800000
     }
   }
 
+
 ###########################
 #
 # Stage 4 Firmware Volumes
 #
 ###########################
+[FV.FvOsBootUncompressed]
+  !include MinPlatformPkg/Include/Fdf/CommonSpiFvHeaderInfo.fdf
+  FvNameGuid    = 4bb59c22-e1b8-414e-9de8-559db4054c4c
+
+  INF OvmfPkg/QemuVideoDxe/QemuVideoDxe.inf
+
+  INF PcAtChipsetPkg/Bus/Pci/IdeControllerDxe/IdeControllerDxe.inf
+  INF MdeModulePkg/Universal/Disk/DiskIoDxe/DiskIoDxe.inf
+  INF MdeModulePkg/Universal/Disk/PartitionDxe/PartitionDxe.inf
+  INF FatPkg/EnhancedFatDxe/Fat.inf
+
+  INF MdeModulePkg/Bus/Isa/IsaBusDxe/IsaBusDxe.inf
+  INF MdeModulePkg/Bus/Isa/Ps2KeyboardDxe/Ps2KeyboardDxe.inf
+
+  # ACPI
+  INF MdeModulePkg/Universal/Acpi/AcpiTableDxe/AcpiTableDxe.inf
+  INF OvmfPkg/AcpiPlatformDxe/AcpiPlatformDxe.inf
+
+  # Buses
+
+  INF MdeModulePkg/Bus/Pci/UhciDxe/UhciDxe.inf
+  INF MdeModulePkg/Bus/Pci/EhciDxe/EhciDxe.inf
+  INF MdeModulePkg/Bus/Pci/XhciDxe/XhciDxe.inf
+  INF MdeModulePkg/Bus/Usb/UsbBusDxe/UsbBusDxe.inf
+  INF MdeModulePkg/Bus/Usb/UsbKbDxe/UsbKbDxe.inf
+
+  INF MdeModulePkg/Bus/Scsi/ScsiBusDxe/ScsiBusDxe.inf
+  INF MdeModulePkg/Bus/Scsi/ScsiDiskDxe/ScsiDiskDxe.inf
+
+  INF OvmfPkg/SataControllerDxe/SataControllerDxe.inf
+
+  INF MdeModulePkg/Bus/Ata/AtaAtapiPassThru/AtaAtapiPassThru.inf
+  INF MdeModulePkg/Bus/Ata/AtaBusDxe/AtaBusDxe.inf
+
+  INF MdeModulePkg/Bus/Pci/NvmExpressDxe/NvmExpressDxe.inf
+
+  !if $(SMM_REQUIRED) == TRUE
+      INF OvmfPkg/SmmAccess/SmmAccess2Dxe.inf
+      INF OvmfPkg/SmmControl2Dxe/SmmControl2Dxe.inf
+      INF MdeModulePkg/Core/PiSmmCore/PiSmmIpl.inf
+      INF MdeModulePkg/Core/PiSmmCore/PiSmmCore.inf
+      INF MdeModulePkg/Universal/LockBox/SmmLockBox/SmmLockBox.inf
+      INF MdeModulePkg/Universal/ReportStatusCodeRouter/Smm/ReportStatusCodeRouterSmm.inf
+      INF MdeModulePkg/Universal/StatusCodeHandler/Smm/StatusCodeHandlerSmm.inf
+      INF UefiCpuPkg/PiSmmCpuDxeSmm/PiSmmCpuDxeSmm.inf
+      INF UefiCpuPkg/CpuIo2Smm/CpuIo2Smm.inf
+      INF MdeModulePkg/Universal/FaultTolerantWriteDxe/FaultTolerantWriteSmm.inf
+      INF IntelSiliconPkg/Feature/Flash/SpiFvbService/SpiFvbServiceSmm.inf
+  !endif
+
+  INF MdeModulePkg/Universal/SmbiosDxe/SmbiosDxe.inf
+  INF OvmfPkg/SmbiosPlatformDxe/SmbiosPlatformDxe.inf
+
 [FV.FvOsBoot]
   !include MinPlatformPkg/Include/Fdf/CommonSpiFvHeaderInfo.fdf
   FvNameGuid    = AE8F0EA0-1614-422D-ABC1-C518596F1678
 
+   FILE FV_IMAGE = 4bb59c22-e1b8-414e-9de8-559db4054c4c {
+    SECTION GUIDED EE4E5898-3914-4259-9D6E-DC7BD79403CF PROCESSING_REQUIRED = TRUE {
+      SECTION FV_IMAGE = FvOsBootUncompressed
+    }
+  }
+
+
 ###########################
 #
 # Stage 5 Firmware Volumes
@@ -249,6 +312,9 @@ SET gMinPlatformPkgTokenSpaceGuid.PcdFlashAreaSize             = 0x800000
 [FV.FvSecurity]
   !include MinPlatformPkg/Include/Fdf/CommonSpiFvHeaderInfo.fdf
   FvNameGuid    = 1AE6AB90-9431-425B-9A92-ED2708A4E982
+  !include MinPlatformPkg/Include/Fdf/CoreSecurityLateInclude.fdf
+  !include MinPlatformPkg/Include/Fdf/CoreSecurityPreMemoryInclude.fdf
+
 
 ###########################
 #
diff --git a/Platform/Qemu/QemuOpenBoardPkg/Include/Library/QemuOpenFwCfgLib.h b/Platform/Qemu/QemuOpenBoardPkg/Include/Library/QemuOpenFwCfgLib.h
index 2d4690b660f5..a94228837b7a 100644
--- a/Platform/Qemu/QemuOpenBoardPkg/Include/Library/QemuOpenFwCfgLib.h
+++ b/Platform/Qemu/QemuOpenBoardPkg/Include/Library/QemuOpenFwCfgLib.h
@@ -89,17 +89,17 @@ QemuFwCfgReadBytes (
 /**
   Finds a file in fw_cfg by its name
 
-  @param[in] String Pointer to an ASCII string to match in the database
+  @param[in]  String Pointer to an ASCII string to match in the database
   @param[out] FWConfigFile Buffer for the config file
 
-  @return EFI_STATUS - Entry was found, FWConfigFile is populated
-  @return EFI_ERROR - Entry was not found
+  @return EFI_STATUS Entry was found, FWConfigFile is populated
+  @return EFI_ERROR Entry was not found
  */
 EFI_STATUS
 EFIAPI
 QemuFwCfgFindFile (
-  IN CHAR8              *String,
-  OUT QEMU_FW_CFG_FILE  *FWConfigFile
+  IN  CHAR8              *String,
+  OUT QEMU_FW_CFG_FILE   *FWConfigFile
   );
 
 #endif // QEMU_OPEN_BOARD_PKG_QEMU_FW_CFG_LIB_H_
-- 
2.32.1 (Apple Git-133)


  parent reply	other threads:[~2022-09-09 11:15 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-09-09 11:15 [[edk2-platforms] Patch V2 0/4] QemuOpenBoardPkg: Add QemuOpenBoardPkg Théo Jehl
2022-09-09 11:15 ` [[edk2-platforms] Patch V2 1/4] " Théo Jehl
2022-09-09 11:15 ` [[edk2-platforms] Patch V2 2/4] QemuOpenBoardPkg: Enable stage 2 Théo Jehl
2022-09-09 11:15 ` [[edk2-platforms] Patch V2 3/4] QemuOpenBoardPkg: Enable stage 3 Théo Jehl
2022-09-09 11:15 ` Théo Jehl [this message]
2022-09-09 14:10 ` [[edk2-platforms] Patch V2 0/4] QemuOpenBoardPkg: Add QemuOpenBoardPkg Isaac Oram

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-list from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20220909111504.1661-5-theojehl76@gmail.com \
    --to=devel@edk2.groups.io \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox