chirping78 commented on code in PR #15907:
URL: https://github.com/apache/nuttx/pull/15907#discussion_r1977379298


##########
arch/xtensa/src/common/xtensa_debug.c:
##########
@@ -0,0 +1,369 @@
+/****************************************************************************
+ * arch/xtensa/src/common/xtensa_debug.c
+ *
+ * SPDX-License-Identifier: Apache-2.0
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.  The
+ * ASF licenses this file to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance with the
+ * License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+ * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.  See the
+ * License for the specific language governing permissions and limitations
+ * under the License.
+ *
+ ****************************************************************************/
+
+/****************************************************************************
+ * Included Files
+ ****************************************************************************/
+
+#include <nuttx/config.h>
+#include <nuttx/arch.h>
+#include <nuttx/kmalloc.h>
+
+/****************************************************************************
+ * Pre-processor Definitions
+ ****************************************************************************/
+
+#define TRIGGER_TYPE_NONE  0
+#define TRIGGER_TYPE_CODE  1
+#define TRIGGER_TYPE_DATA  2
+
+/****************************************************************************
+ * Private Type
+ ****************************************************************************/
+
+struct xtensa_debug_trigger
+{
+  int trigger_type;
+  int index;
+  int type;
+  void *address;
+  size_t size;
+  debug_callback_t callback;
+  void *arg;
+};
+
+/****************************************************************************
+ * Private Data
+ ****************************************************************************/
+
+static int g_trigger_count = 0;
+static struct xtensa_debug_trigger *g_trigger_map;
+static bool g_debug_initiliazed = false;
+
+/****************************************************************************
+ * Private Functions
+ ****************************************************************************/
+
+static void xtensa_enable_ibreak(int index, uintptr_t address)
+{
+  uint32_t ibreakenable = 0;
+
+  __asm__ __volatile__
+  (
+    "rsr %0, IBREAKENABLE\n"
+    : "=r"(ibreakenable)
+  );
+
+  ibreakenable |= 1 << index;
+
+  if (index == 0)
+    {
+      __asm__ __volatile__
+      (
+        "wsr %0, IBREAKA0\n"
+        "wsr %1, IBREAKENABLE\n"
+        "isync\n"
+        :
+        : "r"(address), "r"(ibreakenable)
+      );
+    }
+  else if (index == 1)

Review Comment:
   only support 2 ibreak. added DEBUGASSERT now.



-- 
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