fix 64 lut off by one

This commit is contained in:
Lightos1 committed 2026-10-09 17:13:08 +02:00
1 parent 6fa9e5ae29
commit 9b1aab4128
2 files changed
+9 -9

No files matched your search

@@ -273,8 +273,8 @@ namespace ams::ldr::hoc::pcv::mariko {
PATCH_OFFSET(prod, nw); /* movz wD,#0x3F */ PATCH_OFFSET(prod, nw); /* movz wD,#0x3F */
} }
/* Set SAFE to entry 31 */ /* Set SAFE to entry 32 */
PATCH_OFFSET(ptr + 1, _asm::Encode(_asm::op::MovzW, {_asm::field::Rd, _asm::Get(ptr[1], _asm::field::Rd)}, {_asm::field::Imm16, 0x1F})); PATCH_OFFSET(ptr + 1, _asm::Encode(_asm::op::MovzW, {_asm::field::Rd, _asm::Get(ptr[1], _asm::field::Rd)}, {_asm::field::Imm16, 32}));
R_SUCCEED(); R_SUCCEED();
} }
@@ -294,16 +294,16 @@ namespace ams::ldr::hoc::pcv::mariko {
u32 *lut = reinterpret_cast<u32 *>(base + 0x200); u32 *lut = reinterpret_cast<u32 *>(base + 0x200);
/* Expand the LUT in place */ /* Expand the LUT in place */
const u32 last = lut[31]; const u32 top = lut[32];
lut[62] = last;
lut[63] = last;
for (int i = 30; i >= 0; --i) { for (int i = 31; i >= 0; --i) {
const u32 a = lut[i]; const u32 a = lut[i];
const u32 b = lut[i + 1]; /* dst 2*(i+1) > src i+1 */ const u32 b = lut[i + 1]; /* dst 2*(i+1) > src i+1 */
lut[2 * i] = a; lut[2 * i] = a;
lut[2 * i + 1] = (a + b) >> 1; lut[2 * i + 1] = (a + b) >> 1;
} }
lut[63] = top;
__asm__ volatile("dsb st" ::: "memory"); __asm__ volatile("dsb st" ::: "memory");
} }
@@ -746,8 +746,8 @@ namespace board {
} }
void InitializeCpuLut(bool kip) { void InitializeCpuLut(bool kip) {
if(kip) { if (kip) {
LutSize = 63; /* Account for patched LUT by KIP */ LutSize = 64; /* Account for patched LUT by KIP */
} }
InitializeLutPtr(); InitializeLutPtr();
@@ -758,7 +758,7 @@ namespace board {
cpuVoltData.initialized = true; cpuVoltData.initialized = true;
for(u32 i = 0; i < LutSize + 1; i++) { for (u32 i = 0; i < LutSize; i++) {
file::utils::LogLine("[dvfs] CPU Real LUT %d: %dmV", i, GetLutVolt(*(u32*)(cldvfs + CL_DVFS_LUT_TABLE_0 + (i * sizeof(u32))))); file::utils::LogLine("[dvfs] CPU Real LUT %d: %dmV", i, GetLutVolt(*(u32*)(cldvfs + CL_DVFS_LUT_TABLE_0 + (i * sizeof(u32)))));
} }
} }