verbosity patch rework

This commit is contained in:
souldbminersmwc committed 2026-08-13 19:11:00 -04:00
1 parent 62127a4383
commit 539cd58464
5 files changed
+16 -7

No files matched your search

@@ -132,7 +132,7 @@ volatile CustomizeTable C = {
AUTO /* 153 */, AUTO /* 153 */,
AUTO /* 192 */, AUTO /* 192 */,
AUTO /* 230 */, AUTO /* 230 */,
AUTO /* 269 */, AUTO /* 268 */,
AUTO /* 307 */, AUTO /* 307 */,
AUTO /* 346 */, AUTO /* 346 */,
AUTO /* 384 */, AUTO /* 384 */,
@@ -219,6 +219,16 @@ volatile CustomizeTable C = {
.fineTune_t6_tRTW = 0, .fineTune_t6_tRTW = 0,
.fineTune_t7_tWTR = 0, .fineTune_t7_tWTR = 0,
/* Debugging options */
/* PCV Log Verbosity */
/* -1: Nothing */
/* 0: Basic logging */
/* 1: More advanced logging */
/* 2: All logging excluding MMIO */
/* 3: All logging including MMIO */
.pcvLogVerbosity = 2,
/* You shouldn't have to anything past here. */ /* You shouldn't have to anything past here. */
.eristaCpuDvfsTable = { .eristaCpuDvfsTable = {
{ 204000, { 721094, }, { } }, { 204000, { 721094, }, { } },
@@ -132,7 +132,9 @@ struct CustomizeTable {
u32 fineTune_t6_tRTW; u32 fineTune_t6_tRTW;
u32 fineTune_t7_tWTR; u32 fineTune_t7_tWTR;
u32 reserved[60]; u32 pcvLogVerbosity;
u32 reserved[58];
CustomizeCpuDvfsTable eristaCpuDvfsTable; CustomizeCpuDvfsTable eristaCpuDvfsTable;
CustomizeCpuDvfsTable eristaCpuDvfsTableSLT; CustomizeCpuDvfsTable eristaCpuDvfsTableSLT;
@@ -32,7 +32,6 @@
#endif #endif
#define HOC_PCV_NVLOG_PATCH 1 #define HOC_PCV_NVLOG_PATCH 1
#define HOC_PCV_FORCE_VERBOSITY 1
#include "customize.hpp" #include "customize.hpp"
#include "oc_log.hpp" #include "oc_log.hpp"
@@ -142,7 +142,6 @@ namespace ams::ldr::hoc::pcv::mariko {
/* Redirect the call sites as patching the actual function causes crash */ /* Redirect the call sites as patching the actual function causes crash */
const uintptr_t roStart = g_pcv_cave + g_pcv_cave_size; /* module .rodata start */ const uintptr_t roStart = g_pcv_cave + g_pcv_cave_size; /* module .rodata start */
size_t patchedSites = 0; size_t patchedSites = 0;
if (HOC_PCV_NVLOG_PATCH) {
for (u32 *p = nsoStart; reinterpret_cast<uintptr_t>(p + 1) <= textEnd; ++p) { for (u32 *p = nsoStart; reinterpret_cast<uintptr_t>(p + 1) <= textEnd; ++p) {
if (!AsmIsBl(*p)) { if (!AsmIsBl(*p)) {
continue; continue;
@@ -165,7 +164,6 @@ namespace ams::ldr::hoc::pcv::mariko {
++patchedSites; ++patchedSites;
} }
} }
}
LOGGING("NvLogRedirect: stub@+%lx vsnprintf@+%lx helper@+%lx instr=%zu sites=%zu", LOGGING("NvLogRedirect: stub@+%lx vsnprintf@+%lx helper@+%lx instr=%zu sites=%zu",
nvlog_addr - mapped_nso, vsnprintf_addr - mapped_nso, helper - mapped_nso, n, patchedSites); nvlog_addr - mapped_nso, vsnprintf_addr - mapped_nso, helper - mapped_nso, n, patchedSites);
@@ -221,7 +219,7 @@ namespace ams::ldr::hoc::pcv::mariko {
#if HOC_UART_LOG #if HOC_UART_LOG
/* Force GetEffectiveVerbosityLevel to return a non-zero level so all NvLog runs. */ /* Force GetEffectiveVerbosityLevel to return a non-zero level so all NvLog runs. */
Result ForceVerbosity(u32 *ptr) { Result ForceVerbosity(u32 *ptr) {
PATCH_OFFSET(&ptr[0], AsmMakeMovzW(0, static_cast<u16>(HOC_PCV_FORCE_VERBOSITY))); /* movz w0,#level */ PATCH_OFFSET(&ptr[0], AsmMakeMovzW(0, static_cast<u16>(C.pcvLogVerbosity))); /* movz w0,#level */
PATCH_OFFSET(&ptr[1], RetIns); /* ret */ PATCH_OFFSET(&ptr[1], RetIns); /* ret */
R_SUCCEED(); R_SUCCEED();
} }
@@ -151,7 +151,7 @@ namespace ams::ldr::hoc::pcv::mariko {
} }
inline bool ForceVerbosityPatternFn(u32 *ptr) { inline bool ForceVerbosityPatternFn(u32 *ptr) {
if (HOC_PCV_FORCE_VERBOSITY == 0 || g_pcv_cave == 0) { if (g_pcv_cave == 0) {
return false; return false;
} }
if (reinterpret_cast<uintptr_t>(ptr + 11) > g_pcv_cave) { /* .text only */ if (reinterpret_cast<uintptr_t>(ptr + 11) > g_pcv_cave) { /* .text only */