public inbox for devel@edk2.groups.io
 help / color / mirror / Atom feed
* [edk2-devel] [PATCH v2 1/4] UefiPayloadPkg/SblParseLib: Build SMM feature GUID HOBs from bootloader
@ 2023-12-11 22:39 Benjamin Doron
  2023-12-11 22:39 ` [edk2-devel] [PATCH v2 2/4] UefiPayloadPkg: Introduce coreboot FMAP parser library Benjamin Doron
                   ` (2 more replies)
  0 siblings, 3 replies; 4+ messages in thread
From: Benjamin Doron @ 2023-12-11 22:39 UTC (permalink / raw)
  To: devel; +Cc: Guo Dong, Ray Ni, Sean Rhodes, James Lu, Gua Guo

From: Benjamin Doron <benjamin.doron@9elements.com>

UefiPayload does not install all SBL HOBs, EDK2-relevant ones must be
installed individually. This was omitted from the SMM feature pushes.

Cc: Guo Dong <guo.dong@intel.com>
Cc: Ray Ni <ray.ni@intel.com>
Cc: Sean Rhodes <sean@starlabs.systems>
Cc: James Lu <james.lu@intel.com>
Cc: Gua Guo <gua.guo@intel.com>
Signed-off-by: Benjamin Doron <benjamin.doron@9elements.com>
---
 UefiPayloadPkg/Library/SblParseLib/SblParseLib.c   | 77 ++++++++++++++++++++
 UefiPayloadPkg/Library/SblParseLib/SblParseLib.inf |  5 ++
 2 files changed, 82 insertions(+)

diff --git a/UefiPayloadPkg/Library/SblParseLib/SblParseLib.c b/UefiPayloadPkg/Library/SblParseLib/SblParseLib.c
index d88238bfdccb..9775ad4ac2a6 100644
--- a/UefiPayloadPkg/Library/SblParseLib/SblParseLib.c
+++ b/UefiPayloadPkg/Library/SblParseLib/SblParseLib.c
@@ -15,6 +15,11 @@
 #include <Library/HobLib.h>
 #include <Library/BlParseLib.h>
 #include <IndustryStandard/Acpi.h>
+#include <Guid/SmmRegisterInfoGuid.h>
+#include <Guid/SmramMemoryReserve.h>
+#include <Guid/SpiFlashInfoGuid.h>
+#include <Guid/NvVariableInfoGuid.h>
+#include <Guid/SmmS3CommunicationInfoGuid.h>
 #include <UniversalPayload/PciRootBridges.h>
 
 /**
@@ -264,6 +269,17 @@ ParseMiscInfo (
   RETURN_STATUS                       Status;
   UNIVERSAL_PAYLOAD_PCI_ROOT_BRIDGES  *BlRootBridgesHob;
   UNIVERSAL_PAYLOAD_PCI_ROOT_BRIDGES  *PldRootBridgesHob;
+  // TODO: Drop half by ignoring return?
+  PLD_SMM_REGISTERS                   *BlSmmRegisters;
+  PLD_SMM_REGISTERS                   *PldSmmRegisters;
+  EFI_SMRAM_HOB_DESCRIPTOR_BLOCK      *BlSmramHob;
+  EFI_SMRAM_HOB_DESCRIPTOR_BLOCK      *PldSmramHob;
+  SPI_FLASH_INFO                      *BlSpiFlashInfo;
+  SPI_FLASH_INFO                      *PldSpiFlashInfo;
+  NV_VARIABLE_INFO                    *BlNvVariableInfo;
+  NV_VARIABLE_INFO                    *PldNvVariableInfo;
+  PLD_S3_COMMUNICATION                *BlS3Communication;
+  PLD_S3_COMMUNICATION                *PldS3Communication;
 
   Status           = RETURN_NOT_FOUND;
   BlRootBridgesHob = (UNIVERSAL_PAYLOAD_PCI_ROOT_BRIDGES *)GetGuidHobDataFromSbl (
@@ -287,5 +303,66 @@ ParseMiscInfo (
     }
   }
 
+  // Perhaps payload does not perform SMM, do not override Status
+  BlSmmRegisters = GetGuidHobDataFromSbl (&gSmmRegisterInfoGuid);
+  if (BlSmmRegisters != NULL) {
+    PldSmmRegisters = BuildGuidDataHob (
+                        &gSmmRegisterInfoGuid,
+                        BlSmmRegisters,
+                        sizeof (PLD_SMM_REGISTERS) + (BlSmmRegisters->Count * sizeof (PLD_GENERIC_REGISTER))
+                        );
+    if (PldSmmRegisters != NULL) {
+      DEBUG ((DEBUG_INFO, "Create SMM register info guid hob\n"));
+    }
+  }
+
+  BlSmramHob = GetGuidHobDataFromSbl (&gEfiSmmSmramMemoryGuid);
+  if (BlSmramHob != NULL) {
+    PldSmramHob = BuildGuidDataHob (
+                    &gEfiSmmSmramMemoryGuid,
+                    BlSmramHob,
+                    sizeof (EFI_SMRAM_HOB_DESCRIPTOR_BLOCK) + ((BlSmramHob->number_of_smm_regions - 1) * sizeof (EFI_SMRAM_DESCRIPTOR))
+                    );
+    if (PldSmramHob != NULL) {
+      DEBUG ((DEBUG_INFO, "Create SMM SMRAM memory info guid hob\n"));
+    }
+  }
+
+  BlSpiFlashInfo = GetGuidHobDataFromSbl (&gSpiFlashInfoGuid);
+  if (BlSpiFlashInfo != NULL) {
+    PldSpiFlashInfo = BuildGuidDataHob (
+                        &gSpiFlashInfoGuid,
+                        BlSpiFlashInfo,
+                        sizeof (SPI_FLASH_INFO)
+                        );
+    if (PldSpiFlashInfo != NULL) {
+      DEBUG ((DEBUG_INFO, "Create SPI flash info guid hob\n"));
+    }
+  }
+
+  BlNvVariableInfo = GetGuidHobDataFromSbl (&gNvVariableInfoGuid);
+  if (BlNvVariableInfo != NULL) {
+    PldNvVariableInfo = BuildGuidDataHob (
+                          &gNvVariableInfoGuid,
+                          BlNvVariableInfo,
+                          sizeof (NV_VARIABLE_INFO)
+                          );
+    if (PldNvVariableInfo != NULL) {
+      DEBUG ((DEBUG_INFO, "Create NV variable info guid hob\n"));
+    }
+  }
+
+  BlS3Communication = GetGuidHobDataFromSbl (&gS3CommunicationGuid);
+  if (BlS3Communication != NULL) {
+    PldS3Communication = BuildGuidDataHob (
+                           &gS3CommunicationGuid,
+                           BlS3Communication,
+                           sizeof (PLD_S3_COMMUNICATION)
+                           );
+    if (PldS3Communication != NULL) {
+      DEBUG ((DEBUG_INFO, "Create S3 communication guid hob\n"));
+    }
+  }
+
   return Status;
 }
diff --git a/UefiPayloadPkg/Library/SblParseLib/SblParseLib.inf b/UefiPayloadPkg/Library/SblParseLib/SblParseLib.inf
index f83a10ccd826..1c77d86a8643 100644
--- a/UefiPayloadPkg/Library/SblParseLib/SblParseLib.inf
+++ b/UefiPayloadPkg/Library/SblParseLib/SblParseLib.inf
@@ -41,6 +41,11 @@
   gEfiGraphicsInfoHobGuid
   gEfiGraphicsDeviceInfoHobGuid
   gUniversalPayloadPciRootBridgeInfoGuid
+  gSmmRegisterInfoGuid
+  gEfiSmmSmramMemoryGuid
+  gSpiFlashInfoGuid
+  gNvVariableInfoGuid
+  gS3CommunicationGuid
 
 [Pcd]
   gUefiPayloadPkgTokenSpaceGuid.PcdBootloaderParameter
-- 
2.43.0



-=-=-=-=-=-=-=-=-=-=-=-
Groups.io Links: You receive all messages sent to this group.
View/Reply Online (#112336): https://edk2.groups.io/g/devel/message/112336
Mute This Topic: https://groups.io/mt/103119569/7686176
Group Owner: devel+owner@edk2.groups.io
Unsubscribe: https://edk2.groups.io/g/devel/unsub [rebecca@openfw.io]
-=-=-=-=-=-=-=-=-=-=-=-



^ permalink raw reply related	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2023-12-11 22:39 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2023-12-11 22:39 [edk2-devel] [PATCH v2 1/4] UefiPayloadPkg/SblParseLib: Build SMM feature GUID HOBs from bootloader Benjamin Doron
2023-12-11 22:39 ` [edk2-devel] [PATCH v2 2/4] UefiPayloadPkg: Introduce coreboot FMAP parser library Benjamin Doron
2023-12-11 22:39 ` [edk2-devel] [PATCH v2 3/4] [WIP] UefiPayloadPkg/CbParseLib: Initial coreboot support for SMM payload Benjamin Doron
2023-12-11 22:39 ` [edk2-devel] [PATCH v2 4/4] [WIP] UefiPayloadPkg: Support SMRAMC register Benjamin Doron

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox