You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@nuttx.apache.org by pk...@apache.org on 2022/05/16 09:30:46 UTC

[incubator-nuttx] branch master updated: xtensa:fpu: add up_fpucmp and enable CONFIG_ARCH_FPU macro

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

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


The following commit(s) were added to refs/heads/master by this push:
     new 883337c3a0 xtensa:fpu: add up_fpucmp and enable CONFIG_ARCH_FPU macro
883337c3a0 is described below

commit 883337c3a05a3ecd703e4702be20fc36111f8320
Author: zhuyanlin <zh...@xiaomi.com>
AuthorDate: Thu May 5 16:49:59 2022 +0800

    xtensa:fpu: add up_fpucmp and enable CONFIG_ARCH_FPU macro
    
    For arch with CP_NUM > 0, enable ARCH_FPU
    
    Signed-off-by: zhuyanlin <zh...@xiaomi.com>
---
 arch/xtensa/Kconfig                    |  2 ++
 arch/xtensa/src/common/xtensa_fpucmp.c | 59 ++++++++++++++++++++++++++++++++++
 arch/xtensa/src/esp32/Make.defs        |  4 +++
 arch/xtensa/src/esp32s3/Make.defs      |  4 +++
 4 files changed, 69 insertions(+)

diff --git a/arch/xtensa/Kconfig b/arch/xtensa/Kconfig
index e30b9c2832..692117aa57 100644
--- a/arch/xtensa/Kconfig
+++ b/arch/xtensa/Kconfig
@@ -13,6 +13,7 @@ config ARCH_CHIP_ESP32
 	bool "Espressif ESP32"
 	select ARCH_FAMILY_LX6
 	select XTENSA_HAVE_INTERRUPTS
+	select ARCH_HAVE_FPU
 	select ARCH_HAVE_MULTICPU
 	select ARCH_HAVE_TEXT_HEAP
 	select ARCH_HAVE_SDRAM
@@ -77,6 +78,7 @@ config ARCH_CHIP_ESP32S3
 	bool "Espressif ESP32-S3"
 	select ARCH_FAMILY_LX7
 	select XTENSA_HAVE_INTERRUPTS
+	select ARCH_HAVE_FPU
 	select ARCH_HAVE_MULTICPU
 	select ARCH_HAVE_TEXT_HEAP
 	select ARCH_HAVE_SDRAM
diff --git a/arch/xtensa/src/common/xtensa_fpucmp.c b/arch/xtensa/src/common/xtensa_fpucmp.c
new file mode 100644
index 0000000000..cafd93c3c0
--- /dev/null
+++ b/arch/xtensa/src/common/xtensa_fpucmp.c
@@ -0,0 +1,59 @@
+/****************************************************************************
+ * arch/xtensa/src/common/xtensa_fpucmp.c
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.  The
+ * ASF licenses this file to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance with the
+ * License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+ * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.  See the
+ * License for the specific language governing permissions and limitations
+ * under the License.
+ *
+ ****************************************************************************/
+
+/****************************************************************************
+ * Included Files
+ ****************************************************************************/
+
+#include <nuttx/config.h>
+
+#include <stdint.h>
+#include <string.h>
+#include <nuttx/irq.h>
+
+#include "xtensa.h"
+
+/****************************************************************************
+ * Pre-processor Definitions
+ ****************************************************************************/
+
+#ifdef CONFIG_ARCH_FPU
+
+/****************************************************************************
+ * Public Functions
+ ****************************************************************************/
+
+/****************************************************************************
+ * Name: up_fpucmp
+ *
+ * Description:
+ *   compare FPU areas from thread context
+ *
+ ****************************************************************************/
+
+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],
+                XTENSA_CP_SA_SIZE);
+}
+#endif /* CONFIG_ARCH_FPU */
diff --git a/arch/xtensa/src/esp32/Make.defs b/arch/xtensa/src/esp32/Make.defs
index 1161e8bfe4..445c05acec 100644
--- a/arch/xtensa/src/esp32/Make.defs
+++ b/arch/xtensa/src/esp32/Make.defs
@@ -52,6 +52,10 @@ ifeq ($(CONFIG_DEBUG_ALERT),y)
   CMN_CSRCS += xtensa_dumpstate.c
 endif
 
+ifeq ($(CONFIG_ARCH_FPU),y)
+  CMN_CSRCS += xtensa_fpucmp.c
+endif
+
 ifeq ($(CONFIG_SPINLOCK),y)
   CMN_CSRCS += xtensa_testset.c
 endif
diff --git a/arch/xtensa/src/esp32s3/Make.defs b/arch/xtensa/src/esp32s3/Make.defs
index 8987a2b6b9..cbaeb1ed36 100644
--- a/arch/xtensa/src/esp32s3/Make.defs
+++ b/arch/xtensa/src/esp32s3/Make.defs
@@ -52,6 +52,10 @@ ifeq ($(CONFIG_DEBUG_ALERT),y)
   CMN_CSRCS += xtensa_dumpstate.c
 endif
 
+ifeq ($(CONFIG_ARCH_FPU),y)
+  CMN_CSRCS += xtensa_fpucmp.c
+endif
+
 ifeq ($(CONFIG_SPINLOCK),y)
   CMN_CSRCS += xtensa_testset.c
 endif