XinStellaris commented on code in PR #7808:
URL: https://github.com/apache/nuttx/pull/7808#discussion_r1044304282


##########
sched/misc/assert.c:
##########
@@ -22,17 +22,150 @@
  * Included Files
  ****************************************************************************/
 
+#include <nuttx/config.h>
+
 #include <nuttx/arch.h>
+#include <nuttx/board.h>
+#include <nuttx/irq.h>
+#include <nuttx/misc/panic.h>
+#include <nuttx/usb/usbdev_trace.h>
+#include <nuttx/syslog/syslog.h>
 
 #include <assert.h>
+#include <debug.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: riscv_assert
+ ****************************************************************************/
+
+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
  ****************************************************************************/
 
 void _assert(FAR const char *filename, int linenum)
 {
+  panic_notifier_call_chain(0, NULL);

Review Comment:
   I added some parameter enum, please review



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscr...@nuttx.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org

Reply via email to