more c++ification
This commit is contained in:
1 parent
018325747d
commit
062b52c607
17 files changed
+74
-51
No files matched your search
@@ -97,8 +97,8 @@ namespace board {
|
||||
rc = pscPmModuleGetRequest(&s_pscModule, &state, &flags);
|
||||
if (R_SUCCEEDED(rc)) {
|
||||
if (state == PscPmState_ReadyAwaken) {
|
||||
i2c::wdt::ResetWdtEnableState();
|
||||
i2c::wdt::Pet();
|
||||
HocI2c::wdt::ResetWdtEnableState();
|
||||
HocI2c::wdt::Pet();
|
||||
|
||||
if(board::GetSocType() == HocClkSocType_Mariko &&
|
||||
file::config::GetConfigValue(HocClkConfigValue_CPUDVFSMode) == CPUDVFSMode_Modify) {
|
||||
@@ -117,7 +117,7 @@ namespace board {
|
||||
|
||||
s_isAwake = true;
|
||||
} else if (state == PscPmState_ReadySleep) {
|
||||
i2c::wdt::Disarm();
|
||||
HocI2c::wdt::Disarm();
|
||||
|
||||
ResetToStockMem();
|
||||
ResetToStockCpu();
|
||||
@@ -127,7 +127,7 @@ namespace board {
|
||||
|
||||
s_isAwake = false;
|
||||
} else if (state == PscPmState_ReadyShutdown) {
|
||||
i2c::wdt::Disarm();
|
||||
HocI2c::wdt::Disarm();
|
||||
|
||||
ResetToStockMem();
|
||||
ResetToStockCpu();
|
||||
@@ -326,7 +326,7 @@ namespace board {
|
||||
pscPmModuleClose(&s_pscModule);
|
||||
pscmExit();
|
||||
|
||||
i2c::wdt::Disarm();
|
||||
HocI2c::wdt::Disarm();
|
||||
}
|
||||
|
||||
HocClkSocType GetSocType() {
|
||||
|
||||
@@ -44,6 +44,8 @@
|
||||
#include <lockable_mutex.h>
|
||||
#include <switch.hpp>
|
||||
|
||||
using namespace nx;
|
||||
|
||||
namespace board {
|
||||
static u32 currentInjectedHz = 0;
|
||||
static u32 gMarikoGm20bCutoff = 1228800000;
|
||||
@@ -119,7 +121,7 @@ namespace board {
|
||||
|
||||
/* Voltage bug workaround. */
|
||||
if (module == HocClkModule_CPU) {
|
||||
nx::svc::SleepThread(300'000);
|
||||
svc::SleepThread(300'000);
|
||||
ClkrstSetHz(session, pcvHz);
|
||||
}
|
||||
|
||||
@@ -128,7 +130,7 @@ namespace board {
|
||||
PcvSetHz(GetPcvModule(module), pcvHz);
|
||||
|
||||
if (module == HocClkModule_CPU) {
|
||||
nx::svc::SleepThread(300'000);
|
||||
svc::SleepThread(300'000);
|
||||
PcvSetHz(GetPcvModule(module), pcvHz);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -43,6 +43,7 @@
|
||||
#include <ipc_server.h>
|
||||
#include <lockable_mutex.h>
|
||||
|
||||
using namespace nx;
|
||||
|
||||
namespace board {
|
||||
|
||||
@@ -75,7 +76,7 @@ namespace board {
|
||||
gpu_load_array[i++ % gpu_samples_average] = temp;
|
||||
gpuLoad = std::accumulate(&gpu_load_array[0], &gpu_load_array[gpu_samples_average], 0) / gpu_samples_average;
|
||||
}
|
||||
nx::svc::SleepThread(16'666'000); // wait a bit (this is the perfect amount of time to keep the reading accurate)
|
||||
svc::SleepThread(16'666'000); // wait a bit (this is the perfect amount of time to keep the reading accurate)
|
||||
} while (true);
|
||||
}
|
||||
|
||||
|
||||
@@ -30,6 +30,8 @@
|
||||
#include <hocclk.h>
|
||||
#include <switch.hpp>
|
||||
|
||||
using namespace nx;
|
||||
|
||||
namespace board {
|
||||
|
||||
Thread miscThread;
|
||||
@@ -52,7 +54,7 @@ namespace board {
|
||||
}
|
||||
|
||||
fanLevel = static_cast<u8>(rotationDuty);
|
||||
nx::svc::SleepThread(300'000'000);
|
||||
svc::SleepThread(300'000'000);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -31,6 +31,8 @@
|
||||
#include "board_freq.hpp"
|
||||
#include "board_volt.hpp"
|
||||
|
||||
using namespace nx;
|
||||
|
||||
namespace board {
|
||||
|
||||
GpuVoltData voltData = {};
|
||||
@@ -657,7 +659,7 @@ namespace board {
|
||||
constexpr u32 KNOWN_GOOD_WAR_FREQUENCY = 1'785'000'000;
|
||||
u32 hz = board::GetHz(HocClkModule_CPU);
|
||||
board::SetHz(HocClkModule_CPU, KNOWN_GOOD_WAR_FREQUENCY);
|
||||
nx::svc::SleepThread(5'000'000);
|
||||
svc::SleepThread(5'000'000);
|
||||
board::SetHz(HocClkModule_CPU, hz);
|
||||
}
|
||||
|
||||
|
||||
@@ -21,6 +21,7 @@
|
||||
#include "common.hpp"
|
||||
#include <switch.hpp>
|
||||
|
||||
using namespace nx;
|
||||
// I *think* HOS changes this in some ways, so look into it more
|
||||
|
||||
namespace display {
|
||||
@@ -32,7 +33,7 @@ namespace display {
|
||||
DSI(DSI_TRIGGER) = DSI_TRIGGER_HOST;
|
||||
|
||||
if (wait)
|
||||
nx::svc::SleepThread(wait * 1000); // usleep-equivalant
|
||||
svc::SleepThread(wait * 1000); // usleep-equivalant
|
||||
}
|
||||
|
||||
void SetDisplayColorMode(AulaColorMode mode) {
|
||||
|
||||
@@ -23,6 +23,8 @@
|
||||
#include "display_refresh_rate.hpp"
|
||||
#include <switch.hpp>
|
||||
|
||||
using namespace nx;
|
||||
|
||||
namespace display {
|
||||
#define DSI_CLOCK_HZ 234000000llu
|
||||
#define NVDISP_GET_MODE2 0x803C021B
|
||||
@@ -143,7 +145,7 @@ namespace display {
|
||||
#define MIPI_DCS_PRIV_SM_SET_ELVSS 0xB1
|
||||
|
||||
dsi[DSI_VIDEO_MODE_CONTROL] = true;
|
||||
nx::svc::SleepThread(20000000);
|
||||
svc::SleepThread(20000000);
|
||||
|
||||
dsi[DSI_WR_DATA] = MIPI_DSI_DCS_LONG_WRITE | (5 << 8);
|
||||
dsi[DSI_WR_DATA] = 0x5A5A5AE2;
|
||||
@@ -163,7 +165,7 @@ namespace display {
|
||||
dsi[DSI_TRIGGER] = 0;
|
||||
|
||||
dsi[DSI_VIDEO_MODE_CONTROL] = false;
|
||||
nx::svc::SleepThread(20000000);
|
||||
svc::SleepThread(20000000);
|
||||
}
|
||||
void SetDockedState(bool isDocked) {
|
||||
g_config.isDocked = isDocked;
|
||||
@@ -494,11 +496,11 @@ namespace display {
|
||||
if (!g_config.displaySync) {
|
||||
g_wasRetroSuperTurnedOff = false;
|
||||
} else if (g_wasRetroSuperTurnedOff) {
|
||||
nx::svc::SleepThread(2000000000);
|
||||
svc::SleepThread(2000000000);
|
||||
g_wasRetroSuperTurnedOff = false;
|
||||
}
|
||||
|
||||
nx::svc::SleepThread(1000000000);
|
||||
svc::SleepThread(1000000000);
|
||||
|
||||
uint32_t fd = 0;
|
||||
if (nvOpen(&fd, "/dev/nvdisp-disp0")) {
|
||||
@@ -694,7 +696,7 @@ namespace display {
|
||||
_getDockedHighestRefreshRate(0);
|
||||
g_canChangeRefreshRateDocked = true;
|
||||
} else {
|
||||
nx::svc::SleepThread(1000000000);
|
||||
svc::SleepThread(1000000000);
|
||||
return false;
|
||||
}
|
||||
} else {
|
||||
|
||||
@@ -22,6 +22,8 @@
|
||||
#include <sys/stat.h>
|
||||
#include <switch.hpp>
|
||||
|
||||
using namespace nx;
|
||||
|
||||
namespace hos {
|
||||
|
||||
namespace {
|
||||
@@ -42,7 +44,7 @@ namespace hos {
|
||||
}
|
||||
if (i == 66)
|
||||
return false;
|
||||
nx::svc::SleepThread(1'000'000);
|
||||
svc::SleepThread(1'000'000);
|
||||
}
|
||||
|
||||
for (int i = 0; i < 67; i++) {
|
||||
@@ -50,7 +52,7 @@ namespace hos {
|
||||
svcCloseHandle(saltysd);
|
||||
return true;
|
||||
}
|
||||
nx::svc::SleepThread(1'000'000);
|
||||
svc::SleepThread(1'000'000);
|
||||
}
|
||||
|
||||
return false;
|
||||
|
||||
@@ -30,6 +30,7 @@
|
||||
#include "../file/file_utils.hpp"
|
||||
#include "process_management.hpp"
|
||||
|
||||
using namespace nx;
|
||||
|
||||
namespace hos {
|
||||
|
||||
@@ -62,7 +63,7 @@ namespace hos {
|
||||
u64 pid = 0;
|
||||
do {
|
||||
rc = pmdmntGetProcessId(&pid, Qlaunch);
|
||||
nx::svc::SleepThread(50 * 1000000ULL); // 50ms
|
||||
svc::SleepThread(50 * 1000000ULL); // 50ms
|
||||
} while (R_FAILED(rc));
|
||||
}
|
||||
|
||||
|
||||
@@ -17,6 +17,8 @@
|
||||
#include "i2cDrv.h"
|
||||
#include <switch.hpp>
|
||||
|
||||
using namespace nx;
|
||||
|
||||
Result I2cSet_U8(I2cDevice dev, u8 reg, u8 val) {
|
||||
// ams::fatal::srv::StopSoundTask::StopSound()
|
||||
// I2C Bus Communication Reference: https://www.ti.com/lit/an/slva704/slva704.pdf
|
||||
@@ -134,7 +136,7 @@ u32 I2c_BuckConverter_GetMvOut(const I2c_BuckConverter_Domain *domain) {
|
||||
return 0u;
|
||||
|
||||
// Wait 1us
|
||||
nx::svc::SleepThread(1E3);
|
||||
svc::SleepThread(1E3);
|
||||
|
||||
if (!domain->por_val || val != domain->por_val)
|
||||
break;
|
||||
@@ -150,7 +152,7 @@ u32 I2c_BuckConverter_GetUvOut(const I2c_BuckConverter_Domain *domain) {
|
||||
return 0u;
|
||||
|
||||
// Wait 1us
|
||||
nx::svc::SleepThread(1E3);
|
||||
svc::SleepThread(1E3);
|
||||
|
||||
if (!domain->por_val || val != domain->por_val)
|
||||
break;
|
||||
@@ -173,7 +175,7 @@ Result I2c_BuckConverter_SetMvOut(const I2c_BuckConverter_Domain *domain, u32 mv
|
||||
return res;
|
||||
|
||||
// 5ms Ramp delay
|
||||
nx::svc::SleepThread(5E6);
|
||||
svc::SleepThread(5E6);
|
||||
u8 new_val;
|
||||
res = I2cRead_OutU8(domain->device, domain->reg, &new_val);
|
||||
if (R_FAILED(res))
|
||||
|
||||
@@ -47,7 +47,7 @@
|
||||
|
||||
/* Is this a watchdog or a watchcat, that is the question */
|
||||
|
||||
namespace i2c::wdt {
|
||||
namespace HocI2c::wdt {
|
||||
|
||||
static bool isWdtEnabled = false;
|
||||
|
||||
@@ -128,7 +128,7 @@ namespace i2c::wdt {
|
||||
const bool watchdogEnabled = file::config::GetConfigValue(HocClkConfigValue_Watchdog);
|
||||
|
||||
if (watchdogEnabled) {
|
||||
Arm(i2c::wdt::MAX77620_WDT_2S);
|
||||
Arm(HocI2c::wdt::MAX77620_WDT_2S);
|
||||
Result rc = update_bits(MAX77620_REG_CNFGGLBL3, MAX77620_WDTC_MASK, MAX77620_WDTC_KICK);
|
||||
ASSERT_RESULT_OK(rc, "update_bits");
|
||||
} else {
|
||||
@@ -136,4 +136,4 @@ namespace i2c::wdt {
|
||||
}
|
||||
}
|
||||
|
||||
} // namespace i2c::wdt
|
||||
} // namespace HocI2c::wdt
|
||||
@@ -22,7 +22,7 @@
|
||||
#include "i2cDrv.h"
|
||||
#include "../file/errors.hpp"
|
||||
|
||||
namespace i2c::wdt {
|
||||
namespace HocI2c::wdt {
|
||||
|
||||
typedef enum {
|
||||
MAX77620_WDT_2S = 0, /* ~2 seconds */
|
||||
@@ -38,4 +38,4 @@ namespace i2c::wdt {
|
||||
|
||||
void ResetWdtEnableState();
|
||||
bool IsWdtEnabled();
|
||||
} // namespace i2c::wdt
|
||||
} // namespace HocI2c::wdt
|
||||
@@ -41,6 +41,7 @@
|
||||
#define INNER_HEAP_SIZE 0x40000
|
||||
|
||||
extern "C" {
|
||||
using namespace nx;
|
||||
void virtmemSetup(void);
|
||||
|
||||
extern std::uint32_t __start__;
|
||||
@@ -86,43 +87,43 @@ void __libnx_initheap(void) {
|
||||
}
|
||||
|
||||
void __appInit(void) {
|
||||
if (R_FAILED(smInitialize())) {
|
||||
if (R_FAILED(sm::Initialize())) {
|
||||
fatalThrow(MAKERESULT(Module_Libnx, LibnxError_InitFail_SM));
|
||||
}
|
||||
|
||||
Result rc = setsysInitialize();
|
||||
Result rc = setsys::Initialize();
|
||||
if (R_SUCCEEDED(rc)) {
|
||||
SetSysFirmwareVersion fw;
|
||||
rc = setsysGetFirmwareVersion(&fw);
|
||||
rc = setsys::GetFirmwareVersion(&fw);
|
||||
if (R_SUCCEEDED(rc))
|
||||
hosversionSet(MAKEHOSVERSION(fw.major, fw.minor, fw.micro));
|
||||
setsysExit();
|
||||
hosversion::Set(MAKEHOSVERSION(fw.major, fw.minor, fw.micro));
|
||||
setsys::Exit();
|
||||
}
|
||||
|
||||
|
||||
// rc = fanInitialize();
|
||||
// if (R_FAILED(rc))
|
||||
// diagAbortWithResult(MAKERESULT(Module_Libnx, LibnxError_ShouldNotHappen));
|
||||
|
||||
rc = i2cInitialize();
|
||||
rc = i2c::Initialize();
|
||||
if (R_FAILED(rc))
|
||||
diagAbortWithResult(MAKERESULT(Module_Libnx, LibnxError_ShouldNotHappen));
|
||||
diag::AbortWithResult(MAKERESULT(Module_Libnx, LibnxError_ShouldNotHappen));
|
||||
}
|
||||
|
||||
void __appExit(void) {
|
||||
// CloseFanControllerThread();
|
||||
// fanExit();
|
||||
i2cExit();
|
||||
setsysExit();
|
||||
fsdevUnmountAll();
|
||||
fsExit();
|
||||
smExit();
|
||||
i2c::Exit();
|
||||
setsys::Exit();
|
||||
fsdev::UnmountAll();
|
||||
fs::Exit();
|
||||
sm::Exit();
|
||||
}
|
||||
}
|
||||
|
||||
int main(int argc, char **argv) {
|
||||
Result rc = file::utils::Initialize();
|
||||
if (R_FAILED(rc)) {
|
||||
fatalThrow(rc);
|
||||
fatal::Throw(rc);
|
||||
return 1;
|
||||
}
|
||||
file::config::Initialize();
|
||||
@@ -156,7 +157,7 @@ int main(int argc, char **argv) {
|
||||
board::Exit();
|
||||
file::config::Exit();
|
||||
file::utils::LogLine("Exiting hoc-clk");
|
||||
nx::svc::SleepThread(1000000ULL);
|
||||
svc::SleepThread(1000000ULL);
|
||||
file::utils::Exit();
|
||||
|
||||
return 0;
|
||||
|
||||
@@ -48,6 +48,8 @@
|
||||
#include "../hos/clkrst_ext.hpp"
|
||||
#include <switch.hpp>
|
||||
|
||||
using namespace nx;
|
||||
|
||||
#define HOSPPC_HAS_BOOST (hosversionAtLeast(7, 0, 0))
|
||||
|
||||
namespace mgr {
|
||||
@@ -810,7 +812,7 @@ namespace mgr {
|
||||
else
|
||||
gContext.resolutionHeight = 0; // N/A
|
||||
|
||||
gContext.isWdtEnabled = i2c::wdt::IsWdtEnabled();
|
||||
gContext.isWdtEnabled = HocI2c::wdt::IsWdtEnabled();
|
||||
|
||||
return hasChanged;
|
||||
}
|
||||
@@ -915,7 +917,7 @@ namespace mgr {
|
||||
}
|
||||
|
||||
void WaitForNextTick() {
|
||||
i2c::wdt::Pet();
|
||||
nx::svc::SleepThread(file::config::GetConfigValue(HocClkConfigValue_PollingIntervalMs) * 1000000ULL);
|
||||
HocI2c::wdt::Pet();
|
||||
svc::SleepThread(file::config::GetConfigValue(HocClkConfigValue_PollingIntervalMs) * 1000000ULL);
|
||||
}
|
||||
} // namespace mgr
|
||||
@@ -19,6 +19,8 @@
|
||||
#include "governor.hpp"
|
||||
#include <hocclk/clock_manager.h>
|
||||
|
||||
using namespace nx;
|
||||
|
||||
namespace mgr {
|
||||
|
||||
#define DOWN_HOLD_TICKS_DEFAULT 10 // 50 ms at 5ms poll – how long to hold while ramping down
|
||||
@@ -140,7 +142,7 @@ namespace mgr {
|
||||
cpuLastHz = 0;
|
||||
gpuDownHoldRemaining = 0;
|
||||
gpuLastHz = 0;
|
||||
nx::svc::SleepThread(pollNs);
|
||||
svc::SleepThread(pollNs);
|
||||
continue;
|
||||
}
|
||||
|
||||
@@ -302,14 +304,14 @@ namespace mgr {
|
||||
if (++vrrTick > 50) {
|
||||
vrrTick = 0;
|
||||
board::SetHz(HocClkModule_Display, maxDisplay);
|
||||
nx::svc::SleepThread(50'000'000);
|
||||
svc::SleepThread(50'000'000);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
nx::svc::SleepThread(pollNs);
|
||||
svc::SleepThread(pollNs);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -21,9 +21,11 @@
|
||||
#include <hocclk.h>
|
||||
#include <switch.hpp>
|
||||
|
||||
using namespace nx;
|
||||
|
||||
#define WAIT_NS 1000000000UL
|
||||
|
||||
#define usleep(x) (nx::svc::SleepThread(1000UL * x))
|
||||
#define usleep(x) (svc::SleepThread(1000UL * x))
|
||||
|
||||
#define GPU_TRIM_SYS_GPCPLL_COEFF 0x4
|
||||
#define GPU_TRIM_SYS_GPCPLL(x) (*(volatile u32 *)(g_gpu_base + 0x137000ul + (x)))
|
||||
|
||||
@@ -30,6 +30,7 @@
|
||||
#include "soctherm.hpp"
|
||||
#include "tsensor_common.hpp"
|
||||
|
||||
using namespace nx;
|
||||
|
||||
namespace tsensor {
|
||||
|
||||
@@ -505,7 +506,7 @@ namespace tsensor {
|
||||
}
|
||||
|
||||
/* Wait for HW recalibration */
|
||||
nx::svc::SleepThread(25'000);
|
||||
svc::SleepThread(25'000);
|
||||
|
||||
temps.cpu = TranslateTemp(ReadReg(socthermVa, SENSOR_TEMP1) >> 16);
|
||||
temps.gpu = TranslateTemp(ReadReg(socthermVa, SENSOR_TEMP1) & SENSOR_TEMP1_GPU_TEMP_MASK);
|
||||
@@ -528,7 +529,7 @@ namespace tsensor {
|
||||
|
||||
WriteReg(carVa, CAR_CLK_SOURCE_TSENSOR, CAR_CLK_SOURCE_TSENSOR_VAL);
|
||||
SetBits(carVa, CAR_CLK_OUT_ENB_V, 0x10);
|
||||
nx::svc::SleepThread(2000);
|
||||
svc::SleepThread(2000);
|
||||
|
||||
TSensorSharedCalib sharedCal = {};
|
||||
CalcSharedCal(&tfuse, &sharedCal, fuseVa);
|
||||
|
||||
Reference in new issue
Block a user