You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@nuttx.apache.org by xi...@apache.org on 2022/08/26 03:57:12 UTC

[incubator-nuttx] branch master updated (ea5ba0113e -> 2fb8af0c20)

This is an automated email from the ASF dual-hosted git repository.

xiaoxiang pushed a change to branch master
in repository https://gitbox.apache.org/repos/asf/incubator-nuttx.git


    from ea5ba0113e spresense/configs: Add fmsynth defconfig
     new e31e69aa30 xtensa: Fix comparison result for up_fpucmp function
     new 5ed2ee85c9 arch: Improve documentation for up_fpucmp function
     new fe2d37aa33 xtensa: Fix allocation of FPU registers in exception context
     new 2fb8af0c20 xtensa: Refactor up_fpucmp to only consider enabled coprocessors

The 4 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails.  The revisions
listed as "add" were already present in the repository and have only
been added to this reference.


Summary of changes:
 arch/arm/src/armv7-a/arm_fpucmp.c       |  9 ++++++-
 arch/arm/src/armv7-m/arm_fpucmp.c       |  9 ++++++-
 arch/arm/src/armv7-r/arm_fpucmp.c       |  9 ++++++-
 arch/arm/src/armv8-m/arm_fpucmp.c       |  9 ++++++-
 arch/arm64/src/common/arm64_fpu.c       |  9 ++++++-
 arch/risc-v/src/common/riscv_fpucmp.c   |  9 ++++++-
 arch/xtensa/include/irq.h               | 12 ++++++---
 arch/xtensa/src/common/xtensa_coproc.S  |  4 +--
 arch/xtensa/src/common/xtensa_fpucmp.c  | 47 +++++++++++++++++++++++++++++----
 arch/xtensa/src/common/xtensa_tcbinfo.c |  2 +-
 include/nuttx/arch.h                    |  9 ++++++-
 11 files changed, 109 insertions(+), 19 deletions(-)


[incubator-nuttx] 02/04: arch: Improve documentation for up_fpucmp function

Posted by xi...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

xiaoxiang pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/incubator-nuttx.git

commit 5ed2ee85c9fa1a7654b6d590a1e1cb09732ca3b2
Author: Gustavo Henrique Nihei <gu...@espressif.com>
AuthorDate: Thu Aug 25 15:36:04 2022 -0300

    arch: Improve documentation for up_fpucmp function
    
    Signed-off-by: Gustavo Henrique Nihei <gu...@espressif.com>
---
 arch/arm/src/armv7-a/arm_fpucmp.c      | 9 ++++++++-
 arch/arm/src/armv7-m/arm_fpucmp.c      | 9 ++++++++-
 arch/arm/src/armv7-r/arm_fpucmp.c      | 9 ++++++++-
 arch/arm/src/armv8-m/arm_fpucmp.c      | 9 ++++++++-
 arch/arm64/src/common/arm64_fpu.c      | 9 ++++++++-
 arch/risc-v/src/common/riscv_fpucmp.c  | 9 ++++++++-
 arch/xtensa/src/common/xtensa_fpucmp.c | 9 ++++++++-
 include/nuttx/arch.h                   | 9 ++++++++-
 8 files changed, 64 insertions(+), 8 deletions(-)

diff --git a/arch/arm/src/armv7-a/arm_fpucmp.c b/arch/arm/src/armv7-a/arm_fpucmp.c
index 6bf2dbca3f..00ee4ccafe 100644
--- a/arch/arm/src/armv7-a/arm_fpucmp.c
+++ b/arch/arm/src/armv7-a/arm_fpucmp.c
@@ -44,7 +44,14 @@
  * Name: up_fpucmp
  *
  * Description:
- *   compare FPU areas from thread context
+ *   Compare FPU areas from thread context.
+ *
+ * Input Parameters:
+ *   saveregs1 - Pointer to the saved FPU registers.
+ *   saveregs2 - Pointer to the saved FPU registers.
+ *
+ * Returned Value:
+ *   True if FPU areas compare equal, False otherwise.
  *
  ****************************************************************************/
 
diff --git a/arch/arm/src/armv7-m/arm_fpucmp.c b/arch/arm/src/armv7-m/arm_fpucmp.c
index 5ddc18e89b..dfed405645 100644
--- a/arch/arm/src/armv7-m/arm_fpucmp.c
+++ b/arch/arm/src/armv7-m/arm_fpucmp.c
@@ -44,7 +44,14 @@
  * Name: up_fpucmp
  *
  * Description:
- *   compare FPU areas from thread context
+ *   Compare FPU areas from thread context.
+ *
+ * Input Parameters:
+ *   saveregs1 - Pointer to the saved FPU registers.
+ *   saveregs2 - Pointer to the saved FPU registers.
+ *
+ * Returned Value:
+ *   True if FPU areas compare equal, False otherwise.
  *
  ****************************************************************************/
 
diff --git a/arch/arm/src/armv7-r/arm_fpucmp.c b/arch/arm/src/armv7-r/arm_fpucmp.c
index e37ee256da..bcc6ecb203 100644
--- a/arch/arm/src/armv7-r/arm_fpucmp.c
+++ b/arch/arm/src/armv7-r/arm_fpucmp.c
@@ -44,7 +44,14 @@
  * Name: up_fpucmp
  *
  * Description:
- *   compare FPU areas from thread context
+ *   Compare FPU areas from thread context.
+ *
+ * Input Parameters:
+ *   saveregs1 - Pointer to the saved FPU registers.
+ *   saveregs2 - Pointer to the saved FPU registers.
+ *
+ * Returned Value:
+ *   True if FPU areas compare equal, False otherwise.
  *
  ****************************************************************************/
 
diff --git a/arch/arm/src/armv8-m/arm_fpucmp.c b/arch/arm/src/armv8-m/arm_fpucmp.c
index 08b2da7f94..4c5e3bb2d3 100644
--- a/arch/arm/src/armv8-m/arm_fpucmp.c
+++ b/arch/arm/src/armv8-m/arm_fpucmp.c
@@ -44,7 +44,14 @@
  * Name: up_fpucmp
  *
  * Description:
- *   compare FPU areas from thread context
+ *   Compare FPU areas from thread context.
+ *
+ * Input Parameters:
+ *   saveregs1 - Pointer to the saved FPU registers.
+ *   saveregs2 - Pointer to the saved FPU registers.
+ *
+ * Returned Value:
+ *   True if FPU areas compare equal, False otherwise.
  *
  ****************************************************************************/
 
diff --git a/arch/arm64/src/common/arm64_fpu.c b/arch/arm64/src/common/arm64_fpu.c
index 1516268359..9e6a43f5a1 100644
--- a/arch/arm64/src/common/arm64_fpu.c
+++ b/arch/arm64/src/common/arm64_fpu.c
@@ -229,7 +229,14 @@ void arm64_fpu_disable(void)
  * Name: up_fpucmp
  *
  * Description:
- *   compare FPU areas from thread context
+ *   Compare FPU areas from thread context.
+ *
+ * Input Parameters:
+ *   saveregs1 - Pointer to the saved FPU registers.
+ *   saveregs2 - Pointer to the saved FPU registers.
+ *
+ * Returned Value:
+ *   True if FPU areas compare equal, False otherwise.
  *
  ***************************************************************************/
 
diff --git a/arch/risc-v/src/common/riscv_fpucmp.c b/arch/risc-v/src/common/riscv_fpucmp.c
index d37faefe91..f0c209216b 100644
--- a/arch/risc-v/src/common/riscv_fpucmp.c
+++ b/arch/risc-v/src/common/riscv_fpucmp.c
@@ -44,7 +44,14 @@
  * Name: up_fpucmp
  *
  * Description:
- *   compare FPU areas from thread context
+ *   Compare FPU areas from thread context.
+ *
+ * Input Parameters:
+ *   saveregs1 - Pointer to the saved FPU registers.
+ *   saveregs2 - Pointer to the saved FPU registers.
+ *
+ * Returned Value:
+ *   True if FPU areas compare equal, False otherwise.
  *
  ****************************************************************************/
 
diff --git a/arch/xtensa/src/common/xtensa_fpucmp.c b/arch/xtensa/src/common/xtensa_fpucmp.c
index e466917991..c4aaa09b22 100644
--- a/arch/xtensa/src/common/xtensa_fpucmp.c
+++ b/arch/xtensa/src/common/xtensa_fpucmp.c
@@ -44,7 +44,14 @@
  * Name: up_fpucmp
  *
  * Description:
- *   compare FPU areas from thread context
+ *   Compare FPU areas from thread context.
+ *
+ * Input Parameters:
+ *   saveregs1 - Pointer to the saved FPU registers.
+ *   saveregs2 - Pointer to the saved FPU registers.
+ *
+ * Returned Value:
+ *   True if FPU areas compare equal, False otherwise.
  *
  ****************************************************************************/
 
diff --git a/include/nuttx/arch.h b/include/nuttx/arch.h
index e8272c5385..431d34122c 100644
--- a/include/nuttx/arch.h
+++ b/include/nuttx/arch.h
@@ -2594,7 +2594,14 @@ int up_saveusercontext(FAR void *saveregs);
  * Name: up_fpucmp
  *
  * Description:
- *   compare FPU areas from thread context
+ *   Compare FPU areas from thread context.
+ *
+ * Input Parameters:
+ *   saveregs1 - Pointer to the saved FPU registers.
+ *   saveregs2 - Pointer to the saved FPU registers.
+ *
+ * Returned Value:
+ *   True if FPU areas compare equal, False otherwise.
  *
  ****************************************************************************/
 


[incubator-nuttx] 04/04: xtensa: Refactor up_fpucmp to only consider enabled coprocessors

Posted by xi...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

xiaoxiang pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/incubator-nuttx.git

commit 2fb8af0c209b3ef0979d2b2a8febaf07af275a7b
Author: Gustavo Henrique Nihei <gu...@espressif.com>
AuthorDate: Thu Aug 25 17:54:55 2022 -0300

    xtensa: Refactor up_fpucmp to only consider enabled coprocessors
    
    Signed-off-by: Gustavo Henrique Nihei <gu...@espressif.com>
---
 arch/xtensa/src/common/xtensa_fpucmp.c | 38 ++++++++++++++++++++++++++++++----
 1 file changed, 34 insertions(+), 4 deletions(-)

diff --git a/arch/xtensa/src/common/xtensa_fpucmp.c b/arch/xtensa/src/common/xtensa_fpucmp.c
index bc32a9f79c..94146b44e5 100644
--- a/arch/xtensa/src/common/xtensa_fpucmp.c
+++ b/arch/xtensa/src/common/xtensa_fpucmp.c
@@ -26,15 +26,29 @@
 
 #include <stdint.h>
 #include <string.h>
+#include <strings.h>
+
 #include <nuttx/irq.h>
 
 #include "xtensa.h"
 
+#ifdef CONFIG_ARCH_FPU
+
 /****************************************************************************
- * Pre-processor Definitions
+ * Private Data
  ****************************************************************************/
 
-#ifdef CONFIG_ARCH_FPU
+static uint32_t g_coproc_sa_offsets[] =
+{
+  XTENSA_CP0_SA, XTENSA_CP1_SA, XTENSA_CP2_SA, XTENSA_CP3_SA,
+  XTENSA_CP4_SA, XTENSA_CP5_SA, XTENSA_CP6_SA, XTENSA_CP7_SA
+};
+
+static uint32_t g_coproc_sa_sizes[] =
+{
+  XCHAL_CP0_SA_SIZE, XCHAL_CP1_SA_SIZE, XCHAL_CP2_SA_SIZE, XCHAL_CP3_SA_SIZE,
+  XCHAL_CP4_SA_SIZE, XCHAL_CP5_SA_SIZE, XCHAL_CP6_SA_SIZE, XCHAL_CP7_SA_SIZE
+};
 
 /****************************************************************************
  * Public Functions
@@ -45,6 +59,7 @@
  *
  * Description:
  *   Compare FPU areas from thread context.
+ *   This comparison will skip disabled coprocessors.
  *
  * Input Parameters:
  *   saveregs1 - Pointer to the saved FPU registers.
@@ -59,8 +74,23 @@ bool up_fpucmp(const void *saveregs1, const void *saveregs2)
 {
   const uint32_t *regs1 = saveregs1;
   const uint32_t *regs2 = saveregs2;
+  uint32_t cpenable = xtensa_get_cpenable();
+  int ndx = 0;
+  bool ret = true;
+  int i;
+
+  while (ret && (i = ffs(cpenable)))
+    {
+      uint32_t reg_offset;
+
+      ndx += i;
+      reg_offset = g_coproc_sa_offsets[ndx - 1] / 4;
+      ret = memcmp(&regs1[COMMON_CTX_REGS + reg_offset],
+                   &regs2[COMMON_CTX_REGS + reg_offset],
+                   g_coproc_sa_sizes[ndx - 1]) == 0;
+      cpenable >>= i;
+    }
 
-  return memcmp(&regs1[COMMON_CTX_REGS], &regs2[COMMON_CTX_REGS],
-                XTENSA_CP_SA_SIZE) == 0;
+  return ret;
 }
 #endif /* CONFIG_ARCH_FPU */


[incubator-nuttx] 03/04: xtensa: Fix allocation of FPU registers in exception context

Posted by xi...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

xiaoxiang pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/incubator-nuttx.git

commit fe2d37aa3395adb24f1d01a23af39a06e089d78a
Author: Gustavo Henrique Nihei <gu...@espressif.com>
AuthorDate: Thu Aug 25 15:36:53 2022 -0300

    xtensa: Fix allocation of FPU registers in exception context
    
    Signed-off-by: Gustavo Henrique Nihei <gu...@espressif.com>
---
 arch/xtensa/include/irq.h               | 12 ++++++++----
 arch/xtensa/src/common/xtensa_coproc.S  |  4 ++--
 arch/xtensa/src/common/xtensa_fpucmp.c  |  2 +-
 arch/xtensa/src/common/xtensa_tcbinfo.c |  2 +-
 4 files changed, 12 insertions(+), 8 deletions(-)

diff --git a/arch/xtensa/include/irq.h b/arch/xtensa/include/irq.h
index d23a07ae25..ad1dc4c686 100644
--- a/arch/xtensa/include/irq.h
+++ b/arch/xtensa/include/irq.h
@@ -144,13 +144,17 @@
 #if XCHAL_CP_NUM > 0
   /* FPU first address must align to CP align size. */
 
-#  define XCPTCONTEXT_REGS  ALIGN_UP(_REG_CP_START, XCHAL_TOTAL_SA_ALIGN / 4)
-#  define XCPTCONTEXT_SIZE  ((4 * XCPTCONTEXT_REGS) + XTENSA_CP_SA_SIZE + 0x20)
+#  define COMMON_CTX_REGS   ALIGN_UP(_REG_CP_START, XCHAL_TOTAL_SA_ALIGN / 4)
+#  define COPROC_CTX_REGS   (XTENSA_CP_SA_SIZE / 4)
+#  define RESERVE_REGS      8
+#  define XCPTCONTEXT_REGS  (COMMON_CTX_REGS + COPROC_CTX_REGS + RESERVE_REGS)
 #else
-#  define XCPTCONTEXT_REGS  _REG_CP_START
-#  define XCPTCONTEXT_SIZE  ((4 * XCPTCONTEXT_REGS) + 0x20)
+#  define RESERVE_REGS      8
+#  define XCPTCONTEXT_REGS  (_REG_CP_START + RESERVE_REGS)
 #endif
 
+#define XCPTCONTEXT_SIZE    (4 * XCPTCONTEXT_REGS)
+
 /****************************************************************************
  * Public Types
  ****************************************************************************/
diff --git a/arch/xtensa/src/common/xtensa_coproc.S b/arch/xtensa/src/common/xtensa_coproc.S
index ed5c92dabc..f355267c4c 100644
--- a/arch/xtensa/src/common/xtensa_coproc.S
+++ b/arch/xtensa/src/common/xtensa_coproc.S
@@ -105,7 +105,7 @@ _xtensa_coproc_saoffsets:
 	* ---------------------------------------------------| <- SP
 	*/
 
-	addi		a3, sp, (4 * XCPTCONTEXT_REGS)
+	addi		a3, sp, (4 * COMMON_CTX_REGS)
 
 	/* CPENABLE should show which CPs are enabled. */
 
@@ -216,7 +216,7 @@ Ldone1:
 	* ---------------------------------------------------| <- SP
 	*/
 
-	addi		a3, a2, (4 * XCPTCONTEXT_REGS)
+	addi		a3, a2, (4 * COMMON_CTX_REGS)
 
 	rsr		a8, CPENABLE			/* a8 = which CPs are enabled */
 	beqz		a8, Ldone2			/* Quick exit if none */
diff --git a/arch/xtensa/src/common/xtensa_fpucmp.c b/arch/xtensa/src/common/xtensa_fpucmp.c
index c4aaa09b22..bc32a9f79c 100644
--- a/arch/xtensa/src/common/xtensa_fpucmp.c
+++ b/arch/xtensa/src/common/xtensa_fpucmp.c
@@ -60,7 +60,7 @@ bool up_fpucmp(const void *saveregs1, const void *saveregs2)
   const uint32_t *regs1 = saveregs1;
   const uint32_t *regs2 = saveregs2;
 
-  return memcmp(&regs1[XCPTCONTEXT_REGS], &regs2[XCPTCONTEXT_REGS],
+  return memcmp(&regs1[COMMON_CTX_REGS], &regs2[COMMON_CTX_REGS],
                 XTENSA_CP_SA_SIZE) == 0;
 }
 #endif /* CONFIG_ARCH_FPU */
diff --git a/arch/xtensa/src/common/xtensa_tcbinfo.c b/arch/xtensa/src/common/xtensa_tcbinfo.c
index 836930d5a3..882da9abaa 100644
--- a/arch/xtensa/src/common/xtensa_tcbinfo.c
+++ b/arch/xtensa/src/common/xtensa_tcbinfo.c
@@ -64,7 +64,7 @@ const struct tcbinfo_s g_tcbinfo =
   .pri_off   = TCB_PRI_OFF,
   .name_off  = TCB_NAME_OFF,
   .regs_off  = TCB_REGS_OFF,
-  .basic_num = XCPTCONTEXT_REGS,
+  .basic_num = COMMON_CTX_REGS,
   .total_num = XCPTCONTEXT_REGS,
   {
     .p = g_reg_offs,


[incubator-nuttx] 01/04: xtensa: Fix comparison result for up_fpucmp function

Posted by xi...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

xiaoxiang pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/incubator-nuttx.git

commit e31e69aa30b5c114bbdc2450e6ccfa681db65b38
Author: Gustavo Henrique Nihei <gu...@espressif.com>
AuthorDate: Thu Aug 25 15:33:42 2022 -0300

    xtensa: Fix comparison result for up_fpucmp function
    
    Signed-off-by: Gustavo Henrique Nihei <gu...@espressif.com>
---
 arch/xtensa/src/common/xtensa_fpucmp.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/arch/xtensa/src/common/xtensa_fpucmp.c b/arch/xtensa/src/common/xtensa_fpucmp.c
index cafd93c3c0..e466917991 100644
--- a/arch/xtensa/src/common/xtensa_fpucmp.c
+++ b/arch/xtensa/src/common/xtensa_fpucmp.c
@@ -54,6 +54,6 @@ bool up_fpucmp(const void *saveregs1, const void *saveregs2)
   const uint32_t *regs2 = saveregs2;
 
   return memcmp(&regs1[XCPTCONTEXT_REGS], &regs2[XCPTCONTEXT_REGS],
-                XTENSA_CP_SA_SIZE);
+                XTENSA_CP_SA_SIZE) == 0;
 }
 #endif /* CONFIG_ARCH_FPU */