VERY experimental Nintendo Switch 2 emulator
C++
[hle] Fixes for nxident, nxmp and nxplay, remove hbl.nsp workarounds (#3996)
lizzie3875093c70e3
diff --git a/src/core/CMakeLists.txt b/src/core/CMakeLists.txtindex 04d63c18b8..16806ff0c0 100644--- a/src/core/CMakeLists.txt+++ b/src/core/CMakeLists.txt@@ -1121,6 +1121,10 @@ add_library(core STATIChle/service/vi/vi_types.hhle/service/vi/vsync_manager.cpphle/service/vi/vsync_manager.h+ hle/service/gpio/gpio.cpp+ hle/service/gpio/gpio.h+ hle/service/i2c/i2c.cpp+ hle/service/i2c/i2c.hinternal_network/emu_net_state.cppinternal_network/emu_net_state.hinternal_network/network.cppdiff --git a/src/core/hle/kernel/k_process.cpp b/src/core/hle/kernel/k_process.cppindex 70e578f22a..364f44849b 100644--- a/src/core/hle/kernel/k_process.cpp+++ b/src/core/hle/kernel/k_process.cpp@@ -1174,8 +1174,7 @@ KProcess::KProcess(KernelCore& kernel)KProcess::~KProcess() = default;-Result KProcess::LoadFromMetadata(const FileSys::ProgramMetadata& metadata, std::size_t code_size,- KProcessAddress aslr_space_start, size_t aslr_space_offset, bool is_hbl) {+Result KProcess::LoadFromMetadata(const FileSys::ProgramMetadata& metadata, std::size_t code_size, KProcessAddress aslr_space_start, size_t aslr_space_offset) {// Create a resource limit for the process.const auto pool = static_cast<KMemoryManager::Pool>(metadata.GetPoolPartition());const auto physical_memory_size = m_kernel.MemoryManager().GetSize(pool);@@ -1247,7 +1246,6 @@ Result KProcess::LoadFromMetadata(const FileSys::ProgramMetadata& metadata, std:aslr_space_start));// Assign remaining properties.- m_is_hbl = is_hbl;m_ideal_core_id = metadata.GetMainThreadCore();// Set up emulation context.diff --git a/src/core/hle/kernel/k_process.h b/src/core/hle/kernel/k_process.hindex 975448f0dd..b3922444cc 100644--- a/src/core/hle/kernel/k_process.h+++ b/src/core/hle/kernel/k_process.h@@ -133,7 +133,6 @@ private:bool m_is_initialized : 1 = false;bool m_is_application : 1 = false;bool m_is_default_application_system_resource : 1 = false;- bool m_is_hbl : 1 = false;bool m_is_suspended : 1 = false;bool m_is_immortal : 1 = false;bool m_is_handle_table_initialized : 1 = false;@@ -277,10 +276,6 @@ public:return m_capabilities.CanForceDebug();}- bool IsHbl() const {- return m_is_hbl;- }-u32 GetAllocateOption() const {return m_page_table.GetAllocateOption();}@@ -514,8 +509,7 @@ public:}public:- Result LoadFromMetadata(const FileSys::ProgramMetadata& metadata, std::size_t code_size,- KProcessAddress aslr_space_start, size_t aslr_space_offset, bool is_hbl);+ Result LoadFromMetadata(const FileSys::ProgramMetadata& metadata, std::size_t code_size, KProcessAddress aslr_space_start, size_t aslr_space_offset);void LoadModule(CodeSet code_set, KProcessAddress base_addr);diff --git a/src/core/hle/kernel/svc/svc_exception.cpp b/src/core/hle/kernel/svc/svc_exception.cppindex 47b7568288..bf09641bad 100644--- a/src/core/hle/kernel/svc/svc_exception.cpp+++ b/src/core/hle/kernel/svc/svc_exception.cpp@@ -1,3 +1,6 @@+// SPDX-FileCopyrightText: Copyright 2026 Eden Emulator Project+// SPDX-License-Identifier: GPL-3.0-or-later+// SPDX-FileCopyrightText: Copyright 2023 yuzu Emulator Project// SPDX-License-Identifier: GPL-2.0-or-later@@ -106,9 +109,7 @@ void Break(Core::System& system, BreakReason reason, u64 info1, u64 info2) {system.CurrentPhysicalCore().LogBacktrace();}- const bool is_hbl = GetCurrentProcess(system.Kernel()).IsHbl();- const bool should_break = is_hbl || !notification_only;-+ const bool should_break = !notification_only;if (system.DebuggerEnabled() && should_break) {auto* thread = system.Kernel().GetCurrentEmuThread();system.GetDebugger().NotifyThreadStopped(thread);diff --git a/src/core/hle/service/am/applet.h b/src/core/hle/service/am/applet.hindex a693a47d7a..1121fe221e 100644--- a/src/core/hle/service/am/applet.h+++ b/src/core/hle/service/am/applet.h@@ -1,4 +1,4 @@-// SPDX-FileCopyrightText: Copyright 2025 Eden Emulator Project+// SPDX-FileCopyrightText: Copyright 2026 Eden Emulator Project// SPDX-License-Identifier: GPL-3.0-or-later// SPDX-FileCopyrightText: Copyright 2024 yuzu Emulator Project@@ -83,6 +83,7 @@ struct Applet {// Application functionsbool game_play_recording_supported{};+ bool media_playback_state{};GamePlayRecordingState game_play_recording_state{GamePlayRecordingState::Disabled};bool jit_service_launched{};bool application_crash_report_enabled{};diff --git a/src/core/hle/service/am/service/application_functions.cpp b/src/core/hle/service/am/service/application_functions.cppindex 9ab343e59e..787c88f52d 100644--- a/src/core/hle/service/am/service/application_functions.cpp+++ b/src/core/hle/service/am/service/application_functions.cpp@@ -11,6 +11,7 @@#include "core/file_sys/registered_cache.h"#include "core/file_sys/savedata_factory.h"#include "core/hle/kernel/k_transfer_memory.h"+#include "core/hle/result.h"#include "core/hle/service/am/am_results.h"#include "core/hle/service/am/applet.h"#include "core/hle/service/am/service/application_functions.h"@@ -56,7 +57,7 @@ IApplicationFunctions::IApplicationFunctions(Core::System& system_, std::shared_{37, nullptr, "GetLimitedApplicationLicenseUpgradableEvent"},{40, D<&IApplicationFunctions::NotifyRunning>, "NotifyRunning"},{50, D<&IApplicationFunctions::GetPseudoDeviceId>, "GetPseudoDeviceId"},- {60, nullptr, "SetMediaPlaybackStateForApplication"},+ {60, D<&IApplicationFunctions::SetMediaPlaybackStateForApplication>, "SetMediaPlaybackStateForApplication"},{65, D<&IApplicationFunctions::IsGamePlayRecordingSupported>, "IsGamePlayRecordingSupported"},{66, D<&IApplicationFunctions::InitializeGamePlayRecording>, "InitializeGamePlayRecording"},{67, D<&IApplicationFunctions::SetGamePlayRecordingState>, "SetGamePlayRecordingState"},@@ -364,6 +365,13 @@ Result IApplicationFunctions::InitializeGamePlayRecording(R_SUCCEED();}+Result IApplicationFunctions::SetMediaPlaybackStateForApplication(bool enabled) {+ LOG_WARNING(Service_AM, "(stubbed) {}", enabled);+ std::scoped_lock lk{m_applet->lock};+ m_applet->media_playback_state = enabled;+ R_SUCCEED();+}+Result IApplicationFunctions::SetGamePlayRecordingState(GamePlayRecordingState game_play_recording_state) {LOG_WARNING(Service_AM, "(STUBBED) called");diff --git a/src/core/hle/service/am/service/application_functions.h b/src/core/hle/service/am/service/application_functions.hindex abee2f9d47..b97ed7e25e 100644--- a/src/core/hle/service/am/service/application_functions.h+++ b/src/core/hle/service/am/service/application_functions.h@@ -53,6 +53,7 @@ private:Result IsGamePlayRecordingSupported(Out<bool> out_is_game_play_recording_supported);Result InitializeGamePlayRecording(u64 transfer_memory_size, InCopyHandle<Kernel::KTransferMemory> transfer_memory_handle);+ Result SetMediaPlaybackStateForApplication(bool enabled);Result SetGamePlayRecordingState(GamePlayRecordingState game_play_recording_state);Result EnableApplicationCrashReport(bool enabled);Result InitializeApplicationCopyrightFrameBuffer(diff --git a/src/core/hle/service/btm/btm_system_core.cpp b/src/core/hle/service/btm/btm_system_core.cppindex f1e623be16..318657fc32 100644--- a/src/core/hle/service/btm/btm_system_core.cpp+++ b/src/core/hle/service/btm/btm_system_core.cpp@@ -29,7 +29,7 @@ IBtmSystemCore::IBtmSystemCore(Core::System& system_){10, nullptr, "StartAudioDeviceDiscovery"},{11, nullptr, "StopAudioDeviceDiscovery"},{12, nullptr, "IsDiscoveryingAudioDevice"},- {13, nullptr, "GetDiscoveredAudioDevice"},+ {13, C<&IBtmSystemCore::GetDiscoveredAudioDevice>, "GetDiscoveredAudioDevice"},{14, C<&IBtmSystemCore::AcquireAudioDeviceConnectionEvent>, "AcquireAudioDeviceConnectionEvent"},{15, nullptr, "ConnectAudioDevice"},{16, nullptr, "IsConnectingAudioDevice"},@@ -93,6 +93,11 @@ Result IBtmSystemCore::AcquireRadioEvent(Out<bool> out_is_valid,R_SUCCEED();}+Result IBtmSystemCore::GetDiscoveredAudioDevice(OutArray<std::array<u8, 0xFF>, BufferAttr_HipcPointer> out_audio_devices, s32 count, Out<s32> out_total) {+ LOG_WARNING(Service_BTM, "(STUBBED) called");+ R_SUCCEED();+}+Result IBtmSystemCore::AcquireAudioDeviceConnectionEvent(OutCopyHandle<Kernel::KReadableEvent> out_event) {LOG_WARNING(Service_BTM, "(STUBBED) called");diff --git a/src/core/hle/service/btm/btm_system_core.h b/src/core/hle/service/btm/btm_system_core.hindex 06498b21ea..3fc4c0d56c 100644--- a/src/core/hle/service/btm/btm_system_core.h+++ b/src/core/hle/service/btm/btm_system_core.h@@ -1,3 +1,6 @@+// SPDX-FileCopyrightText: Copyright 2026 Eden Emulator Project+// SPDX-License-Identifier: GPL-3.0-or-later+// SPDX-FileCopyrightText: Copyright 2024 yuzu Emulator Project// SPDX-License-Identifier: GPL-3.0-or-later@@ -34,9 +37,8 @@ private:Result DisableRadio();Result IsRadioEnabled(Out<bool> out_is_enabled);- Result AcquireRadioEvent(Out<bool> out_is_valid,- OutCopyHandle<Kernel::KReadableEvent> out_event);-+ Result AcquireRadioEvent(Out<bool> out_is_valid, OutCopyHandle<Kernel::KReadableEvent> out_event);+ Result GetDiscoveredAudioDevice(OutArray<std::array<u8, 0xFF>, BufferAttr_HipcPointer> out_audio_devices, s32 count, Out<s32> out_total);Result AcquireAudioDeviceConnectionEvent(OutCopyHandle<Kernel::KReadableEvent> out_event);Result GetConnectedAudioDevices(diff --git a/src/core/hle/service/gpio/gpio.cpp b/src/core/hle/service/gpio/gpio.cppnew file mode 100644index 0000000000..8b4aa0f5ab--- /dev/null+++ b/src/core/hle/service/gpio/gpio.cpp@@ -0,0 +1,33 @@+// SPDX-FileCopyrightText: Copyright 2026 Eden Emulator Project+// SPDX-License-Identifier: GPL-3.0-or-later++// SPDX-FileCopyrightText: Copyright 2018 yuzu Emulator Project+// SPDX-License-Identifier: GPL-2.0-or-later++#include "core/core.h"+#include "core/hle/service/gpio/gpio.h"+#include "core/hle/service/ipc_helpers.h"+#include "core/hle/service/service.h"++namespace Service::GPIO {++class GPIO final : public ServiceFramework<GPIO> {+public:+ explicit GPIO(Core::System& system_)+ : ServiceFramework{system_, "gpio"}+ {+ static const FunctionInfo functions[] = {+ {0, nullptr, "Cmd0"},+ };+ RegisterHandlers(functions);+ }+ ~GPIO() override = default;+};++void LoopProcess(Core::System& system) {+ auto server_manager = std::make_unique<ServerManager>(system);+ server_manager->RegisterNamedService("gpio", std::make_shared<GPIO>(system));+ ServerManager::RunServer(std::move(server_manager));+}++} // namespace Service::GPIOdiff --git a/src/core/hle/service/gpio/gpio.h b/src/core/hle/service/gpio/gpio.hnew file mode 100644index 0000000000..57f9a64e56--- /dev/null+++ b/src/core/hle/service/gpio/gpio.h@@ -0,0 +1,15 @@+// SPDX-FileCopyrightText: Copyright 2026 Eden Emulator Project+// SPDX-License-Identifier: GPL-3.0-or-later++// SPDX-FileCopyrightText: Copyright 2018 yuzu Emulator Project+// SPDX-License-Identifier: GPL-2.0-or-later++#pragma once++namespace Core {+class System;+}++namespace Service::GPIO {+void LoopProcess(Core::System& system);+} // namespace Service::GPIOdiff --git a/src/core/hle/service/i2c/i2c.cpp b/src/core/hle/service/i2c/i2c.cppnew file mode 100644index 0000000000..d000487246--- /dev/null+++ b/src/core/hle/service/i2c/i2c.cpp@@ -0,0 +1,76 @@+// SPDX-FileCopyrightText: Copyright 2026 Eden Emulator Project+// SPDX-License-Identifier: GPL-3.0-or-later++// SPDX-FileCopyrightText: Copyright 2018 yuzu Emulator Project+// SPDX-License-Identifier: GPL-2.0-or-later++#include "core/core.h"+#include "core/hle/result.h"+#include "core/hle/service/i2c/i2c.h"+#include "core/hle/service/ipc_helpers.h"+#include "core/hle/service/cmif_serialization.h"+#include "core/hle/service/cmif_types.h"+#include "core/hle/service/service.h"+#include "core/hle/service/server_manager.h"++namespace Service::I2C {++class I2CSession final : public ServiceFramework<I2CSession> {+public:+ explicit I2CSession(Core::System& system_)+ : ServiceFramework{system_, "I2CSession"}+ {+ static const FunctionInfo functions[] = {+ {0, nullptr, "SendOld"},+ {1, nullptr, "ReceiveOld"},+ {2, nullptr, "ExecuteCommandListOld"},+ {10, C<&I2CSession::Send>, "Send"},+ {11, nullptr, "Receive"},+ {12, nullptr, "ExecuteCommandList"},+ {13, nullptr, "SetRetryPolicy"},+ };+ RegisterHandlers(functions);+ }+ ~I2CSession() override = default;++ Result Send(InBuffer<BufferAttr_HipcMapAlias> in_data, u32 transaction_option) {+ LOG_WARNING(Service, "(stubbed) topt={}", transaction_option);+ R_THROW(ResultUnknown);+ }+};++enum class I2CDevice : u32 {+ ClassicController,+ Ftm3bd56,+};++class I2C final : public ServiceFramework<I2C> {+public:+ explicit I2C(Core::System& system_)+ : ServiceFramework{system_, "i2c"}+ {+ static const FunctionInfo functions[] = {+ {0, nullptr, "OpenSessionForDev"},+ {1, C<&I2C::OpenSession>, "OpenSession"},+ {2, nullptr, "HasDevice"},+ {3, nullptr, "HasDeviceForDev"},+ {4, nullptr, "OpenSession2"},+ };+ RegisterHandlers(functions);+ }+ ~I2C() override = default;++ Result OpenSession(I2CDevice device, OutInterface<I2CSession> out_session) {+ LOG_DEBUG(Service, "(stubbed)");+ *out_session = std::make_shared<I2CSession>(system);+ R_SUCCEED();+ }+};++void LoopProcess(Core::System& system) {+ auto server_manager = std::make_unique<ServerManager>(system);+ server_manager->RegisterNamedService("i2c", std::make_shared<I2C>(system));+ ServerManager::RunServer(std::move(server_manager));+}++} // namespace Service::I2Cdiff --git a/src/core/hle/service/i2c/i2c.h b/src/core/hle/service/i2c/i2c.hnew file mode 100644index 0000000000..c26df8e86f--- /dev/null+++ b/src/core/hle/service/i2c/i2c.h@@ -0,0 +1,15 @@+// SPDX-FileCopyrightText: Copyright 2026 Eden Emulator Project+// SPDX-License-Identifier: GPL-3.0-or-later++// SPDX-FileCopyrightText: Copyright 2018 yuzu Emulator Project+// SPDX-License-Identifier: GPL-2.0-or-later++#pragma once++namespace Core {+class System;+}++namespace Service::I2C {+void LoopProcess(Core::System& system);+} // namespace Service::I2Cdiff --git a/src/core/hle/service/nvdrv/devices/nvhost_ctrl_gpu.cpp b/src/core/hle/service/nvdrv/devices/nvhost_ctrl_gpu.cppindex ace1f7e8f7..b621e5d70d 100644--- a/src/core/hle/service/nvdrv/devices/nvhost_ctrl_gpu.cpp+++ b/src/core/hle/service/nvdrv/devices/nvhost_ctrl_gpu.cpp@@ -47,6 +47,8 @@ NvResult nvhost_ctrl_gpu::Ioctl1(DeviceFD fd, Ioctl command, std::span<const u8>return WrapFixed(this, &nvhost_ctrl_gpu::FlushL2, input, output);case 0x14:return WrapFixed(this, &nvhost_ctrl_gpu::GetActiveSlotMask, input, output);+ case 0x15:+ return WrapFixed(this, &nvhost_ctrl_gpu::PmuGetGpuLoad, input, output);case 0x1c:return WrapFixed(this, &nvhost_ctrl_gpu::GetGpuTime, input, output);default:@@ -234,6 +236,12 @@ NvResult nvhost_ctrl_gpu::GetActiveSlotMask(IoctlActiveSlotMask& params) {return NvResult::Success;}+NvResult nvhost_ctrl_gpu::PmuGetGpuLoad(IoctlPmuGetLoad& params) {+ LOG_WARNING(Service_NVDRV, "(stubbed) called");+ params.pmu_gpu_load = 100;+ return NvResult::Success;+}+NvResult nvhost_ctrl_gpu::ZCullGetCtxSize(IoctlZcullGetCtxSize& params) {LOG_DEBUG(Service_NVDRV, "called");params.size = 0x1;diff --git a/src/core/hle/service/nvdrv/devices/nvhost_ctrl_gpu.h b/src/core/hle/service/nvdrv/devices/nvhost_ctrl_gpu.hindex e0603f9a71..80b7abd6a1 100644--- a/src/core/hle/service/nvdrv/devices/nvhost_ctrl_gpu.h+++ b/src/core/hle/service/nvdrv/devices/nvhost_ctrl_gpu.h@@ -1,4 +1,4 @@-// SPDX-FileCopyrightText: Copyright 2025 Eden Emulator Project+// SPDX-FileCopyrightText: Copyright 2026 Eden Emulator Project// SPDX-License-Identifier: GPL-3.0-or-later// SPDX-FileCopyrightText: Copyright 2018 yuzu Emulator Project@@ -184,6 +184,11 @@ private:};static_assert(sizeof(IoctlGetCpuTimeCorrelationInfo) == 264);+ struct IoctlPmuGetLoad {+ u32 pmu_gpu_load;+ };+ static_assert(sizeof(IoctlPmuGetLoad) == 4);+NvResult GetCharacteristics1(IoctlCharacteristics& params);NvResult GetCharacteristics3(IoctlCharacteristics& params,std::span<IoctlGpuCharacteristics> gpu_characteristics);@@ -192,6 +197,7 @@ private:NvResult GetTPCMasks3(IoctlGpuGetTpcMasksArgs& params, std::span<u32> tpc_mask);NvResult GetActiveSlotMask(IoctlActiveSlotMask& params);+ NvResult PmuGetGpuLoad(IoctlPmuGetLoad& params);NvResult ZCullGetCtxSize(IoctlZcullGetCtxSize& params);NvResult ZCullGetInfo(IoctlNvgpuGpuZcullGetInfoArgs& params);NvResult ZBCSetTable(IoctlZbcSetTable& params);diff --git a/src/core/hle/service/nvdrv/devices/nvhost_nvdec.cpp b/src/core/hle/service/nvdrv/devices/nvhost_nvdec.cppindex d64658bddc..7ac3dfaa46 100644--- a/src/core/hle/service/nvdrv/devices/nvhost_nvdec.cpp+++ b/src/core/hle/service/nvdrv/devices/nvhost_nvdec.cpp@@ -25,18 +25,20 @@ NvResult nvhost_nvdec::Ioctl1(DeviceFD fd, Ioctl command, std::span<const u8> inswitch (command.group) {case 0x0:switch (command.cmd) {- case 0x1:+ case 0x01:return WrapFixedVariable(this, &nvhost_nvdec::Submit, input, output, fd);- case 0x2:+ case 0x02:return WrapFixed(this, &nvhost_nvdec::GetSyncpoint, input, output);- case 0x3:+ case 0x03:return WrapFixed(this, &nvhost_nvdec::GetWaitbase, input, output);- case 0x7:+ case 0x07:return WrapFixed(this, &nvhost_nvdec::SetSubmitTimeout, input, output);- case 0x9:+ case 0x09:return WrapFixedVariable(this, &nvhost_nvdec::MapBuffer, input, output, fd);- case 0xa:+ case 0x0a:return WrapFixedVariable(this, &nvhost_nvdec::UnmapBuffer, input, output);+ case 0x23:+ return WrapFixed(this, &nvhost_nvdec::GetClkRate, input, output);default:break;}diff --git a/src/core/hle/service/nvdrv/devices/nvhost_nvdec_common.cpp b/src/core/hle/service/nvdrv/devices/nvhost_nvdec_common.cppindex c726d6f93e..698712e152 100644--- a/src/core/hle/service/nvdrv/devices/nvhost_nvdec_common.cpp+++ b/src/core/hle/service/nvdrv/devices/nvhost_nvdec_common.cpp@@ -168,6 +168,13 @@ NvResult nvhost_nvdec_common::SetSubmitTimeout(u32 timeout) {return NvResult::Success;}+NvResult nvhost_nvdec_common::GetClkRate(IoctlGetClkRate& params) {+ LOG_WARNING(Service_NVDRV, "(STUBBED) called");+ params.clk_rate = 614400000;+ params.module_id = 0;+ return NvResult::Success;+}+Kernel::KEvent* nvhost_nvdec_common::QueryEvent(u32 event_id) {LOG_CRITICAL(Service_NVDRV, "Unknown HOSTX1 Event {}", event_id);return nullptr;diff --git a/src/core/hle/service/nvdrv/devices/nvhost_nvdec_common.h b/src/core/hle/service/nvdrv/devices/nvhost_nvdec_common.hindex 6b66a0d28d..8b3b7ee285 100644--- a/src/core/hle/service/nvdrv/devices/nvhost_nvdec_common.h+++ b/src/core/hle/service/nvdrv/devices/nvhost_nvdec_common.h@@ -111,6 +111,12 @@ protected:};static_assert(sizeof(IoctlMapBuffer) == 0x0C, "IoctlMapBuffer is incorrect size");+ struct IoctlGetClkRate {+ u32_le clk_rate{};+ u32_le module_id{};+ };+ static_assert(sizeof(IoctlGetClkRate) == 8);+/// Ioctl command implementationsNvResult SetNVMAPfd(IoctlSetNvmapFD&);NvResult Submit(IoctlSubmit& params, std::span<u8> input, DeviceFD fd);@@ -119,6 +125,7 @@ protected:NvResult MapBuffer(IoctlMapBuffer& params, std::span<MapBufferEntry> entries, DeviceFD fd);NvResult UnmapBuffer(IoctlMapBuffer& params, std::span<MapBufferEntry> entries);NvResult SetSubmitTimeout(u32 timeout);+ NvResult GetClkRate(IoctlGetClkRate& params);Kernel::KEvent* QueryEvent(u32 event_id) override;diff --git a/src/core/hle/service/ptm/psm.cpp b/src/core/hle/service/ptm/psm.cppindex f144b8e497..06396bbb4c 100644--- a/src/core/hle/service/ptm/psm.cpp+++ b/src/core/hle/service/ptm/psm.cpp@@ -6,10 +6,12 @@#include <memory>+#include "common/common_funcs.h"#include "common/device_power_state.h"#include "common/logging.h"#include "core/core.h"#include "core/hle/kernel/k_event.h"+#include "core/hle/result.h"#include "core/hle/service/ipc_helpers.h"#include "core/hle/service/kernel_helpers.h"#include "core/hle/service/ptm/psm.h"@@ -134,12 +136,12 @@ PSM::PSM(Core::System& system_) : ServiceFramework{system_, "psm"} {{9, nullptr, "DisableEnoughPowerChargeEmulation"},{10, nullptr, "EnableFastBatteryCharging"},{11, nullptr, "DisableFastBatteryCharging"},- {12, nullptr, "GetBatteryVoltageState"},+ {12, &PSM::GetBatteryVoltageState, "GetBatteryVoltageState"},{13, nullptr, "GetRawBatteryChargePercentage"},{14, nullptr, "IsEnoughPowerSupplied"},- {15, nullptr, "GetBatteryAgePercentage"},+ {15, &PSM::GetBatteryAgePercentage, "GetBatteryAgePercentage"},{16, nullptr, "GetBatteryChargeInfoEvent"},- {17, nullptr, "GetBatteryChargeInfoFields"},+ {17, &PSM::GetBatteryChargeInfoFields, "GetBatteryChargeInfoFields"},{18, nullptr, "GetBatteryChargeCalibratedEvent"},};// clang-format on@@ -187,4 +189,64 @@ void PSM::OpenSession(HLERequestContext& ctx) {rb.PushIpcInterface<IPsmSession>(system);}+void PSM::GetBatteryVoltageState(HLERequestContext& ctx) {+ LOG_DEBUG(Service_PTM, "(stubbed)");+ IPC::ResponseBuilder rb{ctx, 3};+ rb.Push(ResultSuccess);+ rb.PushRaw<u32>(0); //+}++void PSM::GetBatteryAgePercentage(HLERequestContext& ctx) {+ LOG_DEBUG(Service_PTM, "(stubbed)");+ IPC::ResponseBuilder rb{ctx, 3};+ rb.Push(ResultSuccess);+ rb.PushRaw<f64>(1.f);+}++struct BatteryChargeInfoFields {+ u32 input_current_limit; //mA+ u32 boost_mode_current_limit;+ u32 fast_charge_current_limit;+ u32 charge_voltage_limit;+ u32 charger_type;+ u8 hi2_mode;+ u8 battery_charging;+ INSERT_PADDING_BYTES_NOINIT(2);+ u32 vdd50_state;+ u32 temperature_celcius;+ f32 battery_charge_percentage;+ u32 battery_charge_milli_voltage;+ f32 battery_age_percentage;+ u32 usb_power_role;+ u32 usb_charger_type;+ u32 charger_input_voltage_limit;+ u32 charger_input_current_limit;+ u8 fast_battery_charging;+ u8 controller_power_supply;+ u8 otg_request;+ INSERT_PADDING_BYTES_NOINIT(1);+ INSERT_PADDING_BYTES_NOINIT(0x14); //[+17.0.0]+};+static_assert(sizeof(struct BatteryChargeInfoFields) == 0x54);+void PSM::GetBatteryChargeInfoFields(HLERequestContext& ctx) {+ LOG_DEBUG(Service_PTM, "called");+ Common::PowerStatus power_status = Common::GetPowerStatus();++ BatteryChargeInfoFields r{};+ r.battery_charge_percentage = f32(power_status.percentage); //100%+ r.battery_age_percentage = f32(power_status.percentage); //100%+ r.battery_charging = power_status.charging ? 1 : 0;+ r.charger_type = u32(power_status.has_battery && power_status.charging+ ? ChargerType::RegularCharger : ChargerType::Unplugged);+ r.charger_input_voltage_limit = 100;+ r.charger_input_voltage_limit = 100;+ r.input_current_limit = 100;+ r.boost_mode_current_limit = 100;+ r.fast_charge_current_limit = 100;++ IPC::ResponseBuilder rb{ctx, 3};+ rb.Push(ResultSuccess);+ rb.PushRaw<BatteryChargeInfoFields>(r);+}+} // namespace Service::PTMdiff --git a/src/core/hle/service/ptm/psm.h b/src/core/hle/service/ptm/psm.hindex 2853a45753..77c38d1f9b 100644--- a/src/core/hle/service/ptm/psm.h+++ b/src/core/hle/service/ptm/psm.h@@ -1,4 +1,4 @@-// SPDX-FileCopyrightText: Copyright 2025 Eden Emulator Project+// SPDX-FileCopyrightText: Copyright 2026 Eden Emulator Project// SPDX-License-Identifier: GPL-3.0-or-later// SPDX-FileCopyrightText: Copyright 2018 yuzu Emulator Project@@ -22,10 +22,12 @@ private:LowPowerCharger = 2,Unknown = 3,};-void GetBatteryChargePercentage(HLERequestContext& ctx);void GetChargerType(HLERequestContext& ctx);void OpenSession(HLERequestContext& ctx);+ void GetBatteryVoltageState(HLERequestContext& ctx);+ void GetBatteryAgePercentage(HLERequestContext& ctx);+ void GetBatteryChargeInfoFields(HLERequestContext& ctx);};} // namespace Service::PTMdiff --git a/src/core/hle/service/services.cpp b/src/core/hle/service/services.cppindex 636f54ad49..4dfdf9068f 100644--- a/src/core/hle/service/services.cpp+++ b/src/core/hle/service/services.cpp@@ -1,4 +1,4 @@-// SPDX-FileCopyrightText: Copyright 2025 Eden Emulator Project+// SPDX-FileCopyrightText: Copyright 2026 Eden Emulator Project// SPDX-License-Identifier: GPL-3.0-or-later// SPDX-FileCopyrightText: Copyright 2024 yuzu Emulator Project@@ -25,8 +25,10 @@#include "core/hle/service/friend/friend.h"#include "core/hle/service/glue/glue.h"#include "core/hle/service/grc/grc.h"+#include "core/hle/service/gpio/gpio.h"#include "core/hle/service/hid/hid.h"#include "core/hle/service/ipc_helpers.h"+#include "core/hle/service/i2c/i2c.h"#include "core/hle/service/jit/jit.h"#include "core/hle/service/lbl/lbl.h"#include "core/hle/service/ldn/ldn.h"@@ -144,7 +146,9 @@ Services::Services(std::shared_ptr<SM::ServiceManager>& sm, Core::System& system{"ro", &RO::LoopProcess},{"spl", &SPL::LoopProcess},{"ssl", &SSL::LoopProcess},- {"usb", &USB::LoopProcess}+ {"usb", &USB::LoopProcess},+ {"i2c", &I2C::LoopProcess},+ {"gpio", &GPIO::LoopProcess},})kernel.RunOnGuestCoreProcess(std::string(e.first), [&system, f = e.second] { f(system); });}diff --git a/src/core/hle/service/set/system_settings_server.cpp b/src/core/hle/service/set/system_settings_server.cppindex 0ed6d28dd4..7fa74e6689 100644--- a/src/core/hle/service/set/system_settings_server.cpp+++ b/src/core/hle/service/set/system_settings_server.cpp@@ -142,10 +142,10 @@ ISystemSettingsServer::ISystemSettingsServer(Core::System& system_){22, C<&ISystemSettingsServer::SetEulaVersions>, "SetEulaVersions"},{23, C<&ISystemSettingsServer::GetColorSetId>, "GetColorSetId"},{24, C<&ISystemSettingsServer::SetColorSetId>, "SetColorSetId"},- {25, nullptr, "GetConsoleInformationUploadFlag"},- {26, nullptr, "SetConsoleInformationUploadFlag"},- {27, nullptr, "GetAutomaticApplicationDownloadFlag"},- {28, nullptr, "SetAutomaticApplicationDownloadFlag"},+ {25, C<&ISystemSettingsServer::GetConsoleInformationUploadFlag>, "GetConsoleInformationUploadFlag"},+ {26, C<&ISystemSettingsServer::SetConsoleInformationUploadFlag>, "SetConsoleInformationUploadFlag"},+ {27, C<&ISystemSettingsServer::GetAutomaticApplicationDownloadFlag>, "GetAutomaticApplicationDownloadFlag"},+ {28, C<&ISystemSettingsServer::SetAutomaticApplicationDownloadFlag>, "SetAutomaticApplicationDownloadFlag"},{29, C<&ISystemSettingsServer::GetNotificationSettings>, "GetNotificationSettings"},{30, C<&ISystemSettingsServer::SetNotificationSettings>, "SetNotificationSettings"},{31, C<&ISystemSettingsServer::GetAccountNotificationSettings>, "GetAccountNotificationSettings"},@@ -160,8 +160,8 @@ ISystemSettingsServer::ISystemSettingsServer(Core::System& system_){42, nullptr, "SetEdid"},{43, C<&ISystemSettingsServer::GetAudioOutputMode>, "GetAudioOutputMode"},{44, C<&ISystemSettingsServer::SetAudioOutputMode>, "SetAudioOutputMode"},- {45, C<&ISystemSettingsServer::GetSpeakerAutoMuteFlag> , "GetSpeakerAutoMuteFlag"},- {46, C<&ISystemSettingsServer::SetSpeakerAutoMuteFlag> , "SetSpeakerAutoMuteFlag"},+ {45, C<&ISystemSettingsServer::GetSpeakerAutoMuteFlag>, "GetSpeakerAutoMuteFlag"},+ {46, C<&ISystemSettingsServer::SetSpeakerAutoMuteFlag>, "SetSpeakerAutoMuteFlag"},{47, C<&ISystemSettingsServer::GetQuestFlag>, "GetQuestFlag"},{48, C<&ISystemSettingsServer::SetQuestFlag>, "SetQuestFlag"},{49, nullptr, "GetDataDeletionSettings"},@@ -180,8 +180,8 @@ ISystemSettingsServer::ISystemSettingsServer(Core::System& system_){62, C<&ISystemSettingsServer::GetDebugModeFlag>, "GetDebugModeFlag"},{63, C<&ISystemSettingsServer::GetPrimaryAlbumStorage>, "GetPrimaryAlbumStorage"},{64, C<&ISystemSettingsServer::SetPrimaryAlbumStorage>, "SetPrimaryAlbumStorage"},- {65, nullptr, "GetUsb30EnableFlag"},- {66, nullptr, "SetUsb30EnableFlag"},+ {65, C<&ISystemSettingsServer::GetUsb30EnableFlag>, "GetUsb30EnableFlag"},+ {66, C<&ISystemSettingsServer::SetUsb30EnableFlag>, "SetUsb30EnableFlag"},{67, C<&ISystemSettingsServer::GetBatteryLot>, "GetBatteryLot"},{68, C<&ISystemSettingsServer::GetSerialNumber>, "GetSerialNumber"},{69, C<&ISystemSettingsServer::GetNfcEnableFlag>, "GetNfcEnableFlag"},@@ -1074,6 +1074,45 @@ Result ISystemSettingsServer::SetNfcEnableFlag(bool nfc_enable_flag) {R_SUCCEED();}+Result ISystemSettingsServer::GetConsoleInformationUploadFlag(Out<bool> out_flag) {+ LOG_INFO(Service_SET, "called {}", m_system_settings.console_information_upload_flag);+ *out_flag = m_system_settings.console_information_upload_flag;+ R_SUCCEED();+}++Result ISystemSettingsServer::SetConsoleInformationUploadFlag(bool flag) {+ LOG_INFO(Service_SET, "called {}", flag);+ m_system_settings.usb_30_enable_flag = flag;+ SetSaveNeeded();+ R_SUCCEED();+}++Result ISystemSettingsServer::GetAutomaticApplicationDownloadFlag(Out<bool> out_flag) {+ LOG_INFO(Service_SET, "called {}", m_system_settings.usb_30_enable_flag);+ *out_flag = m_system_settings.automatic_application_download_flag;+ R_SUCCEED();+}++Result ISystemSettingsServer::SetAutomaticApplicationDownloadFlag(bool flag) {+ LOG_INFO(Service_SET, "called {}", flag);+ m_system_settings.automatic_application_download_flag = flag;+ SetSaveNeeded();+ R_SUCCEED();+}++Result ISystemSettingsServer::GetUsb30EnableFlag(Out<bool> out_usb30_enable_flag) {+ LOG_INFO(Service_SET, "called, usb30_enable_flag={}", m_system_settings.usb_30_enable_flag);+ *out_usb30_enable_flag = m_system_settings.usb_30_enable_flag;+ R_SUCCEED();+}++Result ISystemSettingsServer::SetUsb30EnableFlag(bool usb30_enable_flag) {+ LOG_INFO(Service_SET, "called, usb30_enable_flag={}", usb30_enable_flag);+ m_system_settings.usb_30_enable_flag = usb30_enable_flag;+ SetSaveNeeded();+ R_SUCCEED();+}+Result ISystemSettingsServer::GetSleepSettings(Out<SleepSettings> out_sleep_settings) {LOG_INFO(Service_SET, "called, flags={}, handheld_sleep_plan={}, console_sleep_plan={}",m_system_settings.sleep_settings.flags.raw,diff --git a/src/core/hle/service/set/system_settings_server.h b/src/core/hle/service/set/system_settings_server.hindex 2a160dfc6b..1d56e61f88 100644--- a/src/core/hle/service/set/system_settings_server.h+++ b/src/core/hle/service/set/system_settings_server.h@@ -109,6 +109,12 @@ public:Result SetPrimaryAlbumStorage(PrimaryAlbumStorage primary_album_storage);Result GetBatteryLot(Out<BatteryLot> out_battery_lot);Result GetSerialNumber(Out<SerialNumber> out_console_serial);+ Result GetConsoleInformationUploadFlag(Out<bool> out_flag);+ Result SetConsoleInformationUploadFlag(bool flag);+ Result GetAutomaticApplicationDownloadFlag(Out<bool> out_flag);+ Result SetAutomaticApplicationDownloadFlag(bool flag);+ Result GetUsb30EnableFlag(Out<bool> out_usb30_enable_flag);+ Result SetUsb30EnableFlag(bool usb30_enable_flag);Result GetNfcEnableFlag(Out<bool> out_nfc_enable_flag);Result SetNfcEnableFlag(bool nfc_enable_flag);Result GetSleepSettings(Out<SleepSettings> out_sleep_settings);diff --git a/src/core/loader/deconstructed_rom_directory.cpp b/src/core/loader/deconstructed_rom_directory.cppindex afa5cdbc36..74b2ff7018 100644--- a/src/core/loader/deconstructed_rom_directory.cpp+++ b/src/core/loader/deconstructed_rom_directory.cpp@@ -71,9 +71,10 @@ struct PatchCollection {std::array<s32, 13> module_patcher_indices{};};-AppLoader_DeconstructedRomDirectory::AppLoader_DeconstructedRomDirectory(FileSys::VirtualFile file_,- bool override_update_)- : AppLoader(std::move(file_)), override_update(override_update_), is_hbl(false) {+AppLoader_DeconstructedRomDirectory::AppLoader_DeconstructedRomDirectory(FileSys::VirtualFile file_, bool override_update_)+ : AppLoader(std::move(file_))+ , override_update(override_update_)+{const auto file_dir = file->GetContainingDirectory();// Title ID@@ -124,9 +125,11 @@ AppLoader_DeconstructedRomDirectory::AppLoader_DeconstructedRomDirectory(FileSys}AppLoader_DeconstructedRomDirectory::AppLoader_DeconstructedRomDirectory(- FileSys::VirtualDir directory, bool override_update_, bool is_hbl_)- : AppLoader(directory->GetFile("main")), dir(std::move(directory)),- override_update(override_update_), is_hbl(is_hbl_) {}+ FileSys::VirtualDir directory, bool override_update_)+ : AppLoader(directory->GetFile("main"))+ , dir(std::move(directory))+ , override_update(override_update_)+{}FileType AppLoader_DeconstructedRomDirectory::IdentifyType(const FileSys::VirtualFile& dir_file) {if (FileSys::IsDirectoryExeFS(dir_file->GetContainingDirectory())) {@@ -232,7 +235,7 @@ AppLoader_DeconstructedRomDirectory::LoadResult AppLoader_DeconstructedRomDirect? ::Settings::values.rng_seed.GetValue() : Common::Random::Random64(0)) << 12) & 0xfff000;// Setup the process code layout- if (process.LoadFromMetadata(metadata, code_size, fastmem_base, aslr_offset, is_hbl).IsError()) {+ if (process.LoadFromMetadata(metadata, code_size, fastmem_base, aslr_offset).IsError()) {return {ResultStatus::ErrorUnableToParseKernelMetadata, {}};}diff --git a/src/core/loader/deconstructed_rom_directory.h b/src/core/loader/deconstructed_rom_directory.hindex 1e9f765c9d..7283db0662 100644--- a/src/core/loader/deconstructed_rom_directory.h+++ b/src/core/loader/deconstructed_rom_directory.h@@ -1,3 +1,6 @@+// SPDX-FileCopyrightText: Copyright 2026 Eden Emulator Project+// SPDX-License-Identifier: GPL-3.0-or-later+// SPDX-FileCopyrightText: Copyright 2018 yuzu Emulator Project// SPDX-License-Identifier: GPL-2.0-or-later@@ -22,13 +25,9 @@ namespace Loader {*/class AppLoader_DeconstructedRomDirectory final : public AppLoader {public:- explicit AppLoader_DeconstructedRomDirectory(FileSys::VirtualFile main_file,- bool override_update_ = false);-+ explicit AppLoader_DeconstructedRomDirectory(FileSys::VirtualFile main_file, bool override_update_ = false);// Overload to accept exefs directory. Must contain 'main' and 'main.npdm'- explicit AppLoader_DeconstructedRomDirectory(FileSys::VirtualDir directory,- bool override_update_ = false,- bool is_hbl_ = false);+ explicit AppLoader_DeconstructedRomDirectory(FileSys::VirtualDir directory, bool override_update_ = false);/*** Identifies whether or not the given file is a deconstructed ROM directory.@@ -63,7 +62,6 @@ private:std::string name;u64 title_id{};bool override_update;- bool is_hbl;Modules modules;};diff --git a/src/core/loader/kip.cpp b/src/core/loader/kip.cppindex 978ffed2b9..fdfbac0a20 100644--- a/src/core/loader/kip.cpp+++ b/src/core/loader/kip.cpp@@ -93,7 +93,7 @@ AppLoader::LoadResult AppLoader_KIP::Load(Kernel::KProcess& process,? ::Settings::values.rng_seed.GetValue() : Common::Random::Random64(0)) << 12) & 0xfff000;// Setup the process code layout- if (process.LoadFromMetadata(FileSys::ProgramMetadata::GetDefault(), codeset.memory.size(), 0, aslr_offset, false).IsError()) {+ if (process.LoadFromMetadata(FileSys::ProgramMetadata::GetDefault(), codeset.memory.size(), 0, aslr_offset).IsError()) {return {ResultStatus::ErrorNotInitialized, {}};}const VAddr base_address = GetInteger(process.GetEntryPoint());diff --git a/src/core/loader/nro.cpp b/src/core/loader/nro.cppindex 738d805149..866059286a 100644--- a/src/core/loader/nro.cpp+++ b/src/core/loader/nro.cpp@@ -247,7 +247,7 @@ static bool LoadNroImpl(Core::System& system, Kernel::KProcess& process,// Setup the process code layoutif (process- .LoadFromMetadata(FileSys::ProgramMetadata::GetDefault(), image_size, fastmem_base, aslr_offset, false)+ .LoadFromMetadata(FileSys::ProgramMetadata::GetDefault(), image_size, fastmem_base, aslr_offset).IsError()) {return false;}diff --git a/src/core/loader/nsp.cpp b/src/core/loader/nsp.cppindex 4333acb70c..726bb428f6 100644--- a/src/core/loader/nsp.cpp+++ b/src/core/loader/nsp.cpp@@ -34,8 +34,7 @@ AppLoader_NSP::AppLoader_NSP(FileSys::VirtualFile file_,}if (nsp->IsExtractedType()) {- secondary_loader = std::make_unique<AppLoader_DeconstructedRomDirectory>(- nsp->GetExeFS(), false, file->GetName() == "hbl.nsp");+ secondary_loader = std::make_unique<AppLoader_DeconstructedRomDirectory>(nsp->GetExeFS(), false);} else {const auto control_nca =nsp->GetNCA(nsp->GetProgramTitleID(), FileSys::ContentRecordType::Control);diff --git a/src/yuzu/main_window.cpp b/src/yuzu/main_window.cppindex 8c362d229b..4c53ef1221 100644--- a/src/yuzu/main_window.cpp+++ b/src/yuzu/main_window.cpp@@ -581,7 +581,7 @@ MainWindow::MainWindow(bool has_broken_vulkan)} else if (should_launch_hlaunch) {std::filesystem::path const sd_dir = Common::FS::GetEdenPathString(Common::FS::EdenPath::SDMCDir);auto const hbl_path = (sd_dir / "atmosphere" / "hbl.nsp").string();- BootGame(QString::fromStdString(hbl_path), ApplicationAppletParameters());+ BootGame(QString::fromStdString(hbl_path), LibraryAppletParameters(0x010000000000100Dull, Service::AM::AppletId::QLaunch));}}}