2019-08-19 17:16:08 +02:00
|
|
|
/****************************************************************************
|
|
|
|
* boards/arm/stm32/stm3240g-eval/src/stm32_ostest.c
|
2012-02-24 22:34:55 +01:00
|
|
|
*
|
2020-04-30 20:48:28 +02:00
|
|
|
* 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
|
2012-02-24 22:34:55 +01:00
|
|
|
*
|
2020-04-30 20:48:28 +02:00
|
|
|
* http://www.apache.org/licenses/LICENSE-2.0
|
2012-02-24 22:34:55 +01:00
|
|
|
*
|
2020-04-30 20:48:28 +02:00
|
|
|
* 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.
|
2012-02-24 22:34:55 +01:00
|
|
|
*
|
2019-08-19 17:16:08 +02:00
|
|
|
****************************************************************************/
|
2012-02-24 22:34:55 +01:00
|
|
|
|
2019-08-19 17:16:08 +02:00
|
|
|
/****************************************************************************
|
2012-02-24 22:34:55 +01:00
|
|
|
* Included Files
|
2019-08-19 17:16:08 +02:00
|
|
|
****************************************************************************/
|
2012-02-24 22:34:55 +01:00
|
|
|
|
|
|
|
#include <nuttx/config.h>
|
|
|
|
|
|
|
|
#include <stdint.h>
|
|
|
|
#include <stdbool.h>
|
|
|
|
#include <string.h>
|
|
|
|
#include <debug.h>
|
|
|
|
|
2016-02-13 19:37:46 +01:00
|
|
|
#include <nuttx/irq.h>
|
2012-02-24 22:34:55 +01:00
|
|
|
#include <arch/board/board.h>
|
|
|
|
|
2020-05-01 03:20:29 +02:00
|
|
|
#include "arm_arch.h"
|
|
|
|
#include "arm_internal.h"
|
2014-11-28 18:06:43 +01:00
|
|
|
#include "stm3240g-eval.h"
|
2012-02-24 22:34:55 +01:00
|
|
|
|
2019-08-19 17:16:08 +02:00
|
|
|
/****************************************************************************
|
2015-04-08 17:15:17 +02:00
|
|
|
* Pre-processor Definitions
|
2019-08-19 17:16:08 +02:00
|
|
|
****************************************************************************/
|
2020-04-30 20:48:28 +02:00
|
|
|
|
|
|
|
/* Configuration ************************************************************/
|
2012-02-24 22:34:55 +01:00
|
|
|
|
|
|
|
#undef HAVE_FPU
|
2018-12-13 00:56:02 +01:00
|
|
|
#if defined(CONFIG_ARCH_FPU) && defined(CONFIG_TESTING_OSTEST_FPUSIZE) && \
|
2019-04-29 22:52:05 +02:00
|
|
|
defined(CONFIG_SCHED_WAITPID)
|
2012-02-24 22:34:55 +01:00
|
|
|
# define HAVE_FPU 1
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#ifdef HAVE_FPU
|
|
|
|
|
2018-12-13 00:56:02 +01:00
|
|
|
#if CONFIG_TESTING_OSTEST_FPUSIZE != (4*SW_FPU_REGS)
|
|
|
|
# error "CONFIG_TESTING_OSTEST_FPUSIZE has the wrong size"
|
2012-02-24 22:34:55 +01:00
|
|
|
#endif
|
|
|
|
|
2019-08-19 17:16:08 +02:00
|
|
|
/****************************************************************************
|
2012-02-26 16:27:36 +01:00
|
|
|
* Private Data
|
2019-08-19 17:16:08 +02:00
|
|
|
****************************************************************************/
|
2012-02-26 16:27:36 +01:00
|
|
|
|
|
|
|
static uint32_t g_saveregs[XCPTCONTEXT_REGS];
|
|
|
|
|
2019-08-19 17:16:08 +02:00
|
|
|
/****************************************************************************
|
2012-02-24 22:34:55 +01:00
|
|
|
* Private Functions
|
2019-08-19 17:16:08 +02:00
|
|
|
****************************************************************************/
|
2012-02-24 22:34:55 +01:00
|
|
|
|
2019-08-19 17:16:08 +02:00
|
|
|
/****************************************************************************
|
2012-02-24 22:34:55 +01:00
|
|
|
* Public Functions
|
2019-08-19 17:16:08 +02:00
|
|
|
****************************************************************************/
|
2020-04-30 20:48:28 +02:00
|
|
|
|
|
|
|
/* Given an array of size CONFIG_TESTING_OSTEST_FPUSIZE, this function will
|
|
|
|
* return the current FPU registers.
|
2012-02-24 22:34:55 +01:00
|
|
|
*/
|
|
|
|
|
2012-02-25 20:32:16 +01:00
|
|
|
void arch_getfpu(FAR uint32_t *fpusave)
|
2012-02-24 22:34:55 +01:00
|
|
|
{
|
|
|
|
irqstate_t flags;
|
2012-02-26 16:27:36 +01:00
|
|
|
|
|
|
|
/* Take a snapshot of the thread context right now */
|
2012-02-24 22:34:55 +01:00
|
|
|
|
2016-02-13 19:37:46 +01:00
|
|
|
flags = enter_critical_section();
|
2020-04-30 20:33:20 +02:00
|
|
|
arm_saveusercontext(g_saveregs);
|
2012-02-24 22:34:55 +01:00
|
|
|
|
2012-02-26 16:27:36 +01:00
|
|
|
/* Return only the floating register values */
|
|
|
|
|
|
|
|
memcpy(fpusave, &g_saveregs[REG_S0], (4*SW_FPU_REGS));
|
2016-02-13 19:37:46 +01:00
|
|
|
leave_critical_section(flags);
|
2012-02-24 22:34:55 +01:00
|
|
|
}
|
|
|
|
|
2018-12-13 00:56:02 +01:00
|
|
|
/* Given two arrays of size CONFIG_TESTING_OSTEST_FPUSIZE this function
|
2012-02-26 16:27:36 +01:00
|
|
|
* will compare them and return true if they are identical.
|
2012-02-24 22:34:55 +01:00
|
|
|
*/
|
|
|
|
|
2012-02-25 20:32:16 +01:00
|
|
|
bool arch_cmpfpu(FAR const uint32_t *fpusave1, FAR const uint32_t *fpusave2)
|
2012-02-24 22:34:55 +01:00
|
|
|
{
|
2012-02-25 20:32:16 +01:00
|
|
|
return memcmp(fpusave1, fpusave2, (4*SW_FPU_REGS)) == 0;
|
2012-02-24 22:34:55 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
#endif /* HAVE_FPU */
|