[edk2] [PATCH 1/6] EmbeddedPkg/DtPlatformDxe: allow multiple entries in DTB FV file

Ard Biesheuvel posted 6 patches 7 years, 7 months ago
[edk2] [PATCH 1/6] EmbeddedPkg/DtPlatformDxe: allow multiple entries in DTB FV file
Posted by Ard Biesheuvel 7 years, 7 months ago
To allow some dynamic behavior in selecting the DTB to expose to the
OS, allow the DTB FV file to contain multiple sections, and indirect
the choice of section via a fixed/dynamic PCD, which defaults to 0.

Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Ard Biesheuvel <ard.biesheuvel@linaro.org>
---
 EmbeddedPkg/Drivers/DtPlatformDxe/DtPlatformDxe.c   | 5 ++++-
 EmbeddedPkg/Drivers/DtPlatformDxe/DtPlatformDxe.inf | 4 ++++
 EmbeddedPkg/EmbeddedPkg.dec                         | 3 +++
 3 files changed, 11 insertions(+), 1 deletion(-)

diff --git a/EmbeddedPkg/Drivers/DtPlatformDxe/DtPlatformDxe.c b/EmbeddedPkg/Drivers/DtPlatformDxe/DtPlatformDxe.c
index 5778633b4985..72f9f5721cda 100644
--- a/EmbeddedPkg/Drivers/DtPlatformDxe/DtPlatformDxe.c
+++ b/EmbeddedPkg/Drivers/DtPlatformDxe/DtPlatformDxe.c
@@ -17,6 +17,7 @@
 #include <Library/DevicePathLib.h>
 #include <Library/DxeServicesLib.h>
 #include <Library/HiiLib.h>
+#include <Library/PcdLib.h>
 #include <Library/MemoryAllocationLib.h>
 #include <Library/UefiBootServicesTableLib.h>
 #include <Library/UefiDriverEntryPoint.h>
@@ -121,7 +122,9 @@ DtPlatformDxeEntryPoint (
   //
   Dtb = NULL;
   Status = GetSectionFromAnyFv (&gDtPlatformDefaultDtbFileGuid,
-             EFI_SECTION_RAW, 0, &Dtb, &DtbSize);
+             EFI_SECTION_RAW,
+             PcdGet8 (PcdDtPlatformDefaultDtbSectionIndex),
+             &Dtb, &DtbSize);
   if (EFI_ERROR (Status)) {
     DEBUG ((DEBUG_WARN, "%a: no DTB blob found, defaulting to ACPI\n",
       __FUNCTION__));
diff --git a/EmbeddedPkg/Drivers/DtPlatformDxe/DtPlatformDxe.inf b/EmbeddedPkg/Drivers/DtPlatformDxe/DtPlatformDxe.inf
index b73877a6086b..c16202790ed9 100644
--- a/EmbeddedPkg/Drivers/DtPlatformDxe/DtPlatformDxe.inf
+++ b/EmbeddedPkg/Drivers/DtPlatformDxe/DtPlatformDxe.inf
@@ -43,6 +43,7 @@ [LibraryClasses]
   DxeServicesLib
   HiiLib
   MemoryAllocationLib
+  PcdLib
   UefiBootServicesTableLib
   UefiDriverEntryPoint
   UefiRuntimeServicesTableLib
@@ -56,3 +57,6 @@ [Guids]
 [Depex]
   gEfiVariableArchProtocolGuid        AND
   gEfiVariableWriteArchProtocolGuid
+
+[Pcd]
+  gEmbeddedTokenSpaceGuid.PcdDtPlatformDefaultDtbSectionIndex
diff --git a/EmbeddedPkg/EmbeddedPkg.dec b/EmbeddedPkg/EmbeddedPkg.dec
index 871fc5ff4016..f1b7af347861 100644
--- a/EmbeddedPkg/EmbeddedPkg.dec
+++ b/EmbeddedPkg/EmbeddedPkg.dec
@@ -198,3 +198,6 @@ [PcdsFixedAtBuild.X64]
 
 [PcdsFixedAtBuild.common, PcdsDynamic.common]
   gEmbeddedTokenSpaceGuid.PcdFdtDevicePaths|L""|VOID*|0x00000055
+
+  # the section containing the default DTB for the current platform
+  gEmbeddedTokenSpaceGuid.PcdDtPlatformDefaultDtbSectionIndex|0|UINT8|0x00000057
-- 
2.9.3

_______________________________________________
edk2-devel mailing list
edk2-devel@lists.01.org
https://lists.01.org/mailman/listinfo/edk2-devel