xiaoxiang781216 commented on code in PR #7841: URL: https://github.com/apache/nuttx/pull/7841#discussion_r1049146020
########## drivers/note/Kconfig: ########## @@ -10,6 +10,13 @@ menuconfig DRIVER_NOTE if DRIVER_NOTE +config DRIVER_NOTE_MAX + int "Maximum number of sched_note drivers" + default 5 + depends on SCHED_INSTRUMENTATION Review Comment: remove, already done at line 8 ########## include/nuttx/note/note_driver.h: ########## @@ -35,6 +38,66 @@ * Public Types ****************************************************************************/ +struct note_driver_s; + +struct note_driver_ops_s +{ + 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 + CODE void (*write)(FAR struct note_driver_s *drv, + FAR const void *note, size_t notelen); +}; + +struct note_driver_s +{ + FAR const struct note_driver_ops_s *ops; + FAR void *priv; +}; + +/**************************************************************************** + * Public Data + ****************************************************************************/ + +extern struct note_driver_s g_noteram_driver; Review Comment: move include/nuttx/note/noteram_driver.h ########## drivers/note/Kconfig: ########## @@ -10,6 +10,13 @@ menuconfig DRIVER_NOTE if DRIVER_NOTE +config DRIVER_NOTE_MAX + int "Maximum number of sched_note drivers" + default 5 + depends on SCHED_INSTRUMENTATION + ---help--- + sched_note supports the maximum number of drivers + choice Review Comment: remove choice, we can support more than one note device now. remove DRIVER_NOTEARCH too since arch code can register the custom note driver freely. with the new design, SCHED_INSTRUMENTATION_EXTERNAL doesn't need anymore, let's remove it. ########## drivers/note/sched_note.c: ########## @@ -91,6 +140,12 @@ static unsigned int g_note_disabled_irq_nest[CONFIG_SMP_NCPUS]; #endif #endif +FAR struct note_driver_s + *g_note_drivers_list[CONFIG_DRIVER_NOTE_MAX] = Review Comment: merge into one line ########## include/nuttx/note/note_driver.h: ########## @@ -35,6 +38,66 @@ * Public Types ****************************************************************************/ +struct note_driver_s; + +struct note_driver_ops_s +{ + 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 + CODE void (*write)(FAR struct note_driver_s *drv, + FAR const void *note, size_t notelen); +}; + +struct note_driver_s +{ + FAR const struct note_driver_ops_s *ops; + FAR void *priv; Review Comment: remove priv, let's note driver embed note_driver_s directly ########## drivers/note/note_driver.c: ########## @@ -91,6 +140,12 @@ static unsigned int g_note_disabled_irq_nest[CONFIG_SMP_NCPUS]; #endif #endif +FAR struct note_driver_s Review Comment: merge into one line ########## drivers/note/note_driver.c: ########## @@ -91,6 +140,12 @@ static unsigned int g_note_disabled_irq_nest[CONFIG_SMP_NCPUS]; #endif #endif +FAR struct note_driver_s + *g_note_drivers_list[CONFIG_DRIVER_NOTE_MAX] = Review Comment: g_note_drivers -- 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