Skip to content

Commit

Permalink
[BACKPORT] Systemview add kconfig SEGGER_SYSVIEW_PREFIX for co-exista…
Browse files Browse the repository at this point in the history
…nce with other note drivers

apache/nuttx#7809
  • Loading branch information
PetervdPerk-NXP authored and davids5 committed Dec 8, 2022
1 parent b527c6a commit 170673b
Show file tree
Hide file tree
Showing 3 changed files with 69 additions and 14 deletions.
6 changes: 6 additions & 0 deletions drivers/segger/Kconfig
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,12 @@ config SEGGER_SYSVIEW_RAM_BASE
---help---
The lowest RAM address used for IDs

config SEGGER_SYSVIEW_PREFIX
bool "Segger note function prefix"
default ""
---help---
prefix sched_note functions with "sysview_" to call them indirectly

endif

endif
27 changes: 14 additions & 13 deletions drivers/segger/note_sysview.c
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@
#include <nuttx/clock.h>
#include <nuttx/sched.h>
#include <nuttx/sched_note.h>
#include <nuttx/note/note_sysview.h>

#include <SEGGER_RTT.h>
#include <SEGGER_SYSVIEW.h>
Expand Down Expand Up @@ -275,7 +276,7 @@ static inline int sysview_isenabled_syscall(int nr)
*
****************************************************************************/

void sched_note_start(FAR struct tcb_s *tcb)
void PREFIX(sched_note_start)(FAR struct tcb_s *tcb)
{
if (!sysview_isenabled())
{
Expand All @@ -286,7 +287,7 @@ void sched_note_start(FAR struct tcb_s *tcb)
sysview_send_taskinfo(tcb);
}

void sched_note_stop(FAR struct tcb_s *tcb)
void PREFIX(sched_note_stop)(FAR struct tcb_s *tcb)
{
if (!sysview_isenabled())
{
Expand All @@ -297,7 +298,7 @@ void sched_note_stop(FAR struct tcb_s *tcb)
}

#ifdef CONFIG_SCHED_INSTRUMENTATION_SWITCH
void sched_note_suspend(FAR struct tcb_s *tcb)
void PREFIX(sched_note_suspend)(FAR struct tcb_s *tcb)
{
if (!sysview_isenabled())
{
Expand All @@ -310,7 +311,7 @@ void sched_note_suspend(FAR struct tcb_s *tcb)
}
}

void sched_note_resume(FAR struct tcb_s *tcb)
void PREFIX(sched_note_resume)(FAR struct tcb_s *tcb)
{
if (!sysview_isenabled())
{
Expand All @@ -332,7 +333,7 @@ void sched_note_resume(FAR struct tcb_s *tcb)
#endif

#ifdef CONFIG_SCHED_INSTRUMENTATION_IRQHANDLER
void sched_note_irqhandler(int irq, FAR void *handler, bool enter)
void PREFIX(sched_note_irqhandler)(int irq, FAR void *handler, bool enter)
{
if (!sysview_isenabled_irq(irq, enter))
{
Expand Down Expand Up @@ -370,7 +371,7 @@ void sched_note_irqhandler(int irq, FAR void *handler, bool enter)
#endif

#ifdef CONFIG_SCHED_INSTRUMENTATION_SYSCALL
void sched_note_syscall_enter(int nr, int argc, ...)
void PREFIX(sched_note_syscall_enter)(int nr, int argc, ...)
{
nr -= CONFIG_SYS_RESERVED;

Expand Down Expand Up @@ -405,7 +406,7 @@ void sched_note_syscall_enter(int nr, int argc, ...)
SEGGER_SYSVIEW_MarkStart(nr);
}

void sched_note_syscall_leave(int nr, uintptr_t result)
void PREFIX(sched_note_syscall_leave)(int nr, uintptr_t result)
{
nr -= CONFIG_SYS_RESERVED;

Expand Down Expand Up @@ -513,8 +514,8 @@ int sysview_initialize(void)
*
****************************************************************************/

void sched_note_filter_mode(struct note_filter_mode_s *oldm,
struct note_filter_mode_s *newm)
void PREFIX(sched_note_filter_mode)(struct note_filter_mode_s *oldm,
struct note_filter_mode_s *newm)
{
irqstate_t flags;

Expand Down Expand Up @@ -578,8 +579,8 @@ void sched_note_filter_mode(struct note_filter_mode_s *oldm,
****************************************************************************/

#ifdef CONFIG_SCHED_INSTRUMENTATION_IRQHANDLER
void sched_note_filter_irq(struct note_filter_irq_s *oldf,
struct note_filter_irq_s *newf)
void PREFIX(sched_note_filter_irq)(struct note_filter_irq_s *oldf,
struct note_filter_irq_s *newf)
{
irqstate_t flags;

Expand Down Expand Up @@ -624,8 +625,8 @@ void sched_note_filter_irq(struct note_filter_irq_s *oldf,
****************************************************************************/

#ifdef CONFIG_SCHED_INSTRUMENTATION_SYSCALL
void sched_note_filter_syscall(struct note_filter_syscall_s *oldf,
struct note_filter_syscall_s *newf)
void PREFIX(sched_note_filter_syscall)(struct note_filter_syscall_s *oldf,
struct note_filter_syscall_s *newf)
{
irqstate_t flags;

Expand Down
50 changes: 49 additions & 1 deletion include/nuttx/note/note_sysview.h
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,17 @@
****************************************************************************/

#include <nuttx/config.h>
#include <nuttx/sched.h>

/****************************************************************************
* Pre-processor Definitions
****************************************************************************/

#ifdef CONFIG_SEGGER_SYSVIEW_PREFIX
# define PREFIX(fun) sysview ## _ ## fun
#else
# define PREFIX(fun) fun
#endif

/****************************************************************************
* Public Function Prototypes
Expand All @@ -47,6 +58,43 @@

#ifdef CONFIG_SEGGER_SYSVIEW
int sysview_initialize(void);
#endif

# ifdef CONFIG_SEGGER_SYSVIEW_PREFIX

void PREFIX(sched_note_start)(struct tcb_s *tcb);

void PREFIX(sched_note_stop)(struct tcb_s *tcb);

void PREFIX(sched_note_suspend)(struct tcb_s *tcb);

void PREFIX(sched_note_resume)(struct tcb_s *tcb);

# ifdef CONFIG_SCHED_INSTRUMENTATION_IRQHANDLER
void PREFIX(sched_note_irqhandler)(int irq, void *handler, bool enter);
# endif

# ifdef CONFIG_SCHED_INSTRUMENTATION_SYSCALL
void PREFIX(sched_note_syscall_enter)(int nr);
void PREFIX(sched_note_syscall_leave)(int nr, uintptr_t result);
# endif

# ifdef CONFIG_SCHED_INSTRUMENTATION_FILTER
void PREFIX(sched_note_filter_mode)(struct note_filter_mode_s *oldm,
struct note_filter_mode_s *newm);
# endif

# ifdef CONFIG_SCHED_INSTRUMENTATION_IRQHANDLER
void PREFIX(sched_note_filter_irq)(struct note_filter_irq_s *oldf,
struct note_filter_irq_s *newf);
# endif

# ifdef CONFIG_SCHED_INSTRUMENTATION_SYSCALL
void PREFIX(sched_note_filter_syscall)(struct note_filter_syscall_s *oldf,
struct note_filter_syscall_s *newf);
# endif

# endif /* CONFIG_SEGGER_SYSVIEW_PREFIX */

#endif /* CONFIG_SEGGER_SYSVIEW */

#endif /* __INCLUDE_NUTTX_NOTE_NOTE_SYSVIEW_H */

0 comments on commit 170673b

Please sign in to comment.