From 883337c3a05a3ecd703e4702be20fc36111f8320 Mon Sep 17 00:00:00 2001 From: zhuyanlin Date: Thu, 5 May 2022 16:49:59 +0800 Subject: [PATCH] xtensa:fpu: add up_fpucmp and enable CONFIG_ARCH_FPU macro For arch with CP_NUM > 0, enable ARCH_FPU Signed-off-by: zhuyanlin --- 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(+) create mode 100644 arch/xtensa/src/common/xtensa_fpucmp.c diff --git a/arch/xtensa/Kconfig b/arch/xtensa/Kconfig index e30b9c28320..692117aa576 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 00000000000..cafd93c3c0d --- /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 + +#include +#include +#include + +#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(®s1[XCPTCONTEXT_REGS], ®s2[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 1161e8bfe48..445c05acec8 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 8987a2b6b97..cbaeb1ed369 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