board/arch_fpu*: move arch_[get|cmp]fpu to common arch

rename the arch api:
arch_getfpu  -> up_saveusercontext
arch_cmpfpu  -> up_cmpfpu

Signed-off-by: chao.an <anchao@xiaomi.com>
This commit is contained in:
chao.an 2022-04-15 22:35:54 +08:00 committed by Xiang Xiao
parent dc2e4b7024
commit 29005bd79f
38 changed files with 171 additions and 0 deletions

View File

@ -133,6 +133,8 @@
#define XCPTCONTEXT_REGS (HW_XCPT_REGS + SW_XCPT_REGS)
#define XCPTCONTEXT_SIZE (4 * XCPTCONTEXT_REGS)
#define FPU_CONTEXT_REGS SW_FPU_REGS
/****************************************************************************
* Public Types
****************************************************************************/

View File

@ -151,6 +151,8 @@
#define XCPTCONTEXT_REGS (HW_XCPT_REGS + SW_XCPT_REGS)
#define XCPTCONTEXT_SIZE (HW_XCPT_SIZE + SW_XCPT_SIZE)
#define FPU_CONTEXT_REGS SW_FPU_REGS
/****************************************************************************
* Public Types
****************************************************************************/

View File

@ -139,6 +139,8 @@
#define XCPTCONTEXT_REGS (HW_XCPT_REGS + SW_XCPT_REGS)
#define XCPTCONTEXT_SIZE (4 * XCPTCONTEXT_REGS)
#define FPU_CONTEXT_REGS SW_FPU_REGS
/****************************************************************************
* Public Types
****************************************************************************/

View File

@ -157,6 +157,8 @@
#define XCPTCONTEXT_REGS (HW_XCPT_REGS + SW_XCPT_REGS)
#define XCPTCONTEXT_SIZE (HW_XCPT_SIZE + SW_XCPT_SIZE)
#define FPU_CONTEXT_REGS SW_FPU_REGS
/****************************************************************************
* Public Types
****************************************************************************/

View File

@ -105,6 +105,7 @@ CMN_CSRCS += arm_cache.c
ifeq ($(CONFIG_ARCH_FPU),y)
CMN_ASRCS += arm_savefpu.S arm_restorefpu.S
CMN_CSRCS += arm_fpucmp.c
endif
ifeq ($(CONFIG_STACK_COLORATION),y)

View File

@ -101,6 +101,7 @@ CMN_CSRCS += arm_cache.c
ifeq ($(CONFIG_ARCH_FPU),y)
CMN_ASRCS += arm_savefpu.S arm_restorefpu.S
CMN_CSRCS += arm_fpucmp.c
endif
ifeq ($(CONFIG_STACK_COLORATION),y)

View File

@ -0,0 +1,59 @@
/****************************************************************************
* arch/arm/src/common/arm_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 "arm_internal.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[REG_S0],
&regs2[REG_S0], (4 * FPU_CONTEXT_REGS)) == 0;
}
#endif /* CONFIG_ARCH_FPU */

View File

@ -63,6 +63,7 @@ endif
ifeq ($(CONFIG_ARCH_FPU),y)
CMN_ASRCS += arm_fpu.S
CMN_CSRCS += arm_fpuconfig.c
CMN_CSRCS += arm_fpucmp.c
endif
ifeq ($(CONFIG_ARMV7M_ITMSYSLOG),y)

View File

@ -59,6 +59,7 @@ endif
ifeq ($(CONFIG_ARCH_FPU),y)
CMN_ASRCS += arm_fpu.S
CMN_CSRCS += arm_fpuconfig.c
CMN_CSRCS += arm_fpucmp.c
endif
ifeq ($(CONFIG_ARMV7M_ITMSYSLOG),y)

View File

@ -58,6 +58,7 @@ endif
ifeq ($(CONFIG_ARCH_FPU),y)
CMN_CSRCS += arm_fpuconfig.c
CMN_CSRCS += arm_fpucmp.c
endif
CHIP_CSRCS = eoss3_start.c eoss3_gpio.c eoss3_lowputc.c eoss3_clockconfig.c

View File

@ -125,6 +125,7 @@ endif
ifeq ($(CONFIG_ARCH_FPU),y)
CMN_ASRCS += arm_savefpu.S arm_restorefpu.S
CMN_CSRCS += arm_fpucmp.c
endif
ifeq ($(CONFIG_STACK_COLORATION),y)

View File

@ -73,6 +73,7 @@ CMN_CSRCS += arm_cache.c
ifeq ($(CONFIG_ARCH_FPU),y)
CMN_ASRCS += arm_fpu.S
CMN_CSRCS += arm_fpuconfig.c
CMN_CSRCS += arm_fpucmp.c
endif
# Required i.MX RT files

View File

@ -77,6 +77,7 @@ endif
ifeq ($(CONFIG_ARCH_FPU),y)
CMN_ASRCS += arm_fpu.S
CMN_CSRCS += arm_fpuconfig.c
CMN_CSRCS += arm_fpucmp.c
endif
ifeq ($(CONFIG_ARMV7M_ITMSYSLOG),y)

View File

@ -75,6 +75,7 @@ endif
ifeq ($(CONFIG_ARCH_FPU),y)
CMN_ASRCS += arm_fpu.S
CMN_CSRCS += arm_fpuconfig.c
CMN_CSRCS += arm_fpucmp.c
endif
# Required LPC17xx files

View File

@ -63,6 +63,7 @@ endif
ifeq ($(CONFIG_ARCH_FPU),y)
CMN_ASRCS += arm_fpu.S
CMN_CSRCS += arm_fpuconfig.c
CMN_CSRCS += arm_fpucmp.c
endif
CHIP_CSRCS = lpc43_allocateheap.c lpc43_cgu.c lpc43_clrpend.c lpc43_gpio.c

View File

@ -63,6 +63,7 @@ endif
ifeq ($(CONFIG_ARCH_FPU),y)
CMN_ASRCS += arm_fpu.S
CMN_CSRCS += arm_fpuconfig.c
CMN_CSRCS += arm_fpucmp.c
endif
CHIP_CSRCS = lpc54_start.c lpc54_clockconfig.c lpc54_irq.c lpc54_clrpend.c

View File

@ -61,6 +61,7 @@ endif
ifeq ($(CONFIG_ARCH_FPU),y)
CMN_ASRCS += arm_fpu.S
CMN_CSRCS += arm_fpuconfig.c
CMN_CSRCS += arm_fpucmp.c
endif
# Common MAX326XX Source Files

View File

@ -71,6 +71,7 @@ endif
ifeq ($(CONFIG_ARCH_FPU),y)
CMN_ASRCS += arm_fpu.S
CMN_CSRCS += arm_fpuconfig.c
CMN_CSRCS += arm_fpucmp.c
endif
CHIP_CSRCS = nrf52_start.c nrf52_clockconfig.c nrf52_irq.c nrf52_utils.c

View File

@ -40,6 +40,7 @@ endif
ifeq ($(CONFIG_ARCH_FPU),y)
CMN_CSRCS += arm_fpuconfig.c
CMN_CSRCS += arm_fpucmp.c
endif
# Source files common to all S32K1xx chip families.

View File

@ -67,6 +67,7 @@ endif
ifeq ($(CONFIG_ARCH_FPU),y)
CMN_ASRCS += arm_fpu.S
CMN_CSRCS += arm_fpuconfig.c
CMN_CSRCS += arm_fpucmp.c
endif
ifeq ($(CONFIG_SCHED_BACKTRACE),y)

View File

@ -107,6 +107,7 @@ CMN_CSRCS += arm_cache.c
ifeq ($(CONFIG_ARCH_FPU),y)
CMN_ASRCS += arm_savefpu.S arm_restorefpu.S
CMN_CSRCS += arm_fpucmp.c
endif
ifeq ($(CONFIG_STACK_COLORATION),y)

View File

@ -57,6 +57,7 @@ endif
ifeq ($(CONFIG_ARCH_FPU),y)
CMN_ASRCS += arm_fpu.S
CMN_CSRCS += arm_fpuconfig.c
CMN_CSRCS += arm_fpucmp.c
endif
ifeq ($(CONFIG_SCHED_BACKTRACE),y)

View File

@ -62,6 +62,7 @@ CMN_CSRCS += arm_cache.c
ifeq ($(CONFIG_ARCH_FPU),y)
CMN_ASRCS += arm_fpu.S
CMN_CSRCS += arm_fpuconfig.c
CMN_CSRCS += arm_fpucmp.c
endif
ifeq ($(CONFIG_ARCH_RAMVECTORS),y)

View File

@ -71,6 +71,7 @@ endif
ifeq ($(CONFIG_ARCH_FPU),y)
CMN_ASRCS += arm_fpu.S
CMN_CSRCS += arm_fpuconfig.c
CMN_CSRCS += arm_fpucmp.c
endif
ifeq ($(CONFIG_ARMV7M_ITMSYSLOG),y)

View File

@ -62,6 +62,7 @@ CMN_CSRCS += arm_cache.c
ifeq ($(CONFIG_ARCH_FPU),y)
CMN_ASRCS += arm_fpu.S
CMN_CSRCS += arm_fpuconfig.c
CMN_CSRCS += arm_fpucmp.c
endif
ifeq ($(CONFIG_ARCH_RAMVECTORS),y)

View File

@ -62,6 +62,7 @@ CMN_CSRCS += arm_cache.c
ifeq ($(CONFIG_ARCH_FPU),y)
CMN_ASRCS += arm_fpu.S
CMN_CSRCS += arm_fpuconfig.c
CMN_CSRCS += arm_fpucmp.c
endif
ifneq ($(CONFIG_ARCH_IDLE_CUSTOM),y)

View File

@ -56,6 +56,7 @@ CMN_CSRCS += arm_vectors.c
ifeq ($(CONFIG_ARCH_FPU),y)
CMN_ASRCS += arm_fpu.S
CMN_CSRCS += arm_fpuconfig.c
CMN_CSRCS += arm_fpucmp.c
endif
ifeq ($(CONFIG_ARCH_RAMVECTORS),y)

View File

@ -61,6 +61,7 @@ CMN_CSRCS += arm_vectors.c
ifeq ($(CONFIG_ARCH_FPU),y)
CMN_ASRCS += arm_fpu.S
CMN_CSRCS += arm_fpuconfig.c
CMN_CSRCS += arm_fpucmp.c
endif
ifeq ($(CONFIG_ARCH_RAMVECTORS),y)

View File

@ -61,6 +61,7 @@ CMN_CSRCS += arm_vectors.c
ifeq ($(CONFIG_ARCH_FPU),y)
CMN_ASRCS += arm_fpu.S
CMN_CSRCS += arm_fpuconfig.c
CMN_CSRCS += arm_fpucmp.c
endif
ifeq ($(CONFIG_ARCH_RAMVECTORS),y)

View File

@ -50,6 +50,7 @@ CMN_CSRCS += arm_vectors.c
ifeq ($(CONFIG_ARCH_FPU),y)
CMN_ASRCS += arm_fpu.S
CMN_CSRCS += arm_fpuconfig.c
CMN_CSRCS += arm_fpucmp.c
endif
ifeq ($(CONFIG_ARCH_RAMVECTORS),y)

View File

@ -73,6 +73,7 @@ CMN_CSRCS += arm_cache.c
ifeq ($(CONFIG_ARCH_FPU),y)
CMN_ASRCS += arm_savefpu.S arm_restorefpu.S
CMN_CSRCS += arm_fpucmp.c
endif
ifeq ($(CONFIG_SCHED_BACKTRACE),y)

View File

@ -76,6 +76,7 @@ endif
ifeq ($(CONFIG_ARCH_FPU),y)
CMN_ASRCS += arm_fpu.S
CMN_CSRCS += arm_fpuconfig.c
CMN_CSRCS += arm_fpucmp.c
endif
ifeq ($(CONFIG_ARMV7M_ITMSYSLOG),y)

View File

@ -47,6 +47,7 @@ endif
ifeq ($(CONFIG_ARCH_FPU),y)
CMN_ASRCS += riscv_fpu.S
CMN_CSRCS += riscv_fpucmp.c
endif
ifeq ($(CONFIG_ARCH_HAVE_VFORK),y)

View File

@ -47,6 +47,7 @@ endif
ifeq ($(CONFIG_ARCH_FPU),y)
CMN_ASRCS += riscv_fpu.S
CMN_CSRCS += riscv_fpucmp.c
endif
ifeq ($(CONFIG_ARCH_HAVE_VFORK),y)

View File

@ -0,0 +1,59 @@
/****************************************************************************
* arch/risc-v/src/common/riscv_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 "riscv_internal.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 uintptr_t *regs1 = saveregs1;
const uintptr_t *regs2 = saveregs2;
return memcmp(&regs1[INT_XCPT_REGS], &regs2[INT_XCPT_REGS],
INT_REG_SIZE * FPU_XCPT_REGS) == 0;
}
#endif /* CONFIG_ARCH_FPU */

View File

@ -48,6 +48,7 @@ endif
ifeq ($(CONFIG_ARCH_FPU),y)
CMN_ASRCS += riscv_fpu.S
CMN_CSRCS += riscv_fpucmp.c
endif
ifeq ($(CONFIG_ARCH_HAVE_VFORK),y)

View File

@ -60,6 +60,7 @@ endif
ifeq ($(CONFIG_ARCH_FPU),y)
CMN_ASRCS += riscv_fpu.S
CMN_CSRCS += riscv_fpucmp.c
endif
ifeq ($(CONFIG_ARCH_RV_ISA_A),y)

View File

@ -2573,6 +2573,20 @@ void up_perf_convert(uint32_t elapsed, FAR struct timespec *ts);
int up_saveusercontext(FAR void *saveregs);
/****************************************************************************
* Name: up_fpucmp
*
* Description:
* compare FPU areas from thread context
*
****************************************************************************/
#ifdef CONFIG_ARCH_FPU
bool up_fpucmp(FAR const void *saveregs1, FAR const void *saveregs2);
#else
#define up_fpucmp(r1, r2) (true)
#endif
#undef EXTERN
#if defined(__cplusplus)
}