From 2c49a045169fb126cb700e5f09bb16f670bf1a32 Mon Sep 17 00:00:00 2001 From: TuxSH <1922548+TuxSH@users.noreply.github.com> Date: Fri, 2 Aug 2024 17:22:53 +0200 Subject: [PATCH] rosalina: add battery info in debug info --- sysmodules/rosalina/include/menu.h | 2 ++ sysmodules/rosalina/source/menu.c | 5 +++++ sysmodules/rosalina/source/menus.c | 12 ++++++++---- 3 files changed, 15 insertions(+), 4 deletions(-) diff --git a/sysmodules/rosalina/include/menu.h b/sysmodules/rosalina/include/menu.h index 89b794742..0bba97b50 100644 --- a/sysmodules/rosalina/include/menu.h +++ b/sysmodules/rosalina/include/menu.h @@ -68,6 +68,8 @@ typedef struct Menu { extern u32 menuCombo; extern bool isHidInitialized; extern u32 mcuFwVersion; +extern u8 mcuInfoTable[9]; +extern bool mcuInfoTableRead; // From main.c extern bool isN3DS; diff --git a/sysmodules/rosalina/source/menu.c b/sysmodules/rosalina/source/menu.c index 99fe21414..b2b24aa40 100644 --- a/sysmodules/rosalina/source/menu.c +++ b/sysmodules/rosalina/source/menu.c @@ -43,6 +43,8 @@ u32 menuCombo = 0; bool isHidInitialized = false; u32 mcuFwVersion = 0; +u8 mcuInfoTable[9] = {0}; +bool mcuInfoTableRead = false; // libctru redefinition: @@ -226,6 +228,9 @@ static Result menuUpdateMcuInfo(void) mcuFwVersion = SYSTEM_VERSION(major - 0x10, minor, 0); } + if (!mcuInfoTableRead) + mcuInfoTableRead = R_SUCCEEDED(MCUHWC_ReadRegister(0x7F, mcuInfoTable, sizeof(mcuInfoTable))); + svcCloseHandle(*mcuHwcHandlePtr); return res; } diff --git a/sysmodules/rosalina/source/menus.c b/sysmodules/rosalina/source/menus.c index 9b741707f..766a0d8c7 100644 --- a/sysmodules/rosalina/source/menus.c +++ b/sysmodules/rosalina/source/menus.c @@ -125,14 +125,18 @@ void RosalinaMenu_ShowDebugInfo(void) 10, posY, COLOR_WHITE, "Kernel version: %lu.%lu-%lu\n", GET_VERSION_MAJOR(kernelVer), GET_VERSION_MINOR(kernelVer), GET_VERSION_REVISION(kernelVer) ); - if (mcuFwVersion != 0) + if (mcuFwVersion != 0 && mcuInfoTableRead) { posY = Draw_DrawFormattedString( - 10, posY, COLOR_WHITE, "MCU FW version: %lu.%lu\n", - GET_VERSION_MAJOR(mcuFwVersion), GET_VERSION_MINOR(mcuFwVersion) + 10, posY, COLOR_WHITE, "MCU FW version: %lu.%lu (PMIC vendor: %hhu)\n", + GET_VERSION_MAJOR(mcuFwVersion), GET_VERSION_MINOR(mcuFwVersion), + mcuInfoTable[1] + ); + posY = Draw_DrawFormattedString( + 10, posY, COLOR_WHITE, "Battery: vendor: %hhu gauge IC ver.: %hhu.%hhu RCOMP: %hhu\n", + mcuInfoTable[2], mcuInfoTable[3], mcuInfoTable[4], mcuInfoTable[4] ); } - if (R_SUCCEEDED(FSUSER_GetSdmcSpeedInfo(&speedInfo))) { u32 clkDiv = 1 << (1 + (speedInfo.sdClkCtrl & 0xFF));