[edk2-devel] [edk2-platforms][PATCH 11/30] SiFive/U540: RiscVSpecialPlatformLib instance of U540

Abner Chang abner.chang at hpe.com
Tue Oct 19 08:09:48 UTC 2021


Provide platform_override of U540 platform.

Cc: Sunil V L <sunilvl at ventanamicro.com>
Cc: Daniel Schaefer <daniel.schaefer at hpe.com>

Signed-off-by: Abner Chang <abner.chang at hpe.com>
---
 .../FreedomU540HiFiveUnleashedBoard/U540.dsc  |  1 +
 .../RiscVSpecialPlatformLib.inf               | 36 ++++++++++++
 .../RiscVSpecialPlatformLib/SifiveFu540.c     | 56 +++++++++++++++++++
 3 files changed, 93 insertions(+)
 create mode 100644 Platform/SiFive/U5SeriesPkg/FreedomU540HiFiveUnleashedBoard/Library/RiscVSpecialPlatformLib/RiscVSpecialPlatformLib.inf
 create mode 100644 Platform/SiFive/U5SeriesPkg/FreedomU540HiFiveUnleashedBoard/Library/RiscVSpecialPlatformLib/SifiveFu540.c

diff --git a/Platform/SiFive/U5SeriesPkg/FreedomU540HiFiveUnleashedBoard/U540.dsc b/Platform/SiFive/U5SeriesPkg/FreedomU540HiFiveUnleashedBoard/U540.dsc
index d12af19825..71dbca0e96 100644
--- a/Platform/SiFive/U5SeriesPkg/FreedomU540HiFiveUnleashedBoard/U540.dsc
+++ b/Platform/SiFive/U5SeriesPkg/FreedomU540HiFiveUnleashedBoard/U540.dsc
@@ -163,6 +163,7 @@
 
   ReportStatusCodeLib|MdeModulePkg/Library/PeiReportStatusCodeLib/PeiReportStatusCodeLib.inf
   ExtractGuidedSectionLib|MdePkg/Library/BaseExtractGuidedSectionLib/BaseExtractGuidedSectionLib.inf
+  RiscVSpecialPlatformLib|Platform/SiFive/U5SeriesPkg/FreedomU540HiFiveUnleashedBoard/Library/RiscVSpecialPlatformLib/RiscVSpecialPlatformLib.inf
 
 !ifdef $(SOURCE_DEBUG_ENABLE)
   DebugAgentLib|SourceLevelDebugPkg/Library/DebugAgent/SecPeiDebugAgentLib.inf
diff --git a/Platform/SiFive/U5SeriesPkg/FreedomU540HiFiveUnleashedBoard/Library/RiscVSpecialPlatformLib/RiscVSpecialPlatformLib.inf b/Platform/SiFive/U5SeriesPkg/FreedomU540HiFiveUnleashedBoard/Library/RiscVSpecialPlatformLib/RiscVSpecialPlatformLib.inf
new file mode 100644
index 0000000000..26f475ca45
--- /dev/null
+++ b/Platform/SiFive/U5SeriesPkg/FreedomU540HiFiveUnleashedBoard/Library/RiscVSpecialPlatformLib/RiscVSpecialPlatformLib.inf
@@ -0,0 +1,36 @@
+## @file
+#  Null library instance to provide platform_override for the
+#  special RISC-V platform. This module incorporates with
+#  OpensbiPlatformLib and RISC-V Opensbi library.
+#
+#  Copyright (c) 2021, Hewlett Packard Enterprise Development LP. All rights reserved.<BR>
+#
+#  SPDX-License-Identifier: BSD-2-Clause-Patent
+#
+##
+
+[Defines]
+  INF_VERSION                    = 0x0001001b
+  BASE_NAME                      = RiscVSpecialPlatformLib
+  FILE_GUID                      = FE0AE3E6-90A4-421D-851D-E092CBEEE645
+  MODULE_TYPE                    = BASE
+  VERSION_STRING                 = 1.0
+  LIBRARY_CLASS                  = RiscVSpecialPlatformLib|SEC
+
+#
+# The following information is for reference only and not required by the build tools.
+#
+#  VALID_ARCHITECTURES           = RISCV64
+#
+
+[Sources]
+ SifiveFu540.c
+
+[Packages]
+  MdePkg/MdePkg.dec
+  MdeModulePkg/MdeModulePkg.dec
+  Platform/RISC-V/PlatformPkg/RiscVPlatformPkg.dec
+  Silicon/RISC-V/ProcessorPkg/RiscVProcessorPkg.dec
+
+[LibraryClasses]
+  BaseLib
diff --git a/Platform/SiFive/U5SeriesPkg/FreedomU540HiFiveUnleashedBoard/Library/RiscVSpecialPlatformLib/SifiveFu540.c b/Platform/SiFive/U5SeriesPkg/FreedomU540HiFiveUnleashedBoard/Library/RiscVSpecialPlatformLib/SifiveFu540.c
new file mode 100644
index 0000000000..e89403f7ff
--- /dev/null
+++ b/Platform/SiFive/U5SeriesPkg/FreedomU540HiFiveUnleashedBoard/Library/RiscVSpecialPlatformLib/SifiveFu540.c
@@ -0,0 +1,56 @@
+/*
+ * SPDX-License-Identifier: BSD-2-Clause
+ *
+ * Copyright (c) 2020 Western Digital Corporation or its affiliates.
+ *
+ * Authors:
+ *   Anup Patel <anup.patel at wdc.com>
+
+   Copyright (c) 2021, Hewlett Packard Enterprise Development LP. All rights reserved.<BR>
+
+   SPDX-License-Identifier: BSD-2-Clause-Patent
+ */
+
+#include <Library/RiscVSpecialPlatformLib.h>
+#include <sbi_utils/fdt/fdt_helper.h>
+#include <sbi_utils/fdt/fdt_fixup.h>
+
+static u64 sifive_fu540_tlbr_flush_limit(const struct fdt_match *match)
+{
+  /*
+   * The sfence.vma by virtual address does not work on
+   * SiFive FU540 so we return remote TLB flush limit as zero.
+   */
+  return 0;
+}
+
+static int sifive_fu540_fdt_fixup(void *fdt, const struct fdt_match *match)
+{
+  /*
+   * SiFive Freedom U540 has an erratum that prevents S-mode software
+   * to access a PMP protected region using 1GB page table mapping, so
+   * always add the no-map attribute on this platform.
+   */
+  fdt_reserved_memory_nomap_fixup(fdt);
+
+  return 0;
+}
+
+static const struct fdt_match sifive_fu540_match[] = {
+  { .compatible = "sifive,fu540" },
+  { .compatible = "sifive,fu540g" },
+  { .compatible = "sifive,fu540-c000" },
+  { .compatible = "sifive,hifive-unleashed-a00" },
+  { },
+};
+
+const struct platform_override sifive_fu540 = {
+  .match_table = sifive_fu540_match,
+  .tlbr_flush_limit = sifive_fu540_tlbr_flush_limit,
+  .fdt_fixup = sifive_fu540_fdt_fixup,
+};
+
+const struct platform_override *special_platforms[] = {
+  &sifive_fu540,
+};
+INTN NumberOfPlaformsInArray = array_size(special_platforms);
-- 
2.31.1



-=-=-=-=-=-=-=-=-=-=-=-
Groups.io Links: You receive all messages sent to this group.
View/Reply Online (#82331): https://edk2.groups.io/g/devel/message/82331
Mute This Topic: https://groups.io/mt/86435683/1813853
Group Owner: devel+owner at edk2.groups.io
Unsubscribe: https://edk2.groups.io/g/devel/unsub [edk2-devel-archive at redhat.com]
-=-=-=-=-=-=-=-=-=-=-=-






More information about the edk2-devel-archive mailing list