From dc63dfdca214919f964a5f6fdfb46f6c9d2b91ed Mon Sep 17 00:00:00 2001 From: souldbminersmwc Date: Mon, 6 Apr 2026 16:52:18 -0400 Subject: [PATCH] hocclk: add support for FW <10.0.0 --- Source/hoc-clk/sysmodule/src/board/board.cpp | 10 +++---- Source/hoc-clk/sysmodule/src/board/board.hpp | 2 +- .../sysmodule/src/board/board_volt.cpp | 5 ++-- Source/hoc-clk/sysmodule/src/globals.cpp | 30 +++++++++++++++++++ Source/hoc-clk/sysmodule/src/globals.hpp | 20 +++++++++++++ Source/hoc-clk/sysmodule/src/soctherm.cpp | 5 ++-- 6 files changed, 60 insertions(+), 12 deletions(-) create mode 100644 Source/hoc-clk/sysmodule/src/globals.cpp create mode 100644 Source/hoc-clk/sysmodule/src/globals.hpp diff --git a/Source/hoc-clk/sysmodule/src/board/board.cpp b/Source/hoc-clk/sysmodule/src/board/board.cpp index f30a181e..f53f4514 100644 --- a/Source/hoc-clk/sysmodule/src/board/board.cpp +++ b/Source/hoc-clk/sysmodule/src/board/board.cpp @@ -145,13 +145,13 @@ namespace board { StartMiscThread(pwmCheck, &iCon); - u64 clkVirtAddr, dsiVirtAddr, outsize; + u64 clkVirtAddr, dsiVirtAddr; - rc = svcQueryMemoryMapping(&clkVirtAddr, &outsize, 0x60006000, 0x1000); - ASSERT_RESULT_OK(rc, "svcQueryMemoryMapping (clk)"); + rc = QueryMemoryMapping(&clkVirtAddr, 0x60006000, 0x1000); + ASSERT_RESULT_OK(rc, "QueryMemoryMapping (clk)"); - rc = svcQueryMemoryMapping(&dsiVirtAddr, &outsize, 0x54300000, 0x40000); - ASSERT_RESULT_OK(rc, "svcQueryMemoryMapping (dsi)"); + rc = QueryMemoryMapping(&dsiVirtAddr, 0x54300000, 0x40000); + ASSERT_RESULT_OK(rc, "QueryMemoryMapping (dsi)"); display::DisplayRefreshConfig cfg = {.clkVirtAddr = clkVirtAddr, .dsiVirtAddr = dsiVirtAddr, .isLite = (GetConsoleType() == HocClkConsoleType_Hoag), .isRetroSUPER = integrations::GetRETROSuperStatus()}; display::Initialize(&cfg); diff --git a/Source/hoc-clk/sysmodule/src/board/board.hpp b/Source/hoc-clk/sysmodule/src/board/board.hpp index c83a1b33..478e08b1 100644 --- a/Source/hoc-clk/sysmodule/src/board/board.hpp +++ b/Source/hoc-clk/sysmodule/src/board/board.hpp @@ -35,7 +35,7 @@ #include "board_sensor.hpp" #include "board_volt.hpp" #include "board_profile.hpp" - +#include "../globals.hpp" #define HOSSVC_HAS_CLKRST (hosversionAtLeast(8,0,0)) #define HOSSVC_HAS_TC (hosversionAtLeast(5,0,0)) diff --git a/Source/hoc-clk/sysmodule/src/board/board_volt.cpp b/Source/hoc-clk/sysmodule/src/board/board_volt.cpp index 1a863a12..8707bf0c 100644 --- a/Source/hoc-clk/sysmodule/src/board/board_volt.cpp +++ b/Source/hoc-clk/sysmodule/src/board/board_volt.cpp @@ -87,9 +87,8 @@ namespace board { } void CacheDfllData() { - u64 temp; - Result rc = svcQueryMemoryMapping(&cldvfs, &temp, CLDVFS_REGION_BASE, CLDVFS_REGION_SIZE); - ASSERT_RESULT_OK(rc, "svcQueryMemoryMapping (cldvfs)"); + Result rc = QueryMemoryMapping(&cldvfs, CLDVFS_REGION_BASE, CLDVFS_REGION_SIZE); + ASSERT_RESULT_OK(rc, "QueryMemoryMapping (cldvfs)"); if (GetSocType() == HocClkSocType_Erista) { cachedTune.tune0Low = *reinterpret_cast(cldvfs + CL_DVFS_TUNE0_0); diff --git a/Source/hoc-clk/sysmodule/src/globals.cpp b/Source/hoc-clk/sysmodule/src/globals.cpp new file mode 100644 index 00000000..31715e4e --- /dev/null +++ b/Source/hoc-clk/sysmodule/src/globals.cpp @@ -0,0 +1,30 @@ +/* + * Copyright (c) Souldbminer and Horizon OC Contributors + * + * This program is free software; you can redistribute it and/or modify it + * under the terms and conditions of the GNU General Public License, + * version 2, as published by the Free Software Foundation. + * + * This program is distributed in the hope it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for + * more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + * + */ + +#include "globals.hpp" + +Result QueryMemoryMapping(u64* virtaddr, u64 physaddr, u64 size) { + if(hosversionAtLeast(10,0,0)) + { + u64 out_size; + return svcQueryMemoryMapping(virtaddr, &out_size, physaddr, size); + } + else + { + return svcLegacyQueryIoMapping(virtaddr, physaddr, size); + } +} diff --git a/Source/hoc-clk/sysmodule/src/globals.hpp b/Source/hoc-clk/sysmodule/src/globals.hpp new file mode 100644 index 00000000..6fcd68d4 --- /dev/null +++ b/Source/hoc-clk/sysmodule/src/globals.hpp @@ -0,0 +1,20 @@ +/* + * Copyright (c) Souldbminer and Horizon OC Contributors + * + * This program is free software; you can redistribute it and/or modify it + * under the terms and conditions of the GNU General Public License, + * version 2, as published by the Free Software Foundation. + * + * This program is distributed in the hope it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for + * more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + * + */ + +#include + +Result QueryMemoryMapping(u64* virtaddr, u64 physaddr, u64 size); diff --git a/Source/hoc-clk/sysmodule/src/soctherm.cpp b/Source/hoc-clk/sysmodule/src/soctherm.cpp index b11ad6db..e69321e5 100644 --- a/Source/hoc-clk/sysmodule/src/soctherm.cpp +++ b/Source/hoc-clk/sysmodule/src/soctherm.cpp @@ -25,7 +25,7 @@ #include "soctherm.hpp" #include "board/board.hpp" #include "file_utils.hpp" - +#include "globals.hpp" namespace soctherm { namespace { @@ -440,8 +440,7 @@ namespace soctherm { } Result MapAddress(u64 &va, const u64 &physAddr, const char *name) { - u64 outSize; - Result mapResult = svcQueryMemoryMapping(&va, &outSize, physAddr, 0x1000); + Result mapResult = QueryMemoryMapping(&va, physAddr, 0x1000); if (R_FAILED(mapResult)) { fileUtils::LogLine("[Soctherm] Failed to map %s! %u", name, R_DESCRIPTION(mapResult)); }