VERY experimental Nintendo Switch 2 emulator
C++
IR: Move The IR services to their own folder and implement "GetHandles"
purpasmart96d6c9af600fba
diff --git a/src/core/CMakeLists.txt b/src/core/CMakeLists.txtindex bdf4b62123..0528175ba0 100644--- a/src/core/CMakeLists.txt+++ b/src/core/CMakeLists.txt@@ -61,8 +61,10 @@ set(SRCShle/service/hid/hid_spvr.cpphle/service/gsp_lcd.cpphle/service/http_c.cpp- hle/service/ir_rst.cpp- hle/service/ir_u.cpp+ hle/service/ir/ir.cpp+ hle/service/ir/ir_rst.cpp+ hle/service/ir/ir_u.cpp+ hle/service/ir/ir_user.cpphle/service/ldr_ro.cpphle/service/mic_u.cpphle/service/ndm_u.cpp@@ -170,8 +172,10 @@ set(HEADERShle/service/hid/hid_user.hhle/service/gsp_lcd.hhle/service/http_c.h- hle/service/ir_rst.h- hle/service/ir_u.h+ hle/service/ir/ir.h+ hle/service/ir/ir_rst.h+ hle/service/ir/ir_u.h+ hle/service/ir/ir_user.hhle/service/ldr_ro.hhle/service/mic_u.hhle/service/ndm_u.hdiff --git a/src/core/hle/service/ir/ir.cpp b/src/core/hle/service/ir/ir.cppnew file mode 100644index 0000000000..58dfd8e1a4--- /dev/null+++ b/src/core/hle/service/ir/ir.cpp@@ -0,0 +1,48 @@+// Copyright 2015 Citra Emulator Project+// Licensed under GPLv2 or any later version+// Refer to the license.txt file included.++#include "core/hle/service/service.h"+#include "core/hle/service/ir/ir.h"+#include "core/hle/service/ir/ir_rst.h"+#include "core/hle/service/ir/ir_u.h"+#include "core/hle/service/ir/ir_user.h"++#include "core/hle/hle.h"+#include "core/hle/kernel/event.h"+#include "core/hle/kernel/shared_memory.h"++namespace Service {+namespace IR {++static Kernel::SharedPtr<Kernel::Event> handle_event = nullptr;+static Kernel::SharedPtr<Kernel::SharedMemory> shared_memory = nullptr;++void GetHandles(Service::Interface* self) {+ u32* cmd_buff = Kernel::GetCommandBuffer();++ cmd_buff[1] = RESULT_SUCCESS.raw;+ cmd_buff[2] = 0x4000000;+ cmd_buff[3] = Kernel::g_handle_table.Create(Service::IR::shared_memory).MoveFrom();+ cmd_buff[4] = Kernel::g_handle_table.Create(Service::IR::handle_event).MoveFrom();+}++void Init() {+ using namespace Kernel;++ AddService(new IR_RST_Interface);+ AddService(new IR_U_Interface);+ AddService(new IR_User_Interface);++ shared_memory = SharedMemory::Create("IR:SharedMemory");++ // Create event handle(s)+ handle_event = Event::Create(RESETTYPE_ONESHOT, "IR:HandleEvent");+}++void Shutdown() {+}++} // namespace IR++} // namespace Servicediff --git a/src/core/hle/service/ir/ir.h b/src/core/hle/service/ir/ir.hnew file mode 100644index 0000000000..c16d963e7b--- /dev/null+++ b/src/core/hle/service/ir/ir.h@@ -0,0 +1,30 @@+// Copyright 2015 Citra Emulator Project+// Licensed under GPLv2 or any later version+// Refer to the license.txt file included.++#pragma once++#include "core/hle/kernel/kernel.h"+#include "core/hle/service/service.h"++namespace Service {+namespace IR {++/**+ * IR::GetHandles service function+ * Outputs:+ * 1 : Result of function, 0 on success, otherwise error code+ * 2 : Translate header, used by the ARM11-kernel+ * 3 : Shared memory handle+ * 4 : Event handle+ */+void GetHandles(Interface* self);++/// Initialize IR service+void Init();++/// Shutdown IR service+void Shutdown();++} // namespace IR+} // namespace Servicediff --git a/src/core/hle/service/ir/ir_rst.cpp b/src/core/hle/service/ir/ir_rst.cppnew file mode 100644index 0000000000..96ae63420d--- /dev/null+++ b/src/core/hle/service/ir/ir_rst.cpp@@ -0,0 +1,24 @@+// Copyright 2015 Citra Emulator Project+// Licensed under GPLv2 or any later version+// Refer to the license.txt file included.++#include "core/hle/hle.h"+#include "core/hle/service/ir/ir.h"+#include "core/hle/service/ir/ir_rst.h"++namespace Service {+namespace IR {++const Interface::FunctionInfo FunctionTable[] = {+ {0x00010000, GetHandles, "GetHandles"},+ {0x00020080, nullptr, "Initialize"},+ {0x00030000, nullptr, "Shutdown"},+ {0x00090000, nullptr, "WriteToTwoFields"},+};++IR_RST_Interface::IR_RST_Interface() {+ Register(FunctionTable);+}++} // namespace IR+} // namespace Servicediff --git a/src/core/hle/service/ir_rst.h b/src/core/hle/service/ir/ir_rst.hsimilarity index 55%rename from src/core/hle/service/ir_rst.hrename to src/core/hle/service/ir/ir_rst.hindex deef701c59..a492e15c96 100644--- a/src/core/hle/service/ir_rst.h+++ b/src/core/hle/service/ir/ir_rst.h@@ -6,18 +6,17 @@#include "core/hle/service/service.h"-////////////////////////////////////////////////////////////////////////////////////////////////////-// Namespace IR_RST+namespace Service {+namespace IR {-namespace IR_RST {--class Interface : public Service::Interface {+class IR_RST_Interface : public Service::Interface {public:- Interface();+ IR_RST_Interface();std::string GetPortName() const override {return "ir:rst";}};-} // namespace+} // namespace IR+} // namespace Servicediff --git a/src/core/hle/service/ir_u.cpp b/src/core/hle/service/ir/ir_u.cppsimilarity index 80%rename from src/core/hle/service/ir_u.cpprename to src/core/hle/service/ir/ir_u.cppindex 608ed3c06a..1b1e3078b4 100644--- a/src/core/hle/service/ir_u.cpp+++ b/src/core/hle/service/ir/ir_u.cpp@@ -3,12 +3,11 @@// Refer to the license.txt file included.#include "core/hle/hle.h"-#include "core/hle/service/ir_u.h"+#include "core/hle/service/ir/ir.h"+#include "core/hle/service/ir/ir_u.h"-////////////////////////////////////////////////////////////////////////////////////////////////////-// Namespace IR_U--namespace IR_U {+namespace Service {+namespace IR {const Interface::FunctionInfo FunctionTable[] = {{0x00010000, nullptr, "Initialize"},@@ -31,11 +30,9 @@ const Interface::FunctionInfo FunctionTable[] = {{0x00120040, nullptr, "SetSleepModeState"},};-////////////////////////////////////////////////////////////////////////////////////////////////////-// Interface class--Interface::Interface() {+IR_U_Interface::IR_U_Interface() {Register(FunctionTable);}-} // namespace+} // namespace IR+} // namespace Servicediff --git a/src/core/hle/service/ir_u.h b/src/core/hle/service/ir/ir_u.hsimilarity index 55%rename from src/core/hle/service/ir_u.hrename to src/core/hle/service/ir/ir_u.hindex ec47a15244..056d2ce1a9 100644--- a/src/core/hle/service/ir_u.h+++ b/src/core/hle/service/ir/ir_u.h@@ -6,18 +6,17 @@#include "core/hle/service/service.h"-////////////////////////////////////////////////////////////////////////////////////////////////////-// Namespace IR_U+namespace Service {+namespace IR {-namespace IR_U {--class Interface : public Service::Interface {+class IR_U_Interface : public Service::Interface {public:- Interface();+ IR_U_Interface();std::string GetPortName() const override {return "ir:u";}};-} // namespace+} // namespace IR+} // namespace Servicediff --git a/src/core/hle/service/ir/ir_user.cpp b/src/core/hle/service/ir/ir_user.cppnew file mode 100644index 0000000000..8e3ff140fc--- /dev/null+++ b/src/core/hle/service/ir/ir_user.cpp@@ -0,0 +1,34 @@+// Copyright 2015 Citra Emulator Project+// Licensed under GPLv2 or any later version+// Refer to the license.txt file included.++#include "core/hle/hle.h"+#include "core/hle/service/ir/ir.h"+#include "core/hle/service/ir/ir_user.h"++namespace Service {+namespace IR {++const Interface::FunctionInfo FunctionTable[] = {+ {0x00010182, nullptr, "InitializeIrNop"},+ {0x00020000, nullptr, "FinalizeIrNop"},+ {0x00030000, nullptr, "ClearReceiveBuffer"},+ {0x00040000, nullptr, "ClearSendBuffer"},+ {0x00060040, nullptr, "RequireConnection"},+ {0x00090000, nullptr, "Disconnect"},+ {0x000A0000, nullptr, "GetReceiveEvent"},+ {0x000B0000, nullptr, "GetSendEvent"},+ {0x000C0000, nullptr, "GetConnectionStatusEvent"},+ {0x000D0042, nullptr, "SendIrNop"},+ {0x000E0042, nullptr, "SendIrNopLarge"},+ {0x00180182, nullptr, "InitializeIrNopShared"},+ {0x00190040, nullptr, "ReleaseReceivedData"},+ {0x001A0040, nullptr, "SetOwnMachineId"},+};++IR_User_Interface::IR_User_Interface() {+ Register(FunctionTable);+}++} // namespace IR+} // namespace Servicediff --git a/src/core/hle/service/ir/ir_user.h b/src/core/hle/service/ir/ir_user.hnew file mode 100644index 0000000000..71c932ffaf--- /dev/null+++ b/src/core/hle/service/ir/ir_user.h@@ -0,0 +1,22 @@+// Copyright 2015 Citra Emulator Project+// Licensed under GPLv2 or any later version+// Refer to the license.txt file included.++#pragma once++#include "core/hle/service/service.h"++namespace Service {+namespace IR {++class IR_User_Interface : public Service::Interface {+public:+ IR_User_Interface();++ std::string GetPortName() const override {+ return "ir:USER";+ }+};++} // namespace IR+} // namespace Servicediff --git a/src/core/hle/service/ir_rst.cpp b/src/core/hle/service/ir_rst.cppdeleted file mode 100644index 4c26c2f03b..0000000000--- a/src/core/hle/service/ir_rst.cpp+++ /dev/null@@ -1,27 +0,0 @@-// Copyright 2014 Citra Emulator Project-// Licensed under GPLv2 or any later version-// Refer to the license.txt file included.--#include "core/hle/hle.h"-#include "core/hle/service/ir_rst.h"--////////////////////////////////////////////////////////////////////////////////////////////////////-// Namespace IR_RST--namespace IR_RST {--const Interface::FunctionInfo FunctionTable[] = {- {0x00010000, nullptr, "GetHandles"},- {0x00020080, nullptr, "Initialize"},- {0x00030000, nullptr, "Shutdown"},- {0x00090000, nullptr, "WriteToTwoFields"},-};--////////////////////////////////////////////////////////////////////////////////////////////////////-// Interface class--Interface::Interface() {- Register(FunctionTable);-}--} // namespacediff --git a/src/core/hle/service/service.cpp b/src/core/hle/service/service.cppindex eeb4046595..134ff1740a 100644--- a/src/core/hle/service/service.cpp+++ b/src/core/hle/service/service.cpp@@ -24,8 +24,6 @@#include "core/hle/service/gsp_gpu.h"#include "core/hle/service/gsp_lcd.h"#include "core/hle/service/http_c.h"-#include "core/hle/service/ir_rst.h"-#include "core/hle/service/ir_u.h"#include "core/hle/service/ldr_ro.h"#include "core/hle/service/mic_u.h"#include "core/hle/service/ndm_u.h"@@ -45,6 +43,7 @@#include "core/hle/service/fs/archive.h"#include "core/hle/service/cfg/cfg.h"#include "core/hle/service/hid/hid.h"+#include "core/hle/service/ir/ir.h"#include "core/hle/service/ptm/ptm.h"namespace Service {@@ -73,6 +72,7 @@ void Init() {Service::APT::Init();Service::PTM::Init();Service::HID::Init();+ Service::IR::Init();AddService(new AC_U::Interface);AddService(new ACT_U::Interface);@@ -91,8 +91,6 @@ void Init() {AddService(new GSP_GPU::Interface);AddService(new GSP_LCD::Interface);AddService(new HTTP_C::Interface);- AddService(new IR_RST::Interface);- AddService(new IR_U::Interface);AddService(new LDR_RO::Interface);AddService(new MIC_U::Interface);AddService(new NDM_U::Interface);@@ -112,6 +110,7 @@ void Init() {/// Shutdown ServiceManagervoid Shutdown() {+ Service::IR::Shutdown();Service::HID::Shutdown();Service::PTM::Shutdown();Service::APT::Shutdown();