drivers/note: sched_note support mulit-channel

call callbacks for different channels in sched_note_*
noteram channel is enabled by default

Signed-off-by: yinshengkai <yinshengkai@xiaomi.com>
This commit is contained in:
yinshengkai 2022-12-16 18:31:28 +08:00 committed by Xiang Xiao
parent 659bd495b0
commit 6f66c0ea0b
6 changed files with 835 additions and 319 deletions

View file

@ -10,6 +10,12 @@ menuconfig DRIVER_NOTE
if DRIVER_NOTE
config DRIVER_NOTE_MAX
int "Maximum number of sched_note drivers"
default 1
---help---
sched_note supports the maximum number of drivers
choice
prompt "Note driver selection"
default DRIVER_NOTERAM

File diff suppressed because it is too large Load diff

View file

@ -34,6 +34,7 @@
#include <nuttx/spinlock.h>
#include <nuttx/sched.h>
#include <nuttx/sched_note.h>
#include <nuttx/note/note_driver.h>
#include <nuttx/note/noteram_driver.h>
#include <nuttx/fs/fs.h>
@ -73,6 +74,8 @@ static int noteram_open(FAR struct file *filep);
static ssize_t noteram_read(FAR struct file *filep,
FAR char *buffer, size_t buflen);
static int noteram_ioctl(struct file *filep, int cmd, unsigned long arg);
static void noteram_add(FAR struct note_driver_s *drv,
FAR const void *note, size_t len);
/****************************************************************************
* Private Data
@ -105,10 +108,24 @@ static struct noteram_info_s g_noteram_info =
static struct noteram_taskname_s g_noteram_taskname;
#endif
static const struct note_driver_ops_s g_noteram_ops =
{
noteram_add
};
#ifdef CONFIG_SMP
static volatile spinlock_t g_noteram_lock;
#endif
/****************************************************************************
* Public Data
****************************************************************************/
struct note_driver_s g_noteram_driver =
{
&g_noteram_ops,
};
/****************************************************************************
* Private Functions
****************************************************************************/
@ -769,11 +786,7 @@ static int noteram_ioctl(struct file *filep, int cmd, unsigned long arg)
}
/****************************************************************************
* Public Functions
****************************************************************************/
/****************************************************************************
* Name: sched_note_add
* Name: noteram_add
*
* Description:
* Add the variable length note to the transport layer
@ -790,7 +803,8 @@ static int noteram_ioctl(struct file *filep, int cmd, unsigned long arg)
*
****************************************************************************/
void sched_note_add(FAR const void *note, size_t notelen)
static void noteram_add(FAR struct note_driver_s *drv,
FAR const void *note, size_t notelen)
{
FAR const char *buf = note;
unsigned int head;
@ -877,6 +891,10 @@ void sched_note_add(FAR const void *note, size_t notelen)
up_irq_restore(flags);
}
/****************************************************************************
* Public Functions
****************************************************************************/
/****************************************************************************
* Name: noteram_register
*

View file

@ -25,7 +25,11 @@
* Included Files
****************************************************************************/
#include <nuttx/config.h>
#include <stdarg.h>
#include <stdbool.h>
#include <stddef.h>
#include <nuttx/sched.h>
/****************************************************************************
* Pre-processor Definitions
@ -35,6 +39,70 @@
* Public Types
****************************************************************************/
struct note_driver_s;
struct note_driver_ops_s
{
CODE void (*add)(FAR struct note_driver_s *drv,
FAR const void *note, size_t notelen);
CODE void (*start)(FAR struct note_driver_s *drv, FAR struct tcb_s *tcb);
CODE void (*stop)(FAR struct note_driver_s *drv, FAR struct tcb_s *tcb);
#ifdef CONFIG_SCHED_INSTRUMENTATION_SWITCH
CODE void (*suspend)(FAR struct note_driver_s *drv, FAR struct tcb_s *tcb);
CODE void (*resume)(FAR struct note_driver_s *drv, FAR struct tcb_s *tcb);
# ifdef CONFIG_SMP
CODE void (*cpu_start)(FAR struct note_driver_s *drv,
FAR struct tcb_s *tcb, int cpu);
CODE void (*cpu_started)(FAR struct note_driver_s *drv,
FAR struct tcb_s *tcb);
CODE void (*cpu_pause)(FAR struct note_driver_s *drv,
FAR struct tcb_s *tcb, int cpu);
CODE void (*cpu_paused)(FAR struct note_driver_s *drv,
FAR struct tcb_s *tcb);
CODE void (*cpu_resume)(FAR struct note_driver_s *drv,
FAR struct tcb_s *tcb, int cpu);
CODE void (*cpu_resumed)(FAR struct note_driver_s *drv,
FAR struct tcb_s *tcb);
# endif
#endif
#ifdef CONFIG_SCHED_INSTRUMENTATION_PREEMPTION
CODE void (*premption)(FAR struct note_driver_s *drv,
FAR struct tcb_s *tcb, bool locked);
#endif
#ifdef CONFIG_SCHED_INSTRUMENTATION_CSECTION
CODE void (*csection)(FAR struct note_driver_s *drv,
FAR struct tcb_s *tcb, bool enter);
#endif
#ifdef CONFIG_SCHED_INSTRUMENTATION_SPINLOCKS
CODE void (*spinlock)(FAR struct note_driver_s *drv, FAR struct tcb_s *tcb,
FAR volatile void *spinlock, int type);
#endif
#ifdef CONFIG_SCHED_INSTRUMENTATION_SYSCALL
CODE void (*syscall_enter)(FAR struct note_driver_s *drv, int nr);
CODE void (*syscall_leave)(FAR struct note_driver_s *drv, int nr);
#endif
#ifdef CONFIG_SCHED_INSTRUMENTATION_IRQHANDLER
CODE void (*irqhandler)(FAR struct note_driver_s *drv, int irq,
FAR void *handler, bool enter);
#endif
#ifdef CONFIG_SCHED_INSTRUMENTATION_DUMP
CODE void (*string)(FAR struct note_driver_s *drv, uintptr_t ip,
FAR const char *buf);
CODE void (*dump)(FAR struct note_driver_s *drv, uintptr_t ip,
uint8_t event, FAR const void *buf, size_t len);
CODE void (*vprintf)(FAR struct note_driver_s *drv, uintptr_t ip,
FAR const char *fmt, va_list va) printflike(3, 0);
CODE void (*vbprintf)(FAR struct note_driver_s *drv, uintptr_t ip,
uint8_t event, FAR const char *fmt,
va_list va) printflike(4, 0);
#endif
};
struct note_driver_s
{
FAR const struct note_driver_ops_s *ops;
};
/****************************************************************************
* Public Function Prototypes
****************************************************************************/

View file

@ -83,6 +83,12 @@ struct noteram_get_taskname_s
};
#endif
/****************************************************************************
* Public Data
****************************************************************************/
extern struct note_driver_s g_noteram_driver;
/****************************************************************************
* Public Function Prototypes
****************************************************************************/

View file

@ -557,26 +557,6 @@ void sched_note_bprintf(uintptr_t ip, uint8_t event,
#if defined(__KERNEL__) || defined(CONFIG_BUILD_FLAT)
/****************************************************************************
* Name: sched_note_add
*
* Description:
* Add the variable length note to the transport layer
*
* Input Parameters:
* note - The note buffer
* notelen - The buffer length
*
* Returned Value:
* None
*
* Assumptions:
* We are within a critical section.
*
****************************************************************************/
void sched_note_add(FAR const void *note, size_t notelen);
/****************************************************************************
* Name: sched_note_filter_mode
*