From b417099a4a266fc506cbeb264fdb04b01e88c363 Mon Sep 17 00:00:00 2001 From: souldbminersmwc Date: Sat, 11 Apr 2026 19:00:22 -0400 Subject: [PATCH] hocclk: add RAM bandwidth monitor --- Source/hoc-clk/common/include/hocclk/board.h | 3 ++ Source/hoc-clk/common/include/hocclk/ipc.h | 2 +- .../hoc-clk/overlay/src/ui/gui/about_gui.cpp | 33 +++++++++++++++++-- .../sysmodule/lib/nxExt/include/nxExt/t210.h | 3 ++ Source/hoc-clk/sysmodule/lib/nxExt/src/t210.c | 25 ++++++++++++++ .../sysmodule/src/board/board_load.cpp | 6 ++++ 6 files changed, 69 insertions(+), 3 deletions(-) diff --git a/Source/hoc-clk/common/include/hocclk/board.h b/Source/hoc-clk/common/include/hocclk/board.h index cea5fe6f..519b12cd 100644 --- a/Source/hoc-clk/common/include/hocclk/board.h +++ b/Source/hoc-clk/common/include/hocclk/board.h @@ -109,6 +109,9 @@ typedef enum HocClkPartLoad_CPUMax, HocClkPartLoad_BAT, HocClkPartLoad_FAN, + HocClkPartLoad_RamBWAll, + HocClkPartLoad_RamBWCpu, + HocClkPartLoad_RamBWGpu, HocClkPartLoad_EnumMax } HocClkPartLoad; diff --git a/Source/hoc-clk/common/include/hocclk/ipc.h b/Source/hoc-clk/common/include/hocclk/ipc.h index 8f806b0b..369e1d30 100644 --- a/Source/hoc-clk/common/include/hocclk/ipc.h +++ b/Source/hoc-clk/common/include/hocclk/ipc.h @@ -31,7 +31,7 @@ #include "board.h" #include "clock_manager.h" -#define HOCCLK_IPC_API_VERSION 1 +#define HOCCLK_IPC_API_VERSION 2 #define HOCCLK_IPC_SERVICE_NAME "hoc:clk" enum HocClkIpcCmd diff --git a/Source/hoc-clk/overlay/src/ui/gui/about_gui.cpp b/Source/hoc-clk/overlay/src/ui/gui/about_gui.cpp index 982172ad..bea7039d 100644 --- a/Source/hoc-clk/overlay/src/ui/gui/about_gui.cpp +++ b/Source/hoc-clk/overlay/src/ui/gui/about_gui.cpp @@ -32,6 +32,9 @@ tsl::elm::ListItem* waferCordsItem = NULL; tsl::elm::ListItem* ramVoltItem = NULL; tsl::elm::ListItem* eristaPLLXItem = NULL; tsl::elm::ListItem* dispVoltItem = NULL; +tsl::elm::ListItem* ramBWItemAll = NULL; +tsl::elm::ListItem* ramBWItemCpu = NULL; +tsl::elm::ListItem* ramBWItemGpu = NULL; ImageElement* CatImage = NULL; HideableCategoryHeader* CatHeader = NULL; @@ -50,7 +53,7 @@ AboutGui::~AboutGui() void AboutGui::listUI() { this->listElement->addItem( - new tsl::elm::CategoryHeader("Voltages and Temperatures") + new tsl::elm::CategoryHeader("Voltages and Temps") ); ramVoltItem = @@ -59,7 +62,6 @@ void AboutGui::listUI() if(IsMariko()) { this->listElement->addItem(ramVoltItem); } - dispVoltItem = new tsl::elm::ListItem("Display Voltage:"); this->listElement->addItem(dispVoltItem); @@ -70,6 +72,23 @@ void AboutGui::listUI() this->listElement->addItem(eristaPLLXItem); } + this->listElement->addItem( + new tsl::elm::CategoryHeader("RAM Bandwidth") + ); + + ramBWItemAll = + new tsl::elm::ListItem("Ram BW (All):"); + this->listElement->addItem(ramBWItemAll); + + ramBWItemCpu = + new tsl::elm::ListItem("Ram BW (CPU):"); + this->listElement->addItem(ramBWItemCpu); + + ramBWItemGpu = + new tsl::elm::ListItem("Ram BW (GPU):"); + this->listElement->addItem(ramBWItemGpu); + + this->listElement->addItem( new tsl::elm::CategoryHeader("HW Info") ); @@ -346,4 +365,14 @@ void AboutGui::refresh() sprintf(strings[5], "%u.%u mV", context->voltages[HocClkVoltage_Display] / 1000U, (context->voltages[HocClkVoltage_Display] % 1000U) / 100U); dispVoltItem->setValue(strings[5]); + sprintf(strings[6], "%u MB/s", context->partLoad[HocClkPartLoad_RamBWAll]); + ramBWItemAll->setValue(strings[6]); + + sprintf(strings[7], "%u MB/s", context->partLoad[HocClkPartLoad_RamBWCpu]); + ramBWItemCpu->setValue(strings[7]); + + sprintf(strings[8], "%u MB/s", context->partLoad[HocClkPartLoad_RamBWGpu]); + ramBWItemGpu->setValue(strings[8]); + + } diff --git a/Source/hoc-clk/sysmodule/lib/nxExt/include/nxExt/t210.h b/Source/hoc-clk/sysmodule/lib/nxExt/include/nxExt/t210.h index 9e5b41e0..d19dd384 100644 --- a/Source/hoc-clk/sysmodule/lib/nxExt/include/nxExt/t210.h +++ b/Source/hoc-clk/sysmodule/lib/nxExt/include/nxExt/t210.h @@ -39,6 +39,9 @@ u32 t210ClkMemFreq(void); u32 t210ClkGpuFreq(void); u32 t210EmcLoadAll(void); u32 t210EmcLoadCpu(void); +u32 t210EmcBwAll(void); +u32 t210EmcBwCpu(void); +u32 t210EmcBwGpu(void); #ifdef __cplusplus } diff --git a/Source/hoc-clk/sysmodule/lib/nxExt/src/t210.c b/Source/hoc-clk/sysmodule/lib/nxExt/src/t210.c index 91ce4ec2..2538ca09 100644 --- a/Source/hoc-clk/sysmodule/lib/nxExt/src/t210.c +++ b/Source/hoc-clk/sysmodule/lib/nxExt/src/t210.c @@ -117,6 +117,9 @@ static u32 g_gpu_freq = 0; static u32 g_mem_freq = 0; static u32 g_emc_lall = 0; static u32 g_emc_lcpu = 0; +static u32 g_emc_bw_all = 0; +static u32 g_emc_bw_cpu = 0; +static u32 g_emc_bw_gpu = 0; static u32 _clock_get_dev_freq(u32 id, u32 multiplier) { @@ -256,6 +259,10 @@ static void _clock_update_freqs(void) // Get 1000 -> 100.0. g_emc_lall = (u64)_actmon_dev_get_count_avg(ACTMON_DEV_MC_ALL) * 10 * 100 / (emc_freq * ACTMON_PERIOD_MS); g_emc_lcpu = (u64)_actmon_dev_get_count_avg(ACTMON_DEV_MC_CPU) * 10 * 100 / (emc_freq * ACTMON_PERIOD_MS); + + g_emc_bw_all = (u64)emc_freq * 8 * g_emc_lall / 1000 / 1000; + g_emc_bw_cpu = (u64)emc_freq * 8 * g_emc_lcpu / 1000 / 1000; + g_emc_bw_gpu = g_emc_bw_all > g_emc_bw_cpu ? g_emc_bw_all - g_emc_bw_cpu : 0; } @@ -288,3 +295,21 @@ u32 t210EmcLoadCpu() _clock_update_freqs(); return g_emc_lcpu; } + +u32 t210EmcBwAll() +{ + _clock_update_freqs(); + return g_emc_bw_all; +} + +u32 t210EmcBwCpu() +{ + _clock_update_freqs(); + return g_emc_bw_cpu; +} + +u32 t210EmcBwGpu() +{ + _clock_update_freqs(); + return g_emc_bw_gpu; +} \ No newline at end of file diff --git a/Source/hoc-clk/sysmodule/src/board/board_load.cpp b/Source/hoc-clk/sysmodule/src/board/board_load.cpp index be1bce99..a14e096c 100644 --- a/Source/hoc-clk/sysmodule/src/board/board_load.cpp +++ b/Source/hoc-clk/sysmodule/src/board/board_load.cpp @@ -120,6 +120,12 @@ namespace board { return info.RawBatteryCharge; case HocClkPartLoad_FAN: return GetFanLevel(); + case HocClkPartLoad_RamBWAll: + return t210EmcBwAll(); + case HocClkPartLoad_RamBWCpu: + return t210EmcBwCpu(); + case HocClkPartLoad_RamBWGpu: + return t210EmcBwGpu(); default: ASSERT_ENUM_VALID(HocClkPartLoad, loadSource); }