From f61bfd56082524e5a307d197cf871f3d37de3b64 Mon Sep 17 00:00:00 2001 From: xuxingliang Date: Sat, 6 Jul 2024 19:38:29 +0800 Subject: [PATCH] drivers/segger: add heap note support Signed-off-by: xuxingliang Signed-off-by: Neo Xu --- drivers/segger/note_sysview.c | 30 ++++++++++++++++++++++++++++++ 1 file changed, 30 insertions(+) diff --git a/drivers/segger/note_sysview.c b/drivers/segger/note_sysview.c index 1b221fff5a..0af3f562dc 100644 --- a/drivers/segger/note_sysview.c +++ b/drivers/segger/note_sysview.c @@ -73,6 +73,11 @@ static void note_sysview_syscall_enter(FAR struct note_driver_s *drv, static void note_sysview_syscall_leave(FAR struct note_driver_s *drv, int nr, uintptr_t result); #endif +#ifdef CONFIG_SCHED_INSTRUMENTATION_HEAP +static void note_sysview_heap(FAR struct note_driver_s *drv, + uint8_t event, FAR void *heap, FAR void *mem, + size_t size); +#endif /**************************************************************************** * Private Data @@ -113,6 +118,9 @@ static const struct note_driver_ops_s g_note_sysview_ops = #ifdef CONFIG_SCHED_INSTRUMENTATION_IRQHANDLER note_sysview_irqhandler, /* irqhandler */ #endif +#ifdef CONFIG_SCHED_INSTRUMENTATION_HEAP + note_sysview_heap, /* heap */ +#endif }; static struct note_sysview_driver_s g_note_sysview_driver = @@ -319,6 +327,28 @@ static void note_sysview_syscall_leave(FAR struct note_driver_s *drv, } #endif +#ifdef CONFIG_SCHED_INSTRUMENTATION_HEAP +static void note_sysview_heap(FAR struct note_driver_s *drv, + uint8_t event, FAR void *heap, FAR void *mem, + size_t size) +{ + switch (event) + { + case NOTE_HEAP_ALLOC: + SEGGER_SYSVIEW_HeapAlloc(heap, mem, size); + break; + case NOTE_HEAP_FREE: + SEGGER_SYSVIEW_HeapFree(heap, mem); + break; + case NOTE_HEAP_ADD: + SEGGER_SYSVIEW_HeapDefine(heap, mem, size, 0); + break; + default: + break; + } +} +#endif + /**************************************************************************** * Public Functions ****************************************************************************/