74aeb5d0c5
includes following parts: add support of sparc in arch/Kconfig add support of sparc in boards/Kconfig add sparc dir in arch, add sparc dir in boards add support of sparc in libs/libc/machine modify all the coding style problem about saprc
169 lines
4.7 KiB
C
169 lines
4.7 KiB
C
/****************************************************************************
|
|
* arch/sparc/src/common/up_assert.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 <stdlib.h>
|
|
#include <assert.h>
|
|
#include <debug.h>
|
|
|
|
#include <nuttx/irq.h>
|
|
#include <nuttx/arch.h>
|
|
#include <nuttx/board.h>
|
|
#include <nuttx/syslog/syslog.h>
|
|
#include <nuttx/usb/usbdev_trace.h>
|
|
|
|
#include <arch/board/board.h>
|
|
|
|
#include "up_arch.h"
|
|
#include "sched/sched.h"
|
|
#include "up_internal.h"
|
|
|
|
/****************************************************************************
|
|
* Pre-processor Definitions
|
|
****************************************************************************/
|
|
|
|
/* USB trace dumping */
|
|
|
|
#ifndef CONFIG_USBDEV_TRACE
|
|
# undef CONFIG_ARCH_USBDUMP
|
|
#endif
|
|
|
|
#ifndef CONFIG_BOARD_RESET_ON_ASSERT
|
|
# define CONFIG_BOARD_RESET_ON_ASSERT 0
|
|
#endif
|
|
|
|
/****************************************************************************
|
|
* Private Functions
|
|
****************************************************************************/
|
|
|
|
/****************************************************************************
|
|
* Name: _up_assert
|
|
****************************************************************************/
|
|
|
|
static void _up_assert(int errorcode) noreturn_function;
|
|
static void _up_assert(int errorcode)
|
|
{
|
|
/* Flush any buffered SYSLOG data */
|
|
|
|
(void)syslog_flush();
|
|
|
|
/* Are we in an interrupt handler or the idle task? */
|
|
|
|
if (g_current_regs || running_task()->flink == NULL)
|
|
{
|
|
(void)up_irq_save();
|
|
for (; ; )
|
|
{
|
|
#if CONFIG_BOARD_RESET_ON_ASSERT >= 1
|
|
board_reset(CONFIG_BOARD_ASSERT_RESET_VALUE);
|
|
#endif
|
|
#ifdef CONFIG_ARCH_LEDS
|
|
board_autoled_on(LED_PANIC);
|
|
up_mdelay(250);
|
|
board_autoled_off(LED_PANIC);
|
|
up_mdelay(250);
|
|
#endif
|
|
}
|
|
}
|
|
else
|
|
{
|
|
#if CONFIG_BOARD_RESET_ON_ASSERT >= 2
|
|
board_reset(CONFIG_BOARD_ASSERT_RESET_VALUE);
|
|
#endif
|
|
exit(errorcode);
|
|
}
|
|
}
|
|
|
|
/****************************************************************************
|
|
* Name: assert_tracecallback
|
|
****************************************************************************/
|
|
|
|
#ifdef CONFIG_ARCH_USBDUMP
|
|
static int usbtrace_syslog(FAR const char *fmt, ...)
|
|
{
|
|
va_list ap;
|
|
int ret;
|
|
|
|
/* Let nx_vsyslog do the real work */
|
|
|
|
va_start(ap, fmt);
|
|
ret = nx_vsyslog(LOG_EMERG, fmt, &ap);
|
|
va_end(ap);
|
|
return ret;
|
|
}
|
|
|
|
static int assert_tracecallback(FAR struct usbtrace_s *trace, FAR void *arg)
|
|
{
|
|
usbtrace_trprintf(usbtrace_syslog, trace->event, trace->value);
|
|
return 0;
|
|
}
|
|
#endif
|
|
|
|
/****************************************************************************
|
|
* Public Functions
|
|
****************************************************************************/
|
|
|
|
/****************************************************************************
|
|
* Name: up_assert
|
|
****************************************************************************/
|
|
|
|
void up_assert(const char *filename, int lineno)
|
|
{
|
|
#if CONFIG_TASK_NAME_SIZE > 0 && defined(CONFIG_DEBUG_ALERT)
|
|
struct tcb_s *rtcb = running_task();
|
|
#endif
|
|
|
|
/* Flush any buffered SYSLOG data (prior to the assertion) */
|
|
|
|
(void)syslog_flush();
|
|
|
|
#if CONFIG_TASK_NAME_SIZE > 0
|
|
_alert("Assertion failed at file:%s line: %d task: %s\n",
|
|
filename, lineno, rtcb->name);
|
|
#else
|
|
_alert("Assertion failed at file:%s line: %d\n",
|
|
filename, lineno);
|
|
#endif
|
|
|
|
up_dumpstate();
|
|
|
|
/* Flush any buffered SYSLOG data (from the above) */
|
|
|
|
(void)syslog_flush();
|
|
|
|
#ifdef CONFIG_BOARD_CRASHDUMP
|
|
board_crashdump(up_getsp(), running_task(), filename, lineno);
|
|
#endif
|
|
|
|
#ifdef CONFIG_ARCH_USBDUMP
|
|
/* Dump USB trace data */
|
|
|
|
(void)usbtrace_enumerate(assert_tracecallback, NULL);
|
|
#endif
|
|
|
|
_up_assert(EXIT_FAILURE);
|
|
}
|