You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@nuttx.apache.org by xi...@apache.org on 2024/10/13 06:06:01 UTC

(nuttx) 05/13: drivers/note:add the api of sched_note_add

This is an automated email from the ASF dual-hosted git repository.

xiaoxiang pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/nuttx.git

commit 149b1f186e056a3c5f30eea4c9af740355c0b248
Author: zhangwenjian <zh...@xiaomi.com>
AuthorDate: Mon Feb 5 15:54:39 2024 +0800

    drivers/note:add the api of sched_note_add
    
    Signed-off-by: zhangwenjian <zh...@xiaomi.com>
---
 drivers/note/note_driver.c | 51 ++++++++++++++++++++++++++++++++++++++++++++++
 include/nuttx/sched_note.h |  6 ++++++
 2 files changed, 57 insertions(+)

diff --git a/drivers/note/note_driver.c b/drivers/note/note_driver.c
index db15e2ffc9..6b619c470e 100644
--- a/drivers/note/note_driver.c
+++ b/drivers/note/note_driver.c
@@ -564,6 +564,57 @@ static void note_record_taskname(pid_t pid, FAR const char *name)
  * Public Functions
  ****************************************************************************/
 
+#ifdef CONFIG_SCHED_INSTRUMENTATION
+
+/****************************************************************************
+ * Name: sched_note_add
+ *
+ * Description:
+ *   Forward rpmsg note data to individual channels.This process does
+ *   not require filtering
+ *
+ * Input Parameters:
+ *   data - The forward note data.
+ *   len - The len of forward note data.
+ *
+ * Returned Value:
+ *   None
+ *
+ * Assumptions:
+ *   We are within a critical section.
+ *
+ ****************************************************************************/
+
+void sched_note_add(FAR const void *data, size_t len)
+{
+  DEBUGASSERT(data);
+
+  while (len >= sizeof(struct note_common_s))
+    {
+      FAR struct note_common_s *note = (FAR struct note_common_s *)data;
+      size_t notelen = note->nc_length;
+      FAR struct note_driver_s **driver;
+
+      DEBUGASSERT(notelen >= sizeof(struct note_common_s) &&
+                  len >= notelen);
+      for (driver = g_note_drivers; *driver; driver++)
+        {
+          if ((*driver)->ops->add == NULL)
+            {
+              continue;
+            }
+
+          /* Add the note to circular buffer */
+
+          note_add(*driver, note, notelen);
+        }
+
+      data += notelen;
+      len -= notelen;
+    }
+}
+#endif
+
 /****************************************************************************
  * Name: sched_note_*
  *
diff --git a/include/nuttx/sched_note.h b/include/nuttx/sched_note.h
index 2953eed0e3..13ad52cb2d 100644
--- a/include/nuttx/sched_note.h
+++ b/include/nuttx/sched_note.h
@@ -595,6 +595,12 @@ extern "C"
  *
  ****************************************************************************/
 
+#ifdef CONFIG_SCHED_INSTRUMENTATION
+void sched_note_add(FAR const void *note, size_t notelen);
+#else
+#  define sched_note_add(n,l)
+#endif
+
 #ifdef CONFIG_SCHED_INSTRUMENTATION_SWITCH
 void sched_note_start(FAR struct tcb_s *tcb);
 void sched_note_stop(FAR struct tcb_s *tcb);