Merge branch 'feature_impl'

This commit is contained in:
hanabbi
2023-07-06 06:13:36 +09:00
8 changed files with 168 additions and 32 deletions

View File

@@ -91,6 +91,8 @@ volatile CustomizeTable C = {
.marikoGpuUV = 0,
.marikoEmcDvbShift = 0,
.ramTimingPresetOne = 0,
.ramTimingPresetTwo = 0,
@@ -105,6 +107,8 @@ volatile CustomizeTable C = {
.ramTimingPresetSeven = 0,
.marikoGpuVoltArray = {610, 610, 610, 610, 610, 610, 610, 610, 610, 610, 620, 640, 675, 710, 735, 785, 815},
/* Advanced Settings:
* - Erista CPU DVFS Table:
*/

View File

@@ -52,9 +52,10 @@ typedef struct CustomizeTable {
u32 marikoCpuMaxVolt;
u32 marikoEmcMaxClock;
u32 marikoEmcVddqVolt;
//advanced config
u32 marikoCpuUV;
u32 marikoGpuUV;
// advanced config
u32 marikoEmcDvbShift;
u32 ramTimingPresetOne;
u32 ramTimingPresetTwo;
u32 ramTimingPresetThree;
@@ -62,6 +63,8 @@ typedef struct CustomizeTable {
u32 ramTimingPresetFive;
u32 ramTimingPresetSix;
u32 ramTimingPresetSeven;
//
u32 marikoGpuVoltArray[17];
CustomizeCpuDvfsTable eristaCpuDvfsTable;
CustomizeCpuDvfsTable marikoCpuDvfsTable;
CustomizeCpuDvfsTable marikoCpuDvfsTableSLT;

View File

@@ -107,6 +107,7 @@ void SafetyCheck() {
break;
default:
marikoGpuDvfsMaxFreq = static_cast<u32>(GetDvfsTableLastEntry(C.marikoGpuDvfsTable)->freq);
break;
}
sValidator validators[] = {
@@ -115,7 +116,7 @@ void SafetyCheck() {
{ C.eristaCpuMaxVolt, 1100, 1300 },
{ C.eristaEmcMaxClock, 1600'000, 2131'200 },
{ C.marikoCpuMaxVolt, 1100, 1300 },
{ C.marikoEmcMaxClock, 1600'000, 2400'000 },
{ C.marikoEmcMaxClock, 1600'000, 2800'000 },
{ C.marikoEmcVddqVolt, 550'000, 650'000 },
{ eristaCpuDvfsMaxFreq, 1785'000, 3000'000 },
{ marikoCpuDvfsMaxFreq, 1785'000, 3000'000 },

View File

@@ -203,7 +203,11 @@ Result CpuFreqCvbTable(u32* ptr) {
cvb_entry_t* entry = static_cast<cvb_entry_t *>(cpu_cvb_table_head);
for (size_t i = 0; i < customize_entry_count; i++) {
if (entry->freq >= cpu_freq_threshold) {
PATCH_OFFSET(&(entry->cvb_pll_param.c0), cpu_max_volt * 1000);
if (isMariko) {
PATCH_OFFSET(&(entry->cvb_pll_param.c0), cpu_max_volt * 1000);
} else {
PATCH_OFFSET(&(entry->cvb_dfll_param.c0), cpu_max_volt * 1000);
}
}
entry++;
}
@@ -215,7 +219,25 @@ Result CpuFreqCvbTable(u32* ptr) {
template<bool isMariko>
Result GpuFreqCvbTable(u32* ptr) {
cvb_entry_t* default_table = isMariko ? (cvb_entry_t *)(&mariko::GpuCvbTableDefault) : (cvb_entry_t *)(&erista::GpuCvbTableDefault);
cvb_entry_t* customize_table = const_cast<cvb_entry_t *>(isMariko ? (C.marikoGpuUV ? (C.marikoGpuUV == 2 ? C.marikoGpuDvfsTableHiOPT : C.marikoGpuDvfsTableSLT) : C.marikoGpuDvfsTable) : C.eristaGpuDvfsTable);
cvb_entry_t* customize_table;
if (isMariko) {
switch (C.marikoGpuUV) {
case 0:
customize_table = const_cast<cvb_entry_t *>(C.marikoGpuDvfsTable);
break;
case 1:
customize_table = const_cast<cvb_entry_t *>(C.marikoGpuDvfsTableSLT);
break;
case 2:
customize_table = const_cast<cvb_entry_t *>(C.marikoGpuDvfsTableHiOPT);
break;
default:
customize_table = const_cast<cvb_entry_t *>(C.marikoGpuDvfsTable);
break;
}
} else {
customize_table = const_cast<cvb_entry_t *>(C.eristaGpuDvfsTable);
}
size_t default_entry_count = GetDvfsTableEntryCount(default_table);
size_t default_table_size = default_entry_count * sizeof(cvb_entry_t);
@@ -230,6 +252,20 @@ Result GpuFreqCvbTable(u32* ptr) {
std::memcpy(gpu_cvb_table_head, (void*)customize_table, customize_table_size);
// Patch GPU volt
if (isMariko && C.marikoGpuUV == 3) {
cvb_entry_t* entry = static_cast<cvb_entry_t *>(gpu_cvb_table_head);
for (size_t i = 0; i < customize_entry_count; i++) {
PATCH_OFFSET(&(entry->cvb_pll_param.c0), C.marikoGpuVoltArray[i] * 1000);
PATCH_OFFSET(&(entry->cvb_pll_param.c1), 0);
PATCH_OFFSET(&(entry->cvb_pll_param.c2), 0);
PATCH_OFFSET(&(entry->cvb_pll_param.c3), 0);
PATCH_OFFSET(&(entry->cvb_pll_param.c4), 0);
PATCH_OFFSET(&(entry->cvb_pll_param.c5), 0);
entry++;
}
}
R_SUCCEED();
};

View File

@@ -73,7 +73,9 @@ Result GpuFreqMaxAsm(u32* ptr32) {
case 2:
max_clock = GetDvfsTableLastEntry(C.marikoGpuDvfsTableHiOPT)->freq;
break;
default: max_clock = GetDvfsTableLastEntry(C.marikoGpuDvfsTable)->freq;
default:
max_clock = GetDvfsTableLastEntry(C.marikoGpuDvfsTable)->freq;
break;
}
u32 asm_patch[2] = {
asm_set_rd(asm_set_imm16(asm_pattern[0], max_clock), rd),
@@ -369,10 +371,10 @@ Result MemFreqDvbTable(u32* ptr) {
emc_dvb_dvfs_table_t oc_table = { 2131200, { 725, 700, 675, } };
std::memcpy(new_start, &oc_table, sizeof(emc_dvb_dvfs_table_t));
} else if (C.marikoEmcMaxClock < 2665600){
emc_dvb_dvfs_table_t oc_table = { 2400000, { 750, 725, 700, } };
emc_dvb_dvfs_table_t oc_table = { 2400000, { 750+25*C.marikoEmcDvbShift, 725+25*C.marikoEmcDvbShift, 700+25*C.marikoEmcDvbShift, } };
std::memcpy(new_start, &oc_table, sizeof(emc_dvb_dvfs_table_t));
} else {
emc_dvb_dvfs_table_t oc_table = { 2665600, { 775, 750, 725, } };
emc_dvb_dvfs_table_t oc_table = { 2665600, { 775+25*C.marikoEmcDvbShift, 750+25*C.marikoEmcDvbShift, 725+25*C.marikoEmcDvbShift, } };
std::memcpy(new_start, &oc_table, sizeof(emc_dvb_dvfs_table_t));
}
new_start->freq = C.marikoEmcMaxClock;

View File

@@ -58,6 +58,7 @@ typedef struct CustTable {
u32 marikoEmcVddqVolt;
u32 marikoCpuUV;
u32 marikoGpuUV;
u32 marikoEmcDvbShift;
u32 ramTimingPresetOne;
u32 ramTimingPresetTwo;
u32 ramTimingPresetThree;
@@ -65,6 +66,7 @@ typedef struct CustTable {
u32 ramTimingPresetFive;
u32 ramTimingPresetSix;
u32 ramTimingPresetSeven;
u32 marikoGpuVoltArray[17];
CustomizeCpuDvfsTable eristaCpuDvfsTable;
CustomizeCpuDvfsTable marikoCpuDvfsTable;
CustomizeCpuDvfsTable marikoCpuDvfsTableSLT;

View File

@@ -401,6 +401,7 @@
</label>
<div id="config-list-basic"></div>
<div id="config-list-advanced"></div>
<div id="config-list-gpu"></div>
</form>
</body>
<footer>

View File

@@ -1,5 +1,4 @@
/* Config: Cust */
const CUST_REV = 4;
const CUST_REV_ADV = 8;
enum CustPlatform {
@@ -156,6 +155,53 @@ class AdvEntry extends CustEntry {
}
}
class GpuEntry extends CustEntry {
constructor(
public id: string,
public name: string,
public platform: CustPlatform = CustPlatform.Mariko,
public size: number = 4,
public desc: string[] = ["range: 610 ≤ x ≤ 1000"],
public defval: number = 610,
minmax: [number, number] = [610, 1000],
public step: number = 5,
public zeroable: boolean = false) {
super(id, name, platform, size, desc, defval, minmax, step, zeroable);
};
createElement() {
let input = this.getInputElement();
if (!input) {
let grid = document.createElement("div");
grid.classList.add("grid", "cust-element");
// Label and input
input = document.createElement("input");
input.min = String(this.zeroable ? 0 : this.min);
input.max = String(this.max);
input.id = this.id;
input.type = "number";
input.step = String(this.step);
let label = document.createElement("label");
label.setAttribute("for", this.id);
label.innerHTML = this.name;
label.appendChild(input);
grid.appendChild(label);
// Description in blockquote style
let desc = document.createElement("blockquote");
desc.innerHTML = "<ul>" + this.desc.map(i => `<li>${i}</li>`).join('') + "</ul>";
desc.setAttribute("for", this.id);
grid.appendChild(desc);
document.getElementById("config-list-gpu")!.appendChild(grid);
new ErrorToolTip(this.id).addChangeListener();
}
input.value = String(this.value);
}
}
var CustTable: Array<CustEntry> = [
new CustEntry(
"mtcConf",
@@ -237,9 +283,10 @@ var CustTable: Array<CustEntry> = [
4,
["Values should be ≥ 1600000, and divided evenly by 3200.",
"Recommended Clocks: 1862400, 2131200, 2400000 (JEDEC)",
"Clocks above 2400Mhz might not boot, or work correctly",
"<b>WARNING:</b> RAM overclock could be UNSTABLE if timing parameters are not suitable for your DRAM."],
1996_800,
[1600_000, 2400_000],
[1600_000, 2502_400],
3200,
),
new CustEntry(
@@ -280,14 +327,28 @@ var CustTable: Array<CustEntry> = [
"Can hang your console, or crash games",
"<b>0</b> : Default Table",
"<b>1</b> : Undervolt Level 1 (SLT: Aggressive)",
"<b>2</b> : Undervolt Level 2 (HiOPT: Drastic)"],
"<b>2</b> : Undervolt Level 2 (HiOPT: Drastic)",
"<b>3</b> : Custom static GPU Table (Use Gpu Configuation below)"],
0,
[0,2],
[0,3],
1,
),
];
var AdvTable: Array<AdvEntry> = [
new AdvEntry(
"marikoEmcDvbShift",
"Step up Mariko EMC DVB Table",
CustPlatform.Mariko,
4,
["Might help with stability at higher memory clock",
"<b>0</b> : Don't Adjust",
"<b>1</b> : Shift one step",
"<b>2</b> : Shift two step"],
0,
[0,2],
1,
),
new AdvEntry(
"ramTimingPresetOne",
"Primary RAM Timing Preset",
@@ -421,6 +482,26 @@ var AdvTable: Array<AdvEntry> = [
)
];
var GpuTable: Array<GpuEntry> = [
new GpuEntry("0", "76.8",),
new GpuEntry("1", "153.6",),
new GpuEntry("2", "230.4",),
new GpuEntry("3", "307.2",),
new GpuEntry("4", "384.0",),
new GpuEntry("5", "460.8",),
new GpuEntry("6", "537.6",),
new GpuEntry("7", "614.4",),
new GpuEntry("8", "691.2",),
new GpuEntry("9", "768.0",),
new GpuEntry("10", "844.8",),
new GpuEntry("11", "921.6",),
new GpuEntry("12", "998.4",),
new GpuEntry("13", "1075.2",),
new GpuEntry("14", "1152.0",),
new GpuEntry("15", "1228.8",),
new GpuEntry("16", "1267.2",),
];
class ErrorToolTip {
element: HTMLElement | null;
@@ -467,21 +548,17 @@ class CustStorage {
readonly key = "last_saved";
updateFromTable() {
CustTable.forEach(i => {
let update = (i => {
i.updateValueFromElement();
if (!i.validate()) {
i.getInputElement()?.focus();
throw new Error(`Invalid ${i.name}`);
}
});
AdvTable.forEach(i => {
i.updateValueFromElement();
if (!i.validate()) {
i.getInputElement()?.focus();
throw new Error(`Invalid ${i.name}`);
}
});
CustTable.forEach(update);
AdvTable.forEach(update);
GpuTable.forEach(update);
this.storage = {};
let kv = Object.fromEntries(CustTable.map((i) => [i.id, i.value]));
Object.keys(kv)
@@ -516,6 +593,13 @@ class CustStorage {
}
i.setElementValue();
});
GpuTable.forEach(i => {
if (!i.validate()) {
i.getInputElement()?.focus();
throw new Error(`Invalid ${i.name}`);
}
i.setElementValue();
});
}
save() {
@@ -580,7 +664,7 @@ class Cust {
save() {
this.storage.updateFromTable();
let lambda = (i => {
let saveValue = (i => {
if (!i.offset) {
i.getInputElement()?.focus();
throw new Error(`Failed to get offset for ${i.name}`);
@@ -592,10 +676,9 @@ class Cust {
}
mapper.set(i.offset, i.value!);
});
CustTable.forEach(lambda);
if (this.rev == CUST_REV_ADV) {
AdvTable.forEach(lambda);
}
CustTable.forEach(saveValue);
AdvTable.forEach(saveValue);
GpuTable.forEach(saveValue);
this.storage.save();
@@ -633,7 +716,12 @@ class Cust {
advanced.innerHTML = "Advanced configuration";
document.getElementById("config-list-advanced")?.appendChild(advanced);
let gpu = document.createElement("p");
gpu.innerHTML = "Gpu Volt configuration";
document.getElementById("config-list-gpu")?.appendChild(gpu);
AdvTable.forEach(i => i.createElement());
GpuTable.forEach(i => i.createElement());
let default_btn = document.getElementById("load_default")!;
default_btn.removeAttribute("disabled");
@@ -678,13 +766,13 @@ class Cust {
let offset = this.beginOffset + this.magicLen;
let revLen = 4;
this.rev = this.mapper[revLen].get(offset);
if (this.rev != CUST_REV && this.rev != CUST_REV_ADV) {
throw new Error(`Unsupported custRev, expected: ${CUST_REV} or ${CUST_REV_ADV}, got ${this.rev}`);
if (this.rev != CUST_REV_ADV) {
throw new Error(`Unsupported custRev, expected: ${CUST_REV_ADV}, got ${this.rev}`);
}
offset += revLen;
document.getElementById("cust_rev")!.innerHTML = `Cust v${this.rev} is loaded.`;
let lambda = (i => {
let loadValue = (i => {
i.offset = offset;
let mapper = this.mapper[i.size];
if (!mapper) {
@@ -696,10 +784,9 @@ class Cust {
i.validate();
});
CustTable.forEach(lambda);
if (this.rev == CUST_REV_ADV) {
AdvTable.forEach(lambda);
}
CustTable.forEach(loadValue);
AdvTable.forEach(loadValue);
GpuTable.forEach(loadValue);
}
load(buffer: ArrayBuffer) {