public inbox for devel@edk2.groups.io
 help / color / mirror / Atom feed
* [edk2-platforms][PATCH v2 00/14] Use generic OpenSBI platform
@ 2021-10-06 11:56 Daniel Schaefer
  2021-10-06 11:56 ` [edk2-platforms][PATCH v2 01/14] U5SeriesPkg: Deduplicate PlatformPei Daniel Schaefer
                   ` (7 more replies)
  0 siblings, 8 replies; 10+ messages in thread
From: Daniel Schaefer @ 2021-10-06 11:56 UTC (permalink / raw)
  To: devel

OpenSBI can now use a generic platform implementation. The platform
specific behavior is derived from the device tree.

This patchset updates OpenSBI, adds and builds the device tree and does
a lot of deduplication as a result.
Because OpenSBI has done quite a few other changes, Abner will send out
another patchset to adapt the rest of EDK2 RISC-V code for that.

This generic implementation not only works for the current U540 and U500
implementations but also upcoming QEMU virt platform and possibly others
like BeagleV or Allwinner Nezha board.

Abner Chang (4):
  Silicon/RISC-V: Introduce FirmwareContext library
  Silicon/RISC-V: PeiServiceTableLib uses RiscVFirmwareContextLib
  SiFive/U5SeriesPkg: Use FirmwareContext library
  RISC-V/PlatformPkg: Add FdtPeim to pass DTB from PEI to DXE via HOB

Daniel Schaefer (10):
  U5SeriesPkg: Deduplicate PlatformPei
  RISC-V: Split SMBIOS out of PlatformPei
  RISC-V: Use U5 SMBIOS library only for those platforms
  U540: Add and build device tree
  RISC-V/PlatformPkg: Build DeviceTree and use that in SEC
  RISC-V/PlatformPkg: Fixup FDT from HOB and install into config table
  U5SeriesPkg: Switch to generic OpenSBI platform
  RISC-V: Switch to latest OpenSBI
  RISC-V: Implement ResetSystem RT call
  Move OpenSbiPlatformLib to RISC-V/PlatformPkg

 Platform/{SiFive/U5SeriesPkg/FreedomU540HiFiveUnleashedBoard => RISC-V/PlatformPkg}/Library/OpensbiPlatformLib/OpensbiPlatformLib.inf |   2 +
 Platform/RISC-V/PlatformPkg/Library/OpensbiPlatformLib/Platform.c                                                                     | 224 ++++++++++++++
 Platform/RISC-V/PlatformPkg/Library/OpensbiPlatformLib/PlatformOverride.h                                                             |  30 ++
 Platform/RISC-V/PlatformPkg/Library/OpensbiPlatformLib/SifiveFu540.c                                                                  |  47 +++
 Platform/RISC-V/PlatformPkg/Library/OpensbiPlatformLibNull/Platform.c                                                                 |  27 +-
 Platform/RISC-V/PlatformPkg/Library/PeiCoreInfoHobLibNull/CoreInfoHob.c                                                               |  37 +++
 Platform/RISC-V/PlatformPkg/Library/PeiCoreInfoHobLibNull/PeiCoreInfoHobLib.inf                                                       |  43 +++
 Platform/RISC-V/PlatformPkg/Library/ResetSystemLib/ResetSystemLib.c                                                                   | 128 ++++++++
 Platform/RISC-V/PlatformPkg/Library/ResetSystemLib/ResetSystemLib.inf                                                                 |  33 +++
 Platform/RISC-V/PlatformPkg/RiscVPlatformPkg.dec                                                                                      |   4 +
 Platform/RISC-V/PlatformPkg/Universal/FdtPeim/FdtPeim.c                                                                               |  70 +++++
 Platform/RISC-V/PlatformPkg/Universal/FdtPeim/FdtPeim.inf                                                                             |  49 ++++
 Platform/{SiFive/U5SeriesPkg/FreedomU500VC707Board => RISC-V/PlatformPkg}/Universal/Pei/PlatformPei/Fv.c                              |   0
 Platform/{SiFive/U5SeriesPkg/FreedomU540HiFiveUnleashedBoard => RISC-V/PlatformPkg}/Universal/Pei/PlatformPei/MemDetect.c             |  11 +-
 Platform/{SiFive/U5SeriesPkg/FreedomU540HiFiveUnleashedBoard => RISC-V/PlatformPkg}/Universal/Pei/PlatformPei/Platform.c              |  21 +-
 Platform/{SiFive/U5SeriesPkg/FreedomU500VC707Board => RISC-V/PlatformPkg}/Universal/Pei/PlatformPei/Platform.h                        |   0
 Platform/{SiFive/U5SeriesPkg/FreedomU540HiFiveUnleashedBoard => RISC-V/PlatformPkg}/Universal/Pei/PlatformPei/PlatformPei.inf         |   6 +-
 Platform/RISC-V/PlatformPkg/Universal/Sec/Riscv64/SecEntry.S                                                                          |  24 +-
 Platform/RISC-V/PlatformPkg/Universal/Sec/SecMain.c                                                                                   |  54 +++-
 Platform/RISC-V/PlatformPkg/Universal/Sec/SecMain.inf                                                                                 |   2 +
 Platform/SiFive/U5SeriesPkg/FreedomU500VC707Board/Library/OpensbiPlatformLib/Platform.c                                               |  29 +-
 Platform/SiFive/U5SeriesPkg/FreedomU500VC707Board/U500.dsc                                                                            |  16 +-
 Platform/SiFive/U5SeriesPkg/FreedomU500VC707Board/U500.fdf                                                                            |   2 +-
 Platform/SiFive/U5SeriesPkg/FreedomU500VC707Board/U500.fdf.inc                                                                        |   6 +-
 Platform/SiFive/U5SeriesPkg/FreedomU500VC707Board/Universal/Pei/PlatformPei/MemDetect.c                                               |  74 -----
 Platform/SiFive/U5SeriesPkg/FreedomU500VC707Board/Universal/Pei/PlatformPei/Platform.c                                                | 310 --------------------
 Platform/SiFive/U5SeriesPkg/FreedomU500VC707Board/Universal/Pei/PlatformPei/PlatformPei.inf                                           |  73 -----
 Platform/SiFive/U5SeriesPkg/FreedomU540HiFiveUnleashedBoard/DeviceTree.fdf.inc                                                        |  35 +++
 Platform/SiFive/U5SeriesPkg/FreedomU540HiFiveUnleashedBoard/DeviceTree/U540DeviceTree.inf                                             |  25 ++
 Platform/SiFive/U5SeriesPkg/FreedomU540HiFiveUnleashedBoard/DeviceTree/fu540-c000.dtsi                                                | 287 ++++++++++++++++++
 Platform/SiFive/U5SeriesPkg/FreedomU540HiFiveUnleashedBoard/DeviceTree/gpio.h                                                         |  42 +++
 Platform/SiFive/U5SeriesPkg/FreedomU540HiFiveUnleashedBoard/DeviceTree/hifive-unleashed-a00.dts                                       | 106 +++++++
 Platform/SiFive/U5SeriesPkg/FreedomU540HiFiveUnleashedBoard/DeviceTree/sifive-fu540-prci.h                                            |  18 ++
 Platform/SiFive/U5SeriesPkg/FreedomU540HiFiveUnleashedBoard/Library/OpensbiPlatformLib/Platform.c                                     | 216 --------------
 Platform/SiFive/U5SeriesPkg/FreedomU540HiFiveUnleashedBoard/U540.dsc                                                                  |  29 +-
 Platform/SiFive/U5SeriesPkg/FreedomU540HiFiveUnleashedBoard/U540.fdf                                                                  |  10 +-
 Platform/SiFive/U5SeriesPkg/FreedomU540HiFiveUnleashedBoard/U540.fdf.inc                                                              |  14 +-
 Platform/SiFive/U5SeriesPkg/FreedomU540HiFiveUnleashedBoard/Universal/Pei/PlatformPei/Fv.c                                            |  51 ----
 Platform/SiFive/U5SeriesPkg/FreedomU540HiFiveUnleashedBoard/Universal/Pei/PlatformPei/Platform.h                                      |  86 ------
 Platform/SiFive/U5SeriesPkg/Include/SiFiveU5MCCoreplex.h                                                                              |  33 +--
 Platform/SiFive/U5SeriesPkg/Library/PeiCoreInfoHobLib/CoreInfoHob.c                                                                   |  32 +-
 Platform/SiFive/U5SeriesPkg/Library/PeiCoreInfoHobLib/PeiCoreInfoHobLib.inf                                                           |   4 +-
 Platform/SiFive/U5SeriesPkg/Library/SerialIoLib/SerialPortLib.c                                                                       |  81 ++++-
 Silicon/RISC-V/ProcessorPkg/Include/IndustryStandard/RiscV.h                                                                          |   3 +-
 Silicon/RISC-V/ProcessorPkg/Include/IndustryStandard/RiscVOpensbi.h                                                                   |   1 +
 Silicon/RISC-V/ProcessorPkg/Include/Library/RiscVCpuLib.h                                                                             |  14 +-
 Silicon/RISC-V/ProcessorPkg/Include/Library/RiscVEdk2SbiLib.h                                                                         |  39 ++-
 Silicon/RISC-V/ProcessorPkg/Include/Library/RiscVFirmwareContextLib.h                                                                 |  43 +++
 Silicon/RISC-V/ProcessorPkg/Include/OpensbiTypes.h                                                                                    |   1 +
 Silicon/RISC-V/ProcessorPkg/Library/PeiServicesTablePointerLibOpenSbi/PeiServicesTablePointerLibOpenSbi.inf                           |   4 +-
 Silicon/RISC-V/ProcessorPkg/Library/PeiServicesTablePointerLibOpenSbi/PeiServicesTablePointerOpenSbi.c                                |   8 +-
 Silicon/RISC-V/ProcessorPkg/Library/RiscVCpuLib/Cpu.S                                                                                 |  34 ++-
 Silicon/RISC-V/ProcessorPkg/Library/RiscVEdk2SbiLib/RiscVEdk2SbiLib.c                                                                 |  44 ++-
 Silicon/RISC-V/ProcessorPkg/Library/RiscVFirmwareContextSbiLib/RiscVFirmwareContextSbiLib.c                                           |  52 ++++
 Silicon/RISC-V/ProcessorPkg/Library/RiscVFirmwareContextSbiLib/RiscVFirmwareContextSbiLib.inf                                         |  34 +++
 Silicon/RISC-V/ProcessorPkg/Library/RiscVFirmwareContextSscratchLib/RiscVFirmwareContextSscratchLib.c                                 |  48 +++
 Silicon/RISC-V/ProcessorPkg/Library/RiscVFirmwareContextSscratchLib/RiscVFirmwareContextSscratchLib.inf                               |  33 +++
 Silicon/RISC-V/ProcessorPkg/Library/RiscVFirmwareContextStvecLib/RiscVFirmwareContextStvecLib.c                                       |  48 +++
 Silicon/RISC-V/ProcessorPkg/Library/RiscVFirmwareContextStvecLib/RiscVFirmwareContextStvecLib.inf                                     |  34 +++
 Silicon/RISC-V/ProcessorPkg/Library/RiscVOpensbiLib/RiscVOpensbiLib.inf                                                               |  13 +-
 Silicon/RISC-V/ProcessorPkg/RiscVProcessorPkg.dec                                                                                     |   1 +
 Silicon/RISC-V/ProcessorPkg/RiscVProcessorPkg.dsc                                                                                     |   7 +-
 Silicon/RISC-V/ProcessorPkg/Universal/FdtDxe/FdtDxe.c                                                                                 | 116 ++++++++
 Silicon/RISC-V/ProcessorPkg/Universal/FdtDxe/FdtDxe.inf                                                                               |  53 ++++
 64 files changed, 2055 insertions(+), 966 deletions(-)
 rename Platform/{SiFive/U5SeriesPkg/FreedomU540HiFiveUnleashedBoard => RISC-V/PlatformPkg}/Library/OpensbiPlatformLib/OpensbiPlatformLib.inf (94%)
 create mode 100644 Platform/RISC-V/PlatformPkg/Library/OpensbiPlatformLib/Platform.c
 create mode 100644 Platform/RISC-V/PlatformPkg/Library/OpensbiPlatformLib/PlatformOverride.h
 create mode 100644 Platform/RISC-V/PlatformPkg/Library/OpensbiPlatformLib/SifiveFu540.c
 create mode 100644 Platform/RISC-V/PlatformPkg/Library/PeiCoreInfoHobLibNull/CoreInfoHob.c
 create mode 100644 Platform/RISC-V/PlatformPkg/Library/PeiCoreInfoHobLibNull/PeiCoreInfoHobLib.inf
 create mode 100644 Platform/RISC-V/PlatformPkg/Library/ResetSystemLib/ResetSystemLib.c
 create mode 100644 Platform/RISC-V/PlatformPkg/Library/ResetSystemLib/ResetSystemLib.inf
 create mode 100644 Platform/RISC-V/PlatformPkg/Universal/FdtPeim/FdtPeim.c
 create mode 100644 Platform/RISC-V/PlatformPkg/Universal/FdtPeim/FdtPeim.inf
 rename Platform/{SiFive/U5SeriesPkg/FreedomU500VC707Board => RISC-V/PlatformPkg}/Universal/Pei/PlatformPei/Fv.c (100%)
 rename Platform/{SiFive/U5SeriesPkg/FreedomU540HiFiveUnleashedBoard => RISC-V/PlatformPkg}/Universal/Pei/PlatformPei/MemDetect.c (79%)
 rename Platform/{SiFive/U5SeriesPkg/FreedomU540HiFiveUnleashedBoard => RISC-V/PlatformPkg}/Universal/Pei/PlatformPei/Platform.c (89%)
 rename Platform/{SiFive/U5SeriesPkg/FreedomU500VC707Board => RISC-V/PlatformPkg}/Universal/Pei/PlatformPei/Platform.h (100%)
 rename Platform/{SiFive/U5SeriesPkg/FreedomU540HiFiveUnleashedBoard => RISC-V/PlatformPkg}/Universal/Pei/PlatformPei/PlatformPei.inf (87%)
 delete mode 100644 Platform/SiFive/U5SeriesPkg/FreedomU500VC707Board/Universal/Pei/PlatformPei/MemDetect.c
 delete mode 100644 Platform/SiFive/U5SeriesPkg/FreedomU500VC707Board/Universal/Pei/PlatformPei/Platform.c
 delete mode 100644 Platform/SiFive/U5SeriesPkg/FreedomU500VC707Board/Universal/Pei/PlatformPei/PlatformPei.inf
 create mode 100644 Platform/SiFive/U5SeriesPkg/FreedomU540HiFiveUnleashedBoard/DeviceTree.fdf.inc
 create mode 100644 Platform/SiFive/U5SeriesPkg/FreedomU540HiFiveUnleashedBoard/DeviceTree/U540DeviceTree.inf
 create mode 100644 Platform/SiFive/U5SeriesPkg/FreedomU540HiFiveUnleashedBoard/DeviceTree/fu540-c000.dtsi
 create mode 100644 Platform/SiFive/U5SeriesPkg/FreedomU540HiFiveUnleashedBoard/DeviceTree/gpio.h
 create mode 100644 Platform/SiFive/U5SeriesPkg/FreedomU540HiFiveUnleashedBoard/DeviceTree/hifive-unleashed-a00.dts
 create mode 100644 Platform/SiFive/U5SeriesPkg/FreedomU540HiFiveUnleashedBoard/DeviceTree/sifive-fu540-prci.h
 delete mode 100644 Platform/SiFive/U5SeriesPkg/FreedomU540HiFiveUnleashedBoard/Library/OpensbiPlatformLib/Platform.c
 delete mode 100644 Platform/SiFive/U5SeriesPkg/FreedomU540HiFiveUnleashedBoard/Universal/Pei/PlatformPei/Fv.c
 delete mode 100644 Platform/SiFive/U5SeriesPkg/FreedomU540HiFiveUnleashedBoard/Universal/Pei/PlatformPei/Platform.h
 create mode 100644 Silicon/RISC-V/ProcessorPkg/Include/Library/RiscVFirmwareContextLib.h
 create mode 100644 Silicon/RISC-V/ProcessorPkg/Library/RiscVFirmwareContextSbiLib/RiscVFirmwareContextSbiLib.c
 create mode 100644 Silicon/RISC-V/ProcessorPkg/Library/RiscVFirmwareContextSbiLib/RiscVFirmwareContextSbiLib.inf
 create mode 100644 Silicon/RISC-V/ProcessorPkg/Library/RiscVFirmwareContextSscratchLib/RiscVFirmwareContextSscratchLib.c
 create mode 100644 Silicon/RISC-V/ProcessorPkg/Library/RiscVFirmwareContextSscratchLib/RiscVFirmwareContextSscratchLib.inf
 create mode 100644 Silicon/RISC-V/ProcessorPkg/Library/RiscVFirmwareContextStvecLib/RiscVFirmwareContextStvecLib.c
 create mode 100644 Silicon/RISC-V/ProcessorPkg/Library/RiscVFirmwareContextStvecLib/RiscVFirmwareContextStvecLib.inf
 create mode 100644 Silicon/RISC-V/ProcessorPkg/Universal/FdtDxe/FdtDxe.c
 create mode 100644 Silicon/RISC-V/ProcessorPkg/Universal/FdtDxe/FdtDxe.inf

-- 
2.33.0


^ permalink raw reply	[flat|nested] 10+ messages in thread
* [edk2-platforms][PATCH v2 08/14] RISC-V/PlatformPkg: Build DeviceTree and use that in SEC
@ 2021-10-06 11:58 Daniel Schaefer
  0 siblings, 0 replies; 10+ messages in thread
From: Daniel Schaefer @ 2021-10-06 11:58 UTC (permalink / raw)
  To: devel; +Cc: Abner Chang, Sunil V L

OpenSBI uses the device tree for platform specific initialization, so we
need to have it already in SEC.

Cc: Daniel Schaefer <daniel.schaefer@hpe.com>
Cc: Abner Chang <abner.chang@hpe.com>
Cc: Sunil V L <sunilvl@ventanamicro.com>

Signed-off-by: Daniel Schaefer <daniel.schaefer@hpe.com>
---
 Platform/RISC-V/PlatformPkg/RiscVPlatformPkg.dec                    |  4 ++
 Platform/RISC-V/PlatformPkg/Universal/Sec/Riscv64/SecEntry.S        | 22 ---------
 Platform/RISC-V/PlatformPkg/Universal/Sec/SecMain.c                 | 49 ++++++++++++++++++++
 Platform/RISC-V/PlatformPkg/Universal/Sec/SecMain.inf               |  2 +
 Silicon/RISC-V/ProcessorPkg/Include/IndustryStandard/RiscVOpensbi.h |  1 +
 5 files changed, 56 insertions(+), 22 deletions(-)

diff --git a/Platform/RISC-V/PlatformPkg/RiscVPlatformPkg.dec b/Platform/RISC-V/PlatformPkg/RiscVPlatformPkg.dec
index 48aeb97431..ad15a155fe 100644
--- a/Platform/RISC-V/PlatformPkg/RiscVPlatformPkg.dec
+++ b/Platform/RISC-V/PlatformPkg/RiscVPlatformPkg.dec
@@ -31,6 +31,8 @@
   gUefiRiscVPlatformPkgTokenSpaceGuid.PcdRiscVPeiFvSize|0x0|UINT32|0x00001003
   gUefiRiscVPlatformPkgTokenSpaceGuid.PcdRiscVDxeFvBase|0x0|UINT32|0x00001004
   gUefiRiscVPlatformPkgTokenSpaceGuid.PcdRiscVDxeFvSize|0x0|UINT32|0x00001005
+  gUefiRiscVPlatformPkgTokenSpaceGuid.PcdRiscVDtbFvBase|0x0|UINT32|0x00001016
+  gUefiRiscVPlatformPkgTokenSpaceGuid.PcdRiscVDtbFvSize|0x0|UINT32|0x00001017
 
 #
 # Definition of EFI Variable region
@@ -66,6 +68,8 @@
   gUefiRiscVPlatformPkgTokenSpaceGuid.PcdTemporaryRamSize|0|UINT32|0x00001104
   gUefiRiscVPlatformPkgTokenSpaceGuid.PcdPeiCorePrivilegeMode|0|UINT32|0x00001105
 
+  gUefiRiscVPlatformPkgTokenSpaceGuid.PcdDeviceTreeAddress|0|UINT32|0x00001106
+
 [PcdsPatchableInModule]
 
 [PcdsFeatureFlag]
diff --git a/Platform/RISC-V/PlatformPkg/Universal/Sec/Riscv64/SecEntry.S b/Platform/RISC-V/PlatformPkg/Universal/Sec/Riscv64/SecEntry.S
index 8434d1a4e0..0e3940180d 100644
--- a/Platform/RISC-V/PlatformPkg/Universal/Sec/Riscv64/SecEntry.S
+++ b/Platform/RISC-V/PlatformPkg/Universal/Sec/Riscv64/SecEntry.S
@@ -75,11 +75,6 @@ _scratch_init:
   sd    a4, SBI_SCRATCH_FW_START_OFFSET(tp)
   sd    a5, SBI_SCRATCH_FW_SIZE_OFFSET(tp)
 
-  /*
-   * Note: fw_next_arg1() uses a0, a1, and ra
-  */
-  call  fw_next_arg1
-  sd    a0, SBI_SCRATCH_NEXT_ARG1_OFFSET(tp) /* Save agr1 in scratch buffer*/
   /*
    Note: fw_next_addr()uses a0, a1, and ra
   */
@@ -500,23 +495,6 @@ _reset_regs:
   csrw  CSR_MSCRATCH, 0
   ret
 
-  .align 3
-  .section .entry, "ax", %progbits
-  .global fw_prev_arg1
-fw_prev_arg1:
-
-  /* We return previous arg1 in 'a0' */
-  add   a0, zero, zero
-  ret
-
-  .align 3
-  .section .entry, "ax", %progbits
-  .global fw_next_arg1
-fw_next_arg1:
-  /* We return next arg1 in 'a0' */
-  li    a0, FixedPcdGet32(PcdRiscVPeiFvBase)
-  ret
-
   .align 3
   .section .entry, "ax", %progbits
   .global fw_next_addr
diff --git a/Platform/RISC-V/PlatformPkg/Universal/Sec/SecMain.c b/Platform/RISC-V/PlatformPkg/Universal/Sec/SecMain.c
index fa9ecd789a..0af0b4bac8 100644
--- a/Platform/RISC-V/PlatformPkg/Universal/Sec/SecMain.c
+++ b/Platform/RISC-V/PlatformPkg/Universal/Sec/SecMain.c
@@ -557,6 +557,12 @@ VOID EFIAPI PeiCore (
              &FirmwareContext
              ));
   ThisSbiPlatform->firmware_context = (unsigned long)&FirmwareContext;
+
+  //
+  // Save Flattened Device tree in firmware context
+  //
+  FirmwareContext.FlattenedDeviceTree = FuncArg1;
+
   //
   // Set firmware context Hart-specific pointer
   //
@@ -647,6 +653,42 @@ RiscVOpenSbiHartSwitchMode (
   sbi_hart_switch_mode(FuncArg0, FuncArg1, NextAddr, NextMode, NextVirt);
 }
 
+/**
+  Get device tree address
+
+  @retval The address of Device Tree binary.
+**/
+VOID *
+EFIAPI
+GetDeviceTreeAddress (
+  VOID
+  )
+{
+  EFI_STATUS Status;
+  EFI_COMMON_SECTION_HEADER *FoundSection;
+
+  if (FixedPcdGet32 (PcdDeviceTreeAddress)) {
+      return (VOID *)*((unsigned long *)FixedPcdGet32 (PcdDeviceTreeAddress));
+  } else if (FixedPcdGet32 (PcdRiscVDtbFvBase)) {
+      Status = FindFfsFileAndSection (
+                 (EFI_FIRMWARE_VOLUME_HEADER *)FixedPcdGet32 (PcdRiscVDtbFvBase),
+                 EFI_FV_FILETYPE_FREEFORM,
+                 EFI_SECTION_RAW,
+                 &FoundSection
+               );
+      if (EFI_ERROR(Status)) {
+        DEBUG ((DEBUG_ERROR, "Platform Device Tree is not found from FV.\n"));
+        return NULL;
+      }
+      FoundSection ++;
+      return (VOID *)FoundSection;
+  } else {
+      DEBUG ((DEBUG_ERROR, "Must use DTB either from memory or compiled in FW. PCDs configured incorrectly.\n"));
+      ASSERT (FALSE);
+  }
+  return NULL;
+}
+
 /**
   This function initilizes hart specific information and SBI.
   For the boot hart, it boots system through PEI core and initial SBI in the DXE IPL.
@@ -686,6 +728,13 @@ VOID EFIAPI SecCoreStartUpWithStack(
   UINT64 NonBootHartMessageLockValue;
   EFI_RISCV_FIRMWARE_CONTEXT_HART_SPECIFIC *HartFirmwareContext;
 
+  Scratch->next_arg1 = (unsigned long)GetDeviceTreeAddress ();
+  if (Scratch->next_arg1 == (unsigned long)NULL) {
+    DEBUG ((DEBUG_ERROR, "Platform Device Tree is not found\n"));
+    ASSERT (FALSE);
+  }
+  DEBUG ((DEBUG_INFO, "DTB address: 0x%08x\n", Scratch->next_arg1));
+
   //
   // Setup EFI_RISCV_FIRMWARE_CONTEXT_HART_SPECIFIC for each hart.
   //
diff --git a/Platform/RISC-V/PlatformPkg/Universal/Sec/SecMain.inf b/Platform/RISC-V/PlatformPkg/Universal/Sec/SecMain.inf
index 89bcb039a6..78bd75e3ac 100644
--- a/Platform/RISC-V/PlatformPkg/Universal/Sec/SecMain.inf
+++ b/Platform/RISC-V/PlatformPkg/Universal/Sec/SecMain.inf
@@ -57,6 +57,8 @@
 [FixedPcd]
   gUefiRiscVPlatformPkgTokenSpaceGuid.PcdRiscVPeiFvBase
   gUefiRiscVPlatformPkgTokenSpaceGuid.PcdRiscVPeiFvSize
+  gUefiRiscVPlatformPkgTokenSpaceGuid.PcdRiscVDtbFvBase
+  gUefiRiscVPlatformPkgTokenSpaceGuid.PcdDeviceTreeAddress
 
 [Pcd]
   gUefiRiscVPlatformPkgTokenSpaceGuid.PcdBootHartId
diff --git a/Silicon/RISC-V/ProcessorPkg/Include/IndustryStandard/RiscVOpensbi.h b/Silicon/RISC-V/ProcessorPkg/Include/IndustryStandard/RiscVOpensbi.h
index 2dab696af8..e7ac6d26ee 100644
--- a/Silicon/RISC-V/ProcessorPkg/Include/IndustryStandard/RiscVOpensbi.h
+++ b/Silicon/RISC-V/ProcessorPkg/Include/IndustryStandard/RiscVOpensbi.h
@@ -47,6 +47,7 @@ typedef struct {
 
 typedef struct {
   VOID            *PeiServiceTable;       // PEI Service table
+  UINT64           FlattenedDeviceTree;   // Pointer to Flattened Device tree
   EFI_RISCV_FIRMWARE_CONTEXT_HART_SPECIFIC  *HartSpecific[RISC_V_MAX_HART_SUPPORTED];
 } EFI_RISCV_OPENSBI_FIRMWARE_CONTEXT;
 
-- 
2.33.0


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

end of thread, other threads:[~2021-10-06 11:59 UTC | newest]

Thread overview: 10+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2021-10-06 11:56 [edk2-platforms][PATCH v2 00/14] Use generic OpenSBI platform Daniel Schaefer
2021-10-06 11:56 ` [edk2-platforms][PATCH v2 01/14] U5SeriesPkg: Deduplicate PlatformPei Daniel Schaefer
2021-10-06 11:56 ` [edk2-platforms][PATCH v2 02/14] RISC-V: Split SMBIOS out of PlatformPei Daniel Schaefer
2021-10-06 11:56 ` [edk2-platforms][PATCH v2 03/14] RISC-V: Use U5 SMBIOS library only for those platforms Daniel Schaefer
2021-10-06 11:56 ` [edk2-platforms][PATCH v2 04/14] Silicon/RISC-V: Introduce FirmwareContext library Daniel Schaefer
2021-10-06 11:56 ` [edk2-platforms][PATCH v2 05/14] Silicon/RISC-V: PeiServiceTableLib uses RiscVFirmwareContextLib Daniel Schaefer
2021-10-06 11:56 ` [edk2-platforms][PATCH v2 06/14] SiFive/U5SeriesPkg: Use FirmwareContext library Daniel Schaefer
2021-10-06 11:56 ` [edk2-platforms][PATCH v2 07/14] U540: Add and build device tree Daniel Schaefer
2021-10-06 11:56 ` [edk2-platforms][PATCH v2 08/14] RISC-V/PlatformPkg: Build DeviceTree and use that in SEC Daniel Schaefer
  -- strict thread matches above, loose matches on Subject: below --
2021-10-06 11:58 Daniel Schaefer

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