Skip to content

Commit 149b1f1

Browse files
zhangwenjian111xiaoxiang781216
authored andcommitted
drivers/note:add the api of sched_note_add
Signed-off-by: zhangwenjian <zhangwenjian@xiaomi.com>
1 parent 7aa1871 commit 149b1f1

File tree

2 files changed

+57
-0
lines changed

2 files changed

+57
-0
lines changed

drivers/note/note_driver.c

Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -564,6 +564,57 @@ static void note_record_taskname(pid_t pid, FAR const char *name)
564564
* Public Functions
565565
****************************************************************************/
566566

567+
#ifdef CONFIG_SCHED_INSTRUMENTATION
568+
569+
/****************************************************************************
570+
* Name: sched_note_add
571+
*
572+
* Description:
573+
* Forward rpmsg note data to individual channels.This process does
574+
* not require filtering
575+
*
576+
* Input Parameters:
577+
* data - The forward note data.
578+
* len - The len of forward note data.
579+
*
580+
* Returned Value:
581+
* None
582+
*
583+
* Assumptions:
584+
* We are within a critical section.
585+
*
586+
****************************************************************************/
587+
588+
void sched_note_add(FAR const void *data, size_t len)
589+
{
590+
DEBUGASSERT(data);
591+
592+
while (len >= sizeof(struct note_common_s))
593+
{
594+
FAR struct note_common_s *note = (FAR struct note_common_s *)data;
595+
size_t notelen = note->nc_length;
596+
FAR struct note_driver_s **driver;
597+
598+
DEBUGASSERT(notelen >= sizeof(struct note_common_s) &&
599+
len >= notelen);
600+
for (driver = g_note_drivers; *driver; driver++)
601+
{
602+
if ((*driver)->ops->add == NULL)
603+
{
604+
continue;
605+
}
606+
607+
/* Add the note to circular buffer */
608+
609+
note_add(*driver, note, notelen);
610+
}
611+
612+
data += notelen;
613+
len -= notelen;
614+
}
615+
}
616+
#endif
617+
567618
/****************************************************************************
568619
* Name: sched_note_*
569620
*

include/nuttx/sched_note.h

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -595,6 +595,12 @@ extern "C"
595595
*
596596
****************************************************************************/
597597

598+
#ifdef CONFIG_SCHED_INSTRUMENTATION
599+
void sched_note_add(FAR const void *note, size_t notelen);
600+
#else
601+
# define sched_note_add(n,l)
602+
#endif
603+
598604
#ifdef CONFIG_SCHED_INSTRUMENTATION_SWITCH
599605
void sched_note_start(FAR struct tcb_s *tcb);
600606
void sched_note_stop(FAR struct tcb_s *tcb);

0 commit comments

Comments
 (0)