From 335096e19a50b38f5ccf81a3d4942a4a0e4dc546 Mon Sep 17 00:00:00 2001 From: mailwl Date: Wed, 7 Feb 2018 15:11:17 +0300 Subject: [PATCH] Service: stub some functions in am, audio, time, vi services --- src/core/hle/service/am/am.cpp | 78 ++++++++++++++++++++- src/core/hle/service/am/am.h | 5 ++ src/core/hle/service/audio/audren_u.cpp | 51 ++++++++++++-- src/core/hle/service/audio/audren_u.h | 4 ++ src/core/hle/service/filesystem/fsp_srv.cpp | 1 + src/core/hle/service/hid/hid.cpp | 22 ++++++ src/core/hle/service/time/time.cpp | 13 ++++ src/core/hle/service/vi/vi.cpp | 22 +++++- src/core/hle/service/vi/vi.h | 1 + 9 files changed, 191 insertions(+), 6 deletions(-) diff --git a/src/core/hle/service/am/am.cpp b/src/core/hle/service/am/am.cpp index b3341d9adb..07cea87173 100644 --- a/src/core/hle/service/am/am.cpp +++ b/src/core/hle/service/am/am.cpp @@ -45,6 +45,7 @@ ISelfController::ISelfController(std::shared_ptr nvflinger static const FunctionInfo functions[] = { {1, &ISelfController::LockExit, "LockExit"}, {2, &ISelfController::UnlockExit, "UnlockExit"}, + {9, &ISelfController::GetLibraryAppletLaunchableEvent, "GetLibraryAppletLaunchableEvent"}, {11, &ISelfController::SetOperationModeChangedNotification, "SetOperationModeChangedNotification"}, {12, &ISelfController::SetPerformanceModeChangedNotification, @@ -55,6 +56,9 @@ ISelfController::ISelfController(std::shared_ptr nvflinger {40, &ISelfController::CreateManagedDisplayLayer, "CreateManagedDisplayLayer"}, }; RegisterHandlers(functions); + + launchable_event = + Kernel::Event::Create(Kernel::ResetType::OneShot, "ISelfController:LaunchableEvent"); } void ISelfController::SetFocusHandlingMode(Kernel::HLERequestContext& ctx) { @@ -132,6 +136,16 @@ void ISelfController::UnlockExit(Kernel::HLERequestContext& ctx) { LOG_WARNING(Service_AM, "(STUBBED) called"); } +void ISelfController::GetLibraryAppletLaunchableEvent(Kernel::HLERequestContext& ctx) { + launchable_event->Signal(); + + IPC::ResponseBuilder rb{ctx, 2, 1}; + rb.Push(RESULT_SUCCESS); + rb.PushCopyObjects(launchable_event); + + LOG_WARNING(Service_AM, "(STUBBED) called"); +} + void ISelfController::CreateManagedDisplayLayer(Kernel::HLERequestContext& ctx) { // TODO(Subv): Find out how AM determines the display to use, for now just create the layer // in the Default display. @@ -200,7 +214,69 @@ void ICommonStateGetter::GetPerformanceMode(Kernel::HLERequestContext& ctx) { LOG_WARNING(Service_AM, "(STUBBED) called"); } -ILibraryAppletCreator::ILibraryAppletCreator() : ServiceFramework("ILibraryAppletCreator") {} +class ILibraryAppletAccessor final : public ServiceFramework { +public: + explicit ILibraryAppletAccessor() : ServiceFramework("ILibraryAppletAccessor") { + static const FunctionInfo functions[] = { + {0, &ILibraryAppletAccessor::GetAppletStateChangedEvent, "GetAppletStateChangedEvent"}, + {1, nullptr, "IsCompleted"}, + {10, nullptr, "Start"}, + {20, nullptr, "RequestExit"}, + {25, nullptr, "Terminate"}, + {30, nullptr, "GetResult"}, + {50, nullptr, "SetOutOfFocusApplicationSuspendingEnabled"}, + {100, nullptr, "PushInData"}, + {101, nullptr, "PopOutData"}, + {102, nullptr, "PushExtraStorage"}, + {103, nullptr, "PushInteractiveInData"}, + {104, nullptr, "PopInteractiveOutData"}, + {105, nullptr, "GetPopOutDataEvent"}, + {106, nullptr, "GetPopInteractiveOutDataEvent"}, + {120, nullptr, "NeedsToExitProcess"}, + {120, nullptr, "GetLibraryAppletInfo"}, + {150, nullptr, "RequestForAppletToGetForeground"}, + {160, nullptr, "GetIndirectLayerConsumerHandle"}, + }; + RegisterHandlers(functions); + + state_changed_event = Kernel::Event::Create(Kernel::ResetType::OneShot, + "ILibraryAppletAccessor:StateChangedEvent"); + } + +private: + void GetAppletStateChangedEvent(Kernel::HLERequestContext& ctx) { + state_changed_event->Signal(); + + IPC::ResponseBuilder rb{ctx, 2, 1}; + rb.Push(RESULT_SUCCESS); + rb.PushCopyObjects(state_changed_event); + + LOG_WARNING(Service_AM, "(STUBBED) called"); + } + + Kernel::SharedPtr state_changed_event; +}; + +ILibraryAppletCreator::ILibraryAppletCreator() : ServiceFramework("ILibraryAppletCreator") { + static const FunctionInfo functions[] = { + {0, &ILibraryAppletCreator::CreateLibraryApplet, "CreateLibraryApplet"}, + {1, nullptr, "TerminateAllLibraryApplets"}, + {2, nullptr, "AreAnyLibraryAppletsLeft"}, + {10, nullptr, "CreateStorage"}, + {11, nullptr, "CreateTransferMemoryStorage"}, + {12, nullptr, "CreateHandleStorage"}, + }; + RegisterHandlers(functions); +} + +void ILibraryAppletCreator::CreateLibraryApplet(Kernel::HLERequestContext& ctx) { + IPC::ResponseBuilder rb{ctx, 2, 0, 1}; + + rb.Push(RESULT_SUCCESS); + rb.PushIpcInterface(); + + LOG_DEBUG(Service_AM, "called"); +} class IStorageAccessor final : public ServiceFramework { public: diff --git a/src/core/hle/service/am/am.h b/src/core/hle/service/am/am.h index 0f17f8377f..793ac65559 100644 --- a/src/core/hle/service/am/am.h +++ b/src/core/hle/service/am/am.h @@ -60,9 +60,11 @@ private: void SetOutOfFocusSuspendingEnabled(Kernel::HLERequestContext& ctx); void LockExit(Kernel::HLERequestContext& ctx); void UnlockExit(Kernel::HLERequestContext& ctx); + void GetLibraryAppletLaunchableEvent(Kernel::HLERequestContext& ctx); void CreateManagedDisplayLayer(Kernel::HLERequestContext& ctx); std::shared_ptr nvflinger; + Kernel::SharedPtr launchable_event; }; class ICommonStateGetter final : public ServiceFramework { @@ -92,6 +94,9 @@ private: class ILibraryAppletCreator final : public ServiceFramework { public: ILibraryAppletCreator(); + +private: + void CreateLibraryApplet(Kernel::HLERequestContext& ctx); }; class IApplicationFunctions final : public ServiceFramework { diff --git a/src/core/hle/service/audio/audren_u.cpp b/src/core/hle/service/audio/audren_u.cpp index 4bafdfac3a..4c3a685e95 100644 --- a/src/core/hle/service/audio/audren_u.cpp +++ b/src/core/hle/service/audio/audren_u.cpp @@ -4,6 +4,7 @@ #include "common/logging/log.h" #include "core/hle/ipc_helpers.h" +#include "core/hle/kernel/event.h" #include "core/hle/kernel/hle_ipc.h" #include "core/hle/service/audio/audren_u.h" @@ -18,27 +19,69 @@ public: {0x1, nullptr, "GetAudioRendererSampleCount"}, {0x2, nullptr, "GetAudioRendererMixBufferCount"}, {0x3, nullptr, "GetAudioRendererState"}, - {0x4, nullptr, "RequestUpdateAudioRenderer"}, + {0x4, &IAudioRenderer::RequestUpdateAudioRenderer, "RequestUpdateAudioRenderer"}, {0x5, nullptr, "StartAudioRenderer"}, {0x6, nullptr, "StopAudioRenderer"}, - {0x7, nullptr, "QuerySystemEvent"}, + {0x7, &IAudioRenderer::QuerySystemEvent, "QuerySystemEvent"}, {0x8, nullptr, "SetAudioRendererRenderingTimeLimit"}, {0x9, nullptr, "GetAudioRendererRenderingTimeLimit"}, }; RegisterHandlers(functions); + + system_event = + Kernel::Event::Create(Kernel::ResetType::OneShot, "IAudioRenderer:SystemEvent"); } ~IAudioRenderer() = default; + +private: + void RequestUpdateAudioRenderer(Kernel::HLERequestContext& ctx) { + IPC::ResponseBuilder rb{ctx, 2}; + + rb.Push(RESULT_SUCCESS); + + LOG_WARNING(Service_Audio, "(STUBBED) called"); + } + + void QuerySystemEvent(Kernel::HLERequestContext& ctx) { + // system_event->Signal(); + + IPC::ResponseBuilder rb{ctx, 2, 1}; + rb.Push(RESULT_SUCCESS); + rb.PushCopyObjects(system_event); + + LOG_WARNING(Service_Audio, "(STUBBED) called"); + } + + Kernel::SharedPtr system_event; }; AudRenU::AudRenU() : ServiceFramework("audren:u") { static const FunctionInfo functions[] = { - {0x00000000, nullptr, "OpenAudioRenderer"}, - {0x00000001, nullptr, "GetAudioRendererWorkBufferSize"}, + {0x00000000, &AudRenU::OpenAudioRenderer, "OpenAudioRenderer"}, + {0x00000001, &AudRenU::GetAudioRendererWorkBufferSize, "GetAudioRendererWorkBufferSize"}, {0x00000002, nullptr, "GetAudioRenderersProcessMasterVolume"}, {0x00000003, nullptr, "SetAudioRenderersProcessMasterVolume"}, }; RegisterHandlers(functions); } +void AudRenU::OpenAudioRenderer(Kernel::HLERequestContext& ctx) { + IPC::ResponseBuilder rb{ctx, 2, 0, 1}; + + rb.Push(RESULT_SUCCESS); + rb.PushIpcInterface(); + + LOG_DEBUG(Service_Audio, "called"); +} + +void AudRenU::GetAudioRendererWorkBufferSize(Kernel::HLERequestContext& ctx) { + IPC::ResponseBuilder rb{ctx, 4}; + + rb.Push(RESULT_SUCCESS); + rb.Push(0x1000); + + LOG_WARNING(Service_Audio, "called"); +} + } // namespace Audio } // namespace Service diff --git a/src/core/hle/service/audio/audren_u.h b/src/core/hle/service/audio/audren_u.h index 1d9264c727..e975437423 100644 --- a/src/core/hle/service/audio/audren_u.h +++ b/src/core/hle/service/audio/audren_u.h @@ -17,6 +17,10 @@ class AudRenU final : public ServiceFramework { public: explicit AudRenU(); ~AudRenU() = default; + +private: + void OpenAudioRenderer(Kernel::HLERequestContext& ctx); + void GetAudioRendererWorkBufferSize(Kernel::HLERequestContext& ctx); }; } // namespace Audio diff --git a/src/core/hle/service/filesystem/fsp_srv.cpp b/src/core/hle/service/filesystem/fsp_srv.cpp index 71b82393e4..aa5a3d6311 100644 --- a/src/core/hle/service/filesystem/fsp_srv.cpp +++ b/src/core/hle/service/filesystem/fsp_srv.cpp @@ -71,6 +71,7 @@ FSP_SRV::FSP_SRV() : ServiceFramework("fsp-srv") { static const FunctionInfo functions[] = { {1, &FSP_SRV::Initalize, "Initalize"}, {200, &FSP_SRV::OpenDataStorageByCurrentProcess, "OpenDataStorageByCurrentProcess"}, + {202, nullptr, "OpenDataStorageByDataId"}, {203, &FSP_SRV::OpenRomStorage, "OpenRomStorage"}, {1005, &FSP_SRV::GetGlobalAccessLogMode, "GetGlobalAccessLogMode"}, }; diff --git a/src/core/hle/service/hid/hid.cpp b/src/core/hle/service/hid/hid.cpp index 3e35f59993..d757d2eae7 100644 --- a/src/core/hle/service/hid/hid.cpp +++ b/src/core/hle/service/hid/hid.cpp @@ -9,6 +9,7 @@ #include "core/hle/ipc_helpers.h" #include "core/hle/kernel/client_port.h" #include "core/hle/kernel/client_session.h" +#include "core/hle/kernel/event.h" #include "core/hle/kernel/shared_memory.h" #include "core/hle/service/hid/hid.h" #include "core/hle/service/service.h" @@ -179,17 +180,24 @@ public: {100, &Hid::SetSupportedNpadStyleSet, "SetSupportedNpadStyleSet"}, {102, &Hid::SetSupportedNpadIdType, "SetSupportedNpadIdType"}, {103, &Hid::ActivateNpad, "ActivateNpad"}, + {106, &Hid::AcquireNpadStyleSetUpdateEventHandle, + "AcquireNpadStyleSetUpdateEventHandle"}, {120, &Hid::SetNpadJoyHoldType, "SetNpadJoyHoldType"}, + {121, &Hid::GetNpadJoyHoldType, "GetNpadJoyHoldType"}, {124, nullptr, "SetNpadJoyAssignmentModeDual"}, {128, &Hid::SetNpadHandheldActivationMode, "SetNpadHandheldActivationMode"}, {203, &Hid::CreateActiveVibrationDeviceList, "CreateActiveVibrationDeviceList"}, }; RegisterHandlers(functions); + + event = Kernel::Event::Create(Kernel::ResetType::OneShot, "hid:EventHandle"); } ~Hid() = default; private: std::shared_ptr applet_resource; + u32 joy_hold_type{0}; + Kernel::SharedPtr event; void CreateAppletResource(Kernel::HLERequestContext& ctx) { if (applet_resource == nullptr) { @@ -238,12 +246,26 @@ private: LOG_WARNING(Service_HID, "(STUBBED) called"); } + void AcquireNpadStyleSetUpdateEventHandle(Kernel::HLERequestContext& ctx) { + IPC::ResponseBuilder rb{ctx, 2, 1}; + rb.Push(RESULT_SUCCESS); + rb.PushCopyObjects(event); + LOG_WARNING(Service_HID, "(STUBBED) called"); + } + void SetNpadJoyHoldType(Kernel::HLERequestContext& ctx) { IPC::ResponseBuilder rb{ctx, 2}; rb.Push(RESULT_SUCCESS); LOG_WARNING(Service_HID, "(STUBBED) called"); } + void GetNpadJoyHoldType(Kernel::HLERequestContext& ctx) { + IPC::ResponseBuilder rb{ctx, 3}; + rb.Push(RESULT_SUCCESS); + rb.Push(joy_hold_type); + LOG_WARNING(Service_HID, "(STUBBED) called"); + } + void SetNpadHandheldActivationMode(Kernel::HLERequestContext& ctx) { IPC::ResponseBuilder rb{ctx, 2}; rb.Push(RESULT_SUCCESS); diff --git a/src/core/hle/service/time/time.cpp b/src/core/hle/service/time/time.cpp index 532b9c1c57..364ddcea24 100644 --- a/src/core/hle/service/time/time.cpp +++ b/src/core/hle/service/time/time.cpp @@ -68,8 +68,15 @@ public: ITimeZoneService() : ServiceFramework("ITimeZoneService") { static const FunctionInfo functions[] = { {0, &ITimeZoneService::GetDeviceLocationName, "GetDeviceLocationName"}, + {1, nullptr, "SetDeviceLocationName"}, {2, &ITimeZoneService::GetTotalLocationNameCount, "GetTotalLocationNameCount"}, + {3, nullptr, "LoadLocationNameList"}, + {4, &ITimeZoneService::LoadTimeZoneRule, "LoadTimeZoneRule"}, + {5, nullptr, "GetTimeZoneRuleVersion"}, + {100, nullptr, "ToCalendarTime"}, {101, &ITimeZoneService::ToCalendarTimeWithMyRule, "ToCalendarTimeWithMyRule"}, + {200, nullptr, "ToPosixTime"}, + {201, nullptr, "ToPosixTimeWithMyRule"}, }; RegisterHandlers(functions); } @@ -90,6 +97,12 @@ private: rb.Push(0); } + void LoadTimeZoneRule(Kernel::HLERequestContext& ctx) { + LOG_WARNING(Service_Time, "(STUBBED) called"); + IPC::ResponseBuilder rb{ctx, 2}; + rb.Push(RESULT_SUCCESS); + } + void ToCalendarTimeWithMyRule(Kernel::HLERequestContext& ctx) { IPC::RequestParser rp{ctx}; u64 posix_time = rp.Pop(); diff --git a/src/core/hle/service/vi/vi.cpp b/src/core/hle/service/vi/vi.cpp index adefba2b7a..cfddd7c416 100644 --- a/src/core/hle/service/vi/vi.cpp +++ b/src/core/hle/service/vi/vi.cpp @@ -19,6 +19,15 @@ namespace Service { namespace VI { +struct DisplayInfo { + char display_name[0x40]{"Default"}; + u64 unknown_1{1}; + u64 unknown_2{1}; + u64 width{1920}; + u64 height{1080}; +}; +static_assert(sizeof(DisplayInfo) == 0x60, "DisplayInfo has wrong size"); + class Parcel { public: // This default size was chosen arbitrarily. @@ -722,6 +731,17 @@ void IApplicationDisplayService::SetLayerScalingMode(Kernel::HLERequestContext& rb.Push(RESULT_SUCCESS); } +void IApplicationDisplayService::ListDisplays(Kernel::HLERequestContext& ctx) { + IPC::RequestParser rp{ctx}; + DisplayInfo display_info; + auto& buffer = ctx.BufferDescriptorB()[0]; + Memory::WriteBlock(buffer.Address(), &display_info, sizeof(DisplayInfo)); + IPC::ResponseBuilder rb = rp.MakeBuilder(4, 0, 0); + rb.Push(RESULT_SUCCESS); + rb.Push(1); + LOG_WARNING(Service_VI, "(STUBBED) called"); +} + void IApplicationDisplayService::GetDisplayVsyncEvent(Kernel::HLERequestContext& ctx) { LOG_WARNING(Service_VI, "(STUBBED) called"); IPC::RequestParser rp{ctx}; @@ -743,7 +763,7 @@ IApplicationDisplayService::IApplicationDisplayService( {102, &IApplicationDisplayService::GetManagerDisplayService, "GetManagerDisplayService"}, {103, &IApplicationDisplayService::GetIndirectDisplayTransactionService, "GetIndirectDisplayTransactionService"}, - {1000, nullptr, "ListDisplays"}, + {1000, &IApplicationDisplayService::ListDisplays, "ListDisplays"}, {1010, &IApplicationDisplayService::OpenDisplay, "OpenDisplay"}, {1020, &IApplicationDisplayService::CloseDisplay, "CloseDisplay"}, {2101, &IApplicationDisplayService::SetLayerScalingMode, "SetLayerScalingMode"}, diff --git a/src/core/hle/service/vi/vi.h b/src/core/hle/service/vi/vi.h index a6e084f874..f6be7d1e68 100644 --- a/src/core/hle/service/vi/vi.h +++ b/src/core/hle/service/vi/vi.h @@ -30,6 +30,7 @@ private: void OpenDisplay(Kernel::HLERequestContext& ctx); void CloseDisplay(Kernel::HLERequestContext& ctx); void SetLayerScalingMode(Kernel::HLERequestContext& ctx); + void ListDisplays(Kernel::HLERequestContext& ctx); void OpenLayer(Kernel::HLERequestContext& ctx); void CreateStrayLayer(Kernel::HLERequestContext& ctx); void DestroyStrayLayer(Kernel::HLERequestContext& ctx);