hoc-sys: fix config error
finally
This commit is contained in:
@@ -496,14 +496,9 @@ void Board::FetchHardwareInfos()
|
||||
|
||||
switch(sku)
|
||||
{
|
||||
case 2:
|
||||
case 3:
|
||||
case 5:
|
||||
case 2 ... 5:
|
||||
g_socType = SysClkSocType_Mariko;
|
||||
break;
|
||||
case 4:
|
||||
g_socType = SysClkSocType_MarikoLite;
|
||||
break;
|
||||
default:
|
||||
g_socType = SysClkSocType_Erista;
|
||||
}
|
||||
|
||||
@@ -15,7 +15,8 @@
|
||||
*
|
||||
*/
|
||||
|
||||
/* --------------------------------------------------------------------------
|
||||
/*
|
||||
* --------------------------------------------------------------------------
|
||||
* "THE BEER-WARE LICENSE" (Revision 42):
|
||||
* <p-sam@d3vs.net>, <natinusala@gmail.com>, <m4x@m4xw.net>
|
||||
* wrote this file. As long as you retain this notice you can do whatever you
|
||||
@@ -24,7 +25,6 @@
|
||||
* --------------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
|
||||
#include "config.h"
|
||||
#include <sys/types.h>
|
||||
#include <sys/stat.h>
|
||||
@@ -197,17 +197,24 @@ bool Config::SetProfiles(std::uint64_t tid, SysClkTitleProfileList* profiles, bo
|
||||
std::scoped_lock lock{this->configMutex};
|
||||
uint8_t numProfiles = 0;
|
||||
|
||||
// String pointer array passed to ini
|
||||
char* iniKeys[SysClkProfile_EnumMax * SysClkModule_EnumMax + 1];
|
||||
char* iniValues[SysClkProfile_EnumMax * SysClkModule_EnumMax + 1];
|
||||
|
||||
// Char arrays to build strings
|
||||
char keysStr[SysClkProfile_EnumMax * SysClkModule_EnumMax * 0x40];
|
||||
char valuesStr[SysClkProfile_EnumMax * SysClkModule_EnumMax * 0x10];
|
||||
char section[17] = {0};
|
||||
snprintf(section, sizeof(section), "%016lX", tid);
|
||||
|
||||
// Use dynamic allocation
|
||||
std::vector<std::string> keys;
|
||||
std::vector<std::string> values;
|
||||
keys.reserve(SysClkProfile_EnumMax * SysClkModule_EnumMax);
|
||||
values.reserve(SysClkProfile_EnumMax * SysClkModule_EnumMax);
|
||||
|
||||
// Iteration pointers
|
||||
char** ik = &iniKeys[0];
|
||||
char** iv = &iniValues[0];
|
||||
char* sk = &keysStr[0];
|
||||
char* sv = &valuesStr[0];
|
||||
std::uint32_t* mhz = &profiles->mhz[0];
|
||||
|
||||
snprintf(section, sizeof(section), "%016lX", tid);
|
||||
|
||||
for(unsigned int profile = 0; profile < SysClkProfile_EnumMax; profile++)
|
||||
{
|
||||
for(unsigned int module = 0; module < SysClkModule_EnumMax; module++)
|
||||
@@ -216,38 +223,34 @@ bool Config::SetProfiles(std::uint64_t tid, SysClkTitleProfileList* profiles, bo
|
||||
{
|
||||
numProfiles++;
|
||||
|
||||
// Build key and value strings
|
||||
std::string key = std::string(Board::GetProfileName((SysClkProfile)profile, false)) +
|
||||
"_" +
|
||||
Board::GetModuleName((SysClkModule)module, false);
|
||||
std::string value = std::to_string(*mhz);
|
||||
// Put key and value as string
|
||||
snprintf(sk, 0x40, "%s_%s", Board::GetProfileName((SysClkProfile)profile, false), Board::GetModuleName((SysClkModule)module, false));
|
||||
snprintf(sv, 0x10, "%d", *mhz);
|
||||
|
||||
keys.push_back(key);
|
||||
values.push_back(value);
|
||||
// Add them to the ini key/value str arrays
|
||||
*ik = sk;
|
||||
*iv = sv;
|
||||
ik++;
|
||||
iv++;
|
||||
|
||||
// We used those chars, get to the next ones
|
||||
sk += 0x40;
|
||||
sv += 0x10;
|
||||
}
|
||||
|
||||
mhz++;
|
||||
}
|
||||
}
|
||||
|
||||
// Build pointer arrays
|
||||
std::vector<const char*> keyPointers;
|
||||
std::vector<const char*> valuePointers;
|
||||
keyPointers.reserve(keys.size() + 1);
|
||||
valuePointers.reserve(values.size() + 1);
|
||||
*ik = NULL;
|
||||
*iv = NULL;
|
||||
|
||||
for(size_t i = 0; i < keys.size(); i++) {
|
||||
keyPointers.push_back(keys[i].c_str());
|
||||
valuePointers.push_back(values[i].c_str());
|
||||
}
|
||||
keyPointers.push_back(NULL);
|
||||
valuePointers.push_back(NULL);
|
||||
|
||||
if(!ini_putsection(section, keyPointers.data(), valuePointers.data(), this->path.c_str()))
|
||||
if(!ini_putsection(section, (const char**)iniKeys, (const char**)iniValues, this->path.c_str()))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
// Only actually apply changes in memory after a successful save
|
||||
// Only actually apply changes in memory after a succesful save
|
||||
if(immediate)
|
||||
{
|
||||
mhz = &profiles->mhz[0];
|
||||
@@ -428,43 +431,46 @@ bool Config::SetConfigValues(SysClkConfigValueList* configValues, bool immediate
|
||||
{
|
||||
std::scoped_lock lock{this->configMutex};
|
||||
|
||||
// Use dynamic allocation instead of fixed stack buffers
|
||||
std::vector<const char*> iniKeys;
|
||||
std::vector<std::string> iniValues;
|
||||
|
||||
iniKeys.reserve(SysClkConfigValue_EnumMax + 1);
|
||||
iniValues.reserve(SysClkConfigValue_EnumMax);
|
||||
// String pointer array passed to ini
|
||||
const char* iniKeys[SysClkConfigValue_EnumMax + 1];
|
||||
char* iniValues[SysClkConfigValue_EnumMax + 1];
|
||||
|
||||
// char arrays to build strings
|
||||
char valuesStr[SysClkConfigValue_EnumMax * 0x20];
|
||||
|
||||
// Iteration pointers
|
||||
char* sv = &valuesStr[0];
|
||||
const char** ik = &iniKeys[0];
|
||||
char** iv = &iniValues[0];
|
||||
|
||||
for(unsigned int kval = 0; kval < SysClkConfigValue_EnumMax; kval++)
|
||||
{
|
||||
if(!sysclkValidConfigValue((SysClkConfigValue)kval, configValues->values[kval]) ||
|
||||
configValues->values[kval] == sysclkDefaultConfigValue((SysClkConfigValue)kval))
|
||||
if(!sysclkValidConfigValue((SysClkConfigValue)kval, configValues->values[kval]) || configValues->values[kval] == sysclkDefaultConfigValue((SysClkConfigValue)kval))
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
// Store as string in vector (automatically managed memory)
|
||||
iniValues.push_back(std::to_string(configValues->values[kval]));
|
||||
iniKeys.push_back(sysclkFormatConfigValue((SysClkConfigValue)kval, false));
|
||||
// Put key and value as string
|
||||
// And add them to the ini key/value str arrays
|
||||
snprintf(sv, 0x20, "%ld", configValues->values[kval]);
|
||||
*ik = sysclkFormatConfigValue((SysClkConfigValue)kval, false);
|
||||
*iv = sv;
|
||||
|
||||
// We used those chars, get to the next ones
|
||||
sv += 0x20;
|
||||
ik++;
|
||||
iv++;
|
||||
}
|
||||
|
||||
// Null terminate
|
||||
iniKeys.push_back(NULL);
|
||||
*ik = NULL;
|
||||
*iv = NULL;
|
||||
|
||||
// Build pointer array for ini function
|
||||
std::vector<const char*> valuePointers;
|
||||
valuePointers.reserve(iniValues.size() + 1);
|
||||
for(const auto& val : iniValues) {
|
||||
valuePointers.push_back(val.c_str());
|
||||
}
|
||||
valuePointers.push_back(NULL);
|
||||
|
||||
if(!ini_putsection(CONFIG_VAL_SECTION, iniKeys.data(), valuePointers.data(), this->path.c_str()))
|
||||
if(!ini_putsection(CONFIG_VAL_SECTION, (const char**)iniKeys, (const char**)iniValues, this->path.c_str()))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
// Only actually apply changes in memory after a successful save
|
||||
// Only actually apply changes in memory after a succesful save
|
||||
if(immediate)
|
||||
{
|
||||
for(unsigned int kval = 0; kval < SysClkConfigValue_EnumMax; kval++)
|
||||
|
||||
@@ -48,6 +48,9 @@ const std::array<u32, 10> tRTW_values = {0, 1, 2, 3, 4, 5, 6, 7, 8, 9}; /*
|
||||
const std::array<double, 10> tWTR_values = {10, 9, 8, 7, 6, 5, 4, 3, 2, 1};
|
||||
const std::array<u32, 7> tREFpb_values = {488, 732, 488 * 2, 488 * 3, 488 * 4, 488 * 6, 488 * 8}; /* TODO: Figure out if it's actually 8 and if this is even right. */
|
||||
|
||||
struct SOC_THERM_THERMCTL_LEVEL0_GROUP_CPU_0 {
|
||||
|
||||
};
|
||||
|
||||
class EMCpatcher
|
||||
{
|
||||
|
||||
@@ -269,7 +269,7 @@ Result IpcService::SetProfiles(SysClkIpc_SetProfiles_Args* args)
|
||||
|
||||
if(!config->SetProfiles(args->tid, &profiles, true))
|
||||
{
|
||||
return SYSCLK_ERROR(ConfigSaveFailed);
|
||||
return SYSCLK_ERROR(ConfigSaveFailed); // 0x584
|
||||
}
|
||||
|
||||
return 0;
|
||||
|
||||
@@ -38,7 +38,9 @@
|
||||
#include "clock_manager.h"
|
||||
#include "ipc_service.h"
|
||||
#include "fancontrol.h"
|
||||
#define INNER_HEAP_SIZE 0x30000
|
||||
#include "emc_patcher.h"
|
||||
|
||||
#define INNER_HEAP_SIZE 0xFFFFF
|
||||
|
||||
extern "C"
|
||||
{
|
||||
@@ -66,12 +68,22 @@ extern "C"
|
||||
|
||||
void __appInit(void)
|
||||
{
|
||||
Result rc;
|
||||
if (R_FAILED(smInitialize()))
|
||||
{
|
||||
fatalThrow(MAKERESULT(Module_Libnx, LibnxError_InitFail_SM));
|
||||
}
|
||||
|
||||
Result rc = setsysInitialize();
|
||||
rc = fanInitialize();
|
||||
if (R_FAILED(rc))
|
||||
diagAbortWithResult(MAKERESULT(Module_Libnx, LibnxError_ShouldNotHappen));
|
||||
|
||||
rc = i2cInitialize();
|
||||
if (R_FAILED(rc))
|
||||
diagAbortWithResult(MAKERESULT(Module_Libnx, LibnxError_ShouldNotHappen));
|
||||
|
||||
|
||||
rc = setsysInitialize();
|
||||
if (R_SUCCEEDED(rc))
|
||||
{
|
||||
SetSysFirmwareVersion fw;
|
||||
@@ -81,13 +93,6 @@ extern "C"
|
||||
setsysExit();
|
||||
}
|
||||
|
||||
rc = fanInitialize();
|
||||
if (R_FAILED(rc))
|
||||
diagAbortWithResult(MAKERESULT(Module_Libnx, LibnxError_ShouldNotHappen));
|
||||
|
||||
rc = i2cInitialize();
|
||||
if (R_FAILED(rc))
|
||||
diagAbortWithResult(MAKERESULT(Module_Libnx, LibnxError_ShouldNotHappen));
|
||||
}
|
||||
|
||||
void __appExit(void)
|
||||
@@ -96,7 +101,8 @@ extern "C"
|
||||
fanExit();
|
||||
i2cExit();
|
||||
fsExit();
|
||||
fsdevUnmountAll();
|
||||
fsdevUnmountAll();
|
||||
smExit();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -118,8 +124,8 @@ int main(int argc, char** argv)
|
||||
|
||||
ClockManager* clockMgr = new ClockManager();
|
||||
IpcService* ipcSrv = new IpcService(clockMgr);
|
||||
|
||||
FileUtils::LogLine("Ready");
|
||||
|
||||
FileUtils::LogLine("Starting Horizon OC Sysmodule");
|
||||
|
||||
clockMgr->SetRunning(true);
|
||||
clockMgr->GetConfig()->SetEnabled(true);
|
||||
|
||||
Reference in New Issue
Block a user