From f9f94c999af77a218adb14041a1d4e9d4b38c89f Mon Sep 17 00:00:00 2001 From: Lephenixnoir Date: Sun, 25 Feb 2024 12:46:01 +0100 Subject: [PATCH] ports/fxcg50: provide basic memory status view on SHIFT+VARS --- ports/sh/debug.c | 28 +++++++++++++++++++++++++++- ports/sh/debug.h | 4 ++-- 2 files changed, 29 insertions(+), 3 deletions(-) diff --git a/ports/sh/debug.c b/ports/sh/debug.c index fc3397259..b3a331425 100644 --- a/ports/sh/debug.c +++ b/ports/sh/debug.c @@ -42,9 +42,11 @@ void pe_debug_get_meminfo(struct pe_debug_meminfo *info) #ifdef FXCG50 s = kmalloc_get_gint_stats(kmalloc_get_arena("_uram")); info->_uram_used = s->used_memory; + info->_uram_free = s->free_memory; s = kmalloc_get_gint_stats(kmalloc_get_arena("_ostk")); info->_ostk_used = s->used_memory; + info->_ostk_free = s->free_memory; #endif } @@ -89,7 +91,31 @@ void pe_debug_browse_meminfo(void) #endif #ifdef FXCG50 - dprint(1, 1, C_BLACK, "TODO"); + static char const * const names[] = { + "main", "console", "upy", "prompt", "ui", + "now", /* extra element compared to original enum */ + }; + + dtext(1, 1, C_BLACK, "Memory info"); + dtext(83, 24, C_BLACK, "_uram"); + dtext(170, 24, C_BLACK, "_ostk"); + dline(10, 36, DWIDTH-11, 36, C_BLACK); + + for(int i = 0; i < PE_DEBUG_STARTUP_N + 1; i++) { + int y = 15 * i + 39; + struct pe_debug_meminfo *info = &pe_debug_startup_meminfo[i]; + if(i >= PE_DEBUG_STARTUP_N) { + dline(10, y, DWIDTH-11, y, C_BLACK); + y += 4; + info = &infonow; + } + + dtext(10, y, C_BLACK, names[i]); + dprint(83, y+1, C_BLACK, + "%d,%d", info->_uram_used, info->_uram_free); + dprint(170, y+1, C_BLACK, + "%d,%d", info->_ostk_used, info->_ostk_free); + } #endif dupdate(); diff --git a/ports/sh/debug.h b/ports/sh/debug.h index 6ef629ddf..1c7857833 100644 --- a/ports/sh/debug.h +++ b/ports/sh/debug.h @@ -34,8 +34,8 @@ struct pe_debug_meminfo { #ifdef FXCG50 struct pe_debug_meminfo { - uint32_t _uram_used; - uint32_t _ostk_used; + uint16_t _uram_used, _uram_free; + uint32_t _ostk_used, _ostk_free; }; #endif