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 */
}
/* Set SAFE to entry 31 */
PATCH_OFFSET(ptr + 1, _asm::Encode(_asm::op::MovzW, {_asm::field::Rd, _asm::Get(ptr[1], _asm::field::Rd)}, {_asm::field::Imm16, 0x1F}));
/* 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, 32}));
R_SUCCEED();
}
@@ -294,16 +294,16 @@ namespace ams::ldr::hoc::pcv::mariko {
u32 *lut = reinterpret_cast<u32 *>(base + 0x200);
/* Expand the LUT in place */
const u32 last = lut[31];
lut[62] = last;
lut[63] = last;
const u32 top = lut[32];
for (int i = 30; i >= 0; --i) {
for (int i = 31; i >= 0; --i) {
const u32 a = lut[i];
const u32 b = lut[i + 1]; /* dst 2*(i+1) > src i+1 */
lut[2 * i] = a;
lut[2 * i + 1] = (a + b) >> 1;
}
lut[63] = top;
__asm__ volatile("dsb st" ::: "memory");
}
@@ -746,8 +746,8 @@ namespace board {
}
void InitializeCpuLut(bool kip) {
if(kip) {
LutSize = 63; /* Account for patched LUT by KIP */
if (kip) {
LutSize = 64; /* Account for patched LUT by KIP */
}
InitializeLutPtr();
@@ -758,7 +758,7 @@ namespace board {
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)))));
}
}