- [Sys-clk-OC] (#31) Fix the inverted priority of per-app and global settings in clocks and patches detection

- [loader] Bump to 1.4.0-pre

- [system_settings] Add possible entries introduced in HOS 15.0.0
This commit is contained in:
KazushiM
2022-10-13 01:53:37 +08:00
parent c8587ce441
commit 1d7395da56
14 changed files with 110 additions and 109 deletions

View File

@@ -93,8 +93,9 @@ This project will not be actively maintained or regularly updated along with Atm
- **Modded sys-clk and ReverseNX**(-RT)
- Permanent global clock override
- Expected usage: set maximum DRAM clocks for all games and profiles.
- Global profile
- Designated a dummy title id `0xA111111111111111`.
- Priority: "Temp overrides" > "Application profile" > "Global profile" > "System default".
- Miscellaneous
- Auto CPU Boost: For faster game loading

View File

@@ -1,45 +1,77 @@
[tc]
;Fan Control for IcosaMariko/Hoag
;tskin_rate_table_console = str!"[[-1000000, 36000, 0, 0], [36000, 43000, 51, 51], [43000, 48000, 51, 153], [48000, 56000, 153, 255], [56000, 1000000, 255, 255]]"
;tskin_rate_table_handheld = str!"[[-1000000, 40000, 0, 0], [38000, 43000, 51, 51], [43000, 46000, 51, 102], [46000, 50000, 102, 204], [50000, 520000, 204, 255], [52000, 1000000, 255, 255]]"
; 0xCB20 = 52,000 = 52˚C
holdable_tskin = u32!0xCB20
; tskin table
; https://github.com/masagrator/Status-Monitor-Overlay/blob/master/docs/modes.md#additional-info
; Hoag
; holdable_tskin = u32!0xB98C ; 47.5˚C
; touchable_tskin = u32!0xEA60 ; 60.0˚C
; tskin_pcb_coefficients_console = str!"[7338, 112161]"
; tskin_pcb_coefficients_handheld = str!"[5594, 209601]"
; tskin_rate_table_console = str!"[[-1000000, 40000, 0, 0], [36000, 43000, 51, 51], [43000, 53000, 51, 153], [53000, 58000, 153, 255], [58000, 1000000, 255, 255]]"
; tskin_rate_table_handheld = str!"[[-1000000, 40000, 0, 0], [36000, 43000, 51, 51], [43000, 48000, 51, 102], [48000, 53000, 102, 153], [53000, 1000000, 153, 153], [48000, 1000000, 153, 153]]"
; tskin_soc_coefficients_console = str!"[6728, 129810]"
; tskin_soc_coefficients_handheld = str!"[5235, 199759]"
; IcosaMariko
; holdable_tskin = u32!0xB98C ; 47.5˚C
; touchable_tskin = u32!0xEA60 ; 60.0˚C
; tskin_pcb_coefficients_console = str!"[7338, 112161]"
; tskin_pcb_coefficients_handheld = str!"[6357, 168124]"
; tskin_rate_table_console = str!"[[-1000000, 40000, 0, 0], [36000, 43000, 51, 51], [43000, 53000, 51, 153], [53000, 58000, 153, 255], [58000, 1000000, 255, 255]]"
; tskin_rate_table_handheld = str!"[[-1000000, 40000, 0, 0], [36000, 43000, 51, 51], [43000, 48000, 51, 102], [48000, 53000, 102, 153], [53000, 1000000, 153, 153], [48000, 1000000, 153, 153]]"
; tskin_soc_coefficients_console = str!"[6728, 129810]"
; tskin_soc_coefficients_handheld = str!"[5675, 203453]"
; Aula
; holdable_tskin = u32!0xBCB1 ; 48.3˚C
; touchable_tskin = u32!0xC350 ; 50.0˚C
; tskin_pcb_coefficients_console = str!"[8051, -45213]"
; tskin_pcb_coefficients_handheld = str!"[7176, -33954]"
; tskin_rate_table_console = str!"[[-1000000, 40000, 0, 0], [36000, 43000, 51, 51], [43000, 49000, 51, 128], [49000, 53000, 128, 255], [53000, 1000000, 255, 255]]"
; tskin_rate_table_handheld = str!"[[-1000000, 40000, 0, 0], [36000, 43000, 51, 51], [43000, 44000, 51, 76], [44000, 45000, 76, 128], [45000, 46500, 128, 255], [45500, 1000000, 255, 255]]"
; tskin_soc_coefficients_console = str!"[7831, 57590]"
; tskin_soc_coefficients_handheld = str!"[9029, 4274]"
[psm]
;Charger Parameters
;5V CDP/DCP (BC1.2/QC?) Charger Current Limit
;0x4B0 = 1200mA(Hoag Default)
;0x5DC = 1500mA(IcosaMariko/Aula Default)
;0x7D0 = 2000mA
cdp_dcp_input_current_limit_in_ma = u32!0x5DC
;Enough Power Threshold in mW
;0x9858 = 39,000mW(Default)
;0x4268 = 17,000mW(typical 9V/2A PD chargers)
enough_power_threshold_mw = u32!0x9858 ;39,000mW
; 5V CDP/DCP (BC1.2/QC?) Charger Current Limit
; 0x4B0 = 1200mA(Hoag Default)
; 0x5DC = 1500mA(IcosaMariko/Aula Default)
; 0x7D0 = 2000mA
; cdp_dcp_input_current_limit_in_ma = u32!0x5DC
; Enough Power Threshold in mW
; 0x9858 = 39,000mW(Default)
; 0x4268 = 17,000mW(typical 9V/2A PD chargers)
; enough_power_threshold_mw = u32!0x9858 ;39,000mW
[am.debug]
;Game Recording FPS and Bitrate
;30 or 60
continuous_recording_fps=u32!60
;~7.5Mbps(0x780000 = 7,864,320), default is ~5Mbps, VBR(Variable Bitrate)
continuous_recording_video_bit_rate=u32!0x780000
; Game Recording FPS and Bitrate
continuous_recording_fps = u32!60 ; 30 or 60 FPS
continuous_recording_video_bit_rate = u32!0x780000 ; ~7.5Mbps(0x780000 = 7,864,320), default is ~5Mbps, VBR(Variable Bitrate)
; Other possibly related entries in PlatformConfig
[apm]
; throttling_for_undock_enabled = u8!0x0 ; 1 for IcosaMariko/Aula, 0 for Hoag
[psm]
; boost_threshold_in_milli_volt = u32!0xCF8 ; 3,320mV for IcosaMariko/Hoag, 0 for Aula
; charge_configuration_number = u32!0x0 ; 0 for IcosaMariko/Hoag, 1 for Aula
[nvservices]
; external_display_full_dp_lanes = u8!0x0 ; 0 for IcosaMariko/Hoag, 1 for Aula
;Disable Background service
;For power saving in standby mode
;Delete all the following lines if you use Nintendo Online Services
; Disable Background service
; For power saving in standby mode
; Do NOT add this if online service is in use
[bgtc]
enable_halfawake = u32!0x0
minimum_interval_normal = u32!0x7FFFFFFF
@@ -92,7 +124,7 @@ alarm_pattern_total_repeat_count = u32!0x0
alarm_pattern_with_vibration_repeat_count = u32!0x0
[prepo]
;background_processing = u8!0x0 (shutdown directly when entering sleep mode)
background_processing = u8!0x0 (shutdown directly when entering sleep mode)
transmission_interval_min = u32!0x7FFFFFFF
transmission_retry_interval_min = u32!0x7FFFFFFF
transmission_retry_interval_max = u32!0x7FFFFFFF
@@ -132,47 +164,7 @@ next_available_time_of_unexpected_error = u32!0x7FFFFFFF
[pctl]
intermittent_task_interval_seconds = u32!0x7FFFFFFF
[apm]
throttling_for_undock_enabled = u8!0x0 ;1 for IcosaMariko/Aula, 0 for Hoag
[psm]
;boost_threshold_in_milli_volt = u32!0xCF8 ;3,320mV for IcosaMariko/Hoag, 0 for Aula
;charge_configuration_number = u32!0x0 ;0 for IcosaMariko/Hoag, 1 for Aula
[nvservices]
;external_display_full_dp_lanes = u8!0x0 ;0 for IcosaMariko/Hoag, 1 for Aula
;tskin table
;[tc]-Hoag
;holdable_tskin = u32!0xB98C ;47.5˚C
;touchable_tskin = u32!0xEA60 ;60.0˚C
;tskin_pcb_coefficients_console = str!"[7338, 112161]"
;tskin_pcb_coefficients_handheld = str!"[5594, 209601]"
;tskin_rate_table_console = str!"[[-1000000, 40000, 0, 0], [36000, 43000, 51, 51], [43000, 53000, 51, 153], [53000, 58000, 153, 255], [58000, 1000000, 255, 255]]"
;tskin_rate_table_handheld = str!"[[-1000000, 40000, 0, 0], [36000, 43000, 51, 51], [43000, 48000, 51, 102], [48000, 53000, 102, 153], [53000, 1000000, 153, 153], [48000, 1000000, 153, 153]]"
;tskin_soc_coefficients_console = str!"[6728, 129810]"
;tskin_soc_coefficients_handheld = str!"[5235, 199759]"
;[tc]-IcosaMariko
;holdable_tskin = u32!0xB98C ;47.5˚C
;touchable_tskin = u32!0xEA60 ;60.0˚C
;tskin_pcb_coefficients_console = str!"[7338, 112161]"
;tskin_pcb_coefficients_handheld = str!"[6357, 168124]"
;tskin_rate_table_console = str!"[[-1000000, 40000, 0, 0], [36000, 43000, 51, 51], [43000, 53000, 51, 153], [53000, 58000, 153, 255], [58000, 1000000, 255, 255]]"
;tskin_rate_table_handheld = str!"[[-1000000, 40000, 0, 0], [36000, 43000, 51, 51], [43000, 48000, 51, 102], [48000, 53000, 102, 153], [53000, 1000000, 153, 153], [48000, 1000000, 153, 153]]"
;tskin_soc_coefficients_console = str!"[6728, 129810]"
;tskin_soc_coefficients_handheld = str!"[5675, 203453]"
;[tc]-Aula
;holdable_tskin = u32!0xBCB1 ;48.3˚C
;touchable_tskin = u32!0xC350 ;50.0˚C
;tskin_pcb_coefficients_console = str!"[8051, -45213]"
;tskin_pcb_coefficients_handheld = str!"[7176, -33954]"
;tskin_rate_table_console = str!"[[-1000000, 40000, 0, 0], [36000, 43000, 51, 51], [43000, 49000, 51, 128], [49000, 53000, 128, 255], [53000, 1000000, 255, 255]]"
;tskin_rate_table_handheld = str!"[[-1000000, 40000, 0, 0], [36000, 43000, 51, 51], [43000, 44000, 51, 76], [44000, 45000, 76, 128], [45000, 46500, 128, 255], [45500, 1000000, 255, 255]]"
;tskin_soc_coefficients_console = str!"[7831, 57590]"
;tskin_soc_coefficients_handheld = str!"[9029, 4274]"
[sprofile]
adjust_polling_interval_by_profile = u8!0x0
polling_interval_sec_max = u32!0x7FFFFFFF
polling_interval_sec_min = u32!0x7FFFFFFF

View File

@@ -408,6 +408,15 @@ namespace ams::ldr {
R_SUCCEED();
}
u64 GenerateSecureRandom(u64 max) {
/* Generate a cryptographically random number. */
u64 rand;
crypto::GenerateCryptographicallyRandomBytes(std::addressof(rand), sizeof(rand));
/* Coerce into range. */
return rand % (max + 1);
}
Result DecideAddressSpaceLayout(ProcessInfo *out, svc::CreateProcessParameter *out_param, const NsoHeader *nso_headers, const bool *has_nso, const ArgumentStore::Entry *argument) {
/* Clear output. */
out->args_address = 0;
@@ -477,8 +486,7 @@ namespace ams::ldr {
uintptr_t aslr_slide = 0;
size_t free_size = (aslr_size - total_size);
if (out_param->flags & svc::CreateProcessFlag_EnableAslr) {
/* Nintendo uses MT19937 (not os::GenerateRandomBytes), but we'll just use TinyMT for now. */
aslr_slide = os::GenerateRandomU64(free_size / os::MemoryBlockUnitSize) * os::MemoryBlockUnitSize;
aslr_slide = GenerateSecureRandom(free_size / os::MemoryBlockUnitSize) * os::MemoryBlockUnitSize;
}
/* Set out. */
@@ -536,7 +544,7 @@ namespace ams::ldr {
{
/* Map the process memory. */
void *mapped_memory = nullptr;
R_TRY(os::MapProcessMemory(std::addressof(mapped_memory), process_handle, nso_address, nso_size));
R_TRY(os::MapProcessMemory(std::addressof(mapped_memory), process_handle, nso_address, nso_size, GenerateSecureRandom));
ON_SCOPE_EXIT { os::UnmapProcessMemory(mapped_memory, process_handle, nso_address, nso_size); };
const uintptr_t map_address = reinterpret_cast<uintptr_t>(mapped_memory);
@@ -607,7 +615,7 @@ namespace ams::ldr {
/* Write argument data into memory. */
{
void *map_address = nullptr;
R_TRY(os::MapProcessMemory(std::addressof(map_address), process_info->process_handle, process_info->args_address, process_info->args_size));
R_TRY(os::MapProcessMemory(std::addressof(map_address), process_info->process_handle, process_info->args_address, process_info->args_size, GenerateSecureRandom));
ON_SCOPE_EXIT { os::UnmapProcessMemory(map_address, process_info->process_handle, process_info->args_address, process_info->args_size); };
ProgramArguments *args = static_cast<ProgramArguments *>(map_address);

View File

@@ -1,5 +1,5 @@
namespace ams::ldr::oc {
#include "mtc_empty_table.inc"
#include "mtc_empty_table.inl"
static const volatile CustomizeTable C = {
/* DRAM Timing:
* AUTO_ADJ_MARIKO_SAFE: Auto adjust timings for LPDDR4 ≤3733 Mbps specs, 8Gb density (Default).

View File

@@ -21,7 +21,7 @@
#else
#include <stratosphere.hpp>
#include "ldr_oc_suite.hpp"
#include "ldr_oc_customize.inc"
#include "ldr_oc_customize.inl"
#endif
namespace ams::ldr::oc {

View File

@@ -81,6 +81,7 @@ typedef struct
};
} SysClkTitleProfileList;
#define SYSCLK_GLOBAL_PROFILE_TID 0xA111111111111111
#define SYSCLK_CPU_SAFE_MAX_HZ 1963500000U
#define SYSCLK_GPU_HANDHELD_MAX_HZ 921600000U
#define SYSCLK_GPU_CHARGING_USB_MAX_HZ 1267200000U

View File

@@ -98,19 +98,19 @@ AdvancedSettingsTab::AdvancedSettingsTab()
this->addView(gpuFreqListItem);
this->addView(memFreqListItem);
// Permanent overrides
this->addView(new brls::Header("Permanent overrides"));
// Global profile
this->addView(new brls::Header("Global profile"));
// Add the ListItem to Permanent override
Title* permTitle = (Title*) malloc(sizeof(Title));
permTitle->tid = 0xA111111111111111;
// Add the ListItem to Global profile
Title* globalTitle = (Title*) malloc(sizeof(Title));
globalTitle->tid = SYSCLK_GLOBAL_PROFILE_TID;
brls::ListItem *listItem = new brls::ListItem(std::string("Permanent Override"));
listItem->getClickEvent()->subscribe([permTitle](View* view) {
AppProfileFrame* profileFrame = new AppProfileFrame(permTitle);
brls::ListItem *globalList = new brls::ListItem(std::string("Set global profile"));
globalList->getClickEvent()->subscribe([globalTitle](View* view) {
AppProfileFrame* profileFrame = new AppProfileFrame(globalTitle);
brls::Application::pushView(profileFrame, brls::ViewAnimation::SLIDE_LEFT);
});
this->addView(listItem);
this->addView(globalList);
// Config
// Broken, only accepting single digit

View File

@@ -30,9 +30,9 @@
AppProfileFrame::AppProfileFrame(Title* title) : ThumbnailFrame(), title(title)
{
bool isPermanent = (title->tid == 0xA111111111111111);
bool isGlobal = (title->tid == SYSCLK_GLOBAL_PROFILE_TID);
this->setTitle(isPermanent ? "Edit Permanent Override" : "Edit application profile");
this->setTitle(isGlobal ? "Edit global profile" : "Edit application profile");
this->setIcon(new brls::MaterialIcon("\uE315"));
// Get the freqs
@@ -42,7 +42,7 @@ AppProfileFrame::AppProfileFrame(Title* title) : ThumbnailFrame(), title(title)
errorResult("sysclkIpcGetProfiles", rc);
// Setup the right sidebar
if (!isPermanent)
if (!isGlobal)
{
this->getSidebar()->setThumbnail(title->icon, sizeof(title->icon));
this->getSidebar()->setTitle(std::string(title->name));

View File

@@ -92,7 +92,7 @@ void AppProfileGui::update()
{
BaseMenuGui::update();
if(this->context && this->applicationId != 0xA111111111111111 && this->applicationId != this->context->applicationId)
if(this->context && this->applicationId != SYSCLK_GLOBAL_PROFILE_TID && this->applicationId != this->context->applicationId)
{
tsl::changeTo<FatalGui>(
"Application changed\n\n"

View File

@@ -56,17 +56,17 @@ void MainGui::listUI()
});
this->listElement->addItem(globalOverrideItem);
tsl::elm::ListItem* globalPermanentOverrideItem = new tsl::elm::ListItem("Permanent overrides");
globalPermanentOverrideItem->setClickListener([this](u64 keys) {
tsl::elm::ListItem* globalProfileItem = new tsl::elm::ListItem("Global profile");
globalProfileItem->setClickListener([this](u64 keys) {
if((keys & HidNpadButton_A) == HidNpadButton_A && this->context)
{
AppProfileGui::changeTo(0xA111111111111111);
AppProfileGui::changeTo(SYSCLK_GLOBAL_PROFILE_TID);
return true;
}
return false;
});
this->listElement->addItem(globalPermanentOverrideItem);
this->listElement->addItem(globalProfileItem);
tsl::elm::ListItem* miscItem = new tsl::elm::ListItem("Miscellaneous");
miscItem->setClickListener([this](u64 keys) {

View File

@@ -344,7 +344,7 @@ class MiscGui : public BaseMenuGui
const char* getBatteryStateIcon() {
switch (getBatteryState()) {
case Discharging: return "\u25c0"; // ◀
case ChargingPaused: return "| |";
case ChargingPaused:return "| |";
case SlowCharging: return "\u25b6"; // ▶
case FastCharging: return "\u25b6\u25b6"; // ▶▶
default: return "?";

View File

@@ -112,14 +112,14 @@ uint32_t ClockManager::GetHz(SysClkModule module)
/* Temp override setting */
hz = this->context->overrideFreqs[module];
/* Global setting */
if (!hz)
hz = this->config->GetAutoClockHz(0xA111111111111111, module, this->context->profile);
/* Per-Game setting */
if (!hz)
hz = this->config->GetAutoClockHz(this->context->applicationId, module, this->context->profile);
/* Global profile */
if (!hz)
hz = this->config->GetAutoClockHz(SYSCLK_GLOBAL_PROFILE_TID, module, this->context->profile);
/* Return pre-set hz if ReverseNX is enabled, downclock is disabled when realProfile == Docked */
if (!hz && IsReverseNXModeValid())
{
@@ -312,14 +312,14 @@ void ClockManager::CheckReverseNXTool()
const char asmFileName[] = "_ZN2nn2oe18GetPerformanceModeEv.asm64"; // Checking one asm64 file is enough
char asmFilePath[128];
/* Check global override */
snprintf(asmFilePath, sizeof(asmFilePath), "/SaltySD/patches/%s", asmFileName);
/* Check per-game patch */
snprintf(asmFilePath, sizeof(asmFilePath), "/SaltySD/patches/%016lX/%s", this->context->applicationId, asmFileName);
getMode = ReverseNXFileHandler(asmFilePath);
if (!getMode)
{
/* Check per-game override */
snprintf(asmFilePath, sizeof(asmFilePath), "/SaltySD/patches/%016lX/%s", this->context->applicationId, asmFileName);
/* Check global patch */
snprintf(asmFilePath, sizeof(asmFilePath), "/SaltySD/patches/%s", asmFileName);
getMode = ReverseNXFileHandler(asmFilePath);
}
}

View File

@@ -1,6 +1,6 @@
## `system_settings.ini`
# `system_settings.ini`
### Cherry-pick from below and add them manually.
## Cherry-pick from below and add them manually.
- Fan Control Optimization (Mariko only)
- `[tc]`
@@ -8,9 +8,8 @@
- Replacing stock thermal paste and adding thermal pad on Wi-Fi/BT module(shielded, adjacent to antennas) is recommended.
- Beware that Aula (OLED model) has worse cooling compared to all previous models.
- Disable background services, less heat and power consumption in standby mode
- `;Disable Background service`
- Don't add this if you **use Nintendo Online services**.
- Disable background services (For power saving in standby mode)
- Do NOT add this if online service is in use.
- Game recording and SysDVR streaming @ 60fps with high video bitrate (7.5Mbps)
- `[am.debug]`