Revert C++ libnx bindings and call-site conversion

This commit is contained in:
Lightos1 committed 2026-10-06 10:42:15 +02:00
1 parent fb46ac4199
commit 5f973f60b2
44 files changed
+246 -34097

No files matched your search

+9 -9
View File
@@ -26,13 +26,13 @@
#include <battery.h>
#include <hocclk.h>
#include <i2c.hpp>
#include <max17050.hpp>
#include <i2c.h>
#include <max17050.h>
#include <notification.h>
#include <pwm.h>
#include <registers.h>
#include <switch.h>
#include <tmp451.hpp>
#include <tmp451.h>
#include "../display/display_refresh_rate.hpp"
#include "../file/file_utils.hpp"
@@ -46,7 +46,7 @@
#include "board_load.hpp"
#include "board_misc.hpp"
#include "board_volt.hpp"
#include <ipc_server.hpp>
#include <ipc_server.h>
#include <lockable_mutex.h>
#include "../mapping/mem_map.hpp"
#include "../soc/dram_mrr.hpp"
@@ -97,8 +97,8 @@ namespace board {
rc = pscPmModuleGetRequest(&s_pscModule, &state, &flags);
if (R_SUCCEEDED(rc)) {
if (state == PscPmState_ReadyAwaken) {
HocI2c::wdt::ResetWdtEnableState();
HocI2c::wdt::Pet();
i2c::wdt::ResetWdtEnableState();
i2c::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) {
HocI2c::wdt::Disarm();
i2c::wdt::Disarm();
ResetToStockMem();
ResetToStockCpu();
@@ -127,7 +127,7 @@ namespace board {
s_isAwake = false;
} else if (state == PscPmState_ReadyShutdown) {
HocI2c::wdt::Disarm();
i2c::wdt::Disarm();
ResetToStockMem();
ResetToStockCpu();
@@ -326,7 +326,7 @@ namespace board {
pscPmModuleClose(&s_pscModule);
pscmExit();
HocI2c::wdt::Disarm();
i2c::wdt::Disarm();
}
HocClkSocType GetSocType() {
@@ -25,11 +25,11 @@
*/
#include <hocclk.h>
#include <i2c.hpp>
#include <max17050.hpp>
#include <i2c.h>
#include <max17050.h>
#include <switch.h>
#include <t210.hpp>
#include <tmp451.hpp>
#include <t210.h>
#include <tmp451.h>
#include "../display/display_refresh_rate.hpp"
#include "../file/config.hpp"
@@ -40,11 +40,8 @@
#include "../soc/pllmb.hpp"
#include "board.hpp"
#include "board_name.hpp"
#include <ipc_server.hpp>
#include <ipc_server.h>
#include <lockable_mutex.h>
#include <switch.hpp>
using namespace nx;
namespace board {
static u32 currentInjectedHz = 0;
@@ -70,18 +67,18 @@ namespace board {
PcvModuleId GetPcvModuleId(HocClkModule hocclkModule) {
PcvModuleId pcvModuleId;
Result rc = nx::pcv::GetModuleId(&pcvModuleId, GetPcvModule(hocclkModule));
Result rc = pcvGetModuleId(&pcvModuleId, GetPcvModule(hocclkModule));
ASSERT_RESULT_OK(rc, "pcvGetModuleId");
return pcvModuleId;
}
void ClkrstSetHz(ClkrstSession &session, u32 hz) {
ASSERT_RESULT_OK(nx::clkrst::SetClockRate(&session, hz), "clkrstSetClockRate");
ASSERT_RESULT_OK(clkrstSetClockRate(&session, hz), "clkrstSetClockRate");
}
void PcvSetHz(PcvModule moduleID, u32 hz) {
ASSERT_RESULT_OK(nx::pcv::SetClockRate(moduleID, hz), "pcvSetClockRate");
ASSERT_RESULT_OK(pcvSetClockRate(moduleID, hz), "pcvSetClockRate");
}
void HandleCpuUv() {
@@ -115,22 +112,22 @@ namespace board {
if (HOSSVC_HAS_CLKRST) {
ClkrstSession session = {};
rc = nx::clkrst::OpenSession(&session, GetPcvModuleId(module), 3);
rc = clkrstOpenSession(&session, GetPcvModuleId(module), 3);
ASSERT_RESULT_OK(rc, "clkrstOpenSession");
ClkrstSetHz(session, pcvHz);
/* Voltage bug workaround. */
if (module == HocClkModule_CPU) {
svc::SleepThread(300'000);
svcSleepThread(300'000);
ClkrstSetHz(session, pcvHz);
}
nx::clkrst::CloseSession(&session);
clkrstCloseSession(&session);
} else {
PcvSetHz(GetPcvModule(module), pcvHz);
if (module == HocClkModule_CPU) {
svc::SleepThread(300'000);
svcSleepThread(300'000);
PcvSetHz(GetPcvModule(module), pcvHz);
}
}
@@ -26,14 +26,14 @@
#pragma once
#include <hocclk.h>
#include <i2c.hpp>
#include <max17050.hpp>
#include <i2c.h>
#include <max17050.h>
#include <switch.h>
#include <tmp451.hpp>
#include <tmp451.h>
#include "../file/errors.hpp"
#include "../hos/apm_ext.h"
#include <ipc_server.hpp>
#include <ipc_server.h>
#include <lockable_mutex.h>
@@ -27,23 +27,21 @@
#include <algorithm>
#include <battery.h>
#include <hocclk.h>
#include <i2c.hpp>
#include <i2c.h>
#include <math.h>
#include <max17050.hpp>
#include <max17050.h>
#include <minIni.h>
#include <numeric>
#include <switch.h>
#include <t210.hpp>
#include <tmp451.hpp>
#include <switch.hpp>
#include <t210.h>
#include <tmp451.h>
#include "../hos/apm_ext.h"
#include "board.hpp"
#include "board_misc.hpp"
#include <ipc_server.hpp>
#include <ipc_server.h>
#include <lockable_mutex.h>
using namespace nx;
namespace board {
@@ -76,7 +74,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;
}
svc::SleepThread(16'666'000); // wait a bit (this is the perfect amount of time to keep the reading accurate)
svcSleepThread(16'666'000); // wait a bit (this is the perfect amount of time to keep the reading accurate)
} while (true);
}
@@ -27,10 +27,6 @@
#include <cmath>
#include <pwm.h>
#include <switch.h>
#include <hocclk.h>
#include <switch.hpp>
using namespace nx;
namespace board {
@@ -54,7 +50,7 @@ namespace board {
}
fanLevel = static_cast<u8>(rotationDuty);
svc::SleepThread(300'000'000);
svcSleepThread(300'000'000);
}
}
@@ -25,14 +25,14 @@
*/
#include <hocclk.h>
#include <i2c.hpp>
#include <max17050.hpp>
#include <i2c.h>
#include <max17050.h>
#include <switch.h>
#include <tmp451.hpp>
#include <tmp451.h>
#include "../hos/apm_ext.h"
#include "board.hpp"
#include <ipc_server.hpp>
#include <ipc_server.h>
#include <lockable_mutex.h>
namespace board {
@@ -27,11 +27,11 @@
#include <battery.h>
#include <cmath>
#include <hocclk.h>
#include <i2c.hpp>
#include <max17050.hpp>
#include <i2c.h>
#include <max17050.h>
#include <pwm.h>
#include <switch.h>
#include <tmp451.hpp>
#include <tmp451.h>
#include "../file/config.hpp"
#include "../hos/apm_ext.h"
@@ -41,7 +41,7 @@
#include "../tsensor/bq24193.hpp"
#include "../tsensor/soctherm.hpp"
#include "board.hpp"
#include <ipc_server.hpp>
#include <ipc_server.h>
#include <lockable_mutex.h>
@@ -53,7 +53,7 @@ namespace board {
u32 gDramMr4Tick = DramMr4PollDivisor;
s32 gDramMr4Millis = 30000; /* 4x refresh default */
[[maybe_unused]] s32 PollDramMr4TempMilli() {
s32 PollDramMr4TempMilli() {
u8 mr4 = 0;
if (!soc::ReadRamMr4(&mr4))
return 0; /* stock exosphere */
@@ -31,8 +31,6 @@
#include "board_freq.hpp"
#include "board_volt.hpp"
using namespace nx;
namespace board {
GpuVoltData voltData = {};
@@ -659,7 +657,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);
svc::SleepThread(5'000'000);
svcSleepThread(5'000'000);
board::SetHz(HocClkModule_CPU, hz);
}
@@ -19,9 +19,7 @@
#include "aula.hpp"
#include "common.hpp"
#include <switch.hpp>
using namespace nx;
// I *think* HOS changes this in some ways, so look into it more
namespace display {
@@ -33,7 +31,7 @@ namespace display {
DSI(DSI_TRIGGER) = DSI_TRIGGER_HOST;
if (wait)
svc::SleepThread(wait * 1000); // usleep-equivalant
svcSleepThread(wait * 1000); // usleep-equivalant
}
void SetDisplayColorMode(AulaColorMode mode) {
@@ -15,9 +15,6 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#pragma once
#include <switch.hpp>
#ifndef _DI_H_
#define _DI_H_
@@ -19,11 +19,8 @@
#include <stdarg.h>
#include <string.h>
#include <switch.h>
#include <hocclk.h>
#include "display_refresh_rate.hpp"
#include <switch.hpp>
using namespace nx;
#include "display_refresh_rate.hpp"
namespace display {
#define DSI_CLOCK_HZ 234000000llu
@@ -145,7 +142,7 @@ namespace display {
#define MIPI_DCS_PRIV_SM_SET_ELVSS 0xB1
dsi[DSI_VIDEO_MODE_CONTROL] = true;
svc::SleepThread(20000000);
svcSleepThread(20000000);
dsi[DSI_WR_DATA] = MIPI_DSI_DCS_LONG_WRITE | (5 << 8);
dsi[DSI_WR_DATA] = 0x5A5A5AE2;
@@ -165,7 +162,7 @@ namespace display {
dsi[DSI_TRIGGER] = 0;
dsi[DSI_VIDEO_MODE_CONTROL] = false;
svc::SleepThread(20000000);
svcSleepThread(20000000);
}
void SetDockedState(bool isDocked) {
g_config.isDocked = isDocked;
@@ -241,9 +238,9 @@ namespace display {
uint32_t fd = fd_in;
if (!fd)
nv::Open(&fd, "/dev/nvdisp-disp1");
nvOpen(&fd, "/dev/nvdisp-disp1");
NvdcModeDB2 db2 = { 0 };
int rc = nv::Ioctl(fd, NVDISP_GET_MODE_DB2, &db2);
int rc = nvIoctl(fd, NVDISP_GET_MODE_DB2, &db2);
if (rc == 0) {
for (size_t i = 0; i < db2.num_modes; i++) {
@@ -266,7 +263,7 @@ namespace display {
highestRefreshRate = g_dockedRefreshRates[numRates - 1];
NvdcMode2 display_b = { 0 };
rc = nv::Ioctl(fd, NVDISP_GET_MODE2, &display_b);
rc = nvIoctl(fd, NVDISP_GET_MODE2, &display_b);
struct dpaux_read_0x100 {
uint32_t cmd;
@@ -284,7 +281,7 @@ namespace display {
} set;
} dpaux = { 6, 0x100, 0x10 };
rc = nv::Ioctl(fd, NVDISP_GET_PANEL_DATA, &dpaux);
rc = nvIoctl(fd, NVDISP_GET_PANEL_DATA, &dpaux);
if (rc == 0) {
g_dockedLinkRate = dpaux.set.link_rate;
// if (display_b.hActive == 1920 && display_b.vActive == 1080 && highestRefreshRate > 75 && dpaux.set.link_rate < 20 && )
@@ -292,7 +289,7 @@ namespace display {
}
if (!fd_in)
nv::Close(fd);
nvClose(fd);
g_dockedHighestRefreshRate = highestRefreshRate;
}
@@ -320,8 +317,8 @@ namespace display {
} DPCD;
} dpaux = { 6, 0, 0x10 };
int rc = nv::Ioctl(fd, NVDISP_GET_PANEL_DATA, &dpaux);
nv::Close(fd);
int rc = nvIoctl(fd, NVDISP_GET_PANEL_DATA, &dpaux);
nvClose(fd);
if (rc != 0x75c)
return false;
@@ -382,19 +379,19 @@ namespace display {
return false;
uint32_t fd = 0;
if (nv::Open(&fd, "/dev/nvdisp-disp1")) {
if (nvOpen(&fd, "/dev/nvdisp-disp1")) {
return false;
}
NvdcMode2 display_b = { 0 };
int rc = nv::Ioctl(fd, NVDISP_GET_MODE2, &display_b);
int rc = nvIoctl(fd, NVDISP_GET_MODE2, &display_b);
if (rc != 0) {
nv::Close(fd);
nvClose(fd);
return false;
}
if (!display_b.pclkKHz) {
nv::Close(fd);
nvClose(fd);
return false;
}
@@ -457,7 +454,7 @@ namespace display {
}
if (refreshRateNow == g_dockedRefreshRates[itr]) {
nv::Close(fd);
nvClose(fd);
return true;
}
@@ -479,13 +476,13 @@ namespace display {
display_b.bitsPerPixel = 24;
}
rc = nv::Ioctl(fd, NVDISP_VALIDATE_MODE2, &display_b);
rc = nvIoctl(fd, NVDISP_VALIDATE_MODE2, &display_b);
if (rc == 0) {
rc = nv::Ioctl(fd, NVDISP_SET_MODE2, &display_b);
rc = nvIoctl(fd, NVDISP_SET_MODE2, &display_b);
}
}
nv::Close(fd);
nvClose(fd);
return true;
}
@@ -496,31 +493,31 @@ namespace display {
if (!g_config.displaySync) {
g_wasRetroSuperTurnedOff = false;
} else if (g_wasRetroSuperTurnedOff) {
svc::SleepThread(2000000000);
svcSleepThread(2000000000);
g_wasRetroSuperTurnedOff = false;
}
svc::SleepThread(1000000000);
svcSleepThread(1000000000);
uint32_t fd = 0;
if (nv::Open(&fd, "/dev/nvdisp-disp0")) {
if (nvOpen(&fd, "/dev/nvdisp-disp0")) {
return false;
}
NvdcMode2 display_b = { 0 };
int rc = nv::Ioctl(fd, NVDISP_GET_MODE2, &display_b);
int rc = nvIoctl(fd, NVDISP_GET_MODE2, &display_b);
if (rc != 0) {
nv::Close(fd);
nvClose(fd);
return false;
}
if (!display_b.pclkKHz) {
nv::Close(fd);
nvClose(fd);
return false;
}
if ((display_b.vActive == 1280 && display_b.hActive == 720) == false) {
nv::Close(fd);
nvClose(fd);
return false;
}
@@ -566,14 +563,14 @@ namespace display {
display_b.vBackPorch = g_handheldTimingsRETRO[itr].vBackPorch;
display_b.pclkKHz = g_handheldTimingsRETRO[itr].pixelClock_kHz;
rc = nv::Ioctl(fd, NVDISP_VALIDATE_MODE2, &display_b);
rc = nvIoctl(fd, NVDISP_VALIDATE_MODE2, &display_b);
if (rc == 0) {
for (size_t i = 0; i < 5; i++) {
nv::Ioctl(fd, NVDISP_SET_MODE2, &display_b);
nvIoctl(fd, NVDISP_SET_MODE2, &display_b);
}
}
nv::Close(fd);
nvClose(fd);
return true;
}
@@ -606,8 +603,8 @@ namespace display {
} DPCD;
} dpaux = { 6, 0, 0x10 };
int rc = nv::Ioctl(fd, NVDISP_GET_PANEL_DATA, &dpaux);
nv::Close(fd);
int rc = nvIoctl(fd, NVDISP_GET_PANEL_DATA, &dpaux);
nvClose(fd);
if (rc != 0) {
if (!g_config.isRetroSUPER) {
@@ -640,15 +637,15 @@ namespace display {
value = ((temp.PLLD_DIVN / temp.PLLD_DIVM) * 10) / 4;
if (value != 0 && value != 80) {
if (!nv::Open(&fd, "/dev/nvdisp-disp0")) {
if (!nvOpen(&fd, "/dev/nvdisp-disp0")) {
NvdcMode2 display_b = { 0 };
if (nv::Ioctl(fd, NVDISP_GET_MODE2, &display_b) == 0) {
if (nvIoctl(fd, NVDISP_GET_MODE2, &display_b) == 0) {
uint64_t h_total = display_b.hActive + display_b.hFrontPorch + display_b.hSyncWidth + display_b.hBackPorch;
uint64_t v_total = display_b.vActive + display_b.vFrontPorch + display_b.vSyncWidth + display_b.vBackPorch;
uint64_t pixelClock = display_b.pclkKHz * 1000 + 999;
value = (u32)(pixelClock / (h_total * v_total));
}
nv::Close(fd);
nvClose(fd);
} else {
return false;
}
@@ -672,7 +669,7 @@ namespace display {
if (!g_canChangeRefreshRateDocked) {
uint32_t fd = 0;
if (!nv::Open(&fd, "/dev/nvdisp-disp1")) {
if (!nvOpen(&fd, "/dev/nvdisp-disp1")) {
struct dpaux_read_0x100 {
uint32_t cmd;
uint32_t addr;
@@ -689,14 +686,14 @@ namespace display {
} set;
} dpaux = { 6, 0x100, 0x10 };
int rc = nv::Ioctl(fd, NVDISP_GET_PANEL_DATA, &dpaux);
nv::Close(fd);
int rc = nvIoctl(fd, NVDISP_GET_PANEL_DATA, &dpaux);
nvClose(fd);
if (rc == 0) {
_getDockedHighestRefreshRate(0);
g_canChangeRefreshRateDocked = true;
} else {
svc::SleepThread(1000000000);
svcSleepThread(1000000000);
return false;
}
} else {
@@ -708,11 +705,11 @@ namespace display {
return true;
}
uint32_t fd = 0;
if (!nv::Open(&fd, "/dev/nvdisp-disp1")) {
if (!nvOpen(&fd, "/dev/nvdisp-disp1")) {
NvdcMode2 display_b = { 0 };
if (nv::Ioctl(fd, NVDISP_GET_MODE2, &display_b) == 0) {
if (nvIoctl(fd, NVDISP_GET_MODE2, &display_b) == 0) {
if (!display_b.pclkKHz) {
nv::Close(fd);
nvClose(fd);
return false;
}
@@ -728,7 +725,7 @@ namespace display {
} else {
value = 60;
}
nv::Close(fd);
nvClose(fd);
} else {
value = 60;
}
+4 -4
View File
@@ -29,13 +29,13 @@
#include <cstdio>
#include <cstring>
#include <ctime>
#include <i2c.hpp>
#include <i2c.h>
#include <map>
#include <max17050.hpp>
#include <max17050.h>
#include <minIni.h>
#include <sstream>
#include <string>
#include <tmp451.hpp>
#include <tmp451.h>
#include <unistd.h>
#include "../board/board.hpp"
@@ -44,7 +44,7 @@
#include "errors.hpp"
#include "file_utils.hpp"
#include <initializer_list>
#include <ipc_server.hpp>
#include <ipc_server.h>
#include <lockable_mutex.h>
#include <sys/stat.h>
#include <sys/types.h>
@@ -24,13 +24,13 @@
* --------------------------------------------------------------------------
*/
#include <i2c.hpp>
#include <max17050.hpp>
#include <tmp451.hpp>
#include <i2c.h>
#include <max17050.h>
#include <tmp451.h>
#include "../hos/apm_ext.h"
#include "file_utils.hpp"
#include <ipc_server.hpp>
#include <ipc_server.h>
#include <lockable_mutex.h>
extern "C" void __libnx_init_time(void);
@@ -108,7 +108,7 @@ namespace file::utils {
// Debug UART log
if (g_uart_enabled) {
svc::OutputDebugString(buff, len);
svcOutputDebugString(buff, len);
}
if (g_log_enabled) {
@@ -188,27 +188,27 @@ namespace file::utils {
void InitializeAsync() {
Thread initThread = { 0 };
thread::Create(&initThread, InitializeThreadFunc, NULL, NULL, 0x4000, 0x15, 0);
thread::Start(&initThread);
threadCreate(&initThread, InitializeThreadFunc, NULL, NULL, 0x4000, 0x15, 0);
threadStart(&initThread);
}
Result Initialize() {
Result rc = 0;
if (R_SUCCEEDED(rc)) {
rc = time::Initialize();
rc = timeInitialize();
}
__libnx_init_time();
time::Exit();
timeExit();
SetBootTime();
if (R_SUCCEEDED(rc)) {
rc = fs::Initialize();
rc = fsInitialize();
}
if (R_SUCCEEDED(rc)) {
rc = fsdev::MountSdmc();
rc = fsdevMountSdmc();
}
if (R_SUCCEEDED(rc)) {
@@ -230,8 +230,8 @@ namespace file::utils {
g_log_enabled = false;
g_uart_enabled = false;
fsdev::UnmountAll();
fs::Exit();
fsdevUnmountAll();
fsExit();
}
} // namespace file::utils
@@ -33,7 +33,6 @@
#include <switch.h>
#include <time.h>
#include <vector>
#include <switch.hpp>
#define FILE_CONFIG_DIR "/config/" CONFIG_DIR
#define FILE_CONTEXT_CSV_PATH FILE_CONFIG_DIR "/context.csv"
@@ -1,53 +0,0 @@
/*
* Copyright (c) Souldbminer, Lightos_ and Horizon OC Contributors
*
* This program is free software; you can redistribute it and/or modify it
* under the terms and conditions of the GNU General Public License,
* version 2, as published by the Free Software Foundation.
*
* This program is distributed in the hope it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
* more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
*/
#include "clkrst_ext.hpp"
namespace hos::clkrst {
/// @brief Sets the minimum voltage for a session's module to the one required for @param hz. Does not work with cpu module
/// @param session A ClkrstSession pointer
/// @param hz The hz to set the vmin for
/// @return Result code
Result SetMinimumVoltageClockRate(ClkrstSession *session, u32 hz) {
return serviceDispatchIn(&session->s, 9, hz);
}
Result GetDvfsTable(ClkrstSession *session, u32 *out_rate_table, s32 in_rate_count, u32 *out_voltage_table, s32 in_voltage_count, s32 *out_count) {
const struct {
s32 rate_count;
s32 voltage_count;
} in = { in_rate_count, in_voltage_count };
s32 out = 0;
Result rc = serviceDispatchInOut(&session->s, 11, in, out,
.buffer_attrs = {
SfBufferAttr_Out | SfBufferAttr_HipcAutoSelect,
SfBufferAttr_Out | SfBufferAttr_HipcAutoSelect,
},
.buffers = {
{ out_rate_table, in_rate_count * sizeof(u32) },
{ out_voltage_table, in_voltage_count * sizeof(u32) },
},
);
if (R_SUCCEEDED(rc) && out_count) {
*out_count = out;
}
return rc;
}
} // namespace hos::clkrst
@@ -1,24 +0,0 @@
/*
* Copyright (c) Souldbminer, Lightos_ and Horizon OC Contributors
*
* This program is free software; you can redistribute it and/or modify it
* under the terms and conditions of the GNU General Public License,
* version 2, as published by the Free Software Foundation.
*
* This program is distributed in the hope it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
* more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
*/
#include <hocclk.h>
#include <switch.h>
namespace hos::clkrst {
Result SetMinimumVoltageClockRate(ClkrstSession *session, u32 hz);
Result GetDvfsTable(ClkrstSession *session, u32 *out_rate_table, s32 in_rate_count, u32 *out_voltage_table, s32 in_voltage_count, s32 *out_count);
} // namespace hos::clkrst
@@ -20,9 +20,6 @@
#include "integrations.hpp"
#include "process_management.hpp"
#include <sys/stat.h>
#include <switch.hpp>
using namespace nx;
namespace hos {
@@ -38,21 +35,21 @@ namespace hos {
Handle saltysd;
for (int i = 0; i < 67; i++) {
if (R_SUCCEEDED(svc::ConnectToNamedPort(&saltysd, "InjectServ"))) {
svc::CloseHandle(saltysd);
if (R_SUCCEEDED(svcConnectToNamedPort(&saltysd, "InjectServ"))) {
svcCloseHandle(saltysd);
break;
}
if (i == 66)
return false;
svc::SleepThread(1'000'000);
svcSleepThread(1'000'000);
}
for (int i = 0; i < 67; i++) {
if (R_SUCCEEDED(svc::ConnectToNamedPort(&saltysd, "InjectServ"))) {
svc::CloseHandle(saltysd);
if (R_SUCCEEDED(svcConnectToNamedPort(&saltysd, "InjectServ"))) {
svcCloseHandle(saltysd);
return true;
}
svc::SleepThread(1'000'000);
svcSleepThread(1'000'000);
}
return false;
@@ -74,8 +71,8 @@ namespace hos {
return;
SaltySD_GetSharedMemoryHandle(&gRemoteSharedMemory);
SaltySD_Term();
shmem::LoadRemote(&gSharedMemory, gRemoteSharedMemory, 0x1000, Perm_Rw);
if (!shmem::Map(&gSharedMemory))
shmemLoadRemote(&gSharedMemory, gRemoteSharedMemory, 0x1000, Perm_Rw);
if (!shmemMap(&gSharedMemory))
gSharedMemoryUsed = true;
}
@@ -111,7 +108,7 @@ namespace hos {
}
if (!gNxFps) {
uintptr_t base = (uintptr_t)shmem::GetAddr(&gSharedMemory);
uintptr_t base = (uintptr_t)shmemGetAddr(&gSharedMemory);
SearchSharedMemoryBlock(base);
}
@@ -133,7 +130,7 @@ namespace hos {
}
if (!gNxFps) {
uintptr_t base = (uintptr_t)shmem::GetAddr(&gSharedMemory);
uintptr_t base = (uintptr_t)shmemGetAddr(&gSharedMemory);
SearchSharedMemoryBlock(base);
}
@@ -30,7 +30,6 @@
#include "../file/file_utils.hpp"
#include "process_management.hpp"
using namespace nx;
namespace hos {
@@ -43,18 +42,18 @@ namespace hos {
void InitializeProcessManagement() {
Result rc = 0;
rc = pmdmnt::Initialize();
rc = pmdmntInitialize();
ASSERT_RESULT_OK(rc, "pmdmntInitialize");
rc = pminfo::Initialize();
rc = pminfoInitialize();
ASSERT_RESULT_OK(rc, "pminfoInitialize");
rc = pdmqry::Initialize();
rc = pdmqryInitialize();
ASSERT_RESULT_OK(rc, "pdmqryInitialize");
Service *pdmqrySrv = pdmqry::GetServiceSession();
service::Clone(pdmqrySrv, &pdmqryClone);
service::Close(pdmqrySrv);
Service *pdmqrySrv = pdmqryGetServiceSession();
serviceClone(pdmqrySrv, &pdmqryClone);
serviceClose(pdmqrySrv);
memcpy(pdmqrySrv, &pdmqryClone, sizeof(Service));
}
@@ -62,8 +61,8 @@ namespace hos {
Result rc = 0;
u64 pid = 0;
do {
rc = pmdmnt::GetProcessId(&pid, Qlaunch);
svc::SleepThread(50 * 1000000ULL); // 50ms
rc = pmdmntGetProcessId(&pid, Qlaunch);
svcSleepThread(50 * 1000000ULL); // 50ms
} while (R_FAILED(rc));
}
@@ -77,14 +76,14 @@ namespace hos {
u64 TIDnow;
u64 PIDnow;
Result rc = pmdmnt::GetApplicationProcessId(&PIDnow);
Result rc = pmdmntGetApplicationProcessId(&PIDnow);
if (R_FAILED(rc))
return rc;
rc = pmdmnt::GetProgramId(&TIDnow, PIDnow);
rc = pmdmntGetProgramId(&TIDnow, PIDnow);
if (R_FAILED(rc))
return rc;
rc = pdmqry::GetAvailablePlayEventRange(&total_entries, &start_entry_index, &end_entry_index);
rc = pdmqryGetAvailablePlayEventRange(&total_entries, &start_entry_index, &end_entry_index);
if (R_FAILED(rc))
return rc;
if (total_entries == last_total_entries) {
@@ -98,7 +97,7 @@ namespace hos {
s32 start_entry = end_entry_index - 15;
if (start_entry < 0)
start_entry = 0;
rc = pdmqry::QueryPlayEvent(start_entry, events, sizeof(events) / sizeof(events[0]), &out);
rc = pdmqryQueryPlayEvent(start_entry, events, sizeof(events) / sizeof(events[0]), &out);
if (R_FAILED(rc))
return rc;
if (out == 0)
@@ -140,7 +139,7 @@ namespace hos {
Result rc = 0;
u64 pid = 0;
u64 tid = 0;
rc = pmdmnt::GetApplicationProcessId(&pid);
rc = pmdmntGetApplicationProcessId(&pid);
if (rc == IsQlaunch) {
return Qlaunch;
@@ -148,7 +147,7 @@ namespace hos {
ASSERT_RESULT_OK(rc, "pmdmntGetApplicationProcessId");
rc = pminfo::GetProgramId(&tid, pid);
rc = pminfoGetProgramId(&tid, pid);
if (rc == IsQlaunch) {
return Qlaunch;
@@ -160,9 +159,9 @@ namespace hos {
}
void ExitProcessManagement() {
pmdmnt::Exit();
pminfo::Exit();
pdmqry::Exit();
pmdmntExit();
pminfoExit();
pdmqryExit();
}
} // namespace hos
@@ -24,10 +24,7 @@
* --------------------------------------------------------------------------
*/
#include "i2c.hpp"
#include <switch.hpp>
using namespace nx;
#include "i2c.h"
#define I2C_CMD_SND 0
#define I2C_CMD_RCV 1
@@ -37,5 +34,5 @@ Result i2csessionExtRegReceive(I2cSession *s, u8 in, void *out, u8 out_size) {
I2C_CMD_RCV | (I2cTransactionOption_All << 6), out_size };
return i2csession::ExecuteCommandList(s, out, out_size, cmdlist, sizeof(cmdlist));
return i2csessionExecuteCommandList(s, out, out_size, cmdlist, sizeof(cmdlist));
}
@@ -25,7 +25,15 @@
*/
#pragma once
#include <switch.hpp>
#ifdef __cplusplus
extern "C" {
#endif
#include <switch.h>
Result i2csessionExtRegReceive(I2cSession *s, u8 in, void *out, u8 out_size);
#ifdef __cplusplus
}
#endif
+16 -19
View File
@@ -15,9 +15,6 @@
*
*/
#include "i2cDrv.h"
#include <switch.hpp>
using namespace nx;
Result I2cSet_U8(I2cDevice dev, u8 reg, u8 val) {
// ams::fatal::srv::StopSoundTask::StopSound()
@@ -28,14 +25,14 @@ Result I2cSet_U8(I2cDevice dev, u8 reg, u8 val) {
} __attribute__((packed)) cmd;
I2cSession _session;
Result res = i2c::OpenSession(&_session, dev);
Result res = i2cOpenSession(&_session, dev);
if (res)
return res;
cmd.reg = reg;
cmd.val = val;
res = i2csession::SendAuto(&_session, &cmd, sizeof(cmd), I2cTransactionOption_All);
i2csession::Close(&_session);
res = i2csessionSendAuto(&_session, &cmd, sizeof(cmd), I2cTransactionOption_All);
i2csessionClose(&_session);
return res;
}
@@ -48,19 +45,19 @@ Result I2cRead_OutU8(I2cDevice dev, u8 reg, u8 *out) {
} __attribute__((packed)) rec;
I2cSession _session;
Result res = i2c::OpenSession(&_session, dev);
Result res = i2cOpenSession(&_session, dev);
if (res)
return res;
cmd.reg = reg;
res = i2csession::SendAuto(&_session, &cmd, sizeof(cmd), I2cTransactionOption_All);
res = i2csessionSendAuto(&_session, &cmd, sizeof(cmd), I2cTransactionOption_All);
if (res) {
i2csession::Close(&_session);
i2csessionClose(&_session);
return res;
}
res = i2csession::ReceiveAuto(&_session, &rec, sizeof(rec), I2cTransactionOption_All);
i2csession::Close(&_session);
res = i2csessionReceiveAuto(&_session, &rec, sizeof(rec), I2cTransactionOption_All);
i2csessionClose(&_session);
if (res) {
return res;
}
@@ -78,19 +75,19 @@ Result I2cRead_OutU16(I2cDevice dev, u8 reg, u16 *out) {
} __attribute__((packed)) rec;
I2cSession _session;
Result res = i2c::OpenSession(&_session, dev);
Result res = i2cOpenSession(&_session, dev);
if (res)
return res;
cmd.reg = reg;
res = i2csession::SendAuto(&_session, &cmd, sizeof(cmd), I2cTransactionOption_All);
res = i2csessionSendAuto(&_session, &cmd, sizeof(cmd), I2cTransactionOption_All);
if (res) {
i2csession::Close(&_session);
i2csessionClose(&_session);
return res;
}
res = i2csession::ReceiveAuto(&_session, &rec, sizeof(rec), I2cTransactionOption_All);
i2csession::Close(&_session);
res = i2csessionReceiveAuto(&_session, &rec, sizeof(rec), I2cTransactionOption_All);
i2csessionClose(&_session);
if (res) {
return res;
}
@@ -136,7 +133,7 @@ u32 I2c_BuckConverter_GetMvOut(const I2c_BuckConverter_Domain *domain) {
return 0u;
// Wait 1us
svc::SleepThread(1E3);
svcSleepThread(1E3);
if (!domain->por_val || val != domain->por_val)
break;
@@ -152,7 +149,7 @@ u32 I2c_BuckConverter_GetUvOut(const I2c_BuckConverter_Domain *domain) {
return 0u;
// Wait 1us
svc::SleepThread(1E3);
svcSleepThread(1E3);
if (!domain->por_val || val != domain->por_val)
break;
@@ -175,7 +172,7 @@ Result I2c_BuckConverter_SetMvOut(const I2c_BuckConverter_Domain *domain, u32 mv
return res;
// 5ms Ramp delay
svc::SleepThread(5E6);
svcSleepThread(5E6);
u8 new_val;
res = I2cRead_OutU8(domain->device, domain->reg, &new_val);
if (R_FAILED(res))
+1 -1
View File
@@ -6,7 +6,7 @@
#pragma once
#include <switch.h>
#include <hocclk.h>
// To use i2c service, sm and i2c should be intialized via smInitialize() and i2cInitialize().
Result I2cSet_U8(I2cDevice dev, u8 reg, u8 val);
@@ -22,8 +22,8 @@
*
*/
#include "i2c.hpp"
#include "max17050.hpp"
#include "i2c.h"
#include "max17050.h"
#define MAX17050_WAIT_NS 1000000000UL
@@ -47,7 +47,7 @@
/* Is this a watchdog or a watchcat, that is the question */
namespace HocI2c::wdt {
namespace i2c::wdt {
static bool isWdtEnabled = false;
@@ -128,7 +128,7 @@ namespace HocI2c::wdt {
const bool watchdogEnabled = file::config::GetConfigValue(HocClkConfigValue_Watchdog);
if (watchdogEnabled) {
Arm(HocI2c::wdt::MAX77620_WDT_2S);
Arm(i2c::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 HocI2c::wdt {
}
}
} // namespace HocI2c::wdt
} // namespace i2c::wdt
@@ -22,7 +22,7 @@
#include "i2cDrv.h"
#include "../file/errors.hpp"
namespace HocI2c::wdt {
namespace i2c::wdt {
typedef enum {
MAX77620_WDT_2S = 0, /* ~2 seconds */
@@ -38,4 +38,4 @@ namespace HocI2c::wdt {
void ResetWdtEnableState();
bool IsWdtEnabled();
} // namespace HocI2c::wdt
} // namespace i2c::wdt
@@ -17,11 +17,8 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#include "i2c.hpp"
#include "tmp451.hpp"
#include <switch.hpp>
using namespace nx;
#include "i2c.h"
#include "tmp451.h"
#define TMP451_WAIT_NS 1000000000UL
@@ -53,14 +50,14 @@ static Result _tmp451_get_temp(u8 reg, u8 dec_reg, s32 *out) {
}
static void _tmp451_update() {
u64 ticks = arm::GetSystemTick();
if (arm::TicksToNs(ticks - g_update_ticks) <= TMP451_WAIT_NS) {
u64 ticks = armGetSystemTick();
if (armTicksToNs(ticks - g_update_ticks) <= TMP451_WAIT_NS) {
return;
}
g_update_ticks = ticks;
if (!service::IsActive(&g_i2c_session.s)) {
if (!serviceIsActive(&g_i2c_session.s)) {
return;
}
@@ -69,18 +66,18 @@ static void _tmp451_update() {
}
Result tmp451Initialize(void) {
Result rc = i2c::Initialize();
Result rc = i2cInitialize();
if (R_SUCCEEDED(rc)) {
rc = i2c::OpenSession(&g_i2c_session, I2cDevice_Tmp451);
rc = i2cOpenSession(&g_i2c_session, I2cDevice_Tmp451);
}
return rc;
}
void tmp451Exit(void) {
i2csession::Close(&g_i2c_session);
i2c::Exit();
i2csessionClose(&g_i2c_session);
i2cExit();
}
s32 tmp451TempPcb(void) {
@@ -26,9 +26,17 @@
#pragma once
#include <switch.hpp>
using namespace nx;
#ifdef __cplusplus
extern "C" {
#endif
#include <switch.h>
Result tmp451Initialize(void);
void tmp451Exit(void);
s32 tmp451TempPcb(void);
s32 tmp451TempSoc(void);
#ifdef __cplusplus
}
#endif
@@ -26,20 +26,18 @@
#include <string.h>
#include "ipc_server.hpp"
using namespace nx;
#include "ipc_server.h"
Result ipcServerInit(IpcServer *server, const char *name, u32 max_sessions) {
if (max_sessions < 1 || max_sessions > (MAX_WAIT_OBJECTS - 1)) {
return MAKERESULT(Module_Libnx, LibnxError_BadInput);
}
server->srvName = sm::EncodeName(name);
server->srvName = smEncodeName(name);
server->max = max_sessions + 1;
server->count = 0;
Result rc = sm::RegisterService(&server->handles[0], server->srvName, false, max_sessions);
Result rc = smRegisterService(&server->handles[0], server->srvName, false, max_sessions);
if (R_SUCCEEDED(rc)) {
server->count = 1;
}
@@ -48,10 +46,10 @@ Result ipcServerInit(IpcServer *server, const char *name, u32 max_sessions) {
Result ipcServerExit(IpcServer *server) {
for (u32 i = 0; i < server->count; i++) {
svc::CloseHandle(server->handles[i]);
svcCloseHandle(server->handles[i]);
}
server->count = 0;
return sm::UnregisterService(server->srvName);
return smUnregisterService(server->srvName);
}
static Result _ipcServerAddSession(IpcServer *server, Handle session) {
@@ -69,7 +67,7 @@ static Result _ipcServerDeleteSession(IpcServer *server, u32 index) {
return MAKERESULT(Module_Libnx, LibnxError_BadInput);
}
svc::CloseHandle(server->handles[index]);
svcCloseHandle(server->handles[index]);
for (u32 j = index; j < (server->count - 1); j++) {
server->handles[j] = server->handles[j + 1];
@@ -79,15 +77,15 @@ static Result _ipcServerDeleteSession(IpcServer *server, u32 index) {
}
static Result _ipcServerParseRequest(IpcServerRequest *r) {
u8 *base = (u8*)armGetTls();
u8 *base = armGetTls();
r->hipc = hipc::ParseRequest(base);
r->hipc = hipcParseRequest(base);
r->data.cmdId = 0;
r->data.size = 0;
r->data.ptr = NULL;
if (r->hipc.meta.type == CmifCommandType_Request) {
IpcServerRawHeader *header = (IpcServerRawHeader*)cmif::GetAlignedDataStart(r->hipc.data.data_words, base);
IpcServerRawHeader *header = cmifGetAlignedDataStart(r->hipc.data.data_words, base);
size_t dataSize = r->hipc.meta.num_data_words * 4;
if (!header || dataSize < sizeof(IpcServerRawHeader) || header->magic != CMIF_IN_HEADER_MAGIC) {
@@ -105,11 +103,11 @@ static Result _ipcServerParseRequest(IpcServerRequest *r) {
}
static void _ipcServerPrepareResponse(Result rc, void *data, size_t dataSize) {
u8 *base = (u8*)arm::GetTls();
u8 *base = armGetTls();
HipcRequest hipc =
hipcMakeRequestInline(base, .type = CmifCommandType_Request, .num_data_words = (u32)(sizeof(IpcServerRawHeader) + dataSize + 0x10) / 4, );
hipcMakeRequestInline(base, .type = CmifCommandType_Request, .num_data_words = (sizeof(IpcServerRawHeader) + dataSize + 0x10) / 4, );
IpcServerRawHeader *rawHeader = (IpcServerRawHeader*)cmif::GetAlignedDataStart(hipc.data_words, base);
IpcServerRawHeader *rawHeader = cmifGetAlignedDataStart(hipc.data_words, base);
rawHeader->magic = CMIF_OUT_HEADER_MAGIC;
rawHeader->result = rc;
@@ -120,9 +118,9 @@ static void _ipcServerPrepareResponse(Result rc, void *data, size_t dataSize) {
static Result _ipcServerProcessNewSession(IpcServer *server) {
Handle session;
Result rc = svc::AcceptSession(&session, server->handles[0]);
Result rc = svcAcceptSession(&session, server->handles[0]);
if (R_SUCCEEDED(rc) && R_FAILED(rc = _ipcServerAddSession(server, session))) {
svc::CloseHandle(session);
svcCloseHandle(session);
}
return rc;
}
@@ -134,7 +132,7 @@ static Result _ipcServerProcessSession(IpcServer *server, IpcServerRequestHandle
u8 data[IPC_SERVER_EXT_RESPONSE_MAX_DATA_SIZE];
bool close = false;
Result rc = svc::ReplyAndReceive(&unusedIndex, &server->handles[handleIndex], 1, 0, UINT64_MAX);
Result rc = svcReplyAndReceive(&unusedIndex, &server->handles[handleIndex], 1, 0, UINT64_MAX);
if (R_SUCCEEDED(rc)) {
rc = _ipcServerParseRequest(&r);
}
@@ -168,9 +166,9 @@ static Result _ipcServerProcessSession(IpcServer *server, IpcServerRequestHandle
Result ipcServerProcess(IpcServer *server, IpcServerRequestHandler handler, void *userdata) {
s32 handleIndex = -1;
Result rc = svc::WaitSynchronization(&handleIndex, server->handles, server->count, UINT64_MAX);
Result rc = svcWaitSynchronization(&handleIndex, server->handles, server->count, UINT64_MAX);
if (R_SUCCEEDED(rc) && (handleIndex < 0 || handleIndex >= (s32)server->count)) {
if (R_SUCCEEDED(rc) && (handleIndex < 0 || handleIndex >= server->count)) {
rc = MAKERESULT(Module_Libnx, LibnxError_NotFound);
}
@@ -31,7 +31,6 @@ extern "C" {
#endif
#include <switch.h>
#include <switch.hpp>
#define IPC_SERVER_EXT_RESPONSE_MAX_DATA_SIZE (0x100 - 0x10 - sizeof(IpcServerRawHeader))
@@ -25,11 +25,10 @@
*/
#include <cstring>
#include <i2c.hpp>
#include <max17050.hpp>
#include <i2c.h>
#include <max17050.h>
#include <switch.h>
#include <switch.hpp>
#include <tmp451.hpp>
#include <tmp451.h>
#include "../file/config.hpp"
#include "../file/errors.hpp"
@@ -38,11 +37,8 @@
#include "../hos/apm_ext.h"
#include "../mgr/clock_manager.hpp"
#include "ipc_service.hpp"
#include <ipc_server.hpp>
#include <ipc_server.h>
#include <lockable_mutex.h>
using namespace nx;
namespace ipcService {
namespace {
@@ -274,7 +270,7 @@ namespace ipcService {
void Initialize() {
std::int32_t priority;
Result rc = svc::GetThreadPriority(&priority, CUR_THREAD_HANDLE);
Result rc = svcGetThreadPriority(&priority, CUR_THREAD_HANDLE);
ASSERT_RESULT_OK(rc, "svcGetThreadPriority");
rc = ipcServerInit(&gServer, HOCCLK_IPC_SERVICE_NAME, 42);
ASSERT_RESULT_OK(rc, "ipcServerInit");
@@ -285,7 +281,7 @@ namespace ipcService {
void Exit() {
SetRunning(false);
Result rc = thread::Close(&gThread);
Result rc = threadClose(&gThread);
ASSERT_RESULT_OK(rc, "threadClose");
rc = ipcServerExit(&gServer);
ASSERT_RESULT_OK(rc, "ipcServerExit");
@@ -300,11 +296,11 @@ namespace ipcService {
gRunning = running;
if (running) {
Result rc = thread::Start(&gThread);
Result rc = threadStart(&gThread);
ASSERT_RESULT_OK(rc, "threadStart");
} else {
svc::CancelSynchronization(gThread.handle);
thread::WaitForExit(&gThread);
svcCancelSynchronization(gThread.handle);
threadWaitForExit(&gThread);
}
}
+16 -17
View File
@@ -28,7 +28,7 @@
#include <cstring>
#include <malloc.h>
#include <switch.h>
#include <switch.hpp>
#include "board/board.hpp"
#include "file/config.hpp"
#include "file/errors.hpp"
@@ -41,7 +41,6 @@
#define INNER_HEAP_SIZE 0x40000
extern "C" {
using namespace nx;
void virtmemSetup(void);
extern std::uint32_t __start__;
@@ -87,43 +86,43 @@ void __libnx_initheap(void) {
}
void __appInit(void) {
if (R_FAILED(sm::Initialize())) {
if (R_FAILED(smInitialize())) {
fatalThrow(MAKERESULT(Module_Libnx, LibnxError_InitFail_SM));
}
Result rc = setsys::Initialize();
Result rc = setsysInitialize();
if (R_SUCCEEDED(rc)) {
SetSysFirmwareVersion fw;
rc = setsys::GetFirmwareVersion(&fw);
rc = setsysGetFirmwareVersion(&fw);
if (R_SUCCEEDED(rc))
hosversion::Set(MAKEHOSVERSION(fw.major, fw.minor, fw.micro));
setsys::Exit();
hosversionSet(MAKEHOSVERSION(fw.major, fw.minor, fw.micro));
setsysExit();
}
// rc = fanInitialize();
// if (R_FAILED(rc))
// diagAbortWithResult(MAKERESULT(Module_Libnx, LibnxError_ShouldNotHappen));
rc = i2c::Initialize();
rc = i2cInitialize();
if (R_FAILED(rc))
diag::AbortWithResult(MAKERESULT(Module_Libnx, LibnxError_ShouldNotHappen));
diagAbortWithResult(MAKERESULT(Module_Libnx, LibnxError_ShouldNotHappen));
}
void __appExit(void) {
// CloseFanControllerThread();
// fanExit();
i2c::Exit();
setsys::Exit();
fsdev::UnmountAll();
fs::Exit();
sm::Exit();
i2cExit();
setsysExit();
fsdevUnmountAll();
fsExit();
smExit();
}
}
int main(int argc, char **argv) {
Result rc = file::utils::Initialize();
if (R_FAILED(rc)) {
fatal::Throw(rc);
fatalThrow(rc);
return 1;
}
file::config::Initialize();
@@ -157,7 +156,7 @@ int main(int argc, char **argv) {
board::Exit();
file::config::Exit();
file::utils::LogLine("Exiting hoc-clk");
svc::SleepThread(1000000ULL);
svcSleepThread(1000000ULL);
file::utils::Exit();
return 0;
@@ -16,18 +16,15 @@
*/
#include <switch.h>
#include <switch.hpp>
#include "../file/file_utils.hpp"
using namespace nx;
Result QueryMemoryMapping(u64 *virtaddr, u64 physaddr, u64 size) {
if (hosversionAtLeast(10, 0, 0)) {
u64 out_size;
return svc::QueryMemoryMapping(virtaddr, &out_size, physaddr, size);
return svcQueryMemoryMapping(virtaddr, &out_size, physaddr, size);
} else {
return svc::LegacyQueryIoMapping(virtaddr, physaddr, size);
return svcLegacyQueryIoMapping(virtaddr, physaddr, size);
}
}
@@ -27,7 +27,7 @@
#include <crc32.h>
#include <cstdio>
#include <cstring>
#include <i2c.hpp>
#include <i2c.h>
#include "../board/board.hpp"
#include "../display/aula.hpp"
@@ -45,10 +45,7 @@
#include "clock_manager.hpp"
#include "governor.hpp"
#include "../i2c/max77620_wdt.hpp"
#include "../hos/clkrst_ext.hpp"
#include <switch.hpp>
using namespace nx;
#define HOSPPC_HAS_BOOST (hosversionAtLeast(7, 0, 0))
@@ -812,7 +809,7 @@ namespace mgr {
else
gContext.resolutionHeight = 0; // N/A
gContext.isWdtEnabled = HocI2c::wdt::IsWdtEnabled();
gContext.isWdtEnabled = i2c::wdt::IsWdtEnabled();
return hasChanged;
}
@@ -871,7 +868,6 @@ namespace mgr {
}
mgr::StartThreads();
}
void Exit() {
@@ -917,7 +913,7 @@ namespace mgr {
}
void WaitForNextTick() {
HocI2c::wdt::Pet();
svc::SleepThread(file::config::GetConfigValue(HocClkConfigValue_PollingIntervalMs) * 1000000ULL);
i2c::wdt::Pet();
svcSleepThread(file::config::GetConfigValue(HocClkConfigValue_PollingIntervalMs) * 1000000ULL);
}
} // namespace mgr
@@ -19,8 +19,6 @@
#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
@@ -142,7 +140,7 @@ namespace mgr {
cpuLastHz = 0;
gpuDownHoldRemaining = 0;
gpuLastHz = 0;
svc::SleepThread(pollNs);
svcSleepThread(pollNs);
continue;
}
@@ -304,23 +302,23 @@ namespace mgr {
if (++vrrTick > 50) {
vrrTick = 0;
board::SetHz(HocClkModule_Display, maxDisplay);
svc::SleepThread(50'000'000);
svcSleepThread(50'000'000);
}
}
}
}
}
svc::SleepThread(pollNs);
svcSleepThread(pollNs);
}
}
void StartThreads() {
thread::Create(&governorTHREAD, GovernorThread, nullptr, NULL, 0x2000, 0x3F, -2);
thread::Start(&governorTHREAD);
threadCreate(&governorTHREAD, GovernorThread, nullptr, NULL, 0x2000, 0x3F, -2);
threadStart(&governorTHREAD);
}
void ExitThreads() {
thread::Close(&governorTHREAD);
threadClose(&governorTHREAD);
}
} // namespace mgr
@@ -17,15 +17,11 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#include "t210.hpp"
#include <hocclk.h>
#include <switch.hpp>
using namespace nx;
#include "t210.h"
#define WAIT_NS 1000000000UL
#define usleep(x) (svc::SleepThread(1000UL * x))
#define usleep(x) svcSleepThread(1000UL * x)
#define GPU_TRIM_SYS_GPCPLL_COEFF 0x4
#define GPU_TRIM_SYS_GPCPLL(x) (*(volatile u32 *)(g_gpu_base + 0x137000ul + (x)))
@@ -177,9 +173,9 @@ static u32 _actmon_dev_get_count_avg(actmon_dev_t dev) {
static inline Result _svcQueryMemoryMappingFallback(u64 *virtaddr, u64 physaddr, u64 size) {
if (hosversionAtLeast(10, 0, 0)) {
u64 out_size;
return svc::QueryMemoryMapping(virtaddr, &out_size, physaddr, size);
return svcQueryMemoryMapping(virtaddr, &out_size, physaddr, size);
} else {
return svc::LegacyQueryIoMapping(virtaddr, physaddr, size);
return svcLegacyQueryIoMapping(virtaddr, physaddr, size);
}
}
@@ -17,7 +17,7 @@
*
*/
#include <i2c.hpp>
#include <i2c.h>
#include "../board/board.hpp"
#include "../i2c/i2cDrv.h"
@@ -30,7 +30,6 @@
#include "soctherm.hpp"
#include "tsensor_common.hpp"
using namespace nx;
namespace tsensor {
@@ -506,7 +505,7 @@ namespace tsensor {
}
/* Wait for HW recalibration */
svc::SleepThread(25'000);
svcSleepThread(25'000);
temps.cpu = TranslateTemp(ReadReg(socthermVa, SENSOR_TEMP1) >> 16);
temps.gpu = TranslateTemp(ReadReg(socthermVa, SENSOR_TEMP1) & SENSOR_TEMP1_GPU_TEMP_MASK);
@@ -529,7 +528,7 @@ namespace tsensor {
WriteReg(carVa, CAR_CLK_SOURCE_TSENSOR, CAR_CLK_SOURCE_TSENSOR_VAL);
SetBits(carVa, CAR_CLK_OUT_ENB_V, 0x10);
svc::SleepThread(2000);
svcSleepThread(2000);
TSensorSharedCalib sharedCal = {};
CalcSharedCal(&tfuse, &sharedCal, fuseVa);