Skip to contentSkip to conversation

Initial ESWIN/EIC7700 support

PATCH Superseded Bo Gan 2 participants 11 messages Nov 11, 2025 – Nov 12, 2025 RISC-V

v1 of 6 Superseded Latest is v6 →

lore
Share & tools
lore

Bo Gan

author
#0 lore raw

cover Initial ESWIN/EIC7700 support

EIC7700 is the SoC used in HiFive P550 and Milk-V Megrez. This SoC is currently one of the only off-the-shelf board/chips that support H extension, although it's v0.6.1. It also supports pre-ratified N-trace. Add support for it so people can benefit from latest OpenSBI features.

The device-tree of HiFive P550 has been upstreamed to Linux:
https://lore.kernel.org/all/[email protected]/
However U-boot is not, and there are bugs in vendor U-boot device-tree, and also inconsistencies between the two. Thus, this patch is coded with the upstreamed device-tree as the reference, but tested with the patched vendor U-boot device tree as FW_FDT_PATH. The patched vendor U-boot is hosted here: https://github.com/ganboing/u-boot-eic7x/tree/eic7x-dt-fix
Refer to PATCH 3/3 for the instructions on building the firmware blob and launch it through UART boot.

The major complication of this chip is that it requires certain memory regions to be blocked with PMP entries to prevent speculative execution or HW prefetcher from touching them to avoid bus errors. The logic of handling PMP is therefore enhanced to support TOR entries and allow the platform to override PMP configuration. The platform code then properly set the SoC/Chip specific PMP entries alongside with the ones passed by generic code in lib/.

Bo Gan (3):
lib: sbi: allow platform to override PMP configuration
lib: sbi: Add pmp_set_tor for setting TOR regions
platform: generic: eswin: add EIC7700

 include/sbi/riscv_asm.h                  |   4 +
 include/sbi/sbi_hart.h                   |   9 ++
 include/sbi/sbi_platform.h               |  33 +++++
 lib/sbi/riscv_asm.c                      |  75 ++++++++---
 lib/sbi/sbi_hart.c                       |  27 ++--
 platform/generic/Kconfig                 |   5 +
 platform/generic/configs/defconfig       |   1 +
 platform/generic/eswin/Kconfig           |  29 ++++
 platform/generic/eswin/eic770x.c         | 165 +++++++++++++++++++++++
 platform/generic/eswin/objects.mk        |  11 ++
 platform/generic/include/eswin/eic770x.h |  49 +++++++
 11 files changed, 383 insertions(+), 25 deletions(-)
 create mode 100644 platform/generic/eswin/Kconfig
 create mode 100644 platform/generic/eswin/eic770x.c
 create mode 100644 platform/generic/eswin/objects.mk
 create mode 100644 platform/generic/include/eswin/eic770x.h
Signature · 7 lines
2.34.1


-- 
opensbi mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/opensbi
author
#1 lore raw

PATCH 1/3 lib: sbi: allow platform to override PMP configuration

Platform sometimes wants to override the entire PMP configuration phase, not just performing additional work for each individual PMP entry. This allows platforms to insert SoC/core specific PMP entries in a way that works together with the existing ones set by lib/ code, not conflicting. platform can also choose to merge or skip memory regions in a reasonable way in case there's a shortage of PMP entries.

In addition, sbi_hart_oldpmp_configure is made public and a callback function skip is added, so platform code can built on top of it to simplify PMP configuration override.

---
 include/sbi/sbi_hart.h     |  9 +++++++++
 include/sbi/sbi_platform.h | 33 +++++++++++++++++++++++++++++++++
 lib/sbi/sbi_hart.c         | 27 +++++++++++++++++++--------
 3 files changed, 61 insertions(+), 8 deletions(-)
include/sbi/sbi_hart.h +9 -0
index e66dd52f..e5a221bd 100644
@@ -133,6 +133,7 @@ struct sbi_hart_features {
 };
 
 struct sbi_scratch;
+struct sbi_domain_memregion;
 
 int sbi_hart_reinit(struct sbi_scratch *scratch);
 int sbi_hart_init(struct sbi_scratch *scratch, bool cold_boot);
@@ -148,6 +149,14 @@ unsigned int sbi_hart_pmp_addrbits(struct sbi_scratch *scratch);
 unsigned int sbi_hart_mhpm_bits(struct sbi_scratch *scratch);
 bool sbi_hart_smepmp_is_fw_region(unsigned int pmp_idx);
 int sbi_hart_pmp_configure(struct sbi_scratch *scratch);
+int sbi_hart_oldpmp_configure(struct sbi_scratch *scratch,
+			      unsigned int pmp_start,
+			      unsigned int pmp_count,
+			      unsigned int pmp_log2gran,
+			      unsigned long pmp_addr_max,
+			      bool (*skip)(struct sbi_domain_memregion *reg,
+					   void *data),
+			      void *data);
 int sbi_hart_map_saddr(unsigned long base, unsigned long size);
 int sbi_hart_unmap_saddr(void);
 int sbi_hart_priv_version(struct sbi_scratch *scratch);
include/sbi/sbi_platform.h +33 -0
index d75c12de..c6fc137f 100644
@@ -146,6 +146,11 @@ struct sbi_platform_operations {
 			unsigned long log2len);
 	/** platform specific pmp disable on current HART */
 	void (*pmp_disable)(unsigned int n);
+
+	/** platform pmp configure override on current HART */
+	int (*pmp_configure)(unsigned int pmp_count,
+			     unsigned int pmp_log2gran,
+			     unsigned long pmp_addr_max);
 };
 
 /** Platform default per-HART stack size for exception/interrupt handling */
@@ -666,6 +671,34 @@ static inline void sbi_platform_pmp_disable(const struct sbi_platform *plat,
 		sbi_platform_ops(plat)->pmp_disable(n);
 }
 
+/**
+ * Check if platform wants to override PMP configuration
+ *
+ * @param plat pointer to struct sbi_platform
+ */
+static inline bool sbi_platform_pmp_override(const struct sbi_platform *plat)
+{
+	return plat && sbi_platform_ops(plat)->pmp_configure;
+}
+
+/**
+ * Platform PMP configuration override
+ *
+ * @param plat pointer to struct sbi_platform
+ * @param pmp_count number of PMP entries
+ * @param pmp_log2gran PMP granularity
+ * @param pmp_addr_max largest value pmpaddr(x) can hold
+ */
+static inline int sbi_platform_pmp_configure(const struct sbi_platform *plat,
+					     unsigned int pmp_count,
+					     unsigned int pmp_log2gran,
+					     unsigned long pmp_addr_max)
+{
+	return sbi_platform_ops(plat)->pmp_configure(pmp_count,
+						     pmp_log2gran,
+						     pmp_addr_max);
+}
+
 #endif
 
 #endif
lib/sbi/sbi_hart.c +19 -8
index a91703b4..4425f36b 100644
@@ -433,18 +433,24 @@ static int sbi_hart_smepmp_configure(struct sbi_scratch *scratch,
 	return 0;
 }
 
-static int sbi_hart_oldpmp_configure(struct sbi_scratch *scratch,
-				     unsigned int pmp_count,
-				     unsigned int pmp_log2gran,
-				     unsigned long pmp_addr_max)
+int sbi_hart_oldpmp_configure(struct sbi_scratch *scratch,
+			      unsigned int pmp_start,
+			      unsigned int pmp_count,
+			      unsigned int pmp_log2gran,
+			      unsigned long pmp_addr_max,
+			      bool (*skip)(struct sbi_domain_memregion *reg,
+					   void *data),
+			      void *data)
 {
 	struct sbi_domain_memregion *reg;
 	struct sbi_domain *dom = sbi_domain_thishart_ptr();
-	unsigned int pmp_idx = 0;
+	unsigned int pmp_idx = pmp_start;
 	unsigned int pmp_flags;
 	unsigned long pmp_addr;
 
 	sbi_domain_for_each_memregion(dom, reg) {
+		if (skip && skip(reg, data))
+			continue;
 		if (!is_valid_pmp_idx(pmp_count, pmp_idx))
 			return SBI_EFAIL;
 
@@ -534,6 +540,7 @@ int sbi_hart_pmp_configure(struct sbi_scratch *scratch)
 	unsigned int pmp_bits, pmp_log2gran;
 	unsigned int pmp_count = sbi_hart_pmp_count(scratch);
 	unsigned long pmp_addr_max;
+	const struct sbi_platform *plat = sbi_platform_ptr(scratch);
 
 	if (!pmp_count)
 		return 0;
@@ -542,12 +549,16 @@ int sbi_hart_pmp_configure(struct sbi_scratch *scratch)
 	pmp_bits = sbi_hart_pmp_addrbits(scratch) - 1;
 	pmp_addr_max = (1UL << pmp_bits) | ((1UL << pmp_bits) - 1);
 
-	if (sbi_hart_has_extension(scratch, SBI_HART_EXT_SMEPMP))
+	if (sbi_platform_pmp_override(plat))
+		rc = sbi_platform_pmp_configure(plat, pmp_count,
+						pmp_log2gran, pmp_addr_max);
+	else if (sbi_hart_has_extension(scratch, SBI_HART_EXT_SMEPMP))
 		rc = sbi_hart_smepmp_configure(scratch, pmp_count,
 						pmp_log2gran, pmp_addr_max);
 	else
-		rc = sbi_hart_oldpmp_configure(scratch, pmp_count,
-						pmp_log2gran, pmp_addr_max);
+		rc = sbi_hart_oldpmp_configure(scratch, 0, pmp_count,
+						pmp_log2gran, pmp_addr_max,
+						NULL, NULL);
 
 	/*
 	 * As per section 3.7.2 of privileged specification v1.12,
Signature · 7 lines
2.34.1


-- 
opensbi mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/opensbi
#2 lore raw

Re: [PATCH 1/3] lib: sbi: allow platform to override PMP configuration

Quoted 31 lines · 在 2025-11-10一的 19:41 -0800,Bo Gan写道:

Platform sometimes wants to override the entire PMP configuration phase, not just performing additional work for each individual PMP entry. This allows platforms to insert SoC/core specific PMP entries in a way that works together with the existing ones set by lib/ code, not conflicting. platform can also choose to merge or skip memory regions in a reasonable way in case there's a shortage of PMP entries.

In addition, sbi_hart_oldpmp_configure is made public and a callback function skip is added, so platform code can built on top of it to simplify PMP configuration override.

---
 include/sbi/sbi_hart.h     |  9 +++++++++ include/sbi/sbi_platform.h | 33 +++++++++++++++++++++++++++++++++ lib/sbi/sbi_hart.c         | 27 +++++++++++++++++++--------

 3 files changed, 61 insertions(+), 8 deletions(-)
include/sbi/sbi_hart.h +0 -0
index e66dd52f..e5a221bd 100644
@@ -133,6 +133,7 @@ struct sbi_hart_features {
  };


 struct sbi_scratch;
+struct sbi_domain_memregion;

 int sbi_hart_reinit(struct sbi_scratch *scratch);
 int sbi_hart_init(struct sbi_scratch *scratch, bool cold_boot);

include/sbi/sbi_hart.h unsigned int sbi_hart_pmp_addrbits(struct sbi_scratch *scratch); · line 153

Quoted 5 lines
include/sbi/sbi_hart.h +2 -0
@@ -148,6 +149,14 @@ unsigned int sbi_hart_pmp_addrbits(struct sbi_scratch *scratch);
  unsigned int sbi_hart_mhpm_bits(struct sbi_scratch *scratch);
  bool sbi_hart_smepmp_is_fw_region(unsigned int pmp_idx);
  int sbi_hart_pmp_configure(struct sbi_scratch *scratch);
+int sbi_hart_oldpmp_configure(struct sbi_scratch *scratch,
+			      unsigned int pmp_start,

It is recommended to change the declaration from pmp_start to pmp_reserved. Otherwise, it might give the misleading impression that the last pmp is pmp_start + pmp_count - 1.

Regards,
Xiang W

Quoted 125 lines
include/sbi/sbi_hart.h +6 -0
+			      unsigned int pmp_count,
+			      unsigned int pmp_log2gran,
+			      unsigned long pmp_addr_max,
+			      bool (*skip)(struct sbi_domain_memregion *reg,
+					   void *data),
+			      void *data);
  int sbi_hart_map_saddr(unsigned long base, unsigned long size);
  int sbi_hart_unmap_saddr(void);
  int sbi_hart_priv_version(struct sbi_scratch *scratch);
include/sbi/sbi_platform.h +5 -0
index d75c12de..c6fc137f 100644
@@ -146,6 +146,11 @@ struct sbi_platform_operations {
  			unsigned long log2len);
  	/** platform specific pmp disable on current HART */
  	void (*pmp_disable)(unsigned int n);
+
+	/** platform pmp configure override on current HART */
+	int (*pmp_configure)(unsigned int pmp_count,
+			     unsigned int pmp_log2gran,
+			     unsigned long pmp_addr_max);
  };


 /** Platform default per-HART stack size for exception/interrupt handling */

include/sbi/sbi_platform.h +0 -0
@@ -666,6 +671,34 @@ static inline void sbi_platform_pmp_disable(const struct sbi_platform *plat,
  		sbi_platform_ops(plat)->pmp_disable(n);
  }

include/sbi/sbi_platform.h +28 -0
+/**
+ * Check if platform wants to override PMP configuration
+ *
+ * @param plat pointer to struct sbi_platform
+ */
+static inline bool sbi_platform_pmp_override(const struct sbi_platform *plat)
+{
+	return plat && sbi_platform_ops(plat)->pmp_configure;
+}
+
+/**
+ * Platform PMP configuration override
+ *
+ * @param plat pointer to struct sbi_platform
+ * @param pmp_count number of PMP entries
+ * @param pmp_log2gran PMP granularity
+ * @param pmp_addr_max largest value pmpaddr(x) can hold
+ */
+static inline int sbi_platform_pmp_configure(const struct sbi_platform *plat,
+					     unsigned int pmp_count,
+					     unsigned int pmp_log2gran,
+					     unsigned long pmp_addr_max)
+{
+	return sbi_platform_ops(plat)->pmp_configure(pmp_count,
+						     pmp_log2gran,
+						     pmp_addr_max);
+}
+

 #endif

 #endif

lib/sbi/sbi_hart.c +0 -0
index a91703b4..4425f36b 100644
@@ -433,18 +433,24 @@ static int sbi_hart_smepmp_configure(struct sbi_scratch *scratch,
  	return 0;
  }

lib/sbi/sbi_hart.c +8 -4
-static int sbi_hart_oldpmp_configure(struct sbi_scratch *scratch,
-				     unsigned int pmp_count,
-				     unsigned int pmp_log2gran,
-				     unsigned long pmp_addr_max)
+int sbi_hart_oldpmp_configure(struct sbi_scratch *scratch,
+			      unsigned int pmp_start,
+			      unsigned int pmp_count,
+			      unsigned int pmp_log2gran,
+			      unsigned long pmp_addr_max,
+			      bool (*skip)(struct sbi_domain_memregion *reg,
+					   void *data),
+			      void *data)

 {
  struct sbi_domain_memregion *reg;
  struct sbi_domain *dom = sbi_domain_thishart_ptr();

lib/sbi/sbi_hart.c +1 -1
-	unsigned int pmp_idx = 0;
+	unsigned int pmp_idx = pmp_start;

  unsigned int pmp_flags;
  unsigned long pmp_addr;

  sbi_domain_for_each_memregion(dom, reg) {

lib/sbi/sbi_hart.c +2 -0
+		if (skip && skip(reg, data))
+			continue;

  if (!is_valid_pmp_idx(pmp_count, pmp_idx)) return SBI_EFAIL;

lib/sbi/sbi_hart.c +1 -0
@@ -534,6 +540,7 @@ int sbi_hart_pmp_configure(struct sbi_scratch *scratch)
  	unsigned int pmp_bits, pmp_log2gran;
  	unsigned int pmp_count = sbi_hart_pmp_count(scratch);
  	unsigned long pmp_addr_max;
+	const struct sbi_platform *plat = sbi_platform_ptr(scratch);


  if (!pmp_count)
  return 0;

lib/sbi/sbi_hart.c +0 -0
@@ -542,12 +549,16 @@ int sbi_hart_pmp_configure(struct sbi_scratch *scratch)
  	pmp_bits = sbi_hart_pmp_addrbits(scratch) - 1;
  	pmp_addr_max = (1UL << pmp_bits) | ((1UL << pmp_bits) - 1);

lib/sbi/sbi_hart.c +4 -1
-	if (sbi_hart_has_extension(scratch, SBI_HART_EXT_SMEPMP))
+	if (sbi_platform_pmp_override(plat))
+		rc = sbi_platform_pmp_configure(plat, pmp_count,
+						pmp_log2gran, pmp_addr_max);
+	else if (sbi_hart_has_extension(scratch, SBI_HART_EXT_SMEPMP))

  rc = sbi_hart_smepmp_configure(scratch, pmp_count, pmp_log2gran, pmp_addr_max); else

lib/sbi/sbi_hart.c +3 -2
-		rc = sbi_hart_oldpmp_configure(scratch, pmp_count,
-						pmp_log2gran, pmp_addr_max);
+		rc = sbi_hart_oldpmp_configure(scratch, 0, pmp_count,
+						pmp_log2gran, pmp_addr_max,
+						NULL, NULL);


  /*
  * As per section 3.7.2 of privileged specification v1.12,

Signature · 1 line
2.34.1
Signature · 3 lines
opensbi mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/opensbi
author
#3 lore raw

Re: [PATCH 1/3] lib: sbi: allow platform to override PMP configuration

Hi Xiang,

Quoted 41 lines · Xiang W
Quoted 31 lines · 在 2025-11-10一的 19:41 -0800,Bo Gan写道:

Platform sometimes wants to override the entire PMP configuration phase, not just performing additional work for each individual PMP entry. This allows platforms to insert SoC/core specific PMP entries in a way that works together with the existing ones set by lib/ code, not conflicting. platform can also choose to merge or skip memory regions in a reasonable way in case there's a shortage of PMP entries.

In addition, sbi_hart_oldpmp_configure is made public and a callback function skip is added, so platform code can built on top of it to simplify PMP configuration override.

---
  include/sbi/sbi_hart.h     |  9 +++++++++
  include/sbi/sbi_platform.h | 33 +++++++++++++++++++++++++++++++++
  lib/sbi/sbi_hart.c         | 27 +++++++++++++++++++--------
  3 files changed, 61 insertions(+), 8 deletions(-)
include/sbi/sbi_hart.h +1 -0
index e66dd52f..e5a221bd 100644
@@ -133,6 +133,7 @@ struct sbi_hart_features {
  };
 
  struct sbi_scratch;
+struct sbi_domain_memregion;
 
  int sbi_hart_reinit(struct sbi_scratch *scratch);
  int sbi_hart_init(struct sbi_scratch *scratch, bool cold_boot);

include/sbi/sbi_hart.h unsigned int sbi_hart_pmp_addrbits(struct sbi_scratch *scratch); · line 153

Quoted 5 lines
include/sbi/sbi_hart.h +2 -0
@@ -148,6 +149,14 @@ unsigned int sbi_hart_pmp_addrbits(struct sbi_scratch *scratch);
  unsigned int sbi_hart_mhpm_bits(struct sbi_scratch *scratch);
  bool sbi_hart_smepmp_is_fw_region(unsigned int pmp_idx);
  int sbi_hart_pmp_configure(struct sbi_scratch *scratch);
+int sbi_hart_oldpmp_configure(struct sbi_scratch *scratch,
+			      unsigned int pmp_start,

It is recommended to change the declaration from pmp_start to pmp_reserved. Otherwise, it might give the misleading impression that the last pmp is pmp_start + pmp_count - 1.

Quoted 2 lines

Regards,
Xiang W

Thanks for the review. Yes, this pmp_start/pmp_count is indeed misleading. I'll address it in the next version.

Bo

Quoted 126 lines
Quoted 125 lines
include/sbi/sbi_hart.h +6 -0
+			      unsigned int pmp_count,
+			      unsigned int pmp_log2gran,
+			      unsigned long pmp_addr_max,
+			      bool (*skip)(struct sbi_domain_memregion *reg,
+					   void *data),
+			      void *data);
  int sbi_hart_map_saddr(unsigned long base, unsigned long size);
  int sbi_hart_unmap_saddr(void);
  int sbi_hart_priv_version(struct sbi_scratch *scratch);
include/sbi/sbi_platform.h +33 -0
index d75c12de..c6fc137f 100644
@@ -146,6 +146,11 @@ struct sbi_platform_operations {
  			unsigned long log2len);
  	/** platform specific pmp disable on current HART */
  	void (*pmp_disable)(unsigned int n);
+
+	/** platform pmp configure override on current HART */
+	int (*pmp_configure)(unsigned int pmp_count,
+			     unsigned int pmp_log2gran,
+			     unsigned long pmp_addr_max);
  };
 
  /** Platform default per-HART stack size for exception/interrupt handling */
@@ -666,6 +671,34 @@ static inline void sbi_platform_pmp_disable(const struct sbi_platform *plat,
  		sbi_platform_ops(plat)->pmp_disable(n);
  }
 
+/**
+ * Check if platform wants to override PMP configuration
+ *
+ * @param plat pointer to struct sbi_platform
+ */
+static inline bool sbi_platform_pmp_override(const struct sbi_platform *plat)
+{
+	return plat && sbi_platform_ops(plat)->pmp_configure;
+}
+
+/**
+ * Platform PMP configuration override
+ *
+ * @param plat pointer to struct sbi_platform
+ * @param pmp_count number of PMP entries
+ * @param pmp_log2gran PMP granularity
+ * @param pmp_addr_max largest value pmpaddr(x) can hold
+ */
+static inline int sbi_platform_pmp_configure(const struct sbi_platform *plat,
+					     unsigned int pmp_count,
+					     unsigned int pmp_log2gran,
+					     unsigned long pmp_addr_max)
+{
+	return sbi_platform_ops(plat)->pmp_configure(pmp_count,
+						     pmp_log2gran,
+						     pmp_addr_max);
+}
+
  #endif
 
  #endif
lib/sbi/sbi_hart.c +19 -8
index a91703b4..4425f36b 100644
@@ -433,18 +433,24 @@ static int sbi_hart_smepmp_configure(struct sbi_scratch *scratch,
  	return 0;
  }
 
-static int sbi_hart_oldpmp_configure(struct sbi_scratch *scratch,
-				     unsigned int pmp_count,
-				     unsigned int pmp_log2gran,
-				     unsigned long pmp_addr_max)
+int sbi_hart_oldpmp_configure(struct sbi_scratch *scratch,
+			      unsigned int pmp_start,
+			      unsigned int pmp_count,
+			      unsigned int pmp_log2gran,
+			      unsigned long pmp_addr_max,
+			      bool (*skip)(struct sbi_domain_memregion *reg,
+					   void *data),
+			      void *data)
  {
  	struct sbi_domain_memregion *reg;
  	struct sbi_domain *dom = sbi_domain_thishart_ptr();
-	unsigned int pmp_idx = 0;
+	unsigned int pmp_idx = pmp_start;
  	unsigned int pmp_flags;
  	unsigned long pmp_addr;
 
  	sbi_domain_for_each_memregion(dom, reg) {
+		if (skip && skip(reg, data))
+			continue;
  		if (!is_valid_pmp_idx(pmp_count, pmp_idx))
  			return SBI_EFAIL;
 
@@ -534,6 +540,7 @@ int sbi_hart_pmp_configure(struct sbi_scratch *scratch)
  	unsigned int pmp_bits, pmp_log2gran;
  	unsigned int pmp_count = sbi_hart_pmp_count(scratch);
  	unsigned long pmp_addr_max;
+	const struct sbi_platform *plat = sbi_platform_ptr(scratch);
 
  	if (!pmp_count)
  		return 0;
@@ -542,12 +549,16 @@ int sbi_hart_pmp_configure(struct sbi_scratch *scratch)
  	pmp_bits = sbi_hart_pmp_addrbits(scratch) - 1;
  	pmp_addr_max = (1UL << pmp_bits) | ((1UL << pmp_bits) - 1);
 
-	if (sbi_hart_has_extension(scratch, SBI_HART_EXT_SMEPMP))
+	if (sbi_platform_pmp_override(plat))
+		rc = sbi_platform_pmp_configure(plat, pmp_count,
+						pmp_log2gran, pmp_addr_max);
+	else if (sbi_hart_has_extension(scratch, SBI_HART_EXT_SMEPMP))
  		rc = sbi_hart_smepmp_configure(scratch, pmp_count,
  						pmp_log2gran, pmp_addr_max);
  	else
-		rc = sbi_hart_oldpmp_configure(scratch, pmp_count,
-						pmp_log2gran, pmp_addr_max);
+		rc = sbi_hart_oldpmp_configure(scratch, 0, pmp_count,
+						pmp_log2gran, pmp_addr_max,
+						NULL, NULL);
 
  	/*
  	 * As per section 3.7.2 of privileged specification v1.12,
Signature · 1 line
2.34.1
Signature · 3 lines
opensbi mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/opensbi
author
#4 lore raw

PATCH 2/3 lib: sbi: Add pmp_set_tor for setting TOR regions

In reply to Bo Gan

TOR can be utilized to cover memory regions that are not aligned with their sizes. Given that the address matching is formed bt 2 consecutive pmpaddr, i.e., pmpaddr(i-1) and pmpaddr(i), TOR should not be used generically to avoid pmpaddr conflict with other NA4/NAPOT regions.

It's advised to only use them in platform code where the caller can ensure the index and order of every pmp region especially when there's a mixture of TOR/NA4/NAPOT.

---
 include/sbi/riscv_asm.h |  4 +++
 lib/sbi/riscv_asm.c     | 75 +++++++++++++++++++++++++++++++----------
 2 files changed, 62 insertions(+), 17 deletions(-)
include/sbi/riscv_asm.h +4 -0
index ef48dc89..c23feab6 100644
@@ -218,6 +218,10 @@ int is_pmp_entry_mapped(unsigned long entry);
 int pmp_set(unsigned int n, unsigned long prot, unsigned long addr,
 	    unsigned long log2len);
 
+/* Top of range (TOR) matching mode. pmpaddr(n-1) will also be changed */
+int pmp_set_tor(unsigned int n, unsigned long prot, unsigned long addr,
+		unsigned long size);
+
 int pmp_get(unsigned int n, unsigned long *prot_out, unsigned long *addr_out,
 	    unsigned long *log2len);
 
lib/sbi/riscv_asm.c +58 -17

109 lines not on this page · raw message

Signature · 7 lines
2.34.1


-- 
opensbi mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/opensbi
#5 lore raw

Re: [PATCH 2/3] lib: sbi: Add pmp_set_tor for setting TOR regions

Quoted 10 lines · 在 2025-11-10一的 19:41 -0800,Bo Gan写道:

TOR can be utilized to cover memory regions that are not aligned with their sizes. Given that the address matching is formed bt 2 consecutive pmpaddr, i.e., pmpaddr(i-1) and pmpaddr(i), TOR should not be used generically to avoid pmpaddr conflict with other NA4/NAPOT regions.

It's advised to only use them in platform code where the caller can ensure the index and order of every pmp region especially when there's a mixture of TOR/NA4/NAPOT.

Some suggestions:
1. Merge pmp_set_addr/pmp_set_port into
void static void pmp_set_raw(unsigned int n,
unsigned long port, unsigned long pmpaddr)

2. Modify the declaration of pmp_set to
int pmp_set(bool is_tor, unsigned int n, unsigned long port,
unsigned long addr, unsigned long opaque)

Regards,
Xiang W

Quoted 140 lines

---
 include/sbi/riscv_asm.h |  4 +++
 lib/sbi/riscv_asm.c     | 75 +++++++++++++++++++++++++++++++----------

 2 files changed, 62 insertions(+), 17 deletions(-)
include/sbi/riscv_asm.h +0 -0
index ef48dc89..c23feab6 100644
@@ -218,6 +218,10 @@ int is_pmp_entry_mapped(unsigned long entry);
  int pmp_set(unsigned int n, unsigned long prot, unsigned long addr,
  	    unsigned long log2len);

include/sbi/riscv_asm.h +4 -0
+/* Top of range (TOR) matching mode. pmpaddr(n-1) will also be changed */
+int pmp_set_tor(unsigned int n, unsigned long prot, unsigned long addr,
+		unsigned long size);
+

 int pmp_get(unsigned int n, unsigned long *prot_out, unsigned long *addr_out, unsigned long *log2len);

lib/sbi/riscv_asm.c +0 -0
index 3e44320f..8f64f2b5 100644
@@ -330,16 +330,10 @@ int is_pmp_entry_mapped(unsigned long entry)
  	return false;
  }

lib/sbi/riscv_asm.c +1 -2
-int pmp_set(unsigned int n, unsigned long prot, unsigned long addr,
-	    unsigned long log2len)
+static void pmp_set_prot(unsigned int n, unsigned long prot)

 {

lib/sbi/riscv_asm.c +1 -1
-	int pmpcfg_csr, pmpcfg_shift, pmpaddr_csr;
+	int pmpcfg_csr, pmpcfg_shift;

  unsigned long cfgmask, pmpcfg;

lib/sbi/riscv_asm.c +0 -5
-	unsigned long addrmask, pmpaddr;
-
-	/* check parameters */
-	if (n >= PMP_COUNT || log2len > __riscv_xlen || log2len < PMP_SHIFT)
-		return SBI_EINVAL;


  /* calculate PMP register and offset */
 #if __riscv_xlen == 32

lib/sbi/riscv_asm.c +0 -5
@@ -351,15 +345,29 @@ int pmp_set(unsigned int n, unsigned long prot, unsigned long addr,
  #else
  # error "Unexpected __riscv_xlen"
  #endif
-	pmpaddr_csr = CSR_PMPADDR0 + n;
-
-	/* encode PMP config */
-	prot &= ~PMP_A;
-	prot |= (log2len == PMP_SHIFT) ? PMP_A_NA4 : PMP_A_NAPOT;
  	cfgmask = ~(0xffUL << pmpcfg_shift);
  	pmpcfg	= (csr_read_num(pmpcfg_csr) & cfgmask);
  	pmpcfg |= ((prot << pmpcfg_shift) & ~cfgmask);

lib/sbi/riscv_asm.c +19 -0
+	csr_write_num(pmpcfg_csr, pmpcfg);
+}
+
+static void pmp_set_addr(unsigned int n, unsigned long pmpaddr)
+{
+	int pmpaddr_csr = CSR_PMPADDR0 + n;
+
+	csr_write_num(pmpaddr_csr, pmpaddr);
+}
+
+int pmp_set(unsigned int n, unsigned long prot, unsigned long addr,
+	    unsigned long log2len)
+{
+	unsigned long addrmask, pmpaddr;
+
+	/* check parameters */
+	if (n >= PMP_COUNT || log2len > __riscv_xlen || log2len < PMP_SHIFT)
+		return SBI_EINVAL;
+

  /* encode PMP address */
  if (log2len == PMP_SHIFT) {
  pmpaddr = (addr >> PMP_SHIFT);

lib/sbi/riscv_asm.c +0 -0
@@ -373,10 +381,41 @@ int pmp_set(unsigned int n, unsigned long prot, unsigned long addr,
  		}
  	}

lib/sbi/riscv_asm.c +4 -0
+	/* encode PMP config */
+	prot &= ~PMP_A;
+	prot |= (log2len == PMP_SHIFT) ? PMP_A_NA4 : PMP_A_NAPOT;
+

  /* write csrs */

lib/sbi/riscv_asm.c +20 -2
-	csr_write_num(pmpaddr_csr, pmpaddr);
-	csr_write_num(pmpcfg_csr, pmpcfg);
+	pmp_set_addr(n, pmpaddr);
+	pmp_set_prot(n, prot);
+	return 0;
+}
+
+int pmp_set_tor(unsigned int n, unsigned long prot, unsigned long addr,
+		unsigned long size)
+{
+	unsigned long pmpaddr, pmpaddrp;
+
+	/* check parameters */
+	if (n >= PMP_COUNT)
+		return SBI_EINVAL;
+
+	if (n == 0 && addr != 0)
+		return SBI_EINVAL;
+
+	/* encode PMP address */
+	pmpaddrp = addr >> PMP_SHIFT;
+	pmpaddr = (addr + size) >> PMP_SHIFT;

lib/sbi/riscv_asm.c +9 -0
+	/* encode PMP config */
+	prot &= ~PMP_A;
+	prot |= PMP_A_TOR;
+
+	/* write csrs */
+	if (n)
+		pmp_set_addr(n - 1, pmpaddrp);
+	pmp_set_addr(n, pmpaddr);
+	pmp_set_prot(n, prot);

  return 0;
 }

lib/sbi/riscv_asm.c +4 -2
@@ -420,10 +459,12 @@ int pmp_get(unsigned int n, unsigned long *prot_out, unsigned long *addr_out,
  			addr	= (addr & ~((1UL << t1) - 1)) << PMP_SHIFT;
  			len	= (t1 + PMP_SHIFT + 1);
  		}
-	} else {
+	} else if ((prot & PMP_A) == PMP_A_NA4) {
  		addr	= csr_read_num(pmpaddr_csr) << PMP_SHIFT;
  		len	= PMP_SHIFT;
-	}
+	} else
+		/* Error out for TOR region */
+		return SBI_EINVAL;


  /* return details */
  *prot_out    = prot;

Signature · 1 line
2.34.1
Signature · 3 lines
opensbi mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/opensbi
author
#6 lore raw

Re: [PATCH 2/3] lib: sbi: Add pmp_set_tor for setting TOR regions

Hi Xiang,

Quoted 17 lines · Xiang W
Quoted 10 lines · 在 2025-11-10一的 19:41 -0800,Bo Gan写道:

TOR can be utilized to cover memory regions that are not aligned with their sizes. Given that the address matching is formed bt 2 consecutive pmpaddr, i.e., pmpaddr(i-1) and pmpaddr(i), TOR should not be used generically to avoid pmpaddr conflict with other NA4/NAPOT regions.

It's advised to only use them in platform code where the caller can ensure the index and order of every pmp region especially when there's a mixture of TOR/NA4/NAPOT.

Some suggestions:
1. Merge pmp_set_addr/pmp_set_port into
void static void pmp_set_raw(unsigned int n,
unsigned long port, unsigned long pmpaddr)

Quoted 6 lines

2. Modify the declaration of pmp_set to
int pmp_set(bool is_tor, unsigned int n, unsigned long port,
unsigned long addr, unsigned long opaque)

Regards,
Xiang W

I assume you meant port -> prot. For 1, I don't quite like it because it kind of assumes you always change a pmpaddr[i]/pmpcfg[i] pair. In the TOR case, often times you change pmpaddr[i-1] and pmpaddr[i], then pmpcfg[i]. An edge case is when addr == 0 and n == 0, for it we only update pmpaddr0, then pmpcfg0. Perhaps I'm mistaken, and you are suggesting pmp_set_raw can handle different cases based on whether prot is TOR? Then I'd say it probably makes the code more complicated than necessary, as the check can already be made on the caller side, or no TOR check is necessary with my different function approach.

For 2, my rationale on having a different function is that I want to keep all existing pmp_set the same way, and try to discourage the use of TOR. Maybe I should have added a warning in the comment in header file. The reason is because TOR makes the PMP entries dependent on preceding ones, so care must be taken when programming them. The caller must have global knowledge of potentially all PMP entries to be programmed in order to use it properly. I don't feel comfortable unifying to the same interface for TOR and NA4/NAPOT.

Let me know what you think. I'm happy to listen. Thanks.

Bo

Quoted 141 lines
Quoted 140 lines
---
  include/sbi/riscv_asm.h |  4 +++
  lib/sbi/riscv_asm.c     | 75 +++++++++++++++++++++++++++++++----------
  2 files changed, 62 insertions(+), 17 deletions(-)
include/sbi/riscv_asm.h +4 -0
index ef48dc89..c23feab6 100644
@@ -218,6 +218,10 @@ int is_pmp_entry_mapped(unsigned long entry);
  int pmp_set(unsigned int n, unsigned long prot, unsigned long addr,
  	    unsigned long log2len);
 
+/* Top of range (TOR) matching mode. pmpaddr(n-1) will also be changed */
+int pmp_set_tor(unsigned int n, unsigned long prot, unsigned long addr,
+		unsigned long size);
+
  int pmp_get(unsigned int n, unsigned long *prot_out, unsigned long *addr_out,
  	    unsigned long *log2len);
 
lib/sbi/riscv_asm.c +58 -17
index 3e44320f..8f64f2b5 100644
@@ -330,16 +330,10 @@ int is_pmp_entry_mapped(unsigned long entry)
  	return false;
  }
 
-int pmp_set(unsigned int n, unsigned long prot, unsigned long addr,
-	    unsigned long log2len)
+static void pmp_set_prot(unsigned int n, unsigned long prot)
  {
-	int pmpcfg_csr, pmpcfg_shift, pmpaddr_csr;
+	int pmpcfg_csr, pmpcfg_shift;
  	unsigned long cfgmask, pmpcfg;
-	unsigned long addrmask, pmpaddr;
-
-	/* check parameters */
-	if (n >= PMP_COUNT || log2len > __riscv_xlen || log2len < PMP_SHIFT)
-		return SBI_EINVAL;
 
  	/* calculate PMP register and offset */
  #if __riscv_xlen == 32
@@ -351,15 +345,29 @@ int pmp_set(unsigned int n, unsigned long prot, unsigned long addr,
  #else
  # error "Unexpected __riscv_xlen"
  #endif
-	pmpaddr_csr = CSR_PMPADDR0 + n;
-
-	/* encode PMP config */
-	prot &= ~PMP_A;
-	prot |= (log2len == PMP_SHIFT) ? PMP_A_NA4 : PMP_A_NAPOT;
  	cfgmask = ~(0xffUL << pmpcfg_shift);
  	pmpcfg	= (csr_read_num(pmpcfg_csr) & cfgmask);
  	pmpcfg |= ((prot << pmpcfg_shift) & ~cfgmask);
 
+	csr_write_num(pmpcfg_csr, pmpcfg);
+}
+
+static void pmp_set_addr(unsigned int n, unsigned long pmpaddr)
+{
+	int pmpaddr_csr = CSR_PMPADDR0 + n;
+
+	csr_write_num(pmpaddr_csr, pmpaddr);
+}
+
+int pmp_set(unsigned int n, unsigned long prot, unsigned long addr,
+	    unsigned long log2len)
+{
+	unsigned long addrmask, pmpaddr;
+
+	/* check parameters */
+	if (n >= PMP_COUNT || log2len > __riscv_xlen || log2len < PMP_SHIFT)
+		return SBI_EINVAL;
+
  	/* encode PMP address */
  	if (log2len == PMP_SHIFT) {
  		pmpaddr = (addr >> PMP_SHIFT);
@@ -373,10 +381,41 @@ int pmp_set(unsigned int n, unsigned long prot, unsigned long addr,
  		}
  	}
 
+	/* encode PMP config */
+	prot &= ~PMP_A;
+	prot |= (log2len == PMP_SHIFT) ? PMP_A_NA4 : PMP_A_NAPOT;
+
  	/* write csrs */
-	csr_write_num(pmpaddr_csr, pmpaddr);
-	csr_write_num(pmpcfg_csr, pmpcfg);
+	pmp_set_addr(n, pmpaddr);
+	pmp_set_prot(n, prot);
+	return 0;
+}
+
+int pmp_set_tor(unsigned int n, unsigned long prot, unsigned long addr,
+		unsigned long size)
+{
+	unsigned long pmpaddr, pmpaddrp;
+
+	/* check parameters */
+	if (n >= PMP_COUNT)
+		return SBI_EINVAL;
+
+	if (n == 0 && addr != 0)
+		return SBI_EINVAL;
+
+	/* encode PMP address */
+	pmpaddrp = addr >> PMP_SHIFT;
+	pmpaddr = (addr + size) >> PMP_SHIFT;
 
+	/* encode PMP config */
+	prot &= ~PMP_A;
+	prot |= PMP_A_TOR;
+
+	/* write csrs */
+	if (n)
+		pmp_set_addr(n - 1, pmpaddrp);
+	pmp_set_addr(n, pmpaddr);
+	pmp_set_prot(n, prot);
  	return 0;
  }
 
@@ -420,10 +459,12 @@ int pmp_get(unsigned int n, unsigned long *prot_out, unsigned long *addr_out,
  			addr	= (addr & ~((1UL << t1) - 1)) << PMP_SHIFT;
  			len	= (t1 + PMP_SHIFT + 1);
  		}
-	} else {
+	} else if ((prot & PMP_A) == PMP_A_NA4) {
  		addr	= csr_read_num(pmpaddr_csr) << PMP_SHIFT;
  		len	= PMP_SHIFT;
-	}
+	} else
+		/* Error out for TOR region */
+		return SBI_EINVAL;
 
  	/* return details */
  	*prot_out    = prot;
Signature · 1 line
2.34.1
Signature · 3 lines
opensbi mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/opensbi
#7 lore raw

Re: [PATCH 2/3] lib: sbi: Add pmp_set_tor for setting TOR regions

Quoted 27 lines · 在 2025-11-11二的 01:45 -0800,Bo Gan写道:

Hi Xiang,

Quoted 17 lines · Xiang W
Quoted 10 lines · 在 2025-11-10一的 19:41 -0800,Bo Gan写道:

TOR can be utilized to cover memory regions that are not aligned with their sizes. Given that the address matching is formed bt 2 consecutive pmpaddr, i.e., pmpaddr(i-1) and pmpaddr(i), TOR should not be used generically to avoid pmpaddr conflict with other NA4/NAPOT regions.

It's advised to only use them in platform code where the caller can ensure the index and order of every pmp region especially when there's a mixture of TOR/NA4/NAPOT.

Some suggestions:
1. Merge pmp_set_addr/pmp_set_port into
void static void pmp_set_raw(unsigned int n,
unsigned long port, unsigned long pmpaddr)

Quoted 6 lines

2. Modify the declaration of pmp_set to
int pmp_set(bool is_tor, unsigned int n, unsigned long port,
unsigned long addr, unsigned long opaque)

Regards,
Xiang W

Quoted 9 lines

I assume you meant port -> prot. For 1, I don't quite like it because it kind of assumes you always change a pmpaddr[i]/pmpcfg[i] pair. In the TOR case, often times you change pmpaddr[i-1] and pmpaddr[i], then pmpcfg[i]. An edge case is when addr == 0 and n == 0, for it we only update pmpaddr0, then pmpcfg0. Perhaps I'm mistaken, and you are suggesting pmp_set_raw can handle different cases based on whether prot is TOR? Then I'd say it probably makes the code more complicated than necessary, as the check can already be made on the caller side, or no TOR check is necessary with my different function approach.

The function pmp_set_raw is used to set pmpaddr[i]/pmpcfg[i].

Regarding the edge case you mentioned, calling pmp_set_raw once is sufficient. For regular Tor types, call it twice:

pmp_set_raw(n-1, 0, addr >> PMP_SHIFT)
pmp_set_raw(n,prot, (addr + size) >> PMP_SHIFT)

Quoted 9 lines

For 2, my rationale on having a different function is that I want to keep all existing pmp_set the same way, and try to discourage the use of TOR. Maybe I should have added a warning in the comment in header file. The reason is because TOR makes the PMP entries dependent on preceding ones, so care must be taken when programming them. The caller must have global knowledge of potentially all PMP entries to be programmed in order to use it properly. I don't feel comfortable unifying to the same interface for TOR and NA4/NAPOT.

The names pmp_set and pmp_set_tor give the impression that pmp_set is a general-purpose method, while pmp_set_tor is for handling special cases. In reality, pmp_set is not a general-purpose method.

Regards,
Xiang W

Quoted 146 lines

Let me know what you think. I'm happy to listen. Thanks.

Bo

Quoted 141 lines
Quoted 140 lines

---
  include/sbi/riscv_asm.h |  4 +++
  lib/sbi/riscv_asm.c     | 75 +++++++++++++++++++++++++++++++----------

  2 files changed, 62 insertions(+), 17 deletions(-)
include/sbi/riscv_asm.h +0 -0
index ef48dc89..c23feab6 100644
@@ -218,6 +218,10 @@ int is_pmp_entry_mapped(unsigned long entry);
   int pmp_set(unsigned int n, unsigned long prot, unsigned long addr,
   	    unsigned long log2len);

include/sbi/riscv_asm.h +4 -0
+/* Top of range (TOR) matching mode. pmpaddr(n-1) will also be changed */
+int pmp_set_tor(unsigned int n, unsigned long prot, unsigned long addr,
+		unsigned long size);
+

  int pmp_get(unsigned int n, unsigned long *prot_out, unsigned long *addr_out, unsigned long *log2len);

lib/sbi/riscv_asm.c +0 -0
index 3e44320f..8f64f2b5 100644
@@ -330,16 +330,10 @@ int is_pmp_entry_mapped(unsigned long entry)
   	return false;
   }

lib/sbi/riscv_asm.c +1 -2
-int pmp_set(unsigned int n, unsigned long prot, unsigned long addr,
-	    unsigned long log2len)
+static void pmp_set_prot(unsigned int n, unsigned long prot)

  {

lib/sbi/riscv_asm.c +1 -1
-	int pmpcfg_csr, pmpcfg_shift, pmpaddr_csr;
+	int pmpcfg_csr, pmpcfg_shift;

   unsigned long cfgmask, pmpcfg;

lib/sbi/riscv_asm.c +0 -5
-	unsigned long addrmask, pmpaddr;
-
-	/* check parameters */
-	if (n >= PMP_COUNT || log2len > __riscv_xlen || log2len < PMP_SHIFT)
-		return SBI_EINVAL;


   /* calculate PMP register and offset */
  #if __riscv_xlen == 32

lib/sbi/riscv_asm.c +0 -5
@@ -351,15 +345,29 @@ int pmp_set(unsigned int n, unsigned long prot, unsigned long addr,
   #else
   # error "Unexpected __riscv_xlen"
   #endif
-	pmpaddr_csr = CSR_PMPADDR0 + n;
-
-	/* encode PMP config */
-	prot &= ~PMP_A;
-	prot |= (log2len == PMP_SHIFT) ? PMP_A_NA4 : PMP_A_NAPOT;
   	cfgmask = ~(0xffUL << pmpcfg_shift);
   	pmpcfg	= (csr_read_num(pmpcfg_csr) & cfgmask);
   	pmpcfg |= ((prot << pmpcfg_shift) & ~cfgmask);

lib/sbi/riscv_asm.c +19 -0
+	csr_write_num(pmpcfg_csr, pmpcfg);
+}
+
+static void pmp_set_addr(unsigned int n, unsigned long pmpaddr)
+{
+	int pmpaddr_csr = CSR_PMPADDR0 + n;
+
+	csr_write_num(pmpaddr_csr, pmpaddr);
+}
+
+int pmp_set(unsigned int n, unsigned long prot, unsigned long addr,
+	    unsigned long log2len)
+{
+	unsigned long addrmask, pmpaddr;
+
+	/* check parameters */
+	if (n >= PMP_COUNT || log2len > __riscv_xlen || log2len < PMP_SHIFT)
+		return SBI_EINVAL;
+

   /* encode PMP address */
   if (log2len == PMP_SHIFT) {
   pmpaddr = (addr >> PMP_SHIFT);

lib/sbi/riscv_asm.c +0 -0
@@ -373,10 +381,41 @@ int pmp_set(unsigned int n, unsigned long prot, unsigned long addr,
   		}
   	}

lib/sbi/riscv_asm.c +4 -0
+	/* encode PMP config */
+	prot &= ~PMP_A;
+	prot |= (log2len == PMP_SHIFT) ? PMP_A_NA4 : PMP_A_NAPOT;
+

   /* write csrs */

lib/sbi/riscv_asm.c +20 -2
-	csr_write_num(pmpaddr_csr, pmpaddr);
-	csr_write_num(pmpcfg_csr, pmpcfg);
+	pmp_set_addr(n, pmpaddr);
+	pmp_set_prot(n, prot);
+	return 0;
+}
+
+int pmp_set_tor(unsigned int n, unsigned long prot, unsigned long addr,
+		unsigned long size)
+{
+	unsigned long pmpaddr, pmpaddrp;
+
+	/* check parameters */
+	if (n >= PMP_COUNT)
+		return SBI_EINVAL;
+
+	if (n == 0 && addr != 0)
+		return SBI_EINVAL;
+
+	/* encode PMP address */
+	pmpaddrp = addr >> PMP_SHIFT;
+	pmpaddr = (addr + size) >> PMP_SHIFT;

lib/sbi/riscv_asm.c +9 -0
+	/* encode PMP config */
+	prot &= ~PMP_A;
+	prot |= PMP_A_TOR;
+
+	/* write csrs */
+	if (n)
+		pmp_set_addr(n - 1, pmpaddrp);
+	pmp_set_addr(n, pmpaddr);
+	pmp_set_prot(n, prot);

   return 0;
  }

lib/sbi/riscv_asm.c +4 -2
@@ -420,10 +459,12 @@ int pmp_get(unsigned int n, unsigned long *prot_out, unsigned long *addr_out,
   			addr	= (addr & ~((1UL << t1) - 1)) << PMP_SHIFT;
   			len	= (t1 + PMP_SHIFT + 1);
   		}
-	} else {
+	} else if ((prot & PMP_A) == PMP_A_NA4) {
   		addr	= csr_read_num(pmpaddr_csr) << PMP_SHIFT;
   		len	= PMP_SHIFT;
-	}
+	} else
+		/* Error out for TOR region */
+		return SBI_EINVAL;


   /* return details */
   *prot_out    = prot;

Signature · 1 line
2.34.1
Signature · 3 lines
opensbi mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/opensbi
author
#8 lore raw

Re: [PATCH 2/3] lib: sbi: Add pmp_set_tor for setting TOR regions

Quoted 37 lines · Xiang W
Quoted 27 lines · 在 2025-11-11二的 01:45 -0800,Bo Gan写道:

Hi Xiang,

Quoted 17 lines · Xiang W
Quoted 10 lines · 在 2025-11-10一的 19:41 -0800,Bo Gan写道:

TOR can be utilized to cover memory regions that are not aligned with their sizes. Given that the address matching is formed bt 2 consecutive pmpaddr, i.e., pmpaddr(i-1) and pmpaddr(i), TOR should not be used generically to avoid pmpaddr conflict with other NA4/NAPOT regions.

It's advised to only use them in platform code where the caller can ensure the index and order of every pmp region especially when there's a mixture of TOR/NA4/NAPOT.

Some suggestions:
1. Merge pmp_set_addr/pmp_set_port into
void static void pmp_set_raw(unsigned int n,
unsigned long port, unsigned long pmpaddr)

Quoted 6 lines

2. Modify the declaration of pmp_set to
int pmp_set(bool is_tor, unsigned int n, unsigned long port,
unsigned long addr, unsigned long opaque)

Regards,
Xiang W

Quoted 9 lines

I assume you meant port -> prot. For 1, I don't quite like it because it kind of assumes you always change a pmpaddr[i]/pmpcfg[i] pair. In the TOR case, often times you change pmpaddr[i-1] and pmpaddr[i], then pmpcfg[i]. An edge case is when addr == 0 and n == 0, for it we only update pmpaddr0, then pmpcfg0. Perhaps I'm mistaken, and you are suggesting pmp_set_raw can handle different cases based on whether prot is TOR? Then I'd say it probably makes the code more complicated than necessary, as the check can already be made on the caller side, or no TOR check is necessary with my different function approach.

Quoted 8 lines

The function pmp_set_raw is used to set pmpaddr[i]/pmpcfg[i].

Regarding the edge case you mentioned, calling pmp_set_raw once is sufficient. For regular Tor types, call it twice:

pmp_set_raw(n-1, 0, addr >> PMP_SHIFT)
pmp_set_raw(n,prot, (addr + size) >> PMP_SHIFT)

We shouldn't do pmp_set_raw(n-1, 0, addr >> PMP_SHIFT), because it'll zero- out the corresponding pmpcfg of n-1.

This is actually the tricky part of TOR. You can have adjacent TOR regions that share the same pmpaddr, i.e., the same pmpaddr forms the upper-bound of previous region and lower-bound of current region. If we disallow this sharing, then potentially we'll end up with 2x the number of TOR regions. Thus, if lib/ code were to use TOR, either it would have to coordinate neighboring PMP entries, or a single PMP entry should own 2 pmpcfg/pmpaddr register pairs.

Quoted 9 lines
Quoted 9 lines

For 2, my rationale on having a different function is that I want to keep all existing pmp_set the same way, and try to discourage the use of TOR. Maybe I should have added a warning in the comment in header file. The reason is because TOR makes the PMP entries dependent on preceding ones, so care must be taken when programming them. The caller must have global knowledge of potentially all PMP entries to be programmed in order to use it properly. I don't feel comfortable unifying to the same interface for TOR and NA4/NAPOT.

Quoted 4 lines

The names pmp_set and pmp_set_tor give the impression that pmp_set is a general-purpose method, while pmp_set_tor is for handling special cases. In reality, pmp_set is not a general-purpose method.

Given those scenarios I mentioned earlier, I'd like to avoid making it overly complicated. I.e., lib/ code never set or get TOR regions, and can still safely assume the 1:1 correspondence of pmp index to pmpcfg/pmpaddr pair. Everything related to TOR is only used by platform pmp_configure override. Thus, the different function name, so the caller of set_tor can be easily identified.

Bo

Quoted 149 lines

Regards,
Xiang W

Quoted 146 lines

Let me know what you think. I'm happy to listen. Thanks.

Bo

Quoted 141 lines
Quoted 140 lines
---
   include/sbi/riscv_asm.h |  4 +++
   lib/sbi/riscv_asm.c     | 75 +++++++++++++++++++++++++++++++----------
   2 files changed, 62 insertions(+), 17 deletions(-)
include/sbi/riscv_asm.h +4 -0
index ef48dc89..c23feab6 100644
@@ -218,6 +218,10 @@ int is_pmp_entry_mapped(unsigned long entry);
   int pmp_set(unsigned int n, unsigned long prot, unsigned long addr,
   	    unsigned long log2len);
 
+/* Top of range (TOR) matching mode. pmpaddr(n-1) will also be changed */
+int pmp_set_tor(unsigned int n, unsigned long prot, unsigned long addr,
+		unsigned long size);
+
   int pmp_get(unsigned int n, unsigned long *prot_out, unsigned long *addr_out,
   	    unsigned long *log2len);
 
lib/sbi/riscv_asm.c +58 -17
index 3e44320f..8f64f2b5 100644
@@ -330,16 +330,10 @@ int is_pmp_entry_mapped(unsigned long entry)
   	return false;
   }
 
-int pmp_set(unsigned int n, unsigned long prot, unsigned long addr,
-	    unsigned long log2len)
+static void pmp_set_prot(unsigned int n, unsigned long prot)
   {
-	int pmpcfg_csr, pmpcfg_shift, pmpaddr_csr;
+	int pmpcfg_csr, pmpcfg_shift;
   	unsigned long cfgmask, pmpcfg;
-	unsigned long addrmask, pmpaddr;
-
-	/* check parameters */
-	if (n >= PMP_COUNT || log2len > __riscv_xlen || log2len < PMP_SHIFT)
-		return SBI_EINVAL;
 
   	/* calculate PMP register and offset */
   #if __riscv_xlen == 32
@@ -351,15 +345,29 @@ int pmp_set(unsigned int n, unsigned long prot, unsigned long addr,
   #else
   # error "Unexpected __riscv_xlen"
   #endif
-	pmpaddr_csr = CSR_PMPADDR0 + n;
-
-	/* encode PMP config */
-	prot &= ~PMP_A;
-	prot |= (log2len == PMP_SHIFT) ? PMP_A_NA4 : PMP_A_NAPOT;
   	cfgmask = ~(0xffUL << pmpcfg_shift);
   	pmpcfg	= (csr_read_num(pmpcfg_csr) & cfgmask);
   	pmpcfg |= ((prot << pmpcfg_shift) & ~cfgmask);
 
+	csr_write_num(pmpcfg_csr, pmpcfg);
+}
+
+static void pmp_set_addr(unsigned int n, unsigned long pmpaddr)
+{
+	int pmpaddr_csr = CSR_PMPADDR0 + n;
+
+	csr_write_num(pmpaddr_csr, pmpaddr);
+}
+
+int pmp_set(unsigned int n, unsigned long prot, unsigned long addr,
+	    unsigned long log2len)
+{
+	unsigned long addrmask, pmpaddr;
+
+	/* check parameters */
+	if (n >= PMP_COUNT || log2len > __riscv_xlen || log2len < PMP_SHIFT)
+		return SBI_EINVAL;
+
   	/* encode PMP address */
   	if (log2len == PMP_SHIFT) {
   		pmpaddr = (addr >> PMP_SHIFT);
@@ -373,10 +381,41 @@ int pmp_set(unsigned int n, unsigned long prot, unsigned long addr,
   		}
   	}
 
+	/* encode PMP config */
+	prot &= ~PMP_A;
+	prot |= (log2len == PMP_SHIFT) ? PMP_A_NA4 : PMP_A_NAPOT;
+
   	/* write csrs */
-	csr_write_num(pmpaddr_csr, pmpaddr);
-	csr_write_num(pmpcfg_csr, pmpcfg);
+	pmp_set_addr(n, pmpaddr);
+	pmp_set_prot(n, prot);
+	return 0;
+}
+
+int pmp_set_tor(unsigned int n, unsigned long prot, unsigned long addr,
+		unsigned long size)
+{
+	unsigned long pmpaddr, pmpaddrp;
+
+	/* check parameters */
+	if (n >= PMP_COUNT)
+		return SBI_EINVAL;
+
+	if (n == 0 && addr != 0)
+		return SBI_EINVAL;
+
+	/* encode PMP address */
+	pmpaddrp = addr >> PMP_SHIFT;
+	pmpaddr = (addr + size) >> PMP_SHIFT;
 
+	/* encode PMP config */
+	prot &= ~PMP_A;
+	prot |= PMP_A_TOR;
+
+	/* write csrs */
+	if (n)
+		pmp_set_addr(n - 1, pmpaddrp);
+	pmp_set_addr(n, pmpaddr);
+	pmp_set_prot(n, prot);
   	return 0;
   }
 
@@ -420,10 +459,12 @@ int pmp_get(unsigned int n, unsigned long *prot_out, unsigned long *addr_out,
   			addr	= (addr & ~((1UL << t1) - 1)) << PMP_SHIFT;
   			len	= (t1 + PMP_SHIFT + 1);
   		}
-	} else {
+	} else if ((prot & PMP_A) == PMP_A_NA4) {
   		addr	= csr_read_num(pmpaddr_csr) << PMP_SHIFT;
   		len	= PMP_SHIFT;
-	}
+	} else
+		/* Error out for TOR region */
+		return SBI_EINVAL;
 
   	/* return details */
   	*prot_out    = prot;
Signature · 1 line
2.34.1
Signature · 3 lines
opensbi mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/opensbi
#9 lore raw

Re: [PATCH 2/3] lib: sbi: Add pmp_set_tor for setting TOR regions

Quoted 50 lines · 在 2025-11-12三的 02:50 -0800,Bo Gan写道:
Quoted 37 lines · Xiang W
Quoted 27 lines · 在 2025-11-11二的 01:45 -0800,Bo Gan写道:

Hi Xiang,

Quoted 17 lines · Xiang W
Quoted 10 lines · 在 2025-11-10一的 19:41 -0800,Bo Gan写道:

TOR can be utilized to cover memory regions that are not aligned with their sizes. Given that the address matching is formed bt 2 consecutive pmpaddr, i.e., pmpaddr(i-1) and pmpaddr(i), TOR should not be used generically to avoid pmpaddr conflict with other NA4/NAPOT regions.

It's advised to only use them in platform code where the caller can ensure the index and order of every pmp region especially when there's a mixture of TOR/NA4/NAPOT.

Some suggestions:
1. Merge pmp_set_addr/pmp_set_port into
void static void pmp_set_raw(unsigned int n,
unsigned long port, unsigned long pmpaddr)

Quoted 6 lines

2. Modify the declaration of pmp_set to
int pmp_set(bool is_tor, unsigned int n, unsigned long port,
unsigned long addr, unsigned long opaque)

Regards,
Xiang W

Quoted 9 lines

I assume you meant port -> prot. For 1, I don't quite like it because it kind of assumes you always change a pmpaddr[i]/pmpcfg[i] pair. In the TOR case, often times you change pmpaddr[i-1] and pmpaddr[i], then pmpcfg[i]. An edge case is when addr == 0 and n == 0, for it we only update pmpaddr0, then pmpcfg0. Perhaps I'm mistaken, and you are suggesting pmp_set_raw can handle different cases based on whether prot is TOR? Then I'd say it probably makes the code more complicated than necessary, as the check can already be made on the caller side, or no TOR check is necessary with my different function approach.

Quoted 8 lines

The function pmp_set_raw is used to set pmpaddr[i]/pmpcfg[i].

Regarding the edge case you mentioned, calling pmp_set_raw once is sufficient. For regular Tor types, call it twice:

pmp_set_raw(n-1, 0, addr >> PMP_SHIFT)
pmp_set_raw(n,prot, (addr + size) >> PMP_SHIFT)

We shouldn't do pmp_set_raw(n-1, 0, addr >> PMP_SHIFT), because it'll zero- out the corresponding pmpcfg of n-1.

Quoted 7 lines

This is actually the tricky part of TOR. You can have adjacent TOR regions that share the same pmpaddr, i.e., the same pmpaddr forms the upper-bound of previous region and lower-bound of current region. If we disallow this sharing, then potentially we'll end up with 2x the number of TOR regions. Thus, if lib/ code were to use TOR, either it would have to coordinate neighboring PMP entries, or a single PMP entry should own 2 pmpcfg/pmpaddr register pairs.

Thank you for your detailed explanation.

Quoted 15 lines
Quoted 10 lines
Quoted 10 lines

For 2, my rationale on having a different function is that I want to keep all existing pmp_set the same way, and try to discourage the use of TOR. Maybe I should have added a warning in the comment in header file. The reason is because TOR makes the PMP entries dependent on preceding ones, so care must be taken when programming them. The caller must have global knowledge of potentially all PMP entries to be programmed in order to use it properly. I don't feel comfortable unifying to the same interface for TOR and NA4/NAPOT.

Quoted 4 lines

The names pmp_set and pmp_set_tor give the impression that pmp_set is a general-purpose method, while pmp_set_tor is for handling special cases. In reality, pmp_set is not a general-purpose method.

Quoted 6 lines

Given those scenarios I mentioned earlier, I'd like to avoid making it overly complicated. I.e., lib/ code never set or get TOR regions, and can still safely assume the 1:1 correspondence of pmp index to pmpcfg/pmpaddr pair. Everything related to TOR is only used by platform pmp_configure override. Thus, the different function name, so the caller of set_tor can be easily identified.

I agree that we should avoid unnecessary complexity and keep the lib/ code from directly handling TOR regions. To streamline things further, I suggest moving all TOR-related configurations to the platform code. This will help maintain clarity and allow the lib/ code to focus on its main responsibilities without the added burden of managing TOR settings.

Regards,
Xiang W

Quoted 152 lines

Bo

Quoted 149 lines

Regards,
Xiang W

Quoted 146 lines

Let me know what you think. I'm happy to listen. Thanks.

Bo

Quoted 141 lines
Quoted 140 lines

---
   include/sbi/riscv_asm.h |  4 +++
   lib/sbi/riscv_asm.c     | 75 +++++++++++++++++++++++++++++++----------

   2 files changed, 62 insertions(+), 17 deletions(-)
include/sbi/riscv_asm.h +0 -0
index ef48dc89..c23feab6 100644
@@ -218,6 +218,10 @@ int is_pmp_entry_mapped(unsigned long entry);
    int pmp_set(unsigned int n, unsigned long prot, unsigned long addr,
    	    unsigned long log2len);

include/sbi/riscv_asm.h +4 -0
+/* Top of range (TOR) matching mode. pmpaddr(n-1) will also be changed */
+int pmp_set_tor(unsigned int n, unsigned long prot, unsigned long addr,
+		unsigned long size);
+

   int pmp_get(unsigned int n, unsigned long *prot_out, unsigned long *addr_out, unsigned long *log2len);

lib/sbi/riscv_asm.c +0 -0
index 3e44320f..8f64f2b5 100644
@@ -330,16 +330,10 @@ int is_pmp_entry_mapped(unsigned long entry)
    	return false;
    }

lib/sbi/riscv_asm.c +1 -2
-int pmp_set(unsigned int n, unsigned long prot, unsigned long addr,
-	    unsigned long log2len)
+static void pmp_set_prot(unsigned int n, unsigned long prot)

   {

lib/sbi/riscv_asm.c +1 -1
-	int pmpcfg_csr, pmpcfg_shift, pmpaddr_csr;
+	int pmpcfg_csr, pmpcfg_shift;

    unsigned long cfgmask, pmpcfg;

lib/sbi/riscv_asm.c +0 -5
-	unsigned long addrmask, pmpaddr;
-
-	/* check parameters */
-	if (n >= PMP_COUNT || log2len > __riscv_xlen || log2len < PMP_SHIFT)
-		return SBI_EINVAL;


    /* calculate PMP register and offset */
   #if __riscv_xlen == 32

lib/sbi/riscv_asm.c +0 -5
@@ -351,15 +345,29 @@ int pmp_set(unsigned int n, unsigned long prot, unsigned long addr,
    #else
    # error "Unexpected __riscv_xlen"
    #endif
-	pmpaddr_csr = CSR_PMPADDR0 + n;
-
-	/* encode PMP config */
-	prot &= ~PMP_A;
-	prot |= (log2len == PMP_SHIFT) ? PMP_A_NA4 : PMP_A_NAPOT;
    	cfgmask = ~(0xffUL << pmpcfg_shift);
    	pmpcfg	= (csr_read_num(pmpcfg_csr) & cfgmask);
    	pmpcfg |= ((prot << pmpcfg_shift) & ~cfgmask);

lib/sbi/riscv_asm.c +19 -0
+	csr_write_num(pmpcfg_csr, pmpcfg);
+}
+
+static void pmp_set_addr(unsigned int n, unsigned long pmpaddr)
+{
+	int pmpaddr_csr = CSR_PMPADDR0 + n;
+
+	csr_write_num(pmpaddr_csr, pmpaddr);
+}
+
+int pmp_set(unsigned int n, unsigned long prot, unsigned long addr,
+	    unsigned long log2len)
+{
+	unsigned long addrmask, pmpaddr;
+
+	/* check parameters */
+	if (n >= PMP_COUNT || log2len > __riscv_xlen || log2len < PMP_SHIFT)
+		return SBI_EINVAL;
+

    /* encode PMP address */
    if (log2len == PMP_SHIFT) {
    pmpaddr = (addr >> PMP_SHIFT);

lib/sbi/riscv_asm.c +0 -0
@@ -373,10 +381,41 @@ int pmp_set(unsigned int n, unsigned long prot, unsigned long addr,
    		}
    	}

lib/sbi/riscv_asm.c +4 -0
+	/* encode PMP config */
+	prot &= ~PMP_A;
+	prot |= (log2len == PMP_SHIFT) ? PMP_A_NA4 : PMP_A_NAPOT;
+

    /* write csrs */

lib/sbi/riscv_asm.c +20 -2
-	csr_write_num(pmpaddr_csr, pmpaddr);
-	csr_write_num(pmpcfg_csr, pmpcfg);
+	pmp_set_addr(n, pmpaddr);
+	pmp_set_prot(n, prot);
+	return 0;
+}
+
+int pmp_set_tor(unsigned int n, unsigned long prot, unsigned long addr,
+		unsigned long size)
+{
+	unsigned long pmpaddr, pmpaddrp;
+
+	/* check parameters */
+	if (n >= PMP_COUNT)
+		return SBI_EINVAL;
+
+	if (n == 0 && addr != 0)
+		return SBI_EINVAL;
+
+	/* encode PMP address */
+	pmpaddrp = addr >> PMP_SHIFT;
+	pmpaddr = (addr + size) >> PMP_SHIFT;

lib/sbi/riscv_asm.c +9 -0
+	/* encode PMP config */
+	prot &= ~PMP_A;
+	prot |= PMP_A_TOR;
+
+	/* write csrs */
+	if (n)
+		pmp_set_addr(n - 1, pmpaddrp);
+	pmp_set_addr(n, pmpaddr);
+	pmp_set_prot(n, prot);

    return 0;
   }

lib/sbi/riscv_asm.c +4 -2
@@ -420,10 +459,12 @@ int pmp_get(unsigned int n, unsigned long *prot_out, unsigned long *addr_out,
    			addr	= (addr & ~((1UL << t1) - 1)) << PMP_SHIFT;
    			len	= (t1 + PMP_SHIFT + 1);
    		}
-	} else {
+	} else if ((prot & PMP_A) == PMP_A_NA4) {
    		addr	= csr_read_num(pmpaddr_csr) << PMP_SHIFT;
    		len	= PMP_SHIFT;
-	}
+	} else
+		/* Error out for TOR region */
+		return SBI_EINVAL;


    /* return details */
    *prot_out    = prot;

Signature · 1 line
2.34.1
Signature · 3 lines
opensbi mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/opensbi
author
#10 lore raw

PATCH 3/3 platform: generic: eswin: add EIC7700

In reply to Bo Gan

Initial platform support for ESWIN Computing EIC7700 based on public SoC datasheet[1] and tested on HiFive Premier P550. Vendor U-boot/Linux boots fine, and I've tested Geekbench 6.5.0 Preview and got scores on par with the vendor OpenSBI. System shutdown is not implemented due to the lack of public doc regarding the UART communication protocol between the SoC and the onboard BMC, which controls ATX power on HiFive P550. [2]

The files and functions are intentionally named as eic770x in many places for future enhancements to support the 2-cluster/die version of the same SoC, namely EIC7702, seen on DC-ROMA AI PC FML13V03. (Out of scope)

There're 4 build time tunable parameters added to Kconfig, and the values are set in custom CSRs during boot:
- ESWIN_EIC770X_FEAT0_CFG
- ESWIN_EIC770X_FEAT1_CFG
- ESWIN_EIC770X_L1_HWPF_CFG
- ESWIN_EIC770X_L2_HWPF_CFG

The default values are dumped when running SiFive's vendor OpenSBI, and with my own tuning to address the perf regression reported by drmpeg [3]

To build the firmware+u-boot blob, Use the following, and docs [4] for testing it with UART boot without flashing:

make FW_TEXT_START=0x80000000 \
     FW_PAYLOAD_OFFSET=0x200000 \
     FW_PAYLOAD_PATH=u-boot-nodtb.bin \
     FW_PAYLOAD_FDT_ADDR=0xf8000000 \
     FW_FDT_PATH=u-boot.dtb

[1] https://github.com/eswincomputing/EIC7700X-SoC-Technical-Reference-Manual
[2] https://www.sifive.com/boards/hifive-premier-p550#documentation
[3] https://forums.sifive.com/t/low-1-core-stream-bandwidth/7274/15
[4] https://github.com/ganboing/EIC770x-Docs/blob/main/p550/bootchain/UART-Boot.md

---
 platform/generic/Kconfig                 |   5 +
 platform/generic/configs/defconfig       |   1 +
 platform/generic/eswin/Kconfig           |  29 ++++
 platform/generic/eswin/eic770x.c         | 165 +++++++++++++++++++++++
 platform/generic/eswin/objects.mk        |  11 ++
 platform/generic/include/eswin/eic770x.h |  49 +++++++
 6 files changed, 260 insertions(+)
 create mode 100644 platform/generic/eswin/Kconfig
 create mode 100644 platform/generic/eswin/eic770x.c
 create mode 100644 platform/generic/eswin/objects.mk
 create mode 100644 platform/generic/include/eswin/eic770x.h
platform/generic/Kconfig +5 -0
index aedc59a5..047e13ca 100644
@@ -88,7 +88,12 @@ config PLATFORM_SPACEMIT_K1
 	select FDT_HSM_SPACEMIT
 	default n
 
+config PLATFORM_ESWIN_EIC770X
+	bool "ESWIN EIC770X support"
+	default n
+
 source "$(OPENSBI_SRC_DIR)/platform/generic/andes/Kconfig"
+source "$(OPENSBI_SRC_DIR)/platform/generic/eswin/Kconfig"
 source "$(OPENSBI_SRC_DIR)/platform/generic/thead/Kconfig"
 
 endif
platform/generic/configs/defconfig +1 -0
index 9e040ac3..60c5449e 100644
@@ -10,6 +10,7 @@ CONFIG_PLATFORM_STARFIVE_JH7110=y
 CONFIG_PLATFORM_THEAD=y
 CONFIG_PLATFORM_MIPS_P8700=y
 CONFIG_PLATFORM_SPACEMIT_K1=y
+CONFIG_PLATFORM_ESWIN_EIC770X=y
 CONFIG_FDT_CACHE=y
 CONFIG_FDT_CACHE_SIFIVE_CCACHE=y
 CONFIG_FDT_CPPC=y
platform/generic/eswin/Kconfig new file +29 -0
new file mode 100644
index 00000000..84d0f43a
@@ -0,0 +1,29 @@
+# SPDX-License-Identifier: BSD-2-Clause
+
+config ESWIN_EIC770X_FEAT0_CFG
+	int "ESWIN EIC7700X Feature Disable 0 CSR Configuration"
+	default 0x4000
+	help
+	 CSR Value to initialize EIC770X_FEAT0 (0x7c1) with.
+	 Refer to EIC770X SoC TRM for recommendations.
+
+config ESWIN_EIC770X_FEAT1_CFG
+	int "ESWIN EIC7700X Feature Disable 1 CSR Configuration"
+	default 0x80
+	help
+	 CSR Value to initialize EIC770X_FEAT1 (0x7c2) with.
+	 Refer to EIC770X SoC TRM for recommendations.
+
+config ESWIN_EIC770X_L1_HWPF_CFG
+	int "ESWIN EIC7700X L1 HW Prefetcher CSR Configuration"
+	default 0x1005c1be649
+	help
+	 CSR Value to initialize EIC770X_L1_HWPF (0x7c3) with.
+	 Refer to EIC770X SoC TRM for recommendations.
+
+config ESWIN_EIC770X_L2_HWPF_CFG
+	int "ESWIN EIC7700X L2 HW Prefetcher CSR Configuration"
+	default 0x929f
+	help
+	 CSR Value to initialize EIC770X_L2_HWPF (0x7c4) with.
+	 Refer to EIC770X SoC TRM for recommendations.
platform/generic/eswin/eic770x.c new file +165 -0

165 lines not on this page · raw message

platform/generic/eswin/objects.mk new file +11 -0
new file mode 100644
index 00000000..6942a107
@@ -0,0 +1,11 @@
+#
+# SPDX-License-Identifier: BSD-2-Clause
+#
+# Copyright (C) 2025 Bo Gan <[email protected]>
+#
+
+carray-platform_override_modules-$(CONFIG_PLATFORM_ESWIN_EIC770X) += eswin_eic7700
+platform-objs-$(CONFIG_PLATFORM_ESWIN_EIC770X) += eswin/eic770x.o
+
+FW_PAYLOAD=y
+FW_PAYLOAD_OFFSET=0x200000
platform/generic/include/eswin/eic770x.h new file +49 -0

49 lines not on this page · raw message

Signature · 7 lines
2.34.1


-- 
opensbi mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/opensbi