2018-01-13 21:22:39 +00:00
|
|
|
// Copyright 2018 yuzu emulator team
|
2017-10-15 02:50:04 +00:00
|
|
|
// Licensed under GPLv2 or any later version
|
|
|
|
// Refer to the license.txt file included.
|
|
|
|
|
2019-03-18 00:47:03 +00:00
|
|
|
#include <algorithm>
|
2018-08-21 14:59:37 +00:00
|
|
|
#include <array>
|
2018-03-04 18:03:58 +00:00
|
|
|
#include <cinttypes>
|
2018-10-11 01:49:20 +00:00
|
|
|
#include <cstring>
|
2018-11-10 01:08:25 +00:00
|
|
|
#include "audio_core/audio_renderer.h"
|
2018-07-17 19:42:15 +00:00
|
|
|
#include "core/core.h"
|
2019-05-23 07:55:56 +00:00
|
|
|
#include "core/file_sys/control_metadata.h"
|
|
|
|
#include "core/file_sys/patch_manager.h"
|
2018-12-11 03:17:45 +00:00
|
|
|
#include "core/file_sys/savedata_factory.h"
|
2018-02-02 21:03:40 +00:00
|
|
|
#include "core/hle/ipc_helpers.h"
|
2018-11-26 23:34:07 +00:00
|
|
|
#include "core/hle/kernel/kernel.h"
|
2018-07-17 19:42:15 +00:00
|
|
|
#include "core/hle/kernel/process.h"
|
2018-11-26 23:34:07 +00:00
|
|
|
#include "core/hle/kernel/readable_event.h"
|
2019-04-03 20:35:14 +00:00
|
|
|
#include "core/hle/kernel/transfer_memory.h"
|
2018-11-26 23:34:07 +00:00
|
|
|
#include "core/hle/kernel/writable_event.h"
|
2018-10-11 01:49:20 +00:00
|
|
|
#include "core/hle/service/acc/profile_manager.h"
|
2017-10-15 02:50:04 +00:00
|
|
|
#include "core/hle/service/am/am.h"
|
2018-02-02 21:03:40 +00:00
|
|
|
#include "core/hle/service/am/applet_ae.h"
|
2017-10-15 02:50:04 +00:00
|
|
|
#include "core/hle/service/am/applet_oe.h"
|
2018-11-22 20:58:00 +00:00
|
|
|
#include "core/hle/service/am/applets/applets.h"
|
2018-11-23 02:02:57 +00:00
|
|
|
#include "core/hle/service/am/applets/profile_select.h"
|
2018-11-22 20:58:00 +00:00
|
|
|
#include "core/hle/service/am/applets/software_keyboard.h"
|
2018-12-24 21:21:12 +00:00
|
|
|
#include "core/hle/service/am/applets/web_browser.h"
|
2018-07-31 11:01:49 +00:00
|
|
|
#include "core/hle/service/am/idle.h"
|
|
|
|
#include "core/hle/service/am/omm.h"
|
|
|
|
#include "core/hle/service/am/spsm.h"
|
2018-10-21 20:48:58 +00:00
|
|
|
#include "core/hle/service/am/tcap.h"
|
2019-06-29 02:46:51 +00:00
|
|
|
#include "core/hle/service/apm/controller.h"
|
|
|
|
#include "core/hle/service/apm/interface.h"
|
2018-03-04 18:03:58 +00:00
|
|
|
#include "core/hle/service/filesystem/filesystem.h"
|
2019-05-23 07:55:56 +00:00
|
|
|
#include "core/hle/service/ns/ns.h"
|
2018-02-02 21:03:40 +00:00
|
|
|
#include "core/hle/service/nvflinger/nvflinger.h"
|
2018-08-23 22:31:45 +00:00
|
|
|
#include "core/hle/service/pm/pm.h"
|
2018-04-29 00:30:53 +00:00
|
|
|
#include "core/hle/service/set/set.h"
|
2019-05-23 07:55:56 +00:00
|
|
|
#include "core/hle/service/sm/sm.h"
|
2018-09-18 15:10:16 +00:00
|
|
|
#include "core/hle/service/vi/vi.h"
|
2018-03-27 02:24:31 +00:00
|
|
|
#include "core/settings.h"
|
2017-10-15 02:50:04 +00:00
|
|
|
|
2018-04-20 01:41:44 +00:00
|
|
|
namespace Service::AM {
|
2017-10-15 02:50:04 +00:00
|
|
|
|
2018-11-19 19:24:36 +00:00
|
|
|
constexpr ResultCode ERR_NO_DATA_IN_CHANNEL{ErrorModule::AM, 0x2};
|
2019-01-04 02:11:17 +00:00
|
|
|
constexpr ResultCode ERR_NO_MESSAGES{ErrorModule::AM, 0x3};
|
2018-11-19 19:24:36 +00:00
|
|
|
constexpr ResultCode ERR_SIZE_OUT_OF_BOUNDS{ErrorModule::AM, 0x1F7};
|
|
|
|
|
2018-10-13 17:02:33 +00:00
|
|
|
constexpr u32 POP_LAUNCH_PARAMETER_MAGIC = 0xC79497CA;
|
|
|
|
|
|
|
|
struct LaunchParameters {
|
|
|
|
u32_le magic;
|
|
|
|
u32_le is_account_selected;
|
|
|
|
u128 current_user;
|
|
|
|
INSERT_PADDING_BYTES(0x70);
|
|
|
|
};
|
|
|
|
static_assert(sizeof(LaunchParameters) == 0x88);
|
2018-10-10 01:49:29 +00:00
|
|
|
|
2018-02-02 21:03:40 +00:00
|
|
|
IWindowController::IWindowController() : ServiceFramework("IWindowController") {
|
2018-10-21 20:40:17 +00:00
|
|
|
// clang-format off
|
2018-02-02 21:03:40 +00:00
|
|
|
static const FunctionInfo functions[] = {
|
2018-04-10 15:36:00 +00:00
|
|
|
{0, nullptr, "CreateWindow"},
|
2018-02-02 21:03:40 +00:00
|
|
|
{1, &IWindowController::GetAppletResourceUserId, "GetAppletResourceUserId"},
|
|
|
|
{10, &IWindowController::AcquireForegroundRights, "AcquireForegroundRights"},
|
2018-04-10 15:36:00 +00:00
|
|
|
{11, nullptr, "ReleaseForegroundRights"},
|
|
|
|
{12, nullptr, "RejectToChangeIntoBackground"},
|
2018-10-21 20:40:17 +00:00
|
|
|
{20, nullptr, "SetAppletWindowVisibility"},
|
|
|
|
{21, nullptr, "SetAppletGpuTimeSlice"},
|
2018-02-02 21:03:40 +00:00
|
|
|
};
|
2018-10-21 20:40:17 +00:00
|
|
|
// clang-format on
|
|
|
|
|
2018-02-02 21:03:40 +00:00
|
|
|
RegisterHandlers(functions);
|
|
|
|
}
|
|
|
|
|
hle/service: Default constructors and destructors in the cpp file where applicable
When a destructor isn't defaulted into a cpp file, it can cause the use
of forward declarations to seemingly fail to compile for non-obvious
reasons. It also allows inlining of the construction/destruction logic
all over the place where a constructor or destructor is invoked, which
can lead to code bloat. This isn't so much a worry here, given the
services won't be created and destroyed frequently.
The cause of the above mentioned non-obvious errors can be demonstrated
as follows:
------- Demonstrative example, if you know how the described error happens, skip forwards -------
Assume we have the following in the header, which we'll call "thing.h":
\#include <memory>
// Forward declaration. For example purposes, assume the definition
// of Object is in some header named "object.h"
class Object;
class Thing {
public:
// assume no constructors or destructors are specified here,
// or the constructors/destructors are defined as:
//
// Thing() = default;
// ~Thing() = default;
//
// ... Some interface member functions would be defined here
private:
std::shared_ptr<Object> obj;
};
If this header is included in a cpp file, (which we'll call "main.cpp"),
this will result in a compilation error, because even though no
destructor is specified, the destructor will still need to be generated by
the compiler because std::shared_ptr's destructor is *not* trivial (in
other words, it does something other than nothing), as std::shared_ptr's
destructor needs to do two things:
1. Decrement the shared reference count of the object being pointed to,
and if the reference count decrements to zero,
2. Free the Object instance's memory (aka deallocate the memory it's
pointing to).
And so the compiler generates the code for the destructor doing this inside main.cpp.
Now, keep in mind, the Object forward declaration is not a complete type. All it
does is tell the compiler "a type named Object exists" and allows us to
use the name in certain situations to avoid a header dependency. So the
compiler needs to generate destruction code for Object, but the compiler
doesn't know *how* to destruct it. A forward declaration doesn't tell
the compiler anything about Object's constructor or destructor. So, the
compiler will issue an error in this case because it's undefined
behavior to try and deallocate (or construct) an incomplete type and
std::shared_ptr and std::unique_ptr make sure this isn't the case
internally.
Now, if we had defaulted the destructor in "thing.cpp", where we also
include "object.h", this would never be an issue, as the destructor
would only have its code generated in one place, and it would be in a
place where the full class definition of Object would be visible to the
compiler.
---------------------- End example ----------------------------
Given these service classes are more than certainly going to change in
the future, this defaults the constructors and destructors into the
relevant cpp files to make the construction and destruction of all of
the services consistent and unlikely to run into cases where forward
declarations are indirectly causing compilation errors. It also has the
plus of avoiding the need to rebuild several services if destruction
logic changes, since it would only be necessary to recompile the single
cpp file.
2018-09-11 01:20:52 +00:00
|
|
|
IWindowController::~IWindowController() = default;
|
|
|
|
|
2018-02-02 21:03:40 +00:00
|
|
|
void IWindowController::GetAppletResourceUserId(Kernel::HLERequestContext& ctx) {
|
2018-12-18 02:01:06 +00:00
|
|
|
const u64 process_id = Core::System::GetInstance().Kernel().CurrentProcess()->GetProcessID();
|
|
|
|
|
|
|
|
LOG_DEBUG(Service_AM, "called. Process ID=0x{:016X}", process_id);
|
|
|
|
|
2018-02-02 21:03:40 +00:00
|
|
|
IPC::ResponseBuilder rb{ctx, 4};
|
|
|
|
rb.Push(RESULT_SUCCESS);
|
2018-12-18 02:01:06 +00:00
|
|
|
rb.Push<u64>(process_id);
|
2018-02-02 21:03:40 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void IWindowController::AcquireForegroundRights(Kernel::HLERequestContext& ctx) {
|
2018-07-02 16:13:26 +00:00
|
|
|
LOG_WARNING(Service_AM, "(STUBBED) called");
|
2018-02-02 21:03:40 +00:00
|
|
|
IPC::ResponseBuilder rb{ctx, 2};
|
|
|
|
rb.Push(RESULT_SUCCESS);
|
|
|
|
}
|
|
|
|
|
2018-02-22 14:28:15 +00:00
|
|
|
IAudioController::IAudioController() : ServiceFramework("IAudioController") {
|
2019-03-18 00:47:03 +00:00
|
|
|
// clang-format off
|
2018-02-22 14:28:15 +00:00
|
|
|
static const FunctionInfo functions[] = {
|
|
|
|
{0, &IAudioController::SetExpectedMasterVolume, "SetExpectedMasterVolume"},
|
2019-03-18 00:47:03 +00:00
|
|
|
{1, &IAudioController::GetMainAppletExpectedMasterVolume, "GetMainAppletExpectedMasterVolume"},
|
|
|
|
{2, &IAudioController::GetLibraryAppletExpectedMasterVolume, "GetLibraryAppletExpectedMasterVolume"},
|
2019-03-18 02:39:29 +00:00
|
|
|
{3, &IAudioController::ChangeMainAppletMasterVolume, "ChangeMainAppletMasterVolume"},
|
2019-03-18 01:09:25 +00:00
|
|
|
{4, &IAudioController::SetTransparentAudioRate, "SetTransparentVolumeRate"},
|
2018-02-22 14:28:15 +00:00
|
|
|
};
|
2019-03-18 00:47:03 +00:00
|
|
|
// clang-format on
|
|
|
|
|
2018-02-22 14:28:15 +00:00
|
|
|
RegisterHandlers(functions);
|
|
|
|
}
|
|
|
|
|
hle/service: Default constructors and destructors in the cpp file where applicable
When a destructor isn't defaulted into a cpp file, it can cause the use
of forward declarations to seemingly fail to compile for non-obvious
reasons. It also allows inlining of the construction/destruction logic
all over the place where a constructor or destructor is invoked, which
can lead to code bloat. This isn't so much a worry here, given the
services won't be created and destroyed frequently.
The cause of the above mentioned non-obvious errors can be demonstrated
as follows:
------- Demonstrative example, if you know how the described error happens, skip forwards -------
Assume we have the following in the header, which we'll call "thing.h":
\#include <memory>
// Forward declaration. For example purposes, assume the definition
// of Object is in some header named "object.h"
class Object;
class Thing {
public:
// assume no constructors or destructors are specified here,
// or the constructors/destructors are defined as:
//
// Thing() = default;
// ~Thing() = default;
//
// ... Some interface member functions would be defined here
private:
std::shared_ptr<Object> obj;
};
If this header is included in a cpp file, (which we'll call "main.cpp"),
this will result in a compilation error, because even though no
destructor is specified, the destructor will still need to be generated by
the compiler because std::shared_ptr's destructor is *not* trivial (in
other words, it does something other than nothing), as std::shared_ptr's
destructor needs to do two things:
1. Decrement the shared reference count of the object being pointed to,
and if the reference count decrements to zero,
2. Free the Object instance's memory (aka deallocate the memory it's
pointing to).
And so the compiler generates the code for the destructor doing this inside main.cpp.
Now, keep in mind, the Object forward declaration is not a complete type. All it
does is tell the compiler "a type named Object exists" and allows us to
use the name in certain situations to avoid a header dependency. So the
compiler needs to generate destruction code for Object, but the compiler
doesn't know *how* to destruct it. A forward declaration doesn't tell
the compiler anything about Object's constructor or destructor. So, the
compiler will issue an error in this case because it's undefined
behavior to try and deallocate (or construct) an incomplete type and
std::shared_ptr and std::unique_ptr make sure this isn't the case
internally.
Now, if we had defaulted the destructor in "thing.cpp", where we also
include "object.h", this would never be an issue, as the destructor
would only have its code generated in one place, and it would be in a
place where the full class definition of Object would be visible to the
compiler.
---------------------- End example ----------------------------
Given these service classes are more than certainly going to change in
the future, this defaults the constructors and destructors into the
relevant cpp files to make the construction and destruction of all of
the services consistent and unlikely to run into cases where forward
declarations are indirectly causing compilation errors. It also has the
plus of avoiding the need to rebuild several services if destruction
logic changes, since it would only be necessary to recompile the single
cpp file.
2018-09-11 01:20:52 +00:00
|
|
|
IAudioController::~IAudioController() = default;
|
|
|
|
|
2018-02-22 14:28:15 +00:00
|
|
|
void IAudioController::SetExpectedMasterVolume(Kernel::HLERequestContext& ctx) {
|
2019-03-18 00:47:03 +00:00
|
|
|
IPC::RequestParser rp{ctx};
|
|
|
|
const float main_applet_volume_tmp = rp.Pop<float>();
|
|
|
|
const float library_applet_volume_tmp = rp.Pop<float>();
|
|
|
|
|
|
|
|
LOG_DEBUG(Service_AM, "called. main_applet_volume={}, library_applet_volume={}",
|
|
|
|
main_applet_volume_tmp, library_applet_volume_tmp);
|
|
|
|
|
|
|
|
// Ensure the volume values remain within the 0-100% range
|
|
|
|
main_applet_volume = std::clamp(main_applet_volume_tmp, min_allowed_volume, max_allowed_volume);
|
|
|
|
library_applet_volume =
|
|
|
|
std::clamp(library_applet_volume_tmp, min_allowed_volume, max_allowed_volume);
|
|
|
|
|
2018-02-22 14:28:15 +00:00
|
|
|
IPC::ResponseBuilder rb{ctx, 2};
|
|
|
|
rb.Push(RESULT_SUCCESS);
|
|
|
|
}
|
|
|
|
|
|
|
|
void IAudioController::GetMainAppletExpectedMasterVolume(Kernel::HLERequestContext& ctx) {
|
2019-03-18 00:47:03 +00:00
|
|
|
LOG_DEBUG(Service_AM, "called. main_applet_volume={}", main_applet_volume);
|
2018-02-22 14:28:15 +00:00
|
|
|
IPC::ResponseBuilder rb{ctx, 3};
|
|
|
|
rb.Push(RESULT_SUCCESS);
|
2019-03-18 00:47:03 +00:00
|
|
|
rb.Push(main_applet_volume);
|
2018-02-22 14:28:15 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void IAudioController::GetLibraryAppletExpectedMasterVolume(Kernel::HLERequestContext& ctx) {
|
2019-03-18 00:47:03 +00:00
|
|
|
LOG_DEBUG(Service_AM, "called. library_applet_volume={}", library_applet_volume);
|
2018-02-22 14:28:15 +00:00
|
|
|
IPC::ResponseBuilder rb{ctx, 3};
|
|
|
|
rb.Push(RESULT_SUCCESS);
|
2019-03-18 00:47:03 +00:00
|
|
|
rb.Push(library_applet_volume);
|
2018-02-22 14:28:15 +00:00
|
|
|
}
|
2018-02-02 21:03:40 +00:00
|
|
|
|
2019-03-18 02:39:29 +00:00
|
|
|
void IAudioController::ChangeMainAppletMasterVolume(Kernel::HLERequestContext& ctx) {
|
|
|
|
struct Parameters {
|
|
|
|
float volume;
|
|
|
|
s64 fade_time_ns;
|
|
|
|
};
|
|
|
|
static_assert(sizeof(Parameters) == 16);
|
|
|
|
|
|
|
|
IPC::RequestParser rp{ctx};
|
|
|
|
const auto parameters = rp.PopRaw<Parameters>();
|
|
|
|
|
|
|
|
LOG_DEBUG(Service_AM, "called. volume={}, fade_time_ns={}", parameters.volume,
|
|
|
|
parameters.fade_time_ns);
|
|
|
|
|
|
|
|
main_applet_volume = std::clamp(parameters.volume, min_allowed_volume, max_allowed_volume);
|
|
|
|
fade_time_ns = std::chrono::nanoseconds{parameters.fade_time_ns};
|
|
|
|
|
|
|
|
IPC::ResponseBuilder rb{ctx, 2};
|
|
|
|
rb.Push(RESULT_SUCCESS);
|
|
|
|
}
|
|
|
|
|
2019-03-18 01:09:25 +00:00
|
|
|
void IAudioController::SetTransparentAudioRate(Kernel::HLERequestContext& ctx) {
|
|
|
|
IPC::RequestParser rp{ctx};
|
|
|
|
const float transparent_volume_rate_tmp = rp.Pop<float>();
|
|
|
|
|
|
|
|
LOG_DEBUG(Service_AM, "called. transparent_volume_rate={}", transparent_volume_rate_tmp);
|
|
|
|
|
|
|
|
// Clamp volume range to 0-100%.
|
|
|
|
transparent_volume_rate =
|
|
|
|
std::clamp(transparent_volume_rate_tmp, min_allowed_volume, max_allowed_volume);
|
|
|
|
|
|
|
|
IPC::ResponseBuilder rb{ctx, 2};
|
|
|
|
rb.Push(RESULT_SUCCESS);
|
|
|
|
}
|
|
|
|
|
2018-05-26 02:31:54 +00:00
|
|
|
IDisplayController::IDisplayController() : ServiceFramework("IDisplayController") {
|
2018-10-21 20:40:17 +00:00
|
|
|
// clang-format off
|
2018-05-26 02:31:54 +00:00
|
|
|
static const FunctionInfo functions[] = {
|
|
|
|
{0, nullptr, "GetLastForegroundCaptureImage"},
|
|
|
|
{1, nullptr, "UpdateLastForegroundCaptureImage"},
|
|
|
|
{2, nullptr, "GetLastApplicationCaptureImage"},
|
|
|
|
{3, nullptr, "GetCallerAppletCaptureImage"},
|
|
|
|
{4, nullptr, "UpdateCallerAppletCaptureImage"},
|
|
|
|
{5, nullptr, "GetLastForegroundCaptureImageEx"},
|
|
|
|
{6, nullptr, "GetLastApplicationCaptureImageEx"},
|
|
|
|
{7, nullptr, "GetCallerAppletCaptureImageEx"},
|
|
|
|
{8, nullptr, "TakeScreenShotOfOwnLayer"}, // 2.0.0+
|
|
|
|
{9, nullptr, "CopyBetweenCaptureBuffers"}, // 5.0.0+
|
|
|
|
{10, nullptr, "AcquireLastApplicationCaptureBuffer"},
|
|
|
|
{11, nullptr, "ReleaseLastApplicationCaptureBuffer"},
|
|
|
|
{12, nullptr, "AcquireLastForegroundCaptureBuffer"},
|
|
|
|
{13, nullptr, "ReleaseLastForegroundCaptureBuffer"},
|
|
|
|
{14, nullptr, "AcquireCallerAppletCaptureBuffer"},
|
|
|
|
{15, nullptr, "ReleaseCallerAppletCaptureBuffer"},
|
|
|
|
{16, nullptr, "AcquireLastApplicationCaptureBufferEx"},
|
|
|
|
{17, nullptr, "AcquireLastForegroundCaptureBufferEx"},
|
|
|
|
{18, nullptr, "AcquireCallerAppletCaptureBufferEx"},
|
|
|
|
// 2.0.0+
|
|
|
|
{20, nullptr, "ClearCaptureBuffer"},
|
|
|
|
{21, nullptr, "ClearAppletTransitionBuffer"},
|
|
|
|
// 4.0.0+
|
|
|
|
{22, nullptr, "AcquireLastApplicationCaptureSharedBuffer"},
|
|
|
|
{23, nullptr, "ReleaseLastApplicationCaptureSharedBuffer"},
|
|
|
|
{24, nullptr, "AcquireLastForegroundCaptureSharedBuffer"},
|
|
|
|
{25, nullptr, "ReleaseLastForegroundCaptureSharedBuffer"},
|
|
|
|
{26, nullptr, "AcquireCallerAppletCaptureSharedBuffer"},
|
|
|
|
{27, nullptr, "ReleaseCallerAppletCaptureSharedBuffer"},
|
2018-10-21 20:40:17 +00:00
|
|
|
// 6.0.0+
|
|
|
|
{28, nullptr, "TakeScreenShotOfOwnLayerEx"},
|
2018-05-26 02:31:54 +00:00
|
|
|
};
|
2018-10-21 20:40:17 +00:00
|
|
|
// clang-format on
|
|
|
|
|
2018-05-26 02:31:54 +00:00
|
|
|
RegisterHandlers(functions);
|
|
|
|
}
|
2018-02-02 21:03:40 +00:00
|
|
|
|
hle/service: Default constructors and destructors in the cpp file where applicable
When a destructor isn't defaulted into a cpp file, it can cause the use
of forward declarations to seemingly fail to compile for non-obvious
reasons. It also allows inlining of the construction/destruction logic
all over the place where a constructor or destructor is invoked, which
can lead to code bloat. This isn't so much a worry here, given the
services won't be created and destroyed frequently.
The cause of the above mentioned non-obvious errors can be demonstrated
as follows:
------- Demonstrative example, if you know how the described error happens, skip forwards -------
Assume we have the following in the header, which we'll call "thing.h":
\#include <memory>
// Forward declaration. For example purposes, assume the definition
// of Object is in some header named "object.h"
class Object;
class Thing {
public:
// assume no constructors or destructors are specified here,
// or the constructors/destructors are defined as:
//
// Thing() = default;
// ~Thing() = default;
//
// ... Some interface member functions would be defined here
private:
std::shared_ptr<Object> obj;
};
If this header is included in a cpp file, (which we'll call "main.cpp"),
this will result in a compilation error, because even though no
destructor is specified, the destructor will still need to be generated by
the compiler because std::shared_ptr's destructor is *not* trivial (in
other words, it does something other than nothing), as std::shared_ptr's
destructor needs to do two things:
1. Decrement the shared reference count of the object being pointed to,
and if the reference count decrements to zero,
2. Free the Object instance's memory (aka deallocate the memory it's
pointing to).
And so the compiler generates the code for the destructor doing this inside main.cpp.
Now, keep in mind, the Object forward declaration is not a complete type. All it
does is tell the compiler "a type named Object exists" and allows us to
use the name in certain situations to avoid a header dependency. So the
compiler needs to generate destruction code for Object, but the compiler
doesn't know *how* to destruct it. A forward declaration doesn't tell
the compiler anything about Object's constructor or destructor. So, the
compiler will issue an error in this case because it's undefined
behavior to try and deallocate (or construct) an incomplete type and
std::shared_ptr and std::unique_ptr make sure this isn't the case
internally.
Now, if we had defaulted the destructor in "thing.cpp", where we also
include "object.h", this would never be an issue, as the destructor
would only have its code generated in one place, and it would be in a
place where the full class definition of Object would be visible to the
compiler.
---------------------- End example ----------------------------
Given these service classes are more than certainly going to change in
the future, this defaults the constructors and destructors into the
relevant cpp files to make the construction and destruction of all of
the services consistent and unlikely to run into cases where forward
declarations are indirectly causing compilation errors. It also has the
plus of avoiding the need to rebuild several services if destruction
logic changes, since it would only be necessary to recompile the single
cpp file.
2018-09-11 01:20:52 +00:00
|
|
|
IDisplayController::~IDisplayController() = default;
|
|
|
|
|
2019-03-21 19:47:59 +00:00
|
|
|
IDebugFunctions::IDebugFunctions() : ServiceFramework{"IDebugFunctions"} {
|
|
|
|
// clang-format off
|
|
|
|
static const FunctionInfo functions[] = {
|
|
|
|
{0, nullptr, "NotifyMessageToHomeMenuForDebug"},
|
|
|
|
{1, nullptr, "OpenMainApplication"},
|
|
|
|
{10, nullptr, "EmulateButtonEvent"},
|
|
|
|
{20, nullptr, "InvalidateTransitionLayer"},
|
|
|
|
{30, nullptr, "RequestLaunchApplicationWithUserAndArgumentForDebug"},
|
|
|
|
{40, nullptr, "GetAppletResourceUsageInfo"},
|
2019-04-10 18:48:37 +00:00
|
|
|
{41, nullptr, "SetCpuBoostModeForApplet"},
|
2019-03-21 19:47:59 +00:00
|
|
|
};
|
|
|
|
// clang-format on
|
|
|
|
|
|
|
|
RegisterHandlers(functions);
|
|
|
|
}
|
|
|
|
|
hle/service: Default constructors and destructors in the cpp file where applicable
When a destructor isn't defaulted into a cpp file, it can cause the use
of forward declarations to seemingly fail to compile for non-obvious
reasons. It also allows inlining of the construction/destruction logic
all over the place where a constructor or destructor is invoked, which
can lead to code bloat. This isn't so much a worry here, given the
services won't be created and destroyed frequently.
The cause of the above mentioned non-obvious errors can be demonstrated
as follows:
------- Demonstrative example, if you know how the described error happens, skip forwards -------
Assume we have the following in the header, which we'll call "thing.h":
\#include <memory>
// Forward declaration. For example purposes, assume the definition
// of Object is in some header named "object.h"
class Object;
class Thing {
public:
// assume no constructors or destructors are specified here,
// or the constructors/destructors are defined as:
//
// Thing() = default;
// ~Thing() = default;
//
// ... Some interface member functions would be defined here
private:
std::shared_ptr<Object> obj;
};
If this header is included in a cpp file, (which we'll call "main.cpp"),
this will result in a compilation error, because even though no
destructor is specified, the destructor will still need to be generated by
the compiler because std::shared_ptr's destructor is *not* trivial (in
other words, it does something other than nothing), as std::shared_ptr's
destructor needs to do two things:
1. Decrement the shared reference count of the object being pointed to,
and if the reference count decrements to zero,
2. Free the Object instance's memory (aka deallocate the memory it's
pointing to).
And so the compiler generates the code for the destructor doing this inside main.cpp.
Now, keep in mind, the Object forward declaration is not a complete type. All it
does is tell the compiler "a type named Object exists" and allows us to
use the name in certain situations to avoid a header dependency. So the
compiler needs to generate destruction code for Object, but the compiler
doesn't know *how* to destruct it. A forward declaration doesn't tell
the compiler anything about Object's constructor or destructor. So, the
compiler will issue an error in this case because it's undefined
behavior to try and deallocate (or construct) an incomplete type and
std::shared_ptr and std::unique_ptr make sure this isn't the case
internally.
Now, if we had defaulted the destructor in "thing.cpp", where we also
include "object.h", this would never be an issue, as the destructor
would only have its code generated in one place, and it would be in a
place where the full class definition of Object would be visible to the
compiler.
---------------------- End example ----------------------------
Given these service classes are more than certainly going to change in
the future, this defaults the constructors and destructors into the
relevant cpp files to make the construction and destruction of all of
the services consistent and unlikely to run into cases where forward
declarations are indirectly causing compilation errors. It also has the
plus of avoiding the need to rebuild several services if destruction
logic changes, since it would only be necessary to recompile the single
cpp file.
2018-09-11 01:20:52 +00:00
|
|
|
IDebugFunctions::~IDebugFunctions() = default;
|
2018-02-02 21:03:40 +00:00
|
|
|
|
|
|
|
ISelfController::ISelfController(std::shared_ptr<NVFlinger::NVFlinger> nvflinger)
|
|
|
|
: ServiceFramework("ISelfController"), nvflinger(std::move(nvflinger)) {
|
2018-10-21 20:40:17 +00:00
|
|
|
// clang-format off
|
2018-02-02 21:03:40 +00:00
|
|
|
static const FunctionInfo functions[] = {
|
2018-04-10 15:36:00 +00:00
|
|
|
{0, nullptr, "Exit"},
|
2018-02-02 21:03:40 +00:00
|
|
|
{1, &ISelfController::LockExit, "LockExit"},
|
|
|
|
{2, &ISelfController::UnlockExit, "UnlockExit"},
|
2019-03-26 19:12:09 +00:00
|
|
|
{3, &ISelfController::EnterFatalSection, "EnterFatalSection"},
|
|
|
|
{4, &ISelfController::LeaveFatalSection, "LeaveFatalSection"},
|
2018-02-07 12:11:17 +00:00
|
|
|
{9, &ISelfController::GetLibraryAppletLaunchableEvent, "GetLibraryAppletLaunchableEvent"},
|
2018-02-22 10:04:23 +00:00
|
|
|
{10, &ISelfController::SetScreenShotPermission, "SetScreenShotPermission"},
|
2018-10-21 20:40:17 +00:00
|
|
|
{11, &ISelfController::SetOperationModeChangedNotification, "SetOperationModeChangedNotification"},
|
|
|
|
{12, &ISelfController::SetPerformanceModeChangedNotification, "SetPerformanceModeChangedNotification"},
|
2018-02-02 21:03:40 +00:00
|
|
|
{13, &ISelfController::SetFocusHandlingMode, "SetFocusHandlingMode"},
|
|
|
|
{14, &ISelfController::SetRestartMessageEnabled, "SetRestartMessageEnabled"},
|
2018-04-10 15:36:00 +00:00
|
|
|
{15, nullptr, "SetScreenShotAppletIdentityInfo"},
|
2018-02-02 21:03:40 +00:00
|
|
|
{16, &ISelfController::SetOutOfFocusSuspendingEnabled, "SetOutOfFocusSuspendingEnabled"},
|
2018-04-10 15:36:00 +00:00
|
|
|
{17, nullptr, "SetControllerFirmwareUpdateSection"},
|
|
|
|
{18, nullptr, "SetRequiresCaptureButtonShortPressedMessage"},
|
2018-08-08 04:40:46 +00:00
|
|
|
{19, &ISelfController::SetScreenShotImageOrientation, "SetScreenShotImageOrientation"},
|
2018-04-10 15:36:00 +00:00
|
|
|
{20, nullptr, "SetDesirableKeyboardLayout"},
|
2018-02-02 21:03:40 +00:00
|
|
|
{40, &ISelfController::CreateManagedDisplayLayer, "CreateManagedDisplayLayer"},
|
2018-04-10 15:36:00 +00:00
|
|
|
{41, nullptr, "IsSystemBufferSharingEnabled"},
|
|
|
|
{42, nullptr, "GetSystemSharedLayerHandle"},
|
2019-04-10 18:48:37 +00:00
|
|
|
{43, nullptr, "GetSystemSharedBufferHandle"},
|
2018-05-07 15:27:30 +00:00
|
|
|
{50, &ISelfController::SetHandlesRequestToDisplay, "SetHandlesRequestToDisplay"},
|
2018-04-10 15:36:00 +00:00
|
|
|
{51, nullptr, "ApproveToDisplay"},
|
|
|
|
{60, nullptr, "OverrideAutoSleepTimeAndDimmingTime"},
|
|
|
|
{61, nullptr, "SetMediaPlaybackState"},
|
2018-08-17 04:23:08 +00:00
|
|
|
{62, &ISelfController::SetIdleTimeDetectionExtension, "SetIdleTimeDetectionExtension"},
|
|
|
|
{63, &ISelfController::GetIdleTimeDetectionExtension, "GetIdleTimeDetectionExtension"},
|
2018-04-11 11:48:56 +00:00
|
|
|
{64, nullptr, "SetInputDetectionSourceSet"},
|
2018-04-10 15:36:00 +00:00
|
|
|
{65, nullptr, "ReportUserIsActive"},
|
|
|
|
{66, nullptr, "GetCurrentIlluminance"},
|
|
|
|
{67, nullptr, "IsIlluminanceAvailable"},
|
2019-07-11 17:02:29 +00:00
|
|
|
{68, &ISelfController::SetAutoSleepDisabled, "SetAutoSleepDisabled"},
|
2019-07-11 17:32:20 +00:00
|
|
|
{69, &ISelfController::IsAutoSleepDisabled, "IsAutoSleepDisabled"},
|
2018-04-10 15:36:00 +00:00
|
|
|
{70, nullptr, "ReportMultimediaError"},
|
2019-04-10 18:48:37 +00:00
|
|
|
{71, nullptr, "GetCurrentIlluminanceEx"},
|
2018-04-10 15:36:00 +00:00
|
|
|
{80, nullptr, "SetWirelessPriorityMode"},
|
2019-07-06 19:13:34 +00:00
|
|
|
{90, &ISelfController::GetAccumulatedSuspendedTickValue, "GetAccumulatedSuspendedTickValue"},
|
2019-06-16 09:06:33 +00:00
|
|
|
{91, &ISelfController::GetAccumulatedSuspendedTickChangedEvent, "GetAccumulatedSuspendedTickChangedEvent"},
|
2019-04-10 18:48:37 +00:00
|
|
|
{100, nullptr, "SetAlbumImageTakenNotificationEnabled"},
|
2018-10-21 20:40:17 +00:00
|
|
|
{1000, nullptr, "GetDebugStorageChannel"},
|
2018-02-02 21:03:40 +00:00
|
|
|
};
|
2018-10-21 20:40:17 +00:00
|
|
|
// clang-format on
|
|
|
|
|
2018-02-02 21:03:40 +00:00
|
|
|
RegisterHandlers(functions);
|
2018-02-07 12:11:17 +00:00
|
|
|
|
2018-08-28 16:30:33 +00:00
|
|
|
auto& kernel = Core::System::GetInstance().Kernel();
|
2019-05-18 19:39:03 +00:00
|
|
|
launchable_event = Kernel::WritableEvent::CreateEventPair(kernel, Kernel::ResetType::Manual,
|
2018-11-27 14:18:29 +00:00
|
|
|
"ISelfController:LaunchableEvent");
|
2019-06-16 09:06:33 +00:00
|
|
|
|
2019-07-06 20:52:05 +00:00
|
|
|
// This event is created by AM on the first time GetAccumulatedSuspendedTickChangedEvent() is
|
|
|
|
// called. Yuzu can just create it unconditionally, since it doesn't need to support multiple
|
|
|
|
// ISelfControllers. The event is signaled on creation, and on transition from suspended -> not
|
|
|
|
// suspended if the event has previously been created by a call to
|
|
|
|
// GetAccumulatedSuspendedTickChangedEvent.
|
2019-06-16 09:06:33 +00:00
|
|
|
accumulated_suspended_tick_changed_event = Kernel::WritableEvent::CreateEventPair(
|
|
|
|
kernel, Kernel::ResetType::Manual, "ISelfController:AccumulatedSuspendedTickChangedEvent");
|
2019-07-06 19:13:34 +00:00
|
|
|
accumulated_suspended_tick_changed_event.writable->Signal();
|
2018-02-02 21:03:40 +00:00
|
|
|
}
|
|
|
|
|
hle/service: Default constructors and destructors in the cpp file where applicable
When a destructor isn't defaulted into a cpp file, it can cause the use
of forward declarations to seemingly fail to compile for non-obvious
reasons. It also allows inlining of the construction/destruction logic
all over the place where a constructor or destructor is invoked, which
can lead to code bloat. This isn't so much a worry here, given the
services won't be created and destroyed frequently.
The cause of the above mentioned non-obvious errors can be demonstrated
as follows:
------- Demonstrative example, if you know how the described error happens, skip forwards -------
Assume we have the following in the header, which we'll call "thing.h":
\#include <memory>
// Forward declaration. For example purposes, assume the definition
// of Object is in some header named "object.h"
class Object;
class Thing {
public:
// assume no constructors or destructors are specified here,
// or the constructors/destructors are defined as:
//
// Thing() = default;
// ~Thing() = default;
//
// ... Some interface member functions would be defined here
private:
std::shared_ptr<Object> obj;
};
If this header is included in a cpp file, (which we'll call "main.cpp"),
this will result in a compilation error, because even though no
destructor is specified, the destructor will still need to be generated by
the compiler because std::shared_ptr's destructor is *not* trivial (in
other words, it does something other than nothing), as std::shared_ptr's
destructor needs to do two things:
1. Decrement the shared reference count of the object being pointed to,
and if the reference count decrements to zero,
2. Free the Object instance's memory (aka deallocate the memory it's
pointing to).
And so the compiler generates the code for the destructor doing this inside main.cpp.
Now, keep in mind, the Object forward declaration is not a complete type. All it
does is tell the compiler "a type named Object exists" and allows us to
use the name in certain situations to avoid a header dependency. So the
compiler needs to generate destruction code for Object, but the compiler
doesn't know *how* to destruct it. A forward declaration doesn't tell
the compiler anything about Object's constructor or destructor. So, the
compiler will issue an error in this case because it's undefined
behavior to try and deallocate (or construct) an incomplete type and
std::shared_ptr and std::unique_ptr make sure this isn't the case
internally.
Now, if we had defaulted the destructor in "thing.cpp", where we also
include "object.h", this would never be an issue, as the destructor
would only have its code generated in one place, and it would be in a
place where the full class definition of Object would be visible to the
compiler.
---------------------- End example ----------------------------
Given these service classes are more than certainly going to change in
the future, this defaults the constructors and destructors into the
relevant cpp files to make the construction and destruction of all of
the services consistent and unlikely to run into cases where forward
declarations are indirectly causing compilation errors. It also has the
plus of avoiding the need to rebuild several services if destruction
logic changes, since it would only be necessary to recompile the single
cpp file.
2018-09-11 01:20:52 +00:00
|
|
|
ISelfController::~ISelfController() = default;
|
|
|
|
|
2019-03-26 18:54:03 +00:00
|
|
|
void ISelfController::LockExit(Kernel::HLERequestContext& ctx) {
|
2018-11-26 06:06:13 +00:00
|
|
|
LOG_WARNING(Service_AM, "(STUBBED) called");
|
2018-02-02 21:03:40 +00:00
|
|
|
|
|
|
|
IPC::ResponseBuilder rb{ctx, 2};
|
|
|
|
rb.Push(RESULT_SUCCESS);
|
|
|
|
}
|
|
|
|
|
2019-03-26 18:54:03 +00:00
|
|
|
void ISelfController::UnlockExit(Kernel::HLERequestContext& ctx) {
|
2018-11-26 06:06:13 +00:00
|
|
|
LOG_WARNING(Service_AM, "(STUBBED) called");
|
|
|
|
|
2018-02-02 21:03:40 +00:00
|
|
|
IPC::ResponseBuilder rb{ctx, 2};
|
|
|
|
rb.Push(RESULT_SUCCESS);
|
|
|
|
}
|
|
|
|
|
2019-03-26 19:12:09 +00:00
|
|
|
void ISelfController::EnterFatalSection(Kernel::HLERequestContext& ctx) {
|
|
|
|
++num_fatal_sections_entered;
|
|
|
|
LOG_DEBUG(Service_AM, "called. Num fatal sections entered: {}", num_fatal_sections_entered);
|
|
|
|
|
|
|
|
IPC::ResponseBuilder rb{ctx, 2};
|
|
|
|
rb.Push(RESULT_SUCCESS);
|
|
|
|
}
|
|
|
|
|
|
|
|
void ISelfController::LeaveFatalSection(Kernel::HLERequestContext& ctx) {
|
|
|
|
LOG_DEBUG(Service_AM, "called.");
|
|
|
|
|
|
|
|
// Entry and exit of fatal sections must be balanced.
|
|
|
|
if (num_fatal_sections_entered == 0) {
|
|
|
|
IPC::ResponseBuilder rb{ctx, 2};
|
|
|
|
rb.Push(ResultCode{ErrorModule::AM, 512});
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
--num_fatal_sections_entered;
|
|
|
|
|
|
|
|
IPC::ResponseBuilder rb{ctx, 2};
|
|
|
|
rb.Push(RESULT_SUCCESS);
|
|
|
|
}
|
|
|
|
|
2019-03-26 18:54:03 +00:00
|
|
|
void ISelfController::GetLibraryAppletLaunchableEvent(Kernel::HLERequestContext& ctx) {
|
|
|
|
LOG_WARNING(Service_AM, "(STUBBED) called");
|
2018-02-02 21:03:40 +00:00
|
|
|
|
2019-03-26 18:54:03 +00:00
|
|
|
launchable_event.writable->Signal();
|
2018-02-02 21:03:40 +00:00
|
|
|
|
2019-03-26 18:54:03 +00:00
|
|
|
IPC::ResponseBuilder rb{ctx, 2, 1};
|
2018-02-02 21:03:40 +00:00
|
|
|
rb.Push(RESULT_SUCCESS);
|
2019-03-26 18:54:03 +00:00
|
|
|
rb.PushCopyObjects(launchable_event.readable);
|
2018-02-02 21:03:40 +00:00
|
|
|
}
|
|
|
|
|
2018-02-22 10:04:23 +00:00
|
|
|
void ISelfController::SetScreenShotPermission(Kernel::HLERequestContext& ctx) {
|
2018-11-26 06:06:13 +00:00
|
|
|
LOG_WARNING(Service_AM, "(STUBBED) called");
|
|
|
|
|
2018-02-22 10:04:23 +00:00
|
|
|
IPC::ResponseBuilder rb{ctx, 2};
|
|
|
|
rb.Push(RESULT_SUCCESS);
|
|
|
|
}
|
|
|
|
|
2018-02-02 21:03:40 +00:00
|
|
|
void ISelfController::SetOperationModeChangedNotification(Kernel::HLERequestContext& ctx) {
|
|
|
|
IPC::RequestParser rp{ctx};
|
|
|
|
|
|
|
|
bool flag = rp.Pop<bool>();
|
2018-11-26 06:06:13 +00:00
|
|
|
LOG_WARNING(Service_AM, "(STUBBED) called flag={}", flag);
|
2018-02-02 21:03:40 +00:00
|
|
|
|
|
|
|
IPC::ResponseBuilder rb{ctx, 2};
|
|
|
|
rb.Push(RESULT_SUCCESS);
|
|
|
|
}
|
|
|
|
|
2019-03-26 18:54:03 +00:00
|
|
|
void ISelfController::SetPerformanceModeChangedNotification(Kernel::HLERequestContext& ctx) {
|
2018-02-02 21:03:40 +00:00
|
|
|
IPC::RequestParser rp{ctx};
|
|
|
|
|
2019-03-26 18:54:03 +00:00
|
|
|
bool flag = rp.Pop<bool>();
|
|
|
|
LOG_WARNING(Service_AM, "(STUBBED) called flag={}", flag);
|
2018-02-02 21:03:40 +00:00
|
|
|
|
|
|
|
IPC::ResponseBuilder rb{ctx, 2};
|
|
|
|
rb.Push(RESULT_SUCCESS);
|
|
|
|
}
|
|
|
|
|
2019-03-26 18:54:03 +00:00
|
|
|
void ISelfController::SetFocusHandlingMode(Kernel::HLERequestContext& ctx) {
|
|
|
|
// Takes 3 input u8s with each field located immediately after the previous
|
|
|
|
// u8, these are bool flags. No output.
|
|
|
|
IPC::RequestParser rp{ctx};
|
|
|
|
|
|
|
|
struct FocusHandlingModeParams {
|
|
|
|
u8 unknown0;
|
|
|
|
u8 unknown1;
|
|
|
|
u8 unknown2;
|
|
|
|
};
|
2019-04-04 16:56:04 +00:00
|
|
|
const auto flags = rp.PopRaw<FocusHandlingModeParams>();
|
|
|
|
|
|
|
|
LOG_WARNING(Service_AM, "(STUBBED) called. unknown0={}, unknown1={}, unknown2={}",
|
|
|
|
flags.unknown0, flags.unknown1, flags.unknown2);
|
2019-03-26 18:54:03 +00:00
|
|
|
|
2018-02-02 21:03:40 +00:00
|
|
|
IPC::ResponseBuilder rb{ctx, 2};
|
|
|
|
rb.Push(RESULT_SUCCESS);
|
|
|
|
}
|
|
|
|
|
2019-03-26 18:54:03 +00:00
|
|
|
void ISelfController::SetRestartMessageEnabled(Kernel::HLERequestContext& ctx) {
|
2018-11-26 06:06:13 +00:00
|
|
|
LOG_WARNING(Service_AM, "(STUBBED) called");
|
|
|
|
|
2018-02-02 21:03:40 +00:00
|
|
|
IPC::ResponseBuilder rb{ctx, 2};
|
|
|
|
rb.Push(RESULT_SUCCESS);
|
|
|
|
}
|
|
|
|
|
2019-03-26 18:54:03 +00:00
|
|
|
void ISelfController::SetOutOfFocusSuspendingEnabled(Kernel::HLERequestContext& ctx) {
|
|
|
|
// Takes 3 input u8s with each field located immediately after the previous
|
|
|
|
// u8, these are bool flags. No output.
|
|
|
|
IPC::RequestParser rp{ctx};
|
2018-11-26 06:06:13 +00:00
|
|
|
|
2019-03-26 18:54:03 +00:00
|
|
|
bool enabled = rp.Pop<bool>();
|
|
|
|
LOG_WARNING(Service_AM, "(STUBBED) called enabled={}", enabled);
|
2018-02-07 12:11:17 +00:00
|
|
|
|
2019-03-26 18:54:03 +00:00
|
|
|
IPC::ResponseBuilder rb{ctx, 2};
|
2018-02-07 12:11:17 +00:00
|
|
|
rb.Push(RESULT_SUCCESS);
|
2018-11-29 14:14:12 +00:00
|
|
|
}
|
2018-02-07 12:11:17 +00:00
|
|
|
|
2018-08-08 04:40:46 +00:00
|
|
|
void ISelfController::SetScreenShotImageOrientation(Kernel::HLERequestContext& ctx) {
|
2018-11-26 06:06:13 +00:00
|
|
|
LOG_WARNING(Service_AM, "(STUBBED) called");
|
|
|
|
|
2018-08-08 04:40:46 +00:00
|
|
|
IPC::ResponseBuilder rb{ctx, 2};
|
|
|
|
rb.Push(RESULT_SUCCESS);
|
|
|
|
}
|
|
|
|
|
2018-02-02 21:03:40 +00:00
|
|
|
void ISelfController::CreateManagedDisplayLayer(Kernel::HLERequestContext& ctx) {
|
2018-11-26 06:06:13 +00:00
|
|
|
LOG_WARNING(Service_AM, "(STUBBED) called");
|
2019-02-05 21:20:04 +00:00
|
|
|
|
2018-11-17 14:05:55 +00:00
|
|
|
// TODO(Subv): Find out how AM determines the display to use, for now just
|
|
|
|
// create the layer in the Default display.
|
2019-02-05 21:20:04 +00:00
|
|
|
const auto display_id = nvflinger->OpenDisplay("Default");
|
|
|
|
const auto layer_id = nvflinger->CreateLayer(*display_id);
|
2018-02-02 21:03:40 +00:00
|
|
|
|
|
|
|
IPC::ResponseBuilder rb{ctx, 4};
|
|
|
|
rb.Push(RESULT_SUCCESS);
|
2019-02-05 21:20:04 +00:00
|
|
|
rb.Push(*layer_id);
|
2018-02-02 21:03:40 +00:00
|
|
|
}
|
|
|
|
|
2018-05-07 15:27:30 +00:00
|
|
|
void ISelfController::SetHandlesRequestToDisplay(Kernel::HLERequestContext& ctx) {
|
2018-11-26 06:06:13 +00:00
|
|
|
LOG_WARNING(Service_AM, "(STUBBED) called");
|
|
|
|
|
2018-05-07 15:27:30 +00:00
|
|
|
IPC::ResponseBuilder rb{ctx, 2};
|
|
|
|
rb.Push(RESULT_SUCCESS);
|
|
|
|
}
|
|
|
|
|
2018-08-17 04:23:08 +00:00
|
|
|
void ISelfController::SetIdleTimeDetectionExtension(Kernel::HLERequestContext& ctx) {
|
|
|
|
IPC::RequestParser rp{ctx};
|
|
|
|
idle_time_detection_extension = rp.Pop<u32>();
|
2018-11-26 06:06:13 +00:00
|
|
|
LOG_WARNING(Service_AM, "(STUBBED) called idle_time_detection_extension={}",
|
|
|
|
idle_time_detection_extension);
|
|
|
|
|
2018-08-17 04:23:08 +00:00
|
|
|
IPC::ResponseBuilder rb{ctx, 2};
|
|
|
|
rb.Push(RESULT_SUCCESS);
|
|
|
|
}
|
|
|
|
|
|
|
|
void ISelfController::GetIdleTimeDetectionExtension(Kernel::HLERequestContext& ctx) {
|
2018-11-26 06:06:13 +00:00
|
|
|
LOG_WARNING(Service_AM, "(STUBBED) called");
|
|
|
|
|
2018-08-17 04:23:08 +00:00
|
|
|
IPC::ResponseBuilder rb{ctx, 3};
|
|
|
|
rb.Push(RESULT_SUCCESS);
|
|
|
|
rb.Push<u32>(idle_time_detection_extension);
|
|
|
|
}
|
|
|
|
|
2019-07-11 17:02:29 +00:00
|
|
|
void ISelfController::SetAutoSleepDisabled(Kernel::HLERequestContext& ctx) {
|
|
|
|
IPC::RequestParser rp{ctx};
|
|
|
|
is_auto_sleep_disabled = rp.Pop<bool>();
|
|
|
|
|
|
|
|
// On the system itself, if the previous state of is_auto_sleep_disabled
|
|
|
|
// differed from the current value passed in, it'd signify the internal
|
|
|
|
// window manager to update (and also increment some statistics like update counts)
|
|
|
|
//
|
|
|
|
// It'd also indicate this change to an idle handling context.
|
|
|
|
//
|
|
|
|
// However, given we're emulating this behavior, most of this can be ignored
|
|
|
|
// and it's sufficient to simply set the member variable for querying via
|
|
|
|
// IsAutoSleepDisabled().
|
|
|
|
|
|
|
|
LOG_DEBUG(Service_AM, "called. is_auto_sleep_disabled={}", is_auto_sleep_disabled);
|
|
|
|
|
|
|
|
IPC::ResponseBuilder rb{ctx, 2};
|
|
|
|
rb.Push(RESULT_SUCCESS);
|
|
|
|
}
|
|
|
|
|
2019-07-11 17:32:20 +00:00
|
|
|
void ISelfController::IsAutoSleepDisabled(Kernel::HLERequestContext& ctx) {
|
|
|
|
LOG_DEBUG(Service_AM, "called.");
|
|
|
|
|
|
|
|
IPC::ResponseBuilder rb{ctx, 3};
|
|
|
|
rb.Push(RESULT_SUCCESS);
|
|
|
|
rb.Push(is_auto_sleep_disabled);
|
|
|
|
}
|
|
|
|
|
2019-07-06 19:13:34 +00:00
|
|
|
void ISelfController::GetAccumulatedSuspendedTickValue(Kernel::HLERequestContext& ctx) {
|
|
|
|
LOG_DEBUG(Service_AM, "called.");
|
|
|
|
|
|
|
|
// This command returns the total number of system ticks since ISelfController creation
|
|
|
|
// where the game was suspended. Since Yuzu doesn't implement game suspension, this command
|
|
|
|
// can just always return 0 ticks.
|
|
|
|
IPC::ResponseBuilder rb{ctx, 4};
|
|
|
|
rb.Push(RESULT_SUCCESS);
|
|
|
|
rb.Push<u64>(0);
|
|
|
|
}
|
|
|
|
|
2019-06-16 09:06:33 +00:00
|
|
|
void ISelfController::GetAccumulatedSuspendedTickChangedEvent(Kernel::HLERequestContext& ctx) {
|
2019-07-06 19:13:34 +00:00
|
|
|
LOG_DEBUG(Service_AM, "called.");
|
2019-06-16 09:06:33 +00:00
|
|
|
|
|
|
|
IPC::ResponseBuilder rb{ctx, 2, 1};
|
|
|
|
rb.Push(RESULT_SUCCESS);
|
|
|
|
rb.PushCopyObjects(accumulated_suspended_tick_changed_event.readable);
|
|
|
|
}
|
|
|
|
|
2018-11-07 07:01:33 +00:00
|
|
|
AppletMessageQueue::AppletMessageQueue() {
|
|
|
|
auto& kernel = Core::System::GetInstance().Kernel();
|
2019-05-18 19:39:03 +00:00
|
|
|
on_new_message = Kernel::WritableEvent::CreateEventPair(kernel, Kernel::ResetType::Manual,
|
2018-11-27 14:18:29 +00:00
|
|
|
"AMMessageQueue:OnMessageRecieved");
|
|
|
|
on_operation_mode_changed = Kernel::WritableEvent::CreateEventPair(
|
2019-05-18 19:39:03 +00:00
|
|
|
kernel, Kernel::ResetType::Automatic, "AMMessageQueue:OperationModeChanged");
|
2018-11-07 07:01:33 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
AppletMessageQueue::~AppletMessageQueue() = default;
|
|
|
|
|
2018-11-26 23:34:07 +00:00
|
|
|
const Kernel::SharedPtr<Kernel::ReadableEvent>& AppletMessageQueue::GetMesssageRecieveEvent()
|
|
|
|
const {
|
2018-11-27 14:18:29 +00:00
|
|
|
return on_new_message.readable;
|
2018-11-07 07:01:33 +00:00
|
|
|
}
|
|
|
|
|
2018-11-26 23:34:07 +00:00
|
|
|
const Kernel::SharedPtr<Kernel::ReadableEvent>& AppletMessageQueue::GetOperationModeChangedEvent()
|
|
|
|
const {
|
2018-11-27 14:18:29 +00:00
|
|
|
return on_operation_mode_changed.readable;
|
2018-11-07 07:01:33 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void AppletMessageQueue::PushMessage(AppletMessage msg) {
|
|
|
|
messages.push(msg);
|
2018-11-27 14:18:29 +00:00
|
|
|
on_new_message.writable->Signal();
|
2018-11-07 07:01:33 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
AppletMessageQueue::AppletMessage AppletMessageQueue::PopMessage() {
|
|
|
|
if (messages.empty()) {
|
2018-11-27 14:18:29 +00:00
|
|
|
on_new_message.writable->Clear();
|
2018-11-07 07:01:33 +00:00
|
|
|
return AppletMessage::NoMessage;
|
|
|
|
}
|
|
|
|
auto msg = messages.front();
|
|
|
|
messages.pop();
|
|
|
|
if (messages.empty()) {
|
2018-11-27 14:18:29 +00:00
|
|
|
on_new_message.writable->Clear();
|
2018-11-07 07:01:33 +00:00
|
|
|
}
|
|
|
|
return msg;
|
|
|
|
}
|
|
|
|
|
|
|
|
std::size_t AppletMessageQueue::GetMessageCount() const {
|
|
|
|
return messages.size();
|
|
|
|
}
|
|
|
|
|
|
|
|
void AppletMessageQueue::OperationModeChanged() {
|
|
|
|
PushMessage(AppletMessage::OperationModeChanged);
|
|
|
|
PushMessage(AppletMessage::PerformanceModeChanged);
|
2018-11-27 14:18:29 +00:00
|
|
|
on_operation_mode_changed.writable->Signal();
|
2018-11-07 07:01:33 +00:00
|
|
|
}
|
|
|
|
|
2019-06-29 02:46:51 +00:00
|
|
|
ICommonStateGetter::ICommonStateGetter(Core::System& system,
|
|
|
|
std::shared_ptr<AppletMessageQueue> msg_queue)
|
|
|
|
: ServiceFramework("ICommonStateGetter"), system(system), msg_queue(std::move(msg_queue)) {
|
2018-10-21 20:40:17 +00:00
|
|
|
// clang-format off
|
2018-02-02 21:03:40 +00:00
|
|
|
static const FunctionInfo functions[] = {
|
|
|
|
{0, &ICommonStateGetter::GetEventHandle, "GetEventHandle"},
|
|
|
|
{1, &ICommonStateGetter::ReceiveMessage, "ReceiveMessage"},
|
2018-04-10 15:36:00 +00:00
|
|
|
{2, nullptr, "GetThisAppletKind"},
|
|
|
|
{3, nullptr, "AllowToEnterSleep"},
|
|
|
|
{4, nullptr, "DisallowToEnterSleep"},
|
2018-02-02 21:03:40 +00:00
|
|
|
{5, &ICommonStateGetter::GetOperationMode, "GetOperationMode"},
|
|
|
|
{6, &ICommonStateGetter::GetPerformanceMode, "GetPerformanceMode"},
|
2018-04-10 15:36:00 +00:00
|
|
|
{7, nullptr, "GetCradleStatus"},
|
2018-08-23 22:31:45 +00:00
|
|
|
{8, &ICommonStateGetter::GetBootMode, "GetBootMode"},
|
2018-02-02 21:03:40 +00:00
|
|
|
{9, &ICommonStateGetter::GetCurrentFocusState, "GetCurrentFocusState"},
|
2018-04-10 15:36:00 +00:00
|
|
|
{10, nullptr, "RequestToAcquireSleepLock"},
|
|
|
|
{11, nullptr, "ReleaseSleepLock"},
|
|
|
|
{12, nullptr, "ReleaseSleepLockTransiently"},
|
|
|
|
{13, nullptr, "GetAcquiredSleepLockEvent"},
|
|
|
|
{20, nullptr, "PushToGeneralChannel"},
|
|
|
|
{30, nullptr, "GetHomeButtonReaderLockAccessor"},
|
|
|
|
{31, nullptr, "GetReaderLockAccessorEx"},
|
|
|
|
{40, nullptr, "GetCradleFwVersion"},
|
|
|
|
{50, nullptr, "IsVrModeEnabled"},
|
|
|
|
{51, nullptr, "SetVrModeEnabled"},
|
|
|
|
{52, nullptr, "SwitchLcdBacklight"},
|
2019-04-10 18:48:37 +00:00
|
|
|
{53, nullptr, "BeginVrModeEx"},
|
|
|
|
{54, nullptr, "EndVrModeEx"},
|
2018-04-10 15:36:00 +00:00
|
|
|
{55, nullptr, "IsInControllerFirmwareUpdateSection"},
|
2018-09-18 15:10:16 +00:00
|
|
|
{60, &ICommonStateGetter::GetDefaultDisplayResolution, "GetDefaultDisplayResolution"},
|
2018-10-21 20:40:17 +00:00
|
|
|
{61, &ICommonStateGetter::GetDefaultDisplayResolutionChangeEvent, "GetDefaultDisplayResolutionChangeEvent"},
|
2018-04-10 15:36:00 +00:00
|
|
|
{62, nullptr, "GetHdcpAuthenticationState"},
|
|
|
|
{63, nullptr, "GetHdcpAuthenticationStateChangeEvent"},
|
2019-04-10 18:48:37 +00:00
|
|
|
{64, nullptr, "SetTvPowerStateMatchingMode"},
|
|
|
|
{65, nullptr, "GetApplicationIdByContentActionName"},
|
2019-06-29 02:46:51 +00:00
|
|
|
{66, &ICommonStateGetter::SetCpuBoostMode, "SetCpuBoostMode"},
|
2019-04-10 18:48:37 +00:00
|
|
|
{80, nullptr, "PerformSystemButtonPressingIfInFocus"},
|
|
|
|
{90, nullptr, "SetPerformanceConfigurationChangedNotification"},
|
|
|
|
{91, nullptr, "GetCurrentPerformanceConfiguration"},
|
|
|
|
{200, nullptr, "GetOperationModeSystemInfo"},
|
2018-02-02 21:03:40 +00:00
|
|
|
};
|
2018-10-21 20:40:17 +00:00
|
|
|
// clang-format on
|
|
|
|
|
2018-02-02 21:03:40 +00:00
|
|
|
RegisterHandlers(functions);
|
|
|
|
}
|
|
|
|
|
hle/service: Default constructors and destructors in the cpp file where applicable
When a destructor isn't defaulted into a cpp file, it can cause the use
of forward declarations to seemingly fail to compile for non-obvious
reasons. It also allows inlining of the construction/destruction logic
all over the place where a constructor or destructor is invoked, which
can lead to code bloat. This isn't so much a worry here, given the
services won't be created and destroyed frequently.
The cause of the above mentioned non-obvious errors can be demonstrated
as follows:
------- Demonstrative example, if you know how the described error happens, skip forwards -------
Assume we have the following in the header, which we'll call "thing.h":
\#include <memory>
// Forward declaration. For example purposes, assume the definition
// of Object is in some header named "object.h"
class Object;
class Thing {
public:
// assume no constructors or destructors are specified here,
// or the constructors/destructors are defined as:
//
// Thing() = default;
// ~Thing() = default;
//
// ... Some interface member functions would be defined here
private:
std::shared_ptr<Object> obj;
};
If this header is included in a cpp file, (which we'll call "main.cpp"),
this will result in a compilation error, because even though no
destructor is specified, the destructor will still need to be generated by
the compiler because std::shared_ptr's destructor is *not* trivial (in
other words, it does something other than nothing), as std::shared_ptr's
destructor needs to do two things:
1. Decrement the shared reference count of the object being pointed to,
and if the reference count decrements to zero,
2. Free the Object instance's memory (aka deallocate the memory it's
pointing to).
And so the compiler generates the code for the destructor doing this inside main.cpp.
Now, keep in mind, the Object forward declaration is not a complete type. All it
does is tell the compiler "a type named Object exists" and allows us to
use the name in certain situations to avoid a header dependency. So the
compiler needs to generate destruction code for Object, but the compiler
doesn't know *how* to destruct it. A forward declaration doesn't tell
the compiler anything about Object's constructor or destructor. So, the
compiler will issue an error in this case because it's undefined
behavior to try and deallocate (or construct) an incomplete type and
std::shared_ptr and std::unique_ptr make sure this isn't the case
internally.
Now, if we had defaulted the destructor in "thing.cpp", where we also
include "object.h", this would never be an issue, as the destructor
would only have its code generated in one place, and it would be in a
place where the full class definition of Object would be visible to the
compiler.
---------------------- End example ----------------------------
Given these service classes are more than certainly going to change in
the future, this defaults the constructors and destructors into the
relevant cpp files to make the construction and destruction of all of
the services consistent and unlikely to run into cases where forward
declarations are indirectly causing compilation errors. It also has the
plus of avoiding the need to rebuild several services if destruction
logic changes, since it would only be necessary to recompile the single
cpp file.
2018-09-11 01:20:52 +00:00
|
|
|
ICommonStateGetter::~ICommonStateGetter() = default;
|
|
|
|
|
2018-08-23 22:31:45 +00:00
|
|
|
void ICommonStateGetter::GetBootMode(Kernel::HLERequestContext& ctx) {
|
2018-11-26 06:06:13 +00:00
|
|
|
LOG_DEBUG(Service_AM, "called");
|
|
|
|
|
2018-08-23 22:31:45 +00:00
|
|
|
IPC::ResponseBuilder rb{ctx, 3};
|
|
|
|
rb.Push(RESULT_SUCCESS);
|
|
|
|
|
|
|
|
rb.Push<u8>(static_cast<u8>(Service::PM::SystemBootMode::Normal)); // Normal boot mode
|
|
|
|
}
|
|
|
|
|
2018-02-02 21:03:40 +00:00
|
|
|
void ICommonStateGetter::GetEventHandle(Kernel::HLERequestContext& ctx) {
|
2018-11-26 06:06:13 +00:00
|
|
|
LOG_DEBUG(Service_AM, "called");
|
|
|
|
|
2018-02-02 21:03:40 +00:00
|
|
|
IPC::ResponseBuilder rb{ctx, 2, 1};
|
|
|
|
rb.Push(RESULT_SUCCESS);
|
2018-11-07 07:01:33 +00:00
|
|
|
rb.PushCopyObjects(msg_queue->GetMesssageRecieveEvent());
|
2018-02-02 21:03:40 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void ICommonStateGetter::ReceiveMessage(Kernel::HLERequestContext& ctx) {
|
2018-11-26 06:06:13 +00:00
|
|
|
LOG_DEBUG(Service_AM, "called");
|
|
|
|
|
2019-01-04 02:11:17 +00:00
|
|
|
const auto message = msg_queue->PopMessage();
|
2018-02-02 21:03:40 +00:00
|
|
|
IPC::ResponseBuilder rb{ctx, 3};
|
2019-01-04 02:11:17 +00:00
|
|
|
|
|
|
|
if (message == AppletMessageQueue::AppletMessage::NoMessage) {
|
|
|
|
LOG_ERROR(Service_AM, "Message queue is empty");
|
|
|
|
rb.Push(ERR_NO_MESSAGES);
|
|
|
|
rb.PushEnum<AppletMessageQueue::AppletMessage>(message);
|
|
|
|
return;
|
|
|
|
}
|
2018-02-02 21:03:40 +00:00
|
|
|
rb.Push(RESULT_SUCCESS);
|
2019-01-04 02:11:17 +00:00
|
|
|
rb.PushEnum<AppletMessageQueue::AppletMessage>(message);
|
2018-02-02 21:03:40 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void ICommonStateGetter::GetCurrentFocusState(Kernel::HLERequestContext& ctx) {
|
2018-11-26 06:06:13 +00:00
|
|
|
LOG_WARNING(Service_AM, "(STUBBED) called");
|
|
|
|
|
2018-02-02 21:03:40 +00:00
|
|
|
IPC::ResponseBuilder rb{ctx, 3};
|
|
|
|
rb.Push(RESULT_SUCCESS);
|
|
|
|
rb.Push(static_cast<u8>(FocusState::InFocus));
|
|
|
|
}
|
|
|
|
|
2018-08-16 21:20:54 +00:00
|
|
|
void ICommonStateGetter::GetDefaultDisplayResolutionChangeEvent(Kernel::HLERequestContext& ctx) {
|
2018-11-26 06:06:13 +00:00
|
|
|
LOG_DEBUG(Service_AM, "called");
|
|
|
|
|
2018-08-16 21:20:54 +00:00
|
|
|
IPC::ResponseBuilder rb{ctx, 2, 1};
|
|
|
|
rb.Push(RESULT_SUCCESS);
|
2018-11-07 07:01:33 +00:00
|
|
|
rb.PushCopyObjects(msg_queue->GetOperationModeChangedEvent());
|
2018-08-16 21:20:54 +00:00
|
|
|
}
|
|
|
|
|
2018-09-18 15:10:16 +00:00
|
|
|
void ICommonStateGetter::GetDefaultDisplayResolution(Kernel::HLERequestContext& ctx) {
|
2018-11-26 06:06:13 +00:00
|
|
|
LOG_DEBUG(Service_AM, "called");
|
|
|
|
|
2018-09-18 15:10:16 +00:00
|
|
|
IPC::ResponseBuilder rb{ctx, 4};
|
|
|
|
rb.Push(RESULT_SUCCESS);
|
|
|
|
|
|
|
|
if (Settings::values.use_docked_mode) {
|
2018-11-16 07:07:42 +00:00
|
|
|
rb.Push(static_cast<u32>(Service::VI::DisplayResolution::DockedWidth) *
|
|
|
|
static_cast<u32>(Settings::values.resolution_factor));
|
|
|
|
rb.Push(static_cast<u32>(Service::VI::DisplayResolution::DockedHeight) *
|
|
|
|
static_cast<u32>(Settings::values.resolution_factor));
|
2018-09-18 15:10:16 +00:00
|
|
|
} else {
|
2018-11-16 07:07:42 +00:00
|
|
|
rb.Push(static_cast<u32>(Service::VI::DisplayResolution::UndockedWidth) *
|
|
|
|
static_cast<u32>(Settings::values.resolution_factor));
|
|
|
|
rb.Push(static_cast<u32>(Service::VI::DisplayResolution::UndockedHeight) *
|
|
|
|
static_cast<u32>(Settings::values.resolution_factor));
|
2018-09-18 15:10:16 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2019-06-29 02:46:51 +00:00
|
|
|
void ICommonStateGetter::SetCpuBoostMode(Kernel::HLERequestContext& ctx) {
|
|
|
|
LOG_DEBUG(Service_AM, "called, forwarding to APM:SYS");
|
|
|
|
|
|
|
|
const auto& sm = system.ServiceManager();
|
|
|
|
const auto apm_sys = sm.GetService<APM::APM_Sys>("apm:sys");
|
|
|
|
ASSERT(apm_sys != nullptr);
|
|
|
|
|
|
|
|
apm_sys->SetCpuBoostMode(ctx);
|
|
|
|
}
|
|
|
|
|
2018-11-10 01:04:43 +00:00
|
|
|
IStorage::IStorage(std::vector<u8> buffer)
|
|
|
|
: ServiceFramework("IStorage"), buffer(std::move(buffer)) {
|
|
|
|
// clang-format off
|
|
|
|
static const FunctionInfo functions[] = {
|
|
|
|
{0, &IStorage::Open, "Open"},
|
|
|
|
{1, nullptr, "OpenTransferStorage"},
|
|
|
|
};
|
|
|
|
// clang-format on
|
|
|
|
|
|
|
|
RegisterHandlers(functions);
|
|
|
|
}
|
|
|
|
|
2018-11-11 21:39:25 +00:00
|
|
|
IStorage::~IStorage() = default;
|
|
|
|
|
2018-11-10 01:04:43 +00:00
|
|
|
const std::vector<u8>& IStorage::GetData() const {
|
|
|
|
return buffer;
|
|
|
|
}
|
|
|
|
|
2018-02-02 21:03:40 +00:00
|
|
|
void ICommonStateGetter::GetOperationMode(Kernel::HLERequestContext& ctx) {
|
2018-03-27 02:59:18 +00:00
|
|
|
const bool use_docked_mode{Settings::values.use_docked_mode};
|
2018-11-26 06:06:13 +00:00
|
|
|
LOG_DEBUG(Service_AM, "called, use_docked_mode={}", use_docked_mode);
|
|
|
|
|
2018-02-02 21:03:40 +00:00
|
|
|
IPC::ResponseBuilder rb{ctx, 3};
|
|
|
|
rb.Push(RESULT_SUCCESS);
|
2018-03-27 02:59:18 +00:00
|
|
|
rb.Push(static_cast<u8>(use_docked_mode ? OperationMode::Docked : OperationMode::Handheld));
|
2018-02-02 21:03:40 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void ICommonStateGetter::GetPerformanceMode(Kernel::HLERequestContext& ctx) {
|
2019-06-29 02:46:51 +00:00
|
|
|
LOG_DEBUG(Service_AM, "called");
|
2018-11-26 06:06:13 +00:00
|
|
|
|
2018-02-02 21:03:40 +00:00
|
|
|
IPC::ResponseBuilder rb{ctx, 3};
|
|
|
|
rb.Push(RESULT_SUCCESS);
|
2019-06-29 02:46:51 +00:00
|
|
|
rb.PushEnum(system.GetAPMController().GetCurrentPerformanceMode());
|
2018-02-02 21:03:40 +00:00
|
|
|
}
|
|
|
|
|
2018-11-10 01:06:50 +00:00
|
|
|
class ILibraryAppletAccessor final : public ServiceFramework<ILibraryAppletAccessor> {
|
2018-02-02 21:03:40 +00:00
|
|
|
public:
|
2018-11-10 01:06:50 +00:00
|
|
|
explicit ILibraryAppletAccessor(std::shared_ptr<Applets::Applet> applet)
|
2018-11-20 17:02:16 +00:00
|
|
|
: ServiceFramework("ILibraryAppletAccessor"), applet(std::move(applet)) {
|
2018-10-21 20:40:17 +00:00
|
|
|
// clang-format off
|
2018-02-02 21:03:40 +00:00
|
|
|
static const FunctionInfo functions[] = {
|
2018-11-10 01:06:50 +00:00
|
|
|
{0, &ILibraryAppletAccessor::GetAppletStateChangedEvent, "GetAppletStateChangedEvent"},
|
2018-11-11 21:57:59 +00:00
|
|
|
{1, &ILibraryAppletAccessor::IsCompleted, "IsCompleted"},
|
2018-11-10 01:06:50 +00:00
|
|
|
{10, &ILibraryAppletAccessor::Start, "Start"},
|
|
|
|
{20, nullptr, "RequestExit"},
|
|
|
|
{25, nullptr, "Terminate"},
|
|
|
|
{30, &ILibraryAppletAccessor::GetResult, "GetResult"},
|
|
|
|
{50, nullptr, "SetOutOfFocusApplicationSuspendingEnabled"},
|
|
|
|
{100, &ILibraryAppletAccessor::PushInData, "PushInData"},
|
|
|
|
{101, &ILibraryAppletAccessor::PopOutData, "PopOutData"},
|
|
|
|
{102, nullptr, "PushExtraStorage"},
|
|
|
|
{103, &ILibraryAppletAccessor::PushInteractiveInData, "PushInteractiveInData"},
|
|
|
|
{104, &ILibraryAppletAccessor::PopInteractiveOutData, "PopInteractiveOutData"},
|
2018-11-11 21:41:31 +00:00
|
|
|
{105, &ILibraryAppletAccessor::GetPopOutDataEvent, "GetPopOutDataEvent"},
|
2018-11-10 01:06:50 +00:00
|
|
|
{106, &ILibraryAppletAccessor::GetPopInteractiveOutDataEvent, "GetPopInteractiveOutDataEvent"},
|
|
|
|
{110, nullptr, "NeedsToExitProcess"},
|
|
|
|
{120, nullptr, "GetLibraryAppletInfo"},
|
|
|
|
{150, nullptr, "RequestForAppletToGetForeground"},
|
|
|
|
{160, nullptr, "GetIndirectLayerConsumerHandle"},
|
2018-02-02 21:03:40 +00:00
|
|
|
};
|
2018-10-21 20:40:17 +00:00
|
|
|
// clang-format on
|
|
|
|
|
2018-02-02 21:03:40 +00:00
|
|
|
RegisterHandlers(functions);
|
|
|
|
}
|
|
|
|
|
|
|
|
private:
|
2018-11-10 01:06:50 +00:00
|
|
|
void GetAppletStateChangedEvent(Kernel::HLERequestContext& ctx) {
|
2018-11-26 06:06:13 +00:00
|
|
|
LOG_DEBUG(Service_AM, "called");
|
|
|
|
|
2018-11-20 17:02:16 +00:00
|
|
|
const auto event = applet->GetBroker().GetStateChangedEvent();
|
2018-02-02 21:03:40 +00:00
|
|
|
|
2018-11-10 01:06:50 +00:00
|
|
|
IPC::ResponseBuilder rb{ctx, 2, 1};
|
|
|
|
rb.Push(RESULT_SUCCESS);
|
2018-11-19 19:24:36 +00:00
|
|
|
rb.PushCopyObjects(event);
|
2018-11-10 01:06:50 +00:00
|
|
|
}
|
|
|
|
|
2018-11-11 21:57:59 +00:00
|
|
|
void IsCompleted(Kernel::HLERequestContext& ctx) {
|
2018-11-26 06:06:13 +00:00
|
|
|
LOG_DEBUG(Service_AM, "called");
|
|
|
|
|
2018-11-11 21:57:59 +00:00
|
|
|
IPC::ResponseBuilder rb{ctx, 3};
|
2018-02-02 21:03:40 +00:00
|
|
|
rb.Push(RESULT_SUCCESS);
|
2018-11-11 21:57:59 +00:00
|
|
|
rb.Push<u32>(applet->TransactionComplete());
|
|
|
|
}
|
2018-02-02 21:03:40 +00:00
|
|
|
|
2018-11-11 21:57:59 +00:00
|
|
|
void GetResult(Kernel::HLERequestContext& ctx) {
|
2018-11-26 06:06:13 +00:00
|
|
|
LOG_DEBUG(Service_AM, "called");
|
|
|
|
|
2018-11-11 21:57:59 +00:00
|
|
|
IPC::ResponseBuilder rb{ctx, 2};
|
|
|
|
rb.Push(applet->GetStatus());
|
2018-02-02 21:03:40 +00:00
|
|
|
}
|
|
|
|
|
2018-11-10 01:08:25 +00:00
|
|
|
void Start(Kernel::HLERequestContext& ctx) {
|
2018-11-26 06:06:13 +00:00
|
|
|
LOG_DEBUG(Service_AM, "called");
|
|
|
|
|
2018-11-10 01:08:25 +00:00
|
|
|
ASSERT(applet != nullptr);
|
2018-06-03 18:21:45 +00:00
|
|
|
|
2018-11-20 17:02:16 +00:00
|
|
|
applet->Initialize();
|
2018-11-19 19:24:36 +00:00
|
|
|
applet->Execute();
|
2018-11-11 21:41:31 +00:00
|
|
|
|
2018-11-10 01:08:25 +00:00
|
|
|
IPC::ResponseBuilder rb{ctx, 2};
|
|
|
|
rb.Push(RESULT_SUCCESS);
|
|
|
|
}
|
2018-06-03 18:21:45 +00:00
|
|
|
|
2018-11-10 01:06:50 +00:00
|
|
|
void PushInData(Kernel::HLERequestContext& ctx) {
|
2018-11-26 06:06:13 +00:00
|
|
|
LOG_DEBUG(Service_AM, "called");
|
|
|
|
|
2018-11-10 01:06:50 +00:00
|
|
|
IPC::RequestParser rp{ctx};
|
2018-11-20 17:02:16 +00:00
|
|
|
applet->GetBroker().PushNormalDataFromGame(*rp.PopIpcInterface<IStorage>());
|
2018-06-03 18:21:45 +00:00
|
|
|
|
2018-09-19 05:09:59 +00:00
|
|
|
IPC::ResponseBuilder rb{ctx, 2};
|
2018-06-03 18:21:45 +00:00
|
|
|
rb.Push(RESULT_SUCCESS);
|
|
|
|
}
|
|
|
|
|
2018-11-10 01:06:50 +00:00
|
|
|
void PopOutData(Kernel::HLERequestContext& ctx) {
|
2018-11-26 06:06:13 +00:00
|
|
|
LOG_DEBUG(Service_AM, "called");
|
|
|
|
|
2018-11-10 01:06:50 +00:00
|
|
|
IPC::ResponseBuilder rb{ctx, 2, 0, 1};
|
2018-11-17 17:19:06 +00:00
|
|
|
|
2018-11-20 17:02:16 +00:00
|
|
|
const auto storage = applet->GetBroker().PopNormalDataToGame();
|
2018-11-19 19:24:36 +00:00
|
|
|
if (storage == nullptr) {
|
2018-11-27 01:29:06 +00:00
|
|
|
LOG_ERROR(Service_AM,
|
|
|
|
"storage is a nullptr. There is no data in the current normal channel");
|
2018-11-26 06:06:13 +00:00
|
|
|
|
2018-11-19 19:24:36 +00:00
|
|
|
rb.Push(ERR_NO_DATA_IN_CHANNEL);
|
2018-11-17 17:19:06 +00:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2018-11-10 01:06:50 +00:00
|
|
|
rb.Push(RESULT_SUCCESS);
|
2018-11-19 19:24:36 +00:00
|
|
|
rb.PushIpcInterface<IStorage>(std::move(*storage));
|
2018-11-10 01:06:50 +00:00
|
|
|
}
|
2018-02-02 21:03:40 +00:00
|
|
|
|
2018-11-10 01:07:42 +00:00
|
|
|
void PushInteractiveInData(Kernel::HLERequestContext& ctx) {
|
2018-11-26 06:06:13 +00:00
|
|
|
LOG_DEBUG(Service_AM, "called");
|
|
|
|
|
2018-11-10 01:07:42 +00:00
|
|
|
IPC::RequestParser rp{ctx};
|
2018-11-20 17:02:16 +00:00
|
|
|
applet->GetBroker().PushInteractiveDataFromGame(*rp.PopIpcInterface<IStorage>());
|
2018-02-02 21:03:40 +00:00
|
|
|
|
2018-11-11 21:41:31 +00:00
|
|
|
ASSERT(applet->IsInitialized());
|
2018-11-19 19:24:36 +00:00
|
|
|
applet->ExecuteInteractive();
|
|
|
|
applet->Execute();
|
2018-11-11 21:41:31 +00:00
|
|
|
|
2018-09-19 05:09:59 +00:00
|
|
|
IPC::ResponseBuilder rb{ctx, 2};
|
2018-02-02 21:03:40 +00:00
|
|
|
rb.Push(RESULT_SUCCESS);
|
|
|
|
}
|
|
|
|
|
2018-11-10 01:07:42 +00:00
|
|
|
void PopInteractiveOutData(Kernel::HLERequestContext& ctx) {
|
2018-11-26 06:06:13 +00:00
|
|
|
LOG_DEBUG(Service_AM, "called");
|
|
|
|
|
2018-11-10 01:07:42 +00:00
|
|
|
IPC::ResponseBuilder rb{ctx, 2, 0, 1};
|
2018-11-17 17:19:06 +00:00
|
|
|
|
2018-11-20 17:02:16 +00:00
|
|
|
const auto storage = applet->GetBroker().PopInteractiveDataToGame();
|
2018-11-19 19:24:36 +00:00
|
|
|
if (storage == nullptr) {
|
2018-11-27 01:29:06 +00:00
|
|
|
LOG_ERROR(Service_AM,
|
|
|
|
"storage is a nullptr. There is no data in the current interactive channel");
|
2018-11-26 06:06:13 +00:00
|
|
|
|
2018-11-19 19:24:36 +00:00
|
|
|
rb.Push(ERR_NO_DATA_IN_CHANNEL);
|
2018-11-17 17:19:06 +00:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2018-11-10 01:07:42 +00:00
|
|
|
rb.Push(RESULT_SUCCESS);
|
2018-11-19 19:24:36 +00:00
|
|
|
rb.PushIpcInterface<IStorage>(std::move(*storage));
|
2018-11-10 01:07:42 +00:00
|
|
|
}
|
|
|
|
|
2018-11-11 21:41:31 +00:00
|
|
|
void GetPopOutDataEvent(Kernel::HLERequestContext& ctx) {
|
2018-11-26 06:06:13 +00:00
|
|
|
LOG_DEBUG(Service_AM, "called");
|
|
|
|
|
2018-11-11 21:41:31 +00:00
|
|
|
IPC::ResponseBuilder rb{ctx, 2, 1};
|
|
|
|
rb.Push(RESULT_SUCCESS);
|
2018-11-20 17:02:16 +00:00
|
|
|
rb.PushCopyObjects(applet->GetBroker().GetNormalDataEvent());
|
2018-11-11 21:41:31 +00:00
|
|
|
}
|
2018-11-10 01:07:42 +00:00
|
|
|
|
2018-11-11 21:41:31 +00:00
|
|
|
void GetPopInteractiveOutDataEvent(Kernel::HLERequestContext& ctx) {
|
2018-11-26 06:06:13 +00:00
|
|
|
LOG_DEBUG(Service_AM, "called");
|
|
|
|
|
2018-11-10 01:07:42 +00:00
|
|
|
IPC::ResponseBuilder rb{ctx, 2, 1};
|
|
|
|
rb.Push(RESULT_SUCCESS);
|
2018-11-20 17:02:16 +00:00
|
|
|
rb.PushCopyObjects(applet->GetBroker().GetInteractiveDataEvent());
|
2018-02-02 21:03:40 +00:00
|
|
|
}
|
|
|
|
|
2018-11-10 01:06:50 +00:00
|
|
|
std::shared_ptr<Applets::Applet> applet;
|
|
|
|
};
|
2018-02-02 21:03:40 +00:00
|
|
|
|
2018-11-10 01:06:50 +00:00
|
|
|
void IStorage::Open(Kernel::HLERequestContext& ctx) {
|
2018-11-26 06:06:13 +00:00
|
|
|
LOG_DEBUG(Service_AM, "called");
|
|
|
|
|
2018-11-10 01:06:50 +00:00
|
|
|
IPC::ResponseBuilder rb{ctx, 2, 0, 1};
|
2018-02-02 21:03:40 +00:00
|
|
|
|
2018-11-10 01:06:50 +00:00
|
|
|
rb.Push(RESULT_SUCCESS);
|
|
|
|
rb.PushIpcInterface<IStorageAccessor>(*this);
|
|
|
|
}
|
2018-02-02 21:03:40 +00:00
|
|
|
|
2018-11-10 01:04:07 +00:00
|
|
|
IStorageAccessor::IStorageAccessor(IStorage& storage)
|
|
|
|
: ServiceFramework("IStorageAccessor"), backing(storage) {
|
|
|
|
// clang-format off
|
2018-06-03 18:23:44 +00:00
|
|
|
static const FunctionInfo functions[] = {
|
2018-11-10 01:04:07 +00:00
|
|
|
{0, &IStorageAccessor::GetSize, "GetSize"},
|
|
|
|
{10, &IStorageAccessor::Write, "Write"},
|
|
|
|
{11, &IStorageAccessor::Read, "Read"},
|
2018-06-03 18:23:44 +00:00
|
|
|
};
|
2018-11-10 01:04:07 +00:00
|
|
|
// clang-format on
|
2018-10-21 20:40:17 +00:00
|
|
|
|
2018-11-10 01:04:07 +00:00
|
|
|
RegisterHandlers(functions);
|
|
|
|
}
|
2018-06-03 18:23:44 +00:00
|
|
|
|
2018-11-11 21:39:25 +00:00
|
|
|
IStorageAccessor::~IStorageAccessor() = default;
|
|
|
|
|
2018-11-10 01:04:07 +00:00
|
|
|
void IStorageAccessor::GetSize(Kernel::HLERequestContext& ctx) {
|
2018-11-26 06:06:13 +00:00
|
|
|
LOG_DEBUG(Service_AM, "called");
|
|
|
|
|
2018-11-10 01:04:07 +00:00
|
|
|
IPC::ResponseBuilder rb{ctx, 4};
|
2018-06-03 18:23:44 +00:00
|
|
|
|
2018-11-10 01:04:07 +00:00
|
|
|
rb.Push(RESULT_SUCCESS);
|
|
|
|
rb.Push(static_cast<u64>(backing.buffer.size()));
|
|
|
|
}
|
2018-06-03 18:23:44 +00:00
|
|
|
|
2018-11-10 01:04:07 +00:00
|
|
|
void IStorageAccessor::Write(Kernel::HLERequestContext& ctx) {
|
|
|
|
IPC::RequestParser rp{ctx};
|
2018-06-03 18:23:44 +00:00
|
|
|
|
2018-11-10 01:04:07 +00:00
|
|
|
const u64 offset{rp.Pop<u64>()};
|
|
|
|
const std::vector<u8> data{ctx.ReadBuffer()};
|
2018-06-04 03:37:17 +00:00
|
|
|
|
2018-12-24 21:16:28 +00:00
|
|
|
LOG_DEBUG(Service_AM, "called, offset={}, size={}", offset, data.size());
|
|
|
|
|
2018-11-19 19:24:36 +00:00
|
|
|
if (data.size() > backing.buffer.size() - offset) {
|
2018-11-26 09:05:09 +00:00
|
|
|
LOG_ERROR(Service_AM,
|
|
|
|
"offset is out of bounds, backing_buffer_sz={}, data_size={}, offset={}",
|
|
|
|
backing.buffer.size(), data.size(), offset);
|
2018-11-26 06:06:13 +00:00
|
|
|
|
2018-11-19 19:24:36 +00:00
|
|
|
IPC::ResponseBuilder rb{ctx, 2};
|
|
|
|
rb.Push(ERR_SIZE_OUT_OF_BOUNDS);
|
2019-05-18 22:49:19 +00:00
|
|
|
return;
|
2018-11-19 19:24:36 +00:00
|
|
|
}
|
2018-06-04 03:37:17 +00:00
|
|
|
|
2018-11-19 19:24:36 +00:00
|
|
|
std::memcpy(backing.buffer.data() + offset, data.data(), data.size());
|
2018-06-04 03:37:17 +00:00
|
|
|
|
2018-11-10 01:04:07 +00:00
|
|
|
IPC::ResponseBuilder rb{ctx, 2};
|
|
|
|
rb.Push(RESULT_SUCCESS);
|
|
|
|
}
|
2018-06-03 18:23:44 +00:00
|
|
|
|
2018-11-10 01:04:07 +00:00
|
|
|
void IStorageAccessor::Read(Kernel::HLERequestContext& ctx) {
|
|
|
|
IPC::RequestParser rp{ctx};
|
2018-06-03 18:23:44 +00:00
|
|
|
|
2018-11-10 01:04:07 +00:00
|
|
|
const u64 offset{rp.Pop<u64>()};
|
2018-11-19 19:24:36 +00:00
|
|
|
const std::size_t size{ctx.GetWriteBufferSize()};
|
2018-06-03 18:23:44 +00:00
|
|
|
|
2018-12-24 21:16:28 +00:00
|
|
|
LOG_DEBUG(Service_AM, "called, offset={}, size={}", offset, size);
|
|
|
|
|
2018-11-19 19:24:36 +00:00
|
|
|
if (size > backing.buffer.size() - offset) {
|
2018-11-26 09:05:09 +00:00
|
|
|
LOG_ERROR(Service_AM, "offset is out of bounds, backing_buffer_sz={}, size={}, offset={}",
|
|
|
|
backing.buffer.size(), size, offset);
|
2018-11-26 06:06:13 +00:00
|
|
|
|
2018-11-19 19:24:36 +00:00
|
|
|
IPC::ResponseBuilder rb{ctx, 2};
|
|
|
|
rb.Push(ERR_SIZE_OUT_OF_BOUNDS);
|
2019-05-18 22:49:19 +00:00
|
|
|
return;
|
2018-11-19 19:24:36 +00:00
|
|
|
}
|
2018-06-04 03:43:31 +00:00
|
|
|
|
2018-11-10 01:04:07 +00:00
|
|
|
ctx.WriteBuffer(backing.buffer.data() + offset, size);
|
2018-06-04 03:43:31 +00:00
|
|
|
|
2018-11-10 01:04:07 +00:00
|
|
|
IPC::ResponseBuilder rb{ctx, 2};
|
|
|
|
rb.Push(RESULT_SUCCESS);
|
|
|
|
}
|
2018-06-03 18:23:44 +00:00
|
|
|
|
2019-06-06 23:46:36 +00:00
|
|
|
ILibraryAppletCreator::ILibraryAppletCreator(u64 current_process_title_id)
|
|
|
|
: ServiceFramework("ILibraryAppletCreator"),
|
|
|
|
current_process_title_id(current_process_title_id) {
|
2018-06-03 18:19:24 +00:00
|
|
|
static const FunctionInfo functions[] = {
|
|
|
|
{0, &ILibraryAppletCreator::CreateLibraryApplet, "CreateLibraryApplet"},
|
|
|
|
{1, nullptr, "TerminateAllLibraryApplets"},
|
|
|
|
{2, nullptr, "AreAnyLibraryAppletsLeft"},
|
|
|
|
{10, &ILibraryAppletCreator::CreateStorage, "CreateStorage"},
|
2018-11-10 01:04:07 +00:00
|
|
|
{11, &ILibraryAppletCreator::CreateTransferMemoryStorage, "CreateTransferMemoryStorage"},
|
2018-06-03 18:19:24 +00:00
|
|
|
{12, nullptr, "CreateHandleStorage"},
|
|
|
|
};
|
|
|
|
RegisterHandlers(functions);
|
|
|
|
}
|
|
|
|
|
hle/service: Default constructors and destructors in the cpp file where applicable
When a destructor isn't defaulted into a cpp file, it can cause the use
of forward declarations to seemingly fail to compile for non-obvious
reasons. It also allows inlining of the construction/destruction logic
all over the place where a constructor or destructor is invoked, which
can lead to code bloat. This isn't so much a worry here, given the
services won't be created and destroyed frequently.
The cause of the above mentioned non-obvious errors can be demonstrated
as follows:
------- Demonstrative example, if you know how the described error happens, skip forwards -------
Assume we have the following in the header, which we'll call "thing.h":
\#include <memory>
// Forward declaration. For example purposes, assume the definition
// of Object is in some header named "object.h"
class Object;
class Thing {
public:
// assume no constructors or destructors are specified here,
// or the constructors/destructors are defined as:
//
// Thing() = default;
// ~Thing() = default;
//
// ... Some interface member functions would be defined here
private:
std::shared_ptr<Object> obj;
};
If this header is included in a cpp file, (which we'll call "main.cpp"),
this will result in a compilation error, because even though no
destructor is specified, the destructor will still need to be generated by
the compiler because std::shared_ptr's destructor is *not* trivial (in
other words, it does something other than nothing), as std::shared_ptr's
destructor needs to do two things:
1. Decrement the shared reference count of the object being pointed to,
and if the reference count decrements to zero,
2. Free the Object instance's memory (aka deallocate the memory it's
pointing to).
And so the compiler generates the code for the destructor doing this inside main.cpp.
Now, keep in mind, the Object forward declaration is not a complete type. All it
does is tell the compiler "a type named Object exists" and allows us to
use the name in certain situations to avoid a header dependency. So the
compiler needs to generate destruction code for Object, but the compiler
doesn't know *how* to destruct it. A forward declaration doesn't tell
the compiler anything about Object's constructor or destructor. So, the
compiler will issue an error in this case because it's undefined
behavior to try and deallocate (or construct) an incomplete type and
std::shared_ptr and std::unique_ptr make sure this isn't the case
internally.
Now, if we had defaulted the destructor in "thing.cpp", where we also
include "object.h", this would never be an issue, as the destructor
would only have its code generated in one place, and it would be in a
place where the full class definition of Object would be visible to the
compiler.
---------------------- End example ----------------------------
Given these service classes are more than certainly going to change in
the future, this defaults the constructors and destructors into the
relevant cpp files to make the construction and destruction of all of
the services consistent and unlikely to run into cases where forward
declarations are indirectly causing compilation errors. It also has the
plus of avoiding the need to rebuild several services if destruction
logic changes, since it would only be necessary to recompile the single
cpp file.
2018-09-11 01:20:52 +00:00
|
|
|
ILibraryAppletCreator::~ILibraryAppletCreator() = default;
|
|
|
|
|
2018-06-03 18:19:24 +00:00
|
|
|
void ILibraryAppletCreator::CreateLibraryApplet(Kernel::HLERequestContext& ctx) {
|
2018-11-10 01:14:01 +00:00
|
|
|
IPC::RequestParser rp{ctx};
|
2019-03-11 23:33:18 +00:00
|
|
|
const auto applet_id = rp.PopRaw<Applets::AppletId>();
|
2018-11-10 01:14:01 +00:00
|
|
|
const auto applet_mode = rp.PopRaw<u32>();
|
|
|
|
|
|
|
|
LOG_DEBUG(Service_AM, "called with applet_id={:08X}, applet_mode={:08X}",
|
|
|
|
static_cast<u32>(applet_id), applet_mode);
|
|
|
|
|
2019-03-11 23:33:18 +00:00
|
|
|
const auto& applet_manager{Core::System::GetInstance().GetAppletManager()};
|
2019-06-06 23:46:36 +00:00
|
|
|
const auto applet = applet_manager.GetApplet(applet_id, current_process_title_id);
|
2018-11-10 01:14:01 +00:00
|
|
|
|
|
|
|
if (applet == nullptr) {
|
2018-11-26 09:05:09 +00:00
|
|
|
LOG_ERROR(Service_AM, "Applet doesn't exist! applet_id={}", static_cast<u32>(applet_id));
|
2018-11-26 06:06:13 +00:00
|
|
|
|
2018-11-10 01:14:01 +00:00
|
|
|
IPC::ResponseBuilder rb{ctx, 2};
|
|
|
|
rb.Push(ResultCode(-1));
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2018-06-03 18:19:24 +00:00
|
|
|
IPC::ResponseBuilder rb{ctx, 2, 0, 1};
|
|
|
|
|
|
|
|
rb.Push(RESULT_SUCCESS);
|
2018-11-10 01:14:01 +00:00
|
|
|
rb.PushIpcInterface<AM::ILibraryAppletAccessor>(applet);
|
2018-06-03 18:19:24 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void ILibraryAppletCreator::CreateStorage(Kernel::HLERequestContext& ctx) {
|
|
|
|
IPC::RequestParser rp{ctx};
|
|
|
|
const u64 size{rp.Pop<u64>()};
|
2018-11-26 06:06:13 +00:00
|
|
|
LOG_DEBUG(Service_AM, "called, size={}", size);
|
|
|
|
|
2018-06-03 18:19:24 +00:00
|
|
|
std::vector<u8> buffer(size);
|
|
|
|
|
2018-09-19 05:09:59 +00:00
|
|
|
IPC::ResponseBuilder rb{ctx, 2, 0, 1};
|
2018-06-03 18:19:24 +00:00
|
|
|
rb.Push(RESULT_SUCCESS);
|
|
|
|
rb.PushIpcInterface<AM::IStorage>(std::move(buffer));
|
|
|
|
}
|
|
|
|
|
2018-11-10 01:01:20 +00:00
|
|
|
void ILibraryAppletCreator::CreateTransferMemoryStorage(Kernel::HLERequestContext& ctx) {
|
2018-11-26 06:06:13 +00:00
|
|
|
LOG_DEBUG(Service_AM, "called");
|
|
|
|
|
2018-11-10 01:01:20 +00:00
|
|
|
IPC::RequestParser rp{ctx};
|
|
|
|
|
|
|
|
rp.SetCurrentOffset(3);
|
|
|
|
const auto handle{rp.Pop<Kernel::Handle>()};
|
|
|
|
|
2019-04-03 20:35:14 +00:00
|
|
|
const auto transfer_mem =
|
|
|
|
Core::System::GetInstance().CurrentProcess()->GetHandleTable().Get<Kernel::TransferMemory>(
|
2018-11-10 01:01:20 +00:00
|
|
|
handle);
|
|
|
|
|
2019-04-03 20:35:14 +00:00
|
|
|
if (transfer_mem == nullptr) {
|
2018-11-26 09:05:09 +00:00
|
|
|
LOG_ERROR(Service_AM, "shared_mem is a nullpr for handle={:08X}", handle);
|
2018-11-10 01:01:20 +00:00
|
|
|
IPC::ResponseBuilder rb{ctx, 2};
|
|
|
|
rb.Push(ResultCode(-1));
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2019-04-03 20:35:14 +00:00
|
|
|
const u8* const mem_begin = transfer_mem->GetPointer();
|
|
|
|
const u8* const mem_end = mem_begin + transfer_mem->GetSize();
|
2018-11-11 21:39:25 +00:00
|
|
|
std::vector<u8> memory{mem_begin, mem_end};
|
2018-11-10 01:01:20 +00:00
|
|
|
|
|
|
|
IPC::ResponseBuilder rb{ctx, 2, 0, 1};
|
|
|
|
rb.Push(RESULT_SUCCESS);
|
|
|
|
rb.PushIpcInterface(std::make_shared<IStorage>(std::move(memory)));
|
|
|
|
}
|
|
|
|
|
2018-02-02 21:03:40 +00:00
|
|
|
IApplicationFunctions::IApplicationFunctions() : ServiceFramework("IApplicationFunctions") {
|
2018-10-21 20:40:17 +00:00
|
|
|
// clang-format off
|
2018-02-02 21:03:40 +00:00
|
|
|
static const FunctionInfo functions[] = {
|
|
|
|
{1, &IApplicationFunctions::PopLaunchParameter, "PopLaunchParameter"},
|
2018-04-10 15:36:00 +00:00
|
|
|
{10, nullptr, "CreateApplicationAndPushAndRequestToStart"},
|
|
|
|
{11, nullptr, "CreateApplicationAndPushAndRequestToStartForQuest"},
|
|
|
|
{12, nullptr, "CreateApplicationAndRequestToStart"},
|
2018-10-21 20:40:17 +00:00
|
|
|
{13, &IApplicationFunctions::CreateApplicationAndRequestToStartForQuest, "CreateApplicationAndRequestToStartForQuest"},
|
2019-04-10 18:48:37 +00:00
|
|
|
{14, nullptr, "CreateApplicationWithAttributeAndPushAndRequestToStartForQuest"},
|
|
|
|
{15, nullptr, "CreateApplicationWithAttributeAndRequestToStartForQuest"},
|
2018-02-06 01:58:11 +00:00
|
|
|
{20, &IApplicationFunctions::EnsureSaveData, "EnsureSaveData"},
|
2018-02-02 21:03:40 +00:00
|
|
|
{21, &IApplicationFunctions::GetDesiredLanguage, "GetDesiredLanguage"},
|
|
|
|
{22, &IApplicationFunctions::SetTerminateResult, "SetTerminateResult"},
|
2018-05-26 04:21:03 +00:00
|
|
|
{23, &IApplicationFunctions::GetDisplayVersion, "GetDisplayVersion"},
|
2018-04-10 15:36:00 +00:00
|
|
|
{24, nullptr, "GetLaunchStorageInfoForDebug"},
|
2018-12-11 03:17:45 +00:00
|
|
|
{25, &IApplicationFunctions::ExtendSaveData, "ExtendSaveData"},
|
|
|
|
{26, &IApplicationFunctions::GetSaveDataSize, "GetSaveDataSize"},
|
2018-10-21 20:40:17 +00:00
|
|
|
{30, &IApplicationFunctions::BeginBlockingHomeButtonShortAndLongPressed, "BeginBlockingHomeButtonShortAndLongPressed"},
|
|
|
|
{31, &IApplicationFunctions::EndBlockingHomeButtonShortAndLongPressed, "EndBlockingHomeButtonShortAndLongPressed"},
|
2018-10-19 13:01:10 +00:00
|
|
|
{32, &IApplicationFunctions::BeginBlockingHomeButton, "BeginBlockingHomeButton"},
|
|
|
|
{33, &IApplicationFunctions::EndBlockingHomeButton, "EndBlockingHomeButton"},
|
2018-04-10 15:36:00 +00:00
|
|
|
{40, &IApplicationFunctions::NotifyRunning, "NotifyRunning"},
|
2018-06-05 22:44:01 +00:00
|
|
|
{50, &IApplicationFunctions::GetPseudoDeviceId, "GetPseudoDeviceId"},
|
2018-04-10 15:36:00 +00:00
|
|
|
{60, nullptr, "SetMediaPlaybackStateForApplication"},
|
|
|
|
{65, nullptr, "IsGamePlayRecordingSupported"},
|
2018-02-02 21:03:40 +00:00
|
|
|
{66, &IApplicationFunctions::InitializeGamePlayRecording, "InitializeGamePlayRecording"},
|
|
|
|
{67, &IApplicationFunctions::SetGamePlayRecordingState, "SetGamePlayRecordingState"},
|
2018-04-10 15:36:00 +00:00
|
|
|
{68, nullptr, "RequestFlushGamePlayingMovieForDebug"},
|
|
|
|
{70, nullptr, "RequestToShutdown"},
|
|
|
|
{71, nullptr, "RequestToReboot"},
|
|
|
|
{80, nullptr, "ExitAndRequestToShowThanksMessage"},
|
2018-11-17 14:05:55 +00:00
|
|
|
{90, &IApplicationFunctions::EnableApplicationCrashReport, "EnableApplicationCrashReport"},
|
2018-04-10 15:36:00 +00:00
|
|
|
{100, nullptr, "InitializeApplicationCopyrightFrameBuffer"},
|
|
|
|
{101, nullptr, "SetApplicationCopyrightImage"},
|
|
|
|
{102, nullptr, "SetApplicationCopyrightVisibility"},
|
|
|
|
{110, nullptr, "QueryApplicationPlayStatistics"},
|
|
|
|
{120, nullptr, "ExecuteProgram"},
|
|
|
|
{121, nullptr, "ClearUserChannel"},
|
|
|
|
{122, nullptr, "UnpopToUserChannel"},
|
2019-09-04 15:43:04 +00:00
|
|
|
{130, &IApplicationFunctions::GetGpuErrorDetectedSystemEvent, "GetGpuErrorDetectedSystemEvent"},
|
2018-04-10 15:36:00 +00:00
|
|
|
{500, nullptr, "StartContinuousRecordingFlushForDebug"},
|
|
|
|
{1000, nullptr, "CreateMovieMaker"},
|
|
|
|
{1001, nullptr, "PrepareForJit"},
|
2018-02-02 21:03:40 +00:00
|
|
|
};
|
2018-10-21 20:40:17 +00:00
|
|
|
// clang-format on
|
|
|
|
|
2018-02-02 21:03:40 +00:00
|
|
|
RegisterHandlers(functions);
|
2019-09-04 15:43:04 +00:00
|
|
|
|
|
|
|
auto& kernel = Core::System::GetInstance().Kernel();
|
|
|
|
gpu_error_detected_event = Kernel::WritableEvent::CreateEventPair(
|
|
|
|
kernel, Kernel::ResetType::Manual, "IApplicationFunctions:GpuErrorDetectedSystemEvent");
|
2018-02-02 21:03:40 +00:00
|
|
|
}
|
|
|
|
|
hle/service: Default constructors and destructors in the cpp file where applicable
When a destructor isn't defaulted into a cpp file, it can cause the use
of forward declarations to seemingly fail to compile for non-obvious
reasons. It also allows inlining of the construction/destruction logic
all over the place where a constructor or destructor is invoked, which
can lead to code bloat. This isn't so much a worry here, given the
services won't be created and destroyed frequently.
The cause of the above mentioned non-obvious errors can be demonstrated
as follows:
------- Demonstrative example, if you know how the described error happens, skip forwards -------
Assume we have the following in the header, which we'll call "thing.h":
\#include <memory>
// Forward declaration. For example purposes, assume the definition
// of Object is in some header named "object.h"
class Object;
class Thing {
public:
// assume no constructors or destructors are specified here,
// or the constructors/destructors are defined as:
//
// Thing() = default;
// ~Thing() = default;
//
// ... Some interface member functions would be defined here
private:
std::shared_ptr<Object> obj;
};
If this header is included in a cpp file, (which we'll call "main.cpp"),
this will result in a compilation error, because even though no
destructor is specified, the destructor will still need to be generated by
the compiler because std::shared_ptr's destructor is *not* trivial (in
other words, it does something other than nothing), as std::shared_ptr's
destructor needs to do two things:
1. Decrement the shared reference count of the object being pointed to,
and if the reference count decrements to zero,
2. Free the Object instance's memory (aka deallocate the memory it's
pointing to).
And so the compiler generates the code for the destructor doing this inside main.cpp.
Now, keep in mind, the Object forward declaration is not a complete type. All it
does is tell the compiler "a type named Object exists" and allows us to
use the name in certain situations to avoid a header dependency. So the
compiler needs to generate destruction code for Object, but the compiler
doesn't know *how* to destruct it. A forward declaration doesn't tell
the compiler anything about Object's constructor or destructor. So, the
compiler will issue an error in this case because it's undefined
behavior to try and deallocate (or construct) an incomplete type and
std::shared_ptr and std::unique_ptr make sure this isn't the case
internally.
Now, if we had defaulted the destructor in "thing.cpp", where we also
include "object.h", this would never be an issue, as the destructor
would only have its code generated in one place, and it would be in a
place where the full class definition of Object would be visible to the
compiler.
---------------------- End example ----------------------------
Given these service classes are more than certainly going to change in
the future, this defaults the constructors and destructors into the
relevant cpp files to make the construction and destruction of all of
the services consistent and unlikely to run into cases where forward
declarations are indirectly causing compilation errors. It also has the
plus of avoiding the need to rebuild several services if destruction
logic changes, since it would only be necessary to recompile the single
cpp file.
2018-09-11 01:20:52 +00:00
|
|
|
IApplicationFunctions::~IApplicationFunctions() = default;
|
|
|
|
|
2018-11-17 14:05:55 +00:00
|
|
|
void IApplicationFunctions::EnableApplicationCrashReport(Kernel::HLERequestContext& ctx) {
|
2018-11-26 06:06:13 +00:00
|
|
|
LOG_WARNING(Service_AM, "(STUBBED) called");
|
|
|
|
|
2018-11-17 14:05:55 +00:00
|
|
|
IPC::ResponseBuilder rb{ctx, 2};
|
|
|
|
rb.Push(RESULT_SUCCESS);
|
|
|
|
}
|
|
|
|
|
2018-10-19 13:01:10 +00:00
|
|
|
void IApplicationFunctions::BeginBlockingHomeButtonShortAndLongPressed(
|
|
|
|
Kernel::HLERequestContext& ctx) {
|
2018-11-26 06:06:13 +00:00
|
|
|
LOG_WARNING(Service_AM, "(STUBBED) called");
|
|
|
|
|
2018-10-19 13:01:10 +00:00
|
|
|
IPC::ResponseBuilder rb{ctx, 2};
|
|
|
|
rb.Push(RESULT_SUCCESS);
|
|
|
|
}
|
|
|
|
|
|
|
|
void IApplicationFunctions::EndBlockingHomeButtonShortAndLongPressed(
|
|
|
|
Kernel::HLERequestContext& ctx) {
|
2018-11-26 06:06:13 +00:00
|
|
|
LOG_WARNING(Service_AM, "(STUBBED) called");
|
|
|
|
|
2018-10-19 13:01:10 +00:00
|
|
|
IPC::ResponseBuilder rb{ctx, 2};
|
|
|
|
rb.Push(RESULT_SUCCESS);
|
|
|
|
}
|
|
|
|
|
|
|
|
void IApplicationFunctions::BeginBlockingHomeButton(Kernel::HLERequestContext& ctx) {
|
2018-11-26 06:06:13 +00:00
|
|
|
LOG_WARNING(Service_AM, "(STUBBED) called");
|
|
|
|
|
2018-10-19 13:01:10 +00:00
|
|
|
IPC::ResponseBuilder rb{ctx, 2};
|
|
|
|
rb.Push(RESULT_SUCCESS);
|
|
|
|
}
|
|
|
|
|
|
|
|
void IApplicationFunctions::EndBlockingHomeButton(Kernel::HLERequestContext& ctx) {
|
2018-11-26 06:06:13 +00:00
|
|
|
LOG_WARNING(Service_AM, "(STUBBED) called");
|
|
|
|
|
2018-10-19 13:01:10 +00:00
|
|
|
IPC::ResponseBuilder rb{ctx, 2};
|
|
|
|
rb.Push(RESULT_SUCCESS);
|
|
|
|
}
|
|
|
|
|
2018-02-02 21:03:40 +00:00
|
|
|
void IApplicationFunctions::PopLaunchParameter(Kernel::HLERequestContext& ctx) {
|
2018-11-26 06:06:13 +00:00
|
|
|
LOG_DEBUG(Service_AM, "called");
|
|
|
|
|
2018-10-13 17:02:33 +00:00
|
|
|
LaunchParameters params{};
|
2018-10-10 01:49:29 +00:00
|
|
|
|
2018-10-13 17:02:33 +00:00
|
|
|
params.magic = POP_LAUNCH_PARAMETER_MAGIC;
|
|
|
|
params.is_account_selected = 1;
|
2018-10-11 01:49:20 +00:00
|
|
|
|
|
|
|
Account::ProfileManager profile_manager{};
|
2018-10-13 17:02:33 +00:00
|
|
|
const auto uuid = profile_manager.GetUser(Settings::values.current_user);
|
2018-10-30 04:03:25 +00:00
|
|
|
ASSERT(uuid);
|
2018-10-13 17:02:33 +00:00
|
|
|
params.current_user = uuid->uuid;
|
2018-02-02 21:03:40 +00:00
|
|
|
|
|
|
|
IPC::ResponseBuilder rb{ctx, 2, 0, 1};
|
|
|
|
|
|
|
|
rb.Push(RESULT_SUCCESS);
|
2018-10-13 17:02:33 +00:00
|
|
|
|
|
|
|
std::vector<u8> buffer(sizeof(LaunchParameters));
|
|
|
|
std::memcpy(buffer.data(), ¶ms, buffer.size());
|
|
|
|
|
2018-02-02 21:03:40 +00:00
|
|
|
rb.PushIpcInterface<AM::IStorage>(buffer);
|
|
|
|
}
|
|
|
|
|
2018-05-07 15:27:30 +00:00
|
|
|
void IApplicationFunctions::CreateApplicationAndRequestToStartForQuest(
|
|
|
|
Kernel::HLERequestContext& ctx) {
|
2018-11-26 06:06:13 +00:00
|
|
|
LOG_WARNING(Service_AM, "(STUBBED) called");
|
|
|
|
|
2018-05-07 15:27:30 +00:00
|
|
|
IPC::ResponseBuilder rb{ctx, 2};
|
|
|
|
rb.Push(RESULT_SUCCESS);
|
|
|
|
}
|
|
|
|
|
2018-02-06 01:58:11 +00:00
|
|
|
void IApplicationFunctions::EnsureSaveData(Kernel::HLERequestContext& ctx) {
|
2018-03-04 18:03:58 +00:00
|
|
|
IPC::RequestParser rp{ctx};
|
2018-07-17 19:42:15 +00:00
|
|
|
u128 uid = rp.PopRaw<u128>(); // What does this do?
|
2018-07-02 16:13:26 +00:00
|
|
|
LOG_WARNING(Service, "(STUBBED) called uid = {:016X}{:016X}", uid[1], uid[0]);
|
2018-03-04 18:03:58 +00:00
|
|
|
|
2018-02-18 23:09:52 +00:00
|
|
|
IPC::ResponseBuilder rb{ctx, 4};
|
2018-07-17 19:42:15 +00:00
|
|
|
rb.Push(RESULT_SUCCESS);
|
2018-02-18 23:09:52 +00:00
|
|
|
rb.Push<u64>(0);
|
2018-07-17 19:42:15 +00:00
|
|
|
} // namespace Service::AM
|
2018-02-06 01:58:11 +00:00
|
|
|
|
2018-02-02 21:03:40 +00:00
|
|
|
void IApplicationFunctions::SetTerminateResult(Kernel::HLERequestContext& ctx) {
|
|
|
|
// Takes an input u32 Result, no output.
|
2018-11-17 14:05:55 +00:00
|
|
|
// For example, in some cases official apps use this with error 0x2A2 then
|
|
|
|
// uses svcBreak.
|
2018-02-02 21:03:40 +00:00
|
|
|
|
|
|
|
IPC::RequestParser rp{ctx};
|
|
|
|
u32 result = rp.Pop<u32>();
|
2018-11-26 06:06:13 +00:00
|
|
|
LOG_WARNING(Service_AM, "(STUBBED) called, result=0x{:08X}", result);
|
2018-02-02 21:03:40 +00:00
|
|
|
|
|
|
|
IPC::ResponseBuilder rb{ctx, 2};
|
|
|
|
rb.Push(RESULT_SUCCESS);
|
|
|
|
}
|
|
|
|
|
2018-05-26 04:21:03 +00:00
|
|
|
void IApplicationFunctions::GetDisplayVersion(Kernel::HLERequestContext& ctx) {
|
2018-11-26 06:06:13 +00:00
|
|
|
LOG_WARNING(Service_AM, "(STUBBED) called");
|
|
|
|
|
2018-05-26 04:21:03 +00:00
|
|
|
IPC::ResponseBuilder rb{ctx, 6};
|
|
|
|
rb.Push(RESULT_SUCCESS);
|
|
|
|
rb.Push<u64>(1);
|
|
|
|
rb.Push<u64>(0);
|
|
|
|
}
|
|
|
|
|
2018-02-02 21:03:40 +00:00
|
|
|
void IApplicationFunctions::GetDesiredLanguage(Kernel::HLERequestContext& ctx) {
|
2018-04-29 00:30:53 +00:00
|
|
|
// TODO(bunnei): This should be configurable
|
2018-11-26 06:06:13 +00:00
|
|
|
LOG_DEBUG(Service_AM, "called");
|
|
|
|
|
2019-05-23 07:55:56 +00:00
|
|
|
// Get supported languages from NACP, if possible
|
|
|
|
// Default to 0 (all languages supported)
|
|
|
|
u32 supported_languages = 0;
|
|
|
|
FileSys::PatchManager pm{Core::System::GetInstance().CurrentProcess()->GetTitleID()};
|
|
|
|
|
|
|
|
const auto res = pm.GetControlMetadata();
|
|
|
|
if (res.first != nullptr) {
|
|
|
|
supported_languages = res.first->GetSupportedLanguages();
|
|
|
|
}
|
|
|
|
|
|
|
|
// Call IApplicationManagerInterface implementation.
|
|
|
|
auto& service_manager = Core::System::GetInstance().ServiceManager();
|
|
|
|
auto ns_am2 = service_manager.GetService<Service::NS::NS>("ns:am2");
|
|
|
|
auto app_man = ns_am2->GetApplicationManagerInterface();
|
|
|
|
|
|
|
|
// Get desired application language
|
|
|
|
const auto res_lang = app_man->GetApplicationDesiredLanguage(supported_languages);
|
|
|
|
if (res_lang.Failed()) {
|
|
|
|
IPC::ResponseBuilder rb{ctx, 2};
|
|
|
|
rb.Push(res_lang.Code());
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
// Convert to settings language code.
|
|
|
|
const auto res_code = app_man->ConvertApplicationLanguageToLanguageCode(*res_lang);
|
|
|
|
if (res_code.Failed()) {
|
|
|
|
IPC::ResponseBuilder rb{ctx, 2};
|
|
|
|
rb.Push(res_code.Code());
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
LOG_DEBUG(Service_AM, "got desired_language={:016X}", *res_code);
|
|
|
|
|
2018-02-02 21:03:40 +00:00
|
|
|
IPC::ResponseBuilder rb{ctx, 4};
|
|
|
|
rb.Push(RESULT_SUCCESS);
|
2019-05-23 07:55:56 +00:00
|
|
|
rb.Push(*res_code);
|
2018-02-02 21:03:40 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void IApplicationFunctions::InitializeGamePlayRecording(Kernel::HLERequestContext& ctx) {
|
2018-11-26 06:06:13 +00:00
|
|
|
LOG_WARNING(Service_AM, "(STUBBED) called");
|
|
|
|
|
2018-02-02 21:03:40 +00:00
|
|
|
IPC::ResponseBuilder rb{ctx, 2};
|
|
|
|
rb.Push(RESULT_SUCCESS);
|
|
|
|
}
|
|
|
|
|
|
|
|
void IApplicationFunctions::SetGamePlayRecordingState(Kernel::HLERequestContext& ctx) {
|
2018-11-26 06:06:13 +00:00
|
|
|
LOG_WARNING(Service_AM, "(STUBBED) called");
|
|
|
|
|
2018-02-02 21:03:40 +00:00
|
|
|
IPC::ResponseBuilder rb{ctx, 2};
|
|
|
|
rb.Push(RESULT_SUCCESS);
|
|
|
|
}
|
|
|
|
|
|
|
|
void IApplicationFunctions::NotifyRunning(Kernel::HLERequestContext& ctx) {
|
2018-11-26 06:06:13 +00:00
|
|
|
LOG_WARNING(Service_AM, "(STUBBED) called");
|
|
|
|
|
2018-02-02 21:03:40 +00:00
|
|
|
IPC::ResponseBuilder rb{ctx, 3};
|
|
|
|
rb.Push(RESULT_SUCCESS);
|
|
|
|
rb.Push<u8>(0); // Unknown, seems to be ignored by official processes
|
|
|
|
}
|
|
|
|
|
2018-06-05 22:44:01 +00:00
|
|
|
void IApplicationFunctions::GetPseudoDeviceId(Kernel::HLERequestContext& ctx) {
|
2018-11-26 06:06:13 +00:00
|
|
|
LOG_WARNING(Service_AM, "(STUBBED) called");
|
|
|
|
|
2018-06-05 22:44:01 +00:00
|
|
|
IPC::ResponseBuilder rb{ctx, 6};
|
|
|
|
rb.Push(RESULT_SUCCESS);
|
|
|
|
|
|
|
|
// Returns a 128-bit UUID
|
|
|
|
rb.Push<u64>(0);
|
|
|
|
rb.Push<u64>(0);
|
|
|
|
}
|
|
|
|
|
2018-12-11 03:17:45 +00:00
|
|
|
void IApplicationFunctions::ExtendSaveData(Kernel::HLERequestContext& ctx) {
|
|
|
|
IPC::RequestParser rp{ctx};
|
|
|
|
const auto type{rp.PopRaw<FileSys::SaveDataType>()};
|
|
|
|
rp.Skip(1, false);
|
|
|
|
const auto user_id{rp.PopRaw<u128>()};
|
|
|
|
const auto new_normal_size{rp.PopRaw<u64>()};
|
|
|
|
const auto new_journal_size{rp.PopRaw<u64>()};
|
|
|
|
|
|
|
|
LOG_DEBUG(Service_AM,
|
|
|
|
"called with type={:02X}, user_id={:016X}{:016X}, new_normal={:016X}, "
|
|
|
|
"new_journal={:016X}",
|
|
|
|
static_cast<u8>(type), user_id[1], user_id[0], new_normal_size, new_journal_size);
|
|
|
|
|
|
|
|
FileSystem::WriteSaveDataSize(type, Core::CurrentProcess()->GetTitleID(), user_id,
|
|
|
|
{new_normal_size, new_journal_size});
|
|
|
|
|
|
|
|
IPC::ResponseBuilder rb{ctx, 4};
|
|
|
|
rb.Push(RESULT_SUCCESS);
|
|
|
|
|
|
|
|
// The following value is used upon failure to help the system recover.
|
|
|
|
// Since we always succeed, this should be 0.
|
|
|
|
rb.Push<u64>(0);
|
|
|
|
}
|
|
|
|
|
|
|
|
void IApplicationFunctions::GetSaveDataSize(Kernel::HLERequestContext& ctx) {
|
|
|
|
IPC::RequestParser rp{ctx};
|
|
|
|
const auto type{rp.PopRaw<FileSys::SaveDataType>()};
|
|
|
|
rp.Skip(1, false);
|
|
|
|
const auto user_id{rp.PopRaw<u128>()};
|
|
|
|
|
|
|
|
LOG_DEBUG(Service_AM, "called with type={:02X}, user_id={:016X}{:016X}", static_cast<u8>(type),
|
|
|
|
user_id[1], user_id[0]);
|
|
|
|
|
|
|
|
const auto size =
|
|
|
|
FileSystem::ReadSaveDataSize(type, Core::CurrentProcess()->GetTitleID(), user_id);
|
|
|
|
|
|
|
|
IPC::ResponseBuilder rb{ctx, 6};
|
|
|
|
rb.Push(RESULT_SUCCESS);
|
|
|
|
rb.Push(size.normal);
|
|
|
|
rb.Push(size.journal);
|
|
|
|
}
|
|
|
|
|
2019-09-04 15:43:04 +00:00
|
|
|
void IApplicationFunctions::GetGpuErrorDetectedSystemEvent(Kernel::HLERequestContext& ctx) {
|
|
|
|
LOG_WARNING(Service_AM, "(STUBBED) called");
|
|
|
|
|
|
|
|
IPC::ResponseBuilder rb{ctx, 2, 1};
|
|
|
|
rb.Push(RESULT_SUCCESS);
|
|
|
|
rb.PushCopyObjects(gpu_error_detected_event.readable);
|
|
|
|
}
|
|
|
|
|
2018-01-22 18:46:36 +00:00
|
|
|
void InstallInterfaces(SM::ServiceManager& service_manager,
|
2019-06-06 23:46:36 +00:00
|
|
|
std::shared_ptr<NVFlinger::NVFlinger> nvflinger, Core::System& system) {
|
2018-11-07 07:01:33 +00:00
|
|
|
auto message_queue = std::make_shared<AppletMessageQueue>();
|
2018-11-17 14:05:55 +00:00
|
|
|
message_queue->PushMessage(AppletMessageQueue::AppletMessage::FocusStateChanged); // Needed on
|
|
|
|
// game boot
|
2018-11-07 07:01:33 +00:00
|
|
|
|
2019-06-06 23:46:36 +00:00
|
|
|
std::make_shared<AppletAE>(nvflinger, message_queue, system)->InstallAsService(service_manager);
|
|
|
|
std::make_shared<AppletOE>(nvflinger, message_queue, system)->InstallAsService(service_manager);
|
2018-07-31 11:01:49 +00:00
|
|
|
std::make_shared<IdleSys>()->InstallAsService(service_manager);
|
|
|
|
std::make_shared<OMM>()->InstallAsService(service_manager);
|
|
|
|
std::make_shared<SPSM>()->InstallAsService(service_manager);
|
2018-10-21 20:48:58 +00:00
|
|
|
std::make_shared<TCAP>()->InstallAsService(service_manager);
|
2017-10-15 02:50:04 +00:00
|
|
|
}
|
|
|
|
|
2018-05-07 15:27:30 +00:00
|
|
|
IHomeMenuFunctions::IHomeMenuFunctions() : ServiceFramework("IHomeMenuFunctions") {
|
2018-10-21 20:40:17 +00:00
|
|
|
// clang-format off
|
2018-05-07 15:27:30 +00:00
|
|
|
static const FunctionInfo functions[] = {
|
|
|
|
{10, &IHomeMenuFunctions::RequestToGetForeground, "RequestToGetForeground"},
|
|
|
|
{11, nullptr, "LockForeground"},
|
|
|
|
{12, nullptr, "UnlockForeground"},
|
|
|
|
{20, nullptr, "PopFromGeneralChannel"},
|
|
|
|
{21, nullptr, "GetPopFromGeneralChannelEvent"},
|
|
|
|
{30, nullptr, "GetHomeButtonWriterLockAccessor"},
|
|
|
|
{31, nullptr, "GetWriterLockAccessorEx"},
|
2018-10-21 20:40:17 +00:00
|
|
|
{100, nullptr, "PopRequestLaunchApplicationForDebug"},
|
2018-05-07 15:27:30 +00:00
|
|
|
};
|
2018-10-21 20:40:17 +00:00
|
|
|
// clang-format on
|
|
|
|
|
2018-05-07 15:27:30 +00:00
|
|
|
RegisterHandlers(functions);
|
|
|
|
}
|
|
|
|
|
hle/service: Default constructors and destructors in the cpp file where applicable
When a destructor isn't defaulted into a cpp file, it can cause the use
of forward declarations to seemingly fail to compile for non-obvious
reasons. It also allows inlining of the construction/destruction logic
all over the place where a constructor or destructor is invoked, which
can lead to code bloat. This isn't so much a worry here, given the
services won't be created and destroyed frequently.
The cause of the above mentioned non-obvious errors can be demonstrated
as follows:
------- Demonstrative example, if you know how the described error happens, skip forwards -------
Assume we have the following in the header, which we'll call "thing.h":
\#include <memory>
// Forward declaration. For example purposes, assume the definition
// of Object is in some header named "object.h"
class Object;
class Thing {
public:
// assume no constructors or destructors are specified here,
// or the constructors/destructors are defined as:
//
// Thing() = default;
// ~Thing() = default;
//
// ... Some interface member functions would be defined here
private:
std::shared_ptr<Object> obj;
};
If this header is included in a cpp file, (which we'll call "main.cpp"),
this will result in a compilation error, because even though no
destructor is specified, the destructor will still need to be generated by
the compiler because std::shared_ptr's destructor is *not* trivial (in
other words, it does something other than nothing), as std::shared_ptr's
destructor needs to do two things:
1. Decrement the shared reference count of the object being pointed to,
and if the reference count decrements to zero,
2. Free the Object instance's memory (aka deallocate the memory it's
pointing to).
And so the compiler generates the code for the destructor doing this inside main.cpp.
Now, keep in mind, the Object forward declaration is not a complete type. All it
does is tell the compiler "a type named Object exists" and allows us to
use the name in certain situations to avoid a header dependency. So the
compiler needs to generate destruction code for Object, but the compiler
doesn't know *how* to destruct it. A forward declaration doesn't tell
the compiler anything about Object's constructor or destructor. So, the
compiler will issue an error in this case because it's undefined
behavior to try and deallocate (or construct) an incomplete type and
std::shared_ptr and std::unique_ptr make sure this isn't the case
internally.
Now, if we had defaulted the destructor in "thing.cpp", where we also
include "object.h", this would never be an issue, as the destructor
would only have its code generated in one place, and it would be in a
place where the full class definition of Object would be visible to the
compiler.
---------------------- End example ----------------------------
Given these service classes are more than certainly going to change in
the future, this defaults the constructors and destructors into the
relevant cpp files to make the construction and destruction of all of
the services consistent and unlikely to run into cases where forward
declarations are indirectly causing compilation errors. It also has the
plus of avoiding the need to rebuild several services if destruction
logic changes, since it would only be necessary to recompile the single
cpp file.
2018-09-11 01:20:52 +00:00
|
|
|
IHomeMenuFunctions::~IHomeMenuFunctions() = default;
|
|
|
|
|
2018-05-07 15:27:30 +00:00
|
|
|
void IHomeMenuFunctions::RequestToGetForeground(Kernel::HLERequestContext& ctx) {
|
2018-11-26 06:06:13 +00:00
|
|
|
LOG_WARNING(Service_AM, "(STUBBED) called");
|
|
|
|
|
2018-05-07 15:27:30 +00:00
|
|
|
IPC::ResponseBuilder rb{ctx, 2};
|
|
|
|
rb.Push(RESULT_SUCCESS);
|
|
|
|
}
|
|
|
|
|
|
|
|
IGlobalStateController::IGlobalStateController() : ServiceFramework("IGlobalStateController") {
|
2018-10-21 20:40:17 +00:00
|
|
|
// clang-format off
|
2018-05-07 15:27:30 +00:00
|
|
|
static const FunctionInfo functions[] = {
|
|
|
|
{0, nullptr, "RequestToEnterSleep"},
|
|
|
|
{1, nullptr, "EnterSleep"},
|
|
|
|
{2, nullptr, "StartSleepSequence"},
|
|
|
|
{3, nullptr, "StartShutdownSequence"},
|
|
|
|
{4, nullptr, "StartRebootSequence"},
|
2019-04-10 18:48:37 +00:00
|
|
|
{9, nullptr, "IsAutoPowerDownRequested"},
|
2018-05-07 15:27:30 +00:00
|
|
|
{10, nullptr, "LoadAndApplyIdlePolicySettings"},
|
|
|
|
{11, nullptr, "NotifyCecSettingsChanged"},
|
|
|
|
{12, nullptr, "SetDefaultHomeButtonLongPressTime"},
|
|
|
|
{13, nullptr, "UpdateDefaultDisplayResolution"},
|
|
|
|
{14, nullptr, "ShouldSleepOnBoot"},
|
|
|
|
{15, nullptr, "GetHdcpAuthenticationFailedEvent"},
|
|
|
|
};
|
2018-10-21 20:40:17 +00:00
|
|
|
// clang-format on
|
|
|
|
|
2018-05-07 15:27:30 +00:00
|
|
|
RegisterHandlers(functions);
|
|
|
|
}
|
|
|
|
|
hle/service: Default constructors and destructors in the cpp file where applicable
When a destructor isn't defaulted into a cpp file, it can cause the use
of forward declarations to seemingly fail to compile for non-obvious
reasons. It also allows inlining of the construction/destruction logic
all over the place where a constructor or destructor is invoked, which
can lead to code bloat. This isn't so much a worry here, given the
services won't be created and destroyed frequently.
The cause of the above mentioned non-obvious errors can be demonstrated
as follows:
------- Demonstrative example, if you know how the described error happens, skip forwards -------
Assume we have the following in the header, which we'll call "thing.h":
\#include <memory>
// Forward declaration. For example purposes, assume the definition
// of Object is in some header named "object.h"
class Object;
class Thing {
public:
// assume no constructors or destructors are specified here,
// or the constructors/destructors are defined as:
//
// Thing() = default;
// ~Thing() = default;
//
// ... Some interface member functions would be defined here
private:
std::shared_ptr<Object> obj;
};
If this header is included in a cpp file, (which we'll call "main.cpp"),
this will result in a compilation error, because even though no
destructor is specified, the destructor will still need to be generated by
the compiler because std::shared_ptr's destructor is *not* trivial (in
other words, it does something other than nothing), as std::shared_ptr's
destructor needs to do two things:
1. Decrement the shared reference count of the object being pointed to,
and if the reference count decrements to zero,
2. Free the Object instance's memory (aka deallocate the memory it's
pointing to).
And so the compiler generates the code for the destructor doing this inside main.cpp.
Now, keep in mind, the Object forward declaration is not a complete type. All it
does is tell the compiler "a type named Object exists" and allows us to
use the name in certain situations to avoid a header dependency. So the
compiler needs to generate destruction code for Object, but the compiler
doesn't know *how* to destruct it. A forward declaration doesn't tell
the compiler anything about Object's constructor or destructor. So, the
compiler will issue an error in this case because it's undefined
behavior to try and deallocate (or construct) an incomplete type and
std::shared_ptr and std::unique_ptr make sure this isn't the case
internally.
Now, if we had defaulted the destructor in "thing.cpp", where we also
include "object.h", this would never be an issue, as the destructor
would only have its code generated in one place, and it would be in a
place where the full class definition of Object would be visible to the
compiler.
---------------------- End example ----------------------------
Given these service classes are more than certainly going to change in
the future, this defaults the constructors and destructors into the
relevant cpp files to make the construction and destruction of all of
the services consistent and unlikely to run into cases where forward
declarations are indirectly causing compilation errors. It also has the
plus of avoiding the need to rebuild several services if destruction
logic changes, since it would only be necessary to recompile the single
cpp file.
2018-09-11 01:20:52 +00:00
|
|
|
IGlobalStateController::~IGlobalStateController() = default;
|
|
|
|
|
2018-05-07 15:27:30 +00:00
|
|
|
IApplicationCreator::IApplicationCreator() : ServiceFramework("IApplicationCreator") {
|
2018-10-21 20:40:17 +00:00
|
|
|
// clang-format off
|
2018-05-07 15:27:30 +00:00
|
|
|
static const FunctionInfo functions[] = {
|
|
|
|
{0, nullptr, "CreateApplication"},
|
|
|
|
{1, nullptr, "PopLaunchRequestedApplication"},
|
|
|
|
{10, nullptr, "CreateSystemApplication"},
|
|
|
|
{100, nullptr, "PopFloatingApplicationForDevelopment"},
|
|
|
|
};
|
2018-10-21 20:40:17 +00:00
|
|
|
// clang-format on
|
|
|
|
|
2018-05-07 15:27:30 +00:00
|
|
|
RegisterHandlers(functions);
|
|
|
|
}
|
|
|
|
|
hle/service: Default constructors and destructors in the cpp file where applicable
When a destructor isn't defaulted into a cpp file, it can cause the use
of forward declarations to seemingly fail to compile for non-obvious
reasons. It also allows inlining of the construction/destruction logic
all over the place where a constructor or destructor is invoked, which
can lead to code bloat. This isn't so much a worry here, given the
services won't be created and destroyed frequently.
The cause of the above mentioned non-obvious errors can be demonstrated
as follows:
------- Demonstrative example, if you know how the described error happens, skip forwards -------
Assume we have the following in the header, which we'll call "thing.h":
\#include <memory>
// Forward declaration. For example purposes, assume the definition
// of Object is in some header named "object.h"
class Object;
class Thing {
public:
// assume no constructors or destructors are specified here,
// or the constructors/destructors are defined as:
//
// Thing() = default;
// ~Thing() = default;
//
// ... Some interface member functions would be defined here
private:
std::shared_ptr<Object> obj;
};
If this header is included in a cpp file, (which we'll call "main.cpp"),
this will result in a compilation error, because even though no
destructor is specified, the destructor will still need to be generated by
the compiler because std::shared_ptr's destructor is *not* trivial (in
other words, it does something other than nothing), as std::shared_ptr's
destructor needs to do two things:
1. Decrement the shared reference count of the object being pointed to,
and if the reference count decrements to zero,
2. Free the Object instance's memory (aka deallocate the memory it's
pointing to).
And so the compiler generates the code for the destructor doing this inside main.cpp.
Now, keep in mind, the Object forward declaration is not a complete type. All it
does is tell the compiler "a type named Object exists" and allows us to
use the name in certain situations to avoid a header dependency. So the
compiler needs to generate destruction code for Object, but the compiler
doesn't know *how* to destruct it. A forward declaration doesn't tell
the compiler anything about Object's constructor or destructor. So, the
compiler will issue an error in this case because it's undefined
behavior to try and deallocate (or construct) an incomplete type and
std::shared_ptr and std::unique_ptr make sure this isn't the case
internally.
Now, if we had defaulted the destructor in "thing.cpp", where we also
include "object.h", this would never be an issue, as the destructor
would only have its code generated in one place, and it would be in a
place where the full class definition of Object would be visible to the
compiler.
---------------------- End example ----------------------------
Given these service classes are more than certainly going to change in
the future, this defaults the constructors and destructors into the
relevant cpp files to make the construction and destruction of all of
the services consistent and unlikely to run into cases where forward
declarations are indirectly causing compilation errors. It also has the
plus of avoiding the need to rebuild several services if destruction
logic changes, since it would only be necessary to recompile the single
cpp file.
2018-09-11 01:20:52 +00:00
|
|
|
IApplicationCreator::~IApplicationCreator() = default;
|
|
|
|
|
2018-05-07 15:27:30 +00:00
|
|
|
IProcessWindingController::IProcessWindingController()
|
|
|
|
: ServiceFramework("IProcessWindingController") {
|
2018-10-21 20:40:17 +00:00
|
|
|
// clang-format off
|
2018-05-07 15:27:30 +00:00
|
|
|
static const FunctionInfo functions[] = {
|
|
|
|
{0, nullptr, "GetLaunchReason"},
|
|
|
|
{11, nullptr, "OpenCallingLibraryApplet"},
|
|
|
|
{21, nullptr, "PushContext"},
|
|
|
|
{22, nullptr, "PopContext"},
|
|
|
|
{23, nullptr, "CancelWindingReservation"},
|
|
|
|
{30, nullptr, "WindAndDoReserved"},
|
|
|
|
{40, nullptr, "ReserveToStartAndWaitAndUnwindThis"},
|
|
|
|
{41, nullptr, "ReserveToStartAndWait"},
|
|
|
|
};
|
2018-10-21 20:40:17 +00:00
|
|
|
// clang-format on
|
|
|
|
|
2018-05-07 15:27:30 +00:00
|
|
|
RegisterHandlers(functions);
|
|
|
|
}
|
hle/service: Default constructors and destructors in the cpp file where applicable
When a destructor isn't defaulted into a cpp file, it can cause the use
of forward declarations to seemingly fail to compile for non-obvious
reasons. It also allows inlining of the construction/destruction logic
all over the place where a constructor or destructor is invoked, which
can lead to code bloat. This isn't so much a worry here, given the
services won't be created and destroyed frequently.
The cause of the above mentioned non-obvious errors can be demonstrated
as follows:
------- Demonstrative example, if you know how the described error happens, skip forwards -------
Assume we have the following in the header, which we'll call "thing.h":
\#include <memory>
// Forward declaration. For example purposes, assume the definition
// of Object is in some header named "object.h"
class Object;
class Thing {
public:
// assume no constructors or destructors are specified here,
// or the constructors/destructors are defined as:
//
// Thing() = default;
// ~Thing() = default;
//
// ... Some interface member functions would be defined here
private:
std::shared_ptr<Object> obj;
};
If this header is included in a cpp file, (which we'll call "main.cpp"),
this will result in a compilation error, because even though no
destructor is specified, the destructor will still need to be generated by
the compiler because std::shared_ptr's destructor is *not* trivial (in
other words, it does something other than nothing), as std::shared_ptr's
destructor needs to do two things:
1. Decrement the shared reference count of the object being pointed to,
and if the reference count decrements to zero,
2. Free the Object instance's memory (aka deallocate the memory it's
pointing to).
And so the compiler generates the code for the destructor doing this inside main.cpp.
Now, keep in mind, the Object forward declaration is not a complete type. All it
does is tell the compiler "a type named Object exists" and allows us to
use the name in certain situations to avoid a header dependency. So the
compiler needs to generate destruction code for Object, but the compiler
doesn't know *how* to destruct it. A forward declaration doesn't tell
the compiler anything about Object's constructor or destructor. So, the
compiler will issue an error in this case because it's undefined
behavior to try and deallocate (or construct) an incomplete type and
std::shared_ptr and std::unique_ptr make sure this isn't the case
internally.
Now, if we had defaulted the destructor in "thing.cpp", where we also
include "object.h", this would never be an issue, as the destructor
would only have its code generated in one place, and it would be in a
place where the full class definition of Object would be visible to the
compiler.
---------------------- End example ----------------------------
Given these service classes are more than certainly going to change in
the future, this defaults the constructors and destructors into the
relevant cpp files to make the construction and destruction of all of
the services consistent and unlikely to run into cases where forward
declarations are indirectly causing compilation errors. It also has the
plus of avoiding the need to rebuild several services if destruction
logic changes, since it would only be necessary to recompile the single
cpp file.
2018-09-11 01:20:52 +00:00
|
|
|
|
|
|
|
IProcessWindingController::~IProcessWindingController() = default;
|
2018-04-20 01:41:44 +00:00
|
|
|
} // namespace Service::AM
|