diff options
Diffstat (limited to 'src/core/hle/service')
28 files changed, 429 insertions, 142 deletions
diff --git a/src/core/hle/service/am/am.cpp b/src/core/hle/service/am/am.cpp index 57dc1ece..7332478f 100644 --- a/src/core/hle/service/am/am.cpp +++ b/src/core/hle/service/am/am.cpp @@ -38,6 +38,15 @@ void GetTitleIDList(Service::Interface* self) { LOG_WARNING(Service_AM, "(STUBBED) Requested %u titles from media type %u", num_titles, media_type); } +void GetNumContentInfos(Service::Interface* self) { + u32* cmd_buff = Kernel::GetCommandBuffer(); + + cmd_buff[1] = RESULT_SUCCESS.raw; + cmd_buff[2] = 1; // Number of content infos plus one + + LOG_WARNING(Service_AM, "(STUBBED) called"); +} + void Init() { using namespace Kernel; diff --git a/src/core/hle/service/am/am.h b/src/core/hle/service/am/am.h index 063b8bd0..0b78f539 100644 --- a/src/core/hle/service/am/am.h +++ b/src/core/hle/service/am/am.h @@ -37,6 +37,19 @@ void TitleIDListGetTotal(Service::Interface* self); */ void GetTitleIDList(Service::Interface* self); +/** + * AM::GetNumContentInfos service function + * Inputs: + * 0 : Command header (0x100100C0) + * 1 : Unknown + * 2 : Unknown + * 3 : Unknown + * Outputs: + * 1 : Result, 0 on success, otherwise error code + * 2 : Number of content infos plus one + */ +void GetNumContentInfos(Service::Interface* self); + /// Initialize AM service void Init(); diff --git a/src/core/hle/service/am/am_app.cpp b/src/core/hle/service/am/am_app.cpp index c6fc81bc..f40a87cb 100644 --- a/src/core/hle/service/am/am_app.cpp +++ b/src/core/hle/service/am/am_app.cpp @@ -9,11 +9,19 @@ namespace Service { namespace AM { -// Empty arrays are illegal -- commented out until an entry is added. -//const Interface::FunctionInfo FunctionTable[] = { }; +const Interface::FunctionInfo FunctionTable[] = { + {0x100100C0, GetNumContentInfos, "GetNumContentInfos"}, + {0x10020104, nullptr, "FindContentInfos"}, + {0x10030142, nullptr, "ListContentInfos"}, + {0x10040102, nullptr, "DeleteContents"}, + {0x10050084, nullptr, "GetDataTitleInfos"}, + {0x10070102, nullptr, "ListDataTitleTicketInfos"}, + {0x100900C0, nullptr, "IsDataTitleInUse"}, + {0x100A0000, nullptr, "IsExternalTitleDatabaseInitialized"}, +}; AM_APP_Interface::AM_APP_Interface() { - //Register(FunctionTable); + Register(FunctionTable); } } // namespace AM diff --git a/src/core/hle/service/apt/apt.cpp b/src/core/hle/service/apt/apt.cpp index b454a270..7b6ab4ce 100644 --- a/src/core/hle/service/apt/apt.cpp +++ b/src/core/hle/service/apt/apt.cpp @@ -6,6 +6,7 @@ #include "common/file_util.h" #include "common/logging/log.h" +#include "core/hle/applets/applet.h" #include "core/hle/service/service.h" #include "core/hle/service/apt/apt.h" #include "core/hle/service/apt/apt_a.h" @@ -34,12 +35,21 @@ static Kernel::SharedPtr<Kernel::SharedMemory> shared_font_mem; static Kernel::SharedPtr<Kernel::Mutex> lock; static Kernel::SharedPtr<Kernel::Event> notification_event; ///< APT notification event -static Kernel::SharedPtr<Kernel::Event> start_event; ///< APT start event +static Kernel::SharedPtr<Kernel::Event> parameter_event; ///< APT parameter event static std::vector<u8> shared_font; static u32 cpu_percent; ///< CPU time available to the running application +/// Parameter data to be returned in the next call to Glance/ReceiveParameter +static MessageParameter next_parameter; + +void SendParameter(const MessageParameter& parameter) { + next_parameter = parameter; + // Signal the event to let the application know that a new parameter is ready to be read + parameter_event->Signal(); +} + void Initialize(Service::Interface* self) { u32* cmd_buff = Kernel::GetCommandBuffer(); u32 app_id = cmd_buff[1]; @@ -47,18 +57,18 @@ void Initialize(Service::Interface* self) { cmd_buff[2] = IPC::MoveHandleDesc(2); cmd_buff[3] = Kernel::g_handle_table.Create(notification_event).MoveFrom(); - cmd_buff[4] = Kernel::g_handle_table.Create(start_event).MoveFrom(); + cmd_buff[4] = Kernel::g_handle_table.Create(parameter_event).MoveFrom(); // TODO(bunnei): Check if these events are cleared every time Initialize is called. notification_event->Clear(); - start_event->Clear(); + parameter_event->Clear(); ASSERT_MSG((nullptr != lock), "Cannot initialize without lock"); lock->Release(); cmd_buff[1] = RESULT_SUCCESS.raw; // No error - LOG_TRACE(Service_APT, "called app_id=0x%08X, flags=0x%08X", app_id, flags); + LOG_DEBUG(Service_APT, "called app_id=0x%08X, flags=0x%08X", app_id, flags); } void GetSharedFont(Service::Interface* self) { @@ -85,9 +95,6 @@ void GetSharedFont(Service::Interface* self) { void NotifyToWait(Service::Interface* self) { u32* cmd_buff = Kernel::GetCommandBuffer(); u32 app_id = cmd_buff[1]; - // TODO(Subv): Verify this, it seems to get SWKBD and Home Menu further. - start_event->Signal(); - cmd_buff[1] = RESULT_SUCCESS.raw; // No error LOG_WARNING(Service_APT, "(STUBBED) app_id=%u", app_id); } @@ -100,7 +107,7 @@ void GetLockHandle(Service::Interface* self) { // Not sure what these parameters are used for, but retail apps check that they are 0 after // GetLockHandle has been called. - cmd_buff[2] = 0; + cmd_buff[2] = 0; // Applet Attributes, this value is passed to Enable. cmd_buff[3] = 0; cmd_buff[4] = 0; @@ -110,9 +117,10 @@ void GetLockHandle(Service::Interface* self) { void Enable(Service::Interface* self) { u32* cmd_buff = Kernel::GetCommandBuffer(); - u32 unk = cmd_buff[1]; // TODO(bunnei): What is this field used for? + u32 attributes = cmd_buff[1]; cmd_buff[1] = RESULT_SUCCESS.raw; // No error - LOG_WARNING(Service_APT, "(STUBBED) called unk=0x%08X", unk); + parameter_event->Signal(); // Let the application know that it has been started + LOG_WARNING(Service_APT, "(STUBBED) called attributes=0x%08X", attributes); } void GetAppletManInfo(Service::Interface* self) { @@ -121,8 +129,8 @@ void GetAppletManInfo(Service::Interface* self) { cmd_buff[1] = RESULT_SUCCESS.raw; // No error cmd_buff[2] = 0; cmd_buff[3] = 0; - cmd_buff[4] = static_cast<u32>(AppID::HomeMenu); // Home menu AppID - cmd_buff[5] = static_cast<u32>(AppID::Application); // TODO(purpasmart96): Do this correctly + cmd_buff[4] = static_cast<u32>(AppletId::HomeMenu); // Home menu AppID + cmd_buff[5] = static_cast<u32>(AppletId::Application); // TODO(purpasmart96): Do this correctly LOG_WARNING(Service_APT, "(STUBBED) called unk=0x%08X", unk); } @@ -131,7 +139,13 @@ void IsRegistered(Service::Interface* self) { u32* cmd_buff = Kernel::GetCommandBuffer(); u32 app_id = cmd_buff[1]; cmd_buff[1] = RESULT_SUCCESS.raw; // No error - cmd_buff[2] = 1; // Set to registered + /// TODO(Subv): It is currently unknown what this value (0x400) means, + /// but i believe it is used as a global "LibraryApplet" id, to verify if there's + /// any LibApplet currently running. This is not verified. + if (app_id != 0x400) + cmd_buff[2] = 1; // Set to registered + else + cmd_buff[2] = 0; // Set to not registered LOG_WARNING(Service_APT, "(STUBBED) called app_id=0x%08X", app_id); } @@ -145,50 +159,82 @@ void InquireNotification(Service::Interface* self) { void SendParameter(Service::Interface* self) { u32* cmd_buff = Kernel::GetCommandBuffer(); - u32 src_app_id = cmd_buff[1]; - u32 dst_app_id = cmd_buff[2]; - u32 signal_type = cmd_buff[3]; - u32 buffer_size = cmd_buff[4]; - u32 value = cmd_buff[5]; - u32 handle = cmd_buff[6]; - u32 size = cmd_buff[7]; - u32 in_param_buffer_ptr = cmd_buff[8]; + u32 src_app_id = cmd_buff[1]; + u32 dst_app_id = cmd_buff[2]; + u32 signal_type = cmd_buff[3]; + u32 buffer_size = cmd_buff[4]; + u32 value = cmd_buff[5]; + u32 handle = cmd_buff[6]; + u32 size = cmd_buff[7]; + u32 buffer = cmd_buff[8]; + + std::shared_ptr<HLE::Applets::Applet> dest_applet = HLE::Applets::Applet::Get(static_cast<AppletId>(dst_app_id)); + + if (dest_applet == nullptr) { + LOG_ERROR(Service_APT, "Unknown applet id=0x%08X", dst_app_id); + cmd_buff[1] = -1; // TODO(Subv): Find the right error code + return; + } - cmd_buff[1] = RESULT_SUCCESS.raw; // No error + MessageParameter param; + param.buffer_size = buffer_size; + param.destination_id = dst_app_id; + param.sender_id = src_app_id; + param.object = Kernel::g_handle_table.GetGeneric(handle); + param.signal = signal_type; + param.data = Memory::GetPointer(buffer); + + cmd_buff[1] = dest_applet->ReceiveParameter(param).raw; LOG_WARNING(Service_APT, "(STUBBED) called src_app_id=0x%08X, dst_app_id=0x%08X, signal_type=0x%08X," "buffer_size=0x%08X, value=0x%08X, handle=0x%08X, size=0x%08X, in_param_buffer_ptr=0x%08X", - src_app_id, dst_app_id, signal_type, buffer_size, value, handle, size, in_param_buffer_ptr); + src_app_id, dst_app_id, signal_type, buffer_size, value, handle, size, buffer); } void ReceiveParameter(Service::Interface* self) { u32* cmd_buff = Kernel::GetCommandBuffer(); u32 app_id = cmd_buff[1]; u32 buffer_size = cmd_buff[2]; + VAddr buffer = cmd_buff[0x104 >> 2]; + cmd_buff[1] = RESULT_SUCCESS.raw; // No error - cmd_buff[2] = 0; - cmd_buff[3] = static_cast<u32>(SignalType::AppJustStarted); // Signal type - cmd_buff[4] = 0x10; // Parameter buffer size (16) - cmd_buff[5] = 0; + cmd_buff[2] = next_parameter.sender_id; + cmd_buff[3] = next_parameter.signal; // Signal type + cmd_buff[4] = next_parameter.buffer_size; // Parameter buffer size + cmd_buff[5] = 0x10; cmd_buff[6] = 0; - cmd_buff[7] = 0; - LOG_WARNING(Service_APT, "(STUBBED) called app_id=0x%08X, buffer_size=0x%08X", app_id, buffer_size); + if (next_parameter.object != nullptr) + cmd_buff[6] = Kernel::g_handle_table.Create(next_parameter.object).MoveFrom(); + cmd_buff[7] = (next_parameter.buffer_size << 14) | 2; + cmd_buff[8] = buffer; + + if (next_parameter.data) + memcpy(Memory::GetPointer(buffer), next_parameter.data, std::min(buffer_size, next_parameter.buffer_size)); + + LOG_WARNING(Service_APT, "called app_id=0x%08X, buffer_size=0x%08X", app_id, buffer_size); } void GlanceParameter(Service::Interface* self) { u32* cmd_buff = Kernel::GetCommandBuffer(); u32 app_id = cmd_buff[1]; u32 buffer_size = cmd_buff[2]; + VAddr buffer = cmd_buff[0x104 >> 2]; cmd_buff[1] = RESULT_SUCCESS.raw; // No error - cmd_buff[2] = 0; - cmd_buff[3] = static_cast<u32>(SignalType::AppJustStarted); // Signal type - cmd_buff[4] = 0x10; // Parameter buffer size (16) - cmd_buff[5] = 0; + cmd_buff[2] = next_parameter.sender_id; + cmd_buff[3] = next_parameter.signal; // Signal type + cmd_buff[4] = next_parameter.buffer_size; // Parameter buffer size + cmd_buff[5] = 0x10; cmd_buff[6] = 0; - cmd_buff[7] = 0; + if (next_parameter.object != nullptr) + cmd_buff[6] = Kernel::g_handle_table.Create(next_parameter.object).MoveFrom(); + cmd_buff[7] = (next_parameter.buffer_size << 14) | 2; + cmd_buff[8] = buffer; - LOG_WARNING(Service_APT, "(STUBBED) called app_id=0x%08X, buffer_size=0x%08X", app_id, buffer_size); + if (next_parameter.data) + memcpy(Memory::GetPointer(buffer), next_parameter.data, std::min(buffer_size, next_parameter.buffer_size)); + + LOG_WARNING(Service_APT, "called app_id=0x%08X, buffer_size=0x%08X", app_id, buffer_size); } void CancelParameter(Service::Interface* self) { @@ -240,7 +286,7 @@ void AppletUtility(Service::Interface* self) { u32* cmd_buff = Kernel::GetCommandBuffer(); // These are from 3dbrew - I'm not really sure what they're used for. - u32 unk = cmd_buff[1]; + u32 command = cmd_buff[1]; u32 buffer1_size = cmd_buff[2]; u32 buffer2_size = cmd_buff[3]; u32 buffer1_addr = cmd_buff[5]; @@ -248,8 +294,8 @@ void AppletUtility(Service::Interface* self) { cmd_buff[1] = RESULT_SUCCESS.raw; // No error - LOG_WARNING(Service_APT, "(STUBBED) called unk=0x%08X, buffer1_size=0x%08X, buffer2_size=0x%08X, " - "buffer1_addr=0x%08X, buffer2_addr=0x%08X", unk, buffer1_size, buffer2_size, + LOG_WARNING(Service_APT, "(STUBBED) called command=0x%08X, buffer1_size=0x%08X, buffer2_size=0x%08X, " + "buffer1_addr=0x%08X, buffer2_addr=0x%08X", command, buffer1_size, buffer2_size, buffer1_addr, buffer2_addr); } @@ -281,11 +327,41 @@ void GetAppCpuTimeLimit(Service::Interface* self) { LOG_WARNING(Service_APT, "(STUBBED) called value=%u", value); } +void PrepareToStartLibraryApplet(Service::Interface* self) { + u32* cmd_buff = Kernel::GetCommandBuffer(); + AppletId applet_id = static_cast<AppletId>(cmd_buff[1]); + cmd_buff[1] = HLE::Applets::Applet::Create(applet_id).raw; + LOG_DEBUG(Service_APT, "called applet_id=%08X", applet_id); +} + +void StartLibraryApplet(Service::Interface* self) { + u32* cmd_buff = Kernel::GetCommandBuffer(); + AppletId applet_id = static_cast<AppletId>(cmd_buff[1]); + std::shared_ptr<HLE::Applets::Applet> applet = HLE::Applets::Applet::Get(applet_id); + + LOG_DEBUG(Service_APT, "called applet_id=%08X", applet_id); + + if (applet == nullptr) { + LOG_ERROR(Service_APT, "unknown applet id=%08X", applet_id); + cmd_buff[1] = -1; // TODO(Subv): Find the right error code + return; + } + + AppletStartupParameter parameter; + parameter.buffer_size = cmd_buff[2]; + parameter.object = Kernel::g_handle_table.GetGeneric(cmd_buff[4]); + parameter.data = Memory::GetPointer(cmd_buff[6]); + + cmd_buff[1] = applet->Start(parameter).raw; +} + void Init() { AddService(new APT_A_Interface); AddService(new APT_S_Interface); AddService(new APT_U_Interface); + HLE::Applets::Init(); + // Load the shared system font (if available). // The expected format is a decrypted, uncompressed BCFNT file with the 0x80 byte header // generated by the APT:U service. The best way to get is by dumping it from RAM. We've provided @@ -318,7 +394,10 @@ void Init() { // TODO(bunnei): Check if these are created in Initialize or on APT process startup. notification_event = Kernel::Event::Create(RESETTYPE_ONESHOT, "APT_U:Notification"); - start_event = Kernel::Event::Create(RESETTYPE_ONESHOT, "APT_U:Start"); + parameter_event = Kernel::Event::Create(RESETTYPE_ONESHOT, "APT_U:Start"); + + next_parameter.signal = static_cast<u32>(SignalType::AppJustStarted); + next_parameter.destination_id = 0x300; } void Shutdown() { @@ -326,7 +405,11 @@ void Shutdown() { shared_font_mem = nullptr; lock = nullptr; notification_event = nullptr; - start_event = nullptr; + parameter_event = nullptr; + + next_parameter.object = nullptr; + + HLE::Applets::Shutdown(); } } // namespace APT diff --git a/src/core/hle/service/apt/apt.h b/src/core/hle/service/apt/apt.h index a03e1712..72972d05 100644 --- a/src/core/hle/service/apt/apt.h +++ b/src/core/hle/service/apt/apt.h @@ -4,13 +4,33 @@ #pragma once -#include <array> -#include "core/hle/result.h" -#include "core/hle/service/service.h" +#include "common/common_types.h" + +#include "core/hle/kernel/kernel.h" namespace Service { + +class Interface; + namespace APT { +/// Holds information about the parameters used in Send/Glance/ReceiveParameter +struct MessageParameter { + u32 sender_id = 0; + u32 destination_id = 0; + u32 signal = 0; + u32 buffer_size = 0; + Kernel::SharedPtr<Kernel::Object> object = nullptr; + u8* data = nullptr; +}; + +/// Holds information about the parameters used in StartLibraryApplet +struct AppletStartupParameter { + u32 buffer_size = 0; + Kernel::SharedPtr<Kernel::Object> object = nullptr; + u8* data = nullptr; +}; + /// Signals used by APT functions enum class SignalType : u32 { None = 0x0, @@ -23,7 +43,7 @@ enum class SignalType : u32 { }; /// App Id's used by APT functions -enum class AppID : u32 { +enum class AppletId : u32 { HomeMenu = 0x101, AlternateMenu = 0x103, Camera = 0x110, @@ -45,6 +65,9 @@ enum class AppID : u32 { SoftwareKeyboard2 = 0x401, }; +/// Send a parameter to the currently-running application, which will read it via ReceiveParameter +void SendParameter(const MessageParameter& parameter); + /** * APT::Initialize service function * Service function that initializes the APT process for the running application @@ -249,6 +272,33 @@ void SetAppCpuTimeLimit(Service::Interface* self); */ void GetAppCpuTimeLimit(Service::Interface* self); +/** + * APT::PrepareToStartLibraryApplet service function + * Inputs: + * 0 : Command header [0x00180040] + * 1 : Id of the applet to start + * Outputs: + * 0 : Return header + * 1 : Result of function, 0 on success, otherwise error code + */ +void PrepareToStartLibraryApplet(Service::Interface* self); + +/** + * APT::StartLibraryApplet service function + * Inputs: + * 0 : Command header [0x001E0084] + * 1 : Id of the applet to start + * 2 : Buffer size + * 3 : Always 0? + * 4 : Handle passed to the applet + * 5 : (Size << 14) | 2 + * 6 : Input buffer virtual address + * Outputs: + * 0 : Return header + * 1 : Result of function, 0 on success, otherwise error code + */ +void StartLibraryApplet(Service::Interface* self); + /// Initialize the APT service void Init(); diff --git a/src/core/hle/service/apt/apt_a.cpp b/src/core/hle/service/apt/apt_a.cpp index 86493424..88de339f 100644 --- a/src/core/hle/service/apt/apt_a.cpp +++ b/src/core/hle/service/apt/apt_a.cpp @@ -10,19 +10,24 @@ namespace Service { namespace APT { const Interface::FunctionInfo FunctionTable[] = { - {0x00010040, GetLockHandle, "GetLockHandle?"}, - {0x00020080, Initialize, "Initialize?"}, - {0x00030040, Enable, "Enable?"}, - {0x00040040, nullptr, "Finalize?"}, - {0x00050040, nullptr, "GetAppletManInfo?"}, - {0x00060040, nullptr, "GetAppletInfo?"}, - {0x000D0080, ReceiveParameter, "ReceiveParameter?"}, - {0x000E0080, GlanceParameter, "GlanceParameter?"}, - {0x003B0040, nullptr, "CancelLibraryApplet?"}, - {0x00430040, NotifyToWait, "NotifyToWait?"}, - {0x00440000, GetSharedFont, "GetSharedFont?"}, - {0x004B00C2, AppletUtility, "AppletUtility?"}, - {0x00550040, nullptr, "WriteInputToNsState?"}, + {0x00010040, GetLockHandle, "GetLockHandle?"}, + {0x00020080, Initialize, "Initialize?"}, + {0x00030040, Enable, "Enable?"}, + {0x00040040, nullptr, "Finalize?"}, + {0x00050040, nullptr, "GetAppletManInfo?"}, + {0x00060040, nullptr, "GetAppletInfo?"}, + {0x00090040, IsRegistered, "IsRegistered"}, + {0x000C0104, SendParameter, "SendParameter"}, + {0x000D0080, ReceiveParameter, "ReceiveParameter"}, + {0x000E0080, GlanceParameter, "GlanceParameter"}, + {0x000F0100, CancelParameter, "CancelParameter"}, + {0x00180040, PrepareToStartLibraryApplet, "PrepareToStartLibraryApplet"}, + {0x001E0084, StartLibraryApplet, "StartLibraryApplet"}, + {0x003B0040, nullptr, "CancelLibraryApplet?"}, + {0x00430040, NotifyToWait, "NotifyToWait?"}, + {0x00440000, GetSharedFont, "GetSharedFont?"}, + {0x004B00C2, AppletUtility, "AppletUtility?"}, + {0x00550040, nullptr, "WriteInputToNsState?"}, }; APT_A_Interface::APT_A_Interface() { diff --git a/src/core/hle/service/apt/apt_u.cpp b/src/core/hle/service/apt/apt_u.cpp index d006b593..b724cd72 100644 --- a/src/core/hle/service/apt/apt_u.cpp +++ b/src/core/hle/service/apt/apt_u.cpp @@ -35,13 +35,13 @@ const Interface::FunctionInfo FunctionTable[] = { {0x00150140, nullptr, "PrepareToStartApplication"}, {0x00160040, nullptr, "PreloadLibraryApplet"}, {0x00170040, nullptr, "FinishPreloadingLibraryApplet"}, - {0x00180040, nullptr, "PrepareToStartLibraryApplet"}, + {0x00180040, PrepareToStartLibraryApplet, "PrepareToStartLibraryApplet"}, {0x00190040, nullptr, "PrepareToStartSystemApplet"}, {0x001A0000, nullptr, "PrepareToStartNewestHomeMenu"}, {0x001B00C4, nullptr, "StartApplication"}, {0x001C0000, nullptr, "WakeupApplication"}, {0x001D0000, nullptr, "CancelApplication"}, - {0x001E0084, nullptr, "StartLibraryApplet"}, + {0x001E0084, StartLibraryApplet, "StartLibraryApplet"}, {0x001F0084, nullptr, "StartSystemApplet"}, {0x00200044, nullptr, "StartNewestHomeMenu"}, {0x00210000, nullptr, "OrderToCloseApplication"}, diff --git a/src/core/hle/service/cfg/cfg_s.cpp b/src/core/hle/service/cfg/cfg_s.cpp index af4adba8..a329514a 100644 --- a/src/core/hle/service/cfg/cfg_s.cpp +++ b/src/core/hle/service/cfg/cfg_s.cpp @@ -11,7 +11,9 @@ namespace CFG { const Interface::FunctionInfo FunctionTable[] = { {0x00010082, GetConfigInfoBlk2, "GetConfigInfoBlk2"}, - {0x00020000, nullptr, "SecureInfoGetRegion"}, + {0x00020000, SecureInfoGetRegion, "SecureInfoGetRegion"}, + {0x00030040, GenHashConsoleUnique, "GenHashConsoleUnique"}, + {0x00050000, GetSystemModel, "GetSystemModel"}, {0x04010082, GetConfigInfoBlk8, "GetConfigInfoBlk8"}, {0x04020082, nullptr, "SetConfigInfoBlk4"}, {0x04030000, UpdateConfigNANDSavegame, "UpdateConfigNANDSavegame"}, diff --git a/src/core/hle/service/dsp_dsp.cpp b/src/core/hle/service/dsp_dsp.cpp index fafb43a2..a8cb15d6 100644 --- a/src/core/hle/service/dsp_dsp.cpp +++ b/src/core/hle/service/dsp_dsp.cpp @@ -310,4 +310,9 @@ Interface::Interface() { Register(FunctionTable); } +Interface::~Interface() { + semaphore_event = nullptr; + interrupt_event = nullptr; +} + } // namespace diff --git a/src/core/hle/service/dsp_dsp.h b/src/core/hle/service/dsp_dsp.h index fa13bfb7..b6f611db 100644 --- a/src/core/hle/service/dsp_dsp.h +++ b/src/core/hle/service/dsp_dsp.h @@ -4,6 +4,8 @@ #pragma once +#include <string> + #include "core/hle/service/service.h" //////////////////////////////////////////////////////////////////////////////////////////////////// @@ -14,6 +16,7 @@ namespace DSP_DSP { class Interface : public Service::Interface { public: Interface(); + ~Interface() override; std::string GetPortName() const override { return "dsp::DSP"; diff --git a/src/core/hle/service/frd/frd_u.cpp b/src/core/hle/service/frd/frd_u.cpp index 439c7282..3a5897d0 100644 --- a/src/core/hle/service/frd/frd_u.cpp +++ b/src/core/hle/service/frd/frd_u.cpp @@ -10,15 +10,26 @@ namespace Service { namespace FRD { const Interface::FunctionInfo FunctionTable[] = { + {0x00010000, nullptr, "HasLoggedIn"}, + {0x00030000, nullptr, "Login"}, + {0x00040000, nullptr, "Logout"}, {0x00050000, nullptr, "GetFriendKey"}, {0x00080000, nullptr, "GetMyPresence"}, + {0x00090000, nullptr, "GetMyScreenName"}, {0x00100040, nullptr, "GetPassword"}, + {0x00110080, nullptr, "GetFriendKeyList"}, {0x00190042, nullptr, "GetFriendFavoriteGame"}, {0x001A00C4, nullptr, "GetFriendInfo"}, {0x001B0080, nullptr, "IsOnFriendList"}, {0x001C0042, nullptr, "DecodeLocalFriendCode"}, {0x001D0002, nullptr, "SetCurrentlyPlayingText"}, - {0x00320042, nullptr, "SetClientSdkVersion"} + {0x00230000, nullptr, "GetLastResponseResult"}, + {0x00270040, nullptr, "ResultToErrorCode"}, + {0x00280244, nullptr, "RequestGameAuthentication"}, + {0x00290000, nullptr, "GetGameAuthenticationData"}, + {0x002A0204, nullptr, "RequestServiceLocator"}, + {0x002B0000, nullptr, "GetServiceLocatorData"}, + {0x00320042, nullptr, "SetClientSdkVersion"}, }; FRD_U_Interface::FRD_U_Interface() { diff --git a/src/core/hle/service/fs/archive.cpp b/src/core/hle/service/fs/archive.cpp index 4e275cb1..6c0df67c 100644 --- a/src/core/hle/service/fs/archive.cpp +++ b/src/core/hle/service/fs/archive.cpp @@ -2,29 +2,35 @@ // Licensed under GPLv2 or any later version // Refer to the license.txt file included. +#include <cstddef> +#include <system_error> +#include <type_traits> #include <memory> #include <unordered_map> +#include <utility> #include <boost/container/flat_map.hpp> +#include "common/assert.h" #include "common/common_types.h" #include "common/file_util.h" #include "common/logging/log.h" #include "common/make_unique.h" -#include "common/math_util.h" #include "core/file_sys/archive_backend.h" #include "core/file_sys/archive_extsavedata.h" -#include "core/file_sys/archive_romfs.h" #include "core/file_sys/archive_savedata.h" #include "core/file_sys/archive_savedatacheck.h" #include "core/file_sys/archive_sdmc.h" #include "core/file_sys/archive_systemsavedata.h" #include "core/file_sys/directory_backend.h" +#include "core/file_sys/file_backend.h" +#include "core/hle/hle.h" #include "core/hle/service/service.h" #include "core/hle/service/fs/archive.h" #include "core/hle/service/fs/fs_user.h" #include "core/hle/result.h" +#include "core/memory.h" // Specializes std::hash for ArchiveIdCode, so that we can use it in std::unordered_map. // Workaroung for libstdc++ bug: https://gcc.gnu.org/bugzilla/show_bug.cgi?id=60970 @@ -110,7 +116,7 @@ ResultVal<bool> File::SyncRequest() { u32 address = cmd_buff[6]; LOG_TRACE(Service_FS, "Write %s %s: offset=0x%llx length=%d address=0x%x, flush=0x%x", GetTypeName().c_str(), GetName().c_str(), offset, length, address, flush); - cmd_buff[2] = static_cast<u32>(backend->Write(offset, length, flush, Memory::GetPointer(address))); + cmd_buff[2] = static_cast<u32>(backend->Write(offset, length, flush != 0, Memory::GetPointer(address))); break; } diff --git a/src/core/hle/service/fs/archive.h b/src/core/hle/service/fs/archive.h index 357b6b09..f6112595 100644 --- a/src/core/hle/service/fs/archive.h +++ b/src/core/hle/service/fs/archive.h @@ -4,22 +4,25 @@ #pragma once +#include <memory> +#include <string> + #include "common/common_types.h" #include "core/file_sys/archive_backend.h" -#include "core/hle/kernel/kernel.h" #include "core/hle/kernel/session.h" #include "core/hle/result.h" +namespace FileSys { +class DirectoryBackend; +class FileBackend; +} + /// The unique system identifier hash, also known as ID0 extern const std::string SYSTEM_ID; /// The scrambled SD card CID, also known as ID1 extern const std::string SDCARD_ID; -namespace Kernel { - class Session; -} - namespace Service { namespace FS { diff --git a/src/core/hle/service/fs/fs_user.cpp b/src/core/hle/service/fs/fs_user.cpp index 0ad44e55..ae52083f 100644 --- a/src/core/hle/service/fs/fs_user.cpp +++ b/src/core/hle/service/fs/fs_user.cpp @@ -115,7 +115,8 @@ static void OpenFileDirectly(Service::Interface* self) { ResultVal<ArchiveHandle> archive_handle = OpenArchive(archive_id, archive_path); if (archive_handle.Failed()) { - LOG_ERROR(Service_FS, "failed to get a handle for archive"); + LOG_ERROR(Service_FS, "failed to get a handle for archive archive_id=0x%08X archive_path=%s", + archive_id, archive_path.DebugStr().c_str()); cmd_buff[1] = archive_handle.Code().raw; cmd_buff[3] = 0; return; @@ -128,7 +129,8 @@ static void OpenFileDirectly(Service::Interface* self) { cmd_buff[3] = Kernel::g_handle_table.Create(*file_res).MoveFrom(); } else { cmd_buff[3] = 0; - LOG_ERROR(Service_FS, "failed to get a handle for file %s", file_path.DebugStr().c_str()); + LOG_ERROR(Service_FS, "failed to get a handle for file %s mode=%u attributes=%d", + file_path.DebugStr().c_str(), mode.hex, attributes); } } @@ -347,7 +349,8 @@ static void OpenDirectory(Service::Interface* self) { if (dir_res.Succeeded()) { cmd_buff[3] = Kernel::g_handle_table.Create(*dir_res).MoveFrom(); } else { - LOG_ERROR(Service_FS, "failed to get a handle for directory"); + LOG_ERROR(Service_FS, "failed to get a handle for directory type=%d size=%d data=%s", + dirname_type, dirname_size, dir_path.DebugStr().c_str()); } } @@ -382,7 +385,8 @@ static void OpenArchive(Service::Interface* self) { cmd_buff[3] = (*handle >> 32) & 0xFFFFFFFF; } else { cmd_buff[2] = cmd_buff[3] = 0; - LOG_ERROR(Service_FS, "failed to get a handle for archive"); + LOG_ERROR(Service_FS, "failed to get a handle for archive archive_id=0x%08X archive_path=%s", + archive_id, archive_path.DebugStr().c_str()); } } diff --git a/src/core/hle/service/gsp_gpu.cpp b/src/core/hle/service/gsp_gpu.cpp index 4b0b4229..e93c1b43 100644 --- a/src/core/hle/service/gsp_gpu.cpp +++ b/src/core/hle/service/gsp_gpu.cpp @@ -9,14 +9,17 @@ #include "core/hle/kernel/event.h" #include "core/hle/kernel/shared_memory.h" #include "core/hle/result.h" -#include "gsp_gpu.h" #include "core/hw/hw.h" #include "core/hw/gpu.h" #include "core/hw/lcd.h" #include "video_core/gpu_debugger.h" +#include "video_core/debug_utils/debug_utils.h" +#include "video_core/renderer_base.h" #include "video_core/video_core.h" +#include "gsp_gpu.h" + // Main graphics debugger object - TODO: Here is probably not the best place for this GraphicsDebugger g_debugger; @@ -40,7 +43,7 @@ static inline u8* GetCommandBuffer(u32 thread_id) { return g_shared_memory->GetPointer(0x800 + (thread_id * sizeof(CommandBuffer))); } -static inline FrameBufferUpdate* GetFrameBufferInfo(u32 thread_id, u32 screen_index) { +FrameBufferUpdate* GetFrameBufferInfo(u32 thread_id, u32 screen_index) { DEBUG_ASSERT_MSG(screen_index < 2, "Invalid screen index"); // For each thread there are two FrameBufferUpdate fields @@ -203,7 +206,7 @@ static void ReadHWRegs(Service::Interface* self) { } } -static void SetBufferSwap(u32 screen_id, const FrameBufferInfo& info) { +void SetBufferSwap(u32 screen_id, const FrameBufferInfo& info) { u32 base_address = 0x400000; PAddr phys_address_left = Memory::VirtualToPhysicalAddress(info.address_left); PAddr phys_address_right = Memory::VirtualToPhysicalAddress(info.address_right); @@ -224,6 +227,9 @@ static void SetBufferSwap(u32 screen_id, const FrameBufferInfo& info) { &info.format); WriteHWRegs(base_address + 4 * static_cast<u32>(GPU_REG_INDEX(framebuffer_config[screen_id].active_fb)), 4, &info.shown_fb); + + if (Pica::g_debug_context) + Pica::g_debug_context->OnEvent(Pica::DebugContext::Event::BufferSwapped, nullptr); } /** @@ -347,7 +353,7 @@ void SignalInterrupt(InterruptId interrupt_id) { /// Executes the next GSP command static void ExecuteCommand(const Command& command, u32 thread_id) { // Utility function to convert register ID to address - auto WriteGPURegister = [](u32 id, u32 data) { + static auto WriteGPURegister = [](u32 id, u32 data) { GPU::Write<u32>(0x1EF00000 + 4 * id, data); }; @@ -389,19 +395,24 @@ static void ExecuteCommand(const Command& command, u32 thread_id) { case CommandId::SET_MEMORY_FILL: { auto& params = command.memory_fill; - WriteGPURegister(static_cast<u32>(GPU_REG_INDEX(memory_fill_config[0].address_start)), - Memory::VirtualToPhysicalAddress(params.start1) >> 3); - WriteGPURegister(static_cast<u32>(GPU_REG_INDEX(memory_fill_config[0].address_end)), - Memory::VirtualToPhysicalAddress(params.end1) >> 3); - WriteGPURegister(static_cast<u32>(GPU_REG_INDEX(memory_fill_config[0].value_32bit)), params.value1); - WriteGPURegister(static_cast<u32>(GPU_REG_INDEX(memory_fill_config[0].control)), params.control1); - - WriteGPURegister(static_cast<u32>(GPU_REG_INDEX(memory_fill_config[1].address_start)), - Memory::VirtualToPhysicalAddress(params.start2) >> 3); - WriteGPURegister(static_cast<u32>(GPU_REG_INDEX(memory_fill_config[1].address_end)), - Memory::VirtualToPhysicalAddress(params.end2) >> 3); - WriteGPURegister(static_cast<u32>(GPU_REG_INDEX(memory_fill_config[1].value_32bit)), params.value2); - WriteGPURegister(static_cast<u32>(GPU_REG_INDEX(memory_fill_config[1].control)), params.control2); + + if (params.start1 != 0) { + WriteGPURegister(static_cast<u32>(GPU_REG_INDEX(memory_fill_config[0].address_start)), + Memory::VirtualToPhysicalAddress(params.start1) >> 3); + WriteGPURegister(static_cast<u32>(GPU_REG_INDEX(memory_fill_config[0].address_end)), + Memory::VirtualToPhysicalAddress(params.end1) >> 3); + WriteGPURegister(static_cast<u32>(GPU_REG_INDEX(memory_fill_config[0].value_32bit)), params.value1); + WriteGPURegister(static_cast<u32>(GPU_REG_INDEX(memory_fill_config[0].control)), params.control1); + } + + if (params.start2 != 0) { + WriteGPURegister(static_cast<u32>(GPU_REG_INDEX(memory_fill_config[1].address_start)), + Memory::VirtualToPhysicalAddress(params.start2) >> 3); + WriteGPURegister(static_cast<u32>(GPU_REG_INDEX(memory_fill_config[1].address_end)), + Memory::VirtualToPhysicalAddress(params.end2) >> 3); + WriteGPURegister(static_cast<u32>(GPU_REG_INDEX(memory_fill_config[1].value_32bit)), params.value2); + WriteGPURegister(static_cast<u32>(GPU_REG_INDEX(memory_fill_config[1].control)), params.control2); + } break; } @@ -446,6 +457,9 @@ static void ExecuteCommand(const Command& command, u32 thread_id) { default: LOG_ERROR(Service_GSP, "unknown command 0x%08X", (int)command.id.Value()); } + + if (Pica::g_debug_context) + Pica::g_debug_context->OnEvent(Pica::DebugContext::Event::GSPCommandProcessed, (void*)&command); } /** @@ -582,7 +596,7 @@ const Interface::FunctionInfo FunctionTable[] = { Interface::Interface() { Register(FunctionTable); - g_interrupt_event = 0; + g_interrupt_event = nullptr; using Kernel::MemoryPermission; g_shared_memory = Kernel::SharedMemory::Create(0x1000, MemoryPermission::ReadWrite, @@ -591,4 +605,9 @@ Interface::Interface() { g_thread_id = 0; } +Interface::~Interface() { + g_interrupt_event = nullptr; + g_shared_memory = nullptr; +} + } // namespace diff --git a/src/core/hle/service/gsp_gpu.h b/src/core/hle/service/gsp_gpu.h index a435d418..c89d0a46 100644 --- a/src/core/hle/service/gsp_gpu.h +++ b/src/core/hle/service/gsp_gpu.h @@ -5,8 +5,11 @@ #pragma once #include <cstddef> +#include <string> #include "common/bit_field.h" +#include "common/common_types.h" + #include "core/hle/service/service.h" //////////////////////////////////////////////////////////////////////////////////////////////////// @@ -158,6 +161,7 @@ static_assert(sizeof(CommandBuffer) == 0x200, "CommandBuffer struct has incorrec class Interface : public Service::Interface { public: Interface(); + ~Interface() override; std::string GetPortName() const override { return "gsp::Gpu"; @@ -170,4 +174,14 @@ public: */ void SignalInterrupt(InterruptId interrupt_id); +void SetBufferSwap(u32 screen_id, const FrameBufferInfo& info); + +/** + * Retrieves the framebuffer info stored in the GSP shared memory for the + * specified screen index and thread id. + * @param thread_id GSP thread id of the process that accesses the structure that we are requesting. + * @param screen_index Index of the screen we are requesting (Top = 0, Bottom = 1). + * @returns FramebufferUpdate Information about the specified framebuffer. + */ +FrameBufferUpdate* GetFrameBufferInfo(u32 thread_id, u32 screen_index); } // namespace diff --git a/src/core/hle/service/hid/hid.cpp b/src/core/hle/service/hid/hid.cpp index c7c1bb5a..c35b13b2 100644 --- a/src/core/hle/service/hid/hid.cpp +++ b/src/core/hle/service/hid/hid.cpp @@ -3,6 +3,7 @@ // Refer to the license.txt file included. #include "common/logging/log.h" +#include "common/emu_window.h" #include "core/hle/service/service.h" #include "core/hle/service/hid/hid.h" @@ -34,6 +35,16 @@ static Kernel::SharedPtr<Kernel::Event> event_debug_pad; static u32 next_pad_index; static u32 next_touch_index; +const std::array<Service::HID::PadState, Settings::NativeInput::NUM_INPUTS> pad_mapping = { + Service::HID::PAD_A, Service::HID::PAD_B, Service::HID::PAD_X, Service::HID::PAD_Y, + Service::HID::PAD_L, Service::HID::PAD_R, Service::HID::PAD_ZL, Service::HID::PAD_ZR, + Service::HID::PAD_START, Service::HID::PAD_SELECT, Service::HID::PAD_NONE, + Service::HID::PAD_UP, Service::HID::PAD_DOWN, Service::HID::PAD_LEFT, Service::HID::PAD_RIGHT, + Service::HID::PAD_CIRCLE_UP, Service::HID::PAD_CIRCLE_DOWN, Service::HID::PAD_CIRCLE_LEFT, Service::HID::PAD_CIRCLE_RIGHT, + Service::HID::PAD_C_UP, Service::HID::PAD_C_DOWN, Service::HID::PAD_C_LEFT, Service::HID::PAD_C_RIGHT +}; + + // TODO(peachum): // Add a method for setting analog input from joystick device for the circle Pad. // diff --git a/src/core/hle/service/hid/hid.h b/src/core/hle/service/hid/hid.h index 68e2bcee..517f4f2a 100644 --- a/src/core/hle/service/hid/hid.h +++ b/src/core/hle/service/hid/hid.h @@ -6,16 +6,18 @@ #include <array> -#include "core/hle/kernel/kernel.h" -#include "core/hle/service/service.h" +#ifndef _MSC_VER +#include <cstddef> +#endif +#include "core/settings.h" #include "common/bit_field.h" - -namespace Kernel { - class SharedMemory; - class Event; -} +#include "common/common_funcs.h" +#include "common/common_types.h" namespace Service { + +class Interface; + namespace HID { /** @@ -155,6 +157,9 @@ const PadState PAD_CIRCLE_LEFT = {{1u << 29}}; const PadState PAD_CIRCLE_UP = {{1u << 30}}; const PadState PAD_CIRCLE_DOWN = {{1u << 31}}; + +extern const std::array<Service::HID::PadState, Settings::NativeInput::NUM_INPUTS> pad_mapping; + /** * HID::GetIPCHandles service function * Inputs: diff --git a/src/core/hle/service/nwm_uds.cpp b/src/core/hle/service/nwm_uds.cpp index 25b01860..18b22956 100644 --- a/src/core/hle/service/nwm_uds.cpp +++ b/src/core/hle/service/nwm_uds.cpp @@ -125,4 +125,8 @@ Interface::Interface() { Register(FunctionTable); } +Interface::~Interface() { + handle_event = nullptr; +} + } // namespace diff --git a/src/core/hle/service/nwm_uds.h b/src/core/hle/service/nwm_uds.h index 82abdff2..0ced2359 100644 --- a/src/core/hle/service/nwm_uds.h +++ b/src/core/hle/service/nwm_uds.h @@ -16,6 +16,7 @@ namespace NWM_UDS { class Interface : public Service::Interface { public: Interface(); + ~Interface() override; std::string GetPortName() const override { return "nwm::UDS"; diff --git a/src/core/hle/service/service.cpp b/src/core/hle/service/service.cpp index d681cc3d..0de0b13a 100644 --- a/src/core/hle/service/service.cpp +++ b/src/core/hle/service/service.cpp @@ -54,7 +54,7 @@ static std::string MakeFunctionString(const char* name, const char* port_name, c std::string function_string = Common::StringFromFormat("function '%s': port=%s", name, port_name); for (int i = 1; i <= num_params; ++i) { - function_string += Common::StringFromFormat(", cmd_buff[%i]=%u", i, cmd_buff[i]); + function_string += Common::StringFromFormat(", cmd_buff[%i]=0x%X", i, cmd_buff[i]); } return function_string; } diff --git a/src/core/hle/service/service.h b/src/core/hle/service/service.h index 77bfb9ff..f3113521 100644 --- a/src/core/hle/service/service.h +++ b/src/core/hle/service/service.h @@ -4,6 +4,7 @@ #pragma once +#include <cstddef> #include <string> #include <unordered_map> @@ -11,8 +12,8 @@ #include "common/common_types.h" -#include "core/hle/kernel/kernel.h" #include "core/hle/kernel/session.h" +#include "core/hle/result.h" //////////////////////////////////////////////////////////////////////////////////////////////////// // Namespace Service diff --git a/src/core/hle/service/soc_u.cpp b/src/core/hle/service/soc_u.cpp index 3f0c5e38..d768a3fc 100644 --- a/src/core/hle/service/soc_u.cpp +++ b/src/core/hle/service/soc_u.cpp @@ -2,40 +2,47 @@ // Licensed under GPLv2 or any later version // Refer to the license.txt file included. +#include <algorithm> +#include <cstring> +#include <unordered_map> + +#include "common/assert.h" +#include "common/bit_field.h" +#include "common/common_types.h" #include "common/logging/log.h" -#include "common/platform.h" - -#if EMU_PLATFORM == PLATFORM_WINDOWS -#include <winsock2.h> -#include <ws2tcpip.h> - -// MinGW does not define several errno constants -#ifndef _MSC_VER -#define EBADMSG 104 -#define ENODATA 120 -#define ENOMSG 122 -#define ENOSR 124 -#define ENOSTR 125 -#define ETIME 137 -#define EIDRM 2001 -#define ENOLINK 2002 -#endif // _MSC_VER +#include "common/scope_exit.h" +#include "core/hle/kernel/session.h" +#include "core/hle/result.h" +#include "core/hle/service/soc_u.h" +#include "core/memory.h" + +#ifdef _WIN32 + #include <winsock2.h> + #include <ws2tcpip.h> + + // MinGW does not define several errno constants + #ifndef _MSC_VER + #define EBADMSG 104 + #define ENODATA 120 + #define ENOMSG 122 + #define ENOSR 124 + #define ENOSTR 125 + #define ETIME 137 + #define EIDRM 2001 + #define ENOLINK 2002 + #endif // _MSC_VER #else -#include <sys/socket.h> -#include <netinet/in.h> -#include <netdb.h> -#include <arpa/inet.h> -#include <fcntl.h> -#include <poll.h> + #include <cerrno> + #include <fcntl.h> + #include <netinet/in.h> + #include <netdb.h> + #include <poll.h> + #include <sys/socket.h> + #include <unistd.h> #endif -#include "common/scope_exit.h" -#include "core/hle/hle.h" -#include "core/hle/service/soc_u.h" -#include <unordered_map> - -#if EMU_PLATFORM == PLATFORM_WINDOWS +#ifdef _WIN32 # define WSAEAGAIN WSAEWOULDBLOCK # define WSAEMULTIHOP -1 // Invalid dummy value # define ERRNO(x) WSA##x @@ -328,6 +335,7 @@ static void Socket(Service::Interface* self) { if ((s32)socket_handle == SOCKET_ERROR_VALUE) result = TranslateError(GET_ERRNO); + cmd_buffer[0] = IPC::MakeHeader(2, 2, 0); cmd_buffer[1] = result; cmd_buffer[2] = socket_handle; } @@ -351,8 +359,9 @@ static void Bind(Service::Interface* self) { if (res != 0) result = TranslateError(GET_ERRNO); - cmd_buffer[2] = res; + cmd_buffer[0] = IPC::MakeHeader(5, 2, 0); cmd_buffer[1] = result; + cmd_buffer[2] = res; } static void Fcntl(Service::Interface* self) { @@ -369,7 +378,7 @@ static void Fcntl(Service::Interface* self) { }); if (ctr_cmd == 3) { // F_GETFL -#if EMU_PLATFORM == PLATFORM_WINDOWS +#ifdef _WIN32 posix_ret = 0; auto iter = open_sockets.find(socket_handle); if (iter != open_sockets.end() && iter->second.blocking == false) @@ -386,7 +395,7 @@ static void Fcntl(Service::Interface* self) { posix_ret |= 4; // O_NONBLOCK #endif } else if (ctr_cmd == 4) { // F_SETFL -#if EMU_PLATFORM == PLATFORM_WINDOWS +#ifdef _WIN32 unsigned long tmp = (ctr_arg & 4 /* O_NONBLOCK */) ? 1 : 0; int ret = ioctlsocket(socket_handle, FIONBIO, &tmp); if (ret == SOCKET_ERROR_VALUE) { @@ -434,8 +443,9 @@ static void Listen(Service::Interface* self) { if (ret != 0) result = TranslateError(GET_ERRNO); - cmd_buffer[2] = ret; + cmd_buffer[0] = IPC::MakeHeader(3, 2, 0); cmd_buffer[1] = result; + cmd_buffer[2] = ret; } static void Accept(Service::Interface* self) { @@ -460,8 +470,10 @@ static void Accept(Service::Interface* self) { Memory::WriteBlock(cmd_buffer[0x104 >> 2], (const u8*)&ctr_addr, max_addr_len); } - cmd_buffer[2] = ret; + cmd_buffer[0] = IPC::MakeHeader(4, 2, 2); cmd_buffer[1] = result; + cmd_buffer[2] = ret; + cmd_buffer[3] = IPC::StaticBufferDesc(static_cast<u32>(max_addr_len), 0); } static void GetHostId(Service::Interface* self) { @@ -675,26 +687,29 @@ static void Connect(Service::Interface* self) { int result = 0; if (ret != 0) result = TranslateError(GET_ERRNO); - cmd_buffer[2] = ret; + + cmd_buffer[0] = IPC::MakeHeader(6, 2, 0); cmd_buffer[1] = result; + cmd_buffer[2] = ret; } static void InitializeSockets(Service::Interface* self) { // TODO(Subv): Implement -#if EMU_PLATFORM == PLATFORM_WINDOWS +#ifdef _WIN32 WSADATA data; WSAStartup(MAKEWORD(2, 2), &data); #endif u32* cmd_buffer = Kernel::GetCommandBuffer(); - cmd_buffer[1] = 0; + cmd_buffer[0] = IPC::MakeHeader(1, 1, 0); + cmd_buffer[1] = RESULT_SUCCESS.raw; } static void ShutdownSockets(Service::Interface* self) { // TODO(Subv): Implement CleanupSockets(); -#if EMU_PLATFORM == PLATFORM_WINDOWS +#ifdef _WIN32 WSACleanup(); #endif @@ -745,7 +760,7 @@ Interface::Interface() { Interface::~Interface() { CleanupSockets(); -#if EMU_PLATFORM == PLATFORM_WINDOWS +#ifdef _WIN32 WSACleanup(); #endif } diff --git a/src/core/hle/service/soc_u.h b/src/core/hle/service/soc_u.h index 483b3111..a091f597 100644 --- a/src/core/hle/service/soc_u.h +++ b/src/core/hle/service/soc_u.h @@ -4,6 +4,8 @@ #pragma once +#include <string> + #include "core/hle/service/service.h" //////////////////////////////////////////////////////////////////////////////////////////////////// diff --git a/src/core/hle/service/srv.cpp b/src/core/hle/service/srv.cpp index 6c49fa6c..3b8c7c0e 100644 --- a/src/core/hle/service/srv.cpp +++ b/src/core/hle/service/srv.cpp @@ -68,4 +68,8 @@ Interface::Interface() { Register(FunctionTable); } +Interface::~Interface() { + event_handle = nullptr; +} + } // namespace diff --git a/src/core/hle/service/srv.h b/src/core/hle/service/srv.h index 653aba5c..96c89b02 100644 --- a/src/core/hle/service/srv.h +++ b/src/core/hle/service/srv.h @@ -13,6 +13,7 @@ namespace SRV { class Interface : public Service::Interface { public: Interface(); + ~Interface() override; std::string GetPortName() const override { return "srv:"; diff --git a/src/core/hle/service/y2r_u.cpp b/src/core/hle/service/y2r_u.cpp index ac1967da..6e7dafaa 100644 --- a/src/core/hle/service/y2r_u.cpp +++ b/src/core/hle/service/y2r_u.cpp @@ -12,6 +12,7 @@ #include "core/hw/y2r.h" #include "core/mem_map.h" +#include "video_core/renderer_base.h" #include "video_core/utils.h" #include "video_core/video_core.h" @@ -409,4 +410,8 @@ Interface::Interface() { Register(FunctionTable); } +Interface::~Interface() { + completion_event = nullptr; +} + } // namespace diff --git a/src/core/hle/service/y2r_u.h b/src/core/hle/service/y2r_u.h index 7df47fcb..3965a554 100644 --- a/src/core/hle/service/y2r_u.h +++ b/src/core/hle/service/y2r_u.h @@ -5,9 +5,11 @@ #pragma once #include <array> +#include <string> #include "common/common_types.h" +#include "core/hle/result.h" #include "core/hle/service/service.h" //////////////////////////////////////////////////////////////////////////////////////////////////// @@ -110,6 +112,7 @@ struct ConversionConfiguration { class Interface : public Service::Interface { public: Interface(); + ~Interface() override; std::string GetPortName() const override { return "y2r:u"; |