From f76174bd2acb988f8f73776ff2384d82bfa5b2cc Mon Sep 17 00:00:00 2001 From: lizzie Date: Sat, 15 Aug 2026 09:25:52 +0000 Subject: [PATCH] pcv + better oob for hle --- src/core/hle/service/caps/caps.cpp | 20 +++++--------- src/core/hle/service/caps/caps_manager.cpp | 3 +++ src/core/hle/service/glue/ectx.cpp | 24 +++++++++++++++++ src/core/hle/service/glue/ectx.h | 12 +++++++++ src/core/hle/service/glue/glue.cpp | 31 +++++++--------------- src/core/hle/service/hle_ipc.h | 8 +++--- src/core/hle/service/pcv/pcv.cpp | 26 ++++++++++++++++++ 7 files changed, 84 insertions(+), 40 deletions(-) diff --git a/src/core/hle/service/caps/caps.cpp b/src/core/hle/service/caps/caps.cpp index cd1dfe9939..eaee21eb86 100644 --- a/src/core/hle/service/caps/caps.cpp +++ b/src/core/hle/service/caps/caps.cpp @@ -18,20 +18,12 @@ void LoopProcess(Core::System& system) { auto server_manager = std::make_unique(system); auto album_manager = std::make_shared(system); - server_manager->RegisterNamedService( - "caps:a", std::make_shared(system, album_manager)); - server_manager->RegisterNamedService( - "caps:c", std::make_shared(system, album_manager)); - server_manager->RegisterNamedService( - "caps:u", std::make_shared(system, album_manager)); - - server_manager->RegisterNamedService( - "caps:ss", std::make_shared(system, album_manager)); - server_manager->RegisterNamedService("caps:sc", - std::make_shared(system)); - server_manager->RegisterNamedService( - "caps:su", std::make_shared(system, album_manager)); - + server_manager->RegisterNamedService("caps:a", std::make_shared(system, album_manager)); + server_manager->RegisterNamedService("caps:c", std::make_shared(system, album_manager)); + server_manager->RegisterNamedService("caps:u", std::make_shared(system, album_manager)); + server_manager->RegisterNamedService("caps:ss", std::make_shared(system, album_manager)); + server_manager->RegisterNamedService("caps:sc", std::make_shared(system)); + server_manager->RegisterNamedService("caps:su", std::make_shared(system, album_manager)); ServerManager::RunServer(std::move(server_manager)); } diff --git a/src/core/hle/service/caps/caps_manager.cpp b/src/core/hle/service/caps/caps_manager.cpp index af0b9b16ad..743c372aae 100644 --- a/src/core/hle/service/caps/caps_manager.cpp +++ b/src/core/hle/service/caps/caps_manager.cpp @@ -263,6 +263,9 @@ Result AlbumManager::SaveScreenShot(ApplicationAlbumEntry& out_entry, return result; } + // TODO: ??? + R_UNLESS(!image_data.empty(), ResultUnknown); + const auto date = ConvertToAlbumDateTime(posix_time); return SaveImage(out_entry, image_data, title_id, date); diff --git a/src/core/hle/service/glue/ectx.cpp b/src/core/hle/service/glue/ectx.cpp index 951f6cfcc8..322ae45254 100644 --- a/src/core/hle/service/glue/ectx.cpp +++ b/src/core/hle/service/glue/ectx.cpp @@ -43,6 +43,30 @@ private: } }; +ECTX_W::ECTX_W(Core::System& system_) : ServiceFramework{system_, "ectx:w"} { + // clang-format off + static const FunctionInfo functions[] = { + {0, nullptr, "CreateContextRegistrar"}, + {1, nullptr, "CommitContext"}, + {2, nullptr, "RemoveContext"}, + }; + // clang-format on + RegisterHandlers(functions); +} +ECTX_W::~ECTX_W() = default; + +ECTX_R::ECTX_R(Core::System& system_) : ServiceFramework{system_, "ectx:r"} { + // clang-format off + static const FunctionInfo functions[] = { + {0, nullptr, "GetContextInfo"}, + {1, nullptr, "PullContext"}, + {2, nullptr, "ListContextDescriptorWithResultForDebug"}, + }; + // clang-format on + RegisterHandlers(functions); +} +ECTX_R::~ECTX_R() = default; + ECTX_AW::ECTX_AW(Core::System& system_) : ServiceFramework{system_, "ectx:aw"} { // clang-format off static const FunctionInfo functions[] = { diff --git a/src/core/hle/service/glue/ectx.h b/src/core/hle/service/glue/ectx.h index ffa74d8d33..9c40d2d229 100644 --- a/src/core/hle/service/glue/ectx.h +++ b/src/core/hle/service/glue/ectx.h @@ -11,6 +11,18 @@ class System; namespace Service::Glue { +class ECTX_W final : public ServiceFramework { +public: + explicit ECTX_W(Core::System& system_); + ~ECTX_W() override; +}; + +class ECTX_R final : public ServiceFramework { +public: + explicit ECTX_R(Core::System& system_); + ~ECTX_R() override; +}; + class ECTX_AW final : public ServiceFramework { public: explicit ECTX_AW(Core::System& system_); diff --git a/src/core/hle/service/glue/glue.cpp b/src/core/hle/service/glue/glue.cpp index ea2843462f..72d15be646 100644 --- a/src/core/hle/service/glue/glue.cpp +++ b/src/core/hle/service/glue/glue.cpp @@ -19,40 +19,27 @@ void LoopProcess(Core::System& system) { auto server_manager = std::make_unique(system); // ARP - server_manager->RegisterNamedService("arp:r", - std::make_shared(system, system.GetARPManager())); - server_manager->RegisterNamedService("arp:w", - std::make_shared(system, system.GetARPManager())); + server_manager->RegisterNamedService("arp:r", std::make_shared(system, system.GetARPManager())); + server_manager->RegisterNamedService("arp:w", std::make_shared(system, system.GetARPManager())); // BackGround Task Controller server_manager->RegisterNamedService("bgtc:t", std::make_shared(system)); server_manager->RegisterNamedService("bgtc:sc", std::make_shared(system)); // Error Context + server_manager->RegisterNamedService("ectx:w", std::make_shared(system)); + server_manager->RegisterNamedService("ectx:r", std::make_shared(system)); server_manager->RegisterNamedService("ectx:aw", std::make_shared(system)); // Notification Services - server_manager->RegisterNamedService( - "notif:a", std::make_shared(system)); - server_manager->RegisterNamedService("notif:s", - std::make_shared(system)); + server_manager->RegisterNamedService("notif:a", std::make_shared(system)); + server_manager->RegisterNamedService("notif:s", std::make_shared(system)); // Time auto time = std::make_shared(system); - - server_manager->RegisterNamedService( - "time:u", - std::make_shared( - system, Service::PSC::Time::StaticServiceSetupInfo{0, 0, 0, 0, 0, 0}, time, "time:u")); - server_manager->RegisterNamedService( - "time:a", - std::make_shared( - system, Service::PSC::Time::StaticServiceSetupInfo{1, 1, 0, 1, 0, 0}, time, "time:a")); - server_manager->RegisterNamedService( - "time:r", - std::make_shared( - system, Service::PSC::Time::StaticServiceSetupInfo{0, 0, 0, 0, 1, 0}, time, "time:r")); - + server_manager->RegisterNamedService("time:u", std::make_shared(system, Service::PSC::Time::StaticServiceSetupInfo{0, 0, 0, 0, 0, 0}, time, "time:u")); + server_manager->RegisterNamedService("time:a", std::make_shared(system, Service::PSC::Time::StaticServiceSetupInfo{1, 1, 0, 1, 0, 0}, time, "time:a")); + server_manager->RegisterNamedService("time:r", std::make_shared(system, Service::PSC::Time::StaticServiceSetupInfo{0, 0, 0, 0, 1, 0}, time, "time:r")); ServerManager::RunServer(std::move(server_manager)); } diff --git a/src/core/hle/service/hle_ipc.h b/src/core/hle/service/hle_ipc.h index 7387318995..4dee40224a 100644 --- a/src/core/hle/service/hle_ipc.h +++ b/src/core/hle/service/hle_ipc.h @@ -330,12 +330,12 @@ public: /// Helper function to test whether the output buffer at buffer_index can be written [[nodiscard]] bool CanWriteBuffer(std::size_t buffer_index = 0) const; - [[nodiscard]] Handle GetCopyHandle(std::size_t index) const { - return incoming_copy_handles.at(index); + [[nodiscard]] Handle GetCopyHandle(std::size_t index) const noexcept { + return index >= incoming_copy_handles.size() ? 0 : incoming_copy_handles[index]; } - [[nodiscard]] Handle GetMoveHandle(std::size_t index) const { - return incoming_move_handles.at(index); + [[nodiscard]] Handle GetMoveHandle(std::size_t index) const noexcept { + return index >= incoming_move_handles.size() ? 0 : incoming_move_handles[index]; } void AddMoveObject(Kernel::KAutoObject* object) { diff --git a/src/core/hle/service/pcv/pcv.cpp b/src/core/hle/service/pcv/pcv.cpp index c2f466c90b..1b314f3518 100644 --- a/src/core/hle/service/pcv/pcv.cpp +++ b/src/core/hle/service/pcv/pcv.cpp @@ -55,6 +55,30 @@ public: } }; +class PCV_ARB final : public ServiceFramework { +public: + explicit PCV_ARB(Core::System& system_) : ServiceFramework{system_, "pcv:arb"} { + // clang-format off + static const FunctionInfo functions[] = { + {0, nullptr, "ReleaseControl"}, + }; + // clang-format on + RegisterHandlers(functions); + } +}; + +class PCV_IMM final : public ServiceFramework { +public: + explicit PCV_IMM(Core::System& system_) : ServiceFramework{system_, "pcv:imm"} { + // clang-format off + static const FunctionInfo functions[] = { + {0, nullptr, "SetClockRate"}, + }; + // clang-format on + RegisterHandlers(functions); + } +}; + class IClkrstSession final : public ServiceFramework { public: explicit IClkrstSession(Core::System& system_, DeviceCode device_code_) @@ -148,6 +172,8 @@ void LoopProcess(Core::System& system) { auto server_manager = std::make_unique(system); server_manager->RegisterNamedService("pcv", std::make_shared(system)); + server_manager->RegisterNamedService("pcv:arb", std::make_shared(system)); + server_manager->RegisterNamedService("pcv:imm", std::make_shared(system)); server_manager->RegisterNamedService("clkrst", std::make_shared(system, "clkrst")); server_manager->RegisterNamedService("clkrst:i", std::make_shared(system, "clkrst:i")); server_manager->RegisterNamedService("clkrst:a", std::make_shared(system));