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
+245 -34096

No files matched your search

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