move common assert logic together.
Signed-off-by: 田昕 <tianxin7@xiaomi.com>
This commit is contained in:
parent
4d52618128
commit
0382b63f5d
@ -26,37 +26,17 @@
|
|||||||
|
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <stdint.h>
|
#include <stdint.h>
|
||||||
#include <stdlib.h>
|
|
||||||
#include <assert.h>
|
|
||||||
#include <debug.h>
|
#include <debug.h>
|
||||||
|
|
||||||
#include <nuttx/irq.h>
|
|
||||||
#include <nuttx/tls.h>
|
#include <nuttx/tls.h>
|
||||||
#include <nuttx/arch.h>
|
#include <nuttx/arch.h>
|
||||||
#include <nuttx/board.h>
|
#include <nuttx/board.h>
|
||||||
#include <nuttx/syslog/syslog.h>
|
|
||||||
#include <nuttx/usb/usbdev_trace.h>
|
|
||||||
|
|
||||||
#include <arch/board/board.h>
|
#include <arch/board/board.h>
|
||||||
|
|
||||||
#include "sched/sched.h"
|
#include "sched/sched.h"
|
||||||
#include "irq/irq.h"
|
|
||||||
#include "arm_internal.h"
|
#include "arm_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
|
|
||||||
|
|
||||||
#ifdef CONFIG_ARCH_STACKDUMP
|
#ifdef CONFIG_ARCH_STACKDUMP
|
||||||
|
|
||||||
/****************************************************************************
|
/****************************************************************************
|
||||||
@ -77,10 +57,6 @@ static void arm_stackdump(uint32_t sp, uint32_t stack_top)
|
|||||||
{
|
{
|
||||||
uint32_t stack;
|
uint32_t stack;
|
||||||
|
|
||||||
/* Flush any buffered SYSLOG data to avoid overwrite */
|
|
||||||
|
|
||||||
syslog_flush();
|
|
||||||
|
|
||||||
for (stack = sp & ~0x1f; stack < (stack_top & ~0x1f); stack += 32)
|
for (stack = sp & ~0x1f; stack < (stack_top & ~0x1f); stack += 32)
|
||||||
{
|
{
|
||||||
uint32_t *ptr = (uint32_t *)stack;
|
uint32_t *ptr = (uint32_t *)stack;
|
||||||
@ -313,30 +289,6 @@ static void arm_showtasks(void)
|
|||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
/****************************************************************************
|
|
||||||
* Name: assert_tracecallback
|
|
||||||
****************************************************************************/
|
|
||||||
|
|
||||||
#ifdef CONFIG_ARCH_USBDUMP
|
|
||||||
static int usbtrace_syslog(const char *fmt, ...)
|
|
||||||
{
|
|
||||||
va_list ap;
|
|
||||||
|
|
||||||
/* Let vsyslog do the real work */
|
|
||||||
|
|
||||||
va_start(ap, fmt);
|
|
||||||
vsyslog(LOG_EMERG, fmt, ap);
|
|
||||||
va_end(ap);
|
|
||||||
return OK;
|
|
||||||
}
|
|
||||||
|
|
||||||
static int assert_tracecallback(struct usbtrace_s *trace, void *arg)
|
|
||||||
{
|
|
||||||
usbtrace_trprintf(usbtrace_syslog, trace->event, trace->value);
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
|
|
||||||
/****************************************************************************
|
/****************************************************************************
|
||||||
* Name: arm_dump_stack
|
* Name: arm_dump_stack
|
||||||
****************************************************************************/
|
****************************************************************************/
|
||||||
@ -460,54 +412,6 @@ static void arm_dumpstate(void)
|
|||||||
}
|
}
|
||||||
#endif /* CONFIG_ARCH_STACKDUMP */
|
#endif /* CONFIG_ARCH_STACKDUMP */
|
||||||
|
|
||||||
/****************************************************************************
|
|
||||||
* Name: arm_assert
|
|
||||||
****************************************************************************/
|
|
||||||
|
|
||||||
static void arm_assert(void)
|
|
||||||
{
|
|
||||||
/* Flush any buffered SYSLOG data */
|
|
||||||
|
|
||||||
syslog_flush();
|
|
||||||
|
|
||||||
/* Are we in an interrupt handler or the idle task? */
|
|
||||||
|
|
||||||
if (CURRENT_REGS || (running_task())->flink == NULL)
|
|
||||||
{
|
|
||||||
#if CONFIG_BOARD_RESET_ON_ASSERT >= 1
|
|
||||||
board_reset(CONFIG_BOARD_ASSERT_RESET_VALUE);
|
|
||||||
#endif
|
|
||||||
|
|
||||||
/* Disable interrupts on this CPU */
|
|
||||||
|
|
||||||
up_irq_save();
|
|
||||||
|
|
||||||
#ifdef CONFIG_SMP
|
|
||||||
/* Try (again) to stop activity on other CPUs */
|
|
||||||
|
|
||||||
spin_trylock(&g_cpu_irqlock);
|
|
||||||
#endif
|
|
||||||
|
|
||||||
for (; ; )
|
|
||||||
{
|
|
||||||
#ifdef CONFIG_ARCH_LEDS
|
|
||||||
/* FLASH LEDs a 2Hz */
|
|
||||||
|
|
||||||
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
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/****************************************************************************
|
/****************************************************************************
|
||||||
* Public Functions
|
* Public Functions
|
||||||
****************************************************************************/
|
****************************************************************************/
|
||||||
@ -520,39 +424,7 @@ void up_assert(const char *filename, int lineno)
|
|||||||
{
|
{
|
||||||
board_autoled_on(LED_ASSERTION);
|
board_autoled_on(LED_ASSERTION);
|
||||||
|
|
||||||
/* Flush any buffered SYSLOG data (prior to the assertion) */
|
|
||||||
|
|
||||||
syslog_flush();
|
|
||||||
|
|
||||||
_alert("Assertion failed "
|
|
||||||
#ifdef CONFIG_SMP
|
|
||||||
"CPU%d "
|
|
||||||
#endif
|
|
||||||
"at file:%s line: %d"
|
|
||||||
#if CONFIG_TASK_NAME_SIZE > 0
|
|
||||||
" task: %s"
|
|
||||||
#endif
|
|
||||||
"\n",
|
|
||||||
#ifdef CONFIG_SMP
|
|
||||||
up_cpu_index(),
|
|
||||||
#endif
|
|
||||||
filename, lineno
|
|
||||||
#if CONFIG_TASK_NAME_SIZE > 0
|
|
||||||
, running_task()->name
|
|
||||||
#endif
|
|
||||||
);
|
|
||||||
|
|
||||||
#ifdef CONFIG_ARCH_STACKDUMP
|
#ifdef CONFIG_ARCH_STACKDUMP
|
||||||
arm_dumpstate();
|
arm_dumpstate();
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
/* Flush any buffered SYSLOG data (from the above) */
|
|
||||||
|
|
||||||
syslog_flush();
|
|
||||||
|
|
||||||
#ifdef CONFIG_BOARD_CRASHDUMP
|
|
||||||
board_crashdump(up_getsp(), running_task(), filename, lineno);
|
|
||||||
#endif
|
|
||||||
|
|
||||||
arm_assert();
|
|
||||||
}
|
}
|
||||||
|
@ -26,18 +26,10 @@
|
|||||||
|
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <stdint.h>
|
#include <stdint.h>
|
||||||
#include <stdlib.h>
|
|
||||||
|
|
||||||
#include <nuttx/irq.h>
|
|
||||||
#include <nuttx/arch.h>
|
#include <nuttx/arch.h>
|
||||||
#include <assert.h>
|
|
||||||
#include <debug.h>
|
#include <debug.h>
|
||||||
#include <nuttx/board.h>
|
|
||||||
#include <nuttx/syslog/syslog.h>
|
|
||||||
#include <nuttx/usb/usbdev_trace.h>
|
|
||||||
|
|
||||||
#include "sched/sched.h"
|
|
||||||
#include "irq/irq.h"
|
|
||||||
#include "arm64_arch.h"
|
#include "arm64_arch.h"
|
||||||
#include "arm64_internal.h"
|
#include "arm64_internal.h"
|
||||||
#include "chip.h"
|
#include "chip.h"
|
||||||
@ -46,20 +38,6 @@
|
|||||||
#include "arm64_fpu.h"
|
#include "arm64_fpu.h"
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
/****************************************************************************
|
|
||||||
* 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
|
|
||||||
|
|
||||||
/****************************************************************************
|
/****************************************************************************
|
||||||
* Name: arm_registerdump
|
* Name: arm_registerdump
|
||||||
****************************************************************************/
|
****************************************************************************/
|
||||||
@ -124,10 +102,6 @@ static void arm64_stackdump(uint64_t sp, uint64_t stack_top)
|
|||||||
{
|
{
|
||||||
uint64_t stack;
|
uint64_t stack;
|
||||||
|
|
||||||
/* Flush any buffered SYSLOG data to avoid overwrite */
|
|
||||||
|
|
||||||
syslog_flush();
|
|
||||||
|
|
||||||
for (stack = sp & ~0x1f; stack < (stack_top & ~0x1f); stack += 64)
|
for (stack = sp & ~0x1f; stack < (stack_top & ~0x1f); stack += 64)
|
||||||
{
|
{
|
||||||
uint64_t *ptr = (uint64_t *)stack;
|
uint64_t *ptr = (uint64_t *)stack;
|
||||||
@ -333,30 +307,6 @@ static void arm64_showtasks(void)
|
|||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
/****************************************************************************
|
|
||||||
* Name: assert_tracecallback
|
|
||||||
****************************************************************************/
|
|
||||||
|
|
||||||
#ifdef CONFIG_ARCH_USBDUMP
|
|
||||||
static int usbtrace_syslog(const char *fmt, ...)
|
|
||||||
{
|
|
||||||
va_list ap;
|
|
||||||
|
|
||||||
/* Let vsyslog do the real work */
|
|
||||||
|
|
||||||
va_start(ap, fmt);
|
|
||||||
vsyslog(LOG_EMERG, fmt, ap);
|
|
||||||
va_end(ap);
|
|
||||||
return OK;
|
|
||||||
}
|
|
||||||
|
|
||||||
static int assert_tracecallback(struct usbtrace_s *trace, void *arg)
|
|
||||||
{
|
|
||||||
usbtrace_trprintf(usbtrace_syslog, trace->event, trace->value);
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
|
|
||||||
/****************************************************************************
|
/****************************************************************************
|
||||||
* Name: arm_dump_stack
|
* Name: arm_dump_stack
|
||||||
****************************************************************************/
|
****************************************************************************/
|
||||||
@ -458,12 +408,6 @@ static void arm64_dumpstate_assert(void)
|
|||||||
/* Dump the state of all tasks (if available) */
|
/* Dump the state of all tasks (if available) */
|
||||||
|
|
||||||
arm64_showtasks();
|
arm64_showtasks();
|
||||||
|
|
||||||
#ifdef CONFIG_ARCH_USBDUMP
|
|
||||||
/* Dump USB trace data */
|
|
||||||
|
|
||||||
usbtrace_enumerate(assert_tracecallback, NULL);
|
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif /* CONFIG_ARCH_STACKDUMP */
|
#endif /* CONFIG_ARCH_STACKDUMP */
|
||||||
@ -500,47 +444,6 @@ void up_mdelay(unsigned int milliseconds)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/****************************************************************************
|
|
||||||
* Name: arm64_assert
|
|
||||||
****************************************************************************/
|
|
||||||
|
|
||||||
static void arm64_assert(void)
|
|
||||||
{
|
|
||||||
/* Flush any buffered SYSLOG data */
|
|
||||||
|
|
||||||
syslog_flush();
|
|
||||||
|
|
||||||
/* Are we in an interrupt handler or the idle task? */
|
|
||||||
|
|
||||||
if (CURRENT_REGS || (running_task())->flink == NULL)
|
|
||||||
{
|
|
||||||
#if CONFIG_BOARD_RESET_ON_ASSERT >= 1
|
|
||||||
board_reset(CONFIG_BOARD_ASSERT_RESET_VALUE);
|
|
||||||
#endif
|
|
||||||
|
|
||||||
/* Disable interrupts on this CPU */
|
|
||||||
|
|
||||||
up_irq_save();
|
|
||||||
|
|
||||||
#ifdef CONFIG_SMP
|
|
||||||
/* Try (again) to stop activity on other CPUs */
|
|
||||||
|
|
||||||
spin_trylock(&g_cpu_irqlock);
|
|
||||||
#endif
|
|
||||||
|
|
||||||
for (; ; )
|
|
||||||
{
|
|
||||||
up_mdelay(250);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
#if CONFIG_BOARD_RESET_ON_ASSERT >= 2
|
|
||||||
board_reset(CONFIG_BOARD_ASSERT_RESET_VALUE);
|
|
||||||
#endif
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/****************************************************************************
|
/****************************************************************************
|
||||||
* Public Functions
|
* Public Functions
|
||||||
****************************************************************************/
|
****************************************************************************/
|
||||||
@ -551,43 +454,7 @@ static void arm64_assert(void)
|
|||||||
|
|
||||||
void up_assert(const char *filename, int lineno)
|
void up_assert(const char *filename, int lineno)
|
||||||
{
|
{
|
||||||
#ifdef CONFIG_ARCH_FPU
|
|
||||||
arm64_fpu_disable();
|
|
||||||
#endif
|
|
||||||
|
|
||||||
/* Flush any buffered SYSLOG data (prior to the assertion) */
|
|
||||||
|
|
||||||
syslog_flush();
|
|
||||||
|
|
||||||
_alert("Assertion failed "
|
|
||||||
#ifdef CONFIG_SMP
|
|
||||||
"CPU%d "
|
|
||||||
#endif
|
|
||||||
"at file:%s line: %d"
|
|
||||||
#if CONFIG_TASK_NAME_SIZE > 0
|
|
||||||
" task: %s"
|
|
||||||
#endif
|
|
||||||
"\n",
|
|
||||||
#ifdef CONFIG_SMP
|
|
||||||
up_cpu_index(),
|
|
||||||
#endif
|
|
||||||
filename, lineno
|
|
||||||
#if CONFIG_TASK_NAME_SIZE > 0
|
|
||||||
, running_task()->name
|
|
||||||
#endif
|
|
||||||
);
|
|
||||||
|
|
||||||
#ifdef CONFIG_ARCH_STACKDUMP
|
#ifdef CONFIG_ARCH_STACKDUMP
|
||||||
arm64_dumpstate_assert();
|
arm64_dumpstate_assert();
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
/* Flush any buffered SYSLOG data (from the above) */
|
|
||||||
|
|
||||||
syslog_flush();
|
|
||||||
|
|
||||||
#ifdef CONFIG_BOARD_CRASHDUMP
|
|
||||||
board_crashdump(up_getsp(), running_task(), filename, lineno);
|
|
||||||
#endif
|
|
||||||
|
|
||||||
arm64_assert();
|
|
||||||
}
|
}
|
||||||
|
@ -34,10 +34,15 @@
|
|||||||
#include <nuttx/net/loopback.h>
|
#include <nuttx/net/loopback.h>
|
||||||
#include <nuttx/net/tun.h>
|
#include <nuttx/net/tun.h>
|
||||||
#include <nuttx/net/telnet.h>
|
#include <nuttx/net/telnet.h>
|
||||||
|
#include <nuttx/panic_notifier.h>
|
||||||
#include <nuttx/power/pm.h>
|
#include <nuttx/power/pm.h>
|
||||||
#include <arch/chip/chip.h>
|
#include <arch/chip/chip.h>
|
||||||
|
|
||||||
#include "arm64_arch.h"
|
#include "arm64_arch.h"
|
||||||
|
|
||||||
|
#ifdef CONFIG_ARCH_FPU
|
||||||
|
#include "arm64_fpu.h"
|
||||||
|
#endif
|
||||||
#include "arm64_internal.h"
|
#include "arm64_internal.h"
|
||||||
#include "chip.h"
|
#include "chip.h"
|
||||||
|
|
||||||
@ -57,6 +62,10 @@
|
|||||||
|
|
||||||
volatile uint64_t *g_current_regs[CONFIG_SMP_NCPUS];
|
volatile uint64_t *g_current_regs[CONFIG_SMP_NCPUS];
|
||||||
|
|
||||||
|
#ifdef CONFIG_ARCH_FPU
|
||||||
|
static struct notifier_block g_fpu_panic_block;
|
||||||
|
#endif
|
||||||
|
|
||||||
#ifdef CONFIG_SMP
|
#ifdef CONFIG_SMP
|
||||||
INIT_STACK_ARRAY_DEFINE(g_cpu_idlestackalloc, CONFIG_SMP_NCPUS,
|
INIT_STACK_ARRAY_DEFINE(g_cpu_idlestackalloc, CONFIG_SMP_NCPUS,
|
||||||
SMP_STACK_SIZE);
|
SMP_STACK_SIZE);
|
||||||
@ -127,6 +136,23 @@ static void up_color_intstack(void)
|
|||||||
# define up_color_intstack()
|
# define up_color_intstack()
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
/****************************************************************************
|
||||||
|
* Name: arm64_panic_disable_fpu
|
||||||
|
*
|
||||||
|
* Description:
|
||||||
|
* This is called when panic to close fpu.
|
||||||
|
*
|
||||||
|
****************************************************************************/
|
||||||
|
|
||||||
|
#ifdef CONFIG_ARCH_FPU
|
||||||
|
int arm64_panic_disable_fpu(struct notifier_block *this,
|
||||||
|
unsigned long action, void *data)
|
||||||
|
{
|
||||||
|
arm64_fpu_disable();
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
/****************************************************************************
|
/****************************************************************************
|
||||||
* Name: up_initialize
|
* Name: up_initialize
|
||||||
*
|
*
|
||||||
@ -187,4 +213,10 @@ void up_initialize(void)
|
|||||||
|
|
||||||
arm64_usbinitialize();
|
arm64_usbinitialize();
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#ifdef CONFIG_ARCH_FPU
|
||||||
|
g_fpu_panic_block.notifier_call = arm64_panic_disable_fpu;
|
||||||
|
g_fpu_panic_block.priority = INT_MAX;
|
||||||
|
panic_notifier_chain_register(&g_fpu_panic_block);
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
@ -23,102 +23,12 @@
|
|||||||
****************************************************************************/
|
****************************************************************************/
|
||||||
|
|
||||||
#include <nuttx/config.h>
|
#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/board.h>
|
||||||
#include <nuttx/syslog/syslog.h>
|
|
||||||
#include <nuttx/usb/usbdev_trace.h>
|
|
||||||
|
|
||||||
#include <arch/board/board.h>
|
#include <arch/board/board.h>
|
||||||
|
|
||||||
#include "sched/sched.h"
|
|
||||||
#include "avr_internal.h"
|
#include "avr_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(void)
|
|
||||||
{
|
|
||||||
/* Flush any buffered SYSLOG data */
|
|
||||||
|
|
||||||
syslog_flush();
|
|
||||||
|
|
||||||
/* Are we in an interrupt handler or the idle task? */
|
|
||||||
|
|
||||||
if (g_current_regs || running_task()->flink == NULL)
|
|
||||||
{
|
|
||||||
#if CONFIG_BOARD_RESET_ON_ASSERT >= 1
|
|
||||||
board_reset(CONFIG_BOARD_ASSERT_RESET_VALUE);
|
|
||||||
#endif
|
|
||||||
|
|
||||||
up_irq_save();
|
|
||||||
for (; ; )
|
|
||||||
{
|
|
||||||
#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
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/****************************************************************************
|
|
||||||
* Name: assert_tracecallback
|
|
||||||
****************************************************************************/
|
|
||||||
|
|
||||||
#ifdef CONFIG_ARCH_USBDUMP
|
|
||||||
static int usbtrace_syslog(FAR const char *fmt, ...)
|
|
||||||
{
|
|
||||||
va_list ap;
|
|
||||||
|
|
||||||
/* Let vsyslog do the real work */
|
|
||||||
|
|
||||||
va_start(ap, fmt);
|
|
||||||
vsyslog(LOG_EMERG, fmt, ap);
|
|
||||||
va_end(ap);
|
|
||||||
return OK;
|
|
||||||
}
|
|
||||||
|
|
||||||
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
|
* Public Functions
|
||||||
****************************************************************************/
|
****************************************************************************/
|
||||||
@ -130,34 +40,5 @@ static int assert_tracecallback(FAR struct usbtrace_s *trace, FAR void *arg)
|
|||||||
void up_assert(const char *filename, int lineno)
|
void up_assert(const char *filename, int lineno)
|
||||||
{
|
{
|
||||||
board_autoled_on(LED_ASSERTION);
|
board_autoled_on(LED_ASSERTION);
|
||||||
|
|
||||||
/* Flush any buffered SYSLOG data (prior to the assertion) */
|
|
||||||
|
|
||||||
syslog_flush();
|
|
||||||
|
|
||||||
#if CONFIG_TASK_NAME_SIZE > 0
|
|
||||||
_alert("Assertion failed at file:%s line: %d task: %s\n",
|
|
||||||
filename, lineno, running_task()->name);
|
|
||||||
#else
|
|
||||||
_alert("Assertion failed at file:%s line: %d\n",
|
|
||||||
filename, lineno);
|
|
||||||
#endif
|
|
||||||
|
|
||||||
avr_dumpstate();
|
avr_dumpstate();
|
||||||
|
|
||||||
/* Flush any buffered SYSLOG data (from the above) */
|
|
||||||
|
|
||||||
syslog_flush();
|
|
||||||
|
|
||||||
#ifdef CONFIG_BOARD_CRASHDUMP
|
|
||||||
board_crashdump(up_getsp(), running_task(), filename, lineno);
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#ifdef CONFIG_ARCH_USBDUMP
|
|
||||||
/* Dump USB trace data */
|
|
||||||
|
|
||||||
usbtrace_enumerate(assert_tracecallback, NULL);
|
|
||||||
#endif
|
|
||||||
|
|
||||||
_up_assert();
|
|
||||||
}
|
}
|
||||||
|
@ -24,31 +24,13 @@
|
|||||||
|
|
||||||
#include <nuttx/config.h>
|
#include <nuttx/config.h>
|
||||||
|
|
||||||
#include <assert.h>
|
|
||||||
#include <debug.h>
|
#include <debug.h>
|
||||||
|
|
||||||
#include <nuttx/arch.h>
|
#include <nuttx/arch.h>
|
||||||
#include <nuttx/syslog/syslog.h>
|
|
||||||
#include <nuttx/usb/usbdev_trace.h>
|
|
||||||
|
|
||||||
#include "sched/sched.h"
|
#include "sched/sched.h"
|
||||||
#include "irq/irq.h"
|
|
||||||
#include "ceva_internal.h"
|
#include "ceva_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 Data
|
* Private Data
|
||||||
****************************************************************************/
|
****************************************************************************/
|
||||||
@ -151,30 +133,6 @@ static inline void up_registerdump(void)
|
|||||||
# define up_registerdump()
|
# define up_registerdump()
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
/****************************************************************************
|
|
||||||
* Name: assert_tracecallback
|
|
||||||
****************************************************************************/
|
|
||||||
|
|
||||||
#ifdef CONFIG_ARCH_USBDUMP
|
|
||||||
static int usbtrace_syslog(const char *fmt, ...)
|
|
||||||
{
|
|
||||||
va_list ap;
|
|
||||||
|
|
||||||
/* Let vsyslog do the real work */
|
|
||||||
|
|
||||||
va_start(ap, fmt);
|
|
||||||
vsyslog(LOG_EMERG, fmt, &ap);
|
|
||||||
va_end(ap);
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
static int assert_tracecallback(struct usbtrace_s *trace, void *arg)
|
|
||||||
{
|
|
||||||
usbtrace_trprintf(usbtrace_syslog, trace->event, trace->value);
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
|
|
||||||
/****************************************************************************
|
/****************************************************************************
|
||||||
* Name: up_dumpstate
|
* Name: up_dumpstate
|
||||||
****************************************************************************/
|
****************************************************************************/
|
||||||
@ -272,56 +230,11 @@ static void up_dumpstate(void)
|
|||||||
/* Dump the state of all tasks (if available) */
|
/* Dump the state of all tasks (if available) */
|
||||||
|
|
||||||
up_showtasks();
|
up_showtasks();
|
||||||
|
|
||||||
#ifdef CONFIG_ARCH_USBDUMP
|
|
||||||
/* Dump USB trace data */
|
|
||||||
|
|
||||||
usbtrace_enumerate(assert_tracecallback, NULL);
|
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
#else
|
#else
|
||||||
# define up_dumpstate()
|
# define up_dumpstate()
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
/****************************************************************************
|
|
||||||
* Name: _up_assert
|
|
||||||
****************************************************************************/
|
|
||||||
|
|
||||||
static void _up_assert(int errorcode) noreturn_function;
|
|
||||||
static void _up_assert(int errorcode)
|
|
||||||
{
|
|
||||||
/* Flush any buffered SYSLOG data */
|
|
||||||
|
|
||||||
syslog_flush();
|
|
||||||
|
|
||||||
/* Are we in an interrupt handler or the idle task? */
|
|
||||||
|
|
||||||
if (up_interrupt_context() || sched_idletask())
|
|
||||||
{
|
|
||||||
#if CONFIG_BOARD_RESET_ON_ASSERT >= 1
|
|
||||||
board_reset(CONFIG_BOARD_ASSERT_RESET_VALUE);
|
|
||||||
#endif
|
|
||||||
|
|
||||||
up_irq_save();
|
|
||||||
|
|
||||||
#ifdef CONFIG_SMP
|
|
||||||
/* Try (again) to stop activity on other CPUs */
|
|
||||||
|
|
||||||
spin_trylock(&g_cpu_irqlock);
|
|
||||||
#endif
|
|
||||||
|
|
||||||
for (; ; )
|
|
||||||
{
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
#if CONFIG_BOARD_RESET_ON_ASSERT >= 2
|
|
||||||
board_reset(CONFIG_BOARD_ASSERT_RESET_VALUE);
|
|
||||||
#endif
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/****************************************************************************
|
/****************************************************************************
|
||||||
* Public Functions
|
* Public Functions
|
||||||
****************************************************************************/
|
****************************************************************************/
|
||||||
@ -332,41 +245,5 @@ static void _up_assert(int errorcode)
|
|||||||
|
|
||||||
void up_assert(const uint8_t *filename, int lineno)
|
void up_assert(const uint8_t *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) */
|
|
||||||
|
|
||||||
syslog_flush();
|
|
||||||
|
|
||||||
#ifdef CONFIG_SMP
|
|
||||||
#if CONFIG_TASK_NAME_SIZE > 0
|
|
||||||
_alert("Assertion failed CPU%d at file:%s line: %d task: %s\n",
|
|
||||||
up_cpu_index(), filename, lineno, rtcb->name);
|
|
||||||
#else
|
|
||||||
_alert("Assertion failed CPU%d at file:%s line: %d\n",
|
|
||||||
up_cpu_index(), filename, lineno);
|
|
||||||
#endif
|
|
||||||
#else
|
|
||||||
#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
|
|
||||||
#endif
|
|
||||||
|
|
||||||
up_dumpstate();
|
up_dumpstate();
|
||||||
|
|
||||||
/* Flush any buffered SYSLOG data (from the above) */
|
|
||||||
|
|
||||||
syslog_flush();
|
|
||||||
|
|
||||||
#ifdef CONFIG_BOARD_CRASHDUMP
|
|
||||||
board_crashdump(up_getsp(), running_task(), filename, lineno);
|
|
||||||
#endif
|
|
||||||
|
|
||||||
_up_assert(EXIT_FAILURE);
|
|
||||||
}
|
}
|
||||||
|
@ -25,35 +25,17 @@
|
|||||||
#include <nuttx/config.h>
|
#include <nuttx/config.h>
|
||||||
|
|
||||||
#include <stdint.h>
|
#include <stdint.h>
|
||||||
#include <stdlib.h>
|
|
||||||
#include <assert.h>
|
|
||||||
#include <debug.h>
|
#include <debug.h>
|
||||||
|
|
||||||
#include <nuttx/irq.h>
|
#include <nuttx/irq.h>
|
||||||
#include <nuttx/arch.h>
|
#include <nuttx/arch.h>
|
||||||
#include <nuttx/board.h>
|
#include <nuttx/board.h>
|
||||||
#include <nuttx/syslog/syslog.h>
|
|
||||||
#include <nuttx/usb/usbdev_trace.h>
|
|
||||||
|
|
||||||
#include <arch/board/board.h>
|
#include <arch/board/board.h>
|
||||||
|
|
||||||
#include "sched/sched.h"
|
#include "sched/sched.h"
|
||||||
#include "hc_internal.h"
|
#include "hc_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 Data
|
* Private Data
|
||||||
****************************************************************************/
|
****************************************************************************/
|
||||||
@ -75,10 +57,6 @@ static void hc_stackdump(uint16_t sp, uint16_t stack_top)
|
|||||||
{
|
{
|
||||||
uint16_t stack;
|
uint16_t stack;
|
||||||
|
|
||||||
/* Flush any buffered SYSLOG data to avoid overwrite */
|
|
||||||
|
|
||||||
syslog_flush();
|
|
||||||
|
|
||||||
for (stack = sp & ~0x7; stack < (stack_top & ~0x7); stack += 8)
|
for (stack = sp & ~0x7; stack < (stack_top & ~0x7); stack += 8)
|
||||||
{
|
{
|
||||||
uint8_t *ptr = (uint8_t *)stack;
|
uint8_t *ptr = (uint8_t *)stack;
|
||||||
@ -134,30 +112,6 @@ static inline void hc_registerdump(void)
|
|||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
/****************************************************************************
|
|
||||||
* Name: assert_tracecallback
|
|
||||||
****************************************************************************/
|
|
||||||
|
|
||||||
#ifdef CONFIG_ARCH_USBDUMP
|
|
||||||
static int usbtrace_syslog(FAR const char *fmt, ...)
|
|
||||||
{
|
|
||||||
va_list ap;
|
|
||||||
|
|
||||||
/* Let vsyslog do the real work */
|
|
||||||
|
|
||||||
va_start(ap, fmt);
|
|
||||||
vsyslog(LOG_EMERG, fmt, ap);
|
|
||||||
va_end(ap);
|
|
||||||
return OK;
|
|
||||||
}
|
|
||||||
|
|
||||||
static int assert_tracecallback(FAR struct usbtrace_s *trace, FAR void *arg)
|
|
||||||
{
|
|
||||||
usbtrace_trprintf(usbtrace_syslog, trace->event, trace->value);
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
|
|
||||||
/****************************************************************************
|
/****************************************************************************
|
||||||
* Name: up_dumpstate
|
* Name: up_dumpstate
|
||||||
****************************************************************************/
|
****************************************************************************/
|
||||||
@ -243,54 +197,11 @@ static void up_dumpstate(void)
|
|||||||
_alert("ERROR: Stack pointer is not within allocated stack\n");
|
_alert("ERROR: Stack pointer is not within allocated stack\n");
|
||||||
hc_stackdump(ustackbase, ustackbase + ustacksize);
|
hc_stackdump(ustackbase, ustackbase + ustacksize);
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifdef CONFIG_ARCH_USBDUMP
|
|
||||||
/* Dump USB trace data */
|
|
||||||
|
|
||||||
usbtrace_enumerate(assert_tracecallback, NULL);
|
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
#else
|
#else
|
||||||
# define up_dumpstate()
|
# define up_dumpstate()
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
/****************************************************************************
|
|
||||||
* Name: _up_assert
|
|
||||||
****************************************************************************/
|
|
||||||
|
|
||||||
static void _up_assert(void)
|
|
||||||
{
|
|
||||||
/* Flush any buffered SYSLOG data */
|
|
||||||
|
|
||||||
syslog_flush();
|
|
||||||
|
|
||||||
/* Are we in an interrupt handler or the idle task? */
|
|
||||||
|
|
||||||
if (g_current_regs || (running_task())->flink == NULL)
|
|
||||||
{
|
|
||||||
#if CONFIG_BOARD_RESET_ON_ASSERT >= 1
|
|
||||||
board_reset(CONFIG_BOARD_ASSERT_RESET_VALUE);
|
|
||||||
#endif
|
|
||||||
|
|
||||||
up_irq_save();
|
|
||||||
for (; ; )
|
|
||||||
{
|
|
||||||
#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
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/****************************************************************************
|
/****************************************************************************
|
||||||
* Public Functions
|
* Public Functions
|
||||||
****************************************************************************/
|
****************************************************************************/
|
||||||
@ -302,28 +213,5 @@ static void _up_assert(void)
|
|||||||
void up_assert(const char *filename, int lineno)
|
void up_assert(const char *filename, int lineno)
|
||||||
{
|
{
|
||||||
board_autoled_on(LED_ASSERTION);
|
board_autoled_on(LED_ASSERTION);
|
||||||
|
|
||||||
/* Flush any buffered SYSLOG data (from prior to the assertion) */
|
|
||||||
|
|
||||||
syslog_flush();
|
|
||||||
|
|
||||||
#if CONFIG_TASK_NAME_SIZE > 0
|
|
||||||
_alert("Assertion failed at file:%s line: %d task: %s\n",
|
|
||||||
filename, lineno, running_task()->name);
|
|
||||||
#else
|
|
||||||
_alert("Assertion failed at file:%s line: %d\n",
|
|
||||||
filename, lineno);
|
|
||||||
#endif
|
|
||||||
|
|
||||||
up_dumpstate();
|
up_dumpstate();
|
||||||
|
|
||||||
/* Flush any buffered SYSLOG data (from the above) */
|
|
||||||
|
|
||||||
syslog_flush();
|
|
||||||
|
|
||||||
#ifdef CONFIG_BOARD_CRASHDUMP
|
|
||||||
board_crashdump(up_getsp(), running_task(), filename, lineno);
|
|
||||||
#endif
|
|
||||||
|
|
||||||
_up_assert();
|
|
||||||
}
|
}
|
||||||
|
@ -24,101 +24,12 @@
|
|||||||
|
|
||||||
#include <nuttx/config.h>
|
#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/board.h>
|
||||||
#include <nuttx/syslog/syslog.h>
|
|
||||||
#include <nuttx/usb/usbdev_trace.h>
|
|
||||||
|
|
||||||
#include <arch/board/board.h>
|
#include <arch/board/board.h>
|
||||||
|
|
||||||
#include "sched/sched.h"
|
|
||||||
#include "mips_internal.h"
|
#include "mips_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(void)
|
|
||||||
{
|
|
||||||
/* Flush any buffered SYSLOG data */
|
|
||||||
|
|
||||||
syslog_flush();
|
|
||||||
|
|
||||||
/* Are we in an interrupt handler or the idle task? */
|
|
||||||
|
|
||||||
if (CURRENT_REGS || running_task()->flink == NULL)
|
|
||||||
{
|
|
||||||
#if CONFIG_BOARD_RESET_ON_ASSERT >= 1
|
|
||||||
board_reset(CONFIG_BOARD_ASSERT_RESET_VALUE);
|
|
||||||
#endif
|
|
||||||
|
|
||||||
up_irq_save();
|
|
||||||
for (; ; )
|
|
||||||
{
|
|
||||||
#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
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/****************************************************************************
|
|
||||||
* Name: assert_tracecallback
|
|
||||||
****************************************************************************/
|
|
||||||
|
|
||||||
#ifdef CONFIG_ARCH_USBDUMP
|
|
||||||
static int usbtrace_syslog(const char *fmt, ...)
|
|
||||||
{
|
|
||||||
va_list ap;
|
|
||||||
|
|
||||||
/* Let vsyslog do the real work */
|
|
||||||
|
|
||||||
va_start(ap, fmt);
|
|
||||||
vsyslog(LOG_EMERG, fmt, ap);
|
|
||||||
va_end(ap);
|
|
||||||
return OK;
|
|
||||||
}
|
|
||||||
|
|
||||||
static int assert_tracecallback(struct usbtrace_s *trace, void *arg)
|
|
||||||
{
|
|
||||||
usbtrace_trprintf(usbtrace_syslog, trace->event, trace->value);
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
|
|
||||||
/****************************************************************************
|
/****************************************************************************
|
||||||
* Public Functions
|
* Public Functions
|
||||||
****************************************************************************/
|
****************************************************************************/
|
||||||
@ -130,34 +41,5 @@ static int assert_tracecallback(struct usbtrace_s *trace, void *arg)
|
|||||||
void up_assert(const char *filename, int lineno)
|
void up_assert(const char *filename, int lineno)
|
||||||
{
|
{
|
||||||
board_autoled_on(LED_ASSERTION);
|
board_autoled_on(LED_ASSERTION);
|
||||||
|
|
||||||
/* Flush any buffered SYSLOG data (from prior to the assertion) */
|
|
||||||
|
|
||||||
syslog_flush();
|
|
||||||
|
|
||||||
#if CONFIG_TASK_NAME_SIZE > 0
|
|
||||||
_alert("Assertion failed at file:%s line: %d task: %s\n",
|
|
||||||
filename, lineno, running_task()->name);
|
|
||||||
#else
|
|
||||||
_alert("Assertion failed at file:%s line: %d\n",
|
|
||||||
filename, lineno);
|
|
||||||
#endif
|
|
||||||
|
|
||||||
mips_dumpstate();
|
mips_dumpstate();
|
||||||
|
|
||||||
/* Flush any buffered SYSLOG data (from the above) */
|
|
||||||
|
|
||||||
syslog_flush();
|
|
||||||
|
|
||||||
#ifdef CONFIG_ARCH_USBDUMP
|
|
||||||
/* Dump USB trace data */
|
|
||||||
|
|
||||||
usbtrace_enumerate(assert_tracecallback, NULL);
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#ifdef CONFIG_BOARD_CRASHDUMP
|
|
||||||
board_crashdump(up_getsp(), running_task(), filename, lineno);
|
|
||||||
#endif
|
|
||||||
|
|
||||||
_up_assert();
|
|
||||||
}
|
}
|
||||||
|
@ -24,106 +24,12 @@
|
|||||||
|
|
||||||
#include <nuttx/config.h>
|
#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/board.h>
|
||||||
#include <nuttx/syslog/syslog.h>
|
|
||||||
#include <nuttx/usb/usbdev_trace.h>
|
|
||||||
|
|
||||||
#include <arch/board/board.h>
|
#include <arch/board/board.h>
|
||||||
|
|
||||||
#include "sched/sched.h"
|
|
||||||
#include "lm32.h"
|
#include "lm32.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(void)
|
|
||||||
{
|
|
||||||
/* Flush any buffered SYSLOG data */
|
|
||||||
|
|
||||||
syslog_flush();
|
|
||||||
|
|
||||||
/* Are we in an interrupt handler or the idle task?
|
|
||||||
* NOTE: You cannot use the PID to determine if this is an IDLE task. In
|
|
||||||
* the SMP case, there may be multiple IDLE tasks with different PIDs. The
|
|
||||||
* only consistent way to test for the IDLE task is to check it is at the
|
|
||||||
* end of the list (flink == NULL)
|
|
||||||
*/
|
|
||||||
|
|
||||||
if (g_current_regs || running_task()->flink == NULL)
|
|
||||||
{
|
|
||||||
#if CONFIG_BOARD_RESET_ON_ASSERT >= 1
|
|
||||||
board_reset(CONFIG_BOARD_ASSERT_RESET_VALUE);
|
|
||||||
#endif
|
|
||||||
|
|
||||||
up_irq_save();
|
|
||||||
for (; ; )
|
|
||||||
{
|
|
||||||
#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
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/****************************************************************************
|
|
||||||
* Name: assert_tracecallback
|
|
||||||
****************************************************************************/
|
|
||||||
|
|
||||||
#ifdef CONFIG_ARCH_USBDUMP
|
|
||||||
static int usbtrace_syslog(const char *fmt, ...)
|
|
||||||
{
|
|
||||||
va_list ap;
|
|
||||||
|
|
||||||
/* Let vsyslog do the real work */
|
|
||||||
|
|
||||||
va_start(ap, fmt);
|
|
||||||
vsyslog(LOG_EMERG, fmt, ap);
|
|
||||||
va_end(ap);
|
|
||||||
return OK;
|
|
||||||
}
|
|
||||||
|
|
||||||
static int assert_tracecallback(struct usbtrace_s *trace, void *arg)
|
|
||||||
{
|
|
||||||
usbtrace_trprintf(usbtrace_syslog, trace->event, trace->value);
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
|
|
||||||
/****************************************************************************
|
/****************************************************************************
|
||||||
* Public Functions
|
* Public Functions
|
||||||
****************************************************************************/
|
****************************************************************************/
|
||||||
@ -135,34 +41,5 @@ static int assert_tracecallback(struct usbtrace_s *trace, void *arg)
|
|||||||
void up_assert(const char *filename, int lineno)
|
void up_assert(const char *filename, int lineno)
|
||||||
{
|
{
|
||||||
board_autoled_on(LED_ASSERTION);
|
board_autoled_on(LED_ASSERTION);
|
||||||
|
|
||||||
/* Flush any buffered SYSLOG data (prior to the assertion) */
|
|
||||||
|
|
||||||
syslog_flush();
|
|
||||||
|
|
||||||
#if CONFIG_TASK_NAME_SIZE > 0
|
|
||||||
_alert("Assertion failed at file:%s line: %d task: %s\n",
|
|
||||||
filename, lineno, running_task()->name);
|
|
||||||
#else
|
|
||||||
_alert("Assertion failed at file:%s line: %d\n",
|
|
||||||
filename, lineno);
|
|
||||||
#endif
|
|
||||||
|
|
||||||
lm32_dumpstate();
|
lm32_dumpstate();
|
||||||
|
|
||||||
#ifdef CONFIG_ARCH_USBDUMP
|
|
||||||
/* Dump USB trace data */
|
|
||||||
|
|
||||||
usbtrace_enumerate(assert_tracecallback, NULL);
|
|
||||||
#endif
|
|
||||||
|
|
||||||
/* Flush any buffered SYSLOG data (from the above) */
|
|
||||||
|
|
||||||
syslog_flush();
|
|
||||||
|
|
||||||
#ifdef CONFIG_BOARD_CRASHDUMP
|
|
||||||
board_crashdump(up_getsp(), running_task(), filename, lineno);
|
|
||||||
#endif
|
|
||||||
|
|
||||||
_up_assert();
|
|
||||||
}
|
}
|
||||||
|
@ -24,106 +24,12 @@
|
|||||||
|
|
||||||
#include <nuttx/config.h>
|
#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/board.h>
|
||||||
#include <nuttx/syslog/syslog.h>
|
|
||||||
#include <nuttx/usb/usbdev_trace.h>
|
|
||||||
|
|
||||||
#include <arch/board/board.h>
|
#include <arch/board/board.h>
|
||||||
|
|
||||||
#include "sched/sched.h"
|
|
||||||
#include "minerva.h"
|
#include "minerva.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(void)
|
|
||||||
{
|
|
||||||
/* Flush any buffered SYSLOG data */
|
|
||||||
|
|
||||||
syslog_flush();
|
|
||||||
|
|
||||||
/* Are we in an interrupt handler or the idle task? NOTE: You cannot use
|
|
||||||
* the PID to determine if this is an IDLE task. In the SMP case, there
|
|
||||||
* may be multiple IDLE tasks with different PIDs. The only consistent
|
|
||||||
* way to test for the IDLE task is to check it is at the end of the list
|
|
||||||
* (flink == NULL)
|
|
||||||
*/
|
|
||||||
|
|
||||||
if (g_current_regs || running_task()->flink == NULL)
|
|
||||||
{
|
|
||||||
#if CONFIG_BOARD_RESET_ON_ASSERT >= 1
|
|
||||||
board_reset(CONFIG_BOARD_ASSERT_RESET_VALUE);
|
|
||||||
#endif
|
|
||||||
|
|
||||||
up_irq_save();
|
|
||||||
for (; ; )
|
|
||||||
{
|
|
||||||
#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
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/****************************************************************************
|
|
||||||
* Name: assert_tracecallback
|
|
||||||
****************************************************************************/
|
|
||||||
|
|
||||||
#ifdef CONFIG_ARCH_USBDUMP
|
|
||||||
static int usbtrace_syslog(const char *fmt, ...)
|
|
||||||
{
|
|
||||||
va_list ap;
|
|
||||||
|
|
||||||
/* Let vsyslog do the real work */
|
|
||||||
|
|
||||||
va_start(ap, fmt);
|
|
||||||
vsyslog(LOG_EMERG, fmt, ap);
|
|
||||||
va_end(ap);
|
|
||||||
return OK;
|
|
||||||
}
|
|
||||||
|
|
||||||
static int assert_tracecallback(struct usbtrace_s *trace, void *arg)
|
|
||||||
{
|
|
||||||
usbtrace_trprintf(usbtrace_syslog, trace->event, trace->value);
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
|
|
||||||
/****************************************************************************
|
/****************************************************************************
|
||||||
* Public Functions
|
* Public Functions
|
||||||
****************************************************************************/
|
****************************************************************************/
|
||||||
@ -135,33 +41,5 @@ static int assert_tracecallback(struct usbtrace_s *trace, void *arg)
|
|||||||
void up_assert(const char *filename, int lineno)
|
void up_assert(const char *filename, int lineno)
|
||||||
{
|
{
|
||||||
board_autoled_on(LED_ASSERTION);
|
board_autoled_on(LED_ASSERTION);
|
||||||
|
|
||||||
/* Flush any buffered SYSLOG data (prior to the assertion) */
|
|
||||||
|
|
||||||
syslog_flush();
|
|
||||||
|
|
||||||
#if CONFIG_TASK_NAME_SIZE > 0
|
|
||||||
_alert("Assertion failed at file:%s line: %d task: %s\n",
|
|
||||||
filename, lineno, running_task()->name);
|
|
||||||
#else
|
|
||||||
_alert("Assertion failed at file:%s line: %d\n", filename, lineno);
|
|
||||||
#endif
|
|
||||||
|
|
||||||
minerva_dumpstate();
|
minerva_dumpstate();
|
||||||
|
|
||||||
#ifdef CONFIG_ARCH_USBDUMP
|
|
||||||
/* Dump USB trace data */
|
|
||||||
|
|
||||||
usbtrace_enumerate(assert_tracecallback, NULL);
|
|
||||||
#endif
|
|
||||||
|
|
||||||
/* Flush any buffered SYSLOG data (from the above) */
|
|
||||||
|
|
||||||
syslog_flush();
|
|
||||||
|
|
||||||
#ifdef CONFIG_BOARD_CRASHDUMP
|
|
||||||
board_crashdump(up_getsp(), running_task(), filename, lineno);
|
|
||||||
#endif
|
|
||||||
|
|
||||||
_up_assert();
|
|
||||||
}
|
}
|
||||||
|
@ -25,35 +25,17 @@
|
|||||||
#include <nuttx/config.h>
|
#include <nuttx/config.h>
|
||||||
|
|
||||||
#include <stdint.h>
|
#include <stdint.h>
|
||||||
#include <stdlib.h>
|
|
||||||
#include <assert.h>
|
|
||||||
#include <debug.h>
|
#include <debug.h>
|
||||||
|
|
||||||
#include <nuttx/irq.h>
|
#include <nuttx/irq.h>
|
||||||
#include <nuttx/arch.h>
|
#include <nuttx/arch.h>
|
||||||
#include <nuttx/board.h>
|
#include <nuttx/board.h>
|
||||||
#include <nuttx/syslog/syslog.h>
|
|
||||||
#include <nuttx/usb/usbdev_trace.h>
|
|
||||||
|
|
||||||
#include <arch/board/board.h>
|
#include <arch/board/board.h>
|
||||||
|
|
||||||
#include "sched/sched.h"
|
#include "sched/sched.h"
|
||||||
#include "or1k_internal.h"
|
#include "or1k_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 Data
|
* Private Data
|
||||||
****************************************************************************/
|
****************************************************************************/
|
||||||
@ -75,10 +57,6 @@ static void or1k_stackdump(uint32_t sp, uint32_t stack_top)
|
|||||||
{
|
{
|
||||||
uint32_t stack;
|
uint32_t stack;
|
||||||
|
|
||||||
/* Flush any buffered SYSLOG data to avoid overwrite */
|
|
||||||
|
|
||||||
syslog_flush();
|
|
||||||
|
|
||||||
for (stack = sp & ~0x1f; stack < (stack_top & ~0x1f); stack += 32)
|
for (stack = sp & ~0x1f; stack < (stack_top & ~0x1f); stack += 32)
|
||||||
{
|
{
|
||||||
uint32_t *ptr = (uint32_t *)stack;
|
uint32_t *ptr = (uint32_t *)stack;
|
||||||
@ -162,31 +140,6 @@ static inline void or1k_registerdump(void)
|
|||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
/****************************************************************************
|
|
||||||
* Name: assert_tracecallback
|
|
||||||
****************************************************************************/
|
|
||||||
|
|
||||||
#ifdef CONFIG_ARCH_USBDUMP
|
|
||||||
static int usbtrace_syslog(const char *fmt, ...)
|
|
||||||
{
|
|
||||||
va_list ap;
|
|
||||||
int ret;
|
|
||||||
|
|
||||||
/* Let vsyslog do the real work */
|
|
||||||
|
|
||||||
va_start(ap, fmt);
|
|
||||||
ret = vsyslog(LOG_EMERG, fmt, ap);
|
|
||||||
va_end(ap);
|
|
||||||
return ret;
|
|
||||||
}
|
|
||||||
|
|
||||||
static int assert_tracecallback(struct usbtrace_s *trace, void *arg)
|
|
||||||
{
|
|
||||||
usbtrace_trprintf(usbtrace_syslog, trace->event, trace->value);
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
|
|
||||||
/****************************************************************************
|
/****************************************************************************
|
||||||
* Name: up_dumpstate
|
* Name: up_dumpstate
|
||||||
****************************************************************************/
|
****************************************************************************/
|
||||||
@ -287,54 +240,11 @@ static void up_dumpstate(void)
|
|||||||
/* Dump the state of all tasks (if available) */
|
/* Dump the state of all tasks (if available) */
|
||||||
|
|
||||||
up_showtasks();
|
up_showtasks();
|
||||||
|
|
||||||
#ifdef CONFIG_ARCH_USBDUMP
|
|
||||||
/* Dump USB trace data */
|
|
||||||
|
|
||||||
usbtrace_enumerate(assert_tracecallback, NULL);
|
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
#else
|
#else
|
||||||
# define up_dumpstate()
|
# define up_dumpstate()
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
/****************************************************************************
|
|
||||||
* Name: _up_assert
|
|
||||||
****************************************************************************/
|
|
||||||
|
|
||||||
static void _up_assert(void)
|
|
||||||
{
|
|
||||||
/* Flush any buffered SYSLOG data */
|
|
||||||
|
|
||||||
syslog_flush();
|
|
||||||
|
|
||||||
/* Are we in an interrupt handler or the idle task? */
|
|
||||||
|
|
||||||
if (CURRENT_REGS || running_task()->flink == NULL)
|
|
||||||
{
|
|
||||||
#if CONFIG_BOARD_RESET_ON_ASSERT >= 1
|
|
||||||
board_reset(CONFIG_BOARD_ASSERT_RESET_VALUE);
|
|
||||||
#endif
|
|
||||||
|
|
||||||
up_irq_save();
|
|
||||||
for (; ; )
|
|
||||||
{
|
|
||||||
#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
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/****************************************************************************
|
/****************************************************************************
|
||||||
* Public Functions
|
* Public Functions
|
||||||
****************************************************************************/
|
****************************************************************************/
|
||||||
@ -346,28 +256,5 @@ static void _up_assert(void)
|
|||||||
void up_assert(const char *filename, int lineno)
|
void up_assert(const char *filename, int lineno)
|
||||||
{
|
{
|
||||||
board_autoled_on(LED_ASSERTION);
|
board_autoled_on(LED_ASSERTION);
|
||||||
|
|
||||||
/* Flush any buffered SYSLOG data (from prior to the assertion) */
|
|
||||||
|
|
||||||
syslog_flush();
|
|
||||||
|
|
||||||
#if CONFIG_TASK_NAME_SIZE > 0
|
|
||||||
_alert("Assertion failed at file:%s line: %d task: %s\n",
|
|
||||||
filename, lineno, running_task()->name);
|
|
||||||
#else
|
|
||||||
_alert("Assertion failed at file:%s line: %d\n",
|
|
||||||
filename, lineno);
|
|
||||||
#endif
|
|
||||||
|
|
||||||
up_dumpstate();
|
up_dumpstate();
|
||||||
|
|
||||||
/* Flush any buffered SYSLOG data (from the above) */
|
|
||||||
|
|
||||||
syslog_flush();
|
|
||||||
|
|
||||||
#ifdef CONFIG_BOARD_CRASHDUMP
|
|
||||||
board_crashdump(up_getsp(), running_task(), filename, lineno);
|
|
||||||
#endif
|
|
||||||
|
|
||||||
_up_assert();
|
|
||||||
}
|
}
|
||||||
|
@ -24,103 +24,11 @@
|
|||||||
|
|
||||||
#include <nuttx/config.h>
|
#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/board.h>
|
||||||
#include <arch/board/board.h>
|
#include <arch/board/board.h>
|
||||||
|
|
||||||
#include <nuttx/syslog/syslog.h>
|
|
||||||
#include <nuttx/usb/usbdev_trace.h>
|
|
||||||
|
|
||||||
#include <nuttx/usb/usbdev_trace.h>
|
|
||||||
|
|
||||||
#include "sched/sched.h"
|
|
||||||
#include "renesas_internal.h"
|
#include "renesas_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(void)
|
|
||||||
{
|
|
||||||
/* Flush any buffered SYSLOG data */
|
|
||||||
|
|
||||||
syslog_flush();
|
|
||||||
|
|
||||||
/* Are we in an interrupt handler or the idle task? */
|
|
||||||
|
|
||||||
if (g_current_regs || running_task()->flink == NULL)
|
|
||||||
{
|
|
||||||
#if CONFIG_BOARD_RESET_ON_ASSERT >= 1
|
|
||||||
board_reset(CONFIG_BOARD_ASSERT_RESET_VALUE);
|
|
||||||
#endif
|
|
||||||
|
|
||||||
up_irq_save();
|
|
||||||
for (; ; )
|
|
||||||
{
|
|
||||||
#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
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/****************************************************************************
|
|
||||||
* Name: assert_tracecallback
|
|
||||||
****************************************************************************/
|
|
||||||
|
|
||||||
#ifdef CONFIG_ARCH_USBDUMP
|
|
||||||
static int usbtrace_syslog(FAR const char *fmt, ...)
|
|
||||||
{
|
|
||||||
va_list ap;
|
|
||||||
|
|
||||||
/* Let vsyslog do the real work */
|
|
||||||
|
|
||||||
va_start(ap, fmt);
|
|
||||||
vsyslog(LOG_EMERG, fmt, ap);
|
|
||||||
va_end(ap);
|
|
||||||
return OK;
|
|
||||||
}
|
|
||||||
|
|
||||||
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
|
* Public Functions
|
||||||
****************************************************************************/
|
****************************************************************************/
|
||||||
@ -132,34 +40,5 @@ static int assert_tracecallback(FAR struct usbtrace_s *trace, FAR void *arg)
|
|||||||
void up_assert(const char *filename, int lineno)
|
void up_assert(const char *filename, int lineno)
|
||||||
{
|
{
|
||||||
board_autoled_on(LED_ASSERTION);
|
board_autoled_on(LED_ASSERTION);
|
||||||
|
|
||||||
/* Flush any buffered SYSLOG data (from prior to the assertion) */
|
|
||||||
|
|
||||||
syslog_flush();
|
|
||||||
|
|
||||||
#if CONFIG_TASK_NAME_SIZE > 0
|
|
||||||
_alert("Assertion failed at file:%s line: %d task: %s\n",
|
|
||||||
filename, lineno, running_task()->name);
|
|
||||||
#else
|
|
||||||
_alert("Assertion failed at file:%s line: %d\n",
|
|
||||||
filename, lineno);
|
|
||||||
#endif
|
|
||||||
|
|
||||||
renesas_dumpstate();
|
renesas_dumpstate();
|
||||||
|
|
||||||
#ifdef CONFIG_ARCH_USBDUMP
|
|
||||||
/* Dump USB trace data */
|
|
||||||
|
|
||||||
usbtrace_enumerate(assert_tracecallback, NULL);
|
|
||||||
#endif
|
|
||||||
|
|
||||||
/* Flush any buffered SYSLOG data (from the above) */
|
|
||||||
|
|
||||||
syslog_flush();
|
|
||||||
|
|
||||||
#ifdef CONFIG_BOARD_CRASHDUMP
|
|
||||||
board_crashdump(up_getsp(), running_task(), filename, lineno);
|
|
||||||
#endif
|
|
||||||
|
|
||||||
_up_assert();
|
|
||||||
}
|
}
|
||||||
|
@ -26,39 +26,17 @@
|
|||||||
|
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <stdint.h>
|
#include <stdint.h>
|
||||||
#include <stdlib.h>
|
|
||||||
#include <assert.h>
|
|
||||||
#include <debug.h>
|
#include <debug.h>
|
||||||
|
|
||||||
#include <syscall.h>
|
|
||||||
|
|
||||||
#include <nuttx/irq.h>
|
|
||||||
#include <nuttx/tls.h>
|
#include <nuttx/tls.h>
|
||||||
#include <nuttx/arch.h>
|
#include <nuttx/arch.h>
|
||||||
#include <nuttx/board.h>
|
#include <nuttx/board.h>
|
||||||
#include <nuttx/syslog/syslog.h>
|
|
||||||
#include <nuttx/usb/usbdev_trace.h>
|
|
||||||
|
|
||||||
#include <arch/board/board.h>
|
#include <arch/board/board.h>
|
||||||
|
|
||||||
#include "sched/sched.h"
|
#include "sched/sched.h"
|
||||||
#include "irq/irq.h"
|
|
||||||
#include "riscv_internal.h"
|
#include "riscv_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
|
* Private Functions
|
||||||
****************************************************************************/
|
****************************************************************************/
|
||||||
@ -83,10 +61,6 @@ static void riscv_stackdump(uintptr_t sp, uintptr_t stack_top)
|
|||||||
{
|
{
|
||||||
uintptr_t stack;
|
uintptr_t stack;
|
||||||
|
|
||||||
/* Flush any buffered SYSLOG data to avoid overwrite */
|
|
||||||
|
|
||||||
syslog_flush();
|
|
||||||
|
|
||||||
for (stack = sp & ~0x1f; stack < (stack_top & ~0x1f); stack += 32)
|
for (stack = sp & ~0x1f; stack < (stack_top & ~0x1f); stack += 32)
|
||||||
{
|
{
|
||||||
uint32_t *ptr = (uint32_t *)stack;
|
uint32_t *ptr = (uint32_t *)stack;
|
||||||
@ -422,73 +396,6 @@ static void riscv_dumpstate(void)
|
|||||||
# define riscv_dumpstate()
|
# define riscv_dumpstate()
|
||||||
#endif /* CONFIG_ARCH_STACKDUMP */
|
#endif /* CONFIG_ARCH_STACKDUMP */
|
||||||
|
|
||||||
/****************************************************************************
|
|
||||||
* Name: riscv_assert
|
|
||||||
****************************************************************************/
|
|
||||||
|
|
||||||
static void riscv_assert(void)
|
|
||||||
{
|
|
||||||
/* Flush any buffered SYSLOG data */
|
|
||||||
|
|
||||||
syslog_flush();
|
|
||||||
|
|
||||||
/* Are we in an interrupt handler or the idle task? */
|
|
||||||
|
|
||||||
if (CURRENT_REGS || running_task()->flink == NULL)
|
|
||||||
{
|
|
||||||
#if CONFIG_BOARD_RESET_ON_ASSERT >= 1
|
|
||||||
board_reset(CONFIG_BOARD_ASSERT_RESET_VALUE);
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#ifdef CONFIG_SMP
|
|
||||||
/* Try (again) to stop activity on other CPUs */
|
|
||||||
|
|
||||||
spin_trylock(&g_cpu_irqlock);
|
|
||||||
#endif
|
|
||||||
|
|
||||||
up_irq_save();
|
|
||||||
for (; ; )
|
|
||||||
{
|
|
||||||
#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
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/****************************************************************************
|
|
||||||
* Name: assert_tracecallback
|
|
||||||
****************************************************************************/
|
|
||||||
|
|
||||||
#ifdef CONFIG_ARCH_USBDUMP
|
|
||||||
static int usbtrace_syslog(const char *fmt, ...)
|
|
||||||
{
|
|
||||||
va_list ap;
|
|
||||||
|
|
||||||
/* Let vsyslog do the real work */
|
|
||||||
|
|
||||||
va_start(ap, fmt);
|
|
||||||
vsyslog(LOG_EMERG, fmt, ap);
|
|
||||||
va_end(ap);
|
|
||||||
return OK;
|
|
||||||
}
|
|
||||||
|
|
||||||
static int assert_tracecallback(struct usbtrace_s *trace, void *arg)
|
|
||||||
{
|
|
||||||
usbtrace_trprintf(usbtrace_syslog, trace->event, trace->value);
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
|
|
||||||
/****************************************************************************
|
/****************************************************************************
|
||||||
* Public Functions
|
* Public Functions
|
||||||
****************************************************************************/
|
****************************************************************************/
|
||||||
@ -500,54 +407,9 @@ static int assert_tracecallback(struct usbtrace_s *trace, void *arg)
|
|||||||
void up_assert(const char *filename, int lineno)
|
void up_assert(const char *filename, int lineno)
|
||||||
{
|
{
|
||||||
board_autoled_on(LED_ASSERTION);
|
board_autoled_on(LED_ASSERTION);
|
||||||
|
|
||||||
/* Flush any buffered SYSLOG data (from prior to the assertion) */
|
|
||||||
|
|
||||||
syslog_flush();
|
|
||||||
|
|
||||||
#ifdef CONFIG_SMP
|
|
||||||
#if CONFIG_TASK_NAME_SIZE > 0
|
|
||||||
_alert("Assertion failed CPU%d at file:%s line: %d task: %s\n",
|
|
||||||
up_cpu_index(), filename, lineno, running_task()->name);
|
|
||||||
#else
|
|
||||||
_alert("Assertion failed CPU%d at file:%s line: %d\n",
|
|
||||||
up_cpu_index(), filename, lineno);
|
|
||||||
#endif
|
|
||||||
#else
|
|
||||||
#if CONFIG_TASK_NAME_SIZE > 0
|
|
||||||
_alert("Assertion failed at file:%s line: %d task: %s\n",
|
|
||||||
filename, lineno, running_task()->name);
|
|
||||||
#else
|
|
||||||
_alert("Assertion failed at file:%s line: %d\n",
|
|
||||||
filename, lineno);
|
|
||||||
#endif
|
|
||||||
#endif
|
|
||||||
|
|
||||||
riscv_dumpstate();
|
riscv_dumpstate();
|
||||||
|
|
||||||
#ifdef CONFIG_SMP
|
|
||||||
/* Show the CPU number */
|
|
||||||
|
|
||||||
_alert("CPU%d:\n", up_cpu_index());
|
|
||||||
#endif
|
|
||||||
|
|
||||||
/* Dump the state of all tasks (if available) */
|
/* Dump the state of all tasks (if available) */
|
||||||
|
|
||||||
riscv_showtasks();
|
riscv_showtasks();
|
||||||
|
|
||||||
#ifdef CONFIG_ARCH_USBDUMP
|
|
||||||
/* Dump USB trace data */
|
|
||||||
|
|
||||||
usbtrace_enumerate(assert_tracecallback, NULL);
|
|
||||||
#endif
|
|
||||||
|
|
||||||
/* Flush any buffered SYSLOG data (from the above) */
|
|
||||||
|
|
||||||
syslog_flush();
|
|
||||||
|
|
||||||
#ifdef CONFIG_BOARD_CRASHDUMP
|
|
||||||
board_crashdump(up_getsp(), running_task(), filename, lineno);
|
|
||||||
#endif
|
|
||||||
|
|
||||||
riscv_assert();
|
|
||||||
}
|
}
|
||||||
|
@ -75,30 +75,6 @@ void up_assert(const char *filename, int lineno)
|
|||||||
{
|
{
|
||||||
struct tcb_s *rtcb = running_task();
|
struct tcb_s *rtcb = running_task();
|
||||||
|
|
||||||
/* Flush any buffered SYSLOG data (prior to the assertion) */
|
|
||||||
|
|
||||||
syslog_flush();
|
|
||||||
|
|
||||||
/* Show the location of the failed assertion */
|
|
||||||
|
|
||||||
#ifdef CONFIG_SMP
|
|
||||||
#if CONFIG_TASK_NAME_SIZE > 0
|
|
||||||
_alert("Assertion failed CPU%d at file:%s line: %d task: %s\n",
|
|
||||||
up_cpu_index(), filename, lineno, rtcb->name);
|
|
||||||
#else
|
|
||||||
_alert("Assertion failed CPU%d at file:%s line: %d\n",
|
|
||||||
up_cpu_index(), filename, lineno);
|
|
||||||
#endif
|
|
||||||
#else
|
|
||||||
#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
|
|
||||||
#endif
|
|
||||||
|
|
||||||
/* Show back trace */
|
/* Show back trace */
|
||||||
|
|
||||||
#ifdef CONFIG_SCHED_BACKTRACE
|
#ifdef CONFIG_SCHED_BACKTRACE
|
||||||
@ -109,16 +85,6 @@ void up_assert(const char *filename, int lineno)
|
|||||||
|
|
||||||
syslog_flush();
|
syslog_flush();
|
||||||
|
|
||||||
/* Allow for any board/configuration specific crash information */
|
|
||||||
|
|
||||||
#ifdef CONFIG_BOARD_CRASHDUMP
|
|
||||||
board_crashdump(up_getsp(), rtcb, filename, lineno);
|
|
||||||
#endif
|
|
||||||
|
|
||||||
/* Flush any buffered SYSLOG data */
|
|
||||||
|
|
||||||
syslog_flush();
|
|
||||||
|
|
||||||
if (CURRENT_REGS || is_idle_task(rtcb))
|
if (CURRENT_REGS || is_idle_task(rtcb))
|
||||||
{
|
{
|
||||||
/* Exit the simulation */
|
/* Exit the simulation */
|
||||||
|
@ -24,103 +24,8 @@
|
|||||||
|
|
||||||
#include <nuttx/config.h>
|
#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 "sched/sched.h"
|
|
||||||
#include "sparc_internal.h"
|
#include "sparc_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 */
|
|
||||||
|
|
||||||
syslog_flush();
|
|
||||||
|
|
||||||
/* Are we in an interrupt handler or the idle task? */
|
|
||||||
|
|
||||||
if (CURRENT_REGS || running_task()->flink == NULL)
|
|
||||||
{
|
|
||||||
#if CONFIG_BOARD_RESET_ON_ASSERT >= 1
|
|
||||||
board_reset(CONFIG_BOARD_ASSERT_RESET_VALUE);
|
|
||||||
#endif
|
|
||||||
|
|
||||||
up_irq_save();
|
|
||||||
for (; ; )
|
|
||||||
{
|
|
||||||
#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(const char *fmt, ...)
|
|
||||||
{
|
|
||||||
va_list ap;
|
|
||||||
|
|
||||||
/* Let vsyslog do the real work */
|
|
||||||
|
|
||||||
va_start(ap, fmt);
|
|
||||||
vsyslog(LOG_EMERG, fmt, &ap);
|
|
||||||
va_end(ap);
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
static int assert_tracecallback(struct usbtrace_s *trace, void *arg)
|
|
||||||
{
|
|
||||||
usbtrace_trprintf(usbtrace_syslog, trace->event, trace->value);
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
|
|
||||||
/****************************************************************************
|
/****************************************************************************
|
||||||
* Public Functions
|
* Public Functions
|
||||||
****************************************************************************/
|
****************************************************************************/
|
||||||
@ -131,37 +36,5 @@ static int assert_tracecallback(struct usbtrace_s *trace, void *arg)
|
|||||||
|
|
||||||
void up_assert(const char *filename, int lineno)
|
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) */
|
|
||||||
|
|
||||||
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
|
|
||||||
|
|
||||||
sparc_dumpstate();
|
sparc_dumpstate();
|
||||||
|
|
||||||
/* Flush any buffered SYSLOG data (from the above) */
|
|
||||||
|
|
||||||
syslog_flush();
|
|
||||||
|
|
||||||
#ifdef CONFIG_BOARD_CRASHDUMP
|
|
||||||
board_crashdump(up_getsp(), running_task(), filename, lineno);
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#ifdef CONFIG_ARCH_USBDUMP
|
|
||||||
/* Dump USB trace data */
|
|
||||||
|
|
||||||
usbtrace_enumerate(assert_tracecallback, NULL);
|
|
||||||
#endif
|
|
||||||
|
|
||||||
_up_assert(EXIT_FAILURE);
|
|
||||||
}
|
}
|
||||||
|
@ -25,36 +25,17 @@
|
|||||||
#include <nuttx/config.h>
|
#include <nuttx/config.h>
|
||||||
|
|
||||||
#include <stdint.h>
|
#include <stdint.h>
|
||||||
#include <stdlib.h>
|
|
||||||
#include <assert.h>
|
|
||||||
#include <debug.h>
|
#include <debug.h>
|
||||||
|
|
||||||
#include <nuttx/irq.h>
|
#include <nuttx/irq.h>
|
||||||
#include <nuttx/arch.h>
|
#include <nuttx/arch.h>
|
||||||
#include <nuttx/board.h>
|
#include <nuttx/board.h>
|
||||||
#include <arch/arch.h>
|
|
||||||
#include <nuttx/syslog/syslog.h>
|
|
||||||
#include <nuttx/usb/usbdev_trace.h>
|
|
||||||
|
|
||||||
#include <arch/board/board.h>
|
#include <arch/board/board.h>
|
||||||
|
|
||||||
#include "sched/sched.h"
|
#include "sched/sched.h"
|
||||||
#include "x86_internal.h"
|
#include "x86_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 Data
|
* Private Data
|
||||||
****************************************************************************/
|
****************************************************************************/
|
||||||
@ -76,10 +57,6 @@ static void x86_stackdump(uint32_t sp, uint32_t stack_top)
|
|||||||
{
|
{
|
||||||
uint32_t stack;
|
uint32_t stack;
|
||||||
|
|
||||||
/* Flush any buffered SYSLOG data to avoid overwrite */
|
|
||||||
|
|
||||||
syslog_flush();
|
|
||||||
|
|
||||||
for (stack = sp & ~0x1f; stack < (stack_top & ~0x1f); stack += 32)
|
for (stack = sp & ~0x1f; stack < (stack_top & ~0x1f); stack += 32)
|
||||||
{
|
{
|
||||||
uint32_t *ptr = (uint32_t *)stack;
|
uint32_t *ptr = (uint32_t *)stack;
|
||||||
@ -90,30 +67,6 @@ static void x86_stackdump(uint32_t sp, uint32_t stack_top)
|
|||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
/****************************************************************************
|
|
||||||
* Name: assert_tracecallback
|
|
||||||
****************************************************************************/
|
|
||||||
|
|
||||||
#ifdef CONFIG_ARCH_USBDUMP
|
|
||||||
static int usbtrace_syslog(const char *fmt, ...)
|
|
||||||
{
|
|
||||||
va_list ap;
|
|
||||||
|
|
||||||
/* Let vsyslog do the real work */
|
|
||||||
|
|
||||||
va_start(ap, fmt);
|
|
||||||
vsyslog(LOG_EMERG, fmt, ap);
|
|
||||||
va_end(ap);
|
|
||||||
return OK;
|
|
||||||
}
|
|
||||||
|
|
||||||
static int assert_tracecallback(struct usbtrace_s *trace, void *arg)
|
|
||||||
{
|
|
||||||
usbtrace_trprintf(usbtrace_syslog, trace->event, trace->value);
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
|
|
||||||
/****************************************************************************
|
/****************************************************************************
|
||||||
* Name: x86_dumpstate
|
* Name: x86_dumpstate
|
||||||
****************************************************************************/
|
****************************************************************************/
|
||||||
@ -209,54 +162,11 @@ static void x86_dumpstate(void)
|
|||||||
_alert("ERROR: Stack pointer is not within allocated stack\n");
|
_alert("ERROR: Stack pointer is not within allocated stack\n");
|
||||||
x86_stackdump(ustackbase, ustackbase + ustacksize);
|
x86_stackdump(ustackbase, ustackbase + ustacksize);
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifdef CONFIG_ARCH_USBDUMP
|
|
||||||
/* Dump USB trace data */
|
|
||||||
|
|
||||||
usbtrace_enumerate(assert_tracecallback, NULL);
|
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
#else
|
#else
|
||||||
# define x86_dumpstate()
|
# define x86_dumpstate()
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
/****************************************************************************
|
|
||||||
* Name: _up_assert
|
|
||||||
****************************************************************************/
|
|
||||||
|
|
||||||
static void _up_assert(void)
|
|
||||||
{
|
|
||||||
/* Flush any buffered SYSLOG data */
|
|
||||||
|
|
||||||
syslog_flush();
|
|
||||||
|
|
||||||
/* Are we in an interrupt handler or the idle task? */
|
|
||||||
|
|
||||||
if (g_current_regs || (running_task())->flink == NULL)
|
|
||||||
{
|
|
||||||
#if CONFIG_BOARD_RESET_ON_ASSERT >= 1
|
|
||||||
board_reset(CONFIG_BOARD_ASSERT_RESET_VALUE);
|
|
||||||
#endif
|
|
||||||
|
|
||||||
up_irq_save();
|
|
||||||
for (; ; )
|
|
||||||
{
|
|
||||||
#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
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/****************************************************************************
|
/****************************************************************************
|
||||||
* Public Functions
|
* Public Functions
|
||||||
****************************************************************************/
|
****************************************************************************/
|
||||||
@ -268,28 +178,5 @@ static void _up_assert(void)
|
|||||||
void up_assert(const char *filename, int lineno)
|
void up_assert(const char *filename, int lineno)
|
||||||
{
|
{
|
||||||
board_autoled_on(LED_ASSERTION);
|
board_autoled_on(LED_ASSERTION);
|
||||||
|
|
||||||
/* Flush any buffered SYSLOG data (from prior to the assertion) */
|
|
||||||
|
|
||||||
syslog_flush();
|
|
||||||
|
|
||||||
#if CONFIG_TASK_NAME_SIZE > 0
|
|
||||||
_alert("Assertion failed at file:%s line: %d task: %s\n",
|
|
||||||
filename, lineno, running_task()->name);
|
|
||||||
#else
|
|
||||||
_alert("Assertion failed at file:%s line: %d\n",
|
|
||||||
filename, lineno);
|
|
||||||
#endif
|
|
||||||
|
|
||||||
x86_dumpstate();
|
x86_dumpstate();
|
||||||
|
|
||||||
/* Flush any buffered SYSLOG data (from the above) */
|
|
||||||
|
|
||||||
syslog_flush();
|
|
||||||
|
|
||||||
#ifdef CONFIG_BOARD_CRASHDUMP
|
|
||||||
board_crashdump(up_getsp(), running_task(), filename, lineno);
|
|
||||||
#endif
|
|
||||||
|
|
||||||
_up_assert();
|
|
||||||
}
|
}
|
||||||
|
@ -25,36 +25,16 @@
|
|||||||
#include <nuttx/config.h>
|
#include <nuttx/config.h>
|
||||||
|
|
||||||
#include <stdint.h>
|
#include <stdint.h>
|
||||||
#include <stdlib.h>
|
|
||||||
#include <assert.h>
|
|
||||||
#include <debug.h>
|
#include <debug.h>
|
||||||
|
|
||||||
#include <nuttx/irq.h>
|
#include <nuttx/irq.h>
|
||||||
#include <nuttx/arch.h>
|
|
||||||
#include <nuttx/board.h>
|
#include <nuttx/board.h>
|
||||||
#include <arch/arch.h>
|
|
||||||
#include <nuttx/syslog/syslog.h>
|
|
||||||
#include <nuttx/usb/usbdev_trace.h>
|
|
||||||
|
|
||||||
#include <arch/board/board.h>
|
#include <arch/board/board.h>
|
||||||
|
|
||||||
#include "sched/sched.h"
|
#include "sched/sched.h"
|
||||||
#include "x86_64_internal.h"
|
#include "x86_64_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
|
* Private Functions
|
||||||
****************************************************************************/
|
****************************************************************************/
|
||||||
@ -68,10 +48,6 @@ static void x86_64_stackdump(uint64_t sp, uint64_t stack_top)
|
|||||||
{
|
{
|
||||||
uint64_t stack;
|
uint64_t stack;
|
||||||
|
|
||||||
/* Flush any buffered SYSLOG data to avoid overwrite */
|
|
||||||
|
|
||||||
syslog_flush();
|
|
||||||
|
|
||||||
for (stack = sp & ~0x1f; stack < (stack_top & ~0x1f); stack += 32)
|
for (stack = sp & ~0x1f; stack < (stack_top & ~0x1f); stack += 32)
|
||||||
{
|
{
|
||||||
uint32_t *ptr = (uint32_t *)stack;
|
uint32_t *ptr = (uint32_t *)stack;
|
||||||
@ -84,30 +60,6 @@ static void x86_64_stackdump(uint64_t sp, uint64_t stack_top)
|
|||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
/****************************************************************************
|
|
||||||
* Name: assert_tracecallback
|
|
||||||
****************************************************************************/
|
|
||||||
|
|
||||||
#ifdef CONFIG_ARCH_USBDUMP
|
|
||||||
static int usbtrace_syslog(const char *fmt, ...)
|
|
||||||
{
|
|
||||||
va_list ap;
|
|
||||||
|
|
||||||
/* Let vsyslog do the real work */
|
|
||||||
|
|
||||||
va_start(ap, fmt);
|
|
||||||
vsyslog(LOG_EMERG, fmt, ap);
|
|
||||||
va_end(ap);
|
|
||||||
return OK;
|
|
||||||
}
|
|
||||||
|
|
||||||
static int assert_tracecallback(struct usbtrace_s *trace, void *arg)
|
|
||||||
{
|
|
||||||
usbtrace_trprintf(usbtrace_syslog, trace->event, trace->value);
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
|
|
||||||
/****************************************************************************
|
/****************************************************************************
|
||||||
* Name: x86_64_dumpstate
|
* Name: x86_64_dumpstate
|
||||||
****************************************************************************/
|
****************************************************************************/
|
||||||
@ -196,56 +148,11 @@ static void x86_64_dumpstate(void)
|
|||||||
{
|
{
|
||||||
x86_64_registerdump((uint64_t *)g_current_regs);
|
x86_64_registerdump((uint64_t *)g_current_regs);
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifdef CONFIG_ARCH_USBDUMP
|
|
||||||
/* Dump USB trace data */
|
|
||||||
|
|
||||||
usbtrace_enumerate(assert_tracecallback, NULL);
|
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
#else
|
#else
|
||||||
# define x86_64_dumpstate()
|
# define x86_64_dumpstate()
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
/****************************************************************************
|
|
||||||
* Name: _up_assert
|
|
||||||
****************************************************************************/
|
|
||||||
|
|
||||||
static void _up_assert(void)
|
|
||||||
{
|
|
||||||
/* Flush any buffered SYSLOG data */
|
|
||||||
|
|
||||||
syslog_flush();
|
|
||||||
|
|
||||||
/* Are we in an interrupt handler or the idle task? */
|
|
||||||
|
|
||||||
if (g_current_regs || (running_task())->flink == NULL)
|
|
||||||
{
|
|
||||||
#if CONFIG_BOARD_RESET_ON_ASSERT >= 1
|
|
||||||
board_reset(CONFIG_BOARD_ASSERT_RESET_VALUE);
|
|
||||||
#endif
|
|
||||||
|
|
||||||
up_irq_save();
|
|
||||||
for (; ; )
|
|
||||||
{
|
|
||||||
#ifdef CONFIG_ARCH_LEDS
|
|
||||||
board_autoled_on(LED_PANIC);
|
|
||||||
up_mdelay(250);
|
|
||||||
board_autoled_off(LED_PANIC);
|
|
||||||
up_mdelay(250);
|
|
||||||
#endif
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
/* Assertions in other contexts only cause the thread to exit */
|
|
||||||
|
|
||||||
#if CONFIG_BOARD_RESET_ON_ASSERT >= 2
|
|
||||||
board_reset(CONFIG_BOARD_ASSERT_RESET_VALUE);
|
|
||||||
#endif
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/****************************************************************************
|
/****************************************************************************
|
||||||
* Public Functions
|
* Public Functions
|
||||||
****************************************************************************/
|
****************************************************************************/
|
||||||
@ -257,28 +164,5 @@ static void _up_assert(void)
|
|||||||
void up_assert(const char *filename, int lineno)
|
void up_assert(const char *filename, int lineno)
|
||||||
{
|
{
|
||||||
board_autoled_on(LED_ASSERTION);
|
board_autoled_on(LED_ASSERTION);
|
||||||
|
|
||||||
/* Flush any buffered SYSLOG data (from prior to the assertion) */
|
|
||||||
|
|
||||||
syslog_flush();
|
|
||||||
|
|
||||||
#if CONFIG_TASK_NAME_SIZE > 0
|
|
||||||
_alert("Assertion failed at file:%s line: %d task: %s\n",
|
|
||||||
filename, lineno, running_task()->name);
|
|
||||||
#else
|
|
||||||
_alert("Assertion failed at file:%s line: %d\n",
|
|
||||||
filename, lineno);
|
|
||||||
#endif
|
|
||||||
|
|
||||||
x86_64_dumpstate();
|
x86_64_dumpstate();
|
||||||
|
|
||||||
/* Flush any buffered SYSLOG data (from the above) */
|
|
||||||
|
|
||||||
syslog_flush();
|
|
||||||
|
|
||||||
#ifdef CONFIG_BOARD_CRASHDUMP
|
|
||||||
board_crashdump(up_getsp(), this_task(), filename, lineno);
|
|
||||||
#endif
|
|
||||||
|
|
||||||
_up_assert();
|
|
||||||
}
|
}
|
||||||
|
@ -25,63 +25,21 @@
|
|||||||
#include <nuttx/config.h>
|
#include <nuttx/config.h>
|
||||||
|
|
||||||
#include <stdint.h>
|
#include <stdint.h>
|
||||||
#include <stdlib.h>
|
|
||||||
#include <assert.h>
|
|
||||||
#include <debug.h>
|
#include <debug.h>
|
||||||
|
|
||||||
#include <nuttx/irq.h>
|
#include <nuttx/irq.h>
|
||||||
#include <nuttx/arch.h>
|
|
||||||
#include <nuttx/board.h>
|
#include <nuttx/board.h>
|
||||||
#include <nuttx/syslog/syslog.h>
|
#include <nuttx/syslog/syslog.h>
|
||||||
#include <nuttx/usb/usbdev_trace.h>
|
|
||||||
|
|
||||||
#include <arch/board/board.h>
|
#include <arch/board/board.h>
|
||||||
|
|
||||||
#include "sched/sched.h"
|
#include "sched/sched.h"
|
||||||
#include "xtensa.h"
|
#include "xtensa.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
|
* Private Functions
|
||||||
****************************************************************************/
|
****************************************************************************/
|
||||||
|
|
||||||
/****************************************************************************
|
|
||||||
* Name: assert_tracecallback
|
|
||||||
****************************************************************************/
|
|
||||||
|
|
||||||
#ifdef CONFIG_ARCH_USBDUMP
|
|
||||||
static int usbtrace_syslog(const char *fmt, ...)
|
|
||||||
{
|
|
||||||
va_list ap;
|
|
||||||
|
|
||||||
/* Let vsyslog do the real work */
|
|
||||||
|
|
||||||
va_start(ap, fmt);
|
|
||||||
vsyslog(LOG_EMERG, fmt, ap);
|
|
||||||
va_end(ap);
|
|
||||||
return OK;
|
|
||||||
}
|
|
||||||
|
|
||||||
static int assert_tracecallback(struct usbtrace_s *trace, void *arg)
|
|
||||||
{
|
|
||||||
usbtrace_trprintf(usbtrace_syslog, trace->event, trace->value);
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
|
|
||||||
/****************************************************************************
|
/****************************************************************************
|
||||||
* Name: xtensa_assert
|
* Name: xtensa_assert
|
||||||
****************************************************************************/
|
****************************************************************************/
|
||||||
@ -91,52 +49,6 @@ static void xtensa_assert(void)
|
|||||||
/* Dump the processor state */
|
/* Dump the processor state */
|
||||||
|
|
||||||
xtensa_dumpstate();
|
xtensa_dumpstate();
|
||||||
|
|
||||||
#ifdef CONFIG_ARCH_USBDUMP
|
|
||||||
/* Dump USB trace data */
|
|
||||||
|
|
||||||
usbtrace_enumerate(assert_tracecallback, NULL);
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#ifdef CONFIG_BOARD_CRASHDUMP
|
|
||||||
/* Perform board-specific crash dump */
|
|
||||||
|
|
||||||
board_crashdump(up_getsp(), running_task(), filename, lineno);
|
|
||||||
#endif
|
|
||||||
|
|
||||||
/* Flush any buffered SYSLOG data (from the above) */
|
|
||||||
|
|
||||||
syslog_flush();
|
|
||||||
|
|
||||||
/* Are we in an interrupt handler or the idle task? */
|
|
||||||
|
|
||||||
if (CURRENT_REGS || running_task()->flink == NULL)
|
|
||||||
{
|
|
||||||
#if CONFIG_BOARD_RESET_ON_ASSERT >= 1
|
|
||||||
board_reset(CONFIG_BOARD_ASSERT_RESET_VALUE);
|
|
||||||
#endif
|
|
||||||
|
|
||||||
/* Blink the LEDs forever */
|
|
||||||
|
|
||||||
up_irq_save();
|
|
||||||
for (; ; )
|
|
||||||
{
|
|
||||||
#ifdef CONFIG_ARCH_LEDS
|
|
||||||
board_autoled_on(LED_PANIC);
|
|
||||||
up_mdelay(250);
|
|
||||||
board_autoled_off(LED_PANIC);
|
|
||||||
up_mdelay(250);
|
|
||||||
#endif
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
/* Assertions in other contexts only cause the thread to exit */
|
|
||||||
|
|
||||||
#if CONFIG_BOARD_RESET_ON_ASSERT >= 2
|
|
||||||
board_reset(CONFIG_BOARD_ASSERT_RESET_VALUE);
|
|
||||||
#endif
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/****************************************************************************
|
/****************************************************************************
|
||||||
@ -150,19 +62,6 @@ static void xtensa_assert(void)
|
|||||||
void up_assert(const char *filename, int lineno)
|
void up_assert(const char *filename, int lineno)
|
||||||
{
|
{
|
||||||
board_autoled_on(LED_ASSERTION);
|
board_autoled_on(LED_ASSERTION);
|
||||||
|
|
||||||
/* Flush any buffered SYSLOG data (from prior to the assertion) */
|
|
||||||
|
|
||||||
syslog_flush();
|
|
||||||
|
|
||||||
#if CONFIG_TASK_NAME_SIZE > 0
|
|
||||||
_alert("Assertion failed at file:%s line: %d task: %s\n",
|
|
||||||
filename, lineno, running_task()->name);
|
|
||||||
#else
|
|
||||||
_alert("Assertion failed at file:%s line: %d\n",
|
|
||||||
filename, lineno);
|
|
||||||
#endif
|
|
||||||
|
|
||||||
xtensa_assert();
|
xtensa_assert();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -24,102 +24,8 @@
|
|||||||
|
|
||||||
#include <nuttx/config.h>
|
#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 "chip.h"
|
|
||||||
#include "sched/sched.h"
|
|
||||||
#include "z16_internal.h"
|
#include "z16_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(void)
|
|
||||||
{
|
|
||||||
/* Flush any buffered SYSLOG data */
|
|
||||||
|
|
||||||
syslog_flush();
|
|
||||||
|
|
||||||
/* Are we in an interrupt handler or the idle task? */
|
|
||||||
|
|
||||||
if (up_interrupt_context() || running_task()->flink == NULL)
|
|
||||||
{
|
|
||||||
#if CONFIG_BOARD_RESET_ON_ASSERT >= 1
|
|
||||||
board_reset(CONFIG_BOARD_ASSERT_RESET_VALUE);
|
|
||||||
#endif
|
|
||||||
|
|
||||||
up_irq_save();
|
|
||||||
for (; ; )
|
|
||||||
{
|
|
||||||
#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
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/****************************************************************************
|
|
||||||
* Name: assert_tracecallback
|
|
||||||
****************************************************************************/
|
|
||||||
|
|
||||||
#ifdef CONFIG_ARCH_USBDUMP
|
|
||||||
static int usbtrace_syslog(FAR const char *fmt, ...)
|
|
||||||
{
|
|
||||||
va_list ap;
|
|
||||||
|
|
||||||
/* Let vsyslog do the real work */
|
|
||||||
|
|
||||||
va_start(ap, fmt);
|
|
||||||
vsyslog(LOG_EMERG, fmt, ap);
|
|
||||||
va_end(ap);
|
|
||||||
return OK;
|
|
||||||
}
|
|
||||||
|
|
||||||
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
|
* Public Functions
|
||||||
****************************************************************************/
|
****************************************************************************/
|
||||||
@ -131,35 +37,6 @@ static int assert_tracecallback(FAR struct usbtrace_s *trace, FAR void *arg)
|
|||||||
void up_assert(const char *filename, int lineno)
|
void up_assert(const char *filename, int lineno)
|
||||||
{
|
{
|
||||||
board_autoled_on(LED_ASSERTION);
|
board_autoled_on(LED_ASSERTION);
|
||||||
|
|
||||||
/* Flush any buffered SYSLOG data (from prior to the assertion) */
|
|
||||||
|
|
||||||
syslog_flush();
|
|
||||||
|
|
||||||
#if CONFIG_TASK_NAME_SIZE > 0
|
|
||||||
_alert("Assertion failed at file:%s line: %d task: %s\n",
|
|
||||||
filename, lineno, running_task()->name);
|
|
||||||
#else
|
|
||||||
_alert("Assertion failed at file:%s line: %d\n",
|
|
||||||
filename, lineno);
|
|
||||||
#endif
|
|
||||||
|
|
||||||
z16_registerdump();
|
z16_registerdump();
|
||||||
z16_stackdump();
|
z16_stackdump();
|
||||||
|
|
||||||
#ifdef CONFIG_ARCH_USBDUMP
|
|
||||||
/* Dump USB trace data */
|
|
||||||
|
|
||||||
usbtrace_enumerate(assert_tracecallback, NULL);
|
|
||||||
#endif
|
|
||||||
|
|
||||||
/* Flush any buffered SYSLOG data (from the above) */
|
|
||||||
|
|
||||||
syslog_flush();
|
|
||||||
|
|
||||||
#ifdef CONFIG_BOARD_CRASHDUMP
|
|
||||||
board_crashdump(up_getsp(), running_task(), filename, lineno);
|
|
||||||
#endif
|
|
||||||
|
|
||||||
_up_assert();
|
|
||||||
}
|
}
|
||||||
|
@ -24,100 +24,8 @@
|
|||||||
|
|
||||||
#include <nuttx/config.h>
|
#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 "chip.h"
|
|
||||||
#include "sched/sched.h"
|
|
||||||
#include "z80_internal.h"
|
#include "z80_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(void)
|
|
||||||
{
|
|
||||||
/* Flush any buffered SYSLOG data */
|
|
||||||
|
|
||||||
syslog_flush();
|
|
||||||
|
|
||||||
/* Are we in an interrupt handler or the idle task? */
|
|
||||||
|
|
||||||
if (up_interrupt_context() || running_task()->flink == NULL)
|
|
||||||
{
|
|
||||||
#if CONFIG_BOARD_RESET_ON_ASSERT >= 1
|
|
||||||
board_reset(CONFIG_BOARD_ASSERT_RESET_VALUE);
|
|
||||||
#endif
|
|
||||||
|
|
||||||
up_irq_save();
|
|
||||||
for (; ; )
|
|
||||||
{
|
|
||||||
#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
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/****************************************************************************
|
|
||||||
* Name: assert_tracecallback
|
|
||||||
****************************************************************************/
|
|
||||||
|
|
||||||
#ifdef CONFIG_ARCH_USBDUMP
|
|
||||||
static int usbtrace_syslog(FAR const char *fmt, ...)
|
|
||||||
{
|
|
||||||
va_list ap;
|
|
||||||
|
|
||||||
/* Let vsyslog do the real work */
|
|
||||||
|
|
||||||
va_start(ap, fmt);
|
|
||||||
vsyslog(LOG_EMERG, fmt, ap);
|
|
||||||
va_end(ap);
|
|
||||||
return OK;
|
|
||||||
}
|
|
||||||
|
|
||||||
static int assert_tracecallback(struct usbtrace_s *trace, void *arg)
|
|
||||||
{
|
|
||||||
usbtrace_trprintf(FAR usbtrace_syslog, trace->event, FAR trace->value);
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
|
|
||||||
/****************************************************************************
|
/****************************************************************************
|
||||||
* Public Functions
|
* Public Functions
|
||||||
****************************************************************************/
|
****************************************************************************/
|
||||||
@ -128,38 +36,6 @@ static int assert_tracecallback(struct usbtrace_s *trace, void *arg)
|
|||||||
|
|
||||||
void up_assert(const char *filename, int lineno)
|
void up_assert(const char *filename, int lineno)
|
||||||
{
|
{
|
||||||
board_autoled_on(LED_ASSERTION);
|
|
||||||
|
|
||||||
/* Flush any buffered SYSLOG data (from prior to the assertion) */
|
|
||||||
|
|
||||||
syslog_flush();
|
|
||||||
|
|
||||||
#if CONFIG_TASK_NAME_SIZE > 0
|
|
||||||
_alert("Assertion failed at file:%s line: %d task: %s\n",
|
|
||||||
filename, lineno, running_task()->name);
|
|
||||||
#else
|
|
||||||
_alert("Assertion failed at file:%s line: %d\n",
|
|
||||||
filename, lineno);
|
|
||||||
#endif
|
|
||||||
|
|
||||||
Z80_REGISTER_DUMP();
|
Z80_REGISTER_DUMP();
|
||||||
z80_stackdump();
|
z80_stackdump();
|
||||||
|
|
||||||
#ifdef CONFIG_ARCH_USBDUMP
|
|
||||||
/* Dump USB trace data */
|
|
||||||
|
|
||||||
usbtrace_enumerate(assert_tracecallback, NULL);
|
|
||||||
#endif
|
|
||||||
|
|
||||||
/* Flush any buffered SYSLOG data (from the above) */
|
|
||||||
|
|
||||||
syslog_flush();
|
|
||||||
|
|
||||||
#ifdef CONFIG_BOARD_CRASHDUMP
|
|
||||||
/* Execute board-specific crash dump logic */
|
|
||||||
|
|
||||||
board_crashdump(up_getsp(), running_task(), filename, lineno);
|
|
||||||
#endif
|
|
||||||
|
|
||||||
_up_assert();
|
|
||||||
}
|
}
|
||||||
|
87
include/nuttx/panic_notifier.h
Normal file
87
include/nuttx/panic_notifier.h
Normal file
@ -0,0 +1,87 @@
|
|||||||
|
/****************************************************************************
|
||||||
|
* include/nuttx/panic_notifier.h
|
||||||
|
*
|
||||||
|
* 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.
|
||||||
|
*
|
||||||
|
****************************************************************************/
|
||||||
|
|
||||||
|
#ifndef __INCLUDE_NUTTX_PANIC_NOTIFIER_H
|
||||||
|
#define __INCLUDE_NUTTX_PANIC_NOTIFIER_H
|
||||||
|
|
||||||
|
/****************************************************************************
|
||||||
|
* Included Files
|
||||||
|
****************************************************************************/
|
||||||
|
|
||||||
|
#include <nuttx/config.h>
|
||||||
|
#include <nuttx/notifier.h>
|
||||||
|
|
||||||
|
#include <sys/types.h>
|
||||||
|
|
||||||
|
/****************************************************************************
|
||||||
|
* Public Types
|
||||||
|
****************************************************************************/
|
||||||
|
|
||||||
|
enum panic_type_e
|
||||||
|
{
|
||||||
|
PANIC_KERNEL = 0,
|
||||||
|
PANIC_TASK = 1,
|
||||||
|
};
|
||||||
|
|
||||||
|
/****************************************************************************
|
||||||
|
* Public Function
|
||||||
|
****************************************************************************/
|
||||||
|
|
||||||
|
/****************************************************************************
|
||||||
|
* Name: panic_notifier_chain_register
|
||||||
|
*
|
||||||
|
* Description:
|
||||||
|
* Add notifier to the panic notifier chain
|
||||||
|
*
|
||||||
|
* Input Parameters:
|
||||||
|
* nb - New entry in notifier chain
|
||||||
|
*
|
||||||
|
****************************************************************************/
|
||||||
|
|
||||||
|
void panic_notifier_chain_register(FAR struct notifier_block *nb);
|
||||||
|
|
||||||
|
/****************************************************************************
|
||||||
|
* Name: panic_notifier_chain_unregister
|
||||||
|
*
|
||||||
|
* Description:
|
||||||
|
* Remove notifier from the panic notifier chain
|
||||||
|
*
|
||||||
|
* Input Parameters:
|
||||||
|
* nb - Entry to remove from notifier chain
|
||||||
|
*
|
||||||
|
****************************************************************************/
|
||||||
|
|
||||||
|
void panic_notifier_chain_unregister(FAR struct notifier_block *nb);
|
||||||
|
|
||||||
|
/****************************************************************************
|
||||||
|
* Name: panic_notifier_call_chain
|
||||||
|
*
|
||||||
|
* Description:
|
||||||
|
* Call functions in the panic notifier chain.
|
||||||
|
*
|
||||||
|
* Input Parameters:
|
||||||
|
* action - Value passed unmodified to notifier function
|
||||||
|
* data - Pointer passed unmodified to notifier function
|
||||||
|
*
|
||||||
|
****************************************************************************/
|
||||||
|
|
||||||
|
void panic_notifier_call_chain(unsigned long action, FAR void *data);
|
||||||
|
|
||||||
|
#endif /* __INCLUDE_NUTTX_PANIC_NOTIFIER_H */
|
@ -18,7 +18,7 @@
|
|||||||
#
|
#
|
||||||
############################################################################
|
############################################################################
|
||||||
|
|
||||||
CSRCS += assert.c
|
CSRCS += assert.c panic.c
|
||||||
|
|
||||||
# Include init build support
|
# Include init build support
|
||||||
|
|
||||||
|
@ -22,17 +22,159 @@
|
|||||||
* Included Files
|
* Included Files
|
||||||
****************************************************************************/
|
****************************************************************************/
|
||||||
|
|
||||||
|
#include <nuttx/config.h>
|
||||||
|
|
||||||
#include <nuttx/arch.h>
|
#include <nuttx/arch.h>
|
||||||
|
#include <nuttx/board.h>
|
||||||
|
#include <nuttx/irq.h>
|
||||||
|
#include <nuttx/panic_notifier.h>
|
||||||
|
#include <nuttx/usb/usbdev_trace.h>
|
||||||
|
#include <nuttx/syslog/syslog.h>
|
||||||
|
|
||||||
#include <assert.h>
|
#include <assert.h>
|
||||||
|
#include <debug.h>
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
|
|
||||||
|
#include "irq/irq.h"
|
||||||
|
#include "sched/sched.h"
|
||||||
|
|
||||||
|
/****************************************************************************
|
||||||
|
* Pre-processor Definitions
|
||||||
|
****************************************************************************/
|
||||||
|
|
||||||
|
#ifndef CONFIG_BOARD_RESET_ON_ASSERT
|
||||||
|
# define CONFIG_BOARD_RESET_ON_ASSERT 0
|
||||||
|
#endif
|
||||||
|
|
||||||
|
/* USB trace dumping */
|
||||||
|
|
||||||
|
#ifndef CONFIG_USBDEV_TRACE
|
||||||
|
# undef CONFIG_ARCH_USBDUMP
|
||||||
|
#endif
|
||||||
|
|
||||||
|
/****************************************************************************
|
||||||
|
* Private Functions
|
||||||
|
****************************************************************************/
|
||||||
|
|
||||||
|
/****************************************************************************
|
||||||
|
* Name: assert_tracecallback
|
||||||
|
****************************************************************************/
|
||||||
|
|
||||||
|
#ifdef CONFIG_ARCH_USBDUMP
|
||||||
|
static int usbtrace_syslog(FAR const char *fmt, ...)
|
||||||
|
{
|
||||||
|
va_list ap;
|
||||||
|
|
||||||
|
/* Let vsyslog do the real work */
|
||||||
|
|
||||||
|
va_start(ap, fmt);
|
||||||
|
vsyslog(LOG_EMERG, fmt, ap);
|
||||||
|
va_end(ap);
|
||||||
|
return OK;
|
||||||
|
}
|
||||||
|
|
||||||
|
static int assert_tracecallback(FAR struct usbtrace_s *trace, FAR void *arg)
|
||||||
|
{
|
||||||
|
usbtrace_trprintf(usbtrace_syslog, trace->event, trace->value);
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
/****************************************************************************
|
||||||
|
* Name: assert_end
|
||||||
|
****************************************************************************/
|
||||||
|
|
||||||
|
static void assert_end(void)
|
||||||
|
{
|
||||||
|
/* Flush any buffered SYSLOG data */
|
||||||
|
|
||||||
|
syslog_flush();
|
||||||
|
|
||||||
|
/* Are we in an interrupt handler or the idle task? */
|
||||||
|
|
||||||
|
if (up_interrupt_context() || running_task()->flink == NULL)
|
||||||
|
{
|
||||||
|
#if CONFIG_BOARD_RESET_ON_ASSERT >= 1
|
||||||
|
board_reset(CONFIG_BOARD_ASSERT_RESET_VALUE);
|
||||||
|
#endif
|
||||||
|
|
||||||
|
/* Disable interrupts on this CPU */
|
||||||
|
|
||||||
|
up_irq_save();
|
||||||
|
|
||||||
|
#ifdef CONFIG_SMP
|
||||||
|
/* Try (again) to stop activity on other CPUs */
|
||||||
|
|
||||||
|
spin_trylock(&g_cpu_irqlock);
|
||||||
|
#endif
|
||||||
|
|
||||||
|
for (; ; )
|
||||||
|
{
|
||||||
|
up_mdelay(250);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
#if CONFIG_BOARD_RESET_ON_ASSERT >= 2
|
||||||
|
board_reset(CONFIG_BOARD_ASSERT_RESET_VALUE);
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/****************************************************************************
|
/****************************************************************************
|
||||||
* Public Functions
|
* Public Functions
|
||||||
****************************************************************************/
|
****************************************************************************/
|
||||||
|
|
||||||
void _assert(FAR const char *filename, int linenum)
|
void _assert(FAR const char *filename, int linenum)
|
||||||
{
|
{
|
||||||
|
/* Flush any buffered SYSLOG data (from prior to the assertion) */
|
||||||
|
|
||||||
|
syslog_flush();
|
||||||
|
|
||||||
|
#if CONFIG_BOARD_RESET_ON_ASSERT < 2
|
||||||
|
if (!up_interrupt_context() && running_task()->flink != NULL)
|
||||||
|
{
|
||||||
|
panic_notifier_call_chain(PANIC_TASK, NULL);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
#endif
|
||||||
|
{
|
||||||
|
panic_notifier_call_chain(PANIC_KERNEL, NULL);
|
||||||
|
}
|
||||||
|
|
||||||
|
#ifdef CONFIG_SMP
|
||||||
|
# if CONFIG_TASK_NAME_SIZE > 0
|
||||||
|
_alert("Assertion failed CPU%d at file:%s line: %d task: %s\n",
|
||||||
|
up_cpu_index(), filename, linenum, running_task()->name);
|
||||||
|
# else
|
||||||
|
_alert("Assertion failed CPU%d at file:%s line: %d\n",
|
||||||
|
up_cpu_index(), filename, linenum);
|
||||||
|
# endif
|
||||||
|
#else
|
||||||
|
# if CONFIG_TASK_NAME_SIZE > 0
|
||||||
|
_alert("Assertion failed at file:%s line: %d task: %s\n",
|
||||||
|
filename, linenum, running_task()->name);
|
||||||
|
# else
|
||||||
|
_alert("Assertion failed at file:%s line: %d\n",
|
||||||
|
filename, linenum);
|
||||||
|
# endif
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifdef CONFIG_ARCH_USBDUMP
|
||||||
|
/* Dump USB trace data */
|
||||||
|
|
||||||
|
usbtrace_enumerate(assert_tracecallback, NULL);
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifdef CONFIG_BOARD_CRASHDUMP
|
||||||
|
board_crashdump(up_getsp(), running_task(), filename, linenum);
|
||||||
|
#endif
|
||||||
|
|
||||||
|
/* Flush any buffered SYSLOG data (from the above) */
|
||||||
|
|
||||||
|
syslog_flush();
|
||||||
|
|
||||||
up_assert(filename, linenum);
|
up_assert(filename, linenum);
|
||||||
|
assert_end();
|
||||||
exit(EXIT_FAILURE);
|
exit(EXIT_FAILURE);
|
||||||
}
|
}
|
||||||
|
88
sched/misc/panic.c
Normal file
88
sched/misc/panic.c
Normal file
@ -0,0 +1,88 @@
|
|||||||
|
/****************************************************************************
|
||||||
|
* sched/misc/panic.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/arch.h>
|
||||||
|
#include <nuttx/notifier.h>
|
||||||
|
|
||||||
|
#include <sys/types.h>
|
||||||
|
|
||||||
|
/****************************************************************************
|
||||||
|
* Private Data
|
||||||
|
****************************************************************************/
|
||||||
|
|
||||||
|
static ATOMIC_NOTIFIER_HEAD(g_panic_notifier_list);
|
||||||
|
|
||||||
|
/****************************************************************************
|
||||||
|
* Public Functions
|
||||||
|
****************************************************************************/
|
||||||
|
|
||||||
|
/****************************************************************************
|
||||||
|
* Name: panic_notifier_chain_register
|
||||||
|
*
|
||||||
|
* Description:
|
||||||
|
* Add notifier to the panic notifier chain
|
||||||
|
*
|
||||||
|
* Input Parameters:
|
||||||
|
* nb - New entry in notifier chain
|
||||||
|
*
|
||||||
|
****************************************************************************/
|
||||||
|
|
||||||
|
void panic_notifier_chain_register(FAR struct notifier_block *nb)
|
||||||
|
{
|
||||||
|
atomic_notifier_chain_register(&g_panic_notifier_list, nb);
|
||||||
|
}
|
||||||
|
|
||||||
|
/****************************************************************************
|
||||||
|
* Name: panic_notifier_chain_unregister
|
||||||
|
*
|
||||||
|
* Description:
|
||||||
|
* Remove notifier from the panic notifier chain
|
||||||
|
*
|
||||||
|
* Input Parameters:
|
||||||
|
* nb - Entry to remove from notifier chain
|
||||||
|
*
|
||||||
|
****************************************************************************/
|
||||||
|
|
||||||
|
void panic_notifier_chain_unregister(FAR struct notifier_block *nb)
|
||||||
|
{
|
||||||
|
atomic_notifier_chain_unregister(&g_panic_notifier_list, nb);
|
||||||
|
}
|
||||||
|
|
||||||
|
/****************************************************************************
|
||||||
|
* Name: panic_notifier_call_chain
|
||||||
|
*
|
||||||
|
* Description:
|
||||||
|
* Call functions in the panic notifier chain.
|
||||||
|
*
|
||||||
|
* Input Parameters:
|
||||||
|
* action - Value passed unmodified to notifier function
|
||||||
|
* data - Pointer passed unmodified to notifier function
|
||||||
|
*
|
||||||
|
****************************************************************************/
|
||||||
|
|
||||||
|
void panic_notifier_call_chain(unsigned long action, FAR void *data)
|
||||||
|
{
|
||||||
|
atomic_notifier_call_chain(&g_panic_notifier_list, action, data);
|
||||||
|
}
|
||||||
|
|
Loading…
x
Reference in New Issue
Block a user